PageSourceSearch

https://fridayreport.ai/assets/Templates-CEJrwzAF.js

js fridayreport.ai collected 2026-10-05 13:58:32 UTC 29,500 bytes, 1 lines download raw bytes

1import{u as vs,a as _,b as g,j as e}from"./vendor-query-CS-Sb1c4.js";import{e as bs,a as n}from"./vendor-router-CZSztoNj.js";import{u as Cs,b as Ss,a as x,y as Ts,c as o,B as y,C as w,m as ee,o as se,p as N,v as Ne}from"./index-D-3pbJbQ.js";import{f as ks}from"./workingDays-Ck8Jq3wT.js";import{I as C}from"./input-BvtS77xI.js";import{L as u}from"./label-Umko-O4j.js";import{T as W}from"./textarea-CZuGeFTv.js";import{D as L,a as U,d as z,b as $,c as X,e as q}from"./dialog-BO586DMh.js";import{D as Ps,a as Ds,b as Fs,e as S}from"./dropdown-menu-DkkYrLDC.js";import{S as Qe,a as _e,b as We,c as Xe,d as Je}from"./select--txDPtWB.js";import{T as Es,a as Is,b as Ze,c as J,d as Ms,e as Z}from"./table-CVKQVNVc.js";import{T as je,a as fe,b as T,c as A}from"./tabs-DW84ybwb.js";import{B as h}from"./badge-Dc91IPO4.js";import{S as Ls}from"./separator-DTAapM0F.js";import{T as Us}from"./TemplateGanttPreview-B-uQwdYv.js";import{u as zs}from"./usePermissions-BJooOnAY.js";import{A as $s}from"./agentTemplates-BKR7OPRx.js";import{d$ as qs,dr as As,ds as Bs,dt as Rs,dl as Os,d4 as Vs,Z as as,du as Ks,A as Gs,x as we,an as Ye,u as es,bI as Hs,dp as ss,aN as Qs,F as Y,bt as ge,cC as ve,w as be,K as B,J as _s,c7 as Ws,y as Xs,R as Js,a$ as Zs,dW as Ys,bB as et,ch as st,dz as tt,e0 as at,e1 as rt,aT as it,S as nt,n as rs,B as lt,e2 as ot,e3 as ct,t as dt,bv as mt,cz as pt,cB as ut,cw as ht,br as xt,e as jt,bD as ft,bu as gt,cV as yt,h as wt,av as Nt,aS as vt,b7 as bt,cW as Ct,g as St,a0 as Tt}from"./vendor-icons-B_ClLdji.js";import"./vendor-ui-Cz1dd9Yr.js";import"./vendor-motion-D0xMKZ2p.js";import"./vendor-dates-WZsEYwlI.js";const ts={Code:ht,ListChecks:ut,Smartphone:pt,Cloud:mt,Layers:dt,Server:ct,Network:ot,Mail:be,Building2:lt,Users:rs,ShieldAlert:nt,FileCheck:it,BadgeCheck:rt,LifeBuoy:at,Headphones:tt,Globe:st,Database:et,Brain:Ys,FileText:B,FolderKanban:Y},ye=[{key:"it",label:"Information Technology",icon:qs,comingSoon:!1},{key:"healthcare",label:"Healthcare",icon:As,comingSoon:!1},{key:"financial-services",label:"Financial Services",icon:Bs,comingSoon:!1},{key:"manufacturing",label:"Manufacturing",icon:Rs,comingSoon:!1},{key:"industrial-automation",label:"Industrial Automation",icon:Os,comingSoon:!1},{key:"capital-projects",label:"Capital Projects",icon:Vs,comingSoon:!1},{key:"energy",label:"Energy & Utilities",icon:as,comingSoon:!1},{key:"government",label:"Government & Public Sector",icon:Ks,comingSoon:!1}];function is(a){return a&&ts[a]?ts[a]:B}function ns(a){return a==null?"—":a<7?`${a} days`:a<30?`${Math.round(a/7)} weeks`:a<365?`${Math.round(a/30)} months`:`${(a/365).toFixed(1)} years`}function Jt(){const{currentOrganization:a}=Cs(),{toast:l}=Ss(),[,j]=bs(),d=vs(),k=n.useRef(null),R=n.useRef(null),{can:ls}=zs(),Ce=ls("custom_agents.create"),[te,os]=n.useState("library"),[P,cs]=n.useState("it"),[ds,v]=n.useState(!1),[Se,D]=n.useState(!1),[Te,b]=n.useState(!1),[ms,O]=n.useState(!1),[ps,V]=n.useState(!1),[m,f]=n.useState(null),[i,ae]=n.useState(null),[K,ke]=n.useState(""),[Pe,De]=n.useState(""),[re,Fe]=n.useState(null),[G,Ee]=n.useState(""),[Ie,Me]=n.useState(""),[H,Le]=n.useState(""),[Q,F]=n.useState(""),[Ue,E]=n.useState(""),[ze,$e]=n.useState(""),[ie,qe]=n.useState(""),[ne,Ae]=n.useState(""),[Be,Re]=n.useState(""),c=a?.id,{data:le=[],isLoading:us}=_({queryKey:["/api/project-templates","system",P],queryFn:async()=>(await x("GET",`/api/project-templates?scope=system&industry=${encodeURIComponent(P)}`)).json(),enabled:te==="library"&&!ye.find(s=>s.key===P)?.comingSoon}),{data:Oe=[],isLoading:hs}=_({queryKey:["/api/project-templates","org",c],queryFn:async()=>(await x("GET",`/api/project-templates?scope=org&organizationId=${c}`)).json(),enabled:!!c&&te==="my-templates"}),{data:xs=[]}=_({queryKey:["/api/projects",c],queryFn:async()=>(await x("GET",`/api/projects?organizationId=${c}`)).json(),enabled:!!c&&Se}),{data:js=[]}=_({queryKey:["/api/portfolios",c],queryFn:async()=>(await x("GET",`/api/portfolios?organizationId=${c}`)).json(),enabled:!!c&&Te}),oe=g({mutationFn:async()=>{if(!re||!K||!c)throw new Error("Missing required fields");const s=new FormData;s.append("file",re),s.append("name",K),s.append("description",Pe),s.append("organizationId",String(c));const t=await fetch("/api/project-templates/from-mpp",{method:"POST",body:s,credentials:"include"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.message||"Upload failed")}return t.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),v(!1),ue(),l({title:"Template created",description:"Template has been created from the uploaded file."})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),ce=g({mutationFn:async()=>
1{if(!H||!G)throw new Error("Missing required fields");const s=await x("POST","/api/project-templates/from-project",{projectId:Number(H),name:G,description:Ie});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.message||"Failed to create template")}return s.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),D(!1),he(),l({title:"Template created",description:"Template has been created from the project."})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),de=g({mutationFn:async()=>{if(!m||!Q)throw new Error("Missing required fields");const s={name:Q,description:Ue,startDate:ze||void 0,portfolioId:ie?Number(ie):void 0};if(m.isSystem){if(!c)throw new Error("No organization selected");s.organizationId=c}const t=await x("POST",`/api/project-templates/${m.id}/create-project`,s);if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.message||"Failed to create project")}return t.json()},onSuccess:s=>{d.invalidateQueries({queryKey:["/api/projects"]}),b(!1),xe();const t=s?.project?.id;l({title:"Project created",description:s.message||"Project has been created from the template.",action:t?e.jsx(Ts,{altText:"Open project",onClick:()=>j(`/projects/${t}`),"data-testid":"toast-action-open-created-project",children:"Open"}):void 0})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),me=g({mutationFn:async()=>{if(!m)throw new Error("No template selected");const s=await x("PUT",`/api/project-templates/${m.id}`,{name:ne,description:Be});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.message||"Failed to update template")}return s.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),O(!1),l({title:"Template updated"})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),pe=g({mutationFn:async()=>{if(!m)throw new Error("No template selected");const s=await x("DELETE",`/api/project-templates/${m.id}`);if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.message||"Failed to delete template")}return s.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),V(!1),f(null),i&&i.id===m?.id&&ae(null),l({title:"Template deleted"})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),fs=g({mutationFn:async s=>{const t={};if(s.isSystem){if(!c)throw new Error("No organization selected");t.organizationId=c}const r=await x("POST",`/api/project-templates/${s.id}/duplicate`,t);if(!r.ok){const p=await r.json().catch(()=>({}));throw new Error(p.message||"Failed to duplicate template")}return r.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),l({title:"Saved to your templates",description:"Find the editable copy under My Templates."})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),Ve=g({mutationFn:async({templateId:s,file:t})=>{const r=new FormData;r.append("file",t);const p=await fetch(`/api/project-templates/${s}/reimport`,{method:"POST",body:r,credentials:"include"});if(!p.ok){const M=await p.json().catch(()=>({}));throw new Error(M.message||"Re-import failed")}return p.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["/api/project-templates"]}),l({title:"Template updated",description:"Template has been re-imported with the new file."})},onError:s=>{l({title:"Error",description:s.message,variant:"destructive"})}}),ue=()=>{ke(""),De(""),Fe(null),k.current&&(k.current.value="")},he=()=>{Ee(""),Me(""),Le("")},xe=()=>{F(""),E(""),$e(""),qe("")},Ke=n.useCallback(async s=>{try{const r=await(await x("GET",`/api/project-templates/${s.id}`)).json();ae(r)}catch{l({title:"Error",description:"Failed to load template details",variant:"destructive"})}},[l]),Ge=n.useCallback(async s=>{try{const t=await fetch(`/api/project-templates/${s.id}/download`,{credentials:"include"});if(!t.ok)throw new Error("Download failed");const r=await t.blob(),p=URL.createObjectURL(r),M=document.createElement("a");M.href=p,M.download=s.originalFileName||"template.mpp",M.click(),URL.revokeObjectURL(p)}catch{l({title:"Error",description:"Failed to download file",variant:"destructive"})}},[l]),gs=n.useCallback(s=>{f(s),setTimeout(()=>R.current?.click(),100)},[]),ys=n.useCallback(s=>{if(!c)return;
1const t={organizationId:c,type:s.type,name:s.name,description:s.description,icon:s.icon,systemPrompt:s.systemPrompt,model:s.model,dataScope:s.dataScope,allowedTools:[...s.allowedTools],visibility:"private",enabled:!0,scheduleDay:s.scheduleDay??1,scheduleTime:s.scheduleTime??"09:00",timezone:s.timezone??"America/New_York",recipientEmails:[],emailSubject:"",memberIds:[],_templateSlug:s.slug};try{sessionStorage.setItem("agents:templateDraft",JSON.stringify(t))}catch{}j("/agents")},[c,j]),ws=n.useCallback(s=>{const t=s.target.files?.[0];t&&m&&Ve.mutate({templateId:m.id,file:t}),R.current&&(R.current.value="")},[m,Ve]),Ns=n.useMemo(()=>{const s=new Map;for(const t of le){const r=t.category||"Uncategorized";s.has(r)||s.set(r,[]),s.get(r).push(t)}return Array.from(s.entries()).sort(([t],[r])=>t.localeCompare(r))},[le]),I=ye.find(s=>s.key===P),He=e.jsx(L,{open:Te,onOpenChange:s=>{b(s),s||xe()},children:e.jsxs(U,{children:[e.jsxs(z,{children:[e.jsx($,{children:"Create Project from Template"}),e.jsxs(X,{children:['Create a new project using "',m?.name,'" as a template.']})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(u,{htmlFor:"new-project-name",children:"Project Name"}),e.jsx(C,{id:"new-project-name",value:Q,onChange:s=>F(s.target.value),placeholder:"Enter project name"})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"new-project-desc",children:"Description (optional)"}),e.jsx(W,{id:"new-project-desc",value:Ue,onChange:s=>E(s.target.value),placeholder:"Describe this project",rows:3})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"new-project-portfolio",children:"Portfolio (optional)"}),e.jsxs(Qe,{value:ie,onValueChange:qe,children:[e.jsx(_e,{children:e.jsx(We,{placeholder:"Select a portfolio"})}),e.jsx(Xe,{children:js.map(s=>e.jsx(Je,{value:String(s.id),children:s.name},s.id))})]})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"new-project-start",children:"Start Date (optional)"}),e.jsx(C,{id:"new-project-start",type:"date",value:ze,onChange:s=>$e(s.target.value)}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"If set, task dates will be adjusted relative to this start date."})]})]}),e.jsxs(q,{children:[e.jsx(o,{variant:"outline",onClick:()=>{b(!1),xe()},children:"Cancel"}),e.jsxs(o,{onClick:()=>de.mutate(),disabled:!Q||de.isPending,children:[de.isPending&&e.jsx(y,{size:"sm",className:"mr-2"}),"Create Project"]})]})]})});if(!c)return e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Please select an organization to manage templates."})});if(i){const s=is(i.icon),t=i.isSystem;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(o,{variant:"ghost",size:"sm",onClick:()=>ae(null),"data-testid":"button-back-templates",children:[e.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(s,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold",children:i.name}),(i.summary||i.description)&&e.jsx("p",{className:"mt-1 text-muted-foreground",children:i.summary||i.description}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t&&e.jsxs(h,{variant:"default",className:"gap-1",children:[e.jsx(we,{className:"h-3 w-3"}),"System template"]}),i.category&&e.jsx(h,{variant:"outline",children:i.category}),!t&&e.jsx(h,{variant:i.sourceType==="mpp"?"default":"secondary",children:i.sourceType==="mpp"?"MPP Import":i.sourceType==="system-copy"?"Copied from library":"From Project"}),i.originalFileName&&e.jsx("span",{className:"text-sm text-muted-foreground",children:i.originalFileName}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i.itemCount," items · ",i.milestoneCount," milestones"]}),i.estimatedDurationDays!=null&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["~",ns(i.estimatedDurationDays)]})]})]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[i.storedFileUrl&&!t&&e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ge(i),"data-testid":"button-download-template",children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"}),"Download File"]}),e.jsxs(o,{size:"sm",onClick:()=>{f(i),F(""),E(i.summary||i.description||""),b(!0)},"data-testid":"button-use-template",children:[e.jsx(es,{className:"mr-2 h-4 w-4"}),"Use this template"]})]})]}),e.jsx(Ls,{}),e.jsxs(w,{children:[e.jsx(ee,{children:e.jsxs(se,{className:"text-lg",children:["Template Items (",i.items.length,")"]})}),e.jsx(N,{children:i.items.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No items in this template."}):e.jsxs(je,{defaultValue:"timeline",className:"space-y-4",children:[e.jsxs(fe,{children:[e.jsxs(T,{value:"timeline","data-testid":"tab-template-timeline",children:[e.jsx(Hs,{className:"mr-2 h-4 w-4"}),"Timeline"]}),e.jsxs(T,{value:"list","data-testid":"tab-template-list",children:[e.jsx(ss,{className:"mr-2 h-4 w-4"}),"Item list"]})]}),e.jsx(A,{value:"timeline",className:"mt-0",children:e.jsx(Us,{items:i.items})}),e.jsx(A,{value:"list",className:"mt-0",children:e.jsx("div",{className:"rounded-md border max-h-[600px] overflow-auto",children:e.jsxs(Es,{children:[e.jsx(Is,{children:e.jsxs(Ze,{children:[e.jsx(J,{className:"w-16",children:"WBS"}),e.jsx(J,{children:"Name"}),e.jsx(J,{className:"w-24",children:"Duration"}),e.jsx(J,{className:"w-20",children:"Type"})]})}),e.jsx(Ms,{children:i.items.map(r=>e.jsxs(Ze,{children:[e.jsx(Z,{className:"font-mono text-xs text-muted-foreground",children:r.wbs||"-"}),e.jsx(Z,{children:e.jsxs("div",{style:{paddingLeft:`${((r.outlineLevel||1)-1)*2
10}px`},className:"flex items-center gap-2",children:[r.isSummary?e.jsx(ss,{className:"h-4 w-4 text-blue-500"}):r.isMilestone?e.jsx(Qs,{className:"h-4 w-4 text-amber-500"}):null,e.jsx("span",{className:r.isSummary?"font-semibold":"",children:r.name})]})}),e.jsx(Z,{className:"text-sm text-muted-foreground",children:r.duration||(r.durationDays!=null?ks(Number(r.durationDays)):"-")}),e.jsx(Z,{children:r.isMilestone?e.jsx(h,{variant:"outline",className:"text-xs",children:"Milestone"}):r.isSummary?e.jsx(h,{variant:"outline",className:"text-xs",children:"Summary"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Task"})})]},r.id))})]})})})]})})]})]}),He]})}return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Project Templates"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse a curated library of project templates, or save your own from existing work."})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsxs(o,{variant:"outline",onClick:()=>D(!0),"data-testid":"button-from-project",children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),"From Project"]}),e.jsxs(o,{onClick:()=>v(!0),"data-testid":"button-upload-file",children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"Upload File"]})]})]}),e.jsxs(je,{value:te,onValueChange:s=>os(s),className:"space-y-6",children:[e.jsxs(fe,{children:[e.jsxs(T,{value:"library","data-testid":"tab-library",children:[e.jsx(we,{className:"mr-2 h-4 w-4"}),"Browse Library"]}),e.jsxs(T,{value:"my-templates","data-testid":"tab-my-templates",children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),"My Templates"]}),Ce&&e.jsxs(T,{value:"agent-templates","data-testid":"tab-agent-templates",children:[e.jsx(ve,{className:"mr-2 h-4 w-4"}),"Agent Templates"]})]}),e.jsxs(A,{value:"library",className:"space-y-6",children:[e.jsx(je,{value:P,onValueChange:cs,children:e.jsx(fe,{className:"flex w-full flex-wrap h-auto justify-start gap-1",children:ye.map(s=>{const t=s.icon;return e.jsxs(T,{value:s.key,className:"gap-2","data-testid":`tab-industry-${s.key}`,children:[e.jsx(t,{className:"h-4 w-4"}),s.label,s.comingSoon&&e.jsx(h,{variant:"secondary",className:"ml-1 text-[10px] px-1 py-0",children:"Soon"})]},s.key)})})}),I?.comingSoon?e.jsx(w,{className:"py-16",children:e.jsxs(N,{className:"flex flex-col items-center justify-center text-center",children:[e.jsx(I.icon,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsxs("h3",{className:"text-lg font-semibold",children:[I.label," templates — coming soon"]}),e.jsxs("p",{className:"mt-1 max-w-md text-muted-foreground",children:["We're building a curated set of templates for ",I.label.toLowerCase(),". In the meantime, you can upload your own MPP, XML, or CSV file or save an existing project."]}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(o,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:`mailto:[email protected]?subject=${encodeURIComponent("Template request: "+I.label)}`,children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),"Request a template"]})}),e.jsxs(o,{size:"sm",onClick:()=>v(!0),children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"Upload your own"]})]})]})}):us?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(y,{size:"sm",className:"h-8 w-8"})}):le.length===0?e.jsx(w,{className:"py-16",children:e.jsxs(N,{className:"flex flex-col items-center justify-center text-center",children:[e.jsx(B,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No templates available yet"})]})}):e.jsx("div",{className:"space-y-8",children:Ns.map(([s,t])=>e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(r=>e.jsx(Dt,{template:r,onView:Ke,onUse:p=>{f(p),F(""),E(p.summary||p.description||""),b(!0)}},r.id))})]},s))})]}),e.jsx(A,{value:"my-templates",className:"space-y-6",children:hs?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(y,{size:"sm",className:"h-8 w-8"})}):Oe.length===0?e.jsx(w,{className:"py-16",children:e.jsxs(N,{className:"flex flex-col items-center justify-center text-center",children:[e.jsx(B,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No templates yet"}),e.jsx("p",{className:"mt-1 text-muted-foreground max-w-sm",children:"Upload an MPP/XML/CSV file or save an existing project as a template to get started."}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs(o,{variant:"outline",onClick:()=>D(!0),children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),"From Project"]}),e.jsxs(o,{onClick:()=>v(!0),children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"Upload File"]})]})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:Oe.map(s=>e.jsxs(w,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>Ke(s),"data-testid":`card-template-${s.id}`,children:[e.jsx(ee,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(se,{className:"text-base truncate",children:s.name}),s.description&&e.jsx(Ne,{className:"mt-1 line-clamp-2",children:s.description})]}),e.jsxs(Ps,{children:[e.jsx(Ds,{asChild:!0,onClick:t=>t.stopPropagation(),children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:e.jsx(_s,{className:"h-4 w-4"})})}),e.jsxs(Fs,{align:"end",onClick:t=>t.stopPropagation(),children:[e.jsxs(S,{onClick:()=>{f(s),F(""),E(s.description||""),b(!0)},children:[e.jsx(es,{className:"mr-2 h-4 w-4"}),"Use this template"]}),e.jsxs(S,{onClick:()=>{f(s),Ae(s.name),Re(s.description||""),O(!0)},children:[e.jsx(Ws,{className:"mr-2 h-4 w-4"}),"Edit"]}),e.jsxs(S,{onClick:()=>fs.mutate(s),children:[e.jsx(Xs,{className:"mr-2 h-4 w-4"}),"Duplicate"]}),s.storedFileUrl&&e.jsxs(e.Fragment,{children:[e.jsxs(S,{onClick:()=>Ge(s),children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"}),"Download File"]}),e.jsxs(S,{onClick:()=>gs(s),children:[e.jsx(Js,{className:"mr-2 h-4 w-4"}),"Re-import File"]})]}),e.jsxs(S,{className:"text-destructive",onClick:()=>{f(s),V(!0)},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})]})}),e.jsxs(N,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsx(h,{variant:s.sourceType==="mpp"?"default":"secondary",className:"text-xs",children:s.sourceType==="mpp"?"MPP":s.sourceType==="system-copy"?"From Library":"Project"}),e.jsxs("span",{children:[s.itemCount," tasks"]}),s.milestoneCount>0&&e.jsxs("span",{children:[s.milestoneCount," milestones"]})]}),s.originalFileName&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground truncate",children:s.originalFileName}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Created ",new Date(s.createdAt).toLocaleDateString()]})]})]},s.id))})}),Ce&&e.jsxs(A,{value:"agent-templates",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Agent Templates"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Spin up a Custom AI Agent from a curated starter. Use template opens the agent editor pre-filled — review the prompt, scope, and recipients, then save to create a normal agent."})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:$s.map(s=>e.jsx(Pt,{template:s,onUse:()=>ys(s)},s.slug))})]})]}),e.jsx("input",{ref:R,type:"file",accept:".mpp,.xml,.csv",className:"hidden",onChange:ws}),e.jsx(L,{open:ds,onOpenChange:s=>{v(s),s||ue()},children:e.jsxs(U,{children:[e.jsxs(z,{children:[e.jsx($,{children:"Upload File as Template"}),e.jsx(X,{children:"Upload an MPP, XML, or CSV file to create a new project template."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(u,{htmlFor:"template-name",children:"Template Name"}),e.jsx(C,{id:"template-name",value:K,onChange:s=>ke(s.target.value),placeholder:"Enter template name"})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"template-desc",children:"Description (optional)"}),e.jsx(W,{id:"template-desc",value:Pe,onChange:s=>De(s.target.value),placeholder:"Describe this template",rows:3})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"template-file",children:"File"}),e.jsx(C,{ref:k,id:"template-file",type:"file",accept:".mpp,.xml,.csv",onChange:s=>Fe(s.target.files?.[0]||null)}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Supported formats: MPP, 
1XML (MSPDI), CSV"})]})]}),e.jsxs(q,{children:[e.jsx(o,{variant:"outline",onClick:()=>{v(!1),ue()},children:"Cancel"}),e.jsxs(o,{onClick:()=>oe.mutate(),disabled:!re||!K||oe.isPending,children:[oe.isPending&&e.jsx(y,{size:"sm",className:"mr-2"}),"Upload & Create"]})]})]})}),e.jsx(L,{open:Se,onOpenChange:s=>{D(s),s||he()},children:e.jsxs(U,{children:[e.jsxs(z,{children:[e.jsx($,{children:"Create Template from Project"}),e.jsx(X,{children:"Save an existing project's structure as a reusable template."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(u,{htmlFor:"from-project-name",children:"Template Name"}),e.jsx(C,{id:"from-project-name",value:G,onChange:s=>Ee(s.target.value),placeholder:"Enter template name"})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"from-project-desc",children:"Description (optional)"}),e.jsx(W,{id:"from-project-desc",value:Ie,onChange:s=>Me(s.target.value),placeholder:"Describe this template",rows:3})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"source-project",children:"Source Project"}),e.jsxs(Qe,{value:H,onValueChange:Le,children:[e.jsx(_e,{children:e.jsx(We,{placeholder:"Select a project"})}),e.jsx(Xe,{children:xs.map(s=>e.jsx(Je,{value:String(s.id),children:s.name},s.id))})]})]})]}),e.jsxs(q,{children:[e.jsx(o,{variant:"outline",onClick:()=>{D(!1),he()},children:"Cancel"}),e.jsxs(o,{onClick:()=>ce.mutate(),disabled:!H||!G||ce.isPending,children:[ce.isPending&&e.jsx(y,{size:"sm",className:"mr-2"}),"Create Template"]})]})]})}),He,e.jsx(L,{open:ms,onOpenChange:O,children:e.jsxs(U,{children:[e.jsx(z,{children:e.jsx($,{children:"Edit Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(u,{htmlFor:"edit-name",children:"Name"}),e.jsx(C,{id:"edit-name",value:ne,onChange:s=>Ae(s.target.value)})]}),e.jsxs("div",{children:[e.jsx(u,{htmlFor:"edit-desc",children:"Description"}),e.jsx(W,{id:"edit-desc",value:Be,onChange:s=>Re(s.target.value),rows:3})]})]}),e.jsxs(q,{children:[e.jsx(o,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(o,{onClick:()=>me.mutate(),disabled:!ne||me.isPending,children:[me.isPending&&e.jsx(y,{size:"sm",className:"mr-2"}),"Save"]})]})]})}),e.jsx(L,{open:ps,onOpenChange:V,children:e.jsxs(U,{children:[e.jsxs(z,{children:[e.jsx($,{children:"Delete Template"}),e.jsxs(X,{children:['Are you sure you want to delete "',m?.name,'"? This will also delete the stored file. This action cannot be undone.']})]}),e.jsxs(q,{children:[e.jsx(o,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),e.jsxs(o,{variant:"destructive",onClick:()=>pe.mutate(),disabled:pe.isPending,children:[pe.isPending&&e.jsx(y,{size:"sm",className:"mr-2"}),"Delete"]})]})]})})]})}const kt={Bot:ve,Sparkles:we,BrainCircuit:Ct,Bookmark:bt,ClipboardList:vt,FileText:B,BarChart3:Nt,Calendar:wt,Users:rs,Mail:be,Wand2:yt,Rocket:gt,ShieldCheck:ft,Lightbulb:jt,Zap:as};function Pt({template:a,onUse:l}){const j=kt[a.icon]??ve,d=a.type==="scheduled";return e.jsxs(w,{className:"flex h-full flex-col transition-shadow hover:shadow-md","data-testid":`card-agent-template-${a.slug}`,children:[e.jsx(ee,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(j,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(se,{className:"text-base leading-tight",children:a.name}),e.jsx(Ne,{className:"mt-1 line-clamp-2",children:a.tagline})]})]})}),e.jsxs(N,{className:"flex flex-1 flex-col justify-between gap-3 pt-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(h,{variant:d?"default":"secondary",className:"gap-1 text-[10px]",children:[d?e.jsx(St,{className:"h-3 w-3"}):e.jsx(Tt,{className:"h-3 w-3"}),d?"Scheduled":"Chat"]}),e.jsx(h,{variant:"outline",className:"text-[10px]",children:a.model})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:a.description})]}),e.jsx(o,{size:"sm",className:"w-full",onClick:l,"data-testid":`button-use-agent-template-${a.slug}`,children:"Use template"})]})]})}function Dt({template:a,onView:l,onUse:j}){const d=is(a.icon);return e.jsxs(w,{className:"flex h-full cursor-pointer flex-col transition-shadow hover:shadow-md",onClick:()=>l(a),"data-testid":`card-system-template-${a.slug||a.id}`,children:[e.jsx(ee,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(d,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(se,{className:"text-base leading-tight",children:a.name}),a.summary&&e.jsx(Ne,{className:"mt-1 line-clamp-2",children:a.summary})]})]})}),e.jsxs(N,{className:"flex flex-1 flex-col justify-between gap-3 pt-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(h,{variant:"default",className:"gap-1 text-[10px]",children:[e.jsx(xt,{className:"h-3 w-3"}),"System"]}),a.category&&e.jsx(h,{variant:"outline",className:"text-[10px]",children:a.category})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[a.itemCount," items"]}),a.milestoneCount>0&&e.jsxs("span",{children:[a.milestoneCount," milestones"]}),a.estimatedDurationDays!=null&&e.jsxs("span",{children:["~",ns(a.estimatedDurationDays)]})]}),e.jsx("div",{className:"pt-1",children:e.jsx(o,{size:"sm",className:"w-full",onClick:k=>{k.stopPropagation(),j(a)},"data-testid":`button-use-${a.slug||a.id}`,children:"Use this template"})})]})]})}export{Jt as default};

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.