@shumai-one/shumai 0.3.7 → 0.3.9

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 (160) hide show
  1. package/bin/{chunk-2xmsrq7f.js → chunk-03ec6p4p.js} +2 -2
  2. package/bin/chunk-0h1yw3eq.js +1 -0
  3. package/bin/chunk-0kfcfd0x.js +2 -0
  4. package/bin/chunk-0rydta2q.js +2 -0
  5. package/bin/{chunk-zg60j9x2.js → chunk-0x6zt5yg.js} +1 -1
  6. package/bin/{chunk-ftc48rbb.js → chunk-11j7ejan.js} +3 -3
  7. package/bin/chunk-1eqdvehm.js +2 -0
  8. package/bin/chunk-24ke0th1.css +1 -0
  9. package/bin/{chunk-t3tp9trj.js → chunk-2ckj039r.js} +2 -2
  10. package/bin/chunk-2wcfw38x.js +1 -0
  11. package/bin/{chunk-af6wbhkv.js → chunk-331s5eb9.js} +2 -2
  12. package/bin/{chunk-7hnw6y6d.js → chunk-39j992fb.js} +2 -2
  13. package/bin/{chunk-9s02m95j.js → chunk-3h4t28zz.js} +2 -2
  14. package/bin/{chunk-qmpph1gt.js → chunk-4st1t79p.js} +2 -2
  15. package/bin/{chunk-zjj9qj6y.js → chunk-4yp5add5.js} +2 -2
  16. package/bin/chunk-5657zj59.js +2 -0
  17. package/bin/chunk-5ctpz542.js +78 -0
  18. package/bin/{chunk-p4c4z0f2.js → chunk-5efr8prc.js} +1 -1
  19. package/bin/chunk-5ex69zt3.js +2 -0
  20. package/bin/{chunk-0t8q76ac.js → chunk-6ja68bbj.js} +1 -1
  21. package/bin/{chunk-1khzycf9.js → chunk-6ts9djn2.js} +1 -1
  22. package/bin/{chunk-260wywfb.js → chunk-79wjyt2p.js} +1 -1
  23. package/bin/{chunk-9xhnmnnb.js → chunk-7a4347xe.js} +2 -2
  24. package/bin/chunk-7t9c532y.js +1 -0
  25. package/bin/{chunk-x3ynjbt5.js → chunk-7w01v7bw.js} +47 -47
  26. package/bin/{chunk-v98e3gex.js → chunk-7wh2mr72.js} +1 -1
  27. package/bin/chunk-7zvv37z0.js +7 -0
  28. package/bin/{chunk-t9t9evan.js → chunk-8hex1hjk.js} +2 -2
  29. package/bin/{chunk-n4gghgrj.js → chunk-8qryr65z.js} +2 -2
  30. package/bin/{chunk-81tb4v5v.js → chunk-9fc118ea.js} +2 -2
  31. package/bin/{chunk-esrtafz0.js → chunk-9s1fdecm.js} +1 -1
  32. package/bin/chunk-9vjkb4vh.js +1 -0
  33. package/bin/{chunk-k48y9e5s.js → chunk-a2m63585.js} +1 -1
  34. package/bin/{chunk-5gtew41y.js → chunk-a6s80m0k.js} +1 -1
  35. package/bin/{chunk-50keqtz9.js → chunk-agvb6bpw.js} +1 -1
  36. package/bin/{chunk-karn564z.js → chunk-ar79dg9g.js} +2 -2
  37. package/bin/{chunk-6fv38qdc.js → chunk-awaf0g5z.js} +2 -2
  38. package/bin/chunk-b0kh9jpt.js +1 -0
  39. package/bin/{chunk-9gzy30zm.js → chunk-bdwtaj3w.js} +2 -2
  40. package/bin/{chunk-3dx0p1ge.js → chunk-c32x8x6z.js} +1 -1
  41. package/bin/{chunk-38g3s1f3.js → chunk-c4yr75hy.js} +2 -2
  42. package/bin/chunk-d5v9nz51.js +1 -0
  43. package/bin/{chunk-zwgf211t.js → chunk-ddt5224b.js} +2 -2
  44. package/bin/{chunk-6zs49mef.js → chunk-dntwxkyf.js} +1 -1
  45. package/bin/{chunk-tzt4c1dm.js → chunk-dt9wfyf2.js} +2 -2
  46. package/bin/{chunk-tpp9qf5m.js → chunk-eekmnfn4.js} +2 -2
  47. package/bin/{chunk-a0k1b4sq.js → chunk-ej18j83b.js} +1 -1
  48. package/bin/{chunk-7872prvg.js → chunk-f37ywvvp.js} +1 -1
  49. package/bin/{chunk-7k3ccca6.js → chunk-fbqr4v70.js} +1 -1
  50. package/bin/chunk-ff8zrme6.js +1 -0
  51. package/bin/{chunk-qy93r7tm.js → chunk-fhd9yadg.js} +2 -2
  52. package/bin/chunk-g2qeb32y.js +2 -0
  53. package/bin/chunk-gtqchcj0.js +2 -0
  54. package/bin/{chunk-b8v7jvkb.js → chunk-h7jb1xb4.js} +2 -2
  55. package/bin/chunk-hdx9q31r.js +1 -0
  56. package/bin/chunk-hk5pwxhf.js +2 -0
  57. package/bin/chunk-hx2y4d75.js +2 -0
  58. package/bin/{chunk-dej1gq35.js → chunk-j4byth37.js} +1 -1
  59. package/bin/chunk-jkpxykx9.css +1 -0
  60. package/bin/chunk-jq28ge97.js +1 -0
  61. package/bin/{chunk-2086rsb2.js → chunk-jt7fdhke.js} +1 -1
  62. package/bin/{chunk-jszpvg8e.js → chunk-jvn0xnj8.js} +2 -2
  63. package/bin/{chunk-g60v3jc1.js → chunk-jx9tqjh9.js} +1 -1
  64. package/bin/chunk-mffjg6zb.js +2 -0
  65. package/bin/{chunk-4bn9eb9h.js → chunk-mv4v52ah.js} +1 -1
  66. package/bin/{chunk-gjdmnfms.js → chunk-mwrheqe3.js} +1 -1
  67. package/bin/{chunk-ptw49k86.js → chunk-n3997tqa.js} +1 -1
  68. package/bin/chunk-n3e4agsa.js +2 -0
  69. package/bin/chunk-naaa5ejw.js +2 -0
  70. package/bin/chunk-nc9hbzad.js +3 -0
  71. package/bin/{chunk-s0hgykza.js → chunk-nn753fbs.js} +2 -2
  72. package/bin/{chunk-hqkmdp31.js → chunk-nw1ch5d8.js} +2 -2
  73. package/bin/chunk-p2wyyvfa.js +2 -0
  74. package/bin/chunk-p65avrcv.js +2 -0
  75. package/bin/{chunk-fcs4v6jq.js → chunk-pfwt5734.js} +2 -2
  76. package/bin/chunk-ppwy5dja.js +1 -0
  77. package/bin/chunk-ptmxkptc.js +14 -0
  78. package/bin/chunk-px660tvj.js +2 -0
  79. package/bin/{chunk-3kqdgddm.js → chunk-q3y6kdkh.js} +2 -2
  80. package/bin/chunk-qbs0nvbn.js +3 -0
  81. package/bin/{chunk-gjn3w26y.js → chunk-qp1hkx9k.js} +2 -2
  82. package/bin/{chunk-87wqbn4g.js → chunk-qt6j0fm6.js} +2 -2
  83. package/bin/{chunk-3xzgddev.js → chunk-r0c9vmfm.js} +1 -1
  84. package/bin/chunk-r7crhkhn.js +5 -0
  85. package/bin/{chunk-b3jh3hf1.js → chunk-rq6bvf0t.js} +2 -2
  86. package/bin/{chunk-zqg4f56h.js → chunk-s78r8f5v.js} +1 -1
  87. package/bin/chunk-t6gqzden.js +1 -0
  88. package/bin/{chunk-nvjp2rnh.js → chunk-tfwtxwth.js} +2 -2
  89. package/bin/{chunk-1sqz0va1.js → chunk-tk362keq.js} +2 -2
  90. package/bin/chunk-tn24as5d.js +2 -0
  91. package/bin/{chunk-qdycy714.js → chunk-tx42kfdh.js} +1 -1
  92. package/bin/{chunk-vxpnp4xg.js → chunk-v2dksv7p.js} +2 -2
  93. package/bin/chunk-v2n1hwt3.js +1 -0
  94. package/bin/chunk-v5c6t1w3.js +41 -0
  95. package/bin/{chunk-0ycwr0kb.js → chunk-va9hwggw.js} +1 -1
  96. package/bin/{chunk-bancgvrc.js → chunk-vf6mpxrd.js} +2 -2
  97. package/bin/{chunk-f2j2cqd1.js → chunk-vhcsdnzv.js} +2 -2
  98. package/bin/{chunk-48nzw50r.js → chunk-vtm39m0n.js} +1 -1
  99. package/bin/{chunk-br5xkaf7.js → chunk-vwayy6dy.js} +3 -3
  100. package/bin/chunk-w4e52ade.js +2 -0
  101. package/bin/{chunk-6v39c8eg.js → chunk-wjk0f9fq.js} +2 -2
  102. package/bin/chunk-wk153p7c.js +1 -0
  103. package/bin/{chunk-cqq8e3hc.js → chunk-wth2f791.js} +2 -2
  104. package/bin/{chunk-503qq6sa.js → chunk-wy82m4nq.js} +2 -2
  105. package/bin/{chunk-r5dv0rfv.js → chunk-wzw7rrfy.js} +2 -2
  106. package/bin/{chunk-kpn9d97x.js → chunk-x6ta6e2v.js} +1 -1
  107. package/bin/chunk-y8wj6g7y.js +11 -0
  108. package/bin/chunk-ympx92ct.js +1 -0
  109. package/bin/{chunk-v8w2nxew.js → chunk-ytgtf0ak.js} +1 -1
  110. package/bin/{chunk-9nyhmtp9.js → chunk-yvknqnkb.js} +2 -2
  111. package/bin/chunk-yx6mahz0.js +1 -0
  112. package/bin/{chunk-x6532q76.js → chunk-z71h48pj.js} +1 -1
  113. package/bin/{chunk-ytzk81tr.js → chunk-z7m6sa7g.js} +1 -1
  114. package/bin/chunk-z8s40zfa.js +68 -0
  115. package/bin/{chunk-1xzc6z02.js → chunk-zafjhkkk.js} +1 -1
  116. package/bin/{chunk-rfyaphas.js → chunk-zcxajg6j.js} +2 -2
  117. package/bin/{chunk-0jkqmbcx.js → chunk-zq665ybs.js} +1 -1
  118. package/bin/{chunk-98j2z6he.js → chunk-zvq0btde.js} +3 -3
  119. package/bin/{chunk-qcqw7wnv.js → chunk-zwny8t7c.js} +2 -2
  120. package/bin/shumai-app.html +1 -1
  121. package/bin/shumai-app.js +494 -370
  122. package/package.json +7 -7
  123. package/prisma/migrations/20260814090300_add_asset_agentmd/migration.sql +2 -0
  124. package/prisma/migrations/20260814125921_create_asset_agentmd_table/migration.sql +21 -0
  125. package/prisma/migrations/20260816020719_add_agent_permission/migration.sql +2 -0
  126. package/prisma/migrations/20260817022118_add_quota_rules_and_records/migration.sql +68 -0
  127. package/prisma/migrations/20260818025858_remove_agent_skill_call_count_from_quota_resource_type/migration.sql +14 -0
  128. package/prisma/schema.prisma +82 -0
  129. package/bin/chunk-0xern7e4.js +0 -1
  130. package/bin/chunk-0yngn45x.js +0 -2
  131. package/bin/chunk-2mqqghrz.js +0 -2
  132. package/bin/chunk-4egayx81.js +0 -2
  133. package/bin/chunk-4rbzswqs.js +0 -71
  134. package/bin/chunk-60hpa5kf.js +0 -3
  135. package/bin/chunk-69tt1pvr.js +0 -2
  136. package/bin/chunk-815ezj20.js +0 -1
  137. package/bin/chunk-83k0wa5k.js +0 -2
  138. package/bin/chunk-85eg9xqx.js +0 -1
  139. package/bin/chunk-86aagej8.js +0 -1
  140. package/bin/chunk-8y1v9dm9.js +0 -2
  141. package/bin/chunk-9gq9782d.js +0 -1
  142. package/bin/chunk-bv88se28.css +0 -1
  143. package/bin/chunk-dv1zpd2p.js +0 -15
  144. package/bin/chunk-eetrc0j1.js +0 -3
  145. package/bin/chunk-eztggp8r.js +0 -1
  146. package/bin/chunk-gf5ds9r9.js +0 -2
  147. package/bin/chunk-h9emz0zb.js +0 -2
  148. package/bin/chunk-h9k2atte.js +0 -1
  149. package/bin/chunk-kkq4wvnc.js +0 -1
  150. package/bin/chunk-ksx113sp.js +0 -1
  151. package/bin/chunk-m6a4rzdt.js +0 -62
  152. package/bin/chunk-mw8f8ngt.js +0 -7
  153. package/bin/chunk-n76r6s9k.js +0 -2
  154. package/bin/chunk-qh9rz2ee.js +0 -11
  155. package/bin/chunk-rvspnthy.js +0 -1
  156. package/bin/chunk-sjjndwt4.js +0 -2
  157. package/bin/chunk-tvg9gvqs.js +0 -1
  158. package/bin/chunk-xp4dcyk3.js +0 -1
  159. package/bin/chunk-y8aehqr8.js +0 -2
  160. package/bin/chunk-yvxt48r4.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{Ff as l0,Gf as c0,Hf as u0,If as x0,Jf as j0,Mf as r0}from"./chunk-4st1t79p.js";import{Qf as E0,Rf as P0}from"./chunk-mffjg6zb.js";import{Sf as I0}from"./chunk-3h4t28zz.js";import{Xf as i0,Yf as n0}from"./chunk-nc9hbzad.js";import{Hg as S0,Mg as o0,wg as F0,xg as C0,yg as f0}from"./chunk-z8s40zfa.js";import{Ng as q0}from"./chunk-zcxajg6j.js";import{Rg as g0,Sg as D0,Tg as p0,Ug as m0}from"./chunk-03ec6p4p.js";import{lh as H0,oh as K0}from"./chunk-tn24as5d.js";import{Ch as v0,Dh as u,Eh as s,Fh as e,Gh as L0,Ih as a0,vh as d,wh as n,xh as t,yh as i,zh as O}from"./chunk-8qryr65z.js";import{Ej as w0,Kj as b0,Lh as N0,Mh as w,Nh as L,Oh as J,Ph as W0,Sh as X0,Ti as y0,Uh as o,Yi as M0,Zi as k0,_h as T0,ai as O0,dl as l,fl as $0,il as X,jl as G0,ll as Q0,ml as R0,ni as I,nj as a,ol as B0,pi as M,uj as Z0,vk as _0,xi as A0,yi as Y0,zj as V0}from"./chunk-5ctpz542.js";import{nm as J0}from"./chunk-j4byth37.js";var d0=J0(N0(),1);var c=J0(N0(),1);function U1(N){if(!N)return null;try{let U=K0(N);if(isNaN(U.getTime()))return null;return H0(U,"MMM d, yyyy")}catch{return null}}function z1({version:N,displayVersionNumber:U,index:K,canEdit:S,onRemove:$}){let[F,G]=c.useState(!1),{ref:Q,handleRef:C}=P0({id:N.id,index:K,disabled:!S}),R=U1(N.createdAt);return J("div",{ref:Q,className:"group flex items-center gap-3 p-2.5 rounded-lg border border-border bg-card hover:bg-accent/40 transition-colors",children:[J("div",{className:"flex-shrink-0 flex items-center justify-center bg-muted text-muted-foreground rounded-full px-2.5 py-0.5 text-xs font-semibold select-none min-w-[2.25rem]",children:["v",U]}),S?L("div",{ref:C,className:"cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground p-1 -m-1 rounded touch-none flex items-center justify-center",children:L(Z0,{className:"h-4 w-4"})}):L("div",{className:"w-4"}),L("div",{className:"h-12 w-20 flex-shrink-0 overflow-hidden rounded-md border border-border bg-muted flex items-center justify-center",children:N.previewUrl?L("img",{src:N.previewUrl,alt:N.name||"",className:"h-full w-full object-cover"}):L(a,{className:"h-5 w-5 text-muted-foreground"})}),J("div",{className:"flex flex-col flex-1 min-w-0 text-left",children:[L("span",{className:"truncate text-sm font-medium text-foreground",title:N.name||"",children:N.name||"Untitled"}),J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground truncate",children:[L("span",{children:N.creator?.name||X.unknown()}),R&&J(w,{children:[L("span",{children:"•"}),L("span",{children:R})]})]})]}),S&&J(d,{modal:!1,open:F,onOpenChange:G,children:[L(t,{asChild:!0,children:L($0,{variant:"ghost",size:"icon","aria-label":"More options",className:l("h-8 w-8 text-muted-foreground hover:text-foreground transition-opacity flex-shrink-0",F?"opacity-100":"opacity-0 group-hover:opacity-100 focus:opacity-100"),children:L(Y0,{className:"h-4 w-4"})})}),L(i,{align:"end",children:J(O,{onClick:()=>$(N.id),className:"text-destructive focus:text-destructive cursor-pointer",children:[L(_0,{className:"h-4 w-4 mr-2"}),L("span",{children:X.remove_from_stack()})]})})]})]})}function h0({open:N,onOpenChange:U,stackId:K,canEdit:S=!0,onVersionRemoved:$,onStackDissolved:F}){let G=W0(),[Q,C]=c.useState([]),{data:R,isLoading:V}=X0({queryKey:["version_stacks",K,"versions"],queryFn:async()=>{let W=await M.api.version_stacks[":stackId"].versions.$get({param:{stackId:K}});if(!W.ok)throw Error("Failed to fetch versions");return await W.json()},enabled:N&&!!K});c.useEffect(()=>{if(R)C(R)},[R]);let{mutate:k}=o({mutationFn:async({fileId:W,beforeId:Z})=>{if(!(await M.api.version_stacks[":stackId"].order.$post({param:{stackId:K},json:{fileId:W,beforeId:Z}})).ok)throw Error("Failed to reorder versions")},onSuccess:()=>{G.invalidateQueries({queryKey:["version_stacks"]}),G.invalidateQueries({queryKey:["files"]}),G.invalidateQueries({queryKey:["projects"]}),I.success(X.version_reordered_successfully())},onError:()=>{if(I.error(X.failed_to_reorder_versions()),R)C(R)}}),{mutate:D,isPending:A}=o({mutationFn:async(W)=>{if(!(await M.api.version_stacks[":stackId"].versions[":versionId"].$delete({param:{stackId:K,versionId:W}})).ok)throw Error("Failed to remove version from stack");return W},onSuccess:(W)=>{I.success(X.version_removed_successfully());let Z=Q.filter((q)=>q.id!==W);if(C(Z),G.invalidateQueries({queryKey:["version_stacks"]}),G.invalidateQueries({queryKey:["files"]}),G.invalidateQueries({queryKey:["projects"]}),Z.length<=1){let q=Z[0];if(U(!1),q)F?.(q.id)}else $?.(W,Z)},onError:()=>{I.error(X.failed_to_remove_version())}}),B=(W)=>{if(W.canceled)return;let{source:Z}=W.operation;if(!E0(Z))return;let{initialIndex:q,index:_}=Z;if(q===_)return;let f=[...Q],[b]=f.splice(q,1);f.splice(_,0,b),C(f);let E=_===f.length-1?"-1":f[_+1].id;k({fileId:b.id,beforeId:E})},h=(W)=>{if(A)return;D(W)};return L(G0,{open:N,onOpenChange:U,children:J(Q0,{className:"max-w-lg p-0 gap-0 overflow-hidden",children:[L(R0,{className:"p-4 pb-3 border-b border-border",children:L(B0,{className:"text-base font-semibold",children:X.manage_versions_title()})}),L(q0,{className:"max-h-[60vh] p-4",children:V?L("div",{className:"py-8 text-center text-sm text-muted-foreground",children:X.loading?.()||"Loading..."}):Q.length===0?L("div",{className:"py-8 text-center text-sm text-muted-foreground",children:X.no_versions_found()}):L("div",{className:"space-y-2",children:L(S0,{sensors:[f0.configure({activationConstraints:[new C0.Distance({value:6})]}),F0],onDragEnd:B,children:Q.map((W,Z)=>L(z1,{version:W,displayVersionNumber:Q.length-Z,index:Z,canEdit:S,onRemove:h},W.id))})})})]})})}function t0({teamId:N,projectId:U,projectName:K,ancestorFolders:S,currentAsset:$,isRootFolder:F,customTerminalBreadcrumb:G,displayStyle:Q,onDisplayStyleChange:C,isLeftSidebarCollapsed:R,onLeftSidebarToggle:V,isRightSidebarCollapsed:k,onRightSidebarToggle:D,isChatbotOpen:A=!1,onChatbotToggle:B,isPublic:h=!1,onFolderClick:W,onRename:Z,onDelete:q,fileId:_,shareId:f,allowDownload:b=!0,downloadInfo:E,versions:H,compareMode:x=!1,canCompareVersions:y=!1,onCompareVersions:j}){let g=T0(),{canEdit:p}=a0(U),[r,m]=d0.useState(!1),U0=!1,z0=(z)=>{if(!_)return;if(h&&f){g({to:"/share/$shareId/files/$fileId",params:{shareId:f,fileId:_},search:(Y)=>({...Y,version:z})});return}if(!U)return;g({to:"/projects/$projectId/files/$fileId",params:{projectId:U,fileId:_},search:(Y)=>({...Y,version:z})})},v=async(z)=>{if(!_)return;try{let Y=f?await M.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:f,fileId:_},json:{key:z}}):await M.api.files["download-url"].$post({json:{key:z,assetId:_}});if(!Y.ok)return;let{url:P}=await Y.json(),T=document.createElement("a");T.href=P,T.download="",document.body.appendChild(T),T.click(),document.body.removeChild(T)}catch{}},s0=$.proxyType!=="audio"&&(E?.videoTranscodes?.length??0)>0,e0=h?[{name:K,id:"root"},...S.slice().reverse().map((z)=>({name:z.name||"",id:z.id}))]:[{name:X.all_projects(),path:`/teams/${N}`,isMuted:!0},{name:K,path:`/projects/${U}`},...S.slice().reverse().map((z)=>({name:z.name||"",path:`/projects/${U}/folders/${z.id}`}))];return J("div",{className:"flex h-14 flex-wrap items-center justify-between gap-2 border-b border-border bg-card px-4 py-2",children:[J("div",{className:"flex min-w-0 flex-shrink items-center gap-1",children:[e0.map((z,Y)=>J("div",{className:"flex items-center gap-1",children:[Y>0&&L("span",{className:"text-muted-foreground",children:"/"}),z.path?L(O0,{to:z.path,className:l("truncate rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground",z.isMuted?"text-muted-foreground":"text-foreground"),children:z.name}):L("button",{onClick:()=>z.id&&W?.(z.id),className:"truncate rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground text-foreground",children:z.name})]},Y)),G?J("div",{className:"flex items-center gap-1",children:[L("span",{className:"text-muted-foreground",children:"/"}),L("span",{className:"truncate rounded px-2 py-1 text-sm font-medium text-foreground",children:G})]}):!F&&!x?J("div",{className:"flex items-center gap-1",children:[L("span",{className:"text-muted-foreground",children:"/"}),$.type==="folder"?L("span",{className:"truncate rounded px-2 py-1 text-sm font-medium text-foreground",children:$.name}):J(d,{modal:!1,children:[J(t,{className:"flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[L("span",{children:$.name}),$.version!==void 0&&J(I0,{variant:"outline",className:"px-1 py-0 text-xs",children:["v",$.version]}),L(k0,{className:"h-4 w-4"})]}),J(i,{className:"w-56",children:[b&&(s0?J(s,{children:[L(e,{className:"flex items-center gap-2",children:L("span",{children:X.download()})}),L(n,{children:J(L0,{className:"w-48",children:[L(v0,{children:X.download()}),E?.videoTranscodes?.map((z)=>{let Y=Math.max(z.width,z.height),P=`${z.height}p`;if(Y>=3840)P="2160p";else if(Y>=1920)P="1080p";else if(Y>=1280)P="720p";else if(Y>=960)P="540p";else if(Y>=640)P="360p";else if(Y>=320)P="180p";return J(O,{onClick:()=>v(z.key),className:"flex items-center justify-between",children:[L("span",{children:P}),L("span",{className:"text-xs text-muted-foreground",children:"MP4"})]},P)}),E?.originalKey&&J(w,{children:[L(u,{}),J(O,{onClick:()=>v(E.originalKey),className:"flex items-center justify-between",children:[L("span",{children:"Original"}),L("span",{className:"text-xs text-muted-foreground",children:$.name?.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})})]}):L(O,{onClick:()=>E?.originalKey&&v(E.originalKey),disabled:!E?.originalKey,children:X.download()})),p&&Z&&L(O,{onClick:Z,children:X.rename()}),p&&q&&L(O,{onClick:q,className:"text-destructive focus:text-destructive",children:X.delete()}),y&&j&&J(w,{children:[L(u,{}),J(O,{onClick:()=>j(),children:[L(A0,{className:"h-4 w-4"}),L("span",{children:X.compare_versions()})]})]}),H&&H.length>0&&J(w,{children:[L(u,{}),J(s,{children:[J(e,{className:"flex items-center gap-2",children:[L(V0,{className:"h-4 w-4"}),L("span",{children:"Versions"})]}),L(n,{children:J(L0,{className:"w-80 p-1",children:[L("div",{className:"flex flex-col gap-1 max-h-96 overflow-y-auto",children:H.map((z)=>{let Y=$.version===z.version;return J(O,{onClick:()=>z0(z.id),className:"flex items-center gap-3 py-2 px-3 rounded-md cursor-pointer focus:bg-accent focus:text-accent-foreground",children:[J("div",{className:"flex-shrink-0 flex items-center justify-center bg-muted dark:bg-muted-foreground/20 text-muted-foreground dark:text-muted-foreground rounded-full px-2 py-0.5 text-xs font-semibold select-none min-w-[2rem]",children:["v",z.version]}),L("div",{className:"h-10 w-16 flex-shrink-0 overflow-hidden rounded-md border border-border bg-muted flex items-center justify-center",children:z.previewUrl?L("img",{src:z.previewUrl,alt:z.name||void 0,className:"h-full w-full object-cover"}):L(a,{className:"h-4 w-4 text-muted-foreground"})}),J("div",{className:"flex flex-col flex-1 min-w-0 text-left",children:[L("span",{className:"truncate text-sm font-semibold text-foreground",children:z.name}),L("span",{className:"truncate text-xs text-muted-foreground",children:z.creator?.name||"Unknown"})]}),Y&&L(M0,{className:"h-4 w-4 text-primary ml-auto flex-shrink-0"})]},z.id)})}),L(u,{}),L("div",{className:"p-1",children:L("button",{className:"w-full text-center text-xs font-medium py-2 px-3 rounded-md bg-muted/80 hover:bg-muted text-foreground transition-colors cursor-pointer",onClick:()=>m(!0),children:X.manage_versions()})})]})})]})]})]})]})]}):null,_&&H&&H.length>0&&L(h0,{open:r,onOpenChange:m,stackId:_,canEdit:p,onStackDissolved:(z)=>{m(!1),g({to:"/projects/$projectId/files/$fileId",params:{projectId:U,fileId:z}})},onVersionRemoved:(z,Y)=>{if(($.version?H.find((T)=>T.version===$.version)?.id:void 0)===z){let T=Y[0];if(T)g({to:"/projects/$projectId/files/$fileId",params:{projectId:U,fileId:_},search:(L1)=>({...L1,version:T.id})})}}})]}),J("div",{className:"flex items-center gap-2",children:[J("div",{className:"flex flex-shrink-0 items-center gap-1 rounded-md border border-border bg-background p-1",children:[!_&&!h&&V&&L("button",{onClick:V,className:"rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:R?"Show Left Sidebar":"Hide Left Sidebar",children:R?L(l0,{className:"h-4 w-4"}):L(u0,{className:"h-4 w-4 fill-primary stroke-0"})}),!_&&!h&&Q&&C&&J(w,{children:[L("button",{onClick:()=>C("card"),className:`rounded p-1.5 transition-colors ${Q==="card"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:"Card View",children:L(w0,{className:"h-4 w-4"})}),L("button",{onClick:()=>C("list"),className:`rounded p-1.5 transition-colors ${Q==="list"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:"List View",children:L(b0,{className:"h-4 w-4"})})]}),L("button",{onClick:D,className:`rounded p-1.5 transition-colors ${!k&&!A?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:k?"Show Right Sidebar":"Hide Right Sidebar",children:!k&&!A?L(x0,{className:"h-4 w-4 fill-primary stroke-0"}):L(c0,{className:"h-4 w-4"})})]}),!h&&B&&L(g0,{children:J(D0,{children:[L(p0,{asChild:!0,children:L("span",{children:L("button",{disabled:!1,onClick:B,className:l("h-9 w-9 flex items-center justify-center rounded-full border border-border bg-background transition-colors",A?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground",!1),children:A?L(j0,{className:"h-6 w-6 text-primary transition-colors"}):L(y0,{className:"h-6 w-6 text-muted-foreground transition-colors"})})})}),L(m0,{children:L("p",{children:A?X.hide_chatbot():X.show_chatbot()})})]})})]})]})}function I1(){let{projectState:N}=i0(),U=o0(),{isChatbotOpen:K,setIsChatbotOpen:S}=n0();if(!N)return L(J1,{});let{teamId:$,projectId:F,projectName:G,ancestorFolders:Q,currentAsset:C,isRootFolder:R,customTerminalBreadcrumb:V,fileId:k,downloadInfo:D,versions:A,isPublic:B,shareId:h,allowDownload:W,onFolderClick:Z,onRename:q,onDelete:_,compareMode:f,canCompareVersions:b,onCompareVersions:E}=N,H=!!k,x=!!V,y=!!h&&!H,j=H?U.fileViewLeftSidebarCollapsed:y?U.shareConfigLeftSidebarCollapsed:U.fileListLeftSidebarCollapsed,g=B?void 0:()=>H?U.setFileViewLeftSidebarCollapsed(!U.fileViewLeftSidebarCollapsed):y?U.setShareConfigLeftSidebarCollapsed(!U.shareConfigLeftSidebarCollapsed):U.setFileListLeftSidebarCollapsed(!U.fileListLeftSidebarCollapsed),p=B&&N.isRightSidebarCollapsed!==void 0?N.isRightSidebarCollapsed:H?U.fileViewRightSidebarCollapsed:y?U.shareConfigRightSidebarCollapsed:U.fileListRightSidebarCollapsed,r=B&&N.onRightSidebarToggle?N.onRightSidebarToggle:()=>{if(!B&&K)if(S(!1),H)U.setFileViewRightSidebarCollapsed(!1);else if(y)U.setShareConfigRightSidebarCollapsed(!1);else U.setFileListRightSidebarCollapsed(!1);else if(H)U.setFileViewRightSidebarCollapsed(!U.fileViewRightSidebarCollapsed);else if(y)U.setShareConfigRightSidebarCollapsed(!U.shareConfigRightSidebarCollapsed);else U.setFileListRightSidebarCollapsed(!U.fileListRightSidebarCollapsed)},m=B?void 0:()=>{S(!K)},U0=F?U.viewModes[F]??"card":"card";return L(t0,{teamId:$,projectId:F,projectName:G,ancestorFolders:Q,currentAsset:C,isRootFolder:R,customTerminalBreadcrumb:V,displayStyle:H||y||x?void 0:U0,onDisplayStyleChange:H||y||x?void 0:B?void 0:(v)=>{if(F)U.setViewMode(F,v)},isLeftSidebarCollapsed:j,onLeftSidebarToggle:g,isRightSidebarCollapsed:p,onRightSidebarToggle:r,isChatbotOpen:!B&&K,onChatbotToggle:m,isPublic:B,shareId:h,allowDownload:W,fileId:k,downloadInfo:D,versions:A,onFolderClick:Z,onRename:q,onDelete:_,compareMode:f,canCompareVersions:b,onCompareVersions:E})}function J1(){return L("div",{className:"flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2 flex-shrink-0",children:L(r0,{className:"w-10 h-10 text-orange-600"})})}
2
+ export{I1 as af};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{nb as a}from"./chunk-qp1hkx9k.js";import"./chunk-j4byth37.js";export default a();
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Pl as pt}from"./chunk-dej1gq35.js";var Fe={};pt(Fe,{encode:()=>y,decode:()=>W});var X=new TextEncoder,C=new TextDecoder;function g(...e){let t=e.reduce((i,{length:a})=>i+a,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function Ge(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Ve(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return Ge(n,t,0),Ge(n,r,4),n}function Ce(e){let t=new Uint8Array(4);return Ge(t,e),t}function w(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function de(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function xe(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function W(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==="string"?e:C.decode(e),{alphabet:"base64url"});let t=e;if(t instanceof Uint8Array)t=C.decode(t);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return xe(t)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function y(e){let t=e;if(typeof t==="string")t=X.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return de(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var v=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),N=(e,t)=>e.name===t;function mr(e){return parseInt(e.name.slice(4),10)}function Pe(e,t){if(mr(e.hash)!==t)throw v(`SHA-${t}`,"algorithm.hash")}function yr(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}function ut(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function dt(e,t,r){switch(t){case"HS256":case"HS384":case"HS512":{if(!N(e.algorithm,"HMAC"))throw v("HMAC");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!N(e.algorithm,"RSASSA-PKCS1-v1_5"))throw v("RSASSA-PKCS1-v1_5");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!N(e.algorithm,"RSA-PSS"))throw v("RSA-PSS");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!N(e.algorithm,"Ed25519"))throw v("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!N(e.algorithm,t))throw v(t);break}case"ES256":case"ES384":case"ES512":{if(!N(e.algorithm,"ECDSA"))throw v("ECDSA");let n=yr(t);if(e.algorithm.namedCurve!==n)throw v(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function J(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!N(e.algorithm,"AES-GCM"))throw v("AES-GCM");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!N(e.algorithm,"AES-KW"))throw v("AES-KW");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw v("ECDH or X25519")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!N(e.algorithm,"PBKDF2"))throw v("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!N(e.algorithm,"RSA-OAEP"))throw v("RSA-OAEP");Pe(e.algorithm,parseInt(t.slice(9),10)||1);break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function ft(e,t,...r){if(r=r.filter(Boolean),r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var D=(e,...t)=>ft("Key must be ",e,...t),ze=(e,t,...r)=>ft(`Key for the ${e} algorithm must be `,t,...r);var ht={};pt(ht,{JWTInvalid:()=>K,JWTExpired:()=>fe,JWTClaimValidationFailed:()=>H,JWSSignatureVerificationFailed:()=>ne,JWSInvalid:()=>h,JWKSTimeout:()=>Te,JWKSNoMatchingKey:()=>re,JWKSMultipleMatchingKeys:()=>He,JWKSInvalid:()=>he,JWKInvalid:()=>We,JWEInvalid:()=>c,JWEDecryptionFailed:()=>V,JOSENotSupported:()=>d,JOSEError:()=>x,JOSEAlgNotAllowed:()=>Y});class x extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class H extends x{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class fe extends x{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class Y extends x{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class d extends x{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class V extends x{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class c extends x{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class h extends x{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class K extends x{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class We extends x{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class he extends x{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class re extends x{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class He extends x{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class Te extends x{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class ne extends x{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function ie(e){if(!M(e))throw Error("CryptoKey instance expected")}var M=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},q=(e)=>e?.[Symbol.toStringTag]==="KeyObject",me=(e)=>M(e)||q(e);function Ie(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var _=(e)=>crypto.getRandomValues(new Uint8Array(Ie(e)>>3));function ve(e,t){let r=e.byteLength<<3;if(r!==t)throw new c(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function mt(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var lr=(e)=>crypto.getRandomValues(new Uint8Array(mt(e)>>3));function yt(e,t){if(t.length<<3!==mt(e))throw new c("Invalid Initialization Vector length")}async function lt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(D(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10),i=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),a=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return{encKey:i,macKey:a,keySize:n}}async function St(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function Sr(e,t,r,n,i){let{encKey:a,macKey:s,keySize:o}=await lt(e,r,"encrypt"),p=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=g(i,n,p,Ve(i.length<<3)),f=await St(s,u,o);return{ciphertext:p,tag:f,iv:n}}async function wr(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),s=0,o=-1;while(++o<32)s|=i[o]^a[o];return s===0}async function Ar(e,t,r,n,i,a){let{encKey:s,macKey:o,keySize:p}=await lt(e,t,"decrypt"),u=g(a,n,r,Ve(a.length<<3)),f=await St(o,u,p),l;try{l=await wr(i,f)}catch{}if(!l)throw new V;let E;try{E=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},s,r))}catch{}if(!E)throw new V;return E}async function Er(e,t,r,n,i){let a;if(r instanceof Uint8Array)a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]);else J(r,e,"encrypt"),a=r;let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),o=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:o,iv:n}}async function br(e,t,r,n,i,a){let s;if(t instanceof Uint8Array)s=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]);else J(t,e,"decrypt"),s=t;try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},s,g(r,i)))}catch{throw new V}}var wt="Unsupported JWE Content Encryption Algorithm";async function Je(e,t,r,n,i){if(!M(r)&&!(r instanceof Uint8Array))throw TypeError(D(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)yt(e,n);else n=lr(e);switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(-3),10));return Sr(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(1,4),10));return Er(e,t,r,n,i);default:throw new d(wt)}}async function Re(e,t,r,n,i,a){if(!M(t)&&!(t instanceof Uint8Array))throw TypeError(D(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new c("JWE Initialization Vector missing");if(!i)throw new c("JWE Authentication Tag missing");switch(yt(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(-3),10));return Ar(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(1,4),10));return br(e,t,r,n,i,a);default:throw new d(wt)}}var De=Symbol();function S(e,t){if(e)throw TypeError(`${t} can only be called once`)}function I(e,t,r){try{return W(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function Ue(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}var gr=(e)=>typeof e==="object"&&e!==null;function m(e){if(!gr(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function L(...e){let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(let a of i){if(r.has(a))return!1;r.add(a)}}return!0}var Q=(e)=>m(e)&&typeof e.kty==="string",At=(e)=>e.kty!=="oct"&&(e.kty==="AKP"&&typeof e.priv==="string"||typeof e.d==="string"),Et=(e)=>e.kty!=="oct"&&e.d===void 0&&e.priv===void 0,bt=(e)=>e.kty==="oct"&&typeof e.k==="string";function gt(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function Kt(e,t,r){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]);return J(e,t,r),e}async function ye(e,t,r){let n=await Kt(t,e,"wrapKey");gt(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function le(e,t,r){let n=await Kt(t,e,"unwrapKey");gt(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function Xe(e){return g(Ce(e.length),e)}async function Cr(e,t,r){let n=t>>3,i=32,a=Math.ceil(n/32),s=new Uint8Array(a*32);for(let o=1;o<=a;o++){let p=new Uint8Array(4+e.length+r.length);p.set(Ce(o),0),p.set(e,4),p.set(r,4+e.length);let u=await Ue("sha256",p);s.set(u,(o-1)*32)}return s.slice(0,n)}async function Ye(e,t,r,n,i=new Uint8Array,a=new Uint8Array){J(e,"ECDH"),J(t,"ECDH","deriveBits");let s=Xe(w(r)),o=Xe(i),p=Xe(a),u=Ce(n),f=new Uint8Array,l=g(s,o,p,u,f),E=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,xr(e)));return Cr(E,n,l)}function xr(e){if(e.algorithm.name==="X25519")return 256;return Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3}function qe(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return e.algorithm.name==="X25519"}}function Wr(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return J(e,t,"deriveBits"),e}var Hr=(e,t)=>g(w(e),Uint8Array.of(0),t);async function xt(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new c("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new c("PBES2 Count Input must be a positive integer");let i=Hr(t,e),a=parseInt(t.slice(13,16),10),s={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},o=await Wr(n,t);return new Uint8Array(await crypto.subtle.deriveBits(s,o,a))}async function Pt(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await xt(i,e,n,t);return{encryptedKey:await ye(e.slice(-6),a,r),p2c:n,p2s:y(i)}}async function Wt(e,t,r,n,i){let a=await xt(i,e,n,t);return le(e.slice(-6),a,r)}function Se(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function Ht(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Tt(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(D(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}return dt(t,e,r),t}async function vt(e,t,r){let n=await Tt(e,t,"sign");Se(e,n);let i=await crypto.subtle.sign(Ht(e,n.algorithm),n,r);return new Uint8Array(i)}async function It(e,t,r,n){let i=await Tt(e,t,"verify");Se(e,i);let a=Ht(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}var Jt=(e)=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function Rt(e,t,r){return J(t,e,"encrypt"),Se(e,t),new Uint8Array(await crypto.subtle.encrypt(Jt(e),t,r))}async function Dt(e,t,r){return J(t,e,"decrypt"),Se(e,t),new Uint8Array(await crypto.subtle.decrypt(Jt(e),t,r))}var Me='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Ir(e){let t,r;switch(e.kty){case"AKP":{switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new d(Me)}break}case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new d(Me)}break}case"EC":{switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}default:throw new d('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}async function ae(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=Ir(e),n={...e};if(n.kty!=="AKP")delete n.alg;return delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(e.d||e.priv?!1:!0),e.key_ops??r)}var se="given KeyObject instance cannot be used for this algorithm",oe,Ut=async(e,t,r,n=!1)=>{oe||=new WeakMap;let i=oe.get(e);if(i?.[r])return i[r];let a=await ae({...t,alg:r});if(n)Object.freeze(e);if(!i)oe.set(e,{[r]:a});else i[r]=a;return a},Jr=(e,t)=>{oe||=new WeakMap;let r=oe.get(e);if(r?.[t])return r[t];let n=e.type==="public",i=n?!0:!1,a;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(se)}a=e.toCryptoKey(e.asymmetricKeyType,i,n?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}}if(e.asymmetricKeyType==="rsa"){let s;switch(t){case"RSA-OAEP":s="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":s="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":s="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":s="SHA-512";break;default:throw TypeError(se)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:s},i,n?["encrypt"]:["decrypt"]);a=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:s},i,[n?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){let o=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!o)throw TypeError(se);let p={ES256:"P-256",ES384:"P-384",ES512:"P-521"};if(p[t]&&o===p[t])a=e.toCryptoKey({name:"ECDSA",namedCurve:o},i,[n?"verify":"sign"]);if(t.startsWith("ECDH-ES"))a=e.toCryptoKey({name:"ECDH",namedCurve:o},i,n?[]:["deriveBits"])}if(!a)throw TypeError(se);if(!r)oe.set(e,{[t]:a});else r[t]=a;return a};async function U(e,t){if(e instanceof Uint8Array)return e;if(M(e))return e;if(q(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey==="function")try{return Jr(e,t)}catch(n){if(n instanceof TypeError)throw n}let r=e.export({format:"jwk"});return Ut(e,r,t)}if(Q(e)){if(e.k)return W(e.k);return Ut(e,e,t,!0)}throw Error("unreachable")}var Mt=(e,t)=>{let r=(e.match(/.{1,64}/g)||[]).join(`
2
+ import{pm as pt}from"./chunk-j4byth37.js";var Fe={};pt(Fe,{encode:()=>y,decode:()=>W});var X=new TextEncoder,C=new TextDecoder;function g(...e){let t=e.reduce((i,{length:a})=>i+a,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function Ge(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Ve(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return Ge(n,t,0),Ge(n,r,4),n}function Ce(e){let t=new Uint8Array(4);return Ge(t,e),t}function w(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function de(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function xe(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function W(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==="string"?e:C.decode(e),{alphabet:"base64url"});let t=e;if(t instanceof Uint8Array)t=C.decode(t);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return xe(t)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function y(e){let t=e;if(typeof t==="string")t=X.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return de(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var v=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),N=(e,t)=>e.name===t;function mr(e){return parseInt(e.name.slice(4),10)}function Pe(e,t){if(mr(e.hash)!==t)throw v(`SHA-${t}`,"algorithm.hash")}function yr(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}function ut(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function dt(e,t,r){switch(t){case"HS256":case"HS384":case"HS512":{if(!N(e.algorithm,"HMAC"))throw v("HMAC");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!N(e.algorithm,"RSASSA-PKCS1-v1_5"))throw v("RSASSA-PKCS1-v1_5");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!N(e.algorithm,"RSA-PSS"))throw v("RSA-PSS");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!N(e.algorithm,"Ed25519"))throw v("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!N(e.algorithm,t))throw v(t);break}case"ES256":case"ES384":case"ES512":{if(!N(e.algorithm,"ECDSA"))throw v("ECDSA");let n=yr(t);if(e.algorithm.namedCurve!==n)throw v(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function J(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!N(e.algorithm,"AES-GCM"))throw v("AES-GCM");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!N(e.algorithm,"AES-KW"))throw v("AES-KW");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw v("ECDH or X25519")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!N(e.algorithm,"PBKDF2"))throw v("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!N(e.algorithm,"RSA-OAEP"))throw v("RSA-OAEP");Pe(e.algorithm,parseInt(t.slice(9),10)||1);break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function ft(e,t,...r){if(r=r.filter(Boolean),r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var D=(e,...t)=>ft("Key must be ",e,...t),ze=(e,t,...r)=>ft(`Key for the ${e} algorithm must be `,t,...r);var ht={};pt(ht,{JWTInvalid:()=>K,JWTExpired:()=>fe,JWTClaimValidationFailed:()=>H,JWSSignatureVerificationFailed:()=>ne,JWSInvalid:()=>h,JWKSTimeout:()=>Te,JWKSNoMatchingKey:()=>re,JWKSMultipleMatchingKeys:()=>He,JWKSInvalid:()=>he,JWKInvalid:()=>We,JWEInvalid:()=>c,JWEDecryptionFailed:()=>V,JOSENotSupported:()=>d,JOSEError:()=>x,JOSEAlgNotAllowed:()=>Y});class x extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class H extends x{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class fe extends x{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class Y extends x{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class d extends x{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class V extends x{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class c extends x{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class h extends x{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class K extends x{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class We extends x{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class he extends x{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class re extends x{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class He extends x{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class Te extends x{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class ne extends x{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function ie(e){if(!M(e))throw Error("CryptoKey instance expected")}var M=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},q=(e)=>e?.[Symbol.toStringTag]==="KeyObject",me=(e)=>M(e)||q(e);function Ie(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var _=(e)=>crypto.getRandomValues(new Uint8Array(Ie(e)>>3));function ve(e,t){let r=e.byteLength<<3;if(r!==t)throw new c(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function mt(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var lr=(e)=>crypto.getRandomValues(new Uint8Array(mt(e)>>3));function yt(e,t){if(t.length<<3!==mt(e))throw new c("Invalid Initialization Vector length")}async function lt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(D(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10),i=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),a=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return{encKey:i,macKey:a,keySize:n}}async function St(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function Sr(e,t,r,n,i){let{encKey:a,macKey:s,keySize:o}=await lt(e,r,"encrypt"),p=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=g(i,n,p,Ve(i.length<<3)),f=await St(s,u,o);return{ciphertext:p,tag:f,iv:n}}async function wr(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),s=0,o=-1;while(++o<32)s|=i[o]^a[o];return s===0}async function Ar(e,t,r,n,i,a){let{encKey:s,macKey:o,keySize:p}=await lt(e,t,"decrypt"),u=g(a,n,r,Ve(a.length<<3)),f=await St(o,u,p),l;try{l=await wr(i,f)}catch{}if(!l)throw new V;let E;try{E=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},s,r))}catch{}if(!E)throw new V;return E}async function Er(e,t,r,n,i){let a;if(r instanceof Uint8Array)a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]);else J(r,e,"encrypt"),a=r;let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),o=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:o,iv:n}}async function br(e,t,r,n,i,a){let s;if(t instanceof Uint8Array)s=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]);else J(t,e,"decrypt"),s=t;try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},s,g(r,i)))}catch{throw new V}}var wt="Unsupported JWE Content Encryption Algorithm";async function Je(e,t,r,n,i){if(!M(r)&&!(r instanceof Uint8Array))throw TypeError(D(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)yt(e,n);else n=lr(e);switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(-3),10));return Sr(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(1,4),10));return Er(e,t,r,n,i);default:throw new d(wt)}}async function Re(e,t,r,n,i,a){if(!M(t)&&!(t instanceof Uint8Array))throw TypeError(D(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new c("JWE Initialization Vector missing");if(!i)throw new c("JWE Authentication Tag missing");switch(yt(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(-3),10));return Ar(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(1,4),10));return br(e,t,r,n,i,a);default:throw new d(wt)}}var De=Symbol();function S(e,t){if(e)throw TypeError(`${t} can only be called once`)}function I(e,t,r){try{return W(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function Ue(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}var gr=(e)=>typeof e==="object"&&e!==null;function m(e){if(!gr(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function L(...e){let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(let a of i){if(r.has(a))return!1;r.add(a)}}return!0}var Q=(e)=>m(e)&&typeof e.kty==="string",At=(e)=>e.kty!=="oct"&&(e.kty==="AKP"&&typeof e.priv==="string"||typeof e.d==="string"),Et=(e)=>e.kty!=="oct"&&e.d===void 0&&e.priv===void 0,bt=(e)=>e.kty==="oct"&&typeof e.k==="string";function gt(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function Kt(e,t,r){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]);return J(e,t,r),e}async function ye(e,t,r){let n=await Kt(t,e,"wrapKey");gt(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function le(e,t,r){let n=await Kt(t,e,"unwrapKey");gt(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function Xe(e){return g(Ce(e.length),e)}async function Cr(e,t,r){let n=t>>3,i=32,a=Math.ceil(n/32),s=new Uint8Array(a*32);for(let o=1;o<=a;o++){let p=new Uint8Array(4+e.length+r.length);p.set(Ce(o),0),p.set(e,4),p.set(r,4+e.length);let u=await Ue("sha256",p);s.set(u,(o-1)*32)}return s.slice(0,n)}async function Ye(e,t,r,n,i=new Uint8Array,a=new Uint8Array){J(e,"ECDH"),J(t,"ECDH","deriveBits");let s=Xe(w(r)),o=Xe(i),p=Xe(a),u=Ce(n),f=new Uint8Array,l=g(s,o,p,u,f),E=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,xr(e)));return Cr(E,n,l)}function xr(e){if(e.algorithm.name==="X25519")return 256;return Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3}function qe(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return e.algorithm.name==="X25519"}}function Wr(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return J(e,t,"deriveBits"),e}var Hr=(e,t)=>g(w(e),Uint8Array.of(0),t);async function xt(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new c("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new c("PBES2 Count Input must be a positive integer");let i=Hr(t,e),a=parseInt(t.slice(13,16),10),s={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},o=await Wr(n,t);return new Uint8Array(await crypto.subtle.deriveBits(s,o,a))}async function Pt(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await xt(i,e,n,t);return{encryptedKey:await ye(e.slice(-6),a,r),p2c:n,p2s:y(i)}}async function Wt(e,t,r,n,i){let a=await xt(i,e,n,t);return le(e.slice(-6),a,r)}function Se(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function Ht(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Tt(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(D(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}return dt(t,e,r),t}async function vt(e,t,r){let n=await Tt(e,t,"sign");Se(e,n);let i=await crypto.subtle.sign(Ht(e,n.algorithm),n,r);return new Uint8Array(i)}async function It(e,t,r,n){let i=await Tt(e,t,"verify");Se(e,i);let a=Ht(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}var Jt=(e)=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function Rt(e,t,r){return J(t,e,"encrypt"),Se(e,t),new Uint8Array(await crypto.subtle.encrypt(Jt(e),t,r))}async function Dt(e,t,r){return J(t,e,"decrypt"),Se(e,t),new Uint8Array(await crypto.subtle.decrypt(Jt(e),t,r))}var Me='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Ir(e){let t,r;switch(e.kty){case"AKP":{switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new d(Me)}break}case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new d(Me)}break}case"EC":{switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}default:throw new d('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}async function ae(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=Ir(e),n={...e};if(n.kty!=="AKP")delete n.alg;return delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(e.d||e.priv?!1:!0),e.key_ops??r)}var se="given KeyObject instance cannot be used for this algorithm",oe,Ut=async(e,t,r,n=!1)=>{oe||=new WeakMap;let i=oe.get(e);if(i?.[r])return i[r];let a=await ae({...t,alg:r});if(n)Object.freeze(e);if(!i)oe.set(e,{[r]:a});else i[r]=a;return a},Jr=(e,t)=>{oe||=new WeakMap;let r=oe.get(e);if(r?.[t])return r[t];let n=e.type==="public",i=n?!0:!1,a;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(se)}a=e.toCryptoKey(e.asymmetricKeyType,i,n?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}}if(e.asymmetricKeyType==="rsa"){let s;switch(t){case"RSA-OAEP":s="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":s="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":s="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":s="SHA-512";break;default:throw TypeError(se)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:s},i,n?["encrypt"]:["decrypt"]);a=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:s},i,[n?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){let o=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!o)throw TypeError(se);let p={ES256:"P-256",ES384:"P-384",ES512:"P-521"};if(p[t]&&o===p[t])a=e.toCryptoKey({name:"ECDSA",namedCurve:o},i,[n?"verify":"sign"]);if(t.startsWith("ECDH-ES"))a=e.toCryptoKey({name:"ECDH",namedCurve:o},i,n?[]:["deriveBits"])}if(!a)throw TypeError(se);if(!r)oe.set(e,{[t]:a});else r[t]=a;return a};async function U(e,t){if(e instanceof Uint8Array)return e;if(M(e))return e;if(q(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey==="function")try{return Jr(e,t)}catch(n){if(n instanceof TypeError)throw n}let r=e.export({format:"jwk"});return Ut(e,r,t)}if(Q(e)){if(e.k)return W(e.k);return Ut(e,e,t,!0)}throw Error("unreachable")}var Mt=(e,t)=>{let r=(e.match(/.{1,64}/g)||[]).join(`
3
3
  `);return`-----BEGIN ${t}-----
4
4
  ${r}
5
5
  -----END ${t}-----`},Ot=async(e,t,r)=>{if(q(r)){if(r.type!==e)throw TypeError(`key is not a ${e} key`);return r.export({format:"pem",type:t})}if(!M(r))throw TypeError(D(r,"CryptoKey","KeyObject"));if(!r.extractable)throw TypeError("CryptoKey is not extractable");if(r.type!==e)throw TypeError(`key is not a ${e} key`);return Mt(de(new Uint8Array(await crypto.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},Nt=(e)=>Ot("public","spki",e),_t=(e)=>Ot("private","pkcs8",e),Qe=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},je=(e)=>({data:e,pos:0}),O=(e)=>{let t=e.data[e.pos++];if(t&128){let r=t&127,n=0;for(let i=0;i<r;i++)n=n<<8|e.data[e.pos++];return n}return t},Ze=(e,t=1)=>{if(t<=0)return;e.pos++;let r=O(e);if(e.pos+=r,t>1)Ze(e,t-1)},B=(e,t,r)=>{if(e.data[e.pos++]!==t)throw Error(r)},Lt=(e,t)=>{let r=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,r},Rr=(e)=>{B(e,6,"Expected algorithm OID");let t=O(e);return Lt(e,t)};function Dr(e){B(e,48,"Invalid PKCS#8 structure"),O(e),B(e,2,"Expected version field");let t=O(e);e.pos+=t,B(e,48,"Expected algorithm identifier");let r=O(e);return{algIdStart:e.pos,algIdLength:r}}function Ur(e){B(e,48,"Invalid SPKI structure"),O(e),B(e,48,"Expected algorithm identifier");let t=O(e);return{algIdStart:e.pos,algIdLength:t}}var Bt=(e)=>{let t=Rr(e);if(Qe(t,[43,101,110]))return"X25519";if(!Qe(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");B(e,6,"Expected curve OID");let r=O(e),n=Lt(e,r);for(let{name:i,oid:a}of[{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}])if(Qe(n,a))return i;throw Error("Unsupported named curve")},kt=async(e,t,r,n)=>{let i,a,s=e==="spki",o=()=>s?["verify"]:["sign"],p=()=>s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];switch(r){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${r.slice(-3)}`},a=o();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.slice(-3)}`},a=o();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(r.slice(-3),10)||1}`},a=p();break;case"ES256":case"ES384":case"ES512":{i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[r]},a=o();break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{try{let u=n.getNamedCurve(t);i=u==="X25519"?{name:"X25519"}:{name:"ECDH",namedCurve:u}}catch(u){throw new d("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break}case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=o();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:r},a=o();break;default:throw new d('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,n?.extractable??(s?!0:!1),a)},et=(e,t)=>{return xe(e.replace(t,""))},$t=(e,t,r)=>{let n=et(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),i=r;if(t?.startsWith?.("ECDH-ES"))i||={},i.getNamedCurve=(a)=>{let s=je(a);return Dr(s),Bt(s)};return kt("pkcs8",n,t,i)},tt=(e,t,r)=>{let n=et(e,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g),i=r;if(t?.startsWith?.("ECDH-ES"))i||={},i.getNamedCurve=(a)=>{let s=je(a);return Ur(s),Bt(s)};return kt("spki",n,t,i)};function Mr(e){let t=je(e);if(B(t,48,"Invalid certificate structure"),O(t),B(t,48,"Invalid tbsCertificate structure"),O(t),e[t.pos]===160)Ze(t,6);else Ze(t,5);let r=t.pos;B(t,48,"Invalid SPKI structure");let n=O(t);return e.subarray(r,r+n+(t.pos-r))}function Or(e){let t=et(e,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g);return Mr(t)}var Gt=(e,t,r)=>{let n;try{n=Or(e)}catch(i){throw TypeError("Failed to parse the X.509 certificate",{cause:i})}return tt(Mt(de(n),"PUBLIC KEY"),t,r)};async function Nr(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw TypeError('"spki" must be SPKI formatted string');return tt(e,t,r)}async function _r(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN CERTIFICATE-----")!==0)throw TypeError('"x509" must be X.509 formatted string');return Gt(e,t,r)}async function Lr(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw TypeError('"pkcs8" must be PKCS#8 formatted string');return $t(e,t,r)}async function Z(e,t,r){if(!m(e))throw TypeError("JWK must be an object");let n;switch(t??=e.alg,n??=r?.extractable??e.ext,e.kty){case"oct":if(typeof e.k!=="string"||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return W(e.k);case"RSA":if("oth"in e&&e.oth!==void 0)throw new d('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return ae({...e,alg:t,ext:n});case"AKP":{if(typeof e.alg!=="string"||!e.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(t!==void 0&&t!==e.alg)throw TypeError("JWK alg and alg option value mismatch");return ae({...e,ext:n})}case"EC":case"OKP":return ae({...e,alg:t,ext:n});default:throw new d('Unsupported "kty" (Key Type) Parameter value')}}async function Vt(e){if(q(e))if(e.type==="secret")e=e.export();else return e.export({format:"jwk"});if(e instanceof Uint8Array)return{kty:"oct",k:y(e)};if(!M(e))throw TypeError(D(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:i,...a}=await crypto.subtle.exportKey("jwk",e);if(a.kty==="AKP")a.alg=n;return a}async function Br(e){return Nt(e)}async function kr(e){return _t(e)}async function we(e){return Vt(e)}async function Ft(e,t,r,n){let i=e.slice(0,7),a=await Je(i,r,t,n,new Uint8Array);return{encryptedKey:a.ciphertext,iv:y(a.iv),tag:y(a.tag)}}async function zt(e,t,r,n,i){let a=e.slice(0,7);return Re(a,t,r,n,i,new Uint8Array)}var Xt='Invalid or unsupported "alg" (JWE Algorithm) header value';function Ae(e){if(e===void 0)throw new c("JWE Encrypted Key missing")}async function Yt(e,t,r,n,i){switch(e){case"dir":{if(r!==void 0)throw new c("Encountered unexpected JWE Encrypted Key");return t}case"ECDH-ES":if(r!==void 0)throw new c("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!m(n.epk))throw new c('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(ie(t),!qe(t))throw new d("ECDH with the provided key is not allowed or not supported by your javascript runtime");let a=await Z(n.epk,e);ie(a);let s,o;if(n.apu!==void 0){if(typeof n.apu!=="string")throw new c('JOSE Header "apu" (Agreement PartyUInfo) invalid');s=I(n.apu,"apu",c)}if(n.apv!==void 0){if(typeof n.apv!=="string")throw new c('JOSE Header "apv" (Agreement PartyVInfo) invalid');o=I(n.apv,"apv",c)}let p=await Ye(a,t,e==="ECDH-ES"?n.enc:e,e==="ECDH-ES"?Ie(n.enc):parseInt(e.slice(-5,-2),10),s,o);if(e==="ECDH-ES")return p;return Ae(r),le(e.slice(-6),p,r)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return Ae(r),ie(t),Dt(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(Ae(r),typeof n.p2c!=="number")throw new c('JOSE Header "p2c" (PBES2 Count) missing or invalid');let a=i?.maxPBES2Count||1e4;if(n.p2c>a)throw new c('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof n.p2s!=="string")throw new c('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let s;return s=I(n.p2s,"p2s",c),Wt(e,t,r,n.p2c,s)}case"A128KW":case"A192KW":case"A256KW":return Ae(r),le(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(Ae(r),typeof n.iv!=="string")throw new c('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof n.tag!=="string")throw new c('JOSE Header "tag" (Authentication Tag) missing or invalid');let a;a=I(n.iv,"iv",c);let s;return s=I(n.tag,"tag",c),zt(e,t,r,a,s)}default:throw new d(Xt)}}async function Oe(e,t,r,n,i={}){let a,s,o;switch(e){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(ie(r),!qe(r))throw new d("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:p,apv:u}=i,f;if(i.epk)f=await U(i.epk,e);else f=(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let{x:l,y:E,crv:T,kty:b}=await we(f),A=await Ye(r,f,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Ie(t):parseInt(e.slice(-5,-2),10),p,u);if(s={epk:{x:l,crv:T,kty:b}},b==="EC")s.epk.y=E;if(p)s.apu=y(p);if(u)s.apv=y(u);if(e==="ECDH-ES"){o=A;break}o=n||_(t);let P=e.slice(-6);a=await ye(P,A,o);break}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||_(t),ie(r),a=await Rt(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||_(t);let{p2c:p,p2s:u}=i;({encryptedKey:a,...s}=await Pt(e,r,o,p,u));break}case"A128KW":case"A192KW":case"A256KW":{o=n||_(t),a=await ye(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||_(t);let{iv:p}=i;({encryptedKey:a,...s}=await Ft(e,r,o,p));break}default:throw new d(Xt)}return{cek:o,encryptedKey:a,parameters:s}}function k(e,t,r,n,i){if(i.crit!==void 0&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some((s)=>typeof s!=="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;if(r!==void 0)a=new Map([...Object.entries(r),...t.entries()]);else a=t;for(let s of n.crit){if(!a.has(s))throw new d(`Extension Header Parameter "${s}" is not recognized`);if(i[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&n[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}function Ee(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some((r)=>typeof r!=="string")))throw TypeError(`"${e}" option must be an array of strings`);if(!t)return;return new Set(t)}var ce=(e)=>e?.[Symbol.toStringTag],rt=(e,t,r)=>{if(t.use!==void 0){let n;switch(r){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(t.use!==n)throw TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let n;switch(!0){case(r==="sign"||r==="verify"):case e==="dir":case e.includes("CBC-HS"):n=r;break;case e.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):if(!e.includes("GCM")&&e.endsWith("KW"))n=r==="encrypt"?"wrapKey":"unwrapKey";else n=r;break;case(r==="encrypt"&&e.startsWith("RSA")):n="wrapKey";break;case r==="decrypt":n=e.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&t.key_ops?.includes?.(n)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},$r=(e,t,r)=>{if(t instanceof Uint8Array)return;if(Q(t)){if(bt(t)&&rt(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!me(t))throw TypeError(ze(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(t.type!=="secret")throw TypeError(`${ce(t)} instances for symmetric algorithms must be of type "secret"`)},Gr=(e,t,r)=>{if(Q(t))switch(r){case"decrypt":case"sign":if(At(t)&&rt(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if(Et(t)&&rt(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!me(t))throw TypeError(ze(e,t,"CryptoKey","KeyObject","JSON Web Key"));if(t.type==="secret")throw TypeError(`${ce(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type==="public")switch(r){case"sign":throw TypeError(`${ce(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw TypeError(`${ce(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type==="private")switch(r){case"verify":throw TypeError(`${ce(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw TypeError(`${ce(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function $(e,t,r){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":$r(e,t,r);break;default:Gr(e,t,r)}}function qt(e){if(typeof globalThis[e]>"u")throw new d(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function Qt(e){qt("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],i=t.readable.getReader();for(;;){let{value:a,done:s}=await i.read();if(s)break;n.push(a)}return g(...n)}async function Zt(e,t){qt("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let i=[],a=0,s=r.readable.getReader();for(;;){let{value:o,done:p}=await s.read();if(p)break;if(i.push(o),a+=o.byteLength,t!==1/0&&a>t)throw new c("Decompressed plaintext exceeded the configured limit")}return g(...i)}async function be(e,t,r){if(!m(e))throw new c("Flattened JWE must be an object");if(e.protected===void 0&&e.header===void 0&&e.unprotected===void 0)throw new c("JOSE Header missing");if(e.iv!==void 0&&typeof e.iv!=="string")throw new c("JWE Initialization Vector incorrect type");if(typeof e.ciphertext!=="string")throw new c("JWE Ciphertext missing or incorrect type");if(e.tag!==void 0&&typeof e.tag!=="string")throw new c("JWE Authentication Tag incorrect type");if(e.protected!==void 0&&typeof e.protected!=="string")throw new c("JWE Protected Header incorrect type");if(e.encrypted_key!==void 0&&typeof e.encrypted_key!=="string")throw new c("JWE Encrypted Key incorrect type");if(e.aad!==void 0&&typeof e.aad!=="string")throw new c("JWE AAD incorrect type");if(e.header!==void 0&&!m(e.header))throw new c("JWE Shared Unprotected Header incorrect type");if(e.unprotected!==void 0&&!m(e.unprotected))throw new c("JWE Per-Recipient Unprotected Header incorrect type");let n;if(e.protected)try{let R=W(e.protected);n=JSON.parse(C.decode(R))}catch{throw new c("JWE Protected Header is invalid")}if(!L(n,e.header,e.unprotected))throw new c("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let i={...n,...e.header,...e.unprotected};if(k(c,new Map,r?.crit,n,i),i.zip!==void 0&&i.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(i.zip!==void 0&&!n?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:a,enc:s}=i;if(typeof a!=="string"||!a)throw new c("missing JWE Algorithm (alg) in JWE Header");if(typeof s!=="string"||!s)throw new c("missing JWE Encryption Algorithm (enc) in JWE Header");let o=r&&Ee("keyManagementAlgorithms",r.keyManagementAlgorithms),p=r&&Ee("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(o&&!o.has(a)||!o&&a.startsWith("PBES2"))throw new Y('"alg" (Algorithm) Header Parameter value not allowed');if(p&&!p.has(s))throw new Y('"enc" (Encryption Algorithm) Header Parameter value not allowed');let u;if(e.encrypted_key!==void 0)u=I(e.encrypted_key,"encrypted_key",c);let f=!1;if(typeof t==="function")t=await t(n,e),f=!0;$(a==="dir"?s:a,t,"decrypt");let l=await U(t,a),E;try{E=await Yt(a,l,u,i,r)}catch(R){if(R instanceof TypeError||R instanceof c||R instanceof d)throw R;E=_(s)}let T,b;if(e.iv!==void 0)T=I(e.iv,"iv",c);if(e.tag!==void 0)b=I(e.tag,"tag",c);let A=e.protected!==void 0?w(e.protected):new Uint8Array,P;if(e.aad!==void 0)P=g(A,w("."),w(e.aad));else P=A;let ke=I(e.ciphertext,"ciphertext",c),ct=await Re(s,E,ke,T,b,P),z={plaintext:ct};if(i.zip==="DEF"){let R=r?.maxDecompressedLength??250000;if(R===0)throw new d('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(R!==1/0&&(!Number.isSafeInteger(R)||R<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");z.plaintext=await Zt(ct,R).catch(($e)=>{if($e instanceof c)throw $e;throw new c("Failed to decompress plaintext",{cause:$e})})}if(e.protected!==void 0)z.protectedHeader=n;if(e.aad!==void 0)z.additionalAuthenticatedData=I(e.aad,"aad",c);if(e.unprotected!==void 0)z.sharedUnprotectedHeader=e.unprotected;if(e.header!==void 0)z.unprotectedHeader=e.header;if(f)return{...z,key:l};return z}async function nt(e,t,r){if(e instanceof Uint8Array)e=C.decode(e);if(typeof e!=="string")throw new c("Compact JWE must be a string or Uint8Array");let{0:n,1:i,2:a,3:s,4:o,length:p}=e.split(".");if(p!==5)throw new c("Invalid Compact JWE");let u=await be({ciphertext:s,iv:a||void 0,protected:n,tag:o||void 0,encrypted_key:i||void 0},t,r),f={plaintext:u.plaintext,protectedHeader:u.protectedHeader};if(typeof t==="function")return{...f,key:u.key};return f}async function Vr(e,t,r){if(!m(e))throw new c("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(m))throw new c("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new c("JWE Recipients has no members");for(let n of e.recipients)try{return await be({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch{}throw new V}class j{#e;#t;#r;#n;#a;#s;#o;#i;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this.#e=e}setKeyManagementParameters(e){return S(this.#i,"setKeyManagementParameters"),this.#i=e,this}setProtectedHeader(e){return S(this.#t,"setProtectedHeader"),this.#t=e,this}setSharedUnprotectedHeader(e){return S(this.#r,"setSharedUnprotectedHeader"),this.#r=e,this}setUnprotectedHeader(e){return S(this.#n,"setUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#a=e,this}setContentEncryptionKey(e){return S(this.#s,"setContentEncryptionKey"),this.#s=e,this}setInitializationVector(e){return S(this.#o,"setInitializationVector"),this.#o=e,this}async encrypt(e,t){if(!this.#t&&!this.#n&&!this.#r)throw new c("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!L(this.#t,this.#n,this.#r))throw new c("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let r={...this.#t,...this.#n,...this.#r};if(k(c,new Map,t?.crit,this.#t,r),r.zip!==void 0&&r.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(r.zip!==void 0&&!this.#t?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:n,enc:i}=r;if(typeof n!=="string"||!n)throw new c('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!=="string"||!i)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a;if(this.#s&&(n==="dir"||n==="ECDH-ES"))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${n}`);$(n==="dir"?i:n,e,"encrypt");let s;{let P,ke=await U(e,n);if({cek:s,encryptedKey:a,parameters:P}=await Oe(n,i,ke,this.#s,this.#i),P)if(t&&De in t)if(!this.#n)this.setUnprotectedHeader(P);else this.#n={...this.#n,...P};else if(!this.#t)this.setProtectedHeader(P);else this.#t={...this.#t,...P}}let o,p,u,f;if(this.#t)p=y(JSON.stringify(this.#t)),u=w(p);else p="",u=new Uint8Array;if(this.#a){f=y(this.#a);let P=w(f);o=g(u,w("."),P)}else o=u;let l=this.#e;if(r.zip==="DEF")l=await Qt(l).catch((P)=>{throw new c("Failed to compress plaintext",{cause:P})});let{ciphertext:E,tag:T,iv:b}=await Je(i,l,s,this.#o,o),A={ciphertext:y(E)};if(b)A.iv=y(b);if(T)A.tag=y(T);if(a)A.encrypted_key=y(a);if(f)A.aad=f;if(this.#t)A.protected=p;if(this.#r)A.unprotected=this.#r;if(this.#n)A.header=this.#n;return A}}class jt{#e;unprotectedHeader;keyManagementParameters;key;options;constructor(e,t,r){this.#e=e,this.key=t,this.options=r}setUnprotectedHeader(e){return S(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=e,this}setKeyManagementParameters(e){return S(this.keyManagementParameters,"setKeyManagementParameters"),this.keyManagementParameters=e,this}addRecipient(...e){return this.#e.addRecipient(...e)}encrypt(...e){return this.#e.encrypt(...e)}done(){return this.#e}}class er{#e;#t=[];#r;#n;#a;constructor(e){this.#e=e}addRecipient(e,t){let r=new jt(this,e,{crit:t?.crit});return this.#t.push(r),r}setProtectedHeader(e){return S(this.#r,"setProtectedHeader"),this.#r=e,this}setSharedUnprotectedHeader(e){return S(this.#n,"setSharedUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#a=e,this}async encrypt(){if(!this.#t.length)throw new c("at least one recipient must be added");if(this.#t.length===1){let[n]=this.#t,i=await new j(this.#e).setAdditionalAuthenticatedData(this.#a).setProtectedHeader(this.#r).setSharedUnprotectedHeader(this.#n).setUnprotectedHeader(n.unprotectedHeader).encrypt(n.key,{...n.options}),a={ciphertext:i.ciphertext,iv:i.iv,recipients:[{}],tag:i.tag};if(i.aad)a.aad=i.aad;if(i.protected)a.protected=i.protected;if(i.unprotected)a.unprotected=i.unprotected;if(i.encrypted_key)a.recipients[0].encrypted_key=i.encrypted_key;if(i.header)a.recipients[0].header=i.header;return a}let e;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];if(!L(this.#r,this.#n,i.unprotectedHeader))throw new c("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let a={...this.#r,...this.#n,...i.unprotectedHeader},{alg:s}=a;if(typeof s!=="string"||!s)throw new c('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(s==="dir"||s==="ECDH-ES")throw new c('"dir" and "ECDH-ES" alg may only be used with a single recipient');if(typeof a.enc!=="string"||!a.enc)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(!e)e=a.enc;else if(e!==a.enc)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');if(k(c,new Map,i.options.crit,this.#r,a),a.zip!==void 0&&a.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(a.zip!==void 0&&!this.#r?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}let t=_(e),r={ciphertext:"",recipients:[]};for(let n=0;n<this.#t.length;n++){let i=this.#t[n],a={};if(r.recipients.push(a),n===0){let f=await new j(this.#e).setAdditionalAuthenticatedData(this.#a).setContentEncryptionKey(t).setProtectedHeader(this.#r).setSharedUnprotectedHeader(this.#n).setUnprotectedHeader(i.unprotectedHeader).setKeyManagementParameters(i.keyManagementParameters).encrypt(i.key,{...i.options,[De]:!0});if(r.ciphertext=f.ciphertext,r.iv=f.iv,r.tag=f.tag,f.aad)r.aad=f.aad;if(f.protected)r.protected=f.protected;if(f.unprotected)r.unprotected=f.unprotected;if(a.encrypted_key=f.encrypted_key,f.header)a.header=f.header;continue}let s=i.unprotectedHeader?.alg||this.#r?.alg||this.#n?.alg;$(s==="dir"?e:s,i.key,"encrypt");let o=await U(i.key,s),{encryptedKey:p,parameters:u}=await Oe(s,e,o,t,i.keyManagementParameters);if(a.encrypted_key=y(p),i.unprotectedHeader||u)a.header={...i.unprotectedHeader,...u}}return r}}async function ge(e,t,r){if(!m(e))throw new h("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new h('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!=="string")throw new h("JWS Protected Header incorrect type");if(e.payload===void 0)throw new h("JWS Payload missing");if(typeof e.signature!=="string")throw new h("JWS Signature missing or incorrect type");if(e.header!==void 0&&!m(e.header))throw new h("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{let P=W(e.protected);n=JSON.parse(C.decode(P))}catch{throw new h("JWS Protected Header is invalid")}if(!L(n,e.header))throw new h("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...n,...e.header},a=k(h,new Map([["b64",!0]]),r?.crit,n,i),s=!0;if(a.has("b64")){if(s=n.b64,typeof s!=="boolean")throw new h('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}let{alg:o}=i;if(typeof o!=="string"||!o)throw new h('JWS "alg" (Algorithm) Header Parameter missing or invalid');let p=r&&Ee("algorithms",r.algorithms);if(p&&!p.has(o))throw new Y('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof e.payload!=="string")throw new h("JWS Payload must be a string")}else if(typeof e.payload!=="string"&&!(e.payload instanceof Uint8Array))throw new h("JWS Payload must be a string or an Uint8Array instance");let u=!1;if(typeof t==="function")t=await t(n,e),u=!0;$(o,t,"verify");let f=g(e.protected!==void 0?w(e.protected):new Uint8Array,w("."),typeof e.payload==="string"?s?w(e.payload):X.encode(e.payload):e.payload),l=I(e.signature,"signature",h),E=await U(t,o);if(!await It(o,E,l,f))throw new ne;let b;if(s)b=I(e.payload,"payload",h);else if(typeof e.payload==="string")b=X.encode(e.payload);else b=e.payload;let A={payload:b};if(e.protected!==void 0)A.protectedHeader=n;if(e.header!==void 0)A.unprotectedHeader=e.header;if(u)return{...A,key:E};return A}async function it(e,t,r){if(e instanceof Uint8Array)e=C.decode(e);if(typeof e!=="string")throw new h("Compact JWS must be a string or Uint8Array");let{0:n,1:i,2:a,length:s}=e.split(".");if(s!==3)throw new h("Invalid Compact JWS");let o=await ge({payload:i,protected:n,signature:a},t,r),p={payload:o.payload,protectedHeader:o.protectedHeader};if(typeof t==="function")return{...p,key:o.key};return p}async function Fr(e,t,r){if(!m(e))throw new h("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(m))throw new h("JWS Signatures missing or incorrect type");for(let n of e.signatures)try{return await ge({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new ne}var F=(e)=>Math.floor(e.getTime()/1000),rr=60,nr=rr*60,at=nr*24,zr=at*7,Xr=at*365.25,Yr=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Ke(e){let t=Yr.exec(e);if(!t||t[4]&&t[1])throw TypeError("Invalid time period format");let r=parseFloat(t[2]),n=t[3].toLowerCase(),i;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":i=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":i=Math.round(r*rr);break;case"hour":case"hours":case"hr":case"hrs":case"h":i=Math.round(r*nr);break;case"day":case"days":case"d":i=Math.round(r*at);break;case"week":case"weeks":case"w":i=Math.round(r*zr);break;default:i=Math.round(r*Xr);break}if(t[1]==="-"||t[4]==="ago")return-i;return i}function ee(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}var tr=(e)=>{if(e.includes("/"))return e.toLowerCase();return`application/${e.toLowerCase()}`},qr=(e,t)=>{if(typeof e==="string")return t.includes(e);if(Array.isArray(e))return t.some(Set.prototype.has.bind(new Set(e)));return!1};function pe(e,t,r={}){let n;try{n=JSON.parse(C.decode(t))}catch{}if(!m(n))throw new K("JWT Claims Set must be a top-level JSON object");let{typ:i}=r;if(i&&(typeof e.typ!=="string"||tr(e.typ)!==tr(i)))throw new H('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:a=[],issuer:s,subject:o,audience:p,maxTokenAge:u}=r,f=[...a];if(u!==void 0)f.push("iat");if(p!==void 0)f.push("aud");if(o!==void 0)f.push("sub");if(s!==void 0)f.push("iss");for(let b of new Set(f.reverse()))if(!(b in n))throw new H(`missing required "${b}" claim`,n,b,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new H('unexpected "iss" claim value',n,"iss","check_failed");if(o&&n.sub!==o)throw new H('unexpected "sub" claim value',n,"sub","check_failed");if(p&&!qr(n.aud,typeof p==="string"?[p]:p))throw new H('unexpected "aud" claim value',n,"aud","check_failed");let l;switch(typeof r.clockTolerance){case"string":l=Ke(r.clockTolerance);break;case"number":l=r.clockTolerance;break;case"undefined":l=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:E}=r,T=F(E||new Date);if((n.iat!==void 0||u)&&typeof n.iat!=="number")throw new H('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!=="number")throw new H('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>T+l)throw new H('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!=="number")throw new H('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=T-l)throw new fe('"exp" claim timestamp check failed',n,"exp","check_failed")}if(u){let b=T-n.iat,A=typeof u==="number"?u:Ke(u);if(b-l>A)throw new fe('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(b<0-l)throw new H('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}class te{#e;constructor(e){if(!m(e))throw TypeError("JWT Claims Set MUST be an object");this.#e=structuredClone(e)}data(){return X.encode(JSON.stringify(this.#e))}get iss(){return this.#e.iss}set iss(e){this.#e.iss=e}get sub(){return this.#e.sub}set sub(e){this.#e.sub=e}get aud(){return this.#e.aud}set aud(e){this.#e.aud=e}set jti(e){this.#e.jti=e}set nbf(e){if(typeof e==="number")this.#e.nbf=ee("setNotBefore",e);else if(e instanceof Date)this.#e.nbf=ee("setNotBefore",F(e));else this.#e.nbf=F(new Date)+Ke(e)}set exp(e){if(typeof e==="number")this.#e.exp=ee("setExpirationTime",e);else if(e instanceof Date)this.#e.exp=ee("setExpirationTime",F(e));else this.#e.exp=F(new Date)+Ke(e)}set iat(e){if(e===void 0)this.#e.iat=F(new Date);else if(e instanceof Date)this.#e.iat=ee("setIssuedAt",F(e));else if(typeof e==="string")this.#e.iat=ee("setIssuedAt",F(new Date)+Ke(e));else this.#e.iat=ee("setIssuedAt",e)}}async function Qr(e,t,r){let n=await it(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new K("JWTs MUST NOT use unencoded payload");let a={payload:pe(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};if(typeof t==="function")return{...a,key:n.key};return a}async function Zr(e,t,r){let n=await nt(e,t,r),i=pe(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(a.iss!==void 0&&a.iss!==i.iss)throw new H('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(a.sub!==void 0&&a.sub!==i.sub)throw new H('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(a.aud!==void 0&&JSON.stringify(a.aud)!==JSON.stringify(i.aud))throw new H('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let s={payload:i,protectedHeader:a};if(typeof t==="function")return{...s,key:n.key};return s}class Ne{#e;constructor(e){this.#e=new j(e)}setContentEncryptionKey(e){return this.#e.setContentEncryptionKey(e),this}setInitializationVector(e){return this.#e.setInitializationVector(e),this}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}setKeyManagementParameters(e){return this.#e.setKeyManagementParameters(e),this}async encrypt(e,t){let r=await this.#e.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}class ue{#e;#t;#r;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this.#e=e}setProtectedHeader(e){return S(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return S(this.#r,"setUnprotectedHeader"),this.#r=e,this}async sign(e,t){if(!this.#t&&!this.#r)throw new h("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!L(this.#t,this.#r))throw new h("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let r={...this.#t,...this.#r},n=k(h,new Map([["b64",!0]]),t?.crit,this.#t,r),i=!0;if(n.has("b64")){if(i=this.#t.b64,typeof i!=="boolean")throw new h('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}let{alg:a}=r;if(typeof a!=="string"||!a)throw new h('JWS "alg" (Algorithm) Header Parameter missing or invalid');$(a,e,"sign");let s,o;if(i)s=y(this.#e),o=w(s);else o=this.#e,s="";let p,u;if(this.#t)p=y(JSON.stringify(this.#t)),u=w(p);else p="",u=new Uint8Array;let f=g(u,w("."),o),l=await U(e,a),E=await vt(a,l,f),T={signature:y(E),payload:s};if(this.#r)T.header=this.#r;if(this.#t)T.protected=p;return T}}class _e{#e;constructor(e){this.#e=new ue(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}async sign(e,t){let r=await this.#e.sign(e,t);if(r.payload===void 0)throw TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class ir{#e;protectedHeader;unprotectedHeader;options;key;constructor(e,t,r){this.#e=e,this.key=t,this.options=r}setProtectedHeader(e){return S(this.protectedHeader,"setProtectedHeader"),this.protectedHeader=e,this}setUnprotectedHeader(e){return S(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=e,this}addSignature(...e){return this.#e.addSignature(...e)}sign(...e){return this.#e.sign(...e)}done(){return this.#e}}class ar{#e;#t=[];constructor(e){this.#e=e}addSignature(e,t){let r=new ir(this,e,t);return this.#t.push(r),r}async sign(){if(!this.#t.length)throw new h("at least one signature must be added");let e={signatures:[],payload:""};for(let t=0;t<this.#t.length;t++){let r=this.#t[t],n=new ue(this.#e);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);let{payload:i,...a}=await n.sign(r.key,r.options);if(t===0)e.payload=i;else if(e.payload!==i)throw new h("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(a)}return e}}class sr{#e;#t;constructor(e={}){this.#t=new te(e)}setIssuer(e){return this.#t.iss=e,this}setSubject(e){return this.#t.sub=e,this}setAudience(e){return this.#t.aud=e,this}setJti(e){return this.#t.jti=e,this}setNotBefore(e){return this.#t.nbf=e,this}setExpirationTime(e){return this.#t.exp=e,this}setIssuedAt(e){return this.#t.iat=e,this}setProtectedHeader(e){return this.#e=e,this}async sign(e,t){let r=new _e(this.#t.data());if(r.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes("b64")&&this.#e.b64===!1)throw new K("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}class or{#e;#t;#r;#n;#a;#s;#o;#i;constructor(e={}){this.#i=new te(e)}setIssuer(e){return this.#i.iss=e,this}setSubject(e){return this.#i.sub=e,this}setAudience(e){return this.#i.aud=e,this}setJti(e){return this.#i.jti=e,this}setNotBefore(e){return this.#i.nbf=e,this}setExpirationTime(e){return this.#i.exp=e,this}setIssuedAt(e){return this.#i.iat=e,this}setProtectedHeader(e){return S(this.#n,"setProtectedHeader"),this.#n=e,this}setKeyManagementParameters(e){return S(this.#r,"setKeyManagementParameters"),this.#r=e,this}setContentEncryptionKey(e){return S(this.#e,"setContentEncryptionKey"),this.#e=e,this}setInitializationVector(e){return S(this.#t,"setInitializationVector"),this.#t=e,this}replicateIssuerAsHeader(){return this.#a=!0,this}replicateSubjectAsHeader(){return this.#s=!0,this}replicateAudienceAsHeader(){return this.#o=!0,this}async encrypt(e,t){let r=new Ne(this.#i.data());if(this.#n&&(this.#a||this.#s||this.#o))this.#n={...this.#n,iss:this.#a?this.#i.iss:void 0,sub:this.#s?this.#i.sub:void 0,aud:this.#o?this.#i.aud:void 0};if(r.setProtectedHeader(this.#n),this.#t)r.setInitializationVector(this.#t);if(this.#e)r.setContentEncryptionKey(this.#e);if(this.#r)r.setKeyManagementParameters(this.#r);return r.encrypt(e,t)}}var G=(e,t)=>{if(typeof e!=="string"||!e)throw new We(`${t} missing or invalid`)};async function cr(e,t){let r;if(Q(e))r=e;else if(me(e))r=await we(e);else throw TypeError(D(e,"CryptoKey","KeyObject","JSON Web Key"));if(t??="sha256",t!=="sha256"&&t!=="sha384"&&t!=="sha512")throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let n;switch(r.kty){case"AKP":G(r.alg,'"alg" (Algorithm) Parameter'),G(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":G(r.crv,'"crv" (Curve) Parameter'),G(r.x,'"x" (X Coordinate) Parameter'),G(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":G(r.crv,'"crv" (Subtype of Key Pair) Parameter'),G(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":G(r.e,'"e" (Exponent) Parameter'),G(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":G(r.k,'"k" (Key Value) Parameter'),n={k:r.k,kty:r.kty};break;default:throw new d('"kty" (Key Type) Parameter missing or unsupported')}let i=w(JSON.stringify(n));return y(await Ue(t,i))}async function jr(e,t){t??="sha256";let r=await cr(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function en(e,t){let r={...e,...t?.header};if(!m(r.jwk))throw new h('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let n=await Z({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||n.type!=="public")throw new h('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function tn(e){switch(typeof e==="string"&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";case"ML":return"AKP";default:throw new d('Unsupported "alg" value for a JSON Web Key Set')}}function rn(e){return e&&typeof e==="object"&&Array.isArray(e.keys)&&e.keys.every(nn)}function nn(e){return m(e)}class ur{#e;#t=new WeakMap;constructor(e){if(!rn(e))throw new he("JSON Web Key Set malformed");this.#e=structuredClone(e)}jwks(){return this.#e}async getKey(e,t){let{alg:r,kid:n}={...e,...t?.header},i=tn(r),a=this.#e.keys.filter((p)=>{let u=i===p.kty;if(u&&typeof n==="string")u=n===p.kid;if(u&&(typeof p.alg==="string"||i==="AKP"))u=r===p.alg;if(u&&typeof p.use==="string")u=p.use==="sig";if(u&&Array.isArray(p.key_ops))u=p.key_ops.includes("verify");if(u)switch(r){case"ES256":u=p.crv==="P-256";break;case"ES384":u=p.crv==="P-384";break;case"ES512":u=p.crv==="P-521";break;case"Ed25519":case"EdDSA":u=p.crv==="Ed25519";break}return u}),{0:s,length:o}=a;if(o===0)throw new re;if(o!==1){let p=new He,u=this.#t;throw p[Symbol.asyncIterator]=async function*(){for(let f of a)try{yield await pr(u,f,r)}catch{}},p}return pr(this.#t,s,r)}}async function pr(e,t,r){let n=e.get(t)||e.set(t,{}).get(t);if(n[r]===void 0){let i=await Z({...t,ext:!0},r);if(i instanceof Uint8Array||i.type!=="public")throw new he("JSON Web Key Set members must be public keys");n[r]=i}return n[r]}function Le(e){let t=new ur(e),r=async(n,i)=>t.getKey(n,i);return Object.defineProperties(r,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),r}function an(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var st;if(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))st="jose/v6.2.3";var dr=Symbol();async function sn(e,t,r,n=fetch){let i=await n(e,{method:"GET",signal:r,redirect:"manual",headers:t}).catch((a)=>{if(a.name==="TimeoutError")throw new Te;throw a});if(i.status!==200)throw new x("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new x("Failed to parse the JSON Web Key Set HTTP response as JSON")}}var Be=Symbol();function on(e,t){if(typeof e!=="object"||e===null)return!1;if(!("uat"in e)||typeof e.uat!=="number"||Date.now()-e.uat>=t)return!1;if(!("jwks"in e)||!m(e.jwks)||!Array.isArray(e.jwks.keys)||!Array.prototype.every.call(e.jwks.keys,m))return!1;return!0}class fr{#e;#t;#r;#n;#a;#s;#o;#i;#c;#p;constructor(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");if(this.#e=new URL(e.href),this.#t=typeof t?.timeoutDuration==="number"?t?.timeoutDuration:5000,this.#r=typeof t?.cooldownDuration==="number"?t?.cooldownDuration:30000,this.#n=typeof t?.cacheMaxAge==="number"?t?.cacheMaxAge:600000,this.#o=new Headers(t?.headers),st&&!this.#o.has("User-Agent"))this.#o.set("User-Agent",st);if(!this.#o.has("accept"))this.#o.set("accept","application/json"),this.#o.append("accept","application/jwk-set+json");if(this.#i=t?.[dr],t?.[Be]!==void 0){if(this.#p=t?.[Be],on(t?.[Be],this.#n))this.#a=this.#p.uat,this.#c=Le(this.#p.jwks)}}pendingFetch(){return!!this.#s}coolingDown(){return typeof this.#a==="number"?Date.now()<this.#a+this.#r:!1}fresh(){return typeof this.#a==="number"?Date.now()<this.#a+this.#n:!1}jwks(){return this.#c?.jwks()}async getKey(e,t){if(!this.#c||!this.fresh())await this.reload();try{return await this.#c(e,t)}catch(r){if(r instanceof re){if(this.coolingDown()===!1)return await this.reload(),this.#c(e,t)}throw r}}async reload(){if(this.#s&&an())this.#s=void 0;this.#s||=sn(this.#e.href,this.#o,AbortSignal.timeout(this.#t),this.#i).then((e)=>{if(this.#c=Le(e),this.#p)this.#p.uat=Date.now(),this.#p.jwks=e;this.#a=Date.now(),this.#s=void 0}).catch((e)=>{throw this.#s=void 0,e}),await this.#s}}function cn(e,t){let r=new fr(e,t),n=async(i,a)=>r.getKey(i,a);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>r.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>r.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}class hr{#e;constructor(e={}){this.#e=new te(e)}encode(){let e=y(JSON.stringify({alg:"none"})),t=y(this.#e.data());return`${e}.${t}.`}setIssuer(e){return this.#e.iss=e,this}setSubject(e){return this.#e.sub=e,this}setAudience(e){return this.#e.aud=e,this}setJti(e){return this.#e.jti=e,this}setNotBefore(e){return this.#e.nbf=e,this}setExpirationTime(e){return this.#e.exp=e,this}setIssuedAt(e){return this.#e.iat=e,this}static decode(e,t){if(typeof e!=="string")throw new K("Unsecured JWT must be a string");let{0:r,1:n,2:i,length:a}=e.split(".");if(a!==3||i!=="")throw new K("Invalid Unsecured JWT");let s;try{if(s=JSON.parse(C.decode(W(r))),s.alg!=="none")throw Error()}catch{throw new K("Invalid Unsecured JWT")}return{payload:pe(s,W(n),t),header:s}}}function pn(e){let t;if(typeof e==="string"){let r=e.split(".");if(r.length===3||r.length===5)[t]=r}else if(typeof e==="object"&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");try{if(typeof t!=="string"||!t)throw Error();let r=JSON.parse(C.decode(W(t)));if(!m(r))throw Error();return r}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function un(e){if(typeof e!=="string")throw new K("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new K("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new K("Invalid JWT");if(!t)throw new K("JWTs must contain a payload");let n;try{n=W(t)}catch{throw new K("Failed to base64url decode the payload")}let i;try{i=JSON.parse(C.decode(n))}catch{throw new K("Failed to parse the decoded payload as JSON")}if(!m(i))throw new K("Invalid JWT Claims Set");return i}function ot(e){let t=e?.modulusLength??2048;if(typeof t!=="number"||t<2048)throw new d("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function dn(e,t){let r,n;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"Ed25519":case"EdDSA":{n=["sign","verify"],r={name:"Ed25519"};break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{n=["sign","verify"],r={name:e};break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveBits"];let i=t?.crv??"P-256";switch(i){case"P-256":case"P-384":case"P-521":{r={name:"ECDH",namedCurve:i};break}case"X25519":r={name:"X25519"};break;default:throw new d("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}break}default:throw new d('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(r,t?.extractable??!1,n)}async function fn(e,t){let r,n,i;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),n={name:"HMAC",hash:`SHA-${r}`,length:r},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(e.slice(-3),10),crypto.getRandomValues(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(e.slice(1,4),10),n={name:"AES-KW",length:r},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10),n={name:"AES-GCM",length:r},i=["encrypt","decrypt"];break;default:throw new d('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(n,t?.extractable??!1,i)}var wo="WebCryptoAPI";
6
- export{Fe as Le,fe as Me,ht as Ne,Nr as Oe,_r as Pe,Lr as Qe,Z as Re,Br as Se,kr as Te,we as Ue,be as Ve,nt as We,Vr as Xe,j as Ye,er as Ze,ge as _e,it as $e,Fr as af,Qr as bf,Zr as cf,Ne as df,ue as ef,_e as ff,ar as gf,sr as hf,or as if,cr as jf,jr as kf,en as lf,Le as mf,dr as nf,Be as of,cn as pf,hr as qf,pn as rf,un as sf,dn as tf,fn as uf,wo as vf};
6
+ export{Fe as Zd,fe as _d,ht as $d,Nr as ae,_r as be,Lr as ce,Z as de,Br as ee,kr as fe,we as ge,be as he,nt as ie,Vr as je,j as ke,er as le,ge as me,it as ne,Fr as oe,Qr as pe,Zr as qe,Ne as re,ue as se,_e as te,ar as ue,sr as ve,or as we,cr as xe,jr as ye,en as ze,Le as Ae,dr as Be,Be as Ce,cn as De,hr as Ee,pn as Fe,un as Ge,dn as He,fn as Ie,wo as Je};
@@ -0,0 +1 @@
1
+ import{n as x}from"./chunk-ddt5224b.js";import"./chunk-zwny8t7c.js";import"./chunk-0rydta2q.js";import"./chunk-7zvv37z0.js";import"./chunk-7w01v7bw.js";import"./chunk-hk5pwxhf.js";import"./chunk-5ex69zt3.js";import"./chunk-wzw7rrfy.js";import"./chunk-n3e4agsa.js";import"./chunk-yvknqnkb.js";import"./chunk-ptmxkptc.js";import"./chunk-p2wyyvfa.js";import"./chunk-eekmnfn4.js";import"./chunk-r7crhkhn.js";import"./chunk-px660tvj.js";import"./chunk-a6s80m0k.js";import"./chunk-q3y6kdkh.js";import"./chunk-ar79dg9g.js";import{Ue as f}from"./chunk-bdwtaj3w.js";import{jf as p}from"./chunk-nn753fbs.js";import"./chunk-c4yr75hy.js";import"./chunk-4yp5add5.js";import"./chunk-4st1t79p.js";import"./chunk-mffjg6zb.js";import"./chunk-3h4t28zz.js";import"./chunk-qt6j0fm6.js";import"./chunk-nc9hbzad.js";import"./chunk-z8s40zfa.js";import"./chunk-zcxajg6j.js";import"./chunk-vhcsdnzv.js";import"./chunk-03ec6p4p.js";import"./chunk-331s5eb9.js";import"./chunk-tn24as5d.js";import"./chunk-naaa5ejw.js";import{Hh as h}from"./chunk-8qryr65z.js";import{Lh as w,Nh as a,Sh as l,Th as r,di as o,pi as c}from"./chunk-5ctpz542.js";import{nm as m}from"./chunk-j4byth37.js";var g=m(w(),1);function v(){let{projectId:e}=d.useParams(),{teamId:s,ensureTeamIdForProject:n}=h();g.useEffect(()=>{n(e)},[e,n]);let{data:i}=r(f(e)),t=i?.rootFolder,{data:b}=l({queryKey:["folders",t],queryFn:()=>(async()=>{return await(await c.api.folders[":folderId"].$get({param:{folderId:t}})).json()})(),enabled:!!t});if(!s||!t||!b)return a(p,{});return a(x,{teamId:s,projectId:e,projectName:i.name??"",assetId:"recently-deleted",rootFolderId:t})}var d=o("/projects/$projectId/recently-deleted")({component:v});export{d as Route};
@@ -0,0 +1,2 @@
1
+ import{$ as p,_ as o,aa as r,ca as x,da as $0,ka as F5,la as d0}from"./chunk-n3e4agsa.js";import{xa as u0}from"./chunk-q3y6kdkh.js";import{Pf as o0,Qf as k5,Rf as V5}from"./chunk-mffjg6zb.js";import{Hg as P5,wg as _5,xg as m5,yg as U5}from"./chunk-z8s40zfa.js";import{Vg as W0}from"./chunk-331s5eb9.js";import{Xg as R0,Yg as b,bh as S2,gh as G0,lh as G2}from"./chunk-tn24as5d.js";import{sh as U0,th as P0,uh as k0}from"./chunk-naaa5ejw.js";import{vh as W5,xh as z5,yh as M5,zh as w5}from"./chunk-8qryr65z.js";import{$i as y2,$j as Q0,Dk as G5,Ei as c0,Ek as B5,Gi as N5,Ik as w0,Kj as Y5,Lh as h,Nh as X,Oh as H,Ph as $5,Pi as u2,Ti as n0,Uh as W2,Wi as J5,Yi as i0,Zi as z0,_i as x2,_k as f0,dl as V0,fj as v2,fl as i,ii as v0,ik as M0,il as m,ji as f2,jl as i2,kk as K5,kl as o2,ll as p2,ml as r2,ni as m0,ol as s2,pi as u,pl as a2,qk as h0,ql as O0,sk as q5,uj as Z5,uk as Q5,vi as B2,vj as X5,wk as H5}from"./chunk-5ctpz542.js";import{nm as j}from"./chunk-j4byth37.js";function g5($){let N=$.lastIndexOf(".");if(N>0)return[0,N];return[0,$.length]}function B1($){$.focus();let[N,J]=g5($.value);if(typeof $.setSelectionRange==="function")$.setSelectionRange(N,J);else $.select()}var V2=Symbol.for("immer-nothing"),w2=Symbol.for("immer-draftable"),v=Symbol.for("immer-state");function d($,...N){throw Error(`[Immer] minified error nr: ${$}. Full error at: https://bit.ly/3cXEKWf`)}var F0=Object.getPrototypeOf;function H0($){return!!$&&!!$[v]}function Y0($){if(!$)return!1;return F2($)||Array.isArray($)||!!$[w2]||!!$.constructor?.[w2]||A0($)||x0($)}var S5=Object.prototype.constructor.toString(),_2=new WeakMap;function F2($){if(!$||typeof $!=="object")return!1;let N=Object.getPrototypeOf($);if(N===null||N===Object.prototype)return!0;let J=Object.hasOwnProperty.call(N,"constructor")&&N.constructor;if(J===Object)return!0;if(typeof J!=="function")return!1;let Z=_2.get(J);if(Z===void 0)Z=Function.toString.call(J),_2.set(J,Z);return Z===S5}function S0($,N,J=!0){if(b0($)===0)(J?Reflect.ownKeys($):Object.keys($)).forEach((Y)=>{N(Y,$[Y],$)});else $.forEach((Z,Y)=>N(Y,Z,$))}function b0($){let N=$[v];return N?N.type_:Array.isArray($)?1:A0($)?2:x0($)?3:0}function a0($,N){return b0($)===2?$.has(N):Object.prototype.hasOwnProperty.call($,N)}function L2($,N,J){let Z=b0($);if(Z===2)$.set(N,J);else if(Z===3)$.add(J);else $[N]=J}function T5($,N){if($===N)return $!==0||1/$===1/N;else return $!==$&&N!==N}function A0($){return $ instanceof Map}function x0($){return $ instanceof Set}function X0($){return $.copy_||$.base_}function t0($,N){if(A0($))return new Map($);if(x0($))return new Set($);if(Array.isArray($))return Array.prototype.slice.call($);let J=F2($);if(N===!0||N==="class_only"&&!J){let Z=Object.getOwnPropertyDescriptors($);delete Z[v];let Y=Reflect.ownKeys(Z);for(let q=0;q<Y.length;q++){let K=Y[q],Q=Z[K];if(Q.writable===!1)Q.writable=!0,Q.configurable=!0;if(Q.get||Q.set)Z[K]={configurable:!0,writable:!0,enumerable:Q.enumerable,value:$[K]}}return Object.create(F0($),Z)}else{let Z=F0($);if(Z!==null&&J)return{...$};let Y=Object.create(Z);return Object.assign(Y,$)}}function Z2($,N=!1){if(y0($)||H0($)||!Y0($))return $;if(b0($)>1)Object.defineProperties($,{set:g0,add:g0,clear:g0,delete:g0});if(Object.freeze($),N)Object.values($).forEach((J)=>Z2(J,!0));return $}function E5(){d(2)}var g0={value:E5};function y0($){if($===null||typeof $!=="object")return!0;return Object.isFrozen($)}var b5={};function K0($){let N=b5[$];if(!N)d(0,$);return N}var L0;function C2(){return L0}function x5($,N){return{drafts_:[],parent_:$,immer_:N,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function m2($,N){if(N)K0("Patches"),$.patches_=[],$.inversePatches_=[],$.patchListener_=N}function e0($){$2($),$.drafts_.forEach(y5),$.drafts_=null}function $2($){if($===L0)L0=$.parent_}function U2($){return L0=x5(L0,$)}function y5($){let N=$[v];if(N.type_===0||N.type_===1)N.revoke_();else N.revoked_=!0}function P2($,N){N.unfinalizedDrafts_=N.drafts_.length;let J=N.drafts_[0];if($!==void 0&&$!==J){if(J[v].modified_)e0(N),d(4);if(Y0($)){if($=T0(N,$),!N.parent_)E0(N,$)}if(N.patches_)K0("Patches").generateReplacementPatches_(J[v].base_,$,N.patches_,N.inversePatches_)}else $=T0(N,J,[]);if(e0(N),N.patches_)N.patchListener_(N.patches_,N.inversePatches_);return $!==V2?$:void 0}function T0($,N,J){if(y0(N))return N;let Z=$.immer_.shouldUseStrictIteration(),Y=N[v];if(!Y)return S0(N,(q,K)=>k2($,Y,N,q,K,J),Z),N;if(Y.scope_!==$)return N;if(!Y.modified_)return E0($,Y.base_,!0),Y.base_;if(!Y.finalized_){Y.finalized_=!0,Y.scope_.unfinalizedDrafts_--;let q=Y.copy_,K=q,Q=!1;if(Y.type_===3)K=new Set(q),q.clear(),Q=!0;if(S0(K,(W,z)=>k2($,Y,q,W,z,J,Q),Z),E0($,q,!1),J&&$.patches_)K0("Patches").generatePatches_(Y,J,$.patches_,$.inversePatches_)}return Y.copy_}function k2($,N,J,Z,Y,q,K){if(Y==null)return;if(typeof Y!=="object"&&!K)return;let Q=y0(Y);if(Q&&!K)return;if(H0(Y)){let W=q&&N&&N.type_!==3&&!a0(N.assigned_,Z)?q.concat(Z):void 0,z=T0($,Y,W);if(L2(J,Z,z),H0(z))$.canAutoFreeze_=!1;else return}else if(K)J.add(Y);if(Y0(Y)&&!Q){if(!$.immer_.autoFreeze_&&$.unfinalizedDrafts_<1)return;if(N&&N.base_&&N.base_[Z]===Y&&Q)return;if(T0($,Y),(!N||!N.scope_.parent_)&&typeof Z!=="symbol"&&(A0(J)?J.has(Z):Object.prototype.propertyIsEnumerable.call(J,Z)))E0($,Y)}}function E0($,N,J=!1){if(!$.parent_&&$.immer_.autoFreeze_&&$.canAutoFreeze_)Z2(N,J)}function v5($,N){let J=Array.isArray($),Z={type_:J?1:0,scope_:N?N.scope_:C2(),modified_:!1,finalized_:!1,assigned_:{},parent_:N,base_:$,draft_:null,copy_:null,revoke_:null,isManual_:!1},Y=Z,q=X2;if(J)Y=[Z],q=C0;let{revoke:K,proxy:Q}=Proxy.revocable(Y,q);return Z.draft_=Q,Z.revoke_=K,Q}var X2={get($,N){if(N===v)return $;let J=X0($);if(!a0(J,N))return D5($,J,N);let Z=J[N];if($.finalized_||!Y0(Z))return Z;if(Z===r0($.base_,N))return s0($),$.copy_[N]=J2(Z,$);return Z},has($,N){return N in X0($)},ownKeys($){return Reflect.ownKeys(X0($))},set($,N,J){let Z=A2(X0($),N);if(Z?.set)return Z.set.call($.draft_,J),!0;if(!$.modified_){let Y=r0(X0($),N),q=Y?.[v];if(q&&q.base_===J)return $.copy_[N]=J,$.assigned_[N]=!1,!0;if(T5(J,Y)&&(J!==void 0||a0($.base_,N)))return!0;s0($),N2($)}if($.copy_[N]===J&&(J!==void 0||(N in $.copy_))||Number.isNaN(J)&&Number.isNaN($.copy_[N]))return!0;return $.copy_[N]=J,$.assigned_[N]=!0,!0},deleteProperty($,N){if(r0($.base_,N)!==void 0||N in $.base_)$.assigned_[N]=!1,s0($),N2($);else delete $.assigned_[N];if($.copy_)delete $.copy_[N];return!0},getOwnPropertyDescriptor($,N){let J=X0($),Z=Reflect.getOwnPropertyDescriptor(J,N);if(!Z)return Z;return{writable:!0,configurable:$.type_!==1||N!=="length",enumerable:Z.enumerable,value:J[N]}},defineProperty(){d(11)},getPrototypeOf($){return F0($.base_)},setPrototypeOf(){d(12)}},C0={};S0(X2,($,N)=>{C0[$]=function(){return arguments[0]=arguments[0][0],N.apply(this,arguments)}});C0.deleteProperty=function($,N){return C0.set.call(this,$,N,void 0)};C0.set=function($,N,J){return X2.set.call(this,$[0],N,J,$[0])};function r0($,N){let J=$[v];return(J?X0(J):$)[N]}function D5($,N,J){let Z=A2(N,J);return Z?"value"in Z?Z.value:Z.get?.call($.draft_):void 0}function A2($,N){if(!(N in $))return;let J=F0($);while(J){let Z=Object.getOwnPropertyDescriptor(J,N);if(Z)return Z;J=F0(J)}return}function N2($){if(!$.modified_){if($.modified_=!0,$.parent_)N2($.parent_)}}function s0($){if(!$.copy_)$.copy_=t0($.base_,$.scope_.immer_.useStrictShallowCopy_)}var j5=class{constructor($){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(N,J,Z)=>{if(typeof N==="function"&&typeof J!=="function"){let q=J;J=N;let K=this;return function(W=q,...z){return K.produce(W,(M)=>J.call(this,M,...z))}}if(typeof J!=="function")d(6);if(Z!==void 0&&typeof Z!=="function")d(7);let Y;if(Y0(N)){let q=U2(this),K=J2(N,void 0),Q=!0;try{Y=J(K),Q=!1}finally{if(Q)e0(q);else $2(q)}return m2(q,Z),P2(Y,q)}else if(!N||typeof N!=="object"){if(Y=J(N),Y===void 0)Y=N;if(Y===V2)Y=void 0;if(this.autoFreeze_)Z2(Y,!0);if(Z){let q=[],K=[];K0("Patches").generateReplacementPatches_(N,Y,q,K),Z(q,K)}return Y}else d(1,N)},this.produceWithPatches=(N,J)=>{if(typeof N==="function")return(K,...Q)=>this.produceWithPatches(K,(W)=>N(W,...Q));let Z,Y;return[this.produce(N,J,(K,Q)=>{Z=K,Y=Q}),Z,Y]},typeof $?.autoFreeze==="boolean")this.setAutoFreeze($.autoFreeze);if(typeof $?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy($.useStrictShallowCopy);if(typeof $?.useStrictIteration==="boolean")this.setUseStrictIteration($.useStrictIteration)}createDraft($){if(!Y0($))d(8);if(H0($))$=h5($);let N=U2(this),J=J2($,void 0);return J[v].isManual_=!0,$2(N),J}finishDraft($,N){let J=$&&$[v];if(!J||!J.isManual_)d(9);let{scope_:Z}=J;return m2(Z,N),P2(void 0,Z)}setAutoFreeze($){this.autoFreeze_=$}setUseStrictShallowCopy($){this.useStrictShallowCopy_=$}setUseStrictIteration($){this.useStrictIteration_=$}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches($,N){let J;for(J=N.length-1;J>=0;J--){let Y=N[J];if(Y.path.length===0&&Y.op==="replace"){$=Y.value;break}}if(J>-1)N=N.slice(J+1);let Z=K0("Patches").applyPatches_;if(H0($))return Z($,N);return this.produce($,(Y)=>Z(Y,N))}};function J2($,N){let J=A0($)?K0("MapSet").proxyMap_($,N):x0($)?K0("MapSet").proxySet_($,N):v5($,N);return(N?N.scope_:C2()).drafts_.push(J),J}function h5($){if(!H0($))d(10,$);return R2($)}function R2($){if(!Y0($)||y0($))return $;let N=$[v],J,Z=!0;if(N){if(!N.modified_)return N.base_;N.finalized_=!0,J=t0($,N.scope_.immer_.useStrictShallowCopy_),Z=N.scope_.immer_.shouldUseStrictIteration()}else J=t0($,!0);if(S0(J,(Y,q)=>{L2(J,Y,R2(q))},Z),N)N.finalized_=!1;return J}var c5=new j5,O2=c5.produce;var n5=($)=>(N,J,Z)=>{return Z.setState=(Y,q,...K)=>{let Q=typeof Y==="function"?O2(Y):Y;return N(Q,q,...K)},$(Z.setState,J,Z)},I2=n5;var D0=v0()(f2(I2(($,N)=>({members:[],loading:!1,fetchMembers:async(J,Z,Y)=>{if(!Y&&N().loadedTeamId===J&&N().loadedWithAgents===Z)return;$({loading:!0});try{let q=await u.api.teams[":teamId"].members.$get({param:{teamId:J},query:{includeAgents:Z?"true":"false"}});if(!q.ok)throw Error("failed to fetch members");let K=await q.json();$({members:K||[],loadedTeamId:J,loadedProjectId:void 0,loadedWithAgents:Z,loading:!1})}catch{$({loading:!1})}},fetchProjectMembers:async(J,Z,Y)=>{if(!Y&&N().loadedProjectId===J&&N().loadedWithAgents===Z)return;$({loading:!0});try{let q=await u.api.projects[":projectId"].members.$get({param:{projectId:J},query:{includeAgents:Z?"true":"false"}});if(!q.ok)throw Error("failed to fetch project members");let K=await q.json();$({members:K||[],loadedProjectId:J,loadedTeamId:void 0,loadedWithAgents:Z,loading:!1})}catch{$({loading:!1})}}}))));var a=v0(($)=>({fields:[],loadedProjectId:null,setFields:(N,J)=>$({fields:N,loadedProjectId:J}),updateFields:(N)=>$({fields:N})}));function Y2($,N,J){let Z=b($,J?.in);if(isNaN(N))return R0(J?.in||$,NaN);if(!N)return Z;let Y=Z.getDate(),q=R0(J?.in||$,Z.getTime());q.setMonth(Z.getMonth()+N+1,0);let K=q.getDate();if(Y>=K)return q;else return Z.setFullYear(q.getFullYear(),q.getMonth(),Y),Z}function g2($,N){let J=b($,N?.in),Z=J.getMonth();return J.setFullYear(J.getFullYear(),Z+1,0),J.setHours(23,59,59,999),J}function T2($,N){let[J,Z]=S2($,N.start,N.end);return{start:J,end:Z}}function E2($,N){let{start:J,end:Z}=T2(N?.in,$),Y=+J>+Z,q=Y?+J:+Z,K=Y?Z:J;K.setHours(0,0,0,0);let Q=N?.step??1;if(!Q)return[];if(Q<0)Q=-Q,Y=!Y;let W=[];while(+K<=q)W.push(R0(J,K)),K.setDate(K.getDate()+Q),K.setHours(0,0,0,0);return Y?W.reverse():W}function j0($,N){return b($,N?.in).getDate()}function b2($,N){return b($,N?.in).getDay()}function K2($,N){return b($,N?.in).getHours()}function q2($,N){return b($,N?.in).getMinutes()}function Q2($,N){return b($,N?.in).getMonth()}function H2($,N){return b($,N?.in).getFullYear()}var t=j(h(),1);var d5=({value:$,config:N,onSave:J,readOnly:Z})=>{let Y=N?.date,[q,K]=t.useState(!1),Q=t.useRef(null),W=$?new Date($):new Date,z=G0(W)?W:new Date,[M,w]=t.useState(z);t.useEffect(()=>{if(q&&$){let P=new Date($);if(G0(P))w(P)}},[q,$]),t.useEffect(()=>{let P=(B)=>{if(Q.current&&!Q.current.contains(B.target)){if(q)K(!1)}};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[q]);let V=()=>{if(!Z)K(!0)},A=(P)=>{if(!P)return"";let B=new Date(P);if(!G0(B))return"Invalid Date";let F="PPP";if(Y?.displayFormat==="usa")F="MM/dd/yyyy";else if(Y?.displayFormat==="euro")F="dd/MM/yyyy";else if(Y?.displayFormat==="iso")F="yyyy-MM-dd";if(Y?.includeTime)if(Y?.timeFormat==="twenty_four_hour")F+=" HH:mm";else F+=" p";let f=G2(B,F);if(Y?.displayTimezone)f+=` (${Intl.DateTimeFormat().resolvedOptions().timeZone})`;return f},G=new Date(M.getFullYear(),M.getMonth(),1),L=g2(M),O=E2({start:G,end:L}),T=b2(G),U=(P)=>{let B=new Date(P);if(Y?.includeTime)B.setHours(K2(z)),B.setMinutes(q2(z));let F=B.toISOString();if(J(F),!Y?.includeTime)K(!1)},I=(P,B)=>{let F=$?new Date($):new Date;if(!G0(F))F.setTime(new Date().getTime());if(P==="hour")F.setHours(B);if(P==="minute")F.setMinutes(B);let f=F.toISOString();J(f)},k=Array.from({length:24},(P,B)=>B),E=Array.from({length:12},(P,B)=>B*5);if(q)return H("div",{className:"relative w-full",ref:Q,children:[X("div",{className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm shadow-sm min-h-[28px] flex items-center",children:$?A($):X("span",{className:"text-muted-foreground",children:"Select date..."})}),H("div",{className:"absolute z-50 top-full left-0 mt-1 bg-popover border border-border rounded-lg shadow-xl flex flex-col md:flex-row overflow-hidden min-w-[280px]",children:[H("div",{className:"p-4 w-64",children:[H("div",{className:"flex justify-between items-center mb-4",children:[X("button",{onClick:()=>w(Y2(M,-1)),className:"p-1 hover:bg-accent rounded",children:X(x2,{className:"w-4 h-4"})}),X("span",{className:"font-semibold text-sm",children:G2(M,"MMMM yyyy")}),X("button",{onClick:()=>w(Y2(M,1)),className:"p-1 hover:bg-accent rounded",children:X(y2,{className:"w-4 h-4"})})]}),X("div",{className:"grid grid-cols-7 gap-1 text-center text-xs mb-2 text-muted-foreground",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map((P)=>X("div",{children:P},P))}),H("div",{className:"grid grid-cols-7 gap-1 text-center text-sm",children:[Array.from({length:T}).map((P,B)=>X("div",{},`empty-${B}`)),O.map((P)=>{let B=$?new Date($):null,F=B&&G0(B)&&j0(B)===j0(P)&&Q2(B)===Q2(P)&&H2(B)===H2(P);return X("button",{onClick:()=>U(P),className:`w-8 h-8 rounded-full flex items-center justify-center hover:bg-accent transition-colors ${F?"bg-primary text-primary-foreground hover:bg-primary/90":"text-foreground"}`,children:j0(P)},P.toString())})]})]}),Y?.includeTime&&H("div",{className:"border-l border-border bg-muted w-32 flex flex-col",children:[H("div",{className:"p-2 border-b border-border text-xs font-semibold text-muted-foreground flex items-center justify-center gap-1",children:[X(v2,{className:"w-3 h-3"})," Time"]}),H("div",{className:"flex flex-1 h-64",children:[X("div",{className:"flex-1 overflow-y-auto scrollbar-hide border-r border-border",children:k.map((P)=>X("div",{onClick:()=>I("hour",P),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${K2(z)===P?"bg-primary/10 font-medium text-primary":""}`,children:P.toString().padStart(2,"0")},P))}),X("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:E.map((P)=>X("div",{onClick:()=>I("minute",P),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${q2(z)===P?"bg-primary/10 font-medium text-primary":""}`,children:P.toString().padStart(2,"0")},P))})]})]})]})]});return X("div",{onClick:V,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors ${!Z?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$?A($):X("span",{className:"text-muted-foreground italic",children:"Empty"})})},D2=d5;var l=j(h(),1);var l5=({value:$,onSave:N,readOnly:J})=>{let[Z,Y]=l.useState(!1),[q,K]=l.useState($||""),Q=l.useRef(null),W=l.useRef(null),[z,M]=l.useState(!1);l.useEffect(()=>{K($||"")},[$]),l.useEffect(()=>{if(Z&&Q.current)Q.current.focus(),M(!1)},[Z]),l.useEffect(()=>{let G=(L)=>{if(z&&W.current&&!W.current.contains(L.target))M(!1)};if(z)document.addEventListener("mousedown",G);return()=>{document.removeEventListener("mousedown",G)}},[z]);let w=()=>{Y(!1),N(q)},V=(G)=>{G.stopPropagation(),M(!0)},A=(G)=>{if(G.stopPropagation(),!J)Y(!0)};if(Z)return X("textarea",{ref:Q,value:q,onChange:(G)=>K(G.target.value),onBlur:w,className:"w-full min-h-[80px] p-2 border border-ring rounded bg-background text-sm outline-none shadow-sm resize-none"});return H("div",{ref:W,className:"relative w-full text-sm",children:[X("div",{onClick:V,className:`w-full text-foreground rounded border border-transparent transition-all px-2 py-1 h-[48px] line-clamp-2 whitespace-pre-wrap overflow-hidden ${!J?"cursor-pointer hover:bg-accent hover:border-border":"cursor-pointer"}`,title:"Click to expand",children:$?$:X("span",{className:"text-muted-foreground italic",children:"Empty"})}),z&&X("div",{onClick:A,className:`absolute top-0 left-0 w-full min-h-full h-auto z-50 bg-background border border-ring rounded shadow-lg px-2 py-1 whitespace-pre-wrap ${!J?"cursor-text":""}`,children:$?$:X("span",{className:"text-muted-foreground italic",children:"Empty"})})]})},j2=l5;var e=j(h(),1);var u5=({value:$,config:N,onSave:J,readOnly:Z})=>{let Y=N?.number,[q,K]=e.useState(!1),[Q,W]=e.useState(""),z=e.useRef(null);e.useEffect(()=>{W($!==void 0&&$!==null?$.toString():"")},[$]),e.useEffect(()=>{if(q&&z.current)z.current.focus()},[q]);let M=()=>{if(!Z)K(!0)},w=()=>{if(K(!1),Q==="")J(void 0);else{let G=parseFloat(Q);J(isNaN(G)?void 0:G)}},V=(G)=>{if(G.key==="Enter")G.stopPropagation(),z.current?.blur()},A=(G)=>{if(G===void 0||G===null||isNaN(G))return"";return G.toFixed(Y?.scale)};if(q)return X("input",{ref:z,type:"number",step:1/Math.pow(10,Y?.scale||0),value:Q,onChange:(G)=>W(G.target.value),onBlur:w,onKeyDown:V,onDoubleClick:(G)=>G.stopPropagation(),className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm text-left font-mono"});return X("div",{onClick:M,onDoubleClick:(G)=>G.stopPropagation(),className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors text-left font-mono ${!Z?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$!==void 0&&$!==null?A($):X("span",{className:"text-muted-foreground italic font-sans text-left block",children:"Empty"})})},h2=u5;var c2=j(h(),1);var i5=({value:$,config:N,onSave:J,readOnly:Z})=>{let Y=N?.rating,q=Math.max(2,Math.min(6,Y?.maxValue||5)),[K,Q]=c2.useState(null),W=(M,w)=>{if(M.stopPropagation(),Z)return;let V;if($===w)V=0;else V=w;J(V)},z=Array.from({length:q},(M,w)=>w+1);return X("div",{className:"flex items-center gap-1 h-[28px]",onMouseLeave:()=>!Z&&Q(null),onDoubleClick:(M)=>M.stopPropagation(),children:z.map((M)=>{let w=K!==null?M<=K:M<=($||0);return X("button",{onClick:(V)=>W(V,M),onMouseEnter:()=>!Z&&Q(M),className:`focus:outline-none transition-transform ${!Z?"cursor-pointer hover:scale-110":"cursor-default"}`,type:"button",disabled:Z,children:X(h0,{className:`w-5 h-5 transition-colors ${w?"fill-yellow-400 text-yellow-400":"fill-muted text-muted-foreground/30"}`})},M)})})},n2=i5;var M2=j(h(),1);var q0;(function($){$.Base32IncorrectEncoding="B32_ENC_INVALID",$.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",$.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",$.EncodeTimeNegative="ENC_TIME_NEG",$.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",$.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",$.PRNGDetectFailure="PRNG_DETECT",$.ULIDInvalid="ULID_INVALID",$.Unexpected="UNEXPECTED",$.UUIDInvalid="UUID_INVALID"})(q0||(q0={}));class B0 extends Error{constructor($,N){super(`${N} (${$})`);this.name="ULIDError",this.code=$}}function o5($){let N=Math.floor($()*32)%32;return"0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt(N)}function p5($){let N=r5(),J=N&&(N.crypto||N.msCrypto)||null;if(typeof J?.getRandomValues==="function")return()=>{let Z=new Uint8Array(1);return J.getRandomValues(Z),Z[0]/256};else if(typeof J?.randomBytes==="function")return()=>J.randomBytes(1).readUInt8()/256;throw new B0(q0.PRNGDetectFailure,"Failed to find a reliable PRNG")}function r5(){if(t5())return self;if(typeof window<"u")return window;if(typeof global<"u")return global;if(typeof globalThis<"u")return globalThis;return null}function s5($,N){let J="";for(;$>0;$--)J=o5(N)+J;return J}function a5($,N=10){if(isNaN($))throw new B0(q0.EncodeTimeValueMalformed,`Time must be a number: ${$}`);else if($>281474976710655)throw new B0(q0.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${$}`);else if($<0)throw new B0(q0.EncodeTimeNegative,`Time must be positive: ${$}`);else if(Number.isInteger($)===!1)throw new B0(q0.EncodeTimeValueMalformed,`Time must be an integer: ${$}`);let J,Z="";for(let Y=N;Y>0;Y--)J=$%32,Z="0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt(J)+Z,$=($-J)/32;return Z}function t5(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function d2($,N){let J=N||p5(),Z=!$||isNaN($)?Date.now():$;return a5(Z,10)+s5(16,J)}function e5($,N,J){let Z=$.slice();return Z.splice(J,0,Z.splice(N,1)[0]),Z}function l2($,N,J,Z){if(J===Z)return $;let Y=e5(N,J,Z),q=new Set(N.map((Q)=>Q.id)),K=0;return $.map((Q)=>q.has(Q.id)?Y[K++]:Q)}async function Q4($){let N=[],J=[],Z=$.items;if(Z)for(let K=0;K<Z.length;K++){let Q=Z[K];if(Q.kind==="file"){let W=Q.webkitGetAsEntry?.();if(W)J.push({entry:W,path:""})}}else return Array.from($.files);let Y=(K)=>{return new Promise((Q)=>{K.readEntries((W)=>Q(W),()=>Q([]))})},q=(K)=>{return new Promise((Q,W)=>{K.file((z)=>Q(z),(z)=>W(z))})};while(J.length>0){let K=J.shift();if(!K)continue;let{entry:Q,path:W}=K;if(Q.isFile)try{let z=await q(Q),M=W?`${W}/${z.name}`:z.name;Object.defineProperty(z,"webkitRelativePath",{value:M,writable:!1,configurable:!0}),N.push(z)}catch(z){console.error("Error reading file entry:",z)}else if(Q.isDirectory){let z=Q.createReader(),M=[],w=await Y(z);while(w.length>0)M=M.concat(w),w=await Y(z);let V=W?`${W}/${Q.name}`:Q.name;for(let A of M)J.push({entry:A,path:V})}}return N}var c=j(h(),1);var t2=j(h(),1);function e2(){let[$,N]=t2.useState(!1);return H(i2,{open:$,onOpenChange:N,children:[X(o2,{asChild:!0,children:H(i,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 p-0 hover:bg-transparent text-muted-foreground hover:text-foreground inline-flex items-center justify-center shrink-0 ml-1",title:m.autofill_source_help_title(),children:[X(B2,{className:"h-3.5 w-3.5"}),X("span",{className:"sr-only",children:m.autofill_source_help_title()})]})}),H(p2,{className:"sm:max-w-[500px]",children:[H(r2,{children:[H(s2,{className:"flex items-center gap-2",children:[X(B2,{className:"h-5 w-5 text-muted-foreground"}),m.autofill_source_help_title()]}),X(a2,{children:m.autofill_source_help_desc()})]}),H("div",{className:"space-y-4 py-2",children:[H("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[H("div",{className:"flex items-center gap-2 font-medium text-sm",children:[X(u2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),X("span",{children:m.autofill_source_none()})]}),X("p",{className:"text-xs text-muted-foreground leading-relaxed",children:m.autofill_source_none_desc()}),X("p",{className:"text-xs italic text-muted-foreground/80",children:m.autofill_source_none_example()})]}),H("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[H("div",{className:"flex items-center gap-2 font-medium text-sm",children:[X(c0,{className:"h-4 w-4 text-amber-500 shrink-0"}),X("span",{children:m.autofill_source_content()})]}),X("p",{className:"text-xs text-muted-foreground leading-relaxed",children:m.autofill_source_content_desc()}),X("p",{className:"text-xs italic text-muted-foreground/80",children:m.autofill_source_content_example()})]}),H("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[H("div",{className:"flex items-center gap-2 font-medium text-sm",children:[X(n0,{className:"h-4 w-4 text-blue-500 shrink-0"}),X("span",{children:m.autofill_source_creation_context()})]}),X("p",{className:"text-xs text-muted-foreground leading-relaxed",children:m.autofill_source_creation_context_desc()}),X("p",{className:"text-xs italic text-muted-foreground/80",children:m.autofill_source_creation_context_example()})]})]})]})]})}var l0=["red","orange","yellow","green","blue","purple","gray"],z2={red:{bg:"rgba(239, 68, 68, 0.15)",text:"#ef4444",hex:"#ef4444"},orange:{bg:"rgba(249, 115, 22, 0.15)",text:"#f97316",hex:"#f97316"},yellow:{bg:"rgba(234, 179, 8, 0.15)",text:"#ca8a04",hex:"#eab308"},green:{bg:"rgba(34, 197, 94, 0.15)",text:"#16a34a",hex:"#22c55e"},blue:{bg:"rgba(59, 130, 246, 0.15)",text:"#2563eb",hex:"#3b82f6"},purple:{bg:"rgba(168, 85, 247, 0.15)",text:"#9333ea",hex:"#a855f7"},gray:{bg:"rgba(128, 128, 128, 0.15)",text:"#4b5563",hex:"#808080"},system:{bg:"rgba(128, 128, 128, 0.1)",text:"#6b7280",hex:"#808080"}};function _0($){if(!$)return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:"#6b7280"};let N=$.toLowerCase(),J=z2[N];if(J)return{backgroundColor:J.bg,color:J.text};if($.startsWith("#"))return{backgroundColor:`${$}33`,color:$};return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:$}}function I0($=[]){let N=new Set($.map((Z)=>Z.color?.toLowerCase()).filter(Boolean)),J=l0.filter((Z)=>!N.has(Z.toLowerCase()));if(J.length>0)return J[Math.floor(Math.random()*J.length)];return l0[Math.floor(Math.random()*l0.length)]}var $1={[x.text]:H5,[x.longText]:N5,[x.select]:Y5,[x.selectMulti]:q5,[x.rating]:h0,[x.number]:X5,[x.toggle]:Q5,[x.date]:J5,[x.user]:G5,[x.userMulti]:B5};function N1({field:$,index:N,onVisibilityChange:J}){let{ref:Z,handleRef:Y}=V5({id:$.id,index:N}),q=$.config?.type?$1[$.config.type]:null;return H("div",{ref:Z,className:"flex items-center justify-between p-2 rounded-md hover:bg-muted",children:[H("div",{className:"flex items-center gap-2",children:[X("div",{ref:Y,className:"cursor-grab",children:X(Z5,{className:"h-4 w-4 text-muted-foreground"})}),q&&X(q,{className:"h-4 w-4 text-muted-foreground shrink-0"}),$.config?.autofillSource===$0.CONTENT&&X(c0,{className:"h-4 w-4 text-muted-foreground shrink-0"}),$.config?.autofillSource===$0.CREATION_CONTEXT&&X(n0,{className:"h-4 w-4 text-muted-foreground shrink-0"}),X("span",{className:"text-sm truncate",children:$.config?.name})]}),X(u0,{checked:$.visible,onCheckedChange:(K)=>J($.id,K)})]})}function x4({projectId:$,onManageFields:N,onSave:J}){let{fields:Z,updateFields:Y}=a(),[q,K]=c.useState(""),[Q,W]=c.useState("list"),[z,M]=c.useState(""),[w,V]=c.useState(""),[A,G]=c.useState($0.NONE),[L,O]=c.useState(""),[T,U]=c.useState([]),I=$5();c.useEffect(()=>{I.invalidateQueries({queryKey:["fields",$]})},[$,I]);let k=u.api.projects[":projectId"].fields.order.$patch,{mutate:E}=W2({mutationFn:async(_)=>{if(!(await k(_)).ok)throw Error(m.failed_update_fields_order());return null}}),P=u.api.projects[":projectId"].fields.$post,{mutate:B}=W2({mutationFn:async(_)=>{let R=await P(_);if(!R.ok)throw Error(m.failed_create_field());return await R.json()},onSuccess:(_)=>{let R={..._,visible:!0},S=[...Z,R];Y(S),M(""),U([]),E({param:{projectId:$},json:S.map((C)=>({fieldId:C.id,visible:C.visible||!1}))}),J?.()}}),F=c.useMemo(()=>Z.filter((_)=>_.config?.name?.toLowerCase().includes(q.toLowerCase())),[Z,q]),f=(_)=>{if(_.canceled)return;let{source:R}=_.operation;if(!k5(R))return;let{initialIndex:S,index:C}=R;if(S===C)return;let n=l2(Z,F,S,C);Y(n),E({param:{projectId:$},json:n.map((Z0)=>({fieldId:Z0.id,visible:Z0.visible||!1}))})},y=(_,R)=>{let S=Z.map((C)=>C.id===_?{...C,visible:R}:C);Y(S),E({param:{projectId:$},json:S.map((C)=>({fieldId:C.id,visible:C.visible||!1}))})},g=()=>{if(!z||!w)return;let _=w===x.select?{select:{options:T}}:w===x.selectMulti?{selectMulti:{options:T}}:{};B({param:{projectId:$},json:{config:{name:z,type:w,autofillSource:A,..._},label:z,description:L}})},D=Z.filter((_)=>_.visible).length;if(Q==="create")return X("div",{className:"w-80 p-4",children:H("div",{className:"space-y-4",children:[H("div",{className:"space-y-2",children:[X(W0,{htmlFor:"field-name",children:m.field_name()}),X(O0,{id:"field-name",placeholder:m.new_field_placeholder(),value:z,onChange:(_)=>M(_.target.value),autoFocus:!0})]}),H("div",{className:"space-y-2",children:[X(W0,{children:m.field_type()}),H(W5,{children:[X(z5,{asChild:!0,children:H(i,{variant:"outline",className:"w-full justify-between font-normal",children:[w?X("span",{className:"capitalize",children:w.replace(/_/g," ")}):X("span",{className:"text-muted-foreground border-dashed",children:m.select_field_type()}),X(z0,{className:"ml-2 h-4 w-4 opacity-50"})]})}),X(M5,{className:"w-[--radix-dropdown-menu-trigger-width]",children:Object.values(x).map((_)=>X(w5,{onClick:()=>{V(_),U([])},className:"capitalize",children:_.replace(/_/g," ")},_))})]})]}),H("div",{className:"space-y-2",children:[X(W0,{htmlFor:"field-desc",children:m.description()}),X(O0,{id:"field-desc",placeholder:m.description_optional_placeholder(),value:L,onChange:(_)=>O(_.target.value)})]}),H("div",{className:"space-y-2",children:[H("div",{className:"flex items-center gap-1",children:[X(W0,{children:m.autofill_source()}),X(e2,{})]}),H(F5,{type:"single",value:A,onValueChange:(_)=>{if(_)G(_)},className:"w-full grid grid-cols-3 border rounded-md p-1 gap-1",children:[X(d0,{value:$0.NONE,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:m.autofill_source_none()}),X(d0,{value:$0.CONTENT,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:m.autofill_source_content()}),X(d0,{value:$0.CREATION_CONTEXT,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:m.autofill_source_creation_context()})]})]}),(w===x.select||w===x.selectMulti)&&H("div",{className:"space-y-2",children:[H("div",{className:"flex items-center justify-between",children:[X(W0,{className:"text-sm font-medium",children:m.options()}),H(i,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{let _={id:d2(),displayName:m.new_option(),color:I0(T)};U([...T,_])},children:[X(Q0,{className:"h-4 w-4 mr-1"})," ",m.add_option()]})]}),X("div",{className:"space-y-2 max-h-40 overflow-y-auto pr-1",children:T.map((_,R)=>H("div",{className:"flex items-center gap-2",children:[X(O0,{value:_.displayName,onChange:(S)=>{let C=[...T];C[R]={..._,displayName:S.target.value},U(C)},placeholder:m.option_name_placeholder(),className:"h-8 flex-1"}),H(o,{children:[X(p,{asChild:!0,children:X("button",{type:"button",className:"w-6 h-6 rounded-full border shrink-0 cursor-pointer focus:outline-none hover:scale-105 transition-transform",style:{backgroundColor:z2[_.color||""]?.hex||_.color||"#808080"}})}),X(r,{className:"p-2 w-auto",align:"end",children:X("div",{className:"flex gap-1",children:l0.map((S)=>X("button",{type:"button",className:"w-5 h-5 rounded-full border cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:z2[S]?.hex||S},onClick:()=>{let C=[...T];C[R]={..._,color:S},U(C)}},S))})})]}),X(i,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{U(T.filter((S,C)=>C!==R))},children:X(w0,{className:"h-4 w-4"})})]},_.id))})]}),H("div",{className:"flex gap-2 pt-2",children:[X(i,{variant:"secondary",className:"flex-1",onClick:()=>{W("list"),M(""),V(""),G($0.NONE),O(""),U([])},children:m.cancel()}),X(i,{className:"flex-1",onClick:g,disabled:!z||!w,children:m.save()})]})]})});return H("div",{className:"w-80 p-4",children:[X("div",{className:"flex items-center justify-between mb-4",children:H("h3",{className:"font-semibold",children:[m.fields()," ",X("span",{className:"text-muted-foreground text-sm font-normal",children:m.visible_count({count:D})})]})}),H("div",{className:"relative mb-4",children:[X(M0,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),X(O0,{placeholder:m.search_fields_placeholder(),value:q,onChange:(_)=>K(_.target.value),className:"pl-8"})]}),X("div",{className:"max-h-60 overflow-y-auto pr-2",children:X(P5,{sensors:[U5.configure({activationConstraints:[new m5.Distance({value:8})]}),_5],onDragEnd:f,children:F.map((_,R)=>X(N1,{field:_,index:R,onVisibilityChange:y},_.id))})}),N&&H("div",{className:"mt-4 space-y-2",children:[H(i,{variant:"secondary",className:"w-full",onClick:N,children:[X(K5,{className:"h-4 w-4 mr-2"}),m.manage_fields()]}),H(i,{className:"w-full",onClick:()=>W("create"),children:[X(Q0,{className:"h-4 w-4 mr-2"}),m.new_field()]})]})]})}var J1=({value:$,config:N,onSave:J,readOnly:Z,fieldId:Y})=>{let q=N?.select,K=q?.options||[],[Q,W]=M2.useState(!1),[z,M]=M2.useState(""),w=K.find((k)=>k.id===$),V=z.trim(),A=K.filter((k)=>k.displayName.toLowerCase().includes(V.toLowerCase())),G=K.some((k)=>k.displayName.trim().toLowerCase()===V.toLowerCase()||k.id.toLowerCase()===V.toLowerCase()),L=()=>{if(!Z)W(!0)},O=(k)=>{J(k),W(!1),M("")},T=(k)=>{if(Z)return;if(W(k),!k)M("")},U=async()=>{if(!V)return;let k={id:V.toLowerCase().replace(/\s+/g,"-"),displayName:V,color:I0(K)},E=[...K,k],P={...N,select:{...q,options:E}};if(Y)try{let B=await u.api.fields[":fieldId"].$put({param:{fieldId:Y},json:{config:P}});if(!B.ok){m0.error(m.failed_update_field());return}let F=await B.json(),y=a.getState().fields.map((g)=>g.id===F.id?{...g,...F,visible:g.visible}:g);a.getState().updateFields(y)}catch{m0.error(m.failed_update_field());return}J(k.id),M(""),W(!1)};return X("div",{className:"relative w-full",onClick:(k)=>k.stopPropagation(),children:H(o,{open:!Z&&Q,onOpenChange:T,children:[X(p,{asChild:!0,children:H("div",{onClick:L,className:`flex items-center justify-between w-full h-[28px] px-2 rounded border border-transparent transition-colors ${!Z?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((k)=>{if(!k)return X("span",{className:"text-muted-foreground italic text-sm",children:"Select an option"});return X("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium h-[22px]",style:_0(k.color),children:k.displayName})})(w),!Z&&X(z0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),H(r,{side:"bottom",align:"start",sideOffset:4,className:"p-1.5 w-64 max-h-72 flex flex-col bg-popover border border-border rounded-lg shadow-lg",children:[H("div",{className:"relative pb-1.5 border-b border-border mb-1",onClick:(k)=>k.stopPropagation(),children:[X(M0,{className:"w-3.5 h-3.5 absolute left-2 top-2 text-muted-foreground"}),X("input",{type:"text",className:"w-full pl-7 pr-2 py-1 text-xs bg-muted/50 border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-ring text-foreground",placeholder:m.search_options_placeholder(),value:z,onChange:(k)=>M(k.target.value),autoFocus:!0})]}),H("div",{className:"overflow-y-auto max-h-48 min-h-[120px] space-y-0.5",children:[z===""&&H("div",{onClick:()=>O(""),className:"px-2.5 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded cursor-pointer flex items-center gap-2",children:[X(w0,{className:"w-3.5 h-3.5"})," Clear"]}),A.map((k)=>X("div",{onClick:()=>O(k.id),className:`px-2.5 py-1.5 text-xs hover:bg-accent rounded cursor-pointer flex items-center justify-between ${$===k.id?"bg-accent/50 font-medium":""}`,children:X("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:_0(k.color),children:k.displayName})},k.id)),A.length===0&&!V&&X("div",{className:"px-2.5 py-2 text-xs text-muted-foreground italic text-center",children:m.no_options_found()}),V!==""&&!G&&H("div",{onClick:U,className:"px-2.5 py-1.5 text-xs text-primary hover:bg-accent rounded cursor-pointer flex items-center gap-1.5 font-medium border-t border-border mt-1 pt-1.5",children:[X(Q0,{className:"w-3.5 h-3.5 shrink-0"}),X("span",{className:"truncate",children:m.add_option_with_name({name:V})})]})]})]})]})})},L5=J1;var N0=j(h(),1);var Z1=({value:$=[],config:N,onSave:J,readOnly:Z,fieldId:Y})=>{let q=N?.selectMulti,K=q?.options||[],Q=N0.useRef(null),[W,z]=N0.useState(!1),[M,w]=N0.useState($.length),[V,A]=N0.useState(""),G=K.filter((B)=>($||[]).includes(B.id))||[],L=V.trim(),O=K.filter((B)=>B.displayName.toLowerCase().includes(L.toLowerCase())),T=K.some((B)=>B.displayName.trim().toLowerCase()===L.toLowerCase()||B.id.toLowerCase()===L.toLowerCase());N0.useLayoutEffect(()=>{if(W){w(G.length);return}if(Q.current){let B=Q.current.clientWidth-8,f=document.createElement("canvas").getContext("2d");if(f&&B>0){f.font="500 12px ui-sans-serif, system-ui, sans-serif";let y=4,g=G.map((n)=>Math.ceil(f.measureText(n.displayName).width)+18);if(g.reduce((n,Z0)=>n+Z0,0)+Math.max(0,g.length-1)*y<=B){w(G.length);return}let R=B-32-y,S=0,C=0;for(let n=0;n<g.length;n++){let Z0=C>0?S+y+g[n]:g[n];if(Z0>R)break;S=Z0,C++}w(C)}}},[G,W,$]);let U=(B)=>{let F=$||[],f;if(F.includes(B))f=F.filter((y)=>y!==B);else f=[...F,B];J(f)},I=async()=>{if(!L)return;let B={id:L.toLowerCase().replace(/\s+/g,"-"),displayName:L,color:I0(K)},F=[...K,B],f={...N,selectMulti:{...q,options:F}};if(Y)try{let y=await u.api.fields[":fieldId"].$put({param:{fieldId:Y},json:{config:f}});if(!y.ok){m0.error(m.failed_update_field());return}let g=await y.json(),_=a.getState().fields.map((R)=>R.id===g.id?{...R,...g,visible:R.visible}:R);a.getState().updateFields(_)}catch{m0.error(m.failed_update_field());return}J([...$||[],B.id]),A("")},k=(B)=>{if(B.stopPropagation(),!Z)z(!0)},E=G.length-M;return X("div",{className:"relative w-full",onClick:(B)=>B.stopPropagation(),children:H(o,{open:!Z&&W,onOpenChange:(B)=>{if(Z)return;if(z(B),!B)A("")},children:[X(p,{asChild:!0,children:H("div",{ref:Q,onClick:k,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!Z||E>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[G.length===0&&X("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),G.slice(0,M).map((B)=>X("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border border-transparent whitespace-nowrap h-[22px]",style:_0(B.color),children:B.displayName},B.id)),E>0&&H("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",E]})]})}),H(r,{side:"bottom",align:"start",sideOffset:4,className:"p-1.5 w-64 max-h-72 flex flex-col bg-popover border border-border rounded-lg shadow-lg",children:[H("div",{className:"relative pb-1.5 border-b border-border mb-1",onClick:(B)=>B.stopPropagation(),children:[X(M0,{className:"w-3.5 h-3.5 absolute left-2 top-2 text-muted-foreground"}),X("input",{type:"text",className:"w-full pl-7 pr-2 py-1 text-xs bg-muted/50 border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-ring text-foreground",placeholder:m.search_options_placeholder(),value:V,onChange:(B)=>A(B.target.value),autoFocus:!0})]}),H("div",{className:"overflow-y-auto max-h-48 min-h-[120px] space-y-0.5",children:[O.map((B)=>{let F=($||[]).includes(B.id);return H("div",{onClick:()=>U(B.id),className:`px-2.5 py-1.5 hover:bg-accent rounded cursor-pointer flex items-center justify-between text-xs ${F?"bg-accent/30 font-medium":""}`,children:[X("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:_0(B.color),children:B.displayName}),F&&X(i0,{className:"w-3.5 h-3.5 text-primary"})]},B.id)}),O.length===0&&!L&&X("div",{className:"px-2.5 py-2 text-xs text-muted-foreground italic text-center",children:m.no_options_found()}),L!==""&&!T&&H("div",{onClick:I,className:"px-2.5 py-1.5 text-xs text-primary hover:bg-accent rounded cursor-pointer flex items-center gap-1.5 font-medium border-t border-border mt-1 pt-1.5",children:[X(Q0,{className:"w-3.5 h-3.5 shrink-0"}),X("span",{className:"truncate",children:m.add_option_with_name({name:L})})]})]})]})]})})},C5=Z1;var J0=j(h(),1);var X1=({value:$,onSave:N,readOnly:J})=>{let[Z,Y]=J0.useState(!1),[q,K]=J0.useState($||""),Q=J0.useRef(null);J0.useEffect(()=>{K($||"")},[$]),J0.useEffect(()=>{if(Z&&Q.current)Q.current.focus()},[Z]);let W=()=>{if(!J)Y(!0)},z=()=>{Y(!1),N(q)},M=(w)=>{if(w.key==="Enter")Q.current?.blur()};if(Z)return X("input",{ref:Q,type:"text",value:q,onChange:(w)=>K(w.target.value),onBlur:z,onKeyDown:M,className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm"});return X("div",{onClick:W,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded truncate border border-transparent transition-colors ${!J?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$||X("span",{className:"text-muted-foreground italic",children:"Empty"})})},A5=X1;var Y1=({value:$,onSave:N,readOnly:J})=>{return X("div",{className:"flex items-center h-[28px] w-full",onClick:(Y)=>Y.stopPropagation(),children:X(u0,{checked:$,onCheckedChange:(Y)=>{if(!J)N(Y)},disabled:J,className:"cursor-pointer"})})},R5=Y1;var p0=j(h(),1);var K1=({value:$,onSave:N,readOnly:J})=>{let Z=o0(),{members:Y,fetchMembers:q}=D0(),[K,Q]=p0.useState(!1);p0.useEffect(()=>{if(Z)q(Z)},[Z,q]);let W=Y.find((G)=>G.id===$),z=()=>{if(!J)Q(!0)},M=(G)=>{N(G),Q(!1)},w=(G)=>{if(J)return;Q(G)},V=(G)=>{return G.split(" ").map((L)=>L[0]).slice(0,2).join("").toUpperCase()};return X("div",{className:"relative w-full",onClick:(G)=>G.stopPropagation(),children:H(o,{open:!J&&K,onOpenChange:w,children:[X(p,{asChild:!0,children:H("div",{onClick:z,className:`flex items-center justify-between w-full h-[28px] px-2 rounded border border-transparent transition-colors ${!J?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((G)=>{if(!G)return X("span",{className:"text-muted-foreground italic text-sm",children:"Select user"});return H("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border h-[22px]",children:[H(U0,{className:"w-4 h-4",children:[X(P0,{src:G.image,alt:G.name,className:"object-cover"}),X(k0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:V(G.name)})]}),X("span",{className:"truncate max-w-[120px]",children:G.name})]})})(W),!J&&X(z0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),H(r,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[200px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:[H("div",{onClick:()=>M(""),className:"px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[X(w0,{className:"w-3 h-3"})," Clear"]}),Y.map((G)=>H("div",{onClick:()=>M(G.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[H(U0,{className:"w-5 h-5",children:[X(P0,{src:G.image,alt:G.name,className:"object-cover"}),X(k0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:V(G.name)})]}),X("span",{className:"text-sm font-medium text-foreground",children:G.name})]},G.id))]})]})})},O5=K1;var s=j(h(),1);var q1=({value:$=[],onSave:N,readOnly:J})=>{let Z=o0(),{members:Y,fetchMembers:q}=D0(),K=s.useRef(null),[Q,W]=s.useState(!1),[z,M]=s.useState($.length);s.useEffect(()=>{if(Z)q(Z)},[Z,q]);let w=Y.filter((U)=>($||[]).includes(U.id)),V=(U)=>{return U.split(" ").map((I)=>I[0]).slice(0,2).join("").toUpperCase()};s.useLayoutEffect(()=>{if(Q){M(w.length);return}if(K.current){let U=K.current.clientWidth-8,k=document.createElement("canvas").getContext("2d");if(k&&U>0){k.font="500 12px ui-sans-serif, system-ui, sans-serif";let E=4,P=w.map((D)=>{return Math.min(100,Math.ceil(k.measureText(D.name).width))+40});if(P.reduce((D,_)=>D+_,0)+Math.max(0,P.length-1)*E<=U){M(w.length);return}let f=U-32-E,y=0,g=0;for(let D=0;D<P.length;D++){let _=g>0?y+E+P[D]:P[D];if(_>f)break;y=_,g++}M(g)}}},[w,Q,$]);let A=(U)=>{let I=$||[],k;if(I.includes(U))k=I.filter((E)=>E!==U);else k=[...I,U];N(k)},G=(U)=>{if(U.stopPropagation(),!J)W(!0)},L=w.length-z,O=(U)=>{if(J)return;W(U)},T=(U)=>{return H("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border whitespace-nowrap h-[22px]",children:[H(U0,{className:"w-4 h-4",children:[X(P0,{src:U.image,alt:U.name,className:"object-cover"}),X(k0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:V(U.name)})]}),X("span",{className:"truncate max-w-[100px]",children:U.name})]},U.id)};return X("div",{className:"relative w-full",onClick:(U)=>U.stopPropagation(),children:H(o,{open:!J&&Q,onOpenChange:O,children:[X(p,{asChild:!0,children:H("div",{ref:K,onClick:G,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!J||L>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[w.length===0&&X("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),w.slice(0,z).map(T),L>0&&H("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",L]})]})}),X(r,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[200px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:Y.map((U)=>{let I=($||[]).includes(U.id);return H("div",{onClick:()=>A(U.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between rounded-sm",children:[H("div",{className:"flex items-center gap-2",children:[H(U0,{className:"w-5 h-5",children:[X(P0,{src:U.image,alt:U.name,className:"object-cover"}),X(k0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:V(U.name)})]}),X("span",{className:"text-sm font-medium text-foreground",children:U.name})]}),I&&X(i0,{className:"w-4 h-4 text-primary"})]},U.id)})})]})})},I5=q1;var Q1=($)=>{if(!$.config)return X("div",{children:"Unknown Field Type"});switch($.config.type){case"text":return X(A5,{...$,value:$.value,onSave:$.onSave});case"longText":return X(j2,{...$,value:$.value,onSave:$.onSave});case"select":return X(L5,{...$,value:$.value,onSave:$.onSave});case"selectMulti":return X(C5,{...$,value:$.value,onSave:$.onSave});case"rating":return X(n2,{...$,value:$.value,onSave:$.onSave});case"number":return X(h2,{...$,value:$.value,onSave:$.onSave});case"toggle":return X(R5,{...$,value:$.value,onSave:$.onSave});case"date":return X(D2,{...$,value:$.value,onSave:$.onSave});case"user":return X(O5,{...$,value:$.value,onSave:$.onSave});case"userMulti":return X(I5,{...$,value:$.value,onSave:$.onSave});default:return X("div",{children:"Unknown Field Type"})}},v$=Q1;var h$=({progress:$,className:N})=>{let Z=2*Math.PI*20,Y=Z-Math.min(100,Math.max(0,$))/100*Z;return H("svg",{viewBox:"0 0 50 50",className:V0("w-12 h-12",N),children:[X("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),X("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:Z,strokeDashoffset:Y,transform:"rotate(-90 25 25)"}),X("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round($)}%`})]})};var H1=($)=>{if(isNaN($))return"00:00";let N=new Date($*1000),J=N.getUTCHours(),Z=N.getUTCMinutes().toString().padStart(2,"0"),Y=N.getUTCSeconds().toString().padStart(2,"0");if(J)return`${J}:${Z}:${Y}`;return`${Z}:${Y}`},d$=($,N,J,Z)=>{if(J==="frames")return`${$} fr`;if(J==="standard")return H1($/N);let Y=Math.round(N),q=N!==Y,K=!1;if(q&&(Y===30||Y===60))K=!0;let Q=0;if(Z){let G=Z.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(G){let L=parseInt(G[1],10),O=parseInt(G[2],10),T=parseInt(G[3],10),U=parseInt(G[5],10);if(K=G[4]!==":",Q=(L*3600+O*60+T)*Y+U,K){let I=L*60+O,k=N<30?2:4;Q-=k*(I-Math.floor(I/10))}}}let W=$+Q;if(K){let G=N<30?2:4,L=Math.floor(W/(17982*G/2)),O=W%(17982*G/2);if(O<G)O=O+G;W+=9*G*L+G*Math.floor((O-G)/(1798*G/2))}let z=W%Y,M=Math.floor(W/Y)%60,w=Math.floor(W/(Y*60))%60,V=Math.floor(W/(Y*3600))%24,A=K?";":":";return`${V.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}:${M.toString().padStart(2,"0")}${A}${z.toString().padStart(2,"0")}`};var l$=($,N)=>{if(!N)return 0;let J=1/N;return $*J+J/2},G1=($)=>Math.max(100,3000/($||30)),u$=({dbTotalFrames:$,containerDuration:N,frameRate:J})=>{let Z=J||30,Y=Math.round(N*Z);if($<=0)return Y;let q=$/Z,K=N-q,Q=G1(Z)/1000;return K>Q?Y:$};var f5=j(h(),1);function r$({className:$,defaultValue:N,value:J,min:Z=0,max:Y=100,...q}){let K=f5.useMemo(()=>Array.isArray(J)?J:Array.isArray(N)?N:[Z,Y],[J,N,Z,Y]);return H(f0.Root,{"data-slot":"slider",defaultValue:N,value:J,min:Z,max:Y,className:V0("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",$),...q,children:[X(f0.Track,{"data-slot":"slider-track",className:V0("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:X(f0.Range,{"data-slot":"slider-range",className:V0("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:K.length},(Q,W)=>X(f0.Thumb,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},W))]})}
2
+ export{Y2 as x,g2 as y,T2 as z,Q2 as A,H2 as B,l2 as C,Q4 as D,a as E,d2 as F,h$ as G,B1 as H,n2 as I,e2 as J,l0 as K,z2 as L,_0 as M,I0 as N,$1 as O,x4 as P,D0 as Q,v$ as R,H1 as S,d$ as T,l$ as U,G1 as V,u$ as W,r$ as X};
@@ -0,0 +1,2 @@
1
+ import{jf as A}from"./chunk-nn753fbs.js";import{Nh as v,ci as w,pi as z}from"./chunk-5ctpz542.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId_/agentsmd")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
+ export{B as Re,H as Se};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,s=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var t=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var u=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var v=(a,b)=>()=>(a&&(b=a(a=0)),b);var w=(a)=>JSON.parse(a);var x=import.meta.require;
3
- export{s as Nl,t as Ol,u as Pl,v as Ql,w as Rl,x as Sl};
3
+ export{s as nm,t as om,u as pm,v as qm,w as rm,x as sm};