@heycys/gallery 0.2.1 → 0.2.3

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 (169) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/editor/page/annotate/index.mjs +3 -2
  3. package/browser/editor/page/board/index.mjs +2 -1
  4. package/browser/editor/page/board/settings.mjs +2 -1
  5. package/browser/editor/page/core.mjs +3 -2
  6. package/browser/editor/page/custom-page.mjs +4 -3
  7. package/browser/editor/page/editor.mjs +13 -7
  8. package/browser/editor/page/emoji-picker/support.mjs +3 -2
  9. package/browser/editor/page/links/index.mjs +1 -12
  10. package/browser/editor/page/links/pages.mjs +3 -2
  11. package/browser/editor/page/outline/folds.mjs +3 -0
  12. package/browser/editor/page/post.mjs +2 -1
  13. package/browser/editor/page/present-links.mjs +4 -3
  14. package/browser/editor/page/present-shell.mjs +3 -58
  15. package/browser/editor/page/session.mjs +3 -37
  16. package/browser/editor/page/storage.mjs +5 -5
  17. package/browser/shared/component-catalog.mjs +2 -2
  18. package/browser/shared/drafts.mjs +26 -51
  19. package/browser/shared/emoji/icon-value.mjs +2 -1
  20. package/browser/shared/extension-manifest.mjs +90 -0
  21. package/browser/shared/extensions.mjs +26 -16
  22. package/browser/shared/http.mjs +1 -1
  23. package/browser/shared/i18n/en.mjs +46 -15
  24. package/browser/shared/media.mjs +2 -1
  25. package/browser/shared/outline.mjs +11 -51
  26. package/browser/shared/page-address.mjs +8 -15
  27. package/browser/shared/paths.mjs +2 -1
  28. package/browser/shared/preferences.mjs +3 -1
  29. package/browser/shared/preview-server.mjs +51 -63
  30. package/browser/shared/service-location.mjs +18 -0
  31. package/browser/shared/session.mjs +3 -6
  32. package/browser/shared/workspace-address.mjs +22 -0
  33. package/browser/shared/workspace-columns.mjs +1 -2
  34. package/browser/shared/workspace-registry.mjs +6 -40
  35. package/browser/shared/workspace.mjs +3 -6
  36. package/browser/shared/writing-preferences.mjs +6 -4
  37. package/dist/{chunk-5MEXZ2UF.mjs → chunk-225ALKYI.mjs} +1 -1
  38. package/dist/{chunk-7N2LPG33.mjs → chunk-2HS7ZBPU.mjs} +1 -1
  39. package/dist/chunk-3F57LEN5.mjs +2 -0
  40. package/dist/{chunk-MKTX5PGV.mjs → chunk-43B75J5T.mjs} +1 -1
  41. package/dist/{chunk-VKSRM7EY.mjs → chunk-4B2TB5K2.mjs} +1 -1
  42. package/dist/{chunk-LV24RY2E.mjs → chunk-4K5KC6V2.mjs} +1 -1
  43. package/dist/chunk-5GK7HS62.mjs +2 -0
  44. package/dist/chunk-6GV3CBB2.mjs +2 -0
  45. package/dist/{chunk-TOE6DPLH.mjs → chunk-6NLXUKAY.mjs} +1 -1
  46. package/dist/{chunk-ZCP7BTOZ.mjs → chunk-6QBHU4DF.mjs} +1 -1
  47. package/dist/{chunk-QXVNUASA.mjs → chunk-6QWQXHAV.mjs} +1 -1
  48. package/dist/chunk-6XD6U3QA.mjs +5 -0
  49. package/dist/{chunk-DKR7LFIY.mjs → chunk-6Y3HYOBM.mjs} +1 -1
  50. package/dist/{chunk-36FIRJIF.mjs → chunk-742D2WWJ.mjs} +2 -2
  51. package/dist/{chunk-7M7UPWU6.mjs → chunk-7EFHNQ5B.mjs} +1 -1
  52. package/dist/{chunk-2GKGEVMR.mjs → chunk-7UZUQQ7Q.mjs} +25 -24
  53. package/dist/{chunk-VPVOAJ7X.mjs → chunk-AGDILNWB.mjs} +1 -1
  54. package/dist/{chunk-5IIH335D.mjs → chunk-ALZ6ZENZ.mjs} +1 -1
  55. package/dist/{chunk-G4YP7GVC.mjs → chunk-BFJGHSQN.mjs} +1 -1
  56. package/dist/{chunk-AMDGVDNV.mjs → chunk-BQNTTFPL.mjs} +1 -1
  57. package/dist/chunk-BX5AKINW.mjs +15 -0
  58. package/dist/{chunk-PAFSFVYB.mjs → chunk-BYNPEUDS.mjs} +1 -1
  59. package/dist/{chunk-74RPP2M2.mjs → chunk-C564NU2H.mjs} +1 -1
  60. package/dist/{chunk-DH6GMDNN.mjs → chunk-CRDG6EF2.mjs} +1 -1
  61. package/dist/{chunk-7XDYK3UC.mjs → chunk-E7656LR7.mjs} +1 -1
  62. package/dist/{chunk-KFZBYDIS.mjs → chunk-ECZBLQKK.mjs} +1 -1
  63. package/dist/{chunk-ZEY2RLBT.mjs → chunk-ERLAIBOA.mjs} +2 -2
  64. package/dist/{chunk-YFJU3O7G.mjs → chunk-FJLM7YE7.mjs} +1 -1
  65. package/dist/{chunk-AFGUR7SY.mjs → chunk-FNCCVGKX.mjs} +1 -1
  66. package/dist/{chunk-VNUWREXU.mjs → chunk-FOJ3K5Z3.mjs} +1 -1
  67. package/dist/{chunk-WCWYNFDF.mjs → chunk-FQ72LZHB.mjs} +1 -1
  68. package/dist/chunk-G7N7YFVD.mjs +2 -0
  69. package/dist/chunk-GIRXJBGC.mjs +2 -0
  70. package/dist/{chunk-VA3KAQZD.mjs → chunk-GKOBB6DH.mjs} +1 -1
  71. package/dist/chunk-GMJD7ID3.mjs +2 -0
  72. package/dist/chunk-GQJMVSSN.mjs +2 -0
  73. package/dist/{chunk-QZ35UAB4.mjs → chunk-GRAXKKG4.mjs} +1 -1
  74. package/dist/{chunk-SAHS56QM.mjs → chunk-HX4DLE3J.mjs} +1 -1
  75. package/dist/{chunk-2RKIHJI2.mjs → chunk-HYMEEXKN.mjs} +1 -1
  76. package/dist/{chunk-QK3VISCA.mjs → chunk-IA4PSIMD.mjs} +1 -1
  77. package/dist/chunk-IS7N3N6Q.mjs +168 -0
  78. package/dist/{chunk-CZ5KJSGK.mjs → chunk-JJNHKGTD.mjs} +1 -1
  79. package/dist/chunk-JPG2LBQM.mjs +11 -0
  80. package/dist/chunk-JYK5WJPM.mjs +2 -0
  81. package/dist/{chunk-LE44MD3O.mjs → chunk-KLQP46Y3.mjs} +1 -1
  82. package/dist/chunk-L55NOXBE.mjs +4 -0
  83. package/dist/{chunk-FXQBADMN.mjs → chunk-LCB6MARS.mjs} +1 -1
  84. package/dist/{chunk-SOD23RGL.mjs → chunk-LJLVCU6W.mjs} +8 -8
  85. package/dist/{chunk-NAGMRVW4.mjs → chunk-LKX55H76.mjs} +1 -1
  86. package/dist/chunk-LMUZQK5O.mjs +2 -0
  87. package/dist/{chunk-CG3UHDKH.mjs → chunk-M4NRDYI5.mjs} +1 -1
  88. package/dist/{chunk-HM4E43VM.mjs → chunk-MAFIGVXY.mjs} +1 -1
  89. package/dist/chunk-NLDF35P5.mjs +2 -0
  90. package/dist/{chunk-3OFXMN6N.mjs → chunk-NMF3IPYA.mjs} +1 -1
  91. package/dist/chunk-ONKC4BCC.mjs +2 -0
  92. package/dist/{chunk-CPS4SRPF.mjs → chunk-OU6ZZVBX.mjs} +2 -2
  93. package/dist/{chunk-NWRZXELO.mjs → chunk-PAREWQGB.mjs} +1 -1
  94. package/dist/{chunk-BYSF5UMM.mjs → chunk-PKVK6WFC.mjs} +2 -2
  95. package/dist/{chunk-4AMTKWDO.mjs → chunk-PUOQ65NC.mjs} +1 -1
  96. package/dist/{chunk-L7W624FD.mjs → chunk-QJAVCTY7.mjs} +1 -1
  97. package/dist/{chunk-6MPKCH3P.mjs → chunk-QNECWMGR.mjs} +1 -1
  98. package/dist/{chunk-HBAUKKQH.mjs → chunk-QP7BOHE4.mjs} +1 -1
  99. package/dist/chunk-QVGOPHOF.mjs +2 -0
  100. package/dist/{chunk-NFABH3QW.mjs → chunk-RRKJMHNX.mjs} +2 -2
  101. package/dist/chunk-S3SX3COT.mjs +20 -0
  102. package/dist/chunk-SQ3FQCCN.mjs +8 -0
  103. package/dist/{chunk-ZO7SFB2E.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  104. package/dist/{chunk-3A5I2GJK.mjs → chunk-T4Y2ZSVX.mjs} +1 -1
  105. package/dist/{chunk-VG5JEIUQ.mjs → chunk-TKWEX4FD.mjs} +2 -2
  106. package/dist/{chunk-CCSGFCLZ.mjs → chunk-U3SSPL4K.mjs} +1 -1
  107. package/dist/{chunk-DHB7UZ7F.mjs → chunk-U5XL7D6A.mjs} +1 -1
  108. package/dist/{chunk-JXLSHVJ2.mjs → chunk-UMHUSOPJ.mjs} +1 -1
  109. package/dist/chunk-UTF7GBQU.mjs +4 -0
  110. package/dist/chunk-UTMAY3WK.mjs +2 -0
  111. package/dist/{chunk-S2Y7VI4H.mjs → chunk-V4ZHRALW.mjs} +2 -2
  112. package/dist/{chunk-GWOYMENX.mjs → chunk-V6XZ4VIR.mjs} +1 -1
  113. package/dist/{chunk-WTEGUPFG.mjs → chunk-VRPVVMRB.mjs} +1 -1
  114. package/dist/{chunk-XKOHV4H6.mjs → chunk-W5NPH5UA.mjs} +1 -1
  115. package/dist/{chunk-VGTMLQWZ.mjs → chunk-WD4U6XXT.mjs} +1 -1
  116. package/dist/{chunk-4DNHHJSL.mjs → chunk-XBNFXWAW.mjs} +1 -1
  117. package/dist/chunk-XZV72SQ4.mjs +2 -0
  118. package/dist/{chunk-QJ3TFJLQ.mjs → chunk-Y34NR5JL.mjs} +1 -1
  119. package/dist/{chunk-YBB5LWZK.mjs → chunk-YFJB534W.mjs} +1 -1
  120. package/dist/{chunk-V5JRSGZF.mjs → chunk-YN37ZDLW.mjs} +1 -1
  121. package/dist/chunk-Z6OKLRHC.mjs +2 -0
  122. package/dist/chunk-ZLS2FRS6.mjs +3 -0
  123. package/dist/{chunk-JI6T3A4Y.mjs → chunk-ZMHUDYLV.mjs} +1 -1
  124. package/dist/{chunk-KH24LWAT.mjs → chunk-ZTHICSSF.mjs} +1 -1
  125. package/dist/cli.mjs +1 -1
  126. package/dist/server.mjs +1 -1
  127. package/dist/worker.mjs +1 -1
  128. package/kit/math.js +1 -1
  129. package/kit/runtime.js +13 -2
  130. package/kit/state.js +2 -0
  131. package/kit/ui.js +5 -1
  132. package/package.json +1 -1
  133. package/release.json +7 -7
  134. package/skill/SKILL.md +13 -13
  135. package/skill/references/building-blocks.md +1 -1
  136. package/skill/references/extensions.md +45 -9
  137. package/web/assets/index-D8P8uhDW.js +15 -0
  138. package/web/assets/{index-xP0uw3a0.css → index-FLb9jCfl.css} +1 -1
  139. package/web/index.html +2 -2
  140. package/dist/chunk-46ACXOU5.mjs +0 -2
  141. package/dist/chunk-5DPABPBI.mjs +0 -2
  142. package/dist/chunk-5L26JUYA.mjs +0 -2
  143. package/dist/chunk-AEMVZYZQ.mjs +0 -166
  144. package/dist/chunk-ASAXY2DJ.mjs +0 -2
  145. package/dist/chunk-DAMVDXR3.mjs +0 -2
  146. package/dist/chunk-DLFZJJEE.mjs +0 -2
  147. package/dist/chunk-EKNHM3P4.mjs +0 -2
  148. package/dist/chunk-FCK6NXON.mjs +0 -3
  149. package/dist/chunk-FX42XU6J.mjs +0 -2
  150. package/dist/chunk-HATA2W7X.mjs +0 -2
  151. package/dist/chunk-JJNRIFND.mjs +0 -8
  152. package/dist/chunk-JL6R4FG4.mjs +0 -4
  153. package/dist/chunk-KUILYI7H.mjs +0 -4
  154. package/dist/chunk-NIW7F7LU.mjs +0 -4
  155. package/dist/chunk-OU3S466R.mjs +0 -20
  156. package/dist/chunk-QCEATQC4.mjs +0 -2
  157. package/dist/chunk-TDWJKOLN.mjs +0 -2
  158. package/dist/chunk-UGO5N3EI.mjs +0 -15
  159. package/dist/chunk-XMKHCUI6.mjs +0 -15
  160. package/dist/chunk-XQRUG4G3.mjs +0 -2
  161. package/dist/chunk-YPPJVDQI.mjs +0 -2
  162. package/dist/chunk-ZANMKAWS.mjs +0 -2
  163. package/web/assets/index-BHC5ZOMh.js +0 -15
  164. /package/dist/{chunk-N3DSBH5S.mjs → chunk-A55HN5OK.mjs} +0 -0
  165. /package/dist/{chunk-KNZJT4ET.mjs → chunk-QAIHRH3I.mjs} +0 -0
  166. /package/dist/{chunk-ZW2A6GBW.mjs → chunk-QR6A54KJ.mjs} +0 -0
  167. /package/dist/{chunk-74UW7QSL.mjs → chunk-UH4SIXTR.mjs} +0 -0
  168. /package/dist/{chunk-EKGYYOSP.mjs → chunk-W7XHE4CT.mjs} +0 -0
  169. /package/dist/{chunk-5MMN3N5J.mjs → chunk-YEY3RSFQ.mjs} +0 -0
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{e as D,f as x}from"./chunk-XQRUG4G3.mjs";import{a as d,b as u,c as w,d as y}from"./chunk-OU3S466R.mjs";import{b as c,d as f,e as m,g as p,h as g,i as a,j as h}from"./chunk-WTEGUPFG.mjs";import{k as l}from"./chunk-YFJU3O7G.mjs";import{a as s}from"./chunk-JXLSHVJ2.mjs";import S from"node:path";import{FILE as j}from"../browser/shared/annotations.mjs";import{editStateDirectory as L,reportsDirectory as i}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as k}from"../browser/shared/workspace.mjs";function O({say:e=!0}={}){return o=>{let{text:t,changes:n}=c(o.html,{finish:l});if(e&&n.length&&console.log(p(o.htmlPath,n,{pending:!0}).join(`
2
+ import{e as D,f as x}from"./chunk-5GK7HS62.mjs";import{a as d,b as u,c as w,d as y}from"./chunk-S3SX3COT.mjs";import{b as c,d as f,e as m,g as p,h as g,i as a,j as h}from"./chunk-VRPVVMRB.mjs";import{k as l}from"./chunk-FJLM7YE7.mjs";import{a as s}from"./chunk-UMHUSOPJ.mjs";import S from"node:path";import{FILE as j}from"../browser/shared/annotations.mjs";import{editStateDirectory as L,reportsDirectory as i}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as k}from"../browser/shared/workspace.mjs";function O({say:e=!0}={}){return o=>{let{text:t,changes:n}=c(o.html,{finish:l});if(e&&n.length&&console.log(p(o.htmlPath,n,{pending:!0}).join(`
3
3
  `)),e){let r=f(o.html);r.length&&console.log(D(o.htmlPath,r,r.length,{pending:!0}).join(`
4
4
  `));for(let N of x(o.htmlPath,m(s(o.html),o.metadata),{pending:!0}))console.log(N)}return t}}function b(e){for(let o of e){for(let t of g(o.html))console.log(`note ${o.slug}: ${t} (read-only in the preview)`);for(let t of a(o.html))console.log(`note ${o.slug}: ${t}`);for(let t of h(o.html))console.log(`note ${o.slug}: ${t}`)}}async function q(e){for(let o of e){let t=await w({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of y(k($(o,i)).html,t))console.log(n)}}async function z(e){for(let o of e){let t=await d({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of u(S.join($(o,i),j),t))console.log(n)}}export{O as a,b,q as c,z as d};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as H,c as X,e as ve}from"./chunk-N3DSBH5S.mjs";ve();import{isUtf8 as _e}from"node:buffer";import{createHash as Pe}from"node:crypto";import{existsSync as Ce,lstatSync as De,readFileSync as _,readdirSync as Me,realpathSync as Q,statSync as Fe}from"node:fs";import Le from"node:fs/promises";import k from"node:path";import{isInstance as Re,parseCompound as Ke,parsePart as Ge,parseSelector as Ve,partOf as Ue}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as pe,NO_TEXT as We,PACKAGE_ID as A,PACKAGE_MARK as Be,SLOT as ee,inDocumentMenus as Je,instanceMatch as Ze,refusedInCopy as qe,settingState as Ye}from"../browser/shared/components/installed.mjs";import{writeAtomic as He}from"../browser/shared/files.mjs";import{attr as Xe,walk as Qe}from"../browser/shared/html-tree.mjs";import{HOST as me,NET as te,netHostsOf as et}from"../browser/shared/net-policy.mjs";import{inLanguage as tt,refusal as ue,said as i,saying as nt,told as st}from"../browser/shared/i18n/index.mjs";import{DEFAULT_PACK as ot,OWN_SCOPE as it,PACK_FILE as ne,PACK_ID as he,readPackManifest as rt}from"../browser/shared/pack-manifest.mjs";import{DEVICE_NAMES as at,PACKAGE_MANIFEST as I,WORKSPACE_MARK as ct,findWorkspace as lt,layoutOf as G,markerOf as ft,packageFolders as dt}from"../browser/shared/workspace.mjs";var se=1,oe=new Set(["code","state","sheets","tokens","dialogs","katex-styles","katex","katex-auto-render","math","d3","charts","tables"]),pt=["id","apiVersion","version","name","description","words","parts","runtime","assets","markdown","schema","places","card","settings","needs"],mt=["at","edit","optional","min","max"],ut=["generated","attrs"],ht=["document","page"],wt=["document"],yt=["sizes","w","h","min","max","resize","fit","bare","consent"],y={w:12,h:24},bt=["fixed","content"],ie={sizes:null,any:!1,w:4,h:null,min:{w:1,h:1},max:{...y},resize:!1,fit:"fixed",bare:!1},gt=["key","label","type","options","default","required"],kt=/^[a-z][a-zA-Z0-9]*$/,re=["text","number","select","date","switch","document"],Ot=/^\d{4}-\d{2}-\d{2}$/,$t="settings",Et=["workspace","tables"],St=["text","data","flow","none"],xt=/^[a-z][a-z0-9-]*$/,At=e=>`div[${ee}="${e}"], section[${ee}="${e}"]`,Nt=e=>Object.fromEntries(Object.entries(e).map(([n,s])=>[n,s.edit==="flow"?{...s,at:At(n)}:s])),jt=["parts","text"],we=["kit.js","style.css","preview.svg"],M="template.html",zt=[I,M,...we],V=e=>[...new Set([...zt,...e])].sort(),Tt=/^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/,It=/^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i,ae=256*1024,u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),b=e=>typeof e=="string"&&e.trim()!=="",U=(e,n)=>e.id<n.id?-1:1,r=e=>{throw ue(e)},S=e=>{let n=Pe("sha256");return e(n),n.digest("hex").slice(0,16)};function j(e,n){let s=k.join(e,n);try{let t=De(s,{throwIfNoEntry:!1});if(!t)return null;if(!t.isSymbolicLink()&&!n.includes("/"))return s;let o=Q.native(s);return o.startsWith(Q.native(e)+k.sep)?o:null}catch{return null}}function ye(e,n){try{let s=j(e,n);return s&&_(s)}catch{return null}}var ce=new Map,vt=2e3;function _t(e){let{size:n,mtimeMs:s}=Fe(e),t=ce.get(e);if(t?.size===n&&t.time===s)return t.digest;let o=S(f=>f.update(_(e)));return Date.now()-s>vt&&ce.set(e,{size:n,time:s,digest:o}),o}var W=(e,n)=>S(s=>{for(let t of n){let o=j(e,t),f="none";try{o&&(f=_t(o))}catch{}s.update(`${t}\0${f}
3
- `)}}),be=e=>e.toString("utf8").replace(/^\uFEFF/,""),ge=(e,n)=>{e.length>ae&&r(i("{0} \u6709 {1} KB\uFF0C\u800C\u6BCF\u4E00\u9875\u90FD\u5E26\u7740\u5B83\uFF0C\u6700\u591A {2} KB",n,Math.ceil(e.length/1024),ae/1024))},E=(e,n,s="")=>{for(let t of Object.keys(e))n.includes(t)||r(i("{0} \u4E0D\u662F\u81EA\u5B9A\u4E49\u5757\u7684\u6E05\u5355\u80FD\u5199\u7684\u5B57\u6BB5",`${s}${t}`))},le=(e,n)=>{for(let s of n)e[s]===void 0&&r(i("\u7F3A\u5C11 {0}",s))},v=(e,n)=>{(!u(e)||!b(e.zh)||!b(e.en)||Object.keys(e).length!==2)&&r(i("{0} \u8981\u5199\u6210 { zh, en } \u4E24\u79CD\u8BED\u8A00\u7684\u6587\u5B57",n))},F=e=>e.split(",").map(n=>n.split(">").at(-1).trim()).filter(n=>n!=="*").map(n=>Ke(n).tag);function Pt(e,n){let s=`parts.${e}`;if(u(n)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",s)),E(n,mt,`${s}.`),n.edit==="flow"){xt.test(e)||r(i("{0} \u662F\u63D2\u69FD\uFF0C\u540D\u5B57\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",s)),n.at!==void 0&&r(i('{0} \u662F\u63D2\u69FD\uFF0C\u7531 data-doc-slot="{1}" \u6807\u51FA\uFF0C\u4E0D\u5199 at',s,e)),(n.min!==void 0||n.max!==void 0)&&r(i("{0} \u662F\u63D2\u69FD\uFF0C\u4E00\u4E2A\u5B9E\u4F8B\u91CC\u53EA\u6709\u4E00\u4E2A\uFF0C\u4E0D\u5199 min\u3001max",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));return}b(n.at)||r(i("\u7F3A\u5C11 {0}",`${s}.at`));try{Ge(n.at)}catch(t){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",`${s}.at`,t.message))}St.includes(n.edit)||r(i("{0} \u7684 edit \u53EA\u80FD\u662F text\u3001data\u3001flow \u6216 none",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));for(let t of["min","max"])n[t]!==void 0&&!(Number.isInteger(n[t])&&n[t]>=0)&&r(i("{0} \u8981\u5199\u6210\u4E0D\u5C0F\u4E8E 0 \u7684\u6574\u6570",`${s}.${t}`));if(n.min>n.max&&r(i("{0} \u7684 min \u6BD4 max \u5927\uFF0C\u6CA1\u6709\u5B9E\u4F8B\u80FD\u6EE1\u8DB3",s)),n.edit==="text")for(let t of F(n.at))We.has(t)&&r(i("{0} \u4E0D\u80FD\u6309\u6587\u5B57\u7F16\u8F91\uFF1A<{1}> \u4E0D\u662F\u80FD\u6253\u5B57\u7684\u6587\u5B57",s,t))}var Ct=e=>e.split(",").some(n=>n.split(">").every(s=>[":scope","*"].includes(s.trim())));function Dt(e,n){if(e===void 0)return null;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime")),E(e,ut,"runtime.");let s=`[${pe}="${n}"]`,t=(d,a)=>{try{if(!b(d))throw new Error("no selector");Ve(d)}catch(l){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",a,l.message))}return d.split(",").map(l=>l.trim().startsWith(":scope")?l.trim().replace(":scope",s):`${s} ${l.trim()}`).join(", ")},{generated:o=[],attrs:f={}}=e;Array.isArray(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.generated")),u(f)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime.attrs"));for(let d of Object.values(f)){(!Array.isArray(d)||!d.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.attrs"));for(let a of d)It.test(a)&&r(i("{0} \u662F Gallery \u81EA\u5DF1\u7684\u540D\u5B57\uFF0C\u81EA\u5B9A\u4E49\u5757\u4E0D\u80FD\u7528",a))}let c=d=>{let a=t(d,"runtime.generated");return Ct(d)&&r(i("{0} \u7684 {1} \u662F\u6574\u4E2A\u5B9E\u4F8B\uFF0C\u800C\u8FD9\u91CC\u53EA\u5199\u5B83\u751F\u6210\u7684\u8282\u70B9","runtime.generated",d)),a};return{generated:o.map(c),attrs:Object.fromEntries(Object.entries(f).map(([d,a])=>[t(d,"runtime.attrs"),a]))}}var T=(e,n)=>Number.isInteger(e)&&e>=1&&e<=n,O=e=>e.find((n,s)=>e.indexOf(n)!==s);function Mt(e){return e===void 0?wt:((!Array.isArray(e)||e.length===0||!e.every(n=>ht.includes(n)))&&r(i('places \u8981\u5199\u6210 document\u3001page \u4E2D\u7684\u4E00\u4E2A\u6216\u4E24\u4E2A\uFF0C\u5982 ["document"]')),O(e)&&r(i("places \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e])}function Ft(e){if(e===void 0)return ie;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","card")),E(e,yt,"card.");let n=a=>Array.isArray(a)&&a.length===2&&T(a[0],y.w)&&T(a[1],y.h);if(e.sizes!==void 0){(!Array.isArray(e.sizes)||e.sizes.length===0||!e.sizes.every(n))&&r(i("card.sizes \u8981\u5199\u6210 [\u5BBD, \u9AD8] \u7684\u4E00\u4E32\uFF0C\u5BBD 1 \u5230 {0} \u683C\uFF0C\u9AD8 1 \u5230 {1} \u683C",y.w,y.h));let a=O(e.sizes.map(p=>p.join("x")));a&&r(i("card.sizes \u91CC {0} \u5199\u4E86\u4E24\u6B21",a));let l=["w","h"].find(p=>e[p]!==void 0);l&&r(i("\u5199\u4E86 card.sizes\uFF0C\u5C31\u4E0D\u518D\u5199 card.{0}\uFF1A\u7B2C\u4E00\u79CD\u5927\u5C0F\u662F\u9ED8\u8BA4\u7684",l))}for(let a of["w","h"])e[a]!==void 0&&!T(e[a],y[a])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}`,y[a]));let s={};for(let a of["min","max"]){let l=e[a];if(l!==void 0){u(l)||r(i("{0} \u8981\u5199\u6210 { w, h }\uFF0C\u5355\u4F4D\u662F\u683C",`card.${a}`)),E(l,["w","h"],`card.${a}.`);for(let p of["w","h"])l[p]!==void 0&&!T(l[p],y[p])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}.${p}`,y[p]));s[a]=l}}let t={w:s.min?.w??1,h:s.min?.h??1},o={w:s.max?.w??y.w,h:s.max?.h??y.h},f=e.sizes?e.sizes[0][0]:e.w??ie.w,c=e.sizes?e.sizes[0][1]:e.h??null,d=!!e.sizes&&(e.min!==void 0||e.max!==void 0);if(d){let a=e.sizes.find(([l,p])=>l<t.w||l>o.w||p<t.h||p>o.h);a&&r(i("card.sizes \u91CC {0} \u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4",a.join("x")))}for(let a of["w","h"]){t[a]>o[a]&&r(i("card.min.{0} \u6BD4 card.max.{0} \u5927",a));let l={w:f,h:c}[a];l!==null&&!e.sizes&&(l<t[a]||l>o[a])&&r(i("\u9ED8\u8BA4\u7684 card.{0} \u662F {1}\uFF0C\u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4\uFF08{2} \u5230 {3}\uFF09",a,l,t[a],o[a]))}for(let a of["resize","bare"])e[a]!==void 0&&typeof e[a]!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`card.${a}`));return e.fit!==void 0&&!bt.includes(e.fit)&&r(i("card.fit \u53EA\u80FD\u662F fixed \u6216 content")),e.consent!==void 0&&v(e.consent,"card.consent"),{sizes:e.sizes?e.sizes.map(([a,l])=>[a,l]):null,any:d,w:f,h:c,min:t,max:o,resize:e.resize??!1,fit:e.fit??"fixed",bare:e.bare??!1,...e.consent!==void 0?{consent:{zh:e.consent.zh,en:e.consent.en}}:{}}}var Lt=(e,{type:n,options:s})=>({text:typeof e=="string",number:typeof e=="number"&&Number.isFinite(e),select:s?.includes(e),date:typeof e=="string"&&Ot.test(e),switch:typeof e=="boolean",document:typeof e=="string"})[n];function Rt(e,n){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u5B57\u6BB5","settings"));let s=[];e.forEach((o,f)=>{let c=`settings[${f}]`;u(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",c)),E(o,gt,`${c}.`),(typeof o.key!="string"||!kt.test(o.key))&&r(i("{0} \u7684 key \u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u53EA\u7528\u5B57\u6BCD\u548C\u6570\u5B57\uFF08\u5982 city\u3001startDate\uFF09",c)),s.includes(o.key)&&r(i("settings \u91CC key {0} \u5199\u4E86\u4E24\u6B21",o.key)),s.push(o.key),v(o.label,`${c}.label`),re.includes(o.type)||r(i("{0} \u7684 type \u53EA\u80FD\u662F {1}",c,re.join(", "))),o.type==="select"?((!Array.isArray(o.options)||o.options.length===0||!o.options.every(b))&&r(i("{0} \u662F select\uFF0C\u8981\u6709 options\uFF1A\u4E00\u4E32\u6587\u5B57",c)),O(o.options)&&r(i("{0} \u7684 options \u91CC {1} \u5199\u4E86\u4E24\u6B21",c,O(o.options)))):o.options!==void 0&&r(i("{0} \u4E0D\u662F select\uFF0C\u4E0D\u5199 options",c)),o.default!==void 0&&!Lt(o.default,o)&&r(i("{0} \u7684 default \u548C\u5B83\u7684 type {1} \u4E0D\u7B26",c,o.type)),o.required!==void 0&&typeof o.required!="boolean"&&r(i("{0} \u7684 required \u8981\u5199 true \u6216 false",c))});let t=n[$t];return e.length>0&&!(t?.edit==="data"&&F(t.at).every(o=>o==="script")&&F(t.at).length>0)&&r(i('\u5199\u4E86 settings\uFF0Cparts \u91CC\u5C31\u8981\u6709\u4E00\u4E2A\u540D\u4E3A settings\u3001edit \u4E3A data \u7684\u90E8\u5206\uFF0C\u5B83\u662F\u4E00\u4E2A <script type="application/json">\uFF0C\u5B58\u5361\u7247\u8BBE\u7F6E\u7684\u503C')),e.map(o=>({...o}))}function Kt(e){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","needs"));for(let n of e)typeof n=="string"&&(Et.includes(n)||n.startsWith(te)&&me.test(n.slice(te.length)))||r(i("needs \u91CC\u7684 {0} \u4E0D\u8BA4\u8BC6\uFF1A\u53EA\u8BA4 workspace\u3001tables \u548C net:<\u57DF\u540D>\uFF08\u5C0F\u5199\u7684\u4E3B\u673A\u540D\uFF0C\u4E0D\u5E26\u7AEF\u53E3\u548C\u8DEF\u5F84\uFF0C\u53EF\u4EE5\u4EE5 *. \u5F00\u5934\uFF09",typeof n=="string"?n:JSON.stringify(n)));return O(e)&&r(i("needs \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e]}function Gt(e,n){if(!e.includes("page"))return;let s=Object.entries(n).find(([,t])=>t.edit==="flow");s&&r(i("places \u91CC\u6709 page\uFF0C\u5C31\u4E0D\u80FD\u6709\u63D2\u69FD\uFF1A{0} \u7684 edit \u662F flow\uFF0C\u63D2\u69FD\u653E\u7684\u662F\u6587\u6863\u7684\u5757\uFF0C\u81EA\u5B9A\u4E49\u9875\u4E0A\u6CA1\u6709",`parts.${s[0]}`))}function Vt(e,n){if(e===void 0)return{kit:[],own:[]};(!Array.isArray(e)||!e.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","assets"));let s=e.filter(t=>!oe.has(t));for(let t of s)Tt.test(t)||r(i("assets \u91CC\u7684 {0} \u65E2\u4E0D\u662F\u5957\u4EF6\u7684\u8D44\u6E90\uFF0C\u4E5F\u4E0D\u662F\u5757\u7684\u6587\u4EF6\u5939\u91CC\u7684\u6587\u4EF6",t)),j(n,t)||r(i("assets \u5199\u4E86 {0}\uFF0C\u5757\u7684\u6587\u4EF6\u5939\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6587\u4EF6",t));return{kit:e.filter(t=>oe.has(t)),own:s}}function Ut(e,n,s){let t;try{t=JSON.parse(s)}catch(w){r(i("component.json \u4E0D\u662F JSON\uFF1A{0}",w.message))}u(t)||r(i("component.json \u5199\u7684\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61")),A.test(e)||r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A\u8303\u56F4\u548C\u540D\u5B57\u90FD\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",e));for(let w of e.split("/"))at.has(w)&&r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A{1} \u662F Windows \u7559\u7ED9\u8BBE\u5907\u7684\u540D\u5B57",e,w));if(t.id!==e&&r(i("\u6E05\u5355\u7684 id \u662F {0}\uFF0C\u548C\u5B83\u7684\u6587\u4EF6\u5939 {1} \u4E0D\u4E00\u6837",String(t.id),e)),le(t,["apiVersion"]),(!Number.isInteger(t.apiVersion)||t.apiVersion<1)&&r(i("apiVersion \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570")),t.apiVersion!==se)throw ue(i("\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u5757\u8981 apiVersion {0}\uFF0C\u8FD9\u4E00\u7248 Gallery \u53EA\u652F\u6301 {1}",t.apiVersion,se),{disabled:!0,version:b(t.version)?t.version:null});E(t,pt),le(t,["version","name","description","parts"]),b(t.version)||r(i("{0} \u8981\u5199\u6210\u6587\u5B57","version")),v(t.name,"name"),v(t.description,"description"),t.words!==void 0&&typeof t.words!="string"&&r(i("{0} \u8981\u5199\u6210\u6587\u5B57","words")),u(t.parts)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","parts"));for(let[w,$]of Object.entries(t.parts))Pt(w,$);let o=Dt(t.runtime,e),{kit:f,own:c}=Vt(t.assets,n);t.markdown!==void 0&&!jt.includes(t.markdown)&&r(i("markdown \u53EA\u80FD\u662F parts \u6216 text")),t.schema!==void 0&&!(Number.isInteger(t.schema)&&t.schema>=1)&&r(i("schema \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570"));let d=Mt(t.places);Gt(d,t.parts);let a=Ft(t.card),l=Rt(t.settings,t.parts),p=Kt(t.needs),h=ye(n,M);return h&&ge(h,M),{id:e,match:Ze(e),parts:Nt(t.parts),...o?{runtime:o}:{},...t.schema!==void 0?{schema:t.schema}:{},apiVersion:t.apiVersion,version:t.version,name:t.name,description:t.description,words:t.words??"",assets:f,markdown:t.markdown??"parts",places:d,card:a,settings:l,needs:p,files:[...new Set([...we.filter(w=>j(n,w)),...c])],template:h&&be(h),folder:n,definition:S(w=>w.update(s)),stamp:W(n,V(c))}}function Wt(e,n){try{let s=ye(n,I);return s||r(i("\u8BFB\u4E0D\u51FA component.json")),_e(s)||r(i("{0} \u4E0D\u662F UTF-8 \u7F16\u7801\uFF1A\u8BF7\u5B58\u6210 UTF-8",I)),ge(s,I),Ut(e,n,be(s))}catch(s){let t=nt(s),o=S(f=>f.update(`${W(n,V([]))} ${JSON.stringify(t)}`));return{id:e.toLowerCase(),stamp:o,problem:t,disabled:s.disabled===!0,version:s.version??null}}}var P=()=>lt().root,Bt=/^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/,x=(e,n)=>[...new Set(Array.isArray(e)?e.filter(s=>typeof s=="string"&&n.test(s)):[])],Jt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n])=>A.test(n)).map(([n,s])=>[n,x(s,me)]).filter(([,n])=>n.length>0)),Zt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n,s])=>he.test(n)&&typeof s?.enabled=="boolean").map(([n,s])=>[n,s.enabled])),C=e=>{let n=Zt(e?.components?.packs);return{hidden:x(e?.components?.hidden,Bt),disabled:x(e?.components?.disabled,A),shown:x(e?.components?.shown,A),unlisted:x(e?.components?.unlisted,A),net:Jt(e?.components?.net),packs:n,packsOff:Object.keys(n).filter(s=>n[s]===!1).sort()}},B=i("gallery.json \u8BFB\u4E0D\u51FA\u6765\uFF1A\u6539\u597D\u8FD9\u4E2A\u6587\u4EF6\u540E\u518D\u8BD5"),qt=i("gallery.json \u4E0D\u662F Gallery \u7684\u6587\u4EF6");function L(e){if(e===null)return{value:null};let{value:n,ours:s,reads:t}=ft(e);return s?{value:n}:{problem:t?qt:B}}function ke(e){try{return L(_(G(e).marker,"utf8"))}catch(n){return n.code==="ENOENT"?L(null):{problem:B}}}var On=(e=P())=>C(ke(e).value),Yt=["EPERM","EACCES","EBUSY","EROFS"];async function $n(e,{id:n,hidden:s,shown:t,disabled:o,unlisted:f,net:c,pack:d,enabled:a}){let l=G(e).marker,p=await Le.readFile(l,"utf8").catch(m=>{if(m.code==="ENOENT")return null;r(B)}),{value:h,problem:w}=L(p);w&&r(w);let $=(m,Y)=>Y===void 0?m:Y?[...new Set([...m,n])]:m.filter(Ie=>Ie!==n),{hidden:Ne,disabled:je,shown:ze,unlisted:Te}=C(h),g=u(h?.components)?h.components:{},Z=$(ze,t),q=$(Te,f),z={...g,hidden:$(Ne,s),disabled:$(je,o),...Z.length>0||Object.hasOwn(g,"shown")?{shown:Z}:{},...q.length>0||Object.hasOwn(g,"unlisted")?{unlisted:q}:{}};if(d!==void 0){let m=u(g.packs)?g.packs:{};z.packs={...m,[d]:{...u(m[d])?m[d]:{},enabled:a===!0}}}if(c!==void 0){let m={...u(g.net)?g.net:{}};c.length>0?m[n]=[...new Set(c)]:delete m[n],Object.keys(m).length>0?z.net=m:delete z.net}await He(l,`${JSON.stringify({...h??ct,components:z},null,2)}
2
+ import{a as H,c as X,e as ve}from"./chunk-A55HN5OK.mjs";ve();import{isUtf8 as _e}from"node:buffer";import{createHash as Pe}from"node:crypto";import{existsSync as Ce,lstatSync as De,readFileSync as _,readdirSync as Me,realpathSync as Q,statSync as Fe}from"node:fs";import Le from"node:fs/promises";import k from"node:path";import{isInstance as Re,parseCompound as Ke,parsePart as Ge,parseSelector as Ve,partOf as Ue}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as pe,NO_TEXT as We,PACKAGE_ID as A,PACKAGE_MARK as Be,SLOT as ee,inDocumentMenus as Je,instanceMatch as Ze,refusedInCopy as qe,settingState as Ye}from"../browser/shared/components/installed.mjs";import{writeAtomic as He}from"../browser/shared/files.mjs";import{attr as Xe,walk as Qe}from"../browser/shared/html-tree.mjs";import{HOST as me,NET as te,netHostsOf as et}from"../browser/shared/net-policy.mjs";import{inLanguage as tt,refusal as ue,said as i,saying as nt,told as st}from"../browser/shared/i18n/index.mjs";import{DEFAULT_PACK as ot,OWN_SCOPE as it,PACK_FILE as ne,PACK_ID as he,readPackManifest as rt}from"../browser/shared/pack-manifest.mjs";import{DEVICE_NAMES as at,PACKAGE_MANIFEST as I,WORKSPACE_MARK as ct,defaultWorkspace as lt,layoutOf as G,markerOf as ft,packageFolders as dt}from"../browser/shared/workspace.mjs";var se=1,oe=new Set(["code","state","sheets","tokens","dialogs","katex-styles","katex","katex-auto-render","math","d3","charts","tables"]),pt=["id","apiVersion","version","name","description","words","parts","runtime","assets","markdown","schema","places","card","settings","needs"],mt=["at","edit","optional","min","max"],ut=["generated","attrs"],ht=["document","page"],wt=["document"],yt=["sizes","w","h","min","max","resize","fit","bare","consent"],y={w:12,h:24},bt=["fixed","content"],ie={sizes:null,any:!1,w:4,h:null,min:{w:1,h:1},max:{...y},resize:!1,fit:"fixed",bare:!1},gt=["key","label","type","options","default","required"],kt=/^[a-z][a-zA-Z0-9]*$/,re=["text","number","select","date","switch","document"],Ot=/^\d{4}-\d{2}-\d{2}$/,$t="settings",Et=["workspace","tables"],St=["text","data","flow","none"],xt=/^[a-z][a-z0-9-]*$/,At=e=>`div[${ee}="${e}"], section[${ee}="${e}"]`,Nt=e=>Object.fromEntries(Object.entries(e).map(([n,s])=>[n,s.edit==="flow"?{...s,at:At(n)}:s])),jt=["parts","text"],we=["kit.js","style.css","preview.svg"],M="template.html",zt=[I,M,...we],V=e=>[...new Set([...zt,...e])].sort(),Tt=/^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/,It=/^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i,ae=256*1024,u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),b=e=>typeof e=="string"&&e.trim()!=="",U=(e,n)=>e.id<n.id?-1:1,r=e=>{throw ue(e)},S=e=>{let n=Pe("sha256");return e(n),n.digest("hex").slice(0,16)};function j(e,n){let s=k.join(e,n);try{let t=De(s,{throwIfNoEntry:!1});if(!t)return null;if(!t.isSymbolicLink()&&!n.includes("/"))return s;let o=Q.native(s);return o.startsWith(Q.native(e)+k.sep)?o:null}catch{return null}}function ye(e,n){try{let s=j(e,n);return s&&_(s)}catch{return null}}var ce=new Map,vt=2e3;function _t(e){let{size:n,mtimeMs:s}=Fe(e),t=ce.get(e);if(t?.size===n&&t.time===s)return t.digest;let o=S(f=>f.update(_(e)));return Date.now()-s>vt&&ce.set(e,{size:n,time:s,digest:o}),o}var W=(e,n)=>S(s=>{for(let t of n){let o=j(e,t),f="none";try{o&&(f=_t(o))}catch{}s.update(`${t}\0${f}
3
+ `)}}),be=e=>e.toString("utf8").replace(/^\uFEFF/,""),ge=(e,n)=>{e.length>ae&&r(i("{0} \u6709 {1} KB\uFF0C\u800C\u6BCF\u4E00\u9875\u90FD\u5E26\u7740\u5B83\uFF0C\u6700\u591A {2} KB",n,Math.ceil(e.length/1024),ae/1024))},E=(e,n,s="")=>{for(let t of Object.keys(e))n.includes(t)||r(i("{0} \u4E0D\u662F\u81EA\u5B9A\u4E49\u5757\u7684\u6E05\u5355\u80FD\u5199\u7684\u5B57\u6BB5",`${s}${t}`))},le=(e,n)=>{for(let s of n)e[s]===void 0&&r(i("\u7F3A\u5C11 {0}",s))},v=(e,n)=>{(!u(e)||!b(e.zh)||!b(e.en)||Object.keys(e).length!==2)&&r(i("{0} \u8981\u5199\u6210 { zh, en } \u4E24\u79CD\u8BED\u8A00\u7684\u6587\u5B57",n))},F=e=>e.split(",").map(n=>n.split(">").at(-1).trim()).filter(n=>n!=="*").map(n=>Ke(n).tag);function Pt(e,n){let s=`parts.${e}`;if(u(n)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",s)),E(n,mt,`${s}.`),n.edit==="flow"){xt.test(e)||r(i("{0} \u662F\u63D2\u69FD\uFF0C\u540D\u5B57\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",s)),n.at!==void 0&&r(i('{0} \u662F\u63D2\u69FD\uFF0C\u7531 data-doc-slot="{1}" \u6807\u51FA\uFF0C\u4E0D\u5199 at',s,e)),(n.min!==void 0||n.max!==void 0)&&r(i("{0} \u662F\u63D2\u69FD\uFF0C\u4E00\u4E2A\u5B9E\u4F8B\u91CC\u53EA\u6709\u4E00\u4E2A\uFF0C\u4E0D\u5199 min\u3001max",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));return}b(n.at)||r(i("\u7F3A\u5C11 {0}",`${s}.at`));try{Ge(n.at)}catch(t){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",`${s}.at`,t.message))}St.includes(n.edit)||r(i("{0} \u7684 edit \u53EA\u80FD\u662F text\u3001data\u3001flow \u6216 none",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));for(let t of["min","max"])n[t]!==void 0&&!(Number.isInteger(n[t])&&n[t]>=0)&&r(i("{0} \u8981\u5199\u6210\u4E0D\u5C0F\u4E8E 0 \u7684\u6574\u6570",`${s}.${t}`));if(n.min>n.max&&r(i("{0} \u7684 min \u6BD4 max \u5927\uFF0C\u6CA1\u6709\u5B9E\u4F8B\u80FD\u6EE1\u8DB3",s)),n.edit==="text")for(let t of F(n.at))We.has(t)&&r(i("{0} \u4E0D\u80FD\u6309\u6587\u5B57\u7F16\u8F91\uFF1A<{1}> \u4E0D\u662F\u80FD\u6253\u5B57\u7684\u6587\u5B57",s,t))}var Ct=e=>e.split(",").some(n=>n.split(">").every(s=>[":scope","*"].includes(s.trim())));function Dt(e,n){if(e===void 0)return null;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime")),E(e,ut,"runtime.");let s=`[${pe}="${n}"]`,t=(d,a)=>{try{if(!b(d))throw new Error("no selector");Ve(d)}catch(l){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",a,l.message))}return d.split(",").map(l=>l.trim().startsWith(":scope")?l.trim().replace(":scope",s):`${s} ${l.trim()}`).join(", ")},{generated:o=[],attrs:f={}}=e;Array.isArray(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.generated")),u(f)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime.attrs"));for(let d of Object.values(f)){(!Array.isArray(d)||!d.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.attrs"));for(let a of d)It.test(a)&&r(i("{0} \u662F Gallery \u81EA\u5DF1\u7684\u540D\u5B57\uFF0C\u81EA\u5B9A\u4E49\u5757\u4E0D\u80FD\u7528",a))}let c=d=>{let a=t(d,"runtime.generated");return Ct(d)&&r(i("{0} \u7684 {1} \u662F\u6574\u4E2A\u5B9E\u4F8B\uFF0C\u800C\u8FD9\u91CC\u53EA\u5199\u5B83\u751F\u6210\u7684\u8282\u70B9","runtime.generated",d)),a};return{generated:o.map(c),attrs:Object.fromEntries(Object.entries(f).map(([d,a])=>[t(d,"runtime.attrs"),a]))}}var T=(e,n)=>Number.isInteger(e)&&e>=1&&e<=n,O=e=>e.find((n,s)=>e.indexOf(n)!==s);function Mt(e){return e===void 0?wt:((!Array.isArray(e)||e.length===0||!e.every(n=>ht.includes(n)))&&r(i('places \u8981\u5199\u6210 document\u3001page \u4E2D\u7684\u4E00\u4E2A\u6216\u4E24\u4E2A\uFF0C\u5982 ["document"]')),O(e)&&r(i("places \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e])}function Ft(e){if(e===void 0)return ie;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","card")),E(e,yt,"card.");let n=a=>Array.isArray(a)&&a.length===2&&T(a[0],y.w)&&T(a[1],y.h);if(e.sizes!==void 0){(!Array.isArray(e.sizes)||e.sizes.length===0||!e.sizes.every(n))&&r(i("card.sizes \u8981\u5199\u6210 [\u5BBD, \u9AD8] \u7684\u4E00\u4E32\uFF0C\u5BBD 1 \u5230 {0} \u683C\uFF0C\u9AD8 1 \u5230 {1} \u683C",y.w,y.h));let a=O(e.sizes.map(p=>p.join("x")));a&&r(i("card.sizes \u91CC {0} \u5199\u4E86\u4E24\u6B21",a));let l=["w","h"].find(p=>e[p]!==void 0);l&&r(i("\u5199\u4E86 card.sizes\uFF0C\u5C31\u4E0D\u518D\u5199 card.{0}\uFF1A\u7B2C\u4E00\u79CD\u5927\u5C0F\u662F\u9ED8\u8BA4\u7684",l))}for(let a of["w","h"])e[a]!==void 0&&!T(e[a],y[a])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}`,y[a]));let s={};for(let a of["min","max"]){let l=e[a];if(l!==void 0){u(l)||r(i("{0} \u8981\u5199\u6210 { w, h }\uFF0C\u5355\u4F4D\u662F\u683C",`card.${a}`)),E(l,["w","h"],`card.${a}.`);for(let p of["w","h"])l[p]!==void 0&&!T(l[p],y[p])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}.${p}`,y[p]));s[a]=l}}let t={w:s.min?.w??1,h:s.min?.h??1},o={w:s.max?.w??y.w,h:s.max?.h??y.h},f=e.sizes?e.sizes[0][0]:e.w??ie.w,c=e.sizes?e.sizes[0][1]:e.h??null,d=!!e.sizes&&(e.min!==void 0||e.max!==void 0);if(d){let a=e.sizes.find(([l,p])=>l<t.w||l>o.w||p<t.h||p>o.h);a&&r(i("card.sizes \u91CC {0} \u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4",a.join("x")))}for(let a of["w","h"]){t[a]>o[a]&&r(i("card.min.{0} \u6BD4 card.max.{0} \u5927",a));let l={w:f,h:c}[a];l!==null&&!e.sizes&&(l<t[a]||l>o[a])&&r(i("\u9ED8\u8BA4\u7684 card.{0} \u662F {1}\uFF0C\u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4\uFF08{2} \u5230 {3}\uFF09",a,l,t[a],o[a]))}for(let a of["resize","bare"])e[a]!==void 0&&typeof e[a]!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`card.${a}`));return e.fit!==void 0&&!bt.includes(e.fit)&&r(i("card.fit \u53EA\u80FD\u662F fixed \u6216 content")),e.consent!==void 0&&v(e.consent,"card.consent"),{sizes:e.sizes?e.sizes.map(([a,l])=>[a,l]):null,any:d,w:f,h:c,min:t,max:o,resize:e.resize??!1,fit:e.fit??"fixed",bare:e.bare??!1,...e.consent!==void 0?{consent:{zh:e.consent.zh,en:e.consent.en}}:{}}}var Lt=(e,{type:n,options:s})=>({text:typeof e=="string",number:typeof e=="number"&&Number.isFinite(e),select:s?.includes(e),date:typeof e=="string"&&Ot.test(e),switch:typeof e=="boolean",document:typeof e=="string"})[n];function Rt(e,n){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u5B57\u6BB5","settings"));let s=[];e.forEach((o,f)=>{let c=`settings[${f}]`;u(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",c)),E(o,gt,`${c}.`),(typeof o.key!="string"||!kt.test(o.key))&&r(i("{0} \u7684 key \u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u53EA\u7528\u5B57\u6BCD\u548C\u6570\u5B57\uFF08\u5982 city\u3001startDate\uFF09",c)),s.includes(o.key)&&r(i("settings \u91CC key {0} \u5199\u4E86\u4E24\u6B21",o.key)),s.push(o.key),v(o.label,`${c}.label`),re.includes(o.type)||r(i("{0} \u7684 type \u53EA\u80FD\u662F {1}",c,re.join(", "))),o.type==="select"?((!Array.isArray(o.options)||o.options.length===0||!o.options.every(b))&&r(i("{0} \u662F select\uFF0C\u8981\u6709 options\uFF1A\u4E00\u4E32\u6587\u5B57",c)),O(o.options)&&r(i("{0} \u7684 options \u91CC {1} \u5199\u4E86\u4E24\u6B21",c,O(o.options)))):o.options!==void 0&&r(i("{0} \u4E0D\u662F select\uFF0C\u4E0D\u5199 options",c)),o.default!==void 0&&!Lt(o.default,o)&&r(i("{0} \u7684 default \u548C\u5B83\u7684 type {1} \u4E0D\u7B26",c,o.type)),o.required!==void 0&&typeof o.required!="boolean"&&r(i("{0} \u7684 required \u8981\u5199 true \u6216 false",c))});let t=n[$t];return e.length>0&&!(t?.edit==="data"&&F(t.at).every(o=>o==="script")&&F(t.at).length>0)&&r(i('\u5199\u4E86 settings\uFF0Cparts \u91CC\u5C31\u8981\u6709\u4E00\u4E2A\u540D\u4E3A settings\u3001edit \u4E3A data \u7684\u90E8\u5206\uFF0C\u5B83\u662F\u4E00\u4E2A <script type="application/json">\uFF0C\u5B58\u5361\u7247\u8BBE\u7F6E\u7684\u503C')),e.map(o=>({...o}))}function Kt(e){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","needs"));for(let n of e)typeof n=="string"&&(Et.includes(n)||n.startsWith(te)&&me.test(n.slice(te.length)))||r(i("needs \u91CC\u7684 {0} \u4E0D\u8BA4\u8BC6\uFF1A\u53EA\u8BA4 workspace\u3001tables \u548C net:<\u57DF\u540D>\uFF08\u5C0F\u5199\u7684\u4E3B\u673A\u540D\uFF0C\u4E0D\u5E26\u7AEF\u53E3\u548C\u8DEF\u5F84\uFF0C\u53EF\u4EE5\u4EE5 *. \u5F00\u5934\uFF09",typeof n=="string"?n:JSON.stringify(n)));return O(e)&&r(i("needs \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e]}function Gt(e,n){if(!e.includes("page"))return;let s=Object.entries(n).find(([,t])=>t.edit==="flow");s&&r(i("places \u91CC\u6709 page\uFF0C\u5C31\u4E0D\u80FD\u6709\u63D2\u69FD\uFF1A{0} \u7684 edit \u662F flow\uFF0C\u63D2\u69FD\u653E\u7684\u662F\u6587\u6863\u7684\u5757\uFF0C\u81EA\u5B9A\u4E49\u9875\u4E0A\u6CA1\u6709",`parts.${s[0]}`))}function Vt(e,n){if(e===void 0)return{kit:[],own:[]};(!Array.isArray(e)||!e.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","assets"));let s=e.filter(t=>!oe.has(t));for(let t of s)Tt.test(t)||r(i("assets \u91CC\u7684 {0} \u65E2\u4E0D\u662F\u5957\u4EF6\u7684\u8D44\u6E90\uFF0C\u4E5F\u4E0D\u662F\u5757\u7684\u6587\u4EF6\u5939\u91CC\u7684\u6587\u4EF6",t)),j(n,t)||r(i("assets \u5199\u4E86 {0}\uFF0C\u5757\u7684\u6587\u4EF6\u5939\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6587\u4EF6",t));return{kit:e.filter(t=>oe.has(t)),own:s}}function Ut(e,n,s){let t;try{t=JSON.parse(s)}catch(w){r(i("component.json \u4E0D\u662F JSON\uFF1A{0}",w.message))}u(t)||r(i("component.json \u5199\u7684\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61")),A.test(e)||r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A\u8303\u56F4\u548C\u540D\u5B57\u90FD\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",e));for(let w of e.split("/"))at.has(w)&&r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A{1} \u662F Windows \u7559\u7ED9\u8BBE\u5907\u7684\u540D\u5B57",e,w));if(t.id!==e&&r(i("\u6E05\u5355\u7684 id \u662F {0}\uFF0C\u548C\u5B83\u7684\u6587\u4EF6\u5939 {1} \u4E0D\u4E00\u6837",String(t.id),e)),le(t,["apiVersion"]),(!Number.isInteger(t.apiVersion)||t.apiVersion<1)&&r(i("apiVersion \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570")),t.apiVersion!==se)throw ue(i("\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u5757\u8981 apiVersion {0}\uFF0C\u8FD9\u4E00\u7248 Gallery \u53EA\u652F\u6301 {1}",t.apiVersion,se),{disabled:!0,version:b(t.version)?t.version:null});E(t,pt),le(t,["version","name","description","parts"]),b(t.version)||r(i("{0} \u8981\u5199\u6210\u6587\u5B57","version")),v(t.name,"name"),v(t.description,"description"),t.words!==void 0&&typeof t.words!="string"&&r(i("{0} \u8981\u5199\u6210\u6587\u5B57","words")),u(t.parts)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","parts"));for(let[w,$]of Object.entries(t.parts))Pt(w,$);let o=Dt(t.runtime,e),{kit:f,own:c}=Vt(t.assets,n);t.markdown!==void 0&&!jt.includes(t.markdown)&&r(i("markdown \u53EA\u80FD\u662F parts \u6216 text")),t.schema!==void 0&&!(Number.isInteger(t.schema)&&t.schema>=1)&&r(i("schema \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570"));let d=Mt(t.places);Gt(d,t.parts);let a=Ft(t.card),l=Rt(t.settings,t.parts),p=Kt(t.needs),h=ye(n,M);return h&&ge(h,M),{id:e,match:Ze(e),parts:Nt(t.parts),...o?{runtime:o}:{},...t.schema!==void 0?{schema:t.schema}:{},apiVersion:t.apiVersion,version:t.version,name:t.name,description:t.description,words:t.words??"",assets:f,markdown:t.markdown??"parts",places:d,card:a,settings:l,needs:p,files:[...new Set([...we.filter(w=>j(n,w)),...c])],template:h&&be(h),folder:n,definition:S(w=>w.update(s)),stamp:W(n,V(c))}}function Wt(e,n){try{let s=ye(n,I);return s||r(i("\u8BFB\u4E0D\u51FA component.json")),_e(s)||r(i("{0} \u4E0D\u662F UTF-8 \u7F16\u7801\uFF1A\u8BF7\u5B58\u6210 UTF-8",I)),ge(s,I),Ut(e,n,be(s))}catch(s){let t=nt(s),o=S(f=>f.update(`${W(n,V([]))} ${JSON.stringify(t)}`));return{id:e.toLowerCase(),stamp:o,problem:t,disabled:s.disabled===!0,version:s.version??null}}}var P=()=>lt(),Bt=/^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/,x=(e,n)=>[...new Set(Array.isArray(e)?e.filter(s=>typeof s=="string"&&n.test(s)):[])],Jt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n])=>A.test(n)).map(([n,s])=>[n,x(s,me)]).filter(([,n])=>n.length>0)),Zt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n,s])=>he.test(n)&&typeof s?.enabled=="boolean").map(([n,s])=>[n,s.enabled])),C=e=>{let n=Zt(e?.components?.packs);return{hidden:x(e?.components?.hidden,Bt),disabled:x(e?.components?.disabled,A),shown:x(e?.components?.shown,A),unlisted:x(e?.components?.unlisted,A),net:Jt(e?.components?.net),packs:n,packsOff:Object.keys(n).filter(s=>n[s]===!1).sort()}},B=i("gallery.json \u8BFB\u4E0D\u51FA\u6765\uFF1A\u6539\u597D\u8FD9\u4E2A\u6587\u4EF6\u540E\u518D\u8BD5"),qt=i("gallery.json \u4E0D\u662F Gallery \u7684\u6587\u4EF6");function L(e){if(e===null)return{value:null};let{value:n,ours:s,reads:t}=ft(e);return s?{value:n}:{problem:t?qt:B}}function ke(e){try{return L(_(G(e).marker,"utf8"))}catch(n){return n.code==="ENOENT"?L(null):{problem:B}}}var On=(e=P())=>C(ke(e).value),Yt=["EPERM","EACCES","EBUSY","EROFS"];async function $n(e,{id:n,hidden:s,shown:t,disabled:o,unlisted:f,net:c,pack:d,enabled:a}){let l=G(e).marker,p=await Le.readFile(l,"utf8").catch(m=>{if(m.code==="ENOENT")return null;r(B)}),{value:h,problem:w}=L(p);w&&r(w);let $=(m,Y)=>Y===void 0?m:Y?[...new Set([...m,n])]:m.filter(Ie=>Ie!==n),{hidden:Ne,disabled:je,shown:ze,unlisted:Te}=C(h),g=u(h?.components)?h.components:{},Z=$(ze,t),q=$(Te,f),z={...g,hidden:$(Ne,s),disabled:$(je,o),...Z.length>0||Object.hasOwn(g,"shown")?{shown:Z}:{},...q.length>0||Object.hasOwn(g,"unlisted")?{unlisted:q}:{}};if(d!==void 0){let m=u(g.packs)?g.packs:{};z.packs={...m,[d]:{...u(m[d])?m[d]:{},enabled:a===!0}}}if(c!==void 0){let m={...u(g.net)?g.net:{}};c.length>0?m[n]=[...new Set(c)]:delete m[n],Object.keys(m).length>0?z.net=m:delete z.net}await He(l,`${JSON.stringify({...h??ct,components:z},null,2)}
4
4
  `,{expect:p}).catch(m=>{throw Yt.includes(m.code)&&r(i("gallery.json \u5199\u4E0D\u8FDB\u53BB\uFF1A\u53EF\u80FD\u662F\u53EA\u8BFB\u7684\uFF0C\u6216\u88AB\u522B\u7684\u7A0B\u5E8F\u5360\u7740")),m})||r(i("gallery.json \u521A\u521A\u88AB\u6539\u8FC7\uFF1A\u518D\u8BD5\u4E00\u6B21"))}var Ht=e=>({...e,off:!0,disabled:!0,problem:i("\u5728\u8BBE\u7F6E\u91CC\u505C\u7528\u4E86"),stamp:S(n=>n.update(`${e.stamp} off`))}),D=C(null),Xt=({packages:e,problems:n,settings:s=D,packs:t=new Map})=>S(o=>{for(let{id:f,stamp:c}of[...e.values(),...n.values()].sort(U))o.update(`${f} ${c}
5
5
  `);o.update(`hidden ${[...s.hidden].sort().join(" ")}
6
6
  `),o.update(`shown ${[...s.shown].sort().join(" ")}
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as je}from"./chunk-5MMN3N5J.mjs";import{c as $e}from"./chunk-EKGYYOSP.mjs";import{a as p,c as S,e as N}from"./chunk-5L7RYZCL.mjs";var T=S((Tr,He)=>{"use strict";var Ve=["nodebuffer","arraybuffer","fragments"],ze=typeof Blob<"u";ze&&Ve.push("blob");He.exports={BINARY_TYPES:Ve,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ze,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((kr,re)=>{"use strict";var{EMPTY_BUFFER:Qt}=T(),xe=Buffer[Symbol.species];function Jt(t,e){if(t.length===0)return Qt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new xe(s.buffer,s.byteOffset,r):s}function Ye(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function Ke(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function es(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}re.exports={concat:Jt,mask:Ye,toArrayBuffer:es,toBuffer:Se,unmask:Ke};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?Ye(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?Ke(e,s):t.unmask(e,s)}}catch{}});var Qe=S((Cr,Ze)=>{"use strict";var Xe=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Xe]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Xe])}}};Ze.exports=ve});var G=S((Lr,st)=>{"use strict";var Z=p("zlib"),Je=X(),ts=Qe(),{kStatusCode:et}=T(),ss=Buffer[Symbol.species],rs=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new ts(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?s.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",ns),this._inflate.on("data",tt)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(rs),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Je.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",is)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Je.concat(this._deflate[P],this._deflate[k]);s&&(n=new ss(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};st.exports=be;function is(t){this[P].push(t),this[k]+=t.length}function tt(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][et]=1009,this.removeListener("data",tt),this.reset()}function ns(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[et]=1007,this[W](t)}});var $=S((Nr,oe)=>{"use strict";var{isUtf8:rt}=p("buffer"),{hasBlob:os}=T(),as=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ls(t){return os&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ls,isValidStatusCode:fs,isValidUTF8:we,tokenChars:as};if(rt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):rt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Pr,ht)=>{"use strict";var{Writable:hs}=p("stream"),it=G(),{BINARY_TYPES:cs,EMPTY_BUFFER:nt,kStatusCode:us,kWebSocket:ds}=T(),{concat:Oe,toArrayBuffer:_s,unmask:ms}=X(),{isValidStatusCode:ps,isValidUTF8:ot}=$(),ae=Buffer[Symbol.species],v=0,at=1,ft=2,lt=3,Te=4,ke=5,fe=6,Ce=class extends hs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cs[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ds]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case at:this.getPayloadLength16(e);break;case ft:this.getPayloadLength64(e);break;case lt:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[it.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=at:this._payloadLength===127?this._state=ft:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=lt:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ms(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[it.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=_s(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,nt),this.end();else{let r=e.readUInt16BE(0);if(!ps(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[us]=i,o}};ht.exports=Ce});var Be=S((Rr,dt)=>{"use strict";var{Duplex:Br}=p("stream"),{randomFillSync:gs}=p("crypto"),{types:{isUint8Array:ys}}=p("util"),ct=G(),{EMPTY_BUFFER:xs,kWebSocket:Ss,NOOP:Es}=T(),{isBlob:j,isValidStatusCode:vs}=$(),{mask:ut,toBuffer:R}=X(),b=Symbol("kByteLength"),bs=Buffer.alloc(4),le=8*1024,U,V=le,w=0,ws=1,Os=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=Es,this[Ss]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||bs,s.generateMask?s.generateMask(r):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),gs(U,0,le),V=0),r[0]=U[V++],r[1]=U[V++],r[2]=U[V++],r[3]=U[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?a=s[b]:(e=Buffer.from(e),a=e.length):(a=e.length,i=s.mask&&s.readOnly&&!o);let l=a;a>=65536?(n+=8,l=127):a>125&&(n+=2,l=126);let f=Buffer.allocUnsafe(i?a+n:n);return f[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(f[0]|=64),f[1]=l,l===126?f.writeUInt16BE(a,2):l===127&&(f[2]=f[3]=0,f.writeUIntBE(a,4,6)),s.mask?(f[1]|=128,f[n-4]=r[0],f[n-3]=r[1],f[n-2]=r[2],f[n-1]=r[3],o?[f,e]:i?(ut(e,r,f,n,a),[f]):(ut(e,r,e,0,a),[f,e])):[f,e]}close(e,s,r,i){let n;if(e===void 0)n=xs;else{if(typeof e!="number"||!vs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(s);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof s=="string")n.write(s,2);else if(ys(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ct.extensionName],n=s.binary?2:1,o=s.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):j(e)?(a=e.size,l=!1):(e=R(e),a=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let f={[b]:a,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,f,r]):this.getBlobData(e,this._compress,f,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,f,r]):this.dispatch(e,this._compress,f,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=Os,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,a,i);return}this._bufferedBytes-=r[b];let o=R(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(Ts,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ct.extensionName];this._bufferedBytes+=r[b],this._state=ws,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};dt.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function Ts(t,e,s){Pe(t,e,s),t.onerror(e)}});var vt=S((Ur,Et)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),_t=Symbol("kCode"),mt=Symbol("kData"),pt=Symbol("kError"),gt=Symbol("kMessage"),yt=Symbol("kReason"),z=Symbol("kTarget"),xt=Symbol("kType"),St=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[xt]=e}get target(){return this[z]}get type(){return this[xt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[_t]=s.code===void 0?0:s.code,this[yt]=s.reason===void 0?"":s.reason,this[St]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[_t]}get reason(){return this[yt]}get wasClean(){return this[St]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,s={}){super(e),this[pt]=s.error===void 0?null:s.error,this[gt]=s.message===void 0?"":s.message}get error(){return this[pt]}get message(){return this[gt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[mt]=s.data===void 0?null:s.data}get data(){return this[mt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var ks={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let a=new J("message",{data:o?n:n.toString()});a[z]=this,he(e,this,a)};else if(t==="close")r=function(n,o){let a=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[z]=this,he(e,this,a)};else if(t==="error")r=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};Et.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:ks,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ce=S((Ir,bt)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Cs(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,a,l=-1,f=-1,h=-1,c=0;for(;c<t.length;c++)if(f=t.charCodeAt(c),o===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(c!==0&&(f===32||f===9))h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);f===44?(O(e,g,s),s=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(f===32||f===9)h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(l,h),!0),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=h=-1}else if(f===61&&l!==-1&&h===-1)a=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[f]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(ee[f]===1)l===-1&&(l=c);else if(f===34&&l!==-1)n=!1,h=c;else if(f===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(l!==-1&&(f===32||f===9))h===-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,a,g),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),a=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||f===32||f===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,s):(a===void 0?O(s,_,!0):r?O(s,a,_.replace(/\\/g,"")):O(s,a,_),O(e,o,s)),e}function Ls(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bt.exports={format:Ls,parse:Cs}});var me=S((Mr,It)=>{"use strict";var Ns=p("events"),Ps=p("https"),Bs=p("http"),Tt=p("net"),Rs=p("tls"),{randomBytes:Us,createHash:Is}=p("crypto"),{Duplex:Dr,Readable:Ar}=p("stream"),{URL:Ue}=p("url"),B=G(),Ds=Le(),As=Be(),{isBlob:Ms}=$(),{BINARY_TYPES:wt,CLOSE_TIMEOUT:Fs,EMPTY_BUFFER:ue,GUID:Ws,kForOnEventAttribute:Ie,kListener:qs,kStatusCode:Gs,kWebSocket:y,NOOP:kt}=T(),{EventTarget:{addEventListener:$s,removeEventListener:js}}=vt(),{format:Vs,parse:zs}=ce(),{toBuffer:Hs}=X(),Ct=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],Ys=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Ns{constructor(e,s,r){super(),this._binaryType=wt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?!r||r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]):s=[s]),Lt(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){wt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Ds({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new As(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Zs),i.on("drain",Qs),i.on("error",Js),i.on("message",er),i.on("ping",tr),i.on("pong",sr),n.onerror=rr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Bt),e.on("data",_e),e.on("end",Rt),e.on("error",Ut),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Pt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ue,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ue,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[qs];return null},set(e){for(let s of this.listeners(t))if(s[Ie]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=$s;d.prototype.removeEventListener=js;It.exports=d;function Lt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Fs,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let f=o?443:80,h=Us(16).toString("base64"),c=o?Ps.request:Bs.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?Xs:Ks),i.defaultPort=i.defaultPort||f,i.port=n.port||f,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Vs({[B.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!Ys.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[x,M]of Object.entries(u))r.headers[x.toLowerCase()]=M}else if(t.listenerCount("redirect")===0){let u=a?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Ct]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,M=u.statusCode;if(x&&i.followRedirects&&M>=300&&M<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}Lt(t,Y,s,r)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,M)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Is("sha1").update(h+Ws).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=zs(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,M,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ks(t){return t.path=t.socketPath,Tt.connect(t)}function Xs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Tt.isIP(t.host)?"":t.host),Rs.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Ct]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ae(t,e,s){if(e){let r=Ms(e)?e.size:Hs(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Zs(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",_e),process.nextTick(Nt,s._socket),t===1005?s.close():s.close(t,e))}function Qs(){let t=this[y];t.isPaused||t._socket.resume()}function Js(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Nt,e._socket),e.close(t[Gs])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ot(){this[y].emitClose()}function er(t,e){this[y].emit("message",t,e)}function tr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,kt),e.emit("ping",t)}function sr(t){this[y].emit("pong",t)}function Nt(t){t.resume()}function rr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Pt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Pt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Bt(){let t=this[y];if(this.removeListener("close",Bt),this.removeListener("data",_e),this.removeListener("end",Rt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ot),t._receiver.on("finish",Ot))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Rt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Ut(){let t=this[y];this.removeListener("error",Ut),this.on("error",kt),t&&(t._readyState=d.CLOSING,this.destroy())}});var Ft=S((Wr,Mt)=>{"use strict";var Fr=me(),{Duplex:ir}=p("stream");function Dt(t){t.emit("close")}function nr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function At(t){this.removeListener("error",At),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function or(t,e){let s=!0,r=new ir({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Dt,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Dt,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",nr),r.on("error",At),r}Mt.exports=or});var Me=S((qr,Wt)=>{"use strict";var{tokenChars:ar}=$();function fr(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&ar[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=t.slice(s,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Wt.exports={parse:fr}});var Ht=S(($r,zt)=>{"use strict";var lr=p("events"),pe=p("http"),{Duplex:Gr}=p("stream"),{createHash:hr}=p("crypto"),qt=ce(),D=G(),cr=Me(),ur=me(),{CLOSE_TIMEOUT:dr,GUID:_r,kWebSocket:mr}=T(),pr=/^[+/0-9A-Za-z]{22}==$/,Gt=0,$t=1,Vt=2,Fe=class extends lr{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ur,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=gr(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Gt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Vt){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==$t)if(this._state=$t,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",jt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){A(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){A(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!pr.test(n)){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let l=e.headers["sec-websocket-protocol"],f=new Set;if(l!==void 0)try{f=cr.parse(l)}catch{A(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=qt.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{A(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return se(s,m||401,u,x);this.completeUpgrade(c,n,f,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,f,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[mr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gt)return se(n,503);let f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hr("sha1").update(s+_r).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(f.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=qt.format({[D.extensionName]:[c]});f.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",f,i),n.write(f.concat(`\r
2
+ import{a as je}from"./chunk-YEY3RSFQ.mjs";import{c as $e}from"./chunk-W7XHE4CT.mjs";import{a as p,c as S,e as N}from"./chunk-5L7RYZCL.mjs";var T=S((Tr,He)=>{"use strict";var Ve=["nodebuffer","arraybuffer","fragments"],ze=typeof Blob<"u";ze&&Ve.push("blob");He.exports={BINARY_TYPES:Ve,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ze,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((kr,re)=>{"use strict";var{EMPTY_BUFFER:Qt}=T(),xe=Buffer[Symbol.species];function Jt(t,e){if(t.length===0)return Qt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new xe(s.buffer,s.byteOffset,r):s}function Ye(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function Ke(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function es(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}re.exports={concat:Jt,mask:Ye,toArrayBuffer:es,toBuffer:Se,unmask:Ke};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?Ye(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?Ke(e,s):t.unmask(e,s)}}catch{}});var Qe=S((Cr,Ze)=>{"use strict";var Xe=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Xe]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Xe])}}};Ze.exports=ve});var G=S((Lr,st)=>{"use strict";var Z=p("zlib"),Je=X(),ts=Qe(),{kStatusCode:et}=T(),ss=Buffer[Symbol.species],rs=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new ts(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?s.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",ns),this._inflate.on("data",tt)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(rs),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Je.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",is)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Je.concat(this._deflate[P],this._deflate[k]);s&&(n=new ss(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};st.exports=be;function is(t){this[P].push(t),this[k]+=t.length}function tt(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][et]=1009,this.removeListener("data",tt),this.reset()}function ns(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[et]=1007,this[W](t)}});var $=S((Nr,oe)=>{"use strict";var{isUtf8:rt}=p("buffer"),{hasBlob:os}=T(),as=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ls(t){return os&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ls,isValidStatusCode:fs,isValidUTF8:we,tokenChars:as};if(rt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):rt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Pr,ht)=>{"use strict";var{Writable:hs}=p("stream"),it=G(),{BINARY_TYPES:cs,EMPTY_BUFFER:nt,kStatusCode:us,kWebSocket:ds}=T(),{concat:Oe,toArrayBuffer:_s,unmask:ms}=X(),{isValidStatusCode:ps,isValidUTF8:ot}=$(),ae=Buffer[Symbol.species],v=0,at=1,ft=2,lt=3,Te=4,ke=5,fe=6,Ce=class extends hs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cs[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ds]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case at:this.getPayloadLength16(e);break;case ft:this.getPayloadLength64(e);break;case lt:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[it.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=at:this._payloadLength===127?this._state=ft:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=lt:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ms(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[it.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=_s(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,nt),this.end();else{let r=e.readUInt16BE(0);if(!ps(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[us]=i,o}};ht.exports=Ce});var Be=S((Rr,dt)=>{"use strict";var{Duplex:Br}=p("stream"),{randomFillSync:gs}=p("crypto"),{types:{isUint8Array:ys}}=p("util"),ct=G(),{EMPTY_BUFFER:xs,kWebSocket:Ss,NOOP:Es}=T(),{isBlob:j,isValidStatusCode:vs}=$(),{mask:ut,toBuffer:R}=X(),b=Symbol("kByteLength"),bs=Buffer.alloc(4),le=8*1024,U,V=le,w=0,ws=1,Os=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=Es,this[Ss]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||bs,s.generateMask?s.generateMask(r):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),gs(U,0,le),V=0),r[0]=U[V++],r[1]=U[V++],r[2]=U[V++],r[3]=U[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?a=s[b]:(e=Buffer.from(e),a=e.length):(a=e.length,i=s.mask&&s.readOnly&&!o);let l=a;a>=65536?(n+=8,l=127):a>125&&(n+=2,l=126);let f=Buffer.allocUnsafe(i?a+n:n);return f[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(f[0]|=64),f[1]=l,l===126?f.writeUInt16BE(a,2):l===127&&(f[2]=f[3]=0,f.writeUIntBE(a,4,6)),s.mask?(f[1]|=128,f[n-4]=r[0],f[n-3]=r[1],f[n-2]=r[2],f[n-1]=r[3],o?[f,e]:i?(ut(e,r,f,n,a),[f]):(ut(e,r,e,0,a),[f,e])):[f,e]}close(e,s,r,i){let n;if(e===void 0)n=xs;else{if(typeof e!="number"||!vs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(s);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof s=="string")n.write(s,2);else if(ys(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ct.extensionName],n=s.binary?2:1,o=s.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):j(e)?(a=e.size,l=!1):(e=R(e),a=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let f={[b]:a,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,f,r]):this.getBlobData(e,this._compress,f,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,f,r]):this.dispatch(e,this._compress,f,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=Os,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,a,i);return}this._bufferedBytes-=r[b];let o=R(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(Ts,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ct.extensionName];this._bufferedBytes+=r[b],this._state=ws,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};dt.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function Ts(t,e,s){Pe(t,e,s),t.onerror(e)}});var vt=S((Ur,Et)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),_t=Symbol("kCode"),mt=Symbol("kData"),pt=Symbol("kError"),gt=Symbol("kMessage"),yt=Symbol("kReason"),z=Symbol("kTarget"),xt=Symbol("kType"),St=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[xt]=e}get target(){return this[z]}get type(){return this[xt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[_t]=s.code===void 0?0:s.code,this[yt]=s.reason===void 0?"":s.reason,this[St]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[_t]}get reason(){return this[yt]}get wasClean(){return this[St]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,s={}){super(e),this[pt]=s.error===void 0?null:s.error,this[gt]=s.message===void 0?"":s.message}get error(){return this[pt]}get message(){return this[gt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[mt]=s.data===void 0?null:s.data}get data(){return this[mt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var ks={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let a=new J("message",{data:o?n:n.toString()});a[z]=this,he(e,this,a)};else if(t==="close")r=function(n,o){let a=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[z]=this,he(e,this,a)};else if(t==="error")r=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};Et.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:ks,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ce=S((Ir,bt)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Cs(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,a,l=-1,f=-1,h=-1,c=0;for(;c<t.length;c++)if(f=t.charCodeAt(c),o===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(c!==0&&(f===32||f===9))h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);f===44?(O(e,g,s),s=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(f===32||f===9)h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(l,h),!0),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=h=-1}else if(f===61&&l!==-1&&h===-1)a=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[f]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(ee[f]===1)l===-1&&(l=c);else if(f===34&&l!==-1)n=!1,h=c;else if(f===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(l!==-1&&(f===32||f===9))h===-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,a,g),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),a=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||f===32||f===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,s):(a===void 0?O(s,_,!0):r?O(s,a,_.replace(/\\/g,"")):O(s,a,_),O(e,o,s)),e}function Ls(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bt.exports={format:Ls,parse:Cs}});var me=S((Mr,It)=>{"use strict";var Ns=p("events"),Ps=p("https"),Bs=p("http"),Tt=p("net"),Rs=p("tls"),{randomBytes:Us,createHash:Is}=p("crypto"),{Duplex:Dr,Readable:Ar}=p("stream"),{URL:Ue}=p("url"),B=G(),Ds=Le(),As=Be(),{isBlob:Ms}=$(),{BINARY_TYPES:wt,CLOSE_TIMEOUT:Fs,EMPTY_BUFFER:ue,GUID:Ws,kForOnEventAttribute:Ie,kListener:qs,kStatusCode:Gs,kWebSocket:y,NOOP:kt}=T(),{EventTarget:{addEventListener:$s,removeEventListener:js}}=vt(),{format:Vs,parse:zs}=ce(),{toBuffer:Hs}=X(),Ct=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],Ys=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Ns{constructor(e,s,r){super(),this._binaryType=wt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?!r||r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]):s=[s]),Lt(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){wt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Ds({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new As(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Zs),i.on("drain",Qs),i.on("error",Js),i.on("message",er),i.on("ping",tr),i.on("pong",sr),n.onerror=rr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Bt),e.on("data",_e),e.on("end",Rt),e.on("error",Ut),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Pt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ue,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ue,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[qs];return null},set(e){for(let s of this.listeners(t))if(s[Ie]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=$s;d.prototype.removeEventListener=js;It.exports=d;function Lt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Fs,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let f=o?443:80,h=Us(16).toString("base64"),c=o?Ps.request:Bs.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?Xs:Ks),i.defaultPort=i.defaultPort||f,i.port=n.port||f,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Vs({[B.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!Ys.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[x,M]of Object.entries(u))r.headers[x.toLowerCase()]=M}else if(t.listenerCount("redirect")===0){let u=a?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Ct]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,M=u.statusCode;if(x&&i.followRedirects&&M>=300&&M<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}Lt(t,Y,s,r)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,M)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Is("sha1").update(h+Ws).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=zs(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,M,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ks(t){return t.path=t.socketPath,Tt.connect(t)}function Xs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Tt.isIP(t.host)?"":t.host),Rs.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Ct]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ae(t,e,s){if(e){let r=Ms(e)?e.size:Hs(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Zs(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",_e),process.nextTick(Nt,s._socket),t===1005?s.close():s.close(t,e))}function Qs(){let t=this[y];t.isPaused||t._socket.resume()}function Js(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Nt,e._socket),e.close(t[Gs])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ot(){this[y].emitClose()}function er(t,e){this[y].emit("message",t,e)}function tr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,kt),e.emit("ping",t)}function sr(t){this[y].emit("pong",t)}function Nt(t){t.resume()}function rr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Pt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Pt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Bt(){let t=this[y];if(this.removeListener("close",Bt),this.removeListener("data",_e),this.removeListener("end",Rt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ot),t._receiver.on("finish",Ot))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Rt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Ut(){let t=this[y];this.removeListener("error",Ut),this.on("error",kt),t&&(t._readyState=d.CLOSING,this.destroy())}});var Ft=S((Wr,Mt)=>{"use strict";var Fr=me(),{Duplex:ir}=p("stream");function Dt(t){t.emit("close")}function nr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function At(t){this.removeListener("error",At),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function or(t,e){let s=!0,r=new ir({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Dt,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Dt,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",nr),r.on("error",At),r}Mt.exports=or});var Me=S((qr,Wt)=>{"use strict";var{tokenChars:ar}=$();function fr(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&ar[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=t.slice(s,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Wt.exports={parse:fr}});var Ht=S(($r,zt)=>{"use strict";var lr=p("events"),pe=p("http"),{Duplex:Gr}=p("stream"),{createHash:hr}=p("crypto"),qt=ce(),D=G(),cr=Me(),ur=me(),{CLOSE_TIMEOUT:dr,GUID:_r,kWebSocket:mr}=T(),pr=/^[+/0-9A-Za-z]{22}==$/,Gt=0,$t=1,Vt=2,Fe=class extends lr{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ur,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=gr(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Gt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Vt){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==$t)if(this._state=$t,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",jt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){A(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){A(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!pr.test(n)){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let l=e.headers["sec-websocket-protocol"],f=new Set;if(l!==void 0)try{f=cr.parse(l)}catch{A(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=qt.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{A(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return se(s,m||401,u,x);this.completeUpgrade(c,n,f,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,f,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[mr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gt)return se(n,503);let f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hr("sha1").update(s+_r).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(f.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=qt.format({[D.extensionName]:[c]});f.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",f,i),n.write(f.concat(`\r
3
3
  `).join(`\r
4
4
  `)),n.removeListener("error",jt),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),a(h,i)}};zt.exports=Fe;function gr(t,e){for(let s of Object.keys(e))t.on(s,e[s]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function te(t){t._state=Vt,t.emit("close")}function jt(){this.destroy()}function se(t,e,s,r){s=s||pe.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
5
5
  `+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as v,b as j}from"./chunk-2RKIHJI2.mjs";import l from"node:fs";import p from"node:path";import V from"node:zlib";import{escapeAttribute as $,escapeMarkup as _}from"../browser/shared/escape.mjs";import{componentOf as b,instancesOf as L,partOf as O}from"../browser/shared/components/index.mjs";import{ICON_COLOR_VALUES as I,TAB_ICON as N,glyphOf as B,iconKind as u,iconUrl as T,iconValueOf as S,tabIconValue as R}from"../browser/shared/emoji/icon-value.mjs";import{lineIconSvg as z}from"../browser/shared/emoji/line-icons.mjs";import{mediaTypeOf as A,mediaUrl as J}from"../browser/shared/media.mjs";import{emojiDataDirectory as P,reportsDirectory as E}from"../browser/shared/paths.mjs";import{slugPattern as G}from"../browser/shared/reports.mjs";import{documentDirectory as D}from"../browser/shared/workspace.mjs";var g=P,k=String.fromCodePoint(65039),C=null,x=null;function H(){return C??={positions:JSON.parse(l.readFileSync(p.join(g,"positions.json"),"utf8")),index:JSON.parse(l.readFileSync(p.join(g,"twemoji-index.json"),"utf8")),svg:V.gunzipSync(l.readFileSync(p.join(g,"twemoji-svg.bin")))},C}function F(e){let{positions:t,index:r,svg:o}=H(),n=[e,e.replaceAll(k,""),`${e}${k}`].find(c=>t[c]),i=n&&r[t[n][0]];return i?o.subarray(i[0],i[0]+i[1]):null}function U(e){let t=F(e);return t?`data:image/svg+xml;base64,${t.toString("base64")}`:null}function ue(e){return d(""),[...x.keys()].filter(t=>t.startsWith(`${e}/`)).map(t=>t.slice(e.length+1))}function d(e,t="currentColor"){x??=new Map(JSON.parse(l.readFileSync(p.join(g,"icons.json"),"utf8")).icons.flatMap(([,n,i,c,a])=>[[`mingcute/${n}`,c],[`tabler/${i}`,a]].filter(([,s])=>s)));let r=B(e),o=r&&x.get(`${r.set}/${r.name}`);return o?o.split("#COLOR").join(t).replace("<svg ",'<svg aria-hidden="true" '):null}function K(e){let[t,r]=I[B(e)?.color]??I.gray,o=d(e);return o&&o.replace(/<svg\b[^>]*>/,n=>`${n.replace(/ aria-hidden="true"/,"").replace(/^<svg /,'<svg xmlns="http://www.w3.org/2000/svg" ').replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"(?=.* xmlns=)/,"")}<style>svg{color:${t}}@media (prefers-color-scheme:dark){svg{color:${r}}}</style>`)}var W=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><text x="18" y="18" text-anchor="middle" dominant-baseline="central" font-size="30" font-family="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif">${_(e)}</text></svg>`;function q({value:e,slug:t=null,tab:r=!1,reportsDirectory:o=E}){let n=z(e,{color:"#000",tab:r});if(n)return{type:"image/svg+xml",body:Buffer.from(n)};let i=u(e);if(i==="emoji")return{type:"image/svg+xml",body:F(e)??Buffer.from(W(e))};if(i==="glyph"){let a=r?K(e):d(e,"#000");return a&&{type:"image/svg+xml",body:Buffer.from(a)}}if(i!=="image"||!t||!G.test(t))return null;let c=p.join(D(t,o),e);return l.existsSync(c)?{type:A(e),body:l.readFileSync(c)}:null}var M=/(<div\b[^>]*\bclass="doc-icon"[^>]*>)([\s\S]*?)(<\/div>)/g;function de(e,{slug:t,mode:r="export",reportsDirectory:o=E}){return te(X(e,{mode:r}).replace(M,(n,i,c,a)=>{let s=S(n),y=u(s);if(!y)return n;let f=null;if(y==="emoji"){let m=U(s);f=m&&`<img alt="${$(s)}" src="${m}">`}else if(y==="glyph")f=d(s);else if(r==="preview")f=`<img src="${J("asset",t,s)}" alt="">`;else{let m=p.join(D(t,o),s),w=l.existsSync(m)?l.readFileSync(m):null;f=w&&`<img src="data:${A(s)};base64,${w.toString("base64")}" alt="">`}let h=r==="preview"?i.replace(/>$/,` data-ge-icon="${$(s)}">`):i;return f?`${h}${f}${a}`:`${h}${c}${a}`}),ee(Z(e),{slug:t,mode:r,reportsDirectory:o}))}var ye=e=>[...e.matchAll(M)].flatMap(t=>{let r=u(S(t[0]))==="image"?/<img\b[^>]*\bsrc="/.exec(t[2]):null;return r?[t.index+t[1].length+r.index]:[]}),Q=/<button\b[^>]*\bdata-tab-icon="([^"]*)"[^>]*>/g;function X(e,{mode:t="export"}={}){return e.replace(Q,(r,o)=>{if(u(o)!=="emoji"||r.includes(N))return r;let n=t==="preview"?T(o):U(o);if(!n)return r;let i=`${N}: ${R(n)}`;return/\sstyle="/.test(r)?r.replace(/\sstyle="([^"]*)"/,(c,a)=>` style="${a.replace(/;?\s*$/,"; ")}${i}"`):r.replace(/>$/,` style="${i}">`)})}function Y(e){let t=O(e,b("page").header)[0];return{all:L(e,b("icon")),own:t?O(t,b("icon").match):[]}}function Z(e){let[t]=Y(v(e)).own;return t?S(j(e,t)):null}function ee(e,{slug:t,mode:r,reportsDirectory:o}){if(!e)return null;if(r==="preview")return T(e,t,{tab:!0});let n=q({value:e,slug:t,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${Buffer.from(n.body).toString("base64")}`}var te=(e,t)=>t&&/<\/head>/i.test(e)&&!e.includes("data-doc-tab-icon")?e.replace(/<\/head>/i,()=>` <link rel="icon" href="${$(t)}" data-doc-tab-icon>
2
+ import{a as v,b as j}from"./chunk-HYMEEXKN.mjs";import l from"node:fs";import p from"node:path";import V from"node:zlib";import{escapeAttribute as $,escapeMarkup as _}from"../browser/shared/escape.mjs";import{componentOf as b,instancesOf as L,partOf as O}from"../browser/shared/components/index.mjs";import{ICON_COLOR_VALUES as I,TAB_ICON as N,glyphOf as B,iconKind as u,iconUrl as T,iconValueOf as S,tabIconValue as R}from"../browser/shared/emoji/icon-value.mjs";import{lineIconSvg as z}from"../browser/shared/emoji/line-icons.mjs";import{mediaTypeOf as A,mediaUrl as J}from"../browser/shared/media.mjs";import{emojiDataDirectory as P,reportsDirectory as E}from"../browser/shared/paths.mjs";import{slugPattern as G}from"../browser/shared/reports.mjs";import{documentDirectory as D}from"../browser/shared/workspace.mjs";var g=P,k=String.fromCodePoint(65039),C=null,x=null;function H(){return C??={positions:JSON.parse(l.readFileSync(p.join(g,"positions.json"),"utf8")),index:JSON.parse(l.readFileSync(p.join(g,"twemoji-index.json"),"utf8")),svg:V.gunzipSync(l.readFileSync(p.join(g,"twemoji-svg.bin")))},C}function F(e){let{positions:t,index:r,svg:o}=H(),n=[e,e.replaceAll(k,""),`${e}${k}`].find(c=>t[c]),i=n&&r[t[n][0]];return i?o.subarray(i[0],i[0]+i[1]):null}function U(e){let t=F(e);return t?`data:image/svg+xml;base64,${t.toString("base64")}`:null}function ue(e){return d(""),[...x.keys()].filter(t=>t.startsWith(`${e}/`)).map(t=>t.slice(e.length+1))}function d(e,t="currentColor"){x??=new Map(JSON.parse(l.readFileSync(p.join(g,"icons.json"),"utf8")).icons.flatMap(([,n,i,c,a])=>[[`mingcute/${n}`,c],[`tabler/${i}`,a]].filter(([,s])=>s)));let r=B(e),o=r&&x.get(`${r.set}/${r.name}`);return o?o.split("#COLOR").join(t).replace("<svg ",'<svg aria-hidden="true" '):null}function K(e){let[t,r]=I[B(e)?.color]??I.gray,o=d(e);return o&&o.replace(/<svg\b[^>]*>/,n=>`${n.replace(/ aria-hidden="true"/,"").replace(/^<svg /,'<svg xmlns="http://www.w3.org/2000/svg" ').replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"(?=.* xmlns=)/,"")}<style>svg{color:${t}}@media (prefers-color-scheme:dark){svg{color:${r}}}</style>`)}var W=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><text x="18" y="18" text-anchor="middle" dominant-baseline="central" font-size="30" font-family="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif">${_(e)}</text></svg>`;function q({value:e,slug:t=null,tab:r=!1,reportsDirectory:o=E}){let n=z(e,{color:"#000",tab:r});if(n)return{type:"image/svg+xml",body:Buffer.from(n)};let i=u(e);if(i==="emoji")return{type:"image/svg+xml",body:F(e)??Buffer.from(W(e))};if(i==="glyph"){let a=r?K(e):d(e,"#000");return a&&{type:"image/svg+xml",body:Buffer.from(a)}}if(i!=="image"||!t||!G.test(t))return null;let c=p.join(D(t,o),e);return l.existsSync(c)?{type:A(e),body:l.readFileSync(c)}:null}var M=/(<div\b[^>]*\bclass="doc-icon"[^>]*>)([\s\S]*?)(<\/div>)/g;function de(e,{slug:t,mode:r="export",reportsDirectory:o=E}){return te(X(e,{mode:r}).replace(M,(n,i,c,a)=>{let s=S(n),y=u(s);if(!y)return n;let f=null;if(y==="emoji"){let m=U(s);f=m&&`<img alt="${$(s)}" src="${m}">`}else if(y==="glyph")f=d(s);else if(r==="preview")f=`<img src="${J("asset",t,s)}" alt="">`;else{let m=p.join(D(t,o),s),w=l.existsSync(m)?l.readFileSync(m):null;f=w&&`<img src="data:${A(s)};base64,${w.toString("base64")}" alt="">`}let h=r==="preview"?i.replace(/>$/,` data-ge-icon="${$(s)}">`):i;return f?`${h}${f}${a}`:`${h}${c}${a}`}),ee(Z(e),{slug:t,mode:r,reportsDirectory:o}))}var ye=e=>[...e.matchAll(M)].flatMap(t=>{let r=u(S(t[0]))==="image"?/<img\b[^>]*\bsrc="/.exec(t[2]):null;return r?[t.index+t[1].length+r.index]:[]}),Q=/<button\b[^>]*\bdata-tab-icon="([^"]*)"[^>]*>/g;function X(e,{mode:t="export"}={}){return e.replace(Q,(r,o)=>{if(u(o)!=="emoji"||r.includes(N))return r;let n=t==="preview"?T(o):U(o);if(!n)return r;let i=`${N}: ${R(n)}`;return/\sstyle="/.test(r)?r.replace(/\sstyle="([^"]*)"/,(c,a)=>` style="${a.replace(/;?\s*$/,"; ")}${i}"`):r.replace(/>$/,` style="${i}">`)})}function Y(e){let t=O(e,b("page").header)[0];return{all:L(e,b("icon")),own:t?O(t,b("icon").match):[]}}function Z(e){let[t]=Y(v(e)).own;return t?S(j(e,t)):null}function ee(e,{slug:t,mode:r,reportsDirectory:o}){if(!e)return null;if(r==="preview")return T(e,t,{tab:!0});let n=q({value:e,slug:t,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${Buffer.from(n.body).toString("base64")}`}var te=(e,t)=>t&&/<\/head>/i.test(e)&&!e.includes("data-doc-tab-icon")?e.replace(/<\/head>/i,()=>` <link rel="icon" href="${$(t)}" data-doc-tab-icon>
3
3
  </head>`):e;export{U as a,ue as b,d as c,q as d,de as e,ye as f,Y as g,Z as h};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as d,e as L}from"./chunk-N3DSBH5S.mjs";L();import{instanceSlots as x,isInstance as A}from"../browser/shared/components/index.mjs";import{mayHoldOldNames as I,newAttributeName as S,newAttributeValue as b,newScriptNames as N,newStyleNames as j}from"../browser/shared/old-names.mjs";var T=/^data-(?:report|doc)-(?:kit|vendor)$/;function E(o){if(typeof o!="string"||!I(o))return o;let O=d(o,{sourceCodeLocationInfo:!0}),c=[],l=(t,e,s)=>{o.slice(t,e)!==s&&c.push({start:t,end:e,text:s})};function g(t){let e=t.sourceCodeLocation?.attrs??{};for(let{name:n,value:y}of t.attrs){let r=e[n];if(!r)continue;let i=o.slice(r.startOffset,r.endOffset),f=i.indexOf("="),v=f<0?i:i.slice(0,f),m=f<0?"":i.slice(f),C=/^on/i.test(n)||/^\s*javascript:/i.test(y)?N(m):b(n,m,t.tagName);l(r.startOffset,r.endOffset,S(v)+C)}if(t.attrs.some(({name:n})=>T.test(n))||!["style","script"].includes(t.tagName))return;let s=t.childNodes?.[0]?.sourceCodeLocation;if(!s)return;let w=(t.attrs.find(({name:n})=>n==="type")?.value??"").trim().toLowerCase();if(t.tagName==="script"&&/json/.test(w))return;let p=o.slice(s.startOffset,s.endOffset);l(s.startOffset,s.endOffset,t.tagName==="style"?j(p):N(p))}let u=t=>{for(let e of t.childNodes??[]){if(A(e)){x(e).forEach(u);continue}e.tagName&&g(e),u(e.tagName==="template"&&e.content?e.content:e)}};if(u(O),!c.length)return o;c.sort((t,e)=>e.start-t.start);let a=o;for(let{start:t,end:e,text:s}of c)a=a.slice(0,t)+s+a.slice(e);return a}export{E as a};
2
+ import{b as d,e as L}from"./chunk-A55HN5OK.mjs";L();import{instanceSlots as x,isInstance as A}from"../browser/shared/components/index.mjs";import{mayHoldOldNames as I,newAttributeName as S,newAttributeValue as b,newScriptNames as N,newStyleNames as j}from"../browser/shared/old-names.mjs";var T=/^data-(?:report|doc)-(?:kit|vendor)$/;function E(o){if(typeof o!="string"||!I(o))return o;let O=d(o,{sourceCodeLocationInfo:!0}),c=[],l=(t,e,s)=>{o.slice(t,e)!==s&&c.push({start:t,end:e,text:s})};function g(t){let e=t.sourceCodeLocation?.attrs??{};for(let{name:n,value:y}of t.attrs){let r=e[n];if(!r)continue;let i=o.slice(r.startOffset,r.endOffset),f=i.indexOf("="),v=f<0?i:i.slice(0,f),m=f<0?"":i.slice(f),C=/^on/i.test(n)||/^\s*javascript:/i.test(y)?N(m):b(n,m,t.tagName);l(r.startOffset,r.endOffset,S(v)+C)}if(t.attrs.some(({name:n})=>T.test(n))||!["style","script"].includes(t.tagName))return;let s=t.childNodes?.[0]?.sourceCodeLocation;if(!s)return;let w=(t.attrs.find(({name:n})=>n==="type")?.value??"").trim().toLowerCase();if(t.tagName==="script"&&/json/.test(w))return;let p=o.slice(s.startOffset,s.endOffset);l(s.startOffset,s.endOffset,t.tagName==="style"?j(p):N(p))}let u=t=>{for(let e of t.childNodes??[]){if(A(e)){x(e).forEach(u);continue}e.tagName&&g(e),u(e.tagName==="template"&&e.content?e.content:e)}};if(u(O),!c.length)return o;c.sort((t,e)=>e.start-t.start);let a=o;for(let{start:t,end:e,text:s}of c)a=a.slice(0,t)+s+a.slice(e);return a}export{E as a};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{g as i,h as g}from"./chunk-SQ3FQCCN.mjs";import{b as m,f as u}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{spawn as P}from"node:child_process";import h from"node:fs/promises";import R from"node:path";import{projectRoot as v,release as G,reportsDirectory as S}from"../browser/shared/paths.mjs";import{answerOf as k,findPreviewServer as x,portIsFree as y,readAnnouncement as b}from"../browser/shared/preview-server.mjs";import{serviceLocation as E}from"../browser/shared/service-location.mjs";import{registerQuietly as A}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as C}from"../browser/shared/workspace.mjs";var n=C(),I=a=>new Promise(t=>setTimeout(t,a));async function V(a){await A(S);let{positional:t,values:l}=u({values:["--port"],argv:a});if(t.length>0)throw new m(`gallery serve takes no arguments: ${t[0]}`);let o=l.has("--port")?Number(l.get("--port")):null;if(o!==null&&!(Number.isInteger(o)&&o>0&&o<65536))throw new m(`--port takes a port number: ${l.get("--port")}`);let s=await b(),f=s?await k(s,1e4):"no";f!=="no"&&(console.error(`The shared Gallery server runs already: ${i(s.port)} (pid ${s.pid}${f==="busy"?", not answering now":""}). gallery stop stops it; one server serves a Gallery data directory.`),process.exit(1));let r=null;if(o!==null)await y(o)||(console.error(`Port ${o} is taken: name another (--port), or leave it out for the first free one.`),process.exit(1)),r=o;else{for(let e of await g())if(await y(e)){r=e;break}r===null&&(console.error("No port from 4317 is free: name one (--port <n>)."),process.exit(1))}if(G){process.env.GALLERY_SERVER_KIND="cli";let{startProductionServer:e}=await import("./chunk-JYK5WJPM.mjs");await e({reportsDirectory:n,port:r,kind:"cli"}),await h.writeFile(E().lastPortFile,`${r}
3
+ `).catch(()=>{}),console.log(`Gallery serves ${n} at ${i(r)} (Chrome or Edge). Ctrl+C stops it.`);return}let{writeSharedAssets:$}=await import("./chunk-CRDG6EF2.mjs");await $();let c=P(process.execPath,[R.join(v,"node_modules","vite","bin","vite.js"),"--host","127.0.0.1","--port",String(r),"--strictPort"],{cwd:v,env:{...process.env,GALLERY_WORKSPACE:n,GALLERY_SERVER_KIND:"cli"},stdio:"inherit"});for(let e of["SIGINT","SIGTERM"])process.on(e,()=>c.kill(e));let w=new Promise(e=>c.once("exit",(d,p)=>e(d??(p?1:0))));for(;;){let e=await Promise.race([w.then(p=>({code:p})),I(300).then(()=>null)]);if(e&&process.exit(e.code),(await x({answering:!0,timeout:2e3}))?.pid===c.pid)break}await h.writeFile(E().lastPortFile,`${r}
4
+ `).catch(()=>{}),console.log(`Gallery serves ${n} at ${i(r)} (Chrome or Edge). Ctrl+C stops it.`),process.exit(await w)}export{V as run};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a,b}from"./chunk-NLDF35P5.mjs";import"./chunk-L55NOXBE.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as w}from"./chunk-JEUK3ZO7.mjs";import{a as te}from"./chunk-QXVNUASA.mjs";import{d as F,e as W}from"./chunk-2GKGEVMR.mjs";import{a as H,b as L,d as G,e as $,f as E,g as R,h as U,i as q,j as Y,o as V,r as X,s as Q,t as Z}from"./chunk-LE44MD3O.mjs";import{a as P,b as d,f as ee}from"./chunk-4OZWXZE5.mjs";import{i as K}from"./chunk-SAHS56QM.mjs";import{f as S,j as C,s as _,t as B,v as j}from"./chunk-VG5JEIUQ.mjs";import v from"node:fs";import N from"node:path";import{blocksHidden as $e}from"../browser/editor/components/registry.mjs";import{inLanguage as be,told as ve}from"../browser/shared/i18n/index.mjs";import{PACK_ID as xe}from"../browser/shared/pack-manifest.mjs";import{readKeys as Se,writeKey as se}from"../browser/shared/net-keys.mjs";import{HOST as Ne,netHostsOf as Oe}from"../browser/shared/net-policy.mjs";import{PACKAGE_ID as je,SLOT as Ee}from"../browser/shared/components/installed.mjs";import{DEVICE_NAMES as Ae,layoutOf as A,PACKAGE_MANIFEST as ie,shallowPackages as le}from"../browser/shared/workspace.mjs";var fe=(e,t,{script:o,flow:n,data:a,page:s})=>`{
2
+ import{a as w}from"./chunk-JEUK3ZO7.mjs";import{a as te}from"./chunk-6QWQXHAV.mjs";import{d as F,e as W}from"./chunk-7UZUQQ7Q.mjs";import{a as H,b as L,d as G,e as $,f as E,g as R,h as U,i as q,j as Y,o as V,r as X,s as Q,t as Z}from"./chunk-KLQP46Y3.mjs";import{a as P,b as d,f as ee}from"./chunk-4OZWXZE5.mjs";import{i as K}from"./chunk-HX4DLE3J.mjs";import{f as S,j as C,s as _,t as B,v as j}from"./chunk-TKWEX4FD.mjs";import v from"node:fs";import N from"node:path";import{blocksHidden as $e}from"../browser/editor/components/registry.mjs";import{inLanguage as be,told as ve}from"../browser/shared/i18n/index.mjs";import{PACK_ID as xe}from"../browser/shared/pack-manifest.mjs";import{readKeys as Se,writeKey as se}from"../browser/shared/net-keys.mjs";import{HOST as Ne,netHostsOf as Oe}from"../browser/shared/net-policy.mjs";import{PACKAGE_ID as je,SLOT as Ee}from"../browser/shared/components/installed.mjs";import{DEVICE_NAMES as Ae,layoutOf as A,PACKAGE_MANIFEST as ie,shallowPackages as le}from"../browser/shared/workspace.mjs";var fe=(e,t,{script:o,flow:n,data:a,page:s})=>`{
3
3
  "id": "${e}",
4
4
  "apiVersion": 1,
5
5
  "version": "0.1.0",
@@ -167,4 +167,4 @@ DocKit.component({
167
167
  });
168
168
  `;function ne(e,{script:t=!1,flow:o=!1,data:n=!1,page:a=!1}={}){let s=e.split("/")[1],l={script:t||n,flow:o,data:n,page:a};return{"component.json":fe(e,s,l),"template.html":oe(e,"\u6807\u9898","\u5199\u5728\u8FD9\u91CC\u3002",{blocks:o&&["<p></p>"],json:n&&'{"items":[]}'}),"example.html":oe(e,"\u4E00\u4E2A\u4F8B\u5B50","\u8FD9\u91CC\u5199\u8FD9\u4E2A\u5757\u5728\u4E00\u4EFD\u6587\u6863\u91CC\u7684\u6837\u5B50\u3002",{blocks:o&&we,json:n&&'{"items":[{"text":"\u7B2C\u4E00\u6761"},{"text":"\u7B2C\u4E8C\u6761"}]}'}),"writing.md":ue(e,s,l),"style.css":ge(e,l),...l.script?{"kit.js":n?ye(e):ke(e)}:{}}}var x="local";function re(e){let t=e.includes("/")?e:`${x}/${e}`;if(!je.test(t))throw new d(`Not a block's id: ${e} (<scope>/<name>, each in lowercase letters, digits and hyphens; a <name> alone is ${x}/<name>).`);let o=t.split("/").find(n=>Ae.has(n));if(o)throw new d(`Not a block's id: ${e} (Windows keeps ${o} for a device).`);return t}function Ie(e,t){let o=re(t),n=t.includes("/")?null:$(t);if(!n)return o;let a=S(e);return a.packages.has(o)||a.problems.has(o)||v.existsSync(M(e,o))?o:n.id}var M=(e,t)=>N.join(A(e).components,...t.split("/")),u=e=>e.pack===H?e.name:e.id,z=()=>G().map(u).join(", "),ce=({name:e,file:t})=>`${w(t)} is one level too shallow, and no catalog reads it: a custom block is components/<scope>/<name>/, so move it to components/${x}/${e}/`;function Ce(e,t){let o=le(e).find(({name:s})=>s===t.split("/")[1]),n=E(t)&&$(t);if(n)return`No block ${t} in ${w(A(e).components)}: it is one of Gallery's own, which gallery block add ${u(n)} puts in.`;let a=t.startsWith(`${x}/`)?$(t.slice(x.length+1)):null;return o?ce(o):`No block ${t} in ${w(A(e).components)}: gallery block list says which there are${a?`; Gallery has a block of that name, ${a.id}`:""}.`}function Ge(e,t,{script:o,flow:n,data:a,page:s,recipe:l}){let r=t.split("/")[0],m=$(t);if(E(t))throw new d(`The scope ${r}/ is kept for Gallery's own blocks: give yours another (${x}/<name>, or a <name> alone)${m?`; gallery block add ${u(m)} puts Gallery's in, and gallery block new <id> --recipe ${u(m)} starts one of yours from it`:""}.`);if(R(e).packs?.[r])throw new d(`The scope ${r}/ is the pack ${r}'s, which gallery block pack install put in (installing it again would not keep a block of yours there): give yours another (${x}/<name>, or a <name> alone).`);let h=l===void 0?null:$(l);if(l!==void 0&&!h)throw new d(`No block of Gallery's own is called ${l}: ${z()||"none"}.`);let f=M(e,t);if(v.existsSync(f)||S(e).problems.has(t)){let c=!v.existsSync(N.join(f,ie));console.error(c?`A folder is there with no component.json: ${w(f)}: move it, or give this block another name.`:`Block already exists: ${w(f)}: gallery block show ${t} says what it is; give a new one another name.`),process.exit(1)}let i=h?V(h,t):ne(t,{script:o,flow:n,data:a,page:s});try{v.mkdirSync(f,{recursive:!0});for(let c of L(Object.keys(i)))v.mkdirSync(N.dirname(N.join(f,c)),{recursive:!0}),v.writeFileSync(N.join(f,c),i[c])}catch(c){if(!c.code)throw c;console.error(`Cannot write ${w(f)} (${c.code}).`),process.exit(1)}if(console.log(`Created ${w(f)}: ${Object.keys(i).join(", ")}`),h){console.log(`Made from Gallery's ${h.id} ${h.version}, every word that named it naming ${t}: change its name, words and description in component.json first (two blocks of one name read alike in "/"), and in the same files what is still ${h.name}'s: preview.svg (the picture the menu shows beside the description, still ${h.name}'s drawing: draw yours or delete it), writing.md (how to write it, still about ${h.name}) and example.html (the instance check runs and show prints, still ${h.name}'s words), then what you came for (references/building-blocks.md has every field and the rules), and run gallery block check ${t}, which passes as it stands now.`);return}let p=o||a;console.log(`Next: say in component.json what it is (its name, description and parts), write template.html, what ${s?"a custom page's \u6DFB\u52A0\u81EA\u5B9A\u4E49\u5757 puts on it":'"/" puts in a document'}, and example.html, an instance as a writer would fill it, then writing.md and style.css${p?" and kit.js":""} (references/building-blocks.md has every field and the rules${n?", and Slots what its slot body holds":""}${s?"; references/pages-and-data.md a card's size and settings and what it reads":""}${p?"; references/block-script.md its script and how it writes back":""}), and run gallery block check ${t}, which passes as it stands now.`),a&&console.log("It keeps a list of lines (the part items, a script of JSON on one line, as context.editJSON writes it): kit.js reads it with context.readJSON and writes it with context.editJSON, from a field (DocKit.input) and a button, hidden where nothing is written; example() adds a line by the function the field calls, and works on template.html's empty instance. Rename the part, the fields of its JSON and the controls for what the block keeps."),s?console.log(`It is a custom page's card (places ["page"], a card of two sizes): gallery page add <slug> ${t} puts one on a page, then gallery page try <slug> <card id> <gesture> tries a reader's gesture on it${a?' (--type .component-field "words" --then Enter)':""}; for a document too, put "document" in places.`):a&&console.log(`In a document: write the element as example.html does, then gallery block try <slug> --type .component-field "words" --then Enter tries the field (the part and the class are the scaffold's: rename them with the block).`)}function Pe(e,t){let o=$(t);if(!o)throw new d(`No block of Gallery's own is called ${t}: ${z()||"none"} (gallery block list says each).`);let n;try{n=q(e,o)}catch(s){if(s.code!=="changed")throw s;console.error(`${w(s.folder)} was changed after gallery block add put it there (or another hand put it there), so it is not replaced: to keep those changes, make a block of your own from Gallery's with gallery block new <id> --recipe ${u(o)} and move them into it; to take Gallery's ${o.version}, delete the folder and run gallery block add ${u(o)} again.`),process.exit(1)}let a=o.places.includes("document")?`a document can write it now (gallery block show ${o.id} says how)`:"custom pages can place it now";n.did==="same"?console.log(`${o.id} ${o.version} is in already, as Gallery ships it: ${w(n.folder)}`):n.did==="updated"?console.log(`Updated ${o.id} from ${n.from??"an older version"} to ${o.version}: ${w(n.folder)}`):console.log(`Added ${o.id} ${o.version}: ${w(n.folder)}`),n.did!=="same"&&console.log(`It is Gallery's, as it ships: no check or try is needed, and ${a}. Change nothing in its folder, or gallery block add will not update it again: for a block like it of your own, gallery block new <id> --recipe ${u(o)}.`)}var k=({zh:e,en:t})=>e===t?e:`${e} / ${t}`;function Ke(e){if(B(e))return null;let t=_(e);return t?C("en",t):"it has no template.html"}var Je={disabled:"disabled by the user: its instances show as they stand, no script and no style"},I=e=>e?.length?` \u8981\u7528\uFF1A${e.join(", ")}`:"";function ae(e,{id:t,name:o,version:n,description:a,state:s,needs:l},r){console.log(`${t} ${k(o)}`);let h=(e.settings.packsOff??[]).includes(t.split("/")[0])?`available; its pack ${t.split("/")[0]} is switched off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868, so no menu or library offers it, and a document can still write it`:r==="document"&&s==="hidden"?"available; not in the document's menus, by the user's switch, and a document can still write it":"available";console.log(` \u7248\u672C\uFF1A${n}\uFF08${h}\uFF09`),console.log(` \u8BF4\u660E\uFF1A${k(a)}`),I(l)&&console.log(I(l));let f=r==="document"&&Ke(e.packages.get(t));f&&console.log(` \u6A21\u677F\uFF1Athe menus cannot insert it, and a document can still write it: ${f}`)}function Te(e){let t=S(e),o=j(t),n=o.filter(({reason:i})=>i),a=o.filter(({reason:i})=>!i),s=a.filter(({state:i})=>i!=="disabled"),l=s.filter(({places:i})=>i.includes("document")),r=s.filter(({places:i})=>i.includes("page")),m=le(e),h=G().map(i=>({block:i,state:U(e,i)})).filter(({block:i,state:p})=>!p.added||p.behind||p.changed&&Y(i.version,p.version)),f=$e(t.settings.hidden);if(console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`),a.length+n.length+m.length===0)console.log("No custom blocks yet. A document is written with Gallery's blocks and whole blocks; gallery block add <name> puts one of Gallery's own in (below), and gallery block new <id> starts one when the user wants a block to use again.");else{console.log(l.length?`\u6587\u6863\u91CC\u53EF\u7528 (in documents: ${l.length}; gallery block show <id> says how to write each):`:"\u6587\u6863\u91CC\u53EF\u7528 (in documents): none now.");for(let p of l)ae(t,p,"document");console.log(r.length?`\u81EA\u5B9A\u4E49\u9875\u53EF\u7528 (on custom pages: ${r.length}):`:"\u81EA\u5B9A\u4E49\u9875\u53EF\u7528 (on custom pages): none now.");for(let p of r)p.places.includes("document")?console.log(`${p.id} ${k(p.name)} (above: in documents too)`):ae(t,p,"page");let i=a.filter(({state:p})=>p==="disabled");i.length+n.length+m.length>0&&console.log("Not to use now:");for(let{id:p,name:c,version:y,state:O}of i)console.log(`${p} ${k(c)} ${y} ${Je[O]}`);for(let{id:p,reason:c,version:y}of n)console.log(`${p}${y?` ${y}`:""} does not load: ${c.en}`);for(let p of m)console.log(ce(p))}h.length&&console.log("Gallery's own blocks, to add as they are (no check or try needed):");for(let{block:i,state:p}of h){let c=i.places.map(y=>y==="document"?"documents":"custom pages").join(" and ");console.log(`${i.id} ${k(i.title)} ${i.version} (${c})`),console.log(` \u8BF4\u660E\uFF1A${k(i.description)}`),p.changed?console.log(` the workspace's copy (${p.version??"no version"}) was changed after it was added, so it is not updated: to take Gallery's ${i.version}, delete ${w(M(e,i.id))} and run gallery block add ${u(i)} (to keep the changes, gallery block new <id> --recipe ${u(i)} and move them into it)`):console.log(p.added?` gallery block add ${u(i)} (the workspace has ${p.version??"an older one"}: this updates it)`:` gallery block add ${u(i)}`)}f.length&&console.log(`Built-in blocks the user took out of the document's menus (a document can still write them): ${f.join(", ")}`)}var De=(e,{at:t,edit:o,optional:n,min:a,max:s})=>{let l=[n?"optional":"",a!==void 0?`at least ${a}`:"",s!==void 0?`at most ${s}`:""].filter(Boolean),r=o==="flow"?`${Ee}="${e}"`:t;return` ${e} ${r} ${o==="flow"?"flow (blocks of the document: write any block in it)":o}${l.length?` (${l.join(", ")})`:""}`};function de(e,t,o){console.log(`${t} ${k(e.name)}`),console.log(` \u7248\u672C\uFF1A${e.version}\uFF08${o}\uFF09`),console.log(` \u8BF4\u660E\uFF1A${k(e.description)}`),console.log(` \u7528\u5728\uFF1A${e.places.map(l=>l==="document"?"documents":"custom pages").join(", ")}`),I(e.needs)&&console.log(I(e.needs)),console.log(` ${w(e.folder)}`);let n=Object.entries(e.parts);console.log(n.length?"Parts (edit text: the user types there; flow: blocks of the document; none, or data: the component's):":"No parts.");for(let[l,r]of n)console.log(De(l,r));let a=K(e,"writing.md")?.trimEnd();console.log(a?`How to write it (writing.md):
169
169
  ${a}`:"How to write it: the block has no writing.md.");let s=K(e,"example.html")?.trimEnd();console.log(s?`The example (example.html):
170
- ${s}`:"The example: the block has no example.html.")}function Me(e,t){let o=S(e),n=o.problems.get(t),a=o.packages.get(t)??(n?.off?n:void 0);if(!a){let r=n?.problem,m=!r&&E(t)?$(t):null;if(m)return Fe(m);console.error(r?`${t} does not load: ${C("en",r)}`:Ce(e,t)),process.exit(1)}let{state:s}=j(o).find(r=>r.id===t),l={normal:"available",hidden:"available; not in the document's menus, by the user's switch",disabled:"disabled by the user"}[s]??s;de(a,t,l),console.log("In a document: write the element as the example does, straight in the page or a section, with no data-block-id, which the export gives it.")}async function ze(e,t,o,{remove:n}){let a=Se(e);if(t===void 0){let s=[...new Set(j(S(e)).flatMap(({needs:m})=>Oe(m??[])))],l=Object.keys(a).sort();console.log(l.length?`Keys kept (.gallery/keys.json), by host: ${l.join(", ")}.`:"No key kept (.gallery/keys.json holds none).");let r=s.filter(m=>!l.includes(m)).sort();r.length&&console.log(`Hosts the workspace's blocks reach with no key: ${r.join(", ")} (a key is needed only where a block's address names {key}).`);return}if(!Ne.test(t))throw new d(`Not a host a block's needs can name: ${t} (a lowercase name, no scheme, port or path; *. before it for the names under it).`);if(n){if(o!==void 0)throw new d("gallery block key <host> --remove takes no key.");return t in a?(await se(e,t,null),console.log(`Took away the key for ${t}. A block's address that names {key} on it is refused (code "key") until one is kept again.`)):console.log(`No key kept for ${t}: nothing to take away.`)}if(o===void 0)return console.log(t in a?`A key is kept for ${t} (never printed): an address on it that names {key} is fetched with it.`:`No key kept for ${t}: gallery block key ${t} <key> keeps one.`);if(!o.trim()||/[\r\n]/.test(o))throw new d("A key is one line of characters, not empty.");await se(e,t,o),console.log(`Kept the key for ${t} in ${w(A(e).keys)}, which no page, export or cache holds: Gallery writes it where a block's address on ${t} names {key}, as it fetches for the block. Never write the key into a block's files or a page: they are shown and exported.`)}function Fe(e){let t=JSON.parse(v.readFileSync(N.join(e.folder,ie),"utf8"));de({name:e.title,description:e.description,version:e.version,places:e.places,needs:t.needs,folder:e.folder,parts:t.parts??{}},e.id,"Gallery's own, not in this workspace yet");let o=e.places.includes("document")?", and a document writes it as the example above does, straight in the page or a section, with no data-block-id, which the export gives it":`, and gallery page add <slug> ${u(e)} puts a card of it on a custom page`;console.log(`Not in this workspace yet: gallery block add ${u(e)} puts it in as it ships (no check, no try)${o}.`)}var he=e=>be("en",()=>ve(e))??e.message,J=(e,t)=>t.length?[` ${e}: ${t.join(", ")}`]:[];function We(e,t){let o;try{o=X(e,te(t))}catch(a){if(!a.code)throw a;console.error(`Not installed: ${he(a)}`),process.exit(1)}let n=o.added.length+o.updated.length+o.same.length+o.kept.length;o.from===null?console.log(`Installed the pack ${o.id} ${o.version} (${k(o.name)}), ${n} block${n===1?"":"s"}: ${w(o.folder)}`):o.did==="updated"?console.log(`Updated the pack ${o.id} from ${o.from??"an older version"} to ${o.version}: ${w(o.folder)}`):console.log(`The pack ${o.id} ${o.version} is in already, as installed: ${w(o.folder)}`);for(let a of[...J("added",o.added),...o.did==="updated"?J("updated",o.updated):[],...J("taken out (not in this version)",o.removed)])console.log(a);o.kept.length&&console.log(` kept as they are, changed since they were installed: ${o.kept.join(", ")} (to take this version's, delete the block's folder and install the pack again)`),o.ownKept&&console.log(" its pack.json was changed since it was installed, and is kept as it is"),console.log(`Its blocks are offered in "/" and \u6DFB\u52A0\u81EA\u5B9A\u4E49\u5757 while its switch in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 is on (gallery block pack list says each pack's); gallery block list says each block.`)}function D(e){let t=Z(e);console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`);let o={default:"the default pack, where a block made with no pack named goes",official:"Gallery's own",installed:"a pack installed",own:"the workspace's own blocks, no pack.json"};for(let n of t){let a=[n.version?`${n.id} ${n.version}`:n.id,o[n.kind],n.enabled?"on":"off",`${n.blocks} block${n.blocks===1?"":"s"}`,...n.author?[`by ${n.author}`]:[]];console.log(`${k(n.name)} (${a.join(", ")})`),n.description&&console.log(` \u8BF4\u660E\uFF1A${k(n.description)}`),n.problem&&console.log(` its pack.json does not read: ${n.problem.en}`),n.changed.length&&console.log(` changed since it was installed: ${n.changed.join(", ")}${n.newer?` (Gallery's is ${n.newer}, not put over them)`:""}`)}t.every(({kind:n})=>n==="default")&&console.log("No other block packs: gallery block pack install <folder|zip> installs one.")}function _e(e,t){if(!xe.test(t))throw new d(`Not a pack's id: ${t} (lowercase letters, digits and hyphens: gallery block pack list says each).`);let o;try{o=Q(e,t)}catch(n){if(!n.code)throw n;console.error(`Not removed: ${he(n)}`),process.exit(1)}console.log(`Removed the pack ${o.id}${o.version?` ${o.version}`:""} (${o.blocks.length} block${o.blocks.length===1?"":"s"}): what documents and pages hold of its blocks stays, shown as blocks that are not there.`)}var T={install:We,list:D,remove:_e};function Be(e,t,o){if(!t)throw new d("Say what to do with packs: install <folder|zip>, list, remove <pack>.");if(!Object.hasOwn(T,t))throw new d(`No such pack command: ${t} (install, list, remove).`);if(T[t]===D){if(o.length)throw new d("gallery block pack list takes nothing else.");return D(e)}if(o.length!==1)throw new d(t==="install"?"gallery block pack install takes one folder or zip: gallery block pack install <folder|zip>.":"gallery block pack remove takes one pack's id: gallery block pack remove <pack>.");return T[t](e,o[0])}var g={new:(e,t,o)=>Ge(e,t,o),add:Pe,list:Te,show:Me,check:async(e,t,{documents:o})=>(await import("./chunk-FXQBADMN.mjs")).checkCommand(e,t,{documents:o}),try:async(e,t)=>(await import("./chunk-JI6T3A4Y.mjs")).tryCommand(e,t),key:ze,pack:Be},He=["--press","--drag","--to","--key","--type","--select","--then","--steps"],Le={"--key":"--key takes a selector and a key: --key <selector> <key> (Enter, Space, ArrowRight, a letter, Shift+Tab).","--type":"--type takes a selector and the words to type: --type <selector> <words> (quoted when they hold a blank).","--select":"--select takes a selector and an option: --select <selector> <value> (the option's value or its words)."};function pe(e){let t=e.indexOf("--"),o=new Set,n={};for(let[a,s]of Object.entries(Le)){let l=(t===-1?e:e.slice(0,t)).findIndex(h=>h===a||h.startsWith(`${a}=`));if(l===-1)continue;let r=l+(e[l].includes("=")?1:2),m=e[r];if(m===void 0||r===t||P(m)||o.has(r))throw new d(s);o.add(r),n[a]=m}return{argv:e.filter((a,s)=>!o.has(s)),seconds:n}}function pt(e){let{argv:t,seconds:o}=pe(e);return{argv:t,key:o["--key"]??null}}async function mt(e,{workspace:t}){try{return await Re(e,t)}catch(o){let n=e.find(a=>!P(a));throw o instanceof d&&n==="try"&&(o.synopsis=F),o instanceof d&&n==="pack"&&(o.synopsis=W),o}}async function Re(e,t){let{argv:o,seconds:n}=pe(e),{positional:a,options:s,values:l}=ee({options:["--script","--flow","--data","--page","--keep","--documents","--replace","--remove"],values:[...He,"--recipe"],argv:o}),r=l.get("--recipe"),m=new Map([...l].filter(([b])=>b!=="--recipe")),[h,f,...i]=a,p=Object.keys(g).join(", ");if(!h)throw new d(`Say what to do: ${p}.`);if(!Object.hasOwn(g,h))throw new d(`No such block command: ${h} (${p}).`);let c=g[h];for(let b of["--script","--flow","--data","--page"])if(s.has(b)&&c!==g.new)throw new d(`${b} goes with new, not ${h}.`);if(s.has("--documents")&&c!==g.check)throw new d(`--documents goes with check, not ${h}.`);if(s.has("--remove")&&c!==g.key)throw new d(`--remove goes with key, not ${h}.`);if(r!==void 0&&c!==g.new)throw new d(`--recipe goes with new, not ${h}.`);let y=["--script","--flow","--data","--page"].filter(b=>s.has(b));if(r!==void 0&&y.length)throw new d(`--recipe makes a block of what Gallery's ${r} holds: ${y[0]} goes with a new block of none.${y[0]==="--page"&&$(r)?.places.includes("page")?` ${r} already is a card for a custom page (its places hold page): leave --page out.`:""}`);if(s.has("--flow")&&s.has("--data"))throw new d("--flow and --data do not go together: --flow is a slot for blocks of the document's own, --data a list of lines a reader keeps in the block's JSON. Make the one you need with new, and add the other by hand.");if(s.has("--flow")&&s.has("--page"))throw new d("--flow and --page do not go together: a custom page renders no document's blocks, so a block for a page has no slot.");let O=[...m.keys(),...Object.keys(n).filter(b=>!m.has(b)),...s.has("--keep")?["--keep"]:[],...s.has("--replace")?["--replace"]:[]];if(c===g.try)return c(t,{named:a.slice(1),values:m,seconds:n,keep:s.has("--keep"),replace:s.has("--replace")});if(O.length)throw new d(`${O[0]} goes with try, not ${h}.`);if(c===g.list){if(f!==void 0)throw new d(`gallery block ${h} takes nothing else.`);return c(t)}if(c===g.pack)return c(t,f,i);if(c===g.key){if(i.length>1)throw new d("gallery block key takes a host and its key: gallery block key <host> <key>.");return c(t,f,i[0],{remove:s.has("--remove")})}if(c===g.add){if(f===void 0||i.length>0)throw new d(`gallery block add takes one name of Gallery's own blocks: ${z()}.`);return c(t,f)}if(f===void 0||i.length>0)throw new d(`gallery block ${h} takes one id.`);let me=c===g.show||c===g.check?Ie(t,f):re(f);return c(t,me,{script:s.has("--script"),flow:s.has("--flow"),data:s.has("--data"),page:s.has("--page"),documents:s.has("--documents"),recipe:r})}export{re as a,Ie as b,M as c,u as d,ce as e,Ce as f,He as g,pe as h,pt as i,mt as j};
170
+ ${s}`:"The example: the block has no example.html.")}function Me(e,t){let o=S(e),n=o.problems.get(t),a=o.packages.get(t)??(n?.off?n:void 0);if(!a){let r=n?.problem,m=!r&&E(t)?$(t):null;if(m)return Fe(m);console.error(r?`${t} does not load: ${C("en",r)}`:Ce(e,t)),process.exit(1)}let{state:s}=j(o).find(r=>r.id===t),l={normal:"available",hidden:"available; not in the document's menus, by the user's switch",disabled:"disabled by the user"}[s]??s;de(a,t,l),console.log("In a document: write the element as the example does, straight in the page or a section, with no data-block-id, which the export gives it.")}async function ze(e,t,o,{remove:n}){let a=Se(e);if(t===void 0){let s=[...new Set(j(S(e)).flatMap(({needs:m})=>Oe(m??[])))],l=Object.keys(a).sort();console.log(l.length?`Keys kept (.gallery/keys.json), by host: ${l.join(", ")}.`:"No key kept (.gallery/keys.json holds none).");let r=s.filter(m=>!l.includes(m)).sort();r.length&&console.log(`Hosts the workspace's blocks reach with no key: ${r.join(", ")} (a key is needed only where a block's address names {key}).`);return}if(!Ne.test(t))throw new d(`Not a host a block's needs can name: ${t} (a lowercase name, no scheme, port or path; *. before it for the names under it).`);if(n){if(o!==void 0)throw new d("gallery block key <host> --remove takes no key.");return t in a?(await se(e,t,null),console.log(`Took away the key for ${t}. A block's address that names {key} on it is refused (code "key") until one is kept again.`)):console.log(`No key kept for ${t}: nothing to take away.`)}if(o===void 0)return console.log(t in a?`A key is kept for ${t} (never printed): an address on it that names {key} is fetched with it.`:`No key kept for ${t}: gallery block key ${t} <key> keeps one.`);if(!o.trim()||/[\r\n]/.test(o))throw new d("A key is one line of characters, not empty.");await se(e,t,o),console.log(`Kept the key for ${t} in ${w(A(e).keys)}, which no page, export or cache holds: Gallery writes it where a block's address on ${t} names {key}, as it fetches for the block. Never write the key into a block's files or a page: they are shown and exported.`)}function Fe(e){let t=JSON.parse(v.readFileSync(N.join(e.folder,ie),"utf8"));de({name:e.title,description:e.description,version:e.version,places:e.places,needs:t.needs,folder:e.folder,parts:t.parts??{}},e.id,"Gallery's own, not in this workspace yet");let o=e.places.includes("document")?", and a document writes it as the example above does, straight in the page or a section, with no data-block-id, which the export gives it":`, and gallery page add <slug> ${u(e)} puts a card of it on a custom page`;console.log(`Not in this workspace yet: gallery block add ${u(e)} puts it in as it ships (no check, no try)${o}.`)}var he=e=>be("en",()=>ve(e))??e.message,J=(e,t)=>t.length?[` ${e}: ${t.join(", ")}`]:[];function We(e,t){let o;try{o=X(e,te(t))}catch(a){if(!a.code)throw a;console.error(`Not installed: ${he(a)}`),process.exit(1)}let n=o.added.length+o.updated.length+o.same.length+o.kept.length;o.from===null?console.log(`Installed the pack ${o.id} ${o.version} (${k(o.name)}), ${n} block${n===1?"":"s"}: ${w(o.folder)}`):o.did==="updated"?console.log(`Updated the pack ${o.id} from ${o.from??"an older version"} to ${o.version}: ${w(o.folder)}`):console.log(`The pack ${o.id} ${o.version} is in already, as installed: ${w(o.folder)}`);for(let a of[...J("added",o.added),...o.did==="updated"?J("updated",o.updated):[],...J("taken out (not in this version)",o.removed)])console.log(a);o.kept.length&&console.log(` kept as they are, changed since they were installed: ${o.kept.join(", ")} (to take this version's, delete the block's folder and install the pack again)`),o.ownKept&&console.log(" its pack.json was changed since it was installed, and is kept as it is"),console.log(`Its blocks are offered in "/" and \u6DFB\u52A0\u81EA\u5B9A\u4E49\u5757 while its switch in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 is on (gallery block pack list says each pack's); gallery block list says each block.`)}function D(e){let t=Z(e);console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`);let o={default:"the default pack, where a block made with no pack named goes",official:"Gallery's own",installed:"a pack installed",own:"the workspace's own blocks, no pack.json"};for(let n of t){let a=[n.version?`${n.id} ${n.version}`:n.id,o[n.kind],n.enabled?"on":"off",`${n.blocks} block${n.blocks===1?"":"s"}`,...n.author?[`by ${n.author}`]:[]];console.log(`${k(n.name)} (${a.join(", ")})`),n.description&&console.log(` \u8BF4\u660E\uFF1A${k(n.description)}`),n.problem&&console.log(` its pack.json does not read: ${n.problem.en}`),n.changed.length&&console.log(` changed since it was installed: ${n.changed.join(", ")}${n.newer?` (Gallery's is ${n.newer}, not put over them)`:""}`)}t.every(({kind:n})=>n==="default")&&console.log("No other block packs: gallery block pack install <folder|zip> installs one.")}function _e(e,t){if(!xe.test(t))throw new d(`Not a pack's id: ${t} (lowercase letters, digits and hyphens: gallery block pack list says each).`);let o;try{o=Q(e,t)}catch(n){if(!n.code)throw n;console.error(`Not removed: ${he(n)}`),process.exit(1)}console.log(`Removed the pack ${o.id}${o.version?` ${o.version}`:""} (${o.blocks.length} block${o.blocks.length===1?"":"s"}): what documents and pages hold of its blocks stays, shown as blocks that are not there.`)}var T={install:We,list:D,remove:_e};function Be(e,t,o){if(!t)throw new d("Say what to do with packs: install <folder|zip>, list, remove <pack>.");if(!Object.hasOwn(T,t))throw new d(`No such pack command: ${t} (install, list, remove).`);if(T[t]===D){if(o.length)throw new d("gallery block pack list takes nothing else.");return D(e)}if(o.length!==1)throw new d(t==="install"?"gallery block pack install takes one folder or zip: gallery block pack install <folder|zip>.":"gallery block pack remove takes one pack's id: gallery block pack remove <pack>.");return T[t](e,o[0])}var g={new:(e,t,o)=>Ge(e,t,o),add:Pe,list:Te,show:Me,check:async(e,t,{documents:o})=>(await import("./chunk-LCB6MARS.mjs")).checkCommand(e,t,{documents:o}),try:async(e,t)=>(await import("./chunk-ZMHUDYLV.mjs")).tryCommand(e,t),key:ze,pack:Be},He=["--press","--drag","--to","--key","--type","--select","--then","--steps"],Le={"--key":"--key takes a selector and a key: --key <selector> <key> (Enter, Space, ArrowRight, a letter, Shift+Tab).","--type":"--type takes a selector and the words to type: --type <selector> <words> (quoted when they hold a blank).","--select":"--select takes a selector and an option: --select <selector> <value> (the option's value or its words)."};function pe(e){let t=e.indexOf("--"),o=new Set,n={};for(let[a,s]of Object.entries(Le)){let l=(t===-1?e:e.slice(0,t)).findIndex(h=>h===a||h.startsWith(`${a}=`));if(l===-1)continue;let r=l+(e[l].includes("=")?1:2),m=e[r];if(m===void 0||r===t||P(m)||o.has(r))throw new d(s);o.add(r),n[a]=m}return{argv:e.filter((a,s)=>!o.has(s)),seconds:n}}function pt(e){let{argv:t,seconds:o}=pe(e);return{argv:t,key:o["--key"]??null}}async function mt(e,{workspace:t}){try{return await Re(e,t)}catch(o){let n=e.find(a=>!P(a));throw o instanceof d&&n==="try"&&(o.synopsis=F),o instanceof d&&n==="pack"&&(o.synopsis=W),o}}async function Re(e,t){let{argv:o,seconds:n}=pe(e),{positional:a,options:s,values:l}=ee({options:["--script","--flow","--data","--page","--keep","--documents","--replace","--remove"],values:[...He,"--recipe"],argv:o}),r=l.get("--recipe"),m=new Map([...l].filter(([b])=>b!=="--recipe")),[h,f,...i]=a,p=Object.keys(g).join(", ");if(!h)throw new d(`Say what to do: ${p}.`);if(!Object.hasOwn(g,h))throw new d(`No such block command: ${h} (${p}).`);let c=g[h];for(let b of["--script","--flow","--data","--page"])if(s.has(b)&&c!==g.new)throw new d(`${b} goes with new, not ${h}.`);if(s.has("--documents")&&c!==g.check)throw new d(`--documents goes with check, not ${h}.`);if(s.has("--remove")&&c!==g.key)throw new d(`--remove goes with key, not ${h}.`);if(r!==void 0&&c!==g.new)throw new d(`--recipe goes with new, not ${h}.`);let y=["--script","--flow","--data","--page"].filter(b=>s.has(b));if(r!==void 0&&y.length)throw new d(`--recipe makes a block of what Gallery's ${r} holds: ${y[0]} goes with a new block of none.${y[0]==="--page"&&$(r)?.places.includes("page")?` ${r} already is a card for a custom page (its places hold page): leave --page out.`:""}`);if(s.has("--flow")&&s.has("--data"))throw new d("--flow and --data do not go together: --flow is a slot for blocks of the document's own, --data a list of lines a reader keeps in the block's JSON. Make the one you need with new, and add the other by hand.");if(s.has("--flow")&&s.has("--page"))throw new d("--flow and --page do not go together: a custom page renders no document's blocks, so a block for a page has no slot.");let O=[...m.keys(),...Object.keys(n).filter(b=>!m.has(b)),...s.has("--keep")?["--keep"]:[],...s.has("--replace")?["--replace"]:[]];if(c===g.try)return c(t,{named:a.slice(1),values:m,seconds:n,keep:s.has("--keep"),replace:s.has("--replace")});if(O.length)throw new d(`${O[0]} goes with try, not ${h}.`);if(c===g.list){if(f!==void 0)throw new d(`gallery block ${h} takes nothing else.`);return c(t)}if(c===g.pack)return c(t,f,i);if(c===g.key){if(i.length>1)throw new d("gallery block key takes a host and its key: gallery block key <host> <key>.");return c(t,f,i[0],{remove:s.has("--remove")})}if(c===g.add){if(f===void 0||i.length>0)throw new d(`gallery block add takes one name of Gallery's own blocks: ${z()}.`);return c(t,f)}if(f===void 0||i.length>0)throw new d(`gallery block ${h} takes one id.`);let me=c===g.show||c===g.check?Ie(t,f):re(f);return c(t,me,{script:s.has("--script"),flow:s.has("--flow"),data:s.has("--data"),page:s.has("--page"),documents:s.has("--documents"),recipe:r})}export{re as a,Ie as b,M as c,u as d,ce as e,Ce as f,He as g,pe as h,pt as i,mt as j};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b}from"./chunk-CCSGFCLZ.mjs";import"./chunk-5MMN3N5J.mjs";import"./chunk-EKGYYOSP.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_KEEP_ALIVE_INTERVAL_MS,b as NodeWebSocketTransport};
2
+ import{a,b}from"./chunk-U3SSPL4K.mjs";import"./chunk-YEY3RSFQ.mjs";import"./chunk-W7XHE4CT.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_KEEP_ALIVE_INTERVAL_MS,b as NodeWebSocketTransport};