gemi 0.241.0 → 0.242.0

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 (214) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/ai/testing/index.js +2 -2
  4. package/dist/ai/testing/index.js.map +1 -1
  5. package/dist/app/index.js +1 -1
  6. package/dist/bun/plugin.js +1 -1
  7. package/dist/bun/preload.js +1 -1
  8. package/dist/{chunk-8z16b2j2.js → chunk-093j5rh8.js} +3 -3
  9. package/dist/{chunk-8z16b2j2.js.map → chunk-093j5rh8.js.map} +1 -1
  10. package/dist/{chunk-bvgcv0jx.js → chunk-0jmh2271.js} +2 -2
  11. package/dist/{chunk-bvgcv0jx.js.map → chunk-0jmh2271.js.map} +1 -1
  12. package/dist/{chunk-bn2b57qq.js → chunk-0sr3cfex.js} +2 -2
  13. package/dist/{chunk-bn2b57qq.js.map → chunk-0sr3cfex.js.map} +1 -1
  14. package/dist/{chunk-etj63p4p.js → chunk-0tsnmrf9.js} +2 -2
  15. package/dist/{chunk-etj63p4p.js.map → chunk-0tsnmrf9.js.map} +1 -1
  16. package/dist/{chunk-0xmk4jyj.js → chunk-110ecy3e.js} +2 -2
  17. package/dist/{chunk-0xmk4jyj.js.map → chunk-110ecy3e.js.map} +1 -1
  18. package/dist/{chunk-samm4h7d.js → chunk-11hmhyk5.js} +2 -2
  19. package/dist/{chunk-samm4h7d.js.map → chunk-11hmhyk5.js.map} +1 -1
  20. package/dist/{chunk-8wvh099n.js → chunk-26pfh03x.js} +3 -3
  21. package/dist/{chunk-8wvh099n.js.map → chunk-26pfh03x.js.map} +1 -1
  22. package/dist/{chunk-51mz612v.js → chunk-27f9z8yk.js} +2 -2
  23. package/dist/{chunk-51mz612v.js.map → chunk-27f9z8yk.js.map} +1 -1
  24. package/dist/{chunk-3mq0wmq7.js → chunk-2g6cmkrn.js} +3 -3
  25. package/dist/{chunk-3mq0wmq7.js.map → chunk-2g6cmkrn.js.map} +1 -1
  26. package/dist/{chunk-4mysb5ej.js → chunk-2yvzc5tq.js} +2 -2
  27. package/dist/{chunk-4mysb5ej.js.map → chunk-2yvzc5tq.js.map} +1 -1
  28. package/dist/{chunk-vk1x3rsw.js → chunk-3tpj5t10.js} +2 -2
  29. package/dist/{chunk-vk1x3rsw.js.map → chunk-3tpj5t10.js.map} +1 -1
  30. package/dist/{chunk-vqmy8jfr.js → chunk-3ywtqcxt.js} +2 -2
  31. package/dist/{chunk-vqmy8jfr.js.map → chunk-3ywtqcxt.js.map} +1 -1
  32. package/dist/{chunk-3kgp6xka.js → chunk-4f8qpzsw.js} +1 -1
  33. package/dist/{chunk-qb8pjdez.js → chunk-4y0j6c56.js} +4 -4
  34. package/dist/{chunk-qb8pjdez.js.map → chunk-4y0j6c56.js.map} +1 -1
  35. package/dist/{chunk-e4adgvd6.js → chunk-54v3y7mg.js} +3 -3
  36. package/dist/{chunk-e4adgvd6.js.map → chunk-54v3y7mg.js.map} +1 -1
  37. package/dist/{chunk-fec4qnr3.js → chunk-57n0m9fv.js} +2 -2
  38. package/dist/{chunk-fec4qnr3.js.map → chunk-57n0m9fv.js.map} +1 -1
  39. package/dist/{chunk-vvq18rrr.js → chunk-5pfbqc1c.js} +2 -2
  40. package/dist/{chunk-vvq18rrr.js.map → chunk-5pfbqc1c.js.map} +1 -1
  41. package/dist/{chunk-2g1h9ktj.js → chunk-632nqkza.js} +2 -2
  42. package/dist/{chunk-2g1h9ktj.js.map → chunk-632nqkza.js.map} +1 -1
  43. package/dist/{chunk-kabkxq5q.js → chunk-646bqwp8.js} +2 -2
  44. package/dist/{chunk-kabkxq5q.js.map → chunk-646bqwp8.js.map} +1 -1
  45. package/dist/{chunk-3qmhe96e.js → chunk-65m459jb.js} +2 -2
  46. package/dist/{chunk-3qmhe96e.js.map → chunk-65m459jb.js.map} +1 -1
  47. package/dist/{chunk-3crknzwp.js → chunk-7c48nxqb.js} +3 -3
  48. package/dist/{chunk-3crknzwp.js.map → chunk-7c48nxqb.js.map} +1 -1
  49. package/dist/{chunk-n1phcznj.js → chunk-7gqq3834.js} +2 -2
  50. package/dist/{chunk-n1phcznj.js.map → chunk-7gqq3834.js.map} +1 -1
  51. package/dist/{chunk-feh44g4f.js → chunk-7mxwstm2.js} +2 -2
  52. package/dist/{chunk-feh44g4f.js.map → chunk-7mxwstm2.js.map} +1 -1
  53. package/dist/{chunk-gykwq8py.js → chunk-7qt9pxm6.js} +1 -1
  54. package/dist/{chunk-c7hbdsjv.js → chunk-7ztbpqed.js} +2 -2
  55. package/dist/{chunk-3ady4k66.js.map → chunk-7ztbpqed.js.map} +1 -1
  56. package/dist/chunk-8dga75cv.js +5 -0
  57. package/dist/{chunk-by0ydsqs.js.map → chunk-8dga75cv.js.map} +1 -1
  58. package/dist/{chunk-zsmwmg8x.js → chunk-9cxs1q57.js} +2 -2
  59. package/dist/{chunk-zsmwmg8x.js.map → chunk-9cxs1q57.js.map} +1 -1
  60. package/dist/{chunk-387fpg2k.js → chunk-9xm5z33t.js} +2 -2
  61. package/dist/{chunk-387fpg2k.js.map → chunk-9xm5z33t.js.map} +1 -1
  62. package/dist/{chunk-gpngw61t.js → chunk-ac135mmf.js} +2 -2
  63. package/dist/{chunk-gpngw61t.js.map → chunk-ac135mmf.js.map} +1 -1
  64. package/dist/{chunk-z0jf5kzx.js → chunk-bbhrs7s3.js} +2 -2
  65. package/dist/{chunk-z0jf5kzx.js.map → chunk-bbhrs7s3.js.map} +1 -1
  66. package/dist/{chunk-vq1q8mgm.js → chunk-bsmy8vqs.js} +2 -2
  67. package/dist/{chunk-vq1q8mgm.js.map → chunk-bsmy8vqs.js.map} +1 -1
  68. package/dist/{chunk-t495wyhh.js → chunk-c0hxmw3a.js} +2 -2
  69. package/dist/{chunk-t495wyhh.js.map → chunk-c0hxmw3a.js.map} +1 -1
  70. package/dist/{chunk-c3c37k46.js → chunk-d39h1mrz.js} +3 -3
  71. package/dist/{chunk-c3c37k46.js.map → chunk-d39h1mrz.js.map} +1 -1
  72. package/dist/{chunk-n30y9dc5.js → chunk-daw2xr2v.js} +4 -4
  73. package/dist/{chunk-n30y9dc5.js.map → chunk-daw2xr2v.js.map} +1 -1
  74. package/dist/{chunk-3rm4v7ht.js → chunk-dfat5nmk.js} +3 -3
  75. package/dist/{chunk-3rm4v7ht.js.map → chunk-dfat5nmk.js.map} +1 -1
  76. package/dist/{chunk-9a3wbbr6.js → chunk-e0e43wvq.js} +2 -2
  77. package/dist/{chunk-9a3wbbr6.js.map → chunk-e0e43wvq.js.map} +1 -1
  78. package/dist/{chunk-re13gf4s.js → chunk-e3m0anq1.js} +3 -3
  79. package/dist/{chunk-re13gf4s.js.map → chunk-e3m0anq1.js.map} +1 -1
  80. package/dist/{chunk-rpwvwsq9.js → chunk-e4a6smfv.js} +1 -1
  81. package/dist/{chunk-4wj4bwvc.js → chunk-eb4mx34p.js} +3 -3
  82. package/dist/{chunk-4wj4bwvc.js.map → chunk-eb4mx34p.js.map} +1 -1
  83. package/dist/{chunk-qkfd84hx.js → chunk-ed64ynex.js} +2 -2
  84. package/dist/{chunk-qkfd84hx.js.map → chunk-ed64ynex.js.map} +1 -1
  85. package/dist/chunk-evx7nxad.js +10 -0
  86. package/dist/{chunk-2f2t8j4j.js.map → chunk-evx7nxad.js.map} +4 -4
  87. package/dist/{chunk-z6gwn4xf.js → chunk-fb3qkmwh.js} +2 -2
  88. package/dist/{chunk-z6gwn4xf.js.map → chunk-fb3qkmwh.js.map} +1 -1
  89. package/dist/{chunk-9fgyanab.js → chunk-fjh3xaq7.js} +2 -2
  90. package/dist/{chunk-9fgyanab.js.map → chunk-fjh3xaq7.js.map} +1 -1
  91. package/dist/{chunk-kgbgj7v4.js → chunk-fs2cdxry.js} +2 -2
  92. package/dist/{chunk-kgbgj7v4.js.map → chunk-fs2cdxry.js.map} +1 -1
  93. package/dist/{chunk-bhycdjcv.js → chunk-fy4142fv.js} +2 -2
  94. package/dist/{chunk-bhycdjcv.js.map → chunk-fy4142fv.js.map} +1 -1
  95. package/dist/{chunk-342ydn4n.js → chunk-ge5m9qdt.js} +2 -2
  96. package/dist/{chunk-342ydn4n.js.map → chunk-ge5m9qdt.js.map} +1 -1
  97. package/dist/{chunk-7fh7cfjh.js → chunk-gqw25apr.js} +2 -2
  98. package/dist/{chunk-7fh7cfjh.js.map → chunk-gqw25apr.js.map} +1 -1
  99. package/dist/{chunk-wkw8afk0.js → chunk-h6dzn5j6.js} +2 -2
  100. package/dist/{chunk-wkw8afk0.js.map → chunk-h6dzn5j6.js.map} +1 -1
  101. package/dist/{chunk-x68jra5n.js → chunk-hhaxacwh.js} +2 -2
  102. package/dist/{chunk-x68jra5n.js.map → chunk-hhaxacwh.js.map} +1 -1
  103. package/dist/{chunk-a8q7ds6w.js → chunk-hvw25pe3.js} +1 -1
  104. package/dist/{chunk-6wv3k8ap.js → chunk-jr53em8y.js} +2 -2
  105. package/dist/{chunk-6wv3k8ap.js.map → chunk-jr53em8y.js.map} +1 -1
  106. package/dist/{chunk-gs8fvb6a.js → chunk-kejexfsg.js} +2 -2
  107. package/dist/{chunk-gs8fvb6a.js.map → chunk-kejexfsg.js.map} +1 -1
  108. package/dist/{chunk-rc86ewq1.js → chunk-kjz6jh54.js} +3 -3
  109. package/dist/{chunk-rc86ewq1.js.map → chunk-kjz6jh54.js.map} +1 -1
  110. package/dist/{chunk-7sxbq483.js → chunk-mjfnv2r9.js} +2 -2
  111. package/dist/{chunk-7sxbq483.js.map → chunk-mjfnv2r9.js.map} +1 -1
  112. package/dist/{chunk-7ycjs0xn.js → chunk-n537kc55.js} +2 -2
  113. package/dist/{chunk-7ycjs0xn.js.map → chunk-n537kc55.js.map} +1 -1
  114. package/dist/{chunk-8e14zcdc.js → chunk-n8cm2sw6.js} +2 -2
  115. package/dist/{chunk-8e14zcdc.js.map → chunk-n8cm2sw6.js.map} +1 -1
  116. package/dist/{chunk-13eq76tw.js → chunk-p03jdwc1.js} +2 -2
  117. package/dist/{chunk-13eq76tw.js.map → chunk-p03jdwc1.js.map} +1 -1
  118. package/dist/{chunk-aczp96k5.js → chunk-rffa9x3d.js} +2 -2
  119. package/dist/{chunk-aczp96k5.js.map → chunk-rffa9x3d.js.map} +1 -1
  120. package/dist/{chunk-1wfwqgm5.js → chunk-rwyn40p1.js} +2 -2
  121. package/dist/{chunk-1wfwqgm5.js.map → chunk-rwyn40p1.js.map} +1 -1
  122. package/dist/{chunk-gxre6wnc.js → chunk-s0azv6dd.js} +2 -2
  123. package/dist/{chunk-gxre6wnc.js.map → chunk-s0azv6dd.js.map} +1 -1
  124. package/dist/{chunk-1kjyhseb.js → chunk-sew755q5.js} +1 -1
  125. package/dist/{chunk-wgb26e02.js → chunk-sp79baph.js} +2 -2
  126. package/dist/{chunk-wgb26e02.js.map → chunk-sp79baph.js.map} +1 -1
  127. package/dist/{chunk-g9q39z7t.js → chunk-ss0gk90s.js} +2 -2
  128. package/dist/{chunk-g9q39z7t.js.map → chunk-ss0gk90s.js.map} +1 -1
  129. package/dist/{chunk-4sv5vkab.js → chunk-t4eeg7j1.js} +3 -3
  130. package/dist/{chunk-4sv5vkab.js.map → chunk-t4eeg7j1.js.map} +1 -1
  131. package/dist/{chunk-wjjxqw9b.js → chunk-t67dbfqs.js} +3 -3
  132. package/dist/{chunk-wjjxqw9b.js.map → chunk-t67dbfqs.js.map} +1 -1
  133. package/dist/{chunk-4j0h4q8v.js → chunk-t77xnb8k.js} +2 -2
  134. package/dist/{chunk-4j0h4q8v.js.map → chunk-t77xnb8k.js.map} +1 -1
  135. package/dist/{chunk-3ady4k66.js → chunk-tws22txn.js} +2 -2
  136. package/dist/{chunk-c7hbdsjv.js.map → chunk-tws22txn.js.map} +1 -1
  137. package/dist/{chunk-ccymw1ed.js → chunk-v3ddktnq.js} +3 -3
  138. package/dist/{chunk-ccymw1ed.js.map → chunk-v3ddktnq.js.map} +1 -1
  139. package/dist/chunk-vh6vc4h1.js +596 -0
  140. package/dist/{chunk-6gek696n.js.map → chunk-vh6vc4h1.js.map} +7 -6
  141. package/dist/{chunk-tvb68dqg.js → chunk-vqtzwnwr.js} +2 -2
  142. package/dist/{chunk-tvb68dqg.js.map → chunk-vqtzwnwr.js.map} +1 -1
  143. package/dist/{chunk-rreb2k19.js → chunk-wac3gv1t.js} +2 -2
  144. package/dist/{chunk-rreb2k19.js.map → chunk-wac3gv1t.js.map} +1 -1
  145. package/dist/{chunk-cfpzhc8n.js → chunk-xt4ssej8.js} +2 -2
  146. package/dist/{chunk-cfpzhc8n.js.map → chunk-xt4ssej8.js.map} +1 -1
  147. package/dist/{chunk-p0dgpm5r.js → chunk-xvnjahea.js} +2 -2
  148. package/dist/{chunk-p0dgpm5r.js.map → chunk-xvnjahea.js.map} +1 -1
  149. package/dist/{chunk-cjwjrk12.js → chunk-xy5evkaz.js} +1 -1
  150. package/dist/{chunk-vcmwp7pv.js → chunk-ye1kbxkx.js} +3 -3
  151. package/dist/{chunk-vcmwp7pv.js.map → chunk-ye1kbxkx.js.map} +1 -1
  152. package/dist/{chunk-ff8rtz9h.js → chunk-yqsnrp2b.js} +2 -2
  153. package/dist/{chunk-ff8rtz9h.js.map → chunk-yqsnrp2b.js.map} +1 -1
  154. package/dist/{chunk-0wa8ztk5.js → chunk-yrna0ajq.js} +3 -3
  155. package/dist/{chunk-0wa8ztk5.js.map → chunk-yrna0ajq.js.map} +1 -1
  156. package/dist/{chunk-768yza4f.js → chunk-zpnxr23b.js} +2 -2
  157. package/dist/{chunk-768yza4f.js.map → chunk-zpnxr23b.js.map} +1 -1
  158. package/dist/{chunk-agpty0p6.js → chunk-zrqqnfrs.js} +2 -2
  159. package/dist/{chunk-agpty0p6.js.map → chunk-zrqqnfrs.js.map} +1 -1
  160. package/dist/config/index.js +1 -1
  161. package/dist/console/run.js +2 -2
  162. package/dist/console/run.js.map +1 -1
  163. package/dist/container/index.js +2 -2
  164. package/dist/container/index.js.map +1 -1
  165. package/dist/database/index.js +2 -2
  166. package/dist/database/index.js.map +1 -1
  167. package/dist/email/index.js +2 -2
  168. package/dist/email/index.js.map +1 -1
  169. package/dist/facades/index.js +2 -2
  170. package/dist/facades/index.js.map +1 -1
  171. package/dist/foundation/index.js +2 -2
  172. package/dist/foundation/index.js.map +1 -1
  173. package/dist/http/index.js +2 -2
  174. package/dist/http/index.js.map +1 -1
  175. package/dist/i18n/dictionaryRuntime.js +2 -2
  176. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  177. package/dist/i18n/index.js +2 -2
  178. package/dist/i18n/index.js.map +1 -1
  179. package/dist/kernel/index.js +2 -2
  180. package/dist/kernel/index.js.map +1 -1
  181. package/dist/orm/index.js +2 -2
  182. package/dist/orm/index.js.map +1 -1
  183. package/dist/probe/index.js +2 -2
  184. package/dist/probe/index.js.map +1 -1
  185. package/dist/server/index.js +2 -2
  186. package/dist/server/index.js.map +1 -1
  187. package/dist/services/cron/ScheduleServiceProvider.d.ts.map +1 -1
  188. package/dist/services/index.js +2 -2
  189. package/dist/services/index.js.map +1 -1
  190. package/dist/services/queue/Job.d.ts +10 -0
  191. package/dist/services/queue/Job.d.ts.map +1 -1
  192. package/dist/services/queue/QueueManager.d.ts +10 -37
  193. package/dist/services/queue/QueueManager.d.ts.map +1 -1
  194. package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
  195. package/dist/services/queue/WorkerPool.d.ts +123 -0
  196. package/dist/services/queue/WorkerPool.d.ts.map +1 -0
  197. package/dist/services/queue/config.d.ts +16 -0
  198. package/dist/services/queue/config.d.ts.map +1 -1
  199. package/dist/services/queue/work.js +2 -2
  200. package/dist/services/queue/work.js.map +1 -1
  201. package/dist/stats/route-table.js +1 -1
  202. package/dist/support/index.js +2 -2
  203. package/dist/support/index.js.map +1 -1
  204. package/dist/vitest/index.js +1 -1
  205. package/package.json +1 -1
  206. package/dist/chunk-2f2t8j4j.js +0 -10
  207. package/dist/chunk-6gek696n.js +0 -591
  208. package/dist/chunk-by0ydsqs.js +0 -5
  209. /package/dist/{chunk-3kgp6xka.js.map → chunk-4f8qpzsw.js.map} +0 -0
  210. /package/dist/{chunk-gykwq8py.js.map → chunk-7qt9pxm6.js.map} +0 -0
  211. /package/dist/{chunk-rpwvwsq9.js.map → chunk-e4a6smfv.js.map} +0 -0
  212. /package/dist/{chunk-a8q7ds6w.js.map → chunk-hvw25pe3.js.map} +0 -0
  213. /package/dist/{chunk-1kjyhseb.js.map → chunk-sew755q5.js.map} +0 -0
  214. /package/dist/{chunk-cjwjrk12.js.map → chunk-xy5evkaz.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rb as z$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,ic as J$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-2f2t8j4j.js";import{lc as d4}from"../chunk-4j0h4q8v.js";import"../chunk-samm4h7d.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-51mz612v.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,De as nZ,Ee as iZ,Fe as sZ,Ge as oZ,He as aZ,Ie as tZ,Je as rZ,Ke as eZ,Le as W9,Me as Z9,Ne as $9,Oe as Q9,Pe as Y9,Qe as K9,Ve as J9,ye as cZ,ze as uZ}from"../chunk-6gek696n.js";import{We as h9,Xe as E9}from"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{$g as TZ,Af as Y8,Ag as GZ,Bf as K8,Cf as J8,Cg as XZ,Df as z8,Dg as BZ,Ef as G8,Eg as jZ,Ff as X8,Fg as MZ,Gf as B8,Gg as FZ,Hf as j8,Hg as LZ,If as Y6,Ig as DZ,Ih as yZ,Jf as M8,Jg as HZ,Jh as AZ,Kf as F8,Kg as NZ,Lf as L8,Lg as UZ,Mf as D8,Nf as H8,Qg as R,Rg as i,Sg as xZ,Tg as SZ,Ug as RZ,Vg as OZ,Wg as _Z,Yg as VZ,Zg as kZ,_g as CZ,ag as T8,bg as P8,bh as PZ,cg as b8,df as V6,dg as w8,ef as e5,eg as q8,eh as bZ,ff as W8,fg as v8,fh as wZ,gf as Z8,gh as qZ,if as $8,jh as vZ,mg as e8,ng as q6,of as k6,og as WZ,oh as IZ,pf as C4,qf as B6,rf as T4,sf as P4,sg as ZZ,sh as fZ,tg as $Z,ug as YZ,wf as f6,wh as i4,xf as y6,xg as KZ,xh as z1,yg as JZ,zf as Q8,zg as zZ}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import{$i as Y1,Aj as _8,Bi as k4,Ci as O4,Cj as d1,Di as k1,Vi as h4,Zi as j1,cj as _4,dj as C1,ej as p1,fj as N8,gj as U8,hj as x8,ij as S8,jj as R8,vj as mW,wj as cW,zj as O8}from"../chunk-8z16b2j2.js";import"../chunk-2g1h9ktj.js";import{Nj as V8,Oj as k8,Pj as C8}from"../chunk-e4adgvd6.js";import{Rj as q}from"../chunk-0xmk4jyj.js";import{$j as U,Zj as g8,_j as m8,ak as c8,bk as b,ck as u8,dk as p8}from"../chunk-8wvh099n.js";import{jk as A8,kk as h8,lk as E8}from"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import{Uk as QZ}from"../chunk-9a3wbbr6.js";import{$k as n8,Wk as I8,Xk as f8,Yk as y8,Zk as d8,_k as l8,al as i8,bl as s8,cl as o8,hl as a8,il as t8,jl as r8}from"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import{hm as w4,im as hZ,jm as EZ,km as gZ,mm as mZ}from"../chunk-rc86ewq1.js";import"../chunk-x68jra5n.js";import{wm as C}from"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import{$m as u1}from"../chunk-c7hbdsjv.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-qb8pjdez.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
2
+ import{rb as z$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,ic as J$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-evx7nxad.js";import{lc as d4}from"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-27f9z8yk.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,Fe as nZ,Ge as iZ,He as sZ,Ie as oZ,Je as aZ,Ke as tZ,Le as rZ,Me as eZ,Ne as W9,Oe as Z9,Pe as $9,Qe as Q9,Re as Y9,Se as K9,Xe as J9,ye as cZ,ze as uZ}from"../chunk-vh6vc4h1.js";import{Ye as h9,Ze as E9}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{$g as kZ,Ag as JZ,Bf as Q8,Bg as zZ,Cf as Y8,Cg as GZ,Df as K8,Ef as J8,Eg as XZ,Ff as z8,Fg as BZ,Gf as G8,Gg as jZ,Hf as X8,Hg as MZ,If as B8,Ig as FZ,Jf as j8,Jg as LZ,Kf as Y6,Kg as DZ,Kh as yZ,Lf as M8,Lg as HZ,Lh as AZ,Mf as F8,Mg as NZ,Nf as L8,Ng as UZ,Of as D8,Pf as H8,Sg as R,Tg as i,Ug as xZ,Vg as SZ,Wg as RZ,Xg as OZ,Yg as _Z,_g as VZ,ah as CZ,bh as TZ,cg as T8,dg as P8,dh as PZ,eg as b8,ff as V6,fg as w8,gf as e5,gg as q8,gh as bZ,hf as W8,hg as v8,hh as wZ,if as Z8,ih as qZ,kf as $8,lh as vZ,og as e8,pg as q6,qf as k6,qg as WZ,qh as IZ,rf as C4,sf as B6,tf as T4,uf as P4,ug as ZZ,uh as fZ,vg as $Z,wg as YZ,yf as f6,yh as i4,zf as y6,zg as KZ,zh as z1}from"../chunk-daw2xr2v.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as j1,Bj as O8,Cj as _8,Di as k4,Ei as O4,Ej as d1,Fi as k1,Xi as h4,bj as Y1,ej as _4,fj as C1,gj as p1,hj as N8,ij as U8,jj as x8,kj as S8,lj as R8,xj as mW,yj as cW}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Pj as V8,Qj as k8,Rj as C8}from"../chunk-54v3y7mg.js";import{Tj as q}from"../chunk-110ecy3e.js";import{$j as g8,ak as m8,bk as U,ck as c8,dk as b,ek as u8,fk as p8}from"../chunk-26pfh03x.js";import{lk as A8,mk as h8,nk as E8}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import{Wk as QZ}from"../chunk-e0e43wvq.js";import{$k as d8,Yk as I8,Zk as f8,_k as y8,al as l8,bl as n8,cl as i8,dl as s8,el as o8,jl as a8,kl as t8,ll as r8}from"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{jm as w4,km as hZ,lm as EZ,mm as gZ,om as mZ}from"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{ym as C}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as u1}from"../chunk-7ztbpqed.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-4y0j6c56.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
3
3
  local currentKey = KEYS[1]
4
4
  local previousKey = KEYS[2]
5
5
  local limit = tonumber(ARGV[1])
@@ -69,4 +69,4 @@ ${W.resolution}.`;console.warn($),console.warn("To disable this message, import
69
69
  `));return await this.put(Z.data.upload_url,$,{forceBodyMode:"raw",enableAuth:!1,headers:{"Content-Type":"text/plain"},prefix:""}),Z}async complianceJobResult(W){let Z=W;while(Z.status!=="complete"){if(Z.status==="expired"||Z.status==="failed")throw Error("Job failed to be completed.");await new Promise((Q)=>setTimeout(Q,3500)),Z=(await this.complianceJob(W.id)).data}return(await this.get(W.download_url,void 0,{enableAuth:!1,prefix:""})).trim().split(`
70
70
  `).filter((Q)=>Q).map((Q)=>JSON.parse(Q))}async usage(W={}){return this.get("usage/tweets",W)}community(W,Z={}){return this.get("communities/:id",Z,{params:{id:W}})}searchCommunities(W,Z={}){return this.get("communities/search",{query:W,...Z})}}class _1 extends R1{constructor(){super(...arguments);this._prefix=M1}get readOnly(){return this}}class V1 extends O1{constructor(){super(...arguments);this._prefix=t}get readOnly(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new _1(this)}hideReply(W,Z){return this.put("tweets/:id/hidden",{hidden:Z},{params:{id:W}})}like(W,Z){return this.post("users/:id/likes",{tweet_id:Z},{params:{id:W}})}unlike(W,Z){return this.delete("users/:id/likes/:tweet_id",void 0,{params:{id:W,tweet_id:Z}})}retweet(W,Z){return this.post("users/:id/retweets",{tweet_id:Z},{params:{id:W}})}unretweet(W,Z){return this.delete("users/:id/retweets/:tweet_id",void 0,{params:{id:W,tweet_id:Z}})}tweet(W,Z={}){if(typeof W==="object")Z=W;else Z={text:W,...Z};return this.post("tweets",Z)}async uploadMedia(W,Z,$=1048576){let Q=Z.media_category;if(!Z.media_category){if(Z.media_type.includes("gif"))Q="tweet_gif";else if(Z.media_type.includes("image"))Q="tweet_image";else if(Z.media_type.includes("video"))Q="tweet_video"}let Y={additional_owners:Z.additional_owners,media_type:Z.media_type,total_bytes:W.length,media_category:Q},J=(await this.post("media/upload/initialize",Y)).data.id,z=Math.ceil(W.length/$),G=new Uint8Array(W);for(let B=0;B<z;B++){let j=B*$,D=Math.min(j+$,W.length),x=G.slice(j,D),V=Buffer.from(x),Q1={segment_index:B,media:V};await this.post(`media/upload/${J}/append`,Q1,{forceBodyMode:"form-data"})}if((await this.post(`media/upload/${J}/finalize`)).data.processing_info)await this.waitForMediaProcessing(J);return J}async waitForMediaProcessing(W){var Z;let Q=(await this.get("media/upload",{command:"STATUS",media_id:W})).data.processing_info;if(!Q)return;switch(Q.state){case"succeeded":return;case"failed":throw Error(`Media processing failed: ${(Z=Q.error)===null||Z===void 0?void 0:Z.message}`);case"pending":case"in_progress":{let Y=Q===null||Q===void 0?void 0:Q.check_after_secs;if(Y&&Y>0)await new Promise((K)=>setTimeout(K,Y*1000)),await this.waitForMediaProcessing(W)}}}createMediaMetadata(W,Z){return this.post("media/metadata",{id:W,metadata:Z})}reply(W,Z,$={}){var Q;let Y={in_reply_to_tweet_id:Z,...(Q=$.reply)!==null&&Q!==void 0?Q:{}};return this.post("tweets",{text:W,...$,reply:Y})}quote(W,Z,$={}){return this.tweet(W,{...$,quote_tweet_id:Z})}async tweetThread(W){var Z,$;let Q=[];for(let Y of W){let K=Q.length?Q[Q.length-1]:null,J={...typeof Y==="string"?{text:Y}:Y},z=K?K.data.id:(Z=J.reply)===null||Z===void 0?void 0:Z.in_reply_to_tweet_id,G=($=J.text)!==null&&$!==void 0?$:"";if(z)Q.push(await this.reply(G,z,J));else Q.push(await this.tweet(G,J))}return Q}deleteTweet(W){return this.delete("tweets/:id",void 0,{params:{id:W}})}async bookmark(W){let Z=await this.getCurrentUserV2Object();return this.post("users/:id/bookmarks",{tweet_id:W},{params:{id:Z.data.id}})}async deleteBookmark(W){let Z=await this.getCurrentUserV2Object();return this.delete("users/:id/bookmarks/:tweet_id",void 0,{params:{id:Z.data.id,tweet_id:W}})}follow(W,Z){return this.post("users/:id/following",{target_user_id:Z},{params:{id:W}})}unfollow(W,Z){return this.delete("users/:source_user_id/following/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Z}})}block(W,Z){return this.post("users/:id/blocking",{target_user_id:Z},{params:{id:W}})}unblock(W,Z){return this.delete("users/:source_user_id/blocking/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Z}})}mute(W,Z){return this.post("users/:id/muting",{target_user_id:Z},{params:{id:W}})}unmute(W,Z){return this.delete("users/:source_user_id/muting/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Z}})}createList(W){return this.post("lists",W)}updateList(W,Z={}){return this.put("lists/:id",Z,{params:{id:W}})}removeList(W){return this.delete("lists/:id",void 0,{params:{id:W}})}addListMember(W,Z){return this.post("lists/:id/members",{user_id:Z},{params:{id:W}})}removeListMember(W,Z){return this.delete("lists/:id/members/:user_id",void 0,{params:{id:W,user_id:Z}})}subscribeToList(W,Z){return this.post("users/:id/followed_lists",{list_id:Z},{params:{id:W}})}unsubscribeOfList(W,Z){return this.delete("users/:id/followed_lists/:list_id",void 0,{params:{id:W,list_id:Z}})}pinList(W,Z){return this.post("users/:id/pinned_lists",{list_id:Z},{params:{id:W}})}unpinList(W,Z){return this.delete("users/:id/pinned_lists/:list_id",void 0,{params:{id:W,list_id:Z}})}sendDmInConversation(W,Z){return this.post("dm_conversations/:dm_conversation_id/messages",Z,{params:{dm_conversation_id:W}})}sendDmToParticipant(W,Z){return this.post("dm_conversations/with/:participant_id/messages",Z,{params:{participant_id:W}})}createDmConversation(W){return this.post("dm_conversations",W)}}class JW extends _1{constructor(){super(...arguments);this._prefix=M1}get readWrite(){return this}}var zW=JW;class GW extends V1{constructor(){super(...arguments);this._prefix=t}get readWrite(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new zW(this)}}var XW=GW;class g1 extends W1{get v1(){if(this._v1)return this._v1;return this._v1=new U1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new O1(this)}async currentUser(W=!1){return await this.getCurrentUserObject(W)}async currentUserV2(W=!1){return await this.getCurrentUserV2Object(W)}search(W,Z){return this.v2.search(W,Z)}async generateAuthLink(W="oob",{authAccessType:Z,linkMode:$="authenticate",forceLogin:Q,screenName:Y}={}){let K=await this.post("https://api.x.com/oauth/request_token",{oauth_callback:W,x_auth_access_type:Z}),J=`https://api.x.com/oauth/${$}?oauth_token=${encodeURIComponent(K.oauth_token)}`;if(Q!==void 0)J+=`&force_login=${encodeURIComponent(Q)}`;if(Y!==void 0)J+=`&screen_name=${encodeURIComponent(Y)}`;if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth1RequestToken",{client:this._requestMaker,url:J,oauthResult:K});return{url:J,...K}}async login(W){let Z=this.getActiveTokens();if(Z.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept OAuth 1.0 login");let $=await this.post("https://api.x.com/oauth/access_token",{oauth_token:Z.accessToken,oauth_verifier:W}),Q=new this.constructor({appKey:Z.appKey,appSecret:Z.appSecret,accessToken:$.oauth_token,accessSecret:$.oauth_token_secret},this._requestMaker.clientSettings);return{accessToken:$.oauth_token,accessSecret:$.oauth_token_secret,userId:$.user_id,screenName:$.screen_name,client:Q}}async appLogin(){let W=this.getActiveTokens();if(W.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept app-only login");let $=await new this.constructor({username:W.appKey,password:W.appSecret},this._requestMaker.clientSettings).post("https://api.x.com/oauth2/token",{grant_type:"client_credentials"});return new this.constructor($.access_token,this._requestMaker.clientSettings)}generateOAuth2AuthLink(W,Z={}){var $,Q;if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. You can find your client ID in Twitter Developer Portal. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Y=($=Z.state)!==null&&$!==void 0?$:B1.generateRandomString(32),K=B1.getCodeVerifier(),J=B1.getCodeChallengeFromVerifier(K),z=(Q=Z.scope)!==null&&Q!==void 0?Q:"",G=Array.isArray(z)?z.join(" "):z,X=new URL("https://x.com/i/oauth2/authorize"),B={response_type:"code",client_id:this._requestMaker.clientId,redirect_uri:W,state:Y,code_challenge:J,code_challenge_method:"s256",scope:G};v.addQueryParamsToUrl(X,B);let j={url:X.toString(),state:Y,codeVerifier:K,codeChallenge:J};if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth2RequestToken",{client:this._requestMaker,result:j,redirectUri:W});return j}async loginWithOAuth2({code:W,codeVerifier:Z,redirectUri:$}){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Q=await this.post("https://api.x.com/2/oauth2/token",{code:W,code_verifier:Z,redirect_uri:$,grant_type:"authorization_code",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Q)}async refreshOAuth2Token(W){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Z=await this.post("https://api.x.com/2/oauth2/token",{refresh_token:W,grant_type:"refresh_token",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Z)}async revokeOAuth2Token(W,Z="access_token"){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");return await this.post("https://api.x.com/2/oauth2/revoke",{client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret,token:W,token_type_hint:Z})}parseOAuth2AccessTokenResult(W){let Z=new this.constructor(W.access_token,this._requestMaker.clientSettings),$=W.scope.split(" ").filter((Q)=>Q);return{client:Z,expiresIn:W.expires_in,accessToken:W.access_token,scope:$,refreshToken:W.refresh_token}}}class m1 extends g1{get v1(){if(this._v1)return this._v1;return this._v1=new x1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new V1(this)}get readOnly(){return this}}class M4 extends I{constructor(){super(...arguments);this._prefix=F1}}class F4 extends M4{constructor(){super(...arguments);this._prefix=F1}get readOnly(){return this}}class L4 extends I{constructor(){super(...arguments);this._prefix=L1}}class D4 extends L4{constructor(){super(...arguments);this._prefix=L1}get readOnly(){return this}}class BW extends D4{constructor(){super(...arguments);this._prefix=L1}get readWrite(){return this}}var jW=BW;class MW extends F4{constructor(){super(...arguments);this._prefix=F1}get readWrite(){return this}get sandbox(){if(this._sandbox)return this._sandbox;return this._sandbox=new jW(this)}}var FW=MW;class H4 extends m1{get v1(){if(this._v1)return this._v1;return this._v1=new G4(this)}get v2(){if(this._v2)return this._v2;return this._v2=new XW(this)}get readWrite(){return this}get ads(){if(this._ads)return this._ads;return this._ads=new FW(this)}static getErrors(W){var Z;if(typeof W!=="object")return[];if(!("data"in W))return[];return(Z=W.data.errors)!==null&&Z!==void 0?Z:[]}static getProfileImageInSize(W,Z){let $=W.split("/").pop(),Q=["normal","bigger","mini"],Y=W;for(let J of Q)if($.includes(`_${J}`)){Y=W.replace(`_${J}`,"");break}if(Z==="original")return Y;let K=Y.lastIndexOf(".");if(K!==-1){let J=Y.slice(K+1);return Y.slice(0,K)+"_"+Z+"."+J}else return Y+"_"+Z}}var v5={clientId:process.env.X_CLIENT_ID,clientSecret:process.env.X_SECRET,redirectPath:"/auth/oauth/x/callback",scope:["tweet.read","users.read","offline.access"]};class LW extends i{config;client;constructor(W={}){super();this.config={...v5,...W},this.client=new H4({clientId:this.config.clientId,clientSecret:this.config.clientSecret})}redirectUri(){return`${q()??""}${this.config.redirectPath}`}clientFor(W){return a(this,W,{name:"XOAuthProvider",resolve:this.config.resolve,clientId:this.config.clientId,clientSecret:this.config.clientSecret,redirectPath:this.config.redirectPath,staticRedirectUri:()=>this.redirectUri(),staticOrigin:()=>q()??""})}staticClient(){return{clientId:this.config.clientId,clientSecret:this.config.clientSecret,redirectUri:this.redirectUri()}}getRedirectUrl(W,Z){if(!Z)throw Error("XOAuthProvider needs the state and PKCE challenge gemi passes.");if(!this.config.resolve)return this.authorizationUrl(this.staticClient(),Z);return this.clientFor(W??null).then(($)=>{if(!$)throw Error("XOAuthProvider is not offered on this request.");return this.authorizationUrl($,Z)})}authorizationUrl(W,Z){let $=new URL("https://x.com/i/oauth2/authorize"),Q={response_type:"code",client_id:W.clientId,redirect_uri:W.redirectUri,state:Z.state,code_challenge:Z.codeChallenge,code_challenge_method:Z.codeChallengeMethod,scope:this.config.scope.join(" ")};for(let[Y,K]of Object.entries(Q))$.searchParams.set(Y,K);return $.toString()}async onCallback(W,Z){let $=W.search.get("code");if(!$)throw new R("missing_code");if(!Z?.codeVerifier)throw new R("invalid_state");let Q=this.config.resolve?await this.clientFor(W):this.staticClient();if(!Q)throw new R("unknown_provider");let Y=this.config.resolve?new H4({clientId:Q.clientId,clientSecret:Q.clientSecret}):this.client,K;try{K=await Y.loginWithOAuth2({code:$,codeVerifier:Z.codeVerifier,redirectUri:Q.redirectUri})}catch(j){throw console.error("X OAuth error: token exchange failed",j),new R("exchange_failed")}let{data:J}=await K.client.v2.me({"user.fields":["name","username","entities"]}),{name:z,email:G,id:X="",username:B}=J??{};return{name:z,email:G,username:B,providerId:X}}}var HW=["instagram_business_basic"],l={authorizeUrl:"https://www.instagram.com/oauth/authorize",tokenUrl:"https://api.instagram.com/oauth/access_token",graphUrl:"https://graph.instagram.com"};class m extends Error{status;type;code;constructor(W,Z,$,Q,Y){super(W,Y);this.status=Z;this.type=$;this.code=Q;this.name="InstagramApiError"}}async function N4(W){let Z=new URLSearchParams({client_id:W.clientId,client_secret:W.clientSecret,grant_type:"authorization_code",redirect_uri:W.redirectUri,code:W.code.replace(/#_$/,"")}),$=await x4(W.tokenUrl??l.tokenUrl,"code exchange",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Z.toString()}),Q=Array.isArray($.data)?$.data[0]:$,Y=Q?.access_token;if(typeof Y!=="string"||Y==="")throw new m("Instagram's code exchange answered without an access token.",200);let K=Q?.permissions;return{accessToken:Y,userId:o0(Q?.user_id),permissions:Array.isArray(K)?K.map(String):typeof K==="string"?K.split(/[\s,]+/).filter(Boolean):null}}async function NW(W){let Z=new URL("/access_token",W.graphUrl??l.graphUrl);return Z.searchParams.set("grant_type","ig_exchange_token"),Z.searchParams.set("client_secret",W.clientSecret),Z.searchParams.set("access_token",W.accessToken),xW(await x4(Z.toString(),"long-lived token exchange",{method:"GET"}))}async function UW(W){let Z=new URL("/refresh_access_token",W.graphUrl??l.graphUrl);return Z.searchParams.set("grant_type","ig_refresh_token"),Z.searchParams.set("access_token",W.accessToken),xW(await x4(Z.toString(),"token refresh",{method:"GET"}))}async function U4(W){let Z=W.graphApiVersion?`/${W.graphApiVersion.replace(/^\/+|\/+$/g,"")}`:"",$=new URL(`${Z}/me`,W.graphUrl??l.graphUrl);$.searchParams.set("fields",(W.fields??["user_id","username","name","account_type","profile_picture_url"]).join(",")),$.searchParams.set("access_token",W.accessToken);let Q=await x4($.toString(),"profile request",{method:"GET"}),Y=Array.isArray(Q.data)?Q.data[0]:Q,K=o0(Y?.user_id);if(!K)throw new m("Instagram's /me answered without a user_id.",200);let J={user_id:K},z=o0(Y?.id);if(z)J.id=z;for(let G of["username","name","account_type","profile_picture_url"]){let X=Y?.[G];if(typeof X==="string"&&X!=="")J[G]=X}return J}function xW(W){if(typeof W.access_token!=="string"||W.access_token==="")throw new m("Instagram answered without an access token.",200);let Z=Number(W.expires_in);return{accessToken:W.access_token,tokenType:typeof W.token_type==="string"?W.token_type:null,expiresIn:Number.isFinite(Z)&&Z>0?Z:null}}async function x4(W,Z,$){let Q;try{Q=await fetch(W,{...$,redirect:"error"})}catch(K){throw new m(`Instagram's ${Z} failed to reach Instagram.`,void 0,void 0,void 0,{cause:K})}let Y=a0(await Q.text().catch(()=>""));if(!Q.ok){let K=Y.error??{},J=DW(Y.error_type)??DW(K.type),z=Number(Y.code??K.code);throw new m(`Instagram refused the ${Z} (HTTP ${Q.status}${J?`, ${J}`:""}${Number.isFinite(z)?` ${z}`:""}).`,Q.status,J,Number.isFinite(z)?z:void 0)}return Y}function a0(W){try{let Z=JSON.parse(W.replace(/("(?:user_id|id)"\s*:\s*)(-?\d+)(?=\s*[,}\]])/g,'$1"$2"'));return Z&&typeof Z==="object"?Z:{}}catch{return{}}}function o0(W){if(typeof W==="string"&&W!=="")return W;if(typeof W==="number"&&Number.isSafeInteger(W))return String(W);return null}function DW(W){return typeof W==="string"&&W!==""?W:void 0}class SW extends i{createUsersWithoutEmail=!0;linkByEmail=!1;config;constructor(W={}){super();this.config={clientId:process.env.INSTAGRAM_CLIENT_ID??"",clientSecret:process.env.INSTAGRAM_CLIENT_SECRET??"",scopes:HW,redirectPath:"/auth/oauth/instagram/callback",authorizationParams:{},...W}}redirectUri(){return`${q()??""}${this.config.redirectPath}`}clientFor(W){return a(this,W,{name:"InstagramOAuthProvider",resolve:this.config.resolve,clientId:this.config.clientId,clientSecret:this.config.clientSecret,redirectPath:this.config.redirectPath,staticRedirectUri:()=>this.redirectUri(),staticOrigin:()=>q()??""})}staticClient(){return{clientId:this.config.clientId,clientSecret:this.config.clientSecret,redirectUri:this.redirectUri()}}getRedirectUrl(W,Z){if(!this.config.resolve)return this.authorizationUrl(this.staticClient(),Z);return this.clientFor(W??null).then(($)=>{if(!$)throw Error("InstagramOAuthProvider is not offered on this request.");return this.authorizationUrl($,Z)})}authorizationUrl(W,Z){let $=new URL(this.config.authorizeUrl??l.authorizeUrl),Q={...this.config.authorizationParams,client_id:W.clientId,redirect_uri:W.redirectUri,response_type:"code",scope:this.config.scopes.join(",")};if(Z)Q.state=Z.state;for(let[Y,K]of Object.entries(Q))$.searchParams.set(Y,K);return $.toString()}async onCallback(W){let Z=W.search.get("code");if(!Z)throw new R("missing_code");let $=this.config.resolve?await this.clientFor(W):this.staticClient();if(!$)throw new R("unknown_provider");let Q;try{let Y=await N4({code:Z,clientId:$.clientId,clientSecret:$.clientSecret,redirectUri:$.redirectUri,tokenUrl:this.config.tokenUrl});Q=await U4({accessToken:Y.accessToken,graphUrl:this.config.graphUrl,graphApiVersion:this.config.graphApiVersion,fields:["user_id","username","name"]})}catch(Y){if(Y instanceof m)throw console.error(`Instagram OAuth error: ${Y.message}`),new R("exchange_failed");throw Y}return{providerId:Q.user_id,username:Q.username,name:Q.name||Q.username}}}import{createHmac as I5,timingSafeEqual as f5}from"crypto";class c extends Error{reason;constructor(W,Z){super(Z);this.reason=W;this.name="MetaSignedRequestError"}}function y5(W,Z,$={}){if(!Z)throw Error("parseMetaSignedRequest needs the app secret.");if(typeof W!=="string")throw new c("malformed","No signed_request was given.");let Q=W.indexOf(".");if(Q<=0||Q===W.length-1||W.indexOf(".",Q+1)!==-1)throw new c("malformed","A signed_request is <signature>.<payload>.");let Y=W.slice(0,Q),K=W.slice(Q+1);if(!/^[A-Za-z0-9_-]+={0,2}$/.test(Y)||!/^[A-Za-z0-9_-]+={0,2}$/.test(K))throw new c("malformed","A signed_request is base64url.");let J=I5("sha256",Z).update(K).digest(),z=Buffer.from(Y,"base64url");if(z.length!==J.length||!f5(z,J))throw new c("bad_signature","The signed_request's signature does not match the app secret.");let G;try{let D=Buffer.from(K,"base64url").toString("utf8").replace(/("user_id"\s*:\s*)(-?\d+)(?=\s*[,}])/g,'$1"$2"');G=JSON.parse(D)}catch{throw new c("malformed","The signed_request's payload is not JSON.")}if(!G||typeof G!=="object")throw new c("malformed","The signed_request's payload is not an object.");if(String(G.algorithm??"").toUpperCase()!=="HMAC-SHA256")throw new c("unsupported_algorithm","Only HMAC-SHA256 signed_requests are accepted.");let X=Math.floor(($.now??Date.now())/1000),B=Number(G.expires);if(Number.isFinite(B)&&B>0&&B<X)throw new c("expired","The signed_request has expired.");let j=G.user_id;if((typeof j!=="string"||j==="")&&typeof j!=="number")throw new c("missing_user","The signed_request names no user.");return{...G,algorithm:String(G.algorithm),user_id:String(j)}}var A5=86400000;class R4 extends b{instagram;constructor(W={}){let Z={authorizeUrl:W.authorizeUrl??l.authorizeUrl,tokenUrl:W.tokenUrl??l.tokenUrl,graphUrl:W.graphUrl??l.graphUrl,graphApiVersion:W.graphApiVersion};super({authorizeUrl:Z.authorizeUrl,tokenUrl:Z.tokenUrl,clientId:W.clientId??process.env.INSTAGRAM_CLIENT_ID??"",clientSecret:W.clientSecret??process.env.INSTAGRAM_CLIENT_SECRET??"",scopes:W.scopes??["instagram_business_basic","instagram_business_content_publish"],scopeSeparator:",",pkce:!1,authorizationParams:W.authorizationParams??{},redirectUri:W.redirectUri,apiBaseUrl:Z.graphUrl,refreshLeewaySeconds:W.refreshLeewaySeconds??864000,multiple:W.multiple??!1,tokenPlacement:"query",isTokenRejected:t0,refreshStrategy:async($)=>{if(Date.now()-$.issuedAt.getTime()<A5){if($.reason==="rejected")throw new U("refresh_failed","Instagram refused the access token (OAuthException 190).",{status:401});return null}let Q=await S4("refresh_failed",()=>UW({accessToken:$.accessToken,graphUrl:Z.graphUrl}));return{accessToken:Q.accessToken,refreshToken:null,tokenType:Q.tokenType,expiresAt:Q.expiresIn===null?null:new Date(Date.now()+Q.expiresIn*1000),scopes:$.scopes,providerAccountId:$.providerAccountId}}});this.instagram=Z}async exchangeCode(W){let Z=await S4("exchange_failed",()=>N4({code:W.code,clientId:this.config.clientId,clientSecret:this.config.clientSecret,redirectUri:W.redirectUri,tokenUrl:this.instagram.tokenUrl})),$=await S4("exchange_failed",()=>NW({accessToken:Z.accessToken,clientSecret:this.config.clientSecret,graphUrl:this.instagram.graphUrl})),Q=await S4("exchange_failed",()=>U4({accessToken:$.accessToken,graphUrl:this.instagram.graphUrl,graphApiVersion:this.instagram.graphApiVersion}));return{accessToken:$.accessToken,refreshToken:null,tokenType:$.tokenType,expiresAt:$.expiresIn===null?null:new Date(Date.now()+$.expiresIn*1000),scopes:Z.permissions??this.config.scopes,providerAccountId:Q.user_id,profile:{...Q}}}refresh(){return Promise.reject(new U("refresh_failed","Instagram connections renew the access token itself; call connection.refresh()."))}}async function t0(W){if(W.status===401)return!0;if(W.status!==400)return!1;let Z=await W.clone().json().catch(()=>null);return Number(Z?.error?.code)===190}async function S4(W,Z){try{return await Z()}catch($){if($ instanceof m)throw new U(W,$.message,{cause:$,status:$.status===200?502:$.status});throw $}}async function S(W,Z,$){let Q;try{Q=await $()}catch(K){if(K instanceof U)throw K;throw new U(Z,`The ${W} request failed.`,{cause:K})}let Y=await Q.json().catch(()=>null);if(!Q.ok||Y===null||typeof Y!=="object")throw new U(Z,`The ${W} request was refused (HTTP ${Q.status}).`,{status:Q.ok?502:Q.status});return Y}function $1(W,Z,$={}){return fetch(W,{headers:{...$,Authorization:`Bearer ${Z}`,Accept:"application/json"},redirect:"error"})}function f(W,Z,$){if(W.connectionProvider()!==Z)throw TypeError(`${$} takes a connection to this provider; "${W.provider}" is configured with another one.`)}function F(W){return typeof W==="string"&&W!==""?W:null}var y=F;function u(W){return new U("exchange_failed",`${W} did not say which account was connected.`,{status:502})}var RW=["pages_show_list","pages_read_engagement","pages_manage_posts"];class OW extends b{configId;graphApiVersion;constructor(W={}){let Z=W.graphApiVersion?.replace(/^\/+|\/+$/g,""),$=Z?`/${Z}`:"",Q=W.apiBaseUrl??"https://graph.facebook.com";super({authorizeUrl:W.authorizeUrl??`${W.dialogUrl??"https://www.facebook.com"}${$}/dialog/oauth`,tokenUrl:W.tokenUrl??`${Q}${$}/oauth/access_token`,revokeUrl:W.revokeUrl??`${Q}${$}/me/permissions`,apiBaseUrl:Q,clientId:W.clientId??process.env.FACEBOOK_CLIENT_ID??"",clientSecret:W.clientSecret??process.env.FACEBOOK_CLIENT_SECRET??"",scopes:W.scopes??RW,scopeSeparator:",",pkce:!1,authorizationParams:W.authorizationParams??{},redirectUri:W.redirectUri,refreshLeewaySeconds:W.refreshLeewaySeconds??60,multiple:W.multiple??!1,tokenPlacement:"query",revokeTokenHint:"access_token",isTokenRejected:t0,refreshStrategy:async(Y)=>{if(Y.reason==="rejected")throw new U("refresh_failed","Facebook refused the access token (OAuthException 190).",{status:401});return null}});this.configId=W.configId??(process.env.FACEBOOK_CONFIG_ID||void 0),this.graphApiVersion=Z||void 0}authorizationUrl(W){let Z=new URL(super.authorizationUrl(W));if(this.configId)Z.searchParams.delete("scope"),Z.searchParams.set("config_id",this.configId);return Z.toString()}async exchangeCode(W){let Z=await this.tokenCall({client_id:this.config.clientId,client_secret:this.config.clientSecret,redirect_uri:W.redirectUri,code:W.code}),$=await this.tokenCall({grant_type:"fb_exchange_token",client_id:this.config.clientId,client_secret:this.config.clientSecret,fb_exchange_token:Z.accessToken}),Q=$.accessToken,Y=await S("Facebook /me","exchange_failed",()=>fetch(this.graphUrl(this.path("/me",{fields:"id,name,picture{url}"}),Q),{redirect:"error"})),K=y(Y.id);if(!K)throw u("Facebook");let J=await S("Facebook /me/permissions","exchange_failed",()=>fetch(this.graphUrl(this.path("/me/permissions"),Q),{redirect:"error"})),z=(Array.isArray(J.data)?J.data:[]).filter((B)=>B.status==="granted"&&typeof B.permission==="string").map((B)=>B.permission),G=await this.listPages((B)=>fetch(this.graphUrl(B,Q),{redirect:"error"}),"exchange_failed"),X={id:K,name:F(Y.name),username:null,avatarUrl:r0(Y.picture),pages:G.map(({accessToken:B,...j})=>j)};return{accessToken:Q,refreshToken:null,tokenType:$.tokenType,expiresAt:$.expiresIn===null?null:new Date(Date.now()+$.expiresIn*1000),scopes:z.length>0?z:this.config.scopes,providerAccountId:K,profile:{...X}}}refresh(){return Promise.reject(new U("refresh_failed","Facebook issues no refresh token; reconnect the account."))}async revoke(W){let Z=new URL(this.config.revokeUrl);Z.searchParams.set("access_token",W);let $;try{$=await fetch(Z,{method:"DELETE",redirect:"error"})}catch(Q){throw new U("revoke_failed","The revocation request failed.",{cause:Q})}if(await $.body?.cancel().catch(()=>{}),!$.ok)throw new U("revoke_failed",`Facebook refused the revocation (HTTP ${$.status}).`,{status:$.status})}async profile(W){f(W,this,"FacebookConnectionProvider.profile()");let Z=await S("Facebook /me","request_failed",()=>W.fetch(this.path("/me",{fields:"id,name,picture{url}"}))),$=y(Z.id);if(!$)throw u("Facebook");let Q=await this.pages(W);return{id:$,name:F(Z.name),username:null,avatarUrl:r0(Z.picture),pages:Q.map((Y)=>Y.toJSON())}}async pages(W){return f(W,this,"FacebookConnectionProvider.pages()"),(await this.listPages(($)=>W.fetch($),"request_failed")).map(($)=>new e0(W,$))}path(W,Z={}){let $=this.graphApiVersion?`/${this.graphApiVersion}`:"",Q=new URL(`${$}${W}`,this.config.apiBaseUrl);for(let[Y,K]of Object.entries(Z))Q.searchParams.set(Y,K);return`${Q.pathname}${Q.search}`}graphUrl(W,Z){let $=new URL(W,this.config.apiBaseUrl);if($.origin!==new URL(this.config.apiBaseUrl).origin)throw new U("forbidden_url","Facebook paged to another origin.");return $.searchParams.set("access_token",Z),$}async listPages(W,Z){let $=[],Q=this.path("/me/accounts",{fields:"id,name,category,tasks,access_token,picture{url}",limit:"100"});for(let Y=0;Q!==null&&Y<20;Y++){let K=Q,J=await S("Facebook /me/accounts",Z,()=>W(K));for(let G of Array.isArray(J.data)?J.data:[]){let X=y(G.id);if(!X)continue;$.push({id:X,name:F(G.name),category:F(G.category),tasks:Array.isArray(G.tasks)?G.tasks.filter((B)=>typeof B==="string"):[],avatarUrl:r0(G.picture),accessToken:F(G.access_token)})}let z=J.paging??{};Q=typeof z.next==="string"?z.next:null}return $}async tokenCall(W){let Z=new URL(this.config.tokenUrl);for(let[K,J]of Object.entries(W))Z.searchParams.set(K,J);let $=await S("Facebook token","exchange_failed",()=>fetch(Z,{headers:{Accept:"application/json"},redirect:"error"})),Q=F($.access_token);if(!Q)throw new U("exchange_failed","Facebook answered the code exchange without a token.",{status:502});let Y=Number($.expires_in);return{accessToken:Q,tokenType:F($.token_type),expiresIn:Number.isFinite(Y)&&Y>0?Y:null}}}class e0{connection;id;name;category;tasks;avatarUrl;#W;constructor(W,Z){this.connection=W;this.id=Z.id,this.name=Z.name,this.category=Z.category,this.tasks=Z.tasks,this.avatarUrl=Z.avatarUrl,this.#W=Z.accessToken}get canPost(){return this.tasks.includes("CREATE_CONTENT")}accessToken(){if(this.#W===null)throw new U("request_failed",`Facebook gave no Page token for Page ${this.id}.`);return this.#W}fetch(W,Z={}){return this.connection.fetchWithToken(this.accessToken(),W,Z)}toJSON(){return{id:this.id,name:this.name,category:this.category,tasks:[...this.tasks],avatarUrl:this.avatarUrl}}[Symbol.for("nodejs.util.inspect.custom")](){return{FacebookPage:this.toJSON()}}}function r0(W){let Z=W?.data;return F(Z?.url)}var VW=["openid","profile","w_member_social"],h5=["w_organization_social","r_organization_social"];class kW extends b{apiVersion;constructor(W={}){super({authorizeUrl:W.authorizeUrl??"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:W.tokenUrl??"https://www.linkedin.com/oauth/v2/accessToken",revokeUrl:W.revokeUrl,apiBaseUrl:W.apiBaseUrl??"https://api.linkedin.com",clientId:W.clientId??process.env.LINKEDIN_CLIENT_ID??"",clientSecret:W.clientSecret??process.env.LINKEDIN_CLIENT_SECRET??"",scopes:W.scopes??VW,pkce:!1,authorizationParams:W.authorizationParams??{},redirectUri:W.redirectUri,refreshLeewaySeconds:W.refreshLeewaySeconds??86400,multiple:W.multiple??!1});this.apiVersion=W.apiVersion??"202610"}async exchangeCode(W){let Z=await super.exchangeCode(W),$=_W(await S("LinkedIn userinfo","exchange_failed",()=>$1(this.userInfoUrl(),Z.accessToken)));return{...Z,providerAccountId:$.id,profile:{...$}}}async profile(W){return f(W,this,"LinkedInConnectionProvider.profile()"),_W(await S("LinkedIn userinfo","request_failed",()=>W.fetch(this.userInfoUrl())))}async organizations(W){f(W,this,"LinkedInConnectionProvider.organizations()");let Z=new URL("/rest/organizationAcls",this.config.apiBaseUrl);Z.searchParams.set("q","roleAssignee"),Z.searchParams.set("state","APPROVED");let $=await S("LinkedIn organizationAcls","request_failed",()=>W.fetch(Z,{headers:this.restHeaders()})),Q=new Map;for(let J of Array.isArray($.elements)?$.elements:[]){let z=F(J.organization)??F(J.organizationTarget),G=z?.match(/^urn:li:organization:(\d+)$/)?.[1];if(!z||!G||Q.has(G))continue;Q.set(G,{id:G,urn:z,role:F(J.role)??"UNKNOWN",name:null,vanityName:null})}if(Q.size===0)return[];let Y=`/rest/organizations?ids=List(${[...Q.keys()].join(",")})`,K=await W.fetch(Y,{headers:this.restHeaders()});if(K.ok){let J=await K.json().catch(()=>({}));for(let[z,G]of Object.entries(J.results??{})){let X=Q.get(z);if(!X)continue;X.name=F(G.localizedName),X.vanityName=F(G.vanityName)}}else await K.body?.cancel().catch(()=>{});return[...Q.values()]}restHeaders(){return{"LinkedIn-Version":this.apiVersion,"X-Restli-Protocol-Version":"2.0.0"}}userInfoUrl(){return new URL("/v2/userinfo",this.config.apiBaseUrl)}}function _W(W){let Z=y(W.sub);if(!Z)throw u("LinkedIn");let $=F(W.given_name),Q=F(W.family_name);return{id:Z,name:F(W.name)??([$,Q].filter(Boolean).join(" ")||null),username:null,avatarUrl:F(W.picture),authorUrn:`urn:li:person:${Z}`,email:F(W.email)}}var TW=["user.info.basic","video.publish","video.upload"];class PW extends b{constructor(W={}){super({authorizeUrl:W.authorizeUrl??"https://www.tiktok.com/v2/auth/authorize/",tokenUrl:W.tokenUrl??"https://open.tiktokapis.com/v2/oauth/token/",revokeUrl:W.revokeUrl??"https://open.tiktokapis.com/v2/oauth/revoke/",apiBaseUrl:W.apiBaseUrl??"https://open.tiktokapis.com",clientId:W.clientKey??W.clientId??process.env.TIKTOK_CLIENT_KEY??"",clientSecret:W.clientSecret??process.env.TIKTOK_CLIENT_SECRET??"",clientIdParam:"client_key",scopes:W.scopes??TW,scopeSeparator:",",pkce:!1,revokeTokenHint:"access_token",authorizationParams:W.authorizationParams??{},redirectUri:W.redirectUri,refreshLeewaySeconds:W.refreshLeewaySeconds??300,multiple:W.multiple??!1})}async exchangeCode(W){let Z=await super.exchangeCode(W),$=CW(await S("TikTok user info","exchange_failed",()=>$1(this.userInfoUrl(Z.scopes),Z.accessToken)),"exchange_failed");return{...Z,providerAccountId:$.id,profile:{...$}}}async profile(W){return f(W,this,"TikTokConnectionProvider.profile()"),CW(await S("TikTok user info","request_failed",()=>W.fetch(this.userInfoUrl([...W.scopes]))),"request_failed")}userInfoUrl(W){let Z=new URL("/v2/user/info/",this.config.apiBaseUrl),$=["open_id","union_id","avatar_url","display_name"];if(W.includes("user.info.profile"))$.push("username");return Z.searchParams.set("fields",$.join(",")),Z}}function CW(W,Z){let $=W.error??{};if(typeof $.code==="string"&&$.code!=="ok")throw new U(Z,`TikTok refused the user info request (${E5($.code)}).`,{status:400});let Q=(W.data??{}).user,Y=y(Q?.open_id);if(!Q||!Y)throw u("TikTok");return{id:Y,name:F(Q.display_name),username:F(Q.username),avatarUrl:F(Q.avatar_url),unionId:F(Q.union_id)}}function E5(W){return/^[a-z0-9_]{1,64}$/.test(W)?W:"error"}var wW=["https://www.googleapis.com/auth/youtube.upload","https://www.googleapis.com/auth/youtube.readonly"];class qW extends b{constructor(W={}){super({authorizeUrl:W.authorizeUrl??"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:W.tokenUrl??"https://oauth2.googleapis.com/token",revokeUrl:W.revokeUrl??"https://oauth2.googleapis.com/revoke",apiBaseUrl:W.apiBaseUrl??"https://www.googleapis.com",clientId:W.clientId??process.env.GOOGLE_CLIENT_ID??"",clientSecret:W.clientSecret??process.env.GOOGLE_CLIENT_SECRET??"",scopes:W.scopes??wW,pkce:!0,authorizationParams:{access_type:"offline",prompt:"consent",include_granted_scopes:"true",...W.authorizationParams},redirectUri:W.redirectUri,refreshLeewaySeconds:W.refreshLeewaySeconds??300,multiple:W.multiple??!1})}async exchangeCode(W){let Z=await super.exchangeCode(W),$=bW(await S("YouTube channel","exchange_failed",()=>$1(this.channelUrl(),Z.accessToken)));return{...Z,providerAccountId:$.id,profile:{...$}}}async profile(W){return f(W,this,"YouTubeConnectionProvider.profile()"),bW(await S("YouTube channel","request_failed",()=>W.fetch(this.channelUrl())))}channelUrl(){let W=new URL("/youtube/v3/channels",this.config.apiBaseUrl);return W.searchParams.set("part","snippet"),W.searchParams.set("mine","true"),W}}function bW(W){let[Z]=Array.isArray(W.items)?W.items:[],$=y(Z?.id);if(!$)throw u("YouTube (the Google account has no channel)");let Q=Z.snippet??{},Y=Q.thumbnails??{},K=Y.high?.url??Y.medium?.url??Y.default?.url;return{id:$,name:F(Q.title),username:F(Q.customUrl),avatarUrl:F(K)}}var IW=["tweet.read","tweet.write","users.read","media.write","offline.access"];class fW extends b{constructor(W={}){super({authorizeUrl:W.authorizeUrl??"https://x.com/i/oauth2/authorize",tokenUrl:W.tokenUrl??"https://api.x.com/2/oauth2/token",revokeUrl:W.revokeUrl??"https://api.x.com/2/oauth2/revoke",apiBaseUrl:W.apiBaseUrl??"https://api.x.com",clientId:W.clientId??process.env.X_CLIENT_ID??"",clientSecret:W.clientSecret??process.env.X_CLIENT_SECRET??process.env.X_SECRET??"",scopes:W.scopes??IW,clientAuth:"basic",pkce:!0,authorizationParams:W.authorizationParams??{},redirectUri:W.redirectUri,refreshLeewaySeconds:W.refreshLeewaySeconds??300,multiple:W.multiple??!1})}async exchangeCode(W){let Z=await super.exchangeCode(W),$=vW(await S("X profile","exchange_failed",()=>$1(this.profileUrl(),Z.accessToken)));return{...Z,providerAccountId:$.id,profile:{...$}}}async profile(W){return f(W,this,"XConnectionProvider.profile()"),vW(await S("X profile","request_failed",()=>W.fetch(this.profileUrl())))}profileUrl(){let W=new URL("/2/users/me",this.config.apiBaseUrl);return W.searchParams.set("user.fields","profile_image_url"),W}}function vW(W){let Z=W.data??{},$=y(Z.id);if(!$)throw u("X");return{id:$,name:F(Z.name),username:F(Z.username),avatarUrl:F(Z.profile_image_url)}}class _ extends Error{code;status;graphCode;graphSubcode;containerId;constructor(W,Z,$={}){super(Z);this.code=W;this.name="InstagramPublishError",this.status=$.status,this.graphCode=$.graphCode,this.graphSubcode=$.graphSubcode,this.containerId=$.containerId}}var w={captionLength:2200,hashtags:30,mentions:20,userTags:20,carouselMin:2,carouselMax:10},yW="instagram_business_content_publish",g5={for(W,Z={}){return new $6(W,Z)}};class $6{connection;version;pollIntervalMs;maxPollIntervalMs;timeoutMs;constructor(W,Z={}){this.connection=W;let $=W.connectionProvider();if(!($ instanceof R4))throw TypeError(`Instagram.for() takes an Instagram connection; "${W.provider}" is not an InstagramConnectionProvider.`);let Q=Z.graphApiVersion??$.instagram.graphApiVersion;this.version=Q?`/${Q.replace(/^\/+|\/+$/g,"")}`:"",this.pollIntervalMs=Z.pollIntervalMs??2000,this.maxPollIntervalMs=Z.maxPollIntervalMs??1e4,this.timeoutMs=Z.timeoutMs??300000}async publishImage(W,Z={}){if(c1("imageUrl",W.imageUrl),Z6(W.caption),W.altText!==void 0&&typeof W.altText!=="string")T("altText must be a string.");if(W.userTags!==void 0)t5(W.userTags);let $=this.start(Z),Q=await this.createContainer({image_url:W.imageUrl,caption:W.caption,alt_text:W.altText,user_tags:W.userTags?JSON.stringify(W.userTags):void 0,location_id:W.locationId},$);return this.publishContainer(Q,!1,$)}async publishCarousel(W,Z={}){let $=W.items;if(!Array.isArray($)||$.length<w.carouselMin||$.length>w.carouselMax)T(`A carousel takes ${w.carouselMin} to ${w.carouselMax} items.`);$.forEach((z,G)=>gW(`items[${G}]`,z)),Z6(W.caption);let Q=this.start(Z),Y=[];for(let z of $)Y.push(await this.createContainer(z.videoUrl!==void 0?{media_type:"VIDEO",video_url:z.videoUrl,is_carousel_item:"true"}:{image_url:z.imageUrl,is_carousel_item:"true"},Q));for(let[z,G]of $.entries())if(G.videoUrl!==void 0)await this.waitUntilFinished(Y[z],Q);let K=$.some((z)=>z.videoUrl!==void 0),J=await this.createContainer({media_type:"CAROUSEL",children:Y.join(","),caption:W.caption},Q);return this.publishContainer(J,K,Q)}async publishReel(W,Z={}){if(c1("videoUrl",W.videoUrl),W.coverUrl!==void 0)c1("coverUrl",W.coverUrl);if(Z6(W.caption),W.thumbOffset!==void 0&&!(Number.isInteger(W.thumbOffset)&&W.thumbOffset>=0))T("thumbOffset must be a whole number of milliseconds, 0 or more.");let $=this.start(Z),Q=await this.createContainer({media_type:"REELS",video_url:W.videoUrl,caption:W.caption,cover_url:W.coverUrl,share_to_feed:W.shareToFeed===void 0?void 0:String(W.shareToFeed),thumb_offset:W.thumbOffset===void 0?void 0:String(W.thumbOffset)},$);return this.publishContainer(Q,!0,$)}async publishStory(W,Z={}){gW("story",W);let $=this.start(Z),Q=W.videoUrl!==void 0,Y=await this.createContainer(Q?{media_type:"STORIES",video_url:W.videoUrl}:{media_type:"STORIES",image_url:W.imageUrl},$);return this.publishContainer(Y,Q,$)}async publishingLimit(W={}){let Z=this.start(W),$=await this.call("publishing limit request",`/${this.accountId()}/content_publishing_limit?fields=quota_usage,config`,void 0,Z),Q=Array.isArray($.data)?$.data[0]:$,Y=Q?.config??{},K=W6(Q?.quota_usage,0),J=W6(Y.quota_total,100);return{quotaUsage:K,quotaTotal:J,quotaDurationSeconds:W6(Y.quota_duration,86400),remaining:Math.max(0,J-K)}}async containerStatus(W,Z={}){return this.readStatus(W,this.start(Z))}start(W){if(W.signal?.throwIfAborted(),!this.connection.hasScopes(yW))throw new _("permission_denied",`The Instagram connection was not granted ${yW}; connect it again with that scope.`);return{signal:W.signal,deadline:Date.now()+(W.timeoutMs??this.timeoutMs)}}accountId(){let W=this.connection.providerAccountId;if(!W)throw new _("invalid_input","The Instagram connection has no account id (providerAccountId).");return W}async createContainer(W,Z){let $=await this.call("media container request",`/${this.accountId()}/media`,W,Z);return hW($,"media container request")}async publishContainer(W,Z,$){try{if(Z)await this.waitUntilFinished(W,$);let Q=await this.publishOnce(W,Z,$);return{mediaId:Q,permalink:await this.permalink(Q,$)}}catch(Q){throw Q instanceof _?o5(Q,W):Q}}async publishOnce(W,Z,$){try{return await this.mediaPublish(W,$)}catch(Q){if(!(Q instanceof _))throw Q;if(Q.code==="transient"){let{statusCode:Y}=await this.readStatus(W,$);if(Y==="PUBLISHED")throw new _("unconfirmed","Instagram's media_publish failed, but the container reads PUBLISHED: the post is probably live. Do not publish it again.",{status:Q.status,graphCode:Q.graphCode,graphSubcode:Q.graphSubcode});if(Y!=="FINISHED")throw Q;return this.mediaPublish(W,$)}if(s5(Q)&&!Z)return await this.waitUntilFinished(W,$),this.mediaPublish(W,$);throw Q}}async mediaPublish(W,Z){let $=await this.call("media_publish request",`/${this.accountId()}/media_publish`,{creation_id:W},Z,{retry:!1});return hW($,"media_publish request")}async permalink(W,Z){try{let $=await this.call("permalink request",`/${W}?fields=permalink`,void 0,Z,{retry:!1});return typeof $.permalink==="string"?$.permalink:void 0}catch{return}}async readStatus(W,Z){if(!/^\d+$/.test(W))T("A container id is a string of digits.");let $=await this.call("container status request",`/${W}?fields=status_code,status`,void 0,Z),Q=$.status_code;if(typeof Q!=="string"||!m5.has(Q))throw new _("graph_error","Instagram's container status answered without a known status_code.",{status:200,containerId:W});let Y={id:W,statusCode:Q};if(typeof $.status==="string"&&$.status!=="")Y.status=uW($.status);return Y}async waitUntilFinished(W,Z){let $=this.pollIntervalMs;for(;;){let{statusCode:Q,status:Y}=await this.readStatus(W,Z);if(Q==="FINISHED")return;if(Q==="PUBLISHED")throw new _("invalid_input","That media container has been published already.",{containerId:W});if(Q==="ERROR")throw new _("invalid_media",`Instagram could not process the media${Y?` (${Y})`:""}.`,{containerId:W});if(Q==="EXPIRED")throw new _("expired","The media container expired before it was published.",{containerId:W});let K=Z.deadline-Date.now();if(K<=0)throw new _("timeout","Instagram had not finished processing the media in time; the container is still processing.",{containerId:W});await a5(Math.min($,K),Z.signal),$=Math.min($*1.5,this.maxPollIntervalMs)}}async call(W,Z,$,Q,{retry:Y=!0}={}){try{return await this.callOnce(W,Z,$,Q)}catch(K){if(!Y||!(K instanceof _)||K.code!=="transient")throw K;return this.callOnce(W,Z,$,Q)}}async callOnce(W,Z,$,Q){Q.signal?.throwIfAborted();let Y={method:$?"POST":"GET",signal:Q.signal};if($){let z=new URLSearchParams;for(let[G,X]of Object.entries($))if(X!==void 0)z.set(G,X);Y.body=z}let K;try{K=await this.connection.fetch(`${this.version}${Z}`,Y)}catch(z){if(Q.signal?.aborted)throw Q.signal.reason;if(z instanceof TypeError)throw new _("transient",`Instagram's ${W} failed to reach Instagram.`);throw z}let J=a0(await K.text().catch(()=>""));if(K.ok)return J;throw i5(W,K.status,J)}}var m5=new Set(["EXPIRED","ERROR","FINISHED","IN_PROGRESS","PUBLISHED"]),c5=new Set([4,17,32,613,80002]),u5=new Set([3,10]),p5=new Set([9004,352,36000,36001,36002,36003,36004]),d5=new Set([2207004,2207005,2207006,2207009,2207023,2207026,2207028,2207052]),l5=new Set([102,190,463,467]),n5=new Set([2207001,2207003,2207053]),AW={code:9007,subcode:2207027};function i5(W,Z,$){let Q=$.error??{},Y=EW(Q.code),K=EW(Q.error_subcode),J=typeof Q.type==="string"&&Q.type!==""?Q.type:void 0,z=typeof Q.message==="string"&&Q.message!==""?`: ${uW(Q.message)}`:"",G=[Y,K].filter((j)=>j!==void 0).join("/"),X=`Instagram refused the ${W} (HTTP ${Z}${J?`, ${J}`:""}${G?` ${G}`:""})${z}`,B="graph_error";if(K===2207042)B="quota_exceeded";else if(K===2207010)B="invalid_input";else if(Y!==void 0&&c5.has(Y))B="rate_limited";else if(Y!==void 0&&l5.has(Y))B="reconnect_required";else if(Y!==void 0&&(u5.has(Y)||Y>=200&&Y<=299))B="permission_denied";else if(Y!==void 0&&p5.has(Y)||K!==void 0&&d5.has(K))B="invalid_media";else if(Q.is_transient===!0||Y===1||Y===2||K!==void 0&&n5.has(K)||Z>=500||Z===429)B=Z===429?"rate_limited":"transient";return new _(B,X,{status:Z,graphCode:Y,graphSubcode:K})}function s5(W){return W.graphCode===AW.code||W.graphSubcode===AW.subcode}function o5(W,Z){if(W.containerId)return W;return new _(W.code,W.message,{status:W.status,graphCode:W.graphCode,graphSubcode:W.graphSubcode,containerId:Z})}function uW(W){return W.replace(/access_token=[^&\s"']*/gi,"access_token=[redacted]").replace(/\b(?:IG|EAA)[A-Za-z0-9_-]{20,}/g,"[redacted]").slice(0,500)}function hW(W,Z){let $=W.id;if(typeof $==="string"&&$!=="")return $;if(typeof $==="number"&&Number.isSafeInteger($))return String($);throw new _("graph_error",`Instagram's ${Z} answered without an id.`,{status:200})}function EW(W){let Z=Number(W);return W!==void 0&&W!==null&&Number.isFinite(Z)?Z:void 0}function W6(W,Z){let $=Number(W);return W!==void 0&&W!==null&&Number.isFinite($)?$:Z}function a5(W,Z){return new Promise(($,Q)=>{if(Z?.aborted)return Q(Z.reason);let Y=()=>{clearTimeout(K),Q(Z?.reason)},K=setTimeout(()=>{Z?.removeEventListener("abort",Y),$()},W);Z?.addEventListener("abort",Y,{once:!0})})}function T(W){throw new _("invalid_input",W)}function Z6(W){if(W===void 0)return;if(typeof W!=="string")T("caption must be a string.");if([...W].length>w.captionLength)T(`A caption takes at most ${w.captionLength} characters.`);if((W.match(/#[\p{L}\p{N}_]+/gu)??[]).length>w.hashtags)T(`A caption takes at most ${w.hashtags} hashtags.`);if((W.match(/(?<![\p{L}\p{N}_.@])@[\p{L}\p{N}_.]+/gu)??[]).length>w.mentions)T(`A caption takes at most ${w.mentions} @mentions.`)}function t5(W){if(!Array.isArray(W)||W.length>w.userTags)T(`userTags takes at most ${w.userTags} tags.`);for(let Z of W){let $=(Q)=>typeof Q==="number"&&Q>=0&&Q<=1;if(typeof Z?.username!=="string"||Z.username===""||!$(Z.x)||!$(Z.y))T("Each user tag needs a username, and x and y between 0 and 1.")}}function gW(W,Z){let $=Z?.imageUrl!==void 0,Q=Z?.videoUrl!==void 0;if($===Q)T(`${W} takes exactly one of imageUrl and videoUrl.`);if($)c1(`${W}.imageUrl`,Z.imageUrl);else c1(`${W}.videoUrl`,Z.videoUrl)}function c1(W,Z){let $;try{$=new URL(Z)}catch{T(`${W} is not an absolute URL.`)}if($.protocol!=="https:")T(`${W} must be an https URL: Instagram fetches the media from it.`);let Q=$.hostname.replace(/^\[|\]$/g,"").toLowerCase(),Y=mW(Q);if(Y?cW(Y)!==null:!Q.includes(".")||/(^|\.)(localhost|local|internal)$/.test(Q))T(`${W} must be a public URL: Instagram fetches the media from it.`)}class Q6{describe;rollout;when;serverOnly;salt;constructor(W={}){if(W.rollout!==void 0){let{rollout:Z}=W;if(!Number.isFinite(Z)||Z<0||Z>100)throw Error(`A feature's \`rollout\` must be a number between 0 and 100, received ${String(Z)}.`)}this.describe=W.describe,this.rollout=W.rollout,this.when=W.when,this.serverOnly=W.serverOnly??!1,this.salt=W.salt}}function r5(W={}){return new Q6(W)}class pW extends Y6{rows=new Map;constructor(W={}){super();for(let[Z,$]of Object.entries(W))this.rows.set(Z,{key:Z,active:$})}async load(){return[...this.rows.values()].map((W)=>({...W}))}async write(W,Z,$){return this.rows.set(W,{key:W,active:Z,updatedBy:$.actor,updatedAt:new Date}),{actorRecorded:!0}}}export{Q9 as workflowEnded,TZ as viewRouteConfigDefaults,E9 as translationConfigDefaults,O4 as toRangeHeaderValue,X8 as subjectFor,vZ as strictCspPolicy,O8 as sniffContentType,O9 as scheduleConfigDefaults,k4 as resolveRange,Q$ as redisConfigDefaults,W$ as rateLimiterConfigDefaults,iZ as queueConfigDefaults,y5 as parseMetaSignedRequest,k1 as parseContentRange,Z8 as mintSessionToken,AZ as middlewareConfigDefaults,B9 as mcpCallOf,gZ as mailConfigDefaults,k8 as logConfigDefaults,W8 as isSessionToken,F5 as isFixedSignInCode,MZ as isFinalRunStatus,v6 as isBroadcastEvent,_8 as isActiveContentType,z8 as inRollout,OZ as imageConfigDefaults,M5 as fixedSignInCode,x8 as filesystemConfigDefaults,u9 as featuresConfigDefaults,V9 as eventConfigDefaults,G8 as evaluateFeature,n8 as encodeCursor,bZ as documentScriptCspHash,P9 as discoverWorkflows,q9 as discoverListeners,T9 as discoverJobs,b9 as discoverCronJobs,w9 as discoverCommands,h9 as defineTranslationConfig,R9 as defineScheduleConfig,XZ as defineRunsConfig,kZ as defineRouteConfig,$$ as defineRedisConfig,e9 as defineRateLimiterConfig,nZ as defineQueueConfig,yZ as defineMiddlewareConfig,EZ as defineMailConfig,V8 as defineLogConfig,RZ as defineImageConfig,U8 as defineFilesystemConfig,c9 as defineFeaturesConfig,r5 as defineFeature,_9 as defineEventConfig,iW as defineEncryptionConfig,N9 as defineCommandConfig,x9 as defineCommand,d8 as defineChangeFeedConfig,T8 as defineCacheConfig,ZZ as defineBroadcastConfig,Q8 as defineAuthConfig,i8 as decodeCursor,dZ as createWorkflowTableStatements,DZ as createRunsTableStatements,U9 as commandConfigDefaults,l8 as changeFeedConfigDefaults,P8 as cacheConfigDefaults,J8 as bucketOf,K8 as bucketKey,$Z as broadcastConfigDefaults,u4 as bearerToken,Y8 as authConfigDefaults,_4 as assertDeletablePrefix,CZ as apiRouteConfigDefaults,qW as YouTubeConnectionProvider,wW as YOUTUBE_DEFAULT_SCOPES,IW as X_DEFAULT_SCOPES,LW as XOAuthProvider,fW as XConnectionProvider,Y9 as WorkflowRuntime,Z9 as WorkflowCancelledError,C9 as Workflow,eZ as WaitTimeoutError,IZ as ViewRouteDispatcher,L8 as UndeclaredFeatureError,PW as TikTokConnectionProvider,v8 as TaggedCache,TW as TIKTOK_DEFAULT_SCOPES,R8 as StorageFetchTimeoutError,W9 as StepTimeoutError,rZ as StepFailedError,$9 as Step,pW as StaticFeatureFlagSource,SZ as Sharp,L9 as Scheduler,g9 as ScheduleServiceProvider,qZ as STATIC_NAVIGATION_CSP_HASH,WZ as SOCKET_ID_HEADER,e5 as SESSION_TOKEN_PREFIX,J6 as S3Driver,J$ as RunsServiceProvider,HZ as RunNotFoundError,UZ as RunManager,NZ as RunFailure,K$ as RouteServiceProvider,hZ as ResendDriver,Y$ as RedisServiceProvider,b4 as RedisRateLimiterTimeoutError,l1 as RedisRateLimiterDisconnectedError,j6 as RedisRateLimiter,d1 as RedisManager,w8 as RedisCacheStore,YZ as RedisBroadcastDriver,Z$ as RateLimiterServiceProvider,T4 as RateLimiterDriver,$8 as RateLimiter,j1 as RangeNotSatisfiableError,v9 as QueueServiceProvider,K9 as QueueManager,p8 as ProviderConnection,b6 as PrismaMcpOAuthStore,zZ as PendingBroadcast,jZ as OPEN_RUN_STATUSES,c8 as OAuthReconnectRequiredError,i as OAuthProvider,b as OAuthConnectionProvider,U as OAuthConnectionError,R as OAuthCallbackError,t9 as MiddlewareServiceProvider,VZ as MiddlewareRegistry,c as MetaSignedRequestError,sZ as MemoryWorkflowStore,FZ as MemoryRunStore,oZ as MemoryQueueDriver,P6 as MemoryMcpOAuthStore,uZ as MemoryLockStore,g8 as MemoryConnectionStore,o8 as MemoryChangeFeedDriver,b8 as MemoryCacheStore,QZ as MemoryBroadcastDriver,G9 as McpToolError,j9 as McpRegistry,C6 as McpOAuthServer,F9 as McpHttpServer,X9 as McpCallRefusedError,M9 as McpApiKeyResolver,d9 as MailServiceProvider,mZ as MailManager,a9 as LogServiceProvider,C8 as LogManager,y8 as LockManager,I8 as LockLostError,k9 as Listener,kW as LinkedInConnectionProvider,h5 as LINKEDIN_ORGANIZATION_SCOPES,VW as LINKEDIN_DEFAULT_SCOPES,o9 as KernelIdServiceProvider,PZ as KernelId,J9 as Job,tZ as ItemSource,e8 as InvalidChannelError,$6 as InstagramPublisher,_ as InstagramPublishError,SW as InstagramOAuthProvider,R4 as InstagramConnectionProvider,m as InstagramApiError,g5 as Instagram,P4 as InMemoryRateLimiter,s9 as ImageServiceProvider,xZ as ImageOptimizationDriver,_Z as ImageManager,aZ as ITEM_SOURCE_ITEM_LIMIT,wZ as ISLAND_LOADER_CSP_HASH,w as INSTAGRAM_LIMITS,f8 as HeldLock,E6 as GoogleOAuthProvider,m6 as GitHubOAuthProvider,i9 as FilesystemServiceProvider,S8 as FilesystemManager,N8 as FileSystemDriver,C1 as FileStorageDriver,Y1 as FileNotFoundError,p9 as FeaturesServiceProvider,F8 as FeatureSourceReadOnlyError,D8 as FeatureScope,B8 as FeatureReloadError,M8 as FeatureModelMissingError,H8 as FeatureManager,j8 as FeatureFlagStore,Y6 as FeatureFlagSource,Q6 as Feature,e0 as FacebookPage,OW as FacebookConnectionProvider,BZ as FINAL_RUN_STATUSES,RW as FACEBOOK_DEFAULT_SCOPES,n9 as EventServiceProvider,h as EventManager,r1 as Event,l9 as EncryptionServiceProvider,h8 as EncryptionKeyError,A8 as Encrypter,w4 as EmailDriver,E8 as DecryptionError,pZ as DatabaseWorkflowStore,LZ as DatabaseRunStore,r9 as DatabaseRateLimiter,lZ as DatabaseQueueDriver,cZ as DatabaseLockStore,m9 as DatabaseFeatureFlagSource,m8 as DatabaseConnectionStore,s8 as DatabaseChangeFeedDriver,z9 as DEFAULT_MCP_SCOPE,S9 as CronJob,u8 as ConnectionManager,z$ as CommandRegistry,D9 as CommandFailed,H9 as Command,r8 as ChangeFeedSubscription,y9 as ChangeFeedServiceProvider,t8 as ChangeFeedManager,a8 as ChangeFeedFullError,f9 as CacheServiceProvider,q8 as CacheManager,n1 as CONSENT_PAGE_HEADERS,I9 as BroadcastServiceProvider,GZ as BroadcastScope,KZ as BroadcastPayloadTooLargeError,JZ as BroadcastManager,I6 as BroadcastEvent,G6 as AzureBlobDriver,A9 as AuthServiceProvider,z1 as AuthManager,fZ as ApiRouteDispatcher,q4 as AcsDriver};
71
71
 
72
- //# debugId=F4BBF32E2193036964756E2164756E21
72
+ //# debugId=EB131BE0C2E42F1E64756E2164756E21