termbeam 1.14.7 → 1.15.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/README.md +2 -0
- package/package.json +1 -1
- package/public/assets/_basePickBy-DjouGdsh.js +1 -0
- package/public/assets/_baseUniq-DYS09A94.js +1 -0
- package/public/assets/arc-brekJh_V.js +1 -0
- package/public/assets/architectureDiagram-2XIMDMQ5-D9p7d_dK.js +36 -0
- package/public/assets/blockDiagram-WCTKOSBZ-B2BK13gZ.js +132 -0
- package/public/assets/c4Diagram-IC4MRINW-BmGrXTfN.js +10 -0
- package/public/assets/channel-C5toNXiA.js +1 -0
- package/public/assets/chunk-4BX2VUAB-I5eit8Lr.js +1 -0
- package/public/assets/chunk-55IACEB6-BKpR8SpD.js +1 -0
- package/public/assets/chunk-FMBD7UC4-Dt_lJu1p.js +15 -0
- package/public/assets/chunk-JSJVCQXG-DPnc_wzj.js +1 -0
- package/public/assets/chunk-KX2RTZJC-B4E2qFI2.js +1 -0
- package/public/assets/chunk-NQ4KR5QH-B3NVqUmA.js +220 -0
- package/public/assets/chunk-QZHKN3VN-Sw_cLRTv.js +1 -0
- package/public/assets/chunk-WL4C6EOR-4qIeQLNy.js +189 -0
- package/public/assets/classDiagram-VBA2DB6C-D4y0fwUO.js +1 -0
- package/public/assets/classDiagram-v2-RAHNMMFH-D4y0fwUO.js +1 -0
- package/public/assets/clone-R2IpC4hJ.js +1 -0
- package/public/assets/cose-bilkent-S5V4N54A-HjULVf9U.js +1 -0
- package/public/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/public/assets/dagre-KLK3FWXG-CiZyaN9C.js +4 -0
- package/public/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/public/assets/diagram-E7M64L7V-6zO1mbsa.js +24 -0
- package/public/assets/diagram-IFDJBPK2-BPunptYj.js +43 -0
- package/public/assets/diagram-P4PSJMXO-DBdxSnG_.js +24 -0
- package/public/assets/erDiagram-INFDFZHY-W6GTubhX.js +70 -0
- package/public/assets/flowDiagram-PKNHOUZH-z2hCkApS.js +162 -0
- package/public/assets/ganttDiagram-A5KZAMGK-DPFE5RMt.js +292 -0
- package/public/assets/gitGraphDiagram-K3NZZRJ6-CcUONJkD.js +65 -0
- package/public/assets/graph-DKnDIJMD.js +1 -0
- package/public/assets/index-6PEqObPX.css +32 -0
- package/public/assets/index-CwxEeE2N.js +391 -0
- package/public/assets/infoDiagram-LFFYTUFH-CIFqamt3.js +2 -0
- package/public/assets/init-Gi6I4Gst.js +1 -0
- package/public/assets/ishikawaDiagram-PHBUUO56-CkSxg1hl.js +70 -0
- package/public/assets/journeyDiagram-4ABVD52K-Dyz49OU3.js +139 -0
- package/public/assets/kanban-definition-K7BYSVSG-1JGSQux8.js +89 -0
- package/public/assets/katex-B1X10hvy.js +261 -0
- package/public/assets/layout-CtbnOt5R.js +1 -0
- package/public/assets/linear-D_o_z79L.js +1 -0
- package/public/assets/mindmap-definition-YRQLILUH-CxnfH_kb.js +68 -0
- package/public/assets/ordinal-Cboi1Yqb.js +1 -0
- package/public/assets/pieDiagram-SKSYHLDU-aVCS7fbB.js +30 -0
- package/public/assets/quadrantDiagram-337W2JSQ-C9m7_FOq.js +7 -0
- package/public/assets/requirementDiagram-Z7DCOOCP-DXKn90a3.js +73 -0
- package/public/assets/sankeyDiagram-WA2Y5GQK-tsMMebjh.js +10 -0
- package/public/assets/sequenceDiagram-2WXFIKYE-Bz02FAcN.js +145 -0
- package/public/assets/stateDiagram-RAJIS63D-ClUO2QUY.js +1 -0
- package/public/assets/stateDiagram-v2-FVOUBMTO-Dfbot3pk.js +1 -0
- package/public/assets/timeline-definition-YZTLITO2-DYAS6m-N.js +61 -0
- package/public/assets/treemap-KZPCXAKY-nIfENT7p.js +162 -0
- package/public/assets/vennDiagram-LZ73GAT5-DgRtErsV.js +34 -0
- package/public/assets/xychartDiagram-JWTSCODW-D9XfRSJG.js +7 -0
- package/public/index.html +2 -2
- package/public/sw.js +1 -1
- package/src/server/routes.js +153 -6
- package/public/assets/index-CC1GAu2S.js +0 -108
- package/public/assets/index-yPsf11Zp.css +0 -32
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{aI as Gt,s as Wt,g as Kt,q as Ht,p as Yt,a as Xt,b as Zt,_ as S,G as St,I as Jt,d as rt,as as Qt,W as $t,X as te,Y as ee,e as ne,z as se,E as ie,F as re}from"./index-CwxEeE2N.js";const kt=(t,n)=>Gt(t,"a",-n),_t=1e-10;function st(t,n){const s=ae(t),e=s.filter(c=>oe(c,t));let i=0,r=0;const o=[];if(e.length>1){const c=Tt(e);for(let u=0;u<e.length;++u){const a=e[u];a.angle=Math.atan2(a.x-c.x,a.y-c.y)}e.sort((u,a)=>a.angle-u.angle);let f=e[e.length-1];for(let u=0;u<e.length;++u){const a=e[u];r+=(f.x+a.x)*(a.y-f.y);const y={x:(a.x+f.x)/2,y:(a.y+f.y)/2};let d=null;for(let m=0;m<a.parentIndex.length;++m)if(f.parentIndex.includes(a.parentIndex[m])){const x=t[a.parentIndex[m]],M=Math.atan2(a.x-x.x,a.y-x.y),T=Math.atan2(f.x-x.x,f.y-x.y);let _=T-M;_<0&&(_+=2*Math.PI);const w=T-_/2;let g=W(y,{x:x.x+x.radius*Math.sin(w),y:x.y+x.radius*Math.cos(w)});g>x.radius*2&&(g=x.radius*2),(d==null||d.width>g)&&(d={circle:x,width:g,p1:a,p2:f,large:g>x.radius,sweep:!0})}d!=null&&(o.push(d),i+=lt(d.circle.radius,d.width),f=a)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let f=!1;for(let u=0;u<t.length;++u)if(W(t[u],c)>Math.abs(c.radius-t[u].radius)){f=!0;break}f?i=r=0:(i=c.radius*c.radius*Math.PI,o.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-_t,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return r/=2,n&&(n.area=i+r,n.arcArea=i,n.polygonArea=r,n.arcs=o,n.innerPoints=e,n.intersectionPoints=s),i+r}function oe(t,n){return n.every(s=>W(t,s)<s.radius+_t)}function ae(t){const n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){const i=Et(t[s],t[e]);for(const r of i)r.parentIndex=[s,e],n.push(r)}return n}function lt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function W(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function xt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);const e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return lt(t,e)+lt(n,i)}function Et(t,n){const s=W(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];const r=(e*e-i*i+s*s)/(2*s),o=Math.sqrt(e*e-r*r),c=t.x+r*(n.x-t.x)/s,f=t.y+r*(n.y-t.y)/s,u=-(n.y-t.y)*(o/s),a=-(n.x-t.x)*(o/s);return[{x:c+u,y:f-a},{x:c-u,y:f+a}]}function Tt(t){const n={x:0,y:0};for(const s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}function le(t,n,s,e){e=e||{};const i=e.maxIterations||100,r=e.tolerance||1e-10,o=t(n),c=t(s);let f=s-n;if(o*c>0)throw"Initial bisect points must have opposite signs";if(o===0)return n;if(c===0)return s;for(let u=0;u<i;++u){f/=2;const a=n+f,y=t(a);if(y*o>=0&&(n=a),Math.abs(f)<r||y===0)return a}return n+f}function ct(t){const n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}function Mt(t,n){return ct(t).map(()=>ct(n))}function tt(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}function ut(t){return Math.sqrt(tt(t,t))}function ht(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}function Q(t,n,s,e,i){for(let r=0;r<t.length;++r)t[r]=n*s[r]+e*i[r]}function zt(t,n,s){s=s||{};const e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,r=s.zeroDelta||.001,o=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,f=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,a=s.psi!==void 0?s.psi:-.5,y=s.sigma!==void 0?s.sigma:.5;let d;const m=n.length,x=new Array(m+1);x[0]=n,x[0].fx=t(n),x[0].id=0;for(let v=0;v<m;++v){const l=n.slice();l[v]=l[v]?l[v]*i:r,x[v+1]=l,x[v+1].fx=t(l),x[v+1].id=v+1}function M(v){for(let l=0;l<v.length;l++)x[m][l]=v[l];x[m].fx=v.fx}const T=(v,l)=>v.fx-l.fx,_=n.slice(),w=n.slice(),g=n.slice(),b=n.slice();for(let v=0;v<e;++v){if(x.sort(T),s.history){const p=x.map(h=>{const j=h.slice();return j.fx=h.fx,j.id=h.id,j});p.sort((h,j)=>h.id-j.id),s.history.push({x:x[0].slice(),fx:x[0].fx,simplex:p})}d=0;for(let p=0;p<m;++p)d=Math.max(d,Math.abs(x[0][p]-x[1][p]));if(Math.abs(x[0].fx-x[m].fx)<o&&d<c)break;for(let p=0;p<m;++p){_[p]=0;for(let h=0;h<m;++h)_[p]+=x[h][p];_[p]/=m}const l=x[m];if(Q(w,1+f,_,-f,l),w.fx=t(w),w.fx<x[0].fx)Q(b,1+u,_,-u,l),b.fx=t(b),b.fx<w.fx?M(b):M(w);else if(w.fx>=x[m-1].fx){let p=!1;if(w.fx>l.fx?(Q(g,1+a,_,-a,l),g.fx=t(g),g.fx<l.fx?M(g):p=!0):(Q(g,1-a*f,_,a*f,l),g.fx=t(g),g.fx<w.fx?M(g):p=!0),p){if(y>=1)break;for(let h=1;h<x.length;++h)Q(x[h],1-y,x[0],y,x[h]),x[h].fx=t(x[h])}}else M(w)}return x.sort(T),{fx:x[0].fx,x:x[0]}}function ce(t,n,s,e,i,r,o){const c=s.fx,f=tt(s.fxprime,n);let u=c,a=c,y=f,d=0;i=i||1,r=r||1e-6,o=o||.1;function m(x,M,T){for(let _=0;_<16;++_)if(i=(x+M)/2,Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||u>=T)M=i;else{if(Math.abs(y)<=-o*f)return i;y*(M-x)>=0&&(M=x),x=i,T=u}return 0}for(let x=0;x<10;++x){if(Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||x&&u>=a)return m(d,i,a);if(Math.abs(y)<=-o*f)return i;if(y>=0)return m(i,d,u);a=u,d=i,i*=2}return i}function ue(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()};const r=n.slice();let o,c,f=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),o=e.fxprime.slice(),ht(o,e.fxprime,-1);for(let a=0;a<u;++a){if(f=ce(t,o,e,i,f),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),!f)ht(o,e.fxprime,-1);else{Q(r,1,i.fxprime,-1,e.fxprime);const y=tt(e.fxprime,e.fxprime),d=Math.max(0,tt(r,i.fxprime)/y);Q(o,d,o,-1,i.fxprime),c=e,e=i,i=c}if(ut(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),e}function At(t,n={}){n.maxIterations=n.maxIterations||500;const s=n.initialLayout||ge,e=n.lossFunction||et,i=he(t,n),r=s(i,n),o=Object.keys(r),c=[];for(const a of o)c.push(r[a].x),c.push(r[a].y);const u=zt(a=>{const y={};for(let d=0;d<o.length;++d){const m=o[d];y[m]={x:a[2*d],y:a[2*d+1],radius:r[m].radius}}return e(y,i)},c,n).x;for(let a=0;a<o.length;++a){const y=o[a];r[y].x=u[2*a],r[y].y=u[2*a+1]}return r}const Rt=1e-10;function ft(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Rt?Math.abs(t-n):le(e=>xt(t,n,e)-s,0,t+n)}function he(t,n={}){const s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(s){const c=new Map;for(const f of e)for(let u=0;u<f.sets.length;u++){const a=String(f.sets[u]);c.set(a,f.size+(c.get(a)||0));for(let y=u+1;y<f.sets.length;y++){const d=String(f.sets[y]),m=`${a};${d}`,x=`${d};${a}`;c.set(m,f.size+(c.get(m)||0)),c.set(x,f.size+(c.get(x)||0))}}for(const f of e)f.sets.length<3&&(f.size=c.get(i(f.sets)))}const r=[],o=new Set;for(const c of e)if(c.sets.length===1)r.push(c.sets[0]);else if(c.sets.length===2){const f=c.sets[0],u=c.sets[1];o.add(i(c.sets)),o.add(i([u,f]))}r.sort((c,f)=>c===f?0:c<f?-1:1);for(let c=0;c<r.length;++c){const f=r[c];for(let u=c+1;u<r.length;++u){const a=r[u];o.has(i([f,a]))||e.push({sets:[f,a],size:0})}}return e}function fe(t,n,s){const e=Mt(n.length,n.length),i=Mt(n.length,n.length);return t.filter(r=>r.sets.length===2).forEach(r=>{const o=s[r.sets[0]],c=s[r.sets[1]],f=Math.sqrt(n[o].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),a=ft(f,u,r.size);e[o][c]=e[c][o]=a;let y=0;r.size+1e-10>=Math.min(n[o].size,n[c].size)?y=1:r.size<=1e-10&&(y=-1),i[o][c]=i[c][o]=y}),{distances:e,constraints:i}}function de(t,n,s,e){for(let r=0;r<n.length;++r)n[r]=0;let i=0;for(let r=0;r<s.length;++r){const o=t[2*r],c=t[2*r+1];for(let f=r+1;f<s.length;++f){const u=t[2*f],a=t[2*f+1],y=s[r][f],d=e[r][f],m=(u-o)*(u-o)+(a-c)*(a-c),x=Math.sqrt(m),M=m-y*y;d>0&&x<=y||d<0&&x>=y||(i+=2*M*M,n[2*r]+=4*M*(o-u),n[2*r+1]+=4*M*(c-a),n[2*f]+=4*M*(u-o),n[2*f+1]+=4*M*(a-c))}}return i}function ge(t,n={}){let s=ye(t,n);const e=n.lossFunction||et;if(t.length>=8){const i=xe(t,n),r=e(i,t),o=e(s,t);r+1e-8<o&&(s=i)}return s}function xe(t,n={}){const s=n.restarts||10,e=[],i={};for(const d of t)d.sets.length===1&&(i[d.sets[0]]=e.length,e.push(d));let{distances:r,constraints:o}=fe(t,e,i);const c=ut(r.map(ut))/r.length;r=r.map(d=>d.map(m=>m/c));const f=(d,m)=>de(d,m,r,o);let u=null;for(let d=0;d<s;++d){const m=ct(r.length*2).map(Math.random),x=ue(f,m,n);(!u||x.fx<u.fx)&&(u=x)}const a=u.x,y={};for(let d=0;d<e.length;++d){const m=e[d];y[m.sets[0]]={x:a[2*d]*c,y:a[2*d+1]*c,radius:Math.sqrt(m.size/Math.PI)}}if(n.history)for(const d of n.history)ht(d.x,c);return y}function ye(t,n){const s=n&&n.lossFunction?n.lossFunction:et,e={},i={};for(const y of t)if(y.sets.length===1){const d=y.sets[0];e[d]={x:1e10,y:1e10,rowid:e.length,size:y.size,radius:Math.sqrt(y.size/Math.PI)},i[d]=[]}t=t.filter(y=>y.sets.length===2);for(const y of t){let d=y.weight!=null?y.weight:1;const m=y.sets[0],x=y.sets[1];y.size+Rt>=Math.min(e[m].size,e[x].size)&&(d=0),i[m].push({set:x,size:y.size,weight:d}),i[x].push({set:m,size:y.size,weight:d})}const r=[];Object.keys(i).forEach(y=>{let d=0;for(let m=0;m<i[y].length;++m)d+=i[y][m].size*i[y][m].weight;r.push({set:y,size:d})});function o(y,d){return d.size-y.size}r.sort(o);const c={};function f(y){return y.set in c}function u(y,d){e[d].x=y.x,e[d].y=y.y,c[d]=!0}u({x:0,y:0},r[0].set);for(let y=1;y<r.length;++y){const d=r[y].set,m=i[d].filter(f),x=e[d];if(m.sort(o),m.length===0)throw"ERROR: missing pairwise overlap information";const M=[];for(var a=0;a<m.length;++a){const w=e[m[a].set],g=ft(x.radius,w.radius,m[a].size);M.push({x:w.x+g,y:w.y}),M.push({x:w.x-g,y:w.y}),M.push({y:w.y+g,x:w.x}),M.push({y:w.y-g,x:w.x});for(let b=a+1;b<m.length;++b){const v=e[m[b].set],l=ft(x.radius,v.radius,m[b].size),p=Et({x:w.x,y:w.y,radius:g},{x:v.x,y:v.y,radius:l});M.push(...p)}}let T=1e50,_=M[0];for(const w of M){e[d].x=w.x,e[d].y=w.y;const g=s(e,t);g<T&&(T=g,_=w)}u(_,d)}return e}function et(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const o=t[e.sets[0]],c=t[e.sets[1]];i=xt(o.radius,c.radius,W(o,c))}else i=st(e.sets.map(o=>t[o]));const r=e.weight!=null?e.weight:1;s+=r*(i-e.size)*(i-e.size)}return s}function Ct(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const c=t[e.sets[0]],f=t[e.sets[1]];i=xt(c.radius,f.radius,W(c,f))}else i=st(e.sets.map(c=>t[c]));const r=e.weight!=null?e.weight:1,o=Math.log((i+1)/(e.size+1));s+=r*o*o}return s}function pe(t,n,s){if(s==null?t.sort((i,r)=>r.radius-i.radius):t.sort(s),t.length>0){const i=t[0].x,r=t[0].y;for(const o of t)o.x-=i,o.y-=r}if(t.length===2&&W(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const i=Math.atan2(t[1].x,t[1].y)-n,r=Math.cos(i),o=Math.sin(i);for(const c of t){const f=c.x,u=c.y;c.x=r*f-o*u,c.y=o*f+r*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){const r=t[1].y/(1e-10+t[1].x);for(const o of t){var e=(o.x+r*o.y)/(1+r*r);o.x=2*e-o.x,o.y=2*e*r-o.y}}}}function me(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}function s(i,r){const o=n(i),c=n(r);o.parent=c}for(let i=0;i<t.length;++i)for(let r=i+1;r<t.length;++r){const o=t[i].radius+t[r].radius;W(t[i],t[r])+1e-10<o&&s(t[r],t[i])}const e=new Map;for(let i=0;i<t.length;++i){const r=n(t[i]).parent.setid;e.has(r)||e.set(r,[]),e.get(r).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}function dt(t){const n=s=>{const e=t.reduce((r,o)=>Math.max(r,o[s]+o.radius),Number.NEGATIVE_INFINITY),i=t.reduce((r,o)=>Math.min(r,o[s]-o.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}};return{xRange:n("x"),yRange:n("y")}}function Dt(t,n,s){n==null&&(n=Math.PI/2);let e=Ft(t).map(u=>Object.assign({},u));const i=me(e);for(const u of i){pe(u,n,s);const a=dt(u);u.size=(a.xRange.max-a.xRange.min)*(a.yRange.max-a.yRange.min),u.bounds=a}i.sort((u,a)=>a.size-u.size),e=i[0];let r=e.bounds;const o=(r.xRange.max-r.xRange.min)/50;function c(u,a,y){if(!u)return;const d=u.bounds;let m,x;if(a)m=r.xRange.max-d.xRange.min+o;else{m=r.xRange.max-d.xRange.max;const M=(d.xRange.max-d.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;M<0&&(m+=M)}if(y)x=r.yRange.max-d.yRange.min+o;else{x=r.yRange.max-d.yRange.max;const M=(d.yRange.max-d.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;M<0&&(x+=M)}for(const M of u)M.x+=m,M.y+=x,e.push(M)}let f=1;for(;f<i.length;)c(i[f],!0,!1),c(i[f+1],!1,!0),c(i[f+2],!0,!0),f+=3,r=dt(e);return Ot(e)}function Nt(t,n,s,e,i){const r=Ft(t);n-=2*e,s-=2*e;const{xRange:o,yRange:c}=dt(r);if(o.max===o.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let f,u;if(i){const m=Math.sqrt(i/Math.PI)*2;f=n/m,u=s/m}else f=n/(o.max-o.min),u=s/(c.max-c.min);const a=Math.min(u,f),y=(n-(o.max-o.min)*a)/2,d=(s-(c.max-c.min)*a)/2;return Ot(r.map(m=>({radius:a*m.radius,x:e+y+(m.x-o.min)*a,y:e+d+(m.y-c.min)*a,setid:m.setid})))}function Ot(t){const n={};for(const s of t)n[s.setid]=s;return n}function Ft(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}function be(t={}){let n=!1,s=600,e=350,i=15,r=1e3,o=Math.PI/2,c=!0,f=null,u=!0,a=!0,y=null,d=null,m=!1,x=null,M=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,T={},_=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],w=0,g=function(p){if(p in T)return T[p];var h=T[p]=_[w];return w+=1,w>=_.length&&(w=0),h},b=At,v=et;function l(p){let h=p.datum();const j=new Set;h.forEach(I=>{I.size==0&&I.sets.length==1&&j.add(I.sets[0])}),h=h.filter(I=>!I.sets.some(L=>j.has(L)));let k={},N={};if(h.length>0){let I=b(h,{lossFunction:v,distinct:m});c&&(I=Dt(I,o,d)),k=Nt(I,s,e,i,f),N=jt(k,h,M)}const Y={};h.forEach(I=>{I.label&&(Y[I.sets]=I.label)});function B(I){if(I.sets in Y)return Y[I.sets];if(I.sets.length==1)return""+I.sets[0]}p.selectAll("svg").data([k]).enter().append("svg");const U=p.select("svg");n?U.attr("viewBox",`0 0 ${s} ${e}`):U.attr("width",s).attr("height",e);const q={};let z=!1;U.selectAll(".venn-area path").each(function(I){const L=this.getAttribute("d");I.sets.length==1&&L&&!m&&(z=!0,q[I.sets[0]]=ke(L))});function A(I){return L=>{const G=I.sets.map(Z=>{let H=q[Z],J=k[Z];return H||(H={x:s/2,y:e/2,radius:1}),J||(J={x:s/2,y:e/2,radius:1}),{x:H.x*(1-L)+J.x*L,y:H.y*(1-L)+J.y*L,radius:H.radius*(1-L)+J.radius*L}});return wt(G,x)}}const C=U.selectAll(".venn-area").data(h,I=>I.sets),O=C.enter().append("g").attr("class",I=>`venn-area venn-${I.sets.length==1?"circle":"intersection"}${I.colour||I.color?" venn-coloured":""}`).attr("data-venn-sets",I=>I.sets.join("_")),P=O.append("path"),V=O.append("text").attr("class","label").text(I=>B(I)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);a&&(P.style("fill-opacity","0").filter(I=>I.sets.length==1).style("fill",I=>I.colour?I.colour:I.color?I.color:g(I.sets)).style("fill-opacity",".25"),V.style("fill",I=>I.colour||I.color?"#FFF":t.textFill?t.textFill:I.sets.length==1?g(I.sets):"#444"));function R(I){return typeof I.transition=="function"?I.transition("venn").duration(r):I}let E=p;z&&typeof E.transition=="function"?(E=R(p),E.selectAll("path").attrTween("d",A)):E.selectAll("path").attr("d",I=>wt(I.sets.map(L=>k[L])),x);const F=E.selectAll("text").filter(I=>I.sets in N).text(I=>B(I)).attr("x",I=>Math.floor(N[I.sets].x)).attr("y",I=>Math.floor(N[I.sets].y));u&&(z?"on"in F?F.on("end",ot(k,B)):F.each("end",ot(k,B)):F.each(ot(k,B)));const D=R(C.exit()).remove();typeof C.transition=="function"&&D.selectAll("path").attrTween("d",A);const X=D.selectAll("text").attr("x",s/2).attr("y",e/2);return y!==null&&(V.style("font-size","0px"),F.style("font-size",y),X.style("font-size","0px")),{circles:k,textCentres:N,nodes:C,enter:O,update:E,exit:D}}return l.wrap=function(p){return arguments.length?(u=p,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(p){return arguments.length?(s=p,l):s},l.height=function(p){return arguments.length?(e=p,l):e},l.padding=function(p){return arguments.length?(i=p,l):i},l.distinct=function(p){return arguments.length?(m=p,l):m},l.colours=function(p){return arguments.length?(g=p,l):g},l.colors=function(p){return arguments.length?(g=p,l):g},l.fontSize=function(p){return arguments.length?(y=p,l):y},l.round=function(p){return arguments.length?(x=p,l):x},l.duration=function(p){return arguments.length?(r=p,l):r},l.layoutFunction=function(p){return arguments.length?(b=p,l):b},l.normalize=function(p){return arguments.length?(c=p,l):c},l.scaleToFit=function(p){return arguments.length?(f=p,l):f},l.styled=function(p){return arguments.length?(a=p,l):a},l.orientation=function(p){return arguments.length?(o=p,l):o},l.orientationOrder=function(p){return arguments.length?(d=p,l):d},l.lossFunction=function(p){return arguments.length?(v=p==="default"?et:p==="logRatio"?Ct:p,l):v},l}function ot(t,n){return function(s){const e=this,i=t[s.sets[0]].radius||50,r=n(s)||"",o=r.split(/\s+/).reverse(),f=(r.length+o.length)/3;let u=o.pop(),a=[u],y=0;const d=1.1;e.textContent=null;const m=[];function x(g){const b=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return b.textContent=g,m.push(b),e.append(b),b}let M=x(u);for(;u=o.pop(),!!u;){a.push(u);const g=a.join(" ");M.textContent=g,g.length>f&&M.getComputedTextLength()>i&&(a.pop(),M.textContent=a.join(" "),a=[u],M=x(u),y++)}const T=.35-y*d/2,_=e.getAttribute("x"),w=e.getAttribute("y");m.forEach((g,b)=>{g.setAttribute("x",_),g.setAttribute("y",w),g.setAttribute("dy",`${T+b*d}em`)})}}function at(t,n,s){let e=n[0].radius-W(n[0],t);for(let i=1;i<n.length;++i){const r=n[i].radius-W(n[i],t);r<=e&&(e=r)}for(let i=0;i<s.length;++i){const r=W(s[i],t)-s[i].radius;r<=e&&(e=r)}return e}function Lt(t,n,s){const e=[];for(const a of t)e.push({x:a.x,y:a.y}),e.push({x:a.x+a.radius/2,y:a.y}),e.push({x:a.x-a.radius/2,y:a.y}),e.push({x:a.x,y:a.y+a.radius/2}),e.push({x:a.x,y:a.y-a.radius/2});let i=e[0],r=at(e[0],t,n);for(let a=1;a<e.length;++a){const y=at(e[a],t,n);y>=r&&(i=e[a],r=y)}const o=zt(a=>-1*at({x:a[0],y:a[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:o[0],y:o[1]};let f=!0;for(const a of t)if(W(c,a)>a.radius){f=!1;break}for(const a of n)if(W(c,a)<a.radius){f=!1;break}if(f)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};const u={};return st(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?Lt(t,[]):Tt(u.arcs.map(a=>a.p1))}function ve(t){const n={},s=Object.keys(t);for(const e of s)n[e]=[];for(let e=0;e<s.length;e++){const i=s[e],r=t[i];for(let o=e+1;o<s.length;++o){const c=s[o],f=t[c],u=W(r,f);u+f.radius<=r.radius+1e-10?n[c].push(i):u+r.radius<=f.radius+1e-10&&n[i].push(c)}}return n}function jt(t,n,s){const e={},i=ve(t);for(let r=0;r<n.length;++r){const o=n[r].sets,c={},f={};for(let d=0;d<o.length;++d){c[o[d]]=!0;const m=i[o[d]];for(let x=0;x<m.length;++x)f[m[x]]=!0}const u=[],a=[];for(let d in t)d in c?u.push(t[d]):d in f||a.push(t[d]);const y=Lt(u,a,s);e[o]=y,y.disjoint&&n[r].size>0&&console.log("WARNING: area "+o+" not represented on screen")}return e}function Ie(t,n,s){const e=[];return e.push(`
|
|
2
|
+
M`,t,n),e.push(`
|
|
3
|
+
m`,-s,0),e.push(`
|
|
4
|
+
a`,s,s,0,1,0,s*2,0),e.push(`
|
|
5
|
+
a`,s,s,0,1,0,-s*2,0),e.join(" ")}function ke(t){const n=t.split(" ");return{x:Number.parseFloat(n[1]),y:Number.parseFloat(n[2]),radius:-Number.parseFloat(n[4])}}function Pt(t){if(t.length===0)return[];const n={};return st(t,n),n.arcs}function Vt(t,n){if(t.length===0)return"M 0 0";const s=Math.pow(10,n||0),e=n!=null?r=>Math.round(r*s)/s:r=>r;if(t.length==1){const r=t[0].circle;return Ie(e(r.x),e(r.y),e(r.radius))}const i=[`
|
|
6
|
+
M`,e(t[0].p2.x),e(t[0].p2.y)];for(const r of t){const o=e(r.circle.radius);i.push(`
|
|
7
|
+
A`,o,o,0,r.large?1:0,r.sweep?1:0,e(r.p1.x),e(r.p1.y))}return i.join(" ")}function wt(t,n){return Vt(Pt(t),n)}function Me(t,n={}){const{lossFunction:s,layoutFunction:e=At,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:o,width:c=600,height:f=350,padding:u=15,scaleToFit:a=!1,symmetricalTextCentre:y=!1,distinct:d,round:m=2}=n;let x=e(t,{lossFunction:s==="default"||!s?et:s==="logRatio"?Ct:s,distinct:d});i&&(x=Dt(x,r,o));const M=Nt(x,c,f,u,a),T=jt(M,t,y),_=new Map(Object.keys(M).map(b=>[b,{set:b,x:M[b].x,y:M[b].y,radius:M[b].radius}])),w=t.map(b=>{const v=b.sets.map(h=>_.get(h)),l=Pt(v),p=Vt(l,m);return{circles:v,arcs:l,path:p,area:b,has:new Set(b.sets)}});function g(b){let v="";for(const l of w)l.has.size>b.length&&b.every(p=>l.has.has(p))&&(v+=" "+l.path);return v}return w.map(({circles:b,arcs:v,path:l,area:p})=>({data:p,text:T[p.sets],circles:b,arcs:v,path:l,distinctPath:l+g(p.sets)}))}var gt=(function(){var t=S(function(w,g,b,v){for(b=b||{},v=w.length;v--;b[w[v]]=g);return b},"o"),n=[5,8],s=[7,8,11,12,17,19,22,24],e=[1,17],i=[1,18],r=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],o=[1,31],c=[1,39],f=[7,8,11,12,17,19,22,24,27],u=[1,57],a=[1,56],y=[1,58],d=[1,59],m=[1,60],x=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],M={trace:S(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:S(function(g,b,v,l,p,h,j){var k=h.length-1;switch(p){case 1:return h[k-1];case 2:case 3:case 4:this.$=[];break;case 5:h[k-1].push(h[k]),this.$=h[k-1];break;case 6:this.$=[];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:this.$=h[k];break;case 8:l.setDiagramTitle(h[k].substr(6)),this.$=h[k].substr(6);break;case 9:l.addSubsetData([h[k]],void 0,void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 10:l.addSubsetData([h[k-1]],h[k],void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 11:l.addSubsetData([h[k-2]],void 0,parseFloat(h[k])),l.setIndentMode&&l.setIndentMode(!0);break;case 12:l.addSubsetData([h[k-3]],h[k-2],parseFloat(h[k])),l.setIndentMode&&l.setIndentMode(!0);break;case 13:if(h[k].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(h[k]),l.addSubsetData(h[k],void 0,void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 14:if(h[k-1].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(h[k-1]),l.addSubsetData(h[k-1],h[k],void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 15:if(h[k-2].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(h[k-2]),l.addSubsetData(h[k-2],void 0,parseFloat(h[k])),l.setIndentMode&&l.setIndentMode(!0);break;case 16:if(h[k-3].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(h[k-3]),l.addSubsetData(h[k-3],h[k-2],parseFloat(h[k])),l.setIndentMode&&l.setIndentMode(!0);break;case 17:case 18:case 19:l.addTextData(h[k-1],h[k],void 0);break;case 20:case 21:l.addTextData(h[k-2],h[k-1],h[k]);break;case 23:l.addStyleData(h[k-1],h[k]);break;case 24:case 25:case 26:var N=l.getCurrentSets();if(!N)throw new Error("text requires set");l.addTextData(N,h[k],void 0);break;case 27:case 28:var N=l.getCurrentSets();if(!N)throw new Error("text requires set");l.addTextData(N,h[k-1],h[k]);break;case 29:case 41:this.$=[h[k]];break;case 30:case 42:this.$=[...h[k-2],h[k]];break;case 31:this.$=[h[k-2],h[k]];break;case 33:this.$=h[k].join(" ");break;case 34:this.$=[h[k]];break;case 35:h[k-1].push(h[k]),this.$=h[k-1];break;case 43:case 44:this.$=h[k];break}},"anonymous"),table:[t(n,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(s,[2,4],{6:5}),t(n,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(s,[2,5]),t(s,[2,6]),t(s,[2,7]),t(s,[2,8]),{13:16,20:e,21:i},{13:20,18:19,20:e,21:i},{13:20,18:21,20:e,21:i},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:e,21:i},t(s,[2,9],{14:[1,27],15:[1,28]}),t(r,[2,43]),t(r,[2,44]),t(s,[2,13],{14:[1,29],15:[1,30],27:o}),t(r,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:o},t(s,[2,22]),t(s,[2,24],{14:[1,35]}),t(s,[2,25],{14:[1,36]}),t(s,[2,26]),{20:c,25:37,26:38,27:o},t(s,[2,10],{15:[1,40]}),{16:[1,41]},t(s,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:e,21:i},t(s,[2,17],{14:[1,45]}),t(s,[2,18],{14:[1,46]}),t(s,[2,19]),t(s,[2,27]),t(s,[2,28]),t(s,[2,23],{27:[1,47]}),t(f,[2,29]),{15:[1,48]},{16:[1,49]},t(s,[2,11]),{16:[1,50]},t(s,[2,15]),t(r,[2,42]),t(s,[2,20]),t(s,[2,21]),{20:c,26:51},{16:u,20:a,21:[1,53],28:52,29:54,30:55,31:y,32:d,33:m},t(s,[2,12]),t(s,[2,16]),t(f,[2,30]),t(f,[2,31]),t(f,[2,32]),t(f,[2,33],{30:61,16:u,20:a,31:y,32:d,33:m}),t(x,[2,34]),t(x,[2,36]),t(x,[2,37]),t(x,[2,38]),t(x,[2,39]),t(x,[2,40]),t(x,[2,35])],defaultActions:{6:[2,1]},parseError:S(function(g,b){if(b.recoverable)this.trace(g);else{var v=new Error(g);throw v.hash=b,v}},"parseError"),parse:S(function(g){var b=this,v=[0],l=[],p=[null],h=[],j=this.table,k="",N=0,Y=0,B=2,U=1,q=h.slice.call(arguments,1),z=Object.create(this.lexer),A={yy:{}};for(var C in this.yy)Object.prototype.hasOwnProperty.call(this.yy,C)&&(A.yy[C]=this.yy[C]);z.setInput(g,A.yy),A.yy.lexer=z,A.yy.parser=this,typeof z.yylloc>"u"&&(z.yylloc={});var O=z.yylloc;h.push(O);var P=z.options&&z.options.ranges;typeof A.yy.parseError=="function"?this.parseError=A.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function V(K){v.length=v.length-2*K,p.length=p.length-K,h.length=h.length-K}S(V,"popStack");function R(){var K;return K=l.pop()||z.lex()||U,typeof K!="number"&&(K instanceof Array&&(l=K,K=l.pop()),K=b.symbols_[K]||K),K}S(R,"lex");for(var E,F,D,X,I={},L,G,Z,H;;){if(F=v[v.length-1],this.defaultActions[F]?D=this.defaultActions[F]:((E===null||typeof E>"u")&&(E=R()),D=j[F]&&j[F][E]),typeof D>"u"||!D.length||!D[0]){var J="";H=[];for(L in j[F])this.terminals_[L]&&L>B&&H.push("'"+this.terminals_[L]+"'");z.showPosition?J="Parse error on line "+(N+1)+`:
|
|
8
|
+
`+z.showPosition()+`
|
|
9
|
+
Expecting `+H.join(", ")+", got '"+(this.terminals_[E]||E)+"'":J="Parse error on line "+(N+1)+": Unexpected "+(E==U?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(J,{text:z.match,token:this.terminals_[E]||E,line:z.yylineno,loc:O,expected:H})}if(D[0]instanceof Array&&D.length>1)throw new Error("Parse Error: multiple actions possible at state: "+F+", token: "+E);switch(D[0]){case 1:v.push(E),p.push(z.yytext),h.push(z.yylloc),v.push(D[1]),E=null,Y=z.yyleng,k=z.yytext,N=z.yylineno,O=z.yylloc;break;case 2:if(G=this.productions_[D[1]][1],I.$=p[p.length-G],I._$={first_line:h[h.length-(G||1)].first_line,last_line:h[h.length-1].last_line,first_column:h[h.length-(G||1)].first_column,last_column:h[h.length-1].last_column},P&&(I._$.range=[h[h.length-(G||1)].range[0],h[h.length-1].range[1]]),X=this.performAction.apply(I,[k,Y,N,A.yy,D[1],p,h].concat(q)),typeof X<"u")return X;G&&(v=v.slice(0,-1*G*2),p=p.slice(0,-1*G),h=h.slice(0,-1*G)),v.push(this.productions_[D[1]][0]),p.push(I.$),h.push(I._$),Z=j[v[v.length-2]][v[v.length-1]],v.push(Z);break;case 3:return!0}}return!0},"parse")},T=(function(){var w={EOF:1,parseError:S(function(b,v){if(this.yy.parser)this.yy.parser.parseError(b,v);else throw new Error(b)},"parseError"),setInput:S(function(g,b){return this.yy=b||this.yy||{},this._input=g,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:S(function(){var g=this._input[0];this.yytext+=g,this.yyleng++,this.offset++,this.match+=g,this.matched+=g;var b=g.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),g},"input"),unput:S(function(g){var b=g.length,v=g.split(/(?:\r\n?|\n)/g);this._input=g+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b),this.offset-=b;var l=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),v.length-1&&(this.yylineno-=v.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:v?(v.length===l.length?this.yylloc.first_column:0)+l[l.length-v.length].length-v[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},"unput"),more:S(function(){return this._more=!0,this},"more"),reject:S(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
10
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:S(function(g){this.unput(this.match.slice(g))},"less"),pastInput:S(function(){var g=this.matched.substr(0,this.matched.length-this.match.length);return(g.length>20?"...":"")+g.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:S(function(){var g=this.match;return g.length<20&&(g+=this._input.substr(0,20-g.length)),(g.substr(0,20)+(g.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:S(function(){var g=this.pastInput(),b=new Array(g.length+1).join("-");return g+this.upcomingInput()+`
|
|
11
|
+
`+b+"^"},"showPosition"),test_match:S(function(g,b){var v,l,p;if(this.options.backtrack_lexer&&(p={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(p.yylloc.range=this.yylloc.range.slice(0))),l=g[0].match(/(?:\r\n?|\n).*/g),l&&(this.yylineno+=l.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:l?l[l.length-1].length-l[l.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+g[0].length},this.yytext+=g[0],this.match+=g[0],this.matches=g,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(g[0].length),this.matched+=g[0],v=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),v)return v;if(this._backtrack){for(var h in p)this[h]=p[h];return!1}return!1},"test_match"),next:S(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var g,b,v,l;this._more||(this.yytext="",this.match="");for(var p=this._currentRules(),h=0;h<p.length;h++)if(v=this._input.match(this.rules[p[h]]),v&&(!b||v[0].length>b[0].length)){if(b=v,l=h,this.options.backtrack_lexer){if(g=this.test_match(v,p[h]),g!==!1)return g;if(this._backtrack){b=!1;continue}else return!1}else if(!this.options.flex)break}return b?(g=this.test_match(b,p[l]),g!==!1?g:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
12
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:S(function(){var b=this.next();return b||this.lex()},"lex"),begin:S(function(b){this.conditionStack.push(b)},"begin"),popState:S(function(){var b=this.conditionStack.length-1;return b>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:S(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:S(function(b){return b=this.conditionStack.length-1-Math.abs(b||0),b>=0?this.conditionStack[b]:"INITIAL"},"topState"),pushState:S(function(b){this.begin(b)},"pushState"),stateStackSize:S(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:S(function(b,v,l,p){switch(l){case 0:break;case 1:break;case 2:break;case 3:if(b.getIndentMode&&b.getIndentMode())return b.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 4:break;case 5:b.setIndentMode&&b.setIndentMode(!1),this.begin("INITIAL"),this.unput(v.yytext);break;case 6:return this.begin("bol"),8;case 7:break;case 8:break;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(b.consumeIndentText)b.consumeIndentText=!1;else return 19;break;case 15:return 24;case 16:return v.yytext=v.yytext.slice(2,-2),14;case 17:return v.yytext=v.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}};return w})();M.lexer=T;function _(){this.yy={}}return S(_,"Parser"),_.prototype=M,M.Parser=_,new _})();gt.parser=gt;var we=gt,yt=[],pt=[],mt=[],bt=new Set,vt,It=!1,Se=S((t,n,s)=>{const e=it(t).sort(),i=s??10/Math.pow(t.length,2);vt=e,e.length===1&&bt.add(e[0]),yt.push({sets:e,size:i,label:n?nt(n):void 0})},"addSubsetData"),_e=S(()=>yt,"getSubsetData"),nt=S(t=>{const n=t.trim();return n.length>=2&&n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n},"normalizeText"),Ee=S(t=>t&&nt(t),"normalizeStyleValue"),Te=S((t,n,s)=>{const e=nt(n);pt.push({sets:it(t).sort(),id:e,label:s?nt(s):void 0})},"addTextData"),ze=S((t,n)=>{const s=it(t).sort(),e={};for(const[i,r]of n)e[i]=Ee(r)??r;mt.push({targets:s,styles:e})},"addStyleData"),Ae=S(()=>mt,"getStyleData"),it=S(t=>t.map(n=>nt(n)),"normalizeIdentifierList"),Re=S(t=>{const s=it(t).filter(e=>!bt.has(e));if(s.length>0)throw new Error(`unknown set identifier: ${s.join(", ")}`)},"validateUnionIdentifiers"),Ce=S(()=>pt,"getTextData"),De=S(()=>vt,"getCurrentSets"),Ne=S(()=>It,"getIndentMode"),Oe=S(t=>{It=t},"setIndentMode"),Fe=re.venn;function Bt(){return ie(Fe,St().venn)}S(Bt,"getConfig");var Le=S(()=>{se(),yt.length=0,pt.length=0,mt.length=0,bt.clear(),vt=void 0,It=!1},"customClear"),je={getConfig:Bt,clear:Le,setAccTitle:Zt,getAccTitle:Xt,setDiagramTitle:Yt,getDiagramTitle:Ht,getAccDescription:Kt,setAccDescription:Wt,addSubsetData:Se,getSubsetData:_e,addTextData:Te,addStyleData:ze,validateUnionIdentifiers:Re,getTextData:Ce,getStyleData:Ae,getCurrentSets:De,getIndentMode:Ne,setIndentMode:Oe},Pe=S(t=>`
|
|
13
|
+
.venn-title {
|
|
14
|
+
font-size: 32px;
|
|
15
|
+
fill: ${t.vennTitleTextColor};
|
|
16
|
+
font-family: ${t.fontFamily};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.venn-circle text {
|
|
20
|
+
font-size: 48px;
|
|
21
|
+
font-family: ${t.fontFamily};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.venn-intersection text {
|
|
25
|
+
font-size: 48px;
|
|
26
|
+
fill: ${t.vennSetTextColor};
|
|
27
|
+
font-family: ${t.fontFamily};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.venn-text-node {
|
|
31
|
+
font-family: ${t.fontFamily};
|
|
32
|
+
color: ${t.vennSetTextColor};
|
|
33
|
+
}
|
|
34
|
+
`,"getStyles"),Ve=Pe;function qt(t){const n=new Map;for(const s of t){const e=s.targets.join("|"),i=n.get(e);i?Object.assign(i,s.styles):n.set(e,{...s.styles})}return n}S(qt,"buildStyleByKey");var Be=S((t,n,s,e)=>{var U,q,z;const i=e.db,r=(U=i.getConfig)==null?void 0:U.call(i),{themeVariables:o,look:c,handDrawnSeed:f}=St(),u=c==="handDrawn",a=[o.venn1,o.venn2,o.venn3,o.venn4,o.venn5,o.venn6,o.venn7,o.venn8].filter(Boolean),y=(q=i.getDiagramTitle)==null?void 0:q.call(i),d=i.getSubsetData(),m=i.getTextData(),x=qt(i.getStyleData()),M=(r==null?void 0:r.width)??800,T=(r==null?void 0:r.height)??450,w=M/1600,g=y?48*w:0,b=o.primaryTextColor??o.textColor,v=Jt(n);v.attr("viewBox",`0 0 ${M} ${T}`),y&&v.append("text").text(y).attr("class","venn-title").attr("font-size",`${32*w}px`).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*w).style("fill",o.vennTitleTextColor||o.titleColor);const l=rt(document.createElement("div")),p=be().width(M).height(T-g);l.datum(d).call(p);const h=u?Qt.svg(l.select("svg").node()):void 0,j=Me(d,{width:M,height:T-g,padding:(r==null?void 0:r.padding)??15}),k=new Map;for(const A of j){const C=$([...A.data.sets].sort());k.set(C,A)}m.length>0&&Ut(r,k,l,m,w,x);const N=$t(o.background||"#f4f4f4");l.selectAll(".venn-circle").each(function(A,C){var L;const O=rt(this),V=$([...A.sets].sort()),R=x.get(V),E=(R==null?void 0:R.fill)||a[C%a.length]||o.primaryColor;O.classed(`venn-set-${C%8}`,!0);const F=(R==null?void 0:R["fill-opacity"])??.1,D=(R==null?void 0:R.stroke)||E,X=(R==null?void 0:R["stroke-width"])||`${5*w}`;if(u&&h){const G=k.get(V);if(G&&G.circles.length>0){const Z=G.circles[0],H=h.circle(Z.x,Z.y,Z.radius*2,{roughness:.7,seed:f,fill:kt(E,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:-41+C*60,stroke:D,strokeWidth:parseFloat(String(X))});O.select("path").remove(),(L=O.node())==null||L.insertBefore(H,O.select("text").node())}}else O.select("path").style("fill",E).style("fill-opacity",F).style("stroke",D).style("stroke-width",X).style("stroke-opacity",.95);const I=(R==null?void 0:R.color)||(N?te(E,30):ee(E,30));O.select("text").style("font-size",`${48*w}px`).style("fill",I)}),u&&h?l.selectAll(".venn-intersection").each(function(A){var E;const C=rt(this),P=$([...A.sets].sort()),V=x.get(P),R=V==null?void 0:V.fill;if(R){const F=C.select("path"),D=F.attr("d");if(D){const X=h.path(D,{roughness:.7,seed:f,fill:kt(R,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),I=F.node();(E=I==null?void 0:I.parentNode)==null||E.insertBefore(X,I),F.remove()}}else C.select("path").style("fill-opacity",0);C.select("text").style("font-size",`${48*w}px`).style("fill",(V==null?void 0:V.color)??o.vennSetTextColor??b)}):(l.selectAll(".venn-intersection text").style("font-size",`${48*w}px`).style("fill",A=>{var P;const O=$([...A.sets].sort());return((P=x.get(O))==null?void 0:P.color)??o.vennSetTextColor??b}),l.selectAll(".venn-intersection path").style("fill-opacity",A=>{var P;const O=$([...A.sets].sort());return(P=x.get(O))!=null&&P.fill?1:0}).style("fill",A=>{var P;const O=$([...A.sets].sort());return((P=x.get(O))==null?void 0:P.fill)??"transparent"}));const Y=v.append("g").attr("transform",`translate(0, ${g})`),B=l.select("svg").node();if(B&&"childNodes"in B)for(const A of[...B.childNodes])(z=Y.node())==null||z.appendChild(A);ne(v,T,M,(r==null?void 0:r.useMaxWidth)??!0)},"draw");function $(t){return t.join("|")}S($,"stableSetsKey");function Ut(t,n,s,e,i,r){var a;const o=(t==null?void 0:t.useDebugLayout)??!1,f=s.select("svg").append("g").attr("class","venn-text-nodes"),u=new Map;for(const y of e){const d=$(y.sets),m=u.get(d);m?m.push(y):u.set(d,[y])}for(const[y,d]of u.entries()){const m=n.get(y);if(!(m!=null&&m.text))continue;const x=m.text.x,M=m.text.y,T=Math.min(...m.circles.map(q=>q.radius)),_=Math.min(...m.circles.map(q=>q.radius-Math.hypot(x-q.x,M-q.y)));let w=Number.isFinite(_)?Math.max(0,_):0;w===0&&Number.isFinite(T)&&(w=T*.6);const g=f.append("g").attr("class","venn-text-area").attr("font-size",`${40*i}px`);o&&g.append("circle").attr("class","venn-text-debug-circle").attr("cx",x).attr("cy",M).attr("r",w).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);const b=Math.max(80*i,w*2*.95),v=Math.max(60*i,w*2*.95),h=(m.data.label&&m.data.label.length>0?Math.min(32*i,w*.25):0)+(d.length<=2?30*i:0),j=x-b/2,k=M-v/2+h,N=Math.max(1,Math.ceil(Math.sqrt(d.length))),Y=Math.max(1,Math.ceil(d.length/N)),B=b/N,U=v/Y;for(const[q,z]of d.entries()){const A=q%N,C=Math.floor(q/N),O=j+B*(A+.5),P=k+U*(C+.5);o&&g.append("rect").attr("class","venn-text-debug-cell").attr("x",j+B*A).attr("y",k+U*C).attr("width",B).attr("height",U).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);const V=B*.9,R=U*.9,E=g.append("foreignObject").attr("class","venn-text-node-fo").attr("width",V).attr("height",R).attr("x",O-V/2).attr("y",P-R/2).attr("overflow","visible"),F=(a=r.get(z.id))==null?void 0:a.color,D=E.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(z.label??z.id);F&&D.style("color",F)}}}S(Ut,"renderTextNodes");var qe={draw:Be},Ge={parser:we,db:je,renderer:qe,styles:Ve};export{Ge as diagram};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{s as gi,g as xi,q as Xt,p as di,a as fi,b as pi,_ as a,l as Nt,I as mi,e as yi,z as bi,G as St,i as Ai,E as Yt,F as wi,K as Ci,aH as Si,R as Wt}from"./index-CwxEeE2N.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-Cboi1Yqb.js";import{l as zt}from"./linear-D_o_z79L.js";import"./defaultLocale-DX6XiGOO.js";function Ri(e,t,i){e=+e,t=+t,i=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+i;for(var s=-1,n=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(n);++s<n;)o[s]=e+s*i;return o}function yt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,g,m=!1,p=0,k=0,v=.5;delete e.unknown;function C(){var b=t().length,E=n<s,D=E?n:s,P=E?s:n;o=(P-D)/Math.max(1,b-p+k*2),m&&(o=Math.floor(o)),D+=(P-D-o*(b-p))*v,g=o*(1-p),m&&(D=Math.round(D),g=Math.round(g));var I=Ri(b).map(function(y){return D+o*y});return i(E?I.reverse():I)}return e.domain=function(b){return arguments.length?(t(b),C()):t()},e.range=function(b){return arguments.length?([s,n]=b,s=+s,n=+n,C()):[s,n]},e.rangeRound=function(b){return[s,n]=b,s=+s,n=+n,m=!0,C()},e.bandwidth=function(){return g},e.step=function(){return o},e.round=function(b){return arguments.length?(m=!!b,C()):m},e.padding=function(b){return arguments.length?(p=Math.min(1,k=+b),C()):p},e.paddingInner=function(b){return arguments.length?(p=Math.min(1,b),C()):p},e.paddingOuter=function(b){return arguments.length?(k=+b,C()):k},e.align=function(b){return arguments.length?(v=Math.max(0,Math.min(1,b)),C()):v},e.copy=function(){return yt(t(),[s,n]).round(m).paddingInner(p).paddingOuter(k).align(v)},_i.apply(C(),arguments)}var bt=(function(){var e=a(function(F,h,u,x){for(u=u||{},x=F.length;x--;u[F[x]]=h);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],g=[1,7],m=[1,5,10,12,14,16,18,19,21,23,34,35,36],p=[1,25],k=[1,26],v=[1,28],C=[1,29],b=[1,30],E=[1,31],D=[1,32],P=[1,33],I=[1,34],y=[1,35],_=[1,36],c=[1,37],W=[1,43],z=[1,42],U=[1,47],X=[1,50],l=[1,10,12,14,16,18,19,21,23,34,35,36],L=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],S=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],R=[1,64],$={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:a(function(h,u,x,d,w,r,at){var f=r.length-1;switch(w){case 5:d.setOrientation(r[f]);break;case 9:d.setDiagramTitle(r[f].text.trim());break;case 12:d.setLineData({text:"",type:"text"},r[f]);break;case 13:d.setLineData(r[f-1],r[f]);break;case 14:d.setBarData({text:"",type:"text"},r[f]);break;case 15:d.setBarData(r[f-1],r[f]);break;case 16:this.$=r[f].trim(),d.setAccTitle(this.$);break;case 17:case 18:this.$=r[f].trim(),d.setAccDescription(this.$);break;case 19:this.$=r[f-1];break;case 20:this.$=[Number(r[f-2]),...r[f]];break;case 21:this.$=[Number(r[f])];break;case 22:d.setXAxisTitle(r[f]);break;case 23:d.setXAxisTitle(r[f-1]);break;case 24:d.setXAxisTitle({type:"text",text:""});break;case 25:d.setXAxisBand(r[f]);break;case 26:d.setXAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 27:this.$=r[f-1];break;case 28:this.$=[r[f-2],...r[f]];break;case 29:this.$=[r[f]];break;case 30:d.setYAxisTitle(r[f]);break;case 31:d.setYAxisTitle(r[f-1]);break;case 32:d.setYAxisTitle({type:"text",text:""});break;case 33:d.setYAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 37:this.$={text:r[f],type:"text"};break;case 38:this.$={text:r[f],type:"text"};break;case 39:this.$={text:r[f],type:"markdown"};break;case 40:this.$=r[f];break;case 41:this.$=r[f-1]+""+r[f];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,34:n,35:o,36:g}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,34:n,35:o,36:g}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],34:n,35:o,36:g}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(m,[2,34]),e(m,[2,35]),e(m,[2,36]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,34:n,35:o,36:g}),{1:[2,3]},e(m,[2,5]),e(t,[2,7],{4:22,34:n,35:o,36:g}),{11:23,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:39,13:38,24:W,27:z,29:40,30:41,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:45,15:44,27:U,33:46,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:49,17:48,24:X,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:52,17:51,24:X,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{20:[1,53]},{22:[1,54]},e(l,[2,18]),{1:[2,2]},e(l,[2,8]),e(l,[2,9]),e(L,[2,37],{40:55,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c}),e(L,[2,38]),e(L,[2,39]),e(S,[2,40]),e(S,[2,42]),e(S,[2,43]),e(S,[2,44]),e(S,[2,45]),e(S,[2,46]),e(S,[2,47]),e(S,[2,48]),e(S,[2,49]),e(S,[2,50]),e(S,[2,51]),e(l,[2,10]),e(l,[2,22],{30:41,29:56,24:W,27:z}),e(l,[2,24]),e(l,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},e(l,[2,11]),e(l,[2,30],{33:60,27:U}),e(l,[2,32]),{31:[1,61]},e(l,[2,12]),{17:62,24:X},{25:63,27:R},e(l,[2,14]),{17:65,24:X},e(l,[2,16]),e(l,[2,17]),e(S,[2,41]),e(l,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},e(l,[2,31]),{27:[1,69]},e(l,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},e(l,[2,15]),e(l,[2,26]),e(l,[2,27]),{11:59,32:72,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},e(l,[2,33]),e(l,[2,19]),{25:73,27:R},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:a(function(h,u){if(u.recoverable)this.trace(h);else{var x=new Error(h);throw x.hash=u,x}},"parseError"),parse:a(function(h){var u=this,x=[0],d=[],w=[null],r=[],at=this.table,f="",lt=0,It=0,hi=2,Mt=1,li=r.slice.call(arguments,1),T=Object.create(this.lexer),Y={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(Y.yy[dt]=this.yy[dt]);T.setInput(h,Y.yy),Y.yy.lexer=T,Y.yy.parser=this,typeof T.yylloc>"u"&&(T.yylloc={});var ft=T.yylloc;r.push(ft);var ci=T.options&&T.options.ranges;typeof Y.yy.parseError=="function"?this.parseError=Y.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ui(V){x.length=x.length-2*V,w.length=w.length-V,r.length=r.length-V}a(ui,"popStack");function Vt(){var V;return V=d.pop()||T.lex()||Mt,typeof V!="number"&&(V instanceof Array&&(d=V,V=d.pop()),V=u.symbols_[V]||V),V}a(Vt,"lex");for(var M,H,B,pt,q={},ct,O,Bt,ut;;){if(H=x[x.length-1],this.defaultActions[H]?B=this.defaultActions[H]:((M===null||typeof M>"u")&&(M=Vt()),B=at[H]&&at[H][M]),typeof B>"u"||!B.length||!B[0]){var mt="";ut=[];for(ct in at[H])this.terminals_[ct]&&ct>hi&&ut.push("'"+this.terminals_[ct]+"'");T.showPosition?mt="Parse error on line "+(lt+1)+`:
|
|
2
|
+
`+T.showPosition()+`
|
|
3
|
+
Expecting `+ut.join(", ")+", got '"+(this.terminals_[M]||M)+"'":mt="Parse error on line "+(lt+1)+": Unexpected "+(M==Mt?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(mt,{text:T.match,token:this.terminals_[M]||M,line:T.yylineno,loc:ft,expected:ut})}if(B[0]instanceof Array&&B.length>1)throw new Error("Parse Error: multiple actions possible at state: "+H+", token: "+M);switch(B[0]){case 1:x.push(M),w.push(T.yytext),r.push(T.yylloc),x.push(B[1]),M=null,It=T.yyleng,f=T.yytext,lt=T.yylineno,ft=T.yylloc;break;case 2:if(O=this.productions_[B[1]][1],q.$=w[w.length-O],q._$={first_line:r[r.length-(O||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(O||1)].first_column,last_column:r[r.length-1].last_column},ci&&(q._$.range=[r[r.length-(O||1)].range[0],r[r.length-1].range[1]]),pt=this.performAction.apply(q,[f,It,lt,Y.yy,B[1],w,r].concat(li)),typeof pt<"u")return pt;O&&(x=x.slice(0,-1*O*2),w=w.slice(0,-1*O),r=r.slice(0,-1*O)),x.push(this.productions_[B[1]][0]),w.push(q.$),r.push(q._$),Bt=at[x[x.length-2]][x[x.length-1]],x.push(Bt);break;case 3:return!0}}return!0},"parse")},Et=(function(){var F={EOF:1,parseError:a(function(u,x){if(this.yy.parser)this.yy.parser.parseError(u,x);else throw new Error(u)},"parseError"),setInput:a(function(h,u){return this.yy=u||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);return u?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:a(function(h){var u=h.length,x=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),x.length-1&&(this.yylineno-=x.length-1);var w=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:x?(x.length===d.length?this.yylloc.first_column:0)+d[d.length-x.length].length-x[0].length:this.yylloc.first_column-u},this.options.ranges&&(this.yylloc.range=[w[0],w[0]+this.yyleng-u]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(h){this.unput(this.match.slice(h))},"less"),pastInput:a(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var h=this.pastInput(),u=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
|
|
5
|
+
`+u+"^"},"showPosition"),test_match:a(function(h,u){var x,d,w;if(this.options.backtrack_lexer&&(w={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(w.yylloc.range=this.yylloc.range.slice(0))),d=h[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+h[0].length},this.yytext+=h[0],this.match+=h[0],this.matches=h,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(h[0].length),this.matched+=h[0],x=this.performAction.call(this,this.yy,this,u,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),x)return x;if(this._backtrack){for(var r in w)this[r]=w[r];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var h,u,x,d;this._more||(this.yytext="",this.match="");for(var w=this._currentRules(),r=0;r<w.length;r++)if(x=this._input.match(this.rules[w[r]]),x&&(!u||x[0].length>u[0].length)){if(u=x,d=r,this.options.backtrack_lexer){if(h=this.test_match(x,w[r]),h!==!1)return h;if(this._backtrack){u=!1;continue}else return!1}else if(!this.options.flex)break}return u?(h=this.test_match(u,w[d]),h!==!1?h:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:a(function(){var u=this.next();return u||this.lex()},"lex"),begin:a(function(u){this.conditionStack.push(u)},"begin"),popState:a(function(){var u=this.conditionStack.length-1;return u>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(u){return u=this.conditionStack.length-1-Math.abs(u||0),u>=0?this.conditionStack[u]:"INITIAL"},"topState"),pushState:a(function(u){this.begin(u)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:a(function(u,x,d,w){switch(d){case 0:break;case 1:break;case 2:return this.popState(),34;case 3:return this.popState(),34;case 4:return 34;case 5:break;case 6:return 10;case 7:return this.pushState("acc_title"),19;case 8:return this.popState(),"acc_title_value";case 9:return this.pushState("acc_descr"),21;case 10:return this.popState(),"acc_descr_value";case 11:this.pushState("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:return 5;case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";case 18:return this.pushState("axis_data"),"Y_AXIS";case 19:return this.pushState("axis_band_data"),24;case 20:return 31;case 21:return this.pushState("data"),16;case 22:return this.pushState("data"),18;case 23:return this.pushState("data_inner"),24;case 24:return 27;case 25:return this.popState(),26;case 26:this.popState();break;case 27:this.pushState("string");break;case 28:this.popState();break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 43;case 33:return"COLON";case 34:return 44;case 35:return 28;case 36:return 45;case 37:return 46;case 38:return 48;case 39:return 50;case 40:return 47;case 41:return 41;case 42:return 49;case 43:return 42;case 44:break;case 45:return 35;case 46:return 36}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return F})();$.lexer=Et;function N(){this.yy={}}return a(N,"Parser"),N.prototype=$,$.Parser=N,new N})();bt.parser=bt;var Ti=bt;function At(e){return e.type==="bar"}a(At,"isBarPlot");function _t(e){return e.type==="band"}a(_t,"isBandAxisData");function G(e){return e.type==="linear"}a(G,"isLinearAxisData");var j,Ht=(j=class{constructor(t){this.parentGroup=t}getMaxDimension(t,i){if(!this.parentGroup)return{width:t.reduce((o,g)=>Math.max(g.length,o),0)*i,height:i};const s={width:0,height:0},n=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",i);for(const o of t){const g=Si(n,1,o),m=g?g.width:o.length*i,p=g?g.height:i;s.width=Math.max(s.width,m),s.height=Math.max(s.height,p)}return n.remove(),s}},a(j,"TextDimensionCalculatorWithFont"),j),Ft=.7,Ot=.2,Q,Ut=(Q=class{constructor(t,i,s,n){this.axisConfig=t,this.title=i,this.textDimensionCalculator=s,this.axisThemeConfig=n,this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.showTitle=!1,this.showLabel=!1,this.showTick=!1,this.showAxisLine=!1,this.outerPadding=0,this.titleTextHeight=0,this.labelTextHeight=0,this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left"}setRange(t){this.range=t,this.axisPosition==="left"||this.axisPosition==="right"?this.boundingRect.height=t[1]-t[0]:this.boundingRect.width=t[1]-t[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(t){this.axisPosition=t,this.setRange(this.range)}getTickDistance(){const t=this.getRange();return Math.abs(t[0]-t[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(t=>t.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){Ft*this.getTickDistance()>this.outerPadding*2&&(this.outerPadding=Math.floor(Ft*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(t){let i=t.height;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const s=this.getLabelDimension(),n=Ot*t.width;this.outerPadding=Math.min(s.width/2,n);const o=s.height+this.axisConfig.labelPadding*2;this.labelTextHeight=s.height,o<=i&&(i-=o,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const s=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=s.height+this.axisConfig.titlePadding*2;this.titleTextHeight=s.height,n<=i&&(i-=n,this.showTitle=!0)}this.boundingRect.width=t.width,this.boundingRect.height=t.height-i}calculateSpaceIfDrawnVertical(t){let i=t.width;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const s=this.getLabelDimension(),n=Ot*t.height;this.outerPadding=Math.min(s.height/2,n);const o=s.width+this.axisConfig.labelPadding*2;o<=i&&(i-=o,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const s=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=s.height+this.axisConfig.titlePadding*2;this.titleTextHeight=s.height,n<=i&&(i-=n,this.showTitle=!0)}this.boundingRect.width=t.width-i,this.boundingRect.height=t.height}calculateSpace(t){return this.axisPosition==="left"||this.axisPosition==="right"?this.calculateSpaceIfDrawnVertical(t):this.calculateSpaceIfDrawnHorizontally(t),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}getDrawableElementsForLeftAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${i},${this.boundingRect.y} L ${i},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(i),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){const i=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${i},${this.getScaleValue(s)} L ${i-this.axisConfig.tickLength},${this.getScaleValue(s)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForBottomAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.y+this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const i=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${this.getScaleValue(s)},${i} L ${this.getScaleValue(s)},${i+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForTopAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+this.axisConfig.titlePadding*2:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const i=this.boundingRect.y;t.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${this.getScaleValue(s)},${i+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(s)},${i+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElements(){if(this.axisPosition==="left")return this.getDrawableElementsForLeftAxis();if(this.axisPosition==="right")throw Error("Drawing of right axis is not implemented");return this.axisPosition==="bottom"?this.getDrawableElementsForBottomAxis():this.axisPosition==="top"?this.getDrawableElementsForTopAxis():[]}},a(Q,"BaseAxis"),Q),K,Di=(K=class extends Ut{constructor(t,i,s,n,o){super(t,n,o,i),this.categories=s,this.scale=yt().domain(this.categories).range(this.getRange())}setRange(t){super.setRange(t)}recalculateScale(){this.scale=yt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),Nt.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(t){return this.scale(t)??this.getRange()[0]}},a(K,"BandAxis"),K),Z,vi=(Z=class extends Ut{constructor(t,i,s,n,o){super(t,n,o,i),this.domain=s,this.scale=zt().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){const t=[...this.domain];this.axisPosition==="left"&&t.reverse(),this.scale=zt().domain(t).range(this.getRange())}getScaleValue(t){return this.scale(t)}},a(Z,"LinearAxis"),Z);function wt(e,t,i,s){const n=new Ht(s);return _t(e)?new Di(t,i,e.categories,e.title,n):new vi(t,i,[e.min,e.max],e.title,n)}a(wt,"getAxis");var J,Pi=(J=class{constructor(t,i,s,n){this.textDimensionCalculator=t,this.chartConfig=i,this.chartData=s,this.chartThemeConfig=n,this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){const i=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),s=Math.max(i.width,t.width),n=i.height+2*this.chartConfig.titlePadding;return i.width<=s&&i.height<=n&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=s,this.boundingRect.height=n,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){const t=[];return this.showChartTitle&&t.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),t}},a(J,"ChartTitle"),J);function $t(e,t,i,s){const n=new Ht(s);return new Pi(n,e,t,i)}a($t,"getChartTitleComponent");var tt,Li=(tt=class{constructor(t,i,s,n,o){this.plotData=t,this.xAxis=i,this.yAxis=s,this.orientation=n,this.plotIndex=o}getDrawableElement(){const t=this.plotData.data.map(s=>[this.xAxis.getScaleValue(s[0]),this.yAxis.getScaleValue(s[1])]);let i;return this.orientation==="horizontal"?i=Wt().y(s=>s[0]).x(s=>s[1])(t):i=Wt().x(s=>s[0]).y(s=>s[1])(t),i?[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:i,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}]:[]}},a(tt,"LinePlot"),tt),it,Ei=(it=class{constructor(t,i,s,n,o,g){this.barData=t,this.boundingRect=i,this.xAxis=s,this.yAxis=n,this.orientation=o,this.plotIndex=g}getDrawableElement(){const t=this.barData.data.map(o=>[this.xAxis.getScaleValue(o[0]),this.yAxis.getScaleValue(o[1])]),s=Math.min(this.xAxis.getAxisOuterPadding()*2,this.xAxis.getTickDistance())*(1-.05),n=s/2;return this.orientation==="horizontal"?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(o=>({x:this.boundingRect.x,y:o[0]-n,height:s,width:o[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(o=>({x:o[0]-n,y:o[1],width:s,height:this.boundingRect.y+this.boundingRect.height-o[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}},a(it,"BarPlot"),it),et,Ii=(et=class{constructor(t,i,s){this.chartConfig=t,this.chartData=i,this.chartThemeConfig=s,this.boundingRect={x:0,y:0,width:0,height:0}}setAxes(t,i){this.xAxis=t,this.yAxis=i}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){return this.boundingRect.width=t.width,this.boundingRect.height=t.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!(this.xAxis&&this.yAxis))throw Error("Axes must be passed to render Plots");const t=[];for(const[i,s]of this.chartData.plots.entries())switch(s.type){case"line":{const n=new Li(s,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...n.getDrawableElement())}break;case"bar":{const n=new Ei(s,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...n.getDrawableElement())}break}return t}},a(et,"BasePlot"),et);function qt(e,t,i){return new Ii(e,t,i)}a(qt,"getPlotComponent");var st,Mi=(st=class{constructor(t,i,s,n){this.chartConfig=t,this.chartData=i,this.componentStore={title:$t(t,i,s,n),plot:qt(t,i,s),xAxis:wt(i.xAxis,t.xAxis,{titleColor:s.xAxisTitleColor,labelColor:s.xAxisLabelColor,tickColor:s.xAxisTickColor,axisLineColor:s.xAxisLineColor},n),yAxis:wt(i.yAxis,t.yAxis,{titleColor:s.yAxisTitleColor,labelColor:s.yAxisLabelColor,tickColor:s.yAxisTickColor,axisLineColor:s.yAxisLineColor},n)}}calculateVerticalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,s=0,n=0,o=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),g=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),m=this.componentStore.plot.calculateSpace({width:o,height:g});t-=m.width,i-=m.height,m=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),n=m.height,i-=m.height,this.componentStore.xAxis.setAxisPosition("bottom"),m=this.componentStore.xAxis.calculateSpace({width:t,height:i}),i-=m.height,this.componentStore.yAxis.setAxisPosition("left"),m=this.componentStore.yAxis.calculateSpace({width:t,height:i}),s=m.width,t-=m.width,t>0&&(o+=t,t=0),i>0&&(g+=i,i=0),this.componentStore.plot.calculateSpace({width:o,height:g}),this.componentStore.plot.setBoundingBoxXY({x:s,y:n}),this.componentStore.xAxis.setRange([s,s+o]),this.componentStore.xAxis.setBoundingBoxXY({x:s,y:n+g}),this.componentStore.yAxis.setRange([n,n+g]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:n}),this.chartData.plots.some(p=>At(p))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,s=0,n=0,o=0,g=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),m=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),p=this.componentStore.plot.calculateSpace({width:g,height:m});t-=p.width,i-=p.height,p=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),s=p.height,i-=p.height,this.componentStore.xAxis.setAxisPosition("left"),p=this.componentStore.xAxis.calculateSpace({width:t,height:i}),t-=p.width,n=p.width,this.componentStore.yAxis.setAxisPosition("top"),p=this.componentStore.yAxis.calculateSpace({width:t,height:i}),i-=p.height,o=s+p.height,t>0&&(g+=t,t=0),i>0&&(m+=i,i=0),this.componentStore.plot.calculateSpace({width:g,height:m}),this.componentStore.plot.setBoundingBoxXY({x:n,y:o}),this.componentStore.yAxis.setRange([n,n+g]),this.componentStore.yAxis.setBoundingBoxXY({x:n,y:s}),this.componentStore.xAxis.setRange([o,o+m]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:o}),this.chartData.plots.some(k=>At(k))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){this.chartConfig.chartOrientation==="horizontal"?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();const t=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(const i of Object.values(this.componentStore))t.push(...i.getDrawableElements());return t}},a(st,"Orchestrator"),st),nt,Vi=(nt=class{static build(t,i,s,n){return new Mi(t,i,s,n).getDrawableElement()}},a(nt,"XYChartBuilder"),nt),rt=0,Gt,ot=Tt(),ht=Rt(),A=Dt(),Ct=ht.plotColorPalette.split(",").map(e=>e.trim()),gt=!1,kt=!1;function Rt(){const e=Ci(),t=St();return Yt(e.xyChart,t.themeVariables.xyChart)}a(Rt,"getChartDefaultThemeConfig");function Tt(){const e=St();return Yt(wi.xyChart,e.xyChart)}a(Tt,"getChartDefaultConfig");function Dt(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}a(Dt,"getChartDefaultData");function xt(e){const t=St();return Ai(e.trim(),t)}a(xt,"textSanitizer");function jt(e){Gt=e}a(jt,"setTmpSVGG");function Qt(e){e==="horizontal"?ot.chartOrientation="horizontal":ot.chartOrientation="vertical"}a(Qt,"setOrientation");function Kt(e){A.xAxis.title=xt(e.text)}a(Kt,"setXAxisTitle");function vt(e,t){A.xAxis={type:"linear",title:A.xAxis.title,min:e,max:t},gt=!0}a(vt,"setXAxisRangeData");function Zt(e){A.xAxis={type:"band",title:A.xAxis.title,categories:e.map(t=>xt(t.text))},gt=!0}a(Zt,"setXAxisBand");function Jt(e){A.yAxis.title=xt(e.text)}a(Jt,"setYAxisTitle");function ti(e,t){A.yAxis={type:"linear",title:A.yAxis.title,min:e,max:t},kt=!0}a(ti,"setYAxisRangeData");function ii(e){const t=Math.min(...e),i=Math.max(...e),s=G(A.yAxis)?A.yAxis.min:1/0,n=G(A.yAxis)?A.yAxis.max:-1/0;A.yAxis={type:"linear",title:A.yAxis.title,min:Math.min(s,t),max:Math.max(n,i)}}a(ii,"setYAxisRangeFromPlotData");function Pt(e){let t=[];if(e.length===0)return t;if(!gt){const i=G(A.xAxis)?A.xAxis.min:1/0,s=G(A.xAxis)?A.xAxis.max:-1/0;vt(Math.min(i,1),Math.max(s,e.length))}if(kt||ii(e),_t(A.xAxis)&&(t=A.xAxis.categories.map((i,s)=>[i,e[s]])),G(A.xAxis)){const i=A.xAxis.min,s=A.xAxis.max,n=(s-i)/(e.length-1),o=[];for(let g=i;g<=s;g+=n)o.push(`${g}`);t=o.map((g,m)=>[g,e[m]])}return t}a(Pt,"transformDataWithoutCategory");function Lt(e){return Ct[e===0?0:e%Ct.length]}a(Lt,"getPlotColorFromPalette");function ei(e,t){const i=Pt(t);A.plots.push({type:"line",strokeFill:Lt(rt),strokeWidth:2,data:i}),rt++}a(ei,"setLineData");function si(e,t){const i=Pt(t);A.plots.push({type:"bar",fill:Lt(rt),data:i}),rt++}a(si,"setBarData");function ni(){if(A.plots.length===0)throw Error("No Plot to render, please provide a plot with some data");return A.title=Xt(),Vi.build(ot,A,ht,Gt)}a(ni,"getDrawableElem");function ai(){return ht}a(ai,"getChartThemeConfig");function ri(){return ot}a(ri,"getChartConfig");function oi(){return A}a(oi,"getXYChartData");var Bi=a(function(){bi(),rt=0,ot=Tt(),A=Dt(),ht=Rt(),Ct=ht.plotColorPalette.split(",").map(e=>e.trim()),gt=!1,kt=!1},"clear"),Wi={getDrawableElem:ni,clear:Bi,setAccTitle:pi,getAccTitle:fi,setDiagramTitle:di,getDiagramTitle:Xt,getAccDescription:xi,setAccDescription:gi,setOrientation:Qt,setXAxisTitle:Kt,setXAxisRangeData:vt,setXAxisBand:Zt,setYAxisTitle:Jt,setYAxisRangeData:ti,setLineData:ei,setBarData:si,setTmpSVGG:jt,getChartThemeConfig:ai,getChartConfig:ri,getXYChartData:oi},zi=a((e,t,i,s)=>{const n=s.db,o=n.getChartThemeConfig(),g=n.getChartConfig(),m=n.getXYChartData().plots[0].data.map(y=>y[1]);function p(y){return y==="top"?"text-before-edge":"middle"}a(p,"getDominantBaseLine");function k(y){return y==="left"?"start":y==="right"?"end":"middle"}a(k,"getTextAnchor");function v(y){return`translate(${y.x}, ${y.y}) rotate(${y.rotation||0})`}a(v,"getTextTransformation"),Nt.debug(`Rendering xychart chart
|
|
7
|
+
`+e);const C=mi(t),b=C.append("g").attr("class","main"),E=b.append("rect").attr("width",g.width).attr("height",g.height).attr("class","background");yi(C,g.height,g.width,!0),C.attr("viewBox",`0 0 ${g.width} ${g.height}`),E.attr("fill",o.backgroundColor),n.setTmpSVGG(C.append("g").attr("class","mermaid-tmp-group"));const D=n.getDrawableElem(),P={};function I(y){let _=b,c="";for(const[W]of y.entries()){let z=b;W>0&&P[c]&&(z=P[c]),c+=y[W],_=P[c],_||(_=P[c]=z.append("g").attr("class",y[W]))}return _}a(I,"getGroup");for(const y of D){if(y.data.length===0)continue;const _=I(y.groupTexts);switch(y.type){case"rect":if(_.selectAll("rect").data(y.data).enter().append("rect").attr("x",c=>c.x).attr("y",c=>c.y).attr("width",c=>c.width).attr("height",c=>c.height).attr("fill",c=>c.fill).attr("stroke",c=>c.strokeFill).attr("stroke-width",c=>c.strokeWidth),g.showDataLabel)if(g.chartOrientation==="horizontal"){let c=function(l,L){const{data:S,label:R}=l;return L*R.length*W<=S.width-10};a(c,"fitsHorizontally");const W=.7,z=y.data.map((l,L)=>({data:l,label:m[L].toString()})).filter(l=>l.data.width>0&&l.data.height>0),U=z.map(l=>{const{data:L}=l;let S=L.height*.7;for(;!c(l,S)&&S>0;)S-=1;return S}),X=Math.floor(Math.min(...U));_.selectAll("text").data(z).enter().append("text").attr("x",l=>l.data.x+l.data.width-10).attr("y",l=>l.data.y+l.data.height/2).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill","black").attr("font-size",`${X}px`).text(l=>l.label)}else{let c=function(l,L,S){const{data:R,label:$}=l,N=L*$.length*.7,F=R.x+R.width/2,h=F-N/2,u=F+N/2,x=h>=R.x&&u<=R.x+R.width,d=R.y+S+L<=R.y+R.height;return x&&d};a(c,"fitsInBar");const W=10,z=y.data.map((l,L)=>({data:l,label:m[L].toString()})).filter(l=>l.data.width>0&&l.data.height>0),U=z.map(l=>{const{data:L,label:S}=l;let R=L.width/(S.length*.7);for(;!c(l,R,W)&&R>0;)R-=1;return R}),X=Math.floor(Math.min(...U));_.selectAll("text").data(z).enter().append("text").attr("x",l=>l.data.x+l.data.width/2).attr("y",l=>l.data.y+W).attr("text-anchor","middle").attr("dominant-baseline","hanging").attr("fill","black").attr("font-size",`${X}px`).text(l=>l.label)}break;case"text":_.selectAll("text").data(y.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",c=>c.fill).attr("font-size",c=>c.fontSize).attr("dominant-baseline",c=>p(c.verticalPos)).attr("text-anchor",c=>k(c.horizontalPos)).attr("transform",c=>v(c)).text(c=>c.text);break;case"path":_.selectAll("path").data(y.data).enter().append("path").attr("d",c=>c.path).attr("fill",c=>c.fill?c.fill:"none").attr("stroke",c=>c.strokeFill).attr("stroke-width",c=>c.strokeWidth);break}}},"draw"),Fi={draw:zi},Ui={parser:Ti,db:Wi,renderer:Fi};export{Ui as diagram};
|
package/public/index.html
CHANGED
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
const t = localStorage.getItem('termbeam-theme');
|
|
28
28
|
if (t) document.documentElement.setAttribute('data-theme', t);
|
|
29
29
|
</script>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
31
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-CwxEeE2N.js"></script>
|
|
31
|
+
<link rel="stylesheet" crossorigin href="/assets/index-6PEqObPX.css">
|
|
32
32
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
33
33
|
<body>
|
|
34
34
|
<div id="root"></div>
|
package/public/sw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
try{self["workbox:core:7.3.0"]&&_()}catch{}const G=(n,...e)=>{let t=n;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},Q=G;class l extends Error{constructor(e,t){const s=Q(e,t);super(s),this.name=e,this.details=t}}const d={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration<"u"?registration.scope:""},E=n=>[d.prefix,n,d.suffix].filter(e=>e&&e.length>0).join("-"),z=n=>{for(const e of Object.keys(d))n(e)},b={updateDetails:n=>{z(e=>{typeof n[e]=="string"&&(d[e]=n[e])})},getGoogleAnalyticsName:n=>n||E(d.googleAnalytics),getPrecacheName:n=>n||E(d.precache),getPrefix:()=>d.prefix,getRuntimeName:n=>n||E(d.runtime),getSuffix:()=>d.suffix};function N(n,e){const t=e();return n.waitUntil(t),t}try{self["workbox:precaching:7.3.0"]&&_()}catch{}const J="__WB_REVISION__";function X(n){if(!n)throw new l("add-to-cache-list-unexpected-type",{entry:n});if(typeof n=="string"){const r=new URL(n,location.href);return{cacheKey:r.href,url:r.href}}const{revision:e,url:t}=n;if(!t)throw new l("add-to-cache-list-unexpected-type",{entry:n});if(!e){const r=new URL(t,location.href);return{cacheKey:r.href,url:r.href}}const s=new URL(t,location.href),a=new URL(t,location.href);return s.searchParams.set(J,e),{cacheKey:s.href,url:a.href}}class Y{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if(e.type==="install"&&t&&t.originalRequest&&t.originalRequest instanceof Request){const a=t.originalRequest.url;s?this.notUpdatedURLs.push(a):this.updatedURLs.push(a)}return s}}}class Z{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:t,params:s})=>{const a=(s==null?void 0:s.cacheKey)||this._precacheController.getCacheKeyForURL(t.url);return a?new Request(a,{headers:t.headers}):t},this._precacheController=e}}let m;function ee(){if(m===void 0){const n=new Response("");if("body"in n)try{new Response(n.body),m=!0}catch{m=!1}m=!1}return m}async function te(n,e){let t=null;if(n.url&&(t=new URL(n.url).origin),t!==self.location.origin)throw new l("cross-origin-copy-response",{origin:t});const s=n.clone(),r={headers:new Headers(s.headers),status:s.status,statusText:s.statusText},i=ee()?s.body:await s.blob();return new Response(i,r)}const se=n=>new URL(String(n),location.href).href.replace(new RegExp(`^${location.origin}`),"");function M(n,e){const t=new URL(n);for(const s of e)t.searchParams.delete(s);return t.href}async function ne(n,e,t,s){const a=M(e.url,t);if(e.url===a)return n.match(e,s);const r=Object.assign(Object.assign({},s),{ignoreSearch:!0}),i=await n.keys(e,r);for(const c of i){const o=M(c.url,t);if(a===o)return n.match(c,s)}}class ae{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}const B=new Set;async function re(){for(const n of B)await n()}function ie(n){return new Promise(e=>setTimeout(e,n))}try{self["workbox:strategies:7.3.0"]&&_()}catch{}function C(n){return typeof n=="string"?new Request(n):n}class ce{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new ae,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:t}=this;let s=C(e);if(s.mode==="navigate"&&t instanceof FetchEvent&&t.preloadResponse){const i=await t.preloadResponse;if(i)return i}const a=this.hasCallback("fetchDidFail")?s.clone():null;try{for(const i of this.iterateCallbacks("requestWillFetch"))s=await i({request:s.clone(),event:t})}catch(i){if(i instanceof Error)throw new l("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const r=s.clone();try{let i;i=await fetch(s,s.mode==="navigate"?void 0:this._strategy.fetchOptions);for(const c of this.iterateCallbacks("fetchDidSucceed"))i=await c({event:t,request:r,response:i});return i}catch(i){throw a&&await this.runCallbacks("fetchDidFail",{error:i,event:t,originalRequest:a.clone(),request:r.clone()}),i}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=C(e);let s;const{cacheName:a,matchOptions:r}=this._strategy,i=await this.getCacheKey(t,"read"),c=Object.assign(Object.assign({},r),{cacheName:a});s=await caches.match(i,c);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:a,matchOptions:r,cachedResponse:s,request:i,event:this.event})||void 0;return s}async cachePut(e,t){const s=C(e);await ie(0);const a=await this.getCacheKey(s,"write");if(!t)throw new l("cache-put-with-no-response",{url:se(a.url)});const r=await this._ensureResponseSafeToCache(t);if(!r)return!1;const{cacheName:i,matchOptions:c}=this._strategy,o=await self.caches.open(i),h=this.hasCallback("cacheDidUpdate"),g=h?await ne(o,a.clone(),["__WB_REVISION__"],c):null;try{await o.put(a,h?r.clone():r)}catch(u){if(u instanceof Error)throw u.name==="QuotaExceededError"&&await re(),u}for(const u of this.iterateCallbacks("cacheDidUpdate"))await u({cacheName:i,oldResponse:g,newResponse:r.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let a=e;for(const r of this.iterateCallbacks("cacheKeyWillBeUsed"))a=C(await r({mode:t,request:a,event:this.event,params:this.params}));this._cacheKeys[s]=a}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if(typeof t[e]=="function"){const s=this._pluginStateMap.get(t);yield r=>{const i=Object.assign(Object.assign({},r),{state:s});return t[e](i)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){const e=this._extendLifetimePromises.splice(0),s=(await Promise.allSettled(e)).find(a=>a.status==="rejected");if(s)throw s.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const a of this.iterateCallbacks("cacheWillUpdate"))if(t=await a({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&t.status!==200&&(t=void 0),t}}class W{constructor(e={}){this.cacheName=b.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s=typeof e.request=="string"?new Request(e.request):e.request,a="params"in e?e.params:void 0,r=new ce(this,{event:t,request:s,params:a}),i=this._getResponse(r,s,t),c=this._awaitComplete(i,r,s,t);return[i,c]}async _getResponse(e,t,s){await e.runCallbacks("handlerWillStart",{event:s,request:t});let a;try{if(a=await this._handle(t,e),!a||a.type==="error")throw new l("no-response",{url:t.url})}catch(r){if(r instanceof Error){for(const i of e.iterateCallbacks("handlerDidError"))if(a=await i({error:r,event:s,request:t}),a)break}if(!a)throw r}for(const r of e.iterateCallbacks("handlerWillRespond"))a=await r({event:s,request:t,response:a});return a}async _awaitComplete(e,t,s,a){let r,i;try{r=await e}catch{}try{await t.runCallbacks("handlerDidRespond",{event:a,request:s,response:r}),await t.doneWaiting()}catch(c){c instanceof Error&&(i=c)}if(await t.runCallbacks("handlerDidComplete",{event:a,request:s,response:r,error:i}),t.destroy(),i)throw i}}class p extends W{constructor(e={}){e.cacheName=b.getPrecacheName(e.cacheName),super(e),this._fallbackToNetwork=e.fallbackToNetwork!==!1,this.plugins.push(p.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&t.event.type==="install"?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,t){let s;const a=t.params||{};if(this._fallbackToNetwork){const r=a.integrity,i=e.integrity,c=!i||i===r;s=await t.fetch(new Request(e,{integrity:e.mode!=="no-cors"?i||r:void 0})),r&&c&&e.mode!=="no-cors"&&(this._useDefaultCacheabilityPluginIfNeeded(),await t.cachePut(e,s.clone()))}else throw new l("missing-precache-entry",{cacheName:this.cacheName,url:e.url});return s}async _handleInstall(e,t){this._useDefaultCacheabilityPluginIfNeeded();const s=await t.fetch(e);if(!await t.cachePut(e,s.clone()))throw new l("bad-precaching-response",{url:e.url,status:s.status});return s}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,a]of this.plugins.entries())a!==p.copyRedirectedCacheableResponsesPlugin&&(a===p.defaultPrecacheCacheabilityPlugin&&(e=s),a.cacheWillUpdate&&t++);t===0?this.plugins.push(p.defaultPrecacheCacheabilityPlugin):t>1&&e!==null&&this.plugins.splice(e,1)}}p.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:n}){return!n||n.status>=400?null:n}};p.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:n}){return n.redirected?await te(n):n}};class oe{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new p({cacheName:b.getPrecacheName(e),plugins:[...t,new Z({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const t=[];for(const s of e){typeof s=="string"?t.push(s):s&&s.revision===void 0&&t.push(s.url);const{cacheKey:a,url:r}=X(s),i=typeof s!="string"&&s.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==a)throw new l("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:a});if(typeof s!="string"&&s.integrity){if(this._cacheKeysToIntegrities.has(a)&&this._cacheKeysToIntegrities.get(a)!==s.integrity)throw new l("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(a,s.integrity)}if(this._urlsToCacheKeys.set(r,a),this._urlsToCacheModes.set(r,i),t.length>0){const c=`Workbox is precaching URLs without revision info: ${t.join(", ")}
|
|
2
|
-
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return N(e,async()=>{const t=new Y;this.strategy.plugins.push(t);for(const[r,i]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(i),o=this._urlsToCacheModes.get(r),h=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:i},request:h,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return N(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),r=[];for(const i of s)a.has(i.url)||(await t.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new l("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let D;const j=()=>(D||(D=new oe),D);try{self["workbox:routing:7.3.0"]&&_()}catch{}const F="GET",x=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=F){this.handler=x(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=x(e)}}class he extends R{constructor(e,t,s){const a=({url:r})=>{const i=e.exec(r.href);if(i&&!(r.origin!==location.origin&&i.index!==0))return i.slice(1)};super(a,t,s)}}class le{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const r=new Request(...a);return this.handleRequest({request:r,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=i&&i.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let h;try{h=c.handle({url:s,request:e,event:t,params:r})}catch(u){h=Promise.reject(u)}const g=i&&i.catchHandler;return h instanceof Promise&&(this._catchHandler||g)&&(h=h.catch(async u=>{if(g)try{return await g.handle({url:s,request:e,event:t,params:r})}catch(I){I instanceof Error&&(u=I)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),h}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const r=this._routes.get(s.method)||[];for(const i of r){let c;const o=i.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:i,params:c}}return{}}setDefaultHandler(e,t=F){this._defaultHandlerMap.set(t,x(e))}setCatchHandler(e){this._catchHandler=x(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new l("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new l("unregister-route-route-not-registered")}}let w;const ue=()=>(w||(w=new le,w.addFetchListener(),w.addCacheListener()),w);function q(n,e,t){let s;if(typeof n=="string"){const r=new URL(n,location.href),i=({url:c})=>c.href===r.href;s=new R(i,e,t)}else if(n instanceof RegExp)s=new he(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new l("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return ue().registerRoute(s),s}function de(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*fe(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const r=new URL(n,location.href);r.hash="",yield r.href;const i=de(r,e);if(yield i.href,t&&i.pathname.endsWith("/")){const c=new URL(i.href);c.pathname+=t,yield c.href}if(s){const c=new URL(i.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:r});for(const o of c)yield o.href}}class pe extends R{constructor(e,t){const s=({request:a})=>{const r=e.getURLsToCacheKeys();for(const i of fe(a.url,t)){const c=r.get(i);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ge(n){const e=j(),t=new pe(e,n);q(t)}const me="-precache-",we=async(n,e=me)=>{const s=(await self.caches.keys()).filter(a=>a.includes(e)&&a.includes(self.registration.scope)&&a!==n);return await Promise.all(s.map(a=>self.caches.delete(a))),s};function ye(){self.addEventListener("activate",(n=>{const e=b.getPrecacheName();n.waitUntil(we(e).then(t=>{}))}))}function _e(n){j().precache(n)}function Re(n,e){_e(n),ge(e)}class be extends W{async _handle(e,t){let s=await t.cacheMatch(e),a;if(!s)try{s=await t.fetchAndCachePut(e)}catch(r){r instanceof Error&&(a=r)}if(!s)throw new l("no-response",{url:e.url,error:a});return s}}function H(n){n.then(()=>{})}const Ce=(n,e)=>e.some(t=>n instanceof t);let K,A;function xe(){return K||(K=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ee(){return A||(A=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const V=new WeakMap,k=new WeakMap,$=new WeakMap,L=new WeakMap,v=new WeakMap;function De(n){const e=new Promise((t,s)=>{const a=()=>{n.removeEventListener("success",r),n.removeEventListener("error",i)},r=()=>{t(f(n.result)),a()},i=()=>{s(n.error),a()};n.addEventListener("success",r),n.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&V.set(t,n)}).catch(()=>{}),v.set(e,n),e}function Le(n){if(k.has(n))return;const e=new Promise((t,s)=>{const a=()=>{n.removeEventListener("complete",r),n.removeEventListener("error",i),n.removeEventListener("abort",i)},r=()=>{t(),a()},i=()=>{s(n.error||new DOMException("AbortError","AbortError")),a()};n.addEventListener("complete",r),n.addEventListener("error",i),n.addEventListener("abort",i)});k.set(n,e)}let P={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return k.get(n);if(e==="objectStoreNames")return n.objectStoreNames||$.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return f(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Ue(n){P=n(P)}function Te(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(U(this),e,...t);return $.set(s,e.sort?e.sort():[e]),f(s)}:Ee().includes(n)?function(...e){return n.apply(U(this),e),f(V.get(this))}:function(...e){return f(n.apply(U(this),e))}}function ke(n){return typeof n=="function"?Te(n):(n instanceof IDBTransaction&&Le(n),Ce(n,xe())?new Proxy(n,P):n)}function f(n){if(n instanceof IDBRequest)return De(n);if(L.has(n))return L.get(n);const e=ke(n);return e!==n&&(L.set(n,e),v.set(e,n)),e}const U=n=>v.get(n);function Pe(n,e,{blocked:t,upgrade:s,blocking:a,terminated:r}={}){const i=indexedDB.open(n,e),c=f(i);return s&&i.addEventListener("upgradeneeded",o=>{s(f(i.result),o.oldVersion,o.newVersion,f(i.transaction),o)}),t&&i.addEventListener("blocked",o=>t(o.oldVersion,o.newVersion,o)),c.then(o=>{r&&o.addEventListener("close",()=>r()),a&&o.addEventListener("versionchange",h=>a(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function ve(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",s=>e(s.oldVersion,s)),f(t).then(()=>{})}const Ie=["get","getKey","getAll","getAllKeys","count"],Ne=["put","add","delete","clear"],T=new Map;function S(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(T.get(e))return T.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,a=Ne.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(a||Ie.includes(t)))return;const r=async function(i,...c){const o=this.transaction(i,a?"readwrite":"readonly");let h=o.store;return s&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),a&&o.done]))[0]};return T.set(e,r),r}Ue(n=>({...n,get:(e,t,s)=>S(e,t)||n.get(e,t,s),has:(e,t)=>!!S(e,t)||n.has(e,t)}));try{self["workbox:expiration:7.3.0"]&&_()}catch{}const Me="workbox-expiration",y="cache-entries",O=n=>{const e=new URL(n,location.href);return e.hash="",e.href};class Ke{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(y,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&ve(this._cacheName)}async setTimestamp(e,t){e=O(e);const s={url:e,timestamp:t,cacheName:this._cacheName,id:this._getId(e)},r=(await this.getDb()).transaction(y,"readwrite",{durability:"relaxed"});await r.store.put(s),await r.done}async getTimestamp(e){const s=await(await this.getDb()).get(y,this._getId(e));return s==null?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let a=await s.transaction(y).store.index("timestamp").openCursor(null,"prev");const r=[];let i=0;for(;a;){const o=a.value;o.cacheName===this._cacheName&&(e&&o.timestamp<e||t&&i>=t?r.push(a.value):i++),a=await a.continue()}const c=[];for(const o of r)await s.delete(y,o.id),c.push(o.url);return c}_getId(e){return this._cacheName+"|"+O(e)}async getDb(){return this._db||(this._db=await Pe(Me,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class Ae{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new Ke(e)}async expireEntries(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const a of t)await s.delete(a,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,H(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-this._maxAgeSeconds*1e3;return t!==void 0?t<s:!0}else return!1}async delete(){this._rerunRequested=!1,await this._timestampModel.expireEntries(1/0)}}function Se(n){B.add(n)}class Oe{constructor(e={}){this.cachedResponseWillBeUsed=async({event:t,request:s,cacheName:a,cachedResponse:r})=>{if(!r)return null;const i=this._isResponseDateFresh(r),c=this._getCacheExpiration(a);H(c.expireEntries());const o=c.updateTimestamp(s.url);if(t)try{t.waitUntil(o)}catch{}return i?r:null},this.cacheDidUpdate=async({cacheName:t,request:s})=>{const a=this._getCacheExpiration(t);await a.updateTimestamp(s.url),await a.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&Se(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===b.getRuntimeName())throw new l("expire-custom-caches-only");let t=this._cacheExpirations.get(e);return t||(t=new Ae(e,this._config),this._cacheExpirations.set(e,t)),t}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(t===null)return!0;const s=Date.now();return t>=s-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),a=new Date(t).getTime();return isNaN(a)?null:a}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}Re([{"revision":"1872c500de691dce40960bb85481de07","url":"registerSW.js"},{"revision":"0f93805414c783a30b72e0ce88f2c7c4","url":"icons/icon.svg"},{"revision":"5dee5ddcd8e8533edb348118334d9756","url":"icons/icon-512.png"},{"revision":"75734e6b38a556148f51b9e10eeb01c8","url":"icons/icon-192.png"},{"revision":"0362e0eb00358646fd4c97674945adba","url":"icons/icon-180.png"},{"revision":null,"url":"assets/index-yPsf11Zp.css"},{"revision":null,"url":"assets/index-CC1GAu2S.js"},{"revision":"0362e0eb00358646fd4c97674945adba","url":"icons/icon-180.png"},{"revision":"75734e6b38a556148f51b9e10eeb01c8","url":"icons/icon-192.png"},{"revision":"5dee5ddcd8e8533edb348118334d9756","url":"icons/icon-512.png"},{"revision":"b0747e8d6cde0d45e05be8e5c731729e","url":"manifest.webmanifest"}]);ye();q(({url:n})=>n.hostname==="cdn.jsdelivr.net"&&n.pathname.endsWith(".ttf"),new be({cacheName:"termbeam-fonts",plugins:[new Oe({maxEntries:5,maxAgeSeconds:365*24*60*60})]}));self.addEventListener("message",n=>{var e;((e=n.data)==null?void 0:e.type)==="CLEAR_CACHES"&&caches.keys().then(t=>{for(const s of t)s!=="workbox-precache-v2"&&caches.delete(s)})});self.addEventListener("install",()=>{self.skipWaiting()});self.addEventListener("activate",n=>{n.waitUntil(caches.delete("termbeam-navigation").then(()=>self.clients.claim()))});
|
|
2
|
+
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return N(e,async()=>{const t=new Y;this.strategy.plugins.push(t);for(const[r,i]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(i),o=this._urlsToCacheModes.get(r),h=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:i},request:h,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return N(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),r=[];for(const i of s)a.has(i.url)||(await t.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new l("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let D;const j=()=>(D||(D=new oe),D);try{self["workbox:routing:7.3.0"]&&_()}catch{}const F="GET",x=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=F){this.handler=x(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=x(e)}}class he extends R{constructor(e,t,s){const a=({url:r})=>{const i=e.exec(r.href);if(i&&!(r.origin!==location.origin&&i.index!==0))return i.slice(1)};super(a,t,s)}}class le{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const r=new Request(...a);return this.handleRequest({request:r,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=i&&i.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let h;try{h=c.handle({url:s,request:e,event:t,params:r})}catch(u){h=Promise.reject(u)}const g=i&&i.catchHandler;return h instanceof Promise&&(this._catchHandler||g)&&(h=h.catch(async u=>{if(g)try{return await g.handle({url:s,request:e,event:t,params:r})}catch(I){I instanceof Error&&(u=I)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),h}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const r=this._routes.get(s.method)||[];for(const i of r){let c;const o=i.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:i,params:c}}return{}}setDefaultHandler(e,t=F){this._defaultHandlerMap.set(t,x(e))}setCatchHandler(e){this._catchHandler=x(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new l("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new l("unregister-route-route-not-registered")}}let w;const ue=()=>(w||(w=new le,w.addFetchListener(),w.addCacheListener()),w);function q(n,e,t){let s;if(typeof n=="string"){const r=new URL(n,location.href),i=({url:c})=>c.href===r.href;s=new R(i,e,t)}else if(n instanceof RegExp)s=new he(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new l("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return ue().registerRoute(s),s}function de(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*fe(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const r=new URL(n,location.href);r.hash="",yield r.href;const i=de(r,e);if(yield i.href,t&&i.pathname.endsWith("/")){const c=new URL(i.href);c.pathname+=t,yield c.href}if(s){const c=new URL(i.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:r});for(const o of c)yield o.href}}class pe extends R{constructor(e,t){const s=({request:a})=>{const r=e.getURLsToCacheKeys();for(const i of fe(a.url,t)){const c=r.get(i);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ge(n){const e=j(),t=new pe(e,n);q(t)}const me="-precache-",we=async(n,e=me)=>{const s=(await self.caches.keys()).filter(a=>a.includes(e)&&a.includes(self.registration.scope)&&a!==n);return await Promise.all(s.map(a=>self.caches.delete(a))),s};function ye(){self.addEventListener("activate",(n=>{const e=b.getPrecacheName();n.waitUntil(we(e).then(t=>{}))}))}function _e(n){j().precache(n)}function Re(n,e){_e(n),ge(e)}class be extends W{async _handle(e,t){let s=await t.cacheMatch(e),a;if(!s)try{s=await t.fetchAndCachePut(e)}catch(r){r instanceof Error&&(a=r)}if(!s)throw new l("no-response",{url:e.url,error:a});return s}}function H(n){n.then(()=>{})}const Ce=(n,e)=>e.some(t=>n instanceof t);let K,A;function xe(){return K||(K=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ee(){return A||(A=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const V=new WeakMap,k=new WeakMap,$=new WeakMap,L=new WeakMap,v=new WeakMap;function De(n){const e=new Promise((t,s)=>{const a=()=>{n.removeEventListener("success",r),n.removeEventListener("error",i)},r=()=>{t(f(n.result)),a()},i=()=>{s(n.error),a()};n.addEventListener("success",r),n.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&V.set(t,n)}).catch(()=>{}),v.set(e,n),e}function Le(n){if(k.has(n))return;const e=new Promise((t,s)=>{const a=()=>{n.removeEventListener("complete",r),n.removeEventListener("error",i),n.removeEventListener("abort",i)},r=()=>{t(),a()},i=()=>{s(n.error||new DOMException("AbortError","AbortError")),a()};n.addEventListener("complete",r),n.addEventListener("error",i),n.addEventListener("abort",i)});k.set(n,e)}let P={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return k.get(n);if(e==="objectStoreNames")return n.objectStoreNames||$.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return f(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Ue(n){P=n(P)}function Te(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(U(this),e,...t);return $.set(s,e.sort?e.sort():[e]),f(s)}:Ee().includes(n)?function(...e){return n.apply(U(this),e),f(V.get(this))}:function(...e){return f(n.apply(U(this),e))}}function ke(n){return typeof n=="function"?Te(n):(n instanceof IDBTransaction&&Le(n),Ce(n,xe())?new Proxy(n,P):n)}function f(n){if(n instanceof IDBRequest)return De(n);if(L.has(n))return L.get(n);const e=ke(n);return e!==n&&(L.set(n,e),v.set(e,n)),e}const U=n=>v.get(n);function Pe(n,e,{blocked:t,upgrade:s,blocking:a,terminated:r}={}){const i=indexedDB.open(n,e),c=f(i);return s&&i.addEventListener("upgradeneeded",o=>{s(f(i.result),o.oldVersion,o.newVersion,f(i.transaction),o)}),t&&i.addEventListener("blocked",o=>t(o.oldVersion,o.newVersion,o)),c.then(o=>{r&&o.addEventListener("close",()=>r()),a&&o.addEventListener("versionchange",h=>a(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function ve(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",s=>e(s.oldVersion,s)),f(t).then(()=>{})}const Ie=["get","getKey","getAll","getAllKeys","count"],Ne=["put","add","delete","clear"],T=new Map;function S(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(T.get(e))return T.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,a=Ne.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(a||Ie.includes(t)))return;const r=async function(i,...c){const o=this.transaction(i,a?"readwrite":"readonly");let h=o.store;return s&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),a&&o.done]))[0]};return T.set(e,r),r}Ue(n=>({...n,get:(e,t,s)=>S(e,t)||n.get(e,t,s),has:(e,t)=>!!S(e,t)||n.has(e,t)}));try{self["workbox:expiration:7.3.0"]&&_()}catch{}const Me="workbox-expiration",y="cache-entries",O=n=>{const e=new URL(n,location.href);return e.hash="",e.href};class Ke{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(y,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&ve(this._cacheName)}async setTimestamp(e,t){e=O(e);const s={url:e,timestamp:t,cacheName:this._cacheName,id:this._getId(e)},r=(await this.getDb()).transaction(y,"readwrite",{durability:"relaxed"});await r.store.put(s),await r.done}async getTimestamp(e){const s=await(await this.getDb()).get(y,this._getId(e));return s==null?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let a=await s.transaction(y).store.index("timestamp").openCursor(null,"prev");const r=[];let i=0;for(;a;){const o=a.value;o.cacheName===this._cacheName&&(e&&o.timestamp<e||t&&i>=t?r.push(a.value):i++),a=await a.continue()}const c=[];for(const o of r)await s.delete(y,o.id),c.push(o.url);return c}_getId(e){return this._cacheName+"|"+O(e)}async getDb(){return this._db||(this._db=await Pe(Me,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class Ae{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new Ke(e)}async expireEntries(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const a of t)await s.delete(a,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,H(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-this._maxAgeSeconds*1e3;return t!==void 0?t<s:!0}else return!1}async delete(){this._rerunRequested=!1,await this._timestampModel.expireEntries(1/0)}}function Se(n){B.add(n)}class Oe{constructor(e={}){this.cachedResponseWillBeUsed=async({event:t,request:s,cacheName:a,cachedResponse:r})=>{if(!r)return null;const i=this._isResponseDateFresh(r),c=this._getCacheExpiration(a);H(c.expireEntries());const o=c.updateTimestamp(s.url);if(t)try{t.waitUntil(o)}catch{}return i?r:null},this.cacheDidUpdate=async({cacheName:t,request:s})=>{const a=this._getCacheExpiration(t);await a.updateTimestamp(s.url),await a.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&Se(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===b.getRuntimeName())throw new l("expire-custom-caches-only");let t=this._cacheExpirations.get(e);return t||(t=new Ae(e,this._config),this._cacheExpirations.set(e,t)),t}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(t===null)return!0;const s=Date.now();return t>=s-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),a=new Date(t).getTime();return isNaN(a)?null:a}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}Re([{"revision":"1872c500de691dce40960bb85481de07","url":"registerSW.js"},{"revision":"0f93805414c783a30b72e0ce88f2c7c4","url":"icons/icon.svg"},{"revision":"5dee5ddcd8e8533edb348118334d9756","url":"icons/icon-512.png"},{"revision":"75734e6b38a556148f51b9e10eeb01c8","url":"icons/icon-192.png"},{"revision":"0362e0eb00358646fd4c97674945adba","url":"icons/icon-180.png"},{"revision":null,"url":"assets/xychartDiagram-JWTSCODW-D9XfRSJG.js"},{"revision":null,"url":"assets/vennDiagram-LZ73GAT5-DgRtErsV.js"},{"revision":null,"url":"assets/treemap-KZPCXAKY-nIfENT7p.js"},{"revision":null,"url":"assets/timeline-definition-YZTLITO2-DYAS6m-N.js"},{"revision":null,"url":"assets/stateDiagram-v2-FVOUBMTO-Dfbot3pk.js"},{"revision":null,"url":"assets/stateDiagram-RAJIS63D-ClUO2QUY.js"},{"revision":null,"url":"assets/sequenceDiagram-2WXFIKYE-Bz02FAcN.js"},{"revision":null,"url":"assets/sankeyDiagram-WA2Y5GQK-tsMMebjh.js"},{"revision":null,"url":"assets/requirementDiagram-Z7DCOOCP-DXKn90a3.js"},{"revision":null,"url":"assets/quadrantDiagram-337W2JSQ-C9m7_FOq.js"},{"revision":null,"url":"assets/pieDiagram-SKSYHLDU-aVCS7fbB.js"},{"revision":null,"url":"assets/ordinal-Cboi1Yqb.js"},{"revision":null,"url":"assets/mindmap-definition-YRQLILUH-CxnfH_kb.js"},{"revision":null,"url":"assets/linear-D_o_z79L.js"},{"revision":null,"url":"assets/layout-CtbnOt5R.js"},{"revision":null,"url":"assets/katex-B1X10hvy.js"},{"revision":null,"url":"assets/kanban-definition-K7BYSVSG-1JGSQux8.js"},{"revision":null,"url":"assets/journeyDiagram-4ABVD52K-Dyz49OU3.js"},{"revision":null,"url":"assets/ishikawaDiagram-PHBUUO56-CkSxg1hl.js"},{"revision":null,"url":"assets/init-Gi6I4Gst.js"},{"revision":null,"url":"assets/infoDiagram-LFFYTUFH-CIFqamt3.js"},{"revision":null,"url":"assets/index-CwxEeE2N.js"},{"revision":null,"url":"assets/index-6PEqObPX.css"},{"revision":null,"url":"assets/graph-DKnDIJMD.js"},{"revision":null,"url":"assets/gitGraphDiagram-K3NZZRJ6-CcUONJkD.js"},{"revision":null,"url":"assets/ganttDiagram-A5KZAMGK-DPFE5RMt.js"},{"revision":null,"url":"assets/flowDiagram-PKNHOUZH-z2hCkApS.js"},{"revision":null,"url":"assets/erDiagram-INFDFZHY-W6GTubhX.js"},{"revision":null,"url":"assets/diagram-P4PSJMXO-DBdxSnG_.js"},{"revision":null,"url":"assets/diagram-IFDJBPK2-BPunptYj.js"},{"revision":null,"url":"assets/diagram-E7M64L7V-6zO1mbsa.js"},{"revision":null,"url":"assets/defaultLocale-DX6XiGOO.js"},{"revision":null,"url":"assets/dagre-KLK3FWXG-CiZyaN9C.js"},{"revision":null,"url":"assets/cytoscape.esm-BQaXIfA_.js"},{"revision":null,"url":"assets/cose-bilkent-S5V4N54A-HjULVf9U.js"},{"revision":null,"url":"assets/clone-R2IpC4hJ.js"},{"revision":null,"url":"assets/classDiagram-v2-RAHNMMFH-D4y0fwUO.js"},{"revision":null,"url":"assets/classDiagram-VBA2DB6C-D4y0fwUO.js"},{"revision":null,"url":"assets/chunk-WL4C6EOR-4qIeQLNy.js"},{"revision":null,"url":"assets/chunk-QZHKN3VN-Sw_cLRTv.js"},{"revision":null,"url":"assets/chunk-NQ4KR5QH-B3NVqUmA.js"},{"revision":null,"url":"assets/chunk-KX2RTZJC-B4E2qFI2.js"},{"revision":null,"url":"assets/chunk-JSJVCQXG-DPnc_wzj.js"},{"revision":null,"url":"assets/chunk-FMBD7UC4-Dt_lJu1p.js"},{"revision":null,"url":"assets/chunk-55IACEB6-BKpR8SpD.js"},{"revision":null,"url":"assets/chunk-4BX2VUAB-I5eit8Lr.js"},{"revision":null,"url":"assets/channel-C5toNXiA.js"},{"revision":null,"url":"assets/c4Diagram-IC4MRINW-BmGrXTfN.js"},{"revision":null,"url":"assets/blockDiagram-WCTKOSBZ-B2BK13gZ.js"},{"revision":null,"url":"assets/architectureDiagram-2XIMDMQ5-D9p7d_dK.js"},{"revision":null,"url":"assets/arc-brekJh_V.js"},{"revision":null,"url":"assets/_baseUniq-DYS09A94.js"},{"revision":null,"url":"assets/_basePickBy-DjouGdsh.js"},{"revision":"0362e0eb00358646fd4c97674945adba","url":"icons/icon-180.png"},{"revision":"75734e6b38a556148f51b9e10eeb01c8","url":"icons/icon-192.png"},{"revision":"5dee5ddcd8e8533edb348118334d9756","url":"icons/icon-512.png"},{"revision":"b0747e8d6cde0d45e05be8e5c731729e","url":"manifest.webmanifest"}]);ye();q(({url:n})=>n.hostname==="cdn.jsdelivr.net"&&n.pathname.endsWith(".ttf"),new be({cacheName:"termbeam-fonts",plugins:[new Oe({maxEntries:5,maxAgeSeconds:365*24*60*60})]}));self.addEventListener("message",n=>{var e;((e=n.data)==null?void 0:e.type)==="CLEAR_CACHES"&&caches.keys().then(t=>{for(const s of t)s!=="workbox-precache-v2"&&caches.delete(s)})});self.addEventListener("install",()=>{self.skipWaiting()});self.addEventListener("activate",n=>{n.waitUntil(caches.delete("termbeam-navigation").then(()=>self.clients.claim()))});
|
package/src/server/routes.js
CHANGED
|
@@ -463,6 +463,153 @@ function setupRoutes(app, { auth, sessions, config, state }) {
|
|
|
463
463
|
});
|
|
464
464
|
});
|
|
465
465
|
|
|
466
|
+
// Browse files and directories within a session's CWD
|
|
467
|
+
app.get('/api/sessions/:id/files', apiRateLimit, auth.middleware, (req, res) => {
|
|
468
|
+
const session = sessions.get(req.params.id);
|
|
469
|
+
if (!session) return res.status(404).json({ error: 'Session not found' });
|
|
470
|
+
|
|
471
|
+
if (req.query.dir !== undefined && typeof req.query.dir !== 'string') {
|
|
472
|
+
return res.status(400).json({ error: 'Invalid dir parameter' });
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const rootDir = path.resolve(session.cwd);
|
|
476
|
+
const dir = path.resolve(rootDir, req.query.dir || '.');
|
|
477
|
+
|
|
478
|
+
const MAX_ENTRIES = 1000;
|
|
479
|
+
try {
|
|
480
|
+
const dirents = fs.readdirSync(dir, { withFileTypes: true });
|
|
481
|
+
let entries = dirents
|
|
482
|
+
.filter((e) => {
|
|
483
|
+
if (e.name.startsWith('.')) return false;
|
|
484
|
+
try {
|
|
485
|
+
return !fs.lstatSync(path.join(dir, e.name)).isSymbolicLink();
|
|
486
|
+
} catch {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
})
|
|
490
|
+
.map((e) => {
|
|
491
|
+
const fullPath = path.join(dir, e.name);
|
|
492
|
+
const isDir = e.isDirectory();
|
|
493
|
+
try {
|
|
494
|
+
const stat = fs.statSync(fullPath);
|
|
495
|
+
return {
|
|
496
|
+
name: e.name,
|
|
497
|
+
type: isDir ? 'directory' : 'file',
|
|
498
|
+
size: isDir ? 0 : stat.size,
|
|
499
|
+
modified: stat.mtime.toISOString(),
|
|
500
|
+
};
|
|
501
|
+
} catch {
|
|
502
|
+
return { name: e.name, type: isDir ? 'directory' : 'file', size: 0, modified: null };
|
|
503
|
+
}
|
|
504
|
+
})
|
|
505
|
+
.sort((a, b) => {
|
|
506
|
+
if (a.type !== b.type) return a.type === 'directory' ? -1 : 1;
|
|
507
|
+
return a.name.localeCompare(b.name);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
const truncated = entries.length > MAX_ENTRIES;
|
|
511
|
+
entries = entries.slice(0, MAX_ENTRIES);
|
|
512
|
+
|
|
513
|
+
res.json({ base: dir, rootDir, entries, truncated });
|
|
514
|
+
} catch (err) {
|
|
515
|
+
log.warn(`File browse failed: ${err.message}`);
|
|
516
|
+
res.status(500).json({ error: 'Failed to read directory' });
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// Download a file from within a session's CWD
|
|
521
|
+
app.get('/api/sessions/:id/download', apiRateLimit, auth.middleware, (req, res) => {
|
|
522
|
+
const session = sessions.get(req.params.id);
|
|
523
|
+
if (!session) return res.status(404).json({ error: 'Session not found' });
|
|
524
|
+
|
|
525
|
+
const file = req.query.file;
|
|
526
|
+
if (!file || typeof file !== 'string') {
|
|
527
|
+
return res.status(400).json({ error: 'Missing file parameter' });
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const rootDir = path.resolve(session.cwd);
|
|
531
|
+
const filePath = path.resolve(rootDir, file);
|
|
532
|
+
|
|
533
|
+
try {
|
|
534
|
+
if (fs.lstatSync(filePath).isSymbolicLink()) {
|
|
535
|
+
return res.status(403).json({ error: 'Symbolic links are not allowed' });
|
|
536
|
+
}
|
|
537
|
+
const stat = fs.statSync(filePath);
|
|
538
|
+
if (!stat.isFile()) {
|
|
539
|
+
return res.status(400).json({ error: 'Not a regular file' });
|
|
540
|
+
}
|
|
541
|
+
if (stat.size > 100 * 1024 * 1024) {
|
|
542
|
+
return res.status(413).json({ error: 'File too large (max 100 MB)' });
|
|
543
|
+
}
|
|
544
|
+
} catch {
|
|
545
|
+
return res.status(404).json({ error: 'File not found' });
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
res.download(filePath);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// Serve a file inline (for images in markdown viewer, etc.)
|
|
552
|
+
app.get('/api/sessions/:id/file-raw', apiRateLimit, auth.middleware, (req, res) => {
|
|
553
|
+
const session = sessions.get(req.params.id);
|
|
554
|
+
if (!session) return res.status(404).json({ error: 'Session not found' });
|
|
555
|
+
|
|
556
|
+
const file = req.query.file;
|
|
557
|
+
if (!file || typeof file !== 'string') {
|
|
558
|
+
return res.status(400).json({ error: 'Missing file parameter' });
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const rootDir = path.resolve(session.cwd);
|
|
562
|
+
const filePath = path.resolve(rootDir, file);
|
|
563
|
+
|
|
564
|
+
try {
|
|
565
|
+
if (fs.lstatSync(filePath).isSymbolicLink()) {
|
|
566
|
+
return res.status(403).json({ error: 'Symbolic links are not allowed' });
|
|
567
|
+
}
|
|
568
|
+
const stat = fs.statSync(filePath);
|
|
569
|
+
if (!stat.isFile()) {
|
|
570
|
+
return res.status(400).json({ error: 'Not a regular file' });
|
|
571
|
+
}
|
|
572
|
+
if (stat.size > 20 * 1024 * 1024) {
|
|
573
|
+
return res.status(413).json({ error: 'File too large (max 20 MB)' });
|
|
574
|
+
}
|
|
575
|
+
} catch {
|
|
576
|
+
return res.status(404).json({ error: 'File not found' });
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
res.sendFile(filePath);
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// Read file content as text (for markdown viewer, etc.)
|
|
583
|
+
app.get('/api/sessions/:id/file-content', apiRateLimit, auth.middleware, (req, res) => {
|
|
584
|
+
const session = sessions.get(req.params.id);
|
|
585
|
+
if (!session) return res.status(404).json({ error: 'Session not found' });
|
|
586
|
+
|
|
587
|
+
const file = req.query.file;
|
|
588
|
+
if (!file || typeof file !== 'string') {
|
|
589
|
+
return res.status(400).json({ error: 'Missing file parameter' });
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const rootDir = path.resolve(session.cwd);
|
|
593
|
+
const filePath = path.resolve(rootDir, file);
|
|
594
|
+
|
|
595
|
+
try {
|
|
596
|
+
if (fs.lstatSync(filePath).isSymbolicLink()) {
|
|
597
|
+
return res.status(403).json({ error: 'Symbolic links are not allowed' });
|
|
598
|
+
}
|
|
599
|
+
const stat = fs.statSync(filePath);
|
|
600
|
+
if (!stat.isFile()) {
|
|
601
|
+
return res.status(400).json({ error: 'Not a regular file' });
|
|
602
|
+
}
|
|
603
|
+
if (stat.size > 2 * 1024 * 1024) {
|
|
604
|
+
return res.status(413).json({ error: 'File too large (max 2 MB)' });
|
|
605
|
+
}
|
|
606
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
607
|
+
res.json({ content, name: path.basename(filePath), size: stat.size });
|
|
608
|
+
} catch {
|
|
609
|
+
return res.status(404).json({ error: 'File not found' });
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
|
|
466
613
|
// Directory listing for folder browser
|
|
467
614
|
app.get('/api/dirs', apiRateLimit, auth.middleware, (req, res) => {
|
|
468
615
|
log.debug(`Directory listing requested: ${req.query.q || config.cwd}`);
|
|
@@ -472,16 +619,16 @@ function setupRoutes(app, { auth, sessions, config, state }) {
|
|
|
472
619
|
const prefix = endsWithSep ? '' : path.basename(query);
|
|
473
620
|
|
|
474
621
|
try {
|
|
622
|
+
const MAX_DIRS = 500;
|
|
475
623
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
476
|
-
const
|
|
624
|
+
const filtered = entries
|
|
477
625
|
.filter((e) => e.isDirectory() && !e.name.startsWith('.'))
|
|
478
|
-
.filter((e) => !prefix || e.name.toLowerCase().startsWith(prefix.toLowerCase()))
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
res.json({ base: dir, dirs });
|
|
626
|
+
.filter((e) => !prefix || e.name.toLowerCase().startsWith(prefix.toLowerCase()));
|
|
627
|
+
const dirs = filtered.slice(0, MAX_DIRS).map((e) => path.join(dir, e.name));
|
|
628
|
+
res.json({ base: dir, dirs, truncated: filtered.length > MAX_DIRS });
|
|
482
629
|
} catch (err) {
|
|
483
630
|
log.warn(`Directory listing failed: ${err.message}`);
|
|
484
|
-
res.json({ base: dir, dirs: [] });
|
|
631
|
+
res.json({ base: dir, dirs: [], truncated: false });
|
|
485
632
|
}
|
|
486
633
|
});
|
|
487
634
|
}
|