@alook/app 0.0.77 → 0.0.79
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/bundled/email-worker/index.js +2 -1
- package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
- package/bundled/web/.open-next/.build/open-next.config.edge.mjs +146 -5
- package/bundled/web/.open-next/.build/open-next.config.mjs +140 -5
- package/bundled/web/.open-next/assets/BUILD_ID +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/031m-eb429hj4.js +2 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0d2ptea7.h139.js → 05~4tl0zgrol5.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/07-fakltbt2a2.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/07zixwn.53xcm.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0_i1v2~_w-_jk.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0bwptiqeu8.61.js +325 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0e32q02m3ewux.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0h_a9~1fp7ago.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{00vv.te1qu_1m.js → 0ie.u1iu3pwrm.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/{0alt4g70q0kns.js → 0ivn_32mz4lhv.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0jahw0dpk9vgc.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0zeouhtn0hbkx.js → 0kcuw_83491vk.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0mntmjgjntb7y.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0t2w-7.88r2xw.js → 0oh4spqzj65-a.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/{0.ow13_gacl1n.js → 0p-5xcfjcbn~s.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0v3.4j_hftqix.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0x8emvplqk0j_.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0y.7dv.ck31vl.css +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0~xam~jpkm~vn.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/106i157mnp0ro.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/11r7n17iffcwi.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/17gxqoer2p0mw.js +22 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/1816-z_y9qndk.js +1 -0
- package/bundled/web/.open-next/assets/gallery/calendar.png +0 -0
- package/bundled/web/.open-next/assets/gallery/collaboration.png +0 -0
- package/bundled/web/.open-next/assets/gallery/email.png +0 -0
- package/bundled/web/.open-next/assets/gallery/issues.png +0 -0
- package/bundled/web/.open-next/assets/gallery/local-agent.png +0 -0
- package/bundled/web/.open-next/assets/gallery/org.png +0 -0
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_global-error.cache +1 -1
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_not-found.cache +1 -1
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/sitemap.xml.cache +1 -1
- package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
- package/bundled/web/.open-next/cloudflare/init.js +1 -1
- package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
- package/bundled/web/.open-next/dynamodb-provider/open-next.config.mjs +140 -5
- package/bundled/web/.open-next/middleware/handler.mjs +4 -4
- package/bundled/web/.open-next/middleware/open-next.config.mjs +146 -5
- package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/activity/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/email/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/files/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/meetings/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/new/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/help/email-setup/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/[traceId]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/calendar/route.js +6 -5
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/[id]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/0b5f_next_dist_esm_build_templates_app-route_08rz-qa.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +13 -11
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0266t8u._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_03t_17c._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_09j_99x._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0drn_ol._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0exm5_w._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0h3guve._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0w6dw.t._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_12wxdg1._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/0b-r_unique-names-generator_dist_index_m_10n7h-y.js +4 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__03fsn3f._.js +13 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__091lwu-._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{[root-of-the-server]__099etsu._.js → [root-of-the-server]__0esiqa8._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{[root-of-the-server]__0r2s1aj._.js → [root-of-the-server]__0rdn-xi._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +13 -11
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_0vv9cr4._.js → _02qoj2p._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_063q-hj._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0ilz5db._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0n4z71y._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_05wa4wr._.js → _0rgicks._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0tu039y._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_11h_8jo._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_12e18r-._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_13__3im._.js +21 -22
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0ioufd8._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_10wwsme._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0~23g-y._.js +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_agents_[id]_email_page_tsx_09mq1-g._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_agents_[id]_layout_tsx_0juu2um._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_00xgo_-._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_0nj0euq._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_home_home-page_tsx_0to84tv._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_lib_api_ts_0uf2r1p._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +83 -83
- package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +261 -214
- package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/open-next.config.mjs +146 -5
- package/bundled/ws-do/index.js +2 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/session-runner.js +2 -1
- package/dist/index.js +3 -2
- package/package.json +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0.vi-1cgnne0e.css +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/01je4kbh.8akj.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/05rjq4guhci-w.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0fmcohc0raah~.js +0 -326
- package/bundled/web/.open-next/assets/_next/static/chunks/0ipcqq75rslc3.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0khqgglj_9zdp.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0lf4c2v9ftogx.js +0 -3
- package/bundled/web/.open-next/assets/_next/static/chunks/0m~et1blru7_u.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0npw723ph39ai.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0pig4vcvoqn0w.js +0 -20
- package/bundled/web/.open-next/assets/_next/static/chunks/0pijx0.ayvlyr.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0sp16c8-thn5e.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0uht5kak3uat9.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0ypg5.fp9-.a2.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0zoi2a2-ucmjh.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/112_xk40~~_sr.js +0 -3
- package/bundled/web/.open-next/assets/_next/static/chunks/173os6ji32qc1.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/182fqror32n8n.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0x7m_vj._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0.a2670._.js +0 -13
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0nava3-._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_091qk6t._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0xcw94t._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0d6x0l6._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0o~nukr._.js +0 -3
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_buildManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_clientMiddlewareManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_ssgManifest.js +0 -0
- /package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/robots.txt.cache +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[221781,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(207058),e=a.i(506180),f=a.i(752792),g=a.i(588339),h=a.i(732254),i=a.i(22902),j=a.i(243703),k=a.i(163672),l=a.i(185077),m=a.i(277337),n=a.i(404943),o=a.i(724890),p=o.Extension.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:a=>{let b=a.style.textAlign;return this.options.alignments.includes(b)?b:this.options.defaultAlignment},renderHTML:a=>a.textAlign?{style:`text-align: ${a.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:a=>({commands:b})=>!!this.options.alignments.includes(a)&&this.options.types.map(c=>b.updateAttributes(c,{textAlign:a})).some(a=>a),unsetTextAlign:()=>({commands:a})=>this.options.types.map(b=>a.resetAttributes(b,"textAlign")).some(a=>a),toggleTextAlign:a=>({editor:b,commands:c})=>!!this.options.alignments.includes(a)&&(b.isActive({textAlign:a})?c.unsetTextAlign():c.setTextAlign(a))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),q=(a,b=0)=>{let c=[];return!a.children.length||b>20||Array.from(a.children).forEach(a=>{"SPAN"===a.tagName?c.push(a):a.children.length&&c.push(...q(a,b+1))}),c},r=o.Mark.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:a=>{var b;return!!a.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(b=a).children.length&&q(b).forEach(a=>{var b,c;let d=a.getAttribute("style"),e=null==(c=null==(b=a.parentElement)?void 0:b.closest("span"))?void 0:c.getAttribute("style");a.setAttribute("style",`${e};${d}`)}),{})}}]},renderHTML({HTMLAttributes:a}){return["span",(0,o.mergeAttributes)(this.options.HTMLAttributes,a),0]},addCommands(){return{toggleTextStyle:a=>({commands:b})=>b.toggleMark(this.name,a),removeEmptyTextStyle:()=>({tr:a})=>{let{selection:b}=a;return a.doc.nodesBetween(b.from,b.to,(b,c)=>{if(b.isTextblock)return!0;b.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(a=>!!a))||a.removeMark(c,c+b.nodeSize,this.type)}),!0}}}}),s=o.Extension.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:a=>{var b;let c=null!=(b=(0,o.getStyleProperty)(a,"background-color"))?b:a.style.backgroundColor;return null==c?void 0:c.replace(/['"]+/g,"")},renderHTML:a=>a.backgroundColor?{style:`background-color: ${a.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:a=>({chain:b})=>b().setMark("textStyle",{backgroundColor:a}).run(),unsetBackgroundColor:()=>({chain:a})=>a().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),t=o.Extension.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:a=>{var b;let c=null!=(b=(0,o.getStyleProperty)(a,"color"))?b:a.style.color;return null==c?void 0:c.replace(/['"]+/g,"")},renderHTML:a=>a.color?{style:`color: ${a.color}`}:{}}}}]},addCommands:()=>({setColor:a=>({chain:b})=>b().setMark("textStyle",{color:a}).run(),unsetColor:()=>({chain:a})=>a().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),u=o.Extension.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"font-family"))?b:a.style.fontFamily},renderHTML:a=>a.fontFamily?{style:`font-family: ${a.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:a=>({chain:b})=>b().setMark("textStyle",{fontFamily:a}).run(),unsetFontFamily:()=>({chain:a})=>a().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),v=o.Extension.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"font-size"))?b:a.style.fontSize},renderHTML:a=>a.fontSize?{style:`font-size: ${a.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:a=>({chain:b})=>b().setMark("textStyle",{fontSize:a}).run(),unsetFontSize:()=>({chain:a})=>a().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),w=o.Extension.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"line-height"))?b:a.style.lineHeight},renderHTML:a=>a.lineHeight?{style:`line-height: ${a.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:a=>({chain:b})=>b().setMark("textStyle",{lineHeight:a}).run(),unsetLineHeight:()=>({chain:a})=>a().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})});o.Extension.create({name:"textStyleKit",addExtensions(){let a=[];return!1!==this.options.backgroundColor&&a.push(s.configure(this.options.backgroundColor)),!1!==this.options.color&&a.push(t.configure(this.options.color)),!1!==this.options.fontFamily&&a.push(u.configure(this.options.fontFamily)),!1!==this.options.fontSize&&a.push(v.configure(this.options.fontSize)),!1!==this.options.lineHeight&&a.push(w.configure(this.options.lineHeight)),!1!==this.options.textStyle&&a.push(r.configure(this.options.textStyle)),a}});var x=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,y=o.Node.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:a}){return["img",(0,o.mergeAttributes)(this.options.HTMLAttributes,a)]},parseMarkdown:(a,b)=>b.createNode("image",{src:a.href,title:a.title,alt:a.text}),renderMarkdown:a=>{var b,c,d,e,f,g;let h=null!=(c=null==(b=a.attrs)?void 0:b.src)?c:"",i=null!=(e=null==(d=a.attrs)?void 0:d.alt)?e:"",j=null!=(g=null==(f=a.attrs)?void 0:f.title)?g:"";return j?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:a,minWidth:b,minHeight:c,alwaysPreserveAspectRatio:d}=this.options.resize;return({node:e,getPos:f,HTMLAttributes:g,editor:h})=>{let i=document.createElement("img");Object.entries(g).forEach(([a,b])=>{if(null!=b)switch(a){case"width":case"height":break;default:i.setAttribute(a,b)}}),i.src=g.src;let j=new o.ResizableNodeView({element:i,editor:h,node:e,getPos:f,onResize:(a,b)=>{i.style.width=`${a}px`,i.style.height=`${b}px`},onCommit:(a,b)=>{let c=f();void 0!==c&&this.editor.chain().setNodeSelection(c).updateAttributes(this.name,{width:a,height:b}).run()},onUpdate:(a,b,c)=>a.type===e.type,options:{directions:a,min:{width:b,height:c},preserveAspectRatio:!0===d}}),k=j.dom;return k.style.visibility="hidden",k.style.pointerEvents="none",i.onload=()=>{k.style.visibility="",k.style.pointerEvents=""},j}},addCommands(){return{setImage:a=>({commands:b})=>b.insertContent({type:this.name,attrs:a})}},addInputRules(){return[(0,o.nodeInputRule)({find:x,type:this.type,getAttributes:a=>{let[,,b,c,d]=a;return{src:c,alt:b,title:d}}})]}}),z=a.i(75118),A=a.i(525132),B=a.i(647651);let C=(0,B.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]),D=(0,B.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),E=(0,B.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]),F=(0,B.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]),G=(0,B.default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),H=(0,B.default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]),I=(0,B.default)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]),J=(0,B.default)("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]),K=(0,B.default)("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]]),L=(0,B.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),M=(0,B.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),N=(0,B.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),O=(0,B.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]),P=(0,B.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);var Q=a.i(457655),Q=Q;function R({active:a,disabled:c,onClick:d,title:e,children:f}){return(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",disabled:c,onMouseDown:a=>a.preventDefault(),onClick:d,className:(0,z.cn)("text-muted-foreground/70",a&&"bg-accent text-foreground")}),children:f}),(0,b.jsx)(A.TooltipContent,{children:e})]})}function S(){return(0,b.jsx)("div",{className:"w-px h-4 bg-border/60 mx-0.5 shrink-0"})}function T({editor:a}){if(!a)return null;let c="size-3.5";return(0,b.jsxs)("div",{className:"flex items-center gap-0.5 px-3 py-1 overflow-x-auto",children:[(0,b.jsx)(R,{title:"Bold",active:a.isActive("bold"),onClick:()=>a.chain().focus().toggleBold().run(),children:(0,b.jsx)(C,{className:c})}),(0,b.jsx)(R,{title:"Italic",active:a.isActive("italic"),onClick:()=>a.chain().focus().toggleItalic().run(),children:(0,b.jsx)(D,{className:c})}),(0,b.jsx)(R,{title:"Underline",active:a.isActive("underline"),onClick:()=>a.chain().focus().toggleUnderline().run(),children:(0,b.jsx)(E,{className:c})}),(0,b.jsx)(R,{title:"Strikethrough",active:a.isActive("strike"),onClick:()=>a.chain().focus().toggleStrike().run(),children:(0,b.jsx)(F,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Heading 1",active:a.isActive("heading",{level:1}),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),children:(0,b.jsx)(O,{className:c})}),(0,b.jsx)(R,{title:"Heading 2",active:a.isActive("heading",{level:2}),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),children:(0,b.jsx)(P,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Bullet List",active:a.isActive("bulletList"),onClick:()=>a.chain().focus().toggleBulletList().run(),children:(0,b.jsx)(G,{className:c})}),(0,b.jsx)(R,{title:"Ordered List",active:a.isActive("orderedList"),onClick:()=>a.chain().focus().toggleOrderedList().run(),children:(0,b.jsx)(H,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Align Left",active:a.isActive({textAlign:"left"}),onClick:()=>a.chain().focus().setTextAlign("left").run(),children:(0,b.jsx)(I,{className:c})}),(0,b.jsx)(R,{title:"Align Center",active:a.isActive({textAlign:"center"}),onClick:()=>a.chain().focus().setTextAlign("center").run(),children:(0,b.jsx)(J,{className:c})}),(0,b.jsx)(R,{title:"Align Right",active:a.isActive({textAlign:"right"}),onClick:()=>a.chain().focus().setTextAlign("right").run(),children:(0,b.jsx)(K,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:a.isActive("link")?"Remove Link":"Insert Link",active:a.isActive("link"),onClick:()=>{if(a.isActive("link"))return void a.chain().focus().unsetLink().run();let b=window.prompt("URL");b&&a.chain().focus().extendMarkRange("link").setLink({href:b}).run()},children:a.isActive("link")?(0,b.jsx)(M,{className:c}):(0,b.jsx)(L,{className:c})}),(0,b.jsx)(R,{title:"Insert Image",onClick:()=>{let b=window.prompt("Image URL");b&&a.chain().focus().setImage({src:b}).run()},children:(0,b.jsx)(N,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Horizontal Rule",onClick:()=>a.chain().focus().setHorizontalRule().run(),children:(0,b.jsx)(Q.default,{className:c})})]})}var U=a.i(334235),V=a.i(921584),W=a.i(17239),X=a.i(518828),Y=a.i(16831),Z=a.i(546257),$=a.i(390759);function _({fromAddress:d,onSend:e,onDiscard:f,initialTo:g="",initialSubject:i="",initialBody:o="",initialAttachments:q=[],inReplyTo:s,references:u}){let[v,w]=(0,c.useState)(g),[x,z]=(0,c.useState)(i),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(q),[F,G]=(0,c.useState)(!1),H=(0,c.useRef)(null),I=(0,j.useEditor)({immediatelyRender:!1,content:o||void 0,extensions:[k.default.configure({link:!1,underline:!1}),l.default.configure({placeholder:"Write your email..."}),m.default,n.default.configure({autolink:!0,openOnClick:!1,linkOnPaste:!0}),p.configure({types:["heading","paragraph"]}),r,t,y.configure({inline:!0,allowBase64:!0})],editorProps:{attributes:{class:"text-sm max-w-none focus:outline-none min-h-50 px-4 py-3"}}}),J=async()=>{if(v.trim()&&x.trim()&&I){C(!0);try{let a=I.getHTML();await e(v.trim(),x.trim(),a,D,s||u?{inReplyTo:s,references:u}:void 0)&&(w(""),z(""),E([]),I.commands.clearContent())}finally{C(!1)}}},K=async b=>{let c=b.target.files;if(c&&0!==c.length){G(!0);try{let{uploadEmailAttachment:b}=await a.A(81396);for(let a of Array.from(c)){if(a.size>0xa00000){V.toast.error(`${a.name} exceeds 10 MB limit`);continue}let c=new URLSearchParams(window.location.search).get("workspace_id")??"",d=await b(a,c);E(a=>[...a,d])}}catch{V.toast.error("Failed to upload attachment")}finally{G(!1),H.current&&(H.current.value="")}}};return(0,b.jsxs)("div",{className:"flex flex-col h-full w-full min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2",children:[(0,b.jsx)("h3",{className:"text-sm font-heading font-medium tracking-tight",children:"New Email"}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground h-7 px-2",onClick:f,disabled:B,children:[(0,b.jsx)(X.X,{className:"size-3 mr-1"}),"Discard"]}),(0,b.jsxs)(h.Button,{size:"sm",className:"text-xs h-7 px-3",onClick:J,disabled:B||!v.trim()||!x.trim(),children:[B?(0,b.jsx)(Y.Loader2,{className:"size-3 mr-1 animate-spin"}):(0,b.jsx)(W.Send,{className:"size-3 mr-1"}),"Send"]})]})]}),(0,b.jsxs)("div",{className:"border-b border-border/30 px-4 py-2.5 space-y-1 min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,b.jsx)("span",{className:"text-muted-foreground truncate min-w-0",children:d})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,b.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,b.jsx)(U.Input,{type:"email",value:v,onChange:a=>w(a.target.value),placeholder:"recipient@example.com",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:B})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"Subject"}),(0,b.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,b.jsx)(U.Input,{value:x,onChange:a=>z(a.target.value),placeholder:"Email subject",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:B})})]})]}),(0,b.jsxs)("div",{className:"flex items-center border-b border-border/30",children:[(0,b.jsx)(T,{editor:I}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-2 border-l border-border/30",children:[(0,b.jsx)("input",{ref:H,type:"file",multiple:!0,className:"hidden",onChange:K}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",disabled:F,onMouseDown:a=>a.preventDefault(),onClick:()=>H.current?.click(),className:"text-muted-foreground/70"}),children:F?(0,b.jsx)(Y.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(Z.Paperclip,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Attach file"})]})]})]}),D.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 px-4 py-2 border-b border-border/30",children:D.map(a=>{var c;return(0,b.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs",children:[(0,b.jsx)($.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:(c=a.size)<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`}),(0,b.jsx)("button",{type:"button",onClick:()=>{var b;return b=a.key,void E(a=>a.filter(a=>a.key!==b))},className:"text-muted-foreground hover:text-foreground ml-0.5 cursor-pointer",children:(0,b.jsx)(X.X,{className:"size-3"})})]},a.key)})}),(0,b.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar",children:(0,b.jsx)(j.EditorContent,{editor:I})})]})}var aa=a.i(25668),ab=a.i(321932),ac=a.i(606896),ad=a.i(109578),ae=a.i(552012),af=a.i(415584);let ag=(0,B.default)("forward",[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]),ah=(0,B.default)("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]);var ai=a.i(584126),aj=a.i(549931);let ak=(0,B.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var al=a.i(236631),al=al,am=a.i(586220),an=a.i(511238),ao=a.i(135510);function ap(a){let b=new Date(a),c=Math.floor((new Date().getTime()-b.getTime())/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;let d=Math.floor(c/60);if(d<24)return`${d}h ago`;let e=Math.floor(d/24);return e<7?`${e}d ago`:b.toLocaleDateString(void 0,{month:"short",day:"numeric"})}a.s(["default",0,function(){let a=(0,d.useParams)().id,{workspaceId:j}=(0,e.useWorkspace)(),{agents:k,subscribeWs:l}=(0,f.useAgentContext)(),m=k.find(b=>b.id===a),n=(0,am.useIsMobile)(),[o,p]=(0,c.useState)("inbox"),[q,r]=(0,c.useState)([]),s=(0,c.useMemo)(()=>q.filter(a=>"unread"===a.status).length,[q]),[t,u]=(0,c.useState)(!0),[v,w]=(0,c.useState)(null),[x,y]=(0,c.useState)(null),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(!1),[F,G]=(0,c.useState)({}),[H,I]=(0,c.useState)([]),[J,K]=(0,c.useState)(null),[L,M]=(0,c.useState)({}),[N,O]=(0,c.useState)(!1),[P,Q]=(0,c.useState)(null),[R,S]=(0,c.useState)(!1),[T,U]=(0,c.useState)([]),[X,aq]=(0,c.useState)(!1),ar=(0,c.useCallback)(a=>{p(a),r([]),w(null),y(null),E(!1)},[]),as=m?.email_handle?`${m.email_handle}@alook.ai`:"",at=[...as?[{type:"alook",address:as}]:[],...T.map(a=>({type:"custom",address:a.email_address,accountId:a.id}))],[au,av]=(0,c.useState)(0),aw=at[au]??at[0]??null,ax=aw?.address??"",ay=aw?.type==="custom"?aw.accountId:void 0,az=q.find(a=>a.id===v)??null,aA=(0,c.useCallback)(async(b,c)=>{u(!0);try{let d=await (0,g.listEmails)(a,j,b,c);r(d)}catch{V.toast.error("Failed to load emails")}finally{u(!1)}},[a,j]);(0,c.useEffect)(()=>{(0,g.listEmailAccounts)(a,j).then(U).catch(()=>{})},[a,j]),(0,c.useEffect)(()=>{aA(o,ax)},[o,ax,aA]),(0,c.useEffect)(()=>l(b=>{("email.received"===b.type&&b.agentId===a||"email.sent"===b.type&&b.agentId===a)&&aA(o,ax)}),[l,a,o,ax,aA]);let aB=async a=>{E(!1),w(a),y(null),C(!0),I([]),K(null),M({});try{let[b,c]=await Promise.all([(0,g.getEmailBody)(a,j),(0,g.getEmailThread)(a,j).catch(()=>[])]);y(b),I(c);let d=q.find(b=>b.id===a);d&&"unread"===d.status&&(0,g.updateEmailStatus)(a,j,"read").then(()=>{r(b=>b.map(b=>b.id===a?{...b,status:"read"}:b))}).catch(()=>{r(b=>b.map(b=>b.id===a?{...b,status:"unread"}:b))})}catch{y({content:"(body not available)",isHtml:!1})}finally{C(!1)}},aC=async a=>{if(J===a)return void K(null);if(K(a),!L[a])try{let b=await (0,g.getEmailBody)(a,j);M(c=>({...c,[a]:b}))}catch{M(b=>({...b,[a]:{content:"(body not available)",isHtml:!1}}))}},aD=async()=>{if(P){S(!0);try{await (0,g.deleteEmail)(P,j),r(a=>a.filter(a=>a.id!==P)),v===P&&(w(null),y(null)),V.toast.success("Email deleted")}catch{V.toast.error("Failed to delete email")}finally{S(!1),O(!1),Q(null)}}},aE=async(b,c,d,e,f)=>{try{return await (0,g.sendEmail)(a,b,c,d,j,e.length>0?e:void 0,f,ay),V.toast.success("Email sent"),E(!1),ar("sent"),!0}catch{return V.toast.error("Failed to send email"),!1}},aF=a=>`<br/><br/><div style="border-left: 2px solid #ccc; padding-left: 12px; margin-left: 0; color: #666;"><p><strong>From:</strong> ${a.from_email}<br/><strong>To:</strong> ${a.to_email}<br/><strong>Date:</strong> ${new Date(a.created_at).toLocaleString()}<br/><strong>Subject:</strong> ${a.subject}</p>`+(a.html_body?a.html_body:x?.isHtml?x.content:`<pre>${x?.content??""}</pre>`)+"</div>",aG=a=>({inReplyTo:a.message_id||void 0,references:[a.references,a.message_id].filter(Boolean).join(" ").trim()||void 0}),[aH,aI]=(0,c.useState)(!1),aJ=async()=>{if(ax)try{await navigator.clipboard.writeText(ax),aI(!0),setTimeout(()=>aI(!1),1500)}catch{V.toast.error("Failed to copy")}},aK=(0,b.jsxs)("div",{className:"flex h-full flex-col",children:[at.length>0?(0,b.jsx)("div",{className:"px-3 pt-3 pb-1 relative",children:1===at.length?(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsxs)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"group flex items-center gap-1.5 text-left cursor-pointer w-full"}),children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500 shrink-0"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/0 group-hover:text-muted-foreground/60 shrink-0 transition-colors"})]}),(0,b.jsx)(A.TooltipContent,{children:"Click to copy"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-1 w-full",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aq(!X),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),(0,b.jsx)(al.default,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"shrink-0 p-0.5"}),children:aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,b.jsx)(A.TooltipContent,{children:"Copy address"})]})]}),X&&(0,b.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:at.map((a,c)=>(0,b.jsxs)("button",{type:"button",onClick:()=>{av(c),aq(!1)},className:(0,z.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",c===au?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,b.jsx)(ac.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.address}),"custom"===a.type&&(0,b.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},a.address))})]})}):(0,b.jsx)("div",{className:"px-3 pt-3 pb-1",children:(0,b.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"No email configured"})}),(0,b.jsx)("div",{className:"p-2",children:(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsxs)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{size:"sm",className:"w-full justify-start text-xs h-8 gap-1.5",onClick:()=>{G({}),E(!0),w(null)},disabled:0===at.length}),children:[(0,b.jsx)(ae.Plus,{className:"size-3.5"}),"New Email"]}),(0,b.jsx)(A.TooltipContent,{children:0===at.length?"Configure an email in agent settings to send emails":"Compose new email"})]})}),(0,b.jsxs)("nav",{className:"flex flex-col gap-0.5 px-2",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>ar("inbox"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","inbox"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(ad.Inbox,{className:"size-4 shrink-0"}),"Inbox","inbox"===o&&s>0&&(0,b.jsx)("span",{className:"ml-auto text-xs bg-blue-500 text-white rounded-full px-1.5 py-0.5 leading-none min-w-5 text-center",children:s})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>ar("sent"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","sent"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(W.Send,{className:"size-4 shrink-0"}),"Sent"]}),(0,b.jsxs)("button",{type:"button",onClick:()=>ar("untrust"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","untrust"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(ak,{className:"size-4 shrink-0"}),"Untrust"]})]})]}),aL=(0,b.jsx)("div",{className:(0,z.cn)("h-full thin-scrollbar",q.length>0&&!t?"overflow-y-auto":"overflow-hidden"),children:t?(0,b.jsx)(b.Fragment,{children:Array.from({length:3}).map((a,c)=>(0,b.jsxs)("div",{className:"px-4 py-3 border-b border-border/30",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[(0,b.jsx)(aa.Skeleton,{className:"h-3.5 w-32"}),(0,b.jsx)(aa.Skeleton,{className:"h-2.5 w-10"})]}),(0,b.jsx)(aa.Skeleton,{className:"h-3.5 w-48 mb-1.5"}),(0,b.jsx)(aa.Skeleton,{className:"h-4 w-16 rounded-full"})]},c))}):0===q.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center h-full animate-[fade-up_400ms_ease-out_both]",children:[(0,b.jsx)(ac.Mail,{className:"size-8 text-muted-foreground mb-3"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"inbox"===o?"No emails from trusted senders":"sent"===o?"No emails sent yet":"No untrusted emails"})]}):q.map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>aB(a.id),className:(0,z.cn)("w-full text-left px-4 py-3 border-b border-border/30 transition-colors duration-150 cursor-pointer",v===a.id?"bg-accent/60":"hover:bg-accent/30"),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[(0,b.jsx)("p",{className:(0,z.cn)("text-sm truncate","unread"===a.status?"font-semibold":"font-medium text-muted-foreground"),children:"sent"===o?a.to_email:a.from_email}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:["sent"!==o&&(0,b.jsx)("span",{className:(0,z.cn)("text-[10px] rounded-full px-1.5 py-0.5 leading-none font-medium","unread"===a.status?"bg-blue-500/15 text-blue-600 dark:text-blue-400":"bg-muted text-muted-foreground"),children:"unread"===a.status?"unread":"read"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:ap(a.created_at)})]})]}),(0,b.jsx)("p",{className:(0,z.cn)("text-[13px] truncate","unread"===a.status?"text-foreground":"text-muted-foreground"),children:a.subject||"(no subject)"})]},a.id))}),aM=(0,b.jsx)("div",{className:"h-full overflow-auto flex flex-col min-w-0 thin-scrollbar",children:D?(0,b.jsx)(_,{fromAddress:ax,onSend:aE,onDiscard:()=>{E(!1),G({})},initialTo:F.to,initialSubject:F.subject,initialBody:F.body,initialAttachments:F.attachments,inReplyTo:F.inReplyTo,references:F.references},JSON.stringify(F)):az?(0,b.jsxs)("div",{className:"flex flex-col h-full md:min-w-100 max-w-3xl mx-auto w-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-border/40 px-4 py-1.5",children:["sent"!==o&&(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let a;return a=az.subject.startsWith("Re:")?az.subject:`Re: ${az.subject}`,void(w(null),G({to:az.from_email,subject:a,body:aF(az),...aG(az)}),E(!0))}}),children:(0,b.jsx)(ah,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Reply"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let a;return a=az.subject.startsWith("Fwd:")?az.subject:`Fwd: ${az.subject}`,void(w(null),G({subject:a,body:aF(az),attachments:az.attachments??[],...aG(az)}),E(!0))}}),children:(0,b.jsx)(ag,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Forward"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-destructive",onClick:()=>{Q(az.id),O(!0)}}),children:(0,b.jsx)(af.Trash2,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Delete"})]})]}),H.length>0&&(0,b.jsx)("div",{className:"border-b border-border/30",children:H.map(a=>(0,b.jsxs)("div",{className:"border-b border-border/20 last:border-b-0",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aC(a.id),className:"w-full flex items-center gap-2 px-5 py-2.5 text-left hover:bg-accent/30 transition-colors cursor-pointer",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:J===a.id?"▾":"▸"}),(0,b.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:a.from_email}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:ap(a.created_at)})]}),J===a.id&&(0,b.jsxs)("div",{className:"px-5 pb-3",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:a.subject}),L[a.id]?L[a.id].isHtml?(0,b.jsx)(ao.EmailBodyFrame,{html:L[a.id].content,className:"max-w-full text-sm"}):(0,b.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:L[a.id].content}):(0,b.jsx)(Y.Loader2,{className:"size-3 animate-spin text-muted-foreground"})]})]},a.id))}),(0,b.jsxs)("div",{className:"p-5",children:[(0,b.jsx)("h2",{className:"text-lg font-heading font-semibold tracking-tight mb-1",children:az.subject||"(no subject)"}),(0,b.jsxs)("div",{className:"text-sm space-y-1 mb-5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,b.jsx)("span",{children:az.from_email})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,b.jsx)("span",{children:az.to_email})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"sent"===o?"Sent":"Received"}),(0,b.jsx)("span",{className:"text-muted-foreground",children:new Date(az.created_at).toLocaleString()})]})]}),B?(0,b.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,b.jsx)(Y.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}):az.html_body?(0,b.jsx)(ao.EmailBodyFrame,{html:az.html_body,className:"max-w-full"}):x?.isHtml?(0,b.jsx)(ao.EmailBodyFrame,{html:x.content,className:"max-w-full"}):(0,b.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:x?.content}),az.attachments&&az.attachments.length>0&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,b.jsx)(Z.Paperclip,{className:"size-3"}),az.attachments.length," attachment",az.attachments.length>1?"s":""]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:az.attachments.map((a,c)=>(0,b.jsxs)("a",{href:`/api/email/${az.id}/attachment/${c}?workspace_id=${j}`,target:"_blank",rel:"noopener noreferrer",download:a.filename,className:"flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/50 px-2.5 py-1.5 text-xs hover:bg-muted transition-colors cursor-pointer",children:[(0,b.jsx)($.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-45",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:a.size<1024?`${a.size} B`:a.size<1048576?`${(a.size/1024).toFixed(1)} KB`:`${(a.size/1048576).toFixed(1)} MB`})]},a.key))})]})]})]}):(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select an email to view"})}),aN=D?(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{E(!1),G({})},children:(0,b.jsx)(ab.ArrowLeft,{className:"size-4"})}),(0,b.jsx)("span",{className:"text-sm font-medium",children:"New Email"})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aM})]}):v&&az?(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{w(null),y(null)},children:(0,b.jsx)(ab.ArrowLeft,{className:"size-4"})}),(0,b.jsx)("span",{className:"text-sm font-medium truncate",children:az.subject||"(no subject)"})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aM})]}):(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[at.length>1&&(0,b.jsxs)("div",{className:"relative px-3 pt-2 pb-1 border-b border-border/30",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aq(!X),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),(0,b.jsx)(al.default,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"shrink-0 p-0.5"}),children:aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,b.jsx)(A.TooltipContent,{children:"Copy address"})]})]}),X&&(0,b.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:at.map((a,c)=>(0,b.jsxs)("button",{type:"button",onClick:()=>{av(c),aq(!1)},className:(0,z.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",c===au?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,b.jsx)(ac.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.address}),"custom"===a.type&&(0,b.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},a.address))})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)("div",{className:"flex items-center gap-0.5 flex-1 min-w-0",children:[{id:"inbox",label:"Inbox"},{id:"sent",label:"Sent"},{id:"untrust",label:"Untrust"}].map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>ar(a.id),className:(0,z.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors",o===a.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[a.label,"inbox"===a.id&&"inbox"===o&&s>0&&(0,b.jsx)("span",{className:"ml-0.5 text-[10px] bg-blue-500 text-white rounded-full px-1 leading-none min-w-4 text-center",children:s})]},a.id))}),(0,b.jsx)(h.Button,{size:"icon-sm",variant:"ghost",onClick:()=>{G({}),E(!0),w(null)},disabled:0===at.length,children:(0,b.jsx)(ae.Plus,{className:"size-4"})})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aL})]});return(0,b.jsxs)(b.Fragment,{children:[n?aN:(0,b.jsx)(an.ResizablePanels,{storageKey:"email-panel-sizes",panels:[{defaultWidth:180,minWidth:120,maxWidth:240,children:aK},{defaultWidth:300,minWidth:200,maxWidth:480,children:aL},{children:aM,minWidth:300}]}),(0,b.jsx)(i.ConfirmDialog,{open:N,onOpenChange:O,title:"Delete email",description:"This will permanently delete this email.",loading:R,onConfirm:aD})]})}],221781)}];
|
|
1
|
+
module.exports=[221781,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(207058),e=a.i(506180),f=a.i(752792),g=a.i(588339),h=a.i(732254),i=a.i(22902),j=a.i(243703),k=a.i(163672),l=a.i(185077),m=a.i(277337),n=a.i(404943),o=a.i(724890),p=o.Extension.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:a=>{let b=a.style.textAlign;return this.options.alignments.includes(b)?b:this.options.defaultAlignment},renderHTML:a=>a.textAlign?{style:`text-align: ${a.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:a=>({commands:b})=>!!this.options.alignments.includes(a)&&this.options.types.map(c=>b.updateAttributes(c,{textAlign:a})).some(a=>a),unsetTextAlign:()=>({commands:a})=>this.options.types.map(b=>a.resetAttributes(b,"textAlign")).some(a=>a),toggleTextAlign:a=>({editor:b,commands:c})=>!!this.options.alignments.includes(a)&&(b.isActive({textAlign:a})?c.unsetTextAlign():c.setTextAlign(a))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),q=(a,b=0)=>{let c=[];return!a.children.length||b>20||Array.from(a.children).forEach(a=>{"SPAN"===a.tagName?c.push(a):a.children.length&&c.push(...q(a,b+1))}),c},r=o.Mark.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:a=>{var b;return!!a.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(b=a).children.length&&q(b).forEach(a=>{var b,c;let d=a.getAttribute("style"),e=null==(c=null==(b=a.parentElement)?void 0:b.closest("span"))?void 0:c.getAttribute("style");a.setAttribute("style",`${e};${d}`)}),{})}}]},renderHTML({HTMLAttributes:a}){return["span",(0,o.mergeAttributes)(this.options.HTMLAttributes,a),0]},addCommands(){return{toggleTextStyle:a=>({commands:b})=>b.toggleMark(this.name,a),removeEmptyTextStyle:()=>({tr:a})=>{let{selection:b}=a;return a.doc.nodesBetween(b.from,b.to,(b,c)=>{if(b.isTextblock)return!0;b.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(a=>!!a))||a.removeMark(c,c+b.nodeSize,this.type)}),!0}}}}),s=o.Extension.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:a=>{var b;let c=null!=(b=(0,o.getStyleProperty)(a,"background-color"))?b:a.style.backgroundColor;return null==c?void 0:c.replace(/['"]+/g,"")},renderHTML:a=>a.backgroundColor?{style:`background-color: ${a.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:a=>({chain:b})=>b().setMark("textStyle",{backgroundColor:a}).run(),unsetBackgroundColor:()=>({chain:a})=>a().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),t=o.Extension.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:a=>{var b;let c=null!=(b=(0,o.getStyleProperty)(a,"color"))?b:a.style.color;return null==c?void 0:c.replace(/['"]+/g,"")},renderHTML:a=>a.color?{style:`color: ${a.color}`}:{}}}}]},addCommands:()=>({setColor:a=>({chain:b})=>b().setMark("textStyle",{color:a}).run(),unsetColor:()=>({chain:a})=>a().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),u=o.Extension.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"font-family"))?b:a.style.fontFamily},renderHTML:a=>a.fontFamily?{style:`font-family: ${a.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:a=>({chain:b})=>b().setMark("textStyle",{fontFamily:a}).run(),unsetFontFamily:()=>({chain:a})=>a().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),v=o.Extension.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"font-size"))?b:a.style.fontSize},renderHTML:a=>a.fontSize?{style:`font-size: ${a.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:a=>({chain:b})=>b().setMark("textStyle",{fontSize:a}).run(),unsetFontSize:()=>({chain:a})=>a().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),w=o.Extension.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:a=>{var b;return null!=(b=(0,o.getStyleProperty)(a,"line-height"))?b:a.style.lineHeight},renderHTML:a=>a.lineHeight?{style:`line-height: ${a.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:a=>({chain:b})=>b().setMark("textStyle",{lineHeight:a}).run(),unsetLineHeight:()=>({chain:a})=>a().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})});o.Extension.create({name:"textStyleKit",addExtensions(){let a=[];return!1!==this.options.backgroundColor&&a.push(s.configure(this.options.backgroundColor)),!1!==this.options.color&&a.push(t.configure(this.options.color)),!1!==this.options.fontFamily&&a.push(u.configure(this.options.fontFamily)),!1!==this.options.fontSize&&a.push(v.configure(this.options.fontSize)),!1!==this.options.lineHeight&&a.push(w.configure(this.options.lineHeight)),!1!==this.options.textStyle&&a.push(r.configure(this.options.textStyle)),a}});var x=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,y=o.Node.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:a}){return["img",(0,o.mergeAttributes)(this.options.HTMLAttributes,a)]},parseMarkdown:(a,b)=>b.createNode("image",{src:a.href,title:a.title,alt:a.text}),renderMarkdown:a=>{var b,c,d,e,f,g;let h=null!=(c=null==(b=a.attrs)?void 0:b.src)?c:"",i=null!=(e=null==(d=a.attrs)?void 0:d.alt)?e:"",j=null!=(g=null==(f=a.attrs)?void 0:f.title)?g:"";return j?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:a,minWidth:b,minHeight:c,alwaysPreserveAspectRatio:d}=this.options.resize;return({node:e,getPos:f,HTMLAttributes:g,editor:h})=>{let i=document.createElement("img");Object.entries(g).forEach(([a,b])=>{if(null!=b)switch(a){case"width":case"height":break;default:i.setAttribute(a,b)}}),i.src=g.src;let j=new o.ResizableNodeView({element:i,editor:h,node:e,getPos:f,onResize:(a,b)=>{i.style.width=`${a}px`,i.style.height=`${b}px`},onCommit:(a,b)=>{let c=f();void 0!==c&&this.editor.chain().setNodeSelection(c).updateAttributes(this.name,{width:a,height:b}).run()},onUpdate:(a,b,c)=>a.type===e.type,options:{directions:a,min:{width:b,height:c},preserveAspectRatio:!0===d}}),k=j.dom;return k.style.visibility="hidden",k.style.pointerEvents="none",i.onload=()=>{k.style.visibility="",k.style.pointerEvents=""},j}},addCommands(){return{setImage:a=>({commands:b})=>b.insertContent({type:this.name,attrs:a})}},addInputRules(){return[(0,o.nodeInputRule)({find:x,type:this.type,getAttributes:a=>{let[,,b,c,d]=a;return{src:c,alt:b,title:d}}})]}}),z=a.i(75118),A=a.i(525132),B=a.i(647651);let C=(0,B.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]),D=(0,B.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),E=(0,B.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]),F=(0,B.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]),G=(0,B.default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),H=(0,B.default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]),I=(0,B.default)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]),J=(0,B.default)("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]),K=(0,B.default)("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]]),L=(0,B.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),M=(0,B.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),N=(0,B.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),O=(0,B.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]),P=(0,B.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);var Q=a.i(457655),Q=Q;function R({active:a,disabled:c,onClick:d,title:e,children:f}){return(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",disabled:c,onMouseDown:a=>a.preventDefault(),onClick:d,className:(0,z.cn)("text-muted-foreground/70",a&&"bg-accent text-foreground")}),children:f}),(0,b.jsx)(A.TooltipContent,{children:e})]})}function S(){return(0,b.jsx)("div",{className:"w-px h-4 bg-border/60 mx-0.5 shrink-0"})}function T({editor:a}){if(!a)return null;let c="size-3.5";return(0,b.jsxs)("div",{className:"flex items-center gap-0.5 px-3 py-1 overflow-x-auto",children:[(0,b.jsx)(R,{title:"Bold",active:a.isActive("bold"),onClick:()=>a.chain().focus().toggleBold().run(),children:(0,b.jsx)(C,{className:c})}),(0,b.jsx)(R,{title:"Italic",active:a.isActive("italic"),onClick:()=>a.chain().focus().toggleItalic().run(),children:(0,b.jsx)(D,{className:c})}),(0,b.jsx)(R,{title:"Underline",active:a.isActive("underline"),onClick:()=>a.chain().focus().toggleUnderline().run(),children:(0,b.jsx)(E,{className:c})}),(0,b.jsx)(R,{title:"Strikethrough",active:a.isActive("strike"),onClick:()=>a.chain().focus().toggleStrike().run(),children:(0,b.jsx)(F,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Heading 1",active:a.isActive("heading",{level:1}),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),children:(0,b.jsx)(O,{className:c})}),(0,b.jsx)(R,{title:"Heading 2",active:a.isActive("heading",{level:2}),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),children:(0,b.jsx)(P,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Bullet List",active:a.isActive("bulletList"),onClick:()=>a.chain().focus().toggleBulletList().run(),children:(0,b.jsx)(G,{className:c})}),(0,b.jsx)(R,{title:"Ordered List",active:a.isActive("orderedList"),onClick:()=>a.chain().focus().toggleOrderedList().run(),children:(0,b.jsx)(H,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Align Left",active:a.isActive({textAlign:"left"}),onClick:()=>a.chain().focus().setTextAlign("left").run(),children:(0,b.jsx)(I,{className:c})}),(0,b.jsx)(R,{title:"Align Center",active:a.isActive({textAlign:"center"}),onClick:()=>a.chain().focus().setTextAlign("center").run(),children:(0,b.jsx)(J,{className:c})}),(0,b.jsx)(R,{title:"Align Right",active:a.isActive({textAlign:"right"}),onClick:()=>a.chain().focus().setTextAlign("right").run(),children:(0,b.jsx)(K,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:a.isActive("link")?"Remove Link":"Insert Link",active:a.isActive("link"),onClick:()=>{if(a.isActive("link"))return void a.chain().focus().unsetLink().run();let b=window.prompt("URL");b&&a.chain().focus().extendMarkRange("link").setLink({href:b}).run()},children:a.isActive("link")?(0,b.jsx)(M,{className:c}):(0,b.jsx)(L,{className:c})}),(0,b.jsx)(R,{title:"Insert Image",onClick:()=>{let b=window.prompt("Image URL");b&&a.chain().focus().setImage({src:b}).run()},children:(0,b.jsx)(N,{className:c})}),(0,b.jsx)(S,{}),(0,b.jsx)(R,{title:"Horizontal Rule",onClick:()=>a.chain().focus().setHorizontalRule().run(),children:(0,b.jsx)(Q.default,{className:c})})]})}var U=a.i(334235),V=a.i(921584),W=a.i(17239),X=a.i(518828),Y=a.i(16831),Z=a.i(546257),$=a.i(390759);function _({fromAddress:d,onSend:e,onDiscard:f,initialTo:g="",initialSubject:i="",initialBody:o="",initialAttachments:q=[],inReplyTo:s,references:u}){let[v,w]=(0,c.useState)(g),[x,z]=(0,c.useState)(i),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(q),[F,G]=(0,c.useState)(!1),H=(0,c.useRef)(null),I=(0,j.useEditor)({immediatelyRender:!1,content:o||void 0,extensions:[k.default.configure({link:!1,underline:!1}),l.default.configure({placeholder:"Write your email..."}),m.default,n.default.configure({autolink:!0,openOnClick:!1,linkOnPaste:!0}),p.configure({types:["heading","paragraph"]}),r,t,y.configure({inline:!0,allowBase64:!0})],editorProps:{attributes:{class:"text-sm max-w-none focus:outline-none min-h-50 px-4 py-3"}}}),J=async()=>{if(v.trim()&&x.trim()&&I){C(!0);try{let a=I.getHTML();await e(v.trim(),x.trim(),a,D,s||u?{inReplyTo:s,references:u}:void 0)&&(w(""),z(""),E([]),I.commands.clearContent())}finally{C(!1)}}},K=async b=>{let c=b.target.files;if(c&&0!==c.length){G(!0);try{let{uploadEmailAttachment:b}=await a.A(81396);for(let a of Array.from(c)){if(a.size>0xa00000){V.toast.error(`${a.name} exceeds 10 MB limit`);continue}let c=new URLSearchParams(window.location.search).get("workspace_id")??"",d=await b(a,c);E(a=>[...a,d])}}catch{V.toast.error("Failed to upload attachment")}finally{G(!1),H.current&&(H.current.value="")}}};return(0,b.jsxs)("div",{className:"flex flex-col h-full w-full min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2",children:[(0,b.jsx)("h3",{className:"text-sm font-heading font-medium tracking-tight",children:"New Email"}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground h-7 px-2",onClick:f,disabled:B,children:[(0,b.jsx)(X.X,{className:"size-3 mr-1"}),"Discard"]}),(0,b.jsxs)(h.Button,{size:"sm",className:"text-xs h-7 px-3",onClick:J,disabled:B||!v.trim()||!x.trim(),children:[B?(0,b.jsx)(Y.Loader2,{className:"size-3 mr-1 animate-spin"}):(0,b.jsx)(W.Send,{className:"size-3 mr-1"}),"Send"]})]})]}),(0,b.jsxs)("div",{className:"border-b border-border/30 px-4 py-2.5 space-y-1 min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,b.jsx)("span",{className:"text-muted-foreground truncate min-w-0",children:d})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,b.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,b.jsx)(U.Input,{type:"email",value:v,onChange:a=>w(a.target.value),placeholder:"recipient@example.com",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:B})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"Subject"}),(0,b.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,b.jsx)(U.Input,{value:x,onChange:a=>z(a.target.value),placeholder:"Email subject",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:B})})]})]}),(0,b.jsxs)("div",{className:"flex items-center border-b border-border/30",children:[(0,b.jsx)(T,{editor:I}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-2 border-l border-border/30",children:[(0,b.jsx)("input",{ref:H,type:"file",multiple:!0,className:"hidden",onChange:K}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",disabled:F,onMouseDown:a=>a.preventDefault(),onClick:()=>H.current?.click(),className:"text-muted-foreground/70"}),children:F?(0,b.jsx)(Y.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(Z.Paperclip,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Attach file"})]})]})]}),D.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 px-4 py-2 border-b border-border/30",children:D.map(a=>{var c;return(0,b.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs",children:[(0,b.jsx)($.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:(c=a.size)<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`}),(0,b.jsx)("button",{type:"button",onClick:()=>{var b;return b=a.key,void E(a=>a.filter(a=>a.key!==b))},className:"text-muted-foreground hover:text-foreground ml-0.5 cursor-pointer",children:(0,b.jsx)(X.X,{className:"size-3"})})]},a.key)})}),(0,b.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar",children:(0,b.jsx)(j.EditorContent,{editor:I})})]})}var aa=a.i(25668),ab=a.i(321932),ac=a.i(606896),ad=a.i(109578),ae=a.i(552012),af=a.i(415584);let ag=(0,B.default)("forward",[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]),ah=(0,B.default)("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]);var ai=a.i(584126),aj=a.i(549931);let ak=(0,B.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var al=a.i(28429),am=a.i(586220),an=a.i(511238),ao=a.i(135510);function ap(a){let b=new Date(a),c=Math.floor((new Date().getTime()-b.getTime())/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;let d=Math.floor(c/60);if(d<24)return`${d}h ago`;let e=Math.floor(d/24);return e<7?`${e}d ago`:b.toLocaleDateString(void 0,{month:"short",day:"numeric"})}a.s(["default",0,function(){let a=(0,d.useParams)().id,{workspaceId:j}=(0,e.useWorkspace)(),{agents:k,subscribeWs:l}=(0,f.useAgentContext)(),m=k.find(b=>b.id===a),n=(0,am.useIsMobile)(),[o,p]=(0,c.useState)("inbox"),[q,r]=(0,c.useState)([]),s=(0,c.useMemo)(()=>q.filter(a=>"unread"===a.status).length,[q]),[t,u]=(0,c.useState)(!0),[v,w]=(0,c.useState)(null),[x,y]=(0,c.useState)(null),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(!1),[F,G]=(0,c.useState)({}),[H,I]=(0,c.useState)([]),[J,K]=(0,c.useState)(null),[L,M]=(0,c.useState)({}),[N,O]=(0,c.useState)(!1),[P,Q]=(0,c.useState)(null),[R,S]=(0,c.useState)(!1),[T,U]=(0,c.useState)([]),[X,aq]=(0,c.useState)(!1),ar=(0,c.useCallback)(a=>{p(a),r([]),w(null),y(null),E(!1)},[]),as=m?.email_handle?`${m.email_handle}@alook.ai`:"",at=[...as?[{type:"alook",address:as}]:[],...T.map(a=>({type:"custom",address:a.email_address,accountId:a.id}))],[au,av]=(0,c.useState)(0),aw=at[au]??at[0]??null,ax=aw?.address??"",ay=aw?.type==="custom"?aw.accountId:void 0,az=q.find(a=>a.id===v)??null,aA=(0,c.useCallback)(async(b,c)=>{u(!0);try{let d=await (0,g.listEmails)(a,j,b,c);r(d)}catch{V.toast.error("Failed to load emails")}finally{u(!1)}},[a,j]);(0,c.useEffect)(()=>{(0,g.listEmailAccounts)(a,j).then(U).catch(()=>{})},[a,j]),(0,c.useEffect)(()=>{aA(o,ax)},[o,ax,aA]),(0,c.useEffect)(()=>l(b=>{("email.received"===b.type&&b.agentId===a||"email.sent"===b.type&&b.agentId===a)&&aA(o,ax)}),[l,a,o,ax,aA]);let aB=async a=>{E(!1),w(a),y(null),C(!0),I([]),K(null),M({});try{let[b,c]=await Promise.all([(0,g.getEmailBody)(a,j),(0,g.getEmailThread)(a,j).catch(()=>[])]);y(b),I(c);let d=q.find(b=>b.id===a);d&&"unread"===d.status&&(0,g.updateEmailStatus)(a,j,"read").then(()=>{r(b=>b.map(b=>b.id===a?{...b,status:"read"}:b))}).catch(()=>{r(b=>b.map(b=>b.id===a?{...b,status:"unread"}:b))})}catch{y({content:"(body not available)",isHtml:!1})}finally{C(!1)}},aC=async a=>{if(J===a)return void K(null);if(K(a),!L[a])try{let b=await (0,g.getEmailBody)(a,j);M(c=>({...c,[a]:b}))}catch{M(b=>({...b,[a]:{content:"(body not available)",isHtml:!1}}))}},aD=async()=>{if(P){S(!0);try{await (0,g.deleteEmail)(P,j),r(a=>a.filter(a=>a.id!==P)),v===P&&(w(null),y(null)),V.toast.success("Email deleted")}catch{V.toast.error("Failed to delete email")}finally{S(!1),O(!1),Q(null)}}},aE=async(b,c,d,e,f)=>{try{return await (0,g.sendEmail)(a,b,c,d,j,e.length>0?e:void 0,f,ay),V.toast.success("Email sent"),E(!1),ar("sent"),!0}catch{return V.toast.error("Failed to send email"),!1}},aF=a=>`<br/><br/><div style="border-left: 2px solid #ccc; padding-left: 12px; margin-left: 0; color: #666;"><p><strong>From:</strong> ${a.from_email}<br/><strong>To:</strong> ${a.to_email}<br/><strong>Date:</strong> ${new Date(a.created_at).toLocaleString()}<br/><strong>Subject:</strong> ${a.subject}</p>`+(a.html_body?a.html_body:x?.isHtml?x.content:`<pre>${x?.content??""}</pre>`)+"</div>",aG=a=>({inReplyTo:a.message_id||void 0,references:[a.references,a.message_id].filter(Boolean).join(" ").trim()||void 0}),[aH,aI]=(0,c.useState)(!1),aJ=async()=>{if(ax)try{await navigator.clipboard.writeText(ax),aI(!0),setTimeout(()=>aI(!1),1500)}catch{V.toast.error("Failed to copy")}},aK=(0,b.jsxs)("div",{className:"flex h-full flex-col",children:[at.length>0?(0,b.jsx)("div",{className:"px-3 pt-3 pb-1 relative",children:1===at.length?(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsxs)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"group flex items-center gap-1.5 text-left cursor-pointer w-full"}),children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500 shrink-0"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/0 group-hover:text-muted-foreground/60 shrink-0 transition-colors"})]}),(0,b.jsx)(A.TooltipContent,{children:"Click to copy"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-1 w-full",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aq(!X),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),(0,b.jsx)(al.ChevronDown,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"shrink-0 p-0.5"}),children:aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,b.jsx)(A.TooltipContent,{children:"Copy address"})]})]}),X&&(0,b.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:at.map((a,c)=>(0,b.jsxs)("button",{type:"button",onClick:()=>{av(c),aq(!1)},className:(0,z.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",c===au?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,b.jsx)(ac.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.address}),"custom"===a.type&&(0,b.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},a.address))})]})}):(0,b.jsx)("div",{className:"px-3 pt-3 pb-1",children:(0,b.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"No email configured"})}),(0,b.jsx)("div",{className:"p-2",children:(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsxs)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{size:"sm",className:"w-full justify-start text-xs h-8 gap-1.5",onClick:()=>{G({}),E(!0),w(null)},disabled:0===at.length}),children:[(0,b.jsx)(ae.Plus,{className:"size-3.5"}),"New Email"]}),(0,b.jsx)(A.TooltipContent,{children:0===at.length?"Configure an email in agent settings to send emails":"Compose new email"})]})}),(0,b.jsxs)("nav",{className:"flex flex-col gap-0.5 px-2",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>ar("inbox"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","inbox"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(ad.Inbox,{className:"size-4 shrink-0"}),"Inbox","inbox"===o&&s>0&&(0,b.jsx)("span",{className:"ml-auto text-xs bg-blue-500 text-white rounded-full px-1.5 py-0.5 leading-none min-w-5 text-center",children:s})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>ar("sent"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","sent"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(W.Send,{className:"size-4 shrink-0"}),"Sent"]}),(0,b.jsxs)("button",{type:"button",onClick:()=>ar("untrust"),className:(0,z.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","untrust"===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,b.jsx)(ak,{className:"size-4 shrink-0"}),"Untrust"]})]})]}),aL=(0,b.jsx)("div",{className:(0,z.cn)("h-full thin-scrollbar",q.length>0&&!t?"overflow-y-auto":"overflow-hidden"),children:t?(0,b.jsx)(b.Fragment,{children:Array.from({length:3}).map((a,c)=>(0,b.jsxs)("div",{className:"px-4 py-3 border-b border-border/30",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[(0,b.jsx)(aa.Skeleton,{className:"h-3.5 w-32"}),(0,b.jsx)(aa.Skeleton,{className:"h-2.5 w-10"})]}),(0,b.jsx)(aa.Skeleton,{className:"h-3.5 w-48 mb-1.5"}),(0,b.jsx)(aa.Skeleton,{className:"h-4 w-16 rounded-full"})]},c))}):0===q.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center h-full animate-[fade-up_400ms_ease-out_both]",children:[(0,b.jsx)(ac.Mail,{className:"size-8 text-muted-foreground mb-3"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"inbox"===o?"No emails from trusted senders":"sent"===o?"No emails sent yet":"No untrusted emails"})]}):q.map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>aB(a.id),className:(0,z.cn)("w-full text-left px-4 py-3 border-b border-border/30 transition-colors duration-150 cursor-pointer",v===a.id?"bg-accent/60":"hover:bg-accent/30"),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[(0,b.jsx)("p",{className:(0,z.cn)("text-sm truncate","unread"===a.status?"font-semibold":"font-medium text-muted-foreground"),children:"sent"===o?a.to_email:a.from_email}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:["sent"!==o&&(0,b.jsx)("span",{className:(0,z.cn)("text-[10px] rounded-full px-1.5 py-0.5 leading-none font-medium","unread"===a.status?"bg-blue-500/15 text-blue-600 dark:text-blue-400":"bg-muted text-muted-foreground"),children:"unread"===a.status?"unread":"read"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:ap(a.created_at)})]})]}),(0,b.jsx)("p",{className:(0,z.cn)("text-[13px] truncate","unread"===a.status?"text-foreground":"text-muted-foreground"),children:a.subject||"(no subject)"})]},a.id))}),aM=(0,b.jsx)("div",{className:"h-full overflow-auto flex flex-col min-w-0 thin-scrollbar",children:D?(0,b.jsx)(_,{fromAddress:ax,onSend:aE,onDiscard:()=>{E(!1),G({})},initialTo:F.to,initialSubject:F.subject,initialBody:F.body,initialAttachments:F.attachments,inReplyTo:F.inReplyTo,references:F.references},JSON.stringify(F)):az?(0,b.jsxs)("div",{className:"flex flex-col h-full md:min-w-100 max-w-3xl mx-auto w-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-border/40 px-4 py-1.5",children:["sent"!==o&&(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let a;return a=az.subject.startsWith("Re:")?az.subject:`Re: ${az.subject}`,void(w(null),G({to:az.from_email,subject:a,body:aF(az),...aG(az)}),E(!0))}}),children:(0,b.jsx)(ah,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Reply"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let a;return a=az.subject.startsWith("Fwd:")?az.subject:`Fwd: ${az.subject}`,void(w(null),G({subject:a,body:aF(az),attachments:az.attachments??[],...aG(az)}),E(!0))}}),children:(0,b.jsx)(ag,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Forward"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-destructive",onClick:()=>{Q(az.id),O(!0)}}),children:(0,b.jsx)(af.Trash2,{className:"size-3.5"})}),(0,b.jsx)(A.TooltipContent,{children:"Delete"})]})]}),H.length>0&&(0,b.jsx)("div",{className:"border-b border-border/30",children:H.map(a=>(0,b.jsxs)("div",{className:"border-b border-border/20 last:border-b-0",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aC(a.id),className:"w-full flex items-center gap-2 px-5 py-2.5 text-left hover:bg-accent/30 transition-colors cursor-pointer",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:J===a.id?"▾":"▸"}),(0,b.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:a.from_email}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:ap(a.created_at)})]}),J===a.id&&(0,b.jsxs)("div",{className:"px-5 pb-3",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:a.subject}),L[a.id]?L[a.id].isHtml?(0,b.jsx)(ao.EmailBodyFrame,{html:L[a.id].content,className:"max-w-full text-sm"}):(0,b.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:L[a.id].content}):(0,b.jsx)(Y.Loader2,{className:"size-3 animate-spin text-muted-foreground"})]})]},a.id))}),(0,b.jsxs)("div",{className:"p-5",children:[(0,b.jsx)("h2",{className:"text-lg font-heading font-semibold tracking-tight mb-1",children:az.subject||"(no subject)"}),(0,b.jsxs)("div",{className:"text-sm space-y-1 mb-5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,b.jsx)("span",{children:az.from_email})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,b.jsx)("span",{children:az.to_email})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"sent"===o?"Sent":"Received"}),(0,b.jsx)("span",{className:"text-muted-foreground",children:new Date(az.created_at).toLocaleString()})]})]}),B?(0,b.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,b.jsx)(Y.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}):az.html_body?(0,b.jsx)(ao.EmailBodyFrame,{html:az.html_body,className:"max-w-full"}):x?.isHtml?(0,b.jsx)(ao.EmailBodyFrame,{html:x.content,className:"max-w-full"}):(0,b.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:x?.content}),az.attachments&&az.attachments.length>0&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,b.jsx)(Z.Paperclip,{className:"size-3"}),az.attachments.length," attachment",az.attachments.length>1?"s":""]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:az.attachments.map((a,c)=>(0,b.jsxs)("a",{href:`/api/email/${az.id}/attachment/${c}?workspace_id=${j}`,target:"_blank",rel:"noopener noreferrer",download:a.filename,className:"flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/50 px-2.5 py-1.5 text-xs hover:bg-muted transition-colors cursor-pointer",children:[(0,b.jsx)($.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-45",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:a.size<1024?`${a.size} B`:a.size<1048576?`${(a.size/1024).toFixed(1)} KB`:`${(a.size/1048576).toFixed(1)} MB`})]},a.key))})]})]})]}):(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select an email to view"})}),aN=D?(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{E(!1),G({})},children:(0,b.jsx)(ab.ArrowLeft,{className:"size-4"})}),(0,b.jsx)("span",{className:"text-sm font-medium",children:"New Email"})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aM})]}):v&&az?(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{w(null),y(null)},children:(0,b.jsx)(ab.ArrowLeft,{className:"size-4"})}),(0,b.jsx)("span",{className:"text-sm font-medium truncate",children:az.subject||"(no subject)"})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aM})]}):(0,b.jsxs)("div",{className:"flex flex-col h-full",children:[at.length>1&&(0,b.jsxs)("div",{className:"relative px-3 pt-2 pb-1 border-b border-border/30",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aq(!X),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ax}),(0,b.jsx)(al.ChevronDown,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(A.Tooltip,{children:[(0,b.jsx)(A.TooltipTrigger,{render:(0,b.jsx)("button",{type:"button",onClick:aJ,className:"shrink-0 p-0.5"}),children:aH?(0,b.jsx)(aj.Check,{className:"size-2.5 text-green-500"}):(0,b.jsx)(ai.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,b.jsx)(A.TooltipContent,{children:"Copy address"})]})]}),X&&(0,b.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:at.map((a,c)=>(0,b.jsxs)("button",{type:"button",onClick:()=>{av(c),aq(!1)},className:(0,z.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",c===au?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,b.jsx)(ac.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.address}),"custom"===a.type&&(0,b.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},a.address))})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-b border-border/50 px-3 py-2",children:[(0,b.jsx)("div",{className:"flex items-center gap-0.5 flex-1 min-w-0",children:[{id:"inbox",label:"Inbox"},{id:"sent",label:"Sent"},{id:"untrust",label:"Untrust"}].map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>ar(a.id),className:(0,z.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors",o===a.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[a.label,"inbox"===a.id&&"inbox"===o&&s>0&&(0,b.jsx)("span",{className:"ml-0.5 text-[10px] bg-blue-500 text-white rounded-full px-1 leading-none min-w-4 text-center",children:s})]},a.id))}),(0,b.jsx)(h.Button,{size:"icon-sm",variant:"ghost",onClick:()=>{G({}),E(!0),w(null)},disabled:0===at.length,children:(0,b.jsx)(ae.Plus,{className:"size-4"})})]}),(0,b.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:aL})]});return(0,b.jsxs)(b.Fragment,{children:[n?aN:(0,b.jsx)(an.ResizablePanels,{storageKey:"email-panel-sizes",panels:[{defaultWidth:180,minWidth:120,maxWidth:240,children:aK},{defaultWidth:300,minWidth:200,maxWidth:480,children:aL},{children:aM,minWidth:300}]}),(0,b.jsx)(i.ConfirmDialog,{open:N,onOpenChange:O,title:"Delete email",description:"This will permanently delete this email.",loading:R,onConfirm:aD})]})}],221781)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_web_src_app_%28app%29_w_%5Bslug%5D_agents_%5Bid%5D_email_page_tsx_09mq1-g._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[812187,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(207058),e=a.i(26822),f=a.i(752792),g=a.i(506180),h=a.i(732254),i=a.i(22902),j=a.i(654461),k=a.i(75118),l=a.i(647651);let m=(0,l.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var n=a.i(137993),o=a.i(889624),p=a.i(588339),q=a.i(921584),r=a.i(224226);a.i(735132);var s=a.i(628508),t=a.i(325848);function u({ratio:a,size:c=16,stroke:d=1.5}){let e=(c-d)/2,f=2*Math.PI*e,g=(a<=0?0:a>=1?1:Math.log1p(99*a)/Math.log(100))*f;return(0,b.jsxs)("svg",{width:c,height:c,className:"shrink-0 -rotate-90","aria-hidden":!0,children:[(0,b.jsx)("circle",{cx:c/2,cy:c/2,r:e,fill:"none",stroke:"currentColor",strokeWidth:d,className:"text-border"}),(0,b.jsx)("circle",{cx:c/2,cy:c/2,r:e,fill:"none",stroke:"currentColor",strokeWidth:d,strokeDasharray:`${g} ${f-g}`,strokeLinecap:"round",className:(0,k.cn)("transition-all duration-300",a>.9?"text-destructive/70":a>.7?"text-yellow-500/50":"text-muted-foreground/30")})]})}function v({agent:a,runtimes:d,modelOptions:e,onSave:f,onCancel:i,saving:l}){let{workspaceId:w}=(0,g.useWorkspace)(),[x,y]=(0,c.useState)("general"),[z,A]=(0,c.useState)(a.name??""),[B,C]=(0,c.useState)(a.description??""),[D,E]=(0,c.useState)(a.runtime_id??""),[F,G]=(0,c.useState)(()=>(0,t.parseAvatarUrl)(a.avatar_url)??t.DEFAULT_CONFIG),[H,I]=(0,c.useState)(()=>{let b=a.runtime_config;return"string"==typeof b?.model?b.model:""}),[J,K]=(0,c.useState)(a.instructions??""),[L,M]=(0,c.useState)(a.instructions??""),N=(0,c.useRef)(J);(0,c.useEffect)(()=>{N.current=J},[J]);let O=(0,c.useRef)(L);(0,c.useEffect)(()=>{O.current=L},[L]);let P=(0,c.useRef)(null),Q=(0,c.useRef)(!1),R=(0,c.useRef)(()=>{}),S=(0,c.useCallback)(async()=>{if(Q.current)return;let b=N.current;if(b!==O.current){Q.current=!0;try{await (0,p.updateAgent)(a.id,{instructions:b},w),M(b)}catch(a){q.toast.error(a instanceof Error?a.message:"Failed to save instructions")}finally{Q.current=!1,N.current!==O.current&&R.current()}}},[a.id,w]),T=(0,c.useCallback)(()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(S,500)},[S]);(0,c.useEffect)(()=>{R.current=T},[T]);let U=(0,c.useCallback)(a=>{K(a),T()},[T]);(0,c.useEffect)(()=>{let b=()=>{if(P.current&&clearTimeout(P.current),N.current!==O.current){let b=new URLSearchParams({workspace_id:w});fetch(`/api/agents/${a.id}?${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:N.current}),keepalive:!0})}};return window.addEventListener("beforeunload",b),()=>window.removeEventListener("beforeunload",b)},[a.id,w]),(0,c.useEffect)(()=>()=>{if(P.current&&clearTimeout(P.current),N.current!==O.current){let b=new URLSearchParams({workspace_id:w});fetch(`/api/agents/${a.id}?${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:N.current}),keepalive:!0})}},[a.id,w]);let V=d.find(a=>a.id===D),W=V&&e?e[V.provider]??[]:[],X=async a=>{a.preventDefault(),await f({name:z,description:B,runtime_id:D,runtime_config:H?{model:H}:{},avatar_url:(0,t.serializeAvatarConfig)(F)})},Y=[{id:"general",label:"General"},{id:"instruction",label:"Instruction"},{id:"email",label:"Email"},{id:"permission",label:"Permission"}],Z="general"===x||"email"===x,$=J.length/5e4;return(0,b.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,b.jsx)("nav",{className:"w-48 shrink-0 border-r border-border/50 py-3 px-2 hidden md:block",children:Y.map(a=>(0,b.jsx)("button",{type:"button",onClick:()=>y(a.id),className:(0,k.cn)("w-full rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",x===a.id?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:a.label},a.id))}),(0,b.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,b.jsx)("div",{className:"px-4 pt-2 md:hidden",children:(0,b.jsx)(j.Tabs,{className:"items-center",value:x,onValueChange:a=>y(a),children:(0,b.jsx)(j.TabsList,{className:"h-auto gap-1",children:Y.map(a=>(0,b.jsx)(j.TabsTrigger,{value:a.id,children:a.label},a.id))})})}),"instruction"===x?(0,b.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,b.jsx)("div",{className:"flex-1 px-6 pt-4 pb-4 overflow-y-auto",children:(0,b.jsx)(o.MarkdownEditor,{value:J,onChange:U,placeholder:"Write instructions for this agent...",minHeight:"calc(100vh - 240px)",contentType:"markdown",variant:"seamless"})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-6 py-3 border-t border-border/50",children:[(0,b.jsx)(u,{ratio:$}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Agent-specific instruction. Your global instruction is prepended automatically."})]})]}):(0,b.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar px-5 py-6",children:Z?(0,b.jsxs)("form",{onSubmit:X,className:"mx-auto max-w-md space-y-4",children:["general"===x&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s.AvatarPickerDialog,{config:F,onChange:G}),(0,b.jsx)(r.GeneralFields,{name:z,setName:A,description:B,setDescription:C,model:H,setModel:I,runtimeId:D,setRuntimeId:E,runtimes:d,providerModels:W}),(0,b.jsx)(r.PinToggle,{agentId:a.id})]}),"email"===x&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"rounded-lg border border-border/50 bg-muted/30 px-4 py-3",children:[(0,b.jsxs)("div",{className:"mb-2.5 flex items-center gap-1.5",children:[(0,b.jsx)(m,{className:"size-3 text-muted-foreground/60"}),(0,b.jsx)("span",{className:"text-xs font-medium text-muted-foreground/60",children:"Set at creation"})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"Email"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a.email_handle?`${a.email_handle}@alook.ai`:"Not configured"})]})]}),(0,b.jsx)(n.CustomEmailForm,{agentId:a.id,workspaceId:a.workspace_id}),a.email_handle&&(0,b.jsx)("div",{className:"border-t border-border/50 pt-4 mt-4",children:(0,b.jsx)(r.AllowedSendersTab,{agentId:a.id})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),(0,b.jsx)(h.Button,{type:"submit",size:"sm",disabled:l||!z,children:l?"Saving...":"Save"})]})]}):(0,b.jsx)(r.AgentAccessTab,{agentId:a.id,ownerId:a.owner_id})})]})]})}var w=a.i(953528),x=a.i(25668),y=a.i(191525),z=a.i(426619),A=a.i(858767),B=a.i(304377),C=a.i(606896),D=a.i(113010);let E=(0,l.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var F=a.i(372443),G=a.i(415584),H=a.i(110025),I=a.i(518828),J=a.i(867561),K=a.i(525132);a.s(["default",0,function({children:a}){let j=(0,d.useParams)(),k=(0,d.useRouter)(),l=(0,d.usePathname)(),{slug:m}=(0,g.useWorkspace)(),n=(0,d.useSearchParams)(),o=j.id,q=!!n.get("conv"),r=l.includes("/activity")||q?"activity":l.includes("/meetings")?"meetings":l.includes("/email")?"email":l.includes("/files")?"files":"chat",{agents:s,runtimes:t,handleDeleteAgent:u,handleUpdateAgent:L}=(0,f.useAgentContext)(),M=s.find(a=>a.id===o),N=M?t.find(a=>a.id===M.runtime_id):null,O=N?.status==="online",{activeTaskCounts:P}=(0,f.useAgentContext)(),Q=P[o]??0,[R,S]=(0,c.useState)(!1),[T,U]=(0,c.useState)(!1),[V,W]=(0,c.useState)(!1),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)({});return(0,c.useEffect)(()=>{(0,p.fetchModelOptions)().then($).catch(()=>{})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border/50 px-3 md:px-5 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[M?(0,b.jsx)(y.AgentStatusBadge,{isOnline:O,taskCount:Q,agentId:o}):(0,b.jsx)(x.Skeleton,{className:"size-2 rounded-full shrink-0"}),M?(0,b.jsxs)(K.Tooltip,{children:[(0,b.jsx)(K.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:`/w/${m}/agents/${o}`,onClick:()=>S(!1),className:"text-sm font-medium truncate hover:text-foreground/80 transition-colors"}),children:M.name}),(0,b.jsx)(K.TooltipContent,{children:M.description||"No description"})]}):(0,b.jsx)(x.Skeleton,{className:"h-3.5 w-24"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["/ ",R?"Settings":({email:"Email",meetings:"Meetings",activity:"Activity",files:"Files"})[r]??"Chat"]})]}),M?(0,b.jsx)("div",{className:"flex items-center gap-0.5 shrink-0",children:R?(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground h-7 gap-1 px-2",onClick:()=>S(!1),children:[(0,b.jsx)(I.X,{className:"size-3"}),"Cancel"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"hidden sm:flex items-center gap-0.5",children:[(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"chat"===r?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(D.MessageSquare,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"chat"===r?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Chat"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/email`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"email"===r?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(C.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"email"===r?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Email"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/meetings`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"meetings"===r?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(H.Video,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"meetings"===r?"max-w-20 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Meetings"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/activity`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"activity"===r?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(B.History,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"activity"===r?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Activity"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/files`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"files"===r?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(z.FolderOpen,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"files"===r?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Files"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/threads?agentId=${o}`,className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all",children:[(0,b.jsx)(A.GitBranch,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Threads"})]}),(0,b.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,b.jsxs)("button",{className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all",onClick:()=>S(!0),children:[(0,b.jsx)(F.Pencil,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-12 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Edit"})]}),(0,b.jsxs)("button",{className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-destructive transition-all",onClick:()=>W(!0),children:[(0,b.jsx)(G.Trash2,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Remove"})]})]}),(0,b.jsx)("div",{className:"sm:hidden",children:(0,b.jsxs)(J.DropdownMenu,{children:[(0,b.jsx)(J.DropdownMenuTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground"}),children:(0,b.jsx)(E,{className:"size-4"})}),(0,b.jsxs)(J.DropdownMenuContent,{align:"end",sideOffset:6,children:["chat"!==r&&(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}`),children:[(0,b.jsx)(D.MessageSquare,{className:"size-3.5"})," Chat"]}),"email"!==r&&(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/email`),children:[(0,b.jsx)(C.Mail,{className:"size-3.5"})," Email"]}),"meetings"!==r&&(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/meetings`),children:[(0,b.jsx)(H.Video,{className:"size-3.5"})," Meetings"]}),"activity"!==r&&(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/activity`),children:[(0,b.jsx)(B.History,{className:"size-3.5"})," Activity"]}),"files"!==r&&(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/files`),children:[(0,b.jsx)(z.FolderOpen,{className:"size-3.5"})," Files"]}),(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/threads?agentId=${o}`),children:[(0,b.jsx)(A.GitBranch,{className:"size-3.5"}),"Threads"]}),(0,b.jsx)(J.DropdownMenuSeparator,{}),(0,b.jsxs)(J.DropdownMenuItem,{onClick:()=>S(!0),children:[(0,b.jsx)(F.Pencil,{className:"size-3.5"}),"Edit"]}),(0,b.jsx)(J.DropdownMenuSeparator,{}),(0,b.jsxs)(J.DropdownMenuItem,{variant:"destructive",onClick:()=>W(!0),children:[(0,b.jsx)(G.Trash2,{className:"size-3.5"}),"Remove"]})]})]})})]})}):(0,b.jsx)("div",{className:"h-7 shrink-0"})]}),R&&M?(0,b.jsx)(v,{agent:M,runtimes:t,modelOptions:Z,saving:T,onCancel:()=>S(!1),onSave:async a=>{U(!0);try{let b=await L(M.id,a);return b&&S(!1),b}finally{U(!1)}}}):(0,b.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:["chat"===r&&(0,b.jsx)(w.ChannelBar,{}),a]}),M&&(0,b.jsx)(i.ConfirmDialog,{open:V,onOpenChange:W,title:"Remove agent",description:`This will permanently delete "${M.name}" and all its conversations.`,loading:X,onConfirm:async()=>{Y(!0);try{await u(M.id)&&k.push(`/w/${m}/home`)}finally{Y(!1),W(!1)}}})]})}],812187)}];
|
|
1
|
+
module.exports=[812187,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(207058),e=a.i(26822),f=a.i(752792),g=a.i(506180),h=a.i(732254),i=a.i(22902),j=a.i(654461),k=a.i(75118),l=a.i(647651);let m=(0,l.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var n=a.i(137993),o=a.i(334235),p=a.i(76592),q=a.i(889624),r=a.i(984078),s=a.i(588339),t=a.i(921584),u=a.i(224226);a.i(735132);var v=a.i(628508),w=a.i(325848);function x({ratio:a,size:c=16,stroke:d=1.5}){let e=(c-d)/2,f=2*Math.PI*e,g=(a<=0?0:a>=1?1:Math.log1p(99*a)/Math.log(100))*f;return(0,b.jsxs)("svg",{width:c,height:c,className:"shrink-0 -rotate-90","aria-hidden":!0,children:[(0,b.jsx)("circle",{cx:c/2,cy:c/2,r:e,fill:"none",stroke:"currentColor",strokeWidth:d,className:"text-border"}),(0,b.jsx)("circle",{cx:c/2,cy:c/2,r:e,fill:"none",stroke:"currentColor",strokeWidth:d,strokeDasharray:`${g} ${f-g}`,strokeLinecap:"round",className:(0,k.cn)("transition-all duration-300",a>.9?"text-destructive/70":a>.7?"text-yellow-500/50":"text-muted-foreground/30")})]})}function y({model:a,setModel:c,runtimeId:d,setRuntimeId:e,runtimes:f,providerModels:g}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(p.Label,{className:"text-xs text-muted-foreground",children:"Runtime"}),(0,b.jsx)(r.RuntimeSelect,{value:d,onValueChange:a=>{let b=f.find(a=>a.id===d)?.provider,g=f.find(b=>b.id===a)?.provider;e(a),b&&b!==g&&c("")},runtimes:f})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(p.Label,{className:"text-xs text-muted-foreground",children:"Model"}),(0,b.jsx)(o.Input,{value:a,onChange:a=>c(a.target.value),placeholder:"Default (runtime model)",list:"agent-model-options-edit"}),g.length>0&&(0,b.jsx)("datalist",{id:"agent-model-options-edit",children:g.map(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Optional. Leave blank to use the runtime's default model."})]})]})}function z({agent:a,runtimes:d,modelOptions:e,onSave:f,onCancel:i,saving:l}){let{workspaceId:o}=(0,g.useWorkspace)(),[p,r]=(0,c.useState)("general"),[A,B]=(0,c.useState)(a.name??""),[C,D]=(0,c.useState)(a.description??""),[E,F]=(0,c.useState)(a.runtime_id??""),[G,H]=(0,c.useState)(()=>(0,w.parseAvatarUrl)(a.avatar_url)??w.DEFAULT_CONFIG),[I,J]=(0,c.useState)(()=>{let b=a.runtime_config;return"string"==typeof b?.model?b.model:""}),[K,L]=(0,c.useState)(a.instructions??""),[M,N]=(0,c.useState)(a.instructions??""),O=(0,c.useRef)(K);(0,c.useEffect)(()=>{O.current=K},[K]);let P=(0,c.useRef)(M);(0,c.useEffect)(()=>{P.current=M},[M]);let Q=(0,c.useRef)(null),R=(0,c.useRef)(!1),S=(0,c.useRef)(()=>{}),T=(0,c.useCallback)(async()=>{if(R.current)return;let b=O.current;if(b!==P.current){R.current=!0;try{await (0,s.updateAgent)(a.id,{instructions:b},o),N(b)}catch(a){t.toast.error(a instanceof Error?a.message:"Failed to save instructions")}finally{R.current=!1,O.current!==P.current&&S.current()}}},[a.id,o]),U=(0,c.useCallback)(()=>{Q.current&&clearTimeout(Q.current),Q.current=setTimeout(T,500)},[T]);(0,c.useEffect)(()=>{S.current=U},[U]);let V=(0,c.useCallback)(a=>{L(a),U()},[U]);(0,c.useEffect)(()=>{let b=()=>{if(Q.current&&clearTimeout(Q.current),O.current!==P.current){let b=new URLSearchParams({workspace_id:o});fetch(`/api/agents/${a.id}?${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:O.current}),keepalive:!0})}};return window.addEventListener("beforeunload",b),()=>window.removeEventListener("beforeunload",b)},[a.id,o]),(0,c.useEffect)(()=>()=>{if(Q.current&&clearTimeout(Q.current),O.current!==P.current){let b=new URLSearchParams({workspace_id:o});fetch(`/api/agents/${a.id}?${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:O.current}),keepalive:!0})}},[a.id,o]);let W=d.find(a=>a.id===E),X=W&&e?e[W.provider]??[]:[],Y=async a=>{a.preventDefault(),await f({name:A,description:C,runtime_id:E,runtime_config:I?{model:I}:{},avatar_url:(0,w.serializeAvatarConfig)(G)})},Z=[{id:"general",label:"General"},{id:"instruction",label:"Instruction"},{id:"runtime",label:"Runtime"},{id:"email",label:"Email"},{id:"permission",label:"Permission"}],$="general"===p||"runtime"===p||"email"===p,_=K.length/5e4;return(0,b.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,b.jsx)("nav",{className:"w-48 shrink-0 border-r border-border/50 py-3 px-2 hidden md:block",children:Z.map(a=>(0,b.jsx)("button",{type:"button",onClick:()=>r(a.id),className:(0,k.cn)("w-full rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",p===a.id?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:a.label},a.id))}),(0,b.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,b.jsx)("div",{className:"px-4 pt-2 md:hidden",children:(0,b.jsx)(j.Tabs,{className:"items-center",value:p,onValueChange:a=>r(a),children:(0,b.jsx)(j.TabsList,{className:"h-auto gap-1",children:Z.map(a=>(0,b.jsx)(j.TabsTrigger,{value:a.id,children:a.label},a.id))})})}),"instruction"===p?(0,b.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,b.jsx)("div",{className:"flex-1 px-6 pt-4 pb-4 overflow-y-auto",children:(0,b.jsx)(q.MarkdownEditor,{value:K,onChange:V,placeholder:"Write instructions for this agent...",minHeight:"calc(100vh - 240px)",contentType:"markdown",variant:"seamless"})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-6 py-3 border-t border-border/50",children:[(0,b.jsx)(x,{ratio:_}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Agent-specific instruction. Your global instruction is prepended automatically."})]})]}):(0,b.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar px-5 py-6",children:$?(0,b.jsxs)("form",{onSubmit:Y,className:"mx-auto max-w-md space-y-4",children:["general"===p&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(v.AvatarPickerDialog,{config:G,onChange:H}),(0,b.jsx)(u.GeneralFields,{name:A,setName:B,description:C,setDescription:D,model:I,setModel:J,runtimeId:E,setRuntimeId:F,runtimes:[],providerModels:[]})]}),"runtime"===p&&(0,b.jsx)(y,{model:I,setModel:J,runtimeId:E,setRuntimeId:F,runtimes:d,providerModels:X}),"email"===p&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"rounded-lg border border-border/50 bg-muted/30 px-4 py-3",children:[(0,b.jsxs)("div",{className:"mb-2.5 flex items-center gap-1.5",children:[(0,b.jsx)(m,{className:"size-3 text-muted-foreground/60"}),(0,b.jsx)("span",{className:"text-xs font-medium text-muted-foreground/60",children:"Set at creation"})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"Email"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a.email_handle?`${a.email_handle}@alook.ai`:"Not configured"})]})]}),(0,b.jsx)(n.CustomEmailForm,{agentId:a.id,workspaceId:a.workspace_id}),a.email_handle&&(0,b.jsx)("div",{className:"border-t border-border/50 pt-4 mt-4",children:(0,b.jsx)(u.AllowedSendersTab,{agentId:a.id})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),(0,b.jsx)(h.Button,{type:"submit",size:"sm",disabled:l||!A,children:l?"Saving...":"Save"})]})]}):(0,b.jsx)(u.AgentAccessTab,{agentId:a.id,ownerId:a.owner_id})})]})]})}var A=a.i(953528),B=a.i(25668),C=a.i(191525),D=a.i(426619),E=a.i(858767),F=a.i(304377),G=a.i(606896),H=a.i(113010);let I=(0,l.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var J=a.i(372443),K=a.i(415584),L=a.i(110025),M=a.i(518828),N=a.i(867561),O=a.i(525132);a.s(["default",0,function({children:a}){let j=(0,d.useParams)(),k=(0,d.useRouter)(),l=(0,d.usePathname)(),{slug:m}=(0,g.useWorkspace)(),n=(0,d.useSearchParams)(),o=j.id,p=!!n.get("conv"),q=l.includes("/activity")||p?"activity":l.includes("/meetings")?"meetings":l.includes("/email")?"email":l.includes("/files")?"files":"chat",{agents:r,runtimes:t,handleDeleteAgent:u,handleUpdateAgent:v}=(0,f.useAgentContext)(),w=r.find(a=>a.id===o),x=w?t.find(a=>a.id===w.runtime_id):null,y=x?.status==="online",{activeTaskCounts:P}=(0,f.useAgentContext)(),Q=P[o]??0,[R,S]=(0,c.useState)(!1),[T,U]=(0,c.useState)(!1),[V,W]=(0,c.useState)(!1),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)({});return(0,c.useEffect)(()=>{(0,s.fetchModelOptions)().then($).catch(()=>{})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border/50 px-3 md:px-5 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[w?(0,b.jsx)(C.AgentStatusBadge,{isOnline:y,taskCount:Q,agentId:o}):(0,b.jsx)(B.Skeleton,{className:"size-2 rounded-full shrink-0"}),w?(0,b.jsxs)(O.Tooltip,{children:[(0,b.jsx)(O.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:`/w/${m}/agents/${o}`,onClick:()=>S(!1),className:"text-sm font-medium truncate hover:text-foreground/80 transition-colors"}),children:w.name}),(0,b.jsx)(O.TooltipContent,{children:w.description||"No description"})]}):(0,b.jsx)(B.Skeleton,{className:"h-3.5 w-24"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["/ ",R?"Settings":({email:"Email",meetings:"Meetings",activity:"Activity",files:"Files"})[q]??"Chat"]})]}),w?(0,b.jsx)("div",{className:"flex items-center gap-0.5 shrink-0",children:R?(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground h-7 gap-1 px-2",onClick:()=>S(!1),children:[(0,b.jsx)(M.X,{className:"size-3"}),"Cancel"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"hidden sm:flex items-center gap-0.5",children:[(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"chat"===q?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(H.MessageSquare,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"chat"===q?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Chat"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/email`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"email"===q?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(G.Mail,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"email"===q?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Email"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/meetings`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"meetings"===q?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(L.Video,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"meetings"===q?"max-w-20 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Meetings"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/activity`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"activity"===q?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(F.History,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"activity"===q?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Activity"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/agents/${o}/files`,className:`group inline-flex items-center rounded-lg text-xs h-7 px-2 transition-all ${"files"===q?"text-foreground bg-muted":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[(0,b.jsx)(D.FolderOpen,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:`overflow-hidden transition-all duration-500 ease-out ${"files"===q?"max-w-16 opacity-100 ml-1":"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300"}`,children:"Files"})]}),(0,b.jsxs)(e.default,{href:`/w/${m}/threads?agentId=${o}`,className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all",children:[(0,b.jsx)(E.GitBranch,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Threads"})]}),(0,b.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,b.jsxs)("button",{className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all",onClick:()=>S(!0),children:[(0,b.jsx)(J.Pencil,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-12 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Edit"})]}),(0,b.jsxs)("button",{className:"group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-destructive transition-all",onClick:()=>W(!0),children:[(0,b.jsx)(K.Trash2,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out",children:"Remove"})]})]}),(0,b.jsx)("div",{className:"sm:hidden",children:(0,b.jsxs)(N.DropdownMenu,{children:[(0,b.jsx)(N.DropdownMenuTrigger,{render:(0,b.jsx)(h.Button,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground"}),children:(0,b.jsx)(I,{className:"size-4"})}),(0,b.jsxs)(N.DropdownMenuContent,{align:"end",sideOffset:6,children:["chat"!==q&&(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}`),children:[(0,b.jsx)(H.MessageSquare,{className:"size-3.5"})," Chat"]}),"email"!==q&&(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/email`),children:[(0,b.jsx)(G.Mail,{className:"size-3.5"})," Email"]}),"meetings"!==q&&(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/meetings`),children:[(0,b.jsx)(L.Video,{className:"size-3.5"})," Meetings"]}),"activity"!==q&&(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/activity`),children:[(0,b.jsx)(F.History,{className:"size-3.5"})," Activity"]}),"files"!==q&&(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/agents/${o}/files`),children:[(0,b.jsx)(D.FolderOpen,{className:"size-3.5"})," Files"]}),(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>k.push(`/w/${m}/threads?agentId=${o}`),children:[(0,b.jsx)(E.GitBranch,{className:"size-3.5"}),"Threads"]}),(0,b.jsx)(N.DropdownMenuSeparator,{}),(0,b.jsxs)(N.DropdownMenuItem,{onClick:()=>S(!0),children:[(0,b.jsx)(J.Pencil,{className:"size-3.5"}),"Edit"]}),(0,b.jsx)(N.DropdownMenuSeparator,{}),(0,b.jsxs)(N.DropdownMenuItem,{variant:"destructive",onClick:()=>W(!0),children:[(0,b.jsx)(K.Trash2,{className:"size-3.5"}),"Remove"]})]})]})})]})}):(0,b.jsx)("div",{className:"h-7 shrink-0"})]}),R&&w?(0,b.jsx)(z,{agent:w,runtimes:t,modelOptions:Z,saving:T,onCancel:()=>S(!1),onSave:async a=>{U(!0);try{let b=await v(w.id,a);return b&&S(!1),b}finally{U(!1)}}}):(0,b.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:["chat"===q&&(0,b.jsx)(A.ChannelBar,{}),a]}),w&&(0,b.jsx)(i.ConfirmDialog,{open:V,onOpenChange:W,title:"Remove agent",description:`This will permanently delete "${w.name}" and all its conversations.`,loading:X,onConfirm:async()=>{Y(!0);try{await u(w.id)&&k.push(`/w/${m}/home`)}finally{Y(!1),W(!1)}}})]})}],812187)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_web_src_app_%28app%29_w_%5Bslug%5D_agents_%5Bid%5D_layout_tsx_0juu2um._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[137993,370085,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(732254),e=a.i(334235),f=a.i(76592),g=a.i(7455),h=a.i(525132),i=a.i(75118),j=a.i(588339),k=a.i(16831),l=a.i(606896),m=a.i(877014),n=a.i(123047),o=a.i(940723),p=a.i(143984),q=a.i(73270);let r=(0,a.i(647651).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);a.s(["CircleHelp",0,r],370085);var s=a.i(921584),t=a.i(506180),u=a.i(390248);let v={Gmail:{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:587},Outlook:{imapHost:"outlook.office365.com",imapPort:993,smtpHost:"smtp.office365.com",smtpPort:587},Yahoo:{imapHost:"imap.mail.yahoo.com",imapPort:993,smtpHost:"smtp.mail.yahoo.com",smtpPort:587}};function w({fields:a,applyPreset:c,errors:g,onClearError:h}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"flex gap-1.5",children:Object.keys(v).map(a=>(0,b.jsx)(d.Button,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>c(a),children:a},a))}),(0,b.jsxs)("div",{className:"grid gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)(f.Label,{className:"text-xs",children:"Email Address *"}),(0,b.jsx)(e.Input,{placeholder:"you@gmail.com",value:a.emailAddress,onChange:b=>{a.setEmailAddress(b.target.value),b.target.value.trim()&&h("emailAddress")},"aria-invalid":!!g.emailAddress,"aria-describedby":g.emailAddress?"custom-email-address-error":void 0,className:"h-8 text-sm"}),g.emailAddress&&(0,b.jsx)("p",{id:"custom-email-address-error",className:"mt-1 text-xs text-destructive",children:g.emailAddress})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)(f.Label,{className:"text-xs",children:"Display Name"}),(0,b.jsx)(e.Input,{placeholder:"My Agent",value:a.displayName,onChange:b=>a.setDisplayName(b.target.value),className:"h-8 text-sm"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(f.Label,{className:"text-xs font-medium",children:"IMAP (Receive)"}),(0,b.jsx)(e.Input,{placeholder:"imap.gmail.com",value:a.imapHost,onChange:b=>{a.setImapHost(b.target.value),b.target.value.trim()&&h("imapHost")},"aria-invalid":!!g.imapHost,"aria-describedby":g.imapHost?"custom-email-imap-host-error":void 0,className:"h-8 text-sm"}),g.imapHost&&(0,b.jsx)("p",{id:"custom-email-imap-host-error",className:"text-xs text-destructive",children:g.imapHost}),(0,b.jsx)(e.Input,{type:"number",placeholder:"993",value:a.imapPort,onChange:b=>a.setImapPort(Number(b.target.value)),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{placeholder:a.emailAddress||"Username (defaults to email)",value:a.imapUsername,onChange:b=>a.setImapUsername(b.target.value),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{type:"password",placeholder:"App Password",value:a.imapPassword,onChange:b=>{a.setImapPassword(b.target.value),b.target.value.trim()&&h("imapPassword")},"aria-invalid":!!g.imapPassword,"aria-describedby":g.imapPassword?"custom-email-imap-password-error":void 0,className:"h-8 text-sm"}),g.imapPassword&&(0,b.jsx)("p",{id:"custom-email-imap-password-error",className:"text-xs text-destructive",children:g.imapPassword})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(f.Label,{className:"text-xs font-medium",children:"SMTP (Send)"}),(0,b.jsx)(e.Input,{placeholder:"smtp.gmail.com",value:a.smtpHost,onChange:b=>{a.setSmtpHost(b.target.value),b.target.value.trim()&&h("smtpHost")},"aria-invalid":!!g.smtpHost,"aria-describedby":g.smtpHost?"custom-email-smtp-host-error":void 0,className:"h-8 text-sm"}),g.smtpHost&&(0,b.jsx)("p",{id:"custom-email-smtp-host-error",className:"text-xs text-destructive",children:g.smtpHost}),(0,b.jsx)(e.Input,{type:"number",placeholder:"587",value:a.smtpPort,onChange:b=>a.setSmtpPort(Number(b.target.value)),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{placeholder:a.emailAddress||"Username (defaults to email)",value:a.smtpUsername,onChange:b=>a.setSmtpUsername(b.target.value),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{type:"password",placeholder:"App Password",value:a.smtpPassword,onChange:b=>{a.setSmtpPassword(b.target.value),b.target.value.trim()&&h("smtpPassword")},"aria-invalid":!!g.smtpPassword,"aria-describedby":g.smtpPassword?"custom-email-smtp-password-error":void 0,className:"h-8 text-sm"}),g.smtpPassword&&(0,b.jsx)("p",{id:"custom-email-smtp-password-error",className:"text-xs text-destructive",children:g.smtpPassword})]})]})]})}a.s(["CustomEmailForm",0,function({agentId:a,workspaceId:e,onDataChange:f,getDataRef:x}){let{slug:y}=(0,t.useWorkspace)(),z=!a,[A,B]=(0,c.useState)(!1),[C,D]=(0,c.useState)([]),[E,F]=(0,c.useState)(!z),[G,H]=(0,c.useState)(!1),[I,J]=(0,c.useState)(!1),[K,L]=(0,c.useState)(!1),[M,N]=(0,c.useState)({}),{fields:O,applyPreset:P,buildData:Q}=function(){let[a,b]=(0,c.useState)(""),[d,e]=(0,c.useState)(""),[f,g]=(0,c.useState)(""),[h,i]=(0,c.useState)(993),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(""),[p,q]=(0,c.useState)(587),[r,s]=(0,c.useState)(""),[t,u]=(0,c.useState)(""),w=j||a,x=r||a;return{fields:{emailAddress:a,setEmailAddress:b,displayName:d,setDisplayName:e,imapHost:f,setImapHost:g,imapPort:h,setImapPort:i,imapUsername:j,setImapUsername:k,imapPassword:l,setImapPassword:m,smtpHost:n,setSmtpHost:o,smtpPort:p,setSmtpPort:q,smtpUsername:r,setSmtpUsername:s,smtpPassword:t,setSmtpPassword:u},applyPreset:function(a){let b=v[a];b&&(g(b.imapHost),i(b.imapPort),o(b.smtpHost),q(b.smtpPort))},buildData:function(){return a&&f&&w&&l&&n&&x&&t?{emailAddress:a,displayName:d,imapHost:f,imapPort:h,imapUsername:w,imapPassword:l,imapTls:!0,smtpHost:n,smtpPort:p,smtpUsername:x,smtpPassword:t,smtpTls:1,pollIntervalSeconds:60}:null}}}(),R=O.imapUsername||O.emailAddress,S=O.smtpUsername||O.emailAddress,T=(0,c.useCallback)(a=>{N(b=>({...b,[a]:void 0}))},[]);(0,c.useEffect)(()=>{x&&(x.current=Q)}),(0,c.useEffect)(()=>{z&&f?.(Q())},[z,Q,f,O.emailAddress,O.displayName,O.imapHost,O.imapPort,O.imapUsername,O.imapPassword,O.smtpHost,O.smtpPort,O.smtpUsername,O.smtpPassword]);let U=(0,c.useCallback)(async()=>{if(!z)try{let b=await (0,j.listEmailAccounts)(a,e);D(b)}catch{}finally{F(!1)}},[a,e,z]);(0,c.useEffect)(()=>{U()},[U]);let V=C[0]??null;async function W(){let b=(0,u.validateCustomEmailFields)({emailAddress:O.emailAddress,imapHost:O.imapHost,imapUsername:R,imapPassword:O.imapPassword,smtpHost:O.smtpHost,smtpUsername:S,smtpPassword:O.smtpPassword});if(N(b),(0,u.hasCustomEmailErrors)(b))return;let c=Q();if(c&&a){H(!0);try{await (0,j.createEmailAccount)(a,c,e),s.toast.success("Custom email configured"),B(!1),await U()}catch(a){s.toast.error(a instanceof Error?a.message:"Failed to save")}finally{H(!1)}}}async function X(){if(V&&a){L(!0);try{await (0,j.deleteEmailAccount)(a,V.id,e),s.toast.success("Custom email removed"),D([])}catch(a){s.toast.error(a instanceof Error?a.message:"Failed to remove")}finally{L(!1)}}}async function Y(){if(V&&a){J(!0);try{await (0,j.syncEmailAccount)(a,V.id,e),s.toast.success("Sync triggered"),setTimeout(()=>U(),2e3)}catch(a){s.toast.error(a instanceof Error?a.message:"Sync failed")}finally{J(!1)}}}let Z=z?O.emailAddress?O.emailAddress:"Connect your own mailbox via IMAP/SMTP":E?"Loading...":V?V.email_address:"Connect your own mailbox via IMAP/SMTP";return(0,b.jsxs)(g.Sheet,{open:A,onOpenChange:B,children:[(0,b.jsxs)(g.SheetTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border/50 bg-muted/30 px-4 py-3 text-left transition-colors hover:bg-muted/50"}),children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"Custom Email"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:Z})]}),!z&&V?(0,b.jsxs)("span",{className:(0,i.cn)("inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium shrink-0","active"===V.status?"bg-green-500/10 text-green-600":"error"===V.status?"bg-red-500/10 text-red-600":"bg-yellow-500/10 text-yellow-600"),children:["active"===V.status?(0,b.jsx)(o.CheckCircle2,{className:"size-2.5"}):"error"===V.status?(0,b.jsx)(n.AlertCircle,{className:"size-2.5"}):null,V.status]}):(0,b.jsx)(p.ChevronRight,{className:"size-4 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(g.SheetContent,{side:"right",className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,b.jsx)(g.SheetTitle,{className:"sr-only",children:"Custom Email"}),(0,b.jsx)(g.SheetBody,{className:"px-8 pt-10 pb-6",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("h2",{className:"font-heading text-lg font-semibold",children:"Custom Email"}),(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)("a",{href:`/w/${y}/help/email-setup`,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors"}),children:(0,b.jsx)(r,{className:"size-4"})}),(0,b.jsx)(h.TooltipContent,{children:"How to get IMAP/SMTP credentials"})]})]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Connect your own mailbox to send and receive email as your identity."})]}),!z&&V?(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)(l.Mail,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-sm truncate",children:V.email_address})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)(d.Button,{variant:"ghost",size:"icon-xs",onClick:Y,disabled:I,className:"rounded-full text-muted-foreground"}),children:(0,b.jsx)(m.RefreshCw,{className:(0,i.cn)("size-3.5",I&&"animate-spin")})}),(0,b.jsx)(h.TooltipContent,{children:"Sync now"})]}),(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)(d.Button,{variant:"ghost",size:"icon-xs",onClick:X,disabled:K,className:"rounded-full text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}),children:K?(0,b.jsx)(k.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(q.XIcon,{className:"size-3.5"})}),(0,b.jsx)(h.TooltipContent,{children:"Remove"})]})]})]}),V.error_message&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:V.error_message}),V.last_synced_at&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Last synced: ",new Date(V.last_synced_at).toLocaleString()]}),(0,b.jsxs)("div",{className:"rounded-md border border-border/50 px-3 py-2 text-xs text-muted-foreground space-y-1",children:[(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"IMAP"}),(0,b.jsxs)("span",{children:[V.imap_host,":",V.imap_port]})]}),(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"SMTP"}),(0,b.jsxs)("span",{children:[V.smtp_host,":",V.smtp_port]})]}),(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"Poll interval"}),(0,b.jsxs)("span",{children:[V.poll_interval_seconds,"s"]})]})]})]}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsx)(w,{fields:O,applyPreset:P,errors:M,onClearError:T}),!z&&(0,b.jsxs)(d.Button,{type:"button",size:"sm",className:"w-full",onClick:W,disabled:G,children:[G&&(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin mr-1"}),"Save & Connect"]}),z&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Will be connected after creating the agent."})]})]})})]})]})}],137993)},224226,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(732254),e=a.i(334235),f=a.i(76592),g=a.i(75118);function h({className:a,...c}){return(0,b.jsx)("textarea",{"data-slot":"textarea",className:(0,g.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",a),...c})}var i=a.i(354498),j=a.i(432340),k=a.i(74414);function l({value:a,onValueChange:c,runtimes:d,disabled:e,triggerProps:f}){let g=function(a){let b=new Map;for(let c of a){let a=c.daemon_id||c.id;b.has(a)||b.set(a,{label:("string"==typeof c.device_info?c.device_info:"")||a,runtimes:[]}),b.get(a).runtimes.push(c)}return b}(d),h=e||0===d.length||d.every(a=>"online"!==a.status);return(0,b.jsxs)(i.Select,{value:a,onValueChange:a=>{a&&c(a)},disabled:h,items:d.map(a=>{let b=("string"==typeof a.device_info?a.device_info:"")||"",c=b?`${a.provider} (${b})`:a.provider;return{value:a.id,label:c}}),children:[(0,b.jsx)(i.SelectTrigger,{...f,children:(0,b.jsx)(i.SelectValue,{placeholder:0===d.length?"No runtimes — start a daemon first":d.every(a=>"online"!==a.status)?"All runtimes offline":"Select a runtime"})}),(0,b.jsx)(i.SelectPopup,{children:Array.from(g.entries()).map(([a,c])=>(0,b.jsxs)(i.SelectGroup,{children:[(0,b.jsx)(i.SelectGroupLabel,{className:"truncate",children:c.label}),c.runtimes.map(a=>(0,b.jsx)(i.SelectItem,{value:a.id,disabled:"online"!==a.status,children:(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)(k.ProviderLogo,{provider:a.provider,className:"h-4 w-4"}),(0,b.jsx)("span",{children:a.provider}),(0,b.jsxs)("span",{className:"text-muted-foreground text-xs",children:["(",a.status,")"]})]})},a.id))]},a))})]})}a.i(974936),process.env.ALOOK_DOMAIN;let m=/^[a-zA-Z0-9-]{3,}$/,n=new Set(["no-reply","noreply","admin","support","help","info","postmaster","abuse","security","mailer-daemon","root","webmaster","hostmaster","system","alook"]);function o(a){return m.test(a)&&!n.has(a.toLowerCase())}let p=(0,a.i(647651).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var q=a.i(73270),r=a.i(506180),s=a.i(588339),t=a.i(752792),u=a.i(446827),v=a.i(921584);a.s(["AgentAccessTab",0,function({agentId:e,ownerId:f}){let{workspaceId:h}=(0,r.useWorkspace)(),[k,l]=(0,c.useState)("private"),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)([]),[t,w]=(0,c.useState)([]),[x,y]=(0,c.useState)(!0),[z,A]=(0,c.useState)(null),[B,C]=(0,c.useState)(""),[D,E]=(0,c.useState)(!1),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(!0);(0,c.useEffect)(()=>{let a=!1;return y(!0),Promise.all([(0,s.listAgentAccess)(h,e),(0,s.listMembers)(h)]).then(([b,c])=>{a||(p(b),w(c))}).catch(b=>{a||(b instanceof u.ApiError&&403===b.status?A(b.message):A("Failed to load access list"))}).finally(()=>{a||y(!1)}),()=>{a=!0}},[h,e]),(0,c.useEffect)(()=>{a.A(81396).then(({listAgents:a})=>{a(h).then(a=>{let b=a.find(a=>a.id===e);b&&l(b.visibility??"private")}).catch(()=>{})})},[h,e]);let J=async a=>{l(a),n(!0);try{await (0,s.updateAgent)(e,{visibility:a},h),v.toast.success("public"===a?"Agent is now public":"Agent is now private")}catch{l(k),v.toast.error("Failed to update visibility")}finally{n(!1)}},K=t.find(a=>a.user_id===f),L=new Set(o.map(a=>a.user_id)),M=t.filter(a=>!L.has(a.user_id)&&a.user_id!==f),N=async a=>{if(a&&!D){E(!0),A(null);try{await (0,s.grantAgentAccess)(h,e,a);let b=t.find(b=>b.user_id===a);b&&p(c=>[...c,{id:a,user_id:b.user_id,name:b.name,email:b.email,created_at:new Date().toISOString()}]),C(""),v.toast.success("Access granted")}catch(a){A(a instanceof Error?a.message:"Failed to grant access")}finally{E(!1)}}},O=async()=>{if(F){p(a=>a.filter(a=>a.user_id!==F.user_id)),G(null),A(null);try{await (0,s.revokeAgentAccess)(h,e,F.user_id,H),v.toast.success(H?"Access revoked and removed from whitelist":"Access revoked")}catch{p(o),A("Failed to revoke access")}}};return(0,b.jsxs)("div",{className:"mx-auto max-w-md space-y-6",children:[(0,b.jsx)("div",{className:"space-y-4 rounded-lg border border-border/50 p-4",children:(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Visibility"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"public"===k?"All workspace members can use this agent":"Only authorized members can use this agent"})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:m?"Saving…":"public"===k?"Public":"Private"}),(0,b.jsx)("input",{type:"checkbox",checked:"public"===k,onChange:a=>J(a.target.checked?"public":"private"),disabled:m,className:"sr-only peer"}),(0,b.jsx)("div",{className:"relative w-9 h-5 bg-muted rounded-full peer-checked:bg-primary transition-colors",children:(0,b.jsx)("div",{className:(0,g.cn)("absolute left-0.5 top-0.5 w-4 h-4 bg-background rounded-full transition-transform","public"===k?"translate-x-4":"translate-x-0")})})]})]})}),"private"===k&&(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Authorized Members"}),z&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:z}),x?(0,b.jsx)("div",{className:"space-y-2",children:[1,2].map(a=>(0,b.jsx)("span",{className:"block h-10 animate-pulse rounded-md bg-muted"},a))}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[K&&(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-medium truncate",children:K.name||K.email}),K.name&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:K.email})]}),(0,b.jsx)("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:"Owner"})]}),o.map(a=>(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-medium truncate",children:a.name||a.email}),a.name&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:a.email})]}),(0,b.jsx)("button",{type:"button",onClick:()=>{var b;let c;return b=a.user_id,void((c=o.find(a=>a.user_id===b))&&(G(c),I(!0)))},className:"ml-2 shrink-0 rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,b.jsx)(q.XIcon,{className:"size-3.5"})})]},a.user_id))]}),M.length>0?(0,b.jsx)("div",{className:"flex items-center gap-2",children:(0,b.jsxs)(i.Select,{value:B,onValueChange:a=>{a&&(C(a),N(a))},children:[(0,b.jsx)(i.SelectTrigger,{className:"flex-1 text-xs",children:(0,b.jsx)(i.SelectValue,{placeholder:"Add a member..."})}),(0,b.jsx)(i.SelectPopup,{children:M.map(a=>(0,b.jsx)(i.SelectItem,{value:a.user_id,children:a.name||a.email},a.user_id))})]})}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"All workspace members have been added. Invite new members from workspace settings."})]})]}),(0,b.jsx)(j.Dialog,{open:!!F,onOpenChange:a=>{a||G(null)},children:(0,b.jsxs)(j.DialogContent,{children:[(0,b.jsxs)(j.DialogHeader,{children:[(0,b.jsx)(j.DialogTitle,{children:"Remove Member Access"}),(0,b.jsxs)(j.DialogDescription,{children:["Remove"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:F?.name||F?.email})," ","from this agent?"]})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer px-1",children:[(0,b.jsx)("input",{type:"checkbox",checked:H,onChange:a=>I(a.target.checked),className:"size-4 rounded border-border accent-primary"}),(0,b.jsx)("span",{className:"text-sm",children:"Also remove from email whitelist"})]}),(0,b.jsxs)(j.DialogFooter,{children:[(0,b.jsx)(j.DialogClose,{render:(0,b.jsx)(d.Button,{variant:"outline",size:"sm"}),children:"Cancel"}),(0,b.jsx)(d.Button,{size:"sm",variant:"destructive",onClick:O,children:"Remove"})]})]})})]})},"AllowedSendersTab",0,function({agentId:a}){let{workspaceId:f}=(0,r.useWorkspace)(),[g,h]=(0,c.useState)([]),[i,j]=(0,c.useState)(""),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,t]=(0,c.useState)(null),[u,v]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let b=!1;return l(!0),(0,s.listWhitelist)(a,f).then(a=>{b||h(a)}).catch(()=>{b||t("Failed to load whitelist")}).finally(()=>{b||l(!1)}),()=>{b=!0}},[a,f]),(0,c.useEffect)(()=>{let b=!1;return(0,s.listAgents)(f).then(c=>{b||v(c.filter(b=>b.id!==a&&b.email_handle).length>0)}).catch(()=>{}),()=>{b=!0}},[a,f]);let w=i.includes("@")&&i.trim().length>0,x=async()=>{if(w&&!m){n(!0),t(null);try{let b=await (0,s.addWhitelistEmail)(a,i.toLowerCase(),f);h(a=>[...a,b]),j("")}catch(a){t(a instanceof Error?a.message:"Failed to add email")}finally{n(!1)}}},y=async b=>{h(a=>a.filter(a=>a.id!==b)),t(null);try{await (0,s.removeWhitelistEmail)(a,b,f)}catch{h(g),t("Failed to remove email")}};return(0,b.jsxs)("div",{className:"mx-auto max-w-md space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Allowed Senders"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Only emails from these addresses will trigger this agent. Applies to all configured email addresses (alook.ai handle and custom email)."}),u&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/70 mt-1.5 flex items-center gap-1",children:[(0,b.jsx)(p,{className:"size-3 shrink-0"}),"Agents in this workspace can already email each other — no whitelist entry needed."]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e.Input,{value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),x())},placeholder:"user@example.com",type:"email",className:"flex-1"}),(0,b.jsx)(d.Button,{type:"button",size:"sm",variant:"secondary",disabled:!w||m,onClick:x,children:m?"Adding...":"Add"})]}),o&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:o}),k?(0,b.jsx)("div",{className:"space-y-2",children:[1,2,3].map(a=>(0,b.jsx)("span",{className:"block h-8 animate-pulse rounded-md bg-muted"},a))}):0===g.length?(0,b.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No allowed senders — all inbound emails will be rejected."}):(0,b.jsx)("div",{className:"space-y-1.5",children:g.map(a=>(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-sm",children:a.email}),(0,b.jsx)("button",{type:"button",onClick:()=>y(a.id),className:"rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,b.jsx)(q.XIcon,{className:"size-3.5"})})]},a.id))})]})},"EmailHandleField",0,function({emailHandle:a,setEmailHandle:c,derivedHandle:d}){let h=a||d,i=h&&!o(h)?"Must be 3+ characters, letters/numbers/hyphens only":"";return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(f.Label,{htmlFor:"agent-handle",children:"Email Handle"}),(0,b.jsxs)("div",{className:"flex items-center gap-0",children:[(0,b.jsx)(e.Input,{id:"agent-handle",value:a,onChange:a=>c(a.target.value.toLowerCase()),placeholder:d||"my-agent",className:"rounded-r-none"}),(0,b.jsx)("span",{className:"inline-flex h-8 items-center rounded-r-lg border border-l-0 border-input bg-muted px-2.5 text-sm text-muted-foreground",children:"@alook.ai"})]}),h&&(0,b.jsx)("p",{className:(0,g.cn)("text-xs",i?"text-destructive":"text-muted-foreground"),children:i||`${h}@alook.ai`}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"This cannot be changed after creation."})]})},"GeneralFields",0,function({name:a,setName:c,description:d,setDescription:i,instructions:j,setInstructions:m,model:n,setModel:o,runtimeId:p,setRuntimeId:q,runtimes:r,providerModels:s,errors:t,runtimeAsRadio:u=!1}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)(f.Label,{htmlFor:"agent-name",children:["Name ",(0,b.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,b.jsx)(e.Input,{id:"agent-name",value:a,onChange:a=>c(a.target.value),placeholder:"My Agent",required:!0,"aria-invalid":!!t?.name,"aria-describedby":t?.name?"agent-name-error":void 0}),t?.name&&(0,b.jsx)("p",{id:"agent-name-error",className:"text-xs text-destructive",children:t.name})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(f.Label,{htmlFor:"agent-description",children:"Description"}),(0,b.jsx)(e.Input,{id:"agent-description",value:d,onChange:a=>i(a.target.value),placeholder:"What does this agent do?"})]}),m&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(f.Label,{htmlFor:"agent-instructions",children:"Instructions"}),(0,b.jsx)(h,{id:"agent-instructions",value:j??"",onChange:a=>m(a.target.value),placeholder:"System prompt or instructions...",rows:6})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(f.Label,{htmlFor:"agent-model",children:"Model"}),(0,b.jsx)(e.Input,{id:"agent-model",value:n,onChange:a=>o(a.target.value),placeholder:"Default (runtime model)",list:"agent-model-options"}),s.length>0&&(0,b.jsx)("datalist",{id:"agent-model-options",children:s.map(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Optional. Leave blank to use the runtime's default model."})]}),(0,b.jsxs)("div",{id:"agent-runtime-select",className:"space-y-1.5",children:[(0,b.jsxs)(f.Label,{children:["Runtime ",(0,b.jsx)("span",{className:"text-destructive",children:"*"})]}),u?(0,b.jsx)("div",{className:"space-y-1.5",role:"radiogroup","aria-label":"Runtime",children:0===r.length?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No runtimes — start a daemon first"}):r.map(a=>{let c="online"===a.status,d=p===a.id,e="string"==typeof a.device_info?a.device_info:"";return(0,b.jsxs)("label",{className:(0,g.cn)("flex items-center gap-2.5 rounded-lg border p-2.5 cursor-pointer transition-colors",d?"border-primary bg-primary/5":"border-border hover:border-foreground/20",!c&&"opacity-40 pointer-events-none"),children:[(0,b.jsx)("input",{type:"radio",name:"runtime",value:a.id,checked:d,disabled:!c,onChange:()=>{let b=r.find(a=>a.id===p)?.provider,c=a.provider;q(a.id),b&&b!==c&&o("")},className:"accent-primary size-3.5"}),(0,b.jsx)(k.ProviderLogo,{provider:a.provider,className:"h-4 w-4 shrink-0"}),(0,b.jsx)("span",{className:"text-sm",children:a.provider}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),!c&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:"offline"})]},a.id)})}):(0,b.jsx)(l,{value:p,onValueChange:a=>{let b=r.find(a=>a.id===p)?.provider,c=r.find(b=>b.id===a)?.provider;q(a),b&&b!==c&&o("")},runtimes:r,triggerProps:{"aria-invalid":!!t?.runtimeId,"aria-describedby":t?.runtimeId?"agent-runtime-error":void 0}}),t?.runtimeId&&(0,b.jsx)("p",{id:"agent-runtime-error",className:"text-xs text-destructive",children:t.runtimeId})]})]})},"PinToggle",0,function({agentId:a}){let{pins:d,handlePinAgent:e,handleUnpinAgent:f}=(0,t.useAgentContext)(),h=d.has(a),[i,j]=(0,c.useState)(!1),k=async()=>{j(!0);try{h?await f(a):await e(a)}finally{j(!1)}};return(0,b.jsxs)("div",{className:"space-y-4 rounded-lg border border-border/50 p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Pin to Sidebar"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:h?"This agent is pinned to the top of the sidebar":"Pin this agent to the top of the sidebar"})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:i?"Saving…":h?"Pinned":"Unpinned"}),(0,b.jsx)("input",{type:"checkbox",checked:h,onChange:k,disabled:i,className:"sr-only peer"}),(0,b.jsx)("div",{className:"relative w-9 h-5 bg-muted rounded-full peer-checked:bg-primary transition-colors",children:(0,b.jsx)("div",{className:(0,g.cn)("absolute left-0.5 top-0.5 w-4 h-4 bg-background rounded-full transition-transform",h?"translate-x-4":"translate-x-0")})})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Tip: You can also right-click an agent in the sidebar to pin or unpin it."})]})},"getHandleError",0,function(a){return a&&!o(a)?"Must be 3+ characters, letters/numbers/hyphens only":""},"nameToHandle",0,function(a){return a.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}],224226)}];
|
|
1
|
+
module.exports=[137993,370085,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(732254),e=a.i(334235),f=a.i(76592),g=a.i(7455),h=a.i(525132),i=a.i(75118),j=a.i(588339),k=a.i(16831),l=a.i(606896),m=a.i(877014),n=a.i(123047),o=a.i(940723),p=a.i(143984),q=a.i(73270);let r=(0,a.i(647651).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);a.s(["CircleHelp",0,r],370085);var s=a.i(921584),t=a.i(506180),u=a.i(390248);let v={Gmail:{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:587},Outlook:{imapHost:"outlook.office365.com",imapPort:993,smtpHost:"smtp.office365.com",smtpPort:587},Yahoo:{imapHost:"imap.mail.yahoo.com",imapPort:993,smtpHost:"smtp.mail.yahoo.com",smtpPort:587}};function w({fields:a,applyPreset:c,errors:g,onClearError:h}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"flex gap-1.5",children:Object.keys(v).map(a=>(0,b.jsx)(d.Button,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>c(a),children:a},a))}),(0,b.jsxs)("div",{className:"grid gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)(f.Label,{className:"text-xs",children:"Email Address *"}),(0,b.jsx)(e.Input,{placeholder:"you@gmail.com",value:a.emailAddress,onChange:b=>{a.setEmailAddress(b.target.value),b.target.value.trim()&&h("emailAddress")},"aria-invalid":!!g.emailAddress,"aria-describedby":g.emailAddress?"custom-email-address-error":void 0,className:"h-8 text-sm"}),g.emailAddress&&(0,b.jsx)("p",{id:"custom-email-address-error",className:"mt-1 text-xs text-destructive",children:g.emailAddress})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)(f.Label,{className:"text-xs",children:"Display Name"}),(0,b.jsx)(e.Input,{placeholder:"My Agent",value:a.displayName,onChange:b=>a.setDisplayName(b.target.value),className:"h-8 text-sm"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(f.Label,{className:"text-xs font-medium",children:"IMAP (Receive)"}),(0,b.jsx)(e.Input,{placeholder:"imap.gmail.com",value:a.imapHost,onChange:b=>{a.setImapHost(b.target.value),b.target.value.trim()&&h("imapHost")},"aria-invalid":!!g.imapHost,"aria-describedby":g.imapHost?"custom-email-imap-host-error":void 0,className:"h-8 text-sm"}),g.imapHost&&(0,b.jsx)("p",{id:"custom-email-imap-host-error",className:"text-xs text-destructive",children:g.imapHost}),(0,b.jsx)(e.Input,{type:"number",placeholder:"993",value:a.imapPort,onChange:b=>a.setImapPort(Number(b.target.value)),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{placeholder:a.emailAddress||"Username (defaults to email)",value:a.imapUsername,onChange:b=>a.setImapUsername(b.target.value),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{type:"password",placeholder:"App Password",value:a.imapPassword,onChange:b=>{a.setImapPassword(b.target.value),b.target.value.trim()&&h("imapPassword")},"aria-invalid":!!g.imapPassword,"aria-describedby":g.imapPassword?"custom-email-imap-password-error":void 0,className:"h-8 text-sm"}),g.imapPassword&&(0,b.jsx)("p",{id:"custom-email-imap-password-error",className:"text-xs text-destructive",children:g.imapPassword})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(f.Label,{className:"text-xs font-medium",children:"SMTP (Send)"}),(0,b.jsx)(e.Input,{placeholder:"smtp.gmail.com",value:a.smtpHost,onChange:b=>{a.setSmtpHost(b.target.value),b.target.value.trim()&&h("smtpHost")},"aria-invalid":!!g.smtpHost,"aria-describedby":g.smtpHost?"custom-email-smtp-host-error":void 0,className:"h-8 text-sm"}),g.smtpHost&&(0,b.jsx)("p",{id:"custom-email-smtp-host-error",className:"text-xs text-destructive",children:g.smtpHost}),(0,b.jsx)(e.Input,{type:"number",placeholder:"587",value:a.smtpPort,onChange:b=>a.setSmtpPort(Number(b.target.value)),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{placeholder:a.emailAddress||"Username (defaults to email)",value:a.smtpUsername,onChange:b=>a.setSmtpUsername(b.target.value),className:"h-8 text-sm"}),(0,b.jsx)(e.Input,{type:"password",placeholder:"App Password",value:a.smtpPassword,onChange:b=>{a.setSmtpPassword(b.target.value),b.target.value.trim()&&h("smtpPassword")},"aria-invalid":!!g.smtpPassword,"aria-describedby":g.smtpPassword?"custom-email-smtp-password-error":void 0,className:"h-8 text-sm"}),g.smtpPassword&&(0,b.jsx)("p",{id:"custom-email-smtp-password-error",className:"text-xs text-destructive",children:g.smtpPassword})]})]})]})}a.s(["CustomEmailForm",0,function({agentId:a,workspaceId:e,onDataChange:f,getDataRef:x}){let{slug:y}=(0,t.useWorkspace)(),z=!a,[A,B]=(0,c.useState)(!1),[C,D]=(0,c.useState)([]),[E,F]=(0,c.useState)(!z),[G,H]=(0,c.useState)(!1),[I,J]=(0,c.useState)(!1),[K,L]=(0,c.useState)(!1),[M,N]=(0,c.useState)({}),{fields:O,applyPreset:P,buildData:Q}=function(){let[a,b]=(0,c.useState)(""),[d,e]=(0,c.useState)(""),[f,g]=(0,c.useState)(""),[h,i]=(0,c.useState)(993),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(""),[p,q]=(0,c.useState)(587),[r,s]=(0,c.useState)(""),[t,u]=(0,c.useState)(""),w=j||a,x=r||a;return{fields:{emailAddress:a,setEmailAddress:b,displayName:d,setDisplayName:e,imapHost:f,setImapHost:g,imapPort:h,setImapPort:i,imapUsername:j,setImapUsername:k,imapPassword:l,setImapPassword:m,smtpHost:n,setSmtpHost:o,smtpPort:p,setSmtpPort:q,smtpUsername:r,setSmtpUsername:s,smtpPassword:t,setSmtpPassword:u},applyPreset:function(a){let b=v[a];b&&(g(b.imapHost),i(b.imapPort),o(b.smtpHost),q(b.smtpPort))},buildData:function(){return a&&f&&w&&l&&n&&x&&t?{emailAddress:a,displayName:d,imapHost:f,imapPort:h,imapUsername:w,imapPassword:l,imapTls:!0,smtpHost:n,smtpPort:p,smtpUsername:x,smtpPassword:t,smtpTls:1,pollIntervalSeconds:60}:null}}}(),R=O.imapUsername||O.emailAddress,S=O.smtpUsername||O.emailAddress,T=(0,c.useCallback)(a=>{N(b=>({...b,[a]:void 0}))},[]);(0,c.useEffect)(()=>{x&&(x.current=Q)}),(0,c.useEffect)(()=>{z&&f?.(Q())},[z,Q,f,O.emailAddress,O.displayName,O.imapHost,O.imapPort,O.imapUsername,O.imapPassword,O.smtpHost,O.smtpPort,O.smtpUsername,O.smtpPassword]);let U=(0,c.useCallback)(async()=>{if(!z)try{let b=await (0,j.listEmailAccounts)(a,e);D(b)}catch{}finally{F(!1)}},[a,e,z]);(0,c.useEffect)(()=>{U()},[U]);let V=C[0]??null;async function W(){let b=(0,u.validateCustomEmailFields)({emailAddress:O.emailAddress,imapHost:O.imapHost,imapUsername:R,imapPassword:O.imapPassword,smtpHost:O.smtpHost,smtpUsername:S,smtpPassword:O.smtpPassword});if(N(b),(0,u.hasCustomEmailErrors)(b))return;let c=Q();if(c&&a){H(!0);try{await (0,j.createEmailAccount)(a,c,e),s.toast.success("Custom email configured"),B(!1),await U()}catch(a){s.toast.error(a instanceof Error?a.message:"Failed to save")}finally{H(!1)}}}async function X(){if(V&&a){L(!0);try{await (0,j.deleteEmailAccount)(a,V.id,e),s.toast.success("Custom email removed"),D([])}catch(a){s.toast.error(a instanceof Error?a.message:"Failed to remove")}finally{L(!1)}}}async function Y(){if(V&&a){J(!0);try{await (0,j.syncEmailAccount)(a,V.id,e),s.toast.success("Sync triggered"),setTimeout(()=>U(),2e3)}catch(a){s.toast.error(a instanceof Error?a.message:"Sync failed")}finally{J(!1)}}}let Z=z?O.emailAddress?O.emailAddress:"Connect your own mailbox via IMAP/SMTP":E?"Loading...":V?V.email_address:"Connect your own mailbox via IMAP/SMTP";return(0,b.jsxs)(g.Sheet,{open:A,onOpenChange:B,children:[(0,b.jsxs)(g.SheetTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border/50 bg-muted/30 px-4 py-3 text-left transition-colors hover:bg-muted/50"}),children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"Custom Email"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:Z})]}),!z&&V?(0,b.jsxs)("span",{className:(0,i.cn)("inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium shrink-0","active"===V.status?"bg-green-500/10 text-green-600":"error"===V.status?"bg-red-500/10 text-red-600":"bg-yellow-500/10 text-yellow-600"),children:["active"===V.status?(0,b.jsx)(o.CheckCircle2,{className:"size-2.5"}):"error"===V.status?(0,b.jsx)(n.AlertCircle,{className:"size-2.5"}):null,V.status]}):(0,b.jsx)(p.ChevronRight,{className:"size-4 text-muted-foreground shrink-0"})]}),(0,b.jsxs)(g.SheetContent,{side:"right",className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,b.jsx)(g.SheetTitle,{className:"sr-only",children:"Custom Email"}),(0,b.jsx)(g.SheetBody,{className:"px-8 pt-10 pb-6",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("h2",{className:"font-heading text-lg font-semibold",children:"Custom Email"}),(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)("a",{href:`/w/${y}/help/email-setup`,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors"}),children:(0,b.jsx)(r,{className:"size-4"})}),(0,b.jsx)(h.TooltipContent,{children:"How to get IMAP/SMTP credentials"})]})]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Connect your own mailbox to send and receive email as your identity."})]}),!z&&V?(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)(l.Mail,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-sm truncate",children:V.email_address})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)(d.Button,{variant:"ghost",size:"icon-xs",onClick:Y,disabled:I,className:"rounded-full text-muted-foreground"}),children:(0,b.jsx)(m.RefreshCw,{className:(0,i.cn)("size-3.5",I&&"animate-spin")})}),(0,b.jsx)(h.TooltipContent,{children:"Sync now"})]}),(0,b.jsxs)(h.Tooltip,{children:[(0,b.jsx)(h.TooltipTrigger,{render:(0,b.jsx)(d.Button,{variant:"ghost",size:"icon-xs",onClick:X,disabled:K,className:"rounded-full text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}),children:K?(0,b.jsx)(k.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(q.XIcon,{className:"size-3.5"})}),(0,b.jsx)(h.TooltipContent,{children:"Remove"})]})]})]}),V.error_message&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:V.error_message}),V.last_synced_at&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Last synced: ",new Date(V.last_synced_at).toLocaleString()]}),(0,b.jsxs)("div",{className:"rounded-md border border-border/50 px-3 py-2 text-xs text-muted-foreground space-y-1",children:[(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"IMAP"}),(0,b.jsxs)("span",{children:[V.imap_host,":",V.imap_port]})]}),(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"SMTP"}),(0,b.jsxs)("span",{children:[V.smtp_host,":",V.smtp_port]})]}),(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsx)("span",{children:"Poll interval"}),(0,b.jsxs)("span",{children:[V.poll_interval_seconds,"s"]})]})]})]}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsx)(w,{fields:O,applyPreset:P,errors:M,onClearError:T}),!z&&(0,b.jsxs)(d.Button,{type:"button",size:"sm",className:"w-full",onClick:W,disabled:G,children:[G&&(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin mr-1"}),"Save & Connect"]}),z&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Will be connected after creating the agent."})]})]})})]})]})}],137993)},224226,984078,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(732254),e=a.i(334235),f=a.i(76592),g=a.i(354498),h=a.i(432340),i=a.i(74414);function j({value:a,onValueChange:c,runtimes:d,disabled:e,triggerProps:f}){let h=function(a){let b=new Map;for(let c of a){let a=c.daemon_id||c.id;b.has(a)||b.set(a,{label:("string"==typeof c.device_info?c.device_info:"")||a,runtimes:[]}),b.get(a).runtimes.push(c)}return b}(d),k=e||0===d.length||d.every(a=>"online"!==a.status);return(0,b.jsxs)(g.Select,{value:a,onValueChange:a=>{a&&c(a)},disabled:k,items:d.map(a=>{let b=("string"==typeof a.device_info?a.device_info:"")||"",c=b?`${a.provider} (${b})`:a.provider;return{value:a.id,label:c}}),children:[(0,b.jsx)(g.SelectTrigger,{...f,children:(0,b.jsx)(g.SelectValue,{placeholder:0===d.length?"No runtimes — start a daemon first":d.every(a=>"online"!==a.status)?"All runtimes offline":"Select a runtime"})}),(0,b.jsx)(g.SelectPopup,{children:Array.from(h.entries()).map(([a,c])=>(0,b.jsxs)(g.SelectGroup,{children:[(0,b.jsx)(g.SelectGroupLabel,{className:"truncate",children:c.label}),c.runtimes.map(a=>(0,b.jsx)(g.SelectItem,{value:a.id,disabled:"online"!==a.status,children:(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)(i.ProviderLogo,{provider:a.provider,className:"h-4 w-4"}),(0,b.jsx)("span",{children:a.provider}),(0,b.jsxs)("span",{className:"text-muted-foreground text-xs",children:["(",a.status,")"]})]})},a.id))]},a))})]})}a.s(["RuntimeSelect",0,j],984078),a.i(974936),process.env.ALOOK_DOMAIN;let k=/^[a-zA-Z0-9-]{3,}$/,l=new Set(["no-reply","noreply","admin","support","help","info","postmaster","abuse","security","mailer-daemon","root","webmaster","hostmaster","system","alook"]);function m(a){return k.test(a)&&!l.has(a.toLowerCase())}var n=a.i(75118),o=a.i(647651);let p=(0,o.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var q=a.i(73270);let r=(0,o.default)("dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);var s=a.i(28429),t=a.i(506180),u=a.i(588339);a.i(752792);var v=a.i(446827),w=a.i(921584);function x({children:a}){let[d,e]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"pt-1",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>e(!d),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(s.ChevronDown,{className:(0,n.cn)("size-3.5 transition-transform",d&&"rotate-180")}),"Advanced"]}),d&&(0,b.jsx)("div",{className:"mt-3 space-y-4",children:a})]})}a.s(["AgentAccessTab",0,function({agentId:e,ownerId:f}){let{workspaceId:i}=(0,t.useWorkspace)(),[j,k]=(0,c.useState)("private"),[l,m]=(0,c.useState)(!1),[o,p]=(0,c.useState)([]),[r,s]=(0,c.useState)([]),[x,y]=(0,c.useState)(!0),[z,A]=(0,c.useState)(null),[B,C]=(0,c.useState)(""),[D,E]=(0,c.useState)(!1),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(!0);(0,c.useEffect)(()=>{let a=!1;return y(!0),Promise.all([(0,u.listAgentAccess)(i,e),(0,u.listMembers)(i)]).then(([b,c])=>{a||(p(b),s(c))}).catch(b=>{a||(b instanceof v.ApiError&&403===b.status?A(b.message):A("Failed to load access list"))}).finally(()=>{a||y(!1)}),()=>{a=!0}},[i,e]),(0,c.useEffect)(()=>{a.A(81396).then(({listAgents:a})=>{a(i).then(a=>{let b=a.find(a=>a.id===e);b&&k(b.visibility??"private")}).catch(()=>{})})},[i,e]);let J=async a=>{k(a),m(!0);try{await (0,u.updateAgent)(e,{visibility:a},i),w.toast.success("public"===a?"Agent is now public":"Agent is now private")}catch{k(j),w.toast.error("Failed to update visibility")}finally{m(!1)}},K=r.find(a=>a.user_id===f),L=new Set(o.map(a=>a.user_id)),M=r.filter(a=>!L.has(a.user_id)&&a.user_id!==f),N=async a=>{if(a&&!D){E(!0),A(null);try{await (0,u.grantAgentAccess)(i,e,a);let b=r.find(b=>b.user_id===a);b&&p(c=>[...c,{id:a,user_id:b.user_id,name:b.name,email:b.email,created_at:new Date().toISOString()}]),C(""),w.toast.success("Access granted")}catch(a){A(a instanceof Error?a.message:"Failed to grant access")}finally{E(!1)}}},O=async()=>{if(F){p(a=>a.filter(a=>a.user_id!==F.user_id)),G(null),A(null);try{await (0,u.revokeAgentAccess)(i,e,F.user_id,H),w.toast.success(H?"Access revoked and removed from whitelist":"Access revoked")}catch{p(o),A("Failed to revoke access")}}};return(0,b.jsxs)("div",{className:"mx-auto max-w-md space-y-6",children:[(0,b.jsx)("div",{className:"space-y-4 rounded-lg border border-border/50 p-4",children:(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Visibility"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"public"===j?"All workspace members can use this agent":"Only authorized members can use this agent"})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:l?"Saving…":"public"===j?"Public":"Private"}),(0,b.jsx)("input",{type:"checkbox",checked:"public"===j,onChange:a=>J(a.target.checked?"public":"private"),disabled:l,className:"sr-only peer"}),(0,b.jsx)("div",{className:"relative w-9 h-5 bg-muted rounded-full peer-checked:bg-primary transition-colors",children:(0,b.jsx)("div",{className:(0,n.cn)("absolute left-0.5 top-0.5 w-4 h-4 bg-background rounded-full transition-transform","public"===j?"translate-x-4":"translate-x-0")})})]})]})}),"private"===j&&(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Authorized Members"}),z&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:z}),x?(0,b.jsx)("div",{className:"space-y-2",children:[1,2].map(a=>(0,b.jsx)("span",{className:"block h-10 animate-pulse rounded-md bg-muted"},a))}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[K&&(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-medium truncate",children:K.name||K.email}),K.name&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:K.email})]}),(0,b.jsx)("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:"Owner"})]}),o.map(a=>(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-medium truncate",children:a.name||a.email}),a.name&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:a.email})]}),(0,b.jsx)("button",{type:"button",onClick:()=>{var b;let c;return b=a.user_id,void((c=o.find(a=>a.user_id===b))&&(G(c),I(!0)))},className:"ml-2 shrink-0 rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,b.jsx)(q.XIcon,{className:"size-3.5"})})]},a.user_id))]}),M.length>0?(0,b.jsx)("div",{className:"flex items-center gap-2",children:(0,b.jsxs)(g.Select,{value:B,onValueChange:a=>{a&&(C(a),N(a))},children:[(0,b.jsx)(g.SelectTrigger,{className:"flex-1 text-xs",children:(0,b.jsx)(g.SelectValue,{placeholder:"Add a member..."})}),(0,b.jsx)(g.SelectPopup,{children:M.map(a=>(0,b.jsx)(g.SelectItem,{value:a.user_id,children:a.name||a.email},a.user_id))})]})}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"All workspace members have been added. Invite new members from workspace settings."})]})]}),(0,b.jsx)(h.Dialog,{open:!!F,onOpenChange:a=>{a||G(null)},children:(0,b.jsxs)(h.DialogContent,{children:[(0,b.jsxs)(h.DialogHeader,{children:[(0,b.jsx)(h.DialogTitle,{children:"Remove Member Access"}),(0,b.jsxs)(h.DialogDescription,{children:["Remove"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:F?.name||F?.email})," ","from this agent?"]})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer px-1",children:[(0,b.jsx)("input",{type:"checkbox",checked:H,onChange:a=>I(a.target.checked),className:"size-4 rounded border-border accent-primary"}),(0,b.jsx)("span",{className:"text-sm",children:"Also remove from email whitelist"})]}),(0,b.jsxs)(h.DialogFooter,{children:[(0,b.jsx)(h.DialogClose,{render:(0,b.jsx)(d.Button,{variant:"outline",size:"sm"}),children:"Cancel"}),(0,b.jsx)(d.Button,{size:"sm",variant:"destructive",onClick:O,children:"Remove"})]})]})})]})},"AllowedSendersTab",0,function({agentId:a}){let{workspaceId:f}=(0,t.useWorkspace)(),[g,h]=(0,c.useState)([]),[i,j]=(0,c.useState)(""),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,r]=(0,c.useState)(null),[s,v]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let b=!1;return l(!0),(0,u.listWhitelist)(a,f).then(a=>{b||h(a)}).catch(()=>{b||r("Failed to load whitelist")}).finally(()=>{b||l(!1)}),()=>{b=!0}},[a,f]),(0,c.useEffect)(()=>{let b=!1;return(0,u.listAgents)(f).then(c=>{b||v(c.filter(b=>b.id!==a&&b.email_handle).length>0)}).catch(()=>{}),()=>{b=!0}},[a,f]);let w=i.includes("@")&&i.trim().length>0,x=async()=>{if(w&&!m){n(!0),r(null);try{let b=await (0,u.addWhitelistEmail)(a,i.toLowerCase(),f);h(a=>[...a,b]),j("")}catch(a){r(a instanceof Error?a.message:"Failed to add email")}finally{n(!1)}}},y=async b=>{h(a=>a.filter(a=>a.id!==b)),r(null);try{await (0,u.removeWhitelistEmail)(a,b,f)}catch{h(g),r("Failed to remove email")}};return(0,b.jsxs)("div",{className:"mx-auto max-w-md space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"Allowed Senders"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Only emails from these addresses will trigger this agent. Applies to all configured email addresses (alook.ai handle and custom email)."}),s&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/70 mt-1.5 flex items-center gap-1",children:[(0,b.jsx)(p,{className:"size-3 shrink-0"}),"Agents in this workspace can already email each other — no whitelist entry needed."]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e.Input,{value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),x())},placeholder:"user@example.com",type:"email",className:"flex-1"}),(0,b.jsx)(d.Button,{type:"button",size:"sm",variant:"secondary",disabled:!w||m,onClick:x,children:m?"Adding...":"Add"})]}),o&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:o}),k?(0,b.jsx)("div",{className:"space-y-2",children:[1,2,3].map(a=>(0,b.jsx)("span",{className:"block h-8 animate-pulse rounded-md bg-muted"},a))}):0===g.length?(0,b.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No allowed senders — all inbound emails will be rejected."}):(0,b.jsx)("div",{className:"space-y-1.5",children:g.map(a=>(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-sm",children:a.email}),(0,b.jsx)("button",{type:"button",onClick:()=>y(a.id),className:"rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,b.jsx)(q.XIcon,{className:"size-3.5"})})]},a.id))})]})},"EmailHandleField",0,function({emailHandle:a,setEmailHandle:c,derivedHandle:d}){let e=a||d,g=e&&!m(e)?"Must be 3+ characters, letters/numbers/hyphens only":"";return(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(f.Label,{className:"text-xs text-muted-foreground",children:"Email"}),(0,b.jsxs)("div",{className:"flex items-center",children:[(0,b.jsx)("input",{id:"agent-handle",value:a,onChange:a=>c(a.target.value.toLowerCase()),placeholder:d||"my-agent",className:"w-full border-0 bg-transparent px-0 py-0.5 text-sm text-foreground shadow-none outline-none placeholder:text-muted-foreground/40 focus-visible:ring-0"}),(0,b.jsx)("span",{className:"shrink-0 text-sm text-muted-foreground/70",children:"@alook.ai"})]}),g&&(0,b.jsx)("p",{className:"text-xs text-destructive",children:g})]})},"GeneralFields",0,function({name:a,setName:c,description:d,setDescription:e,instructions:g,setInstructions:h,model:k,setModel:l,runtimeId:m,setRuntimeId:o,runtimes:p,providerModels:q,errors:s,runtimeAsRadio:t=!1,onShuffle:u,emailHandleSlot:v,advancedSection:w}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{id:"agent-name",value:a,onChange:a=>c(a.target.value),placeholder:"Agent name",required:!0,autoFocus:!0,"aria-invalid":!!s?.name,"aria-describedby":s?.name?"agent-name-error":void 0,className:"w-full border-0 bg-transparent px-0 py-1 text-2xl font-medium leading-[1.2] tracking-tight shadow-none outline-none placeholder:text-muted-foreground/40 placeholder:font-normal focus-visible:ring-0"}),u&&(0,b.jsx)("button",{type:"button",onClick:u,"aria-label":"Randomize name",className:"absolute right-0 top-1/2 -translate-y-1/2 rounded p-1.5 text-muted-foreground/50 hover:text-foreground hover:bg-accent transition-colors",children:(0,b.jsx)(r,{className:"size-4"})})]}),s?.name&&(0,b.jsx)("p",{id:"agent-name-error",className:"text-xs text-destructive mt-1",children:s.name})]}),(0,b.jsx)("textarea",{id:"agent-description",value:d,onChange:a=>{e(a.target.value),a.target.style.height="auto",a.target.style.height=`${a.target.scrollHeight}px`},ref:a=>{a&&(a.style.height="auto",a.style.height=`${a.scrollHeight}px`)},placeholder:"Add a description…",rows:1,className:"w-full resize-none overflow-hidden border-0 bg-transparent px-0 py-0.5 text-sm text-foreground shadow-none outline-none placeholder:text-muted-foreground/40 focus-visible:ring-0"}),v,(t||p.length>0)&&(0,b.jsxs)("div",{id:"agent-runtime-select",className:"space-y-1.5",children:[(0,b.jsx)(f.Label,{className:"text-xs text-muted-foreground",children:"Runtime"}),t?(0,b.jsx)("div",{className:"space-y-1.5",role:"radiogroup","aria-label":"Runtime",children:0===p.length?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No runtimes — start a daemon first"}):p.map(a=>{let c="online"===a.status,d=m===a.id,e="string"==typeof a.device_info?a.device_info:"";return(0,b.jsxs)("label",{className:(0,n.cn)("flex items-center gap-2.5 rounded-lg border p-2.5 cursor-pointer transition-colors",d?"border-primary bg-primary/5":"border-border/50 hover:border-foreground/20",!c&&"opacity-40 pointer-events-none"),children:[(0,b.jsx)("input",{type:"radio",name:"runtime",value:a.id,checked:d,disabled:!c,onChange:()=>{let b=p.find(a=>a.id===m)?.provider,c=a.provider;o(a.id),b&&b!==c&&l("")},className:"accent-primary size-3.5"}),(0,b.jsx)(i.ProviderLogo,{provider:a.provider,className:"h-4 w-4 shrink-0"}),(0,b.jsx)("span",{className:"text-sm",children:a.provider}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),!c&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:"offline"})]},a.id)})}):(0,b.jsx)(j,{value:m,onValueChange:a=>{let b=p.find(a=>a.id===m)?.provider,c=p.find(b=>b.id===a)?.provider;o(a),b&&b!==c&&l("")},runtimes:p,triggerProps:{"aria-invalid":!!s?.runtimeId,"aria-describedby":s?.runtimeId?"agent-runtime-error":void 0}}),s?.runtimeId&&(0,b.jsx)("p",{id:"agent-runtime-error",className:"text-xs text-destructive",children:s.runtimeId})]}),(h||w)&&(0,b.jsxs)(x,{children:[h&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(f.Label,{className:"text-xs text-muted-foreground",children:"Instructions"}),(0,b.jsx)("textarea",{id:"agent-instructions",value:g??"",onChange:a=>{h(a.target.value),a.target.style.height="auto",a.target.style.height=`${a.target.scrollHeight}px`},ref:a=>{a&&(a.style.height="auto",a.style.height=`${a.scrollHeight}px`)},placeholder:"System prompt or instructions...",rows:3,className:"w-full resize-none overflow-hidden border-0 bg-transparent px-0 py-1 text-sm text-foreground shadow-none outline-none placeholder:text-muted-foreground/40 focus-visible:ring-0"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(f.Label,{className:"text-xs text-muted-foreground",children:"Model"}),(0,b.jsx)("input",{id:"agent-model",value:k,onChange:a=>l(a.target.value),placeholder:"Default (runtime model)",list:"agent-model-options",className:"w-full border-0 bg-transparent px-0 py-0.5 text-sm text-foreground shadow-none outline-none placeholder:text-muted-foreground/40 focus-visible:ring-0"}),q.length>0&&(0,b.jsx)("datalist",{id:"agent-model-options",children:q.map(a=>(0,b.jsx)("option",{value:a},a))})]}),w]})]})},"getHandleError",0,function(a){return a&&!m(a)?"Must be 3+ characters, letters/numbers/hyphens only":""},"nameToHandle",0,function(a){return a.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}],224226)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_web_src_components_00xgo_-._.js.map
|