glyphcss 0.0.5 → 0.0.6

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/dist/elements.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var ht=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var tn=(n,e)=>{for(var t in e)ht(n,t,{get:e[t],enumerable:!0})},nn=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Qt(e))!en.call(n,r)&&r!==t&&ht(n,r,{get:()=>e[r],enumerable:!(o=Jt(e,r))||o.enumerable});return n};var rn=n=>nn(ht({},"__esModule",{value:!0}),n);var Xn={};tn(Xn,{GlyphHotspotElement:()=>We,GlyphMapControlsElement:()=>Ue,GlyphMeshElement:()=>$e,GlyphOrbitControlsElement:()=>qe,GlyphOrthographicCameraElement:()=>Ne,GlyphPerspectiveCameraElement:()=>je,GlyphSceneElement:()=>Xe});module.exports=rn(Xn);var Bt=require("@glyphcss/core");var Gt=Math.PI/180,Lt=.01,on=32e3,sn=Lt*1.01;function ft(n,e,t){let o=n[1],r=n[0],s=n[2],l=t*Gt,i=Math.cos(l),c=Math.sin(l),u=o*i-r*c,p=o*c+r*i,d=s,m=e*Gt,h=Math.cos(m),f=Math.sin(m),b=p*h-d*f,C=p*f+d*h;return[u,b,C]}function Ie(n={}){let e={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??on,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[t,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return e.rotX},set rotX(r){e.rotX=r},get rotY(){return e.rotY},set rotY(r){e.rotY=r},get distance(){return e.distance},set distance(r){e.distance=r},get perspective(){return e.perspective},set perspective(r){e.perspective=r},get zoom(){return e.zoom},set zoom(r){e.zoom=r},get stretch(){return e.stretch},set stretch(r){e.stretch=r},get fovScale(){return e.fovScale},set fovScale(r){e.fovScale=r},get target(){return e.target},set target(r){e.target=r},get eyeMode(){return e.eyeMode},set eyeMode(r){e.eyeMode=r},eyeDepth(r){let s=ft([r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],e.rotX,e.rotY),l=.001*1.01;if(e.eyeMode)return-s[2]-l;if(e.perspective>0){let i=s[2]*e.zoom*50-e.distance;return e.perspective-i-e.perspective*sn}return e.distance-s[2]-l},project(r,s,l,i){let u=50/i,p=[r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],d=ft(p,e.rotX,e.rotY);if(e.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let y=e.focal/-d[2],w=d[0]*y*e.zoom*50,P=d[1]*y*e.zoom*50,H=s*t+w/u*e.stretch,v=l*o+P/50;return[H,v,d[2],-1/d[2]]}if(e.perspective>0){let x=e.perspective,y=d[0]*e.zoom*50,w=d[1]*e.zoom*50,P=d[2]*e.zoom*50-e.distance,H=x-P,v=x*Lt;if(H<v)return[NaN,NaN,P,NaN];let A=x/H,L=s*t+y*A/u*e.stretch*e.fovScale,a=l*o+w*A/50*e.fovScale;return[L,a,P,1/H]}let m=.001,h=e.distance-d[2];if(h<m)return[NaN,NaN,d[2],NaN];let f=e.distance/h,b=d[0]*f*e.zoom*50,C=d[1]*f*e.zoom*50,_=s*t+b/u*e.stretch*e.fovScale,M=l*o+C/50*e.fovScale;return[_,M,d[2],1/h]}}}function Tt(n={}){let e={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[t,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return e.rotX},set rotX(r){e.rotX=r},get rotY(){return e.rotY},set rotY(r){e.rotY=r},get distance(){return e.distance},set distance(r){e.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return e.zoom},set zoom(r){e.zoom=r},get stretch(){return e.stretch},set stretch(r){e.stretch=r},get fovScale(){return e.fovScale},set fovScale(r){e.fovScale=r},get target(){return e.target},set target(r){e.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,s,l,i){let u=50/i,p=[r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],d=ft(p,e.rotX,e.rotY),m=d[0]*e.zoom*50,h=d[1]*e.zoom*50,f=s*t+m/u*e.fovScale,b=l*o+h/50*e.fovScale;return[f,b,d[2]]}}}var ln={direction:[-.5,-.7,-.5],intensity:1},an={intensity:.4};function cn(n){let e=new Set,t=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let l=r[s],i=r[(s+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${i[0]},${i[1]},${i[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(e.has(p))continue;e.add(p);let d={from:l,to:i,weight:2};o.color&&(d.color=o.color),t.push(d)}}return t}function _t(n){let e=n.polygons??[],t=n.mode??(e.length?"solid":"wireframe"),o=n.wireframe??(t==="wireframe"?cn(e):[]);return{camera:n.camera,grid:n.grid,polygons:e,wireframe:o,mode:t,directionalLight:n.directionalLight??ln,ambientLight:n.ambientLight??an,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var qn=" .:-=+*#%@".split(""),Un=" .:-=+*#%@".split(""),gt={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Kn=gt.default;function yt(n){return gt[n]??gt.default}function Ht(n){let{camera:e,grid:t,wireframe:o,mode:r}=n,{cols:s,rows:l,cellAspect:i}=t;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return un(n,s,l,i,d)}let c=yt(n.glyphPalette),u=new Uint8Array(s*l),p=n.useColors?new Array(s*l).fill(null):null;for(let d of o){let m=e.project(d.from,s,l,i),h=e.project(d.to,s,l,i);m[0]!==m[0]||h[0]!==h[0]||bn(u,p,m[0]|0,m[1]|0,h[0]|0,h[1]|0,d.weight??2,d.color??null,s,l)}return vn(u,p,s,l,c)}function un(n,e,t,o,r){let s=e*r,l=t*r,{camera:i,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:m,doubleSided:h,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,_=n.depthEpsilon??0,M=r>1?{zoom:i.zoom,eyeDepth:B=>i.eyeDepth(B),project:(B,V,X,Y)=>{let S=i.project(B,V,X,Y);return[V*.5+(S[0]-V*.5)*r,X*.5+(S[1]-X*.5)*r,S[2],S[3]]}}:i,x=yt(n.glyphPalette).solid,y=x.length-1,w=new Array(s*l).fill(" "),P=n.useColors,H=P?new Array(s*l).fill(null):null,v=new Float64Array(s*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(s*l*3).fill(NaN):null,a=u.direction,E=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/E,G=a[1]/E,z=a[2]/E,F=u.intensity??1,T=p.intensity??.4,W=ze(u.color??"#ffffff"),R=ze(p.color??"#ffffff"),j=d&&m>0?gn(c,m):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?fn(c,f,g,G,z):null,oe=k?.opacity??.25,K=k?.lift??.05,Z=k?.color??"#000000",ie=q?ze(Z):[0,0,0],O=globalThis.__glyphPerfDetail,Ke=O?performance.now():0,ge=[],J=n.shadeCache??null,Q=-1,ve=(B,V,X,Y)=>{if(q===null||!Y)return null;let S=q,I=Oe(B,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Oe(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Oe(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:I[0],lvA:I[1],ldA:I[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:N}};for(let B=0;B<c.length;B++){let V=c[B],X=V.vertices;if(X.length<3)continue;let Y=V.uvs,S=null;if(re!==null&&Y&&Y.length>=X.length){let I=(0,nt.polygonTexture)(V);I&&(S=re.get(I)??null)}for(let I=0;I<X.length;I++)ge[I]=M.project(X[I],s,l,o);for(let I=1;I<X.length-1;I++){Q++;let ee=0,de=I,Ee=I+1,se=X[ee],pe=X[de],we=X[Ee],ae=ge[ee],ye=ge[de],xe=ge[Ee],it=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(xe[0]!==xe[0]?1:0);if(it===3||it===0&&!h&&(ye[0]-ae[0])*(xe[1]-ae[1])-(ye[1]-ae[1])*(xe[0]-ae[0])>0)continue;let Ge,Le,Te,ke=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],ke=J.lit[Q];else{let $=pe[0]-se[0],me=pe[1]-se[1],Ae=pe[2]-se[2],he=we[0]-se[0],Je=we[1]-se[1],Qe=we[2]-se[2],et=me*Qe-Ae*Je,Ye=Ae*he-$*Qe,U=$*Je-me*he,D=Math.hypot(et,Ye,U)||1,te=et/D,fe=Ye/D,le=U/D,ce,_e,st,lt,at,ct,ut,dt,pt;if(j){let De=j[B],Me=De[ee],Fe=De[de],Ve=De[Ee];ce=Me[0],_e=Me[1],st=Me[2],lt=Fe[0],at=Fe[1],ct=Fe[2],ut=Ve[0],dt=Ve[1],pt=Ve[2]}else ce=lt=ut=te,_e=at=dt=fe,st=ct=pt=le;let St=ce*g+_e*G+st*z,xt=lt*g+at*G+ct*z,Mt=ut*g+dt*G+pt*z,Vt=h?Math.abs(St):Math.max(0,-St),Xt=h?Math.abs(xt):Math.max(0,-xt),$t=h?Math.abs(Mt):Math.max(0,-Mt);if(Ge=Math.min(1,T+Vt*F),Le=Math.min(1,T+Xt*F),Te=Math.min(1,T+$t*F),P){let De=(Ge+Le+Te)/3,Me=Math.max(0,De-T),Fe=V.color??"#ffffff",Ve=Me*255|0,Ct=`${Fe}:${Ve}`,tt=N.get(Ct);if(tt===void 0){let mt=ze(Fe),Wt=T*R[0]/255+Me*W[0]/255,jt=T*R[1]/255+Me*W[1]/255,qt=T*R[2]/255+Me*W[2]/255,Ut=Math.min(255,mt[0]*Wt),Kt=Math.min(255,mt[1]*jt),Zt=Math.min(255,mt[2]*qt);tt=`#${ne(Ut)}${ne(Kt)}${ne(Zt)}`,N.set(Ct,tt)}ke=tt}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=ke)}let wt=b[B]??!1,He=1+(C?.[B]??0),At=null;if(S!==null&&Y){let $=Y[ee],me=Y[de],Ae=Y[Ee],he=Math.max(0,(Ge+Le+Te)/3-T);At={sampler:S,ua:$[0],va:$[1],ub:me[0],vb:me[1],uc:Ae[0],vc:Ae[1],tintR:T*R[0]/255+he*W[0]/255,tintG:T*R[1]/255+he*W[1]/255,tintB:T*R[2]/255+he*W[2]/255}}if(it===0)zt(ae[0],ae[1],(ae[3]??ae[2])*He,Ge,ye[0],ye[1],(ye[3]??ye[2])*He,Le,xe[0],xe[1],(xe[3]??xe[2])*He,Te,x,y,ke,w,H,v,s,l,ve(se,pe,we,wt),h,se,pe,we,L,_,At);else{let $=[],me=[],Ae=[se,pe,we],he=[Ge,Le,Te],Je=M.eyeDepth(se),Qe=M.eyeDepth(pe),et=M.eyeDepth(we),Ye=[Je,Qe,et];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ye[U],fe=Ye[D];if(te>0&&($.push(Ae[U]),me.push(he[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[D];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),me.push(he[U]+le*(he[D]-he[U]))}}if($.length>=3){let U=$.map(D=>M.project(D,s,l,o));for(let D=1;D<$.length-1;D++){let te=U[0],fe=U[D],le=U[D+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!h&&ce>0||zt(te[0],te[1],(te[3]??te[2])*He,me[0],fe[0],fe[1],(fe[3]??fe[2])*He,me[D],le[0],le[1],(le[3]??le[2])*He,me[D+1],x,y,ke,w,H,v,s,l,ve($[0],$[D],$[D+1],wt),h,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Ke);let Et=O?performance.now():0,Pe=w,Se=H,Ze=L;if(r>1){let B=pn(w,H,v,L,e,t,r,x);Pe=B.glyphBuf,Se=B.colorBuf,Ze=B.worldPos}A&&dn(Pe,Se,Ze,e,t,o,x,n.temporalBlend,n.temporalHistory,i);let ot=yn(Pe,Se,e,t);return O&&(O.string??(O.string=[])).push(performance.now()-Et),ot}function dn(n,e,t,o,r,s,l,i,c,u){let p=o*r,d=l.length-1,m=new Map;for(let x=0;x<l.length;x++)m.set(l[x],x);let h=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),h=null);let f=null;if(h){let x=Ie({rotX:h.rotX,rotY:h.rotY,distance:h.distance,perspective:h.perspective,zoom:h.zoom,stretch:h.stretch});x.target=h.target,f=y=>x.project(y,o,r,s)}let b=new Float32Array(p),C=new Float32Array(p),_=new Float32Array(p),M=new Float32Array(p);for(let x=0;x<r;x++)for(let y=0;y<o;y++){let w=x*o+y,P=m.get(n[w])??0,H=0,v=0,A=0,L=e?e[w]:null;if(L){let k=ze(L);H=k[0],v=k[1],A=k[2]}let a=0,E=0,g=0,G=0,z=0,F=t[w*3];if(f&&F===F){let k=f([F,t[w*3+1],t[w*3+2]]),q=Math.round(k[0]),oe=Math.round(k[1]);if(k[0]===k[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;E=c.idx[K],g=c.r[K],G=c.g[K],z=c.b[K],a=i}}let T=1-a,W=T*P+a*E,R=T*H+a*g,j=T*v+a*G,N=T*A+a*z;b[w]=W,C[w]=R,_[w]=j,M[w]=N;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[w]=l[re],e&&(e[w]=re===0?null:`#${ne(R)}${ne(j)}${ne(N)}`)}c.idx=b,c.r=C,c.g=_,c.b=M,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function pn(n,e,t,o,r,s,l,i){let c=new Map;for(let b=0;b<i.length;b++)c.set(i[b],b);let u=i.length-1,p=r*l,d=new Array(r*s).fill(" "),m=e?new Array(r*s).fill(null):null,h=o?new Float32Array(r*s*3).fill(NaN):null,f=1/(l*l);for(let b=0;b<s;b++)for(let C=0;C<r;C++){let _=0,M=0,x=0,y=0,w=0,P=0,H=0,v=0;for(let a=0;a<l;a++){let E=(b*l+a)*p+C*l;for(let g=0;g<l;g++){let G=E+g;if(t[G]!==-1/0){if(_+=c.get(n[G])??0,M++,m){let z=e[G];if(z){let F=ze(z);x+=F[0],y+=F[1],w+=F[2]}}h&&(P+=o[G*3],H+=o[G*3+1],v+=o[G*3+2])}}}let A=b*r+C;if(M===0)continue;let L=Math.round(_*f);L<0?L=0:L>u&&(L=u),d[A]=i[L],m&&(m[A]=`#${ne(x/M)}${ne(y/M)}${ne(w/M)}`),h&&(h[A*3]=P/M,h[A*3+1]=H/M,h[A*3+2]=v/M)}return{glyphBuf:d,colorBuf:m,worldPos:h}}var mn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Oe(n,e,t,o,r,s,l,i,c,u,p,d,m,h){let f=e*n[0]+t*n[1]+o*n[2],b=r*n[0]+s*n[1]+l*n[2],C=-(i*n[0]+c*n[1]+u*n[2]),_=(f-p)/(d-p)*(be-1),M=(b-m)/(h-m)*(be-1);return[_,M,C]}function hn(n,e,t,o){let r=e[0],s=e[1],l=e[2],i=t[0],c=t[1],u=t[2],p=o[0],d=o[1],m=o[2],h=(i-r)*(d-s)-(c-s)*(p-r);if(h===0)return;let f=1/h,b=r<i?r:i;p<b&&(b=p);let C=r>i?r:i;p>C&&(C=p);let _=s<c?s:c;d<_&&(_=d);let M=s>c?s:c;d>M&&(M=d);let x=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),w=Math.max(0,Math.ceil(_)),P=Math.min(be-1,Math.floor(M));if(x>y||w>P)return;let H=h>0;for(let v=w;v<=P;v++)for(let A=x;A<=y;A++){let L=A,a=v,E=(i-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(s-a)-(d-a)*(r-L),G=(r-L)*(c-a)-(s-a)*(i-L);if(H?E<0||g<0||G<0:E>0||g>0||G>0)continue;let z=(E*l+g*u+G*m)*f,F=v*be+A;z>n[F]&&(n[F]=z)}}function fn(n,e,t,o,r){let s,l,i;Math.abs(t)<.9?(s=0,l=r,i=-o):(s=-r,l=0,i=t);let c=Math.hypot(s,l,i);s/=c,l/=c,i/=c;let u=l*r-i*o,p=i*t-s*r,d=s*o-l*t,m=1/0,h=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(e[y]){C=!0;for(let w of n[y].vertices){let P=s*w[0]+l*w[1]+i*w[2],H=u*w[0]+p*w[1]+d*w[2];P<m&&(m=P),P>h&&(h=P),H<f&&(f=H),H>b&&(b=H)}}if(!C)return null;let _=(h-m)*.05+.01,M=(b-f)*.05+.01;m-=_,h+=_,f-=M,b+=M;let x=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!e[y])continue;let w=n[y].vertices;if(!(w.length<3))for(let P=1;P<w.length-1;P++){let H=w[0],v=w[P],A=w[P+1],L=Oe(H,s,l,i,u,p,d,t,o,r,m,h,f,b),a=Oe(v,s,l,i,u,p,d,t,o,r,m,h,f,b),E=Oe(A,s,l,i,u,p,d,t,o,r,m,h,f,b);hn(x,L,a,E)}}return{buf:x,right:[s,l,i],up:[u,p,d],dir:[t,o,r],uMin:m,uMax:h,vMin:f,vMax:b}}function zt(n,e,t,o,r,s,l,i,c,u,p,d,m,h,f,b,C,_,M,x,y,w,P,H,v,A,L,a){let E=(r-n)*(u-e)-(s-e)*(c-n);if(E===0||!w&&E>0)return;let g=1/E,G=E>0,z=n<r?n:r;c<z&&(z=c);let F=n>r?n:r;c>F&&(F=c);let T=e<s?e:s;u<T&&(T=u);let W=e>s?e:s;u>W&&(W=u);let R=Math.max(0,Math.ceil(z)),j=Math.min(M-1,Math.floor(F)),N=Math.max(0,Math.ceil(T)),re=Math.min(x-1,Math.floor(W));if(!(R>j||N>re))for(let k=N;k<=re;k++){let q=k;for(let oe=R;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(s-q)*(c-K),ie=(c-K)*(e-q)-(u-q)*(n-K),O=(n-K)*(s-q)-(e-q)*(r-K);if(G?Z<0||ie<0||O<0:Z>0||ie>0||O>0)continue;let Ke=(Z*t+ie*l+O*p)*g,ge=k*M+oe,J=_[ge];if(Ke>(J>0?J*(1-L):J)){if(_[ge]=Ke,A!==null){let V=ge*3;A[V]=(Z*P[0]+ie*H[0]+O*v[0])*g,A[V+1]=(Z*P[1]+ie*H[1]+O*v[1])*g,A[V+2]=(Z*P[2]+ie*H[2]+O*v[2])*g}let Q=(Z*o+ie*i+O*d)*g,ve=f;if(a!==null){let V=(Z*a.ua+ie*a.ub+O*a.uc)*g,X=(Z*a.va+ie*a.vb+O*a.vc)*g,Y=(0,nt.sampleTexel)(a.sampler,V,X);if(Y!==null&&Y.a>8){let S=Y.r*a.tintR|0;S>255&&(S=255);let I=Y.g*a.tintG|0;I>255&&(I=255);let ee=Y.b*a.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(I)}${ne(ee)}`,Q*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Pe=(Q<0?0:Q>1?1:Q)*h,Se=Pe|0,Ze=Pe-Se,ot=mn[(k&3)*4+(oe&3)],B=Ze>ot&&Se<h?Se+1:Se;if(B>h&&(B=h),y!==null){let V=(Z*y.luA+ie*y.luB+O*y.luC)*g,X=(Z*y.lvA+ie*y.lvB+O*y.lvC)*g,Y=(Z*y.ldA+ie*y.ldB+O*y.ldC)*g,S=V|0,I=X|0;if(S>=0&&S<be&&I>=0&&I<be){let ee=y.map.buf[I*be+S];if(ee>-1/0&&Y+y.lift<ee&&(B=Math.max(0,B-Math.round(y.opacity*h)),ve!==null)){let de=`shadow:${ve}:${B}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=y.shadowColorRgb,we=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ae=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ye=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ye)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ge]=m[B],C&&(C[ge]=ve)}}}}function gn(n,e){let t=n.length,o=new Array(t);for(let i=0;i<t;i++){let c=n[i].vertices;if(c.length<3){o[i]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],m=p[0]-u[0],h=p[1]-u[1],f=p[2]-u[2],b=d[0]-u[0],C=d[1]-u[1],_=d[2]-u[2],M=h*_-f*C,x=f*b-m*_,y=m*C-h*b,w=Math.hypot(M,x,y)||1;o[i]=[M/w,x/w,y/w]}let r=new Map;for(let i=0;i<t;i++){let c=n[i].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,m=r.get(d);m||(m=[],r.set(d,m)),(m.length===0||m[m.length-1]!==i)&&m.push(i)}}let s=Math.cos(e*Math.PI/180),l=new Array(t);for(let i=0;i<t;i++){let c=n[i].vertices,u=o[i],p=new Array(c.length);for(let d=0;d<c.length;d++){let m=c[d],h=r.get(`${m[0]},${m[1]},${m[2]}`),f=0,b=0,C=0;for(let M=0;M<h.length;M++){let x=h[M],y=o[x];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(f+=y[0],b+=y[1],C+=y[2])}let _=Math.hypot(f,b,C)||1;p[d]=[f/_,b/_,C/_]}l[i]=p}return l}function yn(n,e,t,o){let r=[],s=null,l="",i=()=>{l&&(s!==null?r.push(`<span style="color:${s}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<t;u++){let p=c*t+u,d=n[p],m=e&&d!==" "?e[p]??null:null;m!==s&&(i(),s=m),l+=d}i(),s=null,c<o-1&&r.push(`
2
- `)}return r.join("")}function bn(n,e,t,o,r,s,l,i,c,u){let p=Math.abs(r-t),d=-Math.abs(s-o),m=t<r?1:-1,h=o<s?1:-1,f=p+d;for(;;){if(t>=0&&t<c&&o>=0&&o<u){let C=o*c+t;n[C]<l&&(n[C]=l,e&&(e[C]=i))}if(t===r&&o===s)break;let b=2*f;b>=d&&(f+=d,t+=m),b<=p&&(f+=p,o+=h)}}function vn(n,e,t,o,r){let s=[],l=null,i="",c=()=>{i&&(l!==null?s.push(`<span style="color:${l}">${i}</span>`):s.push(i),i="")};for(let u=0;u<o;u++){for(let p=0;p<t;p++){let d=u*t+p,m=n[d],h,f;m===0?(h=" ",f=null):(h=m===1?r.thin[Math.random()*r.thin.length|0]:m===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=e?e[d]??null:null),f!==l&&(c(),l=f),i+=h}c(),l=null,u<o-1&&s.push(`
3
- `)}return s.join("")}var Pt=new Map;function ze(n){let e=Pt.get(n);if(e!==void 0)return e;let t=En(n);return Pt.set(n,t),t}function En(n){let e=n.startsWith("#")?n.slice(1):n;if(e.length===3){let t=parseInt(e[0]+e[0],16),o=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16);return[t||0,o||0,r||0]}if(e.length===6){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return[t||0,o||0,r||0]}return[255,255,255]}function ne(n){let e=Math.max(0,Math.min(255,n|0)).toString(16);return e.length===1?"0"+e:e}var Ft="glyph-styles";function It(n){let e=n??(typeof document<"u"?document:void 0);if(!e||e.getElementById(Ft))return;let t=e.createElement("style");t.id=Ft,t.textContent=wn,e.head.appendChild(t)}var wn=`
1
+ "use strict";var mt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var tn=(n,t)=>{for(var e in t)mt(n,e,{get:t[e],enumerable:!0})},nn=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qt(t))!en.call(n,r)&&r!==e&&mt(n,r,{get:()=>t[r],enumerable:!(o=Jt(t,r))||o.enumerable});return n};var rn=n=>nn(mt({},"__esModule",{value:!0}),n);var Xn={};tn(Xn,{GlyphHotspotElement:()=>We,GlyphMapControlsElement:()=>Ue,GlyphMeshElement:()=>$e,GlyphOrbitControlsElement:()=>qe,GlyphOrthographicCameraElement:()=>Ne,GlyphPerspectiveCameraElement:()=>je,GlyphSceneElement:()=>Ve});module.exports=rn(Xn);var Bt=require("@glyphcss/core");var Gt=Math.PI/180,Lt=.01,on=32e3,sn=Lt*1.01;function ft(n,t,e){let o=n[1],r=n[0],l=n[2],a=e*Gt,i=Math.cos(a),c=Math.sin(a),u=o*i-r*c,p=o*c+r*i,d=l,h=t*Gt,m=Math.cos(h),f=Math.sin(h),b=p*m-d*f,C=p*f+d*m;return[u,b,C]}function Ie(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??on,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let l=ft([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),a=.001*1.01;if(t.eyeMode)return-l[2]-a;if(t.perspective>0){let i=l[2]*t.zoom*50-t.distance;return t.perspective-i-t.perspective*sn}return t.distance-l[2]-a},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ft(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let y=t.focal/-d[2],w=d[0]*y*t.zoom*50,P=d[1]*y*t.zoom*50,H=l*e+w/u*t.stretch,v=a*o+P/50;return[H,v,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,y=d[0]*t.zoom*50,w=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,H=M-P,v=M*Lt;if(H<v)return[NaN,NaN,P,NaN];let A=M/H,L=l*e+y*A/u*t.stretch*t.fovScale,s=a*o+w*A/50*t.fovScale;return[L,s,P,1/H]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,b=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,_=l*e+b/u*t.stretch*t.fovScale,x=a*o+C/50*t.fovScale;return[_,x,d[2],1/m]}}}function Tt(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ft(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=l*e+h/u*t.fovScale,b=a*o+m/50*t.fovScale;return[f,b,d[2]]}}}var ln={direction:[-.5,-.7,-.5],intensity:1},an={intensity:.4};function cn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let l=0;l<r.length;l++){let a=r[l],i=r[(l+1)%r.length],c=`${a[0]},${a[1]},${a[2]}`,u=`${i[0]},${i[1]},${i[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:a,to:i,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function _t(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?cn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??ln,ambientLight:n.ambientLight??an,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var jn=" .:-=+*#%@".split(""),qn=" .:-=+*#%@".split(""),gt={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Un=gt.default;function yt(n){return gt[n]??gt.default}function Ht(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:l,rows:a,cellAspect:i}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return un(n,l,a,i,d)}let c=yt(n.glyphPalette),u=new Uint8Array(l*a),p=n.useColors?new Array(l*a).fill(null):null;for(let d of o){let h=t.project(d.from,l,a,i),m=t.project(d.to,l,a,i);h[0]!==h[0]||m[0]!==m[0]||bn(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,l,a)}return vn(u,p,l,a,c)}function un(n,t,e,o,r){let l=t*r,a=e*r,{camera:i,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,_=n.depthEpsilon??0,x=r>1?{zoom:i.zoom,eyeDepth:B=>i.eyeDepth(B),project:(B,X,V,Y)=>{let S=i.project(B,X,V,Y);return[X*.5+(S[0]-X*.5)*r,V*.5+(S[1]-V*.5)*r,S[2],S[3]]}}:i,M=yt(n.glyphPalette).solid,y=M.length-1,w=new Array(l*a).fill(" "),P=n.useColors,H=P?new Array(l*a).fill(null):null,v=new Float64Array(l*a).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(l*a*3).fill(NaN):null,s=u.direction,E=Math.hypot(s[0],s[1],s[2])||1,g=s[0]/E,G=s[1]/E,z=s[2]/E,F=u.intensity??1,T=p.intensity??.4,W=ze(u.color??"#ffffff"),R=ze(p.color??"#ffffff"),j=d&&h>0?gn(c,h):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?fn(c,f,g,G,z):null,oe=k?.opacity??.25,K=k?.lift??.05,Z=k?.color??"#000000",ie=q?ze(Z):[0,0,0],O=globalThis.__glyphPerfDetail,Ke=O?performance.now():0,ge=[],J=n.shadeCache??null,Q=-1,ve=(B,X,V,Y)=>{if(q===null||!Y)return null;let S=q,I=Oe(B,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Oe(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Oe(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:I[0],lvA:I[1],ldA:I[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:N}};for(let B=0;B<c.length;B++){let X=c[B],V=X.vertices;if(V.length<3)continue;let Y=X.uvs,S=null;if(re!==null&&Y&&Y.length>=V.length){let I=(0,nt.polygonTexture)(X);I&&(S=re.get(I)??null)}for(let I=0;I<V.length;I++)ge[I]=x.project(V[I],l,a,o);for(let I=1;I<V.length-1;I++){Q++;let ee=0,de=I,Ee=I+1,se=V[ee],pe=V[de],we=V[Ee],ae=ge[ee],ye=ge[de],Me=ge[Ee],it=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(Me[0]!==Me[0]?1:0);if(it===3||it===0&&!m&&(ye[0]-ae[0])*(Me[1]-ae[1])-(ye[1]-ae[1])*(Me[0]-ae[0])>0)continue;let Ge,Le,Te,ke=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],ke=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],Je=we[1]-se[1],Qe=we[2]-se[2],et=he*Qe-Ae*Je,Ye=Ae*me-$*Qe,U=$*Je-he*me,D=Math.hypot(et,Ye,U)||1,te=et/D,fe=Ye/D,le=U/D,ce,_e,st,lt,at,ct,ut,dt,pt;if(j){let De=j[B],xe=De[ee],Fe=De[de],Xe=De[Ee];ce=xe[0],_e=xe[1],st=xe[2],lt=Fe[0],at=Fe[1],ct=Fe[2],ut=Xe[0],dt=Xe[1],pt=Xe[2]}else ce=lt=ut=te,_e=at=dt=fe,st=ct=pt=le;let St=ce*g+_e*G+st*z,Mt=lt*g+at*G+ct*z,xt=ut*g+dt*G+pt*z,Xt=m?Math.abs(St):Math.max(0,-St),Vt=m?Math.abs(Mt):Math.max(0,-Mt),$t=m?Math.abs(xt):Math.max(0,-xt);if(Ge=Math.min(1,T+Xt*F),Le=Math.min(1,T+Vt*F),Te=Math.min(1,T+$t*F),P){let De=(Ge+Le+Te)/3,xe=Math.max(0,De-T),Fe=X.color??"#ffffff",Xe=xe*255|0,Ct=`${Fe}:${Xe}`,tt=N.get(Ct);if(tt===void 0){let ht=ze(Fe),Wt=T*R[0]/255+xe*W[0]/255,jt=T*R[1]/255+xe*W[1]/255,qt=T*R[2]/255+xe*W[2]/255,Ut=Math.min(255,ht[0]*Wt),Kt=Math.min(255,ht[1]*jt),Zt=Math.min(255,ht[2]*qt);tt=`#${ne(Ut)}${ne(Kt)}${ne(Zt)}`,N.set(Ct,tt)}ke=tt}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=ke)}let wt=b[B]??!1,He=1+(C?.[B]??0),At=null;if(S!==null&&Y){let $=Y[ee],he=Y[de],Ae=Y[Ee],me=Math.max(0,(Ge+Le+Te)/3-T);At={sampler:S,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:Ae[0],vc:Ae[1],tintR:T*R[0]/255+me*W[0]/255,tintG:T*R[1]/255+me*W[1]/255,tintB:T*R[2]/255+me*W[2]/255}}if(it===0)zt(ae[0],ae[1],(ae[3]??ae[2])*He,Ge,ye[0],ye[1],(ye[3]??ye[2])*He,Le,Me[0],Me[1],(Me[3]??Me[2])*He,Te,M,y,ke,w,H,v,l,a,ve(se,pe,we,wt),m,se,pe,we,L,_,At);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],Je=x.eyeDepth(se),Qe=x.eyeDepth(pe),et=x.eyeDepth(we),Ye=[Je,Qe,et];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ye[U],fe=Ye[D];if(te>0&&($.push(Ae[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[D];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[D]-me[U]))}}if($.length>=3){let U=$.map(D=>x.project(D,l,a,o));for(let D=1;D<$.length-1;D++){let te=U[0],fe=U[D],le=U[D+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||zt(te[0],te[1],(te[3]??te[2])*He,he[0],fe[0],fe[1],(fe[3]??fe[2])*He,he[D],le[0],le[1],(le[3]??le[2])*He,he[D+1],M,y,ke,w,H,v,l,a,ve($[0],$[D],$[D+1],wt),m,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Ke);let Et=O?performance.now():0,Pe=w,Se=H,Ze=L;if(r>1){let B=pn(w,H,v,L,t,e,r,M);Pe=B.glyphBuf,Se=B.colorBuf,Ze=B.worldPos}A&&dn(Pe,Se,Ze,t,e,o,M,n.temporalBlend,n.temporalHistory,i);let ot=yn(Pe,Se,t,e);return O&&(O.string??(O.string=[])).push(performance.now()-Et),ot}function dn(n,t,e,o,r,l,a,i,c,u){let p=o*r,d=a.length-1,h=new Map;for(let M=0;M<a.length;M++)h.set(a[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Ie({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=y=>M.project(y,o,r,l)}let b=new Float32Array(p),C=new Float32Array(p),_=new Float32Array(p),x=new Float32Array(p);for(let M=0;M<r;M++)for(let y=0;y<o;y++){let w=M*o+y,P=h.get(n[w])??0,H=0,v=0,A=0,L=t?t[w]:null;if(L){let k=ze(L);H=k[0],v=k[1],A=k[2]}let s=0,E=0,g=0,G=0,z=0,F=e[w*3];if(f&&F===F){let k=f([F,e[w*3+1],e[w*3+2]]),q=Math.round(k[0]),oe=Math.round(k[1]);if(k[0]===k[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;E=c.idx[K],g=c.r[K],G=c.g[K],z=c.b[K],s=i}}let T=1-s,W=T*P+s*E,R=T*H+s*g,j=T*v+s*G,N=T*A+s*z;b[w]=W,C[w]=R,_[w]=j,x[w]=N;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[w]=a[re],t&&(t[w]=re===0?null:`#${ne(R)}${ne(j)}${ne(N)}`)}c.idx=b,c.r=C,c.g=_,c.b=x,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function pn(n,t,e,o,r,l,a,i){let c=new Map;for(let b=0;b<i.length;b++)c.set(i[b],b);let u=i.length-1,p=r*a,d=new Array(r*l).fill(" "),h=t?new Array(r*l).fill(null):null,m=o?new Float32Array(r*l*3).fill(NaN):null,f=1/(a*a);for(let b=0;b<l;b++)for(let C=0;C<r;C++){let _=0,x=0,M=0,y=0,w=0,P=0,H=0,v=0;for(let s=0;s<a;s++){let E=(b*a+s)*p+C*a;for(let g=0;g<a;g++){let G=E+g;if(e[G]!==-1/0){if(_+=c.get(n[G])??0,x++,h){let z=t[G];if(z){let F=ze(z);M+=F[0],y+=F[1],w+=F[2]}}m&&(P+=o[G*3],H+=o[G*3+1],v+=o[G*3+2])}}}let A=b*r+C;if(x===0)continue;let L=Math.round(_*f);L<0?L=0:L>u&&(L=u),d[A]=i[L],h&&(h[A]=`#${ne(M/x)}${ne(y/x)}${ne(w/x)}`),m&&(m[A*3]=P/x,m[A*3+1]=H/x,m[A*3+2]=v/x)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var hn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Oe(n,t,e,o,r,l,a,i,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],b=r*n[0]+l*n[1]+a*n[2],C=-(i*n[0]+c*n[1]+u*n[2]),_=(f-p)/(d-p)*(be-1),x=(b-h)/(m-h)*(be-1);return[_,x,C]}function mn(n,t,e,o){let r=t[0],l=t[1],a=t[2],i=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(i-r)*(d-l)-(c-l)*(p-r);if(m===0)return;let f=1/m,b=r<i?r:i;p<b&&(b=p);let C=r>i?r:i;p>C&&(C=p);let _=l<c?l:c;d<_&&(_=d);let x=l>c?l:c;d>x&&(x=d);let M=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),w=Math.max(0,Math.ceil(_)),P=Math.min(be-1,Math.floor(x));if(M>y||w>P)return;let H=m>0;for(let v=w;v<=P;v++)for(let A=M;A<=y;A++){let L=A,s=v,E=(i-L)*(d-s)-(c-s)*(p-L),g=(p-L)*(l-s)-(d-s)*(r-L),G=(r-L)*(c-s)-(l-s)*(i-L);if(H?E<0||g<0||G<0:E>0||g>0||G>0)continue;let z=(E*a+g*u+G*h)*f,F=v*be+A;z>n[F]&&(n[F]=z)}}function fn(n,t,e,o,r){let l,a,i;Math.abs(e)<.9?(l=0,a=r,i=-o):(l=-r,a=0,i=e);let c=Math.hypot(l,a,i);l/=c,a/=c,i/=c;let u=a*r-i*o,p=i*e-l*r,d=l*o-a*e,h=1/0,m=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(t[y]){C=!0;for(let w of n[y].vertices){let P=l*w[0]+a*w[1]+i*w[2],H=u*w[0]+p*w[1]+d*w[2];P<h&&(h=P),P>m&&(m=P),H<f&&(f=H),H>b&&(b=H)}}if(!C)return null;let _=(m-h)*.05+.01,x=(b-f)*.05+.01;h-=_,m+=_,f-=x,b+=x;let M=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let w=n[y].vertices;if(!(w.length<3))for(let P=1;P<w.length-1;P++){let H=w[0],v=w[P],A=w[P+1],L=Oe(H,l,a,i,u,p,d,e,o,r,h,m,f,b),s=Oe(v,l,a,i,u,p,d,e,o,r,h,m,f,b),E=Oe(A,l,a,i,u,p,d,e,o,r,h,m,f,b);mn(M,L,s,E)}}return{buf:M,right:[l,a,i],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:b}}function zt(n,t,e,o,r,l,a,i,c,u,p,d,h,m,f,b,C,_,x,M,y,w,P,H,v,A,L,s){let E=(r-n)*(u-t)-(l-t)*(c-n);if(E===0||!w&&E>0)return;let g=1/E,G=E>0,z=n<r?n:r;c<z&&(z=c);let F=n>r?n:r;c>F&&(F=c);let T=t<l?t:l;u<T&&(T=u);let W=t>l?t:l;u>W&&(W=u);let R=Math.max(0,Math.ceil(z)),j=Math.min(x-1,Math.floor(F)),N=Math.max(0,Math.ceil(T)),re=Math.min(M-1,Math.floor(W));if(!(R>j||N>re))for(let k=N;k<=re;k++){let q=k;for(let oe=R;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(l-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),O=(n-K)*(l-q)-(t-q)*(r-K);if(G?Z<0||ie<0||O<0:Z>0||ie>0||O>0)continue;let Ke=(Z*e+ie*a+O*p)*g,ge=k*x+oe,J=_[ge];if(Ke>(J>0?J*(1-L):J)){if(_[ge]=Ke,A!==null){let X=ge*3;A[X]=(Z*P[0]+ie*H[0]+O*v[0])*g,A[X+1]=(Z*P[1]+ie*H[1]+O*v[1])*g,A[X+2]=(Z*P[2]+ie*H[2]+O*v[2])*g}let Q=(Z*o+ie*i+O*d)*g,ve=f;if(s!==null){let X=(Z*s.ua+ie*s.ub+O*s.uc)*g,V=(Z*s.va+ie*s.vb+O*s.vc)*g,Y=(0,nt.sampleTexel)(s.sampler,X,V);if(Y!==null&&Y.a>8){let S=Y.r*s.tintR|0;S>255&&(S=255);let I=Y.g*s.tintG|0;I>255&&(I=255);let ee=Y.b*s.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(I)}${ne(ee)}`,Q*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Pe=(Q<0?0:Q>1?1:Q)*m,Se=Pe|0,Ze=Pe-Se,ot=hn[(k&3)*4+(oe&3)],B=Ze>ot&&Se<m?Se+1:Se;if(B>m&&(B=m),y!==null){let X=(Z*y.luA+ie*y.luB+O*y.luC)*g,V=(Z*y.lvA+ie*y.lvB+O*y.lvC)*g,Y=(Z*y.ldA+ie*y.ldB+O*y.ldC)*g,S=X|0,I=V|0;if(S>=0&&S<be&&I>=0&&I<be){let ee=y.map.buf[I*be+S];if(ee>-1/0&&Y+y.lift<ee&&(B=Math.max(0,B-Math.round(y.opacity*m)),ve!==null)){let de=`shadow:${ve}:${B}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=y.shadowColorRgb,we=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ae=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ye=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ye)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ge]=h[B],C&&(C[ge]=ve)}}}}function gn(n,t){let e=n.length,o=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices;if(c.length<3){o[i]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],b=d[0]-u[0],C=d[1]-u[1],_=d[2]-u[2],x=m*_-f*C,M=f*b-h*_,y=h*C-m*b,w=Math.hypot(x,M,y)||1;o[i]=[x/w,M/w,y/w]}let r=new Map;for(let i=0;i<e;i++){let c=n[i].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==i)&&h.push(i)}}let l=Math.cos(t*Math.PI/180),a=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices,u=o[i],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,b=0,C=0;for(let x=0;x<m.length;x++){let M=m[x],y=o[M];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=l&&(f+=y[0],b+=y[1],C+=y[2])}let _=Math.hypot(f,b,C)||1;p[d]=[f/_,b/_,C/_]}a[i]=p}return a}function yn(n,t,e,o){let r=[],l=null,a="",i=()=>{a&&(l!==null?r.push(`<span style="color:${l}">${a}</span>`):r.push(a),a="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==l&&(i(),l=h),a+=d}i(),l=null,c<o-1&&r.push(`
2
+ `)}return r.join("")}function bn(n,t,e,o,r,l,a,i,c,u){let p=Math.abs(r-e),d=-Math.abs(l-o),h=e<r?1:-1,m=o<l?1:-1,f=p+d;for(;;){if(e>=0&&e<c&&o>=0&&o<u){let C=o*c+e;n[C]<a&&(n[C]=a,t&&(t[C]=i))}if(e===r&&o===l)break;let b=2*f;b>=d&&(f+=d,e+=h),b<=p&&(f+=p,o+=m)}}function vn(n,t,e,o,r){let l=[],a=null,i="",c=()=>{i&&(a!==null?l.push(`<span style="color:${a}">${i}</span>`):l.push(i),i="")};for(let u=0;u<o;u++){for(let p=0;p<e;p++){let d=u*e+p,h=n[d],m,f;h===0?(m=" ",f=null):(m=h===1?r.thin[Math.random()*r.thin.length|0]:h===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[d]??null:null),f!==a&&(c(),a=f),i+=m}c(),a=null,u<o-1&&l.push(`
3
+ `)}return l.join("")}var Pt=new Map;function ze(n){let t=Pt.get(n);if(t!==void 0)return t;let e=En(n);return Pt.set(n,e),e}function En(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function ne(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Ft="glyph-styles";function It(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Ft))return;let e=t.createElement("style");e.id=Ft,e.textContent=wn,t.head.appendChild(e)}var wn=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5
5
 
6
6
  .glyph-host {
@@ -59,5 +59,5 @@
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function Ot(n,e,t,o,r){return n.map(s=>{let[l,i,c]=e.project(s.at,t,o,r),u=c>-3&&l>=0&&l<t&&i>=0&&i<o;return{id:s.id,col:l,row:i,depth:c,visible:u}})}var An=1;function Sn(n,e){let{position:t,scale:o,rotation:r}=e;if(!t&&!o&&!r)return n;let[s,l,i]=t??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[m,h,f]=r??[0,0,0],b=m*d,C=h*d,_=f*d,M=Math.cos(b),x=Math.sin(b),y=Math.cos(C),w=Math.sin(C),P=Math.cos(_),H=Math.sin(_);function v(A){let L=A[0]*c,a=A[1]*u,E=A[2]*p,g=P*L-H*a,G=H*L+P*a,z=E;return L=y*g+w*z,a=G,E=-w*g+y*z,g=L,G=M*a-x*E,z=x*a+M*E,[g+s,G+l,z+i]}return n.map(A=>({...A,vertices:A.vertices.map(v)}))}function Rt(n,e={}){It(n.ownerDocument??void 0);let t={mode:e.mode??"solid",glyphPalette:e.glyphPalette??"default",useColors:e.useColors??!0,cols:e.cols??80,rows:e.rows??24,cellAspect:e.cellAspect??2,directionalLight:e.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:e.ambientLight??{intensity:.4},camera:e.camera??Ie(),smoothShading:e.smoothShading??!1,creaseAngle:e.creaseAngle??60,doubleSided:e.doubleSided??!1,supersample:e.supersample??1,depthEpsilon:e.depthEpsilon??0,temporalBlend:e.temporalBlend??0,autoSize:e.autoSize??!1,shadow:e.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let l=new Map,i=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let m=null,h=0;function f(){let a=[];for(let g of l.values())for(let G of g.polygons)(G.texture||G.material?.texture)&&a.push(G);if(a.length===0){m&&(m=null,b());return}let E=++h;(0,Bt.buildTextureSamplers)(a).then(g=>{E===h&&(m=g.size>0?g:null,b())})}function b(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],E=[],g=[],G=[],z=!1;for(let N of l.values()){let re=Sn(N.polygons,N.transform),k=N.transform.castShadow??!1,q=N.transform.receiveShadow??!1,oe=N.transform.depthBias??0;oe!==0&&(z=!0);for(let K of re)a.push(K),E.push(k),g.push(q),G.push(oe)}let F=_t({camera:t.camera,grid:{cols:t.cols,rows:t.rows,cellAspect:t.cellAspect},polygons:a,mode:t.mode,directionalLight:t.directionalLight,ambientLight:t.ambientLight,glyphPalette:t.glyphPalette,useColors:t.useColors,smoothShading:t.smoothShading,creaseAngle:t.creaseAngle,doubleSided:t.doubleSided,supersample:t.supersample,depthEpsilon:t.depthEpsilon,temporalBlend:t.temporalBlend,shadow:t.shadow,castShadowFlags:E,receiveShadowFlags:g,depthBiases:z?G:void 0});F.shadeCache=u,F.textureSamplers=m,F.temporalHistory=p;let T=globalThis.__glyphPerf,W=T?performance.now():0,R=Ht(F),j=T?performance.now():0;if(t.useColors?r.innerHTML=R:r.textContent=R,T){let N=performance.now();(T.raster??(T.raster=[])).push(j-W),(T.dom??(T.dom=[])).push(N-j),(T.polys??(T.polys=[])).push(a.length)}_()}function _(){let{cols:a,rows:E,cellAspect:g,camera:G}=t,z=Ot(i.map(R=>R.hotspot),G,a,E,g),F=r.getBoundingClientRect(),T=a>0?F.width/a:8,W=E>0?F.height/E:16;for(let R=0;R<i.length;R++){let{el:j}=i[R],N=z[R];N.visible?(j.style.display="",j.style.left=`${(N.col+.5)*T}px`,j.style.top=`${(N.row+.5)*W}px`,j.style.zIndex=String(Math.round(N.depth*1e3))):j.style.display="none"}}function M(a,E={}){let g=An++;return l.set(g,{id:g,polygons:a,transform:E}),d(),f(),b(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(G){let z=l.get(g);z&&(z.transform=G,d(),b())},dispose(){l.delete(g),d(),f(),b()}}}function x(a,E){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[G,z]=a.size??[1,1];g.style.position="absolute",g.style.width=`${G}ch`,g.style.height=`${z*t.cellAspect}ch`,E&&g.addEventListener("click",E),s.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:E};return i.push(F),b(),{get el(){return g},remove(){let T=i.indexOf(F);T>=0&&i.splice(T,1),E&&g.removeEventListener("click",E),s.removeChild(g),b()}}}function y(){C()}function w(a){a.mode!==void 0&&(t.mode=a.mode),a.glyphPalette!==void 0&&(t.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(t.useColors=a.useColors),a.cols!==void 0&&(t.cols=a.cols),a.rows!==void 0&&(t.rows=a.rows),a.cellAspect!==void 0&&(t.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(t.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(t.ambientLight=a.ambientLight),a.camera!==void 0&&(t.camera=a.camera),a.smoothShading!==void 0&&(t.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(t.creaseAngle=a.creaseAngle),"shadow"in a&&(t.shadow=a.shadow),a.autoSize!==void 0&&(t.autoSize=a.autoSize,t.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>v()),A.observe(n),v()):!t.autoSize&&A&&(A.disconnect(),A=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),b()}function P(){return{...t}}function H(){let E=n.ownerDocument.createElement("span");E.textContent=Array(20).fill("M").join(`
63
- `),E.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(E);let g=E.getBoundingClientRect();return E.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function v(){let a=n.clientWidth,E=n.clientHeight;if(!a||!E)return;let g=H(),G=Math.max(20,Math.floor(a/g.w)),z=Math.max(8,Math.floor(E/g.h)),F=g.h/g.w,T=!1;t.cols!==G&&(t.cols=G,T=!0),t.rows!==z&&(t.rows=z,T=!0),Math.abs(t.cellAspect-F)>.01&&(t.cellAspect=F,T=!0),T&&b()}let A=null;t.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>v()),A.observe(n),v());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return t.camera},add:M,addHotspot:x,rerender:y,setOptions:w,getOptions:P,fit:v,destroy:L}}var xn=typeof HTMLElement<"u"?HTMLElement:class{},Mn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Ce(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}function Cn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Gn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Xe=class extends xn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Mn]}getScene(){return this._scene}_readOptions(){let t={},o=Cn(this.getAttribute("mode"));o!==void 0&&(t.mode=o);let r=this.getAttribute("glyph-palette");r&&(t.glyphPalette=r);let s=Gn(this.getAttribute("use-colors"));s!==void 0&&(t.useColors=s);let l=Ce(this.getAttribute("cols"));l!==void 0&&(t.cols=l);let i=Ce(this.getAttribute("rows"));i!==void 0&&(t.rows=i);let c=Ce(this.getAttribute("cell-aspect"));c!==void 0&&(t.cellAspect=c);let u=Ce(this.getAttribute("directional-intensity"));u!==void 0&&(t.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Ce(this.getAttribute("ambient-intensity"));if(p!==void 0&&(t.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(t.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},m=this.getAttribute("shadow-color");m&&(d.color=m);let h=Ce(this.getAttribute("shadow-opacity"));h!==void 0&&(d.opacity=h);let f=Ce(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let b=Ce(this.getAttribute("shadow-max-extend"));b!==void 0&&(d.maxExtend=b),t.shadow=d}return t}_findCameraAncestor(){let t=this.parentElement;for(;t;){let o=t.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return t;t=t.parentElement}return null}_initScene(t){let o=typeof t.getCamera=="function"?t.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Rt(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let t=this._findCameraAncestor();if(!t)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof t.getCamera=="function"?t.getCamera():null)!==null)this._initScene(t);else{let r=()=>{t.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(t)};t.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(t,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var Be=require("@glyphcss/core"),Ln=typeof HTMLElement<"u"?HTMLElement:class{},Tn=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function _n(n){let e=(0,Be.computeSceneBbox)(n),t=(e.min[0]+e.max[0])/2,o=(e.min[1]+e.max[1])/2,r=(e.min[2]+e.max[2])/2,l=2/(Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],e.max[2]-e.min[2])||1);return n.map(i=>({...i,vertices:i.vertices.map(c=>[(c[0]-t)*l,(c[1]-o)*l,(c[2]-r)*l])}))}function bt(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==3||e.some(t=>!Number.isFinite(t))))return[e[0],e[1],e[2]]}function zn(n){if(n){if(!n.includes(",")){let e=parseFloat(n);return Number.isFinite(e)?e:void 0}return bt(n)}}function Pn(n){return n.closest("glyph-scene")??null}var $e=class extends Ln{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Tn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r){if(t==="src"||t==="geometry"||t==="size"||t==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:bt(this.getAttribute("position")),scale:zn(this.getAttribute("scale")),rotation:bt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let t=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Pn(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(t){let s=++this._loadToken,l;try{l=await(0,Be.loadMesh)(t)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(s!==this._loadToken){try{l.dispose()}catch{}return}let i=r.getScene();if(!i){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?_n(l.polygons):l.polygons;this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let l=this.getAttribute("size"),i=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=(0,Be.resolveGeometry)(o,{size:Number.isFinite(i)?i:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Hn=typeof HTMLElement<"u"?HTMLElement:class{};function Fn(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==3||e.some(t=>!Number.isFinite(t))))return[e[0],e[1],e[2]]}function In(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==2||e.some(t=>!Number.isFinite(t))))return[e[0],e[1]]}function On(n){return n.closest("glyph-scene")??null}var We=class extends Hn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(t,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let t=this._handle.el;for(;t.firstChild;)this.appendChild(t.firstChild);this._handle.remove(),this._handle=null}_register(){let t=Fn(this.getAttribute("at"));if(!t)return;let o=On(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=In(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:t,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}var je=class extends Bn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(t,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=ue(this.getAttribute("rot-x")),i=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),m=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,m=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,m=!0),c!==void 0&&s.distance!==c&&(s.distance=c,m=!0),u!==void 0&&s.perspective!==u&&(s.perspective=u,m=!0),p!==void 0&&s.zoom!==p&&(s.zoom=p,m=!0),d!==void 0&&s.stretch!==d&&(s.stretch=d,m=!0),m&&this.querySelector("glyph-scene")?.rerender?.()}};var Rn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}var Ne=class extends Rn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Tt({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(t,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=Re(this.getAttribute("rot-x")),i=Re(this.getAttribute("rot-y")),c=Re(this.getAttribute("zoom")),u=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,u=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,u=!0),c!==void 0&&s.zoom!==c&&(s.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function kt(n,e={}){let t=n.host,o=e.drag??!0,r=e.wheel??!0,s=Nt(e.invert),l=e.clampPitch??!0,i=e.animate??!1,c=!1,u=!1,p=null,d=null,m=null,h={x:0,y:0},f=n.camera;function b(v){if(!(!o||c)&&m===null&&v.isPrimary!==!1){v.preventDefault(),m=v.pointerId,h={x:v.clientX,y:v.clientY},t.style.cursor="grabbing";try{v.target.setPointerCapture(v.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function C(v){if(m===null||v.pointerId!==m||!o||c)return;v.preventDefault();let A=v.clientX-h.x,L=v.clientY-h.y;h={x:v.clientX,y:v.clientY};let a=s,E=1/4;f.rotY=f.rotY-A*E*a;let g=f.rotX-L*E*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function _(v){if(m===v.pointerId){m=null,t.style.cursor=o&&!c?"grab":"";try{v.target.releasePointerCapture(v.pointerId)}catch{}i&&(u=!1)}}function M(v){if(!r||c)return;v.preventDefault();let A=v.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function x(v){if(!(c||!i)){if(!u){let A=d!==null?Math.min(v-d,50):16.67,L=typeof i=="object"&&i.speed?i.speed:.3,a=typeof i=="object"&&i.axis?i.axis:"y",E=L*(A/16.67);a==="y"?f.rotY=f.rotY+E:f.rotX=f.rotX+E,n.rerender()}d=v,p=requestAnimationFrame(x)}}function y(){p===null&&typeof requestAnimationFrame<"u"&&i&&(p=requestAnimationFrame(x))}function w(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){t.addEventListener("pointerdown",b),t.addEventListener("pointermove",C),t.addEventListener("pointerup",_),t.addEventListener("pointercancel",_),t.addEventListener("wheel",M,{passive:!1}),t.style.cursor=o?"grab":"",t.style.touchAction="none",t.style.userSelect="none"}function H(){t.removeEventListener("pointerdown",b),t.removeEventListener("pointermove",C),t.removeEventListener("pointerup",_),t.removeEventListener("pointercancel",_),t.removeEventListener("wheel",M),t.style.cursor="",t.style.touchAction="",t.style.userSelect=""}return P(),y(),{update(v){let A=!!i;o=v.drag??o,r=v.wheel??r,s=Nt(v.invert),v.clampPitch!==void 0&&(l=v.clampPitch),i=v.animate??i,!c&&m===null&&(t.style.cursor=o?"grab":"");let L=!!i;A&&!L?w():!A&&L&&y()},pause(){c||(c=!0,H(),w(),m=null,u=!1)},resume(){c&&(c=!1,P(),y())},destroy(){c||H(),w(),c=!0}}}function Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Nn=typeof HTMLElement<"u"?HTMLElement:class{};function kn(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}function rt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Yn(n){return n.closest("glyph-scene")??null}var qe=class extends Nn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let t=rt(this.getAttribute("drag")),o=rt(this.getAttribute("wheel")),r=rt(this.getAttribute("invert")),s=rt(this.getAttribute("clamp-pitch")),l=kn(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...t!==void 0?{drag:t}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...l!==void 0?{animate:{speed:l,axis:i}}:{}}}_attach(){if(this._controls)return;let t=Yn(this);if(!t)return;let o=t.getScene();if(!o){let r=()=>{t.removeEventListener("glyphcss:scene-ready",r),this._attach()};t.addEventListener("glyphcss:scene-ready",r);return}this._controls=kt(o,this._readOptions())}};function Dt(n,e={}){let t=n.host,o=e.drag??!0,r=e.wheel??!0,s=Yt(e.invert),l=e.animate??!1,i=!1,c=!1,u=null,p=null,d=null,m={x:0,y:0},h=!1,f=n.camera,b=1/4,C=.02;function _(a){if(!(!o||i)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,m={x:a.clientX,y:a.clientY},h=a.button===2,t.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function M(a){if(d===null||a.pointerId!==d||!o||i)return;a.preventDefault();let E=a.clientX-m.x,g=a.clientY-m.y;m={x:a.clientX,y:a.clientY};let G=s;if(h||a.shiftKey)f.rotY=f.rotY-E*b*G,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*b*G));else{let z=f.target;f.target=[z[0]-E*C/f.zoom,z[1]-g*C/f.zoom,z[2]]}n.rerender()}function x(a){if(d===a.pointerId){d=null,h=!1,t.style.cursor=o&&!i?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function y(a){a.preventDefault()}function w(a){if(!r||i)return;a.preventDefault();let E=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-E))),n.rerender()}function P(a){if(!(i||!l)){if(!c){let E=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,G=typeof l=="object"&&l.axis?l.axis:"y",z=g*(E/16.67);G==="y"?f.rotY=f.rotY+z:f.rotX=f.rotX+z,n.rerender()}p=a,u=requestAnimationFrame(P)}}function H(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function v(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){t.addEventListener("pointerdown",_),t.addEventListener("pointermove",M),t.addEventListener("pointerup",x),t.addEventListener("pointercancel",x),t.addEventListener("contextmenu",y),t.addEventListener("wheel",w,{passive:!1}),t.style.cursor=o?"grab":"",t.style.touchAction="none",t.style.userSelect="none"}function L(){t.removeEventListener("pointerdown",_),t.removeEventListener("pointermove",M),t.removeEventListener("pointerup",x),t.removeEventListener("pointercancel",x),t.removeEventListener("contextmenu",y),t.removeEventListener("wheel",w),t.style.cursor="",t.style.touchAction="",t.style.userSelect=""}return A(),H(),{update(a){let E=!!l;o=a.drag??o,r=a.wheel??r,s=Yt(a.invert),l=a.animate??l,!i&&d===null&&(t.style.cursor=o?"grab":"");let g=!!l;E&&!g?v():!E&&g&&H()},pause(){i||(i=!0,L(),v(),d=null,c=!1)},resume(){i&&(i=!1,A(),H())},destroy(){i||L(),v(),i=!0}}}function Yt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Dn=typeof HTMLElement<"u"?HTMLElement:class{};function vt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Vn(n){return n.closest("glyph-scene")??null}var Ue=class extends Dn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let t=vt(this.getAttribute("drag")),o=vt(this.getAttribute("wheel")),r=vt(this.getAttribute("invert"));return{...t!==void 0?{drag:t}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let t=Vn(this);if(!t)return;let o=t.getScene();if(!o){let r=()=>{t.removeEventListener("glyphcss:scene-ready",r),this._attach()};t.addEventListener("glyphcss:scene-ready",r);return}this._controls=Dt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Xe),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",$e),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",We),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",Ne),!customElements.get("glyph-camera")){class n extends Ne{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",qe),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",Ue)}0&&(module.exports={GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement});
62
+ `;function Ot(n,t,e,o,r){return n.map(l=>{let[a,i,c]=t.project(l.at,e,o,r),u=c>-3&&a>=0&&a<e&&i>=0&&i<o;return{id:l.id,col:a,row:i,depth:c,visible:u}})}var An=1;function Sn(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[l,a,i]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],b=h*d,C=m*d,_=f*d,x=Math.cos(b),M=Math.sin(b),y=Math.cos(C),w=Math.sin(C),P=Math.cos(_),H=Math.sin(_);function v(A){let L=A[0]*c,s=A[1]*u,E=A[2]*p,g=P*L-H*s,G=H*L+P*s,z=E;return L=y*g+w*z,s=G,E=-w*g+y*z,g=L,G=x*s-M*E,z=M*s+x*E,[g+l,G+a,z+i]}return n.map(A=>({...A,vertices:A.vertices.map(v)}))}function Rt(n,t={}){It(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Ie(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let l=n.ownerDocument.createElement("div");l.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(l),n.appendChild(o);let a=new Map,i=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let s=[];for(let g of a.values())for(let G of g.polygons)(G.texture||G.material?.texture)&&s.push(G);if(s.length===0){h&&(h=null,b());return}let E=++m;(0,Bt.buildTextureSamplers)(s).then(g=>{E===m&&(h=g.size>0?g:null,b())})}function b(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let s=[],E=[],g=[],G=[],z=!1;for(let N of a.values()){let re=Sn(N.polygons,N.transform),k=N.transform.castShadow??!1,q=N.transform.receiveShadow??!1,oe=N.transform.depthBias??0;oe!==0&&(z=!0);for(let K of re)s.push(K),E.push(k),g.push(q),G.push(oe)}let F=_t({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:s,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:E,receiveShadowFlags:g,depthBiases:z?G:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let T=globalThis.__glyphPerf,W=T?performance.now():0,R=Ht(F),j=T?performance.now():0;if(e.useColors?r.innerHTML=R:r.textContent=R,T){let N=performance.now();(T.raster??(T.raster=[])).push(j-W),(T.dom??(T.dom=[])).push(N-j),(T.polys??(T.polys=[])).push(s.length)}_()}function _(){let{cols:s,rows:E,cellAspect:g,camera:G}=e,z=Ot(i.map(R=>R.hotspot),G,s,E,g),F=r.getBoundingClientRect(),T=s>0?F.width/s:8,W=E>0?F.height/E:16;for(let R=0;R<i.length;R++){let{el:j}=i[R],N=z[R];N.visible?(j.style.display="",j.style.left=`${(N.col+.5)*T}px`,j.style.top=`${(N.row+.5)*W}px`,j.style.zIndex=String(Math.round(N.depth*1e3))):j.style.display="none"}}function x(s,E={}){let g=An++;return a.set(g,{id:g,polygons:s,transform:E}),d(),f(),b(),{get id(){return g},get name(){return a.get(g)?.transform.id},get polygons(){return s},setTransform(G){let z=a.get(g);z&&(z.transform=G,d(),b())},dispose(){a.delete(g),d(),f(),b()}}}function M(s,E){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",s.id);let[G,z]=s.size??[1,1];g.style.position="absolute",g.style.width=`${G}ch`,g.style.height=`${z*e.cellAspect}ch`,E&&g.addEventListener("click",E),l.appendChild(g);let F={hotspot:{id:s.id,at:s.at,size:s.size},el:g,onClick:E};return i.push(F),b(),{get el(){return g},remove(){let T=i.indexOf(F);T>=0&&i.splice(T,1),E&&g.removeEventListener("click",E),l.removeChild(g),b()}}}function y(){C()}function w(s){s.mode!==void 0&&(e.mode=s.mode),s.glyphPalette!==void 0&&(e.glyphPalette=s.glyphPalette),s.useColors!==void 0&&(e.useColors=s.useColors),s.cols!==void 0&&(e.cols=s.cols),s.rows!==void 0&&(e.rows=s.rows),s.cellAspect!==void 0&&(e.cellAspect=s.cellAspect),s.directionalLight!==void 0&&(e.directionalLight=s.directionalLight),s.ambientLight!==void 0&&(e.ambientLight=s.ambientLight),s.camera!==void 0&&(e.camera=s.camera),s.smoothShading!==void 0&&(e.smoothShading=s.smoothShading),s.creaseAngle!==void 0&&(e.creaseAngle=s.creaseAngle),"shadow"in s&&(e.shadow=s.shadow),s.autoSize!==void 0&&(e.autoSize=s.autoSize,e.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>v()),A.observe(n),v()):!e.autoSize&&A&&(A.disconnect(),A=null)),(s.mode!==void 0||s.useColors!==void 0||s.directionalLight!==void 0||s.ambientLight!==void 0||s.smoothShading!==void 0||s.creaseAngle!==void 0||s.glyphPalette!==void 0)&&d(),b()}function P(){return{...e}}function H(){let E=n.ownerDocument.createElement("span");E.textContent=Array(20).fill("M").join(`
63
+ `),E.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(E);let g=E.getBoundingClientRect();return E.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function v(){let s=n.clientWidth,E=n.clientHeight;if(!s||!E)return;let g=H(),G=Math.max(20,Math.floor(s/g.w)),z=Math.max(8,Math.floor(E/g.h)),F=g.h/g.w,T=!1;e.cols!==G&&(e.cols=G,T=!0),e.rows!==z&&(e.rows=z,T=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,T=!0),T&&b()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>v()),A.observe(n),v());function L(){A&&(A.disconnect(),A=null),a.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:x,addHotspot:M,rerender:y,setOptions:w,getOptions:P,fit:v,destroy:L}}var Mn=typeof HTMLElement<"u"?HTMLElement:class{},xn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Ce(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Cn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Gn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ve=class extends Mn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...xn]}getScene(){return this._scene}_readOptions(){let e={},o=Cn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let l=Gn(this.getAttribute("use-colors"));l!==void 0&&(e.useColors=l);let a=Ce(this.getAttribute("cols"));a!==void 0&&(e.cols=a);let i=Ce(this.getAttribute("rows"));i!==void 0&&(e.rows=i);let c=Ce(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Ce(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Ce(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Ce(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Ce(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let b=Ce(this.getAttribute("shadow-max-extend"));b!==void 0&&(d.maxExtend=b),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Rt(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var Be=require("@glyphcss/core"),Ln=typeof HTMLElement<"u"?HTMLElement:class{},Tn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function bt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function _n(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return bt(n)}}function zn(n){return n.closest("glyph-scene")??null}var $e=class extends Ln{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Tn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:bt(this.getAttribute("position")),scale:_n(this.getAttribute("scale")),rotation:bt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=zn(this);if(r){if(!r.getScene()){let l=()=>{r.removeEventListener("glyphcss:scene-ready",l),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",l);return}if(e){let l=++this._loadToken,a;try{a=await(0,Be.loadMesh)(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(l!==this._loadToken){try{a.dispose()}catch{}return}let i=r.getScene();if(!i){try{a.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?(0,Be.recenterPolygons)(a.polygons):a.polygons;this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let l=r.getScene();if(!l)return;let a=this.getAttribute("size"),i=a!==null?parseFloat(a):1,c=this.getAttribute("color")??void 0,u;try{u=(0,Be.resolveGeometry)(o,{size:Number.isFinite(i)?i:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Pn=typeof HTMLElement<"u"?HTMLElement:class{};function Hn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Fn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function In(n){return n.closest("glyph-scene")??null}var We=class extends Pn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Hn(this.getAttribute("at"));if(!e)return;let o=In(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let l=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),a=Fn(this.getAttribute("size"));this._handle=r.addHotspot({id:l,at:e,size:a},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:l},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var On=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var je=class extends On{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=ue(this.getAttribute("rot-x")),i=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,h=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,h=!0),c!==void 0&&l.distance!==c&&(l.distance=c,h=!0),u!==void 0&&l.perspective!==u&&(l.perspective=u,h=!0),p!==void 0&&l.zoom!==p&&(l.zoom=p,h=!0),d!==void 0&&l.stretch!==d&&(l.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Ne=class extends Bn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Tt({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=Re(this.getAttribute("rot-x")),i=Re(this.getAttribute("rot-y")),c=Re(this.getAttribute("zoom")),u=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,u=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,u=!0),c!==void 0&&l.zoom!==c&&(l.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function kt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Nt(t.invert),a=t.clampPitch??!0,i=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function b(v){if(!(!o||c)&&h===null&&v.isPrimary!==!1){v.preventDefault(),h=v.pointerId,m={x:v.clientX,y:v.clientY},e.style.cursor="grabbing";try{v.target.setPointerCapture(v.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function C(v){if(h===null||v.pointerId!==h||!o||c)return;v.preventDefault();let A=v.clientX-m.x,L=v.clientY-m.y;m={x:v.clientX,y:v.clientY};let s=l,E=1/4;f.rotY=f.rotY-A*E*s;let g=f.rotX-L*E*s;f.rotX=a?Math.max(-90,Math.min(90,g)):g,n.rerender()}function _(v){if(h===v.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{v.target.releasePointerCapture(v.pointerId)}catch{}i&&(u=!1)}}function x(v){if(!r||c)return;v.preventDefault();let A=v.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(v){if(!(c||!i)){if(!u){let A=d!==null?Math.min(v-d,50):16.67,L=typeof i=="object"&&i.speed?i.speed:.3,s=typeof i=="object"&&i.axis?i.axis:"y",E=L*(A/16.67);s==="y"?f.rotY=f.rotY+E:f.rotX=f.rotX+E,n.rerender()}d=v,p=requestAnimationFrame(M)}}function y(){p===null&&typeof requestAnimationFrame<"u"&&i&&(p=requestAnimationFrame(M))}function w(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",b),e.addEventListener("pointermove",C),e.addEventListener("pointerup",_),e.addEventListener("pointercancel",_),e.addEventListener("wheel",x,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function H(){e.removeEventListener("pointerdown",b),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",_),e.removeEventListener("pointercancel",_),e.removeEventListener("wheel",x),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),y(),{update(v){let A=!!i;o=v.drag??o,r=v.wheel??r,l=Nt(v.invert),v.clampPitch!==void 0&&(a=v.clampPitch),i=v.animate??i,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!i;A&&!L?w():!A&&L&&y()},pause(){c||(c=!0,H(),w(),h=null,u=!1)},resume(){c&&(c=!1,P(),y())},destroy(){c||H(),w(),c=!0}}}function Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Rn=typeof HTMLElement<"u"?HTMLElement:class{};function Nn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function rt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function kn(n){return n.closest("glyph-scene")??null}var qe=class extends Rn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=rt(this.getAttribute("drag")),o=rt(this.getAttribute("wheel")),r=rt(this.getAttribute("invert")),l=rt(this.getAttribute("clamp-pitch")),a=Nn(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...l!==void 0?{clampPitch:l}:{},...a!==void 0?{animate:{speed:a,axis:i}}:{}}}_attach(){if(this._controls)return;let e=kn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=kt(o,this._readOptions())}};function Dt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Yt(t.invert),a=t.animate??!1,i=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,b=1/4,C=.02;function _(s){if(!(!o||i)&&d===null&&s.isPrimary!==!1){s.preventDefault(),d=s.pointerId,h={x:s.clientX,y:s.clientY},m=s.button===2,e.style.cursor="grabbing";try{s.target.setPointerCapture(s.pointerId)}catch{}a&&a.pauseOnInteraction!==!1&&(c=!0)}}function x(s){if(d===null||s.pointerId!==d||!o||i)return;s.preventDefault();let E=s.clientX-h.x,g=s.clientY-h.y;h={x:s.clientX,y:s.clientY};let G=l;if(m||s.shiftKey)f.rotY=f.rotY-E*b*G,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*b*G));else{let z=f.target;f.target=[z[0]-E*C/f.zoom,z[1]-g*C/f.zoom,z[2]]}n.rerender()}function M(s){if(d===s.pointerId){d=null,m=!1,e.style.cursor=o&&!i?"grab":"";try{s.target.releasePointerCapture(s.pointerId)}catch{}a&&(c=!1)}}function y(s){s.preventDefault()}function w(s){if(!r||i)return;s.preventDefault();let E=s.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-E))),n.rerender()}function P(s){if(!(i||!a)){if(!c){let E=p!==null?Math.min(s-p,50):16.67,g=typeof a=="object"&&a.speed?a.speed:.3,G=typeof a=="object"&&a.axis?a.axis:"y",z=g*(E/16.67);G==="y"?f.rotY=f.rotY+z:f.rotX=f.rotX+z,n.rerender()}p=s,u=requestAnimationFrame(P)}}function H(){u===null&&typeof requestAnimationFrame<"u"&&a&&(u=requestAnimationFrame(P))}function v(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",x),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",y),e.addEventListener("wheel",w,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",x),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",y),e.removeEventListener("wheel",w),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),H(),{update(s){let E=!!a;o=s.drag??o,r=s.wheel??r,l=Yt(s.invert),a=s.animate??a,!i&&d===null&&(e.style.cursor=o?"grab":"");let g=!!a;E&&!g?v():!E&&g&&H()},pause(){i||(i=!0,L(),v(),d=null,c=!1)},resume(){i&&(i=!1,A(),H())},destroy(){i||L(),v(),i=!0}}}function Yt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Yn=typeof HTMLElement<"u"?HTMLElement:class{};function vt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Dn(n){return n.closest("glyph-scene")??null}var Ue=class extends Yn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=vt(this.getAttribute("drag")),o=vt(this.getAttribute("wheel")),r=vt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Dn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Dt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ve),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",$e),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",We),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",Ne),!customElements.get("glyph-camera")){class n extends Ne{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",qe),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",Ue)}0&&(module.exports={GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement});
package/dist/elements.js CHANGED
@@ -1,6 +1,6 @@
1
- import{buildTextureSamplers as hn}from"@glyphcss/core";var xt=Math.PI/180,Mt=.01,qt=32e3,Ut=Mt*1.01;function pt(n,e,t){let o=n[1],r=n[0],s=n[2],l=t*xt,i=Math.cos(l),c=Math.sin(l),u=o*i-r*c,p=o*c+r*i,d=s,m=e*xt,h=Math.cos(m),f=Math.sin(m),b=p*h-d*f,C=p*f+d*h;return[u,b,C]}function Ie(n={}){let e={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??qt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[t,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return e.rotX},set rotX(r){e.rotX=r},get rotY(){return e.rotY},set rotY(r){e.rotY=r},get distance(){return e.distance},set distance(r){e.distance=r},get perspective(){return e.perspective},set perspective(r){e.perspective=r},get zoom(){return e.zoom},set zoom(r){e.zoom=r},get stretch(){return e.stretch},set stretch(r){e.stretch=r},get fovScale(){return e.fovScale},set fovScale(r){e.fovScale=r},get target(){return e.target},set target(r){e.target=r},get eyeMode(){return e.eyeMode},set eyeMode(r){e.eyeMode=r},eyeDepth(r){let s=pt([r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],e.rotX,e.rotY),l=.001*1.01;if(e.eyeMode)return-s[2]-l;if(e.perspective>0){let i=s[2]*e.zoom*50-e.distance;return e.perspective-i-e.perspective*Ut}return e.distance-s[2]-l},project(r,s,l,i){let u=50/i,p=[r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],d=pt(p,e.rotX,e.rotY);if(e.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let y=e.focal/-d[2],w=d[0]*y*e.zoom*50,P=d[1]*y*e.zoom*50,H=s*t+w/u*e.stretch,v=l*o+P/50;return[H,v,d[2],-1/d[2]]}if(e.perspective>0){let x=e.perspective,y=d[0]*e.zoom*50,w=d[1]*e.zoom*50,P=d[2]*e.zoom*50-e.distance,H=x-P,v=x*Mt;if(H<v)return[NaN,NaN,P,NaN];let A=x/H,L=s*t+y*A/u*e.stretch*e.fovScale,a=l*o+w*A/50*e.fovScale;return[L,a,P,1/H]}let m=.001,h=e.distance-d[2];if(h<m)return[NaN,NaN,d[2],NaN];let f=e.distance/h,b=d[0]*f*e.zoom*50,C=d[1]*f*e.zoom*50,_=s*t+b/u*e.stretch*e.fovScale,M=l*o+C/50*e.fovScale;return[_,M,d[2],1/h]}}}function Ct(n={}){let e={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[t,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return e.rotX},set rotX(r){e.rotX=r},get rotY(){return e.rotY},set rotY(r){e.rotY=r},get distance(){return e.distance},set distance(r){e.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return e.zoom},set zoom(r){e.zoom=r},get stretch(){return e.stretch},set stretch(r){e.stretch=r},get fovScale(){return e.fovScale},set fovScale(r){e.fovScale=r},get target(){return e.target},set target(r){e.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,s,l,i){let u=50/i,p=[r[0]-e.target[0],r[1]-e.target[1],r[2]-e.target[2]],d=pt(p,e.rotX,e.rotY),m=d[0]*e.zoom*50,h=d[1]*e.zoom*50,f=s*t+m/u*e.fovScale,b=l*o+h/50*e.fovScale;return[f,b,d[2]]}}}var Kt={direction:[-.5,-.7,-.5],intensity:1},Zt={intensity:.4};function Jt(n){let e=new Set,t=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let l=r[s],i=r[(s+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${i[0]},${i[1]},${i[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(e.has(p))continue;e.add(p);let d={from:l,to:i,weight:2};o.color&&(d.color=o.color),t.push(d)}}return t}function Gt(n){let e=n.polygons??[],t=n.mode??(e.length?"solid":"wireframe"),o=n.wireframe??(t==="wireframe"?Jt(e):[]);return{camera:n.camera,grid:n.grid,polygons:e,wireframe:o,mode:t,directionalLight:n.directionalLight??Kt,ambientLight:n.ambientLight??Zt,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as Qt,polygonTexture as en}from"@glyphcss/core";var Dn=" .:-=+*#%@".split(""),Vn=" .:-=+*#%@".split(""),mt={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Xn=mt.default;function ht(n){return mt[n]??mt.default}function _t(n){let{camera:e,grid:t,wireframe:o,mode:r}=n,{cols:s,rows:l,cellAspect:i}=t;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return tn(n,s,l,i,d)}let c=ht(n.glyphPalette),u=new Uint8Array(s*l),p=n.useColors?new Array(s*l).fill(null):null;for(let d of o){let m=e.project(d.from,s,l,i),h=e.project(d.to,s,l,i);m[0]!==m[0]||h[0]!==h[0]||un(u,p,m[0]|0,m[1]|0,h[0]|0,h[1]|0,d.weight??2,d.color??null,s,l)}return dn(u,p,s,l,c)}function tn(n,e,t,o,r){let s=e*r,l=t*r,{camera:i,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:m,doubleSided:h,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,_=n.depthEpsilon??0,M=r>1?{zoom:i.zoom,eyeDepth:B=>i.eyeDepth(B),project:(B,V,X,Y)=>{let S=i.project(B,V,X,Y);return[V*.5+(S[0]-V*.5)*r,X*.5+(S[1]-X*.5)*r,S[2],S[3]]}}:i,x=ht(n.glyphPalette).solid,y=x.length-1,w=new Array(s*l).fill(" "),P=n.useColors,H=P?new Array(s*l).fill(null):null,v=new Float64Array(s*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(s*l*3).fill(NaN):null,a=u.direction,E=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/E,G=a[1]/E,z=a[2]/E,F=u.intensity??1,T=p.intensity??.4,W=ze(u.color??"#ffffff"),R=ze(p.color??"#ffffff"),j=d&&m>0?an(c,m):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?ln(c,f,g,G,z):null,oe=k?.opacity??.25,K=k?.lift??.05,Z=k?.color??"#000000",ie=q?ze(Z):[0,0,0],O=globalThis.__glyphPerfDetail,Ve=O?performance.now():0,ge=[],J=n.shadeCache??null,Q=-1,ve=(B,V,X,Y)=>{if(q===null||!Y)return null;let S=q,I=Oe(B,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Oe(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Oe(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:I[0],lvA:I[1],ldA:I[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:N}};for(let B=0;B<c.length;B++){let V=c[B],X=V.vertices;if(X.length<3)continue;let Y=V.uvs,S=null;if(re!==null&&Y&&Y.length>=X.length){let I=en(V);I&&(S=re.get(I)??null)}for(let I=0;I<X.length;I++)ge[I]=M.project(X[I],s,l,o);for(let I=1;I<X.length-1;I++){Q++;let ee=0,de=I,Ee=I+1,se=X[ee],pe=X[de],we=X[Ee],ae=ge[ee],ye=ge[de],xe=ge[Ee],rt=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(xe[0]!==xe[0]?1:0);if(rt===3||rt===0&&!h&&(ye[0]-ae[0])*(xe[1]-ae[1])-(ye[1]-ae[1])*(xe[0]-ae[0])>0)continue;let Ge,Le,Te,Re=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Re=J.lit[Q];else{let $=pe[0]-se[0],me=pe[1]-se[1],Ae=pe[2]-se[2],he=we[0]-se[0],$e=we[1]-se[1],We=we[2]-se[2],je=me*We-Ae*$e,Ne=Ae*he-$*We,U=$*$e-me*he,D=Math.hypot(je,Ne,U)||1,te=je/D,fe=Ne/D,le=U/D,ce,_e,ot,it,st,lt,at,ct,ut;if(j){let ke=j[B],Me=ke[ee],Fe=ke[de],Ye=ke[Ee];ce=Me[0],_e=Me[1],ot=Me[2],it=Fe[0],st=Fe[1],lt=Fe[2],at=Ye[0],ct=Ye[1],ut=Ye[2]}else ce=it=at=te,_e=st=ct=fe,ot=lt=ut=le;let Et=ce*g+_e*G+ot*z,wt=it*g+st*G+lt*z,At=at*g+ct*G+ut*z,Nt=h?Math.abs(Et):Math.max(0,-Et),kt=h?Math.abs(wt):Math.max(0,-wt),Yt=h?Math.abs(At):Math.max(0,-At);if(Ge=Math.min(1,T+Nt*F),Le=Math.min(1,T+kt*F),Te=Math.min(1,T+Yt*F),P){let ke=(Ge+Le+Te)/3,Me=Math.max(0,ke-T),Fe=V.color??"#ffffff",Ye=Me*255|0,St=`${Fe}:${Ye}`,qe=N.get(St);if(qe===void 0){let dt=ze(Fe),Dt=T*R[0]/255+Me*W[0]/255,Vt=T*R[1]/255+Me*W[1]/255,Xt=T*R[2]/255+Me*W[2]/255,$t=Math.min(255,dt[0]*Dt),Wt=Math.min(255,dt[1]*Vt),jt=Math.min(255,dt[2]*Xt);qe=`#${ne($t)}${ne(Wt)}${ne(jt)}`,N.set(St,qe)}Re=qe}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Re)}let bt=b[B]??!1,He=1+(C?.[B]??0),vt=null;if(S!==null&&Y){let $=Y[ee],me=Y[de],Ae=Y[Ee],he=Math.max(0,(Ge+Le+Te)/3-T);vt={sampler:S,ua:$[0],va:$[1],ub:me[0],vb:me[1],uc:Ae[0],vc:Ae[1],tintR:T*R[0]/255+he*W[0]/255,tintG:T*R[1]/255+he*W[1]/255,tintB:T*R[2]/255+he*W[2]/255}}if(rt===0)Lt(ae[0],ae[1],(ae[3]??ae[2])*He,Ge,ye[0],ye[1],(ye[3]??ye[2])*He,Le,xe[0],xe[1],(xe[3]??xe[2])*He,Te,x,y,Re,w,H,v,s,l,ve(se,pe,we,bt),h,se,pe,we,L,_,vt);else{let $=[],me=[],Ae=[se,pe,we],he=[Ge,Le,Te],$e=M.eyeDepth(se),We=M.eyeDepth(pe),je=M.eyeDepth(we),Ne=[$e,We,je];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ne[U],fe=Ne[D];if(te>0&&($.push(Ae[U]),me.push(he[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[D];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),me.push(he[U]+le*(he[D]-he[U]))}}if($.length>=3){let U=$.map(D=>M.project(D,s,l,o));for(let D=1;D<$.length-1;D++){let te=U[0],fe=U[D],le=U[D+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!h&&ce>0||Lt(te[0],te[1],(te[3]??te[2])*He,me[0],fe[0],fe[1],(fe[3]??fe[2])*He,me[D],le[0],le[1],(le[3]??le[2])*He,me[D+1],x,y,Re,w,H,v,s,l,ve($[0],$[D],$[D+1],bt),h,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Ve);let yt=O?performance.now():0,Pe=w,Se=H,Xe=L;if(r>1){let B=rn(w,H,v,L,e,t,r,x);Pe=B.glyphBuf,Se=B.colorBuf,Xe=B.worldPos}A&&nn(Pe,Se,Xe,e,t,o,x,n.temporalBlend,n.temporalHistory,i);let nt=cn(Pe,Se,e,t);return O&&(O.string??(O.string=[])).push(performance.now()-yt),nt}function nn(n,e,t,o,r,s,l,i,c,u){let p=o*r,d=l.length-1,m=new Map;for(let x=0;x<l.length;x++)m.set(l[x],x);let h=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),h=null);let f=null;if(h){let x=Ie({rotX:h.rotX,rotY:h.rotY,distance:h.distance,perspective:h.perspective,zoom:h.zoom,stretch:h.stretch});x.target=h.target,f=y=>x.project(y,o,r,s)}let b=new Float32Array(p),C=new Float32Array(p),_=new Float32Array(p),M=new Float32Array(p);for(let x=0;x<r;x++)for(let y=0;y<o;y++){let w=x*o+y,P=m.get(n[w])??0,H=0,v=0,A=0,L=e?e[w]:null;if(L){let k=ze(L);H=k[0],v=k[1],A=k[2]}let a=0,E=0,g=0,G=0,z=0,F=t[w*3];if(f&&F===F){let k=f([F,t[w*3+1],t[w*3+2]]),q=Math.round(k[0]),oe=Math.round(k[1]);if(k[0]===k[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;E=c.idx[K],g=c.r[K],G=c.g[K],z=c.b[K],a=i}}let T=1-a,W=T*P+a*E,R=T*H+a*g,j=T*v+a*G,N=T*A+a*z;b[w]=W,C[w]=R,_[w]=j,M[w]=N;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[w]=l[re],e&&(e[w]=re===0?null:`#${ne(R)}${ne(j)}${ne(N)}`)}c.idx=b,c.r=C,c.g=_,c.b=M,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function rn(n,e,t,o,r,s,l,i){let c=new Map;for(let b=0;b<i.length;b++)c.set(i[b],b);let u=i.length-1,p=r*l,d=new Array(r*s).fill(" "),m=e?new Array(r*s).fill(null):null,h=o?new Float32Array(r*s*3).fill(NaN):null,f=1/(l*l);for(let b=0;b<s;b++)for(let C=0;C<r;C++){let _=0,M=0,x=0,y=0,w=0,P=0,H=0,v=0;for(let a=0;a<l;a++){let E=(b*l+a)*p+C*l;for(let g=0;g<l;g++){let G=E+g;if(t[G]!==-1/0){if(_+=c.get(n[G])??0,M++,m){let z=e[G];if(z){let F=ze(z);x+=F[0],y+=F[1],w+=F[2]}}h&&(P+=o[G*3],H+=o[G*3+1],v+=o[G*3+2])}}}let A=b*r+C;if(M===0)continue;let L=Math.round(_*f);L<0?L=0:L>u&&(L=u),d[A]=i[L],m&&(m[A]=`#${ne(x/M)}${ne(y/M)}${ne(w/M)}`),h&&(h[A*3]=P/M,h[A*3+1]=H/M,h[A*3+2]=v/M)}return{glyphBuf:d,colorBuf:m,worldPos:h}}var on=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Oe(n,e,t,o,r,s,l,i,c,u,p,d,m,h){let f=e*n[0]+t*n[1]+o*n[2],b=r*n[0]+s*n[1]+l*n[2],C=-(i*n[0]+c*n[1]+u*n[2]),_=(f-p)/(d-p)*(be-1),M=(b-m)/(h-m)*(be-1);return[_,M,C]}function sn(n,e,t,o){let r=e[0],s=e[1],l=e[2],i=t[0],c=t[1],u=t[2],p=o[0],d=o[1],m=o[2],h=(i-r)*(d-s)-(c-s)*(p-r);if(h===0)return;let f=1/h,b=r<i?r:i;p<b&&(b=p);let C=r>i?r:i;p>C&&(C=p);let _=s<c?s:c;d<_&&(_=d);let M=s>c?s:c;d>M&&(M=d);let x=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),w=Math.max(0,Math.ceil(_)),P=Math.min(be-1,Math.floor(M));if(x>y||w>P)return;let H=h>0;for(let v=w;v<=P;v++)for(let A=x;A<=y;A++){let L=A,a=v,E=(i-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(s-a)-(d-a)*(r-L),G=(r-L)*(c-a)-(s-a)*(i-L);if(H?E<0||g<0||G<0:E>0||g>0||G>0)continue;let z=(E*l+g*u+G*m)*f,F=v*be+A;z>n[F]&&(n[F]=z)}}function ln(n,e,t,o,r){let s,l,i;Math.abs(t)<.9?(s=0,l=r,i=-o):(s=-r,l=0,i=t);let c=Math.hypot(s,l,i);s/=c,l/=c,i/=c;let u=l*r-i*o,p=i*t-s*r,d=s*o-l*t,m=1/0,h=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(e[y]){C=!0;for(let w of n[y].vertices){let P=s*w[0]+l*w[1]+i*w[2],H=u*w[0]+p*w[1]+d*w[2];P<m&&(m=P),P>h&&(h=P),H<f&&(f=H),H>b&&(b=H)}}if(!C)return null;let _=(h-m)*.05+.01,M=(b-f)*.05+.01;m-=_,h+=_,f-=M,b+=M;let x=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!e[y])continue;let w=n[y].vertices;if(!(w.length<3))for(let P=1;P<w.length-1;P++){let H=w[0],v=w[P],A=w[P+1],L=Oe(H,s,l,i,u,p,d,t,o,r,m,h,f,b),a=Oe(v,s,l,i,u,p,d,t,o,r,m,h,f,b),E=Oe(A,s,l,i,u,p,d,t,o,r,m,h,f,b);sn(x,L,a,E)}}return{buf:x,right:[s,l,i],up:[u,p,d],dir:[t,o,r],uMin:m,uMax:h,vMin:f,vMax:b}}function Lt(n,e,t,o,r,s,l,i,c,u,p,d,m,h,f,b,C,_,M,x,y,w,P,H,v,A,L,a){let E=(r-n)*(u-e)-(s-e)*(c-n);if(E===0||!w&&E>0)return;let g=1/E,G=E>0,z=n<r?n:r;c<z&&(z=c);let F=n>r?n:r;c>F&&(F=c);let T=e<s?e:s;u<T&&(T=u);let W=e>s?e:s;u>W&&(W=u);let R=Math.max(0,Math.ceil(z)),j=Math.min(M-1,Math.floor(F)),N=Math.max(0,Math.ceil(T)),re=Math.min(x-1,Math.floor(W));if(!(R>j||N>re))for(let k=N;k<=re;k++){let q=k;for(let oe=R;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(s-q)*(c-K),ie=(c-K)*(e-q)-(u-q)*(n-K),O=(n-K)*(s-q)-(e-q)*(r-K);if(G?Z<0||ie<0||O<0:Z>0||ie>0||O>0)continue;let Ve=(Z*t+ie*l+O*p)*g,ge=k*M+oe,J=_[ge];if(Ve>(J>0?J*(1-L):J)){if(_[ge]=Ve,A!==null){let V=ge*3;A[V]=(Z*P[0]+ie*H[0]+O*v[0])*g,A[V+1]=(Z*P[1]+ie*H[1]+O*v[1])*g,A[V+2]=(Z*P[2]+ie*H[2]+O*v[2])*g}let Q=(Z*o+ie*i+O*d)*g,ve=f;if(a!==null){let V=(Z*a.ua+ie*a.ub+O*a.uc)*g,X=(Z*a.va+ie*a.vb+O*a.vc)*g,Y=Qt(a.sampler,V,X);if(Y!==null&&Y.a>8){let S=Y.r*a.tintR|0;S>255&&(S=255);let I=Y.g*a.tintG|0;I>255&&(I=255);let ee=Y.b*a.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(I)}${ne(ee)}`,Q*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Pe=(Q<0?0:Q>1?1:Q)*h,Se=Pe|0,Xe=Pe-Se,nt=on[(k&3)*4+(oe&3)],B=Xe>nt&&Se<h?Se+1:Se;if(B>h&&(B=h),y!==null){let V=(Z*y.luA+ie*y.luB+O*y.luC)*g,X=(Z*y.lvA+ie*y.lvB+O*y.lvC)*g,Y=(Z*y.ldA+ie*y.ldB+O*y.ldC)*g,S=V|0,I=X|0;if(S>=0&&S<be&&I>=0&&I<be){let ee=y.map.buf[I*be+S];if(ee>-1/0&&Y+y.lift<ee&&(B=Math.max(0,B-Math.round(y.opacity*h)),ve!==null)){let de=`shadow:${ve}:${B}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=y.shadowColorRgb,we=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ae=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ye=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ye)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ge]=m[B],C&&(C[ge]=ve)}}}}function an(n,e){let t=n.length,o=new Array(t);for(let i=0;i<t;i++){let c=n[i].vertices;if(c.length<3){o[i]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],m=p[0]-u[0],h=p[1]-u[1],f=p[2]-u[2],b=d[0]-u[0],C=d[1]-u[1],_=d[2]-u[2],M=h*_-f*C,x=f*b-m*_,y=m*C-h*b,w=Math.hypot(M,x,y)||1;o[i]=[M/w,x/w,y/w]}let r=new Map;for(let i=0;i<t;i++){let c=n[i].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,m=r.get(d);m||(m=[],r.set(d,m)),(m.length===0||m[m.length-1]!==i)&&m.push(i)}}let s=Math.cos(e*Math.PI/180),l=new Array(t);for(let i=0;i<t;i++){let c=n[i].vertices,u=o[i],p=new Array(c.length);for(let d=0;d<c.length;d++){let m=c[d],h=r.get(`${m[0]},${m[1]},${m[2]}`),f=0,b=0,C=0;for(let M=0;M<h.length;M++){let x=h[M],y=o[x];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(f+=y[0],b+=y[1],C+=y[2])}let _=Math.hypot(f,b,C)||1;p[d]=[f/_,b/_,C/_]}l[i]=p}return l}function cn(n,e,t,o){let r=[],s=null,l="",i=()=>{l&&(s!==null?r.push(`<span style="color:${s}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<t;u++){let p=c*t+u,d=n[p],m=e&&d!==" "?e[p]??null:null;m!==s&&(i(),s=m),l+=d}i(),s=null,c<o-1&&r.push(`
2
- `)}return r.join("")}function un(n,e,t,o,r,s,l,i,c,u){let p=Math.abs(r-t),d=-Math.abs(s-o),m=t<r?1:-1,h=o<s?1:-1,f=p+d;for(;;){if(t>=0&&t<c&&o>=0&&o<u){let C=o*c+t;n[C]<l&&(n[C]=l,e&&(e[C]=i))}if(t===r&&o===s)break;let b=2*f;b>=d&&(f+=d,t+=m),b<=p&&(f+=p,o+=h)}}function dn(n,e,t,o,r){let s=[],l=null,i="",c=()=>{i&&(l!==null?s.push(`<span style="color:${l}">${i}</span>`):s.push(i),i="")};for(let u=0;u<o;u++){for(let p=0;p<t;p++){let d=u*t+p,m=n[d],h,f;m===0?(h=" ",f=null):(h=m===1?r.thin[Math.random()*r.thin.length|0]:m===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=e?e[d]??null:null),f!==l&&(c(),l=f),i+=h}c(),l=null,u<o-1&&s.push(`
3
- `)}return s.join("")}var Tt=new Map;function ze(n){let e=Tt.get(n);if(e!==void 0)return e;let t=pn(n);return Tt.set(n,t),t}function pn(n){let e=n.startsWith("#")?n.slice(1):n;if(e.length===3){let t=parseInt(e[0]+e[0],16),o=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16);return[t||0,o||0,r||0]}if(e.length===6){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return[t||0,o||0,r||0]}return[255,255,255]}function ne(n){let e=Math.max(0,Math.min(255,n|0)).toString(16);return e.length===1?"0"+e:e}var zt="glyph-styles";function Pt(n){let e=n??(typeof document<"u"?document:void 0);if(!e||e.getElementById(zt))return;let t=e.createElement("style");t.id=zt,t.textContent=mn,e.head.appendChild(t)}var mn=`
1
+ import{buildTextureSamplers as mn}from"@glyphcss/core";var Mt=Math.PI/180,xt=.01,qt=32e3,Ut=xt*1.01;function pt(n,t,e){let o=n[1],r=n[0],l=n[2],a=e*Mt,i=Math.cos(a),c=Math.sin(a),u=o*i-r*c,p=o*c+r*i,d=l,h=t*Mt,m=Math.cos(h),f=Math.sin(h),b=p*m-d*f,C=p*f+d*m;return[u,b,C]}function Ie(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??qt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let l=pt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),a=.001*1.01;if(t.eyeMode)return-l[2]-a;if(t.perspective>0){let i=l[2]*t.zoom*50-t.distance;return t.perspective-i-t.perspective*Ut}return t.distance-l[2]-a},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=pt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let y=t.focal/-d[2],w=d[0]*y*t.zoom*50,P=d[1]*y*t.zoom*50,H=l*e+w/u*t.stretch,v=a*o+P/50;return[H,v,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,y=d[0]*t.zoom*50,w=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,H=M-P,v=M*xt;if(H<v)return[NaN,NaN,P,NaN];let A=M/H,L=l*e+y*A/u*t.stretch*t.fovScale,s=a*o+w*A/50*t.fovScale;return[L,s,P,1/H]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,b=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,_=l*e+b/u*t.stretch*t.fovScale,x=a*o+C/50*t.fovScale;return[_,x,d[2],1/m]}}}function Ct(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=pt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=l*e+h/u*t.fovScale,b=a*o+m/50*t.fovScale;return[f,b,d[2]]}}}var Kt={direction:[-.5,-.7,-.5],intensity:1},Zt={intensity:.4};function Jt(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let l=0;l<r.length;l++){let a=r[l],i=r[(l+1)%r.length],c=`${a[0]},${a[1]},${a[2]}`,u=`${i[0]},${i[1]},${i[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:a,to:i,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function Gt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?Jt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Kt,ambientLight:n.ambientLight??Zt,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as Qt,polygonTexture as en}from"@glyphcss/core";var Yn=" .:-=+*#%@".split(""),Dn=" .:-=+*#%@".split(""),ht={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Xn=ht.default;function mt(n){return ht[n]??ht.default}function _t(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:l,rows:a,cellAspect:i}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return tn(n,l,a,i,d)}let c=mt(n.glyphPalette),u=new Uint8Array(l*a),p=n.useColors?new Array(l*a).fill(null):null;for(let d of o){let h=t.project(d.from,l,a,i),m=t.project(d.to,l,a,i);h[0]!==h[0]||m[0]!==m[0]||un(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,l,a)}return dn(u,p,l,a,c)}function tn(n,t,e,o,r){let l=t*r,a=e*r,{camera:i,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,_=n.depthEpsilon??0,x=r>1?{zoom:i.zoom,eyeDepth:B=>i.eyeDepth(B),project:(B,X,V,Y)=>{let S=i.project(B,X,V,Y);return[X*.5+(S[0]-X*.5)*r,V*.5+(S[1]-V*.5)*r,S[2],S[3]]}}:i,M=mt(n.glyphPalette).solid,y=M.length-1,w=new Array(l*a).fill(" "),P=n.useColors,H=P?new Array(l*a).fill(null):null,v=new Float64Array(l*a).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(l*a*3).fill(NaN):null,s=u.direction,E=Math.hypot(s[0],s[1],s[2])||1,g=s[0]/E,G=s[1]/E,z=s[2]/E,F=u.intensity??1,T=p.intensity??.4,W=ze(u.color??"#ffffff"),R=ze(p.color??"#ffffff"),j=d&&h>0?an(c,h):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?ln(c,f,g,G,z):null,oe=k?.opacity??.25,K=k?.lift??.05,Z=k?.color??"#000000",ie=q?ze(Z):[0,0,0],O=globalThis.__glyphPerfDetail,Xe=O?performance.now():0,ge=[],J=n.shadeCache??null,Q=-1,ve=(B,X,V,Y)=>{if(q===null||!Y)return null;let S=q,I=Oe(B,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Oe(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Oe(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:I[0],lvA:I[1],ldA:I[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:N}};for(let B=0;B<c.length;B++){let X=c[B],V=X.vertices;if(V.length<3)continue;let Y=X.uvs,S=null;if(re!==null&&Y&&Y.length>=V.length){let I=en(X);I&&(S=re.get(I)??null)}for(let I=0;I<V.length;I++)ge[I]=x.project(V[I],l,a,o);for(let I=1;I<V.length-1;I++){Q++;let ee=0,de=I,Ee=I+1,se=V[ee],pe=V[de],we=V[Ee],ae=ge[ee],ye=ge[de],Me=ge[Ee],rt=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(Me[0]!==Me[0]?1:0);if(rt===3||rt===0&&!m&&(ye[0]-ae[0])*(Me[1]-ae[1])-(ye[1]-ae[1])*(Me[0]-ae[0])>0)continue;let Ge,Le,Te,Re=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Re=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],$e=we[1]-se[1],We=we[2]-se[2],je=he*We-Ae*$e,Ne=Ae*me-$*We,U=$*$e-he*me,D=Math.hypot(je,Ne,U)||1,te=je/D,fe=Ne/D,le=U/D,ce,_e,ot,it,st,lt,at,ct,ut;if(j){let ke=j[B],xe=ke[ee],Fe=ke[de],Ye=ke[Ee];ce=xe[0],_e=xe[1],ot=xe[2],it=Fe[0],st=Fe[1],lt=Fe[2],at=Ye[0],ct=Ye[1],ut=Ye[2]}else ce=it=at=te,_e=st=ct=fe,ot=lt=ut=le;let Et=ce*g+_e*G+ot*z,wt=it*g+st*G+lt*z,At=at*g+ct*G+ut*z,Nt=m?Math.abs(Et):Math.max(0,-Et),kt=m?Math.abs(wt):Math.max(0,-wt),Yt=m?Math.abs(At):Math.max(0,-At);if(Ge=Math.min(1,T+Nt*F),Le=Math.min(1,T+kt*F),Te=Math.min(1,T+Yt*F),P){let ke=(Ge+Le+Te)/3,xe=Math.max(0,ke-T),Fe=X.color??"#ffffff",Ye=xe*255|0,St=`${Fe}:${Ye}`,qe=N.get(St);if(qe===void 0){let dt=ze(Fe),Dt=T*R[0]/255+xe*W[0]/255,Xt=T*R[1]/255+xe*W[1]/255,Vt=T*R[2]/255+xe*W[2]/255,$t=Math.min(255,dt[0]*Dt),Wt=Math.min(255,dt[1]*Xt),jt=Math.min(255,dt[2]*Vt);qe=`#${ne($t)}${ne(Wt)}${ne(jt)}`,N.set(St,qe)}Re=qe}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Re)}let bt=b[B]??!1,He=1+(C?.[B]??0),vt=null;if(S!==null&&Y){let $=Y[ee],he=Y[de],Ae=Y[Ee],me=Math.max(0,(Ge+Le+Te)/3-T);vt={sampler:S,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:Ae[0],vc:Ae[1],tintR:T*R[0]/255+me*W[0]/255,tintG:T*R[1]/255+me*W[1]/255,tintB:T*R[2]/255+me*W[2]/255}}if(rt===0)Lt(ae[0],ae[1],(ae[3]??ae[2])*He,Ge,ye[0],ye[1],(ye[3]??ye[2])*He,Le,Me[0],Me[1],(Me[3]??Me[2])*He,Te,M,y,Re,w,H,v,l,a,ve(se,pe,we,bt),m,se,pe,we,L,_,vt);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],$e=x.eyeDepth(se),We=x.eyeDepth(pe),je=x.eyeDepth(we),Ne=[$e,We,je];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ne[U],fe=Ne[D];if(te>0&&($.push(Ae[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[D];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[D]-me[U]))}}if($.length>=3){let U=$.map(D=>x.project(D,l,a,o));for(let D=1;D<$.length-1;D++){let te=U[0],fe=U[D],le=U[D+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||Lt(te[0],te[1],(te[3]??te[2])*He,he[0],fe[0],fe[1],(fe[3]??fe[2])*He,he[D],le[0],le[1],(le[3]??le[2])*He,he[D+1],M,y,Re,w,H,v,l,a,ve($[0],$[D],$[D+1],bt),m,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Xe);let yt=O?performance.now():0,Pe=w,Se=H,Ve=L;if(r>1){let B=rn(w,H,v,L,t,e,r,M);Pe=B.glyphBuf,Se=B.colorBuf,Ve=B.worldPos}A&&nn(Pe,Se,Ve,t,e,o,M,n.temporalBlend,n.temporalHistory,i);let nt=cn(Pe,Se,t,e);return O&&(O.string??(O.string=[])).push(performance.now()-yt),nt}function nn(n,t,e,o,r,l,a,i,c,u){let p=o*r,d=a.length-1,h=new Map;for(let M=0;M<a.length;M++)h.set(a[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Ie({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=y=>M.project(y,o,r,l)}let b=new Float32Array(p),C=new Float32Array(p),_=new Float32Array(p),x=new Float32Array(p);for(let M=0;M<r;M++)for(let y=0;y<o;y++){let w=M*o+y,P=h.get(n[w])??0,H=0,v=0,A=0,L=t?t[w]:null;if(L){let k=ze(L);H=k[0],v=k[1],A=k[2]}let s=0,E=0,g=0,G=0,z=0,F=e[w*3];if(f&&F===F){let k=f([F,e[w*3+1],e[w*3+2]]),q=Math.round(k[0]),oe=Math.round(k[1]);if(k[0]===k[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;E=c.idx[K],g=c.r[K],G=c.g[K],z=c.b[K],s=i}}let T=1-s,W=T*P+s*E,R=T*H+s*g,j=T*v+s*G,N=T*A+s*z;b[w]=W,C[w]=R,_[w]=j,x[w]=N;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[w]=a[re],t&&(t[w]=re===0?null:`#${ne(R)}${ne(j)}${ne(N)}`)}c.idx=b,c.r=C,c.g=_,c.b=x,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function rn(n,t,e,o,r,l,a,i){let c=new Map;for(let b=0;b<i.length;b++)c.set(i[b],b);let u=i.length-1,p=r*a,d=new Array(r*l).fill(" "),h=t?new Array(r*l).fill(null):null,m=o?new Float32Array(r*l*3).fill(NaN):null,f=1/(a*a);for(let b=0;b<l;b++)for(let C=0;C<r;C++){let _=0,x=0,M=0,y=0,w=0,P=0,H=0,v=0;for(let s=0;s<a;s++){let E=(b*a+s)*p+C*a;for(let g=0;g<a;g++){let G=E+g;if(e[G]!==-1/0){if(_+=c.get(n[G])??0,x++,h){let z=t[G];if(z){let F=ze(z);M+=F[0],y+=F[1],w+=F[2]}}m&&(P+=o[G*3],H+=o[G*3+1],v+=o[G*3+2])}}}let A=b*r+C;if(x===0)continue;let L=Math.round(_*f);L<0?L=0:L>u&&(L=u),d[A]=i[L],h&&(h[A]=`#${ne(M/x)}${ne(y/x)}${ne(w/x)}`),m&&(m[A*3]=P/x,m[A*3+1]=H/x,m[A*3+2]=v/x)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var on=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Oe(n,t,e,o,r,l,a,i,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],b=r*n[0]+l*n[1]+a*n[2],C=-(i*n[0]+c*n[1]+u*n[2]),_=(f-p)/(d-p)*(be-1),x=(b-h)/(m-h)*(be-1);return[_,x,C]}function sn(n,t,e,o){let r=t[0],l=t[1],a=t[2],i=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(i-r)*(d-l)-(c-l)*(p-r);if(m===0)return;let f=1/m,b=r<i?r:i;p<b&&(b=p);let C=r>i?r:i;p>C&&(C=p);let _=l<c?l:c;d<_&&(_=d);let x=l>c?l:c;d>x&&(x=d);let M=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),w=Math.max(0,Math.ceil(_)),P=Math.min(be-1,Math.floor(x));if(M>y||w>P)return;let H=m>0;for(let v=w;v<=P;v++)for(let A=M;A<=y;A++){let L=A,s=v,E=(i-L)*(d-s)-(c-s)*(p-L),g=(p-L)*(l-s)-(d-s)*(r-L),G=(r-L)*(c-s)-(l-s)*(i-L);if(H?E<0||g<0||G<0:E>0||g>0||G>0)continue;let z=(E*a+g*u+G*h)*f,F=v*be+A;z>n[F]&&(n[F]=z)}}function ln(n,t,e,o,r){let l,a,i;Math.abs(e)<.9?(l=0,a=r,i=-o):(l=-r,a=0,i=e);let c=Math.hypot(l,a,i);l/=c,a/=c,i/=c;let u=a*r-i*o,p=i*e-l*r,d=l*o-a*e,h=1/0,m=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(t[y]){C=!0;for(let w of n[y].vertices){let P=l*w[0]+a*w[1]+i*w[2],H=u*w[0]+p*w[1]+d*w[2];P<h&&(h=P),P>m&&(m=P),H<f&&(f=H),H>b&&(b=H)}}if(!C)return null;let _=(m-h)*.05+.01,x=(b-f)*.05+.01;h-=_,m+=_,f-=x,b+=x;let M=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let w=n[y].vertices;if(!(w.length<3))for(let P=1;P<w.length-1;P++){let H=w[0],v=w[P],A=w[P+1],L=Oe(H,l,a,i,u,p,d,e,o,r,h,m,f,b),s=Oe(v,l,a,i,u,p,d,e,o,r,h,m,f,b),E=Oe(A,l,a,i,u,p,d,e,o,r,h,m,f,b);sn(M,L,s,E)}}return{buf:M,right:[l,a,i],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:b}}function Lt(n,t,e,o,r,l,a,i,c,u,p,d,h,m,f,b,C,_,x,M,y,w,P,H,v,A,L,s){let E=(r-n)*(u-t)-(l-t)*(c-n);if(E===0||!w&&E>0)return;let g=1/E,G=E>0,z=n<r?n:r;c<z&&(z=c);let F=n>r?n:r;c>F&&(F=c);let T=t<l?t:l;u<T&&(T=u);let W=t>l?t:l;u>W&&(W=u);let R=Math.max(0,Math.ceil(z)),j=Math.min(x-1,Math.floor(F)),N=Math.max(0,Math.ceil(T)),re=Math.min(M-1,Math.floor(W));if(!(R>j||N>re))for(let k=N;k<=re;k++){let q=k;for(let oe=R;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(l-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),O=(n-K)*(l-q)-(t-q)*(r-K);if(G?Z<0||ie<0||O<0:Z>0||ie>0||O>0)continue;let Xe=(Z*e+ie*a+O*p)*g,ge=k*x+oe,J=_[ge];if(Xe>(J>0?J*(1-L):J)){if(_[ge]=Xe,A!==null){let X=ge*3;A[X]=(Z*P[0]+ie*H[0]+O*v[0])*g,A[X+1]=(Z*P[1]+ie*H[1]+O*v[1])*g,A[X+2]=(Z*P[2]+ie*H[2]+O*v[2])*g}let Q=(Z*o+ie*i+O*d)*g,ve=f;if(s!==null){let X=(Z*s.ua+ie*s.ub+O*s.uc)*g,V=(Z*s.va+ie*s.vb+O*s.vc)*g,Y=Qt(s.sampler,X,V);if(Y!==null&&Y.a>8){let S=Y.r*s.tintR|0;S>255&&(S=255);let I=Y.g*s.tintG|0;I>255&&(I=255);let ee=Y.b*s.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(I)}${ne(ee)}`,Q*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Pe=(Q<0?0:Q>1?1:Q)*m,Se=Pe|0,Ve=Pe-Se,nt=on[(k&3)*4+(oe&3)],B=Ve>nt&&Se<m?Se+1:Se;if(B>m&&(B=m),y!==null){let X=(Z*y.luA+ie*y.luB+O*y.luC)*g,V=(Z*y.lvA+ie*y.lvB+O*y.lvC)*g,Y=(Z*y.ldA+ie*y.ldB+O*y.ldC)*g,S=X|0,I=V|0;if(S>=0&&S<be&&I>=0&&I<be){let ee=y.map.buf[I*be+S];if(ee>-1/0&&Y+y.lift<ee&&(B=Math.max(0,B-Math.round(y.opacity*m)),ve!==null)){let de=`shadow:${ve}:${B}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=y.shadowColorRgb,we=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ae=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ye=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ye)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ge]=h[B],C&&(C[ge]=ve)}}}}function an(n,t){let e=n.length,o=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices;if(c.length<3){o[i]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],b=d[0]-u[0],C=d[1]-u[1],_=d[2]-u[2],x=m*_-f*C,M=f*b-h*_,y=h*C-m*b,w=Math.hypot(x,M,y)||1;o[i]=[x/w,M/w,y/w]}let r=new Map;for(let i=0;i<e;i++){let c=n[i].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==i)&&h.push(i)}}let l=Math.cos(t*Math.PI/180),a=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices,u=o[i],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,b=0,C=0;for(let x=0;x<m.length;x++){let M=m[x],y=o[M];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=l&&(f+=y[0],b+=y[1],C+=y[2])}let _=Math.hypot(f,b,C)||1;p[d]=[f/_,b/_,C/_]}a[i]=p}return a}function cn(n,t,e,o){let r=[],l=null,a="",i=()=>{a&&(l!==null?r.push(`<span style="color:${l}">${a}</span>`):r.push(a),a="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==l&&(i(),l=h),a+=d}i(),l=null,c<o-1&&r.push(`
2
+ `)}return r.join("")}function un(n,t,e,o,r,l,a,i,c,u){let p=Math.abs(r-e),d=-Math.abs(l-o),h=e<r?1:-1,m=o<l?1:-1,f=p+d;for(;;){if(e>=0&&e<c&&o>=0&&o<u){let C=o*c+e;n[C]<a&&(n[C]=a,t&&(t[C]=i))}if(e===r&&o===l)break;let b=2*f;b>=d&&(f+=d,e+=h),b<=p&&(f+=p,o+=m)}}function dn(n,t,e,o,r){let l=[],a=null,i="",c=()=>{i&&(a!==null?l.push(`<span style="color:${a}">${i}</span>`):l.push(i),i="")};for(let u=0;u<o;u++){for(let p=0;p<e;p++){let d=u*e+p,h=n[d],m,f;h===0?(m=" ",f=null):(m=h===1?r.thin[Math.random()*r.thin.length|0]:h===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[d]??null:null),f!==a&&(c(),a=f),i+=m}c(),a=null,u<o-1&&l.push(`
3
+ `)}return l.join("")}var Tt=new Map;function ze(n){let t=Tt.get(n);if(t!==void 0)return t;let e=pn(n);return Tt.set(n,e),e}function pn(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function ne(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var zt="glyph-styles";function Pt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(zt))return;let e=t.createElement("style");e.id=zt,e.textContent=hn,t.head.appendChild(e)}var hn=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5
5
 
6
6
  .glyph-host {
@@ -59,5 +59,5 @@ import{buildTextureSamplers as hn}from"@glyphcss/core";var xt=Math.PI/180,Mt=.01
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function Ht(n,e,t,o,r){return n.map(s=>{let[l,i,c]=e.project(s.at,t,o,r),u=c>-3&&l>=0&&l<t&&i>=0&&i<o;return{id:s.id,col:l,row:i,depth:c,visible:u}})}var fn=1;function gn(n,e){let{position:t,scale:o,rotation:r}=e;if(!t&&!o&&!r)return n;let[s,l,i]=t??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[m,h,f]=r??[0,0,0],b=m*d,C=h*d,_=f*d,M=Math.cos(b),x=Math.sin(b),y=Math.cos(C),w=Math.sin(C),P=Math.cos(_),H=Math.sin(_);function v(A){let L=A[0]*c,a=A[1]*u,E=A[2]*p,g=P*L-H*a,G=H*L+P*a,z=E;return L=y*g+w*z,a=G,E=-w*g+y*z,g=L,G=M*a-x*E,z=x*a+M*E,[g+s,G+l,z+i]}return n.map(A=>({...A,vertices:A.vertices.map(v)}))}function Ft(n,e={}){Pt(n.ownerDocument??void 0);let t={mode:e.mode??"solid",glyphPalette:e.glyphPalette??"default",useColors:e.useColors??!0,cols:e.cols??80,rows:e.rows??24,cellAspect:e.cellAspect??2,directionalLight:e.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:e.ambientLight??{intensity:.4},camera:e.camera??Ie(),smoothShading:e.smoothShading??!1,creaseAngle:e.creaseAngle??60,doubleSided:e.doubleSided??!1,supersample:e.supersample??1,depthEpsilon:e.depthEpsilon??0,temporalBlend:e.temporalBlend??0,autoSize:e.autoSize??!1,shadow:e.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let l=new Map,i=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let m=null,h=0;function f(){let a=[];for(let g of l.values())for(let G of g.polygons)(G.texture||G.material?.texture)&&a.push(G);if(a.length===0){m&&(m=null,b());return}let E=++h;hn(a).then(g=>{E===h&&(m=g.size>0?g:null,b())})}function b(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],E=[],g=[],G=[],z=!1;for(let N of l.values()){let re=gn(N.polygons,N.transform),k=N.transform.castShadow??!1,q=N.transform.receiveShadow??!1,oe=N.transform.depthBias??0;oe!==0&&(z=!0);for(let K of re)a.push(K),E.push(k),g.push(q),G.push(oe)}let F=Gt({camera:t.camera,grid:{cols:t.cols,rows:t.rows,cellAspect:t.cellAspect},polygons:a,mode:t.mode,directionalLight:t.directionalLight,ambientLight:t.ambientLight,glyphPalette:t.glyphPalette,useColors:t.useColors,smoothShading:t.smoothShading,creaseAngle:t.creaseAngle,doubleSided:t.doubleSided,supersample:t.supersample,depthEpsilon:t.depthEpsilon,temporalBlend:t.temporalBlend,shadow:t.shadow,castShadowFlags:E,receiveShadowFlags:g,depthBiases:z?G:void 0});F.shadeCache=u,F.textureSamplers=m,F.temporalHistory=p;let T=globalThis.__glyphPerf,W=T?performance.now():0,R=_t(F),j=T?performance.now():0;if(t.useColors?r.innerHTML=R:r.textContent=R,T){let N=performance.now();(T.raster??(T.raster=[])).push(j-W),(T.dom??(T.dom=[])).push(N-j),(T.polys??(T.polys=[])).push(a.length)}_()}function _(){let{cols:a,rows:E,cellAspect:g,camera:G}=t,z=Ht(i.map(R=>R.hotspot),G,a,E,g),F=r.getBoundingClientRect(),T=a>0?F.width/a:8,W=E>0?F.height/E:16;for(let R=0;R<i.length;R++){let{el:j}=i[R],N=z[R];N.visible?(j.style.display="",j.style.left=`${(N.col+.5)*T}px`,j.style.top=`${(N.row+.5)*W}px`,j.style.zIndex=String(Math.round(N.depth*1e3))):j.style.display="none"}}function M(a,E={}){let g=fn++;return l.set(g,{id:g,polygons:a,transform:E}),d(),f(),b(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(G){let z=l.get(g);z&&(z.transform=G,d(),b())},dispose(){l.delete(g),d(),f(),b()}}}function x(a,E){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[G,z]=a.size??[1,1];g.style.position="absolute",g.style.width=`${G}ch`,g.style.height=`${z*t.cellAspect}ch`,E&&g.addEventListener("click",E),s.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:E};return i.push(F),b(),{get el(){return g},remove(){let T=i.indexOf(F);T>=0&&i.splice(T,1),E&&g.removeEventListener("click",E),s.removeChild(g),b()}}}function y(){C()}function w(a){a.mode!==void 0&&(t.mode=a.mode),a.glyphPalette!==void 0&&(t.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(t.useColors=a.useColors),a.cols!==void 0&&(t.cols=a.cols),a.rows!==void 0&&(t.rows=a.rows),a.cellAspect!==void 0&&(t.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(t.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(t.ambientLight=a.ambientLight),a.camera!==void 0&&(t.camera=a.camera),a.smoothShading!==void 0&&(t.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(t.creaseAngle=a.creaseAngle),"shadow"in a&&(t.shadow=a.shadow),a.autoSize!==void 0&&(t.autoSize=a.autoSize,t.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>v()),A.observe(n),v()):!t.autoSize&&A&&(A.disconnect(),A=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),b()}function P(){return{...t}}function H(){let E=n.ownerDocument.createElement("span");E.textContent=Array(20).fill("M").join(`
63
- `),E.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(E);let g=E.getBoundingClientRect();return E.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function v(){let a=n.clientWidth,E=n.clientHeight;if(!a||!E)return;let g=H(),G=Math.max(20,Math.floor(a/g.w)),z=Math.max(8,Math.floor(E/g.h)),F=g.h/g.w,T=!1;t.cols!==G&&(t.cols=G,T=!0),t.rows!==z&&(t.rows=z,T=!0),Math.abs(t.cellAspect-F)>.01&&(t.cellAspect=F,T=!0),T&&b()}let A=null;t.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>v()),A.observe(n),v());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return t.camera},add:M,addHotspot:x,rerender:y,setOptions:w,getOptions:P,fit:v,destroy:L}}var yn=typeof HTMLElement<"u"?HTMLElement:class{},bn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Ce(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}function vn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function En(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ue=class extends yn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...bn]}getScene(){return this._scene}_readOptions(){let t={},o=vn(this.getAttribute("mode"));o!==void 0&&(t.mode=o);let r=this.getAttribute("glyph-palette");r&&(t.glyphPalette=r);let s=En(this.getAttribute("use-colors"));s!==void 0&&(t.useColors=s);let l=Ce(this.getAttribute("cols"));l!==void 0&&(t.cols=l);let i=Ce(this.getAttribute("rows"));i!==void 0&&(t.rows=i);let c=Ce(this.getAttribute("cell-aspect"));c!==void 0&&(t.cellAspect=c);let u=Ce(this.getAttribute("directional-intensity"));u!==void 0&&(t.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Ce(this.getAttribute("ambient-intensity"));if(p!==void 0&&(t.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(t.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},m=this.getAttribute("shadow-color");m&&(d.color=m);let h=Ce(this.getAttribute("shadow-opacity"));h!==void 0&&(d.opacity=h);let f=Ce(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let b=Ce(this.getAttribute("shadow-max-extend"));b!==void 0&&(d.maxExtend=b),t.shadow=d}return t}_findCameraAncestor(){let t=this.parentElement;for(;t;){let o=t.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return t;t=t.parentElement}return null}_initScene(t){let o=typeof t.getCamera=="function"?t.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Ft(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let t=this._findCameraAncestor();if(!t)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof t.getCamera=="function"?t.getCamera():null)!==null)this._initScene(t);else{let r=()=>{t.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(t)};t.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(t,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as wn,resolveGeometry as An,computeSceneBbox as Sn}from"@glyphcss/core";var xn=typeof HTMLElement<"u"?HTMLElement:class{},Mn=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function Cn(n){let e=Sn(n),t=(e.min[0]+e.max[0])/2,o=(e.min[1]+e.max[1])/2,r=(e.min[2]+e.max[2])/2,l=2/(Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],e.max[2]-e.min[2])||1);return n.map(i=>({...i,vertices:i.vertices.map(c=>[(c[0]-t)*l,(c[1]-o)*l,(c[2]-r)*l])}))}function ft(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==3||e.some(t=>!Number.isFinite(t))))return[e[0],e[1],e[2]]}function Gn(n){if(n){if(!n.includes(",")){let e=parseFloat(n);return Number.isFinite(e)?e:void 0}return ft(n)}}function Ln(n){return n.closest("glyph-scene")??null}var Ke=class extends xn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Mn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r){if(t==="src"||t==="geometry"||t==="size"||t==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:ft(this.getAttribute("position")),scale:Gn(this.getAttribute("scale")),rotation:ft(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let t=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Ln(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(t){let s=++this._loadToken,l;try{l=await wn(t)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(s!==this._loadToken){try{l.dispose()}catch{}return}let i=r.getScene();if(!i){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?Cn(l.polygons):l.polygons;this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let l=this.getAttribute("size"),i=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=An(o,{size:Number.isFinite(i)?i:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Tn=typeof HTMLElement<"u"?HTMLElement:class{};function _n(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==3||e.some(t=>!Number.isFinite(t))))return[e[0],e[1],e[2]]}function zn(n){if(!n)return;let e=n.split(",").map(t=>parseFloat(t.trim()));if(!(e.length!==2||e.some(t=>!Number.isFinite(t))))return[e[0],e[1]]}function Pn(n){return n.closest("glyph-scene")??null}var Ze=class extends Tn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(t,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let t=this._handle.el;for(;t.firstChild;)this.appendChild(t.firstChild);this._handle.remove(),this._handle=null}_register(){let t=_n(this.getAttribute("at"));if(!t)return;let o=Pn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=zn(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:t,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var Hn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}var Je=class extends Hn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(t,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=ue(this.getAttribute("rot-x")),i=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),m=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,m=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,m=!0),c!==void 0&&s.distance!==c&&(s.distance=c,m=!0),u!==void 0&&s.perspective!==u&&(s.perspective=u,m=!0),p!==void 0&&s.zoom!==p&&(s.zoom=p,m=!0),d!==void 0&&s.stretch!==d&&(s.stretch=d,m=!0),m&&this.querySelector("glyph-scene")?.rerender?.()}};var Fn=typeof HTMLElement<"u"?HTMLElement:class{};function Be(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}var De=class extends Fn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ct({rotX:Be(this.getAttribute("rot-x")),rotY:Be(this.getAttribute("rot-y")),zoom:Be(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(t,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=Be(this.getAttribute("rot-x")),i=Be(this.getAttribute("rot-y")),c=Be(this.getAttribute("zoom")),u=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,u=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,u=!0),c!==void 0&&s.zoom!==c&&(s.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function Ot(n,e={}){let t=n.host,o=e.drag??!0,r=e.wheel??!0,s=It(e.invert),l=e.clampPitch??!0,i=e.animate??!1,c=!1,u=!1,p=null,d=null,m=null,h={x:0,y:0},f=n.camera;function b(v){if(!(!o||c)&&m===null&&v.isPrimary!==!1){v.preventDefault(),m=v.pointerId,h={x:v.clientX,y:v.clientY},t.style.cursor="grabbing";try{v.target.setPointerCapture(v.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function C(v){if(m===null||v.pointerId!==m||!o||c)return;v.preventDefault();let A=v.clientX-h.x,L=v.clientY-h.y;h={x:v.clientX,y:v.clientY};let a=s,E=1/4;f.rotY=f.rotY-A*E*a;let g=f.rotX-L*E*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function _(v){if(m===v.pointerId){m=null,t.style.cursor=o&&!c?"grab":"";try{v.target.releasePointerCapture(v.pointerId)}catch{}i&&(u=!1)}}function M(v){if(!r||c)return;v.preventDefault();let A=v.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function x(v){if(!(c||!i)){if(!u){let A=d!==null?Math.min(v-d,50):16.67,L=typeof i=="object"&&i.speed?i.speed:.3,a=typeof i=="object"&&i.axis?i.axis:"y",E=L*(A/16.67);a==="y"?f.rotY=f.rotY+E:f.rotX=f.rotX+E,n.rerender()}d=v,p=requestAnimationFrame(x)}}function y(){p===null&&typeof requestAnimationFrame<"u"&&i&&(p=requestAnimationFrame(x))}function w(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){t.addEventListener("pointerdown",b),t.addEventListener("pointermove",C),t.addEventListener("pointerup",_),t.addEventListener("pointercancel",_),t.addEventListener("wheel",M,{passive:!1}),t.style.cursor=o?"grab":"",t.style.touchAction="none",t.style.userSelect="none"}function H(){t.removeEventListener("pointerdown",b),t.removeEventListener("pointermove",C),t.removeEventListener("pointerup",_),t.removeEventListener("pointercancel",_),t.removeEventListener("wheel",M),t.style.cursor="",t.style.touchAction="",t.style.userSelect=""}return P(),y(),{update(v){let A=!!i;o=v.drag??o,r=v.wheel??r,s=It(v.invert),v.clampPitch!==void 0&&(l=v.clampPitch),i=v.animate??i,!c&&m===null&&(t.style.cursor=o?"grab":"");let L=!!i;A&&!L?w():!A&&L&&y()},pause(){c||(c=!0,H(),w(),m=null,u=!1)},resume(){c&&(c=!1,P(),y())},destroy(){c||H(),w(),c=!0}}}function It(n){return n===void 0||n===!1?1:n===!0?-1:n}var In=typeof HTMLElement<"u"?HTMLElement:class{};function On(n){if(n==null)return;let e=parseFloat(n);return Number.isFinite(e)?e:void 0}function Qe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Bn(n){return n.closest("glyph-scene")??null}var et=class extends In{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let t=Qe(this.getAttribute("drag")),o=Qe(this.getAttribute("wheel")),r=Qe(this.getAttribute("invert")),s=Qe(this.getAttribute("clamp-pitch")),l=On(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...t!==void 0?{drag:t}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...l!==void 0?{animate:{speed:l,axis:i}}:{}}}_attach(){if(this._controls)return;let t=Bn(this);if(!t)return;let o=t.getScene();if(!o){let r=()=>{t.removeEventListener("glyphcss:scene-ready",r),this._attach()};t.addEventListener("glyphcss:scene-ready",r);return}this._controls=Ot(o,this._readOptions())}};function Rt(n,e={}){let t=n.host,o=e.drag??!0,r=e.wheel??!0,s=Bt(e.invert),l=e.animate??!1,i=!1,c=!1,u=null,p=null,d=null,m={x:0,y:0},h=!1,f=n.camera,b=1/4,C=.02;function _(a){if(!(!o||i)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,m={x:a.clientX,y:a.clientY},h=a.button===2,t.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function M(a){if(d===null||a.pointerId!==d||!o||i)return;a.preventDefault();let E=a.clientX-m.x,g=a.clientY-m.y;m={x:a.clientX,y:a.clientY};let G=s;if(h||a.shiftKey)f.rotY=f.rotY-E*b*G,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*b*G));else{let z=f.target;f.target=[z[0]-E*C/f.zoom,z[1]-g*C/f.zoom,z[2]]}n.rerender()}function x(a){if(d===a.pointerId){d=null,h=!1,t.style.cursor=o&&!i?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function y(a){a.preventDefault()}function w(a){if(!r||i)return;a.preventDefault();let E=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-E))),n.rerender()}function P(a){if(!(i||!l)){if(!c){let E=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,G=typeof l=="object"&&l.axis?l.axis:"y",z=g*(E/16.67);G==="y"?f.rotY=f.rotY+z:f.rotX=f.rotX+z,n.rerender()}p=a,u=requestAnimationFrame(P)}}function H(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function v(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){t.addEventListener("pointerdown",_),t.addEventListener("pointermove",M),t.addEventListener("pointerup",x),t.addEventListener("pointercancel",x),t.addEventListener("contextmenu",y),t.addEventListener("wheel",w,{passive:!1}),t.style.cursor=o?"grab":"",t.style.touchAction="none",t.style.userSelect="none"}function L(){t.removeEventListener("pointerdown",_),t.removeEventListener("pointermove",M),t.removeEventListener("pointerup",x),t.removeEventListener("pointercancel",x),t.removeEventListener("contextmenu",y),t.removeEventListener("wheel",w),t.style.cursor="",t.style.touchAction="",t.style.userSelect=""}return A(),H(),{update(a){let E=!!l;o=a.drag??o,r=a.wheel??r,s=Bt(a.invert),l=a.animate??l,!i&&d===null&&(t.style.cursor=o?"grab":"");let g=!!l;E&&!g?v():!E&&g&&H()},pause(){i||(i=!0,L(),v(),d=null,c=!1)},resume(){i&&(i=!1,A(),H())},destroy(){i||L(),v(),i=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Rn=typeof HTMLElement<"u"?HTMLElement:class{};function gt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Nn(n){return n.closest("glyph-scene")??null}var tt=class extends Rn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let t=gt(this.getAttribute("drag")),o=gt(this.getAttribute("wheel")),r=gt(this.getAttribute("invert"));return{...t!==void 0?{drag:t}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let t=Nn(this);if(!t)return;let o=t.getScene();if(!o){let r=()=>{t.removeEventListener("glyphcss:scene-ready",r),this._attach()};t.addEventListener("glyphcss:scene-ready",r);return}this._controls=Rt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ue),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",Ke),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",Ze),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",Je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",De),!customElements.get("glyph-camera")){class n extends De{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",et),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",tt)}export{Ze as GlyphHotspotElement,tt as GlyphMapControlsElement,Ke as GlyphMeshElement,et as GlyphOrbitControlsElement,De as GlyphOrthographicCameraElement,Je as GlyphPerspectiveCameraElement,Ue as GlyphSceneElement};
62
+ `;function Ht(n,t,e,o,r){return n.map(l=>{let[a,i,c]=t.project(l.at,e,o,r),u=c>-3&&a>=0&&a<e&&i>=0&&i<o;return{id:l.id,col:a,row:i,depth:c,visible:u}})}var fn=1;function gn(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[l,a,i]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],b=h*d,C=m*d,_=f*d,x=Math.cos(b),M=Math.sin(b),y=Math.cos(C),w=Math.sin(C),P=Math.cos(_),H=Math.sin(_);function v(A){let L=A[0]*c,s=A[1]*u,E=A[2]*p,g=P*L-H*s,G=H*L+P*s,z=E;return L=y*g+w*z,s=G,E=-w*g+y*z,g=L,G=x*s-M*E,z=M*s+x*E,[g+l,G+a,z+i]}return n.map(A=>({...A,vertices:A.vertices.map(v)}))}function Ft(n,t={}){Pt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Ie(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let l=n.ownerDocument.createElement("div");l.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(l),n.appendChild(o);let a=new Map,i=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let s=[];for(let g of a.values())for(let G of g.polygons)(G.texture||G.material?.texture)&&s.push(G);if(s.length===0){h&&(h=null,b());return}let E=++m;mn(s).then(g=>{E===m&&(h=g.size>0?g:null,b())})}function b(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let s=[],E=[],g=[],G=[],z=!1;for(let N of a.values()){let re=gn(N.polygons,N.transform),k=N.transform.castShadow??!1,q=N.transform.receiveShadow??!1,oe=N.transform.depthBias??0;oe!==0&&(z=!0);for(let K of re)s.push(K),E.push(k),g.push(q),G.push(oe)}let F=Gt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:s,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:E,receiveShadowFlags:g,depthBiases:z?G:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let T=globalThis.__glyphPerf,W=T?performance.now():0,R=_t(F),j=T?performance.now():0;if(e.useColors?r.innerHTML=R:r.textContent=R,T){let N=performance.now();(T.raster??(T.raster=[])).push(j-W),(T.dom??(T.dom=[])).push(N-j),(T.polys??(T.polys=[])).push(s.length)}_()}function _(){let{cols:s,rows:E,cellAspect:g,camera:G}=e,z=Ht(i.map(R=>R.hotspot),G,s,E,g),F=r.getBoundingClientRect(),T=s>0?F.width/s:8,W=E>0?F.height/E:16;for(let R=0;R<i.length;R++){let{el:j}=i[R],N=z[R];N.visible?(j.style.display="",j.style.left=`${(N.col+.5)*T}px`,j.style.top=`${(N.row+.5)*W}px`,j.style.zIndex=String(Math.round(N.depth*1e3))):j.style.display="none"}}function x(s,E={}){let g=fn++;return a.set(g,{id:g,polygons:s,transform:E}),d(),f(),b(),{get id(){return g},get name(){return a.get(g)?.transform.id},get polygons(){return s},setTransform(G){let z=a.get(g);z&&(z.transform=G,d(),b())},dispose(){a.delete(g),d(),f(),b()}}}function M(s,E){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",s.id);let[G,z]=s.size??[1,1];g.style.position="absolute",g.style.width=`${G}ch`,g.style.height=`${z*e.cellAspect}ch`,E&&g.addEventListener("click",E),l.appendChild(g);let F={hotspot:{id:s.id,at:s.at,size:s.size},el:g,onClick:E};return i.push(F),b(),{get el(){return g},remove(){let T=i.indexOf(F);T>=0&&i.splice(T,1),E&&g.removeEventListener("click",E),l.removeChild(g),b()}}}function y(){C()}function w(s){s.mode!==void 0&&(e.mode=s.mode),s.glyphPalette!==void 0&&(e.glyphPalette=s.glyphPalette),s.useColors!==void 0&&(e.useColors=s.useColors),s.cols!==void 0&&(e.cols=s.cols),s.rows!==void 0&&(e.rows=s.rows),s.cellAspect!==void 0&&(e.cellAspect=s.cellAspect),s.directionalLight!==void 0&&(e.directionalLight=s.directionalLight),s.ambientLight!==void 0&&(e.ambientLight=s.ambientLight),s.camera!==void 0&&(e.camera=s.camera),s.smoothShading!==void 0&&(e.smoothShading=s.smoothShading),s.creaseAngle!==void 0&&(e.creaseAngle=s.creaseAngle),"shadow"in s&&(e.shadow=s.shadow),s.autoSize!==void 0&&(e.autoSize=s.autoSize,e.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>v()),A.observe(n),v()):!e.autoSize&&A&&(A.disconnect(),A=null)),(s.mode!==void 0||s.useColors!==void 0||s.directionalLight!==void 0||s.ambientLight!==void 0||s.smoothShading!==void 0||s.creaseAngle!==void 0||s.glyphPalette!==void 0)&&d(),b()}function P(){return{...e}}function H(){let E=n.ownerDocument.createElement("span");E.textContent=Array(20).fill("M").join(`
63
+ `),E.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(E);let g=E.getBoundingClientRect();return E.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function v(){let s=n.clientWidth,E=n.clientHeight;if(!s||!E)return;let g=H(),G=Math.max(20,Math.floor(s/g.w)),z=Math.max(8,Math.floor(E/g.h)),F=g.h/g.w,T=!1;e.cols!==G&&(e.cols=G,T=!0),e.rows!==z&&(e.rows=z,T=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,T=!0),T&&b()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>v()),A.observe(n),v());function L(){A&&(A.disconnect(),A=null),a.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:x,addHotspot:M,rerender:y,setOptions:w,getOptions:P,fit:v,destroy:L}}var yn=typeof HTMLElement<"u"?HTMLElement:class{},bn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Ce(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function vn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function En(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ue=class extends yn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...bn]}getScene(){return this._scene}_readOptions(){let e={},o=vn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let l=En(this.getAttribute("use-colors"));l!==void 0&&(e.useColors=l);let a=Ce(this.getAttribute("cols"));a!==void 0&&(e.cols=a);let i=Ce(this.getAttribute("rows"));i!==void 0&&(e.rows=i);let c=Ce(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Ce(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Ce(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Ce(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Ce(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let b=Ce(this.getAttribute("shadow-max-extend"));b!==void 0&&(d.maxExtend=b),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Ft(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as wn,resolveGeometry as An,recenterPolygons as Sn}from"@glyphcss/core";var Mn=typeof HTMLElement<"u"?HTMLElement:class{},xn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function ft(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Cn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return ft(n)}}function Gn(n){return n.closest("glyph-scene")??null}var Ke=class extends Mn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...xn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:ft(this.getAttribute("position")),scale:Cn(this.getAttribute("scale")),rotation:ft(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Gn(this);if(r){if(!r.getScene()){let l=()=>{r.removeEventListener("glyphcss:scene-ready",l),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",l);return}if(e){let l=++this._loadToken,a;try{a=await wn(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(l!==this._loadToken){try{a.dispose()}catch{}return}let i=r.getScene();if(!i){try{a.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?Sn(a.polygons):a.polygons;this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let l=r.getScene();if(!l)return;let a=this.getAttribute("size"),i=a!==null?parseFloat(a):1,c=this.getAttribute("color")??void 0,u;try{u=An(o,{size:Number.isFinite(i)?i:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Ln=typeof HTMLElement<"u"?HTMLElement:class{};function Tn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function _n(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function zn(n){return n.closest("glyph-scene")??null}var Ze=class extends Ln{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Tn(this.getAttribute("at"));if(!e)return;let o=zn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let l=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),a=_n(this.getAttribute("size"));this._handle=r.addHotspot({id:l,at:e,size:a},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:l},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var Pn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Je=class extends Pn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=ue(this.getAttribute("rot-x")),i=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,h=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,h=!0),c!==void 0&&l.distance!==c&&(l.distance=c,h=!0),u!==void 0&&l.perspective!==u&&(l.perspective=u,h=!0),p!==void 0&&l.zoom!==p&&(l.zoom=p,h=!0),d!==void 0&&l.stretch!==d&&(l.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Hn=typeof HTMLElement<"u"?HTMLElement:class{};function Be(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var De=class extends Hn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ct({rotX:Be(this.getAttribute("rot-x")),rotY:Be(this.getAttribute("rot-y")),zoom:Be(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=Be(this.getAttribute("rot-x")),i=Be(this.getAttribute("rot-y")),c=Be(this.getAttribute("zoom")),u=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,u=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,u=!0),c!==void 0&&l.zoom!==c&&(l.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function Ot(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=It(t.invert),a=t.clampPitch??!0,i=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function b(v){if(!(!o||c)&&h===null&&v.isPrimary!==!1){v.preventDefault(),h=v.pointerId,m={x:v.clientX,y:v.clientY},e.style.cursor="grabbing";try{v.target.setPointerCapture(v.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function C(v){if(h===null||v.pointerId!==h||!o||c)return;v.preventDefault();let A=v.clientX-m.x,L=v.clientY-m.y;m={x:v.clientX,y:v.clientY};let s=l,E=1/4;f.rotY=f.rotY-A*E*s;let g=f.rotX-L*E*s;f.rotX=a?Math.max(-90,Math.min(90,g)):g,n.rerender()}function _(v){if(h===v.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{v.target.releasePointerCapture(v.pointerId)}catch{}i&&(u=!1)}}function x(v){if(!r||c)return;v.preventDefault();let A=v.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(v){if(!(c||!i)){if(!u){let A=d!==null?Math.min(v-d,50):16.67,L=typeof i=="object"&&i.speed?i.speed:.3,s=typeof i=="object"&&i.axis?i.axis:"y",E=L*(A/16.67);s==="y"?f.rotY=f.rotY+E:f.rotX=f.rotX+E,n.rerender()}d=v,p=requestAnimationFrame(M)}}function y(){p===null&&typeof requestAnimationFrame<"u"&&i&&(p=requestAnimationFrame(M))}function w(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",b),e.addEventListener("pointermove",C),e.addEventListener("pointerup",_),e.addEventListener("pointercancel",_),e.addEventListener("wheel",x,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function H(){e.removeEventListener("pointerdown",b),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",_),e.removeEventListener("pointercancel",_),e.removeEventListener("wheel",x),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),y(),{update(v){let A=!!i;o=v.drag??o,r=v.wheel??r,l=It(v.invert),v.clampPitch!==void 0&&(a=v.clampPitch),i=v.animate??i,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!i;A&&!L?w():!A&&L&&y()},pause(){c||(c=!0,H(),w(),h=null,u=!1)},resume(){c&&(c=!1,P(),y())},destroy(){c||H(),w(),c=!0}}}function It(n){return n===void 0||n===!1?1:n===!0?-1:n}var Fn=typeof HTMLElement<"u"?HTMLElement:class{};function In(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Qe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function On(n){return n.closest("glyph-scene")??null}var et=class extends Fn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Qe(this.getAttribute("drag")),o=Qe(this.getAttribute("wheel")),r=Qe(this.getAttribute("invert")),l=Qe(this.getAttribute("clamp-pitch")),a=In(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...l!==void 0?{clampPitch:l}:{},...a!==void 0?{animate:{speed:a,axis:i}}:{}}}_attach(){if(this._controls)return;let e=On(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Ot(o,this._readOptions())}};function Rt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Bt(t.invert),a=t.animate??!1,i=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,b=1/4,C=.02;function _(s){if(!(!o||i)&&d===null&&s.isPrimary!==!1){s.preventDefault(),d=s.pointerId,h={x:s.clientX,y:s.clientY},m=s.button===2,e.style.cursor="grabbing";try{s.target.setPointerCapture(s.pointerId)}catch{}a&&a.pauseOnInteraction!==!1&&(c=!0)}}function x(s){if(d===null||s.pointerId!==d||!o||i)return;s.preventDefault();let E=s.clientX-h.x,g=s.clientY-h.y;h={x:s.clientX,y:s.clientY};let G=l;if(m||s.shiftKey)f.rotY=f.rotY-E*b*G,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*b*G));else{let z=f.target;f.target=[z[0]-E*C/f.zoom,z[1]-g*C/f.zoom,z[2]]}n.rerender()}function M(s){if(d===s.pointerId){d=null,m=!1,e.style.cursor=o&&!i?"grab":"";try{s.target.releasePointerCapture(s.pointerId)}catch{}a&&(c=!1)}}function y(s){s.preventDefault()}function w(s){if(!r||i)return;s.preventDefault();let E=s.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-E))),n.rerender()}function P(s){if(!(i||!a)){if(!c){let E=p!==null?Math.min(s-p,50):16.67,g=typeof a=="object"&&a.speed?a.speed:.3,G=typeof a=="object"&&a.axis?a.axis:"y",z=g*(E/16.67);G==="y"?f.rotY=f.rotY+z:f.rotX=f.rotX+z,n.rerender()}p=s,u=requestAnimationFrame(P)}}function H(){u===null&&typeof requestAnimationFrame<"u"&&a&&(u=requestAnimationFrame(P))}function v(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",x),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",y),e.addEventListener("wheel",w,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",x),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",y),e.removeEventListener("wheel",w),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),H(),{update(s){let E=!!a;o=s.drag??o,r=s.wheel??r,l=Bt(s.invert),a=s.animate??a,!i&&d===null&&(e.style.cursor=o?"grab":"");let g=!!a;E&&!g?v():!E&&g&&H()},pause(){i||(i=!0,L(),v(),d=null,c=!1)},resume(){i&&(i=!1,A(),H())},destroy(){i||L(),v(),i=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function gt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Rn(n){return n.closest("glyph-scene")??null}var tt=class extends Bn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=gt(this.getAttribute("drag")),o=gt(this.getAttribute("wheel")),r=gt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Rn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Rt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ue),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",Ke),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",Ze),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",Je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",De),!customElements.get("glyph-camera")){class n extends De{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",et),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",tt)}export{Ze as GlyphHotspotElement,tt as GlyphMapControlsElement,Ke as GlyphMeshElement,et as GlyphOrbitControlsElement,De as GlyphOrthographicCameraElement,Je as GlyphPerspectiveCameraElement,Ue as GlyphSceneElement};
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Gt=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var yn=(n,t)=>{for(var e in t)Gt(n,e,{get:t[e],enumerable:!0})},Mt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mn(t))!fn.call(n,r)&&r!==e&&Gt(n,r,{get:()=>t[r],enumerable:!(o=hn(t,r))||o.enumerable});return n},V=(n,t,e)=>(Mt(n,t,"default"),e&&Mt(e,t,"default"));var gn=n=>Mt(Gt({},"__esModule",{value:!0}),n);var N={};yn(N,{DEFAULT_PERSPECTIVE:()=>Tt,DEFAULT_RAMP:()=>Vt,GlyphHotspotElement:()=>ut,GlyphMapControlsElement:()=>ft,GlyphMeshElement:()=>ct,GlyphOrbitControlsElement:()=>mt,GlyphOrthographicCameraElement:()=>pt,GlyphPerspectiveCameraElement:()=>dt,GlyphSceneElement:()=>at,SOLID_RAMP:()=>Xt,WIREFRAME_GLYPHS:()=>$t,WIREFRAME_PALETTES:()=>We,bakeFrames:()=>qt,buildRasterizeContext:()=>tt,createGlyphCamera:()=>Yt,createGlyphFirstPersonControls:()=>en,createGlyphMapControls:()=>lt,createGlyphOrbitControls:()=>st,createGlyphOrthographicCamera:()=>$e,createGlyphPerspectiveCamera:()=>Le,createGlyphScene:()=>it,findGlyphMeshHandle:()=>tn,findMeshUnderPoint:()=>nn,getWireframeGlyphs:()=>je,injectGlyphBaseStyles:()=>rt,pointInMeshElement:()=>_t,projectHotspots:()=>ot,rasterize:()=>qe});module.exports=gn(N);var Kt=require("@glyphcss/core");var Nt=Math.PI/180,Dt=.01,Tt=32e3,bn=Dt*1.01;function Lt(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*Nt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*Nt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Le(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Tt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=Lt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*bn}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],A=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+A/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,A=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Dt;if(y<E)return[NaN,NaN,P,NaN];let x=M/y,L=i*e+b*x/u*t.stretch*t.fovScale,a=l*o+A*x/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function $e(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Yt=$e;var vn={direction:[-.5,-.7,-.5],intensity:1},En={intensity:.4};function wn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function tt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?wn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vn,ambientLight:n.ambientLight??En,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var Vt=" .:-=+*#%@".split(""),Xt=" .:-=+*#%@".split(""),We={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},$t=We.default;function je(n){return We[n]??We.default}function qe(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return xn(n,i,l,s,d)}let c=je(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||_n(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return Pn(u,p,i,l,c)}function xn(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,$,W,Y)=>{let S=s.project(R,$,W,Y);return[$*.5+(S[0]-$*.5)*r,W*.5+(S[1]-W*.5)*r,S[2],S[3]]}}:s,M=je(n.glyphPalette).solid,b=M.length-1,A=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),x=n.temporalBlend>0&&!!n.temporalHistory,L=x?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,q=Fe(u.color??"#ffffff"),B=Fe(p.color??"#ffffff"),U=d&&h>0?Ln(c,h):null,k=new Map,ie=n.textureSamplers??null,D=n.shadow,K=D!=null&&f.length>0?Gn(c,f,g,_,H):null,se=D?.opacity??.25,J=D?.lift??.05,Q=D?.color??"#000000",le=K?Fe(Q):[0,0,0],I=globalThis.__glyphPerfDetail,Ue=I?performance.now():0,be=[],ee=n.shadeCache??null,te=-1,we=(R,$,W,Y)=>{if(K===null||!Y)return null;let S=K,O=Be(R,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ne=Be($,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),he=Be(W,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:O[0],lvA:O[1],ldA:O[2],luB:ne[0],lvB:ne[1],ldB:ne[2],luC:he[0],lvC:he[1],ldC:he[2],lift:J,opacity:se,shadowColorRgb:le,shadowColorHex:Q,litCache:k}};for(let R=0;R<c.length;R++){let $=c[R],W=$.vertices;if(W.length<3)continue;let Y=$.uvs,S=null;if(ie!==null&&Y&&Y.length>=W.length){let O=(0,nt.polygonTexture)($);O&&(S=ie.get(O)??null)}for(let O=0;O<W.length;O++)be[O]=G.project(W[O],i,l,o);for(let O=1;O<W.length-1;O++){te++;let ne=0,he=O,xe=O+1,ae=W[ne],me=W[he],Ae=W[xe],ue=be[ne],ve=be[he],Me=be[xe],gt=(ue[0]!==ue[0]?1:0)+(ve[0]!==ve[0]?1:0)+(Me[0]!==Me[0]?1:0);if(gt===3||gt===0&&!m&&(ve[0]-ue[0])*(Me[1]-ue[1])-(ve[1]-ue[1])*(Me[0]-ue[0])>0)continue;let _e,Pe,ze,De=null;if(ee!==null&&ee.iA[te]!==void 0)_e=ee.iA[te],Pe=ee.iB[te],ze=ee.iC[te],De=ee.lit[te];else{let j=me[0]-ae[0],fe=me[1]-ae[1],Se=me[2]-ae[2],ye=Ae[0]-ae[0],Ze=Ae[1]-ae[1],Je=Ae[2]-ae[2],Qe=fe*Je-Se*Ze,Ye=Se*ye-j*Je,Z=j*Ze-fe*ye,X=Math.hypot(Qe,Ye,Z)||1,re=Qe/X,ge=Ye/X,ce=Z/X,de,He,bt,vt,Et,wt,xt,At,St;if(U){let Ve=U[R],Ge=Ve[ne],Re=Ve[he],Xe=Ve[xe];de=Ge[0],He=Ge[1],bt=Ge[2],vt=Re[0],Et=Re[1],wt=Re[2],xt=Xe[0],At=Xe[1],St=Xe[2]}else de=vt=xt=re,He=Et=At=ge,bt=wt=St=ce;let It=de*g+He*_+bt*H,Rt=vt*g+Et*_+wt*H,Bt=xt*g+At*_+St*H,rn=m?Math.abs(It):Math.max(0,-It),on=m?Math.abs(Rt):Math.max(0,-Rt),sn=m?Math.abs(Bt):Math.max(0,-Bt);if(_e=Math.min(1,z+rn*F),Pe=Math.min(1,z+on*F),ze=Math.min(1,z+sn*F),P){let Ve=(_e+Pe+ze)/3,Ge=Math.max(0,Ve-z),Re=$.color??"#ffffff",Xe=Ge*255|0,kt=`${Re}:${Xe}`,et=k.get(kt);if(et===void 0){let Ct=Fe(Re),ln=z*B[0]/255+Ge*q[0]/255,an=z*B[1]/255+Ge*q[1]/255,cn=z*B[2]/255+Ge*q[2]/255,un=Math.min(255,Ct[0]*ln),dn=Math.min(255,Ct[1]*an),pn=Math.min(255,Ct[2]*cn);et=`#${oe(un)}${oe(dn)}${oe(pn)}`,k.set(kt,et)}De=et}ee!==null&&(ee.iA[te]=_e,ee.iB[te]=Pe,ee.iC[te]=ze,ee.lit[te]=De)}let Ft=v[R]??!1,Ie=1+(C?.[R]??0),Ot=null;if(S!==null&&Y){let j=Y[ne],fe=Y[he],Se=Y[xe],ye=Math.max(0,(_e+Pe+ze)/3-z);Ot={sampler:S,ua:j[0],va:j[1],ub:fe[0],vb:fe[1],uc:Se[0],vc:Se[1],tintR:z*B[0]/255+ye*q[0]/255,tintG:z*B[1]/255+ye*q[1]/255,tintB:z*B[2]/255+ye*q[2]/255}}if(gt===0)Wt(ue[0],ue[1],(ue[3]??ue[2])*Ie,_e,ve[0],ve[1],(ve[3]??ve[2])*Ie,Pe,Me[0],Me[1],(Me[3]??Me[2])*Ie,ze,M,b,De,A,y,E,i,l,we(ae,me,Ae,Ft),m,ae,me,Ae,L,T,Ot);else{let j=[],fe=[],Se=[ae,me,Ae],ye=[_e,Pe,ze],Ze=G.eyeDepth(ae),Je=G.eyeDepth(me),Qe=G.eyeDepth(Ae),Ye=[Ze,Je,Qe];for(let Z=0;Z<3;Z++){let X=(Z+1)%3,re=Ye[Z],ge=Ye[X];if(re>0&&(j.push(Se[Z]),fe.push(ye[Z])),re>0!=ge>0){let ce=re/(re-ge),de=Se[Z],He=Se[X];j.push([de[0]+ce*(He[0]-de[0]),de[1]+ce*(He[1]-de[1]),de[2]+ce*(He[2]-de[2])]),fe.push(ye[Z]+ce*(ye[X]-ye[Z]))}}if(j.length>=3){let Z=j.map(X=>G.project(X,i,l,o));for(let X=1;X<j.length-1;X++){let re=Z[0],ge=Z[X],ce=Z[X+1],de=(ge[0]-re[0])*(ce[1]-re[1])-(ge[1]-re[1])*(ce[0]-re[0]);!m&&de>0||Wt(re[0],re[1],(re[3]??re[2])*Ie,fe[0],ge[0],ge[1],(ge[3]??ge[2])*Ie,fe[X],ce[0],ce[1],(ce[3]??ce[2])*Ie,fe[X+1],M,b,De,A,y,E,i,l,we(j[0],j[X],j[X+1],Ft),m,j[0],j[X],j[X+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ue);let Ht=I?performance.now():0,Oe=A,Ce=y,Ke=L;if(r>1){let R=Sn(A,y,E,L,t,e,r,M);Oe=R.glyphBuf,Ce=R.colorBuf,Ke=R.worldPos}x&&An(Oe,Ce,Ke,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let yt=Tn(Oe,Ce,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ht),yt}function An(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Le({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let A=M*o+b,P=h.get(n[A])??0,y=0,E=0,x=0,L=t?t[A]:null;if(L){let D=Fe(L);y=D[0],E=D[1],x=D[2]}let a=0,w=0,g=0,_=0,H=0,F=e[A*3];if(f&&F===F){let D=f([F,e[A*3+1],e[A*3+2]]),K=Math.round(D[0]),se=Math.round(D[1]);if(D[0]===D[0]&&K>=0&&K<o&&se>=0&&se<r){let J=se*o+K;w=c.idx[J],g=c.r[J],_=c.g[J],H=c.b[J],a=s}}let z=1-a,q=z*P+a*w,B=z*y+a*g,U=z*E+a*_,k=z*x+a*H;v[A]=q,C[A]=B,T[A]=U,G[A]=k;let ie=Math.round(q);ie<0?ie=0:ie>d&&(ie=d),n[A]=l[ie],t&&(t[A]=ie===0?null:`#${oe(B)}${oe(U)}${oe(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function Sn(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,A=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=Fe(H);M+=F[0],b+=F[1],A+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let x=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[x]=s[L],h&&(h[x]=`#${oe(M/G)}${oe(b/G)}${oe(A/G)}`),m&&(m[x*3]=P/G,m[x*3+1]=y/G,m[x*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var Cn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),Ee=256;function Be(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(Ee-1),G=(v-h)/(m-h)*(Ee-1);return[T,G,C]}function Mn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(Ee-1,Math.floor(C)),A=Math.max(0,Math.ceil(T)),P=Math.min(Ee-1,Math.floor(G));if(M>b||A>P)return;let y=m>0;for(let E=A;E<=P;E++)for(let x=M;x<=b;x++){let L=x,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*Ee+x;H>n[F]&&(n[F]=H)}}function Gn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let A of n[b].vertices){let P=i*A[0]+l*A[1]+s*A[2],y=u*A[0]+p*A[1]+d*A[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(Ee*Ee).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let A=n[b].vertices;if(!(A.length<3))for(let P=1;P<A.length-1;P++){let y=A[0],E=A[P],x=A[P+1],L=Be(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Be(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Be(x,i,l,s,u,p,d,e,o,r,h,m,f,v);Mn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Wt(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,A,P,y,E,x,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!A&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let q=t>i?t:i;u>q&&(q=u);let B=Math.max(0,Math.ceil(H)),U=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),ie=Math.min(M-1,Math.floor(q));if(!(B>U||k>ie))for(let D=k;D<=ie;D++){let K=D;for(let se=B;se<=U;se++){let J=se,Q=(r-J)*(u-K)-(i-K)*(c-J),le=(c-J)*(t-K)-(u-K)*(n-J),I=(n-J)*(i-K)-(t-K)*(r-J);if(_?Q<0||le<0||I<0:Q>0||le>0||I>0)continue;let Ue=(Q*e+le*l+I*p)*g,be=D*G+se,ee=T[be];if(Ue>(ee>0?ee*(1-L):ee)){if(T[be]=Ue,x!==null){let $=be*3;x[$]=(Q*P[0]+le*y[0]+I*E[0])*g,x[$+1]=(Q*P[1]+le*y[1]+I*E[1])*g,x[$+2]=(Q*P[2]+le*y[2]+I*E[2])*g}let te=(Q*o+le*s+I*d)*g,we=f;if(a!==null){let $=(Q*a.ua+le*a.ub+I*a.uc)*g,W=(Q*a.va+le*a.vb+I*a.vc)*g,Y=(0,nt.sampleTexel)(a.sampler,$,W);if(Y!==null&&Y.a>8){let S=Y.r*a.tintR|0;S>255&&(S=255);let O=Y.g*a.tintG|0;O>255&&(O=255);let ne=Y.b*a.tintB|0;ne>255&&(ne=255),we=`#${oe(S)}${oe(O)}${oe(ne)}`,te*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Oe=(te<0?0:te>1?1:te)*m,Ce=Oe|0,Ke=Oe-Ce,yt=Cn[(D&3)*4+(se&3)],R=Ke>yt&&Ce<m?Ce+1:Ce;if(R>m&&(R=m),b!==null){let $=(Q*b.luA+le*b.luB+I*b.luC)*g,W=(Q*b.lvA+le*b.lvB+I*b.lvC)*g,Y=(Q*b.ldA+le*b.ldB+I*b.ldC)*g,S=$|0,O=W|0;if(S>=0&&S<Ee&&O>=0&&O<Ee){let ne=b.map.buf[O*Ee+S];if(ne>-1/0&&Y+b.lift<ne&&(R=Math.max(0,R-Math.round(b.opacity*m)),we!==null)){let he=`shadow:${we}:${R}`,xe=b.litCache.get(he);if(xe===void 0){let ae=Fe(we),me=b.shadowColorRgb,Ae=Math.round(ae[0]*(1-b.opacity)+me[0]*b.opacity),ue=Math.round(ae[1]*(1-b.opacity)+me[1]*b.opacity),ve=Math.round(ae[2]*(1-b.opacity)+me[2]*b.opacity);xe=`#${oe(Ae)}${oe(ue)}${oe(ve)}`,b.litCache.set(he,xe)}we=xe}}}v[be]=h[R],C&&(C[be]=we)}}}}function Ln(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,A=Math.hypot(G,M,b)||1;o[s]=[G/A,M/A,b/A]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function Tn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
1
+ "use strict";var Gt=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var yn=(n,t)=>{for(var e in t)Gt(n,e,{get:t[e],enumerable:!0})},Mt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mn(t))!fn.call(n,r)&&r!==e&&Gt(n,r,{get:()=>t[r],enumerable:!(o=hn(t,r))||o.enumerable});return n},V=(n,t,e)=>(Mt(n,t,"default"),e&&Mt(e,t,"default"));var gn=n=>Mt(Gt({},"__esModule",{value:!0}),n);var N={};yn(N,{DEFAULT_PERSPECTIVE:()=>Tt,DEFAULT_RAMP:()=>Vt,GlyphHotspotElement:()=>ut,GlyphMapControlsElement:()=>ft,GlyphMeshElement:()=>ct,GlyphOrbitControlsElement:()=>mt,GlyphOrthographicCameraElement:()=>pt,GlyphPerspectiveCameraElement:()=>dt,GlyphSceneElement:()=>at,SOLID_RAMP:()=>Xt,WIREFRAME_GLYPHS:()=>$t,WIREFRAME_PALETTES:()=>We,bakeFrames:()=>qt,buildRasterizeContext:()=>tt,createGlyphCamera:()=>Yt,createGlyphFirstPersonControls:()=>en,createGlyphMapControls:()=>lt,createGlyphOrbitControls:()=>st,createGlyphOrthographicCamera:()=>$e,createGlyphPerspectiveCamera:()=>Le,createGlyphScene:()=>it,findGlyphMeshHandle:()=>tn,findMeshUnderPoint:()=>nn,getWireframeGlyphs:()=>je,injectGlyphBaseStyles:()=>rt,pointInMeshElement:()=>_t,projectHotspots:()=>ot,rasterize:()=>qe});module.exports=gn(N);var Kt=require("@glyphcss/core");var Nt=Math.PI/180,Dt=.01,Tt=32e3,bn=Dt*1.01;function Lt(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*Nt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*Nt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Le(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Tt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=Lt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*bn}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],S=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+S/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,S=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Dt;if(y<E)return[NaN,NaN,P,NaN];let A=M/y,L=i*e+b*A/u*t.stretch*t.fovScale,a=l*o+S*A/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function $e(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Yt=$e;var vn={direction:[-.5,-.7,-.5],intensity:1},En={intensity:.4};function wn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function tt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?wn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vn,ambientLight:n.ambientLight??En,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var Vt=" .:-=+*#%@".split(""),Xt=" .:-=+*#%@".split(""),We={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},$t=We.default;function je(n){return We[n]??We.default}function qe(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return An(n,i,l,s,d)}let c=je(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||_n(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return Pn(u,p,i,l,c)}function An(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,$,W,Y)=>{let x=s.project(R,$,W,Y);return[$*.5+(x[0]-$*.5)*r,W*.5+(x[1]-W*.5)*r,x[2],x[3]]}}:s,M=je(n.glyphPalette).solid,b=M.length-1,S=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,q=Fe(u.color??"#ffffff"),B=Fe(p.color??"#ffffff"),U=d&&h>0?Ln(c,h):null,k=new Map,ie=n.textureSamplers??null,D=n.shadow,K=D!=null&&f.length>0?Gn(c,f,g,_,H):null,se=D?.opacity??.25,J=D?.lift??.05,Q=D?.color??"#000000",le=K?Fe(Q):[0,0,0],I=globalThis.__glyphPerfDetail,Ue=I?performance.now():0,be=[],ee=n.shadeCache??null,te=-1,we=(R,$,W,Y)=>{if(K===null||!Y)return null;let x=K,O=Be(R,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),ne=Be($,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),he=Be(W,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax);return{map:x,luA:O[0],lvA:O[1],ldA:O[2],luB:ne[0],lvB:ne[1],ldB:ne[2],luC:he[0],lvC:he[1],ldC:he[2],lift:J,opacity:se,shadowColorRgb:le,shadowColorHex:Q,litCache:k}};for(let R=0;R<c.length;R++){let $=c[R],W=$.vertices;if(W.length<3)continue;let Y=$.uvs,x=null;if(ie!==null&&Y&&Y.length>=W.length){let O=(0,nt.polygonTexture)($);O&&(x=ie.get(O)??null)}for(let O=0;O<W.length;O++)be[O]=G.project(W[O],i,l,o);for(let O=1;O<W.length-1;O++){te++;let ne=0,he=O,Ae=O+1,ae=W[ne],me=W[he],Se=W[Ae],ue=be[ne],ve=be[he],Me=be[Ae],gt=(ue[0]!==ue[0]?1:0)+(ve[0]!==ve[0]?1:0)+(Me[0]!==Me[0]?1:0);if(gt===3||gt===0&&!m&&(ve[0]-ue[0])*(Me[1]-ue[1])-(ve[1]-ue[1])*(Me[0]-ue[0])>0)continue;let _e,Pe,ze,De=null;if(ee!==null&&ee.iA[te]!==void 0)_e=ee.iA[te],Pe=ee.iB[te],ze=ee.iC[te],De=ee.lit[te];else{let j=me[0]-ae[0],fe=me[1]-ae[1],xe=me[2]-ae[2],ye=Se[0]-ae[0],Ze=Se[1]-ae[1],Je=Se[2]-ae[2],Qe=fe*Je-xe*Ze,Ye=xe*ye-j*Je,Z=j*Ze-fe*ye,X=Math.hypot(Qe,Ye,Z)||1,re=Qe/X,ge=Ye/X,ce=Z/X,de,He,bt,vt,Et,wt,At,St,xt;if(U){let Ve=U[R],Ge=Ve[ne],Re=Ve[he],Xe=Ve[Ae];de=Ge[0],He=Ge[1],bt=Ge[2],vt=Re[0],Et=Re[1],wt=Re[2],At=Xe[0],St=Xe[1],xt=Xe[2]}else de=vt=At=re,He=Et=St=ge,bt=wt=xt=ce;let It=de*g+He*_+bt*H,Rt=vt*g+Et*_+wt*H,Bt=At*g+St*_+xt*H,rn=m?Math.abs(It):Math.max(0,-It),on=m?Math.abs(Rt):Math.max(0,-Rt),sn=m?Math.abs(Bt):Math.max(0,-Bt);if(_e=Math.min(1,z+rn*F),Pe=Math.min(1,z+on*F),ze=Math.min(1,z+sn*F),P){let Ve=(_e+Pe+ze)/3,Ge=Math.max(0,Ve-z),Re=$.color??"#ffffff",Xe=Ge*255|0,kt=`${Re}:${Xe}`,et=k.get(kt);if(et===void 0){let Ct=Fe(Re),ln=z*B[0]/255+Ge*q[0]/255,an=z*B[1]/255+Ge*q[1]/255,cn=z*B[2]/255+Ge*q[2]/255,un=Math.min(255,Ct[0]*ln),dn=Math.min(255,Ct[1]*an),pn=Math.min(255,Ct[2]*cn);et=`#${oe(un)}${oe(dn)}${oe(pn)}`,k.set(kt,et)}De=et}ee!==null&&(ee.iA[te]=_e,ee.iB[te]=Pe,ee.iC[te]=ze,ee.lit[te]=De)}let Ft=v[R]??!1,Ie=1+(C?.[R]??0),Ot=null;if(x!==null&&Y){let j=Y[ne],fe=Y[he],xe=Y[Ae],ye=Math.max(0,(_e+Pe+ze)/3-z);Ot={sampler:x,ua:j[0],va:j[1],ub:fe[0],vb:fe[1],uc:xe[0],vc:xe[1],tintR:z*B[0]/255+ye*q[0]/255,tintG:z*B[1]/255+ye*q[1]/255,tintB:z*B[2]/255+ye*q[2]/255}}if(gt===0)Wt(ue[0],ue[1],(ue[3]??ue[2])*Ie,_e,ve[0],ve[1],(ve[3]??ve[2])*Ie,Pe,Me[0],Me[1],(Me[3]??Me[2])*Ie,ze,M,b,De,S,y,E,i,l,we(ae,me,Se,Ft),m,ae,me,Se,L,T,Ot);else{let j=[],fe=[],xe=[ae,me,Se],ye=[_e,Pe,ze],Ze=G.eyeDepth(ae),Je=G.eyeDepth(me),Qe=G.eyeDepth(Se),Ye=[Ze,Je,Qe];for(let Z=0;Z<3;Z++){let X=(Z+1)%3,re=Ye[Z],ge=Ye[X];if(re>0&&(j.push(xe[Z]),fe.push(ye[Z])),re>0!=ge>0){let ce=re/(re-ge),de=xe[Z],He=xe[X];j.push([de[0]+ce*(He[0]-de[0]),de[1]+ce*(He[1]-de[1]),de[2]+ce*(He[2]-de[2])]),fe.push(ye[Z]+ce*(ye[X]-ye[Z]))}}if(j.length>=3){let Z=j.map(X=>G.project(X,i,l,o));for(let X=1;X<j.length-1;X++){let re=Z[0],ge=Z[X],ce=Z[X+1],de=(ge[0]-re[0])*(ce[1]-re[1])-(ge[1]-re[1])*(ce[0]-re[0]);!m&&de>0||Wt(re[0],re[1],(re[3]??re[2])*Ie,fe[0],ge[0],ge[1],(ge[3]??ge[2])*Ie,fe[X],ce[0],ce[1],(ce[3]??ce[2])*Ie,fe[X+1],M,b,De,S,y,E,i,l,we(j[0],j[X],j[X+1],Ft),m,j[0],j[X],j[X+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ue);let Ht=I?performance.now():0,Oe=S,Ce=y,Ke=L;if(r>1){let R=xn(S,y,E,L,t,e,r,M);Oe=R.glyphBuf,Ce=R.colorBuf,Ke=R.worldPos}A&&Sn(Oe,Ce,Ke,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let yt=Tn(Oe,Ce,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ht),yt}function Sn(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Le({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let S=M*o+b,P=h.get(n[S])??0,y=0,E=0,A=0,L=t?t[S]:null;if(L){let D=Fe(L);y=D[0],E=D[1],A=D[2]}let a=0,w=0,g=0,_=0,H=0,F=e[S*3];if(f&&F===F){let D=f([F,e[S*3+1],e[S*3+2]]),K=Math.round(D[0]),se=Math.round(D[1]);if(D[0]===D[0]&&K>=0&&K<o&&se>=0&&se<r){let J=se*o+K;w=c.idx[J],g=c.r[J],_=c.g[J],H=c.b[J],a=s}}let z=1-a,q=z*P+a*w,B=z*y+a*g,U=z*E+a*_,k=z*A+a*H;v[S]=q,C[S]=B,T[S]=U,G[S]=k;let ie=Math.round(q);ie<0?ie=0:ie>d&&(ie=d),n[S]=l[ie],t&&(t[S]=ie===0?null:`#${oe(B)}${oe(U)}${oe(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function xn(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,S=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=Fe(H);M+=F[0],b+=F[1],S+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let A=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[A]=s[L],h&&(h[A]=`#${oe(M/G)}${oe(b/G)}${oe(S/G)}`),m&&(m[A*3]=P/G,m[A*3+1]=y/G,m[A*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var Cn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),Ee=256;function Be(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(Ee-1),G=(v-h)/(m-h)*(Ee-1);return[T,G,C]}function Mn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(Ee-1,Math.floor(C)),S=Math.max(0,Math.ceil(T)),P=Math.min(Ee-1,Math.floor(G));if(M>b||S>P)return;let y=m>0;for(let E=S;E<=P;E++)for(let A=M;A<=b;A++){let L=A,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*Ee+A;H>n[F]&&(n[F]=H)}}function Gn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let S of n[b].vertices){let P=i*S[0]+l*S[1]+s*S[2],y=u*S[0]+p*S[1]+d*S[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(Ee*Ee).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let S=n[b].vertices;if(!(S.length<3))for(let P=1;P<S.length-1;P++){let y=S[0],E=S[P],A=S[P+1],L=Be(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Be(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Be(A,i,l,s,u,p,d,e,o,r,h,m,f,v);Mn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Wt(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,S,P,y,E,A,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!S&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let q=t>i?t:i;u>q&&(q=u);let B=Math.max(0,Math.ceil(H)),U=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),ie=Math.min(M-1,Math.floor(q));if(!(B>U||k>ie))for(let D=k;D<=ie;D++){let K=D;for(let se=B;se<=U;se++){let J=se,Q=(r-J)*(u-K)-(i-K)*(c-J),le=(c-J)*(t-K)-(u-K)*(n-J),I=(n-J)*(i-K)-(t-K)*(r-J);if(_?Q<0||le<0||I<0:Q>0||le>0||I>0)continue;let Ue=(Q*e+le*l+I*p)*g,be=D*G+se,ee=T[be];if(Ue>(ee>0?ee*(1-L):ee)){if(T[be]=Ue,A!==null){let $=be*3;A[$]=(Q*P[0]+le*y[0]+I*E[0])*g,A[$+1]=(Q*P[1]+le*y[1]+I*E[1])*g,A[$+2]=(Q*P[2]+le*y[2]+I*E[2])*g}let te=(Q*o+le*s+I*d)*g,we=f;if(a!==null){let $=(Q*a.ua+le*a.ub+I*a.uc)*g,W=(Q*a.va+le*a.vb+I*a.vc)*g,Y=(0,nt.sampleTexel)(a.sampler,$,W);if(Y!==null&&Y.a>8){let x=Y.r*a.tintR|0;x>255&&(x=255);let O=Y.g*a.tintG|0;O>255&&(O=255);let ne=Y.b*a.tintB|0;ne>255&&(ne=255),we=`#${oe(x)}${oe(O)}${oe(ne)}`,te*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Oe=(te<0?0:te>1?1:te)*m,Ce=Oe|0,Ke=Oe-Ce,yt=Cn[(D&3)*4+(se&3)],R=Ke>yt&&Ce<m?Ce+1:Ce;if(R>m&&(R=m),b!==null){let $=(Q*b.luA+le*b.luB+I*b.luC)*g,W=(Q*b.lvA+le*b.lvB+I*b.lvC)*g,Y=(Q*b.ldA+le*b.ldB+I*b.ldC)*g,x=$|0,O=W|0;if(x>=0&&x<Ee&&O>=0&&O<Ee){let ne=b.map.buf[O*Ee+x];if(ne>-1/0&&Y+b.lift<ne&&(R=Math.max(0,R-Math.round(b.opacity*m)),we!==null)){let he=`shadow:${we}:${R}`,Ae=b.litCache.get(he);if(Ae===void 0){let ae=Fe(we),me=b.shadowColorRgb,Se=Math.round(ae[0]*(1-b.opacity)+me[0]*b.opacity),ue=Math.round(ae[1]*(1-b.opacity)+me[1]*b.opacity),ve=Math.round(ae[2]*(1-b.opacity)+me[2]*b.opacity);Ae=`#${oe(Se)}${oe(ue)}${oe(ve)}`,b.litCache.set(he,Ae)}we=Ae}}}v[be]=h[R],C&&(C[be]=we)}}}}function Ln(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,S=Math.hypot(G,M,b)||1;o[s]=[G/S,M/S,b/S]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function Tn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
2
2
  `)}return r.join("")}function qt(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,i=new Array(t);for(let l=0;l<t;l++){let s=r+l/t*Math.PI*2;e==="y"?o.rotY=s:o.rotX=s,i[l]=qe(n)}return e==="y"?o.rotY=r:o.rotX=r,i}function _n(n,t,e,o,r,i,l,s,c,u){let p=Math.abs(r-e),d=-Math.abs(i-o),h=e<r?1:-1,m=o<i?1:-1,f=p+d;for(;;){if(e>=0&&e<c&&o>=0&&o<u){let C=o*c+e;n[C]<l&&(n[C]=l,t&&(t[C]=s))}if(e===r&&o===i)break;let v=2*f;v>=d&&(f+=d,e+=h),v<=p&&(f+=p,o+=m)}}function Pn(n,t,e,o,r){let i=[],l=null,s="",c=()=>{s&&(l!==null?i.push(`<span style="color:${l}">${s}</span>`):i.push(s),s="")};for(let u=0;u<o;u++){for(let p=0;p<e;p++){let d=u*e+p,h=n[d],m,f;h===0?(m=" ",f=null):(m=h===1?r.thin[Math.random()*r.thin.length|0]:h===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[d]??null:null),f!==l&&(c(),l=f),s+=m}c(),l=null,u<o-1&&i.push(`
3
3
  `)}return i.join("")}var jt=new Map;function Fe(n){let t=jt.get(n);if(t!==void 0)return t;let e=zn(n);return jt.set(n,e),e}function zn(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function oe(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Ut="glyph-styles";function rt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Ut))return;let e=t.createElement("style");e.id=Ut,e.textContent=Hn,t.head.appendChild(e)}var Hn=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@@ -59,5 +59,5 @@
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function ot(n,t,e,o,r){return n.map(i=>{let[l,s,c]=t.project(i.at,e,o,r),u=c>-3&&l>=0&&l<e&&s>=0&&s<o;return{id:i.id,col:l,row:s,depth:c,visible:u}})}var Fn=1;function On(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[i,l,s]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],v=h*d,C=m*d,T=f*d,G=Math.cos(v),M=Math.sin(v),b=Math.cos(C),A=Math.sin(C),P=Math.cos(T),y=Math.sin(T);function E(x){let L=x[0]*c,a=x[1]*u,w=x[2]*p,g=P*L-y*a,_=y*L+P*a,H=w;return L=b*g+A*H,a=_,w=-A*g+b*H,g=L,_=G*a-M*w,H=M*a+G*w,[g+i,_+l,H+s]}return n.map(x=>({...x,vertices:x.vertices.map(E)}))}function it(n,t={}){rt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Le(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let i=n.ownerDocument.createElement("div");i.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(i),n.appendChild(o);let l=new Map,s=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let a=[];for(let g of l.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&a.push(_);if(a.length===0){h&&(h=null,v());return}let w=++m;(0,Kt.buildTextureSamplers)(a).then(g=>{w===m&&(h=g.size>0?g:null,v())})}function v(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],w=[],g=[],_=[],H=!1;for(let k of l.values()){let ie=On(k.polygons,k.transform),D=k.transform.castShadow??!1,K=k.transform.receiveShadow??!1,se=k.transform.depthBias??0;se!==0&&(H=!0);for(let J of ie)a.push(J),w.push(D),g.push(K),_.push(se)}let F=tt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:w,receiveShadowFlags:g,depthBiases:H?_:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let z=globalThis.__glyphPerf,q=z?performance.now():0,B=qe(F),U=z?performance.now():0;if(e.useColors?r.innerHTML=B:r.textContent=B,z){let k=performance.now();(z.raster??(z.raster=[])).push(U-q),(z.dom??(z.dom=[])).push(k-U),(z.polys??(z.polys=[])).push(a.length)}T()}function T(){let{cols:a,rows:w,cellAspect:g,camera:_}=e,H=ot(s.map(B=>B.hotspot),_,a,w,g),F=r.getBoundingClientRect(),z=a>0?F.width/a:8,q=w>0?F.height/w:16;for(let B=0;B<s.length;B++){let{el:U}=s[B],k=H[B];k.visible?(U.style.display="",U.style.left=`${(k.col+.5)*z}px`,U.style.top=`${(k.row+.5)*q}px`,U.style.zIndex=String(Math.round(k.depth*1e3))):U.style.display="none"}}function G(a,w={}){let g=Fn++;return l.set(g,{id:g,polygons:a,transform:w}),d(),f(),v(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(_){let H=l.get(g);H&&(H.transform=_,d(),v())},dispose(){l.delete(g),d(),f(),v()}}}function M(a,w){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[_,H]=a.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${H*e.cellAspect}ch`,w&&g.addEventListener("click",w),i.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:w};return s.push(F),v(),{get el(){return g},remove(){let z=s.indexOf(F);z>=0&&s.splice(z,1),w&&g.removeEventListener("click",w),i.removeChild(g),v()}}}function b(){C()}function A(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!x&&typeof ResizeObserver<"u"?(x=new ResizeObserver(()=>E()),x.observe(n),E()):!e.autoSize&&x&&(x.disconnect(),x=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),v()}function P(){return{...e}}function y(){let w=n.ownerDocument.createElement("span");w.textContent=Array(20).fill("M").join(`
63
- `),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let x=null;e.autoSize&&typeof ResizeObserver<"u"&&(x=new ResizeObserver(()=>E()),x.observe(n),E());function L(){x&&(x.disconnect(),x=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:A,getOptions:P,fit:E,destroy:L}}function st(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Zt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let x=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-x*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let x=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-x))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let x=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(x/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function A(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let x=!!s;o=E.drag??o,r=E.wheel??r,i=Zt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;x&&!L?A():!x&&L&&b()},pause(){c||(c=!0,y(),A(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),A(),c=!0}}}function Zt(n){return n===void 0||n===!1?1:n===!0?-1:n}function lt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Jt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function A(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function x(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",A,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",A),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return x(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=Jt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,x(),y())},destroy(){s||L(),E(),s=!0}}}function Jt(n){return n===void 0||n===!1?1:n===!0?-1:n}function en(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Qt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,x=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+x*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,x=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-x*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+x*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-x*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+x*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function A(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return A(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Qt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,A())},destroy(){c||P(),c=!0}}}function Qt(n){return n===void 0||n===!1?1:n===!0?-1:n}function tn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function _t(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(_t(i,t,e))return i;return null}var In=typeof HTMLElement<"u"?HTMLElement:class{},Rn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Bn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var at=class extends In{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Rn]}getScene(){return this._scene}_readOptions(){let e={},o=Bn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=kn(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Te(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Te(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Te(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Te(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Te(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Te(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Te(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=it(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var ke=require("@glyphcss/core"),Nn=typeof HTMLElement<"u"?HTMLElement:class{},Dn=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function Yn(n){let t=(0,ke.computeSceneBbox)(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,l=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(s=>({...s,vertices:s.vertices.map(c=>[(c[0]-e)*l,(c[1]-o)*l,(c[2]-r)*l])}))}function Pt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Vn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Pt(n)}}function Xn(n){return n.closest("glyph-scene")??null}var ct=class extends Nn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Dn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Pt(this.getAttribute("position")),scale:Vn(this.getAttribute("scale")),rotation:Pt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Xn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await(0,ke.loadMesh)(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?Yn(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=(0,ke.resolveGeometry)(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var $n=typeof HTMLElement<"u"?HTMLElement:class{};function Wn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function jn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function qn(n){return n.closest("glyph-scene")??null}var ut=class extends $n{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Wn(this.getAttribute("at"));if(!e)return;let o=qn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=jn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var Un=typeof HTMLElement<"u"?HTMLElement:class{};function pe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var dt=class extends Un{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Le({rotX:pe(this.getAttribute("rot-x")),rotY:pe(this.getAttribute("rot-y")),distance:pe(this.getAttribute("distance")),perspective:pe(this.getAttribute("perspective")),zoom:pe(this.getAttribute("zoom")),stretch:pe(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=pe(this.getAttribute("rot-x")),s=pe(this.getAttribute("rot-y")),c=pe(this.getAttribute("distance")),u=pe(this.getAttribute("perspective")),p=pe(this.getAttribute("zoom")),d=pe(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Kn=typeof HTMLElement<"u"?HTMLElement:class{};function Ne(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var pt=class extends Kn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=$e({rotX:Ne(this.getAttribute("rot-x")),rotY:Ne(this.getAttribute("rot-y")),zoom:Ne(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Ne(this.getAttribute("rot-x")),s=Ne(this.getAttribute("rot-y")),c=Ne(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Zn=typeof HTMLElement<"u"?HTMLElement:class{};function Jn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ht(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Qn(n){return n.closest("glyph-scene")??null}var mt=class extends Zn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=ht(this.getAttribute("drag")),o=ht(this.getAttribute("wheel")),r=ht(this.getAttribute("invert")),i=ht(this.getAttribute("clamp-pitch")),l=Jn(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Qn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=st(o,this._readOptions())}};var er=typeof HTMLElement<"u"?HTMLElement:class{};function zt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function tr(n){return n.closest("glyph-scene")??null}var ft=class extends er{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=zt(this.getAttribute("drag")),o=zt(this.getAttribute("wheel")),r=zt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=tr(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=lt(o,this._readOptions())}};V(N,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_PERSPECTIVE,DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
62
+ `;function ot(n,t,e,o,r){return n.map(i=>{let[l,s,c]=t.project(i.at,e,o,r),u=c>-3&&l>=0&&l<e&&s>=0&&s<o;return{id:i.id,col:l,row:s,depth:c,visible:u}})}var Fn=1;function On(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[i,l,s]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],v=h*d,C=m*d,T=f*d,G=Math.cos(v),M=Math.sin(v),b=Math.cos(C),S=Math.sin(C),P=Math.cos(T),y=Math.sin(T);function E(A){let L=A[0]*c,a=A[1]*u,w=A[2]*p,g=P*L-y*a,_=y*L+P*a,H=w;return L=b*g+S*H,a=_,w=-S*g+b*H,g=L,_=G*a-M*w,H=M*a+G*w,[g+i,_+l,H+s]}return n.map(A=>({...A,vertices:A.vertices.map(E)}))}function it(n,t={}){rt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Le(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let i=n.ownerDocument.createElement("div");i.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(i),n.appendChild(o);let l=new Map,s=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let a=[];for(let g of l.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&a.push(_);if(a.length===0){h&&(h=null,v());return}let w=++m;(0,Kt.buildTextureSamplers)(a).then(g=>{w===m&&(h=g.size>0?g:null,v())})}function v(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],w=[],g=[],_=[],H=!1;for(let k of l.values()){let ie=On(k.polygons,k.transform),D=k.transform.castShadow??!1,K=k.transform.receiveShadow??!1,se=k.transform.depthBias??0;se!==0&&(H=!0);for(let J of ie)a.push(J),w.push(D),g.push(K),_.push(se)}let F=tt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:w,receiveShadowFlags:g,depthBiases:H?_:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let z=globalThis.__glyphPerf,q=z?performance.now():0,B=qe(F),U=z?performance.now():0;if(e.useColors?r.innerHTML=B:r.textContent=B,z){let k=performance.now();(z.raster??(z.raster=[])).push(U-q),(z.dom??(z.dom=[])).push(k-U),(z.polys??(z.polys=[])).push(a.length)}T()}function T(){let{cols:a,rows:w,cellAspect:g,camera:_}=e,H=ot(s.map(B=>B.hotspot),_,a,w,g),F=r.getBoundingClientRect(),z=a>0?F.width/a:8,q=w>0?F.height/w:16;for(let B=0;B<s.length;B++){let{el:U}=s[B],k=H[B];k.visible?(U.style.display="",U.style.left=`${(k.col+.5)*z}px`,U.style.top=`${(k.row+.5)*q}px`,U.style.zIndex=String(Math.round(k.depth*1e3))):U.style.display="none"}}function G(a,w={}){let g=Fn++;return l.set(g,{id:g,polygons:a,transform:w}),d(),f(),v(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(_){let H=l.get(g);H&&(H.transform=_,d(),v())},dispose(){l.delete(g),d(),f(),v()}}}function M(a,w){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[_,H]=a.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${H*e.cellAspect}ch`,w&&g.addEventListener("click",w),i.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:w};return s.push(F),v(),{get el(){return g},remove(){let z=s.indexOf(F);z>=0&&s.splice(z,1),w&&g.removeEventListener("click",w),i.removeChild(g),v()}}}function b(){C()}function S(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>E()),A.observe(n),E()):!e.autoSize&&A&&(A.disconnect(),A=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),v()}function P(){return{...e}}function y(){let w=n.ownerDocument.createElement("span");w.textContent=Array(20).fill("M").join(`
63
+ `),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>E()),A.observe(n),E());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:S,getOptions:P,fit:E,destroy:L}}function st(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Zt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let A=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-A*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let A=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let A=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(A/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function S(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let A=!!s;o=E.drag??o,r=E.wheel??r,i=Zt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;A&&!L?S():!A&&L&&b()},pause(){c||(c=!0,y(),S(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),S(),c=!0}}}function Zt(n){return n===void 0||n===!1?1:n===!0?-1:n}function lt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Jt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function S(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=Jt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,A(),y())},destroy(){s||L(),E(),s=!0}}}function Jt(n){return n===void 0||n===!1?1:n===!0?-1:n}function en(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Qt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,A=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+A*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,A=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-A*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+A*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-A*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+A*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function S(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return S(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Qt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,S())},destroy(){c||P(),c=!0}}}function Qt(n){return n===void 0||n===!1?1:n===!0?-1:n}function tn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function _t(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(_t(i,t,e))return i;return null}var In=typeof HTMLElement<"u"?HTMLElement:class{},Rn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Bn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var at=class extends In{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Rn]}getScene(){return this._scene}_readOptions(){let e={},o=Bn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=kn(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Te(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Te(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Te(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Te(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Te(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Te(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Te(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=it(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var ke=require("@glyphcss/core"),Nn=typeof HTMLElement<"u"?HTMLElement:class{},Dn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function Pt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Yn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Pt(n)}}function Vn(n){return n.closest("glyph-scene")??null}var ct=class extends Nn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Dn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Pt(this.getAttribute("position")),scale:Yn(this.getAttribute("scale")),rotation:Pt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Vn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await(0,ke.loadMesh)(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?(0,ke.recenterPolygons)(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=(0,ke.resolveGeometry)(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Xn=typeof HTMLElement<"u"?HTMLElement:class{};function $n(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Wn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function jn(n){return n.closest("glyph-scene")??null}var ut=class extends Xn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=$n(this.getAttribute("at"));if(!e)return;let o=jn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=Wn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var qn=typeof HTMLElement<"u"?HTMLElement:class{};function pe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var dt=class extends qn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Le({rotX:pe(this.getAttribute("rot-x")),rotY:pe(this.getAttribute("rot-y")),distance:pe(this.getAttribute("distance")),perspective:pe(this.getAttribute("perspective")),zoom:pe(this.getAttribute("zoom")),stretch:pe(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=pe(this.getAttribute("rot-x")),s=pe(this.getAttribute("rot-y")),c=pe(this.getAttribute("distance")),u=pe(this.getAttribute("perspective")),p=pe(this.getAttribute("zoom")),d=pe(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Un=typeof HTMLElement<"u"?HTMLElement:class{};function Ne(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var pt=class extends Un{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=$e({rotX:Ne(this.getAttribute("rot-x")),rotY:Ne(this.getAttribute("rot-y")),zoom:Ne(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Ne(this.getAttribute("rot-x")),s=Ne(this.getAttribute("rot-y")),c=Ne(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Kn=typeof HTMLElement<"u"?HTMLElement:class{};function Zn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ht(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Jn(n){return n.closest("glyph-scene")??null}var mt=class extends Kn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=ht(this.getAttribute("drag")),o=ht(this.getAttribute("wheel")),r=ht(this.getAttribute("invert")),i=ht(this.getAttribute("clamp-pitch")),l=Zn(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Jn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=st(o,this._readOptions())}};var Qn=typeof HTMLElement<"u"?HTMLElement:class{};function zt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function er(n){return n.closest("glyph-scene")??null}var ft=class extends Qn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=zt(this.getAttribute("drag")),o=zt(this.getAttribute("wheel")),r=zt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=er(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=lt(o,this._readOptions())}};V(N,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_PERSPECTIVE,DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{buildTextureSamplers as wn}from"@glyphcss/core";var zt=Math.PI/180,Ht=.01,Ft=32e3,Zt=Ht*1.01;function ct(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*zt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*zt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Pe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Ft,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=ct([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*Zt}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],A=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+A/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,A=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Ht;if(y<E)return[NaN,NaN,P,NaN];let x=M/y,L=i*e+b*x/u*t.stretch*t.fovScale,a=l*o+A*x/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function qe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Jt=qe;var Qt={direction:[-.5,-.7,-.5],intensity:1},en={intensity:.4};function tn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function ut(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?tn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Qt,ambientLight:n.ambientLight??en,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as sn,polygonTexture as ln}from"@glyphcss/core";var nn=" .:-=+*#%@".split(""),rn=" .:-=+*#%@".split(""),Ue={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},on=Ue.default;function Ke(n){return Ue[n]??Ue.default}function Ze(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return an(n,i,l,s,d)}let c=Ke(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||gn(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return bn(u,p,i,l,c)}function an(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,V,X,D)=>{let S=s.project(R,V,X,D);return[V*.5+(S[0]-V*.5)*r,X*.5+(S[1]-X*.5)*r,S[2],S[3]]}}:s,M=Ke(n.glyphPalette).solid,b=M.length-1,A=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),x=n.temporalBlend>0&&!!n.temporalHistory,L=x?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,W=ze(u.color??"#ffffff"),B=ze(p.color??"#ffffff"),j=d&&h>0?mn(c,h):null,k=new Map,re=n.textureSamplers??null,N=n.shadow,q=N!=null&&f.length>0?hn(c,f,g,_,H):null,oe=N?.opacity??.25,K=N?.lift??.05,Z=N?.color??"#000000",ie=q?ze(Z):[0,0,0],I=globalThis.__glyphPerfDetail,Ye=I?performance.now():0,ye=[],J=n.shadeCache??null,Q=-1,ve=(R,V,X,D)=>{if(q===null||!D)return null;let S=q,O=Ie(R,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Ie(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Ie(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:O[0],lvA:O[1],ldA:O[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:k}};for(let R=0;R<c.length;R++){let V=c[R],X=V.vertices;if(X.length<3)continue;let D=V.uvs,S=null;if(re!==null&&D&&D.length>=X.length){let O=ln(V);O&&(S=re.get(O)??null)}for(let O=0;O<X.length;O++)ye[O]=G.project(X[O],i,l,o);for(let O=1;O<X.length-1;O++){Q++;let ee=0,de=O,Ee=O+1,se=X[ee],pe=X[de],we=X[Ee],ae=ye[ee],ge=ye[de],Se=ye[Ee],et=(ae[0]!==ae[0]?1:0)+(ge[0]!==ge[0]?1:0)+(Se[0]!==Se[0]?1:0);if(et===3||et===0&&!m&&(ge[0]-ae[0])*(Se[1]-ae[1])-(ge[1]-ae[1])*(Se[0]-ae[0])>0)continue;let Ge,Le,Te,Be=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Be=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],xe=pe[2]-se[2],me=we[0]-se[0],Xe=we[1]-se[1],$e=we[2]-se[2],We=he*$e-xe*Xe,ke=xe*me-$*$e,U=$*Xe-he*me,Y=Math.hypot(We,ke,U)||1,te=We/Y,fe=ke/Y,le=U/Y,ce,_e,tt,nt,rt,ot,it,st,lt;if(j){let Ne=j[R],Ce=Ne[ee],Oe=Ne[de],De=Ne[Ee];ce=Ce[0],_e=Ce[1],tt=Ce[2],nt=Oe[0],rt=Oe[1],ot=Oe[2],it=De[0],st=De[1],lt=De[2]}else ce=nt=it=te,_e=rt=st=fe,tt=ot=lt=le;let Lt=ce*g+_e*_+tt*H,Tt=nt*g+rt*_+ot*H,_t=it*g+st*_+lt*H,Yt=m?Math.abs(Lt):Math.max(0,-Lt),Vt=m?Math.abs(Tt):Math.max(0,-Tt),Xt=m?Math.abs(_t):Math.max(0,-_t);if(Ge=Math.min(1,z+Yt*F),Le=Math.min(1,z+Vt*F),Te=Math.min(1,z+Xt*F),P){let Ne=(Ge+Le+Te)/3,Ce=Math.max(0,Ne-z),Oe=V.color??"#ffffff",De=Ce*255|0,Pt=`${Oe}:${De}`,je=k.get(Pt);if(je===void 0){let at=ze(Oe),$t=z*B[0]/255+Ce*W[0]/255,Wt=z*B[1]/255+Ce*W[1]/255,jt=z*B[2]/255+Ce*W[2]/255,qt=Math.min(255,at[0]*$t),Ut=Math.min(255,at[1]*Wt),Kt=Math.min(255,at[2]*jt);je=`#${ne(qt)}${ne(Ut)}${ne(Kt)}`,k.set(Pt,je)}Be=je}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Be)}let Mt=v[R]??!1,Fe=1+(C?.[R]??0),Gt=null;if(S!==null&&D){let $=D[ee],he=D[de],xe=D[Ee],me=Math.max(0,(Ge+Le+Te)/3-z);Gt={sampler:S,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:xe[0],vc:xe[1],tintR:z*B[0]/255+me*W[0]/255,tintG:z*B[1]/255+me*W[1]/255,tintB:z*B[2]/255+me*W[2]/255}}if(et===0)Ot(ae[0],ae[1],(ae[3]??ae[2])*Fe,Ge,ge[0],ge[1],(ge[3]??ge[2])*Fe,Le,Se[0],Se[1],(Se[3]??Se[2])*Fe,Te,M,b,Be,A,y,E,i,l,ve(se,pe,we,Mt),m,se,pe,we,L,T,Gt);else{let $=[],he=[],xe=[se,pe,we],me=[Ge,Le,Te],Xe=G.eyeDepth(se),$e=G.eyeDepth(pe),We=G.eyeDepth(we),ke=[Xe,$e,We];for(let U=0;U<3;U++){let Y=(U+1)%3,te=ke[U],fe=ke[Y];if(te>0&&($.push(xe[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=xe[U],_e=xe[Y];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[Y]-me[U]))}}if($.length>=3){let U=$.map(Y=>G.project(Y,i,l,o));for(let Y=1;Y<$.length-1;Y++){let te=U[0],fe=U[Y],le=U[Y+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||Ot(te[0],te[1],(te[3]??te[2])*Fe,he[0],fe[0],fe[1],(fe[3]??fe[2])*Fe,he[Y],le[0],le[1],(le[3]??le[2])*Fe,he[Y+1],M,b,Be,A,y,E,i,l,ve($[0],$[Y],$[Y+1],Mt),m,$[0],$[Y],$[Y+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ye);let Ct=I?performance.now():0,He=A,Ae=y,Ve=L;if(r>1){let R=un(A,y,E,L,t,e,r,M);He=R.glyphBuf,Ae=R.colorBuf,Ve=R.worldPos}x&&cn(He,Ae,Ve,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let Qe=fn(He,Ae,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ct),Qe}function cn(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Pe({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let A=M*o+b,P=h.get(n[A])??0,y=0,E=0,x=0,L=t?t[A]:null;if(L){let N=ze(L);y=N[0],E=N[1],x=N[2]}let a=0,w=0,g=0,_=0,H=0,F=e[A*3];if(f&&F===F){let N=f([F,e[A*3+1],e[A*3+2]]),q=Math.round(N[0]),oe=Math.round(N[1]);if(N[0]===N[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;w=c.idx[K],g=c.r[K],_=c.g[K],H=c.b[K],a=s}}let z=1-a,W=z*P+a*w,B=z*y+a*g,j=z*E+a*_,k=z*x+a*H;v[A]=W,C[A]=B,T[A]=j,G[A]=k;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[A]=l[re],t&&(t[A]=re===0?null:`#${ne(B)}${ne(j)}${ne(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function un(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,A=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=ze(H);M+=F[0],b+=F[1],A+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let x=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[x]=s[L],h&&(h[x]=`#${ne(M/G)}${ne(b/G)}${ne(A/G)}`),m&&(m[x*3]=P/G,m[x*3+1]=y/G,m[x*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var dn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Ie(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(be-1),G=(v-h)/(m-h)*(be-1);return[T,G,C]}function pn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(be-1,Math.floor(C)),A=Math.max(0,Math.ceil(T)),P=Math.min(be-1,Math.floor(G));if(M>b||A>P)return;let y=m>0;for(let E=A;E<=P;E++)for(let x=M;x<=b;x++){let L=x,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*be+x;H>n[F]&&(n[F]=H)}}function hn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let A of n[b].vertices){let P=i*A[0]+l*A[1]+s*A[2],y=u*A[0]+p*A[1]+d*A[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(be*be).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let A=n[b].vertices;if(!(A.length<3))for(let P=1;P<A.length-1;P++){let y=A[0],E=A[P],x=A[P+1],L=Ie(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Ie(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Ie(x,i,l,s,u,p,d,e,o,r,h,m,f,v);pn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Ot(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,A,P,y,E,x,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!A&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let W=t>i?t:i;u>W&&(W=u);let B=Math.max(0,Math.ceil(H)),j=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),re=Math.min(M-1,Math.floor(W));if(!(B>j||k>re))for(let N=k;N<=re;N++){let q=N;for(let oe=B;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(i-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),I=(n-K)*(i-q)-(t-q)*(r-K);if(_?Z<0||ie<0||I<0:Z>0||ie>0||I>0)continue;let Ye=(Z*e+ie*l+I*p)*g,ye=N*G+oe,J=T[ye];if(Ye>(J>0?J*(1-L):J)){if(T[ye]=Ye,x!==null){let V=ye*3;x[V]=(Z*P[0]+ie*y[0]+I*E[0])*g,x[V+1]=(Z*P[1]+ie*y[1]+I*E[1])*g,x[V+2]=(Z*P[2]+ie*y[2]+I*E[2])*g}let Q=(Z*o+ie*s+I*d)*g,ve=f;if(a!==null){let V=(Z*a.ua+ie*a.ub+I*a.uc)*g,X=(Z*a.va+ie*a.vb+I*a.vc)*g,D=sn(a.sampler,V,X);if(D!==null&&D.a>8){let S=D.r*a.tintR|0;S>255&&(S=255);let O=D.g*a.tintG|0;O>255&&(O=255);let ee=D.b*a.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(O)}${ne(ee)}`,Q*=(.299*D.r+.587*D.g+.114*D.b)/255}}let He=(Q<0?0:Q>1?1:Q)*m,Ae=He|0,Ve=He-Ae,Qe=dn[(N&3)*4+(oe&3)],R=Ve>Qe&&Ae<m?Ae+1:Ae;if(R>m&&(R=m),b!==null){let V=(Z*b.luA+ie*b.luB+I*b.luC)*g,X=(Z*b.lvA+ie*b.lvB+I*b.lvC)*g,D=(Z*b.ldA+ie*b.ldB+I*b.ldC)*g,S=V|0,O=X|0;if(S>=0&&S<be&&O>=0&&O<be){let ee=b.map.buf[O*be+S];if(ee>-1/0&&D+b.lift<ee&&(R=Math.max(0,R-Math.round(b.opacity*m)),ve!==null)){let de=`shadow:${ve}:${R}`,Ee=b.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=b.shadowColorRgb,we=Math.round(se[0]*(1-b.opacity)+pe[0]*b.opacity),ae=Math.round(se[1]*(1-b.opacity)+pe[1]*b.opacity),ge=Math.round(se[2]*(1-b.opacity)+pe[2]*b.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ge)}`,b.litCache.set(de,Ee)}ve=Ee}}}v[ye]=h[R],C&&(C[ye]=ve)}}}}function mn(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,A=Math.hypot(G,M,b)||1;o[s]=[G/A,M/A,b/A]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function fn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
1
+ import{buildTextureSamplers as wn}from"@glyphcss/core";var zt=Math.PI/180,Ht=.01,Ft=32e3,Zt=Ht*1.01;function ct(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*zt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*zt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Pe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Ft,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=ct([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*Zt}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],S=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+S/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,S=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Ht;if(y<E)return[NaN,NaN,P,NaN];let A=M/y,L=i*e+b*A/u*t.stretch*t.fovScale,a=l*o+S*A/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function qe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Jt=qe;var Qt={direction:[-.5,-.7,-.5],intensity:1},en={intensity:.4};function tn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function ut(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?tn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Qt,ambientLight:n.ambientLight??en,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as sn,polygonTexture as ln}from"@glyphcss/core";var nn=" .:-=+*#%@".split(""),rn=" .:-=+*#%@".split(""),Ue={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},on=Ue.default;function Ke(n){return Ue[n]??Ue.default}function Ze(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return an(n,i,l,s,d)}let c=Ke(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||gn(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return bn(u,p,i,l,c)}function an(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,V,X,D)=>{let x=s.project(R,V,X,D);return[V*.5+(x[0]-V*.5)*r,X*.5+(x[1]-X*.5)*r,x[2],x[3]]}}:s,M=Ke(n.glyphPalette).solid,b=M.length-1,S=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,W=ze(u.color??"#ffffff"),B=ze(p.color??"#ffffff"),j=d&&h>0?mn(c,h):null,k=new Map,re=n.textureSamplers??null,N=n.shadow,q=N!=null&&f.length>0?hn(c,f,g,_,H):null,oe=N?.opacity??.25,K=N?.lift??.05,Z=N?.color??"#000000",ie=q?ze(Z):[0,0,0],I=globalThis.__glyphPerfDetail,Ye=I?performance.now():0,ye=[],J=n.shadeCache??null,Q=-1,ve=(R,V,X,D)=>{if(q===null||!D)return null;let x=q,O=Ie(R,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),ee=Ie(V,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),de=Ie(X,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax);return{map:x,luA:O[0],lvA:O[1],ldA:O[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:k}};for(let R=0;R<c.length;R++){let V=c[R],X=V.vertices;if(X.length<3)continue;let D=V.uvs,x=null;if(re!==null&&D&&D.length>=X.length){let O=ln(V);O&&(x=re.get(O)??null)}for(let O=0;O<X.length;O++)ye[O]=G.project(X[O],i,l,o);for(let O=1;O<X.length-1;O++){Q++;let ee=0,de=O,Ee=O+1,se=X[ee],pe=X[de],we=X[Ee],ae=ye[ee],ge=ye[de],xe=ye[Ee],et=(ae[0]!==ae[0]?1:0)+(ge[0]!==ge[0]?1:0)+(xe[0]!==xe[0]?1:0);if(et===3||et===0&&!m&&(ge[0]-ae[0])*(xe[1]-ae[1])-(ge[1]-ae[1])*(xe[0]-ae[0])>0)continue;let Ge,Le,Te,Be=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Be=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],Xe=we[1]-se[1],$e=we[2]-se[2],We=he*$e-Ae*Xe,ke=Ae*me-$*$e,U=$*Xe-he*me,Y=Math.hypot(We,ke,U)||1,te=We/Y,fe=ke/Y,le=U/Y,ce,_e,tt,nt,rt,ot,it,st,lt;if(j){let Ne=j[R],Ce=Ne[ee],Oe=Ne[de],De=Ne[Ee];ce=Ce[0],_e=Ce[1],tt=Ce[2],nt=Oe[0],rt=Oe[1],ot=Oe[2],it=De[0],st=De[1],lt=De[2]}else ce=nt=it=te,_e=rt=st=fe,tt=ot=lt=le;let Lt=ce*g+_e*_+tt*H,Tt=nt*g+rt*_+ot*H,_t=it*g+st*_+lt*H,Yt=m?Math.abs(Lt):Math.max(0,-Lt),Vt=m?Math.abs(Tt):Math.max(0,-Tt),Xt=m?Math.abs(_t):Math.max(0,-_t);if(Ge=Math.min(1,z+Yt*F),Le=Math.min(1,z+Vt*F),Te=Math.min(1,z+Xt*F),P){let Ne=(Ge+Le+Te)/3,Ce=Math.max(0,Ne-z),Oe=V.color??"#ffffff",De=Ce*255|0,Pt=`${Oe}:${De}`,je=k.get(Pt);if(je===void 0){let at=ze(Oe),$t=z*B[0]/255+Ce*W[0]/255,Wt=z*B[1]/255+Ce*W[1]/255,jt=z*B[2]/255+Ce*W[2]/255,qt=Math.min(255,at[0]*$t),Ut=Math.min(255,at[1]*Wt),Kt=Math.min(255,at[2]*jt);je=`#${ne(qt)}${ne(Ut)}${ne(Kt)}`,k.set(Pt,je)}Be=je}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Be)}let Mt=v[R]??!1,Fe=1+(C?.[R]??0),Gt=null;if(x!==null&&D){let $=D[ee],he=D[de],Ae=D[Ee],me=Math.max(0,(Ge+Le+Te)/3-z);Gt={sampler:x,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:Ae[0],vc:Ae[1],tintR:z*B[0]/255+me*W[0]/255,tintG:z*B[1]/255+me*W[1]/255,tintB:z*B[2]/255+me*W[2]/255}}if(et===0)Ot(ae[0],ae[1],(ae[3]??ae[2])*Fe,Ge,ge[0],ge[1],(ge[3]??ge[2])*Fe,Le,xe[0],xe[1],(xe[3]??xe[2])*Fe,Te,M,b,Be,S,y,E,i,l,ve(se,pe,we,Mt),m,se,pe,we,L,T,Gt);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],Xe=G.eyeDepth(se),$e=G.eyeDepth(pe),We=G.eyeDepth(we),ke=[Xe,$e,We];for(let U=0;U<3;U++){let Y=(U+1)%3,te=ke[U],fe=ke[Y];if(te>0&&($.push(Ae[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[Y];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[Y]-me[U]))}}if($.length>=3){let U=$.map(Y=>G.project(Y,i,l,o));for(let Y=1;Y<$.length-1;Y++){let te=U[0],fe=U[Y],le=U[Y+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||Ot(te[0],te[1],(te[3]??te[2])*Fe,he[0],fe[0],fe[1],(fe[3]??fe[2])*Fe,he[Y],le[0],le[1],(le[3]??le[2])*Fe,he[Y+1],M,b,Be,S,y,E,i,l,ve($[0],$[Y],$[Y+1],Mt),m,$[0],$[Y],$[Y+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ye);let Ct=I?performance.now():0,He=S,Se=y,Ve=L;if(r>1){let R=un(S,y,E,L,t,e,r,M);He=R.glyphBuf,Se=R.colorBuf,Ve=R.worldPos}A&&cn(He,Se,Ve,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let Qe=fn(He,Se,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ct),Qe}function cn(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Pe({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let S=M*o+b,P=h.get(n[S])??0,y=0,E=0,A=0,L=t?t[S]:null;if(L){let N=ze(L);y=N[0],E=N[1],A=N[2]}let a=0,w=0,g=0,_=0,H=0,F=e[S*3];if(f&&F===F){let N=f([F,e[S*3+1],e[S*3+2]]),q=Math.round(N[0]),oe=Math.round(N[1]);if(N[0]===N[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;w=c.idx[K],g=c.r[K],_=c.g[K],H=c.b[K],a=s}}let z=1-a,W=z*P+a*w,B=z*y+a*g,j=z*E+a*_,k=z*A+a*H;v[S]=W,C[S]=B,T[S]=j,G[S]=k;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[S]=l[re],t&&(t[S]=re===0?null:`#${ne(B)}${ne(j)}${ne(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function un(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,S=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=ze(H);M+=F[0],b+=F[1],S+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let A=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[A]=s[L],h&&(h[A]=`#${ne(M/G)}${ne(b/G)}${ne(S/G)}`),m&&(m[A*3]=P/G,m[A*3+1]=y/G,m[A*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var dn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Ie(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(be-1),G=(v-h)/(m-h)*(be-1);return[T,G,C]}function pn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(be-1,Math.floor(C)),S=Math.max(0,Math.ceil(T)),P=Math.min(be-1,Math.floor(G));if(M>b||S>P)return;let y=m>0;for(let E=S;E<=P;E++)for(let A=M;A<=b;A++){let L=A,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*be+A;H>n[F]&&(n[F]=H)}}function hn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let S of n[b].vertices){let P=i*S[0]+l*S[1]+s*S[2],y=u*S[0]+p*S[1]+d*S[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(be*be).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let S=n[b].vertices;if(!(S.length<3))for(let P=1;P<S.length-1;P++){let y=S[0],E=S[P],A=S[P+1],L=Ie(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Ie(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Ie(A,i,l,s,u,p,d,e,o,r,h,m,f,v);pn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Ot(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,S,P,y,E,A,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!S&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let W=t>i?t:i;u>W&&(W=u);let B=Math.max(0,Math.ceil(H)),j=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),re=Math.min(M-1,Math.floor(W));if(!(B>j||k>re))for(let N=k;N<=re;N++){let q=N;for(let oe=B;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(i-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),I=(n-K)*(i-q)-(t-q)*(r-K);if(_?Z<0||ie<0||I<0:Z>0||ie>0||I>0)continue;let Ye=(Z*e+ie*l+I*p)*g,ye=N*G+oe,J=T[ye];if(Ye>(J>0?J*(1-L):J)){if(T[ye]=Ye,A!==null){let V=ye*3;A[V]=(Z*P[0]+ie*y[0]+I*E[0])*g,A[V+1]=(Z*P[1]+ie*y[1]+I*E[1])*g,A[V+2]=(Z*P[2]+ie*y[2]+I*E[2])*g}let Q=(Z*o+ie*s+I*d)*g,ve=f;if(a!==null){let V=(Z*a.ua+ie*a.ub+I*a.uc)*g,X=(Z*a.va+ie*a.vb+I*a.vc)*g,D=sn(a.sampler,V,X);if(D!==null&&D.a>8){let x=D.r*a.tintR|0;x>255&&(x=255);let O=D.g*a.tintG|0;O>255&&(O=255);let ee=D.b*a.tintB|0;ee>255&&(ee=255),ve=`#${ne(x)}${ne(O)}${ne(ee)}`,Q*=(.299*D.r+.587*D.g+.114*D.b)/255}}let He=(Q<0?0:Q>1?1:Q)*m,Se=He|0,Ve=He-Se,Qe=dn[(N&3)*4+(oe&3)],R=Ve>Qe&&Se<m?Se+1:Se;if(R>m&&(R=m),b!==null){let V=(Z*b.luA+ie*b.luB+I*b.luC)*g,X=(Z*b.lvA+ie*b.lvB+I*b.lvC)*g,D=(Z*b.ldA+ie*b.ldB+I*b.ldC)*g,x=V|0,O=X|0;if(x>=0&&x<be&&O>=0&&O<be){let ee=b.map.buf[O*be+x];if(ee>-1/0&&D+b.lift<ee&&(R=Math.max(0,R-Math.round(b.opacity*m)),ve!==null)){let de=`shadow:${ve}:${R}`,Ee=b.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=b.shadowColorRgb,we=Math.round(se[0]*(1-b.opacity)+pe[0]*b.opacity),ae=Math.round(se[1]*(1-b.opacity)+pe[1]*b.opacity),ge=Math.round(se[2]*(1-b.opacity)+pe[2]*b.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ge)}`,b.litCache.set(de,Ee)}ve=Ee}}}v[ye]=h[R],C&&(C[ye]=ve)}}}}function mn(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,S=Math.hypot(G,M,b)||1;o[s]=[G/S,M/S,b/S]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function fn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
2
2
  `)}return r.join("")}function yn(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,i=new Array(t);for(let l=0;l<t;l++){let s=r+l/t*Math.PI*2;e==="y"?o.rotY=s:o.rotX=s,i[l]=Ze(n)}return e==="y"?o.rotY=r:o.rotX=r,i}function gn(n,t,e,o,r,i,l,s,c,u){let p=Math.abs(r-e),d=-Math.abs(i-o),h=e<r?1:-1,m=o<i?1:-1,f=p+d;for(;;){if(e>=0&&e<c&&o>=0&&o<u){let C=o*c+e;n[C]<l&&(n[C]=l,t&&(t[C]=s))}if(e===r&&o===i)break;let v=2*f;v>=d&&(f+=d,e+=h),v<=p&&(f+=p,o+=m)}}function bn(n,t,e,o,r){let i=[],l=null,s="",c=()=>{s&&(l!==null?i.push(`<span style="color:${l}">${s}</span>`):i.push(s),s="")};for(let u=0;u<o;u++){for(let p=0;p<e;p++){let d=u*e+p,h=n[d],m,f;h===0?(m=" ",f=null):(m=h===1?r.thin[Math.random()*r.thin.length|0]:h===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[d]??null:null),f!==l&&(c(),l=f),s+=m}c(),l=null,u<o-1&&i.push(`
3
3
  `)}return i.join("")}var It=new Map;function ze(n){let t=It.get(n);if(t!==void 0)return t;let e=vn(n);return It.set(n,e),e}function vn(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function ne(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Rt="glyph-styles";function dt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Rt))return;let e=t.createElement("style");e.id=Rt,e.textContent=En,t.head.appendChild(e)}var En=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@@ -59,5 +59,5 @@ import{buildTextureSamplers as wn}from"@glyphcss/core";var zt=Math.PI/180,Ht=.01
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function pt(n,t,e,o,r){return n.map(i=>{let[l,s,c]=t.project(i.at,e,o,r),u=c>-3&&l>=0&&l<e&&s>=0&&s<o;return{id:i.id,col:l,row:s,depth:c,visible:u}})}var xn=1;function An(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[i,l,s]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],v=h*d,C=m*d,T=f*d,G=Math.cos(v),M=Math.sin(v),b=Math.cos(C),A=Math.sin(C),P=Math.cos(T),y=Math.sin(T);function E(x){let L=x[0]*c,a=x[1]*u,w=x[2]*p,g=P*L-y*a,_=y*L+P*a,H=w;return L=b*g+A*H,a=_,w=-A*g+b*H,g=L,_=G*a-M*w,H=M*a+G*w,[g+i,_+l,H+s]}return n.map(x=>({...x,vertices:x.vertices.map(E)}))}function ht(n,t={}){dt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Pe(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let i=n.ownerDocument.createElement("div");i.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(i),n.appendChild(o);let l=new Map,s=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let a=[];for(let g of l.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&a.push(_);if(a.length===0){h&&(h=null,v());return}let w=++m;wn(a).then(g=>{w===m&&(h=g.size>0?g:null,v())})}function v(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],w=[],g=[],_=[],H=!1;for(let k of l.values()){let re=An(k.polygons,k.transform),N=k.transform.castShadow??!1,q=k.transform.receiveShadow??!1,oe=k.transform.depthBias??0;oe!==0&&(H=!0);for(let K of re)a.push(K),w.push(N),g.push(q),_.push(oe)}let F=ut({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:w,receiveShadowFlags:g,depthBiases:H?_:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let z=globalThis.__glyphPerf,W=z?performance.now():0,B=Ze(F),j=z?performance.now():0;if(e.useColors?r.innerHTML=B:r.textContent=B,z){let k=performance.now();(z.raster??(z.raster=[])).push(j-W),(z.dom??(z.dom=[])).push(k-j),(z.polys??(z.polys=[])).push(a.length)}T()}function T(){let{cols:a,rows:w,cellAspect:g,camera:_}=e,H=pt(s.map(B=>B.hotspot),_,a,w,g),F=r.getBoundingClientRect(),z=a>0?F.width/a:8,W=w>0?F.height/w:16;for(let B=0;B<s.length;B++){let{el:j}=s[B],k=H[B];k.visible?(j.style.display="",j.style.left=`${(k.col+.5)*z}px`,j.style.top=`${(k.row+.5)*W}px`,j.style.zIndex=String(Math.round(k.depth*1e3))):j.style.display="none"}}function G(a,w={}){let g=xn++;return l.set(g,{id:g,polygons:a,transform:w}),d(),f(),v(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(_){let H=l.get(g);H&&(H.transform=_,d(),v())},dispose(){l.delete(g),d(),f(),v()}}}function M(a,w){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[_,H]=a.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${H*e.cellAspect}ch`,w&&g.addEventListener("click",w),i.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:w};return s.push(F),v(),{get el(){return g},remove(){let z=s.indexOf(F);z>=0&&s.splice(z,1),w&&g.removeEventListener("click",w),i.removeChild(g),v()}}}function b(){C()}function A(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!x&&typeof ResizeObserver<"u"?(x=new ResizeObserver(()=>E()),x.observe(n),E()):!e.autoSize&&x&&(x.disconnect(),x=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),v()}function P(){return{...e}}function y(){let w=n.ownerDocument.createElement("span");w.textContent=Array(20).fill("M").join(`
63
- `),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let x=null;e.autoSize&&typeof ResizeObserver<"u"&&(x=new ResizeObserver(()=>E()),x.observe(n),E());function L(){x&&(x.disconnect(),x=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:A,getOptions:P,fit:E,destroy:L}}function mt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Bt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let x=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-x*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let x=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-x))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let x=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(x/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function A(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let x=!!s;o=E.drag??o,r=E.wheel??r,i=Bt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;x&&!L?A():!x&&L&&b()},pause(){c||(c=!0,y(),A(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),A(),c=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}function ft(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=kt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function A(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function x(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",A,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",A),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return x(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=kt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,x(),y())},destroy(){s||L(),E(),s=!0}}}function kt(n){return n===void 0||n===!1?1:n===!0?-1:n}function Sn(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Nt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,x=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+x*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,x=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-x*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+x*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-x*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+x*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function A(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return A(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Nt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,A())},destroy(){c||P(),c=!0}}}function Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}function Cn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function Dt(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function Mn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(Dt(i,t,e))return i;return null}var Gn=typeof HTMLElement<"u"?HTMLElement:class{},Ln=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Tn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function _n(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var yt=class extends Gn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Ln]}getScene(){return this._scene}_readOptions(){let e={},o=Tn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=_n(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Me(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Me(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Me(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Me(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Me(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Me(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Me(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Me(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=ht(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Pn,resolveGeometry as zn,computeSceneBbox as Hn}from"@glyphcss/core";var Fn=typeof HTMLElement<"u"?HTMLElement:class{},On=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function In(n){let t=Hn(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,l=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(s=>({...s,vertices:s.vertices.map(c=>[(c[0]-e)*l,(c[1]-o)*l,(c[2]-r)*l])}))}function gt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Rn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return gt(n)}}function Bn(n){return n.closest("glyph-scene")??null}var bt=class extends Fn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...On]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:gt(this.getAttribute("position")),scale:Rn(this.getAttribute("scale")),rotation:gt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Bn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await Pn(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?In(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=zn(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var kn=typeof HTMLElement<"u"?HTMLElement:class{};function Nn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Dn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function Yn(n){return n.closest("glyph-scene")??null}var vt=class extends kn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Nn(this.getAttribute("at"));if(!e)return;let o=Yn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=Dn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var Vn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Et=class extends Vn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Pe({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=ue(this.getAttribute("rot-x")),s=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Xn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var wt=class extends Xn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=qe({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Re(this.getAttribute("rot-x")),s=Re(this.getAttribute("rot-y")),c=Re(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var $n=typeof HTMLElement<"u"?HTMLElement:class{};function Wn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Je(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function jn(n){return n.closest("glyph-scene")??null}var xt=class extends $n{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Je(this.getAttribute("drag")),o=Je(this.getAttribute("wheel")),r=Je(this.getAttribute("invert")),i=Je(this.getAttribute("clamp-pitch")),l=Wn(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=jn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=mt(o,this._readOptions())}};var qn=typeof HTMLElement<"u"?HTMLElement:class{};function At(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Un(n){return n.closest("glyph-scene")??null}var St=class extends qn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=At(this.getAttribute("drag")),o=At(this.getAttribute("wheel")),r=At(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Un(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=ft(o,this._readOptions())}};export*from"@glyphcss/core";export{Ft as DEFAULT_PERSPECTIVE,nn as DEFAULT_RAMP,vt as GlyphHotspotElement,St as GlyphMapControlsElement,bt as GlyphMeshElement,xt as GlyphOrbitControlsElement,wt as GlyphOrthographicCameraElement,Et as GlyphPerspectiveCameraElement,yt as GlyphSceneElement,rn as SOLID_RAMP,on as WIREFRAME_GLYPHS,Ue as WIREFRAME_PALETTES,yn as bakeFrames,ut as buildRasterizeContext,Jt as createGlyphCamera,Sn as createGlyphFirstPersonControls,ft as createGlyphMapControls,mt as createGlyphOrbitControls,qe as createGlyphOrthographicCamera,Pe as createGlyphPerspectiveCamera,ht as createGlyphScene,Cn as findGlyphMeshHandle,Mn as findMeshUnderPoint,Ke as getWireframeGlyphs,dt as injectGlyphBaseStyles,Dt as pointInMeshElement,pt as projectHotspots,Ze as rasterize};
62
+ `;function pt(n,t,e,o,r){return n.map(i=>{let[l,s,c]=t.project(i.at,e,o,r),u=c>-3&&l>=0&&l<e&&s>=0&&s<o;return{id:i.id,col:l,row:s,depth:c,visible:u}})}var An=1;function Sn(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[i,l,s]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],v=h*d,C=m*d,T=f*d,G=Math.cos(v),M=Math.sin(v),b=Math.cos(C),S=Math.sin(C),P=Math.cos(T),y=Math.sin(T);function E(A){let L=A[0]*c,a=A[1]*u,w=A[2]*p,g=P*L-y*a,_=y*L+P*a,H=w;return L=b*g+S*H,a=_,w=-S*g+b*H,g=L,_=G*a-M*w,H=M*a+G*w,[g+i,_+l,H+s]}return n.map(A=>({...A,vertices:A.vertices.map(E)}))}function ht(n,t={}){dt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Pe(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let i=n.ownerDocument.createElement("div");i.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(i),n.appendChild(o);let l=new Map,s=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let a=[];for(let g of l.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&a.push(_);if(a.length===0){h&&(h=null,v());return}let w=++m;wn(a).then(g=>{w===m&&(h=g.size>0?g:null,v())})}function v(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],w=[],g=[],_=[],H=!1;for(let k of l.values()){let re=Sn(k.polygons,k.transform),N=k.transform.castShadow??!1,q=k.transform.receiveShadow??!1,oe=k.transform.depthBias??0;oe!==0&&(H=!0);for(let K of re)a.push(K),w.push(N),g.push(q),_.push(oe)}let F=ut({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:w,receiveShadowFlags:g,depthBiases:H?_:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let z=globalThis.__glyphPerf,W=z?performance.now():0,B=Ze(F),j=z?performance.now():0;if(e.useColors?r.innerHTML=B:r.textContent=B,z){let k=performance.now();(z.raster??(z.raster=[])).push(j-W),(z.dom??(z.dom=[])).push(k-j),(z.polys??(z.polys=[])).push(a.length)}T()}function T(){let{cols:a,rows:w,cellAspect:g,camera:_}=e,H=pt(s.map(B=>B.hotspot),_,a,w,g),F=r.getBoundingClientRect(),z=a>0?F.width/a:8,W=w>0?F.height/w:16;for(let B=0;B<s.length;B++){let{el:j}=s[B],k=H[B];k.visible?(j.style.display="",j.style.left=`${(k.col+.5)*z}px`,j.style.top=`${(k.row+.5)*W}px`,j.style.zIndex=String(Math.round(k.depth*1e3))):j.style.display="none"}}function G(a,w={}){let g=An++;return l.set(g,{id:g,polygons:a,transform:w}),d(),f(),v(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(_){let H=l.get(g);H&&(H.transform=_,d(),v())},dispose(){l.delete(g),d(),f(),v()}}}function M(a,w){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[_,H]=a.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${H*e.cellAspect}ch`,w&&g.addEventListener("click",w),i.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:w};return s.push(F),v(),{get el(){return g},remove(){let z=s.indexOf(F);z>=0&&s.splice(z,1),w&&g.removeEventListener("click",w),i.removeChild(g),v()}}}function b(){C()}function S(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!A&&typeof ResizeObserver<"u"?(A=new ResizeObserver(()=>E()),A.observe(n),E()):!e.autoSize&&A&&(A.disconnect(),A=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),v()}function P(){return{...e}}function y(){let w=n.ownerDocument.createElement("span");w.textContent=Array(20).fill("M").join(`
63
+ `),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>E()),A.observe(n),E());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:S,getOptions:P,fit:E,destroy:L}}function mt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Bt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let A=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-A*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let A=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let A=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(A/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function S(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let A=!!s;o=E.drag??o,r=E.wheel??r,i=Bt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;A&&!L?S():!A&&L&&b()},pause(){c||(c=!0,y(),S(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),S(),c=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}function ft(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=kt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function S(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=kt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,A(),y())},destroy(){s||L(),E(),s=!0}}}function kt(n){return n===void 0||n===!1?1:n===!0?-1:n}function xn(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Nt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,A=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+A*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,A=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-A*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+A*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-A*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+A*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function S(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return S(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Nt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,S())},destroy(){c||P(),c=!0}}}function Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}function Cn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function Dt(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function Mn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(Dt(i,t,e))return i;return null}var Gn=typeof HTMLElement<"u"?HTMLElement:class{},Ln=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Tn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function _n(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var yt=class extends Gn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Ln]}getScene(){return this._scene}_readOptions(){let e={},o=Tn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=_n(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Me(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Me(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Me(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Me(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Me(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Me(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Me(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Me(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=ht(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Pn,resolveGeometry as zn,recenterPolygons as Hn}from"@glyphcss/core";var Fn=typeof HTMLElement<"u"?HTMLElement:class{},On=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function gt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function In(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return gt(n)}}function Rn(n){return n.closest("glyph-scene")??null}var bt=class extends Fn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...On]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:gt(this.getAttribute("position")),scale:In(this.getAttribute("scale")),rotation:gt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Rn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await Pn(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?Hn(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=zn(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function kn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Nn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function Dn(n){return n.closest("glyph-scene")??null}var vt=class extends Bn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=kn(this.getAttribute("at"));if(!e)return;let o=Dn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=Nn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var Yn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Et=class extends Yn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Pe({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=ue(this.getAttribute("rot-x")),s=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Vn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var wt=class extends Vn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=qe({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Re(this.getAttribute("rot-x")),s=Re(this.getAttribute("rot-y")),c=Re(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Xn=typeof HTMLElement<"u"?HTMLElement:class{};function $n(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Je(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Wn(n){return n.closest("glyph-scene")??null}var At=class extends Xn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Je(this.getAttribute("drag")),o=Je(this.getAttribute("wheel")),r=Je(this.getAttribute("invert")),i=Je(this.getAttribute("clamp-pitch")),l=$n(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Wn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=mt(o,this._readOptions())}};var jn=typeof HTMLElement<"u"?HTMLElement:class{};function St(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function qn(n){return n.closest("glyph-scene")??null}var xt=class extends jn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=St(this.getAttribute("drag")),o=St(this.getAttribute("wheel")),r=St(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=qn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=ft(o,this._readOptions())}};export*from"@glyphcss/core";export{Ft as DEFAULT_PERSPECTIVE,nn as DEFAULT_RAMP,vt as GlyphHotspotElement,xt as GlyphMapControlsElement,bt as GlyphMeshElement,At as GlyphOrbitControlsElement,wt as GlyphOrthographicCameraElement,Et as GlyphPerspectiveCameraElement,yt as GlyphSceneElement,rn as SOLID_RAMP,on as WIREFRAME_GLYPHS,Ue as WIREFRAME_PALETTES,yn as bakeFrames,ut as buildRasterizeContext,Jt as createGlyphCamera,xn as createGlyphFirstPersonControls,ft as createGlyphMapControls,mt as createGlyphOrbitControls,qe as createGlyphOrthographicCamera,Pe as createGlyphPerspectiveCamera,ht as createGlyphScene,Cn as findGlyphMeshHandle,Mn as findMeshUnderPoint,Ke as getWireframeGlyphs,dt as injectGlyphBaseStyles,Dt as pointInMeshElement,pt as projectHotspots,Ze as rasterize};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glyphcss",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Glyphcss — ASCII paint backend with glyphcss's scene-composition API. Renders 3D meshes as ASCII art in a <pre> element.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@glyphcss/core": "^0.0.5"
36
+ "@glyphcss/core": "^0.0.6"
37
37
  },
38
38
  "devDependencies": {
39
39
  "tsup": "^8.0.1",