@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,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{c as ge,d as q,e as Xt}from"./chunk-KNZJT4ET.mjs";import"./chunk-5L7RYZCL.mjs";function Z(a,t,e,s){e.assert.notStrictEqual(a,t,s)}function Qt(a,t){t.assert.strictEqual(typeof a,"string")}function At(a){return Object.keys(a)}function v(a){return!!a&&!!a.then&&typeof a.then=="function"}function at(a){let e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),s=/\.*[\][<>]/g,n=e.shift();if(!n)throw new Error(`No command found in: ${a}`);let o={cmd:n.replace(s,""),demanded:[],optional:[]};return e.forEach((r,h)=>{let c=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&h===e.length-1&&(c=!0),/^\[/.test(r)?o.optional.push({cmd:r.replace(s,"").split("|"),variadic:c}):o.demanded.push({cmd:r.replace(s,"").split("|"),variadic:c})}),o}var ts=["first","second","third","fourth","fifth","sixth"];function _(a,t,e){function s(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[at(`cmd ${a}`),t,e]}try{let n=0,[o,r,h]=s(),c=[].slice.call(r);for(;c.length&&c[c.length-1]===void 0;)c.pop();let u=h||c.length;if(u<o.demanded.length)throw new q(`Not enough arguments provided. Expected ${o.demanded.length} but received ${c.length}.`);let d=o.demanded.length+o.optional.length;if(u>d)throw new q(`Too many arguments provided. Expected max ${d} but received ${u}.`);o.demanded.forEach(l=>{let f=c.shift(),p=be(f);l.cmd.filter(g=>g===p||g==="*").length===0&&_e(p,l.cmd,n),n+=1}),o.optional.forEach(l=>{if(c.length===0)return;let f=c.shift(),p=be(f);l.cmd.filter(g=>g===p||g==="*").length===0&&_e(p,l.cmd,n),n+=1})}catch(n){console.warn(n.stack)}}function be(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function _e(a,t,e){throw new q(`Invalid ${ts[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}var Wt=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,s=!0,n=!1){if(_("<array|function> [boolean] [boolean] [boolean]",[t,e,s],arguments.length),Array.isArray(t)){for(let o=0;o<t.length;o++){if(typeof t[o]!="function")throw Error("middleware must be a function");let r=t[o];r.applyBeforeValidation=e,r.global=s}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let o=t;o.applyBeforeValidation=e,o.global=s,o.mutates=n,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let s=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(n=>{let o=[...s[e]||[],e];return n.option?!o.includes(n.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function Oe(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function dt(a,t,e,s){return e.reduce((n,o)=>{if(o.applyBeforeValidation!==s)return n;if(o.mutates){if(o.applied)return n;o.applied=!0}if(v(n))return n.then(r=>Promise.all([r,o(r,t)])).then(([r,h])=>Object.assign(r,h));{let r=o(n,t);return v(r)?r.then(h=>Object.assign(n,h)):Object.assign(n,r)}},a)}function pt(a,t,e=s=>{throw s}){try{let s=es(a)?a():a;return v(s)?s.then(n=>t(n)):t(s)}catch(s){return e(s)}}function es(a){return typeof a=="function"}var Et=/(^\*)|(^\$0)/,kt=class{constructor(t,e,s,n){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=n,this.usage=t,this.globalMiddleware=s,this.validation=e}addDirectory(t,e,s,n){n=n||{},this.requireCache.add(s);let o=this.shim.path.resolve(this.shim.path.dirname(s),t),r=this.shim.readdirSync(o,{recursive:!!n.recurse});Array.isArray(n.extensions)||(n.extensions=["js"]);let h=typeof n.visit=="function"?n.visit:c=>c;for(let c of r){let u=c.toString();if(n.exclude){let l=!1;if(typeof n.exclude=="function"?l=n.exclude(u):l=n.exclude.test(u),l)continue}if(n.include){let l=!1;if(typeof n.include=="function"?l=n.include(u):l=n.include.test(u),!l)continue}let d=!1;for(let l of n.extensions)u.endsWith(l)&&(d=!0);if(d){let l=this.shim.path.join(o,u),f=e(l),p=Object.create(null,Object.getOwnPropertyDescriptors({...f}));if(h(p,l,u)){if(this.requireCache.has(l))continue;this.requireCache.add(l),p.command||(p.command=this.shim.path.basename(l,this.shim.path.extname(l))),this.addHandler(p)}}}}addHandler(t,e,s,n,o,r){let h=[],c=Oe(o);if(n=n||(()=>{}),Array.isArray(t))if(ss(t))[t,...h]=t;else for(let u of t)this.addHandler(u);else if(ns(t)){let u=Array.isArray(t.command)||typeof t.command=="string"?t.command:null;if(u===null)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);t.aliases&&(u=[].concat(u).concat(t.aliases)),this.addHandler(u,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(we(s)){this.addHandler([t].concat(h),e,s.builder,s.handler,s.middlewares,s.deprecated);return}if(typeof t=="string"){let u=at(t);h=h.map(f=>at(f).cmd);let d=!1,l=[u.cmd].concat(h).filter(f=>Et.test(f)?(d=!0,!1):!0);l.length===0&&d&&l.push("$0"),d&&(u.cmd=l[0],h=l.slice(1),t=t.replace(Et,u.cmd)),h.forEach(f=>{this.aliasMap[f]=u.cmd}),e!==!1&&this.usage.command(t,e,d,h,r),this.handlers[u.cmd]={original:t,description:e,handler:n,builder:s||{},middlewares:c,deprecated:r,demanded:u.demanded,optional:u.optional},d&&(this.defaultCommand=this.handlers[u.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,s,n,o,r){let h=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,c=e.getInternalMethods().getContext(),u=c.commands.slice(),d=!t;t&&(c.commands.push(t),c.fullCommands.push(h.original));let l=this.applyBuilderUpdateUsageAndParse(d,h,e,s.aliases,u,n,o,r);return v(l)?l.then(f=>this.applyMiddlewareAndGetResult(d,h,f.innerArgv,c,o,f.aliases,e)):this.applyMiddlewareAndGetResult(d,h,l.innerArgv,c,o,l.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,s,n,o,r,h,c){let u=e.builder,d=s;if(Ut(u)){s.getInternalMethods().getUsageInstance().freeze();let l=u(s.getInternalMethods().reset(n),c);if(v(l))return l.then(f=>(d=je(f)?f:s,this.parseAndUpdateUsage(t,e,d,o,r,h)))}else is(u)&&(s.getInternalMethods().getUsageInstance().freeze(),d=s.getInternalMethods().reset(n),Object.keys(e.builder).forEach(l=>{d.option(l,u[l])}));return this.parseAndUpdateUsage(t,e,d,o,r,h)}parseAndUpdateUsage(t,e,s,n,o,r){t&&s.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(s)&&s.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(n,e),e.description);let h=s.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,o,r);return v(h)?h.then(c=>({aliases:s.parsed.aliases,innerArgv:c})):{aliases:s.parsed.aliases,innerArgv:h}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let s=Et.test(e.original)?e.original.replace(Et,"").trim():e.original,n=t.filter(o=>!Et.test(o));return n.push(s),`$0 ${n.join(" ")}`}handleValidationAndGetResult(t,e,s,n,o,r,h,c){if(!r.getInternalMethods().getHasOutput()){let u=r.getInternalMethods().runValidation(o,c,r.parsed.error,t);s=pt(s,d=>(u(d),d))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let u=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(s,u,!1,!1),s=dt(s,r,h,!1),s=pt(s,d=>{let l=e.handler(d);return v(l)?l.then(()=>d):d}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),v(s)&&!r.getInternalMethods().hasParseCallback()&&s.catch(d=>{try{r.getInternalMethods().getUsageInstance().fail(null,d)}catch{}})}return t||(n.commands.pop(),n.fullCommands.pop()),s}applyMiddlewareAndGetResult(t,e,s,n,o,r,h){let c={};if(o)return s;h.getInternalMethods().getHasOutput()||(c=this.populatePositionals(e,s,n,h));let u=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),d=dt(s,h,u,!0);return v(d)?d.then(l=>this.handleValidationAndGetResult(t,e,l,n,r,h,u,c)):this.handleValidationAndGetResult(t,e,d,n,r,h,u,c)}populatePositionals(t,e,s,n){e._=e._.slice(s.commands.length);let o=t.demanded.slice(0),r=t.optional.slice(0),h={};for(this.validation.positionalCount(o.length,e._.length);o.length;){let c=o.shift();this.populatePositional(c,e,h)}for(;r.length;){let c=r.shift();this.populatePositional(c,e,h)}return e._=s.commands.concat(e._.map(c=>""+c)),this.postProcessPositionals(e,h,this.cmdToParseOptions(t.original),n),h}populatePositional(t,e,s){let n=t.cmd[0];t.variadic?s[n]=e._.splice(0).map(String):e._.length&&(s[n]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},s=at(t);return s.demanded.forEach(n=>{let[o,...r]=n.cmd;n.variadic&&(e.array.push(o),e.default[o]=[]),e.alias[o]=r,e.demand[o]=!0}),s.optional.forEach(n=>{let[o,...r]=n.cmd;n.variadic&&(e.array.push(o),e.default[o]=[]),e.alias[o]=r}),e}postProcessPositionals(t,e,s,n){let o=Object.assign({},n.getOptions());o.default=Object.assign(s.default,o.default);for(let u of Object.keys(s.alias))o.alias[u]=(o.alias[u]||[]).concat(s.alias[u]);o.array=o.array.concat(s.array),o.config={};let r=[];if(Object.keys(e).forEach(u=>{e[u].map(d=>{o.configuration["unknown-options-as-args"]&&(o.key[u]=!0),r.push(`--${u}`),r.push(d)})}),!r.length)return;let h=Object.assign({},o.configuration,{"populate--":!1}),c=this.shim.Parser.detailed(r,Object.assign({},o,{configuration:h}));if(c.error)n.getInternalMethods().getUsageInstance().fail(c.error.message,c.error);else{let u=Object.keys(e);Object.keys(e).forEach(d=>{u.push(...c.aliases[d])}),Object.keys(c.argv).forEach(d=>{u.includes(d)&&(e[d]||(e[d]=c.argv[d]),!this.isInConfigs(n,d)&&!this.isDefaulted(n,d)&&Object.prototype.hasOwnProperty.call(t,d)&&Object.prototype.hasOwnProperty.call(c.argv,d)&&(Array.isArray(t[d])||Array.isArray(c.argv[d]))?t[d]=[].concat(t[d],c.argv[d]):t[d]=c.argv[d])})}}isDefaulted(t,e){let{default:s}=t.getOptions();return Object.prototype.hasOwnProperty.call(s,e)||Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:s}=t.getOptions();return s.some(n=>Object.prototype.hasOwnProperty.call(n,e))||s.some(n=>Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let s=Et.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(s,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Ut(e))return e(t,!0);we(e)||Object.keys(e).forEach(s=>{t.option(s,e[s])})}extractDesc({describe:t,description:e,desc:s}){for(let n of[t,e,s]){if(typeof n=="string"||n===!1)return n;Z(n,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();Z(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ce(a,t,e,s){return new kt(a,t,e,s)}function we(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function ss(a){return a.every(t=>typeof t=="string")}function Ut(a){return typeof a=="function"}function is(a){return typeof a=="object"}function ns(a){return typeof a=="object"&&!Array.isArray(a)}function lt(a={},t=()=>!0){let e={};return At(a).forEach(s=>{t(s,a[s])&&(e[s]=a[s])}),e}function ht(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function os(a){return typeof a=="boolean"}function Pe(a,t){let e=t.y18n.__,s={},n=[];s.failFn=function(b){n.push(b)};let o=null,r=null,h=!0;s.showHelpOnFail=function(b=!0,C){let[M,$]=typeof b=="string"?[!0,b]:[b,C];return a.getInternalMethods().isGlobalContext()&&(r=$),o=$,h=M,s};let c=!1;s.fail=function(b,C){let M=a.getInternalMethods().getLoggerInstance();if(n.length)for(let $=n.length-1;$>=0;--$){let T=n[$];if(os(T)){if(C)throw C;if(b)throw Error(b)}else T(b,C,s)}else{if(a.getExitProcess()&&ht(!0),!c){c=!0,h&&(a.showHelp("error"),M.error()),(b||C)&&M.error(b||C);let $=o||r;$&&((b||C)&&M.error(""),M.error($))}if(C=C||new q(b),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,C);throw C}};let u=[],d=!1;s.usage=(j,b)=>j===null?(d=!0,u=[],s):(d=!1,u.push([j,b||""]),s),s.getUsage=()=>u,s.getUsageDisabled=()=>d,s.getPositionalGroupName=()=>e("Positionals:");let l=[];s.example=(j,b)=>{l.push([j,b||""])};let f=[];s.command=function(b,C,M,$,T=!1){M&&(f=f.map(I=>(I[2]=!1,I))),f.push([b,C||"",M,$,T])},s.getCommands=()=>f;let p={};s.describe=function(b,C){Array.isArray(b)?b.forEach(M=>{s.describe(M,C)}):typeof b=="object"?Object.keys(b).forEach(M=>{s.describe(M,b[M])}):p[b]=C},s.getDescriptions=()=>p;let m=[];s.epilog=j=>{m.push(j)};let g=!1,x;s.wrap=j=>{g=!0,x=j},s.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(g||(x=it(),g=!0),x);let E="__yargsString__:";s.deferY18nLookup=j=>E+j,s.help=function(){if(D)return D;H();let b=a.customScriptName?a.$0:t.path.basename(a.$0),C=a.getDemandedOptions(),M=a.getDemandedCommands(),$=a.getDeprecatedOptions(),T=a.getGroups(),I=a.getOptions(),R=[];R=R.concat(Object.keys(p)),R=R.concat(Object.keys(C)),R=R.concat(Object.keys(M)),R=R.concat(Object.keys(I.default)),R=R.filter(z),R=Object.keys(R.reduce((P,U)=>(U!=="_"&&(P[U]=!0),P),{}));let vt=s.getWrap(),L=t.cliui({width:vt,wrap:!!vt});if(!d){if(u.length)u.forEach(P=>{L.div({text:`${P[0].replace(/\$0/g,b)}`}),P[1]&&L.div({text:`${P[1]}`,padding:[1,0,0,0]})}),L.div();else if(f.length){let P=null;M._?P=`${b} <${e("command")}>
2
+ import{c as ge,d as q,e as Xt}from"./chunk-QAIHRH3I.mjs";import"./chunk-5L7RYZCL.mjs";function Z(a,t,e,s){e.assert.notStrictEqual(a,t,s)}function Qt(a,t){t.assert.strictEqual(typeof a,"string")}function At(a){return Object.keys(a)}function v(a){return!!a&&!!a.then&&typeof a.then=="function"}function at(a){let e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),s=/\.*[\][<>]/g,n=e.shift();if(!n)throw new Error(`No command found in: ${a}`);let o={cmd:n.replace(s,""),demanded:[],optional:[]};return e.forEach((r,h)=>{let c=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&h===e.length-1&&(c=!0),/^\[/.test(r)?o.optional.push({cmd:r.replace(s,"").split("|"),variadic:c}):o.demanded.push({cmd:r.replace(s,"").split("|"),variadic:c})}),o}var ts=["first","second","third","fourth","fifth","sixth"];function _(a,t,e){function s(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[at(`cmd ${a}`),t,e]}try{let n=0,[o,r,h]=s(),c=[].slice.call(r);for(;c.length&&c[c.length-1]===void 0;)c.pop();let u=h||c.length;if(u<o.demanded.length)throw new q(`Not enough arguments provided. Expected ${o.demanded.length} but received ${c.length}.`);let d=o.demanded.length+o.optional.length;if(u>d)throw new q(`Too many arguments provided. Expected max ${d} but received ${u}.`);o.demanded.forEach(l=>{let f=c.shift(),p=be(f);l.cmd.filter(g=>g===p||g==="*").length===0&&_e(p,l.cmd,n),n+=1}),o.optional.forEach(l=>{if(c.length===0)return;let f=c.shift(),p=be(f);l.cmd.filter(g=>g===p||g==="*").length===0&&_e(p,l.cmd,n),n+=1})}catch(n){console.warn(n.stack)}}function be(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function _e(a,t,e){throw new q(`Invalid ${ts[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}var Wt=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,s=!0,n=!1){if(_("<array|function> [boolean] [boolean] [boolean]",[t,e,s],arguments.length),Array.isArray(t)){for(let o=0;o<t.length;o++){if(typeof t[o]!="function")throw Error("middleware must be a function");let r=t[o];r.applyBeforeValidation=e,r.global=s}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let o=t;o.applyBeforeValidation=e,o.global=s,o.mutates=n,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let s=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(n=>{let o=[...s[e]||[],e];return n.option?!o.includes(n.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function Oe(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function dt(a,t,e,s){return e.reduce((n,o)=>{if(o.applyBeforeValidation!==s)return n;if(o.mutates){if(o.applied)return n;o.applied=!0}if(v(n))return n.then(r=>Promise.all([r,o(r,t)])).then(([r,h])=>Object.assign(r,h));{let r=o(n,t);return v(r)?r.then(h=>Object.assign(n,h)):Object.assign(n,r)}},a)}function pt(a,t,e=s=>{throw s}){try{let s=es(a)?a():a;return v(s)?s.then(n=>t(n)):t(s)}catch(s){return e(s)}}function es(a){return typeof a=="function"}var Et=/(^\*)|(^\$0)/,kt=class{constructor(t,e,s,n){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=n,this.usage=t,this.globalMiddleware=s,this.validation=e}addDirectory(t,e,s,n){n=n||{},this.requireCache.add(s);let o=this.shim.path.resolve(this.shim.path.dirname(s),t),r=this.shim.readdirSync(o,{recursive:!!n.recurse});Array.isArray(n.extensions)||(n.extensions=["js"]);let h=typeof n.visit=="function"?n.visit:c=>c;for(let c of r){let u=c.toString();if(n.exclude){let l=!1;if(typeof n.exclude=="function"?l=n.exclude(u):l=n.exclude.test(u),l)continue}if(n.include){let l=!1;if(typeof n.include=="function"?l=n.include(u):l=n.include.test(u),!l)continue}let d=!1;for(let l of n.extensions)u.endsWith(l)&&(d=!0);if(d){let l=this.shim.path.join(o,u),f=e(l),p=Object.create(null,Object.getOwnPropertyDescriptors({...f}));if(h(p,l,u)){if(this.requireCache.has(l))continue;this.requireCache.add(l),p.command||(p.command=this.shim.path.basename(l,this.shim.path.extname(l))),this.addHandler(p)}}}}addHandler(t,e,s,n,o,r){let h=[],c=Oe(o);if(n=n||(()=>{}),Array.isArray(t))if(ss(t))[t,...h]=t;else for(let u of t)this.addHandler(u);else if(ns(t)){let u=Array.isArray(t.command)||typeof t.command=="string"?t.command:null;if(u===null)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);t.aliases&&(u=[].concat(u).concat(t.aliases)),this.addHandler(u,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(we(s)){this.addHandler([t].concat(h),e,s.builder,s.handler,s.middlewares,s.deprecated);return}if(typeof t=="string"){let u=at(t);h=h.map(f=>at(f).cmd);let d=!1,l=[u.cmd].concat(h).filter(f=>Et.test(f)?(d=!0,!1):!0);l.length===0&&d&&l.push("$0"),d&&(u.cmd=l[0],h=l.slice(1),t=t.replace(Et,u.cmd)),h.forEach(f=>{this.aliasMap[f]=u.cmd}),e!==!1&&this.usage.command(t,e,d,h,r),this.handlers[u.cmd]={original:t,description:e,handler:n,builder:s||{},middlewares:c,deprecated:r,demanded:u.demanded,optional:u.optional},d&&(this.defaultCommand=this.handlers[u.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,s,n,o,r){let h=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,c=e.getInternalMethods().getContext(),u=c.commands.slice(),d=!t;t&&(c.commands.push(t),c.fullCommands.push(h.original));let l=this.applyBuilderUpdateUsageAndParse(d,h,e,s.aliases,u,n,o,r);return v(l)?l.then(f=>this.applyMiddlewareAndGetResult(d,h,f.innerArgv,c,o,f.aliases,e)):this.applyMiddlewareAndGetResult(d,h,l.innerArgv,c,o,l.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,s,n,o,r,h,c){let u=e.builder,d=s;if(Ut(u)){s.getInternalMethods().getUsageInstance().freeze();let l=u(s.getInternalMethods().reset(n),c);if(v(l))return l.then(f=>(d=je(f)?f:s,this.parseAndUpdateUsage(t,e,d,o,r,h)))}else is(u)&&(s.getInternalMethods().getUsageInstance().freeze(),d=s.getInternalMethods().reset(n),Object.keys(e.builder).forEach(l=>{d.option(l,u[l])}));return this.parseAndUpdateUsage(t,e,d,o,r,h)}parseAndUpdateUsage(t,e,s,n,o,r){t&&s.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(s)&&s.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(n,e),e.description);let h=s.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,o,r);return v(h)?h.then(c=>({aliases:s.parsed.aliases,innerArgv:c})):{aliases:s.parsed.aliases,innerArgv:h}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let s=Et.test(e.original)?e.original.replace(Et,"").trim():e.original,n=t.filter(o=>!Et.test(o));return n.push(s),`$0 ${n.join(" ")}`}handleValidationAndGetResult(t,e,s,n,o,r,h,c){if(!r.getInternalMethods().getHasOutput()){let u=r.getInternalMethods().runValidation(o,c,r.parsed.error,t);s=pt(s,d=>(u(d),d))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let u=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(s,u,!1,!1),s=dt(s,r,h,!1),s=pt(s,d=>{let l=e.handler(d);return v(l)?l.then(()=>d):d}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),v(s)&&!r.getInternalMethods().hasParseCallback()&&s.catch(d=>{try{r.getInternalMethods().getUsageInstance().fail(null,d)}catch{}})}return t||(n.commands.pop(),n.fullCommands.pop()),s}applyMiddlewareAndGetResult(t,e,s,n,o,r,h){let c={};if(o)return s;h.getInternalMethods().getHasOutput()||(c=this.populatePositionals(e,s,n,h));let u=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),d=dt(s,h,u,!0);return v(d)?d.then(l=>this.handleValidationAndGetResult(t,e,l,n,r,h,u,c)):this.handleValidationAndGetResult(t,e,d,n,r,h,u,c)}populatePositionals(t,e,s,n){e._=e._.slice(s.commands.length);let o=t.demanded.slice(0),r=t.optional.slice(0),h={};for(this.validation.positionalCount(o.length,e._.length);o.length;){let c=o.shift();this.populatePositional(c,e,h)}for(;r.length;){let c=r.shift();this.populatePositional(c,e,h)}return e._=s.commands.concat(e._.map(c=>""+c)),this.postProcessPositionals(e,h,this.cmdToParseOptions(t.original),n),h}populatePositional(t,e,s){let n=t.cmd[0];t.variadic?s[n]=e._.splice(0).map(String):e._.length&&(s[n]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},s=at(t);return s.demanded.forEach(n=>{let[o,...r]=n.cmd;n.variadic&&(e.array.push(o),e.default[o]=[]),e.alias[o]=r,e.demand[o]=!0}),s.optional.forEach(n=>{let[o,...r]=n.cmd;n.variadic&&(e.array.push(o),e.default[o]=[]),e.alias[o]=r}),e}postProcessPositionals(t,e,s,n){let o=Object.assign({},n.getOptions());o.default=Object.assign(s.default,o.default);for(let u of Object.keys(s.alias))o.alias[u]=(o.alias[u]||[]).concat(s.alias[u]);o.array=o.array.concat(s.array),o.config={};let r=[];if(Object.keys(e).forEach(u=>{e[u].map(d=>{o.configuration["unknown-options-as-args"]&&(o.key[u]=!0),r.push(`--${u}`),r.push(d)})}),!r.length)return;let h=Object.assign({},o.configuration,{"populate--":!1}),c=this.shim.Parser.detailed(r,Object.assign({},o,{configuration:h}));if(c.error)n.getInternalMethods().getUsageInstance().fail(c.error.message,c.error);else{let u=Object.keys(e);Object.keys(e).forEach(d=>{u.push(...c.aliases[d])}),Object.keys(c.argv).forEach(d=>{u.includes(d)&&(e[d]||(e[d]=c.argv[d]),!this.isInConfigs(n,d)&&!this.isDefaulted(n,d)&&Object.prototype.hasOwnProperty.call(t,d)&&Object.prototype.hasOwnProperty.call(c.argv,d)&&(Array.isArray(t[d])||Array.isArray(c.argv[d]))?t[d]=[].concat(t[d],c.argv[d]):t[d]=c.argv[d])})}}isDefaulted(t,e){let{default:s}=t.getOptions();return Object.prototype.hasOwnProperty.call(s,e)||Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:s}=t.getOptions();return s.some(n=>Object.prototype.hasOwnProperty.call(n,e))||s.some(n=>Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let s=Et.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(s,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Ut(e))return e(t,!0);we(e)||Object.keys(e).forEach(s=>{t.option(s,e[s])})}extractDesc({describe:t,description:e,desc:s}){for(let n of[t,e,s]){if(typeof n=="string"||n===!1)return n;Z(n,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();Z(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ce(a,t,e,s){return new kt(a,t,e,s)}function we(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function ss(a){return a.every(t=>typeof t=="string")}function Ut(a){return typeof a=="function"}function is(a){return typeof a=="object"}function ns(a){return typeof a=="object"&&!Array.isArray(a)}function lt(a={},t=()=>!0){let e={};return At(a).forEach(s=>{t(s,a[s])&&(e[s]=a[s])}),e}function ht(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function os(a){return typeof a=="boolean"}function Pe(a,t){let e=t.y18n.__,s={},n=[];s.failFn=function(b){n.push(b)};let o=null,r=null,h=!0;s.showHelpOnFail=function(b=!0,C){let[M,$]=typeof b=="string"?[!0,b]:[b,C];return a.getInternalMethods().isGlobalContext()&&(r=$),o=$,h=M,s};let c=!1;s.fail=function(b,C){let M=a.getInternalMethods().getLoggerInstance();if(n.length)for(let $=n.length-1;$>=0;--$){let T=n[$];if(os(T)){if(C)throw C;if(b)throw Error(b)}else T(b,C,s)}else{if(a.getExitProcess()&&ht(!0),!c){c=!0,h&&(a.showHelp("error"),M.error()),(b||C)&&M.error(b||C);let $=o||r;$&&((b||C)&&M.error(""),M.error($))}if(C=C||new q(b),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,C);throw C}};let u=[],d=!1;s.usage=(j,b)=>j===null?(d=!0,u=[],s):(d=!1,u.push([j,b||""]),s),s.getUsage=()=>u,s.getUsageDisabled=()=>d,s.getPositionalGroupName=()=>e("Positionals:");let l=[];s.example=(j,b)=>{l.push([j,b||""])};let f=[];s.command=function(b,C,M,$,T=!1){M&&(f=f.map(I=>(I[2]=!1,I))),f.push([b,C||"",M,$,T])},s.getCommands=()=>f;let p={};s.describe=function(b,C){Array.isArray(b)?b.forEach(M=>{s.describe(M,C)}):typeof b=="object"?Object.keys(b).forEach(M=>{s.describe(M,b[M])}):p[b]=C},s.getDescriptions=()=>p;let m=[];s.epilog=j=>{m.push(j)};let g=!1,x;s.wrap=j=>{g=!0,x=j},s.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(g||(x=it(),g=!0),x);let E="__yargsString__:";s.deferY18nLookup=j=>E+j,s.help=function(){if(D)return D;H();let b=a.customScriptName?a.$0:t.path.basename(a.$0),C=a.getDemandedOptions(),M=a.getDemandedCommands(),$=a.getDeprecatedOptions(),T=a.getGroups(),I=a.getOptions(),R=[];R=R.concat(Object.keys(p)),R=R.concat(Object.keys(C)),R=R.concat(Object.keys(M)),R=R.concat(Object.keys(I.default)),R=R.filter(z),R=Object.keys(R.reduce((P,U)=>(U!=="_"&&(P[U]=!0),P),{}));let vt=s.getWrap(),L=t.cliui({width:vt,wrap:!!vt});if(!d){if(u.length)u.forEach(P=>{L.div({text:`${P[0].replace(/\$0/g,b)}`}),P[1]&&L.div({text:`${P[1]}`,padding:[1,0,0,0]})}),L.div();else if(f.length){let P=null;M._?P=`${b} <${e("command")}>
3
3
  `:P=`${b} [${e("command")}]
4
4
  `,L.div(`${P}`)}}if(f.length>1||f.length===1&&!f[0][2]){L.div(e("Commands:"));let P=a.getInternalMethods().getContext(),U=P.commands.length?`${P.commands.join(" ")} `:"";a.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(f=f.sort((A,B)=>A[0].localeCompare(B[0])));let K=b?`${b} `:"";f.forEach(A=>{let B=`${K}${U}${A[0].replace(/^\$0 ?/,"")}`;L.span({text:B,padding:[0,2,0,2],width:W(f,vt,`${b}${U}`)+4},{text:A[1]});let N=[];A[2]&&N.push(`[${e("default")}]`),A[3]&&A[3].length&&N.push(`[${e("aliases:")} ${A[3].join(", ")}]`),A[4]&&(typeof A[4]=="string"?N.push(`[${e("deprecated: %s",A[4])}]`):N.push(`[${e("deprecated")}]`)),N.length?L.div({text:N.join(" "),padding:[0,0,0,2],align:"right"}):L.div()}),L.div()}let Bt=(Object.keys(I.alias)||[]).concat(Object.keys(a.parsed.newAliases)||[]);R=R.filter(P=>!a.parsed.newAliases[P]&&Bt.every(U=>(I.alias[U]||[]).indexOf(P)===-1));let Zt=e("Options:");T[Zt]||(T[Zt]=[]),Mt(R,I.alias,T,Zt);let Dt=P=>/^--/.test(Ft(P)),Jt=Object.keys(T).filter(P=>T[P].length>0).map(P=>{let U=T[P].filter(z).map(K=>{if(Bt.includes(K))return K;for(let A=0,B;(B=Bt[A])!==void 0;A++)if((I.alias[B]||[]).includes(K))return B;return K});return{groupName:P,normalizedKeys:U}}).filter(({normalizedKeys:P})=>P.length>0).map(({groupName:P,normalizedKeys:U})=>{let K=U.reduce((A,B)=>(A[B]=[B].concat(I.alias[B]||[]).map(N=>P===s.getPositionalGroupName()?N:(/^[0-9]$/.test(N)?I.boolean.includes(B)?"-":"--":N.length>1?"--":"-")+N).sort((N,rt)=>Dt(N)===Dt(rt)?0:Dt(N)?1:-1).join(", "),A),{});return{groupName:P,normalizedKeys:U,switches:K}});if(Jt.filter(({groupName:P})=>P!==s.getPositionalGroupName()).some(({normalizedKeys:P,switches:U})=>!P.every(K=>Dt(U[K])))&&Jt.filter(({groupName:P})=>P!==s.getPositionalGroupName()).forEach(({normalizedKeys:P,switches:U})=>{P.forEach(K=>{Dt(U[K])&&(U[K]=rs(U[K],4))})}),Jt.forEach(({groupName:P,normalizedKeys:U,switches:K})=>{L.div(P),U.forEach(A=>{let B=K[A],N=p[A]||"",rt=null;N.includes(E)&&(N=e(N.substring(E.length))),I.boolean.includes(A)&&(rt=`[${e("boolean")}]`),I.count.includes(A)&&(rt=`[${e("count")}]`),I.string.includes(A)&&(rt=`[${e("string")}]`),I.normalize.includes(A)&&(rt=`[${e("string")}]`),I.array.includes(A)&&(rt=`[${e("array")}]`),I.number.includes(A)&&(rt=`[${e("number")}]`);let Qe=me=>typeof me=="string"?`[${e("deprecated: %s",me)}]`:`[${e("deprecated")}]`,pe=[A in $?Qe($[A]):null,rt,A in C?`[${e("required")}]`:null,I.choices&&I.choices[A]?`[${e("choices:")} ${s.stringifiedValues(I.choices[A])}]`:null,V(I.default[A],I.defaultDescription[A])].filter(Boolean).join(" ");L.span({text:Ft(B),padding:[0,2,0,2+ye(B)],width:W(K,vt)+4},N);let ke=a.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;pe&&!ke?L.div({text:pe,padding:[0,0,0,2],align:"right"}):L.div()}),L.div()}),l.length&&(L.div(e("Examples:")),l.forEach(P=>{P[0]=P[0].replace(/\$0/g,b)}),l.forEach(P=>{P[1]===""?L.div({text:P[0],padding:[0,2,0,2]}):L.div({text:P[0],padding:[0,2,0,2],width:W(l,vt)+4},{text:P[1]})}),L.div()),m.length>0){let P=m.map(U=>U.replace(/\$0/g,b)).join(`
5
5
  `);L.div(`${P}
@@ -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{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
2
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
@@ -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{g as St,r as nt,t as Ct}from"./chunk-VG5JEIUQ.mjs";import{a as Lt,b as st,c as z,e as vt}from"./chunk-N3DSBH5S.mjs";import{createHash as Ee}from"node:crypto";import{BLOCK_LEVEL as ot}from"../browser/shared/html-tree.mjs";var wt=t=>Ee("sha256").update(t).digest("hex").slice(0,16),M=t=>t.nodeName==="#text"&&!t.value.trim();function at(t,e){for(let s of t.childNodes??[]){if(s.tagName===e)return s;let o=s.tagName&&at(s,e);if(o)return o}return null}import{ATTRIBUTES as an,BOX_CLASSES as on,COMPONENT_ATTRIBUTES as rn,COMPONENT_CLASSES as cn,GROUPING as ln,IDENTITY as R,TOGGLES as fn,UNIT_KINDS as dn}from"../browser/editor/components/registry.mjs";import{attr as I,hasClass as kt}from"../browser/shared/html-tree.mjs";import{idsNamed as un}from"../browser/shared/copy-ids.mjs";import{DIALOG as pn,PAGE as mn,SECTION as gn,SHEETS as K,TABLE as Le}from"../browser/editor/components/kit.mjs";import{matchesNode as q,partOf as bt}from"../browser/shared/components/index.mjs";import{escapeMarkup as V}from"../browser/shared/escape.mjs";import{imageFile as Ae}from"../browser/shared/media.mjs";import{emptyFigure as Ie}from"../browser/editor/components/media/write.mjs";var _e=t=>typeof t=="string"&&t.length<=2e3&&/^https?:\/\/[^\s"<>]+$/.test(t),Et=(t,e)=>typeof t=="string"&&t.length<=e&&!/[\u0000-\u001f]/.test(t),At=t=>t.href===""&&!t.title&&!t.description&&!t.icon&&!t.cover&&t.caption==="",It=t=>t==null||Ae(t),_t={bookmark:{check:(t,{validLeaf:e})=>At(t)||_e(t.href)&&Et(t.title,300)&&Et(t.description??"",600)&&It(t.icon)&&It(t.cover)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(At(t))return Ie("bookmark",e);let s=t.title.trim()||new URL(t.href).hostname,o=[`<span class="doc-bookmark-title">${V(s)}</span>`,t.description?`<span class="doc-bookmark-description">${V(t.description)}</span>`:"",`<span class="doc-bookmark-url">${t.icon?`<img class="doc-bookmark-icon" src="${t.icon}" alt="">`:""}<span class="doc-bookmark-href">${V(t.href)}</span></span>`].join(""),n=t.cover?`<span class="doc-bookmark-cover"><img src="${t.cover}" alt=""></span>`:"",a=`<a class="doc-bookmark-card" href="${V(t.href)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text">${o}</span>${n}</a>`;return e.block(`<figure class="doc-bookmark"${e.id}>`,[a,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{BLOCK_TYPES as Be,sizeValue as Me}from"../browser/editor/components/registry.mjs";import{LINE_START as Mt,lineStart as je}from"../browser/shared/code-lines.mjs";import{hasClass as Bt}from"../browser/shared/html-tree.mjs";import{CODE_HEIGHT as rt,FOLDED_LINES as jt,validFolded as Re,validLanguage as De}from"../browser/editor/components/code/index.mjs";var ze=(t,e,s,o,n="",a="",r="",i="")=>`<div class="${t.className}"${s?` data-language="${s}"`:""}${i?` ${Mt}="${i}"`:""}${r?` ${jt}="${r}"`:""}${o?` style="${rt}: ${o}"`:""}${n}><div class="doc-code-title">${a}</div><pre><code>${e}</code></pre></div>`,Ue=(t,e)=>t==="data-language"||t===jt||t===Mt||t==="style"&&new RegExp(`^\\s*${rt}\\s*:[^;]*;?\\s*$`).test(e??""),We=t=>typeof t=="string"&&t.length<=200&&!/[<>\n]|&(?!(amp|lt|gt|quot|#39);)/.test(t),Fe=t=>(t.language===void 0||De(t.language))&&(t.folded===void 0||Re(t.folded))&&(t.height===void 0||Me("code",rt,t.height)===t.height)&&(t.title===void 0||We(t.title))&&(t.lineStart===void 0||typeof t.lineStart=="string"&&String(je(t.lineStart))===t.lineStart);function Ke(t){let{node:e}=t;if(t.tag!=="div"||t.nested||!Bt(e,Be.code.className))return!1;let s=(n,a)=>{let r=n.childNodes??[],i=r.filter(f=>f.tagName);return i.length===a.length&&i.every((f,l)=>f.tagName===a[l])&&r.every(f=>f.tagName||!(f.value??"").trim())?i:null},o=s(e,["div","pre"]);return!!o&&Bt(o[0],"doc-code-title")&&!!s(o[1],["code"])}var Rt={code:{fields:["language","folded","height","title","lineStart"],check:Fe,leaf:(t,e,s)=>ze(t,e.html,e.language,e.height,s,e.title,e.folded,e.lineStart),written:Ke,attribute:Ue}};import{sizeValue as He}from"../browser/editor/components/registry.mjs";import{MIN_COLUMNS as Pe,RATIO as Dt}from"../browser/editor/components/columns/index.mjs";var zt={columns:{check:t=>t.children.length>=Pe&&t.children.every(e=>e.type==="column")},column:{check:t=>t.ratio===void 0||He("column",Dt,t.ratio)===t.ratio,write(t,e){let s=t.ratio===void 0?"":` style="${Dt}: ${t.ratio}"`;return e.block(`<div class="doc-column"${s}${e.id}>`,e.children(e.inner),"</div>")}}};var Ut={details:{empty:!0,check:(t,{validLeaf:e})=>t.title===""||e({tag:"span"},t.title),write(t,e){let s=e.inner===null?null:e.inner+e.step,o=e.block('<div class="doc-details-content">',e.children(s),"</div>",e.inner,s),n=t.classes?.length?` ${t.classes.join(" ")}`:"";return e.block(`<details class="doc-details${n}"${e.id}>`,[`<summary><span class="doc-details-summary-label">${t.title}</span></summary>`,t.children.length>0?o:'<div class="doc-details-content"></div>'],"</details>")}}};var Wt={dialog:{empty:!0,check(t,{usedIds:e}){return typeof t.id!="string"||!/^[A-Za-z][\w-]{0,63}$/.test(t.id)||e.has(t.id)?!1:(e.add(t.id),!0)},write(t,e){let s=t.children.length>0?e.block('<div class="doc-dialog-content">',e.children(e.deep(3)),"</div>",e.deep(2),e.deep(3)):'<div class="doc-dialog-content"></div>',o=e.block('<div class="doc-dialog-panel">',[s],"</div>",e.deep(1),e.deep(2));return e.block(`<dialog class="doc-dialog" id="${t.id}">`,[o],"</dialog>")}}};import{escapeAttribute as Ge}from"../browser/shared/escape.mjs";import{embedFile as Ft}from"../browser/shared/media.mjs";import{emptyFigure as qe}from"../browser/editor/components/media/write.mjs";import{FILE_SANDBOX as Ve,WEB_SANDBOX as Xe}from"../browser/editor/components/embed/index.mjs";var Ye=t=>typeof t=="string"&&t.length<=2e3&&/^https:\/\/[^\s"<>]+$/.test(t),Kt=t=>t.src===""&&t.height===void 0&&t.caption==="",Ht={embed:{check:(t,{validLeaf:e})=>Kt(t)||(Ye(t.src)||Ft(t.src))&&(t.height===void 0||/^\d{2,4}px$/.test(t.height))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Kt(t))return qe("embed",e);let s=Ft(t.src),o=s?/\.pdf$/i.test(t.src)?"":` sandbox="${Ve}"`:` sandbox="${Xe}" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen`,n=`<iframe class="doc-embed-frame" src="${Ge(t.src)}"${o} loading="lazy"></iframe>`,a=t.height?` style="--doc-embed-height: ${t.height}"`:"";return e.block(`<figure class="doc-embed${s?" doc-embed--file":""}"${a}${e.id}>`,[n,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{escapeMarkup as Pt}from"../browser/shared/escape.mjs";import{assetFile as Ze}from"../browser/shared/media.mjs";import{emptyFigure as Je}from"../browser/editor/components/media/write.mjs";var Gt=t=>t.href===""&&t.name===""&&t.size===void 0&&t.caption==="",Qe=t=>typeof t=="string"&&t.trim()!==""&&t.length<=120&&!/[\u0000-\u001f<>:"/\\|?*]/.test(t),qt={file:{check:(t,{validLeaf:e})=>Gt(t)||Ze(t.href)&&Qe(t.name)&&(t.size===void 0||/^\d+(\.\d)? (B|KiB|MiB|GiB)$/.test(t.size))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Gt(t))return Je("file",e);let s=t.size?`<span class="doc-file-size">${t.size}</span>`:"",o=`<a class="doc-file-link" href="${t.href}" download="${Pt(t.name)}"><span class="doc-file-name">${Pt(t.name)}</span>${s}</a>`;return e.block(`<figure class="doc-file"${e.id}>`,[o,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{FLOW as ts,FLOW_DIRECTION as Vt,FLOW_RATIO as Xt}from"../browser/editor/components/flowchart/index.mjs";import{START as es,validDirection as Yt,validStart as ss}from"../browser/editor/components/list/index.mjs";import{sizeValue as ns,TOGGLES as as}from"../browser/editor/components/registry.mjs";var Zt={flowchart:{check:t=>(t.start===void 0||ss(t.start))&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write:(t,e)=>e.block(`<ol class="${ts}"${t.start?` ${es}="${t.start}"`:""}${t.direction?` ${Vt}="${t.direction}"`:""}${e.id}>`,e.children(e.inner),"</ol>")},step:{check:t=>(t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(e=>(as.step??[]).includes(e)))&&(t.ratio===void 0||ns("step",Xt,t.ratio)===t.ratio)&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write(t,e){let s=t.classes?.length?` class="${t.classes.join(" ")}"`:"",o=t.direction?` ${Vt}="${t.direction}"`:"",n=t.ratio===void 0?"":` style="${Xt}: ${t.ratio}"`;return e.block(`<li${s}${o}${n}${e.id}>`,e.children(e.inner),"</li>")}}};import{SPAN as os,SPAN_SIZE as Jt,imageFile as Qt}from"../browser/shared/media.mjs";import{emptyFigure as rs}from"../browser/editor/components/media/write.mjs";var is=/^\d{1,3}(\.\d{1,3})?( \d{1,3}(\.\d{1,3})?){3}$/,te=t=>t.src===""&&t.caption===""&&t.span===void 0&&t.original===void 0&&t.classes===void 0,cs=t=>typeof t=="number"&&Number.isFinite(t)&&t>=Jt.min&&t<=Jt.max,ee={image:{check:(t,{validLeaf:e})=>te(t)||Qt(t.src)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption))&&(t.span===void 0||cs(t.span))&&(t.original===void 0||Qt(t.original)&&typeof t.crop=="string"&&is.test(t.crop)),write(t,e){if(te(t))return rs("image",e);let s=["doc-image",...t.classes??[]].join(" "),o=t.span===void 0?"":` style="${os}: ${Math.round(t.span*1e3)/1e3}"`,n=t.original===void 0?"":` data-original="${t.original}" data-crop="${t.crop}"`;return e.block(`<figure class="${s}"${o}${e.id}>`,[`<img src="${t.src}" alt=""${n}>`,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};vt();import{heldByNode as ls,instanceSlots as fs,isInstance as lt,isSlot as ds,ownSlots as us,partOf as ft}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as G,DATA_MOST as ps,NO_TEXT as ms,PACKAGE_ID as se,SCHEMA as ne,SLOT as ae,fitsDataScript as gs,isDataScript as hs,noDataPart as $s,refusedInCopy as Ns,refusedInData as Os,schemaAhead as oe}from"../browser/shared/components/installed.mjs";import{attr as B,walk as re}from"../browser/shared/html-tree.mjs";import{CHART_KEY as bs,VIEW_FROM as it}from"../browser/shared/table-chart.mjs";var P=(t,e)=>{for(let s=t.parentNode;s;s=s.parentNode)if(s===e)return!0;return!1},xs=t=>{let e=t.parentNode;for(;e&&!lt(e);)e=e.parentNode;return e??null},dt=(t,e)=>xs(t)===e&&ls(t)===e&&!ds(t);function ct(t,e){let o=Object.entries(e.get(B(t,G))?.parts??{}).filter(([,{edit:n}])=>n==="data").map(([n,{at:a}])=>[n,ft(t,a).find(r=>r.sourceCodeLocation&&!lt(r)&&dt(r,t))]).filter(([,n])=>n);return o.filter(([,n],a)=>!o.some(([,r],i)=>P(n,r)||r===n&&i<a))}var ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ks="http://www.w3.org/1999/xhtml",Ts=t=>(t.content??t).childNodes;function ie(t,e,s,o){let n=s;for(let a of Ts(t)){let r=a.sourceCodeLocation;if(r?.startOffset!==n)return!1;if(a.tagName){let{startTag:i,endTag:f}=r,l=ys.has(a.tagName)||a.namespaceURI!==ks&&e.startsWith("/>",r.endOffset-2);if(f?!ie(a,e,i.endOffset,f.startOffset):!l)return!1}n=r.endOffset}return n===o}function Ls(t,e,s){if(e.tagName==="script")return hs(e.tagName,e.attrs)&&gs(s);if($s(e.tagName))return!1;let{startTag:o,endTag:n}=e.sourceCodeLocation,a=t.slice(o.startOffset,o.endOffset),r=`${a}${s}${t.slice(n.startOffset,n.endOffset)}`,[i,...f]=z(e.parentNode,r,{sourceCodeLocationInfo:!0}).childNodes;if(f.length>0||i?.tagName!==e.tagName||i.sourceCodeLocation?.endOffset!==r.length||!i.sourceCodeLocation.endTag||!ie(i,r,a.length,a.length+s.length))return!1;let l=!1;return re(i,m=>{l||=Os(m.tagName,m.attrs)}),!l}var vs=(t,e)=>Object.values(e.get(B(t,G))?.parts??{}).filter(({edit:s})=>s==="text"||s==="data").flatMap(({at:s})=>ft(t,s).filter(o=>dt(o,t))),ce={installed:{slots(t,e){let s=vs(t,e);return fs(t).filter(o=>!s.some(n=>P(o,n)))},boxes(t,e){return this.slots(t,e).map(s=>({element:s,kind:"slot",key:B(s,ae)}))},textParts(t,e){let s=e.get(B(t,G));if(oe(B(t,ne),s?.schema))return[];let o=Object.values(s?.parts??{}).filter(({edit:r})=>r==="text"),n=ct(t,e).map(([,r])=>r),a=[...new Set(o.flatMap(({at:r})=>ft(t,r)))].filter(r=>r.sourceCodeLocation&&!lt(r)&&!ms.has(r.tagName)&&dt(r,t)).filter(r=>!n.some(i=>i===r||P(r,i)||P(i,r)));return a.filter(r=>!a.some(i=>P(r,i))).map(r=>({kind:"installed",part:r}))},source({package:t,html:e,children:s,boxKeys:o,from:n},{packages:a,written:r}){if(typeof t!="string"||!se.test(t))return null;let i=s!==void 0;if(i&&!(Array.isArray(s)&&Array.isArray(o)&&o.length===s.length)||n!=null&&(typeof n!="string"||!bs.test(n)))return null;let f=e===void 0?a.has(t)?Ct(a.get(t)):null:e,l=typeof f=="string"?nt(f,t):null;if(l&&(typeof n=="string"||n===null&&B(l.root,it)!==void 0)&&(l.root.attrs=[...l.root.attrs.filter(({name:L})=>L!==it),...n===null?[]:[{name:it,value:n}]],l=nt(Lt(l.root),t)),!l)return null;let m=us(l.root),u=L=>!L.childNodes.every(N=>N.nodeName==="#text"&&!N.value.trim());if((e!==void 0||!i)&&m.some(u)||i&&!o.every(L=>m.some(N=>B(N,ae)===L)))return null;if(e!==void 0){let L=!1;if(re({childNodes:[l.root]},N=>{L||=Ns(N.tagName,N.attrs)}),L)return null}let v=m.map(L=>L.sourceCodeLocation).sort((L,N)=>N.startOffset-L.startOffset).reduce((L,{startTag:N,endTag:b})=>L.slice(0,N.endOffset)+L.slice(b.startOffset),l.markup);return r(i?v:l.markup)},unwritten:({package:t,html:e},{packages:s})=>e===void 0&&se.test(t)&&!s.has(t)?"no-package":"invalid",definition:(t,e)=>e.get(B(t,G))?.definition,dataOf(t,e,s){let o=ct(e,s).filter(([,n])=>n.sourceCodeLocation.endTag);return o.length>0?Object.fromEntries(o.map(([n,a])=>[n,t.slice(a.sourceCodeLocation.startTag.endOffset,a.sourceCodeLocation.endTag.startOffset)])):null},rewrite(t,e,s,{packages:o}){let n=new Map(ct(e,o)),a=Object.keys(s),r=a.map(f=>s[f]);if(oe(B(e,ne),o.get(B(e,G))?.schema)||a.length===0||!r.every(f=>typeof f=="string")||!a.every(f=>n.has(f))||r.reduce((f,l)=>f+Buffer.byteLength(l),0)>ps||!a.every(f=>n.get(f).sourceCodeLocation.endTag&&Ls(t,n.get(f),s[f])))return null;let i=t.includes(`\r
2
+ import{g as St,r as nt,t as Ct}from"./chunk-TKWEX4FD.mjs";import{a as Lt,b as st,c as z,e as vt}from"./chunk-A55HN5OK.mjs";import{createHash as Ee}from"node:crypto";import{BLOCK_LEVEL as ot}from"../browser/shared/html-tree.mjs";var wt=t=>Ee("sha256").update(t).digest("hex").slice(0,16),M=t=>t.nodeName==="#text"&&!t.value.trim();function at(t,e){for(let s of t.childNodes??[]){if(s.tagName===e)return s;let o=s.tagName&&at(s,e);if(o)return o}return null}import{ATTRIBUTES as an,BOX_CLASSES as on,COMPONENT_ATTRIBUTES as rn,COMPONENT_CLASSES as cn,GROUPING as ln,IDENTITY as R,TOGGLES as fn,UNIT_KINDS as dn}from"../browser/editor/components/registry.mjs";import{attr as I,hasClass as kt}from"../browser/shared/html-tree.mjs";import{idsNamed as un}from"../browser/shared/copy-ids.mjs";import{DIALOG as pn,PAGE as mn,SECTION as gn,SHEETS as K,TABLE as Le}from"../browser/editor/components/kit.mjs";import{matchesNode as q,partOf as bt}from"../browser/shared/components/index.mjs";import{escapeMarkup as V}from"../browser/shared/escape.mjs";import{imageFile as Ae}from"../browser/shared/media.mjs";import{emptyFigure as Ie}from"../browser/editor/components/media/write.mjs";var _e=t=>typeof t=="string"&&t.length<=2e3&&/^https?:\/\/[^\s"<>]+$/.test(t),Et=(t,e)=>typeof t=="string"&&t.length<=e&&!/[\u0000-\u001f]/.test(t),At=t=>t.href===""&&!t.title&&!t.description&&!t.icon&&!t.cover&&t.caption==="",It=t=>t==null||Ae(t),_t={bookmark:{check:(t,{validLeaf:e})=>At(t)||_e(t.href)&&Et(t.title,300)&&Et(t.description??"",600)&&It(t.icon)&&It(t.cover)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(At(t))return Ie("bookmark",e);let s=t.title.trim()||new URL(t.href).hostname,o=[`<span class="doc-bookmark-title">${V(s)}</span>`,t.description?`<span class="doc-bookmark-description">${V(t.description)}</span>`:"",`<span class="doc-bookmark-url">${t.icon?`<img class="doc-bookmark-icon" src="${t.icon}" alt="">`:""}<span class="doc-bookmark-href">${V(t.href)}</span></span>`].join(""),n=t.cover?`<span class="doc-bookmark-cover"><img src="${t.cover}" alt=""></span>`:"",a=`<a class="doc-bookmark-card" href="${V(t.href)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text">${o}</span>${n}</a>`;return e.block(`<figure class="doc-bookmark"${e.id}>`,[a,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{BLOCK_TYPES as Be,sizeValue as Me}from"../browser/editor/components/registry.mjs";import{LINE_START as Mt,lineStart as je}from"../browser/shared/code-lines.mjs";import{hasClass as Bt}from"../browser/shared/html-tree.mjs";import{CODE_HEIGHT as rt,FOLDED_LINES as jt,validFolded as Re,validLanguage as De}from"../browser/editor/components/code/index.mjs";var ze=(t,e,s,o,n="",a="",r="",i="")=>`<div class="${t.className}"${s?` data-language="${s}"`:""}${i?` ${Mt}="${i}"`:""}${r?` ${jt}="${r}"`:""}${o?` style="${rt}: ${o}"`:""}${n}><div class="doc-code-title">${a}</div><pre><code>${e}</code></pre></div>`,Ue=(t,e)=>t==="data-language"||t===jt||t===Mt||t==="style"&&new RegExp(`^\\s*${rt}\\s*:[^;]*;?\\s*$`).test(e??""),We=t=>typeof t=="string"&&t.length<=200&&!/[<>\n]|&(?!(amp|lt|gt|quot|#39);)/.test(t),Fe=t=>(t.language===void 0||De(t.language))&&(t.folded===void 0||Re(t.folded))&&(t.height===void 0||Me("code",rt,t.height)===t.height)&&(t.title===void 0||We(t.title))&&(t.lineStart===void 0||typeof t.lineStart=="string"&&String(je(t.lineStart))===t.lineStart);function Ke(t){let{node:e}=t;if(t.tag!=="div"||t.nested||!Bt(e,Be.code.className))return!1;let s=(n,a)=>{let r=n.childNodes??[],i=r.filter(f=>f.tagName);return i.length===a.length&&i.every((f,l)=>f.tagName===a[l])&&r.every(f=>f.tagName||!(f.value??"").trim())?i:null},o=s(e,["div","pre"]);return!!o&&Bt(o[0],"doc-code-title")&&!!s(o[1],["code"])}var Rt={code:{fields:["language","folded","height","title","lineStart"],check:Fe,leaf:(t,e,s)=>ze(t,e.html,e.language,e.height,s,e.title,e.folded,e.lineStart),written:Ke,attribute:Ue}};import{sizeValue as He}from"../browser/editor/components/registry.mjs";import{MIN_COLUMNS as Pe,RATIO as Dt}from"../browser/editor/components/columns/index.mjs";var zt={columns:{check:t=>t.children.length>=Pe&&t.children.every(e=>e.type==="column")},column:{check:t=>t.ratio===void 0||He("column",Dt,t.ratio)===t.ratio,write(t,e){let s=t.ratio===void 0?"":` style="${Dt}: ${t.ratio}"`;return e.block(`<div class="doc-column"${s}${e.id}>`,e.children(e.inner),"</div>")}}};var Ut={details:{empty:!0,check:(t,{validLeaf:e})=>t.title===""||e({tag:"span"},t.title),write(t,e){let s=e.inner===null?null:e.inner+e.step,o=e.block('<div class="doc-details-content">',e.children(s),"</div>",e.inner,s),n=t.classes?.length?` ${t.classes.join(" ")}`:"";return e.block(`<details class="doc-details${n}"${e.id}>`,[`<summary><span class="doc-details-summary-label">${t.title}</span></summary>`,t.children.length>0?o:'<div class="doc-details-content"></div>'],"</details>")}}};var Wt={dialog:{empty:!0,check(t,{usedIds:e}){return typeof t.id!="string"||!/^[A-Za-z][\w-]{0,63}$/.test(t.id)||e.has(t.id)?!1:(e.add(t.id),!0)},write(t,e){let s=t.children.length>0?e.block('<div class="doc-dialog-content">',e.children(e.deep(3)),"</div>",e.deep(2),e.deep(3)):'<div class="doc-dialog-content"></div>',o=e.block('<div class="doc-dialog-panel">',[s],"</div>",e.deep(1),e.deep(2));return e.block(`<dialog class="doc-dialog" id="${t.id}">`,[o],"</dialog>")}}};import{escapeAttribute as Ge}from"../browser/shared/escape.mjs";import{embedFile as Ft}from"../browser/shared/media.mjs";import{emptyFigure as qe}from"../browser/editor/components/media/write.mjs";import{FILE_SANDBOX as Ve,WEB_SANDBOX as Xe}from"../browser/editor/components/embed/index.mjs";var Ye=t=>typeof t=="string"&&t.length<=2e3&&/^https:\/\/[^\s"<>]+$/.test(t),Kt=t=>t.src===""&&t.height===void 0&&t.caption==="",Ht={embed:{check:(t,{validLeaf:e})=>Kt(t)||(Ye(t.src)||Ft(t.src))&&(t.height===void 0||/^\d{2,4}px$/.test(t.height))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Kt(t))return qe("embed",e);let s=Ft(t.src),o=s?/\.pdf$/i.test(t.src)?"":` sandbox="${Ve}"`:` sandbox="${Xe}" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen`,n=`<iframe class="doc-embed-frame" src="${Ge(t.src)}"${o} loading="lazy"></iframe>`,a=t.height?` style="--doc-embed-height: ${t.height}"`:"";return e.block(`<figure class="doc-embed${s?" doc-embed--file":""}"${a}${e.id}>`,[n,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{escapeMarkup as Pt}from"../browser/shared/escape.mjs";import{assetFile as Ze}from"../browser/shared/media.mjs";import{emptyFigure as Je}from"../browser/editor/components/media/write.mjs";var Gt=t=>t.href===""&&t.name===""&&t.size===void 0&&t.caption==="",Qe=t=>typeof t=="string"&&t.trim()!==""&&t.length<=120&&!/[\u0000-\u001f<>:"/\\|?*]/.test(t),qt={file:{check:(t,{validLeaf:e})=>Gt(t)||Ze(t.href)&&Qe(t.name)&&(t.size===void 0||/^\d+(\.\d)? (B|KiB|MiB|GiB)$/.test(t.size))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Gt(t))return Je("file",e);let s=t.size?`<span class="doc-file-size">${t.size}</span>`:"",o=`<a class="doc-file-link" href="${t.href}" download="${Pt(t.name)}"><span class="doc-file-name">${Pt(t.name)}</span>${s}</a>`;return e.block(`<figure class="doc-file"${e.id}>`,[o,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{FLOW as ts,FLOW_DIRECTION as Vt,FLOW_RATIO as Xt}from"../browser/editor/components/flowchart/index.mjs";import{START as es,validDirection as Yt,validStart as ss}from"../browser/editor/components/list/index.mjs";import{sizeValue as ns,TOGGLES as as}from"../browser/editor/components/registry.mjs";var Zt={flowchart:{check:t=>(t.start===void 0||ss(t.start))&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write:(t,e)=>e.block(`<ol class="${ts}"${t.start?` ${es}="${t.start}"`:""}${t.direction?` ${Vt}="${t.direction}"`:""}${e.id}>`,e.children(e.inner),"</ol>")},step:{check:t=>(t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(e=>(as.step??[]).includes(e)))&&(t.ratio===void 0||ns("step",Xt,t.ratio)===t.ratio)&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write(t,e){let s=t.classes?.length?` class="${t.classes.join(" ")}"`:"",o=t.direction?` ${Vt}="${t.direction}"`:"",n=t.ratio===void 0?"":` style="${Xt}: ${t.ratio}"`;return e.block(`<li${s}${o}${n}${e.id}>`,e.children(e.inner),"</li>")}}};import{SPAN as os,SPAN_SIZE as Jt,imageFile as Qt}from"../browser/shared/media.mjs";import{emptyFigure as rs}from"../browser/editor/components/media/write.mjs";var is=/^\d{1,3}(\.\d{1,3})?( \d{1,3}(\.\d{1,3})?){3}$/,te=t=>t.src===""&&t.caption===""&&t.span===void 0&&t.original===void 0&&t.classes===void 0,cs=t=>typeof t=="number"&&Number.isFinite(t)&&t>=Jt.min&&t<=Jt.max,ee={image:{check:(t,{validLeaf:e})=>te(t)||Qt(t.src)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption))&&(t.span===void 0||cs(t.span))&&(t.original===void 0||Qt(t.original)&&typeof t.crop=="string"&&is.test(t.crop)),write(t,e){if(te(t))return rs("image",e);let s=["doc-image",...t.classes??[]].join(" "),o=t.span===void 0?"":` style="${os}: ${Math.round(t.span*1e3)/1e3}"`,n=t.original===void 0?"":` data-original="${t.original}" data-crop="${t.crop}"`;return e.block(`<figure class="${s}"${o}${e.id}>`,[`<img src="${t.src}" alt=""${n}>`,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};vt();import{heldByNode as ls,instanceSlots as fs,isInstance as lt,isSlot as ds,ownSlots as us,partOf as ft}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as G,DATA_MOST as ps,NO_TEXT as ms,PACKAGE_ID as se,SCHEMA as ne,SLOT as ae,fitsDataScript as gs,isDataScript as hs,noDataPart as $s,refusedInCopy as Ns,refusedInData as Os,schemaAhead as oe}from"../browser/shared/components/installed.mjs";import{attr as B,walk as re}from"../browser/shared/html-tree.mjs";import{CHART_KEY as bs,VIEW_FROM as it}from"../browser/shared/table-chart.mjs";var P=(t,e)=>{for(let s=t.parentNode;s;s=s.parentNode)if(s===e)return!0;return!1},xs=t=>{let e=t.parentNode;for(;e&&!lt(e);)e=e.parentNode;return e??null},dt=(t,e)=>xs(t)===e&&ls(t)===e&&!ds(t);function ct(t,e){let o=Object.entries(e.get(B(t,G))?.parts??{}).filter(([,{edit:n}])=>n==="data").map(([n,{at:a}])=>[n,ft(t,a).find(r=>r.sourceCodeLocation&&!lt(r)&&dt(r,t))]).filter(([,n])=>n);return o.filter(([,n],a)=>!o.some(([,r],i)=>P(n,r)||r===n&&i<a))}var ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ks="http://www.w3.org/1999/xhtml",Ts=t=>(t.content??t).childNodes;function ie(t,e,s,o){let n=s;for(let a of Ts(t)){let r=a.sourceCodeLocation;if(r?.startOffset!==n)return!1;if(a.tagName){let{startTag:i,endTag:f}=r,l=ys.has(a.tagName)||a.namespaceURI!==ks&&e.startsWith("/>",r.endOffset-2);if(f?!ie(a,e,i.endOffset,f.startOffset):!l)return!1}n=r.endOffset}return n===o}function Ls(t,e,s){if(e.tagName==="script")return hs(e.tagName,e.attrs)&&gs(s);if($s(e.tagName))return!1;let{startTag:o,endTag:n}=e.sourceCodeLocation,a=t.slice(o.startOffset,o.endOffset),r=`${a}${s}${t.slice(n.startOffset,n.endOffset)}`,[i,...f]=z(e.parentNode,r,{sourceCodeLocationInfo:!0}).childNodes;if(f.length>0||i?.tagName!==e.tagName||i.sourceCodeLocation?.endOffset!==r.length||!i.sourceCodeLocation.endTag||!ie(i,r,a.length,a.length+s.length))return!1;let l=!1;return re(i,m=>{l||=Os(m.tagName,m.attrs)}),!l}var vs=(t,e)=>Object.values(e.get(B(t,G))?.parts??{}).filter(({edit:s})=>s==="text"||s==="data").flatMap(({at:s})=>ft(t,s).filter(o=>dt(o,t))),ce={installed:{slots(t,e){let s=vs(t,e);return fs(t).filter(o=>!s.some(n=>P(o,n)))},boxes(t,e){return this.slots(t,e).map(s=>({element:s,kind:"slot",key:B(s,ae)}))},textParts(t,e){let s=e.get(B(t,G));if(oe(B(t,ne),s?.schema))return[];let o=Object.values(s?.parts??{}).filter(({edit:r})=>r==="text"),n=ct(t,e).map(([,r])=>r),a=[...new Set(o.flatMap(({at:r})=>ft(t,r)))].filter(r=>r.sourceCodeLocation&&!lt(r)&&!ms.has(r.tagName)&&dt(r,t)).filter(r=>!n.some(i=>i===r||P(r,i)||P(i,r)));return a.filter(r=>!a.some(i=>P(r,i))).map(r=>({kind:"installed",part:r}))},source({package:t,html:e,children:s,boxKeys:o,from:n},{packages:a,written:r}){if(typeof t!="string"||!se.test(t))return null;let i=s!==void 0;if(i&&!(Array.isArray(s)&&Array.isArray(o)&&o.length===s.length)||n!=null&&(typeof n!="string"||!bs.test(n)))return null;let f=e===void 0?a.has(t)?Ct(a.get(t)):null:e,l=typeof f=="string"?nt(f,t):null;if(l&&(typeof n=="string"||n===null&&B(l.root,it)!==void 0)&&(l.root.attrs=[...l.root.attrs.filter(({name:L})=>L!==it),...n===null?[]:[{name:it,value:n}]],l=nt(Lt(l.root),t)),!l)return null;let m=us(l.root),u=L=>!L.childNodes.every(N=>N.nodeName==="#text"&&!N.value.trim());if((e!==void 0||!i)&&m.some(u)||i&&!o.every(L=>m.some(N=>B(N,ae)===L)))return null;if(e!==void 0){let L=!1;if(re({childNodes:[l.root]},N=>{L||=Ns(N.tagName,N.attrs)}),L)return null}let v=m.map(L=>L.sourceCodeLocation).sort((L,N)=>N.startOffset-L.startOffset).reduce((L,{startTag:N,endTag:b})=>L.slice(0,N.endOffset)+L.slice(b.startOffset),l.markup);return r(i?v:l.markup)},unwritten:({package:t,html:e},{packages:s})=>e===void 0&&se.test(t)&&!s.has(t)?"no-package":"invalid",definition:(t,e)=>e.get(B(t,G))?.definition,dataOf(t,e,s){let o=ct(e,s).filter(([,n])=>n.sourceCodeLocation.endTag);return o.length>0?Object.fromEntries(o.map(([n,a])=>[n,t.slice(a.sourceCodeLocation.startTag.endOffset,a.sourceCodeLocation.endTag.startOffset)])):null},rewrite(t,e,s,{packages:o}){let n=new Map(ct(e,o)),a=Object.keys(s),r=a.map(f=>s[f]);if(oe(B(e,ne),o.get(B(e,G))?.schema)||a.length===0||!r.every(f=>typeof f=="string")||!a.every(f=>n.has(f))||r.reduce((f,l)=>f+Buffer.byteLength(l),0)>ps||!a.every(f=>n.get(f).sourceCodeLocation.endTag&&Ls(t,n.get(f),s[f])))return null;let i=t.includes(`\r
3
3
  `)?`\r
4
4
  `:`
5
5
  `;return a.map(f=>{let{startTag:l,endTag:m}=n.get(f).sourceCodeLocation;return{start:l.endOffset,end:m.startOffset,text:s[f].replace(/\r?\n/g,i)}})}}};vt();import{IDENTITY as Ss}from"../browser/editor/components/registry.mjs";import{SHEETS as X,TABLE as le}from"../browser/editor/components/kit.mjs";import{escapeAttribute as Y,escapeText as ut}from"../browser/shared/escape.mjs";import{isInstance as Cs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{attr as j}from"../browser/shared/html-tree.mjs";import{CHART_SOURCE as fe,TABLE_READERS as ws}from"../browser/shared/table-chart.mjs";import{freshPrefix as Es,referencedIds as As,rewrite as Is}from"../browser/shared/copy-ids.mjs";var de=(t={})=>Object.entries(t).map(([e,s])=>s===""?` ${e}`:` ${e}="${Y(String(s))}"`).join(""),ue=(t,e)=>t[e-1]==="/"?e-1:e;function Z(t,e,s){let o=e;for(;o>0&&/\s/.test(t[o-1]);)o--;return{start:o,end:s}}function Sa(t){let e=s=>s.nodeName==="#text"?s.value:(s.childNodes??[]).map(e).join("");return e(z(t)).replace(/\s+/g," ").trim()}function Ca(t,{from:e,to:s}){let n=pe(st(t,{sourceCodeLocationInfo:!0}))?.sourceCodeLocation;if(!n?.endTag)return null;let a=t.slice(n.startTag.endOffset,n.endTag.startOffset);if(!e)return a.trim()===""?{start:n.startTag.endOffset,end:n.endTag.startOffset,text:ut(s)}:null;let r=ut(e),i=a.indexOf(r);if(i<0||a.indexOf(r,i+1)>=0)return null;let f=n.startTag.endOffset+i;return{start:f,end:f+r.length,text:ut(s)}}function pe(t){for(let e of t.childNodes??[]){if(e.tagName==="title")return e;if(e.tagName==="body")continue;let s=e.tagName&&pe(e);if(s)return s}return null}function _s(t){let e=[],s=0,o=null,n=0;for(let a=0;a<t.length;a++){let r=t[a];if(r==="&"){let i=/^&(#\d+|#x[\da-f]+|[a-z]\w*);/i.exec(t.slice(a));i&&(a+=i[0].length-1)}else o?r===o?o=null:r==="\\"&&a++:r==='"'||r==="'"?o=r:r==="("?s++:r===")"?s=Math.max(0,s-1):r===";"&&s===0&&(e.push(t.slice(n,a)),n=a+1)}return e.push(t.slice(n)),e.map(a=>a.trim()).filter(Boolean)}function ht(t,e){let s=_s(t);for(let[o,n]of e){let a=s.findIndex(r=>r.slice(0,r.indexOf(":")).trim()===o);n===null?a>=0&&s.splice(a,1):a>=0?s[a]=`${o}: ${n}`:s.push(`${o}: ${n}`)}return s.join("; ")}var Bs=new Set(["pre","textarea","script","style"]);function wa(t){if(typeof t!="string"||!t.trim())return null;let s=z(t,{sourceCodeLocationInfo:!0}).childNodes.filter(f=>f.nodeName!=="#comment"&&!(f.nodeName==="#text"&&!f.value.trim())),[o,n]=s;if(s.length===2&&o.tagName==="button"&&pt(o,X.tab)&&n.tagName&&n.sourceCodeLocation?.endTag&&j(o,X.tabKey)&&j(n,X.panelKey)===j(o,X.tabKey)){let f=o.sourceCodeLocation.endOffset;return{element:o,source:t.slice(0,f),panel:t.slice(f).replace(/^\s+/,""),kind:"tab"}}let a=s.at(-1),r=s.length===2?s[0]:null;if(!a?.tagName||!a.sourceCodeLocation?.startTag||s.length>2||r&&!(r.tagName&&pt(r,le.lead)&&pt(a,le.frame)))return null;let i=W(a);return{element:a,source:t,kind:i}}function Ms(t){let e=[],s=o=>{for(let n of o.childNodes??[]){if(!n.tagName)continue;let a=j(n,"id");a&&e.push(a),s(n.tagName==="template"?n.content:n)}};return s(st(t)),e}var Ea=(t,e)=>`${mt(t.slice(e.start,e.end),U(t,e.start),"")}
@@ -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{D as $,a as H,c as y,d as v,e as q,f as K,g as Y,i as V,k as X,o as z}from"./chunk-7XDYK3UC.mjs";import{g as P}from"./chunk-VG5JEIUQ.mjs";import{b as S,e as U}from"./chunk-N3DSBH5S.mjs";U();import{HOSTS as A,IDENTITY as dt}from"../browser/editor/components/registry.mjs";import{CODE as ut,MATH as tt,MEDIA as mt,PAGE as pt,TABLE as gt}from"../browser/editor/components/kit.mjs";import{TAB as ht}from"../browser/editor/components/paragraph/index.mjs";import{componentOf as Nt,isInstance as w,matchesNode as x,partOf as bt}from"../browser/shared/components/index.mjs";import{texSource as It}from"../browser/editor/components/math/index.mjs";import{MENTION as M,MENTION_ICON as J,MENTION_PAGE as Q}from"../browser/shared/components/mention.mjs";import{imageFile as et}from"../browser/shared/media.mjs";import{isFileLink as kt}from"../browser/shared/page-address.mjs";import{isInkClass as xt}from"../browser/editor/page/marks.mjs";import{ownInline as Tt}from"../browser/editor/page/own.mjs";import{attr as h,hasClass as Ot}from"../browser/shared/html-tree.mjs";var Lt=new Set(["h1","h2","h3","h4","p","li"]),Ct=new Set(["h3","h4","p","figcaption"]),Et=Object.entries(A).flatMap(([t,e])=>(e.parts??[]).map(([r,a])=>{let c=Nt(r);if(c?.parts?.[a]?.edit!=="text")throw new Error(`Host ${t}: ${r} has no part ${a} edited as text`);return{kind:t,match:c.match,at:c.parts[a].at}})),St=t=>Et.filter(({match:e})=>x(t,e)).flatMap(({kind:e,at:r})=>bt(t,r).map(a=>({kind:e,part:a}))),vt=t=>t.sort((e,r)=>e.part.sourceCodeLocation.startOffset-r.part.sourceCodeLocation.startOffset),$t=new Set(["strong","em","b","i","u","s","code","a","br","sup","sub"]),wt=new Set(["ul","ol","blockquote"]),_=new Set(["pre","summary","button","label","select","textarea","form","template","script","style","svg","math","iframe","object","noscript","canvas","video","audio"]),le={p:"p",h1:"p",h2:"p",h3:"p",h4:"p",li:"li"};function At(t,e,r){let a=A[t];if(!a)throw new Error(`Unknown block kind ${t}`);return a.caps({bound:r,blockLevel:y.has(e)})}var st=t=>t.tagName==="span"&&x(t,tt.inline),Bt=t=>t.tagName==="a"&&Ot(t,M),Pt=/^https?:\/\/[^\s"<>]+$/i,C=t=>t.attrs.map(e=>e.name).sort().join(),yt=t=>h(t,"class")===M&&t.childNodes.length===0&&(C(t)==="class"||C(t)===`class,${Q}`&&h(t,Q)==="");function _t(t){if(yt(t))return null;if(C(t)!=="class,href"||h(t,"class")!==M||!(Pt.test(h(t,"href"))||kt(h(t,"href"))))return"mention";let[e,...r]=t.childNodes;return(e?.tagName==="img"?C(e)==="alt,class,src"&&h(e,"class")===J&&h(e,"alt")===""&&et(h(e,"src")):e?.tagName==="span"&&C(e)==="class"&&h(e,"class")===J&&e.childNodes.length===0)&&r.length>0&&r.every(c=>c.nodeName==="#text")&&r.some(c=>c.value.trim())?null:"mention"}var Mt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value.trim().split(/\s+/).every(xt),jt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value===ht,ot=t=>$t.has(t.tagName)||Mt(t)||jt(t),B=t=>(t.childNodes??[]).some(e=>e.nodeName==="#text"?e.value.trim()!=="":B(e)),at=t=>Tt(t.tagName,t.attrs,B(t)),Z=t=>t.attrs.some(e=>e.name==="id"||e.name.startsWith("data-")&&e.name!==dt),Wt=t=>/^(javascript|vbscript|data):/i.test(t.replace(/[\u0000- ]/g,"")),Dt=(t,e,r={})=>t==="text"?y.has(e)?!1:"atoms":t==="title"||t==="code"||t==="codeTitle"||t==="tex"||!!r.plain;function j(t,e,r=!1,{cell:a=!1,pictures:c=a,known:l=null}={}){for(let n of t.childNodes){if(n.nodeName==="#text")continue;if(!n.tagName)return"comment";if(r===!0)return`tag:${n.tagName}`;if(n.attrs.some(m=>/^on/i.test(m.name)))return"markup";if(r==="atoms"){if(!n.sourceCodeLocation?.endTag&&n.tagName!=="br")return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(a&&(n.tagName==="ul"||n.tagName==="ol")){let m=Ut(n,e,l);if(m)return m;continue}if(c&&n.tagName==="img"){if(Ft(n))return"picture";continue}if(st(n)){if(n.childNodes.some(m=>m.nodeName!=="#text"))return"markup";e.push(n.sourceCodeLocation);continue}if(Bt(n)){let m=_t(n);if(m)return m;e.push(n.sourceCodeLocation);continue}if(at(n)){if(!n.sourceCodeLocation?.endTag)return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(!ot(n))return`tag:${n.tagName}`;if(n.tagName!=="br"&&!n.sourceCodeLocation?.endTag)return"markup";if(n.tagName==="a"&&Wt(h(n,"href")??""))return"link";let N=j(n,e,!1,{known:l,pictures:c});if(N)return N}return null}var Gt=["src","alt","width"],Rt=/^[1-9]\d{0,3}$/;function Ft(t){let r=t.attrs.map(l=>l.name).find(l=>!Gt.includes(l));if(r)return`the attribute ${r}`;let a=h(t,"src");if(!et(a))return`its src (${a===void 0?"none":a.slice(0,80)}): no picture of the document's assets/ folder`;let c=h(t,"width");return c===void 0||Rt.test(c)?null:`its width (${c}): a whole number of pixels`}function Ut(t,e,r){if(t.attrs.length>0||!t.sourceCodeLocation?.endTag)return"markup";for(let a of t.childNodes){if(a.nodeName==="#text"&&!a.value.trim())continue;if(a.tagName!=="li")return`tag:${a.tagName??"text"}`;if(a.attrs.length>0||!a.sourceCodeLocation?.endTag)return"markup";let c=j(a,e,!1,{known:r,pictures:!0});if(c)return c}return null}function T(t){let e=[],r=[],a=new Map,c=null,l=(o,s,i=null)=>{let u=o.sourceCodeLocation;if(!A[s]||!u?.startTag||h(o,"contenteditable")!==void 0)return!1;let k=[],f=Dt(s,o.tagName),p=i?{childNodes:o.childNodes.slice(0,o.childNodes.indexOf(i))}:o,G=u.endTag?j(p,k,f,{cell:s==="cell"}):"markup";if(G)return r.push({at:u.startTag.endOffset-1,reason:G}),!1;let L=u.startTag.endOffset,ft=i?L+t.slice(L,i.sourceCodeLocation.startOffset).replace(/[ \t\r\n\f]+$/,"").length:u.endTag.startOffset,R={id:e.length,tag:o.tagName,kind:s,bound:!1,caps:{},start:u.startOffset,end:u.endOffset,innerStart:L,innerEnd:ft,atoms:k.map(F=>[F.startOffset-L,F.endOffset-L]),wrapper:null,nested:!!i,node:o};return e.push(R),a.set(o,R),!0},n=o=>(o.childNodes??[]).filter(s=>s.tagName),N=o=>{let s=o.sourceCodeLocation;return s?.startTag&&s.endTag?t.slice(s.startTag.endOffset,s.endTag.startOffset):null},m=o=>o.tagName!=="a"&&!Z(o)&&B(o)&&n(o).every(s=>at(s)?!B(s):ot(s)||st(s)),I=o=>{for(let s of n(o))s.tagName==="td"||s.tagName==="th"?l(s,"cell"):["thead","tbody","tfoot","tr"].includes(s.tagName)&&I(s)},d=o=>{for(let s of n(o))s.tagName==="table"?I(s):!_.has(s.tagName)&&!w(s)&&d(s)},b=o=>{let s=n(o);s.length===1&&s[0].tagName==="code"&&o.childNodes.every(i=>i.tagName||!i.value?.trim())?l(s[0],"code"):s.length===0?l(o,"code"):o.sourceCodeLocation?.startTag&&r.push({at:o.sourceCodeLocation.startTag.endOffset-1,reason:"markup"})},g=(o,s=!0)=>{for(let i of n(o)){let u=i.tagName,k=w(i);for(let{kind:f,part:p}of vt(k?$[V(i)].textParts(i,c??=P().packages):St(i)))l(p,f);if(k){for(let{element:f}of Y(i))g(f,s);continue}if(u==="div"&&x(i,ut.match)){for(let f of n(i))f.tagName==="pre"&&h(f,"contenteditable")===void 0&&b(f);continue}if(!(_.has(u)||h(i,"contenteditable")!==void 0))if(u==="table")I(i);else if(u==="figure"){let f=x(i,mt);for(let p of n(i))if(!(f&&p.tagName==="figcaption"))if(Ct.has(p.tagName))l(p,"field");else if(p.tagName==="table")I(p);else{if(_.has(p.tagName))continue;w(p)?g({childNodes:[p]},s):f||v(p)||Z(p)?d(p):g({childNodes:[p]},s)}}else if(u==="details")for(let f of n(i))w(f)?g({childNodes:[f]},s):f.tagName!=="summary"&&g(f,s);else if(u==="h1"&&(o.tagName==="header"||x(i,pt.title)))l(i,"title");else if(u==="li"&&K(i))g({childNodes:n(i)},s);else if(Lt.has(u)){let f=u==="li"?q(i):[];f?.length>0?(l(i,"flow",f[0]),g({childNodes:f},s)):l(i,"flow")||g(i,!1)}else if(u==="div"&&x(i,tt.block)&&n(i).length===0&&It(N(i)))l(i,"tex");else if(u==="div"&&x(i,gt.lead))for(let f of n(i))f.tagName==="span"&&l(f,"field");else s&&!v(i)&&m(i)?l(i,"text"):(g(i,s&&!v(i)),wt.has(u)&&it(i))}},it=o=>{let s=o.sourceCodeLocation,i=n(o).map(f=>a.get(f));if(!(i.length>0&&i.every(Boolean)&&o.childNodes.every(f=>f.tagName||f.nodeName==="#text"&&!f.value.trim()))||!s?.endTag)return;let k={start:s.startOffset,end:s.endOffset,ids:i.map(f=>f.id)};i.forEach(f=>f.wrapper=k)},W=o=>{for(let s of n(o))(s.tagName==="main"?g:W)(s)},D=S(t,{sourceCodeLocationInfo:!0});W(D);let{units:E,boxes:ct,referenced:lt}=X(D,t);for(let o of E)o.grid=!!$[o.kind]?.plain?.(o.node);for(let o of E){let s=$[o.kind]?.dataOf?.(t,o.node,c??=P().packages);s&&(o.parts=Object.fromEntries(Object.entries(s).map(([i,u])=>[i,H(u)])))}for(let o of e){let s=null;for(let i of E)i.start<=o.start&&o.start<i.end&&(!s||i.start>s.start)&&(s=i);o.unit=s?.id??null,o.self=s&&s.at===o.innerStart-1?s.id:null,o.self!==null&&(s.text=o.id),o.path=s&&o.self===null?Ht(s,o.node):null,A.text&&o.kind==="flow"&&o.self===null&&(s?.kind==="block"||s?.kind==="figure")&&(o.kind="text"),o.bound=lt(o.node)!==null,o.caps=Object.fromEntries(At(o.kind,o.tag,o.bound).map(i=>[i,!0]))}return{blocks:e,locks:r,units:E,boxes:ct}}function Ht(t,e){let r=[],a=e;for(;a&&!t.nodes.includes(a);a=a.parentNode){let c=(a.parentNode?.childNodes??[]).filter(l=>l.tagName===a.tagName);r.unshift([a.tagName,c.indexOf(a),c.length])}return a?[a===t.node?"unit":a===t.nodes[0]&&t.lead!==null?"lead":"panel",...r]:null}var fe=t=>T(t).blocks;function de(t){let{units:e,boxes:r}=T(t);return{units:e,boxes:r}}U();import{randomBlockId as qt}from"../browser/shared/ids.mjs";import{IDENTITY as O}from"../browser/editor/components/registry.mjs";var Kt=/\sdata-block-id\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;function be(t,e=qt){let{units:r}=T(t),a=new Set([...t.matchAll(Kt)].map(d=>d[1]??d[2])),c=()=>{for(;;){let d=e();if(!a.has(d))return a.add(d)&&d}},l=new Set,n=[],N=[],m=[];for(let d of r)if(d.blockId)l.has(d.blockId)&&d.blockIdAttr?(N.push(d.blockId),n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${c()}"`})):l.add(d.blockId);else{let b=c();if(d.blockIdAttr)n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${b}"`});else{let g=z(t,d.at);n.push({start:g,end:g,text:` ${O}="${b}"`})}m.push({id:b,tag:rt(d.tag,d.attrs),at:d.elStart})}let I=t;for(let d of n.sort((b,g)=>g.start-b.start))I=I.slice(0,d.start)+d.text+I.slice(d.end);return m.sort((d,b)=>d.at-b.at),{text:I,added:m.length,renamed:N,given:m.map(({id:d,tag:b})=>({id:d,tag:b}))}}function Ie(t){let e=nt(t);return T(t).units.filter(r=>!r.blockId).sort((r,a)=>r.elStart-a.elStart).map(r=>({line:e(r.elStart),tag:rt(r.tag,r.attrs)}))}function ke(t,e){let r=new Map(e.map(c=>[c.id,c])),a=nt(t);return T(t).units.filter(c=>r.has(c.blockId)).sort((c,l)=>c.elStart-l.elStart).map(c=>({...r.get(c.blockId),line:a(c.elStart)}))}function nt(t){let e=[0];for(let r=t.indexOf(`
2
+ import{D as $,a as H,c as y,d as v,e as q,f as K,g as Y,i as V,k as X,o as z}from"./chunk-E7656LR7.mjs";import{g as P}from"./chunk-TKWEX4FD.mjs";import{b as S,e as U}from"./chunk-A55HN5OK.mjs";U();import{HOSTS as A,IDENTITY as dt}from"../browser/editor/components/registry.mjs";import{CODE as ut,MATH as tt,MEDIA as mt,PAGE as pt,TABLE as gt}from"../browser/editor/components/kit.mjs";import{TAB as ht}from"../browser/editor/components/paragraph/index.mjs";import{componentOf as Nt,isInstance as w,matchesNode as x,partOf as bt}from"../browser/shared/components/index.mjs";import{texSource as It}from"../browser/editor/components/math/index.mjs";import{MENTION as M,MENTION_ICON as J,MENTION_PAGE as Q}from"../browser/shared/components/mention.mjs";import{imageFile as et}from"../browser/shared/media.mjs";import{isFileLink as kt}from"../browser/shared/page-address.mjs";import{isInkClass as xt}from"../browser/editor/page/marks.mjs";import{ownInline as Tt}from"../browser/editor/page/own.mjs";import{attr as h,hasClass as Ot}from"../browser/shared/html-tree.mjs";var Lt=new Set(["h1","h2","h3","h4","p","li"]),Ct=new Set(["h3","h4","p","figcaption"]),Et=Object.entries(A).flatMap(([t,e])=>(e.parts??[]).map(([r,a])=>{let c=Nt(r);if(c?.parts?.[a]?.edit!=="text")throw new Error(`Host ${t}: ${r} has no part ${a} edited as text`);return{kind:t,match:c.match,at:c.parts[a].at}})),St=t=>Et.filter(({match:e})=>x(t,e)).flatMap(({kind:e,at:r})=>bt(t,r).map(a=>({kind:e,part:a}))),vt=t=>t.sort((e,r)=>e.part.sourceCodeLocation.startOffset-r.part.sourceCodeLocation.startOffset),$t=new Set(["strong","em","b","i","u","s","code","a","br","sup","sub"]),wt=new Set(["ul","ol","blockquote"]),_=new Set(["pre","summary","button","label","select","textarea","form","template","script","style","svg","math","iframe","object","noscript","canvas","video","audio"]),le={p:"p",h1:"p",h2:"p",h3:"p",h4:"p",li:"li"};function At(t,e,r){let a=A[t];if(!a)throw new Error(`Unknown block kind ${t}`);return a.caps({bound:r,blockLevel:y.has(e)})}var st=t=>t.tagName==="span"&&x(t,tt.inline),Bt=t=>t.tagName==="a"&&Ot(t,M),Pt=/^https?:\/\/[^\s"<>]+$/i,C=t=>t.attrs.map(e=>e.name).sort().join(),yt=t=>h(t,"class")===M&&t.childNodes.length===0&&(C(t)==="class"||C(t)===`class,${Q}`&&h(t,Q)==="");function _t(t){if(yt(t))return null;if(C(t)!=="class,href"||h(t,"class")!==M||!(Pt.test(h(t,"href"))||kt(h(t,"href"))))return"mention";let[e,...r]=t.childNodes;return(e?.tagName==="img"?C(e)==="alt,class,src"&&h(e,"class")===J&&h(e,"alt")===""&&et(h(e,"src")):e?.tagName==="span"&&C(e)==="class"&&h(e,"class")===J&&e.childNodes.length===0)&&r.length>0&&r.every(c=>c.nodeName==="#text")&&r.some(c=>c.value.trim())?null:"mention"}var Mt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value.trim().split(/\s+/).every(xt),jt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value===ht,ot=t=>$t.has(t.tagName)||Mt(t)||jt(t),B=t=>(t.childNodes??[]).some(e=>e.nodeName==="#text"?e.value.trim()!=="":B(e)),at=t=>Tt(t.tagName,t.attrs,B(t)),Z=t=>t.attrs.some(e=>e.name==="id"||e.name.startsWith("data-")&&e.name!==dt),Wt=t=>/^(javascript|vbscript|data):/i.test(t.replace(/[\u0000- ]/g,"")),Dt=(t,e,r={})=>t==="text"?y.has(e)?!1:"atoms":t==="title"||t==="code"||t==="codeTitle"||t==="tex"||!!r.plain;function j(t,e,r=!1,{cell:a=!1,pictures:c=a,known:l=null}={}){for(let n of t.childNodes){if(n.nodeName==="#text")continue;if(!n.tagName)return"comment";if(r===!0)return`tag:${n.tagName}`;if(n.attrs.some(m=>/^on/i.test(m.name)))return"markup";if(r==="atoms"){if(!n.sourceCodeLocation?.endTag&&n.tagName!=="br")return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(a&&(n.tagName==="ul"||n.tagName==="ol")){let m=Ut(n,e,l);if(m)return m;continue}if(c&&n.tagName==="img"){if(Ft(n))return"picture";continue}if(st(n)){if(n.childNodes.some(m=>m.nodeName!=="#text"))return"markup";e.push(n.sourceCodeLocation);continue}if(Bt(n)){let m=_t(n);if(m)return m;e.push(n.sourceCodeLocation);continue}if(at(n)){if(!n.sourceCodeLocation?.endTag)return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(!ot(n))return`tag:${n.tagName}`;if(n.tagName!=="br"&&!n.sourceCodeLocation?.endTag)return"markup";if(n.tagName==="a"&&Wt(h(n,"href")??""))return"link";let N=j(n,e,!1,{known:l,pictures:c});if(N)return N}return null}var Gt=["src","alt","width"],Rt=/^[1-9]\d{0,3}$/;function Ft(t){let r=t.attrs.map(l=>l.name).find(l=>!Gt.includes(l));if(r)return`the attribute ${r}`;let a=h(t,"src");if(!et(a))return`its src (${a===void 0?"none":a.slice(0,80)}): no picture of the document's assets/ folder`;let c=h(t,"width");return c===void 0||Rt.test(c)?null:`its width (${c}): a whole number of pixels`}function Ut(t,e,r){if(t.attrs.length>0||!t.sourceCodeLocation?.endTag)return"markup";for(let a of t.childNodes){if(a.nodeName==="#text"&&!a.value.trim())continue;if(a.tagName!=="li")return`tag:${a.tagName??"text"}`;if(a.attrs.length>0||!a.sourceCodeLocation?.endTag)return"markup";let c=j(a,e,!1,{known:r,pictures:!0});if(c)return c}return null}function T(t){let e=[],r=[],a=new Map,c=null,l=(o,s,i=null)=>{let u=o.sourceCodeLocation;if(!A[s]||!u?.startTag||h(o,"contenteditable")!==void 0)return!1;let k=[],f=Dt(s,o.tagName),p=i?{childNodes:o.childNodes.slice(0,o.childNodes.indexOf(i))}:o,G=u.endTag?j(p,k,f,{cell:s==="cell"}):"markup";if(G)return r.push({at:u.startTag.endOffset-1,reason:G}),!1;let L=u.startTag.endOffset,ft=i?L+t.slice(L,i.sourceCodeLocation.startOffset).replace(/[ \t\r\n\f]+$/,"").length:u.endTag.startOffset,R={id:e.length,tag:o.tagName,kind:s,bound:!1,caps:{},start:u.startOffset,end:u.endOffset,innerStart:L,innerEnd:ft,atoms:k.map(F=>[F.startOffset-L,F.endOffset-L]),wrapper:null,nested:!!i,node:o};return e.push(R),a.set(o,R),!0},n=o=>(o.childNodes??[]).filter(s=>s.tagName),N=o=>{let s=o.sourceCodeLocation;return s?.startTag&&s.endTag?t.slice(s.startTag.endOffset,s.endTag.startOffset):null},m=o=>o.tagName!=="a"&&!Z(o)&&B(o)&&n(o).every(s=>at(s)?!B(s):ot(s)||st(s)),I=o=>{for(let s of n(o))s.tagName==="td"||s.tagName==="th"?l(s,"cell"):["thead","tbody","tfoot","tr"].includes(s.tagName)&&I(s)},d=o=>{for(let s of n(o))s.tagName==="table"?I(s):!_.has(s.tagName)&&!w(s)&&d(s)},b=o=>{let s=n(o);s.length===1&&s[0].tagName==="code"&&o.childNodes.every(i=>i.tagName||!i.value?.trim())?l(s[0],"code"):s.length===0?l(o,"code"):o.sourceCodeLocation?.startTag&&r.push({at:o.sourceCodeLocation.startTag.endOffset-1,reason:"markup"})},g=(o,s=!0)=>{for(let i of n(o)){let u=i.tagName,k=w(i);for(let{kind:f,part:p}of vt(k?$[V(i)].textParts(i,c??=P().packages):St(i)))l(p,f);if(k){for(let{element:f}of Y(i))g(f,s);continue}if(u==="div"&&x(i,ut.match)){for(let f of n(i))f.tagName==="pre"&&h(f,"contenteditable")===void 0&&b(f);continue}if(!(_.has(u)||h(i,"contenteditable")!==void 0))if(u==="table")I(i);else if(u==="figure"){let f=x(i,mt);for(let p of n(i))if(!(f&&p.tagName==="figcaption"))if(Ct.has(p.tagName))l(p,"field");else if(p.tagName==="table")I(p);else{if(_.has(p.tagName))continue;w(p)?g({childNodes:[p]},s):f||v(p)||Z(p)?d(p):g({childNodes:[p]},s)}}else if(u==="details")for(let f of n(i))w(f)?g({childNodes:[f]},s):f.tagName!=="summary"&&g(f,s);else if(u==="h1"&&(o.tagName==="header"||x(i,pt.title)))l(i,"title");else if(u==="li"&&K(i))g({childNodes:n(i)},s);else if(Lt.has(u)){let f=u==="li"?q(i):[];f?.length>0?(l(i,"flow",f[0]),g({childNodes:f},s)):l(i,"flow")||g(i,!1)}else if(u==="div"&&x(i,tt.block)&&n(i).length===0&&It(N(i)))l(i,"tex");else if(u==="div"&&x(i,gt.lead))for(let f of n(i))f.tagName==="span"&&l(f,"field");else s&&!v(i)&&m(i)?l(i,"text"):(g(i,s&&!v(i)),wt.has(u)&&it(i))}},it=o=>{let s=o.sourceCodeLocation,i=n(o).map(f=>a.get(f));if(!(i.length>0&&i.every(Boolean)&&o.childNodes.every(f=>f.tagName||f.nodeName==="#text"&&!f.value.trim()))||!s?.endTag)return;let k={start:s.startOffset,end:s.endOffset,ids:i.map(f=>f.id)};i.forEach(f=>f.wrapper=k)},W=o=>{for(let s of n(o))(s.tagName==="main"?g:W)(s)},D=S(t,{sourceCodeLocationInfo:!0});W(D);let{units:E,boxes:ct,referenced:lt}=X(D,t);for(let o of E)o.grid=!!$[o.kind]?.plain?.(o.node);for(let o of E){let s=$[o.kind]?.dataOf?.(t,o.node,c??=P().packages);s&&(o.parts=Object.fromEntries(Object.entries(s).map(([i,u])=>[i,H(u)])))}for(let o of e){let s=null;for(let i of E)i.start<=o.start&&o.start<i.end&&(!s||i.start>s.start)&&(s=i);o.unit=s?.id??null,o.self=s&&s.at===o.innerStart-1?s.id:null,o.self!==null&&(s.text=o.id),o.path=s&&o.self===null?Ht(s,o.node):null,A.text&&o.kind==="flow"&&o.self===null&&(s?.kind==="block"||s?.kind==="figure")&&(o.kind="text"),o.bound=lt(o.node)!==null,o.caps=Object.fromEntries(At(o.kind,o.tag,o.bound).map(i=>[i,!0]))}return{blocks:e,locks:r,units:E,boxes:ct}}function Ht(t,e){let r=[],a=e;for(;a&&!t.nodes.includes(a);a=a.parentNode){let c=(a.parentNode?.childNodes??[]).filter(l=>l.tagName===a.tagName);r.unshift([a.tagName,c.indexOf(a),c.length])}return a?[a===t.node?"unit":a===t.nodes[0]&&t.lead!==null?"lead":"panel",...r]:null}var fe=t=>T(t).blocks;function de(t){let{units:e,boxes:r}=T(t);return{units:e,boxes:r}}U();import{randomBlockId as qt}from"../browser/shared/ids.mjs";import{IDENTITY as O}from"../browser/editor/components/registry.mjs";var Kt=/\sdata-block-id\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;function be(t,e=qt){let{units:r}=T(t),a=new Set([...t.matchAll(Kt)].map(d=>d[1]??d[2])),c=()=>{for(;;){let d=e();if(!a.has(d))return a.add(d)&&d}},l=new Set,n=[],N=[],m=[];for(let d of r)if(d.blockId)l.has(d.blockId)&&d.blockIdAttr?(N.push(d.blockId),n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${c()}"`})):l.add(d.blockId);else{let b=c();if(d.blockIdAttr)n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${b}"`});else{let g=z(t,d.at);n.push({start:g,end:g,text:` ${O}="${b}"`})}m.push({id:b,tag:rt(d.tag,d.attrs),at:d.elStart})}let I=t;for(let d of n.sort((b,g)=>g.start-b.start))I=I.slice(0,d.start)+d.text+I.slice(d.end);return m.sort((d,b)=>d.at-b.at),{text:I,added:m.length,renamed:N,given:m.map(({id:d,tag:b})=>({id:d,tag:b}))}}function Ie(t){let e=nt(t);return T(t).units.filter(r=>!r.blockId).sort((r,a)=>r.elStart-a.elStart).map(r=>({line:e(r.elStart),tag:rt(r.tag,r.attrs)}))}function ke(t,e){let r=new Map(e.map(c=>[c.id,c])),a=nt(t);return T(t).units.filter(c=>r.has(c.blockId)).sort((c,l)=>c.elStart-l.elStart).map(c=>({...r.get(c.blockId),line:a(c.elStart)}))}function nt(t){let e=[0];for(let r=t.indexOf(`
3
3
  `);r!==-1;r=t.indexOf(`
4
4
  `,r+1))e.push(r+1);return r=>{let[a,c]=[0,e.length-1];for(;a<c;){let l=a+c+1>>1;e[l]<=r?a=l:c=l-1}return a+1}}function rt(t,e=[]){let r=e.filter(({name:l})=>l!==O&&l!=="style"),a=l=>{let n=l.replace(/\s+/g," "),N=n.length>32?`${n.slice(0,31)}\u2026`:n;return N===""?"":/[\s"'=<>`]/.test(N)?`="${N.replaceAll('"',"&quot;")}"`:`=${N}`},c=r.slice(0,3).map(({name:l,value:n})=>`${l}${a(n)}`);return`<${[t,...c,...r.length>3?["\u2026"]:[]].join(" ")}>`}function xe(t){let e=new Map,r=a=>{let c=a.attrs?.find(n=>n.name===O)?.value,l=a.sourceCodeLocation?.attrs?.[O]??a.sourceCodeLocation;c!==void 0&&e.set(c,[...e.get(c)??[],l]);for(let n of a.content?.childNodes??a.childNodes??[])r(n)};return r(S(t,{sourceCodeLocationInfo:!0})),[...e].filter(([,a])=>a.length>1).map(([a,c])=>({id:a,lines:c.map(l=>l?.startLine),columns:c.map(l=>l?.startCol)}))}export{le as a,Dt as b,j as c,Ft as d,T as e,fe as f,de as g,qt as h,Kt as i,be as j,Ie as k,ke as l,xe as m};
@@ -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{$ as zr,$a as $t,$b as ks,A as K,Aa as wt,Ab as ls,Ac as li,B as _,Ba as gt,Bb as fs,Bc as fi,Ca as bt,Cb as ps,Cc as pi,Da as Et,Db as ds,Dc as di,E as _r,Ea as xt,Eb as hs,Ec as hi,F as we,Fa as yt,Fb as ms,Fc as mi,G as Br,Ga as Dt,Gb as ws,Gc as wi,H as Sr,Ha as Pt,Hb as gs,Hc as gi,I as Fr,Ia as vt,Ib as bs,Ic as bi,J as Tr,Ja as Ot,Jb as Es,Jc as Ei,K as Ir,Ka as _t,Kb as xs,Kc as xi,L as Rr,Lb as Q,Lc as yi,M as ge,Mb as ys,Mc as Di,N as Cr,Nb as Ds,Nc as Pi,O as Ar,Oa as J,Ob as Ps,Oc as vi,P as Lr,Pb as vs,Pc as Oi,Q as kr,Qa as Bt,Qb as Os,Qc as _i,R as Wr,Ra as St,Rb as _s,Rc as Bi,S as $r,Sa as Ft,Sb as Bs,Sc as ye,T as Ur,Ta as Tt,Tb as Ss,Tc as Si,U as Nr,Ua as It,Ub as Fs,Uc as Fi,V as Mr,Va as Rt,Vb as Ts,Vc as Ti,W as Gr,Wa as Ct,Wb as Is,Wc as Ri,X as Vr,Xa as At,Xb as Rs,Xc as Ae,Y as jr,Ya as Lt,Yb as Cs,Yc as Le,Z as Xr,Za as kt,Zb as As,Zc as Ci,_ as Hr,_a as Wt,_b as Ls,_c as q,a as k,aa as Yr,ab as Ut,ac as Ws,ba as Kr,bb as Nt,bc as $s,c as oe,ca as Jr,cb as Mt,cc as Us,d as ae,da as Qr,db as Gt,dc as Ns,e as W,ea as be,eb as Vt,ec as Ms,fa as Zr,fb as jt,fc as Gs,ga as qr,gb as Xt,gc as Vs,h as ne,ha as et,hb as Ht,hc as js,i as ce,ia as rt,ib as zt,ic as Xs,j as ue,ja as tt,jb as Yt,jc as Hs,k as le,ka as st,kb as Kt,kc as zs,l as fe,la as it,lb as xe,lc as Ys,m as pe,ma as Ee,mb as Jt,mc as Ks,na as ot,nb as Qt,nc as Js,oa as at,ob as Zt,oc as Qs,pa as nt,pb as qt,pc as Zs,qa as ct,qb as es,qc as qs,r as de,ra as ut,rb as rs,rc as ei,s as he,sa as lt,sb as ts,sc as ri,t as yr,ta as ft,tb as ss,tc as ti,u as Y,ua as pt,ub as is,uc as si,v as Dr,vb as os,vc as ii,w as me,wb as as,wc as oi,x as Pr,xa as dt,xb as ns,xc as ai,y as vr,ya as ht,yb as cs,yc as ci,z as Or,za as mt,zb as us,zc as ui}from"./chunk-ZO7SFB2E.mjs";import{a as Ii}from"./chunk-QJ3TFJLQ.mjs";import{b as Z}from"./chunk-CCSGFCLZ.mjs";import"./chunk-5MMN3N5J.mjs";import{b as P,c as g,d as I}from"./chunk-EKGYYOSP.mjs";import{a as Ce}from"./chunk-HM4E43VM.mjs";import{a as x,e as De,f as Pe,i as ve,l as Oe,m as _e,n as Be,o as Se,p as Fe,r as Te,u as Ie,v as Re}from"./chunk-36FIRJIF.mjs";import{a as ni}from"./chunk-74UW7QSL.mjs";import"./chunk-5L7RYZCL.mjs";import p from"node:fs";import je from"node:path";import{debuglog as Xe}from"node:util";var He=p.constants.O_RDONLY|p.constants.O_NOFOLLOW,ee=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_TRUNC|p.constants.O_NOFOLLOW,ze=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL|p.constants.O_NOFOLLOW,Ye=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,G=384;async function Ke(a,e){return!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.readFile(a,{encoding:e,flag:He}):await p.promises.readFile(a,{encoding:e})}P.value={path:je,debuglog:P.value.debuglog??Xe,ScreenRecorder:P.value.ScreenRecorder,followSymlinks:!0,readFile:Ke,writeFile:async(a,e)=>{!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.writeFile(a,e,{flag:ee,mode:G}):await p.promises.writeFile(a,e)},openFileForWriting:async a=>!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.open(a,ee,G):await p.promises.open(a,"w+"),createWriteStream:(a,e)=>{let r=e?.encoding,t=e?.overwrite??!0;if(!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0){let s=t?ee:ze,c=p.openSync(a,s,G);return p.createWriteStream("",{fd:c,mode:G,encoding:r})}if(!t){let s=p.openSync(a,Ye);return p.createWriteStream("",{fd:s,encoding:r})}return p.createWriteStream(a,r?{encoding:r}:void 0)},mkdir:async(a,e)=>{await p.promises.mkdir(a,e)}};import{mkdtemp as or}from"node:fs/promises";import ar from"node:os";import te from"node:path";import{accessSync as Je,constants as Qe,existsSync as $,rmSync as Ze}from"node:fs";import{tmpdir as qe}from"node:os";import{join as ke}from"node:path";var V=class{#e;#r=new me;#t;#i=!1;#s=[];onclose;onmessage;constructor(e,r,t){this.#e=e,this.#t=t;let s=this.#r.use(new K(r,t));s.on("data",o=>this.#o(o)),s.on("close",()=>{this.onclose&&this.onclose.call(null)}),s.on("error",o=>{this.#t?.(g.error)?.(o)}),this.#r.use(new K(e)).on("error",o=>{this.#t?.(g.error)?.(o)})}send(e){_(!this.#i,"`PipeTransport` is closed."),this.#e.write(e),this.#e.write("\0")}#o(e){if(_(!this.#i,"`PipeTransport` is closed."),this.#s.push(e),e.indexOf("\0")===-1)return;let r=Buffer.concat(this.#s),t=0,s=r.indexOf("\0");for(;s!==-1;){let c=r.toString(void 0,t,s);setImmediate(()=>{this.onmessage&&this.onmessage.call(null,c)}),t=s+1,s=r.indexOf("\0",t)}t>=r.length?this.#s=[]:this.#s=[r.subarray(t)]}close(){this.#i=!0,this.#r.dispose()}};function er(a){try{return Je(a,Qe.W_OK),!0}catch{return!$(a)}}function rr(a){switch(a){case x.FIREFOX:case x.CHROME:return a.charAt(0).toUpperCase()+a.slice(1);default:return a}}var R=class{#e;#r;puppeteer;constructor(e,r,t){this.puppeteer=e,this.#e=r,this.#r=t}get logger(){return this.#r}get browser(){return this.#e}async launch(e={}){e.logger??=this.#r;let{dumpio:r=!1,enableExtensions:t=!1,extensionsEnabledInIncognito:s=[],env:c=process.env,handleSIGINT:o=!0,handleSIGTERM:n=!0,handleSIGHUP:i=!0,acceptInsecureCerts:u=!1,networkEnabled:d=!0,issuesEnabled:f=!0,defaultViewport:h=ge,downloadBehavior:l,slowMo:b=0,timeout:E=3e4,waitForInitialPage:y=!0,protocolTimeout:D,handleDevToolsAsPage:U,idGenerator:C=xe(),blocklist:A,allowlist:B}=e,{protocol:v}=e;if(this.#e==="firefox"&&v===void 0&&(v="webDriverBiDi"),Ae({allowlist:B,blocklist:A,protocol:v}),this.#e==="firefox"&&v==="cdp")throw new Error("Connecting to Firefox using CDP is no longer supported");let m=await this.computeLaunchArguments({...e,protocol:v});if(!$(m.executablePath))throw m.isTempUserDataDir&&await this.cleanUserDataDir(m.userDataDir,{isTemp:!0}),new Error(`Browser was not found at the configured executablePath (${m.executablePath})`);let T=m.args.includes("--remote-debugging-pipe"),N=async()=>{try{await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir})}finally{w?.()}};if(this.#e==="firefox"&&v==="webDriverBiDi"&&T)throw new Error("Pipe connections are not supported with Firefox and WebDriver BiDi");let w,O;try{O=Be({executablePath:m.executablePath,args:m.args,handleSIGHUP:i,handleSIGTERM:n,handleSIGINT:o,dumpio:r,env:c,pipe:T,onExit:N,signal:e.signal,logger:e.logger}),w=m.isTempUserDataDir?tr(m.userDataDir,this.#r):void 0}catch(F){throw w?.(),await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir}),F}let S,L,se=!1,M=async()=>{se||(se=!0,await this.closeBrowser(O,L))};try{this.#e==="firefox"?S=await this.createBiDiBrowser(O,M,{timeout:E,protocolTimeout:D,slowMo:b,defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,idGenerator:C,logger:e.logger}):(T?L=await this.createCdpPipeConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}):L=await this.createCdpSocketConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}),v==="webDriverBiDi"?S=await this.createBiDiOverCdpBrowser(O,L,M,{defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,issuesEnabled:f,logger:e.logger}):S=await ye._create(L,[],u,h,l,O.nodeProcess,M,e.targetFilter,void 0,void 0,d,f,U,A,B,e.logger))}catch(F){M();let ie=O.getRecentLogs().join(`
3
- `);throw ie.includes("Failed to create a ProcessSingleton for your profile directory")||process.platform==="win32"&&$(ke(m.userDataDir,"lockfile"))?er(m.userDataDir)?new Error(`The browser is already running for ${m.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`):new Error(`The browser cannot write to ${m.userDataDir}. Make the \`userDataDir\` writable or use a different one.`):ie.includes("Missing X server")&&e.headless===!1?new Error("Missing X server to start the headful browser. Either set headless to true or use xvfb-run to run your Puppeteer script."):F instanceof Te?new we(F.message):F}return Array.isArray(t)&&await Promise.all([t.map(F=>S.installExtension(F,{enabledInIncognito:s.includes(F)}))]),y&&await this.waitForPageTarget(S,E),S}async closeBrowser(e,r){if(r)try{await r.closeBrowser(),await e.hasClosed()}catch(t){this.#r?.(g.error)?.(t),await e.close()}else await ae(le(k(e.hasClosed()),ce(5e3).pipe(W(()=>k(e.close())))))}async waitForPageTarget(e,r){try{await e.waitForTarget(t=>t.type()==="page",{timeout:r})}catch(t){throw await e.close(),t}}async createCdpSocketConnection(e,r){let t=await e.waitForLineOutput(Se,r.timeout),s=await Z.create(t,void 0,r.logger,r.wsOptions);return new Q(t,s,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createCdpPipeConnection(e,r){let{3:t,4:s}=e.nodeProcess.stdio,c=new V(t,s,r.logger);return new Q("",c,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createBiDiOverCdpBrowser(e,r,t,s){let c=process.env.PUPPETEER_WEBDRIVER_BIDI_ONLY==="true",o=await import("./chunk-ZCP7BTOZ.mjs"),n=await o.connectBidiOverCdp(r,s.logger);return await o.BidiBrowser.create({connection:n,cdpConnection:c?void 0:r,closeCallback:t,process:e.nodeProcess,defaultViewport:s.defaultViewport,acceptInsecureCerts:s.acceptInsecureCerts,networkEnabled:s.networkEnabled,issuesEnabled:s.issuesEnabled,logger:s.logger})}async createBiDiBrowser(e,r,t){let s=await e.waitForLineOutput(Fe,t.timeout)+"/session",c=await Z.create(s,void 0,t.logger,t.wsOptions),o=await import("./chunk-ZCP7BTOZ.mjs"),n=new o.BidiConnection(s,c,t.idGenerator,t.slowMo,t.protocolTimeout,t.logger);return await o.BidiBrowser.create({connection:n,closeCallback:r,process:e.nodeProcess,defaultViewport:t.defaultViewport,acceptInsecureCerts:t.acceptInsecureCerts,networkEnabled:t.networkEnabled??!0,issuesEnabled:t.issuesEnabled??!0,logger:t.logger})}async getProfilePath(){let e=await this.puppeteer.configuration();return ke(e.temporaryDirectory??qe(),`puppeteer_dev_${this.browser}_profile-`)}async resolveExecutablePath(e,r=!0){let t=await this.puppeteer.configuration(),s=t.executablePath;if(s){if(r&&!$(s))throw new Error(`Tried to find the browser at the configured path (${s}), but no executable was found.`);return s}function c(u,d){switch(u){case"chrome":return d==="shell"?x.CHROMEHEADLESSSHELL:x.CHROME;case"firefox":return x.FIREFOX}return x.CHROME}let o=c(this.browser,e),n=await this.puppeteer.defaultDownloadPath(),i=await this.puppeteer.browserVersion();if(s=Oe({cacheDir:n,browser:o,buildId:i}),r&&!$(s)){let u=t?.[this.browser]?.version;throw u?new Error(`Tried to find the browser at the configured path (${s}) for version ${u}, but no executable was found.`):new Error(`Could not find ${rr(o)} (ver. ${i}). This can occur if either
2
+ import{$ as zr,$a as $t,$b as ks,A as K,Aa as wt,Ab as ls,Ac as li,B as _,Ba as gt,Bb as fs,Bc as fi,Ca as bt,Cb as ps,Cc as pi,Da as Et,Db as ds,Dc as di,E as _r,Ea as xt,Eb as hs,Ec as hi,F as we,Fa as yt,Fb as ms,Fc as mi,G as Br,Ga as Dt,Gb as ws,Gc as wi,H as Sr,Ha as Pt,Hb as gs,Hc as gi,I as Fr,Ia as vt,Ib as bs,Ic as bi,J as Tr,Ja as Ot,Jb as Es,Jc as Ei,K as Ir,Ka as _t,Kb as xs,Kc as xi,L as Rr,Lb as Q,Lc as yi,M as ge,Mb as ys,Mc as Di,N as Cr,Nb as Ds,Nc as Pi,O as Ar,Oa as J,Ob as Ps,Oc as vi,P as Lr,Pb as vs,Pc as Oi,Q as kr,Qa as Bt,Qb as Os,Qc as _i,R as Wr,Ra as St,Rb as _s,Rc as Bi,S as $r,Sa as Ft,Sb as Bs,Sc as ye,T as Ur,Ta as Tt,Tb as Ss,Tc as Si,U as Nr,Ua as It,Ub as Fs,Uc as Fi,V as Mr,Va as Rt,Vb as Ts,Vc as Ti,W as Gr,Wa as Ct,Wb as Is,Wc as Ri,X as Vr,Xa as At,Xb as Rs,Xc as Ae,Y as jr,Ya as Lt,Yb as Cs,Yc as Le,Z as Xr,Za as kt,Zb as As,Zc as Ci,_ as Hr,_a as Wt,_b as Ls,_c as q,a as k,aa as Yr,ab as Ut,ac as Ws,ba as Kr,bb as Nt,bc as $s,c as oe,ca as Jr,cb as Mt,cc as Us,d as ae,da as Qr,db as Gt,dc as Ns,e as W,ea as be,eb as Vt,ec as Ms,fa as Zr,fb as jt,fc as Gs,ga as qr,gb as Xt,gc as Vs,h as ne,ha as et,hb as Ht,hc as js,i as ce,ia as rt,ib as zt,ic as Xs,j as ue,ja as tt,jb as Yt,jc as Hs,k as le,ka as st,kb as Kt,kc as zs,l as fe,la as it,lb as xe,lc as Ys,m as pe,ma as Ee,mb as Jt,mc as Ks,na as ot,nb as Qt,nc as Js,oa as at,ob as Zt,oc as Qs,pa as nt,pb as qt,pc as Zs,qa as ct,qb as es,qc as qs,r as de,ra as ut,rb as rs,rc as ei,s as he,sa as lt,sb as ts,sc as ri,t as yr,ta as ft,tb as ss,tc as ti,u as Y,ua as pt,ub as is,uc as si,v as Dr,vb as os,vc as ii,w as me,wb as as,wc as oi,x as Pr,xa as dt,xb as ns,xc as ai,y as vr,ya as ht,yb as cs,yc as ci,z as Or,za as mt,zb as us,zc as ui}from"./chunk-SQ6Y2ZMA.mjs";import{a as Ii}from"./chunk-Y34NR5JL.mjs";import{b as Z}from"./chunk-U3SSPL4K.mjs";import"./chunk-YEY3RSFQ.mjs";import{b as P,c as g,d as I}from"./chunk-W7XHE4CT.mjs";import{a as Ce}from"./chunk-MAFIGVXY.mjs";import{a as x,e as De,f as Pe,i as ve,l as Oe,m as _e,n as Be,o as Se,p as Fe,r as Te,u as Ie,v as Re}from"./chunk-742D2WWJ.mjs";import{a as ni}from"./chunk-UH4SIXTR.mjs";import"./chunk-5L7RYZCL.mjs";import p from"node:fs";import je from"node:path";import{debuglog as Xe}from"node:util";var He=p.constants.O_RDONLY|p.constants.O_NOFOLLOW,ee=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_TRUNC|p.constants.O_NOFOLLOW,ze=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL|p.constants.O_NOFOLLOW,Ye=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,G=384;async function Ke(a,e){return!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.readFile(a,{encoding:e,flag:He}):await p.promises.readFile(a,{encoding:e})}P.value={path:je,debuglog:P.value.debuglog??Xe,ScreenRecorder:P.value.ScreenRecorder,followSymlinks:!0,readFile:Ke,writeFile:async(a,e)=>{!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.writeFile(a,e,{flag:ee,mode:G}):await p.promises.writeFile(a,e)},openFileForWriting:async a=>!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.open(a,ee,G):await p.promises.open(a,"w+"),createWriteStream:(a,e)=>{let r=e?.encoding,t=e?.overwrite??!0;if(!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0){let s=t?ee:ze,c=p.openSync(a,s,G);return p.createWriteStream("",{fd:c,mode:G,encoding:r})}if(!t){let s=p.openSync(a,Ye);return p.createWriteStream("",{fd:s,encoding:r})}return p.createWriteStream(a,r?{encoding:r}:void 0)},mkdir:async(a,e)=>{await p.promises.mkdir(a,e)}};import{mkdtemp as or}from"node:fs/promises";import ar from"node:os";import te from"node:path";import{accessSync as Je,constants as Qe,existsSync as $,rmSync as Ze}from"node:fs";import{tmpdir as qe}from"node:os";import{join as ke}from"node:path";var V=class{#e;#r=new me;#t;#i=!1;#s=[];onclose;onmessage;constructor(e,r,t){this.#e=e,this.#t=t;let s=this.#r.use(new K(r,t));s.on("data",o=>this.#o(o)),s.on("close",()=>{this.onclose&&this.onclose.call(null)}),s.on("error",o=>{this.#t?.(g.error)?.(o)}),this.#r.use(new K(e)).on("error",o=>{this.#t?.(g.error)?.(o)})}send(e){_(!this.#i,"`PipeTransport` is closed."),this.#e.write(e),this.#e.write("\0")}#o(e){if(_(!this.#i,"`PipeTransport` is closed."),this.#s.push(e),e.indexOf("\0")===-1)return;let r=Buffer.concat(this.#s),t=0,s=r.indexOf("\0");for(;s!==-1;){let c=r.toString(void 0,t,s);setImmediate(()=>{this.onmessage&&this.onmessage.call(null,c)}),t=s+1,s=r.indexOf("\0",t)}t>=r.length?this.#s=[]:this.#s=[r.subarray(t)]}close(){this.#i=!0,this.#r.dispose()}};function er(a){try{return Je(a,Qe.W_OK),!0}catch{return!$(a)}}function rr(a){switch(a){case x.FIREFOX:case x.CHROME:return a.charAt(0).toUpperCase()+a.slice(1);default:return a}}var R=class{#e;#r;puppeteer;constructor(e,r,t){this.puppeteer=e,this.#e=r,this.#r=t}get logger(){return this.#r}get browser(){return this.#e}async launch(e={}){e.logger??=this.#r;let{dumpio:r=!1,enableExtensions:t=!1,extensionsEnabledInIncognito:s=[],env:c=process.env,handleSIGINT:o=!0,handleSIGTERM:n=!0,handleSIGHUP:i=!0,acceptInsecureCerts:u=!1,networkEnabled:d=!0,issuesEnabled:f=!0,defaultViewport:h=ge,downloadBehavior:l,slowMo:b=0,timeout:E=3e4,waitForInitialPage:y=!0,protocolTimeout:D,handleDevToolsAsPage:U,idGenerator:C=xe(),blocklist:A,allowlist:B}=e,{protocol:v}=e;if(this.#e==="firefox"&&v===void 0&&(v="webDriverBiDi"),Ae({allowlist:B,blocklist:A,protocol:v}),this.#e==="firefox"&&v==="cdp")throw new Error("Connecting to Firefox using CDP is no longer supported");let m=await this.computeLaunchArguments({...e,protocol:v});if(!$(m.executablePath))throw m.isTempUserDataDir&&await this.cleanUserDataDir(m.userDataDir,{isTemp:!0}),new Error(`Browser was not found at the configured executablePath (${m.executablePath})`);let T=m.args.includes("--remote-debugging-pipe"),N=async()=>{try{await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir})}finally{w?.()}};if(this.#e==="firefox"&&v==="webDriverBiDi"&&T)throw new Error("Pipe connections are not supported with Firefox and WebDriver BiDi");let w,O;try{O=Be({executablePath:m.executablePath,args:m.args,handleSIGHUP:i,handleSIGTERM:n,handleSIGINT:o,dumpio:r,env:c,pipe:T,onExit:N,signal:e.signal,logger:e.logger}),w=m.isTempUserDataDir?tr(m.userDataDir,this.#r):void 0}catch(F){throw w?.(),await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir}),F}let S,L,se=!1,M=async()=>{se||(se=!0,await this.closeBrowser(O,L))};try{this.#e==="firefox"?S=await this.createBiDiBrowser(O,M,{timeout:E,protocolTimeout:D,slowMo:b,defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,idGenerator:C,logger:e.logger}):(T?L=await this.createCdpPipeConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}):L=await this.createCdpSocketConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}),v==="webDriverBiDi"?S=await this.createBiDiOverCdpBrowser(O,L,M,{defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,issuesEnabled:f,logger:e.logger}):S=await ye._create(L,[],u,h,l,O.nodeProcess,M,e.targetFilter,void 0,void 0,d,f,U,A,B,e.logger))}catch(F){M();let ie=O.getRecentLogs().join(`
3
+ `);throw ie.includes("Failed to create a ProcessSingleton for your profile directory")||process.platform==="win32"&&$(ke(m.userDataDir,"lockfile"))?er(m.userDataDir)?new Error(`The browser is already running for ${m.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`):new Error(`The browser cannot write to ${m.userDataDir}. Make the \`userDataDir\` writable or use a different one.`):ie.includes("Missing X server")&&e.headless===!1?new Error("Missing X server to start the headful browser. Either set headless to true or use xvfb-run to run your Puppeteer script."):F instanceof Te?new we(F.message):F}return Array.isArray(t)&&await Promise.all([t.map(F=>S.installExtension(F,{enabledInIncognito:s.includes(F)}))]),y&&await this.waitForPageTarget(S,E),S}async closeBrowser(e,r){if(r)try{await r.closeBrowser(),await e.hasClosed()}catch(t){this.#r?.(g.error)?.(t),await e.close()}else await ae(le(k(e.hasClosed()),ce(5e3).pipe(W(()=>k(e.close())))))}async waitForPageTarget(e,r){try{await e.waitForTarget(t=>t.type()==="page",{timeout:r})}catch(t){throw await e.close(),t}}async createCdpSocketConnection(e,r){let t=await e.waitForLineOutput(Se,r.timeout),s=await Z.create(t,void 0,r.logger,r.wsOptions);return new Q(t,s,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createCdpPipeConnection(e,r){let{3:t,4:s}=e.nodeProcess.stdio,c=new V(t,s,r.logger);return new Q("",c,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createBiDiOverCdpBrowser(e,r,t,s){let c=process.env.PUPPETEER_WEBDRIVER_BIDI_ONLY==="true",o=await import("./chunk-6QBHU4DF.mjs"),n=await o.connectBidiOverCdp(r,s.logger);return await o.BidiBrowser.create({connection:n,cdpConnection:c?void 0:r,closeCallback:t,process:e.nodeProcess,defaultViewport:s.defaultViewport,acceptInsecureCerts:s.acceptInsecureCerts,networkEnabled:s.networkEnabled,issuesEnabled:s.issuesEnabled,logger:s.logger})}async createBiDiBrowser(e,r,t){let s=await e.waitForLineOutput(Fe,t.timeout)+"/session",c=await Z.create(s,void 0,t.logger,t.wsOptions),o=await import("./chunk-6QBHU4DF.mjs"),n=new o.BidiConnection(s,c,t.idGenerator,t.slowMo,t.protocolTimeout,t.logger);return await o.BidiBrowser.create({connection:n,closeCallback:r,process:e.nodeProcess,defaultViewport:t.defaultViewport,acceptInsecureCerts:t.acceptInsecureCerts,networkEnabled:t.networkEnabled??!0,issuesEnabled:t.issuesEnabled??!0,logger:t.logger})}async getProfilePath(){let e=await this.puppeteer.configuration();return ke(e.temporaryDirectory??qe(),`puppeteer_dev_${this.browser}_profile-`)}async resolveExecutablePath(e,r=!0){let t=await this.puppeteer.configuration(),s=t.executablePath;if(s){if(r&&!$(s))throw new Error(`Tried to find the browser at the configured path (${s}), but no executable was found.`);return s}function c(u,d){switch(u){case"chrome":return d==="shell"?x.CHROMEHEADLESSSHELL:x.CHROME;case"firefox":return x.FIREFOX}return x.CHROME}let o=c(this.browser,e),n=await this.puppeteer.defaultDownloadPath(),i=await this.puppeteer.browserVersion();if(s=Oe({cacheDir:n,browser:o,buildId:i}),r&&!$(s)){let u=t?.[this.browser]?.version;throw u?new Error(`Tried to find the browser at the configured path (${s}) for version ${u}, but no executable was found.`):new Error(`Could not find ${rr(o)} (ver. ${i}). This can occur if either
4
4
  1. you did not perform an installation before running the script (e.g. \`npx puppeteer browsers install ${o}\`) or
5
5
  2. your cache path is incorrectly configured (which is: ${t.cacheDirectory}).
6
6
  For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.`)}return s}},re=new WeakMap;function tr(a,e,r=process){let t=re.get(r);if(!t){let c=new Set,o=()=>{for(let n of c)try{Ze(n.userDataDir,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch(i){n.logger(g.error)?.(i)}};t={entries:c,onExit:o},re.set(r,t),r.once("exit",o)}let s={userDataDir:a,logger:e};return t.entries.add(s),()=>{!t?.entries.delete(s)||t.entries.size>0||(r.off("exit",t.onExit),re.delete(r))}}import sr from"node:fs";var ir={force:!0,recursive:!0,maxRetries:10,retryDelay:100};async function j(a){await sr.promises.rm(a,ir)}var X=class extends R{constructor(e,r){super(e,"chrome",r)}async launch(e={}){return(await this.puppeteer.configuration()).logLevel==="warn"&&process.platform==="darwin"&&process.arch==="x64"&&ar.cpus()[0]?.model.includes("Apple")&&console.warn(["\x1B[1m\x1B[43m\x1B[30m","Degraded performance warning:\x1B[0m\x1B[33m","Launching Chrome on Mac Silicon (arm64) from an x64 Node installation results in","Rosetta translating the Chrome binary, even if Chrome is already arm64. This would","result in huge performance issues. To resolve this, you must run Puppeteer with","a version of Node built for arm64."].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 g}from"./chunk-2RKIHJI2.mjs";import{createRequire as re}from"node:module";import{typescriptFile as ae}from"../browser/shared/paths.mjs";var ce=re(import.meta.url),B=null;function fe(){return B??=ce(ae??"typescript"),B}var b=new Proxy({},{get:(e,n)=>fe()[n]});import _ from"node:fs/promises";import h from"node:path";import{COMPONENTS as D,instancesOf as ue}from"../browser/shared/components/index.mjs";import{PACKAGE_MARK as q}from"../browser/shared/components/installed.mjs";import{MATH_IGNORED_TAGS as pe}from"../browser/shared/components/math.mjs";import{attr as x,elementsOf as O,walk as y}from"../browser/shared/html-tree.mjs";import I from"node:path";import de from"node:vm";var L=()=>{throw new Error("esbuild is not in the release: Gallery 0.2.1 calls it only in a source checkout")},Le=L,J=L;var Te=new Proxy({},{get:L});import{projectRoot as le}from"../browser/shared/paths.mjs";var T=I.join(le,"src","shared","components","index.mjs");function F(e){let{outputFiles:n}=J({stdin:{contents:`import { FLOWS, FLOW_BLOCKS, runtimeDescriptions } from ${JSON.stringify(e)}; module.exports = { descriptions: runtimeDescriptions(), flows: FLOWS, blockFlows: FLOW_BLOCKS };`,resolveDir:I.dirname(e),loader:"js"},bundle:!0,write:!1,format:"cjs",platform:"node",logLevel:"silent"}),s={module:{exports:null}};return de.runInNewContext(n[0].text,s),JSON.parse(JSON.stringify(s.module.exports))}var W=(e=T)=>F(e).descriptions,G=(e=T)=>F(e).flows,U=(e=T)=>F(e).blockFlows;import{kitPublicDirectory as me,projectRoot as H,release as Y,vendorDirectory as z}from"../browser/shared/paths.mjs";var P=h.join(H,"node_modules"),he=h.join(P,"d3","dist","d3.min.js"),S=Y?h.join(z,"katex"):h.join(P,"katex","dist"),xe=h.join(S,"fonts"),He=h.join(S,"contrib","mhchem.min.js"),u=[{id:"styles",file:"report.css",build:{styles:"styles/index.css"},always:!0},{id:"katex-styles",vendor:{path:"/vendor/katex/katex.min.css",source:h.join(S,"katex.min.css")}},{id:"runtime",file:"runtime.js",build:{bundle:"runtime/index.js",options:()=>({minify:!1,define:{__COMPONENT_RUNTIME__:JSON.stringify(W()),__COMPONENT_FLOWS__:JSON.stringify(G()),__COMPONENT_BLOCK_FLOWS__:JSON.stringify(U())}})},api:"DocKit",always:!0},{id:"code",file:"code.js",build:{bundle:"code.js",options:{minify:!0,legalComments:"inline"}},api:"DocCode",after:["runtime"]},{id:"state",file:"state.js",build:{read:"state.js"},api:"DocState",always:!0},{id:"sheets",file:"sheets.js",build:{read:"sheets.js"},api:"DocSheets",after:["runtime","state"]},{id:"tokens",file:"tokens.js",build:{read:"tokens.js"},api:"DocTokens",always:!0},{id:"ui",file:"ui.js",build:{bundle:"ui.js",options:{minify:!1}},added:!0,after:["runtime","state","tokens"]},{id:"dialogs",file:"dialogs.js",build:{read:"dialogs.js"},api:"DocDialogs",after:["runtime"]},{id:"katex",vendor:{path:"/vendor/katex/katex.min.js",source:h.join(S,"katex.min.js")},umd:!0},{id:"katex-auto-render",vendor:{path:"/vendor/katex/auto-render.min.js",source:h.join(S,"contrib","auto-render.min.js")},umd:!0,after:["katex"]},{id:"math",file:"math.js",build:{bundle:"math-bundle.js",options:{minify:!1,legalComments:"inline",alias:{katex:h.join(H,"src","render","kit","page-katex.js")},nodePaths:[h.join(P,"katex")]}},api:"DocMath",after:["runtime","katex-styles","katex","katex-auto-render"]},{id:"d3",vendor:{path:"/vendor/d3.v7.9.0.min.js",source:he},api:"d3",umd:!0},{id:"charts",file:"charts.js",build:{bundle:"charts/index.js",options:{minify:!1}},api:"DocCharts",after:["runtime","tokens"]},{id:"tables",file:"tables.js",build:{bundle:"tables/index.js",options:{minify:!1}},api:"DocTables",after:["runtime"]},{id:"board-styles",file:"board.css",build:{styles:"board/index.css"},page:!0},{id:"board",file:"board.js",build:{bundle:"board/index.js",options:{minify:!1}},page:!0}],m=e=>e.file?`/kit/${e.file}`:e.vendor.path,ge=e=>e.file?h.join(me,e.file):h.join(z,...e.vendor.path.split("/").slice(2));if(Y)for(let e of u)e.vendor&&(e.vendor.source=ge(e));var k=e=>m(e).endsWith(".css"),E=e=>e.file?"data-doc-kit":"data-doc-vendor",C=e=>u.find(n=>n.id===e),w=(e,n=m(e))=>k(e)?`<link rel="stylesheet" href="${n}" ${E(e)}="${e.id}">`:`<script src="${n}" ${E(e)}="${e.id}"></script>`,we=u.map(e=>({id:e.id,tag:w(e),always:!!e.always,element:k(e)?"style":"script",attribute:E(e)}));function Ye(e,n=m){let s=new Set,i=t=>{s.has(t)||(s.add(t),C(t)?.after?.forEach(i))};return e.forEach(i),u.filter(t=>s.has(t.id)&&!t.always&&!t.added).map(t=>w(t,n(t)))}function ye(e=u,n=D){let s=[],i=e.map(t=>t.id);for(let t of new Set(i.filter((a,o)=>i.indexOf(a)!==o)))s.push(`the asset "${t}" is listed twice`);for(let t of e){!!t.file==!!t.vendor&&s.push(`the asset "${t.id}" is a kit file (file) or a vendor file (vendor), one of them`),t.file&&!["read","bundle","styles"].some(o=>typeof t.build?.[o]=="string")&&s.push(`the kit file "${t.file}" does not say how it is made (build: read, bundle or styles)`),t.vendor&&!(t.vendor.path&&t.vendor.source)&&s.push(`the vendor asset "${t.id}" needs its public path and its source`);for(let o of t.after??[])i.includes(o)?i.indexOf(o)>i.indexOf(t.id)&&s.push(`the asset "${t.id}" loads after "${o}", which the list puts after it`):s.push(`the asset "${t.id}" loads after "${o}", which is no asset`);let a=n.filter(o=>(o.assets??[]).includes(t.id));!t.always&&!t.api&&!t.added&&!t.page&&a.length===0&&s.push(`no report would keep the asset "${t.id}": it is not always kept, defines no global and no component needs it`)}for(let t of n)for(let a of t.assets??[])i.includes(a)||s.push(`the component "${t.id}" needs "${a}", which is no asset`);return s}{let e=ye();if(e.length>0)throw new Error(`src/render/assets.mjs: ${e.join("; ")}`)}var K=/^(?:|module|(?:text|application)\/(?:x-)?(?:javascript|ecmascript)|text\/javascript1\.[0-5]|text\/(?:jscript|livescript))$/,be=/^application\/(?:\S+\+)?json$/,N=e=>(x(e,"type")??"").trim().toLowerCase();function V(e){let n=b.createSourceFile("report.js",e,b.ScriptTarget.Latest,!1,b.ScriptKind.JS),s=[],i=[n];for(;i.length>0;){let t=i.pop();if(t.kind>=b.SyntaxKind.FirstJSDocNode&&t.kind<=b.SyntaxKind.LastJSDocNode)continue;let a=t.getChildren(n);a.length===0&&s.push(e.slice(t.getStart(n),t.end));for(let o=a.length-1;o>=0;o-=1)i.push(a[o])}return s.join(" ")}var Q=e=>new RegExp(`\\b(?:${e.filter(n=>n.api).map(n=>n.api).join("|")})\\b`);function $e(e,n){let s=[],i=t=>{n.test(t)&&s.push(V(t))};return y(e,t=>{t.tagName==="script"&&x(t,"src")===void 0&&K.test(N(t))&&i(t.childNodes.map(a=>a.value??"").join(""));for(let{name:a,value:o}of t.attrs??[]){if(/^on/.test(a)){i(o);continue}let c=o.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(!/^javascript:/i.test(c))continue;let r=c.slice(11);try{r=decodeURIComponent(r)}catch{}i(r)}}),s.join(`
2
+ import{a as g}from"./chunk-HYMEEXKN.mjs";import{createRequire as re}from"node:module";import{typescriptFile as ae}from"../browser/shared/paths.mjs";var ce=re(import.meta.url),B=null;function fe(){return B??=ce(ae??"typescript"),B}var b=new Proxy({},{get:(e,n)=>fe()[n]});import _ from"node:fs/promises";import h from"node:path";import{COMPONENTS as D,instancesOf as ue}from"../browser/shared/components/index.mjs";import{PACKAGE_MARK as q}from"../browser/shared/components/installed.mjs";import{MATH_IGNORED_TAGS as pe}from"../browser/shared/components/math.mjs";import{attr as x,elementsOf as O,walk as y}from"../browser/shared/html-tree.mjs";import I from"node:path";import de from"node:vm";var L=()=>{throw new Error("esbuild is not in the release: Gallery 0.2.3 calls it only in a source checkout")},Le=L,J=L;var Te=new Proxy({},{get:L});import{projectRoot as le}from"../browser/shared/paths.mjs";var T=I.join(le,"src","shared","components","index.mjs");function F(e){let{outputFiles:n}=J({stdin:{contents:`import { FLOWS, FLOW_BLOCKS, runtimeDescriptions } from ${JSON.stringify(e)}; module.exports = { descriptions: runtimeDescriptions(), flows: FLOWS, blockFlows: FLOW_BLOCKS };`,resolveDir:I.dirname(e),loader:"js"},bundle:!0,write:!1,format:"cjs",platform:"node",logLevel:"silent"}),s={module:{exports:null}};return de.runInNewContext(n[0].text,s),JSON.parse(JSON.stringify(s.module.exports))}var W=(e=T)=>F(e).descriptions,G=(e=T)=>F(e).flows,U=(e=T)=>F(e).blockFlows;import{kitPublicDirectory as me,projectRoot as H,release as Y,vendorDirectory as z}from"../browser/shared/paths.mjs";var P=h.join(H,"node_modules"),he=h.join(P,"d3","dist","d3.min.js"),S=Y?h.join(z,"katex"):h.join(P,"katex","dist"),xe=h.join(S,"fonts"),He=h.join(S,"contrib","mhchem.min.js"),u=[{id:"styles",file:"report.css",build:{styles:"styles/index.css"},always:!0},{id:"katex-styles",vendor:{path:"/vendor/katex/katex.min.css",source:h.join(S,"katex.min.css")}},{id:"runtime",file:"runtime.js",build:{bundle:"runtime/index.js",options:()=>({minify:!1,define:{__COMPONENT_RUNTIME__:JSON.stringify(W()),__COMPONENT_FLOWS__:JSON.stringify(G()),__COMPONENT_BLOCK_FLOWS__:JSON.stringify(U())}})},api:"DocKit",always:!0},{id:"code",file:"code.js",build:{bundle:"code.js",options:{minify:!0,legalComments:"inline"}},api:"DocCode",after:["runtime"]},{id:"state",file:"state.js",build:{read:"state.js"},api:"DocState",always:!0},{id:"sheets",file:"sheets.js",build:{read:"sheets.js"},api:"DocSheets",after:["runtime","state"]},{id:"tokens",file:"tokens.js",build:{read:"tokens.js"},api:"DocTokens",always:!0},{id:"ui",file:"ui.js",build:{bundle:"ui.js",options:{minify:!1}},added:!0,after:["runtime","state","tokens"]},{id:"dialogs",file:"dialogs.js",build:{read:"dialogs.js"},api:"DocDialogs",after:["runtime"]},{id:"katex",vendor:{path:"/vendor/katex/katex.min.js",source:h.join(S,"katex.min.js")},umd:!0},{id:"katex-auto-render",vendor:{path:"/vendor/katex/auto-render.min.js",source:h.join(S,"contrib","auto-render.min.js")},umd:!0,after:["katex"]},{id:"math",file:"math.js",build:{bundle:"math-bundle.js",options:{minify:!1,legalComments:"inline",alias:{katex:h.join(H,"src","render","kit","page-katex.js")},nodePaths:[h.join(P,"katex")]}},api:"DocMath",after:["runtime","katex-styles","katex","katex-auto-render"]},{id:"d3",vendor:{path:"/vendor/d3.v7.9.0.min.js",source:he},api:"d3",umd:!0},{id:"charts",file:"charts.js",build:{bundle:"charts/index.js",options:{minify:!1}},api:"DocCharts",after:["runtime","tokens"]},{id:"tables",file:"tables.js",build:{bundle:"tables/index.js",options:{minify:!1}},api:"DocTables",after:["runtime"]},{id:"board-styles",file:"board.css",build:{styles:"board/index.css"},page:!0},{id:"board",file:"board.js",build:{bundle:"board/index.js",options:{minify:!1}},page:!0}],m=e=>e.file?`/kit/${e.file}`:e.vendor.path,ge=e=>e.file?h.join(me,e.file):h.join(z,...e.vendor.path.split("/").slice(2));if(Y)for(let e of u)e.vendor&&(e.vendor.source=ge(e));var k=e=>m(e).endsWith(".css"),E=e=>e.file?"data-doc-kit":"data-doc-vendor",C=e=>u.find(n=>n.id===e),w=(e,n=m(e))=>k(e)?`<link rel="stylesheet" href="${n}" ${E(e)}="${e.id}">`:`<script src="${n}" ${E(e)}="${e.id}"></script>`,we=u.map(e=>({id:e.id,tag:w(e),always:!!e.always,element:k(e)?"style":"script",attribute:E(e)}));function Ye(e,n=m){let s=new Set,i=t=>{s.has(t)||(s.add(t),C(t)?.after?.forEach(i))};return e.forEach(i),u.filter(t=>s.has(t.id)&&!t.always&&!t.added).map(t=>w(t,n(t)))}function ye(e=u,n=D){let s=[],i=e.map(t=>t.id);for(let t of new Set(i.filter((a,o)=>i.indexOf(a)!==o)))s.push(`the asset "${t}" is listed twice`);for(let t of e){!!t.file==!!t.vendor&&s.push(`the asset "${t.id}" is a kit file (file) or a vendor file (vendor), one of them`),t.file&&!["read","bundle","styles"].some(o=>typeof t.build?.[o]=="string")&&s.push(`the kit file "${t.file}" does not say how it is made (build: read, bundle or styles)`),t.vendor&&!(t.vendor.path&&t.vendor.source)&&s.push(`the vendor asset "${t.id}" needs its public path and its source`);for(let o of t.after??[])i.includes(o)?i.indexOf(o)>i.indexOf(t.id)&&s.push(`the asset "${t.id}" loads after "${o}", which the list puts after it`):s.push(`the asset "${t.id}" loads after "${o}", which is no asset`);let a=n.filter(o=>(o.assets??[]).includes(t.id));!t.always&&!t.api&&!t.added&&!t.page&&a.length===0&&s.push(`no report would keep the asset "${t.id}": it is not always kept, defines no global and no component needs it`)}for(let t of n)for(let a of t.assets??[])i.includes(a)||s.push(`the component "${t.id}" needs "${a}", which is no asset`);return s}{let e=ye();if(e.length>0)throw new Error(`src/render/assets.mjs: ${e.join("; ")}`)}var K=/^(?:|module|(?:text|application)\/(?:x-)?(?:javascript|ecmascript)|text\/javascript1\.[0-5]|text\/(?:jscript|livescript))$/,be=/^application\/(?:\S+\+)?json$/,N=e=>(x(e,"type")??"").trim().toLowerCase();function V(e){let n=b.createSourceFile("report.js",e,b.ScriptTarget.Latest,!1,b.ScriptKind.JS),s=[],i=[n];for(;i.length>0;){let t=i.pop();if(t.kind>=b.SyntaxKind.FirstJSDocNode&&t.kind<=b.SyntaxKind.LastJSDocNode)continue;let a=t.getChildren(n);a.length===0&&s.push(e.slice(t.getStart(n),t.end));for(let o=a.length-1;o>=0;o-=1)i.push(a[o])}return s.join(" ")}var Q=e=>new RegExp(`\\b(?:${e.filter(n=>n.api).map(n=>n.api).join("|")})\\b`);function $e(e,n){let s=[],i=t=>{n.test(t)&&s.push(V(t))};return y(e,t=>{t.tagName==="script"&&x(t,"src")===void 0&&K.test(N(t))&&i(t.childNodes.map(a=>a.value??"").join(""));for(let{name:a,value:o}of t.attrs??[]){if(/^on/.test(a)){i(o);continue}let c=o.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(!/^javascript:/i.test(c))continue;let r=c.slice(11);try{r=decodeURIComponent(r)}catch{}i(r)}}),s.join(`
3
3
  `)}function je(e,n){let s=[],i=(o,c)=>{for(let r of o.childNodes??[]){let f=r.sourceCodeLocation;r.nodeName==="#comment"||c&&r.nodeName==="#text"?f&&s.push([f.startOffset,f.endOffset]):r.tagName==="script"?i(r,be.test(N(r))):r.tagName&&i(r.content??r,c||pe.includes(r.tagName))}};i(e,!1);let t="",a=0;for(let[o,c]of s.sort((r,f)=>r[0]-f[0]))o<a||(t+=`${n.slice(a,o)} `,a=c);return t+n.slice(a)}function R(e,n=u,s=D){let i=n.reduce((f,d)=>f.replaceAll(w(d),""),e),t=g(i),a=je(t,i),o=$e(t,Q(n)),c=new Set,r=f=>{c.has(f)||(c.add(f),(n.find(d=>d.id===f)?.after??[]).forEach(r))};for(let f of s){if(!(f.assets??[]).length)continue;((f.uses??[]).some(l=>l.test(a))||f.match&&ue(t,f).length>0)&&f.assets.forEach(r)}for(let f of n)f.api&&new RegExp(`\\b${f.api}\\b`).test(o)&&r(f.id);return c}function ze(e,n=D){let s=R(e,u,n),i=[];for(let t of u){let a=w(t);if(t.always||t.added||s.has(t.id)||!e.includes(a))continue;let o=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp(`[ \\t]*${o}[ \\t]*\\r?\\n?`),""),i.push(t.id)}return{html:e,removed:i,used:s}}function M(e,n){let s=[];return y(n,i=>{let t=Z(i),a=t===void 0?void 0:u.find(c=>m(c)===t.trim()),o=i.sourceCodeLocation;!a||!o||s.push({asset:a,start:o.startOffset,end:o.endOffset,line:o.startLine,exact:e.slice(o.startOffset,o.endOffset)===w(a)})},{inTemplates:!1}),s}var X=e=>e.tagName==="style"||e.tagName==="link"&&(x(e,"rel")??"").toLowerCase().split(/\s+/).includes("stylesheet"),Z=e=>e.tagName==="script"?x(e,"src"):X(e)?x(e,"href"):void 0,j=e=>!!e.sourceCodeLocation,A=e=>e.includes(`\r
4
4
  `)?`\r
5
5
  `:`
@@ -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{$ as ha,A as I,B as J,C as K,D as L,E as M,F as N,G as O,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as i,aa as ia,b as j,ba as ja,c as k,ca as ka,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s,l as t,m as u,n as v,o as w,p as x,q as y,r as z,s as A,t as B,u as C,v as D,w as E,x as F,y as G,z as H}from"./chunk-4DNHHJSL.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-3A5I2GJK.mjs";import"./chunk-XQRUG4G3.mjs";import"./chunk-4AMTKWDO.mjs";import{a,b,c,f as d,g as e,h as f,k as g,l as h}from"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{_ as ADVICE,t as BLOCK_PICTURES,$ as CODE_SIDEWAYS,X as HAND_OVER,u as INK_MARGIN,i as KINDS,j as LEVELS,k as LOOKS,Y as LOOK_YOURSELF,W as MORE_PICTURES,M as MOSTLY_CHANGED,y as MOVED_PART,x as MOVED_WHOLE,w as NEIGHBOUR_EDGE,p as PICTURED_INFO,ca as SCROLLS,v as SCROLL_FRAMES,s as SCROLL_SLACK,ba as WARNED,l as WIDE,m as WIDTHS,f as adoptIdless,aa as adviceOf,e as baselineOf,L as baselineSaid,b as blocksOf,N as blocksToPicture,da as describeLooks,S as disclosuresSaid,g as exportBaselines,G as exportOf,ga as exportingFirst,Q as findingKey,q as findingLevel,O as inkOf,P as inventory,n as layoutNotesOf,o as levelOf,R as lookAt,J as missedWidths,V as morePictures,H as movedBlocks,z as movedClips,ha as namedBlocks,I as nextBaseline,ea as notPicturedLine,c as pageOf,r as picturedAt,T as picturesSaid,D as placeOf,h as previewBaseline,a as rankOf,d as readBaseline,ka as run,K as seenOf,C as sourceIndex,F as staleExport,Z as startFailure,E as timeOf,ia as unknownBlocks,ja as unknownBlocksSaid,U as unopenedSaid,A as urlName,fa as verdictOf,B as wordsOf};
2
+ import{$ as ha,A as I,B as J,C as K,D as L,E as M,F as N,G as O,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as i,aa as ia,b as j,ba as ja,c as k,ca as ka,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s,l as t,m as u,n as v,o as w,p as x,q as y,r as z,s as A,t as B,u as C,v as D,w as E,x as F,y as G,z as H}from"./chunk-XBNFXWAW.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-PUOQ65NC.mjs";import{a,b,c,f as d,g as e,h as f,k as g,l as h}from"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{_ as ADVICE,t as BLOCK_PICTURES,$ as CODE_SIDEWAYS,X as HAND_OVER,u as INK_MARGIN,i as KINDS,j as LEVELS,k as LOOKS,Y as LOOK_YOURSELF,W as MORE_PICTURES,M as MOSTLY_CHANGED,y as MOVED_PART,x as MOVED_WHOLE,w as NEIGHBOUR_EDGE,p as PICTURED_INFO,ca as SCROLLS,v as SCROLL_FRAMES,s as SCROLL_SLACK,ba as WARNED,l as WIDE,m as WIDTHS,f as adoptIdless,aa as adviceOf,e as baselineOf,L as baselineSaid,b as blocksOf,N as blocksToPicture,da as describeLooks,S as disclosuresSaid,g as exportBaselines,G as exportOf,ga as exportingFirst,Q as findingKey,q as findingLevel,O as inkOf,P as inventory,n as layoutNotesOf,o as levelOf,R as lookAt,J as missedWidths,V as morePictures,H as movedBlocks,z as movedClips,ha as namedBlocks,I as nextBaseline,ea as notPicturedLine,c as pageOf,r as picturedAt,T as picturesSaid,D as placeOf,h as previewBaseline,a as rankOf,d as readBaseline,ka as run,K as seenOf,C as sourceIndex,F as staleExport,Z as startFailure,E as timeOf,ia as unknownBlocks,ja as unknownBlocksSaid,U as unopenedSaid,A as urlName,fa as verdictOf,B as wordsOf};
@@ -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{b as Q}from"./chunk-7N2LPG33.mjs";import{c as _,d as z,e as B,l as G}from"./chunk-JJNRIFND.mjs";import"./chunk-ASAXY2DJ.mjs";import"./chunk-HBAUKKQH.mjs";import{i as q}from"./chunk-YPPJVDQI.mjs";import{a as b,b as J}from"./chunk-JEUK3ZO7.mjs";import{a as Z}from"./chunk-CZ5KJSGK.mjs";import{a as ee}from"./chunk-UGO5N3EI.mjs";import"./chunk-5IIH335D.mjs";import"./chunk-QK3VISCA.mjs";import{c as V,d as Y,e as M}from"./chunk-NFABH3QW.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import{b as W,h as X}from"./chunk-WTEGUPFG.mjs";import"./chunk-KUILYI7H.mjs";import"./chunk-2GKGEVMR.mjs";import{b as T,f as C,g as H}from"./chunk-4OZWXZE5.mjs";import"./chunk-KH24LWAT.mjs";import{k as U}from"./chunk-YFJU3O7G.mjs";import{b as K}from"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";import v from"node:fs/promises";import se from"node:os";import x from"node:path";import{IMPORT_EXT as re,kindOf as ie}from"../browser/shared/import-types.mjs";import{reportsDirectory as O}from"../browser/shared/paths.mjs";import{kebab as S}from"../browser/shared/web-links.mjs";import{documentDirectory as oe,documentFiles as E,newDocSlug as ae}from"../browser/shared/workspace.mjs";var ce=Object.values(re).flat().join(" "),j=(d,g)=>`${d} ${g}${d===1?"":"s"}`;function fe(d,g,p){let n=(f,r=g)=>(r.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),$=n(/<li id="fn-\d+"/g,p),w=[[n(/<section class="doc-section"/g),"section"],[n(/<h[2-4][\s>]/g),"heading"],[n(/<p[\s>]/g),"paragraph"],[n(/<(?:ul|ol)[\s>]/g),"list"],[n(/<table\b/g),"table"],[n(/class="doc-math-(?:inline|block)"/g,p),"formula"],[n(/<div class="doc-code"/g),"code block"],[n(/<figure class="doc-image"/g),"picture"],[c,"flow"],[$,"footnote"]].filter(([f])=>f>0).map(([f,r])=>j(f,r)),h=(d.raws?.length??0)-c-($?1:0);return h>0&&w.push(`${j(h,"HTML block")} kept as written`),w}async function Se(d){let{positional:g,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,$]=g;if(g.length<1||g.length>3||!n)throw new T("Name the file; then the slug and the title, if you choose them.");let w=ie(n);if(!w)throw new T(`Not a kind of file gallery import takes: ${n} (${ce}).`);c!==void 0&&H(c);let h=x.resolve(n);await v.stat(h).then(i=>i.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await Q(c):null;f&&(console.error(f),process.exit(1));let r=x.basename(h),F=await v.mkdtemp(x.join(se.tmpdir(),"gallery-import-")),L,y,R;try{let i,u=[];if(w==="markdown")i=[{...await Y(h,F),from:r,children:[]}];else try{({pages:i,skipped:u}=await V([{file:h,name:r}],F))}catch(e){console.error(`${r} could not be read: ${e.message}`),process.exit(1)}i.length===0&&(console.error(`Nothing in ${r} could be read as a page${u.length?` (not taken: ${u.join(", ")})`:""}.`),process.exit(1)),$?.trim()&&(i[0]={...i[0],title:$.replace(/\s+/g," ").trim()});let I=new Map,te=ee({edits:{},reports:{},reportsDirectory:O});y=(await Z(i,{create:async(e,t,l,{lang:s})=>{let{directory:o}=await K(e,t,l,{blank:!0,lang:s});I.set(e,await v.readFile(E(o).html,"utf8"))},slugOf:(e,t)=>{if(t===0&&c!==void 0)return c;let l=S(e.title)||S(e.from?.replace(/\.[^.]+$/,"")??"")||S(r.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>q(e,{parent:t})})).made;let P=[],A=(e,t)=>{P.push({page:e,depth:t});for(let l of e.children??[])A(l,t+1)};for(let e of i)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let s=y[l],o=oe(s,O),a=E(o).html,k=await v.readFile(a,"utf8"),ne=(await M({source:I.get(s),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=X(W(k,{finish:U}).text);return{slug:s,depth:t,page:e,directory:o,htmlFile:a,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:s,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${r}`),console.log(`Title: ${e.title}`),console.log(`Made: ${s.length?s.join(", "):"nothing but the title"}${e.files.length?` (${j(e.files.length,"file")} in ${b(x.join(t,"assets"))})`:""}`),e.notes?.length){console.log(`Not brought as the file has it (${e.notes.length}):`);for(let a of e.notes)console.log(` ${a.line?`line ${a.line}: `:""}${a.text}`)}if(o.length){console.log(`Text the preview leaves read-only (${o.length}), by doc.html's lines as gallery check gives them:`);for(let a of o)console.log(` ${a}`)}}else{console.log(`Created ${j(m.length,"document")} from ${r} (each nested as in the file):`);for(let{slug:l,depth:s,page:o,htmlFile:a,made:k}of m)console.log(`${" ".repeat(s+1)}${l} ${o.title} ${b(a)}`),console.log(`${" ".repeat(s+2)}Made: ${k.length?k.join(", "):"nothing but the title"}${o.files.length?` (${j(o.files.length,"file")} in its assets/)`:""}`);let e=m.flatMap(({slug:l,page:s})=>(s.notes??[]).map(o=>` ${l}: ${o.line?`line ${o.line}: `:""}${o.text}`));e.length&&console.log(`Not brought as the file has it (${e.length}):
2
+ import{b as Q}from"./chunk-2HS7ZBPU.mjs";import{c as _,d as z,e as B,l as G}from"./chunk-SQ3FQCCN.mjs";import"./chunk-3F57LEN5.mjs";import"./chunk-QP7BOHE4.mjs";import{i as q}from"./chunk-GMJD7ID3.mjs";import{a as b,b as J}from"./chunk-JEUK3ZO7.mjs";import{a as Z}from"./chunk-JJNHKGTD.mjs";import{a as ee}from"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import{c as V,d as Y,e as M}from"./chunk-RRKJMHNX.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import{b as W,h as X}from"./chunk-VRPVVMRB.mjs";import"./chunk-L55NOXBE.mjs";import"./chunk-7UZUQQ7Q.mjs";import{b as T,f as C,g as H}from"./chunk-4OZWXZE5.mjs";import"./chunk-ZTHICSSF.mjs";import{k as U}from"./chunk-FJLM7YE7.mjs";import{b as K}from"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import v from"node:fs/promises";import se from"node:os";import x from"node:path";import{IMPORT_EXT as re,kindOf as ie}from"../browser/shared/import-types.mjs";import{reportsDirectory as O}from"../browser/shared/paths.mjs";import{kebab as S}from"../browser/shared/web-links.mjs";import{documentDirectory as oe,documentFiles as E,newDocSlug as ae}from"../browser/shared/workspace.mjs";var ce=Object.values(re).flat().join(" "),j=(d,g)=>`${d} ${g}${d===1?"":"s"}`;function fe(d,g,p){let n=(f,r=g)=>(r.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),$=n(/<li id="fn-\d+"/g,p),w=[[n(/<section class="doc-section"/g),"section"],[n(/<h[2-4][\s>]/g),"heading"],[n(/<p[\s>]/g),"paragraph"],[n(/<(?:ul|ol)[\s>]/g),"list"],[n(/<table\b/g),"table"],[n(/class="doc-math-(?:inline|block)"/g,p),"formula"],[n(/<div class="doc-code"/g),"code block"],[n(/<figure class="doc-image"/g),"picture"],[c,"flow"],[$,"footnote"]].filter(([f])=>f>0).map(([f,r])=>j(f,r)),h=(d.raws?.length??0)-c-($?1:0);return h>0&&w.push(`${j(h,"HTML block")} kept as written`),w}async function Se(d){let{positional:g,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,$]=g;if(g.length<1||g.length>3||!n)throw new T("Name the file; then the slug and the title, if you choose them.");let w=ie(n);if(!w)throw new T(`Not a kind of file gallery import takes: ${n} (${ce}).`);c!==void 0&&H(c);let h=x.resolve(n);await v.stat(h).then(i=>i.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await Q(c):null;f&&(console.error(f),process.exit(1));let r=x.basename(h),F=await v.mkdtemp(x.join(se.tmpdir(),"gallery-import-")),L,y,R;try{let i,u=[];if(w==="markdown")i=[{...await Y(h,F),from:r,children:[]}];else try{({pages:i,skipped:u}=await V([{file:h,name:r}],F))}catch(e){console.error(`${r} could not be read: ${e.message}`),process.exit(1)}i.length===0&&(console.error(`Nothing in ${r} could be read as a page${u.length?` (not taken: ${u.join(", ")})`:""}.`),process.exit(1)),$?.trim()&&(i[0]={...i[0],title:$.replace(/\s+/g," ").trim()});let I=new Map,te=ee({edits:{},reports:{},reportsDirectory:O});y=(await Z(i,{create:async(e,t,l,{lang:s})=>{let{directory:o}=await K(e,t,l,{blank:!0,lang:s});I.set(e,await v.readFile(E(o).html,"utf8"))},slugOf:(e,t)=>{if(t===0&&c!==void 0)return c;let l=S(e.title)||S(e.from?.replace(/\.[^.]+$/,"")??"")||S(r.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>q(e,{parent:t})})).made;let P=[],A=(e,t)=>{P.push({page:e,depth:t});for(let l of e.children??[])A(l,t+1)};for(let e of i)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let s=y[l],o=oe(s,O),a=E(o).html,k=await v.readFile(a,"utf8"),ne=(await M({source:I.get(s),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=X(W(k,{finish:U}).text);return{slug:s,depth:t,page:e,directory:o,htmlFile:a,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:s,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${r}`),console.log(`Title: ${e.title}`),console.log(`Made: ${s.length?s.join(", "):"nothing but the title"}${e.files.length?` (${j(e.files.length,"file")} in ${b(x.join(t,"assets"))})`:""}`),e.notes?.length){console.log(`Not brought as the file has it (${e.notes.length}):`);for(let a of e.notes)console.log(` ${a.line?`line ${a.line}: `:""}${a.text}`)}if(o.length){console.log(`Text the preview leaves read-only (${o.length}), by doc.html's lines as gallery check gives them:`);for(let a of o)console.log(` ${a}`)}}else{console.log(`Created ${j(m.length,"document")} from ${r} (each nested as in the file):`);for(let{slug:l,depth:s,page:o,htmlFile:a,made:k}of m)console.log(`${" ".repeat(s+1)}${l} ${o.title} ${b(a)}`),console.log(`${" ".repeat(s+2)}Made: ${k.length?k.join(", "):"nothing but the title"}${o.files.length?` (${j(o.files.length,"file")} in its assets/)`:""}`);let e=m.flatMap(({slug:l,page:s})=>(s.notes??[]).map(o=>` ${l}: ${o.line?`line ${o.line}: `:""}${o.text}`));e.length&&console.log(`Not brought as the file has it (${e.length}):
3
3
  ${e.join(`
4
4
  `)}`);let t=m.flatMap(({slug:l,readOnly:s})=>s.map(o=>` ${l}: ${o}`));t.length&&console.log(`Text the preview leaves read-only (${t.length}), by doc.html's lines as gallery check gives them:
5
5
  ${t.join(`
@@ -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 as R}from"./chunk-DKR7LFIY.mjs";import{b as I,c as B}from"./chunk-342HXE3Q.mjs";import{a as f,b as F,c as L,d as M}from"./chunk-3A5I2GJK.mjs";import{a as S,b as k,g as $}from"./chunk-XQRUG4G3.mjs";import{a as N}from"./chunk-DR73Y2UJ.mjs";import{k as b}from"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import{b as D}from"./chunk-5IIH335D.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import{b as v}from"./chunk-WTEGUPFG.mjs";import{j as d}from"./chunk-4OZWXZE5.mjs";import{k as w,q as h,t as g,u as y,v as x}from"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";import O from"node:fs/promises";import{reportsDirectory as P}from"../browser/shared/paths.mjs";import{documentDirectory as U,documentFiles as q,layoutOf as z}from"../browser/shared/workspace.mjs";function C(s=P){let n=D({root:s,read:async a=>{let o=await O.readFile(q(U(a,s)).html,"utf8").catch(()=>null);return o===null?null:{source:o,text:v(o).text}},activity:N({file:z(s).activity})});return a=>n.snapshot(a)}async function te(s){let{slugs:t,options:n}=await d({options:["--allow-failures"],argv:s});t.length===0&&(console.error(R()),process.exit(1));let a=await b(t),o=await w(t,{prepare:f({say:!1})}),r=await S(t.filter(e=>!o.has(e)));await k(t.filter(e=>o.has(e)||r.failures.has(e))),await L(t),await M(t);let m=t.filter(e=>!o.has(e)&&!r.failures.has(e)),{built:l,exported:p,failures:c}=m.length>0?await h(m,{prepare:f({say:!1}),workspace:C()}):{built:[],exported:[],failures:new Map};for(let[e,i]of[...o,...r.failures])c.set(e,i);await y(c,{exportNote:!0}),await a.keep(p.map(({slug:e})=>e));let A=new Map(l.map(({report:e,removed:i})=>[e.slug,i]));for(let{slug:e,bytes:i,sha256:j}of p){let u=A.get(e),E=u.length>0?`; shared scripts and styles left out (unused): ${u.join(", ")}`:"";console.log(`Exported ${I(e)} (${i.toLocaleString("en-US")} bytes, sha256 ${j})${E}`)}g(l.map(({report:e})=>e)),F(l.map(({report:e})=>e));for(let e of r.lines)console.log(e);r.written.length>0&&console.log($(r.written));for(let{slug:e}of p)console.log(B(e));x(c,{above:!0,allow:n.has("--allow-failures")})}export{te as run};
2
+ import{a as R}from"./chunk-6Y3HYOBM.mjs";import{b as I,c as B}from"./chunk-342HXE3Q.mjs";import{a as f,b as F,c as L,d as M}from"./chunk-T4Y2ZSVX.mjs";import{a as S,b as k,g as $}from"./chunk-5GK7HS62.mjs";import{a as N}from"./chunk-DR73Y2UJ.mjs";import{k as b}from"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import{b as D}from"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import{b as v}from"./chunk-VRPVVMRB.mjs";import{j as d}from"./chunk-4OZWXZE5.mjs";import{k as w,q as h,t as g,u as y,v as x}from"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import O from"node:fs/promises";import{reportsDirectory as P}from"../browser/shared/paths.mjs";import{documentDirectory as U,documentFiles as q,layoutOf as z}from"../browser/shared/workspace.mjs";function C(s=P){let n=D({root:s,read:async a=>{let o=await O.readFile(q(U(a,s)).html,"utf8").catch(()=>null);return o===null?null:{source:o,text:v(o).text}},activity:N({file:z(s).activity})});return a=>n.snapshot(a)}async function te(s){let{slugs:t,options:n}=await d({options:["--allow-failures"],argv:s});t.length===0&&(console.error(R()),process.exit(1));let a=await b(t),o=await w(t,{prepare:f({say:!1})}),r=await S(t.filter(e=>!o.has(e)));await k(t.filter(e=>o.has(e)||r.failures.has(e))),await L(t),await M(t);let m=t.filter(e=>!o.has(e)&&!r.failures.has(e)),{built:l,exported:p,failures:c}=m.length>0?await h(m,{prepare:f({say:!1}),workspace:C()}):{built:[],exported:[],failures:new Map};for(let[e,i]of[...o,...r.failures])c.set(e,i);await y(c,{exportNote:!0}),await a.keep(p.map(({slug:e})=>e));let A=new Map(l.map(({report:e,removed:i})=>[e.slug,i]));for(let{slug:e,bytes:i,sha256:j}of p){let u=A.get(e),E=u.length>0?`; shared scripts and styles left out (unused): ${u.join(", ")}`:"";console.log(`Exported ${I(e)} (${i.toLocaleString("en-US")} bytes, sha256 ${j})${E}`)}g(l.map(({report:e})=>e)),F(l.map(({report:e})=>e));for(let e of r.lines)console.log(e);r.written.length>0&&console.log($(r.written));for(let{slug:e}of p)console.log(B(e));x(c,{above:!0,allow:n.has("--allow-failures")})}export{te 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-6Y3HYOBM.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as noDocuments,b 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,c,d,e,f,g,h}from"./chunk-PKVK6WFC.mjs";import"./chunk-NMF3IPYA.mjs";import"./chunk-LJLVCU6W.mjs";import"./chunk-XBNFXWAW.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-XZV72SQ4.mjs";import"./chunk-V4ZHRALW.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-SQ3FQCCN.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as PAGE_ASIDE,b as PAGE_INSIDE_ALONE,e as cardChangesOf,c as firstInstance,d as outsideWhat,g as pageHost,f as pageSaves,h as pageTryCommand};
@@ -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 as f,d as g,e as h,f as $,g as v,i as y,j as r,k as x}from"./chunk-YPPJVDQI.mjs";import{b as c,f as p}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{descendantsIn as A}from"../browser/shared/outline.mjs";async function N(L){let{positional:u,options:I,values:T}=p({options:["--top","--first"],values:["--under","--after"],argv:L});if(u.length!==1)throw new c("Name the document to move, one.");let e=x(T,I);if(e.under===void 0&&!e.top&&e.after===void 0&&!e.first)throw new c("Say where it goes: --under <document> or --top, and --after <document> or --first.");let s=await f(),a=async(b,k)=>{let d=await $(b,k,s);return d.refused&&(console.error(d.refused),process.exit(1)),d.slug},t=await a(u[0],"the document to move"),l=e.under!==void 0?await a(e.under,"--under"):e.top?"":void 0,m=e.after!==void 0?await a(e.after,"--after"):null,o=await y(t,{parent:l,after:m,first:e.first});o.ok||(console.error(v(s,t,o.reason,{parent:l,after:m,message:o.message})),process.exit(1));let n=await f(),i=A(n.children,t).length,w=`${g(n,t)}${i?` with the ${i} document${i===1?"":"s"} under it`:""}`;o.moved?console.log(`Moved ${w}: now ${r(n,o)}; it was ${r(s,o.from)}.`):console.log(`${w} is there already: ${r(n,o)}.`),console.log(h(n,t))}export{N as run};
2
+ import{a as f,d as g,e as h,f as $,g as v,i as y,j as r,k as x}from"./chunk-GMJD7ID3.mjs";import{b as c,f as p}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{descendantsIn as A}from"../browser/shared/outline.mjs";async function N(L){let{positional:u,options:I,values:T}=p({options:["--top","--first"],values:["--under","--after"],argv:L});if(u.length!==1)throw new c("Name the document to move, one.");let e=x(T,I);if(e.under===void 0&&!e.top&&e.after===void 0&&!e.first)throw new c("Say where it goes: --under <document> or --top, and --after <document> or --first.");let s=await f(),a=async(b,k)=>{let d=await $(b,k,s);return d.refused&&(console.error(d.refused),process.exit(1)),d.slug},t=await a(u[0],"the document to move"),l=e.under!==void 0?await a(e.under,"--under"):e.top?"":void 0,m=e.after!==void 0?await a(e.after,"--after"):null,o=await y(t,{parent:l,after:m,first:e.first});o.ok||(console.error(v(s,t,o.reason,{parent:l,after:m,message:o.message})),process.exit(1));let n=await f(),i=A(n.children,t).length,w=`${g(n,t)}${i?` with the ${i} document${i===1?"":"s"} under it`:""}`;o.moved?console.log(`Moved ${w}: now ${r(n,o)}; it was ${r(s,o.from)}.`):console.log(`${w} is there already: ${r(n,o)}.`),console.log(h(n,t))}export{N 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{b as g,i as S}from"./chunk-4OZWXZE5.mjs";import{workspaceBase as _}from"../browser/shared/service-location.mjs";import I from"node:fs/promises";import{listExtensions as C}from"../browser/shared/extensions.mjs";import{ancestorsIn as M,moveDocument as P,outlineAndFile as A}from"../browser/shared/outline.mjs";import{DOCS as k,groupOfTop as B,isForeign as b,isTop as G,topIn as J,topOf as U}from"../browser/shared/outline-shape.mjs";import{draftFacts as q,draftOf as z,registeredIds as K,workspaceNames as R}from"../browser/shared/drafts.mjs";import{reportsDirectory as u}from"../browser/shared/paths.mjs";import{findPreviewServer as W}from"../browser/shared/preview-server.mjs";import{roleOf as X}from"../browser/shared/reports.mjs";import{nameStops as H,workspaceName as Q}from"../browser/shared/workspace-name.mjs";import{workspaceKey as w}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as V,documentDirectory as y,documentFiles as Y,pageSlug as Z,readLink as ee}from"../browser/shared/workspace.mjs";async function ge(e=u,{others:t=w(e)===w(u)}={}){let{outline:{children:n,groups:o,links:s,shown:i},others:c}=await A(e,{others:t}),m=te(e,o,i),a=new Set(i.map(({id:r})=>r)),p=o.map(r=>({...r,name:m.get(r.id)??null,...t&&r.workspace&&!a.has(r.workspace)?{away:!0}:{}})),$=p.filter(r=>!r.extension),F=await C(e),x=Object.values(n).flat(),N=r=>typeof r=="string"?r.replace(/\s+/g," ").trim():"",j=x.some(b)?K():null,E=new Map(await Promise.all(x.map(async r=>{if(b(r)){let d=z(r),O=c.find(({id:L})=>L===d?.ws)?.facts.get(d.slug),f=O?{...O,missing:null}:await q(r,j);return[r,{slug:r,title:f.title,description:f.description,icon:f.icon,...f.url?{url:f.url}:{},draft:{path:f.path,missing:f.missing,ws:d?.ws??null}}]}if(s.includes(r)){let d=await ee(y(r,e));return[r,{slug:r,title:d?.title??r,description:"",icon:d?.icon??null,url:d?.url??""}]}let h=await I.readFile(Y(y(r,e)).json,"utf8").then(JSON.parse).catch(()=>({}));return[r,{slug:r,title:N(h?.title)||r,description:N(h?.description),icon:typeof h?.icon=="string"?h.icon:null}]})));return{children:n,groups:$,columns:p,extensions:F,documents:E}}function te(e,t,n=[]){let o=w(V()),s=new Set(t.map(({workspace:a})=>a).filter(Boolean)),i=H(),c=s.size?R(s,{stops:i}):new Map,m=new Map;for(let a of t)if(a.id===k)m.set(a.id,w(e)===o?"\u9ED8\u8BA4\u6587\u6863":Q(e,{stops:i}).name);else if(a.workspace){let p=n.find(({id:$})=>$===a.workspace);m.set(a.id,p?.isDefault?"\u9ED8\u8BA4\u6587\u6863":c.get(a.workspace)?.name??a.workspace)}else a.role==="links"&&m.set(a.id,"\u94FE\u63A5");return m}var v=e=>e?.title??e?.name??(e?.id===k?"\u6587\u6863":e?.role==="links"?"\u94FE\u63A5":e?"\u672A\u547D\u540D\u680F":"\u6587\u6863"),T=(e,t)=>e.groups?.find(({id:n})=>n===B(t));function ye(e,t){let n=e.documents.get(t);if(!n||n.url!==void 0)return null;let o=D(e,t),s=n.draft?.ws??null,i=s?e.groups.find(c=>c.workspace===s):e.groups.find(c=>c.id===k);return i&&U(i.id)===o?null:i?i.hidden?i.name??s:v(i):s}var l=({documents:e},t)=>`${t} (${e.get(t)?.title??t})`,D=(e,t)=>J(e.children,t)??"";function ke(e,t){let n=M(e.children,t).map(i=>l(e,i)),o=D(e,t),s=[...o===""?[]:[`${v(T(e,o))}\u680F`],...n];return`\u4F4D\u7F6E\uFF1A${s.length?s.join(" \u203A "):"\u9876\u5C42"}`}async function ve(e,t,n){let{slug:o}=await S(e);if(o===await Z(u))return{refused:`${e} is the \u5199\u4F5C\u504F\u597D page, which the sidebar lists apart: it moves nowhere and holds no documents (${t}).`};if(!n.documents.has(o)){let s=y(o,u);return{refused:await X(s)==="instructions"?`${e} is the \u5199\u4F5C\u504F\u597D page, which the sidebar lists apart: it moves nowhere and holds no documents (${t}).`:`No document "${e}" (${t}): gallery list --tree shows the documents and where they are.`}}return{slug:o}}var ne={"cross-workspace":()=>"Not moved: copying to another workspace requires confirmation in Gallery; the original stays in its workspace.",missing:(e,t)=>`No document "${t}" in the sidebar's tree: gallery list --tree shows them.`,parent:(e,t,{parent:n})=>`No document "${n}" to put ${l(e,t)} under: gallery list --tree shows them.`,after:(e,t,{after:n})=>`No document "${n}" to put ${l(e,t)} after: gallery list --tree shows them.`,level:(e,t,{parent:n,after:o})=>`${l(e,o)} is not under ${n?l(e,n):"the top level"}: --after names a document at the level it goes to.`,itself:(e,t)=>`${l(e,t)} cannot go after itself.`,inside:(e,t,{parent:n,after:o})=>n===void 0&&o?`${l(e,t)} cannot go after ${l(e,o)}, which is under it.`:`${l(e,t)} cannot go under ${n===t?"itself":`${l(e,n)}, which is under it`}.`,instructions:(e,t)=>"The \u5199\u4F5C\u504F\u597D page is listed apart: it moves nowhere and holds no documents."},xe=(e,t,n,o={})=>(ne[n]??((s,i,{message:c})=>`Not moved: ${c??n}.`))(e,t,o);async function oe(e,t,n="move"){let o=`127.0.0.1:${e.port}`;try{let i=await(await fetch(`http://${o}${_(u)}/__gallery/workspace/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${o}`,"X-Gallery-Token":e.token},body:JSON.stringify({...t,workspace:u}),signal:AbortSignal.timeout(3e4)})).json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin","unknown"].includes(i.reason)?null:i}catch{return null}}async function Ne(e,{parent:t=void 0,after:n=null,first:o=!1}={}){let s=await W(),i={slug:e,...t!==void 0?{parent:t}:{},after:n,first:o},c=s?await oe(s,i):null;return c||P(u,e,{parent:t,after:n,first:o})}function Oe(e,{parent:t,index:n}){let o=e.children[t]??[],s=t===""?"at the top level":G(t)?`at the top of the ${v(T(e,t))} column`:`under ${l(e,t)}`;return o.length===1?`${s}, the only ${o.some(i=>e.documents.get(i)?.url!==void 0)?"entry":"document"} there`:n===0?`${s}, first`:`${s}, right after ${l(e,o[n-1])}${n===o.length-1?", last":""}`}function Se(e,t,{top:n=!0}={}){let o=e.get("--under"),s=e.get("--after");if(o!==void 0&&t.has("--top"))throw new g("--under and --top are two places: give one.");if(s!==void 0&&t.has("--first"))throw new g("--after and --first are two places: give one.");return{under:o,top:n&&t.has("--top"),after:s,first:t.has("--first")}}export{ge as a,v as b,ye as c,l as d,ke as e,ve as f,xe as g,oe as h,Ne as i,Oe as j,Se as k};
@@ -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,c}from"./chunk-2HS7ZBPU.mjs";import"./chunk-SQ3FQCCN.mjs";import"./chunk-3F57LEN5.mjs";import"./chunk-QP7BOHE4.mjs";import"./chunk-GMJD7ID3.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-L55NOXBE.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_DESCRIPTION,c as run,b as slugRefused};
@@ -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}from"./chunk-QJ3TFJLQ.mjs";import"./chunk-EKGYYOSP.mjs";import"./chunk-5L7RYZCL.mjs";export{a as BrowserWebSocketTransport};
2
+ import{a}from"./chunk-Y34NR5JL.mjs";import"./chunk-W7XHE4CT.mjs";import"./chunk-5L7RYZCL.mjs";export{a as BrowserWebSocketTransport};
@@ -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 i,l as C}from"./chunk-YFJU3O7G.mjs";import{a as g,c as w}from"./chunk-2RKIHJI2.mjs";import{g as j,o as A,p as S}from"./chunk-VG5JEIUQ.mjs";import f from"node:path";import{attr as P,hasClass as z,walk as D}from"../browser/shared/html-tree.mjs";import{projectRoot as F,sdkDirectory as O,typeRoots as Y}from"../browser/shared/paths.mjs";var H=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]);function y(t,{diffs:s=!1,tree:r=g(t)}={}){let n=[];return D(r,a=>{if(a.tagName!=="script"||P(a,"src")!==void 0)return;let o=(P(a,"type")||"").trim().toLowerCase(),l=s&&o==="application/json"&&a.parentNode?.tagName?a.parentNode:null,e=l&&z(l,"doc-diff")?"__declaredDiff(":void 0;if(!e&&o&&o!=="module"&&!H.has(o))return;let{startTag:c,endTag:p}=a.sourceCodeLocation??{};c&&n.push({start:c.endOffset,end:p?.startOffset??t.length,module:o==="module",...e?{call:e}:{}})},{inTemplates:!1}),n}function L(t,s,r=[]){let n=[],a=0,o="",l=e=>e.replace(/[^\r\n]/g," ");for(let{start:e,end:c,call:p}of s){let u=o+l(t.slice(a+o.length,e));if(p){let h=V(u,p,o.length);if(h===null){r.push(e);continue}u=h}n.push(u,t.slice(e,c)),a=c,o=p?");":""}return n.push(o+l(t.slice(a+o.length)),`
2
+ import{a as i,l as C}from"./chunk-FJLM7YE7.mjs";import{a as g,c as w}from"./chunk-HYMEEXKN.mjs";import{g as j,o as A,p as S}from"./chunk-TKWEX4FD.mjs";import f from"node:path";import{attr as P,hasClass as z,walk as D}from"../browser/shared/html-tree.mjs";import{projectRoot as F,sdkDirectory as O,typeRoots as Y}from"../browser/shared/paths.mjs";var H=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]);function y(t,{diffs:s=!1,tree:r=g(t)}={}){let n=[];return D(r,a=>{if(a.tagName!=="script"||P(a,"src")!==void 0)return;let o=(P(a,"type")||"").trim().toLowerCase(),l=s&&o==="application/json"&&a.parentNode?.tagName?a.parentNode:null,e=l&&z(l,"doc-diff")?"__declaredDiff(":void 0;if(!e&&o&&o!=="module"&&!H.has(o))return;let{startTag:c,endTag:p}=a.sourceCodeLocation??{};c&&n.push({start:c.endOffset,end:p?.startOffset??t.length,module:o==="module",...e?{call:e}:{}})},{inTemplates:!1}),n}function L(t,s,r=[]){let n=[],a=0,o="",l=e=>e.replace(/[^\r\n]/g," ");for(let{start:e,end:c,call:p}of s){let u=o+l(t.slice(a+o.length,e));if(p){let h=V(u,p,o.length);if(h===null){r.push(e);continue}u=h}n.push(u,t.slice(e,c)),a=c,o=p?");":""}return n.push(o+l(t.slice(a+o.length)),`
3
3
  export {};
4
4
  `),n.join("")}function V(t,s,r){let n=t.length;for(;;){let a=Math.max(t.lastIndexOf(`
5
5
  `,n-1)+1,r),o=t[n-1]==="\r"?n-1:n;if(o-a>=s.length)return t.slice(0,o-s.length)+s+t.slice(o);if(a<=r)return null;n=a-1}}function Pt(t,s=g(t)){return L(t,y(t,{tree:s}))}var q=new Set(["href","src","action","formaction"]),X=t=>{try{return decodeURIComponent(t)}catch{return t}};function Z(t,s){let r=y(t,{tree:s}).map(({start:n,end:a})=>({code:t.slice(n,a),start:n,where:"the document's script"}));return D(s,n=>{for(let{name:a,value:o}of n.attrs){let l=n.sourceCodeLocation?.attrs?.[a]?.startLine??n.sourceCodeLocation?.startLine,e=q.has(a)?o.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""):"";/^on[a-z]+$/.test(a)?r.push({code:o,line:l,where:`the ${a} attribute of <${n.tagName}>`}):/^javascript:/i.test(e)&&r.push({code:X(e.slice(11)),line:l,where:`the javascript: address of <${n.tagName} ${a}>`})}},{inTemplates:!1}),r}var R=new Set(["fetch","XMLHttpRequest","WebSocket","EventSource","sendBeacon","import"]),E=new Set(["window","globalThis","self"]),Q=t=>i.isIdentifier(t)?t.text==="navigator":i.isPropertyAccessExpression(t)&&t.name.text==="navigator"&&i.isIdentifier(t.expression)&&E.has(t.expression.text);function I(t){let{initializer:s}=i.walkUpBindingElementsAndPatterns(t);return!!s&&i.isIdentifier(s)&&E.has(s.text)}function tt(t){let s=t.parent;return i.isPropertyAccessExpression(s)&&s.name===t?i.isIdentifier(s.expression)&&E.has(s.expression.text):i.isBindingElement(s)&&s.propertyName===t?I(s):!((i.isPropertyAssignment(s)||i.isMethodDeclaration(s)||i.isPropertyDeclaration(s)||i.isGetAccessorDeclaration(s)||i.isSetAccessorDeclaration(s))&&s.name===t)}function et(t,s){return i.isIdentifier(t)&&s.has(t.text)&&tt(t)?{name:t.text,reference:i.isPropertyAccessExpression(t.parent)&&t.parent.name===t?t.parent:t}:i.isElementAccessExpression(t)&&i.isIdentifier(t.expression)&&E.has(t.expression.text)&&i.isStringLiteralLike(t.argumentExpression)&&s.has(t.argumentExpression.text)?{name:t.argumentExpression.text,reference:t}:i.isPropertyAccessExpression(t)&&s.has(t.name.text)&&t.name.text==="sendBeacon"&&Q(t.expression)?{name:"sendBeacon",reference:t}:s.has("import")&&i.isCallExpression(t)&&t.expression.kind===i.SyntaxKind.ImportKeyword?{name:"import",reference:t.expression}:null}function st(t,s){let r=new Map,n=(e,c)=>{let p=e.parent;for(;p&&!c(p);)p=p.parent;return p??t},a=e=>i.isFunctionLike(e)||i.isBlock(e)||i.isCaseBlock(e)||i.isForStatement(e)||i.isForInStatement(e)||i.isForOfStatement(e),o=e=>i.isFunctionExpression(e)||i.isClassExpression(e)?e:i.isFunctionDeclaration(e)||i.isClassDeclaration(e)?n(e,a):i.isCatchClause(e.parent)?e.parent:n(e,i.getCombinedNodeFlags(e)&i.NodeFlags.BlockScoped?a:i.isFunctionLike),l=e=>{(i.isParameter(e)||i.isVariableDeclaration(e)||i.isBindingElement(e)||i.isFunctionDeclaration(e)||i.isClassDeclaration(e)||i.isFunctionExpression(e)||i.isClassExpression(e))&&e.name&&i.isIdentifier(e.name)&&s.has(e.name.text)&&!(i.isBindingElement(e)&&I(e))&&r.set(e.name.text,[...r.get(e.name.text)??[],o(e)]),i.forEachChild(e,l)};return l(t),r}function rt(t,s=[]){for(let r=t;r;r=r.parent)if(s.includes(r))return!0;return!1}function Nt(t,s,{tree:r=g(t)}={}){let n=[];for(let{code:a,start:o,line:l,where:e}of Z(t,r))for(let{name:c,how:p,at:u}of k(a,s))n.push({name:c,how:p,line:l??w(t,o+u),where:e});return n.sort((a,o)=>a.line-o.line)}function k(t,s){if(![...s].some(l=>t.includes(l)))return[];let r=[],n=i.createSourceFile("code.js",t,i.ScriptTarget.Latest,!0,i.ScriptKind.JS),a=st(n,s),o=l=>{let e=et(l,s),c=e?.reference.parent;if(e&&!i.isTypeOfExpression(c)&&!(i.isIdentifier(e.reference)&&rt(l,a.get(e.name)))){let p=(i.isCallExpression(c)||i.isNewExpression(c))&&c.expression===e.reference?i.isNewExpression(c)?"new":"call":"use";r.push({name:e.name,how:p,at:l.getStart(n)})}i.forEachChild(l,o)};return o(n),r}var nt=new Set([2304,2552]),it=new Set([2300,2451,2448,2449,2450]),M=t=>nt.has(t)||it.has(t)||t>=1e3&&t<2e3;function at(t,s,r){if(!t.file||r.has(t)||M(t.code))return!1;let n=t.start??-1;return s.some(a=>!a.call&&a.start<=n&&n<a.end)}var ot=(t,s)=>/\bNumberValue\b/.test(t)||/\bd3\.(?:min|max|extent)\(/.test(s)?"; here d3 reads values of no type as strings: give the data its shape once with JSDoc, /** @type {Array<{ label: string, value: number }>} */ const rows = data;, and d3.min or d3.max may give undefined (?? 0)":"";function B(t){let s={allowJs:!0,checkJs:!0,noEmit:!0,allowUmdGlobalAccess:!0,strict:!0,noImplicitAny:!1,target:i.ScriptTarget.ES2022,module:i.ModuleKind.ESNext,moduleResolution:i.ModuleResolutionKind.Bundler,lib:["lib.es2022.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts"],types:["d3"],typeRoots:Y,skipLibCheck:!1},r=i.createCompilerHost(s),n=r.readFile.bind(r),a=r.fileExists.bind(r);return r.readFile=o=>t.get(f.resolve(o))??n(o),r.fileExists=o=>t.has(f.resolve(o))||a(o),i.createProgram([f.join(O,"index.d.ts"),...t.keys()],s,r)}var ct=/\bDoc[A-Z]\w*/,lt=(t,s)=>ct.test(s)||(t.relatedInformation??[]).some(({file:r})=>r&&f.resolve(r.fileName).startsWith(O+f.sep)),N={katex:"katex","katex-auto-render":"renderMathInElement"};function Dt(t,{assets:s=[]}={}){let r=f.join(F,"reports","__package__","kit.js"),n=t.replace(/^([ \t]*)(?:<!--|-->)/gm,"$1//"),a=s.filter(c=>Object.hasOwn(N,c)).map(c=>`declare const ${N[c]}: any;
@@ -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{b as n,e as c}from"./chunk-N3DSBH5S.mjs";c();var f=e=>n(e.replace(/^\uFEFF/," "),{sourceCodeLocationInfo:!0}),i=(e,o)=>e.slice(o.sourceCodeLocation.startOffset,o.sourceCodeLocation.endOffset);function a(e,o){let r=1;for(let t=e.indexOf(`
2
+ import{b as n,e as c}from"./chunk-A55HN5OK.mjs";c();var f=e=>n(e.replace(/^\uFEFF/," "),{sourceCodeLocationInfo:!0}),i=(e,o)=>e.slice(o.sourceCodeLocation.startOffset,o.sourceCodeLocation.endOffset);function a(e,o){let r=1;for(let t=e.indexOf(`
3
3
  `);t!==-1&&t<o;t=e.indexOf(`
4
4
  `,t+1))r++;return r}export{f as a,i as b,a as c};
@@ -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 p,e as L}from"./chunk-N3DSBH5S.mjs";L();import{TODO as b}from"../browser/shared/components/list.mjs";import{sha256 as k}from"../browser/shared/files.mjs";import{attr as u,BLOCK_LEVEL as N,elementsOf as O,hasClass as h}from"../browser/shared/html-tree.mjs";var w=new Set(["script","style","template","noscript","svg","math"]),y=/^h([1-6])$/,C=o=>o.replace(/[\s​]+/g," ").trim();function f(o,a=()=>!1){let n="",t=c=>{for(let s of c.childNodes??[])s.nodeName==="#text"?n+=s.value:s.tagName==="br"?n+=" ":s.tagName&&!w.has(s.tagName)&&!a(s)&&t(s)};return t(o),C(n)}function E(o){let a=f(o,t=>N.has(t.tagName));if(a)return a;let n=O(o).find(t=>N.has(t.tagName)&&t.tagName!=="ul"&&t.tagName!=="ol");return n?f(n,t=>t.tagName==="ul"||t.tagName==="ol"):""}function P(o,{at:a=!1}={}){let n=p(String(o),{sourceCodeLocationInfo:a}),t=[],c=[],s=new Map,l=v=>{for(let e of O(v)){if(w.has(e.tagName))continue;let m=y.exec(e.tagName);if(m&&!h(e,"doc-title")){let i=Number(m[1]);for(;t.length&&t.at(-1).level>=i;)t.pop();let r=f(e);r&&t.push({level:i,words:r});continue}if(e.tagName==="li"&&e.parentNode?.tagName==="ul"&&h(e.parentNode,b)){let i=t.map(({words:x})=>x),r=E(e),d=JSON.stringify([r,i]),g=s.get(d)??0;s.set(d,g+1),c.push({text:r,done:u(e,"data-checked")!==void 0,block:u(e,"data-block-id")??null,path:i,nth:g,...a?{at:e.sourceCodeLocation?.startOffset??-1}:{}})}l(e)}};return l(n),c}var V=o=>k(o).slice(0,16);export{P as a,V as b};
2
+ import{b as p,e as L}from"./chunk-A55HN5OK.mjs";L();import{TODO as b}from"../browser/shared/components/list.mjs";import{sha256 as k}from"../browser/shared/files.mjs";import{attr as u,BLOCK_LEVEL as N,elementsOf as O,hasClass as h}from"../browser/shared/html-tree.mjs";var w=new Set(["script","style","template","noscript","svg","math"]),y=/^h([1-6])$/,C=o=>o.replace(/[\s​]+/g," ").trim();function f(o,a=()=>!1){let n="",t=c=>{for(let s of c.childNodes??[])s.nodeName==="#text"?n+=s.value:s.tagName==="br"?n+=" ":s.tagName&&!w.has(s.tagName)&&!a(s)&&t(s)};return t(o),C(n)}function E(o){let a=f(o,t=>N.has(t.tagName));if(a)return a;let n=O(o).find(t=>N.has(t.tagName)&&t.tagName!=="ul"&&t.tagName!=="ol");return n?f(n,t=>t.tagName==="ul"||t.tagName==="ol"):""}function P(o,{at:a=!1}={}){let n=p(String(o),{sourceCodeLocationInfo:a}),t=[],c=[],s=new Map,l=v=>{for(let e of O(v)){if(w.has(e.tagName))continue;let m=y.exec(e.tagName);if(m&&!h(e,"doc-title")){let i=Number(m[1]);for(;t.length&&t.at(-1).level>=i;)t.pop();let r=f(e);r&&t.push({level:i,words:r});continue}if(e.tagName==="li"&&e.parentNode?.tagName==="ul"&&h(e.parentNode,b)){let i=t.map(({words:x})=>x),r=E(e),d=JSON.stringify([r,i]),g=s.get(d)??0;s.set(d,g+1),c.push({text:r,done:u(e,"data-checked")!==void 0,block:u(e,"data-block-id")??null,path:i,nth:g,...a?{at:e.sourceCodeLocation?.startOffset??-1}:{}})}l(e)}};return l(n),c}var V=o=>k(o).slice(0,16);export{P as a,V as b};