vibe64 0.1.47 → 0.1.49
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/bin/run.js +1734 -1687
- package/bin/server.js +75 -75
- package/bin/upgrade-state.js +4539 -4471
- package/dist/assets/GithubBrowserTabs-BwpiRS2u.js +1 -0
- package/dist/assets/{LocalDatabaseServer-6VzPWZxG.js → LocalDatabaseServer-u_Ky7bNS.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-TLwqAxDo.js → Vibe64AuthSettingsButton-BCwswT1G.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-B4dQ-oHD.js → Vibe64DashboardShell-CWlgrR2B.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-Bh5WIPOj.js → Vibe64DatabaseWorkspace-Dhs8_H0P.js} +1 -1
- package/dist/assets/Vibe64OutputControls-Dn548CZa.js +8 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-idDg94lc.js → Vibe64RepositoryWorkspace-C-8S4JUF.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-Z9zxosyl.js → Vibe64SessionFiles-Cx6J7DDN.js} +2 -3
- package/dist/assets/{Vibe64UiStoryboardView-CrCDWMdR.js → Vibe64UiStoryboardView-DHyhJiWS.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-TqsxvGSf.js → Vibe64UnavailableSessions-Da4RxIhA.js} +1 -1
- package/dist/assets/{_sessionId_-7F1VGOou.js → _sessionId_-DCpgDPSI.js} +1 -1
- package/dist/assets/_slug_-BbEWp01a.js +25 -0
- package/dist/assets/{_slug_-B16mTWjj.css → _slug_-DerKOisL.css} +1 -1
- package/dist/assets/{access-Cx9RH95J.js → access-D4di2sCr.js} +1 -1
- package/dist/assets/{app-DPx4KKOa.js → app-Adr9Iz8p.js} +1 -1
- package/dist/assets/asyncModuleRecovery-DJsn5NrL.js +1 -0
- package/dist/assets/{changes-DYsuQLFW.js → changes-3Dd1O8Lu.js} +1 -1
- package/dist/assets/client-BAXHGUOC.js +1 -0
- package/dist/assets/{client-BYsDPxR3.js → client-CCZIu6yc.js} +1 -1
- package/dist/assets/{conversation-3ln-WnbL.css → conversation-CSDHdGDb.css} +1 -1
- package/dist/assets/conversation-DG9lp25w.js +8 -0
- package/dist/assets/conversation-ErAO1CmH.js +13 -0
- package/dist/assets/{dashboard-CWswAbYP.js → dashboard-0tCzDYCX.js} +1 -1
- package/dist/assets/english-definitions-DeiQ-jTT.js +1 -0
- package/dist/assets/env-DsyQ2MFX.js +1 -0
- package/dist/assets/{health-C0f6s-G1.js → health-DyTXU-nb.js} +1 -1
- package/dist/assets/{history-BQjETNB9.js → history-BXGAdPMI.js} +1 -1
- package/dist/assets/{incoming-COpY201m.js → incoming-yajkdGBY.js} +1 -1
- package/dist/assets/{index-MWACm8Pp.css → index-B-dukXUB.css} +1 -1
- package/dist/assets/index-CGz4Yow6.js +136 -0
- package/dist/assets/{integrations-BBkvNRHu.js → integrations-BMrXET36.js} +10 -2
- package/dist/assets/issues-kc1XBZCK.js +1 -0
- package/dist/assets/{learning-B8_wHoe1.js → learning-CIE5ghYv.js} +1 -1
- package/dist/assets/linkPath-Ch9eft18.js +1 -0
- package/dist/assets/{placement-DXvgK433.js → placement-BNmlke_j.js} +1 -1
- package/dist/assets/placement-DYM3JJ-F.js +1 -0
- package/dist/assets/publish-DTh6amqi.js +3 -0
- package/dist/assets/pull-requests-CbfGSSIh.js +1 -0
- package/dist/assets/{repository-BNPt7UWc.js → repository-BstMh-bG.js} +1 -1
- package/dist/assets/settings-Bf8C6dls.js +1 -0
- package/dist/assets/{studioGateApi-BVdclhPL.js → studioGateApi-mkX1eOTX.js} +1 -1
- package/dist/assets/{studioUrls-CGKCbM_d.js → studioUrls-B0-GdWh8.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-DIOpfUxD.js +1 -0
- package/dist/assets/useCommand-CVuya6vG.js +1 -0
- package/dist/assets/useEndpointResource-7-YDfAxX.js +1 -0
- package/dist/assets/usePaths-Y6UuQxmI.js +1 -0
- package/dist/assets/{useUiFeedback-B51xtCAK.js → useUiFeedback-Bd3rao6E.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-ChJOU2SD.js +1 -0
- package/dist/assets/{useVibe64DatabaseTools-BE_yXZFn.js → useVibe64DatabaseTools-DKV-TeNJ.js} +1 -1
- package/dist/assets/{useVibe64ProjectScope-D7b8n1gx.js → useVibe64ProjectScope-DXjsKKhl.js} +1 -1
- package/dist/assets/useVibe64SessionData-BkIHUrP5.js +1 -0
- package/dist/assets/useVibe64SessionSelection-N8wX5oqo.js +1 -0
- package/dist/assets/{useVibe64SystemGraph-CDDcsye4.js → useVibe64SystemGraph-Db_eD-X8.js} +1 -1
- package/dist/assets/{useVibe64Terminal-Zr3Mig2L.js → useVibe64Terminal-B9EWJ9Ba.js} +2 -2
- package/dist/assets/vibe64ProjectScope.local-l5_-E6pq.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-CHT4-6VN.js +1 -0
- package/dist/assets/vibe64SessionFocus-CS6Ex53G.js +1 -0
- package/dist/assets/vibe64SessionFocus-CSm4YJQD.css +1 -0
- package/dist/assets/vibe64SessionRequestConfig-xIx-5jxQ.js +1 -0
- package/dist/index.html +26 -22
- package/docs/colleague-usage/ai-accounts.md +6 -2
- package/docs/colleague-usage/ai-balance-and-allowance.md +15 -2
- package/docs/colleague-usage/coding-agent-failures.md +2 -1
- package/docs/colleague-usage/coding-agent-goals.md +8 -3
- package/docs/colleague-usage/coding-agents.md +16 -0
- package/docs/colleague-usage/github-work.md +14 -0
- package/docs/colleague-usage/preview-browser-checks.md +5 -3
- package/docs/colleague-usage/project-setup.md +6 -3
- package/docs/colleague-usage/running-vibe64-on-your-computer.md +3 -1
- package/docs/colleague-usage/sessions.md +35 -7
- package/docs/colleague-usage/starter-apps.md +3 -0
- package/docs/colleague-usage/temporary-chat-context.md +2 -1
- package/docs/colleague-usage/temporary-chats.md +17 -5
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +539 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +383 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +3 -2
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +138 -0
- package/node_modules/@jskit-ai/assistant-runtime/README.md +2 -1
- package/node_modules/@jskit-ai/assistant-runtime/locales/en.json +137 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +3 -2
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/assistantConfigRepository.js +223 -203
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/conversationsRepository.js +286 -266
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/messagesRepository.js +270 -250
- package/node_modules/@jskit-ai/assistant-voice/locales/en.json +182 -0
- package/node_modules/@jskit-ai/assistant-voice/package.json +3 -2
- package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +83 -0
- package/node_modules/@jskit-ai/connector-google-calendar/locales/en.json +91 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +4 -3
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1722 -0
- package/node_modules/@jskit-ai/connectors-catalog/README.md +11 -0
- package/node_modules/@jskit-ai/connectors-catalog/locales/en.json +3139 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +5 -4
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +183 -0
- package/node_modules/@jskit-ai/connectors-core/locales/en.json +92 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +3 -2
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +31 -0
- package/node_modules/@jskit-ai/http-runtime/locales/en.json +14 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +3 -2
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +182 -0
- package/node_modules/@jskit-ai/kernel/locales/en.json +94 -0
- package/node_modules/@jskit-ai/kernel/package.json +6 -2
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +128 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +77 -0
- package/node_modules/@jskit-ai/payments-core/package.json +3 -2
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +20 -0
- package/node_modules/@jskit-ai/realtime/locales/en.json +14 -0
- package/node_modules/@jskit-ai/realtime/package.json +3 -2
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/resource-crud-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/CHANGELOG.md +35 -0
- package/node_modules/@jskit-ai/uploads-runtime/locales/en.json +15 -0
- package/node_modules/@jskit-ai/uploads-runtime/package.json +3 -2
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +49 -48
- package/node_modules/@local/vibe64-execution/src/server/gitTurnCheckpointCommand.js +1327 -0
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +430 -390
- package/node_modules/@local/vibe64-genesis/src/server/index.js +45 -45
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +119 -119
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +57 -57
- package/node_modules/@local/vibe64-sessions/package.json +2 -1
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +195 -175
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1385 -1362
- package/package.json +15 -15
- package/server.bundle.mjs +44206 -42825
- package/dist/assets/GithubBrowserTabs-D-Z3TlA8.js +0 -1
- package/dist/assets/Vibe64OutputControls-DtybwgL3.js +0 -8
- package/dist/assets/_slug_-Bq84T_Iv.js +0 -24
- package/dist/assets/conversation-Bn7wpATa.js +0 -2
- package/dist/assets/conversation-CNcCrV-R.js +0 -16
- package/dist/assets/definitions-CEbi4qae.js +0 -1
- package/dist/assets/env-X7EOFLtl.js +0 -1
- package/dist/assets/index-CBo1BEk6.js +0 -138
- package/dist/assets/issues-BiSiUd5o.js +0 -1
- package/dist/assets/placement-B5T1LR7m.js +0 -1
- package/dist/assets/publish-CeLZE2AG.js +0 -3
- package/dist/assets/pull-requests-pTdQOT7i.js +0 -1
- package/dist/assets/settings-lecRzZ-r.js +0 -1
- package/dist/assets/useArchivedVibe64Sessions-DHYRnyJD.js +0 -1
- package/dist/assets/useCommand-Epd2yHhQ.js +0 -1
- package/dist/assets/useEndpointResource-DBRQISI_.js +0 -1
- package/dist/assets/usePaths-DdAnjVDj.js +0 -1
- package/dist/assets/useVibe64ConversationLog-DboM3tYN.js +0 -1
- package/dist/assets/useVibe64SessionData-CreWtQAO.js +0 -1
- package/dist/assets/useVibe64SessionSelection-CDaX4uwY.js +0 -1
- package/dist/assets/vibe64ProjectScope.local-BxTBYuRg.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-C-J0I5jY.js +0 -1
- package/dist/assets/vibe64SessionFocus-DSW5Irm6.css +0 -1
- package/dist/assets/vibe64SessionFocus-DzqbVq60.js +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import{$n as normalizeProps,D as createVNode,E as createTextVNode,En as toValue,Ht as watch,On as unref,St as resolveComponent,Yt as withDirectives,Zn as normalizeClass,_ as createBaseVNode,an as getCurrentScope,b as createElementBlock,bt as renderList,ct as onMounted,er as normalizeStyle,et as mergeProps,g as computed,gn as reactive,it as onBeforeUnmount,mt as openBlock,o as Fragment,pn as onScopeDispose,qt as withCtx,tr as toDisplayString,tt as nextTick,v as createBlock,vn as ref,w as createSlots,wn as toRef,wt as resolveDynamicComponent,xt as renderSlot,y as createCommentVNode,z as guardReactiveProps}from"./runtime-core.esm-bundler-DGXg_mpN.js";import{B as useRounded,D as makeDensityProps,Dt as genericComponent,Ft as makeComponentProps,G as useDimension,It as propsFactory,K as VDefaultsProvider,Mt as provideDefaults,O as useDensity,Q as makeTagProps,Tn as pick,U as useTextColor,V as useBackgroundColor,W as makeDimensionProps,_ as VIcon,_t as IconValue,bt as useRender,cr as withKeys,i as makeRouterProps,lr as withModifiers,lt as useDisplay,o as useLink,qn as isString,sr as vShow,z as makeRoundedProps}from"./VAvatar-H2hyOWlB.js";import{T as ROUTE_VISIBILITY_PUBLIC,t as useEndpointResource}from"./useEndpointResource-DBRQISI_.js";import{d as getHttpWebClient,r as projectAppPath}from"./vibe64ProjectScope.local-BxTBYuRg.js";import{n as VList,s as VListItem,t as VMenu}from"./VMenu-DnhVIMrr.js";import{t as VChip}from"./VChip-Uixfx461.js";import{t as VTextField}from"./VTextField-CnkGeXaT.js";import{r as scopedDevelopmentApiUrl,t as resolveStudioRequestUrl}from"./studioUrls-CGKCbM_d.js";import{$n as mdiRedoVariant,Cr as mdiStar,Ct as mdiDotsVertical,Ft as mdiFileOutline,H as mdiChevronLeft,Hr as mdiVolumeHigh,Ht as mdiFolderOutline,It as mdiFilePlusOutline,Lt as mdiFileSearchOutline,Mn as mdiMicrophone,Nn as mdiMicrophoneOff,Nt as mdiFileDocumentOutline,Pr as mdiTrayArrowUp,Rr as mdiUndoVariant,S as mdiArrowLeft,Sr as mdiSourceRepository,Tr as mdiStop,U as mdiChevronRight,Un as mdiPencilOutline,Ur as mdiVolumeOff,Ut as mdiFolderPlusOutline,X as mdiClose,ar as mdiRobotOutline,at as mdiCollapseAllOutline,bt as mdiDeleteOutline,er as mdiRefresh,ft as mdiContentSaveOutline,kn as mdiMagnify,kt as mdiFileCodeOutline,lr as mdiSend,t as mdiAccountCheckOutline,ut as mdiContentCopy,wr as mdiStarOutline,wt as mdiDownload,xt as mdiDotsHorizontal,y as mdiArchiveClockOutline,zr as mdiUpload}from"./mdi-X9prU-DG.js";import{t as VBtn}from"./VBtn-Sj5jAuOx.js";import{t as VAlert}from"./VAlert-7_VM9EUm.js";import{t as VDialog}from"./VDialog-Drp3yzSH.js";import{i as VCardTitle,n as VCardText,o as VCardActions,t as VCard}from"./VCard-DExT9Cji.js";import{t as VSpacer}from"./VSpacer-BSTt0_VA.js";import{t as VSkeletonLoader}from"./VSkeletonLoader-pc4bBTxv.js";import{t as VTextarea}from"./VTextarea-wqoRFl1K.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{_ as parseLongTextReviewBlocks,a as AssistantAttachmentQueue_default,c as AssistantPromptInput_default,g as LongTextPreviewBlocks_default,h as _sfc_main$14,m as useScrollToBottom,n as AssistantConversationElement_default,t as AssistantAttachmentPreview_default,u as scrollElementNearBottom,v as AssistantMessageAttachments_default}from"./conversation-CNcCrV-R.js";import"./conversation-Bn7wpATa.js";import{n as useRealtimeEvent}from"./useRealtimeEvent-BNXVwzFG.js";import{t as usePaths}from"./usePaths-DdAnjVDj.js";import{a as conversationAttachmentReference,c as vibe64AssistantSelectionLabel,g as vibe64AgentExecutionProfileAuditSnapshot,i as conversationAttachmentContentType,l as vibe64ProviderPresentation,o as normalizeVibe64ConversationAttachments}from"./shared-TUhK_uYM.js";import{c as assistantGoalManagementMessage,l as assistantGoalObjective,u as assistantModeLabel}from"./assistantRouting-D_9PZkWu.js";import{t as useCommand}from"./useCommand-Epd2yHhQ.js";import{t as useUiFeedback}from"./useUiFeedback-B51xtCAK.js";import{n as stableLocalStorageKeyPart,r as writeLocalStorageJson,t as readLocalStorageJson}from"./browserLocalStorage-B4C7rHrs.js";import{t as writeClipboardText}from"./clipboard-CZs9aH3L.js";import"./shared-BEwrtWSp.js";import{n as vibe64ApiResponseError,t as vibe64ApiError}from"./vibe64ApiResponses-B4VY77Q_.js";import{r as vibe64RealtimePayloadFromCurrentTab,t as vibe64BrowserTabOriginId}from"./vibe64BrowserTabOrigin-SF9E31vi.js";import{t as useVibe64SystemGraph}from"./useVibe64SystemGraph-CDDcsye4.js";import{A as VIBE64_SOURCE_EDITOR_SYNC_ERROR_EVENT,Bt as VTab,D as VIBE64_SESSIONS_API_SUFFIX,Dt as createProjectVoiceBinding,F as vibe64AgentAttachmentPath,Ft as useVoiceLauncher,It as VoiceAvatar_default,Jt as usePageActivity,Mt as VoiceConversationHost_default,Nt as VoiceConversationSettings_default,O as VIBE64_SESSION_CHANGED_EVENT,P as vibe64AgentAttachmentFilePath,Pt as VoiceConversationControls_default,_t as vibe64SourceEditorSearchPath,at as vibe64SessionsQueryKey,b as readRefOrGetterValue,ct as vibe64SourceEditorDownloadPath,dt as vibe64SourceEditorExplanationStopPath,et as vibe64SessionPath,ft as vibe64SourceEditorExplanationsCleanupPath,gt as vibe64SourceEditorResolvePathPath,h as F,ht as vibe64SourceEditorFilesPath,j as VIBE64_SOURCE_EDITOR_SYNC_READY_EVENT,jt as useVibe64Voice,k as VIBE64_SOURCE_EDITOR_FILE_CHANGED_EVENT,lt as vibe64SourceEditorExplanationFollowupsStreamPath,m as GithubMarkdown_default,mt as vibe64SourceEditorFilePath,ot as vibe64SourceEditorChangesStreamPath,pt as vibe64SourceEditorExplanationsStreamPath,st as vibe64SourceEditorCreateFilePath,ut as vibe64SourceEditorExplanationPath,yt as vibe64SourceEditorTreePath,zt as VTabs}from"./index-CBo1BEk6.js";import{$ as rectangularSelection,A as foldService,B as tags$1,C as continuedIndent,Ct as NodeWeakMap,D as flatIndent,E as delimitedIndent,Et as parseMixed,F as sublanguageProp,G as drawSelection,H as EditorView,I as syntaxHighlighting,J as getPanel,K as dropCursor,L as syntaxTree,M as indentOnInput,N as indentUnit,O as foldInside,P as languageDataProp,Q as lineNumbers,R as Tag,S as bracketMatchingHandle,St as NodeType,T as defineLanguageFacet,Tt as Tree,U as ViewPlugin,V as Decoration,W as crosshairCursor,X as highlightActiveLineGutter,Z as keymap,_ as LanguageDescription,_t as findClusterBreak,a as redo,at as Compartment,b as StreamLanguage,bt as NodeProp,c as completeFromList,ct as Facet,d as ContextTracker,dt as StateEffect,et as runScopeHandlers,f as ExternalTokenizer,ft as StateField,g as Language,gt as countColumn,h as LRLanguage,ht as combineConfig,i as indentWithTab,it as CharCategory,j as indentNodeProp,k as foldNodeProp,l as ifNotIn,lt as Prec,m as LocalTokenGroup,mt as codePointSize,n as history,nt as showPanel,o as undo,ot as EditorSelection,p as LRParser,pt as codePointAt,q as getDialog,r as historyKeymap,rt as crelt,s as CompletionContext,st as EditorState,t as defaultKeymap,tt as showDialog,u as snippetCompletion,ut as RangeSetBuilder,v as LanguageSupport,vt as fromCodePoint,w as defaultHighlightStyle,wt as Parser,x as bracketMatching,xt as NodeSet,y as ParseContext,yt as IterMode,z as styleTags}from"./dist-CDa9Iec1.js";import{s as vibe64SessionShortLabel}from"./vibe64SessionViewModel-B0cCumM8.js";import{n as vibe64SessionDebugError,r as vibe64SessionDebugLog}from"./vibe64SessionDebugLog-C06bcdUN.js";import{t as diffLines}from"./libesm-CR-iGldz.js";var makeVBreadcrumbsDividerProps=propsFactory({divider:[Number,String],...makeComponentProps()},`VBreadcrumbsDivider`);var VBreadcrumbsDivider=genericComponent()({name:`VBreadcrumbsDivider`,props:makeVBreadcrumbsDividerProps(),setup(props,{slots}){useRender(()=>createBaseVNode(`li`,{"aria-hidden":`true`,"class":normalizeClass([`v-breadcrumbs-divider`,props.class]),"style":normalizeStyle(props.style)},[slots?.default?.()??props.divider]));return{}}});var makeVBreadcrumbsItemProps=propsFactory({active:Boolean,activeClass:String,activeColor:String,color:String,disabled:Boolean,title:String,...makeComponentProps(),...pick(makeDimensionProps(),[`width`,`maxWidth`]),...makeRouterProps(),...makeTagProps({tag:`li`})},`VBreadcrumbsItem`);var VBreadcrumbsItem=genericComponent()({name:`VBreadcrumbsItem`,props:makeVBreadcrumbsItemProps(),setup(props,{slots,attrs}){const link=useLink(props,attrs);const isActive=computed(()=>props.active||link.isActive?.value);const{dimensionStyles}=useDimension(props);const{textColorClasses,textColorStyles}=useTextColor(()=>isActive.value?props.activeColor:props.color);useRender(()=>{return createVNode(props.tag,{"class":normalizeClass([`v-breadcrumbs-item`,{"v-breadcrumbs-item--active":isActive.value,"v-breadcrumbs-item--disabled":props.disabled,[`${props.activeClass}`]:isActive.value&&props.activeClass},textColorClasses.value,props.class]),"style":normalizeStyle([textColorStyles.value,dimensionStyles.value,props.style]),"aria-current":isActive.value?`page`:void 0},{default:()=>[!link.isLink.value?slots.default?.()??props.title:createBaseVNode(`a`,mergeProps({"class":`v-breadcrumbs-item--link`,"onClick":link.navigate.value},link.linkProps),[slots.default?.()??props.title])]})});return{}}});var makeVBreadcrumbsProps=propsFactory({activeClass:String,activeColor:String,bgColor:String,color:String,disabled:Boolean,divider:{type:String,default:`/`},icon:IconValue,items:{type:Array,default:()=>[]},...makeComponentProps(),...makeDensityProps(),...makeRoundedProps(),...makeTagProps({tag:`ul`})},`VBreadcrumbs`);var VBreadcrumbs=genericComponent()({name:`VBreadcrumbs`,props:makeVBreadcrumbsProps(),setup(props,{slots}){const{backgroundColorClasses,backgroundColorStyles}=useBackgroundColor(()=>props.bgColor);const{densityClasses}=useDensity(props);const{roundedClasses,roundedStyles}=useRounded(props);provideDefaults({VBreadcrumbsDivider:{divider:toRef(()=>props.divider)},VBreadcrumbsItem:{activeClass:toRef(()=>props.activeClass),activeColor:toRef(()=>props.activeColor),color:toRef(()=>props.color),disabled:toRef(()=>props.disabled)}});const items=computed(()=>props.items.map(item=>{return isString(item)?{item:{title:item},raw:item}:{item,raw:item}}));useRender(()=>{const hasPrepend=!!(slots.prepend||props.icon);return createVNode(props.tag,{"class":normalizeClass([`v-breadcrumbs`,backgroundColorClasses.value,densityClasses.value,roundedClasses.value,props.class]),"style":normalizeStyle([backgroundColorStyles.value,roundedStyles.value,props.style])},{default:()=>[hasPrepend&&createBaseVNode(`li`,{"key":`prepend`,"class":`v-breadcrumbs__prepend`},[!slots.prepend?createVNode(VIcon,{"key":`prepend-icon`,"start":true,"icon":props.icon},null):createVNode(VDefaultsProvider,{"key":`prepend-defaults`,"disabled":!props.icon,"defaults":{VIcon:{icon:props.icon,start:true}}},slots.prepend)]),items.value.map(({item,raw},index,array)=>createBaseVNode(Fragment,null,[slots.item?.({item,index})??createVNode(VBreadcrumbsItem,mergeProps({"key":index,"disabled":index>=array.length-1},isString(item)?{title:item}:item),{default:slots.title?()=>slots.title?.({item,index}):void 0}),index<array.length-1&&createVNode(VBreadcrumbsDivider,null,{default:slots.divider?()=>slots.divider?.({item:raw,index}):void 0})])),slots.default?.()]})});return{}}});function assistantAttachmentSessionId(sessionId){return String(toValue(sessionId)||``).trim()}function assistantAttachmentUploadAllowed(canUpload){return toValue(canUpload)!==false}function assistantAttachmentFiles(fileList=[]){return Array.from(fileList||[]).filter(file=>file&&file.size>=0)}function assistantAttachmentFilesFromTransferItems(items=[]){return assistantAttachmentFiles(Array.from(items||[]).map(item=>{if(item?.kind!==`file`||typeof item.getAsFile!==`function`)return null;return item.getAsFile()}))}function assistantAttachmentFilesFromDropEvent(event){const dataTransfer=event?.dataTransfer;const itemFiles=assistantAttachmentFilesFromTransferItems(dataTransfer?.items);if(itemFiles.length>0)return itemFiles;return assistantAttachmentFiles(dataTransfer?.files)}function assistantAttachmentFilesFromPasteEvent(event){const clipboardData=event?.clipboardData;const itemFiles=assistantAttachmentFilesFromTransferItems(clipboardData?.items);if(itemFiles.length>0)return itemFiles;return assistantAttachmentFiles(clipboardData?.files)}function assistantAttachmentEventHasFiles(event){const dataTransfer=event?.dataTransfer;return assistantAttachmentFilesFromDropEvent(event).length>0||Array.from(dataTransfer?.items||[]).some(item=>item?.kind===`file`)||Array.from(dataTransfer?.types||[]).some(type=>type===`Files`||type===`application/x-moz-file`)}function assistantAttachmentClipboardText(event){if(typeof event?.clipboardData?.getData!==`function`)return``;return String(event.clipboardData.getData(`text/plain`)||``)}function assistantAttachmentClipboardLocalFileReference(event){const clipboardData=event?.clipboardData;if(!clipboardData||typeof clipboardData.getData!==`function`)return``;const types=Array.from(clipboardData.types||[]);const text=[clipboardData.getData(`x-special/gnome-copied-files`),clipboardData.getData(`text/uri-list`),clipboardData.getData(`text/plain`)].map(value=>String(value||``).trim()).filter(Boolean).join(`
|
|
2
|
-
`);if(types.includes(`Files`)||types.includes(`application/x-moz-file`)||types.includes(`x-special/gnome-copied-files`)||/^file:/imu.test(text))return text||`file://`;return``}function attachmentUploadError(attachment={}){return attachment?.error||attachment?.errors?.[0]?.message||``}function attachmentIdentity(attachment={}){return String(attachment?.clientId||attachment?.attachmentId||attachment?.path||attachment?.fileName||``)}var ASSISTANT_ATTACHMENT_MAX_BYTES=1e8;var ASSISTANT_ATTACHMENT_UPLOAD_CONCURRENCY=2;var ASSISTANT_ATTACHMENT_UNRESOLVED_PHASES=new Set([`preparing`,`queued`,`uploading`,`delivering`,`failed`]);var attachmentClientSequence=0;function nextAttachmentClientId(){attachmentClientSequence+=1;return`attachment-${Date.now().toString(36)}-${attachmentClientSequence.toString(36)}`}function attachmentFileName(file={}){return String(file?.name||`attachment`)}function attachmentUploadResult(upload=null){if(upload&&typeof upload.then===`function`)return{cancel:typeof upload.cancel===`function`?()=>upload.cancel():null,promise:upload};if(upload?.promise&&typeof upload.promise.then===`function`)return{cancel:typeof upload.abort===`function`?()=>upload.abort():typeof upload.cancel===`function`?()=>upload.cancel():null,promise:upload.promise};return{cancel:null,promise:Promise.resolve(upload)}}function attachmentProgress(progress={},possibleTotal,fallbackTotal=0){const directNumericProgress=typeof progress===`number`?progress:null;const progressObject=progress&&typeof progress===`object`?progress:{};const totalBytes=Math.max(0,Number(progressObject.totalBytes??progressObject.total??possibleTotal??fallbackTotal)||0);const bytesValue=progressObject.bytesSent??progressObject.loaded??progressObject.uploadedBytes??directNumericProgress;const bytesKnown=bytesValue!==null&&bytesValue!==void 0&&bytesValue!==``;let bytesSent=bytesKnown?Number(bytesValue)||0:0;const directPercent=progressObject.percent;let percent=directPercent!==null&&directPercent!==void 0&&directPercent!==``?Number(directPercent):null;const progressValue=progressObject.progress;if(!Number.isFinite(percent)&&progressValue!==null&&progressValue!==void 0&&progressValue!==``){const numericProgressValue=Number(progressValue);if(Number.isFinite(numericProgressValue))percent=numericProgressValue<=1?numericProgressValue*100:numericProgressValue}if(!Number.isFinite(percent))percent=bytesKnown&&totalBytes>0?bytesSent/totalBytes*100:null;if(percent!==null)percent=Math.max(0,Math.min(100,percent));if(totalBytes>0){const inferredBytes=percent===null?0:totalBytes*percent/100;bytesSent=Math.max(0,Math.min(totalBytes,bytesSent||inferredBytes))}else bytesSent=Math.max(0,bytesSent);return{bytesSent,percent,totalBytes}}function attachmentReceipt(row,uploaded={}){return{...uploaded,attachmentId:String(uploaded?.attachmentId||``),clientId:row.clientId,fileName:String(uploaded?.fileName||row.fileName),sessionId:row.sessionId,size:Number(uploaded?.size??row.size)||0}}function useAssistantAttachments({canUpload=()=>true,deleteAttachment=null,onError=null,onUploaded=async()=>null,sessionId,uploadAttachment,maxBytes=ASSISTANT_ATTACHMENT_MAX_BYTES,maxItems=10,uploadConcurrency=2}={}){if(![maxBytes,maxItems,uploadConcurrency].every(value=>Number.isSafeInteger(value)&&value>0))throw new TypeError(`Attachment limits must be positive integers.`);const maxSizeLabel=maxBytes%1048576===0?`${maxBytes/1048576} MiB`:`${maxBytes/1e6} MB`;const attachments=ref([]);const queueItems=ref([]);const dragDepth=ref(0);const status=ref(``);const activeUploadCount=ref(0);const uploadQueue=[];const rowsById=new Map;const activeAttempts=new Map;const cleanupTasks=new Set;const receiptCleanupById=new Map;const cleanedReceiptIds=new Set;let disposed=false;let stopSessionWatch=null;const dragActive=computed(()=>dragDepth.value>0);const uploading=computed(()=>activeUploadCount.value>0||queueItems.value.some(item=>[`preparing`,`uploading`,`delivering`].includes(item.phase)));const hasUnresolved=computed(()=>queueItems.value.some(item=>ASSISTANT_ATTACHMENT_UNRESOLVED_PHASES.has(item.phase)));const canSubmit=computed(()=>!hasUnresolved.value);const retainedItemCount=computed(()=>queueItems.value.filter(item=>item.phase!==`cancelled`).length);const atCapacity=computed(()=>retainedItemCount.value>=maxItems);const canAddFiles=computed(()=>Boolean(!disposed&&assistantAttachmentSessionId(sessionId)&&assistantAttachmentUploadAllowed(canUpload)&&!atCapacity.value&&typeof uploadAttachment===`function`));const aggregateProgress=computed(()=>{const retainedItems=queueItems.value.filter(item=>item.phase!==`cancelled`);const totalBytes=retainedItems.reduce((sum,item)=>sum+item.totalBytes,0);const bytesSent=retainedItems.reduce((sum,item)=>sum+item.bytesSent,0);return{bytesSent,percent:totalBytes>0?Math.round(bytesSent/totalBytes*100):0,totalBytes}});function reportAttachmentError(error,fallbackMessage=`Attachment upload failed.`,{notify=true}={}){const message=String(error?.message||error||fallbackMessage);status.value=message;if(notify&&typeof onError===`function`)try{onError(error||new Error(message),fallbackMessage)}catch{}return message}function resetDragState(){dragDepth.value=0}function clearStatus(){status.value=``}function createWaiter(row){let resolve=null;row.waiter={promise:new Promise(currentResolve=>{resolve=currentResolve}),resolve,settled:false};return row.waiter}function settleWaiter(row,value=null,waiter=row.waiter){if(!waiter||waiter.settled)return;waiter.settled=true;waiter.resolve(value)}function canonicalRow(attachment={}){const identity=attachmentIdentity(attachment);return identity?rowsById.get(identity)||queueItems.value.find(row=>attachmentIdentity(row)===identity||row.attachmentId===identity):null}function trackCleanup(task){const cleanup=Promise.resolve(task).catch(error=>{reportAttachmentError(error,`Attachment cleanup failed.`);return false});cleanupTasks.add(cleanup);cleanup.finally(()=>cleanupTasks.delete(cleanup));return cleanup}async function deleteUploadedAttachment(currentSessionId,attachment={}){const attachmentId=String(attachment?.attachmentId||``).trim();if(!attachmentId||typeof deleteAttachment!==`function`)return false;const response=await deleteAttachment(currentSessionId,attachmentId);if(response?.ok===false)throw new Error(attachmentUploadError(response)||`Attachment cleanup failed.`);return true}function cleanupReceipt(currentSessionId,receipt={}){const attachmentId=String(receipt?.attachmentId||``).trim();const cleanupId=`${currentSessionId}:${attachmentId}`;if(!attachmentId)return Promise.resolve(false);if(cleanedReceiptIds.has(cleanupId))return Promise.resolve(false);if(receiptCleanupById.has(cleanupId))return receiptCleanupById.get(cleanupId);const cleanup=trackCleanup(deleteUploadedAttachment(currentSessionId,receipt)).then(deleted=>{if(deleted)cleanedReceiptIds.add(cleanupId);return deleted});receiptCleanupById.set(cleanupId,cleanup);cleanup.finally(()=>receiptCleanupById.delete(cleanupId));return cleanup}function updateProgress(row,progress,total){if(!row.retained||row.phase!==`uploading`)return;const next=attachmentProgress(progress,total,row.totalBytes);row.bytesSent=Math.max(row.bytesSent,next.bytesSent);row.totalBytes=next.totalBytes||row.totalBytes;if(next.percent!==null)row.progress=Math.max(Number(row.progress)||0,next.percent)}function removeReadyReceipt(row){const removed=attachments.value.filter(attachment=>attachment.clientId===row.clientId);attachments.value=attachments.value.filter(attachment=>attachment.clientId!==row.clientId);return removed}async function handOffUploadedAttachment(row,receipt,waiter=row.waiter){const token=Symbol(`${row.clientId}-handoff`);row.activeHandoffToken=token;row.phase=`delivering`;if(!attachments.value.some(attachment=>attachment.clientId===row.clientId))attachments.value.push(receipt);try{const accepted=(await onUploaded([receipt]))?.accepted===true;if(row.activeHandoffToken!==token||!row.retained||row.phase===`cancelled`){removeReadyReceipt(row);if(!accepted)await cleanupReceipt(row.sessionId,receipt);settleWaiter(row,null,waiter);return null}row.activeHandoffToken=null;row.error=``;row.failureStage=``;if(accepted){removeReadyReceipt(row);row.retained=false;rowsById.delete(row.clientId);queueItems.value=queueItems.value.filter(candidate=>candidate.clientId!==row.clientId);settleWaiter(row,receipt,waiter);return receipt}row.phase=`ready`;settleWaiter(row,receipt,waiter);return receipt}catch(error){if(row.activeHandoffToken!==token||!row.retained||row.phase===`cancelled`){await cleanupReceipt(row.sessionId,receipt);settleWaiter(row,null,waiter);return null}row.activeHandoffToken=null;removeReadyReceipt(row);row.error=String(error?.message||error||`Uploaded attachment could not be used.`);row.failureStage=`handoff`;row.phase=`failed`;settleWaiter(row,null,waiter);reportAttachmentError(error,`Uploaded attachment could not be used.`,{notify:false});return null}}async function finishUploadAttempt(attempt,uploaded,uploadError=null){activeAttempts.delete(attempt.token);activeUploadCount.value=activeAttempts.size;pumpQueue();const{row}=attempt;const isCurrentAttempt=row.activeToken===attempt.token;const uploadSucceeded=Boolean(!uploadError&&uploaded&&uploaded.ok!==false&&String(uploaded.attachmentId||``).trim());if(!isCurrentAttempt||!row.retained||disposed){if(uploadSucceeded)await cleanupReceipt(attempt.sessionId,uploaded);settleWaiter(row,null,attempt.waiter);pumpQueue();return}row.activeToken=null;if(uploadSucceeded){const receipt=attachmentReceipt(row,uploaded);row.receipt=receipt;row.attachmentId=receipt.attachmentId;row.path=String(receipt.path||``);row.bytesSent=row.totalBytes;row.progress=100;row.error=``;row.failureStage=``;await handOffUploadedAttachment(row,receipt,attempt.waiter)}else{const error=uploadError||new Error(attachmentUploadError(uploaded)||`Attachment upload failed.`);row.error=String(error?.message||error||`Attachment upload failed.`);row.failureStage=`upload`;row.phase=`failed`;settleWaiter(row,null,attempt.waiter);reportAttachmentError(error,`Attachment upload failed.`,{notify:false})}pumpQueue()}function startUpload(row){const token=Symbol(row.clientId);const abortController=typeof AbortController===`function`?new AbortController:null;const attempt={abortController,cancel:null,row,sessionId:row.sessionId,settled:null,token,waiter:row.waiter};row.activeToken=token;row.phase=`uploading`;row.error=``;activeAttempts.set(token,attempt);activeUploadCount.value=activeAttempts.size;try{const transport=attachmentUploadResult(uploadAttachment(row.sessionId,row.file,{onProgress:(progress,total)=>updateProgress(row,progress,total),signal:abortController?.signal}));attempt.cancel=transport.cancel;attempt.settled=transport.promise.then(uploaded=>finishUploadAttempt(attempt,uploaded),error=>finishUploadAttempt(attempt,null,error))}catch(error){attempt.settled=finishUploadAttempt(attempt,null,error)}}function pumpQueue(){if(disposed)return;while(activeAttempts.size<uploadConcurrency&&uploadQueue.length>0){const row=uploadQueue.shift();if(!row?.retained||row.phase!==`queued`)continue;startUpload(row)}}function cancelAttachment(attachment={}){const row=canonicalRow(attachment);if(!row||!row.retained||![`preparing`,`queued`,`uploading`].includes(row.phase))return false;const token=row.activeToken;row.activeToken=null;row.activeHandoffToken=null;row.phase=`cancelled`;row.error=``;const receipt=row.receipt;removeReadyReceipt(row);if(receipt)cleanupReceipt(row.sessionId,receipt);row.receipt=null;row.failureStage=``;settleWaiter(row,null);const attempt=token?activeAttempts.get(token):null;try{row.producerAbortController?.abort();attempt?.abortController?.abort();attempt?.cancel?.()}catch{}row.producerAbortController=null;row.producerToken=null;pumpQueue();return true}function retryAttachment(attachment={}){const row=canonicalRow(attachment);if(!row||!row.retained||![`failed`,`cancelled`].includes(row.phase)||row.sessionId!==assistantAttachmentSessionId(sessionId)||!assistantAttachmentUploadAllowed(canUpload)||typeof uploadAttachment!==`function`)return Promise.resolve(null);if(row.phase===`cancelled`&&retainedItemCount.value>=maxItems){reportAttachmentError(`A message can keep at most ${maxItems} attachments.`);return Promise.resolve(null)}if(row.failureStage===`handoff`&&row.receipt){row.error=``;row.phase=`uploading`;const waiter=createWaiter(row);handOffUploadedAttachment(row,row.receipt,waiter);return waiter.promise}if(row.producer&&!row.file){const waiter=createWaiter(row);startAttachmentProducer(row);return waiter.promise}if(row.size>maxBytes){row.error=`${row.fileName} is larger than the ${maxSizeLabel} attachment limit.`;row.failureStage=`validation`;row.phase=`failed`;reportAttachmentError(row.error,`Attachment upload failed.`,{notify:false});return Promise.resolve(null)}row.bytesSent=0;row.progress=null;row.error=``;row.failureStage=``;row.phase=`queued`;const waiter=createWaiter(row);uploadQueue.push(row);pumpQueue();return waiter.promise}function detachRow(row){if([`preparing`,`queued`,`uploading`].includes(row.phase))cancelAttachment(row);row.retained=false;rowsById.delete(row.clientId);settleWaiter(row,null)}function removeAttachment(attachment={}){const row=canonicalRow(attachment);if(!row)return[];const removedReceipts=removeReadyReceipt(row);const removed=removedReceipts.length>0?removedReceipts:[row];const receiptToClean=removedReceipts[0]||row.receipt;detachRow(row);queueItems.value=queueItems.value.filter(candidate=>candidate.clientId!==row.clientId);if(receiptToClean)cleanupReceipt(row.sessionId,receiptToClean);return removed}function clearAttachments({accepted=true,attachmentIds=null}={}){if(!accepted)return abandonAttachments();const selectedIds=Array.isArray(attachmentIds)?new Set(attachmentIds):null;const cleared=attachments.value.filter(attachment=>!selectedIds||selectedIds.has(attachment.attachmentId));const readyIds=new Set(cleared.map(attachment=>attachment.clientId));const remaining=[];for(const row of[...queueItems.value]){if(selectedIds&&!readyIds.has(row.clientId)){remaining.push(row);continue}if(readyIds.has(row.clientId)){row.retained=false;rowsById.delete(row.clientId);continue}detachRow(row);if(row.receipt)cleanupReceipt(row.sessionId,row.receipt)}attachments.value=attachments.value.filter(attachment=>!readyIds.has(attachment.clientId));queueItems.value=remaining;return cleared}async function abandonAttachments({onlySessionId=``}={}){const normalizedSessionId=String(onlySessionId||``).trim();const rows=queueItems.value.filter(row=>!normalizedSessionId||row.sessionId===normalizedSessionId);const rowIds=new Set(rows.map(row=>row.clientId));const readyReceipts=rows.map(row=>row.receipt).filter(Boolean);const attempts=[...activeAttempts.values()].filter(attempt=>rowIds.has(attempt.row.clientId));for(const row of rows)detachRow(row);queueItems.value=queueItems.value.filter(row=>!rowIds.has(row.clientId));attachments.value=attachments.value.filter(attachment=>!rowIds.has(attachment.clientId));const readyCleanup=readyReceipts.map(attachment=>cleanupReceipt(attachment.sessionId,attachment));await Promise.allSettled([...readyCleanup,...attempts.map(attempt=>attempt.settled).filter(Boolean)]);await waitForAttachmentCleanup();return rows}async function waitForAttachmentCleanup(){while(cleanupTasks.size>0)await Promise.allSettled([...cleanupTasks])}async function disposeAttachments(){if(disposed){await waitForAttachmentCleanup();return[]}disposed=true;stopSessionWatch?.();stopSessionWatch=null;return abandonAttachments()}function handleDragEnter(event){if(!assistantAttachmentEventHasFiles(event))return;dragDepth.value+=1;if(event?.dataTransfer)event.dataTransfer.dropEffect=`copy`}function handleDragOver(event){if(event?.dataTransfer)event.dataTransfer.dropEffect=`copy`}function handleDragLeave(){dragDepth.value=Math.max(0,dragDepth.value-1)}function createQueueRow({currentSessionId,file=null,fileName=`attachment`,phase=`queued`,producer=null,size=0}={}){const normalizedSize=Number(file?.size??size)||0;const row=reactive({activeHandoffToken:null,activeToken:null,attachmentId:``,bytesSent:0,clientId:nextAttachmentClientId(),error:``,failureStage:``,file,fileName:file?attachmentFileName(file):String(fileName||`attachment`),path:``,phase,producer,producerAbortController:null,producerToken:null,progress:null,receipt:null,retained:true,sessionId:currentSessionId,size:normalizedSize,totalBytes:normalizedSize,waiter:null});rowsById.set(row.clientId,row);queueItems.value.push(row);createWaiter(row);return row}function queuePreparedFile(row,file,waiter=row.waiter){const preparedFile=assistantAttachmentFiles([file])[0];if(!preparedFile)throw new Error(`The prepared attachment did not produce a file.`);row.file=preparedFile;row.fileName=attachmentFileName(preparedFile);row.size=Number(preparedFile.size)||0;row.totalBytes=row.size;if(row.size>maxBytes){row.error=`${row.fileName} is larger than the ${maxSizeLabel} attachment limit.`;row.failureStage=`validation`;row.phase=`failed`;settleWaiter(row,null,waiter);reportAttachmentError(row.error,`Attachment upload failed.`,{notify:false});return false}row.phase=`queued`;uploadQueue.push(row);pumpQueue();return true}function startAttachmentProducer(row){const token=Symbol(`${row.clientId}-producer`);const waiter=row.waiter;const abortController=typeof AbortController===`function`?new AbortController:null;row.file=null;row.producerAbortController=abortController;row.producerToken=token;row.phase=`preparing`;row.error=``;row.failureStage=``;row.producerSettled=Promise.resolve().then(()=>row.producer({signal:abortController?.signal})).then(file=>{if(row.producerToken!==token||!row.retained||disposed){settleWaiter(row,null,waiter);return null}row.producerAbortController=null;row.producerToken=null;try{queuePreparedFile(row,file,waiter)}catch(error){row.error=String(error?.message||error||`Attachment preparation failed.`);row.failureStage=`preparing`;row.phase=`failed`;settleWaiter(row,null,waiter);reportAttachmentError(error,`Attachment preparation failed.`,{notify:false})}return file},error=>{if(row.producerToken!==token||!row.retained||disposed){settleWaiter(row,null,waiter);return null}row.producerAbortController=null;row.producerToken=null;if(error?.name===`AbortError`){row.phase=`cancelled`;row.error=``}else{row.error=String(error?.message||error||`Attachment preparation failed.`);row.failureStage=`preparing`;row.phase=`failed`;reportAttachmentError(error,`Attachment preparation failed.`,{notify:false})}settleWaiter(row,null,waiter);return null})}function uploadFileProducer({fileName=`Preparing attachment…`,produce}={}){const currentSessionId=assistantAttachmentSessionId(sessionId);if(!canAddFiles.value||typeof produce!==`function`){if(atCapacity.value)reportAttachmentError(`A message can keep at most ${maxItems} attachments.`);return Promise.resolve(null)}status.value=``;const row=createQueueRow({currentSessionId,fileName,phase:`preparing`,producer:produce});const waiter=row.waiter;startAttachmentProducer(row);return waiter.promise}async function uploadFiles(files=[]){const uploadableFiles=assistantAttachmentFiles(files);const currentSessionId=assistantAttachmentSessionId(sessionId);if(uploadableFiles.length<1||!currentSessionId||disposed||!assistantAttachmentUploadAllowed(canUpload)||typeof uploadAttachment!==`function`)return[];status.value=``;const availableSlots=Math.max(0,maxItems-retainedItemCount.value);const acceptedFiles=uploadableFiles.slice(0,availableSlots);if(acceptedFiles.length<uploadableFiles.length)reportAttachmentError(`A message can keep at most ${maxItems} attachments.`);const waiters=[];for(const file of acceptedFiles){const row=createQueueRow({currentSessionId,file});const waiter=row.waiter;waiters.push(waiter.promise);if(row.size>maxBytes){row.error=`${row.fileName} is larger than the ${maxSizeLabel} attachment limit.`;row.failureStage=`validation`;row.phase=`failed`;settleWaiter(row,null);reportAttachmentError(row.error,`Attachment upload failed.`,{notify:false})}else uploadQueue.push(row)}pumpQueue();return(await Promise.all(waiters)).filter(attachment=>attachment&&attachments.value.some(candidate=>candidate.clientId===attachment.clientId))}async function handleDrop(event){resetDragState();return uploadFiles(assistantAttachmentFilesFromDropEvent(event))}async function handlePaste(event){const files=assistantAttachmentFilesFromPasteEvent(event);if(files.length<1){if(assistantAttachmentClipboardLocalFileReference(event))reportAttachmentError(`Copied local files cannot be pasted from this browser. Drop the file or use Attach files.`);return[]}if(!assistantAttachmentClipboardText(event))event?.preventDefault?.();return uploadFiles(files)}stopSessionWatch=watch(()=>assistantAttachmentSessionId(sessionId),(nextSessionId,previousSessionId)=>{if(nextSessionId!==previousSessionId&&previousSessionId)abandonAttachments({onlySessionId:previousSessionId})},{flush:`sync`});if(getCurrentScope())onScopeDispose(()=>{disposeAttachments()});return{maxBytes,maxItems,abandonAttachments,aggregateProgress,attachments,atCapacity,canAddFiles,cancelAttachment,canSubmit,clearAttachments,clearStatus,disposeAttachments,dragActive,hasUnresolved,handleDragEnter,handleDragLeave,handleDragOver,handleDrop,handlePaste,queueItems,removeAttachment,resetDragState,retryAttachment,status,uploading,uploadFiles,uploadFileProducer,waitForAttachmentCleanup}}function parseIntegrationSetupRequest(message){if(message?.role!==`assistant`||typeof message.text!==`string`)return null;const lines=message.text.replace(/\r\n/gu,`
|
|
1
|
+
import{$n as normalizeProps,D as createVNode,E as createTextVNode,Ht as watch,On as unref,St as resolveComponent,Yt as withDirectives,Zn as normalizeClass,_ as createBaseVNode,b as createElementBlock,bt as renderList,ct as onMounted,er as normalizeStyle,et as mergeProps,g as computed,it as onBeforeUnmount,mt as openBlock,o as Fragment,pn as onScopeDispose,qt as withCtx,tr as toDisplayString,tt as nextTick,v as createBlock,vn as ref,w as createSlots,wn as toRef,wt as resolveDynamicComponent,xt as renderSlot,y as createCommentVNode,z as guardReactiveProps}from"./runtime-core.esm-bundler-DGXg_mpN.js";import{B as useRounded,D as makeDensityProps,Dt as genericComponent,Ft as makeComponentProps,G as useDimension,It as propsFactory,K as VDefaultsProvider,Mt as provideDefaults,O as useDensity,Q as makeTagProps,Tn as pick,U as useTextColor,V as useBackgroundColor,W as makeDimensionProps,_ as VIcon,_t as IconValue,bt as useRender,cr as withKeys,i as makeRouterProps,lr as withModifiers,lt as useDisplay,o as useLink,qn as isString,sr as vShow,z as makeRoundedProps}from"./VAvatar-H2hyOWlB.js";import{D as ROUTE_VISIBILITY_PUBLIC,t as useEndpointResource}from"./useEndpointResource-7-YDfAxX.js";import{d as getHttpWebClient,r as projectAppPath}from"./vibe64ProjectScope.local-l5_-E6pq.js";import{n as VList,s as VListItem,t as VMenu}from"./VMenu-DnhVIMrr.js";import{t as VChip}from"./VChip-Uixfx461.js";import{t as VTextField}from"./VTextField-CnkGeXaT.js";import{r as scopedDevelopmentApiUrl,t as resolveStudioRequestUrl}from"./studioUrls-B0-GdWh8.js";import{$n as mdiRedoVariant,Cr as mdiStar,Ct as mdiDotsVertical,Ft as mdiFileOutline,H as mdiChevronLeft,Hr as mdiVolumeHigh,Ht as mdiFolderOutline,It as mdiFilePlusOutline,Lt as mdiFileSearchOutline,Mn as mdiMicrophone,Nn as mdiMicrophoneOff,Nt as mdiFileDocumentOutline,Pr as mdiTrayArrowUp,Rr as mdiUndoVariant,S as mdiArrowLeft,Sr as mdiSourceRepository,Tr as mdiStop,U as mdiChevronRight,Un as mdiPencilOutline,Ur as mdiVolumeOff,Ut as mdiFolderPlusOutline,X as mdiClose,ar as mdiRobotOutline,at as mdiCollapseAllOutline,bt as mdiDeleteOutline,er as mdiRefresh,ft as mdiContentSaveOutline,kn as mdiMagnify,kt as mdiFileCodeOutline,lr as mdiSend,t as mdiAccountCheckOutline,ut as mdiContentCopy,wr as mdiStarOutline,wt as mdiDownload,xt as mdiDotsHorizontal,y as mdiArchiveClockOutline,zr as mdiUpload}from"./mdi-X9prU-DG.js";import{t as VBtn}from"./VBtn-Sj5jAuOx.js";import{t as VAlert}from"./VAlert-7_VM9EUm.js";import{t as VDialog}from"./VDialog-Drp3yzSH.js";import{i as VCardTitle,n as VCardText,o as VCardActions,t as VCard}from"./VCard-DExT9Cji.js";import{t as VSpacer}from"./VSpacer-BSTt0_VA.js";import{t as VSkeletonLoader}from"./VSkeletonLoader-pc4bBTxv.js";import{t as VTextarea}from"./VTextarea-wqoRFl1K.js";import{t as _plugin_vue_export_helper_default}from"./_plugin-vue_export-helper-DNW4j-dv.js";import{S as AssistantMessageAttachments_default,_ as scrollElementNearBottom,a as assistantAttachmentFilesFromPasteEvent,b as LongTextPreviewBlocks_default,f as AssistantAttachmentQueue_default,h as AssistantPromptInput_default,i as assistantAttachmentFilesFromDropEvent,l as AssistantConversationElement_default,o as useAssistantAttachments,r as AssistantAttachmentPreview_default,v as useScrollToBottom,x as parseLongTextReviewBlocks,y as _sfc_main$14}from"./conversation-ErAO1CmH.js";import"./conversation-DG9lp25w.js";import{n as useRealtimeEvent}from"./useRealtimeEvent-BNXVwzFG.js";import{t as usePaths}from"./usePaths-Y6UuQxmI.js";import{a as conversationAttachmentReference,c as vibe64AssistantSelectionLabel,g as vibe64AgentExecutionProfileAuditSnapshot,i as conversationAttachmentContentType,l as vibe64ProviderPresentation,o as normalizeVibe64ConversationAttachments}from"./shared-TUhK_uYM.js";import{c as assistantGoalManagementMessage,l as assistantGoalObjective,u as assistantModeLabel}from"./assistantRouting-D_9PZkWu.js";import{t as useCommand}from"./useCommand-CVuya6vG.js";import{t as useUiFeedback}from"./useUiFeedback-Bd3rao6E.js";import{n as stableLocalStorageKeyPart,r as writeLocalStorageJson,t as readLocalStorageJson}from"./browserLocalStorage-B4C7rHrs.js";import{t as writeClipboardText}from"./clipboard-CZs9aH3L.js";import"./shared-BEwrtWSp.js";import{n as vibe64ApiResponseError,t as vibe64ApiError}from"./vibe64ApiResponses-B4VY77Q_.js";import{r as vibe64RealtimePayloadFromCurrentTab,t as vibe64BrowserTabOriginId}from"./vibe64BrowserTabOrigin-SF9E31vi.js";import{B as vibe64SessionsQueryKey,F as vibe64SessionPath,G as vibe64SourceEditorExplanationPath,H as vibe64SourceEditorCreateFilePath,J as vibe64SourceEditorExplanationsStreamPath,K as vibe64SourceEditorExplanationStopPath,Q as vibe64SourceEditorSearchPath,U as vibe64SourceEditorDownloadPath,V as vibe64SourceEditorChangesStreamPath,W as vibe64SourceEditorExplanationFollowupsStreamPath,X as vibe64SourceEditorFilesPath,Y as vibe64SourceEditorFilePath,Z as vibe64SourceEditorResolvePathPath,c as VIBE64_SOURCE_EDITOR_FILE_CHANGED_EVENT,et as vibe64SourceEditorTreePath,l as VIBE64_SOURCE_EDITOR_SYNC_ERROR_EVENT,m as vibe64AgentAttachmentPath,o as VIBE64_SESSIONS_API_SUFFIX,p as vibe64AgentAttachmentFilePath,q as vibe64SourceEditorExplanationsCleanupPath,s as VIBE64_SESSION_CHANGED_EVENT,u as VIBE64_SOURCE_EDITOR_SYNC_READY_EVENT}from"./vibe64SessionRequestConfig-xIx-5jxQ.js";import{t as useVibe64SystemGraph}from"./useVibe64SystemGraph-Db_eD-X8.js";import{B as useVoiceLauncher,C as readRefOrGetterValue,H as VTabs,I as useVibe64Voice,L as VoiceConversationHost_default,M as createProjectVoiceBinding,R as VoiceConversationSettings_default,U as VTab,V as VoiceAvatar_default,Z as usePageActivity,_ as GithubMarkdown_default,v as F,z as VoiceConversationControls_default}from"./index-CGz4Yow6.js";import{$ as rectangularSelection,A as foldService,B as tags$1,C as continuedIndent,Ct as NodeWeakMap,D as flatIndent,E as delimitedIndent,Et as parseMixed,F as sublanguageProp,G as drawSelection,H as EditorView,I as syntaxHighlighting,J as getPanel,K as dropCursor,L as syntaxTree,M as indentOnInput,N as indentUnit,O as foldInside,P as languageDataProp,Q as lineNumbers,R as Tag,S as bracketMatchingHandle,St as NodeType,T as defineLanguageFacet,Tt as Tree,U as ViewPlugin,V as Decoration,W as crosshairCursor,X as highlightActiveLineGutter,Z as keymap,_ as LanguageDescription,_t as findClusterBreak,a as redo,at as Compartment,b as StreamLanguage,bt as NodeProp,c as completeFromList,ct as Facet,d as ContextTracker,dt as StateEffect,et as runScopeHandlers,f as ExternalTokenizer,ft as StateField,g as Language,gt as countColumn,h as LRLanguage,ht as combineConfig,i as indentWithTab,it as CharCategory,j as indentNodeProp,k as foldNodeProp,l as ifNotIn,lt as Prec,m as LocalTokenGroup,mt as codePointSize,n as history,nt as showPanel,o as undo,ot as EditorSelection,p as LRParser,pt as codePointAt,q as getDialog,r as historyKeymap,rt as crelt,s as CompletionContext,st as EditorState,t as defaultKeymap,tt as showDialog,u as snippetCompletion,ut as RangeSetBuilder,v as LanguageSupport,vt as fromCodePoint,w as defaultHighlightStyle,wt as Parser,x as bracketMatching,xt as NodeSet,y as ParseContext,yt as IterMode,z as styleTags}from"./dist-CDa9Iec1.js";import{s as vibe64SessionShortLabel}from"./vibe64SessionViewModel-B0cCumM8.js";import{n as vibe64SessionDebugError,r as vibe64SessionDebugLog}from"./vibe64SessionDebugLog-C06bcdUN.js";import{t as diffLines}from"./libesm-CR-iGldz.js";var makeVBreadcrumbsDividerProps=propsFactory({divider:[Number,String],...makeComponentProps()},`VBreadcrumbsDivider`);var VBreadcrumbsDivider=genericComponent()({name:`VBreadcrumbsDivider`,props:makeVBreadcrumbsDividerProps(),setup(props,{slots}){useRender(()=>createBaseVNode(`li`,{"aria-hidden":`true`,"class":normalizeClass([`v-breadcrumbs-divider`,props.class]),"style":normalizeStyle(props.style)},[slots?.default?.()??props.divider]));return{}}});var makeVBreadcrumbsItemProps=propsFactory({active:Boolean,activeClass:String,activeColor:String,color:String,disabled:Boolean,title:String,...makeComponentProps(),...pick(makeDimensionProps(),[`width`,`maxWidth`]),...makeRouterProps(),...makeTagProps({tag:`li`})},`VBreadcrumbsItem`);var VBreadcrumbsItem=genericComponent()({name:`VBreadcrumbsItem`,props:makeVBreadcrumbsItemProps(),setup(props,{slots,attrs}){const link=useLink(props,attrs);const isActive=computed(()=>props.active||link.isActive?.value);const{dimensionStyles}=useDimension(props);const{textColorClasses,textColorStyles}=useTextColor(()=>isActive.value?props.activeColor:props.color);useRender(()=>{return createVNode(props.tag,{"class":normalizeClass([`v-breadcrumbs-item`,{"v-breadcrumbs-item--active":isActive.value,"v-breadcrumbs-item--disabled":props.disabled,[`${props.activeClass}`]:isActive.value&&props.activeClass},textColorClasses.value,props.class]),"style":normalizeStyle([textColorStyles.value,dimensionStyles.value,props.style]),"aria-current":isActive.value?`page`:void 0},{default:()=>[!link.isLink.value?slots.default?.()??props.title:createBaseVNode(`a`,mergeProps({"class":`v-breadcrumbs-item--link`,"onClick":link.navigate.value},link.linkProps),[slots.default?.()??props.title])]})});return{}}});var makeVBreadcrumbsProps=propsFactory({activeClass:String,activeColor:String,bgColor:String,color:String,disabled:Boolean,divider:{type:String,default:`/`},icon:IconValue,items:{type:Array,default:()=>[]},...makeComponentProps(),...makeDensityProps(),...makeRoundedProps(),...makeTagProps({tag:`ul`})},`VBreadcrumbs`);var VBreadcrumbs=genericComponent()({name:`VBreadcrumbs`,props:makeVBreadcrumbsProps(),setup(props,{slots}){const{backgroundColorClasses,backgroundColorStyles}=useBackgroundColor(()=>props.bgColor);const{densityClasses}=useDensity(props);const{roundedClasses,roundedStyles}=useRounded(props);provideDefaults({VBreadcrumbsDivider:{divider:toRef(()=>props.divider)},VBreadcrumbsItem:{activeClass:toRef(()=>props.activeClass),activeColor:toRef(()=>props.activeColor),color:toRef(()=>props.color),disabled:toRef(()=>props.disabled)}});const items=computed(()=>props.items.map(item=>{return isString(item)?{item:{title:item},raw:item}:{item,raw:item}}));useRender(()=>{const hasPrepend=!!(slots.prepend||props.icon);return createVNode(props.tag,{"class":normalizeClass([`v-breadcrumbs`,backgroundColorClasses.value,densityClasses.value,roundedClasses.value,props.class]),"style":normalizeStyle([backgroundColorStyles.value,roundedStyles.value,props.style])},{default:()=>[hasPrepend&&createBaseVNode(`li`,{"key":`prepend`,"class":`v-breadcrumbs__prepend`},[!slots.prepend?createVNode(VIcon,{"key":`prepend-icon`,"start":true,"icon":props.icon},null):createVNode(VDefaultsProvider,{"key":`prepend-defaults`,"disabled":!props.icon,"defaults":{VIcon:{icon:props.icon,start:true}}},slots.prepend)]),items.value.map(({item,raw},index,array)=>createBaseVNode(Fragment,null,[slots.item?.({item,index})??createVNode(VBreadcrumbsItem,mergeProps({"key":index,"disabled":index>=array.length-1},isString(item)?{title:item}:item),{default:slots.title?()=>slots.title?.({item,index}):void 0}),index<array.length-1&&createVNode(VBreadcrumbsDivider,null,{default:slots.divider?()=>slots.divider?.({item:raw,index}):void 0})])),slots.default?.()]})});return{}}});function parseIntegrationSetupRequest(message){if(message?.role!==`assistant`||typeof message.text!==`string`)return null;const lines=message.text.replace(/\r\n/gu,`
|
|
3
2
|
`).split(`
|
|
4
3
|
`);let fence=null;for(let index=0;index<lines.length;index+=1){const line=lines[index];if(fence){const closing=/^ {0,3}(`{3,}|~{3,})\s*$/u.exec(line);if(!closing||closing[1][0]!==fence.character||closing[1].length<fence.length)continue;if(fence.request){if(lines.slice(index+1).some(tail=>tail.trim()))return null;const payload=lines.slice(fence.start+1,index).join(`
|
|
5
4
|
`);if(payload.length>1024)return null;let value;try{value=JSON.parse(payload)}catch{return null}if(!value||Array.isArray(value)||typeof value!==`object`||Object.keys(value).length!==1||typeof value.integrationId!==`string`||!value.integrationId.trim()||value.integrationId.length>200||/[\p{Cc}\p{Cf}]/u.test(value.integrationId))return null;return{integrationId:value.integrationId,text:lines.slice(0,fence.start).join(`
|
|
@@ -38,4 +37,4 @@ import{$n as normalizeProps,D as createVNode,E as createTextVNode,En as toValue,
|
|
|
38
37
|
`)end--;this.fragmentEnd=end?end-1:0}let c=this.cursor;if(!c){c=this.cursor=this.fragment.tree.cursor();c.firstChild()}let rPos=pos+this.fragment.offset;while(c.to<=rPos)if(!c.parent())return false;for(;;){if(c.from>=rPos)return this.fragment.from<=lineStart;if(!c.childAfter(rPos))return false}}matches(hash){let tree=this.cursor.tree;return tree&&tree.prop(NodeProp.contextHash)==hash}takeNodes(cx){let cur=this.cursor,off=this.fragment.offset,fragEnd=this.fragmentEnd-(this.fragment.openEnd?1:0);let start=cx.absoluteLineStart,end=start,blockI=cx.block.children.length;let prevEnd=end,prevI=blockI;for(;;){if(cur.to-off>fragEnd){if(cur.type.isAnonymous&&cur.firstChild())continue;break}let pos=toRelative(cur.from-off,cx.ranges);if(cur.to-off<=cx.ranges[cx.rangeI].to)cx.addNode(cur.tree,pos);else{let dummy=new Tree(cx.parser.nodeSet.types[Type.Paragraph],[],[],0,cx.block.hashProp);cx.reusePlaceholders.set(dummy,cur.tree);cx.addNode(dummy,pos)}if(cur.type.is(`Block`)){if(NotLast.indexOf(cur.type.id)<0){end=cur.to-off;blockI=cx.block.children.length}else{end=prevEnd;blockI=prevI}prevEnd=cur.to-off;prevI=cx.block.children.length}if(!cur.nextSibling())break}while(cx.block.children.length>blockI){cx.block.children.pop();cx.block.positions.pop()}return end-start}};function toRelative(abs,ranges){let pos=abs;for(let i=1;i<ranges.length;i++){let gapFrom=ranges[i-1].to,gapTo=ranges[i].from;if(gapFrom<abs)pos-=gapTo-gapFrom}return pos}var markdownHighlighting=styleTags({"Blockquote/...":tags$1.quote,HorizontalRule:tags$1.contentSeparator,"ATXHeading1/... SetextHeading1/...":tags$1.heading1,"ATXHeading2/... SetextHeading2/...":tags$1.heading2,"ATXHeading3/...":tags$1.heading3,"ATXHeading4/...":tags$1.heading4,"ATXHeading5/...":tags$1.heading5,"ATXHeading6/...":tags$1.heading6,"Comment CommentBlock":tags$1.comment,Escape:tags$1.escape,Entity:tags$1.character,"Emphasis/...":tags$1.emphasis,"StrongEmphasis/...":tags$1.strong,"Link/... Image/...":tags$1.link,"OrderedList/... BulletList/...":tags$1.list,"BlockQuote/...":tags$1.quote,"InlineCode CodeText":tags$1.monospace,"URL Autolink":tags$1.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":tags$1.processingInstruction,"CodeInfo LinkLabel":tags$1.labelName,LinkTitle:tags$1.string,Paragraph:tags$1.content});var parser=new MarkdownParser(new NodeSet(nodeTypes).extend(markdownHighlighting),Object.keys(DefaultBlockParsers).map(n=>DefaultBlockParsers[n]),Object.keys(DefaultBlockParsers).map(n=>DefaultLeafBlocks[n]),Object.keys(DefaultBlockParsers),DefaultEndLeaf,DefaultSkipMarkup,Object.keys(DefaultInline).map(n=>DefaultInline[n]),Object.keys(DefaultInline),[]);function leftOverSpace(node,from,to){let ranges=[];for(let n=node.firstChild,pos=from;;n=n.nextSibling){let nextPos=n?n.from:to;if(nextPos>pos)ranges.push({from:pos,to:nextPos});if(!n)break;pos=n.to}return ranges}function parseCode(config){let{codeParser,htmlParser}=config;return{wrap:parseMixed((node,input)=>{let id=node.type.id;if(codeParser&&(id==Type.CodeBlock||id==Type.FencedCode)){let info=``;if(id==Type.FencedCode){let infoNode=node.node.getChild(Type.CodeInfo);if(infoNode)info=input.read(infoNode.from,infoNode.to)}let parser=codeParser(info);if(parser)return{parser,overlay:node=>node.type.id==Type.CodeText,bracketed:id==Type.FencedCode}}else if(htmlParser&&(id==Type.HTMLBlock||id==Type.HTMLTag||id==Type.CommentBlock))return{parser:htmlParser,overlay:leftOverSpace(node.node,node.from,node.to)};return null})}}var StrikethroughDelim={resolve:`Strikethrough`,mark:`StrikethroughMark`};var Strikethrough={defineNodes:[{name:`Strikethrough`,style:{"Strikethrough/...":tags$1.strikethrough}},{name:`StrikethroughMark`,style:tags$1.processingInstruction}],parseInline:[{name:`Strikethrough`,parse(cx,next,pos){if(next!=126||cx.char(pos+1)!=126||cx.char(pos+2)==126)return-1;let before=cx.slice(pos-1,pos),after=cx.slice(pos+2,pos+3);let sBefore=/\s|^$/.test(before),sAfter=/\s|^$/.test(after);let pBefore=Punctuation.test(before),pAfter=Punctuation.test(after);return cx.addDelimiter(StrikethroughDelim,pos,pos+2,!sAfter&&(!pAfter||sBefore||pBefore),!sBefore&&(!pBefore||sAfter||pAfter))},after:`Emphasis`}]};function parseRow(cx,line,startI=0,elts,offset=0){let count=0,first=true,cellStart=-1,cellEnd=-1,esc=false;let parseCell=()=>{elts.push(cx.elt(`TableCell`,offset+cellStart,offset+cellEnd,cx.parser.parseInline(line.slice(cellStart,cellEnd),offset+cellStart)))};for(let i=startI;i<line.length;i++){let next=line.charCodeAt(i);if(next==124&&!esc){if(!first||cellStart>-1)count++;first=false;if(elts){if(cellStart>-1)parseCell();elts.push(cx.elt(`TableDelimiter`,i+offset,i+offset+1))}cellStart=cellEnd=-1}else if(esc||next!=32&&next!=9){if(cellStart<0)cellStart=i;cellEnd=i+1}esc=!esc&&next==92}if(cellStart>-1){count++;if(elts)parseCell()}return count}function hasPipe(str,start){for(let i=start;i<str.length;i++){let next=str.charCodeAt(i);if(next==124)return true;if(next==92)i++}return false}var delimiterLine=/^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;var TableParser=class{constructor(){this.rows=null}nextLine(cx,line,leaf){if(this.rows==null){this.rows=false;let lineText;if((line.next==45||line.next==58||line.next==124)&&delimiterLine.test(lineText=line.text.slice(line.pos))){let firstRow=[];if(parseRow(cx,leaf.content,0,firstRow,leaf.start)==parseRow(cx,lineText,0))this.rows=[cx.elt(`TableHeader`,leaf.start,leaf.start+leaf.content.length,firstRow),cx.elt(`TableDelimiter`,cx.lineStart+line.pos,cx.lineStart+line.text.length)]}}else if(this.rows){let content=[];parseRow(cx,line.text,line.pos,content,cx.lineStart);this.rows.push(cx.elt(`TableRow`,cx.lineStart+line.pos,cx.lineStart+line.text.length,content))}return false}finish(cx,leaf){if(!this.rows)return false;cx.addLeafElement(leaf,cx.elt(`Table`,leaf.start,leaf.start+leaf.content.length,this.rows));return true}};var Table={defineNodes:[{name:`Table`,block:true},{name:`TableHeader`,style:{"TableHeader/...":tags$1.heading}},`TableRow`,{name:`TableCell`,style:tags$1.content},{name:`TableDelimiter`,style:tags$1.processingInstruction}],parseBlock:[{name:`Table`,leaf(_,leaf){return hasPipe(leaf.content,0)?new TableParser:null},endLeaf(cx,line,leaf){if(leaf.parsers.some(p=>p instanceof TableParser)||!hasPipe(line.text,line.basePos))return false;let next=cx.peekLine();return delimiterLine.test(next)&&parseRow(cx,line.text,line.basePos)==parseRow(cx,next,line.basePos)},before:`SetextHeading`}]};var TaskParser=class{nextLine(){return false}finish(cx,leaf){cx.addLeafElement(leaf,cx.elt(`Task`,leaf.start,leaf.start+leaf.content.length,[cx.elt(`TaskMarker`,leaf.start,leaf.start+3),...cx.parser.parseInline(leaf.content.slice(3),leaf.start+3)]));return true}};var TaskList={defineNodes:[{name:`Task`,block:true,style:tags$1.list},{name:`TaskMarker`,style:tags$1.atom}],parseBlock:[{name:`TaskList`,leaf(cx,leaf){return/^\[[ xX]\][ \t]/.test(leaf.content)&&cx.parentType().name==`ListItem`?new TaskParser:null},after:`SetextHeading`}]};var autolinkRE=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy;var urlRE=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy;var lastTwoDomainWords=/[\w-]+\.[\w-]+($|[/:])/;var emailRE=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy;var xmppResourceRE=/\/[a-zA-Z\d@.]+/gy;function count(str,from,to,ch){let result=0;for(let i=from;i<to;i++)if(str[i]==ch)result++;return result}function autolinkURLEnd(text,from){urlRE.lastIndex=from;let m=urlRE.exec(text);if(!m||lastTwoDomainWords.exec(m[0])[0].indexOf(`_`)>-1)return-1;let end=from+m[0].length;for(;;){let last=text[end-1],m;if(/[?!.,:*_~]/.test(last)||last==`)`&&count(text,from,end,`)`)>count(text,from,end,`(`))end--;else if(last==`;`&&(m=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(text.slice(from,end))))end=from+m.index;else break}return end}function autolinkEmailEnd(text,from){emailRE.lastIndex=from;let m=emailRE.exec(text);if(!m)return-1;let last=m[0][m[0].length-1];return last==`_`||last==`-`?-1:from+m[0].length-(last==`.`?1:0)}var Autolink={parseInline:[{name:`Autolink`,parse(cx,next,absPos){let pos=absPos-cx.offset;if(pos&&/\w/.test(cx.text[pos-1]))return-1;autolinkRE.lastIndex=pos;let m=autolinkRE.exec(cx.text),end=-1;if(!m)return-1;if(m[1]||m[2]){end=autolinkURLEnd(cx.text,pos+m[0].length);if(end>-1&&cx.hasOpenLink)end=pos+/([^\[\]]|\[[^\]]*\])*/.exec(cx.text.slice(pos,end))[0].length}else if(m[3])end=autolinkEmailEnd(cx.text,pos);else{end=autolinkEmailEnd(cx.text,pos+m[0].length);if(end>-1&&m[0]==`xmpp:`){xmppResourceRE.lastIndex=end;m=xmppResourceRE.exec(cx.text);if(m)end=m.index+m[0].length}}if(end<0)return-1;cx.addElement(cx.elt(`URL`,absPos,end+cx.offset));return end+cx.offset}}]};var GFM=[Table,TaskList,Strikethrough,Autolink];function parseSubSuper(ch,node,mark){return(cx,next,pos)=>{if(next!=ch||cx.char(pos+1)==ch)return-1;let elts=[cx.elt(mark,pos,pos+1)];for(let i=pos+1;i<cx.end;i++){let next=cx.char(i);if(next==ch)return cx.addElement(cx.elt(node,pos,i+1,elts.concat(cx.elt(mark,i,i+1))));if(next==92)elts.push(cx.elt(`Escape`,i,i+++2));if(space(next))break}return-1}}var Superscript={defineNodes:[{name:`Superscript`,style:tags$1.special(tags$1.content)},{name:`SuperscriptMark`,style:tags$1.processingInstruction}],parseInline:[{name:`Superscript`,parse:parseSubSuper(94,`Superscript`,`SuperscriptMark`)}]};var Subscript={defineNodes:[{name:`Subscript`,style:tags$1.special(tags$1.content)},{name:`SubscriptMark`,style:tags$1.processingInstruction}],parseInline:[{name:`Subscript`,parse:parseSubSuper(126,`Subscript`,`SubscriptMark`)}]};var Emoji={defineNodes:[{name:`Emoji`,style:tags$1.character}],parseInline:[{name:`Emoji`,parse(cx,next,pos){let match;if(next!=58||!(match=/^[a-zA-Z_0-9]+:/.exec(cx.slice(pos+1,cx.end))))return-1;return cx.addElement(cx.elt(`Emoji`,pos,pos+1+match[0].length))}}]};var data=defineLanguageFacet({commentTokens:{block:{open:`<!--`,close:`-->`}}});var headingProp=new NodeProp;var commonmark=parser.configure({props:[foldNodeProp.add(type=>{return!type.is(`Block`)||type.is(`Document`)||isHeading(type)!=null||isList(type)?void 0:(tree,state)=>({from:state.doc.lineAt(tree.from).to,to:tree.to})}),headingProp.add(isHeading),indentNodeProp.add({Document:()=>null}),languageDataProp.add({Document:data})]});function isHeading(type){let match=/^(?:ATX|Setext)Heading(\d)$/.exec(type.name);return match?+match[1]:void 0}function isList(type){return type.name==`OrderedList`||type.name==`BulletList`}function findSectionEnd(headerNode,level){let last=headerNode;for(;;){let next=last.nextSibling,heading;if(!next||(heading=isHeading(next.type))!=null&&heading<=level)break;last=next}return last.to}var headerIndent=foldService.of((state,start,end)=>{for(let node=syntaxTree(state).resolveInner(end,-1);node;node=node.parent){if(node.from<start)break;let heading=node.type.prop(headingProp);if(heading==null)continue;let upto=findSectionEnd(node,heading);if(upto>end)return{from:end,to:upto}}return null});function mkLang(parser){return new Language(data,parser,[],`markdown`)}var commonmarkLanguage=mkLang(commonmark);var markdownLanguage=mkLang(commonmark.configure([GFM,Subscript,Superscript,Emoji,{props:[foldNodeProp.add({Table:(tree,state)=>({from:state.doc.lineAt(tree.from).to,to:tree.to})})]}]));function getCodeParser(languages,defaultLanguage){return info=>{if(info&&languages){let found=null;info=/\S*/.exec(info)[0];if(typeof languages==`function`)found=languages(info);else found=LanguageDescription.matchLanguageName(languages,info,true);if(found instanceof LanguageDescription)return found.support?found.support.language.parser:ParseContext.getSkippingParser(found.load());else if(found)return found.parser}return defaultLanguage?defaultLanguage.parser:null}}var Context=class{constructor(node,from,to,spaceBefore,spaceAfter,type,item){this.node=node;this.from=from;this.to=to;this.spaceBefore=spaceBefore;this.spaceAfter=spaceAfter;this.type=type;this.item=item}blank(maxWidth,trailing=true){let result=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(maxWidth!=null){while(result.length<maxWidth)result+=` `;return result}else{for(let i=this.to-this.from-result.length-this.spaceAfter.length;i>0;i--)result+=` `;return result+(trailing?this.spaceAfter:``)}}marker(doc,add){let number=this.node.name==`OrderedList`?String(+itemNumber(this.item,doc)[2]+add):``;return this.spaceBefore+number+this.type+this.spaceAfter}};function getContext(node,doc){let nodes=[],context=[];for(let cur=node;cur;cur=cur.parent){if(cur.name==`FencedCode`)return context;if(cur.name==`ListItem`||cur.name==`Blockquote`)nodes.push(cur)}for(let i=nodes.length-1;i>=0;i--){let node=nodes[i],match;let line=doc.lineAt(node.from),startPos=node.from-line.from;if(node.name==`Blockquote`&&(match=/^ *>( ?)/.exec(line.text.slice(startPos))))context.push(new Context(node,startPos,startPos+match[0].length,``,match[1],`>`,null));else if(node.name==`ListItem`&&node.parent.name==`OrderedList`&&(match=/^( *)\d+([.)])( *)/.exec(line.text.slice(startPos)))){let after=match[3],len=match[0].length;if(after.length>=4){after=after.slice(0,after.length-4);len-=4}context.push(new Context(node.parent,startPos,startPos+len,match[1],after,match[2],node))}else if(node.name==`ListItem`&&node.parent.name==`BulletList`&&(match=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(line.text.slice(startPos)))){let after=match[4],len=match[0].length;if(after.length>4){after=after.slice(0,after.length-4);len-=4}let type=match[2];if(match[3])type+=match[3].replace(/[xX]/,` `);context.push(new Context(node.parent,startPos,startPos+len,match[1],after,type,node))}}return context}function itemNumber(item,doc){return/^(\s*)(\d+)(?=[.)])/.exec(doc.sliceString(item.from,item.from+10))}function renumberList(after,doc,changes,offset=0){for(let prev=-1,node=after;;){if(node.name==`ListItem`){let m=itemNumber(node,doc);let number=+m[2];if(prev>=0){if(number!=prev+1)return;changes.push({from:node.from+m[1].length,to:node.from+m[0].length,insert:String(prev+2+offset)})}prev=number}let next=node.nextSibling;if(!next)break;node=next}}function normalizeIndent(content,state){let blank=/^[ \t]*/.exec(content)[0].length;if(!blank||state.facet(indentUnit)!=` `)return content;let col=countColumn(content,4,blank);let space=``;for(let i=col;i>0;)if(i>=4){space+=` `;i-=4}else{space+=` `;i--}return space+content.slice(blank)}var insertNewlineContinueMarkupCommand=(config={})=>({state,dispatch})=>{let tree=syntaxTree(state),{doc}=state;let dont=null,changes=state.changeByRange(range=>{if(!range.empty||!markdownLanguage.isActiveAt(state,range.from,-1)&&!markdownLanguage.isActiveAt(state,range.from,1))return dont={range};let pos=range.from,line=doc.lineAt(pos);let context=getContext(tree.resolveInner(pos,-1),doc);while(context.length&&context[context.length-1].from>pos-line.from)context.pop();if(!context.length)return dont={range};let inner=context[context.length-1];if(inner.to-inner.spaceAfter.length>pos-line.from)return dont={range};let emptyLine=pos>=inner.to-inner.spaceAfter.length&&!/\S/.test(line.text.slice(inner.to));if(inner.item&&emptyLine){if(inner.item.from<line.from&&!/^[\s>]*$/.test(line.text.slice(0,inner.to)))return dont={range};let first=inner.node.firstChild,second=inner.node.getChild(`ListItem`,`ListItem`);if(first.to>=pos||second&&second.to<pos||line.from>0&&!/[^\s>]/.test(doc.lineAt(line.from-1).text)||config.nonTightLists===false){let next=context.length>1?context[context.length-2]:null;let delTo,insert=``;if(next&&next.item){delTo=line.from+next.from;insert=next.marker(doc,1)}else delTo=line.from+(next?next.to:0);let changes=[{from:delTo,to:pos,insert}];if(inner.node.name==`OrderedList`)renumberList(inner.item,doc,changes,-2);if(next&&next.node.name==`OrderedList`)renumberList(next.item,doc,changes);return{range:EditorSelection.cursor(delTo+insert.length),changes}}else{let insert=blankLine(context,state,line);return{range:EditorSelection.cursor(pos+insert.length+1),changes:{from:line.from,insert:insert+state.lineBreak}}}}if(inner.node.name==`Blockquote`&&emptyLine&&line.from){let prevLine=doc.lineAt(line.from-1),quoted=/>\s*$/.exec(prevLine.text);if(quoted&"ed.index==inner.from){let changes=state.changes([{from:prevLine.from+quoted.index,to:prevLine.to},{from:line.from+inner.from,to:line.to}]);return{range:range.map(changes),changes}}}let changes=[];if(inner.node.name==`OrderedList`)renumberList(inner.item,doc,changes);let continued=inner.item&&inner.item.from<line.from;let insert=``;if(!continued||/^[\s\d.)\-+*>]*/.exec(line.text)[0].length>=inner.to)for(let i=0,e=context.length-1;i<=e;i++)insert+=i==e&&!continued?context[i].marker(doc,1):context[i].blank(i<e?countColumn(line.text,4,context[i+1].from)-insert.length:null);let from=pos;while(from>line.from&&/\s/.test(line.text.charAt(from-line.from-1)))from--;insert=normalizeIndent(insert,state);if(nonTightList(inner.node,state.doc))insert=blankLine(context,state,line)+state.lineBreak+insert;changes.push({from,to:pos,insert:state.lineBreak+insert});return{range:EditorSelection.cursor(from+insert.length+1),changes}});if(dont)return false;dispatch(state.update(changes,{scrollIntoView:true,userEvent:`input`}));return true};var insertNewlineContinueMarkup=insertNewlineContinueMarkupCommand();function isMark(node){return node.name==`QuoteMark`||node.name==`ListMark`}function nonTightList(node,doc){if(node.name!=`OrderedList`&&node.name!=`BulletList`)return false;let first=node.firstChild,second=node.getChild(`ListItem`,`ListItem`);if(!second)return false;let line1=doc.lineAt(first.to),line2=doc.lineAt(second.from);let empty=/^[\s>]*$/.test(line1.text);return line1.number+(empty?0:1)<line2.number}function blankLine(context,state,line){let insert=``;for(let i=0,e=context.length-2;i<=e;i++)insert+=context[i].blank(i<e?countColumn(line.text,4,context[i+1].from)-insert.length:null,i<e);return normalizeIndent(insert,state)}function contextNodeForDelete(tree,pos){let node=tree.resolveInner(pos,-1),scan=pos;if(isMark(node)){scan=node.from;node=node.parent}for(let prev;prev=node.childBefore(scan);)if(isMark(prev))scan=prev.from;else if(prev.name==`OrderedList`||prev.name==`BulletList`){node=prev.lastChild;scan=node.to}else break;return node}var deleteMarkupBackward=({state,dispatch})=>{let tree=syntaxTree(state);let dont=null,changes=state.changeByRange(range=>{let pos=range.from,{doc}=state;if(range.empty&&markdownLanguage.isActiveAt(state,range.from)){let line=doc.lineAt(pos);let context=getContext(contextNodeForDelete(tree,pos),doc);if(context.length){let inner=context[context.length-1];let spaceEnd=inner.to-inner.spaceAfter.length+(inner.spaceAfter?1:0);if(pos-line.from>spaceEnd&&!/\S/.test(line.text.slice(spaceEnd,pos-line.from)))return{range:EditorSelection.cursor(line.from+spaceEnd),changes:{from:line.from+spaceEnd,to:pos}};if(pos-line.from==spaceEnd&&(inner.item&&line.from<=inner.item.from||/^[\s>]*$/.test(line.text.slice(0,inner.to)))){let start=line.from+inner.from;if(inner.item&&inner.node.from<inner.item.from&&/\S/.test(line.text.slice(inner.from,inner.to))){let insert=inner.blank(countColumn(line.text,4,inner.to)-countColumn(line.text,4,inner.from));if(start==line.from)insert=normalizeIndent(insert,state);return{range:EditorSelection.cursor(start+insert.length),changes:{from:start,to:line.from+inner.to,insert}}}if(start<pos)return{range:EditorSelection.cursor(start),changes:{from:start,to:pos}}}}}return dont={range}});if(dont)return false;dispatch(state.update(changes,{scrollIntoView:true,userEvent:`delete`}));return true};var markdownKeymap=[{key:`Enter`,run:insertNewlineContinueMarkup},{key:`Backspace`,run:deleteMarkupBackward}];var htmlNoMatch=html({matchClosingTags:false});function markdown(config={}){let{codeLanguages,defaultCodeLanguage,addKeymap=true,base:{parser}=commonmarkLanguage,completeHTMLTags=true,pasteURLAsLink:pasteURL=true,htmlTagLanguage=htmlNoMatch}=config;if(!(parser instanceof MarkdownParser))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let extensions=config.extensions?[config.extensions]:[];let support=[htmlTagLanguage.support,headerIndent],defaultCode;if(pasteURL)support.push(pasteURLAsLink);if(defaultCodeLanguage instanceof LanguageSupport){support.push(defaultCodeLanguage.support);defaultCode=defaultCodeLanguage.language}else if(defaultCodeLanguage)defaultCode=defaultCodeLanguage;let codeParser=codeLanguages||defaultCode?getCodeParser(codeLanguages,defaultCode):void 0;extensions.push(parseCode({codeParser,htmlParser:htmlTagLanguage.language.parser}));if(addKeymap)support.push(Prec.high(keymap.of(markdownKeymap)));let lang=mkLang(parser.configure(extensions));if(completeHTMLTags)support.push(lang.data.of({autocomplete:htmlTagCompletion}));return new LanguageSupport(lang,support)}function htmlTagCompletion(context){let{state,pos}=context,m=/<[:\-\.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos-25,pos));if(!m)return null;let tree=syntaxTree(state).resolveInner(pos,-1);while(tree&&!tree.type.isTop){if(tree.name==`CodeBlock`||tree.name==`FencedCode`||tree.name==`ProcessingInstructionBlock`||tree.name==`CommentBlock`||tree.name==`Link`||tree.name==`Image`)return null;tree=tree.parent}return{from:pos-m[0].length,to:pos,options:htmlTagCompletions(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var _tagCompletions=null;function htmlTagCompletions(){if(_tagCompletions)return _tagCompletions;let result=htmlCompletionSource(new CompletionContext(EditorState.create({extensions:htmlNoMatch}),0,true));return _tagCompletions=result?result.options:[]}var nonPlainText=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i;var pasteURLAsLink=EditorView.domEventHandlers({paste:(event,view)=>{var _a;let{main}=view.state.selection;if(main.empty)return false;let link=(_a=event.clipboardData)===null||_a===void 0?void 0:_a.getData(`text/plain`);if(!link||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(link))return false;if(/^www\./.test(link))link=`https://`+link;if(!markdownLanguage.isActiveAt(view.state,main.from,1))return false;let tree=syntaxTree(view.state),crossesNode=false;tree.iterate({from:main.from,to:main.to,enter:node=>{if(node.from>main.from||nonPlainText.test(node.name))crossesNode=true},leave:node=>{if(node.to<main.to)crossesNode=true}});if(crossesNode)return false;view.dispatch({changes:[{from:main.from,insert:`[`},{from:main.to,insert:`](${link})`}],userEvent:`input.paste`,scrollIntoView:true});return true}});var words={};function define(style,dict){for(var i=0;i<dict.length;i++)words[dict[i]]=style}var commonAtoms=[`true`,`false`];var commonKeywords=[`if`,`then`,`do`,`else`,`elif`,`while`,`until`,`for`,`in`,`esac`,`fi`,`fin`,`fil`,`done`,`exit`,`set`,`unset`,`export`,`function`];var commonCommands=[`ab`,`awk`,`bash`,`beep`,`cat`,`cc`,`cd`,`chown`,`chmod`,`chroot`,`clear`,`cp`,`curl`,`cut`,`diff`,`echo`,`find`,`gawk`,`gcc`,`get`,`git`,`grep`,`hg`,`kill`,`killall`,`ln`,`ls`,`make`,`mkdir`,`openssl`,`mv`,`nc`,`nl`,`node`,`npm`,`ping`,`ps`,`restart`,`rm`,`rmdir`,`sed`,`service`,`sh`,`shopt`,`shred`,`source`,`sort`,`sleep`,`ssh`,`start`,`stop`,`su`,`sudo`,`svn`,`tee`,`telnet`,`top`,`touch`,`vi`,`vim`,`wall`,`wc`,`wget`,`who`,`write`,`yes`,`zsh`];define(`atom`,commonAtoms);define(`keyword`,commonKeywords);define(`builtin`,commonCommands);function tokenBase(stream,state){if(stream.eatSpace())return null;var sol=stream.sol();var ch=stream.next();if(ch===`\\`){stream.next();return null}if(ch===`'`||ch===`"`||ch==="`"){state.tokens.unshift(tokenString(ch,ch==="`"?`quote`:`string`));return tokenize(stream,state)}if(ch===`#`){if(sol&&stream.eat(`!`)){stream.skipToEnd();return`meta`}stream.skipToEnd();return`comment`}if(ch===`$`){state.tokens.unshift(tokenDollar);return tokenize(stream,state)}if(ch===`+`||ch===`=`)return`operator`;if(ch===`-`){stream.eat(`-`);stream.eatWhile(/\w/);return`attribute`}if(ch==`<`){if(stream.match(`<<`))return`operator`;var heredoc=stream.match(/^<-?\s*(?:['"]([^'"]*)['"]|([^'"\s]*))/);if(heredoc){state.tokens.unshift(tokenHeredoc(heredoc[1]||heredoc[2]));return`string.special`}}if(/\d/.test(ch)){stream.eatWhile(/\d/);if(stream.eol()||!/\w/.test(stream.peek()))return`number`}stream.eatWhile(/[\w-]/);var cur=stream.current();if(stream.peek()===`=`&&/\w+/.test(cur))return`def`;return words.hasOwnProperty(cur)?words[cur]:null}function tokenString(quote,style){var close=quote==`(`?`)`:quote==`{`?`}`:quote;return function(stream,state){var next,escaped=false;while((next=stream.next())!=null){if(next===close&&!escaped){state.tokens.shift();break}else if(next===`$`&&!escaped&"e!==`'`&&stream.peek()!=close){escaped=true;stream.backUp(1);state.tokens.unshift(tokenDollar);break}else if(!escaped&"e!==close&&next===quote){state.tokens.unshift(tokenString(quote,style));return tokenize(stream,state)}else if(!escaped&&/['"]/.test(next)&&!/['"]/.test(quote)){state.tokens.unshift(tokenStringStart(next,`string`));stream.backUp(1);break}escaped=!escaped&&next===`\\`}return style}}function tokenStringStart(quote,style){return function(stream,state){state.tokens[0]=tokenString(quote,style);stream.next();return tokenize(stream,state)}}var tokenDollar=function(stream,state){if(state.tokens.length>1)stream.eat(`$`);var ch=stream.next();if(/['"({]/.test(ch)){state.tokens[0]=tokenString(ch,ch==`(`?`quote`:ch==`{`?`def`:`string`);return tokenize(stream,state)}if(!/\d/.test(ch))stream.eatWhile(/\w/);state.tokens.shift();return`def`};function tokenHeredoc(delim){return function(stream,state){if(stream.sol()&&stream.string==delim)state.tokens.shift();stream.skipToEnd();return`string.special`}}function tokenize(stream,state){return(state.tokens[0]||tokenBase)(stream,state)}var shell={name:`shell`,startState:function(){return{tokens:[]}},token:function(stream,state){return tokenize(stream,state)},languageData:{autocomplete:commonAtoms.concat(commonKeywords,commonCommands),closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`#`}}};var _hoisted_1$4={class:`source-interface`,"aria-label":`File public interface`};var _hoisted_2$4={class:`source-interface__heading`};var _hoisted_3$4={class:`source-interface__modes`};var _hoisted_4$4={class:`source-interface__overview`,"aria-label":`File explanation`};var _hoisted_5$4={class:`source-interface__field-heading`};var _hoisted_6$4={key:2,class:`source-interface__hint`};var _hoisted_7$4={key:3,class:`source-interface__membership`,"aria-label":`Program membership`};var _hoisted_8$4={key:0,class:`source-interface__main`};var _hoisted_9$4={key:1};var _hoisted_10$4=[`onClick`];var _hoisted_11$4={key:4,class:`source-interface__hint`,role:`status`};var _hoisted_12$3=[`title`];var _hoisted_13$3={key:5,class:`source-interface__analysis`};var _hoisted_14$2={key:0,class:`source-interface__hint`};var _hoisted_15$2={key:1,class:`source-interface__hint`};var _hoisted_16$1={class:`source-interface__layout`};var _hoisted_17$1={class:`source-interface__symbols`,"aria-label":`Exported and public symbols`};var _hoisted_18$1=[`data-symbol-id`,`disabled`,`aria-pressed`,`onClick`];var _hoisted_19$1=[`title`];var _hoisted_20$1={key:0};var _hoisted_21$1={key:1};var _hoisted_22$1={key:0,class:`source-interface__detail`,"aria-label":`Selected symbol`};var _hoisted_23$1={key:0,class:`source-interface__hint`};var _hoisted_24$1={class:`source-interface__modes`,"aria-label":`Symbol presentation`};var _hoisted_25$1={key:0};var _hoisted_26$1={key:1,class:`source-interface__hint`};var _hoisted_27$1={key:2,class:`source-interface__code`};var _hoisted_28$1={key:0,class:`source-interface__hint`};var _hoisted_29$1={key:3,class:`source-interface__hint`};var _hoisted_30$1={key:0,class:`source-interface__hint`};var _sfc_main$5={__name:`Vibe64SourceInterface`,props:{filePath:String,fileHash:String,analysisError:String,symbols:{type:Array,default:()=>[]},programs:{type:Array,default:()=>[]},programStatus:String,interpretations:{type:Array,default:()=>[]},interpretationWarning:String,activeInterpretation:Boolean,activeFileInterpretation:Boolean,selectedId:String,current:Boolean,indexed:Boolean,dirty:Boolean,busy:Boolean,assistantAvailable:Boolean,assistantUnavailableMessage:String,source:String,presentation:{type:String,default:`description`},coverage:{type:String,default:`Partial static coverage`}},emits:[`select-symbol`,`present-symbol`,`explain-file`,`whole-file-code`,`open-source`,`open-program`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const orderedPrograms=computed(()=>[...props.programs.filter(program=>program.mainSource===props.filePath),...props.programs.filter(program=>program.mainSource!==props.filePath)]);function openProgramLink(payload={}){const target=sourceEditorLinkTarget(payload);if(!target)return;payload.event?.preventDefault?.();const program=props.programs.find(program=>program.path===target.path);if(program)emit(`open-program`,program.id);else emit(`open-source`,target)}const selectedSymbol=computed(()=>props.symbols.find(symbol=>symbol.id===props.selectedId));const explanationDisabled=computed(()=>props.busy||props.dirty||!props.assistantAvailable);function signature(symbol){return(symbol.qualifiedName||symbol.name)+(Array.isArray(symbol.parameters)?`(${symbol.parameters.join(`, `)})`:``)}function saved(scope,symbolId,presentation){return props.interpretations.find(record=>record.path===props.filePath&&record.scope===scope&&(record.symbolId||``)===symbolId&&record.presentation===presentation)}function isCurrentInterpretation(record){return record.status===`current`&&record.fileHash===props.fileHash&&!props.dirty}const selectedInterpretation=computed(()=>saved(`selection`,selectedSymbol.value?.id||``,`steps`));const fileInterpretation=computed(()=>saved(`file`,``,`description`));const interpretationBlocks=computed(()=>parseLongTextReviewBlocks(selectedInterpretation.value?.body||``));return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,_hoisted_1$4,[createBaseVNode(`header`,_hoisted_2$4,[createBaseVNode(`h3`,null,toDisplayString(__props.filePath?.split(`/`).pop()),1),createBaseVNode(`div`,_hoisted_3$4,[createVNode(VBtn,{size:`small`,"min-height":`44`,variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>_ctx.$emit(`whole-file-code`))},{default:withCtx(()=>[..._cache[5]||(_cache[5]=[createTextVNode(`Code · whole file`,-1)])]),_:1})]),createBaseVNode(`p`,null,toDisplayString(__props.filePath),1)]),__props.analysisError?(openBlock(),createBlock(VAlert,{key:0,type:`error`,variant:`tonal`,class:`mb-3`},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.analysisError),1)]),_:1})):createCommentVNode(``,true),__props.dirty?(openBlock(),createBlock(VAlert,{key:1,type:`info`,variant:`tonal`,class:`mb-3`},{default:withCtx(()=>[..._cache[6]||(_cache[6]=[createTextVNode(`This file has unsaved edits. Save before generating an explanation or using indexed symbol ranges.`,-1)])]),_:1})):!__props.current?(openBlock(),createBlock(VAlert,{key:2,type:`info`,variant:`tonal`,class:`mb-3`},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.indexed?`Index out of date.`:`Symbols not indexed.`)+` Open whole-file Code. Update the index from Architecture → ⋯.`,1)]),_:1})):createCommentVNode(``,true),createBaseVNode(`section`,_hoisted_4$4,[createBaseVNode(`header`,_hoisted_5$4,[_cache[7]||(_cache[7]=createBaseVNode(`h4`,null,`Explanation`,-1)),fileInterpretation.value?(openBlock(),createElementBlock(`span`,{key:0,class:normalizeClass([`source-interface__freshness`,{"source-interface__freshness--stale":!isCurrentInterpretation(fileInterpretation.value)}])},toDisplayString(isCurrentInterpretation(fileInterpretation.value)?`Saved`:`Out of date`),3)):createCommentVNode(``,true),createVNode(VBtn,{size:`small`,"min-height":`44`,variant:`text`,disabled:explanationDisabled.value,onClick:_cache[1]||(_cache[1]=$event=>_ctx.$emit(`explain-file`,Boolean(fileInterpretation.value)))},{default:withCtx(()=>[createTextVNode(toDisplayString(fileInterpretation.value?`Update explanation`:`Generate explanation`),1)]),_:1},8,[`disabled`])]),createBaseVNode(`div`,{class:normalizeClass([`source-interface__explanation`,{"source-interface__explanation--empty":!fileInterpretation.value&&!__props.activeFileInterpretation}])},[__props.activeFileInterpretation?renderSlot(_ctx.$slots,`explanation`,{savedBody:fileInterpretation.value?.body||``},void 0,true,0):fileInterpretation.value?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:1,blocks:unref(parseLongTextReviewBlocks)(fileInterpretation.value.body),onLinkClick:openProgramLink},null,8,[`blocks`])):(openBlock(),createElementBlock(`p`,_hoisted_6$4,toDisplayString(!__props.assistantAvailable?`Choose an Explain & check model in Models to generate an explanation.`:`No explanation yet.`),1))],2)]),__props.programs.length?(openBlock(),createElementBlock(`nav`,_hoisted_7$4,[(openBlock(true),createElementBlock(Fragment,null,renderList(orderedPrograms.value,program=>{return openBlock(),createElementBlock(`span`,{key:program.id},[program.mainSource===__props.filePath?(openBlock(),createElementBlock(`small`,_hoisted_8$4,`Main Program file`)):(openBlock(),createElementBlock(`span`,_hoisted_9$4,`Part of `)),createBaseVNode(`button`,{type:`button`,onClick:$event=>_ctx.$emit(`open-program`,program.id)},toDisplayString(program.title)+` →`,9,_hoisted_10$4)])}),128))])):createCommentVNode(``,true),__props.interpretationWarning?(openBlock(),createElementBlock(`p`,_hoisted_11$4,toDisplayString(__props.interpretationWarning),1)):createCommentVNode(``,true),createBaseVNode(`h4`,{class:`source-interface__exports-heading`,title:`${__props.coverage}. File exports may be internal to the subsystem. Unrecorded returns are omitted.`},[_cache[8]||(_cache[8]=createTextVNode(`File exports `,-1)),createBaseVNode(`span`,null,toDisplayString(__props.symbols.length),1)],8,_hoisted_12$3),__props.programStatus!==`valid`||!__props.assistantAvailable?(openBlock(),createElementBlock(`details`,_hoisted_13$3,[_cache[9]||(_cache[9]=createBaseVNode(`summary`,null,`Analysis details`,-1)),__props.programStatus!==`valid`?(openBlock(),createElementBlock(`p`,_hoisted_14$2,`Program unavailable.`)):createCommentVNode(``,true),!__props.assistantAvailable?(openBlock(),createElementBlock(`p`,_hoisted_15$2,toDisplayString(__props.assistantUnavailableMessage||`A Helper is needed to generate explanations.`),1)):createCommentVNode(``,true)])):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_16$1,[createBaseVNode(`nav`,_hoisted_17$1,[(openBlock(true),createElementBlock(Fragment,null,renderList(__props.symbols,symbol=>{return openBlock(),createElementBlock(`div`,{key:symbol.id,class:`source-interface__symbol-row`},[createBaseVNode(`button`,{class:normalizeClass([`source-interface__symbol`,{"source-interface__symbol--selected":symbol.id===__props.selectedId}]),type:`button`,"data-symbol-id":symbol.id,disabled:!__props.current||__props.dirty,"aria-pressed":symbol.id===__props.selectedId,onClick:$event=>_ctx.$emit(`select-symbol`,symbol.id)},[createBaseVNode(`small`,null,toDisplayString(symbol.kind),1),createBaseVNode(`code`,{title:signature(symbol)},toDisplayString(signature(symbol)),9,_hoisted_19$1),symbol.returnType?(openBlock(),createElementBlock(`span`,_hoisted_20$1,`Returns: `+toDisplayString(symbol.returnType),1)):createCommentVNode(``,true),!symbol.rangeAvailable||symbol.visibilityScope&&symbol.visibilityScope!==`public`?(openBlock(),createElementBlock(`span`,_hoisted_21$1,toDisplayString(symbol.rangeAvailable?``:`Range unavailable`)+toDisplayString(symbol.visibilityScope&&symbol.visibilityScope!==`public`?` · Visibility: ${symbol.visibilityScope}`:``),1)):createCommentVNode(``,true)],10,_hoisted_18$1),symbol.id===__props.selectedId?(openBlock(),createElementBlock(`section`,_hoisted_22$1,[selectedSymbol.value.returnType?(openBlock(),createElementBlock(`p`,_hoisted_23$1,`Returns: `+toDisplayString(selectedSymbol.value.returnType),1)):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_24$1,[Array.isArray(selectedSymbol.value.parameters)?(openBlock(),createElementBlock(`h4`,_hoisted_25$1,`Pseudocode`)):createCommentVNode(``,true),__props.presentation===`code`&&selectedInterpretation.value?(openBlock(),createBlock(VBtn,{key:1,size:`small`,"min-height":`44`,variant:`text`,onClick:_cache[2]||(_cache[2]=$event=>_ctx.$emit(`select-symbol`,__props.selectedId))},{default:withCtx(()=>[..._cache[10]||(_cache[10]=[createTextVNode(`Pseudocode`,-1)])]),_:1})):createCommentVNode(``,true),Array.isArray(selectedSymbol.value.parameters)?(openBlock(),createBlock(VBtn,{key:2,size:`small`,"min-height":`44`,variant:`text`,disabled:!selectedSymbol.value.rangeAvailable||!__props.current||__props.dirty||explanationDisabled.value,onClick:_cache[3]||(_cache[3]=$event=>_ctx.$emit(`present-symbol`,`steps`,Boolean(selectedInterpretation.value)))},{default:withCtx(()=>[createTextVNode(toDisplayString(selectedInterpretation.value?`Update pseudocode`:`Generate pseudocode`),1)]),_:1},8,[`disabled`])):createCommentVNode(``,true),createVNode(VBtn,{size:`small`,"min-height":`44`,variant:`text`,disabled:!selectedSymbol.value.rangeAvailable||!__props.current||__props.dirty,onClick:_cache[4]||(_cache[4]=$event=>_ctx.$emit(`present-symbol`,`code`))},{default:withCtx(()=>[..._cache[11]||(_cache[11]=[createTextVNode(`Code`,-1)])]),_:1},8,[`disabled`])]),Array.isArray(selectedSymbol.value.parameters)&&!__props.assistantAvailable&&!saved(`selection`,__props.selectedId,`steps`)?(openBlock(),createElementBlock(`p`,_hoisted_26$1,`Choose a Helper to generate pseudocode.`)):createCommentVNode(``,true),__props.presentation===`code`?(openBlock(),createElementBlock(`pre`,_hoisted_27$1,[createBaseVNode(`code`,null,toDisplayString(__props.source),1)])):Array.isArray(selectedSymbol.value.parameters)?(openBlock(),createElementBlock(Fragment,{key:3},[selectedInterpretation.value?(openBlock(),createElementBlock(`p`,_hoisted_28$1,toDisplayString(isCurrentInterpretation(selectedInterpretation.value)?`Saved · matches source`:`Out of date · source or guidance changed`),1)):createCommentVNode(``,true),__props.activeInterpretation?renderSlot(_ctx.$slots,`explanation`,{savedBody:selectedInterpretation.value?.body||``},void 0,true,1):selectedInterpretation.value?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:2,blocks:interpretationBlocks.value,onLinkClick:openProgramLink},null,8,[`blocks`])):(openBlock(),createElementBlock(`p`,_hoisted_29$1,`No pseudocode yet.`))],64)):createCommentVNode(``,true)])):createCommentVNode(``,true)])}),128)),!__props.symbols.length?(openBlock(),createElementBlock(`p`,_hoisted_30$1,toDisplayString(__props.current?`No exports recorded; analysis may be incomplete.`:`Open whole-file Code.`),1)):createCommentVNode(``,true)])])])}}};var Vibe64SourceInterface_default=_plugin_vue_export_helper_default(_sfc_main$5,[[`__scopeId`,`data-v-0a8a7f93`]]);var _hoisted_1$3=[`aria-busy`];var _hoisted_2$3={key:1,class:`source-explanation-document__progress`,role:`status`};var _hoisted_3$3={key:2,class:`source-explanation-document__activity`,open:``};var _hoisted_4$3={key:3,class:`source-explanation-document__progress`,role:`status`};var _hoisted_5$3=[`aria-busy`];var _hoisted_6$3={class:`vibe64-source-explanation__header`};var _hoisted_7$3={class:`vibe64-source-explanation__source`};var _hoisted_8$3=[`title`];var _hoisted_9$3={class:`vibe64-source-explanation__range-path`};var _hoisted_10$3={key:0,class:`vibe64-source-explanation__range-suffix`};var _hoisted_11$3={key:0,class:`vibe64-source-explanation__thinking`};var _hoisted_12$2={key:3,class:`vibe64-source-explanation__status vibe64-source-explanation__status--stopped`};var _hoisted_13$2={key:1,class:`vibe64-source-explanation__recovery`,"aria-label":`Explanation controls`};var _hoisted_14$1={class:`vibe64-source-explanation__recovery-actions`};var _hoisted_15$1={class:`vibe64-source-explanation__followup-footer`};var _sfc_main$4={__name:`Vibe64SourceExplanationPanel`,props:{embedded:Boolean,savedBody:{type:String,default:``},assistantAvailable:{default:true,type:Boolean},assistantUnavailableMessage:{default:`The selected AI connection is unavailable for this account.`,type:String},busy:{default:false,type:Boolean},closing:{default:false,type:Boolean},explanation:{default:()=>({body:``,followups:[],messages:[],sourceRange:{},summary:``,title:``}),type:Object},followup:{default:``,type:String},selectedPath:{default:``,type:String}},emits:[`collapse`,`close`,`open-range`,`open-source-link`,`retry`,`send-followup`,`stop`,`update:followup`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const threadElement=ref(null);const threadBottomElement=ref(null);const followingLatest=ref(true);const assistantLabel=computed(()=>{const profile=props.explanation?.executionProfile;if(!profile?.providerId||!profile?.model)return`Assistant`;return vibe64AssistantSelectionLabel({engineId:profile.providerId,modelId:profile.model,variantId:profile.thinking})});const chatMessages=computed(()=>(Array.isArray(props.explanation?.messages)&&props.explanation.messages.length?props.explanation.messages:[...props.explanation?.body?[{id:`body`,role:`assistant`,text:props.explanation.body}]:[],...Array.isArray(props.explanation?.followups)?props.explanation.followups:[]]).map(message=>({...message,blocks:parseLongTextReviewBlocks(message.text||``,{preserveParagraphLineBreaks:message.role===`user`})})));const documentBody=computed(()=>props.explanation?.body||props.savedBody||chatMessages.value.findLast(message=>message.role===`assistant`&&message.status===`complete`)?.text||``);const documentBlocks=computed(()=>parseLongTextReviewBlocks(documentBody.value));const documentProgress=computed(()=>chatMessages.value.findLast(message=>message.role===`assistant`&&message.status===`thinking`)?.text||``);const documentFailure=computed(()=>chatMessages.value.findLast(message=>message.role===`assistant`&&message.status===`failed`)?.text||``);const followupAvailable=computed(()=>Boolean(props.explanation?.status!==`failed`&&(props.explanation?.agentThreadId||props.explanation?.engine===`agent-cache`)&&(String(props.explanation?.body||``).trim()||chatMessages.value.some(message=>message.role===`assistant`&&message.status===`complete`&&message.text))));const sourceRange=computed(()=>props.explanation?.sourceRange||{});const sourceRangeFullLabel=computed(()=>sourceRangeDisplayLabel(sourceRange.value));const sourceRangePathLabel=computed(()=>sourceRangePathDisplayLabel(sourceRange.value));const sourceRangeSuffixLabel=computed(()=>sourceRangeLineSuffix(sourceRange.value));const threadScrollKey=computed(()=>chatMessages.value.map(message=>[message.id||``,message.role||``,message.status||``,String(message.text||``).length].join(`:`)).join(`|`));const{scrollAfterLayout:scrollThreadToBottom}=useScrollToBottom({anchor:threadBottomElement,enabled:computed(()=>followingLatest.value),scrollAnchorIntoView:false,target:threadElement});function sourceRangeLineSuffix({endLine,startLine}={}){const start=Number(startLine);const end=Number(endLine);if(!Number.isFinite(start)||start<1)return``;if(!Number.isFinite(end)||end<1||end===start)return`:${start}`;return`:${start}-${end}`}function compactSourcePath(path=``,{maxLength=36}={}){const normalized=normalizeSourceEditorPath(path);if(normalized.length<=maxLength)return normalized;return`...${normalized.slice(-maxLength)}`}function sourceRangePathDisplayLabel(range={}){const path=normalizeSourceEditorPath(range?.path);if(!path)return`Source`;return compactSourcePath(path)}function sourceRangeDisplayLabel(range={}){const path=normalizeSourceEditorPath(range?.path);if(!path)return`Source`;return`${path}${sourceRangeLineSuffix(range)}`}function submitFollowup(){if(!props.assistantAvailable||!props.followup.trim()||props.busy||props.closing||!followupAvailable.value)return;emit(`send-followup`)}function queueThreadBottomScroll({force=false}={}){if(props.embedded)return;if(force)followingLatest.value=true;scrollThreadToBottom({behavior:force?`auto`:`smooth`})}function updateThreadFollowState(event={}){followingLatest.value=scrollElementNearBottom(event?.currentTarget||threadElement.value)}function handleExplanationLinkClick(payload={}){const target=sourceEditorLinkTarget(payload);if(!target)return;payload.event?.preventDefault?.();payload.event?.stopPropagation?.();emit(`open-source-link`,target)}watch(()=>props.explanation?.id||``,()=>{queueThreadBottomScroll({force:true})},{flush:`post`,immediate:true});watch(threadScrollKey,(value,previous)=>{if(!value||value===previous)return;queueThreadBottomScroll({force:chatMessages.value.at(-1)?.role===`user`})},{flush:`post`});return(_ctx,_cache)=>{return __props.embedded?(openBlock(),createElementBlock(`section`,{key:0,class:`source-explanation-document`,"aria-busy":__props.busy||__props.closing,"aria-label":`Generated explanation`},[documentBody.value?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:0,blocks:documentBlocks.value,onLinkClick:handleExplanationLinkClick},null,8,[`blocks`])):createCommentVNode(``,true),__props.busy||__props.closing?(openBlock(),createElementBlock(`div`,_hoisted_2$3,[createBaseVNode(`span`,null,toDisplayString(__props.closing?`Stopping…`:`Generating explanation…`),1),!__props.closing?(openBlock(),createBlock(VBtn,{key:0,size:`small`,"min-height":`44`,variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>emit(`stop`))},{default:withCtx(()=>[..._cache[9]||(_cache[9]=[createTextVNode(`Stop`,-1)])]),_:1})):createCommentVNode(``,true)])):createCommentVNode(``,true),__props.busy&&documentProgress.value?(openBlock(),createElementBlock(`details`,_hoisted_3$3,[_cache[10]||(_cache[10]=createBaseVNode(`summary`,null,`Progress`,-1)),createVNode(unref(LongTextPreviewBlocks_default),{blocks:unref(parseLongTextReviewBlocks)(documentProgress.value),onLinkClick:handleExplanationLinkClick},null,8,[`blocks`])])):!__props.busy&&!__props.closing&&[`failed`,`stopped`].includes(__props.explanation.status)?(openBlock(),createElementBlock(`div`,_hoisted_4$3,[createBaseVNode(`span`,null,toDisplayString(__props.explanation.status===`stopped`?`Generation stopped.`:documentFailure.value||`Generation failed.`),1),createVNode(VBtn,{size:`small`,"min-height":`44`,variant:`text`,disabled:!__props.assistantAvailable,onClick:_cache[1]||(_cache[1]=$event=>emit(`retry`))},{default:withCtx(()=>[..._cache[11]||(_cache[11]=[createTextVNode(`Retry`,-1)])]),_:1},8,[`disabled`])])):createCommentVNode(``,true)],8,_hoisted_1$3)):(openBlock(),createElementBlock(`aside`,{key:1,"aria-busy":__props.busy||__props.closing?`true`:`false`,class:`vibe64-source-explanation`,"aria-label":`Source explanation`},[createBaseVNode(`header`,_hoisted_6$3,[createBaseVNode(`div`,_hoisted_7$3,[createBaseVNode(`button`,{class:`vibe64-source-explanation__range`,title:sourceRangeFullLabel.value,type:`button`,onClick:_cache[2]||(_cache[2]=$event=>emit(`open-range`,__props.explanation))},[createBaseVNode(`span`,_hoisted_9$3,toDisplayString(sourceRangePathLabel.value),1),sourceRangeSuffixLabel.value?(openBlock(),createElementBlock(`span`,_hoisted_10$3,toDisplayString(sourceRangeSuffixLabel.value),1)):createCommentVNode(``,true)],8,_hoisted_8$3),__props.explanation.stale?(openBlock(),createBlock(VChip,{key:0,color:`warning`,size:`x-small`,variant:`tonal`},{default:withCtx(()=>[..._cache[12]||(_cache[12]=[createTextVNode(` Stale `,-1)])]),_:1})):createCommentVNode(``,true)]),createVNode(VBtn,{class:`vibe64-source-explanation__action-target`,"aria-label":`Collapse explanation`,icon:unref(mdiChevronRight),size:`small`,title:`Collapse explanation`,type:`button`,variant:`text`,onClick:_cache[3]||(_cache[3]=$event=>emit(`collapse`,$event))},null,8,[`icon`]),createVNode(VBtn,{class:`vibe64-source-explanation__action-target vibe64-source-explanation__close-button`,"aria-busy":__props.closing?`true`:void 0,"aria-label":`Close explanation`,disabled:__props.closing,"prepend-icon":unref(mdiClose),size:`x-small`,title:__props.closing?`Closing explanation`:`Close explanation`,type:`button`,variant:`text`,onClick:_cache[4]||(_cache[4]=$event=>emit(`close`,$event))},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.closing?`Closing…`:`Close`),1)]),_:1},8,[`aria-busy`,`disabled`,`prepend-icon`,`title`])]),__props.explanation.stale?(openBlock(),createBlock(VAlert,{key:0,class:`vibe64-source-explanation__stale`,density:`compact`,type:`warning`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(__props.explanation.staleReason||`The source changed after this explanation was created.`),1)]),_:1})):createCommentVNode(``,true),createBaseVNode(`section`,{ref_key:`threadElement`,ref:threadElement,class:`vibe64-source-explanation__thread`,"aria-label":`Explanation chat`,tabindex:`0`,onScroll:updateThreadFollowState},[(openBlock(true),createElementBlock(Fragment,null,renderList(chatMessages.value,message=>{return openBlock(),createElementBlock(`article`,{key:message.id,class:normalizeClass([`vibe64-source-explanation__message`,[`vibe64-source-explanation__message--${message.role}`,{"vibe64-source-explanation__message--failed":message.status===`failed`,"vibe64-source-explanation__message--thinking":message.status===`thinking`}]])},[createBaseVNode(`strong`,null,toDisplayString(message.role===`user`?`You`:assistantLabel.value),1),message.status===`thinking`?(openBlock(),createElementBlock(`div`,_hoisted_11$3,[message.text?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:0,compact:``,class:`vibe64-source-explanation__thinking-detail`,blocks:message.blocks,onLinkClick:handleExplanationLinkClick},null,8,[`blocks`])):createCommentVNode(``,true),_cache[13]||(_cache[13]=createBaseVNode(`div`,{class:`vibe64-source-explanation__status`,role:`status`},[createBaseVNode(`span`,{"aria-hidden":`true`,class:`vibe64-source-explanation__status-mark`}),createBaseVNode(`span`,null,`Thinking…`)],-1))])):message.status===`failed`&&message.text?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:1,class:`vibe64-source-explanation__failure-detail`,blocks:message.blocks,onLinkClick:handleExplanationLinkClick},null,8,[`blocks`])):message.text?(openBlock(),createBlock(unref(LongTextPreviewBlocks_default),{key:2,blocks:message.blocks,onLinkClick:handleExplanationLinkClick},null,8,[`blocks`])):message.status===`stopped`?(openBlock(),createElementBlock(`div`,_hoisted_12$2,` Stopped. `)):createCommentVNode(``,true)],2)}),128)),createBaseVNode(`div`,{ref_key:`threadBottomElement`,ref:threadBottomElement,class:`vibe64-source-explanation__thread-bottom`},null,512)],544),!followupAvailable.value?(openBlock(),createElementBlock(`section`,_hoisted_13$2,[createBaseVNode(`p`,null,toDisplayString(__props.closing?`Closing…`:__props.busy?`Waiting for the explanation…`:`No explanation was produced. Check the assistant provider, then retry.`),1),createBaseVNode(`div`,_hoisted_14$1,[__props.busy&&!__props.closing?(openBlock(),createBlock(VBtn,{key:0,class:`vibe64-source-explanation__action-target`,"aria-label":`Stop explanation`,color:`error`,icon:unref(mdiStop),size:`small`,title:`Stop explanation`,type:`button`,variant:`tonal`,onClick:_cache[5]||(_cache[5]=$event=>emit(`stop`))},null,8,[`icon`])):(openBlock(),createBlock(VBtn,{key:1,class:`vibe64-source-explanation__action-target`,color:`primary`,disabled:__props.closing||!__props.assistantAvailable,"prepend-icon":unref(mdiRefresh),size:`small`,title:__props.assistantAvailable?`Retry explanation`:__props.assistantUnavailableMessage,type:`button`,variant:`flat`,onClick:_cache[6]||(_cache[6]=$event=>emit(`retry`))},{default:withCtx(()=>[..._cache[14]||(_cache[14]=[createTextVNode(` Retry explanation `,-1)])]),_:1},8,[`disabled`,`prepend-icon`,`title`]))])])):(openBlock(),createElementBlock(`form`,{key:2,class:`vibe64-source-explanation__followup`,onSubmit:withModifiers(submitFollowup,[`prevent`])},[createVNode(_sfc_main$11,{"attachments-enabled":false,"auto-grow":true,disabled:__props.busy||__props.closing||!__props.assistantAvailable,label:`Ask about this explanation`,"model-value":__props.followup,placeholder:`Ask a follow-up`,rows:`1`,onSubmit:submitFollowup,"onUpdate:modelValue":_cache[8]||(_cache[8]=$event=>emit(`update:followup`,$event))},{footer:withCtx(()=>[createBaseVNode(`div`,_hoisted_15$1,[__props.busy&&!__props.closing?(openBlock(),createBlock(VBtn,{key:0,class:`vibe64-source-explanation__action-target`,"aria-label":`Stop explanation`,color:`error`,icon:unref(mdiStop),size:`small`,title:`Stop explanation`,type:`button`,variant:`tonal`,onClick:_cache[7]||(_cache[7]=$event=>emit(`stop`))},null,8,[`icon`])):createCommentVNode(``,true),createVNode(VBtn,{class:`vibe64-source-explanation__action-target`,"aria-label":`Send follow-up`,color:`primary`,disabled:!__props.followup.trim()||__props.busy||__props.closing||!__props.assistantAvailable,icon:unref(mdiSend),size:`small`,title:__props.assistantAvailable?`Send follow-up`:__props.assistantUnavailableMessage,type:`submit`,variant:`flat`},null,8,[`disabled`,`icon`,`title`])])]),_:1},8,[`disabled`,`model-value`])],32))],8,_hoisted_5$3))}}};var Vibe64SourceExplanationPanel_default=_plugin_vue_export_helper_default(_sfc_main$4,[[`__scopeId`,`data-v-71fd443b`]]);var _hoisted_1$2={class:`vibe64-source-tree`};var _hoisted_2$2={class:`vibe64-source-tree__row`};var _hoisted_3$2=[`data-vibe64-guide-path`,`title`,`onClick`];var _hoisted_4$2=[`title`,`onClick`];var _hoisted_5$2={key:1,class:`vibe64-source-tree__chevron-spacer`,"aria-hidden":`true`};var _hoisted_6$2={key:0,class:`vibe64-source-tree__directory`};var _hoisted_7$2={key:0,class:`vibe64-source-tree__notice`};var _hoisted_8$2={key:1,class:`vibe64-source-tree__notice vibe64-source-tree__notice--error`};var _hoisted_9$2={key:2,class:`vibe64-source-tree__notice`};var _hoisted_10$2={key:0,class:`vibe64-source-tree__item`};var _hoisted_11$2=[`disabled`,`title`];var _hoisted_12$1={key:0};var _hoisted_13$1={key:1};var _sfc_main$3={__name:`Vibe64SourceFileTree`,props:{starredPaths:{type:Array,default:()=>[]},expandedPaths:{default:()=>[],type:Array},loadErrors:{default:()=>({}),type:Object},loadingPaths:{default:()=>[],type:Array},node:{default:null,type:Object},selectedPath:{default:``,type:String},assistantDraftAvailable:{default:false,type:Boolean}},emits:[`ask-assistant`,`copy-path`,`directory-open-change`,`download-file`,`load-more-directory`,`new-file`,`open-file`,`toggle-star`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const nodes=computed(()=>Array.isArray(props.node?.children)?props.node.children:[]);const nodeHasMore=computed(()=>props.node?.hasMore===true);const currentNodeLoading=computed(()=>pathLoading(props.node?.path||``));const nextHiddenNodeCount=computed(()=>{const loadedCount=nodes.value.length;const totalCount=Number(props.node?.total||0);const pageSize=Number(props.node?.limit||0);return totalCount>loadedCount?Math.min(pageSize,totalCount-loadedCount):pageSize});const nodeLabel=computed(()=>props.node?.path||props.node?.name||`source`);const expandedPathSet=computed(()=>new Set((Array.isArray(props.expandedPaths)?props.expandedPaths:[]).map(path=>normalizeSourceEditorPath(path)).filter(Boolean)));const loadingPathSet=computed(()=>new Set((Array.isArray(props.loadingPaths)?props.loadingPaths:[]).map(path=>normalizeSourceEditorPath(path))));function directoryExpandable(node={}){return node.type===`directory`&&(node.loaded!==true||node.hasMore===true||Array.isArray(node.children)&&node.children.length>0)}function directoryKey(node={}){return normalizeSourceEditorPath(node.path||node.name||``)}function directoryOpen(node={}){return expandedPathSet.value.has(directoryKey(node))}function pathLoading(path=``){return loadingPathSet.value.has(normalizeSourceEditorPath(path))}function directoryLoading(node={}){return pathLoading(directoryKey(node))}function directoryLoadError(node={}){return String(props.loadErrors?.[directoryKey(node)]||``)}function directoryChildCount(node={}){return Array.isArray(node.children)?node.children.length:0}function toggleDirectory(node={}){const key=directoryKey(node);if(!key)return;emit(`directory-open-change`,{open:!directoryOpen(node),path:key})}function showMore(){emit(`load-more-directory`,props.node?.path||``)}return(_ctx,_cache)=>{const _component_Vibe64SourceFileTree=resolveComponent(`Vibe64SourceFileTree`,true);return openBlock(),createElementBlock(`ul`,_hoisted_1$2,[(openBlock(true),createElementBlock(Fragment,null,renderList(nodes.value,child=>{return openBlock(),createElementBlock(`li`,{key:child.path||child.name,class:`vibe64-source-tree__item`},[createBaseVNode(`div`,_hoisted_2$2,[child.type===`file`?(openBlock(),createElementBlock(`button`,{key:0,class:normalizeClass([`vibe64-source-tree__button`,{"vibe64-source-tree__button--active":child.path===__props.selectedPath}]),"data-vibe64-guide-path":child.path||void 0,title:child.path||child.name||`source`,type:`button`,onClick:$event=>emit(`open-file`,child.path)},[createVNode(VIcon,{icon:unref(mdiFileDocumentOutline),size:`15`},null,8,[`icon`]),createBaseVNode(`span`,null,toDisplayString(child.name),1),__props.starredPaths.includes(child.path)?(openBlock(),createBlock(VIcon,{key:0,icon:unref(mdiStar),size:`14`,"aria-label":`Starred`},null,8,[`icon`])):createCommentVNode(``,true)],10,_hoisted_3$2)):(openBlock(),createElementBlock(`button`,{key:1,class:`vibe64-source-tree__button vibe64-source-tree__button--directory`,title:child.path||child.name||`source`,type:`button`,onClick:$event=>toggleDirectory(child)},[directoryExpandable(child)?(openBlock(),createBlock(VIcon,{key:0,class:normalizeClass([`vibe64-source-tree__chevron`,{"vibe64-source-tree__chevron--open":directoryOpen(child)}]),icon:unref(mdiChevronRight),size:`14`},null,8,[`class`,`icon`])):(openBlock(),createElementBlock(`span`,_hoisted_5$2)),createVNode(VIcon,{icon:unref(mdiFolderOutline),size:`15`},null,8,[`icon`]),createBaseVNode(`span`,null,toDisplayString(child.name||`source`),1)],8,_hoisted_4$2)),createVNode(VMenu,{location:`bottom end`},{activator:withCtx(({props:activatorProps})=>[createVNode(VBtn,mergeProps({ref_for:true},activatorProps,{"aria-label":`Actions for ${child.path||child.name||`source`}`,class:`vibe64-source-tree__menu-button`,icon:unref(mdiDotsVertical),size:`x-small`,title:`Actions for ${child.path||child.name||`source`}`,type:`button`,variant:`text`,onClick:_cache[0]||(_cache[0]=withModifiers(()=>{},[`stop`]))}),null,16,[`aria-label`,`icon`,`title`])]),default:withCtx(()=>[createVNode(VList,{class:`vibe64-source-tree__menu`,density:`compact`},{default:withCtx(()=>[child.type===`file`?(openBlock(),createBlock(VListItem,{key:0,"prepend-icon":__props.starredPaths.includes(child.path)?unref(mdiStar):unref(mdiStarOutline),title:__props.starredPaths.includes(child.path)?`Unstar file`:`Star file`,onClick:$event=>emit(`toggle-star`,child.path)},null,8,[`prepend-icon`,`title`,`onClick`])):createCommentVNode(``,true),child.type===`file`?(openBlock(),createBlock(VListItem,{key:1,"prepend-icon":unref(mdiDownload),title:`Download file`,onClick:$event=>emit(`download-file`,child.path)},null,8,[`prepend-icon`,`onClick`])):createCommentVNode(``,true),child.type===`directory`?(openBlock(),createBlock(VListItem,{key:2,"prepend-icon":unref(mdiFilePlusOutline),title:`New file here`,onClick:$event=>emit(`new-file`,child.path||``)},null,8,[`prepend-icon`,`onClick`])):createCommentVNode(``,true),createVNode(VListItem,{"prepend-icon":unref(mdiContentCopy),title:`Copy path`,onClick:$event=>emit(`copy-path`,child.path||child.name||``)},null,8,[`prepend-icon`,`onClick`]),child.type===`file`&&__props.assistantDraftAvailable?(openBlock(),createBlock(VListItem,{key:3,"prepend-icon":unref(mdiRobotOutline),title:`Ask the AI assistant about this file`,onClick:$event=>emit(`ask-assistant`,child.path||``)},null,8,[`prepend-icon`,`onClick`])):createCommentVNode(``,true)]),_:2},1024)]),_:2},1024)]),child.type!==`file`&&directoryOpen(child)?(openBlock(),createElementBlock(`div`,_hoisted_6$2,[createVNode(_component_Vibe64SourceFileTree,{node:child,"assistant-draft-available":__props.assistantDraftAvailable,"selected-path":__props.selectedPath,"starred-paths":__props.starredPaths,"expanded-paths":__props.expandedPaths,"load-errors":__props.loadErrors,"loading-paths":__props.loadingPaths,onLoadMoreDirectory:_cache[1]||(_cache[1]=$event=>emit(`load-more-directory`,$event)),onOpenFile:_cache[2]||(_cache[2]=$event=>emit(`open-file`,$event)),onToggleStar:_cache[3]||(_cache[3]=$event=>emit(`toggle-star`,$event)),onDownloadFile:_cache[4]||(_cache[4]=$event=>emit(`download-file`,$event)),onDirectoryOpenChange:_cache[5]||(_cache[5]=$event=>emit(`directory-open-change`,$event)),onNewFile:_cache[6]||(_cache[6]=$event=>emit(`new-file`,$event)),onCopyPath:_cache[7]||(_cache[7]=$event=>emit(`copy-path`,$event)),onAskAssistant:_cache[8]||(_cache[8]=$event=>emit(`ask-assistant`,$event))},null,8,[`node`,`assistant-draft-available`,`selected-path`,`starred-paths`,`expanded-paths`,`load-errors`,`loading-paths`]),directoryLoading(child)?(openBlock(),createElementBlock(`div`,_hoisted_7$2,` Loading... `)):directoryLoadError(child)?(openBlock(),createElementBlock(`div`,_hoisted_8$2,toDisplayString(directoryLoadError(child)),1)):directoryOpen(child)&&child.loaded&&!directoryChildCount(child)&&!child.hasMore?(openBlock(),createElementBlock(`div`,_hoisted_9$2,` Empty directory. `)):createCommentVNode(``,true)])):createCommentVNode(``,true)])}),128)),nodeHasMore.value?(openBlock(),createElementBlock(`li`,_hoisted_10$2,[createBaseVNode(`button`,{class:`vibe64-source-tree__button vibe64-source-tree__button--more`,disabled:currentNodeLoading.value,title:`Load ${nextHiddenNodeCount.value} more entries in ${nodeLabel.value}`,type:`button`,onClick:showMore},[createVNode(VIcon,{icon:unref(mdiDotsHorizontal),size:`15`},null,8,[`icon`]),currentNodeLoading.value?(openBlock(),createElementBlock(`span`,_hoisted_12$1,`Loading...`)):(openBlock(),createElementBlock(`span`,_hoisted_13$1,`Load `+toDisplayString(nextHiddenNodeCount.value)+` more`,1))],8,_hoisted_11$2)])):createCommentVNode(``,true)])}}};var Vibe64SourceFileTree_default=_plugin_vue_export_helper_default(_sfc_main$3,[[`__scopeId`,`data-v-5bc17139`]]);async function downloadAttachment(url,fileName,fallbackMessage=`Download failed.`){const response=await fetch(url,{credentials:`include`});if(!response.ok||!response.headers.get(`content-disposition`)?.startsWith(`attachment;`))throw new Error(vibe64ApiResponseError(await response.json().catch(()=>({})),fallbackMessage));const objectUrl=URL.createObjectURL(await response.blob());const anchor=document.createElement(`a`);anchor.href=objectUrl;anchor.download=fileName;document.body.append(anchor);anchor.click();anchor.remove();setTimeout(()=>URL.revokeObjectURL(objectUrl),1e3)}function parseJsonStreamEvent(event){try{return JSON.parse(event?.data||`{}`)}catch{return{}}}function useVibe64SourceEditorFileSync({active=true,onChange=null,onError=null,onReady=null,path=``,sessionId=``,sessionsApiPath=``}={}){let eventSource=null;function currentValue(value){return String(readRefOrGetterValue(value)||``).trim()}function isActive(){return readRefOrGetterValue(active)!==false}function close(){eventSource?.close?.();eventSource=null}function start(){close();const currentPath=currentValue(path);const currentSessionId=currentValue(sessionId);const currentSessionsApiPath=currentValue(sessionsApiPath);if(!isActive()||!currentPath||!currentSessionId||!currentSessionsApiPath||typeof EventSource!==`function`)return;let source;try{source=new EventSource(resolveStudioRequestUrl(vibe64SourceEditorChangesStreamPath(currentSessionsApiPath,currentSessionId,currentPath)),{withCredentials:true})}catch(error){onError?.({error:String(error?.message||error||`Source file observation could not start.`),fatal:true});return}eventSource=source;const isCurrent=()=>eventSource===source;source.addEventListener(VIBE64_SOURCE_EDITOR_FILE_CHANGED_EVENT,event=>{if(isCurrent())onChange?.(parseJsonStreamEvent(event))});source.addEventListener(VIBE64_SOURCE_EDITOR_SYNC_READY_EVENT,event=>{if(!isCurrent())return;onReady?.(parseJsonStreamEvent(event))});source.addEventListener(VIBE64_SOURCE_EDITOR_SYNC_ERROR_EVENT,event=>{if(isCurrent()){const payload=parseJsonStreamEvent(event);onError?.(payload);if(payload.fatal===true)close()}});source.onerror=()=>{if(isCurrent())onError?.({error:`Source file observation disconnected.`,transient:true})}}watch([()=>isActive(),()=>currentValue(path),()=>currentValue(sessionId),()=>currentValue(sessionsApiPath)],start,{immediate:true});onBeforeUnmount(close)}var SOURCE_EDITOR_AUTOSAVE_DELAY_MS=700;var SOURCE_EDITOR_FILE_MATCH_DELAY_MS=120;var SOURCE_EDITOR_SEARCH_DELAY_MS=260;var SOURCE_EDITOR_TREE_PAGE_SIZE=20;var SOURCE_EDITOR_REMOTE_CHANGE_MESSAGE=`This file changed in another window. Reload it before saving.`;var sourceExplanationClientIdCounter=0;function normalizeSourceEditorSyncValue(value=``){return String(value||``).trim()}function sourceEditorFileChangePayloadMatches({originId=vibe64BrowserTabOriginId(),path=``,payload={},projectSlug=``,sessionId=``}={}){const normalizedPath=normalizeSourceEditorPath(path);const normalizedProjectSlug=normalizeSourceEditorSyncValue(projectSlug);const normalizedSessionId=normalizeSourceEditorSyncValue(sessionId);if(!normalizedPath||!normalizedProjectSlug||!normalizedSessionId||normalizeSourceEditorPath(payload?.path)!==normalizedPath||normalizeSourceEditorSyncValue(payload?.projectSlug)!==normalizedProjectSlug||normalizeSourceEditorSyncValue(payload?.sessionId)!==normalizedSessionId||vibe64RealtimePayloadFromCurrentTab(payload,{originId}))return false;return Boolean(normalizeSourceEditorSyncValue(payload?.hash))}function normalizeEditorQuery(value=``){return String(value||``).trim()}function normalizeSourceEditorPolicy(value={}){return value&&typeof value===`object`&&!Array.isArray(value)?{...value}:{}}function normalizeFileMatches(value=[]){return(Array.isArray(value)?value:[]).map((file={})=>({language:String(file.language||``),name:String(file.name||``),path:normalizeSourceEditorPath(file.path)})).filter(file=>file.path)}function normalizeSearchResults(value=[]){return(Array.isArray(value)?value:[]).map((result={})=>({column:Math.max(1,Number(result.column||1)),line:Math.max(1,Number(result.line||1)),path:normalizeSourceEditorPath(result.path),preview:String(result.preview||``)})).filter(result=>result.path)}function normalizeResolvedSourceEditorPath(value={}){const source=value&&typeof value===`object`&&!Array.isArray(value)?value:{};return{path:normalizeSourceEditorPath(source.path||source.file?.path),resolved:source.resolved===true}}function normalizeExplanationEntry(entry,{status}={}){return{createdAt:String(entry?.createdAt||``),id:String(entry?.id||``),role:String(entry?.role||``),...status===void 0?{}:{status},text:String(entry?.text||``)}}function explanationEntryVisible(entry){return Boolean(entry.id&&[`assistant`,`user`].includes(entry.role)&&entry.text)}function normalizeExplanationMessages(value=[],{body=``,followups=[]}={}){const messages=(Array.isArray(value)?value:[]).map(entry=>normalizeExplanationEntry(entry,{status:String(entry?.status||`complete`)})).filter(entry=>entry.id&&[`assistant`,`user`].includes(entry.role)&&(entry.text||entry.status!==`complete`));if(messages.length)return messages;const fallback=[];if(String(body||``).trim())fallback.push({createdAt:``,id:`body`,role:`assistant`,status:`complete`,text:String(body||``)});return[...fallback,...(Array.isArray(followups)?followups:[]).map(entry=>normalizeExplanationEntry(entry,{status:`complete`})).filter(explanationEntryVisible)]}function normalizeExplanationExecutionProfile(value=null){try{return vibe64AgentExecutionProfileAuditSnapshot(value)}catch{return null}}function normalizeExplanation(value=null){if(!value||typeof value!==`object`||Array.isArray(value))return null;const sourceRange=value.sourceRange&&typeof value.sourceRange===`object`&&!Array.isArray(value.sourceRange)?value.sourceRange:{};const id=String(value.id||``).trim();if(!id)return null;const followups=(Array.isArray(value.followups)?value.followups:[]).map(entry=>normalizeExplanationEntry(entry)).filter(explanationEntryVisible);return{agentThreadId:String(value.agentThreadId||``),agentTurnId:String(value.agentTurnId||``),body:String(value.body||``),createdAt:String(value.createdAt||``),engine:String(value.engine||``),error:String(value.error||``),executionProfile:normalizeExplanationExecutionProfile(value.executionProfile),followups,id,messages:normalizeExplanationMessages(value.messages,{body:value.body,followups}),model:String(value.model||``),sourceRange:{endColumn:Math.max(1,Number(sourceRange.endColumn||1)),endLine:Math.max(1,Number(sourceRange.endLine||1)),language:String(sourceRange.language||``),path:normalizeSourceEditorPath(sourceRange.path),scope:String(sourceRange.scope||`selection`),...sourceRange.presentation?{presentation:sourceRange.presentation}:{},...sourceRange.fileHash?{fileHash:String(sourceRange.fileHash)}:{},...sourceRange.symbolId?{symbolId:String(sourceRange.symbolId)}:{},startColumn:Math.max(1,Number(sourceRange.startColumn||1)),startLine:Math.max(1,Number(sourceRange.startLine||1))},stale:value.stale===true,staleReason:String(value.staleReason||``),status:String(value.status||``),summary:String(value.summary||``),title:String(value.title||``)}}function normalizeTreeNode(value=null){if(!value||typeof value!==`object`||Array.isArray(value))return null;const type=String(value.type||``);const path=normalizeSourceEditorPath(value.path);if(type===`file`)return{language:String(value.language||``),name:String(value.name||``),path,size:Number(value.size||0),type};if(type!==`directory`)return null;return{children:(Array.isArray(value.children)?value.children:[]).map(child=>normalizeTreeNode(child)).filter(Boolean),hasMore:value.hasMore===true,limit:Math.max(1,Number(value.limit||SOURCE_EDITOR_TREE_PAGE_SIZE)),loaded:value.loaded===true,name:String(value.name||``),nextOffset:Math.max(0,Number(value.nextOffset||0)),offset:Math.max(0,Number(value.offset||0)),path,total:Math.max(0,Number(value.total||0)),truncated:value.truncated===true,type}}function mergeDirectoryChildren(existingChildren=[],pageChildren=[],append=false){const byKey=new Map((existingChildren||[]).map(child=>[treeNodeKey(child),child]));const mergedChildren=pageChildren.map(child=>{const previous=byKey.get(treeNodeKey(child));return child.type===`directory`&&previous?.loaded&&!child.loaded?{...child,...previous,name:child.name}:child});if(!append)return mergedChildren;for(const child of mergedChildren)byKey.set(treeNodeKey(child),child);return[...byKey.values()]}function treeNodeKey(node={}){return normalizeSourceEditorPath(node.path)||String(node.name||``)}function sortTreeNodes(children=[]){return[...children].sort((left,right)=>{if(left?.type!==right?.type)return left?.type===`directory`?-1:1;return String(left?.name||``).localeCompare(String(right?.name||``))})}function mergeDirectoryPage(root=null,directoryPath=``,page=null,append=false){const normalizedPath=normalizeSourceEditorPath(directoryPath);const normalizedPage=normalizeTreeNode(page);if(!normalizedPage)return root;if(!normalizedPath)return{...normalizedPage,children:mergeDirectoryChildren(root?.children,normalizedPage.children,append)};function visit(node=null){if(!node||node.type!==`directory`)return node;if(normalizeSourceEditorPath(node.path)===normalizedPath)return{...node,...normalizedPage,children:mergeDirectoryChildren(node.children,normalizedPage.children,append)};return{...node,children:(Array.isArray(node.children)?node.children:[]).map(child=>visit(child))}}return visit(root)}function mergeRevealedTreeNode(existing=null,reveal=null){const normalizedReveal=normalizeTreeNode(reveal);if(!normalizedReveal)return normalizeTreeNode(existing);const normalizedExisting=normalizeTreeNode(existing);if(!normalizedExisting||treeNodeKey(normalizedExisting)!==treeNodeKey(normalizedReveal))return normalizedReveal;if(normalizedExisting.type!==`directory`||normalizedReveal.type!==`directory`)return normalizedExisting;const childrenByKey=new Map((normalizedExisting.children||[]).map(child=>[treeNodeKey(child),child]));for(const child of normalizedReveal.children||[]){const key=treeNodeKey(child);childrenByKey.set(key,mergeRevealedTreeNode(childrenByKey.get(key),child))}return{...normalizedExisting,children:sortTreeNodes([...childrenByKey.values()])}}function mergeRevealTree(root=null,revealTree=null){const normalizedReveal=normalizeTreeNode(revealTree);if(!normalizedReveal)return root;return mergeRevealedTreeNode(root,normalizedReveal)}function findTreeDirectory(root=null,directoryPath=``){const normalizedPath=normalizeSourceEditorPath(directoryPath);if(!root||root.type!==`directory`)return null;if(normalizeSourceEditorPath(root.path)===normalizedPath)return root;for(const child of Array.isArray(root.children)?root.children:[]){const found=findTreeDirectory(child,normalizedPath);if(found)return found}return null}function loadedFileAncestorDirectoryPaths(root=null,filePath=``,ancestors=[]){const normalizedFilePath=normalizeSourceEditorPath(filePath);if(!root||!normalizedFilePath)return null;if(root.type===`file`)return normalizeSourceEditorPath(root.path)===normalizedFilePath?ancestors:null;if(root.type!==`directory`)return null;const normalizedDirectoryPath=normalizeSourceEditorPath(root.path);const childAncestors=normalizedDirectoryPath?[...ancestors,normalizedDirectoryPath]:ancestors;for(const child of Array.isArray(root.children)?root.children:[]){const found=loadedFileAncestorDirectoryPaths(child,normalizedFilePath,childAncestors);if(found)return found}return null}function loadedTreeDirectoryPaths(root=null){const paths=[];function visit(node=null){if(!node||node.type!==`directory`)return;const normalizedPath=normalizeSourceEditorPath(node.path);if(normalizedPath&&node.loaded===true)paths.push(normalizedPath);for(const child of Array.isArray(node.children)?node.children:[])visit(child)}visit(root);return[...new Set(paths)].sort((left,right)=>{return left.split(`/`).length-right.split(`/`).length||left.localeCompare(right)})}async function sourceEditorRequest(url=``,options={}){const payload=await getHttpWebClient().request(url,options);if(payload?.ok===false)throw vibe64ApiError(payload,`Source editor request failed.`);return payload}function sourceEditorClientId(prefix=`id`){sourceExplanationClientIdCounter+=1;return`${prefix}_${Date.now().toString(36)}_${sourceExplanationClientIdCounter.toString(36)}`}function nowIso(){return new Date().toISOString()}function sourceEditorExplanationPromptText(filePath=``,range={}){return range.scope===`file`?`Explain the whole file ${filePath}.`:`Explain ${filePath}:${range.startLine}-${range.endLine}.`}function sourceEditorExplanationTitle(filePath=``,range={}){const name=normalizeSourceEditorPath(filePath).split(`/`).filter(Boolean).pop()||`Code`;return range.scope===`file`?`${name} full file`:`${name} lines ${range.startLine}-${range.endLine}`}function localSourceExplanation({assistantMessageId=sourceEditorClientId(`msg`),explanationId=sourceEditorClientId(`exp`),filePath=``,range={},userMessageId=sourceEditorClientId(`msg`)}={}){const createdAt=nowIso();const sourceRange={endColumn:Math.max(1,Number(range.endColumn||1)),endLine:Math.max(1,Number(range.endLine||1)),language:String(range.language||``),path:normalizeSourceEditorPath(filePath),scope:String(range.scope||`selection`),...range.presentation?{presentation:range.presentation}:{},...range.symbolId?{symbolId:range.symbolId}:{},startColumn:Math.max(1,Number(range.startColumn||1)),startLine:Math.max(1,Number(range.startLine||1))};return normalizeExplanation({agentThreadId:``,agentTurnId:``,body:``,createdAt,engine:`agent-chat`,error:``,executionProfile:null,followups:[],id:explanationId,messages:[{createdAt,id:userMessageId,role:`user`,status:`complete`,text:sourceEditorExplanationPromptText(filePath,sourceRange)},{createdAt,id:assistantMessageId,role:`assistant`,status:`thinking`,text:``}],model:``,sourceRange,status:`running`,summary:``,title:sourceEditorExplanationTitle(filePath,sourceRange)})}function sourceEditorExplanationWithMessage(explanation=null,messageId=``,patch={}){const normalized=normalizeExplanation(explanation);if(!normalized)return null;const messages=normalizeExplanationMessages(normalized.messages);const index=messages.findIndex(message=>message.id===messageId);if(index===-1)return normalized;const nextMessages=[...messages];nextMessages[index]={...nextMessages[index],...patch};return{...normalized,messages:normalizeExplanationMessages(nextMessages)}}function appendSourceEditorExplanationMessages(explanation=null,messages=[]){const normalized=normalizeExplanation(explanation);if(!normalized)return null;return{...normalized,messages:normalizeExplanationMessages([...normalized.messages,...messages])}}function useVibe64SourceEditor({active=true,agentActive=false,navigateReferencedSource=null,projectSlug,readCurrentText=null,sessionsApiPath,sessionId}={}){const originId=vibe64BrowserTabOriginId();const explanationFeedback=useUiFeedback({source:`vibe64.source-editor.explanation.feedback`});const tree=ref(null);const policy=ref({});const selectedPath=ref(``);const text=ref(``);const savedHash=ref(``);const interpretations=ref([]);const interpretationWarning=ref(``);const dirty=ref(false);const treeLoadingPaths=ref([]);const treeLoadErrors=ref({});const fileQuery=ref(``);const fileMatches=ref([]);const fileMatchesError=ref(``);const fileMatchesLoading=ref(false);const fileMatchesTruncated=ref(false);const searchQuery=ref(``);const searchResults=ref([]);const searchError=ref(``);const searchLoading=ref(false);const searchTruncated=ref(false);const searchIndex=ref(null);const searchIndexPending=computed(()=>[`building`,`refreshing`].includes(searchIndex.value?.state));const searchIndexLabel=computed(()=>{const index=searchIndex.value;if(index?.state===`error`)return index.error||`The search index could not be updated. Use Refresh to retry.`;if(!searchIndexPending.value)return``;const action=index.state===`refreshing`?`Refreshing file index`:`Indexing files`;return index.total?`${action}: ${index.scanned} of ${index.total} files…`:`${action}…`});const activeExplanation=ref(null);const explanationError=ref(``);const explanationBusy=ref(false);const explanationClosing=ref(false);const explanationFollowup=ref(``);const loadFailure=ref(null);const loadError=computed(()=>loadFailure.value?.message||``);const downloadOnlyFile=ref(null);const saveError=ref(``);const createFileError=ref(``);const creatingFile=ref(false);const loadingTree=ref(false);const loadingFile=ref(false);const loadingPath=ref(``);const saving=ref(false);const loadedVersion=ref(0);const cursorRequest=ref(null);const revealedDirectoryPaths=ref([]);const selectedRevealTree=ref(null);let treeRequestId=0;const treeDirectoryRequestIds=new Map;let createFileRequestId=0;let fileRequestId=0;let fileRevalidationRequestId=0;let fileMatchesRequestId=0;let searchRequestId=0;let explanationRequestId=0;let explanationAbortController=null;let autosaveTimer=null;let fileMatchesTimer=null;let searchTimer=null;let pendingFileRevalidation=false;let pendingTreeRefresh=false;let refreshPromise=null;let savePromise=null;let textAtUnmount=null;let disposed=false;const currentSessionsApiPath=computed(()=>String(readRefOrGetterValue(sessionsApiPath)||``).trim());const currentSessionId=computed(()=>String(readRefOrGetterValue(sessionId)||``).trim());const currentProjectSlug=computed(()=>String(readRefOrGetterValue(projectSlug)||``).trim());const reportActivity=usePageActivity();const currentActive=computed(()=>readRefOrGetterValue(active)!==false);const canLoad=computed(()=>Boolean(currentSessionsApiPath.value&¤tSessionId.value));const statusLabel=computed(()=>{if(saveError.value)return saveError.value;if(loadingFile.value)return`Opening...`;if(saving.value)return`Saving...`;if(dirty.value)return`Unsaved`;return selectedPath.value?`Saved`:``});useRealtimeEvent({enabled:computed(()=>Boolean(canLoad.value&¤tProjectSlug.value)),event:VIBE64_SOURCE_EDITOR_FILE_CHANGED_EVENT,matches:({payload={}}={})=>payload.operation===`created`&&payload.originId!==originId&&payload.projectSlug===currentProjectSlug.value&&payload.sessionId===currentSessionId.value||sourceEditorFileChangePayloadMatches({originId,path:selectedPath.value,payload,projectSlug:currentProjectSlug.value,sessionId:currentSessionId.value}),onEvent:({payload={}}={})=>{applyRemoteFileChange(payload);if(payload.operation===`created`){if(currentActive.value)loadTree();else pendingTreeRefresh=true}}});useVibe64SourceEditorFileSync({active:computed(()=>canLoad.value&¤tActive.value),onChange:(payload={})=>{applyObservedFileChange(payload)},onError:(error={})=>{vibe64SessionDebugLog(`client.sourceEditor.fileSync.error`,{error:String(error.error||`Source file observation failed.`),path:selectedPath.value,sessionId:currentSessionId.value,transient:error.transient===true})},onReady:()=>{revalidateSelectedFile()},path:selectedPath,sessionId:currentSessionId,sessionsApiPath:currentSessionsApiPath});function clearAutosave(){if(autosaveTimer){clearTimeout(autosaveTimer);autosaveTimer=null}}function clearFileMatchesTimer(){if(fileMatchesTimer){clearTimeout(fileMatchesTimer);fileMatchesTimer=null}}function clearSearchTimer(){if(searchTimer){clearTimeout(searchTimer);searchTimer=null}}function clearFileMatches(){fileMatchesRequestId+=1;fileMatches.value=[];fileMatchesError.value=``;fileMatchesLoading.value=false;fileMatchesTruncated.value=false}function clearSearchResults(){searchRequestId+=1;searchResults.value=[];searchError.value=``;searchLoading.value=false;searchTruncated.value=false;searchIndex.value=null}function resetDiscoveryState(){clearFileMatchesTimer();clearSearchTimer();fileQuery.value=``;searchQuery.value=``;clearFileMatches();clearSearchResults()}function treePathKey(value=``){return normalizeSourceEditorPath(value)}function setTreePathLoading(path=``,loading=false){const key=treePathKey(path);const current=new Set(treeLoadingPaths.value);if(loading)current.add(key);else current.delete(key);treeLoadingPaths.value=[...current].sort((left,right)=>left.localeCompare(right))}function setTreePathError(path=``,message=``){const key=treePathKey(path);const next={...treeLoadErrors.value};if(message)next[key]=message;else delete next[key];treeLoadErrors.value=next}async function loadDirectoryPage(directoryPath=``,{applyPage=true,append=false,offset=0}={}){const normalizedPath=treePathKey(directoryPath);if(!canLoad.value||disposed)return null;const treeGeneration=treeRequestId;const requestKey=normalizedPath;const requestId=(treeDirectoryRequestIds.get(requestKey)||0)+1;treeDirectoryRequestIds.set(requestKey,requestId);setTreePathLoading(normalizedPath,true);setTreePathError(normalizedPath,``);if(!normalizedPath&&!append){loadingTree.value=true;loadFailure.value=null}try{const response=await sourceEditorRequest(vibe64SourceEditorTreePath(currentSessionsApiPath.value,currentSessionId.value,{limit:SOURCE_EDITOR_TREE_PAGE_SIZE,offset,path:normalizedPath}));if(treeGeneration!==treeRequestId||treeDirectoryRequestIds.get(requestKey)!==requestId)return null;if(!normalizedPath)policy.value=normalizeSourceEditorPolicy(response.policy||{});const page=normalizeTreeNode(response.tree);if(applyPage){tree.value=mergeDirectoryPage(tree.value,normalizedPath,page,append);if(selectedRevealTree.value)tree.value=mergeRevealTree(tree.value,selectedRevealTree.value)}if(applyPage)revealLoadedFilePath(selectedPath.value);return page}catch(error){if(treeGeneration===treeRequestId&&treeDirectoryRequestIds.get(requestKey)===requestId){const message=String(error?.message||error||`Source tree could not be loaded.`);setTreePathError(normalizedPath,message);if(!normalizedPath)loadFailure.value={operation:`tree`,message}}return null}finally{if(treeGeneration===treeRequestId&&treeDirectoryRequestIds.get(requestKey)===requestId){setTreePathLoading(normalizedPath,false);if(!normalizedPath&&applyPage)loadingTree.value=false}}}function revealLoadedFilePath(filePath=``){const ancestors=loadedFileAncestorDirectoryPaths(tree.value,filePath);if(ancestors)revealedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths(ancestors)}async function loadTree({preserveLoadedDirectories=true}={}){const refreshingLoadedTree=preserveLoadedDirectories&&Boolean(tree.value);const directoriesToReload=preserveLoadedDirectories?loadedTreeDirectoryPaths(tree.value):[];const loadedCounts=new Map([``,...directoriesToReload].map(directoryPath=>[directoryPath,findTreeDirectory(tree.value,directoryPath)?.children?.length||0]));const requestId=treeRequestId+1;treeRequestId=requestId;if(!preserveLoadedDirectories){tree.value=null;policy.value=normalizeSourceEditorPolicy({});revealedDirectoryPaths.value=[]}treeDirectoryRequestIds.clear();treeLoadingPaths.value=[];treeLoadErrors.value={};loadFailure.value=null;if(!canLoad.value)return;loadingTree.value=true;let refreshedTree=tree.value;for(const directoryPath of[``,...directoriesToReload]){if(requestId!==treeRequestId)return;if(directoryPath&&!findTreeDirectory(refreshedTree,directoryPath))continue;let offset=0;do{if(disposed||refreshingLoadedTree&&!currentActive.value){pendingTreeRefresh=!disposed;loadingTree.value=false;return}const page=await loadDirectoryPage(directoryPath,{applyPage:false,append:offset>0,offset});if(requestId!==treeRequestId)return;if(page)refreshedTree=mergeDirectoryPage(refreshedTree,directoryPath,page,offset>0);if(!page?.hasMore||!page.nextOffset||page.nextOffset<=offset)break;offset=page.nextOffset}while(offset<loadedCounts.get(directoryPath))}tree.value=refreshedTree;loadingTree.value=false;if(selectedRevealTree.value){tree.value=mergeRevealTree(tree.value,selectedRevealTree.value);revealLoadedFilePath(selectedPath.value)}}function loadDirectory(directoryPath=``){const normalizedPath=treePathKey(directoryPath);if(findTreeDirectory(tree.value,normalizedPath)?.loaded===true)return;loadDirectoryPage(normalizedPath,{append:false,offset:0})}function loadMoreDirectory(directoryPath=``){const normalizedPath=treePathKey(directoryPath);const directory=findTreeDirectory(tree.value,normalizedPath);if(!directory?.hasMore)return;loadDirectoryPage(normalizedPath,{append:true,offset:directory.nextOffset||directory.children?.length||0})}function applyFileResponse(response={},{column=0,fallbackPath=``,line=0,reveal=true}={}){const file=response.file||{};const filePath=normalizeSourceEditorPath(file.path||fallbackPath);if(!filePath)return false;selectedPath.value=filePath;downloadOnlyFile.value=null;selectedRevealTree.value=normalizeTreeNode(response.revealTree);if(selectedRevealTree.value)tree.value=mergeRevealTree(tree.value,selectedRevealTree.value);text.value=String(file.text||``);savedHash.value=String(file.hash||``);applySavedInterpretations(response,filePath);dirty.value=false;if(reveal)revealLoadedFilePath(filePath);cursorRequest.value={column:Number(column||0)||0,line:Number(line||0)||0,path:filePath,version:loadedVersion.value+1};loadedVersion.value+=1;return true}function applySavedInterpretations(response,filePath){interpretations.value=(response.interpretations?.records||[]).filter(record=>record.path===filePath&&[`file`,`selection`].includes(record.scope)&&[`description`,`steps`].includes(record.presentation)&&typeof record.body===`string`&&[`current`,`stale`].includes(record.status));interpretationWarning.value=String(response.interpretations?.warning||``)}async function openFile(filePath=``,options={}){const normalizedPath=normalizeSourceEditorPath(filePath);if(!normalizedPath||!canLoad.value)return false;if((dirty.value||saving.value)&&!await saveNow())return false;const requestId=fileRequestId+1;fileRequestId=requestId;fileRevalidationRequestId+=1;loadFailure.value=null;saveError.value=``;loadingFile.value=true;loadingPath.value=normalizedPath;try{const response=await sourceEditorRequest(vibe64SourceEditorFilePath(currentSessionsApiPath.value,currentSessionId.value,normalizedPath));if(requestId!==fileRequestId)return false;if(!applyFileResponse(response,{column:options.column,fallbackPath:normalizedPath,line:options.line}))return false;reportActivity(`file-opened`,{projectSlug:currentProjectSlug.value,sessionId:currentSessionId.value,path:normalizedPath});return true}catch(error){if(requestId===fileRequestId){const code=error?.code;if(code===`vibe64_source_editor_binary_file`||code===`vibe64_source_editor_file_too_large`){selectedPath.value=``;selectedRevealTree.value=null;text.value=``;savedHash.value=``;downloadOnlyFile.value={path:normalizedPath,message:code===`vibe64_source_editor_binary_file`?`This file cannot be edited as text. Download it to open it in another application.`:`This file is too large to edit here. You can download the complete file.`};revealLoadedFilePath(normalizedPath);return true}loadFailure.value={operation:`open-file`,message:String(error?.message||error||`Source file could not be loaded.`)}}return false}finally{if(requestId===fileRequestId){loadingFile.value=false;loadingPath.value=``}}}async function createFile(filePath=``){const normalizedPath=normalizeSourceEditorPath(filePath);if(!normalizedPath||!canLoad.value||creatingFile.value)return false;if((dirty.value||saving.value)&&!await saveNow())return false;const createRequestId=createFileRequestId+1;createFileRequestId=createRequestId;const fileSelectionRequestId=fileRequestId+1;fileRequestId=fileSelectionRequestId;fileRevalidationRequestId+=1;createFileError.value=``;loadFailure.value=null;saveError.value=``;creatingFile.value=true;try{const response=await sourceEditorRequest(vibe64SourceEditorCreateFilePath(currentSessionsApiPath.value,currentSessionId.value),{body:{originId,path:normalizedPath,projectSlug:currentProjectSlug.value},method:`POST`});if(fileSelectionRequestId!==fileRequestId)return false;if(!applyFileResponse(response,{fallbackPath:normalizedPath}))return false;return true}catch(error){if(fileSelectionRequestId===fileRequestId)createFileError.value=String(error?.message||error||`Source file could not be created.`);return false}finally{if(createRequestId===createFileRequestId)creatingFile.value=false}}async function revalidateSelectedFile(){const pathAtRequest=selectedPath.value;const sessionIdAtRequest=currentSessionId.value;if(disposed||!pathAtRequest||!canLoad.value||!currentActive.value)return false;if(saving.value){pendingFileRevalidation=true;return false}const requestId=fileRevalidationRequestId+1;fileRevalidationRequestId=requestId;try{const response=await sourceEditorRequest(vibe64SourceEditorFilePath(currentSessionsApiPath.value,sessionIdAtRequest,pathAtRequest));if(requestId!==fileRevalidationRequestId||selectedPath.value!==pathAtRequest||currentSessionId.value!==sessionIdAtRequest)return false;if(loadFailure.value?.operation===`revalidation`)loadFailure.value=null;selectedRevealTree.value=normalizeTreeNode(response.revealTree);if(selectedRevealTree.value)tree.value=mergeRevealTree(tree.value,selectedRevealTree.value);const nextHash=String(response.file?.hash||``);applySavedInterpretations(response,pathAtRequest);if(dirty.value||saving.value){if(nextHash&&nextHash!==savedHash.value)saveError.value=SOURCE_EDITOR_REMOTE_CHANGE_MESSAGE;else if(saveError.value===`This file changed in another window. Reload it before saving.`)saveError.value=``;return false}if(!nextHash||nextHash===savedHash.value)return false;return applyFileResponse(response,{fallbackPath:pathAtRequest,reveal:false})}catch(error){if(requestId===fileRevalidationRequestId&&selectedPath.value===pathAtRequest&¤tSessionId.value===sessionIdAtRequest)loadFailure.value={operation:`revalidation`,message:String(error?.message||error||`Source file could not be refreshed.`)};return false}}async function applySelectedFileChange({hash=``,path=``}={}){const changedPath=normalizeSourceEditorPath(path);const changedHash=normalizeSourceEditorSyncValue(hash);if(!changedPath||changedPath!==selectedPath.value||changedHash&&changedHash===savedHash.value)return;if(saving.value){pendingFileRevalidation=true;return}if(dirty.value&&changedHash){saveError.value=SOURCE_EDITOR_REMOTE_CHANGE_MESSAGE;return}await revalidateSelectedFile()}async function applyRemoteFileChange(payload={}){if(!sourceEditorFileChangePayloadMatches({originId,path:selectedPath.value,payload,projectSlug:currentProjectSlug.value,sessionId:currentSessionId.value}))return;await applySelectedFileChange(payload)}async function applyObservedFileChange(payload={}){if(normalizeSourceEditorSyncValue(payload.sessionId)!==currentSessionId.value||normalizeSourceEditorPath(payload.path)!==selectedPath.value)return;await applySelectedFileChange(payload)}function cleanupAbandonedExplanations(){if(!canLoad.value)return;const activeExplanationIds=activeExplanation.value?.id?[activeExplanation.value.id]:[];sourceEditorRequest(vibe64SourceEditorExplanationsCleanupPath(currentSessionsApiPath.value,currentSessionId.value),{body:{activeExplanationIds,originId},method:`POST`}).catch(error=>{vibe64SessionDebugLog(`client.sourceEditor.explanations.cleanup.error`,{error:vibe64SessionDebugError(error),sessionId:currentSessionId.value})})}async function loadFileMatches(){const query=normalizeEditorQuery(fileQuery.value);if(!query){clearFileMatches();return}const requestId=fileMatchesRequestId+1;fileMatchesRequestId=requestId;fileMatchesError.value=``;if(!canLoad.value)return;fileMatchesLoading.value=true;try{const response=await sourceEditorRequest(vibe64SourceEditorFilesPath(currentSessionsApiPath.value,currentSessionId.value,query));if(requestId!==fileMatchesRequestId)return;fileMatches.value=normalizeFileMatches(response.files);fileMatchesTruncated.value=response.truncated===true}catch(error){if(requestId===fileMatchesRequestId){fileMatches.value=[];fileMatchesError.value=String(error?.message||error||`File matches could not be loaded.`)}}finally{if(requestId===fileMatchesRequestId)fileMatchesLoading.value=false}}function updateFileQuery(value=``){fileQuery.value=String(value||``);clearFileMatchesTimer();if(!normalizeEditorQuery(fileQuery.value)){clearFileMatches();return}fileMatchesTimer=setTimeout(()=>{loadFileMatches()},120)}async function openFileMatch(filePath=``){const normalizedPath=normalizeSourceEditorPath(filePath);if(!normalizedPath)return;clearFileMatchesTimer();fileQuery.value=``;clearFileMatches();await openFile(normalizedPath)}async function openReferencedSourcePath({fromPath=selectedPath.value,target=``}={}){const normalizedFromPath=normalizeSourceEditorPath(fromPath);const normalizedTarget=String(target||``).trim();if(!normalizedFromPath||!normalizedTarget||!canLoad.value)return false;try{const resolved=normalizeResolvedSourceEditorPath(await sourceEditorRequest(vibe64SourceEditorResolvePathPath(currentSessionsApiPath.value,currentSessionId.value),{body:{fromPath:normalizedFromPath,target:normalizedTarget},method:`POST`}));if(!resolved.resolved||!resolved.path)return false;if(typeof navigateReferencedSource===`function`)try{if(await navigateReferencedSource({fromPath:normalizedFromPath,path:resolved.path,target:normalizedTarget})===true)return true}catch{}await openFile(resolved.path);return true}catch{return false}}function openFirstFileMatch(){const firstFile=fileMatches.value[0];if(firstFile?.path)openFileMatch(firstFile.path)}async function loadSearchResults({background=false}={}){clearSearchTimer();if(disposed||!currentActive.value)return;const query=normalizeEditorQuery(searchQuery.value);if(!query){clearSearchResults();return}const requestId=searchRequestId+1;searchRequestId=requestId;searchError.value=``;if(!canLoad.value)return;searchLoading.value=!background;try{const response=await sourceEditorRequest(vibe64SourceEditorSearchPath(currentSessionsApiPath.value,currentSessionId.value,query));if(requestId!==searchRequestId)return;searchResults.value=normalizeSearchResults(response.results);searchTruncated.value=response.truncated===true;searchIndex.value=response.index||null;if(searchIndexPending.value&¤tActive.value&&!disposed)searchTimer=setTimeout(()=>{loadSearchResults({background:true})},1e3)}catch(error){if(requestId===searchRequestId){searchResults.value=[];searchIndex.value=null;searchError.value=String(error?.message||error||`Search results could not be loaded.`)}}finally{if(requestId===searchRequestId)searchLoading.value=false}}function clearExplanationStream(){explanationRequestId+=1;explanationAbortController?.abort?.();explanationAbortController=null;explanationBusy.value=false}function markActiveExplanationMessage(status=``,text=``){const explanation=activeExplanation.value;const lastAssistant=[...explanation?.messages||[]].reverse().find(message=>message.role===`assistant`);if(!lastAssistant?.id)return;const nextExplanation=sourceEditorExplanationWithMessage(explanation,lastAssistant.id,{status,text:text||lastAssistant.text});activeExplanation.value=status===`failed`?{...nextExplanation,error:text||nextExplanation?.error||`Source explanation failed.`,status:`failed`}:nextExplanation}function applyExplanationStreamEvent(event={},requestId=explanationRequestId){if(requestId!==explanationRequestId)return;if(event.type===`source-explanation.error`||event.ok===false){const message=vibe64ApiResponseError(event,`Source explanation failed.`);explanationError.value=message;markActiveExplanationMessage(`failed`,message);throw new Error(message)}const eventExplanation=normalizeExplanation(event.explanation);if(event.type===`source-explanation.failed`){const message=vibe64ApiResponseError(event,`Source explanation failed.`);explanationError.value=message;if(eventExplanation)activeExplanation.value=eventExplanation;else markActiveExplanationMessage(`failed`,message);return}if(event.type===`source-explanation.started`||event.type===`source-explanation.followup.started`){if(eventExplanation)activeExplanation.value=eventExplanation;return}if(event.type===`source-explanation.thread`||event.type===`source-explanation.turn`){if(!activeExplanation.value)return;activeExplanation.value={...activeExplanation.value,agentThreadId:String(event.threadId||activeExplanation.value.agentThreadId||``),agentTurnId:String(event.turnId||activeExplanation.value.agentTurnId||``)};return}if(event.type===`source-explanation.execution-profile`&&eventExplanation){activeExplanation.value=eventExplanation;return}if(event.type===`source-explanation.message`&&event.messageId){activeExplanation.value=sourceEditorExplanationWithMessage(activeExplanation.value,String(event.messageId),{status:String(event.status||`thinking`),text:String(event.text||``)});return}if(event.type===`source-explanation.finished`&&eventExplanation){activeExplanation.value=eventExplanation;const range=eventExplanation.sourceRange;if(eventExplanation.status===`ready`&&range.presentation&&(range.scope===`file`||range.symbolId)&&!eventExplanation.followups.length&&range.path===selectedPath.value){const record={path:range.path,scope:range.scope,symbolId:range.symbolId||``,presentation:range.presentation,fileHash:range.fileHash,body:eventExplanation.body,summary:eventExplanation.summary,createdAt:eventExplanation.createdAt,status:range.fileHash===savedHash.value?`current`:`stale`};interpretations.value=[...interpretations.value.filter(previous=>!(previous.scope===record.scope&&previous.symbolId===record.symbolId&&previous.presentation===record.presentation)),record]}if(eventExplanation.status!==`failed`)explanationError.value=``}}async function streamSourceEditorRequest(url=``,body={},requestId=explanationRequestId){const controller=new AbortController;explanationAbortController=controller;await getHttpWebClient().requestStream(url,{body,method:`POST`,signal:controller.signal},{onEvent(event){applyExplanationStreamEvent(event,requestId)}})}async function explainSelection(range={}){if(!selectedPath.value||!canLoad.value||explanationBusy.value||explanationClosing.value)return;const requestId=explanationRequestId+1;explanationRequestId=requestId;explanationAbortController?.abort?.();explanationAbortController=null;const explanationId=sourceEditorClientId(`exp`);const userMessageId=sourceEditorClientId(`msg`);const assistantMessageId=sourceEditorClientId(`msg`);const previousExplanation=activeExplanation.value;activeExplanation.value=localSourceExplanation({assistantMessageId,explanationId,filePath:selectedPath.value,range,userMessageId});explanationBusy.value=true;explanationError.value=``;explanationFollowup.value=``;if(previousExplanation?.id)disposeExplanation(previousExplanation).catch(()=>null);try{await streamSourceEditorRequest(vibe64SourceEditorExplanationsStreamPath(currentSessionsApiPath.value,currentSessionId.value),{assistantMessageId,endColumn:range.endColumn,endLine:range.endLine,explanationId,force:range.force===true,presentation:range.presentation,symbolId:range.symbolId,expectedHash:range.expectedHash,originId,path:selectedPath.value,scope:range.scope,startColumn:range.startColumn,startLine:range.startLine,userMessageId},requestId)}catch(error){if(String(error?.name||``)===`AbortError`)return;if(requestId===explanationRequestId){const message=String(error?.message||error||`Source explanation could not be created.`);explanationError.value=message;markActiveExplanationMessage(`failed`,message)}}finally{if(requestId===explanationRequestId){explanationBusy.value=false;explanationAbortController=null}}}async function retryExplanation(){const range=activeExplanation.value?.sourceRange||{};const explanationPath=normalizeSourceEditorPath(range.path);if(!explanationPath||explanationBusy.value||explanationClosing.value)return;if(selectedPath.value!==explanationPath){await openFile(explanationPath);if(selectedPath.value!==explanationPath)return}await explainSelection({...range,...range.presentation&&range.fileHash?{expectedHash:range.fileHash}:{},force:true})}async function stopExplanation(){const explanation=activeExplanation.value;if(!explanation?.id||explanationClosing.value)return;const requestId=explanationRequestId+1;explanationRequestId=requestId;const controller=explanationAbortController;explanationAbortController=null;explanationBusy.value=false;explanationError.value=``;markActiveExplanationMessage(`stopped`,`Stopped.`);controller?.abort?.();if(!canLoad.value)return;try{const response=await sourceEditorRequest(vibe64SourceEditorExplanationStopPath(currentSessionsApiPath.value,currentSessionId.value,explanation.id),{method:`POST`});if(requestId!==explanationRequestId||activeExplanation.value?.id!==explanation.id)return;const stoppedExplanation=normalizeExplanation(response.explanation);if(stoppedExplanation)activeExplanation.value=stoppedExplanation}catch(error){if(requestId===explanationRequestId&&activeExplanation.value?.id===explanation.id)explanationFeedback.error(error,`Source explanation could not be stopped.`)}}async function disposeExplanation(explanation=null,{onError=null,sessionsApiPath:apiPath=currentSessionsApiPath.value,sessionId:targetSessionId=currentSessionId.value}={}){const id=String(explanation?.id||``).trim();if(!id||!apiPath||!targetSessionId)return true;try{await sourceEditorRequest(vibe64SourceEditorExplanationPath(apiPath,targetSessionId,id),{method:`DELETE`});return true}catch(error){vibe64SessionDebugLog(`client.sourceEditor.explanations.cleanup.error`,{error:vibe64SessionDebugError(error),sessionId:targetSessionId});onError?.(error);return false}}async function disposeActiveExplanation(options={}){const explanation=activeExplanation.value;if(!explanation)return true;const requestId=explanationRequestId;const disposed=await disposeExplanation(explanation,options);if(disposed&&requestId===explanationRequestId&&activeExplanation.value?.id===explanation.id){activeExplanation.value=null;explanationFollowup.value=``}return disposed}async function closeExplanation(){const explanation=activeExplanation.value;if(!explanation?.id||explanationClosing.value)return false;clearExplanationStream();const requestId=explanationRequestId;explanationClosing.value=true;explanationError.value=``;try{return await disposeActiveExplanation({onError(error){if(requestId===explanationRequestId&&activeExplanation.value?.id===explanation.id)explanationFeedback.error(error,`Source explanation cleanup failed. Close it again to retry.`)}})&&requestId===explanationRequestId}finally{if(requestId===explanationRequestId)explanationClosing.value=false}}function updateExplanationFollowup(value=``){explanationFollowup.value=String(value||``)}async function sendExplanationFollowup(){const message=explanationFollowup.value.trim();const explanationId=activeExplanation.value?.id||``;if(!message||!explanationId||!canLoad.value||explanationBusy.value||explanationClosing.value)return;const requestId=explanationRequestId+1;explanationRequestId=requestId;explanationAbortController?.abort?.();explanationAbortController=null;const createdAt=nowIso();const userMessageId=sourceEditorClientId(`msg`);const assistantMessageId=sourceEditorClientId(`msg`);activeExplanation.value=appendSourceEditorExplanationMessages(activeExplanation.value,[{createdAt,id:userMessageId,role:`user`,status:`complete`,text:message},{createdAt,id:assistantMessageId,role:`assistant`,status:`thinking`,text:``}]);explanationBusy.value=true;explanationError.value=``;explanationFollowup.value=``;try{await streamSourceEditorRequest(vibe64SourceEditorExplanationFollowupsStreamPath(currentSessionsApiPath.value,currentSessionId.value,explanationId),{assistantMessageId,message,userMessageId},requestId)}catch(error){if(String(error?.name||``)===`AbortError`)return;if(requestId===explanationRequestId){const errorMessage=String(error?.message||error||`Source explanation follow-up could not be sent.`);explanationError.value=errorMessage;markActiveExplanationMessage(`failed`,errorMessage)}}finally{if(requestId===explanationRequestId){explanationBusy.value=false;explanationAbortController=null}}}function updateSearchQuery(value=``){searchQuery.value=String(value||``);clearSearchTimer();clearSearchResults();if(!normalizeEditorQuery(searchQuery.value))return;searchTimer=setTimeout(()=>{loadSearchResults()},260)}function openSearchResult(result={}){const filePath=normalizeSourceEditorPath(result.path);if(!filePath)return;openFile(filePath,{column:result.column,line:result.line})}function scheduleSave(){clearAutosave();if(!selectedPath.value||!dirty.value)return;autosaveTimer=setTimeout(()=>{saveNow()},700)}function updateText(){dirty.value=true;saveError.value=``;scheduleSave()}function currentText(){if(textAtUnmount!==null)return textAtUnmount;return typeof readCurrentText===`function`?String(readCurrentText()??``):text.value}async function saveDirtyBuffers(){while(selectedPath.value&&dirty.value){const pathAtSave=selectedPath.value;const textAtSave=currentText();const baseHashAtSave=savedHash.value;saving.value=true;saveError.value=``;try{const response=await sourceEditorRequest(vibe64SourceEditorFilePath(currentSessionsApiPath.value,currentSessionId.value),{body:{baseHash:baseHashAtSave,originId,path:pathAtSave,projectSlug:currentProjectSlug.value,text:textAtSave},method:`PUT`});if(selectedPath.value===pathAtSave){savedHash.value=String(response.file?.hash||``);text.value=textAtSave;dirty.value=currentText()!==textAtSave}}catch(error){if(selectedPath.value===pathAtSave)saveError.value=String(error?.message||error||`Source file could not be saved.`);return false}finally{saving.value=false}}if(pendingFileRevalidation){pendingFileRevalidation=false;revalidateSelectedFile()}return!dirty.value}function saveNow(){clearAutosave();if(savePromise)return savePromise;savePromise=saveDirtyBuffers().finally(()=>{savePromise=null});return savePromise}function openRequest(request={}){const filePath=normalizeSourceEditorPath(request.path);if(!filePath)return;openFile(filePath,{column:request.column,line:request.line})}function refresh(){if(refreshPromise){pendingTreeRefresh=true;return refreshPromise}refreshPromise=(async()=>{do{pendingTreeRefresh=false;selectedRevealTree.value=null;await loadTree();await revalidateSelectedFile();if(searchQuery.value&¤tActive.value)await loadSearchResults({background:true})}while(pendingTreeRefresh&¤tActive.value)})().finally(()=>{refreshPromise=null});return refreshPromise}watch([currentSessionId,()=>Boolean(readRefOrGetterValue(agentActive))],([id,working],previous=[])=>{if(id!==previous[0]||!previous[1]||working)return;if(currentActive.value)refresh();else pendingTreeRefresh=true});if(typeof window!==`undefined`)window.addEventListener(`focus`,revalidateSelectedFile);watch([currentSessionsApiPath,currentSessionId,currentActive],async(current,previous=[])=>{if(current[0]===previous[0]&¤t[1]===previous[1]){if(!current[2]){clearSearchTimer();searchRequestId+=1;searchLoading.value=false}else if(searchQuery.value&&!pendingTreeRefresh)loadSearchResults({background:true});if(current[2]&&pendingTreeRefresh)await refresh();return}pendingTreeRefresh=false;const closePending=explanationClosing.value;clearExplanationStream();explanationClosing.value=false;if(activeExplanation.value&&!closePending)disposeActiveExplanation({sessionsApiPath:previous[0]||currentSessionsApiPath.value,sessionId:previous[1]||currentSessionId.value});resetDiscoveryState();fileRequestId+=1;loadingFile.value=false;loadingPath.value=``;fileRevalidationRequestId+=1;pendingFileRevalidation=false;selectedPath.value=``;downloadOnlyFile.value=null;selectedRevealTree.value=null;text.value=``;savedHash.value=``;interpretations.value=[];interpretationWarning.value=``;dirty.value=false;activeExplanation.value=null;explanationFollowup.value=``;await loadTree({preserveLoadedDirectories:false});cleanupAbandonedExplanations()},{immediate:true});onBeforeUnmount(()=>{disposed=true;treeRequestId+=1;fileRequestId+=1;fileRevalidationRequestId+=1;textAtUnmount=currentText();const closePending=explanationClosing.value;clearExplanationStream();explanationClosing.value=false;clearAutosave();clearFileMatchesTimer();clearSearchTimer();searchRequestId+=1;if(typeof window!==`undefined`)window.removeEventListener(`focus`,revalidateSelectedFile);if(!closePending)disposeActiveExplanation();saveNow()});return{activeExplanation,closeExplanation,createFile,createFileError,creatingFile,cursorRequest,dirty,downloadOnlyFile,explanationBusy,explanationClosing,explanationError,explanationFollowup,explainSelection,fileMatches,fileMatchesError,fileMatchesLoading,fileMatchesTruncated,fileQuery,loadError,loadedVersion,loadDirectory,loadMoreDirectory,loadingFile,loadingPath,loadingTree,openFile,openFileMatch,openFirstFileMatch,openReferencedSourcePath,openRequest,openSearchResult,policy,refresh,retryExplanation,revealedDirectoryPaths,saveError,saveNow,savedHash,interpretations,interpretationWarning,searchError,searchLoading,searchIndex,searchIndexLabel,searchIndexPending,searchQuery,searchResults,searchTruncated,selectedPath,sendExplanationFollowup,saving,stopExplanation,statusLabel,text,tree,treeLoadErrors,treeLoadingPaths,updateExplanationFollowup,updateFileQuery,updateSearchQuery,updateText}}var SOURCE_EDITOR_DIFF_TIMEOUT_MS=100;function sourceEditorDocumentChanges(currentText,nextText){if(currentText===nextText)return[];const parts=diffLines(currentText,nextText,{timeout:SOURCE_EDITOR_DIFF_TIMEOUT_MS});if(!parts)return[{from:0,insert:nextText,to:currentText.length}];const changes=[];let currentPosition=0;let pendingChange=null;for(const part of parts){if(!part.added&&!part.removed){if(pendingChange){changes.push(pendingChange);pendingChange=null}currentPosition+=part.value.length;continue}pendingChange||={from:currentPosition,insert:``,to:currentPosition};if(part.added)pendingChange.insert+=part.value;else{currentPosition+=part.value.length;pendingChange.to=currentPosition}}if(pendingChange)changes.push(pendingChange);return changes}var _hoisted_1$1={key:0,class:`vibe64-source-editor__header`};var _hoisted_2$1={class:`vibe64-source-editor__title`};var _hoisted_3$1=[`title`];var _hoisted_4$1={key:3,class:`vibe64-source-editor__mobile-actions`};var _hoisted_5$1={key:4,class:`vibe64-source-editor__actions`};var _hoisted_6$1={key:1,class:`vibe64-source-editor__tools`};var _hoisted_7$1={class:`vibe64-source-editor__tool`};var _hoisted_8$1={key:0,class:`vibe64-source-editor__matches`};var _hoisted_9$1={key:0,class:`vibe64-source-editor__match-note`};var _hoisted_10$1={key:1,class:`vibe64-source-editor__match-note vibe64-source-editor__match-note--error`};var _hoisted_11$1=[`title`,`onClick`];var _hoisted_12={class:`vibe64-source-editor__match-name`};var _hoisted_13={class:`vibe64-source-editor__match-path`};var _hoisted_14={key:0,class:`vibe64-source-editor__match-note`};var _hoisted_15={key:1,class:`vibe64-source-editor__match-note`};var _hoisted_16={class:`vibe64-source-editor__tool`};var _hoisted_17={class:`vibe64-source-editor__tree-toolbar`};var _hoisted_18={class:`vibe64-source-editor__tree-actions`};var _hoisted_19=[`open`];var _hoisted_20={key:1,class:`vibe64-source-editor__search-results`,"aria-label":`Find results`};var _hoisted_21={class:`vibe64-source-editor__search-heading`};var _hoisted_22={key:1,class:`vibe64-source-editor__notice`};var _hoisted_23={key:2,class:`vibe64-source-editor__notice vibe64-source-editor__notice--error`};var _hoisted_24={key:3,class:`vibe64-source-editor__notice`};var _hoisted_25=[`title`,`onClick`];var _hoisted_26={class:`vibe64-source-editor__search-path`};var _hoisted_27={class:`vibe64-source-editor__search-location`};var _hoisted_28={class:`vibe64-source-editor__search-preview`};var _hoisted_29={key:5,class:`vibe64-source-editor__notice`};var _hoisted_30={key:2,class:`vibe64-source-editor__notice`};var _hoisted_31={key:3,class:`vibe64-source-editor__notice vibe64-source-editor__notice--error`};var _hoisted_32={class:`vibe64-source-editor__main`};var _hoisted_33={key:0,class:`vibe64-source-editor__banner`};var _hoisted_34={key:1,class:`vibe64-source-editor__empty`};var _hoisted_35={class:`mb-4`};var _hoisted_36={key:2,class:`vibe64-source-editor__empty`};var _hoisted_37={key:3,class:`vibe64-source-editor__banner vibe64-source-editor__banner--error`};var _hoisted_38={key:1,class:`vibe64-source-editor__markdown`,"aria-label":`Formatted document`,tabindex:`0`};var _hoisted_39={key:2,class:`vibe64-source-editor__image-preview`,"aria-label":`Image preview`,tabindex:`0`};var _hoisted_40={key:0,class:`pa-4`};var _hoisted_41=[`src`,`alt`];var _hoisted_42=[`aria-label`];var _hoisted_43={class:`vibe64-source-editor__download-status`,role:`status`};var SOURCE_EDITOR_TREE_STATE_STORAGE_KEY=`vibe64:source-editor:tree-state`;var _sfc_main$2={__name:`Vibe64SessionSourceEditor`,props:{singleFile:{type:Boolean,default:false},architectureFacts:{type:Object,default:null},agentActive:{type:Boolean,default:false},fileBookmarks:{type:Object,default:null},active:{default:false,type:Boolean},assistantAvailable:{default:true,type:Boolean},assistantUnavailableMessage:{default:`The selected AI connection is unavailable for this account.`,type:String},codeFocusMode:{default:false,type:Boolean},openRequest:{default:null,type:Object},projectSlug:{default:``,type:String},sessionId:{default:``,type:String},sessionsApiPath:{default:``,type:String},assistantDraftAvailable:{default:false,type:Boolean},navigateReferencedSource:{default:null,type:Function},sourcePathClickWithoutModifier:{default:false,type:Boolean}},emits:[`ask-assistant-about-file`,`open-source-file`,`interface-location`,`open-program`],setup(__props,{emit:__emit}){const props=__props;const emit=__emit;const editorElement=ref(null);let editorView=null;let explanationFocusTimer=null;let renderedEditorPath=``;let resettingEditor=false;let sourceEditorUnmounted=false;const editor=useVibe64SourceEditor({active:()=>props.active,agentActive:()=>props.agentActive,navigateReferencedSource:navigation=>props.navigateReferencedSource?.(navigation),projectSlug:()=>props.projectSlug,readCurrentText:()=>editorView?.state.doc.toString()??``,sessionId:()=>props.sessionId,sessionsApiPath:()=>props.sessionsApiPath});const filePresentation=ref(`interface`);const interfaceSymbolId=ref(``);const symbolPresentation=ref(`description`);const interfaceGraph=props.architectureFacts?null:useVibe64SystemGraph({active:toRef(props,`active`),sessionId:toRef(props,`sessionId`)});const interfaceArchitecture=computed(()=>props.architectureFacts||interfaceGraph?.architecture.value);const interfaceFile=computed(()=>interfaceArchitecture.value?.files?.find(file=>file.path===editor.selectedPath.value));const interfaceCurrent=computed(()=>interfaceFile.value?.hash===`sha256:${editor.savedHash.value}`&&!editor.dirty.value);const interfaceSymbols=computed(()=>(interfaceArchitecture.value?.symbols||[]).filter(symbol=>symbol.fileId===interfaceFile.value?.id&&symbol.visibility===`public`));const interfacePrograms=computed(()=>(interfaceArchitecture.value?.program?.modules||[]).filter(program=>program.sources.includes(editor.selectedPath.value)));const interfaceSymbol=computed(()=>interfaceSymbols.value.find(symbol=>symbol.id===interfaceSymbolId.value));const interfaceSymbolSource=computed(()=>{const symbol=interfaceSymbol.value;if(!symbol?.end||!interfaceCurrent.value)return``;const selected=editor.text.value.split(`
|
|
39
38
|
`).slice(symbol.start.line-1,symbol.end.line);if(!selected.length)return``;selected[selected.length-1]=selected.at(-1).slice(0,symbol.end.column-1);selected[0]=selected[0].slice(symbol.start.column-1);return selected.join(`
|
|
40
39
|
`)});function showWholeFileCode(){filePresentation.value=`code`;nextTick(()=>{editorView?.requestMeasure();editorView?.focus()})}function selectInterfaceSymbol(id){interfaceSymbolId.value=id;symbolPresentation.value=`steps`}function currentInterpretation(scope,symbolId,presentation){return editor.interpretations.value.find(record=>record.path===editor.selectedPath.value&&record.scope===scope&&(record.symbolId||``)===symbolId&&record.presentation===presentation&&record.status===`current`&&record.fileHash===editor.savedHash.value)}const activeInterfaceInterpretation=computed(()=>{const range=editor.activeExplanation.value?.sourceRange;return Boolean(range?.path===editor.selectedPath.value&&range.presentation===symbolPresentation.value&&(range.symbolId||``)===interfaceSymbolId.value&&range.scope===(interfaceSymbolId.value?`selection`:`file`))});const activeFileInterpretation=computed(()=>{const range=editor.activeExplanation.value?.sourceRange;return range?.path===editor.selectedPath.value&&range.scope===`file`&&range.presentation===`description`});function presentFileOverview(force=false){if(!force&¤tInterpretation(`file`,``,`description`))return;if(!editor.selectedPath.value||editor.dirty.value||!props.assistantAvailable||editor.explanationBusy.value||editor.explanationClosing.value)return;const lines=editor.text.value.split(`
|
|
41
|
-
`);editor.explainSelection({scope:`file`,presentation:`description`,force,expectedHash:editor.savedHash.value,startLine:1,startColumn:1,endLine:lines.length,endColumn:lines.at(-1).length+1})}function presentInterfaceSymbol(presentation,force=false){symbolPresentation.value=presentation;const symbol=interfaceSymbol.value;if(presentation!==`steps`||!Array.isArray(symbol?.parameters)||!symbol?.end||!interfaceCurrent.value||!props.assistantAvailable||editor.explanationBusy.value||editor.explanationClosing.value)return;if(!force&¤tInterpretation(`selection`,symbol.id,presentation))return;editor.explainSelection({scope:`selection`,symbolId:symbol.id,presentation,force,expectedHash:editor.savedHash.value,startLine:symbol.start.line,startColumn:symbol.start.column,endLine:symbol.end.line,endColumn:symbol.end.column})}const markdownRenderable=computed(()=>!props.singleFile&&sourceEditorPathIsMarkdown(editor.selectedPath.value));const markdownRenderer=new F({async:false,gfm:true,walkTokens(token){const path=token.type===`image`&&markdownDocumentLinkTarget(editor.selectedPath.value,token.href);if(path)token.href=scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(readRefOrGetterValue(props.sessionsApiPath),props.sessionId,path),props.projectSlug)}});const renderedMarkdownHtml=computed(()=>filePresentation.value===`rendered`?markdownRenderer.parse(editor.text.value):``);watch(editor.selectedPath,()=>{const codeRequested=props.codeFocusMode||props.openRequest?.presentation===`code`&&props.openRequest?.path===editor.selectedPath.value;filePresentation.value=codeRequested?`code`:markdownRenderable.value?`rendered`:`interface`;interfaceSymbolId.value=``;symbolPresentation.value=`description`});function openMarkdownLink(event){const anchor=event.target?.closest?.(`a[href]`);if(!anchor)return;event.preventDefault();const target=anchor.getAttribute(`href`).trim();if(/^(?:https?:|mailto:)/iu.test(target)){globalThis.open?.(target,`_blank`,`noopener,noreferrer`);return}const path=markdownDocumentLinkTarget(editor.selectedPath.value,target);if(path)editor.openFile(path)}watch([interfaceSymbols,interfaceCurrent,()=>props.openRequest],()=>{if(props.openRequest?.path!==editor.selectedPath.value||!interfaceCurrent.value)return;const requested=interfaceSymbols.value.find(symbol=>symbol.id===props.openRequest.symbolId||props.openRequest.symbol&&(symbol.qualifiedName===props.openRequest.symbol||symbol.name===props.openRequest.symbol));if(requested&&requested.id!==interfaceSymbolId.value)selectInterfaceSymbol(requested.id);if(props.openRequest.symbolPresentation)symbolPresentation.value=props.openRequest.symbolPresentation});watch([editor.selectedPath,interfaceSymbolId,filePresentation,symbolPresentation],()=>{if(props.singleFile&&props.active&&interfaceCurrent.value&&editor.selectedPath.value)emit(`interface-location`,{path:editor.selectedPath.value,symbolId:interfaceSymbolId.value,presentation:filePresentation.value,symbolPresentation:symbolPresentation.value})},{flush:`post`});const displayedPath=computed(()=>editor.downloadOnlyFile.value?.path||editor.selectedPath.value);const imagePreviewStatus=ref(`loading`);const imagePreviewVersion=ref(0);const imagePreviewUrl=computed(()=>{const filePath=editor.downloadOnlyFile.value?.path||``;if(editor.loadingFile.value||!/\.(?:png|jpe?g|gif|webp|avif|bmp|ico)$/iu.test(filePath))return``;return scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(readRefOrGetterValue(props.sessionsApiPath),props.sessionId,filePath),props.projectSlug)});watch([imagePreviewUrl,imagePreviewVersion],()=>{imagePreviewStatus.value=`loading`},{immediate:true});function refreshFiles(){imagePreviewVersion.value+=1;editor.refresh()}const selectedStarred=computed(()=>props.fileBookmarks?.paths.value.includes(displayedPath.value)||false);const downloadingPath=ref(``);const downloadDraftOpen=ref(false);const downloadSaving=ref(false);const downloadError=ref(``);let draftDownload=null;const downloadFeedback=useUiFeedback({source:`vibe64.source-editor.download`});function requestDownload(filePath){if(!filePath||downloadingPath.value)return;const target={path:filePath,sessionId:props.sessionId,sessionsApiPath:readRefOrGetterValue(props.sessionsApiPath),projectSlug:props.projectSlug};if(filePath===editor.selectedPath.value&&(editor.dirty.value||editor.saving.value)){draftDownload=target;downloadError.value=``;downloadDraftOpen.value=true}else downloadFile(target)}async function downloadFile(target){downloadingPath.value=target.path;try{await downloadAttachment(scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(target.sessionsApiPath,target.sessionId,target.path),target.projectSlug),basename(target.path),`File could not download. Check your connection and access, then retry.`)}catch(cause){downloadFeedback.error(cause,`File could not download.`)}finally{downloadingPath.value=``}}function downloadSavedDraft(){downloadDraftOpen.value=false;downloadFile(draftDownload)}async function saveAndDownload(){downloadSaving.value=true;await editor.saveNow();downloadSaving.value=false;if(editor.dirty.value||editor.saveError.value){downloadError.value=editor.saveError.value||`The file still has unsaved edits.`;return}downloadSavedDraft()}watch([()=>props.active,()=>props.agentActive],([active,working],[wasActive,wasWorking])=>{if(active&&(!wasActive||wasWorking&&!working))props.fileBookmarks?.refresh()});watch(()=>props.sessionId,()=>{downloadDraftOpen.value=false});const languageCompartment=new Compartment;const lineWrappingCompartment=new Compartment;const editorPerformanceSetup=[lineNumbers(),highlightActiveLineGutter(),history(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),syntaxHighlighting(defaultHighlightStyle,{fallback:true}),bracketMatching(),rectangularSelection(),crosshairCursor(),keymap.of([indentWithTab,...defaultKeymap,...historyKeymap,...searchKeymap])];const sourcePathClickExtension=EditorView.domEventHandlers({click(event,view){if(!sourcePathNavigationGesture(event)||event.button!==0)return false;const sourcePath=sourcePathReferenceAtEvent(view,event);if(!sourcePath)return false;event.preventDefault();event.stopPropagation();editor.openReferencedSourcePath({fromPath:editor.selectedPath.value,target:sourcePath.target});return true},mouseleave(_event,view){setSourcePathHoverState(view,false);return false},mousemove(event,view){setSourcePathHoverState(view,Boolean(sourcePathNavigationGesture(event)&&sourcePathReferenceAtEvent(view,event)));return false}});const expandedDirectoryPaths=ref([]);const explanationCollapsed=ref(false);const{smAndDown:mobile}=useDisplay();const fileListCollapsed=ref(mobile.value);const newFileDialogOpen=ref(false);const sourceEditorElement=ref(null);const newFileDirectory=ref(``);const newFileError=ref(``);const newFileName=ref(``);const treeStateStorageKey=computed(()=>sourceEditorTreeStateStorageKey({sessionId:props.sessionId,sessionsApiPath:props.sessionsApiPath}));const fastOpenPanelVisible=computed(()=>Boolean(editor.fileQuery.value));const searchPanelVisible=computed(()=>Boolean(editor.searchQuery.value)||editor.searchResults.value.length>0);const selectedFileName=computed(()=>editor.loadingPath.value||displayedPath.value?basename(editor.loadingPath.value||displayedPath.value):`Choose a source file`);const newFileDirectoryLabel=computed(()=>newFileDirectory.value?`Create in ${newFileDirectory.value}`:`Create in source root`);const newFilePath=computed(()=>{const name=normalizeNewFileEntryPath(newFileName.value);if(!name)return``;return newFileDirectory.value?`${newFileDirectory.value}/${name}`:name});const newFileCreateDisabled=computed(()=>Boolean(editor.creatingFile.value||!newFilePath.value));function normalizeNewFileEntryPath(value=``){const raw=normalizeSourceEditorPath(value).replace(/\/+$/u,``);if(!raw||raw.startsWith(`/`))return``;const parts=raw.split(`/`).filter(Boolean);if(!parts.length||parts.some(part=>part===`.`||part===`..`))return``;return parts.join(`/`)}function basename(filePath=``){return String(filePath||``).split(`/`).at(-1)||filePath}function searchResultTitle(result={}){return`${result.path||``}:${result.line||1}:${result.column||1}`}async function focusAfterLayout(rootElement=null,selector=``){await nextTick();if(sourceEditorUnmounted)return;if(explanationFocusTimer)clearTimeout(explanationFocusTimer);explanationFocusTimer=setTimeout(()=>{explanationFocusTimer=null;rootElement?.querySelector?.(selector)?.focus?.()},0)}function collapseExplanation(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;explanationCollapsed.value=true;focusAfterLayout(rootElement,`.vibe64-source-editor__side-rail--right`)}function expandExplanation(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;explanationCollapsed.value=false;focusAfterLayout(rootElement,`.vibe64-source-explanation__range`)}async function closeExplanationPanel(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;if(await editor.closeExplanation())focusAfterLayout(rootElement,`.vibe64-source-editor__explain-button`)}function collapseFileList(){fileListCollapsed.value=true}function expandFileList(){fileListCollapsed.value=false}function addExpandedDirectoryPaths(paths=[]){const normalizedPaths=normalizeSourceEditorDirectoryPaths(paths);if(!normalizedPaths.length)return;expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths([...expandedDirectoryPaths.value,...normalizedPaths])}function parentDirectoryPathsFor(filePath=``){const parts=normalizeSourceEditorPath(filePath).split(`/`).filter(Boolean);const paths=[];for(let index=1;index<parts.length;index+=1)paths.push(parts.slice(0,index).join(`/`));return paths}function openNewFileDialog(directoryPath=``){newFileDirectory.value=normalizeSourceEditorPath(directoryPath);newFileName.value=``;newFileError.value=``;newFileDialogOpen.value=true}function closeNewFileDialog(){if(editor.creatingFile.value)return;newFileDialogOpen.value=false;newFileError.value=``}async function submitNewFile(){const filePath=newFilePath.value;if(!filePath||editor.creatingFile.value){if(String(newFileName.value||``).trim())newFileError.value=`Enter a nested file path without absolute or parent-directory segments.`;return}if(!await editor.createFile(filePath)){newFileError.value=editor.createFileError.value||`Source file could not be created.`;return}addExpandedDirectoryPaths(parentDirectoryPathsFor(filePath));newFileDialogOpen.value=false;newFileError.value=``;if(mobile.value)collapseFileList()}async function copySourcePath(path=``){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath)return;try{await writeClipboardText(normalizedPath)}catch{}}function askAssistantAboutPath(path=``){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath||!props.assistantDraftAvailable)return;emit(`ask-assistant-about-file`,normalizedPath)}function sourceEditorTreeStateStorageKey({sessionId=``,sessionsApiPath=``}={}){const normalizedSessionId=String(sessionId||``).trim();const normalizedSessionsApiPath=String(sessionsApiPath||``).trim();if(!normalizedSessionId||!normalizedSessionsApiPath)return``;return[SOURCE_EDITOR_TREE_STATE_STORAGE_KEY,stableLocalStorageKeyPart(normalizedSessionsApiPath),stableLocalStorageKeyPart(normalizedSessionId)].join(`:`)}function languageExtension(filePath=``){const lowerPath=String(filePath||``).toLowerCase();if(lowerPath.endsWith(`.vue`))return htmlSourceLanguage({matchClosingTags:false});if(/\.(html|htm|xhtml|svg)$/u.test(lowerPath))return htmlSourceLanguage();if(/\.(js|jsx|mjs|cjs)$/u.test(lowerPath))return javascript({jsx:true});if(/\.(ts|tsx)$/u.test(lowerPath))return javascript({jsx:lowerPath.endsWith(`.tsx`),typescript:true});if(lowerPath.endsWith(`.json`))return json();if(/\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$/u.test(lowerPath))return cpp();if(/\.(sh|bash|zsh|fish)$/u.test(lowerPath))return StreamLanguage.define(shell);if(sourceEditorPathIsMarkdown(lowerPath))return markdown();return[]}function sourceEditorPathIsMarkdown(filePath=``){const lowerPath=String(filePath||``).toLowerCase();return/\.(md|markdown|todo)$/u.test(lowerPath)||/(^|\/)todo$/u.test(lowerPath)}function sourceEditorLineWrappingExtension(filePath=``){return sourceEditorPathIsMarkdown(filePath)?EditorView.lineWrapping:[]}function htmlSourceLanguage(options={}){return html({selfClosingTags:true,...options,nestedLanguages:[{attrs:(attrs={})=>[`ts`,`typescript`].includes(String(attrs.lang||``).toLowerCase()),parser:typescriptLanguage.parser,tag:`script`},{attrs:(attrs={})=>String(attrs.lang||``).toLowerCase()===`jsx`,parser:jsxLanguage.parser,tag:`script`},{attrs:(attrs={})=>String(attrs.lang||``).toLowerCase()===`tsx`,parser:tsxLanguage.parser,tag:`script`}]})}function sourcePathModifierPressed(event={}){return event.ctrlKey||event.metaKey}function sourcePathNavigationGesture(event={}){return props.sourcePathClickWithoutModifier||sourcePathModifierPressed(event)}function setSourcePathHoverState(view,active=false){view.dom.classList.toggle(`vibe64-source-editor__codemirror--source-link-hover`,active)}function sourcePathReferenceAtEvent(view,event={}){const position=view.posAtCoords({x:event.clientX,y:event.clientY});if(position==null)return null;const line=view.state.doc.lineAt(position);return sourcePathReferenceAtLineColumn(line.text,position-line.from)}function createEditor(){if(!editorElement.value||editorView)return;editorView=new EditorView({parent:editorElement.value,state:EditorState.create({doc:editor.text.value,extensions:[editorPerformanceSetup,sourcePathClickExtension,languageCompartment.of(languageExtension(editor.selectedPath.value)),lineWrappingCompartment.of(sourceEditorLineWrappingExtension(editor.selectedPath.value)),EditorView.updateListener.of(update=>{if(!update.docChanged||resettingEditor)return;editor.updateText()}),EditorView.theme({"&":{backgroundColor:`rgb(var(--v-theme-surface))`,color:`rgb(var(--v-theme-on-surface))`,fontSize:`13px`,height:`100%`},".cm-content":{caretColor:`rgb(var(--v-theme-primary))`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`rgb(var(--v-theme-surface))`,backgroundImage:`linear-gradient(rgba(var(--v-theme-surface-variant), 0.38), rgba(var(--v-theme-surface-variant), 0.38))`,borderRight:`1px solid rgba(var(--v-border-color), 0.28)`,color:`rgba(var(--v-theme-on-surface), 0.56)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace`},".cm-selectionBackground":{backgroundColor:`rgba(var(--v-theme-primary), 0.22)`}})]})});renderedEditorPath=editor.selectedPath.value}function replaceEditorDocument(){if(!editorView)return;const selectedPath=editor.selectedPath.value;const sameFile=renderedEditorPath===selectedPath;const currentText=editorView.state.doc.toString();const changes=editorView.state.changes(sameFile?sourceEditorDocumentChanges(currentText,editor.text.value):[{from:0,insert:editor.text.value,to:currentText.length}]);const effects=[languageCompartment.reconfigure(languageExtension(selectedPath)),lineWrappingCompartment.reconfigure(sourceEditorLineWrappingExtension(selectedPath))];const cursorRequest=editor.cursorRequest.value;const explicitCursorRequest=cursorRequest?.path===selectedPath&&Number(cursorRequest.line||0)>0;if(sameFile&&!explicitCursorRequest){const scrollSnapshot=editorView.scrollSnapshot().map(changes);if(scrollSnapshot)effects.unshift(scrollSnapshot)}resettingEditor=true;try{editorView.dispatch({changes,effects})}finally{resettingEditor=false}renderedEditorPath=selectedPath;applyCursorRequest()}function applyCursorRequest(){if(!editorView)return;const request=editor.cursorRequest.value;const line=Number(request?.line||0);if(!line)return;const boundedLine=Math.max(1,Math.min(line,editorView.state.doc.lines));const lineInfo=editorView.state.doc.line(boundedLine);const column=Math.max(0,Number(request?.column||1)-1);const anchor=Math.min(lineInfo.to,lineInfo.from+column);editorView.dispatch({selection:{anchor},scrollIntoView:true});if(filePresentation.value===`code`)editorView.focus()}function runEditorCommand(command=``){if(!editorView)return;if(command===`undo`)undo(editorView);else if(command===`redo`)redo(editorView)}function currentEditorSelectionRange(){if(!editorView)return{endColumn:1,endLine:1,startColumn:1,startLine:1};const selection=editorView.state.selection.main;const from=Math.min(selection.from,selection.to);const to=Math.max(selection.from,selection.to);const fromLine=editorView.state.doc.lineAt(from);const toLine=editorView.state.doc.lineAt(to);if(selection.empty){const firstLine=editorView.state.doc.line(1);const lastLine=editorView.state.doc.line(editorView.state.doc.lines);return{endColumn:Math.max(1,lastLine.length+1),endLine:lastLine.number,scope:`file`,startColumn:1,startLine:firstLine.number}}return{endColumn:Math.max(1,to-toLine.from+1),endLine:toLine.number,scope:`selection`,startColumn:Math.max(1,from-fromLine.from+1),startLine:fromLine.number}}function explainCurrentSelection(){if(!props.assistantAvailable)return false;editor.explainSelection(currentEditorSelectionRange());return true}function retryExplanation(){if(!props.assistantAvailable)return false;editor.retryExplanation();return true}function sendExplanationFollowup(){if(!props.assistantAvailable)return false;editor.sendExplanationFollowup();return true}function openExplanationRange(explanation={}){const sourceRange=explanation?.sourceRange||{};if(sourceRange.path)editor.openFile(sourceRange.path,{column:sourceRange.startColumn,line:sourceRange.startLine})}function openExplanationSourceLink(sourceLink={}){const path=String(sourceLink?.path||``).trim();if(!path)return;editor.openFile(path,{column:Number(sourceLink.column||0)||0,line:Number(sourceLink.line||0)||0})}function handleDirectoryOpenChange({open=false,path=``}={}){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath)return;const nextPaths=new Set(expandedDirectoryPaths.value);if(open){nextPaths.add(normalizedPath);editor.loadDirectory(normalizedPath)}else nextPaths.delete(normalizedPath);expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths([...nextPaths])}function closeAllDirectories(){expandedDirectoryPaths.value=[]}watch(mobile,compact=>{fileListCollapsed.value=compact});watch(editor.loadingPath,filePath=>{if(mobile.value&&filePath)collapseFileList()});watch(()=>props.openRequest,(request=null)=>{if(request?.path){if(request.path===editor.selectedPath.value&&request.presentation===`code`)showWholeFileCode();if(request.presentation===`interface`)filePresentation.value=`interface`;editor.openRequest(request)}},{deep:true,immediate:true});watch(()=>props.active,async active=>{if(!active)return;await nextTick();editorView?.requestMeasure?.()});watch(editor.loadedVersion,()=>{replaceEditorDocument()});watch(()=>editor.activeExplanation.value?.id||``,(explanationId=``)=>{if(explanationId)explanationCollapsed.value=false});watch(editor.revealedDirectoryPaths,paths=>{addExpandedDirectoryPaths(paths)});watch(treeStateStorageKey,(storageKey=``)=>{expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths(readLocalStorageJson(storageKey,[]))},{immediate:true});watch(expandedDirectoryPaths,paths=>{if(treeStateStorageKey.value)writeLocalStorageJson(treeStateStorageKey.value,normalizeSourceEditorDirectoryPaths(paths))});onMounted(()=>{createEditor()});onBeforeUnmount(()=>{sourceEditorUnmounted=true;if(explanationFocusTimer){clearTimeout(explanationFocusTimer);explanationFocusTimer=null}editorView?.destroy();editorView=null;renderedEditorPath=``});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{ref_key:`sourceEditorElement`,ref:sourceEditorElement,class:normalizeClass([`vibe64-source-editor`,{"vibe64-source-editor--code-focus":__props.codeFocusMode,"vibe64-source-editor--mobile":unref(mobile),"vibe64-source-editor--mobile-file-open":unref(mobile)&&fileListCollapsed.value}]),"aria-label":`Session source editor`},[!__props.singleFile||filePresentation.value===`code`?(openBlock(),createElementBlock(`header`,_hoisted_1$1,[!__props.singleFile&&unref(mobile)&&!__props.codeFocusMode?(openBlock(),createBlock(VBtn,{key:0,"aria-expanded":!fileListCollapsed.value,"aria-label":fileListCollapsed.value?`Show files`:`Hide files`,icon:fileListCollapsed.value?unref(mdiFolderOutline):unref(mdiClose),variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>fileListCollapsed.value?expandFileList():collapseFileList())},null,8,[`aria-expanded`,`aria-label`,`icon`])):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_2$1,[!unref(mobile)?(openBlock(),createBlock(VIcon,{key:0,icon:unref(mdiFileCodeOutline),size:`19`},null,8,[`icon`])):createCommentVNode(``,true),createBaseVNode(`h2`,{title:unref(editor).loadingPath.value||displayedPath.value||`Choose a source file`},toDisplayString(selectedFileName.value),9,_hoisted_3$1)]),unref(editor).selectedPath.value&&markdownRenderable.value?(openBlock(),createBlock(VBtn,{key:1,"min-height":`48`,variant:`text`,title:filePresentation.value===`rendered`?`Show the Markdown source`:`Show the formatted document`,onClick:_cache[1]||(_cache[1]=$event=>filePresentation.value=filePresentation.value===`rendered`?`code`:`rendered`)},{default:withCtx(()=>[createTextVNode(toDisplayString(filePresentation.value===`rendered`?`Markdown`:`Rendered`),1)]),_:1},8,[`title`])):unref(editor).selectedPath.value?(openBlock(),createBlock(VBtn,{key:2,"min-height":`48`,variant:`text`,onClick:_cache[2]||(_cache[2]=$event=>filePresentation.value=filePresentation.value===`code`?`interface`:`code`)},{default:withCtx(()=>[createTextVNode(toDisplayString(filePresentation.value===`code`?`Interface`:`Code`),1)]),_:1})):createCommentVNode(``,true),unref(mobile)?(openBlock(),createElementBlock(`div`,_hoisted_4$1,[createVNode(VBtn,{disabled:!unref(editor).dirty.value||unref(editor).saving.value,"aria-label":unref(editor).saving.value?`Saving file`:`Save now`,icon:unref(mdiContentSaveOutline),variant:`tonal`,onClick:unref(editor).saveNow},null,8,[`disabled`,`aria-label`,`icon`,`onClick`]),createVNode(VMenu,null,{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps(menuProps,{icon:unref(mdiDotsVertical),"aria-label":`File actions`,variant:`text`}),null,16,[`icon`])]),default:withCtx(()=>[createVNode(VList,{density:`compact`},{default:withCtx(()=>[unref(editor).statusLabel.value?(openBlock(),createBlock(VListItem,{key:0,title:unref(editor).statusLabel.value,class:normalizeClass({"text-error":unref(editor).saveError.value})},null,8,[`title`,`class`])):createCommentVNode(``,true),__props.fileBookmarks?(openBlock(),createBlock(VListItem,{key:1,title:selectedStarred.value?`Unstar file`:`Star file`,"prepend-icon":selectedStarred.value?unref(mdiStar):unref(mdiStarOutline),disabled:!displayedPath.value||__props.fileBookmarks.pendingPaths.value.includes(displayedPath.value),onClick:_cache[3]||(_cache[3]=$event=>__props.fileBookmarks.toggle(displayedPath.value))},null,8,[`title`,`prepend-icon`,`disabled`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Download file`,"prepend-icon":unref(mdiDownload),disabled:!displayedPath.value||unref(editor).loadingFile.value||Boolean(downloadingPath.value),onClick:_cache[4]||(_cache[4]=$event=>requestDownload(displayedPath.value))},null,8,[`prepend-icon`,`disabled`]),createVNode(VListItem,{title:`Undo`,"prepend-icon":unref(mdiUndoVariant),disabled:!unref(editor).selectedPath.value,onClick:_cache[5]||(_cache[5]=$event=>runEditorCommand(`undo`))},null,8,[`prepend-icon`,`disabled`]),createVNode(VListItem,{title:`Redo`,"prepend-icon":unref(mdiRedoVariant),disabled:!unref(editor).selectedPath.value,onClick:_cache[6]||(_cache[6]=$event=>runEditorCommand(`redo`))},null,8,[`prepend-icon`,`disabled`]),!__props.singleFile?(openBlock(),createBlock(VListItem,{key:2,title:`Explain file or selection`,"prepend-icon":unref(mdiRobotOutline),disabled:!__props.assistantAvailable||!unref(editor).selectedPath.value||unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,onClick:explainCurrentSelection},null,8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Refresh files`,"prepend-icon":unref(mdiRefresh),disabled:unref(editor).loadingTree.value,onClick:refreshFiles},null,8,[`prepend-icon`,`disabled`])]),_:1})]),_:1})])):(openBlock(),createElementBlock(`div`,_hoisted_5$1,[__props.fileBookmarks?(openBlock(),createBlock(VBtn,{key:0,"aria-label":selectedStarred.value?`Unstar file`:`Star file`,"aria-pressed":selectedStarred.value,disabled:!displayedPath.value||__props.fileBookmarks.pendingPaths.value.includes(displayedPath.value),icon:selectedStarred.value?unref(mdiStar):unref(mdiStarOutline),size:`small`,title:selectedStarred.value?`Unstar file`:`Star file`,variant:`text`,onClick:_cache[7]||(_cache[7]=$event=>__props.fileBookmarks.toggle(displayedPath.value))},null,8,[`aria-label`,`aria-pressed`,`disabled`,`icon`,`title`])):createCommentVNode(``,true),createVNode(VBtn,{"aria-label":`Download file`,disabled:!displayedPath.value||unref(editor).loadingFile.value||Boolean(downloadingPath.value),icon:unref(mdiDownload),size:`small`,title:downloadingPath.value?`Downloading file…`:`Download file`,variant:`text`,onClick:_cache[8]||(_cache[8]=$event=>requestDownload(displayedPath.value))},null,8,[`disabled`,`icon`,`title`]),unref(editor).statusLabel.value?(openBlock(),createElementBlock(`span`,{key:1,class:normalizeClass([`vibe64-source-editor__status`,{"vibe64-source-editor__status--error":unref(editor).saveError.value}])},toDisplayString(unref(editor).statusLabel.value),3)):createCommentVNode(``,true),createVNode(VBtn,{disabled:!unref(editor).selectedPath.value,icon:unref(mdiUndoVariant),size:`small`,title:`Undo`,type:`button`,variant:`text`,onClick:_cache[9]||(_cache[9]=$event=>runEditorCommand(`undo`))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{disabled:!unref(editor).selectedPath.value,icon:unref(mdiRedoVariant),size:`small`,title:`Redo`,type:`button`,variant:`text`,onClick:_cache[10]||(_cache[10]=$event=>runEditorCommand(`redo`))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{disabled:!unref(editor).dirty.value||unref(editor).saving.value,icon:unref(mdiContentSaveOutline),loading:unref(editor).saving.value,size:`small`,title:`Save now`,type:`button`,variant:`tonal`,onClick:unref(editor).saveNow},null,8,[`disabled`,`icon`,`loading`,`onClick`]),!__props.singleFile?(openBlock(),createBlock(VBtn,{key:2,class:`vibe64-source-editor__explain-button`,"aria-busy":unref(editor).explanationBusy.value||unref(editor).explanationClosing.value?`true`:`false`,color:`primary`,disabled:!__props.assistantAvailable||!unref(editor).selectedPath.value||unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,"prepend-icon":unref(mdiRobotOutline),size:`small`,title:!__props.assistantAvailable?__props.assistantUnavailableMessage:unref(editor).explanationClosing.value?`Closing explanation`:unref(editor).explanationBusy.value?`Explanation in progress`:`Explain file or selection`,type:`button`,variant:`tonal`,onClick:explainCurrentSelection},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(editor).explanationClosing.value?`Closing…`:unref(editor).explanationBusy.value?`Working…`:`Explain`),1)]),_:1},8,[`aria-busy`,`disabled`,`prepend-icon`,`title`])):createCommentVNode(``,true),!__props.singleFile?(openBlock(),createBlock(VBtn,{key:3,disabled:unref(editor).loadingTree.value,icon:unref(mdiRefresh),"aria-busy":unref(editor).loadingTree.value,size:`small`,title:`Refresh files`,type:`button`,variant:`text`,onClick:refreshFiles},null,8,[`disabled`,`icon`,`aria-busy`])):createCommentVNode(``,true)]))])):createCommentVNode(``,true),!__props.singleFile&&!__props.codeFocusMode&&(!unref(mobile)||!fileListCollapsed.value)?(openBlock(),createElementBlock(`div`,_hoisted_6$1,[createBaseVNode(`div`,_hoisted_7$1,[createVNode(VTextField,{autocomplete:`off`,clearable:``,density:`compact`,"hide-details":``,label:`Open file`,"model-value":unref(editor).fileQuery.value,"prepend-inner-icon":unref(mdiFileSearchOutline),variant:`outlined`,onKeydown:withKeys(withModifiers(unref(editor).openFirstFileMatch,[`prevent`]),[`enter`]),"onUpdate:modelValue":unref(editor).updateFileQuery},null,8,[`model-value`,`prepend-inner-icon`,`onKeydown`,`onUpdate:modelValue`]),fastOpenPanelVisible.value?(openBlock(),createElementBlock(`div`,_hoisted_8$1,[unref(editor).fileMatchesLoading.value?(openBlock(),createElementBlock(`div`,_hoisted_9$1,` Finding files... `)):unref(editor).fileMatchesError.value?(openBlock(),createElementBlock(`div`,_hoisted_10$1,toDisplayString(unref(editor).fileMatchesError.value),1)):(openBlock(),createElementBlock(Fragment,{key:2},[(openBlock(true),createElementBlock(Fragment,null,renderList(unref(editor).fileMatches.value,file=>{return openBlock(),createElementBlock(`button`,{key:file.path,class:`vibe64-source-editor__match`,title:file.path,type:`button`,onClick:$event=>unref(editor).openFileMatch(file.path)},[createBaseVNode(`span`,_hoisted_12,toDisplayString(file.name||basename(file.path)),1),createBaseVNode(`span`,_hoisted_13,toDisplayString(file.path),1)],8,_hoisted_11$1)}),128)),!unref(editor).fileMatches.value.length?(openBlock(),createElementBlock(`div`,_hoisted_14,` No matching files. `)):createCommentVNode(``,true),unref(editor).fileMatchesTruncated.value?(openBlock(),createElementBlock(`div`,_hoisted_15,` Keep typing to narrow the list. `)):createCommentVNode(``,true)],64))])):createCommentVNode(``,true)]),createBaseVNode(`div`,_hoisted_16,[createVNode(VTextField,{autocomplete:`off`,clearable:``,density:`compact`,"hide-details":``,label:`Find in files`,"model-value":unref(editor).searchQuery.value,"prepend-inner-icon":unref(mdiMagnify),variant:`outlined`,onKeydown:_cache[11]||(_cache[11]=withKeys(withModifiers($event=>unref(editor).openSearchResult(unref(editor).searchResults.value[0]),[`prevent`]),[`enter`])),"onUpdate:modelValue":unref(editor).updateSearchQuery},null,8,[`model-value`,`prepend-inner-icon`,`onUpdate:modelValue`])])])):createCommentVNode(``,true),createBaseVNode(`div`,{class:normalizeClass([`vibe64-source-editor__body`,{"vibe64-source-editor__body--code-focus":__props.codeFocusMode||__props.singleFile,"vibe64-source-editor__body--file-list-collapsed":fileListCollapsed.value&&!__props.codeFocusMode}])},[!__props.singleFile&&!__props.codeFocusMode?withDirectives((openBlock(),createElementBlock(`aside`,{key:0,class:normalizeClass([`vibe64-source-editor__sidebar`,{"vibe64-source-editor__sidebar--collapsed":fileListCollapsed.value}])},[fileListCollapsed.value?(openBlock(),createElementBlock(`button`,{key:0,"aria-label":`Show files`,class:`vibe64-source-editor__side-rail`,title:`Show files`,type:`button`,onClick:expandFileList},[createVNode(VIcon,{icon:unref(mdiChevronRight),size:`22`},null,8,[`icon`]),_cache[24]||(_cache[24]=createBaseVNode(`span`,null,`Files`,-1))])):(openBlock(),createElementBlock(Fragment,{key:1},[createBaseVNode(`div`,_hoisted_17,[_cache[25]||(_cache[25]=createBaseVNode(`span`,null,`Files`,-1)),createBaseVNode(`div`,_hoisted_18,[createVNode(VBtn,{"aria-label":`New file at source root`,disabled:unref(editor).creatingFile.value||!unref(editor).tree.value,icon:unref(mdiFilePlusOutline),size:`x-small`,title:`New file at source root`,type:`button`,variant:`text`,onClick:_cache[12]||(_cache[12]=$event=>openNewFileDialog(``))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{class:`vibe64-source-editor__collapse-files-button`,"aria-label":`Collapse file list`,icon:unref(mdiChevronLeft),size:`small`,title:`Collapse file list`,type:`button`,variant:`text`,onClick:collapseFileList},null,8,[`icon`]),createVNode(VBtn,{"aria-label":`Close all folders`,disabled:!unref(editor).tree.value||!expandedDirectoryPaths.value.length,icon:unref(mdiCollapseAllOutline),size:`x-small`,title:`Close all folders`,type:`button`,variant:`text`,onClick:closeAllDirectories},null,8,[`disabled`,`icon`])])]),__props.fileBookmarks?(openBlock(),createElementBlock(`details`,{key:0,class:`vibe64-source-editor__starred`,open:__props.fileBookmarks.files.value.length<=4},[createBaseVNode(`summary`,null,[_cache[26]||(_cache[26]=createTextVNode(`Starred `,-1)),createBaseVNode(`span`,null,toDisplayString(__props.fileBookmarks.files.value.length),1)]),createVNode(Vibe64StarredFilesList_default,{bookmarks:__props.fileBookmarks,compact:``,onOpenFile:unref(editor).openFile},null,8,[`bookmarks`,`onOpenFile`])],8,_hoisted_19)):createCommentVNode(``,true),searchPanelVisible.value?(openBlock(),createElementBlock(`section`,_hoisted_20,[createBaseVNode(`div`,_hoisted_21,[_cache[27]||(_cache[27]=createBaseVNode(`span`,null,`Find results`,-1)),createBaseVNode(`small`,null,toDisplayString(unref(editor).searchResults.value.length),1)]),unref(editor).searchIndexLabel.value?(openBlock(),createElementBlock(`div`,{key:0,class:normalizeClass([`vibe64-source-editor__notice`,{"vibe64-source-editor__notice--error":unref(editor).searchIndex.value?.state===`error`}]),role:`status`},toDisplayString(unref(editor).searchIndexLabel.value),3)):createCommentVNode(``,true),unref(editor).searchLoading.value&&!unref(editor).searchResults.value.length?(openBlock(),createElementBlock(`div`,_hoisted_22,` Searching files... `)):unref(editor).searchError.value?(openBlock(),createElementBlock(`div`,_hoisted_23,toDisplayString(unref(editor).searchError.value),1)):!unref(editor).searchResults.value.length&&unref(editor).searchIndex.value?.state!==`error`?(openBlock(),createElementBlock(`div`,_hoisted_24,toDisplayString(unref(editor).searchIndexPending.value?`Results will appear as files are indexed.`:`No results.`),1)):(openBlock(true),createElementBlock(Fragment,{key:4},renderList(unref(editor).searchResults.value,result=>{return openBlock(),createElementBlock(`button`,{key:`${result.path}:${result.line}:${result.column}:${result.preview}`,class:`vibe64-source-editor__search-result`,title:searchResultTitle(result),type:`button`,onClick:$event=>unref(editor).openSearchResult(result)},[createBaseVNode(`span`,_hoisted_26,toDisplayString(result.path),1),createBaseVNode(`span`,_hoisted_27,`Line `+toDisplayString(result.line),1),createBaseVNode(`span`,_hoisted_28,toDisplayString(result.preview),1)],8,_hoisted_25)}),128)),unref(editor).searchTruncated.value?(openBlock(),createElementBlock(`div`,_hoisted_29,` Search stopped at the first matches. Narrow the query for more precision. `)):createCommentVNode(``,true)])):createCommentVNode(``,true),unref(editor).loadingTree.value&&!unref(editor).tree.value?(openBlock(),createElementBlock(`div`,_hoisted_30,` Loading files... `)):unref(editor).loadError.value&&!unref(editor).tree.value?(openBlock(),createElementBlock(`div`,_hoisted_31,toDisplayString(unref(editor).loadError.value),1)):unref(editor).tree.value?(openBlock(),createBlock(Vibe64SourceFileTree_default,{key:4,"expanded-paths":expandedDirectoryPaths.value,"load-errors":unref(editor).treeLoadErrors.value,"loading-paths":unref(editor).treeLoadingPaths.value,node:unref(editor).tree.value,"selected-path":displayedPath.value,"starred-paths":__props.fileBookmarks?.paths.value||[],"assistant-draft-available":__props.assistantDraftAvailable,onAskAssistant:askAssistantAboutPath,onCopyPath:copySourcePath,onDirectoryOpenChange:handleDirectoryOpenChange,onLoadMoreDirectory:unref(editor).loadMoreDirectory,onNewFile:openNewFileDialog,onOpenFile:unref(editor).openFile,onToggleStar:_cache[13]||(_cache[13]=$event=>__props.fileBookmarks?.toggle($event)),onDownloadFile:requestDownload},null,8,[`expanded-paths`,`load-errors`,`loading-paths`,`node`,`selected-path`,`starred-paths`,`assistant-draft-available`,`onLoadMoreDirectory`,`onOpenFile`])):createCommentVNode(``,true)],64))],2)),[[vShow,!unref(mobile)||!fileListCollapsed.value]]):createCommentVNode(``,true),withDirectives(createBaseVNode(`main`,_hoisted_32,[unref(editor).loadError.value&&(__props.singleFile||unref(editor).tree.value)?(openBlock(),createElementBlock(`div`,_hoisted_33,toDisplayString(unref(editor).loadError.value),1)):createCommentVNode(``,true),unref(editor).downloadOnlyFile.value&&!imagePreviewUrl.value&&!unref(editor).loadingFile.value?(openBlock(),createElementBlock(`div`,_hoisted_34,[createBaseVNode(`p`,_hoisted_35,toDisplayString(unref(editor).downloadOnlyFile.value.message),1),createVNode(VBtn,{color:`primary`,disabled:Boolean(downloadingPath.value),"prepend-icon":unref(mdiDownload),onClick:_cache[14]||(_cache[14]=$event=>requestDownload(unref(editor).downloadOnlyFile.value.path))},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadingPath.value?`Downloading…`:`Download file`),1)]),_:1},8,[`disabled`,`prepend-icon`])])):!displayedPath.value&&!unref(editor).loadingFile.value?(openBlock(),createElementBlock(`div`,_hoisted_36,` Select a file to edit. `)):createCommentVNode(``,true),unref(editor).explanationError.value&&!unref(editor).activeExplanation.value?(openBlock(),createElementBlock(`div`,_hoisted_37,toDisplayString(unref(editor).explanationError.value),1)):createCommentVNode(``,true),createBaseVNode(`div`,{class:normalizeClass([`vibe64-source-editor__workspace`,{"vibe64-source-editor__workspace--with-explanation":!__props.singleFile&&unref(editor).activeExplanation.value&&filePresentation.value===`code`,"vibe64-source-editor__workspace--explanation-collapsed":!__props.singleFile&&unref(editor).activeExplanation.value&&explanationCollapsed.value&&filePresentation.value===`code`}])},[withDirectives(createBaseVNode(`div`,{ref_key:`editorElement`,ref:editorElement,class:normalizeClass([`vibe64-source-editor__codemirror`,{"vibe64-source-editor__codemirror--hidden":!unref(editor).selectedPath.value||unref(editor).loadingFile.value}])},null,2),[[vShow,filePresentation.value===`code`]]),unref(editor).selectedPath.value&&!unref(editor).loadingFile.value&&filePresentation.value===`interface`?(openBlock(),createBlock(Vibe64SourceInterface_default,{key:0,"file-path":unref(editor).selectedPath.value,"file-hash":unref(editor).savedHash.value,interpretations:unref(editor).interpretations.value,"interpretation-warning":unref(editor).interpretationWarning.value,"active-interpretation":activeInterfaceInterpretation.value,"active-file-interpretation":activeFileInterpretation.value,symbols:interfaceSymbols.value,programs:interfacePrograms.value,"program-status":interfaceArchitecture.value?.program?.status,"selected-id":interfaceSymbolId.value,current:interfaceCurrent.value,indexed:Boolean(interfaceFile.value),dirty:unref(editor).dirty.value,busy:unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,"analysis-error":__props.architectureFacts?``:unref(interfaceGraph)?.error.value,"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,source:interfaceSymbolSource.value,presentation:symbolPresentation.value,onSelectSymbol:selectInterfaceSymbol,onPresentSymbol:presentInterfaceSymbol,onExplainFile:presentFileOverview,onWholeFileCode:showWholeFileCode,onOpenSource:_cache[15]||(_cache[15]=$event=>_ctx.$emit(`open-source-file`,$event)),onOpenProgram:_cache[16]||(_cache[16]=$event=>_ctx.$emit(`open-program`,$event))},{explanation:withCtx(({savedBody})=>[activeInterfaceInterpretation.value||activeFileInterpretation.value?(openBlock(),createBlock(Vibe64SourceExplanationPanel_default,{key:0,embedded:``,"saved-body":savedBody,"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,busy:unref(editor).explanationBusy.value,closing:unref(editor).explanationClosing.value,explanation:unref(editor).activeExplanation.value,followup:unref(editor).explanationFollowup.value,"selected-path":unref(editor).selectedPath.value,onClose:closeExplanationPanel,onOpenRange:openExplanationRange,onOpenSourceLink:openExplanationSourceLink,onRetry:retryExplanation,onSendFollowup:sendExplanationFollowup,onStop:unref(editor).stopExplanation,"onUpdate:followup":unref(editor).updateExplanationFollowup},null,8,[`saved-body`,`assistant-available`,`assistant-unavailable-message`,`busy`,`closing`,`explanation`,`followup`,`selected-path`,`onStop`,`onUpdate:followup`])):createCommentVNode(``,true)]),_:1},8,[`file-path`,`file-hash`,`interpretations`,`interpretation-warning`,`active-interpretation`,`active-file-interpretation`,`symbols`,`programs`,`program-status`,`selected-id`,`current`,`indexed`,`dirty`,`busy`,`analysis-error`,`assistant-available`,`assistant-unavailable-message`,`source`,`presentation`])):createCommentVNode(``,true),unref(editor).selectedPath.value&&!unref(editor).loadingFile.value&&filePresentation.value===`rendered`?(openBlock(),createElementBlock(`div`,_hoisted_38,[createBaseVNode(`div`,{onClick:openMarkdownLink},[createVNode(GithubMarkdown_default,{html:renderedMarkdownHtml.value},null,8,[`html`])])])):createCommentVNode(``,true),imagePreviewUrl.value?(openBlock(),createElementBlock(`div`,_hoisted_39,[imagePreviewStatus.value===`failed`?(openBlock(),createElementBlock(`div`,_hoisted_40,[_cache[29]||(_cache[29]=createBaseVNode(`p`,{class:`mb-3`,role:`alert`},`This image could not be displayed. Try again or download the file.`,-1)),createVNode(VBtn,{variant:`tonal`,onClick:_cache[17]||(_cache[17]=$event=>imagePreviewVersion.value+=1)},{default:withCtx(()=>[..._cache[28]||(_cache[28]=[createTextVNode(`Retry`,-1)])]),_:1})])):(openBlock(),createElementBlock(`img`,{key:`${imagePreviewUrl.value}:${imagePreviewVersion.value}`,src:imagePreviewUrl.value,alt:selectedFileName.value,style:normalizeStyle({visibility:imagePreviewStatus.value===`loaded`?`visible`:`hidden`}),onLoad:_cache[18]||(_cache[18]=$event=>imagePreviewStatus.value=`loaded`),onError:_cache[19]||(_cache[19]=$event=>imagePreviewStatus.value=`failed`)},null,44,_hoisted_41))])):createCommentVNode(``,true),unref(editor).loadingFile.value||imagePreviewUrl.value&&imagePreviewStatus.value===`loading`?(openBlock(),createElementBlock(`div`,{key:3,"aria-label":`Opening ${selectedFileName.value}`,"aria-live":`polite`,class:`vibe64-source-editor__file-loading`,role:`status`},[createVNode(VSkeletonLoader,{class:`vibe64-source-editor__file-skeleton`,type:`image`})],8,_hoisted_42)):createCommentVNode(``,true),!__props.singleFile&&unref(editor).activeExplanation.value&&filePresentation.value===`code`?(openBlock(),createElementBlock(`div`,{key:4,class:normalizeClass([`vibe64-source-editor__explanation-dock`,{"vibe64-source-editor__explanation-dock--collapsed":explanationCollapsed.value}])},[withDirectives(createVNode(Vibe64SourceExplanationPanel_default,{"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,busy:unref(editor).explanationBusy.value,closing:unref(editor).explanationClosing.value,explanation:unref(editor).activeExplanation.value,followup:unref(editor).explanationFollowup.value,"selected-path":unref(editor).selectedPath.value,onClose:closeExplanationPanel,onCollapse:collapseExplanation,onOpenRange:openExplanationRange,onOpenSourceLink:openExplanationSourceLink,onRetry:retryExplanation,onSendFollowup:sendExplanationFollowup,onStop:unref(editor).stopExplanation,"onUpdate:followup":unref(editor).updateExplanationFollowup},null,8,[`assistant-available`,`assistant-unavailable-message`,`busy`,`closing`,`explanation`,`followup`,`selected-path`,`onStop`,`onUpdate:followup`]),[[vShow,!explanationCollapsed.value]]),withDirectives(createBaseVNode(`button`,{"aria-label":`Show explanation`,class:`vibe64-source-editor__side-rail vibe64-source-editor__side-rail--right`,title:`Show explanation`,type:`button`,onClick:expandExplanation},[createVNode(VIcon,{icon:unref(mdiChevronLeft),size:`22`},null,8,[`icon`]),_cache[30]||(_cache[30]=createBaseVNode(`span`,null,`AI`,-1))],512),[[vShow,explanationCollapsed.value]])],2)):createCommentVNode(``,true)],2)],512),[[vShow,__props.singleFile||!unref(mobile)||fileListCollapsed.value||__props.codeFocusMode]])],2),createVNode(VDialog,{modelValue:newFileDialogOpen.value,"onUpdate:modelValue":_cache[21]||(_cache[21]=$event=>newFileDialogOpen.value=$event),"max-width":`520`},{default:withCtx(()=>[createVNode(VCard,null,{default:withCtx(()=>[createVNode(VCardTitle,null,{default:withCtx(()=>[..._cache[31]||(_cache[31]=[createTextVNode(`New file`,-1)])]),_:1}),createVNode(VCardText,{class:`vibe64-source-editor__new-file-dialog`},{default:withCtx(()=>[createBaseVNode(`p`,null,toDisplayString(newFileDirectoryLabel.value),1),newFileError.value?(openBlock(),createBlock(VAlert,{key:0,density:`compact`,type:`warning`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(newFileError.value),1)]),_:1})):createCommentVNode(``,true),createVNode(VTextField,{modelValue:newFileName.value,"onUpdate:modelValue":_cache[20]||(_cache[20]=$event=>newFileName.value=$event),autofocus:``,autocomplete:`off`,disabled:unref(editor).creatingFile.value,label:`Path`,placeholder:`components/NewFile.vue`,variant:`outlined`,onKeydown:withKeys(withModifiers(submitNewFile,[`prevent`]),[`enter`])},null,8,[`modelValue`,`disabled`,`onKeydown`])]),_:1}),createVNode(VCardActions,null,{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{disabled:unref(editor).creatingFile.value,type:`button`,variant:`text`,onClick:closeNewFileDialog},{default:withCtx(()=>[..._cache[32]||(_cache[32]=[createTextVNode(` Cancel `,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,disabled:newFileCreateDisabled.value,loading:unref(editor).creatingFile.value,type:`button`,variant:`flat`,onClick:submitNewFile},{default:withCtx(()=>[..._cache[33]||(_cache[33]=[createTextVNode(` Create `,-1)])]),_:1},8,[`disabled`,`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),createVNode(VDialog,{modelValue:downloadDraftOpen.value,"onUpdate:modelValue":_cache[23]||(_cache[23]=$event=>downloadDraftOpen.value=$event),"max-width":`440`},{default:withCtx(()=>[createVNode(VCard,{title:`Download this file?`},{default:withCtx(()=>[createVNode(VCardText,null,{default:withCtx(()=>[_cache[34]||(_cache[34]=createTextVNode(` This file has unsaved edits. Download the saved version, or save your edits first. `,-1)),downloadError.value?(openBlock(),createBlock(VAlert,{key:0,class:`mt-3`,density:`compact`,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadError.value),1)]),_:1})):createCommentVNode(``,true)]),_:1}),createVNode(VCardActions,{class:`flex-wrap`},{default:withCtx(()=>[createVNode(VBtn,{disabled:downloadSaving.value,onClick:_cache[22]||(_cache[22]=$event=>downloadDraftOpen.value=false)},{default:withCtx(()=>[..._cache[35]||(_cache[35]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{disabled:downloadSaving.value,onClick:downloadSavedDraft},{default:withCtx(()=>[..._cache[36]||(_cache[36]=[createTextVNode(`Download saved file`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,disabled:downloadSaving.value,onClick:saveAndDownload},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadSaving.value?`Saving…`:`Save & download`),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),createBaseVNode(`span`,_hoisted_43,toDisplayString(downloadingPath.value?`Downloading file…`:``),1)],2)}}};var Vibe64SessionSourceEditor_default=_plugin_vue_export_helper_default(_sfc_main$2,[[`__scopeId`,`data-v-1fad75af`]]);var _hoisted_1=[`aria-label`];var _hoisted_2={key:0,class:`session-file-area__drop-target`,role:`status`};var _hoisted_3={key:1,class:`d-flex align-center ga-2 flex-wrap px-3 pt-2`};var _hoisted_4={class:`text-body-small flex-grow-1`};var _hoisted_5={key:2,class:`d-flex align-center ga-2 flex-wrap px-3`};var _hoisted_6={key:4,class:`pa-4`};var _hoisted_7={class:`text-body-medium session-file-area__filename`};var _hoisted_8={key:1,class:`session-file-area__preview`,tabindex:`0`};var _hoisted_9={key:2,class:`pa-4`};var _hoisted_10={key:1,class:`pa-4 text-body-medium`};var _hoisted_11={key:0};var _sfc_main$1={__name:`Vibe64SessionFileArea`,props:{area:{type:String,required:true},archived:{type:Boolean,default:false},sessionId:{type:String,required:true},sessionsApiPath:{type:String,required:true},projectSlug:{type:String,default:``},active:{type:Boolean,default:true},agentActive:{type:Boolean,default:false}},setup(__props){const props=__props;const{smAndDown:mobile}=useDisplay();const writable=computed(()=>[`drop-zone`,`backups`].includes(props.area));const areaLabel=computed(()=>props.area===`backups`?`Project Backups`:props.area===`drop-zone`?`Session Dropzone`:`Session files, read only`);const areaDescription=computed(()=>props.area===`backups`?`Shared across this project · Files automatically deleted after 2 weeks without changes`:props.area===`session`?`Session runtime files · Read only`:`Temporary file exchange · Deleted when this session is archived`);const base=computed(()=>vibe64SessionPath(props.sessionsApiPath,props.sessionId,`/files/${encodeURIComponent(props.area)}`));const directory=ref(``);const entries=ref([]);const location=ref(``);const expired=ref(false);const hasMore=ref(false);const nextOffset=ref(0);const loading=ref(false);const loadError=ref(``);const busy=ref(false);const file=ref(null);const draft=ref(``);const dirty=computed(()=>file.value&&typeof file.value.text===`string`&&draft.value!==file.value.text);const uploadInput=ref(null);const dragDepth=ref(0);let disposed=false;const dialogOpen=ref(false);const dialogOperation=ref(``);const dialogEntry=ref(null);const dialogName=ref(``);const nameError=ref(``);const feedback=useUiFeedback({source:`vibe64.files`});let generation=0;let pendingRefresh=false;const breadcrumbs=computed(()=>[{title:areaLabel.value,path:``},...directory.value.split(`/`).filter(Boolean).map((name,i,parts)=>({title:name,path:parts.slice(0,i+1).join(`/`)}))]);function url(operation,filePath,offset=0){return`${base.value}/${operation}?${new URLSearchParams({path:filePath,offset})}`}async function request(endpoint,options){const result=await getHttpWebClient().request(endpoint,options);if(result?.ok===false)throw new Error(vibe64ApiResponseError(result,`File operation failed.`));return result}async function loadDirectory(target=``,append=false){const current=++generation;loading.value=true;loadError.value=``;file.value=null;try{const result=await request(url(`tree`,target,append?nextOffset.value:0));if(current!==generation)return;directory.value=target;entries.value=append?[...entries.value,...result.tree.children]:result.tree.children;hasMore.value=result.tree.hasMore;nextOffset.value=result.tree.nextOffset;location.value=result.location||``;expired.value=result.expired===true}catch(error){if(current===generation)loadError.value=error.message}finally{if(current===generation)loading.value=false}}async function openEntry(entry){if(entry.type===`directory`)return loadDirectory(entry.path);const current=++generation;loading.value=true;try{const result=await request(url(`file`,entry.path));if(current!==generation)return;file.value=result.file;draft.value=result.file.text}catch(error){if(current!==generation)return;file.value={path:entry.path,message:error.message}}finally{if(current===generation)loading.value=false}}async function command(run){if(busy.value)return;busy.value=true;try{await run()}catch(error){feedback.error(error,`File operation failed.`)}finally{busy.value=false}}function save(){return command(async()=>{const result=await request(`${base.value}/file`,{method:`PUT`,body:{path:file.value.path,baseHash:file.value.hash,text:draft.value}});file.value=result.file;draft.value=result.file.text})}function dragEnter(event){if(writable.value&&!expired.value&&!busy.value&&event.dataTransfer?.types.includes(`Files`))dragDepth.value+=1}function dragOver(event){if(event.dataTransfer){const canUpload=writable.value&&!expired.value&&!busy.value&&!dirty.value;event.dataTransfer.dropEffect=canUpload?`copy`:`none`}}function dragLeave(){dragDepth.value=Math.max(0,dragDepth.value-1)}function dropFiles(event){dragDepth.value=0;if(!writable.value||expired.value||busy.value)return;if(dirty.value){feedback.error(new Error(`Save or discard your edits before uploading files.`));return}if([...event.dataTransfer?.items||[]].some(item=>item.webkitGetAsEntry?.()?.isDirectory)){feedback.error(new Error(`Drop files individually, or upload a zip for a whole folder.`));return}return uploadFiles([...event.dataTransfer?.files||[]])}function upload(event){const files=[...event.target.files||[]];event.target.value=``;return uploadFiles(files)}function uploadFiles(files){if(!files.length)return;const endpoint=base.value;const folder=directory.value;return command(async()=>{for(const selected of files){if(disposed)break;try{if(selected.size>524288e3)throw new Error(`Choose a file no larger than ${VIBE64_UPLOAD_MAX_LABEL}.`);const data=new FormData;data.append(`file`,selected);const target=[folder,selected.name].filter(Boolean).join(`/`);await request(`${endpoint}/upload?${new URLSearchParams({path:target})}`,{method:`POST`,body:data})}catch(error){feedback.error(new Error(`${selected.name}: ${error.message}`),`Upload failed.`)}}if(!disposed)await loadDirectory(folder)})}function download(target,operation=`download`){return command(()=>downloadAttachment(scopedDevelopmentApiUrl(url(operation,target),props.projectSlug),target.split(`/`).at(-1),`Download failed.`))}function openDialog(operation,entry=null){dialogOperation.value=operation;dialogEntry.value=entry;dialogName.value=entry?.name||``;nameError.value=``;dialogOpen.value=true}function confirmDialog(){const operation=dialogOperation.value;if(operation!==`delete`&&(!dialogName.value.trim()||/[/\\]/u.test(dialogName.value)||[`.`,`..`].includes(dialogName.value.trim()))){nameError.value=`Enter a name without directory separators.`;return}return command(async()=>{const suffix=operation===`mkdir`?`directory`:operation===`delete`?`file`:`rename`;const destination=[directory.value,dialogName.value.trim()].filter(Boolean).join(`/`);await request(`${base.value}/${suffix}`,{method:operation===`delete`?`DELETE`:`POST`,body:{path:operation===`mkdir`?destination:dialogEntry.value.path,...operation===`rename`?{destination}:{}}});dialogOpen.value=false;await loadDirectory(directory.value)})}function copyLocation(){return command(()=>writeClipboardText(location.value))}function refresh(){if(dirty.value||busy.value){pendingRefresh=true;return}pendingRefresh=false;return file.value?openEntry({type:`file`,path:file.value.path}):loadDirectory(directory.value)}function entrySubtitle(entry){if(entry.type!==`file`)return`Folder`;const expiry=entry.expiresAt?` · Expires ${new Date(entry.expiresAt).toLocaleString()}`:``;return`${formatSize(entry.size)}${expiry}`}function formatSize(bytes){if(bytes<1024)return`${bytes} B`;if(bytes<1048576)return`${(bytes/1024).toFixed(1)} KiB`;return`${(bytes/1048576).toFixed(1)} MiB`}watch(base,()=>{directory.value=``;loadDirectory()},{immediate:true});watch(()=>props.agentActive,(working,wasWorking)=>{if(!wasWorking||working)return;if(props.active)refresh();else pendingRefresh=true});watch([()=>props.active,dirty],([active,changed])=>{if(active&&!changed&&pendingRefresh)refresh()});onScopeDispose(()=>{disposed=true;generation+=1});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{class:normalizeClass([`session-file-area`,{"session-file-area--mobile":unref(mobile)}]),"aria-label":areaLabel.value,onDragenter:withModifiers(dragEnter,[`prevent`]),onDragover:withModifiers(dragOver,[`prevent`]),onDragleave:withModifiers(dragLeave,[`prevent`]),onDrop:withModifiers(dropFiles,[`prevent`])},[dragDepth.value>0&&writable.value&&!expired.value&&!busy.value?(openBlock(),createElementBlock(`div`,_hoisted_2,[createVNode(VIcon,{icon:unref(mdiUpload),size:`40`},null,8,[`icon`]),_cache[14]||(_cache[14]=createBaseVNode(`span`,null,`Drop files here to upload`,-1))])):createCommentVNode(``,true),!unref(mobile)||!file.value?(openBlock(),createElementBlock(`div`,_hoisted_3,[createBaseVNode(`span`,_hoisted_4,toDisplayString(areaDescription.value),1),__props.archived&&__props.area===`session`?(openBlock(),createBlock(VBtn,{key:0,"prepend-icon":unref(mdiDownload),size:`small`,variant:`text`,disabled:busy.value,onClick:_cache[0]||(_cache[0]=$event=>download(`${__props.sessionId}.tar.gz`,`archive`))},{default:withCtx(()=>[..._cache[15]||(_cache[15]=[createTextVNode(`Download archive`,-1)])]),_:1},8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true),location.value?(openBlock(),createBlock(VBtn,{key:1,"prepend-icon":unref(mdiContentCopy),size:`small`,variant:`text`,onClick:copyLocation},{default:withCtx(()=>[..._cache[16]||(_cache[16]=[createTextVNode(`Copy AI path`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),createVNode(VBtn,{icon:unref(mdiRefresh),"aria-label":`Refresh files`,title:`Refresh files`,variant:`text`,disabled:loading.value||busy.value,onClick:refresh},null,8,[`icon`,`disabled`])])):createCommentVNode(``,true),!unref(mobile)||!file.value?(openBlock(),createElementBlock(`div`,_hoisted_5,[file.value?(openBlock(),createBlock(VBtn,{key:0,"prepend-icon":unref(mdiArrowLeft),variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[1]||(_cache[1]=$event=>file.value=null)},{default:withCtx(()=>[..._cache[17]||(_cache[17]=[createTextVNode(`Back to folder`,-1)])]),_:1},8,[`prepend-icon`,`disabled`])):(openBlock(),createBlock(VBreadcrumbs,{key:1,items:breadcrumbs.value,density:`compact`,class:`pa-0 flex-grow-1`},{item:withCtx(({item})=>[createVNode(VBtn,{size:`small`,variant:`text`,disabled:loading.value||busy.value,onClick:$event=>loadDirectory(item.path)},{default:withCtx(()=>[createTextVNode(toDisplayString(item.title),1)]),_:2},1032,[`disabled`,`onClick`])]),_:1},8,[`items`])),writable.value&&!expired.value&&!file.value?(openBlock(),createElementBlock(Fragment,{key:2},[createBaseVNode(`input`,{ref_key:`uploadInput`,ref:uploadInput,type:`file`,multiple:``,class:`d-none`,"aria-label":`Choose a file to upload`,onChange:upload},null,544),createVNode(VBtn,{"prepend-icon":unref(mdiFolderPlusOutline),variant:`text`,disabled:busy.value,onClick:_cache[2]||(_cache[2]=$event=>openDialog(`mkdir`))},{default:withCtx(()=>[..._cache[18]||(_cache[18]=[createTextVNode(`New folder`,-1)])]),_:1},8,[`prepend-icon`,`disabled`]),createVNode(VBtn,{"prepend-icon":unref(mdiUpload),variant:`tonal`,disabled:busy.value,onClick:_cache[3]||(_cache[3]=$event=>uploadInput.value.click())},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Working…`:`Upload`),1)]),_:1},8,[`prepend-icon`,`disabled`])],64)):createCommentVNode(``,true)])):createCommentVNode(``,true),loading.value?(openBlock(),createBlock(VSkeletonLoader,{key:3,type:`list-item-two-line@5`,class:`flex-grow-1`})):loadError.value?(openBlock(),createElementBlock(`div`,_hoisted_6,[createVNode(VAlert,{type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(loadError.value),1)]),_:1}),createVNode(VBtn,{class:`mt-3`,variant:`tonal`,onClick:refresh},{default:withCtx(()=>[..._cache[19]||(_cache[19]=[createTextVNode(`Retry`,-1)])]),_:1})])):file.value?(openBlock(),createElementBlock(Fragment,{key:5},[createBaseVNode(`div`,{class:normalizeClass([`d-flex align-center`,unref(mobile)?`ga-0 px-1`:`ga-2 flex-wrap px-3 py-2`])},[unref(mobile)?(openBlock(),createBlock(VBtn,{key:0,icon:unref(mdiArrowLeft),"aria-label":`Back to folder`,variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[4]||(_cache[4]=$event=>file.value=null)},null,8,[`icon`,`disabled`])):createCommentVNode(``,true),createBaseVNode(`span`,_hoisted_7,toDisplayString(file.value.path),1),createVNode(VSpacer),dirty.value?(openBlock(),createElementBlock(Fragment,{key:1},[createVNode(VBtn,{variant:`text`,disabled:busy.value,onClick:_cache[5]||(_cache[5]=$event=>draft.value=file.value.text)},{default:withCtx(()=>[..._cache[20]||(_cache[20]=[createTextVNode(`Discard edits`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,variant:`tonal`,disabled:busy.value,onClick:save},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Saving…`:`Save`),1)]),_:1},8,[`disabled`])],64)):createCommentVNode(``,true),createVNode(VBtn,{icon:unref(mobile)?unref(mdiDownload):void 0,"prepend-icon":unref(mobile)?void 0:unref(mdiDownload),text:unref(mobile)?void 0:`Download`,"aria-label":`Download file`,variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[6]||(_cache[6]=$event=>download(file.value.path))},null,8,[`icon`,`prepend-icon`,`text`,`disabled`]),unref(mobile)?(openBlock(),createBlock(VMenu,{key:2},{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps(menuProps,{icon:unref(mdiDotsVertical),"aria-label":`File actions`,variant:`text`}),null,16,[`icon`])]),default:withCtx(()=>[createVNode(VList,{density:`compact`},{default:withCtx(()=>[location.value?(openBlock(),createBlock(VListItem,{key:0,title:`Copy AI path`,"prepend-icon":unref(mdiContentCopy),onClick:copyLocation},null,8,[`prepend-icon`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Refresh files`,"prepend-icon":unref(mdiRefresh),disabled:loading.value||busy.value,onClick:refresh},null,8,[`prepend-icon`,`disabled`]),__props.archived&&__props.area===`session`?(openBlock(),createBlock(VListItem,{key:1,title:`Download archive`,"prepend-icon":unref(mdiDownload),disabled:busy.value,onClick:_cache[7]||(_cache[7]=$event=>download(`${__props.sessionId}.tar.gz`,`archive`))},null,8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true)]),_:1})]),_:1})):createCommentVNode(``,true)],2),writable.value&&typeof file.value.text===`string`?(openBlock(),createBlock(VTextarea,{key:0,modelValue:draft.value,"onUpdate:modelValue":_cache[8]||(_cache[8]=$event=>draft.value=$event),"aria-label":`File contents`,class:`mx-3 session-file-area__text`,disabled:busy.value,variant:`outlined`,rows:`18`,"hide-details":``},null,8,[`modelValue`,`disabled`])):typeof file.value.text===`string`?(openBlock(),createElementBlock(`pre`,_hoisted_8,toDisplayString(file.value.text),1)):(openBlock(),createElementBlock(`p`,_hoisted_9,toDisplayString(file.value.message),1))],64)):(openBlock(),createElementBlock(Fragment,{key:6},[entries.value.length?(openBlock(),createBlock(VList,{key:0,class:`session-file-area__listing`,"aria-label":`Files and folders`},{default:withCtx(()=>[(openBlock(true),createElementBlock(Fragment,null,renderList(entries.value,entry=>{return openBlock(),createBlock(VListItem,{key:entry.path,title:entry.name,subtitle:entrySubtitle(entry),"prepend-icon":entry.type===`directory`?unref(mdiFolderOutline):unref(mdiFileOutline),disabled:busy.value,onClick:$event=>openEntry(entry)},{append:withCtx(()=>[entry.type===`file`?(openBlock(),createBlock(VBtn,{key:0,icon:unref(mdiDownload),"aria-label":`Download ${entry.name}`,variant:`text`,onClick:withModifiers($event=>download(entry.path),[`stop`])},null,8,[`icon`,`aria-label`,`onClick`])):createCommentVNode(``,true),writable.value?(openBlock(),createBlock(VMenu,{key:1,"close-on-content-click":true},{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps({ref_for:true},menuProps,{icon:unref(mdiDotsVertical),"aria-label":`Actions for ${entry.name}`,variant:`text`,onClick:_cache[9]||(_cache[9]=withModifiers(()=>{},[`stop`]))}),null,16,[`icon`,`aria-label`])]),default:withCtx(()=>[createVNode(VList,null,{default:withCtx(()=>[createVNode(VListItem,{"prepend-icon":unref(mdiPencilOutline),title:`Rename`,onClick:$event=>openDialog(`rename`,entry)},null,8,[`prepend-icon`,`onClick`]),createVNode(VListItem,{"prepend-icon":unref(mdiDeleteOutline),title:`Delete`,onClick:$event=>openDialog(`delete`,entry)},null,8,[`prepend-icon`,`onClick`])]),_:2},1024)]),_:2},1024)):createCommentVNode(``,true)]),_:2},1032,[`title`,`subtitle`,`prepend-icon`,`disabled`,`onClick`])}),128))]),_:1})):(openBlock(),createElementBlock(`p`,_hoisted_10,toDisplayString(expired.value?`This Session Dropzone has expired.`:writable.value?`Nothing here yet. Drop files here, use Upload, or ask the AI to put files in ${areaLabel.value}.`:`This folder is empty.`),1)),hasMore.value?(openBlock(),createBlock(VBtn,{key:2,class:`ma-3 align-self-start`,variant:`text`,disabled:busy.value,onClick:_cache[10]||(_cache[10]=$event=>loadDirectory(directory.value,true))},{default:withCtx(()=>[..._cache[21]||(_cache[21]=[createTextVNode(`Load more`,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true)],64)),createVNode(VDialog,{modelValue:dialogOpen.value,"onUpdate:modelValue":_cache[13]||(_cache[13]=$event=>dialogOpen.value=$event),"max-width":`460`,persistent:busy.value},{default:withCtx(()=>[createVNode(VCard,{title:dialogOperation.value===`delete`?`Delete from ${areaLabel.value}?`:dialogOperation.value===`rename`?`Rename item`:`New folder`},{default:withCtx(()=>[createVNode(VCardText,null,{default:withCtx(()=>[dialogOperation.value===`delete`?(openBlock(),createElementBlock(`p`,_hoisted_11,toDisplayString(dialogEntry.value?.name)+toDisplayString(dialogEntry.value?.type===`directory`?` and everything inside it will be deleted.`:` will be deleted.`),1)):(openBlock(),createBlock(VTextField,{key:1,modelValue:dialogName.value,"onUpdate:modelValue":_cache[11]||(_cache[11]=$event=>dialogName.value=$event),label:`Name`,autofocus:``,disabled:busy.value,"error-messages":nameError.value,onKeyup:withKeys(confirmDialog,[`enter`])},null,8,[`modelValue`,`disabled`,`error-messages`]))]),_:1}),createVNode(VCardActions,null,{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{disabled:busy.value,onClick:_cache[12]||(_cache[12]=$event=>dialogOpen.value=false)},{default:withCtx(()=>[..._cache[22]||(_cache[22]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:dialogOperation.value===`delete`?`error`:`primary`,disabled:busy.value,onClick:confirmDialog},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Working…`:dialogOperation.value===`delete`?`Delete`:dialogOperation.value===`rename`?`Rename`:`Create`),1)]),_:1},8,[`color`,`disabled`])]),_:1})]),_:1},8,[`title`])]),_:1},8,[`modelValue`,`persistent`])],42,_hoisted_1)}}};var Vibe64SessionFileArea_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-af3b0d40`]]);var _sfc_main=Object.assign({inheritAttrs:false},{__name:`Vibe64SessionFiles`,props:{repoAvailable:{type:Boolean,default:true},archived:{type:Boolean,default:false},active:{type:Boolean,default:true},agentActive:{type:Boolean,default:false},sessionId:{type:String,required:true},sessionsApiPath:{type:String,required:true},projectSlug:{type:String,default:``},openRequest:{type:Object,default:null}},emits:[`ask-assistant-about-file`,`open-program`],setup(__props){const props=__props;const area=ref(props.archived||!props.repoAvailable?`drop-zone`:`repo`);const visitedAreas=ref([]);watch(area,value=>{if(value!==`repo`&&!visitedAreas.value.includes(value))visitedAreas.value.push(value)},{immediate:true});const areas=ref([`repo`]);const mountedAreas=computed(()=>visitedAreas.value.filter(value=>areas.value.includes(value)));const areaError=ref(``);const loadingAreas=ref(false);let generation=0;async function loadAreas(){const current=++generation;areas.value=[`repo`];areaError.value=``;loadingAreas.value=true;try{const result=await getHttpWebClient().request(vibe64SessionPath(props.sessionsApiPath,props.sessionId,`/files`));if(result?.ok===false)throw new Error(vibe64ApiResponseError(result,`File areas could not load.`));if(current!==generation)return;areas.value=result.areas;if(props.archived)area.value=areas.value.includes(`session`)?`session`:`drop-zone`;else if(!props.repoAvailable)area.value=`drop-zone`;else if(!areas.value.includes(area.value))area.value=`repo`}catch(error){if(current===generation){areaError.value=error.message;area.value=`repo`}}finally{if(current===generation)loadingAreas.value=false}}watch(()=>[props.sessionsApiPath,props.sessionId],loadAreas,{immediate:true});watch(()=>props.openRequest,()=>{area.value=`repo`});onScopeDispose(()=>{generation+=1});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{class:normalizeClass([`vibe64-session-files`,_ctx.$attrs.class]),style:normalizeStyle(_ctx.$attrs.style),"aria-label":`Session files`},[createVNode(VTabs,{modelValue:area.value,"onUpdate:modelValue":_cache[0]||(_cache[0]=$event=>area.value=$event),density:`compact`,"aria-label":`File areas`,disabled:loadingAreas.value},{default:withCtx(()=>[createVNode(VTab,{disabled:__props.archived||!__props.repoAvailable,value:`repo`,"prepend-icon":unref(mdiSourceRepository)},{default:withCtx(()=>[..._cache[3]||(_cache[3]=[createTextVNode(`Repo`,-1)])]),_:1},8,[`disabled`,`prepend-icon`]),areas.value.includes(`drop-zone`)?(openBlock(),createBlock(VTab,{key:0,value:`drop-zone`,"prepend-icon":unref(mdiTrayArrowUp)},{default:withCtx(()=>[..._cache[4]||(_cache[4]=[createTextVNode(`Session Dropzone`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),areas.value.includes(`backups`)?(openBlock(),createBlock(VTab,{key:1,value:`backups`,"prepend-icon":unref(mdiArchiveClockOutline)},{default:withCtx(()=>[..._cache[5]||(_cache[5]=[createTextVNode(`Project Backups (2w retention)`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),areas.value.includes(`session`)?(openBlock(),createBlock(VTab,{key:2,value:`session`,"prepend-icon":unref(mdiArchiveClockOutline)},{default:withCtx(()=>[..._cache[6]||(_cache[6]=[createTextVNode(`Session`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true)]),_:1},8,[`modelValue`,`disabled`]),areaError.value?(openBlock(),createBlock(VAlert,{key:0,type:`error`,variant:`tonal`,density:`compact`},{default:withCtx(()=>[createTextVNode(toDisplayString(areaError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:loadAreas},{default:withCtx(()=>[..._cache[7]||(_cache[7]=[createTextVNode(`Retry`,-1)])]),_:1})]),_:1})):createCommentVNode(``,true),!__props.archived&&__props.repoAvailable?withDirectives((openBlock(),createBlock(Vibe64SessionSourceEditor_default,mergeProps({key:1},_ctx.$attrs,{class:`vibe64-session-files__content`,active:__props.active&&area.value===`repo`,"agent-active":__props.agentActive,"session-id":__props.sessionId,"sessions-api-path":__props.sessionsApiPath,"project-slug":__props.projectSlug,"open-request":__props.openRequest,onAskAssistantAboutFile:_cache[1]||(_cache[1]=$event=>_ctx.$emit(`ask-assistant-about-file`,$event)),onOpenProgram:_cache[2]||(_cache[2]=$event=>_ctx.$emit(`open-program`,$event))}),null,16,[`active`,`agent-active`,`session-id`,`sessions-api-path`,`project-slug`,`open-request`])),[[vShow,area.value===`repo`]]):createCommentVNode(``,true),(openBlock(true),createElementBlock(Fragment,null,renderList(mountedAreas.value,visitedArea=>{return withDirectives((openBlock(),createBlock(Vibe64SessionFileArea_default,{key:`${__props.sessionId}:${visitedArea}`,class:`vibe64-session-files__content`,active:__props.active&&area.value===visitedArea,area:visitedArea,archived:__props.archived,"session-id":__props.sessionId,"sessions-api-path":__props.sessionsApiPath,"project-slug":__props.projectSlug,"agent-active":__props.agentActive},null,8,[`active`,`area`,`archived`,`session-id`,`sessions-api-path`,`project-slug`,`agent-active`])),[[vShow,area.value===visitedArea]])}),128))],6)}}});var Vibe64SessionFiles_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-929f9f95`]]);export{Vibe64StarredFilesList_default as a,conversationAttribution as c,_sfc_main$11 as d,_sfc_main$12 as f,assistantAttachmentFilesFromPasteEvent as h,sourceEditorLinkTarget as i,Vibe64ConversationStatus_default as l,useVibe64AttachmentCommands as m,Vibe64SessionSourceEditor_default as n,thinkingMessagePresentation as o,useAgentAttachments as p,Vibe64ConversationLog_default as r,usesCommentaryForThinking as s,Vibe64SessionFiles_default as t,_sfc_main$10 as u};
|
|
40
|
+
`);editor.explainSelection({scope:`file`,presentation:`description`,force,expectedHash:editor.savedHash.value,startLine:1,startColumn:1,endLine:lines.length,endColumn:lines.at(-1).length+1})}function presentInterfaceSymbol(presentation,force=false){symbolPresentation.value=presentation;const symbol=interfaceSymbol.value;if(presentation!==`steps`||!Array.isArray(symbol?.parameters)||!symbol?.end||!interfaceCurrent.value||!props.assistantAvailable||editor.explanationBusy.value||editor.explanationClosing.value)return;if(!force&¤tInterpretation(`selection`,symbol.id,presentation))return;editor.explainSelection({scope:`selection`,symbolId:symbol.id,presentation,force,expectedHash:editor.savedHash.value,startLine:symbol.start.line,startColumn:symbol.start.column,endLine:symbol.end.line,endColumn:symbol.end.column})}const markdownRenderable=computed(()=>!props.singleFile&&sourceEditorPathIsMarkdown(editor.selectedPath.value));const markdownRenderer=new F({async:false,gfm:true,walkTokens(token){const path=token.type===`image`&&markdownDocumentLinkTarget(editor.selectedPath.value,token.href);if(path)token.href=scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(readRefOrGetterValue(props.sessionsApiPath),props.sessionId,path),props.projectSlug)}});const renderedMarkdownHtml=computed(()=>filePresentation.value===`rendered`?markdownRenderer.parse(editor.text.value):``);watch(editor.selectedPath,()=>{const codeRequested=props.codeFocusMode||props.openRequest?.presentation===`code`&&props.openRequest?.path===editor.selectedPath.value;filePresentation.value=codeRequested?`code`:markdownRenderable.value?`rendered`:`interface`;interfaceSymbolId.value=``;symbolPresentation.value=`description`});function openMarkdownLink(event){const anchor=event.target?.closest?.(`a[href]`);if(!anchor)return;event.preventDefault();const target=anchor.getAttribute(`href`).trim();if(/^(?:https?:|mailto:)/iu.test(target)){globalThis.open?.(target,`_blank`,`noopener,noreferrer`);return}const path=markdownDocumentLinkTarget(editor.selectedPath.value,target);if(path)editor.openFile(path)}watch([interfaceSymbols,interfaceCurrent,()=>props.openRequest],()=>{if(props.openRequest?.path!==editor.selectedPath.value||!interfaceCurrent.value)return;const requested=interfaceSymbols.value.find(symbol=>symbol.id===props.openRequest.symbolId||props.openRequest.symbol&&(symbol.qualifiedName===props.openRequest.symbol||symbol.name===props.openRequest.symbol));if(requested&&requested.id!==interfaceSymbolId.value)selectInterfaceSymbol(requested.id);if(props.openRequest.symbolPresentation)symbolPresentation.value=props.openRequest.symbolPresentation});watch([editor.selectedPath,interfaceSymbolId,filePresentation,symbolPresentation],()=>{if(props.singleFile&&props.active&&interfaceCurrent.value&&editor.selectedPath.value)emit(`interface-location`,{path:editor.selectedPath.value,symbolId:interfaceSymbolId.value,presentation:filePresentation.value,symbolPresentation:symbolPresentation.value})},{flush:`post`});const displayedPath=computed(()=>editor.downloadOnlyFile.value?.path||editor.selectedPath.value);const imagePreviewStatus=ref(`loading`);const imagePreviewVersion=ref(0);const imagePreviewUrl=computed(()=>{const filePath=editor.downloadOnlyFile.value?.path||``;if(editor.loadingFile.value||!/\.(?:png|jpe?g|gif|webp|avif|bmp|ico)$/iu.test(filePath))return``;return scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(readRefOrGetterValue(props.sessionsApiPath),props.sessionId,filePath),props.projectSlug)});watch([imagePreviewUrl,imagePreviewVersion],()=>{imagePreviewStatus.value=`loading`},{immediate:true});function refreshFiles(){imagePreviewVersion.value+=1;editor.refresh()}const selectedStarred=computed(()=>props.fileBookmarks?.paths.value.includes(displayedPath.value)||false);const downloadingPath=ref(``);const downloadDraftOpen=ref(false);const downloadSaving=ref(false);const downloadError=ref(``);let draftDownload=null;const downloadFeedback=useUiFeedback({source:`vibe64.source-editor.download`});function requestDownload(filePath){if(!filePath||downloadingPath.value)return;const target={path:filePath,sessionId:props.sessionId,sessionsApiPath:readRefOrGetterValue(props.sessionsApiPath),projectSlug:props.projectSlug};if(filePath===editor.selectedPath.value&&(editor.dirty.value||editor.saving.value)){draftDownload=target;downloadError.value=``;downloadDraftOpen.value=true}else downloadFile(target)}async function downloadFile(target){downloadingPath.value=target.path;try{await downloadAttachment(scopedDevelopmentApiUrl(vibe64SourceEditorDownloadPath(target.sessionsApiPath,target.sessionId,target.path),target.projectSlug),basename(target.path),`File could not download. Check your connection and access, then retry.`)}catch(cause){downloadFeedback.error(cause,`File could not download.`)}finally{downloadingPath.value=``}}function downloadSavedDraft(){downloadDraftOpen.value=false;downloadFile(draftDownload)}async function saveAndDownload(){downloadSaving.value=true;await editor.saveNow();downloadSaving.value=false;if(editor.dirty.value||editor.saveError.value){downloadError.value=editor.saveError.value||`The file still has unsaved edits.`;return}downloadSavedDraft()}watch([()=>props.active,()=>props.agentActive],([active,working],[wasActive,wasWorking])=>{if(active&&(!wasActive||wasWorking&&!working))props.fileBookmarks?.refresh()});watch(()=>props.sessionId,()=>{downloadDraftOpen.value=false});const languageCompartment=new Compartment;const lineWrappingCompartment=new Compartment;const editorPerformanceSetup=[lineNumbers(),highlightActiveLineGutter(),history(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),syntaxHighlighting(defaultHighlightStyle,{fallback:true}),bracketMatching(),rectangularSelection(),crosshairCursor(),keymap.of([indentWithTab,...defaultKeymap,...historyKeymap,...searchKeymap])];const sourcePathClickExtension=EditorView.domEventHandlers({click(event,view){if(!sourcePathNavigationGesture(event)||event.button!==0)return false;const sourcePath=sourcePathReferenceAtEvent(view,event);if(!sourcePath)return false;event.preventDefault();event.stopPropagation();editor.openReferencedSourcePath({fromPath:editor.selectedPath.value,target:sourcePath.target});return true},mouseleave(_event,view){setSourcePathHoverState(view,false);return false},mousemove(event,view){setSourcePathHoverState(view,Boolean(sourcePathNavigationGesture(event)&&sourcePathReferenceAtEvent(view,event)));return false}});const expandedDirectoryPaths=ref([]);const explanationCollapsed=ref(false);const{smAndDown:mobile}=useDisplay();const fileListCollapsed=ref(mobile.value);const newFileDialogOpen=ref(false);const sourceEditorElement=ref(null);const newFileDirectory=ref(``);const newFileError=ref(``);const newFileName=ref(``);const treeStateStorageKey=computed(()=>sourceEditorTreeStateStorageKey({sessionId:props.sessionId,sessionsApiPath:props.sessionsApiPath}));const fastOpenPanelVisible=computed(()=>Boolean(editor.fileQuery.value));const searchPanelVisible=computed(()=>Boolean(editor.searchQuery.value)||editor.searchResults.value.length>0);const selectedFileName=computed(()=>editor.loadingPath.value||displayedPath.value?basename(editor.loadingPath.value||displayedPath.value):`Choose a source file`);const newFileDirectoryLabel=computed(()=>newFileDirectory.value?`Create in ${newFileDirectory.value}`:`Create in source root`);const newFilePath=computed(()=>{const name=normalizeNewFileEntryPath(newFileName.value);if(!name)return``;return newFileDirectory.value?`${newFileDirectory.value}/${name}`:name});const newFileCreateDisabled=computed(()=>Boolean(editor.creatingFile.value||!newFilePath.value));function normalizeNewFileEntryPath(value=``){const raw=normalizeSourceEditorPath(value).replace(/\/+$/u,``);if(!raw||raw.startsWith(`/`))return``;const parts=raw.split(`/`).filter(Boolean);if(!parts.length||parts.some(part=>part===`.`||part===`..`))return``;return parts.join(`/`)}function basename(filePath=``){return String(filePath||``).split(`/`).at(-1)||filePath}function searchResultTitle(result={}){return`${result.path||``}:${result.line||1}:${result.column||1}`}async function focusAfterLayout(rootElement=null,selector=``){await nextTick();if(sourceEditorUnmounted)return;if(explanationFocusTimer)clearTimeout(explanationFocusTimer);explanationFocusTimer=setTimeout(()=>{explanationFocusTimer=null;rootElement?.querySelector?.(selector)?.focus?.()},0)}function collapseExplanation(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;explanationCollapsed.value=true;focusAfterLayout(rootElement,`.vibe64-source-editor__side-rail--right`)}function expandExplanation(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;explanationCollapsed.value=false;focusAfterLayout(rootElement,`.vibe64-source-explanation__range`)}async function closeExplanationPanel(event={}){const rootElement=event?.currentTarget?.closest?.(`.vibe64-source-editor`)||sourceEditorElement.value;if(await editor.closeExplanation())focusAfterLayout(rootElement,`.vibe64-source-editor__explain-button`)}function collapseFileList(){fileListCollapsed.value=true}function expandFileList(){fileListCollapsed.value=false}function addExpandedDirectoryPaths(paths=[]){const normalizedPaths=normalizeSourceEditorDirectoryPaths(paths);if(!normalizedPaths.length)return;expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths([...expandedDirectoryPaths.value,...normalizedPaths])}function parentDirectoryPathsFor(filePath=``){const parts=normalizeSourceEditorPath(filePath).split(`/`).filter(Boolean);const paths=[];for(let index=1;index<parts.length;index+=1)paths.push(parts.slice(0,index).join(`/`));return paths}function openNewFileDialog(directoryPath=``){newFileDirectory.value=normalizeSourceEditorPath(directoryPath);newFileName.value=``;newFileError.value=``;newFileDialogOpen.value=true}function closeNewFileDialog(){if(editor.creatingFile.value)return;newFileDialogOpen.value=false;newFileError.value=``}async function submitNewFile(){const filePath=newFilePath.value;if(!filePath||editor.creatingFile.value){if(String(newFileName.value||``).trim())newFileError.value=`Enter a nested file path without absolute or parent-directory segments.`;return}if(!await editor.createFile(filePath)){newFileError.value=editor.createFileError.value||`Source file could not be created.`;return}addExpandedDirectoryPaths(parentDirectoryPathsFor(filePath));newFileDialogOpen.value=false;newFileError.value=``;if(mobile.value)collapseFileList()}async function copySourcePath(path=``){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath)return;try{await writeClipboardText(normalizedPath)}catch{}}function askAssistantAboutPath(path=``){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath||!props.assistantDraftAvailable)return;emit(`ask-assistant-about-file`,normalizedPath)}function sourceEditorTreeStateStorageKey({sessionId=``,sessionsApiPath=``}={}){const normalizedSessionId=String(sessionId||``).trim();const normalizedSessionsApiPath=String(sessionsApiPath||``).trim();if(!normalizedSessionId||!normalizedSessionsApiPath)return``;return[SOURCE_EDITOR_TREE_STATE_STORAGE_KEY,stableLocalStorageKeyPart(normalizedSessionsApiPath),stableLocalStorageKeyPart(normalizedSessionId)].join(`:`)}function languageExtension(filePath=``){const lowerPath=String(filePath||``).toLowerCase();if(lowerPath.endsWith(`.vue`))return htmlSourceLanguage({matchClosingTags:false});if(/\.(html|htm|xhtml|svg)$/u.test(lowerPath))return htmlSourceLanguage();if(/\.(js|jsx|mjs|cjs)$/u.test(lowerPath))return javascript({jsx:true});if(/\.(ts|tsx)$/u.test(lowerPath))return javascript({jsx:lowerPath.endsWith(`.tsx`),typescript:true});if(lowerPath.endsWith(`.json`))return json();if(/\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$/u.test(lowerPath))return cpp();if(/\.(sh|bash|zsh|fish)$/u.test(lowerPath))return StreamLanguage.define(shell);if(sourceEditorPathIsMarkdown(lowerPath))return markdown();return[]}function sourceEditorPathIsMarkdown(filePath=``){const lowerPath=String(filePath||``).toLowerCase();return/\.(md|markdown|todo)$/u.test(lowerPath)||/(^|\/)todo$/u.test(lowerPath)}function sourceEditorLineWrappingExtension(filePath=``){return sourceEditorPathIsMarkdown(filePath)?EditorView.lineWrapping:[]}function htmlSourceLanguage(options={}){return html({selfClosingTags:true,...options,nestedLanguages:[{attrs:(attrs={})=>[`ts`,`typescript`].includes(String(attrs.lang||``).toLowerCase()),parser:typescriptLanguage.parser,tag:`script`},{attrs:(attrs={})=>String(attrs.lang||``).toLowerCase()===`jsx`,parser:jsxLanguage.parser,tag:`script`},{attrs:(attrs={})=>String(attrs.lang||``).toLowerCase()===`tsx`,parser:tsxLanguage.parser,tag:`script`}]})}function sourcePathModifierPressed(event={}){return event.ctrlKey||event.metaKey}function sourcePathNavigationGesture(event={}){return props.sourcePathClickWithoutModifier||sourcePathModifierPressed(event)}function setSourcePathHoverState(view,active=false){view.dom.classList.toggle(`vibe64-source-editor__codemirror--source-link-hover`,active)}function sourcePathReferenceAtEvent(view,event={}){const position=view.posAtCoords({x:event.clientX,y:event.clientY});if(position==null)return null;const line=view.state.doc.lineAt(position);return sourcePathReferenceAtLineColumn(line.text,position-line.from)}function createEditor(){if(!editorElement.value||editorView)return;editorView=new EditorView({parent:editorElement.value,state:EditorState.create({doc:editor.text.value,extensions:[editorPerformanceSetup,sourcePathClickExtension,languageCompartment.of(languageExtension(editor.selectedPath.value)),lineWrappingCompartment.of(sourceEditorLineWrappingExtension(editor.selectedPath.value)),EditorView.updateListener.of(update=>{if(!update.docChanged||resettingEditor)return;editor.updateText()}),EditorView.theme({"&":{backgroundColor:`rgb(var(--v-theme-surface))`,color:`rgb(var(--v-theme-on-surface))`,fontSize:`13px`,height:`100%`},".cm-content":{caretColor:`rgb(var(--v-theme-primary))`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`rgb(var(--v-theme-surface))`,backgroundImage:`linear-gradient(rgba(var(--v-theme-surface-variant), 0.38), rgba(var(--v-theme-surface-variant), 0.38))`,borderRight:`1px solid rgba(var(--v-border-color), 0.28)`,color:`rgba(var(--v-theme-on-surface), 0.56)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace`},".cm-selectionBackground":{backgroundColor:`rgba(var(--v-theme-primary), 0.22)`}})]})});renderedEditorPath=editor.selectedPath.value}function replaceEditorDocument(){if(!editorView)return;const selectedPath=editor.selectedPath.value;const sameFile=renderedEditorPath===selectedPath;const currentText=editorView.state.doc.toString();const changes=editorView.state.changes(sameFile?sourceEditorDocumentChanges(currentText,editor.text.value):[{from:0,insert:editor.text.value,to:currentText.length}]);const effects=[languageCompartment.reconfigure(languageExtension(selectedPath)),lineWrappingCompartment.reconfigure(sourceEditorLineWrappingExtension(selectedPath))];const cursorRequest=editor.cursorRequest.value;const explicitCursorRequest=cursorRequest?.path===selectedPath&&Number(cursorRequest.line||0)>0;if(sameFile&&!explicitCursorRequest){const scrollSnapshot=editorView.scrollSnapshot().map(changes);if(scrollSnapshot)effects.unshift(scrollSnapshot)}resettingEditor=true;try{editorView.dispatch({changes,effects})}finally{resettingEditor=false}renderedEditorPath=selectedPath;applyCursorRequest()}function applyCursorRequest(){if(!editorView)return;const request=editor.cursorRequest.value;const line=Number(request?.line||0);if(!line)return;const boundedLine=Math.max(1,Math.min(line,editorView.state.doc.lines));const lineInfo=editorView.state.doc.line(boundedLine);const column=Math.max(0,Number(request?.column||1)-1);const anchor=Math.min(lineInfo.to,lineInfo.from+column);editorView.dispatch({selection:{anchor},scrollIntoView:true});if(filePresentation.value===`code`)editorView.focus()}function runEditorCommand(command=``){if(!editorView)return;if(command===`undo`)undo(editorView);else if(command===`redo`)redo(editorView)}function currentEditorSelectionRange(){if(!editorView)return{endColumn:1,endLine:1,startColumn:1,startLine:1};const selection=editorView.state.selection.main;const from=Math.min(selection.from,selection.to);const to=Math.max(selection.from,selection.to);const fromLine=editorView.state.doc.lineAt(from);const toLine=editorView.state.doc.lineAt(to);if(selection.empty){const firstLine=editorView.state.doc.line(1);const lastLine=editorView.state.doc.line(editorView.state.doc.lines);return{endColumn:Math.max(1,lastLine.length+1),endLine:lastLine.number,scope:`file`,startColumn:1,startLine:firstLine.number}}return{endColumn:Math.max(1,to-toLine.from+1),endLine:toLine.number,scope:`selection`,startColumn:Math.max(1,from-fromLine.from+1),startLine:fromLine.number}}function explainCurrentSelection(){if(!props.assistantAvailable)return false;editor.explainSelection(currentEditorSelectionRange());return true}function retryExplanation(){if(!props.assistantAvailable)return false;editor.retryExplanation();return true}function sendExplanationFollowup(){if(!props.assistantAvailable)return false;editor.sendExplanationFollowup();return true}function openExplanationRange(explanation={}){const sourceRange=explanation?.sourceRange||{};if(sourceRange.path)editor.openFile(sourceRange.path,{column:sourceRange.startColumn,line:sourceRange.startLine})}function openExplanationSourceLink(sourceLink={}){const path=String(sourceLink?.path||``).trim();if(!path)return;editor.openFile(path,{column:Number(sourceLink.column||0)||0,line:Number(sourceLink.line||0)||0})}function handleDirectoryOpenChange({open=false,path=``}={}){const normalizedPath=normalizeSourceEditorPath(path);if(!normalizedPath)return;const nextPaths=new Set(expandedDirectoryPaths.value);if(open){nextPaths.add(normalizedPath);editor.loadDirectory(normalizedPath)}else nextPaths.delete(normalizedPath);expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths([...nextPaths])}function closeAllDirectories(){expandedDirectoryPaths.value=[]}watch(mobile,compact=>{fileListCollapsed.value=compact});watch(editor.loadingPath,filePath=>{if(mobile.value&&filePath)collapseFileList()});watch(()=>props.openRequest,(request=null)=>{if(request?.path){if(request.path===editor.selectedPath.value&&request.presentation===`code`)showWholeFileCode();if(request.presentation===`interface`)filePresentation.value=`interface`;editor.openRequest(request)}},{deep:true,immediate:true});watch(()=>props.active,async active=>{if(!active)return;await nextTick();editorView?.requestMeasure?.()});watch(editor.loadedVersion,()=>{replaceEditorDocument()});watch(()=>editor.activeExplanation.value?.id||``,(explanationId=``)=>{if(explanationId)explanationCollapsed.value=false});watch(editor.revealedDirectoryPaths,paths=>{addExpandedDirectoryPaths(paths)});watch(treeStateStorageKey,(storageKey=``)=>{expandedDirectoryPaths.value=normalizeSourceEditorDirectoryPaths(readLocalStorageJson(storageKey,[]))},{immediate:true});watch(expandedDirectoryPaths,paths=>{if(treeStateStorageKey.value)writeLocalStorageJson(treeStateStorageKey.value,normalizeSourceEditorDirectoryPaths(paths))});onMounted(()=>{createEditor()});onBeforeUnmount(()=>{sourceEditorUnmounted=true;if(explanationFocusTimer){clearTimeout(explanationFocusTimer);explanationFocusTimer=null}editorView?.destroy();editorView=null;renderedEditorPath=``});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{ref_key:`sourceEditorElement`,ref:sourceEditorElement,class:normalizeClass([`vibe64-source-editor`,{"vibe64-source-editor--code-focus":__props.codeFocusMode,"vibe64-source-editor--mobile":unref(mobile),"vibe64-source-editor--mobile-file-open":unref(mobile)&&fileListCollapsed.value}]),"aria-label":`Session source editor`},[!__props.singleFile||filePresentation.value===`code`?(openBlock(),createElementBlock(`header`,_hoisted_1$1,[!__props.singleFile&&unref(mobile)&&!__props.codeFocusMode?(openBlock(),createBlock(VBtn,{key:0,"aria-expanded":!fileListCollapsed.value,"aria-label":fileListCollapsed.value?`Show files`:`Hide files`,icon:fileListCollapsed.value?unref(mdiFolderOutline):unref(mdiClose),variant:`text`,onClick:_cache[0]||(_cache[0]=$event=>fileListCollapsed.value?expandFileList():collapseFileList())},null,8,[`aria-expanded`,`aria-label`,`icon`])):createCommentVNode(``,true),createBaseVNode(`div`,_hoisted_2$1,[!unref(mobile)?(openBlock(),createBlock(VIcon,{key:0,icon:unref(mdiFileCodeOutline),size:`19`},null,8,[`icon`])):createCommentVNode(``,true),createBaseVNode(`h2`,{title:unref(editor).loadingPath.value||displayedPath.value||`Choose a source file`},toDisplayString(selectedFileName.value),9,_hoisted_3$1)]),unref(editor).selectedPath.value&&markdownRenderable.value?(openBlock(),createBlock(VBtn,{key:1,"min-height":`48`,variant:`text`,title:filePresentation.value===`rendered`?`Show the Markdown source`:`Show the formatted document`,onClick:_cache[1]||(_cache[1]=$event=>filePresentation.value=filePresentation.value===`rendered`?`code`:`rendered`)},{default:withCtx(()=>[createTextVNode(toDisplayString(filePresentation.value===`rendered`?`Markdown`:`Rendered`),1)]),_:1},8,[`title`])):unref(editor).selectedPath.value?(openBlock(),createBlock(VBtn,{key:2,"min-height":`48`,variant:`text`,onClick:_cache[2]||(_cache[2]=$event=>filePresentation.value=filePresentation.value===`code`?`interface`:`code`)},{default:withCtx(()=>[createTextVNode(toDisplayString(filePresentation.value===`code`?`Interface`:`Code`),1)]),_:1})):createCommentVNode(``,true),unref(mobile)?(openBlock(),createElementBlock(`div`,_hoisted_4$1,[createVNode(VBtn,{disabled:!unref(editor).dirty.value||unref(editor).saving.value,"aria-label":unref(editor).saving.value?`Saving file`:`Save now`,icon:unref(mdiContentSaveOutline),variant:`tonal`,onClick:unref(editor).saveNow},null,8,[`disabled`,`aria-label`,`icon`,`onClick`]),createVNode(VMenu,null,{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps(menuProps,{icon:unref(mdiDotsVertical),"aria-label":`File actions`,variant:`text`}),null,16,[`icon`])]),default:withCtx(()=>[createVNode(VList,{density:`compact`},{default:withCtx(()=>[unref(editor).statusLabel.value?(openBlock(),createBlock(VListItem,{key:0,title:unref(editor).statusLabel.value,class:normalizeClass({"text-error":unref(editor).saveError.value})},null,8,[`title`,`class`])):createCommentVNode(``,true),__props.fileBookmarks?(openBlock(),createBlock(VListItem,{key:1,title:selectedStarred.value?`Unstar file`:`Star file`,"prepend-icon":selectedStarred.value?unref(mdiStar):unref(mdiStarOutline),disabled:!displayedPath.value||__props.fileBookmarks.pendingPaths.value.includes(displayedPath.value),onClick:_cache[3]||(_cache[3]=$event=>__props.fileBookmarks.toggle(displayedPath.value))},null,8,[`title`,`prepend-icon`,`disabled`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Download file`,"prepend-icon":unref(mdiDownload),disabled:!displayedPath.value||unref(editor).loadingFile.value||Boolean(downloadingPath.value),onClick:_cache[4]||(_cache[4]=$event=>requestDownload(displayedPath.value))},null,8,[`prepend-icon`,`disabled`]),createVNode(VListItem,{title:`Undo`,"prepend-icon":unref(mdiUndoVariant),disabled:!unref(editor).selectedPath.value,onClick:_cache[5]||(_cache[5]=$event=>runEditorCommand(`undo`))},null,8,[`prepend-icon`,`disabled`]),createVNode(VListItem,{title:`Redo`,"prepend-icon":unref(mdiRedoVariant),disabled:!unref(editor).selectedPath.value,onClick:_cache[6]||(_cache[6]=$event=>runEditorCommand(`redo`))},null,8,[`prepend-icon`,`disabled`]),!__props.singleFile?(openBlock(),createBlock(VListItem,{key:2,title:`Explain file or selection`,"prepend-icon":unref(mdiRobotOutline),disabled:!__props.assistantAvailable||!unref(editor).selectedPath.value||unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,onClick:explainCurrentSelection},null,8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Refresh files`,"prepend-icon":unref(mdiRefresh),disabled:unref(editor).loadingTree.value,onClick:refreshFiles},null,8,[`prepend-icon`,`disabled`])]),_:1})]),_:1})])):(openBlock(),createElementBlock(`div`,_hoisted_5$1,[__props.fileBookmarks?(openBlock(),createBlock(VBtn,{key:0,"aria-label":selectedStarred.value?`Unstar file`:`Star file`,"aria-pressed":selectedStarred.value,disabled:!displayedPath.value||__props.fileBookmarks.pendingPaths.value.includes(displayedPath.value),icon:selectedStarred.value?unref(mdiStar):unref(mdiStarOutline),size:`small`,title:selectedStarred.value?`Unstar file`:`Star file`,variant:`text`,onClick:_cache[7]||(_cache[7]=$event=>__props.fileBookmarks.toggle(displayedPath.value))},null,8,[`aria-label`,`aria-pressed`,`disabled`,`icon`,`title`])):createCommentVNode(``,true),createVNode(VBtn,{"aria-label":`Download file`,disabled:!displayedPath.value||unref(editor).loadingFile.value||Boolean(downloadingPath.value),icon:unref(mdiDownload),size:`small`,title:downloadingPath.value?`Downloading file…`:`Download file`,variant:`text`,onClick:_cache[8]||(_cache[8]=$event=>requestDownload(displayedPath.value))},null,8,[`disabled`,`icon`,`title`]),unref(editor).statusLabel.value?(openBlock(),createElementBlock(`span`,{key:1,class:normalizeClass([`vibe64-source-editor__status`,{"vibe64-source-editor__status--error":unref(editor).saveError.value}])},toDisplayString(unref(editor).statusLabel.value),3)):createCommentVNode(``,true),createVNode(VBtn,{disabled:!unref(editor).selectedPath.value,icon:unref(mdiUndoVariant),size:`small`,title:`Undo`,type:`button`,variant:`text`,onClick:_cache[9]||(_cache[9]=$event=>runEditorCommand(`undo`))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{disabled:!unref(editor).selectedPath.value,icon:unref(mdiRedoVariant),size:`small`,title:`Redo`,type:`button`,variant:`text`,onClick:_cache[10]||(_cache[10]=$event=>runEditorCommand(`redo`))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{disabled:!unref(editor).dirty.value||unref(editor).saving.value,icon:unref(mdiContentSaveOutline),loading:unref(editor).saving.value,size:`small`,title:`Save now`,type:`button`,variant:`tonal`,onClick:unref(editor).saveNow},null,8,[`disabled`,`icon`,`loading`,`onClick`]),!__props.singleFile?(openBlock(),createBlock(VBtn,{key:2,class:`vibe64-source-editor__explain-button`,"aria-busy":unref(editor).explanationBusy.value||unref(editor).explanationClosing.value?`true`:`false`,color:`primary`,disabled:!__props.assistantAvailable||!unref(editor).selectedPath.value||unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,"prepend-icon":unref(mdiRobotOutline),size:`small`,title:!__props.assistantAvailable?__props.assistantUnavailableMessage:unref(editor).explanationClosing.value?`Closing explanation`:unref(editor).explanationBusy.value?`Explanation in progress`:`Explain file or selection`,type:`button`,variant:`tonal`,onClick:explainCurrentSelection},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(editor).explanationClosing.value?`Closing…`:unref(editor).explanationBusy.value?`Working…`:`Explain`),1)]),_:1},8,[`aria-busy`,`disabled`,`prepend-icon`,`title`])):createCommentVNode(``,true),!__props.singleFile?(openBlock(),createBlock(VBtn,{key:3,disabled:unref(editor).loadingTree.value,icon:unref(mdiRefresh),"aria-busy":unref(editor).loadingTree.value,size:`small`,title:`Refresh files`,type:`button`,variant:`text`,onClick:refreshFiles},null,8,[`disabled`,`icon`,`aria-busy`])):createCommentVNode(``,true)]))])):createCommentVNode(``,true),!__props.singleFile&&!__props.codeFocusMode&&(!unref(mobile)||!fileListCollapsed.value)?(openBlock(),createElementBlock(`div`,_hoisted_6$1,[createBaseVNode(`div`,_hoisted_7$1,[createVNode(VTextField,{autocomplete:`off`,clearable:``,density:`compact`,"hide-details":``,label:`Open file`,"model-value":unref(editor).fileQuery.value,"prepend-inner-icon":unref(mdiFileSearchOutline),variant:`outlined`,onKeydown:withKeys(withModifiers(unref(editor).openFirstFileMatch,[`prevent`]),[`enter`]),"onUpdate:modelValue":unref(editor).updateFileQuery},null,8,[`model-value`,`prepend-inner-icon`,`onKeydown`,`onUpdate:modelValue`]),fastOpenPanelVisible.value?(openBlock(),createElementBlock(`div`,_hoisted_8$1,[unref(editor).fileMatchesLoading.value?(openBlock(),createElementBlock(`div`,_hoisted_9$1,` Finding files... `)):unref(editor).fileMatchesError.value?(openBlock(),createElementBlock(`div`,_hoisted_10$1,toDisplayString(unref(editor).fileMatchesError.value),1)):(openBlock(),createElementBlock(Fragment,{key:2},[(openBlock(true),createElementBlock(Fragment,null,renderList(unref(editor).fileMatches.value,file=>{return openBlock(),createElementBlock(`button`,{key:file.path,class:`vibe64-source-editor__match`,title:file.path,type:`button`,onClick:$event=>unref(editor).openFileMatch(file.path)},[createBaseVNode(`span`,_hoisted_12,toDisplayString(file.name||basename(file.path)),1),createBaseVNode(`span`,_hoisted_13,toDisplayString(file.path),1)],8,_hoisted_11$1)}),128)),!unref(editor).fileMatches.value.length?(openBlock(),createElementBlock(`div`,_hoisted_14,` No matching files. `)):createCommentVNode(``,true),unref(editor).fileMatchesTruncated.value?(openBlock(),createElementBlock(`div`,_hoisted_15,` Keep typing to narrow the list. `)):createCommentVNode(``,true)],64))])):createCommentVNode(``,true)]),createBaseVNode(`div`,_hoisted_16,[createVNode(VTextField,{autocomplete:`off`,clearable:``,density:`compact`,"hide-details":``,label:`Find in files`,"model-value":unref(editor).searchQuery.value,"prepend-inner-icon":unref(mdiMagnify),variant:`outlined`,onKeydown:_cache[11]||(_cache[11]=withKeys(withModifiers($event=>unref(editor).openSearchResult(unref(editor).searchResults.value[0]),[`prevent`]),[`enter`])),"onUpdate:modelValue":unref(editor).updateSearchQuery},null,8,[`model-value`,`prepend-inner-icon`,`onUpdate:modelValue`])])])):createCommentVNode(``,true),createBaseVNode(`div`,{class:normalizeClass([`vibe64-source-editor__body`,{"vibe64-source-editor__body--code-focus":__props.codeFocusMode||__props.singleFile,"vibe64-source-editor__body--file-list-collapsed":fileListCollapsed.value&&!__props.codeFocusMode}])},[!__props.singleFile&&!__props.codeFocusMode?withDirectives((openBlock(),createElementBlock(`aside`,{key:0,class:normalizeClass([`vibe64-source-editor__sidebar`,{"vibe64-source-editor__sidebar--collapsed":fileListCollapsed.value}])},[fileListCollapsed.value?(openBlock(),createElementBlock(`button`,{key:0,"aria-label":`Show files`,class:`vibe64-source-editor__side-rail`,title:`Show files`,type:`button`,onClick:expandFileList},[createVNode(VIcon,{icon:unref(mdiChevronRight),size:`22`},null,8,[`icon`]),_cache[24]||(_cache[24]=createBaseVNode(`span`,null,`Files`,-1))])):(openBlock(),createElementBlock(Fragment,{key:1},[createBaseVNode(`div`,_hoisted_17,[_cache[25]||(_cache[25]=createBaseVNode(`span`,null,`Files`,-1)),createBaseVNode(`div`,_hoisted_18,[createVNode(VBtn,{"aria-label":`New file at source root`,disabled:unref(editor).creatingFile.value||!unref(editor).tree.value,icon:unref(mdiFilePlusOutline),size:`x-small`,title:`New file at source root`,type:`button`,variant:`text`,onClick:_cache[12]||(_cache[12]=$event=>openNewFileDialog(``))},null,8,[`disabled`,`icon`]),createVNode(VBtn,{class:`vibe64-source-editor__collapse-files-button`,"aria-label":`Collapse file list`,icon:unref(mdiChevronLeft),size:`small`,title:`Collapse file list`,type:`button`,variant:`text`,onClick:collapseFileList},null,8,[`icon`]),createVNode(VBtn,{"aria-label":`Close all folders`,disabled:!unref(editor).tree.value||!expandedDirectoryPaths.value.length,icon:unref(mdiCollapseAllOutline),size:`x-small`,title:`Close all folders`,type:`button`,variant:`text`,onClick:closeAllDirectories},null,8,[`disabled`,`icon`])])]),__props.fileBookmarks?(openBlock(),createElementBlock(`details`,{key:0,class:`vibe64-source-editor__starred`,open:__props.fileBookmarks.files.value.length<=4},[createBaseVNode(`summary`,null,[_cache[26]||(_cache[26]=createTextVNode(`Starred `,-1)),createBaseVNode(`span`,null,toDisplayString(__props.fileBookmarks.files.value.length),1)]),createVNode(Vibe64StarredFilesList_default,{bookmarks:__props.fileBookmarks,compact:``,onOpenFile:unref(editor).openFile},null,8,[`bookmarks`,`onOpenFile`])],8,_hoisted_19)):createCommentVNode(``,true),searchPanelVisible.value?(openBlock(),createElementBlock(`section`,_hoisted_20,[createBaseVNode(`div`,_hoisted_21,[_cache[27]||(_cache[27]=createBaseVNode(`span`,null,`Find results`,-1)),createBaseVNode(`small`,null,toDisplayString(unref(editor).searchResults.value.length),1)]),unref(editor).searchIndexLabel.value?(openBlock(),createElementBlock(`div`,{key:0,class:normalizeClass([`vibe64-source-editor__notice`,{"vibe64-source-editor__notice--error":unref(editor).searchIndex.value?.state===`error`}]),role:`status`},toDisplayString(unref(editor).searchIndexLabel.value),3)):createCommentVNode(``,true),unref(editor).searchLoading.value&&!unref(editor).searchResults.value.length?(openBlock(),createElementBlock(`div`,_hoisted_22,` Searching files... `)):unref(editor).searchError.value?(openBlock(),createElementBlock(`div`,_hoisted_23,toDisplayString(unref(editor).searchError.value),1)):!unref(editor).searchResults.value.length&&unref(editor).searchIndex.value?.state!==`error`?(openBlock(),createElementBlock(`div`,_hoisted_24,toDisplayString(unref(editor).searchIndexPending.value?`Results will appear as files are indexed.`:`No results.`),1)):(openBlock(true),createElementBlock(Fragment,{key:4},renderList(unref(editor).searchResults.value,result=>{return openBlock(),createElementBlock(`button`,{key:`${result.path}:${result.line}:${result.column}:${result.preview}`,class:`vibe64-source-editor__search-result`,title:searchResultTitle(result),type:`button`,onClick:$event=>unref(editor).openSearchResult(result)},[createBaseVNode(`span`,_hoisted_26,toDisplayString(result.path),1),createBaseVNode(`span`,_hoisted_27,`Line `+toDisplayString(result.line),1),createBaseVNode(`span`,_hoisted_28,toDisplayString(result.preview),1)],8,_hoisted_25)}),128)),unref(editor).searchTruncated.value?(openBlock(),createElementBlock(`div`,_hoisted_29,` Search stopped at the first matches. Narrow the query for more precision. `)):createCommentVNode(``,true)])):createCommentVNode(``,true),unref(editor).loadingTree.value&&!unref(editor).tree.value?(openBlock(),createElementBlock(`div`,_hoisted_30,` Loading files... `)):unref(editor).loadError.value&&!unref(editor).tree.value?(openBlock(),createElementBlock(`div`,_hoisted_31,toDisplayString(unref(editor).loadError.value),1)):unref(editor).tree.value?(openBlock(),createBlock(Vibe64SourceFileTree_default,{key:4,"expanded-paths":expandedDirectoryPaths.value,"load-errors":unref(editor).treeLoadErrors.value,"loading-paths":unref(editor).treeLoadingPaths.value,node:unref(editor).tree.value,"selected-path":displayedPath.value,"starred-paths":__props.fileBookmarks?.paths.value||[],"assistant-draft-available":__props.assistantDraftAvailable,onAskAssistant:askAssistantAboutPath,onCopyPath:copySourcePath,onDirectoryOpenChange:handleDirectoryOpenChange,onLoadMoreDirectory:unref(editor).loadMoreDirectory,onNewFile:openNewFileDialog,onOpenFile:unref(editor).openFile,onToggleStar:_cache[13]||(_cache[13]=$event=>__props.fileBookmarks?.toggle($event)),onDownloadFile:requestDownload},null,8,[`expanded-paths`,`load-errors`,`loading-paths`,`node`,`selected-path`,`starred-paths`,`assistant-draft-available`,`onLoadMoreDirectory`,`onOpenFile`])):createCommentVNode(``,true)],64))],2)),[[vShow,!unref(mobile)||!fileListCollapsed.value]]):createCommentVNode(``,true),withDirectives(createBaseVNode(`main`,_hoisted_32,[unref(editor).loadError.value&&(__props.singleFile||unref(editor).tree.value)?(openBlock(),createElementBlock(`div`,_hoisted_33,toDisplayString(unref(editor).loadError.value),1)):createCommentVNode(``,true),unref(editor).downloadOnlyFile.value&&!imagePreviewUrl.value&&!unref(editor).loadingFile.value?(openBlock(),createElementBlock(`div`,_hoisted_34,[createBaseVNode(`p`,_hoisted_35,toDisplayString(unref(editor).downloadOnlyFile.value.message),1),createVNode(VBtn,{color:`primary`,disabled:Boolean(downloadingPath.value),"prepend-icon":unref(mdiDownload),onClick:_cache[14]||(_cache[14]=$event=>requestDownload(unref(editor).downloadOnlyFile.value.path))},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadingPath.value?`Downloading…`:`Download file`),1)]),_:1},8,[`disabled`,`prepend-icon`])])):!displayedPath.value&&!unref(editor).loadingFile.value?(openBlock(),createElementBlock(`div`,_hoisted_36,` Select a file to edit. `)):createCommentVNode(``,true),unref(editor).explanationError.value&&!unref(editor).activeExplanation.value?(openBlock(),createElementBlock(`div`,_hoisted_37,toDisplayString(unref(editor).explanationError.value),1)):createCommentVNode(``,true),createBaseVNode(`div`,{class:normalizeClass([`vibe64-source-editor__workspace`,{"vibe64-source-editor__workspace--with-explanation":!__props.singleFile&&unref(editor).activeExplanation.value&&filePresentation.value===`code`,"vibe64-source-editor__workspace--explanation-collapsed":!__props.singleFile&&unref(editor).activeExplanation.value&&explanationCollapsed.value&&filePresentation.value===`code`}])},[withDirectives(createBaseVNode(`div`,{ref_key:`editorElement`,ref:editorElement,class:normalizeClass([`vibe64-source-editor__codemirror`,{"vibe64-source-editor__codemirror--hidden":!unref(editor).selectedPath.value||unref(editor).loadingFile.value}])},null,2),[[vShow,filePresentation.value===`code`]]),unref(editor).selectedPath.value&&!unref(editor).loadingFile.value&&filePresentation.value===`interface`?(openBlock(),createBlock(Vibe64SourceInterface_default,{key:0,"file-path":unref(editor).selectedPath.value,"file-hash":unref(editor).savedHash.value,interpretations:unref(editor).interpretations.value,"interpretation-warning":unref(editor).interpretationWarning.value,"active-interpretation":activeInterfaceInterpretation.value,"active-file-interpretation":activeFileInterpretation.value,symbols:interfaceSymbols.value,programs:interfacePrograms.value,"program-status":interfaceArchitecture.value?.program?.status,"selected-id":interfaceSymbolId.value,current:interfaceCurrent.value,indexed:Boolean(interfaceFile.value),dirty:unref(editor).dirty.value,busy:unref(editor).explanationBusy.value||unref(editor).explanationClosing.value,"analysis-error":__props.architectureFacts?``:unref(interfaceGraph)?.error.value,"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,source:interfaceSymbolSource.value,presentation:symbolPresentation.value,onSelectSymbol:selectInterfaceSymbol,onPresentSymbol:presentInterfaceSymbol,onExplainFile:presentFileOverview,onWholeFileCode:showWholeFileCode,onOpenSource:_cache[15]||(_cache[15]=$event=>_ctx.$emit(`open-source-file`,$event)),onOpenProgram:_cache[16]||(_cache[16]=$event=>_ctx.$emit(`open-program`,$event))},{explanation:withCtx(({savedBody})=>[activeInterfaceInterpretation.value||activeFileInterpretation.value?(openBlock(),createBlock(Vibe64SourceExplanationPanel_default,{key:0,embedded:``,"saved-body":savedBody,"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,busy:unref(editor).explanationBusy.value,closing:unref(editor).explanationClosing.value,explanation:unref(editor).activeExplanation.value,followup:unref(editor).explanationFollowup.value,"selected-path":unref(editor).selectedPath.value,onClose:closeExplanationPanel,onOpenRange:openExplanationRange,onOpenSourceLink:openExplanationSourceLink,onRetry:retryExplanation,onSendFollowup:sendExplanationFollowup,onStop:unref(editor).stopExplanation,"onUpdate:followup":unref(editor).updateExplanationFollowup},null,8,[`saved-body`,`assistant-available`,`assistant-unavailable-message`,`busy`,`closing`,`explanation`,`followup`,`selected-path`,`onStop`,`onUpdate:followup`])):createCommentVNode(``,true)]),_:1},8,[`file-path`,`file-hash`,`interpretations`,`interpretation-warning`,`active-interpretation`,`active-file-interpretation`,`symbols`,`programs`,`program-status`,`selected-id`,`current`,`indexed`,`dirty`,`busy`,`analysis-error`,`assistant-available`,`assistant-unavailable-message`,`source`,`presentation`])):createCommentVNode(``,true),unref(editor).selectedPath.value&&!unref(editor).loadingFile.value&&filePresentation.value===`rendered`?(openBlock(),createElementBlock(`div`,_hoisted_38,[createBaseVNode(`div`,{onClick:openMarkdownLink},[createVNode(GithubMarkdown_default,{html:renderedMarkdownHtml.value},null,8,[`html`])])])):createCommentVNode(``,true),imagePreviewUrl.value?(openBlock(),createElementBlock(`div`,_hoisted_39,[imagePreviewStatus.value===`failed`?(openBlock(),createElementBlock(`div`,_hoisted_40,[_cache[29]||(_cache[29]=createBaseVNode(`p`,{class:`mb-3`,role:`alert`},`This image could not be displayed. Try again or download the file.`,-1)),createVNode(VBtn,{variant:`tonal`,onClick:_cache[17]||(_cache[17]=$event=>imagePreviewVersion.value+=1)},{default:withCtx(()=>[..._cache[28]||(_cache[28]=[createTextVNode(`Retry`,-1)])]),_:1})])):(openBlock(),createElementBlock(`img`,{key:`${imagePreviewUrl.value}:${imagePreviewVersion.value}`,src:imagePreviewUrl.value,alt:selectedFileName.value,style:normalizeStyle({visibility:imagePreviewStatus.value===`loaded`?`visible`:`hidden`}),onLoad:_cache[18]||(_cache[18]=$event=>imagePreviewStatus.value=`loaded`),onError:_cache[19]||(_cache[19]=$event=>imagePreviewStatus.value=`failed`)},null,44,_hoisted_41))])):createCommentVNode(``,true),unref(editor).loadingFile.value||imagePreviewUrl.value&&imagePreviewStatus.value===`loading`?(openBlock(),createElementBlock(`div`,{key:3,"aria-label":`Opening ${selectedFileName.value}`,"aria-live":`polite`,class:`vibe64-source-editor__file-loading`,role:`status`},[createVNode(VSkeletonLoader,{class:`vibe64-source-editor__file-skeleton`,type:`image`})],8,_hoisted_42)):createCommentVNode(``,true),!__props.singleFile&&unref(editor).activeExplanation.value&&filePresentation.value===`code`?(openBlock(),createElementBlock(`div`,{key:4,class:normalizeClass([`vibe64-source-editor__explanation-dock`,{"vibe64-source-editor__explanation-dock--collapsed":explanationCollapsed.value}])},[withDirectives(createVNode(Vibe64SourceExplanationPanel_default,{"assistant-available":__props.assistantAvailable,"assistant-unavailable-message":__props.assistantUnavailableMessage,busy:unref(editor).explanationBusy.value,closing:unref(editor).explanationClosing.value,explanation:unref(editor).activeExplanation.value,followup:unref(editor).explanationFollowup.value,"selected-path":unref(editor).selectedPath.value,onClose:closeExplanationPanel,onCollapse:collapseExplanation,onOpenRange:openExplanationRange,onOpenSourceLink:openExplanationSourceLink,onRetry:retryExplanation,onSendFollowup:sendExplanationFollowup,onStop:unref(editor).stopExplanation,"onUpdate:followup":unref(editor).updateExplanationFollowup},null,8,[`assistant-available`,`assistant-unavailable-message`,`busy`,`closing`,`explanation`,`followup`,`selected-path`,`onStop`,`onUpdate:followup`]),[[vShow,!explanationCollapsed.value]]),withDirectives(createBaseVNode(`button`,{"aria-label":`Show explanation`,class:`vibe64-source-editor__side-rail vibe64-source-editor__side-rail--right`,title:`Show explanation`,type:`button`,onClick:expandExplanation},[createVNode(VIcon,{icon:unref(mdiChevronLeft),size:`22`},null,8,[`icon`]),_cache[30]||(_cache[30]=createBaseVNode(`span`,null,`AI`,-1))],512),[[vShow,explanationCollapsed.value]])],2)):createCommentVNode(``,true)],2)],512),[[vShow,__props.singleFile||!unref(mobile)||fileListCollapsed.value||__props.codeFocusMode]])],2),createVNode(VDialog,{modelValue:newFileDialogOpen.value,"onUpdate:modelValue":_cache[21]||(_cache[21]=$event=>newFileDialogOpen.value=$event),"max-width":`520`},{default:withCtx(()=>[createVNode(VCard,null,{default:withCtx(()=>[createVNode(VCardTitle,null,{default:withCtx(()=>[..._cache[31]||(_cache[31]=[createTextVNode(`New file`,-1)])]),_:1}),createVNode(VCardText,{class:`vibe64-source-editor__new-file-dialog`},{default:withCtx(()=>[createBaseVNode(`p`,null,toDisplayString(newFileDirectoryLabel.value),1),newFileError.value?(openBlock(),createBlock(VAlert,{key:0,density:`compact`,type:`warning`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(newFileError.value),1)]),_:1})):createCommentVNode(``,true),createVNode(VTextField,{modelValue:newFileName.value,"onUpdate:modelValue":_cache[20]||(_cache[20]=$event=>newFileName.value=$event),autofocus:``,autocomplete:`off`,disabled:unref(editor).creatingFile.value,label:`Path`,placeholder:`components/NewFile.vue`,variant:`outlined`,onKeydown:withKeys(withModifiers(submitNewFile,[`prevent`]),[`enter`])},null,8,[`modelValue`,`disabled`,`onKeydown`])]),_:1}),createVNode(VCardActions,null,{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{disabled:unref(editor).creatingFile.value,type:`button`,variant:`text`,onClick:closeNewFileDialog},{default:withCtx(()=>[..._cache[32]||(_cache[32]=[createTextVNode(` Cancel `,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,disabled:newFileCreateDisabled.value,loading:unref(editor).creatingFile.value,type:`button`,variant:`flat`,onClick:submitNewFile},{default:withCtx(()=>[..._cache[33]||(_cache[33]=[createTextVNode(` Create `,-1)])]),_:1},8,[`disabled`,`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),createVNode(VDialog,{modelValue:downloadDraftOpen.value,"onUpdate:modelValue":_cache[23]||(_cache[23]=$event=>downloadDraftOpen.value=$event),"max-width":`440`},{default:withCtx(()=>[createVNode(VCard,{title:`Download this file?`},{default:withCtx(()=>[createVNode(VCardText,null,{default:withCtx(()=>[_cache[34]||(_cache[34]=createTextVNode(` This file has unsaved edits. Download the saved version, or save your edits first. `,-1)),downloadError.value?(openBlock(),createBlock(VAlert,{key:0,class:`mt-3`,density:`compact`,type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadError.value),1)]),_:1})):createCommentVNode(``,true)]),_:1}),createVNode(VCardActions,{class:`flex-wrap`},{default:withCtx(()=>[createVNode(VBtn,{disabled:downloadSaving.value,onClick:_cache[22]||(_cache[22]=$event=>downloadDraftOpen.value=false)},{default:withCtx(()=>[..._cache[35]||(_cache[35]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{disabled:downloadSaving.value,onClick:downloadSavedDraft},{default:withCtx(()=>[..._cache[36]||(_cache[36]=[createTextVNode(`Download saved file`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,disabled:downloadSaving.value,onClick:saveAndDownload},{default:withCtx(()=>[createTextVNode(toDisplayString(downloadSaving.value?`Saving…`:`Save & download`),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),createBaseVNode(`span`,_hoisted_43,toDisplayString(downloadingPath.value?`Downloading file…`:``),1)],2)}}};var Vibe64SessionSourceEditor_default=_plugin_vue_export_helper_default(_sfc_main$2,[[`__scopeId`,`data-v-1fad75af`]]);var _hoisted_1=[`aria-label`];var _hoisted_2={key:0,class:`session-file-area__drop-target`,role:`status`};var _hoisted_3={key:1,class:`d-flex align-center ga-2 flex-wrap px-3 pt-2`};var _hoisted_4={class:`text-body-small flex-grow-1`};var _hoisted_5={key:2,class:`d-flex align-center ga-2 flex-wrap px-3`};var _hoisted_6={key:4,class:`pa-4`};var _hoisted_7={class:`text-body-medium session-file-area__filename`};var _hoisted_8={key:1,class:`session-file-area__preview`,tabindex:`0`};var _hoisted_9={key:2,class:`pa-4`};var _hoisted_10={key:1,class:`pa-4 text-body-medium`};var _hoisted_11={key:0};var _sfc_main$1={__name:`Vibe64SessionFileArea`,props:{area:{type:String,required:true},archived:{type:Boolean,default:false},sessionId:{type:String,required:true},sessionsApiPath:{type:String,required:true},projectSlug:{type:String,default:``},active:{type:Boolean,default:true},agentActive:{type:Boolean,default:false}},setup(__props){const props=__props;const{smAndDown:mobile}=useDisplay();const writable=computed(()=>[`drop-zone`,`backups`].includes(props.area));const areaLabel=computed(()=>props.area===`backups`?`Project Backups`:props.area===`drop-zone`?`Session Dropzone`:`Session files, read only`);const areaDescription=computed(()=>props.area===`backups`?`Shared across this project · Files automatically deleted after 2 weeks without changes`:props.area===`session`?`Session runtime files · Read only`:`Temporary file exchange · Deleted when this session is archived`);const base=computed(()=>vibe64SessionPath(props.sessionsApiPath,props.sessionId,`/files/${encodeURIComponent(props.area)}`));const directory=ref(``);const entries=ref([]);const location=ref(``);const expired=ref(false);const hasMore=ref(false);const nextOffset=ref(0);const loading=ref(false);const loadError=ref(``);const busy=ref(false);const file=ref(null);const draft=ref(``);const dirty=computed(()=>file.value&&typeof file.value.text===`string`&&draft.value!==file.value.text);const uploadInput=ref(null);const dragDepth=ref(0);let disposed=false;const dialogOpen=ref(false);const dialogOperation=ref(``);const dialogEntry=ref(null);const dialogName=ref(``);const nameError=ref(``);const feedback=useUiFeedback({source:`vibe64.files`});let generation=0;let pendingRefresh=false;const breadcrumbs=computed(()=>[{title:areaLabel.value,path:``},...directory.value.split(`/`).filter(Boolean).map((name,i,parts)=>({title:name,path:parts.slice(0,i+1).join(`/`)}))]);function url(operation,filePath,offset=0){return`${base.value}/${operation}?${new URLSearchParams({path:filePath,offset})}`}async function request(endpoint,options){const result=await getHttpWebClient().request(endpoint,options);if(result?.ok===false)throw new Error(vibe64ApiResponseError(result,`File operation failed.`));return result}async function loadDirectory(target=``,append=false){const current=++generation;loading.value=true;loadError.value=``;file.value=null;try{const result=await request(url(`tree`,target,append?nextOffset.value:0));if(current!==generation)return;directory.value=target;entries.value=append?[...entries.value,...result.tree.children]:result.tree.children;hasMore.value=result.tree.hasMore;nextOffset.value=result.tree.nextOffset;location.value=result.location||``;expired.value=result.expired===true}catch(error){if(current===generation)loadError.value=error.message}finally{if(current===generation)loading.value=false}}async function openEntry(entry){if(entry.type===`directory`)return loadDirectory(entry.path);const current=++generation;loading.value=true;try{const result=await request(url(`file`,entry.path));if(current!==generation)return;file.value=result.file;draft.value=result.file.text}catch(error){if(current!==generation)return;file.value={path:entry.path,message:error.message}}finally{if(current===generation)loading.value=false}}async function command(run){if(busy.value)return;busy.value=true;try{await run()}catch(error){feedback.error(error,`File operation failed.`)}finally{busy.value=false}}function save(){return command(async()=>{const result=await request(`${base.value}/file`,{method:`PUT`,body:{path:file.value.path,baseHash:file.value.hash,text:draft.value}});file.value=result.file;draft.value=result.file.text})}function dragEnter(event){if(writable.value&&!expired.value&&!busy.value&&event.dataTransfer?.types.includes(`Files`))dragDepth.value+=1}function dragOver(event){if(event.dataTransfer){const canUpload=writable.value&&!expired.value&&!busy.value&&!dirty.value;event.dataTransfer.dropEffect=canUpload?`copy`:`none`}}function dragLeave(){dragDepth.value=Math.max(0,dragDepth.value-1)}function dropFiles(event){dragDepth.value=0;if(!writable.value||expired.value||busy.value)return;if(dirty.value){feedback.error(new Error(`Save or discard your edits before uploading files.`));return}if([...event.dataTransfer?.items||[]].some(item=>item.webkitGetAsEntry?.()?.isDirectory)){feedback.error(new Error(`Drop files individually, or upload a zip for a whole folder.`));return}return uploadFiles([...event.dataTransfer?.files||[]])}function upload(event){const files=[...event.target.files||[]];event.target.value=``;return uploadFiles(files)}function uploadFiles(files){if(!files.length)return;const endpoint=base.value;const folder=directory.value;return command(async()=>{for(const selected of files){if(disposed)break;try{if(selected.size>524288e3)throw new Error(`Choose a file no larger than ${VIBE64_UPLOAD_MAX_LABEL}.`);const data=new FormData;data.append(`file`,selected);const target=[folder,selected.name].filter(Boolean).join(`/`);await request(`${endpoint}/upload?${new URLSearchParams({path:target})}`,{method:`POST`,body:data})}catch(error){feedback.error(new Error(`${selected.name}: ${error.message}`),`Upload failed.`)}}if(!disposed)await loadDirectory(folder)})}function download(target,operation=`download`){return command(()=>downloadAttachment(scopedDevelopmentApiUrl(url(operation,target),props.projectSlug),target.split(`/`).at(-1),`Download failed.`))}function openDialog(operation,entry=null){dialogOperation.value=operation;dialogEntry.value=entry;dialogName.value=entry?.name||``;nameError.value=``;dialogOpen.value=true}function confirmDialog(){const operation=dialogOperation.value;if(operation!==`delete`&&(!dialogName.value.trim()||/[/\\]/u.test(dialogName.value)||[`.`,`..`].includes(dialogName.value.trim()))){nameError.value=`Enter a name without directory separators.`;return}return command(async()=>{const suffix=operation===`mkdir`?`directory`:operation===`delete`?`file`:`rename`;const destination=[directory.value,dialogName.value.trim()].filter(Boolean).join(`/`);await request(`${base.value}/${suffix}`,{method:operation===`delete`?`DELETE`:`POST`,body:{path:operation===`mkdir`?destination:dialogEntry.value.path,...operation===`rename`?{destination}:{}}});dialogOpen.value=false;await loadDirectory(directory.value)})}function copyLocation(){return command(()=>writeClipboardText(location.value))}function refresh(){if(dirty.value||busy.value){pendingRefresh=true;return}pendingRefresh=false;return file.value?openEntry({type:`file`,path:file.value.path}):loadDirectory(directory.value)}function entrySubtitle(entry){if(entry.type!==`file`)return`Folder`;const expiry=entry.expiresAt?` · Expires ${new Date(entry.expiresAt).toLocaleString()}`:``;return`${formatSize(entry.size)}${expiry}`}function formatSize(bytes){if(bytes<1024)return`${bytes} B`;if(bytes<1048576)return`${(bytes/1024).toFixed(1)} KiB`;return`${(bytes/1048576).toFixed(1)} MiB`}watch(base,()=>{directory.value=``;loadDirectory()},{immediate:true});watch(()=>props.agentActive,(working,wasWorking)=>{if(!wasWorking||working)return;if(props.active)refresh();else pendingRefresh=true});watch([()=>props.active,dirty],([active,changed])=>{if(active&&!changed&&pendingRefresh)refresh()});onScopeDispose(()=>{disposed=true;generation+=1});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{class:normalizeClass([`session-file-area`,{"session-file-area--mobile":unref(mobile)}]),"aria-label":areaLabel.value,onDragenter:withModifiers(dragEnter,[`prevent`]),onDragover:withModifiers(dragOver,[`prevent`]),onDragleave:withModifiers(dragLeave,[`prevent`]),onDrop:withModifiers(dropFiles,[`prevent`])},[dragDepth.value>0&&writable.value&&!expired.value&&!busy.value?(openBlock(),createElementBlock(`div`,_hoisted_2,[createVNode(VIcon,{icon:unref(mdiUpload),size:`40`},null,8,[`icon`]),_cache[14]||(_cache[14]=createBaseVNode(`span`,null,`Drop files here to upload`,-1))])):createCommentVNode(``,true),!unref(mobile)||!file.value?(openBlock(),createElementBlock(`div`,_hoisted_3,[createBaseVNode(`span`,_hoisted_4,toDisplayString(areaDescription.value),1),__props.archived&&__props.area===`session`?(openBlock(),createBlock(VBtn,{key:0,"prepend-icon":unref(mdiDownload),size:`small`,variant:`text`,disabled:busy.value,onClick:_cache[0]||(_cache[0]=$event=>download(`${__props.sessionId}.tar.gz`,`archive`))},{default:withCtx(()=>[..._cache[15]||(_cache[15]=[createTextVNode(`Download archive`,-1)])]),_:1},8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true),location.value?(openBlock(),createBlock(VBtn,{key:1,"prepend-icon":unref(mdiContentCopy),size:`small`,variant:`text`,onClick:copyLocation},{default:withCtx(()=>[..._cache[16]||(_cache[16]=[createTextVNode(`Copy AI path`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),createVNode(VBtn,{icon:unref(mdiRefresh),"aria-label":`Refresh files`,title:`Refresh files`,variant:`text`,disabled:loading.value||busy.value,onClick:refresh},null,8,[`icon`,`disabled`])])):createCommentVNode(``,true),!unref(mobile)||!file.value?(openBlock(),createElementBlock(`div`,_hoisted_5,[file.value?(openBlock(),createBlock(VBtn,{key:0,"prepend-icon":unref(mdiArrowLeft),variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[1]||(_cache[1]=$event=>file.value=null)},{default:withCtx(()=>[..._cache[17]||(_cache[17]=[createTextVNode(`Back to folder`,-1)])]),_:1},8,[`prepend-icon`,`disabled`])):(openBlock(),createBlock(VBreadcrumbs,{key:1,items:breadcrumbs.value,density:`compact`,class:`pa-0 flex-grow-1`},{item:withCtx(({item})=>[createVNode(VBtn,{size:`small`,variant:`text`,disabled:loading.value||busy.value,onClick:$event=>loadDirectory(item.path)},{default:withCtx(()=>[createTextVNode(toDisplayString(item.title),1)]),_:2},1032,[`disabled`,`onClick`])]),_:1},8,[`items`])),writable.value&&!expired.value&&!file.value?(openBlock(),createElementBlock(Fragment,{key:2},[createBaseVNode(`input`,{ref_key:`uploadInput`,ref:uploadInput,type:`file`,multiple:``,class:`d-none`,"aria-label":`Choose a file to upload`,onChange:upload},null,544),createVNode(VBtn,{"prepend-icon":unref(mdiFolderPlusOutline),variant:`text`,disabled:busy.value,onClick:_cache[2]||(_cache[2]=$event=>openDialog(`mkdir`))},{default:withCtx(()=>[..._cache[18]||(_cache[18]=[createTextVNode(`New folder`,-1)])]),_:1},8,[`prepend-icon`,`disabled`]),createVNode(VBtn,{"prepend-icon":unref(mdiUpload),variant:`tonal`,disabled:busy.value,onClick:_cache[3]||(_cache[3]=$event=>uploadInput.value.click())},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Working…`:`Upload`),1)]),_:1},8,[`prepend-icon`,`disabled`])],64)):createCommentVNode(``,true)])):createCommentVNode(``,true),loading.value?(openBlock(),createBlock(VSkeletonLoader,{key:3,type:`list-item-two-line@5`,class:`flex-grow-1`})):loadError.value?(openBlock(),createElementBlock(`div`,_hoisted_6,[createVNode(VAlert,{type:`error`,variant:`tonal`},{default:withCtx(()=>[createTextVNode(toDisplayString(loadError.value),1)]),_:1}),createVNode(VBtn,{class:`mt-3`,variant:`tonal`,onClick:refresh},{default:withCtx(()=>[..._cache[19]||(_cache[19]=[createTextVNode(`Retry`,-1)])]),_:1})])):file.value?(openBlock(),createElementBlock(Fragment,{key:5},[createBaseVNode(`div`,{class:normalizeClass([`d-flex align-center`,unref(mobile)?`ga-0 px-1`:`ga-2 flex-wrap px-3 py-2`])},[unref(mobile)?(openBlock(),createBlock(VBtn,{key:0,icon:unref(mdiArrowLeft),"aria-label":`Back to folder`,variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[4]||(_cache[4]=$event=>file.value=null)},null,8,[`icon`,`disabled`])):createCommentVNode(``,true),createBaseVNode(`span`,_hoisted_7,toDisplayString(file.value.path),1),createVNode(VSpacer),dirty.value?(openBlock(),createElementBlock(Fragment,{key:1},[createVNode(VBtn,{variant:`text`,disabled:busy.value,onClick:_cache[5]||(_cache[5]=$event=>draft.value=file.value.text)},{default:withCtx(()=>[..._cache[20]||(_cache[20]=[createTextVNode(`Discard edits`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:`primary`,variant:`tonal`,disabled:busy.value,onClick:save},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Saving…`:`Save`),1)]),_:1},8,[`disabled`])],64)):createCommentVNode(``,true),createVNode(VBtn,{icon:unref(mobile)?unref(mdiDownload):void 0,"prepend-icon":unref(mobile)?void 0:unref(mdiDownload),text:unref(mobile)?void 0:`Download`,"aria-label":`Download file`,variant:`text`,disabled:dirty.value||busy.value,onClick:_cache[6]||(_cache[6]=$event=>download(file.value.path))},null,8,[`icon`,`prepend-icon`,`text`,`disabled`]),unref(mobile)?(openBlock(),createBlock(VMenu,{key:2},{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps(menuProps,{icon:unref(mdiDotsVertical),"aria-label":`File actions`,variant:`text`}),null,16,[`icon`])]),default:withCtx(()=>[createVNode(VList,{density:`compact`},{default:withCtx(()=>[location.value?(openBlock(),createBlock(VListItem,{key:0,title:`Copy AI path`,"prepend-icon":unref(mdiContentCopy),onClick:copyLocation},null,8,[`prepend-icon`])):createCommentVNode(``,true),createVNode(VListItem,{title:`Refresh files`,"prepend-icon":unref(mdiRefresh),disabled:loading.value||busy.value,onClick:refresh},null,8,[`prepend-icon`,`disabled`]),__props.archived&&__props.area===`session`?(openBlock(),createBlock(VListItem,{key:1,title:`Download archive`,"prepend-icon":unref(mdiDownload),disabled:busy.value,onClick:_cache[7]||(_cache[7]=$event=>download(`${__props.sessionId}.tar.gz`,`archive`))},null,8,[`prepend-icon`,`disabled`])):createCommentVNode(``,true)]),_:1})]),_:1})):createCommentVNode(``,true)],2),writable.value&&typeof file.value.text===`string`?(openBlock(),createBlock(VTextarea,{key:0,modelValue:draft.value,"onUpdate:modelValue":_cache[8]||(_cache[8]=$event=>draft.value=$event),"aria-label":`File contents`,class:`mx-3 session-file-area__text`,disabled:busy.value,variant:`outlined`,rows:`18`,"hide-details":``},null,8,[`modelValue`,`disabled`])):typeof file.value.text===`string`?(openBlock(),createElementBlock(`pre`,_hoisted_8,toDisplayString(file.value.text),1)):(openBlock(),createElementBlock(`p`,_hoisted_9,toDisplayString(file.value.message),1))],64)):(openBlock(),createElementBlock(Fragment,{key:6},[entries.value.length?(openBlock(),createBlock(VList,{key:0,class:`session-file-area__listing`,"aria-label":`Files and folders`},{default:withCtx(()=>[(openBlock(true),createElementBlock(Fragment,null,renderList(entries.value,entry=>{return openBlock(),createBlock(VListItem,{key:entry.path,title:entry.name,subtitle:entrySubtitle(entry),"prepend-icon":entry.type===`directory`?unref(mdiFolderOutline):unref(mdiFileOutline),disabled:busy.value,onClick:$event=>openEntry(entry)},{append:withCtx(()=>[entry.type===`file`?(openBlock(),createBlock(VBtn,{key:0,icon:unref(mdiDownload),"aria-label":`Download ${entry.name}`,variant:`text`,onClick:withModifiers($event=>download(entry.path),[`stop`])},null,8,[`icon`,`aria-label`,`onClick`])):createCommentVNode(``,true),writable.value?(openBlock(),createBlock(VMenu,{key:1,"close-on-content-click":true},{activator:withCtx(({props:menuProps})=>[createVNode(VBtn,mergeProps({ref_for:true},menuProps,{icon:unref(mdiDotsVertical),"aria-label":`Actions for ${entry.name}`,variant:`text`,onClick:_cache[9]||(_cache[9]=withModifiers(()=>{},[`stop`]))}),null,16,[`icon`,`aria-label`])]),default:withCtx(()=>[createVNode(VList,null,{default:withCtx(()=>[createVNode(VListItem,{"prepend-icon":unref(mdiPencilOutline),title:`Rename`,onClick:$event=>openDialog(`rename`,entry)},null,8,[`prepend-icon`,`onClick`]),createVNode(VListItem,{"prepend-icon":unref(mdiDeleteOutline),title:`Delete`,onClick:$event=>openDialog(`delete`,entry)},null,8,[`prepend-icon`,`onClick`])]),_:2},1024)]),_:2},1024)):createCommentVNode(``,true)]),_:2},1032,[`title`,`subtitle`,`prepend-icon`,`disabled`,`onClick`])}),128))]),_:1})):(openBlock(),createElementBlock(`p`,_hoisted_10,toDisplayString(expired.value?`This Session Dropzone has expired.`:writable.value?`Nothing here yet. Drop files here, use Upload, or ask the AI to put files in ${areaLabel.value}.`:`This folder is empty.`),1)),hasMore.value?(openBlock(),createBlock(VBtn,{key:2,class:`ma-3 align-self-start`,variant:`text`,disabled:busy.value,onClick:_cache[10]||(_cache[10]=$event=>loadDirectory(directory.value,true))},{default:withCtx(()=>[..._cache[21]||(_cache[21]=[createTextVNode(`Load more`,-1)])]),_:1},8,[`disabled`])):createCommentVNode(``,true)],64)),createVNode(VDialog,{modelValue:dialogOpen.value,"onUpdate:modelValue":_cache[13]||(_cache[13]=$event=>dialogOpen.value=$event),"max-width":`460`,persistent:busy.value},{default:withCtx(()=>[createVNode(VCard,{title:dialogOperation.value===`delete`?`Delete from ${areaLabel.value}?`:dialogOperation.value===`rename`?`Rename item`:`New folder`},{default:withCtx(()=>[createVNode(VCardText,null,{default:withCtx(()=>[dialogOperation.value===`delete`?(openBlock(),createElementBlock(`p`,_hoisted_11,toDisplayString(dialogEntry.value?.name)+toDisplayString(dialogEntry.value?.type===`directory`?` and everything inside it will be deleted.`:` will be deleted.`),1)):(openBlock(),createBlock(VTextField,{key:1,modelValue:dialogName.value,"onUpdate:modelValue":_cache[11]||(_cache[11]=$event=>dialogName.value=$event),label:`Name`,autofocus:``,disabled:busy.value,"error-messages":nameError.value,onKeyup:withKeys(confirmDialog,[`enter`])},null,8,[`modelValue`,`disabled`,`error-messages`]))]),_:1}),createVNode(VCardActions,null,{default:withCtx(()=>[createVNode(VSpacer),createVNode(VBtn,{disabled:busy.value,onClick:_cache[12]||(_cache[12]=$event=>dialogOpen.value=false)},{default:withCtx(()=>[..._cache[22]||(_cache[22]=[createTextVNode(`Cancel`,-1)])]),_:1},8,[`disabled`]),createVNode(VBtn,{color:dialogOperation.value===`delete`?`error`:`primary`,disabled:busy.value,onClick:confirmDialog},{default:withCtx(()=>[createTextVNode(toDisplayString(busy.value?`Working…`:dialogOperation.value===`delete`?`Delete`:dialogOperation.value===`rename`?`Rename`:`Create`),1)]),_:1},8,[`color`,`disabled`])]),_:1})]),_:1},8,[`title`])]),_:1},8,[`modelValue`,`persistent`])],42,_hoisted_1)}}};var Vibe64SessionFileArea_default=_plugin_vue_export_helper_default(_sfc_main$1,[[`__scopeId`,`data-v-af3b0d40`]]);var _sfc_main=Object.assign({inheritAttrs:false},{__name:`Vibe64SessionFiles`,props:{repoAvailable:{type:Boolean,default:true},archived:{type:Boolean,default:false},active:{type:Boolean,default:true},agentActive:{type:Boolean,default:false},sessionId:{type:String,required:true},sessionsApiPath:{type:String,required:true},projectSlug:{type:String,default:``},openRequest:{type:Object,default:null}},emits:[`ask-assistant-about-file`,`open-program`],setup(__props){const props=__props;const area=ref(props.archived||!props.repoAvailable?`drop-zone`:`repo`);const visitedAreas=ref([]);watch(area,value=>{if(value!==`repo`&&!visitedAreas.value.includes(value))visitedAreas.value.push(value)},{immediate:true});const areas=ref([`repo`]);const mountedAreas=computed(()=>visitedAreas.value.filter(value=>areas.value.includes(value)));const areaError=ref(``);const loadingAreas=ref(false);let generation=0;async function loadAreas(){const current=++generation;areas.value=[`repo`];areaError.value=``;loadingAreas.value=true;try{const result=await getHttpWebClient().request(vibe64SessionPath(props.sessionsApiPath,props.sessionId,`/files`));if(result?.ok===false)throw new Error(vibe64ApiResponseError(result,`File areas could not load.`));if(current!==generation)return;areas.value=result.areas;if(props.archived)area.value=areas.value.includes(`session`)?`session`:`drop-zone`;else if(!props.repoAvailable)area.value=`drop-zone`;else if(!areas.value.includes(area.value))area.value=`repo`}catch(error){if(current===generation){areaError.value=error.message;area.value=`repo`}}finally{if(current===generation)loadingAreas.value=false}}watch(()=>[props.sessionsApiPath,props.sessionId],loadAreas,{immediate:true});watch(()=>props.openRequest,()=>{area.value=`repo`});onScopeDispose(()=>{generation+=1});return(_ctx,_cache)=>{return openBlock(),createElementBlock(`section`,{class:normalizeClass([`vibe64-session-files`,_ctx.$attrs.class]),style:normalizeStyle(_ctx.$attrs.style),"aria-label":`Session files`},[createVNode(VTabs,{modelValue:area.value,"onUpdate:modelValue":_cache[0]||(_cache[0]=$event=>area.value=$event),density:`compact`,"aria-label":`File areas`,disabled:loadingAreas.value},{default:withCtx(()=>[createVNode(VTab,{disabled:__props.archived||!__props.repoAvailable,value:`repo`,"prepend-icon":unref(mdiSourceRepository)},{default:withCtx(()=>[..._cache[3]||(_cache[3]=[createTextVNode(`Repo`,-1)])]),_:1},8,[`disabled`,`prepend-icon`]),areas.value.includes(`drop-zone`)?(openBlock(),createBlock(VTab,{key:0,value:`drop-zone`,"prepend-icon":unref(mdiTrayArrowUp)},{default:withCtx(()=>[..._cache[4]||(_cache[4]=[createTextVNode(`Session Dropzone`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),areas.value.includes(`backups`)?(openBlock(),createBlock(VTab,{key:1,value:`backups`,"prepend-icon":unref(mdiArchiveClockOutline)},{default:withCtx(()=>[..._cache[5]||(_cache[5]=[createTextVNode(`Project Backups (2w retention)`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true),areas.value.includes(`session`)?(openBlock(),createBlock(VTab,{key:2,value:`session`,"prepend-icon":unref(mdiArchiveClockOutline)},{default:withCtx(()=>[..._cache[6]||(_cache[6]=[createTextVNode(`Session`,-1)])]),_:1},8,[`prepend-icon`])):createCommentVNode(``,true)]),_:1},8,[`modelValue`,`disabled`]),areaError.value?(openBlock(),createBlock(VAlert,{key:0,type:`error`,variant:`tonal`,density:`compact`},{default:withCtx(()=>[createTextVNode(toDisplayString(areaError.value)+` `,1),createVNode(VBtn,{variant:`text`,onClick:loadAreas},{default:withCtx(()=>[..._cache[7]||(_cache[7]=[createTextVNode(`Retry`,-1)])]),_:1})]),_:1})):createCommentVNode(``,true),!__props.archived&&__props.repoAvailable?withDirectives((openBlock(),createBlock(Vibe64SessionSourceEditor_default,mergeProps({key:1},_ctx.$attrs,{class:`vibe64-session-files__content`,active:__props.active&&area.value===`repo`,"agent-active":__props.agentActive,"session-id":__props.sessionId,"sessions-api-path":__props.sessionsApiPath,"project-slug":__props.projectSlug,"open-request":__props.openRequest,onAskAssistantAboutFile:_cache[1]||(_cache[1]=$event=>_ctx.$emit(`ask-assistant-about-file`,$event)),onOpenProgram:_cache[2]||(_cache[2]=$event=>_ctx.$emit(`open-program`,$event))}),null,16,[`active`,`agent-active`,`session-id`,`sessions-api-path`,`project-slug`,`open-request`])),[[vShow,area.value===`repo`]]):createCommentVNode(``,true),(openBlock(true),createElementBlock(Fragment,null,renderList(mountedAreas.value,visitedArea=>{return withDirectives((openBlock(),createBlock(Vibe64SessionFileArea_default,{key:`${__props.sessionId}:${visitedArea}`,class:`vibe64-session-files__content`,active:__props.active&&area.value===visitedArea,area:visitedArea,archived:__props.archived,"session-id":__props.sessionId,"sessions-api-path":__props.sessionsApiPath,"project-slug":__props.projectSlug,"agent-active":__props.agentActive},null,8,[`active`,`area`,`archived`,`session-id`,`sessions-api-path`,`project-slug`,`agent-active`])),[[vShow,area.value===visitedArea]])}),128))],6)}}});var Vibe64SessionFiles_default=_plugin_vue_export_helper_default(_sfc_main,[[`__scopeId`,`data-v-929f9f95`]]);export{Vibe64StarredFilesList_default as a,conversationAttribution as c,_sfc_main$11 as d,_sfc_main$12 as f,sourceEditorLinkTarget as i,Vibe64ConversationStatus_default as l,useVibe64AttachmentCommands as m,Vibe64SessionSourceEditor_default as n,thinkingMessagePresentation as o,useAgentAttachments as p,Vibe64ConversationLog_default as r,usesCommentaryForThinking as s,Vibe64SessionFiles_default as t,_sfc_main$10 as u};
|