@heycys/gallery 0.2.1 → 0.2.2

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 +9 -5
  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 +19 -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-BYSF5UMM.mjs → chunk-236JJXWY.mjs} +2 -2
  38. package/dist/{chunk-3A5I2GJK.mjs → chunk-2KAVXMKG.mjs} +1 -1
  39. package/dist/chunk-2T4PZQEP.mjs +2 -0
  40. package/dist/{chunk-SAHS56QM.mjs → chunk-3SKOU6OZ.mjs} +1 -1
  41. package/dist/{chunk-S2Y7VI4H.mjs → chunk-3XZOA7AH.mjs} +2 -2
  42. package/dist/{chunk-MKTX5PGV.mjs → chunk-43B75J5T.mjs} +1 -1
  43. package/dist/{chunk-VKSRM7EY.mjs → chunk-4B2TB5K2.mjs} +1 -1
  44. package/dist/{chunk-LV24RY2E.mjs → chunk-4K5KC6V2.mjs} +1 -1
  45. package/dist/{chunk-SOD23RGL.mjs → chunk-4KUO7R2M.mjs} +8 -8
  46. package/dist/chunk-4SNV4HA5.mjs +2 -0
  47. package/dist/chunk-53XDTHTG.mjs +4 -0
  48. package/dist/chunk-5XV3YYLG.mjs +2 -0
  49. package/dist/{chunk-VNUWREXU.mjs → chunk-65NTKF4N.mjs} +1 -1
  50. package/dist/chunk-6GV3CBB2.mjs +2 -0
  51. package/dist/{chunk-DH6GMDNN.mjs → chunk-6L6V7YR2.mjs} +1 -1
  52. package/dist/{chunk-TOE6DPLH.mjs → chunk-6NLXUKAY.mjs} +1 -1
  53. package/dist/chunk-6Q7ASAXJ.mjs +3 -0
  54. package/dist/{chunk-ZCP7BTOZ.mjs → chunk-6QBHU4DF.mjs} +1 -1
  55. package/dist/{chunk-QXVNUASA.mjs → chunk-6QWQXHAV.mjs} +1 -1
  56. package/dist/chunk-6XD6U3QA.mjs +5 -0
  57. package/dist/{chunk-36FIRJIF.mjs → chunk-742D2WWJ.mjs} +2 -2
  58. package/dist/{chunk-7M7UPWU6.mjs → chunk-7EFHNQ5B.mjs} +1 -1
  59. package/dist/{chunk-JI6T3A4Y.mjs → chunk-7ISBBDJR.mjs} +1 -1
  60. package/dist/{chunk-2GKGEVMR.mjs → chunk-7UZUQQ7Q.mjs} +25 -24
  61. package/dist/{chunk-VPVOAJ7X.mjs → chunk-AGDILNWB.mjs} +1 -1
  62. package/dist/{chunk-5IIH335D.mjs → chunk-ALZ6ZENZ.mjs} +1 -1
  63. package/dist/{chunk-G4YP7GVC.mjs → chunk-BFJGHSQN.mjs} +1 -1
  64. package/dist/chunk-BLNQUR5R.mjs +168 -0
  65. package/dist/chunk-BMX3VUHY.mjs +2 -0
  66. package/dist/chunk-BN7M3IN7.mjs +8 -0
  67. package/dist/{chunk-AMDGVDNV.mjs → chunk-BQNTTFPL.mjs} +1 -1
  68. package/dist/chunk-C257H6IA.mjs +2 -0
  69. package/dist/{chunk-74RPP2M2.mjs → chunk-C564NU2H.mjs} +1 -1
  70. package/dist/chunk-CHQU37CA.mjs +2 -0
  71. package/dist/{chunk-WCWYNFDF.mjs → chunk-E4IHAIJ7.mjs} +1 -1
  72. package/dist/{chunk-7XDYK3UC.mjs → chunk-E7656LR7.mjs} +1 -1
  73. package/dist/{chunk-KFZBYDIS.mjs → chunk-ECZBLQKK.mjs} +1 -1
  74. package/dist/{chunk-PAFSFVYB.mjs → chunk-ERE2BXYV.mjs} +1 -1
  75. package/dist/{chunk-ZEY2RLBT.mjs → chunk-ERLAIBOA.mjs} +2 -2
  76. package/dist/chunk-FFV733MA.mjs +2 -0
  77. package/dist/{chunk-CZ5KJSGK.mjs → chunk-GJJRBGMY.mjs} +1 -1
  78. package/dist/{chunk-VA3KAQZD.mjs → chunk-GKOBB6DH.mjs} +1 -1
  79. package/dist/chunk-GMJD7ID3.mjs +2 -0
  80. package/dist/{chunk-QZ35UAB4.mjs → chunk-GRAXKKG4.mjs} +1 -1
  81. package/dist/{chunk-2RKIHJI2.mjs → chunk-HYMEEXKN.mjs} +1 -1
  82. package/dist/{chunk-DKR7LFIY.mjs → chunk-IA2SIEJQ.mjs} +1 -1
  83. package/dist/{chunk-QK3VISCA.mjs → chunk-IA4PSIMD.mjs} +1 -1
  84. package/dist/chunk-JPG2LBQM.mjs +11 -0
  85. package/dist/{chunk-VGTMLQWZ.mjs → chunk-JXXHAXYH.mjs} +1 -1
  86. package/dist/{chunk-5MEXZ2UF.mjs → chunk-K3JKPFL5.mjs} +1 -1
  87. package/dist/{chunk-LE44MD3O.mjs → chunk-KLQP46Y3.mjs} +1 -1
  88. package/dist/{chunk-NAGMRVW4.mjs → chunk-LKX55H76.mjs} +1 -1
  89. package/dist/chunk-LMUZQK5O.mjs +2 -0
  90. package/dist/{chunk-CG3UHDKH.mjs → chunk-M4NRDYI5.mjs} +1 -1
  91. package/dist/{chunk-HM4E43VM.mjs → chunk-MAFIGVXY.mjs} +1 -1
  92. package/dist/{chunk-4DNHHJSL.mjs → chunk-MKIBJTJZ.mjs} +1 -1
  93. package/dist/{chunk-L7W624FD.mjs → chunk-MNWJ4EZY.mjs} +1 -1
  94. package/dist/{chunk-FXQBADMN.mjs → chunk-NHP66IWR.mjs} +1 -1
  95. package/dist/{chunk-YBB5LWZK.mjs → chunk-OEIJLMPI.mjs} +1 -1
  96. package/dist/{chunk-NWRZXELO.mjs → chunk-PAREWQGB.mjs} +1 -1
  97. package/dist/{chunk-7N2LPG33.mjs → chunk-PDZR3L3C.mjs} +1 -1
  98. package/dist/{chunk-YFJU3O7G.mjs → chunk-PLB7L22J.mjs} +1 -1
  99. package/dist/{chunk-4AMTKWDO.mjs → chunk-PUOQ65NC.mjs} +1 -1
  100. package/dist/chunk-Q4MS6OFC.mjs +2 -0
  101. package/dist/{chunk-3OFXMN6N.mjs → chunk-Q7P3Q5YX.mjs} +1 -1
  102. package/dist/{chunk-6MPKCH3P.mjs → chunk-QNECWMGR.mjs} +1 -1
  103. package/dist/{chunk-HBAUKKQH.mjs → chunk-QP7BOHE4.mjs} +1 -1
  104. package/dist/chunk-QVGOPHOF.mjs +2 -0
  105. package/dist/{chunk-NFABH3QW.mjs → chunk-RRKJMHNX.mjs} +2 -2
  106. package/dist/chunk-S3SX3COT.mjs +20 -0
  107. package/dist/{chunk-ZO7SFB2E.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  108. package/dist/{chunk-VG5JEIUQ.mjs → chunk-TKWEX4FD.mjs} +2 -2
  109. package/dist/{chunk-CCSGFCLZ.mjs → chunk-U3SSPL4K.mjs} +1 -1
  110. package/dist/{chunk-DHB7UZ7F.mjs → chunk-U5XL7D6A.mjs} +1 -1
  111. package/dist/{chunk-CPS4SRPF.mjs → chunk-ULXSPX5H.mjs} +2 -2
  112. package/dist/{chunk-JXLSHVJ2.mjs → chunk-UMHUSOPJ.mjs} +1 -1
  113. package/dist/chunk-USIHBCSW.mjs +15 -0
  114. package/dist/{chunk-GWOYMENX.mjs → chunk-V6XZ4VIR.mjs} +1 -1
  115. package/dist/{chunk-AFGUR7SY.mjs → chunk-VPMRP2TL.mjs} +1 -1
  116. package/dist/{chunk-WTEGUPFG.mjs → chunk-VRPVVMRB.mjs} +1 -1
  117. package/dist/chunk-VZ2RQ3AM.mjs +2 -0
  118. package/dist/{chunk-XKOHV4H6.mjs → chunk-W5NPH5UA.mjs} +1 -1
  119. package/dist/chunk-WFGPMCTZ.mjs +4 -0
  120. package/dist/chunk-XZCFPKGO.mjs +2 -0
  121. package/dist/{chunk-QJ3TFJLQ.mjs → chunk-Y34NR5JL.mjs} +1 -1
  122. package/dist/{chunk-V5JRSGZF.mjs → chunk-YN37ZDLW.mjs} +1 -1
  123. package/dist/chunk-ZFGMJVJC.mjs +2 -0
  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 +12 -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-xP0uw3a0.css → index-FLb9jCfl.css} +1 -1
  138. package/web/assets/index-czjrXVjf.js +15 -0
  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,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{e as H,f as K,g as Q}from"./chunk-OU3S466R.mjs";import{d as D,f as E,g as T,h as F}from"./chunk-VG5JEIUQ.mjs";import{existsSync as R}from"node:fs";var U=120;function W(n,I){let p=({packages:s,problems:c})=>new Map([...s,...c].map(([a,{stamp:t}])=>[a,t])),[l,f]=[p(n),p(I)];return[...new Set([...l.keys(),...f.keys()])].filter(s=>l.get(s)!==f.get(s)).sort()}function A({root:n,tell:I,delay:p=U,quiet:l=Q,hold:f=H,limit:s=K,now:c=Date.now,timers:a={set:(t,m)=>setTimeout(t,m),clear:t=>clearTimeout(t)}}){let t=null,m=0,u=null,r=new Map;T(n);let M=i=>{t&&m<=c()+i||(a.clear(t),m=c()+i,t=a.set(w,i),t.unref?.())};function w({settled:i=!1}={}){t=null;let d=T(n),o=E(n,d.settings),b=c();o.stamp!==u?.stamp&&(u={stamp:o.stamp,at:b});let y=b-u.at;if(y<l&&!i)return M(l-y);let g=new Map(o.packages),k=new Map(o.problems),h=1/0;for(let[e,L]of d.packages){if(!(!o.settings.disabled.includes(e)&&(k.has(e)||!g.has(e)&&R(L.folder)))){r.delete(e);continue}r.has(e)||r.set(e,u.at);let O=Math.min(f-y,s-(b-r.get(e)));if(O<=0){r.delete(e);continue}g.set(e,L),k.delete(e),h=Math.min(h,O)}let{settings:C,packs:S}=o,x=D({packages:g,problems:k,settings:C,packs:S});if(x!==d.stamp){let e={packages:g,problems:k,settings:C,packs:S,stamp:x};F(n,e),I(e,W(d,e))}h!==1/0&&M(h)}return{changed:()=>M(p),taken(){a.clear(t),w({settled:!0})},close(){a.clear(t),t=null}}}export{U as a,A as b};
2
+ import{e as H,f as K,g as Q}from"./chunk-S3SX3COT.mjs";import{d as D,f as E,g as T,h as F}from"./chunk-TKWEX4FD.mjs";import{existsSync as R}from"node:fs";var U=120;function W(n,I){let p=({packages:s,problems:c})=>new Map([...s,...c].map(([a,{stamp:t}])=>[a,t])),[l,f]=[p(n),p(I)];return[...new Set([...l.keys(),...f.keys()])].filter(s=>l.get(s)!==f.get(s)).sort()}function A({root:n,tell:I,delay:p=U,quiet:l=Q,hold:f=H,limit:s=K,now:c=Date.now,timers:a={set:(t,m)=>setTimeout(t,m),clear:t=>clearTimeout(t)}}){let t=null,m=0,u=null,r=new Map;T(n);let M=i=>{t&&m<=c()+i||(a.clear(t),m=c()+i,t=a.set(w,i),t.unref?.())};function w({settled:i=!1}={}){t=null;let d=T(n),o=E(n,d.settings),b=c();o.stamp!==u?.stamp&&(u={stamp:o.stamp,at:b});let y=b-u.at;if(y<l&&!i)return M(l-y);let g=new Map(o.packages),k=new Map(o.problems),h=1/0;for(let[e,L]of d.packages){if(!(!o.settings.disabled.includes(e)&&(k.has(e)||!g.has(e)&&R(L.folder)))){r.delete(e);continue}r.has(e)||r.set(e,u.at);let O=Math.min(f-y,s-(b-r.get(e)));if(O<=0){r.delete(e);continue}g.set(e,L),k.delete(e),h=Math.min(h,O)}let{settings:C,packs:S}=o,x=D({packages:g,problems:k,settings:C,packs:S});if(x!==d.stamp){let e={packages:g,problems:k,settings:C,packs:S,stamp:x};F(n,e),I(e,W(d,e))}h!==1/0&&M(h)}return{changed:()=>M(p),taken(){a.clear(t),w({settled:!0})},close(){a.clear(t),t=null}}}export{U as a,A as b};
@@ -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{d as e}from"./chunk-36FIRJIF.mjs";function a(r){switch(r){case"chrome":return e.STABLE;case"chrome-dev":return e.DEV;case"chrome-beta":return e.BETA;case"chrome-canary":return e.CANARY}}export{a};
2
+ import{d as e}from"./chunk-742D2WWJ.mjs";function a(r){switch(r){case"chrome":return e.STABLE;case"chrome-dev":return e.DEV;case"chrome-beta":return e.BETA;case"chrome-canary":return e.CANARY}}export{a};
@@ -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 fe,b as At}from"./chunk-342HXE3Q.mjs";import{c as ue,d as pe}from"./chunk-3A5I2GJK.mjs";import{b as ae}from"./chunk-XQRUG4G3.mjs";import{a as ie,b as re,c as le,d as ce,f as Dt,g as de,h as he}from"./chunk-4AMTKWDO.mjs";import{b as _t,c as ee,d as oe,f as ne,h as se}from"./chunk-FCK6NXON.mjs";import{b as Wt,j as Qt}from"./chunk-4OZWXZE5.mjs";import{g as te}from"./chunk-SAHS56QM.mjs";import{a as Zt}from"./chunk-2RKIHJI2.mjs";import{a as Vt}from"./chunk-JXLSHVJ2.mjs";import{spawnSync as Le}from"node:child_process";import vt from"node:fs/promises";import ht from"node:path";import{pathToFileURL as Ie}from"node:url";import{MATH_IGNORED_TAGS as Fe}from"../browser/shared/components/math.mjs";import{exportPackagesOf as Pe,exportSourceOf as Ve,packagesSaid as _e}from"../browser/shared/export-wrap.mjs";import{sha256 as ge}from"../browser/shared/files.mjs";import{attr as me}from"../browser/shared/html-tree.mjs";import{projectRoot as De,qaDirectory as He,reportsDirectory as Rt}from"../browser/shared/paths.mjs";import{documentDirectory as Lt,documentFiles as It}from"../browser/shared/workspace.mjs";import{KINDS as Yo,LEVELS as Bt,LOOKS as we,WIDE as Ko,WIDTHS as $e,layoutNotesOf as ze,levelOf as Ee}from"../browser/shared/qa-levels.mjs";import{tableHidesScript as Ue}from"../browser/shared/table-hides.mjs";var Ge=new Set(["code-scrolls","formula-scrolls"]),qe=(e,n)=>e.level??Ee(e.kind,n),Ye=(e,n)=>["fail","warn"].includes(qe(e,n))||Ge.has(e.kind)&&Ee(e.kind,n)==="info",Ke=4,Ae=12,Xe=8,Je=2,xe=200,Qe=2e3,ye=600;function Ze({block:e,above:n=null,below:s=null}){let l=[e,n,s].filter(Boolean),i=Math.min(...l.map(u=>u.left)),d=Math.max(...l.map(u=>u.right)),w=n?Math.max(Math.min(n.top,e.top),e.top-xe):e.top,f=s?Math.min(Math.max(s.bottom,e.bottom),e.bottom+xe):e.bottom,x=(u,A)=>({x:Math.max(0,i),y:Math.max(0,u),width:d-i,height:A-Math.max(0,u)});return e.bottom-e.top<=Qe?[{part:"",clip:x(w,f)}]:[{part:"top",clip:x(w,e.top+ye)},{part:"bottom",clip:x(e.bottom-ye,f)}]}function be(e,n=""){if(e.startsWith("data:"))return`${e.slice(0,30)}\u2026 (${e.length} characters)`;let s=n.slice(0,n.lastIndexOf("/")+1);if(s&&e.startsWith(s)&&e.length>s.length)try{return decodeURIComponent(e.slice(s.length))}catch{return e.slice(s.length)}return e.length>60?`\u2026${e.slice(-59)}`:e}var Ft=e=>String(e??"").replace(/\s+/g," ").trim(),Mt=(e,n=40)=>{let s=Ft(e);return`"${s.length>n?`${s.slice(0,n-1)}\u2026`:s}"`},to=e=>String(e??"").replace(/\s+/g,"").slice(0,120);function eo(e,n="doc.html"){let s=new Map,l=new Map,i=new Map,d=(x,u)=>(u&&x.sourceCodeLocation.attrs?.[u]||x.sourceCodeLocation).startLine,w=new Map,f=x=>{if(x.nodeName==="#text")return x.value;if(!x.tagName&&x.nodeName!=="#document"||x.tagName==="template")return"";let u=(x.childNodes??[]).map(f).join("");if(!x.tagName||!x.sourceCodeLocation)return u;let A=me(x,"data-block-id");A!==void 0&&!s.has(A)&&s.set(A,d(x,"data-block-id"));let j=me(x,"id");j!==void 0&&!l.has(j)&&l.set(j,d(x,"id"));let K=to(u);if(K.length>=2){let m=`${x.tagName}|${K}`;w.has(m)||w.set(m,[]),w.get(m).push(x.sourceCodeLocation)}return u};f(Zt(e));for(let[x,u]of w)i.set(x,u.sort((A,j)=>A.startOffset-j.startOffset).map(A=>A.startLine));return{blocks:s,ids:l,texts:i,name:n}}function oo(e,n){if(!e)return"the page";let s=n.name??"doc.html",l=u=>{let A=u&&n.texts.get(`${u.tag}|${u.words}`);return A?.[Math.min(u.nth??0,A.length-1)]},i=e.table||e.header?.text,d=e.card?` card ${Mt(e.card.text)}`:i?` table ${Mt(i)}`:"",w=e.blocks?.find(u=>n.blocks.has(u));if(w!==void 0)return`${s}:${n.blocks.get(w)} [data-block-id="${w}"]${d}`;if(l(e.card))return`${s}:${l(e.card)} card ${Mt(e.card.text)}`;if(l(e.header))return`${s}:${l(e.header)} table ${Mt(i)}`;let f=e.texts?.find(l);if(f)return`${s}:${l(f)} ${f===e.texts[0]&&f.tag===e.tag?"":`${e.element} in `}<${f.tag}> ${Mt(f.text,32)}`;let x=e.ids?.find(u=>n.ids.has(u));return x!==void 0?`${s}:${n.ids.get(x)} #${x}${d}`:l(e.section)?`${s}:${l(e.section)} ${e.element} in the section ${Mt(e.section.text)}`:`${e.element}${d} (not found in ${s})`}function Yt(e){let n=new Date(e),s=d=>String(d).padStart(2,"0"),l=-n.getTimezoneOffset(),i=`${l<0?"-":"+"}${s(Math.floor(Math.abs(l)/60))}:${s(Math.abs(l)%60)}`;return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}T${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}${i}`}function no(e,n,s={said:"",now:""}){return e===n?s.said===s.now?{stale:!1,why:""}:{stale:!0,packaged:!0,why:`it holds ${s.said||"no custom block"}, the workspace has ${s.now||"none of them"}`}:{stale:!0,why:e?`made from a text whose sha256 is ${e.slice(0,12)}\u2026, the file's is ${n.slice(0,12)}\u2026`:"it does not say which text it was made from: made before exports said it, or before the kit's names were doc-* (2026-10-26), whose pages gallery qa no longer reads"}}async function Kt(e,{made:n=!1}={}){let s=It(Lt(e,Rt)).html,l=At(e),[i,d]=await Promise.all([vt.readFile(s).catch(()=>null),vt.stat(l).catch(()=>null)]);if(!i)return{problem:`${e}: no document (${s})`};if(!d)return{problem:`${e}: no export (${l}): run gallery export ${e} first`,missing:!0};let w=await vt.readFile(l),f=w.toString("utf8"),x=Ve(f),u={said:Pe(f),now:_e(te(i.toString("utf8")))},{stale:A,why:j,packaged:K=!1}=no(x,ge(i),u);return A&&!n?{problem:`${e}: ${l} is not of ${s} as it is now (${j}): run gallery export ${e} first`,stale:!0,why:j,edited:!!x&&!K,packaged:K}:{file:l,sha256:ge(w),time:d.mtimeMs}}function so(e,n){let s=e.map((w,f)=>({length:1,weight:n[f],previous:-1})),l=(w,f)=>w.length>f.length||w.length===f.length&&w.weight>f.weight;e.forEach((w,f)=>{for(let x=0;x<f;x++){if(e[x]>=w)continue;let u={length:s[x].length+1,weight:s[x].weight+n[f],previous:x};l(u,s[f])&&(s[f]=u)}});let i=-1;s.forEach((w,f)=>{(i<0||l(w,s[i]))&&(i=f)});let d=[];for(let w=i;w>=0;w=s[w].previous)d.unshift(w);return d}function Be(e,n){let s=n?.places??{},l=new Set((n?.moved??[]).filter(d=>e.has(d))),i=new Map;for(let[d,{parent:w,size:f=0}]of e){let x=s[d];if(x){if(x[0]!==w){l.add(d);continue}i.has(w)||i.set(w,[]),i.get(w).push({id:d,at:x[1],size:f})}}for(let d of i.values()){let w=new Set(so(d.map(({at:f})=>f),d.map(({size:f})=>f)).map(f=>d[f].id));for(let{id:f}of d)w.has(f)||l.add(f)}return l}function ao(e,n,s,{named:l=null,verified:i=!0,failed:d=!1,seen:w=null,page:f=void 0,packages:x=void 0}={}){if(!i||d||l&&!n)return null;let u=w??new Set([...s.ids,...[...s.held?.values()??[]].flat()]),A=!n,j=A||s.pageChanged?s.cards??[]:[],K=[...n?.unseen??[],...j],m={blocks:{},places:{},moved:A?[]:[...Be(e,n)].filter($=>!u.has($)),unseen:[...new Set(K)].filter($=>e.has($)&&!u.has($))};for(let[$,{hash:Y,parent:X,at:gt}]of e){let N=A||u.has($)?Y:n.blocks[$];N!==void 0&&(m.blocks[$]=N),m.places[$]=[X,gt]}let E=!A&&(l||s.tiles)?n.page:f;typeof E=="string"&&(m.page=E);let z=!A&&(l||s.tiles)?n.packages:x&&Object.fromEntries(Object.entries(x).map(([$,Y])=>[$,(s.restyled?.get($)??[]).every(X=>u.has(X))?Y:n.packages[$]]));return z&&Object.keys(z).length&&(m.packages=z),m}function Oe(e){let n=new Map;for(let s of e){let l=new Set(s.held?.covered??[]);for(let i of s.held?.missed??[])l.has(i)||n.set(i,[...n.get(i)??[],s.label??String(s.width)])}return n}function io(e,n){let s=Oe(n);return new Set([...e.ids,...[...e.held?.values()??[]].flat().filter(l=>!s.has(l))])}function Se(e){let n=e.time?` of ${Yt(e.time)}`:"";return e.from==="export"?`the export${n} (the document before these changes)`:e.from==="preview"?`gallery open${n} (the document before these changes)`:"the last look"}var ro=3;function lo(e,n,s=null,{tiles:l=!1,page:i=void 0,packages:d=void 0}={}){let w={rest:[],unknown:[],moved:new Set,around:new Map,held:new Map,groups:[],cards:[],pageChanged:!1,changed:new Set,restyled:new Map,left:null},f=[...e.keys()],x=new Map(f.map((a,M)=>[a,M])),u=n?Be(e,n):new Set,A=a=>typeof n?.packages?.[a]=="string"&&typeof d?.[a]=="string"&&n.packages[a]!==d[a],j=n?f.filter(a=>A(e.get(a).package)&&n.blocks[a]===e.get(a).hash&&!u.has(a)):[],K=new Map;for(let a of j)K.set(e.get(a).package,[...K.get(e.get(a).package)??[],a]);let m=new Set(j),E=n?f.filter(a=>n.blocks[a]!==e.get(a).hash||u.has(a)||m.has(a)):[],z=new Set((n?.unseen??[]).filter(a=>e.has(a)&&!E.includes(a))),$=(a,M)=>{let G=null;for(let et=e.get(a).parent;et!==null&&e.has(et);et=e.get(et).parent)M.has(et)&&(G=et);return G},Y=new Set(E),X=new Set(E.filter(a=>e.get(a).card||u.has(a))),gt=a=>Y.has(a)&&!u.has(a)&&$(a,X)===null,N=new Map;for(let a of f)for(let M=e.get(a).parent;M!==null&&e.has(M);M=e.get(M).parent){let G=N.get(M)??{all:0,changed:0};G.all+=1,gt(a)&&(G.changed+=1),N.set(M,G)}let Q=f.filter(a=>!e.get(a).card&&N.has(a)&&N.get(a).changed>=ro&&N.get(a).changed*2>=N.get(a).all);if(s){let a=[...new Set(s)].filter(o=>e.has(o)),M=new Set(a),G=new Map;for(let o of f){let r=M.has(o)?null:$(o,M);r!==null&&G.set(r,[...G.get(r)??[],o])}let et="the blocks named",$t=new Set([...a,...[...G.values()].flat()]),yt=!!n&&typeof n.page=="string"&&typeof i=="string"&&n.page!==i,xt=new Set([...E.filter(o=>e.get(o).card||u.has(o)),...Q]),bt=!n||yt?f.filter(o=>e.get(o).card&&!E.includes(o)):[],Pt=new Set([...xt,...bt]),Nt=[...E,...Q.filter(o=>!Y.has(o))].sort((o,r)=>x.get(o)-x.get(r)).filter(o=>!$t.has(o)&&$(o,xt)===null),Tt=Nt.filter(o=>m.has(o)),t={changed:Nt.filter(o=>!m.has(o)),...Tt.length?{restyled:Tt,packages:[...new Set(Tt.map(o=>e.get(o).package))]}:{},cards:bt.filter(o=>!$t.has(o)&&$(o,Pt)===null).sort((o,r)=>e.get(o).rank-e.get(r).rank||x.get(o)-x.get(r)),since:n?Se(n):"",first:!n};return{...w,ids:a,why:et,groups:[{kind:"named",why:et,ids:a,rest:[]}],held:G,pageChanged:yt,changed:new Set(E),restyled:K,left:t,unknown:[...new Set(s)].filter(o=>!e.has(o))}}if(e.size===0)return{...w,ids:[],why:"the document has no block ids (never handed in): the whole page in tiles instead",tiles:!0};if(l)return{...w,ids:[],why:null,tiles:!0};let h=(...a)=>(M,G)=>a.reduce((et,$t)=>et||$t(M)-$t(G),0),B=a=>e.get(a).rank,_=a=>x.get(a),tt=n?Se(n):"",C=!!n&&typeof n.page=="string"&&typeof i=="string"&&n.page!==i,v=f.filter(a=>e.get(a).card&&!E.includes(a)),L=!n||C||E.length===0?v:v.filter(a=>z.has(a)),it=new Set([...E.filter(a=>e.get(a).card||u.has(a)),...Q]),dt=new Set([...it,...L]),Z=new Map,at=(a,M)=>a.filter(G=>{let et=$(G,M);return et!==null&&Z.set(et,[...Z.get(et)??[],G]),et===null}),V=[...at(E,it),...Q.filter(a=>!Y.has(a)&&$(a,it)===null)].sort(h(a=>+!u.has(a),B,_)),pt=V.filter(a=>m.has(a)),lt=V.filter(a=>!m.has(a)),st=at(L,dt).sort(h(a=>+!z.has(a),B,_)),ct="the cards (chart cards, code blocks, whole blocks, components, flowcharts and Sheet areas, then columns and the other figures, then tables)",y=st.some(a=>z.has(a))?", those no look has pictured yet first":"",D=typeof n?.page=="string"&&typeof i=="string",F=n?C?`${ct.replace("the cards","the cards, not changed themselves")}${y}: the document's own <script> or <style> changed since ${tt}, which may draw any of them`:E.length?"the cards no look has pictured yet (not changed themselves)":`${ct}${y}: no block changed since ${tt}${D?", nor the document's own <script> or <style>":""}`:`${ct}: no earlier look to compare with`,J=[...lt.length?[{kind:"changed",why:`the blocks changed since ${tt}${u.size?" (a moved block pictured with the edges of the blocks before and after it, the moved ones first)":""}`,all:lt}]:[],...pt.length?[{kind:"changed",why:`the instances of a custom block changed since ${tt} (${[...new Set(pt.map(a=>e.get(a).package))].join(", ")})`,all:pt}]:[],...st.length||!V.length?[{kind:"cards",why:F,all:st}]:[]],R=Ae;for(let a of J)a.ids=a.all.slice(0,R),a.rest=a.all.slice(a.ids.length),R-=a.ids.length,delete a.all;let I=J.flatMap(a=>a.ids),k=a=>{let{parent:M,at:G}=e.get(a),et=$t=>f.find(yt=>e.get(yt).parent===M&&e.get(yt).at===G+$t)??null;return[et(-1),et(1)]},H=new Map(I.filter(a=>u.has(a)).map(a=>[a,k(a)])),c=new Map(I.filter(a=>Z.has(a)).map(a=>[a,Z.get(a)]));return{...w,ids:I,why:J[0].why,groups:J,rest:J.flatMap(a=>a.rest),moved:new Set(I.filter(a=>u.has(a))),around:H,held:c,cards:L,pageChanged:C,changed:new Set(E),restyled:K}}function co(e){let n=m=>!!m.closest("[data-doc-dev]"),s=[...document.querySelectorAll("details")].filter(m=>!n(m)),l=s.filter(m=>!m.open).length;s.forEach(m=>{m.open||m.setAttribute("data-qa-closed",""),m.open=!0});let i=[...document.images].filter(m=>!n(m));i.forEach(m=>{m.loading==="lazy"&&(m.loading="eager")});let d=[...document.querySelectorAll("dialog")].filter(m=>!n(m)&&!m.open);d.forEach((m,E)=>{m.dataset.qaCard=String(E)});let w=m=>m.parentElement?.closest("dialog[data-qa-card]")??null,f=[...document.querySelectorAll("[data-doc-sheets] > .doc-sheet-tabs > [data-sheet-tab]")].filter(m=>!n(m));f.forEach((m,E)=>{m.dataset.qaTab=String(E)});let x=m=>m.parentElement.parentElement,u=m=>{let E=[];for(let z=m.closest("[data-doc-sheet]");z;z=z.parentElement.closest("[data-doc-sheet]")){let $=f.find(Y=>x(Y)===z.parentElement&&Y.getAttribute("data-sheet-tab")===z.getAttribute("data-doc-sheet"));$&&E.unshift(Number($.dataset.qaTab))}return E},A=f.map((m,E)=>{let z=[...u(x(m)),E],$=[...x(m).children].find(X=>X.getAttribute("data-doc-sheet")===m.getAttribute("data-sheet-tab"));$&&($.dataset.qaPanel=String(E));let Y=w(m);return{index:E,chain:z,card:Y?Number(Y.dataset.qaCard):null,label:(m.textContent??"").replace(/\s+/g," ").trim(),shown:z.every(X=>f[X].getAttribute("aria-selected")==="true"),panel:!!$}}),j=d.map((m,E)=>{let z=`[href="#${CSS.escape(m.id)}"]`,$=[...m.querySelectorAll("h1, h2, h3, h4")].find(X=>X.textContent.trim())??document.querySelector(z),Y=[];for(let X=w(m);X;X=w(X))Y.unshift(Number(X.dataset.qaCard));return{index:E,chain:u(m),within:Y,label:($?.textContent||m.id||"").replace(/\s+/g," ").trim()}}),K=Promise.all(i.map(m=>m.decode().catch(()=>{})));return Promise.race([K.then(()=>!0),new Promise(m=>setTimeout(()=>m(!1),e))]).then(m=>({details:s.length,closed:l,images:i.length,loaded:m,sheets:A,cards:j}))}function ke(e){let n=document.querySelector(`[data-qa-card="${e}"]`);return n?(n.open||(globalThis.DocDialogs?globalThis.DocDialogs.open(n,null):typeof n.showModal=="function"?n.showModal():n.setAttribute("open","")),document.activeElement?.blur?.(),Promise.all(n.getAnimations({subtree:!0}).map(s=>s.finished.catch(()=>{}))).then(()=>n.open&&n.getClientRects().length>0)):Promise.resolve(!1)}function Ht(e){let n=document.querySelector(`[data-qa-card="${e}"]`);n?.open&&(globalThis.DocDialogs?globalThis.DocDialogs.close(n):typeof n.close=="function"?n.close():n.removeAttribute("open"))}async function ho({selector:e,up:n=0,margin:s=0,frames:l=2}){let i=document.querySelector(e);for(let v=0;v<n&&i;v++)i=i.parentElement;if(!i||i.getClientRects().length===0)return null;let d=i.getBoundingClientRect();i.scrollIntoView({block:"nearest",inline:"nearest"});let w=i.getBoundingClientRect();if(d.top!==w.top||d.left!==w.left){let v=()=>new Promise(U=>{requestAnimationFrame(()=>U()),setTimeout(U,100)});for(let U=0;U<l;U++)await v()}let f=v=>v===document.body||v===document.documentElement,x=(v,U,L)=>{let{left:it,top:dt,right:Z,bottom:at}=v;for(let V=U;V&&!f(V);V=V.parentElement){let pt=getComputedStyle(V),lt=pt.overflowX!=="visible",st=pt.overflowY!=="visible";if(lt||st){let ct=V.getBoundingClientRect();lt&&([it,Z]=[Math.max(it,ct.left),Math.min(Z,ct.right)]),st&&([dt,at]=[Math.max(dt,ct.top),Math.min(at,ct.bottom)])}if(V===L)break}return Z>it&&at>dt?{left:it,top:dt,right:Z,bottom:at}:null},u=v=>parseFloat(v)||0,A=(v,U)=>{let L=getComputedStyle(v,U);if(["none","normal"].includes(L.content)||L.display==="none"||!["absolute","fixed"].includes(L.position))return null;let it=L.position==="fixed"?null:getComputedStyle(v).position!=="static"?v:v.offsetParent,dt=it?it.getBoundingClientRect():{left:0,top:0,right:innerWidth,bottom:innerHeight},Z=it?getComputedStyle(it):null,at={left:dt.left+u(Z?.borderLeftWidth),top:dt.top+u(Z?.borderTopWidth),right:dt.right-u(Z?.borderRightWidth),bottom:dt.bottom-u(Z?.borderBottomWidth)},V=(y,D)=>L.boxSizing==="border-box"?0:u(L[`padding${y}`])+u(L[`padding${D}`])+u(L[`border${y}Width`])+u(L[`border${D}Width`]),pt=u(L.width)+V("Left","Right"),lt=u(L.height)+V("Top","Bottom"),st=L.left!=="auto"?at.left+u(L.left)+u(L.marginLeft):L.right!=="auto"?at.right-u(L.right)-u(L.marginRight)-pt:null,ct=L.top!=="auto"?at.top+u(L.top)+u(L.marginTop):L.bottom!=="auto"?at.bottom-u(L.bottom)-u(L.marginBottom)-lt:null;return st===null||ct===null||!(pt>0)||!(lt>0)?null:x({left:st,top:ct,right:st+pt,bottom:ct+lt},v,i)},j=[i.getBoundingClientRect()],K=[i];for(let v of i.querySelectorAll("*"))v instanceof SVGElement&&v.ownerSVGElement||v.matches("script, style, template")||v.getClientRects().length===0||getComputedStyle(v).visibility!=="hidden"&&(K.push(v),j.push(x(v.getBoundingClientRect(),v.parentElement,i)));for(let v of K)j.push(A(v,"::before"),A(v,"::after"));let m=document.createRange(),E=document.createTreeWalker(i,NodeFilter.SHOW_TEXT);for(let v=E.nextNode();v;v=E.nextNode())if(!(!v.nodeValue.trim()||!v.parentElement||v.parentElement.closest("svg, script, style, template"))){m.selectNodeContents(v);for(let U of m.getClientRects())j.push(x(U,v.parentElement,i))}m.detach();let z=j.filter(Boolean),$={left:Math.min(...z.map(v=>v.left)),top:Math.min(...z.map(v=>v.top)),right:Math.max(...z.map(v=>v.right)),bottom:Math.max(...z.map(v=>v.bottom))},Y=x($,i.parentElement,null)??$,X=!1;for(let v=i;v&&!X;v=v.parentElement)X=getComputedStyle(v).position==="fixed";let gt=visualViewport.pageLeft,N=visualViewport.pageTop,[Q,h]=X?[gt+innerWidth,N+innerHeight]:[document.documentElement.scrollWidth,document.documentElement.scrollHeight],B=Math.max(X?gt:0,Y.left+gt-s),_=Math.max(X?N:0,Y.top+N-s),tt=Math.min(Q,Y.right+gt+s),C=Math.min(h,Y.bottom+N+s);return tt>B&&C>_?{clip:{x:B,y:_,width:tt-B,height:C-_},fixed:X}:null}function ve(e){for(let s of e){let l=document.querySelector(`[data-qa-tab="${s}"]`);l&&l.getAttribute("aria-selected")!=="true"&&l.click()}let n=document.querySelector(`[data-qa-panel="${e.at(-1)}"]`);return!!(n&&!n.hidden&&n.getClientRects().length>0)}function zt({scope:e,next:n,ignored:s=[],place:l,slack:i=4,whole:d=[],drawn:w=[]}){let f=e?document.querySelector(e):document.body,x=[];if(!f)return{found:x,next:n};let u=document.documentElement.clientWidth,A=Math.round,j=t=>String(t??"").replace(/\s+/g," ").trim(),K=(t,o=32)=>{let r=j(t);return`"${r.length>o?`${r.slice(0,o-1)}\u2026`:r}"`},m=t=>!!t.closest?.("[data-doc-dev]"),E=t=>{if(!t.isConnected||t.getClientRects().length===0)return!1;for(let o=t;o&&o.nodeType===1;o=o.parentElement){let r=getComputedStyle(o);if(r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0||o.matches(".katex-mathml, .sr-only, [role=tooltip], [data-doc-dev]"))return!1}return!0},z=t=>`${t.localName}${[...t.classList].filter(o=>!o.startsWith("is-")).slice(0,2).map(o=>`.${o}`).join("")}`,$=t=>(t.textContent??"").replace(/\s+/g,"").slice(0,120),Y=new Map,X=t=>{let o=$(t);if(!Y.has(t.localName)){let b=new Map;for(let O of document.getElementsByTagName(t.localName)){if(m(O))continue;let W=$(O);b.has(W)||b.set(W,[]),b.get(W).push(O)}Y.set(t.localName,b)}let r=Y.get(t.localName).get(o)?.indexOf(t)??0;return{tag:t.localName,words:o,nth:Math.max(0,r),text:j(t.textContent).slice(0,80)}},gt=t=>{let o=t.cloneNode(!0);for(let r of o.querySelectorAll(".doc-tab"))r.before(" \xB7 ");return j(o.textContent).replace(/^· /,"")},N=t=>{let o=t.matches("table")?t:t.querySelector("table"),r=t.closest(".doc-table-wrap")??t,b=r.getAttribute("data-doc-chart-source")?.trim(),W=(b?[...document.querySelectorAll("[data-doc-chart-data]")].find(S=>S.getAttribute("data-doc-chart-data").trim()===b&&!m(S)):null)?.closest("figure")?.querySelector(":scope > h2, :scope > h3, :scope > h4, :scope > figcaption"),p=r.previousElementSibling;return j(o?.caption?.textContent)||j(W?.textContent)||(p?.matches("p.doc-note")?gt(p):"")||j(o?.querySelector("th")?.textContent??o?.rows[0]?.cells[0]?.textContent)},Q=t=>{let o=t.nodeType===1?t:t.parentElement,r=[],b=[];for(let g=o;g&&g!==document.documentElement;g=g.parentElement)g.hasAttribute("data-block-id")&&r.push(g.getAttribute("data-block-id")),g.id&&!g.hasAttribute("data-qa-tab")&&!g.hasAttribute("data-qa-panel")&&b.push(g.id);let O=[];for(let g=o,T=0;g&&T<4&&!g.matches("body, main, section, [data-doc-sheet], [data-doc-sheets], .doc-columns, .doc-column");g=g.parentElement,T++){let ot=X(g);ot.words.length>=2&&O.push(ot)}let W=o.closest("figure")?.querySelector(":scope > h3, :scope > figcaption, :scope > .doc-figure-caption"),p=o.closest(".doc-table-wrap, table"),S=p?.querySelector("th"),q=o.closest("section")?.querySelector(":scope > h2, :scope > h3, :scope > h4");return{blocks:r,ids:b,texts:O,tag:o.localName,element:z(o),card:W?X(W):null,header:S?X(S):null,table:p?N(p).slice(0,80):null,section:q?X(q):null}};if(l){let t=document.querySelector(l);return{found:x,next:n,anchor:t?Q(t):null}}let h=t=>(t.dataset.qaShot||(t.dataset.qaShot=String(++n)),Number(t.dataset.qaShot)),B=(t,o,r,{picture:b=o,url:O,measured:W,scroll:p,level:S}={})=>x.push({kind:t,what:r,anchor:o?Q(o):null,shot:b?h(b):null,seen:!!(b&&E(b)),url:O,measured:W,scroll:p,...S?{level:S}:{}}),_=t=>t.closest("figure")??t.closest("[data-doc-chart]")??t,tt=t=>{let o=t.getBoundingClientRect();return o.width>0&&o.height>0},C=(t,o,{x:r=!0,y:b=!0}={})=>Math.max(r?o.left-t.left:-1/0,r?t.right-o.right:-1/0,b?o.top-t.top:-1/0,b?t.bottom-o.bottom:-1/0),v=t=>({left:Math.min(...t.map(o=>o.x)),right:Math.max(...t.map(o=>o.x)),top:Math.min(...t.map(o=>o.y)),bottom:Math.max(...t.map(o=>o.y))}),U=t=>{let o=t.getBBox(),r=t.getScreenCTM();return v([[o.x,o.y],[o.x+o.width,o.y],[o.x+o.width,o.y+o.height],[o.x,o.y+o.height]].map(([b,O])=>new DOMPoint(b,O).matrixTransform(r)))},L=t=>{let o=[];for(let r=t.parentElement;r&&r!==document.documentElement;r=r.parentElement){let b=getComputedStyle(r);r instanceof SVGSVGElement&&b.overflow!=="visible"&&o.push(["the svg's edge",r.getBoundingClientRect(),{}]);let O=/url\(\s*["']?#([^)"']+)/.exec(`${r.getAttribute?.("clip-path")??""} ${b.clipPath??""}`)?.[1],W=O?document.getElementById(O):null,p=W?.getAttribute("clipPathUnits")!=="objectBoundingBox"?W?.querySelector("rect"):null;if(p&&r.getScreenCTM){let[S,q,g,T]=["x","y","width","height"].map(ot=>p[ot].baseVal.value);o.push(["a clip-path",v([[S,q],[S+g,q+T]].map(([ot,rt])=>new DOMPoint(ot,rt).matrixTransform(r.getScreenCTM()))),{}])}if(!(r instanceof SVGElement)){let S=/hidden|clip/.test(b.overflowX),q=/hidden|clip/.test(b.overflowY);(S||q)&&o.push([z(r),r.getBoundingClientRect(),{x:S,y:q}])}}return o},it=t=>`${t.slice(0,4).join("; ")}${t.length>4?`; ${t.length-4} more`:""}`,dt=t=>!t.matches("script, [data-doc-dev]")&&(t.matches("svg, canvas")||t.querySelector("svg, canvas")||E(t)&&tt(t));for(let t of f.querySelectorAll("[data-doc-chart]"))m(t)||!E(t)||[...t.children].some(dt)||B("chart-empty",t,`the ${t.getAttribute("data-doc-chart")||"chart"} chart drew nothing`,{picture:_(t)});let Z=[...f.querySelectorAll("svg")].filter(t=>{if(t.parentElement.closest("svg")||m(t)||t.closest(".katex, .doc-icon, button")||!E(t))return!1;let o=t.getBoundingClientRect();return t.closest("[data-doc-chart], figure")||o.width>=120&&o.height>=60}),at={across:.6,down:.25},V=new Map;for(let t of Z){let o=_(t),r=o.getBoundingClientRect(),b=[],O=[],W=[...t.querySelectorAll("text")].filter(q=>!q.closest("defs, clipPath, mask, pattern, marker, symbol")&&j(q.textContent)&&E(q));for(let q of W){let g=U(q),T=L(q).map(([ot,rt,ut])=>[ot,C(g,rt,ut)]).find(([,ot])=>ot>1.5);T?b.push(`${K(q.textContent,24)} ${A(T[1])}px past ${T[0]}`):C(g,r)>1.5&&O.push(`${K(q.textContent,24)} ${A(C(g,r))}px past the card's edge`)}b.length&&B("chart-text-clipped",t,it(b),{picture:o}),O.length&&B("chart-text-outside",t,it(O),{picture:o});let p=q=>{let g=/^(-?)[$¥€£]?(\d[\d,]*(?:\.\d+)?)\s*(?:%|‰|[kKMBG]|万|亿)?$/.exec(q.replace(/[−–]/g,"-"));return g?+`${g[1]}${g[2].replace(/,/g,"")}`:NaN},S=q=>q.every(Number.isFinite)&&q[1]!==q[0]&&q.slice(2).every((g,T)=>Math.abs(g-q[T+1]-(q[1]-q[0]))<=1e-9*Math.max(1,Math.abs(g)));for(let q of t.querySelectorAll("g")){let g=[...q.children].filter(P=>P.matches("g.tick")&&E(P)),T=g.map(P=>P.querySelector("text")).filter(P=>P&&j(P.textContent)&&E(P)),ot=T.map(P=>j(P.textContent));if(ot.length<2||ot.length!==g.length||!S(ot.map(p)))continue;let rt=T.map(P=>{let kt=P.getScreenCTM(),je=(parseFloat(getComputedStyle(P).fontSize)||0)*(kt?Math.hypot(kt.c,kt.d):1);return{label:P,box:U(P),size:je,turned:!!kt&&Math.abs(kt.b)>.001*Math.abs(kt.a)}});if(rt.some(P=>P.turned||!(P.size>0)))continue;let ut=rt.map(({box:P})=>[(P.left+P.right)/2,(P.top+P.bottom)/2]),nt=Math.max(...ut.map(([P])=>P))-Math.min(...ut.map(([P])=>P))>=Math.max(...ut.map(([,P])=>P))-Math.min(...ut.map(([,P])=>P)),mt=({box:P,size:kt})=>nt?[P.left,P.right]:[(P.top+P.bottom-kt)/2,(P.top+P.bottom+kt)/2],St=[...rt].sort((P,kt)=>mt(P)[0]-mt(kt)[0]),wt=null;for(let P=1;P<St.length;P++){let kt=mt(St[P])[0]-mt(St[P-1])[1];(!wt||kt<wt.gap)&&(wt={gap:kt,pair:[St[P-1],St[P]]})}let Ct=Math.max(...rt.map(P=>P.size));if(!wt||wt.gap>=at[nt?"across":"down"]*Ct)continue;for(let{label:P}of rt)V.set(P,q);let[Ot,qt]=wt.pair.map(({label:P})=>K(P.textContent,16)),We=wt.gap<0?`${Ot} and ${qt} overlapping by ${A(-wt.gap)}px`:`${Ot} and ${qt} ${A(wt.gap)}px apart`;B("ticks",t,`${ot.length} tick labels ${nt?"across":"down"} a ${A(nt?t.getBoundingClientRect().width:t.getBoundingClientRect().height)}px chart crowd: ${We}, under ${nt?"a digit's width and a hair":"a quarter of a line"} at their ${A(Ct)}px (${ot.slice(0,6).join(", ")}${ot.length>6?", \u2026":""})`,{picture:o})}}let pt=t=>{let o=t.getBBox(),r=t instanceof SVGTextElement&&parseFloat(getComputedStyle(t).fontSize)||o.height,b=o.y+Math.max(0,(o.height-r)/2),O=b+Math.min(o.height,r),W=t.getScreenCTM();return[[o.x,b],[o.x+o.width,b],[o.x+o.width,O],[o.x,O]].map(([p,S])=>new DOMPoint(p,S).matrixTransform(W))},lt=(t,o)=>{let r=1/0;for(let b of[t,o])for(let O=0;O<b.length;O++){let W=b[O],p=b[(O+1)%b.length],S=Math.hypot(p.x-W.x,p.y-W.y);if(S===0)continue;let q={x:-(p.y-W.y)/S,y:(p.x-W.x)/S},g=ut=>ut.map(nt=>nt.x*q.x+nt.y*q.y),[T,ot]=[g(t),g(o)],rt=Math.min(Math.max(...T),Math.max(...ot))-Math.max(Math.min(...T),Math.min(...ot));if(rt<=0)return 0;r=Math.min(r,rt)}return r===1/0?0:r},st=t=>[...t.querySelectorAll("text")].filter(o=>!o.closest("defs, clipPath, mask, pattern, marker, symbol")&&j(o.textContent)&&E(o));for(let t of Z){let o=st(t).map(b=>({label:b,outline:pt(b)})),r=[];o.forEach(({label:b,outline:O},W)=>{for(let p of o.slice(W+1))V.has(b)&&V.get(b)===V.get(p.label)||lt(O,p.outline)>1.5&&r.push(`${K(b.textContent,20)} and ${K(p.label.textContent,20)} overlap`)}),r.length&&B("chart-text-overlap",t,it(r),{picture:_(t)})}let ct=11;for(let t of Z){if(!t.hasAttribute("viewBox"))continue;let o=[];for(let O of st(t)){let W=O.getScreenCTM(),p=parseFloat(getComputedStyle(O).fontSize);if(!W||!(p>0))continue;let S=p*Math.hypot(W.c,W.d);S<ct-.05&&o.push(`${K(O.textContent,24)} at ${S.toFixed(1)}px (font-size ${+p.toFixed(2)})`)}if(!o.length)continue;let r=t.viewBox.baseVal,b=`${o.length} text${o.length>1?"s":""}`;B("svg-text-small",t,`${b} of a drawing scaled by its viewBox (${+r.width.toFixed(2)}\xD7${+r.height.toFixed(2)} drawn ${A(t.getBoundingClientRect().width)}px wide) render below ${ct}px: ${it(o)}`,{picture:_(t)})}let y=new Set;for(let t of f.querySelectorAll(".doc-table-wrap")){if(m(t)||!E(t))continue;y.add(t);let o=t.querySelector("table");if(!o)continue;let r=Math.max(t.clientWidth,o.offsetWidth),b=Math.max(t.clientHeight,o.offsetHeight),O=r>t.clientWidth+i,W=b>t.clientHeight+i,p=N(t);(O||W)&&B("table-scrolls",t,[O&&`${r}px wide in a ${t.clientWidth}px frame`,W&&`${b}px tall in a ${t.clientHeight}px frame`].filter(Boolean).join(", "),{scroll:{sideways:O,down:W,name:p}});let S=globalThis.__qaTableHides(t,o);S.said&&B("table-columns",t,`${S.said}: the table is ${r}px wide in a ${t.clientWidth}px frame`),S.shown<S.rows&&!t.style.getPropertyValue("--doc-table-height")&&B("table-rows",t,`the frame shows ${S.shown} of ${S.rows} rows: a reader scrolls inside it for the other ${S.rows-S.shown}; style="--doc-table-height: none" on its div.doc-table-wrap shows every row (or split the table where its content divides)`)}let D=t=>!!t.closest("details[data-qa-closed]"),F="in a disclosure closed in the file: a reader who opens it scrolls";for(let t of f.querySelectorAll(".doc-code, .doc-diff")){if(m(t)||!E(t))continue;let o=t.querySelector(":scope > pre, :scope > .doc-diff-body");if(o&&E(o)){let b=D(t);if(o.scrollHeight>o.clientHeight+i){let O=[t,o].map(q=>q.style.getPropertyValue("--doc-code-height").trim()).find(Boolean),W=o.getBoundingClientRect().top+o.clientTop+o.clientHeight,p=[...o.querySelectorAll(".doc-code-line")].filter(q=>q.getClientRects().length>0&&q.getBoundingClientRect().top>=W-1).length,S=b?`, ${F} inside it for the rest`:O?`, the block's own height (--doc-code-height: ${O}, the author's or the reader's): a reader scrolls inside it for the rest`:": a reader scrolls inside it for the rest";B("code-scrolls",t,`the code is ${o.scrollHeight}px tall, its frame ${o.clientHeight}px${p?` (its last ${p} line${p===1?"":"s"} below it)`:""}${S}`,{level:b||O?"info":void 0})}if(o.scrollWidth>o.clientWidth+i){let O=t.classList.contains("doc-code--nowrap"),W=b?`, ${F} sideways for the rest`:O?", its lines left unwrapped (doc-code--nowrap, the author's or the reader's choice): a reader scrolls sideways for the rest of its long lines":": a reader scrolls sideways for the rest";B("code-scrolls",t,`the code is ${o.scrollWidth}px wide, its frame ${o.clientWidth}px${W}`,{level:b||O?"info":void 0})}}let r=t.querySelector(":scope > .doc-code-title");r&&E(r)&&r.scrollWidth>r.clientWidth+1&&B("code-title-cut",t,`its title ${K(r.textContent,48)} is cut to fit its header (${r.scrollWidth}px of words in ${r.clientWidth}px)`)}for(let t of f.querySelectorAll(".doc-math-block")){if(m(t)||!E(t)||t.scrollWidth<=t.clientWidth+i)continue;let o=D(t);B("formula-scrolls",t,`the formula is ${t.scrollWidth}px wide, its frame ${t.clientWidth}px${o?`, ${F} it sideways for the rest`:": a reader scrolls it sideways for the rest"}`,{level:o?"info":void 0})}for(let t of f.querySelectorAll("[data-doc-layout]"))m(t)||!E(t)||B("layout",t,t.getAttribute("data-doc-layout"),{picture:t.closest("figure, .doc-table-wrap")??t,measured:y.has(t)});let J=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),R=new Map;for(let t=J.nextNode();t;t=J.nextNode()){if(!/\\\(|\\\[|\$\$/.test(t.nodeValue))continue;let o=t.parentElement;if(!o||o.closest([...s,".katex","[data-doc-dev]"].join(", "))||!E(o))continue;let r=o.closest("p, li, h1, h2, h3, h4, td, th, figcaption, summary, blockquote, dd, dt")??o;R.has(r)||R.set(r,t.nodeValue)}for(let[t,o]of R){let r=o.search(/\\\(|\\\[|\$\$/);B("raw-formula",t,`${K(o.slice(r,r+40),40)} is shown as written: the kit's math did not render it`)}for(let t of f.querySelectorAll(".katex-error"))m(t)||!E(t)||B("formula-error",t,`${K(t.textContent,32)}: ${j(t.getAttribute("title"))||"KaTeX could not read it"}`);let I=t=>`"${globalThis.__qaUrlName?.(t,document.baseURI)??t}"`,k=t=>{try{return new URL(t,document.baseURI).href}catch{return t}},H=t=>[...["src","href","poster","data"].filter(o=>t.hasAttribute(o)&&!(o==="href"&&t.matches("a, area"))).map(o=>t.getAttribute(o)),...(t.getAttribute("srcset")??"").split(",").map(o=>o.trim().split(/\s+/)[0]),...[t.getAttribute("style"),t.localName==="style"?t.textContent:""].flatMap(o=>[...String(o??"").matchAll(/url\(\s*["']?([^"')]+)/g)].map(r=>r[1]))].filter(o=>o&&!o.trim().startsWith("#")).map(k),c=[...document.querySelectorAll("*")].filter(t=>!m(t)).flatMap(t=>H(t).map(o=>({node:t,address:o}))),a=new Set;for(let{url:t,directive:o}of globalThis.__qaViolations??[]){let r=/^[a-z][a-z\d+.-]*$/i.test(t)?`${t.toLowerCase()}:`:null,b=c.find(W=>r?!a.has(W)&&W.address.startsWith(r):W.address===t);b&&r&&a.add(b);let O=b?.node??null;e&&!(O&&f.contains(O))||B("blocked",O,`${o} blocked ${I(b?.address??t)}${O?` (${z(O)})`:""}: the export holds every file it shows`,{url:b?.address??t})}for(let t of f.querySelectorAll("img")){if(m(t)||t.complete&&t.naturalWidth>0)continue;let o=t.currentSrc||t.src?k(t.currentSrc||t.src):"";B("image",t,`${o?I(o):"a picture with no src"} did not load`,{picture:t.closest("figure")??t,url:o})}let M=new Set(d),G=new Set(w),et=document.createRange(),$t="button, select, input, textarea, [data-doc-dev]",yt=(t,o)=>t!==o&&(t.matches($t)||[...t.classList].some(r=>r.startsWith("doc-"))),xt=(t,o,r)=>{let b=[],O=!1;for(let W=t,p=!0;W&&W!==document.body&&W!==document.documentElement;W=W.parentElement,p=!1){let S=getComputedStyle(W);if((!p||r)&&(O&&(S.position!=="static"||S.transform!=="none")&&(O=!1),!O)){if(/auto|scroll/.test(S.overflowY))break;/hidden|clip/.test(S.overflowY)&&!yt(W,o)&&b.push(W)}if(S.position==="fixed")break;S.position==="absolute"&&(O=!0)}return b},bt=t=>t.getBoundingClientRect().bottom-(parseFloat(getComputedStyle(t).borderBottomWidth)||0),Pt=t=>{let o=getComputedStyle(t),r=b=>!/^(transparent|rgba\(.*,\s*0\))$/.test(b);return r(o.backgroundColor)||o.backgroundImage!=="none"||["Top","Right","Bottom","Left"].some(b=>parseFloat(o[`border${b}Width`])>0&&o[`border${b}Style`]!=="none"&&r(o[`border${b}Color`]))},Nt="rect, circle, ellipse, line, polyline, polygon, path, use",Tt=(t,o)=>{let r=new Map,b=(p,S,q,g)=>{if(!r.has(p)&&r.size>=3)return;let T=r.get(p)??{words:[],marks:[],depth:0,height:p.getBoundingClientRect().height};q&&T.words.push(q),g&&T.marks.push(g),T.depth=Math.max(T.depth,S),r.set(p,T)},O=p=>p.getBoundingClientRect().height>1.5,W=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let p=W.nextNode();p;p=W.nextNode()){let S=p.parentElement;if(!p.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!E(S)||o(S))continue;let q=xt(S,t,!0).filter(O);if(q.length===0)continue;let g=getComputedStyle(S),T=parseFloat(g.lineHeight);for(let ot of p.nodeValue.matchAll(/\S+/g)){let rt=ot.index+ot[0].length;et.setStart(p,ot.index),et.setEnd(p,rt);let ut=[...et.getClientRects()];for(let nt of ut){let mt=Number.isFinite(T)?Math.max(0,(nt.height-T)/2):0,St=q.find(Ct=>nt.bottom-bt(Ct)>1.5+mt);if(!St)continue;let wt=ot.index;if(ut.length>1){let Ct=bt(St)+1.5+mt;for(let Ot=rt-1;wt<Ot;){let qt=wt+Ot>>1;et.setStart(p,qt),et.setEnd(p,qt+1),(et.getClientRects()[0]?.bottom??0)>Ct?Ot=qt:wt=qt+1}}b(St,Math.max(...ut.map(Ct=>Ct.bottom))-bt(St),p.nodeValue.slice(wt,rt),null);break}}}for(let p of t.querySelectorAll("*")){let S=p instanceof SVGElement&&p.matches(Nt)&&!p.closest("defs, clipPath, mask, pattern, marker, symbol"),q=!S&&!(p instanceof SVGElement)&&!p.matches("img, picture, video, canvas, iframe, object, embed, script, style, template")&&p.children.length===0&&!p.textContent.trim()&&Pt(p);if(!S&&!q||!E(p))continue;let g=p.getBoundingClientRect();if(g.width<=0&&g.height<=0)continue;let T=S?p.ownerSVGElement:null,ot=[...T&&getComputedStyle(T).overflowY!=="visible"?[T]:[],...xt(T??p,t,!!T)].filter(O),rt=nt=>{let mt=nt.getBoundingClientRect();return g.left>=mt.left-1.5&&g.right<=mt.right+1.5&&g.top>=mt.top-1.5},ut=ot.find(nt=>g.bottom-bt(nt)>1.5&&rt(nt));ut&&b(ut,g.bottom-bt(ut),null,S?p.localName:z(p))}return r};for(let t of f.querySelectorAll("[data-block-id]")){let o=t.getAttribute("data-block-id"),r=G.has(o);if(!r&&!M.has(o)||m(t)||!E(t))continue;let b=p=>p.closest(".doc-chart-message")||p.closest("h2, h3, h4, p, figcaption")?.parentElement===t,O=new Map,W=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let p=W.nextNode();p&&O.size<3;p=W.nextNode()){let S=p.parentElement;if(!p.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!E(S)||r&&b(S))continue;let q=S;for(;q!==t&&["inline","contents"].includes(getComputedStyle(q).display);)q=q.parentElement;let g=!1;for(let nt=S;nt&&!g;nt=nt===t?null:nt.parentElement){let mt=getComputedStyle(nt);g=mt.overflowX!=="visible"||mt.overflowY!=="visible"}if(g)continue;let T=getComputedStyle(q),ot=q.getBoundingClientRect(),rt=ot.left+parseFloat(T.borderLeftWidth)+parseFloat(T.paddingLeft),ut=ot.right-parseFloat(T.borderRightWidth)-parseFloat(T.paddingRight);for(let nt of p.nodeValue.matchAll(/\S+/g)){et.setStart(p,nt.index),et.setEnd(p,nt.index+nt[0].length);let mt=[...et.getClientRects()],St=Math.max(0,...mt.flatMap(Ct=>[Ct.right-ut,rt-Ct.left]));if(St<=1.5||mt.some(Ct=>Ct.right>u+1))continue;let wt=O.get(q)??{words:[],reach:0,width:ut-rt};wt.words.push(nt[0]),wt.reach=Math.max(wt.reach,St),O.set(q,wt)}}for(let[p,{words:S,reach:q,width:g}]of O)B("overflow-in-block",p,`the words ${K(S.join(" "),40)} run ${A(q)}px past the side of ${z(p)} (${A(g)}px wide for its words), over what is beside it`,{picture:t});for(let[p,{words:S,marks:q,depth:g,height:T}]of Tt(t,r?b:()=>!1)){let ot=[S.length&&`the words ${K(S.join(" "),40)}`,q.length&&`${q.length===1?"a mark":`${q.length} marks`} (${[...new Set(q)].slice(0,3).join(", ")})`].filter(Boolean).join(" and "),rt=S.length===0&&q.length===1;B("cut-in-block",p,`${ot} ${rt?"reaches":"reach"} ${A(g)}px past the bottom of ${z(p)} (${A(T)}px tall, its overflow ${getComputedStyle(p).overflowY}), cut off there`,{picture:t})}}if(et.detach(),document.documentElement.scrollWidth>u+1){let t=g=>{for(let T=g.parentElement;T&&T!==document.body;T=T.parentElement)if(getComputedStyle(T).overflowX!=="visible")return!1;return g.nodeType!==1||getComputedStyle(g).position!=="fixed"},o=[...f.querySelectorAll("*")].filter(g=>!(g instanceof SVGElement&&g.ownerSVGElement)&&!m(g)&&g.getBoundingClientRect().right>u+1&&E(g)&&t(g)),r=o.filter(g=>!o.includes(g.parentElement)).slice(0,3),b=`the page is ${document.documentElement.scrollWidth}px wide in a ${u}px window`,O=new Set(o),W=g=>{for(let T=g.parentElement;T;T=T.parentElement)if(O.has(T))return!0;return!1},p=new Map,S=document.createRange(),q=document.createTreeWalker(f,NodeFilter.SHOW_TEXT);for(let g=q.nextNode();g&&p.size<3;g=q.nextNode()){let T=g.parentElement;if(!T||!g.nodeValue.trim()||T.closest("svg, script, style, template")||m(T)||W(g)||!E(T)||!t(g)||(S.selectNodeContents(g),![...S.getClientRects()].some(nt=>nt.right>u+1)))continue;let ot=T.closest("[data-block-id]")??T;if(p.has(ot))continue;let rt=[],ut=0;for(let nt of g.nodeValue.matchAll(/\S+/g)){S.setStart(g,nt.index),S.setEnd(g,nt.index+nt[0].length);let mt=Math.max(...[...S.getClientRects()].map(St=>St.right),0);mt<=u+1||(rt.push(nt[0]),ut=Math.max(ut,mt))}rt.length&&p.set(ot,{node:T,words:rt.join(" "),right:ut})}S.detach(),r.length===0&&p.size===0&&!e&&B("overflow",null,b);for(let g of r)B("overflow",g,`${b}: ${z(g)} ${K(g.textContent,24)} reaches ${A(g.getBoundingClientRect().right)}px`);for(let[g,{node:T,words:ot,right:rt}]of p)B("overflow",T,`${b}: the words ${K(ot,60)} in ${z(g)} run past its edge to ${A(rt)}px (a text that cannot break)`,{picture:g})}return{found:x,next:n}}function fo(){let e=s=>!!s.closest("[data-doc-dev]"),n=s=>[...document.querySelectorAll(s)].filter(l=>!e(l)).length;return{charts:n("[data-doc-chart], [data-doc-component='gallery/chart-view']"),tables:n(".doc-table-wrap"),height:document.documentElement.scrollHeight}}var Et=2e4,Me=1800;function jt(e,n,s){let l=0,i=new Promise((d,w)=>{l=setTimeout(()=>w(new Error(`${s}: no answer in ${n/1e3}s`)),n)});return Promise.race([e,i]).finally(()=>clearTimeout(l))}var Xt=e=>`${e.kind}|${JSON.stringify(e.anchor)}|${e.what}`;async function uo(e,n,s,{out:l,tiles:i=!1,blocks:d=[],around:w=new Map,held:f=new Map,whole:x=[],drawn:u=[],known:A=null}){let{width:j,height:K=900,label:m=String(j)}=typeof s=="number"?{width:s}:s,E=m.replace("\xD7","x"),z,$;try{z=await jt(e.createBrowserContext(),Et,"a browser context opened"),$=await jt(z.newPage(),Et,"a tab opened")}catch(y){return await Dt(z?.close()),{findings:[{kind:"unverified",what:`the browser did not open a page: ${y.message}`,anchor:null,shot:null,seen:!1,state:""}],counts:null,pictures:[],held:{covered:[],missed:[]}}}$.setDefaultTimeout(Et);let Y=[],X=[],gt=new Set,N=new Map,Q=new Set,h=new Set,B=new Set,_="",tt=0,C=(y,D,F={})=>Y.push({kind:y,what:D,anchor:null,shot:null,seen:!1,state:_,...F}),v=Ie(n).href,U=y=>`"${be(y,v)}"`,L=y=>l.folders?.get(y)??l.blocks,it=y=>y.replace(/[^\w-]/g,"_");$.on("pageerror",y=>C("error",`uncaught ${Ft(y.message).slice(0,200)}`)),$.on("console",y=>{y.type()==="error"&&le(y,v)&&C("error",`console: ${Ft(y.text()).slice(0,200)}`)}),$.on("requestfailed",y=>{y.frame()===$.mainFrame()&&C("request",`${U(y.url())}: ${y.failure()?.errorText??"failed"}`,{url:y.url()})}),$.on("response",y=>{y.status()>=400&&y.request().frame()===$.mainFrame()&&C("request",`${U(y.url())}: HTTP ${y.status()}`,{url:y.url()})}),await ce($),await $.evaluateOnNewDocument(`globalThis.__qaUrlName = ${be}; globalThis.__qaTableHides = ${Ue()};`),await $.setViewport({width:j,height:K}),await $.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);let dt=async y=>{for(let D of await he($,{timeout:Et}))C("unverified",`${y}: waited for ${D}`)},Z=async(y,D,F,J)=>jt($.screenshot({path:F,clip:y,captureBeyondViewport:!D}),Et,"the picture").then(()=>!0,R=>(C("unverified",`no picture of ${J} (${R.message})`),!1)),at=async(y,D,F,J=0)=>{let R=await $.evaluate(ho,{selector:y,up:J,margin:Xe,frames:Je}).catch(I=>({error:I}));return R?.clip?await Z(R.clip,R.fixed,D,F)?R.clip:null:(C("unverified",`no picture of ${F} (${R?.error?.message??"the element is gone or shows nothing"})`),null)},V=(y,D)=>y.left<D.x+D.width&&y.right>D.x&&y.top<D.y+D.height&&y.bottom>D.y,pt=async()=>{let y=d.filter(F=>!Q.has(F)),D=await $.evaluate((F,J,R)=>{let I=new Map(F.map((M,G)=>[M,G])),k=M=>!!M&&!M.closest("[data-doc-dev], dialog:not([open])")&&M.getClientRects().length>0,H=M=>M===null?null:[...document.querySelectorAll("[data-block-id]")].find(G=>G.getAttribute("data-block-id")===M&&k(G))??null,c=M=>{if(!M)return null;let G=M.getBoundingClientRect();return{left:G.left+scrollX,right:G.right+scrollX,top:G.top+scrollY,bottom:G.bottom+scrollY}},a=[];for(let M of document.querySelectorAll("[data-block-id]")){let G=I.get(M.getAttribute("data-block-id"));if(G===void 0||!k(M))continue;I.delete(M.getAttribute("data-block-id")),M.setAttribute("data-qa-block",String(G));let[et,$t]=J[G]??[],yt=(R[G]??[]).map(xt=>[xt,[...M.querySelectorAll("[data-block-id]")].find(bt=>bt.getAttribute("data-block-id")===xt&&k(bt))]).filter(([,xt])=>xt);a.push({index:G,boxes:J[G]?{block:c(M),above:c(H(et)),below:c(H($t))}:null,held:yt.map(([xt,bt])=>({id:xt,box:c(bt)}))})}return a},y,y.map(F=>w.get(F)??null),y.map(F=>f.get(F)??[]));for(let{index:F,boxes:J,held:R}of D){let I=y[F];Q.add(I);let k=`${E}-${it(I)}`,H=[];if(!J){let c=ht.join(L(I),`${k}.png`),a=await at(`[data-qa-block="${F}"]`,c,`the block ${I}`);a&&(X.push({block:I,file:c}),H.push(a))}for(let{part:c,clip:a}of J?Ze(J):[]){let M=ht.join(L(I),`${k}${c?`-${c}`:""}.png`);await Z(a,!1,M,`the block ${I}${c?` (its ${c})`:""}`)&&(X.push({block:I,file:M}),H.push(a))}for(let{id:c,box:a}of R)H.some(M=>V(a,M))?h.add(c):h.has(c)||B.add(c);await $.evaluate(c=>document.querySelector(`[data-qa-block="${c}"]`)?.removeAttribute("data-qa-block"),F)}},lt=async(y,D,F)=>{let J=[...f].filter(([I])=>Q.has(I)).map(([I,k])=>[I,k.filter(H=>!h.has(H))]).filter(([,I])=>I.length);if(!J.length)return;let R=await $.evaluate((I,k)=>{let H=document.querySelector(I);if(!H)return[];let c=a=>[...H.querySelectorAll("[data-block-id]")].some(M=>M.getAttribute("data-block-id")===a&&M.getClientRects().length>0);return k.map(([a,M])=>[a,M.filter(c)]).filter(([,a])=>a.length)},y,J);for(let[I,k]of R){let H=ht.join(L(I),`${E}-${it(I)}-${D}.png`);if(await at(y,H,`the block ${I} (${D})`,F)){X.push({block:I,part:D,file:H});for(let c of k)h.add(c),B.delete(c)}}},st=async y=>{let D=await $.evaluate(zt,{scope:y,next:tt,ignored:Fe,slack:Ke,whole:x,drawn:u});tt=D.next;let F=D.found.flatMap(R=>R.kind!=="layout"?[R]:ze(R.what,j).filter(({kind:I})=>!(R.measured&&["table-columns","table-rows"].includes(I))).map(({kind:I,note:k})=>({...R,kind:I,what:`the kit notes ${k}`})));for(let R of F){let I=R.shot===null?null:`${R.kind}|${R.shot}|${R.what}`,k=I&&N.get(I);if(k)!k.seen&&R.seen&&Object.assign(k,R,{state:_});else{let H={...R,state:_};Y.push(H),I&&N.set(I,H)}}let J=new Set(Y.filter(R=>R.kind==="blocked").map(R=>R.url));for(let R of Y){if(R.shot===null||!R.seen||gt.has(R.shot)||!Ye(R,j)||A?.has(Xt(R))||["request","image"].includes(R.kind)&&J.has(R.url))continue;gt.add(R.shot);let I=ht.join(l.flagged,`${E}-${String(R.shot).padStart(2,"0")}-${R.kind}.png`);await at(`[data-qa-shot="${R.shot}"]`,I,R.kind)&&X.push({shot:R.shot,file:I})}d.length&&await pt()},ct=y=>{let D=new Set(Y.filter(J=>J.kind==="blocked").map(J=>J.url));return{findings:Y.filter(J=>!(["request","image"].includes(J.kind)&&D.has(J.url))&&!A?.has(Xt(J))),counts:y,pictures:X,held:{covered:[...h],missed:[...B]}}};try{try{let k=new Promise(c=>$.once("domcontentloaded",c)),H=$.goto(v,{waitUntil:"load",timeout:6e4});if(H.catch(()=>{}),await Promise.race([k,H]),$.url()!==v)throw new Error(`the browser shows ${$.url()}`)}catch(k){return C("unverified",`the page did not load: ${k.message}`),ct(null)}await dt("the page as it opens");let y=await $.evaluate(co,Et);y.loaded||C("unverified",`the pictures (${y.images}) not all loaded in ${Et/1e3}s`),y.closed&&await dt(`the page with its ${y.closed} closed disclosure${y.closed===1?"":"s"} opened`),await st(null);let D=async(k,H,c,a=null)=>{for(let M=k,G=1;M<H;M+=Me,G++){let et=ht.join(l.tiles,`${E}-${c}${String(G).padStart(2,"0")}.png`);await jt($.screenshot({path:et,clip:{x:0,y:M,width:j,height:Math.min(Me,H-M)},captureBeyondViewport:!0}),Et,"a tile").then(()=>X.push({tile:!0,sheet:a,file:et}),$t=>C("unverified",`no tile ${c}${G} (${$t.message})`))}};i&&await D(0,await $.evaluate(()=>document.documentElement.scrollHeight),"");let F=async(k,H=null)=>{if(!await $.evaluate(ve,k.chain)){let{anchor:c}=await $.evaluate(zt,{next:tt,place:`[data-qa-tab="${k.index}"]`});return C("unverified","this Sheet could not be shown: its tab was clicked and its panel stayed hidden",{anchor:c}),!1}if(await dt("the Sheet shown"),await st(`[data-qa-panel="${k.index}"]`),await lt(`[data-qa-panel="${k.index}"]`,`sheet${k.index+1}`,1),i&&H)await J(H,`sheet${k.index+1}-`);else if(i){let c=await $.evaluate(a=>{let M=document.querySelector(`[data-qa-panel="${a}"]`)?.getBoundingClientRect();return M&&M.height>0?{top:Math.max(0,M.top+scrollY),bottom:M.bottom+scrollY}:null},k.index);c&&await D(c.top,c.bottom,`sheet${k.index+1}-`,{number:k.index+1,label:k.label})}return!0},J=async(k,H="")=>{for(let c=1;c<=20;c++){let a=await $.evaluate((G,et)=>{let $t=document.querySelector(`[data-qa-card="${G}"]`),yt=$t?.querySelector(".doc-dialog-content")??$t;if(!yt)return null;if(et)yt.scrollTop=0;else{let bt=yt.scrollTop;if(yt.scrollTop+=Math.max(40,yt.clientHeight-24),yt.scrollTop===bt)return null}let xt=$t.getBoundingClientRect();return{x:xt.left+visualViewport.pageLeft,y:xt.top+visualViewport.pageTop,width:xt.width,height:xt.height}},k.index,c===1);if(!a)break;let M=ht.join(l.tiles,`${E}-card${k.index+1}-${H}${String(c).padStart(2,"0")}.png`);await Z(a,!0,M,`the detail card ${Mt(k.label,24)}, tile ${H}${c}`)&&X.push({tile:!0,card:{number:k.index+1,label:k.label,part:H},file:M})}},R=0;for(let k of y.sheets)k.shown||!k.panel||k.card!==null||(_=`Sheet ${Mt(k.label,24)}`,await F(k)&&(R+=1));let I=0;for(let k of y.cards){_=`detail card ${Mt(k.label,24)}`;let H=`[data-qa-card="${k.index}"]`;k.chain.length&&await $.evaluate(ve,k.chain);for(let c of k.within)await $.evaluate(ke,c);if(!await $.evaluate(ke,k.index)){let{anchor:c}=await $.evaluate(zt,{next:tt,place:H});C("unverified","this detail card could not be opened",{anchor:c});for(let a of k.within.toReversed())await $.evaluate(Ht,a);continue}I+=1,await dt("the detail card opened"),await st(H),await lt(H,`card${k.index+1}`,0),i&&await J(k);for(let c of y.sheets)c.card!==k.index||c.shown||!c.panel||(_=`detail card ${Mt(k.label,24)}, Sheet ${Mt(c.label,24)}`,await F(c,k)&&(R+=1));await $.evaluate(Ht,k.index);for(let c of k.within.toReversed())await $.evaluate(Ht,c)}return _="",ct({...await $.evaluate(fo),details:y.details,closed:y.closed,sheets:R,cards:y.cards.length,cardsOpened:I})}catch(y){return C("unverified",`the look ended early: ${y.message}`),ct(null)}finally{await Dt(z.close())}}var Jt=e=>e.split(ht.sep).join("/"),ft=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`,Ut=e=>`${e.join(", ")}px`,po=e=>e.includes("\xD7")?e:`${e}px`;function go({details:e,closed:n}){if(e===0)return"0 disclosures";let s=n===0?"open in the file":`${n===e?"":`${n} `}closed in the file, opened for the pictures`;return`${ft(e,"disclosure")} (${s})`}function Re(e,n=null){let s=new Map;for(let l of e){let i=n?ht.relative(n,l):"",d=Jt(n&&i&&!i.startsWith("..")&&!ht.isAbsolute(i)?i:l),w=/^(.*\/)?(\d+(?:x\d+)?)-([^/]+)$/.exec(d),f=w?`${w[1]??""}\0${w[3]}`:d;s.has(f)||s.set(f,w?{head:w[1]??"",tail:w[3],looks:[]}:{whole:d});let x=s.get(f);w&&!x.looks.includes(w[2])&&x.looks.push(w[2])}return[...s.values()].map(l=>l.whole??`${l.head}${l.looks.length>1?`{${l.looks.join(",")}}`:l.looks[0]}-${l.tail}`)}function mo(e){let n=e.map(({folder:l,files:i})=>({folder:l,files:[...new Set(i)]})).filter(({files:l})=>l.length);if(!n.length)return null;let s=n.reduce((l,{files:i})=>l+i.length,0);return`Not opened yet: ${ft(s,"picture")} of this run, none looked at for you; open each, and in the handoff name those you opened: ${n.flatMap(({folder:l,files:i})=>Re(i,l).map(d=>ht.isAbsolute(d)?d:`${Jt(l)}/${d}`)).join(", ")}`}var Te=(e="<slug>")=>`more pictures: gallery qa ${e} --tiles (the page, each Sheet panel and each detail card in tiles), gallery qa ${e} --blocks <id,\u2026> (the blocks you name)`,nn=Te(),Ne=fe,Ce='look at the export yourself at 1024, 736 and 360px, its disclosures and detail cards opened (SKILL.md, "Export, check and look"), and say so when you hand the document over.',wo=e=>Ft(e?.message).replace(/\s*Use a different `?userDataDir`? or stop the running browser first\.?/gi,"").slice(0,300),Gt={overflow:"a reader scrolls the whole page sideways. Words that cannot break where they stand (a long path, URL or name): wrap each in <code>, which breaks where it must and keeps it whole for the reader to copy; an element wider than the window (a picture, a drawing, a width of your own): let it fit (max-width: 100%) or put it in a frame that scrolls; never cut or rewrite a path to silence this","table-columns":"not a failure. If the reader must see the column on a desktop, write its long values compactly (a cell of numbers stays on one line, so its longest value sets the column's width: a range as a\u2013b, fewer digits), move a unit out of its header into the line above the table, shorten the header, or split the table; never delete a column to silence this","chart-text-overlap":"not a failure. If the reader must read both, shorten the labels (a unit belongs in the axis's title), move one (above its row, or a leader line) or give the drawing more room at this width; never delete a label or a category to silence this","code-scrolls":'not a failure. A reader scrolls inside the frame (40 lines) for the rest; if every line must show at once, write style="--doc-code-height: none" on its <pre>; never delete code to silence this',"formula-scrolls":"not a failure. A reader scrolls the formula sideways for the rest; if it must show whole at this width, break it into lines (\\begin{aligned} \u2026 \\end{aligned}) or into two formulas; never cut a term to silence this","overflow-in-block":"not a failure. If the words run over others in the picture, give their box room at this width (a wider column in an @media rule of your <style>, or a smaller font there), or let them break (a dash or a space where a line may end); never cut the words to silence this","cut-in-block":"not a failure. If the reader must see what is cut, let the box grow with what it holds (min-height instead of height or max-height, or none), give it room at this width in an @media rule of your <style>, or let it scroll (overflow: auto); never delete the words to silence this",ticks:"not a failure. If the numbers crowd in the picture, give that axis fewer ticks at this width with axis.tickValues([...]), at most four on a phone (the domain's ends and middle; ticks(n) is only a hint to d3 and can still draw five or more), or shorter numbers (the unit in the axis's title: 2k, 1.5\u4E07); never take the axis out to silence this","svg-text-small":"not a failure. The viewBox scales the drawing's text with it: give the text a larger font-size in the viewBox's units (a viewBox 800 wide drawn 340px wide scales by 0.43, so 26 units read as 11px), or lay the drawing out for narrow widths (a viewBox of its own under an @media rule, a chart of your own drawn from its width, or HTML that wraps); never drop the labels to silence this"},$o='not a failure. A reader scrolls sideways for the rest of its long lines; if the reader must see them whole at this width, let them wrap (take data-wrap="false" off its <pre>) or break them where the code allows; a tree or a log whose lines must stay whole may scroll; never cut a line to silence this';function xo(e){if(e.kind!=="code-scrolls")return Gt[e.kind]?[Gt[e.kind]]:[];let n=[...e.said.keys()],s=n.some(l=>/ wide, its frame /.test(l));return[...!s||n.some(l=>/ tall, its frame /.test(l))?[Gt["code-scrolls"]]:[],...s?[$o]:[]]}var yo="none is a failure: each says what to do if it matters to the reader (never delete a column or a label to silence one)",bo="a reader scrolls it: not a problem";function So(e,n,s=null,{folder:l=null,slug:i="<slug>"}={}){let d=[],w=Object.fromEntries(Bt.map(h=>[h,0])),f=new Map,x=new Set,u=new Map,A=[],j=h=>Re(h,l),K=h=>h.label??String(h.width),m=new Map(e.flatMap(h=>h.pictures.filter(B=>B.shot!==void 0).map(B=>[`${K(h)}|${B.shot}`,B.file])));for(let h of e){let{width:B,findings:_,counts:tt}=h,C=K(h),v=new Set,U=Object.fromEntries(Bt.map(V=>[V,0])),L={right:0,down:0,all:0};for(let V of _){let pt=`${V.kind}|${V.shot??""}|${V.what}`;if(v.has(pt))continue;v.add(pt);let lt=qe(V,B);U[lt]+=1;let st=oo(V.anchor,n);if(V.kind==="table-scrolls"){let{sideways:R=!1,down:I=!1,name:k=""}=V.scroll??{};Object.assign(L,{all:L.all+1,right:L.right+Number(R),down:L.down+Number(I)});let H=`${st}|${k}`;u.has(H)||u.set(H,{place:st,name:k,right:[],down:[]}),R&&!u.get(H).right.includes(C)&&u.get(H).right.push(C),I&&!u.get(H).down.includes(C)&&u.get(H).down.push(C)}if(lt==="info"&&x.add(`${V.kind}|${st}`),lt==="info"&&["table-scrolls","table-columns","table-rows"].includes(V.kind))continue;let ct=`${Bt.indexOf(lt)}|${V.kind}|${st}`;f.has(ct)||(f.set(ct,{level:lt,kind:V.kind,place:st,said:new Map}),lt!=="info"&&(w[lt]+=1));let y=f.get(ct).said,D=`${V.state?`[${V.state}] `:""}${V.what}`;y.has(D)||y.set(D,{labels:[],pictures:[]});let F=y.get(D);F.labels.includes(C)||F.labels.push(C);let J=m.get(`${C}|${V.shot}`);J&&!F.pictures.includes(J)&&F.pictures.push(J)}let it=[L.right&&`\u2192 ${L.right}`,L.down&&`\u2193 ${L.down}`].filter(Boolean).join(", "),dt=`${ft(L.all,"table scrolls","tables scroll")}${it?` (${it})`:""}`,Z=tt?.cards?`, ${ft(tt.cards,"detail card")} (${tt.cardsOpened===tt.cards?"closed in the file, opened in turn":`${tt.cardsOpened??0} of them opened`})`:"",at=h.laptop?"; only what the 1024px look did not find":tt?`; ${ft(tt.charts,"chart")}, ${ft(tt.tables,"table")}, ${go(tt)}, ${ft(tt.sheets,"Sheet")} shown besides the first${Z}, page ${tt.height}px tall`:"";A.push({label:C,fail:U.fail,warn:U.warn,line:`${h.laptop?C:`${C.padStart(4)}px`} fail ${U.fail} \xB7 warn ${U.warn} \xB7 unverified ${U.unverified} \xB7 ${dt}${at}`})}let E=[...f.values()].sort((h,B)=>Bt.indexOf(h.level)-Bt.indexOf(B.level)),z=e.flatMap(h=>h.pictures);if(l&&z.length&&d.push(`Pictures of this run in ${Jt(l)}/ (each path below is in it):`),s){let h=new Map;for(let C of z)C.block!==void 0&&h.set(C.block,[...h.get(C.block)??[],C.file]);let B=Oe(e),_=C=>`${s.tags?.get(C)?`${s.tags.get(C)} `:""}${C}`,tt=`at ${$e.slice(0,-1).join(", ")} and ${$e.at(-1)}px`;s.tiles&&s.why&&d.push(`${s.why[0].toUpperCase()}${s.why.slice(1)}.`);for(let C of s.groups??[]){if(!C.ids.length&&!C.rest.length)continue;let v=!C.ids.length&&s.groups.some(U=>U!==C&&U.ids.length)?`: none this run (the ${Ae} blocks a run pictures went to the changed blocks above)`:"";d.push(`${C.why[0].toUpperCase()}${C.why.slice(1)}${C.ids.length?`, ${tt}`:v}:`);for(let U of C.ids){let L=n.blocks.get(U),it=`${L?`${n.name??"doc.html"}:${L}`:`(not in ${n.name??"doc.html"})`} ${U}${s.tags?.get(U)?` ${s.tags.get(U)}`:""}`,dt=h.get(U)??[],Z=s.moved?.has(U)?" (moved: with the edges of the blocks before and after it)":"",at=s.held?.get(U)??[],V=at.filter(F=>s.changed?.has(F)).length,pt=C.kind==="named"?ft(at.length,"block"):[V&&ft(V,"changed block"),at.length-V&&ft(at.length-V,"card")].filter(Boolean).join(" and "),lt=z.some(F=>F.block===U&&F.part)?", pictured again with each Sheet panel or detail card that holds one":"",st=at.filter(F=>B.has(F)),ct=[...new Set(st.flatMap(F=>B.get(F)))].map(F=>F.includes("\xD7")?F:`${F}px`).join(", "),y=st.length?`; ${st.length} of them not pictured at ${ct}: gallery qa ${i} --blocks ${st.join(",")}`:"",D=at.length?` (with the ${pt} it holds${lt}${y})`:"";d.push(dt.length?` ${it}${Z}${D}: ${j(dt).join(", ")}`:` ${it}${Z}${D}: not shown at any width (hidden)`)}if(C.rest.length){let U=ft(C.rest.length,{changed:"changed block",cards:"card"}[C.kind]??"block"),L=`${C.rest.slice(0,6).map(_).join(", ")}${C.rest.length>6?", \u2026":""}`;d.push(` ${C.ids.length?"and ":""}${U}${C.ids.length?" more":""}, not pictured (${L}): gallery qa ${i} --blocks ${C.rest.join(",")}`)}}s.unknown.length&&d.push(` no block of ${n.name??"doc.html"} has the id${s.unknown.length===1?"":"s"} ${s.unknown.join(", ")}`)}let $=[];for(let h of E)for(let{pictures:B}of h.said.values())$.push(...B.filter(_=>!$.includes(_)));$.length&&d.push("The elements flagged below, look at these first:",...j($).map(h=>` ${h}`));let Y=z.filter(h=>h.tile),X=Y.filter(h=>!h.sheet&&!h.card);X.length&&d.push(`The page as it opens (each Sheet area with the panel it shows first): ${ft(X.length,"tile")} in ${j([ht.dirname(X[0].file)])[0]}/ (<width>-<n>.png)`);let gt=new Map;for(let{sheet:h}of Y)h&&gt.set(h.number,{...h,count:(gt.get(h.number)?.count??0)+1});gt.size&&d.push(`Each other Sheet panel, shown in turn: ${ft(Y.filter(h=>h.sheet).length,"tile")} in ${j([ht.dirname(Y.find(h=>h.sheet).file)])[0]}/ (<width>-sheet<i>-<n>.png): ${[...gt.values()].map(({number:h,label:B,count:_})=>`sheet${h} ${Mt(B,24)} ${ft(_,"tile")}`).join(", ")}`);let N=new Map;for(let{card:h}of Y)h&&N.set(h.number,{...h,count:(N.get(h.number)?.count??0)+1});N.size&&d.push(`Each detail card, opened in turn as the window shows it, its content scrolled a tile at a time: ${ft(Y.filter(h=>h.card).length,"tile")} in ${j([ht.dirname(Y.find(h=>h.card).file)])[0]}/ (<width>-card<i>-<n>.png${Y.some(h=>h.card?.part)?"; with another panel of a Sheet in it shown, <width>-card<i>-sheet<j>-<n>.png":""}): ${[...N.values()].map(({number:h,label:B,count:_})=>`card${h} ${Mt(B,24)} ${ft(_,"tile")}`).join(", ")}`);for(let{place:h,name:B,right:_,down:tt}of u.values()){let C=/^(?:doc|report)\.html:\d+/.exec(h)?.[0]??h;d.push(`${"INFO".padEnd(10)} table-scrolls: ${C}${B?` ${Mt(B,32)}`:""}: ${[_.length&&`\u2192 ${Ut(_)}`,tt.length&&`\u2193 ${Ut(tt)}`].filter(Boolean).join("; ")} (${bo})`)}for(let h of E){d.push(`${h.level.toUpperCase().padEnd(10)} ${h.kind}: ${h.place}`);for(let[B,{labels:_,pictures:tt}]of h.said)d.push(` ${Ut(_)}: ${B}${tt.length?` (${j(tt).join(", ")})`:""}`);for(let B of xo(h))d.push(` ${B}`)}d.push(...A.map(({line:h})=>h));let Q=ko(s,i);return Q&&d.push(Q),w.info=x.size,{lines:d,levels:w,looks:A.map(({label:h,fail:B,warn:_})=>({label:h,fail:B,warn:_}))}}function ko(e,n="<slug>"){let{changed:s=[],restyled:l=[],packages:i=[],cards:d=[],since:w="the last look",first:f=!1}=e?.left??{};if(!s.length&&!l.length&&!d.length)return null;let x=A=>`${A.slice(0,6).map(j=>`${e.tags?.get(j)?`${e.tags.get(j)} `:""}${j}`).join(", ")}${A.length>6?", \u2026":""}`;return`Not pictured by this run, which pictures the blocks named alone: ${[s.length&&`${ft(s.length,"block")} changed or moved since ${w} (${x(s)})`,l.length&&`${ft(l.length,"instance")} of a custom block changed since ${w}, ${i.join(", ")} (${x(l)})`,d.length&&(f?`no earlier look: ${ft(d.length,"card")} never pictured (${x(d)})`:`${ft(d.length,"card")} the change of the document's own <script> or <style> since ${w} may draw again (${x(d)})`)].filter(Boolean).join("; ")}. gallery qa ${n} pictures them.`}function vo(e,n,s=[],{unpictured:l=!1}={}){let i=n.map(({label:A,fail:j,warn:K})=>`${po(A)} fail ${j}, warn ${K}`).join("; "),d=i?` (${i})`:"",w=Te(s.length===1?s[0].slug:void 0),f={stale:"its file had changed since its export",missing:"it had none yet"},x=s.filter(({first:A})=>A).map(({slug:A,first:j})=>`${s.length>1?`${A} was`:"It was"} exported first by this run (${f[j]}).`),u=`${x.length?`. ${x.join(" ")}`:""}${s.map(({file:A})=>`
2
+ import{a as fe,b as At}from"./chunk-342HXE3Q.mjs";import{c as ue,d as pe}from"./chunk-2KAVXMKG.mjs";import{b as ae}from"./chunk-XZCFPKGO.mjs";import{a as ie,b as re,c as le,d as ce,f as Dt,g as de,h as he}from"./chunk-PUOQ65NC.mjs";import{b as _t,c as ee,d as oe,f as ne,h as se}from"./chunk-6Q7ASAXJ.mjs";import{b as Wt,j as Qt}from"./chunk-4OZWXZE5.mjs";import{g as te}from"./chunk-3SKOU6OZ.mjs";import{a as Zt}from"./chunk-HYMEEXKN.mjs";import{a as Vt}from"./chunk-UMHUSOPJ.mjs";import{spawnSync as Le}from"node:child_process";import vt from"node:fs/promises";import ht from"node:path";import{pathToFileURL as Ie}from"node:url";import{MATH_IGNORED_TAGS as Fe}from"../browser/shared/components/math.mjs";import{exportPackagesOf as Pe,exportSourceOf as Ve,packagesSaid as _e}from"../browser/shared/export-wrap.mjs";import{sha256 as ge}from"../browser/shared/files.mjs";import{attr as me}from"../browser/shared/html-tree.mjs";import{projectRoot as De,qaDirectory as He,reportsDirectory as Rt}from"../browser/shared/paths.mjs";import{documentDirectory as Lt,documentFiles as It}from"../browser/shared/workspace.mjs";import{KINDS as Yo,LEVELS as Bt,LOOKS as we,WIDE as Ko,WIDTHS as $e,layoutNotesOf as ze,levelOf as Ee}from"../browser/shared/qa-levels.mjs";import{tableHidesScript as Ue}from"../browser/shared/table-hides.mjs";var Ge=new Set(["code-scrolls","formula-scrolls"]),qe=(e,n)=>e.level??Ee(e.kind,n),Ye=(e,n)=>["fail","warn"].includes(qe(e,n))||Ge.has(e.kind)&&Ee(e.kind,n)==="info",Ke=4,Ae=12,Xe=8,Je=2,xe=200,Qe=2e3,ye=600;function Ze({block:e,above:n=null,below:s=null}){let l=[e,n,s].filter(Boolean),i=Math.min(...l.map(u=>u.left)),d=Math.max(...l.map(u=>u.right)),w=n?Math.max(Math.min(n.top,e.top),e.top-xe):e.top,f=s?Math.min(Math.max(s.bottom,e.bottom),e.bottom+xe):e.bottom,x=(u,A)=>({x:Math.max(0,i),y:Math.max(0,u),width:d-i,height:A-Math.max(0,u)});return e.bottom-e.top<=Qe?[{part:"",clip:x(w,f)}]:[{part:"top",clip:x(w,e.top+ye)},{part:"bottom",clip:x(e.bottom-ye,f)}]}function be(e,n=""){if(e.startsWith("data:"))return`${e.slice(0,30)}\u2026 (${e.length} characters)`;let s=n.slice(0,n.lastIndexOf("/")+1);if(s&&e.startsWith(s)&&e.length>s.length)try{return decodeURIComponent(e.slice(s.length))}catch{return e.slice(s.length)}return e.length>60?`\u2026${e.slice(-59)}`:e}var Ft=e=>String(e??"").replace(/\s+/g," ").trim(),Mt=(e,n=40)=>{let s=Ft(e);return`"${s.length>n?`${s.slice(0,n-1)}\u2026`:s}"`},to=e=>String(e??"").replace(/\s+/g,"").slice(0,120);function eo(e,n="doc.html"){let s=new Map,l=new Map,i=new Map,d=(x,u)=>(u&&x.sourceCodeLocation.attrs?.[u]||x.sourceCodeLocation).startLine,w=new Map,f=x=>{if(x.nodeName==="#text")return x.value;if(!x.tagName&&x.nodeName!=="#document"||x.tagName==="template")return"";let u=(x.childNodes??[]).map(f).join("");if(!x.tagName||!x.sourceCodeLocation)return u;let A=me(x,"data-block-id");A!==void 0&&!s.has(A)&&s.set(A,d(x,"data-block-id"));let j=me(x,"id");j!==void 0&&!l.has(j)&&l.set(j,d(x,"id"));let K=to(u);if(K.length>=2){let m=`${x.tagName}|${K}`;w.has(m)||w.set(m,[]),w.get(m).push(x.sourceCodeLocation)}return u};f(Zt(e));for(let[x,u]of w)i.set(x,u.sort((A,j)=>A.startOffset-j.startOffset).map(A=>A.startLine));return{blocks:s,ids:l,texts:i,name:n}}function oo(e,n){if(!e)return"the page";let s=n.name??"doc.html",l=u=>{let A=u&&n.texts.get(`${u.tag}|${u.words}`);return A?.[Math.min(u.nth??0,A.length-1)]},i=e.table||e.header?.text,d=e.card?` card ${Mt(e.card.text)}`:i?` table ${Mt(i)}`:"",w=e.blocks?.find(u=>n.blocks.has(u));if(w!==void 0)return`${s}:${n.blocks.get(w)} [data-block-id="${w}"]${d}`;if(l(e.card))return`${s}:${l(e.card)} card ${Mt(e.card.text)}`;if(l(e.header))return`${s}:${l(e.header)} table ${Mt(i)}`;let f=e.texts?.find(l);if(f)return`${s}:${l(f)} ${f===e.texts[0]&&f.tag===e.tag?"":`${e.element} in `}<${f.tag}> ${Mt(f.text,32)}`;let x=e.ids?.find(u=>n.ids.has(u));return x!==void 0?`${s}:${n.ids.get(x)} #${x}${d}`:l(e.section)?`${s}:${l(e.section)} ${e.element} in the section ${Mt(e.section.text)}`:`${e.element}${d} (not found in ${s})`}function Yt(e){let n=new Date(e),s=d=>String(d).padStart(2,"0"),l=-n.getTimezoneOffset(),i=`${l<0?"-":"+"}${s(Math.floor(Math.abs(l)/60))}:${s(Math.abs(l)%60)}`;return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}T${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}${i}`}function no(e,n,s={said:"",now:""}){return e===n?s.said===s.now?{stale:!1,why:""}:{stale:!0,packaged:!0,why:`it holds ${s.said||"no custom block"}, the workspace has ${s.now||"none of them"}`}:{stale:!0,why:e?`made from a text whose sha256 is ${e.slice(0,12)}\u2026, the file's is ${n.slice(0,12)}\u2026`:"it does not say which text it was made from: made before exports said it, or before the kit's names were doc-* (2026-10-26), whose pages gallery qa no longer reads"}}async function Kt(e,{made:n=!1}={}){let s=It(Lt(e,Rt)).html,l=At(e),[i,d]=await Promise.all([vt.readFile(s).catch(()=>null),vt.stat(l).catch(()=>null)]);if(!i)return{problem:`${e}: no document (${s})`};if(!d)return{problem:`${e}: no export (${l}): run gallery export ${e} first`,missing:!0};let w=await vt.readFile(l),f=w.toString("utf8"),x=Ve(f),u={said:Pe(f),now:_e(te(i.toString("utf8")))},{stale:A,why:j,packaged:K=!1}=no(x,ge(i),u);return A&&!n?{problem:`${e}: ${l} is not of ${s} as it is now (${j}): run gallery export ${e} first`,stale:!0,why:j,edited:!!x&&!K,packaged:K}:{file:l,sha256:ge(w),time:d.mtimeMs}}function so(e,n){let s=e.map((w,f)=>({length:1,weight:n[f],previous:-1})),l=(w,f)=>w.length>f.length||w.length===f.length&&w.weight>f.weight;e.forEach((w,f)=>{for(let x=0;x<f;x++){if(e[x]>=w)continue;let u={length:s[x].length+1,weight:s[x].weight+n[f],previous:x};l(u,s[f])&&(s[f]=u)}});let i=-1;s.forEach((w,f)=>{(i<0||l(w,s[i]))&&(i=f)});let d=[];for(let w=i;w>=0;w=s[w].previous)d.unshift(w);return d}function Be(e,n){let s=n?.places??{},l=new Set((n?.moved??[]).filter(d=>e.has(d))),i=new Map;for(let[d,{parent:w,size:f=0}]of e){let x=s[d];if(x){if(x[0]!==w){l.add(d);continue}i.has(w)||i.set(w,[]),i.get(w).push({id:d,at:x[1],size:f})}}for(let d of i.values()){let w=new Set(so(d.map(({at:f})=>f),d.map(({size:f})=>f)).map(f=>d[f].id));for(let{id:f}of d)w.has(f)||l.add(f)}return l}function ao(e,n,s,{named:l=null,verified:i=!0,failed:d=!1,seen:w=null,page:f=void 0,packages:x=void 0}={}){if(!i||d||l&&!n)return null;let u=w??new Set([...s.ids,...[...s.held?.values()??[]].flat()]),A=!n,j=A||s.pageChanged?s.cards??[]:[],K=[...n?.unseen??[],...j],m={blocks:{},places:{},moved:A?[]:[...Be(e,n)].filter($=>!u.has($)),unseen:[...new Set(K)].filter($=>e.has($)&&!u.has($))};for(let[$,{hash:Y,parent:X,at:gt}]of e){let N=A||u.has($)?Y:n.blocks[$];N!==void 0&&(m.blocks[$]=N),m.places[$]=[X,gt]}let E=!A&&(l||s.tiles)?n.page:f;typeof E=="string"&&(m.page=E);let z=!A&&(l||s.tiles)?n.packages:x&&Object.fromEntries(Object.entries(x).map(([$,Y])=>[$,(s.restyled?.get($)??[]).every(X=>u.has(X))?Y:n.packages[$]]));return z&&Object.keys(z).length&&(m.packages=z),m}function Oe(e){let n=new Map;for(let s of e){let l=new Set(s.held?.covered??[]);for(let i of s.held?.missed??[])l.has(i)||n.set(i,[...n.get(i)??[],s.label??String(s.width)])}return n}function io(e,n){let s=Oe(n);return new Set([...e.ids,...[...e.held?.values()??[]].flat().filter(l=>!s.has(l))])}function Se(e){let n=e.time?` of ${Yt(e.time)}`:"";return e.from==="export"?`the export${n} (the document before these changes)`:e.from==="preview"?`gallery open${n} (the document before these changes)`:"the last look"}var ro=3;function lo(e,n,s=null,{tiles:l=!1,page:i=void 0,packages:d=void 0}={}){let w={rest:[],unknown:[],moved:new Set,around:new Map,held:new Map,groups:[],cards:[],pageChanged:!1,changed:new Set,restyled:new Map,left:null},f=[...e.keys()],x=new Map(f.map((a,M)=>[a,M])),u=n?Be(e,n):new Set,A=a=>typeof n?.packages?.[a]=="string"&&typeof d?.[a]=="string"&&n.packages[a]!==d[a],j=n?f.filter(a=>A(e.get(a).package)&&n.blocks[a]===e.get(a).hash&&!u.has(a)):[],K=new Map;for(let a of j)K.set(e.get(a).package,[...K.get(e.get(a).package)??[],a]);let m=new Set(j),E=n?f.filter(a=>n.blocks[a]!==e.get(a).hash||u.has(a)||m.has(a)):[],z=new Set((n?.unseen??[]).filter(a=>e.has(a)&&!E.includes(a))),$=(a,M)=>{let G=null;for(let et=e.get(a).parent;et!==null&&e.has(et);et=e.get(et).parent)M.has(et)&&(G=et);return G},Y=new Set(E),X=new Set(E.filter(a=>e.get(a).card||u.has(a))),gt=a=>Y.has(a)&&!u.has(a)&&$(a,X)===null,N=new Map;for(let a of f)for(let M=e.get(a).parent;M!==null&&e.has(M);M=e.get(M).parent){let G=N.get(M)??{all:0,changed:0};G.all+=1,gt(a)&&(G.changed+=1),N.set(M,G)}let Q=f.filter(a=>!e.get(a).card&&N.has(a)&&N.get(a).changed>=ro&&N.get(a).changed*2>=N.get(a).all);if(s){let a=[...new Set(s)].filter(o=>e.has(o)),M=new Set(a),G=new Map;for(let o of f){let r=M.has(o)?null:$(o,M);r!==null&&G.set(r,[...G.get(r)??[],o])}let et="the blocks named",$t=new Set([...a,...[...G.values()].flat()]),yt=!!n&&typeof n.page=="string"&&typeof i=="string"&&n.page!==i,xt=new Set([...E.filter(o=>e.get(o).card||u.has(o)),...Q]),bt=!n||yt?f.filter(o=>e.get(o).card&&!E.includes(o)):[],Pt=new Set([...xt,...bt]),Nt=[...E,...Q.filter(o=>!Y.has(o))].sort((o,r)=>x.get(o)-x.get(r)).filter(o=>!$t.has(o)&&$(o,xt)===null),Tt=Nt.filter(o=>m.has(o)),t={changed:Nt.filter(o=>!m.has(o)),...Tt.length?{restyled:Tt,packages:[...new Set(Tt.map(o=>e.get(o).package))]}:{},cards:bt.filter(o=>!$t.has(o)&&$(o,Pt)===null).sort((o,r)=>e.get(o).rank-e.get(r).rank||x.get(o)-x.get(r)),since:n?Se(n):"",first:!n};return{...w,ids:a,why:et,groups:[{kind:"named",why:et,ids:a,rest:[]}],held:G,pageChanged:yt,changed:new Set(E),restyled:K,left:t,unknown:[...new Set(s)].filter(o=>!e.has(o))}}if(e.size===0)return{...w,ids:[],why:"the document has no block ids (never handed in): the whole page in tiles instead",tiles:!0};if(l)return{...w,ids:[],why:null,tiles:!0};let h=(...a)=>(M,G)=>a.reduce((et,$t)=>et||$t(M)-$t(G),0),B=a=>e.get(a).rank,_=a=>x.get(a),tt=n?Se(n):"",C=!!n&&typeof n.page=="string"&&typeof i=="string"&&n.page!==i,v=f.filter(a=>e.get(a).card&&!E.includes(a)),L=!n||C||E.length===0?v:v.filter(a=>z.has(a)),it=new Set([...E.filter(a=>e.get(a).card||u.has(a)),...Q]),dt=new Set([...it,...L]),Z=new Map,at=(a,M)=>a.filter(G=>{let et=$(G,M);return et!==null&&Z.set(et,[...Z.get(et)??[],G]),et===null}),V=[...at(E,it),...Q.filter(a=>!Y.has(a)&&$(a,it)===null)].sort(h(a=>+!u.has(a),B,_)),pt=V.filter(a=>m.has(a)),lt=V.filter(a=>!m.has(a)),st=at(L,dt).sort(h(a=>+!z.has(a),B,_)),ct="the cards (chart cards, code blocks, whole blocks, components, flowcharts and Sheet areas, then columns and the other figures, then tables)",y=st.some(a=>z.has(a))?", those no look has pictured yet first":"",D=typeof n?.page=="string"&&typeof i=="string",F=n?C?`${ct.replace("the cards","the cards, not changed themselves")}${y}: the document's own <script> or <style> changed since ${tt}, which may draw any of them`:E.length?"the cards no look has pictured yet (not changed themselves)":`${ct}${y}: no block changed since ${tt}${D?", nor the document's own <script> or <style>":""}`:`${ct}: no earlier look to compare with`,J=[...lt.length?[{kind:"changed",why:`the blocks changed since ${tt}${u.size?" (a moved block pictured with the edges of the blocks before and after it, the moved ones first)":""}`,all:lt}]:[],...pt.length?[{kind:"changed",why:`the instances of a custom block changed since ${tt} (${[...new Set(pt.map(a=>e.get(a).package))].join(", ")})`,all:pt}]:[],...st.length||!V.length?[{kind:"cards",why:F,all:st}]:[]],R=Ae;for(let a of J)a.ids=a.all.slice(0,R),a.rest=a.all.slice(a.ids.length),R-=a.ids.length,delete a.all;let I=J.flatMap(a=>a.ids),k=a=>{let{parent:M,at:G}=e.get(a),et=$t=>f.find(yt=>e.get(yt).parent===M&&e.get(yt).at===G+$t)??null;return[et(-1),et(1)]},H=new Map(I.filter(a=>u.has(a)).map(a=>[a,k(a)])),c=new Map(I.filter(a=>Z.has(a)).map(a=>[a,Z.get(a)]));return{...w,ids:I,why:J[0].why,groups:J,rest:J.flatMap(a=>a.rest),moved:new Set(I.filter(a=>u.has(a))),around:H,held:c,cards:L,pageChanged:C,changed:new Set(E),restyled:K}}function co(e){let n=m=>!!m.closest("[data-doc-dev]"),s=[...document.querySelectorAll("details")].filter(m=>!n(m)),l=s.filter(m=>!m.open).length;s.forEach(m=>{m.open||m.setAttribute("data-qa-closed",""),m.open=!0});let i=[...document.images].filter(m=>!n(m));i.forEach(m=>{m.loading==="lazy"&&(m.loading="eager")});let d=[...document.querySelectorAll("dialog")].filter(m=>!n(m)&&!m.open);d.forEach((m,E)=>{m.dataset.qaCard=String(E)});let w=m=>m.parentElement?.closest("dialog[data-qa-card]")??null,f=[...document.querySelectorAll("[data-doc-sheets] > .doc-sheet-tabs > [data-sheet-tab]")].filter(m=>!n(m));f.forEach((m,E)=>{m.dataset.qaTab=String(E)});let x=m=>m.parentElement.parentElement,u=m=>{let E=[];for(let z=m.closest("[data-doc-sheet]");z;z=z.parentElement.closest("[data-doc-sheet]")){let $=f.find(Y=>x(Y)===z.parentElement&&Y.getAttribute("data-sheet-tab")===z.getAttribute("data-doc-sheet"));$&&E.unshift(Number($.dataset.qaTab))}return E},A=f.map((m,E)=>{let z=[...u(x(m)),E],$=[...x(m).children].find(X=>X.getAttribute("data-doc-sheet")===m.getAttribute("data-sheet-tab"));$&&($.dataset.qaPanel=String(E));let Y=w(m);return{index:E,chain:z,card:Y?Number(Y.dataset.qaCard):null,label:(m.textContent??"").replace(/\s+/g," ").trim(),shown:z.every(X=>f[X].getAttribute("aria-selected")==="true"),panel:!!$}}),j=d.map((m,E)=>{let z=`[href="#${CSS.escape(m.id)}"]`,$=[...m.querySelectorAll("h1, h2, h3, h4")].find(X=>X.textContent.trim())??document.querySelector(z),Y=[];for(let X=w(m);X;X=w(X))Y.unshift(Number(X.dataset.qaCard));return{index:E,chain:u(m),within:Y,label:($?.textContent||m.id||"").replace(/\s+/g," ").trim()}}),K=Promise.all(i.map(m=>m.decode().catch(()=>{})));return Promise.race([K.then(()=>!0),new Promise(m=>setTimeout(()=>m(!1),e))]).then(m=>({details:s.length,closed:l,images:i.length,loaded:m,sheets:A,cards:j}))}function ke(e){let n=document.querySelector(`[data-qa-card="${e}"]`);return n?(n.open||(globalThis.DocDialogs?globalThis.DocDialogs.open(n,null):typeof n.showModal=="function"?n.showModal():n.setAttribute("open","")),document.activeElement?.blur?.(),Promise.all(n.getAnimations({subtree:!0}).map(s=>s.finished.catch(()=>{}))).then(()=>n.open&&n.getClientRects().length>0)):Promise.resolve(!1)}function Ht(e){let n=document.querySelector(`[data-qa-card="${e}"]`);n?.open&&(globalThis.DocDialogs?globalThis.DocDialogs.close(n):typeof n.close=="function"?n.close():n.removeAttribute("open"))}async function ho({selector:e,up:n=0,margin:s=0,frames:l=2}){let i=document.querySelector(e);for(let v=0;v<n&&i;v++)i=i.parentElement;if(!i||i.getClientRects().length===0)return null;let d=i.getBoundingClientRect();i.scrollIntoView({block:"nearest",inline:"nearest"});let w=i.getBoundingClientRect();if(d.top!==w.top||d.left!==w.left){let v=()=>new Promise(U=>{requestAnimationFrame(()=>U()),setTimeout(U,100)});for(let U=0;U<l;U++)await v()}let f=v=>v===document.body||v===document.documentElement,x=(v,U,L)=>{let{left:it,top:dt,right:Z,bottom:at}=v;for(let V=U;V&&!f(V);V=V.parentElement){let pt=getComputedStyle(V),lt=pt.overflowX!=="visible",st=pt.overflowY!=="visible";if(lt||st){let ct=V.getBoundingClientRect();lt&&([it,Z]=[Math.max(it,ct.left),Math.min(Z,ct.right)]),st&&([dt,at]=[Math.max(dt,ct.top),Math.min(at,ct.bottom)])}if(V===L)break}return Z>it&&at>dt?{left:it,top:dt,right:Z,bottom:at}:null},u=v=>parseFloat(v)||0,A=(v,U)=>{let L=getComputedStyle(v,U);if(["none","normal"].includes(L.content)||L.display==="none"||!["absolute","fixed"].includes(L.position))return null;let it=L.position==="fixed"?null:getComputedStyle(v).position!=="static"?v:v.offsetParent,dt=it?it.getBoundingClientRect():{left:0,top:0,right:innerWidth,bottom:innerHeight},Z=it?getComputedStyle(it):null,at={left:dt.left+u(Z?.borderLeftWidth),top:dt.top+u(Z?.borderTopWidth),right:dt.right-u(Z?.borderRightWidth),bottom:dt.bottom-u(Z?.borderBottomWidth)},V=(y,D)=>L.boxSizing==="border-box"?0:u(L[`padding${y}`])+u(L[`padding${D}`])+u(L[`border${y}Width`])+u(L[`border${D}Width`]),pt=u(L.width)+V("Left","Right"),lt=u(L.height)+V("Top","Bottom"),st=L.left!=="auto"?at.left+u(L.left)+u(L.marginLeft):L.right!=="auto"?at.right-u(L.right)-u(L.marginRight)-pt:null,ct=L.top!=="auto"?at.top+u(L.top)+u(L.marginTop):L.bottom!=="auto"?at.bottom-u(L.bottom)-u(L.marginBottom)-lt:null;return st===null||ct===null||!(pt>0)||!(lt>0)?null:x({left:st,top:ct,right:st+pt,bottom:ct+lt},v,i)},j=[i.getBoundingClientRect()],K=[i];for(let v of i.querySelectorAll("*"))v instanceof SVGElement&&v.ownerSVGElement||v.matches("script, style, template")||v.getClientRects().length===0||getComputedStyle(v).visibility!=="hidden"&&(K.push(v),j.push(x(v.getBoundingClientRect(),v.parentElement,i)));for(let v of K)j.push(A(v,"::before"),A(v,"::after"));let m=document.createRange(),E=document.createTreeWalker(i,NodeFilter.SHOW_TEXT);for(let v=E.nextNode();v;v=E.nextNode())if(!(!v.nodeValue.trim()||!v.parentElement||v.parentElement.closest("svg, script, style, template"))){m.selectNodeContents(v);for(let U of m.getClientRects())j.push(x(U,v.parentElement,i))}m.detach();let z=j.filter(Boolean),$={left:Math.min(...z.map(v=>v.left)),top:Math.min(...z.map(v=>v.top)),right:Math.max(...z.map(v=>v.right)),bottom:Math.max(...z.map(v=>v.bottom))},Y=x($,i.parentElement,null)??$,X=!1;for(let v=i;v&&!X;v=v.parentElement)X=getComputedStyle(v).position==="fixed";let gt=visualViewport.pageLeft,N=visualViewport.pageTop,[Q,h]=X?[gt+innerWidth,N+innerHeight]:[document.documentElement.scrollWidth,document.documentElement.scrollHeight],B=Math.max(X?gt:0,Y.left+gt-s),_=Math.max(X?N:0,Y.top+N-s),tt=Math.min(Q,Y.right+gt+s),C=Math.min(h,Y.bottom+N+s);return tt>B&&C>_?{clip:{x:B,y:_,width:tt-B,height:C-_},fixed:X}:null}function ve(e){for(let s of e){let l=document.querySelector(`[data-qa-tab="${s}"]`);l&&l.getAttribute("aria-selected")!=="true"&&l.click()}let n=document.querySelector(`[data-qa-panel="${e.at(-1)}"]`);return!!(n&&!n.hidden&&n.getClientRects().length>0)}function zt({scope:e,next:n,ignored:s=[],place:l,slack:i=4,whole:d=[],drawn:w=[]}){let f=e?document.querySelector(e):document.body,x=[];if(!f)return{found:x,next:n};let u=document.documentElement.clientWidth,A=Math.round,j=t=>String(t??"").replace(/\s+/g," ").trim(),K=(t,o=32)=>{let r=j(t);return`"${r.length>o?`${r.slice(0,o-1)}\u2026`:r}"`},m=t=>!!t.closest?.("[data-doc-dev]"),E=t=>{if(!t.isConnected||t.getClientRects().length===0)return!1;for(let o=t;o&&o.nodeType===1;o=o.parentElement){let r=getComputedStyle(o);if(r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0||o.matches(".katex-mathml, .sr-only, [role=tooltip], [data-doc-dev]"))return!1}return!0},z=t=>`${t.localName}${[...t.classList].filter(o=>!o.startsWith("is-")).slice(0,2).map(o=>`.${o}`).join("")}`,$=t=>(t.textContent??"").replace(/\s+/g,"").slice(0,120),Y=new Map,X=t=>{let o=$(t);if(!Y.has(t.localName)){let b=new Map;for(let O of document.getElementsByTagName(t.localName)){if(m(O))continue;let W=$(O);b.has(W)||b.set(W,[]),b.get(W).push(O)}Y.set(t.localName,b)}let r=Y.get(t.localName).get(o)?.indexOf(t)??0;return{tag:t.localName,words:o,nth:Math.max(0,r),text:j(t.textContent).slice(0,80)}},gt=t=>{let o=t.cloneNode(!0);for(let r of o.querySelectorAll(".doc-tab"))r.before(" \xB7 ");return j(o.textContent).replace(/^· /,"")},N=t=>{let o=t.matches("table")?t:t.querySelector("table"),r=t.closest(".doc-table-wrap")??t,b=r.getAttribute("data-doc-chart-source")?.trim(),W=(b?[...document.querySelectorAll("[data-doc-chart-data]")].find(S=>S.getAttribute("data-doc-chart-data").trim()===b&&!m(S)):null)?.closest("figure")?.querySelector(":scope > h2, :scope > h3, :scope > h4, :scope > figcaption"),p=r.previousElementSibling;return j(o?.caption?.textContent)||j(W?.textContent)||(p?.matches("p.doc-note")?gt(p):"")||j(o?.querySelector("th")?.textContent??o?.rows[0]?.cells[0]?.textContent)},Q=t=>{let o=t.nodeType===1?t:t.parentElement,r=[],b=[];for(let g=o;g&&g!==document.documentElement;g=g.parentElement)g.hasAttribute("data-block-id")&&r.push(g.getAttribute("data-block-id")),g.id&&!g.hasAttribute("data-qa-tab")&&!g.hasAttribute("data-qa-panel")&&b.push(g.id);let O=[];for(let g=o,T=0;g&&T<4&&!g.matches("body, main, section, [data-doc-sheet], [data-doc-sheets], .doc-columns, .doc-column");g=g.parentElement,T++){let ot=X(g);ot.words.length>=2&&O.push(ot)}let W=o.closest("figure")?.querySelector(":scope > h3, :scope > figcaption, :scope > .doc-figure-caption"),p=o.closest(".doc-table-wrap, table"),S=p?.querySelector("th"),q=o.closest("section")?.querySelector(":scope > h2, :scope > h3, :scope > h4");return{blocks:r,ids:b,texts:O,tag:o.localName,element:z(o),card:W?X(W):null,header:S?X(S):null,table:p?N(p).slice(0,80):null,section:q?X(q):null}};if(l){let t=document.querySelector(l);return{found:x,next:n,anchor:t?Q(t):null}}let h=t=>(t.dataset.qaShot||(t.dataset.qaShot=String(++n)),Number(t.dataset.qaShot)),B=(t,o,r,{picture:b=o,url:O,measured:W,scroll:p,level:S}={})=>x.push({kind:t,what:r,anchor:o?Q(o):null,shot:b?h(b):null,seen:!!(b&&E(b)),url:O,measured:W,scroll:p,...S?{level:S}:{}}),_=t=>t.closest("figure")??t.closest("[data-doc-chart]")??t,tt=t=>{let o=t.getBoundingClientRect();return o.width>0&&o.height>0},C=(t,o,{x:r=!0,y:b=!0}={})=>Math.max(r?o.left-t.left:-1/0,r?t.right-o.right:-1/0,b?o.top-t.top:-1/0,b?t.bottom-o.bottom:-1/0),v=t=>({left:Math.min(...t.map(o=>o.x)),right:Math.max(...t.map(o=>o.x)),top:Math.min(...t.map(o=>o.y)),bottom:Math.max(...t.map(o=>o.y))}),U=t=>{let o=t.getBBox(),r=t.getScreenCTM();return v([[o.x,o.y],[o.x+o.width,o.y],[o.x+o.width,o.y+o.height],[o.x,o.y+o.height]].map(([b,O])=>new DOMPoint(b,O).matrixTransform(r)))},L=t=>{let o=[];for(let r=t.parentElement;r&&r!==document.documentElement;r=r.parentElement){let b=getComputedStyle(r);r instanceof SVGSVGElement&&b.overflow!=="visible"&&o.push(["the svg's edge",r.getBoundingClientRect(),{}]);let O=/url\(\s*["']?#([^)"']+)/.exec(`${r.getAttribute?.("clip-path")??""} ${b.clipPath??""}`)?.[1],W=O?document.getElementById(O):null,p=W?.getAttribute("clipPathUnits")!=="objectBoundingBox"?W?.querySelector("rect"):null;if(p&&r.getScreenCTM){let[S,q,g,T]=["x","y","width","height"].map(ot=>p[ot].baseVal.value);o.push(["a clip-path",v([[S,q],[S+g,q+T]].map(([ot,rt])=>new DOMPoint(ot,rt).matrixTransform(r.getScreenCTM()))),{}])}if(!(r instanceof SVGElement)){let S=/hidden|clip/.test(b.overflowX),q=/hidden|clip/.test(b.overflowY);(S||q)&&o.push([z(r),r.getBoundingClientRect(),{x:S,y:q}])}}return o},it=t=>`${t.slice(0,4).join("; ")}${t.length>4?`; ${t.length-4} more`:""}`,dt=t=>!t.matches("script, [data-doc-dev]")&&(t.matches("svg, canvas")||t.querySelector("svg, canvas")||E(t)&&tt(t));for(let t of f.querySelectorAll("[data-doc-chart]"))m(t)||!E(t)||[...t.children].some(dt)||B("chart-empty",t,`the ${t.getAttribute("data-doc-chart")||"chart"} chart drew nothing`,{picture:_(t)});let Z=[...f.querySelectorAll("svg")].filter(t=>{if(t.parentElement.closest("svg")||m(t)||t.closest(".katex, .doc-icon, button")||!E(t))return!1;let o=t.getBoundingClientRect();return t.closest("[data-doc-chart], figure")||o.width>=120&&o.height>=60}),at={across:.6,down:.25},V=new Map;for(let t of Z){let o=_(t),r=o.getBoundingClientRect(),b=[],O=[],W=[...t.querySelectorAll("text")].filter(q=>!q.closest("defs, clipPath, mask, pattern, marker, symbol")&&j(q.textContent)&&E(q));for(let q of W){let g=U(q),T=L(q).map(([ot,rt,ut])=>[ot,C(g,rt,ut)]).find(([,ot])=>ot>1.5);T?b.push(`${K(q.textContent,24)} ${A(T[1])}px past ${T[0]}`):C(g,r)>1.5&&O.push(`${K(q.textContent,24)} ${A(C(g,r))}px past the card's edge`)}b.length&&B("chart-text-clipped",t,it(b),{picture:o}),O.length&&B("chart-text-outside",t,it(O),{picture:o});let p=q=>{let g=/^(-?)[$¥€£]?(\d[\d,]*(?:\.\d+)?)\s*(?:%|‰|[kKMBG]|万|亿)?$/.exec(q.replace(/[−–]/g,"-"));return g?+`${g[1]}${g[2].replace(/,/g,"")}`:NaN},S=q=>q.every(Number.isFinite)&&q[1]!==q[0]&&q.slice(2).every((g,T)=>Math.abs(g-q[T+1]-(q[1]-q[0]))<=1e-9*Math.max(1,Math.abs(g)));for(let q of t.querySelectorAll("g")){let g=[...q.children].filter(P=>P.matches("g.tick")&&E(P)),T=g.map(P=>P.querySelector("text")).filter(P=>P&&j(P.textContent)&&E(P)),ot=T.map(P=>j(P.textContent));if(ot.length<2||ot.length!==g.length||!S(ot.map(p)))continue;let rt=T.map(P=>{let kt=P.getScreenCTM(),je=(parseFloat(getComputedStyle(P).fontSize)||0)*(kt?Math.hypot(kt.c,kt.d):1);return{label:P,box:U(P),size:je,turned:!!kt&&Math.abs(kt.b)>.001*Math.abs(kt.a)}});if(rt.some(P=>P.turned||!(P.size>0)))continue;let ut=rt.map(({box:P})=>[(P.left+P.right)/2,(P.top+P.bottom)/2]),nt=Math.max(...ut.map(([P])=>P))-Math.min(...ut.map(([P])=>P))>=Math.max(...ut.map(([,P])=>P))-Math.min(...ut.map(([,P])=>P)),mt=({box:P,size:kt})=>nt?[P.left,P.right]:[(P.top+P.bottom-kt)/2,(P.top+P.bottom+kt)/2],St=[...rt].sort((P,kt)=>mt(P)[0]-mt(kt)[0]),wt=null;for(let P=1;P<St.length;P++){let kt=mt(St[P])[0]-mt(St[P-1])[1];(!wt||kt<wt.gap)&&(wt={gap:kt,pair:[St[P-1],St[P]]})}let Ct=Math.max(...rt.map(P=>P.size));if(!wt||wt.gap>=at[nt?"across":"down"]*Ct)continue;for(let{label:P}of rt)V.set(P,q);let[Ot,qt]=wt.pair.map(({label:P})=>K(P.textContent,16)),We=wt.gap<0?`${Ot} and ${qt} overlapping by ${A(-wt.gap)}px`:`${Ot} and ${qt} ${A(wt.gap)}px apart`;B("ticks",t,`${ot.length} tick labels ${nt?"across":"down"} a ${A(nt?t.getBoundingClientRect().width:t.getBoundingClientRect().height)}px chart crowd: ${We}, under ${nt?"a digit's width and a hair":"a quarter of a line"} at their ${A(Ct)}px (${ot.slice(0,6).join(", ")}${ot.length>6?", \u2026":""})`,{picture:o})}}let pt=t=>{let o=t.getBBox(),r=t instanceof SVGTextElement&&parseFloat(getComputedStyle(t).fontSize)||o.height,b=o.y+Math.max(0,(o.height-r)/2),O=b+Math.min(o.height,r),W=t.getScreenCTM();return[[o.x,b],[o.x+o.width,b],[o.x+o.width,O],[o.x,O]].map(([p,S])=>new DOMPoint(p,S).matrixTransform(W))},lt=(t,o)=>{let r=1/0;for(let b of[t,o])for(let O=0;O<b.length;O++){let W=b[O],p=b[(O+1)%b.length],S=Math.hypot(p.x-W.x,p.y-W.y);if(S===0)continue;let q={x:-(p.y-W.y)/S,y:(p.x-W.x)/S},g=ut=>ut.map(nt=>nt.x*q.x+nt.y*q.y),[T,ot]=[g(t),g(o)],rt=Math.min(Math.max(...T),Math.max(...ot))-Math.max(Math.min(...T),Math.min(...ot));if(rt<=0)return 0;r=Math.min(r,rt)}return r===1/0?0:r},st=t=>[...t.querySelectorAll("text")].filter(o=>!o.closest("defs, clipPath, mask, pattern, marker, symbol")&&j(o.textContent)&&E(o));for(let t of Z){let o=st(t).map(b=>({label:b,outline:pt(b)})),r=[];o.forEach(({label:b,outline:O},W)=>{for(let p of o.slice(W+1))V.has(b)&&V.get(b)===V.get(p.label)||lt(O,p.outline)>1.5&&r.push(`${K(b.textContent,20)} and ${K(p.label.textContent,20)} overlap`)}),r.length&&B("chart-text-overlap",t,it(r),{picture:_(t)})}let ct=11;for(let t of Z){if(!t.hasAttribute("viewBox"))continue;let o=[];for(let O of st(t)){let W=O.getScreenCTM(),p=parseFloat(getComputedStyle(O).fontSize);if(!W||!(p>0))continue;let S=p*Math.hypot(W.c,W.d);S<ct-.05&&o.push(`${K(O.textContent,24)} at ${S.toFixed(1)}px (font-size ${+p.toFixed(2)})`)}if(!o.length)continue;let r=t.viewBox.baseVal,b=`${o.length} text${o.length>1?"s":""}`;B("svg-text-small",t,`${b} of a drawing scaled by its viewBox (${+r.width.toFixed(2)}\xD7${+r.height.toFixed(2)} drawn ${A(t.getBoundingClientRect().width)}px wide) render below ${ct}px: ${it(o)}`,{picture:_(t)})}let y=new Set;for(let t of f.querySelectorAll(".doc-table-wrap")){if(m(t)||!E(t))continue;y.add(t);let o=t.querySelector("table");if(!o)continue;let r=Math.max(t.clientWidth,o.offsetWidth),b=Math.max(t.clientHeight,o.offsetHeight),O=r>t.clientWidth+i,W=b>t.clientHeight+i,p=N(t);(O||W)&&B("table-scrolls",t,[O&&`${r}px wide in a ${t.clientWidth}px frame`,W&&`${b}px tall in a ${t.clientHeight}px frame`].filter(Boolean).join(", "),{scroll:{sideways:O,down:W,name:p}});let S=globalThis.__qaTableHides(t,o);S.said&&B("table-columns",t,`${S.said}: the table is ${r}px wide in a ${t.clientWidth}px frame`),S.shown<S.rows&&!t.style.getPropertyValue("--doc-table-height")&&B("table-rows",t,`the frame shows ${S.shown} of ${S.rows} rows: a reader scrolls inside it for the other ${S.rows-S.shown}; style="--doc-table-height: none" on its div.doc-table-wrap shows every row (or split the table where its content divides)`)}let D=t=>!!t.closest("details[data-qa-closed]"),F="in a disclosure closed in the file: a reader who opens it scrolls";for(let t of f.querySelectorAll(".doc-code, .doc-diff")){if(m(t)||!E(t))continue;let o=t.querySelector(":scope > pre, :scope > .doc-diff-body");if(o&&E(o)){let b=D(t);if(o.scrollHeight>o.clientHeight+i){let O=[t,o].map(q=>q.style.getPropertyValue("--doc-code-height").trim()).find(Boolean),W=o.getBoundingClientRect().top+o.clientTop+o.clientHeight,p=[...o.querySelectorAll(".doc-code-line")].filter(q=>q.getClientRects().length>0&&q.getBoundingClientRect().top>=W-1).length,S=b?`, ${F} inside it for the rest`:O?`, the block's own height (--doc-code-height: ${O}, the author's or the reader's): a reader scrolls inside it for the rest`:": a reader scrolls inside it for the rest";B("code-scrolls",t,`the code is ${o.scrollHeight}px tall, its frame ${o.clientHeight}px${p?` (its last ${p} line${p===1?"":"s"} below it)`:""}${S}`,{level:b||O?"info":void 0})}if(o.scrollWidth>o.clientWidth+i){let O=t.classList.contains("doc-code--nowrap"),W=b?`, ${F} sideways for the rest`:O?", its lines left unwrapped (doc-code--nowrap, the author's or the reader's choice): a reader scrolls sideways for the rest of its long lines":": a reader scrolls sideways for the rest";B("code-scrolls",t,`the code is ${o.scrollWidth}px wide, its frame ${o.clientWidth}px${W}`,{level:b||O?"info":void 0})}}let r=t.querySelector(":scope > .doc-code-title");r&&E(r)&&r.scrollWidth>r.clientWidth+1&&B("code-title-cut",t,`its title ${K(r.textContent,48)} is cut to fit its header (${r.scrollWidth}px of words in ${r.clientWidth}px)`)}for(let t of f.querySelectorAll(".doc-math-block")){if(m(t)||!E(t)||t.scrollWidth<=t.clientWidth+i)continue;let o=D(t);B("formula-scrolls",t,`the formula is ${t.scrollWidth}px wide, its frame ${t.clientWidth}px${o?`, ${F} it sideways for the rest`:": a reader scrolls it sideways for the rest"}`,{level:o?"info":void 0})}for(let t of f.querySelectorAll("[data-doc-layout]"))m(t)||!E(t)||B("layout",t,t.getAttribute("data-doc-layout"),{picture:t.closest("figure, .doc-table-wrap")??t,measured:y.has(t)});let J=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),R=new Map;for(let t=J.nextNode();t;t=J.nextNode()){if(!/\\\(|\\\[|\$\$/.test(t.nodeValue))continue;let o=t.parentElement;if(!o||o.closest([...s,".katex","[data-doc-dev]"].join(", "))||!E(o))continue;let r=o.closest("p, li, h1, h2, h3, h4, td, th, figcaption, summary, blockquote, dd, dt")??o;R.has(r)||R.set(r,t.nodeValue)}for(let[t,o]of R){let r=o.search(/\\\(|\\\[|\$\$/);B("raw-formula",t,`${K(o.slice(r,r+40),40)} is shown as written: the kit's math did not render it`)}for(let t of f.querySelectorAll(".katex-error"))m(t)||!E(t)||B("formula-error",t,`${K(t.textContent,32)}: ${j(t.getAttribute("title"))||"KaTeX could not read it"}`);let I=t=>`"${globalThis.__qaUrlName?.(t,document.baseURI)??t}"`,k=t=>{try{return new URL(t,document.baseURI).href}catch{return t}},H=t=>[...["src","href","poster","data"].filter(o=>t.hasAttribute(o)&&!(o==="href"&&t.matches("a, area"))).map(o=>t.getAttribute(o)),...(t.getAttribute("srcset")??"").split(",").map(o=>o.trim().split(/\s+/)[0]),...[t.getAttribute("style"),t.localName==="style"?t.textContent:""].flatMap(o=>[...String(o??"").matchAll(/url\(\s*["']?([^"')]+)/g)].map(r=>r[1]))].filter(o=>o&&!o.trim().startsWith("#")).map(k),c=[...document.querySelectorAll("*")].filter(t=>!m(t)).flatMap(t=>H(t).map(o=>({node:t,address:o}))),a=new Set;for(let{url:t,directive:o}of globalThis.__qaViolations??[]){let r=/^[a-z][a-z\d+.-]*$/i.test(t)?`${t.toLowerCase()}:`:null,b=c.find(W=>r?!a.has(W)&&W.address.startsWith(r):W.address===t);b&&r&&a.add(b);let O=b?.node??null;e&&!(O&&f.contains(O))||B("blocked",O,`${o} blocked ${I(b?.address??t)}${O?` (${z(O)})`:""}: the export holds every file it shows`,{url:b?.address??t})}for(let t of f.querySelectorAll("img")){if(m(t)||t.complete&&t.naturalWidth>0)continue;let o=t.currentSrc||t.src?k(t.currentSrc||t.src):"";B("image",t,`${o?I(o):"a picture with no src"} did not load`,{picture:t.closest("figure")??t,url:o})}let M=new Set(d),G=new Set(w),et=document.createRange(),$t="button, select, input, textarea, [data-doc-dev]",yt=(t,o)=>t!==o&&(t.matches($t)||[...t.classList].some(r=>r.startsWith("doc-"))),xt=(t,o,r)=>{let b=[],O=!1;for(let W=t,p=!0;W&&W!==document.body&&W!==document.documentElement;W=W.parentElement,p=!1){let S=getComputedStyle(W);if((!p||r)&&(O&&(S.position!=="static"||S.transform!=="none")&&(O=!1),!O)){if(/auto|scroll/.test(S.overflowY))break;/hidden|clip/.test(S.overflowY)&&!yt(W,o)&&b.push(W)}if(S.position==="fixed")break;S.position==="absolute"&&(O=!0)}return b},bt=t=>t.getBoundingClientRect().bottom-(parseFloat(getComputedStyle(t).borderBottomWidth)||0),Pt=t=>{let o=getComputedStyle(t),r=b=>!/^(transparent|rgba\(.*,\s*0\))$/.test(b);return r(o.backgroundColor)||o.backgroundImage!=="none"||["Top","Right","Bottom","Left"].some(b=>parseFloat(o[`border${b}Width`])>0&&o[`border${b}Style`]!=="none"&&r(o[`border${b}Color`]))},Nt="rect, circle, ellipse, line, polyline, polygon, path, use",Tt=(t,o)=>{let r=new Map,b=(p,S,q,g)=>{if(!r.has(p)&&r.size>=3)return;let T=r.get(p)??{words:[],marks:[],depth:0,height:p.getBoundingClientRect().height};q&&T.words.push(q),g&&T.marks.push(g),T.depth=Math.max(T.depth,S),r.set(p,T)},O=p=>p.getBoundingClientRect().height>1.5,W=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let p=W.nextNode();p;p=W.nextNode()){let S=p.parentElement;if(!p.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!E(S)||o(S))continue;let q=xt(S,t,!0).filter(O);if(q.length===0)continue;let g=getComputedStyle(S),T=parseFloat(g.lineHeight);for(let ot of p.nodeValue.matchAll(/\S+/g)){let rt=ot.index+ot[0].length;et.setStart(p,ot.index),et.setEnd(p,rt);let ut=[...et.getClientRects()];for(let nt of ut){let mt=Number.isFinite(T)?Math.max(0,(nt.height-T)/2):0,St=q.find(Ct=>nt.bottom-bt(Ct)>1.5+mt);if(!St)continue;let wt=ot.index;if(ut.length>1){let Ct=bt(St)+1.5+mt;for(let Ot=rt-1;wt<Ot;){let qt=wt+Ot>>1;et.setStart(p,qt),et.setEnd(p,qt+1),(et.getClientRects()[0]?.bottom??0)>Ct?Ot=qt:wt=qt+1}}b(St,Math.max(...ut.map(Ct=>Ct.bottom))-bt(St),p.nodeValue.slice(wt,rt),null);break}}}for(let p of t.querySelectorAll("*")){let S=p instanceof SVGElement&&p.matches(Nt)&&!p.closest("defs, clipPath, mask, pattern, marker, symbol"),q=!S&&!(p instanceof SVGElement)&&!p.matches("img, picture, video, canvas, iframe, object, embed, script, style, template")&&p.children.length===0&&!p.textContent.trim()&&Pt(p);if(!S&&!q||!E(p))continue;let g=p.getBoundingClientRect();if(g.width<=0&&g.height<=0)continue;let T=S?p.ownerSVGElement:null,ot=[...T&&getComputedStyle(T).overflowY!=="visible"?[T]:[],...xt(T??p,t,!!T)].filter(O),rt=nt=>{let mt=nt.getBoundingClientRect();return g.left>=mt.left-1.5&&g.right<=mt.right+1.5&&g.top>=mt.top-1.5},ut=ot.find(nt=>g.bottom-bt(nt)>1.5&&rt(nt));ut&&b(ut,g.bottom-bt(ut),null,S?p.localName:z(p))}return r};for(let t of f.querySelectorAll("[data-block-id]")){let o=t.getAttribute("data-block-id"),r=G.has(o);if(!r&&!M.has(o)||m(t)||!E(t))continue;let b=p=>p.closest(".doc-chart-message")||p.closest("h2, h3, h4, p, figcaption")?.parentElement===t,O=new Map,W=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let p=W.nextNode();p&&O.size<3;p=W.nextNode()){let S=p.parentElement;if(!p.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!E(S)||r&&b(S))continue;let q=S;for(;q!==t&&["inline","contents"].includes(getComputedStyle(q).display);)q=q.parentElement;let g=!1;for(let nt=S;nt&&!g;nt=nt===t?null:nt.parentElement){let mt=getComputedStyle(nt);g=mt.overflowX!=="visible"||mt.overflowY!=="visible"}if(g)continue;let T=getComputedStyle(q),ot=q.getBoundingClientRect(),rt=ot.left+parseFloat(T.borderLeftWidth)+parseFloat(T.paddingLeft),ut=ot.right-parseFloat(T.borderRightWidth)-parseFloat(T.paddingRight);for(let nt of p.nodeValue.matchAll(/\S+/g)){et.setStart(p,nt.index),et.setEnd(p,nt.index+nt[0].length);let mt=[...et.getClientRects()],St=Math.max(0,...mt.flatMap(Ct=>[Ct.right-ut,rt-Ct.left]));if(St<=1.5||mt.some(Ct=>Ct.right>u+1))continue;let wt=O.get(q)??{words:[],reach:0,width:ut-rt};wt.words.push(nt[0]),wt.reach=Math.max(wt.reach,St),O.set(q,wt)}}for(let[p,{words:S,reach:q,width:g}]of O)B("overflow-in-block",p,`the words ${K(S.join(" "),40)} run ${A(q)}px past the side of ${z(p)} (${A(g)}px wide for its words), over what is beside it`,{picture:t});for(let[p,{words:S,marks:q,depth:g,height:T}]of Tt(t,r?b:()=>!1)){let ot=[S.length&&`the words ${K(S.join(" "),40)}`,q.length&&`${q.length===1?"a mark":`${q.length} marks`} (${[...new Set(q)].slice(0,3).join(", ")})`].filter(Boolean).join(" and "),rt=S.length===0&&q.length===1;B("cut-in-block",p,`${ot} ${rt?"reaches":"reach"} ${A(g)}px past the bottom of ${z(p)} (${A(T)}px tall, its overflow ${getComputedStyle(p).overflowY}), cut off there`,{picture:t})}}if(et.detach(),document.documentElement.scrollWidth>u+1){let t=g=>{for(let T=g.parentElement;T&&T!==document.body;T=T.parentElement)if(getComputedStyle(T).overflowX!=="visible")return!1;return g.nodeType!==1||getComputedStyle(g).position!=="fixed"},o=[...f.querySelectorAll("*")].filter(g=>!(g instanceof SVGElement&&g.ownerSVGElement)&&!m(g)&&g.getBoundingClientRect().right>u+1&&E(g)&&t(g)),r=o.filter(g=>!o.includes(g.parentElement)).slice(0,3),b=`the page is ${document.documentElement.scrollWidth}px wide in a ${u}px window`,O=new Set(o),W=g=>{for(let T=g.parentElement;T;T=T.parentElement)if(O.has(T))return!0;return!1},p=new Map,S=document.createRange(),q=document.createTreeWalker(f,NodeFilter.SHOW_TEXT);for(let g=q.nextNode();g&&p.size<3;g=q.nextNode()){let T=g.parentElement;if(!T||!g.nodeValue.trim()||T.closest("svg, script, style, template")||m(T)||W(g)||!E(T)||!t(g)||(S.selectNodeContents(g),![...S.getClientRects()].some(nt=>nt.right>u+1)))continue;let ot=T.closest("[data-block-id]")??T;if(p.has(ot))continue;let rt=[],ut=0;for(let nt of g.nodeValue.matchAll(/\S+/g)){S.setStart(g,nt.index),S.setEnd(g,nt.index+nt[0].length);let mt=Math.max(...[...S.getClientRects()].map(St=>St.right),0);mt<=u+1||(rt.push(nt[0]),ut=Math.max(ut,mt))}rt.length&&p.set(ot,{node:T,words:rt.join(" "),right:ut})}S.detach(),r.length===0&&p.size===0&&!e&&B("overflow",null,b);for(let g of r)B("overflow",g,`${b}: ${z(g)} ${K(g.textContent,24)} reaches ${A(g.getBoundingClientRect().right)}px`);for(let[g,{node:T,words:ot,right:rt}]of p)B("overflow",T,`${b}: the words ${K(ot,60)} in ${z(g)} run past its edge to ${A(rt)}px (a text that cannot break)`,{picture:g})}return{found:x,next:n}}function fo(){let e=s=>!!s.closest("[data-doc-dev]"),n=s=>[...document.querySelectorAll(s)].filter(l=>!e(l)).length;return{charts:n("[data-doc-chart], [data-doc-component='gallery/chart-view']"),tables:n(".doc-table-wrap"),height:document.documentElement.scrollHeight}}var Et=2e4,Me=1800;function jt(e,n,s){let l=0,i=new Promise((d,w)=>{l=setTimeout(()=>w(new Error(`${s}: no answer in ${n/1e3}s`)),n)});return Promise.race([e,i]).finally(()=>clearTimeout(l))}var Xt=e=>`${e.kind}|${JSON.stringify(e.anchor)}|${e.what}`;async function uo(e,n,s,{out:l,tiles:i=!1,blocks:d=[],around:w=new Map,held:f=new Map,whole:x=[],drawn:u=[],known:A=null}){let{width:j,height:K=900,label:m=String(j)}=typeof s=="number"?{width:s}:s,E=m.replace("\xD7","x"),z,$;try{z=await jt(e.createBrowserContext(),Et,"a browser context opened"),$=await jt(z.newPage(),Et,"a tab opened")}catch(y){return await Dt(z?.close()),{findings:[{kind:"unverified",what:`the browser did not open a page: ${y.message}`,anchor:null,shot:null,seen:!1,state:""}],counts:null,pictures:[],held:{covered:[],missed:[]}}}$.setDefaultTimeout(Et);let Y=[],X=[],gt=new Set,N=new Map,Q=new Set,h=new Set,B=new Set,_="",tt=0,C=(y,D,F={})=>Y.push({kind:y,what:D,anchor:null,shot:null,seen:!1,state:_,...F}),v=Ie(n).href,U=y=>`"${be(y,v)}"`,L=y=>l.folders?.get(y)??l.blocks,it=y=>y.replace(/[^\w-]/g,"_");$.on("pageerror",y=>C("error",`uncaught ${Ft(y.message).slice(0,200)}`)),$.on("console",y=>{y.type()==="error"&&le(y,v)&&C("error",`console: ${Ft(y.text()).slice(0,200)}`)}),$.on("requestfailed",y=>{y.frame()===$.mainFrame()&&C("request",`${U(y.url())}: ${y.failure()?.errorText??"failed"}`,{url:y.url()})}),$.on("response",y=>{y.status()>=400&&y.request().frame()===$.mainFrame()&&C("request",`${U(y.url())}: HTTP ${y.status()}`,{url:y.url()})}),await ce($),await $.evaluateOnNewDocument(`globalThis.__qaUrlName = ${be}; globalThis.__qaTableHides = ${Ue()};`),await $.setViewport({width:j,height:K}),await $.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);let dt=async y=>{for(let D of await he($,{timeout:Et}))C("unverified",`${y}: waited for ${D}`)},Z=async(y,D,F,J)=>jt($.screenshot({path:F,clip:y,captureBeyondViewport:!D}),Et,"the picture").then(()=>!0,R=>(C("unverified",`no picture of ${J} (${R.message})`),!1)),at=async(y,D,F,J=0)=>{let R=await $.evaluate(ho,{selector:y,up:J,margin:Xe,frames:Je}).catch(I=>({error:I}));return R?.clip?await Z(R.clip,R.fixed,D,F)?R.clip:null:(C("unverified",`no picture of ${F} (${R?.error?.message??"the element is gone or shows nothing"})`),null)},V=(y,D)=>y.left<D.x+D.width&&y.right>D.x&&y.top<D.y+D.height&&y.bottom>D.y,pt=async()=>{let y=d.filter(F=>!Q.has(F)),D=await $.evaluate((F,J,R)=>{let I=new Map(F.map((M,G)=>[M,G])),k=M=>!!M&&!M.closest("[data-doc-dev], dialog:not([open])")&&M.getClientRects().length>0,H=M=>M===null?null:[...document.querySelectorAll("[data-block-id]")].find(G=>G.getAttribute("data-block-id")===M&&k(G))??null,c=M=>{if(!M)return null;let G=M.getBoundingClientRect();return{left:G.left+scrollX,right:G.right+scrollX,top:G.top+scrollY,bottom:G.bottom+scrollY}},a=[];for(let M of document.querySelectorAll("[data-block-id]")){let G=I.get(M.getAttribute("data-block-id"));if(G===void 0||!k(M))continue;I.delete(M.getAttribute("data-block-id")),M.setAttribute("data-qa-block",String(G));let[et,$t]=J[G]??[],yt=(R[G]??[]).map(xt=>[xt,[...M.querySelectorAll("[data-block-id]")].find(bt=>bt.getAttribute("data-block-id")===xt&&k(bt))]).filter(([,xt])=>xt);a.push({index:G,boxes:J[G]?{block:c(M),above:c(H(et)),below:c(H($t))}:null,held:yt.map(([xt,bt])=>({id:xt,box:c(bt)}))})}return a},y,y.map(F=>w.get(F)??null),y.map(F=>f.get(F)??[]));for(let{index:F,boxes:J,held:R}of D){let I=y[F];Q.add(I);let k=`${E}-${it(I)}`,H=[];if(!J){let c=ht.join(L(I),`${k}.png`),a=await at(`[data-qa-block="${F}"]`,c,`the block ${I}`);a&&(X.push({block:I,file:c}),H.push(a))}for(let{part:c,clip:a}of J?Ze(J):[]){let M=ht.join(L(I),`${k}${c?`-${c}`:""}.png`);await Z(a,!1,M,`the block ${I}${c?` (its ${c})`:""}`)&&(X.push({block:I,file:M}),H.push(a))}for(let{id:c,box:a}of R)H.some(M=>V(a,M))?h.add(c):h.has(c)||B.add(c);await $.evaluate(c=>document.querySelector(`[data-qa-block="${c}"]`)?.removeAttribute("data-qa-block"),F)}},lt=async(y,D,F)=>{let J=[...f].filter(([I])=>Q.has(I)).map(([I,k])=>[I,k.filter(H=>!h.has(H))]).filter(([,I])=>I.length);if(!J.length)return;let R=await $.evaluate((I,k)=>{let H=document.querySelector(I);if(!H)return[];let c=a=>[...H.querySelectorAll("[data-block-id]")].some(M=>M.getAttribute("data-block-id")===a&&M.getClientRects().length>0);return k.map(([a,M])=>[a,M.filter(c)]).filter(([,a])=>a.length)},y,J);for(let[I,k]of R){let H=ht.join(L(I),`${E}-${it(I)}-${D}.png`);if(await at(y,H,`the block ${I} (${D})`,F)){X.push({block:I,part:D,file:H});for(let c of k)h.add(c),B.delete(c)}}},st=async y=>{let D=await $.evaluate(zt,{scope:y,next:tt,ignored:Fe,slack:Ke,whole:x,drawn:u});tt=D.next;let F=D.found.flatMap(R=>R.kind!=="layout"?[R]:ze(R.what,j).filter(({kind:I})=>!(R.measured&&["table-columns","table-rows"].includes(I))).map(({kind:I,note:k})=>({...R,kind:I,what:`the kit notes ${k}`})));for(let R of F){let I=R.shot===null?null:`${R.kind}|${R.shot}|${R.what}`,k=I&&N.get(I);if(k)!k.seen&&R.seen&&Object.assign(k,R,{state:_});else{let H={...R,state:_};Y.push(H),I&&N.set(I,H)}}let J=new Set(Y.filter(R=>R.kind==="blocked").map(R=>R.url));for(let R of Y){if(R.shot===null||!R.seen||gt.has(R.shot)||!Ye(R,j)||A?.has(Xt(R))||["request","image"].includes(R.kind)&&J.has(R.url))continue;gt.add(R.shot);let I=ht.join(l.flagged,`${E}-${String(R.shot).padStart(2,"0")}-${R.kind}.png`);await at(`[data-qa-shot="${R.shot}"]`,I,R.kind)&&X.push({shot:R.shot,file:I})}d.length&&await pt()},ct=y=>{let D=new Set(Y.filter(J=>J.kind==="blocked").map(J=>J.url));return{findings:Y.filter(J=>!(["request","image"].includes(J.kind)&&D.has(J.url))&&!A?.has(Xt(J))),counts:y,pictures:X,held:{covered:[...h],missed:[...B]}}};try{try{let k=new Promise(c=>$.once("domcontentloaded",c)),H=$.goto(v,{waitUntil:"load",timeout:6e4});if(H.catch(()=>{}),await Promise.race([k,H]),$.url()!==v)throw new Error(`the browser shows ${$.url()}`)}catch(k){return C("unverified",`the page did not load: ${k.message}`),ct(null)}await dt("the page as it opens");let y=await $.evaluate(co,Et);y.loaded||C("unverified",`the pictures (${y.images}) not all loaded in ${Et/1e3}s`),y.closed&&await dt(`the page with its ${y.closed} closed disclosure${y.closed===1?"":"s"} opened`),await st(null);let D=async(k,H,c,a=null)=>{for(let M=k,G=1;M<H;M+=Me,G++){let et=ht.join(l.tiles,`${E}-${c}${String(G).padStart(2,"0")}.png`);await jt($.screenshot({path:et,clip:{x:0,y:M,width:j,height:Math.min(Me,H-M)},captureBeyondViewport:!0}),Et,"a tile").then(()=>X.push({tile:!0,sheet:a,file:et}),$t=>C("unverified",`no tile ${c}${G} (${$t.message})`))}};i&&await D(0,await $.evaluate(()=>document.documentElement.scrollHeight),"");let F=async(k,H=null)=>{if(!await $.evaluate(ve,k.chain)){let{anchor:c}=await $.evaluate(zt,{next:tt,place:`[data-qa-tab="${k.index}"]`});return C("unverified","this Sheet could not be shown: its tab was clicked and its panel stayed hidden",{anchor:c}),!1}if(await dt("the Sheet shown"),await st(`[data-qa-panel="${k.index}"]`),await lt(`[data-qa-panel="${k.index}"]`,`sheet${k.index+1}`,1),i&&H)await J(H,`sheet${k.index+1}-`);else if(i){let c=await $.evaluate(a=>{let M=document.querySelector(`[data-qa-panel="${a}"]`)?.getBoundingClientRect();return M&&M.height>0?{top:Math.max(0,M.top+scrollY),bottom:M.bottom+scrollY}:null},k.index);c&&await D(c.top,c.bottom,`sheet${k.index+1}-`,{number:k.index+1,label:k.label})}return!0},J=async(k,H="")=>{for(let c=1;c<=20;c++){let a=await $.evaluate((G,et)=>{let $t=document.querySelector(`[data-qa-card="${G}"]`),yt=$t?.querySelector(".doc-dialog-content")??$t;if(!yt)return null;if(et)yt.scrollTop=0;else{let bt=yt.scrollTop;if(yt.scrollTop+=Math.max(40,yt.clientHeight-24),yt.scrollTop===bt)return null}let xt=$t.getBoundingClientRect();return{x:xt.left+visualViewport.pageLeft,y:xt.top+visualViewport.pageTop,width:xt.width,height:xt.height}},k.index,c===1);if(!a)break;let M=ht.join(l.tiles,`${E}-card${k.index+1}-${H}${String(c).padStart(2,"0")}.png`);await Z(a,!0,M,`the detail card ${Mt(k.label,24)}, tile ${H}${c}`)&&X.push({tile:!0,card:{number:k.index+1,label:k.label,part:H},file:M})}},R=0;for(let k of y.sheets)k.shown||!k.panel||k.card!==null||(_=`Sheet ${Mt(k.label,24)}`,await F(k)&&(R+=1));let I=0;for(let k of y.cards){_=`detail card ${Mt(k.label,24)}`;let H=`[data-qa-card="${k.index}"]`;k.chain.length&&await $.evaluate(ve,k.chain);for(let c of k.within)await $.evaluate(ke,c);if(!await $.evaluate(ke,k.index)){let{anchor:c}=await $.evaluate(zt,{next:tt,place:H});C("unverified","this detail card could not be opened",{anchor:c});for(let a of k.within.toReversed())await $.evaluate(Ht,a);continue}I+=1,await dt("the detail card opened"),await st(H),await lt(H,`card${k.index+1}`,0),i&&await J(k);for(let c of y.sheets)c.card!==k.index||c.shown||!c.panel||(_=`detail card ${Mt(k.label,24)}, Sheet ${Mt(c.label,24)}`,await F(c,k)&&(R+=1));await $.evaluate(Ht,k.index);for(let c of k.within.toReversed())await $.evaluate(Ht,c)}return _="",ct({...await $.evaluate(fo),details:y.details,closed:y.closed,sheets:R,cards:y.cards.length,cardsOpened:I})}catch(y){return C("unverified",`the look ended early: ${y.message}`),ct(null)}finally{await Dt(z.close())}}var Jt=e=>e.split(ht.sep).join("/"),ft=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`,Ut=e=>`${e.join(", ")}px`,po=e=>e.includes("\xD7")?e:`${e}px`;function go({details:e,closed:n}){if(e===0)return"0 disclosures";let s=n===0?"open in the file":`${n===e?"":`${n} `}closed in the file, opened for the pictures`;return`${ft(e,"disclosure")} (${s})`}function Re(e,n=null){let s=new Map;for(let l of e){let i=n?ht.relative(n,l):"",d=Jt(n&&i&&!i.startsWith("..")&&!ht.isAbsolute(i)?i:l),w=/^(.*\/)?(\d+(?:x\d+)?)-([^/]+)$/.exec(d),f=w?`${w[1]??""}\0${w[3]}`:d;s.has(f)||s.set(f,w?{head:w[1]??"",tail:w[3],looks:[]}:{whole:d});let x=s.get(f);w&&!x.looks.includes(w[2])&&x.looks.push(w[2])}return[...s.values()].map(l=>l.whole??`${l.head}${l.looks.length>1?`{${l.looks.join(",")}}`:l.looks[0]}-${l.tail}`)}function mo(e){let n=e.map(({folder:l,files:i})=>({folder:l,files:[...new Set(i)]})).filter(({files:l})=>l.length);if(!n.length)return null;let s=n.reduce((l,{files:i})=>l+i.length,0);return`Not opened yet: ${ft(s,"picture")} of this run, none looked at for you; open each, and in the handoff name those you opened: ${n.flatMap(({folder:l,files:i})=>Re(i,l).map(d=>ht.isAbsolute(d)?d:`${Jt(l)}/${d}`)).join(", ")}`}var Te=(e="<slug>")=>`more pictures: gallery qa ${e} --tiles (the page, each Sheet panel and each detail card in tiles), gallery qa ${e} --blocks <id,\u2026> (the blocks you name)`,nn=Te(),Ne=fe,Ce='look at the export yourself at 1024, 736 and 360px, its disclosures and detail cards opened (SKILL.md, "Export, check and look"), and say so when you hand the document over.',wo=e=>Ft(e?.message).replace(/\s*Use a different `?userDataDir`? or stop the running browser first\.?/gi,"").slice(0,300),Gt={overflow:"a reader scrolls the whole page sideways. Words that cannot break where they stand (a long path, URL or name): wrap each in <code>, which breaks where it must and keeps it whole for the reader to copy; an element wider than the window (a picture, a drawing, a width of your own): let it fit (max-width: 100%) or put it in a frame that scrolls; never cut or rewrite a path to silence this","table-columns":"not a failure. If the reader must see the column on a desktop, write its long values compactly (a cell of numbers stays on one line, so its longest value sets the column's width: a range as a\u2013b, fewer digits), move a unit out of its header into the line above the table, shorten the header, or split the table; never delete a column to silence this","chart-text-overlap":"not a failure. If the reader must read both, shorten the labels (a unit belongs in the axis's title), move one (above its row, or a leader line) or give the drawing more room at this width; never delete a label or a category to silence this","code-scrolls":'not a failure. A reader scrolls inside the frame (40 lines) for the rest; if every line must show at once, write style="--doc-code-height: none" on its <pre>; never delete code to silence this',"formula-scrolls":"not a failure. A reader scrolls the formula sideways for the rest; if it must show whole at this width, break it into lines (\\begin{aligned} \u2026 \\end{aligned}) or into two formulas; never cut a term to silence this","overflow-in-block":"not a failure. If the words run over others in the picture, give their box room at this width (a wider column in an @media rule of your <style>, or a smaller font there), or let them break (a dash or a space where a line may end); never cut the words to silence this","cut-in-block":"not a failure. If the reader must see what is cut, let the box grow with what it holds (min-height instead of height or max-height, or none), give it room at this width in an @media rule of your <style>, or let it scroll (overflow: auto); never delete the words to silence this",ticks:"not a failure. If the numbers crowd in the picture, give that axis fewer ticks at this width with axis.tickValues([...]), at most four on a phone (the domain's ends and middle; ticks(n) is only a hint to d3 and can still draw five or more), or shorter numbers (the unit in the axis's title: 2k, 1.5\u4E07); never take the axis out to silence this","svg-text-small":"not a failure. The viewBox scales the drawing's text with it: give the text a larger font-size in the viewBox's units (a viewBox 800 wide drawn 340px wide scales by 0.43, so 26 units read as 11px), or lay the drawing out for narrow widths (a viewBox of its own under an @media rule, a chart of your own drawn from its width, or HTML that wraps); never drop the labels to silence this"},$o='not a failure. A reader scrolls sideways for the rest of its long lines; if the reader must see them whole at this width, let them wrap (take data-wrap="false" off its <pre>) or break them where the code allows; a tree or a log whose lines must stay whole may scroll; never cut a line to silence this';function xo(e){if(e.kind!=="code-scrolls")return Gt[e.kind]?[Gt[e.kind]]:[];let n=[...e.said.keys()],s=n.some(l=>/ wide, its frame /.test(l));return[...!s||n.some(l=>/ tall, its frame /.test(l))?[Gt["code-scrolls"]]:[],...s?[$o]:[]]}var yo="none is a failure: each says what to do if it matters to the reader (never delete a column or a label to silence one)",bo="a reader scrolls it: not a problem";function So(e,n,s=null,{folder:l=null,slug:i="<slug>"}={}){let d=[],w=Object.fromEntries(Bt.map(h=>[h,0])),f=new Map,x=new Set,u=new Map,A=[],j=h=>Re(h,l),K=h=>h.label??String(h.width),m=new Map(e.flatMap(h=>h.pictures.filter(B=>B.shot!==void 0).map(B=>[`${K(h)}|${B.shot}`,B.file])));for(let h of e){let{width:B,findings:_,counts:tt}=h,C=K(h),v=new Set,U=Object.fromEntries(Bt.map(V=>[V,0])),L={right:0,down:0,all:0};for(let V of _){let pt=`${V.kind}|${V.shot??""}|${V.what}`;if(v.has(pt))continue;v.add(pt);let lt=qe(V,B);U[lt]+=1;let st=oo(V.anchor,n);if(V.kind==="table-scrolls"){let{sideways:R=!1,down:I=!1,name:k=""}=V.scroll??{};Object.assign(L,{all:L.all+1,right:L.right+Number(R),down:L.down+Number(I)});let H=`${st}|${k}`;u.has(H)||u.set(H,{place:st,name:k,right:[],down:[]}),R&&!u.get(H).right.includes(C)&&u.get(H).right.push(C),I&&!u.get(H).down.includes(C)&&u.get(H).down.push(C)}if(lt==="info"&&x.add(`${V.kind}|${st}`),lt==="info"&&["table-scrolls","table-columns","table-rows"].includes(V.kind))continue;let ct=`${Bt.indexOf(lt)}|${V.kind}|${st}`;f.has(ct)||(f.set(ct,{level:lt,kind:V.kind,place:st,said:new Map}),lt!=="info"&&(w[lt]+=1));let y=f.get(ct).said,D=`${V.state?`[${V.state}] `:""}${V.what}`;y.has(D)||y.set(D,{labels:[],pictures:[]});let F=y.get(D);F.labels.includes(C)||F.labels.push(C);let J=m.get(`${C}|${V.shot}`);J&&!F.pictures.includes(J)&&F.pictures.push(J)}let it=[L.right&&`\u2192 ${L.right}`,L.down&&`\u2193 ${L.down}`].filter(Boolean).join(", "),dt=`${ft(L.all,"table scrolls","tables scroll")}${it?` (${it})`:""}`,Z=tt?.cards?`, ${ft(tt.cards,"detail card")} (${tt.cardsOpened===tt.cards?"closed in the file, opened in turn":`${tt.cardsOpened??0} of them opened`})`:"",at=h.laptop?"; only what the 1024px look did not find":tt?`; ${ft(tt.charts,"chart")}, ${ft(tt.tables,"table")}, ${go(tt)}, ${ft(tt.sheets,"Sheet")} shown besides the first${Z}, page ${tt.height}px tall`:"";A.push({label:C,fail:U.fail,warn:U.warn,line:`${h.laptop?C:`${C.padStart(4)}px`} fail ${U.fail} \xB7 warn ${U.warn} \xB7 unverified ${U.unverified} \xB7 ${dt}${at}`})}let E=[...f.values()].sort((h,B)=>Bt.indexOf(h.level)-Bt.indexOf(B.level)),z=e.flatMap(h=>h.pictures);if(l&&z.length&&d.push(`Pictures of this run in ${Jt(l)}/ (each path below is in it):`),s){let h=new Map;for(let C of z)C.block!==void 0&&h.set(C.block,[...h.get(C.block)??[],C.file]);let B=Oe(e),_=C=>`${s.tags?.get(C)?`${s.tags.get(C)} `:""}${C}`,tt=`at ${$e.slice(0,-1).join(", ")} and ${$e.at(-1)}px`;s.tiles&&s.why&&d.push(`${s.why[0].toUpperCase()}${s.why.slice(1)}.`);for(let C of s.groups??[]){if(!C.ids.length&&!C.rest.length)continue;let v=!C.ids.length&&s.groups.some(U=>U!==C&&U.ids.length)?`: none this run (the ${Ae} blocks a run pictures went to the changed blocks above)`:"";d.push(`${C.why[0].toUpperCase()}${C.why.slice(1)}${C.ids.length?`, ${tt}`:v}:`);for(let U of C.ids){let L=n.blocks.get(U),it=`${L?`${n.name??"doc.html"}:${L}`:`(not in ${n.name??"doc.html"})`} ${U}${s.tags?.get(U)?` ${s.tags.get(U)}`:""}`,dt=h.get(U)??[],Z=s.moved?.has(U)?" (moved: with the edges of the blocks before and after it)":"",at=s.held?.get(U)??[],V=at.filter(F=>s.changed?.has(F)).length,pt=C.kind==="named"?ft(at.length,"block"):[V&&ft(V,"changed block"),at.length-V&&ft(at.length-V,"card")].filter(Boolean).join(" and "),lt=z.some(F=>F.block===U&&F.part)?", pictured again with each Sheet panel or detail card that holds one":"",st=at.filter(F=>B.has(F)),ct=[...new Set(st.flatMap(F=>B.get(F)))].map(F=>F.includes("\xD7")?F:`${F}px`).join(", "),y=st.length?`; ${st.length} of them not pictured at ${ct}: gallery qa ${i} --blocks ${st.join(",")}`:"",D=at.length?` (with the ${pt} it holds${lt}${y})`:"";d.push(dt.length?` ${it}${Z}${D}: ${j(dt).join(", ")}`:` ${it}${Z}${D}: not shown at any width (hidden)`)}if(C.rest.length){let U=ft(C.rest.length,{changed:"changed block",cards:"card"}[C.kind]??"block"),L=`${C.rest.slice(0,6).map(_).join(", ")}${C.rest.length>6?", \u2026":""}`;d.push(` ${C.ids.length?"and ":""}${U}${C.ids.length?" more":""}, not pictured (${L}): gallery qa ${i} --blocks ${C.rest.join(",")}`)}}s.unknown.length&&d.push(` no block of ${n.name??"doc.html"} has the id${s.unknown.length===1?"":"s"} ${s.unknown.join(", ")}`)}let $=[];for(let h of E)for(let{pictures:B}of h.said.values())$.push(...B.filter(_=>!$.includes(_)));$.length&&d.push("The elements flagged below, look at these first:",...j($).map(h=>` ${h}`));let Y=z.filter(h=>h.tile),X=Y.filter(h=>!h.sheet&&!h.card);X.length&&d.push(`The page as it opens (each Sheet area with the panel it shows first): ${ft(X.length,"tile")} in ${j([ht.dirname(X[0].file)])[0]}/ (<width>-<n>.png)`);let gt=new Map;for(let{sheet:h}of Y)h&&gt.set(h.number,{...h,count:(gt.get(h.number)?.count??0)+1});gt.size&&d.push(`Each other Sheet panel, shown in turn: ${ft(Y.filter(h=>h.sheet).length,"tile")} in ${j([ht.dirname(Y.find(h=>h.sheet).file)])[0]}/ (<width>-sheet<i>-<n>.png): ${[...gt.values()].map(({number:h,label:B,count:_})=>`sheet${h} ${Mt(B,24)} ${ft(_,"tile")}`).join(", ")}`);let N=new Map;for(let{card:h}of Y)h&&N.set(h.number,{...h,count:(N.get(h.number)?.count??0)+1});N.size&&d.push(`Each detail card, opened in turn as the window shows it, its content scrolled a tile at a time: ${ft(Y.filter(h=>h.card).length,"tile")} in ${j([ht.dirname(Y.find(h=>h.card).file)])[0]}/ (<width>-card<i>-<n>.png${Y.some(h=>h.card?.part)?"; with another panel of a Sheet in it shown, <width>-card<i>-sheet<j>-<n>.png":""}): ${[...N.values()].map(({number:h,label:B,count:_})=>`card${h} ${Mt(B,24)} ${ft(_,"tile")}`).join(", ")}`);for(let{place:h,name:B,right:_,down:tt}of u.values()){let C=/^(?:doc|report)\.html:\d+/.exec(h)?.[0]??h;d.push(`${"INFO".padEnd(10)} table-scrolls: ${C}${B?` ${Mt(B,32)}`:""}: ${[_.length&&`\u2192 ${Ut(_)}`,tt.length&&`\u2193 ${Ut(tt)}`].filter(Boolean).join("; ")} (${bo})`)}for(let h of E){d.push(`${h.level.toUpperCase().padEnd(10)} ${h.kind}: ${h.place}`);for(let[B,{labels:_,pictures:tt}]of h.said)d.push(` ${Ut(_)}: ${B}${tt.length?` (${j(tt).join(", ")})`:""}`);for(let B of xo(h))d.push(` ${B}`)}d.push(...A.map(({line:h})=>h));let Q=ko(s,i);return Q&&d.push(Q),w.info=x.size,{lines:d,levels:w,looks:A.map(({label:h,fail:B,warn:_})=>({label:h,fail:B,warn:_}))}}function ko(e,n="<slug>"){let{changed:s=[],restyled:l=[],packages:i=[],cards:d=[],since:w="the last look",first:f=!1}=e?.left??{};if(!s.length&&!l.length&&!d.length)return null;let x=A=>`${A.slice(0,6).map(j=>`${e.tags?.get(j)?`${e.tags.get(j)} `:""}${j}`).join(", ")}${A.length>6?", \u2026":""}`;return`Not pictured by this run, which pictures the blocks named alone: ${[s.length&&`${ft(s.length,"block")} changed or moved since ${w} (${x(s)})`,l.length&&`${ft(l.length,"instance")} of a custom block changed since ${w}, ${i.join(", ")} (${x(l)})`,d.length&&(f?`no earlier look: ${ft(d.length,"card")} never pictured (${x(d)})`:`${ft(d.length,"card")} the change of the document's own <script> or <style> since ${w} may draw again (${x(d)})`)].filter(Boolean).join("; ")}. gallery qa ${n} pictures them.`}function vo(e,n,s=[],{unpictured:l=!1}={}){let i=n.map(({label:A,fail:j,warn:K})=>`${po(A)} fail ${j}, warn ${K}`).join("; "),d=i?` (${i})`:"",w=Te(s.length===1?s[0].slug:void 0),f={stale:"its file had changed since its export",missing:"it had none yet"},x=s.filter(({first:A})=>A).map(({slug:A,first:j})=>`${s.length>1?`${A} was`:"It was"} exported first by this run (${f[j]}).`),u=`${x.length?`. ${x.join(" ")}`:""}${s.map(({file:A})=>`
3
3
  ${Ne}${A}`).join("")}`;if(e.fail)return`failures at ${ft(e.fail,"place")}${d}: fix them in the document's doc.html (report.html in an older document), then run this again (it exports first); ${w}${u}`;if(e.unverified)return`nothing failed${d}; not verified at ${ft(e.unverified,"place")}: say so when you hand the document over; ${w}${u}`;if(e.warn)return`nothing failed${d}; warnings at ${ft(e.warn,"place")} to look at, ${yo}; ${w}${u}`;if(l){let A=s.length===1?s[0].slug:"<slug>";return`nothing found${d}, and no picture taken: a plain run pictures the cards and the blocks changed since the last look, and the document has no card (a chart or a drawing, code, a whole block, a component, a flowchart, a Sheet area, columns, a figure, a table) and no block changed; run gallery qa ${A} --tiles to picture the page, each Sheet panel and each detail card in tiles, open those pictures and look at the document once yourself; gallery qa ${A} --blocks <id,\u2026> pictures the blocks you name${u}`}return`nothing found${d}: open the pictures above and look at the document once yourself; ${w}${u}`}function Mo(e,{missing:n=!1,edited:s=!1,packaged:l=!1}={}){let i=At(e),d=ht.basename(It(Lt(e,Rt)).html);return`exporting first: ${n?`no export yet (${i})`:s?`${d} changed since the last export (${i})`:l?`a custom block it uses changed since the last export (${i})`:`the last export (${i}) does not say which text it was made from (an older Gallery's)`}, as gallery export ${e} does (--no-export: refuse instead)`}async function Co(e){for(let[i,{missing:d,edited:w,packaged:f}]of e)console.log(`${i}: ${Mo(i,{missing:d,edited:w,packaged:f})}`);let n=new Map(await Promise.all(e.map(async([i])=>[i,await vt.stat(At(i)).then(d=>d.mtimeMs,()=>null)]))),s=Le(process.execPath,[ht.join(De,"bin","gallery.mjs"),"export",...e.map(([i])=>i)],{cwd:Rt,encoding:"utf8",env:{...process.env,GALLERY_WORKSPACE:Rt},maxBuffer:256*1024*1024});s.stdout&&process.stdout.write(s.stdout),s.stderr&&process.stderr.write(s.stderr),s.error&&console.error(`the export did not run: ${s.error.message}`);let l=[];for(let[i]of e){let d=await vt.stat(At(i)).then(w=>w.mtimeMs,()=>null);d!==null&&d!==n.get(i)&&!(await Kt(i,{made:!0})).problem&&l.push(i)}return l}var Eo=e=>String(e??"").split(/[\s,]+/).filter(Boolean);function qo(e,n){let s=_t(e);return[...new Set(n)].filter(l=>!s.has(l))}var Ao=(e,n)=>`--blocks: no block of ${e} has the id${n.length===1?"":"s"} ${n.join(", ")}: nothing was looked at and no picture removed. Name ids as gallery qa prints them (data-block-id in the file).`;async function sn(e){let{slugs:n,options:s,values:l}=await Qt({options:["--tiles","--no-export"],values:["--blocks"],argv:e}),i=l.has("--blocks")?Eo(l.get("--blocks")):null;if(i?.length===0)throw new Wt("--blocks takes block ids: --blocks <id,\u2026>");if(i&&n.length!==1)throw new Wt("--blocks names blocks of one document: name one.");let d=new Map,w=[];for(let N of n){let Q=await Kt(N);Q.problem&&!((Q.stale||Q.missing)&&!s.has("--no-export"))&&w.push(Q.problem),d.set(N,Q)}if(w.length&&(console.error(w.join(`
4
4
  `)),process.exit(2)),i){let N=It(Lt(n[0],Rt)).html,Q=qo(Vt(await vt.readFile(N,"utf8").catch(()=>"")),i);if(Q.length)throw new Wt(Ao(ht.resolve(N),Q))}await ae(n),await ue(n),await pe(n);let f=[...d].filter(([,N])=>N.stale||N.missing),x=new Map(f.map(([N,Q])=>[N,Q.missing?"missing":"stale"]));if(f.length){let N=await Co(f),Q=f.map(([h])=>h).filter(h=>!N.includes(h));for(let h of N)d.set(h,await Kt(h,{made:!0}));Q.length&&(console.error(`${Q.join(", ")}: the export failed (above), so nothing was looked at: fix what it says, then run this again`),process.exit(1))}let u=d,A=[...u].map(([N,{file:Q}])=>({slug:N,file:Q,first:x.get(N)??null})),j=(N,Q)=>{for(let[h,{sha256:B,time:_}]of u)console.log(`${h}: ${At(h)} sha256 ${B}, exported ${Yt(_)}`);console.log(`UNVERIFIED ${N}: nothing was looked at. ${Q}`);for(let{file:h}of A)console.log(`${Ne}${h}`);process.exit(3)},K=ie();K||j("no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one)",`Install Chrome or Edge, or ${Ce}`);let m=await de({executablePath:K,args:re()}).catch(N=>j(`the browser ${K} did not start, twice, each time with a fresh profile (${wo(N)}; GALLERY_BROWSER=<its executable> picks another)`,`Run gallery qa once more; if it says UNVERIFIED again, ${Ce}`)),{browser:E}=m,z=Object.fromEntries(Bt.map(N=>[N,0])),$=new Map,Y=!1,X=[];try{for(let[N,{file:Q,sha256:h,time:B}]of u){let _=ht.join(He,N),tt=ht.join(_,"blocks.json");console.log(`${N}: ${At(N)} sha256 ${h}, exported ${Yt(B)} (${ht.basename(K)}, headless)`);let C=It(Lt(N,Rt)).html,v=Vt(await vt.readFile(C,"utf8")),U=_t(v),L=se(U,ne(await vt.readFile(tt,"utf8").catch(()=>null))),it=ee(v),dt=oe(v),Z=lo(U,L,i,{tiles:s.has("--tiles")&&!i,page:it,packages:dt}),at=s.has("--tiles")||!!Z.tiles;(at||Z.ids.length)&&(Y=!0);let V={flagged:ht.join(_,"flagged"),blocks:ht.join(_,i?"blocks":"changed"),tiles:ht.join(_,"tiles")},pt=ht.join(_,"cards");V.folders=new Map(Z.groups.flatMap(c=>c.ids.map(a=>[a,c.kind==="cards"?pt:V.blocks])));let lt=[V.flagged,...i?[V.blocks]:Z.tiles?[]:[V.blocks,pt],...at?[V.tiles]:[]],st=(await Promise.all(lt.map(async c=>[c,(await vt.readdir(c).catch(()=>[])).filter(a=>a.endsWith(".png")).length]))).filter(([,c])=>c>0);st.length&&console.log(`The pictures of the run before in ${st.map(([c])=>`${ht.basename(c)}/`).join(", ")} (${ft(st.reduce((c,[,a])=>c+a,0),"file")}) were removed: this run's replace them.`);for(let c of lt)await vt.rm(c,{recursive:!0,force:!0});for(let c of await vt.readdir(_).catch(()=>[]))c.endsWith(".png")&&await vt.rm(ht.join(_,c),{force:!0});for(let c of lt)await vt.mkdir(c,{recursive:!0});let ct=[...U].filter(([,{whole:c}])=>c).map(([c])=>c),y=[...U].filter(([,{figure:c}])=>c).map(([c])=>c),D=[],F=null;for(let c of we){let a=await uo(E,Q,c,{out:V,tiles:at&&!c.laptop,blocks:c.laptop?[]:Z.ids,around:Z.around,held:c.laptop?new Map:Z.held,whole:ct,drawn:y,known:c.laptop?F:null});D.push({...c,...a}),a.pictures.length&&(Y=!0),X.push({folder:_,files:a.pictures.map(({file:M})=>M)}),!c.laptop&&c.width===we.find(M=>M.laptop)?.width&&(F=new Set(a.findings.map(Xt)))}let{lines:J,levels:R,looks:I}=So(D,eo(v,ht.basename(C)),{...Z,tags:new Map([...U].map(([c,{tag:a}])=>[c,a]))},{folder:_,slug:N});console.log(J.join(`
5
5
  `));for(let c of Bt)z[c]+=R[c];for(let{label:c,fail:a,warn:M}of I){let G=$.get(c)??{label:c,fail:0,warn:0};$.set(c,{label:c,fail:G.fail+a,warn:G.warn+M})}let k=D.every(c=>c.counts&&!c.findings.some(a=>a.kind==="unverified")),H=ao(U,L,Z,{named:i,verified:k,failed:R.fail>0,seen:io(Z,D),page:it,packages:dt})??L;H&&await vt.writeFile(tt,`${JSON.stringify(H)}
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{d as m,i as g,k as p}from"./chunk-JJNRIFND.mjs";import{b as a,f as l,i as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{reportsDirectory as i}from"../browser/shared/paths.mjs";import{joinDefaultTree as b,joinedLine as k}from"../browser/shared/drafts.mjs";var D=5e3;async function v(f){let{positional:s,options:u}=l({options:["--no-browser"],argv:f});if(s.length>1)throw new a("Name one document at most.");let{slug:o=null,block:w=null}=s.length?await c(s[0]):{};console.log(`\u5DE5\u4F5C\u533A\uFF1A${i}`);let e=await g({slug:o,baseline:o!==null});if(e.ok||console.error(e.message),e.reason==="missing"){let{HOME:n,pageExists:d}=await import("../browser/shared/pages.mjs"),{missingPageSaid:E,HOME_NOT_MADE:r}=await import("./chunk-DAMVDXR3.mjs");d(o,i)?console.error(`"${o}" is a custom page, not a document: gallery page open ${o} opens it and gives its address.`):o===n&&await E(o,i)===r&&console.error(r)}if(o!==null&&e.reason!=="missing"){let{roundBegins:n}=await import("./chunk-TDWJKOLN.mjs");await n(o,e.ok?{}:{wait:D})}if(o!==null&&e.reason!=="missing"){let n=k(await b(i,o));n&&console.log(n)}e.ok||process.exit(1);let t=await p(o,e,w);for(let n of t)console.log(n);console.log(await m(t,u))}export{v as run};
2
+ import{d as m,i as g,k as p}from"./chunk-BN7M3IN7.mjs";import{b as a,f as l,i as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{reportsDirectory as i}from"../browser/shared/paths.mjs";import{joinDefaultTree as b,joinedLine as k}from"../browser/shared/drafts.mjs";var D=5e3;async function v(f){let{positional:s,options:u}=l({options:["--no-browser"],argv:f});if(s.length>1)throw new a("Name one document at most.");let{slug:o=null,block:w=null}=s.length?await c(s[0]):{};console.log(`\u5DE5\u4F5C\u533A\uFF1A${i}`);let e=await g({slug:o,baseline:o!==null});if(e.ok||console.error(e.message),e.reason==="missing"){let{HOME:n,pageExists:d}=await import("../browser/shared/pages.mjs"),{missingPageSaid:E,HOME_NOT_MADE:r}=await import("./chunk-2T4PZQEP.mjs");d(o,i)?console.error(`"${o}" is a custom page, not a document: gallery page open ${o} opens it and gives its address.`):o===n&&await E(o,i)===r&&console.error(r)}if(o!==null&&e.reason!=="missing"){let{roundBegins:n}=await import("./chunk-5XV3YYLG.mjs");await n(o,e.ok?{}:{wait:D})}if(o!==null&&e.reason!=="missing"){let n=k(await b(i,o));n&&console.log(n)}e.ok||process.exit(1);let t=await p(o,e,w);for(let n of t)console.log(n);console.log(await m(t,u))}export{v as run};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as ue,b as we,k as ge,v as $e,w as be}from"./chunk-SOD23RGL.mjs";import{M as ye}from"./chunk-4DNHHJSL.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-3A5I2GJK.mjs";import{c as R,f as ke}from"./chunk-S2Y7VI4H.mjs";import"./chunk-XQRUG4G3.mjs";import{a as P}from"./chunk-JEUK3ZO7.mjs";import"./chunk-4AMTKWDO.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import{b as de,h as D}from"./chunk-WTEGUPFG.mjs";import"./chunk-2GKGEVMR.mjs";import{n as ie}from"./chunk-LE44MD3O.mjs";import"./chunk-4OZWXZE5.mjs";import{a as pe,j as fe,s as me}from"./chunk-XMKHCUI6.mjs";import{d as re,e as le,i as I,j as ce,k as he}from"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import{a as g}from"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import{a as z,c as S}from"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import{c as ae}from"./chunk-7XDYK3UC.mjs";import{a as F,f as te,h as se,j as U,r as ne,s as oe}from"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as Ue}from"node:buffer";import X from"node:fs";import E from"node:path";import{instanceSlots as ze,instancesOf as Y,isInstance as Z,partOf as W}from"../browser/shared/components/index.mjs";import{fewestSyllables as Oe}from"../browser/shared/pinyin.mjs";import{ATTRIBUTE as $,refusedInCopy as De}from"../browser/shared/components/installed.mjs";import{attr as b,elementsOf as Q,walk as A}from"../browser/shared/html-tree.mjs";import{blankedCss as M}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as G,SLOT as Le}from"../browser/shared/components/installed.mjs";var Ae=new Set(["media","supports","container","layer","starting-style"]);function K(e,t){let s=0,o="";for(let n=0;n<e.length;n++){let i=e[n];i==="\\"?n++:o?o=i===o?"":o:i==='"'||i==="'"?o=i:i===")"||i==="]"?s--:(s===0&&t(i,n),(i==="("||i==="[")&&s++)}}function Ce(e){let t=M(e),s=M(e,{strings:!0}),o={children:[]},n=[o],i=0,r=0;for(let a=0;a<t.length;a++){let l=t[a];if(l==="\\")a++;else if(l==="("||l==="[")r++;else if(l===")"||l==="]")r=Math.max(0,r-1);else{if(r>0)continue;if(l==="{"){let c={prelude:s.slice(i,a),start:i,children:[]};n.at(-1).children.push(c),n.push(c),i=a+1}else l==="}"?(n.length>1&&n.pop(),i=a+1):l===";"&&(i=a+1)}}return o.children}function _(e){let t=[],s=0;return K(e,(o,n)=>{o===","&&(t.push({text:e.slice(s,n),start:s}),s=n+1)}),t.push({text:e.slice(s),start:s}),t.filter(({text:o})=>o.trim())}function H(e){let t=[],s=e.trim(),o="",n=0,i=0,r=a=>{(i||a)>n&&t.push({combinator:o,compound:s.slice(n,i||a)}),i=0};return K(s,(a,l)=>{/\s/.test(a)?l===n?n=l+1:i||=l:">+~".includes(a)?(r(l),o=a,n=l+1):i&&(r(l),o=" ",n=l)}),r(s.length),t}function B(e){let t=[],s=-1,o=0,n="";for(let r=0;r<e.length;r++){let a=e[r];a==="\\"?r++:n?n=a===n?"":n:a==='"'||a==="'"?n=a:a==="("?o++:a===")"?o--:a==="["&&o===0?s=r:a==="]"&&o===0&&s>=0&&(t.push(e.slice(s,r+1)),s=-1)}let i=!1;return K(e,r=>{i||=r==="&"}),{attributes:t,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(e)}}var Ie=e=>new RegExp(`^\\[\\s*${G}\\s*=\\s*(["'])${e.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),Pe=e=>M(e).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function xe(e,t,s,o=!1){let n=H(e),i=({compound:f})=>B(f).attributes.some(h=>t.test(h)),r=({compound:f})=>{let{nesting:h,scope:m}=B(f);return!!s&&(h||m)},a=f=>["+","~"].includes(f?.combinator),l=f=>n.slice(f).some(({combinator:h},m)=>(m+f===0?h||" ":h)===" "),c=n.findLastIndex(f=>i(f)||r(f));if(c<0)return!s||Pe(e)?{why:"outside"}:{why:s==="instance"&&a(n[0])?"beside":null,subject:"inside",deep:o||l(0)};let p=i(n[c])||s==="instance";return{why:p&&a(n[c+1])?"beside":null,subject:p&&c===n.length-1?"instance":"inside",deep:!i(n[c])&&o||l(c+1)}}var Se=e=>e.some(({subject:t})=>t==="instance")?"instance":"inside",Re=new RegExp(`^\\[\\s*${Le}\\s*(?:\\]|=)`,"i"),Fe=e=>_(/\)\s*to\s*\(([^)]*)\)/i.exec(e)?.[1]??"").some(({text:t})=>H(t).length===1&&B(t).attributes.some(s=>Re.test(s))),je=(e,t)=>Ne(e,t).outside;function Ee(e,t,s){if(s.length===0)return[];let o=`slot${s.length===1?"":"s"} ${s.join(" and ")}`;return Ne(e,t).deep.map(({line:n,words:i})=>({line:n,what:`${i} also reaches the blocks in ${o}, the document's: write each step with > or wrap the rules in @scope ([${G}="${t}"]) to ([${Le}])`}))}function Ne(e,t){let s=Ie(t),o=`[${G}="${t}"]`,n=[],i=[],r=(l,c,p)=>{let f=c.replace(/\s+/g," ").trim();n.push({line:S(e,l),what:p==="beside"?`${f} reaches what stands beside the instance: what it styles has to stand in it`:`${f} reaches outside the instance: start it at ${o}`})},a=(l,c,p=!1,f=!1)=>{for(let h of l){let m=h.prelude.length-h.prelude.trimStart().length,u=h.start+m,y=/^@([\w-]+)\s*/.exec(h.prelude.trim());if(y){let d=y[1].toLowerCase();if(Ae.has(d))a(h.children,c,p,f);else if(d==="page")n.push({line:S(e,u),what:"@page reaches the paper of the whole document: an instance has no page of its own"});else if(d==="scope"){let x=/^@scope\s*\(([^)]*)\)/i.exec(h.prelude.trim())?.[1]??"",L=_(x).map(({text:j})=>({...xe(j,s,c),steps:H(j).length}));x&&L.every(({why:j,steps:Te})=>!j&&Te===1)?a(h.children,Se(L),!1,f||Fe(h.prelude.trim())):r(u,h.prelude,"outside")}continue}let k=_(h.prelude).map(({text:d,start:x})=>{let L=xe(d,s,c,p),j=h.start+x+d.length-d.trimStart().length;return L.why?r(j,d,L.why):L.deep&&!f&&!p&&i.push({line:S(e,j),words:d.replace(/\s+/g," ").trim()}),L});k.some(({why:d})=>d)||a(h.children,Se(k),k.some(d=>d.deep),f)}};return a(Ce(e),null),{outside:n,deep:i}}var w="template.html",N="example.html",O="component.json",Me=new Set(["localStorage","sessionStorage"]),_e=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,Be=/(?: (?:names a file that )?is not in the document's folder|: it is (?:no file of|not in) the document's .*)$|^external resources are not portable: .*$/,Ge=": an example stands in no document: write a picture as a data: address, or draw it from style.css with a file the manifest's assets name",Ke=e=>e.replace(Be,t=>(t.startsWith("external")?t:"")+Ge),T=(e,t)=>I({folder:e},t);function C(e,t){let s=null;try{s=X.readFileSync(E.join(e,t))}catch{return null}return Ue(s)?null:{file:t,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function J(e,t){let s=/^line (\d+): | \(line (\d+)\)/.exec(t);return s?{file:e,line:Number(s[1]??s[2]),what:t.replace(s[0],"")}:{file:e,what:t}}function v(e,t){let s=g.parseJsonText(O,e),o=s.statements[0]?.expression,n=null;for(let i of t.split(".")){let r=o?.properties?.find(({name:a})=>a?.text===i);if(!r)break;n=s.getLineAndCharacterOfPosition(r.getStart(s)).line+1,o=r.initializer}return n}function He(e,{message:t,text:s="",values:o=[]}){let n=/at position (\d+)/.exec(t)?.[1];if(n)return S(e,Number(n));for(let i of[...o.map(String),...s.match(/[a-zA-Z][\w.]*/g)??[]]){let r=v(e,i);if(r)return r}return null}var Je=e=>D(e).map(t=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(t)).filter(Boolean).map(([,t,s,o])=>({line:Number(t),tag:s,why:o}));function qe(e,{file:t,tree:s,html:o}){let n=[],i=Je(o),r=Object.entries(e.parts).filter(([,c])=>c.edit==="text"),a=Object.entries(e.parts).filter(([,c])=>c.edit==="data"),l=(c,p)=>{let f=!1;return A(c,h=>{f||=h===p}),f};for(let c of Y(s,e))for(let[p,f]of r)for(let h of W(c,f.at)){let m=h.sourceCodeLocation?.startLine,u=Q(h).find(d=>ae.has(d.tagName)),y=i.find(d=>d.line===m&&d.tag===h.tagName),k=a.find(([,d])=>W(c,d.at).some(x=>x===h||l(x,h)||l(h,x)))?.[0];k?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and stands in the part ${k}, edited as data, or around it, which is the component's: the editor leaves it read-only: name elements apart`}):u?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text and holds a block, its <${u.tagName}> at line ${u.sourceCodeLocation?.startLine}: a text part holds words and marks alone, and the editor would leave this one read-only: write its \`at\` as what holds the words (${f.at} > ${u.tagName}), or give each block a part of its own`}):y&&n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and the editor would leave it read-only for what it holds: ${y.why}. A text part holds words and marks alone`})}return n}var ee=new RegExp("\\p{Script=Han}","u"),ve=e=>[...e].filter(t=>ee.test(t)).length,Ve={test:e=>{let t=Oe(e);return t!==null&&t<=8}};function We({name:e,words:t}){let s=ve(e.zh),o=t.split(/\s+/).filter(Boolean);return s===0?ee.test(t)&&!o.some(n=>Ve.test(n)):!o.some(n=>Oe(n.toLowerCase())===s)}function Xe({id:e,folder:t,catalog:s,off:o,parts:n}){let i=s.packages.get(e),r=s.problems.get(e)?.problem,a=T(t,O)??"",l=[];r&&l.push({file:O,line:He(a,r),what:U("en",r)}),i?.template===null&&l.push({file:w,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${$}="${e}"> with what a new instance holds`}),l.push(...n);let c=C(t,"writing.md");c&&l.push(c);let p=c||T(t,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery block show has nothing to say of how to write it"}];i&&We(i)&&p.push({file:O,line:v(a,"words")??v(a,"name.zh"),what:ee.test(i.name.zh)?`no word of words spells its whole name ${i.name.zh} in pinyin as an input method composes it, its ${ve(i.name.zh)} Chinese characters a syllable each in one word (as \u65B9\u6848\u6253\u5206 is fangandafen): "/" finds it while those letters are being composed only by such a word. What is counted is how many syllables a word reads as, not which characters they spell`:'its words are Chinese and none of them is pinyin: "/" goes by the letters an input method is composing, so write the pinyin there (\u770B\u677F kanban)'});let f=(()=>{try{return ie(X.readFileSync(E.join(t,"preview.svg")),e)}catch{return null}})();return f&&p.push({file:"preview.svg",what:`it is Gallery's ${f.id} picture, byte for byte (a block made with --recipe keeps its recipe's drawing, which the menu shows beside this block's name): draw this block's own, or delete preview.svg, which the menu does without`}),o&&p.push({file:"gallery.json",what:"the user turned it off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868, which is theirs to change and says nothing of the block: it is checked as if it were on, and the instances of a document show what they hold, read-only, until it is on"}),i&&(l.push(...Ze(i)),p.push(...Ye(i,a))),{title:"manifest",problems:l,notes:p}}function Ye({places:e,parts:t,card:s},o){let n=[];if(e.includes("page"))for(let[i,r]of Object.entries(t))r.edit==="text"&&n.push({file:O,line:v(o,`parts.${i}`),what:`the part ${i} is edited as text, which is read-only on a custom page (no editor runs there): a block whose places hold page keeps what a reader changes there in a data part, with its own field or the card's settings`});else v(o,"card")&&n.push({file:O,line:v(o,"card"),what:`card is for a custom page's board, and its places (${e.join(", ")}) hold no page: nothing reads it`});return n}function Ze(e){if(e.settings.length===0||!e.template)return[];let t=ne(e.template,e.id),s=t?W(t.root,e.parts[F].at):[];if(s.length!==1||(b(s[0],"type")??"").trim().toLowerCase()!=="application/json")return[{file:w,what:`its manifest has settings, and the template holds ${s.length===1?`a <${s[0].tagName}> where`:`${s.length} elements of`} its settings part (${e.parts[F].at}): it is to hold one <script type="application/json">, the values a new card starts with ({} for each setting's default)`}];let o=s[0].childNodes.map(n=>n.value??"").join("").trim();try{let n=JSON.parse(o||"{}");if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("it is no object");return[]}catch(n){return[{file:w,line:s[0].sourceCodeLocation?.startLine,what:`its settings part is not a JSON object (${n.message}): write {} or the values of some of its settings, by key`}]}}function Qe(e){let t=g.createSourceFile("kit.js",e,g.ScriptTarget.Latest,!0,g.ScriptKind.JS),s=[],o=n=>{let i=g.isCallExpression(n)&&g.isPropertyAccessExpression(n.expression)?n.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(t))){let[r]=n.arguments,a=r&&g.isObjectLiteralExpression(r)?r.properties.find(c=>c.name?.getText(t)==="id"):null,l=a&&g.isPropertyAssignment(a)&&g.isStringLiteralLike(a.initializer)?a.initializer.text:null;s.push({id:l,at:n.getStart(t)})}g.forEachChild(n,o)};return o(t),s}function et(e){let t="kit.js";if(!e.files.includes("kit.js"))return{title:t,none:"none: a static block"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"kit.js")??"",n=pe(o);if(n)return{title:t,stops:!0,problems:[{file:t,line:n.line,what:`a browser refuses it: ${n.message}`}]};let i=he(e).map(({line:c,what:p})=>({file:t,line:c,what:p})),r=i.length>0;for(let{name:c,at:p}of re(o,Me))i.push({file:t,line:S(o,p),what:`uses ${c}: an instance keeps what a reader chose with context.state`});let a=Qe(o);for(let{id:c,at:p}of a)c!==null&&c!==e.id&&i.push({file:t,line:S(o,p),what:`it registers ${c}, and this block is ${e.id}`});let l=a.length?[]:[{file:t,what:`no DocKit.component({ id: "${e.id}", mount(host, context) { \u2026 } }) is to be read in it, and a script may make that call in ways reading does not tell: running it says whether it starts one`}];for(let{line:c,code:p,message:f,refused:h}of le(o,{assets:e.assets}))(h?i:l).push({file:t,line:c,what:`TS${p}: ${f}`});return{title:t,stops:r,problems:i.sort((c,p)=>(c.line??0)-(p.line??0)),notes:l}}function tt(e){let t="style.css";if(!e.files.includes("style.css"))return{title:t,none:"none"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"style.css")??"",n=ce(e),i=[...je(o,e.id),...n].map(({line:l,what:c})=>({file:t,line:l,what:c})),r=Object.entries(e.parts??{}).filter(([,{edit:l}])=>l==="flow").map(([l])=>l),a=Ee(o,e.id,r).map(({line:l,what:c})=>({file:t,line:l,what:c}));return{title:t,stops:n.length>0,problems:i.sort((l,c)=>l.line-c.line),notes:a}}function st(e,{tree:t}){let s=null;A(t,a=>{s??=a.tagName==="main"?a:null});let o=Q(s??{}),n=(s?.childNodes??[]).some(a=>a.nodeName==="#text"&&a.value.trim()),[i]=o;if(o.length!==1||n||!Z(i)||b(i,$)!==e)return[{file:w,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${$}="${e}"> or a <section>, and it holds ${o.length===1&&!n?`<${i.tagName}${b(i,$)?` ${$}="${b(i,$)}"`:""}>`:`${o.length} element${o.length===1?"":"s"}${n?" and words":""}`}`}];let r=[];return A({childNodes:[i]},a=>{b(a,"data-block-id")!==void 0&&r.push({file:w,line:a.sourceCodeLocation?.startLine,what:"it writes a data-block-id, which every instance made of it would repeat: leave it out, Gallery gives a block its id"})}),r}var nt=[[e=>b(e,"data-doc-chart")!==void 0,e=>`a chart (<${e.tagName} data-doc-chart="${b(e,"data-doc-chart")}">)`],[e=>e.tagName==="figure",()=>"a card (<figure>)"],[e=>e.tagName==="caption",()=>"a table's <caption>"],[Z,e=>`an instance of ${b(e,$)}`]];function ot(e,t){let s=null;if(A(z(t),i=>{s??=Z(i)&&b(i,$)===e?i:null}),!s)return[];let o=[],n=(i,r)=>{for(let a of Q(i)){let l=nt.find(([c])=>c(a));l?o.push({file:w,line:a.sourceCodeLocation?.startLine,what:`its slot ${b(r,"data-doc-slot")} holds ${l[1](a)}, which a new block from "/" would not have: a menu makes what a template's slot holds as a paste of it makes blocks, and a paste makes no chart, card, table caption or instance of a block. Keep the template's slots to blocks the page makes (paragraphs, headings, lists, quotes, code, a plain table, a disclosure), and show the rest in example.html`}):n(a.tagName==="template"?a.content:a,r)}};for(let i of ze(s))n(i,i);return o}function it(e,{tree:t}){let s=oe(e);if(!s)return[];let[o]=Y(t,e),n=null;return o&&A({childNodes:[o]},i=>{De(i.tagName,i.attrs)&&(n??=i)}),[{file:w,line:(n??o)?.sourceCodeLocation?.startLine,what:U("en",s)}]}function at(e){return[[w,"component-template"],[N,"component-example"]].flatMap(([t,s])=>{let o=T(e,t);if(o===null||!o.trim()||C(e,t))return[];let n=ge(s,o),{text:i}=de(n);return[{file:t,slug:s,written:n,html:i,tree:z(i)}]})}function rt({id:e,folder:t,found:s,pages:o,parts:n}){let i="template.html and example.html",r=[],a=[];for(let h of[w,N]){let m=C(t,h);m?r.push(m):h===w&&!T(t,h)?.trim()&&s.template!==null?r.push({file:h,what:"it is empty"}):h===N&&!o.some(u=>u.file===h)&&r.push({file:h,what:`there is none or it is empty: write an instance as a writer would fill it, a <div ${$}="${e}">; it is what this check runs`})}let l=o.find(h=>h.file===w);l&&r.push(...st(e,l),...ot(e,l.written));let c=o.find(h=>h.file===N);c&&Y(c.tree,s).length===0&&r.push({file:N,what:`it holds no instance of ${e}: a <div ${$}="${e}">`});let p=o.map(({slug:h,written:m,html:u,file:y})=>({file:y,slug:h,written:m,html:u,directory:E.join(t,h),htmlPath:E.join(t,h,"doc.html"),metadata:{title:h,description:h,type:"component"}})),f=fe(p);for(let h of p){for(let m of f.get(h.slug)??[])_e.test(m)||r.push(J(h.file,Ke(m)));for(let m of me(h))a.push(J(h.file,m));for(let m of D(h.html)){let u=J(h.file,`${m} (read-only in the preview)`);n.some(({file:y,line:k})=>y===u.file&&k===u.line)||a.push(u)}}return l&&!r.some(({file:h})=>h===w)&&r.push(...it(s,l)),{title:i,problems:r,notes:a}}function lt(e,t){let s=te(e,void 0,{on:t}),o=R(e,t);if(!s.packages.has(t)&&!s.problems.has(t))return null;se(e,s);let n=s.packages.has(t)&&s.settings.disabled.includes(t),i=s.packages.get(t)??{id:t,folder:o,files:["kit.js","style.css"].filter(c=>X.existsSync(E.join(o,c)))},r=at(o),a=s.packages.has(t)?null:"its manifest does not load",l=a?[]:r.flatMap(c=>qe(i,c));return{found:s.packages.get(t)??null,pages:r,sections:[Xe({id:t,folder:o,catalog:s,off:n,parts:l}),et(i),tt(i),a?{title:"template.html and example.html",skipped:a}:rt({id:t,folder:o,found:i,pages:r,parts:l})]}}var q=({file:e,line:t})=>t?`${e}:${t}`:e;function V({title:e,problems:t=[],notes:s=[],told:o=[],none:n,skipped:i,unverified:r,pictures:a},l){let c=r?`UNVERIFIED ${r}`:i?`not run: ${i}`:n??(t.length?`${t.length} problem${t.length===1?"":"s"}`:`ok${s.length?`, ${s.length} note${s.length===1?"":"s"}`:""}`);return[`${l}. ${e}: ${c}`,...t.map(p=>` FAIL ${q(p)}: ${p.what}`),...s.map(p=>` note ${q(p)}: ${p.what}`),...o.map(p=>` way back ${q(p)}: ${p.what}`),...a?[ct(a)]:[]]}function ct({folder:e,overviews:t,each:s,edited:o=[],asExport:n=[],documents:i=!1}){let r=t.length?`${P(E.join(e,t[0]))}${t.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${P(e)}: `,a=n.length===0?"":n.length===o.length?", each the same picture as the export's at its width: the block draws nothing more where a reader can edit":`, ${n.join(" and ")} the same picture as the export's at its width`,l=o.length?`; and ${o.join(" and ")}, as the editing page draws it (context.canEdit() true)${a}`:"";return` Pictures (none looked at for you; ${i?"each instance under a line naming where it stands in the document":"example.html above the line, template.html below it, each under its name"}): ${r}${s.join(", ")}${l}`}function ht([e,t,s,o]){return e.problems.length?"the manifest":t.stops?"kit.js":s.stops?"style.css":o.skipped||o.problems.length?"template.html and example.html":null}async function Ut(e,t,{documents:s=!1}={}){let o=lt(e,t);o||(console.error(ke(e,t)),process.exit(1)),console.log(`${t}: ${P(R(e,t))}`),o.sections.forEach((p,f)=>console.log(V(p,f+1).join(`
2
+ import{a as ue,b as we,k as ge,v as $e,w as be}from"./chunk-4KUO7R2M.mjs";import{M as ye}from"./chunk-MKIBJTJZ.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-2KAVXMKG.mjs";import{c as R,f as ke}from"./chunk-3XZOA7AH.mjs";import"./chunk-XZCFPKGO.mjs";import{a as P}from"./chunk-JEUK3ZO7.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-6Q7ASAXJ.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{b as de,h as D}from"./chunk-VRPVVMRB.mjs";import"./chunk-7UZUQQ7Q.mjs";import{n as ie}from"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import{a as pe,j as fe,s as me}from"./chunk-USIHBCSW.mjs";import{d as re,e as le,i as I,j as ce,k as he}from"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import{a as g}from"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import{a as z,c as S}from"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import{c as ae}from"./chunk-E7656LR7.mjs";import{a as F,f as te,h as se,j as U,r as ne,s as oe}from"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as Ue}from"node:buffer";import X from"node:fs";import E from"node:path";import{instanceSlots as ze,instancesOf as Y,isInstance as Z,partOf as W}from"../browser/shared/components/index.mjs";import{fewestSyllables as Oe}from"../browser/shared/pinyin.mjs";import{ATTRIBUTE as $,refusedInCopy as De}from"../browser/shared/components/installed.mjs";import{attr as b,elementsOf as Q,walk as A}from"../browser/shared/html-tree.mjs";import{blankedCss as M}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as G,SLOT as Le}from"../browser/shared/components/installed.mjs";var Ae=new Set(["media","supports","container","layer","starting-style"]);function K(e,t){let s=0,o="";for(let n=0;n<e.length;n++){let i=e[n];i==="\\"?n++:o?o=i===o?"":o:i==='"'||i==="'"?o=i:i===")"||i==="]"?s--:(s===0&&t(i,n),(i==="("||i==="[")&&s++)}}function Ce(e){let t=M(e),s=M(e,{strings:!0}),o={children:[]},n=[o],i=0,r=0;for(let a=0;a<t.length;a++){let l=t[a];if(l==="\\")a++;else if(l==="("||l==="[")r++;else if(l===")"||l==="]")r=Math.max(0,r-1);else{if(r>0)continue;if(l==="{"){let c={prelude:s.slice(i,a),start:i,children:[]};n.at(-1).children.push(c),n.push(c),i=a+1}else l==="}"?(n.length>1&&n.pop(),i=a+1):l===";"&&(i=a+1)}}return o.children}function _(e){let t=[],s=0;return K(e,(o,n)=>{o===","&&(t.push({text:e.slice(s,n),start:s}),s=n+1)}),t.push({text:e.slice(s),start:s}),t.filter(({text:o})=>o.trim())}function H(e){let t=[],s=e.trim(),o="",n=0,i=0,r=a=>{(i||a)>n&&t.push({combinator:o,compound:s.slice(n,i||a)}),i=0};return K(s,(a,l)=>{/\s/.test(a)?l===n?n=l+1:i||=l:">+~".includes(a)?(r(l),o=a,n=l+1):i&&(r(l),o=" ",n=l)}),r(s.length),t}function B(e){let t=[],s=-1,o=0,n="";for(let r=0;r<e.length;r++){let a=e[r];a==="\\"?r++:n?n=a===n?"":n:a==='"'||a==="'"?n=a:a==="("?o++:a===")"?o--:a==="["&&o===0?s=r:a==="]"&&o===0&&s>=0&&(t.push(e.slice(s,r+1)),s=-1)}let i=!1;return K(e,r=>{i||=r==="&"}),{attributes:t,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(e)}}var Ie=e=>new RegExp(`^\\[\\s*${G}\\s*=\\s*(["'])${e.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),Pe=e=>M(e).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function xe(e,t,s,o=!1){let n=H(e),i=({compound:f})=>B(f).attributes.some(h=>t.test(h)),r=({compound:f})=>{let{nesting:h,scope:m}=B(f);return!!s&&(h||m)},a=f=>["+","~"].includes(f?.combinator),l=f=>n.slice(f).some(({combinator:h},m)=>(m+f===0?h||" ":h)===" "),c=n.findLastIndex(f=>i(f)||r(f));if(c<0)return!s||Pe(e)?{why:"outside"}:{why:s==="instance"&&a(n[0])?"beside":null,subject:"inside",deep:o||l(0)};let p=i(n[c])||s==="instance";return{why:p&&a(n[c+1])?"beside":null,subject:p&&c===n.length-1?"instance":"inside",deep:!i(n[c])&&o||l(c+1)}}var Se=e=>e.some(({subject:t})=>t==="instance")?"instance":"inside",Re=new RegExp(`^\\[\\s*${Le}\\s*(?:\\]|=)`,"i"),Fe=e=>_(/\)\s*to\s*\(([^)]*)\)/i.exec(e)?.[1]??"").some(({text:t})=>H(t).length===1&&B(t).attributes.some(s=>Re.test(s))),je=(e,t)=>Ne(e,t).outside;function Ee(e,t,s){if(s.length===0)return[];let o=`slot${s.length===1?"":"s"} ${s.join(" and ")}`;return Ne(e,t).deep.map(({line:n,words:i})=>({line:n,what:`${i} also reaches the blocks in ${o}, the document's: write each step with > or wrap the rules in @scope ([${G}="${t}"]) to ([${Le}])`}))}function Ne(e,t){let s=Ie(t),o=`[${G}="${t}"]`,n=[],i=[],r=(l,c,p)=>{let f=c.replace(/\s+/g," ").trim();n.push({line:S(e,l),what:p==="beside"?`${f} reaches what stands beside the instance: what it styles has to stand in it`:`${f} reaches outside the instance: start it at ${o}`})},a=(l,c,p=!1,f=!1)=>{for(let h of l){let m=h.prelude.length-h.prelude.trimStart().length,u=h.start+m,y=/^@([\w-]+)\s*/.exec(h.prelude.trim());if(y){let d=y[1].toLowerCase();if(Ae.has(d))a(h.children,c,p,f);else if(d==="page")n.push({line:S(e,u),what:"@page reaches the paper of the whole document: an instance has no page of its own"});else if(d==="scope"){let x=/^@scope\s*\(([^)]*)\)/i.exec(h.prelude.trim())?.[1]??"",L=_(x).map(({text:j})=>({...xe(j,s,c),steps:H(j).length}));x&&L.every(({why:j,steps:Te})=>!j&&Te===1)?a(h.children,Se(L),!1,f||Fe(h.prelude.trim())):r(u,h.prelude,"outside")}continue}let k=_(h.prelude).map(({text:d,start:x})=>{let L=xe(d,s,c,p),j=h.start+x+d.length-d.trimStart().length;return L.why?r(j,d,L.why):L.deep&&!f&&!p&&i.push({line:S(e,j),words:d.replace(/\s+/g," ").trim()}),L});k.some(({why:d})=>d)||a(h.children,Se(k),k.some(d=>d.deep),f)}};return a(Ce(e),null),{outside:n,deep:i}}var w="template.html",N="example.html",O="component.json",Me=new Set(["localStorage","sessionStorage"]),_e=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,Be=/(?: (?:names a file that )?is not in the document's folder|: it is (?:no file of|not in) the document's .*)$|^external resources are not portable: .*$/,Ge=": an example stands in no document: write a picture as a data: address, or draw it from style.css with a file the manifest's assets name",Ke=e=>e.replace(Be,t=>(t.startsWith("external")?t:"")+Ge),T=(e,t)=>I({folder:e},t);function C(e,t){let s=null;try{s=X.readFileSync(E.join(e,t))}catch{return null}return Ue(s)?null:{file:t,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function J(e,t){let s=/^line (\d+): | \(line (\d+)\)/.exec(t);return s?{file:e,line:Number(s[1]??s[2]),what:t.replace(s[0],"")}:{file:e,what:t}}function v(e,t){let s=g.parseJsonText(O,e),o=s.statements[0]?.expression,n=null;for(let i of t.split(".")){let r=o?.properties?.find(({name:a})=>a?.text===i);if(!r)break;n=s.getLineAndCharacterOfPosition(r.getStart(s)).line+1,o=r.initializer}return n}function He(e,{message:t,text:s="",values:o=[]}){let n=/at position (\d+)/.exec(t)?.[1];if(n)return S(e,Number(n));for(let i of[...o.map(String),...s.match(/[a-zA-Z][\w.]*/g)??[]]){let r=v(e,i);if(r)return r}return null}var Je=e=>D(e).map(t=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(t)).filter(Boolean).map(([,t,s,o])=>({line:Number(t),tag:s,why:o}));function qe(e,{file:t,tree:s,html:o}){let n=[],i=Je(o),r=Object.entries(e.parts).filter(([,c])=>c.edit==="text"),a=Object.entries(e.parts).filter(([,c])=>c.edit==="data"),l=(c,p)=>{let f=!1;return A(c,h=>{f||=h===p}),f};for(let c of Y(s,e))for(let[p,f]of r)for(let h of W(c,f.at)){let m=h.sourceCodeLocation?.startLine,u=Q(h).find(d=>ae.has(d.tagName)),y=i.find(d=>d.line===m&&d.tag===h.tagName),k=a.find(([,d])=>W(c,d.at).some(x=>x===h||l(x,h)||l(h,x)))?.[0];k?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and stands in the part ${k}, edited as data, or around it, which is the component's: the editor leaves it read-only: name elements apart`}):u?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text and holds a block, its <${u.tagName}> at line ${u.sourceCodeLocation?.startLine}: a text part holds words and marks alone, and the editor would leave this one read-only: write its \`at\` as what holds the words (${f.at} > ${u.tagName}), or give each block a part of its own`}):y&&n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and the editor would leave it read-only for what it holds: ${y.why}. A text part holds words and marks alone`})}return n}var ee=new RegExp("\\p{Script=Han}","u"),ve=e=>[...e].filter(t=>ee.test(t)).length,Ve={test:e=>{let t=Oe(e);return t!==null&&t<=8}};function We({name:e,words:t}){let s=ve(e.zh),o=t.split(/\s+/).filter(Boolean);return s===0?ee.test(t)&&!o.some(n=>Ve.test(n)):!o.some(n=>Oe(n.toLowerCase())===s)}function Xe({id:e,folder:t,catalog:s,off:o,parts:n}){let i=s.packages.get(e),r=s.problems.get(e)?.problem,a=T(t,O)??"",l=[];r&&l.push({file:O,line:He(a,r),what:U("en",r)}),i?.template===null&&l.push({file:w,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${$}="${e}"> with what a new instance holds`}),l.push(...n);let c=C(t,"writing.md");c&&l.push(c);let p=c||T(t,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery block show has nothing to say of how to write it"}];i&&We(i)&&p.push({file:O,line:v(a,"words")??v(a,"name.zh"),what:ee.test(i.name.zh)?`no word of words spells its whole name ${i.name.zh} in pinyin as an input method composes it, its ${ve(i.name.zh)} Chinese characters a syllable each in one word (as \u65B9\u6848\u6253\u5206 is fangandafen): "/" finds it while those letters are being composed only by such a word. What is counted is how many syllables a word reads as, not which characters they spell`:'its words are Chinese and none of them is pinyin: "/" goes by the letters an input method is composing, so write the pinyin there (\u770B\u677F kanban)'});let f=(()=>{try{return ie(X.readFileSync(E.join(t,"preview.svg")),e)}catch{return null}})();return f&&p.push({file:"preview.svg",what:`it is Gallery's ${f.id} picture, byte for byte (a block made with --recipe keeps its recipe's drawing, which the menu shows beside this block's name): draw this block's own, or delete preview.svg, which the menu does without`}),o&&p.push({file:"gallery.json",what:"the user turned it off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868, which is theirs to change and says nothing of the block: it is checked as if it were on, and the instances of a document show what they hold, read-only, until it is on"}),i&&(l.push(...Ze(i)),p.push(...Ye(i,a))),{title:"manifest",problems:l,notes:p}}function Ye({places:e,parts:t,card:s},o){let n=[];if(e.includes("page"))for(let[i,r]of Object.entries(t))r.edit==="text"&&n.push({file:O,line:v(o,`parts.${i}`),what:`the part ${i} is edited as text, which is read-only on a custom page (no editor runs there): a block whose places hold page keeps what a reader changes there in a data part, with its own field or the card's settings`});else v(o,"card")&&n.push({file:O,line:v(o,"card"),what:`card is for a custom page's board, and its places (${e.join(", ")}) hold no page: nothing reads it`});return n}function Ze(e){if(e.settings.length===0||!e.template)return[];let t=ne(e.template,e.id),s=t?W(t.root,e.parts[F].at):[];if(s.length!==1||(b(s[0],"type")??"").trim().toLowerCase()!=="application/json")return[{file:w,what:`its manifest has settings, and the template holds ${s.length===1?`a <${s[0].tagName}> where`:`${s.length} elements of`} its settings part (${e.parts[F].at}): it is to hold one <script type="application/json">, the values a new card starts with ({} for each setting's default)`}];let o=s[0].childNodes.map(n=>n.value??"").join("").trim();try{let n=JSON.parse(o||"{}");if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("it is no object");return[]}catch(n){return[{file:w,line:s[0].sourceCodeLocation?.startLine,what:`its settings part is not a JSON object (${n.message}): write {} or the values of some of its settings, by key`}]}}function Qe(e){let t=g.createSourceFile("kit.js",e,g.ScriptTarget.Latest,!0,g.ScriptKind.JS),s=[],o=n=>{let i=g.isCallExpression(n)&&g.isPropertyAccessExpression(n.expression)?n.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(t))){let[r]=n.arguments,a=r&&g.isObjectLiteralExpression(r)?r.properties.find(c=>c.name?.getText(t)==="id"):null,l=a&&g.isPropertyAssignment(a)&&g.isStringLiteralLike(a.initializer)?a.initializer.text:null;s.push({id:l,at:n.getStart(t)})}g.forEachChild(n,o)};return o(t),s}function et(e){let t="kit.js";if(!e.files.includes("kit.js"))return{title:t,none:"none: a static block"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"kit.js")??"",n=pe(o);if(n)return{title:t,stops:!0,problems:[{file:t,line:n.line,what:`a browser refuses it: ${n.message}`}]};let i=he(e).map(({line:c,what:p})=>({file:t,line:c,what:p})),r=i.length>0;for(let{name:c,at:p}of re(o,Me))i.push({file:t,line:S(o,p),what:`uses ${c}: an instance keeps what a reader chose with context.state`});let a=Qe(o);for(let{id:c,at:p}of a)c!==null&&c!==e.id&&i.push({file:t,line:S(o,p),what:`it registers ${c}, and this block is ${e.id}`});let l=a.length?[]:[{file:t,what:`no DocKit.component({ id: "${e.id}", mount(host, context) { \u2026 } }) is to be read in it, and a script may make that call in ways reading does not tell: running it says whether it starts one`}];for(let{line:c,code:p,message:f,refused:h}of le(o,{assets:e.assets}))(h?i:l).push({file:t,line:c,what:`TS${p}: ${f}`});return{title:t,stops:r,problems:i.sort((c,p)=>(c.line??0)-(p.line??0)),notes:l}}function tt(e){let t="style.css";if(!e.files.includes("style.css"))return{title:t,none:"none"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"style.css")??"",n=ce(e),i=[...je(o,e.id),...n].map(({line:l,what:c})=>({file:t,line:l,what:c})),r=Object.entries(e.parts??{}).filter(([,{edit:l}])=>l==="flow").map(([l])=>l),a=Ee(o,e.id,r).map(({line:l,what:c})=>({file:t,line:l,what:c}));return{title:t,stops:n.length>0,problems:i.sort((l,c)=>l.line-c.line),notes:a}}function st(e,{tree:t}){let s=null;A(t,a=>{s??=a.tagName==="main"?a:null});let o=Q(s??{}),n=(s?.childNodes??[]).some(a=>a.nodeName==="#text"&&a.value.trim()),[i]=o;if(o.length!==1||n||!Z(i)||b(i,$)!==e)return[{file:w,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${$}="${e}"> or a <section>, and it holds ${o.length===1&&!n?`<${i.tagName}${b(i,$)?` ${$}="${b(i,$)}"`:""}>`:`${o.length} element${o.length===1?"":"s"}${n?" and words":""}`}`}];let r=[];return A({childNodes:[i]},a=>{b(a,"data-block-id")!==void 0&&r.push({file:w,line:a.sourceCodeLocation?.startLine,what:"it writes a data-block-id, which every instance made of it would repeat: leave it out, Gallery gives a block its id"})}),r}var nt=[[e=>b(e,"data-doc-chart")!==void 0,e=>`a chart (<${e.tagName} data-doc-chart="${b(e,"data-doc-chart")}">)`],[e=>e.tagName==="figure",()=>"a card (<figure>)"],[e=>e.tagName==="caption",()=>"a table's <caption>"],[Z,e=>`an instance of ${b(e,$)}`]];function ot(e,t){let s=null;if(A(z(t),i=>{s??=Z(i)&&b(i,$)===e?i:null}),!s)return[];let o=[],n=(i,r)=>{for(let a of Q(i)){let l=nt.find(([c])=>c(a));l?o.push({file:w,line:a.sourceCodeLocation?.startLine,what:`its slot ${b(r,"data-doc-slot")} holds ${l[1](a)}, which a new block from "/" would not have: a menu makes what a template's slot holds as a paste of it makes blocks, and a paste makes no chart, card, table caption or instance of a block. Keep the template's slots to blocks the page makes (paragraphs, headings, lists, quotes, code, a plain table, a disclosure), and show the rest in example.html`}):n(a.tagName==="template"?a.content:a,r)}};for(let i of ze(s))n(i,i);return o}function it(e,{tree:t}){let s=oe(e);if(!s)return[];let[o]=Y(t,e),n=null;return o&&A({childNodes:[o]},i=>{De(i.tagName,i.attrs)&&(n??=i)}),[{file:w,line:(n??o)?.sourceCodeLocation?.startLine,what:U("en",s)}]}function at(e){return[[w,"component-template"],[N,"component-example"]].flatMap(([t,s])=>{let o=T(e,t);if(o===null||!o.trim()||C(e,t))return[];let n=ge(s,o),{text:i}=de(n);return[{file:t,slug:s,written:n,html:i,tree:z(i)}]})}function rt({id:e,folder:t,found:s,pages:o,parts:n}){let i="template.html and example.html",r=[],a=[];for(let h of[w,N]){let m=C(t,h);m?r.push(m):h===w&&!T(t,h)?.trim()&&s.template!==null?r.push({file:h,what:"it is empty"}):h===N&&!o.some(u=>u.file===h)&&r.push({file:h,what:`there is none or it is empty: write an instance as a writer would fill it, a <div ${$}="${e}">; it is what this check runs`})}let l=o.find(h=>h.file===w);l&&r.push(...st(e,l),...ot(e,l.written));let c=o.find(h=>h.file===N);c&&Y(c.tree,s).length===0&&r.push({file:N,what:`it holds no instance of ${e}: a <div ${$}="${e}">`});let p=o.map(({slug:h,written:m,html:u,file:y})=>({file:y,slug:h,written:m,html:u,directory:E.join(t,h),htmlPath:E.join(t,h,"doc.html"),metadata:{title:h,description:h,type:"component"}})),f=fe(p);for(let h of p){for(let m of f.get(h.slug)??[])_e.test(m)||r.push(J(h.file,Ke(m)));for(let m of me(h))a.push(J(h.file,m));for(let m of D(h.html)){let u=J(h.file,`${m} (read-only in the preview)`);n.some(({file:y,line:k})=>y===u.file&&k===u.line)||a.push(u)}}return l&&!r.some(({file:h})=>h===w)&&r.push(...it(s,l)),{title:i,problems:r,notes:a}}function lt(e,t){let s=te(e,void 0,{on:t}),o=R(e,t);if(!s.packages.has(t)&&!s.problems.has(t))return null;se(e,s);let n=s.packages.has(t)&&s.settings.disabled.includes(t),i=s.packages.get(t)??{id:t,folder:o,files:["kit.js","style.css"].filter(c=>X.existsSync(E.join(o,c)))},r=at(o),a=s.packages.has(t)?null:"its manifest does not load",l=a?[]:r.flatMap(c=>qe(i,c));return{found:s.packages.get(t)??null,pages:r,sections:[Xe({id:t,folder:o,catalog:s,off:n,parts:l}),et(i),tt(i),a?{title:"template.html and example.html",skipped:a}:rt({id:t,folder:o,found:i,pages:r,parts:l})]}}var q=({file:e,line:t})=>t?`${e}:${t}`:e;function V({title:e,problems:t=[],notes:s=[],told:o=[],none:n,skipped:i,unverified:r,pictures:a},l){let c=r?`UNVERIFIED ${r}`:i?`not run: ${i}`:n??(t.length?`${t.length} problem${t.length===1?"":"s"}`:`ok${s.length?`, ${s.length} note${s.length===1?"":"s"}`:""}`);return[`${l}. ${e}: ${c}`,...t.map(p=>` FAIL ${q(p)}: ${p.what}`),...s.map(p=>` note ${q(p)}: ${p.what}`),...o.map(p=>` way back ${q(p)}: ${p.what}`),...a?[ct(a)]:[]]}function ct({folder:e,overviews:t,each:s,edited:o=[],asExport:n=[],documents:i=!1}){let r=t.length?`${P(E.join(e,t[0]))}${t.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${P(e)}: `,a=n.length===0?"":n.length===o.length?", each the same picture as the export's at its width: the block draws nothing more where a reader can edit":`, ${n.join(" and ")} the same picture as the export's at its width`,l=o.length?`; and ${o.join(" and ")}, as the editing page draws it (context.canEdit() true)${a}`:"";return` Pictures (none looked at for you; ${i?"each instance under a line naming where it stands in the document":"example.html above the line, template.html below it, each under its name"}): ${r}${s.join(", ")}${l}`}function ht([e,t,s,o]){return e.problems.length?"the manifest":t.stops?"kit.js":s.stops?"style.css":o.skipped||o.problems.length?"template.html and example.html":null}async function Ut(e,t,{documents:s=!1}={}){let o=lt(e,t);o||(console.error(ke(e,t)),process.exit(1)),console.log(`${t}: ${P(R(e,t))}`),o.sections.forEach((p,f)=>console.log(V(p,f+1).join(`
3
3
  `)));let n=ht(o.sections),i=R(e,t),r=n?{title:ue,skipped:`${n} first`}:await $e(e,o.found,{example:T(i,N),template:T(i,w)});console.log(V(r,5).join(`
4
4
  `));let a=s?n?[{title:we(),skipped:`${n} first`}]:await be(e,o.found):[];a.forEach((p,f)=>console.log(V(p,6+f).join(`
5
5
  `)));let l=ye([r,...a].filter(({pictures:p})=>p).map(({pictures:{folder:p,overviews:f,each:h,edited:m=[]}})=>({folder:p,files:[...f,...h,...m].map(u=>E.join(p,u))})));l&&console.log(l);let c=[...o.sections,r,...a].reduce((p,{problems:f=[]})=>p+f.length,0);c?(console.log(`FAIL ${t}: ${c} problem${c===1?"":"s"}`),process.exitCode=1):r.unverified||a.some(({unverified:p})=>p)?(console.log(`UNVERIFIED ${t}: the rest passed, and no browser ran ${r.unverified?"it":"the documents' instances"}: export a document that holds it and open that in Chrome or Edge.`),process.exitCode=3):console.log(`OK ${t}${s?" and its instances in the workspace's documents":""}`)}export{Ut as checkCommand,Oe as fewestSyllables,lt as readSections,V as sectionLines,We as wantsPinyin};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-S2Y7VI4H.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-2GKGEVMR.mjs";import"./chunk-LE44MD3O.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{g as GESTURES,d as addName,b as blockNamed,i as keyOf,f as missingSaid,c as packageFolder,a as packageNamed,h as pairsOf,j as run,e as shallowSaid};
2
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-3XZOA7AH.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as GESTURES,d as addName,b as blockNamed,i as keyOf,f as missingSaid,c as packageFolder,a as packageNamed,h as pairsOf,j as run,e as shallowSaid};
@@ -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{a as u}from"./chunk-JXLSHVJ2.mjs";import l from"node:fs/promises";import p from"node:path";import{escapeMarkup as g}from"../browser/shared/escape.mjs";import{sha256 as b}from"../browser/shared/files.mjs";import{reportsDirectory as E,starterDirectory as y}from"../browser/shared/paths.mjs";import{listReportSlugs as T,slugPattern as S}from"../browser/shared/reports.mjs";import{documentDirectory as N,documentFiles as $,layoutOf as O,slugTaken as P}from"../browser/shared/workspace.mjs";async function j(t,c){if(!S.test(t))throw new Error(`A document's folder name must be lowercase kebab-case: ${t}`);let n=N(t,c),{html:r,json:i}=$(n),[m,o]=[p.basename(r),p.basename(i)],e,f;try{[e,f]=await Promise.all([l.readFile(r),l.readFile(i,"utf8")])}catch(s){if(s.code!=="ENOENT")throw s;let h=await l.stat(n).then(()=>!0,()=>!1);throw new Error(h?`${n} needs both ${m} and ${o}.`:`${n} does not exist.`)}let a;try{a=JSON.parse(f)}catch(s){throw new Error(`${o} is not valid JSON: ${s.message}`)}if(typeof a.title!="string")throw new Error(`${o} is missing a title.`);for(let s of["description","type"])if(typeof a[s]!="string"||a[s].trim()==="")throw new Error(`${o} is missing a non-empty ${s}.`);if(a.source!==void 0&&typeof a.source!="string")throw new Error(`${o} source must be a string when given.`);return{slug:t,directory:n,htmlPath:r,metadataPath:i,html:e.toString("utf8"),fileSha256:b(e),metadata:a}}async function z(t=[],{directory:c=E,prepare:n=null}={}){let r=t.length>0?[...new Set(t)]:await T(c);if(r.length===0)throw new Error(`No documents in ${p.resolve(c)} yet: gallery new <slug> "<title>" makes one.`);let i=[],m=new Map;for(let o of r)try{let e=await j(o,c);n&&([e.written,e.html]=[u(e.html),n(e)]),i.push(e)}catch(e){m.set(o,[e.message])}return{reports:i,failures:m}}var v=/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,F=/\n[ \t]*<!-- Starter content:[^\n]*-->\n[ \t]*<section\b[^>]*\sdata-doc-placeholder\b[\s\S]*?<\/section>/;async function M(t,c,n,{directory:r=E,blank:i=!1,lang:m=null,page:o=!1}={}){if(!S.test(t))throw new Error("Slug must be lowercase kebab-case.");if(P(t,r))throw Object.assign(new Error(`"${t}" is taken in ${p.resolve(r)}`),{code:"EEXIST"});let e=o?O(r).preferencesPage:p.resolve(r),f=p.join(e,t),{html:a,metadata:s}=await R(t,c,n,{blank:i,lang:m});await l.mkdir(e,{recursive:!0}),await l.mkdir(f,{recursive:!1});let h=$(f);return await Promise.all([l.writeFile(h.html,a),l.writeFile(h.json,`${JSON.stringify(s,null,2)}
2
+ import{a as u}from"./chunk-UMHUSOPJ.mjs";import l from"node:fs/promises";import p from"node:path";import{escapeMarkup as g}from"../browser/shared/escape.mjs";import{sha256 as b}from"../browser/shared/files.mjs";import{reportsDirectory as E,starterDirectory as y}from"../browser/shared/paths.mjs";import{listReportSlugs as T,slugPattern as S}from"../browser/shared/reports.mjs";import{documentDirectory as N,documentFiles as $,layoutOf as O,slugTaken as P}from"../browser/shared/workspace.mjs";async function j(t,c){if(!S.test(t))throw new Error(`A document's folder name must be lowercase kebab-case: ${t}`);let n=N(t,c),{html:r,json:i}=$(n),[m,o]=[p.basename(r),p.basename(i)],e,f;try{[e,f]=await Promise.all([l.readFile(r),l.readFile(i,"utf8")])}catch(s){if(s.code!=="ENOENT")throw s;let h=await l.stat(n).then(()=>!0,()=>!1);throw new Error(h?`${n} needs both ${m} and ${o}.`:`${n} does not exist.`)}let a;try{a=JSON.parse(f)}catch(s){throw new Error(`${o} is not valid JSON: ${s.message}`)}if(typeof a.title!="string")throw new Error(`${o} is missing a title.`);for(let s of["description","type"])if(typeof a[s]!="string"||a[s].trim()==="")throw new Error(`${o} is missing a non-empty ${s}.`);if(a.source!==void 0&&typeof a.source!="string")throw new Error(`${o} source must be a string when given.`);return{slug:t,directory:n,htmlPath:r,metadataPath:i,html:e.toString("utf8"),fileSha256:b(e),metadata:a}}async function z(t=[],{directory:c=E,prepare:n=null}={}){let r=t.length>0?[...new Set(t)]:await T(c);if(r.length===0)throw new Error(`No documents in ${p.resolve(c)} yet: gallery new <slug> "<title>" makes one.`);let i=[],m=new Map;for(let o of r)try{let e=await j(o,c);n&&([e.written,e.html]=[u(e.html),n(e)]),i.push(e)}catch(e){m.set(o,[e.message])}return{reports:i,failures:m}}var v=/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,F=/\n[ \t]*<!-- Starter content:[^\n]*-->\n[ \t]*<section\b[^>]*\sdata-doc-placeholder\b[\s\S]*?<\/section>/;async function M(t,c,n,{directory:r=E,blank:i=!1,lang:m=null,page:o=!1}={}){if(!S.test(t))throw new Error("Slug must be lowercase kebab-case.");if(P(t,r))throw Object.assign(new Error(`"${t}" is taken in ${p.resolve(r)}`),{code:"EEXIST"});let e=o?O(r).preferencesPage:p.resolve(r),f=p.join(e,t),{html:a,metadata:s}=await R(t,c,n,{blank:i,lang:m});await l.mkdir(e,{recursive:!0}),await l.mkdir(f,{recursive:!1});let h=$(f);return await Promise.all([l.writeFile(h.html,a),l.writeFile(h.json,`${JSON.stringify(s,null,2)}
3
3
  `)]),{slug:t,directory:f,metadata:s}}async function R(t,c,n,{blank:r=!1,lang:i=null}={}){let m=w=>g(w).replaceAll("'","&#39;"),[o,e]=await Promise.all([l.readFile(p.join(y,"doc.html"),"utf8"),l.readFile(p.join(y,"doc.json"),"utf8")]),f={...JSON.parse(e),title:c,description:n},a=r?o.replace(F,`
4
4
  <p></p>`):o;if(r&&a===o)throw new Error("The starter's placeholder section was not found.");let s=typeof i=="string"&&v.test(i)?a.replace(/(<html\b[^>]*\slang=")[^"]*"/,(w,d)=>`${d}${i}"`):a,h={SLUG:t,TITLE:m(c)};return{html:s.replace(/__REPORT_(SLUG|TITLE)__/g,(w,d)=>h[d]),metadata:f}}export{z as a,M as b,R 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{c as O,d as P,e as b,l as C}from"./chunk-JJNRIFND.mjs";import{a as q}from"./chunk-ASAXY2DJ.mjs";import{a as u,f as S,g as w,i as E,j as I,k as H}from"./chunk-YPPJVDQI.mjs";import{a as h,b as R}from"./chunk-JEUK3ZO7.mjs";import{b as D,f as L,g as T}from"./chunk-4OZWXZE5.mjs";import{b as N}from"./chunk-NWRZXELO.mjs";import{existsSync as g}from"node:fs";import i from"node:path";import{reportsDirectory as c}from"../browser/shared/paths.mjs";import{idHolder as z,isDocSlug as B,keptName as G,layoutOf as A,listTrash as J}from"../browser/shared/workspace.mjs";import{parentIn as K}from"../browser/shared/outline.mjs";import{joinDefaultTree as Q,joinedLine as V}from"../browser/shared/drafts.mjs";var W="\u65B0\u6587\u6863";async function F(t,n=c){if(G(t))return`"${t}" is a name the workspace keeps for itself: choose another slug.`;if(g(i.join(A(n).preferencesPage,t)))return`"${t}" is the \u5199\u4F5C\u504F\u597D page's slug: choose another slug.`;if(g(i.join(A(n).customPages,t)))return`"${t}" is a custom page's slug (documents and custom pages share one set of names: gallery page list lists them): choose another slug.`;if(g(i.join(n,t)))return`Document already exists: ${h(i.join(n,t))}`;if((await J(n)).some(r=>r.slug===t))return`"${t}" is the slug of something in the trash: choose another slug.`;if(B(t)){let r=await z(t,n);if(r)return`"${t}" would have the page id (${t.slice(4)}) of "${r}" in this workspace, and two documents may not share an address: choose another slug.`}return null}async function fe(t){let{positional:n,options:r,values:U}=L({options:["--no-preview","--no-browser","--first"],values:["--under","--after"],argv:t}),[e,y,$=W]=n;if(n.length<2||n.length>3||!e||!y?.trim()||!$.trim())throw new D("Name the slug and the title (then a description, if you choose one), each quoted when it has spaces.");T(e);let s=H(U,r,{top:!1}),x=await F(e);x&&(console.error(x),process.exit(1));let M=s.under!==void 0||s.after!==void 0||s.first,l=null;if(M){let o=await u(),a=async(X,_)=>{let p=await S(X,_,o);return p.refused&&(console.error(`${p.refused} Nothing made.`),process.exit(1)),p.slug},f=s.under!==void 0?await a(s.under,"--under"):void 0,d=s.after!==void 0?await a(s.after,"--after"):null;d!==null&&f!==void 0&&K(o.children,d)!==f&&(console.error(`${w(o,e,"level",{parent:f,after:d})} Nothing made.`),process.exit(1)),l={parent:f,after:d,first:s.first}}try{await N(e,y,$)}catch(o){if(o.code!=="EEXIST")throw o;console.error(await F(e)??`Document already exists: ${h(i.join(c,e))}`),process.exit(1)}if(await import("./chunk-TDWJKOLN.mjs").then(({noteNew:o})=>o(e)),console.log(`Created ${h(i.join(c,e,"doc.html"))} and doc.json`),l){let o=await E(e,l),a=await u();o.ok?console.log(`Placed it ${I(a,o)}.`):(console.log(`Not placed (${w(a,e,o.reason,{...l,message:o.message})}): it is at the top level, last; gallery move ${e} puts it where it goes.`),process.exitCode=1)}let v=V(await Q(c,e));v&&console.log(v);for(let o of await R())console.log(o);let j=q(c);j&&console.log(j);let m=await C(e,{skipped:b(r),command:`gallery new ${e}`});console.log(O(m,"replace the starter section with the document's skeleton (each section's heading) as soon as you can outline it, then write it a section at a time, as ordinary HTML, so that the user watches it grow (gallery check fails while the starter section remains).")),console.log(`Hand in: gallery export ${e}, then gallery qa ${e}`);let k=await P(m,r);k&&console.log(k);for(let o of m)console.log(o)}export{W as a,F as b,fe as c};
2
+ import{c as O,d as P,e as b,l as C}from"./chunk-BN7M3IN7.mjs";import{a as q}from"./chunk-ZFGMJVJC.mjs";import{a as u,f as S,g as w,i as E,j as I,k as H}from"./chunk-GMJD7ID3.mjs";import{a as h,b as R}from"./chunk-JEUK3ZO7.mjs";import{b as D,f as L,g as T}from"./chunk-4OZWXZE5.mjs";import{b as N}from"./chunk-PAREWQGB.mjs";import{existsSync as g}from"node:fs";import i from"node:path";import{reportsDirectory as c}from"../browser/shared/paths.mjs";import{idHolder as z,isDocSlug as B,keptName as G,layoutOf as A,listTrash as J}from"../browser/shared/workspace.mjs";import{parentIn as K}from"../browser/shared/outline.mjs";import{joinDefaultTree as Q,joinedLine as V}from"../browser/shared/drafts.mjs";var W="\u65B0\u6587\u6863";async function F(t,n=c){if(G(t))return`"${t}" is a name the workspace keeps for itself: choose another slug.`;if(g(i.join(A(n).preferencesPage,t)))return`"${t}" is the \u5199\u4F5C\u504F\u597D page's slug: choose another slug.`;if(g(i.join(A(n).customPages,t)))return`"${t}" is a custom page's slug (documents and custom pages share one set of names: gallery page list lists them): choose another slug.`;if(g(i.join(n,t)))return`Document already exists: ${h(i.join(n,t))}`;if((await J(n)).some(r=>r.slug===t))return`"${t}" is the slug of something in the trash: choose another slug.`;if(B(t)){let r=await z(t,n);if(r)return`"${t}" would have the page id (${t.slice(4)}) of "${r}" in this workspace, and two documents may not share an address: choose another slug.`}return null}async function fe(t){let{positional:n,options:r,values:U}=L({options:["--no-preview","--no-browser","--first"],values:["--under","--after"],argv:t}),[e,y,$=W]=n;if(n.length<2||n.length>3||!e||!y?.trim()||!$.trim())throw new D("Name the slug and the title (then a description, if you choose one), each quoted when it has spaces.");T(e);let s=H(U,r,{top:!1}),x=await F(e);x&&(console.error(x),process.exit(1));let M=s.under!==void 0||s.after!==void 0||s.first,l=null;if(M){let o=await u(),a=async(X,_)=>{let p=await S(X,_,o);return p.refused&&(console.error(`${p.refused} Nothing made.`),process.exit(1)),p.slug},f=s.under!==void 0?await a(s.under,"--under"):void 0,d=s.after!==void 0?await a(s.after,"--after"):null;d!==null&&f!==void 0&&K(o.children,d)!==f&&(console.error(`${w(o,e,"level",{parent:f,after:d})} Nothing made.`),process.exit(1)),l={parent:f,after:d,first:s.first}}try{await N(e,y,$)}catch(o){if(o.code!=="EEXIST")throw o;console.error(await F(e)??`Document already exists: ${h(i.join(c,e))}`),process.exit(1)}if(await import("./chunk-5XV3YYLG.mjs").then(({noteNew:o})=>o(e)),console.log(`Created ${h(i.join(c,e,"doc.html"))} and doc.json`),l){let o=await E(e,l),a=await u();o.ok?console.log(`Placed it ${I(a,o)}.`):(console.log(`Not placed (${w(a,e,o.reason,{...l,message:o.message})}): it is at the top level, last; gallery move ${e} puts it where it goes.`),process.exitCode=1)}let v=V(await Q(c,e));v&&console.log(v);for(let o of await R())console.log(o);let j=q(c);j&&console.log(j);let m=await C(e,{skipped:b(r),command:`gallery new ${e}`});console.log(O(m,"replace the starter section with the document's skeleton (each section's heading) as soon as you can outline it, then write it a section at a time, as ordinary HTML, so that the user watches it grow (gallery check fails while the starter section remains).")),console.log(`Hand in: gallery export ${e}, then gallery qa ${e}`);let k=await P(m,r);k&&console.log(k);for(let o of m)console.log(o)}export{W as a,F as b,fe as c};