@aiquants/markdown-explorer 0.35.0 → 0.36.0
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/CHANGELOG.md +93 -0
- package/README.md +31 -2
- package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
- package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
- package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
- package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
- package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
- package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
- package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
- package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
- package/dist/TreeLayout-DsSKW_Qj.js +103 -0
- package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
- package/dist/core/config.d.cts +6 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/contracts.d.cts +21 -0
- package/dist/core/contracts.d.ts +21 -0
- package/dist/core/dataRoute.d.cts +5 -1
- package/dist/core/dataRoute.d.ts +5 -1
- package/dist/core/documentId.d.cts +6 -0
- package/dist/core/documentId.d.ts +6 -0
- package/dist/core/labels.d.cts +10 -0
- package/dist/core/labels.d.ts +10 -0
- package/dist/core/location.d.cts +21 -0
- package/dist/core/location.d.ts +21 -0
- package/dist/explorerCore-B3RGmMG6.js +1083 -0
- package/dist/explorerCore-CUkyKtm8.cjs +1 -0
- package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
- package/dist/index-lpL7GltU.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +38 -33
- package/dist/location-Dh6K-y7w.js +761 -0
- package/dist/location-DrOP6t1F.cjs +1 -0
- package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
- package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
- package/dist/ownUrls-BTPGNhBt.cjs +1 -0
- package/dist/ownUrls-DD0cSCsF.js +409 -0
- package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
- package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
- package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
- package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +3 -3
- package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
- package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +19 -0
- package/dist/server/ports.d.ts +19 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +6 -6
- package/dist/serverBrowser.cjs +1 -1
- package/dist/serverBrowser.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +4 -4
- package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
- package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +80 -2
- package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
- package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/security.md +23 -2
- package/docs/behavior/url-contract.md +26 -0
- package/package.json +2 -2
- package/dist/TreeLayout-AxLw-36S.js +0 -103
- package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
- package/dist/explorerCore-DLpDuSev.js +0 -998
- package/dist/explorerCore-DYrxS9ez.cjs +0 -1
- package/dist/index-LQWQfpAf.cjs +0 -18
- package/dist/location--KvTA0Ri.js +0 -726
- package/dist/location-D8DyDkuA.cjs +0 -1
- package/dist/ownUrls-B259RGgd.cjs +0 -1
- package/dist/ownUrls-Dh5g6ZJi.js +0 -370
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const A=require("@aiquants/markdown/embeds"),O=require("@aiquants/markdown/viewer-settings"),g=require("./ownUrls-BTPGNhBt.cjs"),i=require("./describeValue-Ccvhbt36.cjs"),Ye=Object.freeze(["UTF-8","IBM866","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-8-I","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic","GBK","gb18030","Big5","EUC-JP","ISO-2022-JP","Shift_JIS","EUC-KR","replacement","UTF-16BE","UTF-16LE","x-user-defined"]),Je=new Map(Ye.map(e=>[e.toLowerCase(),e])),$="UTF-8",ae=Object.freeze([Object.freeze({bytes:Object.freeze([239,187,191]),encoding:$}),Object.freeze({bytes:Object.freeze([255,254]),encoding:"UTF-16LE"}),Object.freeze({bytes:Object.freeze([254,255]),encoding:"UTF-16BE"})]),Ze=new Map([[$,"is read before any legacy encoding"],["UTF-16LE","is read only by its byte order mark"],["UTF-16BE","is read only by its byte order mark"],["ISO-2022-JP","writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],["x-user-defined","is no text encoding (it maps bytes to private-use characters)"]]),Q=e=>{let r;try{r=new TextDecoder(e).encoding}catch(o){throw o instanceof RangeError?new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`):o}const t=Qe(r),n=Ze.get(t);if(n!==void 0)throw new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} names ${t}, which cannot be the legacy encoding: it ${n}`);return t},Qe=e=>{const r=Je.get(e);if(r===void 0)throw new RangeError(`[markdown-explorer] TextDecoder answered ${i.describeValue(e)}, which is no encoding of the WHATWG Encoding Standard`);return r},M=(e,r,t)=>{const n=t===null?null:Q(t),o=ae.find(({bytes:a})=>a.every((d,l)=>e[l]===d));if(o!==void 0)return{body:e.subarray(o.bytes.length),encodings:[o.encoding]};const s=r||e.length===0?void 0:ae.find(({bytes:a})=>e.length<a.length&&e.every((d,l)=>a[l]===d));return s!==void 0?{body:e.subarray(e.length),encodings:[s.encoding]}:{body:e,encodings:n===null?[$]:[$,n]}},er=(e,r,t)=>M(e,r,t).encodings,rr=(e,r,t)=>{try{return new TextDecoder(e,{fatal:!0,ignoreBOM:!0}).decode(r,{stream:!t})}catch(n){if(n instanceof TypeError)return null;throw n}},tr=(e,r,t)=>{const n=ee(M(e,r,t),r);return n===null?null:n.text},ee=({body:e,encodings:r},t)=>{for(const n of r){const o=rr(n,e,t);if(o!==null)return{encoding:n,text:o}}return null},nr=(e,r,t)=>{const n=M(e,r,t),o=ee(n,r);return o===null?n.encodings[0]:o.encoding},or=(e,r,t)=>{const n=M(e,r,t),o=ee(n,r);return o!==null?o.text:new TextDecoder(n.encodings[0],{ignoreBOM:!0}).decode(n.body,{stream:!r})},L=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),ir=/^readme(?:\.|$)/iu,de=/^readme(?:\.[^.]*)?$/iu,le=Object.freeze(["md","markdown","mdx","txt",""]),sr=e=>ir.test(e),X=e=>e.type==="file"&&sr(e.name),ce=e=>{const r=e.lastIndexOf("."),t=le.indexOf(r<0?"":e.slice(r+1).toLowerCase());return t<0?le.length:t},ar=(e,r)=>{const t=+!de.test(e.name)-+!de.test(r.name);if(t!==0)return t;const n=ce(e.name)-ce(r.name);if(n!==0)return n;const o=L.compare(e.name,r.name);return o!==0?o:L.compare(e.path,r.path)},dr=e=>{let r=null;for(const t of e)X(t)&&(r===null||ar(t,r)<0)&&(r=t);return r===null?null:r.path},W=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,showFolderReadme:!0,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),he=[!0,!1],pe=(e,r)=>r?e.settingOn:e.settingOff,T=(e,r)=>({key:e,labelKey:r,values:he,formatValue:pe,requiresTreeView:!1}),lr=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),I=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,r)=>lr[r](e),requiresTreeView:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.folderPlacementMixed:r==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresTreeView:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.readmePlacementMixed:r==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresTreeView:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,r)=>r==="single"?e.selectionSingle:r==="multiple"?e.selectionMultiple:e.selectionNone,requiresTreeView:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,r)=>r==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresTreeView:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,r)=>e.expandIconSizeValue(r),requiresTreeView:!1},T("alwaysExpanded","settingAlwaysExpanded"),T("revealDocument","settingRevealDocument"),{key:"showFolderReadme",labelKey:"settingShowFolderReadme",values:he,formatValue:pe,requiresTreeView:!0},T("removeRootIndent","settingRemoveRootIndent"),T("lines","settingTreeLines"),T("expandIcons","settingExpandIcons"),T("directoryIcons","settingDirectoryIcons"),T("fileIcons","settingFileIcons")]),cr=e=>e==="tree"?I:I.filter(r=>!r.requiresTreeView),be=e=>{const r=I.find(t=>t.key===e);if(r===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return r},ur=(e,r)=>{const t=be(r).values,n=t[(t.indexOf(e[r])+1)%t.length];return{...e,[r]:n}},mr=(e,r,t)=>be(t).formatValue(e,r[t]),xe=2,H=Object.freeze({}),re=(e,r)=>Object.freeze(Object.fromEntries(I.filter(t=>r(t,e[t.key])).map(t=>[t.key,e[t.key]]))),ue="directoriesFirst",fr=e=>{if(!Object.hasOwn(e,ue))return e;const{[ue]:r,...t}=e;return Object.hasOwn(t,"folderPlacement")||typeof r!="boolean"?t:{...t,folderPlacement:r?"first":"mixed"}},wr=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return H;const r=e;return r.version!==xe||r.settings===null||typeof r.settings!="object"||Array.isArray(r.settings)?H:re(fr(r.settings),(t,n)=>t.values.includes(n))},gr=(e,r)=>{const t=re(r,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(t).length===0?e:Object.freeze({...e,...t})},Er=(e,r,t,n)=>re({...e,[r]:t},(o,s)=>s!==void 0&&!(o.key===r&&s===n[r])),hr=e=>JSON.stringify({version:xe,settings:e}),pr=(e,r,t)=>e===void 0||r===void 0?e===r?0:e===void 0?1:-1:t*(e-r),br=e=>{const{sortMode:r,folderPlacement:t,readmePlacement:n}=e;if(r==="native"&&t==="mixed"&&n==="mixed")return;const o=(s,a)=>{const d=L.compare(s.name,a.name);return d!==0?d:L.compare(s.path,a.path)};return(s,a)=>{if(t!=="mixed"&&s.type!==a.type)return s.type==="directory"==(t==="first")?-1:1;if(n!=="mixed"){const l=X(s);if(l!==X(a))return l===(n==="first")?-1:1}if(r==="native")return 0;if(r==="asc")return o(s,a);if(r==="desc")return-o(s,a);const d=pr(s.modifiedAt,a.modifiedAt,r==="oldest"?1:-1);return d!==0?d:o(s,a)}},b=(1+Math.sqrt(5))/2,xr=100/b**3,Sr=100/b**4,te=100/b**2,Se=13,Or=16,Tr=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),K=Object.freeze([1,2,3,5,8,13,21,34,55]),yr=Object.freeze([89,144,233,377]),ne=44,_r=ne,Ir=24;2*K[3]+ne+K[0];const Rr=1/b,kr=1/b**3,Pr="40ch",Ar=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${i.describeValue(e)}`)},Oe=e=>(Ar(e),Se*e),Lr=e=>Oe(e)*b**2,Nr=233,vr=50,Te=100/b**3,Dr=100-Te,$r=yr[0],x=(e,r)=>{if(!Number.isFinite(r)||r<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${i.describeValue(r)}`)},Cr=({trackInlineSize:e,gap:r,minColumnInlineSize:t,logicalColumns:n})=>{if(x("trackInlineSize",e),x("gap",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${i.describeValue(t)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${i.describeValue(n)}`);const o=Math.floor((e+r)/(t+r));return Math.min(n,Math.max(1,o))},Vr=(e,r)=>{const{trackInlineSize:t,gap:n,minColumnInlineSize:o,logicalColumns:s}=r;if(!([t,n,o].every(Number.isFinite)&&t>0&&n>=0&&o>0))return e;const d=Cr(r);if(e===null||d===e)return d;const l=Math.min(s,Math.max(1,e));if(d>l){const f=(l+1)*o+l*n+n/b;return t>=f?d:l}return t>=l*o+(l-1)*n?l:d},Mr=(e,r)=>{if(!(Number.isInteger(e)&&Number.isInteger(r))||r<1||r>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${i.describeValue(r)}`);return Array.from({length:r},(t,n)=>[Math.floor(n*e/r),Math.floor((n+1)*e/r)])},zr=(e,r,t)=>{if(x("surfaceInlineSize",e),x("handlePixels",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${i.describeValue(r)}`);return e>=2*r+t?"beside":"stacked"},B=(e,r,t)=>Math.max(r,Math.min(e,t)),me=(e,r,t,n)=>{const o=(B(e,0,t)+B(r,0,t))/2;return B(o-n/2,0,t-n)},jr=(e,r,t)=>{for(const[n,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${i.describeValue(o)}`);return x("marginBox.width",r.width),x("marginBox.height",r.height),x("viewport.width",t.width),x("viewport.height",t.height),{left:me(e.left,e.right,t.width,r.width),top:me(e.top,e.bottom,t.height,r.height)}},Fr=31536e3,Ur=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Gr=e=>{if(typeof e!="string"||!Ur.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${i.describeValue(e)}`)},fe=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=te,D=(e,r)=>typeof r=="string"&&e.includes(r),Br=(e,r)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const t=e,{treeExplorer:n,treeExplorerHidden:o,multiExplorer:s,multiExplorerHidden:a,style:d,align:l,measure:m,documentColors:f}=t;return{...fe(n)?{treeExplorer:n}:{},...o===!0?{treeExplorerHidden:o}:{},...fe(s)?{multiExplorer:s}:{},...a===!0?{multiExplorerHidden:a}:{},...D(r,d)?{style:d}:{},...D(O.CONTENT_ALIGNS,l)?{align:l}:{},...D(O.CONTENT_MEASURES,m)?{measure:m}:{},...D(O.CONTENT_COLORS,f)?{documentColors:f}:{}}},Xr=(e,r)=>{if(e!==null)for(const t of e.split(";")){const n=t.indexOf("=");if(!(n<0)&&t.slice(0,n).trim()===r)return t.slice(n+1).trim()}},Wr=(e,r)=>{if(e===void 0||e==="")return{};try{return Br(JSON.parse(decodeURIComponent(e)),r)}catch{return{}}},C=100,Hr=Math.floor(te*C)/C,ye=e=>{const r=t=>Math.min(Hr,Math.max(1,Math.round(t*C))/C);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:r(e.treeExplorer)},...e.treeExplorerHidden===!0?{treeExplorerHidden:!0}:{},...e.multiExplorer===void 0?{}:{multiExplorer:r(e.multiExplorer)},...e.multiExplorerHidden===!0?{multiExplorerHidden:!0}:{},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align},...e.measure===void 0?{}:{measure:e.measure},...e.documentColors===void 0?{}:{documentColors:e.documentColors}}))},Kr=(e,r,t)=>`${e}=${ye(r)}; Path=/; Max-Age=${String(Fr)}; SameSite=Lax${t?"; Secure":""}`,q=Object.freeze({tree:"tree",multi:"multi",single:"single"}),_e=Object.freeze({default:12,min:1,max:64}),Ie=Object.freeze({default:4,min:1,max:6}),Re=Object.freeze({default:500,min:1,max:1e4}),ke=Object.freeze({default:16,min:1,max:64}),Pe=Object.freeze({default:16,min:1,max:64}),Ae=Object.freeze({default:2*1024*1024,min:1,max:256*1024*1024}),Le=Object.freeze({default:8*1024*1024,min:1,max:256*1024*1024}),Ne=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,qr=/^[a-z0-9][a-z0-9-]*$/u,Yr=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,Y=(e,r)=>{if(typeof r!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${i.describeValue(r)}`);if(!g.isMountPath(r))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${i.describeValue(r)}`)},we=Object.freeze(Object.keys({basePath:!0,dataPath:!0,settingsCookie:!0,views:!0,documentIds:!0,multiView:!0,expandAll:!0,revealDocument:!0,documentStyles:!0,defaultDocumentStyle:!0,iframeHosts:!0,appOrigins:!0,mediaDataPath:!0,embeds:!0,defaultTreeSettings:!0,legacyTextEncoding:!0,spreadsheets:!0})),S=(e,r,t)=>{if(r===void 0)return[];if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${i.describeValue(r)}`);const n=Object.entries(r);for(const[o]of n)if(!t.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${t.join(", ")}`);return n.filter(([,o])=>o!==void 0)},Jr=e=>{const r={...q};for(const[t,n]of S("views",e,Object.keys(q)))r[t]=n;for(const[t,n]of Object.entries(r))if(typeof n!="string"||!Ne.test(n))throw new RangeError(`[markdown-explorer] views.${t} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(n)}`);return Object.freeze(r)},Zr=e=>{if(e===void 0)return null;const r=S("documentIds",e,["slug"]).find(([t])=>t==="slug")?.[1];if(typeof r!="string"||!Ne.test(r))throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(r)}`);return Object.freeze({slug:r})},y=(e,r,t)=>{if(r===void 0)return t.default;if(typeof r!="number"||!Number.isInteger(r)||r<t.min||r>t.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(t.min)}..${String(t.max)}; got ${i.describeValue(r)}`);return r},Qr=(e,r)=>{const t=new Map(S("embeds",e,["providers","linkCards","linkCardSize"]));if(t.size===0)return A.NO_EMBEDS;const n=t.has("providers")?t.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${i.describeValue(n)}`);for(const d of n)if(!A.isEmbedProviderId(d))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${A.EMBED_PROVIDER_IDS.join(", ")}; got ${i.describeValue(d)}`);const o=t.has("linkCards")?t.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${i.describeValue(o)}`);const s={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?g.explorerLinkCardEndpoint(r):null};if(!t.has("linkCardSize"))return Object.freeze(s);const a=t.get("linkCardSize");if(!A.isLinkCardSize(a))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${A.LINK_CARD_SIZES.join(", ")}; got ${i.describeValue(a)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${i.describeValue(a)} with linkCards ${i.describeValue(o)}`);return Object.freeze({...s,linkCardSize:a})},et=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${i.describeValue(e)}`);return Q(e)},rt=e=>{if(e===void 0)return Object.freeze([]);if(!Array.isArray(e))throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${i.describeValue(e)}`);for(const[r,t]of e.entries()){if(typeof t!="string")throw new TypeError(`[markdown-explorer] appOrigins[${String(r)}] must be a string; got ${i.describeValue(t)}`);if(!g.isBrowserOrigin(t))throw new RangeError(`[markdown-explorer] appOrigins[${String(r)}] must be an origin as the browser writes it (scheme://host[:port], without a default port, path, query, fragment or user info); got ${i.describeValue(t)}`)}return Object.freeze([...new Set(e)])},tt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${i.describeValue(e)}`);if(!g.isMediaDataUrl(e))throw new RangeError(`[markdown-explorer] mediaDataPath must be an absolute http: or https: URL as the browser writes it, of an origin and a path that starts with "/", has no trailing "/", uses only letters, digits and "._~-" in each segment and has no "." or ".." segment, without a query, fragment or user info; got ${i.describeValue(e)}`);return e},nt=e=>{const r=new Map(S("defaultTreeSettings",e,I.map(n=>n.key)));if(r.size===0)return W;const t={...W};for(const n of I){if(!r.has(n.key))continue;const o=r.get(n.key),s=n.values;if(!s.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(i.describeValue).join(", ")}; got ${i.describeValue(o)}`);t[n.key]=o}return Object.freeze(t)},ve=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");for(const c of Object.keys(e))if(!we.includes(c))throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${we.join(", ")}`);Y("basePath",e.basePath),Y("dataPath",e.dataPath);const r=Jr(e.views);if(new Set([r.tree,r.multi,r.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got tree ${i.describeValue(r.tree)}, multi ${i.describeValue(r.multi)} and single ${i.describeValue(r.single)}`);const t=Zr(e.documentIds);if(t!==null&&[r.tree,r.multi,r.single].includes(t.slug))throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${i.describeValue(t.slug)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const c=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(c===r.tree||c===r.multi||c===r.single||c===t?.slug)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${i.describeValue(e.dataPath)}`)}Gr(e.settingsCookie);const n=e.iframeHosts??[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${i.describeValue(n)}`);for(const[c,w]of n.entries())if(typeof w!="string"||!Yr.test(w))throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${i.describeValue(w)}`);const o=Object.fromEntries(S("multiView",e.multiView,["maxPanels","columns"])),s=Object.fromEntries(S("expandAll",e.expandAll,["maxFolders","maxDepth"])),a=Object.fromEntries(S("revealDocument",e.revealDocument,["maxDepth"])),d=Object.fromEntries(S("spreadsheets",e.spreadsheets,["maxBytes","maxWorkbookBytes"])),l=e.documentStyles??O.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(l)||l.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const m=new Set;for(const c of l){if(c===null||typeof c!="object"||typeof c.name!="string"||c.name.trim()===""||typeof c.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(m.has(c.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${i.describeValue(c.name)} repeats`);m.add(c.name)}const f=e.defaultDocumentStyle===void 0?O.DEFAULT_MARKDOWN_STYLE:e.defaultDocumentStyle;if(typeof f!="string")throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${i.describeValue(f)}`);if(!m.has(f)){const c=e.defaultDocumentStyle===void 0?" (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)":"";throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...m].map(i.describeValue).join(", ")}); got ${i.describeValue(f)}${c}`)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:r,documentIds:t,multiView:Object.freeze({maxPanels:y("multiView.maxPanels",o.maxPanels,_e),columns:y("multiView.columns",o.columns,Ie)}),expandAll:Object.freeze({maxFolders:y("expandAll.maxFolders",s.maxFolders,Re),maxDepth:y("expandAll.maxDepth",s.maxDepth,ke)}),revealDocument:Object.freeze({maxDepth:y("revealDocument.maxDepth",a.maxDepth,Pe)}),documentStyles:Object.freeze(l.map(c=>Object.freeze({name:c.name,className:c.className}))),defaultDocumentStyle:f,iframeHosts:Object.freeze([...new Set(n)]),appOrigins:rt(e.appOrigins),mediaDataPath:tt(e.mediaDataPath),embeds:Qr(e.embeds,e.dataPath),defaultTreeSettings:nt(e.defaultTreeSettings),legacyTextEncoding:et(e.legacyTextEncoding),spreadsheets:Object.freeze({maxBytes:y("spreadsheets.maxBytes",d.maxBytes,Ae),maxWorkbookBytes:y("spreadsheets.maxWorkbookBytes",d.maxWorkbookBytes,Le)})})},ot=e=>{const r=e.embeds;if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${i.describeValue(r)}`);if(Object.hasOwn(r,"linkCards"))throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${i.describeValue(r.linkCards)})`);const t=e.legacyTextEncoding;if(t!==null&&typeof t!="string")throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${i.describeValue(t)}`);const n=e.mediaDataPath;if(n!==null&&typeof n!="string")throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${i.describeValue(n)}`);const o=e.documentIds;if(o!==null&&!i.isPlainObject(o))throw new TypeError(`[markdown-explorer] config.documentIds must be the segment defineExplorerConfig resolved, or null; got ${i.describeValue(o)}`);const{linkCardEndpoint:s,...a}=r,d=ve({...e,embeds:{...a,linkCards:s!==null},legacyTextEncoding:t===null?void 0:t,mediaDataPath:n===null?void 0:n,documentIds:o===null?void 0:o});if(d.embeds.linkCardEndpoint!==s)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${i.describeValue(d.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${i.describeValue(s)}`);if(d.legacyTextEncoding!==t)throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${i.describeValue(d.legacyTextEncoding)} (the written name of the encoding it names); got ${i.describeValue(t)}`);const l=e;for(const[m,f]of Object.entries(d)){const c=J(l[m],f,m);if(c!==null)throw c.kind==="extra"?new RangeError(`[markdown-explorer] config.${c.path} is not a key of what defineExplorerConfig resolves; got ${i.describeValue(c.given)} there`):new RangeError(`[markdown-explorer] config.${c.path} must be what defineExplorerConfig resolves; got ${i.describeValue(c.given)} where it resolves ${i.describeValue(c.resolved)}`)}return d},J=(e,r,t)=>{if(Object.is(e,r))return null;if(Array.isArray(r)){if(!Array.isArray(e))return{kind:"value",path:t,given:e,resolved:r};if(e.length!==r.length)return{kind:"value",path:`${t}.length`,given:e.length,resolved:r.length};for(const[o,s]of r.entries()){const a=J(e[o],s,`${t}[${String(o)}]`);if(a!==null)return a}return null}if(!(i.isPlainObject(r)&&i.isPlainObject(e)))return{kind:"value",path:t,given:e,resolved:r};for(const o of Object.keys(r)){const s=J(Object.hasOwn(e,o)?e[o]:void 0,r[o],`${t}.${o}`);if(s!==null)return s}const n=Object.keys(e).find(o=>!Object.hasOwn(r,o));return n===void 0?null:{kind:"extra",path:`${t}.${n}`,given:e[n]}},De=e=>typeof e=="string"&&qr.test(e),it=(e,r)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${i.describeValue(e)}`);if(!Array.isArray(r)||r.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${i.describeValue(r)}`);const t=new Set;for(const[n,o]of r.entries()){if(!De(o))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${i.describeValue(o)}`);if(t.has(o))throw new RangeError(`[markdown-explorer] source ids must be unique; ${i.describeValue(o)} repeats at sourceIds[${String(n)}]`);t.add(o)}return Object.freeze({...e,sourceIds:Object.freeze([...r])})},st=e=>e.documentStyles.map(r=>r.name),at=e=>Object.freeze({origins:e.appOrigins,resources:Object.freeze([e.dataPath]),links:Object.freeze([e.basePath,e.dataPath]),media:Object.freeze(e.mediaDataPath===null?[]:[e.mediaDataPath])}),u=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),$e="true",Ce="true",V="/",ge=".data",Ve=256,Me=/^\d+(?:\.\d+)?$/u,Z=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,ze=Object.freeze(["showToc","showStyle","showAlign"]),Ee=e=>{const r=encodeURIComponent(e.replaceAll("%","%25"));return r.endsWith(ge)?`${r.slice(0,-ge.length)}%2Edata`:r},dt=e=>e.replaceAll("%25","%"),je=e=>{const{sourceIds:r}=e;if(r===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return r},lt=(e,r,t)=>{const n=t.getAll(u.source);if(n.length===0)return r;const[o]=n;return n.length>1||o===void 0||o===r||!e.includes(o)?null:o},Fe=(e,r)=>{const t=r.get(u.style),n=r.get(u.align);return{...t!==null&&e.documentStyles.some(o=>o.name===t)?{style:t}:{},...n!==null&&O.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},Ue=e=>Number.isFinite(e)&&e>=0&&e<=Ve&&Me.test(String(e)),Ge=e=>{const r=e.get(u.padding),t=r!==null&&Me.test(r)?Number(r):Number.NaN,n=e.get(u.width),o=e.get(u.maxWidth);return{...e.get(u.showToc)==="false"?{showToc:!1}:{},...e.get(u.showStyle)==="false"?{showStyle:!1}:{},...e.get(u.showAlign)==="false"?{showAlign:!1}:{},...Ue(t)?{padding:t}:{},...n!==null&&Z.test(n)?{width:n}:{},...o!==null&&Z.test(o)?{maxWidth:o}:{}}},Be=(e,r)=>[...new Set(r.filter(g.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),ct=(e,r,t,n)=>{for(const s of r)oe(s);if(new Set(r).size!==r.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(r.length)} with repeats`);if(r.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(r.length)}`);if(t!==null&&!r.includes(t))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${i.describeValue(t)}`);if(new Set(n).size!==n.length)throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(n.length)} with repeats`);const o=n.find(s=>!r.includes(s));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${i.describeValue(o)}`)},oe=e=>{if(!g.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${i.describeValue(e)}`);return e},ut=e=>{if(!Xe(oe(e)))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${i.describeValue(e)}`);return e},Xe=e=>g.isAcceptableDocumentPath(e)&&!e.endsWith(V),mt=(e,r)=>{if(r.style!==void 0&&!e.documentStyles.some(t=>t.name===r.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(t=>i.describeValue(t.name)).join(", ")}); got ${i.describeValue(r.style)}`);if(r.align!==void 0&&!O.CONTENT_ALIGNS.includes(r.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${O.CONTENT_ALIGNS.join(", ")}; got ${i.describeValue(r.align)}`)},ft=e=>{for(const r of ze)if(e[r]!==void 0&&typeof e[r]!="boolean")throw new RangeError(`[markdown-explorer] embed.${r} must be a boolean; got ${i.describeValue(e[r])}`);if(e.padding!==void 0&&!Ue(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(Ve)} px in plain decimal digits; got ${i.describeValue(e.padding)}`);for(const r of["width","maxWidth"]){const t=e[r];if(t!==void 0&&!Z.test(t))throw new RangeError(`[markdown-explorer] embed.${r} must be a CSS length in px, rem, em, ch, vw or %; got ${i.describeValue(t)}`)}},ie=(e,r)=>{if(r.view==="document-id")return wt(e,r);const t=new URLSearchParams;let n=`${e.basePath}/${e.views[r.view]}`;if(r.view==="multi"){const s=r.docs??[],a=r.maximized??null,d=r.markup??[];ct(e,s,a,d);for(const l of s)t.append(u.doc,l);a!==null&&t.set(u.maximized,a);for(const l of s)d.includes(l)&&t.append(u.markup,l)}else{const s=r.doc??null,a=r.view==="tree"?r.folder??null:null;if(s!==null&&a!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");s!==null&&(n+=`/${Ee(ut(s))}`),a!==null&&(n+=`/${Ee(`${oe(a)}${V}`)}`)}if(r.source!==void 0){const s=je(e);if(!s.includes(r.source))throw new RangeError(`[markdown-explorer] unknown source ${i.describeValue(r.source)}; expected one of ${s.join(", ")}`);r.source!==s[0]&&t.set(u.source,r.source)}r.view!=="multi"&&r.overrides!==void 0&&We(e,t,r.overrides);const o=r.view!=="multi"&&(r.doc!==void 0&&r.doc!==null||r.view==="tree"&&r.folder!==void 0&&r.folder!==null);if(r.view==="tree"&&r.maximized===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");t.set(u.maximized,Ce)}if(r.view!=="multi"&&r.markup===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");t.set(u.markup,$e)}return r.view==="single"&&r.embed!==void 0&&He(t,r.embed),Ke(n,t)},wt=(e,r)=>{if(e.documentIds===null)throw new TypeError("[markdown-explorer] an ID link needs documentIds in defineExplorerConfig");if(!g.isCanonicalDocumentId(r.id))throw new RangeError(`[markdown-explorer] not a canonical document ID: ${i.describeValue(r.id)}`);if(r.opens!==void 0&&r.opens!=="single")throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${i.describeValue(r.opens)}`);if(r.embed!==void 0&&r.opens!=="single")throw new RangeError('[markdown-explorer] embed needs opens: "single" (only the single view takes embedding options)');const t=new URLSearchParams;r.overrides!==void 0&&We(e,t,r.overrides),r.embed!==void 0&&He(t,r.embed);const n=r.opens==="single"?`/${e.views.single}`:"";return Ke(`${e.basePath}/${e.documentIds.slug}/${r.id}${n}`,t)},We=(e,r,t)=>{mt(e,t),t.style!==void 0&&r.set(u.style,t.style),t.align!==void 0&&r.set(u.align,t.align)},He=(e,r)=>{ft(r);for(const t of ze)r[t]===!1&&e.set(u[t],"false");r.padding!==void 0&&e.set(u.padding,String(r.padding)),r.width!==void 0&&e.set(u.width,r.width),r.maxWidth!==void 0&&e.set(u.maxWidth,r.maxWidth)},Ke=(e,r)=>{const t=r.toString();return t===""?e:`${e}?${t}`},gt=(e,r)=>Object.keys(e.views).find(t=>e.views[t]===r),Et=(e,r,t)=>{const n=je(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const s=lt(n,o,t),a=s===null?o:s,d=p=>({kind:"redirect",href:ie(e,p),location:p}),l=()=>d({view:"tree",source:a,doc:null,folder:null,overrides:{},markup:!1,maximized:!1});if(r===void 0||r==="")return l();const m=r.indexOf("/"),f=m<0?r:r.slice(0,m),c=m<0?null:r.slice(m+1);if(e.documentIds!==null&&f===e.documentIds.slug)return ht(e,c,t,o,l);const w=gt(e,f);if(w===void 0)return l();if(w==="multi"){const p=t.getAll(u.doc),_=Be(e,p),z=t.getAll(u.maximized),[j]=z,F=z.length===1&&j!==void 0&&_.includes(j)?j:null,U=t.getAll(u.markup),v=_.filter(P=>U.includes(P)),qe=v.length===U.length&&v.every((P,G)=>P===U[G]);return c===null&&s!==null&&_.length===p.length&&_.every((P,G)=>P===p[G])&&(z.length===0||F!==null)&&qe?{kind:"location",location:{view:"multi",source:a,docs:_,maximized:F,markup:v}}:d({view:"multi",source:a,docs:_,maximized:F,markup:v})}const N=c===null?null:dt(c),E=N?.endsWith(V)===!0?N.slice(0,-V.length):null,h=N!==null&&E===null?N:null;if(h!==null&&!g.isAcceptableDocumentPath(h)||E!==null&&!g.isAcceptableDocumentPath(E))return l();const R=Fe(e,t),k=(h!==null||E!==null)&&t.get(u.markup)===$e;if(w==="single"){if(E!==null)return d({view:"tree",source:a,doc:null,folder:E,overrides:R,markup:k,maximized:!1});if(h===null)return l();const p=Ge(t);return s===null?d({view:w,source:a,doc:h,overrides:R,embed:p,markup:k}):{kind:"location",location:{view:w,source:a,doc:h,overrides:R,embed:p,markup:k}}}const se=(h!==null||E!==null)&&t.get(u.maximized)===Ce;return s===null?d({view:w,source:a,doc:h,folder:E,overrides:R,markup:k,maximized:se}):{kind:"location",location:{view:w,source:a,doc:h,folder:E,overrides:R,markup:k,maximized:se}}},ht=(e,r,t,n,o)=>{if(r===null||r==="")return o();const s=r.indexOf("/"),a=g.parseDocumentId(s<0?r:r.slice(0,s)),d=s<0?null:r.slice(s+1),l=Fe(e,t),m={view:"tree",source:n,doc:null,folder:null,overrides:{},markup:!1,maximized:!1};return d===e.views.single?{kind:"document-id",id:a,opens:{view:"single",overrides:l,embed:Ge(t)},location:m}:d!==null&&a!==null?{kind:"redirect",href:ie(e,{view:"document-id",id:a,overrides:l}),location:m}:{kind:"document-id",id:a,opens:{view:"tree",overrides:l},location:m}},pt=(e,r,t)=>e.view==="single"?{view:"single",source:t,doc:r,overrides:e.overrides,embed:e.embed}:{view:"tree",source:t,doc:r,overrides:e.overrides};exports.ASSUMED_ROOT_FONT_PIXELS=Or;exports.COARSE_TARGET_PIXELS=_r;exports.COLUMN_MIN_MEASURE=Pr;exports.CONTROL_BLOCK_PIXELS=ne;exports.DEFAULT_TREE_SETTINGS=W;exports.DEFAULT_VIEW_SLUGS=q;exports.EDIT_SPLIT_DEFAULT_PERCENT=vr;exports.EDIT_SPLIT_MAX_PERCENT=Dr;exports.EDIT_SPLIT_MIN_PERCENT=Te;exports.EXPAND_ALL_DEPTH_LIMITS=ke;exports.EXPAND_ALL_FOLDER_LIMITS=Re;exports.EXPLORER_DEFAULT_PERCENT=xr;exports.EXPLORER_MAX_PERCENT=te;exports.EXPLORER_MIN_REM=Se;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Sr;exports.FIBONACCI_SPACING_PIXELS=K;exports.FINE_TARGET_PIXELS=Ir;exports.GOLDEN_RATIO=b;exports.MULTI_VIEW_COLUMN_LIMITS=Ie;exports.MULTI_VIEW_PANEL_LIMITS=_e;exports.NAME_COLLATOR=L;exports.NO_TREE_SETTING_CHANGES=H;exports.PANEL_MAX_BLOCK_RATIO=Rr;exports.PANEL_MIN_BLOCK_RATIO=kr;exports.PREFETCH_DWELL_MS=$r;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=Pe;exports.SPLIT_HANDLE_PIXELS=Tr;exports.SPLIT_PERSIST_DELAY_MS=Nr;exports.SPREADSHEET_BYTE_LIMITS=Ae;exports.WORKBOOK_BYTE_LIMITS=Le;exports.advanceTreeSetting=ur;exports.applyTreeSettingChanges=gr;exports.assertMountPath=Y;exports.canonicalMultiDocuments=Be;exports.centeredDialogPosition=jr;exports.columnGroups=Mr;exports.createEntryComparator=br;exports.decodeText=tr;exports.decodeTextLeniently=or;exports.defineExplorerConfig=ve;exports.documentIdOpeningTarget=pt;exports.documentStyleNames=st;exports.editSplitOrientation=zr;exports.explorerHref=ie;exports.explorerMinPixels=Oe;exports.explorerSheetBelowPixels=Lr;exports.folderReadmeOf=dr;exports.formatTreeSettingValue=mr;exports.hasDocumentUrl=Xe;exports.isExplorerSourceId=De;exports.legacyTextEncodingOf=Q;exports.ownUrlsOf=at;exports.parseViewSettings=Wr;exports.readCookieValue=Xr;exports.readTreeSettingChanges=wr;exports.recordTreeSettingChange=Er;exports.replanVisibleColumns=Vr;exports.resolveExplorerLocation=Et;exports.revalidateExplorerConfig=ot;exports.serializeTreeSettingChanges=hr;exports.serializeViewSettings=ye;exports.textEncodingOf=nr;exports.textEncodingsOf=er;exports.viewSettingsCookieString=Kr;exports.visibleTreeSettingDescriptors=cr;exports.withExplorerSources=it;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diff3Merge as d } from "node-diff3";
|
|
2
|
-
import { C, a as R, b as u } from "./index-
|
|
2
|
+
import { C, a as R, b as u } from "./index-D0l_BJqb.js";
|
|
3
3
|
const g = (n, o, e, l) => {
|
|
4
4
|
if (o === n || o === e) return { kind: "clean", text: e };
|
|
5
5
|
if (e === n) return { kind: "clean", text: o };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-lpL7GltU.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
|
|
2
2
|
`),n.split(`
|
|
3
3
|
`),i.split(`
|
|
4
4
|
`),{excludeFalseConflicts:!0}),o=[];let c=0;const u=s(l.ours),a=s(l.theirs);for(const e of d)e.ok!==void 0?o.push(...e.ok):e.conflict!==void 0&&(c+=1,o.push(`${r.CONFLICT_OURS_MARKER} ${u}`,...e.conflict.a,r.CONFLICT_SEPARATOR,...e.conflict.b,`${r.CONFLICT_THEIRS_MARKER} ${a}`));const f=o.join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("./describeValue-Ccvhbt36.cjs"),f="0123456789ABCDEFGHJKMNPQRSTVWXYZ",P=12,fe=37,T=P-1,pe=f.length-1,Ee=/^[0-9A-Za-z-]+$/u,M=e=>{let t=0;for(const r of e)t=(t*f.length+f.indexOf(r))%fe;return t},_=e=>{if(typeof e!="string"||e.length!==P)return!1;for(const t of e)if(!f.includes(t))return!1;return M(e.slice(0,T))===f.indexOf(e.slice(T))},me=e=>{if(!Ee.test(e))return null;const t=e.replaceAll("-","").toUpperCase().replace(/[IL]/gu,"1").replace(/O/gu,"0");return _(t)?t:null},Re=e=>{const t=new Uint8Array(T);for(;;){e(t);const r=Array.from(t,s=>f.charAt(s&pe)).join(""),n=M(r);if(n<f.length)return`${r}${f.charAt(n)}`}},ge=e=>{if(!_(e))throw new RangeError(`[markdown-explorer] not a canonical document ID: ${o.describeValue(e)}`);return`${e.slice(0,4)}-${e.slice(4,8)}-${e.slice(8)}`},H=4096,V=3,F=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),he=/[\u0000-\u001f\u007f]/u,ye=/\p{Cs}/u,be=e=>{const t=e.split("/").filter(r=>r!=="").at(-1);return t===void 0?e:t},A=e=>e.length>0&&e.length<=H&&!ye.test(e)&&!he.test(e)&&!e.includes("\\"),K=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),Oe=/(?:%[0-9A-Fa-f]{2})+/gu,_e=new TextDecoder("utf-8"),Ae=/[/\\]/u,C=e=>e.replace(Oe,t=>_e.decode(Uint8Array.from(t.slice(1).split("%").map(r=>Number.parseInt(r,16))))),xe=e=>{const t=[e];let r=e;for(let n=0;n<V&&r.includes("%");n+=1){const s=C(r);if(s===r)break;t.push(s),r=s}return{levels:t.map(K),stillEncoded:t.length>V&&C(r)!==r}},Te=e=>{if(typeof e!="string"||e.trim()===""||e.includes("/")||e.includes("\\"))throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${o.describeValue(e)}`);const t=K(e).split("*").map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},D=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(Te),r=s=>s!==""&&t.some(i=>i.test(s)),n=s=>{if(t.length===0||s==="")return!1;const{levels:i,stillEncoded:l}=xe(s);return l?!0:i.some(u=>r(u)||u.split(Ae).some(r))};return{deniesPath:s=>s.split("/").some(n),deniesName:n}},we=D(F),Le=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),Pe=e=>e===void 0?we:e===!1?Le:D(e),De=(e,t)=>D(e).deniesPath(t),S=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),Se=Object.freeze(["file","directory"]),ke=Object.freeze(["video","audio","pdf"]),$e=Object.freeze(["raster","svg"]),Ie=Object.freeze(["csv","tsv","workbook"]),Ne=Object.freeze(["csv","tsv"]),Ue=Object.freeze(["info","warning","danger"]),je=Object.freeze(["markdown","text","image","media","spreadsheet","file","failure"]),z=Object.freeze({min:1,max:6}),ve=1e4,m=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),Ve=Object.freeze(["http:","https:","mailto:"]),k=1024,Ce=/^[a-z0-9-]{1,64}$/u,ze="https://relative.invalid/",p=(e,t)=>typeof t=="string"&&e.includes(t),G=e=>p(S,e),Xe=e=>p(Se,e),W=e=>p(ke,e),Y=e=>p($e,e),Me=e=>p(Ie,e),He=e=>p(Ue,e),Fe=e=>p(je,e),$=e=>typeof e=="string"&&Ce.test(e),Ke=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,ze).protocol)}catch{return!1}},E=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:r}=e;return G(t)?r!==void 0&&!$(r)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o.describeValue(r)}`:null:`unknown failure reason ${o.describeValue(t)}`},B=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:r,type:n,mimeType:s,modifiedAt:i,children:l,lazy:u}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof r!="string"||!A(r)?"an entry needs an acceptable path":Xe(n)?s!==void 0&&typeof s!="string"?"an entry mimeType must be a string":i!==void 0&&!Number.isSafeInteger(i)?`an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o.describeValue(i)}`:u!==void 0&&typeof u!="boolean"?"an entry lazy flag must be a boolean":l!==void 0&&!Array.isArray(l)?"entry children must be an array":n==="file"&&(l!==void 0||u===!0)?"a file entry cannot have children or be lazy":u===!0&&Array.isArray(l)&&l.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${o.describeValue(n)}`},Z=e=>{if(B(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(Z)},q=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:r,failure:n}=e;return t==="ok"?Array.isArray(r)&&r.every(Z):t==="error"&&E(n)===null},Ge=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:r,failure:n}=e;return t==="ok"?r===null||Q(r):t==="error"&&E(n)===null},Q=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&A(t))&&new Set(e).size===e.length,We=e=>{if(e===null||typeof e!="object")return!1;const{status:t,source:r,ancestors:n,failure:s}=e;return t==="ok"?r===null&&n===null||typeof r=="string"&&r!==""&&Q(n):t==="error"&&E(s)===null},Ye=e=>{if(e===null||typeof e!="object")return!1;const{status:t,id:r,failure:n}=e;return t==="ok"?_(r):t==="error"&&E(n)===null},Be=e=>{if(e===null||typeof e!="object")return!1;const{status:t,path:r,source:n,failure:s}=e;return t==="ok"?typeof r=="string"&&A(r)&&typeof n=="string"&&n!=="":t==="error"&&E(s)===null},Ze=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:r}=e;return t==="ok"&&!(Number.isSafeInteger(r)&&r>=0)?!1:q(e)},I=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:r,id:n}=e;return typeof t!="string"||typeof n!="string"?"a heading needs text and id strings":typeof r!="number"||!Number.isInteger(r)||r<z.min||r>z.max?`a heading depth must be an integer in 1..6; got ${o.describeValue(r)}`:null},w=e=>{if(typeof e!="string"||e==="")return!1;try{return Intl.getCanonicalLocales(e)[0]===e}catch{return!1}},L=(e,t)=>`a ${e} document needs a lang that is a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${o.describeValue(t)}`,J=e=>typeof e.text!="string"||typeof e.truncated!="boolean"?"a text document needs text and truncated":m(e.url)?null:"a text document needs a root-relative url",N=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:r}=t;if(!Fe(r))return`unknown document kind ${o.describeValue(r)}`;if(r==="failure")return E(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(r){case"markdown":{const{htmlContent:n,headings:s}=t;if(typeof n!="string"||!Array.isArray(s))return"a markdown document needs htmlContent and headings";for(const i of s){const l=I(i);if(l!==null)return l}return w(t.lang)?Je(t.edit):L(r,t.lang)}case"text":{const n=J(t);return n!==null?n:w(t.lang)?null:L(r,t.lang)}case"image":return m(t.url)?Y(t.imageType)?null:`unknown image type ${o.describeValue(t.imageType)}`:"an image document needs a root-relative url";case"media":return m(t.url)?W(t.mediaType)?null:`unknown media type ${o.describeValue(t.mediaType)}`:"a media document needs a root-relative url";case"spreadsheet":return m(t.url)?ee(t):"a spreadsheet document needs a root-relative url";case"file":return m(t.url)?null:"a file document needs a root-relative url"}},qe=e=>N(e)===null,Qe=e=>{if(e===null||typeof e!="object")return!1;const t=e;return t.kind==="failure"?N(t)===null:t.kind==="text"&&typeof t.name=="string"&&J(t)===null},Je=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:t,href:r}=e;return t==="inline"?r===void 0?null:"an inline edit carries no href":t==="draft"?r===void 0?null:"a draft edit carries no href":t!=="external"?`unknown edit kind ${o.describeValue(t)}`:te(r)},et=e=>{if(e===null)return null;if(typeof e!="object")return"a spreadsheet document's edit must be null or an object";const{kind:t,href:r}=e;return t!=="external"?`a spreadsheet document's edit must be external; got ${o.describeValue(t)}`:te(r)},ee=e=>{if(!Me(e.format))return`unknown spreadsheet format ${o.describeValue(e.format)}`;const{firstSheetText:t}=e;return t!==null&&!p(Ne,t)?`a spreadsheet document's firstSheetText must be csv, tsv or null; got ${o.describeValue(t)}`:t!==null&&e.format!=="workbook"?"only a workbook's spreadsheet document names a firstSheetText":et(e.edit)},te=e=>tt(e)?null:`an external edit needs an absolute https: href; got ${o.describeValue(e)}`,tt=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},R=e=>typeof e=="string"&&e.length>0&&e.length<=k,rt=e=>m(e.href)?null:`a grant needs a root-relative href; got ${o.describeValue(e.href)}`,re=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:r,size:n,author:s,kept:i,current:l}=e;return R(t)?r!==null&&(typeof r!="string"||Number.isNaN(Date.parse(r)))?`a revision's modifiedAt must be a date-time string or null; got ${o.describeValue(r)}`:typeof n!="number"||!Number.isSafeInteger(n)||n<0?`a revision's size must be a non-negative integer; got ${o.describeValue(n)}`:s!==null&&typeof s!="string"?`a revision's author must be a string or null; got ${o.describeValue(s)}`:typeof i!="boolean"||typeof l!="boolean"?"a revision needs kept and current booleans":null:`a revision id must be a non-empty string of at most ${k} characters; got ${o.describeValue(t)}`},h=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const r=e,{kind:n}=r;if(n==="failure")return E(r.failure);if(typeof n!="string"||!t.includes(n))return`unexpected answer kind ${o.describeValue(n)}`;switch(n){case"grant":return rt(r);case"edit":return typeof r.text!="string"||typeof r.history!="boolean"?"an edit source needs text and history":R(r.version)?null:`an edit source needs a version; got ${o.describeValue(r.version)}`;case"draft":return typeof r.text=="string"?null:"a draft source needs text";case"saved":return R(r.version)?null:`a saved answer needs a version; got ${o.describeValue(r.version)}`;case"conflict":return typeof r.text!="string"?"a conflict needs the current text":R(r.version)?null:`a conflict needs the current version; got ${o.describeValue(r.version)}`;case"preview":{const{htmlContent:s,headings:i}=r;if(typeof s!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const l of i){const u=I(l);if(u!==null)return u}return null}case"revisions":{if(!Array.isArray(r.revisions))return"revisions need an array";for(const s of r.revisions){const i=re(s);if(i!==null)return i}return null}case"revision":return typeof r.text!="string"?"a revision answer needs text":R(r.id)?null:`a revision answer needs an id; got ${o.describeValue(r.id)}`;default:return`unexpected answer kind ${o.describeValue(n)}`}},nt=Object.freeze(["edit","draft","grant"]),st=Object.freeze(["saved","conflict","grant"]),ne=Object.freeze(["preview"]),ot=Object.freeze(["revisions"]),it=Object.freeze(["revision"]),at=e=>h(e,nt)===null,lt=e=>h(e,st)===null,ct=e=>h(e,ne)===null,ut=e=>h(e,ot)===null,dt=e=>h(e,it)===null,ft=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:h(e,ne),pt=(e,t)=>({kind:"failure",failure:se(e,t)}),se=(e,t)=>$(t)?{reason:e,code:t}:{reason:e},Et=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card","issue-id","resolve-id"]),g=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as",id:"id"}),mt="asset",Rt="link-card",gt=(e,t,r)=>{const n=`${e}/${mt}?${g.path}=${encodeURIComponent(t)}`;return r===null?n:`${n}&${g.version}=${encodeURIComponent(r)}`},oe="text",ie="workbook",ht=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${o.describeValue(e)}`);return`${e}&${g.display}=${oe}`},yt=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${o.describeValue(e)}`);return`${e}&${g.display}=${ie}`},bt=e=>{const t=e.getAll(g.display);return t.length===0?"file":t.length!==1?null:t[0]===oe?"text":t[0]===ie?"workbook":null},Ot=e=>`${e}/${Rt}`,_t="X-Markdown-Explorer-Scope",At="X-Markdown-Explorer",xt="refresh",Tt="edit",wt="document-id",Lt="text/markdown",Pt=e=>Et.includes(e),ae=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Dt=e=>{const[t,...r]=S.filter(n=>ae[n]===e);return t!==void 0&&r.length===0?t:"failed"},St=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,kt=/^[\u0000- ]+|[\u0000- ]+$/gu,$t=/[\t\n\r]/gu,It=/^[a-z][a-z\d+.-]*:/iu,Nt=/^(?:\.|%2e){1,2}$/iu,Ut=new Set(["ftp:","file:","http:","https:","ws:","wss:"]),jt=Object.freeze(["http:","https:"]),vt="http://path.invalid",X=Object.freeze(["origins","resources","links","media"]),O=e=>St.test(e)&&!e.split("/").some(t=>t==="."||t===".."),le=e=>{if(!URL.canParse(e))return!1;const t=new URL(e);return t.host!==""&&e===`${t.protocol}//${t.host}`},ce=e=>{if(!URL.canParse(e))return!1;const t=new URL(e);return(t.protocol==="http:"||t.protocol==="https:")&&e===`${t.origin}${t.pathname}`&&O(t.pathname)},ue=e=>o.isPlainObject(e)&&Object.keys(e).length===X.length&&X.every(t=>{const r=Object.hasOwn(e,t)?e[t]:void 0;return Array.isArray(r)&&Array.from(r).every(n=>typeof n=="string")}),x=e=>`${e.protocol}//${e.hostname.replace(/\.+$/u,"")}${e.port===""?"":`:${e.port}`}`,b=(e,t)=>t.some(r=>e===r||e.startsWith(`${r}/`)),Vt=e=>e.slice(0,e.search(/[?#]|$/u)).split("/").some(t=>Nt.test(t)),Ct=(e,t)=>{switch(t){case"document-link":return!0;case"link":return!Vt(e);case"svg-reference":return e.startsWith("#");default:return!1}},de=e=>{if(!ue(e))throw new TypeError("[markdown-explorer] the HTML sanitizer's ownUrls must be a plain object of exactly origins, resources, links and media, each an array of strings");const t=[["origins",le,"an origin as the browser writes it (scheme://host[:port])"],["resources",O,'a mount path ("/" and segments of letters, digits and "._~-", without a "." or ".." segment or a trailing "/")'],["links",O,'a mount path ("/" and segments of letters, digits and "._~-", without a "." or ".." segment or a trailing "/")'],["media",ce,"an absolute http: or https: URL as the browser writes it, of an origin and a mount path"]];for(const[r,n,s]of t)for(const[i,l]of e[r].entries())if(!n(l))throw new RangeError(`[markdown-explorer] the HTML sanitizer's ownUrls.${r}[${String(i)}] must be ${s}; got ${o.describeValue(l)}`);return Object.freeze({origins:Object.freeze([...e.origins]),resources:Object.freeze([...e.resources]),links:Object.freeze([...e.links]),media:Object.freeze([...e.media])})},zt=e=>{const t=de(e),r=t.origins.map(a=>new URL(a)),n=new Set(r.map(x)),s=new Set(r.map(a=>a.protocol).filter(a=>!Ut.has(a))),i=t.media.map(a=>{const d=new URL(a);return{key:x(d),path:d.pathname}}),l=new Set(i.map(a=>a.key)),u=r.length===0?jt:[...new Set(r.map(a=>a.protocol))],U=a=>a==="link"||a==="document-link"?t.links:t.resources,j=(a,d)=>{const c=x(a),y=n.has(c)||s.has(a.protocol);return!(y||l.has(c))||y&&b(a.pathname,U(d))?!0:d==="media"&&i.some(v=>v.key===c&&b(a.pathname,[v.path]))};return(a,d)=>{const c=a.replace(kt,"").replace($t,"");return c.includes("\\")?!1:It.test(c)?URL.canParse(c)&&j(new URL(c),d):c.startsWith("//")?u.every(y=>URL.canParse(`${y}${c}`)&&j(new URL(`${y}${c}`),d)):c.startsWith("/")?b(new URL(c,vt).pathname,U(d)):Ct(c,d)}};exports.DEFAULT_DENIED_PATH_SEGMENTS=F;exports.DOCUMENT_ID_ALPHABET=f;exports.DOCUMENT_ID_LENGTH=P;exports.EXPLORER_DATA_QUERY=g;exports.EXPLORER_DOCUMENT_ID_PROOF=wt;exports.EXPLORER_DRAFT_MEDIA_TYPE=Lt;exports.EXPLORER_EDIT_PROOF=Tt;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=k;exports.EXPLORER_FAILURE_REASONS=S;exports.EXPLORER_FAILURE_STATUS=ae;exports.EXPLORER_LINK_PROTOCOLS=Ve;exports.EXPLORER_MAX_HEADINGS=ve;exports.EXPLORER_PROOF_HEADER=At;exports.EXPLORER_REFRESH_PROOF=xt;exports.EXPLORER_SCOPE_HEADER=_t;exports.MAX_DOCUMENT_PATH_LENGTH=H;exports.createDocumentId=Re;exports.createOwnUrlRule=zt;exports.documentLangRefusal=L;exports.documentViolation=N;exports.draftAnswerViolation=ft;exports.entryViolation=B;exports.explorerAssetHref=gt;exports.explorerLinkCardEndpoint=Ot;exports.explorerPlainTextHref=ht;exports.explorerWorkbookHref=yt;exports.failureDocument=pt;exports.failureOf=se;exports.failureReasonOfStatus=Dt;exports.failureViolation=E;exports.groupDocumentId=ge;exports.headingViolation=I;exports.isAcceptableDocumentPath=A;exports.isAcceptableUrl=Ke;exports.isBrowserOrigin=le;exports.isCanonicalDocumentId=_;exports.isDeniedPath=De;exports.isExplorerAncestorsResult=Ge;exports.isExplorerChildrenResult=q;exports.isExplorerDataOperation=Pt;exports.isExplorerDocument=qe;exports.isExplorerDocumentLang=w;exports.isExplorerEditAnswer=at;exports.isExplorerEditToken=R;exports.isExplorerFailureCode=$;exports.isExplorerFailureReason=G;exports.isExplorerImageType=Y;exports.isExplorerIssuedDocumentId=Ye;exports.isExplorerMediaType=W;exports.isExplorerNoticeTone=He;exports.isExplorerOwnUrls=ue;exports.isExplorerPreviewAnswer=ct;exports.isExplorerResolvedDocumentId=Be;exports.isExplorerRevealResult=We;exports.isExplorerRevisionAnswer=dt;exports.isExplorerRevisionsAnswer=ut;exports.isExplorerSaveAnswer=lt;exports.isExplorerTextAnswer=Qe;exports.isExplorerTreeResult=Ze;exports.isMediaDataUrl=ce;exports.isMountPath=O;exports.isRootRelativeUrl=m;exports.isUnder=b;exports.lastPathSegment=be;exports.parseDocumentId=me;exports.readExplorerAssetDisplay=bt;exports.readOwnUrls=de;exports.resolvePathRules=Pe;exports.revisionViolation=re;exports.spreadsheetFieldsViolation=ee;
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { d as o, i as q } from "./describeValue-CLlVRO8d.js";
|
|
2
|
+
const d = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", U = 12, Q = 37, _ = U - 1, J = d.length - 1, ee = /^[0-9A-Za-z-]+$/u, v = (e) => {
|
|
3
|
+
let t = 0;
|
|
4
|
+
for (const n of e) t = (t * d.length + d.indexOf(n)) % Q;
|
|
5
|
+
return t;
|
|
6
|
+
}, w = (e) => {
|
|
7
|
+
if (typeof e != "string" || e.length !== U) return !1;
|
|
8
|
+
for (const t of e) if (!d.includes(t)) return !1;
|
|
9
|
+
return v(e.slice(0, _)) === d.indexOf(e.slice(_));
|
|
10
|
+
}, ot = (e) => {
|
|
11
|
+
if (!ee.test(e)) return null;
|
|
12
|
+
const t = e.replaceAll("-", "").toUpperCase().replace(/[IL]/gu, "1").replace(/O/gu, "0");
|
|
13
|
+
return w(t) ? t : null;
|
|
14
|
+
}, it = (e) => {
|
|
15
|
+
const t = new Uint8Array(_);
|
|
16
|
+
for (; ; ) {
|
|
17
|
+
e(t);
|
|
18
|
+
const n = Array.from(t, (s) => d.charAt(s & J)).join(""), r = v(n);
|
|
19
|
+
if (r < d.length) return `${n}${d.charAt(r)}`;
|
|
20
|
+
}
|
|
21
|
+
}, at = (e) => {
|
|
22
|
+
if (!w(e)) throw new RangeError(`[markdown-explorer] not a canonical document ID: ${o(e)}`);
|
|
23
|
+
return `${e.slice(0, 4)}-${e.slice(4, 8)}-${e.slice(8)}`;
|
|
24
|
+
}, te = 4096, L = 3, ne = Object.freeze([
|
|
25
|
+
".env*",
|
|
26
|
+
"*.env",
|
|
27
|
+
"*.env.*",
|
|
28
|
+
"*.env~*",
|
|
29
|
+
"*.env-*",
|
|
30
|
+
"*.env_*",
|
|
31
|
+
"*.env#*",
|
|
32
|
+
".git",
|
|
33
|
+
".git-credentials",
|
|
34
|
+
".svn",
|
|
35
|
+
".hg",
|
|
36
|
+
"node_modules",
|
|
37
|
+
"secrets",
|
|
38
|
+
".secrets",
|
|
39
|
+
"secrets.json",
|
|
40
|
+
"secrets.yml",
|
|
41
|
+
"secrets.yaml",
|
|
42
|
+
"secrets.toml",
|
|
43
|
+
"secrets.ini",
|
|
44
|
+
"secrets.txt",
|
|
45
|
+
".ssh",
|
|
46
|
+
".aws",
|
|
47
|
+
".gnupg",
|
|
48
|
+
".docker",
|
|
49
|
+
".kube",
|
|
50
|
+
".terraform",
|
|
51
|
+
".npmrc",
|
|
52
|
+
".yarnrc",
|
|
53
|
+
".yarnrc.yml",
|
|
54
|
+
".netrc",
|
|
55
|
+
"_netrc",
|
|
56
|
+
".pypirc",
|
|
57
|
+
".pgpass",
|
|
58
|
+
".my.cnf",
|
|
59
|
+
".htpasswd",
|
|
60
|
+
".vault-token",
|
|
61
|
+
"id_rsa*",
|
|
62
|
+
"id_dsa*",
|
|
63
|
+
"id_ecdsa*",
|
|
64
|
+
"id_ed25519*",
|
|
65
|
+
"*.pem",
|
|
66
|
+
"*.key",
|
|
67
|
+
"*.p8",
|
|
68
|
+
"*.p12",
|
|
69
|
+
"*.pfx",
|
|
70
|
+
"*.ppk",
|
|
71
|
+
"*.jks",
|
|
72
|
+
"*.keystore",
|
|
73
|
+
"*.kdbx",
|
|
74
|
+
"*credentials*.json",
|
|
75
|
+
"service-account*.json",
|
|
76
|
+
"*.tfstate",
|
|
77
|
+
"*.tfstate.*",
|
|
78
|
+
"*.tfvars",
|
|
79
|
+
"*.tfvars.json",
|
|
80
|
+
".*_history",
|
|
81
|
+
"fish_history"
|
|
82
|
+
]), re = /[\u0000-\u001f\u007f]/u, se = /\p{Cs}/u, ct = (e) => {
|
|
83
|
+
const t = e.split("/").filter((n) => n !== "").at(-1);
|
|
84
|
+
return t === void 0 ? e : t;
|
|
85
|
+
}, x = (e) => e.length > 0 && e.length <= te && !se.test(e) && !re.test(e) && !e.includes("\\"), z = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), oe = /(?:%[0-9A-Fa-f]{2})+/gu, ie = new TextDecoder("utf-8"), ae = /[/\\]/u, P = (e) => e.replace(
|
|
86
|
+
oe,
|
|
87
|
+
(t) => ie.decode(
|
|
88
|
+
Uint8Array.from(
|
|
89
|
+
t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
), ce = (e) => {
|
|
93
|
+
const t = [e];
|
|
94
|
+
let n = e;
|
|
95
|
+
for (let r = 0; r < L && n.includes("%"); r += 1) {
|
|
96
|
+
const s = P(n);
|
|
97
|
+
if (s === n) break;
|
|
98
|
+
t.push(s), n = s;
|
|
99
|
+
}
|
|
100
|
+
return { levels: t.map(z), stillEncoded: t.length > L && P(n) !== n };
|
|
101
|
+
}, le = (e) => {
|
|
102
|
+
if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
|
|
103
|
+
throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${o(e)}`);
|
|
104
|
+
const t = z(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
105
|
+
return new RegExp(`^${t}$`, "su");
|
|
106
|
+
}, S = (e) => {
|
|
107
|
+
if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
|
|
108
|
+
const t = e.map(le), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => {
|
|
109
|
+
if (t.length === 0 || s === "") return !1;
|
|
110
|
+
const { levels: i, stillEncoded: c } = ce(s);
|
|
111
|
+
return c ? !0 : i.some((u) => n(u) || u.split(ae).some(n));
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
deniesPath: (s) => s.split("/").some(r),
|
|
115
|
+
deniesName: r
|
|
116
|
+
};
|
|
117
|
+
}, ue = S(ne), fe = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), lt = (e) => e === void 0 ? ue : e === !1 ? fe : S(e), ut = (e, t) => S(e).deniesPath(t), C = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), de = Object.freeze(["file", "directory"]), pe = Object.freeze(["video", "audio", "pdf"]), me = Object.freeze(["raster", "svg"]), Ee = Object.freeze(["csv", "tsv", "workbook"]), ge = Object.freeze(["csv", "tsv"]), he = Object.freeze(["info", "warning", "danger"]), ye = Object.freeze(["markdown", "text", "image", "media", "spreadsheet", "file", "failure"]), D = Object.freeze({ min: 1, max: 6 }), ft = 1e4, E = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), dt = Object.freeze(["http:", "https:", "mailto:"]), M = 1024, Re = /^[a-z0-9-]{1,64}$/u, be = "https://relative.invalid/", p = (e, t) => typeof t == "string" && e.includes(t), Oe = (e) => p(C, e), _e = (e) => p(de, e), Ae = (e) => p(pe, e), we = (e) => p(me, e), xe = (e) => p(Ee, e), pt = (e) => p(he, e), Se = (e) => p(ye, e), X = (e) => typeof e == "string" && Re.test(e), mt = (e, t) => {
|
|
118
|
+
if (typeof e != "string") return !1;
|
|
119
|
+
try {
|
|
120
|
+
return t.includes(new URL(e, be).protocol);
|
|
121
|
+
} catch {
|
|
122
|
+
return !1;
|
|
123
|
+
}
|
|
124
|
+
}, m = (e) => {
|
|
125
|
+
if (e === null || typeof e != "object") return "a failure must be an object";
|
|
126
|
+
const { reason: t, code: n } = e;
|
|
127
|
+
return Oe(t) ? n !== void 0 && !X(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
|
|
128
|
+
}, Te = (e) => {
|
|
129
|
+
if (e === null || typeof e != "object") return "an entry must be an object";
|
|
130
|
+
const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: c, lazy: u } = e;
|
|
131
|
+
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !x(n) ? "an entry needs an acceptable path" : _e(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : u !== void 0 && typeof u != "boolean" ? "an entry lazy flag must be a boolean" : c !== void 0 && !Array.isArray(c) ? "entry children must be an array" : r === "file" && (c !== void 0 || u === !0) ? "a file entry cannot have children or be lazy" : u === !0 && Array.isArray(c) && c.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
|
|
132
|
+
}, H = (e) => {
|
|
133
|
+
if (Te(e) !== null) return !1;
|
|
134
|
+
const { children: t } = e;
|
|
135
|
+
return t === void 0 || t.every(H);
|
|
136
|
+
}, ke = (e) => {
|
|
137
|
+
if (e === null || typeof e != "object") return !1;
|
|
138
|
+
const { status: t, entries: n, failure: r } = e;
|
|
139
|
+
return t === "ok" ? Array.isArray(n) && n.every(H) : t === "error" && m(r) === null;
|
|
140
|
+
}, Et = (e) => {
|
|
141
|
+
if (e === null || typeof e != "object") return !1;
|
|
142
|
+
const { status: t, ancestors: n, failure: r } = e;
|
|
143
|
+
return t === "ok" ? n === null || F(n) : t === "error" && m(r) === null;
|
|
144
|
+
}, F = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && x(t)) && new Set(e).size === e.length, gt = (e) => {
|
|
145
|
+
if (e === null || typeof e != "object") return !1;
|
|
146
|
+
const { status: t, source: n, ancestors: r, failure: s } = e;
|
|
147
|
+
return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && F(r) : t === "error" && m(s) === null;
|
|
148
|
+
}, ht = (e) => {
|
|
149
|
+
if (e === null || typeof e != "object") return !1;
|
|
150
|
+
const { status: t, id: n, failure: r } = e;
|
|
151
|
+
return t === "ok" ? w(n) : t === "error" && m(r) === null;
|
|
152
|
+
}, yt = (e) => {
|
|
153
|
+
if (e === null || typeof e != "object") return !1;
|
|
154
|
+
const { status: t, path: n, source: r, failure: s } = e;
|
|
155
|
+
return t === "ok" ? typeof n == "string" && x(n) && typeof r == "string" && r !== "" : t === "error" && m(s) === null;
|
|
156
|
+
}, Rt = (e) => {
|
|
157
|
+
if (e === null || typeof e != "object") return !1;
|
|
158
|
+
const { status: t, loadedAt: n } = e;
|
|
159
|
+
return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : ke(e);
|
|
160
|
+
}, V = (e) => {
|
|
161
|
+
if (e === null || typeof e != "object") return "a heading must be an object";
|
|
162
|
+
const { text: t, depth: n, id: r } = e;
|
|
163
|
+
return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < D.min || n > D.max ? `a heading depth must be an integer in 1..6; got ${o(n)}` : null;
|
|
164
|
+
}, j = (e) => {
|
|
165
|
+
if (typeof e != "string" || e === "") return !1;
|
|
166
|
+
try {
|
|
167
|
+
return Intl.getCanonicalLocales(e)[0] === e;
|
|
168
|
+
} catch {
|
|
169
|
+
return !1;
|
|
170
|
+
}
|
|
171
|
+
}, N = (e, t) => `a ${e} document needs a lang that is a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${o(t)}`, K = (e) => typeof e.text != "string" || typeof e.truncated != "boolean" ? "a text document needs text and truncated" : E(e.url) ? null : "a text document needs a root-relative url", W = (e) => {
|
|
172
|
+
if (e === null || typeof e != "object") return "a document must be an object";
|
|
173
|
+
const t = e, { kind: n } = t;
|
|
174
|
+
if (!Se(n)) return `unknown document kind ${o(n)}`;
|
|
175
|
+
if (n === "failure") return m(t.failure);
|
|
176
|
+
if (typeof t.name != "string") return "a document needs a name string";
|
|
177
|
+
switch (n) {
|
|
178
|
+
case "markdown": {
|
|
179
|
+
const { htmlContent: r, headings: s } = t;
|
|
180
|
+
if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
|
|
181
|
+
for (const i of s) {
|
|
182
|
+
const c = V(i);
|
|
183
|
+
if (c !== null) return c;
|
|
184
|
+
}
|
|
185
|
+
return j(t.lang) ? $e(t.edit) : N(n, t.lang);
|
|
186
|
+
}
|
|
187
|
+
case "text": {
|
|
188
|
+
const r = K(t);
|
|
189
|
+
return r !== null ? r : j(t.lang) ? null : N(n, t.lang);
|
|
190
|
+
}
|
|
191
|
+
case "image":
|
|
192
|
+
return E(t.url) ? we(t.imageType) ? null : `unknown image type ${o(t.imageType)}` : "an image document needs a root-relative url";
|
|
193
|
+
case "media":
|
|
194
|
+
return E(t.url) ? Ae(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
|
|
195
|
+
case "spreadsheet":
|
|
196
|
+
return E(t.url) ? Pe(t) : "a spreadsheet document needs a root-relative url";
|
|
197
|
+
case "file":
|
|
198
|
+
return E(t.url) ? null : "a file document needs a root-relative url";
|
|
199
|
+
}
|
|
200
|
+
}, bt = (e) => W(e) === null, Ot = (e) => {
|
|
201
|
+
if (e === null || typeof e != "object") return !1;
|
|
202
|
+
const t = e;
|
|
203
|
+
return t.kind === "failure" ? W(t) === null : t.kind === "text" && typeof t.name == "string" && K(t) === null;
|
|
204
|
+
}, $e = (e) => {
|
|
205
|
+
if (e === null) return null;
|
|
206
|
+
if (typeof e != "object") return "a markdown document's edit must be null or an object";
|
|
207
|
+
const { kind: t, href: n } = e;
|
|
208
|
+
return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : G(n);
|
|
209
|
+
}, Le = (e) => {
|
|
210
|
+
if (e === null) return null;
|
|
211
|
+
if (typeof e != "object") return "a spreadsheet document's edit must be null or an object";
|
|
212
|
+
const { kind: t, href: n } = e;
|
|
213
|
+
return t !== "external" ? `a spreadsheet document's edit must be external; got ${o(t)}` : G(n);
|
|
214
|
+
}, Pe = (e) => {
|
|
215
|
+
if (!xe(e.format)) return `unknown spreadsheet format ${o(e.format)}`;
|
|
216
|
+
const { firstSheetText: t } = e;
|
|
217
|
+
return t !== null && !p(ge, t) ? `a spreadsheet document's firstSheetText must be csv, tsv or null; got ${o(t)}` : t !== null && e.format !== "workbook" ? "only a workbook's spreadsheet document names a firstSheetText" : Le(e.edit);
|
|
218
|
+
}, G = (e) => De(e) ? null : `an external edit needs an absolute https: href; got ${o(e)}`, De = (e) => {
|
|
219
|
+
if (typeof e != "string") return !1;
|
|
220
|
+
try {
|
|
221
|
+
return new URL(e).protocol === "https:";
|
|
222
|
+
} catch {
|
|
223
|
+
return !1;
|
|
224
|
+
}
|
|
225
|
+
}, y = (e) => typeof e == "string" && e.length > 0 && e.length <= M, je = (e) => E(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, Ne = (e) => {
|
|
226
|
+
if (e === null || typeof e != "object") return "a revision must be an object";
|
|
227
|
+
const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: c } = e;
|
|
228
|
+
return y(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof c != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${M} characters; got ${o(t)}`;
|
|
229
|
+
}, g = (e, t) => {
|
|
230
|
+
if (e === null || typeof e != "object") return "an answer must be an object";
|
|
231
|
+
const n = e, { kind: r } = n;
|
|
232
|
+
if (r === "failure") return m(n.failure);
|
|
233
|
+
if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${o(r)}`;
|
|
234
|
+
switch (r) {
|
|
235
|
+
case "grant":
|
|
236
|
+
return je(n);
|
|
237
|
+
case "edit":
|
|
238
|
+
return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : y(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
|
|
239
|
+
case "draft":
|
|
240
|
+
return typeof n.text == "string" ? null : "a draft source needs text";
|
|
241
|
+
case "saved":
|
|
242
|
+
return y(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
|
|
243
|
+
case "conflict":
|
|
244
|
+
return typeof n.text != "string" ? "a conflict needs the current text" : y(n.version) ? null : `a conflict needs the current version; got ${o(n.version)}`;
|
|
245
|
+
case "preview": {
|
|
246
|
+
const { htmlContent: s, headings: i } = n;
|
|
247
|
+
if (typeof s != "string" || !Array.isArray(i)) return "a preview needs htmlContent and headings";
|
|
248
|
+
for (const c of i) {
|
|
249
|
+
const u = V(c);
|
|
250
|
+
if (u !== null) return u;
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
case "revisions": {
|
|
255
|
+
if (!Array.isArray(n.revisions)) return "revisions need an array";
|
|
256
|
+
for (const s of n.revisions) {
|
|
257
|
+
const i = Ne(s);
|
|
258
|
+
if (i !== null) return i;
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
case "revision":
|
|
263
|
+
return typeof n.text != "string" ? "a revision answer needs text" : y(n.id) ? null : `a revision answer needs an id; got ${o(n.id)}`;
|
|
264
|
+
default:
|
|
265
|
+
return `unexpected answer kind ${o(r)}`;
|
|
266
|
+
}
|
|
267
|
+
}, Ie = Object.freeze(["edit", "draft", "grant"]), Ue = Object.freeze(["saved", "conflict", "grant"]), Y = Object.freeze(["preview"]), ve = Object.freeze(["revisions"]), ze = Object.freeze(["revision"]), _t = (e) => g(e, Ie) === null, At = (e) => g(e, Ue) === null, wt = (e) => g(e, Y) === null, xt = (e) => g(e, ve) === null, St = (e) => g(e, ze) === null, Tt = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : g(e, Y), kt = (e, t) => ({ kind: "failure", failure: Ce(e, t) }), Ce = (e, t) => X(t) ? { reason: e, code: t } : { reason: e }, Me = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card", "issue-id", "resolve-id"]), R = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as", id: "id" }), Xe = "asset", He = "link-card", $t = (e, t, n) => {
|
|
268
|
+
const r = `${e}/${Xe}?${R.path}=${encodeURIComponent(t)}`;
|
|
269
|
+
return n === null ? r : `${r}&${R.version}=${encodeURIComponent(n)}`;
|
|
270
|
+
}, B = "text", Z = "workbook", Lt = (e) => {
|
|
271
|
+
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${o(e)}`);
|
|
272
|
+
return `${e}&${R.display}=${B}`;
|
|
273
|
+
}, Pt = (e) => {
|
|
274
|
+
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${o(e)}`);
|
|
275
|
+
return `${e}&${R.display}=${Z}`;
|
|
276
|
+
}, Dt = (e) => {
|
|
277
|
+
const t = e.getAll(R.display);
|
|
278
|
+
return t.length === 0 ? "file" : t.length !== 1 ? null : t[0] === B ? "text" : t[0] === Z ? "workbook" : null;
|
|
279
|
+
}, jt = (e) => `${e}/${He}`, Nt = "X-Markdown-Explorer-Scope", It = "X-Markdown-Explorer", Ut = "refresh", vt = "edit", zt = "document-id", Ct = "text/markdown", Mt = (e) => Me.includes(e), Fe = Object.freeze({
|
|
280
|
+
invalid: 400,
|
|
281
|
+
unauthorized: 401,
|
|
282
|
+
forbidden: 403,
|
|
283
|
+
"not-found": 404,
|
|
284
|
+
"too-large": 413,
|
|
285
|
+
"not-configured": 500,
|
|
286
|
+
unsupported: 500,
|
|
287
|
+
failed: 500
|
|
288
|
+
}), Xt = (e) => {
|
|
289
|
+
const [t, ...n] = C.filter((r) => Fe[r] === e);
|
|
290
|
+
return t !== void 0 && n.length === 0 ? t : "failed";
|
|
291
|
+
}, Ve = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, Ke = /^[\u0000- ]+|[\u0000- ]+$/gu, We = /[\t\n\r]/gu, Ge = /^[a-z][a-z\d+.-]*:/iu, Ye = /^(?:\.|%2e){1,2}$/iu, Be = /* @__PURE__ */ new Set(["ftp:", "file:", "http:", "https:", "ws:", "wss:"]), Ze = Object.freeze(["http:", "https:"]), qe = "http://path.invalid", I = Object.freeze(["origins", "resources", "links", "media"]), A = (e) => Ve.test(e) && !e.split("/").some((t) => t === "." || t === ".."), Qe = (e) => {
|
|
292
|
+
if (!URL.canParse(e)) return !1;
|
|
293
|
+
const t = new URL(e);
|
|
294
|
+
return t.host !== "" && e === `${t.protocol}//${t.host}`;
|
|
295
|
+
}, Je = (e) => {
|
|
296
|
+
if (!URL.canParse(e)) return !1;
|
|
297
|
+
const t = new URL(e);
|
|
298
|
+
return (t.protocol === "http:" || t.protocol === "https:") && e === `${t.origin}${t.pathname}` && A(t.pathname);
|
|
299
|
+
}, et = (e) => q(e) && Object.keys(e).length === I.length && I.every((t) => {
|
|
300
|
+
const n = Object.hasOwn(e, t) ? e[t] : void 0;
|
|
301
|
+
return Array.isArray(n) && Array.from(n).every((r) => typeof r == "string");
|
|
302
|
+
}), b = (e) => `${e.protocol}//${e.hostname.replace(/\.+$/u, "")}${e.port === "" ? "" : `:${e.port}`}`, O = (e, t) => t.some((n) => e === n || e.startsWith(`${n}/`)), tt = (e) => e.slice(0, e.search(/[?#]|$/u)).split("/").some((t) => Ye.test(t)), nt = (e, t) => {
|
|
303
|
+
switch (t) {
|
|
304
|
+
case "document-link":
|
|
305
|
+
return !0;
|
|
306
|
+
case "link":
|
|
307
|
+
return !tt(e);
|
|
308
|
+
case "svg-reference":
|
|
309
|
+
return e.startsWith("#");
|
|
310
|
+
default:
|
|
311
|
+
return !1;
|
|
312
|
+
}
|
|
313
|
+
}, rt = (e) => {
|
|
314
|
+
if (!et(e)) throw new TypeError("[markdown-explorer] the HTML sanitizer's ownUrls must be a plain object of exactly origins, resources, links and media, each an array of strings");
|
|
315
|
+
const t = [
|
|
316
|
+
["origins", Qe, "an origin as the browser writes it (scheme://host[:port])"],
|
|
317
|
+
["resources", A, 'a mount path ("/" and segments of letters, digits and "._~-", without a "." or ".." segment or a trailing "/")'],
|
|
318
|
+
["links", A, 'a mount path ("/" and segments of letters, digits and "._~-", without a "." or ".." segment or a trailing "/")'],
|
|
319
|
+
["media", Je, "an absolute http: or https: URL as the browser writes it, of an origin and a mount path"]
|
|
320
|
+
];
|
|
321
|
+
for (const [n, r, s] of t)
|
|
322
|
+
for (const [i, c] of e[n].entries())
|
|
323
|
+
if (!r(c)) throw new RangeError(`[markdown-explorer] the HTML sanitizer's ownUrls.${n}[${String(i)}] must be ${s}; got ${o(c)}`);
|
|
324
|
+
return Object.freeze({ origins: Object.freeze([...e.origins]), resources: Object.freeze([...e.resources]), links: Object.freeze([...e.links]), media: Object.freeze([...e.media]) });
|
|
325
|
+
}, Ht = (e) => {
|
|
326
|
+
const t = rt(e), n = t.origins.map((a) => new URL(a)), r = new Set(n.map(b)), s = new Set(n.map((a) => a.protocol).filter((a) => !Be.has(a))), i = t.media.map((a) => {
|
|
327
|
+
const f = new URL(a);
|
|
328
|
+
return { key: b(f), path: f.pathname };
|
|
329
|
+
}), c = new Set(i.map((a) => a.key)), u = n.length === 0 ? Ze : [...new Set(n.map((a) => a.protocol))], T = (a) => a === "link" || a === "document-link" ? t.links : t.resources, k = (a, f) => {
|
|
330
|
+
const l = b(a), h = r.has(l) || s.has(a.protocol);
|
|
331
|
+
return !(h || c.has(l)) || h && O(a.pathname, T(f)) ? !0 : f === "media" && i.some(($) => $.key === l && O(a.pathname, [$.path]));
|
|
332
|
+
};
|
|
333
|
+
return (a, f) => {
|
|
334
|
+
const l = a.replace(Ke, "").replace(We, "");
|
|
335
|
+
return l.includes("\\") ? !1 : Ge.test(l) ? URL.canParse(l) && k(new URL(l), f) : l.startsWith("//") ? u.every((h) => URL.canParse(`${h}${l}`) && k(new URL(`${h}${l}`), f)) : l.startsWith("/") ? O(new URL(l, qe).pathname, T(f)) : nt(l, f);
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
export {
|
|
339
|
+
Ot as $,
|
|
340
|
+
Fe as A,
|
|
341
|
+
Mt as B,
|
|
342
|
+
It as C,
|
|
343
|
+
ne as D,
|
|
344
|
+
ft as E,
|
|
345
|
+
Ut as F,
|
|
346
|
+
vt as G,
|
|
347
|
+
zt as H,
|
|
348
|
+
Nt as I,
|
|
349
|
+
R as J,
|
|
350
|
+
w as K,
|
|
351
|
+
Dt as L,
|
|
352
|
+
te as M,
|
|
353
|
+
it as N,
|
|
354
|
+
Ct as O,
|
|
355
|
+
A as P,
|
|
356
|
+
Je as Q,
|
|
357
|
+
Qe as R,
|
|
358
|
+
jt as S,
|
|
359
|
+
ot as T,
|
|
360
|
+
Tt as U,
|
|
361
|
+
O as V,
|
|
362
|
+
Lt as W,
|
|
363
|
+
Pt as X,
|
|
364
|
+
at as Y,
|
|
365
|
+
Xt as Z,
|
|
366
|
+
m as _,
|
|
367
|
+
ut as a,
|
|
368
|
+
gt as a0,
|
|
369
|
+
Et as a1,
|
|
370
|
+
ke as a2,
|
|
371
|
+
yt as a3,
|
|
372
|
+
ht as a4,
|
|
373
|
+
Rt as a5,
|
|
374
|
+
St as a6,
|
|
375
|
+
xt as a7,
|
|
376
|
+
wt as a8,
|
|
377
|
+
At as a9,
|
|
378
|
+
_t as aa,
|
|
379
|
+
bt as ab,
|
|
380
|
+
d as ac,
|
|
381
|
+
U as ad,
|
|
382
|
+
M as ae,
|
|
383
|
+
C as af,
|
|
384
|
+
j as b,
|
|
385
|
+
Ht as c,
|
|
386
|
+
et as d,
|
|
387
|
+
$t as e,
|
|
388
|
+
lt as f,
|
|
389
|
+
kt as g,
|
|
390
|
+
Oe as h,
|
|
391
|
+
x as i,
|
|
392
|
+
X as j,
|
|
393
|
+
Ce as k,
|
|
394
|
+
ct as l,
|
|
395
|
+
N as m,
|
|
396
|
+
Ae as n,
|
|
397
|
+
we as o,
|
|
398
|
+
W as p,
|
|
399
|
+
y as q,
|
|
400
|
+
rt as r,
|
|
401
|
+
Pe as s,
|
|
402
|
+
Ne as t,
|
|
403
|
+
V as u,
|
|
404
|
+
E as v,
|
|
405
|
+
Te as w,
|
|
406
|
+
pt as x,
|
|
407
|
+
mt as y,
|
|
408
|
+
dt as z
|
|
409
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as l, c as g, M as f } from "./sanitizePolicy-
|
|
1
|
+
import { H as l, c as g, M as f } from "./sanitizePolicy-DAPnUUVm.js";
|
|
2
2
|
const d = (s) => s instanceof Error ? `${s.name}: ${s.message}` : String(s), h = (s) => (
|
|
3
3
|
s instanceof l ? { status: "too-large" } : { status: "error", message: d(s) }
|
|
4
4
|
), H = (s) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./sanitizePolicy-
|
|
1
|
+
"use strict";const i=require("./sanitizePolicy-C-ehd0J_.cjs"),z=t=>t instanceof Error?`${t.name}: ${t.message}`:String(t),c=t=>t instanceof i.HtmlNestingLimitError?{status:"too-large"}:{status:"error",message:z(t)},f=t=>{const r=new Map;return s=>{try{const{origins:a,resources:l,links:m,media:g}=s.ownUrls,n=JSON.stringify([s.iframeHosts,s.dataPath,a,l,m,g]);let e=r.get(n);e===void 0&&(e=i.createHtmlSanitizer(t,s.iframeHosts,s.dataPath,i.MAX_HTML_NESTING_DEPTH,s.ownUrls),r.set(n,e));const o=e(s.html);return o.length>s.maxSanitizedChars?{status:"too-large"}:{status:"sanitized",html:o}}catch(a){return c(a)}}};exports.createJobSanitizer=f;exports.sanitizeJobFailureOf=c;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const z=require("@aiquants/markdown/code-blocks"),f=require("@aiquants/markdown/embeds"),p=require("@aiquants/markdown/source-lines"),_=require("./ownUrls-
|
|
1
|
+
"use strict";const z=require("@aiquants/markdown/code-blocks"),f=require("@aiquants/markdown/embeds"),p=require("@aiquants/markdown/source-lines"),_=require("./ownUrls-BTPGNhBt.cjs"),C=require("./describeValue-Ccvhbt36.cjs"),M=256;class w extends RangeError{constructor(s){super(`[markdown-explorer] the HTML nests deeper than ${String(s)} levels`),this.name="HtmlNestingLimitError"}}const H=["script","style","noscript","template","form","button","textarea","select","option","object","embed","base","meta","link","frame","frameset"],B=["srcdoc","formaction"],x=/^(?:(?:https?|mailto|tel):|[^a-z]|[a-z][a-z\d+.-]*(?:[^a-z\d+.:-]|$))/iu,j=new Set(["left","right","center","justify","start","end"]),F=new Set(["h1","h2","h3","h4","h5","h6"]),m=1,G=3,P=7,y=8,V="http://www.w3.org/1999/xhtml",W="http://www.w3.org/2000/svg",v=Object.freeze(["src","poster","background","href","xlink:href"]),q=new Set(["video","audio","source"]),X=Object.freeze(["clip-path","color-profile","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),$=Object.freeze(["image-set(","image(","src(","element(","cross-fade("]),K=/url\([\t\n\f\r ]*["']?(#?)/gu,Y=new Set([" ",`
|
|
2
2
|
`,"\f","\r"," "]),R=Object.freeze({a:Object.freeze(["target","data-link-kind","data-doc-path","data-doc-exists","data-footnote-ref","data-footnote-backref"]),area:Object.freeze(["target"]),img:Object.freeze(["data-asset-src","data-asset-exists"]),section:Object.freeze(["data-footnotes"]),code:Object.freeze([z.CODE_META_ATTRIBUTE]),iframe:Object.freeze(["allow","allowfullscreen","frameborder","referrerpolicy"])}),Z=[...new Set([...Object.values(R).flatMap(t=>t.filter(s=>s.startsWith("data-"))),p.SOURCE_LINES_ATTRIBUTE])],J=new Set(["src","href","xlink:href"]),Q=/^data:/iu,ee=Object.freeze({FORBID_TAGS:H,FORBID_ATTR:B,ADD_TAGS:["iframe"],ADD_ATTR:(t,s)=>t===p.SOURCE_LINES_ATTRIBUTE||R[s]?.includes(t)===!0,ADD_URI_SAFE_ATTR:Z,ALLOWED_URI_REGEXP:x,ALLOW_DATA_ATTR:!1}),te=t=>{let s=null;for(const i of t.split(";")){const n=i.indexOf(":");if(n<0||i.slice(0,n).trim().toLowerCase()!=="text-align")continue;const c=i.slice(n+1).trim().toLowerCase();j.has(c)&&(s=c)}return s===null?null:`text-align: ${s}`},re=t=>t.nodeType===G?{kind:"text",text:t.nodeValue??""}:t.nodeType===y||t.nodeType===P?{kind:"ignored"}:t.nodeType===m&&t.nodeName.toLowerCase()==="a"?{kind:"link",href:t.getAttribute("href")}:{kind:"element"},se=t=>{const s=t.getAttribute("type");return s!==null&&s.trim().toLowerCase()==="checkbox"&&t.hasAttribute("disabled")},I=t=>t.replace(/[A-Z]/gu,s=>s.toLowerCase()),oe=t=>{const s=[],i=c=>Y.has(t.charAt(c));let n=0;for(;n<t.length;){if(i(n)||t.charAt(n)===","){n+=1;continue}const c=n;for(;n<t.length&&!i(n);)n+=1;const A=t.slice(c,n);if(s.push(A.replace(/,+$/u,"")),A.endsWith(","))continue;let T=!1;for(;n<t.length;){const u=t.charAt(n);if(n+=1,T)T=u!==")";else if(u==="(")T=!0;else if(u===",")break}}return s},ae=t=>{if(t.includes("\\"))return!1;const s=I(t);return!$.some(i=>s.includes(i))&&[...s.matchAll(K)].every(i=>i[1]==="#")},ne=(t,s,i)=>i==="src"?q.has(s)?"media":"resource":i!=="href"&&i!=="xlink:href"?"resource":t.namespaceURI===W?s==="image"?"resource":s==="a"&&i==="href"?"link":"svg-reference":i==="xlink:href"?"resource":s==="a"&&t.namespaceURI===V&&t.getAttribute("data-link-kind")==="doc"?"document-link":"link",ie=t=>{const s=t.getAttribute("preload");t.setAttribute("preload",s!==null&&I(s)==="none"?"none":"metadata")},le=(t,s,i,n,c)=>{if(t.isSupported!==!0)throw new Error("[markdown-explorer] the HTML sanitizer cannot run in this environment");if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`[markdown-explorer] the HTML sanitizer's depth limit must be a positive integer; got ${C.describeValue(n)}`);const A=_.createOwnUrlRule(c),T=Object.freeze([...s]);let u=new WeakMap,h=new WeakMap,E;const S=r=>{const e=r.parentNode===null?void 0:u.get(r.parentNode),o=e===void 0?0:e+1;if(u.set(r,o),r.nodeType===m&&o>n)throw new w(n)},b=(r,e)=>{if(r.nodeType!==m)return;const o=r;(e.tagName==="input"&&!se(o)||e.tagName==="iframe"&&f.allowedFrameUrlOf(o.getAttribute("src")?.trim(),T)===null)&&o.parentNode?.removeChild(o)},k=(r,e)=>{const o=r.nodeName.toLowerCase();if(e.attrName==="style"){const a=te(e.attrValue);a===null?e.keepAttr=!1:e.attrValue=a}else if(e.attrName==="allow"&&o==="iframe"){const a=f.reduceFrameFeatures(e.attrValue);a===null?e.keepAttr=!1:e.attrValue=a}else if(e.attrName==="referrerpolicy"&&o==="iframe"){const a=e.attrValue.trim().toLowerCase();f.EMBED_FRAME_REFERRER_POLICIES.has(a)?e.attrValue=a:e.keepAttr=!1}else e.attrName===f.EMBED_LINK_ATTRIBUTE&&o==="p"?h.set(r,r.getAttribute(f.EMBED_LINK_ATTRIBUTE)):J.has(e.attrName)&&Q.test(e.attrValue)||e.attrName===p.SOURCE_LINES_ATTRIBUTE&&p.parseSourceLines(e.attrValue)===null?e.keepAttr=!1:e.attrName==="id"&&F.has(o)&&(e.forceKeepAttr=!0)},L=r=>{const e=r.getAttribute("data-asset-src");e!==null&&(r.getAttribute("data-asset-exists")!=="false"&&_.isAcceptableDocumentPath(e)?r.setAttribute("src",_.explorerAssetHref(i,e,null)):r.removeAttribute("src"))},N=(r,e,o,a)=>{if(E===void 0)return;const l=r.getAttribute(o);if(l===null)return;const d=E({kind:e,path:l});d!==void 0&&r.setAttribute(a,String(d))},O=r=>{const e=r.parentNode;if(e===null)return;const o=h.get(e);o!=null&&f.placeholderLinkOf(o,[...e.childNodes].map(re))!==null&&e.setAttribute(f.EMBED_LINK_ATTRIBUTE,o)},U=(r,e)=>{for(const a of v){const l=r.getAttribute(a);l!==null&&!A(l,ne(r,e,a))&&r.removeAttribute(a)}const o=r.getAttribute("srcset");o!==null&&!oe(o).every(a=>A(a,"resource"))&&r.removeAttribute("srcset");for(const a of X){const l=r.getAttribute(a);l!==null&&!ae(l)&&r.removeAttribute(a)}},g=r=>{if(r.nodeType!==m)return;const e=r,o=e.nodeName.toLowerCase();o==="img"&&(N(e,"asset","data-asset-src","data-asset-exists"),L(e)),U(e,o),o==="a"?(N(e,"doc","data-doc-path","data-doc-exists"),O(e)):(o==="video"||o==="audio")&&ie(e);const a=e.getAttribute("target");if(a===null||a.trim().toLowerCase()==="_self")return;const l=e.getAttribute("rel"),d=new Set(l===null?[]:l.split(/\s+/u).filter(D=>D!==""));d.add("noopener"),d.add("noreferrer"),e.setAttribute("rel",[...d].join(" "))};return(r,e)=>{u=new WeakMap,h=new WeakMap,E=e,t.addHook("beforeSanitizeElements",S),t.addHook("uponSanitizeElement",b),t.addHook("uponSanitizeAttribute",k),t.addHook("afterSanitizeAttributes",g);try{return t.sanitize(r,ee)}finally{t.removeHook("beforeSanitizeElements",S),t.removeHook("uponSanitizeElement",b),t.removeHook("uponSanitizeAttribute",k),t.removeHook("afterSanitizeAttributes",g),E=void 0}}};exports.HtmlNestingLimitError=w;exports.MAX_HTML_NESTING_DEPTH=M;exports.createHtmlSanitizer=le;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CODE_META_ATTRIBUTE as D } from "@aiquants/markdown/code-blocks";
|
|
2
2
|
import { allowedFrameUrlOf as U, reduceFrameFeatures as z, EMBED_FRAME_REFERRER_POLICIES as C, EMBED_LINK_ATTRIBUTE as E, placeholderLinkOf as M } from "@aiquants/markdown/embeds";
|
|
3
3
|
import { SOURCE_LINES_ATTRIBUTE as h, parseSourceLines as x } from "@aiquants/markdown/source-lines";
|
|
4
|
-
import { c as H, i as j, e as B } from "./ownUrls-
|
|
4
|
+
import { c as H, i as j, e as B } from "./ownUrls-DD0cSCsF.js";
|
|
5
5
|
import { d as F } from "./describeValue-CLlVRO8d.js";
|
|
6
6
|
const be = 256;
|
|
7
7
|
class G extends RangeError {
|