@shopify/cli 4.7.0 → 4.8.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 (324) hide show
  1. package/dist/analytics-3IIUBZ3B.js +1 -0
  2. package/dist/analytics-OOT5AB52.js +1 -0
  3. package/dist/assets/hydrogen/starter/AGENTS.md +5 -0
  4. package/dist/assets/hydrogen/starter/CHANGELOG.md +9 -0
  5. package/dist/assets/hydrogen/starter/CLAUDE.md +1 -0
  6. package/dist/assets/hydrogen/starter/package.json +3 -3
  7. package/dist/bootstrap.js +1 -1
  8. package/dist/{chunk-6ENBE43F.js → chunk-2AK44UYM.js} +1 -1
  9. package/dist/{chunk-XCBEYRQI.js → chunk-2CIZE537.js} +1 -1
  10. package/dist/{chunk-YHPBDS52.js → chunk-2EAFYCCS.js} +1 -1
  11. package/dist/{chunk-U2Z5NMXV.js → chunk-2KGPH7YG.js} +1 -1
  12. package/dist/{chunk-6VGJVXZI.js → chunk-2O224ZPO.js} +1 -1
  13. package/dist/{chunk-RY2SJVWM.js → chunk-2XDUJQQN.js} +3 -3
  14. package/dist/{chunk-GSCWZR22.js → chunk-36ROOKQB.js} +1 -1
  15. package/dist/{chunk-YIZZ5LZN.js → chunk-3DCN3N23.js} +1 -1
  16. package/dist/{chunk-YN6A26QL.js → chunk-3JXPOOFV.js} +39 -39
  17. package/dist/{chunk-KIYHEMHD.js → chunk-4QBJ5JBX.js} +15 -16
  18. package/dist/chunk-4ZNV5YSL.js +1 -0
  19. package/dist/chunk-5L63PRJL.js +2 -0
  20. package/dist/{chunk-MRCWOOSF.js → chunk-5N6HNQQ5.js} +1 -1
  21. package/dist/{chunk-4JY2P2A5.js → chunk-5SEEDOQ5.js} +1 -1
  22. package/dist/chunk-67Z34HN5.js +5 -0
  23. package/dist/chunk-6BDAJ6UD.js +5 -0
  24. package/dist/chunk-6CXG3XLP.js +1 -0
  25. package/dist/{chunk-QEB3HUQE.js → chunk-6MWWJZFN.js} +1 -1
  26. package/dist/{chunk-LRQYUWWB.js → chunk-6RQOEPEC.js} +1 -1
  27. package/dist/{chunk-LJM2DUXN.js → chunk-72ZY3KTF.js} +1 -1
  28. package/dist/{chunk-WKUGSFTB.js → chunk-742XXXGL.js} +1 -1
  29. package/dist/{chunk-37TEEITE.js → chunk-7HFHL5SO.js} +1 -1
  30. package/dist/{chunk-6VRXGEIW.js → chunk-7ISJRIPT.js} +1 -1
  31. package/dist/{chunk-CZJZCJRX.js → chunk-7LWUHQIF.js} +1 -1
  32. package/dist/{chunk-MLZLDL6B.js → chunk-7T6M7FAC.js} +1 -1
  33. package/dist/{chunk-LWJA2DQG.js → chunk-A6BMJISP.js} +1 -1
  34. package/dist/{chunk-TY4W7AYX.js → chunk-AWUX36VG.js} +1 -1
  35. package/dist/chunk-BWJIZYAG.js +1 -0
  36. package/dist/{chunk-EW55WWT7.js → chunk-BZ73NV3L.js} +1 -1
  37. package/dist/chunk-C3RUVXG2.js +6 -0
  38. package/dist/{chunk-QKGZWOOY.js → chunk-C4YLE3NS.js} +1 -1
  39. package/dist/chunk-CEYIZC3M.js +2 -0
  40. package/dist/{chunk-WCRZJY3P.js → chunk-CIWKN4HF.js} +1 -1
  41. package/dist/{chunk-P5MNNBSO.js → chunk-CULTZLC4.js} +1 -1
  42. package/dist/{chunk-X4XP2RQJ.js → chunk-CX75OKZK.js} +1 -1
  43. package/dist/{chunk-LDF4PQ3B.js → chunk-DASVZTAX.js} +46 -46
  44. package/dist/{chunk-UPJLZHHR.js → chunk-DX3JLOUA.js} +1 -1
  45. package/dist/{chunk-ZCNIR6YU.js → chunk-E55KS3GZ.js} +1 -1
  46. package/dist/{chunk-WHLGNDRE.js → chunk-E5FXOLQO.js} +1 -1
  47. package/dist/{chunk-JQ2B3VHR.js → chunk-E6N4PZZR.js} +1 -1
  48. package/dist/{chunk-CIH6LPTG.js → chunk-EB574SY6.js} +1 -1
  49. package/dist/chunk-EX5GVHGE.js +1 -0
  50. package/dist/chunk-F3NYCSXT.js +273 -0
  51. package/dist/{chunk-FWPJEL6Q.js → chunk-F6X6OXXB.js} +1 -1
  52. package/dist/{chunk-QPWMD2VR.js → chunk-FDBHQLFK.js} +1 -1
  53. package/dist/{chunk-TCTVI6PK.js → chunk-FDYW3UQC.js} +1 -1
  54. package/dist/{chunk-2SZOPJYI.js → chunk-FEDVVYK2.js} +1 -1
  55. package/dist/{chunk-SSJGWLCW.js → chunk-FJ6F4XRV.js} +1 -1
  56. package/dist/{chunk-E5T4YRGW.js → chunk-FOREMLFZ.js} +1 -1
  57. package/dist/{chunk-QXHENYJH.js → chunk-FUYDGK33.js} +1 -1
  58. package/dist/{chunk-CYOFLJ3Z.js → chunk-FX3L344E.js} +1 -1
  59. package/dist/{chunk-FCGKO2KY.js → chunk-G5XIGN5D.js} +1 -1
  60. package/dist/{chunk-HHVHVGRT.js → chunk-GAYKYEIM.js} +1 -1
  61. package/dist/{chunk-2U4P6UFZ.js → chunk-GCY7LPEF.js} +1 -1
  62. package/dist/{chunk-OORWOTAP.js → chunk-GNBRCK7L.js} +1 -1
  63. package/dist/{chunk-KOVAFUYN.js → chunk-GRPKF5ZB.js} +1 -1
  64. package/dist/{chunk-QZBSCOJV.js → chunk-GRSF7456.js} +1 -1
  65. package/dist/chunk-H2TQ4ODI.js +1 -0
  66. package/dist/{chunk-AMLWPYNA.js → chunk-H6XEESUN.js} +1 -1
  67. package/dist/{chunk-I3N6NPHF.js → chunk-HB347DXT.js} +1 -1
  68. package/dist/chunk-HFSCXTJQ.js +97 -0
  69. package/dist/chunk-HHN6KZXX.js +1 -0
  70. package/dist/{chunk-QBIVQXUJ.js → chunk-HP64ZTEJ.js} +1 -1
  71. package/dist/{chunk-U7R6LYPJ.js → chunk-IARCMH7G.js} +1 -1
  72. package/dist/{chunk-YOO7DLOT.js → chunk-IBI5UCJO.js} +1 -1
  73. package/dist/{chunk-UVQL7RUY.js → chunk-IKUSLRGD.js} +1 -1
  74. package/dist/{chunk-HLNJL4B6.js → chunk-IT4HYLTY.js} +1 -1
  75. package/dist/{chunk-GZ64KWHX.js → chunk-J4T73EAS.js} +1 -1
  76. package/dist/chunk-JG4HH54Q.js +1 -0
  77. package/dist/{chunk-DKL6N3L2.js → chunk-JIYSCWCG.js} +1 -1
  78. package/dist/chunk-JWRK5KLD.js +560 -0
  79. package/dist/{chunk-DHU57LKD.js → chunk-JX7FYWPO.js} +1 -1
  80. package/dist/{chunk-N6YTJXIS.js → chunk-K42WBNJQ.js} +1 -1
  81. package/dist/{chunk-5CR5YJTU.js → chunk-KDU7VW3L.js} +1 -1
  82. package/dist/{chunk-CTRXLZAJ.js → chunk-KWVOJWO7.js} +1 -1
  83. package/dist/{chunk-RUFQCXBX.js → chunk-LANUJ7LX.js} +1 -1
  84. package/dist/{chunk-PAAKBWSF.js → chunk-LUKQ5HLC.js} +1 -1
  85. package/dist/{chunk-3K6VHXC2.js → chunk-M2XHIN57.js} +1 -1
  86. package/dist/{chunk-TYIGOVRQ.js → chunk-MNOQAXJW.js} +1 -1
  87. package/dist/chunk-MYQUYU4U.js +2 -0
  88. package/dist/{chunk-T5JXQ7KO.js → chunk-N65F7ET2.js} +1 -1
  89. package/dist/{chunk-PWSI275S.js → chunk-N6RBRPGW.js} +1 -1
  90. package/dist/chunk-N75VOJHO.js +15 -0
  91. package/dist/{chunk-4W3UE2ZI.js → chunk-NBFMP5XQ.js} +1 -1
  92. package/dist/{chunk-CFWHR74L.js → chunk-NE3ZFSMS.js} +1 -1
  93. package/dist/{chunk-D2K2ZBKH.js → chunk-NGLMZYS7.js} +2 -2
  94. package/dist/{chunk-JQISGC7D.js → chunk-NHAUJWEG.js} +1 -1
  95. package/dist/chunk-NILETICC.js +11 -0
  96. package/dist/{chunk-SYADOUBB.js → chunk-NNZXKFOS.js} +1 -1
  97. package/dist/{chunk-E2W5OYYM.js → chunk-NQK2VCDA.js} +1 -1
  98. package/dist/{chunk-U6HYEGAE.js → chunk-NROVZETL.js} +1 -1
  99. package/dist/{chunk-TSLQZTXR.js → chunk-NW6NUGN7.js} +1 -1
  100. package/dist/{chunk-JZMRBJH3.js → chunk-O7DZXO3O.js} +1 -1
  101. package/dist/{chunk-5CADTCJE.js → chunk-OBYQSIYU.js} +1 -1
  102. package/dist/{chunk-5NO5OXYP.js → chunk-OEG3N5PG.js} +1 -1
  103. package/dist/{chunk-VRVP2GQL.js → chunk-OGBZTY2G.js} +1 -1
  104. package/dist/chunk-OMHR423H.js +1 -0
  105. package/dist/{chunk-XHZ5BWXL.js → chunk-OV6SRRXR.js} +1 -1
  106. package/dist/{chunk-2JDCVEFK.js → chunk-OVV5YGKN.js} +1 -1
  107. package/dist/{chunk-SEVSMWNX.js → chunk-OZL5FTT7.js} +1 -1
  108. package/dist/{chunk-JUKAWTYY.js → chunk-OZMQ2EJB.js} +1 -1
  109. package/dist/{chunk-7WTNEG2F.js → chunk-P57P7UAN.js} +1 -1
  110. package/dist/{chunk-JZXA3H5K.js → chunk-PATTG7YZ.js} +1 -1
  111. package/dist/{chunk-2HK4MFWP.js → chunk-PG5YNPJB.js} +1 -1
  112. package/dist/chunk-PP4L2JJ6.js +3 -0
  113. package/dist/{chunk-CZPGC2E7.js → chunk-Q5JX23QU.js} +1 -1
  114. package/dist/{chunk-L67BU25M.js → chunk-Q5KVMLBK.js} +1 -1
  115. package/dist/{chunk-ZRLEAF7M.js → chunk-Q5LIJGT7.js} +1 -1
  116. package/dist/{chunk-JQVXH26X.js → chunk-Q6ADIMJM.js} +1 -1
  117. package/dist/{chunk-YUVE2I3C.js → chunk-QERQARMC.js} +1 -1
  118. package/dist/{chunk-GLWQMLUC.js → chunk-QOV43E26.js} +1 -1
  119. package/dist/{chunk-KCS75ZM4.js → chunk-QTFUYKMF.js} +1 -1
  120. package/dist/{chunk-7DOWT5JZ.js → chunk-QTJCCOAG.js} +3 -3
  121. package/dist/{chunk-XAOYKECS.js → chunk-R6ICQT2D.js} +1 -1
  122. package/dist/{chunk-4LRG5YBS.js → chunk-R7T3LYJL.js} +1 -1
  123. package/dist/{chunk-DMXQLI35.js → chunk-RXQJCJDV.js} +1 -1
  124. package/dist/{chunk-BR6DBMQA.js → chunk-S2TLBBSS.js} +1 -1
  125. package/dist/{chunk-FULWTZS6.js → chunk-S5FOQY35.js} +1 -1
  126. package/dist/{chunk-6OFGSZD6.js → chunk-SYLHT42O.js} +1 -1
  127. package/dist/{chunk-CHMEDVDZ.js → chunk-T4AA6TSF.js} +1 -1
  128. package/dist/{chunk-XRT2W5Y2.js → chunk-T4QWK5GG.js} +1 -1
  129. package/dist/{chunk-63CIFL36.js → chunk-T7PJDT5O.js} +1 -1
  130. package/dist/{chunk-6EBLULOC.js → chunk-TEY4LRY7.js} +1 -1
  131. package/dist/{chunk-PANGX7SA.js → chunk-TFBRVLDN.js} +1 -1
  132. package/dist/{chunk-MB7E5GEY.js → chunk-TUVDJ3PG.js} +1 -1
  133. package/dist/{chunk-HZIX3DIT.js → chunk-U2DWBZK2.js} +1 -1
  134. package/dist/chunk-U53OLUOE.js +3 -0
  135. package/dist/{chunk-GKOBFX4A.js → chunk-UAETNFN4.js} +1 -1
  136. package/dist/{chunk-EOMCXBCS.js → chunk-UAFEFKAQ.js} +1 -1
  137. package/dist/{chunk-Q5DQGV3M.js → chunk-ULRJDKWQ.js} +1 -1
  138. package/dist/chunk-UZARYOLN.js +1 -0
  139. package/dist/chunk-VASGXHYA.js +1 -0
  140. package/dist/chunk-VD4XJ6BX.js +1 -0
  141. package/dist/{chunk-Y34LWI3S.js → chunk-VFM2KQRM.js} +3 -3
  142. package/dist/{chunk-CMYQXGLO.js → chunk-VSDRNYA5.js} +1 -1
  143. package/dist/{chunk-OE3F7XXU.js → chunk-VVZSYHDG.js} +1 -1
  144. package/dist/chunk-VXEYO3ZP.js +1 -0
  145. package/dist/{chunk-7JIQXGDE.js → chunk-VYDSOAV4.js} +1 -1
  146. package/dist/{chunk-DQFSKPKL.js → chunk-WBYAGS6B.js} +1 -1
  147. package/dist/chunk-WGAFCKGD.js +1 -0
  148. package/dist/{chunk-AH2ZGMDM.js → chunk-WYBTC356.js} +1 -1
  149. package/dist/{chunk-TTAPXLI5.js → chunk-XF2KTEID.js} +1 -1
  150. package/dist/{chunk-XUEMMLXK.js → chunk-XH5YGJQR.js} +1 -1
  151. package/dist/chunk-XHKWITLA.js +1705 -0
  152. package/dist/chunk-XOCB4KNX.js +2 -0
  153. package/dist/{chunk-2WJAAJVX.js → chunk-XUUAKGEX.js} +1 -1
  154. package/dist/{chunk-LQCR4TGH.js → chunk-XUYVJEZG.js} +1 -1
  155. package/dist/chunk-Y47C3LSX.js +3 -0
  156. package/dist/{chunk-KK24VGVE.js → chunk-Y5PRPHLQ.js} +1 -1
  157. package/dist/{chunk-K4KTNINH.js → chunk-YD2VQEN5.js} +1 -1
  158. package/dist/{chunk-KUNDCAQN.js → chunk-YESGYUEL.js} +1 -1
  159. package/dist/{chunk-JJJTPEMD.js → chunk-YEVGLC5X.js} +1 -1
  160. package/dist/{chunk-GMTNOCMS.js → chunk-YFINLODF.js} +3 -3
  161. package/dist/{chunk-LZ3GZ7NS.js → chunk-YKL3BLWC.js} +1 -1
  162. package/dist/{chunk-5HPBQ6U5.js → chunk-YLXPYXQP.js} +1 -1
  163. package/dist/{chunk-7AALWJAO.js → chunk-YNDIZCD2.js} +1 -1
  164. package/dist/{chunk-6WZYX5RO.js → chunk-YPWHD3NL.js} +1 -1
  165. package/dist/{chunk-4HV6A6UH.js → chunk-YSAFHVV6.js} +1 -1
  166. package/dist/{chunk-AGOEROAI.js → chunk-YZMY2CTU.js} +1 -1
  167. package/dist/{chunk-S3P5WWJD.js → chunk-Z4AFEO36.js} +1 -1
  168. package/dist/{chunk-7MHANY34.js → chunk-Z5WPP6ME.js} +1 -1
  169. package/dist/chunk-Z65E4UAP.js +1 -0
  170. package/dist/{chunk-V2HCVJYF.js → chunk-ZDRIQC7O.js} +1 -1
  171. package/dist/{chunk-2CYVZUYT.js → chunk-ZH44BDUR.js} +1 -1
  172. package/dist/{chunk-SJMTETSU.js → chunk-ZL5LU4U2.js} +1 -1
  173. package/dist/{chunk-DQCIORGH.js → chunk-ZYX7UHCQ.js} +1 -1
  174. package/dist/{chunk-ACTDYTAV.js → chunk-ZZRFG6ME.js} +114 -114
  175. package/dist/cli/commands/app/app-logs/sources.js +1 -1
  176. package/dist/cli/commands/app/build.js +1 -1
  177. package/dist/cli/commands/app/bulk/cancel.js +1 -1
  178. package/dist/cli/commands/app/bulk/execute.js +1 -1
  179. package/dist/cli/commands/app/bulk/status.js +1 -1
  180. package/dist/cli/commands/app/config/link.js +1 -1
  181. package/dist/cli/commands/app/config/pull.js +1 -1
  182. package/dist/cli/commands/app/config/use.js +1 -1
  183. package/dist/cli/commands/app/config/validate.js +1 -1
  184. package/dist/cli/commands/app/demo/watcher.js +1 -1
  185. package/dist/cli/commands/app/deploy.js +1 -1
  186. package/dist/cli/commands/app/dev/clean.js +1 -1
  187. package/dist/cli/commands/app/dev.js +1 -1
  188. package/dist/cli/commands/app/doctor/instructions.js +1 -0
  189. package/dist/cli/commands/app/doctor.js +1 -0
  190. package/dist/cli/commands/app/env/pull.js +1 -1
  191. package/dist/cli/commands/app/env/show.js +1 -1
  192. package/dist/cli/commands/app/execute.js +1 -1
  193. package/dist/cli/commands/app/function/build.js +1 -1
  194. package/dist/cli/commands/app/function/info.js +1 -1
  195. package/dist/cli/commands/app/function/replay.js +1 -1
  196. package/dist/cli/commands/app/function/run.js +1 -1
  197. package/dist/cli/commands/app/function/schema.js +1 -1
  198. package/dist/cli/commands/app/function/typegen.js +1 -1
  199. package/dist/cli/commands/app/generate/extension.js +1 -1
  200. package/dist/cli/commands/app/graphiql.js +1 -1
  201. package/dist/cli/commands/app/import-custom-data-definitions.js +1 -1
  202. package/dist/cli/commands/app/import-extensions.js +1 -1
  203. package/dist/cli/commands/app/info.js +1 -1
  204. package/dist/cli/commands/app/init.js +1 -1
  205. package/dist/cli/commands/app/logs.js +1 -1
  206. package/dist/cli/commands/app/release.js +1 -1
  207. package/dist/cli/commands/app/subscription-migrations/cancel.js +1 -0
  208. package/dist/cli/commands/app/subscription-migrations/list.js +1 -0
  209. package/dist/cli/commands/app/subscription-migrations/schedule.js +1 -0
  210. package/dist/cli/commands/app/subscription-migrations/status.js +1 -0
  211. package/dist/cli/commands/app/subscription-migrations/unschedule.js +1 -0
  212. package/dist/cli/commands/app/versions/list.js +1 -1
  213. package/dist/cli/commands/app/webhook/trigger.js +1 -1
  214. package/dist/cli/commands/auth/login.js +1 -1
  215. package/dist/cli/commands/auth/logout.js +1 -1
  216. package/dist/cli/commands/cache/clear.js +1 -1
  217. package/dist/cli/commands/config/autoupgrade/off.js +1 -1
  218. package/dist/cli/commands/config/autoupgrade/on.js +1 -1
  219. package/dist/cli/commands/config/autoupgrade/status.js +1 -1
  220. package/dist/cli/commands/debug/command-flags.js +1 -1
  221. package/dist/cli/commands/doc/fetch.js +1 -1
  222. package/dist/cli/commands/doc/search.js +1 -1
  223. package/dist/cli/commands/docs/generate.js +1 -1
  224. package/dist/cli/commands/doctor-release/doctor-release.js +1 -1
  225. package/dist/cli/commands/doctor-release/theme/index.js +1 -1
  226. package/dist/cli/commands/help.js +1 -1
  227. package/dist/cli/commands/kitchen-sink/async.js +1 -1
  228. package/dist/cli/commands/kitchen-sink/index.js +1 -1
  229. package/dist/cli/commands/kitchen-sink/prompts.js +1 -1
  230. package/dist/cli/commands/kitchen-sink/static.js +1 -1
  231. package/dist/cli/commands/notifications/generate.js +1 -1
  232. package/dist/cli/commands/notifications/list.js +1 -1
  233. package/dist/cli/commands/organization/list.js +1 -1
  234. package/dist/cli/commands/search.js +1 -1
  235. package/dist/cli/commands/send-analytics.js +1 -1
  236. package/dist/cli/commands/theme/check.js +1 -1
  237. package/dist/cli/commands/theme/console.js +1 -1
  238. package/dist/cli/commands/theme/delete.js +1 -1
  239. package/dist/cli/commands/theme/dev.js +1 -1
  240. package/dist/cli/commands/theme/duplicate.js +1 -1
  241. package/dist/cli/commands/theme/info.js +1 -1
  242. package/dist/cli/commands/theme/init.js +1 -1
  243. package/dist/cli/commands/theme/language-server.js +1 -1
  244. package/dist/cli/commands/theme/list.js +1 -1
  245. package/dist/cli/commands/theme/metafields/pull.js +1 -1
  246. package/dist/cli/commands/theme/open.js +1 -1
  247. package/dist/cli/commands/theme/package.js +1 -1
  248. package/dist/cli/commands/theme/preview.js +1 -1
  249. package/dist/cli/commands/theme/profile.js +1 -1
  250. package/dist/cli/commands/theme/publish.js +1 -1
  251. package/dist/cli/commands/theme/pull.js +1 -1
  252. package/dist/cli/commands/theme/push.js +1 -1
  253. package/dist/cli/commands/theme/rename.js +1 -1
  254. package/dist/cli/commands/theme/share.js +1 -1
  255. package/dist/cli/commands/upgrade.js +1 -1
  256. package/dist/cli/commands/version.js +1 -1
  257. package/dist/command-registry.js +1 -1
  258. package/dist/{conf-store-OAGJBITE.js → conf-store-ASDCTDQ4.js} +1 -1
  259. package/dist/configs/all.yml +60 -0
  260. package/dist/configs/recommended.yml +60 -0
  261. package/dist/data/filters.json +31 -2
  262. package/dist/data/setting.json +129 -4
  263. package/dist/data/shopify_system_translations.json +154 -13
  264. package/dist/{deprecations-K3NPRKBF.js → deprecations-VBQV7Q4O.js} +1 -1
  265. package/dist/dist-FZLOAKU7.js +1 -0
  266. package/dist/dist-HTY6UHG5.js +1 -0
  267. package/dist/environments-HSTNEQRG.js +1 -0
  268. package/dist/{error-YX56C43A.js → error-2LZYKRMA.js} +1 -1
  269. package/dist/error-handler-PIGEJ7BT.js +1 -0
  270. package/dist/{fs-SKHQZZTQ.js → fs-BJHNJDDK.js} +1 -1
  271. package/dist/hooks/did-you-mean.js +1 -1
  272. package/dist/hooks/hydrogen-init.js +1 -1
  273. package/dist/hooks/postrun.js +1 -1
  274. package/dist/hooks/prerun.js +1 -1
  275. package/dist/hooks/public-metadata.js +1 -1
  276. package/dist/hooks/sensitive-metadata.js +1 -1
  277. package/dist/hooks/tunnel-provider.js +1 -1
  278. package/dist/hooks/tunnel-start.js +1 -1
  279. package/dist/index.js +14 -16
  280. package/dist/{is-global-V5VORI3F.js → is-global-6SCOAJVG.js} +1 -1
  281. package/dist/{local-GX5AN6ZS.js → local-PZWPRFU7.js} +1 -1
  282. package/dist/{metadata-XUJUTBTB.js → metadata-VVBHB3HL.js} +1 -1
  283. package/dist/{node-package-manager-3WIYU7Y3.js → node-package-manager-ETYQN7OM.js} +1 -1
  284. package/dist/notifications-system-652OG5KL.js +1 -0
  285. package/dist/os-7D6NT4O3.js +1 -0
  286. package/dist/{output-X47P6ICP.js → output-74VDGYJD.js} +1 -1
  287. package/dist/{prettier-RVUAAWC7.js → prettier-EGVCP5CY.js} +1 -1
  288. package/dist/{system-SR5G7WEW.js → system-P5QIJALL.js} +1 -1
  289. package/dist/tsconfig.tsbuildinfo +1 -1
  290. package/dist/{ui-VYWSLAQ6.js → ui-H5I5YVKV.js} +1 -1
  291. package/dist/upgrade-34HSYBXI.js +1 -0
  292. package/dist/version-EKXEAF6Q.js +1 -0
  293. package/dist/{version-FK4ETQ22.js → version-J2PYO6M5.js} +1 -1
  294. package/dist/{workerd-NAPS5TA7.js → workerd-X4TGHEG3.js} +1 -1
  295. package/oclif.manifest.json +903 -133
  296. package/package.json +9 -8
  297. package/dist/analytics-6LI5GLWS.js +0 -1
  298. package/dist/analytics-UNRIIG4Y.js +0 -1
  299. package/dist/chunk-5CYJG63I.js +0 -1
  300. package/dist/chunk-6PDR2IUL.js +0 -11
  301. package/dist/chunk-F5HCSUXC.js +0 -16
  302. package/dist/chunk-H5KWM27L.js +0 -1
  303. package/dist/chunk-NEMPLS7C.js +0 -1
  304. package/dist/chunk-OUZGGWFN.js +0 -1
  305. package/dist/chunk-PIFW2R3S.js +0 -1382
  306. package/dist/chunk-QRT4A2RV.js +0 -3
  307. package/dist/chunk-R2R6JDNH.js +0 -1
  308. package/dist/chunk-RZFBGBNA.js +0 -1
  309. package/dist/chunk-V5SC2RYQ.js +0 -2
  310. package/dist/chunk-VKSR6MJG.js +0 -2
  311. package/dist/chunk-XLURZ6GL.js +0 -559
  312. package/dist/chunk-Z5K4J7HQ.js +0 -1
  313. package/dist/chunk-ZO74GSWC.js +0 -5
  314. package/dist/chunk-ZSFAURIH.js +0 -3
  315. package/dist/dist-EXJEE23W.js +0 -1
  316. package/dist/dist-S62Z6IFV.js +0 -1
  317. package/dist/environments-ALH2N36U.js +0 -1
  318. package/dist/error-handler-FDCH72NH.js +0 -1
  319. package/dist/notifications-system-RHULO564.js +0 -1
  320. package/dist/os-M6X7KOR4.js +0 -1
  321. package/dist/upgrade-PFQ7JMXG.js +0 -1
  322. package/dist/version-U4GM2LNG.js +0 -1
  323. /package/dist/{chunk-NJPL5BTN.js → chunk-YLQ3LNNY.js} +0 -0
  324. /package/dist/{morph-77RHJICZ.js → morph-BMYYMQNX.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Ju,b as Nn,c as ee}from"./chunk-F3TMLDLC.js";import{Da as Zu}from"./chunk-YN6A26QL.js";import{a as $,c as A,g as v}from"./chunk-VKWPEFWQ.js";var eo=A((ir,In)=>{v();(function(e,t){typeof ir=="object"&&typeof In<"u"?t(ir):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.async={}))})(ir,(function(e){"use strict";function t(f,...n){return(...u)=>f(...n,...u)}function r(f){return function(...n){var u=n.pop();return f.call(this,n,u)}}var i=typeof queueMicrotask=="function"&&queueMicrotask,a=typeof setImmediate=="function"&&setImmediate,o=typeof process=="object"&&typeof process.nextTick=="function";function l(f){setTimeout(f,0)}function y(f){return(n,...u)=>f(()=>n(...u))}var _;i?_=queueMicrotask:a?_=setImmediate:o?_=process.nextTick:_=l;var T=y(_);function x(f){return O(f)?function(...n){let u=n.pop(),s=f.apply(this,n);return M(s,u)}:r(function(n,u){var s;try{s=f.apply(this,n)}catch(h){return u(h)}if(s&&typeof s.then=="function")return M(s,u);u(null,s)})}function M(f,n){return f.then(u=>{L(n,null,u)},u=>{L(n,u&&(u instanceof Error||u.message)?u:new Error(u))})}function L(f,n,u){try{f(n,u)}catch(s){T(h=>{throw h},s)}}function O(f){return f[Symbol.toStringTag]==="AsyncFunction"}function H(f){return f[Symbol.toStringTag]==="AsyncGenerator"}function Q(f){return typeof f[Symbol.asyncIterator]=="function"}function b(f){if(typeof f!="function")throw new Error("expected a function");return O(f)?x(f):f}function S(f,n){if(n||(n=f.length),!n)throw new Error("arity is undefined");function u(...s){return typeof s[n-1]=="function"?f.apply(this,s):new Promise((h,c)=>{s[n-1]=(d,...p)=>{if(d)return c(d);h(p.length>1?p:p[0])},f.apply(this,s)})}return u}function ye(f){return function(u,...s){return S(function(c){var d=this;return f(u,(p,g)=>{b(p).apply(d,s.concat(g))},c)})}}function Br(f,n,u,s){n=n||[];var h=[],c=0,d=b(u);return f(n,(p,g,m)=>{var C=c++;d(p,(B,P)=>{h[C]=P,m(B)})},p=>{s(p,h)})}function xt(f){return f&&typeof f.length=="number"&&f.length>=0&&f.length%1===0}let Ct={};function ve(f){function n(...u){if(f!==null){var s=f;f=null,s.apply(this,u)}}return Object.assign(n,f),n}function Kf(f){return f[Symbol.iterator]&&f[Symbol.iterator]()}function Yf(f){var n=-1,u=f.length;return function(){return++n<u?{value:f[n],key:n}:null}}function Qf(f){var n=-1;return function(){var s=f.next();return s.done?null:(n++,{value:s.value,key:n})}}function Xf(f){var n=f?Object.keys(f):[],u=-1,s=n.length;return function h(){var c=n[++u];return c==="__proto__"?h():u<s?{value:f[c],key:c}:null}}function Zf(f){if(xt(f))return Yf(f);var n=Kf(f);return n?Qf(n):Xf(f)}function _e(f){return function(...n){if(f===null)throw new Error("Callback was already called.");var u=f;f=null,u.apply(this,n)}}function Vi(f,n,u,s){let h=!1,c=!1,d=!1,p=0,g=0;function m(){p>=n||d||h||(d=!0,f.next().then(({value:P,done:Z})=>{if(!(c||h)){if(d=!1,Z){h=!0,p<=0&&s(null);return}p++,u(P,g,C),g++,m()}}).catch(B))}function C(P,Z){if(p-=1,!c){if(P)return B(P);if(P===!1){h=!0,c=!0;return}if(Z===Ct||h&&p<=0)return h=!0,s(null);m()}}function B(P){c||(d=!1,h=!0,s(P))}m()}var ie=f=>(n,u,s)=>{if(s=ve(s),f<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!n)return s(null);if(H(n))return Vi(n,f,u,s);if(Q(n))return Vi(n[Symbol.asyncIterator](),f,u,s);var h=Zf(n),c=!1,d=!1,p=0,g=!1;function m(B,P){if(!d)if(p-=1,B)c=!0,s(B);else if(B===!1)c=!0,d=!0;else{if(P===Ct||c&&p<=0)return c=!0,s(null);g||C()}}function C(){for(g=!0;p<f&&!c;){var B=h();if(B===null){c=!0,p<=0&&s(null);return}p+=1,u(B.value,B.key,_e(m))}g=!1}C()};function Jf(f,n,u,s){return ie(n)(f,b(u),s)}var Be=S(Jf,4);function eu(f,n,u){u=ve(u);var s=0,h=0,{length:c}=f,d=!1;c===0&&u(null);function p(g,m){g===!1&&(d=!0),d!==!0&&(g?u(g):(++h===c||m===Ct)&&u(null))}for(;s<c;s++)n(f[s],s,_e(p))}function tu(f,n,u){return Be(f,1/0,n,u)}function ru(f,n,u){var s=xt(f)?eu:tu;return s(f,b(n),u)}var X=S(ru,3);function iu(f,n,u){return Br(X,f,n,u)}var Pt=S(iu,3),Ki=ye(Pt);function nu(f,n,u){return Be(f,1,n,u)}var ne=S(nu,3);function au(f,n,u){return Br(ne,f,n,u)}var Nr=S(au,3),Yi=ye(Nr);let Ne=Symbol("promiseCallback");function Ie(){let f,n;function u(s,...h){if(s)return n(s);f(h.length>1?h:h[0])}return u[Ne]=new Promise((s,h)=>{f=s,n=h}),u}function Ir(f,n,u){typeof n!="number"&&(u=n,n=null),u=ve(u||Ie());var s=Object.keys(f).length;if(!s)return u(null);n||(n=s);var h={},c=0,d=!1,p=!1,g=Object.create(null),m=[],C=[],B={};Object.keys(f).forEach(w=>{var R=f[w];if(!Array.isArray(R)){P(w,[R]),C.push(w);return}var D=R.slice(0,R.length-1),U=D.length;if(U===0){P(w,R),C.push(w);return}B[w]=U,D.forEach(z=>{if(!f[z])throw new Error("async.auto task `"+w+"` has a non-existent dependency `"+z+"` in "+D.join(", "));We(z,()=>{U--,U===0&&P(w,R)})})}),N(),Z();function P(w,R){m.push(()=>ut(w,R))}function Z(){if(!d){if(m.length===0&&c===0)return u(null,h);for(;m.length&&c<n;){var w=m.shift();w()}}}function We(w,R){var D=g[w];D||(D=g[w]=[]),D.push(R)}function Oe(w){var R=g[w]||[];R.forEach(D=>D()),Z()}function ut(w,R){if(!p){var D=_e((z,...J)=>{if(c--,z===!1){d=!0;return}if(J.length<2&&([J]=J),z){var Ue={};if(Object.keys(h).forEach(Me=>{Ue[Me]=h[Me]}),Ue[w]=J,p=!0,g=Object.create(null),d)return;u(z,Ue)}else h[w]=J,Oe(w)});c++;var U=b(R[R.length-1]);R.length>1?U(h,D):U(D)}}function N(){for(var w,R=0;C.length;)w=C.pop(),R++,E(w).forEach(D=>{--B[D]===0&&C.push(D)});if(R!==s)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function E(w){var R=[];return Object.keys(f).forEach(D=>{let U=f[D];Array.isArray(U)&&U.indexOf(w)>=0&&R.push(D)}),R}return u[Ne]}var fu=/^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/,uu=/^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/,ou=/,/,su=/(=.+)?(\s*)$/;function lu(f){let n="",u=0,s=f.indexOf("*/");for(;u<f.length;)if(f[u]==="/"&&f[u+1]==="/"){let h=f.indexOf(`
1
+ import{a as Ju,b as Nn,c as ee}from"./chunk-F3TMLDLC.js";import{Ea as Zu}from"./chunk-3JXPOOFV.js";import{a as $,c as A,g as v}from"./chunk-VKWPEFWQ.js";var eo=A((ir,In)=>{v();(function(e,t){typeof ir=="object"&&typeof In<"u"?t(ir):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.async={}))})(ir,(function(e){"use strict";function t(f,...n){return(...u)=>f(...n,...u)}function r(f){return function(...n){var u=n.pop();return f.call(this,n,u)}}var i=typeof queueMicrotask=="function"&&queueMicrotask,a=typeof setImmediate=="function"&&setImmediate,o=typeof process=="object"&&typeof process.nextTick=="function";function l(f){setTimeout(f,0)}function y(f){return(n,...u)=>f(()=>n(...u))}var _;i?_=queueMicrotask:a?_=setImmediate:o?_=process.nextTick:_=l;var T=y(_);function x(f){return O(f)?function(...n){let u=n.pop(),s=f.apply(this,n);return M(s,u)}:r(function(n,u){var s;try{s=f.apply(this,n)}catch(h){return u(h)}if(s&&typeof s.then=="function")return M(s,u);u(null,s)})}function M(f,n){return f.then(u=>{L(n,null,u)},u=>{L(n,u&&(u instanceof Error||u.message)?u:new Error(u))})}function L(f,n,u){try{f(n,u)}catch(s){T(h=>{throw h},s)}}function O(f){return f[Symbol.toStringTag]==="AsyncFunction"}function H(f){return f[Symbol.toStringTag]==="AsyncGenerator"}function Q(f){return typeof f[Symbol.asyncIterator]=="function"}function b(f){if(typeof f!="function")throw new Error("expected a function");return O(f)?x(f):f}function S(f,n){if(n||(n=f.length),!n)throw new Error("arity is undefined");function u(...s){return typeof s[n-1]=="function"?f.apply(this,s):new Promise((h,c)=>{s[n-1]=(d,...p)=>{if(d)return c(d);h(p.length>1?p:p[0])},f.apply(this,s)})}return u}function ye(f){return function(u,...s){return S(function(c){var d=this;return f(u,(p,g)=>{b(p).apply(d,s.concat(g))},c)})}}function Br(f,n,u,s){n=n||[];var h=[],c=0,d=b(u);return f(n,(p,g,m)=>{var C=c++;d(p,(B,P)=>{h[C]=P,m(B)})},p=>{s(p,h)})}function xt(f){return f&&typeof f.length=="number"&&f.length>=0&&f.length%1===0}let Ct={};function ve(f){function n(...u){if(f!==null){var s=f;f=null,s.apply(this,u)}}return Object.assign(n,f),n}function Kf(f){return f[Symbol.iterator]&&f[Symbol.iterator]()}function Yf(f){var n=-1,u=f.length;return function(){return++n<u?{value:f[n],key:n}:null}}function Qf(f){var n=-1;return function(){var s=f.next();return s.done?null:(n++,{value:s.value,key:n})}}function Xf(f){var n=f?Object.keys(f):[],u=-1,s=n.length;return function h(){var c=n[++u];return c==="__proto__"?h():u<s?{value:f[c],key:c}:null}}function Zf(f){if(xt(f))return Yf(f);var n=Kf(f);return n?Qf(n):Xf(f)}function _e(f){return function(...n){if(f===null)throw new Error("Callback was already called.");var u=f;f=null,u.apply(this,n)}}function Vi(f,n,u,s){let h=!1,c=!1,d=!1,p=0,g=0;function m(){p>=n||d||h||(d=!0,f.next().then(({value:P,done:Z})=>{if(!(c||h)){if(d=!1,Z){h=!0,p<=0&&s(null);return}p++,u(P,g,C),g++,m()}}).catch(B))}function C(P,Z){if(p-=1,!c){if(P)return B(P);if(P===!1){h=!0,c=!0;return}if(Z===Ct||h&&p<=0)return h=!0,s(null);m()}}function B(P){c||(d=!1,h=!0,s(P))}m()}var ie=f=>(n,u,s)=>{if(s=ve(s),f<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!n)return s(null);if(H(n))return Vi(n,f,u,s);if(Q(n))return Vi(n[Symbol.asyncIterator](),f,u,s);var h=Zf(n),c=!1,d=!1,p=0,g=!1;function m(B,P){if(!d)if(p-=1,B)c=!0,s(B);else if(B===!1)c=!0,d=!0;else{if(P===Ct||c&&p<=0)return c=!0,s(null);g||C()}}function C(){for(g=!0;p<f&&!c;){var B=h();if(B===null){c=!0,p<=0&&s(null);return}p+=1,u(B.value,B.key,_e(m))}g=!1}C()};function Jf(f,n,u,s){return ie(n)(f,b(u),s)}var Be=S(Jf,4);function eu(f,n,u){u=ve(u);var s=0,h=0,{length:c}=f,d=!1;c===0&&u(null);function p(g,m){g===!1&&(d=!0),d!==!0&&(g?u(g):(++h===c||m===Ct)&&u(null))}for(;s<c;s++)n(f[s],s,_e(p))}function tu(f,n,u){return Be(f,1/0,n,u)}function ru(f,n,u){var s=xt(f)?eu:tu;return s(f,b(n),u)}var X=S(ru,3);function iu(f,n,u){return Br(X,f,n,u)}var Pt=S(iu,3),Ki=ye(Pt);function nu(f,n,u){return Be(f,1,n,u)}var ne=S(nu,3);function au(f,n,u){return Br(ne,f,n,u)}var Nr=S(au,3),Yi=ye(Nr);let Ne=Symbol("promiseCallback");function Ie(){let f,n;function u(s,...h){if(s)return n(s);f(h.length>1?h:h[0])}return u[Ne]=new Promise((s,h)=>{f=s,n=h}),u}function Ir(f,n,u){typeof n!="number"&&(u=n,n=null),u=ve(u||Ie());var s=Object.keys(f).length;if(!s)return u(null);n||(n=s);var h={},c=0,d=!1,p=!1,g=Object.create(null),m=[],C=[],B={};Object.keys(f).forEach(w=>{var R=f[w];if(!Array.isArray(R)){P(w,[R]),C.push(w);return}var D=R.slice(0,R.length-1),U=D.length;if(U===0){P(w,R),C.push(w);return}B[w]=U,D.forEach(z=>{if(!f[z])throw new Error("async.auto task `"+w+"` has a non-existent dependency `"+z+"` in "+D.join(", "));We(z,()=>{U--,U===0&&P(w,R)})})}),N(),Z();function P(w,R){m.push(()=>ut(w,R))}function Z(){if(!d){if(m.length===0&&c===0)return u(null,h);for(;m.length&&c<n;){var w=m.shift();w()}}}function We(w,R){var D=g[w];D||(D=g[w]=[]),D.push(R)}function Oe(w){var R=g[w]||[];R.forEach(D=>D()),Z()}function ut(w,R){if(!p){var D=_e((z,...J)=>{if(c--,z===!1){d=!0;return}if(J.length<2&&([J]=J),z){var Ue={};if(Object.keys(h).forEach(Me=>{Ue[Me]=h[Me]}),Ue[w]=J,p=!0,g=Object.create(null),d)return;u(z,Ue)}else h[w]=J,Oe(w)});c++;var U=b(R[R.length-1]);R.length>1?U(h,D):U(D)}}function N(){for(var w,R=0;C.length;)w=C.pop(),R++,E(w).forEach(D=>{--B[D]===0&&C.push(D)});if(R!==s)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function E(w){var R=[];return Object.keys(f).forEach(D=>{let U=f[D];Array.isArray(U)&&U.indexOf(w)>=0&&R.push(D)}),R}return u[Ne]}var fu=/^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/,uu=/^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/,ou=/,/,su=/(=.+)?(\s*)$/;function lu(f){let n="",u=0,s=f.indexOf("*/");for(;u<f.length;)if(f[u]==="/"&&f[u+1]==="/"){let h=f.indexOf(`
2
2
  `,u);u=h===-1?f.length:h}else if(s!==-1&&f[u]==="/"&&f[u+1]==="*"){let h=f.indexOf("*/",u);h!==-1?(u=h+2,s=f.indexOf("*/",u)):(n+=f[u],u++)}else n+=f[u],u++;return n}function hu(f){let n=lu(f.toString()),u=n.match(fu);if(u||(u=n.match(uu)),!u)throw new Error(`could not parse args in autoInject
3
3
  Source:
4
4
  `+n);let[,s]=u;return s.replace(/\s/g,"").split(ou).map(h=>h.replace(su,"").trim())}function Qi(f,n){var u={};return Object.keys(f).forEach(s=>{var h=f[s],c,d=O(h),p=!d&&h.length===1||d&&h.length===0;if(Array.isArray(h))c=[...h],h=c.pop(),u[s]=c.concat(c.length>0?g:h);else if(p)u[s]=h;else{if(c=hu(h),h.length===0&&!d&&c.length===0)throw new Error("autoInject task functions require explicit parameters.");d||c.pop(),u[s]=c.concat(g)}function g(m,C){var B=c.map(P=>m[P]);B.push(C),b(h)(...B)}}),Ir(u,n)}class cu{constructor(){this.head=this.tail=null,this.length=0}removeLink(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n}empty(){for(;this.head;)this.shift();return this}insertAfter(n,u){u.prev=n,u.next=n.next,n.next?n.next.prev=u:this.tail=u,n.next=u,this.length+=1}insertBefore(n,u){u.prev=n.prev,u.next=n,n.prev?n.prev.next=u:this.head=u,n.prev=u,this.length+=1}unshift(n){this.head?this.insertBefore(this.head,n):Xi(this,n)}push(n){this.tail?this.insertAfter(this.tail,n):Xi(this,n)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){for(var n=this.head;n;)yield n.data,n=n.next}remove(n){for(var u=this.head;u;){var{next:s}=u;n(u)&&this.removeLink(u),u=s}return this}}function Xi(f,n){f.length=1,f.head=f.tail=n}function kr(f,n,u){if(n==null)n=1;else if(n===0)throw new RangeError("Concurrency must not be zero");var s=b(f),h=0,c=[];let d={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};function p(E,w){d[E].push(w)}function g(E,w){let R=(...D)=>{m(E,R),w(...D)};d[E].push(R)}function m(E,w){if(!E)return Object.keys(d).forEach(R=>d[R]=[]);if(!w)return d[E]=[];d[E]=d[E].filter(R=>R!==w)}function C(E,...w){d[E].forEach(R=>R(...w))}var B=!1;function P(E,w,R,D){if(D!=null&&typeof D!="function")throw new Error("task callback must be a function");N.started=!0;var U,z;function J(Me,...ot){if(Me)return R?z(Me):U();if(ot.length<=1)return U(ot[0]);U(ot)}var Ue=N._createTaskItem(E,R?J:D||J);if(w?N._tasks.unshift(Ue):N._tasks.push(Ue),B||(B=!0,T(()=>{B=!1,N.process()})),R||!D)return new Promise((Me,ot)=>{U=Me,z=ot})}function Z(E){return function(w,...R){h-=1;for(var D=0,U=E.length;D<U;D++){var z=E[D],J=c.indexOf(z);J===0?c.shift():J>0&&c.splice(J,1),z.callback(w,...R),w!=null&&C("error",w,z.data)}h<=N.concurrency-N.buffer&&C("unsaturated"),N.idle()&&C("drain"),N.process()}}function We(E){return E.length===0&&N.idle()?(T(()=>C("drain")),!0):!1}let Oe=E=>w=>{if(!w)return new Promise((R,D)=>{g(E,(U,z)=>{if(U)return D(U);R(z)})});m(E),p(E,w)};var ut=!1,N={_tasks:new cu,_createTaskItem(E,w){return{data:E,callback:w}},*[Symbol.iterator](){yield*N._tasks[Symbol.iterator]()},concurrency:n,payload:u,buffer:n/4,started:!1,paused:!1,push(E,w){return Array.isArray(E)?We(E)?void 0:E.map(R=>P(R,!1,!1,w)):P(E,!1,!1,w)},pushAsync(E,w){return Array.isArray(E)?We(E)?void 0:E.map(R=>P(R,!1,!0,w)):P(E,!1,!0,w)},kill(){m(),N._tasks.empty()},unshift(E,w){return Array.isArray(E)?We(E)?void 0:E.map(R=>P(R,!0,!1,w)):P(E,!0,!1,w)},unshiftAsync(E,w){return Array.isArray(E)?We(E)?void 0:E.map(R=>P(R,!0,!0,w)):P(E,!0,!0,w)},remove(E){N._tasks.remove(E)},process(){if(!ut){for(ut=!0;!N.paused&&h<N.concurrency&&N._tasks.length;){var E=[],w=[],R=N._tasks.length;N.payload&&(R=Math.min(R,N.payload));for(var D=0;D<R;D++){var U=N._tasks.shift();E.push(U),c.push(U),w.push(U.data)}h+=1,N._tasks.length===0&&C("empty"),h===N.concurrency&&C("saturated");var z=_e(Z(E));s(w,z)}ut=!1}},length(){return N._tasks.length},running(){return h},workersList(){return c},idle(){return N._tasks.length+h===0},pause(){N.paused=!0},resume(){N.paused!==!1&&(N.paused=!1,T(N.process))}};return Object.defineProperties(N,{saturated:{writable:!1,value:Oe("saturated")},unsaturated:{writable:!1,value:Oe("unsaturated")},empty:{writable:!1,value:Oe("empty")},drain:{writable:!1,value:Oe("drain")},error:{writable:!1,value:Oe("error")}}),N}function Zi(f,n){return kr(f,1,n)}function Ji(f,n,u){return kr(f,n,u)}function du(f,n,u,s){s=ve(s);var h=b(u);return ne(f,(c,d,p)=>{h(n,c,(g,m)=>{n=m,p(g)})},c=>s(c,n))}var we=S(du,4);function Wr(...f){var n=f.map(b);return function(...u){var s=this,h=u[u.length-1];return typeof h=="function"?u.pop():h=Ie(),we(n,u,(c,d,p)=>{d.apply(s,c.concat((g,...m)=>{p(g,m)}))},(c,d)=>h(c,...d)),h[Ne]}}function en(...f){return Wr(...f.reverse())}function pu(f,n,u,s){return Br(ie(n),f,u,s)}var rt=S(pu,4);function gu(f,n,u,s){var h=b(u);return rt(f,n,(c,d)=>{h(c,(p,...g)=>p?d(p):d(p,g))},(c,d)=>{for(var p=[],g=0;g<d.length;g++)d[g]&&(p=p.concat(...d[g]));return s(c,p)})}var ke=S(gu,4);function yu(f,n,u){return ke(f,1/0,n,u)}var Dt=S(yu,3);function vu(f,n,u){return ke(f,1,n,u)}var jt=S(vu,3);function tn(...f){return function(...n){var u=n.pop();return u(null,...f)}}function le(f,n){return(u,s,h,c)=>{var d=!1,p;let g=b(h);u(s,(m,C,B)=>{g(m,(P,Z)=>{if(P||P===!1)return B(P);if(f(Z)&&!p)return d=!0,p=n(!0,m),B(null,Ct);B()})},m=>{if(m)return c(m);c(null,d?p:n(!1))})}}function _u(f,n,u){return le(s=>s,(s,h)=>h)(X,f,n,u)}var Bt=S(_u,3);function wu(f,n,u,s){return le(h=>h,(h,c)=>c)(ie(n),f,u,s)}var Nt=S(wu,4);function mu(f,n,u){return le(s=>s,(s,h)=>h)(ie(1),f,n,u)}var It=S(mu,3);function rn(f){return(n,...u)=>b(n)(...u,(s,...h)=>{typeof console=="object"&&(s?console.error&&console.error(s):console[f]&&h.forEach(c=>console[f](c)))})}var nn=rn("dir");function bu(f,n,u){u=_e(u);var s=b(f),h=b(n),c;function d(g,...m){if(g)return u(g);g!==!1&&(c=m,h(...m,p))}function p(g,m){if(g)return u(g);if(g!==!1){if(!m)return u(null,...c);s(d)}}return p(null,!0)}var it=S(bu,3);function an(f,n,u){let s=b(n);return it(f,(...h)=>{let c=h.pop();s(...h,(d,p)=>c(d,!p))},u)}function fn(f){return(n,u,s)=>f(n,s)}function Su(f,n,u){return X(f,fn(b(n)),u)}var kt=S(Su,3);function Eu(f,n,u,s){return ie(n)(f,fn(b(u)),s)}var nt=S(Eu,4);function Ru(f,n,u){return nt(f,1,n,u)}var at=S(Ru,3);function Ur(f){return O(f)?f:function(...n){var u=n.pop(),s=!0;n.push((...h)=>{s?T(()=>u(...h)):u(...h)}),f.apply(this,n),s=!1}}function Tu(f,n,u){return le(s=>!s,s=>!s)(X,f,n,u)}var Wt=S(Tu,3);function Lu(f,n,u,s){return le(h=>!h,h=>!h)(ie(n),f,u,s)}var Ut=S(Lu,4);function Ou(f,n,u){return le(s=>!s,s=>!s)(ne,f,n,u)}var Ft=S(Ou,3);function Mu(f,n,u,s){var h=new Array(n.length);f(n,(c,d,p)=>{u(c,(g,m)=>{h[d]=!!m,p(g)})},c=>{if(c)return s(c);for(var d=[],p=0;p<n.length;p++)h[p]&&d.push(n[p]);s(null,d)})}function Au(f,n,u,s){var h=[];f(n,(c,d,p)=>{u(c,(g,m)=>{if(g)return p(g);m&&h.push({index:d,value:c}),p(g)})},c=>{if(c)return s(c);s(null,h.sort((d,p)=>d.index-p.index).map(d=>d.value))})}function $t(f,n,u,s){var h=xt(n)?Mu:Au;return h(f,n,b(u),s)}function qu(f,n,u){return $t(X,f,n,u)}var Ht=S(qu,3);function xu(f,n,u,s){return $t(ie(n),f,u,s)}var Gt=S(xu,4);function Cu(f,n,u){return $t(ne,f,n,u)}var zt=S(Cu,3);function Pu(f,n){var u=_e(n),s=b(Ur(f));function h(c){if(c)return u(c);c!==!1&&s(h)}return h()}var un=S(Pu,2);function Du(f,n,u,s){var h=b(u);return rt(f,n,(c,d)=>{h(c,(p,g)=>p?d(p):d(p,{key:g,val:c}))},(c,d)=>{for(var p={},{hasOwnProperty:g}=Object.prototype,m=0;m<d.length;m++)if(d[m]){var{key:C}=d[m],{val:B}=d[m];g.call(p,C)?p[C].push(B):p[C]=[B]}return s(c,p)})}var Vt=S(Du,4);function on(f,n,u){return Vt(f,1/0,n,u)}function sn(f,n,u){return Vt(f,1,n,u)}var ln=rn("log");function ju(f,n,u,s){s=ve(s);var h={},c=b(u);return ie(n)(f,(d,p,g)=>{c(d,p,(m,C)=>{if(m)return g(m);h[p]=C,g(m)})},d=>s(d,h))}var Kt=S(ju,4);function hn(f,n,u){return Kt(f,1/0,n,u)}function cn(f,n,u){return Kt(f,1,n,u)}function dn(f,n=u=>u){var u=Object.create(null),s=Object.create(null),h=b(f),c=r((d,p)=>{var g=n(...d);g in u?T(()=>p(null,...u[g])):g in s?s[g].push(p):(s[g]=[p],h(...d,(m,...C)=>{m||(u[g]=C);var B=s[g];delete s[g];for(var P=0,Z=B.length;P<Z;P++)B[P](m,...C)}))});return c.memo=u,c.unmemoized=f,c}var Yt;o?Yt=process.nextTick:a?Yt=setImmediate:Yt=l;var pn=y(Yt),Fr=S((f,n,u)=>{var s=xt(n)?[]:{};f(n,(h,c,d)=>{b(h)((p,...g)=>{g.length<2&&([g]=g),s[c]=g,d(p)})},h=>u(h,s))},3);function gn(f,n){return Fr(X,f,n)}function yn(f,n,u){return Fr(ie(n),f,u)}function $r(f,n){var u=b(f);return kr((s,h)=>{u(s[0],h)},n,1)}class Bu{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(n){let u;for(;n>0&&Hr(this.heap[n],this.heap[u=vn(n)]);){let s=this.heap[n];this.heap[n]=this.heap[u],this.heap[u]=s,n=u}}percDown(n){let u;for(;(u=Nu(n))<this.heap.length&&(u+1<this.heap.length&&Hr(this.heap[u+1],this.heap[u])&&(u=u+1),!Hr(this.heap[n],this.heap[u]));){let s=this.heap[n];this.heap[n]=this.heap[u],this.heap[u]=s,n=u}}push(n){n.pushCount=++this.pushCount,this.heap.push(n),this.percUp(this.heap.length-1)}unshift(n){return this.heap.push(n)}shift(){let[n]=this.heap;return this.heap[0]=this.heap[this.heap.length-1],this.heap.pop(),this.percDown(0),n}toArray(){return[...this]}*[Symbol.iterator](){for(let n=0;n<this.heap.length;n++)yield this.heap[n].data}remove(n){let u=0;for(let s=0;s<this.heap.length;s++)n(this.heap[s])||(this.heap[u]=this.heap[s],u++);this.heap.splice(u);for(let s=vn(this.heap.length-1);s>=0;s--)this.percDown(s);return this}}function Nu(f){return(f<<1)+1}function vn(f){return(f+1>>1)-1}function Hr(f,n){return f.priority!==n.priority?f.priority<n.priority:f.pushCount<n.pushCount}function _n(f,n){var u=$r(f,n),{push:s,pushAsync:h}=u;u._tasks=new Bu,u._createTaskItem=({data:d,priority:p},g)=>({data:d,priority:p,callback:g});function c(d,p){return Array.isArray(d)?d.map(g=>({data:g,priority:p})):{data:d,priority:p}}return u.push=function(d,p=0,g){return s(c(d,p),g)},u.pushAsync=function(d,p=0,g){return h(c(d,p),g)},delete u.unshift,delete u.unshiftAsync,u}function Iu(f,n){if(n=ve(n),!Array.isArray(f))return n(new TypeError("First argument to race must be an array of functions"));if(!f.length)return n();for(var u=0,s=f.length;u<s;u++)b(f[u])(n)}var wn=S(Iu,2);function Qt(f,n,u,s){var h=[...f].reverse();return we(h,n,u,s)}function Xt(f){var n=b(f);return r(function(s,h){return s.push((c,...d)=>{let p={};if(c&&(p.error=c),d.length>0){var g=d;d.length<=1&&([g]=d),p.value=g}h(null,p)}),n.apply(this,s)})}function mn(f){var n;return Array.isArray(f)?n=f.map(Xt):(n={},Object.keys(f).forEach(u=>{n[u]=Xt.call(this,f[u])})),n}function Gr(f,n,u,s){let h=b(u);return $t(f,n,(c,d)=>{h(c,(p,g)=>{d(p,!g)})},s)}function ku(f,n,u){return Gr(X,f,n,u)}var bn=S(ku,3);function Wu(f,n,u,s){return Gr(ie(n),f,u,s)}var Sn=S(Wu,4);function Uu(f,n,u){return Gr(ne,f,n,u)}var En=S(Uu,3);function Rn(f){return function(){return f}}let zr=5,Tn=0;function Zt(f,n,u){var s={times:zr,intervalFunc:Rn(Tn)};if(arguments.length<3&&typeof f=="function"?(u=n||Ie(),n=f):(Fu(s,f),u=u||Ie()),typeof n!="function")throw new Error("Invalid arguments for async.retry");var h=b(n),c=1;function d(){h((p,...g)=>{p!==!1&&(p&&c++<s.times&&(typeof s.errorFilter!="function"||s.errorFilter(p))?setTimeout(d,s.intervalFunc(c-1)):u(p,...g))})}return d(),u[Ne]}function Fu(f,n){if(typeof n=="object")f.times=+n.times||zr,f.intervalFunc=typeof n.interval=="function"?n.interval:Rn(+n.interval||Tn),f.errorFilter=n.errorFilter;else if(typeof n=="number"||typeof n=="string")f.times=+n||zr;else throw new Error("Invalid arguments for async.retry")}function Ln(f,n){n||(n=f,f=null);let u=f&&f.arity||n.length;O(n)&&(u+=1);var s=b(n);return r((h,c)=>{(h.length<u-1||c==null)&&(h.push(c),c=Ie());function d(p){s(...h,p)}return f?Zt(f,d,c):Zt(d,c),c[Ne]})}function On(f,n){return Fr(ne,f,n)}function $u(f,n,u){return le(Boolean,s=>s)(X,f,n,u)}var Jt=S($u,3);function Hu(f,n,u,s){return le(Boolean,h=>h)(ie(n),f,u,s)}var er=S(Hu,4);function Gu(f,n,u){return le(Boolean,s=>s)(ne,f,n,u)}var tr=S(Gu,3);function zu(f,n,u){var s=b(n);return Pt(f,(c,d)=>{s(c,(p,g)=>{if(p)return d(p);d(p,{value:c,criteria:g})})},(c,d)=>{if(c)return u(c);u(null,d.sort(h).map(p=>p.value))});function h(c,d){var p=c.criteria,g=d.criteria;return p<g?-1:p>g?1:0}}var Mn=S(zu,3);function An(f,n,u){var s=b(f);return r((h,c)=>{var d=!1,p;function g(){var m=f.name||"anonymous",C=new Error('Callback function "'+m+'" timed out.');C.code="ETIMEDOUT",u&&(C.info=u),d=!0,c(C)}h.push((...m)=>{d||(c(...m),clearTimeout(p))}),p=setTimeout(g,n),s(...h)})}function Vu(f){for(var n=Array(f);f--;)n[f]=f;return n}function rr(f,n,u,s){var h=b(u);return rt(Vu(f),n,h,s)}function qn(f,n,u){return rr(f,1/0,n,u)}function xn(f,n,u){return rr(f,1,n,u)}function Cn(f,n,u,s){arguments.length<=3&&typeof n=="function"&&(s=u,u=n,n=Array.isArray(f)?[]:{}),s=ve(s||Ie());var h=b(u);return X(f,(c,d,p)=>{h(n,c,d,p)},c=>s(c,n)),s[Ne]}function Ku(f,n){var u=null,s;return at(f,(h,c)=>{b(h)((d,...p)=>{if(d===!1)return c(d);p.length<2?[s]=p:s=p,u=d,c(d?null:{})})},()=>n(u,s))}var Pn=S(Ku);function Dn(f){return(...n)=>(f.unmemoized||f)(...n)}function Yu(f,n,u){u=_e(u);var s=b(n),h=b(f),c=[];function d(g,...m){if(g)return u(g);c=m,g!==!1&&h(p)}function p(g,m){if(g)return u(g);if(g!==!1){if(!m)return u(null,...c);s(d)}}return h(p)}var ft=S(Yu,3);function jn(f,n,u){let s=b(f);return ft(h=>s((c,d)=>h(c,!d)),n,u)}function Qu(f,n){if(n=ve(n),!Array.isArray(f))return n(new Error("First argument to waterfall must be an array of functions"));if(!f.length)return n();var u=0;function s(c){var d=b(f[u++]);d(...c,_e(h))}function h(c,...d){if(c!==!1){if(c||u===f.length)return n(c,...d);s(d)}}s([])}var Bn=S(Qu),Xu={apply:t,applyEach:Ki,applyEachSeries:Yi,asyncify:x,auto:Ir,autoInject:Qi,cargo:Zi,cargoQueue:Ji,compose:en,concat:Dt,concatLimit:ke,concatSeries:jt,constant:tn,detect:Bt,detectLimit:Nt,detectSeries:It,dir:nn,doUntil:an,doWhilst:it,each:kt,eachLimit:nt,eachOf:X,eachOfLimit:Be,eachOfSeries:ne,eachSeries:at,ensureAsync:Ur,every:Wt,everyLimit:Ut,everySeries:Ft,filter:Ht,filterLimit:Gt,filterSeries:zt,forever:un,groupBy:on,groupByLimit:Vt,groupBySeries:sn,log:ln,map:Pt,mapLimit:rt,mapSeries:Nr,mapValues:hn,mapValuesLimit:Kt,mapValuesSeries:cn,memoize:dn,nextTick:pn,parallel:gn,parallelLimit:yn,priorityQueue:_n,queue:$r,race:wn,reduce:we,reduceRight:Qt,reflect:Xt,reflectAll:mn,reject:bn,rejectLimit:Sn,rejectSeries:En,retry:Zt,retryable:Ln,seq:Wr,series:On,setImmediate:T,some:Jt,someLimit:er,someSeries:tr,sortBy:Mn,timeout:An,times:qn,timesLimit:rr,timesSeries:xn,transform:Cn,tryEach:Pn,unmemoize:Dn,until:jn,waterfall:Bn,whilst:ft,all:Wt,allLimit:Ut,allSeries:Ft,any:Jt,anyLimit:er,anySeries:tr,find:Bt,findLimit:Nt,findSeries:It,flatMap:Dt,flatMapLimit:ke,flatMapSeries:jt,forEach:kt,forEachSeries:at,forEachLimit:nt,forEachOf:X,forEachOfSeries:ne,forEachOfLimit:Be,inject:we,foldl:we,foldr:Qt,select:Ht,selectLimit:Gt,selectSeries:zt,wrapSync:x,during:ft,doDuring:it};e.all=Wt,e.allLimit=Ut,e.allSeries=Ft,e.any=Jt,e.anyLimit=er,e.anySeries=tr,e.apply=t,e.applyEach=Ki,e.applyEachSeries=Yi,e.asyncify=x,e.auto=Ir,e.autoInject=Qi,e.cargo=Zi,e.cargoQueue=Ji,e.compose=en,e.concat=Dt,e.concatLimit=ke,e.concatSeries=jt,e.constant=tn,e.default=Xu,e.detect=Bt,e.detectLimit=Nt,e.detectSeries=It,e.dir=nn,e.doDuring=it,e.doUntil=an,e.doWhilst=it,e.during=ft,e.each=kt,e.eachLimit=nt,e.eachOf=X,e.eachOfLimit=Be,e.eachOfSeries=ne,e.eachSeries=at,e.ensureAsync=Ur,e.every=Wt,e.everyLimit=Ut,e.everySeries=Ft,e.filter=Ht,e.filterLimit=Gt,e.filterSeries=zt,e.find=Bt,e.findLimit=Nt,e.findSeries=It,e.flatMap=Dt,e.flatMapLimit=ke,e.flatMapSeries=jt,e.foldl=we,e.foldr=Qt,e.forEach=kt,e.forEachLimit=nt,e.forEachOf=X,e.forEachOfLimit=Be,e.forEachOfSeries=ne,e.forEachSeries=at,e.forever=un,e.groupBy=on,e.groupByLimit=Vt,e.groupBySeries=sn,e.inject=we,e.log=ln,e.map=Pt,e.mapLimit=rt,e.mapSeries=Nr,e.mapValues=hn,e.mapValuesLimit=Kt,e.mapValuesSeries=cn,e.memoize=dn,e.nextTick=pn,e.parallel=gn,e.parallelLimit=yn,e.priorityQueue=_n,e.queue=$r,e.race=wn,e.reduce=we,e.reduceRight=Qt,e.reflect=Xt,e.reflectAll=mn,e.reject=bn,e.rejectLimit=Sn,e.rejectSeries=En,e.retry=Zt,e.retryable=Ln,e.select=Ht,e.selectLimit=Gt,e.selectSeries=zt,e.seq=Wr,e.series=On,e.setImmediate=T,e.some=Jt,e.someLimit=er,e.someSeries=tr,e.sortBy=Mn,e.timeout=An,e.times=qn,e.timesLimit=rr,e.timesSeries=xn,e.transform=Cn,e.tryEach=Pn,e.unmemoize=Dn,e.until=jn,e.waterfall=Bn,e.whilst=ft,e.wrapSync=x,Object.defineProperty(e,"__esModule",{value:!0})}))});var Vr=A((Qh,kn)=>{v();kn.exports=$("stream")});var Gn=A((Zh,Hn)=>{"use strict";v();function Wn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,i)}return r}function Un(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Wn(Object(r),!0).forEach(function(i){to(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wn(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function to(e,t,r){return t=$n(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ro(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,$n(i.key),i)}}function io(e,t,r){return t&&Fn(e.prototype,t),r&&Fn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function $n(e){var t=no(e,"string");return typeof t=="symbol"?t:String(t)}function no(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ao=$("buffer"),nr=ao.Buffer,fo=$("util"),Kr=fo.inspect,uo=Kr&&Kr.custom||"inspect";function oo(e,t,r){nr.prototype.copy.call(e,t,r)}Hn.exports=(function(){function e(){ro(this,e),this.head=null,this.tail=null,this.length=0}return io(e,[{key:"push",value:function(r){var i={data:r,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length}},{key:"unshift",value:function(r){var i={data:r,next:this.head};this.length===0&&(this.tail=i),this.head=i,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var i=this.head,a=""+i.data;i=i.next;)a+=r+i.data;return a}},{key:"concat",value:function(r){if(this.length===0)return nr.alloc(0);for(var i=nr.allocUnsafe(r>>>0),a=this.head,o=0;a;)oo(a.data,i,o),o+=a.data.length,a=a.next;return i}},{key:"consume",value:function(r,i){var a;return r<this.head.data.length?(a=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?a=this.shift():a=i?this._getString(r):this._getBuffer(r),a}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var i=this.head,a=1,o=i.data;for(r-=o.length;i=i.next;){var l=i.data,y=r>l.length?l.length:r;if(y===l.length?o+=l:o+=l.slice(0,r),r-=y,r===0){y===l.length?(++a,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=l.slice(y));break}++a}return this.length-=a,o}},{key:"_getBuffer",value:function(r){var i=nr.allocUnsafe(r),a=this.head,o=1;for(a.data.copy(i),r-=a.data.length;a=a.next;){var l=a.data,y=r>l.length?l.length:r;if(l.copy(i,i.length-r,0,y),r-=y,r===0){y===l.length?(++o,a.next?this.head=a.next:this.head=this.tail=null):(this.head=a,a.data=l.slice(y));break}++o}return this.length-=o,i}},{key:uo,value:function(r,i){return Kr(this,Un(Un({},i),{},{depth:0,customInspect:!1}))}}]),e})()});var Qr=A((ec,Vn)=>{"use strict";v();function so(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Yr,this,e)):process.nextTick(Yr,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?process.nextTick(ar,r):(r._writableState.errorEmitted=!0,process.nextTick(zn,r,o)):process.nextTick(zn,r,o):t?(process.nextTick(ar,r),t(o)):process.nextTick(ar,r)}),this)}function zn(e,t){Yr(e,t),ar(e)}function ar(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function lo(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Yr(e,t){e.emit("error",t)}function ho(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}Vn.exports={destroy:so,undestroy:lo,errorOrDestroy:ho}});var me=A((rc,Qn)=>{"use strict";v();var Yn={};function te(e,t,r){r||(r=Error);function i(o,l,y){return typeof t=="string"?t:t(o,l,y)}class a extends r{constructor(l,y,_){super(i(l,y,_))}}a.prototype.name=r.name,a.prototype.code=e,Yn[e]=a}function Kn(e,t){if(Array.isArray(e)){let r=e.length;return e=e.map(i=>String(i)),r>2?`one of ${t} ${e.slice(0,r-1).join(", ")}, or `+e[r-1]:r===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function co(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function po(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function go(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}te("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);te("ERR_INVALID_ARG_TYPE",function(e,t,r){let i;typeof t=="string"&&co(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";let a;if(po(e," argument"))a=`The ${e} ${i} ${Kn(t,"type")}`;else{let o=go(e,".")?"property":"argument";a=`The "${e}" ${o} ${i} ${Kn(t,"type")}`}return a+=`. Received type ${typeof r}`,a},TypeError);te("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");te("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});te("ERR_STREAM_PREMATURE_CLOSE","Premature close");te("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});te("ERR_MULTIPLE_CALLBACK","Callback called multiple times");te("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");te("ERR_STREAM_WRITE_AFTER_END","write after end");te("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);te("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);te("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Qn.exports.codes=Yn});var Xr=A((nc,Xn)=>{"use strict";v();var yo=me().codes.ERR_INVALID_OPT_VALUE;function vo(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function _o(e,t,r,i){var a=vo(t,i,r);if(a!=null){if(!(isFinite(a)&&Math.floor(a)===a)||a<0){var o=i?r:"highWaterMark";throw new yo(o,a)}return Math.floor(a)}return e.objectMode?16:16*1024}Xn.exports={getHighWaterMark:_o}});var ei=A((fc,ia)=>{"use strict";v();ia.exports=F;function Jn(e){var t=this;this.next=null,this.entry=null,this.finish=function(){Go(t,e)}}var Fe;F.WritableState=lt;var wo={deprecate:Nn()},ea=Vr(),ur=$("buffer").Buffer,mo=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function bo(e){return ur.from(e)}function So(e){return ur.isBuffer(e)||e instanceof mo}var Jr=Qr(),Eo=Xr(),Ro=Eo.getHighWaterMark,be=me().codes,To=be.ERR_INVALID_ARG_TYPE,Lo=be.ERR_METHOD_NOT_IMPLEMENTED,Oo=be.ERR_MULTIPLE_CALLBACK,Mo=be.ERR_STREAM_CANNOT_PIPE,Ao=be.ERR_STREAM_DESTROYED,qo=be.ERR_STREAM_NULL_VALUES,xo=be.ERR_STREAM_WRITE_AFTER_END,Co=be.ERR_UNKNOWN_ENCODING,$e=Jr.errorOrDestroy;ee()(F,ea);function Po(){}function lt(e,t,r){Fe=Fe||Ae(),e=e||{},typeof r!="boolean"&&(r=t instanceof Fe),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=Ro(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){Wo(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Jn(this)}lt.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(lt.prototype,"buffer",{get:wo.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var fr;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(fr=Function.prototype[Symbol.hasInstance],Object.defineProperty(F,Symbol.hasInstance,{value:function(t){return fr.call(this,t)?!0:this!==F?!1:t&&t._writableState instanceof lt}})):fr=function(t){return t instanceof this};function F(e){Fe=Fe||Ae();var t=this instanceof Fe;if(!t&&!fr.call(F,this))return new F(e);this._writableState=new lt(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),ea.call(this)}F.prototype.pipe=function(){$e(this,new Mo)};function Do(e,t){var r=new xo;$e(e,r),process.nextTick(t,r)}function jo(e,t,r,i){var a;return r===null?a=new qo:typeof r!="string"&&!t.objectMode&&(a=new To("chunk",["string","Buffer"],r)),a?($e(e,a),process.nextTick(i,a),!1):!0}F.prototype.write=function(e,t,r){var i=this._writableState,a=!1,o=!i.objectMode&&So(e);return o&&!ur.isBuffer(e)&&(e=bo(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=Po),i.ending?Do(this,r):(o||jo(this,i,e,r))&&(i.pendingcb++,a=No(this,i,o,e,t,r)),a};F.prototype.cork=function(){this._writableState.corked++};F.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&ta(this,e))};F.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new Co(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(F.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Bo(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=ur.from(t,r)),t}Object.defineProperty(F.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function No(e,t,r,i,a,o){if(!r){var l=Bo(t,i,a);i!==l&&(r=!0,a="buffer",i=l)}var y=t.objectMode?1:i.length;t.length+=y;var _=t.length<t.highWaterMark;if(_||(t.needDrain=!0),t.writing||t.corked){var T=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:a,isBuf:r,callback:o,next:null},T?T.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Zr(e,t,!1,y,i,a,o);return _}function Zr(e,t,r,i,a,o,l){t.writelen=i,t.writecb=l,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new Ao("write")):r?e._writev(a,t.onwrite):e._write(a,o,t.onwrite),t.sync=!1}function Io(e,t,r,i,a){--t.pendingcb,r?(process.nextTick(a,i),process.nextTick(st,e,t),e._writableState.errorEmitted=!0,$e(e,i)):(a(i),e._writableState.errorEmitted=!0,$e(e,i),st(e,t))}function ko(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function Wo(e,t){var r=e._writableState,i=r.sync,a=r.writecb;if(typeof a!="function")throw new Oo;if(ko(r),t)Io(e,r,i,t,a);else{var o=ra(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&ta(e,r),i?process.nextTick(Zn,e,r,o,a):Zn(e,r,o,a)}}function Zn(e,t,r,i){r||Uo(e,t),t.pendingcb--,i(),st(e,t)}function Uo(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function ta(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,a=new Array(i),o=t.corkedRequestsFree;o.entry=r;for(var l=0,y=!0;r;)a[l]=r,r.isBuf||(y=!1),r=r.next,l+=1;a.allBuffers=y,Zr(e,t,!0,t.length,a,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Jn(t),t.bufferedRequestCount=0}else{for(;r;){var _=r.chunk,T=r.encoding,x=r.callback,M=t.objectMode?1:_.length;if(Zr(e,t,!1,M,_,T,x),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}F.prototype._write=function(e,t,r){r(new Lo("_write()"))};F.prototype._writev=null;F.prototype.end=function(e,t,r){var i=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||Ho(this,i,r),this};Object.defineProperty(F.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function ra(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Fo(e,t){e._final(function(r){t.pendingcb--,r&&$e(e,r),t.prefinished=!0,e.emit("prefinish"),st(e,t)})}function $o(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,process.nextTick(Fo,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function st(e,t){var r=ra(t);if(r&&($o(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}function Ho(e,t,r){t.ending=!0,st(e,t),r&&(t.finished?process.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function Go(e,t,r){var i=e.entry;for(e.entry=null;i;){var a=i.callback;t.pendingcb--,a(r),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(F.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});F.prototype.destroy=Jr.destroy;F.prototype._undestroy=Jr.undestroy;F.prototype._destroy=function(e,t){t(e)}});var Ae=A((oc,aa)=>{"use strict";v();var zo=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};aa.exports=fe;var na=ii(),ri=ei();ee()(fe,na);for(ti=zo(ri.prototype),or=0;or<ti.length;or++)sr=ti[or],fe.prototype[sr]||(fe.prototype[sr]=ri.prototype[sr]);var ti,sr,or;function fe(e){if(!(this instanceof fe))return new fe(e);na.call(this,e),ri.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",Vo)))}Object.defineProperty(fe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(fe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(fe.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Vo(){this._writableState.ended||process.nextTick(Ko,this)}function Ko(e){e.end()}Object.defineProperty(fe.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var oa=A((ni,ua)=>{v();var lr=$("buffer"),ue=lr.Buffer;function fa(e,t){for(var r in e)t[r]=e[r]}ue.from&&ue.alloc&&ue.allocUnsafe&&ue.allocUnsafeSlow?ua.exports=lr:(fa(lr,ni),ni.Buffer=qe);function qe(e,t,r){return ue(e,t,r)}qe.prototype=Object.create(ue.prototype);fa(ue,qe);qe.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return ue(e,t,r)};qe.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=ue(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};qe.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ue(e)};qe.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return lr.SlowBuffer(e)}});var ui=A(la=>{"use strict";v();var fi=oa().Buffer,sa=fi.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Yo(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Qo(e){var t=Yo(e);if(typeof t!="string"&&(fi.isEncoding===sa||!sa(e)))throw new Error("Unknown encoding: "+e);return t||e}la.StringDecoder=ht;function ht(e){this.encoding=Qo(e);var t;switch(this.encoding){case"utf16le":this.text=rs,this.end=is,t=4;break;case"utf8":this.fillLast=Jo,t=4;break;case"base64":this.text=ns,this.end=as,t=3;break;default:this.write=fs,this.end=us;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=fi.allocUnsafe(t)}ht.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};ht.prototype.end=ts;ht.prototype.text=es;ht.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function ai(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Xo(e,t,r){var i=t.length-1;if(i<r)return 0;var a=ai(t[i]);return a>=0?(a>0&&(e.lastNeed=a-1),a):--i<r||a===-2?0:(a=ai(t[i]),a>=0?(a>0&&(e.lastNeed=a-2),a):--i<r||a===-2?0:(a=ai(t[i]),a>=0?(a>0&&(a===2?a=0:e.lastNeed=a-3),a):0))}function Zo(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Jo(e){var t=this.lastTotal-this.lastNeed,r=Zo(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function es(e,t){var r=Xo(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function ts(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function rs(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function is(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function ns(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function as(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function fs(e){return e.toString(this.encoding)}function us(e){return e&&e.length?this.write(e):""}});var hr=A((dc,da)=>{"use strict";v();var ha=me().codes.ERR_STREAM_PREMATURE_CLOSE;function os(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];e.apply(this,i)}}}function ss(){}function ls(e){return e.setHeader&&typeof e.abort=="function"}function ca(e,t,r){if(typeof t=="function")return ca(e,null,t);t||(t={}),r=os(r||ss);var i=t.readable||t.readable!==!1&&e.readable,a=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||y()},l=e._writableState&&e._writableState.finished,y=function(){a=!1,l=!0,i||r.call(e)},_=e._readableState&&e._readableState.endEmitted,T=function(){i=!1,_=!0,a||r.call(e)},x=function(H){r.call(e,H)},M=function(){var H;if(i&&!_)return(!e._readableState||!e._readableState.ended)&&(H=new ha),r.call(e,H);if(a&&!l)return(!e._writableState||!e._writableState.ended)&&(H=new ha),r.call(e,H)},L=function(){e.req.on("finish",y)};return ls(e)?(e.on("complete",y),e.on("abort",M),e.req?L():e.on("request",L)):a&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",T),e.on("finish",y),t.error!==!1&&e.on("error",x),e.on("close",M),function(){e.removeListener("complete",y),e.removeListener("abort",M),e.removeListener("request",L),e.req&&e.req.removeListener("finish",y),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",y),e.removeListener("end",T),e.removeListener("error",x),e.removeListener("close",M)}}da.exports=ca});var ga=A((gc,pa)=>{"use strict";v();var cr;function Se(e,t,r){return t=hs(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hs(e){var t=cs(e,"string");return typeof t=="symbol"?t:String(t)}function cs(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ds=hr(),Ee=Symbol("lastResolve"),xe=Symbol("lastReject"),ct=Symbol("error"),dr=Symbol("ended"),Ce=Symbol("lastPromise"),oi=Symbol("handlePromise"),Pe=Symbol("stream");function Re(e,t){return{value:e,done:t}}function ps(e){var t=e[Ee];if(t!==null){var r=e[Pe].read();r!==null&&(e[Ce]=null,e[Ee]=null,e[xe]=null,t(Re(r,!1)))}}function gs(e){process.nextTick(ps,e)}function ys(e,t){return function(r,i){e.then(function(){if(t[dr]){r(Re(void 0,!0));return}t[oi](r,i)},i)}}var vs=Object.getPrototypeOf(function(){}),_s=Object.setPrototypeOf((cr={get stream(){return this[Pe]},next:function(){var t=this,r=this[ct];if(r!==null)return Promise.reject(r);if(this[dr])return Promise.resolve(Re(void 0,!0));if(this[Pe].destroyed)return new Promise(function(l,y){process.nextTick(function(){t[ct]?y(t[ct]):l(Re(void 0,!0))})});var i=this[Ce],a;if(i)a=new Promise(ys(i,this));else{var o=this[Pe].read();if(o!==null)return Promise.resolve(Re(o,!1));a=new Promise(this[oi])}return this[Ce]=a,a}},Se(cr,Symbol.asyncIterator,function(){return this}),Se(cr,"return",function(){var t=this;return new Promise(function(r,i){t[Pe].destroy(null,function(a){if(a){i(a);return}r(Re(void 0,!0))})})}),cr),vs),ws=function(t){var r,i=Object.create(_s,(r={},Se(r,Pe,{value:t,writable:!0}),Se(r,Ee,{value:null,writable:!0}),Se(r,xe,{value:null,writable:!0}),Se(r,ct,{value:null,writable:!0}),Se(r,dr,{value:t._readableState.endEmitted,writable:!0}),Se(r,oi,{value:function(o,l){var y=i[Pe].read();y?(i[Ce]=null,i[Ee]=null,i[xe]=null,o(Re(y,!1))):(i[Ee]=o,i[xe]=l)},writable:!0}),r));return i[Ce]=null,ds(t,function(a){if(a&&a.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=i[xe];o!==null&&(i[Ce]=null,i[Ee]=null,i[xe]=null,o(a)),i[ct]=a;return}var l=i[Ee];l!==null&&(i[Ce]=null,i[Ee]=null,i[xe]=null,l(Re(void 0,!0))),i[dr]=!0}),t.on("readable",gs.bind(null,i)),i};pa.exports=ws});var wa=A((vc,_a)=>{"use strict";v();function ya(e,t,r,i,a,o,l){try{var y=e[o](l),_=y.value}catch(T){r(T);return}y.done?t(_):Promise.resolve(_).then(i,a)}function ms(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function l(_){ya(o,i,a,l,y,"next",_)}function y(_){ya(o,i,a,l,y,"throw",_)}l(void 0)})}}function va(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,i)}return r}function bs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?va(Object(r),!0).forEach(function(i){Ss(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):va(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Ss(e,t,r){return t=Es(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Es(e){var t=Rs(e,"string");return typeof t=="symbol"?t:String(t)}function Rs(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ts=me().codes.ERR_INVALID_ARG_TYPE;function Ls(e,t,r){var i;if(t&&typeof t.next=="function")i=t;else if(t&&t[Symbol.asyncIterator])i=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])i=t[Symbol.iterator]();else throw new Ts("iterable",["Iterable"],t);var a=new e(bs({objectMode:!0},r)),o=!1;a._read=function(){o||(o=!0,l())};function l(){return y.apply(this,arguments)}function y(){return y=ms(function*(){try{var _=yield i.next(),T=_.value,x=_.done;x?a.push(null):a.push(yield T)?l():o=!1}catch(M){a.destroy(M)}}),y.apply(this,arguments)}return a}_a.exports=Ls});var ii=A((mc,Aa)=>{"use strict";v();Aa.exports=j;var He;j.ReadableState=Ea;var wc=$("events").EventEmitter,Sa=function(t,r){return t.listeners(r).length},pt=Vr(),pr=$("buffer").Buffer,Os=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Ms(e){return pr.from(e)}function As(e){return pr.isBuffer(e)||e instanceof Os}var si=$("util"),q;si&&si.debuglog?q=si.debuglog("stream"):q=function(){};var qs=Gn(),yi=Qr(),xs=Xr(),Cs=xs.getHighWaterMark,gr=me().codes,Ps=gr.ERR_INVALID_ARG_TYPE,Ds=gr.ERR_STREAM_PUSH_AFTER_EOF,js=gr.ERR_METHOD_NOT_IMPLEMENTED,Bs=gr.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Ge,li,hi;ee()(j,pt);var dt=yi.errorOrDestroy,ci=["error","close","destroy","pause","resume"];function Ns(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Ea(e,t,r){He=He||Ae(),e=e||{},typeof r!="boolean"&&(r=t instanceof He),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=Cs(this,e,"readableHighWaterMark",r),this.buffer=new qs,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Ge||(Ge=ui().StringDecoder),this.decoder=new Ge(e.encoding),this.encoding=e.encoding)}function j(e){if(He=He||Ae(),!(this instanceof j))return new j(e);var t=this instanceof He;this._readableState=new Ea(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),pt.call(this)}Object.defineProperty(j.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});j.prototype.destroy=yi.destroy;j.prototype._undestroy=yi.undestroy;j.prototype._destroy=function(e,t){t(e)};j.prototype.push=function(e,t){var r=this._readableState,i;return r.objectMode?i=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=pr.from(e,t),t=""),i=!0),Ra(this,e,t,!1,i)};j.prototype.unshift=function(e){return Ra(this,e,null,!0,!1)};function Ra(e,t,r,i,a){q("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,Ws(e,o);else{var l;if(a||(l=Is(o,t)),l)dt(e,l);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==pr.prototype&&(t=Ms(t)),i)o.endEmitted?dt(e,new Bs):di(e,o,t,!0);else if(o.ended)dt(e,new Ds);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?di(e,o,t,!1):gi(e,o)):di(e,o,t,!1)}else i||(o.reading=!1,gi(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function di(e,t,r,i){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&yr(e)),gi(e,t)}function Is(e,t){var r;return!As(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new Ps("chunk",["string","Buffer","Uint8Array"],t)),r}j.prototype.isPaused=function(){return this._readableState.flowing===!1};j.prototype.setEncoding=function(e){Ge||(Ge=ui().StringDecoder);var t=new Ge(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";r!==null;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),i!==""&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var ma=1073741824;function ks(e){return e>=ma?e=ma:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ba(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=ks(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}j.prototype.read=function(e){q("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return q("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?pi(this):yr(this),null;if(e=ba(e,t),e===0&&t.ended)return t.length===0&&pi(this),null;var i=t.needReadable;q("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,q("length less than watermark",i)),t.ended||t.reading?(i=!1,q("reading or ended",i)):i&&(q("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ba(r,t)));var a;return e>0?a=Oa(e,t):a=null,a===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&pi(this)),a!==null&&this.emit("data",a),a};function Ws(e,t){if(q("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?yr(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,Ta(e)))}}function yr(e){var t=e._readableState;q("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(q("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(Ta,e))}function Ta(e){var t=e._readableState;q("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,vi(e)}function gi(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(Us,e,t))}function Us(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(q("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}j.prototype._read=function(e){dt(this,new js("_read()"))};j.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,q("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,o=a?y:Q;i.endEmitted?process.nextTick(o):r.once("end",o),e.on("unpipe",l);function l(b,S){q("onunpipe"),b===r&&S&&S.hasUnpiped===!1&&(S.hasUnpiped=!0,x())}function y(){q("onend"),e.end()}var _=Fs(r);e.on("drain",_);var T=!1;function x(){q("cleanup"),e.removeListener("close",O),e.removeListener("finish",H),e.removeListener("drain",_),e.removeListener("error",L),e.removeListener("unpipe",l),r.removeListener("end",y),r.removeListener("end",Q),r.removeListener("data",M),T=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&_()}r.on("data",M);function M(b){q("ondata");var S=e.write(b);q("dest.write",S),S===!1&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&Ma(i.pipes,e)!==-1)&&!T&&(q("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function L(b){q("onerror",b),Q(),e.removeListener("error",L),Sa(e,"error")===0&&dt(e,b)}Ns(e,"error",L);function O(){e.removeListener("finish",H),Q()}e.once("close",O);function H(){q("onfinish"),e.removeListener("close",O),Q()}e.once("finish",H);function Q(){q("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(q("pipe resume"),r.resume()),e};function Fs(e){return function(){var r=e._readableState;q("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Sa(e,"data")&&(r.flowing=!0,vi(e))}}j.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var i=t.pipes,a=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<a;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var l=Ma(t.pipes,e);return l===-1?this:(t.pipes.splice(l,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};j.prototype.on=function(e,t){var r=pt.prototype.on.call(this,e,t),i=this._readableState;return e==="data"?(i.readableListening=this.listenerCount("readable")>0,i.flowing!==!1&&this.resume()):e==="readable"&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,q("on readable",i.length,i.reading),i.length?yr(this):i.reading||process.nextTick($s,this)),r};j.prototype.addListener=j.prototype.on;j.prototype.removeListener=function(e,t){var r=pt.prototype.removeListener.call(this,e,t);return e==="readable"&&process.nextTick(La,this),r};j.prototype.removeAllListeners=function(e){var t=pt.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&process.nextTick(La,this),t};function La(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function $s(e){q("readable nexttick read 0"),e.read(0)}j.prototype.resume=function(){var e=this._readableState;return e.flowing||(q("resume"),e.flowing=!e.readableListening,Hs(this,e)),e.paused=!1,this};function Hs(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(Gs,e,t))}function Gs(e,t){q("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),vi(e),t.flowing&&!t.reading&&e.read(0)}j.prototype.pause=function(){return q("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(q("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function vi(e){var t=e._readableState;for(q("flow",t.flowing);t.flowing&&e.read()!==null;);}j.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;e.on("end",function(){if(q("wrapped end"),r.decoder&&!r.ended){var l=r.decoder.end();l&&l.length&&t.push(l)}t.push(null)}),e.on("data",function(l){if(q("wrapped data"),r.decoder&&(l=r.decoder.write(l)),!(r.objectMode&&l==null)&&!(!r.objectMode&&(!l||!l.length))){var y=t.push(l);y||(i=!0,e.pause())}});for(var a in e)this[a]===void 0&&typeof e[a]=="function"&&(this[a]=(function(y){return function(){return e[y].apply(e,arguments)}})(a));for(var o=0;o<ci.length;o++)e.on(ci[o],this.emit.bind(this,ci[o]));return this._read=function(l){q("wrapped _read",l),i&&(i=!1,e.resume())},this};typeof Symbol=="function"&&(j.prototype[Symbol.asyncIterator]=function(){return li===void 0&&(li=ga()),li(this)});Object.defineProperty(j.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(j.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(j.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});j._fromList=Oa;Object.defineProperty(j.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function Oa(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function pi(e){var t=e._readableState;q("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(zs,t,e))}function zs(e,t){if(q("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(j.from=function(e,t){return hi===void 0&&(hi=wa()),hi(j,e,t)});function Ma(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}});var _i=A((Sc,xa)=>{"use strict";v();xa.exports=he;var vr=me().codes,Vs=vr.ERR_METHOD_NOT_IMPLEMENTED,Ks=vr.ERR_MULTIPLE_CALLBACK,Ys=vr.ERR_TRANSFORM_ALREADY_TRANSFORMING,Qs=vr.ERR_TRANSFORM_WITH_LENGTH_0,_r=Ae();ee()(he,_r);function Xs(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new Ks);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function he(e){if(!(this instanceof he))return new he(e);_r.call(this,e),this._transformState={afterTransform:Xs.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Zs)}function Zs(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){qa(e,t,r)}):qa(this,null,null)}he.prototype.push=function(e,t){return this._transformState.needTransform=!1,_r.prototype.push.call(this,e,t)};he.prototype._transform=function(e,t,r){r(new Vs("_transform()"))};he.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var a=this._readableState;(i.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}};he.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};he.prototype._destroy=function(e,t){_r.prototype._destroy.call(this,e,function(r){t(r)})};function qa(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Qs;if(e._transformState.transforming)throw new Ys;return e.push(null)}});var Da=A((Rc,Pa)=>{"use strict";v();Pa.exports=gt;var Ca=_i();ee()(gt,Ca);function gt(e){if(!(this instanceof gt))return new gt(e);Ca.call(this,e)}gt.prototype._transform=function(e,t,r){r(null,e)}});var ka=A((Lc,Ia)=>{"use strict";v();var wi;function Js(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Na=me().codes,el=Na.ERR_MISSING_ARGS,tl=Na.ERR_STREAM_DESTROYED;function ja(e){if(e)throw e}function rl(e){return e.setHeader&&typeof e.abort=="function"}function il(e,t,r,i){i=Js(i);var a=!1;e.on("close",function(){a=!0}),wi===void 0&&(wi=hr()),wi(e,{readable:t,writable:r},function(l){if(l)return i(l);a=!0,i()});var o=!1;return function(l){if(!a&&!o){if(o=!0,rl(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();i(l||new tl("pipe"))}}}function Ba(e){e()}function nl(e,t){return e.pipe(t)}function al(e){return!e.length||typeof e[e.length-1]!="function"?ja:e.pop()}function fl(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=al(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new el("streams");var a,o=t.map(function(l,y){var _=y<t.length-1,T=y>0;return il(l,_,T,function(x){a||(a=x),x&&o.forEach(Ba),!_&&(o.forEach(Ba),i(a))})});return t.reduce(nl)}Ia.exports=fl});var ze=A((re,vt)=>{v();var yt=$("stream");process.env.READABLE_STREAM==="disable"&&yt?(vt.exports=yt.Readable,Object.assign(vt.exports,yt),vt.exports.Stream=yt):(re=vt.exports=ii(),re.Stream=yt||re,re.Readable=re,re.Writable=ei(),re.Duplex=Ae(),re.Transform=_i(),re.PassThrough=Da(),re.finished=hr(),re.pipeline=ka())});var Fa=A((Ac,Ua)=>{"use strict";v();var{Buffer:ae}=$("buffer"),Wa=Symbol.for("BufferList");function k(e){if(!(this instanceof k))return new k(e);k._init.call(this,e)}k._init=function(t){Object.defineProperty(this,Wa,{value:!0}),this._bufs=[],this.length=0,t&&this.append(t)};k.prototype._new=function(t){return new k(t)};k.prototype._offset=function(t){if(t===0)return[0,0];let r=0;for(let i=0;i<this._bufs.length;i++){let a=r+this._bufs[i].length;if(t<a||i===this._bufs.length-1)return[i,t-r];r=a}};k.prototype._reverseOffset=function(e){let t=e[0],r=e[1];for(let i=0;i<t;i++)r+=this._bufs[i].length;return r};k.prototype.get=function(t){if(t>this.length||t<0)return;let r=this._offset(t);return this._bufs[r[0]][r[1]]};k.prototype.slice=function(t,r){return typeof t=="number"&&t<0&&(t+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,t,r)};k.prototype.copy=function(t,r,i,a){if((typeof i!="number"||i<0)&&(i=0),(typeof a!="number"||a>this.length)&&(a=this.length),i>=this.length||a<=0)return t||ae.alloc(0);let o=!!t,l=this._offset(i),y=a-i,_=y,T=o&&r||0,x=l[1];if(i===0&&a===this.length){if(!o)return this._bufs.length===1?this._bufs[0]:ae.concat(this._bufs,this.length);for(let M=0;M<this._bufs.length;M++)this._bufs[M].copy(t,T),T+=this._bufs[M].length;return t}if(_<=this._bufs[l[0]].length-x)return o?this._bufs[l[0]].copy(t,r,x,x+_):this._bufs[l[0]].slice(x,x+_);o||(t=ae.allocUnsafe(y));for(let M=l[0];M<this._bufs.length;M++){let L=this._bufs[M].length-x;if(_>L)this._bufs[M].copy(t,T,x),T+=L;else{this._bufs[M].copy(t,T,x,x+_),T+=L;break}_-=L,x&&(x=0)}return t.length>T?t.slice(0,T):t};k.prototype.shallowSlice=function(t,r){if(t=t||0,r=typeof r!="number"?this.length:r,t<0&&(t+=this.length),r<0&&(r+=this.length),t===r)return this._new();let i=this._offset(t),a=this._offset(r),o=this._bufs.slice(i[0],a[0]+1);return a[1]===0?o.pop():o[o.length-1]=o[o.length-1].slice(0,a[1]),i[1]!==0&&(o[0]=o[0].slice(i[1])),this._new(o)};k.prototype.toString=function(t,r,i){return this.slice(r,i).toString(t)};k.prototype.consume=function(t){if(t=Math.trunc(t),Number.isNaN(t)||t<=0)return this;for(;this._bufs.length;)if(t>=this._bufs[0].length)t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}return this};k.prototype.duplicate=function(){let t=this._new();for(let r=0;r<this._bufs.length;r++)t.append(this._bufs[r]);return t};k.prototype.append=function(t){if(t==null)return this;if(t.buffer)this._appendBuffer(ae.from(t.buffer,t.byteOffset,t.byteLength));else if(Array.isArray(t))for(let r=0;r<t.length;r++)this.append(t[r]);else if(this._isBufferList(t))for(let r=0;r<t._bufs.length;r++)this.append(t._bufs[r]);else typeof t=="number"&&(t=t.toString()),this._appendBuffer(ae.from(t));return this};k.prototype._appendBuffer=function(t){this._bufs.push(t),this.length+=t.length};k.prototype.indexOf=function(e,t,r){if(r===void 0&&typeof t=="string"&&(r=t,t=void 0),typeof e=="function"||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof e=="number"?e=ae.from([e]):typeof e=="string"?e=ae.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=ae.from(e.buffer,e.byteOffset,e.byteLength):ae.isBuffer(e)||(e=ae.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let i=this._offset(t),a=i[0],o=i[1];for(;a<this._bufs.length;a++){let l=this._bufs[a];for(;o<l.length;)if(l.length-o>=e.length){let _=l.indexOf(e,o);if(_!==-1)return this._reverseOffset([a,_]);o=l.length-e.length+1}else{let _=this._reverseOffset([a,o]);if(this._match(_,e))return _;o++}o=0}return-1};k.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0};(function(){let e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let t in e)(function(r){e[r]===null?k.prototype[r]=function(i,a){return this.slice(i,i+a)[r](0,a)}:k.prototype[r]=function(i=0){return this.slice(i,i+e[r])[r](0)}})(t)})();k.prototype._isBufferList=function(t){return t instanceof k||k.isBufferList(t)};k.isBufferList=function(t){return t!=null&&t[Wa]};Ua.exports=k});var $a=A((xc,wr)=>{"use strict";v();var mi=ze().Duplex,ul=ee(),_t=Fa();function K(e){if(!(this instanceof K))return new K(e);if(typeof e=="function"){this._callback=e;let t=function(i){this._callback&&(this._callback(i),this._callback=null)}.bind(this);this.on("pipe",function(i){i.on("error",t)}),this.on("unpipe",function(i){i.removeListener("error",t)}),e=null}_t._init.call(this,e),mi.call(this)}ul(K,mi);Object.assign(K.prototype,_t.prototype);K.prototype._new=function(t){return new K(t)};K.prototype._write=function(t,r,i){this._appendBuffer(t),typeof i=="function"&&i()};K.prototype._read=function(t){if(!this.length)return this.push(null);t=Math.min(t,this.length),this.push(this.slice(0,t)),this.consume(t)};K.prototype.end=function(t){mi.prototype.end.call(this,t),this._callback&&(this._callback(null,this.slice()),this._callback=null)};K.prototype._destroy=function(t,r){this._bufs.length=0,this.length=0,r(t)};K.prototype._isBufferList=function(t){return t instanceof K||t instanceof _t||K.isBufferList(t)};K.isBufferList=_t.isBufferList;wr.exports=K;wr.exports.BufferListStream=K;wr.exports.BufferList=_t});var Ei=A(Ke=>{v();var ol=Buffer.alloc,sl="0000000000000000000",ll="7777777777777777777",Ha=48,Ga=Buffer.from("ustar\0","binary"),hl=Buffer.from("00","binary"),cl=Buffer.from("ustar ","binary"),dl=Buffer.from(" \0","binary"),pl=parseInt("7777",8),wt=257,Si=263,gl=function(e,t,r){return typeof e!="number"?r:(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0)},yl=function(e){switch(e){case 0:return"file";case 1:return"link";case 2:return"symlink";case 3:return"character-device";case 4:return"block-device";case 5:return"directory";case 6:return"fifo";case 7:return"contiguous-file";case 72:return"pax-header";case 55:return"pax-global-header";case 27:return"gnu-long-link-path";case 28:case 30:return"gnu-long-path"}return null},vl=function(e){switch(e){case"file":return 0;case"link":return 1;case"symlink":return 2;case"character-device":return 3;case"block-device":return 4;case"directory":return 5;case"fifo":return 6;case"contiguous-file":return 7;case"pax-header":return 72}return 0},za=function(e,t,r,i){for(;r<i;r++)if(e[r]===t)return r;return i},Va=function(e){for(var t=256,r=0;r<148;r++)t+=e[r];for(var i=156;i<512;i++)t+=e[i];return t},Te=function(e,t){return e=e.toString(8),e.length>t?ll.slice(0,t)+" ":sl.slice(0,t-e.length)+e+" "};function _l(e){var t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;for(var r=[],i=e.length-1;i>0;i--){var a=e[i];t?r.push(a):r.push(255-a)}var o=0,l=r.length;for(i=0;i<l;i++)o+=r[i]*Math.pow(256,i);return t?o:-1*o}var Le=function(e,t,r){if(e=e.slice(t,t+r),t=0,e[t]&128)return _l(e);for(;t<e.length&&e[t]===32;)t++;for(var i=gl(za(e,32,t,e.length),e.length,e.length);t<i&&e[t]===0;)t++;return i===t?0:parseInt(e.slice(t,i).toString(),8)},Ve=function(e,t,r,i){return e.slice(t,za(e,0,t,t+r)).toString(i)},bi=function(e){var t=Buffer.byteLength(e),r=Math.floor(Math.log(t)/Math.log(10))+1;return t+r>=Math.pow(10,r)&&r++,t+r+e};Ke.decodeLongPath=function(e,t){return Ve(e,0,e.length,t)};Ke.encodePax=function(e){var t="";e.name&&(t+=bi(" path="+e.name+`
@@ -1,4 +1,4 @@
1
- import{a as i}from"./chunk-GCN4O7HM.js";import{b as r}from"./chunk-RY2SJVWM.js";import{t}from"./chunk-AGOEROAI.js";import{y as e}from"./chunk-GMTNOCMS.js";import{g as a}from"./chunk-VKWPEFWQ.js";a();var o=class extends r{static summary="Enable automatic upgrades for Shopify CLI.";static descriptionWithMarkdown=`Enable automatic upgrades for Shopify CLI.
1
+ import{a as i}from"./chunk-GCN4O7HM.js";import{b as r}from"./chunk-2XDUJQQN.js";import{y as e}from"./chunk-YFINLODF.js";import{t}from"./chunk-YZMY2CTU.js";import{g as a}from"./chunk-VKWPEFWQ.js";a();var o=class extends r{static summary="Enable automatic upgrades for Shopify CLI.";static descriptionWithMarkdown=`Enable automatic upgrades for Shopify CLI.
2
2
 
3
3
  When auto-upgrade is enabled, Shopify CLI automatically updates to the latest version once per day. Major version upgrades are skipped and must be done manually.
4
4
 
@@ -1 +1 @@
1
- import{a as C}from"./chunk-NEMPLS7C.js";import{a as y}from"./chunk-KUNDCAQN.js";import{oa as k,qa as w,ra as A,sa as P}from"./chunk-ACTDYTAV.js";import{b as h}from"./chunk-JJJTPEMD.js";import{z as g}from"./chunk-GMTNOCMS.js";import{h as u}from"./chunk-R2R6JDNH.js";import{j as r}from"./chunk-773TIA5M.js";import{g as n}from"./chunk-VKWPEFWQ.js";n();n();async function s(p){let{directory:t,configName:o,configPath:e,configuration:a,remoteApp:i}=p;if(!a.client_id)throw new u("The selected configuration is not linked to a remote app.","Run `shopify app config link` first to link this configuration to a Shopify app.");let c=i.developerPlatformClient,l=await k({developerPlatformClient:c,app:i}),m=i.flags,b={directory:t,configName:o,developerPlatformClient:c,apiKey:a.client_id},d=await w(b,l,m,i.apiKey),v=r(e),x=await A({remoteApp:i,developerPlatformClient:c,specifications:l,flags:m,configFileName:v,appDirectory:d.appDirectory??t,localAppOptions:d});return{configPath:e,configuration:x,remoteApp:i}}var f=class p extends C{static summary="Refresh an already-linked app configuration without prompts.";static descriptionWithMarkdown="Pulls the latest configuration from the already-linked Shopify app and updates the selected configuration file.\n\nThis command reuses the existing linked app and organization and skips all interactive prompts. Use `--config` to target a specific configuration file, or omit it to use the default one.";static description=this.descriptionWithoutMarkdown();static flags={...h,...y};async run(){let{flags:t}=await this.parse(p),{app:o,remoteApp:e}=await P({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),{configuration:a,configPath:i}=await s({directory:t.path,configName:t.config,configPath:o.configPath,configuration:o.configuration,remoteApp:e});return g({headline:`Pulled latest configuration for "${a.name}"`,body:`Updated ${r(i)} with the remote data.`}),{app:o}}};export{f as a};
1
+ import{a as C}from"./chunk-UZARYOLN.js";import{a as y}from"./chunk-YESGYUEL.js";import{sa as k,ua as w,va as A,wa as P}from"./chunk-ZZRFG6ME.js";import{b as h}from"./chunk-YEVGLC5X.js";import{z as g}from"./chunk-YFINLODF.js";import{h as u}from"./chunk-BWJIZYAG.js";import{j as r}from"./chunk-773TIA5M.js";import{g as n}from"./chunk-VKWPEFWQ.js";n();n();async function s(p){let{directory:t,configName:o,configPath:e,configuration:a,remoteApp:i}=p;if(!a.client_id)throw new u("The selected configuration is not linked to a remote app.","Run `shopify app config link` first to link this configuration to a Shopify app.");let c=i.developerPlatformClient,l=await k({developerPlatformClient:c,app:i}),m=i.flags,b={directory:t,configName:o,developerPlatformClient:c,apiKey:a.client_id},d=await w(b,l,m,i.apiKey),v=r(e),x=await A({remoteApp:i,developerPlatformClient:c,specifications:l,flags:m,configFileName:v,appDirectory:d.appDirectory??t,localAppOptions:d});return{configPath:e,configuration:x,remoteApp:i}}var f=class p extends C{static summary="Refresh an already-linked app configuration without prompts.";static descriptionWithMarkdown="Pulls the latest configuration from the already-linked Shopify app and updates the selected configuration file.\n\nThis command reuses the existing linked app and organization and skips all interactive prompts. Use `--config` to target a specific configuration file, or omit it to use the default one.";static description=this.descriptionWithoutMarkdown();static flags={...h,...y};async run(){let{flags:t}=await this.parse(p),{app:o,remoteApp:e}=await P({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),{configuration:a,configPath:i}=await s({directory:t.path,configName:t.config,configPath:o.configPath,configuration:o.configuration,remoteApp:e});return g({headline:`Pulled latest configuration for "${a.name}"`,body:`Updated ${r(i)} with the remote data.`}),{app:o}}};export{f as a};
@@ -1 +1 @@
1
- import{b as u,c as d}from"./chunk-DHU57LKD.js";import{a as c}from"./chunk-OUZGGWFN.js";import{a as e}from"./chunk-KUNDCAQN.js";import{e as n,ta as p}from"./chunk-ACTDYTAV.js";import{b as i}from"./chunk-JJJTPEMD.js";import{z as s}from"./chunk-GMTNOCMS.js";import{g as a}from"./chunk-VKWPEFWQ.js";a();var r=class f extends c{static summary="Generate GraphQL types for a function.";static descriptionWithMarkdown="Creates GraphQL types based on your [input query](https://shopify.dev/docs/apps/functions/input-output#input) for a function. Supports JavaScript functions out of the box, or any language via the `build.typegen_command` configuration.";static description=this.descriptionWithoutMarkdown();static flags={...i,...e,...u};async run(){let{flags:t}=await this.parse(f),{app:o}=await p({directory:t.path,userProvidedConfigName:t.config}),m=await d(o,t.path);return await n(m,{stdout:process.stdout,stderr:process.stderr,app:o}),s({headline:"GraphQL types generated successfully."}),{app:o}}};export{r as a};
1
+ import{b as u,c as d}from"./chunk-JX7FYWPO.js";import{a as c}from"./chunk-JG4HH54Q.js";import{a as e}from"./chunk-YESGYUEL.js";import{e as n,xa as p}from"./chunk-ZZRFG6ME.js";import{b as i}from"./chunk-YEVGLC5X.js";import{z as s}from"./chunk-YFINLODF.js";import{g as a}from"./chunk-VKWPEFWQ.js";a();var r=class f extends c{static summary="Generate GraphQL types for a function.";static descriptionWithMarkdown="Creates GraphQL types based on your [input query](https://shopify.dev/docs/apps/functions/input-output#input) for a function. Supports JavaScript functions out of the box, or any language via the `build.typegen_command` configuration.";static description=this.descriptionWithoutMarkdown();static flags={...i,...e,...u};async run(){let{flags:t}=await this.parse(f),{app:o}=await p({directory:t.path,userProvidedConfigName:t.config}),m=await d(o,t.path);return await n(m,{stdout:process.stdout,stderr:process.stderr,app:o}),s({headline:"GraphQL types generated successfully."}),{app:o}}};export{r as a};
@@ -1 +1 @@
1
- import{a as b}from"./chunk-GSCWZR22.js";import{b as F,c as P,d as w}from"./chunk-DHU57LKD.js";import{a as y}from"./chunk-OUZGGWFN.js";import{a as m}from"./chunk-KUNDCAQN.js";import{ta as x}from"./chunk-ACTDYTAV.js";import{b as d,c as h}from"./chunk-JJJTPEMD.js";import{F as g,M as l}from"./chunk-GMTNOCMS.js";import{a as _}from"./chunk-CTNBSUVU.js";import{Ab as n}from"./chunk-Y34LWI3S.js";import{e as U,g as u}from"./chunk-VKWPEFWQ.js";u();var i=U(_(),1);var a="_start",s=class v extends y{static summary="Run a function locally for testing.";static descriptionWithMarkdown="Runs the function from your current directory for [testing purposes](https://shopify.dev/docs/apps/functions/testing-and-debugging). To learn how you can monitor and debug functions when errors occur, refer to [Shopify Functions error handling](https://shopify.dev/docs/api/functions/errors).";static description=this.descriptionWithoutMarkdown();static flags={...d,...m,...F,...h,input:i.Flags.string({char:"i",description:"The input JSON to pass to the function. If omitted, standard input is used.",env:"SHOPIFY_FLAG_INPUT"}),export:i.Flags.string({char:"e",hidden:!1,description:"Name of the WebAssembly export to invoke.",env:"SHOPIFY_FLAG_EXPORT"}),profile:i.Flags.boolean({description:"Generate a WebAssembly performance profile for the function run. The profile can be viewed in Speedscope.",env:"SHOPIFY_FLAG_PROFILE"})};async run(){let{flags:t}=await this.parse(v),o=a,{app:p}=await x({directory:t.path,userProvidedConfigName:t.config}),e=await P(p,t.path);if(t.export!==void 0)n(`Using export ${t.export} from the --export flag.`),o=t.export;else if(e.configuration.targeting!==void 0&&e.configuration.targeting.length>0){let r=e.configuration.targeting;if(r.length>1&&l({})){let O=r.map(f=>({label:f.target,value:f.export||a}));o=await g({message:"Which target would you like to execute?",choices:O})}else o=r?.[0]?.export||a,n(`Using export '${o}'. Use the --export flag or an interactive terminal to select a different export.`)}else n(`No targeting information found. Using the default export '${o}'. Use the --export flag or an interactive terminal to select a different export.`);let c=e?.configuration.targeting?.[0]?.input_query,T=c&&`${e?.directory}/${c}`,A=await w(e,t.path,t["client-id"],t.reset,t.config);return await b({functionExtension:e,json:t.json,inputPath:t.input,export:o,stdin:"inherit",schemaPath:A,queryPath:T,profile:t.profile}),{app:p}}};export{s as a};
1
+ import{a as b}from"./chunk-36ROOKQB.js";import{b as F,c as P,d as w}from"./chunk-JX7FYWPO.js";import{a as y}from"./chunk-JG4HH54Q.js";import{a as m}from"./chunk-YESGYUEL.js";import{xa as x}from"./chunk-ZZRFG6ME.js";import{b as d,c as h}from"./chunk-YEVGLC5X.js";import{F as g,M as l}from"./chunk-YFINLODF.js";import{a as _}from"./chunk-CTNBSUVU.js";import{Ab as n}from"./chunk-VFM2KQRM.js";import{e as U,g as u}from"./chunk-VKWPEFWQ.js";u();var i=U(_(),1);var a="_start",s=class v extends y{static summary="Run a function locally for testing.";static descriptionWithMarkdown="Runs the function from your current directory for [testing purposes](https://shopify.dev/docs/apps/functions/testing-and-debugging). To learn how you can monitor and debug functions when errors occur, refer to [Shopify Functions error handling](https://shopify.dev/docs/api/functions/errors).";static description=this.descriptionWithoutMarkdown();static flags={...d,...m,...F,...h,input:i.Flags.string({char:"i",description:"The input JSON to pass to the function. If omitted, standard input is used.",env:"SHOPIFY_FLAG_INPUT"}),export:i.Flags.string({char:"e",hidden:!1,description:"Name of the WebAssembly export to invoke.",env:"SHOPIFY_FLAG_EXPORT"}),profile:i.Flags.boolean({description:"Generate a WebAssembly performance profile for the function run. The profile can be viewed in Speedscope.",env:"SHOPIFY_FLAG_PROFILE"})};async run(){let{flags:t}=await this.parse(v),o=a,{app:p}=await x({directory:t.path,userProvidedConfigName:t.config}),e=await P(p,t.path);if(t.export!==void 0)n(`Using export ${t.export} from the --export flag.`),o=t.export;else if(e.configuration.targeting!==void 0&&e.configuration.targeting.length>0){let r=e.configuration.targeting;if(r.length>1&&l({})){let O=r.map(f=>({label:f.target,value:f.export||a}));o=await g({message:"Which target would you like to execute?",choices:O})}else o=r?.[0]?.export||a,n(`Using export '${o}'. Use the --export flag or an interactive terminal to select a different export.`)}else n(`No targeting information found. Using the default export '${o}'. Use the --export flag or an interactive terminal to select a different export.`);let c=e?.configuration.targeting?.[0]?.input_query,T=c&&`${e?.directory}/${c}`,A=await w(e,t.path,t["client-id"],t.reset,t.config);return await b({functionExtension:e,json:t.json,inputPath:t.input,export:o,stdin:"inherit",schemaPath:A,queryPath:T,profile:t.profile}),{app:p}}};export{s as a};
@@ -1,10 +1,10 @@
1
- import{a as Mt}from"./chunk-UOHNRH6E.js";import{a as Cr}from"./chunk-7WTNEG2F.js";import{a as xr}from"./chunk-MRCWOOSF.js";import{a as Er}from"./chunk-PWSI275S.js";import{a as Rr}from"./chunk-X4XP2RQJ.js";import{a as br}from"./chunk-TYIGOVRQ.js";import{a as Sr}from"./chunk-7AALWJAO.js";import{b as Tr}from"./chunk-LQCR4TGH.js";import{a as Ar}from"./chunk-SSJGWLCW.js";import{a as _r}from"./chunk-QBIVQXUJ.js";import{a as pr}from"./chunk-JQ2B3VHR.js";import{a as dr}from"./chunk-2HK4MFWP.js";import{a as mr}from"./chunk-SJMTETSU.js";import{a as fr}from"./chunk-K4KTNINH.js";import{a as hr}from"./chunk-GZ64KWHX.js";import{a as gr}from"./chunk-XLURZ6GL.js";import{a as wr,b as yr,c as Pr,d as vr}from"./chunk-PAAKBWSF.js";import{a as Ur}from"./chunk-4LRG5YBS.js";import{g as ur}from"./chunk-MLZLDL6B.js";import{a as lo,b as po,c as uo,d as mo}from"./chunk-FULWTZS6.js";import{a as ar}from"./chunk-QEB3HUQE.js";import{a as lr}from"./chunk-5NO5OXYP.js";import{a as Xe}from"./chunk-E2W5OYYM.js";import{a as cr}from"./chunk-4W3UE2ZI.js";import{c as Je,m as Ze}from"./chunk-LZ3GZ7NS.js";import{b as ir,g as _e,j as Qe}from"./chunk-4JY2P2A5.js";import{a as nr,b as sr,c as ao,d as io,e as rt,f as co,g as fo}from"./chunk-FCGKO2KY.js";import{a as $,b as Ve}from"./chunk-JUKAWTYY.js";import{a as Xt,b as Zt,d as Te,f as er,m as Ae,n as H,s as q,u as tr,v as rr,w as or}from"./chunk-Q7BOSHWX.js";import{c as kr}from"./chunk-AH2ZGMDM.js";import{a as Jt}from"./chunk-JZMRBJH3.js";import{a as Zr,b as tt,c as ee,d as eo}from"./chunk-63CIFL36.js";import{a as ho,f as go,g as wo,h as ot,i as yo,j as Po,k as vo,l as xo,m as Eo,n as bo,o as So,p as Uo,q as Ro,v as To,x as Ao,z as nt}from"./chunk-U7R6LYPJ.js";import{a as to,b as ro,c as oo,d as no,e as so}from"./chunk-TY4W7AYX.js";import{a as Lr}from"./chunk-PANGX7SA.js";import{a as Xr}from"./chunk-H5KWM27L.js";import{a as Jr}from"./chunk-NEMPLS7C.js";import{a as Ir}from"./chunk-KUNDCAQN.js";import{B as Br,D as Kr,F as Z,M as jr,N as Yr,X as Vr,i as $r,j as W,k as Mr,m as Fr,ma as ke,na as Ie,p as et,q as Or,r as Nr,s as qr,sa as Qr,t as Wr,u as Hr,v as Gr}from"./chunk-ACTDYTAV.js";import{X as zr,e as Ce,j as ie,p as Dr}from"./chunk-F5HCSUXC.js";import{c as Vt}from"./chunk-KIYHEMHD.js";import{a as K}from"./chunk-U6HYEGAE.js";import{b as Qt,e as Re}from"./chunk-JJJTPEMD.js";import{C as ye,R as kt,a as Ke,ba as J,c as bt,da as It,e as St,g as Ut,k as Rt,o as Tt,q as At,t as _t,va as Lt,w as Ct,x as we}from"./chunk-YN6A26QL.js";import{A as se,H as be,L as Bt,N as Se,S as Ue,T as ae,U as Ye,V as Kt,X as jt,a as Et,d as Pe,e as k,f as L,h as ve,i as xe,j as Dt,k as Ft,l as Ot,m as Nt,n as qt,o as D,p as Wt,q as je,r as ze,s as Ht,t as Gt,y as Ee}from"./chunk-GMTNOCMS.js";import{a as Cn}from"./chunk-7UNQOKZW.js";import{d as $t}from"./chunk-JQISGC7D.js";import{h as T,k as X}from"./chunk-R2R6JDNH.js";import{a as _n}from"./chunk-CTNBSUVU.js";import{a as _o}from"./chunk-E5T4YRGW.js";import{$a as vt,Ab as g,Bb as C,Ea as Pt,Na as he,P as Be,Ta as F,Wa as ge,cb as xt,ma as I,qb as v,sb as b,ua as me,wa as fe,xb as B}from"./chunk-Y34LWI3S.js";import{d as zt,f as Yt}from"./chunk-XAOYKECS.js";import{a as ft}from"./chunk-JD5P5RAJ.js";import{d as S,f as Ge,g as ht,i as ue,j as gt,k as de,o as wt,p as yt}from"./chunk-773TIA5M.js";import{e as Q,g as p}from"./chunk-VKWPEFWQ.js";p();p();p();p();p();p();var kn=300*1e3,In='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Co(t,e,r=Date.now()){for(;await Ln(t,e,r););}async function Ln(t,e,r){let o=await _e(t,e);if(!o||$n(o,r))throw new T(In);return await ae(3),o.processing}function $n(t,e){return t.processing&&Date.now()-e>=kn}var Mn="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",Dn="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",st=3,Le=class extends cr{context="App Ext. Host";devPreview;constructor(e,r={devPreview:!1}){super(e),this.themeId=wr(e.storeFqdn),this.devPreview=r.devPreview}async findOrCreate(){let e=await this.fetch();return e??=this.devPreview?await this.createHostTheme():await this.create(),e}setTheme(e){yr(this.adminSession.storeFqdn,e)}removeTheme(){Pr(this.adminSession.storeFqdn)}async createHostTheme(){let e={role:ir,name:this.generateThemeName(this.context),src:Mn};for(let o=0;o<st;o++){g(`Attempt ${o}/${st}: Creating theme with name "${e.name}" and role "${e.role}"`);try{let n=await Qe(e,this.adminSession);if(n)return this.setTheme(n.id.toString()),g(`Waiting for theme with id "${n.id}" to be processed`),await Co(n.id,this.adminSession),n;throw new Error}catch{g(`Failed to create theme with name "${e.name}" and role "${e.role}". Retrying...`)}}g(`Theme creation failed after ${st} retries. Creating theme using fallback theme zip`);let r=await Qe({...e,src:Dn},this.adminSession);if(!r)throw g("Theme creation failed. Exiting process."),new X(`Could not create theme with name "${e.name}" and role "${e.role}"`);return r}};p();var Fn={"theme:init":hr,"theme:check":ar,"theme:console":lr,"theme:delete":pr,"theme:dev":dr,"theme:duplicate":mr,"theme:info":fr,"theme:language-server":gr,"theme:list":vr,"theme:metafields:pull":Ur,"theme:open":xr,"theme:package":Er,"theme:profile":br,"theme:publish":Sr,"theme:preview":Rr,"theme:pull":Tr,"theme:push":Ar,"theme:rename":_r,"theme:share":Cr},ka=Fn;async function ko(t){let{remoteApp:e,localApp:r}=t,n=r.allExtensions.filter(U=>U.isThemeExtension);if(n.length===0)return;let a=n[0].directory,i=t.themeExtensionPort??9293,[c,d]=await Promise.all([kt(t.storeFqdn),qn(e)]),l=c.storeFqdn,[u,h]=await Promise.all([Ze(c),Je(c)]),w=h?await Xe(t.storePassword,l,u):void 0,m=await Nn(c,t.theme),f=m.id.toString();return Ee({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:d}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${l}/admin/themes/${f}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${i}`,url:`http://127.0.0.1:${i}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:On,options:{theme:m,adminSession:c,storefrontPassword:w,crawlerSignatureHeaders:u,themeExtensionDirectory:a,themeExtensionPort:i}}}var On=async(t,{theme:e,adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})=>{await(await ur(e,{adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})).start()};async function Nn(t,e){let r;if(e)g(`Fetching theme with provided id ${e}`),r=await _e(parseInt(e,10),t);else{let o=new Le(t,{devPreview:!0});await be([{title:"Configuring host theme for theme app extension",task:async()=>{g("Finding or creating host theme for theme app extensions"),r=await o.findOrCreate()}}])}if(!r)throw new T("Could not find or create a host theme for theme app extensions");return r}async function qn(t){return t.developerPlatformClient?.clientName===zr.AppManagement?`https://${await we()}/?organization_id=${t.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${t.apiKey}`:`https://${await Ct()}/${t.organizationId}/apps/${t.id}/test`}p();p();p();p();p();p();async function Wn(t){let e=S(t.directory,"locales");return ge([S(e,"*.json")])}async function Io(t,e){let r=await Wn(t);if(!r.length)return{localization:void 0,status:""};let o=e.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},n="success";try{await Promise.all(r.map(async s=>{let[a,...i]=s.split("/").pop().split(".");if(a)return i[0]==="default"&&(o.defaultLocale=a),Hn(a,s,o,t,e)})),o.lastUpdated=Date.now(),g(`Parsed locales for extension ${t.handle} at ${t.directory}`,e.stdout)}catch{n="error"}return{localization:o,status:n}}async function Hn(t,e,r,o,n){let s;try{s=await I(e),r.translations[t]=JSON.parse(s)}catch(a){let i=`Error parsing ${t} locale for ${o.handle} at ${e}: ${a.message}`;throw C(i,n.stderr),new Error(i)}}p();function $e(t,e){switch(t){case"checkout_ui_extension":return{url:e.checkoutCartUrl};case"checkout_post_purchase":return{url:e.checkoutCartUrl};case"product_subscription":return{url:e.subscriptionProductUrl??""};default:return{url:""}}}var at=".js.map";async function te(t,e,r,o){return D({outputPrefix:t.outputPrefix},async()=>{o?.clear();let n=t.getOutputPathForDirectory(e),s=`${r.url}/extensions/${t.devUUID}`,{localization:a,status:i}=await Io(t,r),c=await Mr(t),d=t.outputRelativePath?ue(n):n,l=await Gn(t,s,d,o),u=null;return"metafields"in t.configuration&&Array.isArray(t.configuration.metafields)&&t.configuration.metafields.length>0&&(u=t.configuration.metafields),{assets:{main:ce(l)&&l[0]?.assets?.main?l[0].assets.main:{name:"main",url:`${s}/assets/${t.outputFileName}`,lastUpdated:await he(n)??0}},supportedFeatures:{runsOffline:t.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:t.configuration.capabilities?.block_progress??!1,networkAccess:t.configuration.capabilities?.network_access??!1,apiAccess:t.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:t.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:t.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:t.configuration.capabilities?.iframe?.sources??[]}},development:{...r.currentDevelopmentPayload,resource:$e(t.type,r),root:{url:s},hidden:r.currentDevelopmentPayload?.hidden??!1,localizationStatus:i,status:r.currentDevelopmentPayload?.status??"success",...r.currentDevelopmentPayload??{status:"success"}},extensionPoints:l,localization:a??null,metafields:u,type:t.type,externalType:t.externalType,uuid:t.devUUID,surface:t.surface,version:c?.version,title:t.name,handle:t.handle,name:t.name,description:t.configuration.description,apiVersion:t.configuration.api_version,approvalScopes:r.grantedScopes,settings:t.configuration.settings}})}async function Gn(t,e,r,o){let n=t.configuration,s=n.extension_points??n.targeting;if(t.type==="checkout_post_purchase"&&(s=[{target:"purchase.post.render"}]),ce(s)){let a=await Bn(r);return Promise.all(s.map(async i=>{let{target:c,resource:d}=i,l={...i,surface:Ie(c),root:{url:`${e}/${c}`},resource:d||{url:""}},u=a?.[c];if(!u)return l;let w=await Qn(u,{target:c,extensionPoint:i,url:e,extension:t,buildDirectory:r,resolver:o});return{...l,...w}}))}return s}async function Bn(t){try{let e=S(t,"manifest.json"),r=await I(e);return JSON.parse(r)}catch(e){if(e instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${t}: ${e.message}`);return null}}async function Kn({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s,a){let i=`${t}/${s}`,c=e[s];if(typeof c=="string"){let w=await Me(s,i,typeof a=="string"?a:c,r,o,n,typeof a=="string"?c:void 0);return{assets:{[w.name]:w}}}let l=e.build_manifest?.assets?.[s];if(l?.filepath){let u=await Me(s,i,l.filepath,r,o,n,l.module);return{assets:{[u.name]:u}}}return{}}async function jn({target:t,url:e,buildDirectory:r,resolver:o},n,s){if(s.length===0)return{};for(let i of s)o?.set(`${t}/${i}`,i);let a=await Promise.all(s.map(async i=>await he(S(r,i))??0));return{assets:{[n]:{name:n,url:`${e}/assets/${t}/`,lastUpdated:Math.max(...a)}}}}async function zn({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s){return e.intents?{intents:await Promise.all(e.intents.map(async(i,c)=>{let d=i.schema,l=s[c]?.schema,u=typeof l=="string"?l:d,h=typeof l=="string"?d:void 0;return{...i,schema:await Me("schema",`${t}/intents/${c}/schema`,u,r,o,n,h)}}))}:{}}async function Yn({target:t,url:e,extension:r,resolver:o},n,s){let a=await Me(n,`${t}/${n}`,s,e,r,o);return await Vn(t,s,r,o),{assets:{[a.name]:a}}}async function Vn(t,e,r,o){if(!o)return;let n=`${e}.map`;n.endsWith(at)&&await F(S(r.directory,n))&&o.set(`${t}/${gt(n)}`,n)}async function Qn(t,e){return(await Promise.all(Object.keys(t).map(async o=>{let n=t[o];return Jn(o,n)?zn(e,n):Xn(o,n)?Yn(e,o,n):Zn(o,n)?jn(e,o,n):Kn(e,o,n)}))).reduce((o,n)=>({...o,...n,assets:{...o.assets,...n.assets}}),{})}function ce(t){return Array.isArray(t)&&t.every(e=>typeof e=="object")}async function Me(t,e,r,o,n,s,a){let i=`${e}${de(r)}`;return s?.set(i,r),{name:t,url:`${o}/assets/${i}`,lastUpdated:await he(S(n.directory,a??r))??0}}function Jn(t,e){return t==="intents"&&Array.isArray(e)}function Xn(t,e){return(t==="main"||t==="should_render")&&typeof e=="string"}function Zn(t,e){return t==="assets"&&Array.isArray(e)&&e.every(r=>typeof r=="string")}import{EventEmitter as es}from"events";var le;(function(t){t.Update="PayloadUpdatedEvent:UPDATE"})(le||(le={}));async function Lo(t,e,r){return{app:{title:t.appName,apiKey:t.apiKey,url:ao(t.storeFqdn,t.apiKey),mobileUrl:co(t.storeFqdn,t.apiKey)},appId:t.id,version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:t.websocketURL},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extensions:await Promise.all(t.extensions.filter(n=>n.isPreviewable).map(n=>te(n,e,t,r&&it(r,n.devUUID))))}}function it(t,e){let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}var De=class extends es{options;rawPayload;assetResolvers;constructor(e,r,o=new Map){super(),this.rawPayload=e,this.options=r,this.assetResolvers=o}getAssetResolver(e){return this.assetResolvers.get(e)}getConnectedPayload(){let e=this.getRawPayload();return{app:e.app,appId:e.appId,store:e.store,extensions:e.extensions}}getRawPayloadFilteredByExtensionIds(e){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(r=>e.includes(r.uuid))}}getRawPayload(){return this.rawPayload}updateApp(e){this.rawPayload=J(this.rawPayload,{app:e}),this.emitUpdate([])}updateExtensions(e){let r=this.rawPayload.extensions.map(o=>{let n=e.find(s=>s.uuid===o.uuid);if(n){if(ce(n.extensionPoints)&&ce(o.extensionPoints)){let s=n.extensionPoints.reduce((c,d)=>({...c,[d.target]:d}),{});o.extensionPoints=J(o.extensionPoints,n.extensionPoints,c=>c.map(d=>{let l=s[d.target];return l?J(d,l,(u,h)=>h):d}));let{extensionPoints:a,...i}=n;return J(o,i)}return J(o,n)}return o});this.rawPayload={...this.rawPayload,extensions:r},this.emitUpdate(e.map(o=>o.uuid))}async updateExtension(e,r,o,n){let s=this.rawPayload.extensions,a=s.findIndex(i=>i.uuid===e.devUUID);if(a===-1){g(b`Could not updateExtension() for extension with uuid: ${e.devUUID}`,r.stderr);return}s[a]=await te(e,o,{...this.options,currentDevelopmentPayload:n??{status:s[a]?.development.status},currentLocalizationPayload:s[a]?.localization},it(this.assetResolvers,e.devUUID)),this.rawPayload.extensions=s,this.emitUpdate([e.devUUID])}deleteExtension(e){let r=this.rawPayload.extensions.findIndex(o=>o.uuid===e.devUUID);r!==-1&&(this.rawPayload.extensions.splice(r,1),this.assetResolvers.delete(e.devUUID),this.emitUpdate([e.devUUID]))}async addExtension(e,r){this.rawPayload.extensions.push(await te(e,r,this.options,it(this.assetResolvers,e.devUUID))),this.emitUpdate([e.devUUID])}emitUpdate(e){this.emit(le.Update,e)}};p();p();var j;(function(t){t.Update="update",t.Dispatch="dispatch",t.Log="log"})(j||(j={}));function $o(t,e){return(r,o,n)=>{r.url==="/extensions"&&(g("Upgrading HTTP request to a websocket connection",e.stdout),t.handleUpgrade(r,o,n,ts(t,e)))}}function ts(t,e){return r=>{g("Websocket connection successfully established",e.stdout);let o={event:"connected",data:e.payloadStore.getConnectedPayload(),version:e.manifestVersion};g(b`Sending connected payload: ${v.json(o)}`,e.stdout),r.send(JSON.stringify(o)),r.on("message",as(t,e))}}function rs(t){try{let e=JSON.parse(t);if(!Array.isArray(e))return t;let r=e.map(o=>typeof o=="object"&&o!==null?v.json(o).output():String(o)).join(" ");return b`${r}`.value}catch(e){if(e instanceof SyntaxError)return t;throw e}}var os={debug:t=>v.gray(t),warn:t=>v.yellow(t),error:t=>v.errorText(t)};function ns({type:t,message:e}){let r=rs(e);switch(t){case"debug":case"warn":case"error":return b`${os[t](t.toUpperCase())}: ${r}`.value;case"log":case"info":return r;default:return`${t.toUpperCase()}: ${r}`}}function ss(t,e){D({outputPrefix:t.extensionName,stripAnsi:!1},()=>{e.stdout.write(ns(t))})}function as(t,e){return r=>{let o=JSON.parse(r.toString()),{event:n,data:s}=o;if(g(b`Received websocket message with event type ${n} and data:
1
+ import{a as Mt}from"./chunk-UOHNRH6E.js";import{a as Er}from"./chunk-N6RBRPGW.js";import{a as Rr}from"./chunk-CX75OKZK.js";import{a as br}from"./chunk-MNOQAXJW.js";import{a as Sr}from"./chunk-YNDIZCD2.js";import{b as Tr}from"./chunk-XUYVJEZG.js";import{a as Ar}from"./chunk-FJ6F4XRV.js";import{a as _r}from"./chunk-HP64ZTEJ.js";import{a as Cr}from"./chunk-P57P7UAN.js";import{a as dr}from"./chunk-PG5YNPJB.js";import{a as mr}from"./chunk-ZL5LU4U2.js";import{a as fr}from"./chunk-YD2VQEN5.js";import{a as hr}from"./chunk-J4T73EAS.js";import{a as gr}from"./chunk-JWRK5KLD.js";import{a as wr,b as yr,c as Pr,d as vr}from"./chunk-LUKQ5HLC.js";import{a as Ur}from"./chunk-R7T3LYJL.js";import{g as ur}from"./chunk-7T6M7FAC.js";import{a as xr}from"./chunk-5N6HNQQ5.js";import{a as lo,b as po,c as uo,d as mo}from"./chunk-S5FOQY35.js";import{a as ar}from"./chunk-6MWWJZFN.js";import{a as lr}from"./chunk-OEG3N5PG.js";import{a as Xe}from"./chunk-NQK2VCDA.js";import{c as Je,m as Ze}from"./chunk-YKL3BLWC.js";import{a as pr}from"./chunk-E6N4PZZR.js";import{a as cr}from"./chunk-NBFMP5XQ.js";import{b as ir,g as _e,j as Qe}from"./chunk-5SEEDOQ5.js";import{c as kr}from"./chunk-WYBTC356.js";import{a as nr,b as sr,c as ao,d as io,e as rt,f as co,g as fo}from"./chunk-G5XIGN5D.js";import{a as $,b as Ve}from"./chunk-OZMQ2EJB.js";import{a as Xt,b as Zt,d as Te,f as er,m as Ae,n as H,s as q,u as tr,v as rr,w as or}from"./chunk-Q7BOSHWX.js";import{a as Jt}from"./chunk-O7DZXO3O.js";import{a as Zr,b as tt,c as ee,d as eo}from"./chunk-T7PJDT5O.js";import{a as ho,f as go,g as wo,h as ot,i as yo,j as Po,k as vo,l as xo,m as Eo,n as bo,o as So,p as Uo,q as Ro,v as To,x as Ao,z as nt}from"./chunk-IARCMH7G.js";import{a as to,b as ro,c as oo,d as no,e as so}from"./chunk-AWUX36VG.js";import{a as Lr}from"./chunk-TFBRVLDN.js";import{a as Xr}from"./chunk-EX5GVHGE.js";import{a as Jr}from"./chunk-UZARYOLN.js";import{a as Ir}from"./chunk-YESGYUEL.js";import{$ as Vr,B as Br,D as Kr,F as Z,P as jr,Q as Yr,i as $r,j as W,k as Mr,m as Fr,p as et,q as Or,qa as ke,r as Nr,ra as Ie,s as qr,t as Wr,u as Hr,v as Gr,wa as Qr}from"./chunk-ZZRFG6ME.js";import{y as zr}from"./chunk-N75VOJHO.js";import{c as Vt}from"./chunk-CEYIZC3M.js";import{a as Ce,f as ie,m as Dr}from"./chunk-XOCB4KNX.js";import{a as K}from"./chunk-NROVZETL.js";import{b as Qt,e as Re}from"./chunk-YEVGLC5X.js";import{D as ye,S as kt,b as Ke,ca as J,d as bt,ea as It,f as St,h as Ut,l as Rt,p as Tt,r as At,u as _t,wa as Lt,x as Ct,y as we}from"./chunk-3JXPOOFV.js";import{A as se,H as be,L as Bt,N as Se,S as Ue,T as ae,U as Ye,V as Kt,X as jt,a as Et,d as Pe,e as k,f as L,h as ve,i as xe,j as Dt,k as Ft,l as Ot,m as Nt,n as qt,o as D,p as Wt,q as je,r as ze,s as Ht,t as Gt,y as Ee}from"./chunk-YFINLODF.js";import{a as Cn}from"./chunk-7UNQOKZW.js";import{d as $t}from"./chunk-NHAUJWEG.js";import{h as T,k as X}from"./chunk-BWJIZYAG.js";import{a as _n}from"./chunk-CTNBSUVU.js";import{a as _o}from"./chunk-FOREMLFZ.js";import{$a as vt,Ab as g,Bb as C,Ea as Pt,Na as he,P as Be,Ta as F,Wa as ge,cb as xt,ma as I,qb as v,sb as b,ua as me,wa as fe,xb as B}from"./chunk-VFM2KQRM.js";import{d as zt,f as Yt}from"./chunk-R6ICQT2D.js";import{a as ft}from"./chunk-JD5P5RAJ.js";import{d as S,f as Ge,g as ht,i as ue,j as gt,k as de,o as wt,p as yt}from"./chunk-773TIA5M.js";import{e as Q,g as p}from"./chunk-VKWPEFWQ.js";p();p();p();p();p();p();var kn=300*1e3,In='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Co(t,e,r=Date.now()){for(;await Ln(t,e,r););}async function Ln(t,e,r){let o=await _e(t,e);if(!o||$n(o,r))throw new T(In);return await ae(3),o.processing}function $n(t,e){return t.processing&&Date.now()-e>=kn}var Mn="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",Dn="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",st=3,Le=class extends cr{context="App Ext. Host";devPreview;constructor(e,r={devPreview:!1}){super(e),this.themeId=wr(e.storeFqdn),this.devPreview=r.devPreview}async findOrCreate(){let e=await this.fetch();return e??=this.devPreview?await this.createHostTheme():await this.create(),e}setTheme(e){yr(this.adminSession.storeFqdn,e)}removeTheme(){Pr(this.adminSession.storeFqdn)}async createHostTheme(){let e={role:ir,name:this.generateThemeName(this.context),src:Mn};for(let o=0;o<st;o++){g(`Attempt ${o}/${st}: Creating theme with name "${e.name}" and role "${e.role}"`);try{let n=await Qe(e,this.adminSession);if(n)return this.setTheme(n.id.toString()),g(`Waiting for theme with id "${n.id}" to be processed`),await Co(n.id,this.adminSession),n;throw new Error}catch{g(`Failed to create theme with name "${e.name}" and role "${e.role}". Retrying...`)}}g(`Theme creation failed after ${st} retries. Creating theme using fallback theme zip`);let r=await Qe({...e,src:Dn},this.adminSession);if(!r)throw g("Theme creation failed. Exiting process."),new X(`Could not create theme with name "${e.name}" and role "${e.role}"`);return r}};p();var Fn={"theme:init":hr,"theme:check":ar,"theme:console":lr,"theme:delete":pr,"theme:dev":dr,"theme:duplicate":mr,"theme:info":fr,"theme:language-server":gr,"theme:list":vr,"theme:metafields:pull":Ur,"theme:open":xr,"theme:package":Er,"theme:profile":br,"theme:publish":Sr,"theme:preview":Rr,"theme:pull":Tr,"theme:push":Ar,"theme:rename":_r,"theme:share":Cr},ka=Fn;async function ko(t){let{remoteApp:e,localApp:r}=t,n=r.allExtensions.filter(U=>U.isThemeExtension);if(n.length===0)return;let a=n[0].directory,i=t.themeExtensionPort??9293,[c,d]=await Promise.all([kt(t.storeFqdn),qn(e)]),l=c.storeFqdn,[u,h]=await Promise.all([Ze(c),Je(c)]),w=h?await Xe(t.storePassword,l,u):void 0,m=await Nn(c,t.theme),f=m.id.toString();return Ee({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:d}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${l}/admin/themes/${f}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${i}`,url:`http://127.0.0.1:${i}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:On,options:{theme:m,adminSession:c,storefrontPassword:w,crawlerSignatureHeaders:u,themeExtensionDirectory:a,themeExtensionPort:i}}}var On=async(t,{theme:e,adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})=>{await(await ur(e,{adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})).start()};async function Nn(t,e){let r;if(e)g(`Fetching theme with provided id ${e}`),r=await _e(parseInt(e,10),t);else{let o=new Le(t,{devPreview:!0});await be([{title:"Configuring host theme for theme app extension",task:async()=>{g("Finding or creating host theme for theme app extensions"),r=await o.findOrCreate()}}])}if(!r)throw new T("Could not find or create a host theme for theme app extensions");return r}async function qn(t){return t.developerPlatformClient?.clientName===zr.AppManagement?`https://${await we()}/?organization_id=${t.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${t.apiKey}`:`https://${await Ct()}/${t.organizationId}/apps/${t.id}/test`}p();p();p();p();p();p();async function Wn(t){let e=S(t.directory,"locales");return ge([S(e,"*.json")])}async function Io(t,e){let r=await Wn(t);if(!r.length)return{localization:void 0,status:""};let o=e.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},n="success";try{await Promise.all(r.map(async s=>{let[a,...i]=s.split("/").pop().split(".");if(a)return i[0]==="default"&&(o.defaultLocale=a),Hn(a,s,o,t,e)})),o.lastUpdated=Date.now(),g(`Parsed locales for extension ${t.handle} at ${t.directory}`,e.stdout)}catch{n="error"}return{localization:o,status:n}}async function Hn(t,e,r,o,n){let s;try{s=await I(e),r.translations[t]=JSON.parse(s)}catch(a){let i=`Error parsing ${t} locale for ${o.handle} at ${e}: ${a.message}`;throw C(i,n.stderr),new Error(i)}}p();function $e(t,e){switch(t){case"checkout_ui_extension":return{url:e.checkoutCartUrl};case"checkout_post_purchase":return{url:e.checkoutCartUrl};case"product_subscription":return{url:e.subscriptionProductUrl??""};default:return{url:""}}}var at=".js.map";async function te(t,e,r,o){return D({outputPrefix:t.outputPrefix},async()=>{o?.clear();let n=t.getOutputPathForDirectory(e),s=`${r.url}/extensions/${t.devUUID}`,{localization:a,status:i}=await Io(t,r),c=await Mr(t),d=t.outputRelativePath?ue(n):n,l=await Gn(t,s,d,o),u=null;return"metafields"in t.configuration&&Array.isArray(t.configuration.metafields)&&t.configuration.metafields.length>0&&(u=t.configuration.metafields),{assets:{main:ce(l)&&l[0]?.assets?.main?l[0].assets.main:{name:"main",url:`${s}/assets/${t.outputFileName}`,lastUpdated:await he(n)??0}},supportedFeatures:{runsOffline:t.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:t.configuration.capabilities?.block_progress??!1,networkAccess:t.configuration.capabilities?.network_access??!1,apiAccess:t.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:t.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:t.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:t.configuration.capabilities?.iframe?.sources??[]}},development:{...r.currentDevelopmentPayload,resource:$e(t.type,r),root:{url:s},hidden:r.currentDevelopmentPayload?.hidden??!1,localizationStatus:i,status:r.currentDevelopmentPayload?.status??"success",...r.currentDevelopmentPayload??{status:"success"}},extensionPoints:l,localization:a??null,metafields:u,type:t.type,externalType:t.externalType,uuid:t.devUUID,surface:t.surface,version:c?.version,title:t.name,handle:t.handle,name:t.name,description:t.configuration.description,apiVersion:t.configuration.api_version,approvalScopes:r.grantedScopes,settings:t.configuration.settings}})}async function Gn(t,e,r,o){let n=t.configuration,s=n.extension_points??n.targeting;if(t.type==="checkout_post_purchase"&&(s=[{target:"purchase.post.render"}]),ce(s)){let a=await Bn(r);return Promise.all(s.map(async i=>{let{target:c,resource:d}=i,l={...i,surface:Ie(c),root:{url:`${e}/${c}`},resource:d||{url:""}},u=a?.[c];if(!u)return l;let w=await Qn(u,{target:c,extensionPoint:i,url:e,extension:t,buildDirectory:r,resolver:o});return{...l,...w}}))}return s}async function Bn(t){try{let e=S(t,"manifest.json"),r=await I(e);return JSON.parse(r)}catch(e){if(e instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${t}: ${e.message}`);return null}}async function Kn({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s,a){let i=`${t}/${s}`,c=e[s];if(typeof c=="string"){let w=await Me(s,i,typeof a=="string"?a:c,r,o,n,typeof a=="string"?c:void 0);return{assets:{[w.name]:w}}}let l=e.build_manifest?.assets?.[s];if(l?.filepath){let u=await Me(s,i,l.filepath,r,o,n,l.module);return{assets:{[u.name]:u}}}return{}}async function jn({target:t,url:e,buildDirectory:r,resolver:o},n,s){if(s.length===0)return{};for(let i of s)o?.set(`${t}/${i}`,i);let a=await Promise.all(s.map(async i=>await he(S(r,i))??0));return{assets:{[n]:{name:n,url:`${e}/assets/${t}/`,lastUpdated:Math.max(...a)}}}}async function zn({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s){return e.intents?{intents:await Promise.all(e.intents.map(async(i,c)=>{let d=i.schema,l=s[c]?.schema,u=typeof l=="string"?l:d,h=typeof l=="string"?d:void 0;return{...i,schema:await Me("schema",`${t}/intents/${c}/schema`,u,r,o,n,h)}}))}:{}}async function Yn({target:t,url:e,extension:r,resolver:o},n,s){let a=await Me(n,`${t}/${n}`,s,e,r,o);return await Vn(t,s,r,o),{assets:{[a.name]:a}}}async function Vn(t,e,r,o){if(!o)return;let n=`${e}.map`;n.endsWith(at)&&await F(S(r.directory,n))&&o.set(`${t}/${gt(n)}`,n)}async function Qn(t,e){return(await Promise.all(Object.keys(t).map(async o=>{let n=t[o];return Jn(o,n)?zn(e,n):Xn(o,n)?Yn(e,o,n):Zn(o,n)?jn(e,o,n):Kn(e,o,n)}))).reduce((o,n)=>({...o,...n,assets:{...o.assets,...n.assets}}),{})}function ce(t){return Array.isArray(t)&&t.every(e=>typeof e=="object")}async function Me(t,e,r,o,n,s,a){let i=`${e}${de(r)}`;return s?.set(i,r),{name:t,url:`${o}/assets/${i}`,lastUpdated:await he(S(n.directory,a??r))??0}}function Jn(t,e){return t==="intents"&&Array.isArray(e)}function Xn(t,e){return(t==="main"||t==="should_render")&&typeof e=="string"}function Zn(t,e){return t==="assets"&&Array.isArray(e)&&e.every(r=>typeof r=="string")}import{EventEmitter as es}from"events";var le;(function(t){t.Update="PayloadUpdatedEvent:UPDATE"})(le||(le={}));async function Lo(t,e,r){return{app:{title:t.appName,apiKey:t.apiKey,url:ao(t.storeFqdn,t.apiKey),mobileUrl:co(t.storeFqdn,t.apiKey)},appId:t.id,version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:t.websocketURL},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extensions:await Promise.all(t.extensions.filter(n=>n.isPreviewable).map(n=>te(n,e,t,r&&it(r,n.devUUID))))}}function it(t,e){let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}var De=class extends es{options;rawPayload;assetResolvers;constructor(e,r,o=new Map){super(),this.rawPayload=e,this.options=r,this.assetResolvers=o}getAssetResolver(e){return this.assetResolvers.get(e)}getConnectedPayload(){let e=this.getRawPayload();return{app:e.app,appId:e.appId,store:e.store,extensions:e.extensions}}getRawPayloadFilteredByExtensionIds(e){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(r=>e.includes(r.uuid))}}getRawPayload(){return this.rawPayload}updateApp(e){this.rawPayload=J(this.rawPayload,{app:e}),this.emitUpdate([])}updateExtensions(e){let r=this.rawPayload.extensions.map(o=>{let n=e.find(s=>s.uuid===o.uuid);if(n){if(ce(n.extensionPoints)&&ce(o.extensionPoints)){let s=n.extensionPoints.reduce((c,d)=>({...c,[d.target]:d}),{});o.extensionPoints=J(o.extensionPoints,n.extensionPoints,c=>c.map(d=>{let l=s[d.target];return l?J(d,l,(u,h)=>h):d}));let{extensionPoints:a,...i}=n;return J(o,i)}return J(o,n)}return o});this.rawPayload={...this.rawPayload,extensions:r},this.emitUpdate(e.map(o=>o.uuid))}async updateExtension(e,r,o,n){let s=this.rawPayload.extensions,a=s.findIndex(i=>i.uuid===e.devUUID);if(a===-1){g(b`Could not updateExtension() for extension with uuid: ${e.devUUID}`,r.stderr);return}s[a]=await te(e,o,{...this.options,currentDevelopmentPayload:n??{status:s[a]?.development.status},currentLocalizationPayload:s[a]?.localization},it(this.assetResolvers,e.devUUID)),this.rawPayload.extensions=s,this.emitUpdate([e.devUUID])}deleteExtension(e){let r=this.rawPayload.extensions.findIndex(o=>o.uuid===e.devUUID);r!==-1&&(this.rawPayload.extensions.splice(r,1),this.assetResolvers.delete(e.devUUID),this.emitUpdate([e.devUUID]))}async addExtension(e,r){this.rawPayload.extensions.push(await te(e,r,this.options,it(this.assetResolvers,e.devUUID))),this.emitUpdate([e.devUUID])}emitUpdate(e){this.emit(le.Update,e)}};p();p();var j;(function(t){t.Update="update",t.Dispatch="dispatch",t.Log="log"})(j||(j={}));function $o(t,e){return(r,o,n)=>{r.url==="/extensions"&&(g("Upgrading HTTP request to a websocket connection",e.stdout),t.handleUpgrade(r,o,n,ts(t,e)))}}function ts(t,e){return r=>{g("Websocket connection successfully established",e.stdout);let o={event:"connected",data:e.payloadStore.getConnectedPayload(),version:e.manifestVersion};g(b`Sending connected payload: ${v.json(o)}`,e.stdout),r.send(JSON.stringify(o)),r.on("message",as(t,e))}}function rs(t){try{let e=JSON.parse(t);if(!Array.isArray(e))return t;let r=e.map(o=>typeof o=="object"&&o!==null?v.json(o).output():String(o)).join(" ");return b`${r}`.value}catch(e){if(e instanceof SyntaxError)return t;throw e}}var os={debug:t=>v.gray(t),warn:t=>v.yellow(t),error:t=>v.errorText(t)};function ns({type:t,message:e}){let r=rs(e);switch(t){case"debug":case"warn":case"error":return b`${os[t](t.toUpperCase())}: ${r}`.value;case"log":case"info":return r;default:return`${t.toUpperCase()}: ${r}`}}function ss(t,e){D({outputPrefix:t.extensionName,stripAnsi:!1},()=>{e.stdout.write(ns(t))})}function as(t,e){return r=>{let o=JSON.parse(r.toString()),{event:n,data:s}=o;if(g(b`Received websocket message with event type ${n} and data:
2
2
  ${v.json(s)}
3
3
  `,e.stdout),n===j.Update){let a=e.payloadStore.getRawPayload().app.apiKey,i=s.app?.apiKey;if(s.app){if(a!==i)return;e.payloadStore.updateApp(s.app)}s.extensions&&e.payloadStore.updateExtensions(s.extensions)}else if(n===j.Dispatch){let a=is(o,e);Do(t,a,e)}else n===j.Log&&ss(s,e)}}function Mo(t,e){return r=>{let o={event:j.Update,version:e.manifestVersion,data:{...e.payloadStore.getRawPayloadFilteredByExtensionIds(r)}};g(b`Sending websocket update event to the websocket clients:
4
4
  ${v.json(o)}
5
5
  `,e.stdout),Do(t,o,e)}}function Do(t,e,r){g(b`Sending websocket with event type ${e.event} and data:
6
6
  ${v.json(e.data)}
7
- `,r.stdout);let o=JSON.stringify(e);t.clients.forEach(n=>n.send(o))}function is(t,e){let r=e.payloadStore.getRawPayload();return{...t,version:e.manifestVersion,data:{...t.data,extensions:[],store:r.store,app:r.app}}}var cs=10;function Fo(t){let e=new Mt.default({noServer:!0,clientTracking:!0}),r=ls(e);return t.httpServer.on("upgrade",$o(e,t)),t.payloadStore.on(le.Update,Mo(e,t)),{close:()=>{e.close(),clearInterval(r)}}}function ls(t){return setInterval(()=>{t.clients.forEach(e=>{e.readyState<2&&e.ping()})},cs*1e3)}p();p();p();function Oo(t,e){let{url:r}=$e(t.type,e);if(t.surface==="checkout"&&r){let o=new URL(`https://${e.storeFqdn}/`);return o.pathname=r,o.searchParams.append("dev",`${e.url}/extensions`),o.toString()}else{let o=new URL(`https://${e.storeFqdn}/`);return o.pathname="admin/extensions-dev",o.searchParams.append("url",Fe(t,e)),o.toString()}}function No(t,e,r){let o=Ie(t),n=new URL(`https://${r.storeFqdn}/`);switch(o){case"checkout":n.pathname=r.checkoutCartUrl,n.searchParams.append("dev",`${r.url}/extensions`);break;case"post_purchase":if(n.pathname=r.checkoutCartUrl,n.searchParams.set("script_url",`${r.url}/extensions/${e.devUUID}/assets/${e.localIdentifier}.js`),n.searchParams.set("post_purchase_dev_api_key",r.apiKey),e.devUUID&&r.websocketURL&&(n.searchParams.set("uuid",e.devUUID),n.searchParams.set("socket_url",r.websocketURL)),"metafields"in e.configuration){let s={config:{metafields:e.configuration.metafields}};n.searchParams.set("config",JSON.stringify(s))}break;case"admin":n.pathname="admin/extensions-dev",n.searchParams.append("url",Fe(e,r)),n.searchParams.append("target",t);break;case"customer-accounts":n=ps(e,r,t);break;default:return}return n.toString()}function ps(t,e,r=""){let o=`${e.url}/extensions`,n=e.storeId,s="shopify.com",a=new URL(`https://${s}/${n}/account/extensions-development`);return a.searchParams.append("origin",o),a.searchParams.append("extensionId",t.devUUID),a.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),a.searchParams.append("appId",e.id??""),r!==""&&a.searchParams.append("target",r),a}function Fe(t,e){let r=new URL(e.url);return r.pathname=`/extensions/${t.devUUID}`,r.toString()}function O(t,e){Zt(t,Xt(e))}p();var ct=class extends X{constructor(e){super(`Couldn't find template ${e.template} for extension surface ${e.extensionSurface}`)}};async function qo(t){let e=await us(t),r=await I(e);return Jt(r,t.data)}async function us(t){let e=await ds(),r=[];t.extensionSurface&&r.push(S(e,`${t.extensionSurface}/${t.template}.html.liquid`)),r.push(S(e,`${t.template}.html.liquid`));let o=await ge(r);if(o.length===0)throw new ct(t);return o[0]}async function ds(){return await vt("templates/ui-extensions/html",{type:"directory",cwd:yt(import.meta.url)})}var Wo=q(t=>{H(t,"Access-Control-Allow-Origin","*"),H(t,"Access-Control-Allow-Methods","GET, OPTIONS"),H(t,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),Ho=q(t=>{H(t,"Cache-Control","no-cache")}),lt=q(async t=>Ae(t,"/extensions",307));async function ms(t,e){let{filePath:r}=e;if(!await F(r))return O(t,{statusCode:404,statusMessage:`Not Found: ${r}`});if(await Pt(r)&&(r+=r.endsWith("/")?"index.html":"/index.html",!await F(r)))return O(t,{statusCode:404,statusMessage:`Not Found: ${r}`});let o=await I(r,{}),n={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".map":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},s=de(r),a=n[s]||"text/plain";return H(t,"Content-Type",a),o}function Go({getExtensions:t,payloadStore:e}){return q(async r=>{let{extensionId:o,assetPath:n=""}=Te(r),s=t().find(h=>h.devUUID===o);if(!s)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});let i=e.getAssetResolver(s.devUUID)?.get(n),c=i??n,d=c.endsWith(at);if(d&&i===void 0)return O(r,{statusCode:404,statusMessage:"Not Found"});let l=Ge(d?s.directory:Fr(s.outputPath)),u=Ge(S(l,c));return wt(l,u)?ms(r,{filePath:u}):O(r,{statusCode:404,statusMessage:"Not Found"})})}function pt({payloadStore:t}){return q(e=>(H(e,"content-type","application/json"),t.getRawPayload()))}function Bo({devOptions:t}){return q(e=>{g(`UI extensions server received a ${e.method} request to URL ${e.path}`,t.stdout)})}function ut({devOptions:t,getExtensions:e}){return q(async r=>{let{extensionId:o}=Te(r),n=e().find(i=>i.devUUID===o);if(!n)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(er(r,"accept")?.startsWith("text/html")){if(n.type==="checkout_post_purchase")return qo({data:{url:Fe(n,t)},template:"index",extensionSurface:"post_purchase"});{let i=Oo(n,t);return Ae(r,i,307)}}let a=t.appWatcher.buildOutputPath;return H(r,"content-type","application/json"),{app:{apiKey:t.apiKey},version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:re(t.url)},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extension:await te(n,a,t)}})}function Ko({devOptions:t,getExtensions:e}){return q(async r=>{let{extensionId:o,extensionPointTarget:n=""}=Te(r),s=e().find(i=>i.devUUID===o);if(!s)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(s.configuration.type!=="checkout_post_purchase"&&!s.hasExtensionPointTarget(n))return O(r,{statusCode:404,statusMessage:`Extension with id ${o} has not configured the "${n}" extension target`});let a=No(n,s,t);return a?Ae(r,a,307):O(r,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${o} and extension target "${n}"`})})}import{createServer as fs}from"http";function jo(t){let e=tr(),r=rr();e.use(Bo(t)),e.use(Wo),e.use(Ho),r.use("/extensions/dev-console",lt),r.use("/extensions/:extensionId",ut(t)),r.use("/extensions/:extensionId/",ut(t)),r.use("/extensions/:extensionId/:extensionPointTarget",Ko(t)),r.use("/extensions/:extensionId/assets/**:assetPath",Go(t)),r.use("/extensions",pt(t)),r.use("/extensions/",pt(t)),r.use("/",lt),e.use(r);let o=fs(or(e));return o.listen(t.devOptions.port,"localhost"),o}async function zo(t){let e={...t,websocketURL:re(t.url)},r=e.appWatcher.buildOutputPath,o=new Map,n=await Lo(e,r,o),s=new De(n,e,o),a=e.extensions.filter(u=>u.isPreviewable),i=()=>a;g("Setting up the UI extensions HTTP server...",e.stdout);let c=jo({devOptions:e,payloadStore:s,getExtensions:i});g("Setting up the UI extensions Websocket server...",e.stdout);let d=Fo({...e,httpServer:c,payloadStore:s});g("Setting up the UI extensions bundler and file watching...",e.stdout);let l=async({appWasReloaded:u,app:h,extensionEvents:w})=>{u&&(a=h.allExtensions.filter(m=>m.isPreviewable));for(let m of w){if(!m.extension.isPreviewable)continue;let f=m.buildResult?.status==="ok"?"success":"error",U=m.buildResult?.status==="error"?{message:m.buildResult.error,file:m.buildResult.file}:void 0;switch(m.type){case ee.Created:if(e.extensions.push(m.extension),!e.checkoutCartUrl){let E=await ke(e.extensions,e.storeFqdn);e.checkoutCartUrl=E}await s.addExtension(m.extension,r);break;case ee.Updated:await s.updateExtension(m.extension,e,r,{status:f,error:U});break;case ee.Deleted:e.extensions=e.extensions.filter(E=>E.devUUID!==m.extension.devUUID),await s.deleteExtension(m.extension);break}}};e.appWatcher.onEvent(l).onStart(l),e.signal.addEventListener("abort",()=>{g("Closing the UI extensions dev server..."),d.close(),c.close()})}function re(t){let e=new URL("/extensions",t);return e.protocol="wss:",e.toString()}var hs="3",gs=async({stderr:t,stdout:e,abortSignal:r},{apiKey:o,storeFqdn:n,storeId:s,subscriptionProductUrl:a,port:i,cartUrl:c,proxyUrl:d,appName:l,appDotEnvFile:u,appId:h,grantedScopes:w,allExtensions:m,appDirectory:f,appWatcher:U})=>{await zo({appName:l,appDotEnvFile:u,appDirectory:f,id:h,extensions:m,stdout:e,stderr:t,signal:r,url:d,port:i,storeFqdn:ye(n),storeId:s,apiKey:o,grantedScopes:w,checkoutCartUrl:c,subscriptionProductUrl:a,manifestVersion:hs,appWatcher:U})};async function Yo({allExtensions:t,storeFqdn:e,checkoutCartUrl:r,...o}){let n=t.filter(a=>a.isPreviewable),s=await ke(n,e,r);return{prefix:"extensions",type:"previewable-extension",function:gs,options:{pathPrefix:"/extensions",port:-1,storeFqdn:e,allExtensions:t,cartUrl:s,...o}}}p();p();function z(t){let e=t.find(o=>Z(o,W.Frontend)),r=t.find(o=>Z(o,W.Backend));return{frontendConfig:e,backendConfig:r}}p();async function Vo(t){let r={topic:"app/uninstalled",api_version:(await lo(t.developerPlatformClient,t.organizationId))[1],address:t.address,delivery_method:mo.LOCALHOST,shared_secret:t.sharedSecret},o=await po(t.developerPlatformClient,r,t.organizationId);t.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await ae(3);let n=await ws(t,o);return t.stdout.write(n?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),n}async function ws(t,e){let r=0;for(;r<3;){try{return await uo(t.address,e.samplePayload,JSON.stringify({...JSON.parse(e.headers),"X-Shopify-Shop-Domain":t.storeFqdn}))}catch(o){if(o instanceof Tt&&o.code==="ECONNREFUSED")r<3&&(t.stdout.write("App isn't responding yet, retrying in 5 seconds"),await ae(5));else throw o}r++}return t.stdout.write("App hasn't started in time, giving up"),!1}var ys=async({stdout:t},e)=>{await Vo({stdout:t,developerPlatformClient:e.developerPlatformClient,address:`http://localhost:${e.deliveryPort}${e.webhooksPath}`,sharedSecret:e.apiSecret,storeFqdn:e.storeFqdn,organizationId:e.organizationId})};function Qo({webs:t,remoteAppUpdated:e,backendPort:r,frontendPort:o,organizationId:n,...s}){let{backendConfig:a,frontendConfig:i}=z(t),c=t.map(({configuration:l})=>l.webhooks_path).find(l=>l)??"/api/webhooks";if(c&&e&&(i??a))return{type:"send-webhook",prefix:"webhooks",function:ys,options:{deliveryPort:a?r:o,webhooksPath:c,organizationId:n,...s}}}p();async function Jo(t){return{type:"graphiql",prefix:"graphiql",options:t,function:Ps}}var Ps=async({stdout:t,abortSignal:e},r)=>{let o=fo({apiKey:r.apiKey,apiSecret:r.apiSecret,storeFqdn:r.storeFqdn}),n=sr({stdout:t,port:r.port,storeFqdn:r.storeFqdn,key:r.key,tokenProvider:o,appContext:{appName:r.appName,appUrl:r.appUrl,apiSecret:r.apiSecret}});e.addEventListener("abort",()=>{n.close()})};p();async function Zo({webs:t,proxyUrl:e,frontendPort:r,backendPort:o,apiKey:n,apiSecret:s,scopes:a}){let{frontendConfig:i}=z(t),c=i?.configuration.hmr_server?await $():void 0,d=void 0,l=t.map(async u=>{let h=await vs({web:u,frontendPort:r,backendPort:o}),w=c&&u.configuration.roles.includes(W.Frontend)?{port:c,httpPaths:u.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:u.configuration.name??["web",...u.configuration.roles].join("-"),function:xs,options:{port:h,portFromConfig:u.configuration.port,apiKey:n,apiSecret:s,hostname:e,backendPort:o,frontendServerPort:r,directory:u.directory,devCommand:u.configuration.commands.dev,preDevCommand:u.configuration.commands.predev,scopes:a,shopCustomDomain:d,hmrServerOptions:w,roles:u.configuration.roles}}});return Promise.all(l)}async function vs({web:t,frontendPort:e,backendPort:r}){return Z(t,W.Frontend)?e:Z(t,W.Backend)?r:$()}async function xs({stdout:t,stderr:e,abortSignal:r},{port:o,apiKey:n,apiSecret:s,hostname:a,backendPort:i,frontendServerPort:c,directory:d,devCommand:l,preDevCommand:u,scopes:h,shopCustomDomain:w,hmrServerOptions:m}){let f=m?.port,U={SHOPIFY_API_KEY:n,SHOPIFY_API_SECRET:s,HOST:a,SCOPES:h,NODE_ENV:"development",...w&&{SHOP_CUSTOM_DOMAIN:w},BACKEND_PORT:`${i}`,FRONTEND_PORT:`${c}`,...f&&{HMR_SERVER_PORT:`${f}`},APP_URL:a,APP_ENV:"development",REMIX_DEV_ORIGIN:a},E={signal:r,directory:d,port:o,env:U,stdout:t,stderr:e};u&&(t.write(`Running pre-dev command: "${u}"`),await Xo({...E,command:u,showOutput:zt()})),await Xo({...E,command:l,showOutput:!0})}async function Xo({command:t,signal:e,directory:r,port:o,env:n,showOutput:s,stdout:a,stderr:i}){let c=t.split("&&").map(d=>d.trim())??[];for(let d of c){let[l,...u]=d.split(" ");l?.length!==0&&await Ue(l,u,{cwd:r,stdout:s?a:void 0,stderr:i,signal:e,env:{...n,PORT:`${o}`,SERVER_PORT:`${o}`}})}}p();p();p();var Oe=class{stdout;constructor(e){this.stdout=e}async info(e){await this.log(e)}async warning(e){await this.log(b`${v.yellow(e)}`.value)}async success(e){await this.log(b`${v.green(e)}`.value)}async debug(e){g(e,this.stdout)}async error(e,r){let o=v.errorText("\u274C Error"),n=v.errorText(`\u2514 ${e}`);await this.log(b`${o}`.value,r),await this.log(b`${n}`.value,r)}async logUserErrors(e,r){if(typeof e=="string")await this.error(e);else if(e instanceof Error)await this.error(e.message);else{let o=e.map(n=>{let s=n.on?n.on[0]:void 0,a=r.find(i=>i.uid===s?.user_identifier);return{error:n.message,prefix:a?.handle??"app-preview"}});await this.logMultipleErrors(o)}}async logExtensionEvents(e){let r=e.extensionEvents.filter(n=>n.extension.isAppConfigExtension),o=e.extensionEvents.filter(n=>!n.extension.isAppConfigExtension);r.length&&await this.log("App config updated","app-config"),o.forEach(async n=>{let s=n.extension.handle,a=`Extension ${n.type}`;await this.log(a,s)})}async logExtensionUpdateMessages(e){if(!e)return;let r=e.extensionEvents??[],n=(await Promise.all(r.map(async a=>a.type===ee.Deleted?[]:(await a.extension.getDevSessionUpdateMessages())?.map(c=>({message:c,prefix:a.extension.handle}))??[]))).flat(),s=n.map((a,i)=>{let c=b`${v.gray(i===n.length-1?"\u2514 ":"\u2502 ")}${a.message}`.value;return this.log(c,a.prefix)});await Promise.all(s)}async logMultipleErrors(e){let r=v.errorText("\u274C Error");await this.log(b`${r}`.value,"app-preview");let o=e.map(n=>{let s=v.errorText(`\u2514 ${n.error}`);return this.log(b`${s}`.value,n.prefix)});await Promise.all(o)}async log(e,r){await D({outputPrefix:r??"app-preview",stripAnsi:!1},()=>{this.stdout.write(e)})}};p();var Ne=class{processBatch;queue=[];processingPromise=void 0;constructor(e){this.processBatch=e}enqueue(e){this.queue.push(e),this.processingPromise??=this.startProcessing()}async waitForCompletion(){if(this.processingPromise)return this.processingPromise}async startProcessing(){try{for(;this.queue.length>0;){let e=[...this.queue];this.queue=[],await this.processBatch(e)}}finally{this.processingPromise=void 0}}};var qe=class t{static async start(e,r){let o=new t(e,r);return await o.start(),o}statusManager;logger;options;appWatcher;bundlePath;appEventsProcessor;failedEvents=[];currentSessionState=null;constructor(e,r){this.statusManager=e.devSessionStatusManager,this.logger=new Oe(r),this.options=e,this.appWatcher=e.appWatcher,this.bundlePath=e.appWatcher.buildOutputPath,this.appEventsProcessor=new Ne(o=>this.processEvents(o))}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async e=>this.onEvent(e)).onStart(async e=>this.onStart(e)).onError(async e=>this.handleDevSessionResult({status:"unknown-error",error:e}))}async onEvent(e){await this.validateAppEvent(e)&&this.appEventsProcessor.enqueue(e)}async processEvents(e){let r=[...this.failedEvents,...e],o=this.consolidateAppEvents(r);if(this.failedEvents=[],!o)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(o),await this.logger.logExtensionEvents(o);let n=Zr(),s=await this.bundleExtensionsAndUpload(o);await this.handleDevSessionResult(s,o),await this.logger.debug(`\u2705 Event handled [Network: ${tt(n)}ms - Total: ${tt(o.startTime)}ms]`)}consolidateAppEvents(e){if(e.length===0)return;if(e.length===1)return e[0];let r=e[0],o=e[e.length-1];if(!r||!o)return;let n=new Map;for(let a of e)for(let i of a.extensionEvents)n.set(i.extension.uid,i);return{app:o.app,path:o.path,extensionEvents:Array.from(n.values()),startTime:r.startTime,appWasReloaded:e.some(a=>a.appWasReloaded)}}async onStart(e){let r=this.parseBuildErrors(e);if(r.length)await this.logger.logMultipleErrors(r),await setImmediate(()=>{let o=r.map(n=>n.prefix);throw new T(`Dev preview aborted, build errors detected in extensions: ${o}`)});else{let o=await this.bundleExtensionsAndUpload(e);await this.handleDevSessionResult(o,e)}}async validateAppEvent(e){if(!this.statusManager.status.isReady)return await this.logger.warning("Change detected, but dev preview is not ready yet."),!1;let r=this.parseBuildErrors(e);return r.length?(await this.logger.logMultipleErrors(r),this.statusManager.setMessage("BUILD_ERROR"),!1):e.extensionEvents.length===0?(this.statusManager.setMessage("READY"),!1):!0}parseBuildErrors(e){return e.extensionEvents.filter(o=>o.buildResult?.status==="error").map(o=>({error:"Build error. Please review your code and try again.",prefix:o.extension.handle}))}async handleDevSessionResult(e,r){e.status==="updated"?(await this.logger.success(`\u2705 Updated dev preview on ${this.options.storeFqdn}`),await this.logger.logExtensionUpdateMessages(r),await this.setUpdatedStatusMessage()):e.status==="created"?(this.statusManager.updateStatus({isReady:!0}),await this.logger.success("\u2705 Ready, watching for changes in your app "),await this.logger.logExtensionUpdateMessages(r),this.statusManager.setMessage("READY")):e.status==="aborted"?await this.logger.debug("\u274C Dev preview update aborted (new change detected or error during update)"):(e.status==="remote-error"||e.status==="unknown-error")&&(await this.logger.logUserErrors(e.error,r?.app.allExtensions??[]),e.error instanceof Error&&e.error.cause==="validation-error"?this.statusManager.setMessage("VALIDATION_ERROR"):(r&&this.failedEvents.push(r),this.statusManager.setMessage("REMOTE_ERROR"))),!this.statusManager.status.isReady&&!Yt()&&setImmediate(()=>{throw new T("Failed to start dev preview.")})}updatePreviewURL(e){let r=e.app.nonConfigExtensions.length>0;this.statusManager.updateStatus({previewURL:this.options.appPreviewURL,appEmbedded:e.app.configuration.embedded,hasExtensions:r})}async setUpdatedStatusMessage(){this.statusManager.setMessage("UPDATED"),setTimeout(async()=>{this.statusManager.status.statusMessage?.message==="Updated"&&this.statusManager.setMessage("READY")},2e3)}async bundleExtensionsAndUpload(e){try{let{manifest:r,inheritedModuleUids:o,assets:n}=await this.createManifest(e),s=await this.uploadAssetsIfNeeded(n,!this.statusManager.status.isReady),a=re(this.options.url);if(this.statusManager.status.isReady){let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,manifest:r,inheritedModuleUids:o};return this.devSessionUpdateWithRetry(i)}else{let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,websocketUrl:a};return this.devSessionCreateWithRetry(i)}}catch(r){if(r.statusCode===401)throw new Error("Unauthorized");if(r instanceof Rt)throw r.response.status===401||r.response.status===403?new T("Auth session expired. Please run `shopify app dev` again."):(await this.logger.debug(JSON.stringify(r.response,null,2)),new T("Unknown error"));return r.code==="ETIMEDOUT"?{status:"unknown-error",error:new Error("Request timed out, please check your internet connection and try again.")}:{status:"unknown-error",error:r}}}async createManifest(e){let r=e.extensionEvents.filter(i=>i.type!=="deleted").map(i=>i.extension.uid);e.app.allExtensions.some(i=>i.type==="admin")&&!r.includes("admin")&&r.push("admin");let o=e.app.allExtensions.filter(i=>!r.includes(i.uid)).map(i=>i.uid),n=await e.app.manifest(void 0);await to(n,this.bundlePath),this.statusManager.status.isReady&&(n.modules=n.modules.filter(i=>r.includes(i.uid)));let s=await xt(this.bundlePath),a=n.modules.map(i=>i.assets).filter(i=>s.includes(i));return{manifest:n,inheritedModuleUids:o,assets:a}}async uploadAssetsIfNeeded(e,r){if(!e.length&&!r)return;let o=S(ue(this.bundlePath),`dev-bundle.${this.options.developerPlatformClient.bundleFormat}`),n=[...e.map(a=>`${a}/**`),...ro];r&&n.push("manifest.json"),await oo(this.bundlePath,o,n);let s=await this.getSignedURLWithRetry();return await no(s,o),s}async getSignedURLWithRetry(){return so(this.options.developerPlatformClient,{apiKey:this.options.appId,organizationId:this.options.organizationId,id:this.options.appId})}async devSessionUpdateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionUpdate(e),o=r.devSessionUpdate?.userErrors??[],n=r.devSessionUpdate?.devSession;if(n&&this.currentSessionState){let s=re(this.options.url),a=this.currentSessionState?.userId;if(n.websocketUrl!==s||n.user?.id!==a){let i=n.user?.email;await this.logger.error(`Another developer ${i?`(${i}) `:""}has taken ownership of this dev preview.`);let c=`Another user${i?` (${i})`:""} has taken ownership of this dev preview. Your preview is no longer active.`,d=["You can restart by running",{command:"shopify app dev"},"again."];throw new T(c,d)}this.currentSessionState={websocketUrl:n.websocketUrl,userId:n.user?.id??null,userEmail:n.user?.email??null}}return o.length?{status:"remote-error",error:o}:{status:"updated"}}async devSessionCreateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionCreate(e),o=r.devSessionCreate?.userErrors??[],n=r.devSessionCreate?.warnings??[],s=r.devSessionCreate?.devSession;return s&&(this.currentSessionState={websocketUrl:s.websocketUrl,userId:s.user?.id??null,userEmail:s.user?.email??null}),n.length>0&&await Promise.all(n.map(a=>{let i=a.code==="SESSION_TAKEOVER"?`\u26A0\uFE0F ${a.message}`:a.message;return this.logger.warning(i)})),o.length?{status:"remote-error",error:o}:{status:"created"}}};async function en({app:t,apiKey:e,developerPlatformClient:r,...o}){return{type:"dev-session",prefix:"app-preview",function:Es,options:{app:t,apiKey:e,developerPlatformClient:r,...o}}}var Es=async({stdout:t},e)=>{await qe.start(e,t)};p();p();p();var tn=async({appLog:t,appLogPayload:e,stdout:r,storeName:o,logsDir:n})=>{let s=bt().substring(0,6),i=`${bs(t.log_timestamp)}_${t.source_namespace}_${t.source}_${s}.json`,c=Ao({appLog:t,appLogPayload:e,prettyPrint:!0,storeName:o}),d=S(n,i);try{return await fe(n),await me(d,c),{fullOutputPath:d,identifier:s}}catch(l){throw r.write(`Error while writing log to file: ${l}
7
+ `,r.stdout);let o=JSON.stringify(e);t.clients.forEach(n=>n.send(o))}function is(t,e){let r=e.payloadStore.getRawPayload();return{...t,version:e.manifestVersion,data:{...t.data,extensions:[],store:r.store,app:r.app}}}var cs=10;function Fo(t){let e=new Mt.default({noServer:!0,clientTracking:!0}),r=ls(e);return t.httpServer.on("upgrade",$o(e,t)),t.payloadStore.on(le.Update,Mo(e,t)),{close:()=>{e.close(),clearInterval(r)}}}function ls(t){return setInterval(()=>{t.clients.forEach(e=>{e.readyState<2&&e.ping()})},cs*1e3)}p();p();p();function Oo(t,e){let{url:r}=$e(t.type,e);if(t.surface==="checkout"&&r){let o=new URL(`https://${e.storeFqdn}/`);return o.pathname=r,o.searchParams.append("dev",`${e.url}/extensions`),o.toString()}else{let o=new URL(`https://${e.storeFqdn}/`);return o.pathname="admin/extensions-dev",o.searchParams.append("url",Fe(t,e)),o.toString()}}function No(t,e,r){let o=Ie(t),n=new URL(`https://${r.storeFqdn}/`);switch(o){case"checkout":n.pathname=r.checkoutCartUrl,n.searchParams.append("dev",`${r.url}/extensions`);break;case"post_purchase":if(n.pathname=r.checkoutCartUrl,n.searchParams.set("script_url",`${r.url}/extensions/${e.devUUID}/assets/${e.localIdentifier}.js`),n.searchParams.set("post_purchase_dev_api_key",r.apiKey),e.devUUID&&r.websocketURL&&(n.searchParams.set("uuid",e.devUUID),n.searchParams.set("socket_url",r.websocketURL)),"metafields"in e.configuration){let s={config:{metafields:e.configuration.metafields}};n.searchParams.set("config",JSON.stringify(s))}break;case"admin":n.pathname="admin/extensions-dev",n.searchParams.append("url",Fe(e,r)),n.searchParams.append("target",t);break;case"customer-accounts":n=ps(e,r,t);break;default:return}return n.toString()}function ps(t,e,r=""){let o=`${e.url}/extensions`,n=e.storeId,s="shopify.com",a=new URL(`https://${s}/${n}/account/extensions-development`);return a.searchParams.append("origin",o),a.searchParams.append("extensionId",t.devUUID),a.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),a.searchParams.append("appId",e.id??""),r!==""&&a.searchParams.append("target",r),a}function Fe(t,e){let r=new URL(e.url);return r.pathname=`/extensions/${t.devUUID}`,r.toString()}function O(t,e){Zt(t,Xt(e))}p();var ct=class extends X{constructor(e){super(`Couldn't find template ${e.template} for extension surface ${e.extensionSurface}`)}};async function qo(t){let e=await us(t),r=await I(e);return Jt(r,t.data)}async function us(t){let e=await ds(),r=[];t.extensionSurface&&r.push(S(e,`${t.extensionSurface}/${t.template}.html.liquid`)),r.push(S(e,`${t.template}.html.liquid`));let o=await ge(r);if(o.length===0)throw new ct(t);return o[0]}async function ds(){return await vt("templates/ui-extensions/html",{type:"directory",cwd:yt(import.meta.url)})}var Wo=q(t=>{H(t,"Access-Control-Allow-Origin","*"),H(t,"Access-Control-Allow-Methods","GET, OPTIONS"),H(t,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),Ho=q(t=>{H(t,"Cache-Control","no-cache")}),lt=q(async t=>Ae(t,"/extensions",307));async function ms(t,e){let{filePath:r}=e;if(!await F(r))return O(t,{statusCode:404,statusMessage:`Not Found: ${r}`});if(await Pt(r)&&(r+=r.endsWith("/")?"index.html":"/index.html",!await F(r)))return O(t,{statusCode:404,statusMessage:`Not Found: ${r}`});let o=await I(r,{}),n={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".map":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},s=de(r),a=n[s]||"text/plain";return H(t,"Content-Type",a),o}function Go({getExtensions:t,payloadStore:e}){return q(async r=>{let{extensionId:o,assetPath:n=""}=Te(r),s=t().find(h=>h.devUUID===o);if(!s)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});let i=e.getAssetResolver(s.devUUID)?.get(n),c=i??n,d=c.endsWith(at);if(d&&i===void 0)return O(r,{statusCode:404,statusMessage:"Not Found"});let l=Ge(d?s.directory:Fr(s.outputPath)),u=Ge(S(l,c));return wt(l,u)?ms(r,{filePath:u}):O(r,{statusCode:404,statusMessage:"Not Found"})})}function pt({payloadStore:t}){return q(e=>(H(e,"content-type","application/json"),t.getRawPayload()))}function Bo({devOptions:t}){return q(e=>{g(`UI extensions server received a ${e.method} request to URL ${e.path}`,t.stdout)})}function ut({devOptions:t,getExtensions:e}){return q(async r=>{let{extensionId:o}=Te(r),n=e().find(i=>i.devUUID===o);if(!n)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(er(r,"accept")?.startsWith("text/html")){if(n.type==="checkout_post_purchase")return qo({data:{url:Fe(n,t)},template:"index",extensionSurface:"post_purchase"});{let i=Oo(n,t);return Ae(r,i,307)}}let a=t.appWatcher.buildOutputPath;return H(r,"content-type","application/json"),{app:{apiKey:t.apiKey},version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:re(t.url)},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extension:await te(n,a,t)}})}function Ko({devOptions:t,getExtensions:e}){return q(async r=>{let{extensionId:o,extensionPointTarget:n=""}=Te(r),s=e().find(i=>i.devUUID===o);if(!s)return O(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(s.configuration.type!=="checkout_post_purchase"&&!s.hasExtensionPointTarget(n))return O(r,{statusCode:404,statusMessage:`Extension with id ${o} has not configured the "${n}" extension target`});let a=No(n,s,t);return a?Ae(r,a,307):O(r,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${o} and extension target "${n}"`})})}import{createServer as fs}from"http";function jo(t){let e=tr(),r=rr();e.use(Bo(t)),e.use(Wo),e.use(Ho),r.use("/extensions/dev-console",lt),r.use("/extensions/:extensionId",ut(t)),r.use("/extensions/:extensionId/",ut(t)),r.use("/extensions/:extensionId/:extensionPointTarget",Ko(t)),r.use("/extensions/:extensionId/assets/**:assetPath",Go(t)),r.use("/extensions",pt(t)),r.use("/extensions/",pt(t)),r.use("/",lt),e.use(r);let o=fs(or(e));return o.listen(t.devOptions.port,"localhost"),o}async function zo(t){let e={...t,websocketURL:re(t.url)},r=e.appWatcher.buildOutputPath,o=new Map,n=await Lo(e,r,o),s=new De(n,e,o),a=e.extensions.filter(u=>u.isPreviewable),i=()=>a;g("Setting up the UI extensions HTTP server...",e.stdout);let c=jo({devOptions:e,payloadStore:s,getExtensions:i});g("Setting up the UI extensions Websocket server...",e.stdout);let d=Fo({...e,httpServer:c,payloadStore:s});g("Setting up the UI extensions bundler and file watching...",e.stdout);let l=async({appWasReloaded:u,app:h,extensionEvents:w})=>{u&&(a=h.allExtensions.filter(m=>m.isPreviewable));for(let m of w){if(!m.extension.isPreviewable)continue;let f=m.buildResult?.status==="ok"?"success":"error",U=m.buildResult?.status==="error"?{message:m.buildResult.error,file:m.buildResult.file}:void 0;switch(m.type){case ee.Created:if(e.extensions.push(m.extension),!e.checkoutCartUrl){let E=await ke(e.extensions,e.storeFqdn);e.checkoutCartUrl=E}await s.addExtension(m.extension,r);break;case ee.Updated:await s.updateExtension(m.extension,e,r,{status:f,error:U});break;case ee.Deleted:e.extensions=e.extensions.filter(E=>E.devUUID!==m.extension.devUUID),await s.deleteExtension(m.extension);break}}};e.appWatcher.onEvent(l).onStart(l),e.signal.addEventListener("abort",()=>{g("Closing the UI extensions dev server..."),d.close(),c.close()})}function re(t){let e=new URL("/extensions",t);return e.protocol="wss:",e.toString()}var hs="3",gs=async({stderr:t,stdout:e,abortSignal:r},{apiKey:o,storeFqdn:n,storeId:s,subscriptionProductUrl:a,port:i,cartUrl:c,proxyUrl:d,appName:l,appDotEnvFile:u,appId:h,grantedScopes:w,allExtensions:m,appDirectory:f,appWatcher:U})=>{await zo({appName:l,appDotEnvFile:u,appDirectory:f,id:h,extensions:m,stdout:e,stderr:t,signal:r,url:d,port:i,storeFqdn:ye(n),storeId:s,apiKey:o,grantedScopes:w,checkoutCartUrl:c,subscriptionProductUrl:a,manifestVersion:hs,appWatcher:U})};async function Yo({allExtensions:t,storeFqdn:e,checkoutCartUrl:r,...o}){let n=t.filter(a=>a.isPreviewable),s=await ke(n,e,r);return{prefix:"extensions",type:"previewable-extension",function:gs,options:{pathPrefix:"/extensions",port:-1,storeFqdn:e,allExtensions:t,cartUrl:s,...o}}}p();p();function z(t){let e=t.find(o=>Z(o,W.Frontend)),r=t.find(o=>Z(o,W.Backend));return{frontendConfig:e,backendConfig:r}}p();async function Vo(t){let r={topic:"app/uninstalled",api_version:(await lo(t.developerPlatformClient,t.organizationId))[1],address:t.address,delivery_method:mo.LOCALHOST,shared_secret:t.sharedSecret},o=await po(t.developerPlatformClient,r,t.organizationId);t.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await ae(3);let n=await ws(t,o);return t.stdout.write(n?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),n}async function ws(t,e){let r=0;for(;r<3;){try{return await uo(t.address,e.samplePayload,JSON.stringify({...JSON.parse(e.headers),"X-Shopify-Shop-Domain":t.storeFqdn}))}catch(o){if(o instanceof Tt&&o.code==="ECONNREFUSED")r<3&&(t.stdout.write("App isn't responding yet, retrying in 5 seconds"),await ae(5));else throw o}r++}return t.stdout.write("App hasn't started in time, giving up"),!1}var ys=async({stdout:t},e)=>{await Vo({stdout:t,developerPlatformClient:e.developerPlatformClient,address:`http://localhost:${e.deliveryPort}${e.webhooksPath}`,sharedSecret:e.apiSecret,storeFqdn:e.storeFqdn,organizationId:e.organizationId})};function Qo({webs:t,remoteAppUpdated:e,backendPort:r,frontendPort:o,organizationId:n,...s}){let{backendConfig:a,frontendConfig:i}=z(t),c=t.map(({configuration:l})=>l.webhooks_path).find(l=>l)??"/api/webhooks";if(c&&e&&(i??a))return{type:"send-webhook",prefix:"webhooks",function:ys,options:{deliveryPort:a?r:o,webhooksPath:c,organizationId:n,...s}}}p();async function Jo(t){return{type:"graphiql",prefix:"graphiql",options:t,function:Ps}}var Ps=async({stdout:t,abortSignal:e},r)=>{let o=fo({apiKey:r.apiKey,apiSecret:r.apiSecret,storeFqdn:r.storeFqdn}),n=sr({stdout:t,port:r.port,storeFqdn:r.storeFqdn,key:r.key,tokenProvider:o,appContext:{appName:r.appName,appUrl:r.appUrl,apiSecret:r.apiSecret}});e.addEventListener("abort",()=>{n.close()})};p();async function Zo({webs:t,proxyUrl:e,frontendPort:r,backendPort:o,apiKey:n,apiSecret:s,scopes:a}){let{frontendConfig:i}=z(t),c=i?.configuration.hmr_server?await $():void 0,d=void 0,l=t.map(async u=>{let h=await vs({web:u,frontendPort:r,backendPort:o}),w=c&&u.configuration.roles.includes(W.Frontend)?{port:c,httpPaths:u.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:u.configuration.name??["web",...u.configuration.roles].join("-"),function:xs,options:{port:h,portFromConfig:u.configuration.port,apiKey:n,apiSecret:s,hostname:e,backendPort:o,frontendServerPort:r,directory:u.directory,devCommand:u.configuration.commands.dev,preDevCommand:u.configuration.commands.predev,scopes:a,shopCustomDomain:d,hmrServerOptions:w,roles:u.configuration.roles}}});return Promise.all(l)}async function vs({web:t,frontendPort:e,backendPort:r}){return Z(t,W.Frontend)?e:Z(t,W.Backend)?r:$()}async function xs({stdout:t,stderr:e,abortSignal:r},{port:o,apiKey:n,apiSecret:s,hostname:a,backendPort:i,frontendServerPort:c,directory:d,devCommand:l,preDevCommand:u,scopes:h,shopCustomDomain:w,hmrServerOptions:m}){let f=m?.port,U={SHOPIFY_API_KEY:n,SHOPIFY_API_SECRET:s,HOST:a,SCOPES:h,NODE_ENV:"development",...w&&{SHOP_CUSTOM_DOMAIN:w},BACKEND_PORT:`${i}`,FRONTEND_PORT:`${c}`,...f&&{HMR_SERVER_PORT:`${f}`},APP_URL:a,APP_ENV:"development",REMIX_DEV_ORIGIN:a},E={signal:r,directory:d,port:o,env:U,stdout:t,stderr:e};u&&(t.write(`Running pre-dev command: "${u}"`),await Xo({...E,command:u,showOutput:zt()})),await Xo({...E,command:l,showOutput:!0})}async function Xo({command:t,signal:e,directory:r,port:o,env:n,showOutput:s,stdout:a,stderr:i}){let c=t.split("&&").map(d=>d.trim())??[];for(let d of c){let[l,...u]=d.split(" ");l?.length!==0&&await Ue(l,u,{cwd:r,stdout:s?a:void 0,stderr:i,signal:e,env:{...n,PORT:`${o}`,SERVER_PORT:`${o}`}})}}p();p();p();var Oe=class{stdout;constructor(e){this.stdout=e}async info(e){await this.log(e)}async warning(e){await this.log(b`${v.yellow(e)}`.value)}async success(e){await this.log(b`${v.green(e)}`.value)}async debug(e){g(e,this.stdout)}async error(e,r){let o=v.errorText("\u274C Error"),n=v.errorText(`\u2514 ${e}`);await this.log(b`${o}`.value,r),await this.log(b`${n}`.value,r)}async logUserErrors(e,r){if(typeof e=="string")await this.error(e);else if(e instanceof Error)await this.error(e.message);else{let o=e.map(n=>{let s=n.on?n.on[0]:void 0,a=r.find(i=>i.uid===s?.user_identifier);return{error:n.message,prefix:a?.handle??"app-preview"}});await this.logMultipleErrors(o)}}async logExtensionEvents(e){let r=e.extensionEvents.filter(n=>n.extension.isAppConfigExtension),o=e.extensionEvents.filter(n=>!n.extension.isAppConfigExtension);r.length&&await this.log("App config updated","app-config"),o.forEach(async n=>{let s=n.extension.handle,a=`Extension ${n.type}`;await this.log(a,s)})}async logExtensionUpdateMessages(e,r){if(!e||r.status==="remote-error"||r.status==="unknown-error")return;let o={status:r.status},n=e.extensionEvents??[],a=(await Promise.all(n.map(async c=>c.type===ee.Deleted?[]:(await c.extension.getDevSessionUpdateMessages(o))?.map(l=>({message:l,prefix:c.extension.handle}))??[]))).flat(),i=a.map((c,d)=>{let l=b`${v.gray(d===a.length-1?"\u2514 ":"\u2502 ")}${c.message}`.value;return this.log(l,c.prefix)});await Promise.all(i)}async logMultipleErrors(e){let r=v.errorText("\u274C Error");await this.log(b`${r}`.value,"app-preview");let o=e.map(n=>{let s=v.errorText(`\u2514 ${n.error}`);return this.log(b`${s}`.value,n.prefix)});await Promise.all(o)}async log(e,r){await D({outputPrefix:r??"app-preview",stripAnsi:!1},()=>{this.stdout.write(e)})}};p();var Ne=class{processBatch;queue=[];processingPromise=void 0;constructor(e){this.processBatch=e}enqueue(e){this.queue.push(e),this.processingPromise??=this.startProcessing()}async waitForCompletion(){if(this.processingPromise)return this.processingPromise}async startProcessing(){try{for(;this.queue.length>0;){let e=[...this.queue];this.queue=[],await this.processBatch(e)}}finally{this.processingPromise=void 0}}};var qe=class t{static async start(e,r){let o=new t(e,r);return await o.start(),o}statusManager;logger;options;appWatcher;bundlePath;appEventsProcessor;failedEvents=[];currentSessionState=null;constructor(e,r){this.statusManager=e.devSessionStatusManager,this.logger=new Oe(r),this.options=e,this.appWatcher=e.appWatcher,this.bundlePath=e.appWatcher.buildOutputPath,this.appEventsProcessor=new Ne(o=>this.processEvents(o))}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async e=>this.onEvent(e)).onStart(async e=>this.onStart(e)).onError(async e=>this.handleDevSessionResult({status:"unknown-error",error:e}))}async onEvent(e){await this.validateAppEvent(e)&&this.appEventsProcessor.enqueue(e)}async processEvents(e){let r=[...this.failedEvents,...e],o=this.consolidateAppEvents(r);if(this.failedEvents=[],!o)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(o),await this.logger.logExtensionEvents(o);let n=Zr(),s=await this.bundleExtensionsAndUpload(o);await this.handleDevSessionResult(s,o),await this.logger.debug(`\u2705 Event handled [Network: ${tt(n)}ms - Total: ${tt(o.startTime)}ms]`)}consolidateAppEvents(e){if(e.length===0)return;if(e.length===1)return e[0];let r=e[0],o=e[e.length-1];if(!r||!o)return;let n=new Map;for(let a of e)for(let i of a.extensionEvents)n.set(i.extension.uid,i);return{app:o.app,path:o.path,extensionEvents:Array.from(n.values()),startTime:r.startTime,appWasReloaded:e.some(a=>a.appWasReloaded)}}async onStart(e){let r=this.parseBuildErrors(e);if(r.length)await this.logger.logMultipleErrors(r),await setImmediate(()=>{let o=r.map(n=>n.prefix);throw new T(`Dev preview aborted, build errors detected in extensions: ${o}`)});else{let o=await this.bundleExtensionsAndUpload(e);await this.handleDevSessionResult(o,e)}}async validateAppEvent(e){if(!this.statusManager.status.isReady)return await this.logger.warning("Change detected, but dev preview is not ready yet."),!1;let r=this.parseBuildErrors(e);return r.length?(await this.logger.logMultipleErrors(r),this.statusManager.setMessage("BUILD_ERROR"),!1):e.extensionEvents.length===0?(this.statusManager.setMessage("READY"),!1):!0}parseBuildErrors(e){return e.extensionEvents.filter(o=>o.buildResult?.status==="error").map(o=>({error:"Build error. Please review your code and try again.",prefix:o.extension.handle}))}async handleDevSessionResult(e,r){e.status==="updated"?(await this.logger.success(`\u2705 Updated dev preview on ${this.options.storeFqdn}`),await this.logger.logExtensionUpdateMessages(r,e),await this.setUpdatedStatusMessage()):e.status==="created"?(this.statusManager.updateStatus({isReady:!0}),await this.logger.success("\u2705 Ready, watching for changes in your app "),await this.logger.logExtensionUpdateMessages(r,e),this.statusManager.setMessage("READY")):(e.status==="remote-error"||e.status==="unknown-error")&&(await this.logger.logUserErrors(e.error,r?.app.allExtensions??[]),e.error instanceof Error&&e.error.cause==="validation-error"?this.statusManager.setMessage("VALIDATION_ERROR"):(r&&this.failedEvents.push(r),this.statusManager.setMessage("REMOTE_ERROR"))),!this.statusManager.status.isReady&&!Yt()&&setImmediate(()=>{throw new T("Failed to start dev preview.")})}updatePreviewURL(e){let r=e.app.nonConfigExtensions.length>0;this.statusManager.updateStatus({previewURL:this.options.appPreviewURL,appEmbedded:e.app.configuration.embedded,hasExtensions:r})}async setUpdatedStatusMessage(){this.statusManager.setMessage("UPDATED"),setTimeout(async()=>{this.statusManager.status.statusMessage?.message==="Updated"&&this.statusManager.setMessage("READY")},2e3)}async bundleExtensionsAndUpload(e){try{let{manifest:r,inheritedModuleUids:o,assets:n}=await this.createManifest(e),s=await this.uploadAssetsIfNeeded(n,!this.statusManager.status.isReady),a=re(this.options.url);if(this.statusManager.status.isReady){let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,manifest:r,inheritedModuleUids:o};return this.devSessionUpdateWithRetry(i)}else{let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,websocketUrl:a};return this.devSessionCreateWithRetry(i)}}catch(r){if(r.statusCode===401)throw new Error("Unauthorized");if(r instanceof Rt)throw r.response.status===401||r.response.status===403?new T("Auth session expired. Please run `shopify app dev` again."):(await this.logger.debug(JSON.stringify(r.response,null,2)),new T("Unknown error"));return r.code==="ETIMEDOUT"?{status:"unknown-error",error:new Error("Request timed out, please check your internet connection and try again.")}:{status:"unknown-error",error:r}}}async createManifest(e){let r=e.extensionEvents.filter(i=>i.type!=="deleted").map(i=>i.extension.uid);e.app.allExtensions.some(i=>i.type==="admin")&&!r.includes("admin")&&r.push("admin");let o=e.app.allExtensions.filter(i=>!r.includes(i.uid)).map(i=>i.uid),n=await e.app.manifest(void 0);await to(n,this.bundlePath),this.statusManager.status.isReady&&(n.modules=n.modules.filter(i=>r.includes(i.uid)));let s=await xt(this.bundlePath),a=n.modules.map(i=>i.assets).filter(i=>s.includes(i));return{manifest:n,inheritedModuleUids:o,assets:a}}async uploadAssetsIfNeeded(e,r){if(!e.length&&!r)return;let o=S(ue(this.bundlePath),`dev-bundle.${this.options.developerPlatformClient.bundleFormat}`),n=[...e.map(a=>`${a}/**`),...ro];r&&n.push("manifest.json"),await oo(this.bundlePath,o,n);let s=await this.getSignedURLWithRetry();return await no(s,o),s}async getSignedURLWithRetry(){return so(this.options.developerPlatformClient,{apiKey:this.options.appId,organizationId:this.options.organizationId,id:this.options.appId})}async devSessionUpdateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionUpdate(e),o=r.devSessionUpdate?.userErrors??[],n=r.devSessionUpdate?.devSession;if(n&&this.currentSessionState){let s=re(this.options.url),a=this.currentSessionState?.userId;if(n.websocketUrl!==s||n.user?.id!==a){let i=n.user?.email;await this.logger.error(`Another developer ${i?`(${i}) `:""}has taken ownership of this dev preview.`);let c=`Another user${i?` (${i})`:""} has taken ownership of this dev preview. Your preview is no longer active.`,d=["You can restart by running",{command:"shopify app dev"},"again."];throw new T(c,d)}this.currentSessionState={websocketUrl:n.websocketUrl,userId:n.user?.id??null,userEmail:n.user?.email??null}}return o.length?{status:"remote-error",error:o}:{status:"updated"}}async devSessionCreateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionCreate(e),o=r.devSessionCreate?.userErrors??[],n=r.devSessionCreate?.warnings??[],s=r.devSessionCreate?.devSession;return s&&(this.currentSessionState={websocketUrl:s.websocketUrl,userId:s.user?.id??null,userEmail:s.user?.email??null}),n.length>0&&await Promise.all(n.map(a=>{let i=a.code==="SESSION_TAKEOVER"?`\u26A0\uFE0F ${a.message}`:a.message;return this.logger.warning(i)})),o.length?{status:"remote-error",error:o}:{status:"created"}}};async function en({app:t,apiKey:e,developerPlatformClient:r,...o}){return{type:"dev-session",prefix:"app-preview",function:Es,options:{app:t,apiKey:e,developerPlatformClient:r,...o}}}var Es=async({stdout:t},e)=>{await qe.start(e,t)};p();p();p();var tn=async({appLog:t,appLogPayload:e,stdout:r,storeName:o,logsDir:n})=>{let s=bt().substring(0,6),i=`${bs(t.log_timestamp)}_${t.source_namespace}_${t.source}_${s}.json`,c=Ao({appLog:t,appLogPayload:e,prettyPrint:!0,storeName:o}),d=S(n,i);try{return await fe(n),await me(d,c),{fullOutputPath:d,identifier:s}}catch(l){throw r.write(`Error while writing log to file: ${l}
8
8
  `),l}};function bs(t){let e=new Date(t),r=e.getUTCFullYear(),o=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),s=e.getUTCHours().toString().padStart(2,"0"),a=e.getUTCMinutes().toString().padStart(2,"0"),i=e.getUTCSeconds().toString().padStart(2,"0"),c=e.getUTCMilliseconds().toString().padStart(3,"0");return`${r}${o}${n}_${s}${a}${i}_${c}Z`}var We=async({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:r},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:c,consecutiveResubscribeFailures:d=0})=>{if(!i?.aborted)try{let l=e,u=wo,h=d,w=await o.appLogs({jwtToken:e,cursor:r},a),{errors:m,status:f}=w;if(f===200){h=0;let{app_logs:E}=w;for(let R of E){let x=JSON.parse(R.payload);await D({outputPrefix:R.source,stripAnsi:!1},async()=>{R.log_type===vo?(Ss(R,x,t),x=new ho(go(x))):R.log_type.startsWith(xo)?Us(R,x,t):t.write(JSON.stringify(x));let _=await tn({appLog:R,appLogPayload:x,stdout:t,storeName:s,logsDir:c});t.write(b`${v.gray("\u2514 ")}${v.link("Open log file",`file://${_.fullOutputPath}`,`Log: ${_.fullOutputPath}`)} ${v.gray(`(${_.identifier})`)}\n`.value)})}}else{let E={errors:m.map(x=>({message:x,status:f}))},R=await To({response:E,onThrottle:x=>{C("Request throttled while polling app logs.",t),C(`Retrying in ${x/1e3} seconds.`,t)},onUnknownError:x=>{C("Error while polling app logs.",t),C(`Retrying in ${x/1e3} seconds.`,t)},onResubscribe:()=>n()});if(R.resubscribeResult==="failed"){if(h+=1,h>=yo){C("App log streaming session has expired. Please restart your dev session.",t);return}}else R.resubscribeResult==="succeeded"&&(h=0);R.nextJwtToken&&(l=R.nextJwtToken),u=R.retryIntervalMs}let{cursor:U}=w;setTimeout(()=>{We({stdout:t,appLogsFetchInput:{jwtToken:l,cursor:U??r},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:c,consecutiveResubscribeFailures:h}).catch(E=>{g(`Unexpected error during polling: ${E}}
9
9
  `)})},u)}catch(l){C("Error while polling app logs.",t),C(`Retrying in ${ot/1e3} seconds.`,t),g(`${l}}
10
10
  `),setTimeout(()=>{We({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:void 0},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:c}).catch(u=>{g(`Unexpected error during polling: ${u}}
@@ -17,4 +17,4 @@ ${v.json(JSON.stringify(t))}
17
17
  `),n.statusCode=500,n.end(`Invalid path ${o.url}`)}}function ln(t,e,r=!1){let o=e.url??"/";for(let n in t)if(o.startsWith(n))return t[n];return r&&t.websocket?t.websocket:t.default}async function pn({localApp:t,remoteAppUpdated:e,developerPlatformClient:r,remoteApp:o,storeFqdn:n,storeId:s,commandOptions:a,network:i,graphiqlPort:c,graphiqlKey:d}){let l=o.apiKey,u=o.apiSecretKeys[0]?.secret??"",h=St(),w=!ft(h[Ce.disableGraphiQLExplorer]),m=await Kr(t),f=new eo(m,i.proxyUrl),U=await we(),E=io(n,l,U),R=E,x=nr(d,u,n),_=w?`http://localhost:${c}/graphiql?key=${encodeURIComponent(x)}`:void 0,ne=m.configuration.embedded,V=m.nonConfigExtensions.length>0,N=new He({isReady:!1,previewURL:R,graphiqlURL:_,appEmbedded:ne,hasExtensions:V}),G=[...await Zo({webs:m.webs,proxyUrl:i.proxyUrl,frontendPort:i.frontendPort,backendPort:i.backendPort,apiKey:l,apiSecret:u,scopes:$r(m.configuration)}),w?await Jo({appName:o.title,appUrl:E,port:c,apiKey:l,apiSecret:u,key:x,storeFqdn:n}):void 0,await Yo({allExtensions:m.realExtensions,storeFqdn:n,storeId:s,apiKey:l,subscriptionProductUrl:a.subscriptionProductUrl,checkoutCartUrl:a.checkoutCartUrl,proxyUrl:i.proxyUrl,appName:m.name,appDotEnvFile:m.dotenv,grantedScopes:o.grantedScopes,appId:o.id,appDirectory:m.directory,appWatcher:f}),await en({app:m,apiKey:l,developerPlatformClient:r,url:i.proxyUrl,appId:o.id,organizationId:o.organizationId,storeFqdn:n,appWatcher:f,appPreviewURL:E,devSessionStatusManager:N}),await ko({remoteApp:o,localApp:m,storeFqdn:n,theme:a.theme,themeExtensionPort:a.themeExtensionPort,storePassword:a.storePassword}),Qo({webs:m.webs,backendPort:i.backendPort,frontendPort:i.frontendPort,organizationId:o.organizationId,developerPlatformClient:r,storeFqdn:n,apiSecret:u,remoteAppUpdated:e}),await rn({developerPlatformClient:r,subscription:{shopIds:[Number(s)],apiKey:l},storeName:n,organizationId:o.organizationId,localApp:t,appWatcher:f}),await on({appWatcher:f})].filter(Ls);return{processes:await $s(G,i.proxyPort,i.reverseProxyCert),previewUrl:R,graphiqlUrl:_,devSessionStatusManager:N}}var Ls=t=>t!==void 0&&t!==!1;async function $s(t,e,r){let o=await Promise.all(t.map(async a=>{let i={};if(a.type==="web"&&a.options.roles.includes(W.Frontend)){let c=a.options.portFromConfig??a.options.port;i.default=`http://localhost:${c}`;let d=a.options.hmrServerOptions;d&&(i.websocket=`http://localhost:${d.port}`,d.httpPaths.forEach(l=>i[l]=`http://localhost:${d.port}`)),a.options.port=c}else if(a.type==="previewable-extension"){let c=await $();i[a.options.pathPrefix]=`http://localhost:${c}`,a.options.port=c}return{process:a,rules:i}})),n=o.map(({process:a})=>a),s=o.map(({rules:a})=>a).reduce((a,i)=>({...a,...i}),{});return Object.keys(s).length>0&&n.push({type:"proxy-server",prefix:"proxy",function:Ms,options:{port:e,rules:s,localhostCert:r}}),n}var Ms=async({abortSignal:t,stdout:e},{port:r,rules:o,localhostCert:n})=>{let{server:s}=await cn(o,t,n,e);B(`Proxy server started on port ${r} ${n?`with certificate ${n.certPath}`:""}`,e),await s.listen(r,"localhost")};p();p();p();var oe=Q(Pe(),1);var un=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function dn(){let[t,e]=(0,oe.useState)(0);return(0,oe.useEffect)(()=>{let r=setInterval(()=>{e(o=>(o+1)%un.length)},70);return()=>clearInterval(r)},[]),oe.default.createElement(L,null,un[t])}p();var A=Q(Pe(),1);var mn=.9,fn=({tabs:t,initialActiveTab:e})=>{let{stdout:r}=Dt(),{isRawModeSupported:o}=ve(),[n,s]=(0,A.useState)(e),[a,i]=(0,A.useState)(Math.floor(r.columns*mn)),[c,d]=(0,A.useState)(!0),l=(0,A.useRef)(null);if(!n)throw new Error("No tabs provided");xe((m,f)=>{(async()=>{if(f?.leftArrow||f?.rightArrow||f?.tab){let x=Object.entries(t).filter(([G,P])=>P.content),_=x.findIndex(([G])=>G===n);if(_===-1)return;let ne=f?.leftArrow?-1:1,V=(_+ne+x.length)%x.length,N=x[V];N&&s(N[0])}let E=t[m];if(E){E.action?await E.action():s(m);return}let R=t[n];if(R?.shortcuts){let x=R.shortcuts.find(_=>_.key===m);x&&(!x.condition||x.condition())&&await x.action()}})()},{isActive:!!o}),(0,A.useLayoutEffect)(()=>{let m=()=>{if(i(Math.floor(r.columns*mn)),!l.current)return;let f=Ft(l.current);d(f.width<r.columns)};return r.on("resize",m),()=>{r.off("resize",m)}},[r]);let u=Object.entries(t).map(([m,f])=>({...f,inputKey:m,header:` (${m}) ${f.label} `})),h=u.filter(m=>!m.action),w=u.filter(m=>m.action);return A.default.createElement(A.default.Fragment,null,A.default.createElement(k,{paddingTop:0,width:a,flexDirection:"row",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},A.default.createElement(k,{ref:l,flexDirection:"row",flexWrap:"nowrap",flexShrink:0,marginRight:3},A.default.createElement(L,{wrap:"truncate-end"},"\u2502",h.map(m=>A.default.createElement(A.default.Fragment,{key:m.inputKey},A.default.createElement(L,{bold:n===m.inputKey,inverse:n===m.inputKey,wrap:"truncate"},m.header),"\u2502")))),c&&A.default.createElement(k,{flexGrow:1,justifyContent:"flex-end"},w.map((m,f)=>A.default.createElement(L,{wrap:"truncate",key:m.inputKey},"(",m.inputKey,") ",m.label,f<w.length-1&&" \u2502 ")))),A.default.createElement(k,{flexDirection:"column",marginLeft:1,marginRight:1,marginTop:1},t[n]?.content))};var y=Q(Pe(),1);var hn=({abortController:t,processes:e,devSessionStatusManager:r,shopFqdn:o,appURL:n,appName:s,organizationName:a,configPath:i,localURL:c,onAbort:d})=>{let{isRawModeSupported:l}=ve(),[u,h]=(0,y.useState)(void 0),[w,m]=(0,y.useState)(void 0),[f,U]=(0,y.useState)(r.status),[E,R]=(0,y.useState)(!1),{isAborted:x}=Gt(t.signal,async P=>{P&&m(typeof P=="string"?P:P.message),r.status.isReady?R(!0):(h("Shutting down dev ..."),await d()),_o()}),_=(0,y.useMemo)(()=>e.map(P=>({...P,action:async(pe,Rn,Tn)=>{try{return await P.action(pe,Rn,Tn)}catch(An){t.abort(An)}}})),[e,t]);(0,y.useEffect)(()=>(r.on("dev-session-update",U),()=>{r.off("dev-session-update",U)}),[]),xe((P,pe)=>{Nt(P,pe,()=>t.abort())},{isActive:!!l});let ne=P=>{switch(P){case"loading":return y.default.createElement(dn,null);case"success":return"\u2705";case"error":return"\u274C"}},V=[{key:"p",shortcutLabel:"Open app preview",linkLabel:"Preview",url:f.previewURL,condition:()=>!!(f.isReady&&f.previewURL),action:async()=>{await K.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),f.previewURL&&await Se(f.previewURL)}},{key:"c",shortcutLabel:"Open Dev Console for extension previews",linkLabel:"Dev Console",url:rt(o),condition:()=>!!(f.isReady&&f.appEmbedded===!1&&f.hasExtensions),action:async()=>{await K.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await Se(rt(o))}},{key:"g",shortcutLabel:"Open GraphiQL (Admin API)",linkLabel:"GraphiQL",url:f.graphiqlURL,condition:()=>!!(f.isReady&&f.graphiqlURL),action:async()=>{await K.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),f.graphiqlURL&&await Se(f.graphiqlURL)}}],N=V.filter(P=>P.condition?.()??!0),G={d:{label:"Dev status",shortcuts:V,content:y.default.createElement(y.default.Fragment,null,f.statusMessage&&y.default.createElement(L,null,ne(f.statusMessage.type)," ",f.statusMessage.message),l&&N.length>0&&y.default.createElement(k,{marginTop:1,flexDirection:"column"},N.map(P=>y.default.createElement(L,{key:P.key},qt.pointerSmall," ",y.default.createElement(L,{bold:!0},"(",P.key,")")," ",Ye()&&P.url?y.default.createElement(je,{url:P.url,label:P.shortcutLabel}):P.shortcutLabel))),y.default.createElement(k,{marginTop:l?1:0,flexDirection:"column"},u?y.default.createElement(L,null,u):y.default.createElement(y.default.Fragment,null,f.isReady&&!(l&&Ye())&&y.default.createElement(y.default.Fragment,null,N.filter(P=>P.url).map(P=>y.default.createElement(L,{key:P.key},P.linkLabel," URL: ",y.default.createElement(je,{url:P.url})))))))},a:{label:"App info",content:y.default.createElement(k,{flexDirection:"column"},y.default.createElement(ze,{tabularData:[["App:",s??""],["App URL:",n??""],["Local URL:",n?"":c??""],["Config:",i?.split("/").pop()??""],["Org:",a??""]].filter(([,P])=>P)}))},s:{label:"Store info",content:y.default.createElement(k,{flexDirection:"column"},y.default.createElement(ze,{tabularData:[["Dev store:",{link:{url:`https://${o}`}}],["Dev store admin:",{link:{url:`https://${o}/admin`}}],["Org:",a??""]].filter(([,P])=>P)}))},q:{label:"Quit",action:async()=>{t.abort()}}};return y.default.createElement(y.default.Fragment,null,y.default.createElement(Wt,{processes:_,prefixColumnSize:Dr,abortSignal:t.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!0}),E&&y.default.createElement(k,{marginTop:1,flexDirection:"column"},y.default.createElement(Ht,{type:"info",headline:`A preview of your development changes is still available on ${o}.`,body:["Run",{command:"shopify app dev clean"},"to restore the latest released version of your app."],link:{label:"Learn more about dev previews",url:"https://shopify.dev/beta/developer-dashboard/shopify-app-dev"}})),x?null:y.default.createElement(k,{paddingTop:1,flexDirection:"column",flexGrow:1},l?y.default.createElement(fn,{tabs:G,initialActiveTab:"d"}):y.default.createElement(k,{marginY:1,paddingTop:0,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},G.d?.content)),w?y.default.createElement(k,{marginTop:1,flexDirection:"column"},y.default.createElement(L,{color:"red"},w)):null)};var gn=Q(Pe(),1);async function wn({processes:t,previewUrl:e,app:r,abortController:o,graphiqlUrl:n,shopFqdn:s,devSessionStatusManager:a,appURL:i,appName:c,organizationName:d,configPath:l,localURL:u}){if(Kt())return Ot(gn.default.createElement(hn,{processes:t,abortController:o,devSessionStatusManager:a,shopFqdn:s,appURL:i,appName:c,organizationName:d,configPath:l,localURL:u,onAbort:async()=>{await r.developerPlatformClient.devSessionDelete({appId:r.id,shopFqdn:s})}}),{exitOnCtrlC:!1});await Ds({processes:t,previewUrl:e,graphiqlUrl:n,abortController:o})}async function Ds({processes:t,previewUrl:e,graphiqlUrl:r,abortController:o}){return process.stdout.write(`
18
18
  Preview URL: ${e}
19
19
  `),r&&process.stdout.write(`GraphiQL URL (Admin API): ${r}
20
- `),Promise.all(t.map(async n=>{await n.action(process.stdout,process.stderr,o.signal)}))}p();function yn(t){if(!t.length)return;let e=t.filter(n=>n.requested!==n.actual);if(e.length===0)return;if(e.length===1&&e[0]){let n=e[0];se({headline:[`A random port will be used for ${n.for} because ${n?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:n?.flagToRemedy}," flag."]});return}let r=Be(e.map(n=>n.for)).join(" "),o=Be(e.map(n=>({command:n.flagToRemedy})));se({headline:[`Random ports will be used for ${r} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...o,"flags."]})}p();async function Pn(t,e){return e?e.includes("localhost")?"localhost":(await _t(t)).plugins.find(o=>e?.includes(o))??"custom":void 0}p();var vn=Q(Cn(),1);var Y="v1.4.4",xn="FiloSottile/mkcert",dt=v.genericShellCommand("mkcert");async function Fs(t,e,r,o){let n=e[Ce.mkcertBinaryPath];if(n)return n;let a=S(t,r==="win32"?"mkcert.exe":"mkcert");if(await F(a))return a;let i=await(0,vn.default)("mkcert",{nothrow:!0});return i?(g(b`Found ${dt} at ${v.path(i)}`),i):(await Os(a,r,o),a)}async function Os(t,e,r){let o;switch(e){case"darwin":o=r==="arm64"?`mkcert-${Y}-darwin-arm64`:`mkcert-${Y}-darwin-amd64`;break;case"linux":o=r==="arm64"?`mkcert-${Y}-linux-arm64`:`mkcert-${Y}-linux-amd64`;break;case"win32":o=`mkcert-${Y}-windows-amd64.exe`;break;default:throw new X(`Unsupported platform: ${e}`)}await kr(xn,Y,o,t),g(b`${dt} saved to ${v.path(t)}`)}async function Ns(t){let e=S(t,"mkcert-LICENSE");if(await F(e))return;let r=`https://raw.githubusercontent.com/${xn}/refs/tags/${Y}/LICENSE`,o={headline:"Failed to download mkcert license.",body:["We tried to download the license for mkcert, but the request failed. You can ",{link:{url:r,label:"view the license here"}}]},n;try{if(n=await At(r),!n.ok)return o}catch{return o}let s=await n.text();await me(e,s)}async function En({appDirectory:t,forceInstall:e,env:r=process.env,platform:o=process.platform,arch:n=process.arch}){let s=S(".shopify","localhost-key.pem"),a=S(".shopify","localhost.pem"),i=S(t,s),c=S(t,a);if(await F(i)&&await F(c))return{keyContent:await I(i),certContent:await I(c),certPath:a};if(!(e??await jr()))throw new T(`Localhost certificate and key are required at ${a} and ${s}`);let l="",u;return await be([{title:"Finding or downloading mkcert binary",task:async()=>{let w=S(t,".shopify");l=await Fs(w,r,o,n),u=await Ns(w),g(b`${dt} found at: ${v.path(l)}`)}}]),u&&Ee(u),B(b`Generating self-signed certificate for localhost. You may be prompted for your password.`),await Ue(l,["-install","-key-file",i,"-cert-file",c,"localhost"]),B(b`${v.successIcon()} Certificate generated at ${a}\n`),await jt()&&(se({headline:"It looks like you're using WSL.",body:["Additional steps are required to configure certificate trust in Windows."],link:{label:"See Shopify CLI documentation",url:"https://shopify.dev/docs/apps/build/cli-for-apps/networking-options#localhost-based-development-with-windows-subsystem-for-linux-wsl"}}),B("\u{1F449} Press any key to continue"),await Bt(),B("")),{keyContent:await I(i),certContent:await I(c),certPath:ht(t,c)}}p();function bn(){let t=["Your app has extensions which need to be assigned",{command:"uid"},"identifiers."],e=["You must first map IDs to your existing extensions by running",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},", to finish the migration."],r={title:"Reference",body:{list:{items:[{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}}};throw new T(t,void 0,[e],[r])}async function Sn(t){let e=await qs(t);await Ws(e);let{processes:r,graphiqlUrl:o,previewUrl:n,devSessionStatusManager:s}=await pn(e);await Gs(e),await js({processes:r,previewUrl:n,graphiqlUrl:o,config:e,devSessionStatusManager:s})}async function qs(t){let{app:e,remoteApp:r,developerPlatformClient:o,store:n,specifications:s,tunnel:a}=t,i;if(a.mode==="auto"){let E=await $();i=await Gr(t.commandConfig,E,"cloudflare")}let c=await Yr(r,o,s,r.flags);r.configuration=c,Vr({app:e,remoteApp:r,selectedStore:n,cachedInfo:et(t.directory),organization:t.organization,tunnelMode:a.mode}),e.configuration.build?.dev_store_url&&(e.configuration.build={...e.configuration.build,dev_store_url:n.shopDomain},await(await Vt.read(e.configPath)).patch({build:{dev_store_url:n.shopDomain}})),!t.skipDependenciesInstallation&&!t.project.usesWorkspaces&&await Lr(t.project);let d=t.graphiqlPort??await $(ie.graphiql),l=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:t.graphiqlPort??ie.graphiql,actual:d}];a.mode==="use-localhost"&&l.push({for:"localhost",flagToRemedy:"--localhost-port",requested:a.requestedPort,actual:a.actualPort}),yn(l);let{webs:u,...h}=await Ks(e.directory,e.webs,d,a,i,r.configuration,t.installMkcert);e.webs=u;let w=e.configuration.build?.automatically_update_urls_on_dev,m=et(t.directory)?.previousAppId,f=r.apiKey,U=await Bs(u,t.update,h,e,w,r,f);return{storeFqdn:n.shopDomain,storeId:n.shopId,remoteApp:r,remoteAppUpdated:r.apiKey!==m,localApp:e,developerPlatformClient:o,commandOptions:t,network:h,partnerUrlsUpdated:U,graphiqlPort:d,graphiqlKey:t.graphiqlKey}}async function Ws(t){await Hs(t)}async function Hs(t){let{developerPlatformClient:e,remoteApp:r}=t;(await e.appExtensionRegistrations(r)).app.extensionRegistrations.filter(n=>n.type.toLowerCase()!=="webhook_subscription").every(n=>n.id)||bn()}async function Gs(t){Or({directory:t.commandOptions.directory,previousAppId:t.remoteApp.apiKey}),await zs({devOptions:t.commandOptions,tunnelUrl:t.network.proxyUrl,shouldUpdateURLs:t.partnerUrlsUpdated,storeFqdn:t.storeFqdn}),await Lt({config:t.commandOptions.commandConfig,exitMode:"ok"})}async function Bs(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:c}=z(t),d=!1;if((c??i)&&e){let l=qr(r.proxyUrl,t.map(({configuration:u})=>u.auth_callback_path).find(u=>u),o.configuration.app_proxy);d=await Hr({currentURLs:r.currentUrls,appDirectory:o.directory,cachedUpdateURLs:n,newApp:s.newApp,localApp:o,apiKey:a,newURLs:l}),d&&o.setDevApplicationURLs(l)}return d}async function Ks(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:c}=z(e);await Ys(e,r);let d=o.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:o.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:o.mode==="custom"?o.url:void 0,tunnelClient:n},[{frontendUrl:l,frontendPort:u,usingLocalhost:h},w,m]=await Promise.all([Nr(d),Ut()??i?.configuration.port??$(),Wr(s)]),f=h?`${l}:${u}`:l,U=c?.configuration.port;c&&(U??=c===i?w:await $(),c.configuration.port=U),U=U??await $();let E;if(o.mode==="use-localhost"){let{keyContent:R,certContent:x,certPath:_}=await En({appDirectory:t,forceInstall:a});E={key:R,cert:x,certPath:_,port:o.actualPort}}return{proxyUrl:f,proxyPort:u,frontendPort:U,backendPort:w,currentUrls:m,webs:e,reverseProxyCert:E}}async function js({processes:t,previewUrl:e,graphiqlUrl:r,config:o,devSessionStatusManager:n}){let s=new Et,a=t.map(d=>({prefix:d.prefix,action:async(u,h,w)=>{let m=d.function;return m({stdout:u,stderr:h,abortSignal:w},d.options)}})),i=o.developerPlatformClient,c={id:o.remoteApp.id,developerPlatformClient:i};return wn({processes:a,previewUrl:e,graphiqlUrl:r,app:c,abortController:s,shopFqdn:o.storeFqdn,devSessionStatusManager:n,appURL:o.localApp.devApplicationURLs?.applicationUrl,appName:o.remoteApp.title,organizationName:o.commandOptions.organization.businessName,configPath:o.localApp.configPath,localURL:o.network.proxyUrl})}async function zs(t){let e=await Pn(t.devOptions.commandConfig,t.tunnelUrl);await K.addPublicMetadata(()=>({cmd_dev_tunnel_type:e,cmd_dev_tunnel_custom_hash:e==="custom"?Ke(t.tunnelUrl):void 0,cmd_dev_urls_updated:t.shouldUpdateURLs,store_fqdn_hash:Ke(t.storeFqdn),store_domain:t.storeFqdn,cmd_app_dependency_installation_skipped:t.devOptions.skipDependenciesInstallation})),await K.addSensitiveMetadata(()=>({store_fqdn:t.storeFqdn,cmd_dev_tunnel_custom:e==="custom"?t.tunnelUrl:void 0}))}async function Ys(t,e){let r=t.map(n=>n.configuration.port).filter(n=>n),o=r.find((n,s)=>r.indexOf(n)!==s);if(o)throw new T(`Found port ${o} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...r.map(async n=>{if(!await Ve(n))throw new T(`Hard-coded port ${n} is not available, please choose a different one.`)}),(async()=>{if(!await Ve(e)){let s=`Port ${e} is not available for serving GraphiQL.`,a=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new T(s,a)}})()])}p();async function Un({useLocalhost:t,localhostPort:e,tunnelUrl:r}){if(r)return{mode:"custom",url:r};if(!t&&!e)return{mode:"auto"};let o=e??ie.localhost,n=await $(o);if(e&&n!==o){let s=`Port ${e} is not available.`,a=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new T(s,a)}return{mode:"use-localhost",requestedPort:o,actualPort:n}}var M=Q(_n(),1);var mt=class t extends Jr{static get requiresSyncAnalytics(){return!0}static summary="Run the app.";static descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally).";static description=this.descriptionWithoutMarkdown();static flags={...Qt,...Ir,store:M.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>ye(e)}),"skip-dependencies-installation":M.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":M.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"subscription-product-url":M.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":M.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":M.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":M.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",exclusive:["tunnel-url"]}),"install-mkcert":M.Flags.boolean({description:"Install and use mkcert to generate localhost certificates when --use-localhost is enabled without prompting.",env:"SHOPIFY_FLAG_INSTALL_MKCERT",dependsOn:["use-localhost"]}),"localhost-port":Re({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:M.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":Re({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),"store-password":M.Flags.string({description:"The password for storefronts with password protection.",env:"SHOPIFY_FLAG_STORE_PASSWORD"}),notify:M.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":Re({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":M.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})};static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:e}=await this.parse(t),r=await Un({useLocalhost:e["use-localhost"]??!1,tunnelUrl:e["tunnel-url"],localhostPort:e["localhost-port"]});await $t(()=>({cmd_app_dependency_installation_skipped:e["skip-dependencies-installation"],cmd_app_reset_used:e.reset,cmd_dev_tunnel_type:r.mode})),await Br(e.path);let o=await Qr({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config}),n=await Xr({appContextResult:o,storeFqdn:e.store,forceReselectStore:e.reset}),s={...o,store:n,directory:e.path,update:!e["no-update"],skipDependenciesInstallation:e["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:e["subscription-product-url"],checkoutCartUrl:e["checkout-cart-url"],theme:e.theme,themeExtensionPort:e["theme-app-extension-port"],storePassword:e["store-password"],notify:e.notify,graphiqlPort:e["graphiql-port"],graphiqlKey:e["graphiql-key"],installMkcert:e["install-mkcert"]??!1,tunnel:r};return await Sn(s),{app:o.app}}};export{ka as a,mt as b};
20
+ `),Promise.all(t.map(async n=>{await n.action(process.stdout,process.stderr,o.signal)}))}p();function yn(t){if(!t.length)return;let e=t.filter(n=>n.requested!==n.actual);if(e.length===0)return;if(e.length===1&&e[0]){let n=e[0];se({headline:[`A random port will be used for ${n.for} because ${n?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:n?.flagToRemedy}," flag."]});return}let r=Be(e.map(n=>n.for)).join(" "),o=Be(e.map(n=>({command:n.flagToRemedy})));se({headline:[`Random ports will be used for ${r} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...o,"flags."]})}p();async function Pn(t,e){return e?e.includes("localhost")?"localhost":(await _t(t)).plugins.find(o=>e?.includes(o))??"custom":void 0}p();var vn=Q(Cn(),1);var Y="v1.4.4",xn="FiloSottile/mkcert",dt=v.genericShellCommand("mkcert");async function Fs(t,e,r,o){let n=e[Ce.mkcertBinaryPath];if(n)return n;let a=S(t,r==="win32"?"mkcert.exe":"mkcert");if(await F(a))return a;let i=await(0,vn.default)("mkcert",{nothrow:!0});return i?(g(b`Found ${dt} at ${v.path(i)}`),i):(await Os(a,r,o),a)}async function Os(t,e,r){let o;switch(e){case"darwin":o=r==="arm64"?`mkcert-${Y}-darwin-arm64`:`mkcert-${Y}-darwin-amd64`;break;case"linux":o=r==="arm64"?`mkcert-${Y}-linux-arm64`:`mkcert-${Y}-linux-amd64`;break;case"win32":o=`mkcert-${Y}-windows-amd64.exe`;break;default:throw new X(`Unsupported platform: ${e}`)}await kr(xn,Y,o,t),g(b`${dt} saved to ${v.path(t)}`)}async function Ns(t){let e=S(t,"mkcert-LICENSE");if(await F(e))return;let r=`https://raw.githubusercontent.com/${xn}/refs/tags/${Y}/LICENSE`,o={headline:"Failed to download mkcert license.",body:["We tried to download the license for mkcert, but the request failed. You can ",{link:{url:r,label:"view the license here"}}]},n;try{if(n=await At(r),!n.ok)return o}catch{return o}let s=await n.text();await me(e,s)}async function En({appDirectory:t,forceInstall:e,env:r=process.env,platform:o=process.platform,arch:n=process.arch}){let s=S(".shopify","localhost-key.pem"),a=S(".shopify","localhost.pem"),i=S(t,s),c=S(t,a);if(await F(i)&&await F(c))return{keyContent:await I(i),certContent:await I(c),certPath:a};if(!(e??await jr()))throw new T(`Localhost certificate and key are required at ${a} and ${s}`);let l="",u;return await be([{title:"Finding or downloading mkcert binary",task:async()=>{let w=S(t,".shopify");l=await Fs(w,r,o,n),u=await Ns(w),g(b`${dt} found at: ${v.path(l)}`)}}]),u&&Ee(u),B(b`Generating self-signed certificate for localhost. You may be prompted for your password.`),await Ue(l,["-install","-key-file",i,"-cert-file",c,"localhost"]),B(b`${v.successIcon()} Certificate generated at ${a}\n`),await jt()&&(se({headline:"It looks like you're using WSL.",body:["Additional steps are required to configure certificate trust in Windows."],link:{label:"See Shopify CLI documentation",url:"https://shopify.dev/docs/apps/build/cli-for-apps/networking-options#localhost-based-development-with-windows-subsystem-for-linux-wsl"}}),B("\u{1F449} Press any key to continue"),await Bt(),B("")),{keyContent:await I(i),certContent:await I(c),certPath:ht(t,c)}}p();function bn(){let t=["Your app has extensions which need to be assigned",{command:"uid"},"identifiers."],e=["You must first map IDs to your existing extensions by running",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},", to finish the migration."],r={title:"Reference",body:{list:{items:[{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}}};throw new T(t,void 0,[e],[r])}async function Sn(t){let e=await qs(t);await Ws(e);let{processes:r,graphiqlUrl:o,previewUrl:n,devSessionStatusManager:s}=await pn(e);await Gs(e),await js({processes:r,previewUrl:n,graphiqlUrl:o,config:e,devSessionStatusManager:s})}async function qs(t){let{app:e,remoteApp:r,developerPlatformClient:o,store:n,specifications:s,tunnel:a}=t,i;if(a.mode==="auto"){let E=await $();i=await Gr(t.commandConfig,E,"cloudflare")}let c=await Yr(r,o,s,r.flags);r.configuration=c,Vr({app:e,remoteApp:r,selectedStore:n,cachedInfo:et(t.directory),organization:t.organization,tunnelMode:a.mode}),e.configuration.build?.dev_store_url&&(e.configuration.build={...e.configuration.build,dev_store_url:n.shopDomain},await(await Vt.read(e.configPath)).patch({build:{dev_store_url:n.shopDomain}})),!t.skipDependenciesInstallation&&!t.project.usesWorkspaces&&await Lr(t.project);let d=t.graphiqlPort??await $(ie.graphiql),l=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:t.graphiqlPort??ie.graphiql,actual:d}];a.mode==="use-localhost"&&l.push({for:"localhost",flagToRemedy:"--localhost-port",requested:a.requestedPort,actual:a.actualPort}),yn(l);let{webs:u,...h}=await Ks(e.directory,e.webs,d,a,i,r.configuration,t.installMkcert);e.webs=u;let w=e.configuration.build?.automatically_update_urls_on_dev,m=et(t.directory)?.previousAppId,f=r.apiKey,U=await Bs(u,t.update,h,e,w,r,f);return{storeFqdn:n.shopDomain,storeId:n.shopId,remoteApp:r,remoteAppUpdated:r.apiKey!==m,localApp:e,developerPlatformClient:o,commandOptions:t,network:h,partnerUrlsUpdated:U,graphiqlPort:d,graphiqlKey:t.graphiqlKey}}async function Ws(t){await Hs(t)}async function Hs(t){let{developerPlatformClient:e,remoteApp:r}=t;(await e.appExtensionRegistrations(r)).app.extensionRegistrations.filter(n=>n.type.toLowerCase()!=="webhook_subscription").every(n=>n.id)||bn()}async function Gs(t){Or({directory:t.commandOptions.directory,previousAppId:t.remoteApp.apiKey}),await zs({devOptions:t.commandOptions,tunnelUrl:t.network.proxyUrl,shouldUpdateURLs:t.partnerUrlsUpdated,storeFqdn:t.storeFqdn}),await Lt({config:t.commandOptions.commandConfig,exitMode:"ok"})}async function Bs(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:c}=z(t),d=!1;if((c??i)&&e){let l=qr(r.proxyUrl,t.map(({configuration:u})=>u.auth_callback_path).find(u=>u),o.configuration.app_proxy);d=await Hr({currentURLs:r.currentUrls,appDirectory:o.directory,cachedUpdateURLs:n,newApp:s.newApp,localApp:o,apiKey:a,newURLs:l}),d&&o.setDevApplicationURLs(l)}return d}async function Ks(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:c}=z(e);await Ys(e,r);let d=o.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:o.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:o.mode==="custom"?o.url:void 0,tunnelClient:n},[{frontendUrl:l,frontendPort:u,usingLocalhost:h},w,m]=await Promise.all([Nr(d),Ut()??i?.configuration.port??$(),Wr(s)]),f=h?`${l}:${u}`:l,U=c?.configuration.port;c&&(U??=c===i?w:await $(),c.configuration.port=U),U=U??await $();let E;if(o.mode==="use-localhost"){let{keyContent:R,certContent:x,certPath:_}=await En({appDirectory:t,forceInstall:a});E={key:R,cert:x,certPath:_,port:o.actualPort}}return{proxyUrl:f,proxyPort:u,frontendPort:U,backendPort:w,currentUrls:m,webs:e,reverseProxyCert:E}}async function js({processes:t,previewUrl:e,graphiqlUrl:r,config:o,devSessionStatusManager:n}){let s=new Et,a=t.map(d=>({prefix:d.prefix,action:async(u,h,w)=>{let m=d.function;return m({stdout:u,stderr:h,abortSignal:w},d.options)}})),i=o.developerPlatformClient,c={id:o.remoteApp.id,developerPlatformClient:i};return wn({processes:a,previewUrl:e,graphiqlUrl:r,app:c,abortController:s,shopFqdn:o.storeFqdn,devSessionStatusManager:n,appURL:o.localApp.devApplicationURLs?.applicationUrl,appName:o.remoteApp.title,organizationName:o.commandOptions.organization.businessName,configPath:o.localApp.configPath,localURL:o.network.proxyUrl})}async function zs(t){let e=await Pn(t.devOptions.commandConfig,t.tunnelUrl);await K.addPublicMetadata(()=>({cmd_dev_tunnel_type:e,cmd_dev_tunnel_custom_hash:e==="custom"?Ke(t.tunnelUrl):void 0,cmd_dev_urls_updated:t.shouldUpdateURLs,store_fqdn_hash:Ke(t.storeFqdn),store_domain:t.storeFqdn,cmd_app_dependency_installation_skipped:t.devOptions.skipDependenciesInstallation})),await K.addSensitiveMetadata(()=>({store_fqdn:t.storeFqdn,cmd_dev_tunnel_custom:e==="custom"?t.tunnelUrl:void 0}))}async function Ys(t,e){let r=t.map(n=>n.configuration.port).filter(n=>n),o=r.find((n,s)=>r.indexOf(n)!==s);if(o)throw new T(`Found port ${o} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...r.map(async n=>{if(!await Ve(n))throw new T(`Hard-coded port ${n} is not available, please choose a different one.`)}),(async()=>{if(!await Ve(e)){let s=`Port ${e} is not available for serving GraphiQL.`,a=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new T(s,a)}})()])}p();async function Un({useLocalhost:t,localhostPort:e,tunnelUrl:r}){if(r)return{mode:"custom",url:r};if(!t&&!e)return{mode:"auto"};let o=e??ie.localhost,n=await $(o);if(e&&n!==o){let s=`Port ${e} is not available.`,a=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new T(s,a)}return{mode:"use-localhost",requestedPort:o,actualPort:n}}var M=Q(_n(),1);var mt=class t extends Jr{static get requiresSyncAnalytics(){return!0}static summary="Run the app.";static descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally).";static description=this.descriptionWithoutMarkdown();static flags={...Qt,...Ir,store:M.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>ye(e)}),"skip-dependencies-installation":M.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":M.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"subscription-product-url":M.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":M.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":M.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":M.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",exclusive:["tunnel-url"]}),"install-mkcert":M.Flags.boolean({description:"Install and use mkcert to generate localhost certificates when --use-localhost is enabled without prompting.",env:"SHOPIFY_FLAG_INSTALL_MKCERT",dependsOn:["use-localhost"]}),"localhost-port":Re({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:M.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":Re({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),"store-password":M.Flags.string({description:"The password for storefronts with password protection.",env:"SHOPIFY_FLAG_STORE_PASSWORD"}),notify:M.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":Re({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":M.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})};static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:e}=await this.parse(t),r=await Un({useLocalhost:e["use-localhost"]??!1,tunnelUrl:e["tunnel-url"],localhostPort:e["localhost-port"]});await $t(()=>({cmd_app_dependency_installation_skipped:e["skip-dependencies-installation"],cmd_app_reset_used:e.reset,cmd_dev_tunnel_type:r.mode})),await Br(e.path);let o=await Qr({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config}),n=await Xr({appContextResult:o,storeFqdn:e.store,forceReselectStore:e.reset,storeCreationMode:"selection-option"}),s={...o,store:n,directory:e.path,update:!e["no-update"],skipDependenciesInstallation:e["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:e["subscription-product-url"],checkoutCartUrl:e["checkout-cart-url"],theme:e.theme,themeExtensionPort:e["theme-app-extension-port"],storePassword:e["store-password"],notify:e.notify,graphiqlPort:e["graphiql-port"],graphiqlKey:e["graphiql-key"],installMkcert:e["install-mkcert"],tunnel:r};return await Sn(s),{app:o.app}}};export{ka as a,mt as b};