nothumanallowed 14.1.74 → 14.1.75
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothumanallowed",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.75",
|
|
4
4
|
"description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/constants.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
7
|
|
|
8
|
-
export const VERSION = '14.1.
|
|
8
|
+
export const VERSION = '14.1.75';
|
|
9
9
|
export const BASE_URL = 'https://nothumanallowed.com/cli';
|
|
10
10
|
export const API_BASE = 'https://nothumanallowed.com/api/v1';
|
|
11
11
|
|
|
@@ -588,7 +588,7 @@ ${u}
|
|
|
588
588
|
|
|
589
589
|
`),r=`The user asked: "${e}"\n\nHere are the responses from ${t.length} specialist agents:\n\n${n}\n\nSynthesize these responses into a unified analysis.`,i=``;try{await ne(`/api/chat/stream`,{message:r,systemPrompt:`You are the Conductor — a meta-agent that synthesizes the outputs of multiple specialist AI agents.
|
|
590
590
|
Your job: examine all agent responses to a user's question, identify agreements, disagreements, complementary insights, and deliver a unified, high-quality synthesis.
|
|
591
|
-
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},pe=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=D.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),F(e,{voiceActive:!1});return}let r=new t;D.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;F(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>F(e,{voiceActive:!1}),r.onerror=()=>F(e,{voiceActive:!1}),r.start(),F(e,{voiceActive:!0})},me=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];F(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{F(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},he=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];F(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},ge=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),T(``)},_e=async e=>{let t=await O(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),T(``)},ve=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){T(`Tagline and system prompt are required.`);return}ee(!0),T(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){T(`Agent name required (lowercase, no spaces).`),ee(!1);return}let t=await k(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){T(`Error: `+t.error),ee(!1);return}}else await k(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),ie()}catch(e){T(`Error: `+e.message)}finally{ee(!1)}}},I=e=>{confirm(`Delete agent "${e.label}"?`)&&k(`/api/agents/${e.id}`,{},`DELETE`).then(()=>ie())};return r?(0,j.jsx)(`div`,{className:q.root,children:(0,j.jsx)(`div`,{className:q.loading,children:(0,j.jsx)(`div`,{className:`spinner`})})}):(0,j.jsxs)(`div`,{className:q.root,children:[(0,j.jsxs)(`div`,{className:q.gridSection,children:[(0,j.jsxs)(`div`,{className:q.gridHeader,children:[(0,j.jsxs)(`div`,{className:q.headerRow,children:[(0,j.jsx)(`input`,{className:q.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,j.jsx)(`button`,{className:q.createBtn,onClick:ge,children:`+ Create`})]}),(0,j.jsx)(`div`,{className:q.catTabs,children:ae.map(e=>(0,j.jsxs)(`button`,{className:`${q.catTab} ${s===e?q.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,j.jsx)(`div`,{className:q.grid,children:oe.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,j.jsxs)(`div`,{className:`${q.agentCard} ${t?q.agentActive:``}`,onClick:()=>se(e),children:[(0,j.jsxs)(`div`,{className:q.agentCardTop,children:[(0,j.jsx)(`div`,{className:q.agentIcon,children:e.icon}),e.isCustom&&(0,j.jsxs)(`div`,{className:q.agentActions,children:[(0,j.jsx)(`button`,{className:q.agentEditBtn,onClick:t=>{t.stopPropagation(),_e(e)},children:`✏️`}),(0,j.jsx)(`button`,{className:q.agentDelBtn,onClick:t=>{t.stopPropagation(),I(e)},children:`🗑`})]})]}),(0,j.jsx)(`div`,{className:q.agentLabel,children:e.label}),(0,j.jsx)(`div`,{className:q.agentDesc,children:e.description}),(0,j.jsx)(`div`,{className:q.agentCat,children:e.category})]},e.id)})})]}),(0,j.jsx)(`div`,{className:q.chatArea,children:l.length===0?(0,j.jsxs)(`div`,{className:q.emptyChat,children:[(0,j.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,j.jsx)(`span`,{className:q.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,j.jsxs)(`div`,{className:q.chatPanel,children:[(0,j.jsxs)(`div`,{className:q.chatHeader,children:[(0,j.jsx)(`span`,{className:q.chatIcon,children:t.icon}),(0,j.jsxs)(`div`,{className:q.chatHeaderInfo,children:[(0,j.jsx)(`div`,{className:q.chatAgentName,children:t.label}),(0,j.jsx)(`div`,{className:q.chatAgentDesc,children:t.description})]}),(0,j.jsx)(`button`,{className:q.closeChat,onClick:()=>ce(t.id),children:`✕`})]}),(0,j.jsxs)(`div`,{className:q.chatMessages,ref:e=>{A.current.set(t.id,e)},children:[e.history.length===0&&(0,j.jsxs)(`div`,{className:q.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,j.jsx)(`div`,{className:`${q.chatMsg} ${e.role===`user`?q.msgUser:q.msgAgent}`,children:e.role===`assistant`?(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ye(e.content||`…`)}}):(0,j.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,j.jsxs)(`div`,{className:q.thinking,children:[(0,j.jsx)(`span`,{className:q.dot}),(0,j.jsx)(`span`,{className:q.dot}),(0,j.jsx)(`span`,{className:q.dot})]})]}),n&&(0,j.jsxs)(`div`,{className:q.attachBar,children:[(0,j.jsx)(`span`,{children:n}),(0,j.jsx)(`button`,{className:q.attachClear,onClick:()=>F(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,j.jsxs)(`div`,{className:q.chatInput,children:[(0,j.jsxs)(`div`,{className:q.chatTools,children:[(0,j.jsx)(`button`,{className:`${q.toolBtn} ${e.voiceActive?q.toolBtnActive:``}`,onClick:()=>pe(t.id),title:`Voice`,children:`🎤`}),(0,j.jsx)(`button`,{className:q.toolBtn,onClick:()=>re.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,j.jsx)(`button`,{className:q.toolBtn,onClick:()=>M.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,j.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{re.current.set(t.id,e)},onChange:e=>me(t.id,e.target.files?.[0])}),(0,j.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{M.current.set(t.id,e)},onChange:e=>he(t.id,e.target.files?.[0])})]}),(0,j.jsxs)(`div`,{className:q.chatInputRow,children:[(0,j.jsx)(`textarea`,{className:q.chatTextarea,value:e.input,onChange:e=>F(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),de(e,e.input,e.attachedFile,e.attachedImage))}}),(0,j.jsx)(`button`,{className:q.sendBtn,onClick:()=>de(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,j.jsxs)(`div`,{className:q.orchBar,children:[(0,j.jsxs)(`div`,{className:q.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,j.jsxs)(`div`,{className:q.orchRow,children:[(0,j.jsx)(`textarea`,{ref:N,className:q.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),fe())}}),(0,j.jsx)(`button`,{className:q.orchBtn,onClick:fe,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,j.jsxs)(`div`,{className:q.orchSynthesis,children:[(0,j.jsxs)(`div`,{className:q.orchSynthHeader,children:[(0,j.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,j.jsx)(`span`,{className:q.orchSynthSpinner,children:`synthesizing…`})]}),(0,j.jsx)(`div`,{className:q.orchSynthBody,dangerouslySetInnerHTML:{__html:ye(h||`…`)}})]})]}),b&&(0,j.jsx)(`div`,{className:q.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,j.jsxs)(`div`,{className:q.modal,children:[(0,j.jsx)(`div`,{className:q.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,j.jsx)(`input`,{className:q.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`Tagline`}),(0,j.jsx)(`input`,{className:q.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`System Prompt`}),(0,j.jsx)(`textarea`,{className:q.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,j.jsx)(`div`,{className:q.formError,children:w}),(0,j.jsxs)(`div`,{className:q.modalBtns,children:[(0,j.jsx)(`button`,{className:q.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,j.jsx)(`button`,{className:q.modalSaveBtn,onClick:ve,disabled:E,children:E?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var J={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function Zt(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function Qt(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function $t(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),O(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{T()},[]);let E=e=>{c(e),T(e,l)},ee=()=>{u(d),T(s,d)},D=(e,t)=>{i(!0),O(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},te=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await k(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ne=(e,t)=>{i(!0),O(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},A=(e,t)=>{i(!0),O(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},re=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&k(`/api/drive/delete/${e}`,{}).then(()=>{n(null),T()})},M=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&k(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?D(t.id,e):T()}).catch(e=>alert(`Error: `+e.message))},N=()=>{w.current?.click()},ie=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;k(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),T()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,j.jsxs)(`div`,{className:J.error,children:[(0,j.jsx)(`div`,{children:a}),(0,j.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,j.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,j.jsxs)(`div`,{className:J.editorRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:h.name}),(0,j.jsx)(`button`,{className:J.saveBtn,onClick:te,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,j.jsx)(`textarea`,{className:J.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,j.jsxs)(`div`,{className:J.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,j.jsxs)(`div`,{className:J.viewerRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:b.name})]}),(0,j.jsx)(`div`,{className:J.imgContainer,children:(0,j.jsx)(`img`,{src:b.src,alt:b.name,className:J.imgView})})]});if(p===`pdf`&&b)return(0,j.jsxs)(`div`,{className:J.viewerRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:b.name})]}),(0,j.jsx)(`iframe`,{className:J.pdfFrame,src:b.src,title:b.name})]});let ae=t?.files??[],oe=t?.quota;return(0,j.jsxs)(`div`,{className:J.root,children:[oe&&(0,j.jsxs)(`div`,{className:J.quotaBar,children:[(0,j.jsxs)(`div`,{className:J.quotaText,children:[(0,j.jsxs)(`span`,{className:J.quotaUsed,children:[oe.usage,` of `,oe.limit,` used`]}),(0,j.jsxs)(`span`,{className:J.quotaPct,children:[oe.percentUsed,`%`]})]}),(0,j.jsx)(`div`,{className:J.quotaTrack,children:(0,j.jsx)(`div`,{className:J.quotaFill,style:{width:`${Math.min(oe.percentUsed,100)}%`,background:oe.percentUsed>90?`var(--red)`:oe.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,j.jsxs)(`div`,{className:J.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,j.jsx)(`button`,{className:`${J.filterBtn} ${s===e?J.filterActive:``}`,onClick:()=>E(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,j.jsx)(`div`,{className:J.spacer}),(0,j.jsx)(`button`,{className:J.newBtn,onClick:M,children:`+ New File`}),(0,j.jsx)(`button`,{className:J.uploadBtn,onClick:N,children:e(`drive.upload`)}),(0,j.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>ie(e.target.files?.[0])})]}),(0,j.jsxs)(`div`,{className:J.searchRow,children:[(0,j.jsx)(`input`,{className:J.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ee()}),(0,j.jsx)(`button`,{className:J.searchBtn,onClick:ee,children:`Search`})]}),r&&(0,j.jsx)(`div`,{className:J.loading,children:(0,j.jsx)(`div`,{className:`spinner`})}),!r&&ae.length===0&&(0,j.jsxs)(`div`,{className:J.empty,children:[e(`drive.noFiles`),` found`]}),(0,j.jsx)(`div`,{className:J.fileList,children:ae.map(e=>{let t=Qt(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,j.jsxs)(`div`,{className:J.fileRow,onClick:()=>{t?D(e.id,e.name):n?ne(e.id,e.name):r?A(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,j.jsx)(`span`,{className:J.fileIcon,children:Zt(e.type,e.mimeType)}),(0,j.jsxs)(`div`,{className:J.fileInfo,children:[(0,j.jsx)(`div`,{className:J.fileName,children:e.name}),(0,j.jsxs)(`div`,{className:J.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,j.jsxs)(`div`,{className:J.fileBtns,children:[t&&(0,j.jsx)(`button`,{className:J.editBtn,onClick:t=>{t.stopPropagation(),D(e.id,e.name)},children:`Edit`}),n&&(0,j.jsx)(`button`,{className:J.viewBtn,onClick:t=>{t.stopPropagation(),ne(e.id,e.name)},children:`View`}),r&&(0,j.jsx)(`button`,{className:J.pdfBtn,onClick:t=>{t.stopPropagation(),A(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,j.jsx)(`a`,{className:J.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,j.jsx)(`button`,{className:J.delBtn,onClick:t=>{t.stopPropagation(),re(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var Y={root:`_root_a0x57_1`,loading:`_loading_a0x57_10`,errorBox:`_errorBox_a0x57_12`,errorHint:`_errorHint_a0x57_13`,userRow:`_userRow_a0x57_16`,avatar:`_avatar_a0x57_27`,userLogin:`_userLogin_a0x57_29`,userName:`_userName_a0x57_30`,disconnectBtn:`_disconnectBtn_a0x57_32`,repoBar:`_repoBar_a0x57_43`,repoInput:`_repoInput_a0x57_49`,issuesBtn:`_issuesBtn_a0x57_61`,prsBtn:`_prsBtn_a0x57_72`,repoPills:`_repoPills_a0x57_83`,repoPill:`_repoPill_a0x57_83`,issueCount:`_issueCount_a0x57_106`,tabs:`_tabs_a0x57_112`,tab:`_tab_a0x57_112`,tabActive:`_tabActive_a0x57_131`,markRead:`_markRead_a0x57_137`,content:`_content_a0x57_148`,empty:`_empty_a0x57_150`,notifRow:`_notifRow_a0x57_152`,issueRow:`_issueRow_a0x57_152`,prRow:`_prRow_a0x57_152`,notifRepo:`_notifRepo_a0x57_166`,notifType:`_notifType_a0x57_167`,notifTitle:`_notifTitle_a0x57_168`,notifMeta:`_notifMeta_a0x57_169`,issueNum:`_issueNum_a0x57_171`,issueTitle:`_issueTitle_a0x57_172`,issueMeta:`_issueMeta_a0x57_173`,issueLabel:`_issueLabel_a0x57_174`,prNum:`_prNum_a0x57_176`,prTitle:`_prTitle_a0x57_177`,prAuthor:`_prAuthor_a0x57_178`,prDraft:`_prDraft_a0x57_179`,prMeta:`_prMeta_a0x57_180`};function en(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),O(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>k(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&k(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})};if(r)return(0,j.jsx)(`div`,{className:Y.loading,children:(0,j.jsx)(`div`,{className:`spinner`})});if(t?.error)return(0,j.jsxs)(`div`,{className:Y.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:Y.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set github-token YOUR_PAT`})]})]});let g=t?.user,v=Array.isArray(t?.notifications)?t.notifications:[],y=Array.isArray(t?.issues)?t.issues:[],b=Array.isArray(t?.prs)?t.prs:[];return(0,j.jsxs)(`div`,{className:Y.root,children:[g?.login&&(0,j.jsxs)(`div`,{className:Y.userRow,children:[g.avatar&&(0,j.jsx)(`img`,{src:g.avatar,className:Y.avatar,alt:g.login}),(0,j.jsxs)(`div`,{style:{flex:1},children:[(0,j.jsxs)(`div`,{className:Y.userLogin,children:[`@`,g.login]}),g.name&&(0,j.jsx)(`div`,{className:Y.userName,children:g.name})]}),(0,j.jsx)(`button`,{className:Y.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,j.jsxs)(`div`,{className:Y.repoBar,children:[(0,j.jsx)(`input`,{className:Y.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,j.jsx)(`button`,{className:Y.issuesBtn,onClick:f,children:`Issues`}),(0,j.jsx)(`button`,{className:Y.prsBtn,onClick:p,children:`PRs`})]}),g?.repos&&g.repos.length>0&&(0,j.jsx)(`div`,{className:Y.repoPills,children:g.repos.slice(0,12).map(e=>(0,j.jsxs)(`button`,{className:Y.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,j.jsx)(`span`,{className:Y.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,j.jsxs)(`div`,{className:Y.tabs,children:[(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`notifs`?Y.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,v.length>0?`(${v.length})`:``]}),y.length>0&&(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`issues`?Y.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,y.length,`)`]}),b.length>0&&(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`prs`?Y.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,b.length,`)`]}),l===`notifs`&&v.length>0&&(0,j.jsx)(`button`,{className:Y.markRead,onClick:m,children:`Mark all read`})]}),(0,j.jsxs)(`div`,{className:Y.content,children:[l===`notifs`&&(v.length===0?(0,j.jsx)(`div`,{className:Y.empty,children:`No notifications`}):v.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsx)(`span`,{className:Y.notifRepo,children:e.repo}),(0,j.jsxs)(`span`,{className:Y.notifType,children:[`[`,e.type,`]`]}),(0,j.jsx)(`div`,{className:Y.notifTitle,children:e.title}),(0,j.jsxs)(`div`,{className:Y.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(y.length===0?(0,j.jsxs)(`div`,{className:Y.empty,children:[e(`github.noIssues`),` for `,a]}):y.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsxs)(`span`,{className:Y.issueNum,children:[`#`,e.number]}),(0,j.jsx)(`span`,{className:Y.issueTitle,children:e.title}),e.assignee&&(0,j.jsxs)(`span`,{className:Y.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,j.jsxs)(`span`,{className:Y.issueLabel,children:[`[`,e.labels,`]`]}),(0,j.jsx)(`div`,{className:Y.issueMeta,children:e.updated})]},t))),l===`prs`&&(b.length===0?(0,j.jsxs)(`div`,{className:Y.empty,children:[`No PRs for `,a]}):b.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsxs)(`span`,{className:Y.prNum,children:[`#`,e.number]}),(0,j.jsx)(`span`,{className:Y.prTitle,children:e.title}),(0,j.jsxs)(`span`,{className:Y.prAuthor,children:[`by `,e.author]}),e.draft&&(0,j.jsx)(`span`,{className:Y.prDraft,children:`DRAFT`}),(0,j.jsx)(`div`,{className:Y.prMeta,children:e.updated})]},t)))]})]})}var tn={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function nn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)([]),l=()=>{i(!0),O(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},u=e=>{o(e),O(`/api/slack/messages?channel=${e.id}`).then(e=>c(e?.messages??[]))};if((0,_.useEffect)(()=>{l()},[]),r)return(0,j.jsxs)(`div`,{className:tn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,j.jsxs)(`div`,{className:tn.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:tn.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set slack-token xoxb-YOUR-TOKEN`})]})]});let d=t?.channels??[];return(0,j.jsxs)(`div`,{className:tn.twoPane,children:[(0,j.jsxs)(`div`,{className:tn.sidebar,children:[(0,j.jsxs)(`div`,{className:tn.sidebarTitle,children:[(0,j.jsx)(`span`,{children:`💬 Slack`}),t?.workspace&&(0,j.jsx)(`span`,{className:tn.workspace,children:t.workspace})]}),d.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No channels`}),d.map(e=>(0,j.jsxs)(`div`,{className:`${tn.channelItem} ${a?.id===e.id?tn.channelActive:``}`,onClick:()=>u(e),children:[`# `,e.name]},e.id)),(0,j.jsx)(`button`,{className:tn.disconnectBtn,onClick:()=>k(`/api/config`,{key:`slack-token`,value:``}).then(l),children:`Disconnect`})]}),(0,j.jsx)(`div`,{className:tn.messagePane,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:tn.channelHeader,children:[`#`,a.name]}),s.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No messages`}),s.map((e,t)=>(0,j.jsxs)(`div`,{className:tn.message,children:[(0,j.jsx)(`span`,{className:tn.msgUser,children:e.username||e.user||`Unknown`}),(0,j.jsx)(`span`,{className:tn.msgText,children:e.text}),(0,j.jsx)(`span`,{className:tn.msgTs,children:new Date(parseFloat(e.ts)*1e3).toLocaleTimeString()})]},t))]}):(0,j.jsx)(`div`,{className:tn.emptyPane,children:`Select a channel`})})]})}function rn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),O(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),O(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,j.jsxs)(`div`,{className:tn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,j.jsxs)(`div`,{className:tn.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:tn.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,j.jsxs)(`div`,{className:tn.twoPane,children:[(0,j.jsxs)(`div`,{className:tn.sidebar,children:[(0,j.jsx)(`div`,{className:tn.sidebarTitle,children:`📋 Notion`}),(0,j.jsxs)(`div`,{className:tn.searchRow,children:[(0,j.jsx)(`input`,{className:tn.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,j.jsx)(`button`,{className:tn.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No pages found`}),m.map(e=>(0,j.jsxs)(`div`,{className:`${tn.channelItem} ${a?.id===e.id?tn.channelActive:``}`,onClick:()=>f(e),children:[(0,j.jsx)(`div`,{className:tn.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,j.jsx)(`div`,{className:tn.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,j.jsx)(`button`,{className:tn.disconnectBtn,onClick:()=>k(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,j.jsx)(`div`,{className:tn.messagePane,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:tn.channelHeader,children:a.title}),a.url&&(0,j.jsx)(`a`,{className:tn.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,j.jsx)(`div`,{className:tn.pageBody,dangerouslySetInnerHTML:{__html:ye(s||`Loading…`)}})]}):(0,j.jsx)(`div`,{className:tn.emptyPane,children:`Select a page`})})]})}var X={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function an(e){return e.content||e.plaintext||e.message||``}function on(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function sn(){let e=P(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{O(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{O(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await k(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await k(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await k(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await k(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(k(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await k(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,j.jsxs)(`div`,{className:X.root,children:[(0,j.jsxs)(`div`,{className:X.sidebar,children:[(0,j.jsx)(`div`,{className:X.sidebarHeader,children:(0,j.jsx)(`div`,{className:X.sidebarTitle,children:`Alexandria`})}),(0,j.jsxs)(`div`,{className:X.sidebarBtns,children:[(0,j.jsx)(`button`,{className:X.createBtn,onClick:g,children:`+ Create`}),(0,j.jsx)(`button`,{className:X.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,j.jsxs)(`div`,{className:X.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,j.jsxs)(`div`,{className:`${X.channelItem} ${r===e.id?X.channelActive:``}`,onClick:()=>i(e.id),children:[(0,j.jsx)(`div`,{className:X.channelName,children:e.name}),(0,j.jsxs)(`div`,{className:X.channelMeta,children:[(0,j.jsxs)(`span`,{className:X.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,j.jsx)(`button`,{className:X.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,j.jsx)(`div`,{className:X.main,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:X.chatHeader,children:[(0,j.jsx)(`div`,{className:X.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,j.jsx)(`div`,{className:X.chatChannelId,children:r}),(0,j.jsx)(`div`,{className:`${X.statusDot} ${l?X.connected:X.disconnected}`}),(0,j.jsx)(`span`,{className:X.statusText,children:l?`Live`:`HTTP`})]}),(0,j.jsxs)(`div`,{className:X.messages,ref:p,children:[a.length===0&&(0,j.jsx)(`div`,{className:X.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=on(e),r=an(e),i=n===d;return(0,j.jsxs)(`div`,{className:`${X.msg} ${i?X.msgSelf:X.msgOther}`,children:[!i&&(0,j.jsx)(`div`,{className:X.msgSender,children:n}),(0,j.jsx)(`div`,{className:X.msgContent,children:r}),(0,j.jsx)(`div`,{className:X.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,j.jsxs)(`div`,{className:X.inputRow,children:[(0,j.jsx)(`input`,{className:X.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,j.jsx)(`button`,{className:X.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,j.jsxs)(`div`,{className:X.welcome,children:[(0,j.jsx)(`div`,{className:X.welcomeIcon,children:`🔐`}),(0,j.jsx)(`div`,{className:X.welcomeTitle,children:`Alexandria`}),(0,j.jsx)(`div`,{className:X.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,j.jsxs)(`div`,{className:X.welcomeBox,children:[(0,j.jsx)(`div`,{className:X.welcomeBoxTitle,children:`HOW TO USE`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,j.jsx)(`div`,{className:X.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,j.jsx)(`div`,{className:X.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,j.jsxs)(`div`,{className:X.welcomeBox,children:[(0,j.jsx)(`div`,{className:X.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab create "Project X"`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab join <invite-code>`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab read`})]})]})})]})}var Z={root:`_root_1c0f9_2`,header:`_header_1c0f9_10`,title:`_title_1c0f9_21`,subtitle:`_subtitle_1c0f9_28`,headerTabs:`_headerTabs_1c0f9_34`,tabBtn:`_tabBtn_1c0f9_40`,tabActive:`_tabActive_1c0f9_51`,body:`_body_1c0f9_58`,editor:`_editor_1c0f9_67`,examples:`_examples_1c0f9_75`,sectionLabel:`_sectionLabel_1c0f9_81`,examplePills:`_examplePills_1c0f9_89`,examplePill:`_examplePill_1c0f9_89`,editorCols:`_editorCols_1c0f9_109`,leftSidebar:`_leftSidebar_1c0f9_119`,panel:`_panel_1c0f9_128`,panelHeader:`_panelHeader_1c0f9_135`,panelTitle:`_panelTitle_1c0f9_142`,addBtn:`_addBtn_1c0f9_149`,blockLabel:`_blockLabel_1c0f9_160`,blockCheck:`_blockCheck_1c0f9_170`,authField:`_authField_1c0f9_173`,authFieldInput:`_authFieldInput_1c0f9_183`,authFieldSelect:`_authFieldSelect_1c0f9_193`,authFieldReq:`_authFieldReq_1c0f9_204`,removeFieldBtn:`_removeFieldBtn_1c0f9_205`,skillsList:`_skillsList_1c0f9_208`,skillRow:`_skillRow_1c0f9_210`,skillIcon:`_skillIcon_1c0f9_218`,skillName:`_skillName_1c0f9_220`,skillBadge:`_skillBadge_1c0f9_229`,skillBadge_skill:`_skillBadge_skill_1c0f9_237`,skillBadge_memory:`_skillBadge_memory_1c0f9_238`,skillBadge_provider:`_skillBadge_provider_1c0f9_239`,skillBadge_log:`_skillBadge_log_1c0f9_240`,skillEmpty:`_skillEmpty_1c0f9_242`,skillBtn:`_skillBtn_1c0f9_244`,skillsEmpty:`_skillsEmpty_1c0f9_246`,snapshotRow:`_snapshotRow_1c0f9_249`,snapshotTs:`_snapshotTs_1c0f9_258`,snapshotCount:`_snapshotCount_1c0f9_259`,snapshotBtn:`_snapshotBtn_1c0f9_260`,genStatus:`_genStatus_1c0f9_263`,repairStatus:`_repairStatus_1c0f9_265`,repairStatusTitle:`_repairStatusTitle_1c0f9_266`,repairStatusProg:`_repairStatusProg_1c0f9_267`,repairStatusFile:`_repairStatusFile_1c0f9_268`,actionRow:`_actionRow_1c0f9_271`,actionBtn:`_actionBtn_1c0f9_273`,actionBtnIcon:`_actionBtnIcon_1c0f9_275`,actionBtnActive:`_actionBtnActive_1c0f9_276`,repairBtn:`_repairBtn_1c0f9_278`,sandboxBtn:`_sandboxBtn_1c0f9_280`,statsBar:`_statsBar_1c0f9_282`,rightPanel:`_rightPanel_1c0f9_285`,rightTabBar:`_rightTabBar_1c0f9_296`,rightTab:`_rightTab_1c0f9_296`,rightTabActive:`_rightTabActive_1c0f9_313`,repairBar:`_repairBar_1c0f9_316`,repairBarRow:`_repairBarRow_1c0f9_326`,repairBarIcon:`_repairBarIcon_1c0f9_327`,repairBarLabel:`_repairBarLabel_1c0f9_328`,repairBarFile:`_repairBarFile_1c0f9_329`,repairBarCounter:`_repairBarCounter_1c0f9_330`,repairBarTime:`_repairBarTime_1c0f9_331`,genBar:`_genBar_1c0f9_333`,genBarRow:`_genBarRow_1c0f9_343`,genBarRobot:`_genBarRobot_1c0f9_344`,robotBob:`_robotBob_1c0f9_1`,genBarLabel:`_genBarLabel_1c0f9_345`,genBarFile:`_genBarFile_1c0f9_346`,genBarCounter:`_genBarCounter_1c0f9_347`,genBarTime:`_genBarTime_1c0f9_348`,progressTrack:`_progressTrack_1c0f9_350`,repairProgress:`_repairProgress_1c0f9_351`,genProgress:`_genProgress_1c0f9_352`,genDots:`_genDots_1c0f9_355`,dot:`_dot_1c0f9_356`,dot1:`_dot1_1c0f9_357`,dotBounce:`_dotBounce_1c0f9_1`,dot2:`_dot2_1c0f9_358`,dot3:`_dot3_1c0f9_359`,stopBtn:`_stopBtn_1c0f9_362`,codeArea:`_codeArea_1c0f9_365`,sandboxWrap:`_sandboxWrap_1c0f9_366`,sandboxFrame:`_sandboxFrame_1c0f9_367`,sandboxEmpty:`_sandboxEmpty_1c0f9_368`,sandboxStartBtn:`_sandboxStartBtn_1c0f9_369`,codeLayout:`_codeLayout_1c0f9_372`,codeRow:`_codeRow_1c0f9_381`,ideTabBar:`_ideTabBar_1c0f9_389`,ideTab:`_ideTab_1c0f9_389`,ideTabActive:`_ideTabActive_1c0f9_421`,ideTabError:`_ideTabError_1c0f9_426`,ideTabPending:`_ideTabPending_1c0f9_427`,ideTabIcon:`_ideTabIcon_1c0f9_428`,ideTabName:`_ideTabName_1c0f9_429`,ideTabDot:`_ideTabDot_1c0f9_430`,codeEditorWrap:`_codeEditorWrap_1c0f9_438`,editToggleBtn:`_editToggleBtn_1c0f9_449`,editToggleBtnActive:`_editToggleBtnActive_1c0f9_460`,codeEditor:`_codeEditor_1c0f9_438`,genCursor:`_genCursor_1c0f9_482`,cursorBlink:`_cursorBlink_1c0f9_1`,diffOverlay:`_diffOverlay_1c0f9_491`,diffOverlayHeader:`_diffOverlayHeader_1c0f9_500`,diffOverlayActions:`_diffOverlayActions_1c0f9_511`,diffAcceptBtn:`_diffAcceptBtn_1c0f9_512`,diffRejectBtn:`_diffRejectBtn_1c0f9_513`,diffOverlayBody:`_diffOverlayBody_1c0f9_514`,diffSame:`_diffSame_1c0f9_515`,diffRem:`_diffRem_1c0f9_516`,diffAdd:`_diffAdd_1c0f9_517`,noFiles:`_noFiles_1c0f9_519`,noFilesHero:`_noFilesHero_1c0f9_529`,noFilesIcon:`_noFilesIcon_1c0f9_536`,noFilesTitle:`_noFilesTitle_1c0f9_538`,noFilesTagline:`_noFilesTagline_1c0f9_545`,noFilesSteps:`_noFilesSteps_1c0f9_550`,noFilesStep:`_noFilesStep_1c0f9_550`,noFilesStepNum:`_noFilesStepNum_1c0f9_567`,noFilesExamplesHint:`_noFilesExamplesHint_1c0f9_581`,noFilesExampleBtn:`_noFilesExampleBtn_1c0f9_591`,codeViewer:`_codeViewer_1c0f9_603`,codeHeader:`_codeHeader_1c0f9_611`,codeFileIcon:`_codeFileIcon_1c0f9_624`,codeFileName:`_codeFileName_1c0f9_625`,codeFileMeta:`_codeFileMeta_1c0f9_626`,fileError:`_fileError_1c0f9_628`,fileSyntaxError:`_fileSyntaxError_1c0f9_629`,filePending:`_filePending_1c0f9_630`,code:`_code_1c0f9_365`,codeError:`_codeError_1c0f9_645`,codeSyntaxError:`_codeSyntaxError_1c0f9_646`,fileSidebar:`_fileSidebar_1c0f9_649`,fileSidebarHeader:`_fileSidebarHeader_1c0f9_658`,fileTab:`_fileTab_1c0f9_668`,fileTabActive:`_fileTabActive_1c0f9_684`,fileTabError:`_fileTabError_1c0f9_685`,fileTabRow:`_fileTabRow_1c0f9_687`,fileTabIcon:`_fileTabIcon_1c0f9_688`,fileTabName:`_fileTabName_1c0f9_689`,fileTabSize:`_fileTabSize_1c0f9_690`,fileTabDir:`_fileTabDir_1c0f9_691`,fileTabTokens:`_fileTabTokens_1c0f9_692`,fileTabMeta:`_fileTabMeta_1c0f9_693`,projectsList:`_projectsList_1c0f9_696`,emptyProjects:`_emptyProjects_1c0f9_698`,emptyIcon:`_emptyIcon_1c0f9_699`,emptyHint:`_emptyHint_1c0f9_700`,projectCard:`_projectCard_1c0f9_702`,projectInfo:`_projectInfo_1c0f9_703`,projectName:`_projectName_1c0f9_704`,projectDesc:`_projectDesc_1c0f9_705`,projectMeta:`_projectMeta_1c0f9_706`,openBtn:`_openBtn_1c0f9_707`,deleteBtn:`_deleteBtn_1c0f9_708`,planBanner:`_planBanner_1c0f9_711`,planTitle:`_planTitle_1c0f9_720`,planText:`_planText_1c0f9_721`,planActions:`_planActions_1c0f9_722`,planApprove:`_planApprove_1c0f9_723`,planReject:`_planReject_1c0f9_724`,grepPanel:`_grepPanel_1c0f9_727`,grepRow:`_grepRow_1c0f9_736`,grepInput:`_grepInput_1c0f9_737`,grepBtn:`_grepBtn_1c0f9_739`,grepClose:`_grepClose_1c0f9_740`,grepCount:`_grepCount_1c0f9_741`,grepResults:`_grepResults_1c0f9_742`,grepEmpty:`_grepEmpty_1c0f9_743`,grepMatch:`_grepMatch_1c0f9_744`,grepMatchFile:`_grepMatchFile_1c0f9_746`,grepMatchLine:`_grepMatchLine_1c0f9_747`,diffPanel:`_diffPanel_1c0f9_750`,diffHeader:`_diffHeader_1c0f9_759`,diffClose:`_diffClose_1c0f9_760`,diffFile:`_diffFile_1c0f9_761`,diffSummary:`_diffSummary_1c0f9_762`,diffArrow:`_diffArrow_1c0f9_763`,diffFileName:`_diffFileName_1c0f9_764`,diffAdded:`_diffAdded_1c0f9_765`,diffRemoved:`_diffRemoved_1c0f9_766`,diffContent:`_diffContent_1c0f9_767`,diffInline:`_diffInline_1c0f9_770`,diffInlineHeader:`_diffInlineHeader_1c0f9_771`,diffRemLine:`_diffRemLine_1c0f9_772`,diffAddLine:`_diffAddLine_1c0f9_773`,chatPanel:`_chatPanel_1c0f9_776`,chatMessages:`_chatMessages_1c0f9_785`,chatWelcome:`_chatWelcome_1c0f9_787`,chatUser:`_chatUser_1c0f9_789`,chatUserBubble:`_chatUserBubble_1c0f9_790`,chatAttachPreviews:`_chatAttachPreviews_1c0f9_791`,chatAttachBadge:`_chatAttachBadge_1c0f9_792`,chatSystem:`_chatSystem_1c0f9_794`,chatSystemBubble:`_chatSystemBubble_1c0f9_795`,chatSyntaxErr:`_chatSyntaxErr_1c0f9_796`,chatAgent:`_chatAgent_1c0f9_798`,chatAgentCard:`_chatAgentCard_1c0f9_799`,chatAgentHeader:`_chatAgentHeader_1c0f9_800`,chatAgentRobot:`_chatAgentRobot_1c0f9_801`,chatAgentRobotAnim:`_chatAgentRobotAnim_1c0f9_802`,chatAgentLabel:`_chatAgentLabel_1c0f9_803`,chatRunningDots:`_chatRunningDots_1c0f9_804`,chatAgentText:`_chatAgentText_1c0f9_805`,chatToolBadges:`_chatToolBadges_1c0f9_806`,toolBadge:`_toolBadge_1c0f9_807`,toolBadgeOk:`_toolBadgeOk_1c0f9_808`,toolBadgeErr:`_toolBadgeErr_1c0f9_809`,cursor:`_cursor_1c0f9_811`,blink:`_blink_1c0f9_1`,attachPreviews:`_attachPreviews_1c0f9_814`,attachBadge:`_attachBadge_1c0f9_815`,removeAttachBtn:`_removeAttachBtn_1c0f9_816`,projNameRow:`_projNameRow_1c0f9_819`,projNameLabel:`_projNameLabel_1c0f9_820`,projNameInput:`_projNameInput_1c0f9_821`,projActiveRow:`_projActiveRow_1c0f9_822`,projActiveName:`_projActiveName_1c0f9_823`,chatInputRow:`_chatInputRow_1c0f9_826`,attachLabel:`_attachLabel_1c0f9_827`,chatTextarea:`_chatTextarea_1c0f9_828`,chatSendCol:`_chatSendCol_1c0f9_831`,chatSendBtn:`_chatSendBtn_1c0f9_832`,chatStopBtn:`_chatStopBtn_1c0f9_834`,modalOverlay:`_modalOverlay_1c0f9_837`,modal:`_modal_1c0f9_837`,modalHeader:`_modalHeader_1c0f9_859`,modalTitle:`_modalTitle_1c0f9_860`,modalClose:`_modalClose_1c0f9_861`,modalBody:`_modalBody_1c0f9_863`,modalRow:`_modalRow_1c0f9_865`,modalField:`_modalField_1c0f9_866`,modalLabel:`_modalLabel_1c0f9_867`,modalLabelRow:`_modalLabelRow_1c0f9_868`,modalSelect:`_modalSelect_1c0f9_870`,modalInput:`_modalInput_1c0f9_871`,modalHint:`_modalHint_1c0f9_874`,modalAiBox:`_modalAiBox_1c0f9_876`,modalAiRow:`_modalAiRow_1c0f9_877`,modalAiDesc:`_modalAiDesc_1c0f9_878`,modalAiBtn:`_modalAiBtn_1c0f9_879`,modalContentArea:`_modalContentArea_1c0f9_882`,logView:`_logView_1c0f9_885`,modalFooter:`_modalFooter_1c0f9_887`,modalCancelBtn:`_modalCancelBtn_1c0f9_888`,modalSaveBtn:`_modalSaveBtn_1c0f9_889`},cn=[{name:`MySaaS`,desc:`Full-stack SaaS web application with Node.js/Express backend and vanilla JS frontend.
|
|
591
|
+
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},pe=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=D.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),F(e,{voiceActive:!1});return}let r=new t;D.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;F(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>F(e,{voiceActive:!1}),r.onerror=()=>F(e,{voiceActive:!1}),r.start(),F(e,{voiceActive:!0})},me=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];F(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{F(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},he=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];F(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},ge=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),T(``)},_e=async e=>{let t=await O(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),T(``)},ve=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){T(`Tagline and system prompt are required.`);return}ee(!0),T(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){T(`Agent name required (lowercase, no spaces).`),ee(!1);return}let t=await k(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){T(`Error: `+t.error),ee(!1);return}}else await k(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),ie()}catch(e){T(`Error: `+e.message)}finally{ee(!1)}}},I=e=>{confirm(`Delete agent "${e.label}"?`)&&k(`/api/agents/${e.id}`,{},`DELETE`).then(()=>ie())};return r?(0,j.jsx)(`div`,{className:q.root,children:(0,j.jsx)(`div`,{className:q.loading,children:(0,j.jsx)(`div`,{className:`spinner`})})}):(0,j.jsxs)(`div`,{className:q.root,children:[(0,j.jsxs)(`div`,{className:q.gridSection,children:[(0,j.jsxs)(`div`,{className:q.gridHeader,children:[(0,j.jsxs)(`div`,{className:q.headerRow,children:[(0,j.jsx)(`input`,{className:q.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,j.jsx)(`button`,{className:q.createBtn,onClick:ge,children:`+ Create`})]}),(0,j.jsx)(`div`,{className:q.catTabs,children:ae.map(e=>(0,j.jsxs)(`button`,{className:`${q.catTab} ${s===e?q.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,j.jsx)(`div`,{className:q.grid,children:oe.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,j.jsxs)(`div`,{className:`${q.agentCard} ${t?q.agentActive:``}`,onClick:()=>se(e),children:[(0,j.jsxs)(`div`,{className:q.agentCardTop,children:[(0,j.jsx)(`div`,{className:q.agentIcon,children:e.icon}),e.isCustom&&(0,j.jsxs)(`div`,{className:q.agentActions,children:[(0,j.jsx)(`button`,{className:q.agentEditBtn,onClick:t=>{t.stopPropagation(),_e(e)},children:`✏️`}),(0,j.jsx)(`button`,{className:q.agentDelBtn,onClick:t=>{t.stopPropagation(),I(e)},children:`🗑`})]})]}),(0,j.jsx)(`div`,{className:q.agentLabel,children:e.label}),(0,j.jsx)(`div`,{className:q.agentDesc,children:e.description}),(0,j.jsx)(`div`,{className:q.agentCat,children:e.category})]},e.id)})})]}),(0,j.jsx)(`div`,{className:q.chatArea,children:l.length===0?(0,j.jsxs)(`div`,{className:q.emptyChat,children:[(0,j.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,j.jsx)(`span`,{className:q.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,j.jsxs)(`div`,{className:q.chatPanel,children:[(0,j.jsxs)(`div`,{className:q.chatHeader,children:[(0,j.jsx)(`span`,{className:q.chatIcon,children:t.icon}),(0,j.jsxs)(`div`,{className:q.chatHeaderInfo,children:[(0,j.jsx)(`div`,{className:q.chatAgentName,children:t.label}),(0,j.jsx)(`div`,{className:q.chatAgentDesc,children:t.description})]}),(0,j.jsx)(`button`,{className:q.closeChat,onClick:()=>ce(t.id),children:`✕`})]}),(0,j.jsxs)(`div`,{className:q.chatMessages,ref:e=>{A.current.set(t.id,e)},children:[e.history.length===0&&(0,j.jsxs)(`div`,{className:q.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,j.jsx)(`div`,{className:`${q.chatMsg} ${e.role===`user`?q.msgUser:q.msgAgent}`,children:e.role===`assistant`?(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ye(e.content||`…`)}}):(0,j.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,j.jsxs)(`div`,{className:q.thinking,children:[(0,j.jsx)(`span`,{className:q.dot}),(0,j.jsx)(`span`,{className:q.dot}),(0,j.jsx)(`span`,{className:q.dot})]})]}),n&&(0,j.jsxs)(`div`,{className:q.attachBar,children:[(0,j.jsx)(`span`,{children:n}),(0,j.jsx)(`button`,{className:q.attachClear,onClick:()=>F(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,j.jsxs)(`div`,{className:q.chatInput,children:[(0,j.jsxs)(`div`,{className:q.chatTools,children:[(0,j.jsx)(`button`,{className:`${q.toolBtn} ${e.voiceActive?q.toolBtnActive:``}`,onClick:()=>pe(t.id),title:`Voice`,children:`🎤`}),(0,j.jsx)(`button`,{className:q.toolBtn,onClick:()=>re.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,j.jsx)(`button`,{className:q.toolBtn,onClick:()=>M.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,j.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{re.current.set(t.id,e)},onChange:e=>me(t.id,e.target.files?.[0])}),(0,j.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{M.current.set(t.id,e)},onChange:e=>he(t.id,e.target.files?.[0])})]}),(0,j.jsxs)(`div`,{className:q.chatInputRow,children:[(0,j.jsx)(`textarea`,{className:q.chatTextarea,value:e.input,onChange:e=>F(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),de(e,e.input,e.attachedFile,e.attachedImage))}}),(0,j.jsx)(`button`,{className:q.sendBtn,onClick:()=>de(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,j.jsxs)(`div`,{className:q.orchBar,children:[(0,j.jsxs)(`div`,{className:q.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,j.jsxs)(`div`,{className:q.orchRow,children:[(0,j.jsx)(`textarea`,{ref:N,className:q.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),fe())}}),(0,j.jsx)(`button`,{className:q.orchBtn,onClick:fe,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,j.jsxs)(`div`,{className:q.orchSynthesis,children:[(0,j.jsxs)(`div`,{className:q.orchSynthHeader,children:[(0,j.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,j.jsx)(`span`,{className:q.orchSynthSpinner,children:`synthesizing…`})]}),(0,j.jsx)(`div`,{className:q.orchSynthBody,dangerouslySetInnerHTML:{__html:ye(h||`…`)}})]})]}),b&&(0,j.jsx)(`div`,{className:q.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,j.jsxs)(`div`,{className:q.modal,children:[(0,j.jsx)(`div`,{className:q.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,j.jsx)(`input`,{className:q.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`Tagline`}),(0,j.jsx)(`input`,{className:q.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,j.jsxs)(`div`,{className:q.formField,children:[(0,j.jsx)(`label`,{className:q.formLabel,children:`System Prompt`}),(0,j.jsx)(`textarea`,{className:q.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,j.jsx)(`div`,{className:q.formError,children:w}),(0,j.jsxs)(`div`,{className:q.modalBtns,children:[(0,j.jsx)(`button`,{className:q.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,j.jsx)(`button`,{className:q.modalSaveBtn,onClick:ve,disabled:E,children:E?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var J={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function Zt(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function Qt(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function $t(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),O(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{T()},[]);let E=e=>{c(e),T(e,l)},ee=()=>{u(d),T(s,d)},D=(e,t)=>{i(!0),O(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},te=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await k(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ne=(e,t)=>{i(!0),O(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},A=(e,t)=>{i(!0),O(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},re=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&k(`/api/drive/delete/${e}`,{}).then(()=>{n(null),T()})},M=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&k(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?D(t.id,e):T()}).catch(e=>alert(`Error: `+e.message))},N=()=>{w.current?.click()},ie=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;k(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),T()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,j.jsxs)(`div`,{className:J.error,children:[(0,j.jsx)(`div`,{children:a}),(0,j.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,j.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,j.jsxs)(`div`,{className:J.editorRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:h.name}),(0,j.jsx)(`button`,{className:J.saveBtn,onClick:te,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,j.jsx)(`textarea`,{className:J.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,j.jsxs)(`div`,{className:J.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,j.jsxs)(`div`,{className:J.viewerRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:b.name})]}),(0,j.jsx)(`div`,{className:J.imgContainer,children:(0,j.jsx)(`img`,{src:b.src,alt:b.name,className:J.imgView})})]});if(p===`pdf`&&b)return(0,j.jsxs)(`div`,{className:J.viewerRoot,children:[(0,j.jsxs)(`div`,{className:J.editorToolbar,children:[(0,j.jsx)(`button`,{className:J.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,j.jsx)(`span`,{className:J.editorName,children:b.name})]}),(0,j.jsx)(`iframe`,{className:J.pdfFrame,src:b.src,title:b.name})]});let ae=t?.files??[],oe=t?.quota;return(0,j.jsxs)(`div`,{className:J.root,children:[oe&&(0,j.jsxs)(`div`,{className:J.quotaBar,children:[(0,j.jsxs)(`div`,{className:J.quotaText,children:[(0,j.jsxs)(`span`,{className:J.quotaUsed,children:[oe.usage,` of `,oe.limit,` used`]}),(0,j.jsxs)(`span`,{className:J.quotaPct,children:[oe.percentUsed,`%`]})]}),(0,j.jsx)(`div`,{className:J.quotaTrack,children:(0,j.jsx)(`div`,{className:J.quotaFill,style:{width:`${Math.min(oe.percentUsed,100)}%`,background:oe.percentUsed>90?`var(--red)`:oe.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,j.jsxs)(`div`,{className:J.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,j.jsx)(`button`,{className:`${J.filterBtn} ${s===e?J.filterActive:``}`,onClick:()=>E(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,j.jsx)(`div`,{className:J.spacer}),(0,j.jsx)(`button`,{className:J.newBtn,onClick:M,children:`+ New File`}),(0,j.jsx)(`button`,{className:J.uploadBtn,onClick:N,children:e(`drive.upload`)}),(0,j.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>ie(e.target.files?.[0])})]}),(0,j.jsxs)(`div`,{className:J.searchRow,children:[(0,j.jsx)(`input`,{className:J.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ee()}),(0,j.jsx)(`button`,{className:J.searchBtn,onClick:ee,children:`Search`})]}),r&&(0,j.jsx)(`div`,{className:J.loading,children:(0,j.jsx)(`div`,{className:`spinner`})}),!r&&ae.length===0&&(0,j.jsxs)(`div`,{className:J.empty,children:[e(`drive.noFiles`),` found`]}),(0,j.jsx)(`div`,{className:J.fileList,children:ae.map(e=>{let t=Qt(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,j.jsxs)(`div`,{className:J.fileRow,onClick:()=>{t?D(e.id,e.name):n?ne(e.id,e.name):r?A(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,j.jsx)(`span`,{className:J.fileIcon,children:Zt(e.type,e.mimeType)}),(0,j.jsxs)(`div`,{className:J.fileInfo,children:[(0,j.jsx)(`div`,{className:J.fileName,children:e.name}),(0,j.jsxs)(`div`,{className:J.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,j.jsxs)(`div`,{className:J.fileBtns,children:[t&&(0,j.jsx)(`button`,{className:J.editBtn,onClick:t=>{t.stopPropagation(),D(e.id,e.name)},children:`Edit`}),n&&(0,j.jsx)(`button`,{className:J.viewBtn,onClick:t=>{t.stopPropagation(),ne(e.id,e.name)},children:`View`}),r&&(0,j.jsx)(`button`,{className:J.pdfBtn,onClick:t=>{t.stopPropagation(),A(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,j.jsx)(`a`,{className:J.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,j.jsx)(`button`,{className:J.delBtn,onClick:t=>{t.stopPropagation(),re(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var Y={root:`_root_a0x57_1`,loading:`_loading_a0x57_10`,errorBox:`_errorBox_a0x57_12`,errorHint:`_errorHint_a0x57_13`,userRow:`_userRow_a0x57_16`,avatar:`_avatar_a0x57_27`,userLogin:`_userLogin_a0x57_29`,userName:`_userName_a0x57_30`,disconnectBtn:`_disconnectBtn_a0x57_32`,repoBar:`_repoBar_a0x57_43`,repoInput:`_repoInput_a0x57_49`,issuesBtn:`_issuesBtn_a0x57_61`,prsBtn:`_prsBtn_a0x57_72`,repoPills:`_repoPills_a0x57_83`,repoPill:`_repoPill_a0x57_83`,issueCount:`_issueCount_a0x57_106`,tabs:`_tabs_a0x57_112`,tab:`_tab_a0x57_112`,tabActive:`_tabActive_a0x57_131`,markRead:`_markRead_a0x57_137`,content:`_content_a0x57_148`,empty:`_empty_a0x57_150`,notifRow:`_notifRow_a0x57_152`,issueRow:`_issueRow_a0x57_152`,prRow:`_prRow_a0x57_152`,notifRepo:`_notifRepo_a0x57_166`,notifType:`_notifType_a0x57_167`,notifTitle:`_notifTitle_a0x57_168`,notifMeta:`_notifMeta_a0x57_169`,issueNum:`_issueNum_a0x57_171`,issueTitle:`_issueTitle_a0x57_172`,issueMeta:`_issueMeta_a0x57_173`,issueLabel:`_issueLabel_a0x57_174`,prNum:`_prNum_a0x57_176`,prTitle:`_prTitle_a0x57_177`,prAuthor:`_prAuthor_a0x57_178`,prDraft:`_prDraft_a0x57_179`,prMeta:`_prMeta_a0x57_180`};function en(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),O(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>k(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&k(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})};if(r)return(0,j.jsx)(`div`,{className:Y.loading,children:(0,j.jsx)(`div`,{className:`spinner`})});if(t?.error)return(0,j.jsxs)(`div`,{className:Y.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:Y.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set github-token YOUR_PAT`})]})]});let g=t?.user,v=Array.isArray(t?.notifications)?t.notifications:[],y=Array.isArray(t?.issues)?t.issues:[],b=Array.isArray(t?.prs)?t.prs:[];return(0,j.jsxs)(`div`,{className:Y.root,children:[g?.login&&(0,j.jsxs)(`div`,{className:Y.userRow,children:[g.avatar&&(0,j.jsx)(`img`,{src:g.avatar,className:Y.avatar,alt:g.login}),(0,j.jsxs)(`div`,{style:{flex:1},children:[(0,j.jsxs)(`div`,{className:Y.userLogin,children:[`@`,g.login]}),g.name&&(0,j.jsx)(`div`,{className:Y.userName,children:g.name})]}),(0,j.jsx)(`button`,{className:Y.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,j.jsxs)(`div`,{className:Y.repoBar,children:[(0,j.jsx)(`input`,{className:Y.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,j.jsx)(`button`,{className:Y.issuesBtn,onClick:f,children:`Issues`}),(0,j.jsx)(`button`,{className:Y.prsBtn,onClick:p,children:`PRs`})]}),g?.repos&&g.repos.length>0&&(0,j.jsx)(`div`,{className:Y.repoPills,children:g.repos.slice(0,12).map(e=>(0,j.jsxs)(`button`,{className:Y.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,j.jsx)(`span`,{className:Y.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,j.jsxs)(`div`,{className:Y.tabs,children:[(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`notifs`?Y.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,v.length>0?`(${v.length})`:``]}),y.length>0&&(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`issues`?Y.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,y.length,`)`]}),b.length>0&&(0,j.jsxs)(`button`,{className:`${Y.tab} ${l===`prs`?Y.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,b.length,`)`]}),l===`notifs`&&v.length>0&&(0,j.jsx)(`button`,{className:Y.markRead,onClick:m,children:`Mark all read`})]}),(0,j.jsxs)(`div`,{className:Y.content,children:[l===`notifs`&&(v.length===0?(0,j.jsx)(`div`,{className:Y.empty,children:`No notifications`}):v.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsx)(`span`,{className:Y.notifRepo,children:e.repo}),(0,j.jsxs)(`span`,{className:Y.notifType,children:[`[`,e.type,`]`]}),(0,j.jsx)(`div`,{className:Y.notifTitle,children:e.title}),(0,j.jsxs)(`div`,{className:Y.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(y.length===0?(0,j.jsxs)(`div`,{className:Y.empty,children:[e(`github.noIssues`),` for `,a]}):y.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsxs)(`span`,{className:Y.issueNum,children:[`#`,e.number]}),(0,j.jsx)(`span`,{className:Y.issueTitle,children:e.title}),e.assignee&&(0,j.jsxs)(`span`,{className:Y.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,j.jsxs)(`span`,{className:Y.issueLabel,children:[`[`,e.labels,`]`]}),(0,j.jsx)(`div`,{className:Y.issueMeta,children:e.updated})]},t))),l===`prs`&&(b.length===0?(0,j.jsxs)(`div`,{className:Y.empty,children:[`No PRs for `,a]}):b.map((e,t)=>(0,j.jsxs)(`a`,{className:Y.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsxs)(`span`,{className:Y.prNum,children:[`#`,e.number]}),(0,j.jsx)(`span`,{className:Y.prTitle,children:e.title}),(0,j.jsxs)(`span`,{className:Y.prAuthor,children:[`by `,e.author]}),e.draft&&(0,j.jsx)(`span`,{className:Y.prDraft,children:`DRAFT`}),(0,j.jsx)(`div`,{className:Y.prMeta,children:e.updated})]},t)))]})]})}var tn={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function nn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)([]),l=()=>{i(!0),O(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},u=e=>{o(e),O(`/api/slack/messages?channel=${e.id}`).then(e=>c(e?.messages??[]))};if((0,_.useEffect)(()=>{l()},[]),r)return(0,j.jsxs)(`div`,{className:tn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,j.jsxs)(`div`,{className:tn.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:tn.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set slack-token xoxb-YOUR-TOKEN`})]})]});let d=t?.channels??[];return(0,j.jsxs)(`div`,{className:tn.twoPane,children:[(0,j.jsxs)(`div`,{className:tn.sidebar,children:[(0,j.jsxs)(`div`,{className:tn.sidebarTitle,children:[(0,j.jsx)(`span`,{children:`💬 Slack`}),t?.workspace&&(0,j.jsx)(`span`,{className:tn.workspace,children:t.workspace})]}),d.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No channels`}),d.map(e=>(0,j.jsxs)(`div`,{className:`${tn.channelItem} ${a?.id===e.id?tn.channelActive:``}`,onClick:()=>u(e),children:[`# `,e.name]},e.id)),(0,j.jsx)(`button`,{className:tn.disconnectBtn,onClick:()=>k(`/api/config`,{key:`slack-token`,value:``}).then(l),children:`Disconnect`})]}),(0,j.jsx)(`div`,{className:tn.messagePane,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:tn.channelHeader,children:[`#`,a.name]}),s.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No messages`}),s.map((e,t)=>(0,j.jsxs)(`div`,{className:tn.message,children:[(0,j.jsx)(`span`,{className:tn.msgUser,children:e.username||e.user||`Unknown`}),(0,j.jsx)(`span`,{className:tn.msgText,children:e.text}),(0,j.jsx)(`span`,{className:tn.msgTs,children:new Date(parseFloat(e.ts)*1e3).toLocaleTimeString()})]},t))]}):(0,j.jsx)(`div`,{className:tn.emptyPane,children:`Select a channel`})})]})}function rn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),O(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),O(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,j.jsxs)(`div`,{className:tn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,j.jsxs)(`div`,{className:tn.errorBox,children:[(0,j.jsx)(`div`,{children:t.error}),(0,j.jsxs)(`div`,{className:tn.errorHint,children:[`Run: `,(0,j.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,j.jsxs)(`div`,{className:tn.twoPane,children:[(0,j.jsxs)(`div`,{className:tn.sidebar,children:[(0,j.jsx)(`div`,{className:tn.sidebarTitle,children:`📋 Notion`}),(0,j.jsxs)(`div`,{className:tn.searchRow,children:[(0,j.jsx)(`input`,{className:tn.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,j.jsx)(`button`,{className:tn.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,j.jsx)(`div`,{className:tn.empty,children:`No pages found`}),m.map(e=>(0,j.jsxs)(`div`,{className:`${tn.channelItem} ${a?.id===e.id?tn.channelActive:``}`,onClick:()=>f(e),children:[(0,j.jsx)(`div`,{className:tn.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,j.jsx)(`div`,{className:tn.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,j.jsx)(`button`,{className:tn.disconnectBtn,onClick:()=>k(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,j.jsx)(`div`,{className:tn.messagePane,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:tn.channelHeader,children:a.title}),a.url&&(0,j.jsx)(`a`,{className:tn.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,j.jsx)(`div`,{className:tn.pageBody,dangerouslySetInnerHTML:{__html:ye(s||`Loading…`)}})]}):(0,j.jsx)(`div`,{className:tn.emptyPane,children:`Select a page`})})]})}var X={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function an(e){return e.content||e.plaintext||e.message||``}function on(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function sn(){let e=P(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{O(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{O(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await k(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await k(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await k(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await k(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(k(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await k(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,j.jsxs)(`div`,{className:X.root,children:[(0,j.jsxs)(`div`,{className:X.sidebar,children:[(0,j.jsx)(`div`,{className:X.sidebarHeader,children:(0,j.jsx)(`div`,{className:X.sidebarTitle,children:`Alexandria`})}),(0,j.jsxs)(`div`,{className:X.sidebarBtns,children:[(0,j.jsx)(`button`,{className:X.createBtn,onClick:g,children:`+ Create`}),(0,j.jsx)(`button`,{className:X.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,j.jsxs)(`div`,{className:X.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,j.jsxs)(`div`,{className:`${X.channelItem} ${r===e.id?X.channelActive:``}`,onClick:()=>i(e.id),children:[(0,j.jsx)(`div`,{className:X.channelName,children:e.name}),(0,j.jsxs)(`div`,{className:X.channelMeta,children:[(0,j.jsxs)(`span`,{className:X.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,j.jsx)(`button`,{className:X.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,j.jsx)(`div`,{className:X.main,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:X.chatHeader,children:[(0,j.jsx)(`div`,{className:X.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,j.jsx)(`div`,{className:X.chatChannelId,children:r}),(0,j.jsx)(`div`,{className:`${X.statusDot} ${l?X.connected:X.disconnected}`}),(0,j.jsx)(`span`,{className:X.statusText,children:l?`Live`:`HTTP`})]}),(0,j.jsxs)(`div`,{className:X.messages,ref:p,children:[a.length===0&&(0,j.jsx)(`div`,{className:X.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=on(e),r=an(e),i=n===d;return(0,j.jsxs)(`div`,{className:`${X.msg} ${i?X.msgSelf:X.msgOther}`,children:[!i&&(0,j.jsx)(`div`,{className:X.msgSender,children:n}),(0,j.jsx)(`div`,{className:X.msgContent,children:r}),(0,j.jsx)(`div`,{className:X.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,j.jsxs)(`div`,{className:X.inputRow,children:[(0,j.jsx)(`input`,{className:X.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,j.jsx)(`button`,{className:X.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,j.jsxs)(`div`,{className:X.welcome,children:[(0,j.jsx)(`div`,{className:X.welcomeIcon,children:`🔐`}),(0,j.jsx)(`div`,{className:X.welcomeTitle,children:`Alexandria`}),(0,j.jsx)(`div`,{className:X.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,j.jsxs)(`div`,{className:X.welcomeBox,children:[(0,j.jsx)(`div`,{className:X.welcomeBoxTitle,children:`HOW TO USE`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,j.jsx)(`div`,{className:X.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,j.jsx)(`div`,{className:X.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,j.jsxs)(`div`,{className:X.welcomeStep,children:[(0,j.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,j.jsxs)(`div`,{className:X.welcomeBox,children:[(0,j.jsx)(`div`,{className:X.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab create "Project X"`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab join <invite-code>`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,j.jsx)(`div`,{className:X.cliCmd,children:`nha collab read`})]})]})})]})}var Z={root:`_root_1n51d_2`,header:`_header_1n51d_10`,title:`_title_1n51d_21`,subtitle:`_subtitle_1n51d_28`,headerTabs:`_headerTabs_1n51d_34`,tabBtn:`_tabBtn_1n51d_40`,tabActive:`_tabActive_1n51d_51`,body:`_body_1n51d_58`,editor:`_editor_1n51d_67`,examples:`_examples_1n51d_75`,sectionLabel:`_sectionLabel_1n51d_81`,examplePills:`_examplePills_1n51d_89`,examplePill:`_examplePill_1n51d_89`,editorCols:`_editorCols_1n51d_109`,leftSidebar:`_leftSidebar_1n51d_119`,panel:`_panel_1n51d_128`,panelHeader:`_panelHeader_1n51d_135`,panelTitle:`_panelTitle_1n51d_142`,addBtn:`_addBtn_1n51d_149`,blockLabel:`_blockLabel_1n51d_160`,blockCheck:`_blockCheck_1n51d_170`,authField:`_authField_1n51d_173`,authFieldInput:`_authFieldInput_1n51d_183`,authFieldSelect:`_authFieldSelect_1n51d_193`,authFieldReq:`_authFieldReq_1n51d_204`,removeFieldBtn:`_removeFieldBtn_1n51d_205`,skillsList:`_skillsList_1n51d_208`,skillRow:`_skillRow_1n51d_210`,skillIcon:`_skillIcon_1n51d_218`,skillName:`_skillName_1n51d_220`,skillBadge:`_skillBadge_1n51d_229`,skillBadge_skill:`_skillBadge_skill_1n51d_237`,skillBadge_memory:`_skillBadge_memory_1n51d_238`,skillBadge_provider:`_skillBadge_provider_1n51d_239`,skillBadge_log:`_skillBadge_log_1n51d_240`,skillEmpty:`_skillEmpty_1n51d_242`,skillBtn:`_skillBtn_1n51d_244`,skillsEmpty:`_skillsEmpty_1n51d_246`,snapshotRow:`_snapshotRow_1n51d_249`,snapshotTs:`_snapshotTs_1n51d_258`,snapshotCount:`_snapshotCount_1n51d_259`,snapshotBtn:`_snapshotBtn_1n51d_260`,genStatus:`_genStatus_1n51d_263`,repairStatus:`_repairStatus_1n51d_265`,repairStatusTitle:`_repairStatusTitle_1n51d_266`,repairStatusProg:`_repairStatusProg_1n51d_267`,repairStatusFile:`_repairStatusFile_1n51d_268`,actionRow:`_actionRow_1n51d_271`,actionBtn:`_actionBtn_1n51d_273`,actionBtnIcon:`_actionBtnIcon_1n51d_275`,actionBtnActive:`_actionBtnActive_1n51d_276`,repairBtn:`_repairBtn_1n51d_278`,sandboxBtn:`_sandboxBtn_1n51d_280`,statsBar:`_statsBar_1n51d_282`,rightPanel:`_rightPanel_1n51d_285`,rightTabBar:`_rightTabBar_1n51d_296`,rightTab:`_rightTab_1n51d_296`,rightTabActive:`_rightTabActive_1n51d_313`,repairBar:`_repairBar_1n51d_316`,repairBarRow:`_repairBarRow_1n51d_326`,repairBarIcon:`_repairBarIcon_1n51d_327`,repairBarLabel:`_repairBarLabel_1n51d_328`,repairBarFile:`_repairBarFile_1n51d_329`,repairBarCounter:`_repairBarCounter_1n51d_330`,repairBarTime:`_repairBarTime_1n51d_331`,genBar:`_genBar_1n51d_333`,genBarRow:`_genBarRow_1n51d_343`,genBarRobot:`_genBarRobot_1n51d_344`,robotBob:`_robotBob_1n51d_1`,genBarLabel:`_genBarLabel_1n51d_345`,genBarFile:`_genBarFile_1n51d_346`,genBarCounter:`_genBarCounter_1n51d_347`,genBarTime:`_genBarTime_1n51d_348`,progressTrack:`_progressTrack_1n51d_350`,repairProgress:`_repairProgress_1n51d_351`,genProgress:`_genProgress_1n51d_352`,genDots:`_genDots_1n51d_355`,dot:`_dot_1n51d_356`,dot1:`_dot1_1n51d_357`,dotBounce:`_dotBounce_1n51d_1`,dot2:`_dot2_1n51d_358`,dot3:`_dot3_1n51d_359`,stopBtn:`_stopBtn_1n51d_362`,codeArea:`_codeArea_1n51d_365`,sandboxWrap:`_sandboxWrap_1n51d_366`,sandboxFrame:`_sandboxFrame_1n51d_367`,sandboxEmpty:`_sandboxEmpty_1n51d_368`,sandboxStartBtn:`_sandboxStartBtn_1n51d_369`,sandboxConsole:`_sandboxConsole_1n51d_372`,sandboxConsoleHeader:`_sandboxConsoleHeader_1n51d_380`,sandboxConsoleTitle:`_sandboxConsoleTitle_1n51d_389`,sandboxConsolePort:`_sandboxConsolePort_1n51d_390`,sandboxConsoleDots:`_sandboxConsoleDots_1n51d_391`,sandboxConsoleBody:`_sandboxConsoleBody_1n51d_392`,sandboxLogLine:`_sandboxLogLine_1n51d_398`,sandboxLogError:`_sandboxLogError_1n51d_407`,sandboxLogWarn:`_sandboxLogWarn_1n51d_408`,sandboxLogOk:`_sandboxLogOk_1n51d_409`,codeLayout:`_codeLayout_1n51d_412`,codeRow:`_codeRow_1n51d_421`,ideTabBar:`_ideTabBar_1n51d_429`,ideTab:`_ideTab_1n51d_429`,ideTabActive:`_ideTabActive_1n51d_461`,ideTabError:`_ideTabError_1n51d_466`,ideTabPending:`_ideTabPending_1n51d_467`,ideTabIcon:`_ideTabIcon_1n51d_468`,ideTabName:`_ideTabName_1n51d_469`,ideTabDot:`_ideTabDot_1n51d_470`,codeEditorWrap:`_codeEditorWrap_1n51d_478`,editToggleBtn:`_editToggleBtn_1n51d_489`,editToggleBtnActive:`_editToggleBtnActive_1n51d_500`,codeEditor:`_codeEditor_1n51d_478`,genCursor:`_genCursor_1n51d_522`,cursorBlink:`_cursorBlink_1n51d_1`,diffOverlay:`_diffOverlay_1n51d_531`,diffOverlayHeader:`_diffOverlayHeader_1n51d_540`,diffOverlayActions:`_diffOverlayActions_1n51d_551`,diffAcceptBtn:`_diffAcceptBtn_1n51d_552`,diffRejectBtn:`_diffRejectBtn_1n51d_553`,diffOverlayBody:`_diffOverlayBody_1n51d_554`,diffSame:`_diffSame_1n51d_555`,diffRem:`_diffRem_1n51d_556`,diffAdd:`_diffAdd_1n51d_557`,noFiles:`_noFiles_1n51d_559`,noFilesHero:`_noFilesHero_1n51d_569`,noFilesIcon:`_noFilesIcon_1n51d_576`,noFilesTitle:`_noFilesTitle_1n51d_578`,noFilesTagline:`_noFilesTagline_1n51d_585`,noFilesSteps:`_noFilesSteps_1n51d_590`,noFilesStep:`_noFilesStep_1n51d_590`,noFilesStepNum:`_noFilesStepNum_1n51d_607`,noFilesExamplesHint:`_noFilesExamplesHint_1n51d_621`,noFilesExampleBtn:`_noFilesExampleBtn_1n51d_631`,codeViewer:`_codeViewer_1n51d_643`,codeHeader:`_codeHeader_1n51d_651`,codeFileIcon:`_codeFileIcon_1n51d_664`,codeFileName:`_codeFileName_1n51d_665`,codeFileMeta:`_codeFileMeta_1n51d_666`,fileError:`_fileError_1n51d_668`,fileSyntaxError:`_fileSyntaxError_1n51d_669`,filePending:`_filePending_1n51d_670`,code:`_code_1n51d_365`,codeError:`_codeError_1n51d_685`,codeSyntaxError:`_codeSyntaxError_1n51d_686`,fileSidebar:`_fileSidebar_1n51d_689`,fileSidebarHeader:`_fileSidebarHeader_1n51d_698`,fileTab:`_fileTab_1n51d_708`,fileTabActive:`_fileTabActive_1n51d_724`,fileTabError:`_fileTabError_1n51d_725`,fileTabRow:`_fileTabRow_1n51d_727`,fileTabIcon:`_fileTabIcon_1n51d_728`,fileTabName:`_fileTabName_1n51d_729`,fileTabSize:`_fileTabSize_1n51d_730`,fileTabDir:`_fileTabDir_1n51d_731`,fileTabTokens:`_fileTabTokens_1n51d_732`,fileTabMeta:`_fileTabMeta_1n51d_733`,projectsList:`_projectsList_1n51d_736`,emptyProjects:`_emptyProjects_1n51d_738`,emptyIcon:`_emptyIcon_1n51d_739`,emptyHint:`_emptyHint_1n51d_740`,projectCard:`_projectCard_1n51d_742`,projectInfo:`_projectInfo_1n51d_743`,projectName:`_projectName_1n51d_744`,projectDesc:`_projectDesc_1n51d_745`,projectMeta:`_projectMeta_1n51d_746`,openBtn:`_openBtn_1n51d_747`,deleteBtn:`_deleteBtn_1n51d_748`,planBanner:`_planBanner_1n51d_751`,planTitle:`_planTitle_1n51d_760`,planText:`_planText_1n51d_761`,planActions:`_planActions_1n51d_762`,planApprove:`_planApprove_1n51d_763`,planReject:`_planReject_1n51d_764`,grepPanel:`_grepPanel_1n51d_767`,grepRow:`_grepRow_1n51d_776`,grepInput:`_grepInput_1n51d_777`,grepBtn:`_grepBtn_1n51d_779`,grepClose:`_grepClose_1n51d_780`,grepCount:`_grepCount_1n51d_781`,grepResults:`_grepResults_1n51d_782`,grepEmpty:`_grepEmpty_1n51d_783`,grepMatch:`_grepMatch_1n51d_784`,grepMatchFile:`_grepMatchFile_1n51d_786`,grepMatchLine:`_grepMatchLine_1n51d_787`,diffPanel:`_diffPanel_1n51d_790`,diffHeader:`_diffHeader_1n51d_799`,diffClose:`_diffClose_1n51d_800`,diffFile:`_diffFile_1n51d_801`,diffSummary:`_diffSummary_1n51d_802`,diffArrow:`_diffArrow_1n51d_803`,diffFileName:`_diffFileName_1n51d_804`,diffAdded:`_diffAdded_1n51d_805`,diffRemoved:`_diffRemoved_1n51d_806`,diffContent:`_diffContent_1n51d_807`,diffInline:`_diffInline_1n51d_810`,diffInlineHeader:`_diffInlineHeader_1n51d_811`,diffRemLine:`_diffRemLine_1n51d_812`,diffAddLine:`_diffAddLine_1n51d_813`,chatPanel:`_chatPanel_1n51d_816`,chatMessages:`_chatMessages_1n51d_825`,chatWelcome:`_chatWelcome_1n51d_827`,chatUser:`_chatUser_1n51d_829`,chatUserBubble:`_chatUserBubble_1n51d_830`,chatAttachPreviews:`_chatAttachPreviews_1n51d_831`,chatAttachBadge:`_chatAttachBadge_1n51d_832`,chatSystem:`_chatSystem_1n51d_834`,chatSystemBubble:`_chatSystemBubble_1n51d_835`,chatSyntaxErr:`_chatSyntaxErr_1n51d_836`,chatAgent:`_chatAgent_1n51d_838`,chatAgentCard:`_chatAgentCard_1n51d_839`,chatAgentHeader:`_chatAgentHeader_1n51d_840`,chatAgentRobot:`_chatAgentRobot_1n51d_841`,chatAgentRobotAnim:`_chatAgentRobotAnim_1n51d_842`,chatAgentLabel:`_chatAgentLabel_1n51d_843`,chatRunningDots:`_chatRunningDots_1n51d_844`,chatAgentText:`_chatAgentText_1n51d_845`,chatToolBadges:`_chatToolBadges_1n51d_846`,toolBadge:`_toolBadge_1n51d_847`,toolBadgeOk:`_toolBadgeOk_1n51d_848`,toolBadgeErr:`_toolBadgeErr_1n51d_849`,cursor:`_cursor_1n51d_851`,blink:`_blink_1n51d_1`,attachPreviews:`_attachPreviews_1n51d_854`,attachBadge:`_attachBadge_1n51d_855`,removeAttachBtn:`_removeAttachBtn_1n51d_856`,projNameRow:`_projNameRow_1n51d_859`,projNameLabel:`_projNameLabel_1n51d_860`,projNameInput:`_projNameInput_1n51d_861`,projActiveRow:`_projActiveRow_1n51d_862`,projActiveName:`_projActiveName_1n51d_863`,chatInputRow:`_chatInputRow_1n51d_866`,attachLabel:`_attachLabel_1n51d_867`,chatTextarea:`_chatTextarea_1n51d_868`,chatSendCol:`_chatSendCol_1n51d_871`,chatSendBtn:`_chatSendBtn_1n51d_872`,chatStopBtn:`_chatStopBtn_1n51d_874`,modalOverlay:`_modalOverlay_1n51d_877`,modal:`_modal_1n51d_877`,modalHeader:`_modalHeader_1n51d_899`,modalTitle:`_modalTitle_1n51d_900`,modalClose:`_modalClose_1n51d_901`,modalBody:`_modalBody_1n51d_903`,modalRow:`_modalRow_1n51d_905`,modalField:`_modalField_1n51d_906`,modalLabel:`_modalLabel_1n51d_907`,modalLabelRow:`_modalLabelRow_1n51d_908`,modalSelect:`_modalSelect_1n51d_910`,modalInput:`_modalInput_1n51d_911`,modalHint:`_modalHint_1n51d_914`,modalAiBox:`_modalAiBox_1n51d_916`,modalAiRow:`_modalAiRow_1n51d_917`,modalAiDesc:`_modalAiDesc_1n51d_918`,modalAiBtn:`_modalAiBtn_1n51d_919`,modalContentArea:`_modalContentArea_1n51d_922`,logView:`_logView_1n51d_925`,modalFooter:`_modalFooter_1n51d_927`,modalCancelBtn:`_modalCancelBtn_1n51d_928`,modalSaveBtn:`_modalSaveBtn_1n51d_929`},cn=[{name:`MySaaS`,desc:`Full-stack SaaS web application with Node.js/Express backend and vanilla JS frontend.
|
|
592
592
|
|
|
593
593
|
BACKEND (server.js + routes/):
|
|
594
594
|
- Express server with helmet, cors, rate-limiting, compression middleware
|
|
@@ -676,24 +676,24 @@ FRONTEND:
|
|
|
676
676
|
- index.html: Job board homepage — (1) Hero: gradient background, large search widget (keyword input + location input + category select + Search button), quick stats bar (12,847 Jobs / 3,420 Companies / 45K Candidates). (2) Featured jobs: horizontal scroll row of 4 "Featured" cards with company logo (colored emoji), job title, company name, location + type badge + salary range + "Easy Apply" button. (3) Main layout: left sidebar filters (Job Type checkboxes, Salary Range slider, Category checkboxes, Location input, Posted Within select, Remote Only toggle) + right: jobs list (job row cards with company logo/title/company/location/type/salary/time-ago posted/Save bookmark/Apply button). (4) "Load More" button + results count "Showing 12 of 247 jobs". (5) Top companies section: 8 company cards with logo/name/industry/openings count. (6) Category browsing: 6 category cards with icon/name/count/link. (7) Job seeker CTA banner. (8) Newsletter.
|
|
677
677
|
- job.html: Job detail page — company header (logo + name + industry + website + size + "Follow" button), job title + badges (Remote, Senior, Urgent), salary + location + posted date, Apply Now button (sticky on scroll), job description (markdown-rendered sections: About/Responsibilities/Requirements/Nice-to-Have/Benefits), company sidebar card (description + stats), similar jobs list (4 cards)
|
|
678
678
|
- apply.html: Application modal/page — job summary header, form (Full Name / Email / Phone / LinkedIn URL / Portfolio URL / Cover Letter textarea with character count / Resume paste textarea), Submit button with loading state, success page with application reference number
|
|
679
|
-
- public/css/main.css: Modern job board design — tag/badge system (Remote=blue, Onsite=green, Urgent=red), salary range display, company logo placeholder styles, filter sidebar collapse on mobile, job card hover effects, application form validation styles`}],ln=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],un={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`📋`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function dn(e){return un[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function fn(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function pn(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function mn(){let e=P(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[d,f]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(!1),[D,te]=(0,_.useState)(0),[ne,A]=(0,_.useState)(0),[re,M]=(0,_.useState)(``),[N,ie]=(0,_.useState)({fi:0,total:0,name:``}),[ae,oe]=(0,_.useState)({tokIn:0,tokOut:0}),[se,ce]=(0,_.useState)(null),[F,le]=(0,_.useState)([]),[ue,de]=(0,_.useState)(``),[fe,pe]=(0,_.useState)(!1),[me,he]=(0,_.useState)([]),[ge,_e]=(0,_.useState)(null),[ve,ye]=(0,_.useState)([]),[I,be]=(0,_.useState)(!1),[xe,Se]=(0,_.useState)(null),[Ce,L]=(0,_.useState)([]),[we,Te]=(0,_.useState)(!1),[Ee,R]=(0,_.useState)(``),[z,De]=(0,_.useState)([]),[Oe,ke]=(0,_.useState)([]),[Ae,je]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)(null),[Pe,Fe]=(0,_.useState)(`0s`),[
|
|
679
|
+
- public/css/main.css: Modern job board design — tag/badge system (Remote=blue, Onsite=green, Urgent=red), salary range display, company logo placeholder styles, filter sidebar collapse on mobile, job card hover effects, application form validation styles`}],ln=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],un={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`📋`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function dn(e){return un[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function fn(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function pn(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function mn(){let e=P(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[d,f]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(!1),[D,te]=(0,_.useState)(0),[ne,A]=(0,_.useState)(0),[re,M]=(0,_.useState)(``),[N,ie]=(0,_.useState)({fi:0,total:0,name:``}),[ae,oe]=(0,_.useState)({tokIn:0,tokOut:0}),[se,ce]=(0,_.useState)(null),[F,le]=(0,_.useState)([]),[ue,de]=(0,_.useState)(``),[fe,pe]=(0,_.useState)(!1),[me,he]=(0,_.useState)([]),[ge,_e]=(0,_.useState)(null),[ve,ye]=(0,_.useState)([]),[I,be]=(0,_.useState)(!1),[xe,Se]=(0,_.useState)(null),[Ce,L]=(0,_.useState)([]),[we,Te]=(0,_.useState)(!1),[Ee,R]=(0,_.useState)(``),[z,De]=(0,_.useState)([]),[Oe,ke]=(0,_.useState)([]),[Ae,je]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)(null),[Pe,Fe]=(0,_.useState)(!1),[Ie,B]=(0,_.useState)([]),[Le,Re]=(0,_.useState)(null),ze=(0,_.useRef)(null),[Be,Ve]=(0,_.useState)(`0s`),[He,Ue]=(0,_.useState)(`0s`),We=(0,_.useRef)(0),Ge=(0,_.useRef)(0),Ke=(0,_.useRef)(null),qe=(0,_.useRef)(null),Je=(0,_.useRef)(null),Ye=(0,_.useRef)(null),Xe=(0,_.useRef)(null),Ze=(0,_.useRef)(null);function Qe(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function $e(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(w||E?Ke.current=setInterval(()=>{w&&Ve($e(We.current)),E&&Ue($e(Ge.current))},1e3):Ke.current&&=(clearInterval(Ke.current),null),()=>{Ke.current&&clearInterval(Ke.current)}),[w,E]);function et(){Je.current&&(Je.current.scrollTop=Je.current.scrollHeight)}(0,_.useEffect)(()=>{et()},[F]),(0,_.useEffect)(()=>{a&&!I&&(be(!0),O(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`).then(e=>{e?.skills&&ye(e.skills)}).catch(()=>{}))},[a,I]);async function tt(e,t){if(w||!e||e.length<5)return;T(!0),m([]),g(0),y(null),ie({fi:0,total:0,name:``}),oe({tokIn:0,tokOut:0}),We.current=Date.now(),Ve(`0s`),qe.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:qe.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:l,authFields:d})});if(!r.ok||!r.body){T(!1);return}let i=r.body.getReader(),a=new TextDecoder,o=``,s=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let r=o.split(`
|
|
680
680
|
|
|
681
|
-
`);o=r.pop()??``;for(let e of r){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);if(e.type===`processing`||e.type===`planning`)ie(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)s.push({name:e.name,content:``,_pending:!0}),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),g(s.length-1),y(``);else if(e.type===`file_chunk`){let t=s.find(t=>t.name===e.name);t&&(t.content+=e.chunk,t._pending=!1),m([...s]),y(t?t.content:null)}else if(e.type===`file_done`){let t=s.find(t=>t.name===e.name);t&&(t._pending=!1,e.syntaxError&&(t._syntaxError=e.syntaxError)),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&oe({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}else if(e.type===`file_error`){let t=s.find(t=>t.name===e.name);t&&(t._error=!0,t._pending=!1),m([...s])}else e.type===`done`&&(ce({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:s.length}),y(null),T(!1),be(!1),ye([]),s.some(e=>e._error||e._syntaxError)?setTimeout(()=>
|
|
681
|
+
`);o=r.pop()??``;for(let e of r){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);if(e.type===`processing`||e.type===`planning`)ie(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)s.push({name:e.name,content:``,_pending:!0}),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),g(s.length-1),y(``);else if(e.type===`file_chunk`){let t=s.find(t=>t.name===e.name);t&&(t.content+=e.chunk,t._pending=!1),m([...s]),y(t?t.content:null)}else if(e.type===`file_done`){let t=s.find(t=>t.name===e.name);t&&(t._pending=!1,e.syntaxError&&(t._syntaxError=e.syntaxError)),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&oe({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}else if(e.type===`file_error`){let t=s.find(t=>t.name===e.name);t&&(t._error=!0,t._pending=!1),m([...s])}else e.type===`done`&&(ce({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:s.length}),y(null),T(!1),be(!1),ye([]),s.some(e=>e._error||e._syntaxError)?setTimeout(()=>Xe.current?.(),800):setTimeout(()=>Ze.current?.(),800))}catch{}}}}catch(e){e.name!==`AbortError`&&le(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),T(!1)}}async function nt(){let e=ue.trim();if(!(a&&p.length>0)){if(!e||e.length<5)return;let t=a||`MyProject`;o(t),c(e),de(``),await tt(e,t);return}if(!e&&me.length===0||fe||w)return;let t=[...me];if(he([]),de(``),e.toLowerCase().startsWith(`/plan `)||e.toLowerCase().startsWith(`piano: `)){let t=e.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);le(t=>[...t,{role:`user`,text:e}]),await rt(`[MODALITA PIANO] Descrivi cosa modificheresti per: "${t}". Elenca i file e cosa faresti. NON applicare modifiche ancora. Rispondi con il piano in bullet list.`,t,[]);return}le(n=>[...n,{role:`user`,text:e,attachments:t}]),await rt(e,null,t)}async function rt(e,t,n){if(fe)return;pe(!0);let r={};p.forEach(e=>{r[e.name]=e.content});try{let i=await fetch(`/api/studio/webcraft/agent`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:a,message:e,attachments:n.map(e=>({name:e.name,mimeType:e.mimeType,base64:e.base64}))})});if(!i.ok||!i.body){le(e=>[...e,{role:`agent`,text:`Errore: ${i.status}`,tools:[]}]),pe(!1);return}let o={role:`agent`,text:``,tools:[]};le(e=>[...e,o]);let s=i.body.getReader(),c=new TextDecoder,l=``,u=!1;for(;;){let{done:e,value:n}=await s.read();if(e)break;l+=c.decode(n,{stream:!0});let i=l.split(`
|
|
682
682
|
|
|
683
|
-
`);l=i.pop()??``;for(let e of i){let n=e.replace(/^data: /,``).trim();if(n)try{let e=JSON.parse(n);e.type===`text`?(o.text+=e.token,le(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`tool`?(o.tools.push({op:e.op,path:e.path,result:e.result,oldSnippet:e.oldSnippet??``,newSnippet:e.newSnippet??``}),(e.op===`edit`||e.op===`write`)&&e.result===`ok`&&(u=!0),le(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`done`?(t&&!u&&_e({plan:o.text,originalMessage:t}),pe(!1),e.changed&&await
|
|
684
|
-
Errore: `+e.msg,pe(!1))}catch{}}}}catch(e){le(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}pe(!1)}async function
|
|
683
|
+
`);l=i.pop()??``;for(let e of i){let n=e.replace(/^data: /,``).trim();if(n)try{let e=JSON.parse(n);e.type===`text`?(o.text+=e.token,le(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`tool`?(o.tools.push({op:e.op,path:e.path,result:e.result,oldSnippet:e.oldSnippet??``,newSnippet:e.newSnippet??``}),(e.op===`edit`||e.op===`write`)&&e.result===`ok`&&(u=!0),le(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`done`?(t&&!u&&_e({plan:o.text,originalMessage:t}),pe(!1),e.changed&&await it((o.tools??[]).filter(e=>e.op===`edit`||e.op===`write`).map(e=>e.path),r)):e.type===`error`&&(o.text+=`
|
|
684
|
+
Errore: `+e.msg,pe(!1))}catch{}}}}catch(e){le(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}pe(!1)}async function it(e,t){if(!a)return;let n=await O(`/api/studio/webcraft/projects/load/${encodeURIComponent(a)}`);if(n?.files&&(m(n.files),e.length>0)){let r=e.map(e=>{let r=n.files.find(t=>t.name===e);return r?{file:e,before:t[e]??``,after:r.content}:null}).filter(Boolean);ke(e=>[...e,...r])}}function at(){qe.current&&=(qe.current.abort(),null),T(!1),pe(!1),le(e=>[...e,{role:`system`,text:`⏹ Generazione interrotta.`}])}async function ot(){return a?(await k(`/api/studio/webcraft/snapshot`,{projectName:a}))?.snapshot??null:null}async function st(){let e=await ot();e&&(le(t=>[...t,{role:`system`,text:`💾 Snapshot salvato (${e.slice(0,16).replace(`T`,` `)})`}]),ct())}async function ct(){if(!a)return;let e=await O(`/api/studio/webcraft/snapshots/${encodeURIComponent(a)}`);e?.snapshots&&L(e.snapshots)}async function lt(e){confirm(`Ripristinare lo snapshot del ${e.replace(`T`,` `).slice(0,16)}? I file attuali verranno sovrascritti.`)&&await k(`/api/studio/webcraft/restore`,{projectName:a,ts:e})!==null&&(le(t=>[...t,{role:`agent`,text:`Snapshot ripristinato (${e}). Ricarico i file...`}]),it([],{}))}async function V(){if(!a)return;let e=await k(`/api/studio/webcraft/syntax-check`,{projectName:a});if(e?.results){let t=e.results.filter(e=>!e.ok);t.length>0?le(e=>[...e,{role:`system`,text:`⚠ Syntax check: ${t.length} errore/i trovato/i.`,syntaxErrors:t}]):le(e=>[...e,{role:`system`,text:`✓ Syntax check: tutti i file JS sono validi.`}])}}async function ut(){let e=p.filter(e=>e._error||e._syntaxError);if(e.length===0){Ze.current?.();return}ee(!0),te(0),A(e.length),Ge.current=Date.now(),Ue(`0s`);for(let t=0;t<e.length;t++){let n=e[t];M(n.name),te(t),await rt(`REPAIR FILE: ${n.name}\nErrore: ${n._syntaxError??`generazione fallita`}\nRigenera il file correttamente. Output SOLO il contenuto del file, nessuna spiegazione.`,null,[])}te(e.length),M(``),ee(!1),setTimeout(()=>Ze.current?.(),500)}function dt(e){B(t=>[...t,`[${new Date().toLocaleTimeString()}] ${e}`]),setTimeout(()=>{ze.current?.scrollTo(0,ze.current.scrollHeight)},50)}async function ft(e){if(!Pe){Fe(!0),Re(null),Ne(null),B([]),i(`preview`),dt(`Starting sandbox...`);try{let t=await fetch(`/api/studio/webcraft/sandbox/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:e})});if(!t.ok||!t.body){let e=t.ok?`No response body`:`HTTP ${t.status}`;dt(`ERROR: ${e}`),Re(e),Fe(!1);return}let n=t.body.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:t}=await n.read();if(e)break;i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
685
685
|
|
|
686
|
-
`);a
|
|
687
|
-
[Piano approvato — procedi con le modifiche]`,null,[])}function gt(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];he(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let H=a&&p.length>0,_t=p[h],vt=fe||w;return(0,j.jsxs)(`div`,{className:Z.root,children:[(0,j.jsxs)(`div`,{className:Z.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Z.title,children:`⚙ WebCraft`}),(0,j.jsx)(`div`,{className:Z.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,j.jsxs)(`div`,{className:Z.headerTabs,children:[(0,j.jsx)(`button`,{className:`${Z.tabBtn} ${t===`new`?Z.tabActive:``}`,onClick:()=>n(`new`),children:`+ Nuovo`}),(0,j.jsx)(`button`,{className:`${Z.tabBtn} ${t===`projects`?Z.tabActive:``}`,onClick:()=>{n(`projects`),ft()},children:`📁 Progetti`})]})]}),(0,j.jsx)(`div`,{className:Z.body,children:t===`projects`?(0,j.jsx)(`div`,{className:Z.projectsList,children:Ae.length===0?(0,j.jsxs)(`div`,{className:Z.emptyProjects,children:[(0,j.jsx)(`span`,{className:Z.emptyIcon,children:`📁`}),(0,j.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,j.jsx)(`span`,{className:Z.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):Ae.map(e=>(0,j.jsxs)(`div`,{className:Z.projectCard,children:[(0,j.jsxs)(`div`,{className:Z.projectInfo,children:[(0,j.jsx)(`div`,{className:Z.projectName,children:e.name}),(0,j.jsx)(`div`,{className:Z.projectDesc,children:e.description}),(0,j.jsxs)(`div`,{className:Z.projectMeta,children:[(0,j.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,j.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,j.jsx)(`button`,{className:Z.openBtn,onClick:()=>pt(e),children:`↗ Apri`}),(0,j.jsx)(`button`,{className:Z.deleteBtn,onClick:()=>mt(e),children:`🗑`})]},e.name))}):(0,j.jsxs)(`div`,{className:Z.editor,children:[(0,j.jsxs)(`div`,{className:Z.examples,children:[(0,j.jsx)(`div`,{className:Z.sectionLabel,children:`Esempi`}),(0,j.jsx)(`div`,{className:Z.examplePills,children:cn.map(e=>(0,j.jsx)(`button`,{className:Z.examplePill,onClick:()=>{o(e.name),c(e.desc),de(e.desc)},children:e.name},e.name))})]}),(0,j.jsxs)(`div`,{className:Z.editorCols,children:[(0,j.jsxs)(`div`,{className:Z.leftSidebar,children:[(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`Blocchi`}),ln.map(e=>(0,j.jsxs)(`label`,{className:Z.blockLabel,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l[e.key],onChange:t=>u(n=>({...n,[e.key]:t.target.checked})),className:Z.blockCheck}),(0,j.jsx)(`span`,{children:e.icon}),(0,j.jsx)(`span`,{children:e.label})]},e.key))]}),l.auth&&(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsxs)(`div`,{className:Z.panelHeader,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`Campi Auth`}),(0,j.jsx)(`button`,{className:Z.addBtn,onClick:()=>f(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),d.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.authField,children:[(0,j.jsx)(`input`,{value:e.label,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:Z.authFieldInput}),(0,j.jsx)(`select`,{value:e.type,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:Z.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))}),(0,j.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:Z.authFieldReq}),(0,j.jsx)(`button`,{onClick:()=>f(e=>e.filter((e,n)=>n!==t)),className:Z.removeFieldBtn,children:`×`})]},t))]}),(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsxs)(`div`,{className:Z.panelHeader,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`🗂 Contesto AI`}),(0,j.jsx)(`button`,{className:Z.addBtn,onClick:()=>Se({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),ve.length>0?(0,j.jsx)(`div`,{className:Z.skillsList,children:ve.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.skillRow,children:[(0,j.jsx)(`span`,{className:Z.skillIcon,children:pn(e.type)}),(0,j.jsx)(`span`,{className:Z.skillName,title:e.name,children:e.name}),(0,j.jsx)(`span`,{className:`${Z.skillBadge} ${Z[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,j.jsx)(`span`,{className:Z.skillEmpty,children:`⚠`}),(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>Se({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>dt(t),children:`🗑`}),e.type===`log`&&(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>ut(t),children:`🗑`})]},t))}):(0,j.jsx)(`div`,{className:Z.skillsEmpty,children:I?`Nessun file di contesto. Clicca "+ Skill" per aggiungerne uno.`:`Crea o carica un progetto per i file di contesto.`})]}),Ce.length>0&&(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`💾 Snapshot`}),Ce.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,j.jsxs)(`div`,{className:Z.snapshotRow,children:[(0,j.jsx)(`span`,{className:Z.snapshotTs,children:t}),(0,j.jsxs)(`span`,{className:Z.snapshotCount,children:[e.fileCount,`f`]}),(0,j.jsx)(`button`,{className:Z.snapshotBtn,onClick:()=>nt(e.ts),children:`↺`})]},e.ts)})]}),w&&(0,j.jsx)(`div`,{className:Z.genStatus,children:`⏳ Generazione...`}),E&&(0,j.jsxs)(`div`,{className:Z.repairStatus,children:[(0,j.jsx)(`div`,{className:Z.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,j.jsxs)(`div`,{className:Z.repairStatusProg,children:[D,` / `,ne,` file`]}),(0,j.jsx)(`div`,{className:Z.repairStatusFile,children:re})]}),p.length>0&&!w&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:Z.actionRow,children:[(0,j.jsx)(`button`,{className:Z.actionBtn,onClick:lt,children:`⬇ ZIP`}),(0,j.jsx)(`button`,{className:Z.actionBtnIcon,title:`Syntax check`,onClick:rt,children:`✅`}),(0,j.jsx)(`button`,{className:`${Z.actionBtnIcon} ${we?Z.actionBtnActive:``}`,title:`Grep`,onClick:()=>Te(!we),children:`🔍`}),(0,j.jsx)(`button`,{className:Z.actionBtnIcon,title:`Snapshot`,onClick:et,children:`💾`})]}),p.some(e=>e._error||e._syntaxError)&&!E&&(0,j.jsx)(`button`,{className:Z.repairBtn,onClick:it,children:`🔧 Correggi tutti i file rossi`}),(0,j.jsx)(`button`,{className:Z.sandboxBtn,onClick:()=>i(`preview`),children:`▶ Sandbox`}),se&&(0,j.jsxs)(`div`,{className:Z.statsBar,children:[(0,j.jsxs)(`span`,{children:[`⏱ `,se.seconds>=60?`${Math.floor(se.seconds/60)}m ${se.seconds%60}s`:`${se.seconds}s`]}),(0,j.jsxs)(`span`,{children:[`↑ `,se.tokIn.toLocaleString(),` tok`]}),(0,j.jsxs)(`span`,{children:[`↓ `,se.tokOut.toLocaleString(),` tok`]}),(0,j.jsxs)(`span`,{children:[`📄 `,se.files,` file`]})]})]})]}),(0,j.jsxs)(`div`,{className:Z.rightPanel,children:[(0,j.jsxs)(`div`,{className:Z.rightTabBar,children:[(0,j.jsx)(`button`,{className:`${Z.rightTab} ${r===`preview`?``:Z.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,j.jsx)(`button`,{className:`${Z.rightTab} ${r===`preview`?Z.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),E&&(0,j.jsxs)(`div`,{className:Z.repairBar,children:[(0,j.jsxs)(`div`,{className:Z.repairBarRow,children:[(0,j.jsx)(`span`,{className:Z.repairBarIcon,children:`🔧`}),(0,j.jsx)(`span`,{className:Z.repairBarLabel,children:`Auto-fix`}),(0,j.jsx)(`span`,{className:Z.repairBarFile,children:re}),(0,j.jsxs)(`span`,{className:Z.repairBarCounter,children:[D,` / `,ne]}),(0,j.jsx)(`span`,{className:Z.repairBarTime,children:Ie}),(0,j.jsx)(`button`,{className:Z.stopBtn,onClick:Qe,children:`⏹ Stop`})]}),(0,j.jsx)(`div`,{className:Z.progressTrack,children:(0,j.jsx)(`div`,{className:Z.repairProgress,style:{width:ne>0?`${Math.round(D/ne*100)}%`:`0%`}})})]}),w&&(0,j.jsxs)(`div`,{className:Z.genBar,children:[(0,j.jsxs)(`div`,{className:Z.genBarRow,children:[(0,j.jsx)(`span`,{className:Z.genBarRobot,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.genBarLabel,children:N.total===0?`Pianificazione...`:`Generazione`}),(0,j.jsx)(`span`,{className:Z.genBarFile,children:N.name.split(`,`)[0].trim()}),(0,j.jsx)(`span`,{className:Z.genBarCounter,children:N.total>0?`${N.fi} / ${N.total}`:``}),(0,j.jsx)(`span`,{className:Z.genBarCounter,children:ae.tokIn+ae.tokOut>0?`↑${Ge(ae.tokIn)} ↓${Ge(ae.tokOut)}`:``}),(0,j.jsx)(`span`,{className:Z.genBarTime,children:Pe}),(0,j.jsxs)(`span`,{className:Z.genDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.progressTrack,children:(0,j.jsx)(`div`,{className:Z.genProgress,style:{width:N.total>0?`${Math.round(N.fi/N.total*100)}%`:`0%`}})})]}),r===`preview`?(0,j.jsx)(`div`,{className:Z.sandboxWrap,children:Me?(0,j.jsx)(`iframe`,{src:`http://127.0.0.1:${Me}`,className:Z.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,j.jsxs)(`div`,{className:Z.sandboxEmpty,children:[(0,j.jsx)(`span`,{children:`🌐`}),(0,j.jsx)(`span`,{children:e(`webcraft.stopped`)}),(0,j.jsx)(`button`,{className:Z.sandboxStartBtn,onClick:()=>{a&&at(a)},children:`▶ Avvia Sandbox`})]})}):(0,j.jsx)(`div`,{className:Z.codeArea,children:p.length===0&&w?(0,j.jsx)(`div`,{className:Z.noFiles,children:(0,j.jsxs)(`div`,{className:Z.noFilesHero,children:[(0,j.jsx)(`span`,{className:Z.noFilesIcon,children:`⏳`}),(0,j.jsx)(`span`,{className:Z.noFilesTitle,children:`Pianificazione...`}),(0,j.jsx)(`span`,{className:Z.noFilesTagline,children:N.name||`Analisi della struttura del progetto in corso`})]})}):p.length===0?(0,j.jsxs)(`div`,{className:Z.noFiles,children:[(0,j.jsxs)(`div`,{className:Z.noFilesHero,children:[(0,j.jsx)(`span`,{className:Z.noFilesIcon,children:`🔨`}),(0,j.jsx)(`span`,{className:Z.noFilesTitle,children:`WebCraft`}),(0,j.jsx)(`span`,{className:Z.noFilesTagline,children:`Genera progetti web completi con AI`})]}),(0,j.jsxs)(`div`,{className:Z.noFilesSteps,children:[(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`1`}),(0,j.jsx)(`span`,{children:`Scegli un esempio o scrivi una descrizione nel box in basso`})]}),(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`2`}),(0,j.jsxs)(`span`,{children:[`Premi `,(0,j.jsx)(`strong`,{children:`▶ Genera`}),` — l'AI crea tutti i file del progetto`]})]}),(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`3`}),(0,j.jsx)(`span`,{children:`Chiedi modifiche in chat, scarica lo ZIP o avvia il Sandbox`})]})]}),(0,j.jsxs)(`div`,{className:Z.noFilesExamplesHint,children:[`💡 Prova: `,(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[0];o(e.name),c(e.desc),de(e.desc)},children:`MySaaS`}),(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[1];o(e.name),c(e.desc),de(e.desc)},children:`MyShop`}),(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[3];o(e.name),c(e.desc),de(e.desc)},children:`MyPortfolio`})]})]}):(0,j.jsxs)(`div`,{className:Z.codeLayout,children:[(0,j.jsx)(`div`,{className:Z.ideTabBar,children:p.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===h;return(0,j.jsxs)(`button`,{className:`${Z.ideTab} ${r?Z.ideTabActive:``} ${n?Z.ideTabError:``} ${e._pending?Z.ideTabPending:``}`,onClick:()=>{g(t),x(null)},title:e.name,children:[(0,j.jsx)(`span`,{className:Z.ideTabIcon,children:e._pending?`⌛`:n?`⚠`:dn(e.name)}),(0,j.jsx)(`span`,{className:Z.ideTabName,children:e.name.split(`/`).pop()}),n&&(0,j.jsx)(`span`,{className:Z.ideTabDot})]},t)})}),S&&(0,j.jsxs)(`div`,{className:Z.diffOverlay,children:[(0,j.jsxs)(`div`,{className:Z.diffOverlayHeader,children:[(0,j.jsxs)(`span`,{children:[`✏ Modifica proposta — `,(0,j.jsx)(`strong`,{children:S.file})]}),(0,j.jsxs)(`div`,{className:Z.diffOverlayActions,children:[(0,j.jsx)(`button`,{className:Z.diffAcceptBtn,onClick:()=>{m(e=>e.map(e=>e.name===S.file?{...e,content:S.after}:e)),C(null)},children:`✓ Accetta`}),(0,j.jsx)(`button`,{className:Z.diffRejectBtn,onClick:()=>C(null),children:`✕ Rifiuta`})]})]}),(0,j.jsxs)(`div`,{className:Z.diffOverlayBody,children:[S.before.split(`
|
|
686
|
+
`);i=a.pop()??``;for(let e of a){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);e.type===`ready`&&e.port?(dt(`Server ready on port ${e.port}`),Ne(e.port)):e.type===`status`?dt(e.msg||`Processing...`):e.type===`log`?dt(e.msg||``):e.type===`warn`?dt(`WARN: ${e.msg}`):e.type===`error`?(dt(`ERROR: ${e.msg}`),Re(e.msg)):e.type===`exit`&&(dt(`Process exited with code ${e.code}`),e.code!==0&&Re(`Process exited with code ${e.code}`))}catch{}}}}catch(e){let t=e.message||`Connection failed`;dt(`ERROR: ${t}`),Re(t)}Fe(!1)}}async function pt(){a&&await ft(a)}(0,_.useEffect)(()=>{Xe.current=ut,Ze.current=pt});async function mt(){if(!Ee||!a)return;let e=await k(`/api/studio/webcraft/grep`,{projectName:a,query:Ee});e?.matches&&De(e.matches)}function ht(e){let t=p.findIndex(t=>t.name===e);t>=0&&(g(t),i(`files`))}function gt(){window.open(`/api/studio/webcraft/download/${encodeURIComponent(a)}`,`_blank`)}async function H(e,t,n,r){t.endsWith(`.md`)||(t+=`.md`);let i={name:t,content:n,type:r},s;s=e.mode===`edit`&&e.idx!==null?ve.map((t,n)=>n===e.idx?i:t):[...ve,i],ye(s),Se(null);let c=a||`MyProject`;a||o(c),await k(`/api/studio/webcraft/skills/${encodeURIComponent(c)}`,{skills:s})}async function _t(e){let t=ve[e];!t||!confirm(`Eliminare "${t.name}"?`)||(await k(`/api/studio/webcraft/skills/${encodeURIComponent(a)}/delete`,{name:t.name}),ye(ve.filter((t,n)=>n!==e)))}async function vt(e){let t=ve[e];if(!t||!confirm(`Svuotare "${t.name}"? Il file rimane ma il contenuto viene cancellato.`))return;let n=ve.map((t,n)=>n===e?{...t,content:``}:t);ye(n),await k(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`,{skills:n})}async function yt(){let e=await O(`/api/studio/webcraft/projects`);e?.projects&&je(e.projects)}async function bt(e){let t=await O(`/api/studio/webcraft/projects/load/${encodeURIComponent(e.name)}`);if(!t)return;o(t.projectName??e.name),c(t.description??``),m(t.files??[]),g(0),n(`new`),i(`files`),le([]),ye([]),be(!1);let r=await O(`/api/studio/webcraft/projects/chat/load/${encodeURIComponent(t.projectName??e.name)}`);r?.chat&&le(r.chat);let a=await O(`/api/studio/webcraft/skills/${encodeURIComponent(t.projectName??e.name)}`);a?.skills&&(ye(a.skills),be(!0))}async function xt(e){confirm(`Eliminare: ${e.name} - ${e.dir}?`)&&(await k(`/api/studio/webcraft/projects/${encodeURIComponent(e.name)}`,{},`DELETE`),je(Ae.filter(t=>t.name!==e.name)),a===e.name&&(o(``),m([]),le([]),c(``)))}async function U(){if(!ge)return;let e=ge.originalMessage;_e(null),await rt(e+`
|
|
687
|
+
[Piano approvato — procedi con le modifiche]`,null,[])}function St(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];he(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let Ct=a&&p.length>0,wt=p[h],Tt=fe||w;return(0,j.jsxs)(`div`,{className:Z.root,children:[(0,j.jsxs)(`div`,{className:Z.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Z.title,children:`⚙ WebCraft`}),(0,j.jsx)(`div`,{className:Z.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,j.jsxs)(`div`,{className:Z.headerTabs,children:[(0,j.jsx)(`button`,{className:`${Z.tabBtn} ${t===`new`?Z.tabActive:``}`,onClick:()=>n(`new`),children:`+ Nuovo`}),(0,j.jsx)(`button`,{className:`${Z.tabBtn} ${t===`projects`?Z.tabActive:``}`,onClick:()=>{n(`projects`),yt()},children:`📁 Progetti`})]})]}),(0,j.jsx)(`div`,{className:Z.body,children:t===`projects`?(0,j.jsx)(`div`,{className:Z.projectsList,children:Ae.length===0?(0,j.jsxs)(`div`,{className:Z.emptyProjects,children:[(0,j.jsx)(`span`,{className:Z.emptyIcon,children:`📁`}),(0,j.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,j.jsx)(`span`,{className:Z.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):Ae.map(e=>(0,j.jsxs)(`div`,{className:Z.projectCard,children:[(0,j.jsxs)(`div`,{className:Z.projectInfo,children:[(0,j.jsx)(`div`,{className:Z.projectName,children:e.name}),(0,j.jsx)(`div`,{className:Z.projectDesc,children:e.description}),(0,j.jsxs)(`div`,{className:Z.projectMeta,children:[(0,j.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,j.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,j.jsx)(`button`,{className:Z.openBtn,onClick:()=>bt(e),children:`↗ Apri`}),(0,j.jsx)(`button`,{className:Z.deleteBtn,onClick:()=>xt(e),children:`🗑`})]},e.name))}):(0,j.jsxs)(`div`,{className:Z.editor,children:[(0,j.jsxs)(`div`,{className:Z.examples,children:[(0,j.jsx)(`div`,{className:Z.sectionLabel,children:`Esempi`}),(0,j.jsx)(`div`,{className:Z.examplePills,children:cn.map(e=>(0,j.jsx)(`button`,{className:Z.examplePill,onClick:()=>{o(e.name),c(e.desc),de(e.desc)},children:e.name},e.name))})]}),(0,j.jsxs)(`div`,{className:Z.editorCols,children:[(0,j.jsxs)(`div`,{className:Z.leftSidebar,children:[(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`Blocchi`}),ln.map(e=>(0,j.jsxs)(`label`,{className:Z.blockLabel,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l[e.key],onChange:t=>u(n=>({...n,[e.key]:t.target.checked})),className:Z.blockCheck}),(0,j.jsx)(`span`,{children:e.icon}),(0,j.jsx)(`span`,{children:e.label})]},e.key))]}),l.auth&&(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsxs)(`div`,{className:Z.panelHeader,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`Campi Auth`}),(0,j.jsx)(`button`,{className:Z.addBtn,onClick:()=>f(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),d.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.authField,children:[(0,j.jsx)(`input`,{value:e.label,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:Z.authFieldInput}),(0,j.jsx)(`select`,{value:e.type,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:Z.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))}),(0,j.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:Z.authFieldReq}),(0,j.jsx)(`button`,{onClick:()=>f(e=>e.filter((e,n)=>n!==t)),className:Z.removeFieldBtn,children:`×`})]},t))]}),(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsxs)(`div`,{className:Z.panelHeader,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`🗂 Contesto AI`}),(0,j.jsx)(`button`,{className:Z.addBtn,onClick:()=>Se({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),ve.length>0?(0,j.jsx)(`div`,{className:Z.skillsList,children:ve.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.skillRow,children:[(0,j.jsx)(`span`,{className:Z.skillIcon,children:pn(e.type)}),(0,j.jsx)(`span`,{className:Z.skillName,title:e.name,children:e.name}),(0,j.jsx)(`span`,{className:`${Z.skillBadge} ${Z[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,j.jsx)(`span`,{className:Z.skillEmpty,children:`⚠`}),(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>Se({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>vt(t),children:`🗑`}),e.type===`log`&&(0,j.jsx)(`button`,{className:Z.skillBtn,onClick:()=>_t(t),children:`🗑`})]},t))}):(0,j.jsx)(`div`,{className:Z.skillsEmpty,children:I?`Nessun file di contesto. Clicca "+ Skill" per aggiungerne uno.`:`Crea o carica un progetto per i file di contesto.`})]}),Ce.length>0&&(0,j.jsxs)(`div`,{className:Z.panel,children:[(0,j.jsx)(`div`,{className:Z.panelTitle,children:`💾 Snapshot`}),Ce.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,j.jsxs)(`div`,{className:Z.snapshotRow,children:[(0,j.jsx)(`span`,{className:Z.snapshotTs,children:t}),(0,j.jsxs)(`span`,{className:Z.snapshotCount,children:[e.fileCount,`f`]}),(0,j.jsx)(`button`,{className:Z.snapshotBtn,onClick:()=>lt(e.ts),children:`↺`})]},e.ts)})]}),w&&(0,j.jsx)(`div`,{className:Z.genStatus,children:`⏳ Generazione...`}),E&&(0,j.jsxs)(`div`,{className:Z.repairStatus,children:[(0,j.jsx)(`div`,{className:Z.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,j.jsxs)(`div`,{className:Z.repairStatusProg,children:[D,` / `,ne,` file`]}),(0,j.jsx)(`div`,{className:Z.repairStatusFile,children:re})]}),p.length>0&&!w&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:Z.actionRow,children:[(0,j.jsx)(`button`,{className:Z.actionBtn,onClick:gt,children:`⬇ ZIP`}),(0,j.jsx)(`button`,{className:Z.actionBtnIcon,title:`Syntax check`,onClick:V,children:`✅`}),(0,j.jsx)(`button`,{className:`${Z.actionBtnIcon} ${we?Z.actionBtnActive:``}`,title:`Grep`,onClick:()=>Te(!we),children:`🔍`}),(0,j.jsx)(`button`,{className:Z.actionBtnIcon,title:`Snapshot`,onClick:st,children:`💾`})]}),p.some(e=>e._error||e._syntaxError)&&!E&&(0,j.jsx)(`button`,{className:Z.repairBtn,onClick:ut,children:`🔧 Correggi tutti i file rossi`}),(0,j.jsx)(`button`,{className:Z.sandboxBtn,onClick:()=>{a?ft(a):i(`preview`)},children:Pe?`⏳ Starting...`:Me?`🌐 Sandbox Live`:`▶ Sandbox`}),se&&(0,j.jsxs)(`div`,{className:Z.statsBar,children:[(0,j.jsxs)(`span`,{children:[`⏱ `,se.seconds>=60?`${Math.floor(se.seconds/60)}m ${se.seconds%60}s`:`${se.seconds}s`]}),(0,j.jsxs)(`span`,{children:[`↑ `,se.tokIn.toLocaleString(),` tok`]}),(0,j.jsxs)(`span`,{children:[`↓ `,se.tokOut.toLocaleString(),` tok`]}),(0,j.jsxs)(`span`,{children:[`📄 `,se.files,` file`]})]})]})]}),(0,j.jsxs)(`div`,{className:Z.rightPanel,children:[(0,j.jsxs)(`div`,{className:Z.rightTabBar,children:[(0,j.jsx)(`button`,{className:`${Z.rightTab} ${r===`preview`?``:Z.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,j.jsx)(`button`,{className:`${Z.rightTab} ${r===`preview`?Z.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),E&&(0,j.jsxs)(`div`,{className:Z.repairBar,children:[(0,j.jsxs)(`div`,{className:Z.repairBarRow,children:[(0,j.jsx)(`span`,{className:Z.repairBarIcon,children:`🔧`}),(0,j.jsx)(`span`,{className:Z.repairBarLabel,children:`Auto-fix`}),(0,j.jsx)(`span`,{className:Z.repairBarFile,children:re}),(0,j.jsxs)(`span`,{className:Z.repairBarCounter,children:[D,` / `,ne]}),(0,j.jsx)(`span`,{className:Z.repairBarTime,children:He}),(0,j.jsx)(`button`,{className:Z.stopBtn,onClick:at,children:`⏹ Stop`})]}),(0,j.jsx)(`div`,{className:Z.progressTrack,children:(0,j.jsx)(`div`,{className:Z.repairProgress,style:{width:ne>0?`${Math.round(D/ne*100)}%`:`0%`}})})]}),w&&(0,j.jsxs)(`div`,{className:Z.genBar,children:[(0,j.jsxs)(`div`,{className:Z.genBarRow,children:[(0,j.jsx)(`span`,{className:Z.genBarRobot,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.genBarLabel,children:N.total===0?`Pianificazione...`:`Generazione`}),(0,j.jsx)(`span`,{className:Z.genBarFile,children:N.name.split(`,`)[0].trim()}),(0,j.jsx)(`span`,{className:Z.genBarCounter,children:N.total>0?`${N.fi} / ${N.total}`:``}),(0,j.jsx)(`span`,{className:Z.genBarCounter,children:ae.tokIn+ae.tokOut>0?`↑${Qe(ae.tokIn)} ↓${Qe(ae.tokOut)}`:``}),(0,j.jsx)(`span`,{className:Z.genBarTime,children:Be}),(0,j.jsxs)(`span`,{className:Z.genDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.progressTrack,children:(0,j.jsx)(`div`,{className:Z.genProgress,style:{width:N.total>0?`${Math.round(N.fi/N.total*100)}%`:`0%`}})})]}),r===`preview`?(0,j.jsxs)(`div`,{className:Z.sandboxWrap,children:[(Pe||Ie.length>0||Le)&&(0,j.jsxs)(`div`,{className:Z.sandboxConsole,children:[(0,j.jsxs)(`div`,{className:Z.sandboxConsoleHeader,children:[(0,j.jsxs)(`span`,{className:Z.sandboxConsoleTitle,children:[Pe?`⏳`:Le?`❌`:Me?`✅`:`🌐`,` Sandbox Console`]}),Me&&(0,j.jsxs)(`span`,{className:Z.sandboxConsolePort,children:[`:`,Me]}),Pe&&(0,j.jsxs)(`span`,{className:Z.sandboxConsoleDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.sandboxConsoleBody,ref:ze,children:Ie.map((e,t)=>(0,j.jsx)(`div`,{className:`${Z.sandboxLogLine} ${e.includes(`ERROR`)?Z.sandboxLogError:e.includes(`WARN`)?Z.sandboxLogWarn:e.includes(`ready`)||e.includes(`Ready`)?Z.sandboxLogOk:``}`,children:e},t))})]}),Me?(0,j.jsx)(`iframe`,{src:`http://127.0.0.1:${Me}`,className:Z.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,j.jsxs)(`div`,{className:Z.sandboxEmpty,children:[(0,j.jsx)(`span`,{children:Pe?`⏳`:Le?`❌`:`🌐`}),(0,j.jsx)(`span`,{children:Pe?`Avvio in corso...`:Le||`Sandbox non attiva`}),!Pe&&(0,j.jsx)(`button`,{className:Z.sandboxStartBtn,onClick:()=>{a&&ft(a)},children:`▶ Avvia Sandbox`})]})]}):(0,j.jsx)(`div`,{className:Z.codeArea,children:p.length===0&&w?(0,j.jsx)(`div`,{className:Z.noFiles,children:(0,j.jsxs)(`div`,{className:Z.noFilesHero,children:[(0,j.jsx)(`span`,{className:Z.noFilesIcon,children:`⏳`}),(0,j.jsx)(`span`,{className:Z.noFilesTitle,children:`Pianificazione...`}),(0,j.jsx)(`span`,{className:Z.noFilesTagline,children:N.name||`Analisi della struttura del progetto in corso`})]})}):p.length===0?(0,j.jsxs)(`div`,{className:Z.noFiles,children:[(0,j.jsxs)(`div`,{className:Z.noFilesHero,children:[(0,j.jsx)(`span`,{className:Z.noFilesIcon,children:`🔨`}),(0,j.jsx)(`span`,{className:Z.noFilesTitle,children:`WebCraft`}),(0,j.jsx)(`span`,{className:Z.noFilesTagline,children:`Genera progetti web completi con AI`})]}),(0,j.jsxs)(`div`,{className:Z.noFilesSteps,children:[(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`1`}),(0,j.jsx)(`span`,{children:`Scegli un esempio o scrivi una descrizione nel box in basso`})]}),(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`2`}),(0,j.jsxs)(`span`,{children:[`Premi `,(0,j.jsx)(`strong`,{children:`▶ Genera`}),` — l'AI crea tutti i file del progetto`]})]}),(0,j.jsxs)(`div`,{className:Z.noFilesStep,children:[(0,j.jsx)(`span`,{className:Z.noFilesStepNum,children:`3`}),(0,j.jsx)(`span`,{children:`Chiedi modifiche in chat, scarica lo ZIP o avvia il Sandbox`})]})]}),(0,j.jsxs)(`div`,{className:Z.noFilesExamplesHint,children:[`💡 Prova: `,(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[0];o(e.name),c(e.desc),de(e.desc)},children:`MySaaS`}),(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[1];o(e.name),c(e.desc),de(e.desc)},children:`MyShop`}),(0,j.jsx)(`button`,{className:Z.noFilesExampleBtn,onClick:()=>{let e=cn[3];o(e.name),c(e.desc),de(e.desc)},children:`MyPortfolio`})]})]}):(0,j.jsxs)(`div`,{className:Z.codeLayout,children:[(0,j.jsx)(`div`,{className:Z.ideTabBar,children:p.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===h;return(0,j.jsxs)(`button`,{className:`${Z.ideTab} ${r?Z.ideTabActive:``} ${n?Z.ideTabError:``} ${e._pending?Z.ideTabPending:``}`,onClick:()=>{g(t),x(null)},title:e.name,children:[(0,j.jsx)(`span`,{className:Z.ideTabIcon,children:e._pending?`⌛`:n?`⚠`:dn(e.name)}),(0,j.jsx)(`span`,{className:Z.ideTabName,children:e.name.split(`/`).pop()}),n&&(0,j.jsx)(`span`,{className:Z.ideTabDot})]},t)})}),S&&(0,j.jsxs)(`div`,{className:Z.diffOverlay,children:[(0,j.jsxs)(`div`,{className:Z.diffOverlayHeader,children:[(0,j.jsxs)(`span`,{children:[`✏ Modifica proposta — `,(0,j.jsx)(`strong`,{children:S.file})]}),(0,j.jsxs)(`div`,{className:Z.diffOverlayActions,children:[(0,j.jsx)(`button`,{className:Z.diffAcceptBtn,onClick:()=>{m(e=>e.map(e=>e.name===S.file?{...e,content:S.after}:e)),C(null)},children:`✓ Accetta`}),(0,j.jsx)(`button`,{className:Z.diffRejectBtn,onClick:()=>C(null),children:`✕ Rifiuta`})]})]}),(0,j.jsxs)(`div`,{className:Z.diffOverlayBody,children:[S.before.split(`
|
|
688
688
|
`).map((e,t)=>e===(S.after.split(`
|
|
689
689
|
`)[t]??``)?(0,j.jsxs)(`div`,{className:Z.diffSame,children:[`\xA0`,e||` `]},t):(0,j.jsxs)(`div`,{className:Z.diffRem,children:[`- `,e]},`r${t}`)),S.after.split(`
|
|
690
690
|
`).map((e,t)=>e===(S.before.split(`
|
|
691
|
-
`)[t]??``)?null:(0,j.jsxs)(`div`,{className:Z.diffAdd,children:[`+ `,e]},`a${t}`))]})]}),(0,j.jsxs)(`div`,{className:Z.codeRow,children:[(0,j.jsx)(`div`,{className:Z.codeEditorWrap,children:
|
|
692
|
-
`).length,` righe · `,fn(
|
|
691
|
+
`)[t]??``)?null:(0,j.jsxs)(`div`,{className:Z.diffAdd,children:[`+ `,e]},`a${t}`))]})]}),(0,j.jsxs)(`div`,{className:Z.codeRow,children:[(0,j.jsx)(`div`,{className:Z.codeEditorWrap,children:wt&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:Z.codeHeader,children:[(0,j.jsx)(`span`,{className:Z.codeFileIcon,children:dn(wt.name)}),(0,j.jsx)(`span`,{className:Z.codeFileName,children:wt.name}),wt.content&&!wt._error&&(0,j.jsxs)(`span`,{className:Z.codeFileMeta,children:[wt.content.split(`
|
|
692
|
+
`).length,` righe · `,fn(wt.content)]}),!wt._pending&&!wt._error&&!w&&(0,j.jsx)(`button`,{className:`${Z.editToggleBtn} ${b===null?``:Z.editToggleBtnActive}`,onClick:()=>{b===null?x(wt.content):(m(e=>e.map((e,t)=>t===h?{...e,content:b}:e)),x(null))},children:b===null?`✏ Modifica`:`💾 Salva`})]}),wt._error&&(0,j.jsx)(`div`,{className:Z.fileError,children:`⚠ Generazione fallita — chiedi al modello di rigenerare questo file`}),wt._syntaxError&&!wt._error&&(0,j.jsxs)(`div`,{className:Z.fileSyntaxError,children:[`⚠ Syntax error: `,wt._syntaxError]}),b===null?(0,j.jsxs)(`pre`,{className:`${Z.code} ${wt._error?Z.codeError:wt._syntaxError?Z.codeSyntaxError:``}`,children:[w&&v!==null?v:wt.content,(wt._pending||w&&v!==null)&&(0,j.jsx)(`span`,{className:Z.genCursor,children:`▋`})]}):(0,j.jsx)(`textarea`,{className:Z.codeEditor,value:b,onChange:e=>x(e.target.value),spellCheck:!1})]})}),(0,j.jsxs)(`div`,{className:Z.fileSidebar,children:[(0,j.jsxs)(`div`,{className:Z.fileSidebarHeader,children:[p.length,` file`]}),p.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===h;return(0,j.jsxs)(`button`,{className:`${Z.fileTab} ${r?Z.fileTabActive:``} ${n?Z.fileTabError:``}`,onClick:()=>{g(t),x(null),y(null)},children:[(0,j.jsxs)(`div`,{className:Z.fileTabRow,children:[(0,j.jsx)(`span`,{className:Z.fileTabIcon,children:e._pending?`⌛`:n?`⚠`:dn(e.name)}),(0,j.jsx)(`span`,{className:Z.fileTabName,children:e.name.split(`/`).pop()}),e.content&&!e._pending&&(0,j.jsx)(`span`,{className:Z.fileTabSize,children:fn(e.content)})]}),(0,j.jsx)(`div`,{className:Z.fileTabDir,children:e.name.includes(`/`)?e.name:`./${e.name}`}),e.content&&!e._pending&&(0,j.jsxs)(`div`,{className:Z.fileTabTokens,children:[`~`,Math.ceil(e.content.length/4),` tok`]})]},t)})]})]})]})})]})]})]})}),ge&&t!==`projects`&&(0,j.jsxs)(`div`,{className:Z.planBanner,children:[(0,j.jsx)(`div`,{className:Z.planTitle,children:`📌 Piano proposto — approva per eseguire`}),(0,j.jsx)(`pre`,{className:Z.planText,children:ge.plan}),(0,j.jsxs)(`div`,{className:Z.planActions,children:[(0,j.jsx)(`button`,{className:Z.planApprove,onClick:U,children:`✓ Esegui`}),(0,j.jsx)(`button`,{className:Z.planReject,onClick:()=>_e(null),children:`✕ Annulla`})]})]}),we&&t!==`projects`&&(0,j.jsxs)(`div`,{className:Z.grepPanel,children:[(0,j.jsxs)(`div`,{className:Z.grepRow,children:[(0,j.jsx)(`input`,{className:Z.grepInput,value:Ee,onChange:e=>R(e.target.value),onKeyDown:e=>e.key===`Enter`&&mt(),placeholder:`Cerca nel codice...`}),(0,j.jsx)(`button`,{className:Z.grepBtn,onClick:mt,children:`🔍`}),(0,j.jsx)(`button`,{className:Z.grepClose,onClick:()=>Te(!1),children:`×`})]}),z.length>0&&(0,j.jsxs)(`div`,{className:Z.grepCount,children:[z.length,` risultati`]}),(0,j.jsx)(`div`,{className:Z.grepResults,children:z.length===0?(0,j.jsx)(`div`,{className:Z.grepEmpty,children:`Nessun risultato.`}):z.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.grepMatch,onClick:()=>ht(e.file),children:[(0,j.jsxs)(`span`,{className:Z.grepMatchFile,children:[e.file,`:`,e.lineNum]}),(0,j.jsx)(`pre`,{className:Z.grepMatchLine,children:e.line})]},t))})]}),Oe.length>0&&t!==`projects`&&(0,j.jsxs)(`div`,{className:Z.diffPanel,children:[(0,j.jsxs)(`div`,{className:Z.diffHeader,children:[(0,j.jsxs)(`span`,{children:[`🔌 Diff — `,Oe.length,` file modificati`]}),(0,j.jsx)(`button`,{className:Z.diffClose,onClick:()=>ke([]),children:`✕ Chiudi`})]}),Oe.map((e,t)=>{let n=e.after.split(`
|
|
693
693
|
`).length-e.before.split(`
|
|
694
|
-
`).length;return(0,j.jsxs)(`details`,{open:!0,className:Z.diffFile,children:[(0,j.jsxs)(`summary`,{className:Z.diffSummary,children:[(0,j.jsx)(`span`,{className:Z.diffArrow,children:`▲`}),(0,j.jsx)(`span`,{className:Z.diffFileName,children:e.file}),(0,j.jsxs)(`span`,{className:n>=0?Z.diffAdded:Z.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,j.jsx)(`div`,{className:Z.diffContent,children:(0,j.jsx)(hn,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,j.jsxs)(`div`,{className:Z.chatPanel,children:[(0,j.jsxs)(`div`,{className:Z.chatMessages,ref:
|
|
694
|
+
`).length;return(0,j.jsxs)(`details`,{open:!0,className:Z.diffFile,children:[(0,j.jsxs)(`summary`,{className:Z.diffSummary,children:[(0,j.jsx)(`span`,{className:Z.diffArrow,children:`▲`}),(0,j.jsx)(`span`,{className:Z.diffFileName,children:e.file}),(0,j.jsxs)(`span`,{className:n>=0?Z.diffAdded:Z.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,j.jsx)(`div`,{className:Z.diffContent,children:(0,j.jsx)(hn,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,j.jsxs)(`div`,{className:Z.chatPanel,children:[(0,j.jsxs)(`div`,{className:Z.chatMessages,ref:Je,children:[F.length===0&&Ct&&(0,j.jsx)(`div`,{className:Z.chatWelcome,children:`🤖 Pronto! Dimmi cosa vuoi modificare o migliorare nel progetto.`}),F.map((e,t)=>(0,j.jsxs)(`div`,{className:e.role===`user`?Z.chatUser:e.role===`system`?Z.chatSystem:Z.chatAgent,children:[e.role===`user`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:Z.chatUserBubble,children:e.text}),e.attachments&&e.attachments.length>0&&(0,j.jsx)(`div`,{className:Z.chatAttachPreviews,children:e.attachments.map((e,t)=>(0,j.jsxs)(`span`,{className:Z.chatAttachBadge,children:[`📎 `,e.name]},t))})]}),e.role===`system`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:Z.chatSystemBubble,children:e.text}),e.syntaxErrors?.map((e,t)=>(0,j.jsxs)(`div`,{className:Z.chatSyntaxErr,children:[`✕ `,e.file,`: `,e.error]},t))]}),e.role===`agent`&&(0,j.jsxs)(`div`,{className:Z.chatAgentCard,children:[(0,j.jsxs)(`div`,{className:Z.chatAgentHeader,children:[(0,j.jsx)(`span`,{className:Z.chatAgentRobot,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.chatAgentLabel,children:`WebCraft Agent`})]}),(0,j.jsx)(`div`,{className:Z.chatAgentText,children:e.text.replace(/<tool>[\s\S]*?<\/tool>/g,``).trim()}),e.tools&&e.tools.filter(e=>(e.op===`edit`||e.op===`write`)&&e.result===`ok`&&(e.oldSnippet||e.newSnippet)).map((e,t)=>(0,j.jsxs)(`div`,{className:Z.diffInline,children:[(0,j.jsxs)(`div`,{className:Z.diffInlineHeader,children:[`✏ `,e.path]}),e.oldSnippet?.split(`
|
|
695
695
|
`).map((e,t)=>(0,j.jsxs)(`div`,{className:Z.diffRemLine,children:[`- `,e]},`r${t}`)),e.newSnippet?.split(`
|
|
696
|
-
`).map((e,t)=>(0,j.jsxs)(`div`,{className:Z.diffAddLine,children:[`+ `,e]},`a${t}`))]},t)),e.tools&&e.tools.length>0&&(0,j.jsx)(`div`,{className:Z.chatToolBadges,children:e.tools.map((e,t)=>(0,j.jsxs)(`span`,{className:`${Z.toolBadge} ${e.result===`ok`?Z.toolBadgeOk:Z.toolBadgeErr}`,children:[e.op===`edit`?`✏`:e.op===`write`?`+`:`👁`,` `,e.path]},t))})]})]},t)),fe&&(0,j.jsxs)(`div`,{className:Z.chatAgentCard,children:[(0,j.jsxs)(`div`,{className:Z.chatAgentHeader,children:[(0,j.jsx)(`span`,{className:Z.chatAgentRobotAnim,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.chatAgentLabel,children:`WebCraft Agent`}),(0,j.jsxs)(`span`,{className:Z.chatRunningDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.chatAgentText,children:(0,j.jsx)(`span`,{className:Z.cursor,children:``})})]})]}),me.length>0&&(0,j.jsx)(`div`,{className:Z.attachPreviews,children:me.map((e,t)=>(0,j.jsxs)(`span`,{className:Z.attachBadge,children:[`📎 `,e.name,(0,j.jsx)(`button`,{className:Z.removeAttachBtn,onClick:()=>he(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),
|
|
696
|
+
`).map((e,t)=>(0,j.jsxs)(`div`,{className:Z.diffAddLine,children:[`+ `,e]},`a${t}`))]},t)),e.tools&&e.tools.length>0&&(0,j.jsx)(`div`,{className:Z.chatToolBadges,children:e.tools.map((e,t)=>(0,j.jsxs)(`span`,{className:`${Z.toolBadge} ${e.result===`ok`?Z.toolBadgeOk:Z.toolBadgeErr}`,children:[e.op===`edit`?`✏`:e.op===`write`?`+`:`👁`,` `,e.path]},t))})]})]},t)),fe&&(0,j.jsxs)(`div`,{className:Z.chatAgentCard,children:[(0,j.jsxs)(`div`,{className:Z.chatAgentHeader,children:[(0,j.jsx)(`span`,{className:Z.chatAgentRobotAnim,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.chatAgentLabel,children:`WebCraft Agent`}),(0,j.jsxs)(`span`,{className:Z.chatRunningDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.chatAgentText,children:(0,j.jsx)(`span`,{className:Z.cursor,children:``})})]})]}),me.length>0&&(0,j.jsx)(`div`,{className:Z.attachPreviews,children:me.map((e,t)=>(0,j.jsxs)(`span`,{className:Z.attachBadge,children:[`📎 `,e.name,(0,j.jsx)(`button`,{className:Z.removeAttachBtn,onClick:()=>he(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),Ct?(0,j.jsxs)(`div`,{className:Z.projActiveRow,children:[`📄 `,(0,j.jsx)(`strong`,{className:Z.projActiveName,children:a}),` — scrivi per modificare o migliorare il progetto`]}):(0,j.jsxs)(`div`,{className:Z.projNameRow,children:[(0,j.jsx)(`span`,{className:Z.projNameLabel,children:`Nome progetto:`}),(0,j.jsx)(`input`,{className:Z.projNameInput,value:a,onChange:e=>o(e.target.value),placeholder:`MioProgetto`})]}),(0,j.jsxs)(`div`,{className:Z.chatInputRow,children:[(0,j.jsxs)(`label`,{className:Z.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,j.jsx)(`input`,{ref:Ye,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>St(e.target.files)})]}),(0,j.jsx)(`textarea`,{className:Z.chatTextarea,value:ue,onChange:e=>de(e.target.value),placeholder:Ct?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:Tt,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),nt())},rows:4}),(0,j.jsxs)(`div`,{className:Z.chatSendCol,children:[(0,j.jsx)(`button`,{className:Z.chatSendBtn,onClick:nt,disabled:Tt,children:w?`⏳`:Ct?`▶`:`▶ Genera`}),Tt&&(0,j.jsx)(`button`,{className:Z.chatStopBtn,onClick:at,children:`⏹ Stop`})]})]})]}),xe&&(0,j.jsx)(gn,{modal:xe,skills:ve,projectName:a,onClose:()=>Se(null),onSave:(e,t,n)=>H(xe,e,t,n)})]})}function hn({before:e,after:t}){let n=e.split(`
|
|
697
697
|
`),r=t.split(`
|
|
698
698
|
`),i=[],a=0,o=0;for(;(a<n.length||o<r.length)&&(a>=n.length?i.push({type:`add`,text:r[o++]??``}):o>=r.length?i.push({type:`rem`,text:n[a++]??``}):n[a]===r[o]?(i.push({type:`same`,text:n[a++]??``}),o++):(i.push({type:`rem`,text:n[a++]??``}),i.push({type:`add`,text:r[o++]??``})),!(i.length>2e3)););return(0,j.jsx)(`div`,{style:{fontFamily:`var(--mono)`,fontSize:10},children:i.map((e,t)=>(0,j.jsxs)(`div`,{style:{padding:`1px 8px`,background:e.type===`add`?`#0a3a1a`:e.type===`rem`?`#3a0a0a`:`transparent`,color:e.type===`add`?`#4ade80`:e.type===`rem`?`#f87171`:`var(--dim)`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:[e.type===`add`?`+`:e.type===`rem`?`-`:` `,e.text]},t))})}function gn({modal:e,skills:t,projectName:n,onClose:r,onSave:i}){let[a,o]=(0,_.useState)(e.name),[s,c]=(0,_.useState)(e.content),[l,u]=(0,_.useState)(e.type),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),h=l===`skill`?6e3:4e3,g=s.length>h;async function v(){if(!d.trim())return;m(!0);let e={skill:`Sei un esperto di sviluppo web fullstack. Genera un file Markdown "skill" per il WebCraft Agent. Deve contenere istruzioni, pattern di codice, best practice e snippet pronti all uso come contesto persistente. Scrivi SOLO il contenuto Markdown, niente altro.`,memory:`Sei un assistente tecnico. Genera un file Markdown "memory" per il WebCraft Agent. Deve riassumere decisioni architetturali, preferenze dello sviluppatore e contesto generale del progetto. Scrivi SOLO il Markdown.`,provider:`Sei un esperto di prompt engineering. Genera un file Markdown con istruzioni specifiche per calibrare il comportamento del modello AI. Scrivi SOLO il Markdown.`},t=await k(`/api/studio/webcraft`,{system:e[l]??e.skill,user:`Progetto: ${n}\n\n${d}`,max_tokens:2048});t?.text&&(c(t.text),a||o(l===`memory`?`memory.md`:l===`provider`?`liara.md`:d.toLowerCase().replace(/[^a-z0-9]+/g,`-`).slice(0,30)+`.md`)),m(!1)}function y(){if(!a.trim()){alert(`Inserisci un nome per il file.`);return}let n=a.endsWith(`.md`)?a:a+`.md`;if((l===`memory`||l===`provider`)&&e.mode===`new`&&t.findIndex(e=>e.type===l)>=0){alert(`Esiste già un file di tipo "${l}". Modificalo direttamente.`);return}i(n,s,l)}return(0,j.jsx)(`div`,{className:Z.modalOverlay,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,j.jsxs)(`div`,{className:Z.modal,children:[(0,j.jsxs)(`div`,{className:Z.modalHeader,children:[(0,j.jsxs)(`span`,{className:Z.modalTitle,children:[pn(l),` `,e.mode===`new`?`Nuovo file di contesto`:`Modifica ${e.name}`]}),(0,j.jsx)(`button`,{className:Z.modalClose,onClick:r,children:`×`})]}),(0,j.jsx)(`div`,{className:Z.modalBody,children:e.mode===`view`?(0,j.jsx)(`pre`,{className:Z.logView,children:s}):(0,j.jsxs)(j.Fragment,{children:[e.mode===`new`&&(0,j.jsxs)(`div`,{className:Z.modalRow,children:[(0,j.jsxs)(`div`,{className:Z.modalField,children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`TIPO`}),(0,j.jsx)(`select`,{value:l,onChange:e=>{let t=e.target.value;u(t),t===`memory`?o(`memory.md`):t===`provider`&&o(`liara.md`)},className:Z.modalSelect,children:[`skill`,`memory`,`provider`].map(e=>{let n=(e===`memory`||e===`provider`)&&t.some(t=>t.type===e);return(0,j.jsxs)(`option`,{value:e,disabled:n,children:[e,n?` (esiste già)`:``]},e)})})]}),(0,j.jsxs)(`div`,{className:Z.modalField,style:{flex:2},children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`NOME FILE`}),(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:l===`memory`?`memory.md`:l===`provider`?`liara.md`:`nome-skill.md`,className:Z.modalInput})]})]}),(0,j.jsxs)(`div`,{className:Z.modalHint,children:[`💡 `,l===`skill`?`Istruzioni tecniche, snippet, pattern di codice specifici. Max ~6000 caratteri.`:l===`memory`?`Note persistenti sul progetto: decisioni architetturali, preferenze. Solo UN file. Max ~4000 caratteri.`:`Istruzioni specifiche per il modello AI (tono, formato, vincoli). Solo UN file. Max ~4000 caratteri.`]}),(0,j.jsxs)(`div`,{className:Z.modalAiBox,children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`🤖 GENERA CON AI`}),(0,j.jsxs)(`div`,{className:Z.modalAiRow,children:[(0,j.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,placeholder:`Descrivi cosa deve contenere questo file...`,className:Z.modalAiDesc}),(0,j.jsx)(`button`,{onClick:v,disabled:p,className:Z.modalAiBtn,children:p?`⏳ ...`:`▶ Genera`})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:Z.modalLabelRow,children:[(0,j.jsx)(`span`,{children:`CONTENUTO (markdown)`}),(0,j.jsxs)(`span`,{style:{color:g?`#e05050`:`var(--dim)`},children:[s.length,` car.`,g?` ⚠ Troppo lungo`:``]})]}),(0,j.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:14,placeholder:`# Titolo
|
|
699
699
|
Scrivi le istruzioni in Markdown...`,className:Z.modalContentArea,style:{borderColor:g?`#e05050`:`var(--border2)`}})]})]})}),(0,j.jsxs)(`div`,{className:Z.modalFooter,children:[(0,j.jsx)(`button`,{onClick:r,className:Z.modalCancelBtn,children:`Annulla`}),e.mode!==`view`&&(0,j.jsx)(`button`,{onClick:y,className:Z.modalSaveBtn,children:`✓ Salva`})]})]})})}var _n={root:`_root_x9yvu_1`,loading:`_loading_x9yvu_7`,empty:`_empty_x9yvu_18`,emptyIcon:`_emptyIcon_x9yvu_29`,emptyTitle:`_emptyTitle_x9yvu_30`,emptySub:`_emptySub_x9yvu_31`,generateBtn:`_generateBtn_x9yvu_33`,summary:`_summary_x9yvu_46`,sectionTitle:`_sectionTitle_x9yvu_57`,alertTitle:`_alertTitle_x9yvu_68`,actionCard:`_actionCard_x9yvu_70`,actionTime:`_actionTime_x9yvu_81`,actionText:`_actionText_x9yvu_89`,schedCard:`_schedCard_x9yvu_95`,schedTime:`_schedTime_x9yvu_106`,schedTitle:`_schedTitle_x9yvu_114`,alertCard:`_alertCard_x9yvu_119`,alertSev:`_alertSev_x9yvu_129`,alertAction:`_alertAction_x9yvu_135`,insight:`_insight_x9yvu_141`,regenRow:`_regenRow_x9yvu_148`,regenBtn:`_regenBtn_x9yvu_153`};function vn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=()=>{i(!0),c(!1),O(`/api/plan`).then(e=>{e?.plan?(n(e.plan),c(!1)):(n(null),c(!0)),i(!1)}).catch(()=>{i(!1),c(!0)})},u=async()=>{o(!0),i(!0),n(null);try{await k(`/api/plan/refresh`,{}),l()}catch{i(!1)}finally{o(!1)}};if((0,_.useEffect)(()=>{l()},[]),r)return(0,j.jsxs)(`div`,{className:_n.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),(0,j.jsx)(`div`,{children:a?`Generating plan with 5 agents...`:`Loading plan...`})]});if(s||!t)return(0,j.jsxs)(`div`,{className:_n.empty,children:[(0,j.jsx)(`div`,{className:_n.emptyIcon,children:`🗓️`}),(0,j.jsxs)(`div`,{className:_n.emptyTitle,children:[e(`plan.noplan`),` generated yet`]}),(0,j.jsx)(`div`,{className:_n.emptySub,children:`Generate a daily plan using your calendar, tasks, and emails.`}),(0,j.jsx)(`button`,{className:_n.generateBtn,onClick:u,children:e(`plan.generate`)})]});let d=e=>typeof e==`string`?e:e.description??e.message??e.action_required??`Alert`,f=e=>typeof e==`object`&&e.severity?` [${e.severity.toUpperCase()}]`:``,p=e=>typeof e==`object`&&e.action_required&&e.action_required!==d(e)?e.action_required:``,m=e=>typeof e==`string`?e:e.message??e.insight??``;return(0,j.jsxs)(`div`,{className:_n.root,children:[t.executive_summary&&(0,j.jsx)(`div`,{className:_n.summary,children:t.executive_summary}),t.priority_actions&&t.priority_actions.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Priority Actions`}),t.priority_actions.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.actionCard,children:[e.time&&(0,j.jsx)(`span`,{className:_n.actionTime,children:e.time}),(0,j.jsx)(`span`,{className:_n.actionText,children:e.action})]},t))]}),t.schedule&&t.schedule.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Schedule`}),t.schedule.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.schedCard,children:[(0,j.jsxs)(`span`,{className:_n.schedTime,children:[e.time_start,`–`,e.time_end]}),(0,j.jsx)(`span`,{className:_n.schedTitle,children:e.title})]},t))]}),t.security_alerts&&t.security_alerts.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`${_n.sectionTitle} ${_n.alertTitle}`,children:`Security Alerts`}),t.security_alerts.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.alertCard,children:[(0,j.jsxs)(`span`,{className:_n.alertSev,children:[`!`,f(e)]}),(0,j.jsx)(`span`,{children:d(e)}),p(e)&&(0,j.jsxs)(`div`,{className:_n.alertAction,children:[`Action: `,p(e)]})]},t))]}),t.insights&&t.insights.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Insights`}),t.insights.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.insight,children:[`→ `,m(e)]},t))]}),(0,j.jsx)(`div`,{className:_n.regenRow,children:(0,j.jsx)(`button`,{className:_n.regenBtn,onClick:u,disabled:a,children:a?`Regenerating…`:`↺ Regenerate`})})]})}function yn(e){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:e===`sheet`?`📊`:e===`slides`?`📽`:`📄`}function bn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=(e=``)=>{i(!0),O(e?`/api/onedrive?q=${encodeURIComponent(e)}`:`/api/onedrive`).then(e=>{n(e??{files:[]}),i(!1)}).catch(()=>{o(`Could not load OneDrive. Run nha microsoft auth in the terminal to connect.`),i(!1)})};if((0,_.useEffect)(()=>{l()},[]),a)return(0,j.jsx)(`div`,{className:J.error,children:a});let u=t?.files??[],d=t?.quota;return(0,j.jsxs)(`div`,{className:J.root,children:[d&&(0,j.jsxs)(`div`,{className:J.quotaBar,children:[(0,j.jsxs)(`div`,{className:J.quotaText,children:[(0,j.jsxs)(`span`,{className:J.quotaUsed,children:[d.usage,` of `,d.limit,` used`]}),(0,j.jsxs)(`span`,{className:J.quotaPct,children:[d.percentUsed,`%`]})]}),(0,j.jsx)(`div`,{className:J.quotaTrack,children:(0,j.jsx)(`div`,{className:J.quotaFill,style:{width:`${Math.min(d.percentUsed,100)}%`,background:d.percentUsed>90?`var(--red)`:d.percentUsed>70?`var(--amber)`:`var(--cyan)`}})})]}),(0,j.jsxs)(`div`,{className:J.searchRow,children:[(0,j.jsx)(`input`,{className:J.searchInput,value:s,onChange:e=>c(e.target.value),placeholder:`Search OneDrive files…`,onKeyDown:e=>e.key===`Enter`&&l(s)}),(0,j.jsx)(`button`,{className:J.searchBtn,onClick:()=>l(s),children:`Search`})]}),r&&(0,j.jsxs)(`div`,{className:J.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!r&&u.length===0&&(0,j.jsx)(`div`,{className:J.empty,children:e(`drive.noFiles`)}),(0,j.jsx)(`div`,{className:J.fileList,children:u.map(e=>(0,j.jsxs)(`div`,{className:J.fileRow,children:[(0,j.jsx)(`span`,{className:J.fileIcon,children:yn(e.type)}),(0,j.jsxs)(`div`,{className:J.fileInfo,children:[(0,j.jsx)(`div`,{className:J.fileName,children:e.name}),(0,j.jsxs)(`div`,{className:J.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``]})]}),(0,j.jsx)(`div`,{className:J.fileBtns,children:e.webViewLink&&(0,j.jsx)(`a`,{className:J.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,children:`Open`})})]},e.id))})]})}var xn={root:`_root_1vbmp_1`,loading:`_loading_1vbmp_2`,error:`_error_1vbmp_3`,empty:`_empty_1vbmp_4`,addRow:`_addRow_1vbmp_6`,addInput:`_addInput_1vbmp_7`,addBtn:`_addBtn_1vbmp_8`,list:`_list_1vbmp_10`,taskRow:`_taskRow_1vbmp_11`,checkBtn:`_checkBtn_1vbmp_12`,taskInfo:`_taskInfo_1vbmp_14`,taskTitle:`_taskTitle_1vbmp_15`,taskDue:`_taskDue_1vbmp_16`,taskImp:`_taskImp_1vbmp_17`};function Sn(){let e=P(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=()=>{O(`/api/mstodo`).then(e=>{n(e?.tasks??[]),i(!1)}).catch(()=>{o(`Microsoft To Do requires Microsoft authentication. Run nha microsoft auth in the terminal.`),i(!1)})};(0,_.useEffect)(()=>{l()},[]);let u=()=>{let e=s.trim();e&&(c(``),k(`/api/mstodo`,{title:e}).then(e=>{e?.task&&l()}))},d=(e,t)=>{k(`/api/mstodo/${e}/complete`,{listId:t}).then(()=>l())};return r?(0,j.jsxs)(`div`,{className:xn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,j.jsx)(`div`,{className:xn.error,children:a}):(0,j.jsxs)(`div`,{className:xn.root,children:[(0,j.jsxs)(`div`,{className:xn.addRow,children:[(0,j.jsx)(`input`,{className:xn.addInput,value:s,onChange:e=>c(e.target.value),placeholder:`Add a new task…`,onKeyDown:e=>e.key===`Enter`&&u()}),(0,j.jsx)(`button`,{className:xn.addBtn,onClick:u,children:`+ Add`})]}),t.length===0&&(0,j.jsx)(`div`,{className:xn.empty,children:`No active tasks`}),(0,j.jsx)(`div`,{className:xn.list,children:t.map(e=>{let t=e.importance===`high`?`var(--red)`:e.importance===`low`?`var(--dim)`:`var(--amber)`;return(0,j.jsxs)(`div`,{className:xn.taskRow,children:[(0,j.jsx)(`button`,{className:xn.checkBtn,onClick:()=>d(e.id,e.listId)}),(0,j.jsxs)(`div`,{className:xn.taskInfo,children:[(0,j.jsx)(`div`,{className:xn.taskTitle,children:e.title}),e.dueDate&&(0,j.jsxs)(`div`,{className:xn.taskDue,children:[`Due: `,e.dueDate.split(`T`)[0]]})]}),e.importance&&(0,j.jsx)(`span`,{className:xn.taskImp,style:{color:t},children:e.importance})]},e.id)})})]})}var Cn={root:`_root_1ag4s_1`,header:`_header_1ag4s_3`,title:`_title_1ag4s_4`,subtitle:`_subtitle_1ag4s_5`,controls:`_controls_1ag4s_7`,monitorRow:`_monitorRow_1ag4s_8`,label:`_label_1ag4s_9`,monitorBtn:`_monitorBtn_1ag4s_10`,monitorActive:`_monitorActive_1ag4s_11`,captureBtn:`_captureBtn_1ag4s_12`,analyzeSection:`_analyzeSection_1ag4s_15`,sectionTitle:`_sectionTitle_1ag4s_16`,presets:`_presets_1ag4s_17`,preset:`_preset_1ag4s_17`,presetActive:`_presetActive_1ag4s_20`,questionRow:`_questionRow_1ag4s_21`,questionInput:`_questionInput_1ag4s_22`,analyzeBtn:`_analyzeBtn_1ag4s_23`,error:`_error_1ag4s_26`,screenshotContainer:`_screenshotContainer_1ag4s_28`,screenshot:`_screenshot_1ag4s_28`,screenshotMeta:`_screenshotMeta_1ag4s_30`,analysis:`_analysis_1ag4s_32`,analysisTitle:`_analysisTitle_1ag4s_33`,analysisText:`_analysisText_1ag4s_34`,continueInChat:`_continueInChat_1ag4s_35`,history:`_history_1ag4s_37`,historyGrid:`_historyGrid_1ag4s_38`,historyItem:`_historyItem_1ag4s_39`,historyThumb:`_historyThumb_1ag4s_40`,historyMeta:`_historyMeta_1ag4s_41`,historyTs:`_historyTs_1ag4s_42`,historyQ:`_historyQ_1ag4s_43`,historyA:`_historyA_1ag4s_44`},wn=[`Describe exactly what you see on the screen`,`Identify any errors, warnings, or issues visible`,`What application is open and what is the user doing?`,`Summarize the content visible on screen and suggest next actions`,`Read and extract all visible text from the screen`,`Analyze the code visible on screen and identify bugs or improvements`,`What financial data or charts are visible? Summarize key numbers`,`Is there anything sensitive or that should be kept private?`];function Tn(){let e=P(),t=ee(e=>e.setView),n=ee(e=>e.apiBase),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)([]),h=async()=>{i(!0),c(null);try{let e=await k(`/api/screen/capture`,{monitor:d});c(e),(e?.base64||e?.file)&&m(t=>[{ts:new Date().toLocaleTimeString(),question:`Screenshot`,analysis:``,src:e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:`${n}/api/screenshots/${e.file}`},...t.slice(0,9)])}catch(e){c({error:e.message})}i(!1)},g=async()=>{if(l.trim()){o(!0);try{let e=await k(`/api/screen/analyze`,{question:l.trim(),monitor:d});if(c(e),e?.analysis){let t=e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:e.file?`${n}/api/screenshots/${e.file}`:``;m(n=>[{ts:new Date().toLocaleTimeString(),question:l.trim(),analysis:e.analysis??``,src:t},...n.slice(0,9)])}}catch(e){c({error:e.message})}o(!1)}},v=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},y=s?.base64?`data:image/${s.format??`jpeg`};base64,${s.base64}`:s?.file?`${n}/api/screenshots/${s.file}`:null;return(0,j.jsxs)(`div`,{className:Cn.root,children:[(0,j.jsx)(`div`,{className:Cn.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Cn.title,children:`🖥️ Screen Capture`}),(0,j.jsxs)(`div`,{className:Cn.subtitle,children:[e(`screen.capture`),` and analyze your desktop screen with AI vision`]})]})}),(0,j.jsxs)(`div`,{className:Cn.controls,children:[(0,j.jsxs)(`div`,{className:Cn.monitorRow,children:[(0,j.jsx)(`label`,{className:Cn.label,children:`Monitor`}),[1,2,3].map(e=>(0,j.jsxs)(`button`,{className:`${Cn.monitorBtn} ${d===e?Cn.monitorActive:``}`,onClick:()=>f(e),children:[`Monitor `,e]},e))]}),(0,j.jsx)(`button`,{className:Cn.captureBtn,onClick:h,disabled:r||a,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Capturing…`]}):`📷 Capture Screen`})]}),(0,j.jsxs)(`div`,{className:Cn.analyzeSection,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Capture + Analyze`}),(0,j.jsx)(`div`,{className:Cn.presets,children:wn.map(e=>(0,j.jsxs)(`button`,{className:`${Cn.preset} ${l===e?Cn.presetActive:``}`,onClick:()=>u(e),children:[e.slice(0,50),e.length>50?`…`:``]},e))}),(0,j.jsxs)(`div`,{className:Cn.questionRow,children:[(0,j.jsx)(`input`,{className:Cn.questionInput,value:l,onChange:e=>u(e.target.value),placeholder:`Ask something about your screen…`,onKeyDown:e=>e.key===`Enter`&&g()}),(0,j.jsx)(`button`,{className:Cn.analyzeBtn,onClick:g,disabled:!l.trim()||r||a,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Analyzing…`]}):`🔍 Analyze`})]})]}),s?.error&&(0,j.jsx)(`div`,{className:Cn.error,children:s.error}),y&&(0,j.jsxs)(`div`,{className:Cn.screenshotContainer,children:[(0,j.jsx)(`img`,{src:y,className:Cn.screenshot,alt:`Screen capture`}),s?.width&&s?.height&&(0,j.jsxs)(`div`,{className:Cn.screenshotMeta,children:[s.width,` × `,s.height,`px`]})]}),s?.analysis&&(0,j.jsxs)(`div`,{className:Cn.analysis,children:[(0,j.jsx)(`div`,{className:Cn.analysisTitle,children:`AI Analysis`}),(0,j.jsx)(`div`,{className:Cn.analysisText,children:s.analysis}),(0,j.jsx)(`button`,{className:Cn.continueInChat,onClick:()=>v(`I captured my screen. Here's what the AI saw:\n\n${s.analysis}\n\nCan you help me with this?`),children:`Continue in Chat →`})]}),p.length>0&&(0,j.jsxs)(`div`,{className:Cn.history,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Recent Captures`}),(0,j.jsx)(`div`,{className:Cn.historyGrid,children:p.map((e,t)=>(0,j.jsxs)(`div`,{className:Cn.historyItem,children:[e.src&&(0,j.jsx)(`img`,{src:e.src,className:Cn.historyThumb,alt:e.question}),(0,j.jsxs)(`div`,{className:Cn.historyMeta,children:[(0,j.jsx)(`div`,{className:Cn.historyTs,children:e.ts}),(0,j.jsx)(`div`,{className:Cn.historyQ,children:e.question}),e.analysis&&(0,j.jsxs)(`div`,{className:Cn.historyA,children:[e.analysis.slice(0,120),`…`]})]})]},t))})]})]})}var Q={root:`_root_v12qq_1`,header:`_header_v12qq_3`,title:`_title_v12qq_4`,subtitle:`_subtitle_v12qq_5`,section:`_section_v12qq_7`,sectionTitle:`_sectionTitle_v12qq_8`,quickBtns:`_quickBtns_v12qq_10`,quickBtn:`_quickBtn_v12qq_10`,searchRow:`_searchRow_v12qq_14`,searchInput:`_searchInput_v12qq_15`,searchBtn:`_searchBtn_v12qq_16`,modeRow:`_modeRow_v12qq_19`,modeBtn:`_modeBtn_v12qq_20`,modeActive:`_modeActive_v12qq_21`,routeInputs:`_routeInputs_v12qq_23`,inputWrapper:`_inputWrapper_v12qq_24`,inputIcon:`_inputIcon_v12qq_25`,routeInput:`_routeInput_v12qq_23`,swapBtn:`_swapBtn_v12qq_27`,dirBtns:`_dirBtns_v12qq_29`,dirBtn:`_dirBtn_v12qq_29`,openMapsBtn:`_openMapsBtn_v12qq_32`,error:`_error_v12qq_34`,resultCard:`_resultCard_v12qq_36`,routeSummary:`_routeSummary_v12qq_37`,routeDistance:`_routeDistance_v12qq_38`,routeDuration:`_routeDuration_v12qq_39`,routeMode:`_routeMode_v12qq_40`,steps:`_steps_v12qq_41`,step:`_step_v12qq_41`,stepNum:`_stepNum_v12qq_43`,stepText:`_stepText_v12qq_44`,mapLink:`_mapLink_v12qq_45`,askChatBtn:`_askChatBtn_v12qq_47`,savedRoute:`_savedRoute_v12qq_49`,savedFrom:`_savedFrom_v12qq_51`,savedArrow:`_savedArrow_v12qq_52`,savedTo:`_savedTo_v12qq_53`,savedTs:`_savedTs_v12qq_54`},En=[`driving`,`walking`,`bicycling`,`transit`],Dn={driving:`🚗`,walking:`🚶`,bicycling:`🚲`,transit:`🚌`},On=[{label:`🏥 Nearest Hospital`,query:`nearest hospital`},{label:`⛽ Gas Station`,query:`gas station near me`},{label:`🛒 Supermarket`,query:`supermarket near me`},{label:`☕ Coffee Shop`,query:`coffee shop near me`},{label:`🏧 ATM`,query:`ATM near me`},{label:`🍕 Pizza`,query:`pizza restaurant near me`}];function kn(e,t,n){try{let r=JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`),i=[{from:e,to:t,label:n,ts:new Date().toISOString()},...r.filter(n=>!(n.from===e&&n.to===t))].slice(0,10);localStorage.setItem(`nha_maps_routes`,JSON.stringify(i))}catch{}}function An(){try{return JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`)}catch{return[]}}function jn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(`driving`),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(An),[m,h]=(0,_.useState)(``),g=async()=>{if(!(!n.trim()||!i.trim())){l(!0),d(null);try{let e=await O(`/api/maps/directions?from=${encodeURIComponent(n.trim())}&to=${encodeURIComponent(i.trim())}&mode=${o}`);e&&(d(e),e.error||(kn(n.trim(),i.trim()),p(An())))}catch{d({url:`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`}),kn(n.trim(),i.trim()),p(An())}l(!1)}},v=e=>{let t=`https://www.google.com/maps/search/${encodeURIComponent(e)}`;window.open(t,`_blank`)},y=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},b=e=>{r(e.from),a(e.to)},x=n.trim()&&i.trim()?`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`:null;return(0,j.jsxs)(`div`,{className:Q.root,children:[(0,j.jsx)(`div`,{className:Q.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Q.title,children:`🗺️ Maps & Directions`}),(0,j.jsx)(`div`,{className:Q.subtitle,children:e(`maps.directions`)})]})}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:e(`common.search`)}),(0,j.jsx)(`div`,{className:Q.quickBtns,children:On.map(e=>(0,j.jsx)(`button`,{className:Q.quickBtn,onClick:()=>v(e.query),children:e.label},e.label))}),(0,j.jsxs)(`div`,{className:Q.searchRow,children:[(0,j.jsx)(`input`,{className:Q.searchInput,value:m,onChange:e=>h(e.target.value),placeholder:`Search for a place, address, or business…`,onKeyDown:e=>e.key===`Enter`&&v(m)}),(0,j.jsx)(`button`,{className:Q.searchBtn,onClick:()=>v(m),disabled:!m.trim(),children:`Search ↗`})]})]}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Directions`}),(0,j.jsx)(`div`,{className:Q.modeRow,children:En.map(e=>(0,j.jsxs)(`button`,{className:`${Q.modeBtn} ${o===e?Q.modeActive:``}`,onClick:()=>s(e),title:e,children:[Dn[e],` `,e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,j.jsxs)(`div`,{className:Q.routeInputs,children:[(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`A`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:n,onChange:e=>r(e.target.value),placeholder:`From (address, city, or 'my location')`,onKeyDown:e=>e.key===`Enter`&&g()})]}),(0,j.jsx)(`button`,{className:Q.swapBtn,onClick:()=>{r(i),a(n)},title:`Swap`,children:`⇅`}),(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`B`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:i,onChange:e=>a(e.target.value),placeholder:`To (address, city, or landmark)`,onKeyDown:e=>e.key===`Enter`&&g()})]})]}),(0,j.jsxs)(`div`,{className:Q.dirBtns,children:[(0,j.jsx)(`button`,{className:Q.dirBtn,onClick:g,disabled:c||!n.trim()||!i.trim(),children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Getting route…`]}):`🗺️ Get Directions`}),x&&(0,j.jsx)(`a`,{className:Q.openMapsBtn,href:x,target:`_blank`,rel:`noreferrer`,children:`Open in Google Maps ↗`})]})]}),u?.error&&(0,j.jsx)(`div`,{className:Q.error,children:u.error}),u&&!u.error&&(0,j.jsxs)(`div`,{className:Q.resultCard,children:[(u.distance||u.duration)&&(0,j.jsxs)(`div`,{className:Q.routeSummary,children:[u.distance&&(0,j.jsxs)(`span`,{className:Q.routeDistance,children:[`📏 `,u.distance]}),u.duration&&(0,j.jsxs)(`span`,{className:Q.routeDuration,children:[`⏱ `,u.duration]}),(0,j.jsxs)(`span`,{className:Q.routeMode,children:[Dn[o],` `,o]})]}),u.steps&&u.steps.length>0&&(0,j.jsx)(`div`,{className:Q.steps,children:u.steps.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.step,children:[(0,j.jsx)(`span`,{className:Q.stepNum,children:t+1}),(0,j.jsx)(`span`,{className:Q.stepText,children:e})]},t))}),u.url&&(0,j.jsx)(`a`,{className:Q.mapLink,href:u.url,target:`_blank`,rel:`noreferrer`,children:`View full route on Google Maps ↗`}),(0,j.jsx)(`button`,{className:Q.askChatBtn,onClick:()=>y(`Give me directions from "${n}" to "${i}" by ${o}. Include estimated time, distance, and any traffic alerts or alternative routes.`),children:`Ask AI for detailed route advice →`})]}),f.length>0&&(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Recent Routes`}),f.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.savedRoute,onClick:()=>b(e),children:[(0,j.jsx)(`span`,{className:Q.savedFrom,children:e.from}),(0,j.jsx)(`span`,{className:Q.savedArrow,children:`→`}),(0,j.jsx)(`span`,{className:Q.savedTo,children:e.to}),(0,j.jsx)(`span`,{className:Q.savedTs,children:new Date(e.ts).toLocaleDateString()})]},t))]})]})}var $={root:`_root_esnjz_1`,header:`_header_esnjz_3`,title:`_title_esnjz_4`,subtitle:`_subtitle_esnjz_5`,addBtn:`_addBtn_esnjz_6`,quickAdd:`_quickAdd_esnjz_8`,quickLabel:`_quickLabel_esnjz_9`,quickPresets:`_quickPresets_esnjz_10`,quickPreset:`_quickPreset_esnjz_10`,section:`_section_esnjz_14`,sectionTitle:`_sectionTitle_esnjz_15`,loading:`_loading_esnjz_17`,empty:`_empty_esnjz_18`,card:`_card_esnjz_20`,cardPast:`_cardPast_esnjz_21`,cardLeft:`_cardLeft_esnjz_22`,reminderMsg:`_reminderMsg_esnjz_23`,reminderTime:`_reminderTime_esnjz_24`,timeBadge:`_timeBadge_esnjz_25`,countdown:`_countdown_esnjz_26`,timePast:`_timePast_esnjz_27`,sentBadge:`_sentBadge_esnjz_28`,cancelledBadge:`_cancelledBadge_esnjz_29`,cancelBtn:`_cancelBtn_esnjz_30`,repeatBtn:`_repeatBtn_esnjz_31`,aiButtons:`_aiButtons_esnjz_33`,aiBtn:`_aiBtn_esnjz_34`,overlay:`_overlay_esnjz_38`,modal:`_modal_esnjz_39`,modalTitle:`_modalTitle_esnjz_40`,label:`_label_esnjz_41`,input:`_input_esnjz_42`,msgTemplates:`_msgTemplates_esnjz_44`,msgTemplate:`_msgTemplate_esnjz_44`,msgTemplateActive:`_msgTemplateActive_esnjz_47`,typeTabs:`_typeTabs_esnjz_49`,typeTab:`_typeTab_esnjz_49`,typeTabActive:`_typeTabActive_esnjz_51`,relRow:`_relRow_esnjz_53`,inLabel:`_inLabel_esnjz_54`,relInput:`_relInput_esnjz_55`,relSelect:`_relSelect_esnjz_56`,formErr:`_formErr_esnjz_58`,formOk:`_formOk_esnjz_59`,modalBtns:`_modalBtns_esnjz_60`,cancelModalBtn:`_cancelModalBtn_esnjz_61`,saveBtn:`_saveBtn_esnjz_62`},Mn=[{label:`In 5 min`,value:`in 5 minutes`},{label:`In 15 min`,value:`in 15 minutes`},{label:`In 30 min`,value:`in 30 minutes`},{label:`In 1 hour`,value:`in 1 hour`},{label:`In 2 hours`,value:`in 2 hours`},{label:`In 3 hours`,value:`in 3 hours`},{label:`Tomorrow 9am`,value:`tomorrow at 09:00`},{label:`Tomorrow noon`,value:`tomorrow at 12:00`}],Nn=[`Take a break and stretch`,`Check emails`,`Join the standup call`,`Review and respond to messages`,`Take your medication`,`Drink water`,`Focus review — what did you accomplish in the last hour?`,`Follow up on pending tasks`,`End of work day — log your achievements`,`Weekly review — prepare for next week`];function Pn(e){if(e<1)return`now`;if(e<60)return`in ${e}m`;let t=Math.floor(e/60),n=e%60;return n>0?`in ${t}h ${n}m`:`in ${t}h`}function Fn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)({message:``,atTime:``,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`}),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!1),g=()=>{a(!0),O(`/api/reminders`).then(e=>{r(e?.reminders??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{g()},[]);let v=async()=>{if(!o.message.trim()){d(`Message is required`);return}let e=``;if(o.atTimeType===`relative`)e=`in ${o.relValue} ${o.relUnit}`;else{if(!o.atTime){d(`Time is required`);return}e=o.atTime}l(!0),d(``);try{await k(`/api/reminders`,{message:o.message.trim(),atTime:e}),p(`Reminder set!`),setTimeout(()=>{p(``),h(!1)},1500),g()}catch(e){d(e.message??`Failed to set reminder`)}l(!1)},y=e=>{confirm(`Cancel this reminder?`)&&k(`/api/reminders/cancel`,{id:e}).then(g)},b=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},x=n.filter(e=>e.status===`pending`),S=n.filter(e=>e.status!==`pending`);return(0,j.jsxs)(`div`,{className:$.root,children:[(0,j.jsxs)(`div`,{className:$.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:$.title,children:`🔔 Reminders`}),(0,j.jsx)(`div`,{className:$.subtitle,children:`Set one-time notifications via the NHA daemon`})]}),(0,j.jsx)(`button`,{className:$.addBtn,onClick:()=>{h(!0),d(``),p(``)},children:`+ New Reminder`})]}),(0,j.jsxs)(`div`,{className:$.quickAdd,children:[(0,j.jsx)(`div`,{className:$.quickLabel,children:`Quick reminder for now:`}),(0,j.jsx)(`div`,{className:$.quickPresets,children:Mn.map(e=>(0,j.jsx)(`button`,{className:$.quickPreset,onClick:()=>{s(e=>({...e,atTimeType:`relative`,atTime:``,message:e.message||`Reminder`})),h(!0),d(``),p(``)},children:e.label},e.value))})]}),i&&(0,j.jsxs)(`div`,{className:$.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!i&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Pending (`,x.length,`)`]}),x.length===0&&(0,j.jsx)(`div`,{className:$.empty,children:`No pending reminders. Set one to get notified.`}),x.map(e=>(0,j.jsxs)(`div`,{className:$.card,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:$.timeBadge,children:new Date(e.atTime).toLocaleString()}),e.minutesUntil!==void 0&&(0,j.jsx)(`span`,{className:$.countdown,children:Pn(e.minutesUntil)})]})]}),(0,j.jsx)(`button`,{className:$.cancelBtn,onClick:()=>y(e.id),children:`Cancel`})]},e.id))]}),S.length>0&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Recent (`,S.length,`)`]}),S.slice(0,10).map(e=>(0,j.jsxs)(`div`,{className:`${$.card} ${$.cardPast}`,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:e.status===`sent`?$.sentBadge:$.cancelledBadge,children:e.status}),(0,j.jsx)(`span`,{className:$.timePast,children:new Date(e.atTime).toLocaleString()})]})]}),(0,j.jsx)(`button`,{className:$.repeatBtn,onClick:()=>{s(t=>({...t,message:e.message,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`})),h(!0)},children:`Repeat`})]},e.id))]}),(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsx)(`div`,{className:$.sectionTitle,children:`AI-Powered Reminders`}),(0,j.jsxs)(`div`,{className:$.aiButtons,children:[(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder to check my emails in 30 minutes`),children:`📧 Email check in 30min`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder every hour to take a break and drink water`),children:`💧 Hourly water break`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder at the end of the work day (6pm) to do an evening review of my tasks and prepare tomorrow's plan`),children:`🌆 Evening review 6pm`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Look at my calendar and set reminders for all events today`),children:`📅 Remind me of today's events`})]})]}),m&&(0,j.jsx)(`div`,{className:$.overlay,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,j.jsxs)(`div`,{className:$.modal,children:[(0,j.jsx)(`div`,{className:$.modalTitle,children:e(`reminders.new`)}),(0,j.jsx)(`div`,{className:$.label,children:`Message *`}),(0,j.jsx)(`div`,{className:$.msgTemplates,children:Nn.map(e=>(0,j.jsx)(`button`,{className:`${$.msgTemplate} ${o.message===e?$.msgTemplateActive:``}`,onClick:()=>s(t=>({...t,message:e})),children:e},e))}),(0,j.jsx)(`input`,{className:$.input,value:o.message,onChange:e=>s(t=>({...t,message:e.target.value})),placeholder:`Reminder message (e.g. Call John)`}),(0,j.jsx)(`div`,{className:$.label,children:`When *`}),(0,j.jsxs)(`div`,{className:$.typeTabs,children:[(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`relative`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`relative`})),children:`Relative`}),(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`absolute`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`absolute`})),children:`Exact time`})]}),o.atTimeType===`relative`?(0,j.jsxs)(`div`,{className:$.relRow,children:[(0,j.jsx)(`span`,{className:$.inLabel,children:`in`}),(0,j.jsx)(`input`,{className:$.relInput,type:`number`,min:`1`,value:o.relValue,onChange:e=>s(t=>({...t,relValue:e.target.value}))}),(0,j.jsxs)(`select`,{className:$.relSelect,value:o.relUnit,onChange:e=>s(t=>({...t,relUnit:e.target.value})),children:[(0,j.jsx)(`option`,{value:`minutes`,children:`minutes`}),(0,j.jsx)(`option`,{value:`hours`,children:`hours`}),(0,j.jsx)(`option`,{value:`days`,children:`days`})]})]}):(0,j.jsx)(`input`,{className:$.input,type:`datetime-local`,value:o.atTime,onChange:e=>s(t=>({...t,atTime:e.target.value}))}),u&&(0,j.jsx)(`div`,{className:$.formErr,children:u}),f&&(0,j.jsx)(`div`,{className:$.formOk,children:f}),(0,j.jsxs)(`div`,{className:$.modalBtns,children:[(0,j.jsx)(`button`,{className:$.cancelModalBtn,onClick:()=>h(!1),children:`Cancel`}),(0,j.jsx)(`button`,{className:$.saveBtn,onClick:v,disabled:c,children:c?`Setting…`:`🔔 Set Reminder`})]})]})})]})}var In={root:`_root_atgeb_1`,icon:`_icon_atgeb_10`,title:`_title_atgeb_11`,sub:`_sub_atgeb_12`},Ln={dashboard:`⚡`,email:`📧`,calendar:`📅`,tasks:`✅`,contacts:`👤`,notes:`📝`,drive:`💾`,onedrive:`☁️`,mstodo:`📋`,github:`🐙`,slack:`💬`,notion:`📋`,collab:`🏛️`,maps:`🗺️`,cron:`⏰`,screen:`🖥️`,reminders:`🔔`,birthdays:`🎂`,settings:`⚙️`,agents:`🤖`,plan:`🗓️`,webcraft:`🔨`,connectors:`🔗`};function Rn({view:e}){let t=P();return(0,j.jsxs)(`div`,{className:In.root,children:[(0,j.jsx)(`div`,{className:In.icon,children:Ln[e]??`🔧`}),(0,j.jsx)(`div`,{className:In.title,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,j.jsx)(`div`,{className:In.sub,children:t(`common.comingSoon`)})]})}function zn(){let{activeView:e}=ee();switch(e){case`dashboard`:return(0,j.jsx)(mt,{});case`chat`:return(0,j.jsx)(Ce,{});case`studio`:return(0,j.jsx)(lt,{});case`email`:return(0,j.jsx)(Ht,{});case`calendar`:return(0,j.jsx)(Kt,{});case`tasks`:return(0,j.jsx)(gt,{});case`notes`:return(0,j.jsx)(Dt,{});case`contacts`:return(0,j.jsx)(At,{});case`birthdays`:return(0,j.jsx)(xt,{});case`cron`:return(0,j.jsx)(Tt,{});case`connectors`:return(0,j.jsx)(Lt,{});case`agents`:return(0,j.jsx)(Xt,{});case`drive`:return(0,j.jsx)($t,{});case`onedrive`:return(0,j.jsx)(bn,{});case`mstodo`:return(0,j.jsx)(Sn,{});case`github`:return(0,j.jsx)(en,{});case`slack`:return(0,j.jsx)(nn,{});case`notion`:return(0,j.jsx)(rn,{});case`collab`:return(0,j.jsx)(sn,{});case`webcraft`:return(0,j.jsx)(mn,{});case`plan`:return(0,j.jsx)(vn,{});case`screen`:return(0,j.jsx)(Tn,{});case`maps`:return(0,j.jsx)(jn,{});case`reminders`:return(0,j.jsx)(Fn,{});case`settings`:return(0,j.jsx)(yt,{});default:return(0,j.jsx)(Rn,{view:e})}}(0,v.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(_.StrictMode,{children:(0,j.jsx)(de,{children:(0,j.jsx)(zn,{})})}));
|