@aiquants/markdown 5.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +176 -14
  2. package/dist/{abnfDiagram-VRR7QNED-DeHJ63Vu.js → abnfDiagram-VRR7QNED-0ow9i3L-.js} +3 -3
  3. package/dist/{abnfDiagram-VRR7QNED-CfVjEUzG.cjs → abnfDiagram-VRR7QNED-DRNsVB-u.cjs} +1 -1
  4. package/dist/{arc-XFFLkHkK.cjs → arc-BWR9_qMf.cjs} +1 -1
  5. package/dist/arc-Bh12k776.js +83 -0
  6. package/dist/{architectureDiagram-ZJ3FMSHR-CQ1m3MUB.js → architectureDiagram-ZJ3FMSHR-CsFXQcxx.js} +123 -123
  7. package/dist/{architectureDiagram-ZJ3FMSHR-7xJ6YYGu.cjs → architectureDiagram-ZJ3FMSHR-DtrqDlxV.cjs} +1 -1
  8. package/dist/{blockDiagram-677ZJIJ3-CJOFqwiW.cjs → blockDiagram-677ZJIJ3-CoZEeE0C.cjs} +1 -1
  9. package/dist/{blockDiagram-677ZJIJ3-BPC3se0e.js → blockDiagram-677ZJIJ3-CqQ43viF.js} +166 -166
  10. package/dist/{c4Diagram-LMCZKHZV-D8ytYGhR.cjs → c4Diagram-LMCZKHZV-DGA2gxp-.cjs} +1 -1
  11. package/dist/{c4Diagram-LMCZKHZV-BEIrp4t6.js → c4Diagram-LMCZKHZV-QPgNg4El.js} +2 -2
  12. package/dist/{channel-CJQcZr8o.cjs → channel-Jkgg7NV4.cjs} +1 -1
  13. package/dist/channel-PnA15jK3.js +5 -0
  14. package/dist/{chunk-2Q5K7J3B-BbMQR3Sm.cjs → chunk-2Q5K7J3B-1iQ5h7FK.cjs} +1 -1
  15. package/dist/{chunk-2Q5K7J3B-l8ly7Yjr.js → chunk-2Q5K7J3B-DOWfHP5s.js} +1 -1
  16. package/dist/{chunk-32BRIVSS-BhQJBlVw.js → chunk-32BRIVSS-94iTIA-u.js} +1 -1
  17. package/dist/{chunk-32BRIVSS-BwDfmprN.cjs → chunk-32BRIVSS-XUAL4SUU.cjs} +1 -1
  18. package/dist/{chunk-5VM5RSS4-CqDQlS7v.cjs → chunk-5VM5RSS4-CKgpuXOS.cjs} +1 -1
  19. package/dist/{chunk-5VM5RSS4-Bfis-x7E.js → chunk-5VM5RSS4-OANQKmQE.js} +1 -1
  20. package/dist/{chunk-EX3LRPZG-DUTbzwDM.js → chunk-EX3LRPZG-BQDQ1MdS.js} +50 -50
  21. package/dist/{chunk-EX3LRPZG-9aDULZwJ.cjs → chunk-EX3LRPZG-BrRRbskW.cjs} +1 -1
  22. package/dist/{chunk-JWPE2WC7-5cM5nFf6.cjs → chunk-JWPE2WC7-Bz9dXsLZ.cjs} +1 -1
  23. package/dist/{chunk-JWPE2WC7-DpcSSOP5.js → chunk-JWPE2WC7-Djg6Qi23.js} +1 -1
  24. package/dist/{chunk-MOJQB5TN-D_h6bolU.js → chunk-MOJQB5TN-1pZNp2Wl.js} +9 -9
  25. package/dist/{chunk-MOJQB5TN-Cw864mUL.cjs → chunk-MOJQB5TN-DUk2Jy4_.cjs} +1 -1
  26. package/dist/{chunk-PUDLZKDR-yLvT3c9x.cjs → chunk-PUDLZKDR-CVedetzB.cjs} +1 -1
  27. package/dist/{chunk-PUDLZKDR-B0wZjmzv.js → chunk-PUDLZKDR-G5JYyEiR.js} +22 -22
  28. package/dist/{chunk-RYQCIY6F-DTKYsCgk.js → chunk-RYQCIY6F-Crmt36sO.js} +6 -6
  29. package/dist/{chunk-RYQCIY6F-hj9dRWMT.cjs → chunk-RYQCIY6F-D0y50t5B.cjs} +1 -1
  30. package/dist/{chunk-V7JOEXUC-COa9uddv.js → chunk-V7JOEXUC-BNo-X7NC.js} +5 -5
  31. package/dist/{chunk-V7JOEXUC-DIQ8n1AN.cjs → chunk-V7JOEXUC-DXSQM1ea.cjs} +1 -1
  32. package/dist/{chunk-VR4S4FIN-B72PxPVm.js → chunk-VR4S4FIN-BGGITgpQ.js} +3 -3
  33. package/dist/{chunk-VR4S4FIN-Cy-2mZJB.cjs → chunk-VR4S4FIN-Bc567umS.cjs} +1 -1
  34. package/dist/{chunk-XXDRQBXY-DmoUE7-y.cjs → chunk-XXDRQBXY-DOuLpiJ4.cjs} +1 -1
  35. package/dist/{chunk-XXDRQBXY-D2Sgptl-.js → chunk-XXDRQBXY-Drnpl-KK.js} +1 -1
  36. package/dist/{classDiagram-v2-EOCWNBFH-Dah4_VL7.js → classDiagram-OUVF2IWQ-Cneye7qT.js} +2 -2
  37. package/dist/{classDiagram-OUVF2IWQ-GjsCEuKI.cjs → classDiagram-OUVF2IWQ-mmjBEYmN.cjs} +1 -1
  38. package/dist/{classDiagram-OUVF2IWQ-Dah4_VL7.js → classDiagram-v2-EOCWNBFH-Cneye7qT.js} +2 -2
  39. package/dist/{classDiagram-v2-EOCWNBFH-GjsCEuKI.cjs → classDiagram-v2-EOCWNBFH-mmjBEYmN.cjs} +1 -1
  40. package/dist/components/MarkdownRenderer.d.ts +5 -2
  41. package/dist/components/MarkdownViewer.d.ts +3 -2
  42. package/dist/components/NodesRenderer.d.ts +1 -5
  43. package/dist/components/embeds/ClientFrame.d.ts +13 -0
  44. package/dist/components/embeds/LinkCard.d.ts +20 -0
  45. package/dist/components/embeds/ProviderEmbed.d.ts +11 -0
  46. package/dist/components/embeds/embedLabels.d.ts +12 -0
  47. package/dist/components/embeds/frameMessages.d.ts +7 -0
  48. package/dist/components/embeds/markdownEmbeds.d.ts +2 -0
  49. package/dist/components/embeds/requestQueue.d.ts +16 -0
  50. package/dist/components/embeds.d.ts +0 -8
  51. package/dist/components/htmlSanitizer.d.ts +4 -0
  52. package/dist/components/mdastNodes/HTMLBlockContainerNode.d.ts +1 -2
  53. package/dist/components/rawHtml.d.ts +6 -3
  54. package/dist/components/viewerLabels.d.ts +3 -1
  55. package/dist/{cose-bilkent-JH36ORCC-Pi0l3C5o.js → cose-bilkent-JH36ORCC-BQWfGE1G.js} +1 -1
  56. package/dist/{cose-bilkent-JH36ORCC-Vi9pHFwc.cjs → cose-bilkent-JH36ORCC-BaEdcRlX.cjs} +1 -1
  57. package/dist/css/zenn-content.css +0 -40
  58. package/dist/{cynefinDiagram-TSTJHNR4-CIh03JTU.js → cynefinDiagram-TSTJHNR4-CTDDSUz7.js} +47 -47
  59. package/dist/{cynefinDiagram-TSTJHNR4-BQ2k9Z6b.cjs → cynefinDiagram-TSTJHNR4-DPQl09kC.cjs} +1 -1
  60. package/dist/{dagre-VKFMJZFB-cINcPwV3.js → dagre-VKFMJZFB-BMRdJgZy.js} +27 -27
  61. package/dist/{dagre-VKFMJZFB-DI2wSrAy.cjs → dagre-VKFMJZFB-DZ4E-Szs.cjs} +1 -1
  62. package/dist/{diagram-FQU43EPY-BonrBTG_.js → diagram-FQU43EPY-CmEpNw5i.js} +42 -42
  63. package/dist/{diagram-FQU43EPY-B6iUH2l5.cjs → diagram-FQU43EPY-mK9YHIy1.cjs} +1 -1
  64. package/dist/{diagram-G47NLZAW-CY6mWS2R.cjs → diagram-G47NLZAW-BX8Lj_uD.cjs} +1 -1
  65. package/dist/{diagram-G47NLZAW-5N876QQA.js → diagram-G47NLZAW-eJRQFjAg.js} +83 -83
  66. package/dist/{diagram-NH7WQ7WH-x3SaRfd6.cjs → diagram-NH7WQ7WH-3r1_3TrC.cjs} +1 -1
  67. package/dist/{diagram-NH7WQ7WH-LFuTbHxY.js → diagram-NH7WQ7WH-BOOj_4-N.js} +18 -18
  68. package/dist/{diagram-OA4YK3LP-B9mVw8cB.cjs → diagram-OA4YK3LP-CkDJzLOy.cjs} +1 -1
  69. package/dist/{diagram-OA4YK3LP-Cinpbl0B.js → diagram-OA4YK3LP-DnDIHtcW.js} +61 -61
  70. package/dist/{diagram-WEI45ONY-HPCHpafe.js → diagram-WEI45ONY-BHpuPTt-.js} +21 -21
  71. package/dist/{diagram-WEI45ONY-BRYVUhRr.cjs → diagram-WEI45ONY-BpCCo_Ty.cjs} +1 -1
  72. package/dist/{ebnfDiagram-CCIWWBDH-oLOdtH39.js → ebnfDiagram-CCIWWBDH-BDLB-AVF.js} +5 -5
  73. package/dist/{ebnfDiagram-CCIWWBDH-DhFlIi0a.cjs → ebnfDiagram-CCIWWBDH-CfdalXdM.cjs} +1 -1
  74. package/dist/embeds/frames.d.ts +4 -0
  75. package/dist/embeds/linkCards.d.ts +48 -0
  76. package/dist/embeds/placeholder.d.ts +15 -0
  77. package/dist/embeds/providers.d.ts +73 -0
  78. package/dist/embeds/testing.cjs +1 -0
  79. package/dist/embeds/testing.d.ts +7 -0
  80. package/dist/embeds/testing.js +67 -0
  81. package/dist/embeds.cjs +1 -0
  82. package/dist/embeds.d.ts +4 -0
  83. package/dist/embeds.js +73 -0
  84. package/dist/{erDiagram-Q63AITRT-DCCFR1Ai.cjs → erDiagram-Q63AITRT-CviOyQsx.cjs} +1 -1
  85. package/dist/{erDiagram-Q63AITRT-CCtzpK78.js → erDiagram-Q63AITRT-DZlcgZfp.js} +9 -9
  86. package/dist/{extractHeadings-CGJexznE.js → extractHeadings-CtiYkq2z.js} +5482 -5431
  87. package/dist/extractHeadings-D1A8WzVy.cjs +311 -0
  88. package/dist/flowDiagram-23GEKE2U-C_FW0q38.js +7 -0
  89. package/dist/flowDiagram-23GEKE2U-Cb0U58EU.cjs +1 -0
  90. package/dist/{ganttDiagram-NO4QXBWP-C9RPyo4r.cjs → ganttDiagram-NO4QXBWP-CJa-hKPU.cjs} +1 -1
  91. package/dist/{ganttDiagram-NO4QXBWP-Dfi3nINO.js → ganttDiagram-NO4QXBWP-DO0HAbYg.js} +69 -69
  92. package/dist/{gitGraphDiagram-IHSO6WYX-CjAqPhww.js → gitGraphDiagram-IHSO6WYX-CXStgPQs.js} +38 -38
  93. package/dist/{gitGraphDiagram-IHSO6WYX-mT3NNT7T.cjs → gitGraphDiagram-IHSO6WYX-CXcPHbkt.cjs} +1 -1
  94. package/dist/index.cjs +1 -1
  95. package/dist/index.client.cjs +1 -1
  96. package/dist/index.client.d.ts +1 -10
  97. package/dist/index.client.js +41 -49
  98. package/dist/index.js +41 -49
  99. package/dist/index.server.cjs +1 -1
  100. package/dist/index.server.d.ts +1 -2
  101. package/dist/index.server.js +593 -191
  102. package/dist/{infoDiagram-FWYZ7A6U-0Co9BitR.cjs → infoDiagram-FWYZ7A6U-BByoHihL.cjs} +1 -1
  103. package/dist/{infoDiagram-FWYZ7A6U-BXWQ9Vy4.js → infoDiagram-FWYZ7A6U-K0__ySEG.js} +1 -1
  104. package/dist/{ishikawaDiagram-FXEZZL3T-CZp5P1WE.js → ishikawaDiagram-FXEZZL3T-C8QlwQP1.js} +35 -35
  105. package/dist/{ishikawaDiagram-FXEZZL3T-BKqUBw1i.cjs → ishikawaDiagram-FXEZZL3T-DZOMdeTI.cjs} +1 -1
  106. package/dist/{journeyDiagram-5HDEW3XC-DYVTgOOE.js → journeyDiagram-5HDEW3XC-CZ9PFNNN.js} +39 -39
  107. package/dist/{journeyDiagram-5HDEW3XC-CeumPQ1I.cjs → journeyDiagram-5HDEW3XC-RvC77rKo.cjs} +1 -1
  108. package/dist/{kanban-definition-HUTT4EX6-Cg5KnsE9.cjs → kanban-definition-HUTT4EX6-BL1jihGl.cjs} +1 -1
  109. package/dist/{kanban-definition-HUTT4EX6-CnleRy80.js → kanban-definition-HUTT4EX6-Q12F4vHx.js} +123 -123
  110. package/dist/{linear-Cf8i6Rsk.js → linear-LWjATjog.js} +32 -32
  111. package/dist/{linear-qqwu6T0F.cjs → linear-lDvPoqlB.cjs} +1 -1
  112. package/dist/linkCardServer/addressGuard.server.d.ts +25 -0
  113. package/dist/linkCardServer/htmlEncoding.server.d.ts +6 -0
  114. package/dist/linkCardServer/linkCardHandler.server.d.ts +7 -0
  115. package/dist/linkCardServer/metadataCache.server.d.ts +5 -0
  116. package/dist/linkCardServer/pageFetch.server.d.ts +37 -0
  117. package/dist/linkCardServer/pageMetadata.server.d.ts +11 -0
  118. package/dist/linkCards-1JxY8wdm.js +48 -0
  119. package/dist/linkCards-Bjd_vW39.cjs +1 -0
  120. package/dist/markdown.css +1 -1
  121. package/dist/{mindmap-definition-LN4V7U3C-lBin9VOm.js → mindmap-definition-LN4V7U3C-CM1XvwJX.js} +33 -33
  122. package/dist/{mindmap-definition-LN4V7U3C-DfFWeFph.cjs → mindmap-definition-LN4V7U3C-TVYKONRm.cjs} +1 -1
  123. package/dist/{pegDiagram-2B236MQR-BiD21lOj.js → pegDiagram-2B236MQR-Dlrnikqd.js} +5 -5
  124. package/dist/{pegDiagram-2B236MQR-Cf1f-3yi.cjs → pegDiagram-2B236MQR-a9Up0ERY.cjs} +1 -1
  125. package/dist/{pieDiagram-ENE6RG2P-jwhVsZgX.cjs → pieDiagram-ENE6RG2P-ClakmSma.cjs} +1 -1
  126. package/dist/{pieDiagram-ENE6RG2P-BqZb6gaV.js → pieDiagram-ENE6RG2P-WYrEJp8U.js} +58 -58
  127. package/dist/providers-Bxr2Wb-j.cjs +1 -0
  128. package/dist/providers-Drq7MT_K.js +209 -0
  129. package/dist/{quadrantDiagram-ABIIQ3AL-CNe9fRLO.js → quadrantDiagram-ABIIQ3AL-BkgMVDaX.js} +48 -48
  130. package/dist/{quadrantDiagram-ABIIQ3AL-sO_sIA7b.cjs → quadrantDiagram-ABIIQ3AL-Cb01YcqR.cjs} +1 -1
  131. package/dist/{railroadDiagram-RFXS5EU6-Dkc8k3e9.cjs → railroadDiagram-RFXS5EU6-Bob4WSMz.cjs} +1 -1
  132. package/dist/{railroadDiagram-RFXS5EU6-53YTkJrs.js → railroadDiagram-RFXS5EU6-RfCtZGUR.js} +3 -3
  133. package/dist/{requirementDiagram-TGXJPOKE-C0GMlJO4.cjs → requirementDiagram-TGXJPOKE-BP5h9mCj.cjs} +1 -1
  134. package/dist/{requirementDiagram-TGXJPOKE-D8Gz7jzA.js → requirementDiagram-TGXJPOKE-C1yJPMp1.js} +3 -3
  135. package/dist/{sankeyDiagram-HTMAVEWB-CEC0GaCg.js → sankeyDiagram-HTMAVEWB-D5G9Dcmr.js} +67 -67
  136. package/dist/{sankeyDiagram-HTMAVEWB-Bw9J2Ay2.cjs → sankeyDiagram-HTMAVEWB-shq9WK4t.cjs} +1 -1
  137. package/dist/{sequenceDiagram-DBY2YBRQ-CKb4m3I0.js → sequenceDiagram-DBY2YBRQ-8EJMQxiB.js} +47 -47
  138. package/dist/{sequenceDiagram-DBY2YBRQ-BuqPCreB.cjs → sequenceDiagram-DBY2YBRQ-BRxcK5-5.cjs} +1 -1
  139. package/dist/{simple-logger-DZxBpX7v.cjs → simple-logger-9yf7ypyB.cjs} +1 -1
  140. package/dist/{simple-logger-i94ikRyH.js → simple-logger-DwH1YQvq.js} +3 -1
  141. package/dist/{sizeCapture-X5ZJPWSS-Dm3rsxXw.cjs → sizeCapture-X5ZJPWSS-BtBRJO2R.cjs} +1 -1
  142. package/dist/{sizeCapture-X5ZJPWSS-CotnTNAA.js → sizeCapture-X5ZJPWSS-DJG85IuR.js} +1 -1
  143. package/dist/{stateDiagram-2N3HPSRC-GWEIP-C9.js → stateDiagram-2N3HPSRC-CAd-NU-f.js} +22 -22
  144. package/dist/{stateDiagram-2N3HPSRC-5Y-OlePe.cjs → stateDiagram-2N3HPSRC-Czgkv_ey.cjs} +1 -1
  145. package/dist/{stateDiagram-v2-6OUMAXLB-v77D3Qyf.cjs → stateDiagram-v2-6OUMAXLB-BNP5Lx0Y.cjs} +1 -1
  146. package/dist/{stateDiagram-v2-6OUMAXLB-BZFV8swJ.js → stateDiagram-v2-6OUMAXLB-x_Zps-d5.js} +2 -2
  147. package/dist/styles/markdown.css +1 -1
  148. package/dist/{swimlanes-5IMT3BWC-B1hLl8Ph.cjs → swimlanes-5IMT3BWC-CfdkDd3q.cjs} +1 -1
  149. package/dist/{swimlanes-5IMT3BWC-DujAOwAt.js → swimlanes-5IMT3BWC-D8brzzxb.js} +313 -313
  150. package/dist/{swimlanesDiagram-G3AALYLV-B-5z3jDg.js → swimlanesDiagram-G3AALYLV-Bc9-lR2e.js} +2 -2
  151. package/dist/{swimlanesDiagram-G3AALYLV-Cklgsxbg.cjs → swimlanesDiagram-G3AALYLV-dvJpSdGV.cjs} +1 -1
  152. package/dist/{timeline-definition-FHXFAJF6-B2m-aQLI.cjs → timeline-definition-FHXFAJF6-BSqACati.cjs} +1 -1
  153. package/dist/{timeline-definition-FHXFAJF6-Fmzt_lvR.js → timeline-definition-FHXFAJF6-CKW3NJOF.js} +34 -34
  154. package/dist/utils/simple-logger.d.ts +1 -0
  155. package/dist/{vennDiagram-L72KCM5P-rL7UDYbl.cjs → vennDiagram-L72KCM5P-ChKxsFyJ.cjs} +1 -1
  156. package/dist/{vennDiagram-L72KCM5P-zIXK42Cx.js → vennDiagram-L72KCM5P-vPmq984y.js} +92 -92
  157. package/dist/{wardleyDiagram-EHGQE667-pTeeZ0uM.js → wardleyDiagram-EHGQE667-CwN9zwBX.js} +11 -11
  158. package/dist/{wardleyDiagram-EHGQE667-CNLieFen.cjs → wardleyDiagram-EHGQE667-CxzlR7km.cjs} +1 -1
  159. package/dist/{xychartDiagram-FW5EYKEG-B6UdSSVZ.js → xychartDiagram-FW5EYKEG-DBSKTLuc.js} +37 -37
  160. package/dist/{xychartDiagram-FW5EYKEG-CD5ik4HK.cjs → xychartDiagram-FW5EYKEG-wJqYRInm.cjs} +1 -1
  161. package/package.json +25 -9
  162. package/dist/arc-DH6k2JIR.js +0 -83
  163. package/dist/channel-DoH_tsOQ.js +0 -5
  164. package/dist/components/mdastNodes/BlockLinkNode.d.ts +0 -5
  165. package/dist/components/mdastNodes/RichLinkCard.d.ts +0 -8
  166. package/dist/components/mdastNodes/TwitterEmbedNode.d.ts +0 -25
  167. package/dist/components/mdastNodes/YouTubeEmbedNode.d.ts +0 -6
  168. package/dist/extractHeadings-lDHB2sBb.cjs +0 -310
  169. package/dist/flowDiagram-23GEKE2U-ORytlvmX.js +0 -7
  170. package/dist/flowDiagram-23GEKE2U-h2WZTCCn.cjs +0 -1
  171. package/dist/plugins/createIntentTweetLink.d.ts +0 -10
  172. package/dist/plugins/extractYouTubeVideoId.d.ts +0 -5
  173. package/dist/plugins/fetchSiteMetadata.d.ts +0 -9
  174. package/dist/plugins/remark-auto-heading-id.d.ts +0 -2
  175. package/dist/plugins/remark-block-link-metadata.d.ts +0 -23
  176. package/dist/plugins/remark-block-link.d.ts +0 -12
  177. package/dist/plugins/remark-twitter-embed.d.ts +0 -20
  178. package/dist/plugins/remark-youtube-embed.d.ts +0 -14
  179. package/dist/utils/getFaviconUrl.d.ts +0 -1
@@ -1,56 +1,459 @@
1
- import { load as I } from "cheerio";
2
- import { L as B } from "./simple-logger-i94ikRyH.js";
3
- import { visit as J } from "unist-util-visit";
4
- import { spawn as $ } from "node:child_process";
5
- import { existsSync as k, unlinkSync as C } from "node:fs";
6
- import { createRequire as H } from "node:module";
7
- import * as _ from "node:net";
8
- import * as M from "node:path";
9
- import { fileURLToPath as L } from "node:url";
10
- import { createClient as O, ConnectError as q, Code as D } from "@connectrpc/connect";
11
- import { Http2SessionManager as F, createConnectTransport as K } from "@connectrpc/connect-node";
12
- import { Message as S, proto3 as o, MethodKind as U } from "@bufbuild/protobuf";
13
- const Y = async (r) => {
1
+ import { l as L, L as O, a as se, b as ke } from "./linkCards-1JxY8wdm.js";
2
+ import { l as h } from "./simple-logger-DwH1YQvq.js";
3
+ import { Resolver as be } from "node:dns/promises";
4
+ import * as ie from "node:net";
5
+ import { BlockList as ye, isIP as le, connect as Te } from "node:net";
6
+ import { Agent as Se, buildConnector as Y, fetch as ve } from "undici";
7
+ import { Parser as Ae } from "htmlparser2";
8
+ import { spawn as _e } from "node:child_process";
9
+ import { existsSync as M, unlinkSync as Re } from "node:fs";
10
+ import { createRequire as Le } from "node:module";
11
+ import * as C from "node:path";
12
+ import { fileURLToPath as Oe } from "node:url";
13
+ import { createClient as Pe, ConnectError as Me, Code as Ce } from "@connectrpc/connect";
14
+ import { Http2SessionManager as Ie, createConnectTransport as xe } from "@connectrpc/connect-node";
15
+ import { Message as x, proto3 as d, MethodKind as Ne } from "@bufbuild/protobuf";
16
+ const De = [
17
+ [[0], 8],
18
+ [[10], 8],
19
+ [[100, 64], 10],
20
+ [[127], 8],
21
+ [[169, 254], 16],
22
+ [[172, 16], 12],
23
+ [[192, 0, 0], 24],
24
+ [[192, 0, 2], 24],
25
+ [[192, 168], 16],
26
+ [[198, 18], 15],
27
+ [[198, 51, 100], 24],
28
+ [[203, 0, 113], 24],
29
+ [[224], 4],
30
+ [[240], 4]
31
+ ], Be = [
32
+ [[100, 65435], 32],
33
+ [[0, 0, 0, 0, 65535, 0], 96],
34
+ [[256, 0, 0, 0], 64],
35
+ [[256, 0, 0, 1], 64],
36
+ [[8193, 0], 32],
37
+ [[8193, 2, 0], 48],
38
+ [[8193, 3512], 32],
39
+ [[8194], 16],
40
+ [[16383], 20],
41
+ [[24320], 16],
42
+ [[64512], 7],
43
+ [[65152], 10],
44
+ [[65216], 10],
45
+ [[65280], 8]
46
+ ], y = new ye();
47
+ for (const [r, t] of De) {
48
+ const e = [...r, 0, 0, 0].slice(0, 4).join(".");
49
+ y.addSubnet(e, t, "ipv4"), y.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), y.addSubnet(`::${e}`, 96 + t, "ipv6");
50
+ }
51
+ for (const [r, t] of Be)
52
+ y.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
53
+ const U = (r) => {
54
+ const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = le(t);
55
+ return e !== 0 && y.check(t, e === 4 ? "ipv4" : "ipv6");
56
+ }, ce = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new be({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
57
+ error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: ce })
58
+ }), He = async (r, t) => {
59
+ const e = le(r);
60
+ if (e !== 0)
61
+ return U(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
62
+ const [n, o] = await Promise.allSettled([t === 6 ? Promise.resolve([]) : q.resolve4(r), t === 4 ? Promise.resolve([]) : q.resolve6(r)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) => U(R));
63
+ if (i !== void 0) return Q(r, i);
64
+ const [l, ...c] = s;
65
+ if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
66
+ const [f, ...S] = a;
67
+ return f !== void 0 ? { error: null, family: 6, addresses: [f, ...S] } : n.status === "rejected" ? { error: n.reason } : o.status === "rejected" ? { error: o.reason } : { error: Object.assign(new Error(`No address for ${r}`), { code: "ENOTFOUND" }) };
68
+ }, Ue = (r, t, e) => {
69
+ const n = t.family === 4 || t.family === "IPv4" ? 4 : t.family === 6 || t.family === "IPv6" ? 6 : 0;
70
+ He(r, n).then((o) => {
71
+ if (o.error !== null) {
72
+ e(o.error, "");
73
+ return;
74
+ }
75
+ const { family: s, addresses: a } = o;
76
+ t.all === !0 ? e(
77
+ null,
78
+ a.map((i) => ({ address: i, family: s }))
79
+ ) : e(null, a[0], s);
80
+ });
81
+ }, $e = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), je = [".local", ".internal", ".home.arpa"], j = (r, t) => {
82
+ let e;
83
+ try {
84
+ e = new URL(r);
85
+ } catch {
86
+ return { ok: !1, reason: "forbidden-url", detail: "Invalid URL" };
87
+ }
88
+ if (e.protocol !== "http:" && e.protocol !== "https:")
89
+ return { ok: !1, reason: "forbidden-url", detail: "Only http(s) URLs are allowed" };
90
+ if (e.username !== "" || e.password !== "")
91
+ return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
92
+ e.hash = "";
93
+ const n = e.hostname.replace(/\.+$/u, "");
94
+ return n === "localhost" || n.endsWith(".localhost") || $e.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : U(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || je.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
95
+ }, ue = (r) => {
96
+ let t;
14
97
  try {
15
- const e = new AbortController(), t = setTimeout(() => e.abort(), 1e4), c = await fetch(r, { signal: e.signal });
16
- if (clearTimeout(t), !c.ok)
17
- return null;
18
- const s = await c.text(), a = { url: r }, i = I(s), n = i("title").text().trim();
19
- a.title = n;
20
- const w = i("meta");
21
- for (const m of w) {
22
- const h = m.attribs.property;
23
- h === "og:site_name" && (a.site_name = m.attribs.content || void 0), h === "og:title" && (a.title = m.attribs.content || n), h === "og:description" && (a.description = m.attribs.content || void 0), h === "og:image" && (a.image = m.attribs.content || void 0), h === "og:type" && (a.type = m.attribs.content || void 0), m.attribs.name === "description" && (a.description = m.attribs.content || void 0);
98
+ t = new URL(r);
99
+ } catch {
100
+ return "(unparsable URL)";
101
+ }
102
+ return t.protocol !== "http:" && t.protocol !== "https:" ? `(a ${t.protocol} URL)` : (t.username = "", t.password = "", t.href);
103
+ }, de = 1024, ze = /^[\t\n\f\r ]$/u, w = (r) => ze.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), $ = (r) => {
104
+ try {
105
+ return new TextDecoder(r).encoding;
106
+ } catch {
107
+ return null;
108
+ }
109
+ }, Je = (r) => r[0] === 239 && r[1] === 187 && r[2] === 191 ? "utf-8" : r[0] === 254 && r[1] === 255 ? "utf-16be" : r[0] === 255 && r[1] === 254 ? "utf-16le" : null, Ke = (r) => {
110
+ for (const t of r.split(";").slice(1)) {
111
+ const e = t.indexOf("=");
112
+ if (e !== -1 && t.slice(0, e).trim().toLowerCase() === "charset")
113
+ return t.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
114
+ }
115
+ return null;
116
+ }, Fe = (r) => {
117
+ let t = 0;
118
+ for (; ; ) {
119
+ const e = r.indexOf("charset", t);
120
+ if (e === -1) return null;
121
+ let n = e + 7;
122
+ for (; w(r.charAt(n)); ) n += 1;
123
+ if (r.charAt(n) !== "=") {
124
+ t = n;
125
+ continue;
24
126
  }
25
- return a;
26
- } catch (e) {
27
- return B.error("Error fetching site metadata:", e), null;
28
- }
29
- }, b = /* @__PURE__ */ new Map(), j = (r, e) => e.fetchAll ? !0 : e.urlPatterns && e.urlPatterns.length > 0 ? e.urlPatterns.some((t) => t.test(r)) : /^https?:\/\//.test(r) && !r.includes("localhost") && !r.includes("127.0.0.1"), pe = (r = {}) => {
30
- const { enableCache: e = !0 } = r;
31
- return async (t) => {
32
- const c = [];
33
- J(t, "block-link", (a) => {
34
- j(a.url, r) && c.push(a);
35
- });
36
- const s = c.map(async (a) => {
37
- const i = a.url;
38
- if (e && b.has(i)) {
39
- const n = b.get(i);
40
- n && (a.data = a.data || {}, a.data.siteMetadata = n);
41
- return;
42
- }
43
- try {
44
- const n = await Y(i);
45
- n ? (a.data = a.data || {}, a.data.siteMetadata = n, e && b.set(i, n)) : e && b.set(i, null);
46
- } catch (n) {
47
- B.warn(`Failed to fetch metadata for ${i}:`, n), e && b.set(i, null);
127
+ for (n += 1; w(r.charAt(n)); ) n += 1;
128
+ const o = r.charAt(n);
129
+ if (o === '"' || o === "'") {
130
+ const a = r.indexOf(o, n + 1);
131
+ return a === -1 ? null : r.slice(n + 1, a);
132
+ }
133
+ const s = r.slice(n).search(/[\t\n\f\r ;]/u);
134
+ return s === -1 ? r.slice(n) : r.slice(n, n + s);
135
+ }
136
+ }, fe = (r, t) => {
137
+ let e = t;
138
+ for (; w(r.charAt(e)) || r.charAt(e) === "/"; ) e += 1;
139
+ if (r.charAt(e) === ">" || e >= r.length) return { attribute: null, end: e };
140
+ let n = "";
141
+ for (; ; ) {
142
+ const a = r.charAt(e);
143
+ if (a === "") return { attribute: null, end: e };
144
+ if (a === "=" && n !== "") break;
145
+ if (w(a)) {
146
+ for (; w(r.charAt(e)); ) e += 1;
147
+ if (r.charAt(e) !== "=") return { attribute: { name: n, value: "" }, end: e };
148
+ break;
149
+ }
150
+ if (a === "/" || a === ">") return { attribute: { name: n, value: "" }, end: e };
151
+ n += B(a), e += 1;
152
+ }
153
+ for (e += 1; w(r.charAt(e)); ) e += 1;
154
+ const o = r.charAt(e);
155
+ if (o === '"' || o === "'") {
156
+ const a = r.indexOf(o, e + 1);
157
+ return a === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e + 1, a)) }, end: a + 1 };
158
+ }
159
+ if (o === ">") return { attribute: { name: n, value: "" }, end: e };
160
+ const s = r.slice(e).search(/[\t\n\f\r >]/u);
161
+ return s === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e, e + s)) }, end: e + s };
162
+ }, Ge = (r, t) => {
163
+ const e = /* @__PURE__ */ new Set();
164
+ let n = !1, o = null, s = null, a = t;
165
+ for (; ; ) {
166
+ const { attribute: i, end: l } = fe(r, a);
167
+ if (a = l, i === null) break;
168
+ if (!e.has(i.name))
169
+ if (e.add(i.name), i.name === "http-equiv")
170
+ n = i.value === "content-type";
171
+ else if (i.name === "content") {
172
+ const c = Fe(i.value), f = c === null ? null : $(c);
173
+ f !== null && s === null && (s = f, o = !0);
174
+ } else i.name === "charset" && (s = $(i.value) ?? !1, o = !1);
175
+ }
176
+ return o === null || typeof s != "string" || o && !n ? { encoding: null, end: a } : s === "utf-16be" || s === "utf-16le" ? { encoding: "utf-8", end: a } : { encoding: s === "x-user-defined" ? "windows-1252" : s, end: a };
177
+ }, Xe = (r) => {
178
+ const t = Array.from(r.subarray(0, de), (n) => String.fromCharCode(n)).join("");
179
+ let e = 0;
180
+ for (; e < t.length; )
181
+ if (t.startsWith("<!--", e)) {
182
+ const n = t.indexOf("-->", e + 2);
183
+ if (n === -1) return null;
184
+ e = n + 3;
185
+ } else if (/^<meta[\t\n\f\r /]$/iu.test(t.slice(e, e + 6))) {
186
+ const { encoding: n, end: o } = Ge(t, e + 5);
187
+ if (n !== null) return n;
188
+ e = o + 1;
189
+ } else if (/^<\/?[A-Za-z]/u.test(t.slice(e, e + 3))) {
190
+ let n = e + 1;
191
+ for (; n < t.length && !w(t.charAt(n)) && t.charAt(n) !== ">"; ) n += 1;
192
+ for (; ; ) {
193
+ const o = fe(t, n);
194
+ if (n = o.end, o.attribute === null) break;
48
195
  }
196
+ e = n + 1;
197
+ } else if (/^<[!/?]$/u.test(t.slice(e, e + 2))) {
198
+ const n = t.indexOf(">", e + 1);
199
+ if (n === -1) return null;
200
+ e = n + 1;
201
+ } else
202
+ e += 1;
203
+ return null;
204
+ }, Ve = (r, t) => {
205
+ const e = Je(r);
206
+ if (e !== null) return e;
207
+ const n = Ke(t), o = n === null ? null : $(n);
208
+ return o !== null ? o : Xe(r) ?? "utf-8";
209
+ }, We = (r, t) => {
210
+ const e = new Uint8Array(t);
211
+ let n = 0;
212
+ for (const o of r)
213
+ e.set(o, n), n += o.byteLength;
214
+ return e;
215
+ }, Ye = (r) => {
216
+ const t = [];
217
+ let e = 0, n = null;
218
+ const o = () => {
219
+ const s = We(t, e);
220
+ t.length = 0;
221
+ const a = new TextDecoder(Ve(s, r));
222
+ return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
223
+ };
224
+ return {
225
+ write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < de ? "" : o().text),
226
+ end: () => {
227
+ if (n !== null) return n.decode();
228
+ const { started: s, text: a } = o();
229
+ return a + s.decode();
230
+ }
231
+ };
232
+ }, Ze = (r, t, e) => {
233
+ const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
234
+ return (s) => {
235
+ const a = n.get(s);
236
+ if (a !== void 0 && a.expireAt > e()) return Promise.resolve(a.value);
237
+ const i = o.get(s);
238
+ if (i !== void 0) return i;
239
+ const l = r(s).then((c) => (!n.has(s) && n.size >= t.maxEntries && n.delete(n.keys().next().value), n.set(s, { value: c, expireAt: e() + t.ttlMsOf(c) }), c)).finally(() => {
240
+ o.delete(s);
49
241
  });
50
- await Promise.all(s);
242
+ return o.set(s, l), l;
51
243
  };
52
- };
53
- class d extends S {
244
+ }, qe = 65536, Qe = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), et = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), tt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", ce]), me = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), rt = Object.freeze({ lookup: Ue, blockList: y }), nt = (r, t) => {
245
+ const e = Y({ lookup: r.lookup, blockList: r.blockList, timeout: t }), n = Y({ timeout: t });
246
+ return (o, s) => {
247
+ if (o.protocol !== "https:") {
248
+ e(o, s);
249
+ return;
250
+ }
251
+ const a = Te({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup: r.lookup, blockList: r.blockList }), i = (l) => {
252
+ a.destroy(), s(l, null);
253
+ };
254
+ a.setTimeout(t, () => i(Object.assign(new Error(`Connect timeout: ${o.hostname}`), { code: "UND_ERR_CONNECT_TIMEOUT" }))), a.once("error", i), a.once("connect", () => {
255
+ a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
256
+ });
257
+ };
258
+ }, ot = (r) => new Se({
259
+ maxHeaderSize: qe,
260
+ connect: nt(rt, me.timeoutMs)
261
+ }), H = async (r) => {
262
+ r.body !== null && await Promise.allSettled([r.body.cancel()]);
263
+ }, at = (r) => r !== null && et.has(r.split(";", 1)[0].trim().toLowerCase()), st = (r) => {
264
+ const t = [r];
265
+ for (let e = 0; e < 16 && t.length > 0; e += 1) {
266
+ const n = t.shift();
267
+ if (!(n instanceof Error)) continue;
268
+ const o = n.code;
269
+ if (typeof o == "string" && tt.has(o)) return n.message;
270
+ t.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
271
+ }
272
+ return null;
273
+ }, pe = (r, t) => {
274
+ const e = st(r);
275
+ return e !== null ? (h.info("Refused link-card connection to a private address:", t, e), { ok: !1, reason: "private-network" }) : (h.error("Error fetching link-card metadata:", r), { ok: !1, reason: "unreachable" });
276
+ }, it = () => new Promise((r) => {
277
+ setImmediate(r);
278
+ }), lt = async (r, t, e, n) => {
279
+ if (r.body === null) return { ok: !0, value: t.end() };
280
+ const o = r.body.getReader();
281
+ let s = 0;
282
+ for (; ; ) {
283
+ let a;
284
+ try {
285
+ a = await o.read();
286
+ } catch (f) {
287
+ return pe(f, n);
288
+ }
289
+ if (a.done) break;
290
+ const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
291
+ if (s += c.byteLength, !t.write(c)) {
292
+ await Promise.allSettled([o.cancel()]);
293
+ break;
294
+ }
295
+ if (l) {
296
+ await Promise.allSettled([o.cancel()]), h.warn("Link-card page body exceeds the size limit; parsing only its first bytes:", n, e);
297
+ break;
298
+ }
299
+ await it();
300
+ }
301
+ return { ok: !0, value: t.end() };
302
+ }, ct = async (r, t, e, n) => {
303
+ let o = r;
304
+ for (let s = 0; s <= t.limits.maxRedirects; s += 1) {
305
+ let a;
306
+ try {
307
+ a = await ve(o, { signal: n, redirect: "manual", dispatcher: t.agent });
308
+ } catch (f) {
309
+ return pe(f, o);
310
+ }
311
+ const i = Qe.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
312
+ if (i === "") {
313
+ if (!a.ok)
314
+ return await H(a), { ok: !1, reason: "unreachable" };
315
+ const f = a.headers.get("content-type");
316
+ return at(f) ? lt(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await H(a), { ok: !1, reason: "not-html" });
317
+ }
318
+ await H(a);
319
+ let l;
320
+ try {
321
+ l = new URL(i, o);
322
+ } catch {
323
+ return h.error("Blocked redirect to an unparsable Location from:", o), { ok: !1, reason: "unreachable" };
324
+ }
325
+ const c = j(l.href);
326
+ if (!c.ok)
327
+ return h.info("Refused link-card redirect:", ue(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
328
+ o = c.href;
329
+ }
330
+ return h.error("Too many redirects while fetching link-card metadata:", r), { ok: !1, reason: "unreachable" };
331
+ }, ut = (r, t, e) => {
332
+ const n = new AbortController(), o = setTimeout(() => n.abort(), t.limits.timeoutMs);
333
+ return ct(r, t, e, n.signal).finally(() => {
334
+ clearTimeout(o);
335
+ });
336
+ }, dt = 256, ft = 4096, mt = 64, pt = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), ht = /* @__PURE__ */ new Set(["title", "script", "style"]), wt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), gt = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, Et = (r, t) => {
337
+ if (r === void 0) return t;
338
+ let e;
339
+ try {
340
+ e = new URL(r, t);
341
+ } catch {
342
+ return t;
343
+ }
344
+ return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= se ? e.href : t;
345
+ }, ee = (r, t, e) => {
346
+ const n = r?.trim();
347
+ if (n === void 0 || n === "") return;
348
+ let o;
349
+ try {
350
+ o = new URL(n, t);
351
+ } catch {
352
+ return;
353
+ }
354
+ return o.href.length <= se && j(o.href).ok ? o.href : void 0;
355
+ }, kt = (r, t) => {
356
+ let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, S, R, z, J, K = !1, F, G = !1;
357
+ const N = () => {
358
+ e = !0, D.pause();
359
+ }, D = new Ae(
360
+ {
361
+ onopentagname(u) {
362
+ n += 1, o += 1, s = 0, (n > dt || o > ft || a === null && !pt.has(u)) && N();
363
+ },
364
+ onattribute() {
365
+ s += 1, s > mt && N();
366
+ },
367
+ onopentag(u, m) {
368
+ if (!(e || a !== null)) {
369
+ if (wt.has(u)) {
370
+ a = n;
371
+ return;
372
+ }
373
+ if (u === "meta") {
374
+ const p = m.content;
375
+ m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (S = p), m.property === "og:image" && (z = p), m.name === "description" && (S = p);
376
+ } else u === "link" && !K && gt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
377
+ ht.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
378
+ }
379
+ },
380
+ ontext(u) {
381
+ a === null && (l !== null ? l += u : i === null && /[^\t\n\f\r ]/u.test(u) && N());
382
+ },
383
+ onclosetag(u) {
384
+ if (!e) {
385
+ if (n -= 1, a !== null) {
386
+ n < a && (a = null);
387
+ return;
388
+ }
389
+ u === i && (i = null, l !== null && (c = l, l = null));
390
+ }
391
+ }
392
+ },
393
+ { decodeEntities: !0 }
394
+ );
395
+ return {
396
+ write: (u) => (e || D.write(u), !e),
397
+ end: () => {
398
+ e || D.end();
399
+ const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = Et(F, r), V = ee(z, X), W = ee(J, X);
400
+ return {
401
+ ...u === null ? {} : { title: u },
402
+ ...m === null ? {} : { description: m },
403
+ ...p === null ? {} : { site_name: p },
404
+ ...V === void 0 ? {} : { image: V },
405
+ ...W === void 0 ? {} : { icon: W }
406
+ };
407
+ }
408
+ };
409
+ }, bt = /* @__PURE__ */ new Set(["authorize"]), yt = "private, max-age=1800", Tt = 3600 * 1e3, he = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), St = 1e3, P = "no-store", v = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
410
+ status: t,
411
+ headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
412
+ }), te = (r) => new Response(null, {
413
+ status: 204,
414
+ headers: { "Cache-Control": `private, max-age=${he[r]}`, "X-Content-Type-Options": "nosniff", [ke]: r }
415
+ }), vt = (r) => {
416
+ if (typeof r != "object" || r === null)
417
+ throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
418
+ if (typeof r.authorize != "function")
419
+ throw new TypeError("createLinkCardHandler: options.authorize must be a function (pass () => true to serve everyone)");
420
+ const t = Object.keys(r).filter((e) => !bt.has(e));
421
+ if (t.length > 0)
422
+ throw new TypeError(`createLinkCardHandler: unknown option(s): ${t.join(", ")}`);
423
+ }, At = (r) => (t) => {
424
+ const e = Ye(t.contentType), n = kt(t.url);
425
+ return {
426
+ write: (o) => n.write(e.write(o)),
427
+ end: () => (n.write(e.end()), n.end())
428
+ };
429
+ }, _t = (r, t) => {
430
+ vt(r);
431
+ const { authorize: e } = r, n = ot(), o = Ze(
432
+ (s) => ut(s, { agent: n, scope: t, limits: me }, At()),
433
+ { maxEntries: St, ttlMsOf: (s) => s.ok ? Tt : he[s.reason] * 1e3 },
434
+ Date.now
435
+ );
436
+ return async (s) => {
437
+ if (s.method !== "GET" && s.method !== "HEAD")
438
+ return v(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
439
+ if (await e(s) !== !0)
440
+ return v(s, 401, { error: "Unauthorized" }, P);
441
+ const a = new URL(s.url).searchParams.get("url");
442
+ if (a === null || a === "")
443
+ return v(s, 400, { error: "Missing 'url' parameter" }, P);
444
+ const i = j(a);
445
+ if (!i.ok)
446
+ return h.info("Refused link-card URL:", ue(a), `(${i.reason}: ${i.detail})`), te(i.reason);
447
+ let l;
448
+ try {
449
+ l = await o(i.href);
450
+ } catch (c) {
451
+ return h.error("Unexpected error while reading link-card metadata:", i.href, c), v(s, 500, { error: "Internal Server Error" }, P);
452
+ }
453
+ return l.ok ? v(s, 200, l.value, yt) : te(l.reason);
454
+ };
455
+ }, Yt = (r) => _t(r, "public");
456
+ class E extends x {
54
457
  /**
55
458
  * @generated from field: string markdown_text = 1;
56
459
  */
@@ -146,12 +549,12 @@ class d extends S {
146
549
  * @generated from field: markdown.v1.DenyRules deny = 13;
147
550
  */
148
551
  deny;
149
- constructor(e) {
150
- super(), o.util.initPartial(e, this);
552
+ constructor(t) {
553
+ super(), d.util.initPartial(t, this);
151
554
  }
152
- static runtime = o;
555
+ static runtime = d;
153
556
  static typeName = "markdown.v1.ConvertRequest";
154
- static fields = o.util.newFieldList(() => [
557
+ static fields = d.util.newFieldList(() => [
155
558
  {
156
559
  no: 1,
157
560
  name: "markdown_text",
@@ -194,46 +597,46 @@ class d extends S {
194
597
  /* ScalarType.BOOL */
195
598
  },
196
599
  { no: 12, name: "max_html_bytes", kind: "scalar", T: 13, opt: !0 },
197
- { no: 13, name: "deny", kind: "message", T: l }
600
+ { no: 13, name: "deny", kind: "message", T: g }
198
601
  ]);
199
- static fromBinary(e, t) {
200
- return new d().fromBinary(e, t);
602
+ static fromBinary(t, e) {
603
+ return new E().fromBinary(t, e);
201
604
  }
202
- static fromJson(e, t) {
203
- return new d().fromJson(e, t);
605
+ static fromJson(t, e) {
606
+ return new E().fromJson(t, e);
204
607
  }
205
- static fromJsonString(e, t) {
206
- return new d().fromJsonString(e, t);
608
+ static fromJsonString(t, e) {
609
+ return new E().fromJsonString(t, e);
207
610
  }
208
- static equals(e, t) {
209
- return o.util.equals(d, e, t);
611
+ static equals(t, e) {
612
+ return d.util.equals(E, t, e);
210
613
  }
211
614
  }
212
- class l extends S {
615
+ class g extends x {
213
616
  /**
214
617
  * @generated from field: repeated string segment_patterns = 1;
215
618
  */
216
619
  segmentPatterns = [];
217
- constructor(e) {
218
- super(), o.util.initPartial(e, this);
620
+ constructor(t) {
621
+ super(), d.util.initPartial(t, this);
219
622
  }
220
- static runtime = o;
623
+ static runtime = d;
221
624
  static typeName = "markdown.v1.DenyRules";
222
- static fields = o.util.newFieldList(() => [{ no: 1, name: "segment_patterns", kind: "scalar", T: 9, repeated: !0 }]);
223
- static fromBinary(e, t) {
224
- return new l().fromBinary(e, t);
625
+ static fields = d.util.newFieldList(() => [{ no: 1, name: "segment_patterns", kind: "scalar", T: 9, repeated: !0 }]);
626
+ static fromBinary(t, e) {
627
+ return new g().fromBinary(t, e);
225
628
  }
226
- static fromJson(e, t) {
227
- return new l().fromJson(e, t);
629
+ static fromJson(t, e) {
630
+ return new g().fromJson(t, e);
228
631
  }
229
- static fromJsonString(e, t) {
230
- return new l().fromJsonString(e, t);
632
+ static fromJsonString(t, e) {
633
+ return new g().fromJsonString(t, e);
231
634
  }
232
- static equals(e, t) {
233
- return o.util.equals(l, e, t);
635
+ static equals(t, e) {
636
+ return d.util.equals(g, t, e);
234
637
  }
235
638
  }
236
- class u extends S {
639
+ class k extends x {
237
640
  /**
238
641
  * @generated from field: string html_content = 1;
239
642
  */
@@ -242,12 +645,12 @@ class u extends S {
242
645
  * @generated from field: repeated markdown.v1.Heading headings = 2;
243
646
  */
244
647
  headings = [];
245
- constructor(e) {
246
- super(), o.util.initPartial(e, this);
648
+ constructor(t) {
649
+ super(), d.util.initPartial(t, this);
247
650
  }
248
- static runtime = o;
651
+ static runtime = d;
249
652
  static typeName = "markdown.v1.ConvertResponse";
250
- static fields = o.util.newFieldList(() => [
653
+ static fields = d.util.newFieldList(() => [
251
654
  {
252
655
  no: 1,
253
656
  name: "html_content",
@@ -255,22 +658,22 @@ class u extends S {
255
658
  T: 9
256
659
  /* ScalarType.STRING */
257
660
  },
258
- { no: 2, name: "headings", kind: "message", T: f, repeated: !0 }
661
+ { no: 2, name: "headings", kind: "message", T: b, repeated: !0 }
259
662
  ]);
260
- static fromBinary(e, t) {
261
- return new u().fromBinary(e, t);
663
+ static fromBinary(t, e) {
664
+ return new k().fromBinary(t, e);
262
665
  }
263
- static fromJson(e, t) {
264
- return new u().fromJson(e, t);
666
+ static fromJson(t, e) {
667
+ return new k().fromJson(t, e);
265
668
  }
266
- static fromJsonString(e, t) {
267
- return new u().fromJsonString(e, t);
669
+ static fromJsonString(t, e) {
670
+ return new k().fromJsonString(t, e);
268
671
  }
269
- static equals(e, t) {
270
- return o.util.equals(u, e, t);
672
+ static equals(t, e) {
673
+ return d.util.equals(k, t, e);
271
674
  }
272
675
  }
273
- class f extends S {
676
+ class b extends x {
274
677
  /**
275
678
  * @generated from field: string text = 1;
276
679
  */
@@ -283,12 +686,12 @@ class f extends S {
283
686
  * @generated from field: string id = 3;
284
687
  */
285
688
  id = "";
286
- constructor(e) {
287
- super(), o.util.initPartial(e, this);
689
+ constructor(t) {
690
+ super(), d.util.initPartial(t, this);
288
691
  }
289
- static runtime = o;
692
+ static runtime = d;
290
693
  static typeName = "markdown.v1.Heading";
291
- static fields = o.util.newFieldList(() => [
694
+ static fields = d.util.newFieldList(() => [
292
695
  {
293
696
  no: 1,
294
697
  name: "text",
@@ -311,20 +714,20 @@ class f extends S {
311
714
  /* ScalarType.STRING */
312
715
  }
313
716
  ]);
314
- static fromBinary(e, t) {
315
- return new f().fromBinary(e, t);
717
+ static fromBinary(t, e) {
718
+ return new b().fromBinary(t, e);
316
719
  }
317
- static fromJson(e, t) {
318
- return new f().fromJson(e, t);
720
+ static fromJson(t, e) {
721
+ return new b().fromJson(t, e);
319
722
  }
320
- static fromJsonString(e, t) {
321
- return new f().fromJsonString(e, t);
723
+ static fromJsonString(t, e) {
724
+ return new b().fromJsonString(t, e);
322
725
  }
323
- static equals(e, t) {
324
- return o.util.equals(f, e, t);
726
+ static equals(t, e) {
727
+ return d.util.equals(b, t, e);
325
728
  }
326
729
  }
327
- const G = {
730
+ const Rt = {
328
731
  typeName: "markdown.v1.MarkdownService",
329
732
  methods: {
330
733
  /**
@@ -332,148 +735,147 @@ const G = {
332
735
  */
333
736
  convert: {
334
737
  name: "Convert",
335
- I: d,
336
- O: u,
337
- kind: U.Unary
738
+ I: E,
739
+ O: k,
740
+ kind: Ne.Unary
338
741
  }
339
742
  }
340
- }, p = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", W = new F("http://localhost", void 0, {
341
- createConnection: () => _.connect(p)
342
- }), N = 64 * 1024, X = 4294967295, v = Math.floor((X - N) / 2);
343
- class Z extends Error {
743
+ }, T = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Lt = new Ie("http://localhost", void 0, {
744
+ createConnection: () => ie.connect(T)
745
+ }), we = 64 * 1024, Ot = 4294967295, re = Math.floor((Ot - we) / 2);
746
+ class Pt extends Error {
344
747
  /**
345
748
  * Wraps the service's or the transport's resource-exhausted error.
346
749
  * サービスか転送の resource exhausted のエラーを包む処理。
347
750
  *
348
751
  * @param cause - The connect error. connect のエラー。
349
752
  */
350
- constructor(e) {
351
- super(e.rawMessage, { cause: e }), this.name = "MarkdownResourceExhaustedError";
753
+ constructor(t) {
754
+ super(t.rawMessage, { cause: t }), this.name = "MarkdownResourceExhaustedError";
352
755
  }
353
756
  }
354
- const x = () => {
757
+ const ne = () => {
355
758
  try {
356
- return M.dirname(L(import.meta.url));
759
+ return C.dirname(Oe(import.meta.url));
357
760
  } catch {
358
761
  return __dirname;
359
762
  }
360
- }, A = () => `@aiquants/markdown-${process.platform}-${process.arch}`, E = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", z = () => {
763
+ }, ge = () => `@aiquants/markdown-${process.platform}-${process.arch}`, oe = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Mt = () => {
361
764
  const r = process.env.MARKDOWN_API_BINARY;
362
- if (r && k(r))
765
+ if (r && M(r))
363
766
  return r;
364
767
  try {
365
- const t = H(M.join(x(), "index.js")).resolve(`${A()}/${E()}`);
366
- if (k(t))
367
- return t;
768
+ const e = Le(C.join(ne(), "index.js")).resolve(`${ge()}/${oe()}`);
769
+ if (M(e))
770
+ return e;
368
771
  } catch {
369
772
  }
370
- const e = M.join(x(), "..", "..", "go", "markdown-api", "dist", M.basename(E()));
371
- return k(e) ? e : void 0;
372
- }, V = () => [
773
+ const t = C.join(ne(), "..", "..", "go", "markdown-api", "dist", C.basename(oe()));
774
+ return M(t) ? t : void 0;
775
+ }, Ct = () => [
373
776
  `markdown-api binary not found for ${process.platform}-${process.arch}.`,
374
- `Expected the optional dependency ${A()} to be installed.`,
777
+ `Expected the optional dependency ${ge()} to be installed.`,
375
778
  "If your platform is unsupported, build the service yourself",
376
779
  "(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
377
780
  "and point MARKDOWN_API_BINARY at it."
378
- ].join(" "), R = () => new Promise((r) => {
379
- const e = _.connect(p);
380
- e.on("connect", () => {
381
- e.destroy(), r(!0);
382
- }), e.on("error", () => r(!1));
383
- }), P = async (r) => {
384
- const e = Date.now();
385
- for (; Date.now() - e < r; ) {
386
- if (await R()) return !0;
387
- await new Promise((t) => setTimeout(t, 100));
781
+ ].join(" "), Ee = () => new Promise((r) => {
782
+ const t = ie.connect(T);
783
+ t.on("connect", () => {
784
+ t.destroy(), r(!0);
785
+ }), t.on("error", () => r(!1));
786
+ }), ae = async (r) => {
787
+ const t = Date.now();
788
+ for (; Date.now() - t < r; ) {
789
+ if (await Ee()) return !0;
790
+ await new Promise((e) => setTimeout(e, 100));
388
791
  }
389
792
  return !1;
390
793
  };
391
- let y = null, g = null;
392
- const Q = 2e3, ee = () => {
794
+ let A = null, _ = null;
795
+ const It = 2e3, xt = () => {
393
796
  const r = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
394
797
  return Number.isFinite(r) && r > 0 ? r : 1e4;
395
798
  };
396
- let T = null;
397
- const te = async () => {
398
- if (await R()) return !0;
399
- if (g) return g;
400
- g = (async () => {
401
- const e = z();
402
- if (!e)
403
- return await P(Q) ? !0 : (T = V(), !1);
404
- T = null;
799
+ let I = null;
800
+ const Nt = async () => {
801
+ if (await Ee()) return !0;
802
+ if (_) return _;
803
+ _ = (async () => {
804
+ const t = Mt();
805
+ if (!t)
806
+ return await ae(It) ? !0 : (I = Ct(), !1);
807
+ I = null;
405
808
  try {
406
- k(p) && C(p);
809
+ M(T) && Re(T);
407
810
  } catch {
408
811
  }
409
812
  try {
410
- y = $(e, [], { stdio: "ignore" });
411
- const t = () => {
412
- if (y) {
813
+ A = _e(t, [], { stdio: "ignore" });
814
+ const e = () => {
815
+ if (A) {
413
816
  try {
414
- y.kill("SIGTERM");
817
+ A.kill("SIGTERM");
415
818
  } catch {
416
819
  }
417
- y = null;
820
+ A = null;
418
821
  }
419
822
  };
420
- return process.once("exit", t), await P(ee()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", p), t(), process.removeListener("exit", t), !1);
421
- } catch (t) {
422
- return console.error("Failed to spawn markdown-api Go server:", t), y = null, !1;
823
+ return process.once("exit", e), await ae(xt()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", T), e(), process.removeListener("exit", e), !1);
824
+ } catch (e) {
825
+ return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
423
826
  }
424
827
  })();
425
- const r = await g;
426
- return r || (g = null), r;
427
- }, re = (r) => {
828
+ const r = await _;
829
+ return r || (_ = null), r;
830
+ }, Dt = (r) => {
428
831
  if (!Array.isArray(r.deniedPathSegments))
429
832
  throw new TypeError("parseMarkdown: deniedPathSegments must be an array of path segment patterns (an empty array denies nothing)");
430
- if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > v)
431
- throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${v}, got ${r.maxHtmlBytes}`);
833
+ if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > re)
834
+ throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${re}, got ${r.maxHtmlBytes}`);
432
835
  if (r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
433
836
  throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${r.timeoutMs}`);
434
- }, we = async (r, e, t, c, s) => {
435
- if (re(s), !await te()) {
436
- const n = T ? ` ${T}` : "";
437
- throw new Error(`markdown service is not reachable on ${p}.${n}`);
438
- }
439
- const a = {};
440
- c && (a.Authorization = `Bearer ${c}`);
441
- const i = O(G, K({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: W, readMaxBytes: 2 * s.maxHtmlBytes + N }));
837
+ }, Zt = async (r, t, e, n, o) => {
838
+ if (Dt(o), !await Nt()) {
839
+ const i = I ? ` ${I}` : "";
840
+ throw new Error(`markdown service is not reachable on ${T}.${i}`);
841
+ }
842
+ const s = {};
843
+ n && (s.Authorization = `Bearer ${n}`);
844
+ const a = Pe(Rt, xe({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Lt, readMaxBytes: 2 * o.maxHtmlBytes + we }));
442
845
  try {
443
- const n = await i.convert(
846
+ const i = await a.convert(
444
847
  {
445
848
  markdownText: r,
446
- filePath: e,
447
- workspaceRoot: t,
448
- validateExistence: s.validateExistence ?? !0,
449
- enableSubscript: s.enableSubscript,
450
- enableSuperscript: s.enableSuperscript,
451
- enableMark: s.enableMark,
452
- enableTableMerge: s.enableTableMerge,
453
- enableEmbeds: s.enableEmbeds,
454
- enableZennDirectives: s.enableZennDirectives,
455
- resolveImports: s.resolveImports ?? !1,
456
- maxHtmlBytes: s.maxHtmlBytes,
457
- deny: new l({ segmentPatterns: [...s.deniedPathSegments] })
849
+ filePath: t,
850
+ workspaceRoot: e,
851
+ validateExistence: o.validateExistence ?? !0,
852
+ enableSubscript: o.enableSubscript,
853
+ enableSuperscript: o.enableSuperscript,
854
+ enableMark: o.enableMark,
855
+ enableTableMerge: o.enableTableMerge,
856
+ enableEmbeds: o.enableEmbeds,
857
+ enableZennDirectives: o.enableZennDirectives,
858
+ resolveImports: o.resolveImports ?? !1,
859
+ maxHtmlBytes: o.maxHtmlBytes,
860
+ deny: new g({ segmentPatterns: [...o.deniedPathSegments] })
458
861
  },
459
- { headers: a, signal: s.signal, timeoutMs: s.timeoutMs }
862
+ { headers: s, signal: o.signal, timeoutMs: o.timeoutMs }
460
863
  );
461
864
  return {
462
- htmlContent: n.htmlContent,
463
- headings: n.headings.map((w) => ({
464
- text: w.text,
465
- depth: w.depth,
466
- id: w.id
865
+ htmlContent: i.htmlContent,
866
+ headings: i.headings.map((l) => ({
867
+ text: l.text,
868
+ depth: l.depth,
869
+ id: l.id
467
870
  }))
468
871
  };
469
- } catch (n) {
470
- throw n instanceof q && n.code === D.ResourceExhausted ? new Z(n) : n;
872
+ } catch (i) {
873
+ throw i instanceof Me && i.code === Ce.ResourceExhausted ? new Pt(i) : i;
471
874
  }
472
875
  };
473
876
  export {
474
- v as MAX_HTML_BYTES_LIMIT,
475
- Z as MarkdownResourceExhaustedError,
476
- Y as fetchSiteMetadata,
477
- we as parseMarkdown,
478
- pe as remarkBlockLinkMetadata
877
+ re as MAX_HTML_BYTES_LIMIT,
878
+ Pt as MarkdownResourceExhaustedError,
879
+ Yt as createLinkCardHandler,
880
+ Zt as parseMarkdown
479
881
  };