@geminilight/mindos 0.6.84 → 0.6.85
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/_standalone/.mindos-build-version +1 -1
- package/_standalone/.next/BUILD_ID +1 -1
- package/_standalone/.next/app-path-routes-manifest.json +30 -30
- package/_standalone/.next/build-manifest.json +3 -3
- package/_standalone/.next/cache/.previewinfo +1 -1
- package/_standalone/.next/cache/.rscinfo +1 -1
- package/_standalone/.next/cache/config.json +3 -3
- package/_standalone/.next/prerender-manifest.json +3 -3
- package/_standalone/.next/react-loadable-manifest.json +4 -4
- package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error.html +2 -2
- package/_standalone/.next/server/app/_global-error.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/_standalone/.next/server/app/_not-found/page.js +1 -1
- package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/page.js +1 -1
- package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/channels/verify/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/connect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/embedding/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/export/route.js +3 -3
- package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-docx/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/feishu/long-connection/event/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/feishu/long-connection/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/test/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/webhook/feishu/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/im/webhook-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/clip/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/lint/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/direct-tools/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/obsidian/compat-report/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/obsidian/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/prewarm/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/space-overview/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/capture/history/page.js +1 -1
- package/_standalone/.next/server/app/capture/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/capture/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/capture/page.js +1 -1
- package/_standalone/.next/server/app/capture/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/capture/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changelog/page.js +1 -1
- package/_standalone/.next/server/app/changelog/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changes/page.js +1 -1
- package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/page.js +1 -1
- package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/explore/page.js +1 -1
- package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/help/page.js +1 -1
- package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/login/page.js +1 -1
- package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/page.js +1 -1
- package/_standalone/.next/server/app/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/setup/page.js +1 -1
- package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/todo/page.js +1 -1
- package/_standalone/.next/server/app/todo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/todo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/trash/page.js +3 -3
- package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/view/[...path]/page.js +3 -3
- package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app-paths-manifest.json +30 -30
- package/_standalone/.next/server/chunks/{2627.js → 1586.js} +2 -2
- package/_standalone/.next/server/chunks/4802.js +38 -38
- package/_standalone/.next/server/chunks/5299.js +1 -1
- package/_standalone/.next/server/chunks/7662.js +1 -1
- package/_standalone/.next/server/middleware-build-manifest.js +1 -1
- package/_standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/_standalone/.next/server/pages/500.html +2 -2
- package/_standalone/.next/server/server-reference-manifest.js +1 -1
- package/_standalone/.next/server/server-reference-manifest.json +1 -1
- package/_standalone/.next/static/chunks/{1342.4bd0d20f40451413.js → 2526.4a52f68381daef1c.js} +1 -1
- package/_standalone/.next/static/chunks/{6610.e3f7e67446986f89.js → 4681.9a9ec0cb980a002c.js} +2 -2
- package/_standalone/.next/static/chunks/app/{layout-380937d052bb640a.js → layout-ac020edf8aa04aff.js} +67 -67
- package/_standalone/.next/static/chunks/app/trash/page-60906ec826711c03.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/{page-bef57e345dbc7651.js → page-477520eb2231c4dc.js} +2 -2
- package/_standalone/.next/static/chunks/webpack-6c55b0c23f6d2613.js +1 -0
- package/_standalone/.next/trace +97 -97
- package/_standalone/package-lock.json +2 -2
- package/_standalone/package.json +1 -1
- package/app/package.json +1 -1
- package/package.json +1 -1
- package/_standalone/.next/static/chunks/app/trash/page-11cd48ee112e796e.js +0 -1
- package/_standalone/.next/static/chunks/webpack-0a8a73106e24277b.js +0 -1
- /package/_standalone/.next/static/{tww86CooFgPgVHt4LWAxa → zA0rZ81KRNjqF86S3DK0b}/_buildManifest.js +0 -0
- /package/_standalone/.next/static/{tww86CooFgPgVHt4LWAxa → zA0rZ81KRNjqF86S3DK0b}/_ssgManifest.js +0 -0
|
@@ -8,16 +8,7 @@ ${t}`:e})}finally{w(!1),setTimeout(()=>C(null),3e3)}},T=async()=>{if(!i)return;N
|
|
|
8
8
|
1. "${t}/README.md" — write purpose, structure overview, usage guidelines
|
|
9
9
|
2. "${t}/INSTRUCTION.md" — write rules for AI agents operating in this space
|
|
10
10
|
|
|
11
|
-
Keep content concise and actionable. Write files directly using tools.`;window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spaceName:e,spacePath:t,description:r,state:"working"}})),fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:s}],currentFile:t+"/INSTRUCTION.md"})}).then(async e=>{if(!e.ok||!e.body)throw Error(`HTTP ${e.status}`);let r=e.body.getReader();try{for(;;){let{done:e}=await r.read();if(e)break}}finally{r.releaseLock()}window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"done"}})),window.dispatchEvent(new Event("mindos:files-changed"))}).catch(()=>{window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"error"}}))})}},10377:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h});var s=r(12115);let n="mindos-pinned-files",a="mindos:pins-changed";function i(){try{let e=localStorage.getItem(n);return e?JSON.parse(e):[]}catch{return[]}}function o(){return c}let l=[];function d(){return l}let c=[],u=!1;function m(){u||(c=i(),u=!0)}function x(e){m();let t=t=>{t.key===n&&(c=i(),e())},r=()=>{c=i(),e()};return window.addEventListener("storage",t),window.addEventListener(a,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(a,r)}}function p(e){c=e;try{localStorage.setItem(n,JSON.stringify(e))}catch{}window.dispatchEvent(new Event(a))}function h(){m();let e=(0,s.useSyncExternalStore)(x,o,d),t=(0,s.useCallback)(t=>e.includes(t),[e]),r=(0,s.useCallback)(e=>{let t=i(),r=t.indexOf(e);r>=0?t.splice(r,1):t.unshift(e),p(t)},[]);return{pinnedFiles:e,isPinned:t,togglePin:r,reorderPins:(0,s.useCallback)(e=>{p(e)},[]),removePin:(0,s.useCallback)(e=>{p(i().filter(t=>t!==e))},[])}}},12413:(e,t,r)=>{"use strict";r.d(t,{P:()=>s,u:()=>n});let s=[{id:"telegram",name:"Telegram",icon:"\uD83D\uDCF1",guide:"1. Open Telegram → search @BotFather\n2. Send /newbot → follow prompts\n3. Copy the token below",purpose:"Receive MindOS notifications and quick updates in Telegram.",purposeZh:"通过 Telegram 接收 MindOS 的通知和快速更新。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. chat ID like 123456789 or -1001234567890",recipientExampleZh:"例如 123456789 或 -1001234567890 这样的 chat ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456789:AABBccDD-EeFfGgHh...",hint:"Format: number:alphanumeric"}]},{id:"feishu",name:"Feishu",icon:"\uD83D\uDC26",guide:"1. open.feishu.cn → Create App\n2. Credentials page → copy App ID & Secret\n3. Enable Bot capability + add permissions",guideUrl:"https://open.feishu.cn/",editHint:"Need to update credentials? Edit and save below — MindOS will reconnect automatically.",purpose:"Receive MindOS results in Feishu, or let users message the bot directly when conversations are enabled.",purposeZh:"通过飞书接收 MindOS 的结果;开启对话后,也可以让用户直接在飞书里给机器人发消息。",useCases:["Agent completion alerts","Error notifications","Test messages","Direct bot conversations in Feishu"],useCasesZh:["Agent 完成提醒","错误通知","测试消息","在飞书里直接与机器人对话"],recipientExample:"e.g. ou_xxx, oc_xxx, or a work email",recipientExampleZh:"例如 ou_xxx、oc_xxx,或企业邮箱",fields:[{key:"app_id",label:"App ID",placeholder:"CLI_XXXXXXXXXXXXXXXXX",hint:"From Credentials page on open.feishu.cn"},{key:"app_secret",label:"App Secret",placeholder:"XXXXXXXXXXXXXXXXXXXXXXXX",hint:"Keep this secret — do not share"}]},{id:"discord",name:"Discord",icon:"\uD83D\uDCAC",guide:"1. discord.com/developers → New Application\n2. Bot tab → Reset Token → copy\n3. Enable Message Content Intent",purpose:"Send MindOS updates into Discord channels and DMs.",purposeZh:"把 MindOS 的更新发送到 Discord 频道或私信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. Discord channel or user ID",recipientExampleZh:"例如 Discord 频道 ID 或用户 ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"MTIxNzM..."}]},{id:"slack",name:"Slack",icon:"\uD83D\uDCBC",guide:"1. api.slack.com/apps → Create New App\n2. OAuth & Permissions → add chat:write scope\n3. Install to Workspace → copy Bot Token",purpose:"Route MindOS notifications into Slack channels and direct messages.",purposeZh:"把 MindOS 的通知发送到 Slack 频道或私信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. Slack channel or user ID like C123... or U123...",recipientExampleZh:"例如 Slack 频道 ID 或用户 ID(如 C123... / U123...)",fields:[{key:"bot_token",label:"Bot Token",placeholder:"xoxb-xxxx-xxxx-xxxx",hint:"Starts with xoxb-"}]},{id:"wecom",name:"WeCom",icon:"\uD83C\uDFE2",guide:"1. Group chat → Add Robot → Custom\n2. Copy Webhook URL\n3. Extract the key parameter from URL",purpose:"Deliver MindOS notifications into WeCom group chats.",purposeZh:"把 MindOS 通知投递到企业微信群聊。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use your configured robot or WeCom target",recipientExampleZh:"使用你配置好的机器人或企业微信目标",fields:[{key:"webhook_key",label:"Webhook Key",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",hint:"The key= value from webhook URL"}]},{id:"dingtalk",name:"DingTalk",icon:"\uD83D\uDD14",guide:"1. Group → Settings → Smart Assistant → Add Robot\n2. Select Custom (Webhook)\n3. Copy the full Webhook URL",purpose:"Push MindOS notifications into DingTalk groups.",purposeZh:"把 MindOS 通知发送到钉钉群。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use your configured DingTalk robot target",recipientExampleZh:"使用你配置好的钉钉机器人目标",fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",hint:"Full URL including access_token"}]},{id:"wechat",name:"WeChat",icon:"\uD83D\uDC9A",guide:"1. Visit ilinkai.weixin.qq.com\n2. Register & create a bot application\n3. QR login in the console → copy Bot Token from dashboard",purpose:"Send MindOS updates to WeChat via your configured bot.",purposeZh:"通过你配置好的机器人把 MindOS 更新发送到微信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use the WeChat user or chat ID supported by your bot",recipientExampleZh:"使用你的机器人支持的微信用户或群聊 ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"wx_xxxxxxxxxxxxxxxx",hint:"From iLink Bot console after QR login"}]},{id:"qq",name:"QQ",icon:"\uD83D\uDC27",guide:"1. q.qq.com → Create Bot\n2. Development tab → copy App ID & Secret\n3. Add group/C2C intents as needed",purpose:"Deliver MindOS notifications through QQ bot channels.",purposeZh:"通过 QQ 机器人频道接收 MindOS 通知。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use the QQ openid or group_openid for your target",recipientExampleZh:"使用目标 QQ 的 openid 或 group_openid",fields:[{key:"app_id",label:"App ID",placeholder:"102xxxxxx"},{key:"app_secret",label:"App Secret",placeholder:"xxxxxxxxxxxxxxxxxxxxxxxx"}]}];function n(e){return s.find(t=>t.id===e)}},14446:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AudioRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"audio",a=r.split(".").pop()?.toLowerCase()??"",[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let m=(0,n.useCallback)(()=>{o(!1),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full flex flex-col items-center gap-6 py-12 px-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[(0,s.jsx)("span",{className:"text-4xl opacity-40",children:"\uD83C\uDFB5"}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"uppercase opacity-60",children:a}),null!==c&&(0,s.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`})]})]})]}),i?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load audio"}),(0,s.jsx)("button",{onClick:m,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}):(0,s.jsx)("audio",{controls:!0,preload:"metadata",className:"w-full max-w-lg",onError:()=>o(!0),children:(0,s.jsx)("source",{src:t})},l)]})}},16518:(e,t,r)=>{"use strict";r.d(t,{AI:()=>n,RS:()=>s});let s=["imprint","growth","self"],n={imprint:"/echo/imprint",growth:"/echo/growth",self:"/echo/self"}},18847:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AgentInspectorRenderer:()=>j});var s=r(95155),n=r(12115),a=r(73321),i=r(84980),o=r(3926),l=r(93631),d=r(68459),c=r(61878),u=r(10762),m=r(12651),x=r(13545),p=r(66088);function h(e){return/read|list|get|search/.test(e)?/search/.test(e)?"search":"read":/create/.test(e)?"create":/delete/.test(e)?"delete":/write|update|insert|append/.test(e)?"write":"other"}let f={read:{bg:"rgba(138,180,216,0.10)",text:"var(--tool-read)",border:"rgba(138,180,216,0.25)"},write:{bg:"rgba(200,135,58,0.10)",text:"var(--amber)",border:"rgba(200,135,58,0.25)"},create:{bg:"rgba(122,173,128,0.10)",text:"var(--success)",border:"rgba(122,173,128,0.25)"},delete:{bg:"rgba(200,80,80,0.10)",text:"var(--error)",border:"rgba(200,80,80,0.25)"},search:{bg:"rgba(200,160,216,0.10)",text:"var(--tool-search)",border:"rgba(200,160,216,0.25)"},other:{bg:"var(--muted)",text:"var(--muted-foreground)",border:"var(--border)"}};function g({kind:e,size:t=13}){return"read"===e?(0,s.jsx)(i.A,{size:t}):"write"===e?(0,s.jsx)(o.A,{size:t}):"create"===e?(0,s.jsx)(l.A,{size:t}):"delete"===e?(0,s.jsx)(d.A,{size:t}):"search"===e?(0,s.jsx)(c.A,{size:t}):(0,s.jsx)(u.A,{size:t})}function b(e){try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}}function v({op:e}){var t,r;let i,o,l,d,c=(0,a.useRouter)(),[u,v]=(0,n.useState)(!1),y=h(e.tool),j=f[y],w="string"==typeof(t=e.params).path?t.path:null,k=e.tool.replace("mindos_","");return(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",marginBottom:8},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",cursor:"pointer",userSelect:"none"},onClick:()=>v(e=>!e),children:[(0,s.jsxs)("span",{className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:999,fontSize:"0.68rem",fontWeight:600,background:j.bg,color:j.text,border:`1px solid ${j.border}`,flexShrink:0},children:[(0,s.jsx)(g,{kind:y,size:10}),y]}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.78rem",color:"var(--foreground)",fontWeight:600,flexShrink:0},children:k}),w&&(0,s.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--amber)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},onClick:e=>{e.stopPropagation(),c.push("/view/"+w.split("/").map(encodeURIComponent).join("/"))},title:w,className:"font-display",children:w}),(0,s.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.agentName&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.62rem",fontWeight:500,padding:"1px 6px",borderRadius:999,background:"var(--muted)",color:"var(--muted-foreground)",whiteSpace:"nowrap",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},title:e.agentName,children:e.agentName.length>30?e.agentName.slice(0,30)+"...":e.agentName}),"ok"===e.result?(0,s.jsx)(m.A,{size:13,style:{color:"var(--success)"}}):(0,s.jsx)(x.A,{size:13,style:{color:"var(--error)"}}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6},title:b(e.ts),children:(r=e.ts,o=Math.floor((i=Date.now()-new Date(r).getTime())/6e4),l=Math.floor(i/36e5),d=Math.floor(i/864e5),o<1?"just now":o<60?`${o}m ago`:l<24?`${l}h ago`:`${d}d ago`)}),(0,s.jsx)(p.A,{size:12,style:{color:"var(--muted-foreground)",transform:u?"rotate(180deg)":"none",transition:"transform .15s"}})]})]}),u&&(0,s.jsxs)("div",{style:{borderTop:"1px solid var(--border)",padding:"10px 14px",background:"var(--background)"},children:[(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8*!!e.message},children:Object.entries(e.params).map(([e,t])=>(0,s.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0,minWidth:80},children:e}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--foreground)",wordBreak:"break-all",lineHeight:1.5},children:function(e,t=120){let r="string"==typeof e?e:JSON.stringify(e);return r.length>t?r.slice(0,t)+"…":r}(t)})]},e))}),e.message&&(0,s.jsx)("div",{className:"font-display",style:{marginTop:6,padding:"5px 9px",borderRadius:5,fontSize:"0.72rem",background:"error"===e.result?"rgba(200,80,80,0.08)":"rgba(122,173,128,0.08)",color:"error"===e.result?"var(--error)":"var(--success)",border:`1px solid ${"error"===e.result?"rgba(200,80,80,0.2)":"rgba(122,173,128,0.2)"}`},children:e.message}),e.agentName&&(0,s.jsxs)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.68rem",color:"var(--muted-foreground)"},children:["Agent: ",(0,s.jsx)("span",{style:{color:"var(--foreground)",fontWeight:500},children:e.agentName})]}),(0,s.jsx)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.65rem",color:"var(--muted-foreground)",opacity:.5},children:b(e.ts)})]})]})}let y=["all","write","create","delete","read","search"];function j({content:e}){let[t,r]=(0,n.useState)("all"),a=(0,n.useMemo)(()=>(function(e){try{let t=JSON.parse(e);if(Array.isArray(t.events))return t.events.filter(e=>!!e?.tool&&!!e?.ts).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())}catch{}return(function(e){let t=[];for(let r of e.split("\n")){let e=r.trim();if(!(!e||e.startsWith("#")||e.startsWith("//")))try{let r=JSON.parse(e);r.tool&&r.ts&&t.push(r)}catch{}}return t})(e).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())})(e),[e]),i=(0,n.useMemo)(()=>"all"===t?a:a.filter(e=>h(e.tool)===t),[a,t]),o=(0,n.useMemo)(()=>{let e={all:a.length};for(let t of a){let r=h(t.tool);e[r]=(e[r]??0)+1}return e},[a]);return 0===a.length?(0,s.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:12},children:[(0,s.jsx)(u.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,s.jsx)("p",{children:"No agent operations logged yet."}),(0,s.jsxs)("p",{style:{marginTop:6,opacity:.6,fontSize:11},children:["Agent writes appear here from ",(0,s.jsx)("code",{style:{background:"var(--muted)",padding:"1px 5px",borderRadius:4},children:".mindos/agent-audit-log.json"}),"."]})]}):(0,s.jsxs)("div",{style:{maxWidth:760,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:"1.2rem",flexWrap:"wrap"},children:y.map(e=>{let n=o[e]??0;if("all"!==e&&!n)return null;let a="all"!==e?f[e]:void 0,i=t===e;return(0,s.jsxs)("button",{onClick:()=>r(e),className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:999,fontSize:"0.7rem",cursor:"pointer",border:"none",background:i?a?.bg??"var(--accent)":"var(--muted)",color:i?a?.text??"var(--foreground)":"var(--muted-foreground)",outline:i?`1px solid ${a?.border??"var(--border)"}`:"none",transition:"all .1s"},children:["all"!==e&&(0,s.jsx)(g,{kind:e,size:10}),e," ",(0,s.jsxs)("span",{style:{opacity:.6},children:["(",n,")"]})]},e)})}),(0,s.jsx)("div",{children:i.map((e,t)=>(0,s.jsx)(v,{op:e},t))})]})}},19550:(e,t,r)=>{"use strict";r.d(t,{G:()=>S});var s=r(95155),n=r(12115),a=r(37386),i=r(85960),o=r(35176),l=r(59934),d=r(45362),c=r(82022),u=r(98758),m=r(91337),x=r(6539);let p=(0,r(18460).F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function h({className:e,variant:t="default",size:r="default",...n}){return(0,s.jsx)(x.$,{"data-slot":"button",className:(0,m.cn)(p({variant:t,size:r,className:e})),...n})}var f=r(33210);function g({...e}){return(0,s.jsx)(a.D,{"data-slot":"dialog",...e})}function b({...e}){return(0,s.jsx)(i.Z,{"data-slot":"dialog-portal",...e})}function v({className:e,...t}){return(0,s.jsx)(o.X,{"data-slot":"dialog-overlay",className:(0,m.cn)("fixed inset-0 isolate z-50 overlay-backdrop duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function y({className:e,children:t,showCloseButton:r=!0,...n}){return(0,s.jsxs)(b,{children:[(0,s.jsx)(v,{}),(0,s.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,m.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-background p-4 text-sm ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n,children:[t,r&&(0,s.jsxs)(d.H,{"data-slot":"dialog-close",render:(0,s.jsx)(h,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,s.jsx)(f.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function j({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,m.cn)("flex flex-col gap-2",e),...t})}function w({className:e,showCloseButton:t=!1,children:r,...n}){return(0,s.jsxs)("div",{"data-slot":"dialog-footer",className:(0,m.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...n,children:[r,t&&(0,s.jsx)(d.H,{render:(0,s.jsx)(h,{variant:"outline"}),children:"Close"})]})}function k({className:e,...t}){return(0,s.jsx)(c.L,{"data-slot":"dialog-title",className:(0,m.cn)("text-base leading-none font-medium",e),...t})}function N({className:e,...t}){return(0,s.jsx)(u.r,{"data-slot":"dialog-description",className:(0,m.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function S(){let[e,t]=(0,n.useState)(!1),[r,a]=(0,n.useState)({title:""}),i=(0,n.useRef)(null),o=(0,n.useCallback)(e=>(a(e),t(!0),new Promise(e=>{i.current=e})),[]),l=(0,n.useCallback)(e=>{t(!1),i.current?.(e),i.current=null},[]);return{confirm:o,ConfirmDialog:(0,s.jsx)(g,{open:e,onOpenChange:e=>{e||l(!1)},children:(0,s.jsxs)(y,{showCloseButton:!1,className:"sm:max-w-[400px]",children:[(0,s.jsxs)(j,{children:[(0,s.jsx)(k,{children:r.title}),r.description&&(0,s.jsx)(N,{children:r.description})]}),(0,s.jsxs)(w,{children:[(0,s.jsx)(h,{variant:"outline",onClick:()=>l(!1),children:r.cancelLabel??"Cancel"}),(0,s.jsx)(h,{variant:"destructive"===r.variant?"destructive":"default",onClick:()=>l(!0),children:r.confirmLabel??"Confirm"})]})]})})}}},20555:(e,t,r)=>{"use strict";r.d(t,{LD:()=>s,LZ:()=>n,qQ:()=>a});let s=[{id:"c1",icon:"\uD83D\uDC64",category:"memory-sync",scenario:"first-day"},{id:"c2",icon:"\uD83D\uDCE5",category:"knowledge-management",scenario:"daily"},{id:"c3",icon:"\uD83D\uDD04",category:"memory-sync",scenario:"project"},{id:"c4",icon:"\uD83D\uDD01",category:"experience-evolution",scenario:"daily"},{id:"c5",icon:"\uD83D\uDCA1",category:"auto-execute",scenario:"daily"},{id:"c6",icon:"\uD83D\uDE80",category:"auto-execute",scenario:"project"},{id:"c7",icon:"\uD83D\uDD0D",category:"knowledge-management",scenario:"project"},{id:"c8",icon:"\uD83E\uDD1D",category:"human-insights",scenario:"daily"},{id:"c9",icon:"\uD83D\uDEE1️",category:"audit-control",scenario:"advanced"}],n=["knowledge-management","memory-sync","auto-execute","experience-evolution","human-insights","audit-control"],a=["first-day","daily","project","advanced"]},20814:(e,t,r)=>{"use strict";r.r(t),r.d(t,{ImageRenderer:()=>i});var s=r(95155),n=r(12115);let a=[.25,.5,.75,1,1.5,2,3,4];function i({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"image",i=r.split(".").pop()?.toLowerCase()??"",o=["png","svg","webp","ico","gif"].includes(i),[l,d]=(0,n.useState)(!0),[c,u]=(0,n.useState)(!1),[m,x]=(0,n.useState)(0),[p,h]=(0,n.useState)("fit"),[f,g]=(0,n.useState)(null),[b,v]=(0,n.useState)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(null),w=(0,n.useCallback)(()=>{d(!1);let e=y.current;e&&g({w:e.naturalWidth,h:e.naturalHeight})},[]),k=(0,n.useCallback)(()=>{d(!1),u(!0)},[]),N=(0,n.useCallback)(()=>{u(!1),d(!0),x(e=>e+1)},[]);(0,n.useEffect)(()=>{l||c||null!==b||fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&v(parseInt(t,10))}).catch(()=>{})},[t,l,c,b]);let S=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return a.find(e=>e>t)??t})},[]),C=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return[...a].reverse().find(e=>e<t)??t})},[]),A=(0,n.useCallback)(()=>{h(e=>"fit"===e?1:"fit")},[]);(0,n.useEffect)(()=>{let e=j.current;if(!e)return;let t=t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||(document.activeElement===document.body||e.contains(document.activeElement))&&(("+"===t.key||"="===t.key)&&(t.preventDefault(),S()),"-"===t.key&&(t.preventDefault(),C()),"0"===t.key&&(t.preventDefault(),h("fit")),"1"===t.key&&(t.preventDefault(),h(1)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[S,C]);let z="fit"===p?"Fit":`${Math.round(100*p)}%`,E="fit"===p?{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"}:f?{width:f.w*p,height:"auto"}:{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"};return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,s.jsxs)("span",{children:[f.w," x ",f.h]}),null!==b&&(0,s.jsx)("span",{children:b<1024?`${b} B`:b<1048576?`${(b/1024).toFixed(1)} KB`:`${(b/1048576).toFixed(1)} MB`}),(0,s.jsx)("span",{className:"uppercase opacity-60",children:i})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{onClick:C,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom out (-)",children:"-"}),(0,s.jsx)("button",{onClick:A,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors min-w-[48px] text-center disabled:opacity-30",title:"fit"===p?"Actual size (1)":"Fit to view (0)",children:z}),(0,s.jsx)("button",{onClick:S,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom in (+)",children:"+"})]})]}),(0,s.jsxs)("div",{ref:j,tabIndex:-1,className:`relative flex-1 min-h-[70vh] overflow-auto flex items-center justify-center outline-none ${o?"bg-checkerboard":"bg-[var(--bg-secondary)]"}`,children:[l&&!c&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading..."})}),c&&(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center z-10 gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load image"}),(0,s.jsx)("button",{onClick:N,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,s.jsx)("img",{ref:y,src:t,alt:r,onLoad:w,onError:k,draggable:!1,className:"select-none",style:{display:c?"none":"block",...E}},m)]})]})}},20870:(e,t,r)=>{"use strict";r.r(t),r.d(t,{PdfRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,[r,a]=(0,n.useState)(!0),[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),c=(0,n.useCallback)(()=>{o(!1),a(!0),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full h-full min-h-[80vh] flex flex-col relative",children:[r&&!i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10",children:(0,s.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading PDF..."})}),i&&(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10 gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load PDF"}),(0,s.jsx)("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,s.jsx)("iframe",{src:t,className:"w-full flex-1 min-h-[80vh] border-0 rounded-lg bg-[var(--bg-secondary)]",title:e.split("/").pop()??"PDF",onLoad:()=>a(!1),onError:()=>{a(!1),o(!0)},style:{display:i?"none":"block"}},l)]})}},25400:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>er,Fo:()=>F,gL:()=>L});var s=r(95155),n=r(12115),a=r(73321),i=r(82125),o=r(91337),l=r(33078),d=r(48368),c=r(6296),u=r(66088),m=r(15282),x=r(33024),p=r(42129),h=r(38798),f=r(60285),g=r(94290),b=r(67635),v=r(49387),y=r(68459),j=r(9339);let w=(0,j.createServerReference)("60b9c835d85c5b7a25772d53dfe9498a9306fa5c91",j.callServer,void 0,j.findSourceMapURL,"createFileAction"),k=(0,j.createServerReference)("6030b8aa56c2b282d992fe987400a036335ab54443",j.callServer,void 0,j.findSourceMapURL,"renameSpaceAction");var N=r(40674);let S=(0,j.createServerReference)("40d33a37d34737cad20e0d5405a344912cd7367695",j.callServer,void 0,j.findSourceMapURL,"deleteSpaceAction"),C=(0,j.createServerReference)("40d3d7986c655f9ad0c777f7bc03018d03334b383a",j.callServer,void 0,j.findSourceMapURL,"deleteFolderAction");var A=r(69327),z=r(95304),E=r(4235),T=r(35581),$=r(39498),D=r(10377);let R="show-hidden-files";function M(e){let t=t=>{t.key===R&&e()},r=()=>e();return window.addEventListener("storage",t),window.addEventListener("mindos:hidden-files-changed",r),()=>{window.removeEventListener("storage",t),window.removeEventListener("mindos:hidden-files-changed",r)}}function P(){return"true"===localStorage.getItem(R)}function F(e){localStorage.setItem(R,String(e)),window.dispatchEvent(new Event("mindos:hidden-files-changed"))}function L(){return(0,n.useSyncExternalStore)(M,P,()=>!1)}var I=r(51914),O=r(997),W=r(59511);let B=(0,j.createServerReference)("40956c443a80ef5209c4a3eeee661ba8fa08e3d275",j.callServer,void 0,j.findSourceMapURL,"convertToSpaceAction");var _=r(5292);async function U(e){try{await navigator.clipboard.writeText(e)}catch{}}let H="w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-muted transition-colors text-left",K="w-full flex items-center gap-2 px-3 py-2 text-sm text-error hover:bg-error/10 transition-colors text-left",X="my-1 border-t border-border/50";function Y({x:e,y:t,onClose:r,menuHeight:a,children:i}){let o=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&r()},t=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r]);let l=Math.min(t,window.innerHeight-(a??160)),d=Math.min(e,window.innerWidth-200);return(0,s.jsx)("div",{ref:o,className:"fixed z-50 min-w-[180px] bg-card border border-border rounded-lg shadow-lg py-1",style:{top:l,left:d},children:i})}function J({x:e,y:t,node:r,onClose:n,onRename:i,onNewFile:l,onImport:d,onDelete:c}){let u=(0,a.useRouter)(),{t:m}=(0,T.Y)(),{isPinned:x,togglePin:p}=(0,D.Z)(),h=x(r.path);return(0,s.jsxs)(Y,{x:e,y:t,onClose:n,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{l(),n()},children:[(0,s.jsx)(I.A,{size:14,className:"shrink-0"})," ",m.fileTree.newFile]}),(0,s.jsxs)("button",{className:H,onClick:()=>{u.push(`/view/${(0,o.O0)(`${r.path}/INSTRUCTION.md`)}`),n()},children:[(0,s.jsx)(O.A,{size:14,className:"shrink-0"})," ",m.fileTree.viewRules]}),d&&(0,s.jsxs)("button",{className:H,onClick:()=>{d(r.path),n()},children:[(0,s.jsx)(W.A,{size:14,className:"shrink-0"})," ",m.fileTree.importFile]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:H,onClick:()=>{p(r.path),n()},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${h?"fill-[var(--amber)] text-[var(--amber)]":""}`}),h?m.fileTree.removeFromFavorites:m.fileTree.pinToFavorites]}),(0,s.jsxs)("button",{className:H,onClick:()=>{U(r.path),n()},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",m.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{i(),n()},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",m.fileTree.renameSpace]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:()=>{n(),c()},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"}),m.fileTree.deleteSpace]})]})}function G({x:e,y:t,node:r,onClose:i,onRename:o,onNewFile:l,onDelete:d}){let c=(0,a.useRouter)(),{t:u}=(0,T.Y)(),[m,p]=(0,n.useTransition)(),{isPinned:h,togglePin:f}=(0,D.Z)(),j=h(r.path);return(0,s.jsxs)(Y,{x:e,y:t,onClose:i,menuHeight:220,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{l(),i()},children:[(0,s.jsx)(I.A,{size:14,className:"shrink-0"})," ",u.fileTree.newFile]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:H,onClick:()=>{f(r.path),i()},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${j?"fill-[var(--amber)] text-[var(--amber)]":""}`}),j?u.fileTree.removeFromFavorites:u.fileTree.pinToFavorites]}),(0,s.jsxs)("button",{className:H,disabled:m,onClick:()=>{p(async()=>{if((await B(r.path)).success){c.refresh(),window.dispatchEvent(new Event("mindos:files-changed"));let e=r.name.replace(/^[\p{Emoji_Presentation}\p{Extended_Pictographic}\s]+/u,"")||r.name;(0,_.w)().then(t=>{t&&(0,_.V)(e,r.path)})}i()})},children:[(0,s.jsx)(x.A,{size:14,className:"shrink-0 text-[var(--amber)]"})," ",u.fileTree.convertToSpace]}),(0,s.jsxs)("button",{className:H,onClick:()=>{U(r.path),i()},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",u.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{o(),i()},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",u.fileTree.rename]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:()=>{i(),d()},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"}),u.fileTree.deleteFolder]})]})}var Z=r(29494);function V(){window.dispatchEvent(new Event("mindos:files-changed"))}async function q(e){try{await navigator.clipboard.writeText(e)}catch{}}function Q({dirPath:e,depth:t,onDone:r}){let[i,l]=(0,n.useState)(""),[d,u]=(0,n.useTransition)(),[m,x]=(0,n.useState)(""),p=(0,a.useRouter)(),{t:h}=(0,T.Y)(),f=(0,n.useRef)(null),g=(0,n.useCallback)(()=>{let t=i.trim();t?u(async()=>{let s=await w(e,t);s.success&&s.filePath?(r(),p.push(`/view/${(0,o.O0)(s.filePath)}`),p.refresh(),V()):x(s.error||h.fileTree.failed)}):x(h.fileTree.enterFileName)},[i,e,r,p,h]);return(0,n.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&r()},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[r]),(0,s.jsxs)("div",{ref:f,className:"px-2 pb-1",style:{paddingLeft:`${12*t+20}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{autoFocus:!0,type:"text",value:i,onChange:e=>{l(e.target.value),x("")},onKeyDown:e=>{"Enter"===e.key&&g(),"Escape"===e.key&&r()},placeholder:"filename.md",className:" flex-1 bg-muted border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring "}),d?(0,s.jsx)(c.A,{size:13,className:"text-muted-foreground animate-spin shrink-0"}):(0,s.jsx)("button",{onClick:g,className:"text-xs text-[var(--amber)] hover:text-foreground shrink-0 px-1",children:h.fileTree.create})]}),m&&(0,s.jsx)("p",{className:"text-xs text-error mt-0.5 px-1",children:m})]})}let ee=(0,n.memo)(function({node:e,depth:t,currentPath:r,onNavigate:l,maxOpenDepth:d,onImport:g}){let b=(0,a.useRouter)(),v=r.startsWith(e.path+"/")||r===e.path,y=!!e.isSpace,[j,w]=(0,n.useState)(0===t||v),[z,D]=(0,n.useState)(0===t||v),[R,M]=(0,n.useState)(!1),[P,F]=(0,n.useState)(!1),[L,I]=(0,n.useState)(e.name),[O,W]=(0,n.useTransition)(),B=(0,n.useRef)(null),_=(0,n.useRef)(null),[U,H]=(0,n.useState)(null),{t:K}=(0,T.Y)(),[X,Y]=(0,n.useState)(null),[q,ee]=(0,n.useTransition)(),{isDragTarget:et,handleRowDragOver:es,handleRowDragEnter:en,handleRowDragLeave:ea,handleRowDrop:ei}=function(e,t,r,s){let[a,i]=(0,n.useState)(!1),o=(0,n.useRef)(null),l=(0,n.useRef)(null),d=(0,n.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),c=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",l.current&&(clearTimeout(l.current),l.current=null),a||i(!0))},[a]),u=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.stopPropagation(),i(!0),d(),t||(o.current=setTimeout(()=>{r(!0),o.current=null},500)))},[t,d,r]),m=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.stopPropagation(),l.current=setTimeout(()=>{i(!1),d(),l.current=null},50))},[d]),x=(0,n.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),i(!1),d(),l.current&&(clearTimeout(l.current),l.current=null);let r=t.dataTransfer.files;r.length>0&&(0,Z.Nh)(Array.from(r),e.path,s)},[e.path,s,d]);return(0,n.useEffect)(()=>()=>{o.current&&clearTimeout(o.current),l.current&&clearTimeout(l.current)},[]),{isDragTarget:a,handleRowDragOver:c,handleRowDragEnter:u,handleRowDragLeave:m,handleRowDrop:x}}(e,j,(0,n.useCallback)(e=>{w(e),e&&D(!0)},[]),K),eo=(0,n.useCallback)(()=>{w(e=>(e||D(!0),!e))},[]),el=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{if(null==d){el.current=d;return}if(el.current!==d){if(null===el.current||void 0===el.current)t>d?w(!1):D(!0);else{let e=t<=d;w(e),e&&D(!0)}el.current=d}},[d,t]),(0,n.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);let ed=(0,n.useCallback)(t=>{t?.preventDefault(),t?.stopPropagation(),_.current&&(clearTimeout(_.current),_.current=null),I(e.name),F(!0),setTimeout(()=>B.current?.select(),0)},[e.name]),ec=(0,n.useCallback)(()=>{let t=L.trim();t&&t!==e.name?W(async()=>{let r=y?k:N.f,s=await r(e.path,t);s.success&&s.newPath?(F(!1),b.push(`/view/${(0,o.O0)(s.newPath)}`),b.refresh(),V()):F(!1)}):F(!1)},[L,e.name,e.path,b,y]),eu=(0,n.useCallback)(()=>{P||(_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{b.push(`/view/${(0,o.O0)(e.path)}`),l?.(),_.current=null},180))},[P,b,e.path,l]);(0,n.useCallback)(e=>{e.stopPropagation(),eo()},[eo]);let em=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H({x:e.clientX,y:e.clientY})},[]),ex=y?function e(t){return"file"===t.type?+!i.C.has(t.name):(t.children??[]).reduce((t,r)=>t+e(r),0)}(e):0;if(P)return(0,s.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,s.jsx)("input",{ref:B,autoFocus:!0,value:L,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ec(),"Escape"===e.key&&F(!1)},onBlur:ec,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),O&&(0,s.jsx)(c.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]});let ep=y&&0===t;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:`relative group/dir flex items-center transition-colors duration-100 ${et?"bg-[var(--amber)]/10 rounded-md":""}`,onContextMenu:em,onDragEnter:en,onDragOver:es,onDragLeave:ea,onDrop:ei,children:[(0,s.jsx)("button",{onClick:eo,className:"shrink-0 p-1 rounded hover:bg-muted text-muted-foreground transition-colors",style:{marginLeft:`${12*t+4}px`},"aria-label":j?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":j,children:(0,s.jsx)("span",{className:"block transition-transform duration-150",style:{transform:j?"rotate(0deg)":"rotate(-90deg)"},children:(0,s.jsx)(u.A,{size:10})})}),(0,s.jsxs)("button",{type:"button",onClick:eu,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.setData("text/mindos-type","directory"),t.dataTransfer.effectAllowed="copy"},className:`
|
|
12
|
-
flex-1 flex items-center gap-1.5 px-1 py-1 rounded text-left min-w-0 pr-16
|
|
13
|
-
text-sm transition-colors duration-100
|
|
14
|
-
hover:bg-muted cursor-default
|
|
15
|
-
${v?"text-foreground":"text-muted-foreground hover:text-foreground"}
|
|
16
|
-
`,children:[y?"Inbox"===e.name?(0,s.jsx)(m.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):(0,s.jsx)(x.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):j?(0,s.jsx)(p.A,{size:14,className:"text-yellow-400 shrink-0"}):(0,s.jsx)(h.A,{size:14,className:"text-yellow-400 shrink-0"}),(0,s.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),y&&!j&&(0,s.jsx)("span",{className:"ml-auto text-xs text-muted-foreground shrink-0 tabular-nums pr-1",children:ex})]}),(0,s.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/dir:flex items-center gap-0.5 z-10",children:(0,s.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();H({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,s.jsx)(f.A,{size:14})})})]}),(0,s.jsx)("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${j?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:(0,s.jsxs)("div",{className:`overflow-hidden ${ep?"border-l-2 ml-[18px]":""}`,style:ep?{borderColor:"color-mix(in srgb, var(--amber) 30%, transparent)"}:void 0,...!j&&{inert:!0},children:[z&&e.children&&(0,s.jsx)(er,{nodes:e.children,depth:ep?1:t+1,onNavigate:l,maxOpenDepth:d,parentIsSpace:y,onImport:g}),R&&(0,s.jsx)(Q,{dirPath:e.path,depth:ep?0:t,onDone:()=>M(!1)})]})}),U&&(y?(0,s.jsx)(J,{x:U.x,y:U.y,node:e,onClose:()=>H(null),onRename:()=>ed(),onNewFile:()=>{w(!0),D(!0),M(!0)},onImport:g,onDelete:()=>Y("space")}):(0,s.jsx)(G,{x:U.x,y:U.y,node:e,onClose:()=>H(null),onRename:()=>ed(),onNewFile:()=>{w(!0),D(!0),M(!0)},onDelete:()=>Y("folder")})),(0,s.jsx)($.TM,{open:null!==X,title:"space"===X?K.fileTree.deleteSpace:K.fileTree.deleteFolder,message:"space"===X?K.fileTree.confirmDeleteSpace(e.name):K.fileTree.confirmDeleteFolder(e.name),confirmLabel:"space"===X?K.fileTree.deleteSpace:K.fileTree.deleteFolder,cancelLabel:K.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>Y(null),onConfirm:()=>{Y(null),ee(async()=>{let t="space"===X?await S(e.path):await C(e.path);if(t.success&&t.trashId){let r=t.trashId,s=e.path.split("/").pop()??e.path;E.oR.undo(`${K.trash?.movedToTrash??"Deleted"} ${s}`,async()=>{let e=await (0,A.Y)(r);e.success?(b.refresh(),V()):E.oR.error(e.error??"Undo failed")},{label:K.trash?.undo??"Undo"}),b.push("/"),b.refresh(),V()}})}})]})}),et=(0,n.memo)(function({node:e,depth:t,currentPath:r,onNavigate:u}){let m=(0,a.useRouter)(),x=r===e.path,[p,h]=(0,n.useState)(!1),[j,w]=(0,n.useState)(e.name),[k,S]=(0,n.useTransition)(),[,C]=(0,n.useTransition)(),R=(0,n.useRef)(null),{t:M}=(0,T.Y)(),{isPinned:P,togglePin:F}=(0,D.Z)(),L=P(e.path),I=!e.path.includes("/")&&i.A.has(e.name),[O,W]=(0,n.useState)(!1),[B,_]=(0,n.useState)(null),U=(0,n.useCallback)(()=>{p||(m.push(`/view/${(0,o.O0)(e.path)}`),u?.())},[m,e.path,u,p]),J=(0,n.useCallback)(t=>{t.stopPropagation(),w(e.name),h(!0),setTimeout(()=>R.current?.select(),0)},[e.name]),G=(0,n.useCallback)(()=>{let t=j.trim();t&&t!==e.name?S(async()=>{let r=await (0,N.f)(e.path,t);r.success&&r.newPath?(h(!1),m.push(`/view/${(0,o.O0)(r.newPath)}`),m.refresh(),V()):h(!1)}):h(!1)},[j,e.name,e.path,m]),Z=(0,n.useCallback)(e=>{e.stopPropagation(),W(!0)},[]),Q=(0,n.useCallback)(t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.effectAllowed="copy"},[e.path]),ee=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_({x:e.clientX,y:e.clientY})},[]);return p?(0,s.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,s.jsx)("input",{ref:R,autoFocus:!0,value:j,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(),"Escape"===e.key&&h(!1)},onBlur:G,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),k&&(0,s.jsx)(c.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]}):(0,s.jsxs)("div",{className:"relative group/file",children:[(0,s.jsxs)("button",{onClick:U,onContextMenu:ee,draggable:!0,onDragStart:Q,"data-filepath":e.path,className:`
|
|
17
|
-
w-full flex items-center gap-1.5 px-2 py-1 rounded text-left
|
|
18
|
-
text-sm transition-colors duration-100 cursor-default pr-16
|
|
19
|
-
${x?"bg-accent text-foreground":"hover:bg-muted text-muted-foreground hover:text-foreground"}
|
|
20
|
-
`,style:{paddingLeft:`${12*t+8}px`},children:["directory"===e.type?null:".csv"===e.extension?(0,s.jsx)(l.A,{size:14,className:"text-success shrink-0"}):(0,s.jsx)(d.A,{size:14,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),L&&(0,s.jsx)(g.A,{size:10,className:"shrink-0 fill-[var(--amber)] text-[var(--amber)] opacity-60"})]}),(0,s.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/file:flex items-center gap-0.5",children:(0,s.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();_({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,s.jsx)(f.A,{size:14})})}),B&&(0,s.jsxs)(Y,{x:B.x,y:B.y,onClose:()=>_(null),menuHeight:140,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{q(e.path),_(null)},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",M.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{F(e.path),_(null)},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${L?"fill-[var(--amber)] text-[var(--amber)]":""}`}),L?M.fileTree.removeFromFavorites:M.fileTree.pinToFavorites]}),!I&&(0,s.jsxs)("button",{className:H,onClick:e=>{_(null),J(e)},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",M.fileTree.rename]}),!I&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:e=>{_(null),Z(e)},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"})," ",M.fileTree.delete]})]})]}),(0,s.jsx)($.TM,{open:O,title:M.fileTree.delete,message:M.fileTree.confirmDelete(e.name),confirmLabel:M.fileTree.delete,cancelLabel:M.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>W(!1),onConfirm:()=>{W(!1),C(async()=>{let t=await (0,z.i)(e.path);if(t.success){if(t.trashId){let r=t.trashId,s=e.path.split("/").pop()??e.path;E.oR.undo(`${M.trash?.movedToTrash??"Deleted"} ${s}`,async()=>{let e=await (0,A.Y)(r);e.success?(m.refresh(),V()):E.oR.error(e.error??"Undo failed")},{label:M.trash?.undo??"Undo"})}m.refresh(),V()}})}})]})});function er({nodes:e,depth:t=0,onNavigate:r,maxOpenDepth:o,parentIsSpace:l,onImport:d}){var c;let u,m=(u="/view/",(c=(0,a.usePathname)()).startsWith(u)?c.slice(u.length).split("/").map(decodeURIComponent).join("/"):""),x=L(),p=0===t,h=x?e:e.filter(e=>!(p&&e.name.startsWith(".")||"file"===e.type&&i.C.has(e.name)||"directory"===e.type&&e.name.startsWith("."))),f=p?h.filter(e=>"directory"!==e.type||"Inbox"!==e.name):h;return(0,n.useEffect)(()=>{if(!m||0!==t)return;let e=setTimeout(()=>{let e=document.querySelector(`[data-filepath="${CSS.escape(m)}"]`);e?.scrollIntoView({block:"nearest",behavior:"smooth"})},120);return()=>clearTimeout(e)},[m,t]),(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:f.map(e=>"directory"===e.type?(0,s.jsx)(ee,{node:e,depth:t,currentPath:m,onNavigate:r,maxOpenDepth:o,onImport:d},e.path):(0,s.jsx)(et,{node:e,depth:t,currentPath:m,onNavigate:r},e.path))})}},26490:(e,t,r)=>{"use strict";r.d(t,{default:()=>u});var s=r(95155),n=r(12115),a=r(94514),i=r(13545),o=r(68822),l=r(33210),d=r(4235);let c={success:(0,s.jsx)(a.A,{size:15,className:"text-success shrink-0"}),error:(0,s.jsx)(i.A,{size:15,className:"text-error shrink-0"}),info:(0,s.jsx)(o.A,{size:15,className:"text-muted-foreground shrink-0"})};function u(){let e=(0,n.useSyncExternalStore)(d.B1,d.dV,d.dV);return 0===e.length?null:(0,s.jsx)("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col-reverse gap-2 pointer-events-none",role:"status","aria-live":"polite","aria-atomic":"false",children:e.map(e=>(0,s.jsxs)("div",{className:"pointer-events-auto flex items-center gap-2.5 bg-card border border-border rounded-lg shadow-lg px-4 py-2.5 min-w-[180px] max-w-[320px] animate-in slide-in-from-right-4 fade-in duration-200",children:[c[e.type],(0,s.jsx)("span",{className:"text-sm text-foreground flex-1 truncate",children:e.message}),e.action&&(0,s.jsx)("button",{type:"button",onClick:()=>{e.action.onClick(),(0,d.X8)(e.id)},className:"shrink-0 px-2.5 py-1 rounded text-xs font-medium text-[var(--amber)] hover:bg-[var(--amber-dim)] transition-colors min-h-[28px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:e.action.label}),(0,s.jsx)("button",{type:"button",onClick:()=>(0,d.X8)(e.id),className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":e.action?.label?"Close":"Dismiss",children:(0,s.jsx)(l.A,{size:13})})]},e.id))})}},29494:(e,t,r)=>{"use strict";r.d(t,{Aw:()=>d,Nh:()=>u,QL:()=>i,TM:()=>o,h0:()=>l,lL:()=>c});var s=r(4235);function n(e){let t=new Uint8Array(e),r=[];for(let e=0;e<t.length;e+=8192)r.push(String.fromCharCode(...t.subarray(e,e+8192)));return btoa(r.join(""))}async function a(e){if(e.byteLength<524288||"u"<typeof Worker)return n(e);let t=e.slice(0);return new Promise(r=>{let s=new Blob([`
|
|
11
|
+
Keep content concise and actionable. Write files directly using tools.`;window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spaceName:e,spacePath:t,description:r,state:"working"}})),fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:s}],currentFile:t+"/INSTRUCTION.md"})}).then(async e=>{if(!e.ok||!e.body)throw Error(`HTTP ${e.status}`);let r=e.body.getReader();try{for(;;){let{done:e}=await r.read();if(e)break}}finally{r.releaseLock()}window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"done"}})),window.dispatchEvent(new Event("mindos:files-changed"))}).catch(()=>{window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"error"}}))})}},10377:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h});var s=r(12115);let n="mindos-pinned-files",a="mindos:pins-changed";function i(){try{let e=localStorage.getItem(n);return e?JSON.parse(e):[]}catch{return[]}}function o(){return c}let l=[];function d(){return l}let c=[],u=!1;function m(){u||(c=i(),u=!0)}function x(e){m();let t=t=>{t.key===n&&(c=i(),e())},r=()=>{c=i(),e()};return window.addEventListener("storage",t),window.addEventListener(a,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(a,r)}}function p(e){c=e;try{localStorage.setItem(n,JSON.stringify(e))}catch{}window.dispatchEvent(new Event(a))}function h(){m();let e=(0,s.useSyncExternalStore)(x,o,d),t=(0,s.useCallback)(t=>e.includes(t),[e]),r=(0,s.useCallback)(e=>{let t=i(),r=t.indexOf(e);r>=0?t.splice(r,1):t.unshift(e),p(t)},[]);return{pinnedFiles:e,isPinned:t,togglePin:r,reorderPins:(0,s.useCallback)(e=>{p(e)},[]),removePin:(0,s.useCallback)(e=>{p(i().filter(t=>t!==e))},[])}}},12413:(e,t,r)=>{"use strict";r.d(t,{P:()=>s,u:()=>n});let s=[{id:"telegram",name:"Telegram",icon:"\uD83D\uDCF1",guide:"1. Open Telegram → search @BotFather\n2. Send /newbot → follow prompts\n3. Copy the token below",purpose:"Receive MindOS notifications and quick updates in Telegram.",purposeZh:"通过 Telegram 接收 MindOS 的通知和快速更新。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. chat ID like 123456789 or -1001234567890",recipientExampleZh:"例如 123456789 或 -1001234567890 这样的 chat ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456789:AABBccDD-EeFfGgHh...",hint:"Format: number:alphanumeric"}]},{id:"feishu",name:"Feishu",icon:"\uD83D\uDC26",guide:"1. open.feishu.cn → Create App\n2. Credentials page → copy App ID & Secret\n3. Enable Bot capability + add permissions",guideUrl:"https://open.feishu.cn/",editHint:"Need to update credentials? Edit and save below — MindOS will reconnect automatically.",purpose:"Receive MindOS results in Feishu, or let users message the bot directly when conversations are enabled.",purposeZh:"通过飞书接收 MindOS 的结果;开启对话后,也可以让用户直接在飞书里给机器人发消息。",useCases:["Agent completion alerts","Error notifications","Test messages","Direct bot conversations in Feishu"],useCasesZh:["Agent 完成提醒","错误通知","测试消息","在飞书里直接与机器人对话"],recipientExample:"e.g. ou_xxx, oc_xxx, or a work email",recipientExampleZh:"例如 ou_xxx、oc_xxx,或企业邮箱",fields:[{key:"app_id",label:"App ID",placeholder:"CLI_XXXXXXXXXXXXXXXXX",hint:"From Credentials page on open.feishu.cn"},{key:"app_secret",label:"App Secret",placeholder:"XXXXXXXXXXXXXXXXXXXXXXXX",hint:"Keep this secret — do not share"}]},{id:"discord",name:"Discord",icon:"\uD83D\uDCAC",guide:"1. discord.com/developers → New Application\n2. Bot tab → Reset Token → copy\n3. Enable Message Content Intent",purpose:"Send MindOS updates into Discord channels and DMs.",purposeZh:"把 MindOS 的更新发送到 Discord 频道或私信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. Discord channel or user ID",recipientExampleZh:"例如 Discord 频道 ID 或用户 ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"MTIxNzM..."}]},{id:"slack",name:"Slack",icon:"\uD83D\uDCBC",guide:"1. api.slack.com/apps → Create New App\n2. OAuth & Permissions → add chat:write scope\n3. Install to Workspace → copy Bot Token",purpose:"Route MindOS notifications into Slack channels and direct messages.",purposeZh:"把 MindOS 的通知发送到 Slack 频道或私信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"e.g. Slack channel or user ID like C123... or U123...",recipientExampleZh:"例如 Slack 频道 ID 或用户 ID(如 C123... / U123...)",fields:[{key:"bot_token",label:"Bot Token",placeholder:"xoxb-xxxx-xxxx-xxxx",hint:"Starts with xoxb-"}]},{id:"wecom",name:"WeCom",icon:"\uD83C\uDFE2",guide:"1. Group chat → Add Robot → Custom\n2. Copy Webhook URL\n3. Extract the key parameter from URL",purpose:"Deliver MindOS notifications into WeCom group chats.",purposeZh:"把 MindOS 通知投递到企业微信群聊。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use your configured robot or WeCom target",recipientExampleZh:"使用你配置好的机器人或企业微信目标",fields:[{key:"webhook_key",label:"Webhook Key",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",hint:"The key= value from webhook URL"}]},{id:"dingtalk",name:"DingTalk",icon:"\uD83D\uDD14",guide:"1. Group → Settings → Smart Assistant → Add Robot\n2. Select Custom (Webhook)\n3. Copy the full Webhook URL",purpose:"Push MindOS notifications into DingTalk groups.",purposeZh:"把 MindOS 通知发送到钉钉群。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use your configured DingTalk robot target",recipientExampleZh:"使用你配置好的钉钉机器人目标",fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",hint:"Full URL including access_token"}]},{id:"wechat",name:"WeChat",icon:"\uD83D\uDC9A",guide:"1. Visit ilinkai.weixin.qq.com\n2. Register & create a bot application\n3. QR login in the console → copy Bot Token from dashboard",purpose:"Send MindOS updates to WeChat via your configured bot.",purposeZh:"通过你配置好的机器人把 MindOS 更新发送到微信。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use the WeChat user or chat ID supported by your bot",recipientExampleZh:"使用你的机器人支持的微信用户或群聊 ID",fields:[{key:"bot_token",label:"Bot Token",placeholder:"wx_xxxxxxxxxxxxxxxx",hint:"From iLink Bot console after QR login"}]},{id:"qq",name:"QQ",icon:"\uD83D\uDC27",guide:"1. q.qq.com → Create Bot\n2. Development tab → copy App ID & Secret\n3. Add group/C2C intents as needed",purpose:"Deliver MindOS notifications through QQ bot channels.",purposeZh:"通过 QQ 机器人频道接收 MindOS 通知。",useCases:["Agent completion alerts","Error notifications","Test messages"],useCasesZh:["Agent 完成提醒","错误通知","测试消息"],recipientExample:"Use the QQ openid or group_openid for your target",recipientExampleZh:"使用目标 QQ 的 openid 或 group_openid",fields:[{key:"app_id",label:"App ID",placeholder:"102xxxxxx"},{key:"app_secret",label:"App Secret",placeholder:"xxxxxxxxxxxxxxxxxxxxxxxx"}]}];function n(e){return s.find(t=>t.id===e)}},14446:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AudioRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"audio",a=r.split(".").pop()?.toLowerCase()??"",[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let m=(0,n.useCallback)(()=>{o(!1),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full flex flex-col items-center gap-6 py-12 px-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[(0,s.jsx)("span",{className:"text-4xl opacity-40",children:"\uD83C\uDFB5"}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"uppercase opacity-60",children:a}),null!==c&&(0,s.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`})]})]})]}),i?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load audio"}),(0,s.jsx)("button",{onClick:m,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}):(0,s.jsx)("audio",{controls:!0,preload:"metadata",className:"w-full max-w-lg",onError:()=>o(!0),children:(0,s.jsx)("source",{src:t})},l)]})}},16518:(e,t,r)=>{"use strict";r.d(t,{AI:()=>n,RS:()=>s});let s=["imprint","growth","self"],n={imprint:"/echo/imprint",growth:"/echo/growth",self:"/echo/self"}},18847:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AgentInspectorRenderer:()=>j});var s=r(95155),n=r(12115),a=r(73321),i=r(84980),o=r(3926),l=r(93631),d=r(68459),c=r(61878),u=r(10762),m=r(12651),x=r(13545),p=r(66088);function h(e){return/read|list|get|search/.test(e)?/search/.test(e)?"search":"read":/create/.test(e)?"create":/delete/.test(e)?"delete":/write|update|insert|append/.test(e)?"write":"other"}let f={read:{bg:"rgba(138,180,216,0.10)",text:"var(--tool-read)",border:"rgba(138,180,216,0.25)"},write:{bg:"rgba(200,135,58,0.10)",text:"var(--amber)",border:"rgba(200,135,58,0.25)"},create:{bg:"rgba(122,173,128,0.10)",text:"var(--success)",border:"rgba(122,173,128,0.25)"},delete:{bg:"rgba(200,80,80,0.10)",text:"var(--error)",border:"rgba(200,80,80,0.25)"},search:{bg:"rgba(200,160,216,0.10)",text:"var(--tool-search)",border:"rgba(200,160,216,0.25)"},other:{bg:"var(--muted)",text:"var(--muted-foreground)",border:"var(--border)"}};function g({kind:e,size:t=13}){return"read"===e?(0,s.jsx)(i.A,{size:t}):"write"===e?(0,s.jsx)(o.A,{size:t}):"create"===e?(0,s.jsx)(l.A,{size:t}):"delete"===e?(0,s.jsx)(d.A,{size:t}):"search"===e?(0,s.jsx)(c.A,{size:t}):(0,s.jsx)(u.A,{size:t})}function b(e){try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}}function v({op:e}){var t,r;let i,o,l,d,c=(0,a.useRouter)(),[u,v]=(0,n.useState)(!1),y=h(e.tool),j=f[y],w="string"==typeof(t=e.params).path?t.path:null,k=e.tool.replace("mindos_","");return(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",marginBottom:8},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",cursor:"pointer",userSelect:"none"},onClick:()=>v(e=>!e),children:[(0,s.jsxs)("span",{className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:999,fontSize:"0.68rem",fontWeight:600,background:j.bg,color:j.text,border:`1px solid ${j.border}`,flexShrink:0},children:[(0,s.jsx)(g,{kind:y,size:10}),y]}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.78rem",color:"var(--foreground)",fontWeight:600,flexShrink:0},children:k}),w&&(0,s.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--amber)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},onClick:e=>{e.stopPropagation(),c.push("/view/"+w.split("/").map(encodeURIComponent).join("/"))},title:w,className:"font-display",children:w}),(0,s.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.agentName&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.62rem",fontWeight:500,padding:"1px 6px",borderRadius:999,background:"var(--muted)",color:"var(--muted-foreground)",whiteSpace:"nowrap",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},title:e.agentName,children:e.agentName.length>30?e.agentName.slice(0,30)+"...":e.agentName}),"ok"===e.result?(0,s.jsx)(m.A,{size:13,style:{color:"var(--success)"}}):(0,s.jsx)(x.A,{size:13,style:{color:"var(--error)"}}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6},title:b(e.ts),children:(r=e.ts,o=Math.floor((i=Date.now()-new Date(r).getTime())/6e4),l=Math.floor(i/36e5),d=Math.floor(i/864e5),o<1?"just now":o<60?`${o}m ago`:l<24?`${l}h ago`:`${d}d ago`)}),(0,s.jsx)(p.A,{size:12,style:{color:"var(--muted-foreground)",transform:u?"rotate(180deg)":"none",transition:"transform .15s"}})]})]}),u&&(0,s.jsxs)("div",{style:{borderTop:"1px solid var(--border)",padding:"10px 14px",background:"var(--background)"},children:[(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8*!!e.message},children:Object.entries(e.params).map(([e,t])=>(0,s.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0,minWidth:80},children:e}),(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--foreground)",wordBreak:"break-all",lineHeight:1.5},children:function(e,t=120){let r="string"==typeof e?e:JSON.stringify(e);return r.length>t?r.slice(0,t)+"…":r}(t)})]},e))}),e.message&&(0,s.jsx)("div",{className:"font-display",style:{marginTop:6,padding:"5px 9px",borderRadius:5,fontSize:"0.72rem",background:"error"===e.result?"rgba(200,80,80,0.08)":"rgba(122,173,128,0.08)",color:"error"===e.result?"var(--error)":"var(--success)",border:`1px solid ${"error"===e.result?"rgba(200,80,80,0.2)":"rgba(122,173,128,0.2)"}`},children:e.message}),e.agentName&&(0,s.jsxs)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.68rem",color:"var(--muted-foreground)"},children:["Agent: ",(0,s.jsx)("span",{style:{color:"var(--foreground)",fontWeight:500},children:e.agentName})]}),(0,s.jsx)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.65rem",color:"var(--muted-foreground)",opacity:.5},children:b(e.ts)})]})]})}let y=["all","write","create","delete","read","search"];function j({content:e}){let[t,r]=(0,n.useState)("all"),a=(0,n.useMemo)(()=>(function(e){try{let t=JSON.parse(e);if(Array.isArray(t.events))return t.events.filter(e=>!!e?.tool&&!!e?.ts).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())}catch{}return(function(e){let t=[];for(let r of e.split("\n")){let e=r.trim();if(!(!e||e.startsWith("#")||e.startsWith("//")))try{let r=JSON.parse(e);r.tool&&r.ts&&t.push(r)}catch{}}return t})(e).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())})(e),[e]),i=(0,n.useMemo)(()=>"all"===t?a:a.filter(e=>h(e.tool)===t),[a,t]),o=(0,n.useMemo)(()=>{let e={all:a.length};for(let t of a){let r=h(t.tool);e[r]=(e[r]??0)+1}return e},[a]);return 0===a.length?(0,s.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:12},children:[(0,s.jsx)(u.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,s.jsx)("p",{children:"No agent operations logged yet."}),(0,s.jsxs)("p",{style:{marginTop:6,opacity:.6,fontSize:11},children:["Agent writes appear here from ",(0,s.jsx)("code",{style:{background:"var(--muted)",padding:"1px 5px",borderRadius:4},children:".mindos/agent-audit-log.json"}),"."]})]}):(0,s.jsxs)("div",{style:{maxWidth:760,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:"1.2rem",flexWrap:"wrap"},children:y.map(e=>{let n=o[e]??0;if("all"!==e&&!n)return null;let a="all"!==e?f[e]:void 0,i=t===e;return(0,s.jsxs)("button",{onClick:()=>r(e),className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:999,fontSize:"0.7rem",cursor:"pointer",border:"none",background:i?a?.bg??"var(--accent)":"var(--muted)",color:i?a?.text??"var(--foreground)":"var(--muted-foreground)",outline:i?`1px solid ${a?.border??"var(--border)"}`:"none",transition:"all .1s"},children:["all"!==e&&(0,s.jsx)(g,{kind:e,size:10}),e," ",(0,s.jsxs)("span",{style:{opacity:.6},children:["(",n,")"]})]},e)})}),(0,s.jsx)("div",{children:i.map((e,t)=>(0,s.jsx)(v,{op:e},t))})]})}},19550:(e,t,r)=>{"use strict";r.d(t,{G:()=>S});var s=r(95155),n=r(12115),a=r(37386),i=r(85960),o=r(35176),l=r(59934),d=r(45362),c=r(82022),u=r(98758),m=r(91337),x=r(6539);let p=(0,r(18460).F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function h({className:e,variant:t="default",size:r="default",...n}){return(0,s.jsx)(x.$,{"data-slot":"button",className:(0,m.cn)(p({variant:t,size:r,className:e})),...n})}var f=r(33210);function g({...e}){return(0,s.jsx)(a.D,{"data-slot":"dialog",...e})}function b({...e}){return(0,s.jsx)(i.Z,{"data-slot":"dialog-portal",...e})}function v({className:e,...t}){return(0,s.jsx)(o.X,{"data-slot":"dialog-overlay",className:(0,m.cn)("fixed inset-0 isolate z-50 overlay-backdrop duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function y({className:e,children:t,showCloseButton:r=!0,...n}){return(0,s.jsxs)(b,{children:[(0,s.jsx)(v,{}),(0,s.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,m.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-background p-4 text-sm ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n,children:[t,r&&(0,s.jsxs)(d.H,{"data-slot":"dialog-close",render:(0,s.jsx)(h,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,s.jsx)(f.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function j({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,m.cn)("flex flex-col gap-2",e),...t})}function w({className:e,showCloseButton:t=!1,children:r,...n}){return(0,s.jsxs)("div",{"data-slot":"dialog-footer",className:(0,m.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...n,children:[r,t&&(0,s.jsx)(d.H,{render:(0,s.jsx)(h,{variant:"outline"}),children:"Close"})]})}function k({className:e,...t}){return(0,s.jsx)(c.L,{"data-slot":"dialog-title",className:(0,m.cn)("text-base leading-none font-medium",e),...t})}function N({className:e,...t}){return(0,s.jsx)(u.r,{"data-slot":"dialog-description",className:(0,m.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function S(){let[e,t]=(0,n.useState)(!1),[r,a]=(0,n.useState)({title:""}),i=(0,n.useRef)(null),o=(0,n.useCallback)(e=>(a(e),t(!0),new Promise(e=>{i.current=e})),[]),l=(0,n.useCallback)(e=>{t(!1),i.current?.(e),i.current=null},[]);return{confirm:o,ConfirmDialog:(0,s.jsx)(g,{open:e,onOpenChange:e=>{e||l(!1)},children:(0,s.jsxs)(y,{showCloseButton:!1,className:"sm:max-w-[400px]",children:[(0,s.jsxs)(j,{children:[(0,s.jsx)(k,{children:r.title}),r.description&&(0,s.jsx)(N,{children:r.description})]}),(0,s.jsxs)(w,{children:[(0,s.jsx)(h,{variant:"outline",onClick:()=>l(!1),children:r.cancelLabel??"Cancel"}),(0,s.jsx)(h,{variant:"destructive"===r.variant?"destructive":"default",onClick:()=>l(!0),children:r.confirmLabel??"Confirm"})]})]})})}}},19881:(e,t,r)=>{"use strict";r.d(t,{i:()=>n});var s=r(9339);let n=(0,s.createServerReference)("40d3b782c1ec591e6e83b04cfd63707048ef88651a",s.callServer,void 0,s.findSourceMapURL,"deleteFileAction")},20555:(e,t,r)=>{"use strict";r.d(t,{LD:()=>s,LZ:()=>n,qQ:()=>a});let s=[{id:"c1",icon:"\uD83D\uDC64",category:"memory-sync",scenario:"first-day"},{id:"c2",icon:"\uD83D\uDCE5",category:"knowledge-management",scenario:"daily"},{id:"c3",icon:"\uD83D\uDD04",category:"memory-sync",scenario:"project"},{id:"c4",icon:"\uD83D\uDD01",category:"experience-evolution",scenario:"daily"},{id:"c5",icon:"\uD83D\uDCA1",category:"auto-execute",scenario:"daily"},{id:"c6",icon:"\uD83D\uDE80",category:"auto-execute",scenario:"project"},{id:"c7",icon:"\uD83D\uDD0D",category:"knowledge-management",scenario:"project"},{id:"c8",icon:"\uD83E\uDD1D",category:"human-insights",scenario:"daily"},{id:"c9",icon:"\uD83D\uDEE1️",category:"audit-control",scenario:"advanced"}],n=["knowledge-management","memory-sync","auto-execute","experience-evolution","human-insights","audit-control"],a=["first-day","daily","project","advanced"]},20814:(e,t,r)=>{"use strict";r.r(t),r.d(t,{ImageRenderer:()=>i});var s=r(95155),n=r(12115);let a=[.25,.5,.75,1,1.5,2,3,4];function i({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"image",i=r.split(".").pop()?.toLowerCase()??"",o=["png","svg","webp","ico","gif"].includes(i),[l,d]=(0,n.useState)(!0),[c,u]=(0,n.useState)(!1),[m,x]=(0,n.useState)(0),[p,h]=(0,n.useState)("fit"),[f,g]=(0,n.useState)(null),[b,v]=(0,n.useState)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(null),w=(0,n.useCallback)(()=>{d(!1);let e=y.current;e&&g({w:e.naturalWidth,h:e.naturalHeight})},[]),k=(0,n.useCallback)(()=>{d(!1),u(!0)},[]),N=(0,n.useCallback)(()=>{u(!1),d(!0),x(e=>e+1)},[]);(0,n.useEffect)(()=>{l||c||null!==b||fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&v(parseInt(t,10))}).catch(()=>{})},[t,l,c,b]);let S=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return a.find(e=>e>t)??t})},[]),C=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return[...a].reverse().find(e=>e<t)??t})},[]),A=(0,n.useCallback)(()=>{h(e=>"fit"===e?1:"fit")},[]);(0,n.useEffect)(()=>{let e=j.current;if(!e)return;let t=t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||(document.activeElement===document.body||e.contains(document.activeElement))&&(("+"===t.key||"="===t.key)&&(t.preventDefault(),S()),"-"===t.key&&(t.preventDefault(),C()),"0"===t.key&&(t.preventDefault(),h("fit")),"1"===t.key&&(t.preventDefault(),h(1)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[S,C]);let z="fit"===p?"Fit":`${Math.round(100*p)}%`,E="fit"===p?{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"}:f?{width:f.w*p,height:"auto"}:{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"};return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,s.jsxs)("span",{children:[f.w," x ",f.h]}),null!==b&&(0,s.jsx)("span",{children:b<1024?`${b} B`:b<1048576?`${(b/1024).toFixed(1)} KB`:`${(b/1048576).toFixed(1)} MB`}),(0,s.jsx)("span",{className:"uppercase opacity-60",children:i})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{onClick:C,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom out (-)",children:"-"}),(0,s.jsx)("button",{onClick:A,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors min-w-[48px] text-center disabled:opacity-30",title:"fit"===p?"Actual size (1)":"Fit to view (0)",children:z}),(0,s.jsx)("button",{onClick:S,disabled:!f,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom in (+)",children:"+"})]})]}),(0,s.jsxs)("div",{ref:j,tabIndex:-1,className:`relative flex-1 min-h-[70vh] overflow-auto flex items-center justify-center outline-none ${o?"bg-checkerboard":"bg-[var(--bg-secondary)]"}`,children:[l&&!c&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading..."})}),c&&(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center z-10 gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load image"}),(0,s.jsx)("button",{onClick:N,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,s.jsx)("img",{ref:y,src:t,alt:r,onLoad:w,onError:k,draggable:!1,className:"select-none",style:{display:c?"none":"block",...E}},m)]})]})}},20870:(e,t,r)=>{"use strict";r.r(t),r.d(t,{PdfRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,[r,a]=(0,n.useState)(!0),[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),c=(0,n.useCallback)(()=>{o(!1),a(!0),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full h-full min-h-[80vh] flex flex-col relative",children:[r&&!i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10",children:(0,s.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading PDF..."})}),i&&(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10 gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load PDF"}),(0,s.jsx)("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,s.jsx)("iframe",{src:t,className:"w-full flex-1 min-h-[80vh] border-0 rounded-lg bg-[var(--bg-secondary)]",title:e.split("/").pop()??"PDF",onLoad:()=>a(!1),onError:()=>{a(!1),o(!0)},style:{display:i?"none":"block"}},l)]})}},26490:(e,t,r)=>{"use strict";r.d(t,{default:()=>u});var s=r(95155),n=r(12115),a=r(94514),i=r(13545),o=r(68822),l=r(33210),d=r(4235);let c={success:(0,s.jsx)(a.A,{size:15,className:"text-success shrink-0"}),error:(0,s.jsx)(i.A,{size:15,className:"text-error shrink-0"}),info:(0,s.jsx)(o.A,{size:15,className:"text-muted-foreground shrink-0"})};function u(){let e=(0,n.useSyncExternalStore)(d.B1,d.dV,d.dV);return 0===e.length?null:(0,s.jsx)("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col-reverse gap-2 pointer-events-none",role:"status","aria-live":"polite","aria-atomic":"false",children:e.map(e=>(0,s.jsxs)("div",{className:"pointer-events-auto flex items-center gap-2.5 bg-card border border-border rounded-lg shadow-lg px-4 py-2.5 min-w-[180px] max-w-[320px] animate-in slide-in-from-right-4 fade-in duration-200",children:[c[e.type],(0,s.jsx)("span",{className:"text-sm text-foreground flex-1 truncate",children:e.message}),e.action&&(0,s.jsx)("button",{type:"button",onClick:()=>{e.action.onClick(),(0,d.X8)(e.id)},className:"shrink-0 px-2.5 py-1 rounded text-xs font-medium text-[var(--amber)] hover:bg-[var(--amber-dim)] transition-colors min-h-[28px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:e.action.label}),(0,s.jsx)("button",{type:"button",onClick:()=>(0,d.X8)(e.id),className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":e.action?.label?"Close":"Dismiss",children:(0,s.jsx)(l.A,{size:13})})]},e.id))})}},29494:(e,t,r)=>{"use strict";r.d(t,{Aw:()=>d,Nh:()=>u,QL:()=>i,TM:()=>o,h0:()=>l,lL:()=>c});var s=r(4235);function n(e){let t=new Uint8Array(e),r=[];for(let e=0;e<t.length;e+=8192)r.push(String.fromCharCode(...t.subarray(e,e+8192)));return btoa(r.join(""))}async function a(e){if(e.byteLength<524288||"u"<typeof Worker)return n(e);let t=e.slice(0);return new Promise(r=>{let s=new Blob([`
|
|
21
12
|
self.onmessage = function(e) {
|
|
22
13
|
try {
|
|
23
14
|
var bytes = new Uint8Array(e.data);
|
|
@@ -30,62 +21,11 @@ Keep content concise and actionable. Write files directly using tools.`;window.d
|
|
|
30
21
|
self.postMessage({ error: err.message || 'base64 encoding failed' });
|
|
31
22
|
}
|
|
32
23
|
};
|
|
33
|
-
`],{type:"application/javascript"}),a=URL.createObjectURL(s),i=new Worker(a),o=()=>{i.terminate(),URL.revokeObjectURL(a)},l=setTimeout(()=>{o(),r(n(t))},1e4);i.onmessage=e=>{clearTimeout(l),o(),"string"==typeof e.data?r(e.data):r(n(t))},i.onerror=()=>{clearTimeout(l),o(),r(n(t))},i.postMessage(e,[e])})}async function i(e,t){let r=[],n=0;for(let t of e){if(t.size>0xa00000){n++;continue}try{let e=t.name.toLowerCase(),s=e.endsWith(".doc")||e.endsWith(".docx")||e.endsWith(".docm");if(e.endsWith(".pdf")||s){let e=await t.arrayBuffer();r.push({name:t.name,content:await a(e),encoding:"base64"})}else{let e=await t.text();r.push({name:t.name,content:e})}}catch{}}if(0===r.length)return void(n>0?s.oR.error(t.inbox.tooLarge(n),4e3):e.length>0&&s.oR.error(t.inbox.saveFailed,4e3));try{var i;let e=await fetch("/api/inbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:r})});if(!e.ok){let r=await e.json().catch(()=>({}));console.error("[QuickDrop] Save failed:",r.error),s.oR.error(t.inbox.saveFailed,4e3);return}let a=await e.json(),o=a.saved?.length??0,l=a.skipped?.length??0;i=n,o>0&&i>0&&0===l?s.oR.success(t.inbox.savedWithOversized(o,i),4e3):o>0&&l+i>0?s.oR.success(t.inbox.savedWithSkipped(o,l+i),4e3):o>0?s.oR.success(t.inbox.savedToast(o),3e3):(i>0&&s.oR.error(t.inbox.tooLarge(i),4e3),l>0&&s.oR.error(t.inbox.savedWithSkipped(0,l),4e3),0===i&&0===l&&s.oR.error(t.inbox.saveFailed,4e3)),window.dispatchEvent(new Event("mindos:files-changed")),window.dispatchEvent(new Event("mindos:inbox-updated"))}catch(e){console.error("[QuickDrop] Network error:",e),s.oR.error(t.inbox.saveFailed,4e3)}}async function o(e,t){try{let r=await fetch("/api/inbox/clip",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}),n=await r.json();if(!r.ok){let e=n.error||t.inbox.clipFailed;return s.oR.error(e,4e3),{ok:!1}}return s.oR.success(t.inbox.clipSuccess(n.title||e),3e3),window.dispatchEvent(new Event("mindos:files-changed")),window.dispatchEvent(new Event("mindos:inbox-updated")),{ok:!0,title:n.title}}catch(e){return console.error("[ClipURL] Network error:",e),s.oR.error(t.inbox.clipFailed,4e3),{ok:!1}}}function l(e){let t=e.trim();if(!t.startsWith("http://")&&!t.startsWith("https://"))return!1;try{return new URL(t),!0}catch{return!1}}function d(e){if(e.dataTransfer?.files&&e.dataTransfer.files.length>0)return null;let t=e.dataTransfer?.getData("text/uri-list");if(t){let e=t.split(/[\r\n]+/).find(e=>!e.startsWith("#")&&e.trim().length>0);if(e&&l(e))return e.trim()}let r=e.dataTransfer?.getData("text/plain");return r&&l(r)?r.trim():null}function c(e){let t=e.dataTransfer?.types??[];return!t.includes("Files")&&(t.includes("text/uri-list")||t.includes("text/plain"))}async function u(e,t,r){let n=[],i=0,o=new Set(["pdf","png","jpg","jpeg","gif","webp","bmp","ico","mp3","wav","m4a","ogg","flac","aac","mp4","webm","mov","mkv","doc","docx","docm"]);for(let t of e){if(t.size>0xa00000){i++;continue}try{let e=(t.name.split(".").pop()??"").toLowerCase();if(o.has(e)){let e=await t.arrayBuffer();n.push({name:t.name,content:await a(e),encoding:"base64"})}else{let e=await t.text();n.push({name:t.name,content:e})}}catch{}}if(0===n.length)return void(i>0?s.oR.error(r.inbox.tooLarge(i),4e3):e.length>0&&s.oR.error(r.inbox.saveFailed,4e3));let l=t.split("/").pop()||t;try{let e=await fetch("/api/file/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:n,targetSpace:t,organize:!1,conflict:"rename"})});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[TreeDrop] Save failed:",t.error),s.oR.error(r.inbox.saveFailed,4e3);return}let a=await e.json(),o=a.created?.length??0,d=a.skipped?.length??0;o>0&&d+i>0?s.oR.success(r.inbox.savedWithSkipped(o,d+i),4e3):o>0?s.oR.success(r.inbox.savedToDir(o,l),3e3):(i>0&&s.oR.error(r.inbox.tooLarge(i),4e3),d>0&&s.oR.error(r.inbox.savedWithSkipped(0,d),4e3)),window.dispatchEvent(new Event("mindos:files-changed"))}catch(e){console.error("[TreeDrop] Network error:",e),s.oR.error(r.inbox.saveFailed,4e3)}}},30266:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,66872,23)),Promise.resolve().then(r.bind(r,92524)),Promise.resolve().then(r.bind(r,86343)),Promise.resolve().then(r.bind(r,18847)),Promise.resolve().then(r.bind(r,14446)),Promise.resolve().then(r.bind(r,88946)),Promise.resolve().then(r.bind(r,57025)),Promise.resolve().then(r.bind(r,35504)),Promise.resolve().then(r.bind(r,92306)),Promise.resolve().then(r.bind(r,92950)),Promise.resolve().then(r.bind(r,20814)),Promise.resolve().then(r.bind(r,20870)),Promise.resolve().then(r.bind(r,56406)),Promise.resolve().then(r.bind(r,39594)),Promise.resolve().then(r.bind(r,78660)),Promise.resolve().then(r.bind(r,87986)),Promise.resolve().then(r.bind(r,48133)),Promise.resolve().then(r.bind(r,86464)),Promise.resolve().then(r.bind(r,26490)),Promise.resolve().then(r.bind(r,91459)),Promise.resolve().then(r.bind(r,40430)),Promise.resolve().then(r.bind(r,98959)),Promise.resolve().then(r.bind(r,93042)),Promise.resolve().then(r.t.bind(r,16719,23)),Promise.resolve().then(r.t.bind(r,377,23)),Promise.resolve().then(r.t.bind(r,98663,23)),Promise.resolve().then(r.t.bind(r,75282,23))},35504:(e,t,r)=>{"use strict";r.r(t),r.d(t,{ConfigRenderer:()=>d});var s=r(95155),n=r(12115),a=r(6296),i=r(94514),o=r(33210),l=r(51914);function d({content:e,saveAction:t}){let r=(0,n.useMemo)(()=>{try{return JSON.parse(e)}catch{return null}},[e]),[d,c]=(0,n.useState)(r),[u,m]=(0,n.useState)(!1),[x,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)({});(0,n.useEffect)(()=>{c(r),f("")},[r]);let v=d??{},y=v.uiSchema?.sections??[],j=v.keySpecs??{},w=(0,n.useCallback)(async e=>{m(!0),p(!1),f("");try{await t(`${JSON.stringify(e,null,2)}
|
|
34
|
-
`),p(!0),setTimeout(()=>p(!1),1200)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{m(!1)}},[t]),k=(0,n.useCallback)(async(e,t)=>{if(!d)return;let r=function(e,t,r){let s=t.split("."),n=structuredClone(e),a=n;for(let e=0;e<s.length-1;e++){let t=s[e],r=a[t];(!r||"object"!=typeof r||Array.isArray(r))&&(a[t]={}),a=a[t]}return a[s[s.length-1]]=r,n}(d,e,t);c(r),await w(r)},[d,w]);return r&&d?(0,s.jsxs)("div",{className:"max-w-3xl mx-auto flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-border bg-card px-4 py-2.5",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"CONFIG Control Panel"}),(0,s.jsxs)("div",{className:"text-xs flex items-center gap-2",children:[u&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[(0,s.jsx)(a.A,{size:12,className:"animate-spin"}),"Saving"]}),!u&&x&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",style:{color:"var(--success)"},children:[(0,s.jsx)(i.A,{size:12}),"Saved"]})]})]}),h&&(0,s.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/10 px-3 py-2 text-xs text-error",children:h}),y.map(e=>(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:e.title}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e.description})]}),(0,s.jsx)("div",{className:"space-y-3",children:e.fields.map(e=>{let t=j[e]??{},r=function(e,t){let r=t.split("."),s=e;for(let e of r){if(!s||"object"!=typeof s||!(e in s))return null;s=s[e]}return s}(d,e),n=t.label||e;return(0,s.jsxs)("div",{className:"rounded-lg border border-border/80 bg-background px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-foreground",children:n}),t.description&&(0,s.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),"switch"===t.control&&"boolean"==typeof r&&(0,s.jsx)("button",{type:"button",onClick:()=>k(e,!r),className:"px-2.5 py-1 rounded-md text-xs font-medium",style:{background:r?"var(--amber)":"var(--muted)",color:r?"var(--amber-foreground)":"var(--muted-foreground)"},children:r?"ON":"OFF"})]}),"text"===t.control&&"string"==typeof r&&(0,s.jsx)("input",{defaultValue:r,onBlur:t=>k(e,t.target.value),className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"number"===t.control&&"number"==typeof r&&(0,s.jsx)("input",{type:"number",defaultValue:r,min:t.constraints?.min,max:t.constraints?.max,onBlur:s=>{let n=Number(s.target.value),a=t.constraints?.min,i=t.constraints?.max,o=Number.isFinite(n)?n:r;"number"==typeof a&&o<a&&(o=a),"number"==typeof i&&o>i&&(o=i),k(e,o)},className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"tag-list"===t.control&&Array.isArray(r)&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map((t,n)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded border border-border text-xs bg-muted text-foreground",children:[String(t),(0,s.jsx)("button",{type:"button",onClick:()=>k(e,r.filter((e,t)=>t!==n)),className:"text-muted-foreground hover:text-foreground",children:(0,s.jsx)(o.A,{size:11})})]},`${String(t)}-${n}`))}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{value:g[e]??"",onChange:t=>b(r=>({...r,[e]:t.target.value})),onKeyDown:t=>{if("Enter"!==t.key)return;t.preventDefault();let s=(g[e]??"").trim();s&&(k(e,[...r,s]),b(t=>({...t,[e]:""})))},className:"flex-1 px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground",placeholder:"Add item"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let t=(g[e]??"").trim();t&&(k(e,[...r,t]),b(t=>({...t,[e]:""})))},className:"px-2.5 py-1.5 rounded-md text-xs bg-muted text-foreground inline-flex items-center gap-1",children:[(0,s.jsx)(l.A,{size:12})," Add"]})]})]})]},e)})})]},e.id))]}):(0,s.jsx)("div",{className:"rounded-xl border border-border p-4 text-sm text-error",children:"CONFIG.json parse failed. Please check JSON format."})}},39594:(e,t,r)=>{"use strict";r.r(t),r.d(t,{TimelineRenderer:()=>l});var s=r(95155),n=r(12115);let a=/(\d{4}[-/]\d{1,2}(?:[-/]\d{1,2})?|[A-Za-z]+ \d{4}|\d{4}年\d{1,2}月(?:\d{1,2}日)?)/;function i(e){return e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:0.85em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,t,r)=>`<span style="color:var(--amber);cursor:pointer" title="${t}">${r??t}</span>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" style="color:var(--amber)">$1</a>')}let o=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"var(--tool-read)"},{bg:"rgba(200,160,216,0.12)",text:"var(--tool-search)"}];function l({content:e}){let t=(0,n.useMemo)(()=>(function(e){let t=e.split("\n"),r=[],s=null,n=[],i=()=>{let e,t;if(!s)return;let a=n.join("\n").trim();s.body=a,s.tags=(e=[],(t=a.match(/#([\w\u4e00-\u9fff]+)/g))&&e.push(...t.map(e=>e.slice(1))),[...new Set(e)]),r.push(s),s=null,n=[]};for(let e of t)if(!/^# /.test(e)){if(/^## /.test(e)){i();let t=e.slice(3).trim();s={heading:t,date:function(e){let t=a.exec(e);if(!t)return null;let r=new Date(t[1].replace(/[/年月]/g,"-").replace("日",""));return isNaN(r.getTime())?null:r}(t),body:"",tags:[]};continue}s&&n.push(e)}return i(),r})(e),[e]);return 0===t.length?(0,s.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:["No timeline entries found. Add ",(0,s.jsx)("code",{style:{background:"var(--muted)",padding:"1px 6px",borderRadius:4},children:"## 2025-01-15"})," headings to create entries."]}):(0,s.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,s.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[t.length," ",1===t.length?"entry":"entries"]})}),(0,s.jsxs)("div",{style:{position:"relative",paddingLeft:28},children:[(0,s.jsx)("div",{style:{position:"absolute",left:6,top:8,bottom:8,width:1,background:"var(--border)"}}),t.map((e,t)=>(0,s.jsxs)("div",{style:{position:"relative",marginBottom:"1.5rem"},children:[(0,s.jsx)("div",{style:{position:"absolute",left:-22,top:10,width:9,height:9,borderRadius:"50%",background:e.date?"var(--amber)":"var(--border)",outline:e.date?"2px solid var(--amber-dim)":"none",zIndex:1}}),(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,padding:"14px 18px",transition:"border-color .15s"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:8},children:[(0,s.jsx)("span",{style:{fontWeight:600,fontSize:"0.9rem",color:"var(--foreground)"},children:e.heading}),e.date&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.7rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0},children:e.date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})})]}),e.body&&(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:function(e){let t=e.split("\n"),r=[],s=!1,n=()=>{s&&(r.push("</ul>"),s=!1)};for(let e of t){let t=e.trimEnd();if(!t){n(),r.push("<br/>");continue}if(/^### /.test(t)){n(),r.push(`<h3 style="font-size:0.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:.9em 0 .3em">${i(t.slice(4))}</h3>`);continue}if(/^- /.test(t)||/^\* /.test(t)){s||(r.push('<ul style="margin:.3em 0;padding-left:1.2em;list-style:disc">'),s=!0),r.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${i(t.slice(2))}</li>`);continue}if(/^\d+\. /.test(t)){s||(r.push('<ol style="margin:.3em 0;padding-left:1.2em">'),s=!0),r.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${i(t.replace(/^\d+\. /,""))}</li>`);continue}n(),r.push(`<p style="margin:.25em 0;font-size:.82rem;line-height:1.6;color:var(--foreground)">${i(t)}</p>`)}return n(),r.join("")}(e.body)}}),e.tags.length>0&&(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginTop:10},children:e.tags.map(e=>{let t=function(e){let t=0;for(let r=0;r<e.length;r++)t=31*t+e.charCodeAt(r)&65535;return o[t%o.length]}(e);return(0,s.jsxs)("span",{className:"font-display",style:{fontSize:"0.68rem",padding:"1px 8px",borderRadius:999,background:t.bg,color:t.text},children:["#",e]},e)})})]})]},t))]})]})}},40430:(e,t,r)=>{"use strict";r.d(t,{default:()=>d});var s=r(95155),n=r(12115),a=r(12651),i=r(6296),o=r(35581);let l="mindos_update_in_progress";function d(){let[e,t]=(0,n.useState)(!1),[r,d]=(0,n.useState)(!1),c=(0,n.useRef)(void 0),{locale:u}=(0,o.Y)(),m="zh"===u,x=(0,n.useCallback)(()=>{c.current=setInterval(async()=>{try{if((await fetch("/api/health",{signal:AbortSignal.timeout(3e3)})).ok){clearInterval(c.current),c.current=void 0;try{let e=localStorage.getItem(l);if(e){let{originalVer:t}=JSON.parse(e),r=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)}).then(e=>e.json());if(r.current&&r.current!==t){d(!0),localStorage.removeItem(l),localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),setTimeout(()=>window.location.reload(),1500);return}}}catch{}localStorage.removeItem(l),window.location.reload()}}catch{}},3e3)},[]);return((0,n.useEffect)(()=>{let e=()=>{localStorage.getItem(l)&&(t(!0),c.current||x())};e();let r=()=>e();return window.addEventListener("mindos:update-started",r),window.addEventListener("storage",r),()=>{clearInterval(c.current),c.current=void 0,window.removeEventListener("mindos:update-started",r),window.removeEventListener("storage",r)}},[x]),e)?(0,s.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-ui)"},children:[r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.A,{size:32,style:{color:"var(--success)",marginBottom:12}}),(0,s.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"更新成功!":"Update Complete!"}),(0,s.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6},children:m?"正在刷新页面...":"Reloading..."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{size:32,style:{color:"var(--amber)",marginBottom:12,animation:"spin 1s linear infinite"}}),(0,s.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"MindOS 正在更新...":"MindOS is Updating..."}),(0,s.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6,textAlign:"center",maxWidth:300,lineHeight:1.5},children:m?"服务正在重启,请勿关闭此页面。完成后将自动刷新。":"The server is restarting. Please do not close this page. It will auto-reload when ready."})]}),(0,s.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]}):null}},40674:(e,t,r)=>{"use strict";r.d(t,{f:()=>n});var s=r(9339);let n=(0,s.createServerReference)("602da3913f00023ea20b407093d3910fa8cd023abd",s.callServer,void 0,s.findSourceMapURL,"renameFileAction")},46838:(e,t,r)=>{"use strict";r.d(t,{$7:()=>i,MZ:()=>c,TS:()=>l,UG:()=>a,YB:()=>d,pl:()=>o});let s=[],n=new Set;function a(){try{let e=localStorage.getItem("mindos-disabled-renderers");n=new Set(e?JSON.parse(e):[])}catch{n=new Set}}function i(e,t){let r=s.find(t=>t.id===e);r?.core||(t?n.delete(e):n.add(e),localStorage.setItem("mindos-disabled-renderers",JSON.stringify([...n])))}function o(e){let t=s.find(t=>t.id===e);return!!t?.core||!n.has(e)}function l(e){s.find(t=>t.id===e.id)||s.push(e)}function d(e,t,r){if(r){let e=s.find(e=>e.id===r);return e&&o(e.id)?e:void 0}return s.find(r=>o(r.id)&&r.match({filePath:e,extension:t}))}function c(){return s.filter(e=>!e.appBuiltinFeature)}},48133:(e,t,r)=>{"use strict";r.r(t),r.d(t,{WorkflowYamlRenderer:()=>ee});var s=r(95155),n=r(12115),a=r(49387),i=r(20232),o=r(53961),l=r(13545),d=r(73620),c=r(42129),u=r(51914),m=r(6296),x=r(55243),p=r(12651),h=r(66088),f=r(9921),g=r(68459),b=r(1164),v=r(61878),y=r(33210),j=r(48368),w=r(38798),k=r(21362);function N({trigger:e,children:t,open:r,onClose:a}){let i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!r)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,a]),(0,s.jsxs)("div",{ref:i,className:"relative",children:[e,r&&(0,s.jsx)("div",{className:"absolute top-full left-0 mt-1 w-full min-w-[220px] max-h-[260px] overflow-y-auto bg-card border border-border rounded-lg shadow-lg z-50",children:t})]})}let S=null,C=!1,A=[];function z({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),[l,d]=(0,n.useState)(S??[]),[c,u]=(0,n.useState)("");(0,n.useEffect)(()=>{S?d(S):(A.push(d),C||(C=!0,fetch("/api/acp/registry").then(e=>e.json()).then(e=>{let t=(e.registry?.agents??[]).map(e=>({id:e.id,name:e.name||e.id}));S=t,A.forEach(e=>e(t)),A.length=0}).catch(()=>{S=[],A.forEach(e=>e([])),A.length=0})))},[]);let m=c?l.filter(e=>e.id.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())):l,x=e=>{t(e),a(!1),u("")},p=e?l.find(t=>t.id===e)?.name||e:void 0;return(0,s.jsxs)(N,{open:r,onClose:()=>{a(!1),u("")},trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:p||"MindOS"}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,s.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,s.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("input",{type:"text",value:c,onChange:e=>u(e.target.value),autoFocus:!0,placeholder:"Search agents...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),(0,s.jsxs)("button",{onClick:()=>x(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-foreground"}`,children:["MindOS ",(0,s.jsx)("span",{className:"text-muted-foreground/50 ml-1",children:"(default)"})]}),m.slice(0,30).map(t=>(0,s.jsxs)("button",{onClick:()=>x(t.id),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t.id?"text-[var(--amber)] font-medium":"text-foreground"}`,children:[t.name," ",t.name!==t.id&&(0,s.jsxs)("span",{className:"text-muted-foreground/50 ml-1",children:["(",t.id,")"]})]},t.id)),0===l.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),l.length>0&&0===m.length&&!c&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No ACP agents found"}),(0,s.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(x(i.trim()),o(""))},placeholder:"Custom agent ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let E=[{group:"Anthropic",models:["claude-sonnet-4-6","claude-opus-4","claude-3.5-sonnet","claude-3.5-haiku"]},{group:"OpenAI",models:["gpt-4o","gpt-4o-mini","o3","o4-mini"]},{group:"Google",models:["gemini-2.5-pro","gemini-2.5-flash"]}];function T({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),l=e=>{t(e),a(!1)};return(0,s.jsxs)(N,{open:r,onClose:()=>a(!1),trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:e||"Default model"}),e?(0,s.jsx)(y.A,{size:12,className:"text-muted-foreground shrink-0 hover:text-foreground cursor-pointer",onClick:e=>{e.stopPropagation(),l(void 0)}}):(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,s.jsx)("button",{onClick:()=>l(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-muted-foreground"}`,children:"(default)"}),E.map(t=>(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"px-3 py-1 text-2xs font-semibold text-muted-foreground/60 uppercase tracking-wide bg-muted/30",children:t.group}),t.models.map(t=>(0,s.jsx)("button",{onClick:()=>l(t),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t?"text-[var(--amber)] font-medium":"text-foreground"}`,children:t},t))]},t.group)),(0,s.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(l(i.trim()),o(""))},placeholder:"Custom model ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let $=null,D=!1,R=[];function M({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)($??[]),[l,d]=(0,n.useState)("");(0,n.useEffect)(()=>{$?o($):(R.push(o),D||(D=!0,fetch("/api/skills").then(e=>e.json()).then(e=>{$=(e.skills??[]).map(e=>({name:e.name,description:e.description})),R.forEach(e=>e($)),R.length=0}).catch(()=>{$=[],R.forEach(e=>e([])),R.length=0})))},[]);let c=l?i.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())):i;return(0,s.jsxs)("div",{children:[e.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1 mb-1.5",children:e.map(r=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-md text-2xs bg-[var(--amber)]/10 text-[var(--amber)] border border-[var(--amber)]/20",children:[r,(0,s.jsx)("button",{onClick:()=>t(e.filter(e=>e!==r)),className:"p-0.5 rounded hover:bg-[var(--amber)]/20 transition-colors",children:(0,s.jsx)(y.A,{size:10})})]},r))}),(0,s.jsxs)(N,{open:r,onClose:()=>{a(!1),d("")},trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:0===e.length?"Add skills...":`${e.length} selected`}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground"})]}),children:[(0,s.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,s.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("input",{type:"text",value:l,onChange:e=>d(e.target.value),autoFocus:!0,placeholder:"Search skills...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),c.slice(0,60).map(r=>{let n=e.includes(r.name);return(0,s.jsxs)("button",{onClick:()=>{var s;return s=r.name,void(e.includes(s)?t(e.filter(e=>e!==s)):t([...e,s]))},className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2 ${n?"bg-[var(--amber)]/5":""}`,children:[(0,s.jsx)("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0 transition-colors ${n?"bg-[var(--amber)] border-[var(--amber)] text-[var(--amber-foreground)]":"border-border"}`,children:n&&(0,s.jsx)("span",{className:"text-[9px]",children:"✓"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate",children:r.name}),r.description&&(0,s.jsx)("span",{className:"block text-2xs text-muted-foreground truncate mt-0.5",children:r.description})]})]},r.name)}),0===i.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),i.length>0&&0===c.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No skills found"})]})]})}function P({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),l=(0,n.useCallback)(r=>{let s=r.trim();s&&!e.includes(s)&&t([...e,s])},[e,t]),d=(0,n.useCallback)(e=>{e.preventDefault(),a(!1);let t=e.dataTransfer.getData("text/mindos-path");if(t)return void l(t);let r=e.dataTransfer.getData("text/plain");r&&l(r)},[l]),u=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy",a(!0)},[]),m=(0,n.useCallback)(()=>a(!1),[]);return(0,s.jsxs)("div",{children:[e.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-1 mb-1.5",children:e.map(r=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 pl-2 pr-1 py-1 rounded-md text-2xs bg-muted/60 border border-border group",children:[(0,s.jsx)(j.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"text-foreground truncate flex-1",title:r,children:r}),(0,s.jsx)("button",{onClick:()=>t(e.filter(e=>e!==r)),className:"p-0.5 rounded hover:bg-[var(--error)]/10 text-muted-foreground hover:text-[var(--error)] opacity-0 group-hover:opacity-100 transition-all",children:(0,s.jsx)(y.A,{size:10})})]},r))}),(0,s.jsxs)("div",{onDrop:d,onDragOver:u,onDragLeave:m,className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 border-dashed transition-colors ${r?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:border-muted-foreground/30"}`,children:[(0,s.jsx)(c.A,{size:14,className:`shrink-0 ${r?"text-[var(--amber)]":"text-muted-foreground/40"}`}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground",children:"Drag files here from the sidebar"})]}),(0,s.jsx)("div",{className:"mt-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(l(i.trim()),o(""))},placeholder:"Or type a file path...",className:"w-full px-2.5 py-1 text-2xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}async function F(e){try{let t=await fetch("/api/setup/ls",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e||"~"})});if(!t.ok)return[];return(await t.json()).dirs??[]}catch{return[]}}function L({value:e,onChange:t}){let[r,a]=(0,n.useState)([]),[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(-1),u=(0,n.useRef)(!1),m=(0,n.useRef)(null),[x,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(e||"~"),[g,b]=(0,n.useState)([]),[v,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(u.current){u.current=!1;return}if(!e.trim()){a([]),o(!1);return}let t=setTimeout(async()=>{let t=function(e){let t=e.trim();if(!t)return"";if(t.endsWith("/")||t.endsWith("\\"))return t;let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r>=0?t.slice(0,r+1):""}(e)||"~",r=await F(t);if(!r.length){a([]),o(!1);return}let s=t.includes("\\")?"\\":"/",n=t.endsWith("/")||t.endsWith("\\")?t:t+s,i=r.map(e=>n+e),l=e.endsWith("/")||e.endsWith("\\")?i:i.filter(t=>t.startsWith(e.trim()));a(l.slice(0,15)),o(l.length>0),d(-1)},300);return()=>clearTimeout(t)},[e]);let j=()=>{a([]),o(!1),d(-1)},S=e=>{u.current=!0,t(e),j(),m.current?.focus()},C=(0,n.useCallback)(async e=>{y(!0),b(await F(e)),y(!1)},[]);return(0,n.useEffect)(()=>{x&&C(h)},[x,h,C]),(0,s.jsxs)("div",{className:"relative flex gap-1.5",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)("input",{ref:m,type:"text",value:e,onChange:e=>{t(e.target.value),o(!0)},onKeyDown:e=>{i&&0!==r.length&&("ArrowDown"===e.key?(e.preventDefault(),d(e=>Math.min(e+1,r.length-1))):"ArrowUp"===e.key?(e.preventDefault(),d(e=>Math.max(e-1,-1))):"Enter"===e.key&&l>=0?(e.preventDefault(),S(r[l])):"Escape"===e.key?j():"Tab"===e.key&&l>=0&&(e.preventDefault(),S(r[l])))},onBlur:()=>setTimeout(j,150),onFocus:()=>r.length>0&&o(!0),placeholder:"~/projects/my-app",className:"w-full px-2.5 py-1.5 text-xs rounded-lg border border-border bg-background text-foreground font-mono placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),i&&r.length>0&&(0,s.jsx)("div",{role:"listbox",className:"absolute z-50 left-0 right-0 top-full mt-1 rounded-lg border border-border bg-card shadow-lg overflow-auto max-h-[200px]",children:r.map((e,t)=>(0,s.jsxs)("button",{type:"button",role:"option","aria-selected":t===l,onMouseDown:()=>S(e),className:`w-full text-left px-3 py-1.5 text-xs font-mono transition-colors flex items-center gap-1.5 ${t===l?"bg-muted text-foreground":"text-foreground hover:bg-muted/50"}`,children:[(0,s.jsx)(w.A,{size:11,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e})]},e))})]}),(0,s.jsxs)(N,{open:x,onClose:()=>p(!1),trigger:(0,s.jsx)("button",{type:"button",onClick:()=>{f(e||"~"),p(e=>!e)},className:"px-2 py-1.5 rounded-lg border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",title:"Browse directories",children:(0,s.jsx)(c.A,{size:13})}),children:[(0,s.jsxs)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-2 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-2xs font-mono text-muted-foreground truncate flex-1",title:h,children:h}),(0,s.jsx)("button",{onClick:()=>{t(h),p(!1)},className:"px-2 py-0.5 text-2xs rounded font-medium bg-[var(--amber)] text-[var(--amber-foreground)] shrink-0",children:"Select"})]}),"~"!==h&&(0,s.jsxs)("button",{onClick:()=>{let e=h.split("/");e.length<=1||(e.pop(),f(e.join("/")||"~"))},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-muted-foreground flex items-center gap-1.5",children:[(0,s.jsx)(w.A,{size:12,className:"shrink-0"})," .."]}),v&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),!v&&0===g.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No subdirectories"}),g.map(e=>(0,s.jsxs)("button",{onClick:()=>{f("~"===h?`~/${e}`:`${h.replace(/\/+$/,"")}/${e}`)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-foreground flex items-center gap-1.5",children:[(0,s.jsx)(w.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e}),(0,s.jsx)(k.A,{size:10,className:"text-muted-foreground/40 shrink-0"})]},e))]})]})}function I({step:e,index:t,onChange:r,onDelete:a,onMoveUp:i,onMoveDown:o}){let[l,d]=(0,n.useState)(!e.prompt),[c,u]=(0,n.useState)(!1),m=t=>r({...e,...t}),x=e.skills?.length?e.skills:e.skill?[e.skill]:[],p=!!(e.agent||e.model||x.length||e.context?.length||e.description||e.timeout);return l?(0,s.jsxs)("div",{className:"rounded-lg border border-[var(--amber)]/20 bg-card overflow-hidden shadow-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/20",children:[(0,s.jsx)("span",{className:`text-xs font-medium flex-1 truncate ${e.name?"text-foreground":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[i&&(0,s.jsx)("button",{onClick:i,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move up",children:(0,s.jsx)(f.A,{size:12})}),o&&(0,s.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move down",children:(0,s.jsx)(h.A,{size:12})}),(0,s.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-[var(--error)]/10 text-muted-foreground/50 hover:text-[var(--error)] transition-colors",title:"Delete",children:(0,s.jsx)(g.A,{size:11})}),(0,s.jsx)("button",{onClick:()=>d(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground/50 transition-colors",title:"Collapse",children:(0,s.jsx)(f.A,{size:12})})]})]}),(0,s.jsxs)("div",{className:"px-3 py-3 space-y-3",children:[(0,s.jsx)("input",{type:"text",value:e.name,onChange:e=>m({name:e.target.value}),placeholder:"Step name...",autoFocus:!e.name,className:"w-full text-sm font-medium bg-transparent text-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,s.jsx)("textarea",{value:e.prompt,onChange:e=>m({prompt:e.target.value}),placeholder:"What should the AI do?",rows:3,className:"w-full px-3 py-2.5 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y leading-relaxed"}),(0,s.jsxs)("div",{className:`grid ${e.agent?"grid-cols-2":"grid-cols-1"} gap-2`,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Agent"}),(0,s.jsx)(z,{value:e.agent,onChange:t=>m({agent:t,model:t?e.model:void 0})})]}),e.agent&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Model"}),(0,s.jsx)(T,{value:e.model,onChange:e=>m({model:e})})]})]}),(0,s.jsxs)("button",{onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 text-2xs transition-colors ${c||p?"text-muted-foreground":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:[(0,s.jsx)(b.A,{size:11}),c?"Less options":"More options",!c&&p&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)]"})]}),c&&(0,s.jsxs)("div",{className:"space-y-3 pt-1",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Skills"}),(0,s.jsx)(M,{value:x,onChange:e=>m({skills:e,skill:void 0})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Context files"}),(0,s.jsx)(P,{value:e.context??[],onChange:e=>m({context:e.length?e:void 0})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[1fr,auto] gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Description"}),(0,s.jsx)("input",{type:"text",value:e.description||"",onChange:e=>m({description:e.target.value||void 0}),placeholder:"Optional note...",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Timeout"}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{type:"number",min:0,value:e.timeout||"",onChange:e=>m({timeout:e.target.value?Number(e.target.value):void 0}),placeholder:"120",className:"w-16 px-2 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/40",children:"s"})]})]})]})]})]})]}):(0,s.jsxs)("div",{className:"group flex items-start gap-2 px-3 py-2 rounded-lg hover:bg-muted/40 transition-colors cursor-pointer -ml-1",onClick:()=>d(!0),children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:`text-sm leading-tight block ${e.name?"text-foreground font-medium":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),p&&(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1 flex-wrap",children:[e.agent&&(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground",children:e.agent}),x.slice(0,2).map(e=>(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-[var(--amber)]/8 text-[var(--amber)]",children:e},e)),x.length>2&&(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:["+",x.length-2]}),e.context?.length?(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:[e.context.length," files"]}):null]}),e.prompt&&(0,s.jsx)("p",{className:"text-2xs text-muted-foreground/50 mt-1 line-clamp-1 leading-relaxed",children:e.prompt})]}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground/30 mt-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"})]})}var O=r(19550);function W({workflow:e,filePath:t,onChange:r,onSaved:a}){let[i,l]=(0,n.useState)(!1),[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)(!1),{confirm:v,ConfirmDialog:y}=(0,O.G)();(0,n.useEffect)(()=>{if(!g)return;let e=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(e)},[g]);let j=t=>r({...e,...t}),w=(0,n.useCallback)((t,s)=>{let n=[...e.steps];n[t]=s,r({...e,steps:n})},[e,r]),k=(0,n.useCallback)(async t=>{let s=e.steps[t];(!s.name&&!s.prompt||await v({title:`Delete step "${s.name||"Untitled"}"?`,variant:"destructive",confirmLabel:"Delete"}))&&r({...e,steps:e.steps.filter((e,r)=>r!==t)})},[e,r,v]),N=(0,n.useCallback)(()=>{let t=e.steps.map(e=>e.id),s=e.steps.length+1,n={id:function(e,t){let r=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"step",s=r,n=2;for(;t.includes(s);)s=`${r}-${n}`,n++;return s}(`step-${s}`,t),name:`Step ${s}`,prompt:""};r({...e,steps:[...e.steps,n]})},[e,r]),S=(0,n.useCallback)((t,s)=>{if(s<0||s>=e.steps.length)return;let n=[...e.steps],[a]=n.splice(t,1);n.splice(s,0,a),r({...e,steps:n})},[e,r]),C=async()=>{l(!0),f(""),b(!1);try{let r,s=(r={title:e.title},e.description&&(r.description=e.description),e.workDir&&(r.workDir=e.workDir),e.skills?.length&&(r.skills=e.skills),e.tools?.length&&(r.tools=e.tools),r.steps=e.steps.map(e=>{let t={id:e.id,name:e.name};return e.description&&(t.description=e.description),e.agent&&(t.agent=e.agent),e.model&&(t.model=e.model),e.skill&&(t.skill=e.skill),e.skills?.length&&(t.skills=e.skills),e.tools?.length&&(t.tools=e.tools),e.context?.length&&(t.context=e.context),t.prompt=e.prompt,e.timeout&&(t.timeout=e.timeout),t}),d.Ay.dump(r,{lineWidth:-1,noRefs:!0,quotingType:'"',forceQuotes:!1})),n=await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,op:"save_file",content:s})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Save failed (HTTP ${n.status})`)}b(!0),a?.()}catch(e){f(e instanceof Error?e.message:"Save failed")}finally{l(!1)}};(0,n.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&"s"===t.key&&(t.preventDefault(),!i&&e.title.trim()&&e.steps.length>0&&C())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)});let A=!i&&!!e.title.trim()&&e.steps.length>0;return(0,s.jsxs)("div",{children:[y,(0,s.jsxs)("div",{className:"space-y-3 mb-8",children:[(0,s.jsx)("input",{type:"text",value:e.title,onChange:e=>j({title:e.target.value}),placeholder:"Flow title...",className:"w-full text-lg font-semibold bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none border-none p-0 leading-tight"}),(0,s.jsx)("input",{type:"text",value:e.description||"",onChange:e=>j({description:e.target.value||void 0}),placeholder:"Add a description...",className:"w-full text-sm bg-transparent text-muted-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(c.A,{size:12,className:"text-muted-foreground/40 shrink-0"}),(0,s.jsx)(L,{value:e.workDir||"",onChange:e=>j({workDir:e||void 0})})]})]}),e.steps.length>0?(0,s.jsxs)("div",{className:"relative",children:[e.steps.length>1&&(0,s.jsx)("div",{className:"absolute left-[19px] top-6 bottom-16 w-px bg-border"}),(0,s.jsx)("div",{className:"flex flex-col gap-3 mb-5 relative",children:e.steps.map((t,r)=>(0,s.jsxs)("div",{className:"relative pl-11",children:[(0,s.jsx)("div",{className:"absolute left-[7px] top-3 w-[22px] h-[22px] rounded-full border-2 border-border bg-background z-10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-[10px] font-bold text-muted-foreground/60",children:r+1})}),(0,s.jsx)(I,{step:t,index:r,onChange:e=>w(r,e),onDelete:()=>k(r),onMoveUp:r>0?()=>S(r,r-1):void 0,onMoveDown:r<e.steps.length-1?()=>S(r,r+1):void 0})]},t.id))}),(0,s.jsxs)("div",{className:"relative pl-11",children:[(0,s.jsx)("div",{className:"absolute left-[7px] top-2.5 w-[22px] h-[22px] rounded-full border-2 border-dashed border-border bg-background z-10 flex items-center justify-center",children:(0,s.jsx)(u.A,{size:9,className:"text-muted-foreground/40"})}),(0,s.jsx)("button",{onClick:N,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/40 transition-colors",children:"Add step..."})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-2xl bg-[var(--amber)]/8 flex items-center justify-center mb-4",children:(0,s.jsx)(o.A,{size:22,className:"text-[var(--amber)]/60"})}),(0,s.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"Build your flow"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/60 mb-5 max-w-[240px]",children:"Each step is a task for an AI agent. Chain them together to automate complex workflows."}),(0,s.jsxs)("button",{onClick:N,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:[(0,s.jsx)(u.A,{size:12}),"Add first step"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 mt-8 pt-4 border-t border-border/50",children:[(0,s.jsxs)("button",{onClick:C,disabled:!A,title:e.title.trim()?0===e.steps.length?"Add at least one step":void 0:"Title is required",className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed ${A?"bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90":"bg-muted text-muted-foreground"}`,children:[i?(0,s.jsx)(m.A,{size:12,className:"animate-spin"}):(0,s.jsx)(x.A,{size:12}),i?"Saving...":"Save"]}),h&&(0,s.jsx)("span",{className:"text-xs text-[var(--error)]",children:h}),g&&!h&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-2xs text-[var(--success)]",children:[(0,s.jsx)(p.A,{size:11}),"Saved"]}),(0,s.jsx)("kbd",{className:"text-2xs text-muted-foreground/30 ml-auto font-mono",children:"Ctrl+S"})]})]})}var B=r(30125),_=r(62791),U=r(86901),H=r(21628),K=r(9199);let X=new Map;async function Y(e,t){if(X.has(e))return X.get(e);try{let r=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e}),signal:t});if(!r.ok)return X.set(e,null),null;let s=(await r.json()).content;return X.set(e,s??null),s??null}catch{return null}}async function J(e,t){try{let r=await fetch(`/api/acp/registry?agent=${encodeURIComponent(e)}`,{signal:t});if(!r.ok)return null;let s=await r.json();if(s.agent?.id)return{id:s.agent.id,name:s.agent.name||e};return null}catch{return null}}async function G(e,t,r,s,n){let a=function(e,t){let r=[];if(e.skills?.length)for(let t of e.skills)r.includes(t)||r.push(t);else e.skill&&r.push(e.skill);for(let e of t.skills??[])r.includes(e)||r.push(e);return r}(e,t),i=new Map;if(a.length>0)for(let[e,t]of(await Promise.all(a.map(async e=>{let t=await Y(e,n);return[e,t]}))))t&&i.set(e,t);let o=null;e.agent&&(o=await J(e.agent,n));let l={messages:[{role:"user",content:function(e,t,r){let s=t.steps.map((e,t)=>`${t+1}. ${e.name}`).join("\n"),n=e.skills?.length?e.skills[0]:e.skill,a="";if(r.size>0){let e=[];for(let[t,s]of r){let r=t===n;e.push(`### ${r?"[Primary] ":""}Skill: ${t}
|
|
35
|
-
|
|
36
|
-
${s}`)}a=`
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
## Skill Reference
|
|
40
|
-
|
|
41
|
-
Follow the guidelines from these skills when executing this step:
|
|
42
|
-
|
|
43
|
-
${e.join("\n\n---\n\n")}`}return`You are executing step ${e.index+1} of a workflow: "${e.name}".
|
|
44
|
-
|
|
45
|
-
Context of the full workflow "${t.title}":
|
|
46
|
-
${s}
|
|
47
|
-
|
|
48
|
-
Current step instructions:
|
|
49
|
-
${e.prompt||"(No specific instructions — use common sense.)"}${a}
|
|
50
|
-
|
|
51
|
-
Execute concisely. Provide:
|
|
52
|
-
1. What you did / what the output is
|
|
53
|
-
2. Any decisions made
|
|
54
|
-
3. What the next step should watch out for
|
|
55
|
-
|
|
56
|
-
Be specific and actionable. Format in Markdown.`}(e,t,i)}],currentFile:r};o&&(l.selectedAcpAgent=o);let d=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:n});if(!d.ok)throw Error(`Request failed (HTTP ${d.status})`);if(!d.body)throw Error("No response body");let c=d.body.getReader(),u=new TextDecoder,m="";for(;;){let{done:e,value:t}=await c.read();if(e)break;for(let e of u.decode(t,{stream:!0}).split("\n")){let t=e.match(/^data:(.+)$/);if(t){try{let e=JSON.parse(t[1]);if("text_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,s(m);else if("thinking_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,s(m);else if("error"===e.type&&e.message)throw Error(e.message)}catch{let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t&&s(m+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}continue}let r=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);r&&s(m+=r[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}}}function Z(e){return e.steps.map((e,t)=>({...e,index:t,status:"pending",output:"",error:void 0}))}function V({status:e,index:t}){let r="w-[26px] h-[26px] rounded-full flex items-center justify-center shrink-0 transition-all";return"running"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--amber)]/15 ring-2 ring-[var(--amber)]/30`,children:(0,s.jsx)(m.A,{size:12,className:"text-[var(--amber)] animate-spin"})}):"done"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--success)]/15`,children:(0,s.jsx)(p.A,{size:13,className:"text-[var(--success)]"})}):"error"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--error)]/15`,children:(0,s.jsx)(l.A,{size:13,className:"text-[var(--error)]"})}):"skipped"===e?(0,s.jsx)("div",{className:`${r} bg-muted/50`,children:(0,s.jsx)(B.A,{size:11,className:"text-muted-foreground/40"})}):(0,s.jsx)("div",{className:`${r} border-2 border-border bg-background`,children:(0,s.jsx)("span",{className:"text-[11px] font-bold text-muted-foreground/50",children:t+1})})}function q({step:e,canRun:t,onRun:r,onSkip:a,onCancel:o}){let[d,c]=(0,n.useState)(!1),u=!!(e.output||e.error),m=e.skills?.length?e.skills:e.skill?[e.skill]:[];return"running"===e.status||e.status,(0,s.jsx)("div",{className:`transition-opacity ${"skipped"===e.status?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(V,{status:e.status,index:e.index}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-between",children:[(0,s.jsx)("span",{className:`text-sm font-medium truncate ${"done"===e.status?"text-foreground":"running"===e.status?"text-[var(--amber)]":"error"===e.status?"text-[var(--error)]":"text-foreground/70"}`,children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[null!=e.durationMs&&("done"===e.status||"error"===e.status)&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/40 font-mono",children:function(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}(e.durationMs)}),"pending"===e.status&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{onClick:r,disabled:!t,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs font-medium transition-all disabled:opacity-30 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[(0,s.jsx)(i.A,{size:9})," Run"]}),(0,s.jsx)("button",{onClick:a,className:"px-1.5 py-0.5 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:"Skip"})]}),"running"===e.status&&(0,s.jsxs)("button",{onClick:o,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs text-[var(--error)]/70 hover:text-[var(--error)] hover:bg-[var(--error)]/10 transition-colors",children:[(0,s.jsx)(_.A,{size:9})," Stop"]}),u&&"running"!==e.status&&(0,s.jsx)("button",{onClick:()=>c(e=>!e),className:"p-0.5 rounded text-muted-foreground/30 hover:text-muted-foreground transition-colors",children:(0,s.jsx)(h.A,{size:12,className:`transition-transform ${d?"rotate-180":""}`})})]})]}),(e.agent||m.length>0)&&(0,s.jsxs)("div",{className:"flex gap-1 mt-0.5 flex-wrap",children:[e.agent&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/50",children:e.agent}),e.agent&&m.length>0&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/20",children:"/"}),m.map(e=>(0,s.jsx)("span",{className:"text-2xs text-[var(--amber)]/60",children:e},e))]}),(d||"running"===e.status)&&u&&(0,s.jsxs)("div",{className:"mt-2 rounded-lg overflow-hidden border border-border/50",children:[e.error&&(0,s.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--error)]/5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,s.jsx)(l.A,{size:10,className:"text-[var(--error)]"}),(0,s.jsx)("span",{className:"text-2xs font-medium text-[var(--error)]",children:"Error"})]}),(0,s.jsx)("div",{className:"text-xs text-[var(--error)]/80 whitespace-pre-wrap break-words leading-relaxed",children:e.error})]}),e.output&&(0,s.jsxs)("div",{className:"px-3 py-2.5 bg-muted/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,s.jsx)(U.A,{size:10,className:"text-[var(--amber)]"}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider font-medium",children:"Output"}),"running"===e.status&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)] animate-pulse"})]}),(0,s.jsx)("div",{className:"text-xs leading-relaxed text-foreground/80 whitespace-pre-wrap break-words",children:e.output})]})]})]})]})})}function Q({workflow:e,filePath:t}){let[r,a]=(0,n.useState)(()=>Z(e)),[i,o]=(0,n.useState)(!1),d=(0,n.useRef)(null);(0,n.useEffect)(()=>{a(Z(e)),o(!1)},[e]);let u=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,o(!1),a(e=>e.map(e=>"running"===e.status?{...e,status:"error",error:"Cancelled"}:e))},[]),x=(0,n.useCallback)(async r=>{if(i)return;d.current?.abort();let s=new AbortController;d.current=s,o(!0);let n=Date.now();a(e=>e.map((e,t)=>t===r?{...e,status:"running",output:"",error:void 0,startedAt:new Date}:e));try{let i={...e.steps[r],index:r,status:"running",output:""};await G(i,e,t,e=>a(t=>t.map((t,s)=>s===r?{...t,output:e}:t)),s.signal);let o=Date.now()-n;a(e=>e.map((e,t)=>t===r?{...e,status:"done",completedAt:new Date,durationMs:o}:e))}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;let e=Date.now()-n;a(s=>s.map((s,n)=>n===r?{...s,status:"error",error:t instanceof Error?t.message:String(t),durationMs:e}:s))}finally{o(!1)}},[i,e,t]),h=(0,n.useCallback)(e=>{a(t=>t.map((t,r)=>r===e?{...t,status:"skipped"}:t))},[]),f=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,o(!1),X.clear(),a(Z(e))},[e]),g=r.filter(e=>"done"===e.status).length,b=r.length>0?Math.round(g/r.length*100):0,v=g===r.length&&r.length>0,y=r.findIndex(e=>"pending"===e.status),j=r.some(e=>"error"===e.status);return(0,s.jsxs)("div",{children:[(e.workDir||e.description)&&(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4 text-xs text-muted-foreground flex-wrap",children:[e.workDir&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-2xs bg-muted/50 px-2 py-0.5 rounded",children:[(0,s.jsx)(c.A,{size:10,className:"shrink-0"}),e.workDir]}),e.description&&(0,s.jsx)("span",{className:"leading-relaxed",children:e.description})]}),(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:v?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--success)]",children:[(0,s.jsx)(p.A,{size:13}),"Complete"]}):j?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--error)]",children:[(0,s.jsx)(l.A,{size:13}),g,"/",r.length," done"]}):(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[g,"/",r.length]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[y>=0&&(0,s.jsxs)("button",{onClick:()=>x(y),disabled:i,className:"flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all disabled:opacity-40 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[i?(0,s.jsx)(m.A,{size:11,className:"animate-spin"}):(0,s.jsx)(H.A,{size:11}),i?"Running...":"Run next"]}),(0,s.jsxs)("button",{onClick:f,className:"flex items-center gap-1 px-2 py-1 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)(K.A,{size:10}),"Reset"]})]})]}),(0,s.jsx)("div",{className:"h-1 rounded-full bg-border/50 overflow-hidden",children:(0,s.jsx)("div",{className:`h-full rounded-full transition-all duration-500 ease-out ${v?"bg-[var(--success)]":j?"bg-[var(--error)]":"bg-[var(--amber)]"}`,style:{width:`${b}%`}})})]}),(0,s.jsxs)("div",{className:"relative",children:[r.length>1&&(0,s.jsx)("div",{className:"absolute left-[12px] top-5 bottom-5 w-px bg-border/50"}),(0,s.jsx)("div",{className:"flex flex-col gap-4",children:r.map((e,t)=>(0,s.jsx)(q,{step:e,canRun:!i,onRun:()=>x(t),onSkip:()=>h(t),onCancel:u},e.id))})]})]})}function ee({filePath:e,content:t}){let r=(0,n.useMemo)(()=>(function(e){try{let t=d.Ay.load(e,{schema:d.Ay.JSON_SCHEMA});if(!t)return{workflow:null,errors:["File is empty"]};if("object"!=typeof t)return{workflow:null,errors:["Content is not valid YAML"]};let r=function(e){let t=[];if(!e||"object"!=typeof e)return{valid:!1,errors:["Must be a valid YAML object"]};if(e.title&&"string"==typeof e.title&&e.title.trim()||t.push("Missing required field 'title' (string)"),void 0!==e.description&&"string"!=typeof e.description&&t.push("'description' must be a string"),void 0!==e.skills&&(Array.isArray(e.skills)?e.skills.every(e=>"string"==typeof e)||t.push("'skills' must contain only strings"):t.push("'skills' must be an array of strings")),void 0!==e.tools&&(Array.isArray(e.tools)?e.tools.every(e=>"string"==typeof e)||t.push("'tools' must contain only strings"):t.push("'tools' must be an array of strings")),e.steps)if(Array.isArray(e.steps))if(0===e.steps.length)t.push("'steps' must have at least 1 step");else{let r=new Set;e.steps.forEach((e,s)=>{var n,a;let i,o,l=(n=e,a=s,i=[],o=`steps[${a}]`,n&&"object"==typeof n?(n.id&&"string"==typeof n.id&&n.id.trim()?/^[a-z0-9_-]+$/.test(n.id)||i.push(`${o}.id: '${n.id}' is invalid — use only lowercase letters, numbers, hyphens, underscores (e.g., 'run-tests')`):i.push(`${o}: missing required field 'id' (non-empty string)`),n.name&&"string"==typeof n.name&&n.name.trim()||i.push(`${o}: missing required field 'name' (non-empty string)`),void 0!==n.description&&"string"!=typeof n.description&&i.push(`${o}.description: must be a string`),void 0===n.agent||"string"==typeof n.agent&&n.agent.trim()||i.push(`${o}.agent: must be a non-empty string`),void 0===n.skill||"string"==typeof n.skill&&n.skill.trim()||i.push(`${o}.skill: must be a non-empty string`),void 0!==n.tools&&(Array.isArray(n.tools)?n.tools.every(e=>"string"==typeof e)||i.push(`${o}.tools: must contain only strings`):i.push(`${o}.tools: must be an array of strings`)),n.prompt&&"string"==typeof n.prompt&&n.prompt.trim()||i.push(`${o}: missing required field 'prompt' (non-empty string)`),void 0!==n.timeout&&("number"!=typeof n.timeout||n.timeout<=0)&&i.push(`${o}.timeout: must be a positive number (seconds)`)):i.push(`${o}: must be a valid object`),i);t.push(...l);let d=e?.id;"string"==typeof d&&d.trim()&&(r.has(d)&&t.push(`steps[${s}].id: duplicate id '${d}' (each step must have a unique id)`),r.add(d))})}else t.push("'steps' must be an array");else t.push("Missing required field 'steps' (array)");return{valid:0===t.length,errors:t}}(t);if(!r.valid)return{workflow:null,errors:r.errors};return{workflow:t,errors:[]}}catch(e){return{workflow:null,errors:[e instanceof Error?e.message:String(e)]}}})(t),[t]),[c,u]=(0,n.useState)("edit"),[m,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(()=>r.workflow?structuredClone(r.workflow):{title:"",description:"",steps:[]});(0,n.useRef)(t);let f=(0,n.useMemo)(()=>r.workflow??null,[r.workflow]),g=(0,n.useCallback)(e=>{h(e),x(!0)},[]),b=(0,n.useCallback)(()=>x(!1),[]),v=f??p,y=v.steps.length>0&&!!v.title,j=r.errors.length>0,w=v.title?0===v.steps.length?"Add at least one step":m?"Save changes first":void 0:"Add a title first",k=e=>{("run"!==e||y)&&u(e)};return(0,s.jsxs)("div",{className:"max-w-[720px] mx-auto py-8 px-2",children:[(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 p-0.5 rounded-lg bg-muted/50",children:[(0,s.jsxs)("button",{onClick:()=>k("edit"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${"edit"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,s.jsx)(a.A,{size:11}),"Edit"]}),(0,s.jsxs)("button",{onClick:()=>k("run"),disabled:!y,title:w,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all disabled:opacity-30 disabled:cursor-not-allowed ${"run"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,s.jsx)(i.A,{size:11}),"Run"]})]}),p.steps.length>0&&(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/60 font-mono",children:[p.steps.length," step",1!==p.steps.length?"s":""]})]}),(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-1 w-8 h-8 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:(0,s.jsx)(o.A,{size:16,className:"text-[var(--amber)]"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("h1",{className:"text-lg font-semibold text-foreground truncate leading-tight",children:[p.title||"Untitled Flow",m&&(0,s.jsx)("span",{className:"text-[var(--amber)] ml-1.5 text-sm",title:"Unsaved changes",children:"*"})]}),p.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:p.description})]})]})]}),j&&"edit"===c&&(0,s.jsxs)("div",{className:"mb-5 px-3.5 py-3 rounded-lg bg-[var(--error)]/8 border border-[var(--error)]/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,s.jsx)(l.A,{size:13,className:"text-[var(--error)] shrink-0"}),(0,s.jsx)("span",{className:"text-xs font-medium text-[var(--error)]",children:"Parse issues found"})]}),(0,s.jsx)("ul",{className:"text-2xs text-[var(--error)]/70 pl-5 list-disc space-y-0.5",children:r.errors.slice(0,3).map((e,t)=>(0,s.jsx)("li",{children:e},t))})]}),"edit"===c?(0,s.jsx)(W,{workflow:p,filePath:e,onChange:g,onSaved:b}):(0,s.jsx)(Q,{workflow:v,filePath:e})]})}},56406:(e,t,r)=>{"use strict";r.r(t),r.d(t,{SummaryRenderer:()=>x});var s=r(95155),n=r(12115),a=r(91958),i=r(86901),o=r(48368),l=r(84980),d=r(91337),c=r(22356);function u(e){let t=Date.now()-e,r=Math.floor(t/6e4),s=Math.floor(t/36e5),n=Math.floor(t/864e5);return r<1?"just now":r<60?`${r}m ago`:s<24?`${s}h ago`:`${n}d ago`}function m(e){return e.split("/").pop()?.replace(/\.(md|csv)$/,"")??e}function x({filePath:e}){let[t,r]=(0,n.useState)([]),[x,p]=(0,n.useState)(""),[h,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)(""),[v,y]=(0,n.useState)(!1),j=(0,n.useRef)(null),w=(0,n.useMemo)(()=>x.replace(/^### (.+)$/gm,'<h3 style="font-size:.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:1em 0 .3em">$1</h3>').replace(/^## (.+)$/gm,'<h2 style="font-size:.9rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h2>').replace(/^# (.+)$/gm,'<h1 style="font-size:1rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h1>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:.82em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/^[-*] (.+)$/gm,'<li style="margin:.2em 0;padding-left:.3em">$1</li>').replace(/(<li[^>]*>.*<\/li>\n?)+/g,e=>`<ul style="margin:.4em 0;padding-left:1.4em;list-style:disc">${e}</ul>`).replace(/\n{2,}/g,'</p><p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">').replace(/^(?!<[hulo])(.+)$/gm,'<p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">$1</p>'),[x]);async function k(){if(0===t.length)return;j.current?.abort();let e=new AbortController;j.current=e,p(""),b(""),f(!0),y(!1);let r=t.map(e=>e.path),s=t.map(e=>`- **${m(e.path)}** (${e.path}, modified ${u(e.mtime)})`).join("\n"),n=`You are summarizing recent changes in a personal knowledge base (MindOS).
|
|
57
|
-
|
|
58
|
-
The following files were recently modified:
|
|
59
|
-
${s}
|
|
60
|
-
|
|
61
|
-
Please provide a concise daily briefing in this format:
|
|
62
|
-
1. **Key changes**: What was added or updated in each file (1–2 sentences per file)
|
|
63
|
-
2. **Themes**: Any patterns or recurring topics across the changes
|
|
64
|
-
3. **Suggested next actions**: 2–3 actionable follow-ups based on the content
|
|
65
|
-
|
|
66
|
-
Be specific. Reference actual content from the files. Keep the total response under 300 words.`;try{let t=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:n}],attachedFiles:r}),signal:e.signal});if(!t.ok)throw Error(`HTTP ${t.status}`);if(!t.body)throw Error("No response body");let s=t.body.getReader(),a=new TextDecoder,i="";for(;;){let{done:e,value:t}=await s.read();if(e)break;for(let e of a.decode(t,{stream:!0}).split("\n")){let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t?i+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):!e||e.startsWith("d:")||e.startsWith("e:")||e.startsWith("0:")||(i+=e)}p(i)}y(!0)}catch(e){e instanceof Error&&"AbortError"!==e.name&&b(e.message||"Failed to generate summary")}finally{f(!1)}}return(0,n.useEffect)(()=>{(0,c.n)("/api/recent-files?limit=8").then(e=>r(e.filter(e=>e.path.endsWith(".md")))).catch(e=>{console.warn("[SummaryRenderer] fetch recent-files failed:",e)})},[e]),(0,n.useEffect)(()=>()=>{j.current?.abort()},[]),(0,s.jsxs)("div",{className:"max-w-[720px] mx-auto py-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-6 flex-wrap",children:[(0,s.jsx)("span",{className:"font-display text-[11px] text-muted-foreground",children:t.length>0?`${t.length} recently modified files`:"Loading recent files…"}),(0,s.jsxs)("button",{onClick:k,disabled:h||0===t.length,className:`font-display summary-gen-btn ${h?"summary-gen-btn--busy":""}`,children:[h?(0,s.jsx)(a.A,{size:12,className:"animate-spin"}):(0,s.jsx)(i.A,{size:12}),h?"Generating…":v?"Regenerate":"Generate briefing"]})]}),t.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-6",children:t.map(e=>(0,s.jsxs)("a",{href:`/view/${(0,d.O0)(e.path)}`,className:"font-display summary-source-chip",title:e.path,children:[(0,s.jsx)(o.A,{size:10}),m(e.path),(0,s.jsxs)("span",{className:"opacity-50",children:[(0,s.jsx)(l.A,{size:9,className:"inline ml-0.5"})," ",u(e.mtime)]})]},e.path))}),g&&(0,s.jsx)("div",{className:"font-display px-3.5 py-2.5 rounded-lg bg-[var(--error)]/10 border border-[var(--error)]/30 text-[var(--error)] text-xs mb-4",children:g}),x?(0,s.jsxs)("div",{className:"bg-card border border-border rounded-[10px] px-5 py-[18px] relative",children:[h&&(0,s.jsx)("div",{className:"absolute top-3 right-3.5 w-1.5 h-1.5 rounded-full bg-[var(--amber)] animate-pulse"}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:w}})]}):h||v||!(t.length>0)?null:(0,s.jsxs)("div",{className:"border border-dashed border-border rounded-[10px] px-6 py-10 text-center text-muted-foreground",children:[(0,s.jsx)(i.A,{size:28,className:"mx-auto mb-2.5 opacity-30 text-[var(--amber)]"}),(0,s.jsxs)("p",{className:"font-display text-xs",children:["Click ",(0,s.jsx)("strong",{className:"text-foreground",children:"Generate briefing"})," to summarize recent changes with AI."]})]}),(0,s.jsx)("style",{children:`
|
|
67
|
-
.summary-gen-btn {
|
|
68
|
-
display: flex; align-items: center; gap: 6px;
|
|
69
|
-
padding: 5px 14px; border-radius: 7px; font-size: 12px;
|
|
70
|
-
cursor: pointer; border: none;
|
|
71
|
-
background: var(--amber); color: var(--amber-foreground);
|
|
72
|
-
transition: opacity .15s;
|
|
73
|
-
}
|
|
74
|
-
.summary-gen-btn:disabled { cursor: not-allowed; opacity: 0.5; }
|
|
75
|
-
.summary-gen-btn--busy { background: var(--muted); color: var(--muted-foreground); }
|
|
76
|
-
.summary-source-chip {
|
|
77
|
-
display: inline-flex; align-items: center; gap: 5px;
|
|
78
|
-
padding: 3px 10px; border-radius: 999px; font-size: 0.7rem;
|
|
79
|
-
background: var(--muted); color: var(--muted-foreground);
|
|
80
|
-
text-decoration: none; border: 1px solid var(--border);
|
|
81
|
-
transition: color .15s;
|
|
82
|
-
}
|
|
83
|
-
.summary-source-chip:hover { color: var(--foreground); }
|
|
84
|
-
`})]})}},58084:(e,t,r)=>{"use strict";r.d(t,{NT:()=>a,uC:()=>i});var s=r(12115),n=r(22356);function a(e,t,r={preparing:"Preparing search...",fallbackWarmHint:"Search will prepare on first query."}){return t.trim()?null:"warming"===e?r.preparing:"fallback"===e?r.fallbackWarmHint:null}function i(e){let[t,r]=(0,s.useState)("idle"),a=(0,s.useRef)(!1),i=(0,s.useRef)(!0);return(0,s.useEffect)(()=>{(function({active:e,hasAttemptedPrewarm:t,warmState:r}){return e&&!t&&"idle"===r})({active:e,hasAttemptedPrewarm:a.current,warmState:t})&&(a.current=!0,r("warming"),(0,n.n)("/api/search/prewarm").then(()=>{i.current&&r("ready")}).catch(()=>{i.current&&r("fallback")}))},[e,t]),(0,s.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,s.useEffect)(()=>{let e=()=>{a.current=!1,r("idle")};return window.addEventListener("mindos:files-changed",e),()=>window.removeEventListener("mindos:files-changed",e)},[]),(0,s.useEffect)(()=>{e||"fallback"!==t||(a.current=!1,r("idle"))},[e,t]),t}},66709:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var s=r(95155),n=r(12115),a=r(92451),i=r(33210),o=r(6296),l=r(13545),d=r(12651),c=r(35581);function u({open:e,onClose:t,onDiscover:r,discovering:u,error:m}){let{t:x}=(0,c.Y)(),p=x.panels.agents,[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)(null);if(!e)return null;let v=async()=>{if(!h.trim()||u)return;b(null);let e=await r(h.trim());e&&b(e)},y=()=>{f(""),b(null),t()};return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center overlay-backdrop",onClick:y,children:(0,s.jsxs)("div",{className:"bg-popover border border-border rounded-xl shadow-lg w-full max-w-md mx-4 p-5",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":p.a2aDiscover,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[(0,s.jsx)(a.A,{size:15,className:"text-muted-foreground"}),p.a2aDiscover]}),(0,s.jsx)("button",{type:"button",onClick:y,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,s.jsx)(i.A,{size:14})})]}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground mb-3",children:p.a2aDiscoverHint}),(0,s.jsxs)("div",{className:"flex gap-2 mb-4",children:[(0,s.jsx)("input",{type:"url",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(),"Escape"===e.key&&t()},placeholder:p.a2aDiscoverPlaceholder,disabled:u,className:"flex-1 px-3 py-2 text-xs rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",autoFocus:!0}),(0,s.jsxs)("button",{type:"button",onClick:v,disabled:u||!h.trim(),className:"px-3 py-2 text-xs font-medium rounded-lg bg-foreground text-background hover:bg-foreground/90 disabled:opacity-50 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring flex items-center gap-1.5 shrink-0",children:[u&&(0,s.jsx)(o.A,{size:12,className:"animate-spin"}),u?p.a2aDiscovering:p.a2aDiscover]})]}),m&&!g&&(0,s.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/5 px-3 py-2.5 mb-3",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(l.A,{size:14,className:"text-error mt-0.5 shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-error",children:p.a2aDiscoverFailed}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:p.a2aDiscoverFailedHint})]})]})}),g&&(0,s.jsx)("div",{className:"rounded-lg border border-success/30 bg-success/5 px-3 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(d.A,{size:14,className:"text-success mt-0.5 shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-success mb-1.5",children:p.a2aDiscoverSuccess}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-foreground truncate",title:g.card.name,children:[g.card.name,(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground ml-1.5",children:["v",g.card.version]})]}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground truncate",title:g.card.description,children:g.card.description}),g.card.skills.length>0&&(0,s.jsxs)("div",{className:"mt-1.5",children:[(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground mb-1",children:[p.a2aSkills,":"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:g.card.skills.map(e=>(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-muted/80 text-muted-foreground border border-border/50",title:e.description,children:e.name},e.id))})]}),(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground mt-1 truncate",title:g.endpoint,children:[p.a2aEndpoint,": ",g.endpoint]})]})]})]})})]})})}},66872:()=>{},69327:(e,t,r)=>{"use strict";r.d(t,{Y:()=>n});var s=r(9339);let n=(0,s.createServerReference)("4093327b57b7010c844167054d8569a3bd1b9029cf",s.callServer,void 0,s.findSourceMapURL,"undoDeleteAction")},77148:(e,t,r)=>{"use strict";r.d(t,{Un:()=>a});var s=r(12115);let n="mindos-renderer-state-change";function a(e,t,r){let a=`mindos-renderer:${e}:${t}`,i=(0,s.useRef)({key:a,raw:null,parsed:r});return i.current.key!==a&&(i.current={key:a,raw:null,parsed:r}),[(0,s.useSyncExternalStore)(e=>{let t=()=>e();return window.addEventListener("storage",t),window.addEventListener(n,t),()=>{window.removeEventListener("storage",t),window.removeEventListener(n,t)}},()=>{try{let e=localStorage.getItem(a);if(e===i.current.raw)return i.current.parsed;if(null===e)return i.current={key:a,raw:null,parsed:r},r;let t=JSON.parse(e);return i.current={key:a,raw:e,parsed:t},t}catch{return r}},()=>r),(0,s.useCallback)(e=>{try{let t=(()=>{try{let e=localStorage.getItem(a);return null!==e?JSON.parse(e):r}catch{return r}})(),s="function"==typeof e?e(t):e,n=JSON.stringify(s);localStorage.setItem(a,n),i.current={key:a,raw:n,parsed:s}}catch{}window.dispatchEvent(new Event(n))},[a,r])]}},78520:(e,t,r)=>{"use strict";r.d(t,{D4:()=>i,FB:()=>n,W8:()=>o,g4:()=>l,jQ:()=>c});let s="mindos:organize-history";function n(){try{let e=localStorage.getItem(s);if(!e)return[];return JSON.parse(e)}catch{return[]}}function a(e){try{localStorage.setItem(s,JSON.stringify(e.slice(0,50)))}catch{}}function i(e){let t=n();t.unshift(e);let r=t.slice(0,50);return a(r),r}function o(e,t){let r=n(),s=r.findIndex(t=>t.id===e);return s>=0&&(r[s]={...r[s],...t},a(r)),r}function l(){try{localStorage.removeItem(s)}catch{}}let d=0;function c(){return`org-${Date.now()}-${++d}`}},82125:(e,t,r)=>{"use strict";r.d(t,{A:()=>n,C:()=>s});let s=new Set(["INSTRUCTION.md","README.md","CONFIG.json","CHANGELOG.md"]),n=new Set(["TODO.md"])},86343:(e,t,r)=>{"use strict";r.d(t,{default:()=>a});var s=r(95155),n=r(12115);class a extends n.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[50vh] px-4",children:(0,s.jsxs)("div",{className:"text-center max-w-md",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Something went wrong"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred."}),(0,s.jsx)("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:"px-4 py-2 text-sm rounded-lg border border-border hover:bg-muted transition-colors",children:"Try again"})]})}):this.props.children}}},86464:(e,t,r)=>{"use strict";r.d(t,{default:()=>tK});var s=r(95155),n=r(73321),a=r(12115),i=r(98500),o=r.n(i),l=r(29857),d=r(61878),c=r(89363),u=r(33210),m=r(59511),x=r(47857),p=r(46029),h=r(49619),f=r(53961),g=r(34530),b=r(91958),v=r(41641),y=r(21362),j=r(35581),w=r(12651),k=r(62791),N=r(22356),S=r(402);function C(e,t){return t?"syncing":e&&e.enabled?e.lastError?"error":e.conflicts&&e.conflicts.length>0?"conflicts":parseInt(e.unpushed||"0",10)>0?"unpushed":"synced":"off"}let A={synced:"bg-success",unpushed:"bg-yellow-500",conflicts:"bg-error",error:"bg-error",off:"bg-muted-foreground/40",syncing:"bg-blue-500"};function z(){let[e,t]=(0,a.useState)(null),[r,s]=(0,a.useState)(!1),n=(0,a.useRef)(void 0),i=(0,a.useCallback)(async()=>{try{let e=await (0,N.n)("/api/sync");t(e)}catch{t(null)}finally{s(!0)}},[]);return(0,a.useEffect)(()=>{i();let e=()=>{n.current&&clearInterval(n.current),n.current=setInterval(i,3e4)},t=()=>{n.current&&clearInterval(n.current),n.current=void 0};e();let r=()=>{"visible"===document.visibilityState?(i(),e()):t()};return document.addEventListener("visibilitychange",r),()=>{t(),document.removeEventListener("visibilitychange",r)}},[i]),{status:e,loaded:r,fetchStatus:i}}function E(e){let[t,r]=(0,a.useState)(!1),[s,n]=(0,a.useState)(null),i=(0,a.useCallback)(async()=>{if(!t){r(!0),n(null);try{await (0,N.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"now"})}),await e(),n("success")}catch{await e(),n("error")}finally{r(!1),setTimeout(()=>n(null),2500)}}},[t,e]);return{syncing:t,syncResult:s,syncNow:i}}function T(e,t,r){switch(e){case"syncing":{let e=r?.syncing??"Syncing...";return{label:e,tooltip:e}}case"synced":{let e=`${r?.synced??"Synced"} \xb7 ${(0,S.fF)(t?.lastSync)}`;return{label:e,tooltip:e}}case"unpushed":{let e=parseInt(t?.unpushed||"0",10);return{label:`${e} ${r?.unpushed??"awaiting push"}`,tooltip:r?.unpushedHint??`${e} commit(s) not yet pushed to remote`}}case"conflicts":{let e=t?.conflicts?.length||0;return{label:`${e} ${r?.conflicts??"conflicts"}`,tooltip:r?.conflictsHint??`${e} file(s) have merge conflicts — resolve in Settings > Sync`}}case"error":return{label:r?.syncError??"Sync error",tooltip:t?.lastError||(r?.syncError??"Sync error")};default:{let e=r?.syncOff??"Sync off";return{label:e,tooltip:e}}}}function $({collapsed:e,onOpenSyncSettings:t}){let{status:r,loaded:n,fetchStatus:i}=z(),{syncing:o,syncResult:l,syncNow:d}=E(i),[c,u]=(0,a.useState)(null),m=(0,a.useRef)("off"),[x,p]=(0,a.useState)(()=>{try{return!!localStorage.getItem("sync-hint-dismissed")}catch(e){console.warn("[SyncStatusBar] localStorage read failed:",e)}return!1}),{t:h}=(0,j.Y)();if(!function(e){let[,t]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),6e4);return()=>clearInterval(e)},[6e4])}(0),(0,a.useEffect)(()=>{if(!n||o)return;let e=C(r,!1),t=m.current;if(t!==e){let r=h.sidebar?.sync;("error"===t||"conflicts"===t)&&"synced"===e&&(u(r?.syncRestored??"Sync restored"),setTimeout(()=>u(null),3e3)),m.current=e}},[r,n,o,h]),!n||e)return null;let f=C(r,o);if("off"===f){if(x)return null;let e=h.sidebar?.sync;return(0,s.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,s.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:e?.enableHint??"Set up cross-device sync",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 bg-muted-foreground/40"}),(0,s.jsxs)("span",{className:"truncate",children:[e?.enableSync??"Enable sync"," →"]})]}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation();try{localStorage.setItem("sync-hint-dismissed","1")}catch(e){console.warn("[SyncStatusBar] localStorage write dismissed:",e)}p(!0)},className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors shrink-0 ml-2 text-muted-foreground/50 hover:text-muted-foreground",title:"Dismiss",children:(0,s.jsx)("span",{className:"text-2xs",children:"✕"})})]})}let g=h.sidebar?.sync,{label:v,tooltip:y}=T(f,r,g);return(0,s.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,s.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:y,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full shrink-0 ${A[f]} ${"syncing"===f||"conflicts"===f?"animate-pulse":""}`}),(0,s.jsx)("span",{className:"truncate",children:c||v})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[("success"===l||c)&&(0,s.jsx)(w.A,{size:12,className:"text-success animate-in fade-in duration-200"}),"error"===l&&(0,s.jsx)(k.A,{size:12,className:"text-error animate-in fade-in duration-200"}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),d()},disabled:o,className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors disabled:opacity-40",title:g?.syncNow??"Sync now",children:(0,s.jsx)(b.A,{size:12,className:o?"animate-spin":""})})]})]})}function D({status:e,syncing:t}){let r=C(e,t??!1);return"off"===r||"synced"===r?null:(0,s.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${A[r]} ${"conflicts"===r||"error"===r?"animate-pulse":""}`})}var R=r(59960),M=r(91459);function P({icon:e,label:t,shortcut:r,active:n=!1,expanded:a,onClick:i,buttonRef:o,badge:l,walkthroughId:d}){let c=r?`${t} (${r})`:t,u=(0,s.jsxs)("button",{ref:o,onClick:i,"aria-pressed":n,"aria-label":t,title:void 0,"data-walkthrough":d,className:`
|
|
24
|
+
`],{type:"application/javascript"}),a=URL.createObjectURL(s),i=new Worker(a),o=()=>{i.terminate(),URL.revokeObjectURL(a)},l=setTimeout(()=>{o(),r(n(t))},1e4);i.onmessage=e=>{clearTimeout(l),o(),"string"==typeof e.data?r(e.data):r(n(t))},i.onerror=()=>{clearTimeout(l),o(),r(n(t))},i.postMessage(e,[e])})}async function i(e,t){let r=[],n=0;for(let t of e){if(t.size>0xa00000){n++;continue}try{let e=t.name.toLowerCase(),s=e.endsWith(".doc")||e.endsWith(".docx")||e.endsWith(".docm");if(e.endsWith(".pdf")||s){let e=await t.arrayBuffer();r.push({name:t.name,content:await a(e),encoding:"base64"})}else{let e=await t.text();r.push({name:t.name,content:e})}}catch{}}if(0===r.length)return void(n>0?s.oR.error(t.inbox.tooLarge(n),4e3):e.length>0&&s.oR.error(t.inbox.saveFailed,4e3));try{var i;let e=await fetch("/api/inbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:r})});if(!e.ok){let r=await e.json().catch(()=>({}));console.error("[QuickDrop] Save failed:",r.error),s.oR.error(t.inbox.saveFailed,4e3);return}let a=await e.json(),o=a.saved?.length??0,l=a.skipped?.length??0;i=n,o>0&&i>0&&0===l?s.oR.success(t.inbox.savedWithOversized(o,i),4e3):o>0&&l+i>0?s.oR.success(t.inbox.savedWithSkipped(o,l+i),4e3):o>0?s.oR.success(t.inbox.savedToast(o),3e3):(i>0&&s.oR.error(t.inbox.tooLarge(i),4e3),l>0&&s.oR.error(t.inbox.savedWithSkipped(0,l),4e3),0===i&&0===l&&s.oR.error(t.inbox.saveFailed,4e3)),window.dispatchEvent(new Event("mindos:files-changed")),window.dispatchEvent(new Event("mindos:inbox-updated"))}catch(e){console.error("[QuickDrop] Network error:",e),s.oR.error(t.inbox.saveFailed,4e3)}}async function o(e,t){try{let r=await fetch("/api/inbox/clip",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}),n=await r.json();if(!r.ok){let e=n.error||t.inbox.clipFailed;return s.oR.error(e,4e3),{ok:!1}}return s.oR.success(t.inbox.clipSuccess(n.title||e),3e3),window.dispatchEvent(new Event("mindos:files-changed")),window.dispatchEvent(new Event("mindos:inbox-updated")),{ok:!0,title:n.title}}catch(e){return console.error("[ClipURL] Network error:",e),s.oR.error(t.inbox.clipFailed,4e3),{ok:!1}}}function l(e){let t=e.trim();if(!t.startsWith("http://")&&!t.startsWith("https://"))return!1;try{return new URL(t),!0}catch{return!1}}function d(e){if(e.dataTransfer?.files&&e.dataTransfer.files.length>0)return null;let t=e.dataTransfer?.getData("text/uri-list");if(t){let e=t.split(/[\r\n]+/).find(e=>!e.startsWith("#")&&e.trim().length>0);if(e&&l(e))return e.trim()}let r=e.dataTransfer?.getData("text/plain");return r&&l(r)?r.trim():null}function c(e){let t=e.dataTransfer?.types??[];return!t.includes("Files")&&(t.includes("text/uri-list")||t.includes("text/plain"))}async function u(e,t,r){let n=[],i=0,o=new Set(["pdf","png","jpg","jpeg","gif","webp","bmp","ico","mp3","wav","m4a","ogg","flac","aac","mp4","webm","mov","mkv","doc","docx","docm"]);for(let t of e){if(t.size>0xa00000){i++;continue}try{let e=(t.name.split(".").pop()??"").toLowerCase();if(o.has(e)){let e=await t.arrayBuffer();n.push({name:t.name,content:await a(e),encoding:"base64"})}else{let e=await t.text();n.push({name:t.name,content:e})}}catch{}}if(0===n.length)return void(i>0?s.oR.error(r.inbox.tooLarge(i),4e3):e.length>0&&s.oR.error(r.inbox.saveFailed,4e3));let l=t.split("/").pop()||t;try{let e=await fetch("/api/file/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:n,targetSpace:t,organize:!1,conflict:"rename"})});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[TreeDrop] Save failed:",t.error),s.oR.error(r.inbox.saveFailed,4e3);return}let a=await e.json(),o=a.created?.length??0,d=a.skipped?.length??0;o>0&&d+i>0?s.oR.success(r.inbox.savedWithSkipped(o,d+i),4e3):o>0?s.oR.success(r.inbox.savedToDir(o,l),3e3):(i>0&&s.oR.error(r.inbox.tooLarge(i),4e3),d>0&&s.oR.error(r.inbox.savedWithSkipped(0,d),4e3)),window.dispatchEvent(new Event("mindos:files-changed"))}catch(e){console.error("[TreeDrop] Network error:",e),s.oR.error(r.inbox.saveFailed,4e3)}}},30266:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,66872,23)),Promise.resolve().then(r.bind(r,92524)),Promise.resolve().then(r.bind(r,86343)),Promise.resolve().then(r.bind(r,18847)),Promise.resolve().then(r.bind(r,14446)),Promise.resolve().then(r.bind(r,88946)),Promise.resolve().then(r.bind(r,57025)),Promise.resolve().then(r.bind(r,35504)),Promise.resolve().then(r.bind(r,92306)),Promise.resolve().then(r.bind(r,92950)),Promise.resolve().then(r.bind(r,20814)),Promise.resolve().then(r.bind(r,20870)),Promise.resolve().then(r.bind(r,56406)),Promise.resolve().then(r.bind(r,39594)),Promise.resolve().then(r.bind(r,78660)),Promise.resolve().then(r.bind(r,87986)),Promise.resolve().then(r.bind(r,48133)),Promise.resolve().then(r.bind(r,34693)),Promise.resolve().then(r.bind(r,26490)),Promise.resolve().then(r.bind(r,91459)),Promise.resolve().then(r.bind(r,40430)),Promise.resolve().then(r.bind(r,98959)),Promise.resolve().then(r.bind(r,93042)),Promise.resolve().then(r.t.bind(r,16719,23)),Promise.resolve().then(r.t.bind(r,377,23)),Promise.resolve().then(r.t.bind(r,98663,23)),Promise.resolve().then(r.t.bind(r,75282,23))},34693:(e,t,r)=>{"use strict";r.d(t,{default:()=>tK});var s=r(95155),n=r(73321),a=r(12115),i=r(98500),o=r.n(i),l=r(29857),d=r(61878),c=r(89363),u=r(33210),m=r(59511),x=r(47857),p=r(46029),h=r(49619),f=r(53961),g=r(34530),b=r(91958),v=r(41641),y=r(21362),j=r(35581),w=r(12651),k=r(62791),N=r(22356),S=r(402);function C(e,t){return t?"syncing":e&&e.enabled?e.lastError?"error":e.conflicts&&e.conflicts.length>0?"conflicts":parseInt(e.unpushed||"0",10)>0?"unpushed":"synced":"off"}let A={synced:"bg-success",unpushed:"bg-yellow-500",conflicts:"bg-error",error:"bg-error",off:"bg-muted-foreground/40",syncing:"bg-blue-500"};function z(){let[e,t]=(0,a.useState)(null),[r,s]=(0,a.useState)(!1),n=(0,a.useRef)(void 0),i=(0,a.useCallback)(async()=>{try{let e=await (0,N.n)("/api/sync");t(e)}catch{t(null)}finally{s(!0)}},[]);return(0,a.useEffect)(()=>{i();let e=()=>{n.current&&clearInterval(n.current),n.current=setInterval(i,3e4)},t=()=>{n.current&&clearInterval(n.current),n.current=void 0};e();let r=()=>{"visible"===document.visibilityState?(i(),e()):t()};return document.addEventListener("visibilitychange",r),()=>{t(),document.removeEventListener("visibilitychange",r)}},[i]),{status:e,loaded:r,fetchStatus:i}}function E(e){let[t,r]=(0,a.useState)(!1),[s,n]=(0,a.useState)(null),i=(0,a.useCallback)(async()=>{if(!t){r(!0),n(null);try{await (0,N.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"now"})}),await e(),n("success")}catch{await e(),n("error")}finally{r(!1),setTimeout(()=>n(null),2500)}}},[t,e]);return{syncing:t,syncResult:s,syncNow:i}}function T(e,t,r){switch(e){case"syncing":{let e=r?.syncing??"Syncing...";return{label:e,tooltip:e}}case"synced":{let e=`${r?.synced??"Synced"} \xb7 ${(0,S.fF)(t?.lastSync)}`;return{label:e,tooltip:e}}case"unpushed":{let e=parseInt(t?.unpushed||"0",10);return{label:`${e} ${r?.unpushed??"awaiting push"}`,tooltip:r?.unpushedHint??`${e} commit(s) not yet pushed to remote`}}case"conflicts":{let e=t?.conflicts?.length||0;return{label:`${e} ${r?.conflicts??"conflicts"}`,tooltip:r?.conflictsHint??`${e} file(s) have merge conflicts — resolve in Settings > Sync`}}case"error":return{label:r?.syncError??"Sync error",tooltip:t?.lastError||(r?.syncError??"Sync error")};default:{let e=r?.syncOff??"Sync off";return{label:e,tooltip:e}}}}function $({collapsed:e,onOpenSyncSettings:t}){let{status:r,loaded:n,fetchStatus:i}=z(),{syncing:o,syncResult:l,syncNow:d}=E(i),[c,u]=(0,a.useState)(null),m=(0,a.useRef)("off"),[x,p]=(0,a.useState)(()=>{try{return!!localStorage.getItem("sync-hint-dismissed")}catch(e){console.warn("[SyncStatusBar] localStorage read failed:",e)}return!1}),{t:h}=(0,j.Y)();if(!function(e){let[,t]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),6e4);return()=>clearInterval(e)},[6e4])}(0),(0,a.useEffect)(()=>{if(!n||o)return;let e=C(r,!1),t=m.current;if(t!==e){let r=h.sidebar?.sync;("error"===t||"conflicts"===t)&&"synced"===e&&(u(r?.syncRestored??"Sync restored"),setTimeout(()=>u(null),3e3)),m.current=e}},[r,n,o,h]),!n||e)return null;let f=C(r,o);if("off"===f){if(x)return null;let e=h.sidebar?.sync;return(0,s.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,s.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:e?.enableHint??"Set up cross-device sync",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 bg-muted-foreground/40"}),(0,s.jsxs)("span",{className:"truncate",children:[e?.enableSync??"Enable sync"," →"]})]}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation();try{localStorage.setItem("sync-hint-dismissed","1")}catch(e){console.warn("[SyncStatusBar] localStorage write dismissed:",e)}p(!0)},className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors shrink-0 ml-2 text-muted-foreground/50 hover:text-muted-foreground",title:"Dismiss",children:(0,s.jsx)("span",{className:"text-2xs",children:"✕"})})]})}let g=h.sidebar?.sync,{label:v,tooltip:y}=T(f,r,g);return(0,s.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,s.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:y,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full shrink-0 ${A[f]} ${"syncing"===f||"conflicts"===f?"animate-pulse":""}`}),(0,s.jsx)("span",{className:"truncate",children:c||v})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[("success"===l||c)&&(0,s.jsx)(w.A,{size:12,className:"text-success animate-in fade-in duration-200"}),"error"===l&&(0,s.jsx)(k.A,{size:12,className:"text-error animate-in fade-in duration-200"}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),d()},disabled:o,className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors disabled:opacity-40",title:g?.syncNow??"Sync now",children:(0,s.jsx)(b.A,{size:12,className:o?"animate-spin":""})})]})]})}function D({status:e,syncing:t}){let r=C(e,t??!1);return"off"===r||"synced"===r?null:(0,s.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${A[r]} ${"conflicts"===r||"error"===r?"animate-pulse":""}`})}var R=r(59960),M=r(91459);function P({icon:e,label:t,shortcut:r,active:n=!1,expanded:a,onClick:i,buttonRef:o,badge:l,walkthroughId:d}){let c=r?`${t} (${r})`:t,u=(0,s.jsxs)("button",{ref:o,onClick:i,"aria-pressed":n,"aria-label":t,title:void 0,"data-walkthrough":d,className:`
|
|
85
25
|
relative flex items-center ${a?"justify-start px-3 w-full":"justify-center w-10"} h-10 rounded-md transition-colors
|
|
86
26
|
${n?"text-[var(--amber)] bg-[var(--amber-dim)]":"text-muted-foreground hover:text-foreground hover:bg-muted"}
|
|
87
27
|
focus-visible:ring-2 focus-visible:ring-ring
|
|
88
|
-
`,children:[n&&(0,s.jsx)("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-[2px] h-[18px] rounded-r-full bg-[var(--amber)]"}),(0,s.jsx)("span",{className:"shrink-0 flex items-center justify-center w-[18px]",children:e}),l,a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"ml-2.5 text-sm whitespace-nowrap",children:t}),r&&(0,s.jsx)("span",{className:"ml-auto text-2xs text-muted-foreground/60 font-mono shrink-0",children:r})]})]});return a?u:(0,s.jsxs)(M.m_,{children:[(0,s.jsx)(M.k$,{render:u}),(0,s.jsx)(M.ZI,{side:"right",sideOffset:8,children:c})]})}function F({activePanel:e,onPanelChange:t,onEchoClick:r,onAgentsClick:i,onDiscoverClick:o,onWorkflowsClick:l,onSpacesClick:u,syncStatus:m,expanded:w,onExpandedChange:k,onSettingsClick:N,onSyncClick:S}){let z=(0,a.useRef)(0),E=(0,a.useRef)(null),{t:T}=(0,j.Y)(),$=(0,n.usePathname)(),D=(0,n.useRouter)(),F="/"===$,[L,I]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=window.mindos;if(e?.checkUpdate){let t=e.checkUpdate.bind(e),r=setTimeout(async()=>{try{(await t()).available&&I(!0)}catch{}},1e4),s=e.onUpdateAvailable?.(()=>I(!0));return()=>{clearTimeout(r),s?.()}}let t=localStorage.getItem("mindos_update_dismissed"),r=localStorage.getItem("mindos_update_latest");r&&r!==t&&I(!0);let s=setTimeout(async()=>{try{let e=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)});if(!e.ok)return;let t=await e.json();if(!t.hasUpdate){localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),I(!1);return}let r=localStorage.getItem("mindos_update_dismissed");if(t.latest===r)return;localStorage.setItem("mindos_update_latest",t.latest),I(!0)}catch{}},5e3),n=()=>I(!0),a=()=>I(!1);return window.addEventListener("mindos:update-available",n),window.addEventListener("mindos:update-dismissed",a),()=>{clearTimeout(s),window.removeEventListener("mindos:update-available",n),window.removeEventListener("mindos:update-dismissed",a)}},[]);let[O,W]=(0,a.useState)(!1),[B,_]=(0,a.useState)(!1);(0,a.useEffect)(()=>{W("1"===localStorage.getItem("mindos:labs-echo")),_("1"===localStorage.getItem("mindos:labs-workflows"));let e=()=>{W("1"===localStorage.getItem("mindos:labs-echo")),_("1"===localStorage.getItem("mindos:labs-workflows"))};return window.addEventListener("mindos:labs-changed",e),()=>window.removeEventListener("mindos:labs-changed",e)},[]);let U=(0,a.useCallback)(e=>{let t=Date.now();t-z.current<300||(z.current=t,e())},[]),H=(0,a.useCallback)(r=>{U(()=>t(e===r?null:r))},[e,t,U]),K=C(m,!1),X=w?180:48,Y="off"!==K&&"synced"!==K?(0,s.jsx)("span",{className:`absolute ${w?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full ${A[K]} ${"error"===K||"conflicts"===K?"animate-pulse":""}`}):void 0;return(0,s.jsx)(M.TooltipProvider,{delay:2e3,children:(0,s.jsxs)("aside",{className:"group hidden md:flex fixed top-0 left-0 h-screen z-[31] flex-col bg-background border-r border-border transition-[width] duration-200 ease-out",style:{width:`${X}px`},role:"toolbar","aria-label":"Navigation","aria-orientation":"vertical",children:[(0,s.jsxs)("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{F?t("files"===e?null:"files"):(t("files"),D.push("/"))},className:`flex items-center ${w?"px-3 gap-2":"justify-center"} w-full h-[46px] shrink-0 transition-opacity cursor-pointer ${F?"opacity-100":"opacity-50 hover:opacity-80"}`,"aria-label":"MindOS Home",children:[(0,s.jsx)(R.A,{id:"rail",className:"w-7 h-3.5 shrink-0"}),w&&(0,s.jsx)("span",{className:"text-sm text-foreground font-brand whitespace-nowrap",children:"MindOS"})]}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsxs)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,s.jsx)(P,{icon:(0,s.jsx)(x.A,{size:18}),label:T.sidebar.files,active:!F&&"files"===e,expanded:w,onClick:()=>u?U(u):H("files"),walkthroughId:"files-panel"}),O&&(0,s.jsx)(P,{icon:(0,s.jsx)(p.A,{size:18}),label:T.sidebar.echo,active:"echo"===e,expanded:w,onClick:()=>r?U(r):H("echo"),walkthroughId:"echo-panel"}),(0,s.jsx)(P,{icon:(0,s.jsx)(d.A,{size:18}),label:T.sidebar.searchTitle,shortcut:"⌘K",active:"search"===e,expanded:w,onClick:()=>H("search")}),(0,s.jsx)(P,{icon:(0,s.jsx)(h.A,{size:18}),label:T.sidebar.agents,active:"agents"===e,expanded:w,onClick:()=>i?U(i):H("agents"),walkthroughId:"agents-panel"}),B&&(0,s.jsx)(P,{icon:(0,s.jsx)(f.A,{size:18}),label:T.sidebar.workflows??"Flows",active:"workflows"===e,expanded:w,onClick:()=>l?U(l):H("workflows")})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsx)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:(0,s.jsx)(P,{icon:(0,s.jsx)(g.A,{size:18}),label:T.sidebar.discover,active:"discover"===e,expanded:w,onClick:()=>o?U(o):H("discover")})}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsxs)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,s.jsx)(P,{icon:(0,s.jsx)(c.A,{size:18}),label:T.sidebar.settingsTitle,shortcut:"⌘,",expanded:w,onClick:()=>U(N),badge:L?(0,s.jsx)("span",{className:`absolute ${w?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full bg-error`}):void 0}),m?.enabled&&m?.remote&&"(not configured)"!==m.remote&&(0,s.jsx)(P,{icon:(0,s.jsx)(b.A,{size:18}),label:T.sidebar.syncLabel,expanded:w,buttonRef:E,badge:Y,onClick:()=>U(()=>{let e=E.current?.getBoundingClientRect();e&&S(e)})})]})]}),(0,s.jsx)("button",{onClick:()=>k(!w),className:" absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-[32] w-5 h-5 rounded-full bg-card border border-border shadow-sm flex items-center justify-center opacity-0 group-hover:opacity-100 hover:!opacity-100 transition-opacity duration-200 text-muted-foreground hover:text-foreground hover:bg-muted focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring ","aria-label":w?"Collapse sidebar":"Expand sidebar",title:w?"Collapse":"Expand",children:w?(0,s.jsx)(v.A,{size:10}):(0,s.jsx)(y.A,{size:10})})]})})}var L=r(51914),I=r(48368),O=r(33024),W=r(10579),B=r(38569),_=r(56563),U=r(60285),H=r(15282),K=r(50538),X=r(68459),Y=r(15411),J=r(7915),G=r(25400),Z=r(60241),V=r(24371);function q({title:e,children:t,maximized:r,onMaximize:n}){return(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 h-[46px] border-b border-border shrink-0",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[t,n&&(0,s.jsx)("button",{onClick:n,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":r?"Restore panel":"Maximize panel",children:r?(0,s.jsx)(Z.A,{size:13}):(0,s.jsx)(V.A,{size:13})})]})]})}function Q({width:e,minWidth:t,maxWidth:r,maxWidthRatio:s,direction:n,disabled:i,onResize:o,onResizeEnd:l}){let d=(0,a.useRef)(!1),c=(0,a.useRef)(0),u=(0,a.useRef)(0),m=(0,a.useRef)(e);m.current=e;let x=(0,a.useRef)(o);x.current=o;let p=(0,a.useRef)(l);return p.current=l,(0,a.useCallback)(a=>{if(i)return;a.preventDefault(),d.current=!0,c.current=a.clientX,u.current=e,document.body.classList.add("select-none"),document.body.style.cursor="col-resize";let o=e=>{if(!d.current)return;let a="right"===n?e.clientX-c.current:c.current-e.clientX,i=Math.round(Math.max(t,Math.min(Math.min(r,window.innerWidth*s),u.current+a)));x.current(i)},l=()=>{d.current=!1,document.body.classList.remove("select-none"),document.body.style.cursor="",p.current(m.current),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)},[e,t,r,s,n,i])}var ee=r(9339);let et=(0,ee.createServerReference)("00bd579a6e30bb2bd7d5307904efc010a546398ed6",ee.callServer,void 0,ee.findSourceMapURL,"listTrashAction"),er=()=>{},es={files:280,search:320,echo:340,agents:300,discover:300,workflows:320};function en({activePanel:e,fileTree:t,onNavigate:r,onOpenSyncSettings:i,railWidth:o=48,panelWidth:l,onWidthChange:d,onWidthCommit:c,maximized:u=!1,onMaximize:m,onImport:x,children:p}){let h=e?es[e]:280,f=u?void 0:l??h,{t:g}=(0,j.Y)(),b=(0,n.useRouter)(),v=(0,n.usePathname)(),y="/capture"===v||"/capture/"===v,[w,k]=(0,a.useState)(null),N=(0,a.useMemo)(()=>(function e(t,r=0){let s=r;for(let n of t)"directory"===n.type&&(s=Math.max(s,e(n.children??[],r+1)));return s})(t),[t]),[S,C]=(0,a.useState)(!1),A=(0,a.useRef)(null),z=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!S)return;let e=e=>{A.current&&!A.current.contains(e.target)&&z.current&&!z.current.contains(e.target)&&C(!1)},t=e=>{"Escape"===e.key&&C(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[S]);let[E,T]=(0,a.useState)(!1),D=(0,a.useRef)(null),R=(0,a.useRef)(null),M=(0,G.gL)(),[P,F]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(!E)return;let e=e=>{D.current&&!D.current.contains(e.target)&&R.current&&!R.current.contains(e.target)&&T(!1)},t=e=>{"Escape"===e.key&&T(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[E]);let[Z,V]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=()=>{et().then(e=>F(e.length)).catch(()=>{})},t=()=>{fetch("/api/inbox").then(e=>e.json()).then(e=>{Array.isArray(e.files)&&V(e.files.length)}).catch(()=>{})};return e(),t(),window.addEventListener("mindos:files-changed",e),window.addEventListener("mindos:inbox-updated",t),()=>{window.removeEventListener("mindos:files-changed",e),window.removeEventListener("mindos:inbox-updated",t)}},[]);let[ee,en]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"1"===localStorage.getItem("mindos-tree-dblclick-hint")&&en(!0)}catch{}},[]);let ea=(0,a.useCallback)(()=>{if(!ee){en(!0);try{localStorage.setItem("mindos-tree-dblclick-hint","1")}catch{}}},[ee]),ei=Q({width:l??h,minWidth:240,maxWidth:600,maxWidthRatio:.45,direction:"right",disabled:u,onResize:d??er,onResizeEnd:c??er});return(0,s.jsxs)("aside",{className:`
|
|
28
|
+
`,children:[n&&(0,s.jsx)("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-[2px] h-[18px] rounded-r-full bg-[var(--amber)]"}),(0,s.jsx)("span",{className:"shrink-0 flex items-center justify-center w-[18px]",children:e}),l,a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"ml-2.5 text-sm whitespace-nowrap",children:t}),r&&(0,s.jsx)("span",{className:"ml-auto text-2xs text-muted-foreground/60 font-mono shrink-0",children:r})]})]});return a?u:(0,s.jsxs)(M.m_,{children:[(0,s.jsx)(M.k$,{render:u}),(0,s.jsx)(M.ZI,{side:"right",sideOffset:8,children:c})]})}function F({activePanel:e,onPanelChange:t,onEchoClick:r,onAgentsClick:i,onDiscoverClick:o,onWorkflowsClick:l,onSpacesClick:u,syncStatus:m,expanded:w,onExpandedChange:k,onSettingsClick:N,onSyncClick:S}){let z=(0,a.useRef)(0),E=(0,a.useRef)(null),{t:T}=(0,j.Y)(),$=(0,n.usePathname)(),D=(0,n.useRouter)(),F="/"===$,[L,I]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=window.mindos;if(e?.checkUpdate){let t=e.checkUpdate.bind(e),r=setTimeout(async()=>{try{(await t()).available&&I(!0)}catch{}},1e4),s=e.onUpdateAvailable?.(()=>I(!0));return()=>{clearTimeout(r),s?.()}}let t=localStorage.getItem("mindos_update_dismissed"),r=localStorage.getItem("mindos_update_latest");r&&r!==t&&I(!0);let s=setTimeout(async()=>{try{let e=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)});if(!e.ok)return;let t=await e.json();if(!t.hasUpdate){localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),I(!1);return}let r=localStorage.getItem("mindos_update_dismissed");if(t.latest===r)return;localStorage.setItem("mindos_update_latest",t.latest),I(!0)}catch{}},5e3),n=()=>I(!0),a=()=>I(!1);return window.addEventListener("mindos:update-available",n),window.addEventListener("mindos:update-dismissed",a),()=>{clearTimeout(s),window.removeEventListener("mindos:update-available",n),window.removeEventListener("mindos:update-dismissed",a)}},[]);let[O,W]=(0,a.useState)(!1),[B,_]=(0,a.useState)(!1);(0,a.useEffect)(()=>{W("1"===localStorage.getItem("mindos:labs-echo")),_("1"===localStorage.getItem("mindos:labs-workflows"));let e=()=>{W("1"===localStorage.getItem("mindos:labs-echo")),_("1"===localStorage.getItem("mindos:labs-workflows"))};return window.addEventListener("mindos:labs-changed",e),()=>window.removeEventListener("mindos:labs-changed",e)},[]);let U=(0,a.useCallback)(e=>{let t=Date.now();t-z.current<300||(z.current=t,e())},[]),H=(0,a.useCallback)(r=>{U(()=>t(e===r?null:r))},[e,t,U]),K=C(m,!1),X=w?180:48,Y="off"!==K&&"synced"!==K?(0,s.jsx)("span",{className:`absolute ${w?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full ${A[K]} ${"error"===K||"conflicts"===K?"animate-pulse":""}`}):void 0;return(0,s.jsx)(M.TooltipProvider,{delay:2e3,children:(0,s.jsxs)("aside",{className:"group hidden md:flex fixed top-0 left-0 h-screen z-[31] flex-col bg-background border-r border-border transition-[width] duration-200 ease-out",style:{width:`${X}px`},role:"toolbar","aria-label":"Navigation","aria-orientation":"vertical",children:[(0,s.jsxs)("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{F?t("files"===e?null:"files"):(t("files"),D.push("/"))},className:`flex items-center ${w?"px-3 gap-2":"justify-center"} w-full h-[46px] shrink-0 transition-opacity cursor-pointer ${F?"opacity-100":"opacity-50 hover:opacity-80"}`,"aria-label":"MindOS Home",children:[(0,s.jsx)(R.A,{id:"rail",className:"w-7 h-3.5 shrink-0"}),w&&(0,s.jsx)("span",{className:"text-sm text-foreground font-brand whitespace-nowrap",children:"MindOS"})]}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsxs)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,s.jsx)(P,{icon:(0,s.jsx)(x.A,{size:18}),label:T.sidebar.files,active:!F&&"files"===e,expanded:w,onClick:()=>u?U(u):H("files"),walkthroughId:"files-panel"}),O&&(0,s.jsx)(P,{icon:(0,s.jsx)(p.A,{size:18}),label:T.sidebar.echo,active:"echo"===e,expanded:w,onClick:()=>r?U(r):H("echo"),walkthroughId:"echo-panel"}),(0,s.jsx)(P,{icon:(0,s.jsx)(d.A,{size:18}),label:T.sidebar.searchTitle,shortcut:"⌘K",active:"search"===e,expanded:w,onClick:()=>H("search")}),(0,s.jsx)(P,{icon:(0,s.jsx)(h.A,{size:18}),label:T.sidebar.agents,active:"agents"===e,expanded:w,onClick:()=>i?U(i):H("agents"),walkthroughId:"agents-panel"}),B&&(0,s.jsx)(P,{icon:(0,s.jsx)(f.A,{size:18}),label:T.sidebar.workflows??"Flows",active:"workflows"===e,expanded:w,onClick:()=>l?U(l):H("workflows")})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsx)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:(0,s.jsx)(P,{icon:(0,s.jsx)(g.A,{size:18}),label:T.sidebar.discover,active:"discover"===e,expanded:w,onClick:()=>o?U(o):H("discover")})}),(0,s.jsx)("div",{className:`${w?"mx-3":"mx-2"} border-t border-border`}),(0,s.jsxs)("div",{className:`flex flex-col ${w?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,s.jsx)(P,{icon:(0,s.jsx)(c.A,{size:18}),label:T.sidebar.settingsTitle,shortcut:"⌘,",expanded:w,onClick:()=>U(N),badge:L?(0,s.jsx)("span",{className:`absolute ${w?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full bg-error`}):void 0}),m?.enabled&&m?.remote&&"(not configured)"!==m.remote&&(0,s.jsx)(P,{icon:(0,s.jsx)(b.A,{size:18}),label:T.sidebar.syncLabel,expanded:w,buttonRef:E,badge:Y,onClick:()=>U(()=>{let e=E.current?.getBoundingClientRect();e&&S(e)})})]})]}),(0,s.jsx)("button",{onClick:()=>k(!w),className:" absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-[32] w-5 h-5 rounded-full bg-card border border-border shadow-sm flex items-center justify-center opacity-0 group-hover:opacity-100 hover:!opacity-100 transition-opacity duration-200 text-muted-foreground hover:text-foreground hover:bg-muted focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring ","aria-label":w?"Collapse sidebar":"Expand sidebar",title:w?"Collapse":"Expand",children:w?(0,s.jsx)(v.A,{size:10}):(0,s.jsx)(y.A,{size:10})})]})})}var L=r(51914),I=r(48368),O=r(33024),W=r(10579),B=r(38569),_=r(56563),U=r(60285),H=r(15282),K=r(50538),X=r(68459),Y=r(15411),J=r(7915),G=r(99715),Z=r(60241),V=r(24371);function q({title:e,children:t,maximized:r,onMaximize:n}){return(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 h-[46px] border-b border-border shrink-0",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[t,n&&(0,s.jsx)("button",{onClick:n,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":r?"Restore panel":"Maximize panel",children:r?(0,s.jsx)(Z.A,{size:13}):(0,s.jsx)(V.A,{size:13})})]})]})}function Q({width:e,minWidth:t,maxWidth:r,maxWidthRatio:s,direction:n,disabled:i,onResize:o,onResizeEnd:l}){let d=(0,a.useRef)(!1),c=(0,a.useRef)(0),u=(0,a.useRef)(0),m=(0,a.useRef)(e);m.current=e;let x=(0,a.useRef)(o);x.current=o;let p=(0,a.useRef)(l);return p.current=l,(0,a.useCallback)(a=>{if(i)return;a.preventDefault(),d.current=!0,c.current=a.clientX,u.current=e,document.body.classList.add("select-none"),document.body.style.cursor="col-resize";let o=e=>{if(!d.current)return;let a="right"===n?e.clientX-c.current:c.current-e.clientX,i=Math.round(Math.max(t,Math.min(Math.min(r,window.innerWidth*s),u.current+a)));x.current(i)},l=()=>{d.current=!1,document.body.classList.remove("select-none"),document.body.style.cursor="",p.current(m.current),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)},[e,t,r,s,n,i])}var ee=r(9339);let et=(0,ee.createServerReference)("00c329df12304c8255642661ec58d7030319b25ade",ee.callServer,void 0,ee.findSourceMapURL,"listTrashAction"),er=()=>{},es={files:280,search:320,echo:340,agents:300,discover:300,workflows:320};function en({activePanel:e,fileTree:t,onNavigate:r,onOpenSyncSettings:i,railWidth:o=48,panelWidth:l,onWidthChange:d,onWidthCommit:c,maximized:u=!1,onMaximize:m,onImport:x,children:p}){let h=e?es[e]:280,f=u?void 0:l??h,{t:g}=(0,j.Y)(),b=(0,n.useRouter)(),v=(0,n.usePathname)(),y="/capture"===v||"/capture/"===v,[w,k]=(0,a.useState)(null),N=(0,a.useMemo)(()=>(function e(t,r=0){let s=r;for(let n of t)"directory"===n.type&&(s=Math.max(s,e(n.children??[],r+1)));return s})(t),[t]),[S,C]=(0,a.useState)(!1),A=(0,a.useRef)(null),z=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!S)return;let e=e=>{A.current&&!A.current.contains(e.target)&&z.current&&!z.current.contains(e.target)&&C(!1)},t=e=>{"Escape"===e.key&&C(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[S]);let[E,T]=(0,a.useState)(!1),D=(0,a.useRef)(null),R=(0,a.useRef)(null),M=(0,G.gL)(),[P,F]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(!E)return;let e=e=>{D.current&&!D.current.contains(e.target)&&R.current&&!R.current.contains(e.target)&&T(!1)},t=e=>{"Escape"===e.key&&T(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[E]);let[Z,V]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=()=>{et().then(e=>F(e.length)).catch(()=>{})},t=()=>{fetch("/api/inbox").then(e=>e.json()).then(e=>{Array.isArray(e.files)&&V(e.files.length)}).catch(()=>{})};return e(),t(),window.addEventListener("mindos:files-changed",e),window.addEventListener("mindos:inbox-updated",t),()=>{window.removeEventListener("mindos:files-changed",e),window.removeEventListener("mindos:inbox-updated",t)}},[]);let[ee,en]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"1"===localStorage.getItem("mindos-tree-dblclick-hint")&&en(!0)}catch{}},[]);let ea=(0,a.useCallback)(()=>{if(!ee){en(!0);try{localStorage.setItem("mindos-tree-dblclick-hint","1")}catch{}}},[ee]),ei=Q({width:l??h,minWidth:240,maxWidth:600,maxWidthRatio:.45,direction:"right",disabled:u,onResize:d??er,onResizeEnd:c??er});return(0,s.jsxs)("aside",{className:`
|
|
89
29
|
hidden md:flex fixed top-0 h-screen z-30
|
|
90
30
|
flex-col bg-card border-r border-border
|
|
91
31
|
transition-[transform,left,width] duration-200 ease-out
|
|
@@ -122,12 +62,12 @@ Be specific. Reference actual content from the files. Keep the total response un
|
|
|
122
62
|
hover:shadow-lg hover:shadow-[var(--amber)]/20
|
|
123
63
|
active:scale-95 cursor-pointer overflow-hidden
|
|
124
64
|
${t||"/"===a||""===a?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0"}
|
|
125
|
-
`,style:{background:"var(--amber)"},title:i,"aria-label":i,children:[(0,s.jsx)(ts.A,{size:16,className:"relative z-10 shrink-0"}),(0,s.jsx)("span",{className:" relative z-10 max-w-0 group-hover:max-w-[120px] opacity-0 group-hover:opacity-100 transition-all duration-200 ease-out whitespace-nowrap overflow-hidden ",children:r.ask?.fabLabel??"Ask MindOS"})]})}function ta({open:e,onClose:t,anchorRect:r,railWidth:n,onOpenSyncSettings:i,syncStatus:o,onSyncStatusRefresh:l}){let d=(0,a.useRef)(null),c=(0,a.useRef)(t);c.current=t;let{syncing:m,syncResult:x,syncNow:p}=E(l);if((0,a.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),c.current())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),(0,a.useEffect)(()=>{if(!e)return;let t=e=>{d.current&&!d.current.contains(e.target)&&c.current()},r=setTimeout(()=>window.addEventListener("mousedown",t),0);return()=>{clearTimeout(r),window.removeEventListener("mousedown",t)}},[e]),!e||!r)return null;let h=C(o,m),{label:f}=T(h,o),g=Math.max(8,r.bottom-180);return(0,s.jsxs)("div",{ref:d,className:"fixed z-40 w-[240px] border rounded-lg bg-card shadow-lg border-border animate-in fade-in slide-in-from-left-2 duration-150",style:{top:g,left:n},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Sync"}),(0,s.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,s.jsx)(u.A,{size:14})})]}),(0,s.jsxs)("div",{className:"p-3 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${A[h]} ${"syncing"===h||"conflicts"===h||"error"===h?"animate-pulse":""}`}),(0,s.jsx)("span",{className:"text-sm text-foreground",children:f}),"success"===x&&(0,s.jsx)(w.A,{size:14,className:"text-success shrink-0"}),"error"===x&&(0,s.jsx)(k.A,{size:14,className:"text-error shrink-0"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:["off"!==h&&(0,s.jsxs)(eK.jn,{onClick:p,disabled:m,className:"text-xs px-3 py-1.5 flex items-center gap-1.5",children:[(0,s.jsx)(b.A,{size:12,className:m?"animate-spin":""}),"Sync Now"]}),(0,s.jsx)("button",{onClick:()=>{i(),t()},className:"text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 py-0.5 focus-visible:ring-2 focus-visible:ring-ring",children:"Settings →"})]})]})]})}function ti(){let[e,t]=(0,a.useState)(!1),{t:r}=(0,j.Y)(),n=r.shortcutPanel,i="u">typeof navigator&&/Mac|iPhone|iPad/.test(navigator.userAgent)?"⌘":"Ctrl",o=(0,a.useMemo)(()=>[{keys:`${i} K`,label:n.toggleSearch,section:n.navigation},{keys:`${i} /`,label:n.toggleAskAI,section:n.navigation},{keys:`${i} ,`,label:n.openSettings,section:n.navigation},{keys:`${i} ?`,label:n.keyboardShortcuts,section:n.navigation},{keys:"Esc",label:n.closePanel,section:n.panelsSection},{keys:`${i} S`,label:n.saveFile,section:n.editor},{keys:`${i} Z`,label:n.undo,section:n.editor},{keys:`${i} Shift Z`,label:n.redo,section:n.editor}],[i,n]);if((0,a.useEffect)(()=>{let r=r=>{(r.metaKey||r.ctrlKey)&&r.shiftKey&&"/"===r.key&&(r.preventDefault(),t(e=>!e)),"Escape"===r.key&&e&&t(!1)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),!e)return null;let l=[...new Set(o.map(e=>e.section))];return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(!1),children:(0,s.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":n.title,className:"w-full max-w-md mx-4 bg-card border border-border rounded-xl shadow-2xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.title}),(0,s.jsx)("button",{onClick:()=>t(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:15})})]}),(0,s.jsx)("div",{className:"px-5 py-4 space-y-4 max-h-[60vh] overflow-y-auto",children:l.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:e}),(0,s.jsx)("div",{className:"space-y-1",children:o.filter(t=>t.section===e).map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:e.keys.split(" ").map((e,t)=>(0,s.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs rounded border border-border bg-muted text-muted-foreground font-mono min-w-[24px] text-center",children:e},t))})]},e.keys))})]},e))}),(0,s.jsx)("div",{className:"px-5 py-2.5 border-t border-border",children:(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground/60",children:["Press ",(0,s.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono",children:i}),(0,s.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono ml-0.5",children:"?"})," ",n.toggleHint]})})]})})}function to(){let[e,t]=(0,a.useState)(0),[r,i]=(0,a.useState)(null),[l,d]=(0,a.useState)(!1),c=(0,a.useRef)(0),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),f=(0,n.usePathname)(),{t:g}=(0,j.Y)();(0,a.useEffect)(()=>{let e=!0,r=async()=>{try{let r=await (0,N.n)("/api/changes?op=summary");e&&t(r.unreadCount)}catch{e&&t(0)}};r();let s=setInterval(()=>void r(),15e3);return()=>{e=!1,clearInterval(s)}},[]),(0,a.useEffect)(()=>{e>c.current&&l&&d(!1),c.current=e},[e,l]);let b=(0,a.useMemo)(()=>!(e<=0||f?.startsWith("/changes")||f?.startsWith("/changelog"))&&(null===r||!(e<=r))&&!l,[r,f,e,l]);async function v(){try{await (0,N.n)("/api/changes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"mark_seen"})})}catch{}finally{t(0),i(0)}}return((0,a.useEffect)(()=>{if(!b)return;let e=setTimeout(()=>d(!0),1e4);return()=>clearTimeout(e)},[b]),(0,a.useEffect)(()=>{if(b){x(!0);let e=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(e)}h(!1);let e=setTimeout(()=>x(!1),160);return()=>clearTimeout(e)},[b]),m)?(0,s.jsx)("div",{className:`fixed right-3 top-[60px] md:right-6 md:top-4 z-30 transition-all duration-150 ease-out ${p?"opacity-100 translate-y-0 scale-100":"opacity-0 -translate-y-2 scale-[0.98] pointer-events-none"}`,children:(0,s.jsx)("div",{className:"rounded-2xl border bg-card/95 backdrop-blur px-3 py-2.5 shadow-lg min-w-[260px] max-w-[350px]",style:{borderColor:"color-mix(in srgb, var(--amber) 45%, var(--border))",boxShadow:"0 12px 28px color-mix(in srgb, var(--amber) 14%, rgba(0,0,0,.24))"},children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-[var(--amber)] bg-[var(--amber-subtle)]",children:(0,s.jsx)(K.A,{size:14})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-xs text-foreground font-medium whitespace-nowrap",children:g.changes.unreadBanner(e)}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,s.jsx)(o(),{href:"/changelog",className:"inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] focus-visible:ring-2 focus-visible:ring-ring hover:opacity-90",children:g.changes.reviewNow}),(0,s.jsx)("button",{type:"button",onClick:()=>void v(),className:"inline-flex items-center rounded-md px-2 py-1 text-xs font-medium bg-muted text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:g.changes.markAllRead})]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>i(e),"aria-label":g.changes.dismiss,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring",children:(0,s.jsx)(u.A,{size:14})})]})})}):null}var tl=r(55711);let td=(0,ee.createServerReference)("70b1f7cc71b86abd22d7f066711045cb472cdae6fd",ee.callServer,void 0,ee.findSourceMapURL,"revertSpaceInitAction");function tc(){let[e,t]=(0,a.useState)(null),[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useTransition)(),d=(0,n.useRouter)(),{t:c}=(0,j.Y)(),m=(0,a.useCallback)(()=>{i(!1),setTimeout(()=>t(null),200)},[]),x=(0,a.useCallback)(e=>{let r=e.detail;"working"===r.state?(t(r),requestAnimationFrame(()=>i(!0))):"done"===r.state?(t(e=>e?{...e,state:"done"}:null),d.refresh()):m()},[d,m]);(0,a.useEffect)(()=>(window.addEventListener("mindos:ai-init",x),()=>window.removeEventListener("mindos:ai-init",x)),[x]);let p=(0,a.useCallback)(()=>{e&&(m(),d.push(`/view/${(0,ei.O0)(e.spacePath+"/")}`))},[e,m,d]),h=(0,a.useCallback)(()=>{e&&l(async()=>{await td(e.spacePath,e.spaceName,e.description),t(e=>e?{...e,state:"reverted"}:null),d.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(m,2e3)})},[e,d,m]),f=(0,a.useCallback)(()=>{m()},[m]);if(!e)return null;let g=c.home,{state:b}=e,v="done"===b,y="reverted"===b;return(0,s.jsx)("div",{className:`fixed bottom-6 left-1/2 z-50 -translate-x-1/2 transition-all duration-200 ease-out ${r?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-3 scale-[0.96] pointer-events-none"}`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5 rounded-full border bg-card/95 backdrop-blur py-2 shadow-lg",style:{borderColor:"color-mix(in srgb, var(--amber) 40%, var(--border))",boxShadow:"0 8px 24px color-mix(in srgb, var(--amber) 12%, rgba(0,0,0,.2))",paddingLeft:"0.75rem",paddingRight:v?"0.5rem":"1rem"},children:[(0,s.jsx)("span",{className:`inline-flex h-6 w-6 items-center justify-center rounded-full shrink-0 ${y?"text-muted-foreground bg-muted":"text-[var(--amber)] bg-[var(--amber-subtle)]"} ${"working"===b?"animate-pulse":""}`,children:y?(0,s.jsx)(tl.A,{size:12}):v?(0,s.jsx)(ej.A,{size:13,strokeWidth:2.5}):(0,s.jsx)(ts.A,{size:13})}),(0,s.jsx)("span",{className:"text-xs text-foreground whitespace-nowrap select-none font-medium",children:y?g.aiInitReverted(e.spaceName):v?g.aiInitReady(e.spaceName):(0,s.jsxs)(s.Fragment,{children:[g.aiInitGenerating(e.spaceName),(0,s.jsx)(tu,{})]})}),v&&(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-1",children:[(0,s.jsx)("button",{type:"button",onClick:p,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity focus-visible:ring-2 focus-visible:ring-ring",children:g.aiInitReview}),(0,s.jsx)("button",{type:"button",onClick:h,disabled:o,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:g.aiInitDiscard}),(0,s.jsx)("button",{type:"button",onClick:f,"aria-label":"Accept",className:"ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors focus-visible:ring-2 focus-visible:ring-ring",children:(0,s.jsx)(u.A,{size:12})})]})]})})}function tu(){return(0,s.jsxs)("span",{className:"inline-flex gap-[2px] items-end h-[1em] ml-px",children:[(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_0ms_infinite]"}),(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_200ms_infinite]"}),(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_400ms_infinite]"}),(0,s.jsx)("style",{children:`
|
|
65
|
+
`,style:{background:"var(--amber)"},title:i,"aria-label":i,children:[(0,s.jsx)(ts.A,{size:16,className:"relative z-10 shrink-0"}),(0,s.jsx)("span",{className:" relative z-10 max-w-0 group-hover:max-w-[120px] opacity-0 group-hover:opacity-100 transition-all duration-200 ease-out whitespace-nowrap overflow-hidden ",children:r.ask?.fabLabel??"Ask MindOS"})]})}function ta({open:e,onClose:t,anchorRect:r,railWidth:n,onOpenSyncSettings:i,syncStatus:o,onSyncStatusRefresh:l}){let d=(0,a.useRef)(null),c=(0,a.useRef)(t);c.current=t;let{syncing:m,syncResult:x,syncNow:p}=E(l);if((0,a.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),c.current())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),(0,a.useEffect)(()=>{if(!e)return;let t=e=>{d.current&&!d.current.contains(e.target)&&c.current()},r=setTimeout(()=>window.addEventListener("mousedown",t),0);return()=>{clearTimeout(r),window.removeEventListener("mousedown",t)}},[e]),!e||!r)return null;let h=C(o,m),{label:f}=T(h,o),g=Math.max(8,r.bottom-180);return(0,s.jsxs)("div",{ref:d,className:"fixed z-40 w-[240px] border rounded-lg bg-card shadow-lg border-border animate-in fade-in slide-in-from-left-2 duration-150",style:{top:g,left:n},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Sync"}),(0,s.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,s.jsx)(u.A,{size:14})})]}),(0,s.jsxs)("div",{className:"p-3 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${A[h]} ${"syncing"===h||"conflicts"===h||"error"===h?"animate-pulse":""}`}),(0,s.jsx)("span",{className:"text-sm text-foreground",children:f}),"success"===x&&(0,s.jsx)(w.A,{size:14,className:"text-success shrink-0"}),"error"===x&&(0,s.jsx)(k.A,{size:14,className:"text-error shrink-0"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:["off"!==h&&(0,s.jsxs)(eK.jn,{onClick:p,disabled:m,className:"text-xs px-3 py-1.5 flex items-center gap-1.5",children:[(0,s.jsx)(b.A,{size:12,className:m?"animate-spin":""}),"Sync Now"]}),(0,s.jsx)("button",{onClick:()=>{i(),t()},className:"text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 py-0.5 focus-visible:ring-2 focus-visible:ring-ring",children:"Settings →"})]})]})]})}function ti(){let[e,t]=(0,a.useState)(!1),{t:r}=(0,j.Y)(),n=r.shortcutPanel,i="u">typeof navigator&&/Mac|iPhone|iPad/.test(navigator.userAgent)?"⌘":"Ctrl",o=(0,a.useMemo)(()=>[{keys:`${i} K`,label:n.toggleSearch,section:n.navigation},{keys:`${i} /`,label:n.toggleAskAI,section:n.navigation},{keys:`${i} ,`,label:n.openSettings,section:n.navigation},{keys:`${i} ?`,label:n.keyboardShortcuts,section:n.navigation},{keys:"Esc",label:n.closePanel,section:n.panelsSection},{keys:`${i} S`,label:n.saveFile,section:n.editor},{keys:`${i} Z`,label:n.undo,section:n.editor},{keys:`${i} Shift Z`,label:n.redo,section:n.editor}],[i,n]);if((0,a.useEffect)(()=>{let r=r=>{(r.metaKey||r.ctrlKey)&&r.shiftKey&&"/"===r.key&&(r.preventDefault(),t(e=>!e)),"Escape"===r.key&&e&&t(!1)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),!e)return null;let l=[...new Set(o.map(e=>e.section))];return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(!1),children:(0,s.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":n.title,className:"w-full max-w-md mx-4 bg-card border border-border rounded-xl shadow-2xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.title}),(0,s.jsx)("button",{onClick:()=>t(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:15})})]}),(0,s.jsx)("div",{className:"px-5 py-4 space-y-4 max-h-[60vh] overflow-y-auto",children:l.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:e}),(0,s.jsx)("div",{className:"space-y-1",children:o.filter(t=>t.section===e).map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:e.keys.split(" ").map((e,t)=>(0,s.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs rounded border border-border bg-muted text-muted-foreground font-mono min-w-[24px] text-center",children:e},t))})]},e.keys))})]},e))}),(0,s.jsx)("div",{className:"px-5 py-2.5 border-t border-border",children:(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground/60",children:["Press ",(0,s.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono",children:i}),(0,s.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono ml-0.5",children:"?"})," ",n.toggleHint]})})]})})}function to(){let[e,t]=(0,a.useState)(0),[r,i]=(0,a.useState)(null),[l,d]=(0,a.useState)(!1),c=(0,a.useRef)(0),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),f=(0,n.usePathname)(),{t:g}=(0,j.Y)();(0,a.useEffect)(()=>{let e=!0,r=async()=>{try{let r=await (0,N.n)("/api/changes?op=summary");e&&t(r.unreadCount)}catch{e&&t(0)}};r();let s=setInterval(()=>void r(),15e3);return()=>{e=!1,clearInterval(s)}},[]),(0,a.useEffect)(()=>{e>c.current&&l&&d(!1),c.current=e},[e,l]);let b=(0,a.useMemo)(()=>!(e<=0||f?.startsWith("/changes")||f?.startsWith("/changelog"))&&(null===r||!(e<=r))&&!l,[r,f,e,l]);async function v(){try{await (0,N.n)("/api/changes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"mark_seen"})})}catch{}finally{t(0),i(0)}}return((0,a.useEffect)(()=>{if(!b)return;let e=setTimeout(()=>d(!0),1e4);return()=>clearTimeout(e)},[b]),(0,a.useEffect)(()=>{if(b){x(!0);let e=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(e)}h(!1);let e=setTimeout(()=>x(!1),160);return()=>clearTimeout(e)},[b]),m)?(0,s.jsx)("div",{className:`fixed right-3 top-[60px] md:right-6 md:top-4 z-30 transition-all duration-150 ease-out ${p?"opacity-100 translate-y-0 scale-100":"opacity-0 -translate-y-2 scale-[0.98] pointer-events-none"}`,children:(0,s.jsx)("div",{className:"rounded-2xl border bg-card/95 backdrop-blur px-3 py-2.5 shadow-lg min-w-[260px] max-w-[350px]",style:{borderColor:"color-mix(in srgb, var(--amber) 45%, var(--border))",boxShadow:"0 12px 28px color-mix(in srgb, var(--amber) 14%, rgba(0,0,0,.24))"},children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-[var(--amber)] bg-[var(--amber-subtle)]",children:(0,s.jsx)(K.A,{size:14})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-xs text-foreground font-medium whitespace-nowrap",children:g.changes.unreadBanner(e)}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,s.jsx)(o(),{href:"/changelog",className:"inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] focus-visible:ring-2 focus-visible:ring-ring hover:opacity-90",children:g.changes.reviewNow}),(0,s.jsx)("button",{type:"button",onClick:()=>void v(),className:"inline-flex items-center rounded-md px-2 py-1 text-xs font-medium bg-muted text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:g.changes.markAllRead})]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>i(e),"aria-label":g.changes.dismiss,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring",children:(0,s.jsx)(u.A,{size:14})})]})})}):null}var tl=r(55711);let td=(0,ee.createServerReference)("701e3f988949962a97584a84fbe2dbcd88152e03a9",ee.callServer,void 0,ee.findSourceMapURL,"revertSpaceInitAction");function tc(){let[e,t]=(0,a.useState)(null),[r,i]=(0,a.useState)(!1),[o,l]=(0,a.useTransition)(),d=(0,n.useRouter)(),{t:c}=(0,j.Y)(),m=(0,a.useCallback)(()=>{i(!1),setTimeout(()=>t(null),200)},[]),x=(0,a.useCallback)(e=>{let r=e.detail;"working"===r.state?(t(r),requestAnimationFrame(()=>i(!0))):"done"===r.state?(t(e=>e?{...e,state:"done"}:null),d.refresh()):m()},[d,m]);(0,a.useEffect)(()=>(window.addEventListener("mindos:ai-init",x),()=>window.removeEventListener("mindos:ai-init",x)),[x]);let p=(0,a.useCallback)(()=>{e&&(m(),d.push(`/view/${(0,ei.O0)(e.spacePath+"/")}`))},[e,m,d]),h=(0,a.useCallback)(()=>{e&&l(async()=>{await td(e.spacePath,e.spaceName,e.description),t(e=>e?{...e,state:"reverted"}:null),d.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(m,2e3)})},[e,d,m]),f=(0,a.useCallback)(()=>{m()},[m]);if(!e)return null;let g=c.home,{state:b}=e,v="done"===b,y="reverted"===b;return(0,s.jsx)("div",{className:`fixed bottom-6 left-1/2 z-50 -translate-x-1/2 transition-all duration-200 ease-out ${r?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-3 scale-[0.96] pointer-events-none"}`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5 rounded-full border bg-card/95 backdrop-blur py-2 shadow-lg",style:{borderColor:"color-mix(in srgb, var(--amber) 40%, var(--border))",boxShadow:"0 8px 24px color-mix(in srgb, var(--amber) 12%, rgba(0,0,0,.2))",paddingLeft:"0.75rem",paddingRight:v?"0.5rem":"1rem"},children:[(0,s.jsx)("span",{className:`inline-flex h-6 w-6 items-center justify-center rounded-full shrink-0 ${y?"text-muted-foreground bg-muted":"text-[var(--amber)] bg-[var(--amber-subtle)]"} ${"working"===b?"animate-pulse":""}`,children:y?(0,s.jsx)(tl.A,{size:12}):v?(0,s.jsx)(ej.A,{size:13,strokeWidth:2.5}):(0,s.jsx)(ts.A,{size:13})}),(0,s.jsx)("span",{className:"text-xs text-foreground whitespace-nowrap select-none font-medium",children:y?g.aiInitReverted(e.spaceName):v?g.aiInitReady(e.spaceName):(0,s.jsxs)(s.Fragment,{children:[g.aiInitGenerating(e.spaceName),(0,s.jsx)(tu,{})]})}),v&&(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-1",children:[(0,s.jsx)("button",{type:"button",onClick:p,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity focus-visible:ring-2 focus-visible:ring-ring",children:g.aiInitReview}),(0,s.jsx)("button",{type:"button",onClick:h,disabled:o,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:g.aiInitDiscard}),(0,s.jsx)("button",{type:"button",onClick:f,"aria-label":"Accept",className:"ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors focus-visible:ring-2 focus-visible:ring-ring",children:(0,s.jsx)(u.A,{size:12})})]})]})})}function tu(){return(0,s.jsxs)("span",{className:"inline-flex gap-[2px] items-end h-[1em] ml-px",children:[(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_0ms_infinite]"}),(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_200ms_infinite]"}),(0,s.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_400ms_infinite]"}),(0,s.jsx)("style",{children:`
|
|
126
66
|
@keyframes dotBounce {
|
|
127
67
|
0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
|
|
128
68
|
30% { opacity: 1; transform: translateY(-2px); }
|
|
129
69
|
}
|
|
130
|
-
`})]})}var tm=r(93631),tx=r(3926),tp=r(22164),th=r(78916),tf=r(78520);function tg(e,t){let r=e.fileImport;if(!t)return r.organizeProcessing;switch(t.stage){case"connecting":return r.organizeConnecting;case"analyzing":return r.organizeAnalyzing;case"reading":return r.organizeReading(t.detail);case"thinking":return r.organizeThinking;case"writing":return r.organizeWriting(t.detail);default:return r.organizeProcessing}}function tb({aiOrganize:e,onDismiss:t,onCancel:r,onHistoryUpdate:i}){let{t:o}=(0,j.Y)(),l=(0,n.useRouter)(),d=o.fileImport,c="organizing"===e.phase,{elapsed:m,displayHint:x}=function(e,t){let[r,s]=(0,a.useState)(0),[n,i]=(0,a.useState)(!1),o=(0,a.useRef)(Date.now());return(0,a.useEffect)(()=>{o.current=Date.now(),i(!1)},[t]),(0,a.useEffect)(()=>{if(!e){s(0),i(!1);return}let t=setInterval(()=>{s(e=>e+1),Date.now()-o.current>=5e3&&i(!0)},1e3);return()=>clearInterval(t)},[e]),{elapsed:r,displayHint:n?{stage:"thinking"}:t}}(c,e.stageHint),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!1),y=(0,a.useRef)(null),w=(0,a.useRef)(null),k="done"===e.phase,N="error"===e.phase,S=c||k||N,C=e.changes.filter(e=>e.ok&&!e.undone).length;(0,a.useEffect)(()=>{c&&(w.current=null)},[c]),(0,a.useEffect)(()=>{if(k&&!w.current){let t=(0,tf.jQ)();w.current=t,(0,tf.D4)({id:t,timestamp:Date.now(),sourceFiles:e.sourceFileNames,files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.undone})),status:"completed",source:e.source,durationMs:e.durationMs}),i?.()}},[k,e.changes,e.sourceFileNames,e.source,e.durationMs,i]);let A=(0,a.useCallback)(()=>{y.current&&clearTimeout(y.current),(k||N)&&(y.current=setTimeout(()=>{t()},18e4))},[k,N,t]);(0,a.useEffect)(()=>(A(),()=>{y.current&&clearTimeout(y.current)}),[A]);let z=(0,a.useCallback)(()=>{A()},[A]),E=(0,a.useCallback)(async t=>{z(),v(!0);let r=await e.undoOne(t);v(!1),r&&(window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(()=>{if(w.current){let r=e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.path===t||e.undone})),s=r.every(e=>!e.ok||e.undone);(0,tf.W8)(w.current,{files:r,status:s?"undone":"partial"}),i?.()}},0))},[e,z,i]),T=(0,a.useCallback)(async()=>{z(),v(!0);let t=await e.undoAll();v(!1),t>0&&(window.dispatchEvent(new Event("mindos:files-changed")),w.current&&((0,tf.W8)(w.current,{files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:!!e.ok||e.undone})),status:"undone"}),i?.()))},[e,z,i]),$=(0,a.useCallback)(e=>{z(),l.push(`/view/${(0,ei.O0)(e)}`)},[l,z]),D=(0,a.useCallback)(()=>{t()},[t]);if(!S)return null;function R(t,r){let n=t.undone,a=e.canUndo(t.path),i=t.path.split("/").pop()??t.path;return(0,s.jsxs)("div",{className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors ${n?"bg-muted/30 opacity-50":"bg-muted/50"}`,children:[n?(0,s.jsx)(tl.A,{size:14,className:"text-muted-foreground shrink-0"}):"create"===t.action?(0,s.jsx)(tm.A,{size:14,className:"text-success shrink-0"}):(0,s.jsx)(tx.A,{size:14,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:`truncate flex-1 ${n?"line-through text-muted-foreground":"text-foreground"}`,children:i}),n?(0,s.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:d.organizeUndone}):(0,s.jsx)("span",{className:`text-xs shrink-0 ${t.ok?"text-muted-foreground":"text-error"}`,children:t.ok?"create"===t.action?d.organizeCreated:d.organizeUpdated:d.organizeFailed}),a&&(0,s.jsx)("button",{type:"button",onClick:()=>E(t.path),disabled:b,className:"text-2xs text-muted-foreground/60 hover:text-foreground transition-colors shrink-0 px-1 disabled:opacity-40",title:d.organizeUndoOne,children:(0,s.jsx)(tl.A,{size:12})}),t.ok&&!t.undone&&(0,s.jsx)("button",{type:"button",onClick:()=>$(t.path),className:"text-2xs text-muted-foreground/60 hover:text-[var(--amber)] transition-colors shrink-0 px-1",title:d.organizeViewFile,children:(0,s.jsx)(tp.A,{size:12})})]},`${t.path}-${r}`)}function M(){return(0,s.jsxs)("div",{className:"flex items-center justify-end gap-3 px-4 py-3 border-t border-border",children:[k&&e.hasAnyUndoable&&(0,s.jsxs)("button",{onClick:T,disabled:b,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1.5 disabled:opacity-50",children:[b?(0,s.jsx)(ec.A,{size:12,className:"animate-spin"}):(0,s.jsx)(tl.A,{size:12}),d.organizeUndoAll]}),(0,s.jsxs)("button",{onClick:D,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-all",children:[(0,s.jsx)(ej.A,{size:12}),d.organizeDone]})]})}return f?(0,s.jsx)("div",{className:"fixed inset-0 z-50 overlay-backdrop flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&g(!1)},children:(0,s.jsxs)("div",{className:"w-full max-w-xl max-h-[80vh] flex flex-col bg-card rounded-xl shadow-xl border border-border animate-in fade-in-0 zoom-in-95 duration-200",onClick:z,role:"dialog","aria-modal":"true","aria-label":d.organizeDetailTitle,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3 shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,s.jsxs)("div",{className:"relative shrink-0",children:[(0,s.jsx)(ts.A,{size:16,className:"text-[var(--amber)]"}),(0,s.jsx)(ec.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}):k?(0,s.jsx)(ej.A,{size:16,className:"text-success"}):(0,s.jsx)(ez.A,{size:16,className:"text-error"}),(0,s.jsx)("h2",{className:"text-base font-semibold text-foreground",children:d.organizeDetailTitle}),c&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums",children:d.organizeElapsed(m)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>g(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeMinimizeModal,children:(0,s.jsx)(Z.A,{size:14})}),(0,s.jsx)("button",{type:"button",onClick:D,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:14})})]})]}),(0,s.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 pb-2 space-y-4",children:[c&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-[var(--amber-subtle)] border border-[var(--amber-dim)]",children:[(0,s.jsx)(ec.A,{size:14,className:"text-[var(--amber)] animate-spin shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground",children:tg(o,x)})]}),e.sourceFileNames.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSourceFiles}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.sourceFileNames.map((e,t)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-muted/60 text-xs text-foreground",children:[(0,s.jsx)(th.A,{size:11,className:"text-muted-foreground shrink-0"}),e]},t))})]}),(e.summary||c)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSummaryLabel}),(0,s.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-muted/30 border border-border text-sm text-foreground leading-relaxed whitespace-pre-wrap",children:e.summary||d.organizeNoSummary})]}),e.changes.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeChangesLabel(e.changes.length)}),(0,s.jsx)("div",{className:"space-y-0.5",children:e.changes.map((e,t)=>R(e,t))})]}),N&&(0,s.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-error/5 border border-error/20 text-xs text-error",children:e.error})]}),(k||N)&&M()]})}):p&&(k||N)?(0,s.jsxs)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-[420px] max-w-[calc(100vw-2rem)] bg-card border border-border rounded-xl shadow-xl animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:z,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[k?(0,s.jsx)(ej.A,{size:14,className:"text-success"}):(0,s.jsx)(ez.A,{size:14,className:"text-error"}),(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:k?d.organizeReviewTitle:d.organizeErrorTitle})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{h(!1),g(!0)},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeDetailTitle,children:(0,s.jsx)(V.A,{size:13})}),(0,s.jsx)("button",{type:"button",onClick:()=>h(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(ey.A,{size:14})})]})]}),k&&(0,s.jsx)("div",{className:"max-h-[240px] overflow-y-auto p-2 space-y-0.5",children:e.changes.map((e,t)=>R(e,t))}),N&&(0,s.jsx)("div",{className:"p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.error})}),M()]}):(0,s.jsx)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 bg-card border border-border rounded-xl shadow-lg px-4 py-3 max-w-md animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:z,children:k?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ej.A,{size:16,className:"text-success shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeReviewDesc(C)}),e.changes.length>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>{h(!0),z()},className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,s.jsx)(ey.A,{size:12,className:"rotate-180"}),d.organizeExpand]}),(0,s.jsxs)("button",{type:"button",onClick:D,className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,s.jsx)(ej.A,{size:12}),d.organizeDone]})]}):N?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ez.A,{size:16,className:"text-error shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeError}),(0,s.jsx)("button",{type:"button",onClick:()=>{h(!0),z()},className:"text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:d.organizeExpand}),(0,s.jsx)("button",{type:"button",onClick:D,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,s.jsx)(u.A,{size:14})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative shrink-0",children:[(0,s.jsx)(ts.A,{size:16,className:"text-[var(--amber)]"}),(0,s.jsx)(ec.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:tg(o,x)}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums shrink-0",children:d.organizeElapsed(m)}),(0,s.jsx)("button",{type:"button",onClick:()=>{g(!0),z()},className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",title:d.organizeDetailTitle,children:(0,s.jsx)(V.A,{size:13})}),(0,s.jsx)("button",{type:"button",onClick:D,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,s.jsx)(u.A,{size:14})})]})})}var tv=r(87358);class ty{track(e,t){this.record({name:e,ts:Date.now(),props:t})}startTimer(e,t){let r=Date.now();return s=>{this.record({name:e,ts:r,durationMs:Date.now()-r,props:{...t??{},...s??{}}})}}getEvents(){return this.history.map(e=>({...e,props:e.props?{...e.props}:void 0}))}reset(){this.history=[],this.pending=[]}async flush(){if(0===this.pending.length)return 0;let e=this.pending.splice(0),t=tv.env.MINDOS_TELEMETRY_ENDPOINT?.trim();if(!t)return e.length;try{return await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),e.length}catch{return this.pending.unshift(...e),0}}record(e){this.history.push(e),this.history.length>200&&this.history.splice(0,this.history.length-200),this.pending.push(e),this.log(e)}log(e){}constructor(){this.history=[],this.pending=[]}}let tj=new ty;var tw=r(37206);function tk(){return(0,a.useEffect)(()=>em.zd.getState()._init(),[]),null}var tN=r(1934),tS=r(76449);let tC="mindos_walkthrough_done";function tA(e,t){if(e>=tS.g.length||t)try{localStorage.setItem(tC,"1")}catch{}fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{walkthroughStep:e,walkthroughDismissed:t}})}).catch(e=>{console.warn("[walkthrough-store] persist failed:",e)})}let tz=(0,tN.v)((e,t)=>{let r=tS.g.length;return{status:"idle",currentStep:0,totalSteps:r,start:()=>{e({currentStep:0,status:"active"}),tA(0,!1)},next:()=>{let s=t().currentStep+1;s>=r?(e({status:"completed"}),tA(r,!1)):(e({currentStep:s}),tA(s,!1))},back:()=>{let r=t().currentStep;r>0&&(e({currentStep:r-1}),tA(r-1,!1))},skip:()=>{e({status:"dismissed"}),tA(t().currentStep,!0)},_init:()=>{let t="1"===new URLSearchParams(window.location.search).get("welcome");if(t){let e=new URL(window.location.href);e.searchParams.delete("welcome"),window.history.replaceState({},"",e.pathname+(e.search||"")),window.dispatchEvent(new Event("mindos:first-visit"))}return window.innerWidth<768||function(){try{return"1"===localStorage.getItem(tC)}catch{return!1}}()?()=>{}:(fetch("/api/setup").then(e=>e.json()).then(s=>{let n=s.guideState;if(n){if(n.walkthroughDismissed||"number"==typeof n.walkthroughStep&&n.walkthroughStep>=r){try{localStorage.setItem(tC,"1")}catch{}return}n.active&&!n.dismissed&&void 0===n.walkthroughStep?t&&e({status:"active",currentStep:0}):"number"==typeof n.walkthroughStep&&n.walkthroughStep>=0&&n.walkthroughStep<r&&!n.walkthroughDismissed&&e({status:"active",currentStep:n.walkthroughStep})}}).catch(e=>{console.warn("[walkthrough-store] guideState read failed:",e)}),()=>{})}}});function tE({stepIndex:e,rect:t,position:r}){let n,i,o=tz(),{t:l}=(0,j.Y)(),[d,c]=(0,a.useState)({width:1024,height:768});if((0,a.useEffect)(()=>{let e=()=>c({width:window.innerWidth,height:window.innerHeight});return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),!o)return null;let u=l.walkthrough.steps[e];if(!u)return null;"right"===r?(n=t.top+t.height/2,i=t.right+12):(n=t.bottom+12,i=t.left+t.width/2);let m=d.width-320,x=d.height-200;return i=Math.min(i,m),n=Math.max(n=Math.min(n,x),8),(0,s.jsxs)("div",{className:`fixed z-[102] w-[280px] rounded-xl border shadow-lg animate-in fade-in duration-200 ${"right"===r?"slide-in-from-left-2":"slide-in-from-top-2"}`,style:{top:`${n}px`,left:`${i}px`,transform:"right"===r?"translateY(-50%)":"translateX(-50%)",background:"var(--card)",borderColor:"var(--amber)"},children:[(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,s.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:l.walkthrough.step(e+1,o.totalSteps)})}),(0,s.jsx)("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--foreground)"},children:u.title}),(0,s.jsx)("p",{className:"text-xs leading-relaxed",style:{color:"var(--muted-foreground)"},children:u.body}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-3",style:{borderTop:"1px solid var(--border)"},children:[(0,s.jsx)("button",{onClick:o.skip,className:"text-xs transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:l.walkthrough.skip}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e>0&&(0,s.jsx)("button",{onClick:o.back,className:"text-xs px-2.5 py-1 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:l.walkthrough.back}),(0,s.jsx)("button",{onClick:o.next,className:"text-xs px-3 py-1.5 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e===o.totalSteps-1?l.walkthrough.done:l.walkthrough.next})]})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-center gap-1.5 pb-3",children:Array.from({length:o.totalSteps},(t,r)=>(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full transition-all duration-200",style:{background:r===e?"var(--amber)":"var(--border)",transform:r===e?"scale(1.3)":void 0}},r))})]})}function tT(){let e=tz(),[t,r]=(0,a.useState)(null),[n,i]=(0,a.useState)(!1),o=(0,a.useId)(),l=e?tS.g[e.currentStep]:null,d=(0,a.useCallback)(()=>{if(!l)return;let e=document.querySelector(`[data-walkthrough="${l.anchor}"]`);e?r(e.getBoundingClientRect()):r(null)},[l]);(0,a.useEffect)(()=>{i(window.innerWidth<768),d();let e=()=>{i(window.innerWidth<768),d()};return window.addEventListener("resize",e),window.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",d,!0)}},[d]),(0,a.useEffect)(()=>{d();let e=setTimeout(d,100);return()=>clearTimeout(e)},[e?.currentStep,d]);let c=e?.skip;(0,a.useEffect)(()=>{if(!c)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[c]);let u=e?.currentStep??0;return((0,a.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>{document.querySelector(`[data-walkthrough="${l.anchor}"]`)||tz.getState().next()},500);return()=>clearTimeout(e)},[u]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{tz.getState().skip()},6e4);return()=>clearTimeout(e)},[u]),e&&l)?n?(0,s.jsx)(t$,{}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("svg",{className:"fixed inset-0 z-[100] pointer-events-auto",width:"100%",height:"100%",onClick:r=>{if(t){let s=r.clientX,n=r.clientY;s>=t.left-6&&s<=t.right+6&&n>=t.top-6&&n<=t.bottom+6||e.skip()}else e.skip()},children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("mask",{id:o,children:[(0,s.jsx)("rect",{width:"100%",height:"100%",fill:"white"}),t&&(0,s.jsx)("rect",{x:t.left-6,y:t.top-6,width:t.width+12,height:t.height+12,rx:8,ry:8,fill:"black"})]})}),(0,s.jsx)("rect",{width:"100%",height:"100%",fill:"rgba(0, 0, 0, 0.5)",mask:`url(#${o})`})]}),t&&(0,s.jsx)(tE,{stepIndex:e.currentStep,rect:t,position:l.position}),!t&&(0,s.jsx)("div",{className:"fixed inset-0 z-[101] flex items-center justify-center pointer-events-none",children:(0,s.jsx)("button",{onClick:e.skip,className:"pointer-events-auto px-4 py-2 text-sm rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?"✓":"→"})})]}):null}function t$(){let e=tz(),{t}=(0,j.Y)();if(!e)return null;let r=t.walkthrough.steps[e.currentStep];return r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-sm",onClick:e.skip}),(0,s.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 z-[101] rounded-t-2xl border-t shadow-lg p-5 pb-8 animate-in slide-in-from-bottom duration-300",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:t.walkthrough.step(e.currentStep+1,e.totalSteps)}),(0,s.jsx)("div",{className:"flex items-center gap-1 ml-auto",children:Array.from({length:e.totalSteps},(t,r)=>(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:r===e.currentStep?"var(--amber)":"var(--border)"}},r))})]}),(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",style:{color:"var(--foreground)"},children:r.title}),(0,s.jsx)("p",{className:"text-sm leading-relaxed mb-5",style:{color:"var(--muted-foreground)"},children:r.body}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("button",{onClick:e.skip,className:"text-sm transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:t.walkthrough.skip}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.currentStep>0&&(0,s.jsx)("button",{onClick:e.back,className:"text-sm px-3 py-2 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:t.walkthrough.back}),(0,s.jsx)("button",{onClick:e.next,className:"text-sm px-4 py-2 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?t.walkthrough.done:t.walkthrough.next})]})]})]})]}):null}function tD(){return(0,a.useEffect)(()=>tz.getState()._init(),[]),"active"===tz(e=>e.status)?(0,s.jsx)(tT,{}):null}let tR=new Set(["mp3","wav","m4a","ogg","flac","aac"]),tM=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico"]),tP=new Set(["mp4","webm","mov","mkv"]);for(let e of[{id:"agent-inspector",name:"Agent Inspector",description:"Visualizes agent tool-call logs as a filterable timeline. Auto-activates on .mindos/agent-audit-log.json and supports legacy .agent-log.json.",author:"MindOS",icon:"\uD83D\uDD0D",tags:["agent","inspector","log","mcp","tools"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/agent-audit-log.json",match:({filePath:e})=>/(^|\/)\.mindos\/agent-audit-log\.json$/i.test(e)||/\.agent-log\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,18847)).then(e=>({default:e.AgentInspectorRenderer}))},{id:"audio",name:"Audio Player",description:"Plays audio files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFB5",tags:["audio","music","voice","mp3","wav"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tR.has(e),load:()=>Promise.resolve().then(r.bind(r,14446)).then(e=>({default:e.AudioRenderer}))},{id:"backlinks",name:"Backlinks Explorer",description:"Shows all files that link to the current page via wikilinks or markdown links, with highlighted snippet context.",author:"MindOS",icon:"\uD83D\uDD17",tags:["backlinks","wiki","links","references"],builtin:!0,entryPath:"BACKLINKS.md",match:({filePath:e})=>/\bBACKLINKS\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,88946)).then(e=>({default:e.BacklinksRenderer}))},{id:"change-log",name:"Content Changes",description:"Renders the .mindos/change-log.json file as a searchable timeline of content edits.",author:"MindOS",icon:"\uD83D\uDCCB",tags:["changelog","history","changes"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({filePath:e})=>/\.mindos\/change-log\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,57025)).then(e=>({default:e.ChangeLogRenderer}))},{id:"config-panel",name:"Config Panel",description:"Renders CONFIG.json as an editable control panel based on uiSchema/keySpecs. Changes are written back to the JSON file directly.",author:"MindOS",icon:"\uD83E\uDDE9",tags:["config","json","settings","schema"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"CONFIG.json",match:({filePath:e,extension:t})=>"json"===t&&/(^|\/)CONFIG\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,35504)).then(e=>({default:e.ConfigRenderer}))},{id:"csv",name:"CSV Views",description:"Renders any CSV file as Table, Gallery, or Board. Each view is independently configurable — choose which columns map to title, description, tag, and group.",author:"MindOS",icon:"\uD83D\uDCCA",tags:["csv","table","gallery","board","data"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"Resources/Products.csv",match:({extension:e,filePath:t})=>"csv"===e&&!/\bTODO\b/i.test(t),load:()=>Promise.resolve().then(r.bind(r,92306)).then(e=>({default:e.CsvRenderer}))},{id:"image",name:"Image Viewer",description:"Renders image files with zoom, fit-to-view, and transparency support.",author:"MindOS",icon:"\uD83D\uDDBC",tags:["image","photo","viewer","png","jpg","svg"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tM.has(e),load:()=>Promise.resolve().then(r.bind(r,20814)).then(e=>({default:e.ImageRenderer}))},{id:"pdf",name:"PDF Viewer",description:"Renders PDF files using the browser built-in PDF viewer.",author:"MindOS",icon:"\uD83D\uDCC4",tags:["pdf","document","viewer"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>"pdf"===e,load:()=>Promise.resolve().then(r.bind(r,20870)).then(e=>({default:e.PdfRenderer}))},{id:"summary",name:"AI Briefing",description:"Streams an AI-generated daily briefing summarizing your most recently modified files — key changes, recurring themes, and suggested next actions.",author:"MindOS",icon:"✨",tags:["ai","summary","briefing","daily"],builtin:!0,entryPath:"DAILY.md",match:({filePath:e})=>/\b(SUMMARY|summary|Summary|BRIEFING|briefing|Briefing|DAILY|daily|Daily)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,56406)).then(e=>({default:e.SummaryRenderer}))},{id:"timeline",name:"Timeline",description:"Renders changelog and journal files as a vertical timeline. Any markdown with ## date headings (e.g. ## 2025-01-15) becomes a card in the feed.",author:"MindOS",icon:"\uD83D\uDCC5",tags:["timeline","changelog","journal","history"],builtin:!0,entryPath:"CHANGELOG.md",match:({filePath:e})=>/\b(CHANGELOG|changelog|TIMELINE|timeline|journal|Journal|diary|Diary)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,39594)).then(e=>({default:e.TimelineRenderer}))},{id:"todo",name:"TODO Board",description:"Renders TODO.md/TODO.csv as an interactive kanban board grouped by section. Check items off directly — changes are written back to the source file.",author:"MindOS",icon:"✅",tags:["productivity","tasks","markdown"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"TODO.md",match:({filePath:e})=>/\bTODO\b.*\.(md|csv)$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,78660)).then(e=>({default:e.TodoRenderer}))},{id:"video",name:"Video Player",description:"Plays video files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFAC",tags:["video","movie","recording","mp4","webm"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tP.has(e),load:()=>Promise.resolve().then(r.bind(r,87986)).then(e=>({default:e.VideoRenderer}))},{id:"workflow-yaml",name:"Workflow Runner",description:"Execute step-by-step YAML workflows with Skills & Agent support.",author:"MindOS",icon:"⚡",tags:["workflow","automation","steps","ai","yaml"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/workflows/",match:({extension:e,filePath:t})=>("yaml"===e||"yml"===e)&&/\.flow\.(yaml|yml)$/i.test(t),load:()=>Promise.resolve().then(r.bind(r,48133)).then(e=>({default:e.WorkflowYamlRenderer}))},{id:"graph",name:"Wiki Graph",description:"Force-directed graph of wikilink references across all markdown files. Supports Global and Local (2-hop) scope filters.",author:"MindOS",icon:"\uD83D\uDD78️",tags:["graph","wiki","links","visualization"],builtin:!0,match:()=>!1,load:()=>Promise.resolve().then(r.bind(r,92950)).then(e=>({default:e.GraphRenderer}))}])(0,eH.TS)(e);var tF=r(48391),tL=r(29494);let tI=(0,tw.default)(()=>r.e(5576).then(r.bind(r,95576)),{loadableGenerated:{webpack:()=>[95576]},ssr:!1}),tO=(0,tw.default)(()=>r.e(2935).then(r.bind(r,22935)),{loadableGenerated:{webpack:()=>[22935]},ssr:!1}),tW=(0,tw.default)(()=>Promise.all([r.e(9207),r.e(6610)]).then(r.bind(r,96610)),{loadableGenerated:{webpack:()=>[96610]},ssr:!1}),tB=(0,tw.default)(()=>r.e(1342).then(r.bind(r,51342)),{loadableGenerated:{webpack:()=>[51342]},ssr:!1}),t_=(0,tw.default)(()=>r.e(1814).then(r.bind(r,51814)),{loadableGenerated:{webpack:()=>[51814]},ssr:!1}),tU=()=>{};function tH({fileTree:e,children:t}){let r=function(){let[e,t]=(0,a.useState)("files"),[r,s]=(0,a.useState)(null),[n,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"true"===localStorage.getItem("rail-expanded")&&l(!0)}catch{}},[]),(0,a.useEffect)(()=>{if(e){try{let e=localStorage.getItem("left-panel-width");if(e){let t=parseInt(e,10);if(t>=240&&t<=600)return void s(t)}}catch{}s(280)}},[e]),(0,a.useEffect)(()=>{i(!1)},[e]);let d=(0,a.useCallback)(e=>s(e),[]),c=(0,a.useCallback)(e=>{try{localStorage.setItem("left-panel-width",String(e))}catch{}},[]),u=(0,a.useCallback)(()=>i(e=>!e),[]),m=(0,a.useCallback)(e=>{l(e);try{localStorage.setItem("rail-expanded",String(e))}catch{}},[]),x=null!==e,p=r??(e?es[e]:280);return{activePanel:e,setActivePanel:t,panelWidth:r,panelMaximized:n,railExpanded:o,railWidth:o?180:48,panelOpen:x,effectivePanelWidth:p,handlePanelWidthChange:d,handlePanelWidthCommit:c,handlePanelMaximize:u,handleExpandedChange:m}}(),i=function(){let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(380),[n,i]=(0,a.useState)("panel"),[o,l]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),x=(0,a.useRef)(!1);x.current=u;let[p,h]=(0,a.useState)("user"),[f,g]=(0,a.useState)(null),b=(0,a.useRef)(380),v=(0,eU.KT)();(0,a.useEffect)(()=>{try{let e=localStorage.getItem("right-ask-panel-width");if(e){let t=parseInt(e,10);t>=320&&t<=4e3?(s(t),b.current=t):t>4e3&&(s(380),b.current=380)}let t=localStorage.getItem("ask-mode");"popup"===t&&i("popup")}catch{}let e=e=>{"ask-mode"===e.key&&("panel"===e.newValue||"popup"===e.newValue)&&i(e.newValue)};window.addEventListener("storage",e);let r=()=>{t(!0),x.current&&(m(!1),s(b.current))};return window.addEventListener("mindos:open-ask-panel",r),()=>{window.removeEventListener("storage",e),window.removeEventListener("mindos:open-ask-panel",r)}},[]),(0,a.useEffect)(()=>{v.open&&(c(v.initialMessage),h(v.source),g(v.acpAgent),"popup"===n?l(!0):t(!0),v.close())},[v.open,v.initialMessage,v.source,v.acpAgent,v.close,n]);let y=(0,a.useCallback)(()=>{"popup"===n?l(e=>(e||(c(""),h("user"),g(null)),!e)):t(e=>(e||(c(""),h("user"),g(null)),!e))},[n]),j=(0,a.useCallback)(()=>{t(!1),u&&(s(b.current),m(!1))},[u]),w=(0,a.useCallback)(()=>{m(e=>(e?s(b.current):b.current=r,!e))},[r]),k=(0,a.useCallback)(()=>l(!1),[]),N=(0,a.useCallback)(e=>s(e),[]);return{askPanelOpen:e,askPanelWidth:r,askMaximized:u,askMode:n,desktopAskPopupOpen:o,askInitialMessage:d,askOpenSource:p,askAcpAgent:f,toggleAskPanel:y,closeAskPanel:j,closeDesktopAskPopup:k,handleAskWidthChange:N,handleAskWidthCommit:(0,a.useCallback)(e=>{try{localStorage.setItem("right-ask-panel-width",String(e))}catch{}},[]),handleAskModeSwitch:(0,a.useCallback)(()=>{i(e=>{let r="panel"===e?"popup":"panel";try{localStorage.setItem("ask-mode",r),window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:r}))}catch{}return"popup"===r?(t(!1),l(!0)):(l(!1),t(!0)),r})},[]),toggleAskMaximized:w}}(),[x,p]=(0,a.useState)(!1),[h,f]=(0,a.useState)(void 0),[g,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(null),[w,k]=(0,a.useState)(null),[N,S]=(0,a.useState)(()=>{try{let e=localStorage.getItem("right-agent-detail-panel-width");if(e){let t=parseInt(e,10);if(t>=300&&t<=640)return t}}catch{}return 400}),C=(0,tF.dB)(),[A,E]=(0,a.useState)(!1),[T,$]=(0,a.useState)(0);(0,a.useEffect)(()=>{("organizing"===C.phase||"done"===C.phase||"error"===C.phase)&&E(!0)},[C.phase]);let M=(0,a.useCallback)(()=>{E(!1),"organizing"!==C.phase||C.abort(),C.reset()},[C]),P=(0,a.useCallback)(()=>{$(e=>e+1),window.dispatchEvent(new Event("mindos:organize-history-update"))},[]),[L,I]=(0,a.useState)(!1),[O,W]=(0,a.useState)(void 0),[B,_]=(0,a.useState)(void 0),[U,H]=(0,a.useState)(!1),K=(0,a.useRef)(0),X=(0,a.useCallback)(e=>{W(e),_(void 0),I(!0)},[]),Y=(0,a.useCallback)(()=>{I(!1),W(void 0),_(void 0)},[]),[J,Z]=(0,a.useState)(!1),[V,q]=(0,a.useState)(!1),[Q,ee]=(0,a.useState)(!1),{t:et}=(0,j.Y)(),er=(0,n.useRouter)(),ea=(0,n.usePathname)(),ei=(0,a.useMemo)(()=>{let t=tj.startTimer("sidebar.collect_dir_paths"),r=function e(t,r=""){let s=[];for(let n of t)if("directory"===n.type&&!n.name.startsWith(".")){let t=r?`${r}/${n.name}`:n.name;s.push(t),n.children&&s.push(...e(n.children,t))}return s}(e);return t({nodeCount:e.length,pathCount:r.length}),r},[e]),{status:eo,fetchStatus:el}=z(),ec=ea.startsWith("/view/")?ea.slice(6).split("/").map(decodeURIComponent).join("/"):void 0;(0,a.useEffect)(()=>{i.askMaximized&&i.toggleAskMaximized()},[ea,r.panelOpen]);let eu=(0,a.useCallback)(()=>{i.askMaximized&&i.toggleAskMaximized()},[i.askMaximized,i.toggleAskMaximized]);(0,a.useEffect)(()=>{"/"===ea&&i.askPanelOpen&&i.closeAskPanel()},[ea]);let em=ea?.startsWith("/agents"),ex=r.activePanel??(em?"agents":null);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.tab;t&&f(t),p(!0)};return window.addEventListener("mindos:open-settings",e),()=>window.removeEventListener("mindos:open-settings",e)},[]),(0,a.useEffect)(()=>{let e=()=>X();return window.addEventListener("mindos:open-import",e),()=>window.removeEventListener("mindos:open-import",e)},[X]);let ep=(0,a.useRef)([]);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.files;if(!t||0===t.length||"organizing"===C.phase)return;let r=et.inbox.organizePrompt(t.map(e=>e.name));ep.current=t.map(e=>e.name),(async()=>{let e=[];for(let r of t)try{let t=await fetch(`/api/file?path=${encodeURIComponent(r.path)}`);if(t.ok){let s=await t.json();e.push({name:r.name,content:s.content??""})}}catch{}e.length>0?C.start(e,r,"inbox-organize"):(e9.oR.error(et.inbox.organizeFailed,4e3),window.dispatchEvent(new Event("mindos:organize-done")))})()};return window.addEventListener("mindos:inbox-organize",e),()=>window.removeEventListener("mindos:inbox-organize",e)},[C,et]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.content||"organizing"===C.phase)return;let r={name:t.name,content:t.content};C.start([r],"Organize this conversation into well-structured notes in my knowledge base. Extract key insights, decisions, action items, and important details. Create appropriate files with clear titles. Write in the same language as the content.","conversation")};return window.addEventListener("mindos:session-organize",e),()=>window.removeEventListener("mindos:session-organize",e)},[C]),(0,a.useEffect)(()=>{if("done"===C.phase){let e=C.changes.some(e=>e.ok),t=ep.current;e&&t.length>0&&(fetch("/api/inbox",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:t})}).then(()=>{window.dispatchEvent(new Event("mindos:inbox-updated"))}).catch(()=>{}),ep.current=[]),window.dispatchEvent(new Event("mindos:organize-done"))}else"error"===C.phase&&window.dispatchEvent(new Event("mindos:organize-done"))},[C.phase,C.changes]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.panel;t&&r.setActivePanel(t)};return window.addEventListener("mindos:open-panel",e),()=>window.removeEventListener("mindos:open-panel",e)},[r]);let eh=(0,a.useCallback)(()=>{let e=()=>window.dispatchEvent(new Event("guide-state-updated"));"guide"===i.askOpenSource?fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{askedAI:!0}})}).then(e).catch(e=>console.warn("Guide state update failed:",e)):"guide-next"===i.askOpenSource&&e()},[i.askOpenSource]);(0,a.useEffect)(()=>{let e=requestAnimationFrame(()=>Z(!1));return()=>cancelAnimationFrame(e)},[ea]),(0,a.useEffect)(()=>{ea?.startsWith("/echo")&&r.setActivePanel("echo")},[ea,r.setActivePanel]);let ef=(0,a.useCallback)(e=>{S(e);try{localStorage.setItem("right-agent-detail-panel-width",String(e))}catch{}},[]),eg=(0,a.useCallback)(()=>k(null),[]),eb=null!==w&&"agents"===r.activePanel;(0,a.useEffect)(()=>{let e=-1,t=!1,r=0,s=null,n=(e,t)=>{r=Date.now();let s=tj.startTimer("tree.refresh.trigger");(0,a.startTransition)(()=>{er.refresh()}),s({previousVersion:t,version:e,reason:"tree_version_changed"}),window.dispatchEvent(new Event("mindos:files-changed"))},i=async()=>{if(t||"hidden"===document.visibilityState)return;let a=tj.startTimer("tree.version.poll");try{let i=await fetch("/api/tree-version");if(!i.ok)return void a({ok:!1,changed:!1});let{v:o}=await i.json();if(-1===e){e=o,a({ok:!0,changed:!1,version:o,initial:!0});return}if(o!==e){let i=e;e=o;let l=Date.now()-r;l<2e3?(s&&clearTimeout(s),s=setTimeout(()=>{s=null,t||n(o,i)},2e3-l),a({ok:!0,changed:!0,previousVersion:i,version:o,deferred:!0})):(n(o,i),a({ok:!0,changed:!0,previousVersion:i,version:o}));return}a({ok:!0,changed:!1,version:o})}catch(e){a({ok:!1,changed:!1}),console.debug("[tree-version] poll failed",e)}},o=()=>{"visible"===document.visibilityState&&i()};i();let l=setInterval(()=>void i(),5e3);return document.addEventListener("visibilitychange",o),()=>{t=!0,clearInterval(l),s&&clearTimeout(s),document.removeEventListener("visibilitychange",o)}},[er]),(0,a.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(r.panelMaximized)return void r.handlePanelMaximize();if(eb)return void k(null);if(i.askPanelOpen)return void i.closeAskPanel();if(i.desktopAskPopupOpen)return void i.closeDesktopAskPopup()}(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),window.innerWidth>=768?r.setActivePanel(e=>"search"===e?null:"search"):q(e=>!e)),(e.metaKey||e.ctrlKey)&&"/"===e.key&&(e.preventDefault(),window.innerWidth>=768?i.toggleAskPanel():ee(e=>!e)),(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),p(e=>!e)),(e.metaKey||e.ctrlKey)&&"i"===e.key&&(e.preventDefault(),I(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eb,r,i]);let ev=(0,a.useCallback)(()=>{f("sync"),b(!1),p(!0)},[]),ey=(0,a.useCallback)(()=>{p(!0),f(void 0)},[]),ej=(0,a.useCallback)(()=>{p(!1),f(void 0)},[]),ew=(0,a.useCallback)(e=>{y(e),b(e=>!e)},[]),ek=(0,a.useCallback)(e=>{r.handleExpandedChange(e),b(!1)},[r]),eN=(0,a.useCallback)(()=>Z(!1),[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tk,{}),(0,s.jsx)(tD,{}),(0,s.jsx)("a",{href:"#main-content",className:"sr-only focus-visible:not-sr-only focus-visible:fixed focus-visible:top-2 focus-visible:left-2 focus-visible:z-[60] focus-visible:px-4 focus-visible:py-2 focus-visible:rounded-lg focus-visible:text-sm focus-visible:font-medium bg-[var(--amber)] text-[var(--amber-foreground)]",children:"Skip to main content"}),(0,s.jsx)(F,{activePanel:ex,onPanelChange:r.setActivePanel,onEchoClick:()=>{eu();let e="echo"===r.activePanel,t=ea?.startsWith("/echo");e?t?r.setActivePanel(null):er.push("/echo/about-you"):(r.setActivePanel("echo"),er.push("/echo/about-you"))},onAgentsClick:()=>{eu();let e="agents"===r.activePanel,t=ea?.startsWith("/agents");e?t?r.setActivePanel(null):er.push("/agents"):(r.setActivePanel("agents"),er.push("/agents")),k(null)},onDiscoverClick:()=>{eu();let e="discover"===r.activePanel,t=ea?.startsWith("/explore");e?t?r.setActivePanel(null):er.push("/explore"):(r.setActivePanel("discover"),er.push("/explore"))},onSpacesClick:()=>{eu();let e="/"===ea,t="files"===r.activePanel,s="/wiki"===ea||ea?.startsWith("/view/")||ea?.startsWith("/wiki/");e||!t?(r.setActivePanel("files"),er.push("/wiki")):s?r.setActivePanel(null):er.push("/wiki")},syncStatus:eo,expanded:r.railExpanded,onExpandedChange:ek,onSettingsClick:ey,onSyncClick:ew}),(0,s.jsxs)(en,{activePanel:r.activePanel,fileTree:e,onNavigate:tU,onOpenSyncSettings:ev,railWidth:r.railWidth,panelWidth:r.panelWidth??void 0,onWidthChange:r.handlePanelWidthChange,onWidthCommit:r.handlePanelWidthCommit,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize,onImport:X,children:[(0,s.jsx)("div",{className:`flex flex-col h-full ${"echo"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(e0,{active:"echo"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"search"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(ed,{active:"search"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"agents"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(eD,{active:"agents"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize,selectedAgentKey:eb?w:null})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"discover"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(eJ,{active:"discover"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"workflows"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(e2,{active:"workflows"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})})]}),(0,s.jsx)(e4,{open:i.askPanelOpen,onClose:i.closeAskPanel,currentFile:ec,initialMessage:i.askInitialMessage,initialAcpAgent:i.askAcpAgent,onFirstMessage:eh,width:i.askPanelWidth,onWidthChange:i.handleAskWidthChange,onWidthCommit:i.handleAskWidthCommit,askMode:i.askMode,onModeSwitch:i.handleAskModeSwitch,maximized:i.askMaximized,onMaximize:i.toggleAskMaximized,sidebarOffset:r.panelOpen?r.railWidth+r.effectivePanelWidth:r.railWidth}),(0,s.jsx)(tr,{open:eb,agentKey:w,onClose:eg,rightOffset:i.askPanelOpen?i.askPanelWidth:0,width:N,onWidthChange:S,onWidthCommit:ef}),(0,s.jsx)(tO,{open:i.desktopAskPopupOpen,onClose:i.closeDesktopAskPopup,currentFile:ec,initialMessage:i.askInitialMessage,initialAcpAgent:i.askAcpAgent,onFirstMessage:eh,askMode:i.askMode,onModeSwitch:i.handleAskModeSwitch}),(0,s.jsx)(tn,{onToggle:i.toggleAskPanel,askPanelOpen:i.askPanelOpen||i.desktopAskPopupOpen}),(0,s.jsx)(ti,{}),(0,s.jsx)(tW,{open:x,onClose:ej,initialTab:h}),(0,s.jsx)(ta,{open:g,onClose:()=>b(!1),anchorRect:v,railWidth:r.railWidth,onOpenSyncSettings:ev,syncStatus:eo,onSyncStatusRefresh:el}),(0,s.jsxs)("header",{className:"md:hidden fixed top-0 left-0 right-0 z-30 bg-card border-b border-border flex items-center justify-between px-3 py-2",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[(0,s.jsx)("button",{onClick:()=>Z(!0),className:"p-3 -ml-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":"Open menu",children:(0,s.jsx)(l.A,{size:20})}),(0,s.jsxs)(o(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(R.A,{id:"mobile"}),(0,s.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,s.jsx)("button",{onClick:ev,className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent flex items-center justify-center","aria-label":"Sync status",children:(0,s.jsx)(D,{status:eo})}),(0,s.jsx)("button",{onClick:()=>q(!0),className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":et.sidebar.searchTitle,children:(0,s.jsx)(d.A,{size:20})}),(0,s.jsx)("button",{onClick:()=>{p(!0),f(void 0)},className:"p-3 -mr-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":et.sidebar.settingsTitle,children:(0,s.jsx)(c.A,{size:20})})]})]}),J&&(0,s.jsx)("div",{className:"md:hidden fixed inset-0 z-40 overlay-backdrop",onClick:()=>Z(!1)}),(0,s.jsxs)("aside",{className:`md:hidden fixed top-0 left-0 h-screen w-[85vw] max-w-[320px] z-50 bg-card border-r border-border flex flex-col transition-transform duration-300 ease-in-out ${J?"translate-x-0":"-translate-x-full"}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border shrink-0",children:[(0,s.jsxs)(o(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(R.A,{id:"drawer"}),(0,s.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,s.jsx)("button",{onClick:()=>Z(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:16})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-2 py-2",children:(0,s.jsx)(G.Ay,{nodes:e,onNavigate:eN,onImport:X})})]}),(0,s.jsx)(tI,{open:V,onClose:()=>q(!1)}),(0,s.jsx)(tO,{open:Q,onClose:()=>ee(!1),currentFile:ec}),(0,s.jsxs)("main",{id:"main-content",className:"min-h-screen transition-all duration-200 pt-[52px] md:pt-0",onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),K.current++,1===K.current&&H(!0))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&e.preventDefault()},onDragLeave:()=>{K.current=Math.max(0,K.current-1),0===K.current&&H(!1)},onDrop:e=>{e.preventDefault(),K.current=0,H(!1),e.dataTransfer.files.length>0&&!L&&(0,tL.QL)(Array.from(e.dataTransfer.files),et)},children:[(0,s.jsxs)("div",{className:"min-h-screen bg-background",style:{overflowX:"clip"},children:[(0,s.jsx)(to,{}),t]}),(0,s.jsx)(tc,{}),(0,s.jsx)(tB,{t:et,dirPaths:ei}),U&&!L&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",children:(0,s.jsxs)("div",{className:"border-2 border-dashed border-[var(--amber)]/50 rounded-xl p-12 flex flex-col items-center gap-3",children:[(0,s.jsx)(m.A,{size:48,className:"text-[var(--amber)]/60"}),(0,s.jsx)("p",{className:"text-sm text-foreground font-medium",children:et.inbox.dropOverlay}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:et.inbox.dropOverlayFormats})]})})]}),(0,s.jsx)(t_,{open:L,onClose:Y,defaultSpace:O,initialFiles:B,aiOrganize:C,dirPaths:ei}),A&&(0,s.jsx)(tb,{aiOrganize:C,onDismiss:M,onCancel:()=>{C.abort(),C.reset(),E(!1)},onHistoryUpdate:P}),(0,s.jsx)("style",{children:`
|
|
70
|
+
`})]})}var tm=r(93631),tx=r(3926),tp=r(22164),th=r(78916),tf=r(78520);function tg(e,t){let r=e.fileImport;if(!t)return r.organizeProcessing;switch(t.stage){case"connecting":return r.organizeConnecting;case"analyzing":return r.organizeAnalyzing;case"reading":return r.organizeReading(t.detail);case"thinking":return r.organizeThinking;case"writing":return r.organizeWriting(t.detail);default:return r.organizeProcessing}}function tb({aiOrganize:e,onDismiss:t,onCancel:r,onHistoryUpdate:i}){let{t:o}=(0,j.Y)(),l=(0,n.useRouter)(),d=o.fileImport,c="organizing"===e.phase,{elapsed:m,displayHint:x}=function(e,t){let[r,s]=(0,a.useState)(0),[n,i]=(0,a.useState)(!1),o=(0,a.useRef)(Date.now());return(0,a.useEffect)(()=>{o.current=Date.now(),i(!1)},[t]),(0,a.useEffect)(()=>{if(!e){s(0),i(!1);return}let t=setInterval(()=>{s(e=>e+1),Date.now()-o.current>=5e3&&i(!0)},1e3);return()=>clearInterval(t)},[e]),{elapsed:r,displayHint:n?{stage:"thinking"}:t}}(c,e.stageHint),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!1),y=(0,a.useRef)(null),w=(0,a.useRef)(null),k="done"===e.phase,N="error"===e.phase,S=c||k||N,C=e.changes.filter(e=>e.ok&&!e.undone).length;(0,a.useEffect)(()=>{c&&(w.current=null)},[c]),(0,a.useEffect)(()=>{if(k&&!w.current){let t=(0,tf.jQ)();w.current=t,(0,tf.D4)({id:t,timestamp:Date.now(),sourceFiles:e.sourceFileNames,files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.undone})),status:"completed",source:e.source,durationMs:e.durationMs}),i?.()}},[k,e.changes,e.sourceFileNames,e.source,e.durationMs,i]);let A=(0,a.useCallback)(()=>{y.current&&clearTimeout(y.current),(k||N)&&(y.current=setTimeout(()=>{t()},18e4))},[k,N,t]);(0,a.useEffect)(()=>(A(),()=>{y.current&&clearTimeout(y.current)}),[A]);let z=(0,a.useCallback)(()=>{A()},[A]),E=(0,a.useCallback)(async t=>{z(),v(!0);let r=await e.undoOne(t);v(!1),r&&(window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(()=>{if(w.current){let r=e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.path===t||e.undone})),s=r.every(e=>!e.ok||e.undone);(0,tf.W8)(w.current,{files:r,status:s?"undone":"partial"}),i?.()}},0))},[e,z,i]),T=(0,a.useCallback)(async()=>{z(),v(!0);let t=await e.undoAll();v(!1),t>0&&(window.dispatchEvent(new Event("mindos:files-changed")),w.current&&((0,tf.W8)(w.current,{files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:!!e.ok||e.undone})),status:"undone"}),i?.()))},[e,z,i]),$=(0,a.useCallback)(e=>{z(),l.push(`/view/${(0,ei.O0)(e)}`)},[l,z]),D=(0,a.useCallback)(()=>{t()},[t]);if(!S)return null;function R(t,r){let n=t.undone,a=e.canUndo(t.path),i=t.path.split("/").pop()??t.path;return(0,s.jsxs)("div",{className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors ${n?"bg-muted/30 opacity-50":"bg-muted/50"}`,children:[n?(0,s.jsx)(tl.A,{size:14,className:"text-muted-foreground shrink-0"}):"create"===t.action?(0,s.jsx)(tm.A,{size:14,className:"text-success shrink-0"}):(0,s.jsx)(tx.A,{size:14,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:`truncate flex-1 ${n?"line-through text-muted-foreground":"text-foreground"}`,children:i}),n?(0,s.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:d.organizeUndone}):(0,s.jsx)("span",{className:`text-xs shrink-0 ${t.ok?"text-muted-foreground":"text-error"}`,children:t.ok?"create"===t.action?d.organizeCreated:d.organizeUpdated:d.organizeFailed}),a&&(0,s.jsx)("button",{type:"button",onClick:()=>E(t.path),disabled:b,className:"text-2xs text-muted-foreground/60 hover:text-foreground transition-colors shrink-0 px-1 disabled:opacity-40",title:d.organizeUndoOne,children:(0,s.jsx)(tl.A,{size:12})}),t.ok&&!t.undone&&(0,s.jsx)("button",{type:"button",onClick:()=>$(t.path),className:"text-2xs text-muted-foreground/60 hover:text-[var(--amber)] transition-colors shrink-0 px-1",title:d.organizeViewFile,children:(0,s.jsx)(tp.A,{size:12})})]},`${t.path}-${r}`)}function M(){return(0,s.jsxs)("div",{className:"flex items-center justify-end gap-3 px-4 py-3 border-t border-border",children:[k&&e.hasAnyUndoable&&(0,s.jsxs)("button",{onClick:T,disabled:b,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1.5 disabled:opacity-50",children:[b?(0,s.jsx)(ec.A,{size:12,className:"animate-spin"}):(0,s.jsx)(tl.A,{size:12}),d.organizeUndoAll]}),(0,s.jsxs)("button",{onClick:D,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-all",children:[(0,s.jsx)(ej.A,{size:12}),d.organizeDone]})]})}return f?(0,s.jsx)("div",{className:"fixed inset-0 z-50 overlay-backdrop flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&g(!1)},children:(0,s.jsxs)("div",{className:"w-full max-w-xl max-h-[80vh] flex flex-col bg-card rounded-xl shadow-xl border border-border animate-in fade-in-0 zoom-in-95 duration-200",onClick:z,role:"dialog","aria-modal":"true","aria-label":d.organizeDetailTitle,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3 shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,s.jsxs)("div",{className:"relative shrink-0",children:[(0,s.jsx)(ts.A,{size:16,className:"text-[var(--amber)]"}),(0,s.jsx)(ec.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}):k?(0,s.jsx)(ej.A,{size:16,className:"text-success"}):(0,s.jsx)(ez.A,{size:16,className:"text-error"}),(0,s.jsx)("h2",{className:"text-base font-semibold text-foreground",children:d.organizeDetailTitle}),c&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums",children:d.organizeElapsed(m)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>g(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeMinimizeModal,children:(0,s.jsx)(Z.A,{size:14})}),(0,s.jsx)("button",{type:"button",onClick:D,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:14})})]})]}),(0,s.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 pb-2 space-y-4",children:[c&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-[var(--amber-subtle)] border border-[var(--amber-dim)]",children:[(0,s.jsx)(ec.A,{size:14,className:"text-[var(--amber)] animate-spin shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground",children:tg(o,x)})]}),e.sourceFileNames.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSourceFiles}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.sourceFileNames.map((e,t)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-muted/60 text-xs text-foreground",children:[(0,s.jsx)(th.A,{size:11,className:"text-muted-foreground shrink-0"}),e]},t))})]}),(e.summary||c)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSummaryLabel}),(0,s.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-muted/30 border border-border text-sm text-foreground leading-relaxed whitespace-pre-wrap",children:e.summary||d.organizeNoSummary})]}),e.changes.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeChangesLabel(e.changes.length)}),(0,s.jsx)("div",{className:"space-y-0.5",children:e.changes.map((e,t)=>R(e,t))})]}),N&&(0,s.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-error/5 border border-error/20 text-xs text-error",children:e.error})]}),(k||N)&&M()]})}):p&&(k||N)?(0,s.jsxs)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-[420px] max-w-[calc(100vw-2rem)] bg-card border border-border rounded-xl shadow-xl animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:z,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[k?(0,s.jsx)(ej.A,{size:14,className:"text-success"}):(0,s.jsx)(ez.A,{size:14,className:"text-error"}),(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:k?d.organizeReviewTitle:d.organizeErrorTitle})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{h(!1),g(!0)},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeDetailTitle,children:(0,s.jsx)(V.A,{size:13})}),(0,s.jsx)("button",{type:"button",onClick:()=>h(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(ey.A,{size:14})})]})]}),k&&(0,s.jsx)("div",{className:"max-h-[240px] overflow-y-auto p-2 space-y-0.5",children:e.changes.map((e,t)=>R(e,t))}),N&&(0,s.jsx)("div",{className:"p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.error})}),M()]}):(0,s.jsx)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 bg-card border border-border rounded-xl shadow-lg px-4 py-3 max-w-md animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:z,children:k?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ej.A,{size:16,className:"text-success shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeReviewDesc(C)}),e.changes.length>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>{h(!0),z()},className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,s.jsx)(ey.A,{size:12,className:"rotate-180"}),d.organizeExpand]}),(0,s.jsxs)("button",{type:"button",onClick:D,className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,s.jsx)(ej.A,{size:12}),d.organizeDone]})]}):N?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ez.A,{size:16,className:"text-error shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeError}),(0,s.jsx)("button",{type:"button",onClick:()=>{h(!0),z()},className:"text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:d.organizeExpand}),(0,s.jsx)("button",{type:"button",onClick:D,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,s.jsx)(u.A,{size:14})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative shrink-0",children:[(0,s.jsx)(ts.A,{size:16,className:"text-[var(--amber)]"}),(0,s.jsx)(ec.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}),(0,s.jsx)("span",{className:"text-xs text-foreground truncate",children:tg(o,x)}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums shrink-0",children:d.organizeElapsed(m)}),(0,s.jsx)("button",{type:"button",onClick:()=>{g(!0),z()},className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",title:d.organizeDetailTitle,children:(0,s.jsx)(V.A,{size:13})}),(0,s.jsx)("button",{type:"button",onClick:D,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,s.jsx)(u.A,{size:14})})]})})}var tv=r(87358);class ty{track(e,t){this.record({name:e,ts:Date.now(),props:t})}startTimer(e,t){let r=Date.now();return s=>{this.record({name:e,ts:r,durationMs:Date.now()-r,props:{...t??{},...s??{}}})}}getEvents(){return this.history.map(e=>({...e,props:e.props?{...e.props}:void 0}))}reset(){this.history=[],this.pending=[]}async flush(){if(0===this.pending.length)return 0;let e=this.pending.splice(0),t=tv.env.MINDOS_TELEMETRY_ENDPOINT?.trim();if(!t)return e.length;try{return await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),e.length}catch{return this.pending.unshift(...e),0}}record(e){this.history.push(e),this.history.length>200&&this.history.splice(0,this.history.length-200),this.pending.push(e),this.log(e)}log(e){}constructor(){this.history=[],this.pending=[]}}let tj=new ty;var tw=r(37206);function tk(){return(0,a.useEffect)(()=>em.zd.getState()._init(),[]),null}var tN=r(1934),tS=r(76449);let tC="mindos_walkthrough_done";function tA(e,t){if(e>=tS.g.length||t)try{localStorage.setItem(tC,"1")}catch{}fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{walkthroughStep:e,walkthroughDismissed:t}})}).catch(e=>{console.warn("[walkthrough-store] persist failed:",e)})}let tz=(0,tN.v)((e,t)=>{let r=tS.g.length;return{status:"idle",currentStep:0,totalSteps:r,start:()=>{e({currentStep:0,status:"active"}),tA(0,!1)},next:()=>{let s=t().currentStep+1;s>=r?(e({status:"completed"}),tA(r,!1)):(e({currentStep:s}),tA(s,!1))},back:()=>{let r=t().currentStep;r>0&&(e({currentStep:r-1}),tA(r-1,!1))},skip:()=>{e({status:"dismissed"}),tA(t().currentStep,!0)},_init:()=>{let t="1"===new URLSearchParams(window.location.search).get("welcome");if(t){let e=new URL(window.location.href);e.searchParams.delete("welcome"),window.history.replaceState({},"",e.pathname+(e.search||"")),window.dispatchEvent(new Event("mindos:first-visit"))}return window.innerWidth<768||function(){try{return"1"===localStorage.getItem(tC)}catch{return!1}}()?()=>{}:(fetch("/api/setup").then(e=>e.json()).then(s=>{let n=s.guideState;if(n){if(n.walkthroughDismissed||"number"==typeof n.walkthroughStep&&n.walkthroughStep>=r){try{localStorage.setItem(tC,"1")}catch{}return}n.active&&!n.dismissed&&void 0===n.walkthroughStep?t&&e({status:"active",currentStep:0}):"number"==typeof n.walkthroughStep&&n.walkthroughStep>=0&&n.walkthroughStep<r&&!n.walkthroughDismissed&&e({status:"active",currentStep:n.walkthroughStep})}}).catch(e=>{console.warn("[walkthrough-store] guideState read failed:",e)}),()=>{})}}});function tE({stepIndex:e,rect:t,position:r}){let n,i,o=tz(),{t:l}=(0,j.Y)(),[d,c]=(0,a.useState)({width:1024,height:768});if((0,a.useEffect)(()=>{let e=()=>c({width:window.innerWidth,height:window.innerHeight});return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),!o)return null;let u=l.walkthrough.steps[e];if(!u)return null;"right"===r?(n=t.top+t.height/2,i=t.right+12):(n=t.bottom+12,i=t.left+t.width/2);let m=d.width-320,x=d.height-200;return i=Math.min(i,m),n=Math.max(n=Math.min(n,x),8),(0,s.jsxs)("div",{className:`fixed z-[102] w-[280px] rounded-xl border shadow-lg animate-in fade-in duration-200 ${"right"===r?"slide-in-from-left-2":"slide-in-from-top-2"}`,style:{top:`${n}px`,left:`${i}px`,transform:"right"===r?"translateY(-50%)":"translateX(-50%)",background:"var(--card)",borderColor:"var(--amber)"},children:[(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,s.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:l.walkthrough.step(e+1,o.totalSteps)})}),(0,s.jsx)("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--foreground)"},children:u.title}),(0,s.jsx)("p",{className:"text-xs leading-relaxed",style:{color:"var(--muted-foreground)"},children:u.body}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-3",style:{borderTop:"1px solid var(--border)"},children:[(0,s.jsx)("button",{onClick:o.skip,className:"text-xs transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:l.walkthrough.skip}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e>0&&(0,s.jsx)("button",{onClick:o.back,className:"text-xs px-2.5 py-1 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:l.walkthrough.back}),(0,s.jsx)("button",{onClick:o.next,className:"text-xs px-3 py-1.5 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e===o.totalSteps-1?l.walkthrough.done:l.walkthrough.next})]})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-center gap-1.5 pb-3",children:Array.from({length:o.totalSteps},(t,r)=>(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full transition-all duration-200",style:{background:r===e?"var(--amber)":"var(--border)",transform:r===e?"scale(1.3)":void 0}},r))})]})}function tT(){let e=tz(),[t,r]=(0,a.useState)(null),[n,i]=(0,a.useState)(!1),o=(0,a.useId)(),l=e?tS.g[e.currentStep]:null,d=(0,a.useCallback)(()=>{if(!l)return;let e=document.querySelector(`[data-walkthrough="${l.anchor}"]`);e?r(e.getBoundingClientRect()):r(null)},[l]);(0,a.useEffect)(()=>{i(window.innerWidth<768),d();let e=()=>{i(window.innerWidth<768),d()};return window.addEventListener("resize",e),window.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",d,!0)}},[d]),(0,a.useEffect)(()=>{d();let e=setTimeout(d,100);return()=>clearTimeout(e)},[e?.currentStep,d]);let c=e?.skip;(0,a.useEffect)(()=>{if(!c)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[c]);let u=e?.currentStep??0;return((0,a.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>{document.querySelector(`[data-walkthrough="${l.anchor}"]`)||tz.getState().next()},500);return()=>clearTimeout(e)},[u]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{tz.getState().skip()},6e4);return()=>clearTimeout(e)},[u]),e&&l)?n?(0,s.jsx)(t$,{}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("svg",{className:"fixed inset-0 z-[100] pointer-events-auto",width:"100%",height:"100%",onClick:r=>{if(t){let s=r.clientX,n=r.clientY;s>=t.left-6&&s<=t.right+6&&n>=t.top-6&&n<=t.bottom+6||e.skip()}else e.skip()},children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("mask",{id:o,children:[(0,s.jsx)("rect",{width:"100%",height:"100%",fill:"white"}),t&&(0,s.jsx)("rect",{x:t.left-6,y:t.top-6,width:t.width+12,height:t.height+12,rx:8,ry:8,fill:"black"})]})}),(0,s.jsx)("rect",{width:"100%",height:"100%",fill:"rgba(0, 0, 0, 0.5)",mask:`url(#${o})`})]}),t&&(0,s.jsx)(tE,{stepIndex:e.currentStep,rect:t,position:l.position}),!t&&(0,s.jsx)("div",{className:"fixed inset-0 z-[101] flex items-center justify-center pointer-events-none",children:(0,s.jsx)("button",{onClick:e.skip,className:"pointer-events-auto px-4 py-2 text-sm rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?"✓":"→"})})]}):null}function t$(){let e=tz(),{t}=(0,j.Y)();if(!e)return null;let r=t.walkthrough.steps[e.currentStep];return r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-sm",onClick:e.skip}),(0,s.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 z-[101] rounded-t-2xl border-t shadow-lg p-5 pb-8 animate-in slide-in-from-bottom duration-300",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:t.walkthrough.step(e.currentStep+1,e.totalSteps)}),(0,s.jsx)("div",{className:"flex items-center gap-1 ml-auto",children:Array.from({length:e.totalSteps},(t,r)=>(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:r===e.currentStep?"var(--amber)":"var(--border)"}},r))})]}),(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",style:{color:"var(--foreground)"},children:r.title}),(0,s.jsx)("p",{className:"text-sm leading-relaxed mb-5",style:{color:"var(--muted-foreground)"},children:r.body}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("button",{onClick:e.skip,className:"text-sm transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:t.walkthrough.skip}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.currentStep>0&&(0,s.jsx)("button",{onClick:e.back,className:"text-sm px-3 py-2 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:t.walkthrough.back}),(0,s.jsx)("button",{onClick:e.next,className:"text-sm px-4 py-2 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?t.walkthrough.done:t.walkthrough.next})]})]})]})]}):null}function tD(){return(0,a.useEffect)(()=>tz.getState()._init(),[]),"active"===tz(e=>e.status)?(0,s.jsx)(tT,{}):null}let tR=new Set(["mp3","wav","m4a","ogg","flac","aac"]),tM=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico"]),tP=new Set(["mp4","webm","mov","mkv"]);for(let e of[{id:"agent-inspector",name:"Agent Inspector",description:"Visualizes agent tool-call logs as a filterable timeline. Auto-activates on .mindos/agent-audit-log.json and supports legacy .agent-log.json.",author:"MindOS",icon:"\uD83D\uDD0D",tags:["agent","inspector","log","mcp","tools"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/agent-audit-log.json",match:({filePath:e})=>/(^|\/)\.mindos\/agent-audit-log\.json$/i.test(e)||/\.agent-log\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,18847)).then(e=>({default:e.AgentInspectorRenderer}))},{id:"audio",name:"Audio Player",description:"Plays audio files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFB5",tags:["audio","music","voice","mp3","wav"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tR.has(e),load:()=>Promise.resolve().then(r.bind(r,14446)).then(e=>({default:e.AudioRenderer}))},{id:"backlinks",name:"Backlinks Explorer",description:"Shows all files that link to the current page via wikilinks or markdown links, with highlighted snippet context.",author:"MindOS",icon:"\uD83D\uDD17",tags:["backlinks","wiki","links","references"],builtin:!0,entryPath:"BACKLINKS.md",match:({filePath:e})=>/\bBACKLINKS\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,88946)).then(e=>({default:e.BacklinksRenderer}))},{id:"change-log",name:"Content Changes",description:"Renders the .mindos/change-log.json file as a searchable timeline of content edits.",author:"MindOS",icon:"\uD83D\uDCCB",tags:["changelog","history","changes"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({filePath:e})=>/\.mindos\/change-log\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,57025)).then(e=>({default:e.ChangeLogRenderer}))},{id:"config-panel",name:"Config Panel",description:"Renders CONFIG.json as an editable control panel based on uiSchema/keySpecs. Changes are written back to the JSON file directly.",author:"MindOS",icon:"\uD83E\uDDE9",tags:["config","json","settings","schema"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"CONFIG.json",match:({filePath:e,extension:t})=>"json"===t&&/(^|\/)CONFIG\.json$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,35504)).then(e=>({default:e.ConfigRenderer}))},{id:"csv",name:"CSV Views",description:"Renders any CSV file as Table, Gallery, or Board. Each view is independently configurable — choose which columns map to title, description, tag, and group.",author:"MindOS",icon:"\uD83D\uDCCA",tags:["csv","table","gallery","board","data"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"Resources/Products.csv",match:({extension:e,filePath:t})=>"csv"===e&&!/\bTODO\b/i.test(t),load:()=>Promise.resolve().then(r.bind(r,92306)).then(e=>({default:e.CsvRenderer}))},{id:"image",name:"Image Viewer",description:"Renders image files with zoom, fit-to-view, and transparency support.",author:"MindOS",icon:"\uD83D\uDDBC",tags:["image","photo","viewer","png","jpg","svg"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tM.has(e),load:()=>Promise.resolve().then(r.bind(r,20814)).then(e=>({default:e.ImageRenderer}))},{id:"pdf",name:"PDF Viewer",description:"Renders PDF files using the browser built-in PDF viewer.",author:"MindOS",icon:"\uD83D\uDCC4",tags:["pdf","document","viewer"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>"pdf"===e,load:()=>Promise.resolve().then(r.bind(r,20870)).then(e=>({default:e.PdfRenderer}))},{id:"summary",name:"AI Briefing",description:"Streams an AI-generated daily briefing summarizing your most recently modified files — key changes, recurring themes, and suggested next actions.",author:"MindOS",icon:"✨",tags:["ai","summary","briefing","daily"],builtin:!0,entryPath:"DAILY.md",match:({filePath:e})=>/\b(SUMMARY|summary|Summary|BRIEFING|briefing|Briefing|DAILY|daily|Daily)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,56406)).then(e=>({default:e.SummaryRenderer}))},{id:"timeline",name:"Timeline",description:"Renders changelog and journal files as a vertical timeline. Any markdown with ## date headings (e.g. ## 2025-01-15) becomes a card in the feed.",author:"MindOS",icon:"\uD83D\uDCC5",tags:["timeline","changelog","journal","history"],builtin:!0,entryPath:"CHANGELOG.md",match:({filePath:e})=>/\b(CHANGELOG|changelog|TIMELINE|timeline|journal|Journal|diary|Diary)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,39594)).then(e=>({default:e.TimelineRenderer}))},{id:"todo",name:"TODO Board",description:"Renders TODO.md/TODO.csv as an interactive kanban board grouped by section. Check items off directly — changes are written back to the source file.",author:"MindOS",icon:"✅",tags:["productivity","tasks","markdown"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"TODO.md",match:({filePath:e})=>/\bTODO\b.*\.(md|csv)$/i.test(e),load:()=>Promise.resolve().then(r.bind(r,78660)).then(e=>({default:e.TodoRenderer}))},{id:"video",name:"Video Player",description:"Plays video files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFAC",tags:["video","movie","recording","mp4","webm"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>tP.has(e),load:()=>Promise.resolve().then(r.bind(r,87986)).then(e=>({default:e.VideoRenderer}))},{id:"workflow-yaml",name:"Workflow Runner",description:"Execute step-by-step YAML workflows with Skills & Agent support.",author:"MindOS",icon:"⚡",tags:["workflow","automation","steps","ai","yaml"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/workflows/",match:({extension:e,filePath:t})=>("yaml"===e||"yml"===e)&&/\.flow\.(yaml|yml)$/i.test(t),load:()=>Promise.resolve().then(r.bind(r,48133)).then(e=>({default:e.WorkflowYamlRenderer}))},{id:"graph",name:"Wiki Graph",description:"Force-directed graph of wikilink references across all markdown files. Supports Global and Local (2-hop) scope filters.",author:"MindOS",icon:"\uD83D\uDD78️",tags:["graph","wiki","links","visualization"],builtin:!0,match:()=>!1,load:()=>Promise.resolve().then(r.bind(r,92950)).then(e=>({default:e.GraphRenderer}))}])(0,eH.TS)(e);var tF=r(48391),tL=r(29494);let tI=(0,tw.default)(()=>r.e(5576).then(r.bind(r,95576)),{loadableGenerated:{webpack:()=>[95576]},ssr:!1}),tO=(0,tw.default)(()=>r.e(2935).then(r.bind(r,22935)),{loadableGenerated:{webpack:()=>[22935]},ssr:!1}),tW=(0,tw.default)(()=>Promise.all([r.e(9207),r.e(4681)]).then(r.bind(r,84681)),{loadableGenerated:{webpack:()=>[84681]},ssr:!1}),tB=(0,tw.default)(()=>r.e(2526).then(r.bind(r,12526)),{loadableGenerated:{webpack:()=>[12526]},ssr:!1}),t_=(0,tw.default)(()=>r.e(1814).then(r.bind(r,51814)),{loadableGenerated:{webpack:()=>[51814]},ssr:!1}),tU=()=>{};function tH({fileTree:e,children:t}){let r=function(){let[e,t]=(0,a.useState)("files"),[r,s]=(0,a.useState)(null),[n,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"true"===localStorage.getItem("rail-expanded")&&l(!0)}catch{}},[]),(0,a.useEffect)(()=>{if(e){try{let e=localStorage.getItem("left-panel-width");if(e){let t=parseInt(e,10);if(t>=240&&t<=600)return void s(t)}}catch{}s(280)}},[e]),(0,a.useEffect)(()=>{i(!1)},[e]);let d=(0,a.useCallback)(e=>s(e),[]),c=(0,a.useCallback)(e=>{try{localStorage.setItem("left-panel-width",String(e))}catch{}},[]),u=(0,a.useCallback)(()=>i(e=>!e),[]),m=(0,a.useCallback)(e=>{l(e);try{localStorage.setItem("rail-expanded",String(e))}catch{}},[]),x=null!==e,p=r??(e?es[e]:280);return{activePanel:e,setActivePanel:t,panelWidth:r,panelMaximized:n,railExpanded:o,railWidth:o?180:48,panelOpen:x,effectivePanelWidth:p,handlePanelWidthChange:d,handlePanelWidthCommit:c,handlePanelMaximize:u,handleExpandedChange:m}}(),i=function(){let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(380),[n,i]=(0,a.useState)("panel"),[o,l]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),x=(0,a.useRef)(!1);x.current=u;let[p,h]=(0,a.useState)("user"),[f,g]=(0,a.useState)(null),b=(0,a.useRef)(380),v=(0,eU.KT)();(0,a.useEffect)(()=>{try{let e=localStorage.getItem("right-ask-panel-width");if(e){let t=parseInt(e,10);t>=320&&t<=4e3?(s(t),b.current=t):t>4e3&&(s(380),b.current=380)}let t=localStorage.getItem("ask-mode");"popup"===t&&i("popup")}catch{}let e=e=>{"ask-mode"===e.key&&("panel"===e.newValue||"popup"===e.newValue)&&i(e.newValue)};window.addEventListener("storage",e);let r=()=>{t(!0),x.current&&(m(!1),s(b.current))};return window.addEventListener("mindos:open-ask-panel",r),()=>{window.removeEventListener("storage",e),window.removeEventListener("mindos:open-ask-panel",r)}},[]),(0,a.useEffect)(()=>{v.open&&(c(v.initialMessage),h(v.source),g(v.acpAgent),"popup"===n?l(!0):t(!0),v.close())},[v.open,v.initialMessage,v.source,v.acpAgent,v.close,n]);let y=(0,a.useCallback)(()=>{"popup"===n?l(e=>(e||(c(""),h("user"),g(null)),!e)):t(e=>(e||(c(""),h("user"),g(null)),!e))},[n]),j=(0,a.useCallback)(()=>{t(!1),u&&(s(b.current),m(!1))},[u]),w=(0,a.useCallback)(()=>{m(e=>(e?s(b.current):b.current=r,!e))},[r]),k=(0,a.useCallback)(()=>l(!1),[]),N=(0,a.useCallback)(e=>s(e),[]);return{askPanelOpen:e,askPanelWidth:r,askMaximized:u,askMode:n,desktopAskPopupOpen:o,askInitialMessage:d,askOpenSource:p,askAcpAgent:f,toggleAskPanel:y,closeAskPanel:j,closeDesktopAskPopup:k,handleAskWidthChange:N,handleAskWidthCommit:(0,a.useCallback)(e=>{try{localStorage.setItem("right-ask-panel-width",String(e))}catch{}},[]),handleAskModeSwitch:(0,a.useCallback)(()=>{i(e=>{let r="panel"===e?"popup":"panel";try{localStorage.setItem("ask-mode",r),window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:r}))}catch{}return"popup"===r?(t(!1),l(!0)):(l(!1),t(!0)),r})},[]),toggleAskMaximized:w}}(),[x,p]=(0,a.useState)(!1),[h,f]=(0,a.useState)(void 0),[g,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(null),[w,k]=(0,a.useState)(null),[N,S]=(0,a.useState)(()=>{try{let e=localStorage.getItem("right-agent-detail-panel-width");if(e){let t=parseInt(e,10);if(t>=300&&t<=640)return t}}catch{}return 400}),C=(0,tF.dB)(),[A,E]=(0,a.useState)(!1),[T,$]=(0,a.useState)(0);(0,a.useEffect)(()=>{("organizing"===C.phase||"done"===C.phase||"error"===C.phase)&&E(!0)},[C.phase]);let M=(0,a.useCallback)(()=>{E(!1),"organizing"!==C.phase||C.abort(),C.reset()},[C]),P=(0,a.useCallback)(()=>{$(e=>e+1),window.dispatchEvent(new Event("mindos:organize-history-update"))},[]),[L,I]=(0,a.useState)(!1),[O,W]=(0,a.useState)(void 0),[B,_]=(0,a.useState)(void 0),[U,H]=(0,a.useState)(!1),K=(0,a.useRef)(0),X=(0,a.useCallback)(e=>{W(e),_(void 0),I(!0)},[]),Y=(0,a.useCallback)(()=>{I(!1),W(void 0),_(void 0)},[]),[J,Z]=(0,a.useState)(!1),[V,q]=(0,a.useState)(!1),[Q,ee]=(0,a.useState)(!1),{t:et}=(0,j.Y)(),er=(0,n.useRouter)(),ea=(0,n.usePathname)(),ei=(0,a.useMemo)(()=>{let t=tj.startTimer("sidebar.collect_dir_paths"),r=function e(t,r=""){let s=[];for(let n of t)if("directory"===n.type&&!n.name.startsWith(".")){let t=r?`${r}/${n.name}`:n.name;s.push(t),n.children&&s.push(...e(n.children,t))}return s}(e);return t({nodeCount:e.length,pathCount:r.length}),r},[e]),{status:eo,fetchStatus:el}=z(),ec=ea.startsWith("/view/")?ea.slice(6).split("/").map(decodeURIComponent).join("/"):void 0;(0,a.useEffect)(()=>{i.askMaximized&&i.toggleAskMaximized()},[ea,r.panelOpen]);let eu=(0,a.useCallback)(()=>{i.askMaximized&&i.toggleAskMaximized()},[i.askMaximized,i.toggleAskMaximized]);(0,a.useEffect)(()=>{"/"===ea&&i.askPanelOpen&&i.closeAskPanel()},[ea]);let em=ea?.startsWith("/agents"),ex=r.activePanel??(em?"agents":null);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.tab;t&&f(t),p(!0)};return window.addEventListener("mindos:open-settings",e),()=>window.removeEventListener("mindos:open-settings",e)},[]),(0,a.useEffect)(()=>{let e=()=>X();return window.addEventListener("mindos:open-import",e),()=>window.removeEventListener("mindos:open-import",e)},[X]);let ep=(0,a.useRef)([]);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.files;if(!t||0===t.length||"organizing"===C.phase)return;let r=et.inbox.organizePrompt(t.map(e=>e.name));ep.current=t.map(e=>e.name),(async()=>{let e=[];for(let r of t)try{let t=await fetch(`/api/file?path=${encodeURIComponent(r.path)}`);if(t.ok){let s=await t.json();e.push({name:r.name,content:s.content??""})}}catch{}e.length>0?C.start(e,r,"inbox-organize"):(e9.oR.error(et.inbox.organizeFailed,4e3),window.dispatchEvent(new Event("mindos:organize-done")))})()};return window.addEventListener("mindos:inbox-organize",e),()=>window.removeEventListener("mindos:inbox-organize",e)},[C,et]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.content||"organizing"===C.phase)return;let r={name:t.name,content:t.content};C.start([r],"Organize this conversation into well-structured notes in my knowledge base. Extract key insights, decisions, action items, and important details. Create appropriate files with clear titles. Write in the same language as the content.","conversation")};return window.addEventListener("mindos:session-organize",e),()=>window.removeEventListener("mindos:session-organize",e)},[C]),(0,a.useEffect)(()=>{if("done"===C.phase){let e=C.changes.some(e=>e.ok),t=ep.current;e&&t.length>0&&(fetch("/api/inbox",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:t})}).then(()=>{window.dispatchEvent(new Event("mindos:inbox-updated"))}).catch(()=>{}),ep.current=[]),window.dispatchEvent(new Event("mindos:organize-done"))}else"error"===C.phase&&window.dispatchEvent(new Event("mindos:organize-done"))},[C.phase,C.changes]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.panel;t&&r.setActivePanel(t)};return window.addEventListener("mindos:open-panel",e),()=>window.removeEventListener("mindos:open-panel",e)},[r]);let eh=(0,a.useCallback)(()=>{let e=()=>window.dispatchEvent(new Event("guide-state-updated"));"guide"===i.askOpenSource?fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{askedAI:!0}})}).then(e).catch(e=>console.warn("Guide state update failed:",e)):"guide-next"===i.askOpenSource&&e()},[i.askOpenSource]);(0,a.useEffect)(()=>{let e=requestAnimationFrame(()=>Z(!1));return()=>cancelAnimationFrame(e)},[ea]),(0,a.useEffect)(()=>{ea?.startsWith("/echo")&&r.setActivePanel("echo")},[ea,r.setActivePanel]);let ef=(0,a.useCallback)(e=>{S(e);try{localStorage.setItem("right-agent-detail-panel-width",String(e))}catch{}},[]),eg=(0,a.useCallback)(()=>k(null),[]),eb=null!==w&&"agents"===r.activePanel;(0,a.useEffect)(()=>{let e=-1,t=!1,r=0,s=null,n=(e,t)=>{r=Date.now();let s=tj.startTimer("tree.refresh.trigger");(0,a.startTransition)(()=>{er.refresh()}),s({previousVersion:t,version:e,reason:"tree_version_changed"}),window.dispatchEvent(new Event("mindos:files-changed"))},i=async()=>{if(t||"hidden"===document.visibilityState)return;let a=tj.startTimer("tree.version.poll");try{let i=await fetch("/api/tree-version");if(!i.ok)return void a({ok:!1,changed:!1});let{v:o}=await i.json();if(-1===e){e=o,a({ok:!0,changed:!1,version:o,initial:!0});return}if(o!==e){let i=e;e=o;let l=Date.now()-r;l<2e3?(s&&clearTimeout(s),s=setTimeout(()=>{s=null,t||n(o,i)},2e3-l),a({ok:!0,changed:!0,previousVersion:i,version:o,deferred:!0})):(n(o,i),a({ok:!0,changed:!0,previousVersion:i,version:o}));return}a({ok:!0,changed:!1,version:o})}catch(e){a({ok:!1,changed:!1}),console.debug("[tree-version] poll failed",e)}},o=()=>{"visible"===document.visibilityState&&i()};i();let l=setInterval(()=>void i(),5e3);return document.addEventListener("visibilitychange",o),()=>{t=!0,clearInterval(l),s&&clearTimeout(s),document.removeEventListener("visibilitychange",o)}},[er]),(0,a.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(r.panelMaximized)return void r.handlePanelMaximize();if(eb)return void k(null);if(i.askPanelOpen)return void i.closeAskPanel();if(i.desktopAskPopupOpen)return void i.closeDesktopAskPopup()}(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),window.innerWidth>=768?r.setActivePanel(e=>"search"===e?null:"search"):q(e=>!e)),(e.metaKey||e.ctrlKey)&&"/"===e.key&&(e.preventDefault(),window.innerWidth>=768?i.toggleAskPanel():ee(e=>!e)),(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),p(e=>!e)),(e.metaKey||e.ctrlKey)&&"i"===e.key&&(e.preventDefault(),I(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eb,r,i]);let ev=(0,a.useCallback)(()=>{f("sync"),b(!1),p(!0)},[]),ey=(0,a.useCallback)(()=>{p(!0),f(void 0)},[]),ej=(0,a.useCallback)(()=>{p(!1),f(void 0)},[]),ew=(0,a.useCallback)(e=>{y(e),b(e=>!e)},[]),ek=(0,a.useCallback)(e=>{r.handleExpandedChange(e),b(!1)},[r]),eN=(0,a.useCallback)(()=>Z(!1),[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tk,{}),(0,s.jsx)(tD,{}),(0,s.jsx)("a",{href:"#main-content",className:"sr-only focus-visible:not-sr-only focus-visible:fixed focus-visible:top-2 focus-visible:left-2 focus-visible:z-[60] focus-visible:px-4 focus-visible:py-2 focus-visible:rounded-lg focus-visible:text-sm focus-visible:font-medium bg-[var(--amber)] text-[var(--amber-foreground)]",children:"Skip to main content"}),(0,s.jsx)(F,{activePanel:ex,onPanelChange:r.setActivePanel,onEchoClick:()=>{eu();let e="echo"===r.activePanel,t=ea?.startsWith("/echo");e?t?r.setActivePanel(null):er.push("/echo/about-you"):(r.setActivePanel("echo"),er.push("/echo/about-you"))},onAgentsClick:()=>{eu();let e="agents"===r.activePanel,t=ea?.startsWith("/agents");e?t?r.setActivePanel(null):er.push("/agents"):(r.setActivePanel("agents"),er.push("/agents")),k(null)},onDiscoverClick:()=>{eu();let e="discover"===r.activePanel,t=ea?.startsWith("/explore");e?t?r.setActivePanel(null):er.push("/explore"):(r.setActivePanel("discover"),er.push("/explore"))},onSpacesClick:()=>{eu();let e="/"===ea,t="files"===r.activePanel,s="/wiki"===ea||ea?.startsWith("/view/")||ea?.startsWith("/wiki/");e||!t?(r.setActivePanel("files"),er.push("/wiki")):s?r.setActivePanel(null):er.push("/wiki")},syncStatus:eo,expanded:r.railExpanded,onExpandedChange:ek,onSettingsClick:ey,onSyncClick:ew}),(0,s.jsxs)(en,{activePanel:r.activePanel,fileTree:e,onNavigate:tU,onOpenSyncSettings:ev,railWidth:r.railWidth,panelWidth:r.panelWidth??void 0,onWidthChange:r.handlePanelWidthChange,onWidthCommit:r.handlePanelWidthCommit,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize,onImport:X,children:[(0,s.jsx)("div",{className:`flex flex-col h-full ${"echo"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(e0,{active:"echo"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"search"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(ed,{active:"search"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"agents"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(eD,{active:"agents"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize,selectedAgentKey:eb?w:null})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"discover"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(eJ,{active:"discover"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})}),(0,s.jsx)("div",{className:`flex flex-col h-full ${"workflows"===r.activePanel?"":"hidden"}`,children:(0,s.jsx)(e2,{active:"workflows"===r.activePanel,maximized:r.panelMaximized,onMaximize:r.handlePanelMaximize})})]}),(0,s.jsx)(e4,{open:i.askPanelOpen,onClose:i.closeAskPanel,currentFile:ec,initialMessage:i.askInitialMessage,initialAcpAgent:i.askAcpAgent,onFirstMessage:eh,width:i.askPanelWidth,onWidthChange:i.handleAskWidthChange,onWidthCommit:i.handleAskWidthCommit,askMode:i.askMode,onModeSwitch:i.handleAskModeSwitch,maximized:i.askMaximized,onMaximize:i.toggleAskMaximized,sidebarOffset:r.panelOpen?r.railWidth+r.effectivePanelWidth:r.railWidth}),(0,s.jsx)(tr,{open:eb,agentKey:w,onClose:eg,rightOffset:i.askPanelOpen?i.askPanelWidth:0,width:N,onWidthChange:S,onWidthCommit:ef}),(0,s.jsx)(tO,{open:i.desktopAskPopupOpen,onClose:i.closeDesktopAskPopup,currentFile:ec,initialMessage:i.askInitialMessage,initialAcpAgent:i.askAcpAgent,onFirstMessage:eh,askMode:i.askMode,onModeSwitch:i.handleAskModeSwitch}),(0,s.jsx)(tn,{onToggle:i.toggleAskPanel,askPanelOpen:i.askPanelOpen||i.desktopAskPopupOpen}),(0,s.jsx)(ti,{}),(0,s.jsx)(tW,{open:x,onClose:ej,initialTab:h}),(0,s.jsx)(ta,{open:g,onClose:()=>b(!1),anchorRect:v,railWidth:r.railWidth,onOpenSyncSettings:ev,syncStatus:eo,onSyncStatusRefresh:el}),(0,s.jsxs)("header",{className:"md:hidden fixed top-0 left-0 right-0 z-30 bg-card border-b border-border flex items-center justify-between px-3 py-2",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[(0,s.jsx)("button",{onClick:()=>Z(!0),className:"p-3 -ml-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":"Open menu",children:(0,s.jsx)(l.A,{size:20})}),(0,s.jsxs)(o(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(R.A,{id:"mobile"}),(0,s.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,s.jsx)("button",{onClick:ev,className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent flex items-center justify-center","aria-label":"Sync status",children:(0,s.jsx)(D,{status:eo})}),(0,s.jsx)("button",{onClick:()=>q(!0),className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":et.sidebar.searchTitle,children:(0,s.jsx)(d.A,{size:20})}),(0,s.jsx)("button",{onClick:()=>{p(!0),f(void 0)},className:"p-3 -mr-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":et.sidebar.settingsTitle,children:(0,s.jsx)(c.A,{size:20})})]})]}),J&&(0,s.jsx)("div",{className:"md:hidden fixed inset-0 z-40 overlay-backdrop",onClick:()=>Z(!1)}),(0,s.jsxs)("aside",{className:`md:hidden fixed top-0 left-0 h-screen w-[85vw] max-w-[320px] z-50 bg-card border-r border-border flex flex-col transition-transform duration-300 ease-in-out ${J?"translate-x-0":"-translate-x-full"}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border shrink-0",children:[(0,s.jsxs)(o(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(R.A,{id:"drawer"}),(0,s.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,s.jsx)("button",{onClick:()=>Z(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(u.A,{size:16})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-2 py-2",children:(0,s.jsx)(G.Ay,{nodes:e,onNavigate:eN,onImport:X})})]}),(0,s.jsx)(tI,{open:V,onClose:()=>q(!1)}),(0,s.jsx)(tO,{open:Q,onClose:()=>ee(!1),currentFile:ec}),(0,s.jsxs)("main",{id:"main-content",className:"min-h-screen transition-all duration-200 pt-[52px] md:pt-0",onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),K.current++,1===K.current&&H(!0))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&e.preventDefault()},onDragLeave:()=>{K.current=Math.max(0,K.current-1),0===K.current&&H(!1)},onDrop:e=>{e.preventDefault(),K.current=0,H(!1),e.dataTransfer.files.length>0&&!L&&(0,tL.QL)(Array.from(e.dataTransfer.files),et)},children:[(0,s.jsxs)("div",{className:"min-h-screen bg-background",style:{overflowX:"clip"},children:[(0,s.jsx)(to,{}),t]}),(0,s.jsx)(tc,{}),(0,s.jsx)(tB,{t:et,dirPaths:ei}),U&&!L&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",children:(0,s.jsxs)("div",{className:"border-2 border-dashed border-[var(--amber)]/50 rounded-xl p-12 flex flex-col items-center gap-3",children:[(0,s.jsx)(m.A,{size:48,className:"text-[var(--amber)]/60"}),(0,s.jsx)("p",{className:"text-sm text-foreground font-medium",children:et.inbox.dropOverlay}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:et.inbox.dropOverlayFormats})]})})]}),(0,s.jsx)(t_,{open:L,onClose:Y,defaultSpace:O,initialFiles:B,aiOrganize:C,dirPaths:ei}),A&&(0,s.jsx)(tb,{aiOrganize:C,onDismiss:M,onCancel:()=>{C.abort(),C.reset(),E(!1)},onHistoryUpdate:P}),(0,s.jsx)("style",{children:`
|
|
131
71
|
@media (min-width: 768px) {
|
|
132
72
|
:root {
|
|
133
73
|
--right-panel-width: ${i.askMaximized?`calc(100vw - ${r.panelOpen?r.railWidth+r.effectivePanelWidth:r.railWidth}px)`:`${i.askPanelOpen?i.askPanelWidth:0}px`};
|
|
@@ -139,8 +79,68 @@ Be specific. Reference actual content from the files. Keep the total response un
|
|
|
139
79
|
padding-top: 0;
|
|
140
80
|
}
|
|
141
81
|
}
|
|
142
|
-
`})]})}function tK({fileTree:e,children:t}){let r=(0,n.usePathname)(),i=(0,a.useRef)(e),o=function e(t,r){if(t===r)return r;let s=new Map;for(let e of r)s.set(e.path,e);let n=!0,a=Array(t.length);for(let i=0;i<t.length;i++){let o=i<r.length&&r[i].path===t[i].path?r[i]:s.get(t[i].path),l=function(t,r){if(!r||t.path!==r.path||t.type!==r.type||t.name!==r.name||t.extension!==r.extension||t.isSpace!==r.isSpace)return t;if(t.children&&r.children){let s=e(t.children,r.children);return s===r.children&&t.name===r.name&&(t.spacePreview===r.spacePreview||t.spacePreview&&r.spacePreview&&t.spacePreview.lastCompiled===r.spacePreview.lastCompiled&&t.spacePreview.isTemplate===r.spacePreview.isTemplate)?r:{...t,children:s}}return r}(t[i],o);a[i]=l,l!==r[i]&&(n=!1)}return n&&t.length===r.length?r:a}(e,i.current);return(i.current=o,"/login"===r)?(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsx)(tH,{fileTree:o,children:t})}},87986:(e,t,r)=>{"use strict";r.r(t),r.d(t,{VideoRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"video",a=r.split(".").pop()?.toLowerCase()??"",[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let h=(0,n.useCallback)(()=>{let e=p.current;e&&x({w:e.videoWidth,h:e.videoHeight})},[]),f=(0,n.useCallback)(()=>{o(!1),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[m&&(0,s.jsxs)("span",{children:[m.w," x ",m.h]}),null!==c&&(0,s.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`}),(0,s.jsx)("span",{className:"uppercase opacity-60",children:a})]}),(0,s.jsx)("div",{className:"flex-1 min-h-[50vh] flex items-center justify-center bg-black rounded-b-lg overflow-hidden",children:i?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-neutral-400",children:"Failed to load video"}),(0,s.jsx)("button",{onClick:f,className:"text-xs px-3 py-1.5 rounded-md bg-neutral-800 hover:bg-neutral-700 text-neutral-200 transition-colors",children:"Retry"})]}):(0,s.jsx)("video",{ref:p,controls:!0,preload:"metadata",className:"max-w-full max-h-[70vh]",onLoadedMetadata:h,onError:()=>o(!0),children:(0,s.jsx)("source",{src:t})},l)})]})}},88946:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BacklinksRenderer:()=>m});var s=r(95155),n=r(12115),a=r(73321),i=r(48368),o=r(22164),l=r(91337),d=r(22356);function c(e){return e.split("/").pop()?.replace(/\.md$/,"")??e}function u({text:e}){let t=e.split(/(\[\[[^\]]+\]\]|\[[^\]]+\]\([^)]+\))/g);return(0,s.jsx)("span",{children:t.map((e,t)=>/^\[\[/.test(e)||/^\[/.test(e)?(0,s.jsx)("span",{style:{color:"var(--amber)",fontWeight:500},children:e},t):(0,s.jsx)("span",{children:e},t))})}function m({filePath:e}){let t=(0,a.useRouter)(),[r,m]=(0,n.useState)(null),[x,p]=(0,n.useState)(!0);if((0,n.useEffect)(()=>{p(!0),(0,d.n)(`/api/backlinks?path=${encodeURIComponent(e)}`).then(e=>{m(e),p(!1)}).catch(()=>p(!1))},[e]),x)return(0,s.jsx)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",fontSize:12,color:"var(--muted-foreground)"},children:"Scanning backlinks…"});let h=r??[];return(0,s.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,s.jsx)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:0===h.length?"No backlinks found":`${h.length} file${1===h.length?"":"s"} link here`})}),0===h.length?(0,s.jsxs)("div",{style:{border:"1px dashed var(--border)",borderRadius:10,padding:"2.5rem 1.5rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:[(0,s.jsx)(i.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,s.jsxs)("p",{className:"font-display",style:{fontSize:12},children:["No other files link to ",(0,s.jsx)("strong",{style:{color:"var(--foreground)"},children:c(e)})," yet."]})]}):(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:h.map(({filePath:e,snippets:r})=>{let n,a=c(e),d=(n=e.split("/")).length>1?n.slice(0,-1).join("/"):"";return(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",cursor:"pointer",transition:"border-color .15s"},onClick:()=>t.push("/view/"+(0,l.O0)(e)),onMouseEnter:e=>e.currentTarget.style.borderColor="rgba(200,135,58,0.4)",onMouseLeave:e=>e.currentTarget.style.borderColor="var(--border)",children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:r.length>0?"1px solid var(--border)":"none",background:"var(--muted)"},children:[(0,s.jsx)(i.A,{size:13,style:{color:"var(--muted-foreground)",flexShrink:0}}),(0,s.jsx)("span",{style:{fontWeight:600,fontSize:"0.85rem",color:"var(--foreground)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),d&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6,flexShrink:0},children:d}),(0,s.jsx)(o.A,{size:11,style:{color:"var(--muted-foreground)",opacity:.5,flexShrink:0}})]}),r.map((e,t)=>(0,s.jsx)("div",{style:{padding:"8px 14px",borderBottom:t<r.length-1?"1px solid var(--border)":"none",background:"var(--background)"},children:e.split("\n").map((e,t)=>(0,s.jsx)("div",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--muted-foreground)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(0,s.jsx)(u,{text:e})},t))},t))]},e)})})]})}},91459:(e,t,r)=>{"use strict";r.d(t,{TooltipProvider:()=>m,ZI:()=>h,k$:()=>p,m_:()=>x});var s=r(95155),n=r(13714),a=r(62460),i=r(73260),o=r(63878),l=r(36525),d=r(34900),c=r(59964),u=r(91337);function m({delay:e=0,...t}){return(0,s.jsx)(n.B,{"data-slot":"tooltip-provider",delay:e,...t})}function x({...e}){return(0,s.jsx)(a.s,{"data-slot":"tooltip",...e})}function p({...e}){return(0,s.jsx)(i.k,{"data-slot":"tooltip-trigger",...e})}function h({className:e,side:t="top",sideOffset:r=4,align:n="center",alignOffset:a=0,children:i,...m}){return(0,s.jsx)(o.K,{children:(0,s.jsx)(l.o,{align:n,alignOffset:a,side:t,sideOffset:r,className:"isolate z-50",children:(0,s.jsxs)(d.o,{"data-slot":"tooltip-content",className:(0,u.cn)("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...m,children:[i,(0,s.jsx)(c.P,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}},92306:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CsvRenderer:()=>z});var s=r(95155),n=r(12115),a=r(18837),i=r(37595),o=r(8434),l=r(1164),d=r(59386),c=r.n(d);function u(e,t){return c().unparse([e,...t])}let m=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"var(--tool-read)"},{bg:"rgba(200,160,216,0.12)",text:"var(--tool-search)"},{bg:"rgba(200,96,96,0.12)",text:"var(--error)"},{bg:"rgba(150,150,150,0.12)",text:"var(--muted-foreground)"}];function x(e){let t=0;for(let r=0;r<e.length;r++)t=31*t+e.charCodeAt(r)&65535;return m[t%m.length]}var p=r(77148),h=r(9921),f=r(66088),g=r(68459),b=r(51914);function v({value:e,onCommit:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(e),l=(0,n.useRef)(null);function d(){a(!1),i!==e?t(i):o(e)}return((0,n.useEffect)(()=>{o(e)},[e]),(0,n.useEffect)(()=>{r&&l.current?.select()},[r]),r)?(0,s.jsx)("input",{ref:l,value:i,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:t=>{"Enter"===t.key&&d(),"Escape"===t.key&&(o(e),a(!1))},className:"w-full bg-transparent outline-none text-sm",onClick:e=>e.stopPropagation(),style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)",minWidth:60}}):(0,s.jsx)("div",{className:"truncate text-sm cursor-text",style:{color:"var(--foreground)",minWidth:60},onClick:()=>a(!0),title:e,children:e||(0,s.jsx)("span",{style:{color:"var(--muted-foreground)",opacity:.3},children:"—"})})}function y({headers:e,visibleIndices:t,onAdd:r,onCancel:a}){let[i,o]=(0,n.useState)(()=>Array(e.length).fill(""));return(0,s.jsxs)("tr",{style:{background:"color-mix(in srgb, var(--amber) 6%, transparent)",borderTop:"1px solid var(--amber)"},children:[t.map((t,n)=>(0,s.jsx)("td",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)("input",{autoFocus:0===n,value:i[t],onChange:e=>{var r;return r=e.target.value,void o(e=>{let s=[...e];return s[t]=r,s})},onKeyDown:e=>{"Enter"===e.key&&r(i),"Escape"===e.key&&a()},placeholder:e[t],className:"w-full bg-transparent outline-none text-sm placeholder:opacity-30",style:{color:"var(--foreground)",borderBottom:"1px solid var(--border)"}})},t)),(0,s.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"}})]})}function j({headers:e,rows:t,cfg:r,saveAction:a}){let[i,o]=(0,n.useState)(t),[l,d]=(0,n.useState)(!1);(0,n.useEffect)(()=>{o(t)},[t]);let c=(0,n.useMemo)(()=>e.map((e,t)=>t).filter(t=>!r.hiddenFields.includes(e[t])),[e,r.hiddenFields]),m=e.indexOf(r.sortField),x=(0,n.useMemo)(()=>{let e=[...i];return m>=0&&e.sort((e,t)=>{let s=e[m]??"",n=t[m]??"",a=parseFloat(s),i=parseFloat(n),o=isNaN(a)||isNaN(i)?s.localeCompare(n):a-i;return"asc"===r.sortDir?o:-o}),e},[i,m,r.sortDir]),p=e.indexOf(r.groupField),j=(0,n.useMemo)(()=>{if(p<0)return[{key:null,rows:x.map(e=>({row:e,orig:e}))}];let e=new Map;for(let t of x){let r=t[p]||"(empty)";e.has(r)||e.set(r,[]),e.get(r).push(t)}return[...e.entries()].map(([e,t])=>({key:e,rows:t.map(e=>({row:e,orig:e}))}))},[x,p]);async function w(t,r,s){let n=i.map(e=>e===t?e.map((e,t)=>t===r?s:e):e);o(n),await a(u(e,n))}async function k(t){let r=i.filter(e=>e!==t);o(r),await a(u(e,r))}async function N(t){let r=[...i,t];o(r),d(!1),await a(u(e,r))}let S={borderBottom:"1px solid var(--border)",fontSize:"0.72rem",letterSpacing:"0.05em",textTransform:"uppercase",color:"var(--muted-foreground)",fontWeight:600},C=0;return(0,s.jsxs)("div",{className:"rounded-xl overflow-hidden border",style:{borderColor:"var(--border)"},children:[(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"min-w-full text-sm border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{style:{background:"var(--muted)"},children:[c.map(t=>(0,s.jsx)("th",{className:"px-4 py-2.5 text-left whitespace-nowrap",style:S,children:(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[e[t],r.sortField===e[t]&&("asc"===r.sortDir?(0,s.jsx)(h.A,{size:10,style:{color:"var(--amber)"}}):(0,s.jsx)(f.A,{size:10,style:{color:"var(--amber)"}}))]})},t)),(0,s.jsx)("th",{className:"w-8",style:{...S,background:"var(--muted)"}})]})}),(0,s.jsxs)("tbody",{children:[j.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[null!==e.key&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:c.length+1,className:"px-4 py-1.5",style:{background:"var(--accent)",borderBottom:"1px solid var(--border)",borderTop:"1px solid var(--border)"},children:(0,s.jsxs)("span",{className:"text-xs font-semibold font-display",style:{color:"var(--muted-foreground)"},children:[e.key," \xb7 ",e.rows.length]})})},`grp-${e.key}`),e.rows.map(({row:e,orig:t})=>{let r=C++;return(0,s.jsxs)("tr",{className:"group transition-colors",style:{background:r%2==0?"var(--background)":"var(--card)"},onMouseEnter:e=>e.currentTarget.style.background="var(--muted)",onMouseLeave:e=>e.currentTarget.style.background=r%2==0?"var(--background)":"var(--card)",children:[c.map(r=>(0,s.jsx)("td",{className:"px-4 py-2 max-w-xs",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)(v,{value:e[r]??"",onCommit:e=>w(t,r,e)})},r)),(0,s.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)("button",{onClick:()=>k(t),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/10",style:{color:"var(--muted-foreground)"},children:(0,s.jsx)(g.A,{size:12})})})]},r)})]},e.key??`section-${t}`)),l&&(0,s.jsx)(y,{headers:e,visibleIndices:c,onAdd:N,onCancel:()=>d(!1)})]})]})}),(0,s.jsxs)("div",{className:"px-4 py-2 flex items-center justify-between",style:{background:"var(--muted)",borderTop:"1px solid var(--border)"},children:[(0,s.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)"},children:[i.length," rows \xb7 ",e.length," cols"]}),l?(0,s.jsx)("button",{onClick:()=>d(!1),className:"text-xs px-2.5 py-1 rounded-md",style:{color:"var(--muted-foreground)"},children:"Cancel"}):(0,s.jsxs)("button",{onClick:()=>d(!0),className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-md",style:{color:"var(--amber)",background:"var(--amber-dim)"},children:[(0,s.jsx)(b.A,{size:12})," Add row"]})]})]})}function w({headers:e,rows:t,cfg:r}){let n=e.indexOf(r.titleField),a=e.indexOf(r.descField),i=e.indexOf(r.tagField);return(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map((t,r)=>{let o=n>=0?t[n]:t[0]??"",l=a>=0?t[a]:"",d=i>=0?t[i]:"",c=d?x(d):null;return(0,s.jsxs)("div",{className:"rounded-xl border p-4 flex flex-col gap-2 hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[d&&c&&(0,s.jsx)("span",{className:"self-start text-xs px-2 py-0.5 rounded-full font-medium",style:{background:c.bg,color:c.text},children:d}),(0,s.jsx)("p",{className:"text-sm font-semibold leading-snug",style:{color:"var(--foreground)"},children:o}),l&&(0,s.jsx)("p",{className:"text-xs leading-relaxed line-clamp-3",style:{color:"var(--muted-foreground)"},children:l}),(0,s.jsx)("div",{className:"mt-1 flex flex-col gap-0.5",children:e.map((e,r)=>{if(r===n||r===a||r===i)return null;let o=t[r];return o?(0,s.jsxs)("div",{className:"flex items-baseline gap-1.5 text-xs",children:[(0,s.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",opacity:.6,fontSize:"0.68rem"},children:e}),(0,s.jsx)("span",{className:"truncate",style:{color:"var(--muted-foreground)"},children:o})]},r):null})})]},r)})})}function k({headers:e,rows:t,cfg:r,saveAction:a}){let[i,o]=(0,n.useState)(t),[l,d]=(0,n.useState)(null),[c,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{o(t)},[t]);let f=e.indexOf(r.groupField),g=e.indexOf(r.titleField),v=e.indexOf(r.descField),{groups:y,groupKeys:j}=(0,n.useMemo)(()=>{let e=new Map;return i.forEach((t,r)=>{let s=(f>=0?t[f]:"")||"(empty)";e.has(s)||e.set(s,[]),e.get(s).push({row:t,origIdx:r})}),{groups:e,groupKeys:[...e.keys()]}},[i,f]);async function w(t,r){let s=i.map((e,s)=>{if(s!==t)return e;let n=[...e];return f>=0&&(n[f]=r),n});o(s),await a(u(e,s))}function k({group:t}){let r=y.get(t)??[],n=x(t),a=l===t;return(0,s.jsxs)("div",{className:"flex-shrink-0 w-64 flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,s.jsx)("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:n.text}}),(0,s.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider truncate font-display",style:{color:n.text},children:t}),(0,s.jsx)("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--muted-foreground)",opacity:.5},children:r.length})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl p-1.5 min-h-[80px] transition-colors",style:{background:a?"var(--amber-dim)":"var(--muted)",border:`1px solid ${a?"var(--amber)":"transparent"}`},onDragOver:e=>{e.preventDefault(),d(t)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||d(null)},onDrop:e=>{d(null);let r=parseInt(e.dataTransfer.getData("origIdx"));isNaN(r)||w(r,t)},children:[r.map(({row:t,origIdx:r})=>{let n=g>=0?t[g]:t[0]??"",a=v>=0?t[v]:"";return(0,s.jsxs)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.setData("origIdx",String(r)),d(null)},onDragEnd:()=>d(null),className:"rounded-lg border p-3 flex flex-col gap-1.5 cursor-grab active:cursor-grabbing hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,s.jsx)("p",{className:"text-sm font-medium leading-snug",style:{color:"var(--foreground)"},children:n}),a&&(0,s.jsx)("p",{className:"text-xs leading-relaxed line-clamp-2",style:{color:"var(--muted-foreground)"},children:a}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1 mt-0.5",children:e.map((e,r)=>{if(r===f||r===g||r===v)return null;let n=t[r];return n?(0,s.jsxs)("span",{className:"text-2xs px-1.5 py-0.5 rounded font-display",style:{background:"var(--muted)",color:"var(--muted-foreground)"},children:[e,": ",n]},r):null})})]},r)}),0===r.length&&(0,s.jsx)("div",{className:"flex items-center justify-center h-12",children:(0,s.jsx)("span",{className:"text-xs",style:{color:"var(--muted-foreground)",opacity:.4},children:"Drop here"})})]})]})}return(0,s.jsxs)("div",{className:"flex gap-3 overflow-x-auto pb-3 items-start",children:[j.map(e=>(0,s.jsx)(k,{group:e},e)),(0,s.jsx)("div",{className:"flex-shrink-0 w-64",children:p?(0,s.jsxs)("div",{className:"rounded-xl border p-3 flex flex-col gap-2",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,s.jsx)("input",{autoFocus:!0,value:c,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&c.trim()&&(m(""),h(!1)),"Escape"===e.key&&(m(""),h(!1))},placeholder:"Column name…",className:"text-xs bg-transparent outline-none w-full font-display",style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)"}}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:"Create"}),(0,s.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{color:"var(--muted-foreground)"},children:"Cancel"})]})]}):(0,s.jsxs)("button",{onClick:()=>h(!0),className:"flex items-center gap-1.5 text-xs px-3 py-2 rounded-xl border border-dashed w-full transition-colors hover:bg-muted font-display",style:{borderColor:"var(--border)",color:"var(--muted-foreground)"},children:[(0,s.jsx)(b.A,{size:12})," Add column"]})})]})}var N=r(33210),S=r(27996);function C({headers:e,cfg:t,view:r,onClose:n,onChange:a}){let i={color:"var(--muted-foreground)",fontSize:"0.72rem"};function o({label:t,value:r,onChange:n}){return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"font-display",style:i,children:t}),(0,s.jsx)(S.A,{value:r,onChange:n,size:"sm",options:[{value:"",label:"— none —"},...e.map(e=>({value:e,label:e}))]})]})}return(0,s.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-72 rounded-xl border shadow-xl p-4 flex flex-col gap-3",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:[r," settings"]}),(0,s.jsx)("button",{onClick:n,style:{color:"var(--muted-foreground)"},children:(0,s.jsx)(N.A,{size:13})})]}),"table"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Sort"}),(0,s.jsx)(o,{label:"Sort by",value:t.table.sortField,onChange:e=>a({...t,table:{...t.table,sortField:e}})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{style:i,children:"Direction"}),(0,s.jsx)("div",{className:"flex rounded overflow-hidden border",style:{borderColor:"var(--border)"},children:["asc","desc"].map(e=>(0,s.jsx)("button",{onClick:()=>a({...t,table:{...t.table,sortDir:e}}),className:"px-3 py-1 text-xs transition-colors font-display",style:{fontSize:"0.72rem",background:t.table.sortDir===e?"var(--amber)":"var(--background)",color:t.table.sortDir===e?"var(--amber-foreground)":"var(--muted-foreground)"},children:e},e))})]}),(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Group"}),(0,s.jsx)(o,{label:"Group by",value:t.table.groupField,onChange:e=>a({...t,table:{...t.table,groupField:e}})}),(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Columns"}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:e.map(e=>{let r=t.table.hiddenFields.includes(e);return(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{style:i,children:e}),(0,s.jsx)("button",{onClick:()=>{let s=r?t.table.hiddenFields.filter(t=>t!==e):[...t.table.hiddenFields,e];a({...t,table:{...t.table,hiddenFields:s}})},className:"text-xs px-2 py-0.5 rounded transition-colors font-display",style:{background:r?"var(--muted)":"var(--amber-dim)",color:r?"var(--muted-foreground)":"var(--amber)"},children:r?"Hidden":"Visible"})]},e)})})]}),"gallery"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{label:"Title",value:t.gallery.titleField,onChange:e=>a({...t,gallery:{...t.gallery,titleField:e}})}),(0,s.jsx)(o,{label:"Description",value:t.gallery.descField,onChange:e=>a({...t,gallery:{...t.gallery,descField:e}})}),(0,s.jsx)(o,{label:"Tag / Badge",value:t.gallery.tagField,onChange:e=>a({...t,gallery:{...t.gallery,tagField:e}})})]}),"board"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{label:"Group by",value:t.board.groupField,onChange:e=>a({...t,board:{...t.board,groupField:e}})}),(0,s.jsx)(o,{label:"Card title",value:t.board.titleField,onChange:e=>a({...t,board:{...t.board,titleField:e}})}),(0,s.jsx)(o,{label:"Card desc",value:t.board.descField,onChange:e=>a({...t,board:{...t.board,descField:e}})})]})]})}let A=[{id:"table",icon:(0,s.jsx)(a.A,{size:13}),label:"Table"},{id:"gallery",icon:(0,s.jsx)(i.A,{size:13}),label:"Gallery"},{id:"board",icon:(0,s.jsx)(o.A,{size:13}),label:"Board"}];function z({filePath:e,content:t,saveAction:r}){let{headers:a,rows:i}=(0,n.useMemo)(()=>{let e;return{headers:(e=c().parse(t,{skipEmptyLines:!0}).data)[0]??[],rows:e.slice(1)}},[t]),o=(0,n.useMemo)(()=>({activeView:"table",table:{sortField:"",sortDir:"asc",groupField:"",hiddenFields:[]},gallery:{titleField:a[0]??"",descField:a[1]??"",tagField:a[2]??""},board:{groupField:a[a.length-1]??"",titleField:a[0]??"",descField:a[1]??""}}),[a]),[d,u]=(0,p.Un)("csv",e,o),[m,x]=(0,n.useState)(!1),h=(0,n.useCallback)(e=>{u(e)},[u]),f=d.activeView;return(0,s.jsxs)("div",{className:"w-full py-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4 relative",children:[(0,s.jsx)("div",{className:"flex items-center gap-0.5 p-1 rounded-lg",style:{background:"var(--muted)"},children:A.map(e=>(0,s.jsxs)("button",{onClick:()=>h({...d,activeView:e.id}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors font-display",style:{background:f===e.id?"var(--card)":"transparent",color:f===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:f===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none"},children:[e.icon,e.label]},e.id))}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)",opacity:.5},children:[i.length," rows"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>x(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors",style:{background:m?"var(--accent)":"var(--muted)",color:m?"var(--foreground)":"var(--muted-foreground)"},title:"View settings",children:(0,s.jsx)(l.A,{size:13})}),m&&(0,s.jsx)(C,{headers:a,cfg:d,view:f,onClose:()=>x(!1),onChange:h})]})]}),"table"===f&&(0,s.jsx)(j,{headers:a,rows:i,cfg:d.table,saveAction:r}),"gallery"===f&&(0,s.jsx)(w,{headers:a,rows:i,cfg:d.gallery}),"board"===f&&(0,s.jsx)(k,{headers:a,rows:i,cfg:d.board,saveAction:r})]})}},92524:(e,t,r)=>{"use strict";r.d(t,{default:()=>n});var s=r(12115);function n(){return(0,s.useEffect)(()=>{!("u">typeof navigator&&/electron/i.test(navigator.userAgent))&&"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(e=>{console.warn("[SW] Registration failed:",e)})},[]),null}},92950:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GraphRenderer:()=>c});var s=r(95155),n=r(12115),a=r(73321),i=r(81750),o=r(61278);r(53255);var l=r(22356);let d=(0,n.memo)(function({data:e}){let t=(0,a.useRouter)(),{label:r,id:l,isCurrent:d,isOrphan:c,size:u=1}=e,m=(0,n.useCallback)(()=>{let e=l.split("/").map(encodeURIComponent).join("/");t.push("/view/"+e)},[l,t]),x=.8+Math.min(.1*u,1.2);return(0,s.jsxs)("div",{onClick:m,title:l,className:"group font-display",style:{fontSize:10*x,padding:`${4*x}px ${12*x}px`,borderRadius:999,cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",opacity:c?.4:1,background:d?"var(--amber)":"var(--card)",color:d?"var(--amber-foreground)":"var(--foreground)",border:`1.5px solid ${d?"var(--amber)":"var(--border)"}`,boxShadow:d?"0 0 20px var(--amber-dim), 0 0 0 2px var(--amber-dim)":"0 2px 4px rgba(0,0,0,0.1)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:d?10:1},onMouseEnter:e=>{d||(e.currentTarget.style.borderColor="var(--amber)",e.currentTarget.style.background="var(--accent)")},onMouseLeave:e=>{d||(e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--card)")},children:[(0,s.jsx)(i.h7,{type:"target",position:o.yX.Top,style:{opacity:0}}),r,(0,s.jsx)(i.h7,{type:"source",position:o.yX.Bottom,style:{opacity:0}})]})});function c({filePath:e}){let[t,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(!0),[c,u]=(0,n.useState)("local"),[m,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>{x(!0)},[]),(0,n.useEffect)(()=>{(0,l.n)("/api/graph").then(e=>{r(e),o(!1)}).catch(()=>o(!1))},[]);let p=(0,n.useMemo)(()=>{if(!t)return new Map;let e=new Map;for(let r of t.edges)e.set(r.source,(e.get(r.source)||0)+1),e.set(r.target,(e.get(r.target)||0)+1);return e},[t]),h=(0,n.useMemo)(()=>{if(!t)return null;let e=new Map;for(let r of t.edges)e.has(r.source)||e.set(r.source,new Set),e.has(r.target)||e.set(r.target,new Set),e.get(r.source).add(r.target),e.get(r.target).add(r.source);return e},[t]),{filteredNodes:f,filteredEdges:g}=(0,n.useMemo)(()=>{let r,s;if(!t)return{filteredNodes:[],filteredEdges:[]};if("global"===c)r=t.nodes,s=t.edges;else{let n=new Set,a=[{id:e,depth:0}];for(n.add(e);a.length>0;){let{id:e,depth:t}=a.shift();if(!(t>=2))for(let r of h?.get(e)??new Set)n.has(r)||(n.add(r),a.push({id:r,depth:t+1}))}let i=new Set((r=t.nodes.filter(e=>n.has(e.id))).map(e=>e.id));s=t.edges.filter(e=>i.has(e.source)&&i.has(e.target))}return{filteredNodes:r,filteredEdges:s}},[t,c,e,h]),b=(0,n.useMemo)(()=>{let e=new Set;for(let t of g)e.add(t.source),e.add(t.target);return e},[g]),{rfNodes:v,rfEdges:y}=(0,n.useMemo)(()=>{if(0===f.length)return{rfNodes:[],rfEdges:[]};let t=function(e,t,r){let s=e.length;if(0===s)return{};let n=(void 0)??(s>100?80:150),a=.6*Math.sqrt(108e4/Math.max(s,1)),i={};e.forEach((e,t)=>{let r=2*Math.PI*t/s,n=360*Math.random();i[e]={x:600+Math.cos(r)*n,y:450+Math.sin(r)*n}});let o={};for(let r=0;r<n;r++){let l=120*(1-r/n);for(let t of e)o[t]={x:0,y:0};for(let t=0;t<s;t++)for(let r=t+1;r<s;r++){let s=e[t],n=e[r],l=i[s].x-i[n].x,d=i[s].y-i[n].y,c=Math.sqrt(l*l+d*d||.01),u=a*a/c;o[s].x+=l/c*u,o[s].y+=d/c*u,o[n].x-=l/c*u,o[n].y-=d/c*u}for(let e of t){let t=e.source,r=e.target;if(!i[t]||!i[r])continue;let s=i[t].x-i[r].x,n=i[t].y-i[r].y,l=Math.sqrt(s*s+n*n||.01),d=l*l/a;o[t].x-=s/l*d,o[t].y-=n/l*d,o[r].x+=s/l*d,o[r].y+=n/l*d}for(let t of e){let e=i[t].x-600,r=i[t].y-450,s=Math.sqrt(e*e+r*r)||.01,n=.05*s;o[t].x-=e/s*n,o[t].y-=r/s*n}for(let t of e){let e=o[t],r=Math.sqrt(e.x*e.x+e.y*e.y)||.01;i[t].x+=e.x/r*Math.min(r,l),i[t].y+=e.y/r*Math.min(r,l),i[t].x=Math.max(0,Math.min(1200,i[t].x)),i[t].y=Math.max(0,Math.min(900,i[t].y))}}return i}(f.map(e=>e.id),g);return{rfNodes:f.map(r=>({id:r.id,type:"wiki",position:t[r.id]??{x:0,y:0},data:{label:r.label,id:r.id,isCurrent:r.id===e,isOrphan:!b.has(r.id),size:p.get(r.id)||1}})),rfEdges:g.map((t,r)=>{let s=t.source===e||t.target===e;return{id:`e-${r}`,source:t.source,target:t.target,type:"default",markerEnd:{type:"arrowclosed",color:s?"var(--amber)":"var(--border)"},style:{stroke:s?"var(--amber)":"var(--border)",strokeWidth:s?1.5:1,opacity:s?.8:.4},animated:s}})}},[f,g,e,b,p]),j=(0,n.useMemo)(()=>({wiki:d}),[]);return!m||a?(0,s.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400,borderRadius:12,background:"var(--muted)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,s.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",fontSize:12},children:a?"Building graph…":"Loading…"})}):(0,s.jsxs)("div",{style:{width:"100%",position:"relative",zIndex:0},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10,flexWrap:"wrap"},children:[(0,s.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[f.length," nodes \xb7 ",g.length," edges"]}),(0,s.jsx)("div",{style:{display:"flex",gap:2,padding:3,borderRadius:8,background:"var(--muted)"},children:[{id:"local",label:"Local"},{id:"global",label:"Global"}].map(e=>(0,s.jsx)("button",{onClick:()=>u(e.id),className:"font-display",style:{padding:"3px 12px",borderRadius:5,fontSize:11,cursor:"pointer",border:"none",outline:"none",background:c===e.id?"var(--card)":"transparent",color:c===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:c===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.1s"},children:e.label},e.id))})]}),(0,s.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400},children:(0,s.jsxs)(i.Gc,{nodes:v,edges:y,nodeTypes:j,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},style:{background:"var(--background)",borderRadius:12,border:"1px solid var(--border)"},children:[(0,s.jsx)(i.VS,{color:"var(--border)",gap:24,size:1,variant:i._5.Dots}),(0,s.jsx)(i.H2,{showInteractive:!1}),(0,s.jsx)(i.of,{nodeColor:e=>e.data?.isCurrent?"var(--amber)":"var(--muted-foreground)"})]})})]})}},93042:(e,t,r)=>{"use strict";r.d(t,{default:()=>i});var s=r(12115),n=r(35581),a=r(28380);function i({ssrLocale:e}){let t=(0,s.useRef)(!1);return t.current||(t.current=!0,n.D.getState().locale!==e&&n.D.setState({locale:e,t:a.D[e]})),(0,s.useEffect)(()=>n.D.getState()._init(e),[e]),null}},95304:(e,t,r)=>{"use strict";r.d(t,{i:()=>n});var s=r(9339);let n=(0,s.createServerReference)("40cc5a911ff7ea82c7a5d10d06b28b928521f49da3",s.callServer,void 0,s.findSourceMapURL,"deleteFileAction")},98959:(e,t,r)=>{"use strict";r.d(t,{default:()=>d});var s=r(95155),n=r(12115),a=r(33210),i=r(35581);let o="mindos_update_skip_desktop",l="mindos_update_skip_core";function d(){let{t:e}=(0,i.Y)(),t=e.settings.update.updateToast,[r,d]=(0,n.useState)("hidden"),[c,u]=(0,n.useState)({}),m=(0,n.useRef)(null),[x,p]=(0,n.useState)(!1),h=(0,n.useRef)(new Set),f=(0,n.useRef)({}),g=(0,n.useCallback)(()=>{h.current.forEach(clearTimeout),h.current.clear()},[]),b=(0,n.useCallback)((e,t)=>{let r=setTimeout(()=>{h.current.delete(r),d(e)},t);h.current.add(r)},[]);(0,n.useEffect)(()=>{let e,t=(e=window,e.mindos?.checkUpdate?e.mindos:null);m.current=t,p(!!t)},[]),(0,n.useEffect)(()=>{let e=m.current;if(!e)return;g();let t=[],r=(e,t,r)=>{let s=localStorage.getItem(r);s&&!function(e,t){let r=e.split(".").map(Number),s=t.split(".").map(Number);for(let e=0;e<Math.max(r.length,s.length);e++){let t=r[e]??0,n=s[e]??0;if(t>n)return!0;if(t<n)break}return!1}(t,s)||f.current[e]!==t&&(f.current[e]=t,u(r=>({...r,[e]:{type:e,version:t}})),b("visible",1e4))};return e.onUpdateAvailable&&t.push(e.onUpdateAvailable(e=>{e?.version&&r("desktop",e.version,o)})),e.onCoreUpdateAvailable&&t.push(e.onCoreUpdateAvailable(e=>{e?.latest&&!e.ready&&r("core",e.latest,l)})),()=>{t.forEach(e=>e()),g()}},[x,g,b]),(0,n.useEffect)(()=>()=>g(),[g]);let v=(0,n.useCallback)(()=>{g(),window.dispatchEvent(new CustomEvent("mindos:open-settings",{detail:{tab:"update"}})),d("dismissing"),b("hidden",200)},[g,b]),y=(0,n.useCallback)(()=>{g(),c.desktop&&localStorage.setItem(o,c.desktop.version),c.core&&localStorage.setItem(l,c.core.version),d("dismissing"),b("hidden",200)},[c,g,b]);if(!x||"hidden"===r)return null;let j=!!(c.desktop&&c.core),w=j?t.titleMultiple:c.desktop?t.titleSingle(t.desktopLabel,c.desktop.version):c.core?t.titleSingle(t.coreLabel,c.core.version):"",k=j?`${t.desktopLabel} v${c.desktop.version} \u00B7 ${t.coreLabel} v${c.core.version}`:"";return(0,s.jsx)("div",{role:"status","aria-live":"polite",className:`
|
|
82
|
+
`})]})}function tK({fileTree:e,children:t}){let r=(0,n.usePathname)(),i=(0,a.useRef)(e),o=function e(t,r){if(t===r)return r;let s=new Map;for(let e of r)s.set(e.path,e);let n=!0,a=Array(t.length);for(let i=0;i<t.length;i++){let o=i<r.length&&r[i].path===t[i].path?r[i]:s.get(t[i].path),l=function(t,r){if(!r||t.path!==r.path||t.type!==r.type||t.name!==r.name||t.extension!==r.extension||t.isSpace!==r.isSpace)return t;if(t.children&&r.children){let s=e(t.children,r.children);return s===r.children&&t.name===r.name&&(t.spacePreview===r.spacePreview||t.spacePreview&&r.spacePreview&&t.spacePreview.lastCompiled===r.spacePreview.lastCompiled&&t.spacePreview.isTemplate===r.spacePreview.isTemplate)?r:{...t,children:s}}return r}(t[i],o);a[i]=l,l!==r[i]&&(n=!1)}return n&&t.length===r.length?r:a}(e,i.current);return(i.current=o,"/login"===r)?(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsx)(tH,{fileTree:o,children:t})}},35504:(e,t,r)=>{"use strict";r.r(t),r.d(t,{ConfigRenderer:()=>d});var s=r(95155),n=r(12115),a=r(6296),i=r(94514),o=r(33210),l=r(51914);function d({content:e,saveAction:t}){let r=(0,n.useMemo)(()=>{try{return JSON.parse(e)}catch{return null}},[e]),[d,c]=(0,n.useState)(r),[u,m]=(0,n.useState)(!1),[x,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)({});(0,n.useEffect)(()=>{c(r),f("")},[r]);let v=d??{},y=v.uiSchema?.sections??[],j=v.keySpecs??{},w=(0,n.useCallback)(async e=>{m(!0),p(!1),f("");try{await t(`${JSON.stringify(e,null,2)}
|
|
83
|
+
`),p(!0),setTimeout(()=>p(!1),1200)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{m(!1)}},[t]),k=(0,n.useCallback)(async(e,t)=>{if(!d)return;let r=function(e,t,r){let s=t.split("."),n=structuredClone(e),a=n;for(let e=0;e<s.length-1;e++){let t=s[e],r=a[t];(!r||"object"!=typeof r||Array.isArray(r))&&(a[t]={}),a=a[t]}return a[s[s.length-1]]=r,n}(d,e,t);c(r),await w(r)},[d,w]);return r&&d?(0,s.jsxs)("div",{className:"max-w-3xl mx-auto flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-border bg-card px-4 py-2.5",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"CONFIG Control Panel"}),(0,s.jsxs)("div",{className:"text-xs flex items-center gap-2",children:[u&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[(0,s.jsx)(a.A,{size:12,className:"animate-spin"}),"Saving"]}),!u&&x&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",style:{color:"var(--success)"},children:[(0,s.jsx)(i.A,{size:12}),"Saved"]})]})]}),h&&(0,s.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/10 px-3 py-2 text-xs text-error",children:h}),y.map(e=>(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:e.title}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e.description})]}),(0,s.jsx)("div",{className:"space-y-3",children:e.fields.map(e=>{let t=j[e]??{},r=function(e,t){let r=t.split("."),s=e;for(let e of r){if(!s||"object"!=typeof s||!(e in s))return null;s=s[e]}return s}(d,e),n=t.label||e;return(0,s.jsxs)("div",{className:"rounded-lg border border-border/80 bg-background px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-foreground",children:n}),t.description&&(0,s.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),"switch"===t.control&&"boolean"==typeof r&&(0,s.jsx)("button",{type:"button",onClick:()=>k(e,!r),className:"px-2.5 py-1 rounded-md text-xs font-medium",style:{background:r?"var(--amber)":"var(--muted)",color:r?"var(--amber-foreground)":"var(--muted-foreground)"},children:r?"ON":"OFF"})]}),"text"===t.control&&"string"==typeof r&&(0,s.jsx)("input",{defaultValue:r,onBlur:t=>k(e,t.target.value),className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"number"===t.control&&"number"==typeof r&&(0,s.jsx)("input",{type:"number",defaultValue:r,min:t.constraints?.min,max:t.constraints?.max,onBlur:s=>{let n=Number(s.target.value),a=t.constraints?.min,i=t.constraints?.max,o=Number.isFinite(n)?n:r;"number"==typeof a&&o<a&&(o=a),"number"==typeof i&&o>i&&(o=i),k(e,o)},className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"tag-list"===t.control&&Array.isArray(r)&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map((t,n)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded border border-border text-xs bg-muted text-foreground",children:[String(t),(0,s.jsx)("button",{type:"button",onClick:()=>k(e,r.filter((e,t)=>t!==n)),className:"text-muted-foreground hover:text-foreground",children:(0,s.jsx)(o.A,{size:11})})]},`${String(t)}-${n}`))}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{value:g[e]??"",onChange:t=>b(r=>({...r,[e]:t.target.value})),onKeyDown:t=>{if("Enter"!==t.key)return;t.preventDefault();let s=(g[e]??"").trim();s&&(k(e,[...r,s]),b(t=>({...t,[e]:""})))},className:"flex-1 px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground",placeholder:"Add item"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let t=(g[e]??"").trim();t&&(k(e,[...r,t]),b(t=>({...t,[e]:""})))},className:"px-2.5 py-1.5 rounded-md text-xs bg-muted text-foreground inline-flex items-center gap-1",children:[(0,s.jsx)(l.A,{size:12})," Add"]})]})]})]},e)})})]},e.id))]}):(0,s.jsx)("div",{className:"rounded-xl border border-border p-4 text-sm text-error",children:"CONFIG.json parse failed. Please check JSON format."})}},39594:(e,t,r)=>{"use strict";r.r(t),r.d(t,{TimelineRenderer:()=>l});var s=r(95155),n=r(12115);let a=/(\d{4}[-/]\d{1,2}(?:[-/]\d{1,2})?|[A-Za-z]+ \d{4}|\d{4}年\d{1,2}月(?:\d{1,2}日)?)/;function i(e){return e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:0.85em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,t,r)=>`<span style="color:var(--amber);cursor:pointer" title="${t}">${r??t}</span>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" style="color:var(--amber)">$1</a>')}let o=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"var(--tool-read)"},{bg:"rgba(200,160,216,0.12)",text:"var(--tool-search)"}];function l({content:e}){let t=(0,n.useMemo)(()=>(function(e){let t=e.split("\n"),r=[],s=null,n=[],i=()=>{let e,t;if(!s)return;let a=n.join("\n").trim();s.body=a,s.tags=(e=[],(t=a.match(/#([\w\u4e00-\u9fff]+)/g))&&e.push(...t.map(e=>e.slice(1))),[...new Set(e)]),r.push(s),s=null,n=[]};for(let e of t)if(!/^# /.test(e)){if(/^## /.test(e)){i();let t=e.slice(3).trim();s={heading:t,date:function(e){let t=a.exec(e);if(!t)return null;let r=new Date(t[1].replace(/[/年月]/g,"-").replace("日",""));return isNaN(r.getTime())?null:r}(t),body:"",tags:[]};continue}s&&n.push(e)}return i(),r})(e),[e]);return 0===t.length?(0,s.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:["No timeline entries found. Add ",(0,s.jsx)("code",{style:{background:"var(--muted)",padding:"1px 6px",borderRadius:4},children:"## 2025-01-15"})," headings to create entries."]}):(0,s.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,s.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[t.length," ",1===t.length?"entry":"entries"]})}),(0,s.jsxs)("div",{style:{position:"relative",paddingLeft:28},children:[(0,s.jsx)("div",{style:{position:"absolute",left:6,top:8,bottom:8,width:1,background:"var(--border)"}}),t.map((e,t)=>(0,s.jsxs)("div",{style:{position:"relative",marginBottom:"1.5rem"},children:[(0,s.jsx)("div",{style:{position:"absolute",left:-22,top:10,width:9,height:9,borderRadius:"50%",background:e.date?"var(--amber)":"var(--border)",outline:e.date?"2px solid var(--amber-dim)":"none",zIndex:1}}),(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,padding:"14px 18px",transition:"border-color .15s"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:8},children:[(0,s.jsx)("span",{style:{fontWeight:600,fontSize:"0.9rem",color:"var(--foreground)"},children:e.heading}),e.date&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.7rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0},children:e.date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})})]}),e.body&&(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:function(e){let t=e.split("\n"),r=[],s=!1,n=()=>{s&&(r.push("</ul>"),s=!1)};for(let e of t){let t=e.trimEnd();if(!t){n(),r.push("<br/>");continue}if(/^### /.test(t)){n(),r.push(`<h3 style="font-size:0.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:.9em 0 .3em">${i(t.slice(4))}</h3>`);continue}if(/^- /.test(t)||/^\* /.test(t)){s||(r.push('<ul style="margin:.3em 0;padding-left:1.2em;list-style:disc">'),s=!0),r.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${i(t.slice(2))}</li>`);continue}if(/^\d+\. /.test(t)){s||(r.push('<ol style="margin:.3em 0;padding-left:1.2em">'),s=!0),r.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${i(t.replace(/^\d+\. /,""))}</li>`);continue}n(),r.push(`<p style="margin:.25em 0;font-size:.82rem;line-height:1.6;color:var(--foreground)">${i(t)}</p>`)}return n(),r.join("")}(e.body)}}),e.tags.length>0&&(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginTop:10},children:e.tags.map(e=>{let t=function(e){let t=0;for(let r=0;r<e.length;r++)t=31*t+e.charCodeAt(r)&65535;return o[t%o.length]}(e);return(0,s.jsxs)("span",{className:"font-display",style:{fontSize:"0.68rem",padding:"1px 8px",borderRadius:999,background:t.bg,color:t.text},children:["#",e]},e)})})]})]},t))]})]})}},40430:(e,t,r)=>{"use strict";r.d(t,{default:()=>d});var s=r(95155),n=r(12115),a=r(12651),i=r(6296),o=r(35581);let l="mindos_update_in_progress";function d(){let[e,t]=(0,n.useState)(!1),[r,d]=(0,n.useState)(!1),c=(0,n.useRef)(void 0),{locale:u}=(0,o.Y)(),m="zh"===u,x=(0,n.useCallback)(()=>{c.current=setInterval(async()=>{try{if((await fetch("/api/health",{signal:AbortSignal.timeout(3e3)})).ok){clearInterval(c.current),c.current=void 0;try{let e=localStorage.getItem(l);if(e){let{originalVer:t}=JSON.parse(e),r=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)}).then(e=>e.json());if(r.current&&r.current!==t){d(!0),localStorage.removeItem(l),localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),setTimeout(()=>window.location.reload(),1500);return}}}catch{}localStorage.removeItem(l),window.location.reload()}}catch{}},3e3)},[]);return((0,n.useEffect)(()=>{let e=()=>{localStorage.getItem(l)&&(t(!0),c.current||x())};e();let r=()=>e();return window.addEventListener("mindos:update-started",r),window.addEventListener("storage",r),()=>{clearInterval(c.current),c.current=void 0,window.removeEventListener("mindos:update-started",r),window.removeEventListener("storage",r)}},[x]),e)?(0,s.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-ui)"},children:[r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.A,{size:32,style:{color:"var(--success)",marginBottom:12}}),(0,s.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"更新成功!":"Update Complete!"}),(0,s.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6},children:m?"正在刷新页面...":"Reloading..."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{size:32,style:{color:"var(--amber)",marginBottom:12,animation:"spin 1s linear infinite"}}),(0,s.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"MindOS 正在更新...":"MindOS is Updating..."}),(0,s.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6,textAlign:"center",maxWidth:300,lineHeight:1.5},children:m?"服务正在重启,请勿关闭此页面。完成后将自动刷新。":"The server is restarting. Please do not close this page. It will auto-reload when ready."})]}),(0,s.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]}):null}},46838:(e,t,r)=>{"use strict";r.d(t,{$7:()=>i,MZ:()=>c,TS:()=>l,UG:()=>a,YB:()=>d,pl:()=>o});let s=[],n=new Set;function a(){try{let e=localStorage.getItem("mindos-disabled-renderers");n=new Set(e?JSON.parse(e):[])}catch{n=new Set}}function i(e,t){let r=s.find(t=>t.id===e);r?.core||(t?n.delete(e):n.add(e),localStorage.setItem("mindos-disabled-renderers",JSON.stringify([...n])))}function o(e){let t=s.find(t=>t.id===e);return!!t?.core||!n.has(e)}function l(e){s.find(t=>t.id===e.id)||s.push(e)}function d(e,t,r){if(r){let e=s.find(e=>e.id===r);return e&&o(e.id)?e:void 0}return s.find(r=>o(r.id)&&r.match({filePath:e,extension:t}))}function c(){return s.filter(e=>!e.appBuiltinFeature)}},48133:(e,t,r)=>{"use strict";r.r(t),r.d(t,{WorkflowYamlRenderer:()=>ee});var s=r(95155),n=r(12115),a=r(49387),i=r(20232),o=r(53961),l=r(13545),d=r(73620),c=r(42129),u=r(51914),m=r(6296),x=r(55243),p=r(12651),h=r(66088),f=r(9921),g=r(68459),b=r(1164),v=r(61878),y=r(33210),j=r(48368),w=r(38798),k=r(21362);function N({trigger:e,children:t,open:r,onClose:a}){let i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!r)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,a]),(0,s.jsxs)("div",{ref:i,className:"relative",children:[e,r&&(0,s.jsx)("div",{className:"absolute top-full left-0 mt-1 w-full min-w-[220px] max-h-[260px] overflow-y-auto bg-card border border-border rounded-lg shadow-lg z-50",children:t})]})}let S=null,C=!1,A=[];function z({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),[l,d]=(0,n.useState)(S??[]),[c,u]=(0,n.useState)("");(0,n.useEffect)(()=>{S?d(S):(A.push(d),C||(C=!0,fetch("/api/acp/registry").then(e=>e.json()).then(e=>{let t=(e.registry?.agents??[]).map(e=>({id:e.id,name:e.name||e.id}));S=t,A.forEach(e=>e(t)),A.length=0}).catch(()=>{S=[],A.forEach(e=>e([])),A.length=0})))},[]);let m=c?l.filter(e=>e.id.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())):l,x=e=>{t(e),a(!1),u("")},p=e?l.find(t=>t.id===e)?.name||e:void 0;return(0,s.jsxs)(N,{open:r,onClose:()=>{a(!1),u("")},trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:p||"MindOS"}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,s.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,s.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("input",{type:"text",value:c,onChange:e=>u(e.target.value),autoFocus:!0,placeholder:"Search agents...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),(0,s.jsxs)("button",{onClick:()=>x(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-foreground"}`,children:["MindOS ",(0,s.jsx)("span",{className:"text-muted-foreground/50 ml-1",children:"(default)"})]}),m.slice(0,30).map(t=>(0,s.jsxs)("button",{onClick:()=>x(t.id),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t.id?"text-[var(--amber)] font-medium":"text-foreground"}`,children:[t.name," ",t.name!==t.id&&(0,s.jsxs)("span",{className:"text-muted-foreground/50 ml-1",children:["(",t.id,")"]})]},t.id)),0===l.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),l.length>0&&0===m.length&&!c&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No ACP agents found"}),(0,s.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(x(i.trim()),o(""))},placeholder:"Custom agent ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let E=[{group:"Anthropic",models:["claude-sonnet-4-6","claude-opus-4","claude-3.5-sonnet","claude-3.5-haiku"]},{group:"OpenAI",models:["gpt-4o","gpt-4o-mini","o3","o4-mini"]},{group:"Google",models:["gemini-2.5-pro","gemini-2.5-flash"]}];function T({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),l=e=>{t(e),a(!1)};return(0,s.jsxs)(N,{open:r,onClose:()=>a(!1),trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:e||"Default model"}),e?(0,s.jsx)(y.A,{size:12,className:"text-muted-foreground shrink-0 hover:text-foreground cursor-pointer",onClick:e=>{e.stopPropagation(),l(void 0)}}):(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,s.jsx)("button",{onClick:()=>l(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-muted-foreground"}`,children:"(default)"}),E.map(t=>(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"px-3 py-1 text-2xs font-semibold text-muted-foreground/60 uppercase tracking-wide bg-muted/30",children:t.group}),t.models.map(t=>(0,s.jsx)("button",{onClick:()=>l(t),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t?"text-[var(--amber)] font-medium":"text-foreground"}`,children:t},t))]},t.group)),(0,s.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(l(i.trim()),o(""))},placeholder:"Custom model ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let $=null,D=!1,R=[];function M({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)($??[]),[l,d]=(0,n.useState)("");(0,n.useEffect)(()=>{$?o($):(R.push(o),D||(D=!0,fetch("/api/skills").then(e=>e.json()).then(e=>{$=(e.skills??[]).map(e=>({name:e.name,description:e.description})),R.forEach(e=>e($)),R.length=0}).catch(()=>{$=[],R.forEach(e=>e([])),R.length=0})))},[]);let c=l?i.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())):i;return(0,s.jsxs)("div",{children:[e.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1 mb-1.5",children:e.map(r=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-md text-2xs bg-[var(--amber)]/10 text-[var(--amber)] border border-[var(--amber)]/20",children:[r,(0,s.jsx)("button",{onClick:()=>t(e.filter(e=>e!==r)),className:"p-0.5 rounded hover:bg-[var(--amber)]/20 transition-colors",children:(0,s.jsx)(y.A,{size:10})})]},r))}),(0,s.jsxs)(N,{open:r,onClose:()=>{a(!1),d("")},trigger:(0,s.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:0===e.length?"Add skills...":`${e.length} selected`}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground"})]}),children:[(0,s.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,s.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("input",{type:"text",value:l,onChange:e=>d(e.target.value),autoFocus:!0,placeholder:"Search skills...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),c.slice(0,60).map(r=>{let n=e.includes(r.name);return(0,s.jsxs)("button",{onClick:()=>{var s;return s=r.name,void(e.includes(s)?t(e.filter(e=>e!==s)):t([...e,s]))},className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2 ${n?"bg-[var(--amber)]/5":""}`,children:[(0,s.jsx)("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0 transition-colors ${n?"bg-[var(--amber)] border-[var(--amber)] text-[var(--amber-foreground)]":"border-border"}`,children:n&&(0,s.jsx)("span",{className:"text-[9px]",children:"✓"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate",children:r.name}),r.description&&(0,s.jsx)("span",{className:"block text-2xs text-muted-foreground truncate mt-0.5",children:r.description})]})]},r.name)}),0===i.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),i.length>0&&0===c.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No skills found"})]})]})}function P({value:e,onChange:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),l=(0,n.useCallback)(r=>{let s=r.trim();s&&!e.includes(s)&&t([...e,s])},[e,t]),d=(0,n.useCallback)(e=>{e.preventDefault(),a(!1);let t=e.dataTransfer.getData("text/mindos-path");if(t)return void l(t);let r=e.dataTransfer.getData("text/plain");r&&l(r)},[l]),u=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy",a(!0)},[]),m=(0,n.useCallback)(()=>a(!1),[]);return(0,s.jsxs)("div",{children:[e.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-1 mb-1.5",children:e.map(r=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 pl-2 pr-1 py-1 rounded-md text-2xs bg-muted/60 border border-border group",children:[(0,s.jsx)(j.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"text-foreground truncate flex-1",title:r,children:r}),(0,s.jsx)("button",{onClick:()=>t(e.filter(e=>e!==r)),className:"p-0.5 rounded hover:bg-[var(--error)]/10 text-muted-foreground hover:text-[var(--error)] opacity-0 group-hover:opacity-100 transition-all",children:(0,s.jsx)(y.A,{size:10})})]},r))}),(0,s.jsxs)("div",{onDrop:d,onDragOver:u,onDragLeave:m,className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 border-dashed transition-colors ${r?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:border-muted-foreground/30"}`,children:[(0,s.jsx)(c.A,{size:14,className:`shrink-0 ${r?"text-[var(--amber)]":"text-muted-foreground/40"}`}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground",children:"Drag files here from the sidebar"})]}),(0,s.jsx)("div",{className:"mt-1.5",children:(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(l(i.trim()),o(""))},placeholder:"Or type a file path...",className:"w-full px-2.5 py-1 text-2xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}async function F(e){try{let t=await fetch("/api/setup/ls",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e||"~"})});if(!t.ok)return[];return(await t.json()).dirs??[]}catch{return[]}}function L({value:e,onChange:t}){let[r,a]=(0,n.useState)([]),[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(-1),u=(0,n.useRef)(!1),m=(0,n.useRef)(null),[x,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(e||"~"),[g,b]=(0,n.useState)([]),[v,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(u.current){u.current=!1;return}if(!e.trim()){a([]),o(!1);return}let t=setTimeout(async()=>{let t=function(e){let t=e.trim();if(!t)return"";if(t.endsWith("/")||t.endsWith("\\"))return t;let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r>=0?t.slice(0,r+1):""}(e)||"~",r=await F(t);if(!r.length){a([]),o(!1);return}let s=t.includes("\\")?"\\":"/",n=t.endsWith("/")||t.endsWith("\\")?t:t+s,i=r.map(e=>n+e),l=e.endsWith("/")||e.endsWith("\\")?i:i.filter(t=>t.startsWith(e.trim()));a(l.slice(0,15)),o(l.length>0),d(-1)},300);return()=>clearTimeout(t)},[e]);let j=()=>{a([]),o(!1),d(-1)},S=e=>{u.current=!0,t(e),j(),m.current?.focus()},C=(0,n.useCallback)(async e=>{y(!0),b(await F(e)),y(!1)},[]);return(0,n.useEffect)(()=>{x&&C(h)},[x,h,C]),(0,s.jsxs)("div",{className:"relative flex gap-1.5",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)("input",{ref:m,type:"text",value:e,onChange:e=>{t(e.target.value),o(!0)},onKeyDown:e=>{i&&0!==r.length&&("ArrowDown"===e.key?(e.preventDefault(),d(e=>Math.min(e+1,r.length-1))):"ArrowUp"===e.key?(e.preventDefault(),d(e=>Math.max(e-1,-1))):"Enter"===e.key&&l>=0?(e.preventDefault(),S(r[l])):"Escape"===e.key?j():"Tab"===e.key&&l>=0&&(e.preventDefault(),S(r[l])))},onBlur:()=>setTimeout(j,150),onFocus:()=>r.length>0&&o(!0),placeholder:"~/projects/my-app",className:"w-full px-2.5 py-1.5 text-xs rounded-lg border border-border bg-background text-foreground font-mono placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),i&&r.length>0&&(0,s.jsx)("div",{role:"listbox",className:"absolute z-50 left-0 right-0 top-full mt-1 rounded-lg border border-border bg-card shadow-lg overflow-auto max-h-[200px]",children:r.map((e,t)=>(0,s.jsxs)("button",{type:"button",role:"option","aria-selected":t===l,onMouseDown:()=>S(e),className:`w-full text-left px-3 py-1.5 text-xs font-mono transition-colors flex items-center gap-1.5 ${t===l?"bg-muted text-foreground":"text-foreground hover:bg-muted/50"}`,children:[(0,s.jsx)(w.A,{size:11,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e})]},e))})]}),(0,s.jsxs)(N,{open:x,onClose:()=>p(!1),trigger:(0,s.jsx)("button",{type:"button",onClick:()=>{f(e||"~"),p(e=>!e)},className:"px-2 py-1.5 rounded-lg border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",title:"Browse directories",children:(0,s.jsx)(c.A,{size:13})}),children:[(0,s.jsxs)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-2 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-2xs font-mono text-muted-foreground truncate flex-1",title:h,children:h}),(0,s.jsx)("button",{onClick:()=>{t(h),p(!1)},className:"px-2 py-0.5 text-2xs rounded font-medium bg-[var(--amber)] text-[var(--amber-foreground)] shrink-0",children:"Select"})]}),"~"!==h&&(0,s.jsxs)("button",{onClick:()=>{let e=h.split("/");e.length<=1||(e.pop(),f(e.join("/")||"~"))},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-muted-foreground flex items-center gap-1.5",children:[(0,s.jsx)(w.A,{size:12,className:"shrink-0"})," .."]}),v&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),!v&&0===g.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No subdirectories"}),g.map(e=>(0,s.jsxs)("button",{onClick:()=>{f("~"===h?`~/${e}`:`${h.replace(/\/+$/,"")}/${e}`)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-foreground flex items-center gap-1.5",children:[(0,s.jsx)(w.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e}),(0,s.jsx)(k.A,{size:10,className:"text-muted-foreground/40 shrink-0"})]},e))]})]})}function I({step:e,index:t,onChange:r,onDelete:a,onMoveUp:i,onMoveDown:o}){let[l,d]=(0,n.useState)(!e.prompt),[c,u]=(0,n.useState)(!1),m=t=>r({...e,...t}),x=e.skills?.length?e.skills:e.skill?[e.skill]:[],p=!!(e.agent||e.model||x.length||e.context?.length||e.description||e.timeout);return l?(0,s.jsxs)("div",{className:"rounded-lg border border-[var(--amber)]/20 bg-card overflow-hidden shadow-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/20",children:[(0,s.jsx)("span",{className:`text-xs font-medium flex-1 truncate ${e.name?"text-foreground":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[i&&(0,s.jsx)("button",{onClick:i,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move up",children:(0,s.jsx)(f.A,{size:12})}),o&&(0,s.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move down",children:(0,s.jsx)(h.A,{size:12})}),(0,s.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-[var(--error)]/10 text-muted-foreground/50 hover:text-[var(--error)] transition-colors",title:"Delete",children:(0,s.jsx)(g.A,{size:11})}),(0,s.jsx)("button",{onClick:()=>d(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground/50 transition-colors",title:"Collapse",children:(0,s.jsx)(f.A,{size:12})})]})]}),(0,s.jsxs)("div",{className:"px-3 py-3 space-y-3",children:[(0,s.jsx)("input",{type:"text",value:e.name,onChange:e=>m({name:e.target.value}),placeholder:"Step name...",autoFocus:!e.name,className:"w-full text-sm font-medium bg-transparent text-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,s.jsx)("textarea",{value:e.prompt,onChange:e=>m({prompt:e.target.value}),placeholder:"What should the AI do?",rows:3,className:"w-full px-3 py-2.5 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y leading-relaxed"}),(0,s.jsxs)("div",{className:`grid ${e.agent?"grid-cols-2":"grid-cols-1"} gap-2`,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Agent"}),(0,s.jsx)(z,{value:e.agent,onChange:t=>m({agent:t,model:t?e.model:void 0})})]}),e.agent&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Model"}),(0,s.jsx)(T,{value:e.model,onChange:e=>m({model:e})})]})]}),(0,s.jsxs)("button",{onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 text-2xs transition-colors ${c||p?"text-muted-foreground":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:[(0,s.jsx)(b.A,{size:11}),c?"Less options":"More options",!c&&p&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)]"})]}),c&&(0,s.jsxs)("div",{className:"space-y-3 pt-1",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Skills"}),(0,s.jsx)(M,{value:x,onChange:e=>m({skills:e,skill:void 0})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Context files"}),(0,s.jsx)(P,{value:e.context??[],onChange:e=>m({context:e.length?e:void 0})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[1fr,auto] gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Description"}),(0,s.jsx)("input",{type:"text",value:e.description||"",onChange:e=>m({description:e.target.value||void 0}),placeholder:"Optional note...",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Timeout"}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{type:"number",min:0,value:e.timeout||"",onChange:e=>m({timeout:e.target.value?Number(e.target.value):void 0}),placeholder:"120",className:"w-16 px-2 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/40",children:"s"})]})]})]})]})]})]}):(0,s.jsxs)("div",{className:"group flex items-start gap-2 px-3 py-2 rounded-lg hover:bg-muted/40 transition-colors cursor-pointer -ml-1",onClick:()=>d(!0),children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:`text-sm leading-tight block ${e.name?"text-foreground font-medium":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),p&&(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1 flex-wrap",children:[e.agent&&(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground",children:e.agent}),x.slice(0,2).map(e=>(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-[var(--amber)]/8 text-[var(--amber)]",children:e},e)),x.length>2&&(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:["+",x.length-2]}),e.context?.length?(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:[e.context.length," files"]}):null]}),e.prompt&&(0,s.jsx)("p",{className:"text-2xs text-muted-foreground/50 mt-1 line-clamp-1 leading-relaxed",children:e.prompt})]}),(0,s.jsx)(h.A,{size:12,className:"text-muted-foreground/30 mt-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"})]})}var O=r(19550);function W({workflow:e,filePath:t,onChange:r,onSaved:a}){let[i,l]=(0,n.useState)(!1),[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)(!1),{confirm:v,ConfirmDialog:y}=(0,O.G)();(0,n.useEffect)(()=>{if(!g)return;let e=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(e)},[g]);let j=t=>r({...e,...t}),w=(0,n.useCallback)((t,s)=>{let n=[...e.steps];n[t]=s,r({...e,steps:n})},[e,r]),k=(0,n.useCallback)(async t=>{let s=e.steps[t];(!s.name&&!s.prompt||await v({title:`Delete step "${s.name||"Untitled"}"?`,variant:"destructive",confirmLabel:"Delete"}))&&r({...e,steps:e.steps.filter((e,r)=>r!==t)})},[e,r,v]),N=(0,n.useCallback)(()=>{let t=e.steps.map(e=>e.id),s=e.steps.length+1,n={id:function(e,t){let r=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"step",s=r,n=2;for(;t.includes(s);)s=`${r}-${n}`,n++;return s}(`step-${s}`,t),name:`Step ${s}`,prompt:""};r({...e,steps:[...e.steps,n]})},[e,r]),S=(0,n.useCallback)((t,s)=>{if(s<0||s>=e.steps.length)return;let n=[...e.steps],[a]=n.splice(t,1);n.splice(s,0,a),r({...e,steps:n})},[e,r]),C=async()=>{l(!0),f(""),b(!1);try{let r,s=(r={title:e.title},e.description&&(r.description=e.description),e.workDir&&(r.workDir=e.workDir),e.skills?.length&&(r.skills=e.skills),e.tools?.length&&(r.tools=e.tools),r.steps=e.steps.map(e=>{let t={id:e.id,name:e.name};return e.description&&(t.description=e.description),e.agent&&(t.agent=e.agent),e.model&&(t.model=e.model),e.skill&&(t.skill=e.skill),e.skills?.length&&(t.skills=e.skills),e.tools?.length&&(t.tools=e.tools),e.context?.length&&(t.context=e.context),t.prompt=e.prompt,e.timeout&&(t.timeout=e.timeout),t}),d.Ay.dump(r,{lineWidth:-1,noRefs:!0,quotingType:'"',forceQuotes:!1})),n=await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,op:"save_file",content:s})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Save failed (HTTP ${n.status})`)}b(!0),a?.()}catch(e){f(e instanceof Error?e.message:"Save failed")}finally{l(!1)}};(0,n.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&"s"===t.key&&(t.preventDefault(),!i&&e.title.trim()&&e.steps.length>0&&C())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)});let A=!i&&!!e.title.trim()&&e.steps.length>0;return(0,s.jsxs)("div",{children:[y,(0,s.jsxs)("div",{className:"space-y-3 mb-8",children:[(0,s.jsx)("input",{type:"text",value:e.title,onChange:e=>j({title:e.target.value}),placeholder:"Flow title...",className:"w-full text-lg font-semibold bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none border-none p-0 leading-tight"}),(0,s.jsx)("input",{type:"text",value:e.description||"",onChange:e=>j({description:e.target.value||void 0}),placeholder:"Add a description...",className:"w-full text-sm bg-transparent text-muted-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(c.A,{size:12,className:"text-muted-foreground/40 shrink-0"}),(0,s.jsx)(L,{value:e.workDir||"",onChange:e=>j({workDir:e||void 0})})]})]}),e.steps.length>0?(0,s.jsxs)("div",{className:"relative",children:[e.steps.length>1&&(0,s.jsx)("div",{className:"absolute left-[19px] top-6 bottom-16 w-px bg-border"}),(0,s.jsx)("div",{className:"flex flex-col gap-3 mb-5 relative",children:e.steps.map((t,r)=>(0,s.jsxs)("div",{className:"relative pl-11",children:[(0,s.jsx)("div",{className:"absolute left-[7px] top-3 w-[22px] h-[22px] rounded-full border-2 border-border bg-background z-10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-[10px] font-bold text-muted-foreground/60",children:r+1})}),(0,s.jsx)(I,{step:t,index:r,onChange:e=>w(r,e),onDelete:()=>k(r),onMoveUp:r>0?()=>S(r,r-1):void 0,onMoveDown:r<e.steps.length-1?()=>S(r,r+1):void 0})]},t.id))}),(0,s.jsxs)("div",{className:"relative pl-11",children:[(0,s.jsx)("div",{className:"absolute left-[7px] top-2.5 w-[22px] h-[22px] rounded-full border-2 border-dashed border-border bg-background z-10 flex items-center justify-center",children:(0,s.jsx)(u.A,{size:9,className:"text-muted-foreground/40"})}),(0,s.jsx)("button",{onClick:N,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/40 transition-colors",children:"Add step..."})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-2xl bg-[var(--amber)]/8 flex items-center justify-center mb-4",children:(0,s.jsx)(o.A,{size:22,className:"text-[var(--amber)]/60"})}),(0,s.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"Build your flow"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/60 mb-5 max-w-[240px]",children:"Each step is a task for an AI agent. Chain them together to automate complex workflows."}),(0,s.jsxs)("button",{onClick:N,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:[(0,s.jsx)(u.A,{size:12}),"Add first step"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 mt-8 pt-4 border-t border-border/50",children:[(0,s.jsxs)("button",{onClick:C,disabled:!A,title:e.title.trim()?0===e.steps.length?"Add at least one step":void 0:"Title is required",className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed ${A?"bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90":"bg-muted text-muted-foreground"}`,children:[i?(0,s.jsx)(m.A,{size:12,className:"animate-spin"}):(0,s.jsx)(x.A,{size:12}),i?"Saving...":"Save"]}),h&&(0,s.jsx)("span",{className:"text-xs text-[var(--error)]",children:h}),g&&!h&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-2xs text-[var(--success)]",children:[(0,s.jsx)(p.A,{size:11}),"Saved"]}),(0,s.jsx)("kbd",{className:"text-2xs text-muted-foreground/30 ml-auto font-mono",children:"Ctrl+S"})]})]})}var B=r(30125),_=r(62791),U=r(86901),H=r(21628),K=r(9199);let X=new Map;async function Y(e,t){if(X.has(e))return X.get(e);try{let r=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e}),signal:t});if(!r.ok)return X.set(e,null),null;let s=(await r.json()).content;return X.set(e,s??null),s??null}catch{return null}}async function J(e,t){try{let r=await fetch(`/api/acp/registry?agent=${encodeURIComponent(e)}`,{signal:t});if(!r.ok)return null;let s=await r.json();if(s.agent?.id)return{id:s.agent.id,name:s.agent.name||e};return null}catch{return null}}async function G(e,t,r,s,n){let a=function(e,t){let r=[];if(e.skills?.length)for(let t of e.skills)r.includes(t)||r.push(t);else e.skill&&r.push(e.skill);for(let e of t.skills??[])r.includes(e)||r.push(e);return r}(e,t),i=new Map;if(a.length>0)for(let[e,t]of(await Promise.all(a.map(async e=>{let t=await Y(e,n);return[e,t]}))))t&&i.set(e,t);let o=null;e.agent&&(o=await J(e.agent,n));let l={messages:[{role:"user",content:function(e,t,r){let s=t.steps.map((e,t)=>`${t+1}. ${e.name}`).join("\n"),n=e.skills?.length?e.skills[0]:e.skill,a="";if(r.size>0){let e=[];for(let[t,s]of r){let r=t===n;e.push(`### ${r?"[Primary] ":""}Skill: ${t}
|
|
84
|
+
|
|
85
|
+
${s}`)}a=`
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
## Skill Reference
|
|
89
|
+
|
|
90
|
+
Follow the guidelines from these skills when executing this step:
|
|
91
|
+
|
|
92
|
+
${e.join("\n\n---\n\n")}`}return`You are executing step ${e.index+1} of a workflow: "${e.name}".
|
|
93
|
+
|
|
94
|
+
Context of the full workflow "${t.title}":
|
|
95
|
+
${s}
|
|
96
|
+
|
|
97
|
+
Current step instructions:
|
|
98
|
+
${e.prompt||"(No specific instructions — use common sense.)"}${a}
|
|
99
|
+
|
|
100
|
+
Execute concisely. Provide:
|
|
101
|
+
1. What you did / what the output is
|
|
102
|
+
2. Any decisions made
|
|
103
|
+
3. What the next step should watch out for
|
|
104
|
+
|
|
105
|
+
Be specific and actionable. Format in Markdown.`}(e,t,i)}],currentFile:r};o&&(l.selectedAcpAgent=o);let d=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:n});if(!d.ok)throw Error(`Request failed (HTTP ${d.status})`);if(!d.body)throw Error("No response body");let c=d.body.getReader(),u=new TextDecoder,m="";for(;;){let{done:e,value:t}=await c.read();if(e)break;for(let e of u.decode(t,{stream:!0}).split("\n")){let t=e.match(/^data:(.+)$/);if(t){try{let e=JSON.parse(t[1]);if("text_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,s(m);else if("thinking_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,s(m);else if("error"===e.type&&e.message)throw Error(e.message)}catch{let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t&&s(m+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}continue}let r=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);r&&s(m+=r[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}}}function Z(e){return e.steps.map((e,t)=>({...e,index:t,status:"pending",output:"",error:void 0}))}function V({status:e,index:t}){let r="w-[26px] h-[26px] rounded-full flex items-center justify-center shrink-0 transition-all";return"running"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--amber)]/15 ring-2 ring-[var(--amber)]/30`,children:(0,s.jsx)(m.A,{size:12,className:"text-[var(--amber)] animate-spin"})}):"done"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--success)]/15`,children:(0,s.jsx)(p.A,{size:13,className:"text-[var(--success)]"})}):"error"===e?(0,s.jsx)("div",{className:`${r} bg-[var(--error)]/15`,children:(0,s.jsx)(l.A,{size:13,className:"text-[var(--error)]"})}):"skipped"===e?(0,s.jsx)("div",{className:`${r} bg-muted/50`,children:(0,s.jsx)(B.A,{size:11,className:"text-muted-foreground/40"})}):(0,s.jsx)("div",{className:`${r} border-2 border-border bg-background`,children:(0,s.jsx)("span",{className:"text-[11px] font-bold text-muted-foreground/50",children:t+1})})}function q({step:e,canRun:t,onRun:r,onSkip:a,onCancel:o}){let[d,c]=(0,n.useState)(!1),u=!!(e.output||e.error),m=e.skills?.length?e.skills:e.skill?[e.skill]:[];return"running"===e.status||e.status,(0,s.jsx)("div",{className:`transition-opacity ${"skipped"===e.status?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(V,{status:e.status,index:e.index}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-between",children:[(0,s.jsx)("span",{className:`text-sm font-medium truncate ${"done"===e.status?"text-foreground":"running"===e.status?"text-[var(--amber)]":"error"===e.status?"text-[var(--error)]":"text-foreground/70"}`,children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[null!=e.durationMs&&("done"===e.status||"error"===e.status)&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/40 font-mono",children:function(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}(e.durationMs)}),"pending"===e.status&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{onClick:r,disabled:!t,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs font-medium transition-all disabled:opacity-30 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[(0,s.jsx)(i.A,{size:9})," Run"]}),(0,s.jsx)("button",{onClick:a,className:"px-1.5 py-0.5 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:"Skip"})]}),"running"===e.status&&(0,s.jsxs)("button",{onClick:o,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs text-[var(--error)]/70 hover:text-[var(--error)] hover:bg-[var(--error)]/10 transition-colors",children:[(0,s.jsx)(_.A,{size:9})," Stop"]}),u&&"running"!==e.status&&(0,s.jsx)("button",{onClick:()=>c(e=>!e),className:"p-0.5 rounded text-muted-foreground/30 hover:text-muted-foreground transition-colors",children:(0,s.jsx)(h.A,{size:12,className:`transition-transform ${d?"rotate-180":""}`})})]})]}),(e.agent||m.length>0)&&(0,s.jsxs)("div",{className:"flex gap-1 mt-0.5 flex-wrap",children:[e.agent&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/50",children:e.agent}),e.agent&&m.length>0&&(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/20",children:"/"}),m.map(e=>(0,s.jsx)("span",{className:"text-2xs text-[var(--amber)]/60",children:e},e))]}),(d||"running"===e.status)&&u&&(0,s.jsxs)("div",{className:"mt-2 rounded-lg overflow-hidden border border-border/50",children:[e.error&&(0,s.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--error)]/5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,s.jsx)(l.A,{size:10,className:"text-[var(--error)]"}),(0,s.jsx)("span",{className:"text-2xs font-medium text-[var(--error)]",children:"Error"})]}),(0,s.jsx)("div",{className:"text-xs text-[var(--error)]/80 whitespace-pre-wrap break-words leading-relaxed",children:e.error})]}),e.output&&(0,s.jsxs)("div",{className:"px-3 py-2.5 bg-muted/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,s.jsx)(U.A,{size:10,className:"text-[var(--amber)]"}),(0,s.jsx)("span",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider font-medium",children:"Output"}),"running"===e.status&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)] animate-pulse"})]}),(0,s.jsx)("div",{className:"text-xs leading-relaxed text-foreground/80 whitespace-pre-wrap break-words",children:e.output})]})]})]})]})})}function Q({workflow:e,filePath:t}){let[r,a]=(0,n.useState)(()=>Z(e)),[i,o]=(0,n.useState)(!1),d=(0,n.useRef)(null);(0,n.useEffect)(()=>{a(Z(e)),o(!1)},[e]);let u=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,o(!1),a(e=>e.map(e=>"running"===e.status?{...e,status:"error",error:"Cancelled"}:e))},[]),x=(0,n.useCallback)(async r=>{if(i)return;d.current?.abort();let s=new AbortController;d.current=s,o(!0);let n=Date.now();a(e=>e.map((e,t)=>t===r?{...e,status:"running",output:"",error:void 0,startedAt:new Date}:e));try{let i={...e.steps[r],index:r,status:"running",output:""};await G(i,e,t,e=>a(t=>t.map((t,s)=>s===r?{...t,output:e}:t)),s.signal);let o=Date.now()-n;a(e=>e.map((e,t)=>t===r?{...e,status:"done",completedAt:new Date,durationMs:o}:e))}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;let e=Date.now()-n;a(s=>s.map((s,n)=>n===r?{...s,status:"error",error:t instanceof Error?t.message:String(t),durationMs:e}:s))}finally{o(!1)}},[i,e,t]),h=(0,n.useCallback)(e=>{a(t=>t.map((t,r)=>r===e?{...t,status:"skipped"}:t))},[]),f=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,o(!1),X.clear(),a(Z(e))},[e]),g=r.filter(e=>"done"===e.status).length,b=r.length>0?Math.round(g/r.length*100):0,v=g===r.length&&r.length>0,y=r.findIndex(e=>"pending"===e.status),j=r.some(e=>"error"===e.status);return(0,s.jsxs)("div",{children:[(e.workDir||e.description)&&(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4 text-xs text-muted-foreground flex-wrap",children:[e.workDir&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-2xs bg-muted/50 px-2 py-0.5 rounded",children:[(0,s.jsx)(c.A,{size:10,className:"shrink-0"}),e.workDir]}),e.description&&(0,s.jsx)("span",{className:"leading-relaxed",children:e.description})]}),(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:v?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--success)]",children:[(0,s.jsx)(p.A,{size:13}),"Complete"]}):j?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--error)]",children:[(0,s.jsx)(l.A,{size:13}),g,"/",r.length," done"]}):(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[g,"/",r.length]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[y>=0&&(0,s.jsxs)("button",{onClick:()=>x(y),disabled:i,className:"flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all disabled:opacity-40 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[i?(0,s.jsx)(m.A,{size:11,className:"animate-spin"}):(0,s.jsx)(H.A,{size:11}),i?"Running...":"Run next"]}),(0,s.jsxs)("button",{onClick:f,className:"flex items-center gap-1 px-2 py-1 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:[(0,s.jsx)(K.A,{size:10}),"Reset"]})]})]}),(0,s.jsx)("div",{className:"h-1 rounded-full bg-border/50 overflow-hidden",children:(0,s.jsx)("div",{className:`h-full rounded-full transition-all duration-500 ease-out ${v?"bg-[var(--success)]":j?"bg-[var(--error)]":"bg-[var(--amber)]"}`,style:{width:`${b}%`}})})]}),(0,s.jsxs)("div",{className:"relative",children:[r.length>1&&(0,s.jsx)("div",{className:"absolute left-[12px] top-5 bottom-5 w-px bg-border/50"}),(0,s.jsx)("div",{className:"flex flex-col gap-4",children:r.map((e,t)=>(0,s.jsx)(q,{step:e,canRun:!i,onRun:()=>x(t),onSkip:()=>h(t),onCancel:u},e.id))})]})]})}function ee({filePath:e,content:t}){let r=(0,n.useMemo)(()=>(function(e){try{let t=d.Ay.load(e,{schema:d.Ay.JSON_SCHEMA});if(!t)return{workflow:null,errors:["File is empty"]};if("object"!=typeof t)return{workflow:null,errors:["Content is not valid YAML"]};let r=function(e){let t=[];if(!e||"object"!=typeof e)return{valid:!1,errors:["Must be a valid YAML object"]};if(e.title&&"string"==typeof e.title&&e.title.trim()||t.push("Missing required field 'title' (string)"),void 0!==e.description&&"string"!=typeof e.description&&t.push("'description' must be a string"),void 0!==e.skills&&(Array.isArray(e.skills)?e.skills.every(e=>"string"==typeof e)||t.push("'skills' must contain only strings"):t.push("'skills' must be an array of strings")),void 0!==e.tools&&(Array.isArray(e.tools)?e.tools.every(e=>"string"==typeof e)||t.push("'tools' must contain only strings"):t.push("'tools' must be an array of strings")),e.steps)if(Array.isArray(e.steps))if(0===e.steps.length)t.push("'steps' must have at least 1 step");else{let r=new Set;e.steps.forEach((e,s)=>{var n,a;let i,o,l=(n=e,a=s,i=[],o=`steps[${a}]`,n&&"object"==typeof n?(n.id&&"string"==typeof n.id&&n.id.trim()?/^[a-z0-9_-]+$/.test(n.id)||i.push(`${o}.id: '${n.id}' is invalid — use only lowercase letters, numbers, hyphens, underscores (e.g., 'run-tests')`):i.push(`${o}: missing required field 'id' (non-empty string)`),n.name&&"string"==typeof n.name&&n.name.trim()||i.push(`${o}: missing required field 'name' (non-empty string)`),void 0!==n.description&&"string"!=typeof n.description&&i.push(`${o}.description: must be a string`),void 0===n.agent||"string"==typeof n.agent&&n.agent.trim()||i.push(`${o}.agent: must be a non-empty string`),void 0===n.skill||"string"==typeof n.skill&&n.skill.trim()||i.push(`${o}.skill: must be a non-empty string`),void 0!==n.tools&&(Array.isArray(n.tools)?n.tools.every(e=>"string"==typeof e)||i.push(`${o}.tools: must contain only strings`):i.push(`${o}.tools: must be an array of strings`)),n.prompt&&"string"==typeof n.prompt&&n.prompt.trim()||i.push(`${o}: missing required field 'prompt' (non-empty string)`),void 0!==n.timeout&&("number"!=typeof n.timeout||n.timeout<=0)&&i.push(`${o}.timeout: must be a positive number (seconds)`)):i.push(`${o}: must be a valid object`),i);t.push(...l);let d=e?.id;"string"==typeof d&&d.trim()&&(r.has(d)&&t.push(`steps[${s}].id: duplicate id '${d}' (each step must have a unique id)`),r.add(d))})}else t.push("'steps' must be an array");else t.push("Missing required field 'steps' (array)");return{valid:0===t.length,errors:t}}(t);if(!r.valid)return{workflow:null,errors:r.errors};return{workflow:t,errors:[]}}catch(e){return{workflow:null,errors:[e instanceof Error?e.message:String(e)]}}})(t),[t]),[c,u]=(0,n.useState)("edit"),[m,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(()=>r.workflow?structuredClone(r.workflow):{title:"",description:"",steps:[]});(0,n.useRef)(t);let f=(0,n.useMemo)(()=>r.workflow??null,[r.workflow]),g=(0,n.useCallback)(e=>{h(e),x(!0)},[]),b=(0,n.useCallback)(()=>x(!1),[]),v=f??p,y=v.steps.length>0&&!!v.title,j=r.errors.length>0,w=v.title?0===v.steps.length?"Add at least one step":m?"Save changes first":void 0:"Add a title first",k=e=>{("run"!==e||y)&&u(e)};return(0,s.jsxs)("div",{className:"max-w-[720px] mx-auto py-8 px-2",children:[(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 p-0.5 rounded-lg bg-muted/50",children:[(0,s.jsxs)("button",{onClick:()=>k("edit"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${"edit"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,s.jsx)(a.A,{size:11}),"Edit"]}),(0,s.jsxs)("button",{onClick:()=>k("run"),disabled:!y,title:w,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all disabled:opacity-30 disabled:cursor-not-allowed ${"run"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,s.jsx)(i.A,{size:11}),"Run"]})]}),p.steps.length>0&&(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground/60 font-mono",children:[p.steps.length," step",1!==p.steps.length?"s":""]})]}),(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-1 w-8 h-8 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:(0,s.jsx)(o.A,{size:16,className:"text-[var(--amber)]"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("h1",{className:"text-lg font-semibold text-foreground truncate leading-tight",children:[p.title||"Untitled Flow",m&&(0,s.jsx)("span",{className:"text-[var(--amber)] ml-1.5 text-sm",title:"Unsaved changes",children:"*"})]}),p.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:p.description})]})]})]}),j&&"edit"===c&&(0,s.jsxs)("div",{className:"mb-5 px-3.5 py-3 rounded-lg bg-[var(--error)]/8 border border-[var(--error)]/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,s.jsx)(l.A,{size:13,className:"text-[var(--error)] shrink-0"}),(0,s.jsx)("span",{className:"text-xs font-medium text-[var(--error)]",children:"Parse issues found"})]}),(0,s.jsx)("ul",{className:"text-2xs text-[var(--error)]/70 pl-5 list-disc space-y-0.5",children:r.errors.slice(0,3).map((e,t)=>(0,s.jsx)("li",{children:e},t))})]}),"edit"===c?(0,s.jsx)(W,{workflow:p,filePath:e,onChange:g,onSaved:b}):(0,s.jsx)(Q,{workflow:v,filePath:e})]})}},56406:(e,t,r)=>{"use strict";r.r(t),r.d(t,{SummaryRenderer:()=>x});var s=r(95155),n=r(12115),a=r(91958),i=r(86901),o=r(48368),l=r(84980),d=r(91337),c=r(22356);function u(e){let t=Date.now()-e,r=Math.floor(t/6e4),s=Math.floor(t/36e5),n=Math.floor(t/864e5);return r<1?"just now":r<60?`${r}m ago`:s<24?`${s}h ago`:`${n}d ago`}function m(e){return e.split("/").pop()?.replace(/\.(md|csv)$/,"")??e}function x({filePath:e}){let[t,r]=(0,n.useState)([]),[x,p]=(0,n.useState)(""),[h,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)(""),[v,y]=(0,n.useState)(!1),j=(0,n.useRef)(null),w=(0,n.useMemo)(()=>x.replace(/^### (.+)$/gm,'<h3 style="font-size:.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:1em 0 .3em">$1</h3>').replace(/^## (.+)$/gm,'<h2 style="font-size:.9rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h2>').replace(/^# (.+)$/gm,'<h1 style="font-size:1rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h1>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:.82em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/^[-*] (.+)$/gm,'<li style="margin:.2em 0;padding-left:.3em">$1</li>').replace(/(<li[^>]*>.*<\/li>\n?)+/g,e=>`<ul style="margin:.4em 0;padding-left:1.4em;list-style:disc">${e}</ul>`).replace(/\n{2,}/g,'</p><p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">').replace(/^(?!<[hulo])(.+)$/gm,'<p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">$1</p>'),[x]);async function k(){if(0===t.length)return;j.current?.abort();let e=new AbortController;j.current=e,p(""),b(""),f(!0),y(!1);let r=t.map(e=>e.path),s=t.map(e=>`- **${m(e.path)}** (${e.path}, modified ${u(e.mtime)})`).join("\n"),n=`You are summarizing recent changes in a personal knowledge base (MindOS).
|
|
106
|
+
|
|
107
|
+
The following files were recently modified:
|
|
108
|
+
${s}
|
|
109
|
+
|
|
110
|
+
Please provide a concise daily briefing in this format:
|
|
111
|
+
1. **Key changes**: What was added or updated in each file (1–2 sentences per file)
|
|
112
|
+
2. **Themes**: Any patterns or recurring topics across the changes
|
|
113
|
+
3. **Suggested next actions**: 2–3 actionable follow-ups based on the content
|
|
114
|
+
|
|
115
|
+
Be specific. Reference actual content from the files. Keep the total response under 300 words.`;try{let t=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:n}],attachedFiles:r}),signal:e.signal});if(!t.ok)throw Error(`HTTP ${t.status}`);if(!t.body)throw Error("No response body");let s=t.body.getReader(),a=new TextDecoder,i="";for(;;){let{done:e,value:t}=await s.read();if(e)break;for(let e of a.decode(t,{stream:!0}).split("\n")){let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t?i+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):!e||e.startsWith("d:")||e.startsWith("e:")||e.startsWith("0:")||(i+=e)}p(i)}y(!0)}catch(e){e instanceof Error&&"AbortError"!==e.name&&b(e.message||"Failed to generate summary")}finally{f(!1)}}return(0,n.useEffect)(()=>{(0,c.n)("/api/recent-files?limit=8").then(e=>r(e.filter(e=>e.path.endsWith(".md")))).catch(e=>{console.warn("[SummaryRenderer] fetch recent-files failed:",e)})},[e]),(0,n.useEffect)(()=>()=>{j.current?.abort()},[]),(0,s.jsxs)("div",{className:"max-w-[720px] mx-auto py-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-6 flex-wrap",children:[(0,s.jsx)("span",{className:"font-display text-[11px] text-muted-foreground",children:t.length>0?`${t.length} recently modified files`:"Loading recent files…"}),(0,s.jsxs)("button",{onClick:k,disabled:h||0===t.length,className:`font-display summary-gen-btn ${h?"summary-gen-btn--busy":""}`,children:[h?(0,s.jsx)(a.A,{size:12,className:"animate-spin"}):(0,s.jsx)(i.A,{size:12}),h?"Generating…":v?"Regenerate":"Generate briefing"]})]}),t.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-6",children:t.map(e=>(0,s.jsxs)("a",{href:`/view/${(0,d.O0)(e.path)}`,className:"font-display summary-source-chip",title:e.path,children:[(0,s.jsx)(o.A,{size:10}),m(e.path),(0,s.jsxs)("span",{className:"opacity-50",children:[(0,s.jsx)(l.A,{size:9,className:"inline ml-0.5"})," ",u(e.mtime)]})]},e.path))}),g&&(0,s.jsx)("div",{className:"font-display px-3.5 py-2.5 rounded-lg bg-[var(--error)]/10 border border-[var(--error)]/30 text-[var(--error)] text-xs mb-4",children:g}),x?(0,s.jsxs)("div",{className:"bg-card border border-border rounded-[10px] px-5 py-[18px] relative",children:[h&&(0,s.jsx)("div",{className:"absolute top-3 right-3.5 w-1.5 h-1.5 rounded-full bg-[var(--amber)] animate-pulse"}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:w}})]}):h||v||!(t.length>0)?null:(0,s.jsxs)("div",{className:"border border-dashed border-border rounded-[10px] px-6 py-10 text-center text-muted-foreground",children:[(0,s.jsx)(i.A,{size:28,className:"mx-auto mb-2.5 opacity-30 text-[var(--amber)]"}),(0,s.jsxs)("p",{className:"font-display text-xs",children:["Click ",(0,s.jsx)("strong",{className:"text-foreground",children:"Generate briefing"})," to summarize recent changes with AI."]})]}),(0,s.jsx)("style",{children:`
|
|
116
|
+
.summary-gen-btn {
|
|
117
|
+
display: flex; align-items: center; gap: 6px;
|
|
118
|
+
padding: 5px 14px; border-radius: 7px; font-size: 12px;
|
|
119
|
+
cursor: pointer; border: none;
|
|
120
|
+
background: var(--amber); color: var(--amber-foreground);
|
|
121
|
+
transition: opacity .15s;
|
|
122
|
+
}
|
|
123
|
+
.summary-gen-btn:disabled { cursor: not-allowed; opacity: 0.5; }
|
|
124
|
+
.summary-gen-btn--busy { background: var(--muted); color: var(--muted-foreground); }
|
|
125
|
+
.summary-source-chip {
|
|
126
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
127
|
+
padding: 3px 10px; border-radius: 999px; font-size: 0.7rem;
|
|
128
|
+
background: var(--muted); color: var(--muted-foreground);
|
|
129
|
+
text-decoration: none; border: 1px solid var(--border);
|
|
130
|
+
transition: color .15s;
|
|
131
|
+
}
|
|
132
|
+
.summary-source-chip:hover { color: var(--foreground); }
|
|
133
|
+
`})]})}},58084:(e,t,r)=>{"use strict";r.d(t,{NT:()=>a,uC:()=>i});var s=r(12115),n=r(22356);function a(e,t,r={preparing:"Preparing search...",fallbackWarmHint:"Search will prepare on first query."}){return t.trim()?null:"warming"===e?r.preparing:"fallback"===e?r.fallbackWarmHint:null}function i(e){let[t,r]=(0,s.useState)("idle"),a=(0,s.useRef)(!1),i=(0,s.useRef)(!0);return(0,s.useEffect)(()=>{(function({active:e,hasAttemptedPrewarm:t,warmState:r}){return e&&!t&&"idle"===r})({active:e,hasAttemptedPrewarm:a.current,warmState:t})&&(a.current=!0,r("warming"),(0,n.n)("/api/search/prewarm").then(()=>{i.current&&r("ready")}).catch(()=>{i.current&&r("fallback")}))},[e,t]),(0,s.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,s.useEffect)(()=>{let e=()=>{a.current=!1,r("idle")};return window.addEventListener("mindos:files-changed",e),()=>window.removeEventListener("mindos:files-changed",e)},[]),(0,s.useEffect)(()=>{e||"fallback"!==t||(a.current=!1,r("idle"))},[e,t]),t}},66709:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var s=r(95155),n=r(12115),a=r(92451),i=r(33210),o=r(6296),l=r(13545),d=r(12651),c=r(35581);function u({open:e,onClose:t,onDiscover:r,discovering:u,error:m}){let{t:x}=(0,c.Y)(),p=x.panels.agents,[h,f]=(0,n.useState)(""),[g,b]=(0,n.useState)(null);if(!e)return null;let v=async()=>{if(!h.trim()||u)return;b(null);let e=await r(h.trim());e&&b(e)},y=()=>{f(""),b(null),t()};return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center overlay-backdrop",onClick:y,children:(0,s.jsxs)("div",{className:"bg-popover border border-border rounded-xl shadow-lg w-full max-w-md mx-4 p-5",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":p.a2aDiscover,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[(0,s.jsx)(a.A,{size:15,className:"text-muted-foreground"}),p.a2aDiscover]}),(0,s.jsx)("button",{type:"button",onClick:y,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,s.jsx)(i.A,{size:14})})]}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground mb-3",children:p.a2aDiscoverHint}),(0,s.jsxs)("div",{className:"flex gap-2 mb-4",children:[(0,s.jsx)("input",{type:"url",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(),"Escape"===e.key&&t()},placeholder:p.a2aDiscoverPlaceholder,disabled:u,className:"flex-1 px-3 py-2 text-xs rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",autoFocus:!0}),(0,s.jsxs)("button",{type:"button",onClick:v,disabled:u||!h.trim(),className:"px-3 py-2 text-xs font-medium rounded-lg bg-foreground text-background hover:bg-foreground/90 disabled:opacity-50 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring flex items-center gap-1.5 shrink-0",children:[u&&(0,s.jsx)(o.A,{size:12,className:"animate-spin"}),u?p.a2aDiscovering:p.a2aDiscover]})]}),m&&!g&&(0,s.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/5 px-3 py-2.5 mb-3",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(l.A,{size:14,className:"text-error mt-0.5 shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium text-error",children:p.a2aDiscoverFailed}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:p.a2aDiscoverFailedHint})]})]})}),g&&(0,s.jsx)("div",{className:"rounded-lg border border-success/30 bg-success/5 px-3 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(d.A,{size:14,className:"text-success mt-0.5 shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-success mb-1.5",children:p.a2aDiscoverSuccess}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-foreground truncate",title:g.card.name,children:[g.card.name,(0,s.jsxs)("span",{className:"text-2xs text-muted-foreground ml-1.5",children:["v",g.card.version]})]}),(0,s.jsx)("p",{className:"text-2xs text-muted-foreground truncate",title:g.card.description,children:g.card.description}),g.card.skills.length>0&&(0,s.jsxs)("div",{className:"mt-1.5",children:[(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground mb-1",children:[p.a2aSkills,":"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:g.card.skills.map(e=>(0,s.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-muted/80 text-muted-foreground border border-border/50",title:e.description,children:e.name},e.id))})]}),(0,s.jsxs)("p",{className:"text-2xs text-muted-foreground mt-1 truncate",title:g.endpoint,children:[p.a2aEndpoint,": ",g.endpoint]})]})]})]})})]})})}},66872:()=>{},77148:(e,t,r)=>{"use strict";r.d(t,{Un:()=>a});var s=r(12115);let n="mindos-renderer-state-change";function a(e,t,r){let a=`mindos-renderer:${e}:${t}`,i=(0,s.useRef)({key:a,raw:null,parsed:r});return i.current.key!==a&&(i.current={key:a,raw:null,parsed:r}),[(0,s.useSyncExternalStore)(e=>{let t=()=>e();return window.addEventListener("storage",t),window.addEventListener(n,t),()=>{window.removeEventListener("storage",t),window.removeEventListener(n,t)}},()=>{try{let e=localStorage.getItem(a);if(e===i.current.raw)return i.current.parsed;if(null===e)return i.current={key:a,raw:null,parsed:r},r;let t=JSON.parse(e);return i.current={key:a,raw:e,parsed:t},t}catch{return r}},()=>r),(0,s.useCallback)(e=>{try{let t=(()=>{try{let e=localStorage.getItem(a);return null!==e?JSON.parse(e):r}catch{return r}})(),s="function"==typeof e?e(t):e,n=JSON.stringify(s);localStorage.setItem(a,n),i.current={key:a,raw:n,parsed:s}}catch{}window.dispatchEvent(new Event(n))},[a,r])]}},78520:(e,t,r)=>{"use strict";r.d(t,{D4:()=>i,FB:()=>n,W8:()=>o,g4:()=>l,jQ:()=>c});let s="mindos:organize-history";function n(){try{let e=localStorage.getItem(s);if(!e)return[];return JSON.parse(e)}catch{return[]}}function a(e){try{localStorage.setItem(s,JSON.stringify(e.slice(0,50)))}catch{}}function i(e){let t=n();t.unshift(e);let r=t.slice(0,50);return a(r),r}function o(e,t){let r=n(),s=r.findIndex(t=>t.id===e);return s>=0&&(r[s]={...r[s],...t},a(r)),r}function l(){try{localStorage.removeItem(s)}catch{}}let d=0;function c(){return`org-${Date.now()}-${++d}`}},82125:(e,t,r)=>{"use strict";r.d(t,{A:()=>n,C:()=>s});let s=new Set(["INSTRUCTION.md","README.md","CONFIG.json","CHANGELOG.md"]),n=new Set(["TODO.md"])},86343:(e,t,r)=>{"use strict";r.d(t,{default:()=>a});var s=r(95155),n=r(12115);class a extends n.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[50vh] px-4",children:(0,s.jsxs)("div",{className:"text-center max-w-md",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Something went wrong"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred."}),(0,s.jsx)("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:"px-4 py-2 text-sm rounded-lg border border-border hover:bg-muted transition-colors",children:"Try again"})]})}):this.props.children}}},87986:(e,t,r)=>{"use strict";r.r(t),r.d(t,{VideoRenderer:()=>a});var s=r(95155),n=r(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,r=e.split("/").pop()??"video",a=r.split(".").pop()?.toLowerCase()??"",[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let h=(0,n.useCallback)(()=>{let e=p.current;e&&x({w:e.videoWidth,h:e.videoHeight})},[]),f=(0,n.useCallback)(()=>{o(!1),d(e=>e+1)},[]);return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[m&&(0,s.jsxs)("span",{children:[m.w," x ",m.h]}),null!==c&&(0,s.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`}),(0,s.jsx)("span",{className:"uppercase opacity-60",children:a})]}),(0,s.jsx)("div",{className:"flex-1 min-h-[50vh] flex items-center justify-center bg-black rounded-b-lg overflow-hidden",children:i?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-neutral-400",children:"Failed to load video"}),(0,s.jsx)("button",{onClick:f,className:"text-xs px-3 py-1.5 rounded-md bg-neutral-800 hover:bg-neutral-700 text-neutral-200 transition-colors",children:"Retry"})]}):(0,s.jsx)("video",{ref:p,controls:!0,preload:"metadata",className:"max-w-full max-h-[70vh]",onLoadedMetadata:h,onError:()=>o(!0),children:(0,s.jsx)("source",{src:t})},l)})]})}},88946:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BacklinksRenderer:()=>m});var s=r(95155),n=r(12115),a=r(73321),i=r(48368),o=r(22164),l=r(91337),d=r(22356);function c(e){return e.split("/").pop()?.replace(/\.md$/,"")??e}function u({text:e}){let t=e.split(/(\[\[[^\]]+\]\]|\[[^\]]+\]\([^)]+\))/g);return(0,s.jsx)("span",{children:t.map((e,t)=>/^\[\[/.test(e)||/^\[/.test(e)?(0,s.jsx)("span",{style:{color:"var(--amber)",fontWeight:500},children:e},t):(0,s.jsx)("span",{children:e},t))})}function m({filePath:e}){let t=(0,a.useRouter)(),[r,m]=(0,n.useState)(null),[x,p]=(0,n.useState)(!0);if((0,n.useEffect)(()=>{p(!0),(0,d.n)(`/api/backlinks?path=${encodeURIComponent(e)}`).then(e=>{m(e),p(!1)}).catch(()=>p(!1))},[e]),x)return(0,s.jsx)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",fontSize:12,color:"var(--muted-foreground)"},children:"Scanning backlinks…"});let h=r??[];return(0,s.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,s.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,s.jsx)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:0===h.length?"No backlinks found":`${h.length} file${1===h.length?"":"s"} link here`})}),0===h.length?(0,s.jsxs)("div",{style:{border:"1px dashed var(--border)",borderRadius:10,padding:"2.5rem 1.5rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:[(0,s.jsx)(i.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,s.jsxs)("p",{className:"font-display",style:{fontSize:12},children:["No other files link to ",(0,s.jsx)("strong",{style:{color:"var(--foreground)"},children:c(e)})," yet."]})]}):(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:h.map(({filePath:e,snippets:r})=>{let n,a=c(e),d=(n=e.split("/")).length>1?n.slice(0,-1).join("/"):"";return(0,s.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",cursor:"pointer",transition:"border-color .15s"},onClick:()=>t.push("/view/"+(0,l.O0)(e)),onMouseEnter:e=>e.currentTarget.style.borderColor="rgba(200,135,58,0.4)",onMouseLeave:e=>e.currentTarget.style.borderColor="var(--border)",children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:r.length>0?"1px solid var(--border)":"none",background:"var(--muted)"},children:[(0,s.jsx)(i.A,{size:13,style:{color:"var(--muted-foreground)",flexShrink:0}}),(0,s.jsx)("span",{style:{fontWeight:600,fontSize:"0.85rem",color:"var(--foreground)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),d&&(0,s.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6,flexShrink:0},children:d}),(0,s.jsx)(o.A,{size:11,style:{color:"var(--muted-foreground)",opacity:.5,flexShrink:0}})]}),r.map((e,t)=>(0,s.jsx)("div",{style:{padding:"8px 14px",borderBottom:t<r.length-1?"1px solid var(--border)":"none",background:"var(--background)"},children:e.split("\n").map((e,t)=>(0,s.jsx)("div",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--muted-foreground)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(0,s.jsx)(u,{text:e})},t))},t))]},e)})})]})}},91459:(e,t,r)=>{"use strict";r.d(t,{TooltipProvider:()=>m,ZI:()=>h,k$:()=>p,m_:()=>x});var s=r(95155),n=r(13714),a=r(62460),i=r(73260),o=r(63878),l=r(36525),d=r(34900),c=r(59964),u=r(91337);function m({delay:e=0,...t}){return(0,s.jsx)(n.B,{"data-slot":"tooltip-provider",delay:e,...t})}function x({...e}){return(0,s.jsx)(a.s,{"data-slot":"tooltip",...e})}function p({...e}){return(0,s.jsx)(i.k,{"data-slot":"tooltip-trigger",...e})}function h({className:e,side:t="top",sideOffset:r=4,align:n="center",alignOffset:a=0,children:i,...m}){return(0,s.jsx)(o.K,{children:(0,s.jsx)(l.o,{align:n,alignOffset:a,side:t,sideOffset:r,className:"isolate z-50",children:(0,s.jsxs)(d.o,{"data-slot":"tooltip-content",className:(0,u.cn)("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...m,children:[i,(0,s.jsx)(c.P,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}},92218:(e,t,r)=>{"use strict";r.d(t,{f:()=>n});var s=r(9339);let n=(0,s.createServerReference)("608622e1355c9707194ecb539523482a99a63fbd98",s.callServer,void 0,s.findSourceMapURL,"renameFileAction")},92306:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CsvRenderer:()=>z});var s=r(95155),n=r(12115),a=r(18837),i=r(37595),o=r(8434),l=r(1164),d=r(59386),c=r.n(d);function u(e,t){return c().unparse([e,...t])}let m=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"var(--tool-read)"},{bg:"rgba(200,160,216,0.12)",text:"var(--tool-search)"},{bg:"rgba(200,96,96,0.12)",text:"var(--error)"},{bg:"rgba(150,150,150,0.12)",text:"var(--muted-foreground)"}];function x(e){let t=0;for(let r=0;r<e.length;r++)t=31*t+e.charCodeAt(r)&65535;return m[t%m.length]}var p=r(77148),h=r(9921),f=r(66088),g=r(68459),b=r(51914);function v({value:e,onCommit:t}){let[r,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(e),l=(0,n.useRef)(null);function d(){a(!1),i!==e?t(i):o(e)}return((0,n.useEffect)(()=>{o(e)},[e]),(0,n.useEffect)(()=>{r&&l.current?.select()},[r]),r)?(0,s.jsx)("input",{ref:l,value:i,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:t=>{"Enter"===t.key&&d(),"Escape"===t.key&&(o(e),a(!1))},className:"w-full bg-transparent outline-none text-sm",onClick:e=>e.stopPropagation(),style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)",minWidth:60}}):(0,s.jsx)("div",{className:"truncate text-sm cursor-text",style:{color:"var(--foreground)",minWidth:60},onClick:()=>a(!0),title:e,children:e||(0,s.jsx)("span",{style:{color:"var(--muted-foreground)",opacity:.3},children:"—"})})}function y({headers:e,visibleIndices:t,onAdd:r,onCancel:a}){let[i,o]=(0,n.useState)(()=>Array(e.length).fill(""));return(0,s.jsxs)("tr",{style:{background:"color-mix(in srgb, var(--amber) 6%, transparent)",borderTop:"1px solid var(--amber)"},children:[t.map((t,n)=>(0,s.jsx)("td",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)("input",{autoFocus:0===n,value:i[t],onChange:e=>{var r;return r=e.target.value,void o(e=>{let s=[...e];return s[t]=r,s})},onKeyDown:e=>{"Enter"===e.key&&r(i),"Escape"===e.key&&a()},placeholder:e[t],className:"w-full bg-transparent outline-none text-sm placeholder:opacity-30",style:{color:"var(--foreground)",borderBottom:"1px solid var(--border)"}})},t)),(0,s.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"}})]})}function j({headers:e,rows:t,cfg:r,saveAction:a}){let[i,o]=(0,n.useState)(t),[l,d]=(0,n.useState)(!1);(0,n.useEffect)(()=>{o(t)},[t]);let c=(0,n.useMemo)(()=>e.map((e,t)=>t).filter(t=>!r.hiddenFields.includes(e[t])),[e,r.hiddenFields]),m=e.indexOf(r.sortField),x=(0,n.useMemo)(()=>{let e=[...i];return m>=0&&e.sort((e,t)=>{let s=e[m]??"",n=t[m]??"",a=parseFloat(s),i=parseFloat(n),o=isNaN(a)||isNaN(i)?s.localeCompare(n):a-i;return"asc"===r.sortDir?o:-o}),e},[i,m,r.sortDir]),p=e.indexOf(r.groupField),j=(0,n.useMemo)(()=>{if(p<0)return[{key:null,rows:x.map(e=>({row:e,orig:e}))}];let e=new Map;for(let t of x){let r=t[p]||"(empty)";e.has(r)||e.set(r,[]),e.get(r).push(t)}return[...e.entries()].map(([e,t])=>({key:e,rows:t.map(e=>({row:e,orig:e}))}))},[x,p]);async function w(t,r,s){let n=i.map(e=>e===t?e.map((e,t)=>t===r?s:e):e);o(n),await a(u(e,n))}async function k(t){let r=i.filter(e=>e!==t);o(r),await a(u(e,r))}async function N(t){let r=[...i,t];o(r),d(!1),await a(u(e,r))}let S={borderBottom:"1px solid var(--border)",fontSize:"0.72rem",letterSpacing:"0.05em",textTransform:"uppercase",color:"var(--muted-foreground)",fontWeight:600},C=0;return(0,s.jsxs)("div",{className:"rounded-xl overflow-hidden border",style:{borderColor:"var(--border)"},children:[(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"min-w-full text-sm border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{style:{background:"var(--muted)"},children:[c.map(t=>(0,s.jsx)("th",{className:"px-4 py-2.5 text-left whitespace-nowrap",style:S,children:(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[e[t],r.sortField===e[t]&&("asc"===r.sortDir?(0,s.jsx)(h.A,{size:10,style:{color:"var(--amber)"}}):(0,s.jsx)(f.A,{size:10,style:{color:"var(--amber)"}}))]})},t)),(0,s.jsx)("th",{className:"w-8",style:{...S,background:"var(--muted)"}})]})}),(0,s.jsxs)("tbody",{children:[j.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[null!==e.key&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:c.length+1,className:"px-4 py-1.5",style:{background:"var(--accent)",borderBottom:"1px solid var(--border)",borderTop:"1px solid var(--border)"},children:(0,s.jsxs)("span",{className:"text-xs font-semibold font-display",style:{color:"var(--muted-foreground)"},children:[e.key," \xb7 ",e.rows.length]})})},`grp-${e.key}`),e.rows.map(({row:e,orig:t})=>{let r=C++;return(0,s.jsxs)("tr",{className:"group transition-colors",style:{background:r%2==0?"var(--background)":"var(--card)"},onMouseEnter:e=>e.currentTarget.style.background="var(--muted)",onMouseLeave:e=>e.currentTarget.style.background=r%2==0?"var(--background)":"var(--card)",children:[c.map(r=>(0,s.jsx)("td",{className:"px-4 py-2 max-w-xs",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)(v,{value:e[r]??"",onCommit:e=>w(t,r,e)})},r)),(0,s.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,s.jsx)("button",{onClick:()=>k(t),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/10",style:{color:"var(--muted-foreground)"},children:(0,s.jsx)(g.A,{size:12})})})]},r)})]},e.key??`section-${t}`)),l&&(0,s.jsx)(y,{headers:e,visibleIndices:c,onAdd:N,onCancel:()=>d(!1)})]})]})}),(0,s.jsxs)("div",{className:"px-4 py-2 flex items-center justify-between",style:{background:"var(--muted)",borderTop:"1px solid var(--border)"},children:[(0,s.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)"},children:[i.length," rows \xb7 ",e.length," cols"]}),l?(0,s.jsx)("button",{onClick:()=>d(!1),className:"text-xs px-2.5 py-1 rounded-md",style:{color:"var(--muted-foreground)"},children:"Cancel"}):(0,s.jsxs)("button",{onClick:()=>d(!0),className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-md",style:{color:"var(--amber)",background:"var(--amber-dim)"},children:[(0,s.jsx)(b.A,{size:12})," Add row"]})]})]})}function w({headers:e,rows:t,cfg:r}){let n=e.indexOf(r.titleField),a=e.indexOf(r.descField),i=e.indexOf(r.tagField);return(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map((t,r)=>{let o=n>=0?t[n]:t[0]??"",l=a>=0?t[a]:"",d=i>=0?t[i]:"",c=d?x(d):null;return(0,s.jsxs)("div",{className:"rounded-xl border p-4 flex flex-col gap-2 hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[d&&c&&(0,s.jsx)("span",{className:"self-start text-xs px-2 py-0.5 rounded-full font-medium",style:{background:c.bg,color:c.text},children:d}),(0,s.jsx)("p",{className:"text-sm font-semibold leading-snug",style:{color:"var(--foreground)"},children:o}),l&&(0,s.jsx)("p",{className:"text-xs leading-relaxed line-clamp-3",style:{color:"var(--muted-foreground)"},children:l}),(0,s.jsx)("div",{className:"mt-1 flex flex-col gap-0.5",children:e.map((e,r)=>{if(r===n||r===a||r===i)return null;let o=t[r];return o?(0,s.jsxs)("div",{className:"flex items-baseline gap-1.5 text-xs",children:[(0,s.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",opacity:.6,fontSize:"0.68rem"},children:e}),(0,s.jsx)("span",{className:"truncate",style:{color:"var(--muted-foreground)"},children:o})]},r):null})})]},r)})})}function k({headers:e,rows:t,cfg:r,saveAction:a}){let[i,o]=(0,n.useState)(t),[l,d]=(0,n.useState)(null),[c,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{o(t)},[t]);let f=e.indexOf(r.groupField),g=e.indexOf(r.titleField),v=e.indexOf(r.descField),{groups:y,groupKeys:j}=(0,n.useMemo)(()=>{let e=new Map;return i.forEach((t,r)=>{let s=(f>=0?t[f]:"")||"(empty)";e.has(s)||e.set(s,[]),e.get(s).push({row:t,origIdx:r})}),{groups:e,groupKeys:[...e.keys()]}},[i,f]);async function w(t,r){let s=i.map((e,s)=>{if(s!==t)return e;let n=[...e];return f>=0&&(n[f]=r),n});o(s),await a(u(e,s))}function k({group:t}){let r=y.get(t)??[],n=x(t),a=l===t;return(0,s.jsxs)("div",{className:"flex-shrink-0 w-64 flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,s.jsx)("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:n.text}}),(0,s.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider truncate font-display",style:{color:n.text},children:t}),(0,s.jsx)("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--muted-foreground)",opacity:.5},children:r.length})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl p-1.5 min-h-[80px] transition-colors",style:{background:a?"var(--amber-dim)":"var(--muted)",border:`1px solid ${a?"var(--amber)":"transparent"}`},onDragOver:e=>{e.preventDefault(),d(t)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||d(null)},onDrop:e=>{d(null);let r=parseInt(e.dataTransfer.getData("origIdx"));isNaN(r)||w(r,t)},children:[r.map(({row:t,origIdx:r})=>{let n=g>=0?t[g]:t[0]??"",a=v>=0?t[v]:"";return(0,s.jsxs)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.setData("origIdx",String(r)),d(null)},onDragEnd:()=>d(null),className:"rounded-lg border p-3 flex flex-col gap-1.5 cursor-grab active:cursor-grabbing hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,s.jsx)("p",{className:"text-sm font-medium leading-snug",style:{color:"var(--foreground)"},children:n}),a&&(0,s.jsx)("p",{className:"text-xs leading-relaxed line-clamp-2",style:{color:"var(--muted-foreground)"},children:a}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1 mt-0.5",children:e.map((e,r)=>{if(r===f||r===g||r===v)return null;let n=t[r];return n?(0,s.jsxs)("span",{className:"text-2xs px-1.5 py-0.5 rounded font-display",style:{background:"var(--muted)",color:"var(--muted-foreground)"},children:[e,": ",n]},r):null})})]},r)}),0===r.length&&(0,s.jsx)("div",{className:"flex items-center justify-center h-12",children:(0,s.jsx)("span",{className:"text-xs",style:{color:"var(--muted-foreground)",opacity:.4},children:"Drop here"})})]})]})}return(0,s.jsxs)("div",{className:"flex gap-3 overflow-x-auto pb-3 items-start",children:[j.map(e=>(0,s.jsx)(k,{group:e},e)),(0,s.jsx)("div",{className:"flex-shrink-0 w-64",children:p?(0,s.jsxs)("div",{className:"rounded-xl border p-3 flex flex-col gap-2",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,s.jsx)("input",{autoFocus:!0,value:c,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&c.trim()&&(m(""),h(!1)),"Escape"===e.key&&(m(""),h(!1))},placeholder:"Column name…",className:"text-xs bg-transparent outline-none w-full font-display",style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)"}}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:"Create"}),(0,s.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{color:"var(--muted-foreground)"},children:"Cancel"})]})]}):(0,s.jsxs)("button",{onClick:()=>h(!0),className:"flex items-center gap-1.5 text-xs px-3 py-2 rounded-xl border border-dashed w-full transition-colors hover:bg-muted font-display",style:{borderColor:"var(--border)",color:"var(--muted-foreground)"},children:[(0,s.jsx)(b.A,{size:12})," Add column"]})})]})}var N=r(33210),S=r(27996);function C({headers:e,cfg:t,view:r,onClose:n,onChange:a}){let i={color:"var(--muted-foreground)",fontSize:"0.72rem"};function o({label:t,value:r,onChange:n}){return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"font-display",style:i,children:t}),(0,s.jsx)(S.A,{value:r,onChange:n,size:"sm",options:[{value:"",label:"— none —"},...e.map(e=>({value:e,label:e}))]})]})}return(0,s.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-72 rounded-xl border shadow-xl p-4 flex flex-col gap-3",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:[r," settings"]}),(0,s.jsx)("button",{onClick:n,style:{color:"var(--muted-foreground)"},children:(0,s.jsx)(N.A,{size:13})})]}),"table"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Sort"}),(0,s.jsx)(o,{label:"Sort by",value:t.table.sortField,onChange:e=>a({...t,table:{...t.table,sortField:e}})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{style:i,children:"Direction"}),(0,s.jsx)("div",{className:"flex rounded overflow-hidden border",style:{borderColor:"var(--border)"},children:["asc","desc"].map(e=>(0,s.jsx)("button",{onClick:()=>a({...t,table:{...t.table,sortDir:e}}),className:"px-3 py-1 text-xs transition-colors font-display",style:{fontSize:"0.72rem",background:t.table.sortDir===e?"var(--amber)":"var(--background)",color:t.table.sortDir===e?"var(--amber-foreground)":"var(--muted-foreground)"},children:e},e))})]}),(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Group"}),(0,s.jsx)(o,{label:"Group by",value:t.table.groupField,onChange:e=>a({...t,table:{...t.table,groupField:e}})}),(0,s.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:i,children:"Columns"}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:e.map(e=>{let r=t.table.hiddenFields.includes(e);return(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{style:i,children:e}),(0,s.jsx)("button",{onClick:()=>{let s=r?t.table.hiddenFields.filter(t=>t!==e):[...t.table.hiddenFields,e];a({...t,table:{...t.table,hiddenFields:s}})},className:"text-xs px-2 py-0.5 rounded transition-colors font-display",style:{background:r?"var(--muted)":"var(--amber-dim)",color:r?"var(--muted-foreground)":"var(--amber)"},children:r?"Hidden":"Visible"})]},e)})})]}),"gallery"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{label:"Title",value:t.gallery.titleField,onChange:e=>a({...t,gallery:{...t.gallery,titleField:e}})}),(0,s.jsx)(o,{label:"Description",value:t.gallery.descField,onChange:e=>a({...t,gallery:{...t.gallery,descField:e}})}),(0,s.jsx)(o,{label:"Tag / Badge",value:t.gallery.tagField,onChange:e=>a({...t,gallery:{...t.gallery,tagField:e}})})]}),"board"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{label:"Group by",value:t.board.groupField,onChange:e=>a({...t,board:{...t.board,groupField:e}})}),(0,s.jsx)(o,{label:"Card title",value:t.board.titleField,onChange:e=>a({...t,board:{...t.board,titleField:e}})}),(0,s.jsx)(o,{label:"Card desc",value:t.board.descField,onChange:e=>a({...t,board:{...t.board,descField:e}})})]})]})}let A=[{id:"table",icon:(0,s.jsx)(a.A,{size:13}),label:"Table"},{id:"gallery",icon:(0,s.jsx)(i.A,{size:13}),label:"Gallery"},{id:"board",icon:(0,s.jsx)(o.A,{size:13}),label:"Board"}];function z({filePath:e,content:t,saveAction:r}){let{headers:a,rows:i}=(0,n.useMemo)(()=>{let e;return{headers:(e=c().parse(t,{skipEmptyLines:!0}).data)[0]??[],rows:e.slice(1)}},[t]),o=(0,n.useMemo)(()=>({activeView:"table",table:{sortField:"",sortDir:"asc",groupField:"",hiddenFields:[]},gallery:{titleField:a[0]??"",descField:a[1]??"",tagField:a[2]??""},board:{groupField:a[a.length-1]??"",titleField:a[0]??"",descField:a[1]??""}}),[a]),[d,u]=(0,p.Un)("csv",e,o),[m,x]=(0,n.useState)(!1),h=(0,n.useCallback)(e=>{u(e)},[u]),f=d.activeView;return(0,s.jsxs)("div",{className:"w-full py-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4 relative",children:[(0,s.jsx)("div",{className:"flex items-center gap-0.5 p-1 rounded-lg",style:{background:"var(--muted)"},children:A.map(e=>(0,s.jsxs)("button",{onClick:()=>h({...d,activeView:e.id}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors font-display",style:{background:f===e.id?"var(--card)":"transparent",color:f===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:f===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none"},children:[e.icon,e.label]},e.id))}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)",opacity:.5},children:[i.length," rows"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>x(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors",style:{background:m?"var(--accent)":"var(--muted)",color:m?"var(--foreground)":"var(--muted-foreground)"},title:"View settings",children:(0,s.jsx)(l.A,{size:13})}),m&&(0,s.jsx)(C,{headers:a,cfg:d,view:f,onClose:()=>x(!1),onChange:h})]})]}),"table"===f&&(0,s.jsx)(j,{headers:a,rows:i,cfg:d.table,saveAction:r}),"gallery"===f&&(0,s.jsx)(w,{headers:a,rows:i,cfg:d.gallery}),"board"===f&&(0,s.jsx)(k,{headers:a,rows:i,cfg:d.board,saveAction:r})]})}},92524:(e,t,r)=>{"use strict";r.d(t,{default:()=>n});var s=r(12115);function n(){return(0,s.useEffect)(()=>{!("u">typeof navigator&&/electron/i.test(navigator.userAgent))&&"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(e=>{console.warn("[SW] Registration failed:",e)})},[]),null}},92950:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GraphRenderer:()=>c});var s=r(95155),n=r(12115),a=r(73321),i=r(81750),o=r(61278);r(53255);var l=r(22356);let d=(0,n.memo)(function({data:e}){let t=(0,a.useRouter)(),{label:r,id:l,isCurrent:d,isOrphan:c,size:u=1}=e,m=(0,n.useCallback)(()=>{let e=l.split("/").map(encodeURIComponent).join("/");t.push("/view/"+e)},[l,t]),x=.8+Math.min(.1*u,1.2);return(0,s.jsxs)("div",{onClick:m,title:l,className:"group font-display",style:{fontSize:10*x,padding:`${4*x}px ${12*x}px`,borderRadius:999,cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",opacity:c?.4:1,background:d?"var(--amber)":"var(--card)",color:d?"var(--amber-foreground)":"var(--foreground)",border:`1.5px solid ${d?"var(--amber)":"var(--border)"}`,boxShadow:d?"0 0 20px var(--amber-dim), 0 0 0 2px var(--amber-dim)":"0 2px 4px rgba(0,0,0,0.1)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:d?10:1},onMouseEnter:e=>{d||(e.currentTarget.style.borderColor="var(--amber)",e.currentTarget.style.background="var(--accent)")},onMouseLeave:e=>{d||(e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--card)")},children:[(0,s.jsx)(i.h7,{type:"target",position:o.yX.Top,style:{opacity:0}}),r,(0,s.jsx)(i.h7,{type:"source",position:o.yX.Bottom,style:{opacity:0}})]})});function c({filePath:e}){let[t,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(!0),[c,u]=(0,n.useState)("local"),[m,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>{x(!0)},[]),(0,n.useEffect)(()=>{(0,l.n)("/api/graph").then(e=>{r(e),o(!1)}).catch(()=>o(!1))},[]);let p=(0,n.useMemo)(()=>{if(!t)return new Map;let e=new Map;for(let r of t.edges)e.set(r.source,(e.get(r.source)||0)+1),e.set(r.target,(e.get(r.target)||0)+1);return e},[t]),h=(0,n.useMemo)(()=>{if(!t)return null;let e=new Map;for(let r of t.edges)e.has(r.source)||e.set(r.source,new Set),e.has(r.target)||e.set(r.target,new Set),e.get(r.source).add(r.target),e.get(r.target).add(r.source);return e},[t]),{filteredNodes:f,filteredEdges:g}=(0,n.useMemo)(()=>{let r,s;if(!t)return{filteredNodes:[],filteredEdges:[]};if("global"===c)r=t.nodes,s=t.edges;else{let n=new Set,a=[{id:e,depth:0}];for(n.add(e);a.length>0;){let{id:e,depth:t}=a.shift();if(!(t>=2))for(let r of h?.get(e)??new Set)n.has(r)||(n.add(r),a.push({id:r,depth:t+1}))}let i=new Set((r=t.nodes.filter(e=>n.has(e.id))).map(e=>e.id));s=t.edges.filter(e=>i.has(e.source)&&i.has(e.target))}return{filteredNodes:r,filteredEdges:s}},[t,c,e,h]),b=(0,n.useMemo)(()=>{let e=new Set;for(let t of g)e.add(t.source),e.add(t.target);return e},[g]),{rfNodes:v,rfEdges:y}=(0,n.useMemo)(()=>{if(0===f.length)return{rfNodes:[],rfEdges:[]};let t=function(e,t,r){let s=e.length;if(0===s)return{};let n=(void 0)??(s>100?80:150),a=.6*Math.sqrt(108e4/Math.max(s,1)),i={};e.forEach((e,t)=>{let r=2*Math.PI*t/s,n=360*Math.random();i[e]={x:600+Math.cos(r)*n,y:450+Math.sin(r)*n}});let o={};for(let r=0;r<n;r++){let l=120*(1-r/n);for(let t of e)o[t]={x:0,y:0};for(let t=0;t<s;t++)for(let r=t+1;r<s;r++){let s=e[t],n=e[r],l=i[s].x-i[n].x,d=i[s].y-i[n].y,c=Math.sqrt(l*l+d*d||.01),u=a*a/c;o[s].x+=l/c*u,o[s].y+=d/c*u,o[n].x-=l/c*u,o[n].y-=d/c*u}for(let e of t){let t=e.source,r=e.target;if(!i[t]||!i[r])continue;let s=i[t].x-i[r].x,n=i[t].y-i[r].y,l=Math.sqrt(s*s+n*n||.01),d=l*l/a;o[t].x-=s/l*d,o[t].y-=n/l*d,o[r].x+=s/l*d,o[r].y+=n/l*d}for(let t of e){let e=i[t].x-600,r=i[t].y-450,s=Math.sqrt(e*e+r*r)||.01,n=.05*s;o[t].x-=e/s*n,o[t].y-=r/s*n}for(let t of e){let e=o[t],r=Math.sqrt(e.x*e.x+e.y*e.y)||.01;i[t].x+=e.x/r*Math.min(r,l),i[t].y+=e.y/r*Math.min(r,l),i[t].x=Math.max(0,Math.min(1200,i[t].x)),i[t].y=Math.max(0,Math.min(900,i[t].y))}}return i}(f.map(e=>e.id),g);return{rfNodes:f.map(r=>({id:r.id,type:"wiki",position:t[r.id]??{x:0,y:0},data:{label:r.label,id:r.id,isCurrent:r.id===e,isOrphan:!b.has(r.id),size:p.get(r.id)||1}})),rfEdges:g.map((t,r)=>{let s=t.source===e||t.target===e;return{id:`e-${r}`,source:t.source,target:t.target,type:"default",markerEnd:{type:"arrowclosed",color:s?"var(--amber)":"var(--border)"},style:{stroke:s?"var(--amber)":"var(--border)",strokeWidth:s?1.5:1,opacity:s?.8:.4},animated:s}})}},[f,g,e,b,p]),j=(0,n.useMemo)(()=>({wiki:d}),[]);return!m||a?(0,s.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400,borderRadius:12,background:"var(--muted)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,s.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",fontSize:12},children:a?"Building graph…":"Loading…"})}):(0,s.jsxs)("div",{style:{width:"100%",position:"relative",zIndex:0},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10,flexWrap:"wrap"},children:[(0,s.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[f.length," nodes \xb7 ",g.length," edges"]}),(0,s.jsx)("div",{style:{display:"flex",gap:2,padding:3,borderRadius:8,background:"var(--muted)"},children:[{id:"local",label:"Local"},{id:"global",label:"Global"}].map(e=>(0,s.jsx)("button",{onClick:()=>u(e.id),className:"font-display",style:{padding:"3px 12px",borderRadius:5,fontSize:11,cursor:"pointer",border:"none",outline:"none",background:c===e.id?"var(--card)":"transparent",color:c===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:c===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.1s"},children:e.label},e.id))})]}),(0,s.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400},children:(0,s.jsxs)(i.Gc,{nodes:v,edges:y,nodeTypes:j,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},style:{background:"var(--background)",borderRadius:12,border:"1px solid var(--border)"},children:[(0,s.jsx)(i.VS,{color:"var(--border)",gap:24,size:1,variant:i._5.Dots}),(0,s.jsx)(i.H2,{showInteractive:!1}),(0,s.jsx)(i.of,{nodeColor:e=>e.data?.isCurrent?"var(--amber)":"var(--muted-foreground)"})]})})]})}},93042:(e,t,r)=>{"use strict";r.d(t,{default:()=>i});var s=r(12115),n=r(35581),a=r(28380);function i({ssrLocale:e}){let t=(0,s.useRef)(!1);return t.current||(t.current=!0,n.D.getState().locale!==e&&n.D.setState({locale:e,t:a.D[e]})),(0,s.useEffect)(()=>n.D.getState()._init(e),[e]),null}},93097:(e,t,r)=>{"use strict";r.d(t,{Y:()=>n});var s=r(9339);let n=(0,s.createServerReference)("40c97858a864e5fe5975642bac9706b473f1e01f7f",s.callServer,void 0,s.findSourceMapURL,"undoDeleteAction")},98959:(e,t,r)=>{"use strict";r.d(t,{default:()=>d});var s=r(95155),n=r(12115),a=r(33210),i=r(35581);let o="mindos_update_skip_desktop",l="mindos_update_skip_core";function d(){let{t:e}=(0,i.Y)(),t=e.settings.update.updateToast,[r,d]=(0,n.useState)("hidden"),[c,u]=(0,n.useState)({}),m=(0,n.useRef)(null),[x,p]=(0,n.useState)(!1),h=(0,n.useRef)(new Set),f=(0,n.useRef)({}),g=(0,n.useCallback)(()=>{h.current.forEach(clearTimeout),h.current.clear()},[]),b=(0,n.useCallback)((e,t)=>{let r=setTimeout(()=>{h.current.delete(r),d(e)},t);h.current.add(r)},[]);(0,n.useEffect)(()=>{let e,t=(e=window,e.mindos?.checkUpdate?e.mindos:null);m.current=t,p(!!t)},[]),(0,n.useEffect)(()=>{let e=m.current;if(!e)return;g();let t=[],r=(e,t,r)=>{let s=localStorage.getItem(r);s&&!function(e,t){let r=e.split(".").map(Number),s=t.split(".").map(Number);for(let e=0;e<Math.max(r.length,s.length);e++){let t=r[e]??0,n=s[e]??0;if(t>n)return!0;if(t<n)break}return!1}(t,s)||f.current[e]!==t&&(f.current[e]=t,u(r=>({...r,[e]:{type:e,version:t}})),b("visible",1e4))};return e.onUpdateAvailable&&t.push(e.onUpdateAvailable(e=>{e?.version&&r("desktop",e.version,o)})),e.onCoreUpdateAvailable&&t.push(e.onCoreUpdateAvailable(e=>{e?.latest&&!e.ready&&r("core",e.latest,l)})),()=>{t.forEach(e=>e()),g()}},[x,g,b]),(0,n.useEffect)(()=>()=>g(),[g]);let v=(0,n.useCallback)(()=>{g(),window.dispatchEvent(new CustomEvent("mindos:open-settings",{detail:{tab:"update"}})),d("dismissing"),b("hidden",200)},[g,b]),y=(0,n.useCallback)(()=>{g(),c.desktop&&localStorage.setItem(o,c.desktop.version),c.core&&localStorage.setItem(l,c.core.version),d("dismissing"),b("hidden",200)},[c,g,b]);if(!x||"hidden"===r)return null;let j=!!(c.desktop&&c.core),w=j?t.titleMultiple:c.desktop?t.titleSingle(t.desktopLabel,c.desktop.version):c.core?t.titleSingle(t.coreLabel,c.core.version):"",k=j?`${t.desktopLabel} v${c.desktop.version} \u00B7 ${t.coreLabel} v${c.core.version}`:"";return(0,s.jsx)("div",{role:"status","aria-live":"polite",className:`
|
|
143
134
|
fixed bottom-14 left-14 z-40 pointer-events-none
|
|
144
135
|
transition-all duration-200
|
|
145
136
|
${"visible"===r?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}
|
|
146
|
-
`,children:(0,s.jsxs)("div",{className:"pointer-events-auto flex flex-col gap-2.5 bg-card border border-border rounded-xl shadow-lg px-4 py-3 w-[290px]",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"mt-[5px] w-2 h-2 rounded-full bg-[var(--amber)] shrink-0"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground leading-snug",children:w}),k&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k})]}),(0,s.jsx)("button",{type:"button",onClick:y,className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":"Dismiss",children:(0,s.jsx)(a.A,{size:13})})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:v,className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-lg text-[var(--amber-foreground)] bg-[var(--amber)] hover:opacity-90 transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:t.viewDetails}),(0,s.jsx)("button",{type:"button",onClick:y,className:"flex-1 px-3 py-1.5 text-xs rounded-lg text-muted-foreground border border-border hover:text-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:j?t.skipAll:t.skipVersion})]})]})})}}},e=>{e.O(0,[7513,3295,4913,3862,755,854,4243,7396,7159,3606,9538,1986,7121,5581,8252,6636,6902,5358,7025,8660,8441,3794,7358],()=>e(e.s=30266)),_N_E=e.O()}]);
|
|
137
|
+
`,children:(0,s.jsxs)("div",{className:"pointer-events-auto flex flex-col gap-2.5 bg-card border border-border rounded-xl shadow-lg px-4 py-3 w-[290px]",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"mt-[5px] w-2 h-2 rounded-full bg-[var(--amber)] shrink-0"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground leading-snug",children:w}),k&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k})]}),(0,s.jsx)("button",{type:"button",onClick:y,className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":"Dismiss",children:(0,s.jsx)(a.A,{size:13})})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:v,className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-lg text-[var(--amber-foreground)] bg-[var(--amber)] hover:opacity-90 transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:t.viewDetails}),(0,s.jsx)("button",{type:"button",onClick:y,className:"flex-1 px-3 py-1.5 text-xs rounded-lg text-muted-foreground border border-border hover:text-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:j?t.skipAll:t.skipVersion})]})]})})}},99715:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>er,Fo:()=>F,gL:()=>L});var s=r(95155),n=r(12115),a=r(73321),i=r(82125),o=r(91337),l=r(33078),d=r(48368),c=r(6296),u=r(66088),m=r(15282),x=r(33024),p=r(42129),h=r(38798),f=r(60285),g=r(94290),b=r(67635),v=r(49387),y=r(68459),j=r(9339);let w=(0,j.createServerReference)("60e5baceb63aa5708d4e15756c294cd0c542ec119d",j.callServer,void 0,j.findSourceMapURL,"createFileAction"),k=(0,j.createServerReference)("60d6459b6502fcc9e8251d2ce5265d0201033fa148",j.callServer,void 0,j.findSourceMapURL,"renameSpaceAction");var N=r(92218);let S=(0,j.createServerReference)("40982aa78267bf86407ae9ce49737c60ab59369d31",j.callServer,void 0,j.findSourceMapURL,"deleteSpaceAction"),C=(0,j.createServerReference)("4067ff664a43218ca4ffe35a5ff00265551274ca72",j.callServer,void 0,j.findSourceMapURL,"deleteFolderAction");var A=r(93097),z=r(19881),E=r(4235),T=r(35581),$=r(39498),D=r(10377);let R="show-hidden-files";function M(e){let t=t=>{t.key===R&&e()},r=()=>e();return window.addEventListener("storage",t),window.addEventListener("mindos:hidden-files-changed",r),()=>{window.removeEventListener("storage",t),window.removeEventListener("mindos:hidden-files-changed",r)}}function P(){return"true"===localStorage.getItem(R)}function F(e){localStorage.setItem(R,String(e)),window.dispatchEvent(new Event("mindos:hidden-files-changed"))}function L(){return(0,n.useSyncExternalStore)(M,P,()=>!1)}var I=r(51914),O=r(997),W=r(59511);let B=(0,j.createServerReference)("4069acfe15fa71838be0b2f262162ffba9fd586da0",j.callServer,void 0,j.findSourceMapURL,"convertToSpaceAction");var _=r(5292);async function U(e){try{await navigator.clipboard.writeText(e)}catch{}}let H="w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-muted transition-colors text-left",K="w-full flex items-center gap-2 px-3 py-2 text-sm text-error hover:bg-error/10 transition-colors text-left",X="my-1 border-t border-border/50";function Y({x:e,y:t,onClose:r,menuHeight:a,children:i}){let o=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&r()},t=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r]);let l=Math.min(t,window.innerHeight-(a??160)),d=Math.min(e,window.innerWidth-200);return(0,s.jsx)("div",{ref:o,className:"fixed z-50 min-w-[180px] bg-card border border-border rounded-lg shadow-lg py-1",style:{top:l,left:d},children:i})}function J({x:e,y:t,node:r,onClose:n,onRename:i,onNewFile:l,onImport:d,onDelete:c}){let u=(0,a.useRouter)(),{t:m}=(0,T.Y)(),{isPinned:x,togglePin:p}=(0,D.Z)(),h=x(r.path);return(0,s.jsxs)(Y,{x:e,y:t,onClose:n,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{l(),n()},children:[(0,s.jsx)(I.A,{size:14,className:"shrink-0"})," ",m.fileTree.newFile]}),(0,s.jsxs)("button",{className:H,onClick:()=>{u.push(`/view/${(0,o.O0)(`${r.path}/INSTRUCTION.md`)}`),n()},children:[(0,s.jsx)(O.A,{size:14,className:"shrink-0"})," ",m.fileTree.viewRules]}),d&&(0,s.jsxs)("button",{className:H,onClick:()=>{d(r.path),n()},children:[(0,s.jsx)(W.A,{size:14,className:"shrink-0"})," ",m.fileTree.importFile]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:H,onClick:()=>{p(r.path),n()},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${h?"fill-[var(--amber)] text-[var(--amber)]":""}`}),h?m.fileTree.removeFromFavorites:m.fileTree.pinToFavorites]}),(0,s.jsxs)("button",{className:H,onClick:()=>{U(r.path),n()},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",m.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{i(),n()},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",m.fileTree.renameSpace]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:()=>{n(),c()},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"}),m.fileTree.deleteSpace]})]})}function G({x:e,y:t,node:r,onClose:i,onRename:o,onNewFile:l,onDelete:d}){let c=(0,a.useRouter)(),{t:u}=(0,T.Y)(),[m,p]=(0,n.useTransition)(),{isPinned:h,togglePin:f}=(0,D.Z)(),j=h(r.path);return(0,s.jsxs)(Y,{x:e,y:t,onClose:i,menuHeight:220,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{l(),i()},children:[(0,s.jsx)(I.A,{size:14,className:"shrink-0"})," ",u.fileTree.newFile]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:H,onClick:()=>{f(r.path),i()},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${j?"fill-[var(--amber)] text-[var(--amber)]":""}`}),j?u.fileTree.removeFromFavorites:u.fileTree.pinToFavorites]}),(0,s.jsxs)("button",{className:H,disabled:m,onClick:()=>{p(async()=>{if((await B(r.path)).success){c.refresh(),window.dispatchEvent(new Event("mindos:files-changed"));let e=r.name.replace(/^[\p{Emoji_Presentation}\p{Extended_Pictographic}\s]+/u,"")||r.name;(0,_.w)().then(t=>{t&&(0,_.V)(e,r.path)})}i()})},children:[(0,s.jsx)(x.A,{size:14,className:"shrink-0 text-[var(--amber)]"})," ",u.fileTree.convertToSpace]}),(0,s.jsxs)("button",{className:H,onClick:()=>{U(r.path),i()},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",u.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{o(),i()},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",u.fileTree.rename]}),(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:()=>{i(),d()},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"}),u.fileTree.deleteFolder]})]})}var Z=r(29494);function V(){window.dispatchEvent(new Event("mindos:files-changed"))}async function q(e){try{await navigator.clipboard.writeText(e)}catch{}}function Q({dirPath:e,depth:t,onDone:r}){let[i,l]=(0,n.useState)(""),[d,u]=(0,n.useTransition)(),[m,x]=(0,n.useState)(""),p=(0,a.useRouter)(),{t:h}=(0,T.Y)(),f=(0,n.useRef)(null),g=(0,n.useCallback)(()=>{let t=i.trim();t?u(async()=>{let s=await w(e,t);s.success&&s.filePath?(r(),p.push(`/view/${(0,o.O0)(s.filePath)}`),p.refresh(),V()):x(s.error||h.fileTree.failed)}):x(h.fileTree.enterFileName)},[i,e,r,p,h]);return(0,n.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&r()},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[r]),(0,s.jsxs)("div",{ref:f,className:"px-2 pb-1",style:{paddingLeft:`${12*t+20}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{autoFocus:!0,type:"text",value:i,onChange:e=>{l(e.target.value),x("")},onKeyDown:e=>{"Enter"===e.key&&g(),"Escape"===e.key&&r()},placeholder:"filename.md",className:" flex-1 bg-muted border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring "}),d?(0,s.jsx)(c.A,{size:13,className:"text-muted-foreground animate-spin shrink-0"}):(0,s.jsx)("button",{onClick:g,className:"text-xs text-[var(--amber)] hover:text-foreground shrink-0 px-1",children:h.fileTree.create})]}),m&&(0,s.jsx)("p",{className:"text-xs text-error mt-0.5 px-1",children:m})]})}let ee=(0,n.memo)(function({node:e,depth:t,currentPath:r,onNavigate:l,maxOpenDepth:d,onImport:g}){let b=(0,a.useRouter)(),v=r.startsWith(e.path+"/")||r===e.path,y=!!e.isSpace,[j,w]=(0,n.useState)(0===t||v),[z,D]=(0,n.useState)(0===t||v),[R,M]=(0,n.useState)(!1),[P,F]=(0,n.useState)(!1),[L,I]=(0,n.useState)(e.name),[O,W]=(0,n.useTransition)(),B=(0,n.useRef)(null),_=(0,n.useRef)(null),[U,H]=(0,n.useState)(null),{t:K}=(0,T.Y)(),[X,Y]=(0,n.useState)(null),[q,ee]=(0,n.useTransition)(),{isDragTarget:et,handleRowDragOver:es,handleRowDragEnter:en,handleRowDragLeave:ea,handleRowDrop:ei}=function(e,t,r,s){let[a,i]=(0,n.useState)(!1),o=(0,n.useRef)(null),l=(0,n.useRef)(null),d=(0,n.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),c=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",l.current&&(clearTimeout(l.current),l.current=null),a||i(!0))},[a]),u=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.stopPropagation(),i(!0),d(),t||(o.current=setTimeout(()=>{r(!0),o.current=null},500)))},[t,d,r]),m=(0,n.useCallback)(e=>{e.dataTransfer.types.includes("Files")&&(e.stopPropagation(),l.current=setTimeout(()=>{i(!1),d(),l.current=null},50))},[d]),x=(0,n.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),i(!1),d(),l.current&&(clearTimeout(l.current),l.current=null);let r=t.dataTransfer.files;r.length>0&&(0,Z.Nh)(Array.from(r),e.path,s)},[e.path,s,d]);return(0,n.useEffect)(()=>()=>{o.current&&clearTimeout(o.current),l.current&&clearTimeout(l.current)},[]),{isDragTarget:a,handleRowDragOver:c,handleRowDragEnter:u,handleRowDragLeave:m,handleRowDrop:x}}(e,j,(0,n.useCallback)(e=>{w(e),e&&D(!0)},[]),K),eo=(0,n.useCallback)(()=>{w(e=>(e||D(!0),!e))},[]),el=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{if(null==d){el.current=d;return}if(el.current!==d){if(null===el.current||void 0===el.current)t>d?w(!1):D(!0);else{let e=t<=d;w(e),e&&D(!0)}el.current=d}},[d,t]),(0,n.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);let ed=(0,n.useCallback)(t=>{t?.preventDefault(),t?.stopPropagation(),_.current&&(clearTimeout(_.current),_.current=null),I(e.name),F(!0),setTimeout(()=>B.current?.select(),0)},[e.name]),ec=(0,n.useCallback)(()=>{let t=L.trim();t&&t!==e.name?W(async()=>{let r=y?k:N.f,s=await r(e.path,t);s.success&&s.newPath?(F(!1),b.push(`/view/${(0,o.O0)(s.newPath)}`),b.refresh(),V()):F(!1)}):F(!1)},[L,e.name,e.path,b,y]),eu=(0,n.useCallback)(()=>{P||(_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{b.push(`/view/${(0,o.O0)(e.path)}`),l?.(),_.current=null},180))},[P,b,e.path,l]);(0,n.useCallback)(e=>{e.stopPropagation(),eo()},[eo]);let em=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H({x:e.clientX,y:e.clientY})},[]),ex=y?function e(t){return"file"===t.type?+!i.C.has(t.name):(t.children??[]).reduce((t,r)=>t+e(r),0)}(e):0;if(P)return(0,s.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,s.jsx)("input",{ref:B,autoFocus:!0,value:L,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ec(),"Escape"===e.key&&F(!1)},onBlur:ec,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),O&&(0,s.jsx)(c.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]});let ep=y&&0===t;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:`relative group/dir flex items-center transition-colors duration-100 ${et?"bg-[var(--amber)]/10 rounded-md":""}`,onContextMenu:em,onDragEnter:en,onDragOver:es,onDragLeave:ea,onDrop:ei,children:[(0,s.jsx)("button",{onClick:eo,className:"shrink-0 p-1 rounded hover:bg-muted text-muted-foreground transition-colors",style:{marginLeft:`${12*t+4}px`},"aria-label":j?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":j,children:(0,s.jsx)("span",{className:"block transition-transform duration-150",style:{transform:j?"rotate(0deg)":"rotate(-90deg)"},children:(0,s.jsx)(u.A,{size:10})})}),(0,s.jsxs)("button",{type:"button",onClick:eu,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.setData("text/mindos-type","directory"),t.dataTransfer.effectAllowed="copy"},className:`
|
|
138
|
+
flex-1 flex items-center gap-1.5 px-1 py-1 rounded text-left min-w-0 pr-16
|
|
139
|
+
text-sm transition-colors duration-100
|
|
140
|
+
hover:bg-muted cursor-default
|
|
141
|
+
${v?"text-foreground":"text-muted-foreground hover:text-foreground"}
|
|
142
|
+
`,children:[y?"Inbox"===e.name?(0,s.jsx)(m.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):(0,s.jsx)(x.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):j?(0,s.jsx)(p.A,{size:14,className:"text-yellow-400 shrink-0"}):(0,s.jsx)(h.A,{size:14,className:"text-yellow-400 shrink-0"}),(0,s.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),y&&!j&&(0,s.jsx)("span",{className:"ml-auto text-xs text-muted-foreground shrink-0 tabular-nums pr-1",children:ex})]}),(0,s.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/dir:flex items-center gap-0.5 z-10",children:(0,s.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();H({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,s.jsx)(f.A,{size:14})})})]}),(0,s.jsx)("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${j?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:(0,s.jsxs)("div",{className:`overflow-hidden ${ep?"border-l-2 ml-[18px]":""}`,style:ep?{borderColor:"color-mix(in srgb, var(--amber) 30%, transparent)"}:void 0,...!j&&{inert:!0},children:[z&&e.children&&(0,s.jsx)(er,{nodes:e.children,depth:ep?1:t+1,onNavigate:l,maxOpenDepth:d,parentIsSpace:y,onImport:g}),R&&(0,s.jsx)(Q,{dirPath:e.path,depth:ep?0:t,onDone:()=>M(!1)})]})}),U&&(y?(0,s.jsx)(J,{x:U.x,y:U.y,node:e,onClose:()=>H(null),onRename:()=>ed(),onNewFile:()=>{w(!0),D(!0),M(!0)},onImport:g,onDelete:()=>Y("space")}):(0,s.jsx)(G,{x:U.x,y:U.y,node:e,onClose:()=>H(null),onRename:()=>ed(),onNewFile:()=>{w(!0),D(!0),M(!0)},onDelete:()=>Y("folder")})),(0,s.jsx)($.TM,{open:null!==X,title:"space"===X?K.fileTree.deleteSpace:K.fileTree.deleteFolder,message:"space"===X?K.fileTree.confirmDeleteSpace(e.name):K.fileTree.confirmDeleteFolder(e.name),confirmLabel:"space"===X?K.fileTree.deleteSpace:K.fileTree.deleteFolder,cancelLabel:K.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>Y(null),onConfirm:()=>{Y(null),ee(async()=>{let t="space"===X?await S(e.path):await C(e.path);if(t.success&&t.trashId){let r=t.trashId,s=e.path.split("/").pop()??e.path;E.oR.undo(`${K.trash?.movedToTrash??"Deleted"} ${s}`,async()=>{let e=await (0,A.Y)(r);e.success?(b.refresh(),V()):E.oR.error(e.error??"Undo failed")},{label:K.trash?.undo??"Undo"}),b.push("/"),b.refresh(),V()}})}})]})}),et=(0,n.memo)(function({node:e,depth:t,currentPath:r,onNavigate:u}){let m=(0,a.useRouter)(),x=r===e.path,[p,h]=(0,n.useState)(!1),[j,w]=(0,n.useState)(e.name),[k,S]=(0,n.useTransition)(),[,C]=(0,n.useTransition)(),R=(0,n.useRef)(null),{t:M}=(0,T.Y)(),{isPinned:P,togglePin:F}=(0,D.Z)(),L=P(e.path),I=!e.path.includes("/")&&i.A.has(e.name),[O,W]=(0,n.useState)(!1),[B,_]=(0,n.useState)(null),U=(0,n.useCallback)(()=>{p||(m.push(`/view/${(0,o.O0)(e.path)}`),u?.())},[m,e.path,u,p]),J=(0,n.useCallback)(t=>{t.stopPropagation(),w(e.name),h(!0),setTimeout(()=>R.current?.select(),0)},[e.name]),G=(0,n.useCallback)(()=>{let t=j.trim();t&&t!==e.name?S(async()=>{let r=await (0,N.f)(e.path,t);r.success&&r.newPath?(h(!1),m.push(`/view/${(0,o.O0)(r.newPath)}`),m.refresh(),V()):h(!1)}):h(!1)},[j,e.name,e.path,m]),Z=(0,n.useCallback)(e=>{e.stopPropagation(),W(!0)},[]),Q=(0,n.useCallback)(t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.effectAllowed="copy"},[e.path]),ee=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_({x:e.clientX,y:e.clientY})},[]);return p?(0,s.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,s.jsx)("input",{ref:R,autoFocus:!0,value:j,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(),"Escape"===e.key&&h(!1)},onBlur:G,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),k&&(0,s.jsx)(c.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]}):(0,s.jsxs)("div",{className:"relative group/file",children:[(0,s.jsxs)("button",{onClick:U,onContextMenu:ee,draggable:!0,onDragStart:Q,"data-filepath":e.path,className:`
|
|
143
|
+
w-full flex items-center gap-1.5 px-2 py-1 rounded text-left
|
|
144
|
+
text-sm transition-colors duration-100 cursor-default pr-16
|
|
145
|
+
${x?"bg-accent text-foreground":"hover:bg-muted text-muted-foreground hover:text-foreground"}
|
|
146
|
+
`,style:{paddingLeft:`${12*t+8}px`},children:["directory"===e.type?null:".csv"===e.extension?(0,s.jsx)(l.A,{size:14,className:"text-success shrink-0"}):(0,s.jsx)(d.A,{size:14,className:"text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),L&&(0,s.jsx)(g.A,{size:10,className:"shrink-0 fill-[var(--amber)] text-[var(--amber)] opacity-60"})]}),(0,s.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/file:flex items-center gap-0.5",children:(0,s.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();_({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,s.jsx)(f.A,{size:14})})}),B&&(0,s.jsxs)(Y,{x:B.x,y:B.y,onClose:()=>_(null),menuHeight:140,children:[(0,s.jsxs)("button",{className:H,onClick:()=>{q(e.path),_(null)},children:[(0,s.jsx)(b.A,{size:14,className:"shrink-0"})," ",M.fileTree.copyPath]}),(0,s.jsxs)("button",{className:H,onClick:()=>{F(e.path),_(null)},children:[(0,s.jsx)(g.A,{size:14,className:`shrink-0 ${L?"fill-[var(--amber)] text-[var(--amber)]":""}`}),L?M.fileTree.removeFromFavorites:M.fileTree.pinToFavorites]}),!I&&(0,s.jsxs)("button",{className:H,onClick:e=>{_(null),J(e)},children:[(0,s.jsx)(v.A,{size:14,className:"shrink-0"})," ",M.fileTree.rename]}),!I&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:X}),(0,s.jsxs)("button",{className:K,onClick:e=>{_(null),Z(e)},children:[(0,s.jsx)(y.A,{size:14,className:"shrink-0"})," ",M.fileTree.delete]})]})]}),(0,s.jsx)($.TM,{open:O,title:M.fileTree.delete,message:M.fileTree.confirmDelete(e.name),confirmLabel:M.fileTree.delete,cancelLabel:M.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>W(!1),onConfirm:()=>{W(!1),C(async()=>{let t=await (0,z.i)(e.path);if(t.success){if(t.trashId){let r=t.trashId,s=e.path.split("/").pop()??e.path;E.oR.undo(`${M.trash?.movedToTrash??"Deleted"} ${s}`,async()=>{let e=await (0,A.Y)(r);e.success?(m.refresh(),V()):E.oR.error(e.error??"Undo failed")},{label:M.trash?.undo??"Undo"})}m.refresh(),V()}})}})]})});function er({nodes:e,depth:t=0,onNavigate:r,maxOpenDepth:o,parentIsSpace:l,onImport:d}){var c;let u,m=(u="/view/",(c=(0,a.usePathname)()).startsWith(u)?c.slice(u.length).split("/").map(decodeURIComponent).join("/"):""),x=L(),p=0===t,h=x?e:e.filter(e=>!(p&&e.name.startsWith(".")||"file"===e.type&&i.C.has(e.name)||"directory"===e.type&&e.name.startsWith("."))),f=p?h.filter(e=>"directory"!==e.type||"Inbox"!==e.name):h;return(0,n.useEffect)(()=>{if(!m||0!==t)return;let e=setTimeout(()=>{let e=document.querySelector(`[data-filepath="${CSS.escape(m)}"]`);e?.scrollIntoView({block:"nearest",behavior:"smooth"})},120);return()=>clearTimeout(e)},[m,t]),(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:f.map(e=>"directory"===e.type?(0,s.jsx)(ee,{node:e,depth:t,currentPath:m,onNavigate:r,maxOpenDepth:o,onImport:d},e.path):(0,s.jsx)(et,{node:e,depth:t,currentPath:m,onNavigate:r},e.path))})}}},e=>{e.O(0,[7513,3295,4913,3862,755,854,4243,7396,7159,3606,9538,1986,7121,5581,8252,6636,6902,5358,7025,8660,8441,3794,7358],()=>e(e.s=30266)),_N_E=e.O()}]);
|