osmgl 0.31.85 → 0.31.86

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.
@@ -0,0 +1,3 @@
1
+ import {bf,Yd}from'./chunk-OCA36U5D.js';import*as Ie from'polygon-clipping';function U(n){let t=111320*Math.cos(n[1]*Math.PI/180);return {toXY:e=>({x:(e[0]-n[0])*t,y:(e[1]-n[1])*111320}),toLonLat:e=>[n[0]+e.x/t,n[1]+e.y/111320]}}var en=(n,t,e)=>n+(t-n)*e,K=(n,t,e)=>({x:en(n.x,t.x,e),y:en(n.y,t.y,e)}),B=(n,t)=>Math.hypot(t.x-n.x,t.y-n.y),xt=n=>n<0?0:n>1?1:n,cn=n=>{let t=xt(n);return t*t*(3-2*t)};function In(n,t){let e=[0];for(let r=1;r<n.length;r++)e.push(e[r-1]+(t?t[r-1]:B(n[r-1],n[r])));return {pts:n,cum:e,length:e[e.length-1]??0}}function gn(n,t){let e=(t[0]-n[0])*Math.cos((n[1]+t[1])/2*Math.PI/180)*111320,r=(t[1]-n[1])*111320;return Math.hypot(e,r)}function Sn(n,t){let e=n.slice(1).map((r,o)=>gn(n[o],r));return In(n.map(t.toXY),e)}function yn(n,t){let e=0,r=n.pts.length-2;if(r<0)return 0;for(;e<r;){let o=e+r+1>>1;n.cum[o]<=t?e=o:r=o-1;}return e}function $(n,t){if(n.pts.length===1)return n.pts[0];let e=yn(n,t),r=n.cum[e+1]-n.cum[e],o=r>1e-9?(t-n.cum[e])/r:0;return K(n.pts[e],n.pts[e+1],o)}function An(n,t){if(n.pts.length<2)return {x:1,y:0};let e=yn(n,t);for(;e<n.pts.length-2&&B(n.pts[e],n.pts[e+1])<1e-6;)e++;let r=n.pts[e],o=n.pts[e+1],s=B(r,o)||1;return {x:(o.x-r.x)/s,y:(o.y-r.y)/s}}function Ze(n,t,e=0){let r=e>0?(()=>{let o=$(n,t),s=$(n,Math.min(n.length,t+e)),i=B(o,s);return i>.5?{x:(s.x-o.x)/i,y:(s.y-o.y)/i}:An(n,t)})():An(n,t);return (Math.atan2(r.x,r.y)*180/Math.PI+360)%360}function nt(n,t,e=-1/0,r=1/0){let o={s:0,d:1/0};for(let s=0;s+1<n.pts.length;s++){if(n.cum[s+1]<e||n.cum[s]>r)continue;let i=n.pts[s],a=n.pts[s+1],u=a.x-i.x,l=a.y-i.y,c=u*u+l*l,f=c>1e-12?xt(((t.x-i.x)*u+(t.y-i.y)*l)/c):0,b={x:i.x+u*f,y:i.y+l*f},m=B(t,b);m<o.d&&(o={s:n.cum[s]+f*(n.cum[s+1]-n.cum[s]),d:m});}return o}function Qt(n,t){if(n.length<2)return n.slice();let e=[n[0]];for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r],i=Math.max(1,Math.ceil(B(o,s)/t));for(let a=1;a<=i;a++)e.push(K(o,s,a/i));}return e}function Qe(n,t,e){let r=In(n),o=Math.max(0,Math.min(t,e)),s=Math.min(r.length,Math.max(t,e));if(n.length<2||s-o<1e-6)return [];let i=[$(r,o)];for(let a=0;a<n.length;a++)r.cum[a]>o&&r.cum[a]<s&&i.push(n[a]);return i.push($(r,s)),i}function no(n,t){let e=n.length;if(e<2)return n.slice();let r=i=>typeof t=="number"?t:t[i]??0,o=(i,a)=>{let u=B(i,a)||1;return {x:(a.y-i.y)/u,y:-(a.x-i.x)/u}},s=[];for(let i=0;i<e;i++){let a=i>0?o(n[i-1],n[i]):null,u=i<e-1?o(n[i],n[i+1]):null,l,c;if(a&&u){l=a.x+u.x,c=a.y+u.y;let f=Math.hypot(l,c);if(f<1e-6)l=u.x,c=u.y;else {l/=f,c/=f;let b=Math.max(.5,l*u.x+c*u.y);l/=b,c/=b;}}else {let f=a??u;l=f.x,c=f.y;}s.push({x:n[i].x+l*r(i),y:n[i].y+c*r(i)});}return s}function ne(n,t,e){let r=$(n,t),o=An(n,t);return (e.x-r.x)*o.y-(e.y-r.y)*o.x}var te=2;function ee(n,t,e){let r=Qt(t,te),o={s:[],pts:[]};for(let s of r){let{s:i}=nt(n,s,e[0],e[1]);o.s.length&&i<=o.s[o.s.length-1]+.05||(o.s.push(i),o.pts.push(s));}return o.s.length>=2?o:null}function ft(n,t,e){let r=t.s.length,o=u=>{let l=ne(n,t.s[u],t.pts[u]);return oe(n,e,l)};if(e<=t.s[0])return o(0);if(e>=t.s[r-1])return o(r-1);let s=0,i=r-1;for(;i-s>1;){let u=s+i>>1;t.s[u]<=e?s=u:i=u;}let a=(e-t.s[s])/(t.s[i]-t.s[s]);return K(t.pts[s],t.pts[i],a)}function oe(n,t,e){let r=$(n,t),o=An(n,t);return {x:r.x+o.y*e,y:r.y-o.x*e}}var yt=.7,Jn=2,En=25,Mt=4.5,re=8,se=["round","flat","arrow"],ie="round",to=n=>typeof n=="string"&&se.includes(n),mt=32,bt=1.5;function Mn(n,t=0,e){let r=n.map(([s,i])=>[Math.min(s,i),Math.max(s,i)]).map(([s,i])=>e?[Math.max(s,e[0]),Math.min(i,e[1])]:[s,i]).filter(([s,i])=>i-s>1e-6).sort((s,i)=>s[0]-i[0]),o=[];for(let s of r){let i=o[o.length-1];i&&s[0]-i[1]<=t?i[1]=Math.max(i[1],s[1]):o.push([s[0],s[1]]);}return o}function ae(n){let t=[...n].sort((r,o)=>r.index-o.index),e=[];for(let r of t){let o=e[e.length-1];o&&r.index===o[o.length-1].index+1?o.push(r):e.push([r]);}return e}var xn=4,ht=3.3,ue=.045;function eo(n,t,e={}){if(t.length<2||!n.segments.length)return {features:[],hidden:[]};let r=U(t[0]),o=Sn(t,r),s=Mn(n.coverage,e.gapM??0,[0,o.length]);if(!s.length)return {features:[],hidden:[]};let i=[...n.segments].sort((p,x)=>p.fromM-x.fromM),a=new Map;for(let p of i){let x=[p.fromM-40,p.toM+40],k=new Map;for(let L of p.lanes){if(L.centre.length<2)continue;let I=ee(o,L.centre.map(r.toXY),x);I&&k.set(L.laneId,{lane:L,track:I});}a.set(p,k);}let u=p=>i.some(x=>a.get(x).has(p)),l=(p,x)=>x<p.fromM?p.fromM-x:x>p.toM?x-p.toM:0,c=(p,x)=>{let k=null;for(let L of i)a.get(L).has(p)&&(!k||l(L,x)<=l(k,x))&&(k=k&&l(k,x)===0&&l(L,x)===0?k:L);return k},f=(p,x,k)=>{let L=a.get(x),I=L.get(p[0].laneId),E=L.get(p[p.length-1].laneId);if(!I||!E)return null;let S=ft(o,I.track,k),R=ft(o,E.track,k),g=p.length===1?p[0].widthM:B(S,R)+(p[0].widthM+p[p.length-1].widthM)/2;return {p:K(S,R,.5),w:g,level:x.level}},b=(p,x)=>ae(p.lanes.filter(k=>k.state===x&&a.get(p).has(k.laneId))),m=(p,x)=>{let k=b(p,"recommended").find(I=>I.some(E=>E.laneId===x));if(k)return k;let L=a.get(p).get(x);return L?[L.lane]:null},h=(p,x)=>{let k=c(p,x),L=k?m(k,p):null;return k&&L?f(L,k,x):null},d=n.changes.filter(p=>u(p.fromLane)&&u(p.toLane)&&p.endM>p.startM).sort((p,x)=>p.startM-x.startM),y=(p,x)=>{let k=a.get(p);if(p.ribbonLaneId&&k.has(p.ribbonLaneId)){let R=p.ribbonLaneId;for(let g of d)g.endM<=x+1e-6&&g.endM>=p.fromM-1&&g.fromLane===R&&(R=g.toLane);return R}let L=d.find(R=>R.startM>x&&R.startM<=p.toM&&k.has(R.fromLane));if(L)return L.fromLane;let I=[...d].reverse().find(R=>R.endM<=x+1e-6&&R.endM>=p.fromM-1&&k.has(R.toLane));if(I)return I.toLane;let E=d.find(R=>R.startM>=p.toM&&k.has(R.fromLane));if(E)return E.fromLane;let S=b(p,"recommended");return S.length?S.reduce((R,g)=>g.length>R.length?g:R)[0].laneId:null},M=(p,x)=>{let k=y(p,x),L=k?m(p,k):null;return L?f(L,p,x):null},w=new Map(i.map(p=>{let x=new Set;for(let k of [p.fromM,...d.map(L=>L.endM).filter(L=>L>p.fromM&&L<=p.toM),p.toM]){let L=y(p,k);L&&x.add(L);}return [p,x]})),P=p=>w.get(p).size>0,_=p=>{let x=d.find(R=>R.startM<=p&&p<=R.endM);if(x){let R=h(x.fromLane,p),g=h(x.toLane,p);if(R&&g){let F=cn((p-x.startM)/(x.endM-x.startM));return {p:K(R.p,g.p,F),w:en(R.w,g.w,F),level:F<.5?R.level:g.level}}}let k=[...i].reverse().find(R=>R.fromM<=p&&p<=R.toM&&P(R));if(k)return M(k,p);let L=[...i].reverse().find(R=>R.toM<p&&P(R)),I=i.find(R=>R.fromM>p&&P(R)),E=L?M(L,L.toM):null,S=I?M(I,I.fromM):null;if(E&&S&&L&&I){let R=cn((p-L.toM)/(I.fromM-L.toM));return {p:K(E.p,S.p,R),w:en(E.w,S.w,R),level:Math.max(E.level,S.level)}}return L?M(L,p):I?M(I,p):null},A=[],C=[],X={stations:[],line:[],weights:[]},D=e.cap??ie,T=p=>[p[0]>0||D==="flat"?"flat":"round",p[1]>0?"flat":D],J=D==="flat"?"flat":"round",q=(p,x,k,L,I)=>{for(let E=0;E+1<i.length;E++){let S=i[E],R=i[E+1];if(!P(S)||!P(R)||R.fromM-S.toM>2*qn)continue;let g=Math.max(S.toM-Math.min(qn,(S.toM-S.fromM)/2),L),F=Math.min(R.fromM+Math.min(qn,(R.toM-R.fromM)/2),I);d.some(O=>O.endM>g-5&&O.startM<F+5)||le(o,p,x,k,g,F);}},N=e.outside===false?null:{laneM:e.outside?.laneM??ht,offsetM:e.outside?.offsetM??(e.outside?.laneM??ht)/2};if(N){let p=o.length,x=Zn(0,p,Jn),k=Lt(x.map(g=>$(o,g))),L=nn(k),I=g=>({x:k[g].x+L[g].x*N.offsetM,y:k[g].y+L[g].y*N.offsetM}),E=g=>s.some(([F,O])=>O-F>=xn&&g>=F-1e-9&&g<=O+1e-9),S=x.map(g=>E(g)?_(g):null),R=[];for(let g=0;g<x.length;){if(!S[g]){g++;continue}let F=g;for(;F+1<x.length&&S[F+1];)F++;x[F]-x[g]>=xn&&R.push([g,F]),g=F+1;}if(R.length){let g=x.map((Y,z)=>({p:I(z),w:N.laneM,level:0})),F=x.slice(),O=x.map(Y=>be(Y,R.map(([z,Q])=>[x[z],x[Q]])));for(let[Y,z]of R){let Q=x[Y],rn=x[z],sn=H=>{let dn=S[H],an=Math.max(B(dn.p,I(H)),2*Math.abs(dn.w-N.laneM));return Math.min(Math.max(En,1.5*an/ue),(rn-Q)/2)},Wn=Q>.5?sn(Y):0,jn=rn<p-.5?sn(z):0;for(let H=Y;H<=z;H++){let dn=x[H],an=S[H],lt=Math.min(Wn?(dn-Q)/Wn:1/0,jn?(rn-dn)/jn:1/0);if(lt>=1){g[H]=an;continue}let Vn=cn(lt);g[H]={p:K(I(H),an.p,Vn),w:en(N.laneM,an.w,Vn),level:Vn<.5?0:an.level};}q(x,F,g,Q+Wn,rn-jn);}C.push([0,p]),pt(F,g,[0,0],r,A,T([0,0]),X,O);}}else for(let[p,x]of s){if(x-p<xn)continue;let k=Zn(p,x,Jn),L=[];for(let O of k){let Y=_(O);if(!Y){L.push({p:$(o,O),w:0,level:0});continue}L.push(Y);}let I=Math.min(En,(x-p)/3),E=p>.5?I:0,S=x<o.length-.5?I:0;k.forEach((O,Y)=>{let z=Math.min(E?(O-p)/E:1/0,S?(x-O)/S:1/0);if(z>=1)return;let Q=cn(z),rn=$(o,O),sn=L[Y];L[Y]={p:K(rn,sn.p,Q),w:sn.w,level:sn.level};});let R=k.slice();q(k,R,L,p+E,x-S);let g={s:[],pts:[]},F=()=>{if(g.s.length>=2&&g.s[g.s.length-1]-g.s[0]>=xn){C.push([g.s[0],g.s[g.s.length-1]]);let O=[g.s[0]-p<1e-6?E:0,x-g.s[g.s.length-1]<1e-6?S:0];pt(g.s,g.pts,O,r,A,T(O),X,g.s.map(()=>1));}g={s:[],pts:[]};};k.forEach((O,Y)=>{if(L[Y].w<=0){F();return}g.s.push(R[Y]),g.pts.push(L[Y]);}),F();}for(let p of i){let x=w.get(p);for(let k of b(p,"recommended"))k.some(L=>x.has(L.laneId))||v(k,p,"band");for(let k of b(p,"allowed"))v(k,p,"allowed");}function v(p,x,k){let L=Math.max(x.fromM,s[0][0]),I=Math.min(x.toM,s[s.length-1][1]);if(I-L<xn)return;let E=[],S=[];for(let g of Zn(L,I,Jn)){let F=f(p,x,g);F&&(E.push(F),S.push(g));}if(E.length<2)return;let R=Math.max(.5,E[0].w-yt);A.push(gt(k,E.map(g=>g.p),E.map(()=>R),E.map(g=>g.level),r,S,[J,J]).feature);}let Z={features:A,hidden:Mn(C,.5)};return X.stations.length>=2&&(Z.car=X),Z}var qn=14,ce=20;function le(n,t,e,r,o,s){if(s-o<8)return;let i=t.findIndex(v=>v>=o-1e-9),a=-1;for(let v=t.length-1;v>=0;v--)if(t[v]<=s+1e-9){a=v;break}if(i<2||a<0||a+2>=t.length||a-i<3)return;for(let v=i-2;v<=a+2;v++)if(r[v].w<=0)return;let u=r[i].p,l=r[a].p,c={x:u.x-r[i-2].p.x,y:u.y-r[i-2].p.y},f={x:r[a+2].p.x-l.x,y:r[a+2].p.y-l.y},b=Math.hypot(c.x,c.y),m=Math.hypot(f.x,f.y);if(b<1e-6||m<1e-6)return;let h={x:c.x/b,y:c.y/b},d={x:f.x/m,y:f.y/m},y=h.x*d.y-h.y*d.x,M=Math.abs(Math.atan2(y,h.x*d.x+h.y*d.y));if(M<ce*Math.PI/180||Math.abs(y)<1e-9)return;let w=l.x-u.x,P=l.y-u.y,_=(w*d.y-P*d.x)/y,A=(h.x*P-h.y*w)/y;if(_<.5||A<.5)return;let C={x:u.x+h.x*_,y:u.y+h.y*_},X=In([u,C,l]),D=t[a]-t[i],T=t[i],J=Mt*Math.min(1,Math.max(.2,M/(Math.PI/2))),q=r[i].w,N=r[a].w;for(let v=i+1;v<a;v++){let Z=X.length*(t[v]-t[i])/D,p=fe((Z-_)/J),x=$(X,Z);r[v]={...r[v],p:x,w:en(q,N,p)},T=Math.min(t[a],Math.max(T,nt(n,x,t[i],t[a]).s)),e[v]=T;}}function fe(n){let t=Math.abs(n)/Math.SQRT2,e=1/(1+.3275911*t),r=1-((((1.061405429*e-1.453152027)*e+1.421413741)*e-.284496736)*e+.254829592)*e*Math.exp(-t*t);return n>=0?(1+r)/2:(1-r)/2}var me=1;function be(n,t){let e=me;for(let[r,o]of t){if(n>=r&&n<=o)return 1;let s=n<r?r-n:n-o;s<En&&(e=Math.max(e,cn(1-s/En)));}return e}function he(n,t,e){let r=Math.min(n.length,t.length);if(r===0)return 0;if(!(e>n[0]))return t[0];if(e>=n[r-1])return t[r-1];let o=0,s=r-1;for(;s-o>1;){let a=o+s>>1;n[a]<=e?o=a:s=a;}let i=n[s]-n[o];return i>0?t[o]+(t[s]-t[o])*((e-n[o])/i):t[o]}function Zn(n,t,e){if(t<=n)return [n];let r=Math.max(1,Math.ceil((t-n)/e));return Array.from({length:r+1},(o,s)=>n+(t-n)*s/r)}function pt(n,t,e,r,o,s,i,a){let u=pe(t.map(m=>Math.max(.5,m.w-yt))),l=gt("band",t.map(m=>m.p),u,t.map(m=>m.level),r,n,s);o.push(l.feature);for(let m=0;m<l.stations.length;m++){let h=l.stations[m];i.stations.length&&h<i.stations[i.stations.length-1]||(i.stations.push(h),i.line.push(l.feature.line[m]),i.weights.push(he(n,a,h)));}let c=n[0]+e[0],f=n[n.length-1]-e[1],b=l.stations.map((m,h)=>m>=c-1e-6&&m<=f+1e-6?h:-1).filter(m=>m>=0);if(b.length>=2&&f-c>=10){let m=b.map(y=>l.centre[y]),h=ye(m,de),d=Math.max(1,Math.min(...b.map(y=>l.widths[y]))-.6);for(let y=0;y+1<h.length;y++){let M=b[h[y]],w=b[h[y+1]];B(l.centre[M],l.centre[w])<xe||o.push({kind:"chevron",line:[l.feature.line[M],l.feature.line[w]],width:d,levels:[l.feature.levels[M],l.feature.levels[w]],stations:[l.stations[M],l.stations[w]]});}}}var Qn=.5;function pe(n){if(!n.length)return n;let t=[...n].sort((r,o)=>r-o),e=t[t.length>>1];return n.map(r=>{let o=Math.abs(r-e);return o<Qn?e:o<2*Qn?e+Math.sign(r-e)*2*(o-Qn):r})}var de=.1,xe=6;function ye(n,t){let e=n.length;if(e<=2)return n.map((s,i)=>i);let r=new Array(e).fill(false);r[0]=true,r[e-1]=true;let o=[[0,e-1]];for(;o.length;){let[s,i]=o.pop(),a=-1,u=-1,l=n[s].x,c=n[s].y,f=n[i].x-l,b=n[i].y-c,m=Math.hypot(f,b);for(let h=s+1;h<i;h++){let d=m>1e-9?Math.abs((n[h].x-l)*b-(n[h].y-c)*f)/m:Math.hypot(n[h].x-l,n[h].y-c);d>a&&(a=d,u=h);}u>=0&&a>t&&(r[u]=true,o.push([s,u],[u,i]));}return r.map((s,i)=>s?i:-1).filter(s=>s>=0)}var Me=1;function ge(n,t,e=Me){let r=In(n);if(n.length<2||r.length<1e-6)return {pts:n.slice(),attrs:t.map(a=>a.slice())};let o=Math.max(1,Math.round(r.length/e)),s=[],i=t.map(()=>[]);for(let a=0;a<=o;a++){let u=r.length*a/o,l=yn(r,u),c=r.cum[l+1]-r.cum[l],f=c>1e-9?(u-r.cum[l])/c:0;s.push(K(n[l],n[l+1],f)),t.forEach((b,m)=>i[m].push(en(b[l],b[l+1],f)));}return {pts:s,attrs:i}}function gt(n,t,e,r,o,s,i){let a=ge(t,[e,r,s??e.map(()=>0)]),u=Lt(a.pts),l=Re(a.attrs[0]),c=a.attrs[1].map(f=>Math.round(f));return {feature:{kind:n,line:u.map(o.toLonLat),width:Math.max(...l),levels:c,outline:Ln(u,l.map(f=>f/2),nn(u),i).map(o.toLonLat),stations:a.attrs[2],widths:l,caps:i},centre:u,widths:l,stations:a.attrs[2]}}var Le=2;function Re(n,t=Le){let e=n.length;if(e<3||t<=0)return n.slice();let r=Math.ceil(t*3),o=[];for(let s=0;s<e;s++){let i=true;for(let l=Math.max(0,s-r);l<=Math.min(e-1,s+r)&&i;l++)i=Math.abs(n[l]-n[s])<1e-9;if(i||s===0||s===e-1){o.push(n[s]);continue}let a=0,u=0;for(let l=-r;l<=r;l++){let c=Math.min(e-1,Math.max(0,s+l)),f=Math.exp(-(l*l)/(2*t*t));a+=f,u+=n[c]*f;}o.push(u/a);}return o}function ke(n,t){let e=n[t-1],r=n[t],o=n[t+1],s=r.x-e.x,i=r.y-e.y,a=o.x-r.x,u=o.y-r.y;return Math.hypot(s,i)<1e-6||Math.hypot(a,u)<1e-6?0:Math.abs(Math.atan2(s*u-i*a,s*a+i*u))}function Lt(n,t=Mt){let e=n.length;if(e<3||t<=0)return n.slice();let r=0;for(let c=1;c<e;c++)r+=B(n[c-1],n[c]);let o=Math.max(.05,r/(e-1)),s=re*Math.PI/180,i=[];for(let c=1;c<e-1;c++){let f=ke(n,c);if(Math.abs(f)<=s)continue;let b=i[i.length-1];b&&(c-b.to)*o<=3?(b.to=c,b.turn+=f):i.push({at:c,turn:f,from:c,to:c});}if(!i.length)return n.slice();let a=i.map(c=>{let f=Math.max(0,c.from-2),b=Math.min(e-1,c.to+2),m={x:n[c.from].x-n[f].x,y:n[c.from].y-n[f].y},h={x:n[b].x-n[c.to].x,y:n[b].y-n[c.to].y},d=Math.abs(Math.atan2(m.x*h.y-m.y*h.x,m.x*h.x+m.y*h.y))||Math.abs(c.turn),y=t*Math.min(1,Math.max(.2,d/(Math.PI/2)))/o;return {at:(c.from+c.to)/2,sig:y}}),u=c=>{if(c<0){let f=n[Math.min(e-1,-c)];return {x:2*n[0].x-f.x,y:2*n[0].y-f.y}}if(c>e-1){let f=n[Math.max(0,2*(e-1)-c)];return {x:2*n[e-1].x-f.x,y:2*n[e-1].y-f.y}}return n[c]},l=[];for(let c=0;c<e;c++){let f=0,b=0;for(let M of a){let w=Math.abs(M.at-c),P=2*M.sig,_=1.5*M.sig,A=w<=P?1:w>=P+_?0:cn(1-(w-P)/_);(A>f||A===f&&A>0&&M.sig>b)&&(f=A,b=M.sig);}if(f<=0||c===0||c===e-1){l.push(n[c]);continue}let m=Math.ceil(b*2.5),h=0,d=0,y=0;for(let M=-m;M<=m;M++){let w=u(c+M),P=Math.exp(-(M*M)/(2*b*b));h+=w.x*P,d+=w.y*P,y+=P;}l.push(K(n[c],{x:h/y,y:d/y},f));}return l}function Ln(n,t,e=nn(n),r=["flat","flat"]){let o=n.length;if(o<2)return [];let{right:s,left:i}=we(n,t,e),a=[...s,...dt(n[o-1],e[o-1],t[o-1],r[1],true),...i.reverse(),...dt(n[0],e[0],t[0],r[0],false)];return a.push(a[0]),a}function dt(n,t,e,r,o){if(r==="flat"||!(e>0))return [];let s=o?1:-1,i=-t.y*s,a=t.x*s,u=t.x*s,l=t.y*s;if(r==="arrow")return [{x:n.x+i*e*bt,y:n.y+a*e*bt}];let c=[];for(let f=1;f<mt;f++){let b=Math.PI*f/mt,m=Math.cos(b),h=Math.sin(b);c.push({x:n.x+e*(u*m+i*h),y:n.y+e*(l*m+a*h)});}return c}function we(n,t,e=nn(n)){let r=n.length;if(r<2)return {right:[],left:[]};let o=s=>{let i=[],a=[],u=(l,c)=>{let f=i[i.length-1],b=a[a.length-1];return (l.x-f.x)*(n[c].x-n[b].x)+(l.y-f.y)*(n[c].y-n[b].y)<=1e-9};for(let l=0;l<r;l++){let c={x:n[l].x+e[l].x*t[l]*s,y:n[l].y+e[l].y*t[l]*s};if(i.length&&u(c,l)){if(l<r-1)continue;for(;i.length>1&&u(c,l);)i.pop(),a.pop();}i.push(c),a.push(l);}return i};return {right:o(1),left:o(-1)}}function nn(n){let t=n.length,e=[],r={x:0,y:-1};for(let o=0;o<t;o++){let s=n[Math.max(0,o-1)],i=n[Math.min(t-1,o+1)],a=B(s,i);a>1e-9&&(r={x:(i.y-s.y)/a,y:-(i.x-s.x)/a}),e.push(r);}return e}function oo(n,t){if(n.length<2)return [];if(!t.length)return [{coords:n.slice(),source:n.map((a,u)=>Math.min(u,n.length-2))}];let e=U(n[0]),r=Sn(n,e),o=[],s=0;for(let[a,u]of Mn(t,0,[0,r.length]))a>s&&o.push([s,a]),s=Math.max(s,u);s<r.length&&o.push([s,r.length]);let i=[];for(let[a,u]of o){if(u-a<.5)continue;let l=yn(r,a),c=yn(r,u),f=[e.toLonLat($(r,a))],b=[l];for(let m=l+1;m<=c;m++)r.cum[m]<=a||r.cum[m]>=u||(f.push(n[m]),b.push(Math.min(m,n.length-2)));f.push(e.toLonLat($(r,u))),b.push(c),i.push({coords:f,source:b});}return i}function ro(n,t){if(n.length<2)return t.map(()=>0);let e=U(n[0]),r=Sn(n,e),o=0;return t.map(s=>{let{s:i}=nt(r,e.toXY(s),o);return o=Math.max(o,i-1),i})}function so(n){let t=U(n[0]??[0,0]);return {frame:t,route:Sn(n,t)}}var tt=8,j=(n,t)=>Math.max(0,t)*tt;function io(n,t){return vn(n.line,n.line.map((e,r)=>t(e,n.levels[r]??0)))}function vn(n,t){let e=Math.min(...t),r=Math.max(...t);return r-e<.05?r>.01?{lift:+r.toFixed(2)}:{}:{liftPath:n.map((o,s)=>`${o[0].toFixed(7)},${o[1].toFixed(7)},${t[s].toFixed(2)}`).join(";")}}var ln=(n,t,e)=>n+(t-n)*e;function Cn(n){let t=[0];for(let e=1;e<n.length;e++)t.push(t[e-1]+gn(n[e-1],n[e]));return {geometry:n,cum:t,length:t[t.length-1]??0}}function wt(n,t){let e=0,r=n.length-2;if(r<0)return 0;for(;e<r;){let o=e+r+1>>1;n[o]<=t?e=o:r=o-1;}return e}function Rt(n,t){let e=n.geometry;if(e.length===1)return e[0];let r=wt(n.cum,t),o=n.cum[r+1]-n.cum[r],s=o>1e-9?Math.max(0,Math.min(1,(t-n.cum[r])/o)):0;return [ln(e[r][0],e[r+1][0],s),ln(e[r][1],e[r+1][1],s)]}function Pe(n,t,e,r=1e-6){let o=Math.max(0,t),s=Math.min(n.length,e);if(n.geometry.length<2||s-o<r)return [];let i=[Rt(n,o)];for(let a=wt(n.cum,o)+1;a<n.geometry.length&&n.cum[a]<s;a++)n.cum[a]>o&&i.push(n.geometry[a]);return i.push(Rt(n,s)),i}var _e=.5;function co(n,t,e){if(n.geometry.length<2||!(e>0))return [];let r=Math.min(e,n.length),o=[],s=0,i=[];for(let[a,u]of Mn(t,0,[0,n.length]))a>s&&i.push([s,a]),s=Math.max(s,u);s<n.length&&i.push([s,n.length]);for(let[a,u]of i){if(u-a<.5||a>=r)continue;let l=Pe(n,a,Math.min(u,r),_e);l.length>=2&&o.push(l);}return o}function On(n,t){let e=n.length;if(e<2||t<=n[0])return 0;if(t>=n[e-1])return e-1;let r=0,o=e-2;for(;r<o;){let i=r+o+1>>1;n[i]<=t?r=i:o=i-1;}let s=n[r+1]-n[r];return r+(s>1e-12?(t-n[r])/s:0)}function G(n,t,e,r){let o=n.length,s=a=>{let u=Math.floor(a),l=a-u;return u>=o-1?n[o-1]:l<1e-12?n[u]:r(n[u],n[u+1],l)},i=[s(t)];for(let a=Math.floor(t)+1;a<e;a++)i.push(n[a]);return i.push(s(e)),i}var fn=(n,t,e)=>ln(n,t,e),Ae=(n,t,e)=>Math.round(ln(n,t,e)),Fn=(n,t,e)=>[ln(n[0],t[0],e),ln(n[1],t[1],e)],Yn=n=>n==="band"?"band-passed":n==="allowed"?"allowed-passed":n,kt=1e-6;function lo(n,t){let e=[];return n.forEach((r,o)=>{let s=r.line.length,i=f=>e.push({feature:f,source:o,from:0,to:s-1}),a=r.stations;if(t===null||!a||a.length!==s||s<2)return i(r);if(r.kind==="chevron"){a[s-1]>t&&i(r);return}if(r.kind!=="band"&&r.kind!=="allowed")return i(r);let u=On(a,t);if(u<=kt)return i(r);if(u>=s-1-kt)return i({...r,kind:Yn(r.kind)});let[l,c]=Ee(r,u);e.push({feature:l,source:o,from:0,to:u},{feature:c,source:o,from:u,to:s-1});}),e}function Ee(n,t){let e=n.line.length,r=n.widths&&n.widths.length===e?n.widths:n.line.map(()=>n.width),o=U(n.line[0]),s=G(n.line,0,t,Fn),i=G(n.line,t,e-1,Fn),a=[...s,...i.slice(1)].map(o.toXY),u=nn(a),l=s.length-1,c=n.caps,f=(b,m,h,d,y,M,w)=>{let P=G(r,h,d,fn);return {kind:b,line:m,width:Math.max(...P),levels:G(n.levels,h,d,Ae),outline:Ln(a.slice(y,M),P.map(_=>_/2),u.slice(y,M),w).map(o.toLonLat),stations:G(n.stations,h,d,fn),widths:P,...w?{caps:w}:{}}};return [f(Yn(n.kind),s,0,t,0,l+1,c&&[c[0],"flat"]),f(n.kind,i,t,e-1,l,a.length,c&&["flat",c[1]])]}function fo(n,t){if(t===null)return {passed:-1,cut:false};let e=0,r=false;for(let o of n){let s=o.stations;!s||s.length<2||(s[s.length-1]<=t?e++:s[0]<t&&(o.kind==="band"||o.kind==="allowed")&&(r=true));}return {passed:e,cut:r}}var Xn=Ie,_t={intersection:Xn.intersection??Xn.default?.intersection,difference:Xn.difference??Xn.default?.difference},Se=18,W=4096,po=1,Tn=2**Se*W;function Rn(n){let t=Math.sin(n[1]*Math.PI/180);return [(n[0]+180)/360*Tn,(.5-Math.log((1+t)/(1-t))/(4*Math.PI))*Tn]}function $n(n){let t=n[0]/Tn*360-180,e=Math.PI-2*Math.PI*n[1]/Tn;return [t,Math.atan(Math.sinh(e))*180/Math.PI]}var Pt=n=>n%2===0?1.2:.6,Nn=n=>n;function At(n){if(!n.length||n[0].length<4)return [];let t=n.map(m=>m.map(Rn)),e=1/0,r=1/0,o=-1/0,s=-1/0;for(let[m,h]of t[0])m<e&&(e=m),m>o&&(o=m),h<r&&(r=h),h>s&&(s=h);let i=Math.floor(e/W),a=Math.floor(o/W),u=Math.floor(r/W),l=Math.floor(s/W),c=(m,h)=>m-h*W>=2;if(i===a&&u===l&&c(e,i)&&c(r,u))return [n];let f=t.map(Nn),b=[];for(let m=i;m<=a;m++)for(let h=u;h<=l;h++){let d=m*W+Pt(m),y=h*W+Pt(h),M=(m+1)*W,w=(h+1)*W;if(M<=e||d>=o||w<=r||y>=s)continue;let P=[Nn([[d,y],[M,y],[M,w],[d,w],[d,y]])];for(let _ of _t.intersection(f,P))b.push(_.map(A=>A.map(C=>$n([C[0],C[1]]))));}return b}function Et(n){return {polys:n.filter(t=>t.length>=4).map(t=>{let e=t.map(Rn),r=e.map(s=>s[0]),o=e.map(s=>s[1]);return {box:[Math.min(...r),Math.min(...o),Math.max(...r),Math.max(...o)],geom:[Nn(e)]}})}}function It(n,t){if(n.length<4||!t.polys.length)return [[n]];let e=n.map(Rn),r=e.map(u=>u[0]),o=e.map(u=>u[1]),s=[Math.min(...r),Math.min(...o),Math.max(...r),Math.max(...o)],i=t.polys.filter(u=>u.box[0]<s[2]&&u.box[2]>s[0]&&u.box[1]<s[3]&&u.box[3]>s[1]);return i.length?_t.difference([Nn(e)],...i.map(u=>u.geom)).map(u=>u.map(l=>l.map(c=>$n([c[0],c[1]])))):[[n]]}var et=40,mn=1e-6;function kn(n,t,e=et){let r=n.line.length,o=n.stations;if(!o||o.length!==r||r<2)return [{kind:n.kind,from:0,to:r-1}];let s=[0];for(let l=Math.ceil(o[0]/e)*e;l<o[r-1];l+=e){let c=On(o,l);c>s[s.length-1]+mn&&c<r-1-mn&&s.push(c);}s.push(r-1);let i=t===null?-1:On(o,t),a=Yn(n.kind),u=[];for(let l=0;l+1<s.length;l++){let c=s[l],f=s[l+1];t===null||i<=c+mn?u.push({kind:n.kind,from:c,to:f}):i>=f-mn?u.push({kind:a,from:c,to:f}):u.push({kind:a,from:c,to:i,cut:true},{kind:n.kind,from:i,to:f,cut:true});}return u}function Bn(n){let t=U(n.line[0]),e=n.line.map(t.toXY),r=n.widths&&n.widths.length===n.line.length?n.widths:n.line.map(()=>n.width);return {frame:t,xy:e,normals:nn(e),widths:r,caps:n.caps??["flat","flat"]}}var St=(n,t,e)=>({x:n.x+(t.x-n.x)*e,y:n.y+(t.y-n.y)*e}),ve=(n,t,e)=>{let r=St(n,t,e),o=Math.hypot(r.x,r.y);return o>1e-12?{x:r.x/o,y:r.y/o}:n};function wn(n,t,e){let r=G(n.xy,t,e,St),o=G(n.normals,t,e,ve),s=G(n.widths,t,e,fn).map(u=>u/2),i=n.xy.length-1,a=[t<=mn?n.caps[0]:"flat",e>=i-mn?n.caps[1]:"flat"];return Ln(r,s,o,a).map(n.frame.toLonLat)}var vt=(n,t,e)=>G(n.line,t,e,Fn);var Kn="ld-roads",Dn="ld-",Ot="roadbed",ko="/tiles/ldroads/index",wo=n=>`/tiles/ldroads/style.json?v=${encodeURIComponent(n)}`,Po=n=>`/tiles/ldroads/roadbed/{z}/{x}/{y}.pbf?v=${encodeURIComponent(n)}`;function Fe(n,t){return t.startsWith("/")&&!t.startsWith("//")?n.url(t):!n.key||!n.owns(t)||/[?&]key=/.test(t)?t:t+(t.includes("?")?"&":"?")+"key="+n.key}var bn=n=>n&&typeof n=="object"&&!Array.isArray(n)?n:null,Yt=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return null}},Xt=n=>typeof n=="number"&&Number.isFinite(n)?String(n):typeof n=="string"?n:null;function _o(n){let t=bn(Yt(n)),e=t?Xt(t.version):null;return !t||e===null?null:{version:e,areas:Array.isArray(t.areas)?t.areas.length:0}}var Ce="ld-mark-",ot=.35;function Oe(n){let t=String(n.id),e={...n,id:t.startsWith(Dn)?t:Dn+t};e.source==null&&(e.source=Kn);let r=n.minzoom,o=bn(n.paint),s=o?.opacity;return String(e.id).startsWith(Ce)&&typeof r=="number"&&r>ot&&(s===void 0||typeof s=="number")&&(e.paint={...o??{},opacity:{stops:[[r-ot,0],[r,s??1]]}},e.minzoom=r-ot),e}function Ao(n,t){let e=bn(Yt(n));if(!e)return null;let r=bn(e.source),o=(Array.isArray(r?.tiles)?r.tiles.find(i=>typeof i=="string"):void 0)??(typeof r?.url=="string"?r.url:void 0),s=(Array.isArray(e.layers)?e.layers:[]).map(bn).filter(i=>i!==null&&typeof i.id=="string"&&i.id!==""&&typeof i.type=="string"&&i.type!=="").map(Oe);return o===void 0||!s.length?null:{version:Xt(e.version)??"",tiles:Fe(t,o),minzoom:typeof r?.minzoom=="number"?r.minzoom:14,maxzoom:typeof r?.maxzoom=="number"?r.maxzoom:16,layers:s}}function Ye(n){return {url:n.tiles,minzoom:n.minzoom,maxzoom:n.maxzoom}}var Xe=new Set(["symbol","fill-extrusion","building","buildings","model"]),Pn=n=>String(n.id).startsWith(Dn);function Te(n){let t=n.filter(i=>!Pn(i)),e=t.findIndex(i=>i.id===Ot);if(e>=0)return e+1;let r=n.findIndex(Pn);if(r>=0)return n.slice(0,r).filter(i=>!Pn(i)).length;let o=-1;if(t.forEach((i,a)=>{i.source===Yd&&(o=a);}),o>=0)return o+1;let s=t.findIndex(i=>Xe.has(String(i.type)));return s>=0?s:t.length}function Ne(n){let t=n,e=t.sources??{};return Yd in e||Kn in e||t.layers.some(Pn)}function Eo(n,t,e=null){if(!Ne(n))return n;let r=n,o=r.sources??{},s=Te(r.layers),i=r.layers.filter(u=>!Pn(u));i.splice(s,0,...t.layers);let a={[Kn]:Ye(t)};return e!==null&&Yd in o&&(a[Yd]={...bn(o[Yd])??{},url:e}),{...n,sources:{...o,...a},layers:i}}function Io(n){return n.layers.filter(t=>t.source===Kn).map(t=>String(t.id))}var Tt="lane-ribbon",it="lane-ribbon-",$e=17.5,zn="#2f6bff",Hn="#8f98a8",Nt=.58,$t=.2,Bt=.62,Gt=.16,So={allowed:{color:zn,opacity:$t,zIndex:16},"allowed-passed":{color:Hn,opacity:Gt,zIndex:16},band:{color:zn,opacity:Nt,zIndex:17},"band-passed":{color:Hn,opacity:Bt,zIndex:17}},vo=100,Ft=bf,Be=bf,Dt="route",Ge={type:"FeatureCollection",features:[]},zt=(n,t)=>({id:`${it}${n}`,source:Tt,"source-layer":"geojson",minzoom:$e,filter:["==","kind",t]}),Gn=(n,t,e)=>({...zt(n,t),type:"surface",overlay:Dt,elevation:Ft,base:Ft,bevel:0,bevelDrop:0,weld:0,groundField:false,paint:{material:"flat",...e}}),De=(n,t,e)=>({...zt(n,t),type:"line",overlay:Dt,depthTest:true,paint:{elevation:Be,material:"flat",...e}});function Ht(){return [Gn("allowed","allowed",{color:zn,opacity:$t}),Gn("band","band",{color:zn,opacity:Nt}),Gn("allowed-passed","allowed-passed",{color:Hn,opacity:Gt}),Gn("band-passed","band-passed",{color:Hn,opacity:Bt}),De("chevron","chevron",{color:"rgba(255,255,255,0)",opacity:1,width:{stops:[[17,3],[18,6],[19,12],[20,24],[21,48],[22,96]]},arrow:true,arrowStyle:"chevron",arrowColor:"rgba(255,255,255,0.95)",arrowPeriod:{stops:[[17,28],[18,40],[19,64],[20,110],[21,200],[22,380]]},arrowSize:{stops:[[17,1.5],[18,3],[19,6],[20,12],[21,24],[22,48]]}})]}var Fo=`${it}chevron`,Co=()=>Ht().map(n=>String(n.id));function Oo(n,t=Ge){let e=n,r={...e.sources??{},[Tt]:{type:"geojson",sourceLayer:"geojson",minzoom:15,buffer:0,data:t}},o=e.layers.filter(i=>!String(i.id).startsWith(it)),s=-1;return o.forEach((i,a)=>{String(i.id).startsWith(Dn)&&(s=a);}),s<0&&(s=o.findIndex(i=>i.id===Ot)),o.splice(s>=0?s+1:o.length,0,...Ht()),{...n,sources:r,layers:o}}var V=111320,tn=32,ze=4096;function Yo(n){let t=new Map,e=0,r=0,o=(u,l)=>{l.length===1&&(l=[l[0],l[0]]);let c=t.get(u)??[];for(let f=1;f<l.length;f++){let[b,m,h]=l[f-1],[d,y,M]=l[f];c.push({ax:b,ay:m,ah:h,bx:d,by:y,bh:M}),e+=m,r++;}t.set(u,c);};for(let u of n){let l=u.properties,c=typeof l.layer=="number"?l.layer:0;if(typeof l.liftPath=="string"){for(let m of l.liftPath.split("|")){let h=m.split(";").map(d=>d.split(",").map(Number)).filter(d=>d.length===3&&d.every(Number.isFinite));h.length&&o(c,h);}continue}let f=typeof l.lift=="number"?l.lift:null;if(f===null)continue;let b=u.geometry;b.type==="LineString"?o(c,b.coordinates.map(([m,h])=>[m,h,f])):b.type==="Polygon"&&o(c,(b.coordinates[0]??[]).map(([m,h])=>[m,h,f]));}if(!r)return j;let s=V*Math.cos(e/r*Math.PI/180),i=22,a=new Map;if(Number.isFinite(s)){let u=i+1;for(let[l,c]of t){let f=new Map,b=false;for(let m of c){let h=Math.min(m.ax,m.bx)*s-u,d=Math.max(m.ax,m.bx)*s+u,y=Math.min(m.ay,m.by)*V-u,M=Math.max(m.ay,m.by)*V+u;if(Number.isFinite(h)&&Number.isFinite(d)&&Number.isFinite(y)&&Number.isFinite(M)){if((d-h)*(M-y)>ze*tn*tn){b=true;break}for(let w=Math.floor(h/tn);w<=Math.floor(d/tn);w++)for(let P=Math.floor(y/tn);P<=Math.floor(M/tn);P++){let _=`${w}:${P}`,A=f.get(_);A?A.push(m):f.set(_,[m]);}}}b||a.set(l,f);}}return (u,l)=>{if(l<0)return 0;let c=t.get(l);if(!c?.length)return j(u,l);let f=a.get(l),b=f?f.get(`${Math.floor(u[0]*s/tn)}:${Math.floor(u[1]*V/tn)}`)??[]:c,m=1/0,h=j(u,l);for(let d of b){let y=(d.ax-u[0])*s,M=(d.ay-u[1])*V,w=(d.bx-u[0])*s,P=(d.by-u[1])*V,_=w-y,A=P-M,C=_*_+A*A,X=C>1e-9?Math.max(0,Math.min(1,-(y*_+M*A)/C)):0,D=Math.hypot(y+_*X,M+A*X);D<m&&(m=D,h=d.ah+(d.bh-d.ah)*X);}return m<=i?h:j(u,l)}}var Xo=bf;function He(n,t=j){let e=n.features.filter(o=>o.outline&&o.stations&&o.stations.length===o.line.length&&o.line.length>=2),r=e.filter(o=>o.kind==="band");return (r.length?r:e).map(o=>({stations:o.stations,heights:o.line.map((s,i)=>t(s,o.levels[i]??0))}))}function Ke(n,t=j){let e=He(n,t);return e.length?r=>Ue(e,r):()=>0}function Ue(n,t){let e=0;for(let r of n){let o=r.stations,s=r.heights,i=Math.min(o.length,s.length);if(i===0||t<o[0]||t>o[i-1])continue;let a=0,u=i-1;for(;u-a>1;){let b=a+u>>1;o[b]<=t?a=b:u=b;}let l=o[u]-o[a],c=l>0?(t-o[a])/l:0,f=s[a]+(s[u]-s[a])*Math.max(0,Math.min(1,c));f>e&&(e=f);}return e}var rt=25,Ct=rt;function To(n,t,e){if(n.length<2)return null;let r=Cn(n),o=n[0][0],s=n[0][1],i=V*Math.cos(s*Math.PI/180),a=n.map(h=>(h[0]-o)*i),u=n.map(h=>(h[1]-s)*V),l=e?Math.max(0,e[0]-Ct):0,c=e?Math.min(r.length,e[1]+Ct):r.length,f=false;for(let h=l;h<=c&&!f;h+=5)t(h)>0&&(f=true);if(!f&&e&&t(c)>0&&(f=true),!f)return null;let b=rt,m=new Map;for(let h=1;h<n.length;h++){if(r.cum[h]<l||r.cum[h-1]>c)continue;let d=Math.floor(Math.min(a[h-1],a[h])/b),y=Math.floor(Math.max(a[h-1],a[h])/b),M=Math.floor(Math.min(u[h-1],u[h])/b),w=Math.floor(Math.max(u[h-1],u[h])/b);for(let P=d;P<=y;P++)for(let _=M;_<=w;_++){let A=`${P}:${_}`,C=m.get(A);C?C.push(h):m.set(A,[h]);}}return (h,d)=>{let y=(h-o)*i,M=(d-s)*V,w=Math.floor(y/b),P=Math.floor(M/b),_=rt,A=-1;for(let C=-1;C<=1;C++)for(let X=-1;X<=1;X++){let D=m.get(`${w+C}:${P+X}`);if(D)for(let T of D){let J=a[T-1],q=u[T-1],N=a[T]-J,v=u[T]-q,Z=N*N+v*v,p=Z>1e-12?Math.max(0,Math.min(1,((y-J)*N+(M-q)*v)/Z)):0,x=Math.hypot(J+N*p-y,q+v*p-M);x<_&&(_=x,A=Math.max(l,Math.min(c,r.cum[T-1]+(r.cum[T]-r.cum[T-1])*p)));}}return A<0?0:t(A)}}var st=class{constructor(t,e=j,r={}){this.ribbon=t;this.heights=e;this.options=r;this.hs=[];this.props=new Map;this.shapes=new Map;this.frames=[];this.masks=[];this.routeLift=null;}setLift(t){this.options={...this.options,lift:t},this.hs=[],this.props.clear();}setHeights(t){this.heights=t,this.routeLift=null,this.hs=[],this.props.clear();}heightsOf(t){let e=this.hs[t];if(!e){let r=this.ribbon.features[t],o=r.stations,s=this.options.lift;if(s)e=r.line.map(i=>s(i[0],i[1]));else if(o&&o.length===r.line.length){let i=this.routeLift??(this.routeLift=Ke(this.ribbon,this.heights));e=o.map(i);}else e=r.line.map((i,a)=>this.heights(i,r.levels[a]??0));this.hs[t]=e;}return e}maskFor(t){let e=this.masks[t];if(!e){let r=i=>i==="band"?0:1,o=this.ribbon.features,s=r(o[t].kind);e=Et(o.filter((i,a)=>i.outline&&a!==t&&(r(i.kind)<s||r(i.kind)===s&&a<t)).map(i=>i.outline)),this.masks[t]=e;}return e}shapesOf(t,e,r){var s;let o=(s=this.frames)[t]??(s[t]=Bn(this.ribbon.features[t]));return It(wn(o,e,r),this.maskFor(t)).flatMap(At)}at(t){let e=[],r=(o,s)=>e.push({type:"Feature",id:e.length+1,geometry:o,properties:s});return this.ribbon.features.forEach((o,s)=>{let i=Math.max(...o.levels);if(!o.outline){let a=o.stations;if(t!==null&&a&&a.length>=2&&a[a.length-1]<=t)return;let u=this.props.get(`${s}`);u||this.props.set(`${s}`,u=vn(o.line,this.heightsOf(s))),r({type:"LineString",coordinates:o.line},{kind:o.kind,width:+o.width.toFixed(2),layer:i,...u});return}if(this.options.areas!==false)for(let a of kn(o,t)){let u=`${s}:${a.kind}:${a.from}:${a.to}`,l=a.cut?void 0:this.shapes.get(u);l||(l=this.shapesOf(s,a.from,a.to),a.cut||this.shapes.set(u,l));let c=a.cut?void 0:this.props.get(u);c||(c=vn(vt(o,a.from,a.to),G(this.heightsOf(s),a.from,a.to,fn)),a.cut||this.props.set(u,c));for(let f of l)r({type:"Polygon",coordinates:f},{kind:a.kind,width:+o.width.toFixed(2),layer:i,...c});}}),{type:"FeatureCollection",features:e}}};function No(n,t=j){return new st(n,t).at(null)}var hn=Ie,on={union:hn.union??hn.default?.union,intersection:hn.intersection??hn.default?.intersection,difference:hn.difference??hn.default?.difference},Kt=n=>{let t=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of n)for(let[i,a]of s[0]??[])i<t&&(t=i),i>r&&(r=i),a<e&&(e=a),a>o&&(o=a);return [t,e,r,o]},Ut=100,je=(n,t,e)=>!!e&&!!n.metres&&(n.tier[1]<t[0]||t[1]<n.tier[0])&&(n.metres[0]>e[1]+Ut||e[0]>n.metres[1]+Ut),Ve=(n,t)=>n[0]<=t[2]&&t[0]<=n[2]&&n[1]<=t[3]&&t[1]<=n[3],Wt=n=>n.map(Rn),jt=n=>n.map(t=>t.map(e=>e.map(r=>$n([r[0],r[1]])))),ut=20,ct=5,Je=n=>n==="band"||n==="band-passed"?"band":"allowed",at=n=>n==="band"?"band-passed":"allowed-passed",Vt=class{constructor(t,e=et){this.ribbon=t;this.chunkM=e;this.groups=[];this.frames=[];this.built=false;this.featherCache=new Map;this.spans=null;}frame(t){var e;return (e=this.frames)[t]??(e[t]=Bn(this.ribbon.features[t]))}build(){this.built=true;let t=new Map;this.ribbon.features.forEach((o,s)=>{if(!o.outline||o.line.length<2)return;let i=Je(o.kind);for(let a of kn(o,null,this.chunkM)){let u=o.stations,l=u&&u.length===o.line.length?u[Math.floor(a.from)]+(u[Math.min(Math.floor(a.from)+1,u.length-1)]-u[Math.floor(a.from)])*(a.from-Math.floor(a.from)):0,c=Math.floor((l+1e-6)/this.chunkM),f=`${i}:${c}`,b=t.get(f);b||t.set(f,b={cat:i,chunk:c,pieces:[]}),b.pieces.push({i:s,from:a.from,to:a.to});}});let e=[...t.values()].sort((o,s)=>o.cat===s.cat?o.chunk-s.chunk:o.cat==="band"?-1:1),r=[];for(let o of e){let s=o.pieces.map(b=>[Wt(wn(this.frame(b.i),b.from,b.to))]),i=s.length>1?on.union(s[0],...s.slice(1)):on.union(s[0]);if(!i.length)continue;let a=this.tierOf(o.pieces),u=this.metresOf(o.pieces),l=Kt(i),c=r.filter(b=>Ve(b.box,l)&&!je(b,a,u));if(c.length&&(i=on.difference(i,...c.map(b=>b.geom))),!i.length)continue;let f={cat:o.cat,chunk:o.chunk,geom:i,box:Kt(i),pieces:o.pieces,tier:a,metres:u};this.groups.push(f),r.push(f);}}tierOf(t){let e=1/0,r=-1/0;for(let o of t){let s=this.ribbon.features[o.i].levels,i=Math.min(Math.ceil(o.to),this.ribbon.features[o.i].line.length-1);for(let a=Math.max(0,Math.floor(o.from));a<=i;a++){let u=s[a]??0;u<e&&(e=u),u>r&&(r=u);}}return e<=r?[e,r]:[0,0]}metresOf(t){let e=1/0,r=-1/0;for(let o of t){let s=this.ribbon.features[o.i].stations;if(!s||!s.length)return null;let i=a=>{let u=Math.min(Math.floor(a),s.length-1);return s[u]+((s[Math.min(u+1,s.length-1)]??s[u])-s[u])*(a-u)};e=Math.min(e,i(o.from)),r=Math.max(r,i(o.to));}return e<=r?[e,r]:null}inside(t,e){for(let r of this.groups)if(!(t<r.box[0]||t>r.box[2]||e<r.box[1]||e>r.box[3]))for(let o of r.geom){if(!qt(t,e,o[0]))continue;let s=false;for(let i=1;i<o.length&&!s;i++)s=qt(t,e,o[i]);if(!s)return true}return false}featherOf(t){return t.map(e=>{let r=e,o=r.length-1,s=[];for(let i=0;i<o;i++){let[a,u]=r[i],[l,c]=r[i+1],f=Math.hypot(l-a,c-u);if(f<1e-9){s.push(false);continue}let b=(a+l)/2,m=(u+c)/2,h=-(c-u)/f*Jt,d=(l-a)/f*Jt;s.push(this.inside(b+h,m+d)!==this.inside(b-h,m-d));}return s})}spanOf(t){return this.spans||(this.spans=this.groups.map(e=>{if(e.pieces.every(o=>!this.ribbon.features[o.i].stations))return null;let r=(o,s)=>{let i=this.ribbon.features[o.i].stations;if(!i||!i.length)return 0;let a=Math.min(Math.floor(s),i.length-1);return i[a]+((i[Math.min(a+1,i.length-1)]??i[a])-i[a])*(s-a)};return {lo:Math.min(...e.pieces.map(o=>r(o,o.from))),hi:Math.max(...e.pieces.map(o=>r(o,o.to)))}})),this.spans[t]}passMode(t,e,r){let o=this.spanOf(t);return e===null||!o?"b":o.hi<=e-r-ct?"g":o.lo>=e+ct?"b":"x"}passKey(t,e=ut){this.built||this.build();let r="";for(let o=0;o<this.groups.length;o++)r+=this.passMode(o,t,e);return r}passAt(t,e=ut){this.built||this.build();let r=[],o=(s,i,a,u,l)=>{let c=jt(a),f=this.spanOf(u),b=f?[f.lo,f.hi]:null;a.forEach((m,h)=>{let d=`${i}:${h}`,y=this.featherCache.get(d);y||this.featherCache.set(d,y=this.featherOf(m)),r.push({key:d,kind:s,polygon:c[h].map(M=>M.slice(0,-1)),feather:y,group:u,dir:l,span:b});});};return this.groups.forEach((s,i)=>{let a=`${s.cat}:${s.chunk}`,u=this.passMode(i,t,e),l=this.spanOf(i)!==null;u!=="g"&&o(s.cat,`${a}:whole`,s.geom,i,l?1:0),u!=="b"&&o(at(s.cat),`${a}:passed`,s.geom,i,-1);}),r}stationsFor(t,e){this.built||this.build();let r=this.groups[t];if(!r||!this.spanOf(t))return null;let o=[];for(let s of r.pieces){let i=this.ribbon.features[s.i],a=i.stations;if(!a||a.length!==i.line.length||a.length<2)continue;let u=this.frame(s.i),l=Math.max(0,Math.floor(s.from)),c=Math.min(a.length-1,Math.ceil(s.to));c>l&&o.push({xy:u.xy,st:a,frame:u.frame,k0:l,k1:c});}return o.length?e.map(s=>s.map(i=>{let a=1/0,u=0;for(let l of o){let c=l.frame.toXY(i);for(let f=l.k0;f<l.k1;f++){let b=l.xy[f],m=l.xy[f+1],h=m.x-b.x,d=m.y-b.y,y=h*h+d*d,M=y>1e-12?((c.x-b.x)*h+(c.y-b.y)*d)/y:0;M=M<0?0:M>1?1:M;let w=c.x-(b.x+h*M),P=c.y-(b.y+d*M),_=w*w+P*P;_<a&&(a=_,u=l.st[f]+(l.st[f+1]-l.st[f])*M);}}return u})):null}at(t){this.built||this.build();let e=[],r=(o,s,i)=>{let a=jt(i);i.forEach((u,l)=>{let c=`${s}:${l}`,f=this.featherCache.get(c);f||(f=this.featherOf(u),s.includes(":cut-")||this.featherCache.set(c,f)),e.push({key:c,kind:o,polygon:a[l].map(b=>b.slice(0,-1)),feather:f});});};for(let o of this.groups){let s=o.pieces.map(c=>this.ribbon.features[c.i]),i=(c,f)=>{let b=this.ribbon.features[c.i].stations;if(!b||!b.length)return 0;let m=Math.min(Math.floor(f),b.length-1);return b[m]+((b[Math.min(m+1,b.length-1)]??b[m])-b[m])*(f-m)},a=Math.min(...o.pieces.map(c=>i(c,c.from))),u=Math.max(...o.pieces.map(c=>i(c,c.to))),l=`${o.cat}:${o.chunk}`;if(t===null||t<=a||s.every(c=>!c.stations))r(o.cat,`${l}:whole`,o.geom);else if(t>=u)r(at(o.cat),`${l}:passed`,o.geom);else {let c=[];for(let h of o.pieces){let d=this.ribbon.features[h.i];for(let y of kn(d,t,this.chunkM)){if(y.kind===d.kind||y.to<=h.from+1e-9||y.from>=h.to-1e-9)continue;let M=Math.max(y.from,h.from),w=Math.min(y.to,h.to);w-M>1e-6&&c.push([Wt(wn(this.frame(h.i),M,w))]);}}if(!c.length){r(o.cat,`${l}:whole`,o.geom);continue}let f=c.length>1?on.union(c[0],...c.slice(1)):on.union(c[0]),b=on.intersection(o.geom,f),m=on.difference(o.geom,f);r(at(o.cat),`${l}:cut-passed:${t}`,b),r(o.cat,`${l}:cut-rest:${t}`,m);}}return e}},Jt=5;function qt(n,t,e){let r=e,o=false;for(let s=0,i=r.length-1;s<r.length;i=s++){let[a,u]=r[s],[l,c]=r[i];u>t!=c>t&&n<(l-a)*(t-u)/(c-u)+a&&(o=!o);}return o}var zo={COLOR:"rgba(255,255,255,0)",ARROW_COLOR:"rgba(255,255,255,0.95)",WIDTH_M:2.75,PERIOD_M:18.3,SIZE_M:1.37,Z:18};function Ho(n,t,e=ut){let r=[];return n.features.forEach((o,s)=>{if(o.outline||o.kind!=="chevron"||o.line.length<2)return;let i=o.stations,a=i&&i.length>=2?[i[0],i[i.length-1]]:null;t!==null&&a&&a[1]<=t-e-ct||r.push({key:`chevron:${s}`,line:o.line,stations:a});}),r}function Ko(n,t){let e=n.stations,r=n.line;if(!e||r.length<2||!t.length)return null;let o=U(r[0]),s=o.toXY(t[0]),i=0,a=1/0,u=0;for(let l=0;l+1<r.length;l++){let c=o.toXY(r[l]),f=o.toXY(r[l+1]),b=gn(r[l],r[l+1]),m=f.x-c.x,h=f.y-c.y,d=m*m+h*h,y=d>1e-12?((s.x-c.x)*m+(s.y-c.y)*h)/d:0;y=y<0?0:y>1?1:y;let M=s.x-(c.x+m*y),w=s.y-(c.y+h*y),P=M*M+w*w;P<a&&(a=P,u=i+b*y),i+=b;}return i>1e-9?e[0]+(e[1]-e[0])*u/i:e[0]}function Uo(n,t){let e=[];return n.features.forEach((r,o)=>{if(r.outline||r.kind!=="chevron"||r.line.length<2)return;let s=r.stations;t!==null&&s&&s.length>=2&&s[s.length-1]<=t||e.push({key:`chevron:${o}`,line:r.line});}),e}var pn=5e-5;function Wo(n,t){let e=[],r=new Map;for(let o of n){let s=o.lonlat,i=o.z,a=o.normals,u=o.indices;for(let l=0;l+2<u.length;l+=3){let c=u[l],f=u[l+1],b=u[l+2];if(a[3*c+2]<.5||a[3*f+2]<.5||a[3*b+2]<.5)continue;let m={ax:s[2*c],ay:s[2*c+1],az:i[c],bx:s[2*f],by:s[2*f+1],bz:i[f],cx:s[2*b],cy:s[2*b+1],cz:i[b]},h=e.push(m)-1,d=Math.floor(Math.min(m.ax,m.bx,m.cx)/pn),y=Math.floor(Math.max(m.ax,m.bx,m.cx)/pn),M=Math.floor(Math.min(m.ay,m.by,m.cy)/pn),w=Math.floor(Math.max(m.ay,m.by,m.cy)/pn);for(let P=d;P<=y;P++)for(let _=M;_<=w;_++){let A=`${P}:${_}`,C=r.get(A);C?C.push(h):r.set(A,[h]);}}}return (o,s,i)=>{let a=r.get(`${Math.floor(o/pn)}:${Math.floor(s/pn)}`),u=null;if(a)for(let l of a){let c=e[l],f=(c.by-c.cy)*(c.ax-c.cx)+(c.cx-c.bx)*(c.ay-c.cy);if(Math.abs(f)<1e-20)continue;let b=((c.by-c.cy)*(o-c.cx)+(c.cx-c.bx)*(s-c.cy))/f,m=((c.cy-c.ay)*(o-c.cx)+(c.ax-c.cx)*(s-c.cy))/f,h=1-b-m;if(b<-1e-9||m<-1e-9||h<-1e-9)continue;let d=b*c.az+m*c.bz+h*c.cz;(u===null||(i!==void 0?Math.abs(d-i)<Math.abs(u-i):d>u))&&(u=d);}if(u!==null)return u;for(let l of t)if(o>=l[0]&&o<=l[2]&&s>=l[1]&&s<=l[3])return null}}var Zt=tt/2;function jo(n,t){return !n&&!t?null:(e,r)=>{let o=t?t(e,r):0,s=n?n(e,r,o):void 0;return s===void 0?o:s===null?0:Math.abs(s-o)>Zt?o:s>0?s:0}}var Un=2,qe=.5;function Vo(n,t,e){if(!e||n.length<2)return t;let r=Cn(n),o=Math.max(1,Math.ceil(r.length/Un)),s=new Float64Array(o+1),i=0,a=false,u=1;for(let l=0;l<=o;l++){let c=Math.min(r.length,l*Un);for(;u<n.length-1&&r.cum[u]<c;)u++;let f=n[u-1],b=n[u],m=r.cum[u]-r.cum[u-1],h=m>0?Math.max(0,Math.min(1,(c-r.cum[u-1])/m)):0,d=t(c),y=e(f[0]+(b[0]-f[0])*h,f[1]+(b[1]-f[1])*h,a?i:d);if(typeof y=="number"){let M=y>0?y:0;a&&Math.abs(M-i)<=Un*qe+.5?i=M:Math.abs(M-d)<=Zt?(i=M,a=true):a||(i=d);}else i=d,a=false;s[l]=i;}return l=>{if(!(l>0))return s[0];let c=l/Un,f=Math.floor(c);return f>=o?s[o]:s[f]+(s[f+1]-s[f])*(c-f)}}
2
+ export{ro as $,Ht as $a,Mn as A,It as Aa,ae as B,et as Ba,ht as C,kn as Ca,ue as D,Bn as Da,eo as E,wn as Ea,qn as F,vt as Fa,ce as G,Kn as Ga,fe as H,Dn as Ha,me as I,Ot as Ia,be as J,ko as Ja,he as K,wo as Ka,Zn as L,Po as La,Qn as M,Fe as Ma,pe as N,_o as Na,de as O,Ce as Oa,xe as P,ot as Pa,ye as Q,Ao as Qa,Me as R,Ye as Ra,ge as S,Te as Sa,Le as T,Ne as Ta,Re as U,Eo as Ua,Lt as V,Io as Va,Ln as W,Tt as Wa,dt as X,$e as Xa,we as Y,So as Ya,nn as Z,vo as Za,oo as _,Ge as _a,U as a,so as aa,Fo as ab,cn as b,tt as ba,Co as bb,In as c,j as ca,Oo as cb,gn as d,io as da,Yo as db,Sn as e,vn as ea,Xo as eb,$ as f,Cn as fa,He as fb,An as g,Rt as ga,Ke as gb,Ze as h,Pe as ha,rt as hb,nt as i,_e as ia,Ct as ib,Qt as j,co as ja,To as jb,Qe as k,On as ka,st as kb,no as l,G as la,No as lb,ne as m,fn as ma,Ut as mb,ee as n,Ae as na,ut as nb,ft as o,Fn as oa,ct as ob,oe as p,Yn as pa,Vt as pb,yt as q,lo as qa,zo as qb,Jn as r,fo as ra,Ho as rb,En as s,Se as sa,Ko as sb,Mt as t,W as ta,Uo as tb,re as u,po as ua,Wo as ub,se as v,Rn as va,Zt as vb,ie as w,$n as wa,jo as wb,to as x,Pt as xa,Un as xb,mt as y,At as ya,Vo as yb,bt as z,Et as za};//# sourceMappingURL=chunk-RJYVR2JE.js.map
3
+ //# sourceMappingURL=chunk-RJYVR2JE.js.map