1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[32238],{9562:(e,t,n)=>{n.d(t,{Q:()=>o,c:()=>l});var a=n(96775);let i=["edu","edu.*","ac.*","sch.*","k12.*.*"],s=["gov","gov.*","mil","mil.*","gouv.*","gc.ca"];function r(e,t){return t.some(t=>(function(e,t){let n=t.split(".");if(n.length>e.length)return!1;let a=e.slice(e.length-n.length);return n.every((e,t)=>"*"===e?a[t].length>0:a[t]===e)})(e,t))}function o(e){let{class:t}=function(e){let t=(0,a.c_)(e);if(!t){let t=(null!=e?e:"").trim().toLowerCase(),n=t.indexOf("@"),a=n>=0?t.slice(n+1):"";return{domain:null,class:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)&&a.includes(".")?"freemail":"unknown"}}let n=t.split(".");return r(n,i)?{domain:t,class:"education"}:r(n,s)?{domain:t,class:"government"}:{domain:t,class:"corporate"}}(e);return"corporate"===t||"education"===t||"government"===t}function l(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim())}},13149:(e,t,n)=>{n.d(t,{c:()=>l});var a=n(95155);n(12115);var i=n(88240),s=n(84823),r=n(22426);let o={file:"entity-link entity-link-file",agent:"entity-link entity-link-agent",task:"entity-link entity-link-task",integration:"entity-link entity-link-integration"};function l(e){let{text:t}=e,{processed:n,entities:l}=function(e){let t=(0,r.jT)(e),n=new Map;if(0===t.length)return{processed:e,entities:n};let a="",i=0;for(let s=0;s<t.length;s++){let r=t[s],o="__ENTITY_".concat(s,"__");n.set(o,r),a+=e.slice(i,r.start),a+="[".concat(r.display,"](entity://").concat(o,")"),i=r.end}return{processed:a+=e.slice(i),entities:n}}(t.replace(/^(\d+)\.\s*$/gm,"$1\\."));return(0,a.jsx)("div",{className:"chat-md",children:(0,a.jsx)(i.oz,{remarkPlugins:[s.A],components:{a:e=>{let{href:t,children:n}=e;if(null==t?void 0:t.startsWith("entity://")){let e=t.replace("entity://",""),i=l.get(e);if(i)return(0,a.jsxs)("button",{className:o[i.type],onClick:e=>{e.stopPropagation(),(0,r.se)(i)},title:"file"===i.type?"Open /shared/files/".concat(i.data.path):"agent"===i.type?"View agent ".concat(i.data.name):"task"===i.type?"Open task #".concat(i.data.id):"Open ".concat(i.data.id," integration"),children:[(0,a.jsx)("span",{className:"entity-link-icon",children:r.Nf[i.type]}),n]})}return(0,a.jsx)("a",{className:"chat-md-link",href:t,target:"_blank",rel:"noopener noreferrer",children:n})},code:e=>{let{className:t,children:n}=e;if(null==t?void 0:t.startsWith("language-"))return(0,a.jsx)("pre",{className:"chat-md-codeblock",children:(0,a.jsx)("code",{children:n})});let i="string"==typeof n?n:"",s=(0,r.jT)(i);if(1===s.length&&0===s[0].start&&s[0].end===i.length){let e=s[0];return(0,a.jsxs)("button",{className:"".concat(o[e.type]," entity-link-code"),onClick:t=>{t.stopPropagation(),(0,r.se)(e)},title:"file"===e.type?"Open /shared/files/".concat(e.data.path):"agent"===e.type?"View agent ".concat(e.data.name):"task"===e.type?"Open task #".concat(e.data.id):"Open ".concat(e.data.id," integration"),children:[(0,a.jsx)("span",{className:"entity-link-icon",children:r.Nf[e.type]}),e.display]})}return(0,a.jsx)("code",{className:"chat-md-code",children:n})},pre:e=>{let{children:t}=e;return(0,a.jsx)(a.Fragment,{children:t})}},children:n})})}},18694:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(95155);function i(e){let{title:t,children:n,className:i="",style:s,overlay:r,resizable:o,isResizing:l,onResizeMouseDown:c,headerActions:d}=e;return(0,a.jsxs)("div",{className:"glass-window ".concat(o?"glass-window-resizable":""," ").concat(i),style:s,children:[r,o&&c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"glass-resize-handle glass-resize-handle-right nopan".concat(l?" glass-resize-active":""),"data-edge":"right",onMouseDown:c}),(0,a.jsx)("div",{className:"glass-resize-handle glass-resize-handle-bottom nopan".concat(l?" glass-resize-active":""),"data-edge":"bottom",onMouseDown:c}),(0,a.jsx)("div",{className:"glass-resize-handle glass-resize-handle-corner nopan".concat(l?" glass-resize-active":""),"data-edge":"corner",onMouseDown:c})]}),(0,a.jsxs)("div",{className:"glass-window-header custom-drag-handle",children:[(0,a.jsxs)("div",{className:"glass-window-grip","aria-hidden":"true",children:[(0,a.jsx)("span",{}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{})]}),t&&(0,a.jsx)("span",{className:"glass-window-title",children:t}),d&&(0,a.jsx)("div",{className:"glass-window-header-actions nopan nodrag",onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:d})]}),(0,a.jsx)("div",{className:"glass-window-content nopan",children:n})]})}n(12115)},22426:(e,t,n)=>{n.d(t,{Nf:()=>o,f:()=>d,jT:()=>r,se:()=>s});var a=n(95155);n(12115);let i=[{type:"file",regex:/\/shared\/files\/([^\s,)\]}>"`]+)/g,extract:e=>({display:e[1],data:{path:e[1]}})},{type:"agent",regex:/(?:^|\s)@([a-zA-Z][a-zA-Z0-9_-]{1,})/g,extract:e=>({display:"@".concat(e[1]),data:{name:e[1]}})},{type:"task",regex:/(?:task\s+)?#(\d{1,6})\b/gi,extract:e=>({display:"#".concat(e[1]),data:{id:e[1]}})},{type:"integration",regex:/\[integration:([a-zA-Z0-9_-]+)\]/g,extract:e=>({display:e[1].split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),data:{id:e[1]}})}];function s(e){switch(e.type){case"file":window.dispatchEvent(new CustomEvent("mi:open-file-viewer",{detail:{officeId:"__current__",filename:e.data.path}}));break;case"agent":window.dispatchEvent(new CustomEvent("mi:focus-agent",{detail:{name:e.data.name}}));break;case"task":window.dispatchEvent(new CustomEvent("mi:open-task-detail",{detail:{taskId:parseInt(e.data.id,10)}}));break;case"integration":window.dispatchEvent(new CustomEvent("mi:open-integration",{detail:{integrationId:e.data.id}}))}}function r(e){let t=[];for(let n of i){let a,i=new RegExp(n.regex.source,n.regex.flags);for(;null!==(a=i.exec(e));){let e=n.extract(a);if(!e)continue;let i=a[0],s=i.length-i.trimStart().length;t.push({type:n.type,start:a.index+s,end:a.index+a[0].length,display:e.display,data:e.data})}}t.sort((e,t)=>
1e.start-t.start);let n=[],a=0;for(let e of t)e.start>=a&&(n.push(e),a=e.end);return n}let o={file:"\uD83D\uDCC4",agent:"\uD83E\uDD16",task:"â",integration:"\uD83D\uDD17"},l={file:"entity-link entity-link-file",agent:"entity-link entity-link-agent",task:"entity-link entity-link-task",integration:"entity-link entity-link-integration"};function c(e){let{entity:t}=e;return(0,a.jsxs)("button",{className:l[t.type],onClick:e=>{e.stopPropagation(),s(t)},title:"file"===t.type?"Open /shared/files/".concat(t.data.path):"agent"===t.type?"View agent ".concat(t.data.name):"task"===t.type?"Open task #".concat(t.data.id):"Open ".concat(t.data.id," integration"),children:[(0,a.jsx)("span",{className:"entity-link-icon",children:o[t.type]}),t.display]})}function d(e){let{text:t}=e,n=r(t);if(0===n.length)return(0,a.jsx)(a.Fragment,{children:t});let i=[],s=0;for(let e of n)e.start>s&&i.push(t.slice(s,e.start)),i.push((0,a.jsx)(c,{entity:e},e.start)),s=e.end;return s<t.length&&i.push(t.slice(s)),(0,a.jsx)(a.Fragment,{children:i})}},28133:(e,t,n)=>{n.d(t,{s:()=>i});var a=n(12115);function i(e,t){let[n,i]=(0,a.useState)("idle"),[s,r]=(0,a.useState)(null),[o,l]=(0,a.useState)(null),[c,d]=(0,a.useState)(""),u=(0,a.useRef)(null),h=(0,a.useRef)(!1),g=(0,a.useRef)(0),p=(0,a.useCallback)(async t=>{let n;try{n=await fetch("/api/offices/".concat(e,"/chat-server"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(e){return{__transient:!0}}let a=await n.text().catch(()=>"");try{return a?JSON.parse(a):{}}catch(e){return{__transient:!0}}},[e]);(0,a.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let m=(0,a.useCallback)(async()=>{let e=++g.current;u.current&&clearTimeout(u.current),i("starting"),d(""),r(null),h.current=!1;let n=Date.now(),a=(e,t)=>{u.current=setTimeout(e,t)},s=()=>e!==g.current,o=async()=>{let e=await p({action:"qr-start"});if(!s()){if("string"==typeof e.error){d(e.error),i("error");return}if("connected"===e.status){var u;i("connected"),l(null!=(u=e.phoneNumber)?u:null),null==t||t();return}if(e.qrDataUrl){h.current=!0,r(e.qrDataUrl),i("scanning"),a(c,2e3);return}if(Date.now()-n>9e4){d("Could not reach the WhatsApp service. Try again."),i("error");return}a(o,2500)}},c=async()=>{let e=await p({action:"qr-poll"});if(!s()){if(e.__transient)return void a(c,2e3);if("connected"===e.status){var n;i("connected"),l(null!=(n=e.phoneNumber)?n:null),null==t||t();return}if("scanned"===e.status){i("scanned"),r(null),a(c,1500);return}if("expired"===e.status){d("Your WhatsApp link expired. Start again and re-scan the QR code."),i("error");return}e.qrDataUrl&&(h.current=!0,r(e.qrDataUrl),i("scanning")),a(c,2e3)}};o()},[p,t]);return{pairingState:n,qrDataUrl:s,phoneNumber:o,error:c,startPairing:m,cancelPairing:(0,a.useCallback)(()=>{g.current++,u.current&&clearTimeout(u.current),h.current=!1,i("idle"),r(null)},[]),resetPairing:(0,a.useCallback)(async()=>{g.current++,u.current&&clearTimeout(u.current),h.current=!1,i("idle"),r(null),l(null),await p({action:"reset"})},[p])}}},32238:(e,t,n)=>{n.d(t,{_O:()=>eO,Yb:()=>ea,Ay:()=>eD});var a=n(95155),i=n(12115),s=n(68591),r=n(12108),o=n(15448),l=n(75525),c=n(55607),d=n(20144),u=n(19302),h=n(13062),g=n(18186),p=n(83744),m=n(97207),f=n(71366),y=n(5196),x=n(24357),w=n(61106),b=n(29586),j=n(76637),v=n(82266),k=n(79876),N=n(58237),S=n(35081),C=n(59015),z=n(39920),E=n(6183),I=n(86886),T=n(38770),A=n(68323),O=n(18694),L=n(13149),D=n(84616),P=n(51154),M=n(32892),R=n(62525);function U(e){let{officeId:t}=e,{connectors:n,loading:s,error:r,add:o,remove:l}=function(e){let[t,n]=(0,i.useState)([]),[a,s]=(0,i.useState)(!0),[r,o]=(0,i.useState)(null),l=(0,i.useCallback)(async()=>{if(!e){n([]),s(!1);return}s(!0);try{var t;let a=await fetch("/api/offices/".concat(e,"/mcp/servers"));if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"HTTP ".concat(a.status))}let i=await a.json();n(null!=(t=i.servers)?t:[]),o(null)}catch(e){o(e instanceof Error?e.message:"Failed to load connectors")}finally{s(!1)}},[e]),c=(0,i.useCallback)(async t=>{if(!e)throw Error("No office selected");let n=await fetch("/api/offices/".concat(e,"/mcp/servers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"HTTP ".concat(n.status));await l()},[e,l]),d=(0,i.useCallback)(async t=>{if(!e)throw Error("No office selected");
1let n=await fetch("/api/offices/".concat(e,"/mcp/servers/").concat(encodeURIComponent(t)),{method:"DELETE"});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"HTTP ".concat(n.status));await l()},[e,l]);return(0,i.useEffect)(()=>{l()},[l]),{connectors:t,loading:a,error:r,refresh:l,add:c,remove:d}}(t),[c,d]=(0,i.useState)(!1),[u,h]=(0,i.useState)(null),g=async e=>{h(e);try{await l(e)}catch(e){}finally{h(null)}};return(0,a.jsxs)("div",{style:_.root,children:[(0,a.jsxs)("div",{style:_.header,children:[(0,a.jsx)("span",{style:_.title,children:"Custom connectors"}),(0,a.jsxs)("button",{type:"button",style:_.addBtn,onClick:()=>d(!0),children:[(0,a.jsx)(D.A,{size:14})," Add"]})]}),(0,a.jsx)("p",{style:_.subtitle,children:"Connect your own tools so your agents can use them. Paste a server address; we'll wire it up."}),r&&(0,a.jsx)("div",{style:_.error,children:r}),s?(0,a.jsxs)("div",{style:_.muted,children:[(0,a.jsx)(P.A,{size:14,style:{animation:"spin 1s linear infinite"}})," Loadingâ¦"]}):0===n.length?(0,a.jsx)("div",{style:_.empty,children:"No custom connectors yet."}):(0,a.jsx)("ul",{style:_.list,children:n.map(e=>(0,a.jsxs)("li",{style:_.item,children:[(0,a.jsx)("span",{style:_.itemIcon,"aria-hidden":!0,children:(0,a.jsx)(M.A,{size:15,color:"#a78bfa"})}),(0,a.jsxs)("div",{style:_.itemBody,children:[(0,a.jsx)("span",{style:_.itemName,children:e.name}),(0,a.jsx)("span",{style:_.itemUrl,children:e.url})]}),(0,a.jsx)("button",{type:"button",style:_.removeBtn,disabled:u===e.name,onClick:()=>g(e.name),"aria-label":"Remove ".concat(e.name),children:u===e.name?(0,a.jsx)(P.A,{size:14,style:{animation:"spin 1s linear infinite"}}):(0,a.jsx)(R.A,{size:14})})]},e.name))}),c&&(0,a.jsx)(F,{existing:n,onClose:()=>d(!1),onAdd:async e=>{await o(e),d(!1)}})]})}function F(e){let{existing:t,onClose:n,onAdd:s}=e,[r,o]=(0,i.useState)(""),[l,c]=(0,i.useState)(""),[d,u]=(0,i.useState)("none"),[h,g]=(0,i.useState)(""),[p,m]=(0,i.useState)(""),[f,y]=(0,i.useState)(!1),[x,w]=(0,i.useState)(null),b=r.trim().toLowerCase(),j=/^[a-z0-9][a-z0-9_-]{0,38}$/.test(b)&&"mitosis"!==b,v=/^https?:\/\/.+/i.test(l.trim()),k="none"===d||"bearer"===d&&""!==h.trim()||"header"===d&&""!==p.trim()&&""!==h.trim(),N=t.some(e=>e.name===b),S=j&&v&&k&&!N&&!f,C=async()=>{if(S){y(!0),w(null);try{await s({name:b,url:l.trim(),transport:/\/sse\/?($|\?)/i.test(l.trim())?"sse":"http",authType:d,headerName:"header"===d?p.trim():void 0,token:"none"===d?void 0:h})}catch(e){w(e instanceof Error?e.message:"Failed to add connector"),y(!1)}}};return(0,a.jsx)("div",{style:_.backdrop,onClick:n,children:(0,a.jsxs)("div",{style:_.modal,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{style:_.modalHeader,children:[(0,a.jsx)("span",{style:_.modalTitle,children:"Add custom connector"}),(0,a.jsx)("button",{type:"button",style:_.closeBtn,onClick:n,"aria-label":"Close",children:"\xd7"})]}),(0,a.jsx)("label",{style:_.label,children:"Name"}),(0,a.jsx)("input",{style:_.input,value:r,onChange:e=>o(e.target.value),placeholder:"my-crm",autoFocus:!0,autoComplete:"off",spellCheck:!1}),""!==r&&!j&&(0,a.jsx)("span",{style:_.hintErr,children:"Use lowercase letters, digits, â-â or â_â."}),N&&(0,a.jsx)("span",{style:_.hintErr,children:"A connector with this name already exists."}),(0,a.jsx)("label",{style:_.label,children:"Server address"}),(0,a.jsx)("input",{style:_.input,value:l,onChange:e=>c(e.target.value),placeholder:"https://mcp.example.com/sse",autoComplete:"off",spellCheck:!1}),(0,a.jsx)("label",{style:_.label,children:"Authentication"}),(0,a.jsx)("div",{style:_.segmented,children:["none","bearer","header"].map(e=>(0,a.jsx)("button",{type:"button",style:{..._.segment,...d===e?_.segmentActive:{}},onClick:()=>u(e),children:"none"===e?"None":"bearer"===e?"Access token":"Custom header"},e))}),"header"===d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{style:_.label,children:"Header name"}),(0,a.jsx)("input",{style:_.input,value:p,onChange:e=>m(e.target.value),placeholder:"X-Api-Key",autoComplete:"off",spellCheck:!1})]}),"none"!==d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{style:_.label,children:"bearer"===d?"Access token":"Header value"}),(0,a.jsx)("input",{style:_.input,type:"password",value:h,onChange:e=>g(e.target.value),placeholder:"Paste the value your service gave you",autoComplete:"off",spellCheck:!1})]}),x&&(0,a.jsx)("div",{style:_.error,children:x}),(0,a.jsxs)("div",{style:_.actions,children:[(0,a.jsx)("button",{type:"button",style:_.cancelBtn,onClick:n,children:"Cancel"}),(0,a.jsx)("button",{type:"button",style:_.submitBtn,disabled:!S,onClick:C,children:f?(0,a.jsx)(P.A,{size:14,style:{animation:"spin 1s linear infinite"}}):"Add connector"})]})]})})}let _={root:{display:"flex",flexDirection:"column",gap:10,color:"#e8e4e0"},header:{display:"flex",alignItems:"center",justifyContent:"space-between"},title:{fontSize:14,fontWeight:500},subtitle:{fontSize:12,color:"rgba(255,255,255,0.5)",margin:0,lineHeight:1.4},addBtn:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:"#e8e4e0",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"5px 10px",cursor:"pointer"},list:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:8},item:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:"rgba(255,255,255,0.025)",border:"1px solid rgba(255,255,255,0.10)",borderRadius:10},itemIcon:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:8,background:"rgba(167,139,250,0.12)",flexShrink:0},itemBody:{display:"flex",flexDirection:"column",minWidth:0,flex:1},itemName:{fontSize:13,fontWeight:500},itemUrl:{fontSize:11,color:"rgba(255,255,255,0.45)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},removeBtn:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,color:"rgba(255,255,255,0.5)",background:"transparent",border:"none",cursor:"pointer",borderRadius:6},muted:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"rgba(255,255,255,0.5)"},empty:{fontSize:12,color:"rgba(255,255,255,0.4)",padding:"8px 0"},error:{fontSize:12,color:"#fca5a5",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,padding:"8px 10px"},backdrop:{position:"fixed",inset:0,background:"rgba(8,8,12,0.82)",backdropFilter:"blur(14px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:16},modal:{width:"100%",maxWidth:460,maxHeight:"88vh",overflowY:"auto",background:"rgba(20,20,28,0.96)",border:"1px solid rgba(255,255,255,0.10)",borderRadius:16,padding:18,dis
1play:"flex",flexDirection:"column",gap:6,color:"#e8e4e0"},modalHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},modalTitle:{fontSize:15,fontWeight:600},closeBtn:{width:28,height:28,fontSize:20,lineHeight:1,background:"transparent",border:"none",color:"rgba(255,255,255,0.6)",cursor:"pointer"},label:{fontSize:12,color:"rgba(255,255,255,0.6)",marginTop:8},input:{height:36,borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.03)",color:"#e8e4e0",padding:"0 12px",fontSize:13,outline:"none"},hintErr:{fontSize:11,color:"#fca5a5",marginTop:2},segmented:{display:"flex",gap:6},segment:{flex:1,fontSize:12,padding:"7px 8px",borderRadius:8,cursor:"pointer",background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.10)",color:"rgba(255,255,255,0.7)"},segmentActive:{background:"rgba(167,139,250,0.15)",border:"1px solid rgba(167,139,250,0.45)",color:"#e8e4e0"},actions:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:14},cancelBtn:{fontSize:12,padding:"8px 14px",borderRadius:10,cursor:"pointer",background:"transparent",border:"1px solid rgba(255,255,255,0.14)",color:"#e8e4e0"},submitBtn:{fontSize:12,padding:"8px 16px",borderRadius:10,cursor:"pointer",minWidth:120,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"#8a5cf5",border:"1px solid #8a5cf5",color:"#fff"}};var G=n(9562);let W=[{kind:"single",id:"regulatedIndustry",question:"Is your business in a regulated industry?",hint:"Mitosis Vaults are secured according to the top privacy regulations in the US and around the world.",options:[{id:"legal",label:"Legal"},{id:"healthcare",label:"Healthcare"},{id:"finance",label:"Finance"},{id:"utilities",label:"Utilities"},{id:"insurance",label:"Insurance"},{id:"other",label:"Other"}],allowOther:!0},{kind:"single",id:"businessSize",question:"What is the size of your business?",hint:"Mitosis works best for companies generating > $100k/month, but we also help smaller businesses through our startups program.",options:[{id:"lt10",label:"Less than 10 employees"},{id:"10_50",label:"10 â 50"},{id:"50_100",label:"50 â 100"},{id:"100plus",label:"100+"}]},{kind:"single",id:"usesAi",question:"Does your business already have AI agents or use any AI products?",options:[{id:"yes",label:"Yes"},{id:"no",label:"No"}]},{kind:"multi",id:"services",question:"Which of the following services does your business use currently?",hint:"Mitosis automatically imports data and prepares it for AI readiness. Select all that apply.",options:[{id:"google_workspace",label:"Google Workspace"},{id:"microsoft_office",label:"Microsoft Office"},{id:"salesforce",label:"Salesforce"},{id:"hubspot",label:"HubSpot"},{id:"other",label:"Other"}],allowOther:!0,allowEmpty:!0},{kind:"multi",id:"social",question:"Does your business have an active social media presence?",hint:"Mitosis intakes social media activity and uses it to inform internal decision making. Select all that apply.",options:[{id:"linkedin",label:"LinkedIn"},{id:"twitter",label:"Twitter"},{id:"instagram_facebook",label:"Instagram / Facebook"},{id:"tiktok",label:"TikTok"},{id:"later",label:"Letâs talk about it later"},{id:"none",label:"No active presence"}],allowEmpty:!0},{kind:"single",id:"readiness",question:"Are you ready to change the way you work with AI?",hint:"Mitosis has already helped thousands of organizations deploy best-in-class agents.",options:[{id:"right_away",label:"YES â right away."},{id:"not_in_a_hurry",label:"Yes, but not in a hurry"},{id:"meh",label:"Meh"},{id:"low_priority",label:"Not a huge priority"}]},{kind:"single",id:"dataLake",question:"Does your business already have a data lake?",hint:"Itâs okay if you donât â Mitosis Vaults are the #1 solution for any AI-oriented business, and we can onboard your data seamlessly in under a week.",options:[{id:"bigquery",label:"Google BigQuery"},{id:"snowflake",label:"Snowflake"},{id:"databricks",label:"Databricks"},{id:"redshift",label:"Amazon Redshift"},{id:"bigtable",label:"Google Bigtable"},{id:"other",label:"Other"},{id:"none",label:"None of the above"}]},{kind:"email",id:"email",question:"Whatâs your corporate email?",hint:"Weâll only use this to follow up. Generic providers (Gmail, Outlook, Yahoo, etc.) arenât accepted.",placeholder:"[email protected]"}],q=new Set(["50_100","100plus"]),B={regulatedIndustry:null,regulatedIndustryOther:"",businessSize:null,usesAi:null,
1services:[],servicesOther:"",social:[],readiness:null,dataLake:null,email:""};function H(e){var t;let{open:s,onClose:r,placement:o="eligibility",initialEmail:l}=e,[c,d]=(0,i.useState)(0),[u,h]=(0,i.useState)(B),[g,p]=(0,i.useState)(null),[m,f]=(0,i.useState)("form"),y=(0,i.useRef)(null),x=(0,i.useRef)(null),w=(0,i.useMemo)(()=>W.filter(e=>"dataLake"!==e.id||!u.businessSize||q.has(u.businessSize)),[u.businessSize]),b=null!=(t=w[c])?t:null,j=w.length;(0,i.useEffect)(()=>{s&&(d(0),h({...B,email:null!=l?l:""}),p(null),f("form"))},[s,l]),(0,i.useEffect)(()=>{if(s)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[s]),(0,i.useEffect)(()=>{if(!s)return;let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,r]),(0,i.useEffect)(()=>{if(s&&"form"===m&&b&&"email"===b.kind){let e=setTimeout(()=>{var e;return null==(e=x.current)?void 0:e.focus()},60);return()=>clearTimeout(e)}},[s,m,b]),(0,i.useEffect)(()=>{if(b&&("single"===b.kind&&"regulatedIndustry"===b.id&&"other"===u.regulatedIndustry||"multi"===b.kind&&"services"===b.id&&u.services.includes("other"))){let e=setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},60);return()=>clearTimeout(e)}},[b,u.regulatedIndustry,u.services]);let v=(0,i.useCallback)(async()=>{f("submitting"),p(null);try{let e={email:u.email.trim(),regulatedIndustry:u.regulatedIndustry,regulatedIndustryOther:"other"===u.regulatedIndustry?u.regulatedIndustryOther.trim():null,businessSize:u.businessSize,usesAi:u.usesAi,services:u.services,servicesOther:u.services.includes("other")?u.servicesOther.trim():null,social:u.social,readiness:u.readiness,dataLake:u.businessSize&&q.has(u.businessSize)?u.dataLake:null,placement:o},t=await fetch("/api/demo-inquiry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);p((null==e?void 0:e.error)||"Something went wrong. Please try again."),f("error");return}try{(await Promise.resolve().then(n.bind(n,72341))).default.identify(u.email.trim().toLowerCase(),{crm_type:"contact",crm_source:"demo-".concat(o)})}catch(e){}f("success")}catch(e){p("Network error. Please try again."),f("error")}},[u,o]);if(!s)return null;let k=()=>{if(b){if(p(null),"single"===b.kind){let e=u[b.id];if(!e)return void p("Please pick an option.");if(b.allowOther&&"other"===e&&"regulatedIndustry"===b.id&&!u.regulatedIndustryOther.trim())return void p("Please specify your industry.")}else if("multi"===b.kind){let e=u[b.id];if(!b.allowEmpty&&0===e.length)return void p("Please pick at least one option.");if(b.allowOther&&e.includes("other")&&"services"===b.id&&!u.servicesOther.trim())return void p("Please specify which other service.")}else if("email"===b.kind){let e=u.email.trim();if(!e)return void p("Email is required.");if(!(0,G.c)(e))return void p("That doesnât look like an email.");if(!(0,G.Q)(e))return void p("Please use your corporate email â generic providers (Gmail, Outlook, Yahoo, etc.) arenât accepted.")}c<j-1?d(e=>e+1):v()}},N=(e,t)=>{h(n=>{let a=n[e],i=a.includes(t)?a.filter(e=>e!==t):[...a,t];return{...n,[e]:i}})},S=(e,t)=>{h(n=>({...n,[e]:t})),p(null)};return(0,a.jsx)("div",{className:"partner-modal-overlay",onClick:r,children:(0,a.jsxs)("div",{className:"partner-modal demo-modal",role:"dialog","aria-modal":"true","aria-label":"Tell us about your business",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("button",{className:"partner-modal-close",onClick:r,"aria-label":"Close",children:(0,a.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}),"form"===m&&(0,a.jsx)("div",{className:"partner-modal-progress","aria-hidden":"true",children:(0,a.jsx)("div",{className:"partner-modal-progress-bar",style:{width:"".concat((c+1)/j*100,"%")}})}),(0,a.jsxs)("div",{className:"partner-modal-body",children:["submitting"===m&&(0,a.jsx)("div",{className:"partner-modal-status",children:(0,a.jsx)("p",{className:"partner-modal-status-text",children:"Sendingâ¦"})}),"success"===m&&(0,a.jsxs)("div",{className:"partner-modal-status",children:[(0,a.jsx)("h2",{className:"partner-modal-q",children:"Thanks. Weâll be in touch."}),(0,a.jsx)("p",{className:"partner-modal-hint",children:"Your responses landed in our inbox. A member of our team will reach out within a few business days to schedule your demo."}),(0,a.jsx)("button",{className:"partner-modal-next",onClick:r,children:"Close"})]}),"error"===m&&(0,a.jsxs)("div",{className:"partner-modal-status",children:[(0,a.jsx)("h2",{className:"partner-modal-q",children:"Something went wrong."}),(0,a.jsxs)("p",{className:"partner-modal-hint",children:[g||"Please try again."," If the problem persists, email us at"," ",(0,a.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]}),(0,a.jsx)("button",{className:"partner-modal-next",onClick:()=>f("form"),children:"Try again"})]}),"form"===m&&b&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"partner-modal-step-meta",children:[(0,a.jsx)("span",{className:"partner-modal-step-num",children:c+1}),(0,a.jsxs)("span",{className:"partner-modal-step-of",children:["of ",j]})]}),(0,a.jsx)("h2",{className:"partner-modal-q",children:b.question}),b.hint&&(0,a.jsx)("p",{className:"partner-modal-hint",children:b.hint}),"single"===b.kind&&(0,a.jsxs)("div",{className:"demo-modal-options",children:[b.options.map(e=>{let t=u[b.id]===e.id;return(0,a.jsxs)("button",{type:"button",className:"demo-modal-option ".concat(t?"is-selected":""),onClick:()=>S(b.id,e.id),children:[(0,a.jsx)("span",{className:"demo-modal-option-radio","aria-hidden":!0}),(0,a.jsx)("span",{className:"demo-modal-option-label",children:e.label})]},e.id)}),b.allowOther&&"other"===u[b.id]&&"regulatedIndustry"===b.id&&(0,a.jsx)("input",{ref:y,className:"partner-modal-input demo-modal-other-input",type:"text",placeholder:"Type your industry",value:u.regulatedIndustryOther,onChange:e=>h(t=>({...t,regulatedIndustryOther:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),k())},maxLength:200})]}),"multi"===b.kind&&(0,a.jsxs)("div",{className:"demo-modal-options",children:[b.options.map(e=>{let t=u[b.id].includes(e.id);return(0,a.jsxs)("button",{type:"button",className:"demo-modal-option demo-modal-option--check ".concat(t?"is-selected":""),onClick:()=>N(b.id,e.id),children:[(0,a.jsx)("span",{className:"demo-modal-option-check","aria-hidden":!0,
1children:t&&(0,a.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,a.jsx)("path",{d:"M3 8.5l3.2 3.2L13 4.8",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,a.jsx)("span",{className:"demo-modal-option-label",children:e.label})]},e.id)}),b.allowOther&&u[b.id].includes("other")&&"services"===b.id&&(0,a.jsx)("input",{ref:y,className:"partner-modal-input demo-modal-other-input",type:"text",placeholder:"Type the other service",value:u.servicesOther,onChange:e=>h(t=>({...t,servicesOther:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),k())},maxLength:200})]}),"email"===b.kind&&(0,a.jsx)("input",{ref:x,className:"partner-modal-input",type:"email",placeholder:b.placeholder,value:u.email,onChange:e=>h(t=>({...t,email:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),k())},autoComplete:"email",inputMode:"email",spellCheck:!1,maxLength:200}),g&&(0,a.jsx)("p",{className:"partner-modal-error",children:g}),(0,a.jsxs)("div",{className:"partner-modal-actions",children:[c>0&&(0,a.jsx)("button",{className:"partner-modal-back",onClick:()=>{0!==c&&(p(null),d(e=>e-1))},children:"â Back"}),(0,a.jsxs)("button",{className:"partner-modal-next",onClick:k,children:[c===j-1?"Send":"Next"," â"]}),"email"===b.kind&&(0,a.jsxs)("span",{className:"partner-modal-enter-hint",children:["press ",(0,a.jsx)("kbd",{children:"Enter"})]})]})]})]})]})})}var J=n(69498);n(28133);var Y=n(83612);function V(e){return"".concat(e.id,"::").concat(e.instanceLabel||"__default__")}let K=["https://www.googleapis.com/auth/userinfo.email"],$=[{key:"calendar",label:"Calendar",scope:"https://www.googleapis.com/auth/calendar.readonly",hint:"Read-only access to your events"},{key:"drive",label:"Drive",scope:"https://www.googleapis.com/auth/drive.file",hint:"Only the files you pick â Docs and Sheets included"}];$.map(e=>e.key),[...$.map(e=>e.scope),...K].join(" "),["https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/drive.readonly","https://www.googleapis.com/auth/calendar.readonly","https://www.googleapis.com/auth/contacts.readonly",...K].join(" ");var X=n(34037);function Q(e){let{message:t,context:n,officeId:s,trace:r}=e,[o,l]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),u=(0,i.useCallback)(async()=>{l(!0);try{let e=Error("[bug-report] User reported error in ".concat(n||"unknown")).stack,a=["User encountered this error".concat(n?" in **".concat(n,"**"):"",":"),"","> ".concat(t),""];(null==r?void 0:r.traceId)&&a.push("**Trace ID:** `".concat(r.traceId,"`")),(null==r?void 0:r.route)&&a.push("**Route:** ".concat(r.method||"?"," ").concat(r.route)),(null==r?void 0:r.timestamp)&&a.push("**Server time:** ".concat(r.timestamp)),(null==r?void 0:r.upstream)&&(a.push("**Upstream:** ".concat(r.upstream," â HTTP ").concat(r.upstreamStatus||"?")),r.upstreamUrl&&a.push("**Upstream URL:** ".concat(r.upstreamUrl)),r.upstreamLatencyMs&&a.push("**Upstream latency:** ".concat(r.upstreamLatencyMs,"ms"))),(null==r?void 0:r.upstreamError)&&a.push("","**Upstream error:**","```",String(r.upstreamError),"```"),(null==r?void 0:r.requestContext)&&a.push("","**Request context:**","```json",JSON.stringify(r.requestContext,null,2),"```"),(null==r?void 0:r.stack)&&a.push("","**Server stack:**","```",String(r.stack),"```"),e&&a.push("","**Client stack:**","```",e,"```"),(await fetch("/api/bug-reports",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Error: ".concat(t.slice(0,150)),description:a.join("\n"),severity:(null==r?void 0:r.upstreamStatus)&&r.upstreamStatus>=500?"high":"medium",officeId:s||void 0,pageUrl:window.location.href,consoleErrors:(0,X.$)(),metadata:{source:"inline-error-report",errorContext:n,errorMessage:t,serverTrace:r||null,clientStack:e,clientEnvironment:function(){var e,t,n,a,i,s;let r="undefined"!=typeof navigator?navigator:null,o=window,l="undefined"!=typeof performance?performance:null,c=[];try{(null==l?void 0:l.getEntriesByType)&&(c=l.getEntriesByType("resource").filter(e=>e.responseStatus&&e.responseStatus>=400).slice(-10).map(e=>({url:e.name,status:e.responseStatus,duration:Math.round(e.duration),type:e.initiatorType})))}catch(e){}let d={};try{if(null==l?void 0:l.getEntriesByType){let e=l.getEntriesByType("navigation")[0];e&&(d={domContentLoaded:Math.round(e.domContentLoadedEventEnd),loadComplete:Math.round(e.loadEventEnd),ttfb:Math.round(e.responseStart-e.requestStart),transferSize:e.transferSize})}}catch(e){}return{url:null==o||null==(e=o.location)?void 0:e.href,referrer:"undefined"!=typeof document?document.referrer:void 0,userAgent:null==r?void 0:r.userAgent,language:null==r?void 0:r.language,languages:(null==r?void 0:r.languages)?[...r.languages]:void 0,platform:null==r?void 0:r.platform,cookieEnabled:null==r?void 0:r.cookieEnabled,onLine:null==r?void 0:r.onLine,hardwareConcurrency:null==r?void 0:r.hardwareConcurrency,deviceMemory:null==r?void 0:r.deviceMemory,screen:o?{width:null==(t=o.screen)?void 0:t.width,height:null==(n=o.screen)?void 0:n.height,availWidth:null==(a=o.screen)?void 0:a.availWi
1dth,availHeight:null==(i=o.screen)?void 0:i.availHeight,colorDepth:null==(s=o.screen)?void 0:s.colorDepth,pixelRatio:o.devicePixelRatio}:void 0,viewport:o?{innerWidth:o.innerWidth,innerHeight:o.innerHeight,scrollX:Math.round(o.scrollX),scrollY:Math.round(o.scrollY)}:void 0,timing:{pageAge:l?Math.round(l.now()):void 0,...d},recentFailedFetches:c,sessionStorage:{length:"undefined"!=typeof sessionStorage?sessionStorage.length:0},connection:(null==r?void 0:r.connection)?{effectiveType:r.connection.effectiveType,downlink:r.connection.downlink,rtt:r.connection.rtt}:void 0}}()}})})).ok&&d(!0)}catch(e){}finally{l(!1)}},[t,n,s,r]);return c?(0,a.jsx)("span",{className:"inline-error-report-link",style:{cursor:"default",textDecoration:"none",color:"rgba(34,197,94,0.6)"},children:"Reported"}):(0,a.jsx)("button",{className:"inline-error-report-link",onClick:u,disabled:o,children:o?"Reporting...":"Report this issue"})}var Z=n(53311),ee=n(73314),et=n(50589);let en={whatsapp:b.A,telegram:j.A,discord:v.A,signal:k.A,slack:o.A,google:N.A,github:S.A,linear:C.A,notion:z.A,obsidian:E.A,anthropic:I.A,claude:T.A,xmtp:l.A,openai:e=>{let{size:t=14,color:n}=e;return(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:n||"currentColor",width:t,height:t,children:(0,a.jsx)("path",{d:"M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z"})})},gemini:Z.A,venice:ee.A,azure:et.A,browser:A.A,firecrawl:c.A,elevenlabs:d.A,tailscale:u.A,typefully:h.A,"wall-of-fame":g.A,upload:p.A,yappy:m.A};function ea(e){let{icon:t,size:n=14,color:i}=e,s=en[t];return s?(0,a.jsx)(s,{size:n,color:null!=i?i:"rgba(255,255,255,0.6)"}):(0,a.jsx)(f.A,{size:n,color:null!=i?i:"rgba(255,255,255,0.6)"})}let ei={pending:"Not configured",configured:"Configured",active:"Active",error:"Error"},es={pending:"#6b7280",configured:"#3b82f6",active:"#22c55e",error:"#ef4444"};function er(e){var t,n;let{officeId:o,def:l,status:c,onSaved:d}=e,[u,h]=(0,i.useState)(""),[g,p]=(0,i.useState)({}),[m,f]=(0,i.useState)(!1),[y,x]=(0,i.useState)(""),[w,b]=(0,i.useState)(null),[j,v]=(0,i.useState)(null),[k,N]=(0,i.useState)(new Set),S=(0,i.useCallback)(e=>{N(t=>{let n=new Set(t);return n.add(e),n})},[]),C=l.requiredSecrets.filter(e=>e.required&&!e.advanced).every(e=>{var t;return(null!=(t=g[e.key])?t:"").trim().length>0})&&(!j||(null!=(t=g[j.field])?t:"").trim().length>0);(0,i.useEffect)(()=>{if(h(""),l.guideFile){let e=!1;return fetch("/".concat(l.guideFile)).then(e=>{var t;if(!e.ok)throw Error("".concat(e.status));if((null!=(t=e.headers.get("content-type"))?t:"").includes("text/html"))throw Error("html response");return e.text()}).then(t=>{e||h(t)}).catch(()=>{e||h("")}),()=>{e=!0}}},[l.id,l.guideFile]);let z=async()=>{f(!0),x(""),b(null);try{let e=await fetch("/api/offices/".concat(o,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:l.id,secrets:g})});if(401===e.status){let e="/dashboard/connect-sources?office=".concat(o);await (0,r.signOut)({callbackUrl:"/login?callbackUrl=".concat(encodeURIComponent(e))});return}let t=await e.json();e.ok?((0,s.u)("integration_connected",{integration_id:l.id,method:"secret"}),d()):t&&"object"==typeof t&&t.picker&&Array.isArray(t.picker.options)&&t.picker.options.length>0?(v(t.picker),x(""),b(null)):(x(t.error||"Save failed"),b(t))}catch(e){x(e instanceof Error?e.message:"Save failed")}finally{f(!1)}};return(0,a.jsxs)("div",{className:"integration-wizard",children:[u&&(0,a.jsx)("div",{className:"integration-guide",children:(0,a.jsx)(L.c,{text:u})}),l.requiredSecrets.length>0&&(0,a.jsxs)("div",{className:"integration-secret-fields",children:[l.requiredSecrets.filter(e=>!e.advanced).map(e=>{var t;return eo(e,g,p,{revealed:k.has(e.key)||(null!=(t=g[e.key])?t:"").length>0,onReveal:()=>S(e.key)})}),l.requiredSecrets.some(e=>e.advanced)&&(0,a.jsx)(el,{fields:l.requiredSecrets.filter(e=>e.advanced),values:g,setValues:p}),j&&(0,a.jsxs)("div",{className:"integration-field",children:[(0,a.jsx)("label",{className:"integration-field-label",children:j.label}),(0,a.jsx)("p",{className:"integration-field-hint",children:"Multiple workspaces are visible to this API key. Pick the one you want agents to use by default."}),(0,a.jsxs)("select",{className:"integration-field-input",value:null!=(n=g[j.field])?n:"",onCh
1ange:e=>p(t=>({...t,[j.field]:e.target.value})),autoFocus:!0,children:[(0,a.jsx)("option",{value:"",disabled:!0,children:"Choose a workspaceâ¦"}),j.options.map(e=>(0,a.jsxs)("option",{value:e.value,children:[e.label,e.sublabel?" â ".concat(e.sublabel):""]},e.value))]})]}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-save-error",children:y}),(0,a.jsx)(Q,{message:y,context:"integration save (".concat(l.id,")"),officeId:o,trace:w})]}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:z,disabled:m||!C,style:m||!C?{background:"rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.35)",cursor:"not-allowed"}:void 0,children:m?"Savingâ¦":"pending"===c.status?"Save & connect to ".concat(l.name):"Update ".concat(l.name," token")})]})]})}function eo(e,t,n){var i,s,r;let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},l=!!(e.helpUrl&&!o.revealed);return(0,a.jsxs)("div",{className:"integration-field",children:[(0,a.jsxs)("label",{className:"integration-field-label",children:[e.label,e.required&&(0,a.jsx)("span",{className:"integration-field-required",children:" *"})]}),e.hint&&!l&&(0,a.jsxs)("p",{className:"integration-field-hint",children:[e.hint,e.helpUrl&&(0,a.jsxs)(a.Fragment,{children:[" â ",(0,a.jsxs)("a",{href:e.helpUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:[e.helpLabel||"Find it here"," â"]})]})]}),l?(0,a.jsxs)("button",{type:"button",className:"integration-btn integration-btn-primary integration-field-cta",style:{width:"100%",textAlign:"center",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},onClick:()=>{var t;e.helpUrl&&window.open(e.helpUrl,"_blank","noopener,noreferrer"),null==(t=o.onReveal)||t.call(o)},children:["Get ",e.label," ",(0,a.jsx)("span",{"aria-hidden":!0,children:"â"})]}):(0,a.jsx)("input",{className:"integration-field-input",type:"password"===e.type?"password":"text",value:null!=(i=t[e.key])?i:"",onChange:t=>n(n=>({...n,[e.key]:t.target.value})),placeholder:null!=(s=e.placeholder)?s:e.label,autoComplete:"off",autoFocus:o.revealed&&!(null!=(r=t[e.key])?r:"").length})]},e.key)}function el(e){let{fields:t,values:n,setValues:s}=e,[r,o]=(0,i.useState)(!1);return(0,a.jsxs)("div",{className:"integration-advanced",children:[(0,a.jsxs)("button",{type:"button",className:"integration-advanced-toggle",onClick:()=>o(e=>!e),style:{appearance:"none",background:"none",border:0,color:"rgba(255,255,255,0.5)",fontSize:11,padding:"6px 0",cursor:"pointer"},children:[r?"â¾":"â¸"," Advanced"]}),r&&(0,a.jsx)("div",{className:"integration-advanced-body",style:{paddingTop:8,borderTop:"1px solid rgba(255,255,255,0.08)"},children:t.map(e=>eo(e,n,s))})]})}function ec(e){return 0===e?"$0.00":e<.01?"$".concat(e.toFixed(4)):"$".concat(e.toFixed(2))}function ed(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);return t<60?"now":t<3600?"".concat(Math.floor(t/60),"m"):t<86400?"".concat(Math.floor(t/3600),"h"):"".concat(Math.floor(t/86400),"d")}let eu="303971497445",eh="https://apis.google.com/js/api.js",eg={"application/vnd.google-apps.document":"Google Doc","application/vnd.google-apps.spreadsheet":"Google Sheet","application/vnd.google-apps.presentation":"Google Slides","application/vnd.google-apps.form":"Google Form","application/vnd.google-apps.drawing":"Google Drawing","application/vnd.google-apps.folder":"Folder","application/pdf":"PDF"};function ep(e){let{officeId:t}=e,[n,s]=(0,i.useState)(!1),[r,o]=(0,i.useState)(""),[l,c]=(0,i.useState)(null),d=!!eu,u=async()=>{s(!0),o("");try{let e=await fetch("/api/offices/".concat(t,"/google-picker-token"),{method:"POST"}),n=await e.json().catch(()=>({}));if(!e.ok||!n.access_token)throw Error(n.error||"Could not get a Google access token");let a=await new Promise((e,t)=>{var n;let a=window,i=()=>{if(!a.gapi)return t(Error("gapi failed to load"));a.gapi.load("picker",{callback:()=>{var t;return e(null==(t=a.google)?void 0:t.picker)},onerror:()=>t(Error("picker module failed to load"))})};if(a.gapi&&(null==(n=a.google)?void 0:n.picker))return e(a.google.picker);
1if(a.gapi)return i();let s=document.querySelector('script[src="'.concat(eh,'"]'));if(s){s.addEventListener("load",i,{once:!0}),s.addEventListener("error",()=>t(Error("gapi script error")),{once:!0});return}let r=document.createElement("script");r.src=eh,r.async=!0,r.defer=!0,r.onload=i,r.onerror=()=>t(Error("gapi script error")),document.head.appendChild(r)}),i=a.DocsViewMode.LIST,r=new a.DocsView(a.ViewId.DOCS).setIncludeFolders(!0).setSelectFolderEnabled(!0).setMode(i),o=new a.DocsView(a.ViewId.DOCS).setEnableDrives(!0).setIncludeFolders(!0).setSelectFolderEnabled(!0).setMode(i),l=new a.DocsView(a.ViewId.FOLDERS).setSelectFolderEnabled(!0).setMode(i);new a.PickerBuilder().enableFeature(a.Feature.MULTISELECT_ENABLED).setAppId(eu).setOAuthToken(n.access_token).setSize(1051,650).addView(r).addView(o).addView(l).addView(new a.DocsView(a.ViewId.SPREADSHEETS)).setTitle("Choose the files your brain can see").setCallback(e=>{if(e.action===a.Action.PICKED){let t=e.docs||[];c(t.map(e=>{var t,n;return{id:String(null!=(n=null!=(t=e.id)?t:e.name)?n:Math.random()),name:e.name||"Untitled",mimeType:e.mimeType||"",type:e.type||"file",sizeBytes:"number"==typeof e.sizeBytes?e.sizeBytes:void 0,url:e.url}}))}(e.action===a.Action.CANCEL||e.action===a.Action.PICKED)&&s(!1)}).build().setVisible(!0)}catch(e){o(e instanceof Error?e.message:"Could not open the file picker"),s(!1)}};return(0,i.useEffect)(()=>{if(!d)return;let e="mi:auto-open-drive-picker:".concat(t),n=!1;try{(n="1"===sessionStorage.getItem(e))&&sessionStorage.removeItem(e)}catch(e){}n&&u()},[t,d]),(0,a.jsxs)("div",{className:"integration-picker",children:[(0,a.jsx)("button",{type:"button",className:"integration-btn integration-btn-secondary",onClick:u,disabled:n||!d,title:d?"":"File picking is not configured yet",children:n?"Openingâ¦":"Choose Drive files"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Ctrl/â+A to select multiple files."}),null!==l&&!r&&(0===l.length?(0,a.jsx)("p",{className:"integration-wizard-hint",children:"No files selected."}):(0,a.jsxs)("div",{className:"drive-picked",children:[(0,a.jsxs)("div",{className:"drive-picked-head",children:[(0,a.jsxs)("span",{className:"drive-picked-count",children:[l.length," file",1===l.length?"":"s"," added"]}),(0,a.jsx)("span",{className:"drive-picked-sub",children:"Shared with your brain â theyâll appear shortly"})]}),(0,a.jsx)("div",{className:"drive-picked-table-wrap",children:(0,a.jsxs)("table",{className:"drive-picked-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Type"}),(0,a.jsx)("th",{className:"drive-picked-size-col",children:"Size"})]})}),(0,a.jsx)("tbody",{children:l.map(e=>{var t;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"drive-picked-name",children:(0,a.jsx)("span",{className:"drive-picked-name-text",title:e.name,children:e.name})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"drive-picked-type-badge",children:function(e){var t,n;let a=eg[e.mimeType];if(a)return a;if("folder"===e.type)return"Folder";let i=null==(n=e.mimeType)||null==(t=n.split("/"))?void 0:t[1];return i?i.split(/[.+]/).pop().toUpperCase():e.type?e.type.charAt(0).toUpperCase()+e.type.slice(1):"File"}(e)})}),(0,a.jsx)("td",{className:"drive-picked-size-col",children:(t=e.sizeBytes)&&!(t<=0)?t<1024?"".concat(t," B"):t<1048576?"".concat(Math.round(t/1024)," KB"):t<0x40000000?"".concat((t/1048576).toFixed(1)," MB"):"".concat((t/0x40000000).toFixed(1)," GB"):"â"})]},e.id)})})]})})]})),!d&&(0,a.jsx)("p",{className:"integration-wizard-hint",children:"File selection setup is pending."}),r&&(0,a.jsx)("p",{className:"integration-save-error",children:r})]})}function em(e){let{officeId:t,onDone:n}=e,[r,o]=(0,i.useState)("idle"),[l,c]=(0,i.useState)(""),[d,u]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),p=(0,i.useRef)(null),[m,f]=(0,i.useState)(!1),[y,x]=(0,i.useState)(()=>Object.fromEntries($.map(e=>[e.key,!0]))),w=$.some(e=>y[e.key]),b=e=>x(t=>({...t,[e]:!t[e]}));(0,i.useEffect)(()=>{let e=p.current;e&&e.scrollHeight<=e.clientHeight+4&&g(!0)},[r]),(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch("/api/offices/".concat(t,"/google-auth?action=status")),a=await n.json();!e&&a.authenticated&&(o("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"google-workspace",connected:!0}})))}catch(e){}})(),()=>{e=!0}},[t]),(0,i.useEffect)(()=>{let e=new URLSearchParams(window.location.search);if("success"===e.get("google-auth")){o("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"google-workspace",connected:!0}})),n();let e=new URL(window.location.href);e.searchParams.delete("google-auth"),window.history.replaceState({},"",e.toString())}let t=e.get("google-auth-error");
1if(t){c(decodeURIComponent(t)),o("error");let e=new URL(window.location.href);e.searchParams.delete("google-auth-error"),window.history.replaceState({},"",e.toString())}},[t,n]);let j=async e=>{let n=(null==e?void 0:e.power)===!0;o("starting"),c("");try{let e=window.location.pathname+window.location.search,a=$.filter(e=>y[e.key]).map(e=>e.key),i=await fetch("/api/offices/".concat(t,"/google-auth?action=start&returnTo=").concat(encodeURIComponent(e))+(n?"&client=power":"&sources=".concat(encodeURIComponent(a.join(","))))),r=await i.json();r.authUrl?((0,s.u)("integration_connect_started",{integration_id:"google-workspace",method:n?"oauth_power":"oauth"}),window.location.href=r.authUrl):(c(r.error||"Failed to start OAuth"),o("error"))}catch(e){c(e instanceof Error?e.message:"Connection failed"),o("error")}};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"integration-consent",children:[(0,a.jsx)("p",{className:"integration-consent-headline",children:"Everything we do at Mitosis Labs is specifically designed to give you maximum privacy while using AI."}),(0,a.jsx)("p",{className:"integration-consent-casual",children:"Connecting your data to Mitosis lets you use it with any agent, securely. Your data never leaves your Mitosis account, and all compute and AI you connect to your Mitosis Vault runs on your private Mitosis cloud, on secure hardware."}),(0,a.jsxs)("div",{className:"integration-consent-sources",children:[(0,a.jsx)("p",{className:"integration-consent-sources-label",children:"Choose what to connect"}),(0,a.jsx)("div",{className:"integration-consent-sources-list",children:$.map(e=>(0,a.jsxs)("label",{className:"integration-consent-source",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!y[e.key],onChange:()=>b(e.key)}),(0,a.jsx)("span",{className:"integration-consent-source-name",children:e.label}),(0,a.jsx)("span",{className:"integration-consent-source-hint",children:e.hint})]},e.key))}),(0,a.jsx)("p",{className:"integration-consent-sources-note",children:"You only share the sources you leave ticked. For Drive, you pick the exact files to share after connecting â nothing else. You can reconnect later to change this."}),!w&&(0,a.jsx)("p",{className:"integration-consent-scrollhint",children:"Select at least one source to connect."}),(0,a.jsx)("button",{type:"button",className:"integration-consent-power-link",onClick:()=>o("power"),children:"Power user? Connect your entire Workspace â"})]}),(0,a.jsx)("p",{className:"integration-consent-terms-label",children:"Terms & Conditions"}),(0,a.jsxs)("div",{className:"integration-consent-terms",ref:p,onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<8&&g(!0)},children:[(0,a.jsx)("p",{children:"Last updated: 20 June 2026. These Data Connection Terms (the âTermsâ) govern your decision to connect a Google account to Mitosis Labs, Inc. (âMitosisâ, âweâ, âusâ). By ticking the box below you agree to these Terms in addition to our general Terms of Service and Privacy Policy. Please read them in full; you must scroll to the end before you can continue."}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"1. Scope of access."})," When you connect your Google account you authorise Mitosis to access, on your behalf, data from the Google services you approve on Google's consent screen, which may include Google Calendar events, Google Drive files you select through the Google file picker, and the contents of Google Docs and Sheets. The specific scopes granted are those displayed by Google at the time of authorisation, and you may review them at any time in your Google account security settings."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"2. Purpose of processing."})," We access and import this data for the sole purpose of providing the Mitosis service to you: making your data available to the AI agents operating within your Mitosis account so they can search, summarise, organise, and act upon it at your direction. We do not use your Google data for advertising, and we do not sell it."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"3. Limited Use commitment."})," Mitosis's use and transfer of information received from Google APIs adheres to the Google API Services
1User Data Policy, including the Limited Use requirements. We do not transfer this data to third parties except as necessary to provide or improve the features you use, to comply with applicable law, or as part of a merger, acquisition, or sale of assets with notice to you. We do not use Google user data to develop, improve, or train generalised or non-personalised AI or machine-learning models. We do not allow humans to read your Google data unless (a) you give affirmative consent to view specific messages or files, (b) it is necessary for security purposes such as investigating abuse, (c) it is required to comply with applicable law, or (d) the data has been aggregated and anonymised for internal operations."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"4. Storage and location."})," Imported data is stored within your private Mitosis account environment. Compute and AI workloads that you connect to your Mitosis Vault run on isolated infrastructure provisioned for your account. Data is encrypted in transit and at rest using industry-standard mechanisms. Your Google authorisation credentials are stored in an encrypted, per-account secret and are never exposed to your browser or to other customers."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"5. Retention."})," We retain imported Google data for as long as the integration remains connected and your account is active, or as needed to provide the service. You may delete imported data at any time as described in clause 7."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"6. Your responsibilities."})," You represent that you have the right to connect the Google account in question and to authorise the access described here, and that doing so does not violate any policy of your employer, organisation, or Google. If you connect an account that you administer on behalf of others, you are responsible for obtaining any consents required from those users."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"7. Disconnection and deletion."})," You may disconnect the Google integration at any time from this panel, which revokes Mitosis's access and stops all further syncing. You may also revoke access directly from your Google account security settings. To request deletion of Google data already imported into your account, disconnect the integration or contact [email protected], and we will delete it in accordance with our Privacy Policy."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"8. Security and incident handling."})," While we apply commercially reasonable administrative, technical, and physical safeguards, no system is perfectly secure. In the event of a security incident affecting your data we will notify you and applicable authorities as required by law."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"9. No warranty."})," The integration is provided on an âas isâ and âas availableâ basis. To the maximum extent permitted by law, Mitosis disclaims all warranties, express or implied, including merchantability, fitness for a particular purpose, and non-infringement. AI-generated output may be inaccurate; you are responsible for reviewing it before relying on it."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"10. Limitation of liability."})," To the maximum extent permitted by law, Mitosis will not be liable for any indirect, incidental, special, consequential, or punitive damages, or any loss of data, revenue, or profits, arising from your use of the integration."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"11. Changes."})," We may update these Terms from time to time. Material changes will be communicated through the product or by email, and your continued use of the integration after such changes constitutes acceptance."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"12. Contact."})," Questions about these Terms or your data can be sent to [email protected]. By ticking the box below, you confirm that you have read, understood, and agree to these Terms in full."]})]}),!h&&(0,a.jsx)("p",{className:"integration-consent-scrollhint",children:"Scroll to the end of the Terms to continue â"}),(0,a.jsxs)("p",{className:"integration-consent-footnote",children:["Mitosis's use of information received from Google APIs adheres to the"," ",(0,a.jsx)("a",{href:"https://developers.google.com/terms/api-services-user-data-policy",target:"_blank",rel:"noopener noreferrer",className:"integration-consent-link",children:"Google API Services
1User Data Policy"}),", including the Limited Use requirements. See our"," ",(0,a.jsx)("a",{href:"/privacy",target:"_blank",rel:"noopener noreferrer",className:"integration-consent-link",children:"Privacy Policy"}),"."]})]}),(0,a.jsx)("button",{type:"button",className:"integration-hardware-cta",onClick:()=>f(!0),children:"Doesn't work for you? Talk to an engineer about using your own hardware."}),(0,a.jsxs)("div",{className:"integration-consent-footer",children:[(0,a.jsxs)("label",{className:"integration-consent-check".concat(h?"":" is-locked"),children:[(0,a.jsx)("input",{type:"checkbox",checked:d,disabled:!h,onChange:e=>u(e.target.checked)}),(0,a.jsx)("span",{children:"I have read and agree to the Terms & Conditions above, and authorise Mitosis to access and import my Google Workspace data as described."})]}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>j(),disabled:!d||!w,children:"Connect Google Account"})]}),(0,a.jsx)(H,{open:m,onClose:()=>f(!1),placement:"integration-hardware"})]}),"power"===r&&(0,a.jsxs)("div",{className:"integration-power",children:[(0,a.jsx)("button",{type:"button",className:"integration-power-back",onClick:()=>o("idle"),children:"â Back"}),(0,a.jsx)("h3",{className:"integration-power-title",children:"Full Workspace access"}),(0,a.jsx)("p",{className:"integration-power-lead",children:"Bring in everything â all your email, files, calendar, docs and sheets."}),(0,a.jsxs)("p",{className:"integration-power-note",children:["Weâre still completing Googleâs review, so Google shows a caution screen first. Thatâs expected â just click ",(0,a.jsx)("strong",{children:"Advanced"}),", then"," ",(0,a.jsx)("strong",{children:"Continue to Mitosis\xa0Labs"}),"."]}),(0,a.jsxs)("div",{className:"integration-power-shots",children:[(0,a.jsxs)("figure",{className:"integration-power-shot",children:[(0,a.jsx)("img",{src:"/google-unverified-1-advanced.png",alt:"Google's caution screen â click Advanced",loading:"lazy"}),(0,a.jsxs)("figcaption",{children:["1. Click ",(0,a.jsx)("strong",{children:"Advanced"}),"."]})]}),(0,a.jsxs)("figure",{className:"integration-power-shot",children:[(0,a.jsx)("img",{src:"/google-unverified-2-continue.png",alt:"Google's caution screen expanded â click Go to Mitosis Labs (unsafe)",loading:"lazy"}),(0,a.jsxs)("figcaption",{children:["2. Click ",(0,a.jsx)("strong",{children:"Go to Mitosis\xa0Labs (unsafe)"}),"."]})]})]}),(0,a.jsx)("button",{type:"button",className:"integration-btn integration-btn-primary integration-power-cta",onClick:()=>j({power:!0}),children:"Turn on full access"})]}),"starting"===r&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Redirecting to Google..."})]}),"done"===r&&(0,a.jsxs)("div",{className:"cc-wizard-connected",children:[(0,a.jsxs)("div",{className:"cc-wizard-done",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsx)("span",{children:"Google Workspace connected"})]}),(0,a.jsx)(ep,{officeId:t})]}),"error"===r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-save-error",children:l}),(0,a.jsx)(Q,{message:l||"OAuth error",context:"Google Workspace",officeId:t}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>j(),children:"Try again"})]})]})}function ef(e){let{officeId:t,def:n,status:r,onDone:o}=e,[l,c]=(0,i.useState)("idle"),[d,u]=(0,i.useState)(""),[h,g]=(0,i.useState)(null),[p,m]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch("/api/offices/".concat(t,"/github-auth?action=status")),a=await n.json();e||g(!!a.appConfigured)}catch(t){e||g(!1)}})(),()=>{e=!0}},[t]),(0,i.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let a=new URL(window.location.href);t.forEach(e=>a.searchParams.delete(e)),window.history.replaceState({},"",a.toString())};"success"===e.get("github-auth")?(c("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"github",connected:!0}})),o(),t("github-auth","office")):"pending"===e.get("github-auth")&&(c("pending"),t("github-auth","office"));let n=e.get("github-auth-error");n&&(u(decodeURIComponent(n)),c("error"),t("github-auth-error"))},[t,o]);let f=async()=>{c("starting"),u("");try{let e=window.location.pathname+window.location.search,n=await fetch("/api/offices/".concat(t,"/github-auth?action=start&returnTo=").concat(encodeURIComponent(e))),a=await n.json();a.authUrl?((0,s.u)("integration_connect_started",{integration_id:"github",method:"github-app"}),window.location.href=a.authUrl):"app_unconfigured"===a.code?(g(!1),c("idle")):(u(a.error||"Failed to start GitHub connect"),c("error"))}catch(e){u(e instanceof Error?e.message:"Connection failed"),c("error")}};return!1===h||p?(0,a.jsxs)("div",{children:[!1!==h&&(0,a.jsx)("button",{type:"button",className:"integration-alt-link",onClick:()=>m(!1),style:{marginBottom:8},children:"â Back to one-click connect"}),(0,a.jsx)(er,{officeId:t,def:n,status:r,onSaved:o},n.id)]}):(0,a.jsxs)("div",{className:"integration-wizard",children:[("idle"===l||"error"===l)&&(0,a.jsxs)(a.Fragment,{children:["error"===l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-save-error",children:d}),(0,a.jsx)(Q,{message:d||"GitHub connect error",context:"GitHub",officeId:t})]}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect in one click â youâll pick the account or organization and exactly which repositories to share on GitHub, and can change or revoke it there any time. No tokens to create or paste."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:f,disabled:null===h,children:"error"===l?"Try again":"Connect GitHub"}),(0,a.jsx)("button",{type:"button",className:"integration-alt-link",onClick:()=>m(!0),children:"Using GitHub Enterprise Server, or prefer a token? Connect with a PAT â"})]}),"starting"===l&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Redirecting to GitHub..."})]}),"pending"===l&&(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Your organization requires an owner to approve the install. Weâll be able to connect as soon as they approve it â then click Connect GitHub again."}),"done"===l&&(0,a.jsx)("div",{className:"cc-wizard-connected",children:(0,a.jsxs)("div",{className:"cc-wizard-done",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsx)("span",{children:"GitHub connected"})]})})]})}function ey(e){let{onDone:t}=e;return(0,a.jsxs)("div",{className:"integration-wizard",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Open a browser window for your office. Log into any accounts â agents will inherit your saved sessions."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>{window.dispatchEvent(new CustomEvent("mi:open-browser")),t()},children:"Open Browser"})]})}function ex(e){let{officeId:t,onDone:n}=e,[s,r]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[g,p]=(0,i.useState)(null),[m,f]=(0,i.useState)(!1),[y,x]=(0,i.useState)(!1),[w,b]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch("/api/offices/".concat(t,"/code-proxy?action=auth-status")),a=await n.json();if(!e&&a.authenticated){b(!0),r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"claude-code",connected:!0}})),fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"claude-code"})}).catch(()=>{}),f(!0);let e=await fetch("/api/offices/".concat(t,"/code-proxy?action=usage"));e.ok&&p(await e.json()),f(!1)}else e||(b(!1),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"claude-code",connected:!1}})))}catch(t){e||(b(!1),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"claude-code",connected:!1}})))}finally{e||x(!0)}};n();let a=setInterval(n,3e4);return()=>{e=!0,clearInterval(a)}},[t]);let j=(0,i.useRef)(null),v=async(e,a)=>{r("exchanging"),h("");try{let i=await fetch("/api/offices/".concat(t,"/code-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-callback",code:e,state:a})}),s=await i.json();s.success?(r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"claude-code",connected:!0}})),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"claude-code"})}).catch(()=>{}),n()):(h(s.error||"Authentication failed"),r("error"))}catch(e){h(e instanceof Error?e.message:"Exchange failed"),r("error")}},k=async()=>{r("waiting"),h("");try{let e=["localhost","127.0.0.1"].includes(window.location.hostname)?void 0:"".concat(window.location.origin,"/oauth/claude/callback"),n=await fetch("/api/offices/".concat(t,"/code-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-login",redirectUri:e})}),a=await n.json();if(!a.loginUrl){h(a.error||"Failed to start login"),r("error");return}if(l(a.loginUrl),j.current=a.state,a.isLocalhost){r("exchanging");let e=window.open(a.loginUrl,"claude-oauth","width=520,height=680,left=200,top=100"),t=async e=>{var a;if(e.origin!==window.location.origin||(null==(a=e.data)?void 0:a.type)!=="claude-oauth-callback")return;window.removeEventListener("message",t),clearInterval(n);
1let{code:i,state:s,error:o}=e.data;if(o||!i||!s){h(o||"Authorization cancelled"),r("error");return}await v(i,s)};window.addEventListener("message",t);let n=setInterval(()=>{(null==e?void 0:e.closed)&&(clearInterval(n),window.removeEventListener("message",t),"exchanging"===s&&r("code"))},500)}else window.open(a.loginUrl,"_blank"),r("code")}catch(e){h(e instanceof Error?e.message:"Connection failed"),r("error")}},N=async()=>{if(!c.trim())return;let e=c.trim().split("#"),t=e[0],n=e[1]||j.current||"";if(!n){h("Missing state â try starting the login again"),r("error");return}await v(t,n)};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===s&&(0,a.jsxs)("div",{className:"cc-wizard-idle",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect your Claude account to give agents access to Claude Code. You'll sign in via Anthropic's OAuth â no API keys needed."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:k,children:"Connect Claude account"})]}),"waiting"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Opening login
1windowâ¦"})]}),"exchanging"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Waiting for authorizationâ¦"})]}),"code"===s&&(0,a.jsxs)("div",{className:"cc-wizard-code",children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",children:["Sign in on the Anthropic page, then paste the code shown after authorization.",o&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"Reopen login page"})]})]}),(0,a.jsxs)("div",{className:"cc-wizard-code-row",children:[(0,a.jsx)("input",{className:"integration-field-input cc-wizard-code-input",type:"text",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N()},placeholder:"Paste code or code#stateâ¦",autoComplete:"off",spellCheck:!1,autoFocus:!0}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:N,disabled:!c.trim(),children:"Connect"})]})]}),"done"===s&&(0,a.jsxs)("div",{className:"cc-wizard-connected",children:[(0,a.jsxs)("div",{className:"cc-wizard-done",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsx)("span",{children:"Claude Code connected"})]}),m&&(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Loading usage..."}),g&&(0,a.jsxs)("div",{className:"cc-usage",children:[(0,a.jsxs)("div",{className:"cc-usage-stats",children:[(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:ec(g.totalCostUsd)}),(0,a.jsx)("span",{className:"cc-usage-label",children:"total spend"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:g.totalExecutions}),(0,a.jsx)("span",{className:"cc-usage-label",children:"executions"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:g.totalSessions}),(0,a.jsx)("span",{className:"cc-usage-label",children:"sessions"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsxs)("span",{className:"cc-usage-value",children:[((g.totalInputTokens+g.totalOutputTokens)/1e3).toFixed(0),"k"]}),(0,a.jsx)("span",{className:"cc-usage-label",children:"tokens"})]})]}),g.recentExecutions.length>0&&(0,a.jsxs)("div",{className:"cc-recent",children:[(0,a.jsx)("p",{className:"cc-recent-label",children:"Recent"}),g.recentExecutions.slice(0,5).map(e=>(0,a.jsxs)("div",{className:"cc-recent-row",children:[(0,a.jsx)("span",{className:"cc-recent-agent",children:e.agentId}),(0,a.jsxs)("span",{className:"cc-recent-prompt",children:[(e.prompt||"").slice(0,40),(e.prompt||"").length>40?"...":""]}),(0,a.jsxs)("span",{className:"cc-recent-meta",children:[ec(e.costUsd)," \xb7 ",ed(e.createdAt)]})]},e.id))]}),g.sessions.length>0&&(0,a.jsxs)("div",{className:"cc-sessions",children:[(0,a.jsx)("p",{className:"cc-recent-label",children:"Sessions"}),g.sessions.slice(0,5).map(e=>(0,a.jsxs)("div",{className:"cc-session-row",children:[(0,a.jsx)("span",{className:"cc-session-agent",children:e.agentId}),(0,a.jsx)("span",{className:"cc-session-key",children:e.sessionKey}),(0,a.jsxs)("span",{className:"cc-session-meta",children:[e.totalTurns," turns \xb7 ",ec(e.totalCostUsd)," \xb7 ",ed(e.lastActivity)]})]},e.id))]})]})]}),"error"===s&&(0,a.jsxs)("div",{className:"integration-wizard-error",children:[(0,a.jsx)("p",{className:"integration-wizard-error-msg",children:u}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:k,children:"Try again"})]})]})}function ew(e){let{officeId:t,onDone:n}=e,[s,r]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[g,p]=(0,i.useState)(null),[m,f]=(0,i.useState)(!1),y=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch("/api/offices/".concat(t,"/codex-proxy?action=auth-status"));if(!n.ok)return;let a=await n.json();if(!e&&a.authenticated){r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"openai-codex",connected:!0}})),fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"openai-codex"})}).catch(()=>{}),f(!0);let e=await fetch("/api/offices/".concat(t,"/codex-proxy?action=usage"));e.ok&&p(await e.json()),f(!1)}}catch(e){}finally{e||f(!1)}})(),()=>{e=!0}},[t]);let x=async(e,a)=>{r("exchanging"),h("");try{let i=await fetch("/api/offices/".concat(t,"/codex-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-callback",code:e,state:a})}),s=await i.json();s.success?(r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"openai-codex",connected:!0}})),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"openai-codex"})}).catch(()=>{}),n()):(h(s.error||"Authentication failed"),r("error"))}catch(e){h(e instanceof Error?e.message:"Exchange failed"),r("error")}},w=async()=>{r("waiting"),h("");try{await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"openai-codex"})}).catch(()=>{});let e=await fetch("/api/offices/".concat(t,"/codex-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-login",redirectUri:void 0})}),n=await e.json();if(!n.loginUrl){h(n.error||"Failed to start login"),r("error");return}l(n.loginUrl),y.current=n.state,window.open(n.loginUrl,"_blank"),r("code")}catch(e){h(e instanceof Error?e.message:"Connection failed"),r("error")}},b=e=>{let t=e.trim();if(t.startsWith("http://")||t.startsWith("https://"))try{let e=new URL(t),n=e.searchParams.get("code")||"",a=e.searchParams.get("state")||y.current||"";return{authCode:n,state:a}}catch(e){}let n=t.split("#");return{authCode:n[0]||"",state:n[1]||y.current||""}},j=async()=>
1{if(!c.trim())return;let{authCode:e,state:t}=b(c);if(!e){h("Could not find code â paste the full callback URL or just the code"),r("error");return}if(!t){h("Missing state â try starting the login again"),r("error");return}await x(e,t)};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===s&&(0,a.jsxs)("div",{className:"cc-wizard-idle",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect your OpenAI account to share Codex privileges with agents via ChatGPT Pro/Team."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:w,children:"Connect OpenAI account"})]}),"waiting"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Preparing Codex loginâ¦"})]}),"exchanging"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Waiting for authorizationâ¦"})]}),"code"===s&&(0,a.jsxs)("div",{className:"cc-wizard-code",children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",children:["Sign in on the OpenAI tab. After you authorize, the browser will redirect to ",(0,a.jsx)("code",{style:{color:"#a78bfa"},children:"http://localhost:1455/auth/callback?code=â¦"})," and show a ",(0,a.jsx)("em",{children:"âcanât reach this pageâ"})," error â thatâs expected. Copy the full URL from the address bar and paste it below.",o&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"Reopen login page"})]})]}),(0,a.jsxs)("div",{className:"cc-wizard-code-row",children:[(0,a.jsx)("input",{className:"integration-field-input cc-wizard-code-input",type:"text",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j()},placeholder:"Paste callback URL or codeâ¦",autoComplete:"off",spellCheck:!1,autoFocus:!0}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:j,disabled:!c.trim(),children:"Connect"})]})]}),"done"===s&&(0,a.jsxs)("div",{className:"cc-wizard-connected",children:[(0,a.jsxs)("div",{className:"cc-wizard-done",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsx)("span",{children:"OpenAI Codex connected"})]}),m&&(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Loading usage..."}),g&&(0,a.jsx)("div",{className:"cc-usage",children:(0,a.jsxs)("div",{className:"cc-usage-stats",children:[(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:ec(g.totalCostUsd)}),(0,a.jsx)("span",{className:"cc-usage-label",children:"total spend"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:g.totalExecutions}),(0,a.jsx)("span",{className:"cc-usage-label",children:"executions"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsx)("span",{className:"cc-usage-value",children:g.totalSessions}),(0,a.jsx)("span",{className:"cc-usage-label",children:"sessions"})]}),(0,a.jsxs)("div",{className:"cc-usage-stat",children:[(0,a.jsxs)("span",{className:"cc-usage-value",children:[((g.totalInputTokens+g.totalOutputTokens)/1e3).toFixed(0),"k"]}),(0,a.jsx)("span",{className:"cc-usage-label",children:"tokens"})]})]})})]}),"error"===s&&(0,a.jsxs)("div",{className:"integration-wizard-error",children:[(0,a.jsx)("p",{className:"integration-wizard-error-msg",children:u}),(0,a.jsx)(Q,{message:u||"Claude Code error",context:"Claude Code setup",officeId:t}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:w,children:"Try again"})]})]})}function eb(e){let{officeId:t,onDone:n}=e,[s,r]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[g,p]=(0,i.useState)(""),[m,f]=(0,i.useState)(void 0),y=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch("/api/offices/".concat(t,"/gemini-proxy?action=auth-status"));if(!n.ok)return;let a=await n.json();if(e)return;a.authenticated&&(f("string"==typeof a.email?a.email:void 0),a.requiresProject&&!a.cloudProject?r("project"):(r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"gemini-cli",connected:!0}})),fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"gemini-cli"})}).catch(()=>{})))}catch(e){}})(),()=>{e=!0}},[t]);let x=async(e,a)=>{r("exchanging"),p("");try{let i=await fetch("/api/offices/".concat(t,"/gemini-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-callback",code:e,state:a})}),s=await i.json();if(s.success){try{let e=await fetch("/api/offices/".concat(t,"/gemini-proxy?action=auth-status")),n=await e.json();if(f("string"==typeof n.email?n.email:void 0),n.requiresProject&&!n.cloudProject)return void r("project")}catch(e){}r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"gemini-cli",connected:!0}})),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"gemini-cli"})}).catch(()=>{}),n()}else p(s.error||"Authentication failed"),r("error")}catch(e){p(e instanceof Error?e.message:"Exchange failed"),r("error")}},w=async()=>{r("waiting"),p("");try{await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"gemini-cli"})}).catch(()=>{});let e=await fetch("/api/offices/".concat(t,"/gemini-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auth-login"})}),n=await e.json();if(!n.loginUrl){p("string"==typeof n.error?n.error:"Failed to start login"),r("error");return}l(n.loginUrl),y.current="string"==typeof n.state?n.state:null,window.open(n.loginUrl,"_blank"),r("code")}catch(e){p(e instanceof Error?e.message:"Connection failed"),r("error")}},b=e=>{let t=e.trim();if(t.startsWith("http://")||t.startsWith("https://"))try{let e=new URL(t);return{authCode:e.searchParams.get("code")||"",state:e.searchParams.get("state")||y.current||""}}catch(e){}let n=t.split("#");return{authCode:n[0]||"",state:n[1]||y.current||""}},j=async()=>
1{if(!c.trim())return;let{authCode:e,state:t}=b(c);if(!e){p("Could not find code â paste the authorization code from the Google page"),r("error");return}if(!t){p("Missing state â restart the login"),r("error");return}await x(e,t)},v=async()=>{if(u.trim()){r("exchanging"),p("");try{let e=await fetch("/api/offices/".concat(t,"/gemini-proxy"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"set-project",projectId:u.trim()})}),a=await e.json();a.success?(r("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"gemini-cli",connected:!0}})),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"gemini-cli"})}).catch(()=>{}),n()):(p("string"==typeof a.error?a.error:"Could not save project ID"),r("error"))}catch(e){p(e instanceof Error?e.message:"Save failed"),r("error")}}};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===s&&(0,a.jsxs)("div",{className:"cc-wizard-idle",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect your Google account to share your Gemini Code Assist session with agents. Free for personal accounts; Google AI Pro/Ultra also supported."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:w,children:"Connect Google account"})]}),"waiting"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Preparing Google loginâ¦"})]}),"exchanging"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Waiting for authorizationâ¦"})]}),"code"===s&&(0,a.jsxs)("div",{className:"cc-wizard-code",children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",children:["Sign in on the Google tab and click ",(0,a.jsx)("em",{children:"Allow"}),". Google will show you an authorization code on a page titled ",(0,a.jsx)("em",{children:"âAuthentication successfulâ"})," â copy that code and paste it below.",o&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"Reopen login page"})]})]}),(0,a.jsxs)("div",{className:"cc-wizard-code-row",children:[(0,a.jsx)("input",{className:"integration-field-input cc-wizard-code-input",type:"text",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j()},placeholder:"Paste authorization codeâ¦",autoComplete:"off",spellCheck:!1,autoFocus:!0}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:j,disabled:!c.trim(),children:"Connect"})]})]}),"project"===s&&(0,a.jsxs)("div",{className:"cc-wizard-code",children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",children:["Your account needs a Google Cloud project ID (this happens for Workspace accounts and some non-free tiers). Create or pick one at ",(0,a.jsx)("a",{href:"https://console.cloud.google.com/projectcreate",target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"console.cloud.google.com/projectcreate"})," and paste the Project ID below."]}),(0,a.jsxs)("div",{className:"cc-wizard-code-row",children:[(0,a.jsx)("input",{className:"integration-field-input cc-wizard-code-input",type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v()},placeholder:"my-project-id",autoComplete:"off",spellCheck:!1,autoFocus:!0}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:v,disabled:!u.trim(),children:"Save"})]})]}),"done"===s&&(0,a.jsx)("div",{className:"cc-wizard-connected",children:(0,a.jsxs)("div",{className:"cc-wizard-done",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsxs)("span",{children:["Gemini CLI connected",m?" (".concat(m,")"):""]})]})}),"error"===s&&(0,a.jsxs)("div",{className:"integration-wizard-error",children:[(0,a.jsx)("p",{className:"integration-wizard-error-msg",children:g}),(0,a.jsx)(Q,{message:g||"Gemini CLI error",context:"Gemini CLI setup",officeId:t}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:w,children:"Try again"})]})]})}function ej(e){let{officeId:t,onDone:n,onManual:s}=e,[r,o]=(0,i.useState)("idle"),[l,c]=(0,i.useState)(""),[d,u]=(0,i.useState)(""),[h,g]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=new URLSearchParams(window.location.search);if("success"===e.get("slack-auth")){o("done"),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"slack",connected:!0}})),n();let e=new URL(window.location.href);e.searchParams.delete("slack-auth"),window.history.replaceState({},"",e.toString())}if(e.get("slack-auth-error")){g(decodeURIComponent(e.get("slack-auth-error")||"Unknown error")),o("error");let t=new URL(window.location.href);t.searchParams.delete("slack-auth-error"),window.history.replaceState({},"",t.toString())}},[n]);let p=async()=>
1{if(l&&d){o("creating"),g("");try{let e,n=window.location.pathname+window.location.search,a=await fetch("/api/offices/".concat(t,"/slack-auto"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:l,refreshToken:d,returnTo:n})}),i=await a.text();try{e=JSON.parse(i)}catch(e){g("Server error (".concat(a.status,"): ").concat(i.slice(0,200)||"empty response")),o("error");return}if(!a.ok||!e.authUrl){g(e.error||"Failed to create Slack app"),o("error");return}window.location.href=e.authUrl}catch(e){g(e instanceof Error?e.message:"Network error"),o("error")}}};return"done"===r?(0,a.jsx)("div",{className:"integration-wizard",children:(0,a.jsx)("p",{className:"integration-wizard-hint",style:{color:"#4ade80"},children:"Slack connected successfully."})}):(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect your Slack workspace in two clicks. We'll create and configure the app for you."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>o("tokens"),children:"Set up automatically"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",onClick:()=>null==s?void 0:s(),style:{marginTop:8},children:"Or enter tokens manually"})]}),"tokens"===r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",children:["Copy your ",(0,a.jsx)("strong",{children:"Access Token"})," and ",(0,a.jsx)("strong",{children:"Refresh Token"}),' from the "Your App Configuration Tokens" section at the bottom of the Slack apps page.']}),(0,a.jsxs)("div",{className:"integration-field",children:[(0,a.jsx)("label",{className:"integration-field-label",children:"Access Token"}),(0,a.jsxs)("p",{className:"integration-field-hint",children:["Starts with xoxe.xoxp- â ",(0,a.jsx)("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"Open Slack Apps â"})]}),(0,a.jsx)("input",{className:"integration-field-input",type:"password",value:l,onChange:e=>c(e.target.value),placeholder:"xoxe.xoxp-...",autoComplete:"off"})]}),(0,a.jsxs)("div",{className:"integration-field",children:[(0,a.jsx)("label",{className:"integration-field-label",children:"Refresh Token"}),(0,a.jsxs)("p",{className:"integration-field-hint",children:["Starts with xoxe- â ",(0,a.jsx)("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"Open Slack Apps â"})]}),(0,a.jsx)("input",{className:"integration-field-input",type:"password",value:d,onChange:e=>u(e.target.value),placeholder:"xoxe-...",autoComplete:"off"})]}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:p,disabled:!l||!d,style:{marginTop:8},children:"Connect Slack"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",onClick:()=>null==s?void 0:s(),style:{marginTop:8},children:"Enter bot tokens manually instead"})]}),"creating"===r&&(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Creating Slack app and redirecting to authorize..."}),"error"===r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-wizard-hint",style:{color:"#f87171"},children:h}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>o("tokens"),style:{marginTop:8},children:"Try again"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",onClick:()=>null==s?void 0:s(),style:{marginTop:8},children:"Enter tokens manually"})]})]})}function ev(e){let{officeId:t,def:n,status:s,onDone:r}=e,[o,l]=(0,i.useState)(!1);return o?(0,a.jsx)(er,{officeId:t,def:n,status:s,onSaved:r}):(0,a.jsx)(ej,{officeId:t,onDone:r,onManual:()=>l(!0)})}function ek(e){let{officeId:t,onDone:n}=e,[s,r]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),g=i.useRef(null);(0,i.useEffect)(()=>()=>{g.current&&clearInterval(g.current)},[]);let p=async()=>{r("starting"),h("");try{let e=await fetch("/api/offices/".concat(t,"/tailscale"),{method:"POST",headers:{"Content-Type":"application/json"}}),a=await e.json();if(!e.ok){h(a.error||"Failed to start Tailscale"),r("error");return}a.loginUrl&&l(a.loginUrl),r("waiting"),g.current=setInterval(async()=>{try{let e=await fetch("/api/offices/".concat(t,"/tailscale"));if(!e.ok)return;let a=await e.json();"connected"===a.status?(g.current&&clearInterval(g.current),d(a.hostname||""),r("connected"),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"tailscale"})}).catch(()=>{}),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"tailscale",connected:!0}})),n()):a.loginUrl&&!o&&l(a.loginUrl)}catch(e){}},3e3)}catch(e){h(e instanceof Error?e.message:"Failed to connect"),r("error")}};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Connect your agents to your private Tailscale network. One click â no auth keys needed."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:p,children:"Connect Tailscale"})]}),"starting"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Starting Tailscale proxy..."})]}),"waiting"===s&&(0,a.jsx)(a.Fragment,{children:o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-wizard-hint",style:{textAlign:"center"},children:"Click below to authorize this node on your tailnet:"}),(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"integration-btn integration-btn-primary",style:{textAlign:"center",display:"block",textDecoration:"none"},children:"Authorize in Tailscale â"}),(0,a.jsx)("p",{className:"integration-wizard-hint",style:{fontSize:11,opacity:.6,textAlign:"center",marginTop:8},children:"Waiting for authorization..."})]}):(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Generating login link..."})]})}),"connected"===s&&(0,a.jsx)("div",{className:"integration-wizard",children:(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{color:"#4ade80"},children:["Connected to your tailnet",c?" as ".concat(c):"","."]})}),"error"===s&&(0,a.jsxs)("div",{className:"integration-wizard",children:[(0,a.jsx)("p",{className:"integration-save-error",children:u}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",onClick:()=>{r("idle"),h("")},children:"Try again"})]})]})}function eN(e){let{officeId:t,onDone:n}=e,[s,r]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[g,p]=(0,i.useState)(""),m=i.useRef(null),[f,y]=(0,i.useState)(""),[x,w]=(0,i.useState)(!1),[b,j]=(0,i.useState)("");(0,i.useEffect)(()=>()=>{m.current&&clearInterval(m.current)},[]);let v=async()=>{r("creating"),p("");try{let e=await fetch("/api/offices/".concat(t,"/telegram/managed-bot"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),a=await e.json().catch(()=>({error:"HTTP ".concat(e.status)}));if(!e.ok||!a.link){if(503===e.status||404===e.status||502===e.status)return void r("manual");p(a.error||"Failed to start bot creation"),r("error");return}l(a.link),d(a.sessionId),r("waiting"),m.current=setInterval(async()=>{try{let e=await fetch("/api/offices/".concat(t,"/telegram/managed-bot?session=").concat(a.sessionId));if(!e.ok)return;let i=await e.json();"completed"===i.status?(m.current&&clearInterval(m.current),h(i.telegramBotUsername||""),await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"telegram"})}).catch(()=>{}),window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"telegram",connected:!0}})),r("done"),n()):"expired"===i.status&&(m.current&&clearInterval(m.current),p("Session expired. Please try again."),r("error"))}catch(e){}},3e3)}catch(e){r("manual")}},k=async()=>
1{if(f.trim()){w(!0),j("");try{let e=await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:"telegram",secrets:{TELEGRAM_BOT_TOKEN:f.trim()}})}),a=await e.json();e.ok?(window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:"telegram",connected:!0}})),r("done"),n()):j(a.error||"Save failed")}catch(e){j(e instanceof Error?e.message:"Save failed")}finally{w(!1)}}};return(0,a.jsxs)("div",{className:"integration-wizard",children:["idle"===s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Create a dedicated Telegram bot for your office. One tap in Telegram â no BotFather needed."}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:v,children:"Create Telegram Bot"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{marginTop:6,fontSize:11},onClick:()=>r("manual"),children:"Or connect an existing bot"})]}),"creating"===s&&(0,a.jsxs)("div",{className:"cc-wizard-waiting",children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Preparing bot creation..."})]}),"waiting"===s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"8px 0"},children:[o&&(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,a.jsx)("img",{src:"https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=".concat(encodeURIComponent(o),"&bgcolor=1a1a2e&color=ffffff&margin=8"),alt:"Scan to create Telegram bot",style:{width:160,height:160,borderRadius:10,background:"#1a1a2e"}})}),(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{textAlign:"center",margin:0},children:["Scan with your phone or"," ",(0,a.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"open in Telegram"})]}),(0,a.jsxs)("div",{className:"cc-wizard-waiting",style:{padding:0},children:[(0,a.jsx)("div",{className:"cc-wizard-spinner"}),(0,a.jsx)("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:"Waiting for confirmation..."})]})]}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{marginTop:4,fontSize:11},onClick:()=>{m.current&&clearInterval(m.current),r("manual")},children:"Enter token manually instead"})]}),"done"===s&&(0,a.jsxs)("div",{className:"integration-wizard-connected",children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:"#22c55e"}}),(0,a.jsxs)("span",{children:["Telegram bot connected",u?" â @".concat(u):""]})]}),"manual"===s&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{marginBottom:8},children:["Create a bot via ",(0,a.jsx)("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",style:{color:"#a78bfa"},children:"@BotFather"})," and paste the token below."]}),(0,a.jsxs)("div",{className:"integration-secret-fields",children:[(0,a.jsxs)("div",{className:"integration-field",children:[(0,a.jsxs)("label",{className:"integration-field-label",children:["Bot Token",(0,a.jsx)("span",{className:"integration-field-required",children:" *"})]}),(0,a.jsx)("input",{className:"integration-field-input",type:"password",value:f,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",autoComplete:"off"})]}),b&&(0,a.jsx)("p",{className:"integration-save-error",children:b}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:k,disabled:x||!f.trim(),children:x?"Saving...":"Save & activate"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{marginTop:4,fontSize:11},onClick:()=>r("idle"),children:"Back to automatic setup"})]})]}),"error"===s&&(0,a.jsxs)("div",{className:"integration-wizard-error",children:[(0,a.jsx)("p",{className:"integration-wizard-error-msg",children:g}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:v,children:"Try again"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{marginTop:4,fontSize:11},onClick:()=>r("manual"),children:"Enter token manually"})]})]})}let eS=new Set(["openai","google-gemini","venice-ai","azure-openai"]);function eC(e){var t;let{officeId:n,integrationId:s}=e,[r,o]=(0,i.useState)(null),[l,c]=(0,i.useState)(!0),[d,u]=(0,i.useState)(null),h="google-gemini"===s?"gemini":"venice-ai"===s?"venice":"azure-openai"===s?"azure":s,g=(0,i.useRef)("");return(0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let a=await fetch("/api/offices/".concat(n,"/provider-usage?provider=").concat(encodeURIComponent(h)));if(a.ok&&!e){let e=await a.json(),n=JSON.stringify(e);if(n!==g.current){var t;g.current=n,o(e),u(null!=(t=e.keyValid)?t:null)}}}catch(e){}finally{e||c(!1)}};t();let a=setInterval(t,3e4);return()=>{e=!0,clearInterval(a)}},[n,h]),(0,a.jsxs)("div",{className:"integration-provider-status",children:[(0,a.jsxs)("div",{className:"integration-provider-status-row",children:[(0,a.jsx)("span",{className:"integration-status-dot-lg ".concat(!1===d?"integration-status-dot-warn":""),style:{background:!1===d?"#ef4444":"#22c55e"}}),(0,a.jsx)("span",{style:{fontSize:12,color:"rgba(255,255,255,0.6)"},children:!1===d?"Key invalid":"Configured"}
1),(0,a.jsx)("span",{style:{marginLeft:"auto",fontSize:10,color:"rgba(255,255,255,0.3)"},children:"User-billed"})]}),!1===d&&(0,a.jsx)("p",{style:{fontSize:11,color:"#ef4444",margin:"6px 0 0"},children:"Your API key is invalid or expired. Update it below."}),!l&&r&&r.totalRequests>0&&(0,a.jsxs)("div",{style:{marginTop:10},children:[(0,a.jsx)("p",{className:"integration-agent-toggles-label",children:"Usage (24h)"}),(0,a.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6,marginTop:4},children:[(0,a.jsxs)("div",{className:"integration-stat-box",children:[(0,a.jsx)("span",{className:"integration-stat-value",children:r.totalRequests.toLocaleString()}),(0,a.jsx)("span",{className:"integration-stat-label",children:"Requests"})]}),(0,a.jsxs)("div",{className:"integration-stat-box",children:[(0,a.jsx)("span",{className:"integration-stat-value",children:(t=r.totalInputTokens+r.totalOutputTokens)>=1e6?"".concat((t/1e6).toFixed(1),"M"):t>=1e3?"".concat((t/1e3).toFixed(1),"K"):t.toString()}),(0,a.jsx)("span",{className:"integration-stat-label",children:"Tokens"})]}),(0,a.jsxs)("div",{className:"integration-stat-box",children:[(0,a.jsxs)("span",{className:"integration-stat-value",children:[Math.round(100*r.successRate),"%"]}),(0,a.jsx)("span",{className:"integration-stat-label",children:"Success"})]}),(0,a.jsxs)("div",{className:"integration-stat-box",children:[(0,a.jsx)("span",{className:"integration-stat-value",children:r.avgLatencyMs>0?"".concat(Math.round(r.avgLatencyMs),"ms"):"â"}),(0,a.jsx)("span",{className:"integration-stat-label",children:"Avg Latency"})]})]})]})]})}function ez(e){let{officeId:t,def:n,status:s,onSaved:r}=e,[o,l]=(0,i.useState)(!1);return(0,a.jsxs)("div",{className:"integration-reconfigure",children:[(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",onClick:()=>l(e=>!e),children:o?"Hide credentials":"Update credentials"}),o&&(0,a.jsx)(er,{officeId:t,def:n,status:s,onSaved:r},n.id)]})}function eE(e){let{officeId:t,def:n,onToggled:s,enabled:r}=e,[o,l]=(0,i.useState)(!1),c=async()=>{l(!0);try{r?(await fetch("/api/offices/".concat(t,"/integrations/").concat(n.id),{method:"DELETE"})).ok&&(window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:n.id,connected:!1}})),s()):(await fetch("/api/offices/".concat(t,"/integrations"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({integrationId:n.id})})).ok&&(window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:n.id,connected:!0}})),s())}catch(e){}finally{l(!1)}};return(0,a.jsxs)("div",{className:"integration-wizard",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",children:r?"Active for all agents. No setup required.":"Disabled. Enable to let agents submit to the showcase."}),(0,a.jsx)("button",{className:"integration-btn ".concat(r?"integration-btn-danger-subtle":"integration-btn-primary"),style:{width:"100%",marginTop:8},onClick:c,disabled:o,children:o?r?"Disabling...":"Enabling...":r?"Disable":"Enable"})]})}function eI(e){let{officeId:t,integrationId:n,instanceLabel:s,onRemoved:r}=e,[o,l]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),u=async()=>{l(!0);try{let e=s?"?instanceLabel=".concat(encodeURIComponent(s)):"";(await fetch("/api/offices/".concat(t,"/integrations/").concat(n).concat(e),{method:"DELETE"})).ok&&(window.dispatchEvent(new CustomEvent("mi:integration-status",{detail:{integrationId:n,connected:!1}})),r())}catch(e){}finally{l(!1),d(!1)}};return c?(0,a.jsxs)("div",{style:{marginTop:8},children:["google-workspace"===n&&(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{marginBottom:8},children:["This revokes Mitosis's access to your Google account and stops all syncing. You can also revoke access at"," ",(0,a.jsx)("a",{href:"https://myaccount.google.com/permissions",target:"_blank",rel:"noopener noreferrer",className:"integration-consent-link",children:"myaccount.google.com/permissions"}),"."]}),"github"===n&&(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{marginBottom:8},children:["This stops syncing and deletes the GitHub data already in your brain. To also revoke Mitosis's repository access on GitHub, uninstall the app at"," ",(0,a.jsx)("a",{href:"https://github.com/settings/installations",target:"_blank",rel:"noopener noreferrer",className:"integration-consent-link",children:"github.com/settings/installations"}),"."]}),(0,a.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,a.jsx)("button",{className:"integration-btn integration-btn-danger-subtle",style:{flex:1},onClick:u,disabled:o,children:o?"Disconnecting...":"google-workspace"===n?"Disconnect Google":"Confirm remove"}),(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{flex:1},onClick:()=>d(!1),disabled:o,children:"Cancel"})]})]}):(0,a.jsx)("button",{className:"integration-btn integration-btn-danger-subtle",style:{width:"100%",marginTop:8},onClick:()=>d(!0),children:"Remove"})}let eT=[{name:"Claude Code",href:"https://code.claude.com/docs/en/setup"},{name:"Codex",href:"https://developers.openai.com/codex/cli"},{name:"Grok Build",href:"https://x.ai/cli"},{name:"OpenClaw",href:"https://openclaw.ai"},{name:"Hermes",href:"https://hermes-agent.org/#quickstart"},{name:"NemoClaw",href:"https://docs.nvidia.com/nemoclaw/user-guide/openclaw/get-started/quickstart"}];function eA(e){let{officeId:t}=e,n=["Install the official Mitosis SDK and sync my Obsidian vault into my own Mitosis workspace.","","1. npm i @mitosislabs/sdk","2. npx mi login (opens a browser for me to sign in â one time)",'3. Find my Obsidian vault: the folder that c
1ontains a ".obsidian" directory.'," Ask me for the path if it isn't obvious.","4. Ingest every Markdown (.md) file in it, recursively, skipping the"," .obsidian/, .trash/, and .git/ folders:"," npx mi cortex ingest <the .md files> --office ".concat(t," --feed obsidian")," Pass the files as arguments; run in batches if there are many.","","Show me the result when it's done."].join("\n"),[s,r]=(0,i.useState)(!1),o=(0,i.useCallback)(()=>{"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),1800)}).catch(()=>{})},[n]);return(0,a.jsxs)("div",{className:"integration-wizard",children:[(0,a.jsx)("p",{className:"integration-wizard-hint",style:{margin:"0 0 4px",color:"rgba(255,255,255,0.85)",fontWeight:600},children:"1. Open your coding agent"}),(0,a.jsx)("p",{className:"integration-wizard-hint",style:{margin:"0 0 8px"},children:"Don't have one? Pick any below."}),(0,a.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:16},children:eT.map(e=>(0,a.jsxs)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(255,255,255,0.16)",color:"rgba(255,255,255,0.8)",textDecoration:"none",whiteSpace:"nowrap"},children:[e.name," â"]},e.name))}),(0,a.jsx)("p",{className:"integration-wizard-hint",style:{margin:"0 0 8px",color:"rgba(255,255,255,0.85)",fontWeight:600},children:"2. Paste this into your coding agent"}),(0,a.jsx)("pre",{style:{margin:"0 0 8px",padding:12,background:"rgba(0,0,0,0.35)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,fontSize:11,lineHeight:1.5,color:"rgba(255,255,255,0.82)",whiteSpace:"pre-wrap",overflowX:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:n}),(0,a.jsx)("button",{type:"button",onClick:o,className:"integration-btn integration-btn-primary",style:{width:"100%",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:7,padding:"10px 14px",fontSize:13,fontWeight:600,letterSpacing:.1},children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.A,{size:15,strokeWidth:2.5})," Copied"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{size:15,strokeWidth:2.5})," Copy prompt"]})})]})}function eO(e){var t,n,s,r,o;let{officeId:l,integration:c,bots:d,liveConnected:u,onRefresh:h,demoActiveIntegrations:g,pendingAgentRequests:p,onManage:m}=e,f=Y.o4.find(e=>e.id===c.id);if(!f)return null;let y=null!=(n=u.get(c.id))&&n,x=(null==(t=c.metadata)||t.enabledAgentCount,null!=(s=null==g?void 0:g.has(c.id))&&s||y)?"active":c.status,b="pending"!==x,j=!0===c.globallyDisabled,v=!0===c.comingSoon,k=j||v&&!b,[N,S]=(0,i.useState)(!1),C=(0,i.useCallback)(()=>{h(),window.dispatchEvent(new CustomEvent("mi:integration-refresh"))},[h]),z=(0,i.useCallback)(()=>{S(!1),C()},[C]);return(0,a.jsxs)("div",{className:"integration-detail-inner",children:[(0,a.jsxs)("div",{className:"integration-detail-header",children:[(0,a.jsx)("span",{className:"integration-detail-icon",children:(0,a.jsx)(ea,{icon:c.icon,size:18})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"integration-detail-name-row",children:[(0,a.jsx)("span",{className:"integration-detail-name",children:c.name}),c.verified&&(0,a.jsx)(w.A,{className:"integration-verified",size:13,color:"#22c55e"}),v&&(0,a.jsx)("span",{className:"integration-coming-soon-badge",children:"Coming soon"})]}),(0,a.jsxs)("div",{className:"integration-detail-status-row",style:{flexWrap:"wrap"},children:[(0,a.jsx)("span",{className:"integration-status-dot",style:{background:null!=(r=es[x])?r:"#6b7280"}}),(0,a.jsx)("span",{className:"integration-card-status",style:{flexShrink:1,minWidth:0,overflowWrap:"anywhere"},children:b&&c.multiInstance&&c.instanceLabel?(0,a.jsxs)(a.Fragment,{children:["Connected as ",(0,a.jsxs)("code",{style:{fontFamily:"inherit",color:"#fff"},children:["@",c.instanceLabel]}),c.connectedAt&&(0,a.jsxs)("span",{style:{color:"rgba(255,255,255,0.4)"},children:[" \xb7 ",ed(c.connectedAt)," ago"]})]}):null!=(o=ei[x])?o:x})]})]})]}),(0,a.jsx)("p",{className:"integration-detail-desc",children:c.description}),p&&p.length>0&&(0,a.jsxs)("div",{className:"integration-wizard",style:{borderColor:"rgba(139, 92, 246, 0.4)",background:"rgba(139, 92, 246, 0.08)",marginBottom:8},children:[(0,a.jsxs)("p",{style:{fontSize:11,fontWeight:600,color:"#a78bfa",marginBottom:4},children:["Agent",p.length>
11?"s":""," requesting this integration"]}),p.map((e,t)=>(0,a.jsxs)("p",{style:{fontSize:11,color:"rgba(255,255,255,0.7)",margin:"2px 0"},children:[(0,a.jsx)("strong",{children:e.agentName}),e.reason?" â ".concat(e.reason):""]},t)),(0,a.jsxs)("p",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",marginTop:4,marginBottom:0},children:["Configure credentials below to auto-enable for ",p.length>1?"these agents":"this agent"]})]}),j&&(0,a.jsxs)("div",{className:"integration-wizard",style:{borderColor:"rgba(245, 158, 11, 0.35)",background:"rgba(120, 53, 15, 0.12)"},children:[(0,a.jsx)("p",{className:"integration-save-error",style:{marginBottom:6},children:"Disabled globally by admin"}),(0,a.jsx)("p",{className:"integration-wizard-hint",style:{marginBottom:0},children:c.globalDisableMessage||"This integration is currently unavailable in every office."})]}),v&&!j&&!b&&(0,a.jsxs)("div",{className:"integration-wizard",style:{borderColor:"rgba(139, 92, 246, 0.35)",background:"rgba(76, 29, 149, 0.12)"},children:[(0,a.jsx)("p",{style:{fontSize:12,fontWeight:600,color:"#a78bfa",marginBottom:6},children:"Coming soon"}),(0,a.jsxs)("p",{className:"integration-wizard-hint",style:{marginBottom:0},children:["Weâre still wiring ",c.name," into your agent brain. Itâll appear here the moment it can ingest, enrich, and surface its data â hang tight."]})]}),!k&&"chromium-browser"===c.id&&(0,a.jsx)(ey,{officeId:l,onDone:h}),!k&&!b&&"chromium-browser"!==c.id&&(0,a.jsxs)(a.Fragment,{children:["interactive"===f.wizard&&"whatsapp"===c.id&&(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:()=>window.dispatchEvent(new CustomEvent("mi:open-whatsapp-pairing")),children:"Link WhatsApp"}),"interactive"===f.wizard&&"telegram"===c.id&&(0,a.jsx)(eN,{officeId:l,onDone:C}),"interactive"===f.wizard&&"slack"===c.id&&(0,a.jsx)(ev,{officeId:l,def:f,status:c,onDone:C}),"interactive"===f.wizard&&"tailscale"===c.id&&(0,a.jsx)(ek,{officeId:l,onDone:C}),"obsidian"===c.id&&(0,a.jsx)(eA,{officeId:l}),"guide"===f.wizard&&"obsidian"!==c.id&&(0,a.jsx)(er,{officeId:l,def:f,status:c,onSaved:C},f.id),"auto"===f.wizard&&(0,a.jsx)("div",{className:"integration-wizard",children:(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Auto-configured from the agent signing key. No setup required."})}),"oauth"===f.wizard&&"claude-code"===c.id&&(0,a.jsx)(ex,{officeId:l,onDone:C}),"oauth"===f.wizard&&"openai-codex"===c.id&&(0,a.jsx)(ew,{officeId:l,onDone:C}),"oauth"===f.wizard&&"gemini-cli"===c.id&&(0,a.jsx)(eb,{officeId:l,onDone:C}),"oauth"===f.wizard&&"google-workspace"===c.id&&(0,a.jsx)(em,{officeId:l,onDone:C}),"oauth"===f.wizard&&"github"===c.id&&(0,a.jsx)(ef,{officeId:l,def:f,status:c,onDone:C})]}),!j&&b&&"google-workspace"===c.id&&(0,a.jsx)("div",{className:"cc-wizard-connected",children:(0,a.jsx)(ep,{officeId:l})}),!j&&b&&"llm"===f.category&&eS.has(c.id)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eC,{officeId:l,integrationId:c.id}),d.length>0&&(0,a.jsxs)("div",{style:{marginTop:10},children:[(0,a.jsxs)("p",{className:"integration-agent-toggles-label",children:["Switch agent to ",c.name]}),(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:4},children:d.map(e=>(0,a.jsxs)("button",{className:"integration-btn integration-btn-ghost",style:{justifyContent:"flex-start",fontSize:11,padding:"6px 10px"},onClick:()=>{window.dispatchEvent(new CustomEvent("mi:open-agent-detail",{detail:{botId:e.id}}))},children:["Use for ",e.name]},e.id))})]}),(0,a.jsx)(ez,{officeId:l,def:f,status:c,onSaved:C}),(0,a.jsx)(eI,{officeId:l,integrationId:c.id,instanceLabel:c.instanceLabel,onRemoved:C})]}),!j&&b&&"auto"===f.wizard&&"active"===f.defaultStatus&&(0,a.jsx)("div",{className:"integration-wizard",children:(0,a.jsx)("p",{className:"integration-wizard-hint",children:"Active for all agents. No setup required."})}),!j&&b&&"auto"===f.wizard&&"active"!==f.defaultStatus&&(0,a.jsx)(eE,{officeId:l,def:f,onToggled:C,enabled:!0}),!k&&!b&&"auto"===f.wizard&&"active"!==f.defaultStatus&&(0,a.jsx)(eE,{officeId:l,def:f,onToggled:C,enabled:!1}),!j&&b&&"auto"!==f.wizard&&"chromium-browser"!==c.id&&!("llm"===f.category&&eS.has(c.id))&&
1(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"integration-btn integration-btn-ghost",style:{width:"100%",textAlign:"center"},onClick:()=>{let e={integrationId:c.id,instanceLabel:c.instanceLabel};m?m(e):window.dispatchEvent(new CustomEvent("mi:open-integration-settings",{detail:e}))},children:"Manage"}),f.multiInstance&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eI,{officeId:l,integrationId:c.id,instanceLabel:c.instanceLabel,onRemoved:C}),!N&&(0,a.jsxs)("button",{type:"button",onClick:()=>S(!0),style:{appearance:"none",background:"none",border:0,color:"rgba(255,255,255,0.45)",fontSize:11,padding:"10px 0 0",cursor:"pointer",textAlign:"center",width:"100%",textDecoration:"underline",textUnderlineOffset:3},children:["+ add a second ",f.name," account"]})]})]}),N&&f.multiInstance&&("guide"===f.wizard||"github"===c.id)&&(0,a.jsxs)("div",{style:{marginTop:16,paddingTop:12,borderTop:"1px solid rgba(255,255,255,0.08)"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,a.jsxs)("span",{style:{fontSize:12,color:"rgba(255,255,255,0.85)"},children:["Adding new ",f.name," account"]}),(0,a.jsx)("button",{type:"button",onClick:()=>S(!1),style:{appearance:"none",background:"none",border:0,color:"rgba(255,255,255,0.5)",fontSize:11,cursor:"pointer",padding:0},children:"Cancel"})]}),"github"===c.id?(0,a.jsx)(ef,{officeId:l,def:f,status:{...c,status:"pending",instanceLabel:"",secretName:null},onDone:z},"".concat(f.id,"::add-another")):(0,a.jsx)(er,{officeId:l,def:f,status:{...c,status:"pending",instanceLabel:"",secretName:null},onSaved:z},"".concat(f.id,"::add-another"))]})]})}function eL(e){let{officeId:t,extId:n,marketplaceExts:s}=e,r=s.find(e=>e.extId===n),[o,l]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[u,h]=(0,i.useState)(""),g=async()=>{l(!0),h("");try{let e=await fetch("/api/offices/".concat(t,"/extensions/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extId:n})});if(e.ok)d(!0);else{let t=await e.json().catch(()=>({}));h(t.error||"HTTP ".concat(e.status))}}catch(e){h(e instanceof Error?e.message:"Install failed")}finally{l(!1)}};return r?(0,a.jsxs)("div",{className:"integration-detail-inner",style:{padding:16},children:[(0,a.jsx)("h3",{style:{fontSize:15,fontWeight:600,marginBottom:4},children:r.name}),(0,a.jsx)("p",{style:{fontSize:12,color:"#9ca3af",marginBottom:12},children:r.description}),(0,a.jsxs)("div",{style:{display:"flex",gap:16,fontSize:11,color:"#6b7280",marginBottom:16},children:[(0,a.jsxs)("span",{children:["v",r.version]}),(0,a.jsx)("span",{children:r.category}),(0,a.jsxs)("span",{children:["by ",r.authorAgent]}),(0,a.jsxs)("span",{children:[r.downloads," installs"]})]}),c?(0,a.jsx)("p",{style:{fontSize:13,color:"#22c55e"},children:"Installed"}):(0,a.jsxs)(a.Fragment,{children:[u&&(0,a.jsx)("p",{style:{fontSize:12,color:"#ef4444",marginBottom:8},children:u}),(0,a.jsx)("button",{className:"integration-btn integration-btn-primary",onClick:g,disabled:o,children:o?"Installingâ¦":"Install"})]})]}):(0,a.jsx)("p",{className:"integration-empty",children:"Extension not found"})}function eD(e){var t,n,s,r,o;let{officeId:l,bots:c,width:d,height:u,onClose:h,demoActiveIntegrations:g}=e,{size:p,isResizing:m,onResizeMouseDown:f}=(0,J.s)({initialWidth:d,initialHeight:u,minWidth:350,minHeight:300,onResizeEnd:(e,t)=>window.dispatchEvent(new CustomEvent("mi:node-resize",{detail:{nodeId:"integrations",w:e,h:t}}))}),[y,x]=(0,i.useState)([]),[w,b]=(0,i.useState)(!0),[j,v]=(0,i.useState)("");(0,i.useRef)(!0).current=w;let[k,N]=(0,i.useState)(new Map),[S,C]=(0,i.useState)(""),[z,E]=(0,i.useState)(new Map);(0,i.useEffect)(()=>{let e=e=>{var t;let{integrationId:n,connected:a}=null!=(t=e.detail)?t:{};n&&E(e=>{let t=new Map(e);return t.set(n,null!=a&&a),t})};return window.addEventListener("mi:integration-status",e),()=>window.removeEventListener("mi:integration-status",e)},[]);let[I,T]=(0,i.useState)([]),[A,L]=(0,i.useState)(!1),D=i.useRef(null),[P,M]=(0,i.useState)(()=>{let e=localStorage.getItem("mi:integration-tab");return"mitosis"===e||"clawhub"===e||"community"===e?e:"mitosis"}),[R,F]=(0,i.useState)([]),[_,G]=(0,i.useState)(!1);(0,i.useEffect)(()=>
1{if("community"!==P||!l)return;let e=!1;return G(!0),(async()=>{try{let t=await fetch("/api/offices/".concat(l,"/marketplace"));if(e)return;if(t.ok){let n=await t.json();e||F(Array.isArray(n)?n:[])}else console.warn("[marketplace] fetch failed:",t.status)}catch(e){console.warn("[marketplace] fetch error:",e)}e||G(!1)})(),()=>{e=!0}},[P,l]);let W=(0,i.useCallback)(async()=>{if(l)try{let e=await fetch("/api/offices/".concat(l,"/integrations"));if(!e.ok){let t=await e.json().catch(()=>({}));v(t.error||"HTTP ".concat(e.status));return}x(await e.json()),v(""),fetch("/api/offices/".concat(l,"/integration-requests")).then(e=>e.ok?e.json():[]).then(e=>{let t=new Map;for(let n of e){let e=t.get(n.integrationId)||[];e.push({agentName:n.agentName,reason:n.reason}),t.set(n.integrationId,e)}N(t)}).catch(()=>{})}catch(e){v(e instanceof Error?e.message:"Failed to load")}finally{b(!1)}},[l]);(0,i.useEffect)(()=>{W()},[W]),(0,i.useEffect)(()=>{let e=()=>W();return window.addEventListener("mi:integration-refresh",e),()=>window.removeEventListener("mi:integration-refresh",e)},[W]),(0,i.useEffect)(()=>{D.current&&clearTimeout(D.current);let e=S.trim();if(!e){T([]),L(!1);return}return L(!0),D.current=setTimeout(async()=>{try{var t;let n=await fetch("/api/integrations/search?q=".concat(encodeURIComponent(e))),a=await n.json();T(null!=(t=a.results)?t:[])}catch(e){T([])}finally{L(!1)}},400),()=>{D.current&&clearTimeout(D.current)}},[S]);let q=S.toLowerCase().trim(),B=q?y.filter(e=>e.name.toLowerCase().includes(q)||e.description.toLowerCase().includes(q)||e.id.toLowerCase().includes(q)):y,H=new Set(y.map(e=>e.id)),K=I.filter(e=>!H.has(e.slug)),[$,X]=(0,i.useState)(()=>{let e=B.length>0?V(B[0]):null;return localStorage.getItem("mi:integration-selected")||e});(0,i.useEffect)(()=>{localStorage.setItem("mi:integration-tab",P)},[P]),(0,i.useEffect)(()=>{$&&localStorage.setItem("mi:integration-selected",$)},[$]),(0,i.useEffect)(()=>{let e=e=>{var t;let{category:n,integrationId:a}=null!=(t=e.detail)?t:{};if(M("mitosis"),a)X(a);else if(n){let e=Y.o4.find(e=>e.category===n);e&&X(e.id)}};return window.addEventListener("mi:open-integration",e),()=>window.removeEventListener("mi:open-integration",e)},[]);let Z=null!=(t=null==$?void 0:$.split("::")[0])?t:null,ee=null!=(o=null!=(r=null!=(s=null!=(n=B.find(e=>V(e)===$))?n:B.find(e=>e.id===$))?s:Z?B.find(e=>e.id===Z):null)?r:B[0])?o:null;return(0,i.useEffect)(()=>{if(!ee)return;let e=V(ee);$!==e&&X(e)},[ee,$]),(0,a.jsxs)(O.A,{title:"Integrations",className:"integration-node-window",style:{width:p.w,height:p.h},resizable:!0,isResizing:m,onResizeMouseDown:f,overlay:h?(0,a.jsx)("button",{className:"integration-close",onClick:h,children:"\xd7"}):void 0,children:[(0,a.jsxs)("div",{className:"integration-search-bar",children:[(0,a.jsx)("input",{className:"integration-search-input",type:"text",placeholder:"Search integrationsâ¦",value:S,onChange:e=>C(e.target.value),autoComplete:"off",spellCheck:!1}),S&&(0,a.jsx)("button",{className:"integration-search-clear",onClick:()=>C(""),children:"\xd7"})]}),(0,a.jsx)("div",{className:"integration-tabs",children:["mitosis","clawhub","community"].map(e=>(0,a.jsx)("button",{className:"integration-tab".concat(P===e?" integration-tab--active":""),onClick:()=>M(e),children:"mitosis"===e?"Mitosis":"clawhub"===e?"ClawHub":"Community"},e))}),!l&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:16},children:"Select an office to manage integrations."}),l&&w&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:16},children:"Loadingâ¦"}),l&&!w&&j&&(0,a.jsxs)("div",{className:"integration-empty integration-empty-error",style:{padding:16},children:[(0,a.jsx)("p",{children:j}),(0,a.jsx)(Q,{message:j,context:"integrations panel",officeId:l})]}),l&&!w&&!j&&(0,a.jsxs)("div",{className:"integration-split",style:{flex:1,overflow:"hidden"},children:[(0,a.jsxs)("div",{className:"integration-list",children:["mitosis"===P&&(0,a.jsxs)(a.Fragment,{children:[Y.sg.map(e=>{let t=B.filter(t=>{let n=Y.o4.find(e=>e.id===t.id);return(null==n?void 0:n.category)===e});return 0===t.length?null:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"integration-list-section",children:Y.Bi[e]}),t.map(e=>{var t,n,i,s,r,o;let l=null!=(i=z.get(e.id))&&i,c=(null==(t=e.metadata)||t.enabledAgentCount,null!=(s=null==g?void 0:g.has(e.id))&&s),d=e.globallyDisabled?e.status:c||l?"active":e.status,u=V(e),h=!!ee&&V(ee)===u;return(0,a.jsxs)("div",{className:"integration-list-item".concat(h?" integration-list-item-selected":""),onClick:()=>X(u),children:[(0,a.jsx)("span",{className:"integration-list-icon",children:(0,a.jsx)(ea,{icon:e.icon,size:13})}),(0,a.jsxs)("span",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,overflow:"hidden"},children:[(0,a.jsx)("span",{className:"integration-list-name",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.multiInstance&&e.instanceLabel&&(0,a.jsxs)("span",{className:"integration-list-instance",style:{fontSize:10,
1color:"rgba(255,255,255,0.45)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3},children:["@",e.instanceLabel]})]}),e.globallyDisabled&&(0,a.jsx)("span",{style:{marginLeft:6,fontSize:10,color:"#f59e0b",flexShrink:0},children:"disabled"}),!e.globallyDisabled&&e.comingSoon&&(0,a.jsx)("span",{style:{marginLeft:6,fontSize:10,color:"#a78bfa",flexShrink:0},children:"soon"}),(null!=(r=null==(n=k.get(e.id))?void 0:n.length)?r:0)>0&&(0,a.jsx)("span",{title:"".concat(k.get(e.id).length," pending agent request").concat(k.get(e.id).length>1?"s":""),style:{marginLeft:4,fontSize:9,fontWeight:600,color:"#fff",background:"#8b5cf6",borderRadius:999,minWidth:14,height:14,padding:"0 4px",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:k.get(e.id).length}),(0,a.jsx)("span",{className:"integration-list-dot",style:{background:null!=(o=es[d])?o:"#6b7280",flexShrink:0}})]},u)})]},e)}),0===B.length&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:12,fontSize:12},children:"No matching integrations"})]}),"clawhub"===P&&(0,a.jsxs)(a.Fragment,{children:[A&&(0,a.jsx)("p",{className:"integration-hub-searching",children:"Searching ClawHubâ¦"}),!A&&!q&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:12,fontSize:12,color:"#6b7280"},children:"Type to search ClawHub skills"}),!A&&q&&0===K.length&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:12,fontSize:12},children:"No results on ClawHub"}),K.map(e=>(0,a.jsxs)("div",{className:"integration-list-item integration-list-item-hub",onClick:()=>window.open("https://clawhub.ai/skills/".concat(e.slug),"_blank"),children:[(0,a.jsx)("span",{className:"integration-list-icon",style:{fontSize:13},children:"\uD83D\uDCE6"}),(0,a.jsx)("span",{className:"integration-list-name",children:e.displayName})]},e.slug))]}),"community"===P&&(0,a.jsxs)(a.Fragment,{children:[_&&(0,a.jsx)("p",{className:"integration-hub-searching",children:"Loading marketplaceâ¦"}),!_&&0===R.length&&(0,a.jsx)("p",{className:"integration-empty",style:{padding:12,fontSize:12,color:"#6b7280"},children:"No community extensions published yet"}),R.filter(e=>!q||e.name.toLowerCase().includes(q)||e.extId.toLowerCase().includes(q)).map(e=>(0,a.jsxs)("div",{className:"integration-list-item integration-list-item-community",onClick:()=>X("mkt:".concat(e.extId)),children:[(0,a.jsx)("span",{className:"integration-list-icon",style:{fontSize:13},children:"\uD83C\uDF10"}),(0,a.jsx)("span",{className:"integration-list-name",children:e.name}),(0,a.jsxs)("span",{className:"integration-list-meta",children:[e.downloads," installs"]})]},e.extId))]})]}),(0,a.jsx)("div",{className:"integration-detail",children:"mitosis"===P&&ee?(0,a.jsx)(eO,{officeId:l,integration:ee,bots:c,liveConnected:z,onRefresh:W,demoActiveIntegrations:g,pendingAgentRequests:k.get(ee.id)},V(ee)):"community"===P&&(null==$?void 0:$.startsWith("mkt:"))?(0,a.jsx)(eL,{officeId:l,extId:$.replace("mkt:",""),marketplaceExts:R}):"clawhub"===P?(0,a.jsx)("p",{className:"integration-empty",style:{padding:16,fontSize:12,color:"#6b7280"},children:"Click a ClawHub skill to view it on clawhub.ai"}):(0,a.jsx)("p",{className:"integration-empty",children:"Select an integration"})})]}),(0,a.jsx)("div",{style:{padding:"12px 16px",borderTop:"1px solid rgba(255,255,255,0.08)"},children:(0,a.jsx)(U,{officeId:l})})]})}},34037:(e,t,n)=>{n.d(t,{$:()=>l,Y:()=>o});let a="__os1BugReportDiagnostics";function i(e){if("string"==typeof e)return e;if(e instanceof Error)return"".concat(e.name,": ").concat(e.message);try{let t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[circular]";t.add(n)}return n})}catch(t){return String(e)}}function s(){let e=globalThis;return e[a]||(e[a]={diagnostics:[],refCount:0}),e[a]}function r(e,t){e.diagnostics.push(t),e.diagnostics.length>50&&e.diagnostics.splice(0,e.diagnostics.length-50)}function o(){let e=s();if(e.refCount+=1,!e.restore){let t=console.error.bind(console);console.error=function(){for(var n=arguments.length,a=Array(n),s=0;s<n;s++)a[s]=arguments[s];r(e,{timestamp:new Date().toISOString(),source:"console.error",args:a.map(e=>i(e))}),t(...a)};let n=t=>{r(e,{timestamp:new Date().toISOString(),source:"window.error",message:t.message,stack:t.error instanceof Error?t.error.stack:void 0,filename:t.filename,lineno:t.lineno,colno:t.colno})},a=t=>{r(e,{timestamp:new Date().toISOString(),source:"unhandledrejection",reason:i(t.reason)})};window.addEventListener("error",n),window.addEventListener("unhandledrejection",a),e.restore=()=>{console.error=t,window.removeEventListener("error",n),window.removeEventListener("unhandledrejection",a),e.restore=void 0}}return()=>{e.refCount=Math.max(0,e.refCount-1),0===e.refCount&&e.restore&&e.restore(
1)}}function l(){return[...s().diagnostics]}},69498:(e,t,n)=>{n.d(t,{s:()=>i});var a=n(12115);function i(e){let{initialWidth:t,initialHeight:n,minWidth:i=200,minHeight:s=200,onResizeEnd:r}=e,[o,l]=(0,a.useState)({w:t,h:n}),[c,d]=(0,a.useState)(!1),u=(0,a.useRef)(!1);(0,a.useEffect)(()=>{u.current||l({w:t,h:n})},[t,n]);let h=(0,a.useRef)(!1),g=(0,a.useRef)({x:0,y:0,w:0,h:0}),p=(0,a.useCallback)(e=>{var t,n,a;e.preventDefault(),e.stopPropagation();let c=null!=(a=null==(n=e.currentTarget)||null==(t=n.dataset)?void 0:t.edge)?a:"corner",p="right"===c||"corner"===c,m="bottom"===c||"corner"===c;h.current=!0,d(!0),g.current={x:e.clientX,y:e.clientY,w:o.w,h:o.h};let f=e=>{if(!h.current)return;let t=p?e.clientX-g.current.x:0,n=m?e.clientY-g.current.y:0;l({w:Math.max(i,g.current.w+t),h:Math.max(s,g.current.h+n)})},y=e=>{if(h.current=!1,u.current=!0,d(!1),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",y),r){let t=p?e.clientX-g.current.x:0,n=m?e.clientY-g.current.y:0;r(Math.max(i,g.current.w+t),Math.max(s,g.current.h+n))}};document.addEventListener("mousemove",f),document.addEventListener("mouseup",y)},[o.w,o.h,i,s,r]);return{size:o,isResizing:c,onResizeMouseDown:p}}},96775:(e,t,n)=>{n.d(t,{c_:()=>s});let a=new Set(["gmail.com","googlemail.com","ymail.com","rocketmail.com","msn.com","icloud.com","me.com","mac.com","aol.com","proton.me","protonmail.com","pm.me","tutanota.com","tuta.com","tutanota.de","zoho.com","hey.com","fastmail.com","mail.com","duck.com","inbox.lv","yandex.com","yandex.ru","ya.ru","mail.ru","list.ru","bk.ru","inbox.ru","rambler.ru","qq.com","vip.qq.com","163.com","126.com","139.com","189.cn","foxmail.com","yeah.net","sina.com","sina.cn","sohu.com","aliyun.com","tom.com","naver.com","daum.net","hanmail.net","nate.com","web.de","t-online.de","freenet.de","posteo.de","mailbox.org","seznam.cz","wp.pl","o2.pl","onet.pl","interia.pl","free.fr","sfr.fr","laposte.net","orange.fr","wanadoo.fr","libero.it","virgilio.it","ukr.net","i.ua","bigmi.net","comcast.net","verizon.net","sbcglobal.net","cox.net","btinternet.com","rediffmail.com","disroot.org","tuta.io","myyahoo.com","vip.163.com","privaterelay.appleid.com","users.noreply.github.com","noreply.github.com"]),i=new Set(["yahoo","hotmail","outlook","live","gmx","gmail","aol"]);function s(e){if(!e)return null;let t=e.indexOf("@");if(t<0)return null;let n=e.slice(t+1).trim().toLowerCase();return!n||!n.includes(".")||a.has(n)||i.has(n.split(".")[0])?null:n}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.