@vertesia/ui 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/components/SelectList.d.ts.map +1 -1
- package/lib/core/components/SelectList.js +3 -3
- package/lib/core/components/SelectList.js.map +1 -1
- package/lib/core/components/SidePanel.d.ts.map +1 -1
- package/lib/core/components/SidePanel.js +2 -1
- package/lib/core/components/SidePanel.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.js +51 -17
- package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts +5 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js +9 -2
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
- package/lib/features/agent/chat/hooks/useAgentPlans.d.ts +1 -1
- package/lib/features/agent/chat/hooks/useAgentPlans.d.ts.map +1 -1
- package/lib/features/agent/chat/hooks/useAgentPlans.js +5 -5
- package/lib/features/agent/chat/hooks/useAgentPlans.js.map +1 -1
- package/lib/features/magic-pdf/GroundedExtractionView.js +3 -3
- package/lib/features/magic-pdf/GroundedExtractionView.js.map +1 -1
- package/lib/features/oauth/McpConnectionsButton.d.ts +2 -2
- package/lib/features/oauth/McpConnectionsButton.d.ts.map +1 -1
- package/lib/features/oauth/McpConnectionsButton.js +9 -7
- package/lib/features/oauth/McpConnectionsButton.js.map +1 -1
- package/lib/features/oauth/McpConnectionsDialog.d.ts.map +1 -1
- package/lib/features/oauth/McpConnectionsDialog.js +7 -3
- package/lib/features/oauth/McpConnectionsDialog.js.map +1 -1
- package/lib/features/oauth/useMcpConnections.d.ts +4 -2
- package/lib/features/oauth/useMcpConnections.d.ts.map +1 -1
- package/lib/features/oauth/useMcpConnections.js +15 -9
- package/lib/features/oauth/useMcpConnections.js.map +1 -1
- package/lib/features/store/objects/selection/ObjectsActionContext.d.ts.map +1 -1
- package/lib/features/store/objects/selection/ObjectsActionContext.js +2 -0
- package/lib/features/store/objects/selection/ObjectsActionContext.js.map +1 -1
- package/lib/features/store/objects/selection/SelectionActions.d.ts +4 -2
- package/lib/features/store/objects/selection/SelectionActions.d.ts.map +1 -1
- package/lib/features/store/objects/selection/SelectionActions.js +6 -3
- package/lib/features/store/objects/selection/SelectionActions.js.map +1 -1
- package/lib/features/store/objects/selection/actions/RunIntakeAction.d.ts +8 -0
- package/lib/features/store/objects/selection/actions/RunIntakeAction.d.ts.map +1 -0
- package/lib/features/store/objects/selection/actions/RunIntakeAction.js +65 -0
- package/lib/features/store/objects/selection/actions/RunIntakeAction.js.map +1 -0
- package/lib/features/store/objects/selection/actions/index.d.ts +1 -0
- package/lib/features/store/objects/selection/actions/index.d.ts.map +1 -1
- package/lib/features/store/objects/selection/actions/index.js +1 -0
- package/lib/features/store/objects/selection/actions/index.js.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.d.ts.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.js +11 -3
- package/lib/features/store/types/ContentObjectTypesTable.js.map +1 -1
- package/lib/features/store/types/IntakePolicyEditor.d.ts.map +1 -1
- package/lib/features/store/types/IntakePolicyEditor.js +14 -14
- package/lib/features/store/types/IntakePolicyEditor.js.map +1 -1
- package/lib/features/store/types/TypeRegistry.d.ts +275 -150
- package/lib/features/store/types/TypeRegistry.d.ts.map +1 -1
- package/lib/features/store/types/search/ObjectTypeSearchContext.d.ts +275 -150
- package/lib/features/store/types/search/ObjectTypeSearchContext.d.ts.map +1 -1
- package/lib/i18n/locales/ar.json +28 -7
- package/lib/i18n/locales/de.json +24 -7
- package/lib/i18n/locales/en.json +24 -7
- package/lib/i18n/locales/es.json +24 -7
- package/lib/i18n/locales/fr.json +25 -7
- package/lib/i18n/locales/it.json +24 -7
- package/lib/i18n/locales/ja.json +24 -7
- package/lib/i18n/locales/ko.json +24 -7
- package/lib/i18n/locales/pt.json +24 -7
- package/lib/i18n/locales/ru.json +26 -7
- package/lib/i18n/locales/tr.json +24 -7
- package/lib/i18n/locales/zh-TW.json +24 -7
- package/lib/i18n/locales/zh.json +24 -7
- package/lib/shell/apps/AppInstallationProvider.d.ts +4 -4
- package/lib/shell/login/SignInIcons.d.ts.map +1 -1
- package/lib/shell/login/SignInIcons.js +2 -1
- package/lib/shell/login/SignInIcons.js.map +1 -1
- package/lib/shell/login/SignInPasswordStep.d.ts +9 -0
- package/lib/shell/login/SignInPasswordStep.d.ts.map +1 -0
- package/lib/shell/login/SignInPasswordStep.js +58 -0
- package/lib/shell/login/SignInPasswordStep.js.map +1 -0
- package/lib/shell/login/SignInPrimitives.d.ts +13 -0
- package/lib/shell/login/SignInPrimitives.d.ts.map +1 -1
- package/lib/shell/login/SignInPrimitives.js +11 -1
- package/lib/shell/login/SignInPrimitives.js.map +1 -1
- package/lib/shell/login/SignInProvidersStep.d.ts +3 -1
- package/lib/shell/login/SignInProvidersStep.d.ts.map +1 -1
- package/lib/shell/login/SignInProvidersStep.js +4 -2
- package/lib/shell/login/SignInProvidersStep.js.map +1 -1
- package/lib/shell/login/SignInReturningStep.d.ts +3 -1
- package/lib/shell/login/SignInReturningStep.d.ts.map +1 -1
- package/lib/shell/login/SignInReturningStep.js +18 -8
- package/lib/shell/login/SignInReturningStep.js.map +1 -1
- package/lib/shell/login/SignInTenantStep.d.ts +3 -1
- package/lib/shell/login/SignInTenantStep.d.ts.map +1 -1
- package/lib/shell/login/SignInTenantStep.js +2 -2
- package/lib/shell/login/SignInTenantStep.js.map +1 -1
- package/lib/shell/login/SignInWithProviderButton.d.ts +5 -3
- package/lib/shell/login/SignInWithProviderButton.d.ts.map +1 -1
- package/lib/shell/login/SignInWithProviderButton.js +8 -7
- package/lib/shell/login/SignInWithProviderButton.js.map +1 -1
- package/lib/shell/login/SigninScreen.d.ts.map +1 -1
- package/lib/shell/login/SigninScreen.js +13 -4
- package/lib/shell/login/SigninScreen.js.map +1 -1
- package/lib/shell/login/signInUtils.d.ts +20 -4
- package/lib/shell/login/signInUtils.d.ts.map +1 -1
- package/lib/shell/login/signInUtils.js +47 -1
- package/lib/shell/login/signInUtils.js.map +1 -1
- package/lib/vertesia-ui-core.js +1 -1
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-features.js +14 -14
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-i18n.BoNE1APG.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.BoNE1APG.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.BoPtiSPb.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.BoPtiSPb.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.C4BBW5v5.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.C4BBW5v5.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.C81wuNkY.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.C81wuNkY.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.C9GipKIH.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.C9GipKIH.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.CWsoS0W9.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.CWsoS0W9.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.Cr9NtzZB.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.Cr9NtzZB.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.DEpkHOD5.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.DEpkHOD5.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.DPXaRKFO.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.DPXaRKFO.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.D_QNm1Xg.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.D_QNm1Xg.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.F26Cc0f7.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.F26Cc0f7.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.YkXIESV_.chunk.js +5 -0
- package/lib/vertesia-ui-i18n.YkXIESV_.chunk.js.map +1 -0
- package/lib/vertesia-ui-i18n.js +3 -3
- package/lib/vertesia-ui-i18n.js.map +1 -1
- package/lib/vertesia-ui-shell.js +15 -9
- package/lib/vertesia-ui-shell.js.map +1 -1
- package/lib/widgets/xml-viewer/hooks/useCollapsible.d.ts +1 -1
- package/package.json +7 -7
- package/src/core/components/SelectList.tsx +5 -2
- package/src/core/components/SidePanel.tsx +65 -60
- package/src/features/agent/chat/ModernAgentConversation.test.tsx +150 -1
- package/src/features/agent/chat/ModernAgentConversation.tsx +59 -21
- package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +17 -1
- package/src/features/agent/chat/hooks/useAgentPlans.test.ts +52 -0
- package/src/features/agent/chat/hooks/useAgentPlans.ts +5 -5
- package/src/features/magic-pdf/GroundedExtractionView.tsx +3 -3
- package/src/features/oauth/McpConnectionsButton.test.tsx +56 -0
- package/src/features/oauth/McpConnectionsButton.tsx +9 -6
- package/src/features/oauth/McpConnectionsDialog.tsx +14 -5
- package/src/features/oauth/useMcpConnections.test.ts +10 -0
- package/src/features/oauth/useMcpConnections.ts +18 -10
- package/src/features/store/objects/selection/ObjectsActionContext.tsx +2 -0
- package/src/features/store/objects/selection/SelectionActions.tsx +13 -6
- package/src/features/store/objects/selection/actions/RunIntakeAction.tsx +69 -0
- package/src/features/store/objects/selection/actions/index.ts +1 -0
- package/src/features/store/types/ContentObjectTypesTable.tsx +20 -3
- package/src/features/store/types/IntakePolicyEditor.tsx +33 -28
- package/src/i18n/locales/ar.json +28 -7
- package/src/i18n/locales/de.json +24 -7
- package/src/i18n/locales/en.json +24 -7
- package/src/i18n/locales/es.json +24 -7
- package/src/i18n/locales/fr.json +25 -7
- package/src/i18n/locales/it.json +24 -7
- package/src/i18n/locales/ja.json +24 -7
- package/src/i18n/locales/ko.json +24 -7
- package/src/i18n/locales/pt.json +24 -7
- package/src/i18n/locales/ru.json +26 -7
- package/src/i18n/locales/tr.json +24 -7
- package/src/i18n/locales/zh-TW.json +24 -7
- package/src/i18n/locales/zh.json +24 -7
- package/src/shell/login/SignInIcons.tsx +2 -1
- package/src/shell/login/SignInPasswordRequired.test.tsx +82 -0
- package/src/shell/login/SignInPasswordStep.test.tsx +71 -0
- package/src/shell/login/SignInPasswordStep.tsx +103 -0
- package/src/shell/login/SignInPrimitives.tsx +53 -1
- package/src/shell/login/SignInProvidersStep.tsx +8 -4
- package/src/shell/login/SignInReturningStep.tsx +20 -8
- package/src/shell/login/SignInTenantStep.tsx +6 -2
- package/src/shell/login/SignInWithProviderButton.tsx +11 -7
- package/src/shell/login/SigninScreen.tsx +32 -3
- package/src/shell/login/signInPassword.test.ts +133 -0
- package/src/shell/login/signInUtils.ts +60 -7
- package/lib/features/store/objects/selection/actions/StartWorkflowButton.d.ts +0 -7
- package/lib/features/store/objects/selection/actions/StartWorkflowButton.d.ts.map +0 -1
- package/lib/features/store/objects/selection/actions/StartWorkflowButton.js +0 -51
- package/lib/features/store/objects/selection/actions/StartWorkflowButton.js.map +0 -1
- package/lib/vertesia-ui-i18n.BfN7iOHb.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.BfN7iOHb.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.BjH2zEZw.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.BjH2zEZw.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.BjSwAZXl.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.BjSwAZXl.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.C7PUm5Au.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.C7PUm5Au.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.CF_1mUS5.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.CF_1mUS5.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.ChfUl3_-.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.ChfUl3_-.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.D-Sk-5d1.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.D-Sk-5d1.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.D4rnu1_S.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.D4rnu1_S.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.DDf0-laK.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.DDf0-laK.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.DN79y06J.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.DN79y06J.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.DWLIciYQ.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.DWLIciYQ.chunk.js.map +0 -1
- package/lib/vertesia-ui-i18n.DvF_YaAJ.chunk.js +0 -5
- package/lib/vertesia-ui-i18n.DvF_YaAJ.chunk.js.map +0 -1
- package/src/features/store/objects/selection/actions/StartWorkflowButton.tsx +0 -104
|
@@ -1249,7 +1249,7 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
1249
1249
|
.agent-markdown tbody tr:hover {
|
|
1250
1250
|
background: transparent;
|
|
1251
1251
|
}
|
|
1252
|
-
`}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,y&&`hidden`),children:t(OK,{workstreams:fe,activeWorkstream:R,onSelectWorkstream:ge,count:ve,completionStatus:it})}),ye.length===0&&Ve.length===0&&!ke&&!(se&&Ze)?R===`all`&&Ye?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(bq,{label:F(`agent.preparing`),timestamp:Oe.current,className:b})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,se?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,x),children:[se&&R!==`all`&&pe&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),onClick:_e,children:t(wm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:pe})]})}),je&&t(yq,{data:T,schema:E,title:D,template:O,prependFriendlyMessage:w,timestamp:ye[0]?.timestamp??Date.now(),isSummaryView:se,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C},`initial-request`),$e&&t(bq,{label:Qe,timestamp:rt,className:b}),s===`stacked`?n(e,{children:[Je.map((e,n)=>{let r=n===Je.length-1;if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!YH.includes(n.type)&&!i;return h?.includes(s)?null:t(CJ,{status:e.toolStatus,children:t(wJ,{children:t(xK,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},qq(e))}if(e.type===`streaming`)return t(CJ,{children:t(MG,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},qq(e));{let i=e.message;if(Te(i)||Ee(i))return null;if(QH(i))return t(CJ,{children:t(xJ,{message:i,startTimestamp:Jq(Je,n)??i.timestamp,endTimestamp:i.timestamp})},Kq(i,`stopped`));let a=!c&&r&&!YH.includes(i.type);return jK(i)?t(wJ,{children:t(YW,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(CJ,{status:`message`,children:t(wJ,{children:t(yG,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:eW(i,be),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C})})},Kq(i))}}),Ve.map(({id:e,data:n})=>t(CJ,{children:t(MG,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Ye&&Ve.length===0&&!$e&&t(CJ,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,b),children:[t(aW,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[Ke.map(e=>{if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=BK(e.messages);return t(SJ,{label:VK(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:PK(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:b,onSendMessage:u,answeredToolApprovalRequestInputKeys:Se,resolvedToolApprovalKeys:xe},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(xJ,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},Kq(e.message,`stopped-summary`));let n=e.message;return Te(n)||Ee(n)?null:jK(n)?t(wJ,{children:t(YW,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},Kq(n,`batch`)):t(wJ,{children:t(uq,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:ge,requestInputAnswered:eW(n,be),StoreLinkComponent:S,CollectionLinkComponent:C})},Kq(n,`summary`))}),Ve.map(({id:e,data:n})=>t(bJ,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Xe&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,b),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Ze&&!$e&&t(SJ,{label:Qe,status:`running`,timestamp:rt,showElapsed:!0,className:b})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const DJ=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},OJ=ot.memo(EJ);Q();function kJ(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function AJ(e,t){return e?.find(e=>e.cursor===t)}function jJ(e,t){if(t===0||e===`live`)return`live`;let n=fC(e,t);return n>=t-1?`live`:n+1}function MJ(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function NJ(e){return MJ(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function PJ(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function FJ({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>dC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>hC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>kJ(AJ(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=dC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=dC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=jJ(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!ZH(E),A=U(()=>tW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;PJ(`${NJ(j)||`agent-chat`}-${NJ(n)}.json`,t)},[e,m.length,j]),N=V(()=>{O(jJ(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(og,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Gv:ry,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(OJ,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(rW,{message:A,onSendMessage:N,isLoading:!1})]})}function IJ({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function LJ(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>An(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`api_key`),c=new Map,l=new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:api-key:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function RJ(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function zJ(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function BJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!RJ(e,t)).length}function VJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!RJ(e,t)).map(e=>e.label)}Q();function HJ({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(mT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(hT,{children:f(`mcpConnections.title`)}),n(gT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(dO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!RJ(e,c),i=e.authStatus?.authenticated===!0,a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?G_:H_,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):a?t(mO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):e.authType===`oauth`?t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:f(`mcpConnections.managedByApp`)}):null,l&&t(lO,{size:`sm`,value:r,onChange:t=>l(zJ(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function UJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=LJ(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=BJ(u,r),_=VJ(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(oT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(uT,{variant:`success`,children:g})]})]}),t(HJ,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function WJ({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=LJ();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!RJ(i,e),c=i.authStatus?.authenticated===!0,u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?G_:H_,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):u?t(mO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(lO,{size:`sm`,value:s,onChange:t=>r(zJ(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function GJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=LJ(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=BJ(c,r);return n(e,{children:[t(HD,{align:`left`,trigger:t(oT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(UD,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(uT,{variant:`success`,children:m})]})}),t(HJ,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}const KJ=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,qJ=/(^|\/)process\/(history|state)(\/|$)/,JJ=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function YJ(e){if(KJ.test(e)||qJ.test(e))return!0;let t=e.split(`/`).pop()??e;return JJ.some(e=>e.test(t))}function XJ(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function ZJ(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function QJ(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>ZJ(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!YJ(e)),[i,r]),h=U(()=>XJ(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function $J(){return eY||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),eY}var eY,tY,nY,rY=Y((()=>{tY=ht(()=>$J().then(({Document:e})=>({default:e}))),nY=ht(()=>$J().then(({Page:e})=>({default:e})))}));function iY({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function aY({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(iY,{className:`py-4`,size:`md`}),t(ut,{fallback:null,children:t(tY,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(nY,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(iY,{className:`py-4`,size:`sm`})})})})]})}function oY({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(pY.Provider,{value:h,children:e?t(ut,{fallback:t(iY,{className:`py-4`,size:`md`}),children:t(tY,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(iY,{className:`py-4`,size:`md`}),children:r((e,n)=>t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(iY,{className:`py-4`,size:`sm`})},e))})}):t(iY,{className:`py-4`,size:`md`})})}function sY(){return _t(pY)}function cY({pageNumber:e,width:n,className:r}){let i=sY(),a=i?.pageDimensions?.aspectRatio??mY,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(iY,{size:`md`})}):t(`div`,{className:r,children:t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(iY,{className:`py-4`,size:`sm`})})})}function lY({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=mY,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(iY,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function uY(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function dY({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(mY),d?.(mY)}},[d,m]),w=y??mY,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||uY(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(iY,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ut,{fallback:t(iY,{className:`py-4`,size:`md`}),children:t(tY,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(iY,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(lY,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(iY,{className:`py-4`,size:`md`})})})})}function fY({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(iY,{className:`py-8`,size:`lg`}),t(ut,{fallback:null,children:t(tY,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(nY,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(iY,{className:`py-8`,size:`md`})})})})]})}var pY,mY,hY=Y((()=>{Q(),rY(),pY=dt(null),mY=210/297}));function gY({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(xY),[x,S]=G(yY),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=bY.findIndex(e=>e>=y);e===-1&&(e=bY.length-1);let t=Math.min(e+1,bY.length-1);b(bY[t])},[y]),O=V(()=>{let e=bY.findIndex(e=>e>=y);e===-1&&(e=bY.length-1);let t=Math.max(e-1,0);b(bY[t])},[y]),k=V(()=>{b(xY)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),N=W(null),P=W(y);H(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=W(!1);H(()=>{let e=g.current;if(!(!e||!C||F.current)){if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0}},[C,s]);let I=W(s);return H(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:it(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:it(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Dh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(vY,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<bY[bY.length-1],canZoomOut:y>bY[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(_Y,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:it(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(dY,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:it(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:it(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:it(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:it(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(hh,{className:`size-4`})})})]})}function _Y({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function vY({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(Av,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(oy,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===xY?`text-muted/40`:void 0,children:t(fv,{})})]})}var yY,bY,xY,SY=Y((()=>{Q(),hY(),yY=210/297,bY=[50,75,100,125,150,200,300],xY=100}));function CY({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(je,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(Gb,{className:`size-4`})})}),t(gY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(gY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(lv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var wY=Y((()=>{Q(),SY()})),TY=mr({UniversalDocumentViewer:()=>XY});function EY(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function DY(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function OY(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function kY(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function AY(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function jY(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function MY(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function NY(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function PY(e){return[`tsx`,`jsx`].includes(e.extension)}function FY(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function IY({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function LY({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(Zg,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function RY(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function zY(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function BY(e){return e.split(`/`).pop()||e}function VY(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function HY(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function UY(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function WY(e){return Array.isArray(e)?e.length:0}function GY(e){try{let t=VY(JSON.parse(e));if(!t)return;let n=VY(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:HY(n.width),height:HY(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:HY(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:VY(t.timings_ms),error:t.error}}catch{return}}async function KY(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function qY({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${BY(i)}`:n}function JY({metadata:e}){if(!e)return null;let r=HY(e.timings_ms?.total_before_cleanup),a=WY(e.console_errors)+WY(e.page_errors)+WY(e.failed_requests)+WY(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),UY(r)&&n(`div`,{children:[`Total `,UY(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function YY({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,BY(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=zY(e,`.png`),r=zY(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=GY(await KY(await d(r,`inline`),BY(r))),o=qY({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(D_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(JY,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(IY,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(JY,{metadata:l.metadata}),t(IY,{content:c,extension:e.extension})]})]})]})}function XY({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>EY(e),[e]),g=U(()=>DY(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${EY(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(kY(P)||jY(P)||MY(P)||NY(P)),L=!F&&(OY(P)||AY(P)),ee={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},R=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(ee)):void 0,te=!F&&!P.url&&(FY(P)||!!R)&&(!!R||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!te)){w(!0);try{if(te){let e=R?await R.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,te,I,L,D,j,R,e,k]);let ne={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(Ah,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:ne.reload,children:`Retry`})]}):F?RY(F,ne):(OY(ne)||x?.contentType===`application/pdf`)&&ne.url?t(CY,{url:ne.url,className:`h-full`}):AY(ne)&&ne.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:ne.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):kY(ne)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(Nt,{artifactRunId:e.artifact?.runId,components:d,children:ne.content||``})}):jY(ne)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:ne.content||``}):MY(ne)?t(`div`,{className:`px-4 py-2`,children:t(Rt,{xml:ne.content||``,collapsible:!0})}):PY(ne)?t(YY,{context:ne}):NY(ne)?t(IY,{content:ne.content,extension:g}):FY(ne)&&!R&&!u?t(LY,{message:`This file needs a PDF rendition before it can be previewed.`}):t(LY,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),ne.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:ne.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var ZY=Y((()=>{Q(),wY()}));Q();const QY=ot.lazy(async()=>({default:(await Promise.resolve().then(()=>(ZY(),TY))).UniversalDocumentViewer})),$Y=new Set([`md`,`markdown`,`mdx`,`txt`]);function eX(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&$Y.has(t)}function tX(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function nX({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(rh,{className:`size-3.5 shrink-0 text-muted`}):t(lh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?r_:o_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:tX(e.name)})]}),p&&e.children.map(e=>t(nX,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(Zg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(ev,{className:`size-3.5 animate-spin text-info`}):t(xg,{className:`size-3.5`})})]})}function rX(e){return e.reduce((e,t)=>t.isDirectory?e+rX(t.children):e+1,0)}function iX(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=iX(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function aX(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function oX(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function sX({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(We,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(ev,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(We,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(eh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(xy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(Jv,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(xg,{className:`size-4`})})]}),t(wt,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function cX({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function lX({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=QJ(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),N=E.trim(),P=U(()=>iX(h,N),[h,N]),F=U(()=>rX(P),[P]),I=vt(),L=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);aX(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),ee=V(e=>{if(eX(e)){j(e);return}T(e)},[j]),R=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:oX(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(cX,{icon:t(ev,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(M,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(cX,{icon:t(Iv,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(sX,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void L(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[N?`${F} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Ne,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(hy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:I,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:I,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:P.length>0?t(`div`,{className:`min-w-0`,children:P.map(e=>t(nX,{node:e,depth:0,runId:r,onOpen:ee,onDownload:L,downloadingPath:S,forceExpanded:!!N},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),R&&n(se,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(ue,{show:!1,children:R.fileName}),t(ce,{className:`h-full max-h-none p-0`,children:t(ot.Suspense,{fallback:t(p,{className:`h-full`,children:t(ev,{className:`size-6 animate-spin text-muted`})}),children:t(QY,{source:R,className:`h-full`,showHeader:!0,onDownload:()=>w&&void L(w)})})})]})]}):t(cX,{icon:t(Iv,{className:`mb-2 size-8`}),children:`No run selected`})}const uX=ot.memo(lX);Q();function dX(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fX(e){if(!dX(e))return;let t=e.browseruse??e.browser_use;if(!dX(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function pX(e){let t=new Map;for(let n of e){let e=fX(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function mX(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function hX(e){return e?e.replace(/_/g,` `):`browser`}function gX({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=VS(),{openImage:u}=DW(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&mX(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=mX(p);try{let n=US(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Nv,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,hX(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Nv,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:hX(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]})]})}Q();function _X({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(Gg,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(Zn,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(ev,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(Nt,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(Gg,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const vX=ot.memo(_X);Q();function yX({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=vt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(vX,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(Gg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(Zn,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const bX=ot.memo(yX);Q();function xX({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(eg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(oh,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(lh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=Jh,f=`text-muted`;c===`in_progress`?(d=rg,f=`text-info`):c===`completed`&&(d=Nh,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=Jh,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=rg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=Nh,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const SX=ot.memo(xX);Q();function CX({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function wX({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case pn.UPLOADING:case pn.PROCESSING:return t(ev,{className:`size-4 animate-spin text-info`});case pn.READY:return t(Nh,{className:`size-4 text-success`});case pn.ERROR:return t(Gh,{className:`size-4 text-destructive`});default:return t(Gg,{className:`size-4 text-muted`})}},s=e=>{switch(e){case pn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case pn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case pn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case pn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(CX,{icon:t(Gg,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var TX=class extends ot.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function EX({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=nt(),u=U(()=>pX(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await iU(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(CX,{icon:t(z_,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?NH(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(TX,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,VH(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:NH(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(TX,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(gX,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(Zh,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(og,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function DX({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),N=O??j,P=e=>{M(e),k?.(e)},F=!u&&c.length>0,I=d.length>0,L=_?_.size>0:!1,ee=V((e,n)=>t(TX,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),R={name:`conversation`,label:`Conversation`,content:T?ee(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},te=[...T?[R]:[],{name:`plan`,label:A(`agent.plan`),content:ee(A(`agent.plan`),e?t(SX,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(CX,{icon:t(z_,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:ee(A(`agent.workstreams`),t(EX,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:I?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:ee(A(`agent.documents`),d.length>0&&p?t(bX,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(CX,{icon:t(Gg,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:L?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:ee(A(`agent.uploads`),t(wX,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:ee(A(`agent.artifacts`),t(uX,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?ee(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],ne=te.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(ze,{tabs:te,current:N,onTabChange:P,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(pe,{tabs:ne,current:N,onTabChange:P,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(Gb,{className:`size-4`})})]}),t(Ve,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const OX=ot.memo(DX);function kX(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function AX(e,t,n=!1){let[r,i]=G([]),[a,o]=G(0),[s,c]=G(new Map),[l,u]=G(t),[d,f]=G(!n),p=W(-1),m=W(new Set);H(()=>{e.length===0&&(i([]),o(0),c(new Map),f(!n),p.current=-1,m.current.clear())},[e.length,n]);let h=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?u(!1):u(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=p.current+1;if(t>=e.length){h(e);return}let n=!1,r=[],a=[];for(let i=t;i<e.length;i++){let t=e[i];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let i=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!m.current.has(i)){m.current.add(i),n=!0,r.push({plan:e,timestamp:i});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),a.push({timestamp:i,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}p.current=e.length-1,n&&r.length>0&&(i(e=>[...[...r].reverse(),...e]),o(0),f(!0),a.length>0&&c(e=>{let t=new Map(e);for(let e of a)t.set(e.timestamp,e.statusMap);return t})),h(e)},[e,h]),H(()=>{if(r.length===1&&!d&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{f(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[r.length,d]),{plans:r,activePlanIndex:a,setActivePlanIndex:o,workstreamStatusMap:s,showInput:l,showSlidingPanel:d,setShowSlidingPanel:f}}function jX(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function MX(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function NX(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function PX(e){return e?.streaming_id_scope===`workflow_run`}function FX(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function IX(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||FX(e)||Dn(e).length>0}function LX(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function RX(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||QH(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?jX(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||QH(e))&&e.details?._optimistic&&MX(e)===n));return JH(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return JH(r,t),r}}}let n=[...e];return JH(n,t),n}function zX(e){let t=e.details,n=NX(t,`streaming_id`),r=NX(t,`activity_id`);return n&&PX(t)?n:r??n}function BX(e){let t=e.details,n=NX(t,`streaming_id`),r=NX(t,`activity_id`),i=[];return n&&PX(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function VX(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(new Map),C=W(new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!ZH(r))},[r]),H(()=>{qH(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:LX(r[0]),last:LX(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(new Map),h(new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return qH(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),qH(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=zX(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=BX(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),IX(e)&&i(t=>RX(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(IX),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),qH(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:LX(e[0]),last:LX(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>RX(e,t),e))},onHistoryError:e=>{r.signal.aborted||(qH(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return qH(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(qH(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{qH(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&MX(n)===e?jX(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function HX(e){if(typeof e==`string`&&e.trim().length>0)return e}function UX(e,t){let n=HX(e.revision_root_id)||HX(e.revision_root)||HX(e.root_document_id)||HX(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=HX(r.root);if(e)return e}return t}function WX(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function GX(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=HX(e.document_id),r=HX(e.updated_document_id)||t,a=e.title;if(r){let s=UX(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>WX(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function KX(e){return e.type.startsWith(`image/`)}function qX(e){if(!(!KX(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function JX(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function YX(e,t,n,r,i){let a=Xt.getFixedT(null,Yt),[o,s]=G(new Map),[c,l]=G(new Set),u=W(new Set),d=W(new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(JX(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(JX),d.current.clear(),s(new Map);let e=new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(JX),d.current.clear()},[]);let g=U(()=>{let e=new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===pn.UPLOADING||e.status===pn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=qX(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:pn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=pn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=pn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(JX),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(new Map)},[])}}Q();function XX({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=vt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(Am,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?fh:rh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=FH(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,VH(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:NH(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(lh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const ZX=new er({strict:!1,validateFormats:!1});function QX(e){if(e!==wn.virtual_lb&&e!==wn.virtual_mediator&&e!==wn.test)return e}var $X=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new eZ(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},eZ=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?ln.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?On(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?QX(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&jn(n,t)?n:e?.default_model&&t&&jn(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:ZX.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const tZ=dt(void 0);function nZ({children:e}){let{client:n}=q(),[r]=G(()=>new $X(n)),i=xt(r.subscribe,r.getSnapshot);return t(tZ.Provider,{value:i,children:e})}function rZ(){let e=_t(tZ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function iZ(){let{router:e}=$n();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function aZ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=iZ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),N=A===`stacked`?j:M,P=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(eg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:N,"aria-label":N,children:t(A===`stacked`?xy:vv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(xy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(vv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(Gm,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Dg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(hv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(oZ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(Gb,{className:`size-4`})})]});return r===`compact`?t(nZ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:P})}):t(nZ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(Am,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-muted`)})]})]}),P]})})}function oZ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=nt(),{client:v}=q(),y=rZ();return t(w,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(wg,{className:`size-4`})}),children:n(ie,{label:`Actions`,children:[n(ae,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(ae,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(ae,{onClick:p,children:[t(A_,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(ae,{onClick:()=>{l?l():iU(v,r).then(e=>window.open(e,`_blank`))},children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(ae,{onClick:f,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(ae,{onClick:u,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(ae,{onClick:c,children:[t(Gb,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(ae,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(v_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(ae,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(Gb,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function sZ(e){return typeof e==`object`&&!!e&&`value`in e}function cZ(e){return sZ(e)?e.value:e}function lZ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:cZ(e));if(e.multiple)return e.value.map(cZ);let t=e.value[0];return t===void 0?void 0:cZ(t)}function uZ(e,t,n){e.query[t]=n}function dZ(e){let t=new Set(e);return e=>t.has(e)}const fZ=[`sys`,`app`,`tmp`],pZ=/^[0-9a-fA-F]{24}$/;function mZ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&fZ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function hZ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!pZ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function gZ(e){return!!e&&e.version===0&&e.status===hn.unknown}function _Z({interaction:e,className:n}){let r=`success`;switch(e.status){case hn.published:r=`success`;break;case hn.archived:r=`destructive`;break;case hn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==hn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function vZ({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=hZ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=mZ(s),u=!!r&&!gZ(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(_Z,{interaction:r})]})]})}function yZ(e,t){return hZ(e,t)??t}function bZ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=mZ(yZ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(_Z,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>yZ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function xZ(e){return`${e._id} (${e.count})`}function SZ(e){return`${e.name} (${e.count})`}function CZ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:xZ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function wZ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return CZ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const TZ={},EZ={},DZ={};function OZ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function kZ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw OZ(n)||delete e[t],n}),e[t]=r),r}function AZ(e){let{client:t}=q();return Ye(()=>kZ(TZ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function jZ(e){let{client:t}=q();return Ye(()=>kZ(EZ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function MZ(e){let{client:t}=q();return Ye(()=>kZ(DZ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function NZ(){return t(`div`,{className:`size-8`})}function PZ({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(KZ,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function FZ({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(KZ,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(Ab,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function IZ({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]});return t(KZ,{title:s(`user.serviceAccount`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,i.slice(-6)]})]})})}function LZ({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(KZ,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:o}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function RZ({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=AZ(o||``),m=MZ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground dark:text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(KZ,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function zZ({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(HZ,{title:e,message:Ge(n),color:`bg-red-500`,showTitle:r,size:i})}function BZ({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(HZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function VZ({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(HZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case bn.User:return t(WZ,{userId:a[1],showTitle:n,size:r});case bn.Group:return t(UZ,{userId:a[1],showTitle:n,size:r});case`system`:return t(PZ,{showTitle:n,size:r});case bn.ServiceAccount:return t(IZ,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case bn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(RZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case bn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(RZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(LZ,{email:a[1],showTitle:n,size:r});case bn.ApiKey:return t(GZ,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(FZ,{showTitle:n,size:r});break;default:return t(zZ,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function HZ({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(KZ,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function UZ({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=jZ(e);if(s)return OZ(s)?t(BZ,{showTitle:r,size:i,color:`bg-indigo-500`}):t(zZ,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(NZ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(KZ,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(Nb,{className:`size-6 text-info`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function WZ({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=AZ(e);if(c)return OZ(c)?t(BZ,{showTitle:i,size:a,color:`bg-indigo-500`}):t(zZ,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(NZ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(KZ,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function GZ({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=MZ(e);if(c)return OZ(c)?t(BZ,{showTitle:i,size:a,color:`bg-pink-500`}):t(zZ,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(NZ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a}),d=n(Le,{className:`dark:bg-muted dark:text-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(KZ,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function KZ({title:e,description:r,children:i}){return n(he,{hover:!0,children:[t(_e,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(ge,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function qZ({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(VZ,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function JZ({buckets:e,name:t,placeholder:n}){return qZ({buckets:e,name:t,placeholder:n})}Q();const YZ=dZ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`]);function XZ(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(wZ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(bZ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(JZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function ZZ(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!YZ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function QZ({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=XZ(e),_=l??g,v=U(()=>ZZ(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(I,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var $Z=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const eQ=dt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function tQ({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new $Z(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(eQ.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function nQ(){let e=_t(eQ);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const rQ=dZ([`name`,`types`]);function iQ(e){let{registry:t}=nQ(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function aQ(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!rQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function oQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=iQ(e),u=aQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function sQ({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const cQ=[`id`,`name`,`types`,`status`],lQ=[`tags`,`created_at`,`updated_at`],uQ=dZ(cQ),dQ=new Set(lQ);function fQ(e){return dQ.has(e)}function pQ(e){return Array.isArray(e)?e:[]}function mQ(e){let{registry:t}=nQ(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=sQ({buckets:pQ(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=wZ({buckets:pQ(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:pQ(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function hQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=cZ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:cZ(t.value[0]),lte:cZ(t.value[1])})}}else r=lZ(t);uQ(n)?uZ(e,n,r):fQ(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function gQ({facets:e,search:r}){let[i,a]=G([]),o=mQ(e),s=hQ(r),c=$e();return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function _Q({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:SZ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const vQ=dZ([`name`,`prompt`,`model`,`tags`]);function yQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function bQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!vQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search(!0)}}function xQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=yQ(e),u=bQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function SQ(e){let t=[];return t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function CQ({facets:e,filters:r,setFilters:i}){let a=SQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function wQ(e){let t=[];return t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(JZ({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(wZ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(wZ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function TQ({facets:e,filters:r,setFilters:i}){let a=wQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const EQ=dZ([`name`,`role`,`tags`]);function DQ(e,t){let n=e[t];return Array.isArray(n)?n:[]}function OQ(e){let t=DQ(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:DQ(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function kQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!EQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function AQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=OQ(e),u=kQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function jQ({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const MQ=dZ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function NQ(e){return e.filter(e=>e._id!==null)}function PQ(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=bZ({buckets:NQ(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=jQ({buckets:NQ(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=wZ({buckets:NQ(e.models),name:`model`});t.push(n)}if(e.statuses){let n=wZ({buckets:NQ(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=wZ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function FQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!MQ(t.name))return;let n=t.name,r=lZ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),uZ(e,n,r)}}),e.search()}}function IQ({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=PQ(e),p=FQ(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(I,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function LQ({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(we,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:xZ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function RQ({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(ne,{className:i,value:a,onChange:o,placeholder:r})}function zQ(e){return`${e.name} (${e.count})`}function BQ({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=nQ(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:zQ,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function VQ(e){let t=[];return t.push(wZ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function HQ({facets:e,filters:r,setFilters:i}){let a=VQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const UQ=dZ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function WQ(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=wZ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=JZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function GQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!UQ(t.name))return;let n=t.name,r=lZ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&uZ(e,n,t===`true`)}else typeof r==`string`&&uZ(e,n,r)}}),e.search()}}function KQ({facets:e,search:r}){let[i,a]=G([]),o=WQ(e),s=GQ(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function qQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function JQ({facets:e,filters:r,setFilters:i}){let a=qQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var YQ=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const XQ=dt(void 0);function ZQ(){let e=_t(XQ);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function QQ(){return _t(XQ)}function $Q({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new YQ(e,n,{},a);a(t)},[n,e]),i&&t(XQ.Provider,{value:i,children:r})}Q();const e$=dt(void 0);function t$({onFilter:e,children:n}){return t(e$.Provider,{value:e,children:n})}function n$(){return _t(e$)}const r$=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function i$({field:r,value:i,label:a,copyContent:s}){let c=n$(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(x,{content:s,className:r$}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:r$,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(l_,{className:`size-3`})})]})}const a$=`text/csv`,o$=`image/`,s$=`application/pdf`,c$=`video/`,l$=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],u$=e=>e===a$||a$.includes(e),d$=e=>e.startsWith(o$)||o$.includes(e),f$=e=>e===s$||s$.includes(e),p$=e=>e.startsWith(c$)||c$.includes(e),m$=e=>l$.includes(e);function h$(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
|
|
1252
|
+
`}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,y&&`hidden`),children:t(OK,{workstreams:fe,activeWorkstream:R,onSelectWorkstream:ge,count:ve,completionStatus:it})}),ye.length===0&&Ve.length===0&&!ke&&!(se&&Ze)?R===`all`&&Ye?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(bq,{label:F(`agent.preparing`),timestamp:Oe.current,className:b})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,se?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,x),children:[se&&R!==`all`&&pe&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),onClick:_e,children:t(wm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:pe})]})}),je&&t(yq,{data:T,schema:E,title:D,template:O,prependFriendlyMessage:w,timestamp:ye[0]?.timestamp??Date.now(),isSummaryView:se,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C},`initial-request`),$e&&t(bq,{label:Qe,timestamp:rt,className:b}),s===`stacked`?n(e,{children:[Je.map((e,n)=>{let r=n===Je.length-1;if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!YH.includes(n.type)&&!i;return h?.includes(s)?null:t(CJ,{status:e.toolStatus,children:t(wJ,{children:t(xK,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},qq(e))}if(e.type===`streaming`)return t(CJ,{children:t(MG,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},qq(e));{let i=e.message;if(Te(i)||Ee(i))return null;if(QH(i))return t(CJ,{children:t(xJ,{message:i,startTimestamp:Jq(Je,n)??i.timestamp,endTimestamp:i.timestamp})},Kq(i,`stopped`));let a=!c&&r&&!YH.includes(i.type);return jK(i)?t(wJ,{children:t(YW,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(CJ,{status:`message`,children:t(wJ,{children:t(yG,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:eW(i,be),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C})})},Kq(i))}}),Ve.map(({id:e,data:n})=>t(CJ,{children:t(MG,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Ye&&Ve.length===0&&!$e&&t(CJ,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,b),children:[t(aW,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[Ke.map(e=>{if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=BK(e.messages);return t(SJ,{label:VK(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:PK(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:b,onSendMessage:u,answeredToolApprovalRequestInputKeys:Se,resolvedToolApprovalKeys:xe},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(xJ,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},Kq(e.message,`stopped-summary`));let n=e.message;return Te(n)||Ee(n)?null:jK(n)?t(wJ,{children:t(YW,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},Kq(n,`batch`)):t(wJ,{children:t(uq,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:ge,requestInputAnswered:eW(n,be),StoreLinkComponent:S,CollectionLinkComponent:C})},Kq(n,`summary`))}),Ve.map(({id:e,data:n})=>t(bJ,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Xe&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,b),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Ze&&!$e&&t(SJ,{label:Qe,status:`running`,timestamp:rt,showElapsed:!0,className:b})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const DJ=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},OJ=ot.memo(EJ);Q();function kJ(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function AJ(e,t){return e?.find(e=>e.cursor===t)}function jJ(e,t){if(t===0||e===`live`)return`live`;let n=fC(e,t);return n>=t-1?`live`:n+1}function MJ(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function NJ(e){return MJ(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function PJ(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function FJ({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>dC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>hC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>kJ(AJ(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=dC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=dC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=jJ(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!ZH(E),A=U(()=>tW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;PJ(`${NJ(j)||`agent-chat`}-${NJ(n)}.json`,t)},[e,m.length,j]),N=V(()=>{O(jJ(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(og,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Gv:ry,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(OJ,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(rW,{message:A,onSendMessage:N,isLoading:!1})]})}function IJ({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function LJ(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>An(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`none`&&e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`none`||e.auth===`api_key`),c=new Map,l=new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:${e.auth}:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:e.auth===`none`?`none`:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{if(t.authType===`none`)return t;try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function RJ(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function zJ(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function BJ(e){return e.authType===`none`||e.authStatus?.authenticated===!0}function VJ(e,t){return e.filter(e=>BJ(e)&&!RJ(e,t)).length}function HJ(e,t){return e.filter(e=>BJ(e)&&!RJ(e,t)).map(e=>e.label)}Q();function UJ({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(mT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(hT,{children:f(`mcpConnections.title`)}),n(gT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(dO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!RJ(e,c),i=BJ(e),a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?G_:H_,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):a?t(mO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:e.authType===`none`?f(`mcpConnections.noAuthentication`):e.authType===`api_key`?f(`mcpConnections.apiKey`):f(`mcpConnections.managedByApp`)}),l&&t(lO,{size:`sm`,value:r,onChange:t=>l(zJ(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function WJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=LJ(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=VJ(u,r),_=HJ(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(oT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(uT,{variant:`success`,children:g})]})]}),t(UJ,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function GJ({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=LJ();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!RJ(i,e),c=BJ(i),u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?G_:H_,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):u?t(mO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`none`?o(`mcpConnections.noAuthentication`):i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(lO,{size:`sm`,value:s,onChange:t=>r(zJ(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function KJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=LJ(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=VJ(c,r);return n(e,{children:[t(HD,{align:`left`,trigger:t(oT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(UD,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(uT,{variant:`success`,children:m})]})}),t(UJ,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}const qJ=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,JJ=/(^|\/)process\/(history|state)(\/|$)/,YJ=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function XJ(e){if(qJ.test(e)||JJ.test(e))return!0;let t=e.split(`/`).pop()??e;return YJ.some(e=>e.test(t))}function ZJ(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function QJ(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function $J(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>QJ(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!XJ(e)),[i,r]),h=U(()=>ZJ(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function eY(){return tY||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),tY}var tY,nY,rY,iY=Y((()=>{nY=ht(()=>eY().then(({Document:e})=>({default:e}))),rY=ht(()=>eY().then(({Page:e})=>({default:e})))}));function aY({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function oY({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(aY,{className:`py-4`,size:`md`}),t(ut,{fallback:null,children:t(nY,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(rY,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(aY,{className:`py-4`,size:`sm`})})})})]})}function sY({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(mY.Provider,{value:h,children:e?t(ut,{fallback:t(aY,{className:`py-4`,size:`md`}),children:t(nY,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(aY,{className:`py-4`,size:`md`}),children:r((e,n)=>t(rY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(aY,{className:`py-4`,size:`sm`})},e))})}):t(aY,{className:`py-4`,size:`md`})})}function cY(){return _t(mY)}function lY({pageNumber:e,width:n,className:r}){let i=cY(),a=i?.pageDimensions?.aspectRatio??hY,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(aY,{size:`md`})}):t(`div`,{className:r,children:t(rY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(aY,{className:`py-4`,size:`sm`})})})}function uY({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=hY,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(rY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(aY,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function dY(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function fY({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(hY),d?.(hY)}},[d,m]),w=y??hY,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||dY(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(aY,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ut,{fallback:t(aY,{className:`py-4`,size:`md`}),children:t(nY,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(aY,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(uY,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(aY,{className:`py-4`,size:`md`})})})})}function pY({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(aY,{className:`py-8`,size:`lg`}),t(ut,{fallback:null,children:t(nY,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(rY,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(aY,{className:`py-8`,size:`md`})})})})]})}var mY,hY,gY=Y((()=>{Q(),iY(),mY=dt(null),hY=210/297}));function _Y({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(SY),[x,S]=G(bY),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=xY.findIndex(e=>e>=y);e===-1&&(e=xY.length-1);let t=Math.min(e+1,xY.length-1);b(xY[t])},[y]),O=V(()=>{let e=xY.findIndex(e=>e>=y);e===-1&&(e=xY.length-1);let t=Math.max(e-1,0);b(xY[t])},[y]),k=V(()=>{b(SY)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),N=W(null),P=W(y);H(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=W(!1);H(()=>{let e=g.current;if(!(!e||!C||F.current)){if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0}},[C,s]);let I=W(s);return H(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:it(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:it(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Dh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(yY,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<xY[xY.length-1],canZoomOut:y>xY[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(vY,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:it(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(fY,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:it(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:it(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:it(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:it(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(hh,{className:`size-4`})})})]})}function vY({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function yY({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(Av,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(oy,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===SY?`text-muted/40`:void 0,children:t(fv,{})})]})}var bY,xY,SY,CY=Y((()=>{Q(),gY(),bY=210/297,xY=[50,75,100,125,150,200,300],SY=100}));function wY({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(je,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(Gb,{className:`size-4`})})}),t(_Y,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(_Y,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(lv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var TY=Y((()=>{Q(),CY()})),EY=mr({UniversalDocumentViewer:()=>ZY});function DY(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function OY(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function kY(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function AY(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function jY(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function MY(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function NY(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function PY(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function FY(e){return[`tsx`,`jsx`].includes(e.extension)}function IY(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function LY({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function RY({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(Zg,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function zY(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function BY(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function VY(e){return e.split(`/`).pop()||e}function HY(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function UY(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function WY(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function GY(e){return Array.isArray(e)?e.length:0}function KY(e){try{let t=HY(JSON.parse(e));if(!t)return;let n=HY(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:UY(n.width),height:UY(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:UY(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:HY(t.timings_ms),error:t.error}}catch{return}}async function qY(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function JY({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${VY(i)}`:n}function YY({metadata:e}){if(!e)return null;let r=UY(e.timings_ms?.total_before_cleanup),a=GY(e.console_errors)+GY(e.page_errors)+GY(e.failed_requests)+GY(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),WY(r)&&n(`div`,{children:[`Total `,WY(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function XY({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,VY(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=BY(e,`.png`),r=BY(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=KY(await qY(await d(r,`inline`),VY(r))),o=JY({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(D_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(YY,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(LY,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(YY,{metadata:l.metadata}),t(LY,{content:c,extension:e.extension})]})]})]})}function ZY({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>DY(e),[e]),g=U(()=>OY(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${DY(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(AY(P)||MY(P)||NY(P)||PY(P)),L=!F&&(kY(P)||jY(P)),ee={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},R=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(ee)):void 0,te=!F&&!P.url&&(IY(P)||!!R)&&(!!R||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!te)){w(!0);try{if(te){let e=R?await R.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,te,I,L,D,j,R,e,k]);let ne={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(Ah,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:ne.reload,children:`Retry`})]}):F?zY(F,ne):(kY(ne)||x?.contentType===`application/pdf`)&&ne.url?t(wY,{url:ne.url,className:`h-full`}):jY(ne)&&ne.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:ne.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):AY(ne)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(Nt,{artifactRunId:e.artifact?.runId,components:d,children:ne.content||``})}):MY(ne)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:ne.content||``}):NY(ne)?t(`div`,{className:`px-4 py-2`,children:t(Rt,{xml:ne.content||``,collapsible:!0})}):FY(ne)?t(XY,{context:ne}):PY(ne)?t(LY,{content:ne.content,extension:g}):IY(ne)&&!R&&!u?t(RY,{message:`This file needs a PDF rendition before it can be previewed.`}):t(RY,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),ne.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:ne.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var QY=Y((()=>{Q(),TY()}));Q();const $Y=ot.lazy(async()=>({default:(await Promise.resolve().then(()=>(QY(),EY))).UniversalDocumentViewer})),eX=new Set([`md`,`markdown`,`mdx`,`txt`]);function tX(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&eX.has(t)}function nX(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function rX({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(rh,{className:`size-3.5 shrink-0 text-muted`}):t(lh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?r_:o_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:nX(e.name)})]}),p&&e.children.map(e=>t(rX,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(Zg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(ev,{className:`size-3.5 animate-spin text-info`}):t(xg,{className:`size-3.5`})})]})}function iX(e){return e.reduce((e,t)=>t.isDirectory?e+iX(t.children):e+1,0)}function aX(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=aX(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function oX(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function sX(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function cX({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(We,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(ev,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(We,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(eh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(xy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(Jv,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(xg,{className:`size-4`})})]}),t(wt,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function lX({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function uX({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=$J(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),N=E.trim(),P=U(()=>aX(h,N),[h,N]),F=U(()=>iX(P),[P]),I=vt(),L=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);oX(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),ee=V(e=>{if(tX(e)){j(e);return}T(e)},[j]),R=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:sX(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(lX,{icon:t(ev,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(M,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(lX,{icon:t(Iv,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(cX,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void L(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[N?`${F} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Ne,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(hy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:I,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:I,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:P.length>0?t(`div`,{className:`min-w-0`,children:P.map(e=>t(rX,{node:e,depth:0,runId:r,onOpen:ee,onDownload:L,downloadingPath:S,forceExpanded:!!N},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),R&&n(se,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(ue,{show:!1,children:R.fileName}),t(ce,{className:`h-full max-h-none p-0`,children:t(ot.Suspense,{fallback:t(p,{className:`h-full`,children:t(ev,{className:`size-6 animate-spin text-muted`})}),children:t($Y,{source:R,className:`h-full`,showHeader:!0,onDownload:()=>w&&void L(w)})})})]})]}):t(lX,{icon:t(Iv,{className:`mb-2 size-8`}),children:`No run selected`})}const dX=ot.memo(uX);Q();function fX(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pX(e){if(!fX(e))return;let t=e.browseruse??e.browser_use;if(!fX(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function mX(e){let t=new Map;for(let n of e){let e=pX(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function hX(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function gX(e){return e?e.replace(/_/g,` `):`browser`}function _X({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=VS(),{openImage:u}=DW(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&hX(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=hX(p);try{let n=US(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Nv,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,gX(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Nv,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:gX(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]})]})}Q();function vX({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(Gg,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(Zn,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(ev,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(Nt,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(Gg,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const yX=ot.memo(vX);Q();function bX({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=vt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(yX,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(Gg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(Zn,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const xX=ot.memo(bX);Q();function SX({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(eg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(oh,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(lh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=Jh,f=`text-muted`;c===`in_progress`?(d=rg,f=`text-info`):c===`completed`&&(d=Nh,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=Jh,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=rg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=Nh,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const CX=ot.memo(SX);Q();function wX({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function TX({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case pn.UPLOADING:case pn.PROCESSING:return t(ev,{className:`size-4 animate-spin text-info`});case pn.READY:return t(Nh,{className:`size-4 text-success`});case pn.ERROR:return t(Gh,{className:`size-4 text-destructive`});default:return t(Gg,{className:`size-4 text-muted`})}},s=e=>{switch(e){case pn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case pn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case pn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case pn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(wX,{icon:t(Gg,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var EX=class extends ot.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function DX({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=nt(),u=U(()=>mX(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await iU(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(wX,{icon:t(z_,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?NH(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(EX,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,VH(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:NH(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(EX,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(_X,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(Zh,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(og,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function OX({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),N=O??j,P=e=>{M(e),k?.(e)},F=!u&&c.length>0,I=d.length>0,L=_?_.size>0:!1,ee=V((e,n)=>t(EX,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),R={name:`conversation`,label:`Conversation`,content:T?ee(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},te=[...T?[R]:[],{name:`plan`,label:A(`agent.plan`),content:ee(A(`agent.plan`),e?t(CX,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(wX,{icon:t(z_,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:ee(A(`agent.workstreams`),t(DX,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:I?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:ee(A(`agent.documents`),d.length>0&&p?t(xX,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(wX,{icon:t(Gg,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:L?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:ee(A(`agent.uploads`),t(TX,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:ee(A(`agent.artifacts`),t(dX,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?ee(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],ne=te.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(ze,{tabs:te,current:N,onTabChange:P,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(pe,{tabs:ne,current:N,onTabChange:P,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(Gb,{className:`size-4`})})]}),t(Ve,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const kX=ot.memo(OX);function AX(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function jX(e,t){let[n,r]=G([]),[i,a]=G(0),[o,s]=G(new Map),[c,l]=G(t),[u,d]=G(!1),f=W(-1),p=W(new Set);H(()=>{e.length===0&&(r([]),a(0),s(new Map),d(!1),f.current=-1,p.current.clear())},[e.length]);let m=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?l(!1):l(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=f.current+1;if(t>=e.length){m(e);return}let n=!1,i=[],o=[];for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let r=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!p.current.has(r)){p.current.add(r),n=!0,i.push({plan:e,timestamp:r});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),o.push({timestamp:r,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}f.current=e.length-1,n&&i.length>0&&(r(e=>[...[...i].reverse(),...e]),a(0),d(!0),o.length>0&&s(e=>{let t=new Map(e);for(let e of o)t.set(e.timestamp,e.statusMap);return t})),m(e)},[e,m]),H(()=>{if(n.length===1&&!u&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{d(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[n.length,u]),{plans:n,activePlanIndex:i,setActivePlanIndex:a,workstreamStatusMap:o,showInput:c,showSlidingPanel:u,setShowSlidingPanel:d}}function MX(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function NX(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function PX(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function FX(e){return e?.streaming_id_scope===`workflow_run`}function IX(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function LX(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||IX(e)||Dn(e).length>0}function RX(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function zX(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||QH(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?MX(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||QH(e))&&e.details?._optimistic&&NX(e)===n));return JH(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return JH(r,t),r}}}let n=[...e];return JH(n,t),n}function BX(e){let t=e.details,n=PX(t,`streaming_id`),r=PX(t,`activity_id`);return n&&FX(t)?n:r??n}function VX(e){let t=e.details,n=PX(t,`streaming_id`),r=PX(t,`activity_id`),i=[];return n&&FX(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function HX(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(new Map),C=W(new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!ZH(r))},[r]),H(()=>{qH(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:RX(r[0]),last:RX(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(new Map),h(new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return qH(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),qH(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=BX(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=VX(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),LX(e)&&i(t=>zX(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(LX),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),qH(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:RX(e[0]),last:RX(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>zX(e,t),e))},onHistoryError:e=>{r.signal.aborted||(qH(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return qH(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(qH(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{qH(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&NX(n)===e?MX(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function UX(e){if(typeof e==`string`&&e.trim().length>0)return e}function WX(e,t){let n=UX(e.revision_root_id)||UX(e.revision_root)||UX(e.root_document_id)||UX(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=UX(r.root);if(e)return e}return t}function GX(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function KX(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=UX(e.document_id),r=UX(e.updated_document_id)||t,a=e.title;if(r){let s=WX(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>GX(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function qX(e){return e.type.startsWith(`image/`)}function JX(e){if(!(!qX(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function YX(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function XX(e,t,n,r,i){let a=Xt.getFixedT(null,Yt),[o,s]=G(new Map),[c,l]=G(new Set),u=W(new Set),d=W(new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(YX(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(YX),d.current.clear(),s(new Map);let e=new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(YX),d.current.clear()},[]);let g=U(()=>{let e=new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===pn.UPLOADING||e.status===pn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=JX(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:pn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=pn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=pn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(YX),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(new Map)},[])}}Q();function ZX({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=vt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(Am,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?fh:rh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=FH(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,VH(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:NH(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(lh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const QX=new er({strict:!1,validateFormats:!1});function $X(e){if(e!==wn.virtual_lb&&e!==wn.virtual_mediator&&e!==wn.test)return e}var eZ=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new tZ(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},tZ=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?ln.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?On(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?$X(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&jn(n,t)?n:e?.default_model&&t&&jn(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:QX.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const nZ=dt(void 0);function rZ({children:e}){let{client:n}=q(),[r]=G(()=>new eZ(n)),i=xt(r.subscribe,r.getSnapshot);return t(nZ.Provider,{value:i,children:e})}function iZ(){let e=_t(nZ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function aZ(){let{router:e}=$n();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function oZ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=aZ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),N=A===`stacked`?j:M,P=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(eg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:N,"aria-label":N,children:t(A===`stacked`?xy:vv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(xy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(vv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(Gm,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Dg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(hv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(sZ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(Gb,{className:`size-4`})})]});return r===`compact`?t(rZ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:P})}):t(rZ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(Am,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-muted`)})]})]}),P]})})}function sZ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=nt(),{client:v}=q(),y=iZ();return t(w,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(wg,{className:`size-4`})}),children:n(ie,{label:`Actions`,children:[n(ae,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(ae,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(ae,{onClick:p,children:[t(A_,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(ae,{onClick:()=>{l?l():iU(v,r).then(e=>window.open(e,`_blank`))},children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(ae,{onClick:f,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(ae,{onClick:u,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(ae,{onClick:c,children:[t(Gb,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(ae,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(v_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(ae,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(Gb,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function cZ(e){return typeof e==`object`&&!!e&&`value`in e}function lZ(e){return cZ(e)?e.value:e}function uZ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:lZ(e));if(e.multiple)return e.value.map(lZ);let t=e.value[0];return t===void 0?void 0:lZ(t)}function dZ(e,t,n){e.query[t]=n}function fZ(e){let t=new Set(e);return e=>t.has(e)}const pZ=[`sys`,`app`,`tmp`],mZ=/^[0-9a-fA-F]{24}$/;function hZ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&pZ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function gZ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!mZ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function _Z(e){return!!e&&e.version===0&&e.status===hn.unknown}function vZ({interaction:e,className:n}){let r=`success`;switch(e.status){case hn.published:r=`success`;break;case hn.archived:r=`destructive`;break;case hn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==hn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function yZ({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=gZ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=hZ(s),u=!!r&&!_Z(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(vZ,{interaction:r})]})]})}function bZ(e,t){return gZ(e,t)??t}function xZ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=hZ(bZ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(vZ,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>bZ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function SZ(e){return`${e._id} (${e.count})`}function CZ(e){return`${e.name} (${e.count})`}function wZ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:SZ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function TZ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return wZ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const EZ={},DZ={},OZ={};function kZ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function AZ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw kZ(n)||delete e[t],n}),e[t]=r),r}function jZ(e){let{client:t}=q();return Ye(()=>AZ(EZ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function MZ(e){let{client:t}=q();return Ye(()=>AZ(DZ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function NZ(e){let{client:t}=q();return Ye(()=>AZ(OZ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function PZ(){return t(`div`,{className:`size-8`})}function FZ({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(qZ,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function IZ({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(qZ,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(Ab,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function LZ({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]});return t(qZ,{title:s(`user.serviceAccount`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,i.slice(-6)]})]})})}function RZ({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(qZ,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:o}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function zZ({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=jZ(o||``),m=NZ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground dark:text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(qZ,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function BZ({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(UZ,{title:e,message:Ge(n),color:`bg-red-500`,showTitle:r,size:i})}function VZ({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(UZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function HZ({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(UZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case bn.User:return t(GZ,{userId:a[1],showTitle:n,size:r});case bn.Group:return t(WZ,{userId:a[1],showTitle:n,size:r});case`system`:return t(FZ,{showTitle:n,size:r});case bn.ServiceAccount:return t(LZ,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case bn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(zZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case bn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(zZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(RZ,{email:a[1],showTitle:n,size:r});case bn.ApiKey:return t(KZ,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(IZ,{showTitle:n,size:r});break;default:return t(BZ,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function UZ({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(qZ,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function WZ({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=MZ(e);if(s)return kZ(s)?t(VZ,{showTitle:r,size:i,color:`bg-indigo-500`}):t(BZ,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(PZ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(qZ,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(Nb,{className:`size-6 text-info`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function GZ({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=jZ(e);if(c)return kZ(c)?t(VZ,{showTitle:i,size:a,color:`bg-indigo-500`}):t(BZ,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(PZ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(qZ,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function KZ({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=NZ(e);if(c)return kZ(c)?t(VZ,{showTitle:i,size:a,color:`bg-pink-500`}):t(BZ,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(PZ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a}),d=n(Le,{className:`dark:bg-muted dark:text-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(qZ,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function qZ({title:e,description:r,children:i}){return n(he,{hover:!0,children:[t(_e,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(ge,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function JZ({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(HZ,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function YZ({buckets:e,name:t,placeholder:n}){return JZ({buckets:e,name:t,placeholder:n})}Q();const XZ=fZ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`]);function ZZ(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(TZ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(xZ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(TZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(YZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function QZ(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!XZ(t.name))return;let n=t.name;dZ(e,n,uZ(t))}}),e.search()}}function $Z({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=ZZ(e),_=l??g,v=U(()=>QZ(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(I,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var eQ=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const tQ=dt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function nQ({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new eQ(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(tQ.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function rQ(){let e=_t(tQ);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const iQ=fZ([`name`,`types`]);function aQ(e){let{registry:t}=rQ(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function oQ(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!iQ(t.name))return;let n=t.name;dZ(e,n,uZ(t))}}),e.search()}}function sQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=aQ(e),u=oQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function cQ({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const lQ=[`id`,`name`,`types`,`status`],uQ=[`tags`,`created_at`,`updated_at`],dQ=fZ(lQ),fQ=new Set(uQ);function pQ(e){return fQ.has(e)}function mQ(e){return Array.isArray(e)?e:[]}function hQ(e){let{registry:t}=rQ(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=cQ({buckets:mQ(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=TZ({buckets:mQ(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:mQ(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function gQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=lZ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:lZ(t.value[0]),lte:lZ(t.value[1])})}}else r=uZ(t);dQ(n)?dZ(e,n,r):pQ(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function _Q({facets:e,search:r}){let[i,a]=G([]),o=hQ(e),s=gQ(r),c=$e();return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function vQ({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:CZ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const yQ=fZ([`name`,`prompt`,`model`,`tags`]);function bQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function xQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!yQ(t.name))return;let n=t.name;dZ(e,n,uZ(t))}}),e.search(!0)}}function SQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=bQ(e),u=xQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function CQ(e){let t=[];return t.push(TZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function wQ({facets:e,filters:r,setFilters:i}){let a=CQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function TQ(e){let t=[];return t.push(TZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(YZ({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(TZ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(TZ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function EQ({facets:e,filters:r,setFilters:i}){let a=TQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const DQ=fZ([`name`,`role`,`tags`]);function OQ(e,t){let n=e[t];return Array.isArray(n)?n:[]}function kQ(e){let t=OQ(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:OQ(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function AQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!DQ(t.name))return;let n=t.name;dZ(e,n,uZ(t))}}),e.search()}}function jQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=kQ(e),u=AQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function MQ({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const NQ=fZ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function PQ(e){return e.filter(e=>e._id!==null)}function FQ(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=xZ({buckets:PQ(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=MQ({buckets:PQ(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=TZ({buckets:PQ(e.models),name:`model`});t.push(n)}if(e.statuses){let n=TZ({buckets:PQ(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=TZ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function IQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!NQ(t.name))return;let n=t.name,r=uZ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),dZ(e,n,r)}}),e.search()}}function LQ({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=FQ(e),p=IQ(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(I,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function RQ({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(we,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:SZ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function zQ({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(ne,{className:i,value:a,onChange:o,placeholder:r})}function BQ(e){return`${e.name} (${e.count})`}function VQ({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=rQ(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:BQ,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function HQ(e){let t=[];return t.push(TZ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function UQ({facets:e,filters:r,setFilters:i}){let a=HQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const WQ=fZ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function GQ(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=TZ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=YZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function KQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!WQ(t.name))return;let n=t.name,r=uZ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&dZ(e,n,t===`true`)}else typeof r==`string`&&dZ(e,n,r)}}),e.search()}}function qQ({facets:e,search:r}){let[i,a]=G([]),o=GQ(e),s=KQ(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function JQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function YQ({facets:e,filters:r,setFilters:i}){let a=JQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var XQ=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const ZQ=dt(void 0);function QQ(){let e=_t(ZQ);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function $Q(){return _t(ZQ)}function e$({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new XQ(e,n,{},a);a(t)},[n,e]),i&&t(ZQ.Provider,{value:i,children:r})}Q();const t$=dt(void 0);function n$({onFilter:e,children:n}){return t(t$.Provider,{value:e,children:n})}function r$(){return _t(t$)}const i$=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function a$({field:r,value:i,label:a,copyContent:s}){let c=r$(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(x,{content:s,className:i$}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:i$,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(l_,{className:`size-3`})})]})}const o$=`text/csv`,s$=`image/`,c$=`application/pdf`,l$=`video/`,u$=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],d$=e=>e===o$||o$.includes(e),f$=e=>e.startsWith(s$)||s$.includes(e),p$=e=>e===c$||c$.includes(e),m$=e=>e.startsWith(l$)||l$.includes(e),h$=e=>u$.includes(e);function g$(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
|
|
1253
1253
|
@media print {
|
|
1254
1254
|
body {
|
|
1255
1255
|
margin: 24px;
|
|
@@ -1374,30 +1374,30 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
|
|
|
1374
1374
|
page-break-inside: avoid;
|
|
1375
1375
|
}
|
|
1376
1376
|
}
|
|
1377
|
-
`,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const g$={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:mn.jpeg,generate_if_missing:!0},_$=`vertesia.content_store.renditionId`;async function v$(e,t,n,r,i){if(!t?.content?.type||!(d$(t.content.type)||p$(t.content.type)||f$(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${_$}_${t.id}_${g$.max_hw}`),s=localStorage.getItem(`${_$}_${t.id}_${g$.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,g$).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>v$(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${_$}_${t.id}_${g$.max_hw}`,e),localStorage.setItem(`${_$}_${t.id}_${g$.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function y$(e,t=7){return e?`~${e.slice(-t)}`:``}function b$(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function x$(e){switch(e){case Tn.RUNNING:return`text-info`;case Tn.COMPLETED:return`text-success`;case Tn.FAILED:return`text-destructive`;case Tn.TERMINATED:case Tn.CANCELED:return`text-attention`;default:return`text-muted`}}function S$(e){switch(e){case Tn.RUNNING:return`Running`;case Tn.COMPLETED:return`Completed`;case Tn.FAILED:return`Failed`;case Tn.CONTINUED_AS_NEW:return`Continued As New`;case Tn.TERMINATED:return`Terminated`;case Tn.TIMED_OUT:return`Timed Out`;case Tn.CANCELED:return`Canceled`;default:return`Unknown`}}Q();function C$(e){return typeof e==`object`&&!!e}function w$(e,t){if(!C$(e))return;let n=e[t];return typeof n==`string`?n:void 0}function T$(e){return typeof e==`string`?e:w$(e,`id`)||``}function E$(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const D$={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e),o=new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0);return t(`td`,{className:`group/field`,children:o},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=T$(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t(Ag,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(C$(e)&&C$(e.properties)?e.properties:void 0)?.[i],s=E$(o),c=w$(e,`name`),l=w$(e,`id`),u=s||c||(l?y$(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=T$(e),c=i.reduce((e,t)=>t(e),s);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,c,t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t(Ag,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=w$(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=C$(e)&&C$(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=w$(i,`root`),o=w$(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Dg,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=WD(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(We,{description:c.format(`LLL`),children:l}),o]})},r)}}},O$=D$.string();function k$(e){return typeof e==`object`&&!!e}function A$(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!k$(n)||(n=n[t[e]],!n))return;if(k$(n))return n[t[r]]}function j$(e){return!e||e===`.`?[]:e.split(`.`)}var M$=class{layout;renderer=O$;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=j$(e.field||``),this.fallbackPath=e.fallback?j$(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=D$[e](r)}else this.renderer=D$[t]()}}get name(){return this.layout.name}resolveValue(e){let t=A$(e,this.path);return t===void 0&&this.fallbackPath&&(t=A$(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return D$[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(i$,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(i$,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(i$,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(i$,{field:`status`,value:e.status,label:e.status})}};Q();function N$({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function P$({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=q(),[p,m]=G(void 0),[h,g]=G(void 0),[_,v]=G(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};H(()=>{r?.content&&v$(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-info bg-info/50 dark:bg-info/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(eh,{className:`size-4 text-info`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t(Ag,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(We,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(We,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}Q();function F$({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=K();return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(Pe,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-info`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(eh,{className:`size-4 text-info inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function I$({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(N$,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(P$,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var L$=class{client;limit;collectionId;facets=new De({});result=new De({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};deletedIds=new Set;loadedCount=0;constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}removeDeletedObjects(e){if(e.length===0)return;for(let t of e)this.deletedIds.add(t);let t=this.result.value,n=t.objects.filter(e=>!this.deletedIds.has(e.id)),r=t.objects.length-n.length;this.result.value={...t,objects:n};let i=this.facets.value;r>0&&typeof i.total==`number`&&(this.facets.value={...i,total:Math.max(0,i.total-r)})}reset(e=!1){this.initialized=!1,this.deletedIds.clear(),this.loadedCount=0,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:!e||this.result.value.hasMore};let r=this.limit,i=e?this.loadedCount:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};if(this.loadedCount=e?this.loadedCount+a.length:a.length,!e&&this.deletedIds.size>0)for(let e of[...this.deletedIds])a.some(t=>t.id===e)||this.deletedIds.delete(e);let s=this.deletedIds.size>0?a.filter(e=>!this.deletedIds.has(e.id)):a;return this.result.value={isLoading:!1,objects:e?this.objects.concat(s):s,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const R$=dt(void 0);function z$(){return _t(R$)}function B$(){return rt(z$().facets)}function V$(){let e=z$();return{...rt(e.result),search:e}}function H$(){let e=z$();return rt(e.facets).total}const U$=Xt.getFixedT(null,Yt);var W$;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(W$||={});async function G$(e){try{let t=await e.arrayBuffer(),n=new nr;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function K$(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await G$(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function q$(){let{client:e}=q(),t=nt();return{checkDocumentProcessing:V(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await K$(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results.filter(e=>typeof e.id==`string`)}else{let t={query:r,select:`id content.etag`};a=(await e.store.objects.find(t)).flatMap(e=>typeof e.id==`string`?[{id:e.id,content:e.content}]:[])}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=W$.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==W$.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=W$.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===W$.UPDATE).length}`)})(),t.forEach(e=>{e.action||=W$.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===W$.CREATE).length,toUpdate:t.filter(e=>e.action===W$.UPDATE).length,toSkip:t.filter(e=>e.action===W$.SKIP).length}),t}catch(e){throw t({title:U$(`store.errorInUploadProcessingCheck`),status:`error`,description:Ge(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${Ge(e)}`,{cause:e})}},[e,t])}}Q();function J$({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0,initialTypeId:h,defaultProperties:g}){let{client:_}=q(),{registry:v}=nQ(),y=nt(),{t:b}=K(),x=l??b(`upload.uploadFiles`),[S,C]=G([]),[w,T]=G([]),[E,D]=G(!1),[O,k]=G(null),[A,j]=G([]),[M,N]=G(!1),[P,F]=G(!1),[I,L]=G(0),[ee,R]=G(Date.now()),[te,ne]=G(void 0),[re,ie]=G(null),[ae,de]=G(x),[fe,pe]=G(``);H(()=>{s&&_.store.collections.retrieve(s).then(ne)},[_.store.collections.retrieve,s]),H(()=>{M?(de(b(`upload.uploadingFiles`)),pe(`${Math.round(I)}% complete`)):P?(de(b(`upload.uploadComplete`)),pe(``)):E?(de(b(`upload.fileAnalysisResults`)),pe(`${S.length} file${S.length===1?``:`s`}`)):S.length>0?(de(x),pe(b(`upload.checkingForDuplicates`))):(de(x),pe(``))},[M,P,E,x,I,S.length,b]);let me=()=>!te&&!c?null:n(oe,{className:`mb-4`,status:`default`,icon:t(o_,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:b(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[te&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:b(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:te.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:b(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[he,ge]=G({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:_e}=q$(),ve=U(()=>v?.types||[],[v?.types]),ye=V(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await _e(e,c,s);T(t);let n=t.filter(e=>e.action===W$.CREATE).length,r=t.filter(e=>e.action===W$.UPDATE).length,i=t.filter(e=>e.action===W$.SKIP).length;ge({toCreate:n,toUpdate:r,toSkip:i}),y({title:b(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),D(!0)}catch(e){console.error(`Error processing files:`,e),y({title:b(`agent.error`),description:b(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[_e,s,c,b,y]);H(()=>{r&&(T([]),D(!1),k(h?v?.getType(h)??null:null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),a&&a.length>0?(C(a),ye(a)):C([]),R(Date.now()))},[a,h,r,ye,x,v]);let be=()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),R(Date.now()),i()},xe=e=>{e&&e.length>0&&(C(e),ye(e))},Se=async()=>{if(!w.length)return;let e=O?.id||null,t=w.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===W$.CREATE?`create`:e.action===W$.UPDATE?`update`:`skip`}));j(t),N(!0),F(!1);let n=w.filter(e=>e.action===W$.SKIP),r=w.filter(e=>e.action===W$.UPDATE),i=w.filter(e=>e.action===W$.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;y({title:b(`upload.processingFilesAction`,{action:n}),description:b(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(j(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await _.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await _.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name,properties:g},{collection_id:s});j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),j(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:Ge(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:Ge(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&j(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return L(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),j(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:b(`upload.uploadProcessInterrupted`),status:`failed`,type:O?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}:e)):e}),N(!1),F(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),y({title:b(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),ie(a)},Ce=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[b(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:b(`store.optional`)}),t(We,{description:b(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]}),t(we,{options:ve,value:O,optionLabel:e=>e?e.name:b(`store.selectContentTypeLabel`),placeholder:b(`store.selectContentTypeAuto`),onChange:e=>k(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!O&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),b(`store.automaticTypeDetection`),t(We,{description:b(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})})]});return n(se,{isOpen:r,onClose:be,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(ue,{description:fe,children:ae}),p?n(ce,{children:[u,me(),Ce()]}):S.length===0&&!f?n(ce,{className:`flex flex-col items-center justify-center p-8`,children:[me(),t(Ot,{onDrop:xe,message:b(`upload.dragAndDrop`),buttonLabel:b(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!M&&!P?t(ce,{children:E?n(e,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(wb,{className:`size-5 text-info`}),t(`span`,{className:`font-medium`,children:b(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Nh,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:b(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Ah,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:b(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toSkip})]})]})})}),Ce(),t(oe,{className:`mb-4`,status:`info`,children:he.toCreate+he.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:b(`upload.filesReadyToProcess`,{count:he.toCreate+he.toUpdate})}),t(`p`,{children:he.toSkip>0&&b(`upload.filesToSkip`,{count:he.toSkip})})]}):he.toSkip>0?t(`span`,{children:b(`upload.allFilesExist`,{count:he.toSkip})}):t(`span`,{children:b(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(je,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:b(`upload.analyzingFiles`)})]})}):M?n(ce,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${I}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:A.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(Zg,{className:`size-5 text-muted`}),e.status===`uploading`&&t(je,{size:`sm`}),e.status===`success`&&t(Nh,{className:`size-5 text-success`}),e.status===`error`&&t(Gh,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&b(`agent.waiting`),e.status===`uploading`&&b(`agent.uploading`),e.status===`success`&&(e.action===`create`?b(`store.created`):e.action===`update`?b(`store.updated`):b(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(ce,{children:n(`div`,{className:`mb-4`,children:[me(),t(Lt,{files:A.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:te?.name})]})}),(()=>{if(p)return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:O?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),be()},children:O?b(`upload.useTypeName`,{typeName:O.name}):b(`upload.useAutoDetection`)})]});if(S.length===0&&!f)return t(le,{children:t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)})});if(!M&&!P){let e=E;return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{disabled:!e,onClick:Se,children:he.toCreate+he.toUpdate>0?b(`agent.upload`):b(`upload.continue`)})]})}return M?t(le,{children:t(o,{variant:`ghost`,disabled:!0,children:b(`agent.uploading`)})}):n(le,{children:[t(o,{variant:`ghost`,onClick:()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0})},children:b(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&re&&d(re),be()},children:b(`agent.close`)})]})})()]},ee)}function Y$(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=q(),a=z$(),o=nt(),s=Xt.getFixedT(null,Yt),{checkDocumentProcessing:c}=q$();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===W$.CREATE).length,v=g.filter(e=>e.action===W$.UPDATE).length,y=g.filter(e=>e.action===W$.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===W$.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===W$.CREATE||e.action===W$.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===W$.CREATE).length} create, ${b.filter(e=>e.action===W$.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===W$.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:Ge(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:Ge(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const X$=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Z$({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t(Q$,{...i,onUpload:n,isGridView:e,collectionId:r}):t($$,{...i,isGridView:e})}function Q$({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=G(!1),[l,u]=G([]),[d,f]=G(!1),[p,m]=G(null),[h,g]=G(!1),_=z$(),v=nt(),{t:y}=K(),{checkDocumentProcessing:b}=q$(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:it(`bg-white dark:bg-muted opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(je,{size:`xl`})}),t($$,{...o,isGridView:e}),t(`div`,{className:it(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(Ot,{onDrop:x,message:`Drop files or folders here to upload`,className:it(`absolute inset-0 bg-white/90 dark:bg-muted/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(J$,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function $$({objects:e,layout:n=X$,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=QQ(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=e1(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=t1(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=U(()=>{let e=n.length>0?n:X$;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new M$(e,s))},[n,s]);return t(l?I$:F$,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function e1(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function t1(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function n1({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=q(),l=U(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new L$(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(R$.Provider,{value:l,children:e})}Q();const r1=`vertesia.content_store.lastDisplayedView`;function i1({onUpdate:e}){let{t:n}=K(),[r,i]=G(localStorage.getItem(r1)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(r1,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(r1,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,title:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?ob:I_,{})})}i1.LAST_DISPLAYED_VIEW=r1,Q();const a1=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function o1({onChange:e,selectedIds:n}){return t(n1,{children:t(s1,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function s1({onRowClick:e,selectedIds:r}){let{t:i}=K(),a=V(e=>!!r?.has(e.id),[r]),[s,c]=G(!1),[l,u]=G(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=V$(),g=W(null);Qe(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),H(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=B$(),v=z$();return p?t(M,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t(gQ,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(hy,{size:16})}),t(i1,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(Z$,{objects:m||[],isLoading:!m.length&&f,layout:a1,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}Q();function c1(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function l1({onSend:e,onStop:r,approvalModeSlot:i,mcpSlot:a,disabled:s=!1,isSending:c=!1,isStopping:l=!1,isStreaming:u=!1,isCompleted:d=!1,contextWindowUsage:f,onCompactContext:p,isCompactingContext:m=!1,activeTaskCount:h=0,activeWorkstreams:g=[],onSelectWorkstream:_,placeholder:v,onFilesSelected:y,uploadedFiles:b=[],onRemoveFile:x,onRemoveProcessingFile:S,acceptedFileTypes:C,maxFiles:T=5,processingFiles:E,artifactRunId:D,hasProcessingFiles:O=!1,renderDocumentSearch:k,selectedDocuments:A=[],onRemoveDocument:j,hideObjectLinking:M=!1,hideFileUpload:N=!1,disableDropZone:P=!1,className:F,inputClassName:I}){let{t:L}=K(),ee=v??L(`agent.typeYourMessage`),R=W(null),te=W(null),[ne,re]=G(``),[ie,oe]=G(!1),[le,de]=G(!1),[fe,pe]=G(!1),me=!!(y&&!N),he=me&&!P,ge=!M||me||!!k,_e=b.length>=T,ve=S??x,ye=U(()=>g.filter(e=>e.status===`running`||e.status===`canceling`),[g]),be=ye.length||h,xe=f?L(`agent.contextUsageCompactLabel`,{percent:f.usedPercent}):void 0,Se=f?L(`agent.contextTokenUsage`,{used:c1(f.usedTokens),limit:c1(f.checkpointTokens)}):void 0,Ce=U(()=>{let e=[];if(!N&&E)for(let t of E.values()){let n=t.preview_url,r=t.status===pn.UPLOADING?L(`agent.uploading`):t.status===pn.PROCESSING?L(`agent.processing`):t.status===pn.ERROR?L(`agent.error`):t.status===pn.READY?L(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!ve,statusLabel:r,statusTone:t.status===pn.ERROR?`destructive`:t.status===pn.READY?`success`:`attention`})}if(!N)for(let t of b)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!x,statusLabel:L(`agent.ready`),statusTone:`success`});for(let t of A)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!j,statusTone:`info`});return e},[ve,N,j,x,E,A,L,b]);H(()=>{!s&&d&&R.current?.focus()},[s,d]);let we=V(e=>{if(!me||!y)return;let t=Array.from(e),n=T-b.length,r=t.slice(0,n);r.length>0&&y(r)},[me,y,T,b.length]),Te=V(e=>{e.preventDefault(),e.stopPropagation(),he&&pe(!0)},[he]),Ee=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1)},[]),De=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1),he&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&we(e.dataTransfer.files)},[he,we]),Oe=V(e=>{if(!me)return;let t=kX(e.clipboardData?.items);t.length>0&&we(t)},[me,we]),ke=V(e=>{me&&e.target.files&&e.target.files.length>0&&(we(e.target.files),e.target.value=``)},[me,we]),Ae=V(()=>{te.current?.click()},[]),Me=V(()=>de(!1),[]),Ne=V(e=>de(!1),[]),Pe=()=>{let t=ne.trim();!t||s||c||O||(e(t),re(``))},Fe=()=>{r&&!l&&r()},Ie=W(0),Le=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),ne.trim().length>0&&Pe();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,re));return}if(e.key===`Escape`&&u&&r){let e=Date.now();e-Ie.current<500?(Fe(),Ie.current=0):Ie.current=e}},Re=V(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return H(()=>{Re()},[ne,Re]),n(`div`,{className:z(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,fe&&he&&`bg-info/10 border-info`,F),onDragOver:he?Te:void 0,onDragLeave:he?Ee:void 0,onDrop:he?De:void 0,children:[fe&&he&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2`,children:[t(wb,{className:`size-5`}),L(`agent.dropFilesToUpload`)]})}),me&&t(`input`,{ref:te,type:`file`,multiple:!0,accept:C,onChange:ke,className:`hidden`}),t(XX,{activeWorkstreams:g,onSelectWorkstream:_}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[Ce.length>0&&t(VW,{items:Ce,artifactRunId:D,variant:`composer`,onRemove:e=>{E?.has(e)?ve?.(e):b.some(t=>t.id===e)?x?.(e):j?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(Ue,{ref:R,value:ne,onKeyDown:Le,onChange:e=>re(e.target.value),onPaste:Oe,disabled:s,"aria-label":ee,placeholder:ee,rows:1,style:{maxHeight:`160px`},className:z(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,I)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[ge&&n(w,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,title:L(`agent.addAttachment`),children:t(oy,{className:`size-4`})}),children:[!M&&n(ae,{onClick:()=>oe(!0),isDisabled:!d,children:[t(Hv,{className:`size-4`}),L(`agent.linkObject`)]}),me&&n(ae,{onClick:Ae,isDisabled:_e,children:[t(wb,{className:`size-4`}),L(`agent.upload`)]}),k&&n(ae,{onClick:()=>de(!0),children:[t(Gg,{className:`size-4`}),t(`span`,{children:L(`agent.searchDocuments`)}),A.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:A.length})]})]}),i,a,f&&t(We,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:L(`agent.contextRemainingUntilCompact`,{percent:f.remainingPercent})}),Se&&t(`span`,{className:`mt-1 block text-foreground/80`,children:Se})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:z(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":xe,onClick:p,disabled:!p||m,children:m?t(je,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:z(`size-8 -rotate-90`,f.usedPercent>=90?`text-destructive`:f.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-f.usedPercent},className:`stroke-current`})]})})}),ye.length===0&&be>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(xm,{className:`size-3 text-attention`}),L(`agent.activeWorkstreams`,{count:be})]})})]}),u&&r&&!ne.trim()?t(o,{onClick:Fe,disabled:l,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:L(`agent.stopTooltip`),children:l?t(je,{size:`sm`}):t(rb,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:Pe,disabled:s||c||!ne.trim()||O,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:L(O?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":L(O?`agent.waitForFiles`:`agent.send`),children:c?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]}),n(se,{isOpen:ie,onClose:()=>oe(!1),className:`min-w-[60vw]`,children:[t(ue,{children:L(`agent.linkObject`)}),t(ce,{className:`pb-6`,children:t(o1,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=ne||``,r=R.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);re(i),oe(!1),setTimeout(()=>{if(R.current){R.current.focus();let e=r+t.length;R.current.setSelectionRange(e,e)}},100)}})})]}),k?.({isOpen:le,onClose:Me,onSelect:Ne})]})}function u1({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=qt(),i=U(()=>Wt(e),[e]),a=U(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(Et,{type:`proposal`,message:`Loading options...`}):a?t(Tt,{type:`proposal`,fallbackCode:e,children:t(jH,{...a})}):t(Et,{type:`proposal`,error:`Invalid proposal specification`})}const d1=gt(function({code:e}){let n=U(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),f1=gt(function({code:e}){let n=U(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),p1={chart:d1,"vega-lite":f1,vegalite:f1,"fusion-fragment":Jn,proposal:u1,askuser:u1};function m1({url:e,code:n}){let[r,i]=G(null);return H(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function h1(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=An(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(m1,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function g1({children:e}){let{client:n}=q(),[r,i]=G(p1);return H(()=>{h1(n).then(e=>{i({...p1,...e})})},[n]),t(Dt,{components:r,children:e})}Q();const _1=new Map,v1=[400,1200];async function y1(e,t,n){for(let r=0;;r++)try{return await e.agents.sendSignal(t,`FileBatchClosed`,n),!0}catch(e){if(r>=v1.length)return console.error(`Failed to close staged file batch:`,e),!1;await new Promise(e=>setTimeout(e,v1[r]))}}function b1(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function x1(e){return e===`running`||e===`canceling`}function S1(e){return!x1(e)}function C1(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w1(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=C1(r?.prompt),a=i&&i>0?i:C1(r?.total),o=C1(n.checkpoint_threshold)??C1(n.checkpoint_at);if(typeof a!=`number`||typeof o!=`number`||o<=0)continue;let s=Math.max(0,Math.min(100,Math.round(a/o*100)));return{usedTokens:a,checkpointTokens:o,usedPercent:s,remainingPercent:Math.max(0,100-s)}}}function T1(e,t){return!S1(e.status)||!x1(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function E1(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:eU(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function D1(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function O1(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function k1(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=b1(e.timestamp),a=E1(e),o=UH(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=BH(e);if(!o&&!c&&l&&!n.has(s))return;let u=O1(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=HH(e);d?u.status=d:l||(D1(e)?u.status=`failed`:(e.type===J.COMPLETE||e.type===J.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),x1(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!x1(e.status))-Number(!x1(t.status));return n===0?x1(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function A1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function j1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function M1(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=T1(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=T1(e[r],t);return}e.push(t)}function N1(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function P1(e,t=!0){let[n,r]=G(()=>Math.max(0,Math.floor((Date.now()-b1(e))/1e3)));return H(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-b1(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function F1(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*CW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function I1({message:e,startedAt:r}){let{t:i}=K(),a=P1(r),o=F1();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(aW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,N1(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:CW[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(iW,{color:`blue`})})]})]})}function L1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function R1(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function z1(e){return R1(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function B1(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function V1(e){let{agentRunId:n,startWorkflow:r,resourceResolver:i}=e;if(n){let r=t(g1,{children:t(W1,{...e,agentRunId:n})});return i?t(Ct,{value:i,children:r}):r}return r?t(U1,{...e}):t(H1,{})}function H1(){let{t:e}=K();return n(oe,{status:`info`,icon:t(Am,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function U1({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,startViewVariant:b=`default`,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,initialToolApprovalMode:T,onAgentWorkingChange:E}){let{t:D}=K(),O=b!=="default",k=b===`expanded-composer`,A=!_,j=l??D(`agent.typeYourMessage`),M=u??D(`agent.startAgent`),N=d??D(`agent.startNewConversation`),{client:P}=q(),[F,I]=G(``),[L,ee]=G(!1),[R,te]=G(null),[ne,re]=G(null),[ie,ae]=G(null),[oe,se]=G(()=>kn(T,r)),ce=nt(),le=W(null),ue=W(null),[de,fe]=G([]),[pe,me]=G(!1),he=pe?de:de.slice(0,3),ge=de.length-3;H(()=>{E?.(L)},[L,E]);let[_e,ve]=G(!1),ye=W(0),be=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current++,e.dataTransfer?.types?.includes(`Files`)&&ve(!0))},[A]),xe=V(e=>{A&&(e.preventDefault(),e.stopPropagation())},[A]),Se=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current--,ye.current===0&&ve(!1))},[A]),Ce=V(e=>{if(A&&(e.preventDefault(),e.stopPropagation(),ye.current=0,ve(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);fe(e=>[...e,...t].slice(0,h))}},[h,A]),we=V(e=>{if(!A)return;let t=kX(e.clipboardData?.items);t.length>0&&fe(e=>[...e,...t].slice(0,h))},[A,h]),Te=V(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);fe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),Ee=V(e=>{fe(t=>t.filter((t,n)=>n!==e))},[]);H(()=>{de.length<=3&&me(!1)},[de.length]),H(()=>{le.current&&le.current.focus()},[]);let De=async()=>{if(!i)return;let e=F.trim();if(!(!e||L)){ee(!0);try{sessionStorage.removeItem(`plan-panel-shown`),ce({title:A&&de.length>0?D(`agent.startingAgentUploading`):D(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
1377
|
+
`,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const _$={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:mn.jpeg,generate_if_missing:!0},v$=`vertesia.content_store.renditionId`;async function y$(e,t,n,r,i){if(!t?.content?.type||!(f$(t.content.type)||m$(t.content.type)||p$(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${v$}_${t.id}_${_$.max_hw}`),s=localStorage.getItem(`${v$}_${t.id}_${_$.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,_$).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>y$(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${v$}_${t.id}_${_$.max_hw}`,e),localStorage.setItem(`${v$}_${t.id}_${_$.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function b$(e,t=7){return e?`~${e.slice(-t)}`:``}function x$(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function S$(e){switch(e){case Tn.RUNNING:return`text-info`;case Tn.COMPLETED:return`text-success`;case Tn.FAILED:return`text-destructive`;case Tn.TERMINATED:case Tn.CANCELED:return`text-attention`;default:return`text-muted`}}function C$(e){switch(e){case Tn.RUNNING:return`Running`;case Tn.COMPLETED:return`Completed`;case Tn.FAILED:return`Failed`;case Tn.CONTINUED_AS_NEW:return`Continued As New`;case Tn.TERMINATED:return`Terminated`;case Tn.TIMED_OUT:return`Timed Out`;case Tn.CANCELED:return`Canceled`;default:return`Unknown`}}Q();function w$(e){return typeof e==`object`&&!!e}function T$(e,t){if(!w$(e))return;let n=e[t];return typeof n==`string`?n:void 0}function E$(e){return typeof e==`string`?e:T$(e,`id`)||``}function D$(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const O$={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e),o=new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0);return t(`td`,{className:`group/field`,children:o},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=E$(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t(Ag,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(w$(e)&&w$(e.properties)?e.properties:void 0)?.[i],s=D$(o),c=T$(e,`name`),l=T$(e,`id`),u=s||c||(l?b$(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=E$(e),c=i.reduce((e,t)=>t(e),s);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,c,t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t(Ag,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=T$(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=w$(e)&&w$(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=T$(i,`root`),o=T$(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Dg,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=WD(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(We,{description:c.format(`LLL`),children:l}),o]})},r)}}},k$=O$.string();function A$(e){return typeof e==`object`&&!!e}function j$(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!A$(n)||(n=n[t[e]],!n))return;if(A$(n))return n[t[r]]}function M$(e){return!e||e===`.`?[]:e.split(`.`)}var N$=class{layout;renderer=k$;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=M$(e.field||``),this.fallbackPath=e.fallback?M$(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=O$[e](r)}else this.renderer=O$[t]()}}get name(){return this.layout.name}resolveValue(e){let t=j$(e,this.path);return t===void 0&&this.fallbackPath&&(t=j$(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return O$[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(a$,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(a$,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(a$,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(a$,{field:`status`,value:e.status,label:e.status})}};Q();function P$({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function F$({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=q(),[p,m]=G(void 0),[h,g]=G(void 0),[_,v]=G(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};H(()=>{r?.content&&y$(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-info bg-info/50 dark:bg-info/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(eh,{className:`size-4 text-info`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t(Ag,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(We,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(We,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}Q();function I$({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=K();return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(Pe,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-info`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(eh,{className:`size-4 text-info inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function L$({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(P$,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(F$,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var R$=class{client;limit;collectionId;facets=new De({});result=new De({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};deletedIds=new Set;loadedCount=0;constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}removeDeletedObjects(e){if(e.length===0)return;for(let t of e)this.deletedIds.add(t);let t=this.result.value,n=t.objects.filter(e=>!this.deletedIds.has(e.id)),r=t.objects.length-n.length;this.result.value={...t,objects:n};let i=this.facets.value;r>0&&typeof i.total==`number`&&(this.facets.value={...i,total:Math.max(0,i.total-r)})}reset(e=!1){this.initialized=!1,this.deletedIds.clear(),this.loadedCount=0,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:!e||this.result.value.hasMore};let r=this.limit,i=e?this.loadedCount:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};if(this.loadedCount=e?this.loadedCount+a.length:a.length,!e&&this.deletedIds.size>0)for(let e of[...this.deletedIds])a.some(t=>t.id===e)||this.deletedIds.delete(e);let s=this.deletedIds.size>0?a.filter(e=>!this.deletedIds.has(e.id)):a;return this.result.value={isLoading:!1,objects:e?this.objects.concat(s):s,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const z$=dt(void 0);function B$(){return _t(z$)}function V$(){return rt(B$().facets)}function H$(){let e=B$();return{...rt(e.result),search:e}}function U$(){let e=B$();return rt(e.facets).total}const W$=Xt.getFixedT(null,Yt);var G$;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(G$||={});async function K$(e){try{let t=await e.arrayBuffer(),n=new nr;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function q$(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await K$(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function J$(){let{client:e}=q(),t=nt();return{checkDocumentProcessing:V(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await q$(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results.filter(e=>typeof e.id==`string`)}else{let t={query:r,select:`id content.etag`};a=(await e.store.objects.find(t)).flatMap(e=>typeof e.id==`string`?[{id:e.id,content:e.content}]:[])}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=G$.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==G$.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=G$.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===G$.UPDATE).length}`)})(),t.forEach(e=>{e.action||=G$.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===G$.CREATE).length,toUpdate:t.filter(e=>e.action===G$.UPDATE).length,toSkip:t.filter(e=>e.action===G$.SKIP).length}),t}catch(e){throw t({title:W$(`store.errorInUploadProcessingCheck`),status:`error`,description:Ge(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${Ge(e)}`,{cause:e})}},[e,t])}}Q();function Y$({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0,initialTypeId:h,defaultProperties:g}){let{client:_}=q(),{registry:v}=rQ(),y=nt(),{t:b}=K(),x=l??b(`upload.uploadFiles`),[S,C]=G([]),[w,T]=G([]),[E,D]=G(!1),[O,k]=G(null),[A,j]=G([]),[M,N]=G(!1),[P,F]=G(!1),[I,L]=G(0),[ee,R]=G(Date.now()),[te,ne]=G(void 0),[re,ie]=G(null),[ae,de]=G(x),[fe,pe]=G(``);H(()=>{s&&_.store.collections.retrieve(s).then(ne)},[_.store.collections.retrieve,s]),H(()=>{M?(de(b(`upload.uploadingFiles`)),pe(`${Math.round(I)}% complete`)):P?(de(b(`upload.uploadComplete`)),pe(``)):E?(de(b(`upload.fileAnalysisResults`)),pe(`${S.length} file${S.length===1?``:`s`}`)):S.length>0?(de(x),pe(b(`upload.checkingForDuplicates`))):(de(x),pe(``))},[M,P,E,x,I,S.length,b]);let me=()=>!te&&!c?null:n(oe,{className:`mb-4`,status:`default`,icon:t(o_,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:b(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[te&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:b(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:te.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:b(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[he,ge]=G({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:_e}=J$(),ve=U(()=>v?.types||[],[v?.types]),ye=V(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await _e(e,c,s);T(t);let n=t.filter(e=>e.action===G$.CREATE).length,r=t.filter(e=>e.action===G$.UPDATE).length,i=t.filter(e=>e.action===G$.SKIP).length;ge({toCreate:n,toUpdate:r,toSkip:i}),y({title:b(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),D(!0)}catch(e){console.error(`Error processing files:`,e),y({title:b(`agent.error`),description:b(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[_e,s,c,b,y]);H(()=>{r&&(T([]),D(!1),k(h?v?.getType(h)??null:null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),a&&a.length>0?(C(a),ye(a)):C([]),R(Date.now()))},[a,h,r,ye,x,v]);let be=()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),R(Date.now()),i()},xe=e=>{e&&e.length>0&&(C(e),ye(e))},Se=async()=>{if(!w.length)return;let e=O?.id||null,t=w.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===G$.CREATE?`create`:e.action===G$.UPDATE?`update`:`skip`}));j(t),N(!0),F(!1);let n=w.filter(e=>e.action===G$.SKIP),r=w.filter(e=>e.action===G$.UPDATE),i=w.filter(e=>e.action===G$.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;y({title:b(`upload.processingFilesAction`,{action:n}),description:b(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(j(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await _.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await _.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name,properties:g},{collection_id:s});j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),j(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:Ge(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:Ge(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&j(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return L(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),j(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:b(`upload.uploadProcessInterrupted`),status:`failed`,type:O?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}:e)):e}),N(!1),F(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),y({title:b(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),ie(a)},Ce=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[b(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:b(`store.optional`)}),t(We,{description:b(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]}),t(we,{options:ve,value:O,optionLabel:e=>e?e.name:b(`store.selectContentTypeLabel`),placeholder:b(`store.selectContentTypeAuto`),onChange:e=>k(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!O&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),b(`store.automaticTypeDetection`),t(We,{description:b(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})})]});return n(se,{isOpen:r,onClose:be,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(ue,{description:fe,children:ae}),p?n(ce,{children:[u,me(),Ce()]}):S.length===0&&!f?n(ce,{className:`flex flex-col items-center justify-center p-8`,children:[me(),t(Ot,{onDrop:xe,message:b(`upload.dragAndDrop`),buttonLabel:b(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!M&&!P?t(ce,{children:E?n(e,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(wb,{className:`size-5 text-info`}),t(`span`,{className:`font-medium`,children:b(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Nh,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:b(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Ah,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:b(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toSkip})]})]})})}),Ce(),t(oe,{className:`mb-4`,status:`info`,children:he.toCreate+he.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:b(`upload.filesReadyToProcess`,{count:he.toCreate+he.toUpdate})}),t(`p`,{children:he.toSkip>0&&b(`upload.filesToSkip`,{count:he.toSkip})})]}):he.toSkip>0?t(`span`,{children:b(`upload.allFilesExist`,{count:he.toSkip})}):t(`span`,{children:b(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(je,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:b(`upload.analyzingFiles`)})]})}):M?n(ce,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${I}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:A.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(Zg,{className:`size-5 text-muted`}),e.status===`uploading`&&t(je,{size:`sm`}),e.status===`success`&&t(Nh,{className:`size-5 text-success`}),e.status===`error`&&t(Gh,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&b(`agent.waiting`),e.status===`uploading`&&b(`agent.uploading`),e.status===`success`&&(e.action===`create`?b(`store.created`):e.action===`update`?b(`store.updated`):b(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(ce,{children:n(`div`,{className:`mb-4`,children:[me(),t(Lt,{files:A.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:te?.name})]})}),(()=>{if(p)return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:O?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),be()},children:O?b(`upload.useTypeName`,{typeName:O.name}):b(`upload.useAutoDetection`)})]});if(S.length===0&&!f)return t(le,{children:t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)})});if(!M&&!P){let e=E;return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{disabled:!e,onClick:Se,children:he.toCreate+he.toUpdate>0?b(`agent.upload`):b(`upload.continue`)})]})}return M?t(le,{children:t(o,{variant:`ghost`,disabled:!0,children:b(`agent.uploading`)})}):n(le,{children:[t(o,{variant:`ghost`,onClick:()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0})},children:b(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&re&&d(re),be()},children:b(`agent.close`)})]})})()]},ee)}function X$(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=q(),a=B$(),o=nt(),s=Xt.getFixedT(null,Yt),{checkDocumentProcessing:c}=J$();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===G$.CREATE).length,v=g.filter(e=>e.action===G$.UPDATE).length,y=g.filter(e=>e.action===G$.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===G$.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===G$.CREATE||e.action===G$.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===G$.CREATE).length} create, ${b.filter(e=>e.action===G$.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===G$.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:Ge(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:Ge(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const Z$=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Q$({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t($$,{...i,onUpload:n,isGridView:e,collectionId:r}):t(e1,{...i,isGridView:e})}function $$({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=G(!1),[l,u]=G([]),[d,f]=G(!1),[p,m]=G(null),[h,g]=G(!1),_=B$(),v=nt(),{t:y}=K(),{checkDocumentProcessing:b}=J$(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:it(`bg-white dark:bg-muted opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(je,{size:`xl`})}),t(e1,{...o,isGridView:e}),t(`div`,{className:it(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(Ot,{onDrop:x,message:`Drop files or folders here to upload`,className:it(`absolute inset-0 bg-white/90 dark:bg-muted/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(Y$,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function e1({objects:e,layout:n=Z$,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=$Q(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=t1(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=n1(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=U(()=>{let e=n.length>0?n:Z$;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new N$(e,s))},[n,s]);return t(l?L$:I$,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function t1(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function n1(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function r1({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=q(),l=U(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new R$(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(z$.Provider,{value:l,children:e})}Q();const i1=`vertesia.content_store.lastDisplayedView`;function a1({onUpdate:e}){let{t:n}=K(),[r,i]=G(localStorage.getItem(i1)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(i1,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(i1,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,title:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?ob:I_,{})})}a1.LAST_DISPLAYED_VIEW=i1,Q();const o1=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function s1({onChange:e,selectedIds:n}){return t(r1,{children:t(c1,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function c1({onRowClick:e,selectedIds:r}){let{t:i}=K(),a=V(e=>!!r?.has(e.id),[r]),[s,c]=G(!1),[l,u]=G(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=H$(),g=W(null);Qe(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),H(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=V$(),v=B$();return p?t(M,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t(_Q,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(hy,{size:16})}),t(a1,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(Q$,{objects:m||[],isLoading:!m.length&&f,layout:o1,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}Q();function l1(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function u1({onSend:e,value:r,onValueChange:i,onStop:a,approvalModeSlot:s,mcpSlot:c,disabled:l=!1,isSending:u=!1,isStopping:d=!1,isStreaming:f=!1,isCompleted:p=!1,contextWindowUsage:m,onCompactContext:h,isCompactingContext:g=!1,activeTaskCount:_=0,activeWorkstreams:v=[],onSelectWorkstream:y,placeholder:b,onFilesSelected:x,uploadedFiles:S=[],onRemoveFile:C,onRemoveProcessingFile:T,acceptedFileTypes:E,maxFiles:D=5,processingFiles:O,artifactRunId:k,hasProcessingFiles:A=!1,renderDocumentSearch:j,selectedDocuments:M=[],onRemoveDocument:N,hideObjectLinking:P=!1,hideFileUpload:F=!1,disableDropZone:I=!1,className:L,inputClassName:ee}){let{t:R}=K(),te=b??R(`agent.typeYourMessage`),ne=W(null),re=W(null),[ie,oe]=G(``),le=r??ie,de=V(e=>{r===void 0&&oe(e),i?.(e)},[r,i]),[fe,pe]=G(!1),[me,he]=G(!1),[ge,_e]=G(!1),ve=!!(x&&!F),ye=ve&&!I,be=!P||ve||!!j,xe=S.length>=D,Se=T??C,Ce=U(()=>v.filter(e=>e.status===`running`||e.status===`canceling`),[v]),we=Ce.length||_,Te=m?R(`agent.contextUsageCompactLabel`,{percent:m.usedPercent}):void 0,Ee=m?R(`agent.contextTokenUsage`,{used:l1(m.usedTokens),limit:l1(m.checkpointTokens)}):void 0,De=U(()=>{let e=[];if(!F&&O)for(let t of O.values()){let n=t.preview_url,r=t.status===pn.UPLOADING?R(`agent.uploading`):t.status===pn.PROCESSING?R(`agent.processing`):t.status===pn.ERROR?R(`agent.error`):t.status===pn.READY?R(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!Se,statusLabel:r,statusTone:t.status===pn.ERROR?`destructive`:t.status===pn.READY?`success`:`attention`})}if(!F)for(let t of S)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!C,statusLabel:R(`agent.ready`),statusTone:`success`});for(let t of M)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!N,statusTone:`info`});return e},[Se,F,N,C,O,M,R,S]);H(()=>{!l&&p&&ne.current?.focus()},[l,p]);let Oe=V(e=>{if(!ve||!x)return;let t=Array.from(e),n=D-S.length,r=t.slice(0,n);r.length>0&&x(r)},[ve,x,D,S.length]),ke=V(e=>{e.preventDefault(),e.stopPropagation(),ye&&_e(!0)},[ye]),Ae=V(e=>{e.preventDefault(),e.stopPropagation(),_e(!1)},[]),Me=V(e=>{e.preventDefault(),e.stopPropagation(),_e(!1),ye&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&Oe(e.dataTransfer.files)},[ye,Oe]),Ne=V(e=>{if(!ve)return;let t=AX(e.clipboardData?.items);t.length>0&&Oe(t)},[ve,Oe]),Pe=V(e=>{ve&&e.target.files&&e.target.files.length>0&&(Oe(e.target.files),e.target.value=``)},[ve,Oe]),Fe=V(()=>{re.current?.click()},[]),Ie=V(()=>he(!1),[]),Le=V(e=>he(!1),[]),Re=()=>{let t=le.trim();!t||l||u||A||(e(t),de(``))},ze=()=>{a&&!d&&a()},Be=W(0),Ve=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),le.trim().length>0&&Re();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,de));return}if(e.key===`Escape`&&f&&a){let e=Date.now();e-Be.current<500?(ze(),Be.current=0):Be.current=e}},He=V(()=>{let e=ne.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return H(()=>{He()},[le,He]),n(`div`,{className:z(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,ge&&ye&&`bg-info/10 border-info`,L),onDragOver:ye?ke:void 0,onDragLeave:ye?Ae:void 0,onDrop:ye?Me:void 0,children:[ge&&ye&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2`,children:[t(wb,{className:`size-5`}),R(`agent.dropFilesToUpload`)]})}),ve&&t(`input`,{ref:re,type:`file`,multiple:!0,accept:E,onChange:Pe,className:`hidden`}),t(ZX,{activeWorkstreams:v,onSelectWorkstream:y}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[De.length>0&&t(VW,{items:De,artifactRunId:k,variant:`composer`,onRemove:e=>{O?.has(e)?Se?.(e):S.some(t=>t.id===e)?C?.(e):N?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(Ue,{ref:ne,value:le,onKeyDown:Ve,onChange:e=>de(e.target.value),onPaste:Ne,disabled:l,"aria-label":te,placeholder:te,rows:1,style:{maxHeight:`160px`},className:z(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,ee)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[be&&n(w,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,title:R(`agent.addAttachment`),children:t(oy,{className:`size-4`})}),children:[!P&&n(ae,{onClick:()=>pe(!0),isDisabled:!p,children:[t(Hv,{className:`size-4`}),R(`agent.linkObject`)]}),ve&&n(ae,{onClick:Fe,isDisabled:xe,children:[t(wb,{className:`size-4`}),R(`agent.upload`)]}),j&&n(ae,{onClick:()=>he(!0),children:[t(Gg,{className:`size-4`}),t(`span`,{children:R(`agent.searchDocuments`)}),M.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:M.length})]})]}),s,c,m&&t(We,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:R(`agent.contextRemainingUntilCompact`,{percent:m.remainingPercent})}),Ee&&t(`span`,{className:`mt-1 block text-foreground/80`,children:Ee})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:z(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":Te,onClick:h,disabled:!h||g,children:g?t(je,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:z(`size-8 -rotate-90`,m.usedPercent>=90?`text-destructive`:m.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-m.usedPercent},className:`stroke-current`})]})})}),Ce.length===0&&we>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(xm,{className:`size-3 text-attention`}),R(`agent.activeWorkstreams`,{count:we})]})})]}),f&&a&&!le.trim()?t(o,{onClick:ze,disabled:d,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:R(`agent.stopTooltip`),children:d?t(je,{size:`sm`}):t(rb,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:Re,disabled:l||u||!le.trim()||A,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:R(A?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":R(A?`agent.waitForFiles`:`agent.send`),children:u?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]}),n(se,{isOpen:fe,onClose:()=>pe(!1),className:`min-w-[60vw]`,children:[t(ue,{children:R(`agent.linkObject`)}),t(ce,{className:`pb-6`,children:t(s1,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=le||``,r=ne.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);de(i),pe(!1),setTimeout(()=>{if(ne.current){ne.current.focus();let e=r+t.length;ne.current.setSelectionRange(e,e)}},100)}})})]}),j?.({isOpen:me,onClose:Ie,onSelect:Le})]})}function d1({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=qt(),i=U(()=>Wt(e),[e]),a=U(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(Et,{type:`proposal`,message:`Loading options...`}):a?t(Tt,{type:`proposal`,fallbackCode:e,children:t(jH,{...a})}):t(Et,{type:`proposal`,error:`Invalid proposal specification`})}const f1=gt(function({code:e}){let n=U(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),p1=gt(function({code:e}){let n=U(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),m1={chart:f1,"vega-lite":p1,vegalite:p1,"fusion-fragment":Jn,proposal:d1,askuser:d1};function h1({url:e,code:n}){let[r,i]=G(null);return H(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function g1(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=An(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(h1,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function _1({children:e}){let{client:n}=q(),[r,i]=G(m1);return H(()=>{g1(n).then(e=>{i({...m1,...e})})},[n]),t(Dt,{components:r,children:e})}Q();const v1=new Map,y1=[400,1200];async function b1(e,t,n){for(let r=0;;r++)try{return await e.agents.sendSignal(t,`FileBatchClosed`,n),!0}catch(e){if(r>=y1.length)return console.error(`Failed to close staged file batch:`,e),!1;await new Promise(e=>setTimeout(e,y1[r]))}}const x1=new Set([`COMPLETED`,`FAILED`,`CANCELED`,`CANCELLED`,`TERMINATED`,`TIMED_OUT`]);function S1(e){return!!e&&x1.has(e.toUpperCase())}function C1(e,t){return t&&S1(e)&&e?.toUpperCase()!==`FAILED`}function w1(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===409}function T1(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function E1(e){return e===`running`||e===`canceling`}function D1(e){return!E1(e)}function O1(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function k1(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=O1(r?.prompt),a=i&&i>0?i:O1(r?.total),o=O1(n.checkpoint_threshold)??O1(n.checkpoint_at);if(typeof a!=`number`||typeof o!=`number`||o<=0)continue;let s=Math.max(0,Math.min(100,Math.round(a/o*100)));return{usedTokens:a,checkpointTokens:o,usedPercent:s,remainingPercent:Math.max(0,100-s)}}}function A1(e,t){return!D1(e.status)||!E1(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function j1(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:eU(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function M1(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function N1(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function P1(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=T1(e.timestamp),a=j1(e),o=UH(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=BH(e);if(!o&&!c&&l&&!n.has(s))return;let u=N1(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=HH(e);d?u.status=d:l||(M1(e)?u.status=`failed`:(e.type===J.COMPLETE||e.type===J.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),E1(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!E1(e.status))-Number(!E1(t.status));return n===0?E1(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function F1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function I1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function L1(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=A1(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=A1(e[r],t);return}e.push(t)}function R1(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function z1(e,t=!0){let[n,r]=G(()=>Math.max(0,Math.floor((Date.now()-T1(e))/1e3)));return H(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-T1(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function B1(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*CW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function V1({message:e,startedAt:r}){let{t:i}=K(),a=z1(r),o=B1();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(aW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,R1(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:CW[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(iW,{color:`blue`})})]})]})}function H1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function U1(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function W1(e){return U1(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function G1(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function K1(e){let{agentRunId:n,startWorkflow:r,resourceResolver:i}=e;if(n){let r=t(_1,{children:t(Y1,{...e,agentRunId:n})});return i?t(Ct,{value:i,children:r}):r}return r?t(J1,{...e}):t(q1,{})}function q1(){let{t:e}=K();return n(oe,{status:`info`,icon:t(Am,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function J1({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,startViewVariant:b=`default`,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,initialToolApprovalMode:T,onAgentWorkingChange:E}){let{t:D}=K(),O=b!=="default",k=b===`expanded-composer`,A=!_,j=l??D(`agent.typeYourMessage`),M=u??D(`agent.startAgent`),N=d??D(`agent.startNewConversation`),{client:P}=q(),[F,I]=G(``),[L,ee]=G(!1),[R,te]=G(null),[ne,re]=G(null),[ie,ae]=G(null),[oe,se]=G(()=>kn(T,r)),ce=nt(),le=W(null),ue=W(null),[de,fe]=G([]),[pe,me]=G(!1),he=pe?de:de.slice(0,3),ge=de.length-3;H(()=>{E?.(L)},[L,E]);let[_e,ve]=G(!1),ye=W(0),be=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current++,e.dataTransfer?.types?.includes(`Files`)&&ve(!0))},[A]),xe=V(e=>{A&&(e.preventDefault(),e.stopPropagation())},[A]),Se=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current--,ye.current===0&&ve(!1))},[A]),Ce=V(e=>{if(A&&(e.preventDefault(),e.stopPropagation(),ye.current=0,ve(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);fe(e=>[...e,...t].slice(0,h))}},[h,A]),we=V(e=>{if(!A)return;let t=AX(e.clipboardData?.items);t.length>0&&fe(e=>[...e,...t].slice(0,h))},[A,h]),Te=V(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);fe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),Ee=V(e=>{fe(t=>t.filter((t,n)=>n!==e))},[]);H(()=>{de.length<=3&&me(!1)},[de.length]),H(()=>{le.current&&le.current.focus()},[]);let De=async()=>{if(!i)return;let e=F.trim();if(!(!e||L)){ee(!0);try{sessionStorage.removeItem(`plan-panel-shown`),ce({title:A&&de.length>0?D(`agent.startingAgentUploading`):D(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
1378
1378
|
`)),A&&de.length>0){let e=de.map(e=>e.name).join(`, `);n=[n,``,`[System: ${de.length} file(s) are being uploaded: ${e}. Please wait for the "Files Ready" notification before processing them.]`].join(`
|
|
1379
|
-
`)}let r=await i(n,{tool_approval_mode:oe});if(!r){re(null),ae(null);return}re(n),ae(Date.now());let a=r.agent_run_id,o=!0;if(A&&de.length>0){let e=`batch-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t=[],n=[];for(let e of de)try{let n=`files/${e.name}`;await P.agents.uploadArtifact(a,n,e);let r=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;await P.agents.sendSignal(a,`FileUploaded`,{id:r,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${n}`,artifact_path:n}),t.push(r)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t),n.push({name:e.name,error:t instanceof Error?t.message:String(t)})}o=await y1(P,a,{batch_id:e,file_ids:t,failed_uploads:n.length>0?n:void 0}),o&&fe([]),n.length>0&&ce({title:D(`agent.stagedFilesUploadFailed`),status:`warning`,duration:6e3,description:n.map(e=>e.name).join(`, `)})}p?.(),te(a),I(``),ce(o?{title:D(`agent.agentStarted`),status:`success`,duration:3e3}:{title:D(`agent.stagedFilesNotDelivered`),status:`error`,duration:8e3,description:D(`agent.stagedFilesNotDeliveredDescription`)})}catch(e){re(null),ae(null),ce({title:D(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:D(`agent.unknownError`)})}finally{ee(!1)}}},Oe=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),De();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,I))}},ke=V(()=>{let e=le.current;if(e){if(k){e.style.height=`100%`;return}e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`}},[k]);return H(()=>{ke()},[F,ke]),R?t(W1,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,onAgentWorkingChange:E,agentRunId:R,title:d,pendingStartMessage:ne??void 0,pendingStartTimestamp:ie??void 0,initialToolApprovalMode:oe}):t(`div`,{className:z(`flex flex-col items-center bg-background`,O&&!k?``:`h-full`,C),children:n(`div`,{className:z(`relative flex w-full flex-col overflow-hidden border-0`,O&&!k?``:`h-full`,c?``:`max-w-4xl`),onDragEnter:A?be:void 0,onDragOver:A?xe:void 0,onDragLeave:A?Se:void 0,onDrop:A?Ce:void 0,children:[A&&_e&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to stage for upload`]})}),A&&t(`input`,{ref:ue,type:`file`,multiple:!0,accept:m,onChange:Te,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(hg,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:N})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,title:D(`agent.close`),className:`text-muted hover:text-foreground`,children:t(Gb,{className:`size-4`})})]}),t(`div`,{className:z(`flex flex-col items-center justify-end bg-background px-4`,O?`shrink-0 pt-3`:`flex-1 overflow-y-auto`),children:ne&&ie?t(I1,{message:ne,startedAt:ie}):t(`div`,{className:z(`mx-auto flex w-full max-w-3xl flex-col justify-end`,O?``:`min-h-full py-8`),children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:z(`bg-background px-4 pb-safe-area-4 pt-2`,k?`flex min-h-0 flex-1 flex-col`:`shrink-0`),children:n(`div`,{className:z(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,k&&`min-h-0 w-full flex-1`,x),children:[A&&de.length>0&&n(`div`,{className:`flex flex-wrap gap-2`,children:[he.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:D(`agent.fileStagedTooltip`),children:[t(Gg,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:D(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>Ee(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(Gb,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`)),de.length>3&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":pe,onClick:()=>me(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!pe&&n(`span`,{children:[`+`,ge]}),D(pe?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,pe&&`rotate-180`),"aria-hidden":`true`})]})]}),t(Ue,{ref:le,value:F,onChange:e=>I(e.target.value),onKeyDown:Oe,onPaste:we,placeholder:j,disabled:L,rows:2,className:z(`min-h-[72px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,k?`min-h-0 flex-1 overflow-y-auto`:`overflow-hidden`,S),style:k?{minHeight:`72px`,maxHeight:`none`}:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[A&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ue.current?.click(),disabled:L||de.length>=h,"aria-label":D(`agent.upload`),className:`rounded-full text-muted`,title:D(`agent.upload`),children:t(wb,{className:`size-4`})}),r&&t(Yb,{mode:oe,onChange:se,disabled:L})]}),t(o,{onClick:De,disabled:!F.trim()||L,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:M,children:L?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]})})]})})}function W1({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:ee,className:R,inputContainerClassName:te,inputClassName:ne,composerContext:re,fusionData:ie,fileUploadRef:ae,sendMessageRef:de,onMessage:fe,onAgentWorkingChange:pe,onProcessingFilesChange:me,processingFiles:he,onPlansChange:ge,onWorkstreamStatusChange:_e,viewMode:ve,onViewModeChange:ye,onShowInputChange:be,stopRef:xe,onStoppingChange:Se,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:je,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,payloadContent:Re,conversationContent:ze,conversationTab:Be=!1,pendingStartMessage:Ve,pendingStartTimestamp:He,initialToolApprovalMode:Ue,enablePlayback:We,showPlaybackToggle:Ge=!0,messageFilter:Ke,initialWorkstream:qe}){let{t:Je}=K(),{client:Ye}=q(),Xe=nt(),{messages:Ze,streamingMessages:Qe,isCompleted:$e,initialHistoryStatus:et,debugChunkFlash:tt,addOptimisticMessage:rt,updateOptimisticMessageStatus:it,reconnect:at,agentRunStatus:B,workflowRunId:ot,serverFileUpdates:st}=VX(Ye,r,fe),{plans:ct,activePlanIndex:lt,setActivePlanIndex:ut,workstreamStatusMap:dt,showInput:ft,showSlidingPanel:pt,setShowSlidingPanel:mt}=AX(Ze,a,c),{openDocuments:ht,activeDocumentId:gt,isDocPanelOpen:_t,docRefreshKey:vt,closeDocPanel:yt,selectDocument:bt,openDocInPanel:xt,updateDocumentTitle:St}=GX(Ze),{processingFiles:Ct,hasProcessingFiles:wt,handleFileUpload:Tt,removeProcessingFile:Et,clearProcessingFiles:Dt}=YX(Ye,r,st,Xe,U(()=>qW(Ze),[Ze])),Ot=a&&!j,kt=V(e=>{Et(e)},[Et]),At=W(null),jt=W(null),Mt=W(null),[Nt,Pt]=G(!1),[Ft,It]=G(!1),[Lt,Rt]=G(`sliding`),zt=ve??Lt,Bt=V(e=>{ye?ye(e):Rt(e)},[ye]),[Vt,Ht]=G(!1),[Wt,Gt]=G(!1),[Kt,qt]=G(qe||`all`),Jt=W(qe);H(()=>{qe&&qe!==Jt.current&&(Jt.current=qe,qt(qe))},[qe]);let[Yt,Xt]=G(`live`),[Zt,Qt]=G(!1),[$t,en]=G(0),[tn,nn]=G([]),[rn,an]=G([]),[on,sn]=G(!1),cn=U(()=>Ue===void 0&&a?void 0:kn(Ue,a),[Ue,a]),[ln,un]=G(cn),dn=W(!1),fn=W(0),mn=W(!1),hn=W(0),gn=W(null);H(()=>{un(cn)},[cn]);let _n=W(Nt);_n.current=Nt;let vn=W(wt);vn.current=wt;let yn=W(Ct);yn.current=Ct;let bn=U(()=>{let e=Ze.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[Ze]),xn=U(()=>bn?.type===J.TERMINATED?`TERMINATED`:bn?.type===J.COMPLETE&&(!B||B===`RUNNING`)?`COMPLETED`:B,[bn,B]),Sn=U(()=>{let e=xn?.toUpperCase();return e===`COMPLETED`||e===`FAILED`||e===`CANCELED`||e===`CANCELLED`||e===`TERMINATED`||e===`TIMED_OUT`},[xn]),Cn=U(()=>Sn&&xn?.toUpperCase()!==`FAILED`&&!!f,[Sn,xn,f]),wn=!E||Cn,Tn=U(()=>xn?.toUpperCase()===`FAILED`||B?.toUpperCase()===`FAILED`,[xn,B]),En=U(()=>{for(let e=Ze.length-1;e>=0;e--){let t=Ze[e];if(t.type!==J.ERROR||eU(t)!==`main`)continue;let n=typeof t.message==`string`?t.message.trim():``;if(n)return n}},[Ze]),Dn=W(Sn);Dn.current=Sn;let On=W(Cn);On.current=Cn;let An=U(()=>{let e=ct[lt]||{plan:{plan:[]},timestamp:0},t=dt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[ct,lt,dt]),jn=U(()=>k1(Ze),[Ze]),Mn=U(()=>{let e=[...jn];for(let t of rn)M1(e,j1(t));for(let t of tn)M1(e,A1(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!x1(e.workstream.status))-Number(!x1(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[jn,tn,rn]),Nn=U(()=>Mn.filter(e=>x1(e.status)),[Mn]),Pn=U(()=>Nn.filter(e=>e.status===`running`).length,[Nn]),Fn=U(()=>{if(Kt===`all`)return;let e=Mn.find(e=>e.workstream_id===Kt||e.launch_id===Kt);return e?FH(e.workstream_id,e.interaction):FH(Kt)},[Kt,Mn]),In=U(()=>{if(u)return u;if(Fn)return Je(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Fn})},[Fn,u,Je]),Ln=Ge&&We===void 0&&_C(),Rn=We??(vC()||Zt),zn=U(()=>Ze.filter(e=>!XH(e)&&!(P?.includes(e.type)??!1)),[P,Ze]),Bn=U(()=>rU(zn,Kt),[Kt,zn]),Vn=U(()=>hC(Bn,Yt,Rn),[Rn,Yt,Bn]),Hn=Vn.cursor,Un=Vn.isLive,Wn=Rn&&!Un&&Vn.cursorIndex===Bn.length-1,Gn=Vn.displayedMessages,Kn=U(()=>Ke?Gn.filter(e=>Ke(e)):Gn,[Gn,Ke]),qn=U(()=>Ke?zn.filter(e=>Ke(e)):zn,[Ke,zn]),Jn=Un?Qe:_1,Xn=U(()=>k1(Gn),[Gn]),Zn=U(()=>Xn.filter(e=>x1(e.status)),[Xn]),Qn=U(()=>$e||!ZH(Ze),[$e,Ze]),$n=Un||Wn?Qn:!1,er=!Qn&&!Sn;H(()=>{pe?.(er)},[er,pe]);let tr=U(()=>{let e=new Set;for(let t of Gn)NU(r,t)&&e.add(kU(t));return tW(Gn,`main`,e)},[r,Gn]),nr=!!tr&&!Tn&&(!Sn||Cn),rr=Rn&&!Un,ir=wn&&!rr,ar=U(()=>w1(Ze),[Ze]),or=h&&!Sn&&Un&&!!ar;H(()=>{qH(`conversation render state`,{agentRunId:r,messageCount:Ze.length,playbackMessageCount:Bn.length,displayedMessageCount:Kn.length,streamingCount:Qe.size,displayedStreamingCount:Jn.size,initialHistoryStatus:et,isCompleted:$e,effectiveIsCompleted:Qn,displayedIsCompleted:$n,agentRunStatus:B,effectiveWorkflowStatus:xn,isWorkflowTerminal:Sn,playbackCursor:Hn,isPlaybackEnabled:Rn,isPlaybackLive:Un,isPlaybackAtLatest:Wn,activeWorkstream:Kt,showInitialRequest:et===`empty`&&Ze.length===0,pendingStartVisible:Ze.length===0&&!Qn&&!!Ve})},[Kt,r,B,Hn,$n,Kn.length,Jn.size,Qn,xn,et,$e,Wn,Rn,Un,Sn,Ze.length,Ve,Bn.length,Qe.size]);let sr=V(()=>{Qt(e=>!e)},[]),cr=V(e=>{let t=fC(Hn,Bn.length),n=fC(e,Bn.length);Rn&&(n>t||e===`live`&&Hn!==`live`)&&(mn.current=!0,en(e=>e+1)),Xt(e)},[Hn,Rn,Bn.length]);H(()=>{if(!Rn){Yt!==`live`&&Xt(`live`);return}Hn!==Yt&&Xt(Hn)},[Hn,Rn,Yt]),H(()=>{if(!Rn||!mn.current)return;mn.current=!1;let e=window.requestAnimationFrame(()=>{At.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Rn,$t]);let lr=V(e=>{ut(e)},[ut]),[ur,dr]=G(ze||Be?`conversation`:`plan`),[fr,Y]=G(null),[pr,mr]=G(400),[hr,gr]=G(!1),[_r,vr]=G(!1),yr=A&&!_r&&(pt||_t||!k&&Mn.length>0||!!ze||Be),br=W(_t);H(()=>{_t&&!br.current&&vr(!1),br.current=_t},[_t]);let xr=V(()=>{yr?(vr(!0),mt(!1)):(vr(!1),mt(!0),sessionStorage.setItem(`plan-panel-shown`,`true`))},[yr,mt]);H(()=>{!yr&&hr&&gr(!1)},[yr,hr]),H(()=>{if(!hr)return;let e=e=>{let t=Mt.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;mr(Math.min(Math.max(i,300),r))},t=()=>{gr(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[hr]);let Sr=V(()=>{vr(!0),mt(!1),yt()},[mt,yt]),Cr=V(e=>{/\.md$/i.test(e)&&(vr(!1),Y(e),dr(`artifacts`),mt(!0))},[mt]),wr=W(null);H(()=>{let e,t;for(let n of Ze){let r=n.details;r?.event_class===`display_artifact`&&typeof r.path==`string`&&(e=r.path,t=`${n.timestamp??``}:${r.path}`)}!e||!t||t===wr.current||(wr.current=t,vr(!1),Y(e),dr(`artifacts`),mt(!0))},[Ze,mt]);let Tr=V(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),xt(n),dr(`documents`)},children:r}),[xt]),Er=je??Tr;H(()=>(ae&&(ae.current=Ot?Tt:null),()=>{ae&&(ae.current=null)}),[ae,Tt,Ot]),H(()=>{me?.(Ct)},[Ct,me]),H(()=>{ge?.(ct,lt)},[ct,lt,ge]),H(()=>{_e?.(dt)},[dt,_e]),H(()=>{Y(null),dn.current=!1,sn(!1),nn([]),an([])},[r]),H(()=>{let e=et!==`loading`&&!Qn&&!Sn&&!on;if(qH(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:et,effectiveIsCompleted:Qn,isWorkflowTerminal:Sn,isWorkstreamQueryUnavailable:on}),!e){nn(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){qH(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{qH(`active workstreams fetch start`,{agentRunId:r});let e=await Ye.agents.getActiveWorkstreams(r);if(t)return;if(qH(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),nn(e.running??[]),an(e.completed??[]),e.unavailable){sn(!0);return}dn.current=!1}catch(e){if(t)return;nn(e=>e.length===0?e:[]),sn(!0),qH(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),dn.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Ye.agents,r,Qn,et,Sn,on]),H(()=>{if(Ze.length!==0){if(Cn){be?.(!0);return}if(!ft){be?.(!1);return}if(xn&&xn!==`RUNNING`){be?.(!1);return}xn!==null&&be?.(!0)}},[ft,xn,Ze.length,be,Cn]);let Dr=V(async()=>{let e=gn.current;e&&await e},[]),Or=V((e,t)=>{let n=e.trim();if(!n||_n.current||Dn.current&&!On.current)return;if(vn.current){Xe({status:`warning`,title:Je(`agent.filesProcessing`),description:Je(`agent.waitForFilesProcessing`),duration:3e3});return}let i=zU(t);Pt(!0);let a=F?.()||[],o=ee?.()||{},s=n;a.length>0&&!/store:\S+/.test(n)&&(s=[n,``,`Attachments:`,...a.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
1380
|
-
`));let c=Array.from(
|
|
1381
|
-
`));let l=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,u={timestamp:Date.now(),workflow_run_id:r,type:J.QUESTION,message:s,workstream_id:`main`,details:{_optimistic:!0,_messageId:l,_deliveryStatus:`sending`,...t?.editing_action?{editing_action:t.editing_action}:{},...t?.request_input_response?{request_input_response:t.request_input_response}:{}}};rt(u);let d={...a.length>0?{attached_docs:a.map(e=>e.id)}:{},...o,...t,id:l,_messageId:l},f=()=>Ye.agents.sendSignal(r,`UserInput`,{message:s,client_message_id:l,metadata:d}),p=()=>{it(l,`received`),I?.(),Dt()};i&&jU(r,i),(async()=>{await Dr(),Dn.current&&(await Ye.agents.restart(r),at()),await f(),p()})().catch(e=>{i&&MU(r,i),it(l,`failed`),Xe({status:`error`,title:Je(`agent.failedToSend`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}).finally(()=>{Pt(!1)})},[r,Ye,Xe,F,ee,I,Dt,at,rt,it,Je,Dr]);H(()=>(de&&(de.current=Or),()=>{de?.current===Or&&(de.current=null)}),[Or,de]);let kr=V(async(e,t)=>{try{await Ye.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}Or(Je(`agent.mcpConnectedMessage`,{name:e.name}),t)},[Ye,r,Or,Je]),[Ar,jr]=G(void 0);H(()=>{let e=!1,t=hn.current;return Ye.agents.retrieve(r).then(n=>{e||(jr(n.disabled_mcp_collections),hn.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&un(kn(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Ye,r]);let Mr=V(e=>{let t=e.length>0?e:void 0;jr(t),Ye.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Nr=V(()=>{Ye.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Pr=V(e=>{let t=kn(e,a),n=ln;hn.current+=1,un(t);let i=Ye.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{un(e=>e===t?n:e),Xe({status:`error`,title:Je(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})});gn.current=i,i.finally(()=>{gn.current===i&&(gn.current=null)})},[r,Ye,a,Je,Xe,ln]),Fr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current++,e.dataTransfer?.types?.includes(`Files`)&&Gt(!0))},[Ot]),Ir=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation())},[Ot]),Lr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current--,fn.current===0&&Gt(!1))},[Ot]),Rr=V(e=>{if(Ot&&(e.preventDefault(),e.stopPropagation(),fn.current=0,Gt(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);Tt(t)}},[Tt,Ot]),zr=V(async()=>{if(Vt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:J.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};rt(t),Ht(!0);try{await Ye.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),it(e,`received`)}catch(t){Xe({status:`error`,title:Je(`agent.failedToInterrupt`),description:t instanceof Error?t.message:Je(`agent.unknownError`),duration:3e3}),it(e,`failed`)}finally{Ht(!1)}},[Vt,r,rt,Ye.agents,Xe,Je,it]),Br=V(async()=>{if(!(Ft||Qn||!Un)){It(!0);try{await Ye.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Xe({status:`error`,title:Je(`agent.failedToCompactContext`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}finally{It(!1)}}},[r,Ye.agents,Qn,Ft,Un,Je,Xe]);H(()=>(xe&&(xe.current=h&&!Qn?zr:null),()=>{xe&&(xe.current=null)}),[xe,Qn,zr,h]),H(()=>{Se?.(Vt)},[Vt,Se]);let Vr=i||Je(`agent.agentConversation`),Hr=async()=>{try{let e=await iU(Ye,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Xe({status:`error`,title:Je(`agent.failedToDownload`),duration:3e3})}},Ur=V(()=>{let e=new Date().toISOString(),t=Qe.size>0?[{cursor:`live`,streamingMessages:Array.from(Qe,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:Vr,agent_run_id:r,exported_at:e,message_count:Ze.length},messages:Ze,...t?{streamingFrames:t}:{}};B1(`${z1(Vr)||`agent-chat`}-${z1(r)}.json`,n),Xe({status:`success`,title:Je(`agent.rewind.fixtureExported`),duration:2e3})},[Vr,r,Ze,Qe,Je,Xe]),[Wr,Gr]=G(!1),Kr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}Gr(!0)},qr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}let e=`${Vr} - ${r}`;if(!L1(jt.current,e)){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.unableToOpenPrint`),duration:4e3});return}Xe({status:`success`,title:Je(`agent.pdfExportReady`),description:Je(`agent.printDialogDescription`),duration:4e3}),Gr(!1)},Jr=U(()=>Ze.filter(e=>e.type===J.COMPLETE||e.type===J.THOUGHT&&e.details?.tool_status===`completed`).length,[Ze]),Yr=U(()=>{if(!fr)return{key:Jr,details:void 0};let e=0,t;for(let n of Ze){let r=n.details;Ut(r,fr)&&(e++,t=r)}return{key:e,details:t}},[Jr,Ze,fr]),Xr=a&&Un&&xn?.toUpperCase()===`RUNNING`,Zr=U(()=>An.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[An.plan]),Qr=e=>t(aZ,{title:Vr,variant:e,isCompleted:Qn,isTerminal:Sn,onClose:s,isModal:c,agentRunId:r,workflowRunId:ot||``,viewMode:zt,onViewModeChange:Bt,showPlanPanel:yr,hasPlan:A&&ct.length>0,showPlanButton:A&&!Be,onTogglePlanPanel:xr,showPlaybackButton:Ln,isPlaybackEnabled:Rn,onTogglePlayback:sr,onDownload:Hr,onExportFixture:Ur,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:Kr,isReceivingChunks:tt}),$r=n(`div`,{ref:jt,"data-agent-playback-enabled":Rn||void 0,"data-agent-playback-cursor":Rn?Hn:void 0,"data-agent-live-message-count":Ze.length,"data-agent-rendered-message-count":Kn.length,className:z(`flex flex-col min-h-0 min-w-0 border-0`,Be?`flex-1 h-full`:yr?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:Qr(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:Qr(T)}),Rn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:Hn,messages:Bn,onChangeCursor:cr})}),Ze.length===0&&!Qn&&Ve&&He?t(I1,{message:Ve,startedAt:He}):t(OJ,{messages:Kn,workstreamSourceMessages:qn,bottomRef:At,isCompleted:$n,plan:An.plan,workstreamStatus:An.workstreamStatus,showPlanPanel:A&&pt,onTogglePlanPanel:xr,plans:ct,activePlanIndex:lt,onChangePlan:lr,taskLabels:Zr,streamingMessages:Jn,onSendMessage:Un?Or:void 0,onOpenArtifact:M?Cr:void 0,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,artifactRunId:r,viewMode:zt,hideWorkstreamTabs:k,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:Er,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,showInitialRequest:et===`empty`&&Ze.length===0,hiddenMessageTypes:P,disableAutoScroll:!Un,renderRequestInputControls:!nr,activeWorkstream:Kt,onActiveWorkstreamChange:qt}),nr?t(rW,{message:tr,onSendMessage:Un?Or:void 0,onMcpConnected:Un?kr:void 0,disabled:L||!Un,isLoading:Nt||L}):rr&&Zn.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(XX,{activeWorkstreams:Zn,onSelectWorkstream:qt})}):ir&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:Tn?D??t(oe,{status:`error`,title:Je(`agent.failed`),className:`m-2`,children:En??Je(`agent.error`)}):xn&&xn!==`RUNNING`&&!Cn?zt===`sliding`&&xn===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(Nh,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(oe,{status:xn===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,xn]}):(ft||Cn)&&n(e,{children:[re,t(l1,{onSend:Or,onStop:h?zr:void 0,approvalModeSlot:a&&ln?t(Yb,{mode:ln,onChange:Pr,disabled:!Un||Sn||!h}):void 0,mcpSlot:t(GJ,{disabledCollections:Ar,onChange:Mr,onConnectionChange:Nr}),disabled:L||!Un,isSending:Nt||L,isStopping:Vt,isStreaming:!Qn,isCompleted:Qn,contextWindowUsage:or?ar:void 0,onCompactContext:or?Br:void 0,isCompactingContext:Ft,activeTaskCount:Pn,activeWorkstreams:Nn,onSelectWorkstream:qt,placeholder:In,onFilesSelected:Ot?Tt:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:kt,acceptedFileTypes:v,maxFiles:y,processingFiles:Ct,artifactRunId:r,hasProcessingFiles:wt,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!Ot,disableDropZone:Ot,className:te,inputClassName:ne})]})})]}),ei=t(BS,{children:t(OW,{children:n(`div`,{ref:Mt,className:z(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,Ot&&Wt&&`ring-2 ring-info ring-inset`,R),onDragEnter:Ot?Fr:void 0,onDragOver:Ot?Ir:void 0,onDragLeave:Ot?Lr:void 0,onDrop:Ot?Rr:void 0,children:[Ot&&Wt&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to upload`]})}),!Be&&$r,!Be&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:Qr(`compact`)}),yr&&n(e,{children:[!Be&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(pr),"aria-valuemin":300,"aria-valuetext":`${Math.round(pr)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>gr(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=Mt.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;mr(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Be?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Be?void 0:{"--agent-right-panel-width":`${pr}px`},children:t(OX,{plan:An.plan,workstreamStatus:An.workstreamStatus,plans:ct,activePlanIndex:lt,onChangePlan:lr,showPlan:!O&&pt,activeWorkstreams:Mn,hideWorkstreams:k,openDocuments:ht,activeDocumentId:gt,onSelectDocument:bt,onUpdateDocumentTitle:St,docRefreshKey:vt,runId:r,processingFiles:he??Ct,showArtifacts:M,artifactRefreshKey:Yr.key,artifactRefreshDetails:Yr.details,selectedArtifactPath:fr,onSelectedArtifactPathChange:Y,onSendMessage:Xr?Or:void 0,messages:Ze,payloadContent:Re,conversationContent:Be?$r:ze,onClose:Sr,defaultTab:ur,activeTab:ur,onTabChange:dr})})]}),n(se,{isOpen:Wr,onClose:()=>Gr(!1),children:[t(ue,{children:`Export conversation as PDF`}),n(ce,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(le,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Gr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:qr,children:`Open print dialog`})]})]})]})})});return ie?t(Yn,{data:ie,sendMessage:Or,ChartComponent:oC,artifactRunId:r,children:ei}):ei}function G1({messages:e}){let n=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:n.map(e=>t(yG,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function K1({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=ot.useRef(null);H(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-muted`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(G1,{messages:s,isCompleted:!1})})})}function q1(e){return e.name}function J1({isClearable:e=!1,onChange:n,ignoreVirtuals:r=!1,selectedEnvId:i,disabled:a=!1}){let{t:o}=K(),{client:s}=q(),[c,l]=G(),{data:u,isLoading:d}=Xe(()=>s.environments.list().then(e=>(r?e.filter(e=>!e.provider.startsWith(`virtual_`)):e).slice().sort((e,t)=>e.name.localeCompare(t.name))));return H(()=>{l(u?.find(e=>e.id===i))},[u,i]),t(we,{isClearable:e,optionLabel:q1,options:u??[],value:c,onChange:e=>{l(e),n(e)},placeholder:o(`intakePolicy.placeholder.environment`),filterBy:`name`,disabled:a,isLoading:d})}function Y1(e){return e.name}function X1(e){return e?.length?n=>{let r=e.some(e=>e.id===n.id);return t(`span`,{className:r?`opacity-50`:``,children:n.name})}:Y1}function Z1({envId:e,isClearable:n,onChange:r,selectedModelId:i,disabled:a=!1,greyedModels:o,onModelsLoaded:s}){let{t:c}=K(),{client:l}=q(),[u,d]=G(),{data:f,isLoading:p}=Ye(async()=>{if(!e)return[];try{return[...(await l.environments.retrieve(e)).enabled_models??[]].sort((e,t)=>e.name.localeCompare(t.name))}catch{return[]}},[e]);return H(()=>{if(!i){d(void 0);return}let e=f?.find(e=>e.id===i);d(e??{id:i,name:i,provider:`unknown`})},[f,i]),H(()=>{f&&s?.(f)},[f,s]),t(we,{isClearable:n,by:`id`,optionLabel:X1(o),options:f??[],value:u,onChange:e=>{d(e),r(e)},placeholder:c(`intakePolicy.placeholder.model`),disabled:a,isLoading:p})}function Q1({env:e,isClearable:n,onChange:r}){let{t:i}=K(),{client:a}=q(),[o,s]=G(),{data:c,isLoading:l}=Ye(async()=>{if(!e)return[];try{return a.environments.listTrainableModels(e.id)}catch{return[]}},[e?.id]);return t(we,{isClearable:n,by:`id`,optionLabel:Y1,options:c??[],value:o,onChange:e=>{s(e),r(e)},placeholder:i(`intakePolicy.placeholder.model`),disabled:!e,isLoading:l})}function $1({children:e,fallback:n}){return e0?t(e0,{fallback:n,children:e}):t(rr,{FallbackComponent:n,children:e})}let e0=null;function t0(e){e0=e}function n0({children:e}){return t($1,{fallback:r0,children:e})}function r0({error:e}){let{t:r}=K(),i=e instanceof Error?e.message:void 0;return n(oe,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function i0({children:e}){return t($1,{fallback:a0,children:e})}function a0({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-muted`,children:r})]})})}function o0({children:e}){return t($1,{fallback:s0,children:e})}function s0({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}Q();const c0=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function l0(e){return c0.test(e)}function u0({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0,parentPath:u,parentLabel:d}){let f=Qn();function p(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>qn(e)).join(` `)}let m=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?p(n[n.length-1]):`Page`},h=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:m(n),href:n.href,onClick:()=>f(n.href,{stepsBack:i})})});else if(u)e.push({label:d??m({href:u}),href:u,onClick:()=>f(u,{isBasePathNested:!1,replace:!0})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(l0(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:p(t[n-1]||r),href:r,onClick:()=>f(r,{isBasePathNested:!1})})}}}return Array.isArray(c)&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>f(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})(),g=!!i&&h.length===0;return n(`div`,{className:it(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[h.length>0&&t(a,{path:h,separator:t(lh,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&!g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted ms-4`})})]}),i&&n(`div`,{className:`flex gap-2 items-center`,children:[t(`h1`,{className:`text-xl font-semibold break-all`,children:i}),o&&g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted`})})]})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function d0(){let{t:e}=K();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-destructive`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}Q();const f0=`magic-pdf`;function p0(e){return e.replace(/^\$\.?/,``).replace(/^data\./,``)}function m0(e){let{client:t}=q(),[n,r]=G(!1);return H(()=>{let n=!1;return r(!1),t.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url,{method:`HEAD`})).then(e=>{n||r(e.ok)}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function h0(e){let{client:t}=q(),[n,r]=G(null);return H(()=>{let n=!1;return r(null),t.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url)).then(e=>e.ok?e.json():null).then(e=>{n||!e?.citations||r({confidence:e.confidence,verified:e.citations.filter(e=>e.verified).length,total:e.citations.length,verdict:e.verdict,verdict_reason:e.verdict_reason})}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function g0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c,isLoading:l}=Ye(async()=>{let t=await a.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`),n=await fetch(t.url);if(!n.ok)throw Error(i(`grounded.notFound`));return n.json()},[e]);return c?t(`div`,{className:`flex h-full items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`grounded.failedToLoad`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:i(`pdf.close`)})]})}):l||!s?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(`div`,{className:`relative h-full`,children:t(v0,{extraction:s,objectId:e,onClose:r})})}function _0({objectId:e,onClose:n}){return t(`div`,{className:`fixed inset-0 bg-background z-50`,children:t(g0,{objectId:e,onClose:n})})}function v0({extraction:r,objectId:a,onClose:s}){let{t:c}=K(),{client:l}=q(),u=U(()=>Object.keys(r.pages).map(e=>parseInt(e,10)).sort((e,t)=>e-t),[r.pages]),d=e=>{l.files.getDownloadUrl(`${f0}/${a}/${e}`).then(e=>window.open(e.url,`_blank`)).catch(()=>{})},[f,p]=G(u[0]??1),[m,h]=G(void 0),[g,_]=G(!1),[v,y]=G(`original`),b=U(()=>{let e={digital:0,ocr:0,reviewerConfirmed:0,snapped:0,imageRead:0},t=[];for(let n of r.citations)n.verified?n.snapped?e.snapped++:(n.confidence??0)>=1?e.digital++:e.ocr++:n.reviewed?e.reviewerConfirmed++:(e.imageRead++,t.push(n));let n=e.digital+e.ocr+e.snapped,i=e.reviewerConfirmed;return{groups:e,unverified:t,digitallyVerified:n,modelVerified:i,totalVerified:n+i}},[r.citations]),x=U(()=>{let e=new Map;for(let t of r.citations){let n=p0(t.path),r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[r.citations]),S=r.citations.length,C=b.totalVerified===S,T=e=>{h(e);let t=x.get(p0(e))?.[0];t&&p(t.page)},E=u.indexOf(f),D=m?x.get(p0(m))?.find(e=>e.page===f):void 0,O=D?.cells?D.cells.start===D.cells.end?D.cells.start:`${D.cells.start}:${D.cells.end}`:void 0;return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[n(Se,{defaultSize:55,minSize:25,className:`flex flex-col bg-muted`,children:[n(`div`,{className:`relative flex h-9 shrink-0 items-center justify-center bg-sidebar px-2 border-b border-sidebar-border`,children:[O&&t(i,{variant:`secondary`,className:`absolute start-2 max-w-32 truncate font-mono text-[11px]`,title:O,children:O}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.previousPage`),disabled:E<=0,onClick:()=>p(u[E-1]),children:t(oh,{className:`size-4`})}),t(`span`,{className:`text-xs text-muted`,children:c(`pdf.pageOf`,{pageNumber:f,totalPages:u.length})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.nextPage`),disabled:E>=u.length-1,onClick:()=>p(u[E+1]),children:t(lh,{className:`size-4`})})]}),n(`fieldset`,{className:`absolute end-2 flex items-center gap-0.5 rounded border-0 bg-muted p-0.5`,children:[t(`legend`,{className:`sr-only`,children:c(`grounded.checkerboard`)}),t(We,{description:c(`pdf.originalImages`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`original`?`outline`:`ghost`,size:`xs`,"aria-label":c(`pdf.originalImages`),"aria-pressed":v===`original`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`original`),children:[t(D_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`pdf.page`)})]})}),t(We,{description:c(`grounded.checkerboard`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`grid`?`outline`:`ghost`,size:`xs`,"aria-label":c(`grounded.checkerboard`),"aria-pressed":v===`grid`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`grid`),children:[t(x_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`grounded.checkerboard`)})]})})]})]}),t(`div`,{className:`flex-1 overflow-auto p-2`,children:t(y0,{objectId:a,page:f,dims:r.pages[String(f)],citations:r.citations.filter(e=>e.page===f),selectedPath:m,onSelectPath:h,imageMode:v})})]}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:45,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`span`,{className:`text-sm font-medium`,children:c(`grounded.title`)}),n(`div`,{className:`flex items-center gap-2`,children:[S>0&&t(We,{description:c(`grounded.confidenceHint`),placement:`bottom`,size:`xs`,asChild:!0,children:n(i,{variant:C?`success`:`attention`,className:`gap-1 text-nowrap cursor-pointer`,onClick:()=>_(e=>!e),"aria-expanded":g,children:[t(C?Ih:Ag,{className:`size-3.5`}),c(`grounded.verifiedOf`,{verified:b.totalVerified,total:S})]})}),n(w,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`pdf.download`),title:c(`pdf.download`),children:t(xg,{className:`size-4`})}),children:[n(ae,{className:`text-xs`,onClick:()=>d(`grounded-extraction.json`),children:[t(Ng,{className:`size-4`}),c(`grounded.downloadCitations`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`pages/page-${f}.json`),children:[t(Gg,{className:`size-4`}),c(`grounded.downloadBlocks`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`grounded-annotated.pdf`),children:[t(Ig,{className:`size-4`}),c(`grounded.downloadAnnotated`)]})]}),!!s&&t(o,{variant:`ghost`,size:`xs`,onClick:s,"aria-label":c(`pdf.close`),children:t(Gb,{className:`size-4`})})]})]}),g&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm max-h-72 overflow-auto`,children:[n(`div`,{className:`mb-1 flex items-center gap-1`,children:[t(`span`,{className:`font-medium`,children:c(`grounded.breakdownTitle`)}),t(We,{description:c(`grounded.breakdownVerificationHelp`),size:`xs`,children:t(A_,{className:`size-3 text-muted`})})]}),n(`div`,{className:`grid grid-cols-2 gap-x-4 text-xs`,children:[t(`span`,{className:`col-span-2 mt-1 font-medium text-success`,children:c(`grounded.digitalVerifiedOf`,{count:b.digitallyVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownDigital`)}),t(`span`,{className:`text-end text-success`,children:b.groups.digital}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownOcr`)}),t(`span`,{className:`text-end text-success`,children:b.groups.ocr}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownSnapped`)}),t(`span`,{className:`text-end text-success`,children:b.groups.snapped}),t(`span`,{className:`col-span-2 mt-2 font-medium text-success`,children:c(`grounded.modelVerifiedOf`,{count:b.modelVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownReviewer`)}),t(`span`,{className:`text-end text-success`,children:b.groups.reviewerConfirmed}),b.groups.imageRead>0&&n(e,{children:[t(`span`,{className:`col-span-2 mt-2 font-medium text-attention`,children:c(`grounded.unverifiedCount`,{count:b.groups.imageRead})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownImageRead`)}),t(`span`,{className:`text-end text-attention`,children:b.groups.imageRead})]})]}),typeof r.hardness?.score==`number`&&n(`p`,{className:`mt-2 text-xs text-muted`,title:c(`grounded.hardnessHint`),children:[c(`grounded.hardness`,{percent:Math.round(r.hardness.score*100)}),r.hardness.escalated?` ↑`:``]}),(r.verdict_reason??r.review?.verdict_reason)&&t(`p`,{className:`mt-2 text-xs`,children:r.verdict_reason??r.review?.verdict_reason}),r.review?.summary&&n(`p`,{className:`mt-2 text-xs text-muted`,children:[n(`span`,{className:`font-medium text-foreground`,children:[c(`grounded.reviewSummary`),`: `]}),r.review.summary]}),typeof r.review?.corrections_applied==`number`&&r.review.corrections_applied>0&&t(`p`,{className:`mt-1 text-xs text-info`,children:c(`grounded.reviewCorrections`,{count:r.review.corrections_applied})}),b.unverified.length>0&&n(`div`,{className:`mt-2`,children:[t(`div`,{className:`text-xs font-medium text-muted mb-1`,children:c(`grounded.breakdownUnverifiedList`)}),t(`ul`,{className:`space-y-0.5`,children:b.unverified.map(e=>t(`li`,{children:n(`button`,{type:`button`,className:`w-full text-start text-xs rounded px-1 py-0.5 hover:bg-muted cursor-pointer`,onClick:()=>{T(e.path),_(!1)},children:[t(`span`,{className:`text-muted`,children:e.path}),` `,t(`span`,{children:String(e.value??``)})]})},e.path))})]})]}),n(`div`,{className:`flex-1 overflow-auto p-3`,children:[t(b0,{value:r.data,path:``,citationsByPath:x,selectedPath:m,onSelect:T}),r.conflicts&&r.conflicts.length>0&&t(`div`,{className:`mt-4 text-xs text-attention`,children:c(`grounded.conflicts`,{count:r.conflicts.length})})]})]})]})}function y0({objectId:e,page:r,dims:i,citations:a,selectedPath:o,onSelectPath:s,imageMode:c}){let{t:l}=K(),{client:u}=q(),[d,f]=G(void 0);if(H(()=>{let t=!1;return f(void 0),u.files.getDownloadUrl(`${f0}/${e}/pages/page-${r}.${c}.jpg`).then(e=>{t||f(e.url)}).catch(e=>console.warn(`Failed to load page image`,e)),()=>{t=!0}},[u,c,e,r]),!d||!i)return t(`div`,{className:`flex items-center justify-center h-64`,children:t(je,{})});let p=a.flatMap(e=>e.boxes.map((r,a)=>{let c=o!==void 0&&p0(o)===p0(e.path),l=e.cells?e.cells.start===e.cells.end?e.cells.start:`${e.cells.start}:${e.cells.end}`:void 0;return t(We,{description:n(`span`,{className:`flex flex-col gap-0.5`,children:[t(`span`,{className:`flex items-center gap-1 font-medium`,children:C0(e.path).map((e,r)=>n(lt,{children:[r>0&&t(lh,{className:`size-3 shrink-0 cn-rtl-flip`}),e]},`${r}:${e}`))}),l&&t(`span`,{className:`font-mono`,children:l}),e.source_text&&t(`span`,{children:e.source_text})]}),size:`xs`,asChild:!0,children:t(`button`,{type:`button`,"aria-label":e.path,onClick:()=>s(p0(e.path)),className:z(`absolute cursor-pointer border rounded-[1px] transition-colors`,e.misaligned&&`border-dashed`,c?`border-2 border-info bg-info z-10`:e.verified?`border-success/70 hover:bg-success/20`:e.reviewed?`border-info/70 hover:bg-info/20`:`border-attention/80 hover:bg-attention/20`),style:{position:`absolute`,left:`${r.x/i.width*100}%`,top:`${r.y/i.height*100}%`,width:`${r.w/i.width*100}%`,height:`${r.h/i.height*100}%`}})},`${e.path}-${a}`)})),m=((i.rotation??0)%360+360)%360;if(m!==0){let e=m===90||m===270;return n(`div`,{className:`relative w-full`,style:{aspectRatio:`${i.width} / ${i.height}`},children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`absolute select-none`,style:{left:`50%`,top:`50%`,width:`${(e?i.height/i.width:1)*100}%`,height:`${(e?i.width/i.height:1)*100}%`,maxWidth:`none`,transform:`translate(-50%, -50%) rotate(${m}deg)`,transformOrigin:`center center`}}),p]})}return n(`div`,{className:`relative w-full`,children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`w-full select-none`}),p]})}function b0({value:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){return Array.isArray(e)?e.length>0&&e.every(e=>typeof e==`object`&&!!e)?t(x0,{items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}):t(`div`,{className:`space-y-1`,children:e.map((e,n)=>t(b0,{value:e,path:`${r}[${n}]`,citationsByPath:i,selectedPath:a,onSelect:o},`${r}[${n}]`))}):typeof e==`object`&&e?t(`div`,{className:r?`ps-3 border-s border-border space-y-0.5`:`space-y-0.5`,children:Object.entries(e).map(([e,s])=>{let c=r?`${r}.${e}`:e;if(typeof s!=`object`||!s)return t(S0,{label:e,value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o},c);let l=Array.isArray(s)&&s.length>0&&s.every(e=>typeof e==`object`&&!!e);return n(`div`,{className:`pt-1`,children:[!l&&t(`div`,{className:`text-sm font-semibold`,children:w0(e)}),t(b0,{value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o})]},c)})}):null}function x0({items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){let{t:s}=K(),c=U(()=>{let t=new Set;for(let n of e)for(let e of Object.keys(n))t.add(e);return Array.from(t)},[e]);return n(`div`,{className:`pt-1`,children:[n(`div`,{className:`text-sm font-semibold`,children:[w0(r.split(`.`).pop()),` (`,e.length,`)`]}),t(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs`,children:[t(`thead`,{children:t(`tr`,{className:`text-start text-muted`,children:c.map(e=>t(`th`,{scope:`col`,className:`py-1 pe-2 font-medium`,children:w0(e)},e))})}),t(`tbody`,{children:e.map((e,l)=>t(`tr`,{className:`border-t border-border/50`,children:c.map(c=>{let u=`${r}[${l}].${c}`,d=i.get(u)?.[0];return t(`td`,{className:`py-0.5 pe-2`,children:n(`button`,{type:`button`,onClick:()=>o(u),className:z(`text-start rounded px-1 w-full`,a===u?`bg-info ring-1 ring-primary`:d?`hover:bg-muted cursor-pointer`:`text-muted cursor-default`),children:[D0(e[c]),d&&typeof d.confidence==`number`&&t(`span`,{className:z(`ms-1 text-[10px]`,E0(d.confidence)),title:s(`grounded.scoreHint`),children:T0(d.confidence)})]})},c)})},`${r}[${l}]`))})]})})]})}function S0({label:e,value:r,path:i,citationsByPath:a,selectedPath:o,onSelect:s}){let{t:c}=K(),l=a.get(i)?.[0];return n(`button`,{type:`button`,onClick:()=>l&&s(i),className:z(`flex items-center gap-2 w-full text-start text-sm rounded px-1.5 py-0.5`,o===i?`bg-info ring-1 ring-primary`:l?`hover:bg-muted`:``,!l&&`cursor-default`),children:[n(`span`,{className:`min-w-28 shrink-0 font-semibold`,children:[w0(e),`:`]}),t(`span`,{className:`flex-1 wrap-break-word`,children:D0(r)}),l&&typeof l.confidence==`number`&&t(`span`,{className:z(`text-xs shrink-0`,E0(l.confidence)),title:c(`grounded.scoreHint`),children:T0(l.confidence)}),l&&(l.verified?t(Ih,{"aria-label":c(`grounded.verified`),className:`size-3.5 shrink-0 text-success`}):l.reviewed?t(Jy,{"aria-label":c(`grounded.aiVerified`),className:`size-3.5 shrink-0 text-info`}):t(Ag,{"aria-label":c(`grounded.readFromImage`),className:`size-3.5 shrink-0 text-attention`}))]})}function C0(e){return p0(e).split(`.`).map(e=>w0(e.replace(/\[\d+\]/g,``))).filter(Boolean)}function w0(e){return e?zt(e):``}function T0(e){let t=e*100;return Number.isInteger(t)?`${t}%`:`${(Math.floor(t*100)/100).toFixed(2)}%`}function E0(e){return e>=.95?`text-success`:e>=.7?`text-attention`:`text-destructive`}function D0(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`true`:`false`:typeof e==`object`?JSON.stringify(e):String(e)}const O0=`magic-pdf`;var k0;(function(e){e.original=`original`,e.instrumented=`instrumented`})(k0||={});var A0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${O0}/${this.objectId}/pages`;switch(t){case k0.original:return`${n}/page-${e}.original.jpg`;case k0.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},j0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${O0}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},M0=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=N0(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function N0(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const P0=dt(void 0);function F0({children:e,object:n}){let{client:r}=q(),i=n.metadata.page_count||10,[a,o]=G(()=>{let e=new M0(i);return n.text&&e.initFromContent(n.text),{count:i,layoutProvider:new j0(r,n.id,i),markdownProvider:e,imageProvider:new A0(r,n.id,i),pdfUrl:``,pdfUrlLoading:!0}});return H(()=>{let e=n.metadata?.renditions?.find(e=>e.name===_n),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{o(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),o(e=>({...e,pdfUrlLoading:!1}))}):o(e=>({...e,pdfUrlLoading:!1}))},[r,n.metadata,n.content?.type,n.content?.source]),t(P0.Provider,{value:a,children:e})}function I0(e,t,n){return e.files.getDownloadUrl(`${O0}/${t}/${n}`).then(e=>e.url)}function L0(){let e=ot.useContext(P0);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}Q();function R0({object:e}){let{t:n}=K(),{client:r}=q(),i=t=>{I0(r,e.id,t).then(e=>window.open(e,`_blank`))};return t(o,{variant:`ghost`,size:`xs`,onClick:()=>i(`document.md`),title:n(`pdf.download`),children:t(xg,{className:`size-4`})})}Q();function z0({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`w-6 h-6 animate-spin text-muted`})})}function B0({viewType:e,pageNumber:n}){switch(e){case`json`:return t(V0,{pageNumber:n});case`markdown`:return t(H0,{pageNumber:n});default:return t(H0,{pageNumber:n})}}function V0({pageNumber:e}){let[n,r]=G(null),[i,a]=G(!0),[o,s]=G(null),{layoutProvider:c}=L0();return H(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(z0,{})}):o?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:o}):n?t(At,{className:`w-full`,data:n}):null}function H0({pageNumber:e}){let[r,i]=G(null),[a,o]=G(!0),[s,c]=G(null),{markdownProvider:l}=L0();return H(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(z0,{}),t(`span`,{className:`text-sm text-muted`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(Nt,{children:r}):t(`div`,{children:`No markdown content available`})})}Q(),SY();var U0=class extends ct{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:Xt.t(`pdf.failedToLoadViewer`,{ns:Yt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function W0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c}=Ye(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`pdf.fetchingDocumentFailed`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(U0,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(F0,{object:s,children:t(G0,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function G0({object:e,onClose:r}){let{t:i}=K(),{count:a,pdfUrl:s,pdfUrlLoading:c}=L0(),[l,u]=G(1);return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[t(Se,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(gY,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:l,onChange:u})}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(R0,{object:e})}),t(`span`,{className:`text-xs text-muted`,children:i(`pdf.pageOf`,{pageNumber:l,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(B0,{pageNumber:l,viewType:`markdown`})})]})]})}const K0=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],q0=[`video/mp4`,`video/webm`],J0=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function Y0(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function X0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===cn),m=i?.content?.type&&J0.includes(i.content.type),h=!!i&&i.metadata?.type===un.Audio&&!p&&!m;return H(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,Y0(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function Z0({url:e,source:n,object:r,className:i}){let{client:a}=q(),[o,s]=G(e),[c,l]=G(!e&&(!!n||!!r));return H(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==un.Image)return;let e=r.content?.type&&K0.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:mn.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(je,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function Q0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(),[f,p]=G(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&q0.includes(i.content.type),_=m.find(e=>e.name===vn),v=!!i&&i.metadata?.type===un.Video&&!h&&!g;return H(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),H(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}Q();function $0({oauthProviderId:r,onAuthChange:i}){let{client:a}=q(),{t:o}=K(),[s,c]=G(null),[l,u]=G(!0),[d,f]=G(!1),[p,m]=G(!1),h=V(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);H(()=>{h()},[h]);let{openOAuthPopup:g}=pO({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(dO,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(dO,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Dg,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function e2(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function t2(...e){return Array.from(e)}function n2(e){return e.__AnyOf__===!0}function r2(e){if(e&&typeof e==`object`&&`status`in e&&typeof e.status==`number`)return e.status}function i2(e){let t=r2(e);return t===0||t===502||t===503||t===504||e instanceof Error&&e.name===`TimeoutError`}function a2(e,t){let n=U(()=>t?JSON.stringify(t):void 0,[t]),r=!!(t&&!t.permissions),[i,a]=G(0),[o,s]=G(),c=V(()=>a(e=>e+1),[]);return H(()=>{if(!r)return;let t=new AbortController,a=!1,o=0,c,l,u=t=>s({client:e,tokenKey:n,attempt:i,state:t}),d=()=>{a=!0,clearTimeout(f),clearTimeout(p),clearTimeout(l),t.abort()},f=setTimeout(()=>u({status:`retrying`}),5e3),p=setTimeout(()=>{d(),u({status:`error`,error:c})},6e4),m=async()=>{try{let n=await e.iam.roles.listSystem({signal:t.signal,timeoutMs:15e3,retryPolicy:!1});if(a)return;d(),u({status:`ready`,roles:n})}catch(e){if(a)return;if(c=e,!i2(e)){d(),u({status:`error`,error:e});return}u({status:`retrying`});let t=Math.min(1e3*2**o++,8e3)*(.5+Math.random()*.5);l=setTimeout(()=>{m()},t)}};return u({status:`loading`}),m(),d},[e,n,r,i]),{state:o?.client===e&&o.tokenKey===n&&o.attempt===i?o.state:{status:`loading`},retry:c}}var o2=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??s2(n,t),a=e.type===bn.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(n2(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function s2(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const c2=dt(void 0);function l2(){let e=_t(c2);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function u2({children:r,loadingIcon:i}){let{t:a}=K(),s=q(),c=s.authToken,{state:l,retry:u}=a2(s.client,c),d=U(()=>{if(c){if(c.permissions)return new o2(c);if(l.status===`ready`)return new o2(c,l.roles)}},[c,l]);if(c&&!d){let r=l.status===`error`,c=r?r2(l.error):void 0,d=c===401,f=c===403,p=a(d?`auth.recovery.credential.title`:f?`shell.accessDenied`:r?`permissions.connectionFailed`:`permissions.connecting`);return t(`div`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-foreground`,children:n(`div`,{className:`w-full max-w-md space-y-6 text-center`,children:[t(`div`,{"aria-hidden":`true`,className:`flex justify-center`,children:i||!r&&t(je,{size:`2xl`,className:`text-info`})}),n(`div`,{role:r?`alert`:`status`,"aria-live":r?`assertive`:`polite`,className:`space-y-2`,children:[t(`h1`,{className:`text-xl font-semibold`,children:p}),t(`p`,{className:`text-muted`,children:d?a(`auth.recovery.credential.body`):f?a(`permissions.accessDenied`):r?a(`permissions.tryAgainLater`):l.status===`retrying`?a(`permissions.retrying`):a(`permissions.loadingPermissions`)})]}),r&&n(e,{children:[t(o,{variant:`outline`,onClick:d||f?()=>s.signOut():u,children:a(d||f?`auth.recovery.useDifferentAccount`:`auth.recovery.tryAgain`)}),l.error!=null&&n(`details`,{className:`text-start text-sm text-muted`,children:[t(`summary`,{className:`cursor-pointer`,children:a(`auth.recovery.technicalDetails`)}),t(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap wrap-break-word`,children:Ge(l.error)})]})]})]})})}return d&&t(c2.Provider,{value:d,children:r})}function d2({permission:e,isDisabled:n,title:r,children:i,...a}){return l2().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function f2({permission:e,...n}){return l2().hasPermission(e)?t(ar,{...n}):null}const p2=new WeakMap;function m2(e,t){let n=p2.get(e);n||(n=new Map,p2.set(e,n));let r=n.get(t);return r||(r=e.types.catalog.resolve(t).then(e=>e??void 0,()=>{p2.get(e)?.delete(t)}),n.set(t,r)),r}function h2(e,t){let n=p2.get(e);n&&(t?n.delete(t):n.clear())}Q();function g2(e){let t=e.configuration?.defaults?.system?.agent??e.configuration?.defaults?.base;return{environment:t?.environment,model:t?.model}}function _2(e){return e.name}function v2(e){return e.name}function y2(e){return e.split(`/`).filter(Boolean).pop()||e}function b2({value:e,onChange:r,disabled:i=!1,isLoading:a=!1}){let{client:s}=q(),{t:c}=K(),[l,u]=G([]),[d,f]=G([]),[p,m]=G(!0),[h,g]=G(!1),_=W(void 0);H(()=>{let e=!1;return m(!0),s.environments.list().then(t=>{e||u(t.slice().sort((e,t)=>e.name.localeCompare(t.name)))}).catch(t=>{console.warn(`Failed to list document editing environments`,t),e||u([])}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s]),H(()=>{if(!e.environment){f([]),g(!1);return}let t=!1,n=e.environment;return g(!0),s.environments.retrieve(n).then(e=>{t||f((e.enabled_models??[]).map(e=>({id:e.id,name:e.name||e.id})).sort((e,t)=>e.name.localeCompare(t.name)))}).catch(e=>{console.warn(`Failed to load document editing models`,e),t||f([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[s,e.environment]);let v=l.find(t=>t.id===e.environment),y=U(()=>{if(e.model)return d.find(t=>t.id===e.model)??{id:e.model,name:y2(e.model)}},[d,e.model]),b=e=>{_.current=e.id,r({environment:e.id}),s.environments.retrieve(e.id).then(t=>{if(_.current!==e.id)return;let n=t.default_model??t.enabled_models?.[0]?.id;r({environment:e.id,model:n})}).catch(e=>{console.warn(`Failed to select a default document editing model`,e)})},x=t=>{_.current=void 0,r({environment:e.environment,model:t.id})},S=y?.name||c(`agent.documentEditingSelectModel`);return n(he,{children:[t(_e,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 max-w-[15rem] gap-1.5 px-2 text-xs`,"aria-label":c(`agent.documentEditingConfiguration`),title:c(`agent.documentEditingConfiguration`),children:[a?t(je,{size:`sm`}):t(Gy,{className:`size-3.5 shrink-0`}),t(`span`,{className:`min-w-0 truncate`,children:S}),t(rh,{className:`size-3.5 shrink-0 opacity-70`})]})}),n(ge,{align:`end`,className:`z-[1000000] w-80 space-y-3 p-3`,children:[n(`div`,{children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:c(`agent.documentEditingConfiguration`)}),t(`div`,{className:`mt-0.5 text-xs leading-4 text-muted`,children:c(i?`agent.documentEditingConfigurationLocked`:`agent.documentEditingConfigurationDescription`)})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-environment`,children:c(`agent.environment`)}),t(we,{id:`document-editing-environment`,by:`id`,options:l,value:v,optionLabel:_2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectEnvironment`),onChange:b,disabled:i,isLoading:p})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-model`,children:c(`agent.model`)}),t(we,{id:`document-editing-model`,by:`id`,options:d,value:y,optionLabel:v2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectModel`),onChange:x,disabled:i||!e.environment,isLoading:h,warnOnMissingValue:!1})]})]})]})}Q();function x2({isLocked:e,onToggleLock:r}){let{t:i}=K(),a=i(e?`agent.editingLockedTitle`:`agent.editingManuallyUnlockedTitle`),s=i(e?`agent.editingLockedDescription`:`agent.editingManuallyUnlockedDescription`),c=i(e?`agent.unlockEditing`:`agent.lockEditing`);return n(`div`,{className:`flex h-8 max-w-64 shrink-0 items-center gap-1 rounded-md border border-mixer-attention/30 bg-mixer-attention/10 ps-2 pe-1 text-attention`,role:e?`status`:`alert`,"aria-live":`polite`,children:[e?t(rv,{className:`size-3.5 shrink-0 animate-pulse`}):t(ov,{className:`size-3.5 shrink-0`}),t(We,{description:s,asChild:!0,children:t(`span`,{className:`min-w-0 truncate text-xs font-medium text-foreground`,children:a})}),t(`span`,{className:`sr-only`,children:s}),t(We,{description:c,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`size-6 shrink-0 rounded p-0 text-attention hover:bg-mixer-attention/15`,onClick:r,"aria-label":c,children:t(e?ov:rv,{className:`size-3.5`})})})]})}const S2=/artifact:(?!agents\/)(?!documents\/)([^\s)\]"]+)/g;function C2(e){let t=new Set;for(let n of e.matchAll(S2))t.add(n[1].replace(/^\/+/,``));return[...t]}async function w2(e,t,n,r){let i=C2(t);if(i.length===0)return{content:t,persisted:[],failed:[]};let a=new Map,o=[],s=[];for(let t of i){let i=`documents/${r}/${t}`;try{await e.copyFile(`agents/${n}/${t}`,i),a.set(t,i),o.push({from:t,to:i})}catch(e){console.warn(`Failed to persist a referenced artifact; keeping a run-scoped link`,{artifact_path:t,error:e instanceof Error?e.message:String(e)}),a.set(t,`agents/${n}/${t}`),s.push(t)}}return{content:t.replace(S2,(e,t)=>{let n=a.get(t.replace(/^\/+/,``));return n?`artifact:${n}`:e}),persisted:o,failed:s}}const T2=[`ask_user`,`think`,`plan`,`update_plan`,`end_conversation`,`learn_artifact_operations`,`learn_code_execution`,`learn_content_authoring`,`learn_document_management`,`learn_document_search`,`learn_image_analysis`,`execute_shell`,`fetch_document`],E2=[`artifact_operations`,`code_execution`],D2=[`update_document`,`update_document_properties`,`create_document`,`set_document_type`,`merge_documents`,`import_file`,`create_or_update_object_type`,`disable_type`,`batch_execute`];function O2(e,t){return[`Direct edits are already saved to '${e}'. Use this compact unified diff as context only;`,`do not re-apply it. The artifact remains the current source of truth.`,"```diff",`--- a/${e}`,`+++ b/${e}`,t,"```"].join(`
|
|
1382
|
-
`)}const
|
|
1383
|
-
`)}function
|
|
1384
|
-
`)}function
|
|
1385
|
-
`)}function r4(e){if(!(!e||typeof e!=`object`||!(`status`in e)))return typeof e.status==`number`?e.status:void 0}function i4({original:e,workingCopy:r}){let i=U(()=>Vt(e,r),[e,r]),a=U(()=>({added:i.reduce((e,t)=>e+(t.type===`added`?t.text.length:0),0),removed:i.reduce((e,t)=>e+(t.type===`removed`?t.text.length:0),0)}),[i]);return n(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/10`,children:[n(`div`,{className:`flex shrink-0 items-center justify-end gap-3 border-b border-mixer-muted/20 px-5 py-2 text-xs`,children:[n(`span`,{className:`text-destructive`,children:[`−`,a.removed]}),n(`span`,{className:`text-success`,children:[`+`,a.added]})]}),t(`div`,{className:`min-h-0 flex-1 overflow-auto p-5`,children:t(`pre`,{className:`mx-auto max-w-5xl whitespace-pre-wrap break-words rounded-lg border border-mixer-muted/25 bg-background p-5 font-mono text-xs leading-6 shadow-sm`,children:i.map((e,n)=>e.type===`removed`?t(`del`,{className:`bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})})]})}function a4({object:r,initialContent:i=``,onDocumentUpdated:a,onClose:s,sendMessageRef:c,model:l,startImmediately:u=!1}){let{client:d,project:f,store:m,user:h}=q(),{t:g}=K(),_=nt(),v=W(null),y=c??v,[x,S]=G(),[C,w]=G(!1),[T,E]=G(!1),[D,O]=G(!0),[k,A]=G(!0),[j,M]=G(!1),[N,P]=G(0),[F,I]=G(!1),L=JSON.stringify(l?{environment:l.env,model:l.model,model_options:l.options}:{}),ee=l!==void 0,R=U(()=>JSON.parse(L),[L]),[te,ne]=G(!ee),[re,ie]=G(!1),[ae,oe]=G(!1),[se,ce]=G(!1),[le,ue]=G(!1),[de,fe]=G(!1),[pe,me]=G(!1),[he,ge]=G({key:0}),[_e,ve]=G(i),[ye,be]=G(!1),[we,Te]=G(i),[Ee,De]=G(i),[Oe,ke]=G(`document`),[Ae,Me]=G(),[Ne,Pe]=G(r.id),[Fe,Ie]=G(r.content?.etag),[Le,Re]=G(),[ze,Be]=G(R),Ve=W(ee?`host`:`none`),He=W(void 0),Ue=W(new Set),z=W(void 0),Ke=W(!1),qe=W(null),Je=r.revision?.root||r.id,Ye=U(()=>$2(Je),[Je]),Xe=h?.sub?`user:${h.sub}`:void 0,Ze=`${f?.id??`no-project`}:${Je}`,Qe=`${Ze}:${r.type?.id??`no-type`}`,$e=Le?.key===Qe?Le.interaction:void 0,et=W(Ze),tt=W({editingScopeKey:Ze,id:r.id}),rt=W({documentId:r.id,documentRootId:Je}),it=ye&&_e!==Ee,at=le&&!de;rt.current.documentRootId!==Je&&(rt.current={documentId:r.id,documentRootId:Je}),tt.current.editingScopeKey!==Ze&&(tt.current={editingScopeKey:Ze,id:r.id}),H(()=>{et.current!==Ze&&(et.current=Ze,Ve.current=ee?`host`:`none`,Be(R),ne(!ee),Ue.current.clear(),ve(i),Te(i),De(i),be(!1),me(!1),ue(!1),fe(!1),Ke.current=!1,ke(`document`),Pe(r.id),Ie(r.content?.etag))},[Ze,ee,i,r.content?.etag,r.id,R]),H(()=>{let e=!1,t=Ze,n=tt.current.id;return A(!0),M(!1),Y2(m.objects,n).then(n=>{e||tt.current.editingScopeKey!==t||(tt.current={editingScopeKey:t,id:n.id},rt.current={documentId:n.id,documentRootId:Je},Pe(n.id),Ie(n.etag),Te(n.content),De(n.content))}).catch(n=>{console.warn(`Failed to resolve the document editing target`,{error:n,attempt:N}),!e&&tt.current.editingScopeKey===t&&M(!0)}).finally(()=>{!e&&tt.current.editingScopeKey===t&&A(!1)}),()=>{e=!0}},[Je,Ze,m.objects,N]),H(()=>{let e=!1,t=r.type?.id;if(!t){Re({key:Qe,interaction:A2});return}return m2(d,t).then(t=>{e||Re({key:Qe,interaction:t?.editing?.interaction?.trim()||`sys:GeneralAgent`})}),()=>{e=!0}},[d,Qe,r.type?.id]),H(()=>{x||Ve.current===`run`||(ee?(Ve.current=`host`,Be(R),ne(!1)):Ve.current===`host`&&(Ve.current=`none`,Be({})))},[x,ee,R]),H(()=>{if(ee){ne(!1);return}if(!f){ne(!1);return}let e=!1,t=Ze;return ne(!0),d.projects.retrieve(f.id).then(n=>{e||et.current!==t||Ve.current!==`none`||(Ve.current=`project`,Be(g2(n)))}).catch(e=>{console.warn(`Failed to load the default document editing model`,e)}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[d,Ze,ee,f]),H(()=>{if(S(void 0),!Xe||!$e){O(!1);return}let e=!1;return O(!0),q2(d.agents,rt.current.documentId,Je,Xe,$e).then(t=>{e||!t||(S(t.id),t.config?.environment&&t.config.model&&(Ve.current=`run`,Be({environment:t.config.environment,model:t.config.model,model_options:t.config.model_options})))}).catch(e=>{console.warn(`Failed to look up an existing document editing run`,e)}).finally(()=>{e||O(!1)}),()=>{e=!0}},[d,Je,$e,Xe]);let B=V(e=>{Ve.current=`user`,Be(e)},[]),ot=V(()=>{x&&navigator.clipboard.writeText(x).then(()=>_({status:`success`,title:g(`agent.runIdCopied`),duration:2e3})).catch(e=>console.warn(`Failed to copy the agent run id`,e))},[x,g,_]),st=V(async()=>{if(!(!x||T)){E(!0);try{await d.agents.terminate(x,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3})}catch(e){console.warn(`Failed to terminate the document editing run`,e)}finally{E(!1)}Ue.current.clear(),S(void 0),be(!1),ve(Ee),me(!1),Ke.current=!1,ue(!1),fe(!1)}},[x,d.agents,T,Ee,g,_]),ct=V(async(e,t)=>{if(!(!f||!$e||D||k||j||C||te)){w(!0);try{if(!ze.environment||!ze.model){_({status:`error`,title:g(`agent.documentEditingDefaultsRequired`),duration:5e3});return}let n=e4(r,Ne,Fe,Ye,e?.trim()||g(`agent.documentEditingInitialRequest`)),i=B2(Ne,Je),a={interaction:$e,interactive:!0,tool_approval_mode:t?.tool_approval_mode,tool_names:T2,excluded_tools:D2,initial_skills:E2,initial_tool_calls:[{id:`hydrate-working-copy`,tool:`fetch_document`,input:{id:Ne,mode:`content`,output_artifact:{path:Ye}}},{id:`read-working-copy`,tool:`read_artifact`,input:{path:Ye}}],data:{user_prompt:n},config:{environment:ze.environment,model:ze.model,model_options:ze.model_options},started_by:Xe,tags:i.tags,properties:i.properties},o=await d.agents.start(a);return S(o.id),{agent_run_id:o.id}}catch(e){console.error(`Failed to start document editing agent`,e),_({status:`error`,title:g(`agent.documentEditingStartFailed`),description:e instanceof Error?e.message:void 0,duration:5e3});return}finally{w(!1)}}},[d.agents,Je,Ye,ze,$e,te,D,k,C,r,f,Xe,g,Ne,Fe,j,_]),lt=V((e,t)=>{z.current=t,ve(e),be(!0)},[]);H(()=>{if(!u||x||!f||!$e||D||k||j||C||te||!ze.environment||!ze.model)return;let e=JSON.stringify({scope:Ze,interaction:$e,document:Ne,configuration:ze});He.current!==e&&(He.current=e,ct(g(`agent.documentEditingStartRequest`),{tool_approval_mode:`full_control`}))},[x,$e,Ze,ze,te,D,k,C,f,u,ct,g,Ne,j]);let ut=V(e=>{let t=Ke.current;Ke.current=e,ue(e),e||(fe(!1),t&&ge(e=>({key:e.key+1})))},[]),dt=V((e,t)=>{let n=y.current;if(!n){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}n(e,t)},[y,g,_]),ft=V(e=>{let t=e.anchor.block_type.replaceAll(`_`,` `),n=e.comment?.trim()||g(`agent.editedSelectionMessage`,{blockType:t});dt(n,{editing_action:e})},[dt,g]),pt=V(async(e,t)=>{if(!(!ye||!Fe||!it||at||re||k||j)){ie(!0);try{let n=_e;x&&(n=(await w2(d.files,n,x,crypto.randomUUID())).content);let i=r.content?.type||`text/markdown`,o=r.content?.name||`content.md`,s=new File([new Blob([n],{type:i})],o,{type:i}),c=await m.objects.update(Ne,{content:s},{createRevision:e,revisionLabel:t,ifMatch:Fe});if(Pe(c.id),Ie(c.content?.etag),De(n),Me(void 0),oe(!1),a?.(c.id,e),_({status:`success`,title:g(`store.textSaved`),duration:2500}),x&&n!==_e&&z.current)try{await d.agents.updateArtifactContent(x,Ye,{content:n,generation:z.current}),ge(e=>({key:e.key+1}))}catch(e){console.warn(`Failed to sync persisted artifact links into the working copy`,e)}}catch(e){let t=r4(e),n=t===412;if(t===412||t===400)try{let e=await Y2(m.objects,Ne);(e.id!==Ne||t===412)&&(n=!0,Pe(e.id),Ie(e.etag),Me({headId:e.id}))}catch(e){console.warn(`Failed to resolve the new head after a save conflict`,e)}_({status:`error`,title:g(`store.errorSavingText`),description:n?g(`store.textConflict`):Ge(e,g(`store.errorSavingTextDefault`)),duration:5e3})}finally{ie(!1)}}},[x,_e,ye,d.agents,d.files,Ye,it,at,k,re,r.content?.name,r.content?.type,a,m.objects,g,Ne,Fe,j,_]),mt=V(()=>{let e=y.current;if(!e||!Ae){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(t4(Je,Ae.headId,Ye)),Me(void 0),ke(`document`)},[Je,Ye,y,Ae,g,_]),ht=V(()=>{let e=y.current;if(!e){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(n4(Je,tt.current.id,Ye))},[Je,Ye,y,g,_]),gt=V(async()=>Oe!==`editor`||!pe||!!await qe.current?.(),[pe,Oe]),_t=V(async e=>{e!==Oe&&await gt()&&ke(e)},[gt,Oe]),vt=V(async()=>{await gt()&&s?.()},[gt,s]),yt=V(async()=>{let e=y.current;if(!e||!x||at||se){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}ce(!0);try{let t=await qe.current?.();if(!t)return;let n=Bt(t.previous,t.current,{context:1});n&&e(O2(Ye,n)),me(!1),_({status:`success`,title:g(`agent.changesSentToAgent`),duration:2e3})}finally{ce(!1)}},[x,Ye,at,se,y,g,_]);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex h-14 shrink-0 items-center justify-between gap-3 border-b border-mixer-muted/20 px-4`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate font-semibold`,children:r.name||r.content?.name}),n(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[n(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[it?t(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-attention`}):ye?t(eh,{className:`size-3 text-success`}):null,g(it?`store.unsavedChanges`:`store.textSaved`)]}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.workingCopy`)}: ${Ye}`,asChild:!0,children:n(`span`,{className:`min-w-0 truncate font-mono`,children:[`drafts/`,Q2(Je),`.md`]})}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.originalDocument`)}: ${tt.current.id}`,asChild:!0,children:n(`span`,{className:`shrink-0 font-mono`,children:[g(`agent.originalDocument`).toLowerCase(),` `,Q2(tt.current.id)]})})]})]}),n(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[n(`div`,{className:`flex items-center rounded-md border border-mixer-muted/25 bg-muted/10 p-0.5`,children:[n(o,{variant:Oe===`document`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`document`),children:[t(Gg,{className:`size-3.5`}),g(`agent.document`)]}),n(o,{variant:Oe===`editor`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`editor`),children:[t(zg,{className:`size-3.5`}),g(`agent.fullEditor`)]}),n(o,{variant:Oe===`diff`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`diff`),disabled:!ye||_e===we,children:[t(h_,{className:`size-3.5`}),g(`agent.reviewChanges`)]})]}),Oe===`diff`?n(o,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5`,onClick:ht,disabled:!ye||_e===we,children:[t(Z_,{className:`size-3.5`}),g(`agent.summarizeChanges`)]}):null,t(We,{description:g(`agent.refresh`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>ge(e=>({key:e.key+1})),disabled:!x,"aria-label":g(`agent.refresh`),children:t(hy,{className:`size-4`})})}),t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),t(b2,{value:ze,onChange:B,disabled:!!x||C||D,isLoading:te}),x?null:n(o,{variant:`primary`,size:`sm`,className:`h-8 gap-1.5`,onClick:()=>void ct(g(`agent.documentEditingStartRequest`)),disabled:C||D||k||te||j||!f||!$e||!ze.environment||!ze.model,children:[C?t(je,{size:`sm`}):t(Jy,{className:`size-4`}),g(C?`agent.startingAgent`:`agent.documentEditingStart`)]}),x?n(e,{children:[t(We,{description:x,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`font-mono text-[11px] text-muted`,onClick:ot,"aria-label":g(`agent.copyRunId`),children:Q2(x)})}),t(We,{description:g(`agent.startNewConversation`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>{it?I(!0):st()},disabled:T,"aria-label":g(`agent.startNewConversation`),children:t(vy,{className:`size-4`})})})]}):null,t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),n(o,{variant:`primary`,className:`min-w-36 gap-2`,onClick:()=>oe(!0),disabled:!it||!Fe||at||re||k||j,children:[re?t(je,{size:`sm`}):t(wy,{className:`size-4`}),g(`agent.saveToDocument`)]}),s?t(o,{variant:`ghost`,size:`sm`,onClick:()=>void vt(),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})}):null]})]}),Ae?n(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-mixer-attention/30 bg-mixer-attention/10 px-4 py-2 text-sm`,children:[t(`span`,{className:`min-w-0 truncate text-attention`,children:g(`agent.saveConflictNotice`)}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t(o,{variant:`outline`,size:`sm`,onClick:mt,children:g(`agent.askAgentToReconcile`)}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>Me(void 0),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})})]})]}):null,n(Ce,{direction:`horizontal`,className:`min-h-0 flex-1`,children:[t(Se,{defaultSize:65,minSize:35,className:`min-w-0 bg-background`,children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:t(`div`,{className:`min-h-0 flex-1`,children:Oe===`diff`?t(i4,{original:we,workingCopy:_e}):t(wt,{runId:x,path:Ye,viewMode:Oe===`editor`?`document`:`components`,baselineContent:we,initialContent:Ee,refreshKey:he.key,refreshDetails:he.details,readOnly:at,allowComments:!!x,onContentChange:lt,onAction:ft,onSendMessage:dt,onSendChangesToAgent:yt,hasUnsentChanges:it&&pe,isSendingChanges:se,sendChangesDisabled:!x||at,toolbarStatus:le?t(x2,{isLocked:at,onToggleLock:()=>fe(e=>!e)}):void 0,onDocumentEdit:()=>me(!0),flushChangesRef:qe})})})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:35,minSize:25,className:`min-w-[320px]`,children:D||k?t(p,{className:`h-full`,children:t(je,{size:`lg`})}):j?n(p,{className:`h-full flex-col gap-3 px-6 text-center`,children:[t(`div`,{className:`text-sm text-muted`,children:g(`agent.failedToLoadDocument`)}),t(o,{variant:`outline`,size:`sm`,onClick:()=>P(e=>e+1),children:g(`agent.retry`)})]}):t(V1,{agentRunId:x,startWorkflow:ct,resetWorkflow:()=>S(void 0),onRestart:e=>S(e.id),sendMessageRef:y,onMessage:e=>{let t=e.details;if(!Ut(t,Ye))return;let n=`${e.timestamp}:${t?.path}:${t?.generation??``}`;Ue.current.has(n)||(Ue.current.add(n),ge(e=>({key:e.key+1,details:t})))},onAgentWorkingChange:ut,title:g(`agent.documentEditing`),initialMessage:g(`agent.documentEditingWelcome`),startButtonText:g(C?`agent.startingAgent`:`agent.startAgent`),placeholder:g(`agent.documentEditingPlaceholder`),initialToolApprovalMode:`full_control`,hideObjectLinking:!0,hideHeader:!0,showRightPanel:!1,fullWidth:!0,interactive:!0})})]}),t(b,{isOpen:F,title:g(`agent.newSessionDiscardTitle`),content:g(`agent.newSessionDiscardDescription`),onConfirm:()=>{I(!1),st()},onCancel:()=>I(!1)}),t(Z2,{isOpen:ae,onClose:()=>oe(!1),onConfirm:pt,isLoading:re})]})}function o4({object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s}){let{t:c}=K();return t(se,{isOpen:!0,onClose:r,size:`full`,noCloseButton:!0,disableCloseOnClickOutside:!0,className:`gap-0 overflow-hidden p-0`,description:c(`agent.documentEditingWelcome`),children:t(a4,{object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s})})}function s4({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=q(),u=nt(),{t:d}=K(),{theme:f}=tt(),p=Qn(),[m,h]=G(!1),[g,_]=G(``),[v,y]=G(!1),[b,x]=G(null),S=W(void 0),[C,w]=G(null),[T,E]=G(null),D=V(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);H(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:Ge(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(se,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(ue,{children:d(`store.editProperties`)}),n(ce,{children:[n(`div`,{className:`mb-2 text-sm text-muted`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-success`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(Pt,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(le,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(Z2,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}const c4=ht(()=>import(`@vertesia/ui/rich-text`).then(e=>({default:e.VertesiaMarkdownDocumentEditor})));function l4(e){switch(e){case`text/markdown`:case`text/x-markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function u4({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=q(),l=nt(),{t:u}=K(),{theme:d}=tt(),f=Qn(),p=W(void 0),[m,h]=G(i),[g,_]=G(!1),[v,y]=G(!1),[b,x]=G(!1),S=l4(r.content?.type),C=U2(r.content?.type);H(()=>{h(i),_(!1)},[i]);let w=V(()=>{g||_(!0)},[g]),T=V(e=>{h(e),_(e!==i)},[i]);function E(){!C&&!p.current||x(!0)}async function D(e,t){if(!C&&!p.current)return;let n=C?m:p.current?.getValue();if(n===void 0)return;let i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{y(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),x(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=Ge(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{y(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[g&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:v,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:E,disabled:!g,isLoading:v,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:C?t(ut,{fallback:t(`div`,{className:`h-full w-full`}),children:t(c4,{value:m,onChange:T})}):t(Pt,{value:i,language:S,editorRef:p,onChange:w,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(Z2,{isOpen:b,onClose:()=>x(!1),onConfirm:D,isLoading:v})]})}const d4=131072;function f4(e,t,n=!1,r=e){let{store:i}=q(),[a,o]=G(t),[s,c]=G(()=>t&&t.length>d4?t.substring(0,d4):t),[l,u]=G(!1),[d,f]=G(()=>!!t&&t.length>d4),[p,m]=G(),h=W(t),g=W(e),_=W(r),v=W(!1),y=V((e,t=!0)=>{let n=h.current;t&&n&&e&&n!==e?m(e=>({previousText:n,version:(e?.version??0)+1})):t||m(void 0),h.current=e,o(e),e&&e.length>d4?(c(e.substring(0,d4)),f(!0)):(c(e),f(!1))},[]),b=V(()=>{let t=e,n=r;u(!0),i.objects.getObjectText(e).then(e=>{if(g.current!==t)return;let r=_.current===n&&!v.current;y(e.text,r),v.current=!1}).catch(e=>{console.error(`Failed to load text`,e)}).finally(()=>{g.current===t&&u(!1)})},[y,r,e,i]);return bt(()=>{let i=g.current!==e,a=_.current!==r;g.current=e,_.current=r,a&&(v.current=!0),t!==void 0&&(y(t,!a),v.current=!1),n&&t===void 0&&(i||h.current===void 0)&&b()},[y,r,t,n,b,e]),{fullText:a,displayText:s,isLoading:l,isCropped:d,changeHighlight:p,loadText:b}}function p4(e,t){let{client:n}=q(),[r,i]=G({isComplete:!1});return H(()=>{if(!t)return;let r=!1,a,o=(e,t,n)=>{i(r=>{let i=JSON.stringify(r.progress??null),a=JSON.stringify(e??null);return r.status===t&&r.isComplete===n&&i===a?r:{progress:e,status:t,isComplete:n}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{e.status===Tn.RUNNING?(o(e.progress,e.status,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,isComplete:r.isComplete}}function m4(e,t){let{client:n}=q(),r=Xt.getFixedT(null,Yt),[i,a]=G(),[o,s]=G(!1),[c,l]=G();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:V(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:gn.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}Q(),ZY();const h4=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(Zn,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function g4(e){return e===dn.created||e===dn.processing}function _4(e){return e.metadata?.content_processor?.type}function v4(e){return e?e.includes(`
|
|
1379
|
+
`)}let r=await i(n,{tool_approval_mode:oe});if(!r){re(null),ae(null);return}re(n),ae(Date.now());let a=r.agent_run_id,o=!0;if(A&&de.length>0){let e=`batch-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t=[],n=[];for(let e of de)try{let n=`files/${e.name}`;await P.agents.uploadArtifact(a,n,e);let r=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;await P.agents.sendSignal(a,`FileUploaded`,{id:r,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${n}`,artifact_path:n}),t.push(r)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t),n.push({name:e.name,error:t instanceof Error?t.message:String(t)})}o=await b1(P,a,{batch_id:e,file_ids:t,failed_uploads:n.length>0?n:void 0}),o&&fe([]),n.length>0&&ce({title:D(`agent.stagedFilesUploadFailed`),status:`warning`,duration:6e3,description:n.map(e=>e.name).join(`, `)})}p?.(),te(a),I(``),ce(o?{title:D(`agent.agentStarted`),status:`success`,duration:3e3}:{title:D(`agent.stagedFilesNotDelivered`),status:`error`,duration:8e3,description:D(`agent.stagedFilesNotDeliveredDescription`)})}catch(e){re(null),ae(null),ce({title:D(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:D(`agent.unknownError`)})}finally{ee(!1)}}},Oe=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),De();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,I))}},ke=V(()=>{let e=le.current;if(e){if(k){e.style.height=`100%`;return}e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`}},[k]);return H(()=>{ke()},[F,ke]),R?t(Y1,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,onAgentWorkingChange:E,agentRunId:R,title:d,pendingStartMessage:ne??void 0,pendingStartTimestamp:ie??void 0,initialToolApprovalMode:oe}):t(`div`,{className:z(`flex flex-col items-center bg-background`,O&&!k?``:`h-full`,C),children:n(`div`,{className:z(`relative flex w-full flex-col overflow-hidden border-0`,O&&!k?``:`h-full`,c?``:`max-w-4xl`),onDragEnter:A?be:void 0,onDragOver:A?xe:void 0,onDragLeave:A?Se:void 0,onDrop:A?Ce:void 0,children:[A&&_e&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to stage for upload`]})}),A&&t(`input`,{ref:ue,type:`file`,multiple:!0,accept:m,onChange:Te,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(hg,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:N})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,title:D(`agent.close`),className:`text-muted hover:text-foreground`,children:t(Gb,{className:`size-4`})})]}),t(`div`,{className:z(`flex flex-col items-center justify-end bg-background px-4`,O?`shrink-0 pt-3`:`flex-1 overflow-y-auto`),children:ne&&ie?t(V1,{message:ne,startedAt:ie}):t(`div`,{className:z(`mx-auto flex w-full max-w-3xl flex-col justify-end`,O?``:`min-h-full py-8`),children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:z(`bg-background px-4 pb-safe-area-4 pt-2`,k?`flex min-h-0 flex-1 flex-col`:`shrink-0`),children:n(`div`,{className:z(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,k&&`min-h-0 w-full flex-1`,x),children:[A&&de.length>0&&n(`div`,{className:`flex flex-wrap gap-2`,children:[he.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:D(`agent.fileStagedTooltip`),children:[t(Gg,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:D(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>Ee(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(Gb,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`)),de.length>3&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":pe,onClick:()=>me(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!pe&&n(`span`,{children:[`+`,ge]}),D(pe?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,pe&&`rotate-180`),"aria-hidden":`true`})]})]}),t(Ue,{ref:le,value:F,onChange:e=>I(e.target.value),onKeyDown:Oe,onPaste:we,placeholder:j,disabled:L,rows:2,className:z(`min-h-[72px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,k?`min-h-0 flex-1 overflow-y-auto`:`overflow-hidden`,S),style:k?{minHeight:`72px`,maxHeight:`none`}:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[A&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ue.current?.click(),disabled:L||de.length>=h,"aria-label":D(`agent.upload`),className:`rounded-full text-muted`,title:D(`agent.upload`),children:t(wb,{className:`size-4`})}),r&&t(Yb,{mode:oe,onChange:se,disabled:L})]}),t(o,{onClick:De,disabled:!F.trim()||L,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:M,children:L?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]})})]})})}function Y1({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:ee,className:R,inputContainerClassName:te,inputClassName:ne,composerContext:re,fusionData:ie,fileUploadRef:ae,sendMessageRef:de,onMessage:fe,onAgentWorkingChange:pe,onProcessingFilesChange:me,processingFiles:he,onPlansChange:ge,onWorkstreamStatusChange:_e,viewMode:ve,onViewModeChange:ye,onShowInputChange:be,stopRef:xe,onStoppingChange:Se,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:je,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,payloadContent:Re,conversationContent:ze,conversationTab:Be=!1,pendingStartMessage:Ve,pendingStartTimestamp:He,initialToolApprovalMode:Ue,enablePlayback:We,showPlaybackToggle:Ge=!0,messageFilter:Ke,initialWorkstream:qe}){let{t:Je}=K(),{client:Ye}=q(),Xe=nt(),{messages:Ze,streamingMessages:Qe,isCompleted:$e,initialHistoryStatus:et,debugChunkFlash:tt,addOptimisticMessage:rt,updateOptimisticMessageStatus:it,reconnect:at,agentRunStatus:B,workflowRunId:ot,serverFileUpdates:st}=HX(Ye,r,fe),{plans:ct,activePlanIndex:lt,setActivePlanIndex:ut,workstreamStatusMap:dt,showInput:ft,showSlidingPanel:pt,setShowSlidingPanel:mt}=jX(Ze,a),{openDocuments:ht,activeDocumentId:gt,isDocPanelOpen:_t,docRefreshKey:vt,closeDocPanel:yt,selectDocument:bt,openDocInPanel:xt,updateDocumentTitle:St}=KX(Ze),{processingFiles:Ct,hasProcessingFiles:wt,handleFileUpload:Tt,removeProcessingFile:Et,clearProcessingFiles:Dt}=XX(Ye,r,st,Xe,U(()=>qW(Ze),[Ze])),Ot=a&&!j,kt=V(e=>{Et(e)},[Et]),At=W(null),jt=W(null),Mt=W(null),[Nt,Pt]=G(!1),[Ft,It]=G(``),[Lt,Rt]=G(!1),[zt,Bt]=G(`sliding`),Vt=ve??zt,Ht=V(e=>{ye?ye(e):Bt(e)},[ye]),[Wt,Gt]=G(!1),[Kt,qt]=G(!1),[Jt,Yt]=G(qe||`all`),Xt=W(qe);H(()=>{qe&&qe!==Xt.current&&(Xt.current=qe,Yt(qe))},[qe]);let[Zt,Qt]=G(`live`),[$t,en]=G(!1),[tn,nn]=G(0),[rn,an]=G([]),[on,sn]=G([]),[cn,ln]=G(!1),un=U(()=>Ue===void 0&&a?void 0:kn(Ue,a),[Ue,a]),[dn,fn]=G(un),mn=W(!1),hn=W(0),gn=W(!1),_n=W(0),vn=W(null);H(()=>{fn(un)},[un]);let yn=W(Nt);yn.current=Nt;let bn=W(wt);bn.current=wt;let xn=W(Ct);xn.current=Ct;let Sn=U(()=>{let e=Ze.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[Ze]),Cn=U(()=>Sn?.type===J.TERMINATED?`TERMINATED`:Sn?.type===J.COMPLETE&&(!B||B===`RUNNING`)?`COMPLETED`:B,[Sn,B]),wn=U(()=>S1(Cn),[Cn]),Tn=U(()=>C1(Cn,!!f),[Cn,f]),En=!E||Tn,Dn=U(()=>Cn?.toUpperCase()===`FAILED`||B?.toUpperCase()===`FAILED`,[Cn,B]),On=U(()=>{for(let e=Ze.length-1;e>=0;e--){let t=Ze[e];if(t.type!==J.ERROR||eU(t)!==`main`)continue;let n=typeof t.message==`string`?t.message.trim():``;if(n)return n}},[Ze]),An=W(wn);An.current=wn;let jn=W(Tn);jn.current=Tn;let Mn=W(!!f);Mn.current=!!f;let Nn=U(()=>{let e=ct[lt]||{plan:{plan:[]},timestamp:0},t=dt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[ct,lt,dt]),Pn=U(()=>P1(Ze),[Ze]),Fn=U(()=>{let e=[...Pn];for(let t of on)L1(e,I1(t));for(let t of rn)L1(e,F1(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!E1(e.workstream.status))-Number(!E1(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[Pn,rn,on]),In=U(()=>Fn.filter(e=>E1(e.status)),[Fn]),Ln=U(()=>In.filter(e=>e.status===`running`).length,[In]),Rn=U(()=>{if(Jt===`all`)return;let e=Fn.find(e=>e.workstream_id===Jt||e.launch_id===Jt);return e?FH(e.workstream_id,e.interaction):FH(Jt)},[Jt,Fn]),zn=U(()=>{if(u)return u;if(Rn)return Je(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Rn})},[Rn,u,Je]),Bn=Ge&&We===void 0&&_C(),Vn=We??(vC()||$t),Hn=U(()=>Ze.filter(e=>!XH(e)&&!(P?.includes(e.type)??!1)),[P,Ze]),Un=U(()=>rU(Hn,Jt),[Jt,Hn]),Wn=U(()=>hC(Un,Zt,Vn),[Vn,Zt,Un]),Gn=Wn.cursor,Kn=Wn.isLive,qn=Vn&&!Kn&&Wn.cursorIndex===Un.length-1,Jn=Wn.displayedMessages,Xn=U(()=>Ke?Jn.filter(e=>Ke(e)):Jn,[Jn,Ke]),Zn=U(()=>Ke?Hn.filter(e=>Ke(e)):Hn,[Ke,Hn]),Qn=Kn?Qe:v1,$n=U(()=>P1(Jn),[Jn]),er=U(()=>$n.filter(e=>E1(e.status)),[$n]),tr=U(()=>$e||!ZH(Ze),[$e,Ze]),nr=Kn||qn?tr:!1,rr=!tr&&!wn;H(()=>{pe?.(rr)},[rr,pe]);let ir=U(()=>{let e=new Set;for(let t of Jn)NU(r,t)&&e.add(kU(t));return tW(Jn,`main`,e)},[r,Jn]),ar=!!ir&&!Dn&&(!wn||Tn),or=Vn&&!Kn,sr=En&&!or,cr=U(()=>k1(Ze),[Ze]),lr=h&&!wn&&Kn&&!!cr;H(()=>{qH(`conversation render state`,{agentRunId:r,messageCount:Ze.length,playbackMessageCount:Un.length,displayedMessageCount:Xn.length,streamingCount:Qe.size,displayedStreamingCount:Qn.size,initialHistoryStatus:et,isCompleted:$e,effectiveIsCompleted:tr,displayedIsCompleted:nr,agentRunStatus:B,effectiveWorkflowStatus:Cn,isWorkflowTerminal:wn,playbackCursor:Gn,isPlaybackEnabled:Vn,isPlaybackLive:Kn,isPlaybackAtLatest:qn,activeWorkstream:Jt,showInitialRequest:et===`empty`&&Ze.length===0,pendingStartVisible:Ze.length===0&&!tr&&!!Ve})},[Jt,r,B,Gn,nr,Xn.length,Qn.size,tr,Cn,et,$e,qn,Vn,Kn,wn,Ze.length,Ve,Un.length,Qe.size]);let ur=V(()=>{en(e=>!e)},[]),dr=V(e=>{let t=fC(Gn,Un.length),n=fC(e,Un.length);Vn&&(n>t||e===`live`&&Gn!==`live`)&&(gn.current=!0,nn(e=>e+1)),Qt(e)},[Gn,Vn,Un.length]);H(()=>{if(!Vn){Zt!==`live`&&Qt(`live`);return}Gn!==Zt&&Qt(Gn)},[Gn,Vn,Zt]),H(()=>{if(!Vn||!gn.current)return;gn.current=!1;let e=window.requestAnimationFrame(()=>{At.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Vn,tn]);let fr=V(e=>{ut(e)},[ut]),[Y,pr]=G(ze||Be?`conversation`:void 0),mr=ct.length>0||Fn.length===0?`plan`:`workstreams`,[hr,gr]=G(null),[_r,vr]=G(400),[yr,br]=G(!1),[xr,Sr]=G(!1),Cr=A&&!xr&&(pt||_t||!k&&Fn.length>0||!!ze||Be),wr=W(_t);H(()=>{_t&&!wr.current&&Sr(!1),wr.current=_t},[_t]);let Tr=V(()=>{Cr?(Sr(!0),mt(!1)):(Sr(!1),mt(!0),sessionStorage.setItem(`plan-panel-shown`,`true`))},[Cr,mt]);H(()=>{!Cr&&yr&&br(!1)},[Cr,yr]),H(()=>{if(!yr)return;let e=e=>{let t=Mt.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;vr(Math.min(Math.max(i,300),r))},t=()=>{br(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[yr]);let Er=V(()=>{Sr(!0),mt(!1),yt()},[mt,yt]),Dr=V(e=>{/\.md$/i.test(e)&&(Sr(!1),gr(e),pr(`artifacts`),mt(!0))},[mt]),Or=W(null);H(()=>{let e,t;for(let n of Ze){let r=n.details;r?.event_class===`display_artifact`&&typeof r.path==`string`&&(e=r.path,t=`${n.timestamp??``}:${r.path}`)}!e||!t||t===Or.current||(Or.current=t,Sr(!1),gr(e),pr(`artifacts`),mt(!0))},[Ze,mt]);let kr=V(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),xt(n),pr(`documents`)},children:r}),[xt]),Ar=je??kr;H(()=>(ae&&(ae.current=Ot?Tt:null),()=>{ae&&(ae.current=null)}),[ae,Tt,Ot]),H(()=>{me?.(Ct)},[Ct,me]),H(()=>{ge?.(ct,lt)},[ct,lt,ge]),H(()=>{_e?.(dt)},[dt,_e]),H(()=>{gr(null),mn.current=!1,ln(!1),an([]),sn([])},[r]),H(()=>{let e=et!==`loading`&&!tr&&!wn&&!cn;if(qH(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:et,effectiveIsCompleted:tr,isWorkflowTerminal:wn,isWorkstreamQueryUnavailable:cn}),!e){an(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){qH(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{qH(`active workstreams fetch start`,{agentRunId:r});let e=await Ye.agents.getActiveWorkstreams(r);if(t)return;if(qH(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),an(e.running??[]),sn(e.completed??[]),e.unavailable){ln(!0);return}mn.current=!1}catch(e){if(t)return;an(e=>e.length===0?e:[]),ln(!0),qH(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),mn.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Ye.agents,r,tr,et,wn,cn]),H(()=>{if(Ze.length!==0){if(Tn){be?.(!0);return}if(!ft){be?.(!1);return}if(Cn&&Cn!==`RUNNING`){be?.(!1);return}Cn!==null&&be?.(!0)}},[ft,Cn,Ze.length,be,Tn]);let jr=V(async()=>{let e=vn.current;e&&await e},[]),Mr=V((e,t)=>{let n=e.trim();if(!n||yn.current||An.current&&!jn.current)return;if(bn.current){Xe({status:`warning`,title:Je(`agent.filesProcessing`),description:Je(`agent.waitForFilesProcessing`),duration:3e3});return}let i=zU(t);Pt(!0);let a=F?.()||[],o=ee?.()||{},s=n;a.length>0&&!/store:\S+/.test(n)&&(s=[n,``,`Attachments:`,...a.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
|
|
1380
|
+
`));let c=Array.from(xn.current.values()).filter(e=>e.status===pn.READY).map(e=>{let t=e.reference?.startsWith(`artifact:`)?e.reference:e.artifact_path?`artifact:${e.artifact_path}`:void 0;return t?`[${e.name}](${t})`:void 0}).filter(e=>!!e);c.length>0&&(s=[s,``,`Uploaded artifacts:`,...c].join(`
|
|
1381
|
+
`));let l=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,u={timestamp:Date.now(),workflow_run_id:r,type:J.QUESTION,message:s,workstream_id:`main`,details:{_optimistic:!0,_messageId:l,_deliveryStatus:`sending`,...t?.editing_action?{editing_action:t.editing_action}:{},...t?.request_input_response?{request_input_response:t.request_input_response}:{}}};rt(u);let d={...a.length>0?{attached_docs:a.map(e=>e.id)}:{},...o,...t,id:l,_messageId:l},f=()=>Ye.agents.sendSignal(r,`UserInput`,{message:s,client_message_id:l,metadata:d}),p=()=>{it(l,`received`),I?.(),Dt()};i&&jU(r,i);let m=async()=>{await Ye.agents.restart(r),at()};(async()=>{await jr(),An.current&&await m();try{await f()}catch(e){if(!w1(e))throw e;let t=await Ye.agents.retrieve(r);if(!C1(t.status,Mn.current))throw S1(t.status)&&at(),e;await m(),await f()}p()})().catch(e=>{i&&MU(r,i),it(l,`failed`),Xe({status:`error`,title:Je(`agent.failedToSend`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}).finally(()=>{Pt(!1)})},[r,Ye,Xe,F,ee,I,Dt,at,rt,it,Je,jr]);H(()=>(de&&(de.current=Mr),()=>{de?.current===Mr&&(de.current=null)}),[Mr,de]);let Nr=V(async(e,t)=>{try{await Ye.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}Mr(Je(`agent.mcpConnectedMessage`,{name:e.name}),t)},[Ye,r,Mr,Je]),[Pr,Fr]=G(void 0);H(()=>{let e=!1,t=_n.current;return Ye.agents.retrieve(r).then(n=>{e||(Fr(n.disabled_mcp_collections),_n.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&fn(kn(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Ye,r]);let Ir=V(e=>{let t=e.length>0?e:void 0;Fr(t),Ye.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Lr=V(()=>{Ye.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Rr=V(e=>{let t=kn(e,a),n=dn;_n.current+=1,fn(t);let i=Ye.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{fn(e=>e===t?n:e),Xe({status:`error`,title:Je(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})});vn.current=i,i.finally(()=>{vn.current===i&&(vn.current=null)})},[r,Ye,a,Je,Xe,dn]),zr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),hn.current++,e.dataTransfer?.types?.includes(`Files`)&&qt(!0))},[Ot]),Br=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation())},[Ot]),Vr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),hn.current--,hn.current===0&&qt(!1))},[Ot]),Hr=V(e=>{if(Ot&&(e.preventDefault(),e.stopPropagation(),hn.current=0,qt(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);Tt(t)}},[Tt,Ot]),Ur=V(async()=>{if(Wt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:J.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};rt(t),Gt(!0);try{await Ye.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),it(e,`received`)}catch(t){Xe({status:`error`,title:Je(`agent.failedToInterrupt`),description:t instanceof Error?t.message:Je(`agent.unknownError`),duration:3e3}),it(e,`failed`)}finally{Gt(!1)}},[Wt,r,rt,Ye.agents,Xe,Je,it]),Wr=V(async()=>{if(!(Lt||tr||!Kn)){Rt(!0);try{await Ye.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Xe({status:`error`,title:Je(`agent.failedToCompactContext`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}finally{Rt(!1)}}},[r,Ye.agents,tr,Lt,Kn,Je,Xe]);H(()=>(xe&&(xe.current=h&&!tr?Ur:null),()=>{xe&&(xe.current=null)}),[xe,tr,Ur,h]),H(()=>{Se?.(Wt)},[Wt,Se]);let Gr=i||Je(`agent.agentConversation`),Kr=async()=>{try{let e=await iU(Ye,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Xe({status:`error`,title:Je(`agent.failedToDownload`),duration:3e3})}},qr=V(()=>{let e=new Date().toISOString(),t=Qe.size>0?[{cursor:`live`,streamingMessages:Array.from(Qe,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:Gr,agent_run_id:r,exported_at:e,message_count:Ze.length},messages:Ze,...t?{streamingFrames:t}:{}};G1(`${W1(Gr)||`agent-chat`}-${W1(r)}.json`,n),Xe({status:`success`,title:Je(`agent.rewind.fixtureExported`),duration:2e3})},[Gr,r,Ze,Qe,Je,Xe]),[Jr,Yr]=G(!1),Xr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}Yr(!0)},Zr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}let e=`${Gr} - ${r}`;if(!H1(jt.current,e)){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.unableToOpenPrint`),duration:4e3});return}Xe({status:`success`,title:Je(`agent.pdfExportReady`),description:Je(`agent.printDialogDescription`),duration:4e3}),Yr(!1)},Qr=U(()=>Ze.filter(e=>e.type===J.COMPLETE||e.type===J.THOUGHT&&e.details?.tool_status===`completed`).length,[Ze]),$r=U(()=>{if(!hr)return{key:Qr,details:void 0};let e=0,t;for(let n of Ze){let r=n.details;Ut(r,hr)&&(e++,t=r)}return{key:e,details:t}},[Qr,Ze,hr]),ei=a&&Kn&&Cn?.toUpperCase()===`RUNNING`,ti=U(()=>Nn.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[Nn.plan]),ni=e=>t(oZ,{title:Gr,variant:e,isCompleted:tr,isTerminal:wn,onClose:s,isModal:c,agentRunId:r,workflowRunId:ot||``,viewMode:Vt,onViewModeChange:Ht,showPlanPanel:Cr,hasPlan:A&&ct.length>0,showPlanButton:A&&!Be,onTogglePlanPanel:Tr,showPlaybackButton:Bn,isPlaybackEnabled:Vn,onTogglePlayback:ur,onDownload:Kr,onExportFixture:qr,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:Xr,isReceivingChunks:tt}),ri=n(`div`,{ref:jt,"data-agent-playback-enabled":Vn||void 0,"data-agent-playback-cursor":Vn?Gn:void 0,"data-agent-live-message-count":Ze.length,"data-agent-rendered-message-count":Xn.length,className:z(`flex flex-col min-h-0 min-w-0 border-0`,Be?`flex-1 h-full`:Cr?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:ni(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:ni(T)}),Vn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:Gn,messages:Un,onChangeCursor:dr})}),Ze.length===0&&!tr&&Ve&&He?t(V1,{message:Ve,startedAt:He}):t(OJ,{messages:Xn,workstreamSourceMessages:Zn,bottomRef:At,isCompleted:nr,plan:Nn.plan,workstreamStatus:Nn.workstreamStatus,showPlanPanel:A&&pt,onTogglePlanPanel:Tr,plans:ct,activePlanIndex:lt,onChangePlan:fr,taskLabels:ti,streamingMessages:Qn,onSendMessage:Kn?Mr:void 0,onOpenArtifact:M?Dr:void 0,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,artifactRunId:r,viewMode:Vt,hideWorkstreamTabs:k,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:Ar,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,showInitialRequest:et===`empty`&&Ze.length===0,hiddenMessageTypes:P,disableAutoScroll:!Kn,renderRequestInputControls:!ar,activeWorkstream:Jt,onActiveWorkstreamChange:Yt}),ar?t(rW,{message:ir,onSendMessage:Kn?Mr:void 0,onMcpConnected:Kn?Nr:void 0,disabled:L||!Kn,isLoading:Nt||L}):or&&er.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(ZX,{activeWorkstreams:er,onSelectWorkstream:Yt})}):sr&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:Dn?D??t(oe,{status:`error`,title:Je(`agent.failed`),className:`m-2`,children:On??Je(`agent.error`)}):Cn&&Cn!==`RUNNING`&&!Tn?Vt===`sliding`&&Cn===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(Nh,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(oe,{status:Cn===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,Cn]}):(ft||Tn)&&n(e,{children:[re,t(u1,{onSend:Mr,value:Ft,onValueChange:It,onStop:h?Ur:void 0,approvalModeSlot:a&&dn?t(Yb,{mode:dn,onChange:Rr,disabled:!Kn||wn||!h}):void 0,mcpSlot:t(KJ,{disabledCollections:Pr,onChange:Ir,onConnectionChange:Lr}),disabled:L||!Kn,isSending:Nt||L,isStopping:Wt,isStreaming:!tr,isCompleted:tr,contextWindowUsage:lr?cr:void 0,onCompactContext:lr?Wr:void 0,isCompactingContext:Lt,activeTaskCount:Ln,activeWorkstreams:In,onSelectWorkstream:Yt,placeholder:zn,onFilesSelected:Ot?Tt:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:kt,acceptedFileTypes:v,maxFiles:y,processingFiles:Ct,artifactRunId:r,hasProcessingFiles:wt,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!Ot,disableDropZone:Ot,className:te,inputClassName:ne})]})})]}),ii=t(BS,{children:t(OW,{children:n(`div`,{ref:Mt,className:z(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,Ot&&Kt&&`ring-2 ring-info ring-inset`,R),onDragEnter:Ot?zr:void 0,onDragOver:Ot?Br:void 0,onDragLeave:Ot?Vr:void 0,onDrop:Ot?Hr:void 0,children:[Ot&&Kt&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to upload`]})}),!Be&&ri,!Be&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:ni(`compact`)}),Cr&&n(e,{children:[!Be&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(_r),"aria-valuemin":300,"aria-valuetext":`${Math.round(_r)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>br(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=Mt.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;vr(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Be?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Be?void 0:{"--agent-right-panel-width":`${_r}px`},children:t(kX,{plan:Nn.plan,workstreamStatus:Nn.workstreamStatus,plans:ct,activePlanIndex:lt,onChangePlan:fr,showPlan:!O&&pt,activeWorkstreams:Fn,hideWorkstreams:k,openDocuments:ht,activeDocumentId:gt,onSelectDocument:bt,onUpdateDocumentTitle:St,docRefreshKey:vt,runId:r,processingFiles:he??Ct,showArtifacts:M,artifactRefreshKey:$r.key,artifactRefreshDetails:$r.details,selectedArtifactPath:hr,onSelectedArtifactPathChange:gr,onSendMessage:ei?Mr:void 0,messages:Ze,payloadContent:Re,conversationContent:Be?ri:ze,onClose:Er,defaultTab:Y??mr,activeTab:Y??mr,onTabChange:pr})})]}),n(se,{isOpen:Jr,onClose:()=>Yr(!1),children:[t(ue,{children:`Export conversation as PDF`}),n(ce,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(le,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Yr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:Zr,children:`Open print dialog`})]})]})]})})});return ie?t(Yn,{data:ie,sendMessage:Mr,ChartComponent:oC,artifactRunId:r,children:ii}):ii}function X1({messages:e}){let n=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:n.map(e=>t(yG,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function Z1({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=ot.useRef(null);H(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-muted`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(X1,{messages:s,isCompleted:!1})})})}function Q1(e){return e.name}function $1({isClearable:e=!1,onChange:n,ignoreVirtuals:r=!1,selectedEnvId:i,disabled:a=!1}){let{t:o}=K(),{client:s}=q(),[c,l]=G(),{data:u,isLoading:d}=Xe(()=>s.environments.list().then(e=>(r?e.filter(e=>!e.provider.startsWith(`virtual_`)):e).slice().sort((e,t)=>e.name.localeCompare(t.name))));return H(()=>{l(u?.find(e=>e.id===i))},[u,i]),t(we,{isClearable:e,optionLabel:Q1,options:u??[],value:c,onChange:e=>{l(e),n(e)},placeholder:o(`intakePolicy.placeholder.environment`),filterBy:`name`,disabled:a,isLoading:d})}function e0(e){return e.name}function t0(e){return e?.length?n=>{let r=e.some(e=>e.id===n.id);return t(`span`,{className:r?`opacity-50`:``,children:n.name})}:e0}function n0({envId:e,isClearable:n,onChange:r,selectedModelId:i,disabled:a=!1,greyedModels:o,onModelsLoaded:s}){let{t:c}=K(),{client:l}=q(),[u,d]=G(),{data:f,isLoading:p}=Ye(async()=>{if(!e)return[];try{return[...(await l.environments.retrieve(e)).enabled_models??[]].sort((e,t)=>e.name.localeCompare(t.name))}catch{return[]}},[e]);return H(()=>{if(!i){d(void 0);return}let e=f?.find(e=>e.id===i);d(e??{id:i,name:i,provider:`unknown`})},[f,i]),H(()=>{f&&s?.(f)},[f,s]),t(we,{isClearable:n,by:`id`,optionLabel:t0(o),options:f??[],value:u,onChange:e=>{d(e),r(e)},placeholder:c(`intakePolicy.placeholder.model`),disabled:a,isLoading:p})}function r0({env:e,isClearable:n,onChange:r}){let{t:i}=K(),{client:a}=q(),[o,s]=G(),{data:c,isLoading:l}=Ye(async()=>{if(!e)return[];try{return a.environments.listTrainableModels(e.id)}catch{return[]}},[e?.id]);return t(we,{isClearable:n,by:`id`,optionLabel:e0,options:c??[],value:o,onChange:e=>{s(e),r(e)},placeholder:i(`intakePolicy.placeholder.model`),disabled:!e,isLoading:l})}function i0({children:e,fallback:n}){return a0?t(a0,{fallback:n,children:e}):t(rr,{FallbackComponent:n,children:e})}let a0=null;function o0(e){a0=e}function s0({children:e}){return t(i0,{fallback:c0,children:e})}function c0({error:e}){let{t:r}=K(),i=e instanceof Error?e.message:void 0;return n(oe,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function l0({children:e}){return t(i0,{fallback:u0,children:e})}function u0({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-muted`,children:r})]})})}function d0({children:e}){return t(i0,{fallback:f0,children:e})}function f0({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}Q();const p0=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function m0(e){return p0.test(e)}function h0({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0,parentPath:u,parentLabel:d}){let f=Qn();function p(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>qn(e)).join(` `)}let m=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?p(n[n.length-1]):`Page`},h=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:m(n),href:n.href,onClick:()=>f(n.href,{stepsBack:i})})});else if(u)e.push({label:d??m({href:u}),href:u,onClick:()=>f(u,{isBasePathNested:!1,replace:!0})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(m0(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:p(t[n-1]||r),href:r,onClick:()=>f(r,{isBasePathNested:!1})})}}}return Array.isArray(c)&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>f(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})(),g=!!i&&h.length===0;return n(`div`,{className:it(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[h.length>0&&t(a,{path:h,separator:t(lh,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&!g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted ms-4`})})]}),i&&n(`div`,{className:`flex gap-2 items-center`,children:[t(`h1`,{className:`text-xl font-semibold break-all`,children:i}),o&&g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted`})})]})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function g0(){let{t:e}=K();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-destructive`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}Q();const _0=`magic-pdf`;function v0(e){return e.replace(/^\$\.?/,``).replace(/^data\./,``)}function y0(e){let{client:t}=q(),[n,r]=G(!1);return H(()=>{let n=!1;return r(!1),t.files.getDownloadUrl(`${_0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url,{method:`HEAD`})).then(e=>{n||r(e.ok)}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function b0(e){let{client:t}=q(),[n,r]=G(null);return H(()=>{let n=!1;return r(null),t.files.getDownloadUrl(`${_0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url)).then(e=>e.ok?e.json():null).then(e=>{n||!e?.citations||r({confidence:e.confidence,verified:e.citations.filter(e=>e.verified).length,total:e.citations.length,verdict:e.verdict,verdict_reason:e.verdict_reason})}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function x0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c,isLoading:l}=Ye(async()=>{let t=await a.files.getDownloadUrl(`${_0}/${e}/grounded-extraction.json`),n=await fetch(t.url);if(!n.ok)throw Error(i(`grounded.notFound`));return n.json()},[e]);return c?t(`div`,{className:`flex h-full items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`grounded.failedToLoad`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:i(`pdf.close`)})]})}):l||!s?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(`div`,{className:`relative h-full`,children:t(C0,{extraction:s,objectId:e,onClose:r})})}function S0({objectId:e,onClose:n}){return t(`div`,{className:`fixed inset-0 bg-background z-50`,children:t(x0,{objectId:e,onClose:n})})}function C0({extraction:r,objectId:a,onClose:s}){let{t:c}=K(),{client:l}=q(),u=U(()=>Object.keys(r.pages).map(e=>parseInt(e,10)).sort((e,t)=>e-t),[r.pages]),d=e=>{l.files.getDownloadUrl(`${_0}/${a}/${e}`).then(e=>window.open(e.url,`_blank`)).catch(()=>{})},[f,p]=G(u[0]??1),[m,h]=G(void 0),[g,_]=G(!1),[v,y]=G(`original`),b=U(()=>{let e={digital:0,ocr:0,reviewerConfirmed:0,snapped:0,imageRead:0},t=[];for(let n of r.citations)n.verified?n.snapped?e.snapped++:(n.confidence??0)>=1?e.digital++:e.ocr++:n.reviewed?e.reviewerConfirmed++:(e.imageRead++,t.push(n));let n=e.digital+e.ocr+e.snapped,i=e.reviewerConfirmed;return{groups:e,unverified:t,digitallyVerified:n,modelVerified:i,totalVerified:n+i}},[r.citations]),x=U(()=>{let e=new Map;for(let t of r.citations){let n=v0(t.path),r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[r.citations]),S=r.citations.length,C=b.totalVerified===S,T=e=>{h(e);let t=x.get(v0(e))?.[0];t&&p(t.page)},E=u.indexOf(f),D=m?x.get(v0(m))?.find(e=>e.page===f):void 0,O=D?.cells?D.cells.start===D.cells.end?D.cells.start:`${D.cells.start}:${D.cells.end}`:void 0;return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[n(Se,{defaultSize:55,minSize:25,className:`flex flex-col bg-muted`,children:[n(`div`,{className:`relative flex h-9 shrink-0 items-center justify-center bg-sidebar px-2 border-b border-sidebar-border`,children:[O&&t(i,{variant:`secondary`,className:`absolute start-2 max-w-32 truncate font-mono text-[11px]`,title:O,children:O}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.previousPage`),disabled:E<=0,onClick:()=>p(u[E-1]),children:t(oh,{className:`size-4`})}),t(`span`,{className:`text-xs text-muted`,children:c(`pdf.pageOf`,{pageNumber:f,totalPages:u.length})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.nextPage`),disabled:E>=u.length-1,onClick:()=>p(u[E+1]),children:t(lh,{className:`size-4`})})]}),n(`fieldset`,{className:`absolute end-2 flex items-center gap-0.5 rounded border-0 bg-muted p-0.5`,children:[t(`legend`,{className:`sr-only`,children:c(`grounded.checkerboard`)}),t(We,{description:c(`pdf.originalImages`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`original`?`outline`:`ghost`,size:`xs`,"aria-label":c(`pdf.originalImages`),"aria-pressed":v===`original`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`original`),children:[t(D_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`pdf.page`)})]})}),t(We,{description:c(`grounded.checkerboard`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`grid`?`outline`:`ghost`,size:`xs`,"aria-label":c(`grounded.checkerboard`),"aria-pressed":v===`grid`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`grid`),children:[t(x_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`grounded.checkerboard`)})]})})]})]}),t(`div`,{className:`flex-1 overflow-auto p-2`,children:t(w0,{objectId:a,page:f,dims:r.pages[String(f)],citations:r.citations.filter(e=>e.page===f),selectedPath:m,onSelectPath:h,imageMode:v})})]}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:45,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`span`,{className:`text-sm font-medium`,children:c(`grounded.title`)}),n(`div`,{className:`flex items-center gap-2`,children:[S>0&&t(We,{description:c(`grounded.confidenceHint`),placement:`bottom`,size:`xs`,asChild:!0,children:n(i,{variant:C?`success`:`attention`,className:`gap-1 text-nowrap cursor-pointer`,onClick:()=>_(e=>!e),"aria-expanded":g,children:[t(C?Ih:Ag,{className:`size-3.5`}),c(`grounded.verifiedOf`,{verified:b.totalVerified,total:S})]})}),n(w,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`pdf.download`),title:c(`pdf.download`),children:t(xg,{className:`size-4`})}),children:[n(ae,{className:`text-xs`,onClick:()=>d(`grounded-extraction.json`),children:[t(Ng,{className:`size-4`}),c(`grounded.downloadCitations`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`pages/page-${f}.json`),children:[t(Gg,{className:`size-4`}),c(`grounded.downloadBlocks`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`grounded-annotated.pdf`),children:[t(Ig,{className:`size-4`}),c(`grounded.downloadAnnotated`)]})]}),!!s&&t(o,{variant:`ghost`,size:`xs`,onClick:s,"aria-label":c(`pdf.close`),children:t(Gb,{className:`size-4`})})]})]}),g&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm max-h-72 overflow-auto`,children:[n(`div`,{className:`mb-1 flex items-center gap-1`,children:[t(`span`,{className:`font-medium`,children:c(`grounded.breakdownTitle`)}),t(We,{description:c(`grounded.breakdownVerificationHelp`),size:`xs`,children:t(A_,{className:`size-3 text-muted`})})]}),n(`div`,{className:`grid grid-cols-2 gap-x-4 text-xs`,children:[t(`span`,{className:`col-span-2 mt-1 font-medium text-success`,children:c(`grounded.digitalVerifiedOf`,{count:b.digitallyVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownDigital`)}),t(`span`,{className:`text-end text-success`,children:b.groups.digital}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownOcr`)}),t(`span`,{className:`text-end text-success`,children:b.groups.ocr}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownSnapped`)}),t(`span`,{className:`text-end text-success`,children:b.groups.snapped}),t(`span`,{className:`col-span-2 mt-2 font-medium text-success`,children:c(`grounded.modelVerifiedOf`,{count:b.modelVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownReviewer`)}),t(`span`,{className:`text-end text-success`,children:b.groups.reviewerConfirmed}),b.groups.imageRead>0&&n(e,{children:[t(`span`,{className:`col-span-2 mt-2 font-medium text-attention`,children:c(`grounded.unverifiedCount`,{count:b.groups.imageRead})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownImageRead`)}),t(`span`,{className:`text-end text-attention`,children:b.groups.imageRead})]})]}),typeof r.hardness?.score==`number`&&n(`p`,{className:`mt-2 text-xs text-muted`,title:c(`grounded.hardnessHint`),children:[c(`grounded.hardness`,{percent:Math.round(r.hardness.score*100)}),r.hardness.escalated?` ↑`:``]}),(r.verdict_reason??r.review?.verdict_reason)&&t(`p`,{className:`mt-2 text-xs`,children:r.verdict_reason??r.review?.verdict_reason}),r.review?.summary&&n(`p`,{className:`mt-2 text-xs text-muted`,children:[n(`span`,{className:`font-medium text-foreground`,children:[c(`grounded.reviewSummary`),`: `]}),r.review.summary]}),typeof r.review?.corrections_applied==`number`&&r.review.corrections_applied>0&&t(`p`,{className:`mt-1 text-xs text-info`,children:c(`grounded.reviewCorrections`,{count:r.review.corrections_applied})}),b.unverified.length>0&&n(`div`,{className:`mt-2`,children:[t(`div`,{className:`text-xs font-medium text-muted mb-1`,children:c(`grounded.breakdownUnverifiedList`)}),t(`ul`,{className:`space-y-0.5`,children:b.unverified.map(e=>t(`li`,{children:n(`button`,{type:`button`,className:`w-full text-start text-xs rounded px-1 py-0.5 hover:bg-muted cursor-pointer`,onClick:()=>{T(e.path),_(!1)},children:[t(`span`,{className:`text-muted`,children:e.path}),` `,t(`span`,{children:String(e.value??``)})]})},e.path))})]})]}),n(`div`,{className:`flex-1 overflow-auto p-3`,children:[t(T0,{value:r.data,path:``,citationsByPath:x,selectedPath:m,onSelect:T}),r.conflicts&&r.conflicts.length>0&&t(`div`,{className:`mt-4 text-xs text-attention`,children:c(`grounded.conflicts`,{count:r.conflicts.length})})]})]})]})}function w0({objectId:e,page:r,dims:i,citations:a,selectedPath:o,onSelectPath:s,imageMode:c}){let{t:l}=K(),{client:u}=q(),[d,f]=G(void 0);if(H(()=>{let t=!1;return f(void 0),u.files.getDownloadUrl(`${_0}/${e}/pages/page-${r}.${c}.jpg`).then(e=>{t||f(e.url)}).catch(e=>console.warn(`Failed to load page image`,e)),()=>{t=!0}},[u,c,e,r]),!d||!i)return t(`div`,{className:`flex items-center justify-center h-64`,children:t(je,{})});let p=a.flatMap(e=>e.boxes.map((r,a)=>{let c=o!==void 0&&v0(o)===v0(e.path),l=e.cells?e.cells.start===e.cells.end?e.cells.start:`${e.cells.start}:${e.cells.end}`:void 0;return t(We,{description:n(`span`,{className:`flex flex-col gap-0.5`,children:[t(`span`,{className:`flex items-center gap-1 font-medium`,children:O0(e.path).map((e,r)=>n(lt,{children:[r>0&&t(lh,{className:`size-3 shrink-0 cn-rtl-flip`}),e]},`${r}:${e}`))}),l&&t(`span`,{className:`font-mono`,children:l}),e.source_text&&t(`span`,{children:e.source_text})]}),size:`xs`,asChild:!0,children:t(`button`,{type:`button`,"aria-label":e.path,onClick:()=>s(v0(e.path)),className:z(`absolute cursor-pointer border rounded-[1px] transition-colors`,e.misaligned&&`border-dashed`,c?`border-2 border-info bg-info/20 z-10`:e.verified?`border-success/70 hover:bg-success/20`:e.reviewed?`border-info/70 hover:bg-info/20`:`border-attention/80 hover:bg-attention/20`),style:{position:`absolute`,left:`${r.x/i.width*100}%`,top:`${r.y/i.height*100}%`,width:`${r.w/i.width*100}%`,height:`${r.h/i.height*100}%`}})},`${e.path}-${a}`)})),m=((i.rotation??0)%360+360)%360;if(m!==0){let e=m===90||m===270;return n(`div`,{className:`relative w-full`,style:{aspectRatio:`${i.width} / ${i.height}`},children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`absolute select-none`,style:{left:`50%`,top:`50%`,width:`${(e?i.height/i.width:1)*100}%`,height:`${(e?i.width/i.height:1)*100}%`,maxWidth:`none`,transform:`translate(-50%, -50%) rotate(${m}deg)`,transformOrigin:`center center`}}),p]})}return n(`div`,{className:`relative w-full`,children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`w-full select-none`}),p]})}function T0({value:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){return Array.isArray(e)?e.length>0&&e.every(e=>typeof e==`object`&&!!e)?t(E0,{items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}):t(`div`,{className:`space-y-1`,children:e.map((e,n)=>t(T0,{value:e,path:`${r}[${n}]`,citationsByPath:i,selectedPath:a,onSelect:o},`${r}[${n}]`))}):typeof e==`object`&&e?t(`div`,{className:r?`ps-3 border-s border-border space-y-0.5`:`space-y-0.5`,children:Object.entries(e).map(([e,s])=>{let c=r?`${r}.${e}`:e;if(typeof s!=`object`||!s)return t(D0,{label:e,value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o},c);let l=Array.isArray(s)&&s.length>0&&s.every(e=>typeof e==`object`&&!!e);return n(`div`,{className:`pt-1`,children:[!l&&t(`div`,{className:`text-sm font-semibold`,children:k0(e)}),t(T0,{value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o})]},c)})}):null}function E0({items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){let{t:s}=K(),c=U(()=>{let t=new Set;for(let n of e)for(let e of Object.keys(n))t.add(e);return Array.from(t)},[e]);return n(`div`,{className:`pt-1`,children:[n(`div`,{className:`text-sm font-semibold`,children:[k0(r.split(`.`).pop()),` (`,e.length,`)`]}),t(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs`,children:[t(`thead`,{children:t(`tr`,{className:`text-start text-muted`,children:c.map(e=>t(`th`,{scope:`col`,className:`py-1 pe-2 font-medium`,children:k0(e)},e))})}),t(`tbody`,{children:e.map((e,l)=>t(`tr`,{className:`border-t border-border/50`,children:c.map(c=>{let u=`${r}[${l}].${c}`,d=i.get(u)?.[0];return t(`td`,{className:`py-0.5 pe-2`,children:n(`button`,{type:`button`,onClick:()=>o(u),className:z(`text-start rounded px-1 w-full`,a===u?`bg-info/15 ring-1 ring-primary`:d?`hover:bg-muted cursor-pointer`:`text-muted cursor-default`),children:[M0(e[c]),d&&typeof d.confidence==`number`&&t(`span`,{className:z(`ms-1 text-[10px]`,j0(d.confidence)),title:s(`grounded.scoreHint`),children:A0(d.confidence)})]})},c)})},`${r}[${l}]`))})]})})]})}function D0({label:e,value:r,path:i,citationsByPath:a,selectedPath:o,onSelect:s}){let{t:c}=K(),l=a.get(i)?.[0];return n(`button`,{type:`button`,onClick:()=>l&&s(i),className:z(`flex items-center gap-2 w-full text-start text-sm rounded px-1.5 py-0.5`,o===i?`bg-info/15 ring-1 ring-primary`:l?`hover:bg-muted`:``,!l&&`cursor-default`),children:[n(`span`,{className:`min-w-28 shrink-0 font-semibold`,children:[k0(e),`:`]}),t(`span`,{className:`flex-1 wrap-break-word`,children:M0(r)}),l&&typeof l.confidence==`number`&&t(`span`,{className:z(`text-xs shrink-0`,j0(l.confidence)),title:c(`grounded.scoreHint`),children:A0(l.confidence)}),l&&(l.verified?t(Ih,{"aria-label":c(`grounded.verified`),className:`size-3.5 shrink-0 text-success`}):l.reviewed?t(Jy,{"aria-label":c(`grounded.aiVerified`),className:`size-3.5 shrink-0 text-info`}):t(Ag,{"aria-label":c(`grounded.readFromImage`),className:`size-3.5 shrink-0 text-attention`}))]})}function O0(e){return v0(e).split(`.`).map(e=>k0(e.replace(/\[\d+\]/g,``))).filter(Boolean)}function k0(e){return e?zt(e):``}function A0(e){let t=e*100;return Number.isInteger(t)?`${t}%`:`${(Math.floor(t*100)/100).toFixed(2)}%`}function j0(e){return e>=.95?`text-success`:e>=.7?`text-attention`:`text-destructive`}function M0(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`true`:`false`:typeof e==`object`?JSON.stringify(e):String(e)}const N0=`magic-pdf`;var P0;(function(e){e.original=`original`,e.instrumented=`instrumented`})(P0||={});var F0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${N0}/${this.objectId}/pages`;switch(t){case P0.original:return`${n}/page-${e}.original.jpg`;case P0.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},I0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${N0}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},L0=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=R0(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function R0(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const z0=dt(void 0);function B0({children:e,object:n}){let{client:r}=q(),i=n.metadata.page_count||10,[a,o]=G(()=>{let e=new L0(i);return n.text&&e.initFromContent(n.text),{count:i,layoutProvider:new I0(r,n.id,i),markdownProvider:e,imageProvider:new F0(r,n.id,i),pdfUrl:``,pdfUrlLoading:!0}});return H(()=>{let e=n.metadata?.renditions?.find(e=>e.name===_n),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{o(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),o(e=>({...e,pdfUrlLoading:!1}))}):o(e=>({...e,pdfUrlLoading:!1}))},[r,n.metadata,n.content?.type,n.content?.source]),t(z0.Provider,{value:a,children:e})}function V0(e,t,n){return e.files.getDownloadUrl(`${N0}/${t}/${n}`).then(e=>e.url)}function H0(){let e=ot.useContext(z0);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}Q();function U0({object:e}){let{t:n}=K(),{client:r}=q(),i=t=>{V0(r,e.id,t).then(e=>window.open(e,`_blank`))};return t(o,{variant:`ghost`,size:`xs`,onClick:()=>i(`document.md`),title:n(`pdf.download`),children:t(xg,{className:`size-4`})})}Q();function W0({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`w-6 h-6 animate-spin text-muted`})})}function G0({viewType:e,pageNumber:n}){switch(e){case`json`:return t(K0,{pageNumber:n});case`markdown`:return t(q0,{pageNumber:n});default:return t(q0,{pageNumber:n})}}function K0({pageNumber:e}){let[n,r]=G(null),[i,a]=G(!0),[o,s]=G(null),{layoutProvider:c}=H0();return H(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(W0,{})}):o?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:o}):n?t(At,{className:`w-full`,data:n}):null}function q0({pageNumber:e}){let[r,i]=G(null),[a,o]=G(!0),[s,c]=G(null),{markdownProvider:l}=H0();return H(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(W0,{}),t(`span`,{className:`text-sm text-muted`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(Nt,{children:r}):t(`div`,{children:`No markdown content available`})})}Q(),CY();var J0=class extends ct{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:Xt.t(`pdf.failedToLoadViewer`,{ns:Yt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function Y0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c}=Ye(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`pdf.fetchingDocumentFailed`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(J0,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(B0,{object:s,children:t(X0,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function X0({object:e,onClose:r}){let{t:i}=K(),{count:a,pdfUrl:s,pdfUrlLoading:c}=H0(),[l,u]=G(1);return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[t(Se,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(_Y,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:l,onChange:u})}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(U0,{object:e})}),t(`span`,{className:`text-xs text-muted`,children:i(`pdf.pageOf`,{pageNumber:l,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(G0,{pageNumber:l,viewType:`markdown`})})]})]})}const Z0=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],Q0=[`video/mp4`,`video/webm`],$0=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function e2(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function t2({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===cn),m=i?.content?.type&&$0.includes(i.content.type),h=!!i&&i.metadata?.type===un.Audio&&!p&&!m;return H(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,e2(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function n2({url:e,source:n,object:r,className:i}){let{client:a}=q(),[o,s]=G(e),[c,l]=G(!e&&(!!n||!!r));return H(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==un.Image)return;let e=r.content?.type&&Z0.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:mn.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(je,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function r2({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(),[f,p]=G(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&Q0.includes(i.content.type),_=m.find(e=>e.name===vn),v=!!i&&i.metadata?.type===un.Video&&!h&&!g;return H(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),H(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}Q();function i2({oauthProviderId:r,onAuthChange:i}){let{client:a}=q(),{t:o}=K(),[s,c]=G(null),[l,u]=G(!0),[d,f]=G(!1),[p,m]=G(!1),h=V(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);H(()=>{h()},[h]);let{openOAuthPopup:g}=pO({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(dO,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(dO,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Dg,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function a2(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function o2(...e){return Array.from(e)}function s2(e){return e.__AnyOf__===!0}function c2(e){if(e&&typeof e==`object`&&`status`in e&&typeof e.status==`number`)return e.status}function l2(e){let t=c2(e);return t===0||t===502||t===503||t===504||e instanceof Error&&e.name===`TimeoutError`}function u2(e,t){let n=U(()=>t?JSON.stringify(t):void 0,[t]),r=!!(t&&!t.permissions),[i,a]=G(0),[o,s]=G(),c=V(()=>a(e=>e+1),[]);return H(()=>{if(!r)return;let t=new AbortController,a=!1,o=0,c,l,u=t=>s({client:e,tokenKey:n,attempt:i,state:t}),d=()=>{a=!0,clearTimeout(f),clearTimeout(p),clearTimeout(l),t.abort()},f=setTimeout(()=>u({status:`retrying`}),5e3),p=setTimeout(()=>{d(),u({status:`error`,error:c})},6e4),m=async()=>{try{let n=await e.iam.roles.listSystem({signal:t.signal,timeoutMs:15e3,retryPolicy:!1});if(a)return;d(),u({status:`ready`,roles:n})}catch(e){if(a)return;if(c=e,!l2(e)){d(),u({status:`error`,error:e});return}u({status:`retrying`});let t=Math.min(1e3*2**o++,8e3)*(.5+Math.random()*.5);l=setTimeout(()=>{m()},t)}};return u({status:`loading`}),m(),d},[e,n,r,i]),{state:o?.client===e&&o.tokenKey===n&&o.attempt===i?o.state:{status:`loading`},retry:c}}var d2=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??f2(n,t),a=e.type===bn.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(s2(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function f2(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const p2=dt(void 0);function m2(){let e=_t(p2);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function h2({children:r,loadingIcon:i}){let{t:a}=K(),s=q(),c=s.authToken,{state:l,retry:u}=u2(s.client,c),d=U(()=>{if(c){if(c.permissions)return new d2(c);if(l.status===`ready`)return new d2(c,l.roles)}},[c,l]);if(c&&!d){let r=l.status===`error`,c=r?c2(l.error):void 0,d=c===401,f=c===403,p=a(d?`auth.recovery.credential.title`:f?`shell.accessDenied`:r?`permissions.connectionFailed`:`permissions.connecting`);return t(`div`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-foreground`,children:n(`div`,{className:`w-full max-w-md space-y-6 text-center`,children:[t(`div`,{"aria-hidden":`true`,className:`flex justify-center`,children:i||!r&&t(je,{size:`2xl`,className:`text-info`})}),n(`div`,{role:r?`alert`:`status`,"aria-live":r?`assertive`:`polite`,className:`space-y-2`,children:[t(`h1`,{className:`text-xl font-semibold`,children:p}),t(`p`,{className:`text-muted`,children:d?a(`auth.recovery.credential.body`):f?a(`permissions.accessDenied`):r?a(`permissions.tryAgainLater`):l.status===`retrying`?a(`permissions.retrying`):a(`permissions.loadingPermissions`)})]}),r&&n(e,{children:[t(o,{variant:`outline`,onClick:d||f?()=>s.signOut():u,children:a(d||f?`auth.recovery.useDifferentAccount`:`auth.recovery.tryAgain`)}),l.error!=null&&n(`details`,{className:`text-start text-sm text-muted`,children:[t(`summary`,{className:`cursor-pointer`,children:a(`auth.recovery.technicalDetails`)}),t(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap wrap-break-word`,children:Ge(l.error)})]})]})]})})}return d&&t(p2.Provider,{value:d,children:r})}function g2({permission:e,isDisabled:n,title:r,children:i,...a}){return m2().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function _2({permission:e,...n}){return m2().hasPermission(e)?t(ar,{...n}):null}const v2=new WeakMap;function y2(e,t){let n=v2.get(e);n||(n=new Map,v2.set(e,n));let r=n.get(t);return r||(r=e.types.catalog.resolve(t).then(e=>e??void 0,()=>{v2.get(e)?.delete(t)}),n.set(t,r)),r}function b2(e,t){let n=v2.get(e);n&&(t?n.delete(t):n.clear())}Q();function x2(e){let t=e.configuration?.defaults?.system?.agent??e.configuration?.defaults?.base;return{environment:t?.environment,model:t?.model}}function S2(e){return e.name}function C2(e){return e.name}function w2(e){return e.split(`/`).filter(Boolean).pop()||e}function T2({value:e,onChange:r,disabled:i=!1,isLoading:a=!1}){let{client:s}=q(),{t:c}=K(),[l,u]=G([]),[d,f]=G([]),[p,m]=G(!0),[h,g]=G(!1),_=W(void 0);H(()=>{let e=!1;return m(!0),s.environments.list().then(t=>{e||u(t.slice().sort((e,t)=>e.name.localeCompare(t.name)))}).catch(t=>{console.warn(`Failed to list document editing environments`,t),e||u([])}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s]),H(()=>{if(!e.environment){f([]),g(!1);return}let t=!1,n=e.environment;return g(!0),s.environments.retrieve(n).then(e=>{t||f((e.enabled_models??[]).map(e=>({id:e.id,name:e.name||e.id})).sort((e,t)=>e.name.localeCompare(t.name)))}).catch(e=>{console.warn(`Failed to load document editing models`,e),t||f([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[s,e.environment]);let v=l.find(t=>t.id===e.environment),y=U(()=>{if(e.model)return d.find(t=>t.id===e.model)??{id:e.model,name:w2(e.model)}},[d,e.model]),b=e=>{_.current=e.id,r({environment:e.id}),s.environments.retrieve(e.id).then(t=>{if(_.current!==e.id)return;let n=t.default_model??t.enabled_models?.[0]?.id;r({environment:e.id,model:n})}).catch(e=>{console.warn(`Failed to select a default document editing model`,e)})},x=t=>{_.current=void 0,r({environment:e.environment,model:t.id})},S=y?.name||c(`agent.documentEditingSelectModel`);return n(he,{children:[t(_e,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 max-w-[15rem] gap-1.5 px-2 text-xs`,"aria-label":c(`agent.documentEditingConfiguration`),title:c(`agent.documentEditingConfiguration`),children:[a?t(je,{size:`sm`}):t(Gy,{className:`size-3.5 shrink-0`}),t(`span`,{className:`min-w-0 truncate`,children:S}),t(rh,{className:`size-3.5 shrink-0 opacity-70`})]})}),n(ge,{align:`end`,className:`z-[1000000] w-80 space-y-3 p-3`,children:[n(`div`,{children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:c(`agent.documentEditingConfiguration`)}),t(`div`,{className:`mt-0.5 text-xs leading-4 text-muted`,children:c(i?`agent.documentEditingConfigurationLocked`:`agent.documentEditingConfigurationDescription`)})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-environment`,children:c(`agent.environment`)}),t(we,{id:`document-editing-environment`,by:`id`,options:l,value:v,optionLabel:S2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectEnvironment`),onChange:b,disabled:i,isLoading:p})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-model`,children:c(`agent.model`)}),t(we,{id:`document-editing-model`,by:`id`,options:d,value:y,optionLabel:C2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectModel`),onChange:x,disabled:i||!e.environment,isLoading:h,warnOnMissingValue:!1})]})]})]})}Q();function E2({isLocked:e,onToggleLock:r}){let{t:i}=K(),a=i(e?`agent.editingLockedTitle`:`agent.editingManuallyUnlockedTitle`),s=i(e?`agent.editingLockedDescription`:`agent.editingManuallyUnlockedDescription`),c=i(e?`agent.unlockEditing`:`agent.lockEditing`);return n(`div`,{className:`flex h-8 max-w-64 shrink-0 items-center gap-1 rounded-md border border-mixer-attention/30 bg-mixer-attention/10 ps-2 pe-1 text-attention`,role:e?`status`:`alert`,"aria-live":`polite`,children:[e?t(rv,{className:`size-3.5 shrink-0 animate-pulse`}):t(ov,{className:`size-3.5 shrink-0`}),t(We,{description:s,asChild:!0,children:t(`span`,{className:`min-w-0 truncate text-xs font-medium text-foreground`,children:a})}),t(`span`,{className:`sr-only`,children:s}),t(We,{description:c,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`size-6 shrink-0 rounded p-0 text-attention hover:bg-mixer-attention/15`,onClick:r,"aria-label":c,children:t(e?ov:rv,{className:`size-3.5`})})})]})}const D2=/artifact:(?!agents\/)(?!documents\/)([^\s)\]"]+)/g;function O2(e){let t=new Set;for(let n of e.matchAll(D2))t.add(n[1].replace(/^\/+/,``));return[...t]}async function k2(e,t,n,r){let i=O2(t);if(i.length===0)return{content:t,persisted:[],failed:[]};let a=new Map,o=[],s=[];for(let t of i){let i=`documents/${r}/${t}`;try{await e.copyFile(`agents/${n}/${t}`,i),a.set(t,i),o.push({from:t,to:i})}catch(e){console.warn(`Failed to persist a referenced artifact; keeping a run-scoped link`,{artifact_path:t,error:e instanceof Error?e.message:String(e)}),a.set(t,`agents/${n}/${t}`),s.push(t)}}return{content:t.replace(D2,(e,t)=>{let n=a.get(t.replace(/^\/+/,``));return n?`artifact:${n}`:e}),persisted:o,failed:s}}const A2=[`ask_user`,`think`,`plan`,`update_plan`,`end_conversation`,`learn_artifact_operations`,`learn_code_execution`,`learn_content_authoring`,`learn_document_management`,`learn_document_search`,`learn_image_analysis`,`execute_shell`,`fetch_document`],j2=[`artifact_operations`,`code_execution`],M2=[`update_document`,`update_document_properties`,`create_document`,`set_document_type`,`merge_documents`,`import_file`,`create_or_update_object_type`,`disable_type`,`batch_execute`];function N2(e,t){return[`Direct edits are already saved to '${e}'. Use this compact unified diff as context only;`,`do not re-apply it. The artifact remains the current source of truth.`,"```diff",`--- a/${e}`,`+++ b/${e}`,t,"```"].join(`
|
|
1382
|
+
`)}const P2=`document-editing`,F2=`sys:GeneralAgent`,I2=new Set,L2=new Set([`text/markdown`,`text/x-markdown`]),R2=new Set([...L2,`text/plain`]);function z2(e,t){return`${e}:${t}`}function B2(e){return I2.has(e)}function V2(e,t){t?I2.add(e):I2.delete(e)}function H2(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function U2(e){return`document-root:${e}`}function W2(e){return`document:${e}`}function G2(e,t){return{tags:[P2,U2(t),W2(e)],properties:{resource_kind:`store_document`,document_id:e,document_root_id:t}}}function K2(e,t){return{canEdit:e,canCollaborate:t}}function q2(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function J2(e){let t=q2(e);return t!==void 0&&L2.has(t)}function Y2(e){let t=q2(e);return t!==void 0&&R2.has(t)}function X2(e,t,n,r,i=F2){if(e.interaction!==i||e.started_by!==r||e.status===`cancelled`)return!1;let a=e.tags??[];if(!a.includes(P2))return!1;let o=H2(e.properties);return a.includes(U2(n))?o?.resource_kind===`store_document`&&o.document_root_id===n:a.includes(W2(n))||a.includes(W2(t))}async function Z2(e,t,n,r,i,a){for(let o of t)try{let t=await e.retrieve(o);if(X2(t,n,r,i,a))return t}catch{}}async function Q2(e,t,n,r,i=F2){let a=[U2(n),W2(n),W2(t)],o=new Set;for(let s of new Set(a))try{let a=(await e.search({interaction:i,started_by:r,tags:[s],limit:20,sort:[`updated_at:desc`]})).hits.map(e=>e.id).filter(e=>!o.has(e));for(let e of a)o.add(e);let c=await Z2(e,a,t,n,r,i);if(c)return c}catch{break}return(await e.list({interaction:i,started_by:r,limit:100,sort:`updated_at`,order:`desc`})).items.find(e=>e.run_kind===`agent`&&X2(e,t,n,r,i))}var $2=class extends Error{constructor(e,t){super(e,t===void 0?void 0:{cause:t}),this.name=`DocumentEditingTargetError`}};async function e4(e,t){let n=await e.retrieve(t),r=n;if(n.revision&&!n.revision.head){let i=(await e.getRevisions(n.id)).filter(e=>e.revision?.head===!0);if(i.length!==1)throw new $2(`Expected one head revision for document ${t}, found ${i.length}`);if(r=await e.retrieve(i[0].id),r.revision?.head!==!0)throw new $2(`Resolved document ${r.id} is no longer the current head`)}let i=r.content?.etag;if(!i)throw new $2(`Document ${r.id} has no content ETag`);let a=await e.getObjectText(r.id);if(typeof a.text!=`string`)throw new $2(`Document ${r.id} has no text content`);return{id:r.id,etag:i,content:a.text}}var t4=class extends be{idOf(e){return e.id}labelOf(e){return e.label}descriptionOf(e){return e.description}selectedClassName(e){return`border-3 border-primary`}};function n4({isOpen:e,onClose:r,onConfirm:i,isLoading:a,uploadedFileName:s}){let{t:c}=K(),l=U(()=>[{id:`update`,label:c(`modal.saveVersion.updateCurrent`),description:c(s?`modal.saveVersion.updateWithFileDescription`:`modal.saveVersion.updateDescription`)},{id:`new-version`,label:c(`modal.saveVersion.createNew`),description:c(s?`modal.saveVersion.createWithFileDescription`:`modal.saveVersion.createDescription`)}],[c,s]),u=s?l[1]:l[0],[d,f]=G(u),[p,m]=G(``),h=new t4;H(()=>{e&&(f(u),m(``))},[u,e]);let g=d?.id===`new-version`;return n(se,{isOpen:e,onClose:r,className:`sm:max-w-md`,children:[t(ue,{children:c(`modal.saveChanges`)}),t(ce,{children:n(`div`,{className:`space-y-4`,children:[s&&t(`div`,{className:`mb-4 p-3 bg-info rounded-md`,children:n(`p`,{className:`text-sm text-info font-medium`,children:[c(`modal.saveVersion.replaceFile`),` `,t(`span`,{className:`font-bold`,children:s})]})}),t(`p`,{className:`text-sm text-mixer-muted/5`,children:c(`modal.saveVersion.howToSave`)}),t(ye,{adapter:h,options:l,selected:d,onSelect:e=>{f(e)}}),g&&t(L,{label:c(`modal.saveVersion.versionLabel`),description:c(`modal.saveVersion.versionLabelDescription`),className:`mt-3 ps-8`,children:t(te,{value:p,onChange:m,placeholder:c(`modal.saveVersion.versionLabelPlaceholder`),className:`w-full`})})]})}),n(le,{children:[t(o,{variant:`secondary`,onClick:r,disabled:a,children:c(`modal.cancel`)}),t(o,{variant:`primary`,onClick:async()=>{await i(g,g?p:void 0)},isLoading:a,children:c(`modal.save`)})]})]})}Q();function r4(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function i4(e){return`drafts/${e}.md`}function a4(e,t,n,r,i){return[`You are collaborating with the user on one specific Markdown document in Vertesia.`,`Canonical document: [${e.name||e.content?.name||`Document`}](store:${t})`,`Canonical base revision ID: ${t}`,`Canonical base ETag: ${n??`unavailable`}`,`Working copy artifact: ${r}`,``,`The working copy was hydrated and read before your first turn. It is the source of truth for this editing`,`session. Apply requested changes only to that artifact using edit_artifact. Preserve all unrelated content`,`exactly. User block edits may already be applied to the artifact; acknowledge them and continue from the`,`current artifact generation. Attachments may contain review comments to apply in bulk.`,``,`Do not call update_document, create_document, or write_artifact for this working copy. The user publishes`,`the artifact back to the canonical document with the Save to document button, which enforces the base ETag.`,``,`You may use execute_shell to regenerate charts, diagrams, and other derived assets. Write generated files`,`under '/home/daytona/out/' so they sync back to the run, then reference them from Markdown with a run-local`,`link such as 'artifact:out/chart.png'. Saving the document persists and rewrites those links automatically.`,``,`Images: never inline image data as base64 data URIs — it bloats the document and cannot be reliably edited.`,`Keep existing image references (e.g. 'artifact:documents/…' URLs) exactly as they are: they point to durable`,`storage that outlives this session. Files already in this run's artifact space may be referenced with`,`run-local links like 'artifact:files/photo.png' — publishing copies them into durable storage and rewrites`,`the links automatically.`,``,`User request: ${i}`].join(`
|
|
1383
|
+
`)}function o4(e,t,n){return[`The canonical document was updated outside this session, so publishing the working copy was rejected.`,`1) Fetch the latest canonical revision ${t} with fetch_document into 'drafts/${e}.theirs.md'.`,`2) Compare it with the working copy '${n}' and merge the external changes into the working copy with edit_artifact, preserving this session's edits.`,`3) Reply with a short list of what was merged, plus any conflicting passages and how you resolved them, so I can review before saving again.`].join(`
|
|
1384
|
+
`)}function s4(e,t,n){return[`Summarize the changes in the working copy '${n}' relative to the original document revision ${t}.`,`If you no longer have the original content, fetch it with fetch_document into 'drafts/${e}.base.md'.`,`Do not modify the working copy.`,`Reply with a concise changelog: grouped bullets, most important first, suitable for a revision note.`].join(`
|
|
1385
|
+
`)}function c4(e){if(!(!e||typeof e!=`object`||!(`status`in e)))return typeof e.status==`number`?e.status:void 0}function l4({original:e,workingCopy:r}){let i=U(()=>Vt(e,r),[e,r]),a=U(()=>({added:i.reduce((e,t)=>e+(t.type===`added`?t.text.length:0),0),removed:i.reduce((e,t)=>e+(t.type===`removed`?t.text.length:0),0)}),[i]);return n(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/10`,children:[n(`div`,{className:`flex shrink-0 items-center justify-end gap-3 border-b border-mixer-muted/20 px-5 py-2 text-xs`,children:[n(`span`,{className:`text-destructive`,children:[`−`,a.removed]}),n(`span`,{className:`text-success`,children:[`+`,a.added]})]}),t(`div`,{className:`min-h-0 flex-1 overflow-auto p-5`,children:t(`pre`,{className:`mx-auto max-w-5xl whitespace-pre-wrap break-words rounded-lg border border-mixer-muted/25 bg-background p-5 font-mono text-xs leading-6 shadow-sm`,children:i.map((e,n)=>e.type===`removed`?t(`del`,{className:`bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})})]})}function u4({object:r,initialContent:i=``,onDocumentUpdated:a,onClose:s,sendMessageRef:c,model:l,startImmediately:u=!1}){let{client:d,project:f,store:m,user:h}=q(),{t:g}=K(),_=nt(),v=W(null),y=c??v,[x,S]=G(),[C,w]=G(!1),[T,E]=G(!1),[D,O]=G(!0),[k,A]=G(!0),[j,M]=G(!1),[N,P]=G(0),[F,I]=G(!1),L=JSON.stringify(l?{environment:l.env,model:l.model,model_options:l.options}:{}),ee=l!==void 0,R=U(()=>JSON.parse(L),[L]),[te,ne]=G(!ee),[re,ie]=G(!1),[ae,oe]=G(!1),[se,ce]=G(!1),[le,ue]=G(!1),[de,fe]=G(!1),[pe,me]=G(!1),[he,ge]=G({key:0}),[_e,ve]=G(i),[ye,be]=G(!1),[we,Te]=G(i),[Ee,De]=G(i),[Oe,ke]=G(`document`),[Ae,Me]=G(),[Ne,Pe]=G(r.id),[Fe,Ie]=G(r.content?.etag),[Le,Re]=G(),[ze,Be]=G(R),Ve=W(ee?`host`:`none`),He=W(void 0),Ue=W(new Set),z=W(void 0),Ke=W(!1),qe=W(null),Je=r.revision?.root||r.id,Ye=U(()=>i4(Je),[Je]),Xe=h?.sub?`user:${h.sub}`:void 0,Ze=`${f?.id??`no-project`}:${Je}`,Qe=`${Ze}:${r.type?.id??`no-type`}`,$e=Le?.key===Qe?Le.interaction:void 0,et=W(Ze),tt=W({editingScopeKey:Ze,id:r.id}),rt=W({documentId:r.id,documentRootId:Je}),it=ye&&_e!==Ee,at=le&&!de;rt.current.documentRootId!==Je&&(rt.current={documentId:r.id,documentRootId:Je}),tt.current.editingScopeKey!==Ze&&(tt.current={editingScopeKey:Ze,id:r.id}),H(()=>{et.current!==Ze&&(et.current=Ze,Ve.current=ee?`host`:`none`,Be(R),ne(!ee),Ue.current.clear(),ve(i),Te(i),De(i),be(!1),me(!1),ue(!1),fe(!1),Ke.current=!1,ke(`document`),Pe(r.id),Ie(r.content?.etag))},[Ze,ee,i,r.content?.etag,r.id,R]),H(()=>{let e=!1,t=Ze,n=tt.current.id;return A(!0),M(!1),e4(m.objects,n).then(n=>{e||tt.current.editingScopeKey!==t||(tt.current={editingScopeKey:t,id:n.id},rt.current={documentId:n.id,documentRootId:Je},Pe(n.id),Ie(n.etag),Te(n.content),De(n.content))}).catch(n=>{console.warn(`Failed to resolve the document editing target`,{error:n,attempt:N}),!e&&tt.current.editingScopeKey===t&&M(!0)}).finally(()=>{!e&&tt.current.editingScopeKey===t&&A(!1)}),()=>{e=!0}},[Je,Ze,m.objects,N]),H(()=>{let e=!1,t=r.type?.id;if(!t){Re({key:Qe,interaction:F2});return}return y2(d,t).then(t=>{e||Re({key:Qe,interaction:t?.editing?.interaction?.trim()||`sys:GeneralAgent`})}),()=>{e=!0}},[d,Qe,r.type?.id]),H(()=>{x||Ve.current===`run`||(ee?(Ve.current=`host`,Be(R),ne(!1)):Ve.current===`host`&&(Ve.current=`none`,Be({})))},[x,ee,R]),H(()=>{if(ee){ne(!1);return}if(!f){ne(!1);return}let e=!1,t=Ze;return ne(!0),d.projects.retrieve(f.id).then(n=>{e||et.current!==t||Ve.current!==`none`||(Ve.current=`project`,Be(x2(n)))}).catch(e=>{console.warn(`Failed to load the default document editing model`,e)}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[d,Ze,ee,f]),H(()=>{if(S(void 0),!Xe||!$e){O(!1);return}let e=!1;return O(!0),Q2(d.agents,rt.current.documentId,Je,Xe,$e).then(t=>{e||!t||(S(t.id),t.config?.environment&&t.config.model&&(Ve.current=`run`,Be({environment:t.config.environment,model:t.config.model,model_options:t.config.model_options})))}).catch(e=>{console.warn(`Failed to look up an existing document editing run`,e)}).finally(()=>{e||O(!1)}),()=>{e=!0}},[d,Je,$e,Xe]);let B=V(e=>{Ve.current=`user`,Be(e)},[]),ot=V(()=>{x&&navigator.clipboard.writeText(x).then(()=>_({status:`success`,title:g(`agent.runIdCopied`),duration:2e3})).catch(e=>console.warn(`Failed to copy the agent run id`,e))},[x,g,_]),st=V(async()=>{if(!(!x||T)){E(!0);try{await d.agents.terminate(x,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3})}catch(e){console.warn(`Failed to terminate the document editing run`,e)}finally{E(!1)}Ue.current.clear(),S(void 0),be(!1),ve(Ee),me(!1),Ke.current=!1,ue(!1),fe(!1)}},[x,d.agents,T,Ee,g,_]),ct=V(async(e,t)=>{if(!(!f||!$e||D||k||j||C||te)){w(!0);try{if(!ze.environment||!ze.model){_({status:`error`,title:g(`agent.documentEditingDefaultsRequired`),duration:5e3});return}let n=a4(r,Ne,Fe,Ye,e?.trim()||g(`agent.documentEditingInitialRequest`)),i=G2(Ne,Je),a={interaction:$e,interactive:!0,tool_approval_mode:t?.tool_approval_mode,tool_names:A2,excluded_tools:M2,initial_skills:j2,initial_tool_calls:[{id:`hydrate-working-copy`,tool:`fetch_document`,input:{id:Ne,mode:`content`,output_artifact:{path:Ye}}},{id:`read-working-copy`,tool:`read_artifact`,input:{path:Ye}}],data:{user_prompt:n},config:{environment:ze.environment,model:ze.model,model_options:ze.model_options},started_by:Xe,tags:i.tags,properties:i.properties},o=await d.agents.start(a);return S(o.id),{agent_run_id:o.id}}catch(e){console.error(`Failed to start document editing agent`,e),_({status:`error`,title:g(`agent.documentEditingStartFailed`),description:e instanceof Error?e.message:void 0,duration:5e3});return}finally{w(!1)}}},[d.agents,Je,Ye,ze,$e,te,D,k,C,r,f,Xe,g,Ne,Fe,j,_]),lt=V((e,t)=>{z.current=t,ve(e),be(!0)},[]);H(()=>{if(!u||x||!f||!$e||D||k||j||C||te||!ze.environment||!ze.model)return;let e=JSON.stringify({scope:Ze,interaction:$e,document:Ne,configuration:ze});He.current!==e&&(He.current=e,ct(g(`agent.documentEditingStartRequest`),{tool_approval_mode:`full_control`}))},[x,$e,Ze,ze,te,D,k,C,f,u,ct,g,Ne,j]);let ut=V(e=>{let t=Ke.current;Ke.current=e,ue(e),e||(fe(!1),t&&ge(e=>({key:e.key+1})))},[]),dt=V((e,t)=>{let n=y.current;if(!n){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}n(e,t)},[y,g,_]),ft=V(e=>{let t=e.anchor.block_type.replaceAll(`_`,` `),n=e.comment?.trim()||g(`agent.editedSelectionMessage`,{blockType:t});dt(n,{editing_action:e})},[dt,g]),pt=V(async(e,t)=>{if(!(!ye||!Fe||!it||at||re||k||j)){ie(!0);try{let n=_e;x&&(n=(await k2(d.files,n,x,crypto.randomUUID())).content);let i=r.content?.type||`text/markdown`,o=r.content?.name||`content.md`,s=new File([new Blob([n],{type:i})],o,{type:i}),c=await m.objects.update(Ne,{content:s},{createRevision:e,revisionLabel:t,ifMatch:Fe});if(Pe(c.id),Ie(c.content?.etag),De(n),Me(void 0),oe(!1),a?.(c.id,e),_({status:`success`,title:g(`store.textSaved`),duration:2500}),x&&n!==_e&&z.current)try{await d.agents.updateArtifactContent(x,Ye,{content:n,generation:z.current}),ge(e=>({key:e.key+1}))}catch(e){console.warn(`Failed to sync persisted artifact links into the working copy`,e)}}catch(e){let t=c4(e),n=t===412;if(t===412||t===400)try{let e=await e4(m.objects,Ne);(e.id!==Ne||t===412)&&(n=!0,Pe(e.id),Ie(e.etag),Me({headId:e.id}))}catch(e){console.warn(`Failed to resolve the new head after a save conflict`,e)}_({status:`error`,title:g(`store.errorSavingText`),description:n?g(`store.textConflict`):Ge(e,g(`store.errorSavingTextDefault`)),duration:5e3})}finally{ie(!1)}}},[x,_e,ye,d.agents,d.files,Ye,it,at,k,re,r.content?.name,r.content?.type,a,m.objects,g,Ne,Fe,j,_]),mt=V(()=>{let e=y.current;if(!e||!Ae){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(o4(Je,Ae.headId,Ye)),Me(void 0),ke(`document`)},[Je,Ye,y,Ae,g,_]),ht=V(()=>{let e=y.current;if(!e){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(s4(Je,tt.current.id,Ye))},[Je,Ye,y,g,_]),gt=V(async()=>Oe!==`editor`||!pe||!!await qe.current?.(),[pe,Oe]),_t=V(async e=>{e!==Oe&&await gt()&&ke(e)},[gt,Oe]),vt=V(async()=>{await gt()&&s?.()},[gt,s]),yt=V(async()=>{let e=y.current;if(!e||!x||at||se){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}ce(!0);try{let t=await qe.current?.();if(!t)return;let n=Bt(t.previous,t.current,{context:1});n&&e(N2(Ye,n)),me(!1),_({status:`success`,title:g(`agent.changesSentToAgent`),duration:2e3})}finally{ce(!1)}},[x,Ye,at,se,y,g,_]);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex h-14 shrink-0 items-center justify-between gap-3 border-b border-mixer-muted/20 px-4`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate font-semibold`,children:r.name||r.content?.name}),n(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[n(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[it?t(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-attention`}):ye?t(eh,{className:`size-3 text-success`}):null,g(it?`store.unsavedChanges`:`store.textSaved`)]}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.workingCopy`)}: ${Ye}`,asChild:!0,children:n(`span`,{className:`min-w-0 truncate font-mono`,children:[`drafts/`,r4(Je),`.md`]})}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.originalDocument`)}: ${tt.current.id}`,asChild:!0,children:n(`span`,{className:`shrink-0 font-mono`,children:[g(`agent.originalDocument`).toLowerCase(),` `,r4(tt.current.id)]})})]})]}),n(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[n(`div`,{className:`flex items-center rounded-md border border-mixer-muted/25 bg-muted/10 p-0.5`,children:[n(o,{variant:Oe===`document`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`document`),children:[t(Gg,{className:`size-3.5`}),g(`agent.document`)]}),n(o,{variant:Oe===`editor`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`editor`),children:[t(zg,{className:`size-3.5`}),g(`agent.fullEditor`)]}),n(o,{variant:Oe===`diff`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`diff`),disabled:!ye||_e===we,children:[t(h_,{className:`size-3.5`}),g(`agent.reviewChanges`)]})]}),Oe===`diff`?n(o,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5`,onClick:ht,disabled:!ye||_e===we,children:[t(Z_,{className:`size-3.5`}),g(`agent.summarizeChanges`)]}):null,t(We,{description:g(`agent.refresh`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>ge(e=>({key:e.key+1})),disabled:!x,"aria-label":g(`agent.refresh`),children:t(hy,{className:`size-4`})})}),t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),t(T2,{value:ze,onChange:B,disabled:!!x||C||D,isLoading:te}),x?null:n(o,{variant:`primary`,size:`sm`,className:`h-8 gap-1.5`,onClick:()=>void ct(g(`agent.documentEditingStartRequest`)),disabled:C||D||k||te||j||!f||!$e||!ze.environment||!ze.model,children:[C?t(je,{size:`sm`}):t(Jy,{className:`size-4`}),g(C?`agent.startingAgent`:`agent.documentEditingStart`)]}),x?n(e,{children:[t(We,{description:x,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`font-mono text-[11px] text-muted`,onClick:ot,"aria-label":g(`agent.copyRunId`),children:r4(x)})}),t(We,{description:g(`agent.startNewConversation`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>{it?I(!0):st()},disabled:T,"aria-label":g(`agent.startNewConversation`),children:t(vy,{className:`size-4`})})})]}):null,t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),n(o,{variant:`primary`,className:`min-w-36 gap-2`,onClick:()=>oe(!0),disabled:!it||!Fe||at||re||k||j,children:[re?t(je,{size:`sm`}):t(wy,{className:`size-4`}),g(`agent.saveToDocument`)]}),s?t(o,{variant:`ghost`,size:`sm`,onClick:()=>void vt(),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})}):null]})]}),Ae?n(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-mixer-attention/30 bg-mixer-attention/10 px-4 py-2 text-sm`,children:[t(`span`,{className:`min-w-0 truncate text-attention`,children:g(`agent.saveConflictNotice`)}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t(o,{variant:`outline`,size:`sm`,onClick:mt,children:g(`agent.askAgentToReconcile`)}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>Me(void 0),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})})]})]}):null,n(Ce,{direction:`horizontal`,className:`min-h-0 flex-1`,children:[t(Se,{defaultSize:65,minSize:35,className:`min-w-0 bg-background`,children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:t(`div`,{className:`min-h-0 flex-1`,children:Oe===`diff`?t(l4,{original:we,workingCopy:_e}):t(wt,{runId:x,path:Ye,viewMode:Oe===`editor`?`document`:`components`,baselineContent:we,initialContent:Ee,refreshKey:he.key,refreshDetails:he.details,readOnly:at,allowComments:!!x,onContentChange:lt,onAction:ft,onSendMessage:dt,onSendChangesToAgent:yt,hasUnsentChanges:it&&pe,isSendingChanges:se,sendChangesDisabled:!x||at,toolbarStatus:le?t(E2,{isLocked:at,onToggleLock:()=>fe(e=>!e)}):void 0,onDocumentEdit:()=>me(!0),flushChangesRef:qe})})})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:35,minSize:25,className:`min-w-[320px]`,children:D||k?t(p,{className:`h-full`,children:t(je,{size:`lg`})}):j?n(p,{className:`h-full flex-col gap-3 px-6 text-center`,children:[t(`div`,{className:`text-sm text-muted`,children:g(`agent.failedToLoadDocument`)}),t(o,{variant:`outline`,size:`sm`,onClick:()=>P(e=>e+1),children:g(`agent.retry`)})]}):t(K1,{agentRunId:x,startWorkflow:ct,resetWorkflow:()=>S(void 0),onRestart:e=>S(e.id),sendMessageRef:y,onMessage:e=>{let t=e.details;if(!Ut(t,Ye))return;let n=`${e.timestamp}:${t?.path}:${t?.generation??``}`;Ue.current.has(n)||(Ue.current.add(n),ge(e=>({key:e.key+1,details:t})))},onAgentWorkingChange:ut,title:g(`agent.documentEditing`),initialMessage:g(`agent.documentEditingWelcome`),startButtonText:g(C?`agent.startingAgent`:`agent.startAgent`),placeholder:g(`agent.documentEditingPlaceholder`),initialToolApprovalMode:`full_control`,hideObjectLinking:!0,hideHeader:!0,showRightPanel:!1,fullWidth:!0,interactive:!0})})]}),t(b,{isOpen:F,title:g(`agent.newSessionDiscardTitle`),content:g(`agent.newSessionDiscardDescription`),onConfirm:()=>{I(!1),st()},onCancel:()=>I(!1)}),t(n4,{isOpen:ae,onClose:()=>oe(!1),onConfirm:pt,isLoading:re})]})}function d4({object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s}){let{t:c}=K();return t(se,{isOpen:!0,onClose:r,size:`full`,noCloseButton:!0,disableCloseOnClickOutside:!0,className:`gap-0 overflow-hidden p-0`,description:c(`agent.documentEditingWelcome`),children:t(u4,{object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s})})}function f4({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=q(),u=nt(),{t:d}=K(),{theme:f}=tt(),p=Qn(),[m,h]=G(!1),[g,_]=G(``),[v,y]=G(!1),[b,x]=G(null),S=W(void 0),[C,w]=G(null),[T,E]=G(null),D=V(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);H(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:Ge(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(se,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(ue,{children:d(`store.editProperties`)}),n(ce,{children:[n(`div`,{className:`mb-2 text-sm text-muted`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-success`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(Pt,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(le,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(n4,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}const p4=ht(()=>import(`@vertesia/ui/rich-text`).then(e=>({default:e.VertesiaMarkdownDocumentEditor})));function m4(e){switch(e){case`text/markdown`:case`text/x-markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function h4({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=q(),l=nt(),{t:u}=K(),{theme:d}=tt(),f=Qn(),p=W(void 0),[m,h]=G(i),[g,_]=G(!1),[v,y]=G(!1),[b,x]=G(!1),S=m4(r.content?.type),C=J2(r.content?.type);H(()=>{h(i),_(!1)},[i]);let w=V(()=>{g||_(!0)},[g]),T=V(e=>{h(e),_(e!==i)},[i]);function E(){!C&&!p.current||x(!0)}async function D(e,t){if(!C&&!p.current)return;let n=C?m:p.current?.getValue();if(n===void 0)return;let i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{y(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),x(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=Ge(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{y(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[g&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:v,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:E,disabled:!g,isLoading:v,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:C?t(ut,{fallback:t(`div`,{className:`h-full w-full`}),children:t(p4,{value:m,onChange:T})}):t(Pt,{value:i,language:S,editorRef:p,onChange:w,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(n4,{isOpen:b,onClose:()=>x(!1),onConfirm:D,isLoading:v})]})}const g4=131072;function _4(e,t,n=!1,r=e){let{store:i}=q(),[a,o]=G(t),[s,c]=G(()=>t&&t.length>g4?t.substring(0,g4):t),[l,u]=G(!1),[d,f]=G(()=>!!t&&t.length>g4),[p,m]=G(),h=W(t),g=W(e),_=W(r),v=W(!1),y=V((e,t=!0)=>{let n=h.current;t&&n&&e&&n!==e?m(e=>({previousText:n,version:(e?.version??0)+1})):t||m(void 0),h.current=e,o(e),e&&e.length>g4?(c(e.substring(0,g4)),f(!0)):(c(e),f(!1))},[]),b=V(()=>{let t=e,n=r;u(!0),i.objects.getObjectText(e).then(e=>{if(g.current!==t)return;let r=_.current===n&&!v.current;y(e.text,r),v.current=!1}).catch(e=>{console.error(`Failed to load text`,e)}).finally(()=>{g.current===t&&u(!1)})},[y,r,e,i]);return bt(()=>{let i=g.current!==e,a=_.current!==r;g.current=e,_.current=r,a&&(v.current=!0),t!==void 0&&(y(t,!a),v.current=!1),n&&t===void 0&&(i||h.current===void 0)&&b()},[y,r,t,n,b,e]),{fullText:a,displayText:s,isLoading:l,isCropped:d,changeHighlight:p,loadText:b}}function v4(e,t){let{client:n}=q(),[r,i]=G({isComplete:!1});return H(()=>{if(!t)return;let r=!1,a,o=(e,t,n)=>{i(r=>{let i=JSON.stringify(r.progress??null),a=JSON.stringify(e??null);return r.status===t&&r.isComplete===n&&i===a?r:{progress:e,status:t,isComplete:n}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{e.status===Tn.RUNNING?(o(e.progress,e.status,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,isComplete:r.isComplete}}function y4(e,t){let{client:n}=q(),r=Xt.getFixedT(null,Yt),[i,a]=G(),[o,s]=G(!1),[c,l]=G();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:V(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:gn.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}Q(),QY();const b4=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(Zn,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function x4(e){return e===dn.created||e===dn.processing}function S4(e){return e.metadata?.content_processor?.type}function C4(e){return e?e.includes(`
|
|
1386
1386
|
# `)||e.includes(`
|
|
1387
1387
|
## `)||e.includes(`
|
|
1388
1388
|
### `)||e.includes(`
|
|
1389
1389
|
* `)||e.includes(`
|
|
1390
1390
|
- `)||e.includes(`
|
|
1391
|
-
+ `)||e.includes(`:!1}function y4(e){return e?`h-full overflow-auto`:`hidden`}var b4;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(b4||={});function x4({object:r,loadText:i,refetch:a,canEditProperties:o=!0,canCollaborate:s=!1}){let c=nt(),{t:l}=K(),{project:u,store:d}=q(),f=Qn(),p=r.revision?.root||r.id,m=u?.id?P2(u.id,p):void 0,[h,g]=G(r),[_,v]=G(()=>m?F2(m):!1),y=W(null),b=W(r.id),x=W(r.id),S=W(m);H(()=>{S.current!==m&&(S.current=m,v(m?F2(m):!1))},[m]);let C=V(()=>{v(e=>{let t=!e;return m&&I2(m,t),t})},[m]),w=V(()=>{m&&I2(m,!1),v(!1)},[m]);H(()=>{let e=x.current!==r.id;x.current=r.id,g(t=>!e&&t.id!==r.id?t:(b.current=r.id,t.id===r.id&&t.text&&!r.text?{...r,text:t.text}:r))},[r]);let T=V(async(e,t)=>{b.current=e;try{let[t,n]=await Promise.all([d.objects.retrieve(e),d.objects.getObjectText(e)]);b.current===e&&g({...t,text:n.text})}catch(e){console.error(`Failed to load the updated document revision`,e),c({status:`error`,title:l(`agent.failedToLoadDocument`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{t&&f(`/objects/${e}`)}},[f,d.objects,l,c]),E=async(e,t)=>{try{await navigator.clipboard.writeText(e),c({status:`success`,title:l(`store.contentCopied`,{type:l(t===`text`?`store.contentType`:`store.properties`)}),description:l(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),c({status:`error`,title:l(`store.copyFailed`),description:l(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(e,{children:[n(Ce,{direction:`horizontal`,className:`h-full`,children:[t(Se,{defaultSize:67,className:`min-w-[100px]`,children:t(C4,{object:h,loadText:i??!1,handleCopyContent:E,refetch:a,canCollaborate:s,isCollaborating:_,onToggleCollaborate:C})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:33,className:`min-w-[100px]`,children:t(S4,{object:h,refetch:a??(()=>Promise.resolve()),handleCopyContent:E,canEditProperties:o})})]}),_?t(o4,{object:h,initialContent:h.text??``,onClose:w,onDocumentUpdated:(e,t)=>void T(e,t),sendMessageRef:y}):null]})}function S4({object:r,refetch:i,handleCopyContent:a,canEditProperties:s}){let{t:c}=K(),[l,u]=G(!1),[d,f]=G(!1);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${l?`ghost`:`primary`}`,size:`sm`,title:c(`store.previewProperties`),onClick:()=>u(!l),children:`Properties`}),t(o,{variant:`${l?`primary`:`ghost`}`,size:`sm`,title:c(`store.viewInJsonFormat`),onClick:()=>u(!l),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>a(JSON.stringify(r.properties,null,2),`properties`),children:t(fg,{className:`size-4`})}),s&&t(d2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:()=>{f(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(Zy,{className:`size-4`})})]})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(jt,{value:r.properties,viewCode:l})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:c(`store.noPropertiesDefined`)})})]}),t(s4,{isOpen:d,onClose:()=>{f(!1)},object:r,refetch:i})]})}function C4(e){let{client:n}=q(),r=e.object.type,i=r?.id,a=r?.default_view,{data:o}=Ye(async()=>!i||a?null:(await m2(n,i))?.intake?.default_view??null,[i,a]),s=a??o;return i&&!a&&o===void 0?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(w4,{...e,defaultView:s??void 0})}function w4({object:e,loadText:r,handleCopyContent:i,refetch:a,defaultView:s,canCollaborate:c,isCollaborating:l,onToggleCollaborate:u}){let{client:d}=q(),{t:f}=K(),p=e?.metadata?.type===un.Image,m=e?.metadata?.type===un.Video,h=e?.metadata?.type===un.Audio,g=e?.content?.type===`application/pdf`,_=e?.content?.type?m$(e.content.type):!1,v=g4(e?.status),y=!!(e.transcript&&(m||h)),b=e.metadata?.renditions?.find(e=>e.name===_n),x=()=>{switch(s){case`text`:return b4.Text;case`pdf`:if(g||_||b)return b4.Pdf;break;case`image`:if(p)return b4.Image;break;case`properties`:return b4.Text}return m?b4.Video:h?b4.Audio:p?b4.Image:b4.Text},S=m0(e.id),[C,w]=G(x()),[T,E]=G(C===b4.Pdf);H(()=>{C===b4.Pdf&&E(!0)},[C]);let[D,O]=G(!1),k=V2(!!(e.content?.type&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),c),{fullText:A,displayText:j,isLoading:M,isCropped:N,loadText:P}=f4(e.id,e.text,r,e.revision?.root||e.id),F=(g||_)&&v&&(C===b4.Text||C===b4.Pdf),{progress:I,status:L,isComplete:ee}=p4(e.id,F),{pdfUrl:R,isConverting:te,error:ne,triggerConversion:re}=m4(e.id,_),ie=U(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>_||(e?m$(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await d.objects.getRendition(e.id,{format:gn.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[d,_,e.id,e.name]);H(()=>{ee&&L===Tn.COMPLETED&&P()},[ee,L,P]);let ae=(g||_)&&v&&!ee&&L===Tn.RUNNING,oe=C===b4.Pdf&&!ae,se=ae&&(C===b4.Text||C===b4.Pdf),ce=T&&!ae,le=W(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[p&&t(o,{variant:C===b4.Image?`primary`:`ghost`,size:`sm`,title:f(`store.viewImage`),onClick:()=>w(b4.Image),children:`Image`}),m&&t(o,{variant:C===b4.Video?`primary`:`ghost`,size:`sm`,title:f(`store.viewVideo`),onClick:()=>w(b4.Video),children:`Video`}),h&&t(o,{variant:C===b4.Audio?`primary`:`ghost`,size:`sm`,title:f(`store.viewAudio`),onClick:()=>w(b4.Audio),children:`Audio`}),y&&t(o,{variant:C===b4.Transcript?`primary`:`ghost`,size:`sm`,title:f(`store.viewTranscript`),onClick:()=>w(b4.Transcript),children:`Transcript`}),t(o,{variant:C===b4.Text?`primary`:`ghost`,size:`sm`,title:f(`store.viewText`),onClick:()=>w(b4.Text),children:`Text`}),g&&t(o,{variant:C===b4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewPdf`),onClick:()=>w(b4.Pdf),children:`PDF`}),_&&t(o,{variant:C===b4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewAsPdf`),onClick:()=>{w(b4.Pdf),!b&&!R&&!te&&re()},disabled:te,children:te?t(je,{size:`sm`}):`PDF`})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(O4,{object:e}),t(k4,{objectId:e.id,available:S})]})]}),C===b4.Text&&!ae&&!D&&t(T4,{object:e,text:j,fullText:A,handleCopyContent:i,textContainerRef:le,isEditing:D,onToggleEdit:()=>O(!0),canEdit:k.canEdit,isCollaborating:l,onToggleCollaborate:u,canCollaborate:k.canCollaborate}),C===b4.Pdf&&_&&(b||R)&&t(A4,{object:e,pdfRendition:b,officePdfUrl:R})]}),C===b4.Image&&t(`div`,{className:y4(!0),children:t(Z0,{object:e})}),C===b4.Video&&t(`div`,{className:y4(!0),children:t(Q0,{object:e})}),C===b4.Audio&&t(`div`,{className:y4(!0),children:t(X0,{object:e})}),y&&C===b4.Transcript&&t(`div`,{className:y4(!0),children:t(D4,{object:e,handleCopyContent:i})}),g&&ce&&t(`div`,{className:y4(oe),children:t(j4,{object:e})}),_&&ce&&t(`div`,{className:y4(oe),children:t(M4,{object:e,pdfRendition:b,officePdfUrl:R,converters:ie,officePdfConverting:te,officePdfError:ne})}),se&&t(`div`,{className:y4(!0),children:t(N4,{progress:I,status:L})}),C===b4.Text&&!ae&&!D&&M&&!j&&t(`div`,{className:y4(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(je,{size:`lg`})})}),C===b4.Text&&!ae&&!D&&(!M||j)&&t(`div`,{className:y4(!0),children:t(E4,{object:e,text:j,isTextCropped:N,textContainerRef:le})}),D&&C===b4.Text&&A!=null&&t(u4,{object:e,text:A,onClose:()=>O(!1),onSaved:()=>{O(!1),P(),a?.()}})]})}function T4({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l,isCollaborating:u,onToggleCollaborate:d,canCollaborate:f}){let{client:p,project:m}=q(),h=nt(),{t:g}=K(),_=r.content,{renderDocument:v,isDownloading:y}=nG({client:p,toast:h}),{data:b}=Ye(()=>m?p.projects.retrieve(m.id):Promise.resolve(void 0),[m?.id]),x=b?.configuration?.pdf_template_object_id??void 0,S=U2(_?.type),C=W2(_?.type),T=async(e,t)=>{if(y)return;h({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:g(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:x;await v(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(fg,{className:`size-4`})}),y?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(je,{size:`sm`})}):n(w,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(xg,{className:`size-4`})}),children:[a&&t(ae,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;_?.type===`application/xml`||_?.type===`text/xml`?(t=`xml`,n=`text/xml`):S&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Download Text`]})}),S&&i&&n(e,{children:[t(ae,{onClick:()=>T(gn.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as DOCX`]})}),t(ae,{onClick:()=>T(gn.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as PDF`]})}),t(ae,{onClick:()=>T(gn.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as Branded PDF`]})})]})]}),a&&n(e,{children:[l&&c&&t(d2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:c,title:g(`store.editText`),"aria-label":g(`store.editText`),className:`h-8 w-8 p-0`,children:t(Zy,{className:`size-4`})}),f&&d&&C&&t(o,{variant:u?`primary`:`ghost`,size:`sm`,onClick:d,title:g(`agent.editWithAI`),"aria-label":g(`agent.editWithAI`),className:`h-8 w-8 p-0`,children:t(Jy,{className:`size-4`})})]})]})})}const E4=gt(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=K(),c=g4(r?.status),l=r.content,u=_4(r)===`xml`||l?.type===`application/xml`||l?.type===`text/xml`,d=W2(l?.type),f=!u&&(d||v4(i)),p={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:u?`text/xml`:f?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(vb,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(XY,{source:p,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:h4()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function D4({object:e,handleCopyContent:r}){let{t:i}=K(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(fg,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function O4({object:r}){let[i,a]=G(!1);return _4(r)===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(Hg,{className:`size-4`})}),i&&t(ve,{children:t(W0,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function k4({objectId:r,available:i}){let{t:a}=K(),[s,c]=G(!1);return i?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),title:a(`grounded.title`),"aria-label":a(`grounded.title`),children:t(Dy,{className:`size-4`})}),s&&t(ve,{children:t(_0,{objectId:r,onClose:()=>c(!1)})})]}):null}function A4({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=q(),a=nt(),{t:s}=K(),[c,l]=G(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(je,{size:`sm`}):t(xg,{className:`size-4`})})})}function j4({object:e}){let n={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`,showHeader:!1})})}function M4({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=K();if(o)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(je,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]});if(s)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(vb,{className:`size-8`}),t(`span`,{children:s})]});if(r?.content?.source){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`})})}if(i){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`})})}let l={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(XY,{source:l,converters:a,className:`h-full`})})}function N4({progress:r,status:i}){let{t:a}=K(),o=x$(i),s=S$(i),c=r?.phase===`grounded_extraction`,l=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(P4,{name:c?`Prepare Evidence`:`Analyze Page`,progress:r.pages}),c&&n(e,{children:[t(P4,{name:`Run OCR`,progress:r.images}),t(P4,{name:`Extract Grounded Data`,progress:r.tables}),t(P4,{name:`Review and Annotate`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,l,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:o,children:s}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(Ft,{percent:l})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(je,{size:`sm`}),t(`span`,{children:a(`store.loadingProcessingStatus`)})]})]})}function P4({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}Q();const F4=Object.values(xn),I4=Object.values(Cn);function L4({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=q(),{t:l}=K(),u=nt(),[d,f]=G(void 0),[p,h]=G(void 0),g=!!c&&(!!p?.embeddings.text||!!p?.embeddings.image),[_,v]=G(void 0),y=W(i),b=W(void 0),[x,S]=G(!1),[C,w]=G(a||F4),[T,E]=G(100);H(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===xn.full_text?O=!0:k=!0,I4.includes(e)&&(D[e]=!0)}),H(()=>{y.current!==i&&(y.current=i,f(void 0),v(void 0))}),H(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),H(()=>{_&&u({title:_,status:`success`,duration:2e3})},[_,u]),H(()=>{let t=b.current;b.current=d,t&&(!d||d.length===0)&&e(void 0)},[e,d]);let A=()=>{!g||!d||(e({vector:k?{text:d,config:D}:void 0,full_text:O?d:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(te,{placeholder:l(`store.searchPlaceholder`),value:d,onChange:f,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),title:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(Iy,{size:18})}),n(se,{isOpen:x,onClose:()=>S(!1),children:[t(ue,{children:l(`store.searchTypes`)}),t(ce,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-full_text`,checked:C.includes(xn.full_text),onCheckedChange:M(xn.full_text)}),t(re,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),I4.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(re,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(de,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(le,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,title:l(`store.semanticSearch`),children:l(`store.search`)})]})}Q();const R4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function z4(e,t){return(t?e.getTypeLayout(t):R4)??R4}function B4({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=z$(),a=nt(),{t:o}=K(),s=Y$(V(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a])),c=V((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]);return t(V4,{layout:n,onUpload:c,toolbarActions:r})}function V4({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=K(),c=z$(),[l,u]=G(!1),[d,f]=G(null),{registry:p}=nQ(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=V$(),[y,b]=G(p?e||z4(p,m.query.type):R4);H(()=>{e&&b(e)},[e]);let[x,S]=G(0),[C,w]=G(0),[T,E]=G(localStorage.getItem(i1.LAST_DISPLAYED_VIEW)===`grid`),[D,O]=G([]),k=W(null),A=W(null),j=V((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);H(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),H(()=>{_.length<C&&w(_.length)},[_.length,C]),Qe(k,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}j(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),j(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,j(m.search(),`Search reset failed:`))},P=B$(),F=z$(),I=()=>{j(m.search(),`Search refresh failed:`)},L=mQ(P),ee=hQ(F),R=e=>{let t=typeof e==`function`?e(D):e;O(t),ee(t)},te=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};R(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},ne=new URL(window.location.href),re=ne.searchParams.get(`filters`);if(re)try{let e=re.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?ne.searchParams.set(`filters`,e):ne.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,ne.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let ie=Qn();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(U4,{object:d,onClose:()=>f(null)}),g&&t(M,{title:s(`store.error`),children:g.message}),t(H4,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:R,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:A,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(t$,{onFilter:te,children:t(Z$,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{ie(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:k,className:`w-full flex justify-center`,children:t(je,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function H4(e){let{t:r}=K(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(I,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(L4,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(P,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(N,{}),t(F,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(L4,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(o,{variant:`outline`,onClick:p,title:r(`store.refresh`),children:t(hy,{size:16})}),t(i1,{onUpdate:m})]})]})}function U4({object:e,onClose:r}){let{store:i}=q(),a=nt(),s=Qn(),{downloadFromContentSource:c}=nG({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(Oe,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Dg,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,tG(e)),children:t(xg,{className:`size-4`})})]}),t(C,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(x4,{object:e,loadText:!0},e.id)})]}):null}const W4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function G4({collection:e}){let n=nt(),{client:r}=q(),{registry:i}=nQ(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=K4(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(V4,{layout:o}):t(B4,{onUploadDone:a,layout:o})})}function K4(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(En(e.type))),n&&n.length>0)?n:W4}function q4({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=K(),{registry:c}=nQ(),[l,u]=G(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=G(),[m,h]=G([]);return H(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function J4({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=Qn(),c=nt(),{t:l}=K(),[u,d]=G(!1),{client:f}=q(),[p,m]=G({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(ce,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(L,{label:l(`type.name`),required:!0,children:t(te,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(L,{label:l(`type.description`),className:`mt-2`,children:t(Ue,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(L,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Ne,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(L,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(q4,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(L,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(q4,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(le,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function Y4({isOpen:e,onClose:r}){let{t:i}=K();return n(se,{onClose:r,isOpen:e,children:[t(ue,{children:i(`store.createACollection`)}),t(J4,{onClose:r})]})}Q();function X4(){let{client:r}=q(),i=nt(),{t:a}=K(),[s,c]=G(),[l,u]=G(!0),[d,f]=G(!1),{data:p,error:m,refetch:h}=Ye(()=>r.store.collections.search({}),[]);return H(()=>{(p||m)&&u(!1)},[p,m]),m?t(M,{title:a(`store.collectionFetchFailed`),children:Ge(m)}):n(e,{children:[p&&(p.length>0?n(Le,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(Pe,{columns:4,isLoading:l,children:p.map(e=>n(Ie,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(Z4,{isDynamic:e.dynamic}),t(Zn,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:WD(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(hb,{className:`size-4`})})})]},e.id))})]}):t(j,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(Y4,{isOpen:d,onClose:()=>f(!1)}),t(b,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:Ge(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function Z4({isDynamic:e}){let{t:n}=K(),r=n(e?`store.dynamicCollection`:`store.staticCollection`),i=t(e?Ay:e_,{className:`size-5`});return t(We,{description:r,className:`me-2`,children:i})}Q();const Q4=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function $4({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=K(),d=Qn(),f=!!s;return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(Pe,{isLoading:r&&(!e||e.length===0),columns:f?5:4,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:it(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(x,{content:e.id,className:Q4}),i&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${e.name}`,className:Q4,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(l_,{className:`size-3`})})]})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(We,{description:WD(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:WD(e.updated_at).fromNow()})})]},e.id))})]})}function e3({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=K(),u=nt(),[d,f]=G(s?.name),[p,m]=G(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(se,{isOpen:r,onClose:()=>i(),children:[t(ue,{children:e}),t(ce,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(te,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(Ue,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(le,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var t3=class{client;limit;result=new De({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const n3=dt(void 0);function r3(){return _t(n3)}function i3(){let e=r3();return{...rt(e.result),search:e}}function a3(){return r3().objects.length}Q();var o3;(function(e){e.true=`Yes`,e.false=`No`})(o3||={});function s3({isDirty:r=!1}){let{store:i}=q(),{reload:a}=nQ(),{t:s}=K(),c=nt(),[l,u]=G(!1),{search:d,isLoading:f,error:p,objects:m}=i3(),[h,g]=G([]),[_,v]=G(!1),[y,x]=G(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{g(e&&m?m.map(e=>e.id):[])},D=async()=>{if(!y){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;v(!1),g([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[O,k]=G(``),A=Je(O,500),N=W(null);Qe(N,()=>{l&&d.loadMore()},{deps:[l,d]}),H(()=>{d.search().then(()=>u(!0))},[d]),H(()=>{d.query.name=A,d.search().then(()=>u(!0))},[A,d]);let[P,F]=G(void 0),I=e=>{F(e)};H(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),H(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[L,ee]=G(!1);return p?t(M,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(te,{placeholder:s(`store.filterByName`),value:O,onChange:k}),t(we,{className:`w-60`,isClearable:!0,options:Object.values(o3),value:P,onChange:I,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(We,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>g([]),children:t(Gb,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:y,onClick:()=>v(!0),children:s(y?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(j,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{ee(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t($4,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&k(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t(e3,{okLabel:`Create`,title:s(`store.createType`),isOpen:L,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(ee(!1),Promise.resolve())}),t(b,{isOpen:_,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:D,onCancel:()=>v(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function c3(e,t,n){if(t.length===0)return e;let r=structuredClone(e),i=[r],a=r;for(let e of t.slice(0,-1)){let t=a[e],n=p3(t)?t:{};a[e]=n,a=n,i.push(a)}let o=t[t.length-1];return n===void 0||n===``?(delete a[o],f3(i,t)):a[o]=n,r}function l3(e,t,n,r){let i=e?.map(e=>[e[0]??1,e[1]??1])??[],a=i[t]??[1,1];return a[n]=r,i[t]=a,i}function u3(e,t){let n={...e,environment:t};return delete n.model,delete n.model_options,m3(n)?n:void 0}function d3(e,t){let n={...e,model:t};return t!==e?.model&&delete n.model_options,m3(n)?n:void 0}function f3(e,t){for(let n=e.length-1;n>0;--n){let r=e[n];if(Object.keys(r).length>0)break;delete e[n-1][t[n-1]]}}function p3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m3(e){return Object.values(e).some(e=>e!==void 0)}Q();function h3({policy:e,section:r,onChange:i,readonly:a=!1}){let{t:o}=K(),s=(t,n)=>i(c3(e,t,n));if(r===`classification`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.classification`),description:o(`intakePolicy.help.section.classification`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(x3,{label:o(`intakePolicy.field.mode`),description:o(`intakePolicy.help.mode`),value:e.mode,options:E3(o,[`programmatic`,`agentic`]),onChange:e=>s([`mode`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.defaultView`),value:e.default_view,options:E3(o,[`auto`,`text`,`pdf`,`image`,`properties`]),onChange:e=>s([`default_view`],e),readonly:a})]}),t(y3,{label:o(`intakePolicy.field.identificationGuidance`),description:o(`intakePolicy.help.identificationGuidance`),value:e.identification?.guidance,onChange:e=>s([`identification`,`guidance`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.distinguishFrom`),description:o(`intakePolicy.help.distinguishFrom`),value:e.identification?.distinguish_from,onChange:e=>s([`identification`,`distinguish_from`],e),readonly:a}),t(L,{label:o(`intakePolicy.field.examples`),description:o(`intakePolicy.help.examples`),children:t(He,{options:e.identification?.examples??[],value:e.identification?.examples??[],onChange:e=>s([`identification`,`examples`],e.length?e:void 0),onOptionsChange:e=>s([`identification`,`examples`],e.length?e:void 0),creatable:!0,disabled:a,placeholder:o(`intakePolicy.placeholder.objectId`)})})]}),n(_3,{title:o(`intakePolicy.section.locate`),description:o(`intakePolicy.help.section.locate`),last:!0,children:[t(y3,{label:o(`intakePolicy.field.locateInstructions`),description:o(`intakePolicy.help.locateInstructions`),value:e.locate?.instructions,onChange:t=>s([`locate`],t?{...e.locate,instructions:t}:void 0),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(x3,{label:o(`intakePolicy.field.contactSheetDetail`),description:o(`intakePolicy.help.contactSheetDetail`),value:e.locate?.detail,options:[{value:8,label:o(`intakePolicy.option.pagesPerSheet`,{count:8})},{value:16,label:o(`intakePolicy.option.pagesPerSheet`,{count:16})}],onChange:e=>s([`locate`,`detail`],e),readonly:a||!e.locate}),t(b3,{label:o(`intakePolicy.field.locateMinPages`),description:o(`intakePolicy.help.locateMinPages`),value:e.locate?.min_pages,min:0,onChange:e=>s([`locate`,`min_pages`],e),readonly:a||!e.locate})]})]})]});if(r===`conversion`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.conversion`),description:o(`intakePolicy.help.section.conversion`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:e.text_conversion?.enabled,onChange:e=>s([`text_conversion`,`enabled`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.method`),description:o(`intakePolicy.help.method`),value:e.text_conversion?.method,options:E3(o,[`auto`,`basic`,`llm`,`custom`]),onChange:e=>s([`text_conversion`,`method`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.outputFormat`),value:e.text_conversion?.output_format,options:E3(o,[`markdown`,`text`]),onChange:e=>s([`text_conversion`,`output_format`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.text_conversion?.scope,options:E3(o,[`all`,`located`]),onChange:e=>s([`text_conversion`,`scope`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.renderDpi`),description:o(`intakePolicy.help.renderDpi`),value:e.text_conversion?.render_dpi,min:72,onChange:e=>s([`text_conversion`,`render_dpi`],e),readonly:a})]}),t(y3,{label:o(`intakePolicy.field.instructions`),value:e.text_conversion?.instructions,onChange:e=>s([`text_conversion`,`instructions`],e),readonly:a})]}),t(_3,{title:o(`intakePolicy.section.conversionModel`),description:o(`intakePolicy.help.section.conversionModel`),children:t(T3,{title:o(`intakePolicy.field.model`),config:e.text_conversion?.config,onChange:e=>s([`text_conversion`,`config`],e),readonly:a})}),e.text_conversion?.method===`custom`&&t(_3,{title:o(`intakePolicy.section.customConversion`),description:o(`intakePolicy.help.section.customConversion`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(v3,{label:o(`intakePolicy.field.interaction`),value:e.text_conversion.custom?.interaction,onChange:e=>s([`text_conversion`,`custom`,`interaction`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.agent`),value:e.text_conversion.custom?.agent,onChange:e=>s([`text_conversion`,`custom`,`agent`],e),readonly:a})]})}),t(_3,{title:o(`intakePolicy.section.pageRanges`),description:o(`intakePolicy.help.section.pageRanges`),last:!0,children:t(w3,{value:e.text_conversion?.page_ranges,onChange:e=>s([`text_conversion`,`page_ranges`],e),readonly:a})})]});if(r===`extraction`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.extraction`),description:o(`intakePolicy.help.section.extraction`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.enabled,onChange:e=>s([`extraction`,`enabled`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.source`),description:o(`intakePolicy.help.extractionSource`),value:e.extraction?.source,options:E3(o,[`auto`,`text`,`vision`,`mixed`]),onChange:e=>s([`extraction`,`source`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.extraction?.scope,options:E3(o,[`all`,`located`]),onChange:e=>s([`extraction`,`scope`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPages`),description:o(`intakePolicy.help.extractionMaxPages`),value:e.extraction?.max_pages,min:1,onChange:e=>s([`extraction`,`max_pages`],e),readonly:a})]}),t(v3,{label:o(`intakePolicy.field.interaction`),description:o(`intakePolicy.help.extractionInteraction`),value:e.extraction?.interaction,onChange:e=>s([`extraction`,`interaction`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.instructions`),value:e.extraction?.instructions,onChange:e=>s([`extraction`,`instructions`],e),readonly:a}),t(w3,{value:e.extraction?.page_ranges,onChange:e=>s([`extraction`,`page_ranges`],e),readonly:a})]}),t(_3,{title:o(`intakePolicy.section.extractionModel`),description:o(`intakePolicy.help.section.extractionModel`),children:t(T3,{title:o(`intakePolicy.field.model`),config:e.extraction?.config,onChange:e=>s([`extraction`,`config`],e),readonly:a})}),t(_3,{title:o(`intakePolicy.section.visionBudget`),description:o(`intakePolicy.help.section.visionBudget`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(x3,{label:o(`intakePolicy.field.defaultDetail`),description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.default_detail,options:E3(o,[`low`,`standard`,`high`]),onChange:e=>s([`extraction`,`vision`,`default_detail`],e),readonly:a}),t(C3,{description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.allowed_details,onChange:e=>s([`extraction`,`vision`,`allowed_details`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxImageTokens`),description:o(`intakePolicy.help.maxImageTokens`),value:e.extraction?.vision?.max_image_tokens,min:1,onChange:e=>s([`extraction`,`vision`,`max_image_tokens`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPayloadMb`),description:o(`intakePolicy.help.maxPayloadMb`),value:e.extraction?.vision?.max_payload_mb,min:1,onChange:e=>s([`extraction`,`vision`,`max_payload_mb`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPagesPerCall`),value:e.extraction?.vision?.max_pages_per_call,min:1,onChange:e=>s([`extraction`,`vision`,`max_pages_per_call`],e),readonly:a})]})})]});if(r===`grounding`){let r=e.extraction?.grounding,i=r?.review;return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.grounding`),description:o(`intakePolicy.help.section.grounding`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:r?.enabled,onChange:e=>s([`extraction`,`grounding`,`enabled`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPages`),value:r?.max_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`max_pages`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.windowPages`),description:o(`intakePolicy.help.windowPages`),value:r?.window_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`window_pages`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.interaction`),value:r?.interaction,onChange:e=>s([`extraction`,`grounding`,`interaction`],e),readonly:a})]}),n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(S3,{label:o(`intakePolicy.field.useVision`),description:o(`intakePolicy.help.useVision`),value:r?.use_vision,onChange:e=>s([`extraction`,`grounding`,`use_vision`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.forceOcr`),description:o(`intakePolicy.help.forceOcr`),value:r?.force_ocr,onChange:e=>s([`extraction`,`grounding`,`force_ocr`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.refreshOcr`),description:o(`intakePolicy.help.refreshOcr`),value:r?.refresh_ocr,onChange:e=>s([`extraction`,`grounding`,`refresh_ocr`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.omitBlockBoxes`),description:o(`intakePolicy.help.omitBlockBoxes`),value:r?.omit_block_boxes,onChange:e=>s([`extraction`,`grounding`,`omit_block_boxes`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.updateProperties`),description:o(`intakePolicy.help.updateProperties`),value:r?.update_properties,onChange:e=>s([`extraction`,`grounding`,`update_properties`],e),readonly:a})]})]}),n(_3,{title:o(`intakePolicy.section.models`),description:o(`intakePolicy.help.section.models`),children:[t(T3,{title:o(`intakePolicy.field.primaryModel`),config:r?.config,onChange:e=>s([`extraction`,`grounding`,`config`],e),readonly:a}),t(T3,{title:o(`intakePolicy.field.hardModel`),config:r?.hard_config,onChange:e=>s([`extraction`,`grounding`,`hard_config`],e),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(b3,{label:o(`intakePolicy.field.hardnessThreshold`),description:o(`intakePolicy.help.hardnessThreshold`),value:r?.hardness_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`hardness_threshold`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.minCitationDensity`),description:o(`intakePolicy.help.minCitationDensity`),value:r?.min_citation_density,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`min_citation_density`],e),readonly:a})]})]}),n(_3,{title:o(`intakePolicy.section.review`),description:o(`intakePolicy.help.section.review`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:i?.enabled,onChange:e=>s([`extraction`,`grounding`,`review`,`enabled`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.forceReview`),description:o(`intakePolicy.help.forceReview`),value:i?.force,onChange:e=>s([`extraction`,`grounding`,`review`,`force`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.reviewThreshold`),value:i?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`threshold`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.coverageThreshold`),description:o(`intakePolicy.help.coverageThreshold`),value:i?.coverage_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`coverage_threshold`],e),readonly:a})]}),t(T3,{title:o(`intakePolicy.field.reviewModel`),config:i?.config,onChange:e=>s([`extraction`,`grounding`,`review`,`config`],e),readonly:a})]})]})}return n(g3,{children:[t(_3,{title:o(`intakePolicy.section.rendering`),description:o(`intakePolicy.help.section.rendering`),children:t(y3,{label:o(`intakePolicy.field.renderingTemplate`),description:o(`intakePolicy.help.renderingTemplate`),value:e.rendering_template,onChange:e=>s([`rendering_template`],e),readonly:a,monospace:!0,minLines:8})}),t(_3,{title:o(`intakePolicy.section.embeddings`),description:o(`intakePolicy.help.section.embeddings`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.textEmbedding`),value:e.embeddings?.text,onChange:e=>s([`embeddings`,`text`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.imageEmbedding`),value:e.embeddings?.image,onChange:e=>s([`embeddings`,`image`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.propertiesEmbedding`),value:e.embeddings?.properties,onChange:e=>s([`embeddings`,`properties`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.generateToc`),value:e.generate_toc,onChange:e=>s([`generate_toc`],e),readonly:a})]})})]})}function g3({children:e}){return t(`div`,{className:`w-full px-1 py-4`,children:e})}function _3({title:e,description:r,children:i,last:a=!1}){return n(`section`,{className:a?`pb-3`:`mb-6 border-b pb-6`,children:[n(`div`,{className:`mb-4 flex items-center gap-2`,children:[t(`h3`,{className:`text-sm font-semibold`,children:e}),t(R,{description:r})]}),t(`div`,{className:`space-y-4`,children:i})]})}function v3({label:e,value:n,onChange:r,readonly:i,description:a}){return t(L,{label:e,description:a,children:t(te,{value:n??``,onChange:e=>r(e||void 0),disabled:i})})}function y3({label:e,value:n,onChange:r,readonly:i,description:a,minLines:o=3,monospace:s=!1}){return t(L,{label:e,description:a,children:t(Ue,{value:n??``,onChange:e=>r(e.target.value||void 0),disabled:i,minLines:o,maxLines:14,className:s?`font-mono`:void 0})})}function b3({label:e,description:n,value:r,onChange:i,readonly:a,min:o,max:s,step:c}){return t(L,{label:e,description:n,children:t(de,{value:r,onChange:e=>i(e===void 0||Number.isFinite(e)?e:void 0),disabled:a,min:o,max:s,step:c??1,noScroll:!0})})}function x3({label:e,description:n,value:r,options:i,onChange:a,readonly:o}){let{t:s}=K(),c=[{value:`__inherit__`,label:s(`intakePolicy.option.inherit`)},...i],l=c.find(e=>e.value===r)??c[0];return t(L,{label:e,description:n,children:t(we,{options:c,value:l,by:`value`,optionLabel:e=>e.label,onChange:e=>a(e.value===`__inherit__`?void 0:e.value),disabled:o})})}function S3({label:e,description:n,value:r,onChange:i,readonly:a}){let{t:o}=K(),s=[{value:`inherit`,label:o(`intakePolicy.option.inherit`)},{value:`enabled`,label:o(`intakePolicy.option.enabled`)},{value:`disabled`,label:o(`intakePolicy.option.disabled`)}],c=r===void 0?`inherit`:r?`enabled`:`disabled`;return t(L,{label:e,description:n,children:t(we,{options:[...s],value:s.find(e=>e.value===c),by:`value`,optionLabel:e=>e.label,onChange:e=>i(e.value===`inherit`?void 0:e.value===`enabled`),disabled:a})})}function C3({description:e,value:n,onChange:r,readonly:i}){let{t:a}=K(),o=E3(a,[`low`,`standard`,`high`]);return t(L,{label:a(`intakePolicy.field.allowedDetails`),description:e,children:t(we,{multiple:!0,options:o,value:o.filter(e=>n?.includes(e.value)),by:`value`,optionLabel:e=>e.label,onChange:e=>r(e.length?e.map(e=>e.value):void 0),disabled:i})})}function w3({value:e,onChange:r,readonly:i}){let{t:a}=K(),s=t=>{let n=e?.filter((e,n)=>n!==t);r(n?.length?n:void 0)};return t(L,{label:a(`intakePolicy.field.pageRanges`),description:a(`intakePolicy.help.pageRanges`),children:n(`div`,{className:`space-y-2`,children:[e?.map((c,l)=>n(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.25rem] gap-2`,children:[t(de,{"aria-label":a(`intakePolicy.field.rangeStart`),value:c[0],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(l3(e,l,0,t))},disabled:i,step:1,noScroll:!0}),t(de,{"aria-label":a(`intakePolicy.field.rangeEnd`),value:c[1],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(l3(e,l,1,t))},disabled:i,step:1,noScroll:!0}),t(We,{description:a(`intakePolicy.action.removeRange`),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`intakePolicy.action.removeRange`),onClick:()=>s(l),disabled:i,children:t(hb,{className:`size-4`})})})]},`${l}`)),n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...e??[],[1,1]]),disabled:i,children:[t(oy,{className:`size-4`}),a(`intakePolicy.action.addRange`)]})]})})}function T3({title:e,config:r,onChange:i,readonly:a}){let{t:o}=K();return n(`div`,{children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:e}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(L,{label:o(`intakePolicy.field.environment`),children:t(J1,{selectedEnvId:r?.environment,onChange:e=>i(u3(r,e?.id)),isClearable:!0,disabled:a})}),t(L,{label:o(`intakePolicy.field.model`),children:t(Z1,{envId:r?.environment,selectedModelId:r?.model,onChange:e=>i(d3(r,e?.id)),isClearable:!0,disabled:a||!r?.environment})})]})]})}function E3(e,t){return t.map(t=>({value:t,label:e(`intakePolicy.option.${t}`)}))}Q();const D3=[{key:`minimal`,value:{identification:{guidance:`Documents that match this content type.`,distinguish_from:`Do not select this type for unrelated documents.`}}},{key:`extraction_only`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`vision`,instructions:`Extract required fields only. Ignore cover pages, appendices, legal boilerplate, and marketing content.`},rendering_template:`# {{properties.title}}
|
|
1391
|
+
+ `)||e.includes(`:!1}function w4(e){return e?`h-full overflow-auto`:`hidden`}var T4;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(T4||={});function E4({object:r,loadText:i,refetch:a,canEditProperties:o=!0,canCollaborate:s=!1}){let c=nt(),{t:l}=K(),{project:u,store:d}=q(),f=Qn(),p=r.revision?.root||r.id,m=u?.id?z2(u.id,p):void 0,[h,g]=G(r),[_,v]=G(()=>m?B2(m):!1),y=W(null),b=W(r.id),x=W(r.id),S=W(m);H(()=>{S.current!==m&&(S.current=m,v(m?B2(m):!1))},[m]);let C=V(()=>{v(e=>{let t=!e;return m&&V2(m,t),t})},[m]),w=V(()=>{m&&V2(m,!1),v(!1)},[m]);H(()=>{let e=x.current!==r.id;x.current=r.id,g(t=>!e&&t.id!==r.id?t:(b.current=r.id,t.id===r.id&&t.text&&!r.text?{...r,text:t.text}:r))},[r]);let T=V(async(e,t)=>{b.current=e;try{let[t,n]=await Promise.all([d.objects.retrieve(e),d.objects.getObjectText(e)]);b.current===e&&g({...t,text:n.text})}catch(e){console.error(`Failed to load the updated document revision`,e),c({status:`error`,title:l(`agent.failedToLoadDocument`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{t&&f(`/objects/${e}`)}},[f,d.objects,l,c]),E=async(e,t)=>{try{await navigator.clipboard.writeText(e),c({status:`success`,title:l(`store.contentCopied`,{type:l(t===`text`?`store.contentType`:`store.properties`)}),description:l(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),c({status:`error`,title:l(`store.copyFailed`),description:l(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(e,{children:[n(Ce,{direction:`horizontal`,className:`h-full`,children:[t(Se,{defaultSize:67,className:`min-w-[100px]`,children:t(O4,{object:h,loadText:i??!1,handleCopyContent:E,refetch:a,canCollaborate:s,isCollaborating:_,onToggleCollaborate:C})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:33,className:`min-w-[100px]`,children:t(D4,{object:h,refetch:a??(()=>Promise.resolve()),handleCopyContent:E,canEditProperties:o})})]}),_?t(d4,{object:h,initialContent:h.text??``,onClose:w,onDocumentUpdated:(e,t)=>void T(e,t),sendMessageRef:y}):null]})}function D4({object:r,refetch:i,handleCopyContent:a,canEditProperties:s}){let{t:c}=K(),[l,u]=G(!1),[d,f]=G(!1);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${l?`ghost`:`primary`}`,size:`sm`,title:c(`store.previewProperties`),onClick:()=>u(!l),children:`Properties`}),t(o,{variant:`${l?`primary`:`ghost`}`,size:`sm`,title:c(`store.viewInJsonFormat`),onClick:()=>u(!l),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>a(JSON.stringify(r.properties,null,2),`properties`),children:t(fg,{className:`size-4`})}),s&&t(g2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:()=>{f(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(Zy,{className:`size-4`})})]})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(jt,{value:r.properties,viewCode:l})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:c(`store.noPropertiesDefined`)})})]}),t(f4,{isOpen:d,onClose:()=>{f(!1)},object:r,refetch:i})]})}function O4(e){let{client:n}=q(),r=e.object.type,i=r?.id,a=r?.default_view,{data:o}=Ye(async()=>!i||a?null:(await y2(n,i))?.intake?.default_view??null,[i,a]),s=a??o;return i&&!a&&o===void 0?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(k4,{...e,defaultView:s??void 0})}function k4({object:e,loadText:r,handleCopyContent:i,refetch:a,defaultView:s,canCollaborate:c,isCollaborating:l,onToggleCollaborate:u}){let{client:d}=q(),{t:f}=K(),p=e?.metadata?.type===un.Image,m=e?.metadata?.type===un.Video,h=e?.metadata?.type===un.Audio,g=e?.content?.type===`application/pdf`,_=e?.content?.type?h$(e.content.type):!1,v=x4(e?.status),y=!!(e.transcript&&(m||h)),b=e.metadata?.renditions?.find(e=>e.name===_n),x=()=>{switch(s){case`text`:return T4.Text;case`pdf`:if(g||_||b)return T4.Pdf;break;case`image`:if(p)return T4.Image;break;case`properties`:return T4.Text}return m?T4.Video:h?T4.Audio:p?T4.Image:T4.Text},S=y0(e.id),[C,w]=G(x()),[T,E]=G(C===T4.Pdf);H(()=>{C===T4.Pdf&&E(!0)},[C]);let[D,O]=G(!1),k=K2(!!(e.content?.type&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),c),{fullText:A,displayText:j,isLoading:M,isCropped:N,loadText:P}=_4(e.id,e.text,r,e.revision?.root||e.id),F=(g||_)&&v&&(C===T4.Text||C===T4.Pdf),{progress:I,status:L,isComplete:ee}=v4(e.id,F),{pdfUrl:R,isConverting:te,error:ne,triggerConversion:re}=y4(e.id,_),ie=U(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>_||(e?h$(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await d.objects.getRendition(e.id,{format:gn.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[d,_,e.id,e.name]);H(()=>{ee&&L===Tn.COMPLETED&&P()},[ee,L,P]);let ae=(g||_)&&v&&!ee&&L===Tn.RUNNING,oe=C===T4.Pdf&&!ae,se=ae&&(C===T4.Text||C===T4.Pdf),ce=T&&!ae,le=W(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[p&&t(o,{variant:C===T4.Image?`primary`:`ghost`,size:`sm`,title:f(`store.viewImage`),onClick:()=>w(T4.Image),children:`Image`}),m&&t(o,{variant:C===T4.Video?`primary`:`ghost`,size:`sm`,title:f(`store.viewVideo`),onClick:()=>w(T4.Video),children:`Video`}),h&&t(o,{variant:C===T4.Audio?`primary`:`ghost`,size:`sm`,title:f(`store.viewAudio`),onClick:()=>w(T4.Audio),children:`Audio`}),y&&t(o,{variant:C===T4.Transcript?`primary`:`ghost`,size:`sm`,title:f(`store.viewTranscript`),onClick:()=>w(T4.Transcript),children:`Transcript`}),t(o,{variant:C===T4.Text?`primary`:`ghost`,size:`sm`,title:f(`store.viewText`),onClick:()=>w(T4.Text),children:`Text`}),g&&t(o,{variant:C===T4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewPdf`),onClick:()=>w(T4.Pdf),children:`PDF`}),_&&t(o,{variant:C===T4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewAsPdf`),onClick:()=>{w(T4.Pdf),!b&&!R&&!te&&re()},disabled:te,children:te?t(je,{size:`sm`}):`PDF`})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(N4,{object:e}),t(P4,{objectId:e.id,available:S})]})]}),C===T4.Text&&!ae&&!D&&t(A4,{object:e,text:j,fullText:A,handleCopyContent:i,textContainerRef:le,isEditing:D,onToggleEdit:()=>O(!0),canEdit:k.canEdit,isCollaborating:l,onToggleCollaborate:u,canCollaborate:k.canCollaborate}),C===T4.Pdf&&_&&(b||R)&&t(F4,{object:e,pdfRendition:b,officePdfUrl:R})]}),C===T4.Image&&t(`div`,{className:w4(!0),children:t(n2,{object:e})}),C===T4.Video&&t(`div`,{className:w4(!0),children:t(r2,{object:e})}),C===T4.Audio&&t(`div`,{className:w4(!0),children:t(t2,{object:e})}),y&&C===T4.Transcript&&t(`div`,{className:w4(!0),children:t(M4,{object:e,handleCopyContent:i})}),g&&ce&&t(`div`,{className:w4(oe),children:t(I4,{object:e})}),_&&ce&&t(`div`,{className:w4(oe),children:t(L4,{object:e,pdfRendition:b,officePdfUrl:R,converters:ie,officePdfConverting:te,officePdfError:ne})}),se&&t(`div`,{className:w4(!0),children:t(R4,{progress:I,status:L})}),C===T4.Text&&!ae&&!D&&M&&!j&&t(`div`,{className:w4(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(je,{size:`lg`})})}),C===T4.Text&&!ae&&!D&&(!M||j)&&t(`div`,{className:w4(!0),children:t(j4,{object:e,text:j,isTextCropped:N,textContainerRef:le})}),D&&C===T4.Text&&A!=null&&t(h4,{object:e,text:A,onClose:()=>O(!1),onSaved:()=>{O(!1),P(),a?.()}})]})}function A4({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l,isCollaborating:u,onToggleCollaborate:d,canCollaborate:f}){let{client:p,project:m}=q(),h=nt(),{t:g}=K(),_=r.content,{renderDocument:v,isDownloading:y}=nG({client:p,toast:h}),{data:b}=Ye(()=>m?p.projects.retrieve(m.id):Promise.resolve(void 0),[m?.id]),x=b?.configuration?.pdf_template_object_id??void 0,S=J2(_?.type),C=Y2(_?.type),T=async(e,t)=>{if(y)return;h({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:g(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:x;await v(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(fg,{className:`size-4`})}),y?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(je,{size:`sm`})}):n(w,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(xg,{className:`size-4`})}),children:[a&&t(ae,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;_?.type===`application/xml`||_?.type===`text/xml`?(t=`xml`,n=`text/xml`):S&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Download Text`]})}),S&&i&&n(e,{children:[t(ae,{onClick:()=>T(gn.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as DOCX`]})}),t(ae,{onClick:()=>T(gn.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as PDF`]})}),t(ae,{onClick:()=>T(gn.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as Branded PDF`]})})]})]}),a&&n(e,{children:[l&&c&&t(g2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:c,title:g(`store.editText`),"aria-label":g(`store.editText`),className:`h-8 w-8 p-0`,children:t(Zy,{className:`size-4`})}),f&&d&&C&&t(o,{variant:u?`primary`:`ghost`,size:`sm`,onClick:d,title:g(`agent.editWithAI`),"aria-label":g(`agent.editWithAI`),className:`h-8 w-8 p-0`,children:t(Jy,{className:`size-4`})})]})]})})}const j4=gt(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=K(),c=x4(r?.status),l=r.content,u=S4(r)===`xml`||l?.type===`application/xml`||l?.type===`text/xml`,d=Y2(l?.type),f=!u&&(d||C4(i)),p={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:u?`text/xml`:f?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(vb,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(ZY,{source:p,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:b4()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function M4({object:e,handleCopyContent:r}){let{t:i}=K(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(fg,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function N4({object:r}){let[i,a]=G(!1);return S4(r)===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(Hg,{className:`size-4`})}),i&&t(ve,{children:t(Y0,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function P4({objectId:r,available:i}){let{t:a}=K(),[s,c]=G(!1);return i?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),title:a(`grounded.title`),"aria-label":a(`grounded.title`),children:t(Dy,{className:`size-4`})}),s&&t(ve,{children:t(S0,{objectId:r,onClose:()=>c(!1)})})]}):null}function F4({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=q(),a=nt(),{t:s}=K(),[c,l]=G(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(je,{size:`sm`}):t(xg,{className:`size-4`})})})}function I4({object:e}){let n={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(ZY,{source:n,className:`h-full`,showHeader:!1})})}function L4({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=K();if(o)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(je,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]});if(s)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(vb,{className:`size-8`}),t(`span`,{children:s})]});if(r?.content?.source){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source};return t(`div`,{className:`h-full`,children:t(ZY,{source:n,className:`h-full`})})}if(i){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i};return t(`div`,{className:`h-full`,children:t(ZY,{source:n,className:`h-full`})})}let l={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(ZY,{source:l,converters:a,className:`h-full`})})}function R4({progress:r,status:i}){let{t:a}=K(),o=S$(i),s=C$(i),c=r?.phase===`grounded_extraction`,l=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(z4,{name:c?`Prepare Evidence`:`Analyze Page`,progress:r.pages}),c&&n(e,{children:[t(z4,{name:`Run OCR`,progress:r.images}),t(z4,{name:`Extract Grounded Data`,progress:r.tables}),t(z4,{name:`Review and Annotate`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,l,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:o,children:s}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(Ft,{percent:l})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(je,{size:`sm`}),t(`span`,{children:a(`store.loadingProcessingStatus`)})]})]})}function z4({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}Q();const B4=Object.values(xn),V4=Object.values(Cn);function H4({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=q(),{t:l}=K(),u=nt(),[d,f]=G(void 0),[p,h]=G(void 0),g=!!c&&(!!p?.embeddings.text||!!p?.embeddings.image),[_,v]=G(void 0),y=W(i),b=W(void 0),[x,S]=G(!1),[C,w]=G(a||B4),[T,E]=G(100);H(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===xn.full_text?O=!0:k=!0,V4.includes(e)&&(D[e]=!0)}),H(()=>{y.current!==i&&(y.current=i,f(void 0),v(void 0))}),H(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),H(()=>{_&&u({title:_,status:`success`,duration:2e3})},[_,u]),H(()=>{let t=b.current;b.current=d,t&&(!d||d.length===0)&&e(void 0)},[e,d]);let A=()=>{!g||!d||(e({vector:k?{text:d,config:D}:void 0,full_text:O?d:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(te,{placeholder:l(`store.searchPlaceholder`),value:d,onChange:f,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),title:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(Iy,{size:18})}),n(se,{isOpen:x,onClose:()=>S(!1),children:[t(ue,{children:l(`store.searchTypes`)}),t(ce,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-full_text`,checked:C.includes(xn.full_text),onCheckedChange:M(xn.full_text)}),t(re,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),V4.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(re,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(de,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(le,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,title:l(`store.semanticSearch`),children:l(`store.search`)})]})}Q();const U4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function W4(e,t){return(t?e.getTypeLayout(t):U4)??U4}function G4({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=B$(),a=nt(),{t:o}=K(),s=X$(V(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a])),c=V((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]);return t(K4,{layout:n,onUpload:c,toolbarActions:r})}function K4({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=K(),c=B$(),[l,u]=G(!1),[d,f]=G(null),{registry:p}=rQ(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=H$(),[y,b]=G(p?e||W4(p,m.query.type):U4);H(()=>{e&&b(e)},[e]);let[x,S]=G(0),[C,w]=G(0),[T,E]=G(localStorage.getItem(a1.LAST_DISPLAYED_VIEW)===`grid`),[D,O]=G([]),k=W(null),A=W(null),j=V((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);H(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),H(()=>{_.length<C&&w(_.length)},[_.length,C]),Qe(k,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}j(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),j(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,j(m.search(),`Search reset failed:`))},P=V$(),F=B$(),I=()=>{j(m.search(),`Search refresh failed:`)},L=hQ(P),ee=gQ(F),R=e=>{let t=typeof e==`function`?e(D):e;O(t),ee(t)},te=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};R(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},ne=new URL(window.location.href),re=ne.searchParams.get(`filters`);if(re)try{let e=re.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?ne.searchParams.set(`filters`,e):ne.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,ne.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let ie=Qn();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(J4,{object:d,onClose:()=>f(null)}),g&&t(M,{title:s(`store.error`),children:g.message}),t(q4,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:R,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:A,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(n$,{onFilter:te,children:t(Q$,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{ie(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:k,className:`w-full flex justify-center`,children:t(je,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function q4(e){let{t:r}=K(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(I,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(H4,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(P,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(N,{}),t(F,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(H4,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(o,{variant:`outline`,onClick:p,title:r(`store.refresh`),children:t(hy,{size:16})}),t(a1,{onUpdate:m})]})]})}function J4({object:e,onClose:r}){let{store:i}=q(),a=nt(),s=Qn(),{downloadFromContentSource:c}=nG({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(Oe,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Dg,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,tG(e)),children:t(xg,{className:`size-4`})})]}),t(C,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(E4,{object:e,loadText:!0},e.id)})]}):null}const Y4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function X4({collection:e}){let n=nt(),{client:r}=q(),{registry:i}=rQ(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=Z4(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(K4,{layout:o}):t(G4,{onUploadDone:a,layout:o})})}function Z4(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(En(e.type))),n&&n.length>0)?n:Y4}function Q4({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=K(),{registry:c}=rQ(),[l,u]=G(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=G(),[m,h]=G([]);return H(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function $4({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=Qn(),c=nt(),{t:l}=K(),[u,d]=G(!1),{client:f}=q(),[p,m]=G({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(ce,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(L,{label:l(`type.name`),required:!0,children:t(te,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(L,{label:l(`type.description`),className:`mt-2`,children:t(Ue,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(L,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Ne,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(L,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(Q4,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(L,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(Q4,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(le,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function e3({isOpen:e,onClose:r}){let{t:i}=K();return n(se,{onClose:r,isOpen:e,children:[t(ue,{children:i(`store.createACollection`)}),t($4,{onClose:r})]})}Q();function t3(){let{client:r}=q(),i=nt(),{t:a}=K(),[s,c]=G(),[l,u]=G(!0),[d,f]=G(!1),{data:p,error:m,refetch:h}=Ye(()=>r.store.collections.search({}),[]);return H(()=>{(p||m)&&u(!1)},[p,m]),m?t(M,{title:a(`store.collectionFetchFailed`),children:Ge(m)}):n(e,{children:[p&&(p.length>0?n(Le,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(Pe,{columns:4,isLoading:l,children:p.map(e=>n(Ie,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(n3,{isDynamic:e.dynamic}),t(Zn,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:WD(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(hb,{className:`size-4`})})})]},e.id))})]}):t(j,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(e3,{isOpen:d,onClose:()=>f(!1)}),t(b,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:Ge(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function n3({isDynamic:e}){let{t:n}=K(),r=n(e?`store.dynamicCollection`:`store.staticCollection`),i=t(e?Ay:e_,{className:`size-5`});return t(We,{description:r,className:`me-2`,children:i})}Q();const r3=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function i3({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=K(),d=Qn(),f=!!s;return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.status`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(Pe,{isLoading:r&&(!e||e.length===0),columns:f?6:5,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:it(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(x,{content:e.id,className:r3}),i&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${e.name}`,className:r3,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(l_,{className:`size-3`})})]})}),t(`td`,{children:t(a3,{status:e.status})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(We,{description:WD(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:WD(e.updated_at).fromNow()})})]},e.id))})]})}function a3({status:e=`active`}){let{t:n}=K();return e===`active`?t(i,{variant:`success`,children:n(`store.typeStatus.active`)}):t(We,{description:n(`store.typeStatus.draftHint`),children:t(i,{variant:`attention`,children:n(`store.typeStatus.draft`)})})}function o3({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=K(),u=nt(),[d,f]=G(s?.name),[p,m]=G(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(se,{isOpen:r,onClose:()=>i(),children:[t(ue,{children:e}),t(ce,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(te,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(Ue,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(le,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var s3=class{client;limit;result=new De({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const c3=dt(void 0);function l3(){return _t(c3)}function u3(){let e=l3();return{...rt(e.result),search:e}}function d3(){return l3().objects.length}Q();var f3;(function(e){e.true=`Yes`,e.false=`No`})(f3||={});function p3({isDirty:r=!1}){let{store:i}=q(),{reload:a}=rQ(),{t:s}=K(),c=nt(),[l,u]=G(!1),{search:d,isLoading:f,error:p,objects:m}=u3(),[h,g]=G([]),[_,v]=G(!1),[y,x]=G(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{g(e&&m?m.map(e=>e.id):[])},D=async()=>{if(!y){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;v(!1),g([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[O,k]=G(``),A=Je(O,500),N=W(null);Qe(N,()=>{l&&d.loadMore()},{deps:[l,d]}),H(()=>{d.search().then(()=>u(!0))},[d]),H(()=>{d.query.name=A,d.search().then(()=>u(!0))},[A,d]);let[P,F]=G(void 0),I=e=>{F(e)};H(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),H(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[L,ee]=G(!1);return p?t(M,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(te,{placeholder:s(`store.filterByName`),value:O,onChange:k}),t(we,{className:`w-60`,isClearable:!0,options:Object.values(f3),value:P,onChange:I,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(We,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>g([]),children:t(Gb,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:y,onClick:()=>v(!0),children:s(y?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(j,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{ee(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t(i3,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&k(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t(o3,{okLabel:`Create`,title:s(`store.createType`),isOpen:L,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(ee(!1),Promise.resolve())}),t(b,{isOpen:_,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:D,onCancel:()=>v(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function m3(e,t,n){if(t.length===0)return e;let r=structuredClone(e),i=[r],a=r;for(let e of t.slice(0,-1)){let t=a[e],n=y3(t)?t:{};a[e]=n,a=n,i.push(a)}let o=t[t.length-1];return n===void 0||n===``?(delete a[o],v3(i,t)):a[o]=n,r}function h3(e,t,n,r){let i=e?.map(e=>[e[0]??1,e[1]??1])??[],a=i[t]??[1,1];return a[n]=r,i[t]=a,i}function g3(e,t){let n={...e,environment:t};return delete n.model,delete n.model_options,b3(n)?n:void 0}function _3(e,t){let n={...e,model:t};return t!==e?.model&&delete n.model_options,b3(n)?n:void 0}function v3(e,t){for(let n=e.length-1;n>0;--n){let r=e[n];if(Object.keys(r).length>0)break;delete e[n-1][t[n-1]]}}function y3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b3(e){return Object.values(e).some(e=>e!==void 0)}Q();function x3({policy:e,section:r,onChange:i,readonly:a=!1}){let{t:o}=K(),s=(t,n)=>i(m3(e,t,n));if(r===`classification`)return n(S3,{children:[n(C3,{title:o(`intakePolicy.section.classification`),description:o(`intakePolicy.help.section.classification`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(D3,{label:o(`intakePolicy.field.mode`),description:o(`intakePolicy.help.mode`),value:e.mode,options:M3(o,[`programmatic`,`agentic`]),onChange:e=>s([`mode`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.defaultView`),value:e.default_view,options:M3(o,[`auto`,`text`,`pdf`,`image`,`properties`]),onChange:e=>s([`default_view`],e),readonly:a})]}),t(T3,{label:o(`intakePolicy.field.identificationGuidance`),description:o(`intakePolicy.help.identificationGuidance`),value:e.identification?.guidance,onChange:e=>s([`identification`,`guidance`],e),readonly:a}),t(T3,{label:o(`intakePolicy.field.distinguishFrom`),description:o(`intakePolicy.help.distinguishFrom`),value:e.identification?.distinguish_from,onChange:e=>s([`identification`,`distinguish_from`],e),readonly:a}),t(L,{label:o(`intakePolicy.field.examples`),description:o(`intakePolicy.help.examples`),children:t(He,{options:e.identification?.examples??[],value:e.identification?.examples??[],onChange:e=>s([`identification`,`examples`],e.length?e:void 0),onOptionsChange:e=>s([`identification`,`examples`],e.length?e:void 0),creatable:!0,disabled:a,placeholder:o(`intakePolicy.placeholder.objectId`)})})]}),n(C3,{title:o(`intakePolicy.section.locate`),description:o(`intakePolicy.help.section.locate`),last:!0,children:[t(T3,{label:o(`intakePolicy.field.locateInstructions`),description:o(`intakePolicy.help.locateInstructions`),value:e.locate?.instructions,onChange:t=>s([`locate`],t?{...e.locate,instructions:t}:void 0),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(D3,{label:o(`intakePolicy.field.contactSheetDetail`),description:o(`intakePolicy.help.contactSheetDetail`),value:e.locate?.detail,options:[{value:8,label:o(`intakePolicy.option.pagesPerSheet`,{count:8})},{value:16,label:o(`intakePolicy.option.pagesPerSheet`,{count:16})}],onChange:e=>s([`locate`,`detail`],e),readonly:a||!e.locate}),t(E3,{label:o(`intakePolicy.field.locateMinPages`),description:o(`intakePolicy.help.locateMinPages`),value:e.locate?.min_pages,min:0,onChange:e=>s([`locate`,`min_pages`],e),readonly:a||!e.locate})]})]})]});if(r===`conversion`)return n(S3,{children:[n(C3,{title:o(`intakePolicy.section.conversion`),description:o(`intakePolicy.help.section.conversion`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(O3,{label:o(`intakePolicy.field.enabled`),value:e.text_conversion?.enabled,onChange:e=>s([`text_conversion`,`enabled`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.method`),description:o(`intakePolicy.help.method`),value:e.text_conversion?.method,options:M3(o,[`auto`,`basic`,`llm`,`custom`]),onChange:e=>s([`text_conversion`,`method`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.outputFormat`),value:e.text_conversion?.output_format,options:M3(o,[`markdown`,`text`]),onChange:e=>s([`text_conversion`,`output_format`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.text_conversion?.scope,options:M3(o,[`all`,`located`]),onChange:e=>s([`text_conversion`,`scope`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.renderDpi`),description:o(`intakePolicy.help.renderDpi`),value:e.text_conversion?.render_dpi,min:72,onChange:e=>s([`text_conversion`,`render_dpi`],e),readonly:a})]}),t(T3,{label:o(`intakePolicy.field.instructions`),value:e.text_conversion?.instructions,onChange:e=>s([`text_conversion`,`instructions`],e),readonly:a})]}),t(C3,{title:o(`intakePolicy.section.conversionModel`),description:o(`intakePolicy.help.section.conversionModel`),children:t(j3,{title:o(`intakePolicy.field.model`),config:e.text_conversion?.config,onChange:e=>s([`text_conversion`,`config`],e),readonly:a})}),e.text_conversion?.method===`custom`&&t(C3,{title:o(`intakePolicy.section.customConversion`),description:o(`intakePolicy.help.section.customConversion`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(w3,{label:o(`intakePolicy.field.interaction`),value:e.text_conversion.custom?.interaction,onChange:e=>s([`text_conversion`,`custom`,`interaction`],e),readonly:a}),t(w3,{label:o(`intakePolicy.field.agent`),value:e.text_conversion.custom?.agent,onChange:e=>s([`text_conversion`,`custom`,`agent`],e),readonly:a})]})}),t(C3,{title:o(`intakePolicy.section.pageRanges`),description:o(`intakePolicy.help.section.pageRanges`),last:!0,children:t(A3,{value:e.text_conversion?.page_ranges,onChange:e=>s([`text_conversion`,`page_ranges`],e),readonly:a})})]});if(r===`extraction`)return n(S3,{children:[n(C3,{title:o(`intakePolicy.section.extraction`),description:o(`intakePolicy.help.section.extraction`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(O3,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.enabled,onChange:e=>s([`extraction`,`enabled`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.source`),description:o(`intakePolicy.help.extractionSource`),value:e.extraction?.source,options:M3(o,[`auto`,`text`,`vision`,`mixed`]),onChange:e=>s([`extraction`,`source`],e),readonly:a}),t(D3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.extraction?.scope,options:M3(o,[`all`,`located`]),onChange:e=>s([`extraction`,`scope`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.maxPages`),description:o(`intakePolicy.help.extractionMaxPages`),value:e.extraction?.max_pages,min:1,onChange:e=>s([`extraction`,`max_pages`],e),readonly:a})]}),t(w3,{label:o(`intakePolicy.field.interaction`),description:o(`intakePolicy.help.extractionInteraction`),value:e.extraction?.interaction,onChange:e=>s([`extraction`,`interaction`],e),readonly:a}),t(T3,{label:o(`intakePolicy.field.instructions`),value:e.extraction?.instructions,onChange:e=>s([`extraction`,`instructions`],e),readonly:a}),t(A3,{value:e.extraction?.page_ranges,onChange:e=>s([`extraction`,`page_ranges`],e),readonly:a})]}),t(C3,{title:o(`intakePolicy.section.extractionModel`),description:o(`intakePolicy.help.section.extractionModel`),children:t(j3,{title:o(`intakePolicy.field.model`),config:e.extraction?.config,onChange:e=>s([`extraction`,`config`],e),readonly:a})}),t(C3,{title:o(`intakePolicy.section.visionBudget`),description:o(`intakePolicy.help.section.visionBudget`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(D3,{label:o(`intakePolicy.field.defaultDetail`),description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.default_detail,options:M3(o,[`low`,`standard`,`high`]),onChange:e=>s([`extraction`,`vision`,`default_detail`],e),readonly:a}),t(k3,{description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.allowed_details,onChange:e=>s([`extraction`,`vision`,`allowed_details`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.maxImageTokens`),description:o(`intakePolicy.help.maxImageTokens`),value:e.extraction?.vision?.max_image_tokens,min:1,onChange:e=>s([`extraction`,`vision`,`max_image_tokens`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.maxPayloadMb`),description:o(`intakePolicy.help.maxPayloadMb`),value:e.extraction?.vision?.max_payload_mb,min:1,onChange:e=>s([`extraction`,`vision`,`max_payload_mb`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.maxPagesPerCall`),value:e.extraction?.vision?.max_pages_per_call,min:1,onChange:e=>s([`extraction`,`vision`,`max_pages_per_call`],e),readonly:a})]})})]});if(r===`grounding`){let r=e.extraction?.grounding,i=r?.review;return n(S3,{children:[n(C3,{title:o(`intakePolicy.section.grounding`),description:o(`intakePolicy.help.section.grounding`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(O3,{label:o(`intakePolicy.field.enabled`),value:r?.enabled,onChange:e=>s([`extraction`,`grounding`,`enabled`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.maxPages`),value:r?.max_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`max_pages`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.windowPages`),description:o(`intakePolicy.help.windowPages`),value:r?.window_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`window_pages`],e),readonly:a}),t(w3,{label:o(`intakePolicy.field.interaction`),value:r?.interaction,onChange:e=>s([`extraction`,`grounding`,`interaction`],e),readonly:a})]}),n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(O3,{label:o(`intakePolicy.field.useVision`),description:o(`intakePolicy.help.useVision`),value:r?.use_vision,onChange:e=>s([`extraction`,`grounding`,`use_vision`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.forceOcr`),description:o(`intakePolicy.help.forceOcr`),value:r?.force_ocr,onChange:e=>s([`extraction`,`grounding`,`force_ocr`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.refreshOcr`),description:o(`intakePolicy.help.refreshOcr`),value:r?.refresh_ocr,onChange:e=>s([`extraction`,`grounding`,`refresh_ocr`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.omitBlockBoxes`),description:o(`intakePolicy.help.omitBlockBoxes`),value:r?.omit_block_boxes,onChange:e=>s([`extraction`,`grounding`,`omit_block_boxes`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.updateProperties`),description:o(`intakePolicy.help.updateProperties`),value:r?.update_properties,onChange:e=>s([`extraction`,`grounding`,`update_properties`],e),readonly:a})]})]}),n(C3,{title:o(`intakePolicy.section.models`),description:o(`intakePolicy.help.section.models`),children:[t(j3,{title:o(`intakePolicy.field.primaryModel`),config:r?.config,onChange:e=>s([`extraction`,`grounding`,`config`],e),readonly:a}),t(j3,{title:o(`intakePolicy.field.hardModel`),config:r?.hard_config,onChange:e=>s([`extraction`,`grounding`,`hard_config`],e),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(E3,{label:o(`intakePolicy.field.hardnessThreshold`),description:o(`intakePolicy.help.hardnessThreshold`),value:r?.hardness_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`hardness_threshold`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.minCitationDensity`),description:o(`intakePolicy.help.minCitationDensity`),value:r?.min_citation_density,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`min_citation_density`],e),readonly:a})]})]}),n(C3,{title:o(`intakePolicy.section.review`),description:o(`intakePolicy.help.section.review`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(O3,{label:o(`intakePolicy.field.enabled`),value:i?.enabled,onChange:e=>s([`extraction`,`grounding`,`review`,`enabled`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.forceReview`),description:o(`intakePolicy.help.forceReview`),value:i?.force,onChange:e=>s([`extraction`,`grounding`,`review`,`force`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.reviewThreshold`),value:i?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`threshold`],e),readonly:a}),t(E3,{label:o(`intakePolicy.field.coverageThreshold`),description:o(`intakePolicy.help.coverageThreshold`),value:i?.coverage_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`coverage_threshold`],e),readonly:a})]}),t(j3,{title:o(`intakePolicy.field.reviewModel`),config:i?.config,onChange:e=>s([`extraction`,`grounding`,`review`,`config`],e),readonly:a})]})]})}return n(S3,{children:[t(C3,{title:o(`intakePolicy.section.rendering`),description:o(`intakePolicy.help.section.rendering`),children:t(T3,{label:o(`intakePolicy.field.renderingTemplate`),description:o(`intakePolicy.help.renderingTemplate`),value:e.rendering_template,onChange:e=>s([`rendering_template`],e),readonly:a,monospace:!0,minLines:8})}),t(C3,{title:o(`intakePolicy.section.embeddings`),description:o(`intakePolicy.help.section.embeddings`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(O3,{label:o(`intakePolicy.field.textEmbedding`),value:e.embeddings?.text,onChange:e=>s([`embeddings`,`text`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.imageEmbedding`),value:e.embeddings?.image,onChange:e=>s([`embeddings`,`image`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.propertiesEmbedding`),value:e.embeddings?.properties,onChange:e=>s([`embeddings`,`properties`],e),readonly:a}),t(O3,{label:o(`intakePolicy.field.generateToc`),value:e.generate_toc,onChange:e=>s([`generate_toc`],e),readonly:a})]})})]})}function S3({children:e}){return t(`div`,{className:`w-full px-1 py-4`,children:e})}function C3({title:e,description:r,children:i,last:a=!1}){return n(`section`,{className:a?`pb-3`:`mb-6 border-b pb-6`,children:[n(`div`,{className:`mb-4 flex items-center gap-2`,children:[t(`h3`,{className:`text-sm font-semibold`,children:e}),t(R,{description:r})]}),t(`div`,{className:`space-y-4`,children:i})]})}function w3({label:e,value:n,onChange:r,readonly:i,description:a}){return t(L,{label:e,description:a,children:t(te,{value:n??``,onChange:e=>r(e||void 0),disabled:i})})}function T3({label:e,value:n,onChange:r,readonly:i,description:a,minLines:o=3,monospace:s=!1}){return t(L,{label:e,description:a,children:t(Ue,{value:n??``,onChange:e=>r(e.target.value||void 0),disabled:i,minLines:o,maxLines:14,className:s?`font-mono`:void 0})})}function E3({label:e,description:n,value:r,onChange:i,readonly:a,min:o,max:s,step:c}){return t(L,{label:e,description:n,children:t(de,{value:r,onChange:e=>i(e===void 0||Number.isFinite(e)?e:void 0),disabled:a,min:o,max:s,step:c??1,noScroll:!0})})}function D3({label:e,description:n,value:r,options:i,onChange:a,readonly:o}){let{t:s}=K(),c=[{value:`__inherit__`,label:s(`intakePolicy.option.inherit`)},...i],l=c.find(e=>e.value===r)??c[0];return t(L,{label:e,description:n,children:t(we,{options:c,value:l,by:`value`,optionLabel:e=>e.label,onChange:e=>a(e.value===`__inherit__`?void 0:e.value),disabled:o})})}function O3({label:e,description:n,value:r,onChange:i,readonly:a}){let{t:o}=K(),s=[{value:`inherit`,label:o(`intakePolicy.option.inherit`)},{value:`enabled`,label:o(`intakePolicy.option.enabled`)},{value:`disabled`,label:o(`intakePolicy.option.disabled`)}],c=r===void 0?`inherit`:r?`enabled`:`disabled`;return t(L,{label:e,description:n,children:t(we,{options:[...s],value:s.find(e=>e.value===c),by:`value`,optionLabel:e=>e.label,onChange:e=>i(e.value===`inherit`?void 0:e.value===`enabled`),disabled:a})})}function k3({description:e,value:n,onChange:r,readonly:i}){let{t:a}=K(),o=M3(a,[`low`,`standard`,`high`]);return t(L,{label:a(`intakePolicy.field.allowedDetails`),description:e,children:t(we,{multiple:!0,options:o,value:o.filter(e=>n?.includes(e.value)),by:`value`,optionLabel:e=>e.label,onChange:e=>r(e.length?e.map(e=>e.value):void 0),disabled:i})})}function A3({value:e,onChange:r,readonly:i}){let{t:a}=K(),s=t=>{let n=e?.filter((e,n)=>n!==t);r(n?.length?n:void 0)};return t(L,{label:a(`intakePolicy.field.pageRanges`),description:a(`intakePolicy.help.pageRanges`),children:n(`div`,{className:`space-y-2`,children:[e?.map((c,l)=>n(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.25rem] gap-2`,children:[t(de,{"aria-label":a(`intakePolicy.field.rangeStart`),value:c[0],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(h3(e,l,0,t))},disabled:i,step:1,noScroll:!0}),t(de,{"aria-label":a(`intakePolicy.field.rangeEnd`),value:c[1],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(h3(e,l,1,t))},disabled:i,step:1,noScroll:!0}),t(We,{description:a(`intakePolicy.action.removeRange`),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`intakePolicy.action.removeRange`),onClick:()=>s(l),disabled:i,children:t(hb,{className:`size-4`})})})]},`${l}`)),n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...e??[],[1,1]]),disabled:i,children:[t(oy,{className:`size-4`}),a(`intakePolicy.action.addRange`)]})]})})}function j3({title:e,config:r,onChange:i,readonly:a}){let{t:o}=K();return n(`div`,{children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:e}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(L,{label:o(`intakePolicy.field.environment`),children:t($1,{selectedEnvId:r?.environment,onChange:e=>i(g3(r,e?.id)),isClearable:!0,disabled:a})}),t(L,{label:o(`intakePolicy.field.model`),children:t(n0,{envId:r?.environment,selectedModelId:r?.model,onChange:e=>i(_3(r,e?.id)),isClearable:!0,disabled:a||!r?.environment})})]})]})}function M3(e,t){return t.map(t=>({value:t,label:e(`intakePolicy.option.${t}`)}))}Q();const N3=[{key:`minimal`,value:{identification:{guidance:`Documents that match this content type.`,distinguish_from:`Do not select this type for unrelated documents.`}}},{key:`extraction_only`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`vision`,instructions:`Extract required fields only. Ignore cover pages, appendices, legal boilerplate, and marketing content.`},rendering_template:`# {{properties.title}}
|
|
1392
1392
|
|
|
1393
1393
|
{{properties.summary}}`,embeddings:{text:!0,properties:!0},default_view:`pdf`}},{key:`grounded`,value:{extraction:{enabled:!0,grounding:{enabled:!0,use_vision:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hardness_threshold:.5,min_citation_density:.3,window_pages:3,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,thinking_level:`MEDIUM`,max_tokens:32e3,temperature:0}},coverage_threshold:.2}}},default_view:`pdf`}},{key:`visual_first`,value:{identification:{guidance:`Presentation decks or visual reports with slides, charts, diagrams, tables, or callouts.`},text_conversion:{enabled:!0,method:`auto`},extraction:{enabled:!0,source:`auto`,instructions:`Use visual evidence when layout, charts, diagrams, or slide structure contain material information.`},default_view:`pdf`}},{key:`structured_spreadsheet`,value:{text_conversion:{enabled:!0,method:`auto`,instructions:`Preserve sheet names, headers, row labels, totals, and period columns.`},extraction:{enabled:!0,source:`text`,instructions:`Extract values from worksheet text. Do not infer values from charts.`},default_view:`properties`}},{key:`media_no_transcript`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`auto`,instructions:`Analyze available metadata and source evidence without creating a transcript.`},default_view:`properties`}},{key:`full_reference`,value:{mode:`programmatic`,identification:{guidance:`Supplier invoices: billing documents with an invoice number, line items, amounts due, tax breakdown, and payment terms.`,distinguish_from:`Quotes and estimates are offers, not payment requests. Credit notes carry negative amounts. Receipts confirm a payment already made.`,examples:[]},text_conversion:{enabled:!0,method:`auto`,instructions:`Keep the commercial terms and totals. Drop boilerplate and legal footers.`,output_format:`markdown`,custom:{interaction:`my-project:ConvertSpecialDocument`,agent:`my-project:DocumentConversionAgent`}},extraction:{enabled:!0,source:`auto`,instructions:`Extract totals from the summary block, not from line items. Amounts include currency. Dates use ISO 8601.`,interaction:`sys:ExtractInformation`,verification:{enabled:!1,model:`publishers/anthropic/models/claude-sonnet`,environment:`default`,materiality:`Amounts, dates, identifiers, and party names are material. Typos in free text are not.`,threshold:.85,max_retries:1,on_fail:`flag`},grounding:{enabled:!0,interaction:`sys:ExtractInformationGrounded`,max_pages:20,force_ocr:!1,use_vision:!0,omit_block_boxes:!1,config:{model:`publishers/google/models/gemini-3.5-flash`},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`},hardness_threshold:.5,window_pages:3,update_properties:!0,min_citation_density:.3,refresh_ocr:!1,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`},coverage_threshold:.2}}},rendering_template:`# Invoice {{properties.invoice_number}}
|
|
1394
1394
|
|
|
1395
1395
|
- Vendor: {{properties.vendor_name}}
|
|
1396
1396
|
- Total: {{properties.currency}} {{properties.total_amount}}
|
|
1397
|
-
- Due: {{properties.due_date}}`,embeddings:{text:!0,image:!1,properties:!0},generate_toc:!1,default_view:`auto`}}],
|
|
1398
|
-
`):`The intake policy does not match the schema.`}function
|
|
1397
|
+
- Due: {{properties.due_date}}`,embeddings:{text:!0,image:!1,properties:!0},generate_toc:!1,default_view:`auto`}}],P3={};function F3({objectType:r,value:a,onSave:s,onIntakeUpdate:c,leadingTabs:l,readonly:u=!1}){let{store:d}=q(),{t:f}=K(),p=nt(),{theme:m}=tt(),h=W(void 0),g=U(()=>U3(),[]),[_,v]=G(!1),y=r?.intake??a,[b,x]=G(()=>H3(y)),[S,C]=G(()=>H3(y)),[T,E]=G(void 0),[D,O]=G(l?.[0]?.name??`classification`),k=b!==S,A=U(()=>{let e=W3(b,g);return e.ok?e.policy:void 0},[b,g]),j=A??y??P3,M=e=>{let t=e,n=t.languages?.json?.jsonDefaults??t.json?.jsonDefaults,r=structuredClone(fn);n?.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:[{uri:`vertesia://schemas/content-type-intake-policy.json`,fileMatch:[`*`],schema:r}]})},N=()=>{let e=W3(D===`json`?h.current?.getValue()??b:b,g);if(!e.ok){E(e.message);return}return E(void 0),e.policy},P=()=>{let e=N();if(!e)return;let t=s??(r?e=>d.types.update(r.id,{intake:e,...r.edit_revision===void 0?{}:{expected_edit_revision:r.edit_revision}}).then(e=>(r.edit_revision=e.edit_revision,e.intake)):void 0);t&&(v(!0),t(e).then(t=>{let n=H3(t??e);x(n),C(n),c?.(t??e),p({status:`success`,title:f(`intakePolicy.toast.updated`),description:f(`intakePolicy.toast.saved`),duration:2e3})}).catch(e=>{p({status:`error`,title:f(`intakePolicy.toast.updateFailed`),description:Ge(e),duration:5e3})}).finally(()=>{v(!1)}))},F=()=>{let e=W3(D===`json`?h.current?.getValue()??b:b,g);E(e.ok?void 0:e.message),p({status:e.ok?`success`:`error`,title:e.ok?f(`intakePolicy.toast.valid`):f(`intakePolicy.toast.invalid`),description:e.ok?f(`intakePolicy.toast.schemaValid`):e.message,duration:3e3})},I=()=>{x(S),h.current?.setValue(S),E(void 0)},L=()=>{let e=N();if(!e)return;let t=H3(e);x(t),h.current?.setValue(t)},ee=e=>{let t=H3(e.value);x(t),h.current?.setValue(t),E(void 0),O(`classification`)},R=e=>{x(H3(e)),E(void 0)},te=e=>{if(l?.some(t=>t.name===e)){O(e);return}let t=e;if(t!==`json`&&!A){E(f(`intakePolicy.error.fixJsonBeforeForm`)),O(`json`);return}O(t)},ne=n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{children:f(`intakePolicy.title`)}),k&&t(i,{variant:`attention`,children:f(`intakePolicy.status.unsaved`)})]}),re=u?void 0:n(e,{children:[t(w,{align:`right`,trigger:n(o,{variant:`outline`,size:`md`,children:[t(Ib,{className:`size-4`}),f(`intakePolicy.action.examples`)]}),children:t(ie,{label:f(`intakePolicy.action.insertExample`),children:N3.map(e=>n(ae,{onClick:()=>ee(e),children:[t(Gg,{className:`size-4`}),n(`div`,{className:`flex flex-col`,children:[t(`span`,{children:f(`intakePolicy.example.${e.key}.label`)}),t(`span`,{className:`text-xs text-muted`,children:f(`intakePolicy.example.${e.key}.description`)})]})]},e.key))})}),D===`json`&&n(e,{children:[n(o,{variant:`outline`,size:`md`,onClick:L,children:[t(Im,{className:`size-4`}),f(`intakePolicy.action.format`)]}),n(o,{variant:`outline`,size:`md`,onClick:F,children:[t(Ih,{className:`size-4`}),f(`intakePolicy.action.validate`)]})]}),n(o,{variant:`outline`,size:`md`,onClick:I,disabled:!k,children:[t(vy,{className:`size-4`}),f(`intakePolicy.action.revert`)]}),t(o,{isLoading:_,size:`md`,onClick:P,disabled:!k,children:f(`intakePolicy.action.save`)})]}),oe=I3(f,A??P3,u,R,b,{editorRef:h,beforeMount:M,onChange:e=>{x(e),E(void 0)},theme:m},(e,r=!1)=>t(me,{title:ne,className:`bg-background! h-full overflow-hidden`,action:re,children:n(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 ${r?`overflow-hidden`:`overflow-auto`}`,children:[T&&t(`div`,{className:`rounded-sm border border-destructive bg-mixer-destructive/10 px-3 py-2 text-sm whitespace-pre-line text-destructive`,children:T}),e]})}));return n(`div`,{className:`flex h-full min-h-0 w-full flex-col gap-2`,children:[t(L3,{policy:j}),n(ze,{tabs:l?[...l,...oe]:oe,current:D,onTabChange:te,updateHash:!1,fullHeight:!0,className:`px-0 min-h-0 flex-1 flex-row!`,children:[t(Be,{className:`py-2 w-48 shrink-0`,direction:`vertical`}),t(Ve,{className:`min-h-0 min-w-0 flex-1 overflow-auto pb-0!`})]})]})}function I3(e,r,i,a,o,s,c){let l=(e,n)=>({name:e,label:n,content:c(t(x3,{policy:r,section:e,onChange:a,readonly:i}))});return[l(`classification`,e(`intakePolicy.tab.classification`)),l(`conversion`,e(`intakePolicy.tab.conversion`)),l(`extraction`,e(`intakePolicy.tab.extraction`)),l(`grounding`,e(`intakePolicy.tab.grounding`)),l(`output`,e(`intakePolicy.tab.output`)),{name:`json`,label:e(`intakePolicy.tab.json`),content:c(n(`div`,{className:`@container flex min-h-0 flex-1 gap-4`,children:[t(`div`,{className:`relative min-w-0 flex-1 overflow-hidden rounded-sm border`,children:t(`div`,{className:`absolute inset-0`,children:t(Pt,{value:o,language:`json`,editorRef:s.editorRef,beforeMount:s.beforeMount,onChange:e=>s.onChange(e.state.doc.toString()),theme:s.theme===`dark`?`vs-dark`:`vs`,options:{readOnly:i,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2}})})}),t(R3,{})]}),!0)}]}function L3({policy:e}){let{t:r}=K(),a=e.extraction?.grounding,o=[[r(`intakePolicy.summary.mode`),V3(r,e.mode)],[r(`intakePolicy.summary.conversion`),B3(r,e.text_conversion?.enabled)],[r(`intakePolicy.summary.method`),V3(r,e.text_conversion?.method)],[r(`intakePolicy.summary.source`),V3(r,e.extraction?.source)],[r(`intakePolicy.summary.extraction`),B3(r,e.extraction?.enabled)],[r(`intakePolicy.summary.grounding`),B3(r,a?.enabled)],[r(`intakePolicy.summary.defaultView`),V3(r,e.default_view)],[r(`intakePolicy.summary.toc`),B3(r,e.generate_toc)],[r(`intakePolicy.summary.template`),e.rendering_template?r(`intakePolicy.option.set`):r(`intakePolicy.option.inherit`)]];return t(`div`,{className:`flex flex-wrap gap-2`,children:o.map(([e,r])=>n(i,{variant:`outline`,className:`gap-1`,children:[n(`span`,{className:`text-muted`,children:[e,`:`]}),t(`span`,{children:r})]},e))})}function R3(){let{t:e}=K();return n(`aside`,{className:`hidden w-80 shrink-0 overflow-y-auto rounded-sm border bg-mixer-muted/20 p-3 text-sm @3xl:block`,children:[t(`div`,{className:`mb-3 font-semibold`,children:e(`intakePolicy.help.title`)}),n(`div`,{className:`space-y-3 text-muted`,children:[t(z3,{label:`identification`,text:e(`intakePolicy.help.identification`)}),t(z3,{label:`text_conversion`,text:e(`intakePolicy.help.textConversion`)}),t(z3,{label:`extraction.source`,text:e(`intakePolicy.help.extractionSource`)}),t(z3,{label:`extraction.grounding`,text:e(`intakePolicy.help.grounding`)}),t(z3,{label:`extraction.grounding.review`,text:e(`intakePolicy.help.review`)}),t(z3,{label:`rendering_template`,text:e(`intakePolicy.help.renderingTemplate`)}),t(z3,{label:`embeddings`,text:e(`intakePolicy.help.embeddings`)}),t(z3,{label:`default_view`,text:e(`intakePolicy.help.defaultView`)})]})]})}function z3({label:e,text:r}){return n(`div`,{children:[t(`div`,{className:`font-medium text-foreground`,children:e}),t(`div`,{children:r})]})}function B3(e,t){return e(t===!0?`intakePolicy.option.enabled`:t===!1?`intakePolicy.option.disabled`:`intakePolicy.option.inherit`)}function V3(e,t){return e(t?`intakePolicy.option.${t}`:`intakePolicy.option.inherit`)}function H3(e){return JSON.stringify(e??P3,null,2)}function U3(){let e=new er({strict:!1,allErrors:!0});return or(e),e.compile(fn)}function W3(e,t){let n;try{n=e.trim()?JSON.parse(e):{}}catch(e){return{ok:!1,message:`Invalid JSON: ${Ge(e)}`}}return t(n)?{ok:!0,policy:n}:{ok:!1,message:G3(t.errors)}}function G3(e){return e?.length?e.map(e=>`${e.instancePath||`/`} ${e.message??`is invalid`}`).join(`
|
|
1398
|
+
`):`The intake policy does not match the schema.`}function K3({objectType:e,onSchemaUpdate:r,readonly:i=!1}){let{store:a}=q(),{t:s}=K(),c=nt(),{theme:l}=tt(),[u,d]=G(!1),f=Jt(e.object_schema),p=W(void 0),[m,h]=G(!1),g=U(()=>q3(f.schema),[f]),_=()=>{m&&!y()||(d(!0),a.types.update(e.id,{object_schema:f.schema,...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision}}).then(t=>{e.edit_revision=t.edit_revision,r(f),c({status:`success`,title:s(`store.schemaUpdated`),description:s(`store.schemaUpdatedSuccess`),duration:2e3})}).catch(e=>{c({status:`error`,title:s(`store.failedToUpdateSchema`),description:e.message,duration:5e3})}).finally(()=>{d(!1)}))},v=()=>{m&&!y()||h(e=>!e)},y=()=>{if(p.current){let e=p.current.getValue();try{let t=J3(e);Y3(t),f.replaceSchema(t)}catch(e){return c({status:`error`,title:s(`store.invalidJsonSchema`),description:Ge(e),duration:5e3}),!1}}return!0},b=n(`div`,{className:`flex gap-2 items-center`,children:[t(`div`,{className:`text-base font-semibold`,children:s(`store.schemaEditor`)}),!i&&t(`div`,{children:t(o,{variant:`outline`,size:`sm`,onClick:v,children:s(m?`store.editSchema`:`store.editJson`)})})]});return t(me,{title:b,className:`bg-background! h-full`,action:i?void 0:t(o,{isLoading:u,variant:`outline`,size:`sm`,onClick:_,children:s(`modal.saveChanges`)}),children:m?t(Pt,{value:g,language:`json`,editorRef:p,theme:l===`dark`?`vs-dark`:`vs`,options:{readOnly:i}}):t(It,{schema:f,readonly:i})})}function q3(e){return e?JSON.stringify(e,null,2):``}function J3(e){if(e?.trim())return JSON.parse(e.trim())}const Y3=e=>{try{new tr({strict:!1}).compile(e)}catch(e){throw Error(`Invalid JSON Schema definition: ${Ge(e)}`,{cause:e})}};Q();function X3({isOpen:e,onClose:r,title:i,children:a,initialSelectedType:s=null,allowNone:c=!0}){let{t:l}=K(),u=i??l(`store.selectContentType`),{registry:d}=rQ(),[f,p]=G(s),m=d?.types||[],h=()=>{r(void 0)};return n(se,{isOpen:e,onClose:h,className:`w-full max-w-xl mx-auto`,children:[t(ue,{children:u}),n(ce,{children:[a,n(`div`,{className:`mb-4 mt-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[l(`store.contentType`),` `,c&&t(`span`,{className:`text-muted font-normal`,children:l(`store.optional`)})]}),c?t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeAuto`),onChange:e=>p(e||null),filterBy:`name`,isClearable:!0}):t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeLabel`),onChange:e=>p(e||null),filterBy:`name`})]}),!f&&n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),l(`store.automaticTypeDetection`),t(We,{description:l(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})]}),n(le,{children:[t(o,{variant:`ghost`,onClick:h,title:l(`modal.cancel`),children:l(`modal.cancel`)}),t(o,{onClick:()=>{r(f?.id??null),p(null)},title:l(`store.confirmSelection`),children:l(`modal.confirm`)})]})]})}function Z3({children:e,limit:n,name:r,chunkable:i}){let{store:a}=q(),o=U(()=>{let e=new s3(a,n);return e.query.name=r,e.query.chunkable=i,e},[i,n,r,a]);return t(c3.Provider,{value:o,children:e})}function Q3({objectType:e,onLayoutUpdate:n,readonly:r=!1}){let i=nt(),{theme:a}=tt(),{t:s}=K(),[c,l]=G(!1),{store:u}=q(),d=W(void 0),f=U(()=>$3(e.table_layout),[e.table_layout]),p=(e,t)=>{i({status:`error`,title:e,description:t,duration:5e3})};return t(me,{title:`Table Layout Editor`,className:`bg-background! h-full`,action:r?void 0:t(o,{isLoading:c,variant:`outline`,size:`sm`,onClick:()=>{if(!d.current)return;let t=d.current.getValue(),r;if(!t)r=null;else try{r=JSON.parse(t)}catch(e){return p(`Invalid JSON`,Ge(e))}if(!Array.isArray(r))return p(`Invalid JSON`,`The table layout must be an array`);if(r.some(e=>!e?.name||!e.field))return p(`Invalid JSON`,`A table layout entry must contain the following properties:] {field, name, converter?}`);l(!0),u.types.update(e.id,{...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision},table_layout:r}).then(t=>{e.edit_revision=t.edit_revision,i({status:`success`,title:s(`store.tableLayoutUpdated`),description:s(`store.tableLayoutUpdatedDesc`),duration:2e3}),n(t.table_layout)}).catch(e=>{i({status:`error`,title:s(`store.failedToUpdateTableLayout`),description:e.message,duration:5e3})}).finally(()=>{l(!1)})},children:s(`store.saveChanges`)}),children:t(`div`,{className:`h-full`,children:t(Pt,{value:f,language:`json`,editorRef:d,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:r}})})})}function $3(e){return e?JSON.stringify(e,null,2):`[
|
|
1399
1399
|
|
|
1400
|
-
]`}function J3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(void 0),[s,c]=G(e.shared_properties||[]),l=nt();H(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(me,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(He,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function Y3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(e.skip_head_sync??!1),[o,s]=G(!1),c=nt();return t(me,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Ne,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function X3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z3({refetch:r,collection:a}){let{t:s}=K(),c=a.type?En(a.type):void 0,l=W(void 0),u=nt(),{theme:d}=tt(),{client:f}=q(),p=_t(R$),[m,h]=G(!1),[g,_]=G({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?En(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=G(``),b=U(()=>q3(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!X3(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:Ge(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:Ge(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(me,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(VZ,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(VZ,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(L,{label:s(`type.name`),required:!0,children:t(te,{value:g.name,onChange:e=>S(`name`,e)})}),t(L,{label:s(`type.description`),children:t(Ue,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(L,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(q4,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(L,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(Ue,{className:Me.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(L,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(Pt,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(L,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(q4,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(L,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(we,{options:Sn.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${Sn[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(L,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(te,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(Q3,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(Y3,{collection:a}),t(J3,{collection:a})]})]})}function Q3({typeId:e,collection:n}){let{t:r}=K(),[i,a]=G({}),s=nt(),{client:c}=q(),[l,u]=G(!1),{data:d,error:f}=Ye(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=U(()=>new Mt(p,n.properties||{}),[p,n.properties]);if(f)return t(M,{title:r(`store.failedToLoadType`),children:Ge(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(me,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(kt,{object:m,onChange:e=>{e instanceof Mt&&a(e.value)}})})}Q();function $3({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:d}=q(),{t:f}=K(),p=a??f(`store.selectACollection`),m=s??f(`store.searchCollections`),[b,x]=G(``),[S,C]=G(!1),[w,T]=G(!1),E=Je(b,300),D=V(async e=>{C(!0);let t=e.trim(),n=await d.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[d,l,c,w]),{data:O,error:k}=Ye(()=>D(w?E:``),[w?E:``,D]),A=U(()=>O?u&&Array.isArray(r)?O.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?O.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[O,r,u]),j=V(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,O?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,O?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,O,u]),N=V(()=>{e(void 0,void 0)},[e]),P=V(e=>{x(e)},[]),F=b.trim().length>0,I=U(()=>{if(!O)return[];if(w||!F)return O;let e=b.toLowerCase();return O.filter(t=>t.name.toLowerCase().includes(e))},[O,w,F,b]),L=u?Array.isArray(A)&&A.length>0:!!A;return k?t(M,{title:f(`store.collectionFetchFailed`),children:Ge(k)}):n(he,{children:[t(_e,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:z(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(A)&&A.length>0?A.length===1?A[0].name:f(`store.collectionsSelected`,{count:A.length}):!u&&A&&!Array.isArray(A)?A.name:p}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(Gb,{className:`h-4 w-4`})}):t(wh,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(ge,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(h,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(v,{placeholder:m,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(g,{children:f(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(_,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(y,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(y,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:f(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(y,{value:e.id,onSelect:()=>j(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(eh,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function e6({isOpen:e,onClose:r}){return n(se,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(ue,{children:`Select Content`}),t(ce,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(o1,{onChange:r})})]})}Q();const t6=/store:([a-f0-9]+)/;function n6({object:e}){let{client:r}=q(),{off:i,on:a,isOn:s}=Ze(),[c,l]=G(e.value==null?``:String(e.value)),[u,d]=G(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=V(()=>{l(``),e.value=``,d(void 0)},[e]);return H(()=>{if(!c||u)return;let e=c.match(t6);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:it(Me.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-destructive hover:bg-muted`,children:t(Gb,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-muted`,children:t(wh,{className:`size-5`})})}),t(e6,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 font-semibold text-sm text-muted dark:text-foreground`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}Q();function r6({objectId:e,isOpen:r,onClose:i}){let a=Qn(),{client:s,store:c}=q(),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(),[_,v]=G(),[y,b]=G(`preview`),{t:x}=K(),S=nt(),C=V(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=V(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:mn.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);H(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
|
|
1400
|
+
]`}function e6({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(void 0),[s,c]=G(e.shared_properties||[]),l=nt();H(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(me,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(He,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function t6({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(e.skip_head_sync??!1),[o,s]=G(!1),c=nt();return t(me,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Ne,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function n6(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function r6({refetch:r,collection:a}){let{t:s}=K(),c=a.type?En(a.type):void 0,l=W(void 0),u=nt(),{theme:d}=tt(),{client:f}=q(),p=_t(z$),[m,h]=G(!1),[g,_]=G({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?En(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=G(``),b=U(()=>$3(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!n6(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:Ge(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:Ge(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(me,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(HZ,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(HZ,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(L,{label:s(`type.name`),required:!0,children:t(te,{value:g.name,onChange:e=>S(`name`,e)})}),t(L,{label:s(`type.description`),children:t(Ue,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(L,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(Q4,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(L,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(Ue,{className:Me.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(L,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(Pt,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(L,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(Q4,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(L,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(we,{options:Sn.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${Sn[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(L,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(te,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(i6,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(t6,{collection:a}),t(e6,{collection:a})]})]})}function i6({typeId:e,collection:n}){let{t:r}=K(),[i,a]=G({}),s=nt(),{client:c}=q(),[l,u]=G(!1),{data:d,error:f}=Ye(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=U(()=>new Mt(p,n.properties||{}),[p,n.properties]);if(f)return t(M,{title:r(`store.failedToLoadType`),children:Ge(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(me,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(kt,{object:m,onChange:e=>{e instanceof Mt&&a(e.value)}})})}Q();function a6({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:d}=q(),{t:f}=K(),p=a??f(`store.selectACollection`),m=s??f(`store.searchCollections`),[b,x]=G(``),[S,C]=G(!1),[w,T]=G(!1),E=Je(b,300),D=V(async e=>{C(!0);let t=e.trim(),n=await d.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[d,l,c,w]),{data:O,error:k}=Ye(()=>D(w?E:``),[w?E:``,D]),A=U(()=>O?u&&Array.isArray(r)?O.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?O.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[O,r,u]),j=V(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,O?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,O?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,O,u]),N=V(()=>{e(void 0,void 0)},[e]),P=V(e=>{x(e)},[]),F=b.trim().length>0,I=U(()=>{if(!O)return[];if(w||!F)return O;let e=b.toLowerCase();return O.filter(t=>t.name.toLowerCase().includes(e))},[O,w,F,b]),L=u?Array.isArray(A)&&A.length>0:!!A;return k?t(M,{title:f(`store.collectionFetchFailed`),children:Ge(k)}):n(he,{children:[t(_e,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:z(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(A)&&A.length>0?A.length===1?A[0].name:f(`store.collectionsSelected`,{count:A.length}):!u&&A&&!Array.isArray(A)?A.name:p}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(Gb,{className:`h-4 w-4`})}):t(wh,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(ge,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(h,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(v,{placeholder:m,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(g,{children:f(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(_,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(y,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(y,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:f(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(y,{value:e.id,onSelect:()=>j(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(eh,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function o6({isOpen:e,onClose:r}){return n(se,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(ue,{children:`Select Content`}),t(ce,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(s1,{onChange:r})})]})}Q();const s6=/store:([a-f0-9]+)/;function c6({object:e}){let{client:r}=q(),{off:i,on:a,isOn:s}=Ze(),[c,l]=G(e.value==null?``:String(e.value)),[u,d]=G(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=V(()=>{l(``),e.value=``,d(void 0)},[e]);return H(()=>{if(!c||u)return;let e=c.match(s6);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:it(Me.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-destructive hover:bg-muted`,children:t(Gb,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-muted`,children:t(wh,{className:`size-5`})})}),t(o6,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 font-semibold text-sm text-muted dark:text-foreground`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}Q();function l6({objectId:e,isOpen:r,onClose:i}){let a=Qn(),{client:s,store:c}=q(),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(),[_,v]=G(),[y,b]=G(`preview`),{t:x}=K(),S=nt(),C=V(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=V(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:mn.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);H(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
|
|
1401
1401
|
#`)||h.includes(`
|
|
1402
|
-
*`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-muted shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-border bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(Gg,{className:`h-5 w-5 text-info me-2`}),t(`h2`,{className:`text-lg font-semibold text-foreground truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-info hover:text-info`,children:[t(lv,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-muted hover:text-foreground dark:text-foreground`,children:t(Gb,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(je,{size:`lg`,className:`text-info mb-2`}),t(`p`,{className:`text-muted`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(I_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(A_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-muted prose-pre:my-2 prose-headings:text-info dark:prose-invert`,children:t(Nt,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-foreground`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-border rounded-md p-2 bg-white dark:bg-muted`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-info mb-4`}),t(`p`,{className:`text-muted text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:t(jt,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(A_,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-muted`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.id}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?i6(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-muted dark:border-border`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-info border-primary hover:bg-info`,children:[t(xg,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:[x(`store.openFullDocument`),t(lh,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function i6(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var a6;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(a6||={});function o6({isExporting:e,isOpen:r,onClose:i,allowExportAll:a=!0}){return n(se,{onClose:()=>i(void 0),isOpen:r,children:[t(ue,{children:`Export Object Properties`}),n(ce,{children:[!e&&t(s6,{onClose:i,allowExportAll:a}),e&&t(c6,{})]})]})}function s6({onClose:e,allowExportAll:r}){let{t:i}=K(),[a,s]=G(void 0),c=[`Export selected objects`,`Export all objects`],[l,u]=G(r?void 0:c[0]),d=e=>e===c[1];return n(ce,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[r&&t(`div`,{className:`h-1/3`,children:t(we,{options:c,value:l,onChange:u,placeholder:i(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(we,{options:Object.values(a6),value:a,onChange:s,placeholder:i(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!a||!l,onClick:()=>{e(a,d(l))},children:i(`store.actions.exportProperties`)})]})]})}function c6(){let{t:e}=K();return t(ce,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(je,{size:`lg`})]})})}const l6=dt(void 0);function u6(){let e=_t(l6);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function d6(e,t){let n=u6();return H(()=>n.registerCallback(e,t),[n,e,t]),n}function f6({action:e,objectIds:n}){let[r,i]=G(!1),a=V(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return d6(e.id,a),r&&t(ve,{children:t(h6,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const p6=Xt.getFixedT(null,Yt),m6={id:`addToCollection`,name:p6(`store.actions.addToCollection`),description:p6(`store.actions.addToCollectionDesc`),confirm:!1,component:f6};function h6({isOpen:e,onClose:r,objectIds:i}){let{t:a}=K();return n(se,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(ue,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(S,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(g6,{onClose:r,objectIds:i})})]})}function g6({onClose:e,objectIds:r}){let{t:i}=K(),a=nt(),{client:s}=q(),[c,l]=G(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})},d=[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(ee,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(ce,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t($3,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(le,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t(J4,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}];return n(ze,{defaultValue:`select`,tabs:d,fullWidth:!0,children:[t(Be,{}),t(Ve,{})]})}function _6({action:e,objectIds:r,children:i}){let{t:a}=K(),{store:o}=q(),s=nt(),[c,l]=G(!1),u=V(()=>(l(!0),Promise.resolve(!0)),[]);return d6(e.id,u),n(`div`,{children:[i,t(W3,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const v6=Xt.getFixedT(null,Yt),y6={id:`changeType`,name:v6(`store.actions.changeContentType`),description:v6(`store.actions.changeContentTypeDesc`),confirm:!1,component:_6};function b6({action:r,callback:i,children:a}){let{t:o}=K(),[s,c]=G(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=V(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=d6(r.id,u);return n(e,{children:[a,t(b,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function x6({action:r,objectIds:i,children:a}){let{t:o}=K(),s=u6(),c=nt(),{client:l}=q(),u=z$(),d=Qn(),[f,p]=G(!1),m=i?.length??0,h=s.params?.type?.name??`object`,g=V(()=>(p(!0),Promise.resolve(!0)),[]);d6(r.id,g);let _=V(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let t=JSON.parse(JSON.stringify(u.facets));i.length===t._value.total&&u.resetFacets();let n=new Set(e.failed);u.removeDeletedObjects(i.filter(e=>!n.has(e))),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(b,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:_,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const S6=Xt.getFixedT(null,Yt),C6={id:`delete`,name:S6(`store.actions.delete`),description:S6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:S6(`store.actions.confirmDeleteAll`),component:x6,destructive:!0},w6={id:`deleteFromCollections`,name:S6(`store.actions.deleteObjects`),description:S6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:S6(`store.actions.confirmDeleteSelected`),component:x6,destructive:!0};function T6({action:e,objectIds:n}){let{t:r}=K(),{store:i}=q(),a=nt(),[o,s]=G(!1),[c,l]=G(!1),u=V(()=>(s(!0),Promise.resolve(!0)),[]),d=d6(e.id,u);return t(o6,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const E6=Xt.getFixedT(null,Yt),D6={id:`exportProperties`,name:E6(`store.actions.exportProperties`),description:E6(`store.actions.exportAllObjectProperties`),confirm:!1,component:T6};function O6({action:e,objectIds:n,collectionId:r}){let{t:i}=K(),a=u6(),o=nt(),{client:s}=q(),c=z$(),l=V(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:Ge(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o]);return t(b6,{action:e,callback:l})}const k6=Xt.getFixedT(null,Yt),A6={id:`removeFromCollection`,name:k6(`store.actions.removeFromCollection`),description:k6(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:k6(`store.actions.confirmRemoveFromCollection`),component:O6,destructive:!0};var j6=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const M6=[D6,y6,m6,C6,A6,w6];function N6({children:e,type:r}){let i=ZQ(),a=nt(),{client:o}=q(),s=z$(),c=U(()=>{let e=new j6({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=M6,e},[o,s,i,a,r]);return c&&n(l6.Provider,{value:c,children:[t(P6,{}),e]})}function P6(){let e=u6(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}function F6(){let{t:r}=K(),i=ZQ(),[a,s]=G(!1);return i?.hasSelection()?n(e,{children:[t(o,{onClick:()=>s(!0),children:r(`store.actions.startWorkflow`)}),a&&t(I6,{objectIds:i.getObjectIds(),onClose:()=>s(!1)})]}):null}function I6({objectIds:e,onClose:r}){let{t:i}=K(),{client:a}=q(),s=nt(),[c,l]=G(void 0),[u,d]=G(!1),{data:f,isLoading:p}=Ye(()=>a.store.workflows.rules.list(),[]);return n(se,{isOpen:!0,onClose:r,size:`lg`,children:[t(ue,{children:i(`store.actions.startWorkflowByRule`)}),n(ce,{children:[t(`div`,{className:`pb-2`,children:i(`store.actions.chooseWorkflowRule`)}),p?t(`div`,{className:`flex justify-center py-4`,children:t(je,{})}):t(`div`,{className:`max-h-[420px] overflow-y-auto border-border border rounded-md`,children:t(Te,{className:`text-start w-full`,options:f??[],value:c,onChange:l,optionLayout:e=>({label:e.name})})})]}),n(le,{align:`right`,children:[t(o,{variant:`outline`,onClick:r,disabled:u,children:`Cancel`}),t(o,{onClick:async()=>{if(!(!c||u)){d(!0);try{await a.store.workflows.rules.execute(c.id,e),s({title:i(`store.actions.workflowStarted`),status:`success`,duration:3e3}),r()}catch(e){s({title:i(`store.actions.errorStartingWorkflow`),description:e instanceof Error?e.message:void 0,status:`error`,duration:9e3})}finally{d(!1)}}},isDisabled:!c||u,isLoading:u,children:`Start`})]})]})}Q();function L6({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=ZQ(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(N6,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(Gb,{className:`size-4`})})]}),a&&t(F6,{}),t(B6,{selection:s,allowMutations:r,allowDelete:i,children:e=>e.length>0?t(o,{variant:`ghost`,title:`More action`,size:`sm`,children:t(wg,{size:16})}):null})]})})}function R6({collectionId:r,allowFolders:i=!0}){let{t:a}=K(),[s,c]=G([]),[l,u]=G(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(J$,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function z6(e){return{label:e.name,className:it(`flex-1 px-2 py-2 hover:bg-muted nowrap`,e.destructive?`text-destructive`:``)}}function B6({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0}){let o=u6(),s=e=>{o.run(e.id)},c=H6(o.actions,e,{allowMutations:i,allowDelete:a}),l=r(c);return l?n(he,{hover:!0,children:[t(_e,{children:l}),t(ge,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(V6,{executeAction:s,actions:c})})]}):null}function V6({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(Te,{options:n,optionLayout:z6,onChange:t=>{e(t)},noCheck:!0})})})}function H6(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[D6]}function U6({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:(()=>{if(e.picture)return t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name});{let n=e.name.split(` `).map(e=>e[0]).join(``);return t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:n})})}})()}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-foreground group-hover:text-foreground`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-muted dark:text-foreground group-hover:text-foreground`,children:e.email??`Deleted User`})]})]})}Q();const W6=dt(void 0);function G6(){return _t(W6)}function K6(e,t){let n=e.requires_selection??(e.placement===`toolbar`?`none`:`any`);return n===`none`?!0:n===`single`?t.length===1:n===`multiple`?t.length>1:t.length>0}function q6(e){let t=window.URL.createObjectURL(new Blob([e.data],{type:e.type})),n=document.createElement(`a`);n.download=e.name,n.href=t,n.click(),window.setTimeout(()=>window.URL.revokeObjectURL(t),0)}function J6({children:e,definition:r,request:i,result:a,selection:o,contributions:s,client:c,canDelete:l,refresh:u}){let{t:d}=K(),f=nt(),[p,m]=G(),[h,g]=G(),[_,v]=G(!1),[y,x]=G(),S=W(!1),C=r.results?.actions,w=U(()=>({definition:r,request:i,result:a,refresh:u,clearSelection:()=>o?.clear()}),[r,u,i,a,o]),T=U(()=>{let e=(C?.items??[]).filter(e=>{let t=s?.actions?.[e.handler];return t!==void 0&&(t.isAvailable?.(w)??!0)});if(!o||C?.include_defaults===!1||!c)return e;let t=new Set(C?.exclude_defaults??[]),n=[];return t.has(`export`)||n.push({id:`export`,label:d(`store.actions.exportProperties`),handler:`export`,placement:`selection`,requires_selection:`any`}),l&&!t.has(`delete`)&&n.push({id:`delete`,label:d(`store.actions.delete`),handler:`delete`,placement:`selection`,requires_selection:`any`,destructive:!0,confirm:!0}),[...n,...e]},[C,w,l,c,s?.actions,o,d]),E=V(async({action:e,hits:t})=>{if(!S.current){S.current=!0,x(e.id);try{if(e.handler===`delete`){if(!c)return;let e=await c.store.objects.delete(t.map(e=>e.id));f({status:e.failed.length>0?`warning`:`success`,title:d(`view.deletedObjects`,{count:e.deleted})}),o?.clear(),await u();return}let n=s?.actions?.[e.handler];if(!n)return;await n.run({...w,action:e,hits:t})}catch(e){console.error(`View action failed:`,e),f({status:`error`,title:d(`view.actionFailed`),description:d(`view.actionFailedDescription`)})}finally{S.current=!1,x(void 0),m(void 0)}}},[w,c,s?.actions,u,o,d,f]),D=V((e,t)=>{if(!(!K6(e,t)||S.current)){if(e.handler===`export`){g(t);return}if(e.confirm){m({action:e,hits:t});return}E({action:e,hits:t})}},[E]),O=V(e=>{if(!e||!h?.length||!c){g(void 0);return}v(!0),c.store.objects.exportProperties({objectIds:h.map(e=>e.id),type:e}).then(e=>{q6(e),f({status:`success`,title:d(`store.actions.exportProperties`)}),g(void 0)}).catch(e=>{console.error(`View export failed:`,e),f({status:`error`,title:d(`store.actions.errorExportProperties`),description:d(`view.actionFailedDescription`)})}).finally(()=>v(!1))},[c,h,d,f]),k=U(()=>({actions:T,runningActionId:y,run:D}),[T,D,y]);return n(W6.Provider,{value:k,children:[e,t(o6,{isOpen:h!==void 0,isExporting:_,onClose:O,allowExportAll:!1}),t(b,{isOpen:p!==void 0,title:p?.action.label??d(`modal.confirm`),content:d(`view.confirmAction`,{action:p?.action.label??``,count:p?.hits.length??0}),isLoading:y!==void 0,onConfirm:()=>{p&&E(p)},onCancel:()=>m(void 0),confirmationValue:p?.action.handler===`delete`?`delete`:void 0,confirmationLabel:p?.action.handler===`delete`?d(`view.typeDeleteToConfirm`):void 0,confirmationPlaceholder:p?.action.handler===`delete`?`delete`:void 0})]})}function Y6({selection:r,page:i,showSelectPage:a=!1}){let{t:s}=K(),c=G6(),l=vt();if(!c)return null;let u=r?.selectedHits??[],d=r?i.filter(e=>r.isSelected(e.id)).length:0,f=i.length>0&&d===i.length,p=a&&r?.selectAll&&i.length>0,h=c.actions.filter(e=>((e.placement??`selection`)===`toolbar`||(e.placement??`selection`)===`selection`&&u.length>0)&&K6(e,u));return h.length===0&&u.length===0&&!p?null:n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p&&r&&n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:l,checked:f?!0:d>0&&`indeterminate`,onCheckedChange:e=>r.togglePage(i,e===!0)}),t(`label`,{htmlFor:l,className:`text-sm text-muted`,children:s(`view.selectPage`)})]}),u.length>0&&n(e,{children:[t(`span`,{className:`text-sm text-muted`,children:s(`view.selectedCount`,{count:u.length})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`view.clearSelection`),onClick:r?.clear,children:t(Gb,{className:`size-4`})})]}),h.map(e=>n(o,{type:`button`,variant:e.destructive?`destructive`:`outline`,size:`sm`,disabled:c.runningActionId!==void 0,onClick:()=>c.run(e,u),children:[e.handler===`export`&&t(xg,{className:`size-4`}),e.handler===`delete`&&t(hb,{className:`size-4`}),e.label]},e.id))]})}function X6({hit:e}){let{t:r}=K(),i=G6(),a=i?.actions.filter(t=>(t.placement??`selection`)===`row`&&K6(t,[e]));return!i||!a?.length?null:n(he,{children:[t(_e,{children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r(`view.actions`),children:t(wg,{className:`size-4`})})}),t(ge,{className:`w-52 p-1`,align:`end`,sideOffset:6,children:t(Te,{options:a,optionLayout:e=>({label:e.label,className:e.destructive?`text-destructive`:void 0}),onChange:t=>i.run(t,[e]),noCheck:!0})})]})}function Z6(e){return e.dataTransfer.items?Array.from(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null):Array.from(e.dataTransfer.files)}function Q6({children:r,definition:i,request:a,result:o,contribution:s,canWrite:c,refresh:l}){let{t:u}=K(),d=nt(),f=i.results?.drop,p=f?.handler===`upload`&&c,m=s!==void 0||p,[h,g]=G(!1),[_,v]=G(!1),[y,b]=G([]),x=W(!1),S=V(async e=>{if(e.length){if(s){if(x.current)return;x.current=!0,v(!0);try{await s.run({configuration:f,files:e,definition:i,request:a,result:o,refresh:l})}catch(e){console.error(`View drop action failed:`,e),d({status:`error`,title:u(`view.dropFailed`),description:u(`view.actionFailedDescription`)})}finally{x.current=!1,v(!1)}return}p&&b(e)}},[p,f,s,i,l,a,o,u,d]);if(!m)return r;let C=f?.params;return n(e,{children:[n(`div`,{className:`relative min-h-48`,onDragEnter:e=>{e.preventDefault(),g(!0)},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:e=>{e.preventDefault(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),g(!1),!e.target.closest(`[data-view-drop-zone]`)&&S(Z6(e))},children:[r,_&&t(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-background/80`,children:t(je,{size:`xl`})}),t(`div`,{"data-view-drop-zone":!0,className:`pointer-events-none absolute inset-0 ${h?`z-50`:`-z-10`}`,children:t(Ot,{onDrop:e=>void S(e),message:u(`view.dropFiles`),buttonLabel:u(`view.selectFiles`),allowFolders:C?.allow_folders??!0,className:`pointer-events-auto absolute inset-0 bg-background/90 ${h?`flex`:`hidden`}`})})]}),p&&t(J$,{isOpen:y.length>0,onClose:()=>b([]),files:y,collectionId:C?.collection_id,selectedFolder:C?.location,initialTypeId:C?.type_id,defaultProperties:C?.properties,allowFolders:C?.allow_folders??!0,title:u(`view.uploadToView`),onUploadComplete:e=>{e.success&&l()}})]})}Q();function $6(e,t,n,r){return n?r===!1?[t]:e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function e8({node:e}){return n(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[t(`span`,{className:`truncate`,children:e.label}),t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]})}function t8({configuration:e,result:r,isLoading:i,onChange:a,onQueryChange:s}){let{t:c}=K(),l=vt(),u=e.presentation??(e.source===`location`||e.source===`hierarchy`?`tree`:`list`),d=e.source!==`hierarchy`&&e.multi_select,f=r.breadcrumbs??[],[p,h]=G(r.query??``);H(()=>{h(r.query??``)},[r.query]);let g=(e,t)=>{a($6(r.selected,e,t,d))};return n(`section`,{className:`space-y-2`,"aria-labelledby":`${l}-label`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h2`,{id:`${l}-label`,className:`text-sm font-semibold`,children:e.label}),r.selected.length>0&&n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([]),"aria-label":`${c(`filter.clearAll`)}: ${e.label}`,children:[t(Gb,{className:`size-3.5`}),c(`filter.clearAll`)]})]}),e.source===`collection`&&s&&n(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),s?.(p.trim())},children:[t(te,{value:p,onChange:h,disabled:i,placeholder:c(`view.filterNavigation`,{label:e.label}),"aria-label":c(`view.filterNavigation`,{label:e.label})}),t(o,{type:`submit`,variant:`outline`,size:`icon`,disabled:i,"aria-label":c(`view.searchNavigation`,{label:e.label}),children:t(Ay,{"aria-hidden":`true`,className:`size-4`})})]}),f.length>0&&t(`nav`,{"aria-label":`${e.label} path`,children:t(`ol`,{className:`flex flex-wrap items-center gap-1 text-sm`,children:f.map((e,r)=>n(`li`,{className:`flex items-center gap-1`,children:[r>0&&t(lh,{"aria-hidden":`true`,className:`size-3.5 text-muted`}),t(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([e.id]),"aria-current":r===f.length-1?`page`:void 0,children:e.label})]},e.id))})}),r.selected.length>0&&f.length===0&&(e.source===`location`||e.source===`collection`)&&t(`div`,{className:`flex flex-wrap gap-1`,children:r.selected.map(e=>{let a=r.nodes.find(t=>t.id===e)?.label??e;return n(o,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>g(e,!1),"aria-label":c(`view.removeSelection`,{value:a}),children:[a,t(Gb,{"aria-hidden":`true`,className:`size-3.5`})]},e)})}),u===`select`&&d===!1?t(we,{options:r.nodes,value:r.nodes.find(e=>r.selected.includes(e.id)),onChange:e=>a([e.id]),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`select`?t(we,{multiple:!0,options:r.nodes,value:r.nodes.filter(e=>r.selected.includes(e.id)),onChange:e=>a(e.map(e=>e.id)),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`chips`?t(`div`,{className:`flex flex-wrap gap-2`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`outline`,size:`sm`,disabled:i,onClick:()=>g(e.id,!r.selected.includes(e.id)),children:[e.label,t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]},e.id))}):e.source===`hierarchy`?t(`div`,{className:`space-y-1`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`ghost`,className:`w-full justify-start`,disabled:i,onClick:()=>a([e.id]),children:[t(e8,{node:e}),e.expandable&&t(lh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted`})]},e.id))}):t(`div`,{className:`space-y-1`,children:r.nodes.map((e,a)=>{let o=`${l}-${a}`;return n(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted`,children:[t(m,{id:o,checked:r.selected.includes(e.id),disabled:i,onCheckedChange:t=>g(e.id,t===!0)}),t(`label`,{htmlFor:o,className:`flex min-w-0 flex-1 cursor-pointer text-sm`,children:t(e8,{node:e})})]},e.id)})}),r.nodes.length===0&&t(`p`,{className:`text-sm text-muted`,children:c(`filter.noAvailableFilters`)})]})}const n8=`display`,r8=`sort`,i8=`offset`;function a8(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function o8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.getAll(r).filter(e=>e!==``);i.length>0&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function s8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.get(r)?.trim();i&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function c8(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`q`)?.trim(),r=t.get(n8)?.trim(),i=t.get(r8)?.trim(),a=a8(t.get(i8)),o=o8(t,`t.`),s=o8(t,`n.`),c=s8(t,`nq.`);return{...n?{query:n}:{},...o?{key_terms:o}:{},...s?{navigation:s}:{},...c?{navigation_queries:c}:{},...r?{display:r}:{},...i?{sort:i}:{},...a?{offset:a}:{}}}function l8(e){for(let t of[...e.keys()])(t===`q`||t===n8||t===r8||t===i8||t.startsWith(`t.`)||t.startsWith(`nq.`)||t.startsWith(`n.`))&&e.delete(t)}function u8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))for(let n of i)n!==``&&e.append(`${t}${r}`,n)}function d8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))i.trim()&&e.set(`${t}${r}`,i.trim())}function f8(e,t=``){let n=new URLSearchParams(t.startsWith(`?`)?t.slice(1):t);l8(n),e.query?.trim()&&n.set(`q`,e.query.trim()),e.display&&n.set(n8,e.display),e.sort&&n.set(r8,e.sort),e.offset&&e.offset>0&&n.set(i8,String(e.offset)),u8(n,`t.`,e.key_terms),u8(n,`n.`,e.navigation),d8(n,`nq.`,e.navigation_queries);let r=n.toString();return r?`?${r}`:``}function p8(e){let t=Object.fromEntries(Object.entries(e.navigation).filter(([,e])=>e.selected.length>0).map(([e,t])=>[e,t.selected]));return Object.keys(t).length>0?t:void 0}function m8(e){let t={};for(let[n,r]of Object.entries(e.navigation))r.query&&(t[n]=r.query);return Object.keys(t).length>0?t:void 0}function h8(e,t){let n=new Set(t.definition.search?.key_terms?.map(e=>e.id)??[]),r=e.key_terms?Object.fromEntries(Object.entries(e.key_terms).filter(([e,t])=>n.has(e)&&t.length)):void 0,i=p8(t),a=m8(t);return{...e.query?.trim()?{query:e.query.trim()}:{},...r&&Object.keys(r).length>0?{key_terms:r}:{},...i?{navigation:i}:{},...a?{navigation_queries:a}:{},...t.display?{display:t.display}:{},...t.sort?{sort:t.sort}:{},...e.offset&&e.offset>0?{offset:e.offset}:{},...e.limit?{limit:e.limit}:{}}}function g8(e,t,n){return t.sort??e.sort??(e.query?.trim()?void 0:n)}function _8(e){if(typeof window>`u`)return;let t=f8(e,window.location.search);window.history.replaceState(window.history.state||{},``,`${window.location.pathname}${t}`)}Q();function v8(e,t){return!t||t===`.`?e:t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`||Array.isArray(e)))return e[t]},e)}function y8(e,t){return t===`score`?e.score:t.startsWith(`annotation.`)?v8(e.annotation,t.slice(11)):t.startsWith(`document.`)?v8(e.document,t.slice(9)):v8(e.document,t)}const b8=dt(void 0);function x8(e){if(e!=null&&e!==``)return Array.isArray(e)?e.map(x8).filter(Boolean).join(`, `):typeof e==`object`?JSON.stringify(e):String(e)}function S8(e,t,n){let r=y8(e,t.field),i=t.fallback??``;if(r==null||r===``)return i;if(t.format===`date`){let e=String(r),t=/^\d{4}-\d{2}-\d{2}$/.test(e),a=new Date(e);if(Number.isNaN(a.getTime()))return x8(r)??i;let o={year:`numeric`,month:`numeric`,day:`numeric`,...t?{timeZone:`UTC`}:{}};return n?.formatDate(a,o)??new Intl.DateTimeFormat(void 0,o).format(a)}if(t.format===`number`){let e=typeof r==`number`?r:Number(r);return Number.isFinite(e)?n?.formatNumber(e)??new Intl.NumberFormat().format(e):x8(r)??i}return x8(r)??i}function C8({hit:e,field:n,className:r}){let a=S8(e,n,_t(b8));return a?n.format===`badge`||n.format===`content_type`?t(i,{className:r,children:a}):t(`span`,{className:r,children:a}):null}function w8({hit:e,onOpenHit:r,compact:i=!1}){let{t:a}=K();return r?i?t(We,{description:a(`agent.openDocument`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`agent.openDocument`),onClick:()=>r(e),children:t(Dg,{className:`size-4`})})}):n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),children:[t(Dg,{className:`size-4`}),a(`agent.openDocument`)]}):null}function T8(e,t){if(t.source!==`property`||!t.field)return;let n=x8(y8(e,t.field));if(n)try{let e=new URL(n,typeof window>`u`?`https://localhost`:window.location.origin);return e.protocol===`http:`||e.protocol===`https:`?e.toString():void 0}catch{return}}const E8=new WeakMap,D8=[2e3,4e3,8e3];function O8(e){let t=E8.get(e);if(t)return t;let n=new Map;return E8.set(e,n),n}function k8(e,t,n){let r=O8(e),i=r.get(t);if(i)return i;let a=n().finally(()=>{r.delete(t)});return r.set(t,a),a}function A8({hit:e,media:n,resolveMedia:r,className:i}){let a=n?T8(e,n):void 0,[o,s]=G(),[c,l]=G(!1),u=!a&&n?`${e.id}|${JSON.stringify(n)}`:void 0,d=W(e),f=W(n);d.current=e,f.current=n,H(()=>{if(s(void 0),l(!1),!u||!r)return;let e=!0,t,n=i=>{k8(r,u,async()=>r(d.current,f.current)).then(r=>{if(!e)return;if(r){s(r);return}let a=D8[i];a!==void 0&&(t=setTimeout(()=>n(i+1),a))}).catch(()=>{e&&l(!0)})};return n(0),()=>{e=!1,t&&clearTimeout(t)}},[u,r,a]);let p=c?void 0:a??o,m=n?.fit===`contain`?`object-contain`:`object-cover`;if(p)return t(`img`,{src:p,alt:``,className:`${m} ${i??``}`,onError:()=>l(!0)});let h=n?.source===`type_icon`?`type_icon`:n?.fallback??`type_icon`;return h===`none`?null:t(`div`,{className:`flex items-center justify-center bg-muted ${i??``}`,"aria-hidden":`true`,children:t(h===`placeholder`?D_:Gg,{className:`size-10 text-muted`})})}function j8({hit:e}){let n=e.annotation?.why_match??e.annotation?.answer??e.annotation?.excerpt;return n?t(`p`,{className:`text-sm text-info`,children:n}):null}function M8({hit:e,page:n,selection:r}){let{t:i}=K(),a=W(!1);return r?t(m,{checked:r.isSelected(e.id),"aria-label":i(`view.selectResult`,{name:e.document.name}),onClick:e=>{a.current=e.shiftKey,e.stopPropagation()},onCheckedChange:t=>{r.toggle(e,t===!0,{page:n,range:r.mode===`multiple`&&a.current}),a.current=!1}}):null}function N8({hit:e,fields:n}){return n?.length?t(`div`,{className:`flex flex-wrap gap-1`,children:n.map(n=>t(C8,{hit:e,field:n},`${n.field}-${n.label??``}`))}):null}function P8({hit:e,fields:r}){let i=_t(b8);return r?.length?t(`dl`,{className:`space-y-1 text-sm`,children:r.map(r=>{let a=S8(e,r,i);return a?n(`div`,{className:`flex gap-2`,children:[r.label&&t(`dt`,{className:`shrink-0 text-muted`,children:r.label}),t(`dd`,{className:`min-w-0 truncate`,children:a})]},`${r.field}-${r.label??``}`):null})}):null}function F8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`divide-y divide-border rounded-md border`,children:r.map(s=>n(`article`,{className:`flex gap-4 p-4 ${o?.isSelected(s.id)?`bg-muted/40`:``}`,children:[o&&t(`div`,{className:`pt-1`,children:t(M8,{hit:s,page:r,selection:o})}),e.media&&t(A8,{hit:s,media:e.media,resolveMedia:a,className:`size-20 shrink-0 rounded-md`}),n(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[n(`div`,{children:[t(`h3`,{className:`font-semibold`,children:t(C8,{hit:s,field:e.title})}),e.subtitle&&t(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-muted`,children:e.subtitle.map(e=>t(C8,{hit:s,field:e},e.field))})]}),e.description&&t(`p`,{className:`line-clamp-3 text-sm text-muted`,children:t(C8,{hit:s,field:e.description})}),t(N8,{hit:s,fields:e.badges}),t(j8,{hit:s})]}),n(`div`,{className:`shrink-0 self-center`,children:[t(w8,{hit:s,onOpenHit:i,compact:!0}),t(X6,{hit:s})]})]},s.id))})}function I8({display:e,hits:r,isLoading:i,onOpenHit:a,sortOptions:o,currentSort:s,onSortChange:c,selection:l}){let{t:u}=K(),d=G6()?.actions.some(e=>e.placement===`row`)??!1,f=l?r.filter(e=>l.isSelected(e.id)).length:0,p=r.length>0&&f===r.length;return t(`div`,{className:`overflow-x-auto rounded-md border`,children:n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[l&&t(Re,{className:`w-0`,children:l.selectAll&&t(m,{checked:p?!0:f>0&&`indeterminate`,"aria-label":u(`view.selectPage`),onCheckedChange:e=>l.togglePage(r,e===!0)})}),e.columns.map(e=>{let n=e.sort_option?o?.find(t=>t.id===e.sort_option):void 0;if(!e.sortable||!n)return t(Re,{children:e.label??e.field},`${e.field}-${e.label??``}`);let r=s===n.id?n.sort[0]?.order===`desc`?`descending`:`ascending`:`none`;return t(Ae,{sortDirection:r,onSort:()=>c?.(n.id),disabled:i||!c,sortIndicator:e=>e===`ascending`?t(fh,{className:`size-3`,"aria-hidden":`true`}):e===`descending`?t(rh,{className:`size-3`,"aria-hidden":`true`}):t(wh,{className:`size-3 text-muted`,"aria-hidden":`true`}),children:e.label??e.field},`${e.field}-${e.label??``}`)}),(a||d)&&t(Re,{className:`w-0`,children:t(`span`,{className:`sr-only`,children:u(d?`view.actions`:`agent.openDocument`)})})]})}),t(Pe,{isLoading:i&&r.length===0,columns:e.columns.length+ +!!l+(a||d?1:0),children:r.map(i=>n(`tr`,{className:l?.isSelected(i.id)?`bg-muted/40`:void 0,children:[l&&t(`td`,{className:`w-0`,children:t(M8,{hit:i,page:r,selection:l})}),e.columns.map(e=>t(`td`,{style:e.width?{width:e.width}:void 0,children:t(C8,{hit:i,field:e})},`${i.id}-${e.field}`)),(a||d)&&t(`td`,{className:`w-0 whitespace-nowrap text-end`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(w8,{hit:i,onOpenHit:a,compact:!0}),t(X6,{hit:i})]})})]},i.id))})]})})}const L8={2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`md:grid-cols-2 xl:grid-cols-4`,5:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-5`,6:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6`};function R8({hit:e,configuration:r,onOpenHit:i,resolveMedia:a,selection:o,page:p}){let m=G6()?.actions.some(e=>e.placement===`row`)??!1;return n(s,{className:`relative flex h-full min-w-0 flex-col overflow-hidden ${o?.isSelected(e.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(M8,{hit:e,page:p,selection:o})}),r.media&&t(A8,{hit:e,media:r.media,resolveMedia:a,className:`h-40 w-full border-b`}),n(d,{className:`gap-2 p-4`,children:[t(N8,{hit:e,fields:r.badges}),t(f,{className:`truncate text-base`,children:t(C8,{hit:e,field:r.title})}),r.description&&t(l,{className:`line-clamp-3`,children:t(C8,{hit:e,field:r.description})})]}),n(c,{className:`flex-1 p-4 pt-0`,children:[t(P8,{hit:e,fields:r.fields}),t(j8,{hit:e})]}),(i||m)&&n(u,{className:`justify-end p-4 pt-0`,children:[t(w8,{hit:e,onOpenHit:i}),t(X6,{hit:e})]})]})}function z8({display:e,hits:n,onOpenHit:r,resolveMedia:i,selection:a}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${L8[e.columns??3]}`,children:n.map(o=>t(R8,{hit:o,configuration:e,onOpenHit:r,resolveMedia:i,selection:a,page:n},o.id))})}function B8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${L8[e.columns??4]}`,children:r.map(l=>n(s,{className:`relative overflow-hidden ${o?.isSelected(l.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(M8,{hit:l,page:r,selection:o})}),t(A8,{hit:l,media:e.media,resolveMedia:a,className:`aspect-square w-full border-b`}),n(c,{className:`space-y-2 p-3`,children:[t(`h3`,{className:`truncate font-semibold`,children:t(C8,{hit:l,field:e.title})}),e.caption&&t(`div`,{className:`space-y-1 text-sm text-muted`,children:e.caption.map(e=>t(`div`,{className:`truncate`,children:t(C8,{hit:l,field:e})},e.field))}),n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(w8,{hit:l,onOpenHit:i}),t(X6,{hit:l})]})]})]},l.id))})}function V8({display:e,hits:r,onOpenHit:a,resolveMedia:o,selection:s}){let c=new Map;for(let t of r){let n=x8(y8(t,e.group_by))??``;c.set(n,[...c.get(n)??[],t])}let l=e.columns?.length?[...e.columns].sort((e,t)=>(e.order??0)-(t.order??0)):[...c.keys()].sort().map(e=>({value:e,label:e||`—`}));return t(`div`,{className:`flex min-w-max gap-4 overflow-x-auto pb-2`,children:l.map(l=>{let u=c.get(l.value)??[];return n(`section`,{className:`w-80 shrink-0 space-y-3 rounded-lg bg-muted/40 p-3`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h3`,{className:`font-semibold`,children:l.label}),t(i,{children:u.length})]}),t(`div`,{className:`space-y-3`,children:u.map(n=>t(R8,{hit:n,configuration:e.card,onOpenHit:a,resolveMedia:o,selection:s,page:r},n.id))})]},l.value)})})}function H8(e,n,r,i,a,o,s,c,l){return e.type===`table`?t(I8,{display:e,hits:n,isLoading:r,onOpenHit:i,sortOptions:o,currentSort:s,onSortChange:c,selection:l}):e.type===`cards`?t(z8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`gallery`?t(B8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`board`?t(V8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):t(F8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l})}function U8({configuration:e,definition:n,request:r,result:i,isLoading:a,onSortChange:o,onOpenHit:s,resolveMedia:c,selection:l}){let{t:u}=K(),d=Zt();return!a&&i.hits.length===0?t(`p`,{className:`py-12 text-center text-sm text-muted`,children:u(`filter.noResultsFound`)}):t(b8.Provider,{value:d,children:H8(e,i.hits,a,s,c,n.results?.sort_options,g8(r,i,n.results?.default_sort),o,l)})}Q();function W8(e,t){return t?`text`:e===`number`?`number`:e===`date`?`date`:`text`}function G8(e){let[t=``,n=``]=(e[0]??``).split(`..`,2);return[t,n]}function K8(e,t){return e||t?[`${e}..${t}`]:[]}function q8(e,t){return t?e.join(`, `):e[0]??``}function J8(e,t){return t?e.split(`,`).map(e=>e.trim()).filter(Boolean):e.trim()?[e.trim()]:[]}function Y8({term:e,values:n,isLoading:r,onChange:i}){let a=W(!1),o=W(void 0),[s,c]=G(()=>q8(n,e.multiple)),l=q8(n,e.multiple);return H(()=>{a.current&&o.current===l||c(l),o.current=void 0},[l]),t(L,{label:e.label,children:t(te,{type:W8(e.type,e.multiple),name:`view-key-term-${e.id}`,autoComplete:`off`,value:s,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1;let t=J8(s,e.multiple);c(q8(t,e.multiple))},onChange:t=>{c(t);let n=J8(t,e.multiple);o.current=q8(n,e.multiple),i(n)},placeholder:e.label,disabled:r})})}function X8({configuration:e,query:r,keyTerms:i,isLoading:a,onQueryChange:s,onKeyTermsChange:c,onSubmit:l}){let{t:u}=K(),d=vt(),f=e.key_terms?.filter(e=>e.operator!==`range`)??[],p=e.key_terms?.filter(e=>e.operator===`range`)??[];return n(`form`,{className:`flex flex-col gap-3`,"aria-label":u(`layout.search`),autoComplete:`off`,onSubmit:e=>{e.preventDefault(),l()},children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`label`,{htmlFor:d,className:`sr-only`,children:u(`layout.search`)}),t(te,{id:d,name:`view-query`,autoComplete:`off`,value:r,onChange:s,placeholder:e.placeholder??u(`store.searchPlaceholder`),disabled:a}),n(o,{type:`submit`,disabled:a,className:`shrink-0`,children:[t(Ay,{className:`size-4`}),u(a?`store.searching`:`store.search`)]})]}),e.key_terms&&e.key_terms.length>0&&n(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${p.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.searchFields`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2 ${p.length===0?`lg:grid-cols-4`:``}`,children:f.map(e=>t(Y8,{term:e,values:i[e.id]??[],isLoading:a,onChange:t=>c(e.id,t)},e.id))})]}),p.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${f.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.ranges`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>{let[r,o]=G8(i[e.id]??[]),s=e.type===`number`?`number`:e.type===`date`?`date`:`text`;return n(`fieldset`,{className:`min-w-0`,children:[t(`legend`,{className:`mb-1 text-sm font-medium`,children:e.label}),n(`div`,{className:`grid grid-cols-2 gap-2`,children:[t(te,{type:s,name:`view-key-term-${e.id}-from`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.from`)}`,value:r,onChange:t=>c(e.id,K8(t.trim(),o)),placeholder:u(`view.from`),disabled:a}),t(te,{type:s,name:`view-key-term-${e.id}-to`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.to`)}`,value:o,onChange:t=>c(e.id,K8(r,t.trim())),placeholder:u(`view.to`),disabled:a})]})]},e.id)})})]})]})]})}Q();const Z8={id:`default`,label:`Results`,type:`list`,title:{field:`name`},subtitle:[{field:`type.name`,format:`content_type`},{field:`location`,format:`location`}],description:{field:`description`}};function Q8(e){return!e||typeof window>`u`?{}:c8(window.location.search)}function $8(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function e5(e){let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function t5(e){let{client:n}=q(),r=_t(c2),i=V(t=>n.views.execute(e.viewId,t),[n,e.viewId]),a=V(async(e,t)=>{if(t.source!==`content_thumbnail`)return;let r=e.document.content;try{let t=await n.objects.getRenditionSafe(e.id,r?.type,{format:mn.jpeg,max_hw:512,generate_if_missing:!1,sign_url:!0});if(t?.status===`found`&&t.renditions?.length)return t.renditions[0]}catch{}if(r?.source&&r.type?.startsWith(`image/`))return(await n.files.getDownloadUrl(r.source)).url},[n]),o=e=>r!==void 0&&e.some(e=>r.hasPermission(e));return t(r5,{...e,execute:i,resolveMedia:e.resolveMedia??a,client:n,canDelete:o([yn.content_delete,yn.content_admin,yn.content_superadmin]),canWrite:o([yn.content_write,yn.content_admin,yn.content_superadmin])})}function n5({execute:e,...n}){return e?t(r5,{...n,execute:e},n.viewId):t(t5,{...n},n.viewId)}function r5({execute:e,renderers:r,contributions:i,onOpenHit:a,resolveMedia:s,syncUrl:c=!0,showHeader:l=!0,className:u,client:d,canDelete:f=!1,canWrite:p=!1}){let{t:m}=K(),h=W(e);h.current=e;let g=W(0),[_,v]=G(()=>Q8(c)),[y,b]=G(_.query??``),[x,S]=G(_.key_terms??{}),[C,w]=G(),[T,E]=G(!0),[D,O]=G(),[k,A]=G({}),j=W(void 0),N=V(()=>{j.current=void 0,A({})},[]),P=V((e,t,n=!1)=>{let r=++g.current;return n||N(),v(e),t&&c&&_8(e),E(!0),O(void 0),h.current(e).then(t=>{if(r===g.current){let n=h8(e,t);v(n),c&&_8(n),w(t)}}).catch(e=>{r===g.current&&O(e instanceof Error?e:Error(String(e)))}).finally(()=>{r===g.current&&E(!1)})},[N,c]),F=V(()=>{let e=Q8(c);return b(e.query??``),S(e.key_terms??{}),P(e,!1)},[P,c]);H(()=>(F(),()=>{g.current+=1}),[F]),H(()=>{if(!c||typeof window>`u`)return;let e=()=>void F();return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[F,c]);let I=C?.definition,L=U(()=>[...I?.navigation??[]].sort((e,t)=>(e.order??0)-(t.order??0)),[I?.navigation]),ee=I?.results,R=ee?.selection,te=C?.display??_.display??ee?.default_display,ne=ee?.displays.find(e=>e.id===te)??Z8,re=C?g8(_,C,ee?.default_sort):_.sort,ie=e=>{P(e,!0)},ae=(e,t)=>{let n=$8({..._.navigation??{},[e.id]:t});ie({..._,navigation:n,offset:void 0})},se=(e,t)=>{let n=e5({..._.navigation_queries??{},[e.id]:t});ie({..._,navigation_queries:n,offset:void 0})},ce=()=>{ie({..._,query:y.trim()||void 0,key_terms:$8(x),offset:void 0})},le=U(()=>{if(!R)return;let e=Object.keys(k);return{mode:R.mode,selectAll:R.mode===`multiple`&&R.select_all===`page`,selectedIds:e,selectedHits:e.map(e=>k[e]).filter(e=>e!==void 0),isSelected:e=>k[e]!==void 0,toggle:(e,t,n)=>{A(r=>{if(!t){let t={...r};return delete t[e.id],t}if(R.mode===`single`)return j.current=e.id,{[e.id]:e};let i={...r,[e.id]:e};if(n?.range&&n.page&&j.current){let t=n.page.findIndex(e=>e.id===j.current),r=n.page.findIndex(t=>t.id===e.id);if(t>=0&&r>=0){let e=Math.min(t,r),a=Math.max(t,r);for(let t of n.page.slice(e,a+1))i[t.id]=t}}return j.current=e.id,i})},togglePage:(e,t)=>{R.mode===`multiple`&&A(n=>{let r={...n};for(let n of e)t?r[n.id]=n:delete r[n.id];return r})},clear:N}},[N,k,R]);if(!C&&T)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center`,children:t(je,{size:`xl`})});if(!C||!I)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center p-4`,children:t(M,{title:m(`store.searchFailed`),action:()=>void F(),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)})});let ue=I.search?.renderer?r?.search?.[I.search.renderer]??X8:X8,de=ne.renderer?r?.results?.[ne.renderer]??U8:U8,fe=L.length>0&&I.layout?.navigation_position!==`top`,pe=I.layout?.mode===`worklist`,me=_.offset??0,he=_.limit??ne.page_size??20,ge=me>0,_e=me+C.hits.length<C.total,ve=L.map(e=>{let n=C.navigation[e.id]??{id:e.id,selected:[],nodes:[]},i=e.renderer?r?.navigation?.[e.renderer]??t8:t8;return t(i,{configuration:e,result:n,isLoading:T,onChange:t=>ae(e,t),onQueryChange:e.source===`collection`?t=>se(e,t):void 0},e.id)}),ye=()=>P(_,!1,!0),be=n(ir,{className:u,children:[l&&t(u0,{title:I.name,description:I.description}),n(ir.Fixed,{heightClass:`h-auto`,className:`space-y-3 border-b p-3`,children:[I.search&&t(ue,{configuration:I.search,query:y,keyTerms:x,isLoading:T,onQueryChange:b,onKeyTermsChange:(e,t)=>S(n=>({...n,[e]:t})),onSubmit:ce}),L.length>0&&I.layout?.navigation_position===`top`&&t(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:ve})]}),t(ir.Body,{className:`p-0`,children:n(`div`,{className:fe?pe?`grid min-h-full lg:grid-cols-[minmax(0,1fr)_18rem]`:`grid min-h-full lg:grid-cols-[18rem_minmax(0,1fr)]`:`min-h-full`,children:[fe&&t(`aside`,{className:pe?`space-y-5 border-b p-4 lg:order-2 lg:border-s lg:border-b-0`:`space-y-5 border-b p-4 lg:border-e lg:border-b-0`,children:ve}),n(`main`,{className:`min-w-0 space-y-4 p-4 ${pe?`lg:order-1`:``}`,children:[D&&t(M,{title:m(`store.searchFailed`),action:()=>void P(_,!1),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)}),C.search.warnings.length>0&&t(oe,{status:`warning`,title:m(`view.warning`),children:t(`ul`,{className:`list-disc space-y-1 ps-4`,children:C.search.warnings.map(e=>t(`li`,{children:e.message},`${e.code}-${e.path??``}`))})}),n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2 text-sm text-muted`,children:[t(`span`,{children:m(`view.resultsCount`,{count:C.total})}),T&&t(je,{size:`sm`})]}),n(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(Y6,{selection:le,page:C.hits,showSelectPage:ne.type!==`table`}),ee?.allow_display_switch&&ee.displays.length>1&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.display`)}),t(we,{options:ee.displays,value:ne,onChange:e=>void P({..._,display:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.display`),className:`min-w-36`})]}),ee?.sort_options&&ee.sort_options.length>0&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.sort`)}),t(we,{options:ee.sort_options,value:ee.sort_options.find(e=>e.id===re),onChange:e=>void P({..._,sort:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.sort`),className:`min-w-44`})]})]})]}),t(Q6,{definition:I,request:_,result:C,contribution:i?.drop,canWrite:p,refresh:ye,children:t(de,{configuration:ne,definition:I,request:_,result:C,isLoading:T,onSortChange:e=>void P({..._,sort:e,offset:void 0},!0,!0),onOpenHit:a,resolveMedia:s,selection:le})}),(ge||_e)&&n(`nav`,{className:`flex items-center justify-center gap-2`,"aria-label":m(`view.pagination`),children:[n(o,{type:`button`,variant:`outline`,disabled:!ge||T,onClick:()=>void P({..._,offset:Math.max(0,me-he)||void 0},!0,!0),children:[t(oh,{className:`size-4 cn-rtl-flip`}),m(`grounded.previousPage`)]}),n(o,{type:`button`,variant:`outline`,disabled:!_e||T,onClick:()=>void P({..._,offset:me+he},!0,!0),children:[m(`grounded.nextPage`),t(lh,{className:`size-4 cn-rtl-flip`})]})]})]})]})})]});return t(J6,{definition:I,request:_,result:C,selection:le,contributions:i,client:d,canDelete:f,refresh:ye,children:be})}hY(),SY(),wY(),ZY();export{Jp as ActivitiesDoc,Xp as ActivityDoc,m6 as AddToCollectionAction,f6 as AddToCollectionActionComponent,Yb as AgentApprovalModeSelector,uC as AgentChart,FJ as AgentChatFixtureReplay,xC as AgentChatPlaybackControls,St as AgentResourceResolverProvider,QZ as AgentRunnerFacetsNav,t2 as AllOf,iW as AnimatedThinkingDots,e2 as AnyOf,GZ as ApiKeyAvatar,jH as AskUserWidget,X0 as AudioPanel,G4 as BrowseCollectionView,y6 as ChangeTypeAction,_6 as ChangeTypeActionComponent,Z4 as CollectionIcon,oQ as CollectionsFacetsNav,X4 as CollectionsTable,MH as ConfirmationWidget,i1 as ContentDispositionButton,s3 as ContentObjectTypesSearch,$4 as ContentObjectTypesTable,x4 as ContentOverview,J4 as CreateCollectionForm,Y4 as CreateCollectionModal,e3 as CreateOrUpdateTypeModal,t8 as DefaultViewNavigation,U8 as DefaultViewResults,X8 as DefaultViewSearch,C6 as DeleteObjectsAction,x6 as DeleteObjectsActionComponent,w6 as DeleteObjectsFromCollectionsAction,o4 as DocumentEditingPanel,a4 as DocumentEditingWorkspace,I$ as DocumentGridView,P$ as DocumentIcon,N$ as DocumentIconSkeleton,n6 as DocumentInput,r6 as DocumentPreviewPanel,L$ as DocumentSearch,n1 as DocumentSearchProvider,V4 as DocumentSearchResults,B4 as DocumentSearchResultsWithDropZone,YQ as DocumentSelection,$Q as DocumentSelectionProvider,Z$ as DocumentTable,M$ as DocumentTableColumn,F$ as DocumentTableView,J$ as DocumentUploadModal,gQ as DocumentsFacetsNav,Z3 as EditCollectionView,_Q as EnvironmentFacet,D6 as ExportPropertiesAction,T6 as ExportPropertiesComponent,o6 as ExportPropertiesModal,a6 as ExportTypes,W$ as FileUploadAction,u0 as GenericPageNavHeader,g0 as GroundedExtractionPanel,_0 as GroundedExtractionView,aZ as Header,Z0 as ImagePanel,k3 as IntakePolicyEditor,vZ as InteractionLabel,_Z as InteractionStatusBadge,xQ as InteractionsFacetsNav,IJ as JumpingDots,_G as MESSAGE_STYLES,W0 as MagicPdfView,GJ as McpConnectionsActionMenu,UJ as McpConnectionsButton,HJ as McpConnectionsDialog,WJ as McpConnectionsInlineList,yG as MessageItem,K1 as MessagesContainer,V1 as ModernAgentConversation,d0 as NotFoundView,$0 as OAuthProviderConnectButton,B3 as ObjectSchemaEditor,t3 as ObjectTypeSearch,n3 as ObjectTypeSearchContext,G3 as ObjectTypeSearchProvider,N6 as ObjectsActionContextProvider,n0 as PanelErrorBoundary,eZ as PayloadBuilder,nZ as PayloadBuilderProvider,$X as PayloadBuilderStore,tZ as PayloadContext,fY as PdfDocumentRenderer,aY as PdfPageRenderer,gY as PdfPageSlider,dY as PdfThumbnailList,CQ as ProcessDefinitionsFacetsNav,TQ as ProcessRunsFacetsNav,AQ as PromptsFacetsNav,s4 as PropertiesEditorModal,aW as PulsatingCircle,sW as PulsingMessageLoader,mO as RemoteMcpConnectionButton,A6 as RemoveFromCollectionAction,O6 as RemoveFromCollectionActionComponent,i0 as RowErrorBoundary,IQ as RunsFacetsNav,Z2 as SaveVersionConfirmModal,R$ as SearchContext,d2 as SecureButton,f2 as SecureSidebarItem,$3 as SelectCollection,q4 as SelectContentType,W3 as SelectContentTypeModal,o1 as SelectDocument,e6 as SelectDocumentModal,J1 as SelectEnvironment,Z1 as SelectModel,Q1 as SelectTrainingModel,L6 as SelectionActions,oY as SharedPdfProvider,J3 as SharedPropsEditor,cY as SimplePdfPage,CY as SimplePdfViewer,g1 as SkillWidgetProvider,MG as StreamingMessage,LQ as StringFacet,RQ as StringListFacet,Y3 as SyncMemberHeadsToggle,K3 as TableLayoutEditor,cW as ThinkingBar,CW as ThinkingMessages,BQ as TypeFacet,$Z as TypeRegistry,tQ as TypeRegistryProvider,oW as TypedDots,XY as UniversalDocumentViewer,R6 as UploadObjectsButton,U6 as UserAvatar,VZ as UserInfo,u2 as UserPermissionProvider,o2 as UserPermissions,c2 as UserPermissionsContext,bZ as VInteractionFacet,wZ as VStringFacet,sQ as VTypeFacet,JZ as VUserFacet,oC as VegaLiteChart,$1 as VertesiaErrorBoundary,Q0 as VideoPanel,J6 as ViewActionsProvider,Y6 as ViewActionsToolbar,n5 as ViewExperience,X6 as ViewRowActions,J0 as WEB_SUPPORTED_AUDIO_FORMATS,K0 as WEB_SUPPORTED_IMAGE_FORMATS,q0 as WEB_SUPPORTED_VIDEO_FORMATS,lW as WavyThinking,o0 as WidgetErrorBoundary,HQ as WorkflowDefinitionsFacetsNav,KQ as WorkflowExecutionsFacetsNav,JQ as WorkflowRulesFacetsNav,h8 as canonicalizeViewState,dC as clampPlaybackCursor,BJ as countConnectedActiveGroups,ZZ as createAgentRunnerFilterHandler,n4 as createDocumentChangeSummaryPrompt,t4 as createDocumentReconcilePrompt,hC as createPlaybackState,dZ as createSearchQueryKeyGuard,lZ as filterValueToQueryValue,Y0 as formatDuration,S8 as formatViewFieldValue,VJ as getConnectedActiveGroupLabels,tG as getContentObjectDownloadName,mC as getNextUserTurnIndex,fC as getPlaybackCursorIndex,pC as getPreviousUserTurnIndex,y8 as getViewFieldValue,x$ as getWorkflowStatusColor,S$ as getWorkflowStatusName,h2 as invalidateTypeCache,_C as isAgentChatPlaybackAvailable,vC as isAgentChatPlaybackEnabled,n2 as isAnyOf,u$ as isCsv,RJ as isGroupDisabled,d$ as isImage,yC as isLocalhostAgentChatPlaybackAvailable,bC as isLocalhostAgentChatPlaybackEnabled,f$ as isPdf,m$ as isPreviewableAsPdf,cC as isRechartsSpec,gZ as isUnresolvedInteractionRef,sC as isVegaLiteSpec,p$ as isVideo,c8 as parseViewState,h$ as printElementToPdf,_8 as replaceViewStateInUrl,hZ as resolveInteractionName,m2 as resolveTypeCached,g8 as resolveViewSort,v$ as retrieveRendition,f8 as serializeViewState,t0 as setErrorBoundaryComponent,uZ as setSearchQueryValue,y$ as shortId,b$ as shortenString,mZ as splitInteractionType,q3 as stringifyTableLayout,zJ as toggleGroupDisabled,cZ as unwrapFilterOptionValue,Gt as useAgentResourceResolver,XZ as useAgentRunnerFilterGroups,iQ as useCollectionsFilterGroups,aQ as useCollectionsFilterHandler,mQ as useDocumentFilterGroups,hQ as useDocumentFilterHandler,z$ as useDocumentSearch,H$ as useDocumentSearchCount,ZQ as useDocumentSelection,Y$ as useDocumentUploadHandler,nG as useDownloadFile,MZ as useFetchApiKeyInfo,jZ as useFetchGroupInfo,AZ as useFetchUserInfo,m0 as useGroundedExtractionAvailable,h0 as useGroundedSummary,yQ as useInteractionsFilterGroups,bQ as useInteractionsFilterHandler,LJ as useMcpConnections,pO as useOAuthPopup,QQ as useOptionalDocumentSelection,rZ as usePayloadBuilder,SQ as useProcessDefinitionsFilterGroups,wQ as useProcessRunsFilterGroups,OQ as usePromptsFilterGroups,kQ as usePromptsFilterHandler,PQ as useRunsFilterGroups,FQ as useRunsFilterHandler,r3 as useSearch,a3 as useSearchCount,sY as useSharedPdf,q$ as useSmartFileUploadProcessing,nQ as useTypeRegistry,l2 as useUserPermissions,G6 as useViewActions,B$ as useWatchDocumentSearchFacets,V$ as useWatchDocumentSearchResult,i3 as useWatchSearchResult,VQ as useWorkflowDefinitionsFilterGroups,WQ as useWorkflowExecutionsFilterGroups,GQ as useWorkflowExecutionsFilterHandler,qQ as useWorkflowRulesFilterGroups};
|
|
1402
|
+
*`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-muted shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-border bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(Gg,{className:`h-5 w-5 text-info me-2`}),t(`h2`,{className:`text-lg font-semibold text-foreground truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-info hover:text-info`,children:[t(lv,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-muted hover:text-foreground dark:text-foreground`,children:t(Gb,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(je,{size:`lg`,className:`text-info mb-2`}),t(`p`,{className:`text-muted`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(I_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(A_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-muted prose-pre:my-2 prose-headings:text-info dark:prose-invert`,children:t(Nt,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-foreground`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-border rounded-md p-2 bg-white dark:bg-muted`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-info mb-4`}),t(`p`,{className:`text-muted text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:t(jt,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(A_,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-muted`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.id}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?u6(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-muted dark:border-border`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-info border-primary hover:bg-info`,children:[t(xg,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:[x(`store.openFullDocument`),t(lh,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function u6(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var d6;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(d6||={});function f6({isExporting:e,isOpen:r,onClose:i,allowExportAll:a=!0}){return n(se,{onClose:()=>i(void 0),isOpen:r,children:[t(ue,{children:`Export Object Properties`}),n(ce,{children:[!e&&t(p6,{onClose:i,allowExportAll:a}),e&&t(m6,{})]})]})}function p6({onClose:e,allowExportAll:r}){let{t:i}=K(),[a,s]=G(void 0),c=[`Export selected objects`,`Export all objects`],[l,u]=G(r?void 0:c[0]),d=e=>e===c[1];return n(ce,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[r&&t(`div`,{className:`h-1/3`,children:t(we,{options:c,value:l,onChange:u,placeholder:i(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(we,{options:Object.values(d6),value:a,onChange:s,placeholder:i(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!a||!l,onClick:()=>{e(a,d(l))},children:i(`store.actions.exportProperties`)})]})]})}function m6(){let{t:e}=K();return t(ce,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(je,{size:`lg`})]})})}const h6=dt(void 0);function g6(){let e=_t(h6);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function _6(e,t){let n=g6();return H(()=>n.registerCallback(e,t),[n,e,t]),n}function v6({action:e,objectIds:n}){let[r,i]=G(!1),a=V(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return _6(e.id,a),r&&t(ve,{children:t(x6,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const y6=Xt.getFixedT(null,Yt),b6={id:`addToCollection`,name:y6(`store.actions.addToCollection`),description:y6(`store.actions.addToCollectionDesc`),confirm:!1,component:v6};function x6({isOpen:e,onClose:r,objectIds:i}){let{t:a}=K();return n(se,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(ue,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(S,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(S6,{onClose:r,objectIds:i})})]})}function S6({onClose:e,objectIds:r}){let{t:i}=K(),a=nt(),{client:s}=q(),[c,l]=G(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})},d=[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(ee,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(ce,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t(a6,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(le,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t($4,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}];return n(ze,{defaultValue:`select`,tabs:d,fullWidth:!0,children:[t(Be,{}),t(Ve,{})]})}function C6({action:e,objectIds:r,children:i}){let{t:a}=K(),{store:o}=q(),s=nt(),[c,l]=G(!1),u=V(()=>(l(!0),Promise.resolve(!0)),[]);return _6(e.id,u),n(`div`,{children:[i,t(X3,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const w6=Xt.getFixedT(null,Yt),T6={id:`changeType`,name:w6(`store.actions.changeContentType`),description:w6(`store.actions.changeContentTypeDesc`),confirm:!1,component:C6};function E6({action:r,callback:i,children:a}){let{t:o}=K(),[s,c]=G(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=V(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=_6(r.id,u);return n(e,{children:[a,t(b,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function D6({action:r,objectIds:i,children:a}){let{t:o}=K(),s=g6(),c=nt(),{client:l}=q(),u=B$(),d=Qn(),[f,p]=G(!1),m=i?.length??0,h=s.params?.type?.name??`object`,g=V(()=>(p(!0),Promise.resolve(!0)),[]);_6(r.id,g);let _=V(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let t=JSON.parse(JSON.stringify(u.facets));i.length===t._value.total&&u.resetFacets();let n=new Set(e.failed);u.removeDeletedObjects(i.filter(e=>!n.has(e))),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(b,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:_,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const O6=Xt.getFixedT(null,Yt),k6={id:`delete`,name:O6(`store.actions.delete`),description:O6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:O6(`store.actions.confirmDeleteAll`),component:D6,destructive:!0},A6={id:`deleteFromCollections`,name:O6(`store.actions.deleteObjects`),description:O6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:O6(`store.actions.confirmDeleteSelected`),component:D6,destructive:!0};function j6({action:e,objectIds:n}){let{t:r}=K(),{store:i}=q(),a=nt(),[o,s]=G(!1),[c,l]=G(!1),u=V(()=>(s(!0),Promise.resolve(!0)),[]),d=_6(e.id,u);return t(f6,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const M6=Xt.getFixedT(null,Yt),N6={id:`exportProperties`,name:M6(`store.actions.exportProperties`),description:M6(`store.actions.exportAllObjectProperties`),confirm:!1,component:j6};function P6({action:e,objectIds:n,collectionId:r}){let{t:i}=K(),a=g6(),o=nt(),{client:s}=q(),c=B$(),l=V(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:Ge(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o]);return t(E6,{action:e,callback:l})}const F6=Xt.getFixedT(null,Yt),I6={id:`removeFromCollection`,name:F6(`store.actions.removeFromCollection`),description:F6(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:F6(`store.actions.confirmRemoveFromCollection`),component:P6,destructive:!0};function L6({action:e,objectIds:n}){let{t:r}=K(),i=g6(),a=nt(),{store:o}=q(),s=B$(),c=V(()=>n?.length?o.runOperation({name:`start_workflow`,ids:n,params:{}}).then(()=>{a({status:`success`,title:r(`store.actions.intakeStarted`),description:r(`store.actions.intakeStartedOn`,{count:n.length}),duration:3e3}),s&&(i.params?.selection?.removeAll(),s.search())}).catch(e=>{a({status:`error`,title:r(`store.actions.errorStartingIntake`),description:Ge(e),duration:5e3})}):(a({status:`error`,title:r(`store.actions.noObjectsSelected`),description:r(`store.actions.pleaseSelectObjectsToRunIntake`),duration:3e3}),Promise.resolve(!1)),[i.params?.selection?.removeAll,n,s,s?.search,o.runOperation,r,a]);return t(E6,{action:e,callback:c})}const R6=Xt.getFixedT(null,Yt),z6={id:`runIntake`,name:R6(`store.actions.runIntake`),description:R6(`store.actions.runIntakeDesc`),confirm:!0,confirmationText:R6(`store.actions.confirmRunIntake`),component:L6};var B6=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const V6=[N6,T6,b6,z6,k6,I6,A6];function H6({children:e,type:r}){let i=QQ(),a=nt(),{client:o}=q(),s=B$(),c=U(()=>{let e=new B6({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=V6,e},[o,s,i,a,r]);return c&&n(h6.Provider,{value:c,children:[t(U6,{}),e]})}function U6(){let e=g6(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}Q();function W6({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=QQ(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(H6,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(Gb,{className:`size-4`})})]}),t(q6,{selection:s,allowMutations:r,allowDelete:i,allowWorkflowRun:a,children:e=>e.length>0?t(o,{variant:`ghost`,title:`More action`,size:`sm`,children:t(wg,{size:16})}):null})]})})}function G6({collectionId:r,allowFolders:i=!0}){let{t:a}=K(),[s,c]=G([]),[l,u]=G(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(Y$,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function K6(e){return{label:e.name,className:it(`flex-1 px-2 py-2 hover:bg-muted nowrap`,e.destructive?`text-destructive`:``)}}function q6({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0,allowWorkflowRun:o=!1}){let s=g6(),c=e=>{s.run(e.id)},l=Y6(s.actions,e,{allowMutations:i,allowDelete:a,allowWorkflowRun:o}),u=r(l);return u?n(he,{hover:!0,children:[t(_e,{children:u}),t(ge,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(J6,{executeAction:c,actions:l})})]}):null}function J6({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(Te,{options:n,optionLayout:K6,onChange:t=>{e(t)},noCheck:!0})})})}function Y6(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`runIntake`?n.allowWorkflowRun:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[N6]}function X6({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:(()=>{if(e.picture)return t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name});{let n=e.name.split(` `).map(e=>e[0]).join(``);return t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:n})})}})()}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-foreground group-hover:text-foreground`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-muted dark:text-foreground group-hover:text-foreground`,children:e.email??`Deleted User`})]})]})}Q();const Z6=dt(void 0);function Q6(){return _t(Z6)}function $6(e,t){let n=e.requires_selection??(e.placement===`toolbar`?`none`:`any`);return n===`none`?!0:n===`single`?t.length===1:n===`multiple`?t.length>1:t.length>0}function e8(e){let t=window.URL.createObjectURL(new Blob([e.data],{type:e.type})),n=document.createElement(`a`);n.download=e.name,n.href=t,n.click(),window.setTimeout(()=>window.URL.revokeObjectURL(t),0)}function t8({children:e,definition:r,request:i,result:a,selection:o,contributions:s,client:c,canDelete:l,refresh:u}){let{t:d}=K(),f=nt(),[p,m]=G(),[h,g]=G(),[_,v]=G(!1),[y,x]=G(),S=W(!1),C=r.results?.actions,w=U(()=>({definition:r,request:i,result:a,refresh:u,clearSelection:()=>o?.clear()}),[r,u,i,a,o]),T=U(()=>{let e=(C?.items??[]).filter(e=>{let t=s?.actions?.[e.handler];return t!==void 0&&(t.isAvailable?.(w)??!0)});if(!o||C?.include_defaults===!1||!c)return e;let t=new Set(C?.exclude_defaults??[]),n=[];return t.has(`export`)||n.push({id:`export`,label:d(`store.actions.exportProperties`),handler:`export`,placement:`selection`,requires_selection:`any`}),l&&!t.has(`delete`)&&n.push({id:`delete`,label:d(`store.actions.delete`),handler:`delete`,placement:`selection`,requires_selection:`any`,destructive:!0,confirm:!0}),[...n,...e]},[C,w,l,c,s?.actions,o,d]),E=V(async({action:e,hits:t})=>{if(!S.current){S.current=!0,x(e.id);try{if(e.handler===`delete`){if(!c)return;let e=await c.store.objects.delete(t.map(e=>e.id));f({status:e.failed.length>0?`warning`:`success`,title:d(`view.deletedObjects`,{count:e.deleted})}),o?.clear(),await u();return}let n=s?.actions?.[e.handler];if(!n)return;await n.run({...w,action:e,hits:t})}catch(e){console.error(`View action failed:`,e),f({status:`error`,title:d(`view.actionFailed`),description:d(`view.actionFailedDescription`)})}finally{S.current=!1,x(void 0),m(void 0)}}},[w,c,s?.actions,u,o,d,f]),D=V((e,t)=>{if(!(!$6(e,t)||S.current)){if(e.handler===`export`){g(t);return}if(e.confirm){m({action:e,hits:t});return}E({action:e,hits:t})}},[E]),O=V(e=>{if(!e||!h?.length||!c){g(void 0);return}v(!0),c.store.objects.exportProperties({objectIds:h.map(e=>e.id),type:e}).then(e=>{e8(e),f({status:`success`,title:d(`store.actions.exportProperties`)}),g(void 0)}).catch(e=>{console.error(`View export failed:`,e),f({status:`error`,title:d(`store.actions.errorExportProperties`),description:d(`view.actionFailedDescription`)})}).finally(()=>v(!1))},[c,h,d,f]),k=U(()=>({actions:T,runningActionId:y,run:D}),[T,D,y]);return n(Z6.Provider,{value:k,children:[e,t(f6,{isOpen:h!==void 0,isExporting:_,onClose:O,allowExportAll:!1}),t(b,{isOpen:p!==void 0,title:p?.action.label??d(`modal.confirm`),content:d(`view.confirmAction`,{action:p?.action.label??``,count:p?.hits.length??0}),isLoading:y!==void 0,onConfirm:()=>{p&&E(p)},onCancel:()=>m(void 0),confirmationValue:p?.action.handler===`delete`?`delete`:void 0,confirmationLabel:p?.action.handler===`delete`?d(`view.typeDeleteToConfirm`):void 0,confirmationPlaceholder:p?.action.handler===`delete`?`delete`:void 0})]})}function n8({selection:r,page:i,showSelectPage:a=!1}){let{t:s}=K(),c=Q6(),l=vt();if(!c)return null;let u=r?.selectedHits??[],d=r?i.filter(e=>r.isSelected(e.id)).length:0,f=i.length>0&&d===i.length,p=a&&r?.selectAll&&i.length>0,h=c.actions.filter(e=>((e.placement??`selection`)===`toolbar`||(e.placement??`selection`)===`selection`&&u.length>0)&&$6(e,u));return h.length===0&&u.length===0&&!p?null:n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p&&r&&n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:l,checked:f?!0:d>0&&`indeterminate`,onCheckedChange:e=>r.togglePage(i,e===!0)}),t(`label`,{htmlFor:l,className:`text-sm text-muted`,children:s(`view.selectPage`)})]}),u.length>0&&n(e,{children:[t(`span`,{className:`text-sm text-muted`,children:s(`view.selectedCount`,{count:u.length})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`view.clearSelection`),onClick:r?.clear,children:t(Gb,{className:`size-4`})})]}),h.map(e=>n(o,{type:`button`,variant:e.destructive?`destructive`:`outline`,size:`sm`,disabled:c.runningActionId!==void 0,onClick:()=>c.run(e,u),children:[e.handler===`export`&&t(xg,{className:`size-4`}),e.handler===`delete`&&t(hb,{className:`size-4`}),e.label]},e.id))]})}function r8({hit:e}){let{t:r}=K(),i=Q6(),a=i?.actions.filter(t=>(t.placement??`selection`)===`row`&&$6(t,[e]));return!i||!a?.length?null:n(he,{children:[t(_e,{children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r(`view.actions`),children:t(wg,{className:`size-4`})})}),t(ge,{className:`w-52 p-1`,align:`end`,sideOffset:6,children:t(Te,{options:a,optionLayout:e=>({label:e.label,className:e.destructive?`text-destructive`:void 0}),onChange:t=>i.run(t,[e]),noCheck:!0})})]})}function i8(e){return e.dataTransfer.items?Array.from(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null):Array.from(e.dataTransfer.files)}function a8({children:r,definition:i,request:a,result:o,contribution:s,canWrite:c,refresh:l}){let{t:u}=K(),d=nt(),f=i.results?.drop,p=f?.handler===`upload`&&c,m=s!==void 0||p,[h,g]=G(!1),[_,v]=G(!1),[y,b]=G([]),x=W(!1),S=V(async e=>{if(e.length){if(s){if(x.current)return;x.current=!0,v(!0);try{await s.run({configuration:f,files:e,definition:i,request:a,result:o,refresh:l})}catch(e){console.error(`View drop action failed:`,e),d({status:`error`,title:u(`view.dropFailed`),description:u(`view.actionFailedDescription`)})}finally{x.current=!1,v(!1)}return}p&&b(e)}},[p,f,s,i,l,a,o,u,d]);if(!m)return r;let C=f?.params;return n(e,{children:[n(`div`,{className:`relative min-h-48`,onDragEnter:e=>{e.preventDefault(),g(!0)},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:e=>{e.preventDefault(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),g(!1),!e.target.closest(`[data-view-drop-zone]`)&&S(i8(e))},children:[r,_&&t(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-background/80`,children:t(je,{size:`xl`})}),t(`div`,{"data-view-drop-zone":!0,className:`pointer-events-none absolute inset-0 ${h?`z-50`:`-z-10`}`,children:t(Ot,{onDrop:e=>void S(e),message:u(`view.dropFiles`),buttonLabel:u(`view.selectFiles`),allowFolders:C?.allow_folders??!0,className:`pointer-events-auto absolute inset-0 bg-background/90 ${h?`flex`:`hidden`}`})})]}),p&&t(Y$,{isOpen:y.length>0,onClose:()=>b([]),files:y,collectionId:C?.collection_id,selectedFolder:C?.location,initialTypeId:C?.type_id,defaultProperties:C?.properties,allowFolders:C?.allow_folders??!0,title:u(`view.uploadToView`),onUploadComplete:e=>{e.success&&l()}})]})}Q();function o8(e,t,n,r){return n?r===!1?[t]:e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function s8({node:e}){return n(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[t(`span`,{className:`truncate`,children:e.label}),t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]})}function c8({configuration:e,result:r,isLoading:i,onChange:a,onQueryChange:s}){let{t:c}=K(),l=vt(),u=e.presentation??(e.source===`location`||e.source===`hierarchy`?`tree`:`list`),d=e.source!==`hierarchy`&&e.multi_select,f=r.breadcrumbs??[],[p,h]=G(r.query??``);H(()=>{h(r.query??``)},[r.query]);let g=(e,t)=>{a(o8(r.selected,e,t,d))};return n(`section`,{className:`space-y-2`,"aria-labelledby":`${l}-label`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h2`,{id:`${l}-label`,className:`text-sm font-semibold`,children:e.label}),r.selected.length>0&&n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([]),"aria-label":`${c(`filter.clearAll`)}: ${e.label}`,children:[t(Gb,{className:`size-3.5`}),c(`filter.clearAll`)]})]}),e.source===`collection`&&s&&n(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),s?.(p.trim())},children:[t(te,{value:p,onChange:h,disabled:i,placeholder:c(`view.filterNavigation`,{label:e.label}),"aria-label":c(`view.filterNavigation`,{label:e.label})}),t(o,{type:`submit`,variant:`outline`,size:`icon`,disabled:i,"aria-label":c(`view.searchNavigation`,{label:e.label}),children:t(Ay,{"aria-hidden":`true`,className:`size-4`})})]}),f.length>0&&t(`nav`,{"aria-label":`${e.label} path`,children:t(`ol`,{className:`flex flex-wrap items-center gap-1 text-sm`,children:f.map((e,r)=>n(`li`,{className:`flex items-center gap-1`,children:[r>0&&t(lh,{"aria-hidden":`true`,className:`size-3.5 text-muted`}),t(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([e.id]),"aria-current":r===f.length-1?`page`:void 0,children:e.label})]},e.id))})}),r.selected.length>0&&f.length===0&&(e.source===`location`||e.source===`collection`)&&t(`div`,{className:`flex flex-wrap gap-1`,children:r.selected.map(e=>{let a=r.nodes.find(t=>t.id===e)?.label??e;return n(o,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>g(e,!1),"aria-label":c(`view.removeSelection`,{value:a}),children:[a,t(Gb,{"aria-hidden":`true`,className:`size-3.5`})]},e)})}),u===`select`&&d===!1?t(we,{options:r.nodes,value:r.nodes.find(e=>r.selected.includes(e.id)),onChange:e=>a([e.id]),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`select`?t(we,{multiple:!0,options:r.nodes,value:r.nodes.filter(e=>r.selected.includes(e.id)),onChange:e=>a(e.map(e=>e.id)),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`chips`?t(`div`,{className:`flex flex-wrap gap-2`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`outline`,size:`sm`,disabled:i,onClick:()=>g(e.id,!r.selected.includes(e.id)),children:[e.label,t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]},e.id))}):e.source===`hierarchy`?t(`div`,{className:`space-y-1`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`ghost`,className:`w-full justify-start`,disabled:i,onClick:()=>a([e.id]),children:[t(s8,{node:e}),e.expandable&&t(lh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted`})]},e.id))}):t(`div`,{className:`space-y-1`,children:r.nodes.map((e,a)=>{let o=`${l}-${a}`;return n(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted`,children:[t(m,{id:o,checked:r.selected.includes(e.id),disabled:i,onCheckedChange:t=>g(e.id,t===!0)}),t(`label`,{htmlFor:o,className:`flex min-w-0 flex-1 cursor-pointer text-sm`,children:t(s8,{node:e})})]},e.id)})}),r.nodes.length===0&&t(`p`,{className:`text-sm text-muted`,children:c(`filter.noAvailableFilters`)})]})}const l8=`display`,u8=`sort`,d8=`offset`;function f8(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function p8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.getAll(r).filter(e=>e!==``);i.length>0&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function m8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.get(r)?.trim();i&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function h8(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`q`)?.trim(),r=t.get(l8)?.trim(),i=t.get(u8)?.trim(),a=f8(t.get(d8)),o=p8(t,`t.`),s=p8(t,`n.`),c=m8(t,`nq.`);return{...n?{query:n}:{},...o?{key_terms:o}:{},...s?{navigation:s}:{},...c?{navigation_queries:c}:{},...r?{display:r}:{},...i?{sort:i}:{},...a?{offset:a}:{}}}function g8(e){for(let t of[...e.keys()])(t===`q`||t===l8||t===u8||t===d8||t.startsWith(`t.`)||t.startsWith(`nq.`)||t.startsWith(`n.`))&&e.delete(t)}function _8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))for(let n of i)n!==``&&e.append(`${t}${r}`,n)}function v8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))i.trim()&&e.set(`${t}${r}`,i.trim())}function y8(e,t=``){let n=new URLSearchParams(t.startsWith(`?`)?t.slice(1):t);g8(n),e.query?.trim()&&n.set(`q`,e.query.trim()),e.display&&n.set(l8,e.display),e.sort&&n.set(u8,e.sort),e.offset&&e.offset>0&&n.set(d8,String(e.offset)),_8(n,`t.`,e.key_terms),_8(n,`n.`,e.navigation),v8(n,`nq.`,e.navigation_queries);let r=n.toString();return r?`?${r}`:``}function b8(e){let t=Object.fromEntries(Object.entries(e.navigation).filter(([,e])=>e.selected.length>0).map(([e,t])=>[e,t.selected]));return Object.keys(t).length>0?t:void 0}function x8(e){let t={};for(let[n,r]of Object.entries(e.navigation))r.query&&(t[n]=r.query);return Object.keys(t).length>0?t:void 0}function S8(e,t){let n=new Set(t.definition.search?.key_terms?.map(e=>e.id)??[]),r=e.key_terms?Object.fromEntries(Object.entries(e.key_terms).filter(([e,t])=>n.has(e)&&t.length)):void 0,i=b8(t),a=x8(t);return{...e.query?.trim()?{query:e.query.trim()}:{},...r&&Object.keys(r).length>0?{key_terms:r}:{},...i?{navigation:i}:{},...a?{navigation_queries:a}:{},...t.display?{display:t.display}:{},...t.sort?{sort:t.sort}:{},...e.offset&&e.offset>0?{offset:e.offset}:{},...e.limit?{limit:e.limit}:{}}}function C8(e,t,n){return t.sort??e.sort??(e.query?.trim()?void 0:n)}function w8(e){if(typeof window>`u`)return;let t=y8(e,window.location.search);window.history.replaceState(window.history.state||{},``,`${window.location.pathname}${t}`)}Q();function T8(e,t){return!t||t===`.`?e:t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`||Array.isArray(e)))return e[t]},e)}function E8(e,t){return t===`score`?e.score:t.startsWith(`annotation.`)?T8(e.annotation,t.slice(11)):t.startsWith(`document.`)?T8(e.document,t.slice(9)):T8(e.document,t)}const D8=dt(void 0);function O8(e){if(e!=null&&e!==``)return Array.isArray(e)?e.map(O8).filter(Boolean).join(`, `):typeof e==`object`?JSON.stringify(e):String(e)}function k8(e,t,n){let r=E8(e,t.field),i=t.fallback??``;if(r==null||r===``)return i;if(t.format===`date`){let e=String(r),t=/^\d{4}-\d{2}-\d{2}$/.test(e),a=new Date(e);if(Number.isNaN(a.getTime()))return O8(r)??i;let o={year:`numeric`,month:`numeric`,day:`numeric`,...t?{timeZone:`UTC`}:{}};return n?.formatDate(a,o)??new Intl.DateTimeFormat(void 0,o).format(a)}if(t.format===`number`){let e=typeof r==`number`?r:Number(r);return Number.isFinite(e)?n?.formatNumber(e)??new Intl.NumberFormat().format(e):O8(r)??i}return O8(r)??i}function A8({hit:e,field:n,className:r}){let a=k8(e,n,_t(D8));return a?n.format===`badge`||n.format===`content_type`?t(i,{className:r,children:a}):t(`span`,{className:r,children:a}):null}function j8({hit:e,onOpenHit:r,compact:i=!1}){let{t:a}=K();return r?i?t(We,{description:a(`agent.openDocument`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`agent.openDocument`),onClick:()=>r(e),children:t(Dg,{className:`size-4`})})}):n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),children:[t(Dg,{className:`size-4`}),a(`agent.openDocument`)]}):null}function M8(e,t){if(t.source!==`property`||!t.field)return;let n=O8(E8(e,t.field));if(n)try{let e=new URL(n,typeof window>`u`?`https://localhost`:window.location.origin);return e.protocol===`http:`||e.protocol===`https:`?e.toString():void 0}catch{return}}const N8=new WeakMap,P8=[2e3,4e3,8e3];function F8(e){let t=N8.get(e);if(t)return t;let n=new Map;return N8.set(e,n),n}function I8(e,t,n){let r=F8(e),i=r.get(t);if(i)return i;let a=n().finally(()=>{r.delete(t)});return r.set(t,a),a}function L8({hit:e,media:n,resolveMedia:r,className:i}){let a=n?M8(e,n):void 0,[o,s]=G(),[c,l]=G(!1),u=!a&&n?`${e.id}|${JSON.stringify(n)}`:void 0,d=W(e),f=W(n);d.current=e,f.current=n,H(()=>{if(s(void 0),l(!1),!u||!r)return;let e=!0,t,n=i=>{I8(r,u,async()=>r(d.current,f.current)).then(r=>{if(!e)return;if(r){s(r);return}let a=P8[i];a!==void 0&&(t=setTimeout(()=>n(i+1),a))}).catch(()=>{e&&l(!0)})};return n(0),()=>{e=!1,t&&clearTimeout(t)}},[u,r,a]);let p=c?void 0:a??o,m=n?.fit===`contain`?`object-contain`:`object-cover`;if(p)return t(`img`,{src:p,alt:``,className:`${m} ${i??``}`,onError:()=>l(!0)});let h=n?.source===`type_icon`?`type_icon`:n?.fallback??`type_icon`;return h===`none`?null:t(`div`,{className:`flex items-center justify-center bg-muted ${i??``}`,"aria-hidden":`true`,children:t(h===`placeholder`?D_:Gg,{className:`size-10 text-muted`})})}function R8({hit:e}){let n=e.annotation?.why_match??e.annotation?.answer??e.annotation?.excerpt;return n?t(`p`,{className:`text-sm text-info`,children:n}):null}function z8({hit:e,page:n,selection:r}){let{t:i}=K(),a=W(!1);return r?t(m,{checked:r.isSelected(e.id),"aria-label":i(`view.selectResult`,{name:e.document.name}),onClick:e=>{a.current=e.shiftKey,e.stopPropagation()},onCheckedChange:t=>{r.toggle(e,t===!0,{page:n,range:r.mode===`multiple`&&a.current}),a.current=!1}}):null}function B8({hit:e,fields:n}){return n?.length?t(`div`,{className:`flex flex-wrap gap-1`,children:n.map(n=>t(A8,{hit:e,field:n},`${n.field}-${n.label??``}`))}):null}function V8({hit:e,fields:r}){let i=_t(D8);return r?.length?t(`dl`,{className:`space-y-1 text-sm`,children:r.map(r=>{let a=k8(e,r,i);return a?n(`div`,{className:`flex gap-2`,children:[r.label&&t(`dt`,{className:`shrink-0 text-muted`,children:r.label}),t(`dd`,{className:`min-w-0 truncate`,children:a})]},`${r.field}-${r.label??``}`):null})}):null}function H8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`divide-y divide-border rounded-md border`,children:r.map(s=>n(`article`,{className:`flex gap-4 p-4 ${o?.isSelected(s.id)?`bg-muted/40`:``}`,children:[o&&t(`div`,{className:`pt-1`,children:t(z8,{hit:s,page:r,selection:o})}),e.media&&t(L8,{hit:s,media:e.media,resolveMedia:a,className:`size-20 shrink-0 rounded-md`}),n(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[n(`div`,{children:[t(`h3`,{className:`font-semibold`,children:t(A8,{hit:s,field:e.title})}),e.subtitle&&t(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-muted`,children:e.subtitle.map(e=>t(A8,{hit:s,field:e},e.field))})]}),e.description&&t(`p`,{className:`line-clamp-3 text-sm text-muted`,children:t(A8,{hit:s,field:e.description})}),t(B8,{hit:s,fields:e.badges}),t(R8,{hit:s})]}),n(`div`,{className:`shrink-0 self-center`,children:[t(j8,{hit:s,onOpenHit:i,compact:!0}),t(r8,{hit:s})]})]},s.id))})}function U8({display:e,hits:r,isLoading:i,onOpenHit:a,sortOptions:o,currentSort:s,onSortChange:c,selection:l}){let{t:u}=K(),d=Q6()?.actions.some(e=>e.placement===`row`)??!1,f=l?r.filter(e=>l.isSelected(e.id)).length:0,p=r.length>0&&f===r.length;return t(`div`,{className:`overflow-x-auto rounded-md border`,children:n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[l&&t(Re,{className:`w-0`,children:l.selectAll&&t(m,{checked:p?!0:f>0&&`indeterminate`,"aria-label":u(`view.selectPage`),onCheckedChange:e=>l.togglePage(r,e===!0)})}),e.columns.map(e=>{let n=e.sort_option?o?.find(t=>t.id===e.sort_option):void 0;if(!e.sortable||!n)return t(Re,{children:e.label??e.field},`${e.field}-${e.label??``}`);let r=s===n.id?n.sort[0]?.order===`desc`?`descending`:`ascending`:`none`;return t(Ae,{sortDirection:r,onSort:()=>c?.(n.id),disabled:i||!c,sortIndicator:e=>e===`ascending`?t(fh,{className:`size-3`,"aria-hidden":`true`}):e===`descending`?t(rh,{className:`size-3`,"aria-hidden":`true`}):t(wh,{className:`size-3 text-muted`,"aria-hidden":`true`}),children:e.label??e.field},`${e.field}-${e.label??``}`)}),(a||d)&&t(Re,{className:`w-0`,children:t(`span`,{className:`sr-only`,children:u(d?`view.actions`:`agent.openDocument`)})})]})}),t(Pe,{isLoading:i&&r.length===0,columns:e.columns.length+ +!!l+(a||d?1:0),children:r.map(i=>n(`tr`,{className:l?.isSelected(i.id)?`bg-muted/40`:void 0,children:[l&&t(`td`,{className:`w-0`,children:t(z8,{hit:i,page:r,selection:l})}),e.columns.map(e=>t(`td`,{style:e.width?{width:e.width}:void 0,children:t(A8,{hit:i,field:e})},`${i.id}-${e.field}`)),(a||d)&&t(`td`,{className:`w-0 whitespace-nowrap text-end`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(j8,{hit:i,onOpenHit:a,compact:!0}),t(r8,{hit:i})]})})]},i.id))})]})})}const W8={2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`md:grid-cols-2 xl:grid-cols-4`,5:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-5`,6:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6`};function G8({hit:e,configuration:r,onOpenHit:i,resolveMedia:a,selection:o,page:p}){let m=Q6()?.actions.some(e=>e.placement===`row`)??!1;return n(s,{className:`relative flex h-full min-w-0 flex-col overflow-hidden ${o?.isSelected(e.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(z8,{hit:e,page:p,selection:o})}),r.media&&t(L8,{hit:e,media:r.media,resolveMedia:a,className:`h-40 w-full border-b`}),n(d,{className:`gap-2 p-4`,children:[t(B8,{hit:e,fields:r.badges}),t(f,{className:`truncate text-base`,children:t(A8,{hit:e,field:r.title})}),r.description&&t(l,{className:`line-clamp-3`,children:t(A8,{hit:e,field:r.description})})]}),n(c,{className:`flex-1 p-4 pt-0`,children:[t(V8,{hit:e,fields:r.fields}),t(R8,{hit:e})]}),(i||m)&&n(u,{className:`justify-end p-4 pt-0`,children:[t(j8,{hit:e,onOpenHit:i}),t(r8,{hit:e})]})]})}function K8({display:e,hits:n,onOpenHit:r,resolveMedia:i,selection:a}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${W8[e.columns??3]}`,children:n.map(o=>t(G8,{hit:o,configuration:e,onOpenHit:r,resolveMedia:i,selection:a,page:n},o.id))})}function q8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${W8[e.columns??4]}`,children:r.map(l=>n(s,{className:`relative overflow-hidden ${o?.isSelected(l.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(z8,{hit:l,page:r,selection:o})}),t(L8,{hit:l,media:e.media,resolveMedia:a,className:`aspect-square w-full border-b`}),n(c,{className:`space-y-2 p-3`,children:[t(`h3`,{className:`truncate font-semibold`,children:t(A8,{hit:l,field:e.title})}),e.caption&&t(`div`,{className:`space-y-1 text-sm text-muted`,children:e.caption.map(e=>t(`div`,{className:`truncate`,children:t(A8,{hit:l,field:e})},e.field))}),n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(j8,{hit:l,onOpenHit:i}),t(r8,{hit:l})]})]})]},l.id))})}function J8({display:e,hits:r,onOpenHit:a,resolveMedia:o,selection:s}){let c=new Map;for(let t of r){let n=O8(E8(t,e.group_by))??``;c.set(n,[...c.get(n)??[],t])}let l=e.columns?.length?[...e.columns].sort((e,t)=>(e.order??0)-(t.order??0)):[...c.keys()].sort().map(e=>({value:e,label:e||`—`}));return t(`div`,{className:`flex min-w-max gap-4 overflow-x-auto pb-2`,children:l.map(l=>{let u=c.get(l.value)??[];return n(`section`,{className:`w-80 shrink-0 space-y-3 rounded-lg bg-muted/40 p-3`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h3`,{className:`font-semibold`,children:l.label}),t(i,{children:u.length})]}),t(`div`,{className:`space-y-3`,children:u.map(n=>t(G8,{hit:n,configuration:e.card,onOpenHit:a,resolveMedia:o,selection:s,page:r},n.id))})]},l.value)})})}function Y8(e,n,r,i,a,o,s,c,l){return e.type===`table`?t(U8,{display:e,hits:n,isLoading:r,onOpenHit:i,sortOptions:o,currentSort:s,onSortChange:c,selection:l}):e.type===`cards`?t(K8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`gallery`?t(q8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`board`?t(J8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):t(H8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l})}function X8({configuration:e,definition:n,request:r,result:i,isLoading:a,onSortChange:o,onOpenHit:s,resolveMedia:c,selection:l}){let{t:u}=K(),d=Zt();return!a&&i.hits.length===0?t(`p`,{className:`py-12 text-center text-sm text-muted`,children:u(`filter.noResultsFound`)}):t(D8.Provider,{value:d,children:Y8(e,i.hits,a,s,c,n.results?.sort_options,C8(r,i,n.results?.default_sort),o,l)})}Q();function Z8(e,t){return t?`text`:e===`number`?`number`:e===`date`?`date`:`text`}function Q8(e){let[t=``,n=``]=(e[0]??``).split(`..`,2);return[t,n]}function $8(e,t){return e||t?[`${e}..${t}`]:[]}function e5(e,t){return t?e.join(`, `):e[0]??``}function t5(e,t){return t?e.split(`,`).map(e=>e.trim()).filter(Boolean):e.trim()?[e.trim()]:[]}function n5({term:e,values:n,isLoading:r,onChange:i}){let a=W(!1),o=W(void 0),[s,c]=G(()=>e5(n,e.multiple)),l=e5(n,e.multiple);return H(()=>{a.current&&o.current===l||c(l),o.current=void 0},[l]),t(L,{label:e.label,children:t(te,{type:Z8(e.type,e.multiple),name:`view-key-term-${e.id}`,autoComplete:`off`,value:s,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1;let t=t5(s,e.multiple);c(e5(t,e.multiple))},onChange:t=>{c(t);let n=t5(t,e.multiple);o.current=e5(n,e.multiple),i(n)},placeholder:e.label,disabled:r})})}function r5({configuration:e,query:r,keyTerms:i,isLoading:a,onQueryChange:s,onKeyTermsChange:c,onSubmit:l}){let{t:u}=K(),d=vt(),f=e.key_terms?.filter(e=>e.operator!==`range`)??[],p=e.key_terms?.filter(e=>e.operator===`range`)??[];return n(`form`,{className:`flex flex-col gap-3`,"aria-label":u(`layout.search`),autoComplete:`off`,onSubmit:e=>{e.preventDefault(),l()},children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`label`,{htmlFor:d,className:`sr-only`,children:u(`layout.search`)}),t(te,{id:d,name:`view-query`,autoComplete:`off`,value:r,onChange:s,placeholder:e.placeholder??u(`store.searchPlaceholder`),disabled:a}),n(o,{type:`submit`,disabled:a,className:`shrink-0`,children:[t(Ay,{className:`size-4`}),u(a?`store.searching`:`store.search`)]})]}),e.key_terms&&e.key_terms.length>0&&n(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${p.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.searchFields`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2 ${p.length===0?`lg:grid-cols-4`:``}`,children:f.map(e=>t(n5,{term:e,values:i[e.id]??[],isLoading:a,onChange:t=>c(e.id,t)},e.id))})]}),p.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${f.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.ranges`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>{let[r,o]=Q8(i[e.id]??[]),s=e.type===`number`?`number`:e.type===`date`?`date`:`text`;return n(`fieldset`,{className:`min-w-0`,children:[t(`legend`,{className:`mb-1 text-sm font-medium`,children:e.label}),n(`div`,{className:`grid grid-cols-2 gap-2`,children:[t(te,{type:s,name:`view-key-term-${e.id}-from`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.from`)}`,value:r,onChange:t=>c(e.id,$8(t.trim(),o)),placeholder:u(`view.from`),disabled:a}),t(te,{type:s,name:`view-key-term-${e.id}-to`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.to`)}`,value:o,onChange:t=>c(e.id,$8(r,t.trim())),placeholder:u(`view.to`),disabled:a})]})]},e.id)})})]})]})]})}Q();const i5={id:`default`,label:`Results`,type:`list`,title:{field:`name`},subtitle:[{field:`type.name`,format:`content_type`},{field:`location`,format:`location`}],description:{field:`description`}};function a5(e){return!e||typeof window>`u`?{}:h8(window.location.search)}function o5(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function s5(e){let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function c5(e){let{client:n}=q(),r=_t(p2),i=V(t=>n.views.execute(e.viewId,t),[n,e.viewId]),a=V(async(e,t)=>{if(t.source!==`content_thumbnail`)return;let r=e.document.content;try{let t=await n.objects.getRenditionSafe(e.id,r?.type,{format:mn.jpeg,max_hw:512,generate_if_missing:!1,sign_url:!0});if(t?.status===`found`&&t.renditions?.length)return t.renditions[0]}catch{}if(r?.source&&r.type?.startsWith(`image/`))return(await n.files.getDownloadUrl(r.source)).url},[n]),o=e=>r!==void 0&&e.some(e=>r.hasPermission(e));return t(u5,{...e,execute:i,resolveMedia:e.resolveMedia??a,client:n,canDelete:o([yn.content_delete,yn.content_admin,yn.content_superadmin]),canWrite:o([yn.content_write,yn.content_admin,yn.content_superadmin])})}function l5({execute:e,...n}){return e?t(u5,{...n,execute:e},n.viewId):t(c5,{...n},n.viewId)}function u5({execute:e,renderers:r,contributions:i,onOpenHit:a,resolveMedia:s,syncUrl:c=!0,showHeader:l=!0,className:u,client:d,canDelete:f=!1,canWrite:p=!1}){let{t:m}=K(),h=W(e);h.current=e;let g=W(0),[_,v]=G(()=>a5(c)),[y,b]=G(_.query??``),[x,S]=G(_.key_terms??{}),[C,w]=G(),[T,E]=G(!0),[D,O]=G(),[k,A]=G({}),j=W(void 0),N=V(()=>{j.current=void 0,A({})},[]),P=V((e,t,n=!1)=>{let r=++g.current;return n||N(),v(e),t&&c&&w8(e),E(!0),O(void 0),h.current(e).then(t=>{if(r===g.current){let n=S8(e,t);v(n),c&&w8(n),w(t)}}).catch(e=>{r===g.current&&O(e instanceof Error?e:Error(String(e)))}).finally(()=>{r===g.current&&E(!1)})},[N,c]),F=V(()=>{let e=a5(c);return b(e.query??``),S(e.key_terms??{}),P(e,!1)},[P,c]);H(()=>(F(),()=>{g.current+=1}),[F]),H(()=>{if(!c||typeof window>`u`)return;let e=()=>void F();return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[F,c]);let I=C?.definition,L=U(()=>[...I?.navigation??[]].sort((e,t)=>(e.order??0)-(t.order??0)),[I?.navigation]),ee=I?.results,R=ee?.selection,te=C?.display??_.display??ee?.default_display,ne=ee?.displays.find(e=>e.id===te)??i5,re=C?C8(_,C,ee?.default_sort):_.sort,ie=e=>{P(e,!0)},ae=(e,t)=>{let n=o5({..._.navigation??{},[e.id]:t});ie({..._,navigation:n,offset:void 0})},se=(e,t)=>{let n=s5({..._.navigation_queries??{},[e.id]:t});ie({..._,navigation_queries:n,offset:void 0})},ce=()=>{ie({..._,query:y.trim()||void 0,key_terms:o5(x),offset:void 0})},le=U(()=>{if(!R)return;let e=Object.keys(k);return{mode:R.mode,selectAll:R.mode===`multiple`&&R.select_all===`page`,selectedIds:e,selectedHits:e.map(e=>k[e]).filter(e=>e!==void 0),isSelected:e=>k[e]!==void 0,toggle:(e,t,n)=>{A(r=>{if(!t){let t={...r};return delete t[e.id],t}if(R.mode===`single`)return j.current=e.id,{[e.id]:e};let i={...r,[e.id]:e};if(n?.range&&n.page&&j.current){let t=n.page.findIndex(e=>e.id===j.current),r=n.page.findIndex(t=>t.id===e.id);if(t>=0&&r>=0){let e=Math.min(t,r),a=Math.max(t,r);for(let t of n.page.slice(e,a+1))i[t.id]=t}}return j.current=e.id,i})},togglePage:(e,t)=>{R.mode===`multiple`&&A(n=>{let r={...n};for(let n of e)t?r[n.id]=n:delete r[n.id];return r})},clear:N}},[N,k,R]);if(!C&&T)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center`,children:t(je,{size:`xl`})});if(!C||!I)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center p-4`,children:t(M,{title:m(`store.searchFailed`),action:()=>void F(),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)})});let ue=I.search?.renderer?r?.search?.[I.search.renderer]??r5:r5,de=ne.renderer?r?.results?.[ne.renderer]??X8:X8,fe=L.length>0&&I.layout?.navigation_position!==`top`,pe=I.layout?.mode===`worklist`,me=_.offset??0,he=_.limit??ne.page_size??20,ge=me>0,_e=me+C.hits.length<C.total,ve=L.map(e=>{let n=C.navigation[e.id]??{id:e.id,selected:[],nodes:[]},i=e.renderer?r?.navigation?.[e.renderer]??c8:c8;return t(i,{configuration:e,result:n,isLoading:T,onChange:t=>ae(e,t),onQueryChange:e.source===`collection`?t=>se(e,t):void 0},e.id)}),ye=()=>P(_,!1,!0),be=n(ir,{className:u,children:[l&&t(h0,{title:I.name,description:I.description}),n(ir.Fixed,{heightClass:`h-auto`,className:`space-y-3 border-b p-3`,children:[I.search&&t(ue,{configuration:I.search,query:y,keyTerms:x,isLoading:T,onQueryChange:b,onKeyTermsChange:(e,t)=>S(n=>({...n,[e]:t})),onSubmit:ce}),L.length>0&&I.layout?.navigation_position===`top`&&t(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:ve})]}),t(ir.Body,{className:`p-0`,children:n(`div`,{className:fe?pe?`grid min-h-full lg:grid-cols-[minmax(0,1fr)_18rem]`:`grid min-h-full lg:grid-cols-[18rem_minmax(0,1fr)]`:`min-h-full`,children:[fe&&t(`aside`,{className:pe?`space-y-5 border-b p-4 lg:order-2 lg:border-s lg:border-b-0`:`space-y-5 border-b p-4 lg:border-e lg:border-b-0`,children:ve}),n(`main`,{className:`min-w-0 space-y-4 p-4 ${pe?`lg:order-1`:``}`,children:[D&&t(M,{title:m(`store.searchFailed`),action:()=>void P(_,!1),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)}),C.search.warnings.length>0&&t(oe,{status:`warning`,title:m(`view.warning`),children:t(`ul`,{className:`list-disc space-y-1 ps-4`,children:C.search.warnings.map(e=>t(`li`,{children:e.message},`${e.code}-${e.path??``}`))})}),n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2 text-sm text-muted`,children:[t(`span`,{children:m(`view.resultsCount`,{count:C.total})}),T&&t(je,{size:`sm`})]}),n(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(n8,{selection:le,page:C.hits,showSelectPage:ne.type!==`table`}),ee?.allow_display_switch&&ee.displays.length>1&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.display`)}),t(we,{options:ee.displays,value:ne,onChange:e=>void P({..._,display:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.display`),className:`min-w-36`})]}),ee?.sort_options&&ee.sort_options.length>0&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.sort`)}),t(we,{options:ee.sort_options,value:ee.sort_options.find(e=>e.id===re),onChange:e=>void P({..._,sort:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.sort`),className:`min-w-44`})]})]})]}),t(a8,{definition:I,request:_,result:C,contribution:i?.drop,canWrite:p,refresh:ye,children:t(de,{configuration:ne,definition:I,request:_,result:C,isLoading:T,onSortChange:e=>void P({..._,sort:e,offset:void 0},!0,!0),onOpenHit:a,resolveMedia:s,selection:le})}),(ge||_e)&&n(`nav`,{className:`flex items-center justify-center gap-2`,"aria-label":m(`view.pagination`),children:[n(o,{type:`button`,variant:`outline`,disabled:!ge||T,onClick:()=>void P({..._,offset:Math.max(0,me-he)||void 0},!0,!0),children:[t(oh,{className:`size-4 cn-rtl-flip`}),m(`grounded.previousPage`)]}),n(o,{type:`button`,variant:`outline`,disabled:!_e||T,onClick:()=>void P({..._,offset:me+he},!0,!0),children:[m(`grounded.nextPage`),t(lh,{className:`size-4 cn-rtl-flip`})]})]})]})]})})]});return t(t8,{definition:I,request:_,result:C,selection:le,contributions:i,client:d,canDelete:f,refresh:ye,children:be})}gY(),CY(),TY(),QY();export{Jp as ActivitiesDoc,Xp as ActivityDoc,b6 as AddToCollectionAction,v6 as AddToCollectionActionComponent,Yb as AgentApprovalModeSelector,uC as AgentChart,FJ as AgentChatFixtureReplay,xC as AgentChatPlaybackControls,St as AgentResourceResolverProvider,$Z as AgentRunnerFacetsNav,o2 as AllOf,iW as AnimatedThinkingDots,a2 as AnyOf,KZ as ApiKeyAvatar,jH as AskUserWidget,t2 as AudioPanel,X4 as BrowseCollectionView,T6 as ChangeTypeAction,C6 as ChangeTypeActionComponent,n3 as CollectionIcon,sQ as CollectionsFacetsNav,t3 as CollectionsTable,MH as ConfirmationWidget,a1 as ContentDispositionButton,p3 as ContentObjectTypesSearch,i3 as ContentObjectTypesTable,E4 as ContentOverview,$4 as CreateCollectionForm,e3 as CreateCollectionModal,o3 as CreateOrUpdateTypeModal,c8 as DefaultViewNavigation,X8 as DefaultViewResults,r5 as DefaultViewSearch,k6 as DeleteObjectsAction,D6 as DeleteObjectsActionComponent,A6 as DeleteObjectsFromCollectionsAction,d4 as DocumentEditingPanel,u4 as DocumentEditingWorkspace,L$ as DocumentGridView,F$ as DocumentIcon,P$ as DocumentIconSkeleton,c6 as DocumentInput,l6 as DocumentPreviewPanel,R$ as DocumentSearch,r1 as DocumentSearchProvider,K4 as DocumentSearchResults,G4 as DocumentSearchResultsWithDropZone,XQ as DocumentSelection,e$ as DocumentSelectionProvider,Q$ as DocumentTable,N$ as DocumentTableColumn,I$ as DocumentTableView,Y$ as DocumentUploadModal,_Q as DocumentsFacetsNav,r6 as EditCollectionView,vQ as EnvironmentFacet,N6 as ExportPropertiesAction,j6 as ExportPropertiesComponent,f6 as ExportPropertiesModal,d6 as ExportTypes,G$ as FileUploadAction,h0 as GenericPageNavHeader,x0 as GroundedExtractionPanel,S0 as GroundedExtractionView,oZ as Header,n2 as ImagePanel,F3 as IntakePolicyEditor,yZ as InteractionLabel,vZ as InteractionStatusBadge,SQ as InteractionsFacetsNav,IJ as JumpingDots,_G as MESSAGE_STYLES,Y0 as MagicPdfView,KJ as McpConnectionsActionMenu,WJ as McpConnectionsButton,UJ as McpConnectionsDialog,GJ as McpConnectionsInlineList,yG as MessageItem,Z1 as MessagesContainer,K1 as ModernAgentConversation,g0 as NotFoundView,i2 as OAuthProviderConnectButton,K3 as ObjectSchemaEditor,s3 as ObjectTypeSearch,c3 as ObjectTypeSearchContext,Z3 as ObjectTypeSearchProvider,H6 as ObjectsActionContextProvider,s0 as PanelErrorBoundary,tZ as PayloadBuilder,rZ as PayloadBuilderProvider,eZ as PayloadBuilderStore,nZ as PayloadContext,pY as PdfDocumentRenderer,oY as PdfPageRenderer,_Y as PdfPageSlider,fY as PdfThumbnailList,wQ as ProcessDefinitionsFacetsNav,EQ as ProcessRunsFacetsNav,jQ as PromptsFacetsNav,f4 as PropertiesEditorModal,aW as PulsatingCircle,sW as PulsingMessageLoader,mO as RemoteMcpConnectionButton,I6 as RemoveFromCollectionAction,P6 as RemoveFromCollectionActionComponent,l0 as RowErrorBoundary,z6 as RunIntakeAction,L6 as RunIntakeActionComponent,LQ as RunsFacetsNav,n4 as SaveVersionConfirmModal,z$ as SearchContext,g2 as SecureButton,_2 as SecureSidebarItem,a6 as SelectCollection,Q4 as SelectContentType,X3 as SelectContentTypeModal,s1 as SelectDocument,o6 as SelectDocumentModal,$1 as SelectEnvironment,n0 as SelectModel,r0 as SelectTrainingModel,W6 as SelectionActions,sY as SharedPdfProvider,e6 as SharedPropsEditor,lY as SimplePdfPage,wY as SimplePdfViewer,_1 as SkillWidgetProvider,MG as StreamingMessage,RQ as StringFacet,zQ as StringListFacet,t6 as SyncMemberHeadsToggle,Q3 as TableLayoutEditor,cW as ThinkingBar,CW as ThinkingMessages,VQ as TypeFacet,eQ as TypeRegistry,nQ as TypeRegistryProvider,oW as TypedDots,ZY as UniversalDocumentViewer,G6 as UploadObjectsButton,X6 as UserAvatar,HZ as UserInfo,h2 as UserPermissionProvider,d2 as UserPermissions,p2 as UserPermissionsContext,xZ as VInteractionFacet,TZ as VStringFacet,cQ as VTypeFacet,YZ as VUserFacet,oC as VegaLiteChart,i0 as VertesiaErrorBoundary,r2 as VideoPanel,t8 as ViewActionsProvider,n8 as ViewActionsToolbar,l5 as ViewExperience,r8 as ViewRowActions,$0 as WEB_SUPPORTED_AUDIO_FORMATS,Z0 as WEB_SUPPORTED_IMAGE_FORMATS,Q0 as WEB_SUPPORTED_VIDEO_FORMATS,lW as WavyThinking,d0 as WidgetErrorBoundary,UQ as WorkflowDefinitionsFacetsNav,qQ as WorkflowExecutionsFacetsNav,YQ as WorkflowRulesFacetsNav,S8 as canonicalizeViewState,dC as clampPlaybackCursor,VJ as countConnectedActiveGroups,QZ as createAgentRunnerFilterHandler,s4 as createDocumentChangeSummaryPrompt,o4 as createDocumentReconcilePrompt,hC as createPlaybackState,fZ as createSearchQueryKeyGuard,uZ as filterValueToQueryValue,e2 as formatDuration,k8 as formatViewFieldValue,HJ as getConnectedActiveGroupLabels,tG as getContentObjectDownloadName,mC as getNextUserTurnIndex,fC as getPlaybackCursorIndex,pC as getPreviousUserTurnIndex,E8 as getViewFieldValue,S$ as getWorkflowStatusColor,C$ as getWorkflowStatusName,b2 as invalidateTypeCache,_C as isAgentChatPlaybackAvailable,vC as isAgentChatPlaybackEnabled,s2 as isAnyOf,d$ as isCsv,BJ as isGroupConnected,RJ as isGroupDisabled,f$ as isImage,yC as isLocalhostAgentChatPlaybackAvailable,bC as isLocalhostAgentChatPlaybackEnabled,p$ as isPdf,h$ as isPreviewableAsPdf,cC as isRechartsSpec,_Z as isUnresolvedInteractionRef,sC as isVegaLiteSpec,m$ as isVideo,h8 as parseViewState,g$ as printElementToPdf,w8 as replaceViewStateInUrl,gZ as resolveInteractionName,y2 as resolveTypeCached,C8 as resolveViewSort,y$ as retrieveRendition,y8 as serializeViewState,o0 as setErrorBoundaryComponent,dZ as setSearchQueryValue,b$ as shortId,x$ as shortenString,hZ as splitInteractionType,$3 as stringifyTableLayout,zJ as toggleGroupDisabled,lZ as unwrapFilterOptionValue,Gt as useAgentResourceResolver,ZZ as useAgentRunnerFilterGroups,aQ as useCollectionsFilterGroups,oQ as useCollectionsFilterHandler,hQ as useDocumentFilterGroups,gQ as useDocumentFilterHandler,B$ as useDocumentSearch,U$ as useDocumentSearchCount,QQ as useDocumentSelection,X$ as useDocumentUploadHandler,nG as useDownloadFile,NZ as useFetchApiKeyInfo,MZ as useFetchGroupInfo,jZ as useFetchUserInfo,y0 as useGroundedExtractionAvailable,b0 as useGroundedSummary,bQ as useInteractionsFilterGroups,xQ as useInteractionsFilterHandler,LJ as useMcpConnections,pO as useOAuthPopup,$Q as useOptionalDocumentSelection,iZ as usePayloadBuilder,CQ as useProcessDefinitionsFilterGroups,TQ as useProcessRunsFilterGroups,kQ as usePromptsFilterGroups,AQ as usePromptsFilterHandler,FQ as useRunsFilterGroups,IQ as useRunsFilterHandler,l3 as useSearch,d3 as useSearchCount,cY as useSharedPdf,J$ as useSmartFileUploadProcessing,rQ as useTypeRegistry,m2 as useUserPermissions,Q6 as useViewActions,V$ as useWatchDocumentSearchFacets,H$ as useWatchDocumentSearchResult,u3 as useWatchSearchResult,HQ as useWorkflowDefinitionsFilterGroups,GQ as useWorkflowExecutionsFilterGroups,KQ as useWorkflowExecutionsFilterHandler,JQ as useWorkflowRulesFilterGroups};
|
|
1403
1403
|
//# sourceMappingURL=vertesia-ui-features.js.map
|