vzcode 1.49.0 → 1.50.0
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.
|
@@ -375,7 +375,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStat
|
|
|
375
375
|
`+n),r.b(" </div>"),r.b(`
|
|
376
376
|
`+n),r.b(" </div>"),r.b(`
|
|
377
377
|
`+n),r.b(" </div>"),r.b(`
|
|
378
|
-
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});mi["tag-file-added"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-changed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-deleted"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-renamed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),r.fl()},partials:{},subs:{}});class __e{constructor({compiledTemplates:e={},rawTemplates:n={}}){const r=Object.entries(n).reduce((i,[o,s])=>{const a=ii.compile(s,{asString:!1});return Object.assign(Object.assign({},i),{[o]:a})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},mi),e),r)}static compile(e){return ii.compile(e,{asString:!1})}render(e,n,r,i,o){const s=this.templateKey(e,n);try{return this.preCompiledTemplates[s].render(r,i,o)}catch{throw new Error(`Could not find template to render '${s}'`)}}template(e,n){return this.preCompiledTemplates[this.templateKey(e,n)]}templateKey(e,n){return`${e}-${n}`}}const P_e=Object.assign(Object.assign(Object.assign({},aW),lW),{outputFormat:Vxe.LINE_BY_LINE,drawFileList:!0});function C_e(t,e={}){const n=Object.assign(Object.assign({},P_e),e),r=typeof t=="string"?Jxe(t,n):t,i=new __e(n),{colorScheme:o}=n,s={colorScheme:o},a=n.drawFileList?new p_e(i,s).render(r):"",l=n.outputFormat==="side-by-side"?new w_e(i,n).render(r):new v_e(i,n).render(r);return a+l}const E_e=({diffData:t,messageId:e,chatId:n,beforeFiles:r,canUndo:i=!1})=>{const[o,s]=N.useState(!1),{aiChatUndoEndpoint:a}=N.useContext(qr),l=Object.values(t).filter(p=>p.length>0);if(l.length===0)return null;const u=async()=>{if(!(!e||!n||!r||o||!a)){s(!0);try{const p=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatId:n,messageId:e})});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`)}catch(p){console.error("Error undoing AI edit:",p)}finally{s(!1)}}};let c=0,f=0;for(const p of l){const g=Uxe(p);c+=g.additions,f+=g.deletions}const d=qxe(t),h=C_e(d,{drawFileList:!1,matching:"words",diffStyle:"word",outputFormat:"line-by-line"});return X.jsxs("div",{className:"diff-view",children:[X.jsx("div",{className:"diff-summary",children:X.jsxs("div",{className:"diff-stats",children:[X.jsxs("span",{className:"files-changed",children:[l.length," file",l.length!==1?"s":""," changed"]}),c>0&&X.jsxs("span",{className:"additions",children:["+",c]}),f>0&&X.jsxs("span",{className:"deletions",children:["-",f]})]})}),X.jsx("div",{className:"diff-files",dangerouslySetInnerHTML:{__html:h}}),i&&r&&X.jsx("div",{className:"undo-button-container",children:X.jsx("button",{className:"undo-button",onClick:u,disabled:o,title:"Undo this AI edit",children:o?"Undoing...":"Undo"})})]})},T_e=({id:t,role:e,content:n,timestamp:r,isStreaming:i,diffData:o,beforeFiles:s,chatId:a,canUndo:l})=>{const u=N.useMemo(()=>ahe(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[r]),c=N.useMemo(()=>`ai-chat-message ${e}${i?" streaming":""}`,[e,i]);return X.jsxs("div",{className:c,children:[X.jsxs("div",{className:"ai-chat-message-content",children:[X.jsx(Mz,{remarkPlugins:[nW],children:n}),o&&Object.keys(o).length>0&&X.jsx(E_e,{diffData:o,messageId:t,chatId:a,beforeFiles:s,canUndo:l})]}),X.jsx("div",{className:"ai-chat-message-time",children:u})]})},R_e=N.memo(T_e),A_e=()=>X.jsx("div",{className:"ai-chat-message assistant",children:X.jsx("div",{className:"ai-chat-message-content",children:X.jsxs("div",{className:"ai-chat-typing",children:[X.jsx("span",{}),X.jsx("span",{}),X.jsx("span",{})]})})}),M_e=N.memo(A_e),D_e=({content:t,isVisible:e})=>!e||!t?null:X.jsxs("div",{className:"thinking-scratchpad",children:[X.jsxs("div",{className:"thinking-scratchpad-header",children:[X.jsx("span",{className:"thinking-scratchpad-icon",children:"🧠"}),X.jsx("span",{className:"thinking-scratchpad-title",children:"VizBot is thinking..."})]}),X.jsx("div",{className:"thinking-scratchpad-content",children:X.jsx(Mz,{remarkPlugins:[nW],children:t})})]}),I_e=N.memo(D_e),$_e=({messages:t,aiStatus:e,isLoading:n,chatId:r,aiScratchpad:i})=>{const o=N.useRef(null),s=N.useRef(null),[a,l]=N.useState(!1),[u,c]=N.useState(!0),f=N.useRef(),d=N.useCallback(()=>{const S=s.current;if(!S)return!0;const k=50,{scrollTop:x,scrollHeight:_,clientHeight:D}=S;return _-x-D<k},[]),h=N.useCallback(()=>{u&&o.current?.scrollIntoView({behavior:"smooth",block:"end"})},[u]),p=N.useCallback(()=>{if(!s.current)return;const k=d();f.current&&clearTimeout(f.current),!k&&!a&&(l(!0),c(!1)),k&&a&&(f.current=setTimeout(()=>{l(!1),c(!0)},500))},[a,d]);N.useEffect(()=>(u&&!a&&(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{h()},100)),()=>{f.current&&clearTimeout(f.current)}),[t,u,a,h]),N.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const g=t[t.length-1],y=g?.role==="assistant"&&g.content!=="",O=n&&!y,b=!!(i&&i.trim());return X.jsxs("div",{className:"ai-chat-messages",ref:s,onScroll:p,children:[t.map((S,k)=>{const _=S.role==="assistant"&&k===t.length-1&&!n&&S.diffData&&S.beforeFiles&&Object.keys(S.diffData||{}).length>0;return X.jsx(R_e,{id:S.id,role:S.role,content:S.content,timestamp:S.timestamp,diffData:S.diffData,beforeFiles:S.beforeFiles,chatId:r,canUndo:_},S.id)}),b&&X.jsx(I_e,{content:i||"",isVisible:b}),O&&X.jsx(M_e,{}),X.jsx("div",{ref:o})]})},L_e=N.memo($_e),N_e=({aiChatMessage:t,setAIChatMessage:e,onSendMessage:n,isLoading:r,focused:i,aiChatMode:o,setAIChatMode:s})=>{const a=N.useRef(null);N.useEffect(()=>{i&&a.current&&a.current.focus()},[i]);const l=N.useCallback(c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),n())},[n]),u=N.useCallback(c=>{e(c.target.value)},[e]);return X.jsxs("div",{className:"ai-chat-input-container",children:[X.jsxs("div",{className:"ai-chat-mode-toggle",style:{marginBottom:"8px"},children:[X.jsxs(K1e,{size:"sm",children:[X.jsx(QN,{id:"ai-chat-mode-ask",type:"radio",variant:o==="ask"?"primary":"outline-primary",name:"ai-chat-mode",value:"ask",checked:o==="ask",onChange:()=>s("ask"),disabled:r,children:"💬 Ask"}),X.jsx(QN,{id:"ai-chat-mode-edit",type:"radio",variant:o==="edit"?"primary":"outline-primary",name:"ai-chat-mode",value:"edit",checked:o==="edit",onChange:()=>s("edit"),disabled:r,children:"✏️ Edit"})]}),X.jsx("div",{className:"ai-chat-mode-description",children:o==="ask"?"Ask questions without editing files":"Get answers and code edits"})]}),X.jsxs(Ir.Group,{className:"ai-chat-input-group",children:[X.jsx(Ir.Control,{as:"textarea",rows:2,value:t,onChange:u,onKeyDown:l,ref:a,placeholder:o==="edit"?"Ask me to make code changes...":"Ask me anything about your code...",spellCheck:"false",disabled:r,"aria-label":"Chat message input"}),t&&X.jsxs("div",{className:"ai-chat-input-info",children:[X.jsx("span",{className:"ai-chat-hint",children:"Shift+Enter for new line"}),X.jsx("span",{className:"ai-chat-hint",children:"Press Enter to send"})]}),X.jsx(Uu,{variant:"primary",onClick:n,disabled:!t.trim()||r,className:"ai-chat-send-button","aria-label":"Send message",title:"Send message (Enter)",children:"Send"})]})]})},j_e=N.memo(N_e),Q_e="/api/ai-chat/",F_e=()=>{const{aiChatMessage:t,setAIChatMessage:e}=N.useContext(qr),[n,r]=N.useState(!1),[i]=N.useState(()=>fB()),[o,s]=N.useState(null),{aiChatFocused:a,content:l,aiChatEndpoint:u=Q_e,aiChatOptions:c={},aiChatMode:f,setAIChatMode:d}=N.useContext(qr),h=l?.chats?.[i],p=h?.messages||[],g=h?.aiStatus,y=h?.aiScratchpad,O=N.useMemo(()=>p.map((k,x)=>({...k,id:k.id||`msg-${x}`})),[p]),b=p.length===0,S=N.useCallback(async()=>{if(!(!t.trim()||n)){e(""),r(!0),s(null);try{const k=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,vizId:c.vizId,content:t.trim(),chatId:i,mode:f})});if(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);const x=await k.json();if(x.outcome==="failure"&&x.error){s(x.error.message);return}}catch(k){console.error("Error getting AI response:",k),s("Failed to send message. Please try again.")}finally{r(!1)}}},[t,n,u,c,i]);return X.jsx("div",{className:"ai-chat-container",children:X.jsxs("div",{style:{padding:"10px",flex:1,display:"flex",flexDirection:"column"},children:[b?X.jsxs("div",{className:"ai-chat-empty",children:[X.jsx("div",{className:"ai-chat-empty-icon",children:"✨"}),X.jsx("h3",{className:"ai-chat-empty-title",children:"Hi, I'm VizBot!"}),X.jsx("div",{className:"ai-chat-empty-text",children:"How can I help you?"}),X.jsx("div",{className:"ai-chat-empty-examples",children:f==="ask"?X.jsxs(X.Fragment,{children:[X.jsx("h4",{children:"Try asking questions like:"}),X.jsxs("div",{className:"ai-chat-suggested-prompts",children:[X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Explain how this works"),children:'"Explain how this works"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("How could I change it so that the circles are bigger?"),children:'"How could I change it so that the circles are bigger?"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("What does this function do?"),children:'"What does this function do?"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("How can I make this more accessible?"),children:'"How can I make this more accessible?"'})]})]}):X.jsxs(X.Fragment,{children:[X.jsx("h4",{children:"Try edit requests like these:"}),X.jsxs("div",{className:"ai-chat-suggested-prompts",children:[X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Change the circles to squares"),children:'"Change the circles to squares"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Add a button that toggles the animation"),children:'"Add a button that toggles the animation"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Fix the CSS so the layout is responsive"),children:'"Fix the CSS so the layout is responsive"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Refactor this function to use async/await"),children:'"Refactor this function to use async/await"'})]})]})}),X.jsx("div",{className:"ai-chat-empty-text",children:f==="ask"?"Type your question below to get started!":"Type your edit request below to get started!"})]}):X.jsx(L_e,{messages:O,aiStatus:g,isLoading:n,chatId:i,aiScratchpad:y}),o&&X.jsx("div",{className:"ai-chat-error",children:X.jsxs("div",{className:"ai-chat-error-content",children:[X.jsx("span",{className:"ai-chat-error-icon",children:"⚠️"}),X.jsx("span",{className:"ai-chat-error-message",children:o}),X.jsx("button",{className:"ai-chat-error-dismiss",onClick:()=>s(null),"aria-label":"Dismiss error",children:"×"})]})}),X.jsx(j_e,{aiChatMessage:t,setAIChatMessage:e,onSendMessage:S,isLoading:n,focused:a,aiChatMode:f,setAIChatMode:d})]})})};function B_e(t){const e=t.split(".");switch(e[e.length-1]){case"jsx":case"tsx":return X.jsx(pOe,{});case"js":return X.jsx(dOe,{});case"ts":return X.jsx(hOe,{});case"json":return X.jsx(yOe,{});case"md":return X.jsx(OOe,{});case"html":return X.jsx(gOe,{});case"css":return X.jsx(vOe,{});case"svelte":return X.jsx(mOe,{});default:return X.jsx(XV,{})}}const pR=({name:t})=>X.jsx("i",{className:"file-icon",children:N.useMemo(()=>B_e(t),[t])}),U_e=({show:t,onClose:e,onConfirm:n,isDirectory:r,name:i})=>{const o=N.useCallback(s=>{s.key==="Enter"&&n()},[n]);return N.useEffect(()=>(t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}),[t,o]),X.jsxs($r,{show:t,onHide:e,centered:!0,children:[X.jsx($r.Header,{closeButton:!0,onClick:e,children:X.jsxs($r.Title,{children:["Delete ",r?"Directory":"File"]})}),X.jsx($r.Body,{children:X.jsxs("p",{children:["This will delete the"," ",r?"directory":"file"," ",X.jsx("strong",{children:i}),"."]})}),X.jsxs($r.Footer,{children:[X.jsx(Uu,{variant:"secondary",type:"button",onClick:e,children:"Cancel"}),X.jsx(Uu,{variant:"primary",onClick:n,children:"Delete"})]})]})},q_e=!0,uW=({id:t,name:e,children:n,handleClick:r,handleDoubleClick:i,handleRenameClick:o,handleDeleteClick:s,isDirectory:a=!1,isActive:l=!1,renameFileTooltipText:u=a?"Rename Directory":"Rename File",deleteFileTooltipText:c=a?"Delete Directory":"Delete File"})=>{const{hoveredItemId:f,setHoveredItemId:d}=N.useContext(qr),h=f===t,p=N.useCallback(H=>{d(H?t:null)},[t,d]),[g,y]=N.useState(!1),[O,b]=N.useState(""),[S,k]=N.useState(!1),x=N.useRef(null),_=N.useCallback(H=>{H.key==="Escape"?y(!1):H.key==="Enter"&&x.current.blur()},[]),D=N.useCallback(()=>{y(!1),x.current.value.trim()===""?k(!0):o(x.current.value)},[o]),M=N.useCallback(H=>{H.stopPropagation(),y(!g),b(e)},[e,g]);N.useEffect(()=>{g&&x.current.focus()},[g]);const P=N.useCallback(H=>{H.stopPropagation(),k(!0)},[]),C=N.useCallback(()=>{k(!1)},[]),A=N.useCallback(H=>{H?.stopPropagation(),k(!1),s()},[s]),T=N.useCallback(()=>{p(!0)},[]),L=N.useCallback(()=>{p(!1)},[]),R=N.useCallback(()=>{b(x.current.value)},[]);return X.jsxs("div",{className:`file-or-directory user-select-none ${l?"active-file":""}`,onClick:g?null:r,onDoubleClick:g||!i?null:i,onMouseEnter:T,onMouseLeave:L,children:[X.jsx("div",{className:"name",children:g?X.jsxs(X.Fragment,{children:[X.jsx(pR,{name:O}),X.jsx("input",{className:"rename-input",ref:x,type:"text","aria-label":"Field name",value:O,onKeyDown:_,onBlur:D,onChange:R})]}):n}),h&&!g?X.jsxs("div",{className:"utils",style:{position:"relative"},children:[!a||q_e?X.jsx(ns,{placement:"top",overlay:X.jsx(rs,{id:"rename-file-tooltip",children:u}),children:X.jsx("i",{onClick:M,className:"icon-button icon-button-dark",children:X.jsx(nOe,{})})}):null,X.jsx(ns,{placement:"top",overlay:X.jsx(rs,{id:"delete-file-tooltip",children:c}),children:X.jsx("i",{onClick:P,className:"icon-button icon-button-dark",children:X.jsx(oOe,{})})})]}):null,S&&X.jsx(U_e,{show:S,onClose:C,onConfirm:A,isDirectory:a,name:e})]})},V_e=({name:t,path:e,children:n,handleFileClick:r,handleFileDoubleClick:i})=>{const{renameDirectory:o,deleteDirectory:s,isDirectoryOpen:a,toggleDirectory:l,sidebarPresenceIndicators:u}=N.useContext(qr),c=N.useCallback(()=>{l(e)},[l,e]),f=N.useCallback(()=>{s(e)},[s,e]),d=N.useCallback(p=>{o(e,t,p)},[o,e,t]),h=N.useMemo(()=>a(e),[a,e]);return X.jsxs(X.Fragment,{children:[X.jsxs(uW,{id:e,name:t,handleClick:c,handleDeleteClick:f,handleRenameClick:d,isDirectory:!0,children:[X.jsx("div",{className:"arrow-wrapper",style:{transform:`rotate(${h?90:0}deg)`},children:X.jsx(HV,{})}),X.jsx("div",{className:"name",children:t})]}),n&&h?X.jsx("div",{className:"indentation",children:n.map(p=>{const{fileId:g}=p,{path:y}=p;return X.jsx(cW,{entity:p,handleFileClick:r,handleFileDoubleClick:i},g||y)})}):null]})},z_e=({presence:t})=>X.jsx("div",{className:"presence-indicators",children:t.map((e,n)=>{const i=`rgb(${Q8(e.username)})`;return X.jsx("div",{className:"presence-indicator",style:{backgroundColor:i},children:e.username[0]},n)})}),W_e=({name:t,fileId:e,handleFileClick:n,handleFileDoubleClick:r,isActive:i,presence:o})=>{const{renameFile:s,deleteFile:a}=N.useContext(qr),l=N.useCallback(()=>{n(e)},[e,n]),u=N.useCallback(()=>{r(e)},[e,r]),c=N.useCallback(()=>{a(e)},[e,a]),f=N.useCallback(d=>{s(e,d)},[e,s]);return X.jsxs(uW,{id:e,name:t,handleClick:l,handleDoubleClick:u,handleDeleteClick:c,handleRenameClick:f,isActive:i,children:[X.jsx(z_e,{presence:o}),X.jsx(pR,{name:t}),t]})},cW=({entity:t,handleFileClick:e,handleFileDoubleClick:n})=>{const{activePane:r,sidebarPresenceIndicators:i}=N.useContext(qr),{name:o,file:s,fileId:a}=t,{path:l,children:u}=t,c=i?.filter(f=>f.fileId===a)||[];return s?X.jsx(W_e,{fileId:a,name:o,handleFileClick:e,handleFileDoubleClick:n,isActive:a===r.activeFileId,presence:c}):X.jsx(V_e,{name:o,path:l,children:u,handleFileClick:e,handleFileDoubleClick:n})};function t3(t,e,n,r){const i=t.state.doc.line(n).from+r;t.dispatch({selection:{anchor:i,head:i+e.length},scrollIntoView:!0,effects:St.scrollIntoView(i,{y:"center"})})}function n3(t,e){const n=t.scrollTop,r=n+t.clientHeight,i=e.offsetTop-t.offsetTop,o=i+e.clientHeight;return i>=n+100&&o<=r-100}const Z_e=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{search:i,setSearch:o,activePaneId:s,setActiveFileId:a,setSearchResults:l,setSearchFileVisibility:u,setSearchLineVisibility:c,setSearchFocusedIndex:f,shareDBDoc:d,editorCache:h,openTab:p}=N.useContext(qr),{pattern:g,results:y,focusedIndex:O,focusedChildIndex:b,focused:S}=i,k=N.useRef(null),x=Object.entries(y).filter(([C,A])=>A.visibility!=="closed");N.useEffect(()=>{if(t){r(g.trim().length>=1);const C=setTimeout(()=>{g.trim().length>=1&&k.current&&(l(d),r(!1))},2e3);return()=>clearTimeout(C)}else e(!0)},[g]);const _=N.useCallback((C,A)=>{u(d,C,A.visibility==="open"&&b===null?"flattened":"open")},[O,b]),D=N.useCallback(C=>{u(d,C,"closed")},[]),M=N.useCallback((C,A)=>{a(C),f(A,null)},[]),P=C=>{if(C.preventDefault(),x.length===0)return;const A=x[O][1].matches.length;switch(C.key){case"Tab":f(O,null);break;case"ArrowUp":if(O==0&&b==null)break;if(b===null||A==0){const H=x[O-1][1].matches.length;f(O-1,H>0?H-1:null)}else b===0?f(O,null):f(O,b-1);break;case"ArrowDown":if(O==x.length-1&&b==A-1)break;b===null&&A>0?f(O,0):b==A-1||A==0?f(O+1,null):f(O,b+1);break;case"ArrowLeft":b!==null?f(O,null):_(x[O][0],x[O][1]);break;case"ArrowRight":x[O][1].visibility!=="open"?_(x[O][0],x[O][1]):b===null&&A!==0&&f(O,0);break;case"Enter":case" ":const R=x[O][0];if(p({fileId:R,isTransient:!0}),a(R),b!==null){const H=x[O][1].matches[b].line,z=x[O][1].matches[b].index,Z=mm(R,s);h.has(Z)&&t3(h.get(Z).editor,g,H,z)}break}const T=x[O][0],L=document.getElementById("sidebar-view-container");if(L)if(b===null){const R=document.getElementById(T);n3(L,R)||R.scrollIntoView({block:"center"})}else{const R=x[O][1].matches[b].line,H=document.getElementById(T+"-"+R);n3(L,H)||H.scrollIntoView({block:"center"})}};return N.useEffect(()=>{k.current&&k.current.focus()},[S]),X.jsxs("div",{children:[X.jsx(Ir.Group,{className:"sidebar-search-form mb-3",controlId:"searchName",children:X.jsx(Ir.Control,{type:"text",value:g,onChange:C=>o(C.target.value),ref:k,spellCheck:"false"})}),Object.keys(y).length>=1&&g.trim().length>=1?X.jsx("div",{onKeyDown:P,tabIndex:0,className:"search-results",children:x.map(([C,A],T)=>{const L=A.matches;return X.jsxs("div",{className:"search-result",children:[X.jsxs("div",{onClick:()=>M(C,T),id:C,className:`search-file-heading
|
|
378
|
+
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});mi["tag-file-added"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-changed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-deleted"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-renamed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),r.fl()},partials:{},subs:{}});class __e{constructor({compiledTemplates:e={},rawTemplates:n={}}){const r=Object.entries(n).reduce((i,[o,s])=>{const a=ii.compile(s,{asString:!1});return Object.assign(Object.assign({},i),{[o]:a})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},mi),e),r)}static compile(e){return ii.compile(e,{asString:!1})}render(e,n,r,i,o){const s=this.templateKey(e,n);try{return this.preCompiledTemplates[s].render(r,i,o)}catch{throw new Error(`Could not find template to render '${s}'`)}}template(e,n){return this.preCompiledTemplates[this.templateKey(e,n)]}templateKey(e,n){return`${e}-${n}`}}const P_e=Object.assign(Object.assign(Object.assign({},aW),lW),{outputFormat:Vxe.LINE_BY_LINE,drawFileList:!0});function C_e(t,e={}){const n=Object.assign(Object.assign({},P_e),e),r=typeof t=="string"?Jxe(t,n):t,i=new __e(n),{colorScheme:o}=n,s={colorScheme:o},a=n.drawFileList?new p_e(i,s).render(r):"",l=n.outputFormat==="side-by-side"?new w_e(i,n).render(r):new v_e(i,n).render(r);return a+l}const E_e=({diffData:t,messageId:e,chatId:n,beforeFiles:r,canUndo:i=!1})=>{const[o,s]=N.useState(!1),{aiChatUndoEndpoint:a,aiChatOptions:l={}}=N.useContext(qr),u=Object.values(t).filter(g=>g.length>0);if(u.length===0)return null;const c=async()=>{if(!(!e||!n||!r||o||!a)){s(!0);try{const g=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({vizId:l.vizId,chatId:n,messageId:e})});if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`)}catch(g){console.error("Error undoing AI edit:",g)}finally{s(!1)}}};let f=0,d=0;for(const g of u){const y=Uxe(g);f+=y.additions,d+=y.deletions}const h=qxe(t),p=C_e(h,{drawFileList:!1,matching:"words",diffStyle:"word",outputFormat:"line-by-line"});return X.jsxs("div",{className:"diff-view",children:[X.jsx("div",{className:"diff-summary",children:X.jsxs("div",{className:"diff-stats",children:[X.jsxs("span",{className:"files-changed",children:[u.length," file",u.length!==1?"s":""," changed"]}),f>0&&X.jsxs("span",{className:"additions",children:["+",f]}),d>0&&X.jsxs("span",{className:"deletions",children:["-",d]})]})}),X.jsx("div",{className:"diff-files",dangerouslySetInnerHTML:{__html:p}}),i&&r&&X.jsx("div",{className:"undo-button-container",children:X.jsx("button",{className:"undo-button",onClick:c,disabled:o,title:"Undo this AI edit",children:o?"Undoing...":"Undo"})})]})},T_e=({id:t,role:e,content:n,timestamp:r,isStreaming:i,diffData:o,beforeFiles:s,chatId:a,canUndo:l})=>{const u=N.useMemo(()=>ahe(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[r]),c=N.useMemo(()=>`ai-chat-message ${e}${i?" streaming":""}`,[e,i]);return X.jsxs("div",{className:c,children:[X.jsxs("div",{className:"ai-chat-message-content",children:[X.jsx(Mz,{remarkPlugins:[nW],children:n}),o&&Object.keys(o).length>0&&X.jsx(E_e,{diffData:o,messageId:t,chatId:a,beforeFiles:s,canUndo:l})]}),X.jsx("div",{className:"ai-chat-message-time",children:u})]})},R_e=N.memo(T_e),A_e=()=>X.jsx("div",{className:"ai-chat-message assistant",children:X.jsx("div",{className:"ai-chat-message-content",children:X.jsxs("div",{className:"ai-chat-typing",children:[X.jsx("span",{}),X.jsx("span",{}),X.jsx("span",{})]})})}),M_e=N.memo(A_e),D_e=({content:t,isVisible:e})=>!e||!t?null:X.jsxs("div",{className:"thinking-scratchpad",children:[X.jsxs("div",{className:"thinking-scratchpad-header",children:[X.jsx("span",{className:"thinking-scratchpad-icon",children:"🧠"}),X.jsx("span",{className:"thinking-scratchpad-title",children:"VizBot is thinking..."})]}),X.jsx("div",{className:"thinking-scratchpad-content",children:X.jsx(Mz,{remarkPlugins:[nW],children:t})})]}),I_e=N.memo(D_e),$_e=({messages:t,aiStatus:e,isLoading:n,chatId:r,aiScratchpad:i})=>{const o=N.useRef(null),s=N.useRef(null),[a,l]=N.useState(!1),[u,c]=N.useState(!0),f=N.useRef(),d=N.useCallback(()=>{const S=s.current;if(!S)return!0;const k=50,{scrollTop:x,scrollHeight:_,clientHeight:D}=S;return _-x-D<k},[]),h=N.useCallback(()=>{u&&o.current?.scrollIntoView({behavior:"smooth",block:"end"})},[u]),p=N.useCallback(()=>{if(!s.current)return;const k=d();f.current&&clearTimeout(f.current),!k&&!a&&(l(!0),c(!1)),k&&a&&(f.current=setTimeout(()=>{l(!1),c(!0)},500))},[a,d]);N.useEffect(()=>(u&&!a&&(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{h()},100)),()=>{f.current&&clearTimeout(f.current)}),[t,u,a,h]),N.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const g=t[t.length-1],y=g?.role==="assistant"&&g.content!=="",O=n&&!y,b=!!(i&&i.trim());return X.jsxs("div",{className:"ai-chat-messages",ref:s,onScroll:p,children:[t.map((S,k)=>{const _=S.role==="assistant"&&k===t.length-1&&!n&&S.diffData&&S.beforeFiles&&Object.keys(S.diffData||{}).length>0;return X.jsx(R_e,{id:S.id,role:S.role,content:S.content,timestamp:S.timestamp,diffData:S.diffData,beforeFiles:S.beforeFiles,chatId:r,canUndo:_},S.id)}),b&&X.jsx(I_e,{content:i||"",isVisible:b}),O&&X.jsx(M_e,{}),X.jsx("div",{ref:o})]})},L_e=N.memo($_e),N_e=({aiChatMessage:t,setAIChatMessage:e,onSendMessage:n,isLoading:r,focused:i,aiChatMode:o,setAIChatMode:s})=>{const a=N.useRef(null);N.useEffect(()=>{i&&a.current&&a.current.focus()},[i]);const l=N.useCallback(c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),n())},[n]),u=N.useCallback(c=>{e(c.target.value)},[e]);return X.jsxs("div",{className:"ai-chat-input-container",children:[X.jsxs("div",{className:"ai-chat-mode-toggle",style:{marginBottom:"8px"},children:[X.jsxs(K1e,{size:"sm",children:[X.jsx(QN,{id:"ai-chat-mode-ask",type:"radio",variant:o==="ask"?"primary":"outline-primary",name:"ai-chat-mode",value:"ask",checked:o==="ask",onChange:()=>s("ask"),disabled:r,children:"💬 Ask"}),X.jsx(QN,{id:"ai-chat-mode-edit",type:"radio",variant:o==="edit"?"primary":"outline-primary",name:"ai-chat-mode",value:"edit",checked:o==="edit",onChange:()=>s("edit"),disabled:r,children:"✏️ Edit"})]}),X.jsx("div",{className:"ai-chat-mode-description",children:o==="ask"?"Ask questions without editing files":"Get answers and code edits"})]}),X.jsxs(Ir.Group,{className:"ai-chat-input-group",children:[X.jsx(Ir.Control,{as:"textarea",rows:2,value:t,onChange:u,onKeyDown:l,ref:a,placeholder:o==="edit"?"Ask me to make code changes...":"Ask me anything about your code...",spellCheck:"false",disabled:r,"aria-label":"Chat message input"}),t&&X.jsxs("div",{className:"ai-chat-input-info",children:[X.jsx("span",{className:"ai-chat-hint",children:"Shift+Enter for new line"}),X.jsx("span",{className:"ai-chat-hint",children:"Press Enter to send"})]}),X.jsx(Uu,{variant:"primary",onClick:n,disabled:!t.trim()||r,className:"ai-chat-send-button","aria-label":"Send message",title:"Send message (Enter)",children:"Send"})]})]})},j_e=N.memo(N_e),Q_e="/api/ai-chat/",F_e=()=>{const{aiChatMessage:t,setAIChatMessage:e}=N.useContext(qr),[n,r]=N.useState(!1),[i]=N.useState(()=>fB()),[o,s]=N.useState(null),{aiChatFocused:a,content:l,aiChatEndpoint:u=Q_e,aiChatOptions:c={},aiChatMode:f,setAIChatMode:d}=N.useContext(qr),h=l?.chats?.[i],p=h?.messages||[],g=h?.aiStatus,y=h?.aiScratchpad,O=N.useMemo(()=>p.map((k,x)=>({...k,id:k.id||`msg-${x}`})),[p]),b=p.length===0,S=N.useCallback(async()=>{if(!(!t.trim()||n)){e(""),r(!0),s(null);try{const k=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,vizId:c.vizId,content:t.trim(),chatId:i,mode:f})});if(!k.ok)throw new Error(`HTTP error! status: ${k.status}`);const x=await k.json();if(x.outcome==="failure"&&x.error){s(x.error.message);return}}catch(k){console.error("Error getting AI response:",k),s("Failed to send message. Please try again.")}finally{r(!1)}}},[t,n,u,c,i]);return X.jsx("div",{className:"ai-chat-container",children:X.jsxs("div",{style:{padding:"10px",flex:1,display:"flex",flexDirection:"column"},children:[b?X.jsxs("div",{className:"ai-chat-empty",children:[X.jsx("div",{className:"ai-chat-empty-icon",children:"✨"}),X.jsx("h3",{className:"ai-chat-empty-title",children:"Hi, I'm VizBot!"}),X.jsx("div",{className:"ai-chat-empty-text",children:"How can I help you?"}),X.jsx("div",{className:"ai-chat-empty-examples",children:f==="ask"?X.jsxs(X.Fragment,{children:[X.jsx("h4",{children:"Try asking questions like:"}),X.jsxs("div",{className:"ai-chat-suggested-prompts",children:[X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Explain how this works"),children:'"Explain how this works"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("How could I change it so that the circles are bigger?"),children:'"How could I change it so that the circles are bigger?"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("What does this function do?"),children:'"What does this function do?"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("How can I make this more accessible?"),children:'"How can I make this more accessible?"'})]})]}):X.jsxs(X.Fragment,{children:[X.jsx("h4",{children:"Try edit requests like these:"}),X.jsxs("div",{className:"ai-chat-suggested-prompts",children:[X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Change the circles to squares"),children:'"Change the circles to squares"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Add a button that toggles the animation"),children:'"Add a button that toggles the animation"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Fix the CSS so the layout is responsive"),children:'"Fix the CSS so the layout is responsive"'}),X.jsx("button",{className:"ai-chat-suggested-prompt",onClick:()=>e("Refactor this function to use async/await"),children:'"Refactor this function to use async/await"'})]})]})}),X.jsx("div",{className:"ai-chat-empty-text",children:f==="ask"?"Type your question below to get started!":"Type your edit request below to get started!"})]}):X.jsx(L_e,{messages:O,aiStatus:g,isLoading:n,chatId:i,aiScratchpad:y}),o&&X.jsx("div",{className:"ai-chat-error",children:X.jsxs("div",{className:"ai-chat-error-content",children:[X.jsx("span",{className:"ai-chat-error-icon",children:"⚠️"}),X.jsx("span",{className:"ai-chat-error-message",children:o}),X.jsx("button",{className:"ai-chat-error-dismiss",onClick:()=>s(null),"aria-label":"Dismiss error",children:"×"})]})}),X.jsx(j_e,{aiChatMessage:t,setAIChatMessage:e,onSendMessage:S,isLoading:n,focused:a,aiChatMode:f,setAIChatMode:d})]})})};function B_e(t){const e=t.split(".");switch(e[e.length-1]){case"jsx":case"tsx":return X.jsx(pOe,{});case"js":return X.jsx(dOe,{});case"ts":return X.jsx(hOe,{});case"json":return X.jsx(yOe,{});case"md":return X.jsx(OOe,{});case"html":return X.jsx(gOe,{});case"css":return X.jsx(vOe,{});case"svelte":return X.jsx(mOe,{});default:return X.jsx(XV,{})}}const pR=({name:t})=>X.jsx("i",{className:"file-icon",children:N.useMemo(()=>B_e(t),[t])}),U_e=({show:t,onClose:e,onConfirm:n,isDirectory:r,name:i})=>{const o=N.useCallback(s=>{s.key==="Enter"&&n()},[n]);return N.useEffect(()=>(t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}),[t,o]),X.jsxs($r,{show:t,onHide:e,centered:!0,children:[X.jsx($r.Header,{closeButton:!0,onClick:e,children:X.jsxs($r.Title,{children:["Delete ",r?"Directory":"File"]})}),X.jsx($r.Body,{children:X.jsxs("p",{children:["This will delete the"," ",r?"directory":"file"," ",X.jsx("strong",{children:i}),"."]})}),X.jsxs($r.Footer,{children:[X.jsx(Uu,{variant:"secondary",type:"button",onClick:e,children:"Cancel"}),X.jsx(Uu,{variant:"primary",onClick:n,children:"Delete"})]})]})},q_e=!0,uW=({id:t,name:e,children:n,handleClick:r,handleDoubleClick:i,handleRenameClick:o,handleDeleteClick:s,isDirectory:a=!1,isActive:l=!1,renameFileTooltipText:u=a?"Rename Directory":"Rename File",deleteFileTooltipText:c=a?"Delete Directory":"Delete File"})=>{const{hoveredItemId:f,setHoveredItemId:d}=N.useContext(qr),h=f===t,p=N.useCallback(H=>{d(H?t:null)},[t,d]),[g,y]=N.useState(!1),[O,b]=N.useState(""),[S,k]=N.useState(!1),x=N.useRef(null),_=N.useCallback(H=>{H.key==="Escape"?y(!1):H.key==="Enter"&&x.current.blur()},[]),D=N.useCallback(()=>{y(!1),x.current.value.trim()===""?k(!0):o(x.current.value)},[o]),M=N.useCallback(H=>{H.stopPropagation(),y(!g),b(e)},[e,g]);N.useEffect(()=>{g&&x.current.focus()},[g]);const P=N.useCallback(H=>{H.stopPropagation(),k(!0)},[]),C=N.useCallback(()=>{k(!1)},[]),A=N.useCallback(H=>{H?.stopPropagation(),k(!1),s()},[s]),T=N.useCallback(()=>{p(!0)},[]),L=N.useCallback(()=>{p(!1)},[]),R=N.useCallback(()=>{b(x.current.value)},[]);return X.jsxs("div",{className:`file-or-directory user-select-none ${l?"active-file":""}`,onClick:g?null:r,onDoubleClick:g||!i?null:i,onMouseEnter:T,onMouseLeave:L,children:[X.jsx("div",{className:"name",children:g?X.jsxs(X.Fragment,{children:[X.jsx(pR,{name:O}),X.jsx("input",{className:"rename-input",ref:x,type:"text","aria-label":"Field name",value:O,onKeyDown:_,onBlur:D,onChange:R})]}):n}),h&&!g?X.jsxs("div",{className:"utils",style:{position:"relative"},children:[!a||q_e?X.jsx(ns,{placement:"top",overlay:X.jsx(rs,{id:"rename-file-tooltip",children:u}),children:X.jsx("i",{onClick:M,className:"icon-button icon-button-dark",children:X.jsx(nOe,{})})}):null,X.jsx(ns,{placement:"top",overlay:X.jsx(rs,{id:"delete-file-tooltip",children:c}),children:X.jsx("i",{onClick:P,className:"icon-button icon-button-dark",children:X.jsx(oOe,{})})})]}):null,S&&X.jsx(U_e,{show:S,onClose:C,onConfirm:A,isDirectory:a,name:e})]})},V_e=({name:t,path:e,children:n,handleFileClick:r,handleFileDoubleClick:i})=>{const{renameDirectory:o,deleteDirectory:s,isDirectoryOpen:a,toggleDirectory:l,sidebarPresenceIndicators:u}=N.useContext(qr),c=N.useCallback(()=>{l(e)},[l,e]),f=N.useCallback(()=>{s(e)},[s,e]),d=N.useCallback(p=>{o(e,t,p)},[o,e,t]),h=N.useMemo(()=>a(e),[a,e]);return X.jsxs(X.Fragment,{children:[X.jsxs(uW,{id:e,name:t,handleClick:c,handleDeleteClick:f,handleRenameClick:d,isDirectory:!0,children:[X.jsx("div",{className:"arrow-wrapper",style:{transform:`rotate(${h?90:0}deg)`},children:X.jsx(HV,{})}),X.jsx("div",{className:"name",children:t})]}),n&&h?X.jsx("div",{className:"indentation",children:n.map(p=>{const{fileId:g}=p,{path:y}=p;return X.jsx(cW,{entity:p,handleFileClick:r,handleFileDoubleClick:i},g||y)})}):null]})},z_e=({presence:t})=>X.jsx("div",{className:"presence-indicators",children:t.map((e,n)=>{const i=`rgb(${Q8(e.username)})`;return X.jsx("div",{className:"presence-indicator",style:{backgroundColor:i},children:e.username[0]},n)})}),W_e=({name:t,fileId:e,handleFileClick:n,handleFileDoubleClick:r,isActive:i,presence:o})=>{const{renameFile:s,deleteFile:a}=N.useContext(qr),l=N.useCallback(()=>{n(e)},[e,n]),u=N.useCallback(()=>{r(e)},[e,r]),c=N.useCallback(()=>{a(e)},[e,a]),f=N.useCallback(d=>{s(e,d)},[e,s]);return X.jsxs(uW,{id:e,name:t,handleClick:l,handleDoubleClick:u,handleDeleteClick:c,handleRenameClick:f,isActive:i,children:[X.jsx(z_e,{presence:o}),X.jsx(pR,{name:t}),t]})},cW=({entity:t,handleFileClick:e,handleFileDoubleClick:n})=>{const{activePane:r,sidebarPresenceIndicators:i}=N.useContext(qr),{name:o,file:s,fileId:a}=t,{path:l,children:u}=t,c=i?.filter(f=>f.fileId===a)||[];return s?X.jsx(W_e,{fileId:a,name:o,handleFileClick:e,handleFileDoubleClick:n,isActive:a===r.activeFileId,presence:c}):X.jsx(V_e,{name:o,path:l,children:u,handleFileClick:e,handleFileDoubleClick:n})};function t3(t,e,n,r){const i=t.state.doc.line(n).from+r;t.dispatch({selection:{anchor:i,head:i+e.length},scrollIntoView:!0,effects:St.scrollIntoView(i,{y:"center"})})}function n3(t,e){const n=t.scrollTop,r=n+t.clientHeight,i=e.offsetTop-t.offsetTop,o=i+e.clientHeight;return i>=n+100&&o<=r-100}const Z_e=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{search:i,setSearch:o,activePaneId:s,setActiveFileId:a,setSearchResults:l,setSearchFileVisibility:u,setSearchLineVisibility:c,setSearchFocusedIndex:f,shareDBDoc:d,editorCache:h,openTab:p}=N.useContext(qr),{pattern:g,results:y,focusedIndex:O,focusedChildIndex:b,focused:S}=i,k=N.useRef(null),x=Object.entries(y).filter(([C,A])=>A.visibility!=="closed");N.useEffect(()=>{if(t){r(g.trim().length>=1);const C=setTimeout(()=>{g.trim().length>=1&&k.current&&(l(d),r(!1))},2e3);return()=>clearTimeout(C)}else e(!0)},[g]);const _=N.useCallback((C,A)=>{u(d,C,A.visibility==="open"&&b===null?"flattened":"open")},[O,b]),D=N.useCallback(C=>{u(d,C,"closed")},[]),M=N.useCallback((C,A)=>{a(C),f(A,null)},[]),P=C=>{if(C.preventDefault(),x.length===0)return;const A=x[O][1].matches.length;switch(C.key){case"Tab":f(O,null);break;case"ArrowUp":if(O==0&&b==null)break;if(b===null||A==0){const H=x[O-1][1].matches.length;f(O-1,H>0?H-1:null)}else b===0?f(O,null):f(O,b-1);break;case"ArrowDown":if(O==x.length-1&&b==A-1)break;b===null&&A>0?f(O,0):b==A-1||A==0?f(O+1,null):f(O,b+1);break;case"ArrowLeft":b!==null?f(O,null):_(x[O][0],x[O][1]);break;case"ArrowRight":x[O][1].visibility!=="open"?_(x[O][0],x[O][1]):b===null&&A!==0&&f(O,0);break;case"Enter":case" ":const R=x[O][0];if(p({fileId:R,isTransient:!0}),a(R),b!==null){const H=x[O][1].matches[b].line,z=x[O][1].matches[b].index,Z=mm(R,s);h.has(Z)&&t3(h.get(Z).editor,g,H,z)}break}const T=x[O][0],L=document.getElementById("sidebar-view-container");if(L)if(b===null){const R=document.getElementById(T);n3(L,R)||R.scrollIntoView({block:"center"})}else{const R=x[O][1].matches[b].line,H=document.getElementById(T+"-"+R);n3(L,H)||H.scrollIntoView({block:"center"})}};return N.useEffect(()=>{k.current&&k.current.focus()},[S]),X.jsxs("div",{children:[X.jsx(Ir.Group,{className:"sidebar-search-form mb-3",controlId:"searchName",children:X.jsx(Ir.Control,{type:"text",value:g,onChange:C=>o(C.target.value),ref:k,spellCheck:"false"})}),Object.keys(y).length>=1&&g.trim().length>=1?X.jsx("div",{onKeyDown:P,tabIndex:0,className:"search-results",children:x.map(([C,A],T)=>{const L=A.matches;return X.jsxs("div",{className:"search-result",children:[X.jsxs("div",{onClick:()=>M(C,T),id:C,className:`search-file-heading
|
|
379
379
|
${O==T&&b==null?"active":""}`,children:[X.jsxs("div",{className:"search-file-title",children:[X.jsx("div",{className:"arrow-wrapper",onClick:()=>_(C,A),style:{transform:`rotate(${A.visibility==="open"?90:0}deg)`},children:X.jsx(HV,{})}),X.jsxs("div",{className:"search-file-name",children:[X.jsx(pR,{name:A.name}),X.jsx("h5",{children:A.name})]})]}),X.jsx("div",{className:"search-file-info",children:T==O&&b==null?X.jsx("span",{className:"search-file-close",onClick:R=>{R.stopPropagation(),D(C),f(Math.max(0,T-1),null)},children:X.jsx(qO,{})}):X.jsx("h6",{className:"search-file-count",children:L.length})})]}),X.jsx("div",{className:"search-file-lines",children:(A.visibility==="open"||A.visibility==="flattened"&&T==O&&b!==null)&&A.matches.map((R,H)=>{const z=R.text.substring(0,R.index),Z=R.text.substring(R.index,R.index+g.length),G=R.text.substring(R.index+g.length),K=A.name+"-"+R.line;return X.jsxs("div",{tabIndex:T==O?0:-1,id:C+"-"+R.line,className:`search-line
|
|
380
380
|
${O==T&&b==H?"active":""}`,children:[X.jsxs("p",{onClick:()=>{f(T,H),p({fileId:C,isTransient:!0}),a(C);const U=mm(C,s);h.has(U)&&t3(h.get(U).editor,g,R.line,R.index)},children:[z,X.jsx("span",{className:"search-pattern",children:Z}),G]},A.name+" - "+R.line+" - "+R.index),O==T&&b===H&&X.jsx("span",{className:"search-file-close",onClick:U=>{U.stopPropagation(),c(d,C,R.line),H==0&&f(T,null)},children:X.jsx(qO,{})})]},K)})})]},A.name)})}):X.jsx("div",{className:"search-state",children:X.jsx("h6",{children:n?"Searching...":"No Results"})})]})},Hs=!1,X_e=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{createFile:i}=N.useContext(qr),o=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),e(!0)},[]),s=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),t||e(!0)},[t]),a=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),e(!1)},[]),l=p=>["text/","application/json","application/javascript","application/typescript","application/xml","application/x-httpd-php"].some(O=>p.type.startsWith(O))||p.name.match(/\.(txt|js|jsx|ts|tsx|md|css|scss|html|xml|json|php|py|rb|java|c|cpp|h|hpp)$/i)!==null,u=p=>["image/"].some(O=>p.type.startsWith(O))||p.name.match(/\.(png|jpg|jpeg|gif|bmp|svg|webp)$/i)!==null,c=p=>new Promise((g,y)=>{if(!l(p)){y(new Error(`File ${p.name} is not a text file`));return}const O=new FileReader;O.onload=b=>{b.target?.result?g(b.target.result):y(new Error(`Failed to read file ${p.name}`))},O.onerror=()=>{y(new Error(`Error reading file ${p.name}`))},O.readAsText(p)}),f=p=>new Promise((g,y)=>{if(!u(p)){y(new Error(`File ${p.name} is not an image file`));return}if(p.type==="image/svg+xml"||p.name.toLowerCase().endsWith(".svg")){const b=new FileReader;b.onload=S=>{S.target?.result?g(S.target.result):y(new Error(`Failed to read SVG file ${p.name}`))},b.onerror=()=>y(new Error(`Error reading SVG file ${p.name}`)),b.readAsText(p);return}const O=new FileReader;O.onload=b=>{if(b.target?.result){const S=b.target.result.split(",")[1];g(S)}else y(new Error(`Failed to read image file ${p.name}`))},O.onerror=()=>{y(new Error(`Error reading image file ${p.name}`))},O.readAsDataURL(p)}),d=async(p,g)=>{try{if(Hs&&console.log(`[useDragAndDrop] Processing entry: ${p.name} at path: ${g}`),p.isFile)Hs&&console.log(`[useDragAndDrop] Processing file: ${p.name}`),p.file(async y=>{try{if(u(y)){const O=await f(y);Hs&&console.log(`[useDragAndDrop] Creating image file: ${g}${y.name}`),i(`${g}${y.name}`,O)}else{const O=await c(y);Hs&&console.log(`[useDragAndDrop] Creating text file: ${g}${y.name}`),i(`${g}${y.name}`,O)}}catch(O){console.error(`Error processing file ${y.name}:`,O)}});else if(p.isDirectory)return Hs&&console.log(`[useDragAndDrop] Processing directory: ${p.name}`),new Promise(y=>{const O=p.createReader(),b=()=>{O.readEntries(async S=>{if(S.length===0){Hs&&console.log(`[useDragAndDrop] Finished reading directory: ${p.name}`),y();return}const k=`${g}${p.name}/`;Hs&&console.log(`[useDragAndDrop] Reading ${S.length} entries in directory: ${k}`),await Promise.all(S.map(x=>d(x,k))),b()})};b()})}catch(y){console.error(`Error processing entry ${p.name}:`,y)}},h=N.useCallback(async p=>{p.preventDefault(),p.stopPropagation(),e(!1),r(!0);try{const g=p.dataTransfer.items;Hs&&console.log(`[useDragAndDrop] Processing ${g.length} dropped items`);const y=[];for(const O of Array.from(g)){const b=O.webkitGetAsEntry?.()||O.getAsEntry?.()||O.createEntry?.();if(b)Hs&&console.log(`[useDragAndDrop] Got entry for: ${b.name}`),y.push(b);else if(O.kind==="file"){const S=O.getAsFile();if(S){Hs&&console.log(`[useDragAndDrop] Processing dropped file: ${S.name}`);try{if(u(S)){const k=await f(S);i(S.name,k)}else{const k=await c(S);i(S.name,k)}}catch(k){console.error(`Error processing file ${S.name}:`,k)}}}}Hs&&console.log(`[useDragAndDrop] Processing ${y.length} entries`),await Promise.all(y.map(O=>d(O,"")))}catch(g){console.error("Error processing dropped items:",g)}finally{r(!1)}},[i]);return{isDragOver:t,isProcessing:n,handleDragEnter:o,handleDragOver:s,handleDragLeave:a,handleDrop:h}};function H_e(t,e){const n={},d=[{regex:/^\s*###\s*`([^`]+)`\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Backtick-Heading Format",key:"backtick-heading"},{regex:/^\s*###\s*File:\s*\*\*(.+?)\*\*\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"File Bold Format",key:"file-bold"},{regex:/^\s*###\s*\d+\.\s*`([^`]+)`(?:[^\n]*\n)*?\s*```(?:\w+)?\n([\s\S]*?)```/gm,format:"Numbered Backtick Format",key:"numbered-backtick"},{regex:/^### \*\*([^\n`]+?)\*\*\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Heading Bold Format",key:"heading-bold"},{regex:/^\s*###\s*(?!`|File:|\d+\.)\s*([^\n`]+?)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Standard Heading Format",key:"standard-heading"},{regex:/^\s*(?!###|\*\*|`)([^\n#*`]+?):\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Colon Format",key:"colon"},{regex:/^\s*(?!###)\*\*([^\n*`]+?)\*\*(?:[^\n]*)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Bold Format",key:"bold"},{regex:/^\s*# ([^\n`]+?)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Hash Format",key:"hash"},{regex:/^\s*\d+\.\s*\*\*([^\n`]+?)\*\*[\s\S]*?\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Numbered Bold Format",key:"numbered-bold"}];let h=d;{const g=d.find(y=>y.key===e);if(!g)throw new Error(`Unsupported format: ${e}`);h=[g]}let p="Unknown Format";for(const{regex:g,format:y}of h){g.lastIndex=0;const O={};let b;for(;(b=g.exec(t))!==null;){let S=b[1].trim();y==="Bold Format"&&(S=S.replace(/\s*\([^)]*\).*$/,"").trim());const k=b[2].trim();O[S]=k}if(Object.keys(O).length>0){Object.assign(n,O),p=y;break}}return{files:n,format:p}}const Y_e=t=>t.endsWith(".html")?"html":t.endsWith(".js")?"javascript":t.endsWith(".css")?"css":"",G_e=t=>Object.entries(t).map(([e,n])=>[`**${e}**
|
|
381
381
|
`,"```"+Y_e(e),n,"```\n"].join(`
|
package/dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-A_vWxXLO.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-BXyJ2hMf.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
|
@@ -25,7 +25,8 @@ export const DiffView: React.FC<DiffViewProps> = ({
|
|
|
25
25
|
canUndo = false,
|
|
26
26
|
}) => {
|
|
27
27
|
const [isUndoing, setIsUndoing] = useState(false);
|
|
28
|
-
const { aiChatUndoEndpoint } =
|
|
28
|
+
const { aiChatUndoEndpoint, aiChatOptions = {} } =
|
|
29
|
+
useContext(VZCodeContext);
|
|
29
30
|
|
|
30
31
|
const unifiedDiffs = Object.values(diffData).filter(
|
|
31
32
|
(diff) => diff.length > 0,
|
|
@@ -54,6 +55,7 @@ export const DiffView: React.FC<DiffViewProps> = ({
|
|
|
54
55
|
'Content-Type': 'application/json',
|
|
55
56
|
},
|
|
56
57
|
body: JSON.stringify({
|
|
58
|
+
vizId: aiChatOptions.vizId,
|
|
57
59
|
chatId,
|
|
58
60
|
messageId,
|
|
59
61
|
}),
|