hyperframes 0.8.201 → 0.8.203

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 (187) hide show
  1. package/dist/{add-33XNCMY4.js → add-HVWZZBVO.js} +15 -13
  2. package/dist/{animatedGifPrep-MI7Z4OYQ.js → animatedGifPrep-7SQD4XQY.js} +11 -9
  3. package/dist/api.js +23 -21
  4. package/dist/{asset-RMRQN24O.js → asset-H2D5ENJ6.js} +4 -3
  5. package/dist/{assetCataloger-KWTQNFUU.js → assetCataloger-PIRQXMHM.js} +11 -9
  6. package/dist/{audio-SQDZZS6X.js → audio-F6TTYCGR.js} +21 -19
  7. package/dist/{auth-PNC6K5ZD.js → auth-HK5IYSNR.js} +1 -1
  8. package/dist/{autoUpdate-MBZFLUF2.js → autoUpdate-DQMCXE6X.js} +2 -2
  9. package/dist/{backgroundChecks-ZMSPA6TK.js → backgroundChecks-Y466WV7Y.js} +3 -3
  10. package/dist/backgroundChecksWorker.js +3 -3
  11. package/dist/{batchRender-2MMOZRMW.js → batchRender-PGJELR2B.js} +8 -6
  12. package/dist/{beats-GDLNPR4A.js → beats-AD2IJGBZ.js} +13 -11
  13. package/dist/{benchmark-AUKB3XDF.js → benchmark-B564OTLO.js} +12 -10
  14. package/dist/{browser-C3AU5TST.js → browser-B7BELTLZ.js} +3 -3
  15. package/dist/{bundleWithLocalizedFonts-G3UT65XI.js → bundleWithLocalizedFonts-INYZKCJN.js} +4 -4
  16. package/dist/{capture-XGBPNGC5.js → capture-LKV2HS5Q.js} +2 -2
  17. package/dist/{capture-EKNPCFPF.js → capture-VMJVXQJ2.js} +14 -12
  18. package/dist/{captureCompositionFrame-4HHLPTDH.js → captureCompositionFrame-L2W6KSAL.js} +16 -15
  19. package/dist/{catalog-HLDNEJX3.js → catalog-5ETWOAL2.js} +15 -13
  20. package/dist/{catch-up-LRFV4LJO.js → catch-up-3RWU3BRJ.js} +4 -4
  21. package/dist/{check-XWHWGNYE.js → check-KD57MC5Z.js} +40 -39
  22. package/dist/{checkBrowser-KSOBXPJ3.js → checkBrowser-R72NYI4S.js} +36 -33
  23. package/dist/{chunk-ZDVJXWEG.js → chunk-2G6EI3WQ.js} +3 -3
  24. package/dist/chunk-2RY2LWAA.js +3466 -0
  25. package/dist/{chunk-TOT3CLUK.js → chunk-32SIPBON.js} +1 -1
  26. package/dist/{chunk-47NZWTJL.js → chunk-35KHQKEX.js} +5 -5
  27. package/dist/{chunk-B7CYKBXQ.js → chunk-3CISA3OS.js} +1 -1
  28. package/dist/{chunk-XONIZ5CH.js → chunk-3NUFUEAX.js} +235 -38
  29. package/dist/{chunk-GKXH4C2B.js → chunk-3YZ2ESXP.js} +5 -6
  30. package/dist/chunk-42DLVZNO.js +3983 -0
  31. package/dist/{chunk-B67P2WP3.js → chunk-4GV742H2.js} +2 -2
  32. package/dist/{chunk-WO3XZ6HC.js → chunk-5GFNMC2F.js} +2 -2
  33. package/dist/{chunk-CFUCHO4T.js → chunk-6MUI2H6P.js} +1 -1
  34. package/dist/{chunk-IFOZZYHK.js → chunk-7RQXBL4L.js} +8 -8
  35. package/dist/{chunk-JOI7TNCX.js → chunk-7SNVSO4A.js} +1 -1
  36. package/dist/{chunk-K2AUGELJ.js → chunk-AII6P2TC.js} +1 -1
  37. package/dist/{chunk-U2EK5MFR.js → chunk-B7MRZJOW.js} +9 -9
  38. package/dist/{chunk-6XGO7ZKS.js → chunk-BD3LJRJT.js} +1 -1
  39. package/dist/{chunk-RVKJDAYE.js → chunk-CAHZZOEC.js} +1 -1
  40. package/dist/{chunk-X72DJZCM.js → chunk-CFFPH6D3.js} +1 -1
  41. package/dist/{chunk-3J5KO4EJ.js → chunk-CTNWZASM.js} +5 -5
  42. package/dist/{chunk-YTBE4JCX.js → chunk-DO2OTFCJ.js} +2 -2
  43. package/dist/{chunk-GNX3BCQP.js → chunk-DZZ6VHPY.js} +1 -1
  44. package/dist/{chunk-SEAHCCQ4.js → chunk-E3LRVXM2.js} +3 -3
  45. package/dist/{chunk-FDWN4XAD.js → chunk-EUFBE5BW.js} +2 -2
  46. package/dist/{chunk-UIIGEPYY.js → chunk-FE72SB2F.js} +2 -2
  47. package/dist/chunk-FR7YBU3H.js +179 -0
  48. package/dist/{chunk-74UH2KGI.js → chunk-FRXPZCEP.js} +7 -3
  49. package/dist/{chunk-Q6SHXSZX.js → chunk-FTARAZAL.js} +1 -1
  50. package/dist/{chunk-GC6N2LH5.js → chunk-GOPGJXEQ.js} +7 -7
  51. package/dist/{chunk-ITJAHKYO.js → chunk-GOWNPWCJ.js} +1 -1
  52. package/dist/{chunk-SDYDNHEE.js → chunk-GWTIFRF5.js} +262 -3711
  53. package/dist/{chunk-I4DHHX7E.js → chunk-GX4CEJCX.js} +3 -3
  54. package/dist/{chunk-IHQBTZHE.js → chunk-H6NXL4VB.js} +1 -1
  55. package/dist/{chunk-53E45AKI.js → chunk-HAKKV3SY.js} +22 -13
  56. package/dist/{chunk-VCVUEK65.js → chunk-HO2N4UWV.js} +2 -2
  57. package/dist/{chunk-SIZYTGG4.js → chunk-HOQNNE3I.js} +1 -1
  58. package/dist/{chunk-YBJECXQJ.js → chunk-HYMW42OE.js} +3 -3
  59. package/dist/{chunk-CV32PRH3.js → chunk-IDASYE4U.js} +5 -3
  60. package/dist/{chunk-TYRDDIIH.js → chunk-IREQUN2P.js} +1 -1
  61. package/dist/{chunk-7EJ7OZGC.js → chunk-JEFIEL6S.js} +1 -1
  62. package/dist/{chunk-6UFEOVR5.js → chunk-JKUVH7BF.js} +1 -1
  63. package/dist/{chunk-QTWSMJ22.js → chunk-JVWPKIVV.js} +13 -13
  64. package/dist/{chunk-UKB62QOT.js → chunk-KBCV6BHL.js} +5 -5
  65. package/dist/{chunk-Q537KXWA.js → chunk-KWQWEY6F.js} +298 -92
  66. package/dist/chunk-ML7IPYOC.js +39 -0
  67. package/dist/{chunk-2FA53V5S.js → chunk-MPGJNUML.js} +2 -2
  68. package/dist/{chunk-UOSTDTBF.js → chunk-ND5ELD7A.js} +1 -1
  69. package/dist/{chunk-SZNCAINN.js → chunk-OKRH4JU3.js} +1 -1
  70. package/dist/{chunk-QYTGUWNF.js → chunk-OKZZWUZN.js} +1 -1
  71. package/dist/{chunk-6BNTGNGD.js → chunk-PBNWRWKA.js} +1 -1
  72. package/dist/{chunk-57GN6KWT.js → chunk-PLGGKTCB.js} +15 -1
  73. package/dist/{chunk-LVEXHBSH.js → chunk-Q6B7MFTU.js} +1 -1
  74. package/dist/{chunk-XG365L6T.js → chunk-R36C6H32.js} +1 -1
  75. package/dist/{chunk-SGKG7DNX.js → chunk-RUVO77RK.js} +3 -3
  76. package/dist/{chunk-DWULQYOQ.js → chunk-RWHMKGJA.js} +3 -3
  77. package/dist/{chunk-T33GLS6C.js → chunk-RZAPLMVM.js} +3 -3
  78. package/dist/{chunk-MSGWR7WP.js → chunk-SVVAUJPL.js} +33 -83
  79. package/dist/{chunk-ORMTNJBS.js → chunk-TMIX2WQL.js} +3 -3
  80. package/dist/{chunk-VF2VMKNI.js → chunk-TRDUMOUW.js} +3 -3
  81. package/dist/{chunk-A7YO6YSD.js → chunk-TT6HSBYK.js} +5 -5
  82. package/dist/{chunk-VKTUZP7U.js → chunk-TVC4EI2W.js} +1 -1
  83. package/dist/{chunk-QXBZ6VBL.js → chunk-TZKMAQOY.js} +2 -2
  84. package/dist/{chunk-AK2MOAJY.js → chunk-UNBGZQZ6.js} +21 -18
  85. package/dist/{chunk-IDRUJFT4.js → chunk-UVV2DKZR.js} +2 -2
  86. package/dist/{chunk-DS3XITZ5.js → chunk-VI7GBPF6.js} +2 -2
  87. package/dist/{chunk-L33EDCSR.js → chunk-VL5ES6ZM.js} +6 -6
  88. package/dist/{chunk-TAXGZAXM.js → chunk-VYFMJ2HM.js} +23 -20
  89. package/dist/{chunk-7WEGIXI3.js → chunk-WGZOPGHX.js} +1 -1
  90. package/dist/{chunk-IIH24PKY.js → chunk-X5PKA5KH.js} +2 -2
  91. package/dist/{chunk-CD5ZU6PN.js → chunk-YJKSLCKV.js} +5 -5
  92. package/dist/{chunk-XHVQIOOF.js → chunk-YOLS2E5P.js} +156 -24
  93. package/dist/{chunk-442JNXRM.js → chunk-ZBAF6L74.js} +1 -1
  94. package/dist/{clean-EUKURSX2.js → clean-7OBS6NMK.js} +20 -18
  95. package/dist/cli.js +53 -53
  96. package/dist/{cloud-LJDRNQ2N.js → cloud-JFL6IMUV.js} +4 -4
  97. package/dist/{cloudrun-AXVFD6KV.js → cloudrun-GHA4FXS3.js} +10 -8
  98. package/dist/{compare-T3LMATAF.js → compare-UFTPPNLD.js} +31 -30
  99. package/dist/{compiler-KH6DMHIJ.js → compiler-6LUGBYWD.js} +8 -6
  100. package/dist/{component-2FOHCMP2.js → component-4W3MT53Y.js} +5 -4
  101. package/dist/{compositions-REQ6ARAO.js → compositions-63M4AHPA.js} +18 -16
  102. package/dist/{delete-KEPP2QAZ.js → delete-XCSORSYR.js} +2 -2
  103. package/dist/{deploy-N756FEME.js → deploy-JUC2BVCE.js} +72 -20
  104. package/dist/{deterministicFonts-4FULD3AS.js → deterministicFonts-HQYCUUAL.js} +5 -3
  105. package/dist/{dist-TFHABY7N.js → dist-6JMYDD7F.js} +4 -3
  106. package/dist/{dist-5ULOGA6A.js → dist-SOMNYPEE.js} +12 -4
  107. package/dist/{doctor-2SJPC4WZ.js → doctor-LZ5KMUGS.js} +15 -13
  108. package/dist/{dom-37K6YOH4.js → dom-VFHEO7VM.js} +3 -2
  109. package/dist/{events-24ZE2PKB.js → events-DSJDLP3V.js} +3 -3
  110. package/dist/{events-U53QH4XZ.js → events-XN26WXN3.js} +2 -2
  111. package/dist/{feedback-QFMLDLUN.js → feedback-VZZT77OU.js} +11 -9
  112. package/dist/{ffmpeg-7XNWNO7M.js → ffmpeg-TU5BPXP6.js} +11 -9
  113. package/dist/{figma-B4JO44CV.js → figma-BYBMKBNS.js} +3 -3
  114. package/dist/fontLocalizeCli.js +15 -13
  115. package/dist/{get-7CFVCINR.js → get-JAKXQVNF.js} +2 -2
  116. package/dist/{gpuPolicy-MU7CFSAF.js → gpuPolicy-A6BRKFTK.js} +11 -9
  117. package/dist/{grade-compare-Q23U2HGS.js → grade-compare-6TLS63GE.js} +32 -31
  118. package/dist/{help-M67MEDV3.js → help-WMABNXSF.js} +1 -1
  119. package/dist/{history-I2PZXOFL.js → history-PNOTK4KM.js} +6 -6
  120. package/dist/hyperframe.manifest.json +1 -1
  121. package/dist/hyperframe.runtime.iife.js +65 -65
  122. package/dist/hyperframes-player.global.js +1 -1
  123. package/dist/{info-Z2MX54IE.js → info-457IZRNA.js} +14 -12
  124. package/dist/{init-SWH5KZO2.js → init-QNOPZRQJ.js} +32 -30
  125. package/dist/{inspect-WBBDB3YS.js → inspect-4PECXE65.js} +32 -31
  126. package/dist/inspection.js +2088 -0
  127. package/dist/{installer-DQIHGUBJ.js → installer-K6VCZN74.js} +8 -6
  128. package/dist/{keyframes-PSNEUS6P.js → keyframes-KBR4RHQO.js} +12 -11
  129. package/dist/{lambda-KSZFMQ3L.js → lambda-FSC3XJOQ.js} +26 -12
  130. package/dist/{layout-AAOI7W2M.js → layout-PFXAKL65.js} +32 -31
  131. package/dist/{lint-GGNVITIK.js → lint-MR7WHCBO.js} +10 -9
  132. package/dist/{lintProject-Q36Y3AHA.js → lintProject-4IVYXS5J.js} +4 -3
  133. package/dist/{list-OFPDL2AM.js → list-OCSE7GSX.js} +2 -2
  134. package/dist/live-LAHBXVK2.js +4165 -0
  135. package/dist/{login-MZAHGGP4.js → login-M4L3MHVL.js} +4 -4
  136. package/dist/{manager-ZOFTZTRY.js → manager-G6G2WQU3.js} +12 -10
  137. package/dist/{media-treatment-PF67GSUD.js → media-treatment-6ATFI5M2.js} +18 -16
  138. package/dist/{models-WR7CL54R.js → models-NPSWNLVS.js} +15 -13
  139. package/dist/{motionShot-ISLDWLIU.js → motionShot-HVPC2V7Q.js} +19 -18
  140. package/dist/{normalize-FASIPBUM.js → normalize-QJVXFMWO.js} +3 -2
  141. package/dist/{normalize-audio-D7AH5GFZ.js → normalize-audio-YEEAY2TB.js} +13 -11
  142. package/dist/{open-HPVBB2CX.js → open-6LSE4QDQ.js} +15 -13
  143. package/dist/{parakeetRunner-P6PE4WXG.js → parakeetRunner-HMDK2MEQ.js} +16 -14
  144. package/dist/{pipeline-XKBZG2CM.js → pipeline-GQV2DL2T.js} +12 -10
  145. package/dist/{play-QXHO47ZH.js → play-NORPMDGV.js} +23 -21
  146. package/dist/{preflight-KZCU66ES.js → preflight-SDPP63GU.js} +12 -10
  147. package/dist/{present-ERGC5PR4.js → present-BVPAEHE6.js} +19 -17
  148. package/dist/{preview-AGTOQIE7.js → preview-C762R2VY.js} +22 -20
  149. package/dist/{producer-4ONVM5A2.js → producer-XXFVYAW6.js} +1 -1
  150. package/dist/{projectConfig-7T4VY6RJ.js → projectConfig-72HEHSHM.js} +10 -8
  151. package/dist/{publication-J5TS5VR3.js → publication-QOK2NB7H.js} +6 -4
  152. package/dist/{publish-BSOVXRF4.js → publish-OVCPM2R4.js} +14 -12
  153. package/dist/{remove-background-645NVCGL.js → remove-background-BK7G24LO.js} +13 -11
  154. package/dist/{render-55TYPJ5U.js → render-3RV5ZZHB.js} +20 -16
  155. package/dist/{render-R3L44QAP.js → render-BA4DJGH2.js} +34 -32
  156. package/dist/{render-IAVH33YG.js → render-KCRWPUSH.js} +20 -18
  157. package/dist/{render-batch-JWWLQ7ZC.js → render-batch-EKMNALAK.js} +20 -16
  158. package/dist/renderSetupWorker.js +4 -3
  159. package/dist/{resolver-DBAFWC4F.js → resolver-ZQAEKX2N.js} +8 -6
  160. package/dist/{sherpa-UPWG6TKY.js → sherpa-UPEEZCVJ.js} +15 -13
  161. package/dist/skills/hyperframes-cli/references/lambda.md +1 -0
  162. package/dist/{skills-ILH52UL4.js → skills-EBCABDEA.js} +5 -5
  163. package/dist/{skillsUpdateCheck-ZHFDGMEL.js → skillsUpdateCheck-2TBQ3R7X.js} +3 -3
  164. package/dist/{snapshot-WMVHIQVQ.js → snapshot-KRDQ6UFY.js} +37 -36
  165. package/dist/{src-HPLELQRK.js → src-FMPMLWOE.js} +10 -8
  166. package/dist/{src-46QTOHZE.js → src-HODRARUH.js} +16 -14
  167. package/dist/{staticProjectServer-FHP2YQFV.js → staticProjectServer-NBWPYBIH.js} +20 -19
  168. package/dist/studio/assets/{hyperframes-player-BNeO6YSP.js → hyperframes-player-C3pgGOtp.js} +1 -1
  169. package/dist/studio/assets/{index-DiNYtcMK.js → index-5EFQxr70.js} +1 -1
  170. package/dist/studio/assets/{index-CZWE0FI8.js → index-BbcMyD3j.js} +120 -120
  171. package/dist/studio/index.html +1 -1
  172. package/dist/{studio-api-5YHQ4Y2D.js → studio-api-BOV2DTPC.js} +13 -11
  173. package/dist/{studioServer-P6IC76SV.js → studioServer-TSKSIQC3.js} +51 -50
  174. package/dist/{telemetry-WZ7OGFWQ.js → telemetry-RLKGEBGR.js} +3 -3
  175. package/dist/{timeline-U6S7BGMI.js → timeline-ADFTKSNX.js} +24 -22
  176. package/dist/{tokens-FPUYNZSV.js → tokens-2NKS4KAO.js} +4 -3
  177. package/dist/{transcribe-DZHTKXI5.js → transcribe-63XQBLF3.js} +14 -12
  178. package/dist/{transcribe-DJX4E2PE.js → transcribe-AHNMYPY4.js} +21 -19
  179. package/dist/{updateCheck-2LHWRDE7.js → updateCheck-XDYXIVKF.js} +2 -2
  180. package/dist/{upgrade-WAQHCAUS.js → upgrade-GK2RSMPV.js} +2 -2
  181. package/dist/{urlDownloader-HZQPXQET.js → urlDownloader-X2B7NQSQ.js} +10 -8
  182. package/dist/{validate-D6XJ7OSS.js → validate-UN4RB6KN.js} +26 -25
  183. package/dist/{video-A4CQ4WDL.js → video-QRWQLU5O.js} +11 -9
  184. package/dist/warmCheck.js +40 -39
  185. package/package.json +2 -2
  186. package/dist/chunk-JXLHLR26.js +0 -40
  187. package/dist/chunk-ZKHXN2BV.js +0 -3983
@@ -0,0 +1,4165 @@
1
+ import { createRequire as __hf_createRequire } from "node:module";
2
+ import { fileURLToPath as __hf_fileURLToPath } from "node:url";
3
+ import { dirname as __hf_dirname } from "node:path";
4
+ var require = __hf_createRequire(import.meta.url);
5
+ var __filename = __hf_fileURLToPath(import.meta.url);
6
+ var __dirname = __hf_dirname(__filename);
7
+ import {
8
+ decode
9
+ } from "./chunk-FR7YBU3H.js";
10
+ import {
11
+ Parser
12
+ } from "./chunk-2RY2LWAA.js";
13
+ import {
14
+ __commonJS,
15
+ __toESM
16
+ } from "./chunk-M2WBOQ2Q.js";
17
+
18
+ // ../../node_modules/.bun/estraverse@5.3.0/node_modules/estraverse/estraverse.js
19
+ var require_estraverse = __commonJS({
20
+ "../../node_modules/.bun/estraverse@5.3.0/node_modules/estraverse/estraverse.js"(exports) {
21
+ "use strict";
22
+ (function clone(exports2) {
23
+ "use strict";
24
+ var Syntax4, VisitorOption, VisitorKeys, BREAK, SKIP, REMOVE;
25
+ function deepCopy(obj) {
26
+ var ret = {}, key, val;
27
+ for (key in obj) {
28
+ if (obj.hasOwnProperty(key)) {
29
+ val = obj[key];
30
+ if (typeof val === "object" && val !== null) {
31
+ ret[key] = deepCopy(val);
32
+ } else {
33
+ ret[key] = val;
34
+ }
35
+ }
36
+ }
37
+ return ret;
38
+ }
39
+ function upperBound2(array, func) {
40
+ var diff, len, i, current;
41
+ len = array.length;
42
+ i = 0;
43
+ while (len) {
44
+ diff = len >>> 1;
45
+ current = i + diff;
46
+ if (func(array[current])) {
47
+ len = diff;
48
+ } else {
49
+ i = current + 1;
50
+ len -= diff + 1;
51
+ }
52
+ }
53
+ return i;
54
+ }
55
+ Syntax4 = {
56
+ AssignmentExpression: "AssignmentExpression",
57
+ AssignmentPattern: "AssignmentPattern",
58
+ ArrayExpression: "ArrayExpression",
59
+ ArrayPattern: "ArrayPattern",
60
+ ArrowFunctionExpression: "ArrowFunctionExpression",
61
+ AwaitExpression: "AwaitExpression",
62
+ // CAUTION: It's deferred to ES7.
63
+ BlockStatement: "BlockStatement",
64
+ BinaryExpression: "BinaryExpression",
65
+ BreakStatement: "BreakStatement",
66
+ CallExpression: "CallExpression",
67
+ CatchClause: "CatchClause",
68
+ ChainExpression: "ChainExpression",
69
+ ClassBody: "ClassBody",
70
+ ClassDeclaration: "ClassDeclaration",
71
+ ClassExpression: "ClassExpression",
72
+ ComprehensionBlock: "ComprehensionBlock",
73
+ // CAUTION: It's deferred to ES7.
74
+ ComprehensionExpression: "ComprehensionExpression",
75
+ // CAUTION: It's deferred to ES7.
76
+ ConditionalExpression: "ConditionalExpression",
77
+ ContinueStatement: "ContinueStatement",
78
+ DebuggerStatement: "DebuggerStatement",
79
+ DirectiveStatement: "DirectiveStatement",
80
+ DoWhileStatement: "DoWhileStatement",
81
+ EmptyStatement: "EmptyStatement",
82
+ ExportAllDeclaration: "ExportAllDeclaration",
83
+ ExportDefaultDeclaration: "ExportDefaultDeclaration",
84
+ ExportNamedDeclaration: "ExportNamedDeclaration",
85
+ ExportSpecifier: "ExportSpecifier",
86
+ ExpressionStatement: "ExpressionStatement",
87
+ ForStatement: "ForStatement",
88
+ ForInStatement: "ForInStatement",
89
+ ForOfStatement: "ForOfStatement",
90
+ FunctionDeclaration: "FunctionDeclaration",
91
+ FunctionExpression: "FunctionExpression",
92
+ GeneratorExpression: "GeneratorExpression",
93
+ // CAUTION: It's deferred to ES7.
94
+ Identifier: "Identifier",
95
+ IfStatement: "IfStatement",
96
+ ImportExpression: "ImportExpression",
97
+ ImportDeclaration: "ImportDeclaration",
98
+ ImportDefaultSpecifier: "ImportDefaultSpecifier",
99
+ ImportNamespaceSpecifier: "ImportNamespaceSpecifier",
100
+ ImportSpecifier: "ImportSpecifier",
101
+ Literal: "Literal",
102
+ LabeledStatement: "LabeledStatement",
103
+ LogicalExpression: "LogicalExpression",
104
+ MemberExpression: "MemberExpression",
105
+ MetaProperty: "MetaProperty",
106
+ MethodDefinition: "MethodDefinition",
107
+ ModuleSpecifier: "ModuleSpecifier",
108
+ NewExpression: "NewExpression",
109
+ ObjectExpression: "ObjectExpression",
110
+ ObjectPattern: "ObjectPattern",
111
+ PrivateIdentifier: "PrivateIdentifier",
112
+ Program: "Program",
113
+ Property: "Property",
114
+ PropertyDefinition: "PropertyDefinition",
115
+ RestElement: "RestElement",
116
+ ReturnStatement: "ReturnStatement",
117
+ SequenceExpression: "SequenceExpression",
118
+ SpreadElement: "SpreadElement",
119
+ Super: "Super",
120
+ SwitchStatement: "SwitchStatement",
121
+ SwitchCase: "SwitchCase",
122
+ TaggedTemplateExpression: "TaggedTemplateExpression",
123
+ TemplateElement: "TemplateElement",
124
+ TemplateLiteral: "TemplateLiteral",
125
+ ThisExpression: "ThisExpression",
126
+ ThrowStatement: "ThrowStatement",
127
+ TryStatement: "TryStatement",
128
+ UnaryExpression: "UnaryExpression",
129
+ UpdateExpression: "UpdateExpression",
130
+ VariableDeclaration: "VariableDeclaration",
131
+ VariableDeclarator: "VariableDeclarator",
132
+ WhileStatement: "WhileStatement",
133
+ WithStatement: "WithStatement",
134
+ YieldExpression: "YieldExpression"
135
+ };
136
+ VisitorKeys = {
137
+ AssignmentExpression: ["left", "right"],
138
+ AssignmentPattern: ["left", "right"],
139
+ ArrayExpression: ["elements"],
140
+ ArrayPattern: ["elements"],
141
+ ArrowFunctionExpression: ["params", "body"],
142
+ AwaitExpression: ["argument"],
143
+ // CAUTION: It's deferred to ES7.
144
+ BlockStatement: ["body"],
145
+ BinaryExpression: ["left", "right"],
146
+ BreakStatement: ["label"],
147
+ CallExpression: ["callee", "arguments"],
148
+ CatchClause: ["param", "body"],
149
+ ChainExpression: ["expression"],
150
+ ClassBody: ["body"],
151
+ ClassDeclaration: ["id", "superClass", "body"],
152
+ ClassExpression: ["id", "superClass", "body"],
153
+ ComprehensionBlock: ["left", "right"],
154
+ // CAUTION: It's deferred to ES7.
155
+ ComprehensionExpression: ["blocks", "filter", "body"],
156
+ // CAUTION: It's deferred to ES7.
157
+ ConditionalExpression: ["test", "consequent", "alternate"],
158
+ ContinueStatement: ["label"],
159
+ DebuggerStatement: [],
160
+ DirectiveStatement: [],
161
+ DoWhileStatement: ["body", "test"],
162
+ EmptyStatement: [],
163
+ ExportAllDeclaration: ["source"],
164
+ ExportDefaultDeclaration: ["declaration"],
165
+ ExportNamedDeclaration: ["declaration", "specifiers", "source"],
166
+ ExportSpecifier: ["exported", "local"],
167
+ ExpressionStatement: ["expression"],
168
+ ForStatement: ["init", "test", "update", "body"],
169
+ ForInStatement: ["left", "right", "body"],
170
+ ForOfStatement: ["left", "right", "body"],
171
+ FunctionDeclaration: ["id", "params", "body"],
172
+ FunctionExpression: ["id", "params", "body"],
173
+ GeneratorExpression: ["blocks", "filter", "body"],
174
+ // CAUTION: It's deferred to ES7.
175
+ Identifier: [],
176
+ IfStatement: ["test", "consequent", "alternate"],
177
+ ImportExpression: ["source"],
178
+ ImportDeclaration: ["specifiers", "source"],
179
+ ImportDefaultSpecifier: ["local"],
180
+ ImportNamespaceSpecifier: ["local"],
181
+ ImportSpecifier: ["imported", "local"],
182
+ Literal: [],
183
+ LabeledStatement: ["label", "body"],
184
+ LogicalExpression: ["left", "right"],
185
+ MemberExpression: ["object", "property"],
186
+ MetaProperty: ["meta", "property"],
187
+ MethodDefinition: ["key", "value"],
188
+ ModuleSpecifier: [],
189
+ NewExpression: ["callee", "arguments"],
190
+ ObjectExpression: ["properties"],
191
+ ObjectPattern: ["properties"],
192
+ PrivateIdentifier: [],
193
+ Program: ["body"],
194
+ Property: ["key", "value"],
195
+ PropertyDefinition: ["key", "value"],
196
+ RestElement: ["argument"],
197
+ ReturnStatement: ["argument"],
198
+ SequenceExpression: ["expressions"],
199
+ SpreadElement: ["argument"],
200
+ Super: [],
201
+ SwitchStatement: ["discriminant", "cases"],
202
+ SwitchCase: ["test", "consequent"],
203
+ TaggedTemplateExpression: ["tag", "quasi"],
204
+ TemplateElement: [],
205
+ TemplateLiteral: ["quasis", "expressions"],
206
+ ThisExpression: [],
207
+ ThrowStatement: ["argument"],
208
+ TryStatement: ["block", "handler", "finalizer"],
209
+ UnaryExpression: ["argument"],
210
+ UpdateExpression: ["argument"],
211
+ VariableDeclaration: ["declarations"],
212
+ VariableDeclarator: ["id", "init"],
213
+ WhileStatement: ["test", "body"],
214
+ WithStatement: ["object", "body"],
215
+ YieldExpression: ["argument"]
216
+ };
217
+ BREAK = {};
218
+ SKIP = {};
219
+ REMOVE = {};
220
+ VisitorOption = {
221
+ Break: BREAK,
222
+ Skip: SKIP,
223
+ Remove: REMOVE
224
+ };
225
+ function Reference2(parent, key) {
226
+ this.parent = parent;
227
+ this.key = key;
228
+ }
229
+ Reference2.prototype.replace = function replace2(node) {
230
+ this.parent[this.key] = node;
231
+ };
232
+ Reference2.prototype.remove = function remove() {
233
+ if (Array.isArray(this.parent)) {
234
+ this.parent.splice(this.key, 1);
235
+ return true;
236
+ } else {
237
+ this.replace(null);
238
+ return false;
239
+ }
240
+ };
241
+ function Element(node, path, wrap, ref) {
242
+ this.node = node;
243
+ this.path = path;
244
+ this.wrap = wrap;
245
+ this.ref = ref;
246
+ }
247
+ function Controller() {
248
+ }
249
+ Controller.prototype.path = function path() {
250
+ var i, iz, j, jz, result, element;
251
+ function addToPath(result2, path2) {
252
+ if (Array.isArray(path2)) {
253
+ for (j = 0, jz = path2.length; j < jz; ++j) {
254
+ result2.push(path2[j]);
255
+ }
256
+ } else {
257
+ result2.push(path2);
258
+ }
259
+ }
260
+ if (!this.__current.path) {
261
+ return null;
262
+ }
263
+ result = [];
264
+ for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
265
+ element = this.__leavelist[i];
266
+ addToPath(result, element.path);
267
+ }
268
+ addToPath(result, this.__current.path);
269
+ return result;
270
+ };
271
+ Controller.prototype.type = function() {
272
+ var node = this.current();
273
+ return node.type || this.__current.wrap;
274
+ };
275
+ Controller.prototype.parents = function parents() {
276
+ var i, iz, result;
277
+ result = [];
278
+ for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
279
+ result.push(this.__leavelist[i].node);
280
+ }
281
+ return result;
282
+ };
283
+ Controller.prototype.current = function current() {
284
+ return this.__current.node;
285
+ };
286
+ Controller.prototype.__execute = function __execute(callback, element) {
287
+ var previous, result;
288
+ result = void 0;
289
+ previous = this.__current;
290
+ this.__current = element;
291
+ this.__state = null;
292
+ if (callback) {
293
+ result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
294
+ }
295
+ this.__current = previous;
296
+ return result;
297
+ };
298
+ Controller.prototype.notify = function notify(flag) {
299
+ this.__state = flag;
300
+ };
301
+ Controller.prototype.skip = function() {
302
+ this.notify(SKIP);
303
+ };
304
+ Controller.prototype["break"] = function() {
305
+ this.notify(BREAK);
306
+ };
307
+ Controller.prototype.remove = function() {
308
+ this.notify(REMOVE);
309
+ };
310
+ Controller.prototype.__initialize = function(root, visitor) {
311
+ this.visitor = visitor;
312
+ this.root = root;
313
+ this.__worklist = [];
314
+ this.__leavelist = [];
315
+ this.__current = null;
316
+ this.__state = null;
317
+ this.__fallback = null;
318
+ if (visitor.fallback === "iteration") {
319
+ this.__fallback = Object.keys;
320
+ } else if (typeof visitor.fallback === "function") {
321
+ this.__fallback = visitor.fallback;
322
+ }
323
+ this.__keys = VisitorKeys;
324
+ if (visitor.keys) {
325
+ this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
326
+ }
327
+ };
328
+ function isNode(node) {
329
+ if (node == null) {
330
+ return false;
331
+ }
332
+ return typeof node === "object" && typeof node.type === "string";
333
+ }
334
+ function isProperty(nodeType, key) {
335
+ return (nodeType === Syntax4.ObjectExpression || nodeType === Syntax4.ObjectPattern) && "properties" === key;
336
+ }
337
+ function candidateExistsInLeaveList(leavelist, candidate) {
338
+ for (var i = leavelist.length - 1; i >= 0; --i) {
339
+ if (leavelist[i].node === candidate) {
340
+ return true;
341
+ }
342
+ }
343
+ return false;
344
+ }
345
+ Controller.prototype.traverse = function traverse2(root, visitor) {
346
+ var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;
347
+ this.__initialize(root, visitor);
348
+ sentinel = {};
349
+ worklist = this.__worklist;
350
+ leavelist = this.__leavelist;
351
+ worklist.push(new Element(root, null, null, null));
352
+ leavelist.push(new Element(null, null, null, null));
353
+ while (worklist.length) {
354
+ element = worklist.pop();
355
+ if (element === sentinel) {
356
+ element = leavelist.pop();
357
+ ret = this.__execute(visitor.leave, element);
358
+ if (this.__state === BREAK || ret === BREAK) {
359
+ return;
360
+ }
361
+ continue;
362
+ }
363
+ if (element.node) {
364
+ ret = this.__execute(visitor.enter, element);
365
+ if (this.__state === BREAK || ret === BREAK) {
366
+ return;
367
+ }
368
+ worklist.push(sentinel);
369
+ leavelist.push(element);
370
+ if (this.__state === SKIP || ret === SKIP) {
371
+ continue;
372
+ }
373
+ node = element.node;
374
+ nodeType = node.type || element.wrap;
375
+ candidates = this.__keys[nodeType];
376
+ if (!candidates) {
377
+ if (this.__fallback) {
378
+ candidates = this.__fallback(node);
379
+ } else {
380
+ throw new Error("Unknown node type " + nodeType + ".");
381
+ }
382
+ }
383
+ current = candidates.length;
384
+ while ((current -= 1) >= 0) {
385
+ key = candidates[current];
386
+ candidate = node[key];
387
+ if (!candidate) {
388
+ continue;
389
+ }
390
+ if (Array.isArray(candidate)) {
391
+ current2 = candidate.length;
392
+ while ((current2 -= 1) >= 0) {
393
+ if (!candidate[current2]) {
394
+ continue;
395
+ }
396
+ if (candidateExistsInLeaveList(leavelist, candidate[current2])) {
397
+ continue;
398
+ }
399
+ if (isProperty(nodeType, candidates[current])) {
400
+ element = new Element(candidate[current2], [key, current2], "Property", null);
401
+ } else if (isNode(candidate[current2])) {
402
+ element = new Element(candidate[current2], [key, current2], null, null);
403
+ } else {
404
+ continue;
405
+ }
406
+ worklist.push(element);
407
+ }
408
+ } else if (isNode(candidate)) {
409
+ if (candidateExistsInLeaveList(leavelist, candidate)) {
410
+ continue;
411
+ }
412
+ worklist.push(new Element(candidate, key, null, null));
413
+ }
414
+ }
415
+ }
416
+ }
417
+ };
418
+ Controller.prototype.replace = function replace2(root, visitor) {
419
+ var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;
420
+ function removeElem(element2) {
421
+ var i, key2, nextElem, parent;
422
+ if (element2.ref.remove()) {
423
+ key2 = element2.ref.key;
424
+ parent = element2.ref.parent;
425
+ i = worklist.length;
426
+ while (i--) {
427
+ nextElem = worklist[i];
428
+ if (nextElem.ref && nextElem.ref.parent === parent) {
429
+ if (nextElem.ref.key < key2) {
430
+ break;
431
+ }
432
+ --nextElem.ref.key;
433
+ }
434
+ }
435
+ }
436
+ }
437
+ this.__initialize(root, visitor);
438
+ sentinel = {};
439
+ worklist = this.__worklist;
440
+ leavelist = this.__leavelist;
441
+ outer = {
442
+ root
443
+ };
444
+ element = new Element(root, null, null, new Reference2(outer, "root"));
445
+ worklist.push(element);
446
+ leavelist.push(element);
447
+ while (worklist.length) {
448
+ element = worklist.pop();
449
+ if (element === sentinel) {
450
+ element = leavelist.pop();
451
+ target = this.__execute(visitor.leave, element);
452
+ if (target !== void 0 && target !== BREAK && target !== SKIP && target !== REMOVE) {
453
+ element.ref.replace(target);
454
+ }
455
+ if (this.__state === REMOVE || target === REMOVE) {
456
+ removeElem(element);
457
+ }
458
+ if (this.__state === BREAK || target === BREAK) {
459
+ return outer.root;
460
+ }
461
+ continue;
462
+ }
463
+ target = this.__execute(visitor.enter, element);
464
+ if (target !== void 0 && target !== BREAK && target !== SKIP && target !== REMOVE) {
465
+ element.ref.replace(target);
466
+ element.node = target;
467
+ }
468
+ if (this.__state === REMOVE || target === REMOVE) {
469
+ removeElem(element);
470
+ element.node = null;
471
+ }
472
+ if (this.__state === BREAK || target === BREAK) {
473
+ return outer.root;
474
+ }
475
+ node = element.node;
476
+ if (!node) {
477
+ continue;
478
+ }
479
+ worklist.push(sentinel);
480
+ leavelist.push(element);
481
+ if (this.__state === SKIP || target === SKIP) {
482
+ continue;
483
+ }
484
+ nodeType = node.type || element.wrap;
485
+ candidates = this.__keys[nodeType];
486
+ if (!candidates) {
487
+ if (this.__fallback) {
488
+ candidates = this.__fallback(node);
489
+ } else {
490
+ throw new Error("Unknown node type " + nodeType + ".");
491
+ }
492
+ }
493
+ current = candidates.length;
494
+ while ((current -= 1) >= 0) {
495
+ key = candidates[current];
496
+ candidate = node[key];
497
+ if (!candidate) {
498
+ continue;
499
+ }
500
+ if (Array.isArray(candidate)) {
501
+ current2 = candidate.length;
502
+ while ((current2 -= 1) >= 0) {
503
+ if (!candidate[current2]) {
504
+ continue;
505
+ }
506
+ if (isProperty(nodeType, candidates[current])) {
507
+ element = new Element(candidate[current2], [key, current2], "Property", new Reference2(candidate, current2));
508
+ } else if (isNode(candidate[current2])) {
509
+ element = new Element(candidate[current2], [key, current2], null, new Reference2(candidate, current2));
510
+ } else {
511
+ continue;
512
+ }
513
+ worklist.push(element);
514
+ }
515
+ } else if (isNode(candidate)) {
516
+ worklist.push(new Element(candidate, key, null, new Reference2(node, key)));
517
+ }
518
+ }
519
+ }
520
+ return outer.root;
521
+ };
522
+ function traverse(root, visitor) {
523
+ var controller = new Controller();
524
+ return controller.traverse(root, visitor);
525
+ }
526
+ function replace(root, visitor) {
527
+ var controller = new Controller();
528
+ return controller.replace(root, visitor);
529
+ }
530
+ function extendCommentRange(comment, tokens) {
531
+ var target;
532
+ target = upperBound2(tokens, function search(token) {
533
+ return token.range[0] > comment.range[0];
534
+ });
535
+ comment.extendedRange = [comment.range[0], comment.range[1]];
536
+ if (target !== tokens.length) {
537
+ comment.extendedRange[1] = tokens[target].range[0];
538
+ }
539
+ target -= 1;
540
+ if (target >= 0) {
541
+ comment.extendedRange[0] = tokens[target].range[1];
542
+ }
543
+ return comment;
544
+ }
545
+ function attachComments(tree, providedComments, tokens) {
546
+ var comments = [], comment, len, i, cursor;
547
+ if (!tree.range) {
548
+ throw new Error("attachComments needs range information");
549
+ }
550
+ if (!tokens.length) {
551
+ if (providedComments.length) {
552
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
553
+ comment = deepCopy(providedComments[i]);
554
+ comment.extendedRange = [0, tree.range[0]];
555
+ comments.push(comment);
556
+ }
557
+ tree.leadingComments = comments;
558
+ }
559
+ return tree;
560
+ }
561
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
562
+ comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
563
+ }
564
+ cursor = 0;
565
+ traverse(tree, {
566
+ enter: function(node) {
567
+ var comment2;
568
+ while (cursor < comments.length) {
569
+ comment2 = comments[cursor];
570
+ if (comment2.extendedRange[1] > node.range[0]) {
571
+ break;
572
+ }
573
+ if (comment2.extendedRange[1] === node.range[0]) {
574
+ if (!node.leadingComments) {
575
+ node.leadingComments = [];
576
+ }
577
+ node.leadingComments.push(comment2);
578
+ comments.splice(cursor, 1);
579
+ } else {
580
+ cursor += 1;
581
+ }
582
+ }
583
+ if (cursor === comments.length) {
584
+ return VisitorOption.Break;
585
+ }
586
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
587
+ return VisitorOption.Skip;
588
+ }
589
+ }
590
+ });
591
+ cursor = 0;
592
+ traverse(tree, {
593
+ leave: function(node) {
594
+ var comment2;
595
+ while (cursor < comments.length) {
596
+ comment2 = comments[cursor];
597
+ if (node.range[1] < comment2.extendedRange[0]) {
598
+ break;
599
+ }
600
+ if (node.range[1] === comment2.extendedRange[0]) {
601
+ if (!node.trailingComments) {
602
+ node.trailingComments = [];
603
+ }
604
+ node.trailingComments.push(comment2);
605
+ comments.splice(cursor, 1);
606
+ } else {
607
+ cursor += 1;
608
+ }
609
+ }
610
+ if (cursor === comments.length) {
611
+ return VisitorOption.Break;
612
+ }
613
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
614
+ return VisitorOption.Skip;
615
+ }
616
+ }
617
+ });
618
+ return tree;
619
+ }
620
+ exports2.Syntax = Syntax4;
621
+ exports2.traverse = traverse;
622
+ exports2.replace = replace;
623
+ exports2.attachComments = attachComments;
624
+ exports2.VisitorKeys = VisitorKeys;
625
+ exports2.VisitorOption = VisitorOption;
626
+ exports2.Controller = Controller;
627
+ exports2.cloneEnvironment = function() {
628
+ return clone({});
629
+ };
630
+ return exports2;
631
+ })(exports);
632
+ }
633
+ });
634
+
635
+ // ../../node_modules/.bun/esrecurse@4.3.0/node_modules/esrecurse/package.json
636
+ var require_package = __commonJS({
637
+ "../../node_modules/.bun/esrecurse@4.3.0/node_modules/esrecurse/package.json"(exports, module) {
638
+ module.exports = {
639
+ name: "esrecurse",
640
+ description: "ECMAScript AST recursive visitor",
641
+ homepage: "https://github.com/estools/esrecurse",
642
+ main: "esrecurse.js",
643
+ version: "4.3.0",
644
+ engines: {
645
+ node: ">=4.0"
646
+ },
647
+ maintainers: [
648
+ {
649
+ name: "Yusuke Suzuki",
650
+ email: "utatane.tea@gmail.com",
651
+ web: "https://github.com/Constellation"
652
+ }
653
+ ],
654
+ repository: {
655
+ type: "git",
656
+ url: "https://github.com/estools/esrecurse.git"
657
+ },
658
+ dependencies: {
659
+ estraverse: "^5.2.0"
660
+ },
661
+ devDependencies: {
662
+ "babel-cli": "^6.24.1",
663
+ "babel-eslint": "^7.2.3",
664
+ "babel-preset-es2015": "^6.24.1",
665
+ "babel-register": "^6.24.1",
666
+ chai: "^4.0.2",
667
+ esprima: "^4.0.0",
668
+ gulp: "^3.9.0",
669
+ "gulp-bump": "^2.7.0",
670
+ "gulp-eslint": "^4.0.0",
671
+ "gulp-filter": "^5.0.0",
672
+ "gulp-git": "^2.4.1",
673
+ "gulp-mocha": "^4.3.1",
674
+ "gulp-tag-version": "^1.2.1",
675
+ jsdoc: "^3.3.0-alpha10",
676
+ minimist: "^1.1.0"
677
+ },
678
+ license: "BSD-2-Clause",
679
+ scripts: {
680
+ test: "gulp travis",
681
+ "unit-test": "gulp test",
682
+ lint: "gulp lint"
683
+ },
684
+ babel: {
685
+ presets: [
686
+ "es2015"
687
+ ]
688
+ }
689
+ };
690
+ }
691
+ });
692
+
693
+ // ../../node_modules/.bun/esrecurse@4.3.0/node_modules/esrecurse/esrecurse.js
694
+ var require_esrecurse = __commonJS({
695
+ "../../node_modules/.bun/esrecurse@4.3.0/node_modules/esrecurse/esrecurse.js"(exports) {
696
+ "use strict";
697
+ (function() {
698
+ "use strict";
699
+ var estraverse4 = require_estraverse();
700
+ function isNode(node) {
701
+ if (node == null) {
702
+ return false;
703
+ }
704
+ return typeof node === "object" && typeof node.type === "string";
705
+ }
706
+ function isProperty(nodeType, key) {
707
+ return (nodeType === estraverse4.Syntax.ObjectExpression || nodeType === estraverse4.Syntax.ObjectPattern) && key === "properties";
708
+ }
709
+ function Visitor(visitor, options) {
710
+ options = options || {};
711
+ this.__visitor = visitor || this;
712
+ this.__childVisitorKeys = options.childVisitorKeys ? Object.assign({}, estraverse4.VisitorKeys, options.childVisitorKeys) : estraverse4.VisitorKeys;
713
+ if (options.fallback === "iteration") {
714
+ this.__fallback = Object.keys;
715
+ } else if (typeof options.fallback === "function") {
716
+ this.__fallback = options.fallback;
717
+ }
718
+ }
719
+ Visitor.prototype.visitChildren = function(node) {
720
+ var type, children, i, iz, j, jz, child;
721
+ if (node == null) {
722
+ return;
723
+ }
724
+ type = node.type || estraverse4.Syntax.Property;
725
+ children = this.__childVisitorKeys[type];
726
+ if (!children) {
727
+ if (this.__fallback) {
728
+ children = this.__fallback(node);
729
+ } else {
730
+ throw new Error("Unknown node type " + type + ".");
731
+ }
732
+ }
733
+ for (i = 0, iz = children.length; i < iz; ++i) {
734
+ child = node[children[i]];
735
+ if (child) {
736
+ if (Array.isArray(child)) {
737
+ for (j = 0, jz = child.length; j < jz; ++j) {
738
+ if (child[j]) {
739
+ if (isNode(child[j]) || isProperty(type, children[i])) {
740
+ this.visit(child[j]);
741
+ }
742
+ }
743
+ }
744
+ } else if (isNode(child)) {
745
+ this.visit(child);
746
+ }
747
+ }
748
+ }
749
+ };
750
+ Visitor.prototype.visit = function(node) {
751
+ var type;
752
+ if (node == null) {
753
+ return;
754
+ }
755
+ type = node.type || estraverse4.Syntax.Property;
756
+ if (this.__visitor[type]) {
757
+ this.__visitor[type].call(this, node);
758
+ return;
759
+ }
760
+ this.visitChildren(node);
761
+ };
762
+ exports.version = require_package().version;
763
+ exports.Visitor = Visitor;
764
+ exports.visit = function(node, visitor, options) {
765
+ var v = new Visitor(visitor, options);
766
+ v.visit(node);
767
+ };
768
+ })();
769
+ }
770
+ });
771
+
772
+ // ../inspector/dist/live.js
773
+ import { createRequire } from "module";
774
+ import { randomUUID } from "crypto";
775
+ import { readFileSync as readFileSync2, realpathSync as realpathSync2 } from "fs";
776
+ import { createHash } from "crypto";
777
+ import { closeSync, fstatSync, openSync, readFileSync, readdirSync, realpathSync } from "fs";
778
+ import { extname, join, posix, relative, resolve as resolve2 } from "path";
779
+ import { createHash as createHash2 } from "crypto";
780
+ import { parse as parse2 } from "acorn";
781
+ import postcss from "postcss";
782
+
783
+ // ../../node_modules/.bun/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
784
+ var schemeRegex = /^[\w+.-]+:\/\//;
785
+ var urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
786
+ var fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
787
+ function isAbsoluteUrl(input) {
788
+ return schemeRegex.test(input);
789
+ }
790
+ function isSchemeRelativeUrl(input) {
791
+ return input.startsWith("//");
792
+ }
793
+ function isAbsolutePath(input) {
794
+ return input.startsWith("/");
795
+ }
796
+ function isFileUrl(input) {
797
+ return input.startsWith("file:");
798
+ }
799
+ function isRelative(input) {
800
+ return /^[.?#]/.test(input);
801
+ }
802
+ function parseAbsoluteUrl(input) {
803
+ const match = urlRegex.exec(input);
804
+ return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
805
+ }
806
+ function parseFileUrl(input) {
807
+ const match = fileRegex.exec(input);
808
+ const path = match[2];
809
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
810
+ }
811
+ function makeUrl(scheme, user, host, port, path, query, hash) {
812
+ return {
813
+ scheme,
814
+ user,
815
+ host,
816
+ port,
817
+ path,
818
+ query,
819
+ hash,
820
+ type: 7
821
+ };
822
+ }
823
+ function parseUrl(input) {
824
+ if (isSchemeRelativeUrl(input)) {
825
+ const url2 = parseAbsoluteUrl("http:" + input);
826
+ url2.scheme = "";
827
+ url2.type = 6;
828
+ return url2;
829
+ }
830
+ if (isAbsolutePath(input)) {
831
+ const url2 = parseAbsoluteUrl("http://foo.com" + input);
832
+ url2.scheme = "";
833
+ url2.host = "";
834
+ url2.type = 5;
835
+ return url2;
836
+ }
837
+ if (isFileUrl(input))
838
+ return parseFileUrl(input);
839
+ if (isAbsoluteUrl(input))
840
+ return parseAbsoluteUrl(input);
841
+ const url = parseAbsoluteUrl("http://foo.com/" + input);
842
+ url.scheme = "";
843
+ url.host = "";
844
+ url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
845
+ return url;
846
+ }
847
+ function stripPathFilename(path) {
848
+ if (path.endsWith("/.."))
849
+ return path;
850
+ const index = path.lastIndexOf("/");
851
+ return path.slice(0, index + 1);
852
+ }
853
+ function mergePaths(url, base) {
854
+ normalizePath(base, base.type);
855
+ if (url.path === "/") {
856
+ url.path = base.path;
857
+ } else {
858
+ url.path = stripPathFilename(base.path) + url.path;
859
+ }
860
+ }
861
+ function normalizePath(url, type) {
862
+ const rel = type <= 4;
863
+ const pieces = url.path.split("/");
864
+ let pointer = 1;
865
+ let positive = 0;
866
+ let addTrailingSlash = false;
867
+ for (let i = 1; i < pieces.length; i++) {
868
+ const piece = pieces[i];
869
+ if (!piece) {
870
+ addTrailingSlash = true;
871
+ continue;
872
+ }
873
+ addTrailingSlash = false;
874
+ if (piece === ".")
875
+ continue;
876
+ if (piece === "..") {
877
+ if (positive) {
878
+ addTrailingSlash = true;
879
+ positive--;
880
+ pointer--;
881
+ } else if (rel) {
882
+ pieces[pointer++] = piece;
883
+ }
884
+ continue;
885
+ }
886
+ pieces[pointer++] = piece;
887
+ positive++;
888
+ }
889
+ let path = "";
890
+ for (let i = 1; i < pointer; i++) {
891
+ path += "/" + pieces[i];
892
+ }
893
+ if (!path || addTrailingSlash && !path.endsWith("/..")) {
894
+ path += "/";
895
+ }
896
+ url.path = path;
897
+ }
898
+ function resolve(input, base) {
899
+ if (!input && !base)
900
+ return "";
901
+ const url = parseUrl(input);
902
+ let inputType = url.type;
903
+ if (base && inputType !== 7) {
904
+ const baseUrl = parseUrl(base);
905
+ const baseType = baseUrl.type;
906
+ switch (inputType) {
907
+ case 1:
908
+ url.hash = baseUrl.hash;
909
+ // fall through
910
+ case 2:
911
+ url.query = baseUrl.query;
912
+ // fall through
913
+ case 3:
914
+ case 4:
915
+ mergePaths(url, baseUrl);
916
+ // fall through
917
+ case 5:
918
+ url.user = baseUrl.user;
919
+ url.host = baseUrl.host;
920
+ url.port = baseUrl.port;
921
+ // fall through
922
+ case 6:
923
+ url.scheme = baseUrl.scheme;
924
+ }
925
+ if (baseType > inputType)
926
+ inputType = baseType;
927
+ }
928
+ normalizePath(url, inputType);
929
+ const queryHash = url.query + url.hash;
930
+ switch (inputType) {
931
+ // This is impossible, because of the empty checks at the start of the function.
932
+ // case UrlType.Empty:
933
+ case 2:
934
+ case 3:
935
+ return queryHash;
936
+ case 4: {
937
+ const path = url.path.slice(1);
938
+ if (!path)
939
+ return queryHash || ".";
940
+ if (isRelative(base || input) && !isRelative(path)) {
941
+ return "./" + path + queryHash;
942
+ }
943
+ return path + queryHash;
944
+ }
945
+ case 5:
946
+ return url.path + queryHash;
947
+ default:
948
+ return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
949
+ }
950
+ }
951
+
952
+ // ../../node_modules/.bun/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
953
+ function stripFilename(path) {
954
+ if (!path) return "";
955
+ const index = path.lastIndexOf("/");
956
+ return path.slice(0, index + 1);
957
+ }
958
+ function resolver(mapUrl, sourceRoot) {
959
+ const from = stripFilename(mapUrl);
960
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
961
+ return (source) => resolve(prefix + (source || ""), from);
962
+ }
963
+ var COLUMN = 0;
964
+ var SOURCES_INDEX = 1;
965
+ var SOURCE_LINE = 2;
966
+ var SOURCE_COLUMN = 3;
967
+ var NAMES_INDEX = 4;
968
+ function maybeSort(mappings, owned) {
969
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
970
+ if (unsortedIndex === mappings.length) return mappings;
971
+ if (!owned) mappings = mappings.slice();
972
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
973
+ mappings[i] = sortSegments(mappings[i], owned);
974
+ }
975
+ return mappings;
976
+ }
977
+ function nextUnsortedSegmentLine(mappings, start) {
978
+ for (let i = start; i < mappings.length; i++) {
979
+ if (!isSorted(mappings[i])) return i;
980
+ }
981
+ return mappings.length;
982
+ }
983
+ function isSorted(line) {
984
+ for (let j = 1; j < line.length; j++) {
985
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
986
+ return false;
987
+ }
988
+ }
989
+ return true;
990
+ }
991
+ function sortSegments(line, owned) {
992
+ if (!owned) line = line.slice();
993
+ return line.sort(sortComparator);
994
+ }
995
+ function sortComparator(a, b) {
996
+ return a[COLUMN] - b[COLUMN];
997
+ }
998
+ var found = false;
999
+ function binarySearch(haystack, needle, low, high) {
1000
+ while (low <= high) {
1001
+ const mid = low + (high - low >> 1);
1002
+ const cmp = haystack[mid][COLUMN] - needle;
1003
+ if (cmp === 0) {
1004
+ found = true;
1005
+ return mid;
1006
+ }
1007
+ if (cmp < 0) {
1008
+ low = mid + 1;
1009
+ } else {
1010
+ high = mid - 1;
1011
+ }
1012
+ }
1013
+ found = false;
1014
+ return low - 1;
1015
+ }
1016
+ function upperBound(haystack, needle, index) {
1017
+ for (let i = index + 1; i < haystack.length; index = i++) {
1018
+ if (haystack[i][COLUMN] !== needle) break;
1019
+ }
1020
+ return index;
1021
+ }
1022
+ function lowerBound(haystack, needle, index) {
1023
+ for (let i = index - 1; i >= 0; index = i--) {
1024
+ if (haystack[i][COLUMN] !== needle) break;
1025
+ }
1026
+ return index;
1027
+ }
1028
+ function memoizedState() {
1029
+ return {
1030
+ lastKey: -1,
1031
+ lastNeedle: -1,
1032
+ lastIndex: -1
1033
+ };
1034
+ }
1035
+ function memoizedBinarySearch(haystack, needle, state, key) {
1036
+ const { lastKey, lastNeedle, lastIndex } = state;
1037
+ let low = 0;
1038
+ let high = haystack.length - 1;
1039
+ if (key === lastKey) {
1040
+ if (needle === lastNeedle) {
1041
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
1042
+ return lastIndex;
1043
+ }
1044
+ if (needle >= lastNeedle) {
1045
+ low = lastIndex === -1 ? 0 : lastIndex;
1046
+ } else {
1047
+ high = lastIndex;
1048
+ }
1049
+ }
1050
+ state.lastKey = key;
1051
+ state.lastNeedle = needle;
1052
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
1053
+ }
1054
+ function parse(map) {
1055
+ return typeof map === "string" ? JSON.parse(map) : map;
1056
+ }
1057
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
1058
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
1059
+ var LEAST_UPPER_BOUND = -1;
1060
+ var GREATEST_LOWER_BOUND = 1;
1061
+ var TraceMap = class {
1062
+ constructor(map, mapUrl) {
1063
+ const isString = typeof map === "string";
1064
+ if (!isString && map._decodedMemo) return map;
1065
+ const parsed = parse(map);
1066
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
1067
+ this.version = version;
1068
+ this.file = file;
1069
+ this.names = names || [];
1070
+ this.sourceRoot = sourceRoot;
1071
+ this.sources = sources;
1072
+ this.sourcesContent = sourcesContent;
1073
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
1074
+ const resolve3 = resolver(mapUrl, sourceRoot);
1075
+ this.resolvedSources = sources.map(resolve3);
1076
+ const { mappings } = parsed;
1077
+ if (typeof mappings === "string") {
1078
+ this._encoded = mappings;
1079
+ this._decoded = void 0;
1080
+ } else if (Array.isArray(mappings)) {
1081
+ this._encoded = void 0;
1082
+ this._decoded = maybeSort(mappings, isString);
1083
+ } else if (parsed.sections) {
1084
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
1085
+ } else {
1086
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
1087
+ }
1088
+ this._decodedMemo = memoizedState();
1089
+ this._bySources = void 0;
1090
+ this._bySourceMemos = void 0;
1091
+ }
1092
+ };
1093
+ function cast(map) {
1094
+ return map;
1095
+ }
1096
+ function decodedMappings(map) {
1097
+ var _a;
1098
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
1099
+ }
1100
+ function originalPositionFor(map, needle) {
1101
+ let { line, column, bias } = needle;
1102
+ line--;
1103
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
1104
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
1105
+ const decoded = decodedMappings(map);
1106
+ if (line >= decoded.length) return OMapping(null, null, null, null);
1107
+ const segments = decoded[line];
1108
+ const index = traceSegmentInternal(
1109
+ segments,
1110
+ cast(map)._decodedMemo,
1111
+ line,
1112
+ column,
1113
+ bias || GREATEST_LOWER_BOUND
1114
+ );
1115
+ if (index === -1) return OMapping(null, null, null, null);
1116
+ const segment = segments[index];
1117
+ if (segment.length === 1) return OMapping(null, null, null, null);
1118
+ const { names, resolvedSources } = map;
1119
+ return OMapping(
1120
+ resolvedSources[segment[SOURCES_INDEX]],
1121
+ segment[SOURCE_LINE] + 1,
1122
+ segment[SOURCE_COLUMN],
1123
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
1124
+ );
1125
+ }
1126
+ function OMapping(source, line, column, name) {
1127
+ return { source, line, column, name };
1128
+ }
1129
+ function traceSegmentInternal(segments, memo, line, column, bias) {
1130
+ let index = memoizedBinarySearch(segments, column, memo, line);
1131
+ if (found) {
1132
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
1133
+ } else if (bias === LEAST_UPPER_BOUND) index++;
1134
+ if (index === -1 || index === segments.length) return -1;
1135
+ return index;
1136
+ }
1137
+
1138
+ // ../inspector/dist/live.js
1139
+ import { parse as parse3 } from "acorn";
1140
+
1141
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/assert.js
1142
+ function assert(condition, message = "Assertion failed.") {
1143
+ if (!condition) {
1144
+ throw new Error(message);
1145
+ }
1146
+ }
1147
+
1148
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/scope.js
1149
+ var import_estraverse = __toESM(require_estraverse(), 1);
1150
+
1151
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/reference.js
1152
+ var READ = 1;
1153
+ var WRITE = 2;
1154
+ var RW = READ | WRITE;
1155
+ var Reference = class _Reference {
1156
+ constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
1157
+ this.identifier = ident;
1158
+ this.from = scope;
1159
+ this.tainted = false;
1160
+ this.resolved = null;
1161
+ this.flag = flag;
1162
+ if (this.isWrite()) {
1163
+ this.writeExpr = writeExpr;
1164
+ this.partial = partial;
1165
+ this.init = init;
1166
+ }
1167
+ this.__maybeImplicitGlobal = maybeImplicitGlobal;
1168
+ }
1169
+ /**
1170
+ * Whether the reference is static.
1171
+ * @function Reference#isStatic
1172
+ * @returns {boolean} static
1173
+ */
1174
+ isStatic() {
1175
+ return !this.tainted && !!this.resolved && this.resolved.scope.isStatic();
1176
+ }
1177
+ /**
1178
+ * Whether the reference is writeable.
1179
+ * @function Reference#isWrite
1180
+ * @returns {boolean} write
1181
+ */
1182
+ isWrite() {
1183
+ return !!(this.flag & _Reference.WRITE);
1184
+ }
1185
+ /**
1186
+ * Whether the reference is readable.
1187
+ * @function Reference#isRead
1188
+ * @returns {boolean} read
1189
+ */
1190
+ isRead() {
1191
+ return !!(this.flag & _Reference.READ);
1192
+ }
1193
+ /**
1194
+ * Whether the reference is read-only.
1195
+ * @function Reference#isReadOnly
1196
+ * @returns {boolean} read only
1197
+ */
1198
+ isReadOnly() {
1199
+ return this.flag === _Reference.READ;
1200
+ }
1201
+ /**
1202
+ * Whether the reference is write-only.
1203
+ * @function Reference#isWriteOnly
1204
+ * @returns {boolean} write only
1205
+ */
1206
+ isWriteOnly() {
1207
+ return this.flag === _Reference.WRITE;
1208
+ }
1209
+ /**
1210
+ * Whether the reference is read-write.
1211
+ * @function Reference#isReadWrite
1212
+ * @returns {boolean} read write
1213
+ */
1214
+ isReadWrite() {
1215
+ return this.flag === _Reference.RW;
1216
+ }
1217
+ };
1218
+ Reference.READ = READ;
1219
+ Reference.WRITE = WRITE;
1220
+ Reference.RW = RW;
1221
+ var reference_default = Reference;
1222
+
1223
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/variable.js
1224
+ var Variable = class {
1225
+ constructor(name, scope) {
1226
+ this.name = name;
1227
+ this.identifiers = [];
1228
+ this.references = [];
1229
+ this.defs = [];
1230
+ this.tainted = false;
1231
+ this.stack = true;
1232
+ this.scope = scope;
1233
+ }
1234
+ };
1235
+ Variable.CatchClause = "CatchClause";
1236
+ Variable.Parameter = "Parameter";
1237
+ Variable.FunctionName = "FunctionName";
1238
+ Variable.ClassName = "ClassName";
1239
+ Variable.Variable = "Variable";
1240
+ Variable.ImportBinding = "ImportBinding";
1241
+ Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
1242
+ var variable_default = Variable;
1243
+
1244
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/definition.js
1245
+ var Definition = class {
1246
+ constructor(type, name, node, parent, index, kind) {
1247
+ this.type = type;
1248
+ this.name = name;
1249
+ this.node = node;
1250
+ this.parent = parent;
1251
+ this.index = index;
1252
+ this.kind = kind;
1253
+ }
1254
+ };
1255
+ var ParameterDefinition = class extends Definition {
1256
+ constructor(name, node, index, rest) {
1257
+ super(variable_default.Parameter, name, node, null, index, null);
1258
+ this.rest = rest;
1259
+ }
1260
+ };
1261
+
1262
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/scope.js
1263
+ var { Syntax } = import_estraverse.default;
1264
+ function isStrictScope(scope, block, isMethodDefinition) {
1265
+ let body;
1266
+ if (scope.upper && scope.upper.isStrict) {
1267
+ return true;
1268
+ }
1269
+ if (isMethodDefinition) {
1270
+ return true;
1271
+ }
1272
+ if (scope.type === "class" || scope.type === "module") {
1273
+ return true;
1274
+ }
1275
+ if (scope.type === "block" || scope.type === "switch") {
1276
+ return false;
1277
+ }
1278
+ if (scope.type === "function") {
1279
+ if (block.type === Syntax.ArrowFunctionExpression && // @ts-ignore -- when block is ArrowFunctionExpression
1280
+ block.body.type !== Syntax.BlockStatement) {
1281
+ return false;
1282
+ }
1283
+ if (block.type === Syntax.Program) {
1284
+ body = block;
1285
+ } else {
1286
+ body = block.body;
1287
+ }
1288
+ if (!body) {
1289
+ return false;
1290
+ }
1291
+ } else if (scope.type === "global") {
1292
+ body = block;
1293
+ } else {
1294
+ return false;
1295
+ }
1296
+ for (let i = 0, iz = body.body.length; i < iz; ++i) {
1297
+ const stmt = body.body[i];
1298
+ if (typeof stmt.directive !== "string") {
1299
+ break;
1300
+ }
1301
+ if (stmt.directive === "use strict") {
1302
+ return true;
1303
+ }
1304
+ }
1305
+ return false;
1306
+ }
1307
+ function registerScope(scopeManager, scope) {
1308
+ scopeManager.scopes.push(scope);
1309
+ const scopes = scopeManager.__nodeToScope.get(scope.block);
1310
+ if (scopes) {
1311
+ scopes.push(scope);
1312
+ } else {
1313
+ scopeManager.__nodeToScope.set(scope.block, [scope]);
1314
+ }
1315
+ }
1316
+ var Scope = class {
1317
+ constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
1318
+ this.type = type;
1319
+ this.set = /* @__PURE__ */ new Map();
1320
+ this.taints = /* @__PURE__ */ new Map();
1321
+ this.dynamic = this.type === "global" || this.type === "with";
1322
+ this.block = block;
1323
+ this.through = [];
1324
+ this.variables = [];
1325
+ this.references = [];
1326
+ this.variableScope = this.type === "global" || this.type === "module" || this.type === "function" || this.type === "class-field-initializer" || this.type === "class-static-block" ? this : upperScope.variableScope;
1327
+ this.functionExpressionScope = /** @type {any} */
1328
+ false;
1329
+ this.directCallToEvalScope = false;
1330
+ this.thisFound = false;
1331
+ this.__left = [];
1332
+ this.upper = upperScope;
1333
+ this.isStrict = scopeManager.isStrictModeSupported() ? isStrictScope(this, block, isMethodDefinition) : false;
1334
+ this.childScopes = [];
1335
+ if (this.upper) {
1336
+ this.upper.childScopes.push(this);
1337
+ }
1338
+ this.__declaredVariables = scopeManager.__declaredVariables;
1339
+ registerScope(scopeManager, this);
1340
+ }
1341
+ __shouldStaticallyClose(scopeManager) {
1342
+ return !this.dynamic || scopeManager.__isOptimistic() || this.type === "global";
1343
+ }
1344
+ __staticCloseRef(ref) {
1345
+ if (!this.__resolve(ref)) {
1346
+ this.__delegateToUpperScope(ref);
1347
+ }
1348
+ }
1349
+ __dynamicCloseRef(ref) {
1350
+ let current = this;
1351
+ do {
1352
+ current.through.push(ref);
1353
+ current = current.upper;
1354
+ } while (current);
1355
+ }
1356
+ __close(scopeManager) {
1357
+ let closeRef;
1358
+ if (this.__shouldStaticallyClose(scopeManager)) {
1359
+ closeRef = this.__staticCloseRef;
1360
+ } else {
1361
+ closeRef = this.__dynamicCloseRef;
1362
+ }
1363
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
1364
+ const ref = this.__left[i];
1365
+ closeRef.call(this, ref);
1366
+ }
1367
+ this.__left = null;
1368
+ return this.upper;
1369
+ }
1370
+ // To override by function scopes.
1371
+ // References in default parameters isn't resolved to variables which are in their function body.
1372
+ // eslint-disable-next-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
1373
+ __isValidResolution(ref, variable) {
1374
+ return true;
1375
+ }
1376
+ __resolve(ref) {
1377
+ const name = ref.identifier.name;
1378
+ if (!this.set.has(name)) {
1379
+ return false;
1380
+ }
1381
+ const variable = this.set.get(name);
1382
+ if (!this.__isValidResolution(ref, variable)) {
1383
+ return false;
1384
+ }
1385
+ variable.references.push(ref);
1386
+ variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
1387
+ if (ref.tainted) {
1388
+ variable.tainted = true;
1389
+ this.taints.set(variable.name, true);
1390
+ }
1391
+ ref.resolved = variable;
1392
+ return true;
1393
+ }
1394
+ __delegateToUpperScope(ref) {
1395
+ if (this.upper) {
1396
+ this.upper.__left.push(ref);
1397
+ }
1398
+ this.through.push(ref);
1399
+ }
1400
+ __addDeclaredVariablesOfNode(variable, node) {
1401
+ if (node === null || node === void 0) {
1402
+ return;
1403
+ }
1404
+ let variables = this.__declaredVariables.get(node);
1405
+ if (variables === null || variables === void 0) {
1406
+ variables = [];
1407
+ this.__declaredVariables.set(node, variables);
1408
+ }
1409
+ if (!variables.includes(variable)) {
1410
+ variables.push(variable);
1411
+ }
1412
+ }
1413
+ __defineGeneric(name, set, variables, node, def) {
1414
+ let variable;
1415
+ variable = set.get(name);
1416
+ if (!variable) {
1417
+ variable = new variable_default(name, this);
1418
+ set.set(name, variable);
1419
+ variables.push(variable);
1420
+ }
1421
+ if (def) {
1422
+ variable.defs.push(def);
1423
+ this.__addDeclaredVariablesOfNode(variable, def.node);
1424
+ this.__addDeclaredVariablesOfNode(variable, def.parent);
1425
+ }
1426
+ if (node) {
1427
+ variable.identifiers.push(node);
1428
+ }
1429
+ }
1430
+ __define(node, def) {
1431
+ if (node && node.type === Syntax.Identifier) {
1432
+ this.__defineGeneric(
1433
+ node.name,
1434
+ this.set,
1435
+ this.variables,
1436
+ node,
1437
+ def
1438
+ );
1439
+ }
1440
+ }
1441
+ __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
1442
+ if (!node || node.type !== Syntax.Identifier && node.type !== "JSXIdentifier") {
1443
+ return;
1444
+ }
1445
+ if (node.name === "super") {
1446
+ return;
1447
+ }
1448
+ const ref = new reference_default(
1449
+ node,
1450
+ this,
1451
+ assign || reference_default.READ,
1452
+ writeExpr,
1453
+ maybeImplicitGlobal,
1454
+ !!partial,
1455
+ !!init
1456
+ );
1457
+ this.references.push(ref);
1458
+ this.__left.push(ref);
1459
+ }
1460
+ __detectEval() {
1461
+ let current = this;
1462
+ this.directCallToEvalScope = true;
1463
+ do {
1464
+ current.dynamic = true;
1465
+ current = current.upper;
1466
+ } while (current);
1467
+ }
1468
+ __detectThis() {
1469
+ this.thisFound = true;
1470
+ }
1471
+ __isClosed() {
1472
+ return this.__left === null;
1473
+ }
1474
+ /**
1475
+ * returns resolved {Reference}
1476
+ * @function Scope#resolve
1477
+ * @param {ESTree.Identifier} ident identifier to be resolved.
1478
+ * @returns {?Reference} reference
1479
+ */
1480
+ resolve(ident) {
1481
+ let ref, i, iz;
1482
+ assert(this.__isClosed(), "Scope should be closed.");
1483
+ assert(
1484
+ ident.type === Syntax.Identifier,
1485
+ "Target should be identifier."
1486
+ );
1487
+ for (i = 0, iz = this.references.length; i < iz; ++i) {
1488
+ ref = this.references[i];
1489
+ if (ref.identifier === ident) {
1490
+ return ref;
1491
+ }
1492
+ }
1493
+ return null;
1494
+ }
1495
+ /**
1496
+ * returns this scope is static
1497
+ * @function Scope#isStatic
1498
+ * @returns {boolean} static
1499
+ */
1500
+ isStatic() {
1501
+ return !this.dynamic;
1502
+ }
1503
+ /**
1504
+ * returns this scope has materialized arguments
1505
+ * @function Scope#isArgumentsMaterialized
1506
+ * @returns {any} arguments materialized
1507
+ */
1508
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
1509
+ isArgumentsMaterialized() {
1510
+ return true;
1511
+ }
1512
+ /**
1513
+ * returns this scope has materialized `this` reference
1514
+ * @function Scope#isThisMaterialized
1515
+ * @returns {any} this materialized
1516
+ */
1517
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
1518
+ isThisMaterialized() {
1519
+ return true;
1520
+ }
1521
+ isUsedName(name) {
1522
+ if (this.set.has(name)) {
1523
+ return true;
1524
+ }
1525
+ for (let i = 0, iz = this.through.length; i < iz; ++i) {
1526
+ if (this.through[i].identifier.name === name) {
1527
+ return true;
1528
+ }
1529
+ }
1530
+ return false;
1531
+ }
1532
+ };
1533
+ var GlobalScope = class extends Scope {
1534
+ constructor(scopeManager, block) {
1535
+ super(scopeManager, "global", null, block, false);
1536
+ this.implicit = {
1537
+ set: /* @__PURE__ */ new Map(),
1538
+ /** @type {Variable[]} */
1539
+ variables: [],
1540
+ /**
1541
+ * List of {@link Reference}s that are left to be resolved (i.e. which
1542
+ * need to be linked to the variable they refer to).
1543
+ * @member {Reference[]} Scope#implicit#left
1544
+ * @type {Reference[]}
1545
+ */
1546
+ left: []
1547
+ };
1548
+ }
1549
+ __close(scopeManager) {
1550
+ const implicit = [];
1551
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
1552
+ const ref = this.__left[i];
1553
+ if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
1554
+ implicit.push(ref.__maybeImplicitGlobal);
1555
+ }
1556
+ }
1557
+ for (let i = 0, iz = implicit.length; i < iz; ++i) {
1558
+ const info = implicit[i];
1559
+ this.__defineImplicit(
1560
+ info.pattern,
1561
+ new Definition(
1562
+ variable_default.ImplicitGlobalVariable,
1563
+ info.pattern,
1564
+ info.node,
1565
+ null,
1566
+ null,
1567
+ null
1568
+ )
1569
+ );
1570
+ }
1571
+ super.__close(scopeManager);
1572
+ this.implicit.left = [...this.through];
1573
+ return null;
1574
+ }
1575
+ __defineImplicit(node, def) {
1576
+ if (node && node.type === Syntax.Identifier) {
1577
+ this.__defineGeneric(
1578
+ node.name,
1579
+ this.implicit.set,
1580
+ this.implicit.variables,
1581
+ node,
1582
+ def
1583
+ );
1584
+ }
1585
+ }
1586
+ __addVariables(names) {
1587
+ for (const name of names) {
1588
+ this.__defineGeneric(name, this.set, this.variables, null, null);
1589
+ }
1590
+ const namesSet = new Set(names);
1591
+ this.through = this.through.filter((reference) => {
1592
+ const name = reference.identifier.name;
1593
+ if (namesSet.has(name)) {
1594
+ const variable = this.set.get(name);
1595
+ reference.resolved = variable;
1596
+ variable.references.push(reference);
1597
+ return false;
1598
+ }
1599
+ return true;
1600
+ });
1601
+ this.implicit.variables = this.implicit.variables.filter((variable) => {
1602
+ const name = variable.name;
1603
+ if (namesSet.has(name)) {
1604
+ this.implicit.set.delete(name);
1605
+ return false;
1606
+ }
1607
+ return true;
1608
+ });
1609
+ this.implicit.left = this.implicit.left.filter(
1610
+ (reference) => !namesSet.has(reference.identifier.name)
1611
+ );
1612
+ }
1613
+ };
1614
+ var ModuleScope = class extends Scope {
1615
+ constructor(scopeManager, upperScope, block) {
1616
+ super(scopeManager, "module", upperScope, block, false);
1617
+ }
1618
+ };
1619
+ var FunctionExpressionNameScope = class extends Scope {
1620
+ constructor(scopeManager, upperScope, block) {
1621
+ super(
1622
+ scopeManager,
1623
+ "function-expression-name",
1624
+ upperScope,
1625
+ block,
1626
+ false
1627
+ );
1628
+ this.__define(
1629
+ block.id,
1630
+ new Definition(
1631
+ variable_default.FunctionName,
1632
+ block.id,
1633
+ block,
1634
+ null,
1635
+ null,
1636
+ null
1637
+ )
1638
+ );
1639
+ this.functionExpressionScope = /** @type {const} */
1640
+ true;
1641
+ }
1642
+ };
1643
+ var CatchScope = class extends Scope {
1644
+ constructor(scopeManager, upperScope, block) {
1645
+ super(scopeManager, "catch", upperScope, block, false);
1646
+ }
1647
+ };
1648
+ var WithScope = class extends Scope {
1649
+ constructor(scopeManager, upperScope, block) {
1650
+ super(scopeManager, "with", upperScope, block, false);
1651
+ }
1652
+ __close(scopeManager) {
1653
+ if (this.__shouldStaticallyClose(scopeManager)) {
1654
+ return super.__close(scopeManager);
1655
+ }
1656
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
1657
+ const ref = this.__left[i];
1658
+ ref.tainted = true;
1659
+ this.__delegateToUpperScope(ref);
1660
+ }
1661
+ this.__left = null;
1662
+ return this.upper;
1663
+ }
1664
+ };
1665
+ var BlockScope = class extends Scope {
1666
+ constructor(scopeManager, upperScope, block) {
1667
+ super(scopeManager, "block", upperScope, block, false);
1668
+ }
1669
+ };
1670
+ var SwitchScope = class extends Scope {
1671
+ constructor(scopeManager, upperScope, block) {
1672
+ super(scopeManager, "switch", upperScope, block, false);
1673
+ }
1674
+ };
1675
+ var FunctionScope = class extends Scope {
1676
+ constructor(scopeManager, upperScope, block, isMethodDefinition) {
1677
+ super(scopeManager, "function", upperScope, block, isMethodDefinition);
1678
+ if (this.block.type !== Syntax.ArrowFunctionExpression) {
1679
+ this.__defineArguments();
1680
+ }
1681
+ }
1682
+ isArgumentsMaterialized() {
1683
+ if (this.block.type === Syntax.ArrowFunctionExpression) {
1684
+ return false;
1685
+ }
1686
+ if (!this.isStatic()) {
1687
+ return true;
1688
+ }
1689
+ const variable = this.set.get("arguments");
1690
+ assert(variable, "Always have arguments variable.");
1691
+ return variable.tainted || variable.references.length !== 0;
1692
+ }
1693
+ isThisMaterialized() {
1694
+ if (!this.isStatic()) {
1695
+ return true;
1696
+ }
1697
+ return this.thisFound;
1698
+ }
1699
+ __defineArguments() {
1700
+ this.__defineGeneric("arguments", this.set, this.variables, null, null);
1701
+ this.taints.set("arguments", true);
1702
+ }
1703
+ // References in default parameters isn't resolved to variables which are in their function body.
1704
+ // const x = 1
1705
+ // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
1706
+ // const x = 2
1707
+ // console.log(a)
1708
+ // }
1709
+ __isValidResolution(ref, variable) {
1710
+ if (this.block.type === "Program") {
1711
+ return true;
1712
+ }
1713
+ const bodyStart = this.block.body.range[0];
1714
+ return !(variable.scope === this && ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
1715
+ variable.defs.every((d) => d.name.range[0] >= bodyStart));
1716
+ }
1717
+ };
1718
+ var ForScope = class extends Scope {
1719
+ constructor(scopeManager, upperScope, block) {
1720
+ super(scopeManager, "for", upperScope, block, false);
1721
+ }
1722
+ };
1723
+ var ClassScope = class extends Scope {
1724
+ constructor(scopeManager, upperScope, block) {
1725
+ super(scopeManager, "class", upperScope, block, false);
1726
+ }
1727
+ };
1728
+ var ClassFieldInitializerScope = class extends Scope {
1729
+ constructor(scopeManager, upperScope, block) {
1730
+ super(scopeManager, "class-field-initializer", upperScope, block, true);
1731
+ }
1732
+ };
1733
+ var ClassStaticBlockScope = class extends Scope {
1734
+ constructor(scopeManager, upperScope, block) {
1735
+ super(scopeManager, "class-static-block", upperScope, block, true);
1736
+ }
1737
+ };
1738
+
1739
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/scope-manager.js
1740
+ var ScopeManager = class {
1741
+ constructor(options) {
1742
+ this.scopes = [];
1743
+ this.globalScope = null;
1744
+ this.__nodeToScope = /* @__PURE__ */ new WeakMap();
1745
+ this.__currentScope = null;
1746
+ this.__options = options;
1747
+ this.__declaredVariables = /* @__PURE__ */ new WeakMap();
1748
+ }
1749
+ __isOptimistic() {
1750
+ return this.__options.optimistic;
1751
+ }
1752
+ __ignoreEval() {
1753
+ return this.__options.ignoreEval;
1754
+ }
1755
+ __isJSXEnabled() {
1756
+ return this.__options.jsx === true;
1757
+ }
1758
+ isGlobalReturn() {
1759
+ return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
1760
+ }
1761
+ isModule() {
1762
+ return this.__options.sourceType === "module";
1763
+ }
1764
+ isImpliedStrict() {
1765
+ return !!this.__options.impliedStrict;
1766
+ }
1767
+ isStrictModeSupported() {
1768
+ return this.__options.ecmaVersion >= 5;
1769
+ }
1770
+ // Returns appropriate scope for this node.
1771
+ __get(node) {
1772
+ return this.__nodeToScope.get(node);
1773
+ }
1774
+ /**
1775
+ * Get variables that are declared by the node.
1776
+ *
1777
+ * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
1778
+ * If the node declares nothing, this method returns an empty array.
1779
+ * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
1780
+ * @param {ESTree.Node} node a node to get.
1781
+ * @returns {Variable[]} variables that declared by the node.
1782
+ */
1783
+ getDeclaredVariables(node) {
1784
+ return this.__declaredVariables.get(node) || [];
1785
+ }
1786
+ /**
1787
+ * acquire scope from node.
1788
+ * @function ScopeManager#acquire
1789
+ * @param {ESTree.Node} node node for the acquired scope.
1790
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
1791
+ * @returns {Scope?} Scope from node
1792
+ */
1793
+ acquire(node, inner) {
1794
+ function predicate(testScope) {
1795
+ if (testScope.type === "function" && testScope.functionExpressionScope) {
1796
+ return false;
1797
+ }
1798
+ return true;
1799
+ }
1800
+ const scopes = this.__get(node);
1801
+ if (!scopes || scopes.length === 0) {
1802
+ return null;
1803
+ }
1804
+ if (scopes.length === 1) {
1805
+ return scopes[0];
1806
+ }
1807
+ if (inner) {
1808
+ for (let i = scopes.length - 1; i >= 0; --i) {
1809
+ const scope = scopes[i];
1810
+ if (predicate(scope)) {
1811
+ return scope;
1812
+ }
1813
+ }
1814
+ } else {
1815
+ for (let i = 0, iz = scopes.length; i < iz; ++i) {
1816
+ const scope = scopes[i];
1817
+ if (predicate(scope)) {
1818
+ return scope;
1819
+ }
1820
+ }
1821
+ }
1822
+ return null;
1823
+ }
1824
+ /**
1825
+ * acquire all scopes from node.
1826
+ * @function ScopeManager#acquireAll
1827
+ * @param {ESTree.Node} node node for the acquired scope.
1828
+ * @returns {Scope[]?} Scope array
1829
+ */
1830
+ acquireAll(node) {
1831
+ return this.__get(node);
1832
+ }
1833
+ /**
1834
+ * release the node.
1835
+ * @function ScopeManager#release
1836
+ * @param {ESTree.Node} node releasing node.
1837
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
1838
+ * @returns {Scope?} upper scope for the node.
1839
+ */
1840
+ release(node, inner) {
1841
+ const scopes = this.__get(node);
1842
+ if (scopes && scopes.length) {
1843
+ const scope = scopes[0].upper;
1844
+ if (!scope) {
1845
+ return null;
1846
+ }
1847
+ return this.acquire(scope.block, inner);
1848
+ }
1849
+ return null;
1850
+ }
1851
+ /**
1852
+ * Add global variables and resolve their references.
1853
+ * @function ScopeManager#addGlobals
1854
+ * @param {string[]} names Names of global variables to add.
1855
+ * @returns {void}
1856
+ */
1857
+ addGlobals(names) {
1858
+ this.globalScope.__addVariables(names);
1859
+ }
1860
+ attach() {
1861
+ }
1862
+ // eslint-disable-line class-methods-use-this -- Desired as instance method
1863
+ detach() {
1864
+ }
1865
+ // eslint-disable-line class-methods-use-this -- Desired as instance method
1866
+ __nestScope(scope) {
1867
+ if (scope instanceof GlobalScope) {
1868
+ assert(this.__currentScope === null);
1869
+ this.globalScope = scope;
1870
+ }
1871
+ this.__currentScope = scope;
1872
+ return scope;
1873
+ }
1874
+ __nestGlobalScope(node) {
1875
+ return this.__nestScope(new GlobalScope(this, node));
1876
+ }
1877
+ __nestBlockScope(node) {
1878
+ return this.__nestScope(
1879
+ new BlockScope(this, this.__currentScope, node)
1880
+ );
1881
+ }
1882
+ __nestFunctionScope(node, isMethodDefinition) {
1883
+ return this.__nestScope(
1884
+ new FunctionScope(
1885
+ this,
1886
+ this.__currentScope,
1887
+ node,
1888
+ isMethodDefinition
1889
+ )
1890
+ );
1891
+ }
1892
+ __nestForScope(node) {
1893
+ return this.__nestScope(new ForScope(this, this.__currentScope, node));
1894
+ }
1895
+ __nestCatchScope(node) {
1896
+ return this.__nestScope(
1897
+ new CatchScope(this, this.__currentScope, node)
1898
+ );
1899
+ }
1900
+ __nestWithScope(node) {
1901
+ return this.__nestScope(new WithScope(this, this.__currentScope, node));
1902
+ }
1903
+ __nestClassScope(node) {
1904
+ return this.__nestScope(
1905
+ new ClassScope(this, this.__currentScope, node)
1906
+ );
1907
+ }
1908
+ __nestClassFieldInitializerScope(node) {
1909
+ return this.__nestScope(
1910
+ new ClassFieldInitializerScope(this, this.__currentScope, node)
1911
+ );
1912
+ }
1913
+ __nestClassStaticBlockScope(node) {
1914
+ return this.__nestScope(
1915
+ new ClassStaticBlockScope(this, this.__currentScope, node)
1916
+ );
1917
+ }
1918
+ __nestSwitchScope(node) {
1919
+ return this.__nestScope(
1920
+ new SwitchScope(this, this.__currentScope, node)
1921
+ );
1922
+ }
1923
+ __nestModuleScope(node) {
1924
+ return this.__nestScope(
1925
+ new ModuleScope(this, this.__currentScope, node)
1926
+ );
1927
+ }
1928
+ __nestFunctionExpressionNameScope(node) {
1929
+ return this.__nestScope(
1930
+ new FunctionExpressionNameScope(this, this.__currentScope, node)
1931
+ );
1932
+ }
1933
+ __isES6() {
1934
+ return this.__options.ecmaVersion >= 6;
1935
+ }
1936
+ };
1937
+ var scope_manager_default = ScopeManager;
1938
+
1939
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/referencer.js
1940
+ var import_estraverse3 = __toESM(require_estraverse(), 1);
1941
+ var import_esrecurse2 = __toESM(require_esrecurse(), 1);
1942
+
1943
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/pattern-visitor.js
1944
+ var import_estraverse2 = __toESM(require_estraverse(), 1);
1945
+ var import_esrecurse = __toESM(require_esrecurse(), 1);
1946
+ var { Syntax: Syntax2 } = import_estraverse2.default;
1947
+ function getLast(xs) {
1948
+ return xs.at(-1) || null;
1949
+ }
1950
+ var PatternVisitor = class extends import_esrecurse.default.Visitor {
1951
+ static isPattern(node) {
1952
+ const nodeType = node.type;
1953
+ return nodeType === Syntax2.Identifier || nodeType === Syntax2.ObjectPattern || nodeType === Syntax2.ArrayPattern || nodeType === Syntax2.SpreadElement || nodeType === Syntax2.RestElement || nodeType === Syntax2.AssignmentPattern;
1954
+ }
1955
+ constructor(options, rootPattern, callback) {
1956
+ super(null, options);
1957
+ this.rootPattern = rootPattern;
1958
+ this.callback = callback;
1959
+ this.assignments = [];
1960
+ this.rightHandNodes = [];
1961
+ this.restElements = [];
1962
+ }
1963
+ Identifier(pattern) {
1964
+ const lastRestElement = getLast(this.restElements);
1965
+ this.callback(pattern, {
1966
+ topLevel: pattern === this.rootPattern,
1967
+ rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern,
1968
+ assignments: this.assignments
1969
+ });
1970
+ }
1971
+ Property(property) {
1972
+ if (property.computed) {
1973
+ this.rightHandNodes.push(property.key);
1974
+ }
1975
+ this.visit(property.value);
1976
+ }
1977
+ ArrayPattern(pattern) {
1978
+ for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
1979
+ const element = pattern.elements[i];
1980
+ this.visit(element);
1981
+ }
1982
+ }
1983
+ AssignmentPattern(pattern) {
1984
+ this.assignments.push(pattern);
1985
+ this.visit(pattern.left);
1986
+ this.rightHandNodes.push(pattern.right);
1987
+ this.assignments.pop();
1988
+ }
1989
+ RestElement(pattern) {
1990
+ this.restElements.push(pattern);
1991
+ this.visit(pattern.argument);
1992
+ this.restElements.pop();
1993
+ }
1994
+ MemberExpression(node) {
1995
+ if (node.computed) {
1996
+ this.rightHandNodes.push(node.property);
1997
+ }
1998
+ this.rightHandNodes.push(node.object);
1999
+ }
2000
+ //
2001
+ // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
2002
+ // By spec, LeftHandSideExpression is Pattern or MemberExpression.
2003
+ // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
2004
+ // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
2005
+ //
2006
+ SpreadElement(node) {
2007
+ this.visit(node.argument);
2008
+ }
2009
+ ArrayExpression(node) {
2010
+ node.elements.forEach(this.visit, this);
2011
+ }
2012
+ AssignmentExpression(node) {
2013
+ this.assignments.push(node);
2014
+ this.visit(node.left);
2015
+ this.rightHandNodes.push(node.right);
2016
+ this.assignments.pop();
2017
+ }
2018
+ CallExpression(node) {
2019
+ node.arguments.forEach((a) => {
2020
+ this.rightHandNodes.push(a);
2021
+ });
2022
+ this.visit(node.callee);
2023
+ }
2024
+ };
2025
+ var pattern_visitor_default = PatternVisitor;
2026
+
2027
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/referencer.js
2028
+ var { Syntax: Syntax3 } = import_estraverse3.default;
2029
+ function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
2030
+ const visitor = new pattern_visitor_default(options, rootPattern, callback);
2031
+ visitor.visit(rootPattern);
2032
+ if (referencer !== null && referencer !== void 0) {
2033
+ visitor.rightHandNodes.forEach(referencer.visit, referencer);
2034
+ }
2035
+ }
2036
+ var Importer = class extends import_esrecurse2.default.Visitor {
2037
+ constructor(declaration, referencer) {
2038
+ super(null, referencer.options);
2039
+ this.declaration = declaration;
2040
+ this.referencer = referencer;
2041
+ }
2042
+ visitImport(id, specifier) {
2043
+ this.referencer.visitPattern(id, (pattern) => {
2044
+ this.referencer.currentScope().__define(
2045
+ pattern,
2046
+ new Definition(
2047
+ variable_default.ImportBinding,
2048
+ pattern,
2049
+ specifier,
2050
+ this.declaration,
2051
+ null,
2052
+ null
2053
+ )
2054
+ );
2055
+ });
2056
+ }
2057
+ ImportNamespaceSpecifier(node) {
2058
+ const local = node.local || node.id;
2059
+ if (local) {
2060
+ this.visitImport(local, node);
2061
+ }
2062
+ }
2063
+ ImportDefaultSpecifier(node) {
2064
+ const local = node.local || node.id;
2065
+ this.visitImport(local, node);
2066
+ }
2067
+ ImportSpecifier(node) {
2068
+ const local = node.local || node.id;
2069
+ if (node.name) {
2070
+ this.visitImport(node.name, node);
2071
+ } else {
2072
+ this.visitImport(local, node);
2073
+ }
2074
+ }
2075
+ };
2076
+ var Referencer = class extends import_esrecurse2.default.Visitor {
2077
+ constructor(options, scopeManager) {
2078
+ super(null, options);
2079
+ this.options = options;
2080
+ this.scopeManager = scopeManager;
2081
+ this.parent = null;
2082
+ this.isInnerMethodDefinition = false;
2083
+ }
2084
+ currentScope() {
2085
+ return this.scopeManager.__currentScope;
2086
+ }
2087
+ close(node) {
2088
+ while (this.currentScope() && node === this.currentScope().block) {
2089
+ this.scopeManager.__currentScope = this.currentScope().__close(
2090
+ this.scopeManager
2091
+ );
2092
+ }
2093
+ }
2094
+ pushInnerMethodDefinition(isInnerMethodDefinition) {
2095
+ const previous = this.isInnerMethodDefinition;
2096
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
2097
+ return previous;
2098
+ }
2099
+ popInnerMethodDefinition(isInnerMethodDefinition) {
2100
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
2101
+ }
2102
+ referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
2103
+ const scope = this.currentScope();
2104
+ assignments.forEach((assignment) => {
2105
+ scope.__referencing(
2106
+ pattern,
2107
+ reference_default.WRITE,
2108
+ assignment.right,
2109
+ maybeImplicitGlobal,
2110
+ pattern !== assignment.left,
2111
+ init
2112
+ );
2113
+ });
2114
+ }
2115
+ visitPattern(node, options, callback) {
2116
+ let visitPatternOptions = options;
2117
+ let visitPatternCallback = callback;
2118
+ if (typeof options === "function") {
2119
+ visitPatternCallback = options;
2120
+ visitPatternOptions = { processRightHandNodes: false };
2121
+ }
2122
+ traverseIdentifierInPattern(
2123
+ this.options,
2124
+ node,
2125
+ visitPatternOptions.processRightHandNodes ? this : null,
2126
+ visitPatternCallback
2127
+ );
2128
+ }
2129
+ visitFunction(node) {
2130
+ let i, iz;
2131
+ if (node.type === Syntax3.FunctionDeclaration) {
2132
+ this.currentScope().__define(
2133
+ node.id,
2134
+ new Definition(
2135
+ variable_default.FunctionName,
2136
+ node.id,
2137
+ node,
2138
+ null,
2139
+ null,
2140
+ null
2141
+ )
2142
+ );
2143
+ }
2144
+ if (node.type === Syntax3.FunctionExpression && node.id) {
2145
+ this.scopeManager.__nestFunctionExpressionNameScope(node);
2146
+ }
2147
+ this.scopeManager.__nestFunctionScope(
2148
+ node,
2149
+ this.isInnerMethodDefinition
2150
+ );
2151
+ const that = this;
2152
+ function visitPatternCallback(pattern, info) {
2153
+ that.currentScope().__define(
2154
+ pattern,
2155
+ new ParameterDefinition(pattern, node, i, info.rest)
2156
+ );
2157
+ that.referencingDefaultValue(pattern, info.assignments, null, true);
2158
+ }
2159
+ for (i = 0, iz = node.params.length; i < iz; ++i) {
2160
+ this.visitPattern(
2161
+ node.params[i],
2162
+ { processRightHandNodes: true },
2163
+ visitPatternCallback
2164
+ );
2165
+ }
2166
+ if (node.rest) {
2167
+ this.visitPattern(
2168
+ {
2169
+ type: "RestElement",
2170
+ argument: node.rest
2171
+ },
2172
+ (pattern) => {
2173
+ this.currentScope().__define(
2174
+ pattern,
2175
+ new ParameterDefinition(
2176
+ pattern,
2177
+ node,
2178
+ node.params.length,
2179
+ true
2180
+ )
2181
+ );
2182
+ }
2183
+ );
2184
+ }
2185
+ if (node.body) {
2186
+ if (node.body.type === Syntax3.BlockStatement) {
2187
+ this.visitChildren(node.body);
2188
+ } else {
2189
+ this.visit(node.body);
2190
+ }
2191
+ }
2192
+ this.close(node);
2193
+ }
2194
+ visitClass(node) {
2195
+ if (node.type === Syntax3.ClassDeclaration) {
2196
+ this.currentScope().__define(
2197
+ node.id,
2198
+ new Definition(
2199
+ variable_default.ClassName,
2200
+ node.id,
2201
+ node,
2202
+ null,
2203
+ null,
2204
+ null
2205
+ )
2206
+ );
2207
+ }
2208
+ this.scopeManager.__nestClassScope(node);
2209
+ if (node.id) {
2210
+ this.currentScope().__define(
2211
+ node.id,
2212
+ new Definition(variable_default.ClassName, node.id, node)
2213
+ );
2214
+ }
2215
+ this.visit(node.superClass);
2216
+ this.visit(node.body);
2217
+ this.close(node);
2218
+ }
2219
+ visitProperty(node) {
2220
+ let previous;
2221
+ if (node.computed) {
2222
+ this.visit(node.key);
2223
+ }
2224
+ const isMethodDefinition = node.type === Syntax3.MethodDefinition;
2225
+ if (isMethodDefinition) {
2226
+ previous = this.pushInnerMethodDefinition(true);
2227
+ }
2228
+ this.visit(node.value);
2229
+ if (isMethodDefinition) {
2230
+ this.popInnerMethodDefinition(previous);
2231
+ }
2232
+ }
2233
+ visitForIn(node) {
2234
+ if (node.left.type === Syntax3.VariableDeclaration && node.left.kind !== "var") {
2235
+ this.scopeManager.__nestForScope(node);
2236
+ }
2237
+ if (node.left.type === Syntax3.VariableDeclaration) {
2238
+ this.visit(node.left);
2239
+ this.visitPattern(node.left.declarations[0].id, (pattern) => {
2240
+ this.currentScope().__referencing(
2241
+ pattern,
2242
+ reference_default.WRITE,
2243
+ node.right,
2244
+ null,
2245
+ true,
2246
+ true
2247
+ );
2248
+ });
2249
+ } else {
2250
+ this.visitPattern(
2251
+ node.left,
2252
+ { processRightHandNodes: true },
2253
+ (pattern, info) => {
2254
+ let maybeImplicitGlobal = null;
2255
+ if (!this.currentScope().isStrict) {
2256
+ maybeImplicitGlobal = {
2257
+ pattern,
2258
+ node
2259
+ };
2260
+ }
2261
+ this.referencingDefaultValue(
2262
+ pattern,
2263
+ info.assignments,
2264
+ maybeImplicitGlobal,
2265
+ false
2266
+ );
2267
+ this.currentScope().__referencing(
2268
+ pattern,
2269
+ reference_default.WRITE,
2270
+ node.right,
2271
+ maybeImplicitGlobal,
2272
+ true,
2273
+ false
2274
+ );
2275
+ }
2276
+ );
2277
+ }
2278
+ this.visit(node.right);
2279
+ this.visit(node.body);
2280
+ this.close(node);
2281
+ }
2282
+ visitVariableDeclaration(variableTargetScope, type, node, index) {
2283
+ const decl = node.declarations[index];
2284
+ const init = decl.init;
2285
+ this.visitPattern(
2286
+ decl.id,
2287
+ { processRightHandNodes: true },
2288
+ (pattern, info) => {
2289
+ variableTargetScope.__define(
2290
+ pattern,
2291
+ new Definition(type, pattern, decl, node, index, node.kind)
2292
+ );
2293
+ this.referencingDefaultValue(
2294
+ pattern,
2295
+ info.assignments,
2296
+ null,
2297
+ true
2298
+ );
2299
+ if (init) {
2300
+ this.currentScope().__referencing(
2301
+ pattern,
2302
+ reference_default.WRITE,
2303
+ init,
2304
+ null,
2305
+ !info.topLevel,
2306
+ true
2307
+ );
2308
+ }
2309
+ }
2310
+ );
2311
+ }
2312
+ AssignmentExpression(node) {
2313
+ if (pattern_visitor_default.isPattern(node.left)) {
2314
+ if (node.operator === "=") {
2315
+ this.visitPattern(
2316
+ node.left,
2317
+ { processRightHandNodes: true },
2318
+ (pattern, info) => {
2319
+ let maybeImplicitGlobal = null;
2320
+ if (!this.currentScope().isStrict) {
2321
+ maybeImplicitGlobal = {
2322
+ pattern,
2323
+ node
2324
+ };
2325
+ }
2326
+ this.referencingDefaultValue(
2327
+ pattern,
2328
+ info.assignments,
2329
+ maybeImplicitGlobal,
2330
+ false
2331
+ );
2332
+ this.currentScope().__referencing(
2333
+ pattern,
2334
+ reference_default.WRITE,
2335
+ node.right,
2336
+ maybeImplicitGlobal,
2337
+ !info.topLevel,
2338
+ false
2339
+ );
2340
+ }
2341
+ );
2342
+ } else {
2343
+ this.currentScope().__referencing(
2344
+ node.left,
2345
+ reference_default.RW,
2346
+ node.right
2347
+ );
2348
+ }
2349
+ } else {
2350
+ this.visit(node.left);
2351
+ }
2352
+ this.visit(node.right);
2353
+ }
2354
+ CatchClause(node) {
2355
+ this.scopeManager.__nestCatchScope(node);
2356
+ this.visitPattern(
2357
+ node.param,
2358
+ { processRightHandNodes: true },
2359
+ (pattern, info) => {
2360
+ this.currentScope().__define(
2361
+ pattern,
2362
+ new Definition(
2363
+ variable_default.CatchClause,
2364
+ pattern,
2365
+ node,
2366
+ null,
2367
+ null,
2368
+ null
2369
+ )
2370
+ );
2371
+ this.referencingDefaultValue(
2372
+ pattern,
2373
+ info.assignments,
2374
+ null,
2375
+ true
2376
+ );
2377
+ }
2378
+ );
2379
+ this.visit(node.body);
2380
+ this.close(node);
2381
+ }
2382
+ Program(node) {
2383
+ this.scopeManager.__nestGlobalScope(node);
2384
+ if (this.scopeManager.isGlobalReturn()) {
2385
+ this.currentScope().isStrict = false;
2386
+ this.scopeManager.__nestFunctionScope(node, false);
2387
+ }
2388
+ if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
2389
+ this.scopeManager.__nestModuleScope(node);
2390
+ }
2391
+ if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
2392
+ this.currentScope().isStrict = true;
2393
+ }
2394
+ this.visitChildren(node);
2395
+ this.close(node);
2396
+ }
2397
+ Identifier(node) {
2398
+ this.currentScope().__referencing(node);
2399
+ }
2400
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
2401
+ PrivateIdentifier() {
2402
+ }
2403
+ UpdateExpression(node) {
2404
+ if (pattern_visitor_default.isPattern(node.argument)) {
2405
+ this.currentScope().__referencing(
2406
+ node.argument,
2407
+ reference_default.RW,
2408
+ null
2409
+ );
2410
+ } else {
2411
+ this.visitChildren(node);
2412
+ }
2413
+ }
2414
+ MemberExpression(node) {
2415
+ this.visit(node.object);
2416
+ if (node.computed) {
2417
+ this.visit(node.property);
2418
+ }
2419
+ }
2420
+ Property(node) {
2421
+ this.visitProperty(node);
2422
+ }
2423
+ PropertyDefinition(node) {
2424
+ const { computed, key, value } = node;
2425
+ if (computed) {
2426
+ this.visit(key);
2427
+ }
2428
+ if (value) {
2429
+ this.scopeManager.__nestClassFieldInitializerScope(value);
2430
+ this.visit(value);
2431
+ this.close(value);
2432
+ }
2433
+ }
2434
+ StaticBlock(node) {
2435
+ this.scopeManager.__nestClassStaticBlockScope(node);
2436
+ this.visitChildren(node);
2437
+ this.close(node);
2438
+ }
2439
+ MethodDefinition(node) {
2440
+ this.visitProperty(node);
2441
+ }
2442
+ BreakStatement() {
2443
+ }
2444
+ // eslint-disable-line class-methods-use-this -- Desired as instance method
2445
+ ContinueStatement() {
2446
+ }
2447
+ // eslint-disable-line class-methods-use-this -- Desired as instance method
2448
+ LabeledStatement(node) {
2449
+ this.visit(node.body);
2450
+ }
2451
+ ForStatement(node) {
2452
+ if (node.init && node.init.type === Syntax3.VariableDeclaration && node.init.kind !== "var") {
2453
+ this.scopeManager.__nestForScope(node);
2454
+ }
2455
+ this.visitChildren(node);
2456
+ this.close(node);
2457
+ }
2458
+ ClassExpression(node) {
2459
+ this.visitClass(node);
2460
+ }
2461
+ ClassDeclaration(node) {
2462
+ this.visitClass(node);
2463
+ }
2464
+ CallExpression(node) {
2465
+ if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax3.Identifier && node.callee.name === "eval") {
2466
+ this.currentScope().variableScope.__detectEval();
2467
+ }
2468
+ this.visitChildren(node);
2469
+ }
2470
+ BlockStatement(node) {
2471
+ if (this.scopeManager.__isES6()) {
2472
+ this.scopeManager.__nestBlockScope(node);
2473
+ }
2474
+ this.visitChildren(node);
2475
+ this.close(node);
2476
+ }
2477
+ ThisExpression() {
2478
+ this.currentScope().variableScope.__detectThis();
2479
+ }
2480
+ WithStatement(node) {
2481
+ this.visit(node.object);
2482
+ this.scopeManager.__nestWithScope(node);
2483
+ this.visit(node.body);
2484
+ this.close(node);
2485
+ }
2486
+ VariableDeclaration(node) {
2487
+ const variableTargetScope = node.kind === "var" ? this.currentScope().variableScope : this.currentScope();
2488
+ for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
2489
+ const decl = node.declarations[i];
2490
+ this.visitVariableDeclaration(
2491
+ variableTargetScope,
2492
+ variable_default.Variable,
2493
+ node,
2494
+ i
2495
+ );
2496
+ if (decl.init) {
2497
+ this.visit(decl.init);
2498
+ }
2499
+ }
2500
+ }
2501
+ // sec 13.11.8
2502
+ SwitchStatement(node) {
2503
+ this.visit(node.discriminant);
2504
+ if (this.scopeManager.__isES6()) {
2505
+ this.scopeManager.__nestSwitchScope(node);
2506
+ }
2507
+ for (let i = 0, iz = node.cases.length; i < iz; ++i) {
2508
+ this.visit(node.cases[i]);
2509
+ }
2510
+ this.close(node);
2511
+ }
2512
+ FunctionDeclaration(node) {
2513
+ this.visitFunction(node);
2514
+ }
2515
+ FunctionExpression(node) {
2516
+ this.visitFunction(node);
2517
+ }
2518
+ ForOfStatement(node) {
2519
+ this.visitForIn(node);
2520
+ }
2521
+ ForInStatement(node) {
2522
+ this.visitForIn(node);
2523
+ }
2524
+ ArrowFunctionExpression(node) {
2525
+ this.visitFunction(node);
2526
+ }
2527
+ ImportDeclaration(node) {
2528
+ assert(
2529
+ this.scopeManager.__isES6() && this.scopeManager.isModule(),
2530
+ "ImportDeclaration should appear when the mode is ES6 and in the module context."
2531
+ );
2532
+ const importer = new Importer(node, this);
2533
+ importer.visit(node);
2534
+ }
2535
+ visitExportDeclaration(node) {
2536
+ if (node.source) {
2537
+ return;
2538
+ }
2539
+ if (node.declaration) {
2540
+ this.visit(node.declaration);
2541
+ return;
2542
+ }
2543
+ this.visitChildren(node);
2544
+ }
2545
+ // TODO: ExportDeclaration doesn't exist. for bc?
2546
+ ExportDeclaration(node) {
2547
+ this.visitExportDeclaration(node);
2548
+ }
2549
+ ExportAllDeclaration(node) {
2550
+ this.visitExportDeclaration(node);
2551
+ }
2552
+ ExportDefaultDeclaration(node) {
2553
+ this.visitExportDeclaration(node);
2554
+ }
2555
+ ExportNamedDeclaration(node) {
2556
+ this.visitExportDeclaration(node);
2557
+ }
2558
+ ExportSpecifier(node) {
2559
+ const local = node.id || node.local;
2560
+ this.visit(local);
2561
+ }
2562
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
2563
+ MetaProperty() {
2564
+ }
2565
+ JSXIdentifier(node) {
2566
+ if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
2567
+ this.currentScope().__referencing(node);
2568
+ }
2569
+ }
2570
+ JSXMemberExpression(node) {
2571
+ this.visit(node.object);
2572
+ }
2573
+ JSXElement(node) {
2574
+ if (this.scopeManager.__isJSXEnabled()) {
2575
+ this.visit(node.openingElement);
2576
+ node.children.forEach(this.visit, this);
2577
+ } else {
2578
+ this.visitChildren(node);
2579
+ }
2580
+ }
2581
+ JSXOpeningElement(node) {
2582
+ if (this.scopeManager.__isJSXEnabled()) {
2583
+ const nameNode = node.name;
2584
+ const isComponentName = nameNode.type === "JSXIdentifier" && nameNode.name[0].toUpperCase() === nameNode.name[0];
2585
+ const isComponent = isComponentName || nameNode.type === "JSXMemberExpression";
2586
+ if (isComponent) {
2587
+ this.visit(nameNode);
2588
+ }
2589
+ }
2590
+ node.attributes.forEach(this.visit, this);
2591
+ }
2592
+ JSXAttribute(node) {
2593
+ if (node.value) {
2594
+ this.visit(node.value);
2595
+ }
2596
+ }
2597
+ JSXExpressionContainer(node) {
2598
+ this.visit(node.expression);
2599
+ }
2600
+ JSXNamespacedName(node) {
2601
+ this.visit(node.namespace);
2602
+ this.visit(node.name);
2603
+ }
2604
+ };
2605
+ var referencer_default = Referencer;
2606
+
2607
+ // ../../node_modules/.bun/eslint-scope@9.1.2/node_modules/eslint-scope/lib/index.js
2608
+ function defaultOptions() {
2609
+ return {
2610
+ optimistic: false,
2611
+ nodejsScope: false,
2612
+ impliedStrict: false,
2613
+ sourceType: "script",
2614
+ // one of ['script', 'module', 'commonjs']
2615
+ ecmaVersion: 5,
2616
+ childVisitorKeys: null,
2617
+ fallback: "iteration"
2618
+ };
2619
+ }
2620
+ function updateDeeply(target, override) {
2621
+ function isHashObject(value) {
2622
+ return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
2623
+ }
2624
+ for (const key in override) {
2625
+ if (Object.hasOwn(override, key)) {
2626
+ const val = override[key];
2627
+ if (isHashObject(val)) {
2628
+ if (isHashObject(target[key])) {
2629
+ updateDeeply(target[key], val);
2630
+ } else {
2631
+ target[key] = updateDeeply({}, val);
2632
+ }
2633
+ } else {
2634
+ target[key] = val;
2635
+ }
2636
+ }
2637
+ }
2638
+ return target;
2639
+ }
2640
+ function analyze(tree, providedOptions) {
2641
+ const options = updateDeeply(defaultOptions(), providedOptions);
2642
+ const scopeManager = new scope_manager_default(options);
2643
+ const referencer = new referencer_default(options, scopeManager);
2644
+ referencer.visit(tree);
2645
+ assert(
2646
+ scopeManager.__currentScope === null,
2647
+ "currentScope should be null."
2648
+ );
2649
+ return scopeManager;
2650
+ }
2651
+
2652
+ // ../inspector/dist/live.js
2653
+ var require2 = createRequire(import.meta.url);
2654
+ var PLAIN_CLASS = /^[a-zA-Z_-][\w-]*$/;
2655
+ function withAuthoredState(snapshot, sources) {
2656
+ const byHfId = group(sources.htmlTags, (tag) => tag.hfId);
2657
+ const byId = group(sources.htmlTags, (tag) => tag.id);
2658
+ const live = snapshot.nodes;
2659
+ const matched = live.map((node) => sourceTag(node, byHfId, byId));
2660
+ const generated = generatedInsideText(live, matched, sources);
2661
+ const nodes = live.map(
2662
+ (node, index) => generated.has(index) ? steadyGenerated(node, live, generated) : authoredNode(node, matched[index], sources, live)
2663
+ );
2664
+ return { ...snapshot, nodes };
2665
+ }
2666
+ function authoredNode(node, tag, sources, live) {
2667
+ if (!tag) return node;
2668
+ const text = directText(sources, tag) ?? node.text;
2669
+ const id = node.id || tag.id || "";
2670
+ const classes = authoredClasses(node, tag, live);
2671
+ const next = { ...node, text, id };
2672
+ return classes ? { ...next, ...classes } : next;
2673
+ }
2674
+ function generatedInsideText(live, matched, sources) {
2675
+ const generated = /* @__PURE__ */ new Set();
2676
+ for (const [index, tag] of matched.entries()) {
2677
+ if (!tag || !directText(sources, tag)) continue;
2678
+ for (const child of live[index].children)
2679
+ if (!matched[child]) markGenerated(child, live, matched, generated);
2680
+ }
2681
+ return generated;
2682
+ }
2683
+ function markGenerated(index, live, matched, generated) {
2684
+ if (generated.has(index) || matched[index]) return;
2685
+ generated.add(index);
2686
+ for (const child of live[index].children) markGenerated(child, live, matched, generated);
2687
+ }
2688
+ function steadyGenerated(node, live, generated) {
2689
+ const siblings = node.parent === null ? [node] : live[node.parent].children.map((index) => live[index]);
2690
+ const siblingMatchCount = siblings.filter(
2691
+ (other) => generated.has(other.index) && other.tag === node.tag
2692
+ ).length;
2693
+ return {
2694
+ ...node,
2695
+ id: "",
2696
+ classes: [],
2697
+ text: "",
2698
+ generated: true,
2699
+ groupSelector: node.tag,
2700
+ relative: `${node.tag}:nth-child(${node.position})`,
2701
+ siblingMatchCount
2702
+ };
2703
+ }
2704
+ function group(tags, key) {
2705
+ const groups = /* @__PURE__ */ new Map();
2706
+ for (const tag of tags) {
2707
+ const value = key(tag);
2708
+ if (value) groups.set(value, [...groups.get(value) ?? [], tag]);
2709
+ }
2710
+ return groups;
2711
+ }
2712
+ function sourceTag(node, byHfId, byId) {
2713
+ const named = node.hfId && byHfId.get(node.hfId) || node.id && byId.get(node.id) || [];
2714
+ const matches = named.filter((tag) => tag.tag === node.tag);
2715
+ return matches.length === 1 ? matches[0] : void 0;
2716
+ }
2717
+ var RAW_TEXT = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "noembed", "noframes"]);
2718
+ var VOID = /* @__PURE__ */ new Set([
2719
+ "area",
2720
+ "base",
2721
+ "br",
2722
+ "col",
2723
+ "embed",
2724
+ "hr",
2725
+ "img",
2726
+ "input",
2727
+ "link",
2728
+ "meta",
2729
+ "param",
2730
+ "source",
2731
+ "track",
2732
+ "wbr"
2733
+ ]);
2734
+ function directText(sources, tag) {
2735
+ const text = sources.files.get(tag.file)?.text;
2736
+ if (text === void 0) return null;
2737
+ if (VOID.has(tag.tag)) return "";
2738
+ return normalizedInner(text, tag);
2739
+ }
2740
+ function normalizedInner(text, tag) {
2741
+ const inner = sliceUntilClose(text, tag.end, tag.tag);
2742
+ if (inner === null) return null;
2743
+ return decodeEntities(textNodes(inner)).replace(/\s+/g, " ").trim();
2744
+ }
2745
+ function sliceUntilClose(html, from, tag) {
2746
+ const end = closeOffset(html, from, tag, 1);
2747
+ return end === null ? null : html.slice(from, end);
2748
+ }
2749
+ function closeOffset(html, from, tag, depth) {
2750
+ let cursor = from;
2751
+ let level = depth;
2752
+ for (; ; ) {
2753
+ const step = closeStep(html, cursor, tag, level);
2754
+ if (!step) return null;
2755
+ if (step.done) return step.at;
2756
+ cursor = step.at;
2757
+ level = step.depth;
2758
+ }
2759
+ }
2760
+ function closeStep(html, from, tag, depth) {
2761
+ const found2 = nextMarkup(html, from);
2762
+ if (!found2) return null;
2763
+ if (found2.kind !== "tag") return { at: found2.end, depth, done: false };
2764
+ if (isRawOpen(found2)) return rawStep(html, found2, depth);
2765
+ return tagStep(found2, tag, depth);
2766
+ }
2767
+ function isRawOpen(found2) {
2768
+ return !found2.closing && RAW_TEXT.has(found2.name);
2769
+ }
2770
+ function rawStep(html, found2, depth) {
2771
+ const rawEnd = rawElementEnd(html.toLowerCase(), found2.name, found2.bracket);
2772
+ if (rawEnd < 0) return null;
2773
+ return { at: rawEnd, depth, done: false };
2774
+ }
2775
+ function tagStep(found2, tag, depth) {
2776
+ const same = found2.name === tag && !VOID.has(found2.name);
2777
+ if (!same || !found2.closing) return openStep(found2, depth, same);
2778
+ return closingStep(found2, depth);
2779
+ }
2780
+ function closingStep(found2, depth) {
2781
+ if (depth === 1) return { at: found2.start, depth, done: true };
2782
+ return { at: found2.bracket + 1, depth: depth - 1, done: false };
2783
+ }
2784
+ function openStep(found2, depth, same) {
2785
+ const nextDepth = same ? depth + 1 : depth;
2786
+ return { at: found2.bracket + 1, depth: nextDepth, done: false };
2787
+ }
2788
+ function textNodes(inner) {
2789
+ const found2 = nextMarkup(inner, 0);
2790
+ if (!found2) return inner;
2791
+ return inner.slice(0, found2.start) + textAfter(inner, found2);
2792
+ }
2793
+ function textAfter(inner, found2) {
2794
+ if (found2.kind !== "tag") return textNodes(inner.slice(found2.end));
2795
+ return textAfterTag(inner, found2);
2796
+ }
2797
+ function textAfterTag(inner, found2) {
2798
+ if (skipsTag(found2)) return textNodes(inner.slice(found2.bracket + 1));
2799
+ if (RAW_TEXT.has(found2.name)) return textAfterRaw(inner, found2);
2800
+ return textAfterChild(inner, found2);
2801
+ }
2802
+ function skipsTag(found2) {
2803
+ return found2.closing || VOID.has(found2.name);
2804
+ }
2805
+ function textAfterRaw(inner, found2) {
2806
+ const rawEnd = rawElementEnd(inner.toLowerCase(), found2.name, found2.bracket);
2807
+ return textNodes(inner.slice(rawEnd < 0 ? inner.length : rawEnd));
2808
+ }
2809
+ function textAfterChild(inner, found2) {
2810
+ const child = sliceUntilClose(inner, found2.bracket + 1, found2.name);
2811
+ if (child === null) return "";
2812
+ const closeBracket = inner.indexOf(">", found2.bracket + 1 + child.length);
2813
+ return textNodes(inner.slice(closeBracket < 0 ? inner.length : closeBracket + 1));
2814
+ }
2815
+ function nextMarkup(html, from) {
2816
+ const start = html.indexOf("<", from);
2817
+ if (start < 0) return null;
2818
+ return markupAt(html, start);
2819
+ }
2820
+ function markupAt(html, start) {
2821
+ const skipped = skippedMarkup(html, start);
2822
+ if (skipped) return skipped;
2823
+ return tagMarkup(html, start);
2824
+ }
2825
+ function skippedMarkup(html, start) {
2826
+ if (html.startsWith("<!--", start)) return boundedSkip(html, start, "-->", 4);
2827
+ if (html.startsWith("<!", start) || html.startsWith("<?", start))
2828
+ return boundedSkip(html, start, ">", 1);
2829
+ return null;
2830
+ }
2831
+ function boundedSkip(html, start, marker, from) {
2832
+ const end = html.indexOf(marker, start + from);
2833
+ return end < 0 ? null : { kind: "skip", start, end: end + marker.length };
2834
+ }
2835
+ function tagMarkup(html, start) {
2836
+ const name = /^<\/?([a-zA-Z][^\s/>]*)/.exec(html.slice(start, start + 128));
2837
+ if (!name) return { kind: "skip", start, end: start + 1 };
2838
+ const bracket = closingBracket(html, start + name[0].length);
2839
+ if (bracket < 0) return null;
2840
+ return {
2841
+ kind: "tag",
2842
+ start,
2843
+ name: name[1].toLowerCase(),
2844
+ closing: html[start + 1] === "/",
2845
+ bracket
2846
+ };
2847
+ }
2848
+ function rawElementEnd(lower, tag, openBracket) {
2849
+ const marker = `</${tag}`;
2850
+ const at2 = nextRawClose(lower, marker, openBracket + 1);
2851
+ if (at2 < 0) return -1;
2852
+ const bracket = lower.indexOf(">", at2 + marker.length);
2853
+ return bracket < 0 ? -1 : bracket + 1;
2854
+ }
2855
+ function nextRawClose(lower, marker, from) {
2856
+ const at2 = lower.indexOf(marker, from);
2857
+ if (at2 < 0) return -1;
2858
+ const next = lower[at2 + marker.length];
2859
+ if (closesRawText(next)) return at2;
2860
+ return nextRawClose(lower, marker, at2 + marker.length);
2861
+ }
2862
+ function closesRawText(next) {
2863
+ return next !== void 0 && /[\s/>]/.test(next);
2864
+ }
2865
+ function closingBracket(html, from) {
2866
+ let quote = "";
2867
+ for (let i = from; i < html.length; i++) {
2868
+ const c = html[i];
2869
+ if (quote) quote = c === quote ? "" : quote;
2870
+ else if (c === '"' || c === "'") quote = c;
2871
+ else if (c === ">") return i;
2872
+ }
2873
+ return -1;
2874
+ }
2875
+ function decodeEntities(value) {
2876
+ return value.replace(
2877
+ /&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos|nbsp);/gi,
2878
+ (entity, body) => {
2879
+ const named = {
2880
+ amp: "&",
2881
+ lt: "<",
2882
+ gt: ">",
2883
+ quot: '"',
2884
+ apos: "'",
2885
+ nbsp: " "
2886
+ };
2887
+ const lower = body.toLowerCase();
2888
+ if (lower in named) return named[lower];
2889
+ const code = Number.parseInt(
2890
+ lower.slice(lower.startsWith("#x") ? 2 : 1),
2891
+ lower.startsWith("#x") ? 16 : 10
2892
+ );
2893
+ return Number.isInteger(code) && code >= 0 && code <= 1114111 ? String.fromCodePoint(code) : entity;
2894
+ }
2895
+ );
2896
+ }
2897
+ function authoredClasses(node, tag, live) {
2898
+ const classes = [...tag.classes];
2899
+ if (classes.join(" ") === node.classes.join(" ")) return null;
2900
+ if (!classes.every((c) => PLAIN_CLASS.test(c) && node.classes.includes(c))) return null;
2901
+ const simple = `${node.tag}${classes.map((c) => `.${c}`).join("")}`;
2902
+ const siblings = node.parent === null ? [node] : live[node.parent].children.map((i) => live[i]);
2903
+ const siblingMatchCount = siblings.filter(
2904
+ (other) => other.tag === node.tag && classes.every((c) => other.classes.includes(c))
2905
+ ).length;
2906
+ const relative2 = node.relative.startsWith("#") ? node.relative : siblingMatchCount === 1 ? simple : `${node.tag}:nth-child(${node.position})`;
2907
+ return { classes, groupSelector: simple, siblingMatchCount, relative: relative2 };
2908
+ }
2909
+ function collectElementDom() {
2910
+ const excluded2 = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "LINK", "META"]);
2911
+ const nodes = [];
2912
+ const paths = /* @__PURE__ */ new Map();
2913
+ const siblingGroups = /* @__PURE__ */ new WeakMap();
2914
+ function siblingCount(element, selector) {
2915
+ const owner = element.parentElement ?? element;
2916
+ let counts = siblingGroups.get(owner);
2917
+ if (!counts) {
2918
+ counts = /* @__PURE__ */ new Map();
2919
+ siblingGroups.set(owner, counts);
2920
+ }
2921
+ if (!counts.has(selector)) {
2922
+ const siblings = element.parentElement ? [...element.parentElement.children] : [element];
2923
+ counts.set(selector, siblings.filter((sibling) => sibling.matches(selector)).length);
2924
+ }
2925
+ return counts.get(selector);
2926
+ }
2927
+ const quote = (value) => JSON.stringify(value);
2928
+ function path(element) {
2929
+ if (paths.has(element)) return paths.get(element);
2930
+ const candidates = [];
2931
+ if (element.id) candidates.push(`#${CSS.escape(element.id)}`);
2932
+ const hfId = element.getAttribute("data-hf-id");
2933
+ if (hfId) candidates.push(`[data-hf-id=${quote(hfId)}]`);
2934
+ const unique = candidates.find((selector2) => document.querySelectorAll(selector2).length === 1);
2935
+ const parent = element.parentElement;
2936
+ const tag = element.localName;
2937
+ const position2 = parent ? [...parent.children].indexOf(element) + 1 : 1;
2938
+ const selector = unique ?? (parent ? `${path(parent)} > ${CSS.escape(tag)}:nth-child(${position2})` : CSS.escape(tag));
2939
+ paths.set(element, selector);
2940
+ return selector;
2941
+ }
2942
+ function visit(element, parent) {
2943
+ if (excluded2.has(element.tagName)) return;
2944
+ const selector = path(element);
2945
+ if (document.querySelectorAll(selector).length !== 1 || document.querySelector(selector) !== element) {
2946
+ throw new Error(`Element map selector does not resolve uniquely: ${selector}`);
2947
+ }
2948
+ const classes = [...element.classList].sort();
2949
+ const tag = element.localName;
2950
+ const simple = `${CSS.escape(tag)}${classes.map((value) => `.${CSS.escape(value)}`).join("")}`;
2951
+ const siblings = element.parentElement ? [...element.parentElement.children] : [element];
2952
+ const index = nodes.length;
2953
+ const node = {
2954
+ index,
2955
+ parent,
2956
+ selector,
2957
+ tag,
2958
+ id: element.id,
2959
+ hfId: element.getAttribute("data-hf-id"),
2960
+ classes,
2961
+ composition: element.getAttribute("data-composition-id"),
2962
+ compositionSrc: element.getAttribute("data-composition-src"),
2963
+ text: [...element.childNodes].filter((child) => child.nodeType === 3).map((child) => child.textContent).join("").replace(/\s+/g, " ").trim(),
2964
+ media: ["img", "video", "audio", "source", "iframe"].includes(tag) ? element.getAttribute("src") : null,
2965
+ relative: element.id && document.querySelectorAll(`#${CSS.escape(element.id)}`).length === 1 ? `#${CSS.escape(element.id)}` : siblingCount(element, simple) === 1 ? simple : `${CSS.escape(tag)}:nth-child(${siblings.indexOf(element) + 1})`,
2966
+ position: siblings.indexOf(element) + 1,
2967
+ groupSelector: simple,
2968
+ siblingMatchCount: siblingCount(element, simple),
2969
+ children: []
2970
+ };
2971
+ nodes.push(node);
2972
+ for (const child of element.children) {
2973
+ const childIndex = visit(child, index);
2974
+ if (childIndex !== void 0) node.children.push(childIndex);
2975
+ }
2976
+ return index;
2977
+ }
2978
+ if (document.body) visit(document.body, null);
2979
+ return {
2980
+ generation: window.__hfLiveInspection?.generation ?? null,
2981
+ nodes,
2982
+ limitations: {
2983
+ canvas: nodes.filter((node) => node.tag === "canvas").length,
2984
+ iframes: nodes.filter((node) => node.tag === "iframe").length,
2985
+ shadowRoots: [...document.querySelectorAll("*")].filter((node) => node.shadowRoot).length
2986
+ }
2987
+ };
2988
+ }
2989
+ function signature(node, nodes) {
2990
+ return [
2991
+ node.tag,
2992
+ node.id,
2993
+ node.classes,
2994
+ node.composition,
2995
+ node.compositionSrc,
2996
+ node.text,
2997
+ node.media,
2998
+ node.children.map((index) => signature(nodes[index], nodes))
2999
+ ];
3000
+ }
3001
+ function mediaIdentifier(source) {
3002
+ if (source.startsWith("data:")) {
3003
+ const mime = source.slice(5).split(/[;,]/, 1)[0] || "text/plain";
3004
+ const hash = createHash("sha256").update(source).digest("hex").slice(0, 16);
3005
+ return `data:${mime}#sha256:${hash}`;
3006
+ }
3007
+ if (source.startsWith("blob:")) return "blob:runtime";
3008
+ return source;
3009
+ }
3010
+ function childPlaces(members) {
3011
+ const runs = [];
3012
+ let start = members[0].position;
3013
+ let previous = start;
3014
+ for (const member of members.slice(1)) {
3015
+ if (member.position === previous + 1) {
3016
+ previous = member.position;
3017
+ continue;
3018
+ }
3019
+ runs.push(start === previous ? `${start}` : `${start}-${previous}`);
3020
+ start = previous = member.position;
3021
+ }
3022
+ runs.push(start === previous ? `${start}` : `${start}-${previous}`);
3023
+ return runs.join(",");
3024
+ }
3025
+ function describe(node, selector, count, places = "") {
3026
+ const fields = [selector];
3027
+ if (!selector.startsWith(node.tag)) fields.push(node.tag);
3028
+ if (count > 1) fields.push(`\xD7${count}${places ? ` @${places}` : ""}`);
3029
+ if (node.generated) fields.push("(generated)");
3030
+ if (node.id && selector !== `#${node.id}`) fields.push(`id=${JSON.stringify(node.id)}`);
3031
+ if (node.classes.length && !selector.includes("."))
3032
+ fields.push(`class=${JSON.stringify(node.classes.join(" "))}`);
3033
+ if (node.text) fields.push(JSON.stringify(node.text));
3034
+ if (node.media) fields.push(`src=${JSON.stringify(mediaIdentifier(node.media))}`);
3035
+ if (node.composition) fields.push(`composition=${JSON.stringify(node.composition)}`);
3036
+ if (node.compositionSrc) fields.push(`file=${JSON.stringify(node.compositionSrc)}`);
3037
+ return fields.join(" ");
3038
+ }
3039
+ function formatElementMap(snapshot, { file = "index.html" } = {}) {
3040
+ const { nodes } = snapshot;
3041
+ const lines = [`File: ${JSON.stringify(file)}`];
3042
+ const entries = [];
3043
+ function siblings(indices, depth) {
3044
+ const groups = [];
3045
+ for (const index of indices) {
3046
+ const node = nodes[index];
3047
+ const key = JSON.stringify(signature(node, nodes));
3048
+ const previous = groups.at(-1);
3049
+ if (!node.id && previous?.key === key) previous.indices.push(index);
3050
+ else groups.push({ key, indices: [index] });
3051
+ }
3052
+ for (const group2 of groups) {
3053
+ const members = group2.indices.map((index) => nodes[index]);
3054
+ const node = members[0];
3055
+ const exactGroup = members.length > 1 && node.siblingMatchCount === members.length;
3056
+ if (members.length > 1 && !exactGroup) {
3057
+ for (const member of members) emit([member], depth);
3058
+ } else emit(members, depth);
3059
+ }
3060
+ }
3061
+ function emit(members, depth, repeatedParents = false) {
3062
+ const node = members[0];
3063
+ const selector = members.length > 1 && !repeatedParents ? node.groupSelector : node.relative;
3064
+ const places = members.length > 1 && !repeatedParents ? childPlaces(members) : "";
3065
+ lines.push(`${" ".repeat(depth)}${describe(node, selector, members.length, places)}`);
3066
+ entries.push({
3067
+ line: lines.length,
3068
+ selectors: members.map((member) => member.selector),
3069
+ nodeIndices: members.map((member) => member.index)
3070
+ });
3071
+ if (members.length === 1) {
3072
+ siblings(node.children, depth + 1);
3073
+ return;
3074
+ }
3075
+ for (let position2 = 0; position2 < node.children.length; position2++) {
3076
+ emit(
3077
+ members.map((member) => nodes[member.children[position2]]),
3078
+ depth + 1,
3079
+ true
3080
+ );
3081
+ }
3082
+ }
3083
+ siblings(
3084
+ nodes.filter((node) => node.parent === null).map((node) => node.index),
3085
+ 0
3086
+ );
3087
+ const { canvas, iframes, shadowRoots } = snapshot.limitations;
3088
+ if (canvas || iframes || shadowRoots)
3089
+ lines.push(
3090
+ `Unmapped contents: canvas=${canvas}, iframe=${iframes}, shadow-root=${shadowRoots}.`
3091
+ );
3092
+ const covered = entries.flatMap((entry) => entry.nodeIndices);
3093
+ if (covered.length !== nodes.length || new Set(covered).size !== nodes.length)
3094
+ throw new Error("Element map coverage mismatch");
3095
+ return {
3096
+ text: `${lines.join("\n")}
3097
+ `,
3098
+ entries,
3099
+ elementCount: nodes.length,
3100
+ coveredCount: covered.length
3101
+ };
3102
+ }
3103
+ function sourceDependencies(text) {
3104
+ try {
3105
+ const ast = parse3(text, {
3106
+ ecmaVersion: "latest",
3107
+ sourceType: "module",
3108
+ allowReturnOutsideFunction: true,
3109
+ ranges: true
3110
+ });
3111
+ const scopes = analyze(ast, {
3112
+ ecmaVersion: 2022,
3113
+ sourceType: "module",
3114
+ optimistic: false
3115
+ });
3116
+ const references = scopes.scopes.flatMap(
3117
+ (scope) => scope.references.flatMap((reference) => {
3118
+ const location = reference.identifier.range;
3119
+ if (!reference.isRead() || !location) return [];
3120
+ const definitions = (reference.resolved?.defs ?? []).flatMap((definition) => {
3121
+ const node = definition.type === "Variable" ? definition.parent : definition.type === "FunctionName" ? definition.node : null;
3122
+ return node?.range ? [{ start: node.range[0], end: node.range[1] }] : [];
3123
+ });
3124
+ return definitions.length ? [{ start: location[0], end: location[1], definitions }] : [];
3125
+ })
3126
+ );
3127
+ return (range) => {
3128
+ const pending = [range];
3129
+ const found2 = /* @__PURE__ */ new Map();
3130
+ for (let index = 0; index < pending.length; index++) {
3131
+ const current = pending[index];
3132
+ for (const reference of references) {
3133
+ if (reference.start < current.start || reference.end > current.end) continue;
3134
+ for (const { start, end } of reference.definitions) {
3135
+ if (start >= range.start && end <= range.end) continue;
3136
+ const key = `${start}:${end}`;
3137
+ if (found2.has(key)) continue;
3138
+ const dependency = { start, end };
3139
+ found2.set(key, dependency);
3140
+ pending.push(dependency);
3141
+ }
3142
+ }
3143
+ }
3144
+ return [...found2.values()].sort((a, b) => a.start - b.start);
3145
+ };
3146
+ } catch {
3147
+ return () => [];
3148
+ }
3149
+ }
3150
+ var PREVIEW_IGNORED_DIRS = /* @__PURE__ */ new Set([
3151
+ ".cache",
3152
+ ".git",
3153
+ ".hyperframes",
3154
+ ".next",
3155
+ ".thumbnails",
3156
+ ".transcode-cache",
3157
+ ".vite",
3158
+ ".waveform-cache",
3159
+ "build",
3160
+ "coverage",
3161
+ "dist",
3162
+ "node_modules",
3163
+ "outputs",
3164
+ "renders"
3165
+ ]);
3166
+ var starts = (text) => [0, ...[...text.matchAll(/\n/g)].map((m) => m.index + 1)];
3167
+ function position(lines, offset) {
3168
+ let lo = 0, hi = lines.length - 1;
3169
+ while (lo < hi) {
3170
+ const mid = Math.ceil((lo + hi) / 2);
3171
+ if (lines[mid] <= offset) lo = mid;
3172
+ else hi = mid - 1;
3173
+ }
3174
+ return { line: lo + 1, column: offset - lines[lo] };
3175
+ }
3176
+ function occurrences(text, needle) {
3177
+ const hits = [];
3178
+ if (!needle) return hits;
3179
+ let at2 = text.indexOf(needle);
3180
+ while (at2 >= 0) {
3181
+ hits.push(at2);
3182
+ at2 = text.indexOf(needle, at2 + needle.length);
3183
+ }
3184
+ return hits;
3185
+ }
3186
+ function realPath(path) {
3187
+ try {
3188
+ return realpathSync(path);
3189
+ } catch {
3190
+ return resolve2(path);
3191
+ }
3192
+ }
3193
+ var SHOWN_WHOLE = 2e3;
3194
+ var excluded = /* @__PURE__ */ new Set([...PREVIEW_IGNORED_DIRS, ".agents", ".claude", "evidence", "snapshots"]);
3195
+ function sourceFiles(project) {
3196
+ const files = [];
3197
+ function visit(dir) {
3198
+ for (const item of readdirSync(dir, { withFileTypes: true })) {
3199
+ if (excluded.has(item.name) || item.isSymbolicLink()) continue;
3200
+ const path = join(dir, item.name);
3201
+ if (item.isDirectory()) visit(path);
3202
+ else if ([".html", ".js", ".mjs", ".css", ".json"].includes(extname(path))) files.push(path);
3203
+ }
3204
+ }
3205
+ visit(project);
3206
+ return files.sort();
3207
+ }
3208
+ var HF_ID_ATTRIBUTE = /\sdata-hf-id\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/g;
3209
+ function fingerprint(project, { ignoreHfIds = false } = {}) {
3210
+ const hash = createHash2("sha256");
3211
+ for (const path of sourceFiles(project)) {
3212
+ hash.update(relative(project, path));
3213
+ hash.update(
3214
+ ignoreHfIds && extname(path) === ".html" ? readFileSync(path, "utf8").replace(HF_ID_ATTRIBUTE, "") : readFileSync(path)
3215
+ );
3216
+ }
3217
+ return hash.digest("hex");
3218
+ }
3219
+ function statements(text) {
3220
+ const result = [];
3221
+ function visit(value) {
3222
+ if (!value || typeof value !== "object") return;
3223
+ if (Array.isArray(value)) {
3224
+ value.forEach(visit);
3225
+ return;
3226
+ }
3227
+ if ("type" in value && "start" in value && "end" in value && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number") {
3228
+ if ([
3229
+ "ExpressionStatement",
3230
+ "VariableDeclaration",
3231
+ "ReturnStatement",
3232
+ "ThrowStatement",
3233
+ "FunctionDeclaration"
3234
+ ].includes(value.type))
3235
+ result.push({ start: value.start, end: value.end, type: value.type });
3236
+ }
3237
+ for (const entry of Object.values(value)) if (typeof entry === "object") visit(entry);
3238
+ }
3239
+ try {
3240
+ const ast = parse2(text, {
3241
+ ecmaVersion: "latest",
3242
+ sourceType: "module",
3243
+ allowReturnOutsideFunction: true
3244
+ });
3245
+ visit(ast);
3246
+ } catch {
3247
+ }
3248
+ return result;
3249
+ }
3250
+ function rawTextElements(text, tag) {
3251
+ const lower = text.toLowerCase();
3252
+ const opening = `<${tag}`;
3253
+ const closing = `</${tag}`;
3254
+ const elements = [];
3255
+ let cursor = 0;
3256
+ while (cursor < text.length) {
3257
+ const start = lower.indexOf(opening, cursor);
3258
+ if (start < 0) break;
3259
+ const boundary = lower[start + opening.length];
3260
+ if (boundary && boundary !== ">" && !/\s/.test(boundary)) {
3261
+ cursor = start + opening.length;
3262
+ continue;
3263
+ }
3264
+ const contentStart = lower.indexOf(">", start + opening.length);
3265
+ if (contentStart < 0) break;
3266
+ let close = lower.indexOf(closing, contentStart + 1);
3267
+ let closeEnd = -1;
3268
+ while (close >= 0) {
3269
+ let at2 = close + closing.length;
3270
+ while (at2 < lower.length && /\s/.test(lower[at2])) at2++;
3271
+ if (lower[at2] === ">") {
3272
+ closeEnd = at2 + 1;
3273
+ break;
3274
+ }
3275
+ close = lower.indexOf(closing, at2);
3276
+ }
3277
+ if (close < 0) break;
3278
+ elements.push({
3279
+ attributes: text.slice(start + opening.length, contentStart),
3280
+ content: text.slice(contentStart + 1, close),
3281
+ contentStart: contentStart + 1
3282
+ });
3283
+ cursor = closeEnd;
3284
+ }
3285
+ return elements;
3286
+ }
3287
+ function nesting(text) {
3288
+ const parents = /* @__PURE__ */ new Map();
3289
+ const open = [];
3290
+ const parser = new Parser({
3291
+ onopentag() {
3292
+ parents.set(parser.startIndex, open.at(-1));
3293
+ open.push(parser.startIndex);
3294
+ },
3295
+ onclosetag() {
3296
+ open.pop();
3297
+ }
3298
+ });
3299
+ parser.write(text);
3300
+ parser.end();
3301
+ return parents;
3302
+ }
3303
+ function htmlTagsOf(file, text) {
3304
+ const parents = nesting(text);
3305
+ return [...text.matchAll(/<([a-z][\w-]*)\b[^>]*>/gi)].map((m) => {
3306
+ const attr = (name) => {
3307
+ const quoted = new RegExp(`\\s${name}\\s*=\\s*["']([^"']*)["']`, "i").exec(m[0]);
3308
+ if (quoted) return quoted[1];
3309
+ return new RegExp(`\\s${name}\\s*=\\s*([^\\s"'=<>]+)`, "i").exec(m[0])?.[1];
3310
+ };
3311
+ return {
3312
+ file,
3313
+ start: m.index,
3314
+ end: m.index + m[0].length,
3315
+ tag: m[1].toLowerCase(),
3316
+ id: attr("id"),
3317
+ hfId: attr("data-hf-id"),
3318
+ classes: (attr("class") ?? "").split(/\s+/).filter(Boolean),
3319
+ compositionId: attr("data-composition-id"),
3320
+ compositionSrc: attr("data-composition-src"),
3321
+ inMarkup: parents.has(m.index),
3322
+ parent: parents.get(m.index)
3323
+ };
3324
+ });
3325
+ }
3326
+ function authoredHtml(project) {
3327
+ const html = { files: /* @__PURE__ */ new Map(), htmlTags: [] };
3328
+ for (const path of sourceFiles(project)) {
3329
+ const file = relative(project, path);
3330
+ if (!file.endsWith(".html") || /(?:^|\/)(?:vendor|lib)\//.test(file)) continue;
3331
+ const text = readFileSync(path, "utf8");
3332
+ if (text.length > 2e6) continue;
3333
+ html.files.set(file, { text });
3334
+ html.htmlTags.push(...htmlTagsOf(file, text));
3335
+ }
3336
+ return html;
3337
+ }
3338
+ var Sources = class {
3339
+ constructor(project, served) {
3340
+ this.project = project;
3341
+ const root = realPath(project);
3342
+ const bundled = served && new Set([...served].map((path) => relative(root, realPath(path))));
3343
+ for (const path of sourceFiles(project)) {
3344
+ const file = relative(project, path);
3345
+ if (/(?:^|\/)(?:vendor|lib)\//.test(file)) continue;
3346
+ if (bundled && !bundled.has(file)) continue;
3347
+ const fd = openSync(path, "r");
3348
+ let text;
3349
+ try {
3350
+ if (fstatSync(fd).size > 2e6) continue;
3351
+ text = readFileSync(fd, "utf8");
3352
+ } finally {
3353
+ closeSync(fd);
3354
+ }
3355
+ this.files.set(file, { text, lines: starts(text) });
3356
+ if (/\.m?js$/.test(file)) this.addChunk(file, text, 0);
3357
+ if (/\.css$/.test(file)) this.addCss(file, text, 0);
3358
+ if (/\.html$/.test(file)) {
3359
+ for (const script of rawTextElements(text, "script"))
3360
+ if (!/\bsrc\s*=/.test(script.attributes))
3361
+ this.addChunk(file, script.content, script.contentStart);
3362
+ for (const style of rawTextElements(text, "style"))
3363
+ this.addCss(file, style.content, style.contentStart);
3364
+ this.htmlTags.push(...htmlTagsOf(file, text));
3365
+ }
3366
+ }
3367
+ }
3368
+ project;
3369
+ files = /* @__PURE__ */ new Map();
3370
+ chunks = [];
3371
+ cssRules = [];
3372
+ htmlTags = [];
3373
+ addChunk(file, source, offset) {
3374
+ const text = source.trim();
3375
+ const lead = source.length - source.trimStart().length;
3376
+ if (text) {
3377
+ let ranges;
3378
+ let dependencies;
3379
+ this.chunks.push({
3380
+ file,
3381
+ text,
3382
+ offset: offset + lead,
3383
+ get statements() {
3384
+ return ranges ??= statements(text);
3385
+ },
3386
+ dependencies(range) {
3387
+ return (dependencies ??= sourceDependencies(text))(range);
3388
+ }
3389
+ });
3390
+ }
3391
+ }
3392
+ addCss(file, text, offset) {
3393
+ try {
3394
+ postcss.parse(text).walkRules((rule) => {
3395
+ const start = rule.source?.start?.offset;
3396
+ const end = rule.source?.end?.offset;
3397
+ if (start != null && end != null)
3398
+ this.cssRules.push({
3399
+ id: `css:${this.cssRules.length}`,
3400
+ selector: rule.selector,
3401
+ file,
3402
+ start: offset + start,
3403
+ end: offset + end + 1
3404
+ });
3405
+ });
3406
+ } catch {
3407
+ }
3408
+ }
3409
+ slice(file, start, end, kind, target) {
3410
+ const source = this.files.get(file);
3411
+ if (!source) return null;
3412
+ const first = position(source.lines, start).line;
3413
+ const last = position(source.lines, Math.max(start, end - 1)).line;
3414
+ const code = source.text.slice(
3415
+ source.lines[first - 1],
3416
+ source.lines[last] ?? source.text.length
3417
+ );
3418
+ return {
3419
+ id: `${file}:${first}-${last}`,
3420
+ file,
3421
+ startLine: first,
3422
+ endLine: last,
3423
+ kind: [kind],
3424
+ targets: [target],
3425
+ code,
3426
+ uniqueInFile: occurrences(source.text, code).length === 1
3427
+ };
3428
+ }
3429
+ markup(element, target) {
3430
+ const tag = this.markupTag(element);
3431
+ return tag ? this.slice(tag.file, tag.start, tag.end, "html opening tag", target) : null;
3432
+ }
3433
+ markupTag(element) {
3434
+ const sameTag = this.htmlTags.filter((tag) => tag.tag === element.tag);
3435
+ const byHfId = element.hfId ? sameTag.filter((tag) => tag.hfId === element.hfId) : [];
3436
+ const tags = byHfId.length ? byHfId : sameTag.filter(
3437
+ (tag) => element.id ? tag.id === element.id : element.classes.length > 0 && element.classes.every((c) => tag.classes.includes(c))
3438
+ );
3439
+ return tags.length === 1 ? tags[0] : null;
3440
+ }
3441
+ nestingIndex;
3442
+ get nested() {
3443
+ if (this.nestingIndex) return this.nestingIndex;
3444
+ const tagAt = new Map(this.htmlTags.map((t) => [`${t.file}:${t.start}`, t]));
3445
+ const hostsOf = /* @__PURE__ */ new Map();
3446
+ for (const host of this.htmlTags.filter((t) => t.inMarkup && t.compositionSrc)) {
3447
+ const file = this.mountedFile(host);
3448
+ if (file) hostsOf.set(file, [...hostsOf.get(file) ?? [], host]);
3449
+ }
3450
+ return this.nestingIndex = { tagAt, hostsOf };
3451
+ }
3452
+ fileByPath;
3453
+ mountedFile(host) {
3454
+ const files = this.fileByPath ??= new Map(
3455
+ [...this.files.keys()].map((file) => [file.replace(/\\/g, "/"), file])
3456
+ );
3457
+ const src = (host.compositionSrc ?? "").split(/[?#]/)[0].replace(/\\/g, "/");
3458
+ const path = [
3459
+ posix.normalize(src.replace(/^\.?\//, "")),
3460
+ posix.join(posix.dirname(host.file.replace(/\\/g, "/")), src)
3461
+ ].find((file) => files.has(file));
3462
+ return path === void 0 ? void 0 : files.get(path);
3463
+ }
3464
+ compositions(tag, target) {
3465
+ const { tagAt, hostsOf } = this.nested;
3466
+ const shown2 = /* @__PURE__ */ new Set([tag]);
3467
+ const result = [];
3468
+ const show = (t, kind) => {
3469
+ if (shown2.has(t)) return false;
3470
+ shown2.add(t);
3471
+ const snippet = this.slice(t.file, t.start, t.end, kind, target);
3472
+ if (snippet) result.push(snippet);
3473
+ return true;
3474
+ };
3475
+ const mounted = tag.compositionSrc && this.mountedFile(tag);
3476
+ const root = mounted && this.htmlTags.find(
3477
+ (t) => t.file === mounted && t.inMarkup && t.compositionId && (!tag.compositionId || t.compositionId === tag.compositionId)
3478
+ );
3479
+ if (root) show(root, "composition root");
3480
+ const parentOf = (t) => t.parent === void 0 ? void 0 : tagAt.get(`${t.file}:${t.parent}`);
3481
+ const climb = [{ tag, candidate: false }];
3482
+ for (let from = climb.shift(); from; from = climb.shift()) {
3483
+ for (let at2 = parentOf(from.tag); at2; at2 = parentOf(at2))
3484
+ if (at2.compositionId)
3485
+ show(at2, from.candidate ? "composition root candidate" : "composition root");
3486
+ const hosts = hostsOf.get(from.tag.file) ?? [];
3487
+ const candidate = from.candidate || hosts.length > 1;
3488
+ for (const host of hosts)
3489
+ if (show(host, candidate ? "composition host candidate" : "composition host"))
3490
+ climb.push({ tag: host, candidate });
3491
+ }
3492
+ return result;
3493
+ }
3494
+ mapper(html, provenance) {
3495
+ const htmlLines = starts(html);
3496
+ const maps = provenance.flatMap(
3497
+ (p) => occurrences(html, p.output).map((at2) => ({
3498
+ at: at2,
3499
+ p,
3500
+ lines: starts(p.output),
3501
+ inputLines: starts(p.input),
3502
+ map: new TraceMap(p.sourceMap)
3503
+ }))
3504
+ );
3505
+ const ranges = /* @__PURE__ */ new Map();
3506
+ for (const text of [html, ...provenance.map((p) => p.input)])
3507
+ ranges.set(
3508
+ text,
3509
+ this.chunks.flatMap((chunk) => occurrences(text, chunk.text).map((at2) => ({ chunk, at: at2 })))
3510
+ );
3511
+ const locate = (text, offset) => {
3512
+ const found2 = (ranges.get(text) ?? []).filter(({ chunk, at: at2 }) => offset >= at2 && offset < at2 + chunk.text.length).map(({ chunk, at: at2 }) => ({ chunk, local: offset - at2 }));
3513
+ const unique = new Map(
3514
+ found2.map((hit) => [`${hit.chunk.file}:${hit.chunk.offset + hit.local}`, hit])
3515
+ );
3516
+ return unique.size === 1 ? [...unique.values()][0] : null;
3517
+ };
3518
+ const cache = /* @__PURE__ */ new Map();
3519
+ return (stack, target) => {
3520
+ const cached = cache.get(stack);
3521
+ if (cached) return cached.map((snippet) => ({ ...snippet, targets: [target] }));
3522
+ const result = [];
3523
+ for (const frame of stack.split("\n")) {
3524
+ const script = /(hf-inspect-[a-f0-9]+\.js):(\d+):(\d+)\)?$/.exec(frame);
3525
+ const m = /https?:\/\/[^/]+\/(?:index\.html)?:(\d+):(\d+)\)?$/.exec(frame);
3526
+ if (!m && !script) continue;
3527
+ const offset = m ? htmlLines[Number(m[1]) - 1] + Number(m[2]) - 1 : -1;
3528
+ let hit = m ? locate(html, offset) : null;
3529
+ if (!hit)
3530
+ for (const map of maps) {
3531
+ if (script ? map.p.sourceURL !== script[1] : offset < map.at || offset >= map.at + map.p.output.length)
3532
+ continue;
3533
+ const generated = script ? { line: Number(script[2]), column: Number(script[3]) - 1 } : position(map.lines, offset - map.at);
3534
+ const original = originalPositionFor(map.map, generated);
3535
+ if (original.line != null && original.column != null)
3536
+ hit = locate(map.p.input, map.inputLines[original.line - 1] + original.column);
3537
+ }
3538
+ if (!hit) continue;
3539
+ const enclosing = hit.chunk.statements.filter((s) => hit.local >= s.start && hit.local < s.end).sort((a, b) => a.end - a.start - (b.end - b.start))[0];
3540
+ if (!enclosing) continue;
3541
+ const helper = hit.chunk.statements.filter(
3542
+ (s) => s.type === "FunctionDeclaration" && hit.local >= s.start && hit.local < s.end && s.end - s.start <= SHOWN_WHOLE
3543
+ ).sort((a, b) => a.end - a.start - (b.end - b.start))[0];
3544
+ const caller = result.length > 0;
3545
+ const callLine = caller && !helper && enclosing.end - enclosing.start > SHOWN_WHOLE;
3546
+ const range = callLine ? { start: hit.local, end: hit.local + 1 } : helper ?? enclosing;
3547
+ const snippet = this.slice(
3548
+ hit.chunk.file,
3549
+ hit.chunk.offset + range.start,
3550
+ hit.chunk.offset + range.end,
3551
+ caller ? "animation caller" : "animation creation",
3552
+ target
3553
+ );
3554
+ if (snippet) result.push(snippet);
3555
+ if (callLine) continue;
3556
+ for (const dependency of hit.chunk.dependencies(range)) {
3557
+ const definition = this.slice(
3558
+ hit.chunk.file,
3559
+ hit.chunk.offset + dependency.start,
3560
+ hit.chunk.offset + dependency.end,
3561
+ "animation source dependency",
3562
+ target
3563
+ );
3564
+ if (definition) result.push(definition);
3565
+ }
3566
+ }
3567
+ cache.set(stack, result);
3568
+ return result;
3569
+ };
3570
+ }
3571
+ };
3572
+ function mergeSnippets(snippets, sources) {
3573
+ const sorted = snippets.sort((a, b) => a.file.localeCompare(b.file) || a.startLine - b.startLine);
3574
+ const output = [];
3575
+ for (const snippet of sorted) {
3576
+ const last = output.at(-1);
3577
+ if (last && last.file === snippet.file && snippet.startLine <= last.endLine + 1) {
3578
+ last.endLine = Math.max(last.endLine, snippet.endLine);
3579
+ last.id = `${last.file}:${last.startLine}-${last.endLine}`;
3580
+ const source = sources.files.get(last.file);
3581
+ last.code = source.text.slice(
3582
+ source.lines[last.startLine - 1],
3583
+ source.lines[last.endLine] ?? source.text.length
3584
+ );
3585
+ last.targets = [.../* @__PURE__ */ new Set([...last.targets, ...snippet.targets])];
3586
+ last.kind = [.../* @__PURE__ */ new Set([...last.kind, ...snippet.kind])];
3587
+ last.uniqueInFile = occurrences(source.text, last.code).length === 1;
3588
+ } else output.push({ ...snippet });
3589
+ }
3590
+ return output;
3591
+ }
3592
+ var KEPT_FIRST_UNDER_BUDGET = [
3593
+ "animation creation",
3594
+ "animation caller",
3595
+ "timeline attachment",
3596
+ "html opening tag",
3597
+ "animation source dependency",
3598
+ "matched CSS candidate"
3599
+ ];
3600
+ var rank = (kind) => {
3601
+ const at2 = KEPT_FIRST_UNDER_BUDGET.indexOf(kind);
3602
+ return at2 === -1 ? KEPT_FIRST_UNDER_BUDGET.length : at2;
3603
+ };
3604
+ var priority = (snippet) => Math.min(...snippet.kind.map(rank));
3605
+ var byPosition = (a, b) => a.file.localeCompare(b.file) || a.startLine - b.startLine;
3606
+ var CO_TARGETS_SHOWN = 3;
3607
+ function shown(snippet, targetCount) {
3608
+ const { id, kind, code, uniqueInFile, targets } = snippet;
3609
+ return targetCount === 1 ? { id, kind, code, uniqueInFile } : { id, kind, targets, code, uniqueInFile };
3610
+ }
3611
+ function mapInspection(raw, request, context) {
3612
+ const { sources, map, catalog, generation, sourceVersion, reused, start, visualState } = context;
3613
+ const maxBytes = request.maxBytes ?? 12e3;
3614
+ const collected = [];
3615
+ const compositions = [];
3616
+ const queriedRefs = new Set(raw.results.flatMap((result) => result.elements.map((el) => el.ref)));
3617
+ const results = raw.results.map((result, index) => {
3618
+ let unmappedAnimations = 0;
3619
+ for (const animation of result.animations) {
3620
+ const mapped = animation.stack ? map(animation.stack, index) : [];
3621
+ if (!mapped.length) unmappedAnimations++;
3622
+ collected.push(...mapped);
3623
+ for (const stack of animation.attachmentStacks)
3624
+ collected.push(
3625
+ ...map(stack, index).map((snippet) => ({ ...snippet, kind: ["timeline attachment"] }))
3626
+ );
3627
+ }
3628
+ for (const el of result.elements) {
3629
+ const tag = sources.markupTag(el);
3630
+ if (!tag) continue;
3631
+ const snippet = sources.slice(tag.file, tag.start, tag.end, "html opening tag", index);
3632
+ if (snippet) collected.push(snippet);
3633
+ compositions.push(...sources.compositions(tag, index));
3634
+ }
3635
+ for (const id of result.css) {
3636
+ const rule = sources.cssRules.find((rule2) => rule2.id === id);
3637
+ if (rule) {
3638
+ const snippet = sources.slice(
3639
+ rule.file,
3640
+ rule.start,
3641
+ rule.end,
3642
+ "matched CSS candidate",
3643
+ index
3644
+ );
3645
+ if (snippet) collected.push(snippet);
3646
+ }
3647
+ }
3648
+ const coTargets = [
3649
+ ...new Map(
3650
+ result.animations.flatMap((animation) => animation.targets).filter((element) => !result.elements.some((own) => own.ref === element.ref)).map((element) => [element.ref, element])
3651
+ ).values()
3652
+ ].sort((a, b) => Number(queriedRefs.has(a.ref)) - Number(queriedRefs.has(b.ref)));
3653
+ return {
3654
+ target: index,
3655
+ status: result.status,
3656
+ candidates: result.candidates,
3657
+ candidatesOmitted: 0,
3658
+ animations: result.animations.length,
3659
+ coTargets: coTargets.slice(0, CO_TARGETS_SHOWN),
3660
+ ...coTargets.length > CO_TARGETS_SHOWN && {
3661
+ coTargetsOmitted: coTargets.length - CO_TARGETS_SHOWN
3662
+ },
3663
+ unmappedAnimations,
3664
+ scopeTruncated: result.truncated
3665
+ };
3666
+ });
3667
+ const merged = withCompositionsLast(mergeSnippets(collected, sources), compositions, sources);
3668
+ for (const snippet of merged) catalog.set(snippet.id, snippet);
3669
+ let selected = [...merged].sort((a, b) => priority(a) - priority(b));
3670
+ if (request.snippets)
3671
+ selected = request.snippets.map((id) => {
3672
+ const snippet = catalog.get(id);
3673
+ if (!snippet) throw new Error(`unknown_snippet: ${id}`);
3674
+ return snippet;
3675
+ });
3676
+ const candidateContext = {};
3677
+ const response = {
3678
+ generation,
3679
+ visualState,
3680
+ sourceVersion,
3681
+ reused,
3682
+ results,
3683
+ snippets: [],
3684
+ omitted: [],
3685
+ omittedCount: 0,
3686
+ nextOffset: null,
3687
+ ...candidateContext,
3688
+ recordLimitReached: raw.recordLimitReached,
3689
+ hooked: raw.hooked,
3690
+ debugAvailable: true,
3691
+ elapsedMs: Math.round(performance.now() - start)
3692
+ };
3693
+ const offset = request.offset ?? 0;
3694
+ if (!Number.isInteger(offset) || offset < 0)
3695
+ throw new Error("offset must be a non-negative integer");
3696
+ const size = () => Buffer.byteLength(JSON.stringify(response));
3697
+ const trimCandidates = (limit, keep) => {
3698
+ while (size() > limit) {
3699
+ const longest = response.results.reduce(
3700
+ (a, b) => b.candidates.length > a.candidates.length ? b : a
3701
+ );
3702
+ if (longest.candidates.length <= keep) return;
3703
+ longest.candidates.pop();
3704
+ longest.candidatesOmitted++;
3705
+ }
3706
+ };
3707
+ trimCandidates(maxBytes / 2, 5);
3708
+ const targetCount = request.targets.length;
3709
+ const kept = [];
3710
+ for (let i = offset; i < selected.length; i++) {
3711
+ response.snippets.push(shown(selected[i], targetCount));
3712
+ const priorCoverage = response.coverage;
3713
+ if (response.coverage === void 0 && selected[i].kind.some(
3714
+ (kind) => kind.startsWith("composition ") && kind.endsWith(" candidate")
3715
+ ))
3716
+ response.coverage = [
3717
+ "Composition candidates are alternative source mounts and their enclosing roots, not a verified runtime instance chain; all alternatives remain available within the snippet budget and pagination."
3718
+ ];
3719
+ if (size() > maxBytes - 700) {
3720
+ response.snippets.pop();
3721
+ response.coverage = priorCoverage;
3722
+ response.omittedCount = selected.length - i;
3723
+ response.omitted = selected.slice(i, i + 8).map((item) => ({ id: item.id, bytes: Buffer.byteLength(item.code) }));
3724
+ const nothingFit = response.snippets.length === 0;
3725
+ response.nextOffset = nothingFit ? i + 1 < selected.length ? i + 1 : null : i;
3726
+ break;
3727
+ }
3728
+ kept.push(selected[i]);
3729
+ }
3730
+ if (!request.snippets)
3731
+ response.snippets = kept.sort(byPosition).map((snippet) => shown(snippet, targetCount));
3732
+ trimCandidates(maxBytes, 0);
3733
+ if (Buffer.byteLength(JSON.stringify(response)) > maxBytes)
3734
+ throw new Error("metadata_exceeds_budget: use fewer targets or increase maxBytes");
3735
+ if (request.debug) return { ...response, debug: raw };
3736
+ return response;
3737
+ }
3738
+ function withCompositionsLast(merged, compositions, sources) {
3739
+ const covered = (s) => merged.some((m) => m.file === s.file && m.startLine <= s.startLine && m.endLine >= s.endLine);
3740
+ return [
3741
+ ...merged,
3742
+ ...mergeSnippets(
3743
+ compositions.filter((s) => !covered(s)),
3744
+ sources
3745
+ )
3746
+ ];
3747
+ }
3748
+ function queryPage(query) {
3749
+ const inspected = window;
3750
+ const inspection = inspected.__hfInspection;
3751
+ if (!inspection) throw new Error("inspector_unavailable");
3752
+ return {
3753
+ generation: inspected.__hfLiveInspection?.generation ?? null,
3754
+ ...inspection.query(query)
3755
+ };
3756
+ }
3757
+ function timelinePage(request) {
3758
+ const inspected = window;
3759
+ const inspection = inspected.__hfInspection;
3760
+ if (!inspection) throw new Error("inspector_unavailable");
3761
+ const result = inspection.timeline(request);
3762
+ const following = [];
3763
+ const generation = inspected.__hfLiveInspection?.generation ?? null;
3764
+ const duration = inspected.__player?.getDuration();
3765
+ if (request.boundary === void 0) return { ...result, following, generation, duration };
3766
+ const boundary = request.boundary;
3767
+ const schedule = inspection.timeline({ ...request, boundary: void 0 });
3768
+ for (const crossing of result.events) {
3769
+ if (crossing.kind !== "animation" || crossing.relation !== "crosses") continue;
3770
+ for (const target of crossing.targets) {
3771
+ const next = schedule.events.filter(
3772
+ (event) => event.kind === "animation" && event.start > boundary && event.targets.some((t) => t.ref === target.ref) && event.properties.some((p) => crossing.properties.includes(p))
3773
+ ).sort((a, b) => a.start - b.start)[0];
3774
+ if (next && !following.includes(next)) following.push(next);
3775
+ }
3776
+ }
3777
+ return { ...result, following, generation, duration };
3778
+ }
3779
+ function liveGenerationPage() {
3780
+ return window.__hfLiveInspection?.generation ?? null;
3781
+ }
3782
+ var GROUPS_PER_PAGE = 60;
3783
+ var FOLLOWING_SHOWN = 16;
3784
+ var MEMBERS_SHOWN = 8;
3785
+ var RELATIONS_SHOWN = 8;
3786
+ var COVERAGE_NOTE = "Observed DOM-target GSAP and explicit HF items only; callbacks/object tweens/unexecuted code are not inspected. Scheduled intervals do not establish visibility; no visual verification. at/range are half-open; boundary includes exact endpoints. No seek performed.";
3787
+ var BOUNDARY_NOTE = "only actions crossing, starting, ending or instantaneous here. Later stagger members are excluded, not absent. Group spans do not imply simultaneous starts. Target labels T1, T2, ... identify the same element within this response, not DOM order.";
3788
+ function formatTimeline(raw, request, view) {
3789
+ const offset = request.offset ?? 0;
3790
+ const allGroups = byComponent(groupEvents(raw.events));
3791
+ const groups = allGroups.slice(offset, offset + GROUPS_PER_PAGE);
3792
+ const label = labeler();
3793
+ const events = groups.flat().map((event, index) => ({
3794
+ ...event,
3795
+ stack: void 0,
3796
+ sources: onePerSourceLine(event.stack ? view.map(event.stack, index) : []).map((s) => ({
3797
+ file: s.file,
3798
+ line: s.startLine
3799
+ }))
3800
+ }));
3801
+ const nextOffset = offset + groups.length < allGroups.length ? offset + groups.length : null;
3802
+ const lines = [
3803
+ `Timeline \xB7 global seconds \xB7 ${raw.status}`,
3804
+ `generation: ${view.generation}`,
3805
+ ...raw.status !== "found" ? raw.candidates.map(
3806
+ (c) => `${c.ref} ${targetSummary([c])[0]} ${c.tag}${c.composition ? ` in ${c.composition}` : ""}`
3807
+ ) : [],
3808
+ ...pastTheEnd(request, raw.duration),
3809
+ ...request.boundary !== void 0 ? [`Boundary ${request.boundary}s: ${BOUNDARY_NOTE}`] : [],
3810
+ ...describeGroups(groups, request, view.map, label),
3811
+ ...describeFollowing(raw, view.map, label),
3812
+ ...describeRelations(groups),
3813
+ ...nextOffset !== null ? [`More groups: repeat with offset=${nextOffset} and generation.`] : [],
3814
+ ...raw.warnings.map((w) => `Coverage: ${w}`),
3815
+ ...events.some((e) => e.values) ? [
3816
+ "Authored values describe the original tween, not sampled state or reversed repeat direction; ? means unknown. Relative values and expressions are not resolved."
3817
+ ] : [],
3818
+ COVERAGE_NOTE
3819
+ ];
3820
+ return {
3821
+ text: lines.join("\n"),
3822
+ generation: view.generation,
3823
+ reused: view.reused,
3824
+ status: raw.status,
3825
+ candidates: raw.candidates,
3826
+ events,
3827
+ eventCount: raw.events.length,
3828
+ groupCount: allGroups.length,
3829
+ nextOffset,
3830
+ warnings: raw.warnings
3831
+ };
3832
+ }
3833
+ function groupEvents(events) {
3834
+ const groups = /* @__PURE__ */ new Map();
3835
+ for (const event of events) {
3836
+ const identity = event.targets.map((t) => t.id || t.hfId || `${t.composition}:${t.tag}:${t.classes.join(".")}`).sort();
3837
+ const key = event.kind === "animation" && event.stack ? JSON.stringify([
3838
+ event.stack,
3839
+ event.component?.ref,
3840
+ event.relation,
3841
+ [...event.properties].sort(),
3842
+ identity
3843
+ ]) : `unique:${groups.size}`;
3844
+ groups.set(key, [...groups.get(key) ?? [], event]);
3845
+ }
3846
+ return [...groups.values()];
3847
+ }
3848
+ var headingOf = (event) => event.component?.id ? `#${event.component.id}` : event.component?.composition ?? "unassigned";
3849
+ function byComponent(groups) {
3850
+ const owners = /* @__PURE__ */ new Map();
3851
+ for (const group2 of groups) {
3852
+ const heading = headingOf(group2[0]);
3853
+ owners.set(heading, [...owners.get(heading) ?? [], group2]);
3854
+ }
3855
+ return [...owners.values()].flat();
3856
+ }
3857
+ function pastTheEnd(request, duration) {
3858
+ const from = request.range?.[0] ?? request.at ?? request.boundary;
3859
+ const filmLength = duration !== void 0 && duration > 0 ? duration : void 0;
3860
+ if (filmLength === void 0 || from === void 0 || from < filmLength) return [];
3861
+ return [`Requested time is past the end: the film is ${Number(filmLength.toFixed(4))}s long.`];
3862
+ }
3863
+ function labeler() {
3864
+ const labels = /* @__PURE__ */ new Map();
3865
+ return (ref) => {
3866
+ if (!labels.has(ref)) labels.set(ref, `T${labels.size + 1}`);
3867
+ return labels.get(ref);
3868
+ };
3869
+ }
3870
+ var at = (seconds) => seconds.toFixed(4);
3871
+ function onePerSourceLine(sources) {
3872
+ return [...new Map(sources.map((s) => [`${s.file}:${s.startLine}`, s])).values()];
3873
+ }
3874
+ var located = (sources) => onePerSourceLine(sources).map((s) => `${s.file}:${s.startLine}`).join(", ");
3875
+ function describeValue(value) {
3876
+ if (value.kind === "unknown") return "?";
3877
+ if (value.kind === "expression" && value.value === "custom function") return "custom function";
3878
+ const shown2 = typeof value.value === "number" ? Number(value.value.toFixed(4)) : value.value;
3879
+ return `${shown2}${value.kind === "literal" ? "" : ` (${value.kind})`}`;
3880
+ }
3881
+ function describeValues(values) {
3882
+ return ` authored: ${values.properties.map((p) => `${p.property}: ${describeValue(p.from)} \u2192 ${describeValue(p.to)}`).join("; ")}; ease: ${describeValue(values.ease)}`;
3883
+ }
3884
+ function describeGroups(groups, request, map, label) {
3885
+ const lines = [];
3886
+ let owner = "";
3887
+ for (const members of groups) {
3888
+ const first = members[0];
3889
+ const event = {
3890
+ ...first,
3891
+ start: Math.min(...members.map((e) => e.start)),
3892
+ end: Math.max(...members.map((e) => e.end)),
3893
+ targets: [...new Map(members.flatMap((e) => e.targets).map((t) => [t.ref, t])).values()]
3894
+ };
3895
+ const component = event.component;
3896
+ const heading = headingOf(event);
3897
+ if (owner !== heading) {
3898
+ lines.push(`
3899
+ ${heading}${component ? ` [${component.ref}]` : ""}`);
3900
+ owner = heading;
3901
+ }
3902
+ const targets = targetSummary(event.targets);
3903
+ const more = targets.length > 4 ? ` (+${targets.length - 4} groups)` : "";
3904
+ lines.push(
3905
+ ` ${at(event.start)}\u2013${at(event.end)}s ${event.relation} ${event.kind} ${targets.slice(0, 4).join(", ")}${more} ${event.properties.join(",")}`
3906
+ );
3907
+ const variants = new Map(
3908
+ members.filter((m) => m.values).map((m) => [JSON.stringify(m.values), m.values])
3909
+ );
3910
+ if (variants.size === 1) lines.push(describeValues(variants.values().next().value));
3911
+ else if (variants.size > 1)
3912
+ lines.push(" authored values vary across events; inspect the per-event JSON values.");
3913
+ if (event.kind === "animation") {
3914
+ const sources = event.stack ? map(event.stack, 0) : [];
3915
+ lines.push(` ${sources.length ? located(sources) : "source unknown"}`);
3916
+ }
3917
+ if (request.boundary !== void 0 && event.kind === "animation")
3918
+ lines.push(...describeMembers(event.targets, members, label));
3919
+ if (members.length > 1) lines.push(describeSpacing(members));
3920
+ }
3921
+ return lines;
3922
+ }
3923
+ function targetSummary(targets) {
3924
+ const counts = /* @__PURE__ */ new Map();
3925
+ for (const target of targets) {
3926
+ const own = target.id ? `#${target.id}` : target.hfId ?? (target.classes.length ? `.${target.classes.join(".")}` : target.tag);
3927
+ const name = !target.id && target.withinId ? `${own} in #${target.withinId}` : own;
3928
+ counts.set(name, (counts.get(name) ?? 0) + 1);
3929
+ }
3930
+ return [...counts].map(([name, count]) => count > 1 ? `${name} \xD7${count}` : name);
3931
+ }
3932
+ function describeMembers(targets, members, label) {
3933
+ const lines = [` targets: ${targets.map((t) => label(t.ref)).join(", ")}`];
3934
+ if (members.length < 2) return lines;
3935
+ for (const member of members.slice(0, MEMBERS_SHOWN))
3936
+ lines.push(
3937
+ ` ${member.targets.map((t) => label(t.ref)).join(", ")}: ${at(member.start)}\u2013${at(member.end)}s ${member.relation}`
3938
+ );
3939
+ if (members.length > MEMBERS_SHOWN)
3940
+ lines.push(
3941
+ ` ${members.length - MEMBERS_SHOWN} more member intervals omitted; do not infer their exact timing from this span.`
3942
+ );
3943
+ return lines;
3944
+ }
3945
+ function describeSpacing(members) {
3946
+ const durations = members.map((e) => e.end - e.start);
3947
+ const starts2 = [...new Set(members.map((e) => e.start))].sort((a, b) => a - b);
3948
+ const step = starts2.length > 1 ? starts2[1] - starts2[0] : null;
3949
+ const regular = step !== null && starts2.every((t, i) => i === 0 || Math.abs(t - starts2[i - 1] - step) < 1e-4);
3950
+ const uniform = durations.every((d) => Math.abs(d - durations[0]) < 1e-7);
3951
+ return ` ${members.length} events; span is not continuous activity; ${uniform ? `each ${at(durations[0])}s` : "varying durations"}${regular ? `; approx. start spacing ${at(step)}s` : "; irregular or simultaneous starts"}`;
3952
+ }
3953
+ function describeFollowing(raw, map, label) {
3954
+ if (!raw.following.length) return [];
3955
+ const lines = ["\nFollowing actions (context only; these do NOT start at the queried boundary):"];
3956
+ for (const event of raw.following.slice(0, FOLLOWING_SHOWN)) {
3957
+ const sources = event.stack ? map(event.stack, 0) : [];
3958
+ lines.push(
3959
+ ` ${event.targets.map((t) => label(t.ref)).join(", ")}: ${at(event.start)}\u2013${at(event.end)}s ${event.properties.join(",")} ${located(sources)}`
3960
+ );
3961
+ for (const prior of raw.events) {
3962
+ if (prior.kind !== "animation" || prior.relation !== "crosses") continue;
3963
+ if (!prior.targets.some((t) => event.targets.some((n) => n.ref === t.ref))) continue;
3964
+ if (!prior.properties.some((p) => event.properties.includes(p))) continue;
3965
+ const overlap = Math.min(prior.end, event.end) - Math.max(prior.start, event.start);
3966
+ const handoff = overlap > 1e-7 ? `overlap ${at(overlap)}s` : Math.abs(prior.end - event.start) < 1e-7 ? "endpoint handoff: NO duration overlap on this target" : "NO duration overlap on this target";
3967
+ lines.push(` previous action ends ${at(prior.end)}s; ${handoff}.`);
3968
+ }
3969
+ }
3970
+ if (raw.following.length > FOLLOWING_SHOWN)
3971
+ lines.push(` ${raw.following.length - FOLLOWING_SHOWN} additional following actions omitted.`);
3972
+ return lines;
3973
+ }
3974
+ function describeRelations(groups) {
3975
+ const lines = [];
3976
+ const events = groups.flatMap((members, group2) => members.map((event) => ({ event, group: group2 })));
3977
+ const described = /* @__PURE__ */ new Set();
3978
+ for (let a = 0; a < events.length; a++)
3979
+ for (let b = a + 1; b < events.length; b++) {
3980
+ const left = events[a].event;
3981
+ const right = events[b].event;
3982
+ const pair = `${events[a].group}:${events[b].group}`;
3983
+ if (described.has(pair)) continue;
3984
+ if (left.kind !== "animation" || right.kind !== "animation") continue;
3985
+ if (left.end < right.start || right.end < left.start) continue;
3986
+ const shared = left.targets.some((t) => right.targets.some((r) => r.ref === t.ref));
3987
+ const properties = left.properties.filter((p) => right.properties.includes(p));
3988
+ if (!shared || !properties.length || lines.length >= RELATIONS_SHOWN) continue;
3989
+ const kind = left.start === left.end || right.start === right.end ? "instantaneous action touches or occurs inside the other interval" : Math.min(left.end, right.end) > Math.max(left.start, right.start) ? "intervals overlap" : "touch at an endpoint only, no positive-duration overlap";
3990
+ described.add(pair);
3991
+ lines.push(
3992
+ `Relation: ${at(left.start)}\u2013${at(left.end)} and ${at(right.start)}\u2013${at(right.end)} share targets and ${properties.join(",")}; ${kind}; not necessarily an error.`
3993
+ );
3994
+ }
3995
+ return lines;
3996
+ }
3997
+ function assertPageGeneration(view, actual) {
3998
+ if (view.pageGeneration !== void 0 && actual !== view.pageGeneration)
3999
+ throw new Error("stale_preview: the preview reloaded; query again");
4000
+ }
4001
+ async function inspectComponents(runner, view, request, context) {
4002
+ const { sources, map } = view.sourceContext();
4003
+ const raw = await runner.run(queryPage, {
4004
+ targets: request.targets,
4005
+ descendants: request.descendants ?? true,
4006
+ cssRules: sources.cssRules.map(({ id, selector }) => ({ id, selector }))
4007
+ });
4008
+ assertPageGeneration(view, raw.generation);
4009
+ await view.assertCurrent();
4010
+ return mapInspection(raw, request, {
4011
+ ...context,
4012
+ sources,
4013
+ map,
4014
+ generation: view.generation,
4015
+ sourceVersion: view.sourceVersion
4016
+ });
4017
+ }
4018
+ async function inspectTimeline(runner, view, request, reused) {
4019
+ const raw = await runner.run(timelinePage, request);
4020
+ assertPageGeneration(view, raw.generation);
4021
+ await view.assertCurrent();
4022
+ return formatTimeline(raw, request, {
4023
+ generation: view.generation,
4024
+ map: view.sourceContext().map,
4025
+ reused
4026
+ });
4027
+ }
4028
+ async function inspectElementMap(runner, view, file = "index.html") {
4029
+ const snapshot = await runner.run(collectElementDom, void 0);
4030
+ assertPageGeneration(view, snapshot.generation);
4031
+ const authored = view.authoredHtml?.();
4032
+ const map = formatElementMap(authored ? withAuthoredState(snapshot, authored) : snapshot, {
4033
+ file
4034
+ });
4035
+ await view.assertCurrent();
4036
+ return { ...map, sourceVersion: view.sourceVersion, generation: view.generation };
4037
+ }
4038
+ function validateInspectRequest(request) {
4039
+ if (!Array.isArray(request.targets) || request.targets.length > 20 || !request.targets.length && !request.snippets?.length)
4040
+ throw new Error("Provide 1\u201320 targets, or snippet IDs from a previous query.");
4041
+ for (const target of request.targets) {
4042
+ if (!target || typeof target !== "object") throw new Error("Invalid target");
4043
+ const keys = ["selector", "hfId", "ref"].filter((key) => key in target);
4044
+ if (keys.length !== 1 || Object.values(target).some(
4045
+ (value) => typeof value !== "string" || !value || value.length > 1e3
4046
+ ))
4047
+ throw new Error("Each target needs exactly one selector, hfId or ref; within is optional.");
4048
+ }
4049
+ const maxBytes = request.maxBytes ?? 12e3;
4050
+ if (!Number.isInteger(maxBytes) || maxBytes < 2048 || maxBytes > 256e3)
4051
+ throw new Error("maxBytes must be 2048\u2013256000");
4052
+ if (request.time != null && (!Number.isFinite(request.time) || request.time < 0))
4053
+ throw new Error("time must be a finite non-negative number");
4054
+ if (request.snippets?.length && !request.generation)
4055
+ throw new Error("snippet continuation requires generation");
4056
+ }
4057
+ var TIMELINE_KEYS = ["component", "at", "range", "boundary", "generation", "offset"];
4058
+ var COMPONENT_KEYS = ["selector", "hfId", "ref", "within"];
4059
+ function validateTimelineRequest(request) {
4060
+ if (!request || typeof request !== "object" || Array.isArray(request))
4061
+ throw new Error("Expected query object");
4062
+ if (Object.keys(request).some((key) => !TIMELINE_KEYS.includes(key)))
4063
+ throw new Error("Unknown timeline query parameter");
4064
+ const times = [request.at, request.range, request.boundary].filter((v) => v !== void 0);
4065
+ if (times.length > 1) throw new Error("at, range and boundary are mutually exclusive");
4066
+ const numbers = [
4067
+ request.at,
4068
+ request.boundary,
4069
+ ...Array.isArray(request.range) ? request.range : []
4070
+ ].filter((v) => v !== void 0);
4071
+ if (numbers.some((v) => typeof v !== "number" || !Number.isFinite(v) || v < 0))
4072
+ throw new Error("Times must be finite non-negative seconds");
4073
+ if (request.range !== void 0 && (!Array.isArray(request.range) || request.range.length !== 2 || request.range[0] >= request.range[1]))
4074
+ throw new Error("range must be [start,end] with start < end");
4075
+ const component = request.component;
4076
+ if (component && (typeof component !== "object" || Object.keys(component).some((key) => !COMPONENT_KEYS.includes(key)) || ["selector", "hfId", "ref"].filter((key) => key in component).length !== 1 || Object.values(component).some((v) => typeof v !== "string" || !v)))
4077
+ throw new Error("component requires one selector, hfId or ref");
4078
+ const offset = request.offset ?? 0;
4079
+ if (!Number.isInteger(offset) || offset < 0)
4080
+ throw new Error("offset must be non-negative integer");
4081
+ if (offset && !request.generation) throw new Error("pagination requires generation");
4082
+ }
4083
+ function assertGeneration(requested, current) {
4084
+ if (requested && requested !== current)
4085
+ throw new Error("stale_generation: query targets again after source changes or idle disposal");
4086
+ }
4087
+ var runtime = () => readFileSync2(new URL(`./inspection.${"js"}`, import.meta.url), "utf8");
4088
+ function prepareLiveInspection(projectDir, html, provenance, sourceVersion, reads) {
4089
+ const project = realpathSync2(projectDir);
4090
+ if (fingerprint2(project) !== sourceVersion) throw new Error("source_changed_during_load");
4091
+ if (!/<head\b[^>]*>/i.test(html)) throw new Error("preview_head_missing");
4092
+ const generation = randomUUID();
4093
+ const stamp = `window.__hfLiveInspection=${JSON.stringify({ generation, project })};`;
4094
+ const script = `${stamp}
4095
+ ${runtime()}`.replace(/<\/script/gi, "<\\/script");
4096
+ const prepared = html.replace(/<head\b[^>]*>/i, (head) => `${head}<script>${script}</script>`);
4097
+ let document2 = prepared;
4098
+ let context;
4099
+ let authored;
4100
+ const catalog = /* @__PURE__ */ new Map();
4101
+ const view = {
4102
+ generation,
4103
+ sourceVersion,
4104
+ pageGeneration: generation,
4105
+ sourceContext() {
4106
+ if (!context) {
4107
+ const sources = new Sources(project, reads);
4108
+ context = { sources, map: sources.mapper(document2, [...provenance]) };
4109
+ }
4110
+ return context;
4111
+ },
4112
+ authoredHtml() {
4113
+ return authored ??= authoredHtml(project);
4114
+ },
4115
+ async assertCurrent() {
4116
+ if (fingerprint2(project) !== sourceVersion)
4117
+ throw new Error("stale_preview: the project changed; query again once the preview reloads");
4118
+ }
4119
+ };
4120
+ async function current(runner) {
4121
+ if (await previewGeneration(runner) !== generation)
4122
+ throw new Error("stale_preview: the preview reloaded; query again");
4123
+ await view.assertCurrent();
4124
+ }
4125
+ return {
4126
+ html: prepared,
4127
+ generation,
4128
+ finalizeDocument(servedHtml) {
4129
+ document2 = servedHtml;
4130
+ context = void 0;
4131
+ },
4132
+ async inspect(runner, request) {
4133
+ validateInspectRequest(request);
4134
+ if (request.time != null) throw new Error("live_query_does_not_seek");
4135
+ assertGeneration(request.generation, generation);
4136
+ await current(runner);
4137
+ return inspectComponents(runner, view, request, {
4138
+ catalog,
4139
+ reused: true,
4140
+ start: performance.now()
4141
+ });
4142
+ },
4143
+ async timeline(runner, request) {
4144
+ validateTimelineRequest(request);
4145
+ assertGeneration(request.generation, generation);
4146
+ await current(runner);
4147
+ return inspectTimeline(runner, view, request, true);
4148
+ },
4149
+ async elementMap(runner) {
4150
+ await current(runner);
4151
+ return inspectElementMap(runner, view);
4152
+ }
4153
+ };
4154
+ }
4155
+ function previewGeneration(runner) {
4156
+ return runner.run(liveGenerationPage, void 0);
4157
+ }
4158
+ function fingerprint2(project) {
4159
+ return fingerprint(project, { ignoreHfIds: true });
4160
+ }
4161
+ export {
4162
+ fingerprint2 as fingerprint,
4163
+ prepareLiveInspection,
4164
+ previewGeneration
4165
+ };