@tickernelz/paperclip-pro-ui 2026.928.0 → 2026.928.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Ll=Object.defineProperty;var a=(e,t)=>Ll(e,"name",{value:t,configurable:!0});import{i as Js}from"./rolldown-runtime-ZpX3ckPj.js";import{$n as Wl,Ar as Ul,Cr as Po,Dr as Ia,Er as Mt,Fr as Fl,I as Kl,Ir as zl,Lr as ql,M as $o,Mr as Vl,O as Bo,Or as Gl,Pn as is,Pr as Zs,S as z,Sr as Ca,Tr as Sa,U as ea,X as Lo,Xn as Le,Y as we,_r as Na,a as Hl,ar as Ql,br as ta,c as Yl,cr as Xl,dr as Jl,fr as Zl,i as ec,ir as tc,jr as nc,kr as Cs,l as na,lr as rc,m as sc,mr as ac,nr as Ce,o as oc,or as _a,pr as Wo,r as ic,s as lc,sr as cc,t as et,ur as uc,vr as Ve,wr as Ea,xr as dc,yr as fc}from"./createLucideIcon-r3v6fbGz.js";import{B as Gt,W as Rn,X as fr,Y as Vr,Z as pc,b as Uo,o as Fo,t as Ht,w as Ko}from"./router-DyZkoSkG.js";import{Q as Fr,s as Ma,tt as mc}from"./mention-chips-DXumPrOR.js";import{S as Aa,l as ls}from"./zap-P-cXfK28.js";import{d as dn,p as hc}from"./MarkdownEditor-Pip4OXiJ.js";import{b as gc,v as xc,y as bc}from"./sheet-DeCxNmfl.js";import{r as Gr,t as Ra}from"./AgentAvatar-PT82VwmU.js";import{C as Da,O as vc,_ as Oa,a as yc,b as wc,c as kc,f as Ss,g as jc,h as Ns,n as Ic,o as Cc,p as _s,r as Sc,s as Nc,t as Et,u as _c,v as Ec,y as Mc}from"./checkbox-CmMbs2PZ.js";import{a as Ac,i as Rc,n as Dc,o as Oc,t as Es}from"./label-C2ddSDJj.js";import{a as bt,c as vt,r as yt}from"./agents-BlSzFh-1.js";import{_ as Ta,c as zo,h as Pa,i as Tc,l as Pc,n as $c,r as Bc,s as Lc,t as ft,x as Wc}from"./StatusIcon-BuUYMqqU.js";import{o as Hr,t as qo}from"./EmptyState-DPcc0zYh.js";import{t as $a}from"./bot-DZDpMzjD.js";import{t as Yt}from"./check-DDiXDm2i.js";import{t as En}from"./chevron-right-B9JUOr38.js";import{c as Ba,i as Zn,n as La,s as Wa,t as Ua}from"./select-mS22eY6T.js";import{C as Vo,b as _r,d as Uc,k as Qr,p as Fc,t as ye}from"./button-CAPbz11u.js";import{i as Kc,r as zc,t as qc}from"./clipboard-CYJ5Q78m.js";import{i as Go,o as Ho}from"./heartbeats-CK_aXmx5.js";import{n as Vc,t as Gc}from"./useHiddenSettings-2JpxuJV7.js";import{t as Hc}from"./octagon-alert-rGMwyrWA.js";import{t as Qo}from"./rotate-ccw-CRAQ3Xng.js";import{t as ra}from"./triangle-alert-CgJcxSQX.js";import{t as Ge}from"./badge-Cf7ihb3q.js";import{n as Tn,t as Qc}from"./environments-BVeNFanj.js";import{t as fn}from"./input-DpsS9it-.js";import{n as Yo,o as Xo,r as Jo}from"./company-members-BcZm1g8Q.js";import{t as pn}from"./AgentIdentity-MCshmbhZ.js";import{t as Yc}from"./card-dmVcp3AX.js";import{t as Zo}from"./PageSkeleton-DHjTwRT3.js";var Xc=class extends ta{static{a(this,"MutationCache")}#e;#t;#r;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}build(e,t,n){const s=new Zl({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(s),s}add(e){this.#e.add(e);const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(s=>s.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=Er(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ve.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ea(t,n))}findAll(e={}){return this.getAll().filter(t=>Ea(e,t))}notify(e){Ve.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Ve.batch(()=>Promise.all(e.map(t=>t.continue().catch(Mt))))}};function Er(e){return e.options.scope?.id}a(Er,"scopeFor");function Fa(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}a(Fa,"difference");var Jc=class extends ta{static{a(this,"QueriesObserver")}#e;#t;#r;#a;#n;#s;#o;#i;#l;#c=[];constructor(e,t,n){super(),this.#e=e,this.#a=n,this.#r=[],this.#n=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#n.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#a=t,Ve.batch(()=>{const n=this.#n,s=this.#f(this.#r);s.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const o=s.map(f=>f.observer),i=o.map(f=>f.getCurrentResult()),l=n.length!==o.length,c=o.some((f,m)=>f!==n[m]),d=l||c,p=d?!0:i.some((f,m)=>{const x=this.#t[m];return!x||!Ul(f,x)});!d&&!p||(d&&(this.#c=s,this.#n=o),this.#t=i,this.hasListeners()&&(d&&(Fa(n,o).forEach(f=>{f.destroy()}),Fa(o,n).forEach(f=>{f.subscribe(m=>{this.#p(f,m)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,t){const n=this.#f(e),s=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[s,i=>this.#d(i??s,t,o),()=>this.#u(s,n)]}#u(e,t){const n=new Set;return t.map((s,o)=>{const i=e[o];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,l=>{n.has(l)||(n.add(l),t.forEach(c=>{c.observer.trackProp(l)}))})})}#d(e,t,n){if(t){const s=this.#l,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((i,l)=>i!==s[l]));return(this.#t!==this.#i||o||t!==this.#o)&&(this.#o=t,this.#i=this.#t,n!==void 0&&(this.#l=n),this.#s=Gl(this.#s,t(e))),this.#s}return e}#h(){return!this.#a?.combine||this.#n.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#f(e){const t=new Map;this.#n.forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#e.defaultQueryOptions(s),i=t.get(o.queryHash)?.shift()??new Wo(this.#e,o);n.push({defaultedQueryOptions:o,observer:i})}),n}#p(e,t){const n=this.#n.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#m())}#m(){if(this.hasListeners()){const e=this.#h(),t=this.#s,n=e?t:this.#d(this.#u(this.#t,this.#c),this.#a?.combine);(e||t!==n)&&Ve.batch(()=>{this.listeners.forEach(s=>{s(this.#t)})})}}},Zc=class extends ta{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const s=t.queryKey,o=t.queryHash??Po(s,t);let i=this.get(o);return i||(i=new ac({client:e,queryKey:s,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Ve.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Sa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Sa(e,n)):t}notify(e){Ve.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ve.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ve.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},eu=class{static{a(this,"QueryClient")}#e;#t;#r;#a;#n;#s;#o;#i;constructor(e={}){this.#e=e.queryCache||new Zc,this.#t=e.mutationCache||new Xc,this.#r=e.defaultOptions||{},this.#a=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=fc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Na.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Cs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(s.queryHash)?.state.data,i=dc(t,o);if(i!==void 0)return this.#e.build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ve.batch(()=>this.#e.findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Ve.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return Ve.batch(()=>{const s=n.findAll(e),o=new Set(s);return s.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:a(i=>o.has(i),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},s=Ve.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(s).then(Mt).catch(Mt)}invalidateQueries(e,t={}){return Ve.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=Ve.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Mt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(Mt)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),s=n.isStaleByTime(Cs(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(s):s}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Cs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Mt).catch(Mt)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Mt).catch(Mt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Na.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#a.set(Ca(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(s=>{Ia(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(Ca(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(s=>{Ia(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Po(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===nc&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},u=Js(ql(),1);function ei({queries:e,...t},n){const s=Zs(n),o=Jl(),i=uc(),l=t.subscribed!==!1,c=u.useMemo(()=>e.map(I=>{const E=s.defaultQueryOptions(I);return E._optimisticResults=o?"isRestoring":l?"optimistic":void 0,E}),[e,s,o,l]);c.forEach(I=>{tc(I);const E=s.getQueryCache().get(I.queryHash);cc(I,i,E)}),rc(i);const[d]=u.useState(()=>new Jc(s,c,t)),[p,f,m]=d.getOptimisticResult(c,t.combine),x=!o&&l;u.useSyncExternalStore(u.useCallback(I=>x?d.subscribe(Ve.batchCalls(I)):Mt,[d,x]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),u.useEffect(()=>{d.setQueries(c,t)},[c,t,d]);const w=p.some((I,E)=>_a(c[E],I))?p.flatMap((I,E)=>{const D=c[E];if(D&&_a(D,I)){const T=new Wo(s,D);return Ql(D,T,i)}return[]}):[];if(w.length>0)throw Promise.all(w);const N=p.find((I,E)=>{const D=c[E];return D&&Xl({result:I,errorResetBoundary:i,throwOnError:D.throwOnError,query:s.getQueryCache().get(D.queryHash),suspense:D.suspense})});if(N)throw N.error;return f(m())}a(ei,"useQueries");function sa(e){return e.createdByUserId?{kind:"user",id:e.createdByUserId}:e.createdByAgentId?e.responsibleUserId?{kind:"user",id:e.responsibleUserId,viaAgentId:e.createdByAgentId}:{kind:"agent",id:e.createdByAgentId}:e.responsibleUserId?{kind:"user",id:e.responsibleUserId}:null}a(sa,"deriveOriginatingActor");var tu=["uncertain_provider_action","uncertain_external_action","uncertain_control_plane_action","completed_action_context_missing","continuation_evidence_incomplete","execution_finalization_deadline_exceeded","execution_recovery_budget_exhausted","provider_effect_inventory_unavailable","provider_failure_meaning_unverified","provider_ownership_unverified","native_provider_terminal_failed","native_event_replay_conflict","native_session_cleanup_quarantined","native_session_retry_exhausted","native_restart_recovery_blocked","native_continuation_requires_reconciliation","legacy_execution_requires_reconciliation"];function nu(e){return tu.some(t=>t===e)}a(nu,"requiresExecutionReconciliation");var r=Js(Fl(),1),ru=Object.defineProperty,pr=a((e,t)=>ru(e,"name",{value:t,configurable:!0}),"__name"),aa="Collapsible",[su,kg]=Yl(aa),[au,oa]=su(aa),ou=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,open:o,defaultOpen:i,disabled:l,onOpenChange:c,...d}=t,[p,f]=Hl({prop:o,defaultProp:i??!1,onChange:c,caller:aa});return(0,r.jsx)(au,{scope:s,disabled:l,contentId:ic(),open:p,onOpenToggle:u.useCallback(()=>f(m=>!m),[f]),children:(0,r.jsx)(na.div,{"data-state":cs(p),"data-disabled":l?"":void 0,...d,ref:n})})},"Collapsible2"),"Collapsible")),iu="CollapsibleTrigger",lu=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,...o}=t,i=oa(iu,s);return(0,r.jsx)(na.button,{type:"button","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":cs(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...o,ref:n,onClick:lc(t.onClick,i.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),ti="CollapsibleContent",cu=u.forwardRef(pr(a(function(t,n){const{forceMount:s,...o}=t,i=oa(ti,t.__scopeCollapsible);return(0,r.jsx)(ec,{present:s||i.open,children:a(({present:l})=>(0,r.jsx)(uu,{...o,ref:n,present:l}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),uu=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,present:o,children:i,...l}=t,c=oa(ti,s),[d,p]=u.useState(o),f=u.useRef(null),m=sc(n,f),x=u.useRef(0),w=x.current,N=u.useRef(0),I=N.current,E=c.open||d,D=u.useRef(E),T=u.useRef(void 0);return u.useEffect(()=>{const P=requestAnimationFrame(()=>D.current=!1);return()=>cancelAnimationFrame(P)},[]),oc(()=>{const P=f.current;if(P){T.current=T.current||{transitionDuration:P.style.transitionDuration,animationName:P.style.animationName},P.style.transitionDuration="0s",P.style.animationName="none";const B=P.getBoundingClientRect();x.current=B.height,N.current=B.width,D.current||(P.style.transitionDuration=T.current.transitionDuration,P.style.animationName=T.current.animationName),p(o)}},[c.open,o]),(0,r.jsx)(na.div,{"data-state":cs(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!E,...l,ref:m,style:{"--radix-collapsible-content-height":w?`${w}px`:void 0,"--radix-collapsible-content-width":I?`${I}px`:void 0,...t.style},children:E&&i})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function cs(e){return e?"open":"closed"}a(cs,"getState");pr(cs,"getState");var du=ou,fu=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],pu=et("arrow-down",fu),mu=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ni=et("arrow-up-down",mu),hu=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],gu=et("arrow-up",hu),xu=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],ri=et("chevrons-down-up",xu),bu=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]],si=et("circle-slash-2",bu),vu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],yu=et("columns-3",vu),wu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],ku=et("file-search",wu),ju=[["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"}]],Iu=et("funnel",ju),Cu=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],Su=et("hard-drive",Cu),Nu=[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]],ai=et("list-collapse",Nu),_u=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],oi=et("list-tree",_u),Eu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]],ii=et("panel-top-close",Eu),Mu=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],jg=et("repeat",Mu),Au=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]],li=et("square-kanban",Au);function ci({...e}){return(0,r.jsx)(du,{"data-slot":"collapsible",...e})}a(ci,"Collapsible");function Ig({...e}){return(0,r.jsx)(lu,{"data-slot":"collapsible-trigger",...e})}a(Ig,"CollapsibleTrigger");function ui({...e}){return(0,r.jsx)(cu,{"data-slot":"collapsible-content",...e})}a(ui,"CollapsibleContent");var er=Js(zl());function Ru(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,u.useMemo)(()=>s=>{t.forEach(o=>o(s))},t)}a(Ru,"useCombinedRefs");var us=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}a(Pn,"isWindow");function ia(e){return"nodeType"in e}a(ia,"isNode");function Xe(e){var t,n;return e?Pn(e)?e:ia(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}a(Xe,"getWindow");function la(e){const{Document:t}=Xe(e);return e instanceof t}a(la,"isDocument");function mr(e){return Pn(e)?!1:e instanceof Xe(e).HTMLElement}a(mr,"isHTMLElement");function di(e){return e instanceof Xe(e).SVGElement}a(di,"isSVGElement");function $n(e){return e?Pn(e)?e.document:ia(e)?la(e)?e:mr(e)||di(e)?e.ownerDocument:document:document:document}a($n,"getOwnerDocument");var wt=us?u.useLayoutEffect:u.useEffect;function ds(e){const t=(0,u.useRef)(e);return wt(()=>{t.current=e}),(0,u.useCallback)(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}a(ds,"useEvent");function Du(){const e=(0,u.useRef)(null);return[(0,u.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,u.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}a(Du,"useInterval");function or(e,t){t===void 0&&(t=[e]);const n=(0,u.useRef)(e);return wt(()=>{n.current!==e&&(n.current=e)},t),n}a(or,"useLatestValue");function hr(e,t){const n=(0,u.useRef)();return(0,u.useMemo)(()=>{const s=e(n.current);return n.current=s,s},[...t])}a(hr,"useLazyMemo");function Yr(e){const t=ds(e),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(s=>{s!==n.current&&t?.(s,n.current),n.current=s},[])]}a(Yr,"useNodeRef");function Xr(e){const t=(0,u.useRef)();return(0,u.useEffect)(()=>{t.current=e},[e]),t.current}a(Xr,"usePrevious");var Ms={};function gr(e,t){return(0,u.useMemo)(()=>{if(t)return t;const n=Ms[e]==null?0:Ms[e]+1;return Ms[e]=n,e+"-"+n},[e,t])}a(gr,"useUniqueId");function fi(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return s.reduce((i,l)=>{const c=Object.entries(l);for(const[d,p]of c){const f=i[d];f!=null&&(i[d]=f+e*p)}return i},{...t})}}a(fi,"createAdjustmentFn");var Mn=fi(1),ir=fi(-1);function Ou(e){return"clientX"in e&&"clientY"in e}a(Ou,"hasViewportRelativeCoordinates");function fs(e){if(!e)return!1;const{KeyboardEvent:t}=Xe(e.target);return t&&e instanceof t}a(fs,"isKeyboardEvent");function Tu(e){if(!e)return!1;const{TouchEvent:t}=Xe(e.target);return t&&e instanceof t}a(Tu,"isTouchEvent");function Jr(e){if(Tu(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ou(e)?{x:e.clientX,y:e.clientY}:null}a(Jr,"getEventCoordinates");var Xt=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Xt.Translate.toString(e),Xt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),Ka="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Pu(e){return e.matches(Ka)?e:e.querySelector(Ka)}a(Pu,"findFirstFocusableNode");var $u={display:"none"};function Bu(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:$u},n)}a(Bu,"HiddenText");function Lu(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":s,"aria-atomic":!0},n)}a(Lu,"LiveRegion");function Wu(){const[e,t]=(0,u.useState)("");return{announce:(0,u.useCallback)(n=>{n!=null&&t(n)},[]),announcement:e}}a(Wu,"useAnnouncement");var pi=(0,u.createContext)(null);function Uu(e){const t=(0,u.useContext)(pi);(0,u.useEffect)(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}a(Uu,"useDndMonitor");function Fu(){const[e]=(0,u.useState)(()=>new Set),t=(0,u.useCallback)(n=>(e.add(n),()=>e.delete(n)),[e]);return[(0,u.useCallback)(n=>{let{type:s,event:o}=n;e.forEach(i=>{var l;return(l=i[s])==null?void 0:l.call(i,o)})},[e]),t]}a(Fu,"useDndMonitorProvider");var Ku={draggable:`
1
+ var Ll=Object.defineProperty;var a=(e,t)=>Ll(e,"name",{value:t,configurable:!0});import{i as Js}from"./rolldown-runtime-ZpX3ckPj.js";import{$n as Wl,Ar as Ul,Cr as Po,Dr as Ia,Er as Mt,Fr as Fl,I as Kl,Ir as zl,Lr as ql,M as $o,Mr as Vl,O as Bo,Or as Gl,Pn as is,Pr as Zs,S as z,Sr as Ca,Tr as Sa,U as ea,X as Lo,Xn as Le,Y as we,_r as Na,a as Hl,ar as Ql,br as ta,c as Yl,cr as Xl,dr as Jl,fr as Zl,i as ec,ir as tc,jr as nc,kr as Cs,l as na,lr as rc,m as sc,mr as ac,nr as Ce,o as oc,or as _a,pr as Wo,r as ic,s as lc,sr as cc,t as et,ur as uc,vr as Ve,wr as Ea,xr as dc,yr as fc}from"./createLucideIcon-r3v6fbGz.js";import{B as Gt,W as Rn,X as fr,Y as Vr,Z as pc,b as Uo,o as Fo,t as Ht,w as Ko}from"./router-Bb8nJWyv.js";import{Q as Fr,s as Ma,tt as mc}from"./mention-chips-DXumPrOR.js";import{S as Aa,l as ls}from"./zap-P-cXfK28.js";import{d as dn,p as hc}from"./MarkdownEditor-Pip4OXiJ.js";import{b as gc,v as xc,y as bc}from"./sheet-DeCxNmfl.js";import{r as Gr,t as Ra}from"./AgentAvatar-PT82VwmU.js";import{C as Da,O as vc,_ as Oa,a as yc,b as wc,c as kc,f as Ss,g as jc,h as Ns,n as Ic,o as Cc,p as _s,r as Sc,s as Nc,t as Et,u as _c,v as Ec,y as Mc}from"./checkbox-CmMbs2PZ.js";import{a as Ac,i as Rc,n as Dc,o as Oc,t as Es}from"./label-C2ddSDJj.js";import{a as bt,c as vt,r as yt}from"./agents-BlSzFh-1.js";import{_ as Ta,c as zo,h as Pa,i as Tc,l as Pc,n as $c,r as Bc,s as Lc,t as ft,x as Wc}from"./StatusIcon-BuUYMqqU.js";import{o as Hr,t as qo}from"./EmptyState-DPcc0zYh.js";import{t as $a}from"./bot-DZDpMzjD.js";import{t as Yt}from"./check-DDiXDm2i.js";import{t as En}from"./chevron-right-B9JUOr38.js";import{c as Ba,i as Zn,n as La,s as Wa,t as Ua}from"./select-mS22eY6T.js";import{C as Vo,b as _r,d as Uc,k as Qr,p as Fc,t as ye}from"./button-CAPbz11u.js";import{i as Kc,r as zc,t as qc}from"./clipboard-CYJ5Q78m.js";import{i as Go,o as Ho}from"./heartbeats-CK_aXmx5.js";import{n as Vc,t as Gc}from"./useHiddenSettings-2JpxuJV7.js";import{t as Hc}from"./octagon-alert-rGMwyrWA.js";import{t as Qo}from"./rotate-ccw-CRAQ3Xng.js";import{t as ra}from"./triangle-alert-CgJcxSQX.js";import{t as Ge}from"./badge-Cf7ihb3q.js";import{n as Tn,t as Qc}from"./environments-BVeNFanj.js";import{t as fn}from"./input-DpsS9it-.js";import{n as Yo,o as Xo,r as Jo}from"./company-members-BcZm1g8Q.js";import{t as pn}from"./AgentIdentity-MCshmbhZ.js";import{t as Yc}from"./card-dmVcp3AX.js";import{t as Zo}from"./PageSkeleton-DHjTwRT3.js";var Xc=class extends ta{static{a(this,"MutationCache")}#e;#t;#r;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}build(e,t,n){const s=new Zl({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(s),s}add(e){this.#e.add(e);const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Er(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(s=>s.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=Er(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ve.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ea(t,n))}findAll(e={}){return this.getAll().filter(t=>Ea(e,t))}notify(e){Ve.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Ve.batch(()=>Promise.all(e.map(t=>t.continue().catch(Mt))))}};function Er(e){return e.options.scope?.id}a(Er,"scopeFor");function Fa(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}a(Fa,"difference");var Jc=class extends ta{static{a(this,"QueriesObserver")}#e;#t;#r;#a;#n;#s;#o;#i;#l;#c=[];constructor(e,t,n){super(),this.#e=e,this.#a=n,this.#r=[],this.#n=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#n.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#a=t,Ve.batch(()=>{const n=this.#n,s=this.#f(this.#r);s.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const o=s.map(f=>f.observer),i=o.map(f=>f.getCurrentResult()),l=n.length!==o.length,c=o.some((f,m)=>f!==n[m]),d=l||c,p=d?!0:i.some((f,m)=>{const x=this.#t[m];return!x||!Ul(f,x)});!d&&!p||(d&&(this.#c=s,this.#n=o),this.#t=i,this.hasListeners()&&(d&&(Fa(n,o).forEach(f=>{f.destroy()}),Fa(o,n).forEach(f=>{f.subscribe(m=>{this.#p(f,m)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,t){const n=this.#f(e),s=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[s,i=>this.#d(i??s,t,o),()=>this.#u(s,n)]}#u(e,t){const n=new Set;return t.map((s,o)=>{const i=e[o];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,l=>{n.has(l)||(n.add(l),t.forEach(c=>{c.observer.trackProp(l)}))})})}#d(e,t,n){if(t){const s=this.#l,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((i,l)=>i!==s[l]));return(this.#t!==this.#i||o||t!==this.#o)&&(this.#o=t,this.#i=this.#t,n!==void 0&&(this.#l=n),this.#s=Gl(this.#s,t(e))),this.#s}return e}#h(){return!this.#a?.combine||this.#n.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#f(e){const t=new Map;this.#n.forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#e.defaultQueryOptions(s),i=t.get(o.queryHash)?.shift()??new Wo(this.#e,o);n.push({defaultedQueryOptions:o,observer:i})}),n}#p(e,t){const n=this.#n.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#m())}#m(){if(this.hasListeners()){const e=this.#h(),t=this.#s,n=e?t:this.#d(this.#u(this.#t,this.#c),this.#a?.combine);(e||t!==n)&&Ve.batch(()=>{this.listeners.forEach(s=>{s(this.#t)})})}}},Zc=class extends ta{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const s=t.queryKey,o=t.queryHash??Po(s,t);let i=this.get(o);return i||(i=new ac({client:e,queryKey:s,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Ve.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Sa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Sa(e,n)):t}notify(e){Ve.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ve.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ve.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},eu=class{static{a(this,"QueryClient")}#e;#t;#r;#a;#n;#s;#o;#i;constructor(e={}){this.#e=e.queryCache||new Zc,this.#t=e.mutationCache||new Xc,this.#r=e.defaultOptions||{},this.#a=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=fc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Na.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Cs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(s.queryHash)?.state.data,i=dc(t,o);if(i!==void 0)return this.#e.build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ve.batch(()=>this.#e.findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Ve.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return Ve.batch(()=>{const s=n.findAll(e),o=new Set(s);return s.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:a(i=>o.has(i),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},s=Ve.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(s).then(Mt).catch(Mt)}invalidateQueries(e,t={}){return Ve.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=Ve.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Mt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(Mt)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),s=n.isStaleByTime(Cs(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(s):s}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Cs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Mt).catch(Mt)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Mt).catch(Mt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Na.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#a.set(Ca(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(s=>{Ia(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(Ca(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(s=>{Ia(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Po(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===nc&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},u=Js(ql(),1);function ei({queries:e,...t},n){const s=Zs(n),o=Jl(),i=uc(),l=t.subscribed!==!1,c=u.useMemo(()=>e.map(I=>{const E=s.defaultQueryOptions(I);return E._optimisticResults=o?"isRestoring":l?"optimistic":void 0,E}),[e,s,o,l]);c.forEach(I=>{tc(I);const E=s.getQueryCache().get(I.queryHash);cc(I,i,E)}),rc(i);const[d]=u.useState(()=>new Jc(s,c,t)),[p,f,m]=d.getOptimisticResult(c,t.combine),x=!o&&l;u.useSyncExternalStore(u.useCallback(I=>x?d.subscribe(Ve.batchCalls(I)):Mt,[d,x]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),u.useEffect(()=>{d.setQueries(c,t)},[c,t,d]);const w=p.some((I,E)=>_a(c[E],I))?p.flatMap((I,E)=>{const D=c[E];if(D&&_a(D,I)){const T=new Wo(s,D);return Ql(D,T,i)}return[]}):[];if(w.length>0)throw Promise.all(w);const N=p.find((I,E)=>{const D=c[E];return D&&Xl({result:I,errorResetBoundary:i,throwOnError:D.throwOnError,query:s.getQueryCache().get(D.queryHash),suspense:D.suspense})});if(N)throw N.error;return f(m())}a(ei,"useQueries");function sa(e){return e.createdByUserId?{kind:"user",id:e.createdByUserId}:e.createdByAgentId?e.responsibleUserId?{kind:"user",id:e.responsibleUserId,viaAgentId:e.createdByAgentId}:{kind:"agent",id:e.createdByAgentId}:e.responsibleUserId?{kind:"user",id:e.responsibleUserId}:null}a(sa,"deriveOriginatingActor");var tu=["uncertain_provider_action","uncertain_external_action","uncertain_control_plane_action","completed_action_context_missing","continuation_evidence_incomplete","execution_finalization_deadline_exceeded","execution_recovery_budget_exhausted","provider_effect_inventory_unavailable","provider_failure_meaning_unverified","provider_ownership_unverified","native_provider_terminal_failed","native_event_replay_conflict","native_session_cleanup_quarantined","native_session_retry_exhausted","native_restart_recovery_blocked","native_continuation_requires_reconciliation","legacy_execution_requires_reconciliation"];function nu(e){return tu.some(t=>t===e)}a(nu,"requiresExecutionReconciliation");var r=Js(Fl(),1),ru=Object.defineProperty,pr=a((e,t)=>ru(e,"name",{value:t,configurable:!0}),"__name"),aa="Collapsible",[su,kg]=Yl(aa),[au,oa]=su(aa),ou=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,open:o,defaultOpen:i,disabled:l,onOpenChange:c,...d}=t,[p,f]=Hl({prop:o,defaultProp:i??!1,onChange:c,caller:aa});return(0,r.jsx)(au,{scope:s,disabled:l,contentId:ic(),open:p,onOpenToggle:u.useCallback(()=>f(m=>!m),[f]),children:(0,r.jsx)(na.div,{"data-state":cs(p),"data-disabled":l?"":void 0,...d,ref:n})})},"Collapsible2"),"Collapsible")),iu="CollapsibleTrigger",lu=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,...o}=t,i=oa(iu,s);return(0,r.jsx)(na.button,{type:"button","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":cs(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...o,ref:n,onClick:lc(t.onClick,i.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),ti="CollapsibleContent",cu=u.forwardRef(pr(a(function(t,n){const{forceMount:s,...o}=t,i=oa(ti,t.__scopeCollapsible);return(0,r.jsx)(ec,{present:s||i.open,children:a(({present:l})=>(0,r.jsx)(uu,{...o,ref:n,present:l}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),uu=u.forwardRef(pr(a(function(t,n){const{__scopeCollapsible:s,present:o,children:i,...l}=t,c=oa(ti,s),[d,p]=u.useState(o),f=u.useRef(null),m=sc(n,f),x=u.useRef(0),w=x.current,N=u.useRef(0),I=N.current,E=c.open||d,D=u.useRef(E),T=u.useRef(void 0);return u.useEffect(()=>{const P=requestAnimationFrame(()=>D.current=!1);return()=>cancelAnimationFrame(P)},[]),oc(()=>{const P=f.current;if(P){T.current=T.current||{transitionDuration:P.style.transitionDuration,animationName:P.style.animationName},P.style.transitionDuration="0s",P.style.animationName="none";const B=P.getBoundingClientRect();x.current=B.height,N.current=B.width,D.current||(P.style.transitionDuration=T.current.transitionDuration,P.style.animationName=T.current.animationName),p(o)}},[c.open,o]),(0,r.jsx)(na.div,{"data-state":cs(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!E,...l,ref:m,style:{"--radix-collapsible-content-height":w?`${w}px`:void 0,"--radix-collapsible-content-width":I?`${I}px`:void 0,...t.style},children:E&&i})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function cs(e){return e?"open":"closed"}a(cs,"getState");pr(cs,"getState");var du=ou,fu=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],pu=et("arrow-down",fu),mu=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ni=et("arrow-up-down",mu),hu=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],gu=et("arrow-up",hu),xu=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],ri=et("chevrons-down-up",xu),bu=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]],si=et("circle-slash-2",bu),vu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],yu=et("columns-3",vu),wu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],ku=et("file-search",wu),ju=[["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"}]],Iu=et("funnel",ju),Cu=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],Su=et("hard-drive",Cu),Nu=[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]],ai=et("list-collapse",Nu),_u=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],oi=et("list-tree",_u),Eu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]],ii=et("panel-top-close",Eu),Mu=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],jg=et("repeat",Mu),Au=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]],li=et("square-kanban",Au);function ci({...e}){return(0,r.jsx)(du,{"data-slot":"collapsible",...e})}a(ci,"Collapsible");function Ig({...e}){return(0,r.jsx)(lu,{"data-slot":"collapsible-trigger",...e})}a(Ig,"CollapsibleTrigger");function ui({...e}){return(0,r.jsx)(cu,{"data-slot":"collapsible-content",...e})}a(ui,"CollapsibleContent");var er=Js(zl());function Ru(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,u.useMemo)(()=>s=>{t.forEach(o=>o(s))},t)}a(Ru,"useCombinedRefs");var us=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}a(Pn,"isWindow");function ia(e){return"nodeType"in e}a(ia,"isNode");function Xe(e){var t,n;return e?Pn(e)?e:ia(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}a(Xe,"getWindow");function la(e){const{Document:t}=Xe(e);return e instanceof t}a(la,"isDocument");function mr(e){return Pn(e)?!1:e instanceof Xe(e).HTMLElement}a(mr,"isHTMLElement");function di(e){return e instanceof Xe(e).SVGElement}a(di,"isSVGElement");function $n(e){return e?Pn(e)?e.document:ia(e)?la(e)?e:mr(e)||di(e)?e.ownerDocument:document:document:document}a($n,"getOwnerDocument");var wt=us?u.useLayoutEffect:u.useEffect;function ds(e){const t=(0,u.useRef)(e);return wt(()=>{t.current=e}),(0,u.useCallback)(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}a(ds,"useEvent");function Du(){const e=(0,u.useRef)(null);return[(0,u.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,u.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}a(Du,"useInterval");function or(e,t){t===void 0&&(t=[e]);const n=(0,u.useRef)(e);return wt(()=>{n.current!==e&&(n.current=e)},t),n}a(or,"useLatestValue");function hr(e,t){const n=(0,u.useRef)();return(0,u.useMemo)(()=>{const s=e(n.current);return n.current=s,s},[...t])}a(hr,"useLazyMemo");function Yr(e){const t=ds(e),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(s=>{s!==n.current&&t?.(s,n.current),n.current=s},[])]}a(Yr,"useNodeRef");function Xr(e){const t=(0,u.useRef)();return(0,u.useEffect)(()=>{t.current=e},[e]),t.current}a(Xr,"usePrevious");var Ms={};function gr(e,t){return(0,u.useMemo)(()=>{if(t)return t;const n=Ms[e]==null?0:Ms[e]+1;return Ms[e]=n,e+"-"+n},[e,t])}a(gr,"useUniqueId");function fi(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return s.reduce((i,l)=>{const c=Object.entries(l);for(const[d,p]of c){const f=i[d];f!=null&&(i[d]=f+e*p)}return i},{...t})}}a(fi,"createAdjustmentFn");var Mn=fi(1),ir=fi(-1);function Ou(e){return"clientX"in e&&"clientY"in e}a(Ou,"hasViewportRelativeCoordinates");function fs(e){if(!e)return!1;const{KeyboardEvent:t}=Xe(e.target);return t&&e instanceof t}a(fs,"isKeyboardEvent");function Tu(e){if(!e)return!1;const{TouchEvent:t}=Xe(e.target);return t&&e instanceof t}a(Tu,"isTouchEvent");function Jr(e){if(Tu(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ou(e)?{x:e.clientX,y:e.clientY}:null}a(Jr,"getEventCoordinates");var Xt=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Xt.Translate.toString(e),Xt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),Ka="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Pu(e){return e.matches(Ka)?e:e.querySelector(Ka)}a(Pu,"findFirstFocusableNode");var $u={display:"none"};function Bu(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:$u},n)}a(Bu,"HiddenText");function Lu(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":s,"aria-atomic":!0},n)}a(Lu,"LiveRegion");function Wu(){const[e,t]=(0,u.useState)("");return{announce:(0,u.useCallback)(n=>{n!=null&&t(n)},[]),announcement:e}}a(Wu,"useAnnouncement");var pi=(0,u.createContext)(null);function Uu(e){const t=(0,u.useContext)(pi);(0,u.useEffect)(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}a(Uu,"useDndMonitor");function Fu(){const[e]=(0,u.useState)(()=>new Set),t=(0,u.useCallback)(n=>(e.add(n),()=>e.delete(n)),[e]);return[(0,u.useCallback)(n=>{let{type:s,event:o}=n;e.forEach(i=>{var l;return(l=i[s])==null?void 0:l.call(i,o)})},[e]),t]}a(Fu,"useDndMonitorProvider");var Ku={draggable:`
2
2
  To pick up a draggable item, press the space bar.
3
3
  While dragging, use the arrow keys to move the item.
4
4
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -1 +1 @@
1
- var ks=Object.defineProperty;var t=(n,c)=>ks(n,"name",{value:c,configurable:!0});import{i as as}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Ps,Lr as As,Pr as Ms,S as Ds,U as Ts,Y as m,nr as A,tr as _}from"./createLucideIcon-r3v6fbGz.js";import{B as ze,U as qs,b as Ks,ct as Us,o as Es}from"./router-DyZkoSkG.js";import{Ct as Os,O as Ls,bt as Qs,cr as ls,gr as Bs,lr as ee,or as Ge,r as Vs,sr as We,t as $s,v as he,vt as Ye,wt as zs,xt as Gs,yt as Ws}from"./RoutineRunVariablesDialog-IRX4TLng.js";import{l as J,t as Ys}from"./MarkdownEditor-Pip4OXiJ.js";import{t as He}from"./AgentAvatar-PT82VwmU.js";import{a as Hs,r as Js}from"./checkbox-CmMbs2PZ.js";import{n as Je,t as Xs}from"./tabs-DWRZjksg.js";import{a as Xe,c as Ze,r as es,t as Zs}from"./agents-BlSzFh-1.js";import{g as et}from"./StatusIcon-BuUYMqqU.js";import{r as st,t as je}from"./EmptyState-DPcc0zYh.js";import{t as tt}from"./check-DDiXDm2i.js";import{t as nt}from"./chevron-down-F9aZv-V7.js";import{t as cs}from"./chevron-right-B9JUOr38.js";import{c as ye,i as X,n as ve,s as be,t as we}from"./select-mS22eY6T.js";import{k as Z,t as F}from"./button-CAPbz11u.js";import{t as rt}from"./heartbeats-CK_aXmx5.js";import{i as it,o as ot}from"./company-members-BcZm1g8Q.js";import{r as at,t as lt}from"./card-dmVcp3AX.js";import{t as ct}from"./PageSkeleton-DHjTwRT3.js";import{$ as dt,$t as ut,J as mt,Q as pt,X as ft,Y as gt,Z as xt,at as ht,et as jt,fn as yt,ht as M,in as vt,it as bt,mt as wt,nt as Nt,pt as It,rn as Rt,rt as Ct,tt as St}from"./index-CZl9vxyj.js";var l=as(As(),1),s=as(Ps(),1),_t=["coalesce_if_active","always_enqueue","skip_if_active"],Ft=["skip_missed","enqueue_missed_with_cap"],kt={coalesce_if_active:"If a run is already active, keep just one follow-up run queued.",always_enqueue:"Queue every trigger occurrence, even if the routine is already running.",skip_if_active:"Drop new trigger occurrences while a run is still active."},Pt={skip_missed:"Ignore windows that were missed while the scheduler or routine was paused.",enqueue_missed_with_cap:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."};function ss(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}t(ss,"autoResizeTextarea");var At="__built_in_routines",ts={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function ns(n){try{const c=localStorage.getItem(n);if(c)return{...ts,...JSON.parse(c)}}catch{}return{...ts}}t(ns,"getRoutineViewState");function Mt(n,c){localStorage.setItem(n,JSON.stringify(c))}t(Mt,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}t(q,"timestampValue");function rs(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}t(rs,"compareNullableText");function Dt(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}t(Dt,"buildRoutineMutationPayload");function Tt(n,c,d,b,g){if(c==="none")return[{key:"__all",label:null,items:n}];if(c==="folder"){const i=he(n,o=>o.folderId??"__unfiled");return Object.keys(i).sort((o,j)=>{if(o==="__unfiled"||j==="__unfiled")return o===j?0:o==="__unfiled"?1:-1;const w=g.get(o),I=g.get(j),O=(Number.isFinite(w?.position)?w.position:Number.POSITIVE_INFINITY)-(Number.isFinite(I?.position)?I.position:Number.POSITIVE_INFINITY);return O!==0?O:(w?.name??"Unknown folder").localeCompare(I?.name??"Unknown folder",void 0,{sensitivity:"base"})||o.localeCompare(j)}).map(o=>({key:o,label:o==="__unfiled"?"Unfiled":g.get(o)?.name??"Unknown folder",items:i[o]}))}if(c==="project"){const i=he(n,o=>o.projectId??"__no_project");return Object.keys(i).sort((o,j)=>{const w=o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",I=j==="__no_project"?"No project":d.get(j)?.name??"Unknown project";return w.localeCompare(I)}).map(o=>({key:o,label:o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",items:i[o]}))}const x=he(n,i=>i.assigneeAgentId??"__unassigned");return Object.keys(x).sort((i,o)=>{const j=i==="__unassigned"?"Unassigned":b.get(i)?.name??"Unknown agent",w=o==="__unassigned"?"Unassigned":b.get(o)?.name??"Unknown agent";return j.localeCompare(w)}).map(i=>({key:i,label:i==="__unassigned"?"Unassigned":b.get(i)?.name??"Unknown agent",items:x[i]}))}t(Tt,"buildRoutineGroups");function is(n){return n.originKind==="built_in_agent_bundle"}t(is,"isBuiltInRoutine");function qt(n,c,d,b,g){const x=n.filter(is),i=Tt(n.filter(o=>!is(o)),c,d,b,g).filter(o=>o.items.length>0).map(o=>x.length>0&&c==="none"&&o.key==="__all"?{...o,label:"Custom routines"}:o);return x.length===0?i:[...i,{key:At,label:"Built-in routines",items:x}]}t(qt,"buildRoutineSections");function Kt(n,c,d){const b=d==="asc"?1:-1;return[...n].sort((g,x)=>{let i=0;return c==="title"?i=rs(g.title,x.title):c==="created"?i=q(g.createdAt)-q(x.createdAt):c==="lastRun"?i=q(g.lastRun?.triggeredAt??g.lastTriggeredAt)-q(x.lastRun?.triggeredAt??x.lastTriggeredAt):i=q(g.updatedAt)-q(x.updatedAt),i!==0?i*b:rs(g.title,x.title)})}t(Kt,"sortRoutines");function os(n){return n==="runs"?"/routines?tab=runs":"/routines"}t(os,"buildRoutinesTabHref");function Ut({label:n,count:c,isOpen:d}){return(0,s.jsxs)("div",{className:`flex items-center gap-2 rounded-lg border border-border px-3 py-2${d?" mb-1":""}`,children:[(0,s.jsxs)(ls,{className:"flex items-center gap-1.5",children:[(0,s.jsx)(cs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-90"}),(0,s.jsx)("span",{className:"text-sm font-semibold uppercase tracking-wide",children:n})]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:c})]})}t(Ut,"RoutineSectionHeader");function cn(){const{selectedCompanyId:n}=Ts(),{setBreadcrumbs:c}=st(),d=Ms(),b=Es(),[g,x]=Us(),{pushToast:i}=yt(),o=(0,l.useRef)(null),j=(0,l.useRef)(null),w=(0,l.useRef)(null),I=(0,l.useRef)(null),[O,K]=(0,l.useState)(!1),[se,L]=(0,l.useState)(null),[Q,te]=(0,l.useState)(null),[ds,Ne]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[B,V]=(0,l.useState)([]),[Ie,Re]=(0,l.useState)([]),[us,Ce]=(0,l.useState)(null),[ms,Se]=(0,l.useState)(null),[k,ie]=(0,l.useState)(null),[$,z]=(0,l.useState)(!1),[_e,oe]=(0,l.useState)(!1),P=g.get("tab")==="runs"?"runs":"routines",[p,R]=(0,l.useState)({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),G=n?`paperclip:routines-view:${n}`:"paperclip:routines-view",[u,Fe]=(0,l.useState)(()=>ns(G)),f=bt(g.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{Fe(ns(G))},[G]);const{data:ke,isLoading:ps,error:ae}=A({queryKey:m.routines.list(n),queryFn:t(()=>J.list(n),"queryFn"),enabled:!!n}),{data:h,isLoading:Pe}=A({queryKey:m.folders.list(n,"routine"),queryFn:t(()=>M.list(n,"routine"),"queryFn"),enabled:!!n&&P==="routines"}),{data:C}=A({queryKey:m.agents.list(n),queryFn:t(()=>Zs.list(n),"queryFn"),enabled:!!n}),{data:S}=A({queryKey:m.projects.list(n,{includeArchived:!0}),queryFn:t(()=>et.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Ae}=A({queryKey:m.access.companyUserDirectory(n),queryFn:t(()=>ot.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:le,isLoading:fs,error:gs}=A({queryKey:[...m.issues.list(n),"routine-executions"],queryFn:t(()=>ze.list(n,{originKind:"routine_execution"}),"queryFn"),enabled:!!n&&P==="runs"}),Me=m.liveRuns(n),ce=vt({companyId:n,resourceKey:"live-runs",queryKey:Me,enabled:!!n&&P==="runs",refetchInterval:!1,leaderOnly:!0}),{data:de,dataUpdatedAt:xs}=A({queryKey:Me,queryFn:t(()=>rt.liveRunsForCompany(n),"queryFn"),enabled:ce.enabled,refetchInterval:ce.refetchInterval});Rt(ce,de,xs),(0,l.useEffect)(()=>{ss(j.current)},[p.title,$]);const hs=(0,l.useMemo)(()=>it({agents:C,projects:(S??[]).filter(e=>!e.archivedAt),members:Ae?.users}),[C,Ae?.users,S]),N=_({mutationFn:t(()=>J.create(n,Dt(p)),"mutationFn"),onSuccess:t(async e=>{R({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),z(!1),oe(!1),await d.invalidateQueries({queryKey:m.routines.list(n)}),i({title:"Routine created",body:e.assigneeAgentId?"Add the first trigger to turn it into a live workflow.":"Draft saved. Add a default agent before enabling automation.",tone:"success"}),b(`/routines/${e.id}?tab=triggers`)},"onSuccess")}),De=_({mutationFn:t(e=>M.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:t(async e=>{if(K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")}),Ie.length>0){const r=Ie;Re([]);try{await Promise.all(r.map(a=>M.moveItem(n,{kind:"routine",itemId:a,folderId:e.id}))),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])}catch(a){i({title:"Folder created, move failed",body:a instanceof Error?a.message:"Paperclip could not move the selected routines.",tone:"error"});return}}else Y(e.id);i({title:"Folder created",body:e.name,tone:"success"})},"onSuccess"),onError:t(e=>{i({title:"Failed to save folder",body:e instanceof Error?e.message:"Paperclip could not save the folder.",tone:"error"})},"onError")}),ue=_({mutationFn:t(({folderId:e,payload:r})=>M.update(n,e,r),"mutationFn"),onSuccess:t(async()=>{K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")})},"onSuccess"),onError:t(e=>{i({title:"Folder save failed",body:e instanceof Error?e.message:"Paperclip could not update the folder.",tone:"error"})},"onError")}),Te=_({mutationFn:t(e=>M.delete(n,e),"mutationFn"),onSuccess:t(async(e,r)=>{f===r&&Y("all"),te(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})]),i({title:"Folder deleted",body:"Items moved to Unfiled.",tone:"success"})},"onSuccess"),onError:t(e=>{i({title:"Folder delete failed",body:e instanceof Error?e.message:"Paperclip could not delete the folder.",tone:"error"})},"onError")}),qe=_({mutationFn:t(({itemId:e,folderId:r})=>M.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:t(async()=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])},"onSuccess"),onError:t(e=>{i({title:"Move failed",body:e instanceof Error?e.message:"Paperclip could not move the routine.",tone:"error"})},"onError")}),js=_({mutationFn:t(({id:e,data:r})=>ze.update(e,r),"mutationFn"),onSuccess:t(async()=>{await d.invalidateQueries({queryKey:[...m.issues.list(n),"routine-executions"]})},"onSuccess")}),Ke=_({mutationFn:t(({id:e,status:r})=>J.update(e,{status:r}),"mutationFn"),onMutate:t(({id:e})=>{Se(e)},"onMutate"),onSuccess:t(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r.id)})])},"onSuccess"),onSettled:t(()=>{Se(null)},"onSettled"),onError:t(e=>{i({title:"Failed to update routine",body:e instanceof Error?e.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Ue=_({mutationFn:t(({id:e,data:r})=>J.run(e,{...r?.variables&&Object.keys(r.variables).length>0?{variables:r.variables}:{},...r?.assigneeAgentId!==void 0?{assigneeAgentId:r.assigneeAgentId}:{},...r?.projectId!==void 0?{projectId:r.projectId}:{},...r?.executionWorkspaceId!==void 0?{executionWorkspaceId:r.executionWorkspaceId}:{},...r?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:r.executionWorkspacePreference}:{},...r?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:r.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:t(({id:e})=>{Ce(e)},"onMutate"),onSuccess:t(async(e,{id:r})=>{ie(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r)})])},"onSuccess"),onSettled:t(()=>{Ce(null)},"onSettled"),onError:t(e=>{i({title:"Routine run failed",body:e instanceof Error?e.message:"Paperclip could not start the routine run.",tone:"error"})},"onError")}),me=(0,l.useMemo)(()=>Gs(),[$]),ys=(0,l.useMemo)(()=>Ws(),[$]),vs=(0,l.useMemo)(()=>Os((C??[]).filter(e=>e.status!=="terminated"),me).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[C,me]),bs=(0,l.useMemo)(()=>(S??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[S]),U=(0,l.useMemo)(()=>new Map((C??[]).map(e=>[e.id,e])),[C]),E=(0,l.useMemo)(()=>new Map((S??[]).map(e=>[e.id,e])),[S]),Ee=(0,l.useMemo)(()=>new Map((h?.folders??[]).map(e=>[e.id,e])),[h]),ws=(0,l.useMemo)(()=>Ls(de,le),[de,le]),y=(0,l.useMemo)(()=>(ke??[]).filter(e=>e.status!=="archived"),[ke]),Oe=(0,l.useMemo)(()=>u.groupBy!=="folder"||f==="all"?y:f==="unfiled"?y.filter(e=>!e.folderId):y.filter(e=>e.folderId===f),[f,u.groupBy,y]),pe=(0,l.useMemo)(()=>{if(!h)return h;const e=new Map;let r=0;for(const a of y)a.folderId?e.set(a.folderId,(e.get(a.folderId)??0)+1):r+=1;return{...h,allCount:y.length,unfiledCount:r,folders:h.folders.map(a=>({...a,itemCount:e.get(a.id)??0}))}},[h,y]),D=(0,l.useMemo)(()=>Kt(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),Ns=(0,l.useMemo)(()=>qt(D,u.groupBy,E,U,Ee),[U,Ee,E,u.groupBy,D]),Is=(0,l.useMemo)(()=>qs("Recent Runs",os("runs"),"issues"),[]),Le=p.assigneeAgentId?U.get(p.assigneeAgentId)??null:null,Qe=p.projectId?E.get(p.projectId)??null:null,Be=ht(h?.folders??[],f),W=(h?.folders.length??0)>0,fe=P==="routines"&&u.groupBy==="folder"&&W;function ge(e){Fe(r=>{const a={...r,...e};return Mt(G,a),a})}t(ge,"updateRoutineView");function Ve(e){const r=e==="runs"?"runs":"routines";(0,l.startTransition)(()=>{b(os(r))})}t(Ve,"handleTabChange");function Y(e){x(r=>{const a=new URLSearchParams(r),v=Ct(e);return v?a.set("folder",v):a.delete("folder"),a})}t(Y,"setFolderSelection");function T(e=[]){Re(e),L(null),K(!0)}t(T,"openCreateFolder");function $e(){R(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),z(!0)}t($e,"openCreateRoutine");async function Rs(e){const r=B;if(r.length!==0)try{await Promise.all(r.map(a=>M.moveItem(n,{kind:"routine",itemId:a,folderId:e}))),V([]),re(!1),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})]),i({title:"Routines moved",body:`${r.length} routine${r.length===1?"":"s"} filed.`,tone:"success"})}catch(a){i({title:"Failed to move routines",body:a instanceof Error?a.message:"Paperclip could not move the selected routines.",tone:"error"})}}t(Rs,"moveSelectedRoutines");function Cs(e){ie(e)}t(Cs,"handleRunNow");function Ss(e,r){if(!r&&!e.assigneeAgentId){i({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}Ke.mutate({id:e.id,status:wt(e.status,!r)})}t(Ss,"handleToggleEnabled");function _s(e){Ke.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return t(_s,"handleToggleArchived"),n?ps?(0,s.jsx)(ct,{variant:"issues-list"}):(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Routines"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,s.jsxs)(F,{onClick:$e,children:[(0,s.jsx)(Z,{className:"mr-2 h-4 w-4"}),"Create routine"]})]}),(0,s.jsxs)(Xs,{value:P,onValueChange:Ve,children:[(0,s.jsx)(ut,{align:"start",value:P,onValueChange:Ve,items:[{value:"routines",label:"Routines"},{value:"runs",label:"Recent Runs"}]}),(0,s.jsxs)(Je,{value:"routines",className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:[y.length," routine",y.length===1?"":"s"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsxs)(es,{children:[(0,s.jsx)(Ze,{asChild:!0,children:(0,s.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,s.jsx)(Bs,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,s.jsx)(Xe,{align:"end",className:"w-44 p-0",children:(0,s.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,s.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.sortField===e?"bg-accent/50 text-foreground":"text-muted-foreground hover:bg-accent/50"}`,onClick:t(()=>{ge(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,s.jsx)("span",{children:r}),u.sortField===e?(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,s.jsxs)(es,{children:[(0,s.jsx)(Ze,{asChild:!0,children:(0,s.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,s.jsx)(Ks,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,s.jsx)(Xe,{align:"end",className:"w-44 p-0",children:(0,s.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,s.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.groupBy===e?"bg-accent/50 text-foreground":"text-muted-foreground hover:bg-accent/50"}`,onClick:t(()=>ge({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,s.jsx)("span",{children:r}),u.groupBy===e?(0,s.jsx)(tt,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!W?(0,s.jsxs)(F,{variant:"outline",size:"sm",onClick:t(()=>T(),"onClick"),children:[(0,s.jsx)(Z,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,fe?(0,s.jsx)(F,{variant:"ghost",size:"sm",className:"text-xs",onClick:t(()=>re(e=>!e),"onClick"),children:ne?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,s.jsx)("div",{className:"md:hidden",children:(0,s.jsx)(xt,{result:pe,selection:f,allLabel:"All routines",onClick:t(()=>Ne(!0),"onClick")})}):null]}),(0,s.jsx)(Je,{value:"runs",children:(0,s.jsx)(Vs,{issues:le??[],isLoading:fs,error:gs,agents:C,projects:S,liveIssueIds:ws,viewStateKey:"paperclip:routine-recent-runs-view",issueLinkState:Is,onUpdateIssue:t((e,r)=>js.mutate({id:e,data:r}),"onUpdateIssue")})})]}),(0,s.jsx)(Js,{open:$,onOpenChange:t(e=>{N.isPending||z(e)},"onOpenChange"),children:(0,s.jsxs)(Hs,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,s.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-3 border-b border-border/60 px-5 py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"New routine"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,s.jsx)(F,{variant:"ghost",size:"sm",onClick:t(()=>{z(!1),oe(!1)},"onClick"),disabled:N.isPending,children:"Cancel"})]}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,s.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,s.jsx)("textarea",{ref:j,className:"w-full resize-none overflow-hidden bg-transparent text-xl font-semibold outline-none placeholder:text-muted-foreground/50",placeholder:"Routine title",rows:1,value:p.title,onChange:t(e=>{R(r=>({...r,title:e.target.value})),ss(e.target)},"onChange"),onKeyDown:t(e=>{if(e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing){e.preventDefault(),o.current?.focus();return}e.key==="Tab"&&!e.shiftKey&&(e.preventDefault(),p.assigneeAgentId?p.projectId?o.current?.focus():I.current?.focus():w.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,s.jsx)("div",{className:"px-5 pb-3",children:(0,s.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,s.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap",children:[(0,s.jsx)("span",{children:"For"}),(0,s.jsx)(Ye,{ref:w,value:p.assigneeAgentId,options:vs,recentOptionIds:me,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:t(e=>{e&&zs(e),R(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:t(()=>{p.projectId?o.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:t(e=>e?Le?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(He,{agent:Le,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"truncate",children:e.label})]}):(0,s.jsx)("span",{className:"truncate",children:e.label}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:t(e=>{if(!e.id)return(0,s.jsx)("span",{className:"truncate",children:e.label});const r=U.get(e.id);return(0,s.jsxs)(s.Fragment,{children:[r?(0,s.jsx)(He,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,s.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,s.jsx)("span",{children:"in"}),(0,s.jsx)(Ye,{ref:I,value:p.projectId,options:bs,recentOptionIds:ys,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:t(e=>{e&&Qs(e),R(r=>({...r,projectId:e}))},"onChange"),onConfirm:t(()=>o.current?.focus(),"onConfirm"),renderTriggerValue:t(e=>e&&Qe?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Qe.color??"var(--project-none)"}}),(0,s.jsx)("span",{className:"truncate",children:e.label})]}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:t(e=>{if(!e.id)return(0,s.jsx)("span",{className:"truncate",children:e.label});const r=E.get(e.id);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,s.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,s.jsx)("span",{children:"filed in"}),(0,s.jsxs)(we,{value:p.folderId??"__unfiled",onValueChange:t(e=>R(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,s.jsx)(be,{className:"h-8 w-auto min-w-32 border-0 bg-muted/50 px-2 shadow-none",children:(0,s.jsx)(ye,{})}),(0,s.jsxs)(ve,{children:[(0,s.jsx)(X,{value:"__unfiled",children:"Unfiled"}),(h?.folders??[]).map(e=>(0,s.jsx)(X,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,s.jsx)("div",{className:"border-t border-border/60 px-5 py-4",children:(0,s.jsx)(Ys,{ref:o,value:p.description,onChange:t(e=>R(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-muted-foreground",mentions:hs,onSubmit:t(()=>{!N.isPending&&p.title.trim()&&p.projectId&&p.assigneeAgentId&&N.mutate()},"onSubmit")})}),(0,s.jsx)("div",{className:"border-t border-border/60 px-5 py-3",children:(0,s.jsxs)(Ge,{open:_e,onOpenChange:oe,children:[(0,s.jsxs)(ls,{className:"flex w-full items-center justify-between text-left",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Keep policy controls secondary to the work definition."})]}),_e?(0,s.jsx)(nt,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(cs,{className:"h-4 w-4 text-muted-foreground"})]}),(0,s.jsx)(We,{className:"pt-3",children:(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,s.jsxs)(we,{value:p.concurrencyPolicy,onValueChange:t(e=>R(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{})}),(0,s.jsx)(ve,{children:_t.map(e=>(0,s.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:kt[p.concurrencyPolicy]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,s.jsxs)(we,{value:p.catchUpPolicy,onValueChange:t(e=>R(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{})}),(0,s.jsx)(ve,{children:Ft.map(e=>(0,s.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:Pt[p.catchUpPolicy]})]})]})})]})})]}),(0,s.jsxs)("div",{className:"shrink-0 flex flex-col gap-3 border-t border-border/60 px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:"After creation, Paperclip takes you straight to trigger setup. Draft routines stay paused until you add a default agent."}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,s.jsxs)(F,{onClick:t(()=>N.mutate(),"onClick"),disabled:N.isPending||!p.title.trim(),children:[(0,s.jsx)(Z,{className:"mr-2 h-4 w-4"}),N.isPending?"Creating...":"Create routine"]}),N.isError?(0,s.jsx)("p",{className:"text-sm text-destructive",children:N.error instanceof Error?N.error.message:"Failed to create routine"}):null]})]})]})}),ae?(0,s.jsx)(lt,{children:(0,s.jsx)(at,{className:"pt-6 text-sm text-destructive",children:ae instanceof Error?ae.message:"Failed to load routines"})}):null,P==="routines"?(0,s.jsxs)("div",{className:Ds(fe&&"flex gap-4"),children:[fe?(0,s.jsx)(dt,{result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Pe,onSelect:Y,onCreate:t(()=>T(),"onCreate"),onRename:t((e,r)=>ue.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:t(e=>{L(e),K(!0)},"onEdit"),onDelete:te}):null,(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&W?(0,s.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,s.jsx)(Et,{label:"All routines",count:D.length}):(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,s.jsx)(jt,{color:Be?.color}),(0,s.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Be?.name??"Folder"}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[D.length," routine",D.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!W&&!Pe&&y.length>0?(0,s.jsx)(mt,{storageKey:`paperclip:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:t(()=>T(),"onCreateFolder")}):null,ne?(0,s.jsx)(gt,{selectedCount:B.length,folders:h?.folders??[],onMove:t(e=>{Rs(e)},"onMove"),onCreateAndMove:t(()=>T(B),"onCreateAndMove"),onClear:t(()=>V([]),"onClear"),onDone:t(()=>{re(!1),V([])},"onDone")}):null,y.length===0?(0,s.jsx)("div",{className:"py-12",children:(0,s.jsx)(je,{icon:ee,message:"No active routines. Use Create routine to define the first recurring workflow."})}):D.length===0?(0,s.jsxs)("div",{className:"py-12",children:[(0,s.jsx)(je,{icon:ee,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,s.jsx)("div",{className:"mt-3 flex justify-center",children:(0,s.jsxs)(F,{size:"sm",onClick:$e,children:[(0,s.jsx)(Z,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,s.jsx)("div",{className:"flex flex-col gap-3",children:Ns.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,s.jsxs)(Ge,{open:r,onOpenChange:t(a=>{ge({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,s.jsx)(Ut,{label:e.label,count:e.items.length,isOpen:r}):null,(0,s.jsx)(We,{children:e.items.map(a=>(0,s.jsx)(It,{routine:a,projectById:E,agentById:U,runningRoutineId:us,statusMutationRoutineId:ms,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:Cs,onToggleEnabled:Ss,onToggleArchived:_s,selectMode:ne,selected:B.includes(a.id),onSelectChange:t((v,xe)=>{V(H=>xe?Array.from(new Set([...H,v.id])):H.filter(Fs=>Fs!==v.id))},"onSelectChange"),extraMenuItems:(0,s.jsx)(Nt,{folders:h?.folders??[],currentFolderId:a.folderId??null,onMove:t(v=>{const xe=a.folderId??null;qe.mutate({itemId:a.id,folderId:v}),i({title:"Routine moved",body:v?`Moved "${a.title}" to ${h?.folders.find(H=>H.id===v)?.name??"folder"}.`:`Moved "${a.title}" to Unfiled.`,tone:"success",action:{label:"Undo",onClick:t(()=>qe.mutate({itemId:a.id,folderId:xe}),"onClick")}})},"onMove"),onCreateAndMove:t(()=>T([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}):null,(0,s.jsx)(pt,{open:O,kind:"routine",folder:se,pending:De.isPending||ue.isPending,onOpenChange:K,onSubmit:t(e=>{se?ue.mutate({folderId:se.id,payload:e}):De.mutate(e)},"onSubmit")}),(0,s.jsx)(ft,{open:Q!==null,folder:Q,itemLabelPlural:"routines",pending:Te.isPending,onOpenChange:t(e=>{e||te(null)},"onOpenChange"),onConfirm:t(()=>{Q&&Te.mutate(Q.id)},"onConfirm")}),(0,s.jsx)(St,{open:ds,onOpenChange:Ne,result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:Y,onCreate:t(()=>T(),"onCreate")}),(0,s.jsx)($s,{open:k!==null,onOpenChange:t(e=>{e||ie(null)},"onOpenChange"),companyId:n,routineName:k?.title??null,agents:C??[],projects:S??[],defaultProjectId:k?.projectId??null,defaultAssigneeAgentId:k?.assigneeAgentId??null,variables:k?.variables??[],isPending:Ue.isPending,onSubmit:t(e=>{k&&Ue.mutate({id:k.id,data:e})},"onSubmit")})]}):(0,s.jsx)(je,{icon:ee,message:"Select a company to view routines."})}t(cn,"Routines");function Et({label:n,count:c}){return(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,s.jsx)(ee,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsx)("span",{className:"truncate font-medium",children:n}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[c," routine",c===1?"":"s"]})]})}t(Et,"FolderIconHeader");export{cn as Routines};
1
+ var ks=Object.defineProperty;var t=(n,c)=>ks(n,"name",{value:c,configurable:!0});import{i as as}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Ps,Lr as As,Pr as Ms,S as Ds,U as Ts,Y as m,nr as A,tr as _}from"./createLucideIcon-r3v6fbGz.js";import{B as ze,U as qs,b as Ks,ct as Us,o as Es}from"./router-Bb8nJWyv.js";import{Ct as Os,O as Ls,bt as Qs,cr as ls,gr as Bs,lr as ee,or as Ge,r as Vs,sr as We,t as $s,v as he,vt as Ye,wt as zs,xt as Gs,yt as Ws}from"./RoutineRunVariablesDialog-BdO_mZGp.js";import{l as J,t as Ys}from"./MarkdownEditor-Pip4OXiJ.js";import{t as He}from"./AgentAvatar-PT82VwmU.js";import{a as Hs,r as Js}from"./checkbox-CmMbs2PZ.js";import{n as Je,t as Xs}from"./tabs-DWRZjksg.js";import{a as Xe,c as Ze,r as es,t as Zs}from"./agents-BlSzFh-1.js";import{g as et}from"./StatusIcon-BuUYMqqU.js";import{r as st,t as je}from"./EmptyState-DPcc0zYh.js";import{t as tt}from"./check-DDiXDm2i.js";import{t as nt}from"./chevron-down-F9aZv-V7.js";import{t as cs}from"./chevron-right-B9JUOr38.js";import{c as ye,i as X,n as ve,s as be,t as we}from"./select-mS22eY6T.js";import{k as Z,t as F}from"./button-CAPbz11u.js";import{t as rt}from"./heartbeats-CK_aXmx5.js";import{i as it,o as ot}from"./company-members-BcZm1g8Q.js";import{r as at,t as lt}from"./card-dmVcp3AX.js";import{t as ct}from"./PageSkeleton-DHjTwRT3.js";import{$ as dt,$t as ut,J as mt,Q as pt,X as ft,Y as gt,Z as xt,at as ht,et as jt,fn as yt,ht as M,in as vt,it as bt,mt as wt,nt as Nt,pt as It,rn as Rt,rt as Ct,tt as St}from"./index-DhwreIEp.js";var l=as(As(),1),s=as(Ps(),1),_t=["coalesce_if_active","always_enqueue","skip_if_active"],Ft=["skip_missed","enqueue_missed_with_cap"],kt={coalesce_if_active:"If a run is already active, keep just one follow-up run queued.",always_enqueue:"Queue every trigger occurrence, even if the routine is already running.",skip_if_active:"Drop new trigger occurrences while a run is still active."},Pt={skip_missed:"Ignore windows that were missed while the scheduler or routine was paused.",enqueue_missed_with_cap:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."};function ss(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}t(ss,"autoResizeTextarea");var At="__built_in_routines",ts={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function ns(n){try{const c=localStorage.getItem(n);if(c)return{...ts,...JSON.parse(c)}}catch{}return{...ts}}t(ns,"getRoutineViewState");function Mt(n,c){localStorage.setItem(n,JSON.stringify(c))}t(Mt,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}t(q,"timestampValue");function rs(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}t(rs,"compareNullableText");function Dt(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}t(Dt,"buildRoutineMutationPayload");function Tt(n,c,d,b,g){if(c==="none")return[{key:"__all",label:null,items:n}];if(c==="folder"){const i=he(n,o=>o.folderId??"__unfiled");return Object.keys(i).sort((o,j)=>{if(o==="__unfiled"||j==="__unfiled")return o===j?0:o==="__unfiled"?1:-1;const w=g.get(o),I=g.get(j),O=(Number.isFinite(w?.position)?w.position:Number.POSITIVE_INFINITY)-(Number.isFinite(I?.position)?I.position:Number.POSITIVE_INFINITY);return O!==0?O:(w?.name??"Unknown folder").localeCompare(I?.name??"Unknown folder",void 0,{sensitivity:"base"})||o.localeCompare(j)}).map(o=>({key:o,label:o==="__unfiled"?"Unfiled":g.get(o)?.name??"Unknown folder",items:i[o]}))}if(c==="project"){const i=he(n,o=>o.projectId??"__no_project");return Object.keys(i).sort((o,j)=>{const w=o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",I=j==="__no_project"?"No project":d.get(j)?.name??"Unknown project";return w.localeCompare(I)}).map(o=>({key:o,label:o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",items:i[o]}))}const x=he(n,i=>i.assigneeAgentId??"__unassigned");return Object.keys(x).sort((i,o)=>{const j=i==="__unassigned"?"Unassigned":b.get(i)?.name??"Unknown agent",w=o==="__unassigned"?"Unassigned":b.get(o)?.name??"Unknown agent";return j.localeCompare(w)}).map(i=>({key:i,label:i==="__unassigned"?"Unassigned":b.get(i)?.name??"Unknown agent",items:x[i]}))}t(Tt,"buildRoutineGroups");function is(n){return n.originKind==="built_in_agent_bundle"}t(is,"isBuiltInRoutine");function qt(n,c,d,b,g){const x=n.filter(is),i=Tt(n.filter(o=>!is(o)),c,d,b,g).filter(o=>o.items.length>0).map(o=>x.length>0&&c==="none"&&o.key==="__all"?{...o,label:"Custom routines"}:o);return x.length===0?i:[...i,{key:At,label:"Built-in routines",items:x}]}t(qt,"buildRoutineSections");function Kt(n,c,d){const b=d==="asc"?1:-1;return[...n].sort((g,x)=>{let i=0;return c==="title"?i=rs(g.title,x.title):c==="created"?i=q(g.createdAt)-q(x.createdAt):c==="lastRun"?i=q(g.lastRun?.triggeredAt??g.lastTriggeredAt)-q(x.lastRun?.triggeredAt??x.lastTriggeredAt):i=q(g.updatedAt)-q(x.updatedAt),i!==0?i*b:rs(g.title,x.title)})}t(Kt,"sortRoutines");function os(n){return n==="runs"?"/routines?tab=runs":"/routines"}t(os,"buildRoutinesTabHref");function Ut({label:n,count:c,isOpen:d}){return(0,s.jsxs)("div",{className:`flex items-center gap-2 rounded-lg border border-border px-3 py-2${d?" mb-1":""}`,children:[(0,s.jsxs)(ls,{className:"flex items-center gap-1.5",children:[(0,s.jsx)(cs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-90"}),(0,s.jsx)("span",{className:"text-sm font-semibold uppercase tracking-wide",children:n})]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:c})]})}t(Ut,"RoutineSectionHeader");function cn(){const{selectedCompanyId:n}=Ts(),{setBreadcrumbs:c}=st(),d=Ms(),b=Es(),[g,x]=Us(),{pushToast:i}=yt(),o=(0,l.useRef)(null),j=(0,l.useRef)(null),w=(0,l.useRef)(null),I=(0,l.useRef)(null),[O,K]=(0,l.useState)(!1),[se,L]=(0,l.useState)(null),[Q,te]=(0,l.useState)(null),[ds,Ne]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[B,V]=(0,l.useState)([]),[Ie,Re]=(0,l.useState)([]),[us,Ce]=(0,l.useState)(null),[ms,Se]=(0,l.useState)(null),[k,ie]=(0,l.useState)(null),[$,z]=(0,l.useState)(!1),[_e,oe]=(0,l.useState)(!1),P=g.get("tab")==="runs"?"runs":"routines",[p,R]=(0,l.useState)({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),G=n?`paperclip:routines-view:${n}`:"paperclip:routines-view",[u,Fe]=(0,l.useState)(()=>ns(G)),f=bt(g.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{Fe(ns(G))},[G]);const{data:ke,isLoading:ps,error:ae}=A({queryKey:m.routines.list(n),queryFn:t(()=>J.list(n),"queryFn"),enabled:!!n}),{data:h,isLoading:Pe}=A({queryKey:m.folders.list(n,"routine"),queryFn:t(()=>M.list(n,"routine"),"queryFn"),enabled:!!n&&P==="routines"}),{data:C}=A({queryKey:m.agents.list(n),queryFn:t(()=>Zs.list(n),"queryFn"),enabled:!!n}),{data:S}=A({queryKey:m.projects.list(n,{includeArchived:!0}),queryFn:t(()=>et.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Ae}=A({queryKey:m.access.companyUserDirectory(n),queryFn:t(()=>ot.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:le,isLoading:fs,error:gs}=A({queryKey:[...m.issues.list(n),"routine-executions"],queryFn:t(()=>ze.list(n,{originKind:"routine_execution"}),"queryFn"),enabled:!!n&&P==="runs"}),Me=m.liveRuns(n),ce=vt({companyId:n,resourceKey:"live-runs",queryKey:Me,enabled:!!n&&P==="runs",refetchInterval:!1,leaderOnly:!0}),{data:de,dataUpdatedAt:xs}=A({queryKey:Me,queryFn:t(()=>rt.liveRunsForCompany(n),"queryFn"),enabled:ce.enabled,refetchInterval:ce.refetchInterval});Rt(ce,de,xs),(0,l.useEffect)(()=>{ss(j.current)},[p.title,$]);const hs=(0,l.useMemo)(()=>it({agents:C,projects:(S??[]).filter(e=>!e.archivedAt),members:Ae?.users}),[C,Ae?.users,S]),N=_({mutationFn:t(()=>J.create(n,Dt(p)),"mutationFn"),onSuccess:t(async e=>{R({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),z(!1),oe(!1),await d.invalidateQueries({queryKey:m.routines.list(n)}),i({title:"Routine created",body:e.assigneeAgentId?"Add the first trigger to turn it into a live workflow.":"Draft saved. Add a default agent before enabling automation.",tone:"success"}),b(`/routines/${e.id}?tab=triggers`)},"onSuccess")}),De=_({mutationFn:t(e=>M.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:t(async e=>{if(K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")}),Ie.length>0){const r=Ie;Re([]);try{await Promise.all(r.map(a=>M.moveItem(n,{kind:"routine",itemId:a,folderId:e.id}))),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])}catch(a){i({title:"Folder created, move failed",body:a instanceof Error?a.message:"Paperclip could not move the selected routines.",tone:"error"});return}}else Y(e.id);i({title:"Folder created",body:e.name,tone:"success"})},"onSuccess"),onError:t(e=>{i({title:"Failed to save folder",body:e instanceof Error?e.message:"Paperclip could not save the folder.",tone:"error"})},"onError")}),ue=_({mutationFn:t(({folderId:e,payload:r})=>M.update(n,e,r),"mutationFn"),onSuccess:t(async()=>{K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")})},"onSuccess"),onError:t(e=>{i({title:"Folder save failed",body:e instanceof Error?e.message:"Paperclip could not update the folder.",tone:"error"})},"onError")}),Te=_({mutationFn:t(e=>M.delete(n,e),"mutationFn"),onSuccess:t(async(e,r)=>{f===r&&Y("all"),te(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})]),i({title:"Folder deleted",body:"Items moved to Unfiled.",tone:"success"})},"onSuccess"),onError:t(e=>{i({title:"Folder delete failed",body:e instanceof Error?e.message:"Paperclip could not delete the folder.",tone:"error"})},"onError")}),qe=_({mutationFn:t(({itemId:e,folderId:r})=>M.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:t(async()=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])},"onSuccess"),onError:t(e=>{i({title:"Move failed",body:e instanceof Error?e.message:"Paperclip could not move the routine.",tone:"error"})},"onError")}),js=_({mutationFn:t(({id:e,data:r})=>ze.update(e,r),"mutationFn"),onSuccess:t(async()=>{await d.invalidateQueries({queryKey:[...m.issues.list(n),"routine-executions"]})},"onSuccess")}),Ke=_({mutationFn:t(({id:e,status:r})=>J.update(e,{status:r}),"mutationFn"),onMutate:t(({id:e})=>{Se(e)},"onMutate"),onSuccess:t(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r.id)})])},"onSuccess"),onSettled:t(()=>{Se(null)},"onSettled"),onError:t(e=>{i({title:"Failed to update routine",body:e instanceof Error?e.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Ue=_({mutationFn:t(({id:e,data:r})=>J.run(e,{...r?.variables&&Object.keys(r.variables).length>0?{variables:r.variables}:{},...r?.assigneeAgentId!==void 0?{assigneeAgentId:r.assigneeAgentId}:{},...r?.projectId!==void 0?{projectId:r.projectId}:{},...r?.executionWorkspaceId!==void 0?{executionWorkspaceId:r.executionWorkspaceId}:{},...r?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:r.executionWorkspacePreference}:{},...r?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:r.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:t(({id:e})=>{Ce(e)},"onMutate"),onSuccess:t(async(e,{id:r})=>{ie(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r)})])},"onSuccess"),onSettled:t(()=>{Ce(null)},"onSettled"),onError:t(e=>{i({title:"Routine run failed",body:e instanceof Error?e.message:"Paperclip could not start the routine run.",tone:"error"})},"onError")}),me=(0,l.useMemo)(()=>Gs(),[$]),ys=(0,l.useMemo)(()=>Ws(),[$]),vs=(0,l.useMemo)(()=>Os((C??[]).filter(e=>e.status!=="terminated"),me).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[C,me]),bs=(0,l.useMemo)(()=>(S??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[S]),U=(0,l.useMemo)(()=>new Map((C??[]).map(e=>[e.id,e])),[C]),E=(0,l.useMemo)(()=>new Map((S??[]).map(e=>[e.id,e])),[S]),Ee=(0,l.useMemo)(()=>new Map((h?.folders??[]).map(e=>[e.id,e])),[h]),ws=(0,l.useMemo)(()=>Ls(de,le),[de,le]),y=(0,l.useMemo)(()=>(ke??[]).filter(e=>e.status!=="archived"),[ke]),Oe=(0,l.useMemo)(()=>u.groupBy!=="folder"||f==="all"?y:f==="unfiled"?y.filter(e=>!e.folderId):y.filter(e=>e.folderId===f),[f,u.groupBy,y]),pe=(0,l.useMemo)(()=>{if(!h)return h;const e=new Map;let r=0;for(const a of y)a.folderId?e.set(a.folderId,(e.get(a.folderId)??0)+1):r+=1;return{...h,allCount:y.length,unfiledCount:r,folders:h.folders.map(a=>({...a,itemCount:e.get(a.id)??0}))}},[h,y]),D=(0,l.useMemo)(()=>Kt(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),Ns=(0,l.useMemo)(()=>qt(D,u.groupBy,E,U,Ee),[U,Ee,E,u.groupBy,D]),Is=(0,l.useMemo)(()=>qs("Recent Runs",os("runs"),"issues"),[]),Le=p.assigneeAgentId?U.get(p.assigneeAgentId)??null:null,Qe=p.projectId?E.get(p.projectId)??null:null,Be=ht(h?.folders??[],f),W=(h?.folders.length??0)>0,fe=P==="routines"&&u.groupBy==="folder"&&W;function ge(e){Fe(r=>{const a={...r,...e};return Mt(G,a),a})}t(ge,"updateRoutineView");function Ve(e){const r=e==="runs"?"runs":"routines";(0,l.startTransition)(()=>{b(os(r))})}t(Ve,"handleTabChange");function Y(e){x(r=>{const a=new URLSearchParams(r),v=Ct(e);return v?a.set("folder",v):a.delete("folder"),a})}t(Y,"setFolderSelection");function T(e=[]){Re(e),L(null),K(!0)}t(T,"openCreateFolder");function $e(){R(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),z(!0)}t($e,"openCreateRoutine");async function Rs(e){const r=B;if(r.length!==0)try{await Promise.all(r.map(a=>M.moveItem(n,{kind:"routine",itemId:a,folderId:e}))),V([]),re(!1),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})]),i({title:"Routines moved",body:`${r.length} routine${r.length===1?"":"s"} filed.`,tone:"success"})}catch(a){i({title:"Failed to move routines",body:a instanceof Error?a.message:"Paperclip could not move the selected routines.",tone:"error"})}}t(Rs,"moveSelectedRoutines");function Cs(e){ie(e)}t(Cs,"handleRunNow");function Ss(e,r){if(!r&&!e.assigneeAgentId){i({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}Ke.mutate({id:e.id,status:wt(e.status,!r)})}t(Ss,"handleToggleEnabled");function _s(e){Ke.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return t(_s,"handleToggleArchived"),n?ps?(0,s.jsx)(ct,{variant:"issues-list"}):(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Routines"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,s.jsxs)(F,{onClick:$e,children:[(0,s.jsx)(Z,{className:"mr-2 h-4 w-4"}),"Create routine"]})]}),(0,s.jsxs)(Xs,{value:P,onValueChange:Ve,children:[(0,s.jsx)(ut,{align:"start",value:P,onValueChange:Ve,items:[{value:"routines",label:"Routines"},{value:"runs",label:"Recent Runs"}]}),(0,s.jsxs)(Je,{value:"routines",className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:[y.length," routine",y.length===1?"":"s"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsxs)(es,{children:[(0,s.jsx)(Ze,{asChild:!0,children:(0,s.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,s.jsx)(Bs,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,s.jsx)(Xe,{align:"end",className:"w-44 p-0",children:(0,s.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,s.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.sortField===e?"bg-accent/50 text-foreground":"text-muted-foreground hover:bg-accent/50"}`,onClick:t(()=>{ge(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,s.jsx)("span",{children:r}),u.sortField===e?(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,s.jsxs)(es,{children:[(0,s.jsx)(Ze,{asChild:!0,children:(0,s.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,s.jsx)(Ks,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,s.jsx)(Xe,{align:"end",className:"w-44 p-0",children:(0,s.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,s.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.groupBy===e?"bg-accent/50 text-foreground":"text-muted-foreground hover:bg-accent/50"}`,onClick:t(()=>ge({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,s.jsx)("span",{children:r}),u.groupBy===e?(0,s.jsx)(tt,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!W?(0,s.jsxs)(F,{variant:"outline",size:"sm",onClick:t(()=>T(),"onClick"),children:[(0,s.jsx)(Z,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,fe?(0,s.jsx)(F,{variant:"ghost",size:"sm",className:"text-xs",onClick:t(()=>re(e=>!e),"onClick"),children:ne?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,s.jsx)("div",{className:"md:hidden",children:(0,s.jsx)(xt,{result:pe,selection:f,allLabel:"All routines",onClick:t(()=>Ne(!0),"onClick")})}):null]}),(0,s.jsx)(Je,{value:"runs",children:(0,s.jsx)(Vs,{issues:le??[],isLoading:fs,error:gs,agents:C,projects:S,liveIssueIds:ws,viewStateKey:"paperclip:routine-recent-runs-view",issueLinkState:Is,onUpdateIssue:t((e,r)=>js.mutate({id:e,data:r}),"onUpdateIssue")})})]}),(0,s.jsx)(Js,{open:$,onOpenChange:t(e=>{N.isPending||z(e)},"onOpenChange"),children:(0,s.jsxs)(Hs,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,s.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-3 border-b border-border/60 px-5 py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"New routine"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,s.jsx)(F,{variant:"ghost",size:"sm",onClick:t(()=>{z(!1),oe(!1)},"onClick"),disabled:N.isPending,children:"Cancel"})]}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,s.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,s.jsx)("textarea",{ref:j,className:"w-full resize-none overflow-hidden bg-transparent text-xl font-semibold outline-none placeholder:text-muted-foreground/50",placeholder:"Routine title",rows:1,value:p.title,onChange:t(e=>{R(r=>({...r,title:e.target.value})),ss(e.target)},"onChange"),onKeyDown:t(e=>{if(e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing){e.preventDefault(),o.current?.focus();return}e.key==="Tab"&&!e.shiftKey&&(e.preventDefault(),p.assigneeAgentId?p.projectId?o.current?.focus():I.current?.focus():w.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,s.jsx)("div",{className:"px-5 pb-3",children:(0,s.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,s.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap",children:[(0,s.jsx)("span",{children:"For"}),(0,s.jsx)(Ye,{ref:w,value:p.assigneeAgentId,options:vs,recentOptionIds:me,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:t(e=>{e&&zs(e),R(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:t(()=>{p.projectId?o.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:t(e=>e?Le?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(He,{agent:Le,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"truncate",children:e.label})]}):(0,s.jsx)("span",{className:"truncate",children:e.label}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:t(e=>{if(!e.id)return(0,s.jsx)("span",{className:"truncate",children:e.label});const r=U.get(e.id);return(0,s.jsxs)(s.Fragment,{children:[r?(0,s.jsx)(He,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,s.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,s.jsx)("span",{children:"in"}),(0,s.jsx)(Ye,{ref:I,value:p.projectId,options:bs,recentOptionIds:ys,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:t(e=>{e&&Qs(e),R(r=>({...r,projectId:e}))},"onChange"),onConfirm:t(()=>o.current?.focus(),"onConfirm"),renderTriggerValue:t(e=>e&&Qe?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Qe.color??"var(--project-none)"}}),(0,s.jsx)("span",{className:"truncate",children:e.label})]}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:t(e=>{if(!e.id)return(0,s.jsx)("span",{className:"truncate",children:e.label});const r=E.get(e.id);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,s.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,s.jsx)("span",{children:"filed in"}),(0,s.jsxs)(we,{value:p.folderId??"__unfiled",onValueChange:t(e=>R(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,s.jsx)(be,{className:"h-8 w-auto min-w-32 border-0 bg-muted/50 px-2 shadow-none",children:(0,s.jsx)(ye,{})}),(0,s.jsxs)(ve,{children:[(0,s.jsx)(X,{value:"__unfiled",children:"Unfiled"}),(h?.folders??[]).map(e=>(0,s.jsx)(X,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,s.jsx)("div",{className:"border-t border-border/60 px-5 py-4",children:(0,s.jsx)(Ys,{ref:o,value:p.description,onChange:t(e=>R(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-muted-foreground",mentions:hs,onSubmit:t(()=>{!N.isPending&&p.title.trim()&&p.projectId&&p.assigneeAgentId&&N.mutate()},"onSubmit")})}),(0,s.jsx)("div",{className:"border-t border-border/60 px-5 py-3",children:(0,s.jsxs)(Ge,{open:_e,onOpenChange:oe,children:[(0,s.jsxs)(ls,{className:"flex w-full items-center justify-between text-left",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Keep policy controls secondary to the work definition."})]}),_e?(0,s.jsx)(nt,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(cs,{className:"h-4 w-4 text-muted-foreground"})]}),(0,s.jsx)(We,{className:"pt-3",children:(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,s.jsxs)(we,{value:p.concurrencyPolicy,onValueChange:t(e=>R(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{})}),(0,s.jsx)(ve,{children:_t.map(e=>(0,s.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:kt[p.concurrencyPolicy]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,s.jsxs)(we,{value:p.catchUpPolicy,onValueChange:t(e=>R(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{})}),(0,s.jsx)(ve,{children:Ft.map(e=>(0,s.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:Pt[p.catchUpPolicy]})]})]})})]})})]}),(0,s.jsxs)("div",{className:"shrink-0 flex flex-col gap-3 border-t border-border/60 px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:"After creation, Paperclip takes you straight to trigger setup. Draft routines stay paused until you add a default agent."}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,s.jsxs)(F,{onClick:t(()=>N.mutate(),"onClick"),disabled:N.isPending||!p.title.trim(),children:[(0,s.jsx)(Z,{className:"mr-2 h-4 w-4"}),N.isPending?"Creating...":"Create routine"]}),N.isError?(0,s.jsx)("p",{className:"text-sm text-destructive",children:N.error instanceof Error?N.error.message:"Failed to create routine"}):null]})]})]})}),ae?(0,s.jsx)(lt,{children:(0,s.jsx)(at,{className:"pt-6 text-sm text-destructive",children:ae instanceof Error?ae.message:"Failed to load routines"})}):null,P==="routines"?(0,s.jsxs)("div",{className:Ds(fe&&"flex gap-4"),children:[fe?(0,s.jsx)(dt,{result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Pe,onSelect:Y,onCreate:t(()=>T(),"onCreate"),onRename:t((e,r)=>ue.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:t(e=>{L(e),K(!0)},"onEdit"),onDelete:te}):null,(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&W?(0,s.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,s.jsx)(Et,{label:"All routines",count:D.length}):(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,s.jsx)(jt,{color:Be?.color}),(0,s.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Be?.name??"Folder"}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[D.length," routine",D.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!W&&!Pe&&y.length>0?(0,s.jsx)(mt,{storageKey:`paperclip:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:t(()=>T(),"onCreateFolder")}):null,ne?(0,s.jsx)(gt,{selectedCount:B.length,folders:h?.folders??[],onMove:t(e=>{Rs(e)},"onMove"),onCreateAndMove:t(()=>T(B),"onCreateAndMove"),onClear:t(()=>V([]),"onClear"),onDone:t(()=>{re(!1),V([])},"onDone")}):null,y.length===0?(0,s.jsx)("div",{className:"py-12",children:(0,s.jsx)(je,{icon:ee,message:"No active routines. Use Create routine to define the first recurring workflow."})}):D.length===0?(0,s.jsxs)("div",{className:"py-12",children:[(0,s.jsx)(je,{icon:ee,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,s.jsx)("div",{className:"mt-3 flex justify-center",children:(0,s.jsxs)(F,{size:"sm",onClick:$e,children:[(0,s.jsx)(Z,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,s.jsx)("div",{className:"flex flex-col gap-3",children:Ns.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,s.jsxs)(Ge,{open:r,onOpenChange:t(a=>{ge({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,s.jsx)(Ut,{label:e.label,count:e.items.length,isOpen:r}):null,(0,s.jsx)(We,{children:e.items.map(a=>(0,s.jsx)(It,{routine:a,projectById:E,agentById:U,runningRoutineId:us,statusMutationRoutineId:ms,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:Cs,onToggleEnabled:Ss,onToggleArchived:_s,selectMode:ne,selected:B.includes(a.id),onSelectChange:t((v,xe)=>{V(H=>xe?Array.from(new Set([...H,v.id])):H.filter(Fs=>Fs!==v.id))},"onSelectChange"),extraMenuItems:(0,s.jsx)(Nt,{folders:h?.folders??[],currentFolderId:a.folderId??null,onMove:t(v=>{const xe=a.folderId??null;qe.mutate({itemId:a.id,folderId:v}),i({title:"Routine moved",body:v?`Moved "${a.title}" to ${h?.folders.find(H=>H.id===v)?.name??"folder"}.`:`Moved "${a.title}" to Unfiled.`,tone:"success",action:{label:"Undo",onClick:t(()=>qe.mutate({itemId:a.id,folderId:xe}),"onClick")}})},"onMove"),onCreateAndMove:t(()=>T([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}):null,(0,s.jsx)(pt,{open:O,kind:"routine",folder:se,pending:De.isPending||ue.isPending,onOpenChange:K,onSubmit:t(e=>{se?ue.mutate({folderId:se.id,payload:e}):De.mutate(e)},"onSubmit")}),(0,s.jsx)(ft,{open:Q!==null,folder:Q,itemLabelPlural:"routines",pending:Te.isPending,onOpenChange:t(e=>{e||te(null)},"onOpenChange"),onConfirm:t(()=>{Q&&Te.mutate(Q.id)},"onConfirm")}),(0,s.jsx)(St,{open:ds,onOpenChange:Ne,result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:Y,onCreate:t(()=>T(),"onCreate")}),(0,s.jsx)($s,{open:k!==null,onOpenChange:t(e=>{e||ie(null)},"onOpenChange"),companyId:n,routineName:k?.title??null,agents:C??[],projects:S??[],defaultProjectId:k?.projectId??null,defaultAssigneeAgentId:k?.assigneeAgentId??null,variables:k?.variables??[],isPending:Ue.isPending,onSubmit:t(e=>{k&&Ue.mutate({id:k.id,data:e})},"onSubmit")})]}):(0,s.jsx)(je,{icon:ee,message:"Select a company to view routines."})}t(cn,"Routines");function Et({label:n,count:c}){return(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,s.jsx)(ee,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsx)("span",{className:"truncate font-medium",children:n}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[c," routine",c===1?"":"s"]})]})}t(Et,"FolderIconHeader");export{cn as Routines};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var n=(e,o)=>c(e,"name",{value:o,configurable:!0});import{zt as p}from"./index-CZl9vxyj.js";import{PAPERCLIP_CHARACTER as a}from"./character-CguPM7IG.js";import{o as l,r as f}from"./model-DL5biheO.js";function b(e,o=!1){const r=p[o?"muted-dream":e.paletteId],i={...a.character,id:"paperclip-cap-v1",name:"Agent",color:r.a,color2:r.b,followCursor:!0,followRotation:!0},s=f({version:1,name:"Paperclip",characters:[i],expressions:a.expressions,animations:a.animations},i);for(const t of s.animations)t.id==="happy"&&(t.loop=!1);return s}n(b,"characterDefinition");function d(e){return e==="success"?"happy":e==="rest"?"idle":e}n(d,"animationId");function C(e,o){if(o==="rest"){const r=e.expressions.find(i=>i.id==="idle")??e.expressions[0];return{pose:{...r.beats[0].pose},blink:0,bob:0,breathe:0,expressionId:r.id,beatIndex:0,stepIndex:0,faceLayers:void 0}}return l(e,d(o),.6)}n(C,"characterStill");export{d as animationId,b as characterDefinition,C as characterStill};
1
+ var c=Object.defineProperty;var n=(e,o)=>c(e,"name",{value:o,configurable:!0});import{zt as p}from"./index-DhwreIEp.js";import{PAPERCLIP_CHARACTER as a}from"./character-CguPM7IG.js";import{o as l,r as f}from"./model-DL5biheO.js";function b(e,o=!1){const r=p[o?"muted-dream":e.paletteId],i={...a.character,id:"paperclip-cap-v1",name:"Agent",color:r.a,color2:r.b,followCursor:!0,followRotation:!0},s=f({version:1,name:"Paperclip",characters:[i],expressions:a.expressions,animations:a.animations},i);for(const t of s.animations)t.id==="happy"&&(t.loop=!1);return s}n(b,"characterDefinition");function d(e){return e==="success"?"happy":e==="rest"?"idle":e}n(d,"animationId");function C(e,o){if(o==="rest"){const r=e.expressions.find(i=>i.id==="idle")??e.expressions[0];return{pose:{...r.beats[0].pose},blink:0,bob:0,breathe:0,expressionId:r.id,beatIndex:0,stepIndex:0,faceLayers:void 0}}return l(e,d(o),.6)}n(C,"characterStill");export{d as animationId,b as characterDefinition,C as characterStill};