@aiquants/markdown 6.3.0 → 6.4.1

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 (143) hide show
  1. package/README.md +40 -3
  2. package/dist/{abnfDiagram-VRR7QNED-D3L_2hCD.js → abnfDiagram-VRR7QNED-2HHLEFYn.js} +3 -3
  3. package/dist/{abnfDiagram-VRR7QNED-BGUmgNQ4.cjs → abnfDiagram-VRR7QNED-B9qvbKps.cjs} +1 -1
  4. package/dist/{arc-ChEpDr_9.js → arc-DD1A3GS6.js} +1 -1
  5. package/dist/{arc-B48_ucR0.cjs → arc-DGI79XZe.cjs} +1 -1
  6. package/dist/{architectureDiagram-ZJ3FMSHR-Bg0dBVnf.cjs → architectureDiagram-ZJ3FMSHR-B7adKw79.cjs} +1 -1
  7. package/dist/{architectureDiagram-ZJ3FMSHR-D4ta1ajC.js → architectureDiagram-ZJ3FMSHR-C2Isv_kl.js} +2 -2
  8. package/dist/{blockDiagram-677ZJIJ3-CupyE7nK.js → blockDiagram-677ZJIJ3-BzDG3iuJ.js} +3 -3
  9. package/dist/{blockDiagram-677ZJIJ3-DkWMy8pP.cjs → blockDiagram-677ZJIJ3-tX1_79x-.cjs} +1 -1
  10. package/dist/{c4Diagram-LMCZKHZV-Cy1lIde9.js → c4Diagram-LMCZKHZV-C1E7x4pL.js} +2 -2
  11. package/dist/{c4Diagram-LMCZKHZV-DxOKAkJI.cjs → c4Diagram-LMCZKHZV-Cw3Nz-fO.cjs} +1 -1
  12. package/dist/{channel-TOZvPft0.cjs → channel-BDmOr8WI.cjs} +1 -1
  13. package/dist/{channel-C9c0_XwC.js → channel-rE7Nidar.js} +1 -1
  14. package/dist/{chunk-2Q5K7J3B-DaGwwho3.cjs → chunk-2Q5K7J3B-B_uu3ryF.cjs} +1 -1
  15. package/dist/{chunk-2Q5K7J3B-DahzXbiI.js → chunk-2Q5K7J3B-CTJGCzMl.js} +1 -1
  16. package/dist/{chunk-32BRIVSS-DFLtYkrI.js → chunk-32BRIVSS-80KutoA3.js} +1 -1
  17. package/dist/{chunk-32BRIVSS-BddWRgx3.cjs → chunk-32BRIVSS-BU3k8fI2.cjs} +1 -1
  18. package/dist/{chunk-5VM5RSS4-DiwEVqol.js → chunk-5VM5RSS4-B832yI0V.js} +1 -1
  19. package/dist/{chunk-5VM5RSS4-DSg2-2mp.cjs → chunk-5VM5RSS4-uqdZf5S-.cjs} +1 -1
  20. package/dist/{chunk-EX3LRPZG-OD-kvRfM.cjs → chunk-EX3LRPZG-5HbToUCP.cjs} +1 -1
  21. package/dist/{chunk-EX3LRPZG-Ca4uquaA.js → chunk-EX3LRPZG-DApvzt_L.js} +4 -4
  22. package/dist/{chunk-JWPE2WC7-BGdnK7yg.cjs → chunk-JWPE2WC7-CBmUqzlg.cjs} +1 -1
  23. package/dist/{chunk-JWPE2WC7-njgGfGvE.js → chunk-JWPE2WC7-Dum8Mfkz.js} +1 -1
  24. package/dist/{chunk-MOJQB5TN-B-H_fDpi.js → chunk-MOJQB5TN-EODWFr7m.js} +1 -1
  25. package/dist/{chunk-MOJQB5TN-DPs_chEk.cjs → chunk-MOJQB5TN-hBYZmLmM.cjs} +1 -1
  26. package/dist/{chunk-PUDLZKDR-9xQzJ025.js → chunk-PUDLZKDR-C2TE3L5R.js} +6 -6
  27. package/dist/{chunk-PUDLZKDR-DZphdeDg.cjs → chunk-PUDLZKDR-Cy-CXwf7.cjs} +1 -1
  28. package/dist/{chunk-RYQCIY6F-BNzT71C4.js → chunk-RYQCIY6F-BEpprYHU.js} +1 -1
  29. package/dist/{chunk-RYQCIY6F-8Qpsw4iJ.cjs → chunk-RYQCIY6F-DYWz_eP5.cjs} +1 -1
  30. package/dist/{chunk-V7JOEXUC-DG6RRlOY.js → chunk-V7JOEXUC-BM-hXi97.js} +5 -5
  31. package/dist/{chunk-V7JOEXUC-BPE4_Rfd.cjs → chunk-V7JOEXUC-GAaV0B4H.cjs} +1 -1
  32. package/dist/{chunk-VR4S4FIN-CLtgFgby.js → chunk-VR4S4FIN-BC678u_2.js} +1 -1
  33. package/dist/{chunk-VR4S4FIN-C-Pbv_Mm.cjs → chunk-VR4S4FIN-BXcUlQwZ.cjs} +1 -1
  34. package/dist/{chunk-XXDRQBXY-DEXdwwNg.js → chunk-XXDRQBXY-CQpPgj7q.js} +1 -1
  35. package/dist/{chunk-XXDRQBXY-B0bOz96Q.cjs → chunk-XXDRQBXY-DUBr_c4F.cjs} +1 -1
  36. package/dist/{classDiagram-OUVF2IWQ-DMqQXVMf.cjs → classDiagram-OUVF2IWQ-COvGPN2S.cjs} +1 -1
  37. package/dist/{classDiagram-v2-EOCWNBFH-B9uAd2dg.js → classDiagram-OUVF2IWQ-yWKe5-Fq.js} +2 -2
  38. package/dist/{classDiagram-v2-EOCWNBFH-DMqQXVMf.cjs → classDiagram-v2-EOCWNBFH-COvGPN2S.cjs} +1 -1
  39. package/dist/{classDiagram-OUVF2IWQ-B9uAd2dg.js → classDiagram-v2-EOCWNBFH-yWKe5-Fq.js} +2 -2
  40. package/dist/components/mathRendering.d.ts +1 -0
  41. package/dist/conversion.d.ts +26 -0
  42. package/dist/converter/NOTICES.md +178 -0
  43. package/dist/converter/createMarkdownConverter.d.ts +12 -0
  44. package/dist/converter/protocol.d.ts +58 -0
  45. package/dist/converter/serve.d.ts +12 -0
  46. package/dist/converter/worker.d.ts +1 -0
  47. package/dist/converter/worker.js +76 -0
  48. package/dist/converter.cjs +1 -0
  49. package/dist/converter.d.ts +4 -0
  50. package/dist/converter.js +109 -0
  51. package/dist/converter.wasm +0 -0
  52. package/dist/{cose-bilkent-JH36ORCC-DVB8IdFe.js → cose-bilkent-JH36ORCC-BZn7k9jD.js} +1 -1
  53. package/dist/{cose-bilkent-JH36ORCC-DxpO_Qhk.cjs → cose-bilkent-JH36ORCC-CcFTw3np.cjs} +1 -1
  54. package/dist/{cynefinDiagram-TSTJHNR4-Dvc8nHOe.cjs → cynefinDiagram-TSTJHNR4-XM1i8MSX.cjs} +1 -1
  55. package/dist/{cynefinDiagram-TSTJHNR4-C-iEKX8r.js → cynefinDiagram-TSTJHNR4-hurHHCIy.js} +2 -2
  56. package/dist/{dagre-VKFMJZFB-DqU8jG6A.cjs → dagre-VKFMJZFB-3LTByKBx.cjs} +1 -1
  57. package/dist/{dagre-VKFMJZFB-CI1hyGqk.js → dagre-VKFMJZFB-CAdYW8rl.js} +2 -2
  58. package/dist/{diagram-FQU43EPY-DQHw46B-.cjs → diagram-FQU43EPY-Cbzx46mZ.cjs} +1 -1
  59. package/dist/{diagram-FQU43EPY-iMIQEr1Q.js → diagram-FQU43EPY-CksXO5SO.js} +2 -2
  60. package/dist/{diagram-G47NLZAW-Dxkn-83c.cjs → diagram-G47NLZAW-C86xos3U.cjs} +1 -1
  61. package/dist/{diagram-G47NLZAW-L7A0K5es.js → diagram-G47NLZAW-CyQT8r6l.js} +3 -3
  62. package/dist/{diagram-NH7WQ7WH-8BnG6h8J.js → diagram-NH7WQ7WH-ClLVgFsl.js} +2 -2
  63. package/dist/{diagram-NH7WQ7WH-CBMFD5SB.cjs → diagram-NH7WQ7WH-DqE3-hMS.cjs} +1 -1
  64. package/dist/{diagram-OA4YK3LP-C24uGaef.js → diagram-OA4YK3LP-CkDm25Bj.js} +3 -3
  65. package/dist/{diagram-OA4YK3LP-DrD1SsZM.cjs → diagram-OA4YK3LP-TeFqqPyo.cjs} +1 -1
  66. package/dist/{diagram-WEI45ONY-kBWsy9sQ.js → diagram-WEI45ONY-DCJ7RPdW.js} +2 -2
  67. package/dist/{diagram-WEI45ONY-BYN2qTiw.cjs → diagram-WEI45ONY-sNQ6RgM4.cjs} +1 -1
  68. package/dist/{ebnfDiagram-CCIWWBDH-C7whdHrV.cjs → ebnfDiagram-CCIWWBDH-CwojFWHZ.cjs} +1 -1
  69. package/dist/{ebnfDiagram-CCIWWBDH-DRfaz75o.js → ebnfDiagram-CCIWWBDH-ORZrs8P1.js} +3 -3
  70. package/dist/embeds/testing.cjs +1 -1
  71. package/dist/embeds/testing.js +1 -1
  72. package/dist/embeds.cjs +1 -1
  73. package/dist/embeds.js +1 -1
  74. package/dist/{erDiagram-Q63AITRT-Cbh7ns6U.cjs → erDiagram-Q63AITRT-B5r4qjGb.cjs} +1 -1
  75. package/dist/{erDiagram-Q63AITRT-CvcOag5w.js → erDiagram-Q63AITRT-DLihpfSY.js} +4 -4
  76. package/dist/errors-BW5JXRoX.cjs +1 -0
  77. package/dist/errors-Blk_XJ9C.js +55 -0
  78. package/dist/errors.d.ts +12 -0
  79. package/dist/{extractHeadings-By3kC3b_.cjs → extractHeadings-AC80DPCv.cjs} +58 -58
  80. package/dist/{extractHeadings-Dz8gnhsx.js → extractHeadings-jpTidOYO.js} +3766 -3732
  81. package/dist/flowDiagram-23GEKE2U-gaIzKUxz.js +7 -0
  82. package/dist/flowDiagram-23GEKE2U-pAPxQFWB.cjs +1 -0
  83. package/dist/{ganttDiagram-NO4QXBWP-Ccrw6Vga.js → ganttDiagram-NO4QXBWP-Cc8dpB_u.js} +2 -2
  84. package/dist/{ganttDiagram-NO4QXBWP-YWoWQpTa.cjs → ganttDiagram-NO4QXBWP-qrmnl_LY.cjs} +1 -1
  85. package/dist/{gitGraphDiagram-IHSO6WYX-nKm0aLrL.cjs → gitGraphDiagram-IHSO6WYX-Bi0LKdq4.cjs} +1 -1
  86. package/dist/{gitGraphDiagram-IHSO6WYX-C-mHT-ew.js → gitGraphDiagram-IHSO6WYX-DEf3gB0s.js} +3 -3
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.client.cjs +1 -1
  89. package/dist/index.client.js +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/index.server.cjs +1 -1
  92. package/dist/index.server.d.ts +3 -1
  93. package/dist/index.server.js +159 -173
  94. package/dist/{infoDiagram-FWYZ7A6U-B6uUqDCC.cjs → infoDiagram-FWYZ7A6U-ByUzaoGp.cjs} +1 -1
  95. package/dist/{infoDiagram-FWYZ7A6U-HBcwdQ6Z.js → infoDiagram-FWYZ7A6U-CC1jQUez.js} +1 -1
  96. package/dist/{ishikawaDiagram-FXEZZL3T-CcSYEsTJ.js → ishikawaDiagram-FXEZZL3T-BD2ZWvM9.js} +1 -1
  97. package/dist/{ishikawaDiagram-FXEZZL3T-D9WZm1OZ.cjs → ishikawaDiagram-FXEZZL3T-q0Tua53X.cjs} +1 -1
  98. package/dist/{journeyDiagram-5HDEW3XC-PJm-8Gz8.js → journeyDiagram-5HDEW3XC-B2d4YZ1X.js} +4 -4
  99. package/dist/{journeyDiagram-5HDEW3XC-BC3ajweK.cjs → journeyDiagram-5HDEW3XC-Cc_OHYxa.cjs} +1 -1
  100. package/dist/{kanban-definition-HUTT4EX6-BR-C1joQ.cjs → kanban-definition-HUTT4EX6-CGhp8hq-.cjs} +1 -1
  101. package/dist/{kanban-definition-HUTT4EX6-42_dEzBV.js → kanban-definition-HUTT4EX6-CVTjOFjf.js} +2 -2
  102. package/dist/{linear-B7J7VKh9.js → linear-Gki9XU32.js} +1 -1
  103. package/dist/{linear-CoCezkp4.cjs → linear-NPD77kko.cjs} +1 -1
  104. package/dist/{mindmap-definition-LN4V7U3C-BO555Yeu.cjs → mindmap-definition-LN4V7U3C-BVMzWil4.cjs} +1 -1
  105. package/dist/{mindmap-definition-LN4V7U3C-e4fXdr28.js → mindmap-definition-LN4V7U3C-CcFlbH0m.js} +3 -3
  106. package/dist/{pegDiagram-2B236MQR-nN-jUv5o.js → pegDiagram-2B236MQR-BIEbmEyL.js} +3 -3
  107. package/dist/{pegDiagram-2B236MQR-CqN17IwE.cjs → pegDiagram-2B236MQR-BjkrlFo4.cjs} +1 -1
  108. package/dist/{pieDiagram-ENE6RG2P-EvhF_8o2.js → pieDiagram-ENE6RG2P-B8b2HOMr.js} +3 -3
  109. package/dist/{pieDiagram-ENE6RG2P-D_EIGKcE.cjs → pieDiagram-ENE6RG2P-C_zKMY-f.cjs} +1 -1
  110. package/dist/{providers-L5RM3KgR.js → providers-BwQK7hZa.js} +4 -4
  111. package/dist/{providers-BO7J62-7.cjs → providers-DO2t7ks4.cjs} +1 -1
  112. package/dist/{quadrantDiagram-ABIIQ3AL-2gTiccyy.js → quadrantDiagram-ABIIQ3AL-CAzEuvrn.js} +2 -2
  113. package/dist/{quadrantDiagram-ABIIQ3AL-HNTFSQzi.cjs → quadrantDiagram-ABIIQ3AL-DM2brpjs.cjs} +1 -1
  114. package/dist/{railroadDiagram-RFXS5EU6-CRuA7qqW.cjs → railroadDiagram-RFXS5EU6-D4qyeIm0.cjs} +1 -1
  115. package/dist/{railroadDiagram-RFXS5EU6-CYAI9-bK.js → railroadDiagram-RFXS5EU6-Dj5Hhb2C.js} +3 -3
  116. package/dist/remarkProcessor.server.d.ts +1 -28
  117. package/dist/{requirementDiagram-TGXJPOKE-BZc_cLKC.js → requirementDiagram-TGXJPOKE-DCsyd9cl.js} +3 -3
  118. package/dist/{requirementDiagram-TGXJPOKE-DesNyieJ.cjs → requirementDiagram-TGXJPOKE-DxMueY11.cjs} +1 -1
  119. package/dist/{sankeyDiagram-HTMAVEWB-B1QsmzsN.js → sankeyDiagram-HTMAVEWB-Djmdo0Ih.js} +1 -1
  120. package/dist/{sankeyDiagram-HTMAVEWB-wLwqusl2.cjs → sankeyDiagram-HTMAVEWB-HPKhkyBx.cjs} +1 -1
  121. package/dist/{sequenceDiagram-DBY2YBRQ-D3ciEWOE.cjs → sequenceDiagram-DBY2YBRQ-3XPFEpyb.cjs} +1 -1
  122. package/dist/{sequenceDiagram-DBY2YBRQ-OTeHr40Q.js → sequenceDiagram-DBY2YBRQ-BsELINW9.js} +3 -3
  123. package/dist/{sizeCapture-X5ZJPWSS-LlzRMz8i.cjs → sizeCapture-X5ZJPWSS-31abQGwa.cjs} +1 -1
  124. package/dist/{sizeCapture-X5ZJPWSS-BhcQlLlw.js → sizeCapture-X5ZJPWSS-CYMPBUJR.js} +1 -1
  125. package/dist/{stateDiagram-2N3HPSRC-D0q856z6.cjs → stateDiagram-2N3HPSRC-B0XEIOiL.cjs} +1 -1
  126. package/dist/{stateDiagram-2N3HPSRC-DjLE1--n.js → stateDiagram-2N3HPSRC-a3NuIfYf.js} +2 -2
  127. package/dist/{stateDiagram-v2-6OUMAXLB-DJHUGWBX.cjs → stateDiagram-v2-6OUMAXLB-BwCXOhvG.cjs} +1 -1
  128. package/dist/{stateDiagram-v2-6OUMAXLB-DKU0HsD1.js → stateDiagram-v2-6OUMAXLB-DGoXPnAk.js} +2 -2
  129. package/dist/{swimlanes-5IMT3BWC-cxcj_GGS.js → swimlanes-5IMT3BWC-261b0Snh.js} +3 -3
  130. package/dist/{swimlanes-5IMT3BWC-DC6qS8iI.cjs → swimlanes-5IMT3BWC-BogVCjJZ.cjs} +1 -1
  131. package/dist/{swimlanesDiagram-G3AALYLV-B95OToWo.js → swimlanesDiagram-G3AALYLV-0hHND0xf.js} +2 -2
  132. package/dist/{swimlanesDiagram-G3AALYLV-Dv76fKaH.cjs → swimlanesDiagram-G3AALYLV-B-HBl7xR.cjs} +1 -1
  133. package/dist/{timeline-definition-FHXFAJF6-P-5kO0xQ.js → timeline-definition-FHXFAJF6-B_euDX4t.js} +2 -2
  134. package/dist/{timeline-definition-FHXFAJF6-wD6O9DDR.cjs → timeline-definition-FHXFAJF6-Cm4g61OO.cjs} +1 -1
  135. package/dist/{vennDiagram-L72KCM5P-BwinGtNb.js → vennDiagram-L72KCM5P-BL65fZ2Z.js} +1 -1
  136. package/dist/{vennDiagram-L72KCM5P-BXHvaRtm.cjs → vennDiagram-L72KCM5P-DCLNzpM1.cjs} +1 -1
  137. package/dist/{wardleyDiagram-EHGQE667-BeYbREE2.js → wardleyDiagram-EHGQE667-BbdgmKNq.js} +2 -2
  138. package/dist/{wardleyDiagram-EHGQE667-BDgwIQTf.cjs → wardleyDiagram-EHGQE667-yrrICYTB.cjs} +1 -1
  139. package/dist/{xychartDiagram-FW5EYKEG-DLCCDPGO.cjs → xychartDiagram-FW5EYKEG-1YlGN0q3.cjs} +1 -1
  140. package/dist/{xychartDiagram-FW5EYKEG-BXjx9Zgc.js → xychartDiagram-FW5EYKEG-D0ITIjet.js} +2 -2
  141. package/package.json +17 -8
  142. package/dist/flowDiagram-23GEKE2U-C5ygxVuP.js +0 -7
  143. package/dist/flowDiagram-23GEKE2U-DSpM0zzA.cjs +0 -1
@@ -1,19 +1,21 @@
1
- import { l as L, L as O, a as se, b as Ee } from "./linkCards-1JxY8wdm.js";
1
+ import { R as ge, c as ke, a as be } from "./errors-Blk_XJ9C.js";
2
+ import { d as er } from "./errors-Blk_XJ9C.js";
3
+ import { l as L, L as O, a as ae, b as Ee } from "./linkCards-1JxY8wdm.js";
2
4
  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 Se } from "node:net";
6
- import { Agent as Te, 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 = [
5
+ import { Resolver as Te } from "node:dns/promises";
6
+ import * as se from "node:net";
7
+ import { BlockList as ve, isIP as ie, connect as Se } from "node:net";
8
+ import { Agent as ye, buildConnector as Y, fetch as Ae } from "undici";
9
+ import { Parser as _e } from "htmlparser2";
10
+ import { spawn as Re } from "node:child_process";
11
+ import { existsSync as C, unlinkSync as Le } from "node:fs";
12
+ import { createRequire as Oe } from "node:module";
13
+ import * as M from "node:path";
14
+ import { fileURLToPath as Pe } from "node:url";
15
+ import { createClient as Ce, ConnectError as Me, Code as Ie } from "@connectrpc/connect";
16
+ import { Http2SessionManager as xe, createConnectTransport as Ne } from "@connectrpc/connect-node";
17
+ import { Message as x, proto3 as d, MethodKind as De } from "@bufbuild/protobuf";
18
+ const Be = [
17
19
  [[0], 8],
18
20
  [[10], 8],
19
21
  [[100, 64], 10],
@@ -28,7 +30,7 @@ const De = [
28
30
  [[203, 0, 113], 24],
29
31
  [[224], 4],
30
32
  [[240], 4]
31
- ], Be = [
33
+ ], Ue = [
32
34
  [[100, 65435], 32],
33
35
  [[0, 0, 0, 0, 65535, 0], 96],
34
36
  [[256, 0, 0, 0], 64],
@@ -43,31 +45,31 @@ const De = [
43
45
  [[65152], 10],
44
46
  [[65216], 10],
45
47
  [[65280], 8]
46
- ], y = new ye();
47
- for (const [r, t] of De) {
48
+ ], T = new ve();
49
+ for (const [r, t] of Be) {
48
50
  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");
51
+ T.addSubnet(e, t, "ipv4"), T.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), T.addSubnet(`::${e}`, 96 + t, "ipv6");
50
52
  }
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);
53
+ for (const [r, t] of Ue)
54
+ T.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
55
+ const $ = (r) => {
56
+ const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = ie(t);
57
+ return e !== 0 && T.check(t, e === 4 ? "ipv4" : "ipv6");
58
+ }, le = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new Te({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
59
+ error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: le })
60
+ }), $e = async (r, t) => {
61
+ const e = ie(r);
60
62
  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
+ return $(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
64
+ 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) => $(R));
63
65
  if (i !== void 0) return Q(r, i);
64
66
  const [l, ...c] = s;
65
67
  if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
66
- const [f, ...T] = a;
67
- return f !== void 0 ? { error: null, family: 6, addresses: [f, ...T] } : 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) => {
68
+ const [f, ...S] = a;
69
+ 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" }) };
70
+ }, He = (r, t, e) => {
69
71
  const n = t.family === 4 || t.family === "IPv4" ? 4 : t.family === 6 || t.family === "IPv6" ? 6 : 0;
70
- He(r, n).then((o) => {
72
+ $e(r, n).then((o) => {
71
73
  if (o.error !== null) {
72
74
  e(o.error, "");
73
75
  return;
@@ -78,7 +80,7 @@ const U = (r) => {
78
80
  a.map((i) => ({ address: i, family: s }))
79
81
  ) : e(null, a[0], s);
80
82
  });
81
- }, $e = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), je = [".local", ".internal", ".home.arpa"], j = (r, t) => {
83
+ }, je = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), ze = [".local", ".internal", ".home.arpa"], j = (r, t) => {
82
84
  let e;
83
85
  try {
84
86
  e = new URL(r);
@@ -91,8 +93,8 @@ const U = (r) => {
91
93
  return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
92
94
  e.hash = "";
93
95
  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
+ return n === "localhost" || n.endsWith(".localhost") || je.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : $(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || ze.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
97
+ }, ce = (r) => {
96
98
  let t;
97
99
  try {
98
100
  t = new URL(r);
@@ -100,20 +102,20 @@ const U = (r) => {
100
102
  return "(unparsable URL)";
101
103
  }
102
104
  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) => {
105
+ }, ue = 1024, Je = /^[\t\n\f\r ]$/u, w = (r) => Je.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), H = (r) => {
104
106
  try {
105
107
  return new TextDecoder(r).encoding;
106
108
  } catch {
107
109
  return null;
108
110
  }
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) => {
111
+ }, Ke = (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, Fe = (r) => {
110
112
  for (const t of r.split(";").slice(1)) {
111
113
  const e = t.indexOf("=");
112
114
  if (e !== -1 && t.slice(0, e).trim().toLowerCase() === "charset")
113
115
  return t.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
114
116
  }
115
117
  return null;
116
- }, Fe = (r) => {
118
+ }, Ge = (r) => {
117
119
  let t = 0;
118
120
  for (; ; ) {
119
121
  const e = r.indexOf("charset", t);
@@ -133,7 +135,7 @@ const U = (r) => {
133
135
  const s = r.slice(n).search(/[\t\n\f\r ;]/u);
134
136
  return s === -1 ? r.slice(n) : r.slice(n, n + s);
135
137
  }
136
- }, fe = (r, t) => {
138
+ }, de = (r, t) => {
137
139
  let e = t;
138
140
  for (; w(r.charAt(e)) || r.charAt(e) === "/"; ) e += 1;
139
141
  if (r.charAt(e) === ">" || e >= r.length) return { attribute: null, end: e };
@@ -159,23 +161,23 @@ const U = (r) => {
159
161
  if (o === ">") return { attribute: { name: n, value: "" }, end: e };
160
162
  const s = r.slice(e).search(/[\t\n\f\r >]/u);
161
163
  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) => {
164
+ }, Xe = (r, t) => {
163
165
  const e = /* @__PURE__ */ new Set();
164
166
  let n = !1, o = null, s = null, a = t;
165
167
  for (; ; ) {
166
- const { attribute: i, end: l } = fe(r, a);
168
+ const { attribute: i, end: l } = de(r, a);
167
169
  if (a = l, i === null) break;
168
170
  if (!e.has(i.name))
169
171
  if (e.add(i.name), i.name === "http-equiv")
170
172
  n = i.value === "content-type";
171
173
  else if (i.name === "content") {
172
- const c = Fe(i.value), f = c === null ? null : $(c);
174
+ const c = Ge(i.value), f = c === null ? null : H(c);
173
175
  f !== null && s === null && (s = f, o = !0);
174
- } else i.name === "charset" && (s = $(i.value) ?? !1, o = !1);
176
+ } else i.name === "charset" && (s = H(i.value) ?? !1, o = !1);
175
177
  }
176
178
  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
+ }, Ve = (r) => {
180
+ const t = Array.from(r.subarray(0, ue), (n) => String.fromCharCode(n)).join("");
179
181
  let e = 0;
180
182
  for (; e < t.length; )
181
183
  if (t.startsWith("<!--", e)) {
@@ -183,14 +185,14 @@ const U = (r) => {
183
185
  if (n === -1) return null;
184
186
  e = n + 3;
185
187
  } else if (/^<meta[\t\n\f\r /]$/iu.test(t.slice(e, e + 6))) {
186
- const { encoding: n, end: o } = Ge(t, e + 5);
188
+ const { encoding: n, end: o } = Xe(t, e + 5);
187
189
  if (n !== null) return n;
188
190
  e = o + 1;
189
191
  } else if (/^<\/?[A-Za-z]/u.test(t.slice(e, e + 3))) {
190
192
  let n = e + 1;
191
193
  for (; n < t.length && !w(t.charAt(n)) && t.charAt(n) !== ">"; ) n += 1;
192
194
  for (; ; ) {
193
- const o = fe(t, n);
195
+ const o = de(t, n);
194
196
  if (n = o.end, o.attribute === null) break;
195
197
  }
196
198
  e = n + 1;
@@ -201,35 +203,35 @@ const U = (r) => {
201
203
  } else
202
204
  e += 1;
203
205
  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
206
  }, We = (r, t) => {
207
+ const e = Ke(r);
208
+ if (e !== null) return e;
209
+ const n = Fe(t), o = n === null ? null : H(n);
210
+ return o !== null ? o : Ve(r) ?? "utf-8";
211
+ }, Ye = (r, t) => {
210
212
  const e = new Uint8Array(t);
211
213
  let n = 0;
212
214
  for (const o of r)
213
215
  e.set(o, n), n += o.byteLength;
214
216
  return e;
215
- }, Ye = (r) => {
217
+ }, Ze = (r) => {
216
218
  const t = [];
217
219
  let e = 0, n = null;
218
220
  const o = () => {
219
- const s = We(t, e);
221
+ const s = Ye(t, e);
220
222
  t.length = 0;
221
- const a = new TextDecoder(Ve(s, r));
223
+ const a = new TextDecoder(We(s, r));
222
224
  return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
223
225
  };
224
226
  return {
225
- write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < de ? "" : o().text),
227
+ write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < ue ? "" : o().text),
226
228
  end: () => {
227
229
  if (n !== null) return n.decode();
228
230
  const { started: s, text: a } = o();
229
231
  return a + s.decode();
230
232
  }
231
233
  };
232
- }, Ze = (r, t, e) => {
234
+ }, qe = (r, t, e) => {
233
235
  const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
234
236
  return (s) => {
235
237
  const a = n.get(s);
@@ -241,7 +243,7 @@ const U = (r) => {
241
243
  });
242
244
  return o.set(s, l), l;
243
245
  };
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) => {
246
+ }, Qe = 65536, et = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), tt = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), rt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", le]), fe = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), nt = Object.freeze({ lookup: He, blockList: T }), ot = (r, t) => {
245
247
  const e = Y({ lookup: r.lookup, blockList: r.blockList, timeout: t }), n = Y({ timeout: t });
246
248
  return (o, s) => {
247
249
  if (o.protocol !== "https:") {
@@ -255,27 +257,27 @@ const U = (r) => {
255
257
  a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
256
258
  });
257
259
  };
258
- }, ot = (r) => new Te({
259
- maxHeaderSize: qe,
260
- connect: nt(rt, me.timeoutMs)
261
- }), H = async (r) => {
260
+ }, at = (r) => new ye({
261
+ maxHeaderSize: Qe,
262
+ connect: ot(nt, fe.timeoutMs)
263
+ }), U = async (r) => {
262
264
  r.body !== null && await Promise.allSettled([r.body.cancel()]);
263
- }, at = (r) => r !== null && et.has(r.split(";", 1)[0].trim().toLowerCase()), st = (r) => {
265
+ }, st = (r) => r !== null && tt.has(r.split(";", 1)[0].trim().toLowerCase()), it = (r) => {
264
266
  const t = [r];
265
267
  for (let e = 0; e < 16 && t.length > 0; e += 1) {
266
268
  const n = t.shift();
267
269
  if (!(n instanceof Error)) continue;
268
270
  const o = n.code;
269
- if (typeof o == "string" && tt.has(o)) return n.message;
271
+ if (typeof o == "string" && rt.has(o)) return n.message;
270
272
  t.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
271
273
  }
272
274
  return null;
273
- }, pe = (r, t) => {
274
- const e = st(r);
275
+ }, me = (r, t) => {
276
+ const e = it(r);
275
277
  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) => {
278
+ }, lt = () => new Promise((r) => {
277
279
  setImmediate(r);
278
- }), lt = async (r, t, e, n) => {
280
+ }), ct = async (r, t, e, n) => {
279
281
  if (r.body === null) return { ok: !0, value: t.end() };
280
282
  const o = r.body.getReader();
281
283
  let s = 0;
@@ -284,7 +286,7 @@ const U = (r) => {
284
286
  try {
285
287
  a = await o.read();
286
288
  } catch (f) {
287
- return pe(f, n);
289
+ return me(f, n);
288
290
  }
289
291
  if (a.done) break;
290
292
  const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
@@ -296,26 +298,26 @@ const U = (r) => {
296
298
  await Promise.allSettled([o.cancel()]), h.warn("Link-card page body exceeds the size limit; parsing only its first bytes:", n, e);
297
299
  break;
298
300
  }
299
- await it();
301
+ await lt();
300
302
  }
301
303
  return { ok: !0, value: t.end() };
302
- }, ct = async (r, t, e, n) => {
304
+ }, ut = async (r, t, e, n) => {
303
305
  let o = r;
304
306
  for (let s = 0; s <= t.limits.maxRedirects; s += 1) {
305
307
  let a;
306
308
  try {
307
- a = await ve(o, { signal: n, redirect: "manual", dispatcher: t.agent });
309
+ a = await Ae(o, { signal: n, redirect: "manual", dispatcher: t.agent });
308
310
  } catch (f) {
309
- return pe(f, o);
311
+ return me(f, o);
310
312
  }
311
- const i = Qe.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
313
+ const i = et.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
312
314
  if (i === "") {
313
315
  if (!a.ok)
314
- return await H(a), { ok: !1, reason: "unreachable" };
316
+ return await U(a), { ok: !1, reason: "unreachable" };
315
317
  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" });
318
+ return st(f) ? ct(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await U(a), { ok: !1, reason: "not-html" });
317
319
  }
318
- await H(a);
320
+ await U(a);
319
321
  let l;
320
322
  try {
321
323
  l = new URL(i, o);
@@ -324,16 +326,16 @@ const U = (r) => {
324
326
  }
325
327
  const c = j(l.href);
326
328
  if (!c.ok)
327
- return h.info("Refused link-card redirect:", ue(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
329
+ return h.info("Refused link-card redirect:", ce(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
328
330
  o = c.href;
329
331
  }
330
332
  return h.error("Too many redirects while fetching link-card metadata:", r), { ok: !1, reason: "unreachable" };
331
- }, ut = (r, t, e) => {
333
+ }, dt = (r, t, e) => {
332
334
  const n = new AbortController(), o = setTimeout(() => n.abort(), t.limits.timeoutMs);
333
- return ct(r, t, e, n.signal).finally(() => {
335
+ return ut(r, t, e, n.signal).finally(() => {
334
336
  clearTimeout(o);
335
337
  });
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, kt = (r, t) => {
338
+ }, ft = 256, mt = 4096, pt = 64, ht = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), wt = /* @__PURE__ */ new Set(["title", "script", "style"]), gt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), kt = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, bt = (r, t) => {
337
339
  if (r === void 0) return t;
338
340
  let e;
339
341
  try {
@@ -341,7 +343,7 @@ const U = (r) => {
341
343
  } catch {
342
344
  return t;
343
345
  }
344
- return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= se ? e.href : t;
346
+ return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= ae ? e.href : t;
345
347
  }, ee = (r, t, e) => {
346
348
  const n = r?.trim();
347
349
  if (n === void 0 || n === "") return;
@@ -351,30 +353,30 @@ const U = (r) => {
351
353
  } catch {
352
354
  return;
353
355
  }
354
- return o.href.length <= se && j(o.href).ok ? o.href : void 0;
356
+ return o.href.length <= ae && j(o.href).ok ? o.href : void 0;
355
357
  }, Et = (r, t) => {
356
- let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, T, R, z, J, K = !1, F, G = !1;
358
+ 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
359
  const N = () => {
358
360
  e = !0, D.pause();
359
- }, D = new Ae(
361
+ }, D = new _e(
360
362
  {
361
363
  onopentagname(u) {
362
- n += 1, o += 1, s = 0, (n > dt || o > ft || a === null && !pt.has(u)) && N();
364
+ n += 1, o += 1, s = 0, (n > ft || o > mt || a === null && !ht.has(u)) && N();
363
365
  },
364
366
  onattribute() {
365
- s += 1, s > mt && N();
367
+ s += 1, s > pt && N();
366
368
  },
367
369
  onopentag(u, m) {
368
370
  if (!(e || a !== null)) {
369
- if (wt.has(u)) {
371
+ if (gt.has(u)) {
370
372
  a = n;
371
373
  return;
372
374
  }
373
375
  if (u === "meta") {
374
376
  const p = m.content;
375
- m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (T = p), m.property === "og:image" && (z = p), m.name === "description" && (T = 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 = ""));
377
+ 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);
378
+ } else u === "link" && !K && kt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
379
+ wt.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
378
380
  }
379
381
  },
380
382
  ontext(u) {
@@ -396,7 +398,7 @@ const U = (r) => {
396
398
  write: (u) => (e || D.write(u), !e),
397
399
  end: () => {
398
400
  e || D.end();
399
- const u = L(f, O.title) ?? L(c, O.title), m = L(T, O.description), p = L(R, O.siteName), X = kt(F, r), V = ee(z, X), W = ee(J, X);
401
+ const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = bt(F, r), V = ee(z, X), W = ee(J, X);
400
402
  return {
401
403
  ...u === null ? {} : { title: u },
402
404
  ...m === null ? {} : { description: m },
@@ -406,53 +408,53 @@ const U = (r) => {
406
408
  };
407
409
  }
408
410
  };
409
- }, bt = /* @__PURE__ */ new Set(["authorize"]), yt = "private, max-age=1800", St = 3600 * 1e3, he = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), Tt = 1e3, P = "no-store", v = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
411
+ }, Tt = /* @__PURE__ */ new Set(["authorize"]), vt = "private, max-age=1800", St = 3600 * 1e3, pe = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), yt = 1e3, P = "no-store", y = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
410
412
  status: t,
411
413
  headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
412
414
  }), te = (r) => new Response(null, {
413
415
  status: 204,
414
- headers: { "Cache-Control": `private, max-age=${he[r]}`, "X-Content-Type-Options": "nosniff", [Ee]: r }
415
- }), vt = (r) => {
416
+ headers: { "Cache-Control": `private, max-age=${pe[r]}`, "X-Content-Type-Options": "nosniff", [Ee]: r }
417
+ }), At = (r) => {
416
418
  if (typeof r != "object" || r === null)
417
419
  throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
418
420
  if (typeof r.authorize != "function")
419
421
  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));
422
+ const t = Object.keys(r).filter((e) => !Tt.has(e));
421
423
  if (t.length > 0)
422
424
  throw new TypeError(`createLinkCardHandler: unknown option(s): ${t.join(", ")}`);
423
- }, At = (r) => (t) => {
424
- const e = Ye(t.contentType), n = Et(t.url);
425
+ }, _t = (r) => (t) => {
426
+ const e = Ze(t.contentType), n = Et(t.url);
425
427
  return {
426
428
  write: (o) => n.write(e.write(o)),
427
429
  end: () => (n.write(e.end()), n.end())
428
430
  };
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: Tt, ttlMsOf: (s) => s.ok ? St : he[s.reason] * 1e3 },
431
+ }, Rt = (r, t) => {
432
+ At(r);
433
+ const { authorize: e } = r, n = at(), o = qe(
434
+ (s) => dt(s, { agent: n, scope: t, limits: fe }, _t()),
435
+ { maxEntries: yt, ttlMsOf: (s) => s.ok ? St : pe[s.reason] * 1e3 },
434
436
  Date.now
435
437
  );
436
438
  return async (s) => {
437
439
  if (s.method !== "GET" && s.method !== "HEAD")
438
- return v(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
440
+ return y(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
439
441
  if (await e(s) !== !0)
440
- return v(s, 401, { error: "Unauthorized" }, P);
442
+ return y(s, 401, { error: "Unauthorized" }, P);
441
443
  const a = new URL(s.url).searchParams.get("url");
442
444
  if (a === null || a === "")
443
- return v(s, 400, { error: "Missing 'url' parameter" }, P);
445
+ return y(s, 400, { error: "Missing 'url' parameter" }, P);
444
446
  const i = j(a);
445
447
  if (!i.ok)
446
- return h.info("Refused link-card URL:", ue(a), `(${i.reason}: ${i.detail})`), te(i.reason);
448
+ return h.info("Refused link-card URL:", ce(a), `(${i.reason}: ${i.detail})`), te(i.reason);
447
449
  let l;
448
450
  try {
449
451
  l = await o(i.href);
450
452
  } catch (c) {
451
- return h.error("Unexpected error while reading link-card metadata:", i.href, c), v(s, 500, { error: "Internal Server Error" }, P);
453
+ return h.error("Unexpected error while reading link-card metadata:", i.href, c), y(s, 500, { error: "Internal Server Error" }, P);
452
454
  }
453
- return l.ok ? v(s, 200, l.value, yt) : te(l.reason);
455
+ return l.ok ? y(s, 200, l.value, vt) : te(l.reason);
454
456
  };
455
- }, Yt = (r) => _t(r, "public");
457
+ }, Yt = (r) => Rt(r, "public");
456
458
  class k extends x {
457
459
  /**
458
460
  * @generated from field: string markdown_text = 1;
@@ -656,7 +658,7 @@ class g extends x {
656
658
  return d.util.equals(g, t, e);
657
659
  }
658
660
  }
659
- class E extends x {
661
+ class b extends x {
660
662
  /**
661
663
  * @generated from field: string html_content = 1;
662
664
  */
@@ -678,22 +680,22 @@ class E extends x {
678
680
  T: 9
679
681
  /* ScalarType.STRING */
680
682
  },
681
- { no: 2, name: "headings", kind: "message", T: b, repeated: !0 }
683
+ { no: 2, name: "headings", kind: "message", T: E, repeated: !0 }
682
684
  ]);
683
685
  static fromBinary(t, e) {
684
- return new E().fromBinary(t, e);
686
+ return new b().fromBinary(t, e);
685
687
  }
686
688
  static fromJson(t, e) {
687
- return new E().fromJson(t, e);
689
+ return new b().fromJson(t, e);
688
690
  }
689
691
  static fromJsonString(t, e) {
690
- return new E().fromJsonString(t, e);
692
+ return new b().fromJsonString(t, e);
691
693
  }
692
694
  static equals(t, e) {
693
- return d.util.equals(E, t, e);
695
+ return d.util.equals(b, t, e);
694
696
  }
695
697
  }
696
- class b extends x {
698
+ class E extends x {
697
699
  /**
698
700
  * @generated from field: string text = 1;
699
701
  */
@@ -735,19 +737,19 @@ class b extends x {
735
737
  }
736
738
  ]);
737
739
  static fromBinary(t, e) {
738
- return new b().fromBinary(t, e);
740
+ return new E().fromBinary(t, e);
739
741
  }
740
742
  static fromJson(t, e) {
741
- return new b().fromJson(t, e);
743
+ return new E().fromJson(t, e);
742
744
  }
743
745
  static fromJsonString(t, e) {
744
- return new b().fromJsonString(t, e);
746
+ return new E().fromJsonString(t, e);
745
747
  }
746
748
  static equals(t, e) {
747
- return d.util.equals(b, t, e);
749
+ return d.util.equals(E, t, e);
748
750
  }
749
751
  }
750
- const Rt = {
752
+ const Lt = {
751
753
  typeName: "markdown.v1.MarkdownService",
752
754
  methods: {
753
755
  /**
@@ -756,81 +758,69 @@ const Rt = {
756
758
  convert: {
757
759
  name: "Convert",
758
760
  I: k,
759
- O: E,
760
- kind: Ne.Unary
761
+ O: b,
762
+ kind: De.Unary
761
763
  }
762
764
  }
763
- }, S = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Lt = new Ie("http://localhost", void 0, {
764
- createConnection: () => ie.connect(S)
765
- }), we = 64 * 1024, Ot = 4294967295, re = Math.floor((Ot - we) / 2);
766
- class Pt extends Error {
767
- /**
768
- * Wraps the service's or the transport's resource-exhausted error.
769
- * サービスか転送の resource exhausted のエラーを包む処理。
770
- *
771
- * @param cause - The connect error. connect のエラー。
772
- */
773
- constructor(t) {
774
- super(t.rawMessage, { cause: t }), this.name = "MarkdownResourceExhaustedError";
775
- }
776
- }
777
- const ne = () => {
765
+ }, v = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Ot = new xe("http://localhost", void 0, {
766
+ createConnection: () => se.connect(v)
767
+ }), re = () => {
778
768
  try {
779
- return C.dirname(Oe(import.meta.url));
769
+ return M.dirname(Pe(import.meta.url));
780
770
  } catch {
781
771
  return __dirname;
782
772
  }
783
- }, ge = () => `@aiquants/markdown-${process.platform}-${process.arch}`, oe = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Mt = () => {
773
+ }, he = () => `@aiquants/markdown-${process.platform}-${process.arch}`, ne = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Pt = () => {
784
774
  const r = process.env.MARKDOWN_API_BINARY;
785
- if (r && M(r))
775
+ if (r && C(r))
786
776
  return r;
787
777
  try {
788
- const e = Le(C.join(ne(), "index.js")).resolve(`${ge()}/${oe()}`);
789
- if (M(e))
778
+ const e = Oe(M.join(re(), "index.js")).resolve(`${he()}/${ne()}`);
779
+ if (C(e))
790
780
  return e;
791
781
  } catch {
792
782
  }
793
- const t = C.join(ne(), "..", "..", "go", "markdown-api", "dist", C.basename(oe()));
794
- return M(t) ? t : void 0;
783
+ const t = M.join(re(), "..", "..", "go", "markdown-api", "dist", M.basename(ne()));
784
+ return C(t) ? t : void 0;
795
785
  }, Ct = () => [
796
786
  `markdown-api binary not found for ${process.platform}-${process.arch}.`,
797
- `Expected the optional dependency ${ge()} to be installed.`,
787
+ `Expected the optional dependency ${he()} to be installed.`,
798
788
  "If your platform is unsupported, build the service yourself",
799
789
  "(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
800
790
  "and point MARKDOWN_API_BINARY at it."
801
- ].join(" "), ke = () => new Promise((r) => {
802
- const t = ie.connect(S);
791
+ ].join(" "), we = () => new Promise((r) => {
792
+ const t = se.connect(v);
803
793
  t.on("connect", () => {
804
794
  t.destroy(), r(!0);
805
795
  }), t.on("error", () => r(!1));
806
- }), ae = async (r) => {
796
+ }), oe = async (r) => {
807
797
  const t = Date.now();
808
798
  for (; Date.now() - t < r; ) {
809
- if (await ke()) return !0;
799
+ if (await we()) return !0;
810
800
  await new Promise((e) => setTimeout(e, 100));
811
801
  }
812
802
  return !1;
813
803
  };
814
804
  let A = null, _ = null;
815
- const It = 2e3, xt = () => {
805
+ const Mt = 2e3, It = () => {
816
806
  const r = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
817
807
  return Number.isFinite(r) && r > 0 ? r : 1e4;
818
808
  };
819
809
  let I = null;
820
- const Nt = async () => {
821
- if (await ke()) return !0;
810
+ const xt = async () => {
811
+ if (await we()) return !0;
822
812
  if (_) return _;
823
813
  _ = (async () => {
824
- const t = Mt();
814
+ const t = Pt();
825
815
  if (!t)
826
- return await ae(It) ? !0 : (I = Ct(), !1);
816
+ return await oe(Mt) ? !0 : (I = Ct(), !1);
827
817
  I = null;
828
818
  try {
829
- M(S) && Re(S);
819
+ C(v) && Le(v);
830
820
  } catch {
831
821
  }
832
822
  try {
833
- A = _e(t, [], { stdio: "ignore" });
823
+ A = Re(t, [], { stdio: "ignore" });
834
824
  const e = () => {
835
825
  if (A) {
836
826
  try {
@@ -840,28 +830,24 @@ const Nt = async () => {
840
830
  A = null;
841
831
  }
842
832
  };
843
- return process.once("exit", e), await ae(xt()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", S), e(), process.removeListener("exit", e), !1);
833
+ return process.once("exit", e), await oe(It()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", v), e(), process.removeListener("exit", e), !1);
844
834
  } catch (e) {
845
835
  return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
846
836
  }
847
837
  })();
848
838
  const r = await _;
849
839
  return r || (_ = null), r;
850
- }, Dt = (r) => {
851
- if (!Array.isArray(r.deniedPathSegments))
852
- throw new TypeError("parseMarkdown: deniedPathSegments must be an array of path segment patterns (an empty array denies nothing)");
853
- if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > re)
854
- throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${re}, got ${r.maxHtmlBytes}`);
855
- if (r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
840
+ }, Nt = (r) => {
841
+ if (be(r, "parseMarkdown"), r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
856
842
  throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${r.timeoutMs}`);
857
843
  }, Zt = async (r, t, e, n, o) => {
858
- if (Dt(o), !await Nt()) {
844
+ if (Nt(o), !await xt()) {
859
845
  const i = I ? ` ${I}` : "";
860
- throw new Error(`markdown service is not reachable on ${S}.${i}`);
846
+ throw new Error(`markdown service is not reachable on ${v}.${i}`);
861
847
  }
862
848
  const s = {};
863
849
  n && (s.Authorization = `Bearer ${n}`);
864
- const a = Pe(Rt, xe({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Lt, readMaxBytes: 2 * o.maxHtmlBytes + we }));
850
+ const a = Ce(Lt, Ne({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Ot, readMaxBytes: 2 * o.maxHtmlBytes + ge }));
865
851
  try {
866
852
  const i = await a.convert(
867
853
  {
@@ -891,12 +877,12 @@ const Nt = async () => {
891
877
  }))
892
878
  };
893
879
  } catch (i) {
894
- throw i instanceof Me && i.code === Ce.ResourceExhausted ? new Pt(i) : i;
880
+ throw i instanceof Me && i.code === Ie.ResourceExhausted ? new ke(i.rawMessage, { cause: i }) : i;
895
881
  }
896
882
  };
897
883
  export {
898
- re as MAX_HTML_BYTES_LIMIT,
899
- Pt as MarkdownResourceExhaustedError,
884
+ er as MAX_HTML_BYTES_LIMIT,
885
+ ke as MarkdownResourceExhaustedError,
900
886
  Yt as createLinkCardHandler,
901
887
  Zt as parseMarkdown
902
888
  };