PageSourceSearch

https://superwise.chat/_next/static/chunks/4297.ac75969a8959c471.js

js superwise.chat collected 2026-10-04 01:56:37 UTC 46,856 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4297],{20639:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]])},25664:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("chart-no-axes-column",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]])},26921:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]])},39332:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]])},39347:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]])},50906:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},54297:(e,t,s)=>{s.r(t),s.d(t,{ApplicationDashboard:()=>ej});var a=s(95155),l=s(12115),n=s(5121);let i=(0,n.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var r=s(39068),c=s(91456),o=s(89406),d=s(1559),x=s(77979),p=s(52799),m=s(94546),u=s(76907),h=s(89715),w=s(91169),g=s(39332),b=s(56154);let f=(0,n.A)("headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);var j=s(25664),y=s(47937),v=s(37586),N=s(17910),k=s(1473),A=s(95740),_=s(86651),z=s(66955),C=s(39347),S=s(18518);let M=(0,n.A)("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);var L=s(61194);let E={all:(0,a.jsx)(M,{size:14}),analytics:(0,a.jsx)(j.A,{size:14}),support:(0,a.jsx)(f,{size:14}),content:(0,a.jsx)(h.A,{size:14}),productivity:(0,a.jsx)(L.A,{size:14}),compliance:(0,a.jsx)(u.A,{size:14}),knowledge:(0,a.jsx)(y.A,{size:14}),workflow:(0,a.jsx)(g.A,{size:14}),connector:(0,a.jsx)(r.A,{size:14})},P={all:"All",analytics:"Analytics",support:"Support",content:"Content",productivity:"Productivity",compliance:"Compliance",knowledge:"Knowledge",workflow:"Workflow",connector:"Connectors"},F=["all","analytics","support","content","productivity","compliance","knowledge","workflow","connector"],T={support:"from-violet-500 to-purple-600",analytics:"from-blue-500 to-cyan-500",knowledge:"from-emerald-500 to-teal-500",content:"from-cyan-500 to-blue-500",productivity:"from-pink-500 to-rose-500",compliance:"from-slate-500 to-slate-600",workflow:"from-indigo-500 to-blue-600",connector:"from-green-500 to-emerald-600"},D=e=>{let{app:t,installed:s,installing:l,onInstall:n,compact:i}=e;return(0,a.jsxs)("div",{className:(0,x.cn)("group relative sw-card-lg overflow-hidden","hover:shadow-sw-lg hover:border-sw-primary/40","transition-all duration-200",i&&"flex gap-4 items-start p-4"),children:[!i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:(0,x.cn)("h-16 bg-gradient-to-br flex items-end px-4 pb-3",t.gradient),children:[(0,a.jsx)("div",{className:"w-9 h-9 rounded-sw-lg bg-sw-background/20 backdrop-blur-sm flex items-center justify-center",children:t.icon}),t.featured&&(0,a.jsx)("span",{className:"ml-auto text-sw-caption font-bold uppercase tracking-wider text-white/80 bg-sw-background/20 px-2 py-0.5 rounded-sw-full",children:"Featured"})]}),(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsx)("div",{className:"flex items-start justify-between gap-2 mb-1",children:(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text leading-tight",children:t.name})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,a.jsx)("span",{className:"text-sw-caption px-1.5 py-0.5 rounded-sw-sm bg-sw-background border border-sw-border-subtle text-sw-text-muted capitalize",children:t.category}),(0,a.jsx)("span",{className:"text-sw-caption text-sw-text-disabled",children:t.author})]}),(0,a.jsx)("p",{className:"sw-text-caption-muted line-clamp-2 mb-3",children:t.description}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.tags.slice(0,3).map(e=>(0,a.jsx)("span",{className:"text-sw-caption px-1.5 py-0.5 rounded-sw-sm bg-sw-background border border-sw-border-subtle text-sw-text-disabled",children:e},e))}),(0,a.jsx)("button",{onClick:n,disabled:s||l,className:(0,x.cn)("text-sw-caption font-medium px-3 py-1 rounded-sw-md transition-all",s?"bg-sw-coverage-full-bg text-sw-coverage-full-text cursor-default":l?"bg-sw-border text-sw-text-muted cursor-wait":"bg-sw-primary text-white hover:bg-sw-primary-hover shadow-sw-sm"),children:s?"✓ Installed":l?"Adding…":"+ Add"})]})]})]}),i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:(0,x.cn)("w-10 h-10 rounded-sw-lg bg-gradient-to-br flex-shrink-0 flex items-center justify-center",t.gradient),children:t.icon}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-2 mb-0.5",children:(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:t.name})}),(0,a.jsx)("p",{className:"sw-text-caption-muted line-clamp-1 mb-1",children:t.description}),(0,a.jsx)("div",{className:"flex items-center gap-1.5",children:t.tags.slice(0,3).map(e=>(0,a.jsx)("span",{className:"text-sw-caption px-1.5 py-0.5 rounded-sw-sm bg-sw-background border border-sw-border-subtle text-sw-text-disabled",children:e},e))})]}),(0,a.jsx)("button",{onClick:n,disabled:s||l,className:(0,x.cn)("flex-shrink-0 text-sw-caption font-medium px-3 py-1 rounded-sw-md transition-all self-center",s?"bg-sw-coverage-full-bg text-sw-coverage-full-text cursor-default":l?"bg-sw-border text-sw-text-muted cursor-wait":"bg-sw-primary text-white hover:bg-sw-primary-hover"),children:s?"✓":l?"…":"+ Add"})]})]})},I={ShieldCheck:(0,a.jsx)(u.A,{size:20,className:"text-white"}),FileText:(0,a.jsx)(h.A,{size:20,className:"text-white"}),Users:(0,a.jsx)(w.A,{size:20,className:"text-white"}),GitBranch:(0,a.jsx)(g.A,{size:20,className:"text-white"}),Zap:(0,a.jsx)(b.A,{size:20,className:"text-white"}),Headphones:(0,a.jsx)(f,{size:20,className:"text-white"}),BarChart2:(0,a.jsx)(j.A,{size:20,className:"text-white"}),BookOpen:(0,a.jsx)(y.A,{size:20,className:"text-white"}),MessageSquare:(0,a.jsx)(v.A,{size:20,className:"text-white"}),Shield:(0,a.jsx)(N.A,{size:20,className:"text-white"}),Globe:(0,a.jsx)(r.A,{size:20,className:"text-white"}),Brain:(0,a.jsx)(k.A,{size:20,className:"text-white"})},V=e=>{let{onInstall:t,installedIds:s}=e,[n,i]=(0,l.useState)("all"),[c,o]=(0,l.useState)(""),[d,p]=(0,l.useState)(null),[u,h]=(0,l.useState)([]),[w,g]=(0,l.useState)(!0),[b,f]=(0,l.useState)(!1),j=(0,l.useCallback)(()=>{g(!0),f(!1),m.getApplicationTemplates().then(e=>{h(e),g(!1)}).catch(()=>{f(!0),g(!1)})},[]);(0,l.useEffect)(()=>{j()},[j]);let y=(0,l.useMemo)(()=>u.map(e=>{var t,s,l,n,i,r;return{id:e.template_id,name:e.name,description:e.description,long_description:e.description,category:null!=(t=e.category)?t:"workflow",icon:null!=(l=I[null!=(s=e.icon)?s:""])?l:(0,a.jsx)(A.A,{size:20,className:"text-white"}),gradient:null!=(i=T[null!=(n=e.category)?n:""])?i:"from-indigo-500 to-violet-600",tags:null!=(r=e.tags)?r:[],installs:0,rating:0,author:"Superwise",featured:e.featured}}),[u]),v=(0,l.useMemo)(()=>{let e=y;if("all"!==n&&(e=e.filter(e=>e.category===n)),c.trim()){let t=c.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.tags.some(e=>e.includes(t)))}return e},[y,n,c]),N=y.filter(e=>e.featured),k=y.filter(e=>"connector"===e.category),M=async e=>{p(e.id);try{await t(e.id,{})}finally{p(null)}};return w?(0,a.jsx)("div",{className:"max-w-6xl mx-auto px-6 py-6 space-y-4",children:[1,2,3,4,5,6].map(e=>(0,a.jsx)("div",{className:"h-40 rounded-sw-lg bg-sw-surface border border-sw-border animate-pulse"},e))}):b?(0,a.jsx)("div",{className:"max-w-6xl mx-auto px-6 py-6",children:(0,a.jsx)(S.pp,{icon:_.A,title:"Failed to load marketplace",description:"Could not fetch available apps. Please try again.",secondaryLabel:"Retry",onSecondaryClick:j})}):(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-6 space-y-8",children:[(0,a.jsxs)("div",{className:"relative w-full max-w-sm",children:[(0,a.jsx)(_.A,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-sw-text-muted pointer-events-none"}),(0,a.jsx)("input",{type:"text",value:c,onChange:e=>o(e.target.value),placeholder:"Search apps…",className:"w-full pl-8 pr-3 py-1.5 text-sw-body bg-sw-surface border border-sw-border rounded-sw-md sw-focus-ring text-sw-text placeholder:text-sw-text-placeholder"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(z.A,{size:12,className:"text-sw-text-muted flex-shrink-0"}),F.map(e=>(0,a.jsxs)("button",{onClick:()=>i(e),className:(0,x.cn)("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-sw-full text-sw-caption font-medium transition-all border",n===e?"bg-sw-primary text-white border-sw-primary shadow-sw-sm":"bg-sw-surface border-sw-border text-sw-text-muted hover:border-sw-primary/60 hover:text-sw-text"),children:[E[e]," ",P[e]]},e))]}),"all"===n&&!c&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,a.jsx)(C.A,{size:14,className:"text-amber-500 fill-amber-500"}),(0,a.jsx)("h2",{className:"text-sw-body font-semibold text-sw-text",children:"Featured"})]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-4",children:N.map(e=>(0,a.jsx)(D,{app:e,installed:s.has(e.id),installing:d===e.id,onInstall:()=>M(e)},e.id))})]}),"all"===n&&!c&&k.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,a.jsx)(r.A,{size:14,className:"text-sw-primary-text"}),(0,a.jsx)("h2",{className:"text-sw-body font-semibold text-sw-text",children:"Connectors"})]}),(0,a.jsx)("div",{className:"space-y-3",children:k.map(e=>(0,a.jsx)(D,{app:e,installed:s.has(e.id),installing:d===e.id,onInstall:()=>M(e),compact:!0},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsxs)("h2",{className:"text-sw-body font-semibold text-sw-text",children:[c?'Results for "'.concat(c,'"'):"all"===n?"All":P[n],(0,a.jsxs)("span",{className:"ml-2 text-sw-caption font-normal text-sw-text-muted",children:["(",v.length,")"]})]})}),0===v.length?(0,a.jsx)(S.pp,{icon:_.A,title:'No apps found for "'.concat(c,'"'),secondaryLabel:"Clear search",onSecondaryClick:()=>o(""),className:"py-16"}):(0,a.jsx)("div",{className:"grid grid-cols-3 gap-4",children:v.map(e=>(0,a.jsx)(D,{app:e,installed:s.has(e.id),installing:d===e.id,onInstall:()=>M(e)},e.id))})]})]})};var O=s(6191),q=s(27937),B=s(31166),R=s(36402),$=s(35626),G=s(15870),H=s(20639),U=s(26983),W=s(50906),K=s(4788),Z=s(93499),J=s(5917),Q=s(75426),X=s(71360),Y=s(55275),ee=s(89559),et=s(37091);s(67423);var es=s(4602),ea=s(5590),el=s(43698),en=s(3005);let ei={manual:"Manual only",hourly:"Every hour",daily:"Daily",weekly:"Weekly"},er=[{value:"docx",label:"Word (.docx)"},{value:"pdf",label:"PDF (.pdf)"},{value:"pptx",label:"PowerPoint (.pptx)"},{value:"xlsx",label:"Excel (.xlsx)"},{value:"txt",label:"Plain text (.txt)"}],ec=["docx","pdf","pptx"];function eo(e){var t,s;let a=null!=(t=e.config)?t:{};if("string"==typeof a.connector_type&&a.connector_type)return a.connector_type;let l=null!=(s=e.template_id)?s:"",n=l.match(/connector[-_]([a-z0-9_-]+)$/i);
1return n?n[1].toLowerCase():l}function ed(e){var t,s,n,i,r,c,o,x;let{app:p,open:u,onClose:h,onSaved:w}=e,{showToast:g}=(0,d.d)(),b=null!=(s=p.config)?s:{},[f,j]=(0,l.useState)(null),y=(0,l.useRef)(null),v=null!=(n=null==f?void 0:f.file_types)?n:er,N=null!=(i=null==f?void 0:f.default_file_types)?i:ec,[k,A]=(0,l.useState)({}),[_,z]=(0,l.useState)(b.sync_schedule||"manual"),[C,S]=(0,l.useState)(Array.isArray(b.file_types)?b.file_types:N),[M,L]=(0,l.useState)(null!=b.max_file_size_mb?String(b.max_file_size_mb):"50"),[E,P]=(0,l.useState)(!1),[F,T]=(0,l.useState)(""),[D,I]=(0,l.useState)(""),[V,O]=(0,l.useState)(!1),[q,R]=(0,l.useState)(null),[$,G]=(0,l.useState)(!1),[H,U]=(0,l.useState)(!1),W=(0,l.useRef)(null);async function K(){var e;let t=null==f||null==(e=f.config_schema)?void 0:e.length;if(!t){let e=parseFloat(M);if(isNaN(e)||e<=0)return void T("Max file size must be a positive number.")}if(0===C.length&&v.length>0)return void I("Select at least one file type.");P(!0);try{let e=t?{...b,...k,...v.length>0?{file_types:C}:{}}:{...b,sync_schedule:_,file_types:C,max_file_size_mb:parseFloat(M)},s=await m.updateApplication(p.application_id,{config:e});g("Connector settings saved","success"),w(s),h()}catch(e){g("Failed to save connector settings","error")}finally{P(!1)}}async function J(){let e=eo(p);O(!0);try{let{authorize_url:t}=await m.getConnectorOAuthUrl(e);window.open(t,"_blank","noopener,noreferrer"),g("OAuth window opened — complete sign-in to re-authenticate","info")}catch(e){g("Failed to retrieve OAuth URL","error")}finally{O(!1)}}(0,l.useEffect)(()=>{var e;if(!u)return;let t=null!=(e=p.config)?e:{};z(t.sync_schedule||"manual"),S(Array.isArray(t.file_types)?t.file_types:N),L(null!=t.max_file_size_mb?String(t.max_file_size_mb):"50"),A({...t});let s=eo(p);y.current!==p.application_id&&(y.current=p.application_id,j(null),G(!0),m.getConnectorManifests().then(e=>{var t,a;let l=null!=(a=e.find(e=>e.id===s||e.provider===s))?a:null;if(j(l),null==l||null==(t=l.config_schema)?void 0:t.length){let e={};for(let t of l.config_schema)void 0!==t.default&&(e[t.key]=t.default);A(t=>({...e,...t}))}}).catch(()=>{j(null)}).finally(()=>{G(!1)})),W.current!==p.application_id&&(W.current=p.application_id,R(null),m.getConnectorConnection(s).then(e=>{let{configured:t}=e;return R(t)}).catch(()=>R(!0)))},[u,p.application_id]);let Q=null!=(r=null==f?void 0:f.display_name)?r:eo(p),X=null!=(c=null==f?void 0:f.info_fields)?c:[],ed=null!=(o=null==f?void 0:f.display_name)?o:Q,ex=null!=(x=null==f?void 0:f.max_file_size_mb_default)?x:50;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(es.lG,{open:u,onOpenChange:e=>{e||h()},children:(0,a.jsxs)(es.Cf,{size:"lg",children:[(0,a.jsx)(es.c7,{children:(0,a.jsxs)(es.L3,{children:["Configure ",Q," Connector"]})}),(0,a.jsxs)("div",{className:"space-y-5 py-1",children:[!1===q&&(0,a.jsxs)("div",{className:"rounded-sw-md bg-sw-background border border-sw-border p-4 flex items-center justify-between gap-4",children:[(0,a.jsx)("p",{className:"text-sw-body text-sw-text-muted",children:"No credentials configured. Run the connection wizard to authenticate and link a library."}),(0,a.jsxs)(B.$,{variant:"primary",size:"sm",onClick:()=>U(!0),children:[(0,a.jsx)(Y.A,{size:13})," Connect"]})]}),X.length>0&&(0,a.jsx)("div",{className:"rounded-sw-md bg-sw-background border border-sw-border p-4 space-y-2 text-sw-body",children:X.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sw-text-muted w-28 shrink-0",children:e.label}),(0,a.jsx)("span",{className:"text-sw-text font-medium truncate",children:String(b[e.key]||"—")})]},e.key))}),$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 py-2 text-sw-text-muted",children:[(0,a.jsx)(en.y,{size:"sm"}),(0,a.jsx)("span",{className:"text-sw-body",children:"Loading connector settings…"})]}),!$&&(null==f||null==(t=f.config_schema)?void 0:t.length)?f.config_schema.map(e=>(function(e,t,s){var l,n,i,r,c;switch(e.type){case"text":return(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:e.label}),(0,a.jsx)(ea.p,{value:String(null!=(l=null!=t?t:e.default)?l:""),onChange:t=>s(e.key,t.target.value),placeholder:e.hint}),e.hint&&(0,a.jsx)("p",{className:"sw-text-caption-muted",children:e.hint})]},e.key);case"number":return(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:e.label}),(0,a.jsx)(ea.p,{type:"number",value:String(null!=(n=null!=t?t:e.default)?n:""),onChange:t=>s(e.key,parseFloat(t.target.value)||0),className:"w-32"})]},e.key);case"select":return(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:e.label}),(0,a.jsxs)(el.l6,{value:String(null!=(i=null!=t?t:e.default)?i:""),onValueChange:t=>s(e.key,t),children:[(0,a.jsx)(el.bq,{children:(0,a.jsx)(el.yv,{})}),(0,a.jsx)(el.gC,{children:(null!=(r=e.options)?r:[]).map(e=>(0,a.jsx)(el.eb,{value:e.value,children:e.label},e.value))})]})]},e.key);case"toggle":return(0,a.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",className:"accent-sw-primary",checked:!!(null!=(c=null!=t?t:e.default)&&c),onChange:t=>s(e.key,t.target.checked)}),(0,a.jsx)("span",{className:"text-sw-body font-medium text-sw-text",children:e.label})]},e.key);default:return null}})(e,k[e.key],(e,t)=>A(s=>({...s,[e]:t})))):$?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:"Sync schedule"}),(0,a.jsxs)(el.l6,{value:_,onValueChange:e=>z(e),children:[(0,a.jsx)(el.bq,{children:(0,a.jsx)(el.yv,{})}),(0,a.jsx)(el.gC,{children:Object.keys(ei).map(e=>(0,a.jsx)(el.eb,{value:e,children:ei[e]},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:"Max file size (MB)"}),(0,a.jsx)(ea.p,{type:"number",min:"1",max:"500",placeholder:String(ex),value:M,onChange:e=>{L(e.target.value),F&&T("")},className:"w-32"}),F&&(0,a.jsx)("p",{role:"alert",className:"text-sw-error text-sw-caption mt-0.5",children:F})]})]}),v.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sw-body font-medium text-sw-text",children:"File types"}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:v.map(e=>{let{value:t,label:s}=e,l=C.includes(t);return(0,a.jsxs)("label",{className:"flex items-center gap-2.5 px-3 py-2 rounded-sw-md border cursor-pointer transition-colors ".concat(l?"border-sw-primary bg-sw-primary/5 text-sw-text":"border-sw-border bg-sw-background text-sw-text-muted hover:border-sw-border-hover"),children:[(0,a.jsx)("input",{type:"checkbox",className:"accent-sw-primary",checked:l,onChange:()=>{D&&I(""),S(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}}),(0,a.jsx)("span",{className:"text-sw-body",children:s})]},t)})}),D&&(0,a.jsx)("p",{role:"alert",className:"text-sw-error text-sw-caption mt-0.5",children:D})]}),!1!==q&&(0,a.jsxs)("div",{className:"rounded-sw-md border border-sw-border p-4 flex items-center justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sw-body font-medium text-sw-text",children:[ed," credentials"]}),(0,a.jsx)("p",{className:"sw-text-caption-muted mt-0.5",children:"Re-authenticate if the connector reports a credentials error."})]}),(0,a.jsxs)(B.$,{variant:"secondary",size:"sm",onClick:J,disabled:V,children:[V?(0,a.jsx)(en.y,{size:"xs"}):(0,a.jsx)(Z.A,{size:13}),"Re-authenticate"]})]})]}),(0,a.jsxs)(es.Es,{children:[(0,a.jsx)(B.$,{variant:"ghost",size:"sm",onClick:h,disabled:E,children:"Cancel"}),(0,a.jsx)(B.$,{variant:"primary",size:"sm",onClick:K,disabled:E,children:E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(en.y,{size:"xs"})," Saving…"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ee.A,{size:13})," Save"]})})]})]})}),(0,a.jsx)(et.ConnectorWizard,{open:H,onClose:()=>U(!1)})]})}var ex=s(1524),ep=s(26921),em=s(7125);let eu=e=>{let{label:t,value:s,subtitle:l,trend:n,trendValue:i,trendPositive:r,icon:c,accent:o}=e;return(0,a.jsxs)("div",{className:"sw-card-lg p-4 hover:shadow-sw-md transition-shadow",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-sw-caption font-medium text-sw-text-muted uppercase tracking-wide",children:t}),(0,a.jsx)("span",{className:(0,x.cn)("p-1.5 rounded-sw-md",o||"bg-sw-primary/10"),children:c})]}),(0,a.jsx)("div",{className:"text-sw-h1 font-bold text-sw-text",children:s}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[n&&i&&(0,a.jsxs)("span",{className:(0,x.cn)("inline-flex items-center gap-0.5 text-sw-caption font-medium",r?"text-sw-success-text":"down"===n?"text-sw-error":"text-sw-text-muted"),children:["up"===n&&(0,a.jsx)(ex.A,{size:12}),"down"===n&&(0,a.jsx)(ep.A,{size:12}),"flat"===n&&(0,a.jsx)(em.A,{size:12}),i]}),l&&(0,a.jsx)("span",{className:"sw-text-caption-muted",children:l})]})]})};function eh(e){let t=new Date,s=new Date(e),a=Math.floor((t.getTime()-s.getTime())/6e4);if(a<60)return"".concat(a,"m ago");let l=Math.floor(a/60);return l<24?"".concat(l,"h ago"):"".concat(Math.floor(l/24),"d ago")}function ew(e){let t=e.selected_files;return Array.isArray(t)&&0!==t.length?t.filter(e=>!!e&&"object"==typeof e):null}let eg={GET:"bg-sw-coverage-full-bg text-sw-coverage-full-text",POST:"bg-sw-info-bg text-sw-info-text",PUT:"bg-sw-coverage-partial-bg text-sw-coverage-partial-text",DELET
1E:"bg-sw-error/10 text-sw-error"},eb=e=>{var t,s,l,n,r,c;let{app:o,metrics:d,metricsError:m,executions:h,hitlPending:g,connectorHasCredentials:f,syncingConnector:j,copiedEndpoint:y,connectorConfigOpen:k,onBack:A,onDelete:_,onCopyEndpoint:z,onOpenConnectorConfig:C,onCloseConnectorConfig:M,onSyncNow:L,onConnectorSaved:E}=e,P=(e=>{let t="".concat("/v1/applications","/").concat(e);return[{method:"GET",path:t},{method:"PUT",path:t},{method:"DELETE",path:t},{method:"GET",path:"".concat(t,"/metrics")},{method:"POST",path:"".concat(t,"/actions/:actionId/execute")},{method:"GET",path:"".concat(t,"/actions/:actionId/executions/:executionId")}]})(o.application_id);return(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto bg-sw-background",children:[(0,a.jsx)("div",{className:"sticky top-0 z-10 bg-sw-background/95 backdrop-blur-sm border-b border-sw-border",children:(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-4 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(B.$,{variant:"ghost",size:"sm",iconOnly:!0,onClick:A,children:(0,a.jsx)($.A,{size:18,className:"text-sw-text-muted"})}),(0,a.jsx)("div",{className:"w-10 h-10 rounded-sw-lg bg-gradient-to-br from-violet-500 to-purple-600 flex items-center justify-center shadow-sw-lg shadow-violet-500/20",children:(0,a.jsx)(i,{size:20,className:"text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"text-sw-h3 font-bold text-sw-text",children:o.name}),(0,a.jsx)("span",{className:(0,x.cn)("text-sw-caption px-2 py-0.5 rounded-sw-full font-semibold uppercase tracking-wide","published"===o.status?"bg-sw-coverage-full-bg text-sw-coverage-full-text":"bg-sw-coverage-partial-bg text-sw-coverage-partial-text"),children:o.status}),(0,a.jsxs)("span",{className:"text-sw-caption text-sw-text-disabled font-mono",children:["v",o.version]})]}),(0,a.jsx)("p",{className:"sw-text-caption-muted",children:o.description||"No description"})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(null==(t=o.template_id)?void 0:t.includes("sharepoint"))?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(B.$,{variant:"secondary",size:"sm",onClick:C,children:[(0,a.jsx)(G.A,{size:14})," Configure"]}),(0,a.jsxs)(B.$,{variant:"primary",size:"sm",disabled:j,onClick:()=>L(o),children:[(0,a.jsx)(H.A,{size:14})," ",j?"Syncing…":"Sync Now"]})]}):(0,a.jsx)(p.E,{variant:"outline",children:"Coming soon"})})]})}),(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-6 space-y-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-5 gap-4",children:[(0,a.jsx)(eu,{label:"Conversations",value:d?d.conversations.total.toLocaleString():"—",trend:"up",trendValue:d?"".concat(d.conversations.last_7_days," this week"):"",trendPositive:!0,icon:(0,a.jsx)(v.A,{size:16,className:"text-sw-primary-text"})}),(0,a.jsx)(eu,{label:"Avg Response",value:(null==d?void 0:d.avg_response_ms)!=null?"".concat((d.avg_response_ms/1e3).toFixed(1),"s"):"—",trend:"flat",trendValue:"",icon:(0,a.jsx)(b.A,{size:16,className:"text-sw-warning-text"}),accent:"bg-sw-coverage-partial-bg"}),(0,a.jsx)(eu,{label:"Guardrail Pass",value:(null==d?void 0:d.guardrail_pass_rate)!=null?"".concat(Math.round(100*d.guardrail_pass_rate),"%"):"—",trend:"flat",trendValue:(null==d?void 0:d.guardrail_pass_rate)!=null?"".concat(Math.round(100*d.guardrail_pass_rate),"% pass rate"):"",icon:(0,a.jsx)(N.A,{size:16,className:"text-sw-coverage-full-text"}),accent:"bg-sw-coverage-full-bg"}),(null==(s=o.template_id)?void 0:s.includes("sharepoint"))?(0,a.jsx)(eu,{label:"Last Sync",value:h.length>0?h[0].status:"—",trend:"flat",trendValue:h.length>0?new Date(h[0].started_at).toLocaleDateString():"",icon:(0,a.jsx)(U.A,{size:16,className:"text-sw-info-text"}),accent:"bg-sw-info-bg dark:bg-sw-info/10"}):(0,a.jsx)(eu,{label:"Actions Executed",value:d?d.action_executions.toLocaleString():"—",trend:"flat",trendValue:"",icon:(0,a.jsx)(w.A,{size:16,className:"text-sw-info-text"}),accent:"bg-sw-info-bg dark:bg-sw-info/10"}),(0,a.jsx)(eu,{label:"Workflows",value:(null==d?void 0:d.workflow_executions)?"".concat(d.workflow_executions.completed,"/").concat(d.workflow_executions.total):"—",subtitle:(null==d||null==(l=d.workflow_executions)?void 0:l.failed)?"".concat(d.workflow_executions.failed," failed"):void 0,trend:"flat",trendValue:"",icon:(0,a.jsx)(W.A,{size:16,className:"text-sw-primary-text"}),accent:"bg-sw-primary/5"})]}),m&&(0,a.jsx)("p",{className:"sw-text-caption-muted",children:"Metrics unavailable"}
1),(0,a.jsxs)("div",{className:"grid grid-cols-5 gap-6",children:[(0,a.jsxs)("div",{className:"col-span-3 space-y-6",children:[(null==(n=o.template_id)?void 0:n.includes("sharepoint"))?(()=>{var e;let t=null!=(e=o.config)?e:{},s=Array.isArray(t.file_types)?t.file_types.join(", "):"—";return(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(K.A,{size:16,className:"text-sw-primary-text"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"SharePoint Connection"}),(0,a.jsx)("span",{className:"ml-auto text-sw-caption font-semibold px-2 py-0.5 rounded-sw-full ".concat(!0===f?"bg-sw-coverage-full-bg text-sw-coverage-full-text":!1===f?"bg-sw-error/10 text-sw-error":"bg-sw-border text-sw-text-muted animate-pulse"),children:!0===f?"Authenticated":!1===f?"No credentials":"Checking…"})]}),(0,a.jsxs)("div",{className:"p-5 grid grid-cols-2 gap-4 text-sw-body",children:[(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Site URL"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5 break-all",children:String(t.site_url||"—")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Library"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:String(t.library_name||t.library_id||"—")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:function(e){let t=ew(e);return t?1===t.length?"File":"Files":e.file_path?"File":"Folder"}(t)}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5 break-all",children:function(e){let t=ew(e);if(t){if(1===t.length){var s;let e=t[0],a=null!=(s=e.path)?s:e.name;if("string"==typeof a&&a)return a}return"".concat(t.length," files")}return String(e.file_path||e.folder_path||"Entire library")}(t)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Sync schedule"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5 capitalize",children:String(t.sync_schedule||"manual")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"File types"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:s})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Max file size"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:null!=t.max_file_size_mb?"".concat(t.max_file_size_mb," MB"):"—"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Last sync"}),(0,a.jsxs)("p",{className:"font-medium text-sw-text mt-0.5 flex items-center gap-1",children:[(0,a.jsx)(U.A,{size:12,className:"text-sw-text-muted"}),h.length>0?new Date(h[0].started_at).toLocaleString():"Never"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Created"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:new Date(o.created_at).toLocaleDateString()})]})]})]})})():(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(G.A,{size:16,className:"text-sw-primary-text"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"Configuration"})]}),(0,a.jsxs)("div",{className:"p-5 grid grid-cols-2 gap-4 text-sw-body",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Created"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:new Date(o.created_at).toLocaleDateString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Description"}),(0,a.jsx)("p",{className:"font-medium text-sw-text mt-0.5",children:o.description||"—"})]})]})]}),(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(N.A,{size:16,className:"text-sw-success-text"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"Governance & Compliance"})]}),(0,a.jsx)("div",{className:"p-5",children:(0,a.jsx)(S.pp,{icon:u.A,title:"No guardrail data yet",description:"Guardrail metrics will appear once workflows execute."})})]}),(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(H.A,{size:16,className:"text-sw-accent-memory-icon"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"Deployment History"})]}),(0,a.jsx)("div",{className:"p-5",children:(0,a.jsx)(S.pp,{icon:H.A,title:"No deployments yet",description:"Deployment history will appear here."})})]})]}),(0,a.jsxs)("div",{className:"col-span-2 space-y-6",children:[(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(W.A,{size:16,className:"text-sw-info-text"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"Execution History"}),h.length>0&&(0,a.jsxs)("span",{className:"sw-text-caption-muted ml-auto",children:[h.length," runs"]})]}),(0,a.jsx)("div",{className:"p-4",children:0===h.length?(0,a.jsx)(S.pp,{icon:W.A,title:"No executions yet",description:"Workflow runs will appear here."}):(0,a.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:h.slice(0,20).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-sw-md bg-sw-background border border-sw-border-subtle",children:[(0,a.jsx)("span",{className:(0,x.cn)("w-2 h-2 rounded-sw-full flex-shrink-0","completed"===e.status?"bg-sw-coverage-full":"running"===e.status?"bg-sw-info animate-pulse":"failed"===e.status?"bg-sw-error":"bg-sw-warning")}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sw-caption font-medium text-sw-text truncate",children:e.workflow_type}),(0,a.jsx)("span",{className:(0,x.cn)("text-sw-caption px-1.5 py-0.5 rounded-sw-sm font-medium capitalize","completed"===e.status?"bg-sw-coverage-full-bg text-sw-coverage-full-text":"running"===e.status?"bg-sw-info-bg text-sw-info-text":"failed"===e.status?"bg-sw-error/10 text-sw-error":"bg-sw-warning/10 text-sw-warning"),children:e.status})]}),(0,a.jsxs)("span",{className:"text-sw-caption text-sw-text-disabled",children:[eh(e.started_at),e.total_duration_ms?" \xb7 ".concat((e.total_duration_ms/1e3).toFixed(1),"s"):""]})]})]},e.execution_id))})})]}),g.length>0&&(0,a.jsxs)("div",{className:"rounded-sw-lg border border-sw-warning/30 bg-sw-surface",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-warning/20 flex items-center gap-2",children:[(0,a.jsx)(w.A,{size:16,className:"text-sw-warning"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"Pending Approvals"}),(0,a.jsx)(p.E,{variant:"warning",className:"ml-auto",children:g.length})]}),(0,a.jsx)("div",{className:"p-4 space-y-2",children:g.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-3 px-3 py-2.5 rounded-sw-md bg-sw-background border border-sw-border-subtle",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-sw-full bg-sw-warning mt-1.5 flex-shrink-0 animate-pulse"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-sw-caption font-medium text-sw-text",children:e.step_name}),(0,a.jsx)("p",{className:"sw-text-caption-muted line-clamp-2 mt-0.5",children:e.prompt}),(0,a.jsx)("span",{className:"text-sw-caption text-sw-text-disabled mt-1 block",children:eh(e.created_at)})]})]},e.id))})]}),(0,a.jsxs)("div",{className:"sw-card-lg",children:[(0,a.jsxs)("div",{className:"px-5 py-3 border-b border-sw-border flex items-center gap-2",children:[(0,a.jsx)(Z.A,{size:16,className:"text-sw-accent-memory-icon"}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text",children:"API Endpoints"})]}),(0,a.jsx)("div",{className:"p-4 space-y-2",children:P.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-sw-md bg-sw-background border border-sw-border-subtle group",children:[(0,a.jsx)("span",{className:(0,x.cn)("text-sw-caption font-bold px-1.5 py-0.5 rounded-sw-sm",eg[e.method]),children:e.method}),(0,a.jsx)("code",{className:"text-sw-caption text-sw-text font-mono flex-1 truncate",children:e.path}),(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-sw-full bg-sw-coverage-full",title:"live"}),(0,a.jsx)(B.$,{variant:"ghost",size:"sm",iconOnly:!0,onClick:()=>z(e.path),className:"opacity-0 group-hover:opacity-100",children:y===e.path?(0,a.jsx)(J.A,{size:12,className:"text-sw-success-text"}):(0,a.jsx)(Q.A,{size:12,className:"text-sw-text-muted"})})]},"".concat(e.method," ").concat(e.path)))})]})]}),(0,a.jsxs)("div",{className:"rounded-sw-lg border border-sw-error/30 bg-sw-surface p-4",children:[(0,a.jsx)("h4",{className:"text-sw-body font-medium text-sw-error mb-2",children:"Danger Zone"}),(0,a.jsx)("p",{className:"sw-text-caption-muted mb-3",children:"Permanently remove this app and all its configuration."}),(0,a.jsxs)(B.$,{variant:"secondary",size:"sm",className:"text-sw-error hover:opacity-80 border-sw-error/30 hover:border-sw-error/50",onClick:()=>_(o.application_id),children:[(0,a.jsx)(X.A,{size:14})," Delete App"]})]})]})]}),((null==(r=o.template_id)?void 0:r.includes("connector"))||(null==(c=o.template_id)?void 0:c.includes("sharepoint")))&&(0,a.jsx)(ed,{app:o,open:k,onClose:M,onSaved:E})]})},ef=e=>{var t;let{onNavigate:s,onBrowse:n,initialApps:i,hitlPending:r=[]}=e,{selectEntity:p,state:u}=(0,o.cq)(),{showToast:h}=(0,d.d)(),[w,g]=(0,l.useState)(null!=i?i:[]),[b,f]=(0,l.useState)(!i),[j,y]=(0,l.useState)(null),[v,N]=(0,l.useState)(null),[k,A]=(0,l.useState)(!1),[_,z]=(0,l.useState)([]),[C,M]=(0,l.useState)(!1),[L,E]=(0,l.useState)(null),[P,F]=(0,l.useState)(!1),[T,D]=(0,l.useState)(null),[I,V]=(0,l.useState)(null),$=(null==(t=u.active_entity)?void 0:t.type)==="APPLICATION"?u.active_entity.id:null,G=(0,l.useMemo)(()=>{var e;return null!=(e=w.find(e=>e.application_id===$))?e:null},[w,$]),H=(0,l.useCallback)(async()=>{try{f(!0),y(null);let e=await m.getApplications();g(e)}catch(e){y("Failed to load applications. Check your connection and try again.")}finally{f(!1)}},[]);(0,l.useEffect)(()=>{i||H()},[i,H]);let U=(0,l.useRef)(null);(0,l.useEffect)(()=>
1{if($&&$!==U.current){var e;U.current=$,N(null),z([]),A(!1),E(null),m.getApplicationMetrics($).then(N).catch(e=>{console.warn("[InstalledView] metrics unavailable",e),A(!0)}),m.getWfxExecutions($).then(z).catch(e=>{console.warn("[InstalledView] executions unavailable",e),A(!0)});let t=w.find(e=>e.application_id===$);(null==t||null==(e=t.template_id)?void 0:e.includes("sharepoint"))&&m.getConnectorStatus("sharepoint").then(e=>E(e.has_credentials)).catch(()=>E(!1))}},[$,w]);let W=(0,l.useCallback)(async e=>{try{await m.deleteApplication(e),g(t=>t.filter(t=>t.application_id!==e)),p("APPLICATION","","")}catch(e){h("Failed to delete app. Please try again.","error")}finally{V(null)}},[p,h]),K=(0,l.useCallback)(e=>{g(t=>t.map(t=>t.application_id===e.application_id?e:t))},[]),Z=(0,l.useCallback)(async e=>{var t;let s=null!=(t=e.config)?t:{},a="string"==typeof s.collection_id?s.collection_id:null;F(!0);try{if(!a)return void h("This app has no knowledge collection to sync","error");let{connectors:t}=await m.getCollectionConnectors(a),s=t.filter(e=>"sharepoint"===e.connector_id);if(0===s.length)return void h("No SharePoint sync is set up for this collection yet","error");await Promise.all(s.map(e=>m.triggerConnectorSync(e.binding_id,crypto.randomUUID()))),h(1===s.length?"Sync started":"".concat(s.length," syncs started"),"success"),m.getWfxExecutions(e.application_id).then(z).catch(()=>{})}catch(e){h(e instanceof Error?e.message:"Failed to trigger sync","error")}finally{F(!1)}},[h]),J=(0,l.useMemo)(()=>({total:w.length,published:w.filter(e=>"published"===e.status).length,draft:w.filter(e=>"draft"===e.status).length}),[w]);return G?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eb,{app:G,metrics:v,metricsError:k,executions:_,hitlPending:r,connectorHasCredentials:L,syncingConnector:P,copiedEndpoint:T,connectorConfigOpen:C,onBack:()=>p("APPLICATION","",""),onDelete:e=>V(e),onCopyEndpoint:e=>{navigator.clipboard.writeText(e).catch(()=>{}),D(e),setTimeout(()=>D(null),2e3)},onOpenConnectorConfig:()=>M(!0),onCloseConnectorConfig:()=>M(!1),onSyncNow:Z,onConnectorSaved:K}),(0,a.jsx)(R.T,{open:!!I,title:"Delete App",description:"This will permanently remove the app and all its configuration. This cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:()=>I&&W(I),onCancel:()=>V(null)})]}):(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sw-caption font-medium px-2.5 py-1 rounded-sw-full bg-sw-surface border border-sw-border text-sw-text",children:[(0,a.jsx)(c.A,{size:12})," ",J.total," total"]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sw-caption font-medium px-2.5 py-1 rounded-sw-full bg-sw-coverage-full-bg border border-sw-border text-sw-coverage-full-text",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-sw-full bg-sw-coverage-full inline-block"})," ",J.published," published"]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sw-caption font-medium px-2.5 py-1 rounded-sw-full bg-sw-coverage-partial-bg border border-sw-border text-sw-coverage-partial-text",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-sw-full bg-sw-coverage-partial inline-block"})," ",J.draft," draft"]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(B.$,{variant:"primary",size:"sm",onClick:n,children:[(0,a.jsx)(O.A,{size:14})," Browse Marketplace"]})})]}),b?(0,a.jsx)("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(e=>(0,a.jsx)(S.u4,{},e))}):j&&0===w.length?(0,a.jsx)(S.pp,{icon:c.A,title:"Unable to load applications",description:j,ctaLabel:"Try again",onCtaClick:H}):0===w.length?(0,a.jsx)(S.pp,{icon:c.A,title:"No apps installed yet",description:"Browse the app catalog to extend your workspace.",ctaLabel:"Browse Marketplace",onCtaClick:n}):(0,a.jsx)("div",{className:"grid grid-cols-3 gap-4",children:w.map(e=>(0,a.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>s("APPLICATION",e.application_id,e.name),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(" "===t.key&&t.preventDefault(),s("APPLICATION",e.application_id,e.name))},className:"group sw-card-lg overflow-hidden hover:shadow-sw-lg hover:-translate-y-0.5 hover:border-sw-primary/40 transition-all duration-200 cursor-pointer",children:[(0,a.jsx)("div",{className:"h-1.5 bg-gradient-to-r from-violet-500 to-purple-600"}),(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:(0,x.cn)("w-2 h-2 rounded-sw-full flex-shrink-0","published"===e.status?"bg-sw-coverage-full animate-pulse":"draft"===e.status?"bg-sw-coverage-partial":"bg-sw-text-disabled")}),(0,a.jsx)("h3",{className:"text-sw-body font-semibold text-sw-text group-hover:text-sw-primary-text transition-colors",children:e.name})]}),(0,a.jsx)("span",{className:(0,x.cn)("text-sw-caption px-1.5 py-0.5 rounded-sw-full font-medium capitalize","published"===e.status?"bg-sw-coverage-full-bg text-sw-coverage-full-text":"bg-sw-coverage-partial-bg text-sw-coverage-partial-text"),children:e.status})]}),e.description&&(0,a.jsx)("p",{className:"sw-text-caption-muted line-clamp-2 mb-3",children:e.description}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 text-sw-caption text-sw-text-disabled",children:[(0,a.jsxs)("span",{className:"font-mono",children:["v",e.version]}),(0,a.jsx)("span",{children:eh(e.updated_at)})]}),(0,a.jsxs)("span",{className:"text-sw-caption text-sw-primary-text group-hover:underline flex items-center gap-0.5",children:["Open ",(0,a.jsx)(q.A,{size:10})]})]})]})]},e.application_id))}),(0,a.jsx)(R.T,{open:!!I,title:"Delete App",description:"This will permanently remove the app and all its configuration. This cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:()=>I&&W(I),onCancel:()=>V(null)})]})},ej=e=>{let{initialApps:t}=e,{selectEntity:s}=(0,o.cq)(),{showToast:n}=(0,d.d)(),[u,h]=(0,l.useState)("marketplace"),[w,g]=(0,l.useState)(null!=t?t:[]),[b,f]=(0,l.useState)([]);(0,l.useEffect)(()=>{m.getWfxHitlPending().then(f).catch(()=>{})},[]);let j=(0,l.useMemo)(()=>new Set(w.map(e=>e.template_id).filter(e=>null!=e)),[w]),y=(0,l.useCallback)(async(e,t)=>{try{let t=await m.createApplication(e,e,void 0,void 0);g(e=>[t,...e]),h("installed")}catch(e){n("Failed to install app. Please try again.","error")}},[n]);return(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto bg-sw-background",children:[(0,a.jsx)("div",{className:"sticky top-0 z-10 bg-sw-background/95 backdrop-blur-sm border-b border-sw-border",children:(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6",children:[(0,a.jsx)("div",{className:"flex items-center justify-between pt-5 pb-3",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"w-9 h-9 rounded-sw-lg bg-gradient-to-br from-violet-500 to-purple-600 flex items-center justify-center shadow-sw-md shadow-violet-500/20",children:(0,a.jsx)(i,{size:18,className:"text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sw-h3 font-bold text-sw-text leading-tight",children:"App Mar
1ketplace"}),(0,a.jsx)("p",{className:"sw-text-caption-muted",children:"Add AI-powered apps to your workspace"})]})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-1 pb-0",children:[(0,a.jsxs)("button",{onClick:()=>h("marketplace"),className:(0,x.cn)("flex items-center gap-1.5 px-4 py-2 text-sw-body font-medium border-b-2 transition-colors","marketplace"===u?"border-sw-primary text-sw-primary":"border-transparent text-sw-text-muted hover:text-sw-text"),children:[(0,a.jsx)(r.A,{size:14})," Marketplace"]}),(0,a.jsxs)("button",{onClick:()=>h("installed"),className:(0,x.cn)("flex items-center gap-1.5 px-4 py-2 text-sw-body font-medium border-b-2 transition-colors","installed"===u?"border-sw-primary text-sw-primary":"border-transparent text-sw-text-muted hover:text-sw-text"),children:[(0,a.jsx)(c.A,{size:14})," Installed",w.length>0&&(0,a.jsx)("span",{className:"ml-1 text-sw-caption font-bold px-1.5 py-0.5 rounded-sw-full bg-sw-primary/10 text-sw-primary-text",children:w.length}),b.length>0&&(0,a.jsxs)(p.E,{variant:"warning",children:[b.length," pending"]})]})]})]})}),"marketplace"===u&&(0,a.jsx)(V,{onInstall:y,installedIds:j}),"installed"===u&&(0,a.jsx)(ef,{onNavigate:s,onBrowse:()=>h("marketplace"),initialApps:w,hitlPending:b})]})}},55275:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]])},61194:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("square-check-big",[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},66955:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(5121).A)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]])}}]);

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.