@tickernelz/paperclip-pro-ui 2026.1105.0 → 2026.1105.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.
Files changed (70) hide show
  1. package/dist/assets/{AgentAvatar-CvyykZ_o.js → AgentAvatar-BWS01ZkH.js} +1 -1
  2. package/dist/assets/{Agents.production-DUI6AhwG.js → Agents.production-D03SSBGv.js} +2 -2
  3. package/dist/assets/{BreadcrumbContext-BdR2QZTG.js → BreadcrumbContext-Cl4wMUsK.js} +2 -2
  4. package/dist/assets/{CompanyActivity.production-D6dcprLq.js → CompanyActivity.production-DrCR5HhS.js} +1 -1
  5. package/dist/assets/{CompanyExport-gCQ-_PJI.js → CompanyExport-CRqd3hdC.js} +4 -4
  6. package/dist/assets/{CompanySkills.production-BA5OJ0hH.js → CompanySkills.production-D1JBBrk8.js} +1 -1
  7. package/dist/assets/{EmptyState-COTvzeWR.js → EmptyState-Dx8V6QjR.js} +1 -1
  8. package/dist/assets/{MarkdownBody-C1YBAJse.js → MarkdownBody-CKjAuE4c.js} +10 -10
  9. package/dist/assets/{MarkdownEditor-DCjWqjUr.js → MarkdownEditor-NZR4Qf3U.js} +2 -2
  10. package/dist/assets/{OrgChart.production-gtlqn5p2.js → OrgChart.production-Gjcjo5EY.js} +1 -1
  11. package/dist/assets/{PageSkeleton-BF2o9r1d.js → PageSkeleton-DZf26yvt.js} +1 -1
  12. package/dist/assets/{RoutineDetail.production-BGGd4_si.js → RoutineDetail.production-Ds2LF2zN.js} +1 -1
  13. package/dist/assets/{RoutineRunVariablesDialog-BH0cvoTO.js → RoutineRunVariablesDialog-DO5rvO25.js} +2 -2
  14. package/dist/assets/{Routines.production-zUQqy5oH.js → Routines.production-Cx6d5IGv.js} +1 -1
  15. package/dist/assets/{SearchableSelect-Bx1Kt-dp.js → SearchableSelect-Ced5RHuX.js} +2 -2
  16. package/dist/assets/{StatusIcon-_JGOqNQ3.js → StatusIcon-pBJPno3c.js} +1 -1
  17. package/dist/assets/{Terminal-Cstwn3GT.js → Terminal-B3Qfu2KE.js} +1 -1
  18. package/dist/assets/{ToastContext-GEapFtzb.js → ToastContext-Dizyilik.js} +1 -1
  19. package/dist/assets/{access-Xsz-Z8Lm.js → access-BcnCBDzu.js} +1 -1
  20. package/dist/assets/agent-avatar-url-bgxGDA14.js +1 -0
  21. package/dist/assets/{agents-D-qAkJZt.js → agents-Bomtc4Gj.js} +1 -1
  22. package/dist/assets/{alert-dialog-C78v0zDA.js → alert-dialog-fzWNOiQO.js} +1 -1
  23. package/dist/assets/{arrow-right-DNfKtTnU.js → arrow-right-eBIr-GqF.js} +1 -1
  24. package/dist/assets/{badge-BKd5IdYw.js → badge-DxM54O3R.js} +1 -1
  25. package/dist/assets/{bot-5n6nYPlO.js → bot-BR-QgiZy.js} +1 -1
  26. package/dist/assets/{boxes-DcYq-jCc.js → boxes-ULGOWIM3.js} +23 -23
  27. package/dist/assets/card-BhMgl8Q2.js +1 -0
  28. package/dist/assets/{check-2qo6ZJ2G.js → check-Cp2wC8NS.js} +1 -1
  29. package/dist/assets/{checkbox-BWE2L3Gp.js → checkbox-DsJMjAvZ.js} +1 -1
  30. package/dist/assets/{chevron-down-BiI_5EGy.js → chevron-down-C_fR6OOJ.js} +1 -1
  31. package/dist/assets/{clipboard-Bi4egf3Q.js → clipboard-CWwu6L5N.js} +1 -1
  32. package/dist/assets/{definition-CdfMs8VB.js → definition-CaNofzV7.js} +1 -1
  33. package/dist/assets/{dialog-Be3BfHbu.js → dialog-TATv1tMA.js} +1 -1
  34. package/dist/assets/{dist-FV5ug9Gh.js → dist-A0YYaVdk.js} +1 -1
  35. package/dist/assets/dist-B-mU0PGy.js +1 -0
  36. package/dist/assets/{dist-D_GJjr4Y.js → dist-ZK4xjvL5.js} +1 -1
  37. package/dist/assets/{dist-DTju_OGk.js → dist-yoBwUYD5.js} +1 -1
  38. package/dist/assets/{dist-DEpI4MsF.js → dist-znXZiTst.js} +1 -1
  39. package/dist/assets/{environments-BZZFtpSV.js → environments-DaM8ILkn.js} +1 -1
  40. package/dist/assets/{external-link-DWz359_G.js → external-link-mMZBQJwa.js} +1 -1
  41. package/dist/assets/{file-text--r-wpJ-x.js → file-text-CdvtdG1n.js} +1 -1
  42. package/dist/assets/{health-DdYtGPqQ.js → health-mJcWjdCt.js} +1 -1
  43. package/dist/assets/heartbeats-ztXAfZg0.js +1 -0
  44. package/dist/assets/{index-C4vuH91F.js → index-BguRK-v5.js} +168 -168
  45. package/dist/assets/index-z-u6YSeu.css +1 -0
  46. package/dist/assets/{input-BUMo9M0E.js → input-BQM7zHN-.js} +1 -1
  47. package/dist/assets/{instanceSettings-C15rYV4N.js → instanceSettings-DJ1sCOe_.js} +1 -1
  48. package/dist/assets/{label-DxRcxQw2.js → label-CD3JYREq.js} +1 -1
  49. package/dist/assets/{mention-chips-BeL0ezh9.js → mention-chips-D7R-Mj-z.js} +2 -2
  50. package/dist/assets/{rotate-ccw-Cvm9Gwuw.js → rotate-ccw-DC6SGN6w.js} +1 -1
  51. package/dist/assets/{save-BfH6Olgf.js → save-BlsYwJ6r.js} +1 -1
  52. package/dist/assets/{select-DpNDmO-G.js → select-BilSqzhf.js} +1 -1
  53. package/dist/assets/{sheet-D80ckd0R.js → sheet-3Iwj58gb.js} +1 -1
  54. package/dist/assets/{skeleton-8ry9j5Fi.js → skeleton-CMrd-HIy.js} +1 -1
  55. package/dist/assets/{tabs-wYrBE8R2.js → tabs-C9VkqVBk.js} +1 -1
  56. package/dist/assets/{use-adapter-capabilities-BvfYABSN.js → use-adapter-capabilities-Dqf69muf.js} +1 -1
  57. package/dist/assets/{useHiddenSettings-NiFytxe3.js → useHiddenSettings-BQrk89aT.js} +1 -1
  58. package/dist/assets/{usePrefersReducedMotion-DxMMBfvJ.js → usePrefersReducedMotion-C6h9ns9_.js} +1 -1
  59. package/dist/assets/{x-C7r-gM7x.js → x-CPM6OYGf.js} +1 -1
  60. package/dist/downloads/local-browser-chromium.zip +0 -0
  61. package/dist/downloads/local-browser-firefox-unsigned.zip +0 -0
  62. package/dist/downloads/local-browser-firefox.xpi +0 -0
  63. package/dist/index.html +50 -50
  64. package/dist/sw.js +1 -1
  65. package/package.json +1 -1
  66. package/dist/assets/agent-avatar-url-B_0YMMar.js +0 -1
  67. package/dist/assets/card-XuMW7HM-.js +0 -1
  68. package/dist/assets/dist-DdELVTA2.js +0 -1
  69. package/dist/assets/heartbeats-BpBzZUnr.js +0 -1
  70. package/dist/assets/index-DeHHR47K.css +0 -1
@@ -1 +1 @@
1
- var kt=Object.defineProperty;var s=(n,c)=>kt(n,"name",{value:c,configurable:!0});import{i as at}from"./rolldown-runtime-ZpX3ckPj.js";import{G as Pt,Qa as At,St as m,Za as Mt,_a as S,eo as Dt,ht as Tt,va as A}from"./boxes-DcYq-jCc.js";import{Bn as qt,Vt as ze,Wt as Ge,d as Kt,fn as Et,ln as We,n as Ut,pt as Ot,r as F,st as J,zt as Ye}from"./BreadcrumbContext-BdR2QZTG.js";import{_ as He,v as Je,y as lt}from"./SearchableSelect-Bx1Kt-dp.js";import{Ft as Lt,It as Qt,Mt as Bt,Nr as ee,Nt as Vt,Rr as $t,V as zt,jt as Gt,r as Wt,t as Yt,wt as Xe,x as he}from"./RoutineRunVariablesDialog-BH0cvoTO.js";import{t as Ze}from"./AgentAvatar-CvyykZ_o.js";import{r as Ht,t as Jt}from"./dialog-Be3BfHbu.js";import{l as X,t as Xt}from"./MarkdownEditor-DCjWqjUr.js";import{n as et,t as Zt}from"./tabs-wYrBE8R2.js";import{h as es}from"./StatusIcon-_JGOqNQ3.js";import{t as ts}from"./check-2qo6ZJ2G.js";import{t as ss}from"./chevron-down-BiI_5EGy.js";import{a as ct}from"./clipboard-Bi4egf3Q.js";import{a as Z,c as je,l as ye,n as ve,r as be}from"./select-DpNDmO-G.js";import{t as ns}from"./heartbeats-BpBzZUnr.js";import{a as rs}from"./ToastContext-GEapFtzb.js";import{t as os}from"./agents-D-qAkJZt.js";import{t as is}from"./access-Xsz-Z8Lm.js";import{i as as}from"./company-members-Duugb3uG.js";import{r as ls,t as cs}from"./card-XuMW7HM-.js";import{t as we}from"./EmptyState-COTvzeWR.js";import{t as ds}from"./PageSkeleton-BF2o9r1d.js";import{$ as us,$t as ms,G as ps,J as fs,K as gs,Q as xs,X as hs,Xt as js,Y as ys,Z as vs,dt as bs,en as ws,et as Ns,ft as M,nt as Is,q as Rs,tt as _s,ut as Cs}from"./index-C4vuH91F.js";var l=at(Dt(),1),t=at(At(),1),Ss=["coalesce_if_active","always_enqueue","skip_if_active"],Fs=["skip_missed","enqueue_missed_with_cap"],ks={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."},Ps={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 tt(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}s(tt,"autoResizeTextarea");var As="__built_in_routines",st={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function nt(n){try{const c=localStorage.getItem(n);if(c)return{...st,...JSON.parse(c)}}catch{}return{...st}}s(nt,"getRoutineViewState");function Ms(n,c){localStorage.setItem(n,JSON.stringify(c))}s(Ms,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}s(q,"timestampValue");function rt(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}s(rt,"compareNullableText");function Ds(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}s(Ds,"buildRoutineMutationPayload");function Ts(n,c,d,b,g){if(c==="none")return[{key:"__all",label:null,items:n}];if(c==="folder"){const o=he(n,i=>i.folderId??"__unfiled");return Object.keys(o).sort((i,j)=>{if(i==="__unfiled"||j==="__unfiled")return i===j?0:i==="__unfiled"?1:-1;const w=g.get(i),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"})||i.localeCompare(j)}).map(i=>({key:i,label:i==="__unfiled"?"Unfiled":g.get(i)?.name??"Unknown folder",items:o[i]}))}if(c==="project"){const o=he(n,i=>i.projectId??"__no_project");return Object.keys(o).sort((i,j)=>{const w=i==="__no_project"?"No project":d.get(i)?.name??"Unknown project",I=j==="__no_project"?"No project":d.get(j)?.name??"Unknown project";return w.localeCompare(I)}).map(i=>({key:i,label:i==="__no_project"?"No project":d.get(i)?.name??"Unknown project",items:o[i]}))}const x=he(n,o=>o.assigneeAgentId??"__unassigned");return Object.keys(x).sort((o,i)=>{const j=o==="__unassigned"?"Unassigned":b.get(o)?.name??"Unknown agent",w=i==="__unassigned"?"Unassigned":b.get(i)?.name??"Unknown agent";return j.localeCompare(w)}).map(o=>({key:o,label:o==="__unassigned"?"Unassigned":b.get(o)?.name??"Unknown agent",items:x[o]}))}s(Ts,"buildRoutineGroups");function ot(n){return n.originKind==="built_in_agent_bundle"}s(ot,"isBuiltInRoutine");function qs(n,c,d,b,g){const x=n.filter(ot),o=Ts(n.filter(i=>!ot(i)),c,d,b,g).filter(i=>i.items.length>0).map(i=>x.length>0&&c==="none"&&i.key==="__all"?{...i,label:"Custom routines"}:i);return x.length===0?o:[...o,{key:As,label:"Built-in routines",items:x}]}s(qs,"buildRoutineSections");function Ks(n,c,d){const b=d==="asc"?1:-1;return[...n].sort((g,x)=>{let o=0;return c==="title"?o=rt(g.title,x.title):c==="created"?o=q(g.createdAt)-q(x.createdAt):c==="lastRun"?o=q(g.lastRun?.triggeredAt??g.lastTriggeredAt)-q(x.lastRun?.triggeredAt??x.lastTriggeredAt):o=q(g.updatedAt)-q(x.updatedAt),o!==0?o*b:rt(g.title,x.title)})}s(Ks,"sortRoutines");function it(n){return n==="runs"?"/routines?tab=runs":"/routines"}s(it,"buildRoutinesTabHref");function Es({label:n,count:c,isOpen:d}){return(0,t.jsxs)("div",{className:`flex items-center gap-2 rounded-lg border border-border px-3 py-2${d?" mb-1":""}`,children:[(0,t.jsxs)(lt,{className:"flex items-center gap-1.5",children:[(0,t.jsx)(ct,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-90"}),(0,t.jsx)("span",{className:"text-sm font-semibold uppercase tracking-wide",children:n})]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:c})]})}s(Es,"RoutineSectionHeader");function un(){const{selectedCompanyId:n}=Tt(),{setBreadcrumbs:c}=Ut(),d=Mt(),b=Kt(),[g,x]=qt(),{pushToast:o}=rs(),i=(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),[te,L]=(0,l.useState)(null),[Q,se]=(0,l.useState)(null),[dt,Ne]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[B,V]=(0,l.useState)([]),[Ie,Re]=(0,l.useState)([]),[ut,_e]=(0,l.useState)(null),[mt,Ce]=(0,l.useState)(null),[k,oe]=(0,l.useState)(null),[$,z]=(0,l.useState)(!1),[Se,ie]=(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)(()=>nt(G)),f=_s(g.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{Fe(nt(G))},[G]);const{data:ke,isLoading:pt,error:ae}=A({queryKey:m.routines.list(n),queryFn:s(()=>X.list(n),"queryFn"),enabled:!!n}),{data:h,isLoading:Pe}=A({queryKey:m.folders.list(n,"routine"),queryFn:s(()=>M.list(n,"routine"),"queryFn"),enabled:!!n&&P==="routines"}),{data:_}=A({queryKey:m.agents.list(n),queryFn:s(()=>os.list(n),"queryFn"),enabled:!!n}),{data:C}=A({queryKey:m.projects.list(n,{includeArchived:!0}),queryFn:s(()=>es.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Ae}=A({queryKey:m.access.companyUserDirectory(n),queryFn:s(()=>is.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:le,isLoading:ft,error:gt}=A({queryKey:[...m.issues.list(n),"routine-executions"],queryFn:s(()=>We.list(n,{originKind:"routine_execution"}),"queryFn"),enabled:!!n&&P==="runs"}),Me=m.liveRuns(n),ce=ws({companyId:n,resourceKey:"live-runs",queryKey:Me,enabled:!!n&&P==="runs",refetchInterval:!1,leaderOnly:!0}),{data:de,dataUpdatedAt:xt}=A({queryKey:Me,queryFn:s(()=>ns.liveRunsForCompany(n),"queryFn"),enabled:ce.enabled,refetchInterval:ce.refetchInterval});ms(ce,de,xt),(0,l.useEffect)(()=>{tt(j.current)},[p.title,$]);const ht=(0,l.useMemo)(()=>as({agents:_,projects:(C??[]).filter(e=>!e.archivedAt),members:Ae?.users}),[_,Ae?.users,C]),N=S({mutationFn:s(()=>X.create(n,Ds(p)),"mutationFn"),onSuccess:s(async e=>{R({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),z(!1),ie(!1),await d.invalidateQueries({queryKey:m.routines.list(n)}),o({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=S({mutationFn:s(e=>M.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:s(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){o({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);o({title:"Folder created",body:e.name,tone:"success"})},"onSuccess"),onError:s(e=>{o({title:"Failed to save folder",body:e instanceof Error?e.message:"Paperclip could not save the folder.",tone:"error"})},"onError")}),ue=S({mutationFn:s(({folderId:e,payload:r})=>M.update(n,e,r),"mutationFn"),onSuccess:s(async()=>{K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")})},"onSuccess"),onError:s(e=>{o({title:"Folder save failed",body:e instanceof Error?e.message:"Paperclip could not update the folder.",tone:"error"})},"onError")}),Te=S({mutationFn:s(e=>M.delete(n,e),"mutationFn"),onSuccess:s(async(e,r)=>{f===r&&Y("all"),se(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})]),o({title:"Folder deleted",body:"Items moved to Unfiled.",tone:"success"})},"onSuccess"),onError:s(e=>{o({title:"Folder delete failed",body:e instanceof Error?e.message:"Paperclip could not delete the folder.",tone:"error"})},"onError")}),qe=S({mutationFn:s(({itemId:e,folderId:r})=>M.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:s(async()=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])},"onSuccess"),onError:s(e=>{o({title:"Move failed",body:e instanceof Error?e.message:"Paperclip could not move the routine.",tone:"error"})},"onError")}),jt=S({mutationFn:s(({id:e,data:r})=>We.update(e,r),"mutationFn"),onSuccess:s(async()=>{await d.invalidateQueries({queryKey:[...m.issues.list(n),"routine-executions"]})},"onSuccess")}),Ke=S({mutationFn:s(({id:e,status:r})=>X.update(e,{status:r}),"mutationFn"),onMutate:s(({id:e})=>{Ce(e)},"onMutate"),onSuccess:s(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r.id)})])},"onSuccess"),onSettled:s(()=>{Ce(null)},"onSettled"),onError:s(e=>{o({title:"Failed to update routine",body:e instanceof Error?e.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Ee=S({mutationFn:s(({id:e,data:r})=>X.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:s(({id:e})=>{_e(e)},"onMutate"),onSuccess:s(async(e,{id:r})=>{oe(null),await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r)})])},"onSuccess"),onSettled:s(()=>{_e(null)},"onSettled"),onError:s(e=>{o({title:"Routine run failed",body:e instanceof Error?e.message:"Paperclip could not start the routine run.",tone:"error"})},"onError")}),me=(0,l.useMemo)(()=>Vt(),[$]),yt=(0,l.useMemo)(()=>Gt(),[$]),vt=(0,l.useMemo)(()=>Lt((_??[]).filter(e=>e.status!=="terminated"),me).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[_,me]),bt=(0,l.useMemo)(()=>(C??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[C]),E=(0,l.useMemo)(()=>new Map((_??[]).map(e=>[e.id,e])),[_]),U=(0,l.useMemo)(()=>new Map((C??[]).map(e=>[e.id,e])),[C]),Ue=(0,l.useMemo)(()=>new Map((h?.folders??[]).map(e=>[e.id,e])),[h]),wt=(0,l.useMemo)(()=>zt(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)(()=>Ks(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),Nt=(0,l.useMemo)(()=>qs(D,u.groupBy,U,E,Ue),[E,Ue,U,u.groupBy,D]),It=(0,l.useMemo)(()=>Et("Recent Runs",it("runs"),"issues"),[]),Le=p.assigneeAgentId?E.get(p.assigneeAgentId)??null:null,Qe=p.projectId?U.get(p.projectId)??null:null,Be=Is(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 Ms(G,a),a})}s(ge,"updateRoutineView");function Ve(e){const r=e==="runs"?"runs":"routines";(0,l.startTransition)(()=>{b(it(r))})}s(Ve,"handleTabChange");function Y(e){x(r=>{const a=new URLSearchParams(r),v=Ns(e);return v?a.set("folder",v):a.delete("folder"),a})}s(Y,"setFolderSelection");function T(e=[]){Re(e),L(null),K(!0)}s(T,"openCreateFolder");function $e(){R(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),z(!0)}s($e,"openCreateRoutine");async function Rt(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")})]),o({title:"Routines moved",body:`${r.length} routine${r.length===1?"":"s"} filed.`,tone:"success"})}catch(a){o({title:"Failed to move routines",body:a instanceof Error?a.message:"Paperclip could not move the selected routines.",tone:"error"})}}s(Rt,"moveSelectedRoutines");function _t(e){oe(e)}s(_t,"handleRunNow");function Ct(e,r){if(!r&&!e.assigneeAgentId){o({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}Ke.mutate({id:e.id,status:bs(e.status,!r)})}s(Ct,"handleToggleEnabled");function St(e){Ke.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return s(St,"handleToggleArchived"),n?pt?(0,t.jsx)(ds,{variant:"issues-list"}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Routines"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,t.jsxs)(F,{onClick:$e,children:[(0,t.jsx)(J,{className:"mr-2 h-4 w-4"}),"Create routine"]})]}),(0,t.jsxs)(Zt,{value:P,onValueChange:Ve,children:[(0,t.jsx)(js,{align:"start",value:P,onValueChange:Ve,items:[{value:"routines",label:"Routines"},{value:"runs",label:"Recent Runs"}]}),(0,t.jsxs)(et,{value:"routines",className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[y.length," routine",y.length===1?"":"s"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(Ye,{children:[(0,t.jsx)(Ge,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,t.jsx)($t,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,t.jsx)(ze,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,t.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:s(()=>{ge(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,t.jsx)("span",{children:r}),u.sortField===e?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,t.jsxs)(Ye,{children:[(0,t.jsx)(Ge,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,t.jsx)(Ot,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,t.jsx)(ze,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,t.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:s(()=>ge({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,t.jsx)("span",{children:r}),u.groupBy===e?(0,t.jsx)(ts,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!W?(0,t.jsxs)(F,{variant:"outline",size:"sm",onClick:s(()=>T(),"onClick"),children:[(0,t.jsx)(J,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,fe?(0,t.jsx)(F,{variant:"ghost",size:"sm",className:"text-xs",onClick:s(()=>re(e=>!e),"onClick"),children:ne?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(fs,{result:pe,selection:f,allLabel:"All routines",onClick:s(()=>Ne(!0),"onClick")})}):null]}),(0,t.jsx)(et,{value:"runs",children:(0,t.jsx)(Wt,{issues:le??[],isLoading:ft,error:gt,agents:_,projects:C,liveIssueIds:wt,viewStateKey:"paperclip:routine-recent-runs-view",issueLinkState:It,onUpdateIssue:s((e,r)=>jt.mutate({id:e,data:r}),"onUpdateIssue")})})]}),(0,t.jsx)(Jt,{open:$,onOpenChange:s(e=>{N.isPending||z(e)},"onOpenChange"),children:(0,t.jsxs)(Ht,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,t.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,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"New routine"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:s(()=>{z(!1),ie(!1)},"onClick"),disabled:N.isPending,children:"Cancel"})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,t.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,t.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:s(e=>{R(r=>({...r,title:e.target.value})),tt(e.target)},"onChange"),onKeyDown:s(e=>{if(e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing){e.preventDefault(),i.current?.focus();return}e.key==="Tab"&&!e.shiftKey&&(e.preventDefault(),p.assigneeAgentId?p.projectId?i.current?.focus():I.current?.focus():w.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-5 pb-3",children:(0,t.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,t.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,t.jsx)("span",{children:"For"}),(0,t.jsx)(Xe,{ref:w,value:p.assigneeAgentId,options:vt,recentOptionIds:me,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:s(e=>{e&&Qt(e),R(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:s(()=>{p.projectId?i.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:s(e=>e?Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ze,{agent:Le,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"truncate",children:e.label}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=E.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[r?(0,t.jsx)(Ze,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"in"}),(0,t.jsx)(Xe,{ref:I,value:p.projectId,options:bt,recentOptionIds:yt,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:s(e=>{e&&Bt(e),R(r=>({...r,projectId:e}))},"onChange"),onConfirm:s(()=>i.current?.focus(),"onConfirm"),renderTriggerValue:s(e=>e&&Qe?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Qe.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=U.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"filed in"}),(0,t.jsxs)(ve,{value:p.folderId??"__unfiled",onValueChange:s(e=>R(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,t.jsx)(je,{className:"h-8 w-auto min-w-32 border-0 bg-muted/50 px-2 shadow-none",children:(0,t.jsx)(ye,{})}),(0,t.jsxs)(be,{children:[(0,t.jsx)(Z,{value:"__unfiled",children:"Unfiled"}),(h?.folders??[]).map(e=>(0,t.jsx)(Z,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,t.jsx)("div",{className:"border-t border-border/60 px-5 py-4",children:(0,t.jsx)(Xt,{ref:i,value:p.description,onChange:s(e=>R(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-muted-foreground",mentions:ht,onSubmit:s(()=>{!N.isPending&&p.title.trim()&&p.projectId&&p.assigneeAgentId&&N.mutate()},"onSubmit")})}),(0,t.jsx)("div",{className:"border-t border-border/60 px-5 py-3",children:(0,t.jsxs)(He,{open:Se,onOpenChange:ie,children:[(0,t.jsxs)(lt,{className:"flex w-full items-center justify-between text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Keep policy controls secondary to the work definition."})]}),Se?(0,t.jsx)(ss,{className:"h-4 w-4 text-muted-foreground"}):(0,t.jsx)(ct,{className:"h-4 w-4 text-muted-foreground"})]}),(0,t.jsx)(Je,{className:"pt-3",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,t.jsxs)(ve,{value:p.concurrencyPolicy,onValueChange:s(e=>R(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,t.jsx)(je,{children:(0,t.jsx)(ye,{})}),(0,t.jsx)(be,{children:Ss.map(e=>(0,t.jsx)(Z,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ks[p.concurrencyPolicy]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,t.jsxs)(ve,{value:p.catchUpPolicy,onValueChange:s(e=>R(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,t.jsx)(je,{children:(0,t.jsx)(ye,{})}),(0,t.jsx)(be,{children:Fs.map(e=>(0,t.jsx)(Z,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:Ps[p.catchUpPolicy]})]})]})})]})})]}),(0,t.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,t.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,t.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,t.jsxs)(F,{onClick:s(()=>N.mutate(),"onClick"),disabled:N.isPending||!p.title.trim(),children:[(0,t.jsx)(J,{className:"mr-2 h-4 w-4"}),N.isPending?"Creating...":"Create routine"]}),N.isError?(0,t.jsx)("p",{className:"text-sm text-destructive",children:N.error instanceof Error?N.error.message:"Failed to create routine"}):null]})]})]})}),ae?(0,t.jsx)(cs,{children:(0,t.jsx)(ls,{className:"pt-6 text-sm text-destructive",children:ae instanceof Error?ae.message:"Failed to load routines"})}):null,P==="routines"?(0,t.jsxs)("div",{className:Pt(fe&&"flex gap-4"),children:[fe?(0,t.jsx)(hs,{result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Pe,onSelect:Y,onCreate:s(()=>T(),"onCreate"),onRename:s((e,r)=>ue.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:s(e=>{L(e),K(!0)},"onEdit"),onDelete:se}):null,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&W?(0,t.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,t.jsx)(Us,{label:"All routines",count:D.length}):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(vs,{color:Be?.color}),(0,t.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Be?.name??"Folder"}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[D.length," routine",D.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!W&&!Pe&&y.length>0?(0,t.jsx)(ps,{storageKey:`paperclip:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:s(()=>T(),"onCreateFolder")}):null,ne?(0,t.jsx)(gs,{selectedCount:B.length,folders:h?.folders??[],onMove:s(e=>{Rt(e)},"onMove"),onCreateAndMove:s(()=>T(B),"onCreateAndMove"),onClear:s(()=>V([]),"onClear"),onDone:s(()=>{re(!1),V([])},"onDone")}):null,y.length===0?(0,t.jsx)("div",{className:"py-12",children:(0,t.jsx)(we,{icon:ee,message:"No active routines. Use Create routine to define the first recurring workflow."})}):D.length===0?(0,t.jsxs)("div",{className:"py-12",children:[(0,t.jsx)(we,{icon:ee,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,t.jsx)("div",{className:"mt-3 flex justify-center",children:(0,t.jsxs)(F,{size:"sm",onClick:$e,children:[(0,t.jsx)(J,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:Nt.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,t.jsxs)(He,{open:r,onOpenChange:s(a=>{ge({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,t.jsx)(Es,{label:e.label,count:e.items.length,isOpen:r}):null,(0,t.jsx)(Je,{children:e.items.map(a=>(0,t.jsx)(Cs,{routine:a,projectById:U,agentById:E,runningRoutineId:ut,statusMutationRoutineId:mt,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:_t,onToggleEnabled:Ct,onToggleArchived:St,selectMode:ne,selected:B.includes(a.id),onSelectChange:s((v,xe)=>{V(H=>xe?Array.from(new Set([...H,v.id])):H.filter(Ft=>Ft!==v.id))},"onSelectChange"),extraMenuItems:(0,t.jsx)(us,{folders:h?.folders??[],currentFolderId:a.folderId??null,onMove:s(v=>{const xe=a.folderId??null;qe.mutate({itemId:a.id,folderId:v}),o({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:s(()=>qe.mutate({itemId:a.id,folderId:xe}),"onClick")}})},"onMove"),onCreateAndMove:s(()=>T([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}):null,(0,t.jsx)(ys,{open:O,kind:"routine",folder:te,pending:De.isPending||ue.isPending,onOpenChange:K,onSubmit:s(e=>{te?ue.mutate({folderId:te.id,payload:e}):De.mutate(e)},"onSubmit")}),(0,t.jsx)(Rs,{open:Q!==null,folder:Q,itemLabelPlural:"routines",pending:Te.isPending,onOpenChange:s(e=>{e||se(null)},"onOpenChange"),onConfirm:s(()=>{Q&&Te.mutate(Q.id)},"onConfirm")}),(0,t.jsx)(xs,{open:dt,onOpenChange:Ne,result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:Y,onCreate:s(()=>T(),"onCreate")}),(0,t.jsx)(Yt,{open:k!==null,onOpenChange:s(e=>{e||oe(null)},"onOpenChange"),companyId:n,routineName:k?.title??null,agents:_??[],projects:C??[],defaultProjectId:k?.projectId??null,defaultAssigneeAgentId:k?.assigneeAgentId??null,variables:k?.variables??[],isPending:Ee.isPending,onSubmit:s(e=>{k&&Ee.mutate({id:k.id,data:e})},"onSubmit")})]}):(0,t.jsx)(we,{icon:ee,message:"Select a company to view routines."})}s(un,"Routines");function Us({label:n,count:c}){return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(ee,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate font-medium",children:n}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[c," routine",c===1?"":"s"]})]})}s(Us,"FolderIconHeader");export{un as Routines};
1
+ var kt=Object.defineProperty;var s=(n,c)=>kt(n,"name",{value:c,configurable:!0});import{i as at}from"./rolldown-runtime-ZpX3ckPj.js";import{$a as Pt,G as At,St as m,Xa as Mt,Za as Dt,_a as A,ga as S,ht as Tt}from"./boxes-ULGOWIM3.js";import{Bn as qt,Vt as ze,Wt as Ge,d as Kt,fn as Et,ln as We,n as Ut,pt as Ot,r as F,st as J,zt as Ye}from"./BreadcrumbContext-Cl4wMUsK.js";import{_ as He,v as Je,y as lt}from"./SearchableSelect-Ced5RHuX.js";import{Ft as Lt,It as Qt,Mt as Bt,Nr as ee,Nt as Vt,Rr as $t,V as zt,jt as Gt,r as Wt,t as Yt,wt as Xe,x as he}from"./RoutineRunVariablesDialog-DO5rvO25.js";import{t as Ze}from"./AgentAvatar-BWS01ZkH.js";import{r as Ht,t as Jt}from"./dialog-TATv1tMA.js";import{l as X,t as Xt}from"./MarkdownEditor-NZR4Qf3U.js";import{n as et,t as Zt}from"./tabs-C9VkqVBk.js";import{h as es}from"./StatusIcon-pBJPno3c.js";import{t as ts}from"./check-Cp2wC8NS.js";import{t as ss}from"./chevron-down-C_fR6OOJ.js";import{a as ct}from"./clipboard-CWwu6L5N.js";import{a as Z,c as je,l as ye,n as ve,r as be}from"./select-BilSqzhf.js";import{t as ns}from"./heartbeats-ztXAfZg0.js";import{a as rs}from"./ToastContext-Dizyilik.js";import{t as is}from"./agents-Bomtc4Gj.js";import{t as os}from"./access-BcnCBDzu.js";import{i as as}from"./company-members-Duugb3uG.js";import{r as ls,t as cs}from"./card-BhMgl8Q2.js";import{t as we}from"./EmptyState-Dx8V6QjR.js";import{t as ds}from"./PageSkeleton-DZf26yvt.js";import{$ as us,$t as ms,G as ps,J as fs,K as gs,Q as xs,X as hs,Xt as js,Y as ys,Z as vs,dt as bs,en as ws,et as Ns,ft as M,nt as Is,q as Rs,tt as _s,ut as Cs}from"./index-BguRK-v5.js";var l=at(Pt(),1),t=at(Dt(),1),Ss=["coalesce_if_active","always_enqueue","skip_if_active"],Fs=["skip_missed","enqueue_missed_with_cap"],ks={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."},Ps={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 tt(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}s(tt,"autoResizeTextarea");var As="__built_in_routines",st={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function nt(n){try{const c=localStorage.getItem(n);if(c)return{...st,...JSON.parse(c)}}catch{}return{...st}}s(nt,"getRoutineViewState");function Ms(n,c){localStorage.setItem(n,JSON.stringify(c))}s(Ms,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}s(q,"timestampValue");function rt(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}s(rt,"compareNullableText");function Ds(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}s(Ds,"buildRoutineMutationPayload");function Ts(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]}))}s(Ts,"buildRoutineGroups");function it(n){return n.originKind==="built_in_agent_bundle"}s(it,"isBuiltInRoutine");function qs(n,c,d,b,g){const x=n.filter(it),i=Ts(n.filter(o=>!it(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:As,label:"Built-in routines",items:x}]}s(qs,"buildRoutineSections");function Ks(n,c,d){const b=d==="asc"?1:-1;return[...n].sort((g,x)=>{let i=0;return c==="title"?i=rt(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:rt(g.title,x.title)})}s(Ks,"sortRoutines");function ot(n){return n==="runs"?"/routines?tab=runs":"/routines"}s(ot,"buildRoutinesTabHref");function Es({label:n,count:c,isOpen:d}){return(0,t.jsxs)("div",{className:`flex items-center gap-2 rounded-lg border border-border px-3 py-2${d?" mb-1":""}`,children:[(0,t.jsxs)(lt,{className:"flex items-center gap-1.5",children:[(0,t.jsx)(ct,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-90"}),(0,t.jsx)("span",{className:"text-sm font-semibold uppercase tracking-wide",children:n})]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:c})]})}s(Es,"RoutineSectionHeader");function un(){const{selectedCompanyId:n}=Tt(),{setBreadcrumbs:c}=Ut(),d=Mt(),b=Kt(),[g,x]=qt(),{pushToast:i}=rs(),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),[te,L]=(0,l.useState)(null),[Q,se]=(0,l.useState)(null),[dt,Ne]=(0,l.useState)(!1),[ne,re]=(0,l.useState)(!1),[B,V]=(0,l.useState)([]),[Ie,Re]=(0,l.useState)([]),[ut,_e]=(0,l.useState)(null),[mt,Ce]=(0,l.useState)(null),[k,ie]=(0,l.useState)(null),[$,z]=(0,l.useState)(!1),[Se,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)(()=>nt(G)),f=_s(g.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{Fe(nt(G))},[G]);const{data:ke,isLoading:pt,error:ae}=A({queryKey:m.routines.list(n),queryFn:s(()=>X.list(n),"queryFn"),enabled:!!n}),{data:h,isLoading:Pe}=A({queryKey:m.folders.list(n,"routine"),queryFn:s(()=>M.list(n,"routine"),"queryFn"),enabled:!!n&&P==="routines"}),{data:_}=A({queryKey:m.agents.list(n),queryFn:s(()=>is.list(n),"queryFn"),enabled:!!n}),{data:C}=A({queryKey:m.projects.list(n,{includeArchived:!0}),queryFn:s(()=>es.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Ae}=A({queryKey:m.access.companyUserDirectory(n),queryFn:s(()=>os.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:le,isLoading:ft,error:gt}=A({queryKey:[...m.issues.list(n),"routine-executions"],queryFn:s(()=>We.list(n,{originKind:"routine_execution"}),"queryFn"),enabled:!!n&&P==="runs"}),Me=m.liveRuns(n),ce=ws({companyId:n,resourceKey:"live-runs",queryKey:Me,enabled:!!n&&P==="runs",refetchInterval:!1,leaderOnly:!0}),{data:de,dataUpdatedAt:xt}=A({queryKey:Me,queryFn:s(()=>ns.liveRunsForCompany(n),"queryFn"),enabled:ce.enabled,refetchInterval:ce.refetchInterval});ms(ce,de,xt),(0,l.useEffect)(()=>{tt(j.current)},[p.title,$]);const ht=(0,l.useMemo)(()=>as({agents:_,projects:(C??[]).filter(e=>!e.archivedAt),members:Ae?.users}),[_,Ae?.users,C]),N=S({mutationFn:s(()=>X.create(n,Ds(p)),"mutationFn"),onSuccess:s(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=S({mutationFn:s(e=>M.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:s(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:s(e=>{i({title:"Failed to save folder",body:e instanceof Error?e.message:"Paperclip could not save the folder.",tone:"error"})},"onError")}),ue=S({mutationFn:s(({folderId:e,payload:r})=>M.update(n,e,r),"mutationFn"),onSuccess:s(async()=>{K(!1),L(null),await d.invalidateQueries({queryKey:m.folders.list(n,"routine")})},"onSuccess"),onError:s(e=>{i({title:"Folder save failed",body:e instanceof Error?e.message:"Paperclip could not update the folder.",tone:"error"})},"onError")}),Te=S({mutationFn:s(e=>M.delete(n,e),"mutationFn"),onSuccess:s(async(e,r)=>{f===r&&Y("all"),se(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:s(e=>{i({title:"Folder delete failed",body:e instanceof Error?e.message:"Paperclip could not delete the folder.",tone:"error"})},"onError")}),qe=S({mutationFn:s(({itemId:e,folderId:r})=>M.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:s(async()=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.folders.list(n,"routine")})])},"onSuccess"),onError:s(e=>{i({title:"Move failed",body:e instanceof Error?e.message:"Paperclip could not move the routine.",tone:"error"})},"onError")}),jt=S({mutationFn:s(({id:e,data:r})=>We.update(e,r),"mutationFn"),onSuccess:s(async()=>{await d.invalidateQueries({queryKey:[...m.issues.list(n),"routine-executions"]})},"onSuccess")}),Ke=S({mutationFn:s(({id:e,status:r})=>X.update(e,{status:r}),"mutationFn"),onMutate:s(({id:e})=>{Ce(e)},"onMutate"),onSuccess:s(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:m.routines.list(n)}),d.invalidateQueries({queryKey:m.routines.detail(r.id)})])},"onSuccess"),onSettled:s(()=>{Ce(null)},"onSettled"),onError:s(e=>{i({title:"Failed to update routine",body:e instanceof Error?e.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Ee=S({mutationFn:s(({id:e,data:r})=>X.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:s(({id:e})=>{_e(e)},"onMutate"),onSuccess:s(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:s(()=>{_e(null)},"onSettled"),onError:s(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)(()=>Vt(),[$]),yt=(0,l.useMemo)(()=>Gt(),[$]),vt=(0,l.useMemo)(()=>Lt((_??[]).filter(e=>e.status!=="terminated"),me).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[_,me]),bt=(0,l.useMemo)(()=>(C??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[C]),E=(0,l.useMemo)(()=>new Map((_??[]).map(e=>[e.id,e])),[_]),U=(0,l.useMemo)(()=>new Map((C??[]).map(e=>[e.id,e])),[C]),Ue=(0,l.useMemo)(()=>new Map((h?.folders??[]).map(e=>[e.id,e])),[h]),wt=(0,l.useMemo)(()=>zt(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)(()=>Ks(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),Nt=(0,l.useMemo)(()=>qs(D,u.groupBy,U,E,Ue),[E,Ue,U,u.groupBy,D]),It=(0,l.useMemo)(()=>Et("Recent Runs",ot("runs"),"issues"),[]),Le=p.assigneeAgentId?E.get(p.assigneeAgentId)??null:null,Qe=p.projectId?U.get(p.projectId)??null:null,Be=Is(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 Ms(G,a),a})}s(ge,"updateRoutineView");function Ve(e){const r=e==="runs"?"runs":"routines";(0,l.startTransition)(()=>{b(ot(r))})}s(Ve,"handleTabChange");function Y(e){x(r=>{const a=new URLSearchParams(r),v=Ns(e);return v?a.set("folder",v):a.delete("folder"),a})}s(Y,"setFolderSelection");function T(e=[]){Re(e),L(null),K(!0)}s(T,"openCreateFolder");function $e(){R(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),z(!0)}s($e,"openCreateRoutine");async function Rt(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"})}}s(Rt,"moveSelectedRoutines");function _t(e){ie(e)}s(_t,"handleRunNow");function Ct(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:bs(e.status,!r)})}s(Ct,"handleToggleEnabled");function St(e){Ke.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return s(St,"handleToggleArchived"),n?pt?(0,t.jsx)(ds,{variant:"issues-list"}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Routines"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,t.jsxs)(F,{onClick:$e,children:[(0,t.jsx)(J,{className:"mr-2 h-4 w-4"}),"Create routine"]})]}),(0,t.jsxs)(Zt,{value:P,onValueChange:Ve,children:[(0,t.jsx)(js,{align:"start",value:P,onValueChange:Ve,items:[{value:"routines",label:"Routines"},{value:"runs",label:"Recent Runs"}]}),(0,t.jsxs)(et,{value:"routines",className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[y.length," routine",y.length===1?"":"s"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(Ye,{children:[(0,t.jsx)(Ge,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,t.jsx)($t,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,t.jsx)(ze,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,t.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:s(()=>{ge(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,t.jsx)("span",{children:r}),u.sortField===e?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,t.jsxs)(Ye,{children:[(0,t.jsx)(Ge,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,t.jsx)(Ot,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,t.jsx)(ze,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,t.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:s(()=>ge({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,t.jsx)("span",{children:r}),u.groupBy===e?(0,t.jsx)(ts,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!W?(0,t.jsxs)(F,{variant:"outline",size:"sm",onClick:s(()=>T(),"onClick"),children:[(0,t.jsx)(J,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,fe?(0,t.jsx)(F,{variant:"ghost",size:"sm",className:"text-xs",onClick:s(()=>re(e=>!e),"onClick"),children:ne?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(fs,{result:pe,selection:f,allLabel:"All routines",onClick:s(()=>Ne(!0),"onClick")})}):null]}),(0,t.jsx)(et,{value:"runs",children:(0,t.jsx)(Wt,{issues:le??[],isLoading:ft,error:gt,agents:_,projects:C,liveIssueIds:wt,viewStateKey:"paperclip:routine-recent-runs-view",issueLinkState:It,onUpdateIssue:s((e,r)=>jt.mutate({id:e,data:r}),"onUpdateIssue")})})]}),(0,t.jsx)(Jt,{open:$,onOpenChange:s(e=>{N.isPending||z(e)},"onOpenChange"),children:(0,t.jsxs)(Ht,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,t.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,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"New routine"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:s(()=>{z(!1),oe(!1)},"onClick"),disabled:N.isPending,children:"Cancel"})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,t.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,t.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:s(e=>{R(r=>({...r,title:e.target.value})),tt(e.target)},"onChange"),onKeyDown:s(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,t.jsx)("div",{className:"px-5 pb-3",children:(0,t.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,t.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,t.jsx)("span",{children:"For"}),(0,t.jsx)(Xe,{ref:w,value:p.assigneeAgentId,options:vt,recentOptionIds:me,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:s(e=>{e&&Qt(e),R(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:s(()=>{p.projectId?o.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:s(e=>e?Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ze,{agent:Le,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"truncate",children:e.label}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=E.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[r?(0,t.jsx)(Ze,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"in"}),(0,t.jsx)(Xe,{ref:I,value:p.projectId,options:bt,recentOptionIds:yt,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:s(e=>{e&&Bt(e),R(r=>({...r,projectId:e}))},"onChange"),onConfirm:s(()=>o.current?.focus(),"onConfirm"),renderTriggerValue:s(e=>e&&Qe?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Qe.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=U.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"filed in"}),(0,t.jsxs)(ve,{value:p.folderId??"__unfiled",onValueChange:s(e=>R(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,t.jsx)(je,{className:"h-8 w-auto min-w-32 border-0 bg-muted/50 px-2 shadow-none",children:(0,t.jsx)(ye,{})}),(0,t.jsxs)(be,{children:[(0,t.jsx)(Z,{value:"__unfiled",children:"Unfiled"}),(h?.folders??[]).map(e=>(0,t.jsx)(Z,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,t.jsx)("div",{className:"border-t border-border/60 px-5 py-4",children:(0,t.jsx)(Xt,{ref:o,value:p.description,onChange:s(e=>R(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-muted-foreground",mentions:ht,onSubmit:s(()=>{!N.isPending&&p.title.trim()&&p.projectId&&p.assigneeAgentId&&N.mutate()},"onSubmit")})}),(0,t.jsx)("div",{className:"border-t border-border/60 px-5 py-3",children:(0,t.jsxs)(He,{open:Se,onOpenChange:oe,children:[(0,t.jsxs)(lt,{className:"flex w-full items-center justify-between text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Keep policy controls secondary to the work definition."})]}),Se?(0,t.jsx)(ss,{className:"h-4 w-4 text-muted-foreground"}):(0,t.jsx)(ct,{className:"h-4 w-4 text-muted-foreground"})]}),(0,t.jsx)(Je,{className:"pt-3",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,t.jsxs)(ve,{value:p.concurrencyPolicy,onValueChange:s(e=>R(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,t.jsx)(je,{children:(0,t.jsx)(ye,{})}),(0,t.jsx)(be,{children:Ss.map(e=>(0,t.jsx)(Z,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ks[p.concurrencyPolicy]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,t.jsxs)(ve,{value:p.catchUpPolicy,onValueChange:s(e=>R(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,t.jsx)(je,{children:(0,t.jsx)(ye,{})}),(0,t.jsx)(be,{children:Fs.map(e=>(0,t.jsx)(Z,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:Ps[p.catchUpPolicy]})]})]})})]})})]}),(0,t.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,t.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,t.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,t.jsxs)(F,{onClick:s(()=>N.mutate(),"onClick"),disabled:N.isPending||!p.title.trim(),children:[(0,t.jsx)(J,{className:"mr-2 h-4 w-4"}),N.isPending?"Creating...":"Create routine"]}),N.isError?(0,t.jsx)("p",{className:"text-sm text-destructive",children:N.error instanceof Error?N.error.message:"Failed to create routine"}):null]})]})]})}),ae?(0,t.jsx)(cs,{children:(0,t.jsx)(ls,{className:"pt-6 text-sm text-destructive",children:ae instanceof Error?ae.message:"Failed to load routines"})}):null,P==="routines"?(0,t.jsxs)("div",{className:At(fe&&"flex gap-4"),children:[fe?(0,t.jsx)(hs,{result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Pe,onSelect:Y,onCreate:s(()=>T(),"onCreate"),onRename:s((e,r)=>ue.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:s(e=>{L(e),K(!0)},"onEdit"),onDelete:se}):null,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&W?(0,t.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,t.jsx)(Us,{label:"All routines",count:D.length}):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(vs,{color:Be?.color}),(0,t.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Be?.name??"Folder"}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[D.length," routine",D.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!W&&!Pe&&y.length>0?(0,t.jsx)(ps,{storageKey:`paperclip:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:s(()=>T(),"onCreateFolder")}):null,ne?(0,t.jsx)(gs,{selectedCount:B.length,folders:h?.folders??[],onMove:s(e=>{Rt(e)},"onMove"),onCreateAndMove:s(()=>T(B),"onCreateAndMove"),onClear:s(()=>V([]),"onClear"),onDone:s(()=>{re(!1),V([])},"onDone")}):null,y.length===0?(0,t.jsx)("div",{className:"py-12",children:(0,t.jsx)(we,{icon:ee,message:"No active routines. Use Create routine to define the first recurring workflow."})}):D.length===0?(0,t.jsxs)("div",{className:"py-12",children:[(0,t.jsx)(we,{icon:ee,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,t.jsx)("div",{className:"mt-3 flex justify-center",children:(0,t.jsxs)(F,{size:"sm",onClick:$e,children:[(0,t.jsx)(J,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:Nt.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,t.jsxs)(He,{open:r,onOpenChange:s(a=>{ge({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,t.jsx)(Es,{label:e.label,count:e.items.length,isOpen:r}):null,(0,t.jsx)(Je,{children:e.items.map(a=>(0,t.jsx)(Cs,{routine:a,projectById:U,agentById:E,runningRoutineId:ut,statusMutationRoutineId:mt,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:_t,onToggleEnabled:Ct,onToggleArchived:St,selectMode:ne,selected:B.includes(a.id),onSelectChange:s((v,xe)=>{V(H=>xe?Array.from(new Set([...H,v.id])):H.filter(Ft=>Ft!==v.id))},"onSelectChange"),extraMenuItems:(0,t.jsx)(us,{folders:h?.folders??[],currentFolderId:a.folderId??null,onMove:s(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:s(()=>qe.mutate({itemId:a.id,folderId:xe}),"onClick")}})},"onMove"),onCreateAndMove:s(()=>T([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}):null,(0,t.jsx)(ys,{open:O,kind:"routine",folder:te,pending:De.isPending||ue.isPending,onOpenChange:K,onSubmit:s(e=>{te?ue.mutate({folderId:te.id,payload:e}):De.mutate(e)},"onSubmit")}),(0,t.jsx)(Rs,{open:Q!==null,folder:Q,itemLabelPlural:"routines",pending:Te.isPending,onOpenChange:s(e=>{e||se(null)},"onOpenChange"),onConfirm:s(()=>{Q&&Te.mutate(Q.id)},"onConfirm")}),(0,t.jsx)(xs,{open:dt,onOpenChange:Ne,result:pe,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:Y,onCreate:s(()=>T(),"onCreate")}),(0,t.jsx)(Yt,{open:k!==null,onOpenChange:s(e=>{e||ie(null)},"onOpenChange"),companyId:n,routineName:k?.title??null,agents:_??[],projects:C??[],defaultProjectId:k?.projectId??null,defaultAssigneeAgentId:k?.assigneeAgentId??null,variables:k?.variables??[],isPending:Ee.isPending,onSubmit:s(e=>{k&&Ee.mutate({id:k.id,data:e})},"onSubmit")})]}):(0,t.jsx)(we,{icon:ee,message:"Select a company to view routines."})}s(un,"Routines");function Us({label:n,count:c}){return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(ee,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate font-medium",children:n}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[c," routine",c===1?"":"s"]})]})}s(Us,"FolderIconHeader");export{un as Routines};
@@ -1,5 +1,5 @@
1
- var nn=Object.defineProperty;var a=(e,t)=>nn(e,"name",{value:t,configurable:!0});import{i as We}from"./rolldown-runtime-ZpX3ckPj.js";import{$a as rn,A as on,Aa as sn,D as an,E as ln,Fa as un,G as k,Ha as Xe,Ia as ht,Ja as cn,Ka as Re,L as dn,La as fn,M as qe,Na as Ye,O as pn,Oa as mn,Pa as F,Qa as hn,Ra as Je,Ua as V,Va as Ze,Wa as et,_ as vn,eo as gn,j as yn,k as bn,n as vt,v as En,za as gt}from"./boxes-DcYq-jCc.js";import{Vt as xn,Wt as wn,r as Cn,rt as Sn,zt as On}from"./BreadcrumbContext-BdR2QZTG.js";import{n as Nn}from"./dist-D_GJjr4Y.js";import{c as Rn,i as Dn,o as Pn,r as _n,t as In}from"./dialog-Be3BfHbu.js";import{t as An}from"./check-2qo6ZJ2G.js";import{t as yt}from"./x-C7r-gM7x.js";var Tn=class extends ht{static{a(this,"MutationCache")}#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){const r=new mn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);const t=ye(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=ye(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=ye(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=ye(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){F.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=>Ze(t,n))}findAll(e={}){return this.getAll().filter(t=>Ze(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(V))))}};function ye(e){return e.options.scope?.id}a(ye,"scopeFor");var Mn=class extends ht{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const r=t.queryKey,o=t.queryHash??gt(r,t);let s=this.get(o);return s||(s=new sn({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(s)),s}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(){F.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=>Xe(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Xe(e,n)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$o=class{static{a(this,"QueryClient")}#e;#t;#n;#o;#s;#r;#i;#a;constructor(e={}){this.#e=e.queryCache||new Mn,this.#t=e.mutationCache||new Tn,this.#n=e.defaultOptions||{},this.#o=new Map,this.#s=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#i=un.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Ye.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=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),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Re(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(r.queryHash)?.state.data,s=fn(t,o);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return F.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;F.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return F.batch(()=>{const r=n.findAll(e),o=new Set(r);return r.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:a(s=>o.has(s),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=F.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(V).catch(V)}invalidateQueries(e,t={}){return F.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},r=F.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(V)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(V)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),r=n.isStaleByTime(Re(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Re(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(V).catch(V)}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(V).catch(V)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ye.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#o.set(Je(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(r=>{et(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#s.set(Je(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{et(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gt(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===cn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},i=We(gn(),1),f=We(hn(),1),kn=Object.defineProperty,ve=a((e,t)=>kn(e,"name",{value:t,configurable:!0}),"__name"),Ue="Collapsible",[jn,Qo]=yn(Ue),[Fn,He]=jn(Ue),Ln=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,open:o,defaultOpen:s,disabled:u,onOpenChange:l,...p}=t,[c,h]=pn({prop:o,defaultProp:s??!1,onChange:l,caller:Ue});return(0,f.jsx)(Fn,{scope:r,disabled:u,contentId:ln(),open:c,onOpenToggle:i.useCallback(()=>h(y=>!y),[h]),children:(0,f.jsx)(qe.div,{"data-state":Ce(c),"data-disabled":u?"":void 0,...p,ref:n})})},"Collapsible2"),"Collapsible")),$n="CollapsibleTrigger",Qn=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,...o}=t,s=He($n,r);return(0,f.jsx)(qe.button,{type:"button","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open||!1,"data-state":Ce(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...o,ref:n,onClick:on(t.onClick,s.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),bt="CollapsibleContent",zn=i.forwardRef(ve(a(function(t,n){const{forceMount:r,...o}=t,s=He(bt,t.__scopeCollapsible);return(0,f.jsx)(an,{present:r||s.open,children:a(({present:u})=>(0,f.jsx)(Wn,{...o,ref:n,present:u}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),Wn=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,present:o,children:s,...u}=t,l=He(bt,r),[p,c]=i.useState(o),h=i.useRef(null),y=dn(n,h),E=i.useRef(0),x=E.current,R=i.useRef(0),C=R.current,S=l.open||p,I=i.useRef(S),_=i.useRef(void 0);return i.useEffect(()=>{const N=requestAnimationFrame(()=>I.current=!1);return()=>cancelAnimationFrame(N)},[]),bn(()=>{const N=h.current;if(N){_.current=_.current||{transitionDuration:N.style.transitionDuration,animationName:N.style.animationName},N.style.transitionDuration="0s",N.style.animationName="none";const P=N.getBoundingClientRect();E.current=P.height,R.current=P.width,I.current||(N.style.transitionDuration=_.current.transitionDuration,N.style.animationName=_.current.animationName),c(o)}},[l.open,o]),(0,f.jsx)(qe.div,{"data-state":Ce(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...u,ref:y,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:S&&s})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function Ce(e){return e?"open":"closed"}a(Ce,"getState$1");ve(Ce,"getState");var qn=Ln,Et={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]};Et.node;var Un=vt(Et),xt={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};xt.node;var zo=vt(xt);function Wo({...e}){return(0,f.jsx)(qn,{"data-slot":"collapsible",...e})}a(Wo,"Collapsible");function qo({...e}){return(0,f.jsx)(Qn,{"data-slot":"collapsible-trigger",...e})}a(qo,"CollapsibleTrigger");function Uo({...e}){return(0,f.jsx)(zn,{"data-slot":"collapsible-content",...e})}a(Uo,"CollapsibleContent");var tt=1,Hn=.9,Vn=.8,Kn=.17,De=.1,Pe=.999,Bn=.9999,Gn=.99,Xn=/[\\\/_+.#"@\[\(\{&]/,Yn=/[\\\/_+.#"@\[\(\{&]/g,Jn=/[\s-]/,wt=/[\s-]/g;function je(e,t,n,r,o,s,u){if(s===t.length)return o===e.length?tt:Gn;var l=`${o},${s}`;if(u[l]!==void 0)return u[l];for(var p=r.charAt(s),c=n.indexOf(p,o),h=0,y,E,x,R;c>=0;)y=je(e,t,n,r,c+1,s+1,u),y>h&&(c===o?y*=tt:Xn.test(e.charAt(c-1))?(y*=Vn,x=e.slice(o,c-1).match(Yn),x&&o>0&&(y*=Math.pow(Pe,x.length))):Jn.test(e.charAt(c-1))?(y*=Hn,R=e.slice(o,c-1).match(wt),R&&o>0&&(y*=Math.pow(Pe,R.length))):(y*=Kn,o>0&&(y*=Math.pow(Pe,c-o))),e.charAt(c)!==t.charAt(s)&&(y*=Bn)),(y<De&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(E=je(e,t,n,r,c+1,s+2,u),E*De>y&&(y=E*De)),y>h&&(h=y),c=n.indexOf(p,c+1);return u[l]=h,h}a(je,"G");function nt(e){return e.toLowerCase().replace(wt," ")}a(nt,"D");function Zn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,je(e,t,nt(e),nt(t),0,0,{})}a(Zn,"W");var Ho=!!(typeof window<"u"&&window.document&&window.document.createElement);function J(e,t,{checkForDefaultPrevented:n=!0}={}){return a(function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)},"handleEvent")}a(J,"composeEventHandlers");function rt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}a(rt,"setRef");function te(...e){return t=>{let n=!1;const r=e.map(o=>{const s=rt(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():rt(e[o],null)}}}}a(te,"composeRefs");function oe(...e){return i.useCallback(te(...e),e)}a(oe,"useComposedRefs");function er(e,t){const n=i.createContext(t),r=a(s=>{const{children:u,...l}=s,p=i.useMemo(()=>l,Object.values(l));return(0,f.jsx)(n.Provider,{value:p,children:u})},"Provider");r.displayName=e+"Provider";function o(s){const u=i.useContext(n);if(u)return u;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return a(o,"useContext2"),[r,o]}a(er,"createContext2");function tr(e,t=[]){let n=[];function r(s,u){const l=i.createContext(u),p=n.length;n=[...n,u];const c=a(y=>{const{scope:E,children:x,...R}=y,C=E?.[e]?.[p]||l,S=i.useMemo(()=>R,Object.values(R));return(0,f.jsx)(C.Provider,{value:S,children:x})},"Provider");c.displayName=s+"Provider";function h(y,E){const x=E?.[e]?.[p]||l,R=i.useContext(x);if(R)return R;if(u!==void 0)return u;throw new Error(`\`${y}\` must be used within \`${s}\``)}return a(h,"useContext2"),[c,h]}a(r,"createContext3");const o=a(()=>{const s=n.map(u=>i.createContext(u));return a(function(l){const p=l?.[e]||s;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:p}}),[l,p])},"useScope")},"createScope");return o.scopeName=e,[r,nr(o,...t)]}a(tr,"createContextScope");function nr(...e){const t=e[0];if(e.length===1)return t;const n=a(()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return a(function(s){const u=r.reduce((l,{useScope:p,scopeName:c})=>{const h=p(s)[`__scope${c}`];return{...l,...h}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}a(nr,"composeContextScopes");var me=globalThis?.document?i.useLayoutEffect:()=>{},rr=i[" useId ".trim().toString()]||(()=>{}),or=0;function K(e){const[t,n]=i.useState(rr());return me(()=>{e||n(r=>r??String(or++))},[e]),e||(t?`radix-${t}`:"")}a(K,"useId");var sr=i[" useInsertionEffect ".trim().toString()]||me;function ir({prop:e,defaultProp:t,onChange:n=a(()=>{},"onChange"),caller:r}){const[o,s,u]=ar({defaultProp:t,onChange:n}),l=e!==void 0,p=l?e:o;{const c=i.useRef(e!==void 0);i.useEffect(()=>{const h=c.current;c.current=l},[l,r])}return[p,i.useCallback(c=>{if(l){const h=lr(c)?c(e):c;h!==e&&u.current?.(h)}else s(c)},[l,e,s,u])]}a(ir,"useControllableState");function ar({defaultProp:e,onChange:t}){const[n,r]=i.useState(e),o=i.useRef(n),s=i.useRef(t);return sr(()=>{s.current=t},[t]),i.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}a(ar,"useUncontrolledState");function lr(e){return typeof e=="function"}a(lr,"isFunction");var Ct=We(rn(),1);function St(e){const t=ur(e),n=i.forwardRef((r,o)=>{const{children:s,...u}=r,l=i.Children.toArray(s),p=l.find(dr);if(p){const c=p.props.children,h=l.map(y=>y===p?i.Children.count(c)>1?i.Children.only(null):i.isValidElement(c)?c.props.children:null:y);return(0,f.jsx)(t,{...u,ref:o,children:i.isValidElement(c)?i.cloneElement(c,void 0,h):null})}return(0,f.jsx)(t,{...u,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}a(St,"createSlot");function ur(e){const t=i.forwardRef((n,r)=>{const{children:o,...s}=n;if(i.isValidElement(o)){const u=pr(o),l=fr(s,o.props);return o.type!==i.Fragment&&(l.ref=r?te(r,u):u),i.cloneElement(o,l)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}a(ur,"createSlotClone");var cr=Symbol("radix.slottable");function dr(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cr}a(dr,"isSlottable");function fr(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...u)=>{const l=s(...u);return o(...u),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}a(fr,"mergeProps");function pr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}a(pr,"getElementRef$1");var T=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=St(`Primitive.${t}`),r=i.forwardRef((o,s)=>{const{asChild:u,...l}=o,p=u?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,f.jsx)(p,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mr(e,t){e&&Ct.flushSync(()=>e.dispatchEvent(t))}a(mr,"dispatchDiscreteCustomEvent");function he(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>t.current?.(...n),[])}a(he,"useCallbackRef");function hr(e,t=globalThis?.document){const n=he(e);i.useEffect(()=>{const r=a(o=>{o.key==="Escape"&&n(o)},"handleKeyDown");return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}a(hr,"useEscapeKeydown");var vr="DismissableLayer",Fe="dismissableLayer.update",gr="dismissableLayer.pointerDownOutside",yr="dismissableLayer.focusOutside",ot,Ot=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nt=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:u,onDismiss:l,...p}=e,c=i.useContext(Ot),[h,y]=i.useState(null),E=h?.ownerDocument??globalThis?.document,[,x]=i.useState({}),R=oe(t,w=>y(w)),C=Array.from(c.layers),[S]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),I=C.indexOf(S),_=h?C.indexOf(h):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,P=_>=I,Q=xr(w=>{const U=w.target,L=[...c.branches].some(q=>q.contains(U));!P||L||(o?.(w),u?.(w),w.defaultPrevented||l?.())},E),D=wr(w=>{const U=w.target;[...c.branches].some(L=>L.contains(U))||(s?.(w),u?.(w),w.defaultPrevented||l?.())},E);return hr(w=>{_===c.layers.size-1&&(r?.(w),!w.defaultPrevented&&l&&(w.preventDefault(),l()))},E),i.useEffect(()=>{if(h)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(ot=E.body.style.pointerEvents,E.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(h)),c.layers.add(h),st(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(E.body.style.pointerEvents=ot)}},[h,E,n,c]),i.useEffect(()=>()=>{h&&(c.layers.delete(h),c.layersWithOutsidePointerEventsDisabled.delete(h),st())},[h,c]),i.useEffect(()=>{const w=a(()=>x({}),"handleUpdate");return document.addEventListener(Fe,w),()=>document.removeEventListener(Fe,w)},[]),(0,f.jsx)(T.div,{...p,ref:R,style:{pointerEvents:N?P?"auto":"none":void 0,...e.style},onFocusCapture:J(e.onFocusCapture,D.onFocusCapture),onBlurCapture:J(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:J(e.onPointerDownCapture,Q.onPointerDownCapture)})});Nt.displayName=vr;var br="DismissableLayerBranch",Er=i.forwardRef((e,t)=>{const n=i.useContext(Ot),r=i.useRef(null),o=oe(t,r);return i.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),(0,f.jsx)(T.div,{...e,ref:o})});Er.displayName=br;function xr(e,t=globalThis?.document){const n=he(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const s=a(l=>{if(l.target&&!r.current){let p=a(function(){Rt(gr,n,c,{discrete:!0})},"handleAndDispatchPointerDownOutsideEvent2");const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=p,t.addEventListener("click",o.current,{once:!0})):p()}else t.removeEventListener("click",o.current);r.current=!1},"handlePointerDown"),u=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(u),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:a(()=>r.current=!0,"onPointerDownCapture")}}a(xr,"usePointerDownOutside");function wr(e,t=globalThis?.document){const n=he(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a(s=>{s.target&&!r.current&&Rt(yr,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:a(()=>r.current=!0,"onFocusCapture"),onBlurCapture:a(()=>r.current=!1,"onBlurCapture")}}a(wr,"useFocusOutside");function st(){const e=new CustomEvent(Fe);document.dispatchEvent(e)}a(st,"dispatchUpdate");function Rt(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?mr(o,s):o.dispatchEvent(s)}a(Rt,"handleAndDispatchCustomEvent");var _e="focusScope.autoFocusOnMount",Ie="focusScope.autoFocusOnUnmount",it={bubbles:!1,cancelable:!0},Cr="FocusScope",Dt=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...u}=e,[l,p]=i.useState(null),c=he(o),h=he(s),y=i.useRef(null),E=oe(t,C=>p(C)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let C=a(function(N){if(x.paused||!l)return;const P=N.target;l.contains(P)?y.current=P:Y(y.current,{select:!0})},"handleFocusIn2"),S=a(function(N){if(x.paused||!l)return;const P=N.relatedTarget;P!==null&&(l.contains(P)||Y(y.current,{select:!0}))},"handleFocusOut2"),I=a(function(N){if(document.activeElement===document.body)for(const P of N)P.removedNodes.length>0&&Y(l)},"handleMutations2");document.addEventListener("focusin",C),document.addEventListener("focusout",S);const _=new MutationObserver(I);return l&&_.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",S),_.disconnect()}}},[r,l,x.paused]),i.useEffect(()=>{if(l){lt.add(x);const C=document.activeElement;if(!l.contains(C)){const S=new CustomEvent(_e,it);l.addEventListener(_e,c),l.dispatchEvent(S),S.defaultPrevented||(Sr(Pr(Pt(l)),{select:!0}),document.activeElement===C&&Y(l))}return()=>{l.removeEventListener(_e,c),setTimeout(()=>{const S=new CustomEvent(Ie,it);l.addEventListener(Ie,h),l.dispatchEvent(S),S.defaultPrevented||Y(C??document.body,{select:!0}),l.removeEventListener(Ie,h),lt.remove(x)},0)}}},[l,c,h,x]);const R=i.useCallback(C=>{if(!n&&!r||x.paused)return;const S=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,I=document.activeElement;if(S&&I){const _=C.currentTarget,[N,P]=Or(_);N&&P?!C.shiftKey&&I===P?(C.preventDefault(),n&&Y(N,{select:!0})):C.shiftKey&&I===N&&(C.preventDefault(),n&&Y(P,{select:!0})):I===_&&C.preventDefault()}},[n,r,x.paused]);return(0,f.jsx)(T.div,{tabIndex:-1,...u,ref:E,onKeyDown:R})});Dt.displayName=Cr;function Sr(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Y(r,{select:t}),document.activeElement!==n)return}a(Sr,"focusFirst");function Or(e){const t=Pt(e);return[at(t,e),at(t.reverse(),e)]}a(Or,"getTabbableEdges");function Pt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a(r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}a(Pt,"getTabbableCandidates");function at(e,t){for(const n of e)if(!Nr(n,{upTo:t}))return n}a(at,"findVisible");function Nr(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}a(Nr,"isHidden");function Rr(e){return e instanceof HTMLInputElement&&"select"in e}a(Rr,"isSelectableInput");function Y(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rr(e)&&t&&e.select()}}a(Y,"focus");var lt=Dr();function Dr(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ut(e,t),e.unshift(t)},remove(t){e=ut(e,t),e[0]?.resume()}}}a(Dr,"createFocusScopesStack");function ut(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}a(ut,"arrayRemove");function Pr(e){return e.filter(t=>t.tagName!=="A")}a(Pr,"removeLinks");var _r="Portal",_t=i.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=i.useState(!1);me(()=>s(!0),[]);const u=n||o&&globalThis?.document?.body;return u?Ct.createPortal((0,f.jsx)(T.div,{...r,ref:t}),u):null});_t.displayName=_r;function Ir(e,t){return i.useReducer((n,r)=>t[n][r]??n,e)}a(Ir,"useStateMachine");var Se=a(e=>{const{present:t,children:n}=e,r=Ar(t),o=typeof n=="function"?n({present:r.isPresent}):i.Children.only(n),s=oe(r.ref,Tr(o));return typeof n=="function"||r.isPresent?i.cloneElement(o,{ref:s}):null},"Presence");Se.displayName="Presence";function Ar(e){const[t,n]=i.useState(),r=i.useRef(null),o=i.useRef(e),s=i.useRef("none"),[u,l]=Ir(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const p=be(r.current);s.current=u==="mounted"?p:"none"},[u]),me(()=>{const p=r.current,c=o.current;if(c!==e){const h=s.current,y=be(p);e?l("MOUNT"):y==="none"||p?.display==="none"?l("UNMOUNT"):l(c&&h!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),me(()=>{if(t){let p;const c=t.ownerDocument.defaultView??window,h=a(E=>{const x=be(r.current).includes(CSS.escape(E.animationName));if(E.target===t&&x&&(l("ANIMATION_END"),!o.current)){const R=t.style.animationFillMode;t.style.animationFillMode="forwards",p=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=R)})}},"handleAnimationEnd"),y=a(E=>{E.target===t&&(s.current=be(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{c.clearTimeout(p),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:i.useCallback(p=>{r.current=p?getComputedStyle(p):null,n(p)},[])}}a(Ar,"usePresence");function be(e){return e?.animationName||"none"}a(be,"getAnimationName");function Tr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}a(Tr,"getElementRef");var Ae=0;function Mr(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ct()),document.body.insertAdjacentElement("beforeend",e[1]??ct()),Ae++,()=>{Ae===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ae--}},[])}a(Mr,"useFocusGuards");function ct(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}a(ct,"createFocusGuard");var Oe="Dialog",[It,Vo]=tr(Oe),[kr,W]=It(Oe),At=a(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:u=!0}=e,l=i.useRef(null),p=i.useRef(null),[c,h]=ir({prop:r,defaultProp:o??!1,onChange:s,caller:Oe});return(0,f.jsx)(kr,{scope:t,triggerRef:l,contentRef:p,contentId:K(),titleId:K(),descriptionId:K(),open:c,onOpenChange:h,onOpenToggle:i.useCallback(()=>h(y=>!y),[h]),modal:u,children:n})},"Dialog");At.displayName=Oe;var Tt="DialogTrigger",jr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=W(Tt,n),s=oe(t,o.triggerRef);return(0,f.jsx)(T.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Be(o.open),...r,ref:s,onClick:J(e.onClick,o.onOpenToggle)})});jr.displayName=Tt;var Ve="DialogPortal",[Fr,Mt]=It(Ve,{forceMount:void 0}),kt=a(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=W(Ve,t);return(0,f.jsx)(Fr,{scope:t,forceMount:n,children:i.Children.map(r,u=>(0,f.jsx)(Se,{present:n||s.open,children:(0,f.jsx)(_t,{asChild:!0,container:o,children:u})}))})},"DialogPortal");kt.displayName=Ve;var xe="DialogOverlay",jt=i.forwardRef((e,t)=>{const n=Mt(xe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=W(xe,e.__scopeDialog);return s.modal?(0,f.jsx)(Se,{present:r||s.open,children:(0,f.jsx)($r,{...o,ref:t})}):null});jt.displayName=xe;var Lr=St("DialogOverlay.RemoveScroll"),$r=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=W(xe,n);return(0,f.jsx)(En,{as:Lr,allowPinchZoom:!0,shards:[o.contentRef],children:(0,f.jsx)(T.div,{"data-state":Be(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ne="DialogContent",Ft=i.forwardRef((e,t)=>{const n=Mt(ne,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=W(ne,e.__scopeDialog);return(0,f.jsx)(Se,{present:r||s.open,children:s.modal?(0,f.jsx)(Qr,{...o,ref:t}):(0,f.jsx)(zr,{...o,ref:t})})});Ft.displayName=ne;var Qr=i.forwardRef((e,t)=>{const n=W(ne,e.__scopeDialog),r=i.useRef(null),o=oe(t,n.contentRef,r);return i.useEffect(()=>{const s=r.current;if(s)return vn(s)},[]),(0,f.jsx)(Lt,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(e.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,s=>{const u=s.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0;(u.button===2||l)&&s.preventDefault()}),onFocusOutside:J(e.onFocusOutside,s=>s.preventDefault())})}),zr=i.forwardRef((e,t)=>{const n=W(ne,e.__scopeDialog),r=i.useRef(!1),o=i.useRef(!1);return(0,f.jsx)(Lt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a(s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},"onCloseAutoFocus"),onInteractOutside:a(s=>{e.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const u=s.target;n.triggerRef.current?.contains(u)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()},"onInteractOutside")})}),Lt=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...u}=e,l=W(ne,n),p=i.useRef(null),c=oe(t,p);return Mr(),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Dt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:(0,f.jsx)(Nt,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Be(l.open),...u,ref:c,onDismiss:a(()=>l.onOpenChange(!1),"onDismiss")})}),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Hr,{titleId:l.titleId}),(0,f.jsx)(Kr,{contentRef:p,descriptionId:l.descriptionId})]})]})}),Ke="DialogTitle",Wr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=W(Ke,n);return(0,f.jsx)(T.h2,{id:o.titleId,...r,ref:t})});Wr.displayName=Ke;var $t="DialogDescription",qr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=W($t,n);return(0,f.jsx)(T.p,{id:o.descriptionId,...r,ref:t})});qr.displayName=$t;var Qt="DialogClose",Ur=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=W(Qt,n);return(0,f.jsx)(T.button,{type:"button",...r,ref:t,onClick:J(e.onClick,()=>o.onOpenChange(!1))})});Ur.displayName=Qt;function Be(e){return e?"open":"closed"}a(Be,"getState");var zt="DialogTitleWarning",[Ko,Wt]=er(zt,{contentName:ne,titleName:Ke,docsSlug:"dialog"}),Hr=a(({titleId:e})=>{const t=Wt(zt),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1
+ var nn=Object.defineProperty;var a=(e,t)=>nn(e,"name",{value:t,configurable:!0});import{i as ze}from"./rolldown-runtime-ZpX3ckPj.js";import{$a as rn,A as on,Ba as Xe,D as sn,Da as an,E as ln,Fa as ht,G as k,Ga as Re,Ha as V,Ia as un,L as cn,La as Ye,M as Ue,Ma as Ze,Na as F,O as dn,Pa as fn,Qa as pn,Ra as vt,Ua as Je,Va as et,Za as mn,_ as hn,j as vn,k as gn,ka as yn,n as gt,qa as bn,v as En}from"./boxes-ULGOWIM3.js";import{Vt as xn,Wt as wn,r as Cn,rt as Sn,zt as On}from"./BreadcrumbContext-Cl4wMUsK.js";import{n as Nn}from"./dist-ZK4xjvL5.js";import{c as Rn,i as Dn,o as Pn,r as _n,t as In}from"./dialog-TATv1tMA.js";import{t as An}from"./check-Cp2wC8NS.js";import{t as yt}from"./x-CPM6OYGf.js";var Tn=class extends ht{static{a(this,"MutationCache")}#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){const r=new an({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);const t=ye(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=ye(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=ye(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=ye(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){F.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=>Xe(t,n))}findAll(e={}){return this.getAll().filter(t=>Xe(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(V))))}};function ye(e){return e.options.scope?.id}a(ye,"scopeFor");var Mn=class extends ht{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const r=t.queryKey,o=t.queryHash??vt(r,t);let s=this.get(o);return s||(s=new yn({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(s)),s}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(){F.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=>et(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>et(e,n)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$o=class{static{a(this,"QueryClient")}#e;#t;#n;#o;#s;#r;#i;#a;constructor(e={}){this.#e=e.queryCache||new Mn,this.#t=e.mutationCache||new Tn,this.#n=e.defaultOptions||{},this.#o=new Map,this.#s=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#i=fn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Ze.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=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),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Re(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(r.queryHash)?.state.data,s=un(t,o);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return F.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;F.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return F.batch(()=>{const r=n.findAll(e),o=new Set(r);return r.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:a(s=>o.has(s),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=F.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(V).catch(V)}invalidateQueries(e,t={}){return F.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},r=F.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(V)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(V)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),r=n.isStaleByTime(Re(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Re(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(V).catch(V)}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(V).catch(V)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ze.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#o.set(Ye(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(r=>{Je(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#s.set(Ye(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{Je(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vt(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===bn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},i=ze(rn(),1),f=ze(mn(),1),kn=Object.defineProperty,ve=a((e,t)=>kn(e,"name",{value:t,configurable:!0}),"__name"),We="Collapsible",[jn,Qo]=vn(We),[Fn,He]=jn(We),Ln=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,open:o,defaultOpen:s,disabled:u,onOpenChange:l,...p}=t,[c,h]=dn({prop:o,defaultProp:s??!1,onChange:l,caller:We});return(0,f.jsx)(Fn,{scope:r,disabled:u,contentId:ln(),open:c,onOpenToggle:i.useCallback(()=>h(y=>!y),[h]),children:(0,f.jsx)(Ue.div,{"data-state":Ce(c),"data-disabled":u?"":void 0,...p,ref:n})})},"Collapsible2"),"Collapsible")),$n="CollapsibleTrigger",Qn=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,...o}=t,s=He($n,r);return(0,f.jsx)(Ue.button,{type:"button","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open||!1,"data-state":Ce(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...o,ref:n,onClick:on(t.onClick,s.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),bt="CollapsibleContent",qn=i.forwardRef(ve(a(function(t,n){const{forceMount:r,...o}=t,s=He(bt,t.__scopeCollapsible);return(0,f.jsx)(sn,{present:r||s.open,children:a(({present:u})=>(0,f.jsx)(zn,{...o,ref:n,present:u}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),zn=i.forwardRef(ve(a(function(t,n){const{__scopeCollapsible:r,present:o,children:s,...u}=t,l=He(bt,r),[p,c]=i.useState(o),h=i.useRef(null),y=cn(n,h),E=i.useRef(0),x=E.current,R=i.useRef(0),C=R.current,S=l.open||p,I=i.useRef(S),_=i.useRef(void 0);return i.useEffect(()=>{const N=requestAnimationFrame(()=>I.current=!1);return()=>cancelAnimationFrame(N)},[]),gn(()=>{const N=h.current;if(N){_.current=_.current||{transitionDuration:N.style.transitionDuration,animationName:N.style.animationName},N.style.transitionDuration="0s",N.style.animationName="none";const P=N.getBoundingClientRect();E.current=P.height,R.current=P.width,I.current||(N.style.transitionDuration=_.current.transitionDuration,N.style.animationName=_.current.animationName),c(o)}},[l.open,o]),(0,f.jsx)(Ue.div,{"data-state":Ce(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...u,ref:y,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:S&&s})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function Ce(e){return e?"open":"closed"}a(Ce,"getState$1");ve(Ce,"getState");var Un=Ln,Et={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]};Et.node;var Wn=gt(Et),xt={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};xt.node;var qo=gt(xt);function zo({...e}){return(0,f.jsx)(Un,{"data-slot":"collapsible",...e})}a(zo,"Collapsible");function Uo({...e}){return(0,f.jsx)(Qn,{"data-slot":"collapsible-trigger",...e})}a(Uo,"CollapsibleTrigger");function Wo({...e}){return(0,f.jsx)(qn,{"data-slot":"collapsible-content",...e})}a(Wo,"CollapsibleContent");var tt=1,Hn=.9,Vn=.8,Kn=.17,De=.1,Pe=.999,Bn=.9999,Gn=.99,Xn=/[\\\/_+.#"@\[\(\{&]/,Yn=/[\\\/_+.#"@\[\(\{&]/g,Zn=/[\s-]/,wt=/[\s-]/g;function je(e,t,n,r,o,s,u){if(s===t.length)return o===e.length?tt:Gn;var l=`${o},${s}`;if(u[l]!==void 0)return u[l];for(var p=r.charAt(s),c=n.indexOf(p,o),h=0,y,E,x,R;c>=0;)y=je(e,t,n,r,c+1,s+1,u),y>h&&(c===o?y*=tt:Xn.test(e.charAt(c-1))?(y*=Vn,x=e.slice(o,c-1).match(Yn),x&&o>0&&(y*=Math.pow(Pe,x.length))):Zn.test(e.charAt(c-1))?(y*=Hn,R=e.slice(o,c-1).match(wt),R&&o>0&&(y*=Math.pow(Pe,R.length))):(y*=Kn,o>0&&(y*=Math.pow(Pe,c-o))),e.charAt(c)!==t.charAt(s)&&(y*=Bn)),(y<De&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(E=je(e,t,n,r,c+1,s+2,u),E*De>y&&(y=E*De)),y>h&&(h=y),c=n.indexOf(p,c+1);return u[l]=h,h}a(je,"G");function nt(e){return e.toLowerCase().replace(wt," ")}a(nt,"D");function Jn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,je(e,t,nt(e),nt(t),0,0,{})}a(Jn,"W");var Ho=!!(typeof window<"u"&&window.document&&window.document.createElement);function Z(e,t,{checkForDefaultPrevented:n=!0}={}){return a(function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)},"handleEvent")}a(Z,"composeEventHandlers");function rt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}a(rt,"setRef");function te(...e){return t=>{let n=!1;const r=e.map(o=>{const s=rt(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():rt(e[o],null)}}}}a(te,"composeRefs");function oe(...e){return i.useCallback(te(...e),e)}a(oe,"useComposedRefs");function er(e,t){const n=i.createContext(t),r=a(s=>{const{children:u,...l}=s,p=i.useMemo(()=>l,Object.values(l));return(0,f.jsx)(n.Provider,{value:p,children:u})},"Provider");r.displayName=e+"Provider";function o(s){const u=i.useContext(n);if(u)return u;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return a(o,"useContext2"),[r,o]}a(er,"createContext2");function tr(e,t=[]){let n=[];function r(s,u){const l=i.createContext(u),p=n.length;n=[...n,u];const c=a(y=>{const{scope:E,children:x,...R}=y,C=E?.[e]?.[p]||l,S=i.useMemo(()=>R,Object.values(R));return(0,f.jsx)(C.Provider,{value:S,children:x})},"Provider");c.displayName=s+"Provider";function h(y,E){const x=E?.[e]?.[p]||l,R=i.useContext(x);if(R)return R;if(u!==void 0)return u;throw new Error(`\`${y}\` must be used within \`${s}\``)}return a(h,"useContext2"),[c,h]}a(r,"createContext3");const o=a(()=>{const s=n.map(u=>i.createContext(u));return a(function(l){const p=l?.[e]||s;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:p}}),[l,p])},"useScope")},"createScope");return o.scopeName=e,[r,nr(o,...t)]}a(tr,"createContextScope");function nr(...e){const t=e[0];if(e.length===1)return t;const n=a(()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return a(function(s){const u=r.reduce((l,{useScope:p,scopeName:c})=>{const h=p(s)[`__scope${c}`];return{...l,...h}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}a(nr,"composeContextScopes");var me=globalThis?.document?i.useLayoutEffect:()=>{},rr=i[" useId ".trim().toString()]||(()=>{}),or=0;function K(e){const[t,n]=i.useState(rr());return me(()=>{e||n(r=>r??String(or++))},[e]),e||(t?`radix-${t}`:"")}a(K,"useId");var sr=i[" useInsertionEffect ".trim().toString()]||me;function ir({prop:e,defaultProp:t,onChange:n=a(()=>{},"onChange"),caller:r}){const[o,s,u]=ar({defaultProp:t,onChange:n}),l=e!==void 0,p=l?e:o;{const c=i.useRef(e!==void 0);i.useEffect(()=>{const h=c.current;c.current=l},[l,r])}return[p,i.useCallback(c=>{if(l){const h=lr(c)?c(e):c;h!==e&&u.current?.(h)}else s(c)},[l,e,s,u])]}a(ir,"useControllableState");function ar({defaultProp:e,onChange:t}){const[n,r]=i.useState(e),o=i.useRef(n),s=i.useRef(t);return sr(()=>{s.current=t},[t]),i.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}a(ar,"useUncontrolledState");function lr(e){return typeof e=="function"}a(lr,"isFunction");var Ct=ze(pn(),1);function St(e){const t=ur(e),n=i.forwardRef((r,o)=>{const{children:s,...u}=r,l=i.Children.toArray(s),p=l.find(dr);if(p){const c=p.props.children,h=l.map(y=>y===p?i.Children.count(c)>1?i.Children.only(null):i.isValidElement(c)?c.props.children:null:y);return(0,f.jsx)(t,{...u,ref:o,children:i.isValidElement(c)?i.cloneElement(c,void 0,h):null})}return(0,f.jsx)(t,{...u,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}a(St,"createSlot");function ur(e){const t=i.forwardRef((n,r)=>{const{children:o,...s}=n;if(i.isValidElement(o)){const u=pr(o),l=fr(s,o.props);return o.type!==i.Fragment&&(l.ref=r?te(r,u):u),i.cloneElement(o,l)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}a(ur,"createSlotClone");var cr=Symbol("radix.slottable");function dr(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cr}a(dr,"isSlottable");function fr(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...u)=>{const l=s(...u);return o(...u),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}a(fr,"mergeProps");function pr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}a(pr,"getElementRef$1");var T=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=St(`Primitive.${t}`),r=i.forwardRef((o,s)=>{const{asChild:u,...l}=o,p=u?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,f.jsx)(p,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mr(e,t){e&&Ct.flushSync(()=>e.dispatchEvent(t))}a(mr,"dispatchDiscreteCustomEvent");function he(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>t.current?.(...n),[])}a(he,"useCallbackRef");function hr(e,t=globalThis?.document){const n=he(e);i.useEffect(()=>{const r=a(o=>{o.key==="Escape"&&n(o)},"handleKeyDown");return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}a(hr,"useEscapeKeydown");var vr="DismissableLayer",Fe="dismissableLayer.update",gr="dismissableLayer.pointerDownOutside",yr="dismissableLayer.focusOutside",ot,Ot=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nt=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:u,onDismiss:l,...p}=e,c=i.useContext(Ot),[h,y]=i.useState(null),E=h?.ownerDocument??globalThis?.document,[,x]=i.useState({}),R=oe(t,w=>y(w)),C=Array.from(c.layers),[S]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),I=C.indexOf(S),_=h?C.indexOf(h):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,P=_>=I,Q=xr(w=>{const W=w.target,L=[...c.branches].some(U=>U.contains(W));!P||L||(o?.(w),u?.(w),w.defaultPrevented||l?.())},E),D=wr(w=>{const W=w.target;[...c.branches].some(L=>L.contains(W))||(s?.(w),u?.(w),w.defaultPrevented||l?.())},E);return hr(w=>{_===c.layers.size-1&&(r?.(w),!w.defaultPrevented&&l&&(w.preventDefault(),l()))},E),i.useEffect(()=>{if(h)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(ot=E.body.style.pointerEvents,E.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(h)),c.layers.add(h),st(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(E.body.style.pointerEvents=ot)}},[h,E,n,c]),i.useEffect(()=>()=>{h&&(c.layers.delete(h),c.layersWithOutsidePointerEventsDisabled.delete(h),st())},[h,c]),i.useEffect(()=>{const w=a(()=>x({}),"handleUpdate");return document.addEventListener(Fe,w),()=>document.removeEventListener(Fe,w)},[]),(0,f.jsx)(T.div,{...p,ref:R,style:{pointerEvents:N?P?"auto":"none":void 0,...e.style},onFocusCapture:Z(e.onFocusCapture,D.onFocusCapture),onBlurCapture:Z(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Z(e.onPointerDownCapture,Q.onPointerDownCapture)})});Nt.displayName=vr;var br="DismissableLayerBranch",Er=i.forwardRef((e,t)=>{const n=i.useContext(Ot),r=i.useRef(null),o=oe(t,r);return i.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),(0,f.jsx)(T.div,{...e,ref:o})});Er.displayName=br;function xr(e,t=globalThis?.document){const n=he(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const s=a(l=>{if(l.target&&!r.current){let p=a(function(){Rt(gr,n,c,{discrete:!0})},"handleAndDispatchPointerDownOutsideEvent2");const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=p,t.addEventListener("click",o.current,{once:!0})):p()}else t.removeEventListener("click",o.current);r.current=!1},"handlePointerDown"),u=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(u),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:a(()=>r.current=!0,"onPointerDownCapture")}}a(xr,"usePointerDownOutside");function wr(e,t=globalThis?.document){const n=he(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a(s=>{s.target&&!r.current&&Rt(yr,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:a(()=>r.current=!0,"onFocusCapture"),onBlurCapture:a(()=>r.current=!1,"onBlurCapture")}}a(wr,"useFocusOutside");function st(){const e=new CustomEvent(Fe);document.dispatchEvent(e)}a(st,"dispatchUpdate");function Rt(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?mr(o,s):o.dispatchEvent(s)}a(Rt,"handleAndDispatchCustomEvent");var _e="focusScope.autoFocusOnMount",Ie="focusScope.autoFocusOnUnmount",it={bubbles:!1,cancelable:!0},Cr="FocusScope",Dt=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...u}=e,[l,p]=i.useState(null),c=he(o),h=he(s),y=i.useRef(null),E=oe(t,C=>p(C)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let C=a(function(N){if(x.paused||!l)return;const P=N.target;l.contains(P)?y.current=P:Y(y.current,{select:!0})},"handleFocusIn2"),S=a(function(N){if(x.paused||!l)return;const P=N.relatedTarget;P!==null&&(l.contains(P)||Y(y.current,{select:!0}))},"handleFocusOut2"),I=a(function(N){if(document.activeElement===document.body)for(const P of N)P.removedNodes.length>0&&Y(l)},"handleMutations2");document.addEventListener("focusin",C),document.addEventListener("focusout",S);const _=new MutationObserver(I);return l&&_.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",S),_.disconnect()}}},[r,l,x.paused]),i.useEffect(()=>{if(l){lt.add(x);const C=document.activeElement;if(!l.contains(C)){const S=new CustomEvent(_e,it);l.addEventListener(_e,c),l.dispatchEvent(S),S.defaultPrevented||(Sr(Pr(Pt(l)),{select:!0}),document.activeElement===C&&Y(l))}return()=>{l.removeEventListener(_e,c),setTimeout(()=>{const S=new CustomEvent(Ie,it);l.addEventListener(Ie,h),l.dispatchEvent(S),S.defaultPrevented||Y(C??document.body,{select:!0}),l.removeEventListener(Ie,h),lt.remove(x)},0)}}},[l,c,h,x]);const R=i.useCallback(C=>{if(!n&&!r||x.paused)return;const S=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,I=document.activeElement;if(S&&I){const _=C.currentTarget,[N,P]=Or(_);N&&P?!C.shiftKey&&I===P?(C.preventDefault(),n&&Y(N,{select:!0})):C.shiftKey&&I===N&&(C.preventDefault(),n&&Y(P,{select:!0})):I===_&&C.preventDefault()}},[n,r,x.paused]);return(0,f.jsx)(T.div,{tabIndex:-1,...u,ref:E,onKeyDown:R})});Dt.displayName=Cr;function Sr(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Y(r,{select:t}),document.activeElement!==n)return}a(Sr,"focusFirst");function Or(e){const t=Pt(e);return[at(t,e),at(t.reverse(),e)]}a(Or,"getTabbableEdges");function Pt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a(r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}a(Pt,"getTabbableCandidates");function at(e,t){for(const n of e)if(!Nr(n,{upTo:t}))return n}a(at,"findVisible");function Nr(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}a(Nr,"isHidden");function Rr(e){return e instanceof HTMLInputElement&&"select"in e}a(Rr,"isSelectableInput");function Y(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rr(e)&&t&&e.select()}}a(Y,"focus");var lt=Dr();function Dr(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ut(e,t),e.unshift(t)},remove(t){e=ut(e,t),e[0]?.resume()}}}a(Dr,"createFocusScopesStack");function ut(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}a(ut,"arrayRemove");function Pr(e){return e.filter(t=>t.tagName!=="A")}a(Pr,"removeLinks");var _r="Portal",_t=i.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=i.useState(!1);me(()=>s(!0),[]);const u=n||o&&globalThis?.document?.body;return u?Ct.createPortal((0,f.jsx)(T.div,{...r,ref:t}),u):null});_t.displayName=_r;function Ir(e,t){return i.useReducer((n,r)=>t[n][r]??n,e)}a(Ir,"useStateMachine");var Se=a(e=>{const{present:t,children:n}=e,r=Ar(t),o=typeof n=="function"?n({present:r.isPresent}):i.Children.only(n),s=oe(r.ref,Tr(o));return typeof n=="function"||r.isPresent?i.cloneElement(o,{ref:s}):null},"Presence");Se.displayName="Presence";function Ar(e){const[t,n]=i.useState(),r=i.useRef(null),o=i.useRef(e),s=i.useRef("none"),[u,l]=Ir(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const p=be(r.current);s.current=u==="mounted"?p:"none"},[u]),me(()=>{const p=r.current,c=o.current;if(c!==e){const h=s.current,y=be(p);e?l("MOUNT"):y==="none"||p?.display==="none"?l("UNMOUNT"):l(c&&h!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),me(()=>{if(t){let p;const c=t.ownerDocument.defaultView??window,h=a(E=>{const x=be(r.current).includes(CSS.escape(E.animationName));if(E.target===t&&x&&(l("ANIMATION_END"),!o.current)){const R=t.style.animationFillMode;t.style.animationFillMode="forwards",p=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=R)})}},"handleAnimationEnd"),y=a(E=>{E.target===t&&(s.current=be(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{c.clearTimeout(p),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:i.useCallback(p=>{r.current=p?getComputedStyle(p):null,n(p)},[])}}a(Ar,"usePresence");function be(e){return e?.animationName||"none"}a(be,"getAnimationName");function Tr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}a(Tr,"getElementRef");var Ae=0;function Mr(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ct()),document.body.insertAdjacentElement("beforeend",e[1]??ct()),Ae++,()=>{Ae===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ae--}},[])}a(Mr,"useFocusGuards");function ct(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}a(ct,"createFocusGuard");var Oe="Dialog",[It,Vo]=tr(Oe),[kr,z]=It(Oe),At=a(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:u=!0}=e,l=i.useRef(null),p=i.useRef(null),[c,h]=ir({prop:r,defaultProp:o??!1,onChange:s,caller:Oe});return(0,f.jsx)(kr,{scope:t,triggerRef:l,contentRef:p,contentId:K(),titleId:K(),descriptionId:K(),open:c,onOpenChange:h,onOpenToggle:i.useCallback(()=>h(y=>!y),[h]),modal:u,children:n})},"Dialog");At.displayName=Oe;var Tt="DialogTrigger",jr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=z(Tt,n),s=oe(t,o.triggerRef);return(0,f.jsx)(T.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Be(o.open),...r,ref:s,onClick:Z(e.onClick,o.onOpenToggle)})});jr.displayName=Tt;var Ve="DialogPortal",[Fr,Mt]=It(Ve,{forceMount:void 0}),kt=a(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=z(Ve,t);return(0,f.jsx)(Fr,{scope:t,forceMount:n,children:i.Children.map(r,u=>(0,f.jsx)(Se,{present:n||s.open,children:(0,f.jsx)(_t,{asChild:!0,container:o,children:u})}))})},"DialogPortal");kt.displayName=Ve;var xe="DialogOverlay",jt=i.forwardRef((e,t)=>{const n=Mt(xe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=z(xe,e.__scopeDialog);return s.modal?(0,f.jsx)(Se,{present:r||s.open,children:(0,f.jsx)($r,{...o,ref:t})}):null});jt.displayName=xe;var Lr=St("DialogOverlay.RemoveScroll"),$r=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=z(xe,n);return(0,f.jsx)(En,{as:Lr,allowPinchZoom:!0,shards:[o.contentRef],children:(0,f.jsx)(T.div,{"data-state":Be(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ne="DialogContent",Ft=i.forwardRef((e,t)=>{const n=Mt(ne,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=z(ne,e.__scopeDialog);return(0,f.jsx)(Se,{present:r||s.open,children:s.modal?(0,f.jsx)(Qr,{...o,ref:t}):(0,f.jsx)(qr,{...o,ref:t})})});Ft.displayName=ne;var Qr=i.forwardRef((e,t)=>{const n=z(ne,e.__scopeDialog),r=i.useRef(null),o=oe(t,n.contentRef,r);return i.useEffect(()=>{const s=r.current;if(s)return hn(s)},[]),(0,f.jsx)(Lt,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Z(e.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Z(e.onPointerDownOutside,s=>{const u=s.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0;(u.button===2||l)&&s.preventDefault()}),onFocusOutside:Z(e.onFocusOutside,s=>s.preventDefault())})}),qr=i.forwardRef((e,t)=>{const n=z(ne,e.__scopeDialog),r=i.useRef(!1),o=i.useRef(!1);return(0,f.jsx)(Lt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a(s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},"onCloseAutoFocus"),onInteractOutside:a(s=>{e.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const u=s.target;n.triggerRef.current?.contains(u)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()},"onInteractOutside")})}),Lt=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...u}=e,l=z(ne,n),p=i.useRef(null),c=oe(t,p);return Mr(),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Dt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:(0,f.jsx)(Nt,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Be(l.open),...u,ref:c,onDismiss:a(()=>l.onOpenChange(!1),"onDismiss")})}),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Hr,{titleId:l.titleId}),(0,f.jsx)(Kr,{contentRef:p,descriptionId:l.descriptionId})]})]})}),Ke="DialogTitle",zr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=z(Ke,n);return(0,f.jsx)(T.h2,{id:o.titleId,...r,ref:t})});zr.displayName=Ke;var $t="DialogDescription",Ur=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=z($t,n);return(0,f.jsx)(T.p,{id:o.descriptionId,...r,ref:t})});Ur.displayName=$t;var Qt="DialogClose",Wr=i.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=z(Qt,n);return(0,f.jsx)(T.button,{type:"button",...r,ref:t,onClick:Z(e.onClick,()=>o.onOpenChange(!1))})});Wr.displayName=Qt;function Be(e){return e?"open":"closed"}a(Be,"getState");var qt="DialogTitleWarning",[Ko,zt]=er(qt,{contentName:ne,titleName:Ke,docsSlug:"dialog"}),Hr=a(({titleId:e})=>{const t=zt(qt),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2
2
 
3
3
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
4
4
 
5
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&document.getElementById(e)},[n,e]),null},"TitleWarning"),Vr="DialogDescriptionWarning",Kr=a(({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wt(Vr).contentName}}.`;return i.useEffect(()=>{const r=e.current?.getAttribute("aria-describedby");t&&r&&document.getElementById(t)},[n,e,t]),null},"DescriptionWarning"),Br=At,Gr=kt,Xr=jt,Yr=Ft,pe='[cmdk-group=""]',Te='[cmdk-group-items=""]',Jr='[cmdk-group-heading=""]',qt='[cmdk-item=""]',dt=`${qt}:not([aria-disabled="true"])`,Le="cmdk-item-select",ae="data-value",Zr=a((e,t,n)=>Zn(e,t,n),"Re"),Ut=i.createContext(void 0),ge=a(()=>i.useContext(Ut),"K"),Ht=i.createContext(void 0),Ge=a(()=>i.useContext(Ht),"ee"),Vt=i.createContext(void 0),Kt=i.forwardRef((e,t)=>{let n=le(()=>{var d,m;return{search:"",value:(m=(d=e.value)!=null?d:e.defaultValue)!=null?m:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=le(()=>new Set),o=le(()=>new Map),s=le(()=>new Map),u=le(()=>new Set),l=Bt(e),{label:p,children:c,value:h,onValueChange:y,filter:E,shouldFilter:x,loop:R,disablePointerSelection:C=!1,vimBindings:S=!0,...I}=e,_=K(),N=K(),P=K(),Q=i.useRef(null),D=co();re(()=>{if(h!==void 0){let d=h.trim();n.current.value=d,w.emit()}},[h]),re(()=>{D(6,ie)},[]);let w=i.useMemo(()=>({subscribe:a(d=>(u.current.add(d),()=>u.current.delete(d)),"subscribe"),snapshot:a(()=>n.current,"snapshot"),setState:a((d,m,g)=>{var v,b,O,A;if(!Object.is(n.current[d],m)){if(n.current[d]=m,d==="search")M(),q(),D(1,ee);else if(d==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let j=document.getElementById(P);j?j.focus():(v=document.getElementById(_))==null||v.focus()}if(D(7,()=>{var j;n.current.selectedItemId=(j=B())==null?void 0:j.id,w.emit()}),g||D(5,ie),((b=l.current)==null?void 0:b.value)!==void 0){let j=m??"";(A=(O=l.current).onValueChange)==null||A.call(O,j);return}}w.emit()}},"setState"),emit:a(()=>{u.current.forEach(d=>d())},"emit")}),[]),U=i.useMemo(()=>({value:a((d,m,g)=>{var v;m!==((v=s.current.get(d))==null?void 0:v.value)&&(s.current.set(d,{value:m,keywords:g}),n.current.filtered.items.set(d,L(m,g)),D(2,()=>{q(),w.emit()}))},"value"),item:a((d,m)=>(r.current.add(d),m&&(o.current.has(m)?o.current.get(m).add(d):o.current.set(m,new Set([d]))),D(3,()=>{M(),q(),n.current.value||ee(),w.emit()}),()=>{s.current.delete(d),r.current.delete(d),n.current.filtered.items.delete(d);let g=B();D(4,()=>{M(),g?.getAttribute("id")===d&&ee(),w.emit()})}),"item"),group:a(d=>(o.current.has(d)||o.current.set(d,new Set),()=>{s.current.delete(d),o.current.delete(d)}),"group"),filter:a(()=>l.current.shouldFilter,"filter"),label:p||e["aria-label"],getDisablePointerSelection:a(()=>l.current.disablePointerSelection,"getDisablePointerSelection"),listId:_,inputId:P,labelId:N,listInnerRef:Q}),[]);function L(d,m){var g,v;let b=(v=(g=l.current)==null?void 0:g.filter)!=null?v:Zr;return d?b(d,n.current.search,m):0}a(L,"te");function q(){if(!n.current.search||l.current.shouldFilter===!1)return;let d=n.current.filtered.items,m=[];n.current.filtered.groups.forEach(v=>{let b=o.current.get(v),O=0;b.forEach(A=>{let j=d.get(A);O=Math.max(j,O)}),m.push([v,O])});let g=Q.current;H().sort((v,b)=>{var O,A;let j=v.getAttribute("id"),tn=b.getAttribute("id");return((O=d.get(tn))!=null?O:0)-((A=d.get(j))!=null?A:0)}).forEach(v=>{let b=v.closest(Te);b?b.appendChild(v.parentElement===b?v:v.closest(`${Te} > *`)):g.appendChild(v.parentElement===g?v:v.closest(`${Te} > *`))}),m.sort((v,b)=>b[1]-v[1]).forEach(v=>{var b;let O=(b=Q.current)==null?void 0:b.querySelector(`${pe}[${ae}="${encodeURIComponent(v[0])}"]`);O?.parentElement.appendChild(O)})}a(q,"z");function ee(){let d=H().find(g=>g.getAttribute("aria-disabled")!=="true"),m=d?.getAttribute(ae);w.setState("value",m||void 0)}a(ee,"W");function M(){var d,m,g,v;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let b=0;for(let O of r.current){let A=L((m=(d=s.current.get(O))==null?void 0:d.value)!=null?m:"",(v=(g=s.current.get(O))==null?void 0:g.keywords)!=null?v:[]);n.current.filtered.items.set(O,A),A>0&&b++}for(let[O,A]of o.current)for(let j of A)if(n.current.filtered.items.get(j)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=b}a(M,"J");function ie(){var d,m,g;let v=B();v&&(((d=v.parentElement)==null?void 0:d.firstChild)===v&&((g=(m=v.closest(pe))==null?void 0:m.querySelector(Jr))==null||g.scrollIntoView({block:"nearest"})),v.scrollIntoView({block:"nearest"}))}a(ie,"ne");function B(){var d;return(d=Q.current)==null?void 0:d.querySelector(`${qt}[aria-selected="true"]`)}a(B,"M");function H(){var d;return Array.from(((d=Q.current)==null?void 0:d.querySelectorAll(dt))||[])}a(H,"V");function z(d){let m=H()[d];m&&w.setState("value",m.getAttribute(ae))}a(z,"X");function G(d){var m;let g=B(),v=H(),b=v.findIndex(A=>A===g),O=v[b+d];(m=l.current)!=null&&m.loop&&(O=b+d<0?v[v.length-1]:b+d===v.length?v[0]:v[b+d]),O&&w.setState("value",O.getAttribute(ae))}a(G,"Q");function ce(d){let m=B(),g=m?.closest(pe),v;for(;g&&!v;)g=d>0?lo(g,pe):uo(g,pe),v=g?.querySelector(dt);v?w.setState("value",v.getAttribute(ae)):G(d)}a(ce,"re");let de=a(()=>z(H().length-1),"oe"),fe=a(d=>{d.preventDefault(),d.metaKey?de():d.altKey?ce(1):G(1)},"ie"),X=a(d=>{d.preventDefault(),d.metaKey?z(0):d.altKey?ce(-1):G(-1)},"se");return i.createElement(T.div,{ref:t,tabIndex:-1,...I,"cmdk-root":"",onKeyDown:a(d=>{var m;(m=I.onKeyDown)==null||m.call(I,d);let g=d.nativeEvent.isComposing||d.keyCode===229;if(!(d.defaultPrevented||g))switch(d.key){case"n":case"j":S&&d.ctrlKey&&fe(d);break;case"ArrowDown":fe(d);break;case"p":case"k":S&&d.ctrlKey&&X(d);break;case"ArrowUp":X(d);break;case"Home":d.preventDefault(),z(0);break;case"End":d.preventDefault(),de();break;case"Enter":{d.preventDefault();let v=B();if(v){let b=new Event(Le);v.dispatchEvent(b)}}}},"onKeyDown")},i.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:po},p),Ne(e,d=>i.createElement(Ht.Provider,{value:w},i.createElement(Ut.Provider,{value:U},d))))}),eo=i.forwardRef((e,t)=>{var n,r;let o=K(),s=i.useRef(null),u=i.useContext(Vt),l=ge(),p=Bt(e),c=(r=(n=p.current)==null?void 0:n.forceMount)!=null?r:u?.forceMount;re(()=>{if(!c)return l.item(o,u?.id)},[c]);let h=Gt(o,s,[e.value,e.children,s],e.keywords),y=Ge(),E=Z(D=>D.value&&D.value===h.current),x=Z(D=>c||l.filter()===!1?!0:D.search?D.filtered.items.get(o)>0:!0);i.useEffect(()=>{let D=s.current;if(!(!D||e.disabled))return D.addEventListener(Le,R),()=>D.removeEventListener(Le,R)},[x,e.onSelect,e.disabled]);function R(){var D,w;C(),(w=(D=p.current).onSelect)==null||w.call(D,h.current)}a(R,"C");function C(){y.setState("value",h.current,!0)}if(a(C,"S"),!x)return null;let{disabled:S,value:I,onSelect:_,forceMount:N,keywords:P,...Q}=e;return i.createElement(T.div,{ref:te(s,t),...Q,id:o,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!E,"data-disabled":!!S,"data-selected":!!E,onPointerMove:S||l.getDisablePointerSelection()?void 0:C,onClick:S?void 0:R},e.children)}),to=i.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,u=K(),l=i.useRef(null),p=i.useRef(null),c=K(),h=ge(),y=Z(x=>o||h.filter()===!1?!0:x.search?x.filtered.groups.has(u):!0);re(()=>h.group(u),[]),Gt(u,l,[e.value,e.heading,p]);let E=i.useMemo(()=>({id:u,forceMount:o}),[o]);return i.createElement(T.div,{ref:te(l,t),...s,"cmdk-group":"",role:"presentation",hidden:y?void 0:!0},n&&i.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ne(e,x=>i.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},i.createElement(Vt.Provider,{value:E},x))))}),no=i.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=i.useRef(null),s=Z(u=>!u.search);return!n&&!s?null:i.createElement(T.div,{ref:te(o,t),...r,"cmdk-separator":"",role:"separator"})}),ro=i.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Ge(),u=Z(c=>c.search),l=Z(c=>c.selectedItemId),p=ge();return i.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),i.createElement(T.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":l,id:p.inputId,type:"text",value:o?e.value:u,onChange:a(c=>{o||s.setState("search",c.target.value),n?.(c.target.value)},"onChange")})}),oo=i.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=i.useRef(null),u=i.useRef(null),l=Z(c=>c.selectedItemId),p=ge();return i.useEffect(()=>{if(u.current&&s.current){let c=u.current,h=s.current,y,E=new ResizeObserver(()=>{y=requestAnimationFrame(()=>{let x=c.offsetHeight;h.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return E.observe(c),()=>{cancelAnimationFrame(y),E.unobserve(c)}}},[]),i.createElement(T.div,{ref:te(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:p.listId},Ne(e,c=>i.createElement("div",{ref:te(u,p.listInnerRef),"cmdk-list-sizer":""},c)))}),so=i.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:u,...l}=e;return i.createElement(Br,{open:n,onOpenChange:r},i.createElement(Gr,{container:u},i.createElement(Xr,{"cmdk-overlay":"",className:o}),i.createElement(Yr,{"aria-label":e.label,"cmdk-dialog":"",className:s},i.createElement(Kt,{ref:t,...l}))))}),io=i.forwardRef((e,t)=>Z(n=>n.filtered.count===0)?i.createElement(T.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ao=i.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return i.createElement(T.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ne(e,u=>i.createElement("div",{"aria-hidden":!0},u)))}),se=Object.assign(Kt,{List:oo,Item:eo,Input:ro,Group:to,Separator:no,Dialog:so,Empty:io,Loading:ao});function lo(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}a(lo,"we");function uo(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}a(uo,"De");function Bt(e){let t=i.useRef(e);return re(()=>{t.current=e}),t}a(Bt,"pe");var re=typeof window>"u"?i.useEffect:i.useLayoutEffect;function le(e){let t=i.useRef();return t.current===void 0&&(t.current=e()),t}a(le,"L");function Z(e){let t=Ge(),n=a(()=>e(t.snapshot()),"n");return i.useSyncExternalStore(t.subscribe,n,n)}a(Z,"P");function Gt(e,t,n,r=[]){let o=i.useRef(),s=ge();return re(()=>{var u;let l=(()=>{var c;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():o.current}})(),p=r.map(c=>c.trim());s.value(e,l,p),(u=t.current)==null||u.setAttribute(ae,l),o.current=l}),o}a(Gt,"ve");var co=a(()=>{let[e,t]=i.useState(),n=le(()=>new Map);return re(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}},"ke");function fo(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}a(fo,"Me");function Ne({asChild:e,children:t},n){return e&&i.isValidElement(t)?i.cloneElement(fo(t),{ref:t.ref},n(t.props.children)):n(t)}a(Ne,"B");var po={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Xt({className:e,...t}){return(0,f.jsx)(se,{"data-slot":"command",className:k("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}a(Xt,"Command");function Bo({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:o=!0,...s}){return(0,f.jsxs)(In,{...s,children:[(0,f.jsxs)(Pn,{className:"sr-only",children:[(0,f.jsx)(Rn,{children:e}),(0,f.jsx)(Dn,{children:t})]}),(0,f.jsxs)(_n,{className:k("overflow-hidden p-0",r),showCloseButton:!1,children:[(0,f.jsx)(Xt,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n}),o&&(0,f.jsxs)(Nn,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-0 right-2 flex h-12 items-center rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,f.jsx)(yt,{}),(0,f.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}a(Bo,"CommandDialog");function mo({className:e,...t}){return(0,f.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,f.jsx)(Sn,{className:"size-4 shrink-0 opacity-50"}),(0,f.jsx)(se.Input,{"data-slot":"command-input",className:k("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-base md:text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}a(mo,"CommandInput");function ho({className:e,...t}){return(0,f.jsx)(se.List,{"data-slot":"command-list",className:k("max-h-(--sz-300px) scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}a(ho,"CommandList");function vo({...e}){return(0,f.jsx)(se.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}a(vo,"CommandEmpty");function ft({className:e,...t}){return(0,f.jsx)(se.Group,{"data-slot":"command-group",className:k("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}a(ft,"CommandGroup");function Go({className:e,...t}){return(0,f.jsx)(se.Separator,{"data-slot":"command-separator",className:k("bg-border -mx-1 h-px",e),...t})}a(Go,"CommandSeparator");function pt({className:e,...t}){return(0,f.jsx)(se.Item,{"data-slot":"command-item",className:k("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}a(pt,"CommandItem");function Xo({className:e,...t}){return(0,f.jsx)("span",{"data-slot":"command-shortcut",className:k("text-muted-foreground ml-auto text-xs tracking-widest",e),...t})}a(Xo,"CommandShortcut");var go=i.forwardRef(({checked:e,onCheckedChange:t,size:n="default",className:r,disabled:o,onClick:s,...u},l)=>{const p=n==="lg";return(0,f.jsx)("button",{ref:l,type:"button",role:"switch","aria-checked":e,"data-slot":"toggle",disabled:o,className:k("relative inline-flex shrink-0 items-center rounded-full border-2 transition-all outline-none","focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30","disabled:cursor-not-allowed disabled:opacity-50",p?"h-6 w-12":"h-5 w-11",e?"border-(--status-task-done) bg-(--status-task-done)":"border-transparent bg-input/90",r),...u,onClick:a(c=>{s?.(c),t(!e)},"onClick"),children:(0,f.jsx)("span",{className:k("pointer-events-none inline-block rounded-full bg-background shadow-sm transition-transform not-dark:bg-clip-padding dark:bg-foreground",p?"h-5 w-7":"h-4 w-6",e?"translate-x-4":"translate-x-0")})})});go.displayName="ToggleSwitch";var Yt="--mobile-viewport-inset-bottom",$e="--mobile-viewport-height",Qe="keyboardOpen";var yo=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function bo(e){if(!e)return!1;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement)return!yo.has(e.type)&&!e.readOnly&&!e.disabled;const t=e.closest("[contenteditable]");return t!==null&&t.getAttribute("contenteditable")!=="false"}a(bo,"isEditableElement");function Eo(e){const t=Math.max(0,Math.round(e.innerHeight-e.visualHeight-e.offsetTop));return e.sheetOpen||e.editableFocused&&t>120?t:0}a(Eo,"resolveKeyboardInset");var Ee=0,ze=0,Me=null,ue=null;function xo(){const e=window.visualViewport;return{innerHeight:window.innerHeight,visualHeight:e?.height??window.innerHeight,offsetTop:e?.offsetTop??0,editableFocused:bo(document.activeElement),sheetOpen:ze>0}}a(xo,"readSample");function we(){const e=document.documentElement,t=xo(),n=Eo(t);e.style.setProperty(Yt,`${n}px`),n>0?e.style.setProperty($e,`${Math.round(t.visualHeight)}px`):e.style.removeProperty($e),n>120?e.dataset[Qe]="true":delete e.dataset[Qe]}a(we,"publish");function $(){ue===null&&(ue=window.requestAnimationFrame(()=>{ue=null,we()}))}a($,"schedule");function wo(){const e=window.visualViewport;return we(),e?.addEventListener("resize",$),e?.addEventListener("scroll",$),window.addEventListener("resize",$),window.addEventListener("orientationchange",$),document.addEventListener("focusin",$),document.addEventListener("focusout",$),()=>{e?.removeEventListener("resize",$),e?.removeEventListener("scroll",$),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),document.removeEventListener("focusin",$),document.removeEventListener("focusout",$),ue!==null&&window.cancelAnimationFrame(ue),ue=null;const t=document.documentElement;t.style.removeProperty(Yt),t.style.removeProperty($e),delete t.dataset[Qe]}}a(wo,"attach");function Co(e,t={}){const n=t.sheet??!1;(0,i.useEffect)(()=>{if(!(!e||typeof window>"u"))return Ee+=1,n&&(ze+=1),Ee===1?Me=wo():we(),()=>{if(Ee-=1,n&&(ze-=1),Ee>0){we();return}Me?.(),Me=null}},[e,n])}a(Co,"useMobileViewportInsets");function ke(){return(window.visualViewport?.height??window.innerHeight)<500}a(ke,"readShortViewport");function Yo(e){const[t,n]=(0,i.useState)(()=>e&&typeof window<"u"&&ke());return(0,i.useEffect)(()=>{if(!e||typeof window>"u"){n(!1);return}let r=null;const o=a(()=>{r===null&&(r=window.requestAnimationFrame(()=>{r=null,n(ke())}))},"update");n(ke());const s=window.visualViewport;return s?.addEventListener("resize",o),window.addEventListener("resize",o),()=>{s?.removeEventListener("resize",o),window.removeEventListener("resize",o),r!==null&&window.cancelAnimationFrame(r)}},[e]),t}a(Yo,"useShortVisibleViewport");function mt(){const e=window.visualViewport?.height;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}a(mt,"readVisualViewportHeight");function So(){const[e,t]=(0,i.useState)(()=>typeof window>"u"?null:mt());return(0,i.useEffect)(()=>{const n=window.visualViewport;if(!n)return;const r=a(()=>{const o=mt();o!==null&&t(o)},"update");return r(),n.addEventListener("resize",r),n.addEventListener("scroll",r),()=>{n.removeEventListener("resize",r),n.removeEventListener("scroll",r)}},[]),e===null?{}:{"--mobile-entity-picker-visual-viewport-height":`${e}px`}}a(So,"useMobileEntityPickerViewportStyle");function Jt(e){return e.trim().toLowerCase().replace(/\s+/g," ")}a(Jt,"normalizeSearchText");function Zt(e){return Jt(e).match(/[\p{L}\p{N}]+/gu)??[]}a(Zt,"searchWords");function Oo(e,t){if(t.length<3)return null;let n=0,r=-1,o=-1,s=0;for(let u=0;u<e.length&&n<t.length;u+=1)e[u]===t[n]&&(r===-1?r=u:s+=u-o-1,o=u,n+=1);return n!==t.length||o-r+1>t.length*2?null:32+s*2+r+Math.max(0,e.length-t.length)*.5}a(Oo,"fuzzyWordSubsequenceScore");function No(e,t){if(!t)return 0;const n=Zt(e);if(n.length===0)return null;let r=Number.POSITIVE_INFINITY;n.forEach((u,l)=>{let p=null;if(u===t)p=0;else if(u.startsWith(t))p=8+(u.length-t.length)*.25;else{const c=u.indexOf(t);c>=0?p=16+c+(u.length-t.length)*.1:p=Oo(u,t)}p!==null&&(r=Math.min(r,p+l*.05))});const o=n.join("").indexOf(t);o>=0&&(r=Math.min(r,24+o*.05));const s=n.map(u=>u[0]).join("");if(t.length<=4)if(s.startsWith(t))r=Math.min(r,28+(s.length-t.length)*.25);else{const u=s.indexOf(t);u>=0&&(r=Math.min(r,36+u))}return Number.isFinite(r)?r:null}a(No,"scoreTokenAgainstText");function en(e,t){const n=Zt(t);if(n.length===0)return 0;let r=0;for(const o of n){let s=Number.POSITIVE_INFINITY;if(e.forEach((u,l)=>{const p=No(u.text??"",o);p!==null&&(s=Math.min(s,p+(u.weight??l*20)))}),!Number.isFinite(s))return null;r+=s}return r}a(en,"scoreFuzzyTextFields");function Ro(e,t){return en([{text:e}],t)}a(Ro,"scoreFuzzyTextMatch");function Do(e,t){return Ro(e,t)!==null}a(Do,"fuzzyTextMatchesQuery");function Po(e,t){return Do(`${e.label} ${e.searchText??""}`,t)}a(Po,"defaultFilterOption");function _o(e,t){return en([{text:e.label,weight:0},{text:e.searchText,weight:20}],t)}a(_o,"defaultScoreOption");function Jo({value:e,groups:t,onValueChange:n,placeholder:r,searchPlaceholder:o="Search...",emptyMessage:s="No options found.",loadingMessage:u="Loading...",loading:l=!1,disabled:p=!1,className:c,triggerClassName:h,contentClassName:y,align:E="start",contentWidth:x="trigger",renderValue:R,renderOption:C,deriveGroups:S,filterOption:I=Po,scoreOption:_,disablePortal:N,mobileTitle:P,triggerAriaLabel:Q,modal:D,contentStyle:w,listFooter:U,createItem:L}){const[q,ee]=(0,i.useState)(!1),[M,ie]=(0,i.useState)("");Co(q,{sheet:!0});const B=So(),H=(0,i.useRef)(!1),z=(0,i.useRef)(!1),G=(0,i.useMemo)(()=>{for(const m of t){const g=m.options.find(v=>v.value===e);if(g)return g}return null},[t,e]),ce=(0,i.useMemo)(()=>S?S(M,t):t,[S,t,M]),de=(0,i.useMemo)(()=>{if(l)return[];const m=Jt(M);return ce.map(g=>{const v=g.options.map((b,O)=>{if(!m)return{option:b,index:O,score:0};if(!I(b,M))return null;if(_){const A=_(b,M);return A===null?null:{option:b,index:O,score:A}}return{option:b,index:O,score:_o(b,M)??Number.MAX_SAFE_INTEGER}}).filter(b=>b!==null);return m&&v.sort((b,O)=>b.score-O.score||b.index-O.index),{...g,options:v.map(b=>b.option)}}).filter(g=>g.options.length>0)},[I,l,M,_,ce]),fe=de.some(m=>m.options.length>0);function X({suppressTriggerFocus:m=!1}={}){m&&(z.current=!0),ee(!1),ie("")}a(X,"closePopover");function d(m){if(m.disabled)return;z.current=!0;const g=n(m.value,m);g===!1||typeof g=="object"&&g?.close===!1||X()}return a(d,"selectOption"),(0,f.jsxs)(On,{modal:D,open:q,onOpenChange:a(m=>{ee(m),m||ie("")},"onOpenChange"),children:[(0,f.jsx)(wn,{asChild:!0,children:(0,f.jsxs)(Cn,{type:"button",variant:"outline",disabled:p,onPointerDown:a(()=>{H.current=!0},"onPointerDown"),onFocus:a(()=>{const m=H.current||z.current;H.current=!1,z.current=!1,!m&&ee(!0)},"onFocus"),onKeyDown:a(m=>{m.key==="Escape"&&q&&(m.preventDefault(),X())},"onKeyDown"),"aria-expanded":q,"aria-label":Q,role:"combobox",className:k("w-full justify-between overflow-hidden",c,h),children:[(0,f.jsx)("span",{className:k("min-w-0 flex-1 truncate text-left",!G&&"text-muted-foreground"),children:R?R(G):G?.label??r}),(0,f.jsx)(Un,{className:"ml-2 size-4 opacity-50"})]})}),(0,f.jsxs)(xn,{"data-mobile-entity-picker":"","aria-label":P??r,style:{...B,...w},align:E,collisionPadding:16,disablePortal:N,className:k("p-0",x==="trigger"?"w-(--radix-popover-trigger-width) min-w-56 max-w-(--sz-calc-23)":"w-72 max-w-(--sz-calc-23)",y),onKeyDownCapture:a(m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),X({suppressTriggerFocus:!0}))},"onKeyDownCapture"),onCloseAutoFocus:a(()=>{z.current=!0,queueMicrotask(()=>{z.current=!1})},"onCloseAutoFocus"),children:[(0,f.jsxs)("div",{"data-mobile-entity-picker-header":"","data-mobile-sheet-header":"",className:"hidden items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,f.jsx)("span",{className:"shrink-0 text-base font-semibold text-foreground",children:P??r}),(0,f.jsx)("span",{"data-mobile-sheet-value":"",className:"min-w-0 flex-1 truncate text-right text-xs text-muted-foreground",children:G?.label??null}),(0,f.jsx)("button",{type:"button",className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Close selector","data-mobile-sheet-close":"",onClick:a(()=>X({suppressTriggerFocus:!0}),"onClick"),children:(0,f.jsx)(yt,{className:"size-5"})})]}),(0,f.jsxs)(Xt,{shouldFilter:!1,children:[(0,f.jsx)(mo,{value:M,onValueChange:ie,placeholder:o}),(0,f.jsx)(ho,{className:"overscroll-contain touch-pan-y",onWheelCapture:a(m=>{m.currentTarget.scrollHeight>m.currentTarget.clientHeight&&m.stopPropagation()},"onWheelCapture"),children:l?(0,f.jsx)("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:u}):(0,f.jsxs)(f.Fragment,{children:[!fe&&!L?(0,f.jsx)(vo,{children:s}):null,!fe&&L?(0,f.jsx)("div",{className:"px-3 py-3 text-center text-xs text-muted-foreground",children:s}):null,de.map(m=>(0,f.jsx)(ft,{heading:m.label,children:m.options.map(g=>{const v=g.value===e;return(0,f.jsxs)(pt,{value:g.key,disabled:g.disabled,onSelect:a(()=>d(g),"onSelect"),children:[C?C(g,{selected:v}):(0,f.jsx)("span",{className:"min-w-0 truncate",children:g.label}),(0,f.jsx)(An,{className:k("ml-auto size-4",v?"opacity-100":"opacity-0")})]},g.key)})},m.id)),L?(0,f.jsx)(ft,{className:"border-t border-border",children:(0,f.jsx)(pt,{value:"__searchable_select_create__",onSelect:a(()=>{const m=M;z.current=!0,X(),window.setTimeout(()=>L.onSelect(m),0)},"onSelect"),children:L.render(M)})}):null,U]})})]})]})]})}a(Jo,"SearchableSelect");export{$o as S,Wo as _,Co as a,zo as b,Xt as c,ft as d,mo as f,Xo as g,Go as h,So as i,Bo as l,ho as m,Jt as n,Yo as o,pt as p,en as r,go as s,Jo as t,vo as u,Uo as v,Un as x,qo as y};
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&document.getElementById(e)},[n,e]),null},"TitleWarning"),Vr="DialogDescriptionWarning",Kr=a(({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zt(Vr).contentName}}.`;return i.useEffect(()=>{const r=e.current?.getAttribute("aria-describedby");t&&r&&document.getElementById(t)},[n,e,t]),null},"DescriptionWarning"),Br=At,Gr=kt,Xr=jt,Yr=Ft,pe='[cmdk-group=""]',Te='[cmdk-group-items=""]',Zr='[cmdk-group-heading=""]',Ut='[cmdk-item=""]',dt=`${Ut}:not([aria-disabled="true"])`,Le="cmdk-item-select",ae="data-value",Jr=a((e,t,n)=>Jn(e,t,n),"Re"),Wt=i.createContext(void 0),ge=a(()=>i.useContext(Wt),"K"),Ht=i.createContext(void 0),Ge=a(()=>i.useContext(Ht),"ee"),Vt=i.createContext(void 0),Kt=i.forwardRef((e,t)=>{let n=le(()=>{var d,m;return{search:"",value:(m=(d=e.value)!=null?d:e.defaultValue)!=null?m:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=le(()=>new Set),o=le(()=>new Map),s=le(()=>new Map),u=le(()=>new Set),l=Bt(e),{label:p,children:c,value:h,onValueChange:y,filter:E,shouldFilter:x,loop:R,disablePointerSelection:C=!1,vimBindings:S=!0,...I}=e,_=K(),N=K(),P=K(),Q=i.useRef(null),D=co();re(()=>{if(h!==void 0){let d=h.trim();n.current.value=d,w.emit()}},[h]),re(()=>{D(6,ie)},[]);let w=i.useMemo(()=>({subscribe:a(d=>(u.current.add(d),()=>u.current.delete(d)),"subscribe"),snapshot:a(()=>n.current,"snapshot"),setState:a((d,m,g)=>{var v,b,O,A;if(!Object.is(n.current[d],m)){if(n.current[d]=m,d==="search")M(),U(),D(1,ee);else if(d==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let j=document.getElementById(P);j?j.focus():(v=document.getElementById(_))==null||v.focus()}if(D(7,()=>{var j;n.current.selectedItemId=(j=B())==null?void 0:j.id,w.emit()}),g||D(5,ie),((b=l.current)==null?void 0:b.value)!==void 0){let j=m??"";(A=(O=l.current).onValueChange)==null||A.call(O,j);return}}w.emit()}},"setState"),emit:a(()=>{u.current.forEach(d=>d())},"emit")}),[]),W=i.useMemo(()=>({value:a((d,m,g)=>{var v;m!==((v=s.current.get(d))==null?void 0:v.value)&&(s.current.set(d,{value:m,keywords:g}),n.current.filtered.items.set(d,L(m,g)),D(2,()=>{U(),w.emit()}))},"value"),item:a((d,m)=>(r.current.add(d),m&&(o.current.has(m)?o.current.get(m).add(d):o.current.set(m,new Set([d]))),D(3,()=>{M(),U(),n.current.value||ee(),w.emit()}),()=>{s.current.delete(d),r.current.delete(d),n.current.filtered.items.delete(d);let g=B();D(4,()=>{M(),g?.getAttribute("id")===d&&ee(),w.emit()})}),"item"),group:a(d=>(o.current.has(d)||o.current.set(d,new Set),()=>{s.current.delete(d),o.current.delete(d)}),"group"),filter:a(()=>l.current.shouldFilter,"filter"),label:p||e["aria-label"],getDisablePointerSelection:a(()=>l.current.disablePointerSelection,"getDisablePointerSelection"),listId:_,inputId:P,labelId:N,listInnerRef:Q}),[]);function L(d,m){var g,v;let b=(v=(g=l.current)==null?void 0:g.filter)!=null?v:Jr;return d?b(d,n.current.search,m):0}a(L,"te");function U(){if(!n.current.search||l.current.shouldFilter===!1)return;let d=n.current.filtered.items,m=[];n.current.filtered.groups.forEach(v=>{let b=o.current.get(v),O=0;b.forEach(A=>{let j=d.get(A);O=Math.max(j,O)}),m.push([v,O])});let g=Q.current;H().sort((v,b)=>{var O,A;let j=v.getAttribute("id"),tn=b.getAttribute("id");return((O=d.get(tn))!=null?O:0)-((A=d.get(j))!=null?A:0)}).forEach(v=>{let b=v.closest(Te);b?b.appendChild(v.parentElement===b?v:v.closest(`${Te} > *`)):g.appendChild(v.parentElement===g?v:v.closest(`${Te} > *`))}),m.sort((v,b)=>b[1]-v[1]).forEach(v=>{var b;let O=(b=Q.current)==null?void 0:b.querySelector(`${pe}[${ae}="${encodeURIComponent(v[0])}"]`);O?.parentElement.appendChild(O)})}a(U,"z");function ee(){let d=H().find(g=>g.getAttribute("aria-disabled")!=="true"),m=d?.getAttribute(ae);w.setState("value",m||void 0)}a(ee,"W");function M(){var d,m,g,v;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let b=0;for(let O of r.current){let A=L((m=(d=s.current.get(O))==null?void 0:d.value)!=null?m:"",(v=(g=s.current.get(O))==null?void 0:g.keywords)!=null?v:[]);n.current.filtered.items.set(O,A),A>0&&b++}for(let[O,A]of o.current)for(let j of A)if(n.current.filtered.items.get(j)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=b}a(M,"J");function ie(){var d,m,g;let v=B();v&&(((d=v.parentElement)==null?void 0:d.firstChild)===v&&((g=(m=v.closest(pe))==null?void 0:m.querySelector(Zr))==null||g.scrollIntoView({block:"nearest"})),v.scrollIntoView({block:"nearest"}))}a(ie,"ne");function B(){var d;return(d=Q.current)==null?void 0:d.querySelector(`${Ut}[aria-selected="true"]`)}a(B,"M");function H(){var d;return Array.from(((d=Q.current)==null?void 0:d.querySelectorAll(dt))||[])}a(H,"V");function q(d){let m=H()[d];m&&w.setState("value",m.getAttribute(ae))}a(q,"X");function G(d){var m;let g=B(),v=H(),b=v.findIndex(A=>A===g),O=v[b+d];(m=l.current)!=null&&m.loop&&(O=b+d<0?v[v.length-1]:b+d===v.length?v[0]:v[b+d]),O&&w.setState("value",O.getAttribute(ae))}a(G,"Q");function ce(d){let m=B(),g=m?.closest(pe),v;for(;g&&!v;)g=d>0?lo(g,pe):uo(g,pe),v=g?.querySelector(dt);v?w.setState("value",v.getAttribute(ae)):G(d)}a(ce,"re");let de=a(()=>q(H().length-1),"oe"),fe=a(d=>{d.preventDefault(),d.metaKey?de():d.altKey?ce(1):G(1)},"ie"),X=a(d=>{d.preventDefault(),d.metaKey?q(0):d.altKey?ce(-1):G(-1)},"se");return i.createElement(T.div,{ref:t,tabIndex:-1,...I,"cmdk-root":"",onKeyDown:a(d=>{var m;(m=I.onKeyDown)==null||m.call(I,d);let g=d.nativeEvent.isComposing||d.keyCode===229;if(!(d.defaultPrevented||g))switch(d.key){case"n":case"j":S&&d.ctrlKey&&fe(d);break;case"ArrowDown":fe(d);break;case"p":case"k":S&&d.ctrlKey&&X(d);break;case"ArrowUp":X(d);break;case"Home":d.preventDefault(),q(0);break;case"End":d.preventDefault(),de();break;case"Enter":{d.preventDefault();let v=B();if(v){let b=new Event(Le);v.dispatchEvent(b)}}}},"onKeyDown")},i.createElement("label",{"cmdk-label":"",htmlFor:W.inputId,id:W.labelId,style:po},p),Ne(e,d=>i.createElement(Ht.Provider,{value:w},i.createElement(Wt.Provider,{value:W},d))))}),eo=i.forwardRef((e,t)=>{var n,r;let o=K(),s=i.useRef(null),u=i.useContext(Vt),l=ge(),p=Bt(e),c=(r=(n=p.current)==null?void 0:n.forceMount)!=null?r:u?.forceMount;re(()=>{if(!c)return l.item(o,u?.id)},[c]);let h=Gt(o,s,[e.value,e.children,s],e.keywords),y=Ge(),E=J(D=>D.value&&D.value===h.current),x=J(D=>c||l.filter()===!1?!0:D.search?D.filtered.items.get(o)>0:!0);i.useEffect(()=>{let D=s.current;if(!(!D||e.disabled))return D.addEventListener(Le,R),()=>D.removeEventListener(Le,R)},[x,e.onSelect,e.disabled]);function R(){var D,w;C(),(w=(D=p.current).onSelect)==null||w.call(D,h.current)}a(R,"C");function C(){y.setState("value",h.current,!0)}if(a(C,"S"),!x)return null;let{disabled:S,value:I,onSelect:_,forceMount:N,keywords:P,...Q}=e;return i.createElement(T.div,{ref:te(s,t),...Q,id:o,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!E,"data-disabled":!!S,"data-selected":!!E,onPointerMove:S||l.getDisablePointerSelection()?void 0:C,onClick:S?void 0:R},e.children)}),to=i.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,u=K(),l=i.useRef(null),p=i.useRef(null),c=K(),h=ge(),y=J(x=>o||h.filter()===!1?!0:x.search?x.filtered.groups.has(u):!0);re(()=>h.group(u),[]),Gt(u,l,[e.value,e.heading,p]);let E=i.useMemo(()=>({id:u,forceMount:o}),[o]);return i.createElement(T.div,{ref:te(l,t),...s,"cmdk-group":"",role:"presentation",hidden:y?void 0:!0},n&&i.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ne(e,x=>i.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},i.createElement(Vt.Provider,{value:E},x))))}),no=i.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=i.useRef(null),s=J(u=>!u.search);return!n&&!s?null:i.createElement(T.div,{ref:te(o,t),...r,"cmdk-separator":"",role:"separator"})}),ro=i.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Ge(),u=J(c=>c.search),l=J(c=>c.selectedItemId),p=ge();return i.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),i.createElement(T.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":l,id:p.inputId,type:"text",value:o?e.value:u,onChange:a(c=>{o||s.setState("search",c.target.value),n?.(c.target.value)},"onChange")})}),oo=i.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=i.useRef(null),u=i.useRef(null),l=J(c=>c.selectedItemId),p=ge();return i.useEffect(()=>{if(u.current&&s.current){let c=u.current,h=s.current,y,E=new ResizeObserver(()=>{y=requestAnimationFrame(()=>{let x=c.offsetHeight;h.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return E.observe(c),()=>{cancelAnimationFrame(y),E.unobserve(c)}}},[]),i.createElement(T.div,{ref:te(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:p.listId},Ne(e,c=>i.createElement("div",{ref:te(u,p.listInnerRef),"cmdk-list-sizer":""},c)))}),so=i.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:u,...l}=e;return i.createElement(Br,{open:n,onOpenChange:r},i.createElement(Gr,{container:u},i.createElement(Xr,{"cmdk-overlay":"",className:o}),i.createElement(Yr,{"aria-label":e.label,"cmdk-dialog":"",className:s},i.createElement(Kt,{ref:t,...l}))))}),io=i.forwardRef((e,t)=>J(n=>n.filtered.count===0)?i.createElement(T.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ao=i.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return i.createElement(T.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ne(e,u=>i.createElement("div",{"aria-hidden":!0},u)))}),se=Object.assign(Kt,{List:oo,Item:eo,Input:ro,Group:to,Separator:no,Dialog:so,Empty:io,Loading:ao});function lo(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}a(lo,"we");function uo(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}a(uo,"De");function Bt(e){let t=i.useRef(e);return re(()=>{t.current=e}),t}a(Bt,"pe");var re=typeof window>"u"?i.useEffect:i.useLayoutEffect;function le(e){let t=i.useRef();return t.current===void 0&&(t.current=e()),t}a(le,"L");function J(e){let t=Ge(),n=a(()=>e(t.snapshot()),"n");return i.useSyncExternalStore(t.subscribe,n,n)}a(J,"P");function Gt(e,t,n,r=[]){let o=i.useRef(),s=ge();return re(()=>{var u;let l=(()=>{var c;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():o.current}})(),p=r.map(c=>c.trim());s.value(e,l,p),(u=t.current)==null||u.setAttribute(ae,l),o.current=l}),o}a(Gt,"ve");var co=a(()=>{let[e,t]=i.useState(),n=le(()=>new Map);return re(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}},"ke");function fo(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}a(fo,"Me");function Ne({asChild:e,children:t},n){return e&&i.isValidElement(t)?i.cloneElement(fo(t),{ref:t.ref},n(t.props.children)):n(t)}a(Ne,"B");var po={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Xt({className:e,...t}){return(0,f.jsx)(se,{"data-slot":"command",className:k("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}a(Xt,"Command");function Bo({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:o=!0,...s}){return(0,f.jsxs)(In,{...s,children:[(0,f.jsxs)(Pn,{className:"sr-only",children:[(0,f.jsx)(Rn,{children:e}),(0,f.jsx)(Dn,{children:t})]}),(0,f.jsxs)(_n,{className:k("overflow-hidden p-0",r),showCloseButton:!1,children:[(0,f.jsx)(Xt,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n}),o&&(0,f.jsxs)(Nn,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-0 right-2 flex h-12 items-center rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,f.jsx)(yt,{}),(0,f.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}a(Bo,"CommandDialog");function mo({className:e,...t}){return(0,f.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,f.jsx)(Sn,{className:"size-4 shrink-0 opacity-50"}),(0,f.jsx)(se.Input,{"data-slot":"command-input",className:k("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-base md:text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}a(mo,"CommandInput");function ho({className:e,...t}){return(0,f.jsx)(se.List,{"data-slot":"command-list",className:k("max-h-(--sz-300px) scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}a(ho,"CommandList");function vo({...e}){return(0,f.jsx)(se.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}a(vo,"CommandEmpty");function ft({className:e,...t}){return(0,f.jsx)(se.Group,{"data-slot":"command-group",className:k("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}a(ft,"CommandGroup");function Go({className:e,...t}){return(0,f.jsx)(se.Separator,{"data-slot":"command-separator",className:k("bg-border -mx-1 h-px",e),...t})}a(Go,"CommandSeparator");function pt({className:e,...t}){return(0,f.jsx)(se.Item,{"data-slot":"command-item",className:k("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}a(pt,"CommandItem");function Xo({className:e,...t}){return(0,f.jsx)("span",{"data-slot":"command-shortcut",className:k("text-muted-foreground ml-auto text-xs tracking-widest",e),...t})}a(Xo,"CommandShortcut");var go=i.forwardRef(({checked:e,onCheckedChange:t,size:n="default",className:r,disabled:o,onClick:s,...u},l)=>{const p=n==="lg";return(0,f.jsx)("button",{ref:l,type:"button",role:"switch","aria-checked":e,"data-slot":"toggle",disabled:o,className:k("relative inline-flex shrink-0 items-center rounded-full border-2 transition-all outline-none","focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30","disabled:cursor-not-allowed disabled:opacity-50",p?"h-6 w-12":"h-5 w-11",e?"border-(--status-task-done) bg-(--status-task-done)":"border-transparent bg-input/90",r),...u,onClick:a(c=>{s?.(c),t(!e)},"onClick"),children:(0,f.jsx)("span",{className:k("pointer-events-none inline-block rounded-full bg-background shadow-sm transition-transform not-dark:bg-clip-padding dark:bg-foreground",p?"h-5 w-7":"h-4 w-6",e?"translate-x-4":"translate-x-0")})})});go.displayName="ToggleSwitch";var Yt="--mobile-viewport-inset-bottom",$e="--mobile-viewport-height",Qe="keyboardOpen";var yo=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function bo(e){if(!e)return!1;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement)return!yo.has(e.type)&&!e.readOnly&&!e.disabled;const t=e.closest("[contenteditable]");return t!==null&&t.getAttribute("contenteditable")!=="false"}a(bo,"isEditableElement");function Eo(e){const t=Math.max(0,Math.round(e.innerHeight-e.visualHeight-e.offsetTop));return e.sheetOpen||e.editableFocused&&t>120?t:0}a(Eo,"resolveKeyboardInset");var Ee=0,qe=0,Me=null,ue=null;function xo(){const e=window.visualViewport;return{innerHeight:window.innerHeight,visualHeight:e?.height??window.innerHeight,offsetTop:e?.offsetTop??0,editableFocused:bo(document.activeElement),sheetOpen:qe>0}}a(xo,"readSample");function we(){const e=document.documentElement,t=xo(),n=Eo(t);e.style.setProperty(Yt,`${n}px`),n>0?e.style.setProperty($e,`${Math.round(t.visualHeight)}px`):e.style.removeProperty($e),n>120?e.dataset[Qe]="true":delete e.dataset[Qe]}a(we,"publish");function $(){ue===null&&(ue=window.requestAnimationFrame(()=>{ue=null,we()}))}a($,"schedule");function wo(){const e=window.visualViewport;return we(),e?.addEventListener("resize",$),e?.addEventListener("scroll",$),window.addEventListener("resize",$),window.addEventListener("orientationchange",$),document.addEventListener("focusin",$),document.addEventListener("focusout",$),()=>{e?.removeEventListener("resize",$),e?.removeEventListener("scroll",$),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),document.removeEventListener("focusin",$),document.removeEventListener("focusout",$),ue!==null&&window.cancelAnimationFrame(ue),ue=null;const t=document.documentElement;t.style.removeProperty(Yt),t.style.removeProperty($e),delete t.dataset[Qe]}}a(wo,"attach");function Co(e,t={}){const n=t.sheet??!1;(0,i.useEffect)(()=>{if(!(!e||typeof window>"u"))return Ee+=1,n&&(qe+=1),Ee===1?Me=wo():we(),()=>{if(Ee-=1,n&&(qe-=1),Ee>0){we();return}Me?.(),Me=null}},[e,n])}a(Co,"useMobileViewportInsets");function ke(){return(window.visualViewport?.height??window.innerHeight)<500}a(ke,"readShortViewport");function Yo(e){const[t,n]=(0,i.useState)(()=>e&&typeof window<"u"&&ke());return(0,i.useEffect)(()=>{if(!e||typeof window>"u"){n(!1);return}let r=null;const o=a(()=>{r===null&&(r=window.requestAnimationFrame(()=>{r=null,n(ke())}))},"update");n(ke());const s=window.visualViewport;return s?.addEventListener("resize",o),window.addEventListener("resize",o),()=>{s?.removeEventListener("resize",o),window.removeEventListener("resize",o),r!==null&&window.cancelAnimationFrame(r)}},[e]),t}a(Yo,"useShortVisibleViewport");function mt(){const e=window.visualViewport?.height;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}a(mt,"readVisualViewportHeight");function So(){const[e,t]=(0,i.useState)(()=>typeof window>"u"?null:mt());return(0,i.useEffect)(()=>{const n=window.visualViewport;if(!n)return;const r=a(()=>{const o=mt();o!==null&&t(o)},"update");return r(),n.addEventListener("resize",r),n.addEventListener("scroll",r),()=>{n.removeEventListener("resize",r),n.removeEventListener("scroll",r)}},[]),e===null?{}:{"--mobile-entity-picker-visual-viewport-height":`${e}px`}}a(So,"useMobileEntityPickerViewportStyle");function Zt(e){return e.trim().toLowerCase().replace(/\s+/g," ")}a(Zt,"normalizeSearchText");function Jt(e){return Zt(e).match(/[\p{L}\p{N}]+/gu)??[]}a(Jt,"searchWords");function Oo(e,t){if(t.length<3)return null;let n=0,r=-1,o=-1,s=0;for(let u=0;u<e.length&&n<t.length;u+=1)e[u]===t[n]&&(r===-1?r=u:s+=u-o-1,o=u,n+=1);return n!==t.length||o-r+1>t.length*2?null:32+s*2+r+Math.max(0,e.length-t.length)*.5}a(Oo,"fuzzyWordSubsequenceScore");function No(e,t){if(!t)return 0;const n=Jt(e);if(n.length===0)return null;let r=Number.POSITIVE_INFINITY;n.forEach((u,l)=>{let p=null;if(u===t)p=0;else if(u.startsWith(t))p=8+(u.length-t.length)*.25;else{const c=u.indexOf(t);c>=0?p=16+c+(u.length-t.length)*.1:p=Oo(u,t)}p!==null&&(r=Math.min(r,p+l*.05))});const o=n.join("").indexOf(t);o>=0&&(r=Math.min(r,24+o*.05));const s=n.map(u=>u[0]).join("");if(t.length<=4)if(s.startsWith(t))r=Math.min(r,28+(s.length-t.length)*.25);else{const u=s.indexOf(t);u>=0&&(r=Math.min(r,36+u))}return Number.isFinite(r)?r:null}a(No,"scoreTokenAgainstText");function en(e,t){const n=Jt(t);if(n.length===0)return 0;let r=0;for(const o of n){let s=Number.POSITIVE_INFINITY;if(e.forEach((u,l)=>{const p=No(u.text??"",o);p!==null&&(s=Math.min(s,p+(u.weight??l*20)))}),!Number.isFinite(s))return null;r+=s}return r}a(en,"scoreFuzzyTextFields");function Ro(e,t){return en([{text:e}],t)}a(Ro,"scoreFuzzyTextMatch");function Do(e,t){return Ro(e,t)!==null}a(Do,"fuzzyTextMatchesQuery");function Po(e,t){return Do(`${e.label} ${e.searchText??""}`,t)}a(Po,"defaultFilterOption");function _o(e,t){return en([{text:e.label,weight:0},{text:e.searchText,weight:20}],t)}a(_o,"defaultScoreOption");function Zo({value:e,groups:t,onValueChange:n,placeholder:r,searchPlaceholder:o="Search...",emptyMessage:s="No options found.",loadingMessage:u="Loading...",loading:l=!1,disabled:p=!1,className:c,triggerClassName:h,contentClassName:y,align:E="start",contentWidth:x="trigger",renderValue:R,renderOption:C,deriveGroups:S,filterOption:I=Po,scoreOption:_,disablePortal:N,mobileTitle:P,triggerAriaLabel:Q,modal:D,contentStyle:w,listFooter:W,createItem:L}){const[U,ee]=(0,i.useState)(!1),[M,ie]=(0,i.useState)("");Co(U,{sheet:!0});const B=So(),H=(0,i.useRef)(!1),q=(0,i.useRef)(!1),G=(0,i.useMemo)(()=>{for(const m of t){const g=m.options.find(v=>v.value===e);if(g)return g}return null},[t,e]),ce=(0,i.useMemo)(()=>S?S(M,t):t,[S,t,M]),de=(0,i.useMemo)(()=>{if(l)return[];const m=Zt(M);return ce.map(g=>{const v=g.options.map((b,O)=>{if(!m)return{option:b,index:O,score:0};if(!I(b,M))return null;if(_){const A=_(b,M);return A===null?null:{option:b,index:O,score:A}}return{option:b,index:O,score:_o(b,M)??Number.MAX_SAFE_INTEGER}}).filter(b=>b!==null);return m&&v.sort((b,O)=>b.score-O.score||b.index-O.index),{...g,options:v.map(b=>b.option)}}).filter(g=>g.options.length>0)},[I,l,M,_,ce]),fe=de.some(m=>m.options.length>0);function X({suppressTriggerFocus:m=!1}={}){m&&(q.current=!0),ee(!1),ie("")}a(X,"closePopover");function d(m){if(m.disabled)return;q.current=!0;const g=n(m.value,m);g===!1||typeof g=="object"&&g?.close===!1||X()}return a(d,"selectOption"),(0,f.jsxs)(On,{modal:D,open:U,onOpenChange:a(m=>{ee(m),m||ie("")},"onOpenChange"),children:[(0,f.jsx)(wn,{asChild:!0,children:(0,f.jsxs)(Cn,{type:"button",variant:"outline",disabled:p,onPointerDown:a(()=>{H.current=!0},"onPointerDown"),onFocus:a(()=>{const m=H.current||q.current;H.current=!1,q.current=!1,!m&&ee(!0)},"onFocus"),onKeyDown:a(m=>{m.key==="Escape"&&U&&(m.preventDefault(),X())},"onKeyDown"),"aria-expanded":U,"aria-label":Q,role:"combobox",className:k("w-full justify-between overflow-hidden",c,h),children:[(0,f.jsx)("span",{className:k("min-w-0 flex-1 truncate text-left",!G&&"text-muted-foreground"),children:R?R(G):G?.label??r}),(0,f.jsx)(Wn,{className:"ml-2 size-4 opacity-50"})]})}),(0,f.jsxs)(xn,{"data-mobile-entity-picker":"","aria-label":P??r,style:{...B,...w},align:E,collisionPadding:16,disablePortal:N,className:k("p-0",x==="trigger"?"w-(--radix-popover-trigger-width) min-w-56 max-w-(--sz-calc-23)":"w-72 max-w-(--sz-calc-23)",y),onKeyDownCapture:a(m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),X({suppressTriggerFocus:!0}))},"onKeyDownCapture"),onCloseAutoFocus:a(()=>{q.current=!0,queueMicrotask(()=>{q.current=!1})},"onCloseAutoFocus"),children:[(0,f.jsxs)("div",{"data-mobile-entity-picker-header":"","data-mobile-sheet-header":"",className:"hidden items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,f.jsx)("span",{className:"shrink-0 text-base font-semibold text-foreground",children:P??r}),(0,f.jsx)("span",{"data-mobile-sheet-value":"",className:"min-w-0 flex-1 truncate text-right text-xs text-muted-foreground",children:G?.label??null}),(0,f.jsx)("button",{type:"button",className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Close selector","data-mobile-sheet-close":"",onClick:a(()=>X({suppressTriggerFocus:!0}),"onClick"),children:(0,f.jsx)(yt,{className:"size-5"})})]}),(0,f.jsxs)(Xt,{shouldFilter:!1,children:[(0,f.jsx)(mo,{value:M,onValueChange:ie,placeholder:o}),(0,f.jsx)(ho,{className:"overscroll-contain touch-pan-y",onWheelCapture:a(m=>{m.currentTarget.scrollHeight>m.currentTarget.clientHeight&&m.stopPropagation()},"onWheelCapture"),children:l?(0,f.jsx)("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:u}):(0,f.jsxs)(f.Fragment,{children:[!fe&&!L?(0,f.jsx)(vo,{children:s}):null,!fe&&L?(0,f.jsx)("div",{className:"px-3 py-3 text-center text-xs text-muted-foreground",children:s}):null,de.map(m=>(0,f.jsx)(ft,{heading:m.label,children:m.options.map(g=>{const v=g.value===e;return(0,f.jsxs)(pt,{value:g.key,disabled:g.disabled,onSelect:a(()=>d(g),"onSelect"),children:[C?C(g,{selected:v}):(0,f.jsx)("span",{className:"min-w-0 truncate",children:g.label}),(0,f.jsx)(An,{className:k("ml-auto size-4",v?"opacity-100":"opacity-0")})]},g.key)})},m.id)),L?(0,f.jsx)(ft,{className:"border-t border-border",children:(0,f.jsx)(pt,{value:"__searchable_select_create__",onSelect:a(()=>{const m=M;q.current=!0,X(),window.setTimeout(()=>L.onSelect(m),0)},"onSelect"),children:L.render(M)})}):null,W]})})]})]})]})}a(Zo,"SearchableSelect");export{$o as S,zo as _,Co as a,qo as b,Xt as c,ft as d,mo as f,Xo as g,Go as h,So as i,Bo as l,ho as m,Zt as n,Yo as o,pt as p,en as r,go as s,Zo as t,vo as u,Wo as v,Wn as x,Uo as y};
@@ -1 +1 @@
1
- var P=Object.defineProperty;var n=(e,r)=>P(e,"name",{value:r,configurable:!0});import{i as _}from"./rolldown-runtime-ZpX3ckPj.js";import{G as b,Qa as W,eo as A,ia as c,n as i}from"./boxes-DcYq-jCc.js";import{Mt as C,Nt as v,T as H,Vt as V,Wt as F,jt as w,kt as j,r as Y,zt as J}from"./BreadcrumbContext-BdR2QZTG.js";import{i as $,n as B}from"./usePrefersReducedMotion-DxMMBfvJ.js";import{r as I}from"./badge-BKd5IdYw.js";var S={name:"archive",size:24,node:[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]};S.node;var L=i(S),O={name:"circle-x",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],aliases:["x-circle"]};O.node;var R=i(O),E={name:"cloud-off",size:24,node:[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]};E.node;var K=i(E),q={name:"git-merge",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]};q.node;var X=i(q),M={name:"git-pull-request",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]};M.node;var Q=i(M),U={name:"octagon-alert",size:24,node:[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],aliases:["alert-octagon"]};U.node;var Z=i(U);function x(e={}){return{workspaceCommandId:e.workspaceCommandId??null,runtimeServiceId:e.runtimeServiceId??null,serviceIndex:e.serviceIndex??null}}n(x,"sanitizeWorkspaceRuntimeControlTarget");function ee(e,r){return r?`${e}${e.includes("?")?"&":"?"}companyId=${encodeURIComponent(r)}`:e}n(ee,"withCompanyScope");function o(e,r,t=""){return ee(`/projects/${encodeURIComponent(e)}${t}`,r)}n(o,"projectPath");var je={repositoryOptions:n(e=>c.get(`/companies/${e}/project-repositories`),"repositoryOptions"),setRepositories:n((e,r)=>c.put(o(e,void 0,"/repositories"),{repositoryIds:r}),"setRepositories"),list:n((e,r={})=>{const t=new URLSearchParams;r.includeArchived&&t.set("includeArchived","true");const a=t.toString();return c.get("/companies/"+encodeURIComponent(e)+"/projects"+(a?"?"+a:""))},"list"),get:n((e,r)=>c.get(o(e,r)),"get"),create:n((e,r)=>c.post(`/companies/${e}/projects`,r),"create"),update:n((e,r,t)=>c.patch(o(e,t),r),"update"),listAccessMembers:n((e,r)=>c.get(o(e,r,"/access-members")),"listAccessMembers"),addAccessMember:n((e,r,t)=>c.post(o(e,t,"/access-members"),r),"addAccessMember"),removeAccessMember:n((e,r,t)=>c.delete(o(e,t,`/access-members/${encodeURIComponent(r)}`)),"removeAccessMember"),listWorkspaces:n((e,r)=>c.get(o(e,r,"/workspaces")),"listWorkspaces"),createWorkspace:n((e,r,t)=>c.post(o(e,t,"/workspaces"),r),"createWorkspace"),updateWorkspace:n((e,r,t,a)=>c.patch(o(e,a,`/workspaces/${encodeURIComponent(r)}`),t),"updateWorkspace"),controlWorkspaceRuntimeServices:n((e,r,t,a,l={})=>c.post(o(e,a,`/workspaces/${encodeURIComponent(r)}/runtime-services/${t}`),x(l)),"controlWorkspaceRuntimeServices"),controlWorkspaceCommands:n((e,r,t,a,l={})=>c.post(o(e,a,`/workspaces/${encodeURIComponent(r)}/runtime-commands/${t}`),x(l)),"controlWorkspaceCommands"),removeWorkspace:n((e,r,t)=>c.delete(o(e,t,`/workspaces/${encodeURIComponent(r)}`)),"removeWorkspace"),remove:n((e,r)=>c.delete(o(e,r)),"remove")};function $e(e){if(!e)return null;let r;try{r=new URL(e.trim())}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password)return null;const t=r.protocol==="https:"?"https":"http",a=r.pathname||"/";return`${t}://${r.host.toLowerCase()}${a}`}n($e,"normalizeExternalObjectHref");var re=i("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),te={unknown:C,open:w,waiting:$,running:I,succeeded:v,failed:R,blocked:Z,closed:j,archived:L,auth_required:B,unreachable:K},ne=C;function Be(e){return te[e]??ne}n(Be,"externalObjectIconForCategory");var ae={archive:L,check:v,"check-circle":v,circle:j,"circle-dot":w,clock:$,github:re,"git-merge":X,"git-pull-request":Q,key:B,loader:I,"x-circle":R};function Ie(e){return e?ae[e]??null:null}n(Ie,"externalObjectIconForKey");var ce={unknown:"Not yet resolved",open:"Open",waiting:"Waiting",running:"Running",succeeded:"Succeeded",failed:"Failed",blocked:"Blocked",closed:"Closed",archived:"Archived",auth_required:"Authorization required",unreachable:"Unreachable"};function oe(e){return ce[e]??e.replace(/_/g," ")}n(oe,"externalObjectCategoryLabel");var se={unknown:"Not yet refreshed",fresh:"Fresh",stale:"Stale",auth_required:"Requires auth",unreachable:"Unreachable"};function ie(e){return se[e]??e.replace(/_/g," ")}n(ie,"externalObjectLivenessLabel");function Se(e){const r=e.statusLabel?.trim();if(r)return r;const t=e.providerKey==="url"&&e.objectType==="link",a=!!(e.providerKey&&e.objectType);return e.statusCategory==="unknown"&&a&&!t?e.liveness==="fresh"?"Status unavailable":ie(e.liveness):oe(e.statusCategory)}n(Se,"externalObjectDisplayStatusLabel");var N={muted:0,neutral:1,success:2,info:3,warning:4,danger:5};function le(e){return e?N[e]??0:0}n(le,"externalObjectToneSeverity");var ue={github:"GitHub",github_pull_request:"GitHub",github_issue:"GitHub",hubspot:"HubSpot",linear:"Linear",jira:"Jira",notion:"Notion",asana:"Asana"};function de(e){if(!e)return"External";const r=ue[e];return r||e.split(/[._-]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}n(de,"externalObjectProviderLabel");var pe={pull_request:"pull request",issue:"issue",deployment:"deployment",workflow_run:"workflow run",ticket:"ticket",lead:"lead",url_link:"URL"};function me(e){return e?pe[e]??e.replace(/_/g," "):"object"}n(me,"externalObjectTypeLabel");function Le(e,r,t){const a=t?.trim();return a||(e==="url"&&r==="link"?"URL":`${de(e)} ${me(r)}`)}n(Le,"externalObjectDisplayLabel");function he(e){if(!e)return null;const r=e.highestSeverity;return!r||le(r)<=N.muted?null:r}n(he,"dominantExternalObjectTone");function Oe(e){if(!e)return 0;const r=he(e);return r?e.objects.filter(t=>t.statusTone===r).length:0}n(Oe,"externalObjectDominantCount");var fe=_(A(),1),s=_(W(),1),ve=["backlog","todo","in_progress","in_review","done","cancelled","blocked"];function m(e){return e.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}n(m,"statusLabel");function ke(e){if(!e||e.state==="none")return"Blocked";if(e.reason==="active_child"){const r=e.coveredBlockerCount;return r===1&&e.sampleBlockerIdentifier?`Blocked · waiting on active sub-task ${e.sampleBlockerIdentifier}`:r===1?"Blocked · waiting on 1 active sub-task":`Blocked · waiting on ${r} active sub-tasks`}if(e.reason==="active_dependency"){const r=e.coveredBlockerCount;return r===1&&e.sampleBlockerIdentifier?`Blocked · covered by active dependency ${e.sampleBlockerIdentifier}`:r===1?"Blocked · covered by 1 active dependency":`Blocked · covered by ${r} active dependencies`}if(e.reason==="stalled_review"){const r=e.stalledBlockerCount,t=e.sampleStalledBlockerIdentifier??e.sampleBlockerIdentifier;return r===1&&t?`Blocked · review stalled on ${t}`:r===1?"Blocked · review stalled with no clear next step":`Blocked · ${r} reviews stalled with no clear next step`}if(e.reason==="attention_required"){const r=e.attentionBlockerCount||e.unresolvedBlockerCount,t=`${r} ${r===1?"blocker needs":"blockers need"} attention`,a=e.coveredBlockerCount;return a>0?`Blocked · ${t}; ${a} covered by active work`:`Blocked · ${t}`}return"Blocked"}n(ke,"blockedAttentionLabel");function ge({status:e,externalConversationState:r,blockerAttention:t,onChange:a,className:l,glyphContainerClassName:k,showLabel:h,size:z="md"}){const[D,g]=(0,fe.useState)(!1),d=e==="in_review"&&r==="waiting"?"idle":e,T=e==="blocked"&&t?.state==="covered",f=e==="blocked"?ke(t):m(d),y=(0,s.jsx)(H,{status:T?"in_queue":d,size:z,className:b(a&&!h&&"cursor-pointer",l),title:f}),p=k?(0,s.jsx)("span",{className:k,"data-status-glyph-container":"true",children:y}):y;if(!a)return h?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[p,(0,s.jsx)("span",{className:"text-sm",children:m(d)})]}):p;const G=h?(0,s.jsxs)("button",{type:"button","aria-label":`Change status (current: ${f})`,className:"inline-flex min-h-5 items-center gap-1.5 cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1 py-0.5 transition-colors",children:[p,(0,s.jsx)("span",{className:"text-sm",children:m(d)})]}):(0,s.jsx)("button",{type:"button","data-slot":"icon-button","aria-label":`Change status (current: ${f})`,className:"inline-flex cursor-pointer items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-(length:--rad-3) focus-visible:ring-ring",children:p});return(0,s.jsxs)(J,{open:D,onOpenChange:g,children:[(0,s.jsx)(F,{asChild:!0,children:G}),(0,s.jsx)(V,{className:"w-40 p-1",align:"start",children:ve.map(u=>(0,s.jsxs)(Y,{variant:"ghost",size:"sm",className:b("w-full justify-start gap-2 text-xs",u===e&&"bg-accent"),onClick:n(()=>{a(u),g(!1)},"onClick"),children:[(0,s.jsx)(ge,{status:u,size:"lg"}),m(u)]},u))})]})}n(ge,"StatusIcon");export{Z as _,Se as a,R as b,Ie as c,le as d,me as f,x as g,je as h,Le as i,ie as l,$e as m,he as n,Oe as o,re as p,oe as r,Be as s,ge as t,de as u,Q as v,L as x,X as y};
1
+ var P=Object.defineProperty;var n=(e,r)=>P(e,"name",{value:r,configurable:!0});import{i as _}from"./rolldown-runtime-ZpX3ckPj.js";import{$a as W,G as b,Za as A,n as i,ra as c}from"./boxes-ULGOWIM3.js";import{Mt as C,Nt as v,T as H,Vt as V,Wt as F,jt as w,kt as j,r as Y,zt as J}from"./BreadcrumbContext-Cl4wMUsK.js";import{i as $,n as B}from"./usePrefersReducedMotion-C6h9ns9_.js";import{r as I}from"./badge-DxM54O3R.js";var S={name:"archive",size:24,node:[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]};S.node;var L=i(S),O={name:"circle-x",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],aliases:["x-circle"]};O.node;var R=i(O),E={name:"cloud-off",size:24,node:[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]};E.node;var K=i(E),q={name:"git-merge",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]};q.node;var X=i(q),M={name:"git-pull-request",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]};M.node;var Z=i(M),U={name:"octagon-alert",size:24,node:[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],aliases:["alert-octagon"]};U.node;var Q=i(U);function x(e={}){return{workspaceCommandId:e.workspaceCommandId??null,runtimeServiceId:e.runtimeServiceId??null,serviceIndex:e.serviceIndex??null}}n(x,"sanitizeWorkspaceRuntimeControlTarget");function ee(e,r){return r?`${e}${e.includes("?")?"&":"?"}companyId=${encodeURIComponent(r)}`:e}n(ee,"withCompanyScope");function o(e,r,t=""){return ee(`/projects/${encodeURIComponent(e)}${t}`,r)}n(o,"projectPath");var je={repositoryOptions:n(e=>c.get(`/companies/${e}/project-repositories`),"repositoryOptions"),setRepositories:n((e,r)=>c.put(o(e,void 0,"/repositories"),{repositoryIds:r}),"setRepositories"),list:n((e,r={})=>{const t=new URLSearchParams;r.includeArchived&&t.set("includeArchived","true");const a=t.toString();return c.get("/companies/"+encodeURIComponent(e)+"/projects"+(a?"?"+a:""))},"list"),get:n((e,r)=>c.get(o(e,r)),"get"),create:n((e,r)=>c.post(`/companies/${e}/projects`,r),"create"),update:n((e,r,t)=>c.patch(o(e,t),r),"update"),listAccessMembers:n((e,r)=>c.get(o(e,r,"/access-members")),"listAccessMembers"),addAccessMember:n((e,r,t)=>c.post(o(e,t,"/access-members"),r),"addAccessMember"),removeAccessMember:n((e,r,t)=>c.delete(o(e,t,`/access-members/${encodeURIComponent(r)}`)),"removeAccessMember"),listWorkspaces:n((e,r)=>c.get(o(e,r,"/workspaces")),"listWorkspaces"),createWorkspace:n((e,r,t)=>c.post(o(e,t,"/workspaces"),r),"createWorkspace"),updateWorkspace:n((e,r,t,a)=>c.patch(o(e,a,`/workspaces/${encodeURIComponent(r)}`),t),"updateWorkspace"),controlWorkspaceRuntimeServices:n((e,r,t,a,l={})=>c.post(o(e,a,`/workspaces/${encodeURIComponent(r)}/runtime-services/${t}`),x(l)),"controlWorkspaceRuntimeServices"),controlWorkspaceCommands:n((e,r,t,a,l={})=>c.post(o(e,a,`/workspaces/${encodeURIComponent(r)}/runtime-commands/${t}`),x(l)),"controlWorkspaceCommands"),removeWorkspace:n((e,r,t)=>c.delete(o(e,t,`/workspaces/${encodeURIComponent(r)}`)),"removeWorkspace"),remove:n((e,r)=>c.delete(o(e,r)),"remove")};function $e(e){if(!e)return null;let r;try{r=new URL(e.trim())}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password)return null;const t=r.protocol==="https:"?"https":"http",a=r.pathname||"/";return`${t}://${r.host.toLowerCase()}${a}`}n($e,"normalizeExternalObjectHref");var re=i("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),te={unknown:C,open:w,waiting:$,running:I,succeeded:v,failed:R,blocked:Q,closed:j,archived:L,auth_required:B,unreachable:K},ne=C;function Be(e){return te[e]??ne}n(Be,"externalObjectIconForCategory");var ae={archive:L,check:v,"check-circle":v,circle:j,"circle-dot":w,clock:$,github:re,"git-merge":X,"git-pull-request":Z,key:B,loader:I,"x-circle":R};function Ie(e){return e?ae[e]??null:null}n(Ie,"externalObjectIconForKey");var ce={unknown:"Not yet resolved",open:"Open",waiting:"Waiting",running:"Running",succeeded:"Succeeded",failed:"Failed",blocked:"Blocked",closed:"Closed",archived:"Archived",auth_required:"Authorization required",unreachable:"Unreachable"};function oe(e){return ce[e]??e.replace(/_/g," ")}n(oe,"externalObjectCategoryLabel");var se={unknown:"Not yet refreshed",fresh:"Fresh",stale:"Stale",auth_required:"Requires auth",unreachable:"Unreachable"};function ie(e){return se[e]??e.replace(/_/g," ")}n(ie,"externalObjectLivenessLabel");function Se(e){const r=e.statusLabel?.trim();if(r)return r;const t=e.providerKey==="url"&&e.objectType==="link",a=!!(e.providerKey&&e.objectType);return e.statusCategory==="unknown"&&a&&!t?e.liveness==="fresh"?"Status unavailable":ie(e.liveness):oe(e.statusCategory)}n(Se,"externalObjectDisplayStatusLabel");var N={muted:0,neutral:1,success:2,info:3,warning:4,danger:5};function le(e){return e?N[e]??0:0}n(le,"externalObjectToneSeverity");var ue={github:"GitHub",github_pull_request:"GitHub",github_issue:"GitHub",hubspot:"HubSpot",linear:"Linear",jira:"Jira",notion:"Notion",asana:"Asana"};function de(e){if(!e)return"External";const r=ue[e];return r||e.split(/[._-]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}n(de,"externalObjectProviderLabel");var pe={pull_request:"pull request",issue:"issue",deployment:"deployment",workflow_run:"workflow run",ticket:"ticket",lead:"lead",url_link:"URL"};function me(e){return e?pe[e]??e.replace(/_/g," "):"object"}n(me,"externalObjectTypeLabel");function Le(e,r,t){const a=t?.trim();return a||(e==="url"&&r==="link"?"URL":`${de(e)} ${me(r)}`)}n(Le,"externalObjectDisplayLabel");function he(e){if(!e)return null;const r=e.highestSeverity;return!r||le(r)<=N.muted?null:r}n(he,"dominantExternalObjectTone");function Oe(e){if(!e)return 0;const r=he(e);return r?e.objects.filter(t=>t.statusTone===r).length:0}n(Oe,"externalObjectDominantCount");var fe=_(W(),1),s=_(A(),1),ve=["backlog","todo","in_progress","in_review","done","cancelled","blocked"];function m(e){return e.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}n(m,"statusLabel");function ke(e){if(!e||e.state==="none")return"Blocked";if(e.reason==="active_child"){const r=e.coveredBlockerCount;return r===1&&e.sampleBlockerIdentifier?`Blocked · waiting on active sub-task ${e.sampleBlockerIdentifier}`:r===1?"Blocked · waiting on 1 active sub-task":`Blocked · waiting on ${r} active sub-tasks`}if(e.reason==="active_dependency"){const r=e.coveredBlockerCount;return r===1&&e.sampleBlockerIdentifier?`Blocked · covered by active dependency ${e.sampleBlockerIdentifier}`:r===1?"Blocked · covered by 1 active dependency":`Blocked · covered by ${r} active dependencies`}if(e.reason==="stalled_review"){const r=e.stalledBlockerCount,t=e.sampleStalledBlockerIdentifier??e.sampleBlockerIdentifier;return r===1&&t?`Blocked · review stalled on ${t}`:r===1?"Blocked · review stalled with no clear next step":`Blocked · ${r} reviews stalled with no clear next step`}if(e.reason==="attention_required"){const r=e.attentionBlockerCount||e.unresolvedBlockerCount,t=`${r} ${r===1?"blocker needs":"blockers need"} attention`,a=e.coveredBlockerCount;return a>0?`Blocked · ${t}; ${a} covered by active work`:`Blocked · ${t}`}return"Blocked"}n(ke,"blockedAttentionLabel");function ge({status:e,externalConversationState:r,blockerAttention:t,onChange:a,className:l,glyphContainerClassName:k,showLabel:h,size:z="md"}){const[D,g]=(0,fe.useState)(!1),d=e==="in_review"&&r==="waiting"?"idle":e,T=e==="blocked"&&t?.state==="covered",f=e==="blocked"?ke(t):m(d),y=(0,s.jsx)(H,{status:T?"in_queue":d,size:z,className:b(a&&!h&&"cursor-pointer",l),title:f}),p=k?(0,s.jsx)("span",{className:k,"data-status-glyph-container":"true",children:y}):y;if(!a)return h?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[p,(0,s.jsx)("span",{className:"text-sm",children:m(d)})]}):p;const G=h?(0,s.jsxs)("button",{type:"button","aria-label":`Change status (current: ${f})`,className:"inline-flex min-h-5 items-center gap-1.5 cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1 py-0.5 transition-colors",children:[p,(0,s.jsx)("span",{className:"text-sm",children:m(d)})]}):(0,s.jsx)("button",{type:"button","data-slot":"icon-button","aria-label":`Change status (current: ${f})`,className:"inline-flex cursor-pointer items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-(length:--rad-3) focus-visible:ring-ring",children:p});return(0,s.jsxs)(J,{open:D,onOpenChange:g,children:[(0,s.jsx)(F,{asChild:!0,children:G}),(0,s.jsx)(V,{className:"w-40 p-1",align:"start",children:ve.map(u=>(0,s.jsxs)(Y,{variant:"ghost",size:"sm",className:b("w-full justify-start gap-2 text-xs",u===e&&"bg-accent"),onClick:n(()=>{a(u),g(!1)},"onClick"),children:[(0,s.jsx)(ge,{status:u,size:"lg"}),m(u)]},u))})]})}n(ge,"StatusIcon");export{Q as _,Se as a,R as b,Ie as c,le as d,me as f,x as g,je as h,Le as i,ie as l,$e as m,he as n,Oe as o,re as p,oe as r,Be as s,ge as t,de as u,Z as v,L as x,X as y};