@heycys/gallery 0.2.2 → 0.2.4
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.
- package/README.md +1 -1
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/assets/preview/runtime.js +156 -0
- package/assets/preview/shell.html +107 -0
- package/assets/writing-preferences.md +1 -1
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/page/annotate/card.mjs +6 -0
- package/browser/editor/page/annotate/index.mjs +22 -2
- package/browser/editor/page/columns/index.mjs +1 -1
- package/browser/editor/page/conflicts.mjs +1 -1
- package/browser/editor/page/drag/index.mjs +1 -1
- package/browser/editor/page/editor.mjs +43 -5
- package/browser/editor/page/focus.mjs +104 -0
- package/browser/editor/page/handle/index.mjs +14 -2
- package/browser/editor/page/links/index.mjs +2 -2
- package/browser/editor/page/quiet.mjs +3 -3
- package/browser/editor/page/resize/index.mjs +1 -1
- package/browser/editor/page/session.mjs +4 -1
- package/browser/editor/page/ui.mjs +1 -1
- package/browser/shared/annotations.mjs +22 -3
- package/browser/shared/block-packs.mjs +13 -4
- package/browser/shared/document-look.mjs +14 -0
- package/browser/shared/drafts.mjs +1 -1
- package/browser/shared/extension-manifest.mjs +40 -12
- package/browser/shared/favorite-merge.mjs +17 -0
- package/browser/shared/favorites.mjs +77 -0
- package/browser/shared/i18n/en.mjs +123 -24
- package/browser/shared/outline-ops.mjs +109 -0
- package/browser/shared/outline.mjs +6 -0
- package/browser/shared/pages.mjs +20 -8
- package/browser/shared/paths.mjs +5 -2
- package/browser/shared/preference-documents.mjs +137 -0
- package/browser/shared/presence.mjs +94 -0
- package/browser/shared/preview-server.mjs +8 -5
- package/browser/shared/qa-levels.mjs +9 -1
- package/browser/shared/session.mjs +4 -0
- package/browser/shared/shipped-blocks.mjs +22 -4
- package/browser/shared/startup.mjs +101 -0
- package/browser/shared/workspace-address.mjs +3 -0
- package/browser/shared/workspace-columns.mjs +1 -1
- package/browser/shared/workspace-look.mjs +21 -8
- package/browser/shared/workspace-registry.mjs +6 -3
- package/browser/shared/workspace.mjs +37 -10
- package/browser/shared/writing-preferences.mjs +2 -42
- package/dist/chunk-25LYSMAE.mjs +2 -0
- package/dist/chunk-2I6ZVC5O.mjs +2 -0
- package/dist/{chunk-M4NRDYI5.mjs → chunk-2MYTOOP6.mjs} +1 -1
- package/dist/chunk-2VNENLER.mjs +2 -0
- package/dist/chunk-3FERXZF5.mjs +4 -0
- package/dist/chunk-3M6SBBGU.mjs +2 -0
- package/dist/chunk-3VCAAF34.mjs +2 -0
- package/dist/{chunk-JXXHAXYH.mjs → chunk-3ZTRLGSA.mjs} +1 -1
- package/dist/chunk-4FRA5AUE.mjs +2 -0
- package/dist/chunk-4LR2QEC2.mjs +4 -0
- package/dist/chunk-56SVJENP.mjs +966 -0
- package/dist/chunk-5CQISL2G.mjs +4 -0
- package/dist/{chunk-RRKJMHNX.mjs → chunk-5I5ZDDWC.mjs} +5 -5
- package/dist/chunk-5IHDLEB4.mjs +10 -0
- package/dist/chunk-5LRDMV7O.mjs +2 -0
- package/dist/chunk-5MVUYRKG.mjs +5 -0
- package/dist/chunk-5TLLIZT7.mjs +2 -0
- package/dist/chunk-6ILJWFYW.mjs +4 -0
- package/dist/chunk-6N25CJ6Y.mjs +3 -0
- package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-7DTINW6U.mjs} +2 -2
- package/dist/chunk-7KWAGKIK.mjs +2 -0
- package/dist/chunk-7WNUOAFK.mjs +2 -0
- package/dist/chunk-7XCRW5RC.mjs +2 -0
- package/dist/{chunk-ERE2BXYV.mjs → chunk-7XSDTILF.mjs} +1 -1
- package/dist/chunk-ABKYFOVR.mjs +2 -0
- package/dist/chunk-AMUF7PUN.mjs +2 -0
- package/dist/{chunk-PLB7L22J.mjs → chunk-B2EIMERT.mjs} +2 -2
- package/dist/{chunk-QNECWMGR.mjs → chunk-B45IAAU6.mjs} +1 -1
- package/dist/chunk-B6RAGF4R.mjs +2 -0
- package/dist/chunk-BSJKFE7I.mjs +4 -0
- package/dist/chunk-C72EEVLK.mjs +2 -0
- package/dist/chunk-CRAUKZ23.mjs +4 -0
- package/dist/chunk-F4CT35KL.mjs +2 -0
- package/dist/chunk-F63BNJLG.mjs +2 -0
- package/dist/chunk-FBKUPS44.mjs +2 -0
- package/dist/chunk-FL52ZL5Z.mjs +15 -0
- package/dist/chunk-FOZCU4VW.mjs +2 -0
- package/dist/chunk-G5HV7BC3.mjs +2 -0
- package/dist/{chunk-ERLAIBOA.mjs → chunk-GB5SOYQJ.mjs} +2 -2
- package/dist/chunk-GN3SG3IF.mjs +2 -0
- package/dist/{chunk-6QWQXHAV.mjs → chunk-HFTBVEZK.mjs} +1 -1
- package/dist/chunk-IOW5HLRK.mjs +2 -0
- package/dist/chunk-IQ3GJNTI.mjs +6 -0
- package/dist/chunk-K6SPFBUJ.mjs +2 -0
- package/dist/chunk-K7Y7SPTS.mjs +2 -0
- package/dist/chunk-L2IJCEUH.mjs +2 -0
- package/dist/{chunk-GPIWQ4X4.mjs → chunk-L3VT6LM4.mjs} +1 -1
- package/dist/chunk-L4WLQYFC.mjs +5 -0
- package/dist/{chunk-FFV733MA.mjs → chunk-LAMCAGK6.mjs} +1 -1
- package/dist/chunk-LHGKPMTI.mjs +2 -0
- package/dist/chunk-LJZIYVNA.mjs +3 -0
- package/dist/chunk-LSVCTLS2.mjs +2 -0
- package/dist/chunk-LZY74XTP.mjs +2 -0
- package/dist/chunk-MC4LRSVH.mjs +2 -0
- package/dist/chunk-MCEXN4G5.mjs +2 -0
- package/dist/chunk-MTLAOCFF.mjs +181 -0
- package/dist/chunk-MZ66LN3B.mjs +2 -0
- package/dist/chunk-N5QWJRRI.mjs +2 -0
- package/dist/chunk-NF4MMOUB.mjs +2 -0
- package/dist/chunk-NHJYAJ73.mjs +3 -0
- package/dist/chunk-NRSD7SVY.mjs +2 -0
- package/dist/chunk-NT23I4XW.mjs +2 -0
- package/dist/chunk-NUALABIS.mjs +3 -0
- package/dist/chunk-NW6LAU22.mjs +2 -0
- package/dist/chunk-NWWHDGKF.mjs +5 -0
- package/dist/chunk-OFRCVMSJ.mjs +2 -0
- package/dist/chunk-OKVQQ3CX.mjs +4 -0
- package/dist/chunk-OM24O4KR.mjs +8 -0
- package/dist/{chunk-4B2TB5K2.mjs → chunk-PBMOC7KA.mjs} +2 -2
- package/dist/chunk-PVTCP43W.mjs +2 -0
- package/dist/chunk-Q62HZAJS.mjs +2 -0
- package/dist/chunk-QBJWIR3Q.mjs +2 -0
- package/dist/chunk-QDSEZX7Z.mjs +6 -0
- package/dist/chunk-QR4V4A2Z.mjs +15 -0
- package/dist/{chunk-QVGOPHOF.mjs → chunk-QRLVVZ3R.mjs} +1 -1
- package/dist/chunk-QW3QG67J.mjs +2 -0
- package/dist/chunk-R2T2EVWY.mjs +8 -0
- package/dist/{chunk-GJJRBGMY.mjs → chunk-R5RERE6G.mjs} +1 -1
- package/dist/chunk-RFHEWT3Y.mjs +5 -0
- package/dist/chunk-RS2Z2JQP.mjs +2 -0
- package/dist/chunk-S6YEC4GE.mjs +16 -0
- package/dist/chunk-SHZLMGGW.mjs +2 -0
- package/dist/chunk-TALJQM2O.mjs +2 -0
- package/dist/chunk-TLNJWEFY.mjs +22 -0
- package/dist/{chunk-6Q7ASAXJ.mjs → chunk-TQZU7D7C.mjs} +1 -1
- package/dist/chunk-UTKNWYBA.mjs +2 -0
- package/dist/chunk-V3TM3TEN.mjs +2 -0
- package/dist/chunk-V3XROSP5.mjs +7 -0
- package/dist/{chunk-6QBHU4DF.mjs → chunk-V5JTW2LH.mjs} +1 -1
- package/dist/chunk-VAXLSISW.mjs +4 -0
- package/dist/chunk-VBHI3RG6.mjs +2 -0
- package/dist/{chunk-6L6V7YR2.mjs → chunk-VKZJRGDR.mjs} +1 -1
- package/dist/chunk-VZXZM7NS.mjs +2 -0
- package/dist/chunk-WDS6HEPE.mjs +2 -0
- package/dist/chunk-WHGANNEY.mjs +13 -0
- package/dist/chunk-WMJWC4QY.mjs +56 -0
- package/dist/{chunk-VZ2RQ3AM.mjs → chunk-WWONJJQS.mjs} +1 -1
- package/dist/chunk-X4WNLFIK.mjs +2 -0
- package/dist/chunk-XNNCQROX.mjs +11 -0
- package/dist/chunk-XRYECF23.mjs +170 -0
- package/dist/{chunk-K3JKPFL5.mjs → chunk-Z4NEXXFK.mjs} +1 -1
- package/dist/{chunk-236JJXWY.mjs → chunk-ZFVF2YPV.mjs} +2 -2
- package/dist/chunk-ZM2IX3R2.mjs +2 -0
- package/dist/chunk-ZNGGDUZI.mjs +2 -0
- package/dist/chunk-ZOEJQOKT.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/update-fetch.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/runtime.js +1 -0
- package/package.json +1 -1
- package/release.json +4 -4
- package/skill/SKILL.md +54 -148
- package/skill/references/building-blocks.md +4 -4
- package/skill/references/charts-and-figures.md +73 -0
- package/skill/references/extensions.md +47 -4
- package/skill/references/pages-and-data.md +22 -3
- package/skill/references/preference-files.md +7 -0
- package/skill/references/previews.md +17 -0
- package/skill/references/writing-html.md +21 -82
- package/web/assets/index-B4uUluLM.js +15 -0
- package/web/assets/index-C3vHT8sH.css +1 -0
- package/web/index.html +2 -2
- package/dist/chunk-2KAVXMKG.mjs +0 -4
- package/dist/chunk-2T4PZQEP.mjs +0 -2
- package/dist/chunk-3SKOU6OZ.mjs +0 -10
- package/dist/chunk-3XZOA7AH.mjs +0 -170
- package/dist/chunk-4KUO7R2M.mjs +0 -16
- package/dist/chunk-4OZWXZE5.mjs +0 -5
- package/dist/chunk-4SNV4HA5.mjs +0 -2
- package/dist/chunk-53XDTHTG.mjs +0 -4
- package/dist/chunk-5XV3YYLG.mjs +0 -2
- package/dist/chunk-65NTKF4N.mjs +0 -6
- package/dist/chunk-6GV3CBB2.mjs +0 -2
- package/dist/chunk-6NLXUKAY.mjs +0 -4
- package/dist/chunk-6XD6U3QA.mjs +0 -5
- package/dist/chunk-7EFHNQ5B.mjs +0 -3
- package/dist/chunk-7ISBBDJR.mjs +0 -2
- package/dist/chunk-7M2BQQGZ.mjs +0 -2
- package/dist/chunk-7UZUQQ7Q.mjs +0 -554
- package/dist/chunk-ALZ6ZENZ.mjs +0 -3
- package/dist/chunk-BLNQUR5R.mjs +0 -168
- package/dist/chunk-BMX3VUHY.mjs +0 -2
- package/dist/chunk-BN7M3IN7.mjs +0 -8
- package/dist/chunk-C257H6IA.mjs +0 -2
- package/dist/chunk-CHQU37CA.mjs +0 -2
- package/dist/chunk-DR73Y2UJ.mjs +0 -3
- package/dist/chunk-E4IHAIJ7.mjs +0 -2
- package/dist/chunk-EURLTOTZ.mjs +0 -4
- package/dist/chunk-F4ZA6JRZ.mjs +0 -3
- package/dist/chunk-GKOBB6DH.mjs +0 -2
- package/dist/chunk-GMJD7ID3.mjs +0 -2
- package/dist/chunk-IA2SIEJQ.mjs +0 -2
- package/dist/chunk-JEUK3ZO7.mjs +0 -2
- package/dist/chunk-JPG2LBQM.mjs +0 -11
- package/dist/chunk-KLQP46Y3.mjs +0 -4
- package/dist/chunk-LMUZQK5O.mjs +0 -2
- package/dist/chunk-MKIBJTJZ.mjs +0 -6
- package/dist/chunk-MNWJ4EZY.mjs +0 -2
- package/dist/chunk-NHP66IWR.mjs +0 -5
- package/dist/chunk-OEIJLMPI.mjs +0 -2
- package/dist/chunk-PDZR3L3C.mjs +0 -2
- package/dist/chunk-PUOQ65NC.mjs +0 -2
- package/dist/chunk-Q4MS6OFC.mjs +0 -2
- package/dist/chunk-Q7P3Q5YX.mjs +0 -13
- package/dist/chunk-QP7BOHE4.mjs +0 -2
- package/dist/chunk-S3SX3COT.mjs +0 -20
- package/dist/chunk-TANZRINB.mjs +0 -2
- package/dist/chunk-UGWMMEJ5.mjs +0 -15
- package/dist/chunk-ULXSPX5H.mjs +0 -5
- package/dist/chunk-USIHBCSW.mjs +0 -15
- package/dist/chunk-VPMRP2TL.mjs +0 -2
- package/dist/chunk-WFGPMCTZ.mjs +0 -4
- package/dist/chunk-XZCFPKGO.mjs +0 -2
- package/dist/chunk-ZFGMJVJC.mjs +0 -2
- package/web/assets/index-FLb9jCfl.css +0 -1
- package/web/assets/index-czjrXVjf.js +0 -15
- /package/dist/{chunk-PAREWQGB.mjs → chunk-NOGQX56R.mjs} +0 -0
package/dist/chunk-JPG2LBQM.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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 Qt,b as Xt}from"./chunk-ALZ6ZENZ.mjs";import{a as mt}from"./chunk-UMHUSOPJ.mjs";import{b as Vt,e as Ae}from"./chunk-A55HN5OK.mjs";import{randomBytes as kt}from"node:crypto";import h from"node:fs/promises";import{serviceLocation as Be}from"../browser/shared/service-location.mjs";import w from"node:path";import{writeAtomic as R}from"../browser/shared/files.mjs";import{sendJson as G}from"../browser/shared/http.mjs";import{said as B,saying as Et}from"../browser/shared/i18n/index.mjs";import{reportsDirectory as He}from"../browser/shared/paths.mjs";import{moveDocument as Ue,outlineAndFile as ze,ownsOutline as Ke,placeIn as nt,readOutline as te,validOutline as ee,withOutlineLock as ne,writeHead as Ve,writeOutline as Qe,writtenAs as Xe}from"../browser/shared/outline.mjs";Ae();import et from"node:fs/promises";import pt from"node:path";import{attr as Fe,walk as $e}from"../browser/shared/html-tree.mjs";import{escapeAttribute as Re}from"../browser/shared/escape.mjs";import{COMPONENTS_FOLDER as Je,DOCUMENT_FOLDERS as Te,SHARED_FOLDERS as Ce,documentFiles as Zt,packageFolders as _e,readLink as Me}from"../browser/shared/workspace.mjs";async function Pt(O,m){let k=await et.readdir(pt.join(O,m),{withFileTypes:!0});if(!Ce.includes(m))return k.map(({name:j})=>j);let c=m===Je?new Set(_e(O).map(({id:j})=>j.split("/")[0])):new Set;return k.filter(j=>j.isFile()||Te.includes(j.name)&&!c.has(j.name)).map(({name:j})=>j)}async function Nt(O,m,k,c,{names:j=new Map}={}){let x=pt.join(O,m),vt=await et.access(Zt(x).html).then(()=>!0,()=>!1)?null:await Me(x),C=new Set(["",...await Pt(O,m)]);if(await et.cp(x,k,{recursive:!0,errorOnExist:!0,force:!1,filter:N=>C.has(pt.relative(x,N).split(pt.sep)[0])}),vt)return[];let Z=Zt(k).html,v=await et.readFile(Z,"utf8"),ct=mt(v),q=new Map,H=new Set;$e(Vt(ct.replace(/^\uFEFF/," "),{sourceCodeLocationInfo:!0}),N=>{let A=Fe(N,"data-doc-component");A&&H.add(A);for(let{name:E,value:S}of N.attrs??[]){let F=N.sourceCodeLocation?.attrs?.[E];if(!F)continue;let _=/^(\.\.\/)([a-z0-9]+(?:-[a-z0-9]+)*)(\/.*)$/.exec(S),lt=E==="data-doc-id"&&S===m?c:["href","src","poster"].includes(E)&&_&&j.has(_[2])?`../${j.get(_[2])}${_[3]}`:S;lt!==S&&q.set(F.startOffset,{to:F.endOffset,text:`${E}="${Re(lt)}"`})}});let l=[...q].sort(([N],[A])=>A-N).reduce((N,[A,E])=>N.slice(0,A)+E.text+N.slice(E.to),ct);return await et.writeFile(Z,l),[...H]}import{storedHead as Ze}from"../browser/shared/sidebar-head.mjs";import{DOCS as ht,columnWorkspaceId as qe,entryWorkspace as De,entryPattern as tn,isForeign as ie,isTop as V,topOf as X}from"../browser/shared/outline-shape.mjs";import{addDraft as en,addWorkspace as nn,draftEntry as re,draftFacts as oe,draftOf as it,findDraft as rn,foreignMarker as on,projectChoices as an,registeredIds as gt,workspaceNames as sn,workspaceOf as rt}from"../browser/shared/drafts.mjs";import{forgetSnapshot as It,shownWorkspaces as cn}from"../browser/shared/workspace-columns.mjs";import{nameStops as ln}from"../browser/shared/workspace-name.mjs";import{registerWorkspace as un,workspaceId as Lt,workspaceKey as ae}from"../browser/shared/workspace-registry.mjs";import{spawn as We}from"node:child_process";import qt from"node:path";var Ge=O=>!["","0",void 0].includes(O);function Ye(O,{platform:m=process.platform,env:k=process.env}={}){return Ge(k.GALLERY_NO_BROWSER)?{skip:"GALLERY_NO_BROWSER is set"}:m==="win32"?{command:qt.join(k.SystemRoot||k.windir||"C:\\Windows","explorer.exe"),args:[`/select,"${O}"`],verbatim:!0}:m==="darwin"?{command:"open",args:["-R",O]}:!k.DISPLAY&&!k.WAYLAND_DISPLAY?{skip:"no display here (neither DISPLAY nor WAYLAND_DISPLAY is set)"}:{command:"xdg-open",args:[qt.dirname(O)]}}function Dt(O,m){let k=Ye(O,m);return k.skip?Promise.resolve({opened:!1,why:k.skip}):new Promise(c=>{let j;try{j=We(k.command,k.args,{detached:!0,stdio:"ignore",windowsHide:!1,windowsVerbatimArguments:!!k.verbatim})}catch(x){return c({opened:!1,why:x.code??x.message})}j.once("error",x=>c({opened:!1,why:x.code??x.message})),j.once("spawn",()=>{j.unref(),c({opened:!0})})})}import{LINK_FILE as At,linkStem as fn,linkValue as ot,ownAddress as Ft,readLinkText as dn}from"../browser/shared/web-links.mjs";import{sameDirectory as at}from"../browser/shared/preview-server.mjs";import{listReportSlugs as wn,slugPattern as P}from"../browser/shared/reports.mjs";import{PAGE_SLUG as mn,SHARED_FOLDERS as se,defaultWorkspace as yt,documentDirectory as pn,documentFiles as Ot,ensureWorkspace as kn,idHolder as hn,isDocSlug as gn,layoutOf as $t,listTrash as ce,newDocSlug as jt,pageSlug as yn,readLink as Rt,slugTaken as On,trashIdPattern as le}from"../browser/shared/workspace.mjs";import{createPage as jn,headOf as ue,listPages as fe,newPageSlug as Sn,pageFiles as st,readPageMeta as Jt,renamePage as vn}from"../browser/shared/pages.mjs";import{editExtension as xn,extensionSource as bn,listExtensions as Pn}from"../browser/shared/extensions.mjs";import{effectiveLook as Tt,ownLookFor as Nn,ownLookOf as En,sameLook as In,withLookField as de}from"../browser/shared/document-look.mjs";import{workspaceLook as Ct,writeWorkspaceLook as Ln}from"../browser/shared/workspace-look.mjs";import{findIn as An,tidyQuery as Fn}from"../browser/shared/search.mjs";var $n=([O,m,k,...c])=>c.length?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2} \u7B49 {3} \u6761",O,m,k,c.length+3):k!==void 0?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2}",O,m,k):m!==void 0?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}",O,m):B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}",O),St=O=>O==="en"?"en":null,Rn=32*1024*1024;async function Y(O,m){for(let k=0;;k++)try{return await h.rename(O,m)}catch(c){if(!["EPERM","EBUSY","EACCES"].includes(c.code))throw c;if(k>=5)break;await new Promise(j=>setTimeout(j,60*(k+1)))}await h.cp(O,m,{recursive:!0,errorOnExist:!0,force:!1}),await h.rm(O,{recursive:!0,force:!0,maxRetries:5})}var Jn=O=>w.resolve(O);function xi({unified:O=!1,edits:m,reports:k,reportsDirectory:c=He,server:j={kind:"dev",version:null,stop:null},components:x=null,changed:J=()=>{},index:vt=null,web:C=null,projects:Z={touch(){},indexOf:async()=>null}}){let{trash:v}=$t(c),ct=null,q=()=>ct??=ln(),H=vt??Xt({root:c,read:Qt(m),draw:(t,e)=>k.words(t,e)}),l=(t,e,n)=>[t,{ok:!1,reason:e,...Et(n)}],N=t=>h.readFile(t,"utf8").then(JSON.parse).catch(()=>null),A=t=>pn(t,c),E=t=>Ot(A(t)),S=t=>w.join(c,t),F=t=>D(Ot(S(t)).html),_=t=>Promise.resolve(m.forgetChanges?.(t)).catch(()=>{}),lt=t=>Pt(c,t),_t=async(t,e,n)=>{await h.mkdir(n,{recursive:!0});let i=[];try{for(let r of t)await Y(w.join(e,r),w.join(n,r)),i.push(r)}catch(r){for(let o of i)await Y(w.join(n,o),w.join(e,o));throw r}},we=async(t,e)=>{if(!se.includes(t))return Y(S(t),e);await _t(await lt(t),S(t),e),await h.rmdir(S(t)).catch(()=>{})},me=async(t,e)=>se.includes(t)&&!await F(t)&&(await Promise.all((await h.readdir(e)).map(n=>D(w.join(S(t),n))))).every(n=>!n),Mt=async t=>await N(Ot(t).json)??{},$=async t=>{let{title:e=t,description:n="",type:i,instructions:r,icon:o,look:a}=await Mt(A(t)),s=r===!0?{}:Tt(a,Ct(c));return{slug:t,title:e,description:n,...i?{type:i}:{},...typeof o=="string"&&o?{icon:o}:{},...r===!0?{instructions:!0}:{},...Object.keys(s).length?{look:s}:{}}},ut=async t=>{let e=await Rt(S(t));return e&&{slug:t,title:e.title,description:"",kind:"link",url:e.url,...e.icon?{icon:e.icon}:{},...e.siteIcon?{siteIcon:e.siteIcon}:{}}},pe=async(t,e,n=[])=>{let i=it(t),r=i&&n.find(({id:W})=>W===i.ws),o=r?.facts.get(i.slug);if(o){let W=w.join(r.root,i.slug);return{slug:t,title:o.title,description:o.description,kind:o.kind==="link"?"link":"draft",workspace:i.ws,...o.icon?{icon:o.icon}:{},...o.kind==="link"?{url:o.url,siteIcon:o.siteIcon}:{},path:o.path,folder:W,root:r.root}}let{ws:a,title:s,description:u,icon:p,path:g,folder:f,root:d,missing:y,kind:L,url:Q,siteIcon:K}=await oe(t,e);return{slug:t,title:s,description:u,kind:L==="link"?"link":"draft",workspace:a,...L==="link"?{url:Q,siteIcon:K}:{},...p?{icon:p}:{},...g?{path:g,folder:f,root:d}:{},...y?{missing:y}:{}}},Wt=async(t,e,n,i)=>ie(t)?pe(t,n,i):e.includes(t)?await ut(t)??{slug:t,title:t,description:"",kind:"link",url:""}:$(t),b=Lt(c),ke=()=>ae(yt())===ae(c),he=(t,e)=>{let n=t.shown.find(({isDefault:s})=>s)?.id??(ke()?b:null),i=new Set([...t.drafts.map(s=>it(s)?.ws),...t.groups.map(({workspace:s})=>s),...t.shown.map(({id:s})=>s)].filter(Boolean)),r=new Set(t.groups.filter(({workspace:s,title:u})=>s&&!u).map(({workspace:s})=>s));t.groups.find(({id:s})=>s===ht)?.title||r.add(b),r.delete(n);let o=sn(new Set([...i,b]),{ids:new Map([...e,[b,[c]]]),stops:q(),among:r});Z.touch(new Map([...o].filter(([s])=>s!==b).map(([s,{root:u}])=>[s,u])));let a=Object.fromEntries([...i].map(s=>[s,{...o.get(s)??{missing:rt(s,e).refused??"unknown"},...s===n?{default:!0}:{}}]));return a[b]={...o.get(b),there:!0,self:!0,...b===n?{default:!0}:{}},a},U=()=>yn(c),ge=async(t,e)=>{let n=await Mt(A(t));await R(E(t).json,`${JSON.stringify({...n,[e]:!0},null,2)}
|
|
3
|
-
`)},D=t=>h.access(t).then(()=>!0,()=>!1),ft=async(t,{own:e=null}={})=>{let n=new Set((await wt()).map(({slug:i})=>i));n.delete(e);for(let i=1;;i++){let r=i===1?t:`${t}-${i}`;if(!On(r,c)&&!n.has(r))return r}},xt=async t=>{let e=await ft(t.slug,{own:t.slug});return gn(t.slug)?e===t.slug&&!await hn(t.slug,c)?e:jt(c):e},ye=async(t,e)=>{let n=E(t).html,i=await h.readFile(n,"utf8"),r=mt(i).replace(`data-doc-id="${e}"`,`data-doc-id="${t}"`);r!==i&&await R(n,r)},I=()=>te(c),M=async t=>{await Qe(c,t),J()},T=t=>ne(c,t);async function dt(t,e="",n=1/0){await T(async()=>{let i=await I();nt(i,t,e,n),await M(i)})}async function Oe(t,{parent:e="",after:n=null,first:i=!1}={}){await T(async()=>{let r=await I();for(let a of Object.values(r.children))a.includes(t)&&a.splice(a.indexOf(t),1);let o=typeof n=="string"?Object.keys(r.children).find(a=>r.children[a].includes(n)):void 0;o!==void 0?nt(r,t,o,r.children[o].indexOf(n)+1):nt(r,t,typeof e=="string"?e:"",i===!0?0:1/0),await M(r)})}function je(t,e){let n=new Set(Object.values(t.children).flat()),i={...t.children};for(let{id:r}of e.groups){if(r===ht)continue;let o=a=>{let s=(e.children[a]??[]).filter(u=>!n.has(u));(V(a)||s.length)&&(i[a]=s),s.forEach(o)};o(X(r))}return{groups:e.groups,children:i}}function Gt(t){return T(async()=>{let e=await I();for(let[n,i]of Object.entries(e.children)){let r=i.indexOf(t);if(!(r<0))return i.splice(r,1,...e.children[t]??[]),delete e.children[t],await M(e),{parent:n,index:r}}return{parent:"",index:1/0}})}let Se=(t,e)=>H.lines(t,e),Yt=t=>N(w.join(v,t,"entry.json")),wt=()=>ce(c),ve=()=>O?[...gt()].filter(([t,e])=>t!==b&&e.length===1).map(([t,e])=>({id:t,root:e[0]})):[],Bt=async()=>[...await wt(),...(await Promise.all(ve().map(async({id:t,root:e})=>(await ce(e)).map(n=>({...n,id:re(t,n.id),slug:re(t,n.slug)}))))).flat()];async function xe(t){let e=await Jt(t,c);if(!e)return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762");let n=`${Date.now().toString(36)}-${kt(3).toString("hex")}`;try{await h.mkdir(w.join(v,n),{recursive:!0}),await Y(st(t,c).folder,w.join(v,n,"page"))}catch(r){throw await h.rm(w.join(v,n),{recursive:!0,force:!0}).catch(()=>{}),r}let i={id:n,kind:"page",slug:t,title:e.title,at:Date.now(),parent:"",index:-1};return await R(w.join(v,n,"entry.json"),`${JSON.stringify(i,null,2)}
|
|
4
|
-
`),[200,{ok:!0,entry:i}]}async function be(t){let e=w.join(v,t.id,"page"),n=await xt(t);if(await h.mkdir($t(c).customPages,{recursive:!0}),await Y(e,st(n,c).folder),n!==t.slug){let{html:i}=st(n,c),r=await h.readFile(i,"utf8").catch(()=>null),o=r?.replace(`data-page-id="${t.slug}"`,`data-page-id="${n}"`);r!==null&&o!==r&&await R(i,o)}return await h.rm(w.join(v,t.id),{recursive:!0,force:!0}),[200,{ok:!0,page:await Jt(n,c),entry:{...t,slug:n}}]}async function Pe(t){let e=await Rt(S(t));if(!e)return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u94FE\u63A5");let n=`${Date.now().toString(36)}-${kt(3).toString("hex")}`,i=await I(),{parent:r,index:o}=await Gt(t);try{await h.mkdir(w.join(v,n),{recursive:!0}),await Y(S(t),w.join(v,n,"link"))}catch(s){throw await T(()=>M(i)),await h.rm(w.join(v,n),{recursive:!0,force:!0}).catch(()=>{}),s}let a={id:n,kind:"link",slug:t,title:e.title,at:Date.now(),parent:r,index:Number.isFinite(o)?o:-1};return await R(w.join(v,n,"entry.json"),`${JSON.stringify(a,null,2)}
|
|
5
|
-
`),[200,{ok:!0,entry:a}]}async function Ne(t){let e=w.join(v,t.id,"link"),n=await xt(t);return await Y(e,S(n)),await h.rm(w.join(v,t.id),{recursive:!0,force:!0}),await dt(n,t.parent,t.index<0?1/0:t.index),[200,{ok:!0,report:await ut(n),entry:{...t,slug:n}}]}function Ee(t,{parent:e,after:n,first:i}){let r=a=>V(a)?Object.hasOwn(t.children,a):Object.values(t.children).some(s=>s.includes(a));if(n!=null){let a=Object.keys(t.children).find(s=>t.children[s].includes(n));return a===void 0?{refused:[404,"after","\u627E\u4E0D\u5230\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6761\u76EE"]}:e!=null&&e!==a?{refused:[409,"level","\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6761\u76EE\u4E0D\u5728\u8FD9\u4E00\u5C42"]}:{parent:a,index:t.children[a].indexOf(n)+1}}let o=e??X(ht);return V(o)&&t.groups.some(a=>a.extension&&X(a.id)===o)?{refused:[409,"extension","\u6269\u5C55\u7684\u680F\u91CC\u653E\u4E0D\u4E86\u522B\u7684\u6761\u76EE"]}:r(o)?{parent:o,index:i?0:(t.children[o]??[]).length}:{refused:[404,"parent",V(o)?"\u627E\u4E0D\u5230\u8FD9\u4E00\u680F":"\u627E\u4E0D\u5230\u8981\u653E\u5230\u5B83\u4E0B\u9762\u7684\u6761\u76EE"]}}let z=new Map;function Ie(t){let e=z.get(t);if(e&&Date.now()-e.at<36e5)return e.answer;let n=C?C.frameable(t).catch(()=>({frameable:!0,reason:"unknown"})):Promise.resolve({frameable:!0,reason:"unknown"});return z.size>=500&&z.delete(z.keys().next().value),z.set(t,{at:Date.now(),answer:n}),n.then(i=>{["auth","unknown"].includes(i.reason)&&z.get(t)?.answer===n&&z.delete(t)}),n}function Ht(t,e){return C?.icon?(async()=>{let n=await C.icon(e).catch(()=>null);if(!n)return null;let i=w.join(S(t),At),r=await h.readFile(i,"utf8").catch(()=>null),o=r===null?null:dn(r);if(!o||o.url!==e||o.siteIcon===n)return null;let a=ot({...o,siteIcon:n});return a.refused||!a.value.siteIcon||!await R(i,`${JSON.stringify(a.value,null,2)}
|
|
6
|
-
`,{expect:r})?null:(J(),n)})().catch(()=>null):Promise.resolve(null)}let Ut={info:async()=>[200,{ok:!0,version:1,gallery:j.version,token:m.token,commands:[...Object.keys(tt)],server:{pid:process.pid,home:w.resolve(yt()),data:Be().data,version:j.version,kind:j.kind}}],async outline(){let{outline:t,others:e}=await ze(c),n=await U(),i=[...Object.values(t.children).flat(),...n?[n]:[]],r=gt(),o=async d=>[d,await Wt(d,t.links,r,e)],[a,s,u,p]=await Promise.all([Promise.all(i.map(o)),fe(yt()),Bt(),Pn(c)]),g=p.map(({id:d,file:y,revision:L,title:Q,icon:K,entries:W,count:bt,error:Kt})=>({id:d,file:y,revision:L,title:Q,...K?{icon:K}:{},entries:W,count:bt,...Kt?{error:Et(Kt)}:{}})),f=await ue(c,s);return[200,{ok:!0,outline:t,instructions:n,reports:Object.fromEntries(a),pages:s,head:f,trash:u,workspaces:he(t,r),self:b,shared:!0,extensions:g}]},trash:async()=>[200,{ok:!0,entries:await Bt()}],async stats(t){let e=t.get("slug")??"",n=P.test(e)?await H.facts(e).catch(()=>null):null;return n?[200,{ok:!0,edited:n.edited,words:n.words}]:l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},async query(t){let e;try{e=JSON.parse(t.get("options")??"{}")}catch{return[400,{ok:!1,reason:"options",message:"options is JSON"}]}return H.query(t.get("kind")??"",e,{doc:t.get("doc")})},components:async()=>[200,{ok:!0,...x.read()}],async source(t){let e=t.get("slug")??"",n=t.get("kind")==="page";if(!P.test(e))return l(404,"missing",n?"\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762":"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let i=w.resolve(n?st(e,c).html:E(e).html);return await D(i)?[200,{ok:!0,path:i}]:l(404,"missing",n?"\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762":"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},projects:async()=>[200,{ok:!0,workspaces:await an(c,{stops:q()})}],async search(t){let e=Fn(t.get("q")??"");if(!e)return[200,{ok:!0,results:[]}];let{children:n,groups:i,links:r}=await I(),o=[],a=f=>(n[f]??[]).forEach(d=>{!r.includes(d)&&(!ie(d)||it(d))&&o.push(d),a(d)});for(let{id:f}of i)a(X(f));let s=e.toLowerCase(),u=new Map(await Promise.all(o.map(async f=>[f,await Wt(f,r,gt())]))),p=JSON.stringify([...u].map(([f,{title:d}])=>[f,d])),g=(await Promise.all(o.map(async f=>{let d=it(f),y=d?rt(d.ws):null,L=y&&!y.refused?await Z.indexOf(y.root):null,Q=d?await L?.lines(d.slug,p):await Se(f,p);if(!Q)return null;let K=String(u.get(f).title).toLowerCase().includes(s),{count:W,hits:bt}=An(Q,e);return K||W?{slug:f,title:K,count:W,hits:bt}:null}))).filter(Boolean);return g.sort((f,d)=>Number(d.title)-Number(f.title)||d.count-f.count),[200,{ok:!0,results:g.slice(0,50)}]}},tt={async"extension-edit"({id:t,...e}){let n=await bn(c,t),i=await ne(n?.root??c,()=>xn(n?.root??c,t,e),{local:!0});return i.ok?(i.written&&J(),[200,{ok:!0}]):l(i.status,i.reason,i.error)},async outline({outline:t,base:e}){return!ee(t)||e!==void 0&&!ee(e)?l(400,"outline","\u6587\u6863\u76EE\u5F55\u7684\u7ED3\u6784\u4E0D\u5BF9\uFF1A\u6BCF\u4EFD\u6587\u6863\u53EA\u80FD\u51FA\u73B0\u4E00\u6B21"):Ke(c,t)?await T(async()=>{let i=await I();return e!==void 0&&!Xe(e,i)?!1:(await M(t.groups?t:je(t,i)),!0)})?[200,{ok:!0,outline:await I()}]:l(409,"stale","\u6587\u6863\u76EE\u5F55\u521A\u5728\u522B\u5904\u6539\u8FC7"):l(409,"cross-workspace","\u8DE8\u5DE5\u4F5C\u533A\u8BF7\u590D\u5236\uFF0C\u4E0D\u80FD\u53EA\u79FB\u52A8\u76EE\u5F55\u4F4D\u7F6E")},async move({slug:t,parent:e,after:n=null,first:i=!1,workspace:r}){if(typeof r=="string"&&!at(r,c))return l(409,"elsewhere","\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863");let o=u=>typeof u=="string"&&P.test(u);if(!o(t)||e!==void 0&&e!==""&&!o(e)||n!==null&&!o(n)||typeof i!="boolean")return l(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let a=await U();if(a!==null&&[t,e,n].includes(a))return l(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u5728\u6587\u6863\u76EE\u5F55\u91CC\uFF0C\u4E0D\u80FD\u79FB\u52A8\uFF0C\u4E0B\u9762\u4E5F\u4E0D\u80FD\u653E\u6587\u6863");let s=await Ue(c,t,{parent:e,after:n,first:i});if(s.written&&J(),!s.ok){let[u,p]={missing:[404,"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"],parent:[404,"\u627E\u4E0D\u5230\u8981\u653E\u5230\u5B83\u4E0B\u9762\u7684\u6587\u6863"],after:[404,"\u627E\u4E0D\u5230\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6587\u6863"],level:[409,"\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6587\u6863\u4E0D\u5728\u8FD9\u4E00\u5C42"],itself:[409,"\u6587\u6863\u4E0D\u80FD\u653E\u5728\u5B83\u81EA\u5DF1\u540E\u9762"],inside:[409,"\u6587\u6863\u4E0D\u80FD\u79FB\u5230\u5B83\u81EA\u5DF1\u6216\u5B83\u4E0B\u9762\u7684\u6587\u6863\u4E0B\u9762"],"cross-workspace":[409,"\u8DE8\u5DE5\u4F5C\u533A\u8BF7\u590D\u5236\uFF0C\u4E0D\u80FD\u53EA\u79FB\u52A8\u76EE\u5F55\u4F4D\u7F6E"]}[s.reason];return l(u,s.reason,p)}return[200,{ok:!0,...s,outline:await I()}]},async create({title:t,description:e,parent:n="",after:i=null,first:r=!1,language:o}){let a=typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,200):"",s=await jt(c);return await _(s),await k.create(s,a,typeof e=="string"&&e.trim()?e.trim():"\u65B0\u6587\u6863",{lang:St(o)}),await Oe(s,{parent:n,after:i,first:r}),[200,{ok:!0,report:await $(s)}]},async instructions({title:t,description:e,language:n}){let i=await U();if(i)return[200,{ok:!0,report:await $(i)}];let r=await ft(mn),o=(a,s)=>typeof a=="string"&&a.trim()?a.trim().slice(0,200):s;return await k.create(r,o(t,"\u5199\u4F5C\u504F\u597D"),o(e,"Agent \u6BCF\u6B21\u5199\u62A5\u544A\u524D\u90FD\u4F1A\u5148\u8BFB\u7684\u5199\u4F5C\u504F\u597D"),{lang:St(n),page:!0}),await ge(r,"instructions"),[200,{ok:!0,report:await $(r)}]},async components({id:t,hidden:e,shown:n,disabled:i,unlisted:r,net:o,pack:a,enabled:s}){try{return[200,{ok:!0,...await x.write(a!==void 0?{pack:a,enabled:s}:{id:t,hidden:e,shown:n,disabled:i,unlisted:r,net:o})}]}catch(u){return l(409,"components",u)}},async duplicate({slug:t,suffix:e,untitled:n}){if(typeof t!="string"||!P.test(t)||!await F(t))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let i=await jt(c);await _(i),await Nt(c,t,S(i),i);let{title:r}=await $(t),o=r||(typeof n=="string"&&n.trim()?n.trim().slice(0,50):"\u672A\u547D\u540D\u6587\u6863"),a=await m.renameReport(i,`${o}${typeof e=="string"&&e.length>0&&e.length<=20?e:"\uFF08\u526F\u672C\uFF09"}`),s=await I(),[u,p]=Object.entries(s.children).find(([,g])=>g.includes(t))??["",null];return await dt(i,u,p?p.indexOf(t)+1:1/0),[200,{ok:!0,report:await $(i),notes:a.notes??[]}]},async"copy-from"({sourceWs:t,slug:e,parent:n="",index:i=0}){let r=typeof t=="string"?rt(t):{};if(!r.root||t===b||typeof e!="string"||!P.test(e)||typeof n!="string"||!V(n)&&!tn.test(n)||!Number.isInteger(i)||i<0)return l(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let o=await te(r.root);if(!Object.values(o.children).some(f=>f.includes(e)))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let a=[],s=f=>{if(!P.test(f)||a.includes(f))throw new Error("\u6587\u6863\u76EE\u5F55\u7684\u7ED3\u6784\u4E0D\u5BF9\uFF1A\u6BCF\u4EFD\u6587\u6863\u53EA\u80FD\u51FA\u73B0\u4E00\u6B21");a.push(f);for(let d of o.children[f]??[])s(d)};s(e);let u=new Map;for(let f of a){let d;do d=await jt(c);while([...u.values()].includes(d));u.set(f,d)}let p=w.join($t(c).gallery,`copy-${kt(8).toString("hex")}`),g=[];try{await h.mkdir(p,{recursive:!0});for(let f of a)await Nt(r.root,f,w.join(p,u.get(f)),u.get(f),{names:u});return await T(async()=>{let f=await I();if((V(n)?qe(f.groups.find(y=>X(y.id)===n),b):De(n,b))!==b||(V(n)?!f.groups.some(y=>X(y.id)===n&&!y.extension):!Object.values(f.children).some(y=>y.includes(n))))throw new Error("\u627E\u4E0D\u5230\u8981\u653E\u5230\u5B83\u4E0B\u9762\u7684\u6587\u6863");for(let y of a){let L=u.get(y);await h.rename(w.join(p,L),S(L)),g.push(S(L))}It(c),nt(f,u.get(e),n,i);for(let y of a)o.children[y]?.length&&(f.children[u.get(y)]=o.children[y].map(L=>u.get(L)));await M(f)}),[200,{ok:!0,slug:u.get(e),count:a.length}]}catch(f){for(let d of g)await h.rm(d,{recursive:!0,force:!0});return It(c),l(409,"copy",f.text?f:f.message)}finally{await h.rm(p,{recursive:!0,force:!0})}},async look({slug:t,look:e}){if(typeof t!="string"||!P.test(t)||!await F(t))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(t===await U())return l(409,"instructions","\u5199\u4F5C\u504F\u597D\u6CA1\u6709\u5B57\u4F53\u4E0E\u5E03\u5C40");if(e!==null&&(typeof e!="object"||Array.isArray(e)))return l(400,"look","\u5B57\u4F53\u4E0E\u5E03\u5C40\u4E0D\u5BF9");let n=E(t).json,i=null;try{i=JSON.parse(await h.readFile(n,"utf8"))}catch{}if(!i||typeof i!="object"||Array.isArray(i))return l(409,"metadata","\u8FD9\u4EFD\u6587\u6863\u7684\u6807\u9898\u548C\u8BF4\u660E\u8BFB\u4E0D\u51FA\u6765");let r=de(i,Nn(e,Ct(c)));return JSON.stringify(r)!==JSON.stringify(i)&&await R(n,`${JSON.stringify(r,null,2)}
|
|
7
|
-
`),[200,{ok:!0,report:await $(t)}]},async looks({slug:t}){if(typeof t!="string"||!P.test(t)||!await F(t))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=await U();if(t===e)return l(409,"instructions","\u5199\u4F5C\u504F\u597D\u6CA1\u6709\u5B57\u4F53\u4E0E\u5E03\u5C40");let n=await N(E(t).json);if(!n||typeof n!="object"||Array.isArray(n))return l(409,"metadata","\u8FD9\u4EFD\u6587\u6863\u7684\u6807\u9898\u548C\u8BF4\u660E\u8BFB\u4E0D\u51FA\u6765");let i=Ct(c),r=Tt(n.look,i);try{await Ln(c,r)}catch(u){return l(409,"workspace",u)}let o=0,a=(await wn(c)).filter(u=>u!==e).map(u=>({json:E(u).json,self:u===t})),s=(await wt()).filter(({kind:u})=>u==="document").map(({id:u})=>({json:Ot(w.join(v,u,"report")).json,self:!1}));for(let{json:u,self:p}of[...a,...s])for(let g=0;g<3;g++){let f=await h.readFile(u,"utf8").catch(()=>null),d=null;try{d=JSON.parse(f??"")}catch{}if(!d||typeof d!="object"||Array.isArray(d)||!Object.hasOwn(d,"look")||d.instructions===!0)break;let y=await R(u,`${JSON.stringify(de(d,{}),null,2)}
|
|
8
|
-
`,{expect:f}).catch(()=>null);if(y===null)break;if(y){!p&&Object.keys(En(d.look)).length>0&&!In(Tt(d.look,i),r)&&o++;break}}return[200,{ok:!0,look:r,replaced:o,report:await $(t)}]},async head({order:t}){let e=Ze(t);return e?(await T(()=>Ve(c,e)),J(),[200,{ok:!0,head:await ue(c,await fe(yt()))}]):l(400,"head","\u4FA7\u680F\u5934\u90E8\u7684\u987A\u5E8F\u4E0D\u5BF9")},async"new-page"({title:t,after:e=null,language:n}){let i=typeof t=="string"?t.replace(/\s+/g," ").trim():"";if(!i||i.length>200)return l(400,"title","\u6807\u9898\u4E0D\u80FD\u662F\u7A7A\u7684\uFF0C\u4E5F\u4E0D\u80FD\u8D85\u8FC7 200 \u4E2A\u5B57");if(e!==null&&(typeof e!="string"||!P.test(e)))return l(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let r=await Sn(c);return await jn(r,i,{root:c,blank:!0,after:e,...St(n)?{lang:St(n)}:{}}),J(),[200,{ok:!0,page:await Jt(r,c)}]},async rename({slug:t,title:e,kind:n="document"}){if(typeof t!="string"||!P.test(t))return l(400,"slug","\u6587\u6863\u540D\u4E0D\u5BF9");if(n==="page"){let r;try{r=await vn(t,e,c)}catch{return l(400,"title","\u6807\u9898\u4E0D\u80FD\u662F\u7A7A\u7684\uFF0C\u4E5F\u4E0D\u80FD\u8D85\u8FC7 200 \u4E2A\u5B57")}return r?[200,{ok:!0,page:r}]:l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762")}let i=await m.renameReport(t,e);return i.ok?[200,{ok:!0,report:await $(t),notes:i.notes}]:l({title:400,missing:404}[i.reason]??409,i.reason,i.message??"\u6539\u540D\u6CA1\u6709\u6210\u529F")},async trash({slug:t,kind:e="document"}){if(typeof t!="string"||!P.test(t))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(e==="page")return xe(t);if(e==="link")return Pe(t);if(t===await U())return l(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u80FD\u79FB\u5230\u56DE\u6536\u533A");if(!await F(t))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{title:n}=await $(t),i=`${Date.now().toString(36)}-${kt(3).toString("hex")}`,r=await I(),{parent:o,index:a}=await Gt(t);try{await h.mkdir(w.join(v,i),{recursive:!0}),await we(t,w.join(v,i,"report"))}catch(u){throw await T(()=>M(r)),await h.rm(w.join(v,i),{recursive:!0,force:!0}).catch(()=>{}),u}let s={id:i,kind:"document",slug:t,title:n,at:Date.now(),parent:o,index:Number.isFinite(a)?a:-1};return await R(w.join(v,i,"entry.json"),`${JSON.stringify(s,null,2)}
|
|
9
|
-
`),[200,{ok:!0,entry:s}]},async restore({id:t}){let e=typeof t=="string"&&le.test(t)?await Yt(t):null;if(!e)return l(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879");if(e.kind==="page")return be(e);if(e.kind==="link")return Ne(e);let n=w.join(v,t,"report"),i=await me(e.slug,n),r=i?e.slug:await xt(e);return i?await _t(await h.readdir(n),n,S(r)):await Y(n,S(r)),r!==e.slug&&await ye(r,e.slug),await h.rm(w.join(v,t),{recursive:!0,force:!0}),await dt(r,e.parent,e.index<0?1/0:e.index),[200,{ok:!0,report:await $(r),entry:{...e,kind:"document",slug:r}}]},async destroy({id:t}){let e=typeof t=="string"&&le.test(t)?await Yt(t):null;return e?((e.kind??"document")==="document"&&!await F(e.slug)&&await _(e.slug),await h.rm(w.join(v,t),{recursive:!0,force:!0}),[200,{ok:!0}]):l(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879")},async link({url:t,title:e,icon:n=null,parent:i,after:r=null,first:o=!1},{port:a,wait:s=!1}={}){let u=ot({url:t,title:e,icon:n});if(u.refused)return l(400,u.refused,u.message);if(Ft(u.value.url,a))return l(409,"own","\u8FD9\u662F Gallery \u81EA\u5DF1\u7684\u5730\u5740\uFF0C\u8BF7\u76F4\u63A5\u94FE\u63A5\u6587\u6863");if(i!=null&&typeof i!="string"||r!==null&&typeof r!="string"||typeof o!="boolean")return l(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let p=await T(async()=>{let f=await I(),d=Ee(f,{parent:i,after:r,first:o||i==null&&r===null});if(d.refused)return d;let y=await ft(fn(u.value.title,u.value.url));return await h.mkdir(S(y),{recursive:!0}),await R(w.join(S(y),At),`${JSON.stringify(u.value,null,2)}
|
|
10
|
-
`),nt(f,y,d.parent,d.index),await M(f),{slug:y,parent:d.parent,index:d.index}});if(p.refused)return l(...p.refused);let g=Ht(p.slug,u.value.url);return s&&await g,[200,{ok:!0,link:await ut(p.slug),parent:p.parent,index:p.index,outline:await I()}]},async"link-set"({slug:t,url:e,title:n,icon:i},{port:r,wait:o=!1}={}){let a=typeof t=="string"&&P.test(t)?await Rt(S(t)):null;if(!a)return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u94FE\u63A5");let s=e??a.url,u=ot({url:s,title:n??a.title,icon:i===void 0?a.icon??null:i,siteIcon:a.siteIcon??null});if(u.refused)return l(400,u.refused,u.message);let p=u.value.url!==a.url;if(p&&Ft(u.value.url,r))return l(409,"own","\u8FD9\u662F Gallery \u81EA\u5DF1\u7684\u5730\u5740\uFF0C\u8BF7\u76F4\u63A5\u94FE\u63A5\u6587\u6863");if(p&&delete u.value.siteIcon,JSON.stringify(u.value)!==JSON.stringify(a)&&await R(w.join(S(t),At),`${JSON.stringify(u.value,null,2)}
|
|
11
|
-
`),p){let g=Ht(t,u.value.url);o&&await g}return[200,{ok:!0,link:await ut(t)}]},async"draft-add"({path:t,confirm:e=!1,after:n=null}){let i=await rn(t),r=typeof n=="string"?n:null;if(i.kind==="missing")return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u6587\u4EF6\u6216\u6587\u4EF6\u5939");if(i.kind==="plain")return l(409,"plain","\u8FD9\u4E0D\u662F Gallery \u7684\u5E95\u7A3F\u6216\u5DE5\u4F5C\u533A\uFF0C\u53EF\u4EE5\u7528\u300C\u5BFC\u5165\u300D\u628A\u6587\u4EF6\u590D\u5236\u8FDB\u6765");if(i.kind==="nested")return l(409,"nested","\u8FD9\u4EFD\u5E95\u7A3F\u4E0D\u5728\u5B83\u5DE5\u4F5C\u533A\u7684\u7B2C\u4E00\u5C42\uFF08\u5728\u56DE\u6536\u533A\u91CC\uFF0C\u6216\u662F\u5199\u4F5C\u504F\u597D\uFF09\uFF0C\u4E0D\u80FD\u6DFB\u52A0");if(i.kind==="name")return l(409,"name","\u8FD9\u4E2A\u6587\u4EF6\u5939\u7684\u540D\u5B57\u4E0D\u662F Gallery \u6587\u6863\u7684\u5199\u6CD5\uFF08\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF09\uFF0C\u4E0D\u80FD\u6DFB\u52A0");let o=i.kind==="workspace"?i.root:i.kind==="folder"?null:i.root,a=!o||!cn(c).some(g=>at(g.root,o));if(!o){let g=i.kind==="folder"?i.folder:i.parent;if(on(g))return l(409,"marker",B("{0} \u91CC\u7684 gallery.json \u662F\u522B\u7684\u7A0B\u5E8F\u7684\uFF0C\u4E0D\u80FD\u628A\u5B83\u767B\u8BB0\u6210\u5DE5\u4F5C\u533A",g));if(e!==!0)return[409,{ok:!1,reason:"unregistered",folder:g,...Et(B("\u4F1A\u628A {0} \u767B\u8BB0\u6210\u4E00\u4E2A\u5DE5\u4F5C\u533A\uFF08\u5728\u91CC\u9762\u653E gallery.json \u548C .gallery/\uFF09",g))}];if(!(await kn(g)).ours)return l(409,"marker",B("{0} \u91CC\u7684 gallery.json \u662F\u522B\u7684\u7A0B\u5E8F\u7684\uFF0C\u4E0D\u80FD\u628A\u5B83\u767B\u8BB0\u6210\u5DE5\u4F5C\u533A",g));o=g}let s=i.kind==="workspace"||i.kind==="folder";if(at(o,c))return[200,{ok:!0,kind:s?"workspace":"draft",own:!0,existing:!0,...s?{column:ht}:{entry:i.slug}}];let u=await un(o,{force:!0}).catch(()=>"failed"),p=rt(Lt(o));return p.refused==="ambiguous"?l(409,"ambiguous",B("\u672C\u673A\u767B\u8BB0\u7684 {0} \u4E2A\u5DE5\u4F5C\u533A\u7F16\u53F7\u76F8\u540C\uFF08{1}\uFF09\uFF0C\u5148\u7528 gallery workspaces --forget \u53BB\u6389\u5176\u4E2D\u4E00\u4E2A",p.roots.length,Lt(o))):!p.root||!at(p.root,o)?u==="temporary"?l(409,"temporary","\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u5728\u7CFB\u7EDF\u7684\u4E34\u65F6\u6587\u4EF6\u5939\u91CC\uFF0C\u4E0D\u80FD\u6DFB\u52A0"):l(409,"registry","\u6CA1\u80FD\u628A\u5B83\u7684\u5DE5\u4F5C\u533A\u8BB0\u8FDB\u672C\u673A\u7684\u767B\u8BB0\u8868"):(It(o),s?[200,{ok:!0,kind:"workspace",...await nn(c,o,{changed:J,after:r})}]:[200,{ok:!0,kind:"draft",...await en(c,o,i.slug,{changed:J,pick:!0,after:r,fresh:a})}])},async export({slug:t}){if(typeof t!="string"||!P.test(t)||!await D(A(t)))return l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{problems:e=[],file:n,refused:i}=await k.export(t);return i?l(i.reason==="missing"?404:409,i.reason,i.message):e.length?l(422,"check",$n(e)):[200,{ok:!0,path:Jn(n)}]}},zt={async frameable({url:t},{port:e}){let n=typeof t=="string"?ot({url:t,title:"-"}):{refused:"url"};return n.refused?l(400,"url","\u8FD9\u4E0D\u662F\u4E00\u4E2A\u7F51\u5740"):Ft(n.value.url,e)?[200,{ok:!0,frameable:!1,reason:"own"}]:[200,{ok:!0,...await Ie(n.value.url)}]},async reveal({entry:t,ws:e,page:n}){let i=gt(),r=null;return typeof n=="string"?r=P.test(n)?st(n,c).folder:null:typeof t=="string"&&it(t)?r=(await oe(t,i)).folder:e===b?r=w.resolve(c):typeof e=="string"&&(r=rt(e,i).root??null),!r||!await D(r)?l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u6587\u4EF6\u5939"):[200,{ok:!0,path:r,...await Dt(r)}]},async title({url:t}){let e=typeof t=="string"?ot({url:t,title:"-"}):{refused:"url"};if(e.refused)return l(400,"url","\u8FD9\u4E0D\u662F\u4E00\u4E2A\u7F51\u5740");let n=C?await C.title(e.value.url).catch(()=>""):"",i=typeof n=="string"?n:n?.title,r=["auth","unknown"].includes(n?.reason)?n.reason:void 0;return[200,{ok:!0,title:typeof i=="string"?i.slice(0,200):"",...r?{reason:r}:{}}]}};function Le(t,e,n){if(t.method==="GET"&&Object.hasOwn(Ut,n)){let r=t.headers.host??"",o=t.socket.localPort;return r!==`127.0.0.1:${o}`&&r!==`localhost:${o}`?G(e,403,{ok:!1,reason:"host"}):Ut[n](new URL(t.url??"/","http://localhost").searchParams).then(([a,s])=>G(e,a,s),a=>G(e,...l(500,"read",a)))}if(t.method==="POST"&&n==="stop")return m.respond(async r=>{let o=await m.check(r);return o.error?o.error:j.kind!=="cli"||typeof j.stop!="function"?l(409,"dev","\u8FD9\u662F npm run dev \u7684\u670D\u52A1\u5668\uFF1A\u5728\u8FD0\u884C\u5B83\u7684\u5730\u65B9\u505C\u6B62\u5B83"):(e.once("finish",()=>j.stop()),[200,{ok:!0,pid:process.pid}])})(t,e);if(t.method==="POST"&&n==="pack-install")return m.respond(async r=>{let o=await m.check(r,Rn);if(o.error)return o.error;if(!x?.install)return l(404,"unknown");try{return[200,{ok:!0,...x.install(o.body??{})}]}catch(a){if(!a.code)throw a;return l(409,a.code,a)}})(t,e);if(t.method==="POST"&&n==="todo")return(async()=>{let r=await m.check(t);if(r.error)return r.error;let{slug:o,items:a}=r.body??{};return typeof o!="string"||!P.test(o)||!Array.isArray(a)?[400,{ok:!1,reason:"body"}]:!await F(o)||o===await U()?l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"):m.setTodos(o,a)})().then(([r,o])=>G(e,r,o),r=>G(e,...l(500,"write",r.message)));let i={port:t.socket.localPort};return t.method==="POST"&&Object.hasOwn(tt,n)?m.respond(async r=>{let o=await m.check(r);if(o.error)return o.error;let a=o.body&&typeof o.body=="object"?o.body:{};return typeof a.workspace=="string"&&!at(a.workspace,c)?l(409,"elsewhere","\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863"):tt[n](a,i)})(t,e):t.method==="POST"&&Object.hasOwn(zt,n)?(async()=>{let r=await m.check(t);return r.error?r.error:zt[n](r.body&&typeof r.body=="object"?r.body:{},i)})().then(([r,o])=>G(e,r,o),r=>G(e,...l(500,"read",r))):G(e,404,{ok:!1,reason:"unknown"})}return{handle:Le,outline:I,trashEntries:wt,place:dt,freeSlug:ft,index:H,run:(t,e,n={})=>Object.hasOwn(tt,t)?tt[t](e??{},{wait:!0,...n}):Promise.resolve(l(404,"unknown","\u6CA1\u6709\u8FD9\u4E2A\u547D\u4EE4"))}}export{xi as a};
|
package/dist/chunk-KLQP46Y3.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{b as V,c as ce,e as le,j as X}from"./chunk-TKWEX4FD.mjs";import{createHash as $e}from"node:crypto";import v from"node:fs";import h from"node:path";import{packsDirectory as T}from"../browser/shared/paths.mjs";import{PACKAGE_MANIFEST as M,layoutOf as Q}from"../browser/shared/workspace.mjs";var je="gallery",ee=/^(?:\.DS_Store|\._.*|Thumbs\.db|ehthumbs\.db|desktop\.ini)$/i,W=n=>ee.test(n);function G(n){return v.readdirSync(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&!ee.test(e.name)).map(e=>h.relative(n,h.join(e.parentPath,e.name)).split(h.sep).join("/")).sort()}var Y=n=>[...n.filter(e=>e!==M),...n.includes(M)?[M]:[]];function E(n){return v.existsSync(n)?z(G(n).map(e=>({name:e,data:v.readFileSync(h.join(n,e))}))):null}function z(n){let e=$e("sha256"),t=n.filter(({name:i})=>!ee.test(i.split("/").at(-1))).sort((i,s)=>i.name<s.name?-1:i.name>s.name?1:0);for(let{name:i,data:s}of t)e.update(`${i}\0`).update(s).update(`
|
|
3
|
-
`);return e.digest("hex").slice(0,16)}var Z=n=>{try{return v.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort()}catch{return[]}},_=(n=T)=>Z(n);function D(n=T){return Z(n).flatMap(e=>Z(h.join(n,e)).flatMap(t=>{let i=h.join(n,e,t);try{let s=JSON.parse(v.readFileSync(h.join(i,M),"utf8"));return s.id!==`${e}/${t}`?[]:[{name:t,id:s.id,pack:e,folder:i,version:s.version,title:s.name,description:s.description,places:s.places??["document"]}]}catch{return[]}}))}function Ue(n,e=T){let t=n.includes("/")?n:`${je}/${n}`;return D(e).find(i=>i.id===t)??null}var Ve=(n,e=T)=>_(e).includes(String(n).split("/")[0]);function P(n){try{let e=JSON.parse(v.readFileSync(Q(n).blocks,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function K(n,e){let t=Q(n).blocks;v.mkdirSync(h.dirname(t),{recursive:!0}),v.writeFileSync(t,`${JSON.stringify(e,null,2)}
|
|
4
|
-
`)}var he=(n,e)=>h.join(Q(n).components,...e.split("/"));function ne(n,e){let t=he(n,e.id),i=E(t);if(i===null)return{added:!1,version:null,changed:!1,behind:!1};let s=null;try{s=JSON.parse(v.readFileSync(h.join(t,M),"utf8")).version??null}catch{}let a=P(n)[e.id],c=E(e.folder),o=i!==c&&i!==a?.fingerprint;return{added:!0,version:s,changed:o,behind:!o&&i!==c}}function xe(n,e){let t=he(n,e.id),i=ne(n,e);if(i.changed)throw Object.assign(new Error(`${e.id} was changed after it was added`),{code:"changed",folder:t});let s=E(e.folder),a=P(n);if(i.added&&!i.behind)return a[e.id]?.fingerprint!==s&&K(n,{...a,[e.id]:{version:e.version,fingerprint:s}}),{did:"same",folder:t};let c=G(e.folder);if(i.added)for(let o of G(t))c.includes(o)||v.rmSync(h.join(t,o));for(let o of Y(c))v.mkdirSync(h.dirname(h.join(t,o)),{recursive:!0}),v.copyFileSync(h.join(e.folder,o),h.join(t,o));return K(n,{...a,[e.id]:{version:e.version,fingerprint:s}}),{did:i.added?"updated":"added",from:i.version,folder:t}}var ae=n=>/^\d+\.\d+\.\d+$/.test(String(n??""))?n.split(".").map(Number):null;function L(n,e){let[t,i]=[ae(n),ae(e)];if(!t||!i)return n!==e;let s=t.findIndex((a,c)=>a!==i[c]);return s!==-1&&t[s]>i[s]}function Xe(n,e){let t=ne(n,e);return t.changed&&L(e.version,t.version)?e.version:null}var fe=new Map,me=()=>{};function Oe(n,{updated:e,kept:t,failed:i}){let s=[];e.length&&s.push(`Gallery's own blocks in ${n}, as they were added, updated to this Gallery's: ${e.map(({id:a,from:c,to:o})=>`${a} ${c??"?"} -> ${o}`).join(", ")}`);for(let{id:a,version:c,shipped:o}of t)s.push(`${a} in ${n} was changed after it was added, so it stays at ${c??"its version"}: Gallery's is ${o} (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 says how to take it)`);for(let{id:a,to:c,why:o}of i)s.push(`${a} in ${n} could not be updated to Gallery's ${c}: ${o}`);return s}function Fe(n,{ids:e=null,directory:t=T,log:i=null}={}){let s={updated:[],kept:[],failed:[]},a=h.resolve(n);for(let c of D(t)){if(e&&!e.includes(c.id))continue;let o=`${a}\0${h.resolve(c.folder)}`;if(fe.get(o)!==c.version){fe.set(o,c.version);try{let r=ne(n,c);if(r.changed&&L(c.version,r.version)&&s.kept.push({id:c.id,version:r.version,shipped:c.version}),!r.behind)continue;xe(n,c).did==="updated"&&s.updated.push({id:c.id,from:r.version,to:c.version})}catch(r){s.failed.push({id:c.id,to:c.version,why:r?.message??String(r)})}}}for(let c of Oe(a,s))(i??me)(c);return s}var de=new Set,pe=n=>process.platform==="win32"?h.resolve(n).toLowerCase():h.resolve(n);function Ze(n,e){de.add(pe(n)),me=e,le((t,i)=>{de.has(pe(t))&&Fe(t,{ids:i})},_())}var ue=n=>[n,n.replace("/","-")],be=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Qe(n,e,t=T){for(let i of D(t)){if(i.id===e)continue;let s;try{s=v.readFileSync(h.join(i.folder,"preview.svg"))}catch{continue}if(s.equals(n)||Buffer.from(Ae(i,e)["preview.svg"]??"").equals(n))return i}return null}function Ae(n,e){let[t,i]=[ue(n.id),ue(e)],s=new RegExp(t.map(be).join("|"),"g"),a={};for(let c of G(n.folder)){let o=v.readFileSync(h.join(n.folder,c));if(/\.(?:json|html|md|css|js|svg)$/.test(c)){let r=o.toString("utf8").replace(s,f=>i[t.indexOf(f)]);c===M&&(r=r.replace(/"version":\s*"[^"]*"/,'"version": "0.1.0"')),a[c]=r}else a[c]=o}return Object.fromEntries(Y(Object.keys(a)).map(c=>[c,a[c]]))}import m from"node:fs";import u from"node:path";import{refusal as Pe,said as k}from"../browser/shared/i18n/index.mjs";import{DEFAULT_PACK as Ee,OWN_SCOPE as te,PACK_FILE as F,PACK_ID as ye,readPackManifest as ie}from"../browser/shared/pack-manifest.mjs";import{packsDirectory as ge}from"../browser/shared/paths.mjs";import{DEVICE_NAMES as _e,PACKAGE_MANIFEST as R,layoutOf as H,markerOf as Ne,packageFolders as Ie}from"../browser/shared/workspace.mjs";var oe=Object.freeze(["gallery-soft"]);function fn(n,e={}){let t=P(n).packs;return oe.filter(i=>e?.[i]===void 0&&!b(t?.[i]))}var Me="GALLERY_NO_PACKS",Ge=(n=process.env)=>!["","0","false",void 0].includes(n[Me]),q=2e3,re=64*1024*1024,Se=/^[a-z0-9][a-z0-9-]*$/,b=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),j=(n,e)=>{throw Pe(e,{code:n})};function Te(n){let e=[];for(let t of m.readdirSync(n,{recursive:!0,withFileTypes:!0})){if(!t.isFile())continue;e.length>=q&&j("size",k("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",q,re/1024/1024));let i=u.relative(n,u.join(t.parentPath,t.name)).split(u.sep).join("/");e.push({name:i,data:m.readFileSync(u.join(n,...i.split("/")))})}return e}function Ce(n,{refuse:e=()=>{}}={}){let t=[],i=0;for(let{name:r,data:f}of n){let d=String(r).replace(/\\/g,"/");if(d.endsWith("/"))continue;let y=d.split("/");(d.startsWith("/")||/^[A-Za-z]:/.test(d)||d.includes("\0")||y.some(l=>l===""||l==="."||l===".."))&&j("path",k("{0} \u6307\u5411\u5757\u5305\u5916\u9762\uFF0C\u4E0D\u80FD\u88C5",String(r))),!(y[0]==="__MACOSX"||W(y.at(-1)))&&(i+=f.length,t.push({name:d,data:f}))}(t.length>q||i>re)&&j("size",k("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",q,re/1024/1024));let s=t;if(!t.some(({name:r})=>r===F)){let r=new Set(t.map(({name:d})=>d.split("/")[0])),[f]=r;(r.size!==1||!t.some(({name:d})=>d===`${f}/${F}`))&&j("manifest",k("\u6700\u4E0A\u4E00\u5C42\u6CA1\u6709 pack.json\uFF1A\u5757\u5305\u662F\u4E00\u4E2A\u6587\u4EF6\u5939\uFF0C\u6700\u4E0A\u4E00\u5C42\u653E pack.json\uFF0C\u6BCF\u4E2A\u5757\u4E00\u4E2A\u6587\u4EF6\u5939")),s=t.map(({name:d,data:y})=>({name:d.slice(f.length+1),data:y}))}let a=ie(s.find(({name:r})=>r===F).data.toString("utf8"));e(a);let c=new Map,o=[];for(let r of s){let[f,...d]=r.name.split("/");if(d.length===0){o.push(r);continue}c.has(f)||c.set(f,[]),c.get(f).push({name:d.join("/"),data:r.data})}for(let[r,f]of c){(!Se.test(r)||_e.has(r))&&j("block",k("{0} \u4E0D\u662F\u5757\u7684\u6587\u4EF6\u5939\u540D\uFF1A\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",r));let d=f.find(l=>l.name===R);d||j("block",k("{0}/ \u91CC\u6CA1\u6709 component.json",r));let y;try{y=JSON.parse(d.data.toString("utf8").replace(/^/,"")).id}catch{j("block",k("{0}/component.json \u4E0D\u662F JSON",r))}y!==`${a.id}/${r}`&&j("block",k("{0}/component.json \u7684 id \u8981\u5199\u6210 {1}",r,`${a.id}/${r}`))}return{manifest:a,blocks:c,own:o}}function Ke(n){try{let e=JSON.parse(n.find(({name:t})=>t===R).data.toString("utf8").replace(/^/,"")).version;return typeof e=="string"?e:null}catch{return null}}function ve(n){try{return m.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isFile()&&!W(e.name)).map(e=>e.name).sort()}catch{return[]}}function ke(n){let e=ve(n);return e.length?z(e.map(t=>({name:t,data:m.readFileSync(u.join(n,t))}))):null}function ze(n){try{return m.readdirSync(n).some(e=>!W(e))}catch{return!1}}function se(n,e,{replacing:t=!1,last:i=R}={}){let s=e.map(({name:o})=>o);if(t)for(let o of G(n))s.includes(o)||m.rmSync(u.join(n,...o.split("/")),{force:!0});let a=new Map(e.map(o=>[o.name,o.data])),c=i===R?Y(s):[...s.filter(o=>o!==i),...s.includes(i)?[i]:[]];for(let o of c){let r=u.join(n,...o.split("/"));m.mkdirSync(u.dirname(r),{recursive:!0}),m.writeFileSync(r,a.get(o))}}function De(n,e,{official:t=!1,shippedIds:i=_()}={}){let{manifest:s,blocks:a,own:c}=Ce(e,{refuse:({id:g})=>{!t&&i.includes(g)&&j("official",k("{0} \u662F Gallery \u81EA\u5E26\u7684\u5757\u5305\u7528\u7684 id\uFF1A\u6362\u4E00\u4E2A id \u518D\u88C5",g))}}),{id:o}=s,r=u.join(H(n).components,o),f=P(n),d=b(f.packs)?f.packs:{},y=b(d[o])?d[o]:null;!t&&!y&&ze(r)&&j("taken",k("\u5DE5\u4F5C\u533A\u91CC\u5DF2\u7ECF\u6709 components/{0}\uFF1A\u8FD9\u4E2A\u540D\u5B57\u88AB\u522B\u7684\u5757\u5305\u6216\u522B\u4EBA\u5199\u7684\u5757\u7528\u7740\uFF0C\u6362\u4E00\u4E2A id\uFF0C\u6216\u5148\u628A\u90A3\u4E2A\u6587\u4EF6\u5939\u632A\u8D70",o));let l={id:o,name:s.name,version:s.version,from:y?.version??null,folder:r,added:[],updated:[],same:[],kept:[],removed:[],skipped:[],ownKept:!1},w=[...a.keys()].sort();for(let g of w){let p=`${o}/${g}`,O=a.get(g),$=u.join(r,g),B=z(O),I=E($),J=b(f[p])?f[p]:null;if(I===null){if(t&&J){l.skipped.push(p);continue}se($,O),l.added.push(p)}else if(I===B)l.same.push(p);else if(J&&I===J.fingerprint)se($,O,{replacing:!0}),l.updated.push(p);else{l.kept.push(p);continue}f[p]={version:Ke(O),fingerprint:B}}for(let g of Array.isArray(y?.blocks)?y.blocks:[]){let p=String(g).split("/")[1];if(!p||a.has(p)||!Se.test(p))continue;let O=u.join(r,p),$=E(O);if($!==null&&$!==f[g]?.fingerprint){l.kept.push(g);continue}$!==null&&(m.rmSync(O,{recursive:!0,force:!0,maxRetries:5,retryDelay:100}),l.removed.push(g)),delete f[g]}let x=ke(r),A=z(c);if(x!==A)if(x===null||x===y?.fingerprint){let g=c.map(({name:p})=>p);for(let p of ve(r))g.includes(p)||m.rmSync(u.join(r,p),{force:!0});m.mkdirSync(r,{recursive:!0}),se(r,c,{last:F})}else l.ownKept=!0;let N=l.added.length+l.updated.length+l.removed.length>0||x!==A&&!l.ownKept;return l.did=y?N?"updated":"same":"installed",f.packs={...d,[o]:{version:s.version,fingerprint:l.ownKept?y.fingerprint:A,blocks:w.map(g=>`${o}/${g}`),...t?{official:!0}:{}}},K(n,f),l}function dn(n,e,{shippedIds:t=_()}={}){t.includes(e)&&j("official",k("{0} \u662F Gallery \u81EA\u5E26\u7684\u5757\u5305\uFF0C\u4E0D\u80FD\u5220\u9664\uFF1A\u5728 \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 \u91CC\u628A\u5B83\u5173\u6389",e));let i=u.join(H(n).components,e);(!ye.test(e)||!m.existsSync(i))&&j("missing",k("\u5DE5\u4F5C\u533A\u91CC\u6CA1\u6709\u5757\u5305 {0}",e));let s=P(n),a=b(s.packs)&&b(s.packs[e])?s.packs[e]:null;a||j("own",k("components/{0} \u4E0D\u662F\u88C5\u8FDB\u6765\u7684\u5757\u5305\uFF0C\u91CC\u9762\u7684\u5757\u662F\u6709\u4EBA\u5728\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u5199\u7684\uFF1A\u8981\u5220\u5C31\u81EA\u5DF1\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\u5939",e)),m.rmSync(i,{recursive:!0,force:!0,maxRetries:5,retryDelay:100});for(let r of Object.keys(s))r.startsWith(`${e}/`)&&delete s[r];let{[e]:c,...o}=s.packs;return K(n,{...s,packs:o}),{id:e,version:a.version??null,blocks:Array.isArray(a.blocks)?a.blocks:[]}}var Le=n=>({zh:X("zh",n),en:X("en",n)});function pn(n,{settings:e=null,shippedIds:t=_(),directory:i=ge}={}){let{components:s}=H(n),a=P(n),c=b(a.packs)?a.packs:{},o=Ie(n),r=new Set([te,...o.map(({id:l})=>l.split("/")[0])]);try{for(let l of m.readdirSync(s))ye.test(l)&&m.existsSync(u.join(s,l,F))&&r.add(l)}catch{}let f=(e??V(n)).packs??{},d=[...r].map(l=>{let w=u.join(s,l),x=null,A=null;if(m.existsSync(u.join(w,F)))try{x=ie(m.readFileSync(u.join(w,F),"utf8")),x.id!==l&&(A=k("pack.json \u7684 id \u662F {0}\uFF0C\u5B83\u7684\u6587\u4EF6\u5939\u5374\u662F components/{1}",x.id,l),x=null)}catch(S){A=S}let N=b(c[l])?c[l]:null,g=o.filter(S=>S.id.startsWith(`${l}/`)),p=N?g.filter(S=>b(a[S.id])&&E(S.folder)!==a[S.id].fingerprint).map(S=>S.id):[];N&&ke(w)!==N.fingerprint&&p.push(`${l}/${F}`);let O=t.includes(l),$=null;if(O)try{$=ie(m.readFileSync(u.join(i,l,F),"utf8"))}catch{}let B=S=>{try{return JSON.parse(m.readFileSync(u.join(s,...S.split("/"),R),"utf8")).version??null}catch{return null}},I=O?D(i):[],we=O&&$&&p.some(S=>S.endsWith(`/${F}`)?L($.version,x?.version??null):I.some(U=>U.id===S)&&L(I.find(U=>U.id===S).version,B(S)))?$.version:null,C=l===te?Ee:x??(A?null:$);return{id:l,name:C?.name??{zh:l,en:l},description:C?.description??null,version:x?.version??null,author:C?.author??null,homepage:C?.homepage??null,icon:C?.icon??null,kind:l===te?"default":O?"official":N?"installed":"own",problem:A?Le(A):null,blocks:g.length,enabled:f[l]!==!1,changed:p,newer:we}}),y=({id:l,kind:w})=>w==="default"?-1:w==="official"?t.indexOf(l):w==="installed"?1e3:2e3;return d.sort((l,w)=>y(l)-y(w)||(l.id<w.id?-1:1))}function Re(n,e,t){let i=[],s=u.resolve(n);return t?i.push(`Gallery's pack ${e.id} ${e.version} installed in ${s} (${e.added.length+e.same.length+e.updated.length} blocks)${oe.includes(e.id)?", switched off: \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 turns it on":""}`):(e.added.length&&i.push(`Gallery's pack ${e.id} in ${s} has new blocks: ${e.added.join(", ")}`),e.updated.length&&i.push(`Gallery's pack ${e.id} in ${s}, its blocks as they were installed, updated to this Gallery's: ${e.updated.join(", ")}`),e.removed.length&&i.push(`Gallery's pack ${e.id} in ${s}: ${e.removed.join(", ")} no longer in it, taken out`)),i}async function un(n,{directory:e=ge,env:t=process.env,log:i=()=>{}}={}){if(Ge(t))return{did:"off",packs:[]};let s={ours:!1};try{s=Ne(m.readFileSync(H(n).marker,"utf8"))}catch{}if(!s.ours)return{did:"unread",packs:[]};let a=_(e),c=[];for(let o of a)try{let r=!b(P(n).packs?.[o]);r&&oe.includes(o)&&V(n).packs[o]===void 0&&await ce(n,{pack:o,enabled:!1});let f=De(n,Te(u.join(e,o)),{official:!0,shippedIds:a});c.push({...f,first:r});for(let d of Re(n,f,r))i(d)}catch(r){i(`Gallery's pack ${o} could not be installed in ${u.resolve(n)}: ${r?.message??r}`),c.push({id:o,failed:r?.message??String(r)})}return{did:"done",packs:c}}export{je as a,Y as b,_ as c,D as d,Ue as e,Ve as f,P as g,ne as h,xe as i,L as j,Xe as k,Fe as l,Ze as m,Qe as n,Ae as o,fn as p,Te as q,De as r,dn as s,pn as t,un as u};
|
package/dist/chunk-LMUZQK5O.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as h,b as v,d as p,e as S,h as j,j as I}from"./chunk-GMJD7ID3.mjs";import{a as A}from"./chunk-JEUK3ZO7.mjs";import{a as C}from"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import{g as O}from"./chunk-7M2BQQGZ.mjs";import{b as i,f as g,i as y}from"./chunk-4OZWXZE5.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import D from"node:path";import{pageLinks as F,pageOfLink as J}from"../browser/shared/page-links.mjs";import{reportsDirectory as E}from"../browser/shared/paths.mjs";import{findPreviewServer as K}from"../browser/shared/preview-server.mjs";import{topOf as M}from"../browser/shared/outline-shape.mjs";import{LINK_FILE as U,linkAddress as P,linkIcon as T}from"../browser/shared/web-links.mjs";var $=t=>t.replace(/\s+/g," ").trim(),k=t=>t==null?"none":JSON.stringify(t);async function x(t,e){let n=await K(),o=n?await j(n,e,t):null;if(o)return o;let[,s]=await C({edits:{},reports:{},reportsDirectory:E,web:{icon:a=>O(a)}}).run(t,e);return s}function _(t,e){let n=[...t.documents.values()].filter(({url:a})=>a!==void 0),o=J(F(n),e.replace(/^.*#/,""));return o?{slug:o,link:t.documents.get(o)}:{refused:t.documents.get(e)?`${p(t,e)} is a document, not a web link: gallery set changes a document.`:`No web link "${e}": gallery list --tree shows the sidebar's entries.`}}var W=(t,e)=>t.groups.find(n=>[v(n),n.id].some(o=>o.toLowerCase()===$(e).toLowerCase()))??null;async function B(t,e,n){if(t.length!==2)throw new i('Name the address and the name: gallery link add <url> "<name>".');let[o,s]=t,a=P(o);if(a.refused)throw new i(`Not an address a web link takes: ${o} (${{url:"no address",scheme:"http or https only",long:"2048 characters at most"}[a.refused]}).`);if(!$(s))throw new i("The name is never empty.");let d=n.get("--column"),u=n.get("--under"),l=n.get("--after"),c=n.get("--icon");if(d!==void 0&&u!==void 0)throw new i("--column and --under are two places: give one.");if(l!==void 0&&e.has("--first"))throw new i("--after and --first are two places: give one.");if(c!==void 0&&!T(c))throw new i(`Not an icon a web link takes: ${c} (an emoji, or an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg).`);let f=await h(),w;if(d!==void 0){let L=W(f,d);L||(console.error(`No column "${d}" in the sidebar (${f.groups.map(v).join(", ")}): nothing added.`),process.exit(1)),w=M(L.id)}u!==void 0&&(w=(await y(u)).slug);let r=l===void 0?null:(await y(l)).slug,q=e.has("--first")||u===void 0&&r===null,m=await x("link",{url:a.url,title:$(s),...c?{icon:c}:{},...w!==void 0?{parent:w}:{},after:r,first:q});m?.ok||(console.error(`Not added: ${m?.message??m?.reason??"no answer"}.`),process.exit(1));let b=await h(),{slug:N,url:z}=m.link;console.log(`Added the web link ${p(b,N)}: ${z}`),console.log(`Placed it ${I(b,{parent:m.parent,index:m.index})}.`),console.log(S(b,N)),console.log(`It is ${A(D.join(E,N,U))}; the workbench shows the page beside the sidebar (a site that refuses frames: \u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00).`)}async function G(t,e){if(t.length!==1)throw new i("Name one web link, then what to set: --url, --title, --icon.");if(!["--url","--title","--icon"].some(r=>e.has(r)))throw new i('Say what to set: --url <address>, --title "<name>", --icon <emoji|none>.');let n=e.has("--title")?$(e.get("--title")):void 0;if(n==="")throw new i("--title takes the words of the name: a web link's name is never empty.");let o;if(e.has("--url")){let r=P(e.get("--url"));if(r.refused)throw new i(`Not an address a web link takes: ${e.get("--url")}.`);o=r.url}let s;if(e.has("--icon")){let r=e.get("--icon").trim();if(r!=="none"&&!T(r))throw new i(`Not an icon a web link takes: ${r} (an emoji, none, or an icon of the \u56FE\u6807 tab).`);s=r==="none"?null:r}let a=await h(),d=_(a,t[0]);d.refused&&(console.error(d.refused),process.exit(1));let{slug:u,link:l}=d,c=await x("link-set",{slug:u,...o!==void 0?{url:o}:{},...n!==void 0?{title:n}:{},...s!==void 0?{icon:s}:{}});c?.ok||(console.error(`Not set: ${c?.message??c?.reason??"no answer"}.`),process.exit(1));let f=c.link,w=[...n!==void 0&&n!==l.title?[` title: ${k(l.title)} \u2192 ${k(f.title)}`]:[],...o!==void 0&&f.url!==l.url?[` url: ${l.url} \u2192 ${f.url}`]:[],...s!==void 0&&(f.icon??null)!==(l.icon??null)?[` icon: ${k(l.icon)} \u2192 ${k(f.icon??null)}`]:[]];if(!w.length)return void console.log(`Nothing to change: ${u} has ${e.size===1?"that already":"those already"}.`);console.log(`Set the web link ${u}:`);for(let r of w)console.log(r)}async function H(t){if(t.length!==1)throw new i("Name one web link to move to the trash.");let e=await h(),n=_(e,t[0]);n.refused&&(console.error(n.refused),process.exit(1));let o=await x("trash",{slug:n.slug,kind:"link"});o?.ok||(console.error(`Not moved to the trash: ${o?.message??o?.reason??"no answer"}.`),process.exit(1)),console.log(`Moved the web link ${p(e,n.slug)} to the trash: the workbench's \u8BBE\u7F6E \u203A \u56DE\u6536\u533A restores it where it was.`)}async function se(t){let[e,...n]=t;if(e==="add"){let{positional:o,options:s,values:a}=g({options:["--first"],values:["--column","--under","--after","--icon"],argv:n});return B(o,s,a)}if(e==="set"){let{positional:o,values:s}=g({values:["--url","--title","--icon"],argv:n});return G(o,s)}if(e==="remove"){let{positional:o}=g({argv:n});return H(o)}throw new i(e?`No such action: link ${e} (add, set, remove).`:"Say what to do: gallery link add, set or remove.")}export{se as run};
|
package/dist/chunk-MKIBJTJZ.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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-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&>.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
|
-
${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
|
-
`)),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
|
-
`));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)}
|
|
6
|
-
`)}}finally{await m.close()}let gt=mo([...Map.groupBy(X,({folder:N})=>N)].map(([N,Q])=>({folder:N,files:Q.flatMap(({files:h})=>h)})));gt&&console.log(gt),console.log(vo(z,[...$.values()],A,{unpictured:!Y})),process.exitCode=z.fail?1:z.unverified?3:0}export{Yo as a,Bt as b,we as c,Ko as d,$e as e,ze as f,Ee as g,Ge as h,qe as i,Ye as j,Ke as k,Ae as l,Xe as m,Je as n,xe as o,Qe as p,ye as q,Ze as r,be as s,to as t,eo as u,oo as v,Yt as w,no as x,Kt as y,Be as z,ao as A,Oe as B,io as C,Se as D,ro as E,lo as F,ho as G,fo as H,Xt as I,uo as J,go as K,Re as L,mo as M,Te as N,nn as O,Ne as P,Ce as Q,wo as R,Gt as S,$o as T,xo as U,yo as V,bo as W,So as X,ko as Y,vo as Z,Mo as _,Eo as $,qo as aa,Ao as ba,sn as ca};
|
package/dist/chunk-MNWJ4EZY.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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-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};
|
package/dist/chunk-NHP66IWR.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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-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
|
-
`)));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
|
-
`));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
|
-
`)));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};
|
package/dist/chunk-OEIJLMPI.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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-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};
|
package/dist/chunk-PDZR3L3C.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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-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};
|
package/dist/chunk-PUOQ65NC.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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{spawn as O}from"node:child_process";import{existsSync as I}from"node:fs";import C from"node:fs/promises";import _ from"node:os";import q from"node:path";import{APART as S}from"../browser/editor/components/registry.mjs";var N=6e4,x=600,B=["A4","A3","Letter","Legal","Tabloid"];function F(){if(process.env.GALLERY_BROWSER)return process.env.GALLERY_BROWSER;let{PROGRAMFILES:o="","PROGRAMFILES(X86)":e="",LOCALAPPDATA:r="",HOME:i=""}=process.env;return({win32:[`${o}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Google\\Chrome\\Application\\chrome.exe`,`${r}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Microsoft\\Edge\\Application\\msedge.exe`,`${o}\\Microsoft\\Edge\\Application\\msedge.exe`],darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium",...i?[`${i}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`${i}/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${i}/Applications/Chromium.app/Contents/MacOS/Chromium`]:[]],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome","/usr/bin/microsoft-edge","/usr/bin/microsoft-edge-stable","/opt/microsoft/msedge/msedge","/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"]}[process.platform]??[]).find(s=>s&&I(s))??null}var $=()=>process.getuid?.()===0?["--no-sandbox"]:[],te=()=>["--no-first-run","--no-default-browser-check","--disable-extensions","--hide-scrollbars","--lang=zh-CN",...$()];function oe(o,e,r=[]){let i=o.location()?.url??"";return!/^Failed to load resource|^Refused to |Content Security Policy/.test(o.text())&&(!i||i.startsWith(e)||r.includes(i))}var re=o=>o.evaluateOnNewDocument(()=>{globalThis.__qaViolations=[],document.addEventListener("securitypolicyviolation",e=>{globalThis.__qaViolations.push({url:e.blockedURI,directive:e.effectiveDirective||e.violatedDirective,source:e.sourceFile,line:e.lineNumber})})}),V=3e4,W=5e3;function ie(o,e=W){let r=0,i=new Promise(c=>{r=setTimeout(c,e)});return Promise.race([Promise.resolve(o).catch(()=>{}),i]).finally(()=>clearTimeout(r))}var E=o=>new Promise(e=>setTimeout(e,o).unref()),D=o=>String(o??"").replace(/\s+/g," ").trim(),M=o=>{let e=o.split(/\r?\n/).map(D).filter(Boolean).at(-1);return e?`: ${e.slice(0,200)}`:""};async function se({executablePath:o,args:e=[],attempts:r=2,start:i=H}){let c=[];for(let s=0;s<r;s+=1){let n=await C.mkdtemp(q.join(_.tmpdir(),"gallery-browser-")),t=()=>C.rm(n,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});try{let{browser:a,stop:l}=await i({executablePath:o,args:e,profile:n});return{browser:a,failures:c,close:async()=>{await l().catch(()=>{}),await t()}}}catch(a){c.push(D(a?.message??a)),await t()}}throw Object.assign(new Error(c.at(-1)??"the browser did not start"),{failures:c})}async function H({executablePath:o,args:e,profile:r,starting:i=V}){let{default:c}=await import("./chunk-ERLAIBOA.mjs"),s=await c.defaultArgs({headless:!0,userDataDir:r,args:[...e,"--remote-debugging-port=0"]}),n=process.platform!=="win32",t=O(o,s,{stdio:["ignore","ignore","pipe"],windowsHide:!0,detached:n}),a=!1;t.on("error",()=>a||=t.pid===void 0);let l=()=>a||t.exitCode!==null||t.signalCode!==null,u=new Promise(f=>t.once("exit",f)),m=()=>{if(!l())try{n?process.kill(-t.pid,"SIGKILL"):t.kill()}catch{try{t.kill("SIGKILL")}catch{}}};process.once("exit",m);let p="",d=new Promise((f,w)=>{let g=setTimeout(()=>w(new Error(`it said nothing of its DevTools port in ${i/1e3}s${M(p)}`)),i);t.stderr.setEncoding("utf8"),t.stderr.on("data",h=>{p=`${p}${h}`.slice(-4e3);let y=/DevTools listening on (ws:\/\/\S+)/.exec(p);y&&(clearTimeout(g),f(y[1]))}),t.once("error",h=>(clearTimeout(g),w(h))),t.once("exit",(h,y)=>(clearTimeout(g),w(new Error(`it stopped (${y??`exit ${h}`}) before it opened its DevTools port${M(p)}`))))}),A=async()=>{try{l()||await Promise.race([u,E(5e3)]),m(),l()||await Promise.race([u,E(3e3)])}finally{process.off("exit",m)}},v;try{let f=await d,w=0,g=new Promise((y,G)=>{w=setTimeout(()=>G(new Error(`it opened its DevTools port and did not answer in ${i/1e3}s`)),i)}),h=c.connect({browserWSEndpoint:f,defaultViewport:{width:800,height:600}});h.catch(()=>{}),v=await Promise.race([h,g]).finally(()=>clearTimeout(w))}catch(f){throw m(),await A(),f}return{browser:v,stop:async()=>{await Promise.race([v.close().catch(()=>{}),E(5e3)]),await A()}}}var b=null,L=0,T=0;async function K(){let o=F();if(!o)throw Object.assign(new Error("\u6CA1\u6709\u627E\u5230 Chrome \u6216 Edge\uFF1A\u5BFC\u51FA PDF \u9700\u8981\u7535\u8111\u4E0A\u88C5\u6709\u5176\u4E2D\u4E00\u4E2A\u6D4F\u89C8\u5668"),{reason:"browser"});let{default:e}=await import("./chunk-ERLAIBOA.mjs");return e.launch({executablePath:o,headless:!0,args:["--no-first-run","--no-default-browser-check","--disable-extensions",...$()]})}async function R(o,e){clearTimeout(L),T+=1,b??=K().catch(i=>{throw b=null,i});let r=await(await b).newPage();try{return await r.emulateMediaFeatures([{name:"prefers-reduced-motion",value:"reduce"},{name:"prefers-color-scheme",value:"light"}]),await r.setViewport({width:1200,height:900}),await r.setContent(o,{waitUntil:"load",timeout:6e4}),await P(r,{changing:x}),await e(r)}finally{await r.close().catch(()=>{}),T-=1,T===0&&(L=setTimeout(async()=>{let i=b;b=null,(await i?.catch(()=>null))?.close().catch(()=>{})},N))}}async function P(o,{timeout:e=15e3,changing:r=e}={}){let i=[],c=(n,t,a=e)=>{t!==!0&&i.push(`${n} (${t===!1?`not in ${a/1e3}s`:t})`)},s=(n,t=e)=>o.evaluate(n,t).catch(a=>a.message);return c("the fonts loaded",await s(n=>Promise.race([Promise.resolve(document.fonts?.ready).then(()=>!0),new Promise(t=>setTimeout(()=>t(!1),n))]))),c("the kit's first drawing done (data-doc-drawn)",await s(n=>new Promise(t=>{let a=Date.now(),l=()=>{!globalThis.DocKit||document.documentElement.hasAttribute("data-doc-drawn")?(globalThis.DocCode?.colorAll?.(),t(!0)):Date.now()-a>n?t(!1):setTimeout(l,50)};l()}))),c("the page done changing",await s(n=>new Promise(t=>{let a=()=>[document.documentElement.scrollHeight,...[...document.querySelectorAll("[style]")].map(d=>d.getAttribute("style")),...[...document.adoptedStyleSheets??[]].flatMap(d=>[...d.cssRules].map(A=>A.cssText)),...[...document.querySelectorAll("svg, canvas")].map(d=>d.outerHTML.length),[...document.images].filter(d=>d.complete).length].join("|"),l=Date.now(),u=a(),m=0,p=()=>{let d=a();m=d===u?m+1:0,u=d,m>=3?t(!0):Date.now()-l>n?t(!1):setTimeout(p,100)};setTimeout(p,100)}),r),r),i}async function k(o){await o.evaluate(()=>{document.documentElement.setAttribute("data-doc-theme","light");for(let e of document.querySelectorAll("[data-doc-sheets]")){let r=e.querySelector(":scope > .doc-sheet-tabs");if(r){for(let i of r.querySelectorAll(":scope > .doc-sheet-tab")){let c=i.getAttribute("data-sheet-tab"),s=[...e.querySelectorAll(":scope > [data-doc-sheet]")].find(a=>a.getAttribute("data-doc-sheet")===c);if(!s)continue;s.hidden=!1,s.removeAttribute("aria-hidden"),s.style.setProperty("display","block","important");let n=r.cloneNode(!1);n.removeAttribute("id"),n.removeAttribute("role"),n.style.setProperty("break-after","avoid");let t=i.cloneNode(!0);t.removeAttribute("id"),t.setAttribute("aria-selected","true"),t.classList.add("is-active"),n.append(t),s.before(n)}r.style.setProperty("display","none","important")}}for(let e of document.querySelectorAll("details"))e.open=!0;window.dispatchEvent(new Event("resize"))}),await P(o,{changing:x})}var j={A4:793.7,A3:1122.5,Letter:816,Legal:816,Tabloid:1056},z=96;async function U(o,e){await o.emulateMediaType("print");let r=await o.evaluate(()=>Math.max(0,innerWidth-document.documentElement.clientWidth));await o.setViewport({width:Math.floor(e)+r,height:900}),await P(o,{changing:x})}function ne(o,{paper:e="A4",scale:r=1}={}){let i=B.includes(e)?e:"A4",c=Math.min(2,Math.max(.1,r));return R(o,async s=>(await k(s),await U(s,(j[i]-2*z)/c),Buffer.from(await s.pdf({format:i,scale:c,printBackground:!0,margin:{top:"1in",right:"1in",bottom:"1in",left:"1in"}}))))}function ae(o){return R(o,async e=>{await k(e);let r=e.viewport(),i=await e.$$("main figure.doc-figure"),c=[];for(let s of i){let n=0;try{n=await s.evaluate(async(t,a)=>{let l=[];for(let u=t.closest(a);u;u=u.parentElement.closest(a))l.unshift(u);for(let u of l)u.style.setProperty("height","auto"),u.style.setProperty("max-height","calc(100dvh - (2 * var(--doc-dialog-margin)))"),u.showModal();return await new Promise(u=>requestAnimationFrame(()=>requestAnimationFrame(u))),l.length?Math.ceil(t.getBoundingClientRect().height):0},S),n&&(await e.setViewport({...r,height:r.height+n}),await P(e,{changing:x})),await s.evaluate(t=>t.scrollIntoView({block:"center"})),c.push(Buffer.from(await s.screenshot({type:"png"})))}catch{c.push(null)}await s.evaluate((t,a)=>{for(let l=t.closest(a);l;l=l.parentElement.closest(a))l.close(),l.style.removeProperty("height"),l.style.removeProperty("max-height"),l.getAttribute("style")||l.removeAttribute("style")},S).catch(()=>{}),n&&await e.setViewport(r).catch(()=>{})}return c})}export{F as a,te as b,oe as c,re as d,W as e,ie as f,se as g,P as h,ne as i,ae as j};
|
package/dist/chunk-Q4MS6OFC.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a,b,c}from"./chunk-PDZR3L3C.mjs";import"./chunk-BN7M3IN7.mjs";import"./chunk-ZFGMJVJC.mjs";import"./chunk-QP7BOHE4.mjs";import"./chunk-GMJD7ID3.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_DESCRIPTION,c as run,b as slugRefused};
|