@mlightcad/cad-simple-viewer-cli 1.7.6-preview.0 → 1.7.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.
@@ -1,1564 +0,0 @@
1
- import{$ as vr,a as kr,E as At,h as A,x as st,F as U,G as Ar,b as $,H as Mr,o as Ie,I as Fr,J as jt,K as zr,L as Cr,O as Ue,N as Sr,P as Ee,Q as Pr,R as F,S as Lr,U as Br,V as Ir,g as Ur,W as Er,X as Ma,Y as Dr,Z as Nr,_ as Fa,a0 as Tr,a1 as Or,a2 as Rr,a3 as _r,a4 as $r,a5 as jr,a6 as Hr,a7 as ie,a8 as Vr,a9 as Yr,aa as Xr,ab as Gr,ac as Wr,ad as Kr,ae as Jr,af as Zr,ag as qr,ah as Qr,ai as tn,aj as en,ak as an,al as rn,am as nn,an as on,ao as sn,ap as ln,aq as cn,ar as dn,as as un,at as lt,au as za,av as mn,aw as oe,p as pn,ax as hn,ay as fn,az as gn}from"./index-zOqzz2XY.js";import{aA as Ys,aB as Xs}from"./index-zOqzz2XY.js";function se(...t){return`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 1024 1024">${t.map(a=>`<path fill="currentColor" d="${a}"/>`).join("")}</svg>`}se("M624 475.968V640h144a128 128 0 0 1 128 128H128a128 128 0 0 1 128-128h144V475.968a192 192 0 1 1 224 0M128 896v-64h768v64z");se("M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352m0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288m0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448m0 64a160.19 160.19 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160");se("M876.8 156.8c0-9.6-3.2-16-9.6-22.4s-12.8-9.6-22.4-9.6-16 3.2-22.4 9.6L736 220.8c-64-32-137.6-51.2-224-60.8-160 16-288 73.6-377.6 176S0 496 0 512s48 73.6 134.4 176c22.4 25.6 44.8 48 73.6 67.2l-86.4 89.6c-6.4 6.4-9.6 12.8-9.6 22.4s3.2 16 9.6 22.4 12.8 9.6 22.4 9.6 16-3.2 22.4-9.6l704-710.4c3.2-6.4 6.4-12.8 6.4-22.4m-646.4 528Q115.2 579.2 76.8 512q43.2-72 153.6-172.8C304 272 400 230.4 512 224c64 3.2 124.8 19.2 176 44.8l-54.4 54.4C598.4 300.8 560 288 512 288c-64 0-115.2 22.4-160 64s-64 96-64 160c0 48 12.8 89.6 35.2 124.8L256 707.2c-9.6-6.4-19.2-16-25.6-22.4m140.8-96Q352 555.2 352 512c0-44.8 16-83.2 48-112s67.2-48 112-48c28.8 0 54.4 6.4 73.6 19.2zM889.599 336c-12.8-16-28.8-28.8-41.6-41.6l-48 48c73.6 67.2 124.8 124.8 150.4 169.6q-43.2 72-153.6 172.8c-73.6 67.2-172.8 108.8-284.8 115.2-51.2-3.2-99.2-12.8-140.8-28.8l-48 48c57.6 22.4 118.4 38.4 188.8 44.8 160-16 288-73.6 377.6-176S1024 528 1024 512s-48.001-73.6-134.401-176","M511.998 672c-12.8 0-25.6-3.2-38.4-6.4l-51.2 51.2c28.8 12.8 57.6 19.2 89.6 19.2 64 0 115.2-22.4 160-64 41.6-41.6 64-96 64-160 0-32-6.4-64-19.2-89.6l-51.2 51.2c3.2 12.8 6.4 25.6 6.4 38.4 0 44.8-16 83.2-48 112s-67.2 48-112 48");const bn='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10 13.5 14.5 9h-9L10 13.5Z"/></svg>',wn='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 3.53 16.09 6.97 10.09 10.29 4.18 7 10.09 3.56M10.09 2.4 2.17 7 3.31 7.65 10.09 11.45 17 7.62 18.17 7 10.08 2.37 10.09 2.4Z"/><path fill="currentColor" d="M10.25 14.83 18.17 10.22 17 9.57 10.22 13.57 3.32 9.59 2.17 10.22 10.25 14.83Z"/><path fill="currentColor" d="M10.25 17.63 18.17 13 17 12.37 10.22 16.37 3.32 12.38 2.17 13 10.25 17.63Z"/></svg>',xn='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 5.15 16.09 8.59 10.09 11.91 4.18 8.59 10.09 5.15ZM10.09 4 2.17 8.61 3.31 9.25 10.09 13.06 17 9.24 18.16 8.61 10.08 4 10.09 4Z"/><path fill="currentColor" d="M10.25 16.46 18.17 11.85 17 11.2 10.22 15.2 3.32 11.21 2.17 11.85 10.25 16.46Z"/><path fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" d="M3.5 3.5 16.5 16.5"/></svg>',Y=4;var E=Uint8Array,T=Uint16Array,le=Int32Array,ce=new E([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),de=new E([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),De=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ca=function(t,e){for(var a=new T(31),r=0;r<31;++r)a[r]=e+=1<<t[r-1];for(var n=new le(a[30]),r=1;r<30;++r)for(var i=a[r];i<a[r+1];++i)n[i]=i-a[r]<<5|r;return{b:a,r:n}},Sa=Ca(ce,2),yn=Sa.b,Gt=Sa.r;yn[28]=258,Gt[258]=28;var vn=Ca(de,0),Ne=vn.r,Wt=new T(32768);for(var M=0;M<32768;++M){var W=(M&43690)>>1|(M&21845)<<1;W=(W&52428)>>2|(W&13107)<<2,W=(W&61680)>>4|(W&3855)<<4,Wt[M]=((W&65280)>>8|(W&255)<<8)>>1}var gt=(function(t,e,a){for(var r=t.length,n=0,i=new T(e);n<r;++n)t[n]&&++i[t[n]-1];var o=new T(e);for(n=1;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var s;if(a){s=new T(1<<e);var l=15-e;for(n=0;n<r;++n)if(t[n])for(var c=n<<4|t[n],d=e-t[n],u=o[t[n]-1]++<<d,m=u|(1<<d)-1;u<=m;++u)s[Wt[u]>>l]=c}else for(s=new T(r),n=0;n<r;++n)t[n]&&(s[n]=Wt[o[t[n]-1]++]>>15-t[n]);return s}),Q=new E(288);for(var M=0;M<144;++M)Q[M]=8;for(var M=144;M<256;++M)Q[M]=9;for(var M=256;M<280;++M)Q[M]=7;for(var M=280;M<288;++M)Q[M]=8;var Ct=new E(32);for(var M=0;M<32;++M)Ct[M]=5;var kn=gt(Q,9,0),An=gt(Ct,5,0),Pa=function(t){return(t+7)/8|0},La=function(t,e,a){return(a==null||a>t.length)&&(a=t.length),new E(t.subarray(e,a))},Mn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Et=function(t,e,a){var r=new Error(e||Mn[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Et),!a)throw r;return r},X=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8},mt=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8,t[r+2]|=a>>16},Ht=function(t,e){for(var a=[],r=0;r<t.length;++r)t[r]&&a.push({s:r,f:t[r]});var n=a.length,i=a.slice();if(!n)return{t:Ia,l:0};if(n==1){var o=new E(a[0].s+1);return o[a[0].s]=1,{t:o,l:1}}a.sort(function(z,L){return z.f-L.f}),a.push({s:-1,f:25001});var s=a[0],l=a[1],c=0,d=1,u=2;for(a[0]={s:-1,f:s.f+l.f,l:s,r:l};d!=n-1;)s=a[a[c].f<a[u].f?c++:u++],l=a[c!=d&&a[c].f<a[u].f?c++:u++],a[d++]={s:-1,f:s.f+l.f,l:s,r:l};for(var m=i[0].s,r=1;r<n;++r)i[r].s>m&&(m=i[r].s);var p=new T(m+1),h=Kt(a[d-1],p,0);if(h>e){var r=0,g=0,b=h-e,f=1<<b;for(i.sort(function(L,C){return p[C.s]-p[L.s]||L.f-C.f});r<n;++r){var w=i[r].s;if(p[w]>e)g+=f-(1<<h-p[w]),p[w]=e;else break}for(g>>=b;g>0;){var k=i[r].s;p[k]<e?g-=1<<e-p[k]++-1:++r}for(;r>=0&&g;--r){var y=i[r].s;p[y]==e&&(--p[y],++g)}h=e}return{t:new E(p),l:h}},Kt=function(t,e,a){return t.s==-1?Math.max(Kt(t.l,e,a+1),Kt(t.r,e,a+1)):e[t.s]=a},Te=function(t){for(var e=t.length;e&&!t[--e];);for(var a=new T(++e),r=0,n=t[0],i=1,o=function(l){a[r++]=l},s=1;s<=e;++s)if(t[s]==n&&s!=e)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=t[s]}return{c:a.subarray(0,r),n:e}},pt=function(t,e){for(var a=0,r=0;r<e.length;++r)a+=t[r]*e[r];return a},Ba=function(t,e,a){var r=a.length,n=Pa(e+2);t[n]=r&255,t[n+1]=r>>8,t[n+2]=t[n]^255,t[n+3]=t[n+1]^255;for(var i=0;i<r;++i)t[n+i+4]=a[i];return(n+4+r)*8},Oe=function(t,e,a,r,n,i,o,s,l,c,d){X(e,d++,a),++n[256];for(var u=Ht(n,15),m=u.t,p=u.l,h=Ht(i,15),g=h.t,b=h.l,f=Te(m),w=f.c,k=f.n,y=Te(g),z=y.c,L=y.n,C=new T(19),v=0;v<w.length;++v)++C[w[v]&31];for(var v=0;v<z.length;++v)++C[z[v]&31];for(var x=Ht(C,7),D=x.t,at=x.l,N=19;N>4&&!D[De[N-1]];--N);var rt=c+5<<3,O=pt(n,Q)+pt(i,Ct)+o,R=pt(n,m)+pt(i,g)+o+14+3*N+pt(C,D)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&rt<=O&&rt<=R)return Ba(e,d,t.subarray(l,l+c));var j,B,_,G;if(X(e,d,1+(R<O)),d+=2,R<O){j=gt(m,p,0),B=m,_=gt(g,b,0),G=g;var Ot=gt(D,at,0);X(e,d,k-257),X(e,d+5,L-1),X(e,d+10,N-4),d+=14;for(var v=0;v<N;++v)X(e,d+3*v,D[De[v]]);d+=3*N;for(var H=[w,z],ut=0;ut<2;++ut)for(var nt=H[ut],v=0;v<nt.length;++v){var V=nt[v]&31;X(e,d,Ot[V]),d+=D[V],V>15&&(X(e,d,nt[v]>>5&127),d+=nt[v]>>12)}}else j=kn,B=Q,_=An,G=Ct;for(var v=0;v<s;++v){var I=r[v];if(I>255){var V=I>>18&31;mt(e,d,j[V+257]),d+=B[V+257],V>7&&(X(e,d,I>>23&31),d+=ce[V]);var it=I&31;mt(e,d,_[it]),d+=G[it],it>3&&(mt(e,d,I>>5&8191),d+=de[it])}else mt(e,d,j[I]),d+=B[I]}return mt(e,d,j[256]),d+B[256]},Fn=new le([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ia=new E(0),zn=function(t,e,a,r,n,i){var o=i.z||t.length,s=new E(r+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(r,s.length-n),c=i.l,d=(i.r||0)&7;if(e){d&&(l[0]=i.r>>3);for(var u=Fn[e-1],m=u>>13,p=u&8191,h=(1<<a)-1,g=i.p||new T(32768),b=i.h||new T(h+1),f=Math.ceil(a/3),w=2*f,k=function($t){return(t[$t]^t[$t+1]<<f^t[$t+2]<<w)&h},y=new le(25e3),z=new T(288),L=new T(32),C=0,v=0,x=i.i||0,D=0,at=i.w||0,N=0;x+2<o;++x){var rt=k(x),O=x&32767,R=b[rt];if(g[O]=R,b[rt]=O,at<=x){var j=o-x;if((C>7e3||D>24576)&&(j>423||!c)){d=Oe(t,l,0,y,z,L,v,D,N,x-N,d),D=C=v=0,N=x;for(var B=0;B<286;++B)z[B]=0;for(var B=0;B<30;++B)L[B]=0}var _=2,G=0,Ot=p,H=O-R&32767;if(j>2&&rt==k(x-H))for(var ut=Math.min(m,j)-1,nt=Math.min(32767,x),V=Math.min(258,j);H<=nt&&--Ot&&O!=R;){if(t[x+_]==t[x+_-H]){for(var I=0;I<V&&t[x+I]==t[x+I-H];++I);if(I>_){if(_=I,G=H,I>ut)break;for(var it=Math.min(H,I-2),Se=0,B=0;B<it;++B){var Rt=x-H+B&32767,yr=g[Rt],Pe=Rt-yr&32767;Pe>Se&&(Se=Pe,R=Rt)}}}O=R,R=g[O],H+=O-R&32767}if(G){y[D++]=268435456|Gt[_]<<18|Ne[G];var Le=Gt[_]&31,Be=Ne[G]&31;v+=ce[Le]+de[Be],++z[257+Le],++L[Be],at=x+_,++C}else y[D++]=t[x],++z[t[x]]}}for(x=Math.max(x,at);x<o;++x)y[D++]=t[x],++z[t[x]];d=Oe(t,l,c,y,z,L,v,D,N,x-N,d),c||(i.r=d&7|l[d/8|0]<<3,d-=7,i.h=b,i.p=g,i.i=x,i.w=at)}else{for(var x=i.w||0;x<o+c;x+=65535){var _t=x+65535;_t>=o&&(l[d/8|0]=c,_t=o),d=Ba(l,d+1,t.subarray(x,_t))}i.i=o}return La(s,0,r+Pa(d)+n)},Cn=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var a=e,r=9;--r;)a=(a&1&&-306674912)^a>>>1;t[e]=a}return t})(),Ua=function(){var t=-1;return{p:function(e){for(var a=t,r=0;r<e.length;++r)a=Cn[a&255^e[r]]^a>>>8;t=a},d:function(){return~t}}},Ea=function(t,e,a,r,n){if(!n&&(n={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),o=new E(i.length+t.length);o.set(i),o.set(t,i.length),t=o,n.w=i.length}return zn(t,e.level==null?6:e.level,e.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,a,r,n)},Da=function(t,e){var a={};for(var r in t)a[r]=t[r];for(var r in e)a[r]=e[r];return a},S=function(t,e,a){for(;a;++e)t[e]=a,a>>>=8},Sn=function(t,e){var a=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&S(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),a){t[3]=8;for(var r=0;r<=a.length;++r)t[r+10]=a.charCodeAt(r)}},Pn=function(t){return 10+(t.filename?t.filename.length+1:0)};function Ln(t,e){return Ea(t,e||{},0,0)}function Bn(t,e){e||(e={});var a=Ua(),r=t.length;a.p(t);var n=Ea(t,e,Pn(e),8),i=n.length;return Sn(n,e),S(n,i-8,a.d()),S(n,i-4,r),n}var Na=function(t,e,a,r){for(var n in t){var i=t[n],o=e+n,s=r;Array.isArray(i)&&(s=Da(r,i[1]),i=i[0]),i instanceof E?a[o]=[i,s]:(a[o+="/"]=[new E(0),s],Na(i,o,a,r))}},Re=typeof TextEncoder<"u"&&new TextEncoder,In=typeof TextDecoder<"u"&&new TextDecoder,Un=0;try{In.decode(Ia,{stream:!0}),Un=1}catch{}function xt(t,e){var a;if(Re)return Re.encode(t);for(var r=t.length,n=new E(t.length+(t.length>>1)),i=0,o=function(d){n[i++]=d},a=0;a<r;++a){if(i+5>n.length){var s=new E(i+8+(r-a<<1));s.set(n),n=s}var l=t.charCodeAt(a);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|t.charCodeAt(++a)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return La(n,0,i)}var Jt=function(t){var e=0;if(t)for(var a in t){var r=t[a].length;r>65535&&Et(9),e+=r+4}return e},_e=function(t,e,a,r,n,i,o,s){var l=r.length,c=a.extra,d=s&&s.length,u=Jt(c);S(t,e,o!=null?33639248:67324752),e+=4,o!=null&&(t[e++]=20,t[e++]=a.os),t[e]=20,e+=2,t[e++]=a.flag<<1|(i<0&&8),t[e++]=n&&8,t[e++]=a.compression&255,t[e++]=a.compression>>8;var m=new Date(a.mtime==null?Date.now():a.mtime),p=m.getFullYear()-1980;if((p<0||p>119)&&Et(10),S(t,e,p<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>1),e+=4,i!=-1&&(S(t,e,a.crc),S(t,e+4,i<0?-i-2:i),S(t,e+8,a.size)),S(t,e+12,l),S(t,e+14,u),e+=16,o!=null&&(S(t,e,d),S(t,e+6,a.attrs),S(t,e+10,o),e+=14),t.set(r,e),e+=l,u)for(var h in c){var g=c[h],b=g.length;S(t,e,+h),S(t,e+2,b),t.set(g,e+4),e+=4+b}return d&&(t.set(s,e),e+=d),e},En=function(t,e,a,r,n){S(t,e,101010256),S(t,e+8,a),S(t,e+10,a),S(t,e+12,r),S(t,e+16,n)};function Dn(t,e){e||(e={});var a={},r=[];Na(t,"",a,e);var n=0,i=0;for(var o in a){var s=a[o],l=s[0],c=s[1],d=c.level==0?0:8,u=xt(o),m=u.length,p=c.comment,h=p&&xt(p),g=h&&h.length,b=Jt(c.extra);m>65535&&Et(11);var f=d?Ln(l,c):l,w=f.length,k=Ua();k.p(l),r.push(Da(c,{size:l.length,crc:k.d(),c:f,f:u,m:h,u:m!=o.length||h&&p.length!=g,o:n,compression:d})),n+=30+m+b+w,i+=76+2*(m+b)+(g||0)+w}for(var y=new E(i+22),z=n,L=i-n,C=0;C<r.length;++C){var u=r[C];_e(y,u.o,u,u.f,u.u,u.c.length);var v=30+u.f.length+Jt(u.extra);y.set(u.c,u.o+v),_e(y,n,u,u.f,u.u,u.c.length,u.o,u.m),n+=16+v+(u.m?u.m.length:0)}return En(y,n,r.length,L,z),y}const Ta="gzip";function Zt(t){return{bytes:Bn(t),compression:Ta}}async function Oa(t){if(typeof CompressionStream>"u")return Zt(t);try{const e=new Uint8Array(t.byteLength);e.set(t);const a=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return{bytes:new Uint8Array(await new Response(a).arrayBuffer()),compression:Ta}}catch{return Zt(t)}}const $e=1,je=2,He=4,Ve=8,Ye=16,Nn=32,Xe=1,Ge=2,We=4,Ke=8,Je=16,Tn=32,Ze=64,qe=128;function ue(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.lineDistances&&(e+=t.lineDistances.byteLength),t.linePattern&&(e+=64+t.linePattern.pattern.length*8),e}function me(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.gradientPositions&&(e+=t.gradientPositions.byteLength),t.uvs&&(e+=t.uvs.byteLength),t.texture&&(e+=t.texture.bytes.byteLength+64),t.hatchPattern&&(e+=128),t.gradientFill&&(e+=64),e}function Ra(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=$e),e.linePattern&&(a|=je),e.lineDistances&&e.lineDistances.length>0&&(a|=He),e.lineWidth!=null&&e.lineWidth>0&&(a|=Ve),e.renderOrder!=null&&e.renderOrder!==0&&(a|=Ye),e.excludeFromOsnap&&(a|=Nn),t.writeU8(a),a&$e&&t.writeUint32Array(e.indices),a&je&&t.writeJson(e.linePattern),a&He&&t.writeFloat32Array(e.lineDistances),a&Ve&&t.writeF32(e.lineWidth),a&Ye&&t.writeI32(e.renderOrder)}function _a(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=Xe),e.hatchPattern&&(a|=Ge),e.gradientFill&&(a|=We),e.gradientPositions&&e.gradientPositions.length>0&&(a|=Ke),e.side!=null&&(a|=Je),e.points&&(a|=Tn),e.renderOrder!=null&&e.renderOrder!==0&&(a|=Ze),e.texture&&e.texture.bytes.length>0&&e.uvs&&e.uvs.length>=2&&(a|=qe),t.writeU8(a),a&Xe&&t.writeUint32Array(e.indices),a&Ge&&t.writeJson(e.hatchPattern),a&We&&t.writeJson(e.gradientFill),a&Ke&&t.writeFloat32Array(e.gradientPositions),a&Je&&t.writeU8(e.side),a&Ze&&t.writeI32(e.renderOrder),a&qe&&(t.writeFloat32Array(e.uvs),t.writeString(e.texture.mimeType||"image/png"),t.writeU32(e.texture.bytes.byteLength),t.writeBytes(e.texture.bytes))}class pe{constructor(){this.chunks=[],this.length=0}writeU8(e){const a=new Uint8Array(1);a[0]=e&255,this.chunks.push(a),this.length+=1}writeU32(e){const a=new Uint8Array(4);new DataView(a.buffer).setUint32(0,e>>>0,!0),this.chunks.push(a),this.length+=4}writeI32(e){const a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,e|0,!0),this.chunks.push(a),this.length+=4}writeF32(e){const a=new Uint8Array(4);new DataView(a.buffer).setFloat32(0,e,!0),this.chunks.push(a),this.length+=4}writeF64(e){const a=new Uint8Array(8);new DataView(a.buffer).setFloat64(0,e,!0),this.chunks.push(a),this.length+=8}writeBytes(e){this.chunks.push(e),this.length+=e.length}writeString(e){const a=xt(e);this.writeU32(a.length),this.writeBytes(a)}writeJson(e){this.writeString(JSON.stringify(e))}writeFloat32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}writeUint32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}alignTo(e){const a=this.length%e;if(a===0)return;const r=e-a;for(let n=0;n<r;n++)this.writeU8(0)}toUint8Array(){const e=new Uint8Array(this.length);let a=0;for(const r of this.chunks)e.set(r,a),a+=r.length;return e}}const On=1329939265,Rn=1,_n=1,$n=2,jn=3,Hn=4,Vn=5,Yn=6,Xn=7;function $a(t){var e;switch(t.kind){case"line":return 37;case"circle":return 30;case"arc":return 46;case"ellipse":return 71;case"point":return 21;case"path":return 10+t.vertices.length*8;case"spline":return 10+(t.controlPoints.length+t.knots.length+t.weights.length+(((e=t.fitPoints)==null?void 0:e.length)??0))*8+16;default:return t}}function Gn(t,e){if(t.length===0)return[];const a=[];let r=[],n=64;const i=()=>{r.length!==0&&(a.push(r),r=[],n=64)};for(const o of t){const s=$a(o);r.length>0&&n+s>e&&i(),r.push(o),n+=s}return i(),a}function ja(t){const e=new pe;e.writeU32(On),e.writeU8(Rn),e.writeU8(0),e.writeU8(0),e.writeU8(0);const a=[],r=new Map,n=i=>{const o=r.get(i);if(o!=null)return o;const s=a.length;return a.push(i),r.set(i,s),s};for(const i of t.primitives)n(i.layer);e.writeU32(a.length);for(const i of a)e.writeString(i);e.writeU32(t.primitives.length);for(const i of t.primitives)Kn(e,i,n(i.layer));return e.toUint8Array()}async function Wn(t){const e=ja(t),a=(await Oa(e)).bytes;return{uncompressed:e,compressed:a}}function Vt(t,e){t.writeU8(e<0?0:1)}function ht(t,e){t.writeU32(e.length);for(const a of e)t.writeF64(a)}function Kn(t,e,a){switch(e.kind){case"line":t.writeU8(_n),t.writeU32(a),t.writeF64(e.x0),t.writeF64(e.y0),t.writeF64(e.x1),t.writeF64(e.y1);return;case"circle":t.writeU8($n),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),Vt(t,e.normalSign);return;case"arc":t.writeU8(jn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),t.writeF64(e.startAngle),t.writeF64(e.endAngle),Vt(t,e.normalSign);return;case"ellipse":t.writeU8(Hn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.majorX),t.writeF64(e.majorY),t.writeF64(e.majorR),t.writeF64(e.minorR),t.writeF64(e.startAngle),t.writeF64(e.endAngle),t.writeU8(e.closed?1:0),Vt(t,e.normalSign??1);return;case"spline":t.writeU8(Vn),t.writeU32(a),ht(t,e.controlPoints),t.writeU32(e.degree),ht(t,e.knots),ht(t,e.weights),t.writeU8(e.closed?1:0),ht(t,e.fitPoints??[]);return;case"point":t.writeU8(Yn),t.writeU32(a),t.writeF64(e.x),t.writeF64(e.y);return;case"path":t.writeU8(Xn),t.writeU32(a),t.writeU8(e.closed?1:0),ht(t,e.vertices);return;default:{const r=e;throw new Error(`Unsupported osnap primitive: ${String(r)}`)}}}const Jn=1480934209;function Zn(t){if(t.version!==Y)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=new pe;e.writeU32(Jn),e.writeU8(Y),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeJson(qn(t)),e.writeJson(t.layers),e.writeString(t.activeLayoutBtrId),e.writeU32(t.layouts.length);for(const a of t.layouts)Qn(e,a);return e.toUint8Array()}function qn(t){const e={...t.meta.savedViews??{}};for(const a of t.layouts)a.savedView&&(e[a.btrId]=a.savedView);if(Object.keys(e).length===0){if(t.meta.savedViews==null)return t.meta;const{savedViews:a,...r}=t.meta;return r}return{...t.meta,savedViews:e}}function Qn(t,e){t.writeString(e.btrId),t.writeString(e.name),t.writeU8(e.isModelSpace?1:0),ti(t,e.osnap),t.writeJson(e.viewports??null),t.writeU32(e.lineBatches.length);for(const a of e.lineBatches)Ra(t,a);t.writeU32(e.meshBatches.length);for(const a of e.meshBatches)_a(t,a)}function ti(t,e){if(!e||e.primitives.length===0){t.writeU32(0);return}const a=ja(e);t.writeU32(a.length),t.writeBytes(a)}const ei="application/vnd.mlightcad.acex-snapshot+binary";function Ha(t){if(t.version!==Y)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=Zn(t),a=Zt(e);return{payload:ri(a.bytes),compression:a.compression}}function ai(){return ei}function ri(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function tt(t,e,a){if(a<=0)return new Float32Array(0);if(t instanceof Float32Array)return t.subarray(e,e+a).slice();const r=new Float32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function ni(t,e,a){if(a<=0)return new Uint32Array(0);const r=new Uint32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function Va(t,e){if(e.length===0)return{positions:t,indices:e};let a=0;for(let n=0;n<e.length;n++){const i=e[n];i>a&&(a=i)}const r=(a+1)*3;return r>=t.length?{positions:t,indices:e}:{positions:tt(t,0,r),indices:e}}function Qe(t,e){return t+e}const ot={x:0,y:0,z:0};function ii(t){t.updateMatrixWorld(!0);const e=t.matrixWorld.elements;return ot.x=e[12],ot.y=e[13],ot.z=e[14],[ot.x,ot.y,ot.z]}function he(t,e){const a=e.elements,r=t.positions;if(r.length===0)return{positions:new Float32Array(0),indices:t.indices};const n=new Float32Array(r.length);for(let i=0;i<r.length;i+=3){const o=r[i],s=r[i+1],l=r[i+2];n[i]=a[0]*o+a[4]*s+a[8]*l+a[12],n[i+1]=a[1]*o+a[5]*s+a[9]*l+a[13],n[i+2]=a[2]*o+a[6]*s+a[10]*l+a[14]}return{positions:n,indices:t.indices?new Uint32Array(t.indices):void 0}}function ta(t,e){const a=e*3;return Number.isFinite(t[a])&&Number.isFinite(t[a+1])&&Number.isFinite(t[a+2])}function ct(t,e){const a=t.positions,r=a.length/3|0;if(r===0||e<=0)return t;let n=!1;for(let s=0;s<a.length;s++)if(!Number.isFinite(a[s])){n=!0;break}if(!n)return t;const i=t.indices;if(i&&i.length>0){const s=[];for(let u=0;u+e<=i.length;u+=e){let m=!0;for(let p=0;p<e;p++){const h=i[u+p];if(h<0||h>=r||!ta(a,h)){m=!1;break}}if(m)for(let p=0;p<e;p++)s.push(i[u+p])}if(s.length===0)return{positions:new Float32Array(0)};const l=new Int32Array(r);l.fill(-1);const c=[],d=new Uint32Array(s.length);for(let u=0;u<s.length;u++){const m=s[u];let p=l[m];if(p<0){p=c.length/3,l[m]=p;const h=m*3;c.push(a[h],a[h+1],a[h+2])}d[u]=p}return{positions:Float32Array.from(c),indices:d}}const o=[];for(let s=0;s+e<=r;s+=e){let l=!0;for(let c=0;c<e;c++)if(!ta(a,s+c)){l=!1;break}if(l)for(let c=0;c<e;c++){const d=(s+c)*3;o.push(a[d],a[d+1],a[d+2])}}return o.length===0?{positions:new Float32Array(0)}:{positions:Float32Array.from(o)}}function fe(t){const e=t.positions;if(e.length<3)return{slice:t,offset:[0,0,0]};let a=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,s=-1/0,l=0;for(let u=0;u<e.length;u+=3){const m=e[u],p=e[u+1],h=e[u+2];!Number.isFinite(m)||!Number.isFinite(p)||!Number.isFinite(h)||(l++,a=Math.min(a,m),r=Math.min(r,p),n=Math.min(n,h),i=Math.max(i,m),o=Math.max(o,p),s=Math.max(s,h))}if(l===0)return{slice:{positions:new Float32Array(0)},offset:[0,0,0]};const c=[(a+i)/2,(r+o)/2,(n+s)/2],d=new Float32Array(e.length);for(let u=0;u<e.length;u+=3){const m=e[u],p=e[u+1],h=e[u+2];if(!Number.isFinite(m)||!Number.isFinite(p)||!Number.isFinite(h)){d[u]=0,d[u+1]=0,d[u+2]=0;continue}d[u]=m-c[0],d[u+1]=p-c[1],d[u+2]=h-c[2]}return{slice:{positions:d,indices:t.indices?new Uint32Array(t.indices):void 0},offset:c}}function oi(t,e,a={}){t.updateMatrixWorld(!0);const r=he(e,t.matrixWorld);return fe(r)}function si(t){const e=t.image;if(!e||typeof document>"u")return;const a=document.createElement("canvas"),r=a.getContext("2d");if(!r)return;try{if(e instanceof ImageData)a.width=e.width,a.height=e.height,r.putImageData(e,0,0);else if(ci(e)){a.width=e.width,a.height=e.height;const l=ui(e.data,e.width*e.height),c=new ImageData(new Uint8ClampedArray(l),e.width,e.height);r.putImageData(c,0,0)}else if(li(e)){const l=di(e);if(!l)return;a.width=l.width,a.height=l.height,r.drawImage(e,0,0)}else return}catch{return}const n=a.toDataURL("image/png"),i=n.indexOf(",");if(i<0)return;const o=atob(n.slice(i+1)),s=new Uint8Array(o.length);for(let l=0;l<o.length;l++)s[l]=o.charCodeAt(l);return{mimeType:"image/png",bytes:s}}function li(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}function ci(t){if(!t||typeof t!="object")return!1;const e=t;return e.data!=null&&typeof e.width=="number"&&typeof e.height=="number"&&e.width>=1&&e.height>=1}function di(t){let e=Number(t.width),a=Number(t.height);if(t instanceof HTMLImageElement?(e=t.naturalWidth||t.width,a=t.naturalHeight||t.height):typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement&&(e=t.videoWidth||t.width,a=t.videoHeight||t.height),!(!Number.isFinite(e)||!Number.isFinite(a)||e<1||a<1))return{width:e,height:a}}function ui(t,e){const a=e*4;if(t instanceof Uint8ClampedArray&&t.length>=a)return t.length===a?t:t.subarray(0,a);const r=new Uint8ClampedArray(a),n=Math.min(a,t.length);for(let i=0;i<n;i++)r[i]=t[i];if(t.length>=e*3&&t.length<a)for(let i=e-1;i>=0;i--){const o=i*3,s=i*4;r[s]=t[o],r[s+1]=t[o+1],r[s+2]=t[o+2],r[s+3]=255}return r}function mi(t,e){const a=t.getAttribute("uv");if(!a||a.count===0||a.itemSize<2)return;const r=Math.floor(e.length/3)*2;if(r<=0)return;const n=a.array;if(!(a.count*a.itemSize<r))return tt(n,0,r)}function Ya(t){const e=t;return e.map?!1:e.transparent===!0&&typeof e.opacity=="number"&&e.opacity<.01}function ge(t){const e=t;if(e.isShaderMaterial===!0||t.type==="ShaderMaterial")return e}function pi(t){var e;const a=ge(t);if(!a)return;const r=a.uniforms.pattern,n=a.uniforms.patternLength;if(!r||!n)return;const i=r.value;if(!(!Array.isArray(i)||i.length===0))return{pattern:[...i],patternLength:Number(n.value),viewportScale:Number(((e=a.uniforms.u_viewportScale)==null?void 0:e.value)??1)}}function hi(t){var e;const a=ge(t);if(!a)return;const r=a.uniforms.u_patternLines;if(!r)return;const n=r.value;if(!(!Array.isArray(n)||n.length===0))return{patternAngle:Number(((e=a.uniforms.u_patternAngle)==null?void 0:e.value)??0),patternLines:n.map(gi)}}function fi(t){var e,a,r,n,i;const o=ge(t);if(!o||o.uniforms.u_patternLines)return;const s=(e=o.uniforms.u_startColor)==null?void 0:e.value,l=(a=o.uniforms.u_endColor)==null?void 0:a.value,c=o.uniforms.u_gradientType;if(!(!(s!=null&&s.getHex)||c==null))return{startColor:s.getHex(),endColor:((r=l==null?void 0:l.getHex)==null?void 0:r.call(l))??s.getHex(),angle:Number(((n=o.uniforms.u_angle)==null?void 0:n.value)??0),shift:Number(((i=o.uniforms.u_shift)==null?void 0:i.value)??0),gradientType:Number(c.value)}}function gi(t){return{angle:t.angle,base:[t.base.x,t.base.y],offset:[t.offset.x,t.offset.y],dashLengths:[...t.dashLengths],patternLength:t.patternLength}}function be(t){const e=t.length/3;if(e<2)return new Float32Array(0);const a=new Float32Array(e);for(let r=0;r<e;r+=2){r===0?a[r]=0:a[r]=a[r-1];const n=t[r*3],i=t[r*3+1],o=t[r*3+2]??0,s=t[(r+1)*3],l=t[(r+1)*3+1],c=t[(r+1)*3+2]??0,d=s-n,u=l-i,m=c-o;a[r+1]=a[r]+Math.sqrt(d*d+u*u+m*m)}return a}function bi(t,e){const a=t.getAttribute(e);if(!a||a.count===0)return;const r=a.itemSize;if(t.getIndex()){const d=a.array;return tt(d,0,a.count*r)}const n=t.drawRange,i=a.count,o=Math.max(0,Math.min(Math.floor(n.start),i)),s=Math.max(0,i-o),l=!Number.isFinite(n.count)||n.count<=0?s:Math.min(Math.floor(n.count),s);if(l<=0)return;const c=a.array;return tt(c,o*r,l*r)}function ea(t,e){const a=e[0],r=e[1],n=e[4],i=e[5],o=e[12],s=e[13],l=Math.atan2(r,a),c=(m,p)=>[a*m+n*p+o,r*m+i*p+s],d=(m,p)=>[a*m+n*p,r*m+i*p],u=(m,p,h)=>{const g=Math.cos(h),b=Math.sin(h);return[g*m-b*p,b*m+g*p]};return{patternAngle:t.patternAngle,patternLines:t.patternLines.map(m=>{const p=m.angle+t.patternAngle,h=m.angle+l,g=h+t.patternAngle,[b,f]=d(Math.cos(p),Math.sin(p)),w=Math.hypot(b,f),[k,y]=u(m.offset[0],m.offset[1],p),[z,L]=d(k,y),C=u(z,L,-g);return{angle:h,base:c(m.base[0],m.base[1]),offset:C,dashLengths:m.dashLengths.map(v=>v*w),patternLength:m.patternLength*w}})}}function wi(t,e){return{patternAngle:t.patternAngle,patternLines:t.patternLines.map(a=>{const r=new F.Vector2(a.base[0]-e[0],a.base[1]-e[1]),n=new F.Vector2(a.offset[0],a.offset[1]);return Or(r,n,a.angle,t.patternAngle,a.patternLength),{angle:a.angle,base:[r.x,r.y],offset:[a.offset[0],a.offset[1]],dashLengths:[...a.dashLengths],patternLength:a.patternLength}})}}function qt(t,e){return!Number.isFinite(t)||t<0?0:Math.min(Math.floor(t),e)}function Qt(t,e,a){const r=Math.max(0,e-a);return!Number.isFinite(t)||t<=0?r:Math.min(Math.floor(t),r)}function St(t){const e=t.getAttribute("position");if(!e)return{positions:new Float32Array(0)};const a=t.drawRange,r=e.array,n=e.itemSize,i=t.getIndex();if(i){const l=tt(r,0,e.count*n),c=i.array,d=qt(a.start,i.count),u=Qt(a.count,i.count,d),m=ni(c,d,u);return Va(l,m)}const o=qt(a.start,e.count),s=Qt(a.count,e.count,o);return{positions:tt(r,o*n,s*n)}}function Pt(t){return cn(t.flags)&&dn(t.flags)}function Xa(t){const{count:e}=t.mappingStats;for(let a=0;a<e;a++){let r;try{r=t.getGeometryRangeAt(a)}catch{continue}if(Pt(r)&&r.bboxIntersectionCheck)return!0}return!1}function te(t){return Ma(t).bboxIntersectionCheck===!0}function we(t,e){const a=e.getAttribute("position");if(!a)return{positions:new Float32Array(0)};const r=a.itemSize,n=a.array,i=e.getIndex(),{count:o}=t.mappingStats;if(i){const u=tt(n,0,a.count*r),m=i.array;let p=0;const h=[];for(let f=0;f<o;f++){let w;try{w=t.getGeometryRangeAt(f)}catch{continue}const k=w.indexStart??0,y=w.indexCount??0;!Pt(w)||y<=0||(h.push({start:k,count:y}),p+=y)}if(p===0)return{positions:new Float32Array(0)};const g=new Uint32Array(p);let b=0;for(const f of h)for(let w=0;w<f.count;w++)g[b++]=m[f.start+w];return Va(u,g)}let s=0;const l=[];for(let u=0;u<o;u++){let m;try{m=t.getGeometryRangeAt(u)}catch{continue}if(!Pt(m)||m.vertexCount<=0)continue;const p=m.vertexCount*r;l.push({start:m.vertexStart*r,floatCount:p}),s+=p}if(s===0)return{positions:new Float32Array(0)};const c=new Float32Array(s);let d=0;if(n instanceof Float32Array)for(const u of l)c.set(n.subarray(u.start,u.start+u.floatCount),d),d+=u.floatCount;else for(const u of l)for(let m=0;m<u.floatCount;m++)c[d++]=n[u.start+m];return{positions:c}}function aa(t,e,a){t.push(e.getX(a),e.getY(a),e.getZ(a))}function xi(t,e){const a=e.getAttribute("instanceStart"),r=e.getAttribute("instanceEnd");if(!a||!r)return{positions:new Float32Array(0)};const{count:n}=t.mappingStats,i=[];for(let o=0;o<n;o++){let s;try{s=t.getGeometryRangeAt(o)}catch{continue}if(!Pt(s)||s.vertexCount<=0)continue;const l=s.vertexStart,c=l+s.vertexCount;for(let d=l;d<c;d++)aa(i,a,d),aa(i,r,d)}return{positions:new Float32Array(i)}}function yi(t,e){const a=t.instanceCount;if(Number.isFinite(a)&&a>=0)return Math.min(Math.floor(a),e);const r=t.drawRange,n=qt(r.start,e);return Qt(r.count,e,n)}function vi(t){const e=t.getAttribute("instanceStart"),a=t.getAttribute("instanceEnd");if(!e||!a||e.count===0)return{positions:new Float32Array(0)};const r=yi(t,e.count);if(r<=0)return{positions:new Float32Array(0)};const n=[];for(let i=0;i<r;i++){const o=[e.getX(i),e.getY(i),e.getZ(i)],s=[a.getX(i),a.getY(i),a.getZ(i)];!o.every(Number.isFinite)||!s.every(Number.isFinite)||n.push(o[0],o[1],o[2],s[0],s[1],s[2])}return{positions:new Float32Array(n)}}function Mt(t){return Dr(t)}function Ga(t){if(t instanceof Tr)return t.linewidth}function bt(t){if("material"in t){const e=t.userData.originalMaterial??t.material;return Array.isArray(e)?e[0]:e}return t.material}function et(t){var e;const a=Fa(t),r=a.layer??"0",n=t;let i=n.color!=null?n.color.getHex():a.color??16777215;const o=pi(t),s=hi(t),l=fi(t);if(t instanceof F.ShaderMaterial||t.type==="ShaderMaterial"){const c=(e=t.uniforms.u_color)==null?void 0:e.value;c!=null&&c.getHex?i=c.getHex():l&&(i=l.startColor)}return{color:i,layer:r,linePattern:o,hatchPattern:s,gradientFill:l,side:s||l?t.side:void 0}}function ki(t,e){const a=Fa(e).drawOrder??t.renderOrder;return a===0?void 0:a}function dt(t,e,a){const r=ki(e,a);r!=null&&(t.renderOrder=r)}function Ai(t,e){if(!e)return;const a=t.userData.bakedWorldMatrix;return a&&a.length>=16?ea(e,a):(t.updateMatrixWorld(!0),ea(e,Array.from(t.matrixWorld.elements)))}function Dt(t){return ii(t)}function Yt(t,e,a={}){const r=oi(t,e,a);return{...r.slice,offset:r.offset}}function Mi(t){if(t.indices&&t.indices.length>=3)return t;const e=t.positions.length/3|0;if(e<3||e%3!==0)return t;const a=new Uint32Array(e);for(let r=0;r<e;r++)a[r]=r;return{...t,indices:a}}function yt(t,e,a,r,n,i=!1){i&&(r=Mi(r));const o=et(e),s=Ai(a,o.hatchPattern),l=s?wi(s,n):void 0,c=o.gradientFill?bi(t,"gradientPosition"):void 0,d={layer:o.layer,color:o.color,offset:n,hatchPattern:l,gradientFill:o.gradientFill,gradientPositions:c,side:o.side,...r},u=e;if(u.map){const m=si(u.map),p=mi(t,r.positions);if(!m||!p)return;d.texture=m,d.uvs=p,d.color=16777215,d.side=F.DoubleSide}return dt(d,a,e),d}function Fi(t){const e=xi(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r}=et(t.material),n=Ga(t.material),i={layer:r,color:a,offset:Dt(t),lineWidth:n,...e};return Xa(t)&&(i.excludeFromOsnap=!0),dt(i,t,t.material),i}function zi(t){const e=we(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r,linePattern:n}=et(t.material),i=n?be(e.positions):void 0,o={layer:r,color:a,offset:Dt(t),linePattern:n,lineDistances:i,...e};return Xa(t)&&(o.excludeFromOsnap=!0),dt(o,t,t.material),o}function Ci(t){const e=we(t,t.geometry);if(e.positions.length!==0)return yt(t.geometry,t.material,t,e,Dt(t),!0)}function Si(t){const e=we(t,t.geometry);if(e.positions.length===0)return;const a=yt(t.geometry,t.material,t,e,Dt(t));if(a)return{points:!0,...a}}const J=new F.Matrix4,Lt=new F.Matrix4,ft=new F.Object3D;ft.matrixAutoUpdate=!1;function Pi(t){const e=t;return e.isInstancedMesh===!0&&e.instanceMatrix!=null&&typeof e.count=="number"&&e.geometry!=null}function Li(t){return t.renderOrder<1e4||t.isInstancedMesh===!0?!1:Ma(t).sharesTemplateGeometry===!0}function ee(t){const e=t.elements;for(let i=0;i<16;i++)if(!Number.isFinite(e[i]))return!1;const a=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),n=Math.hypot(e[8],e[9],e[10]);return a+r+n>=1e-8}function Wa(t,e){var a;const r=ct(St(t.geometry),e),n=r.positions.length;if(n===0)return;t.updateMatrixWorld(!0);const i=t.instanceMatrix.array,o=((a=r.indices)==null?void 0:a.length)??0;let s=0;for(let p=0;p<t.count;p++)J.fromArray(i,p*16),ee(J)&&s++;if(s===0)return;const l=new Float32Array(s*n),c=r.indices!=null?new Uint32Array(s*o):void 0,d=n/3;let u=0;for(let p=0;p<t.count;p++){if(J.fromArray(i,p*16),!ee(J))continue;Lt.multiplyMatrices(t.matrixWorld,J);const h=he(r,Lt);if(l.set(h.positions,u*n),c&&h.indices){const g=u*d;for(let b=0;b<h.indices.length;b++)c[u*o+b]=h.indices[b]+g}u++}const m=fe(ct({positions:l,indices:c},e));if(m.slice.positions.length!==0)return{slice:m.slice,offset:m.offset}}function Bi(t){const e=et(t),a=t;return!!(e.hatchPattern||e.gradientFill||a.map)}function Ii(t,e){t.updateMatrixWorld(!0);const a=t.instanceMatrix.array;for(let r=0;r<t.count;r++)J.fromArray(a,r*16),ee(J)&&(Lt.multiplyMatrices(t.matrixWorld,J),e(Lt))}function Ui(t,e){const a=Wa(t,2);if(!a)return;const r=bt(t),{color:n,layer:i,linePattern:o}=et(r),s=o?be(a.slice.positions):void 0,l={layer:i,color:n,offset:a.offset,linePattern:o,lineDistances:s,...a.slice};te(t)&&(l.excludeFromOsnap=!0),dt(l,t,r),e.push(l)}function ra(t,e,a){const r=bt(t);if(!a&&Ya(r))return;if(!a&&Bi(r)){const o=ct(St(t.geometry),3);if(o.positions.length===0)return;Ii(t,s=>{const l=ct(he(o,s),3);if(l.positions.length===0)return;const c=fe(l);ft.matrix.copy(s),ft.matrixWorld.copy(s),ft.matrixWorldNeedsUpdate=!1;const d=yt(t.geometry,r,ft,c.slice,c.offset,!0);d&&e.push(d)});return}const n=Wa(t,a?1:3);if(!n)return;const i=yt(t.geometry,r,t,n.slice,n.offset,!a);i&&e.push(a?{...i,points:!0}:i)}function Ft(t){const e=t;return t instanceof Nr||e.isLineSegments2===!0||t.type==="LineSegments2"}function na(t){const e=t;return t instanceof F.LineSegments||e.isLineSegments===!0||t.type==="LineSegments"}function ia(t){const e=t;return t instanceof F.Mesh||e.isMesh===!0||e.isInstancedMesh===!0||t.type==="Mesh"}function Ei(t){const e=[],a=[];return t.traverse(r=>{if(!(zr(r)||Cr(r)||Li(r))){if(Pi(r)){if(!Mt(r))return;r.isPoints===!0?ra(r,a,!0):na(r)&&!Ft(r)?Ui(r,e):ia(r)&&!Ft(r)&&ra(r,a,!1);return}if(r instanceof Ue){const n=zi(r);n&&e.push(n);return}if(r instanceof Sr){const n=Fi(r);n&&e.push(n);return}if(r instanceof Ee){const n=Ci(r);n&&a.push(n);return}if(r instanceof Pr){const n=Si(r);n&&a.push(n);return}if(Ft(r)){if(!Mt(r))return;const n=vi(r.geometry);if(n.positions.length===0)return;const i=bt(r),{color:o,layer:s}=et(i),{offset:l,...c}=Yt(r,n),d={layer:s,color:o,offset:l,lineWidth:Ga(i),...c};te(r)&&(d.excludeFromOsnap=!0),dt(d,r,i),e.push(d)}else if(na(r)&&!(r instanceof Ue)){if(!Mt(r))return;const n=ct(St(r.geometry),2);if(n.positions.length===0)return;const i=bt(r),{color:o,layer:s,linePattern:l}=et(i),{offset:c,...d}=Yt(r,n),u=l?be(d.positions):void 0,m={layer:s,color:o,offset:c,linePattern:l,lineDistances:u,...d};te(r)&&(m.excludeFromOsnap=!0),dt(m,r,i),e.push(m)}else if(ia(r)&&!Ft(r)&&!(r instanceof Ee)){if(!Mt(r))return;const n=bt(r);if(Ya(n))return;const i=ct(St(r.geometry),3);if(i.positions.length===0)return;const{offset:o,...s}=Yt(r,i),l=yt(r.geometry,n,r,s,o,!0);l&&a.push(l)}}}),{lineBatches:e,meshBatches:a}}const oa={size:8,colorCss:"#0080ff",hotColorCss:"#ff0000"};function sa(t){const e=new Ur(Er.ByACI,t);return e.cssColor??`rgb(${e.red}, ${e.green}, ${e.blue})`}function Di(t){try{const e=Fr.instance(),a=e.getVar(jt.GRIPSIZE,t),r=e.getVar(jt.GRIPCOLOR,t),n=e.getVar(jt.GRIPHOT,t);return!(a>0)||!Number.isFinite(a)?oa:{size:a,colorCss:sa(r),hotColorCss:sa(n)}}catch{return oa}}function la(t,e){const a=t.extmin,r=t.extmax,n=Di(t);return{title:e==null?void 0:e.title,extents:{minX:a.x,minY:a.y,maxX:r.x,maxY:r.y},units:{insunits:t.insunits,lunits:t.lunits,luprec:t.luprec,aunits:t.aunits,auprec:t.auprec,measurement:t.measurement,ltscale:t.ltscale,angbase:t.angbase,angdir:t.angdir},grip:n,background:(e==null?void 0:e.background)??0}}function ca(t,e,a,r,n){return Math.atan2(r-e,n*(a-t))}function xe(t){return t.z>=0?1:-1}function Ka(t,e,a){if(!(a.radius>0)||!Number.isFinite(a.radius))return;const r=a.clockwise?-1:1,n=a.center.x,i=a.center.y;t.push({kind:"arc",layer:e,cx:n,cy:i,r:a.radius,startAngle:ca(n,i,a.startPoint.x,a.startPoint.y,r),endAngle:ca(n,i,a.endPoint.x,a.endPoint.y,r),normalSign:r})}function P(t,e){const a=new F.Vector3(e.x,e.y,e.z??0).applyMatrix4(t);return{x:a.x,y:a.y}}function Ni(t){const e=t.elements;return new F.Matrix4(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}function Bt(t,e){return new F.Matrix4().multiplyMatrices(t,Ni(e))}function Ja(t,e){const a=new F.Vector3(e.x,e.y,e.z??0).transformDirection(t).normalize();return{x:a.x,y:a.y}}function ae(t){const e=new F.Vector3(t.elements[0],t.elements[1],t.elements[2]).length(),a=new F.Vector3(t.elements[4],t.elements[5],t.elements[6]).length();return lt.equal(e,a,za*Math.max(e,a,1))}function Ti(t,e){const a=t.tables.blockTable.getIdAt(e);if(a)return a;for(const n of t.tables.blockTable.newIterator())if(n.objectId===e)return n;const r=t.tables.blockTable.modelSpace;if(r.objectId===e)return r}function Oi(t){if(t instanceof un)return!0;const e=t;return(e.type==="LINE"||e.type==="Line")&&e.startPoint!=null&&e.endPoint!=null}function Ri(t,e,a,r){r.startPoint,r.endPoint}function Za(t,e){return t.blockTableRecord??(t.blockName?e.tables.blockTable.getAt(t.blockName):void 0)}function _i(t,e){const a=t.dimBlockId;return a?e.tables.blockTable.getAt(a):void 0}function $i(t,e){const a=Za(t,e);if(a)return a;const r=t.owningBlockRecordId;return r?e.tables.blockTable.getAt(r):void 0}function qa(t){return t.getFullInsertionTransform()}function ji(t){for(const e of t.newIterator())return!0;return!1}function Hi(t){return typeof t.getFullInsertionTransform=="function"&&"blockTableRecord"in t}function Z(t,e,a,r,n){if(r.length<2)return;const i=ae(a),o=a.elements[0]*a.elements[5]-a.elements[4]*a.elements[1]<0?-1:1,s=[];for(const l of r){const c=P(a,l);let d=l.bulge??0;lt.isPositive(Math.abs(d))&&(d=i?d*o:0),s.push(c.x,c.y,d)}t.push({kind:"path",layer:e,closed:n,vertices:s})}function Qa(t,e){return lt.equal(t.x,e.x)&&lt.equal(t.y,e.y)}function Vi(t){return(t.clockwise?-1:1)*Math.tan(t.deltaAngle/4)}function da(t,e,a,r){if(t.length===0){t.push({x:e.x,y:e.y,z:e.z??0,bulge:r}),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0});return}const n=t[t.length-1];Qa(n,e)?n.bulge=r:(n.bulge=0,t.push({x:e.x,y:e.y,z:e.z??0,bulge:r})),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0})}function ua(t){return t.length>=2&&Qa(t[0],t[t.length-1])&&t.pop(),t}function wt(t,e,a,r,n){if(r.length<2)return;const i=n?r.length:r.length-1;for(let o=0;o<i;o++)r[o],r[(o+1)%r.length]}function Yi(t,e,a,r){const n=[r.startPosition];for(const i of r.segments)n.push(i.position);wt(t,e,a,n,r.closed)}function Xi(t,e,a){if(a.vertices.length>=2)return a.vertices;if(a.vertices.length===0)return[];const r=a.vertices[0],n=e.lastLeaderLinePoint??e.landingPoint??t.landingPoint??t.contentBasePosition;if(!n)return a.vertices;const i=r.x-n.x,o=r.y-n.y,s=(r.z??0)-(n.z??0);return Math.hypot(i,o,s)<=za?a.vertices:[r,n]}function Gi(t,e,a,r){var n,i;for(const s of r.leaders)for(const l of s.leaderLines){const c=Xi(r,s,l);wt(t,e,a,c,!1)}const o=s=>{if(!s)return;const l=P(a,s);t.push({kind:"point",layer:e,x:l.x,y:l.y})};o(r.contentBasePosition),o((n=r.mtextContent)==null?void 0:n.anchorPoint),o((i=r.blockContent)==null?void 0:i.position)}function Wi(t,e,a,r){const n=r.numberOfVertices;if(n<2)return;const i=r.elevation,o=r.closed?n:n-1;for(let s=0;s<o;s++){const l=r.getPointAt(s),c=r.getPointAt((s+1)%n),d=r.getBulgeAt(s),u={x:l.x,y:l.y,z:i},m={x:c.x,y:c.y,z:i};if(lt.isPositive(Math.abs(d))){const p=P(a,u),h=P(a,m);Ka(t,e,new oe(p,h,d))}}}function Ki(t,e,a,r,n,i){const o=P(a,r),s=new F.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),l={kind:"circle",layer:e,cx:o.x,cy:o.y,r:n*s,normalSign:xe(i)};t.push(l)}function Ji(t,e,a,r){const n=P(a,r.center),i=new F.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),o={kind:"arc",layer:e,cx:n.x,cy:n.y,r:r.radius*i,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:xe(r.normal)};t.push(o)}function Xt(t,e,a,r){const n=P(a,r.center),i=r._geo,o=(i==null?void 0:i.majorAxis)??{x:1,y:0,z:0},s=Ja(a,o),l=Math.hypot(s.x,s.y)||1,c=new F.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),d=new F.Vector3(a.elements[4],a.elements[5],a.elements[6]).length(),u={kind:"ellipse",layer:e,cx:n.x,cy:n.y,majorX:s.x/l,majorY:s.y/l,majorR:r.majorAxisRadius*c,minorR:r.minorAxisRadius*d,startAngle:r.startAngle,endAngle:r.endAngle,closed:r.closed,normalSign:xe(r.normal)};t.push(u)}function Zi(t,e,a,r){var n,i;const o=r._geo;if(!((n=o==null?void 0:o.controlPoints)!=null&&n.length))return;const s=[];for(const c of o.controlPoints){const d=P(a,c);s.push(d.x,d.y)}const l={kind:"spline",layer:e,controlPoints:s,degree:o.degree??3,knots:[...o.knots??[]],weights:[...o.weights??[]],closed:o.closed??!1};if((i=o.fitPoints)!=null&&i.length){l.fitPoints=[];for(const c of o.fitPoints){const d=P(a,c);l.fitPoints.push(d.x,d.y)}}t.push(l)}const ma=1e-6;function qi(t){var e;const a=t.elevation,r=(e=t._geo)==null?void 0:e.vertices;return r&&r.length>1?r.map(n=>({x:n.x,y:n.y,z:a,bulge:n.bulge,startWidth:n.startWidth,endWidth:n.endWidth})):Array.from({length:t.numberOfVertices},(n,i)=>{const o=t.getPoint2dAt(i);return{x:o.x,y:o.y,z:a,bulge:0}})}function Qi(t){return t.some(e=>{const a=Math.max(0,e.startWidth??0),r=Math.max(0,e.endWidth??0);return a>ma||r>ma})}function to(t,e,a,r){const n=qi(r),i=n.length;if(i<2)return;if(Qi(n)){Z(t,e,a,n,r.closed);return}const o=r.closed?i:i-1;for(let s=0;s<o;s++){const l=n[s],c=n[(s+1)%i],d=l.bulge??0;if(lt.isPositive(Math.abs(d))){const u=P(a,l),m=P(a,c);Ka(t,e,new oe(u,m,d))}}}function eo(t,e,a,r,n){const i=P(a,{x:r.center.x,y:r.center.y,z:n}),o=Ja(a,{x:Math.cos(r.rotation),y:Math.sin(r.rotation),z:0}),s=Math.hypot(o.x,o.y)||1,l=new F.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),c=new F.Vector3(a.elements[4],a.elements[5],a.elements[6]).length();t.push({kind:"ellipse",layer:e,cx:i.x,cy:i.y,majorX:o.x/s,majorY:o.y/s,majorR:r.majorAxisRadius*l,minorR:r.minorAxisRadius*c,startAngle:r.startAngle,endAngle:r.endAngle,closed:!1,normalSign:r.clockwise?-1:1})}function ao(t,e,a,r,n){var i;const o=r.numberOfVertices;if(o<2)return;const s=[];for(let l=0;l<o;l++){const c=r.getPointAt(l);s.push({x:c.x,y:c.y,z:n,bulge:((i=r.vertices[l])==null?void 0:i.bulge)??0})}Z(t,e,a,s,r.closed)}function ro(t,e,a,r,n){if(r instanceof pn){ao(t,e,a,r,n);return}if(!(r instanceof hn))return;const i=[];let o=!1;const s=()=>{const c=ua(i);c.length>=2&&Z(t,e,a,c,!1),i.length=0};for(const c of r.curves)c instanceof fn?da(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},0):c instanceof oe?da(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},Vi(c)):c instanceof gn&&(o=!0,s(),eo(t,e,a,c,n));const l=ua(i);l.length>=2&&Z(t,e,a,l,!o)}function no(t,e,a,r){var n;const i=(n=r._geo)==null?void 0:n.loops;if(!(i!=null&&i.length))return;const o=r.elevation;for(const s of i)ro(t,e,a,s,o)}function io(t,e,a,r){Bt(a,qa(r));const n=[0];for(let o=0;o<r.numColumns;o++)n.push(n[o]+r.columnWidth(o));const i=[0];for(let o=0;o<r.numRows;o++)i.push(i[o]-r.rowHeight(o));n[n.length-1],i[i.length-1];for(const o of i);for(const o of n);}function oo(t,e,a,r,n,i,o,s=!0){const l=re(t.layer,a);if(o&&!o(l))return;const c=$i(t,i);if(c&&!n.has(c.objectId)&&ji(c)){n.add(c.objectId);const u=Bt(e,qa(t));It(c,u,l,r,n,i,o,s),n.delete(c.objectId);return}io(r,l,e,t);const d=P(e,t.position);r.push({kind:"point",layer:l,x:d.x,y:d.y})}function so(t,e,a,r){let n=r.boundaryPath();if(n.length>1){const o=n[0],s=n[n.length-1];o.x===s.x&&o.y===s.y&&(o.z??0)===(s.z??0)&&(n=n.slice(0,-1))}n.length>=2&&Z(t,e,a,n,!0);const i=P(a,r.position);t.push({kind:"point",layer:e,x:i.x,y:i.y})}function lo(t,e,a,r){const n=r.position();Z(t,e,a,[n.upperLeft,n.upperRight,n.lowerRight,n.lowerLeft],!0);const i=P(a,r.getLocation());t.push({kind:"point",layer:e,x:i.x,y:i.y})}function co(t){var e;const a=(e=t.attributeIterator)==null?void 0:e.call(t);return a?typeof a.toArray=="function"?a.toArray():[...a]:[]}function re(t,e){return t==="0"?e:t}function tr(t,e,a,r,n,i,o,s=!0){if(!t.visibility)return;const l=re(t.layer,a);if(!(o&&!o(l))){if(t instanceof Rr){oo(t,e,a,r,n,i,o,s);return}if(Hi(t)){const c=Za(t,i);if(!c||n.has(c.objectId))return;n.add(c.objectId);const d=t.getFullInsertionTransform(),u=Math.max(1,t.columnCount??1),m=Math.max(1,t.rowCount??1),p=t.columnSpacing??0,h=t.rowSpacing??0,g=re(t.layer,a);for(let b=0;b<m;b++)for(let f=0;f<u;f++){const w=Bt(e,d);(f!==0||b!==0)&&w.multiply(new F.Matrix4().makeTranslation(f*p,b*h,0));const k=P(w,{x:0,y:0,z:0});r.push({kind:"point",layer:g,x:k.x,y:k.y}),It(c,w,g,r,n,i,o,s)}for(const b of co(t))b instanceof _r,b.isInvisible||tr(b,e,g,r,n,i,o,s);n.delete(c.objectId);return}if(t instanceof $r){const c=t,d=_i(c,i);if(!d||n.has(d.objectId))return;n.add(d.objectId);const u=Bt(e,c.getFullDimBlockTransform());It(d,u,l,r,n,i,o,!0),n.delete(d.objectId);return}if(Oi(t)){Ri(r,l,e,t);return}if(t instanceof jr){ae(e)?Ki(r,l,e,t.center,t.radius,t.normal):Xt(r,l,e,uo(t));return}if(t instanceof Hr){ae(e)?Ji(r,l,e,t):Xt(r,l,e,mo(t));return}if(t instanceof ie){Xt(r,l,e,t);return}if(t instanceof Vr){Zi(r,l,e,t);return}if(t instanceof Yr){to(r,l,e,t);return}if(t instanceof Xr){Wi(r,l,e,t);return}if(t instanceof Gr){const c=[];for(let d=0;d<t.numberOfVertices;d++)c.push(t.getPointAt(d));wt(r,l,e,c,t.closed);return}if(t instanceof Wr){s&&no(r,l,e,t);return}if(t instanceof Kr){t.basePoint,t.unitDir;return}if(t instanceof Jr){t.basePoint,t.unitDir;return}if(t instanceof Zr){Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof qr){s&&Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof Qr){const c=t.subGetGripPoints();c.length>=2&&wt(r,l,e,c,c.length>=3);return}if(t instanceof tn){const c=t.vertices;c.length>=2&&wt(r,l,e,c,!1);return}if(t instanceof en){Yi(r,l,e,t);return}if(t instanceof an){Gi(r,l,e,t);return}if(t instanceof rn){const c=P(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof nn){const c=P(e,t.location);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof on){s&&lo(r,l,e,t);return}if(t instanceof sn){s&&so(r,l,e,t);return}if(t instanceof ln){const c=P(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y})}}}function It(t,e,a,r,n,i,o,s=!0){for(const l of t.newIterator())tr(l,e,a,r,n,i,o,s)}function uo(t){return new ie(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,0,mn)}function mo(t){return new ie(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,t.startAngle,t.endAngle)}function po(t,e,a={}){const r=Ti(t,e);if(!r)return{primitives:[]};const n=[],i=new F.Matrix4;return It(r,i,"0",n,new Set,t,a.includeLayer),{primitives:n.filter(o=>o.kind!=="line"&&ho(o))}}function ho(t){switch(t.kind){case"line":return Number.isFinite(t.x0)&&Number.isFinite(t.y0)&&Number.isFinite(t.x1)&&Number.isFinite(t.y1);case"circle":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r);case"arc":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"ellipse":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.majorX)&&Number.isFinite(t.majorY)&&Number.isFinite(t.majorR)&&Number.isFinite(t.minorR)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"spline":return t.controlPoints.every(e=>Number.isFinite(e))&&t.knots.every(e=>Number.isFinite(e))&&t.weights.every(e=>Number.isFinite(e));case"point":return Number.isFinite(t.x)&&Number.isFinite(t.y);case"path":return t.vertices.length>=6&&t.vertices.length%3===0&&t.vertices.every(e=>Number.isFinite(e));default:return t}}const fo=["en","zh","cs","tr","ar"];function ye(t){if(t==null||t==="")return null;const e=t.toLowerCase().replace("_","-");for(const a of fo)if(e===a||e.startsWith(`${a}-`))return a;return null}const go=1128612673;function bo(t){if(t.version!==Y)throw new Error(`Unsupported chunk version: ${t.version}`);const e=new pe;e.writeU32(go),e.writeU8(Y),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeString(t.layoutBtrId),e.writeU32(t.lineBatches.length);for(const a of t.lineBatches)Ra(e,a);e.writeU32(t.meshBatches.length);for(const a of t.meshBatches)_a(e,a);return e.toUint8Array()}async function wo(t){const e=bo(t),a=(await Oa(e)).bytes;return{uncompressed:e,compressed:a}}const xo=1,yo=2*1024*1024,Nt=2*1024*1024,vo=512*1024,ko=8*1024*1024,pa=12*1024*1024,Ao=2*1024*1024,Tt="drawing.acex.json",Mo=`./${Tt}`,ne={layerOn:wn,layerOff:xn,chevronDown:bn},Fo=[90,45,30,23,18,10,5];function zo(){return`<div id="mlcad-polar-angles" role="group" data-i18n-attr="aria-label" data-i18n-key="settings.polarAngles" aria-label="Polar tracking angles" hidden>
2
- ${Fo.map(t=>`<button type="button" class="mlcad-tool-btn mlcad-settings-option-btn mlcad-polar-angle-btn" data-polar-ang="${t}" title="${t}°" aria-label="${t}°"><span class="mlcad-settings-option-indicator" aria-hidden="true"></span><span class="mlcad-settings-option-text">${t}°</span></button>`).join("")}
3
- </div>`}const Co=600,So=960,ve=`
4
- :root {
5
- --mlcad-ui-bg: rgba(24, 26, 30, 0.94);
6
- --mlcad-ui-bg-elevated: rgba(32, 35, 40, 0.98);
7
- --mlcad-ui-border: rgba(255, 255, 255, 0.1);
8
- --mlcad-ui-text: #e8eaed;
9
- --mlcad-ui-muted: #9aa0a6;
10
- --mlcad-accent: #08e8de;
11
- --mlcad-accent-active: #1a8cff;
12
- /* Shared measure-tool SVGs read --el-color-primary (Element Plus in cad-viewer). */
13
- --el-color-primary: var(--mlcad-accent);
14
- --ml-ui-accent: var(--mlcad-accent);
15
- --ml-ui-bg: var(--mlcad-ui-bg);
16
- --ml-ui-bg-elevated: var(--mlcad-ui-bg-elevated);
17
- --ml-ui-border: var(--mlcad-ui-border);
18
- --ml-ui-text: var(--mlcad-ui-text);
19
- --ml-ui-muted: var(--mlcad-ui-muted);
20
- --mlcad-tool-btn-active-border: rgba(26, 140, 255, 0.55);
21
- --mlcad-tool-btn-active-bg: rgba(26, 140, 255, 0.22);
22
- --mlcad-measure-accent: #08e8de;
23
- --mlcad-measure-accent-border: rgba(8, 232, 222, 0.45);
24
- --mlcad-measure-accent-fill: rgba(8, 232, 222, 0.2);
25
- --mlcad-markup-accent: #e53935;
26
- --mlcad-markup-accent-border: rgba(229, 57, 53, 0.45);
27
- --mlcad-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
28
- --mlcad-toolbar-width: 44px;
29
- --mlcad-drawer-width: 220px;
30
- --mlcad-drawer-gap: 8px;
31
- --mlcad-ui-inset: 12px;
32
- --mlcad-review-max-height: calc(100vh - 2 * var(--mlcad-ui-inset) - 48px);
33
- --mlcad-z-chrome: 7;
34
- /* Drawing overlays stay under chrome, session panel, and modal dialogs. */
35
- --mlcad-z-measure: 1;
36
- --mlcad-z-markup: 2;
37
- --ml-ui-grip-size: 8px;
38
- --ml-ui-grip-normal: #0080ff;
39
- --ml-ui-grip-hot: #ff0000;
40
- }
41
- html, body {
42
- margin: 0; height: 100%; overflow: hidden;
43
- background: #121418;
44
- font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
45
- color: var(--mlcad-ui-text);
46
- }
47
- #mlcad-root { position: relative; width: 100%; height: 100%; }
48
- #mlcad-canvas-host {
49
- position: absolute;
50
- inset: 0;
51
- min-width: 0;
52
- min-height: 0;
53
- -webkit-touch-callout: none;
54
- -webkit-tap-highlight-color: transparent;
55
- }
56
- #mlcad-canvas-host canvas,
57
- #mlcad-root > canvas {
58
- display: block;
59
- width: 100%;
60
- height: 100%;
61
- touch-action: none;
62
- -webkit-user-select: none;
63
- user-select: none;
64
- -webkit-touch-callout: none;
65
- -webkit-tap-highlight-color: transparent;
66
- }
67
-
68
- .mlcad-snap-loupe {
69
- position: absolute;
70
- left: 8px;
71
- top: 8px;
72
- width: 128px;
73
- height: 128px;
74
- box-sizing: border-box;
75
- border: 2px solid var(--mlcad-measure-accent, #08e8de);
76
- border-radius: 2px;
77
- pointer-events: none;
78
- z-index: 8;
79
- overflow: hidden;
80
- box-shadow: var(--mlcad-shadow);
81
- }
82
-
83
- html[data-mlcad-theme="light"] {
84
- --mlcad-ui-bg: rgba(255, 255, 255, 0.94);
85
- --mlcad-ui-bg-elevated: rgba(248, 249, 250, 0.98);
86
- --mlcad-ui-border: rgba(0, 0, 0, 0.12);
87
- --mlcad-ui-text: #202124;
88
- --mlcad-ui-muted: #5f6368;
89
- --mlcad-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
90
- }
91
- html[data-mlcad-theme="light"],
92
- html[data-mlcad-theme="light"] body {
93
- background: #e8eaed;
94
- color: var(--mlcad-ui-text);
95
- }
96
-
97
- #mlcad-sidebar {
98
- position: absolute;
99
- left: var(--mlcad-ui-inset);
100
- top: 50%;
101
- z-index: var(--mlcad-z-chrome);
102
- transform: translateY(-50%);
103
- display: flex;
104
- align-items: flex-start;
105
- gap: var(--mlcad-drawer-gap);
106
- max-width: calc(100% - 2 * var(--mlcad-ui-inset));
107
- box-sizing: border-box;
108
- pointer-events: none;
109
- }
110
- #mlcad-sidebar > * { pointer-events: auto; }
111
-
112
- #mlcad-toolbar {
113
- flex-shrink: 0;
114
- display: flex;
115
- flex-direction: column;
116
- align-items: stretch;
117
- padding: 0;
118
- background: transparent;
119
- border: none;
120
- border-radius: 0;
121
- box-shadow: none;
122
- backdrop-filter: none;
123
- }
124
- /* AcUiToolbar chrome replaces the old .mlcad-tool-btn shell styles. */
125
- #mlcad-toolbar .ml-ex-ui-toolbar {
126
- position: relative !important;
127
- inset: auto !important;
128
- left: auto !important;
129
- top: auto !important;
130
- right: auto !important;
131
- bottom: auto !important;
132
- transform: none !important;
133
- background: var(--mlcad-ui-bg);
134
- border: 1px solid var(--mlcad-ui-border);
135
- border-radius: 8px;
136
- box-shadow: var(--mlcad-shadow);
137
- backdrop-filter: blur(12px);
138
- --ml-ex-ui-toolbar-btn-size: var(--mlcad-toolbar-width);
139
- }
140
- #mlcad-toolbar .ml-ex-ui-toolbar.is-left,
141
- #mlcad-toolbar .ml-ex-ui-toolbar.is-right {
142
- flex-direction: column;
143
- }
144
- #mlcad-toolbar .ml-ex-ui-toolbar.is-bottom,
145
- #mlcad-toolbar .ml-ex-ui-toolbar.is-top {
146
- flex-direction: row;
147
- width: 100%;
148
- box-sizing: border-box;
149
- }
150
- #mlcad-sidebar > #mlcad-toolbar.ml-ex-ui-toolbar-host {
151
- display: flex;
152
- flex-direction: column;
153
- align-items: stretch;
154
- }
155
- /* Phone strips mount on #mlcad-root so they can sit above the bottom bar. */
156
- #mlcad-root > .ml-ex-ui-subtoolbar {
157
- z-index: calc(var(--mlcad-z-chrome) + 1);
158
- }
159
- .mlcad-tool-btn {
160
- position: relative;
161
- display: flex; flex-direction: column; align-items: center; justify-content: center;
162
- gap: 2px;
163
- width: var(--mlcad-toolbar-width); height: var(--mlcad-toolbar-width);
164
- margin: 0; padding: 0;
165
- border: 1px solid transparent;
166
- border-radius: 6px;
167
- background: transparent;
168
- color: var(--mlcad-ui-text);
169
- cursor: pointer;
170
- transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
171
- }
172
- .mlcad-tool-btn:hover {
173
- background: rgba(255, 255, 255, 0.08);
174
- border-color: var(--mlcad-ui-border);
175
- }
176
- .mlcad-tool-btn.active,
177
- .mlcad-tool-btn.is-menu-open {
178
- background: var(--mlcad-tool-btn-active-bg);
179
- border-color: var(--mlcad-tool-btn-active-border);
180
- color: #fff;
181
- }
182
- .mlcad-tool-btn-icon {
183
- display: inline-flex;
184
- align-items: center;
185
- justify-content: center;
186
- width: 20px;
187
- height: 20px;
188
- flex-shrink: 0;
189
- }
190
- .mlcad-tool-btn-icon svg,
191
- .mlcad-tool-btn svg {
192
- width: 20px; height: 20px; display: block; flex-shrink: 0;
193
- }
194
- .mlcad-tool-btn-label {
195
- display: none;
196
- max-width: 100%;
197
- overflow: hidden;
198
- text-overflow: ellipsis;
199
- white-space: nowrap;
200
- font-size: 10px;
201
- line-height: 1.2;
202
- text-align: center;
203
- pointer-events: none;
204
- }
205
- /* Settings is always on the bar (desktop/pad/phone); language lives under it. */
206
- /* Flyout mark: opaque corner triangle (cad-simple-ui-plugin is-left style). */
207
- .mlcad-tool-btn.has-children::after {
208
- content: '';
209
- position: absolute;
210
- right: 1px;
211
- bottom: 1px;
212
- width: 6px;
213
- height: 6px;
214
- background: currentColor;
215
- clip-path: polygon(100% 100%, 0 100%, 100% 0);
216
- pointer-events: none;
217
- }
218
- .mlcad-dropdown {
219
- position: fixed;
220
- z-index: 40;
221
- min-width: 180px;
222
- max-width: min(280px, calc(100vw - 24px));
223
- max-height: min(360px, calc(100vh - 24px));
224
- overflow-y: auto;
225
- padding: 4px;
226
- background: var(--mlcad-ui-bg-elevated);
227
- border: 1px solid var(--mlcad-ui-border);
228
- border-radius: 8px;
229
- box-shadow: var(--mlcad-shadow);
230
- backdrop-filter: blur(12px);
231
- }
232
- .mlcad-dropdown-item {
233
- display: flex;
234
- align-items: center;
235
- gap: 8px;
236
- width: 100%;
237
- box-sizing: border-box;
238
- margin: 0;
239
- padding: 6px 8px;
240
- border: none;
241
- border-radius: 5px;
242
- background: transparent;
243
- color: var(--mlcad-ui-text);
244
- font-size: 12px;
245
- font-weight: 500;
246
- text-align: left;
247
- cursor: pointer;
248
- }
249
- .mlcad-dropdown-item:hover {
250
- background: rgba(255, 255, 255, 0.08);
251
- }
252
- .mlcad-dropdown-item.active,
253
- .mlcad-dropdown-item.is-toggled {
254
- background: rgba(26, 140, 255, 0.22);
255
- color: #fff;
256
- }
257
- .mlcad-dropdown-icon {
258
- display: inline-flex;
259
- width: 18px;
260
- height: 18px;
261
- flex-shrink: 0;
262
- align-items: center;
263
- justify-content: center;
264
- }
265
- .mlcad-dropdown-icon svg {
266
- width: 18px;
267
- height: 18px;
268
- display: block;
269
- }
270
- .mlcad-dropdown-label {
271
- overflow: hidden;
272
- text-overflow: ellipsis;
273
- white-space: nowrap;
274
- }
275
- .mlcad-dropdown-separator {
276
- height: 1px;
277
- margin: 4px 6px;
278
- background: var(--mlcad-ui-border);
279
- }
280
- #mlcad-toolbar-toggle {
281
- height: calc(var(--mlcad-toolbar-width) / 2);
282
- margin-top: -4px;
283
- margin-bottom: -4px;
284
- border-radius: 4px;
285
- }
286
- #mlcad-toolbar-toggle svg {
287
- width: calc(var(--mlcad-toolbar-width) / 2);
288
- height: calc(var(--mlcad-toolbar-width) / 2);
289
- }
290
- .mlcad-tool-separator {
291
- height: 1px;
292
- margin: 4px 8px;
293
- background: var(--mlcad-ui-border);
294
- }
295
- .mlcad-locale-option-badge {
296
- display: inline-flex;
297
- align-items: center;
298
- justify-content: center;
299
- width: 100%;
300
- height: 100%;
301
- font-size: 12px;
302
- font-weight: 700;
303
- line-height: 1;
304
- letter-spacing: -0.04em;
305
- user-select: none;
306
- }
307
- #mlcad-zoom-window-rect,
308
- #mlcad-selection-rect {
309
- position: fixed;
310
- z-index: 25;
311
- box-sizing: border-box;
312
- pointer-events: none;
313
- border: 1px dashed var(--mlcad-accent, #08e8de);
314
- background: rgba(8, 232, 222, 0.12);
315
- }
316
- #mlcad-zoom-window-rect[hidden],
317
- #mlcad-selection-rect[hidden] { display: none; }
318
- #mlcad-selection-rect[data-mode='window'] {
319
- border-style: solid;
320
- border-color: #00ff5a;
321
- background: rgba(64, 158, 255, 0.12);
322
- }
323
- #mlcad-selection-rect[data-mode='crossing'] {
324
- border-style: dashed;
325
- border-color: #00d1ff;
326
- background: rgba(64, 158, 255, 0.12);
327
- }
328
-
329
- #mlcad-layer-drawer,
330
- #mlcad-review-drawer,
331
- #mlcad-measure-drawer {
332
- flex-shrink: 1;
333
- min-width: 0;
334
- width: var(--mlcad-drawer-width);
335
- max-height: min(420px, var(--mlcad-review-max-height));
336
- display: flex; flex-direction: column;
337
- background: var(--mlcad-ui-bg-elevated);
338
- border: 1px solid var(--mlcad-ui-border);
339
- border-radius: 8px;
340
- box-shadow: var(--mlcad-shadow);
341
- backdrop-filter: blur(12px);
342
- overflow: hidden;
343
- box-sizing: border-box;
344
- }
345
- #mlcad-markup-strip-wrap {
346
- position: relative;
347
- }
348
- #mlcad-review-drawer {
349
- position: absolute;
350
- left: 100%;
351
- top: 0;
352
- margin-left: var(--mlcad-drawer-gap);
353
- width: min(320px, calc(100vw - 2 * var(--mlcad-ui-inset) - var(--mlcad-toolbar-width) - var(--mlcad-drawer-gap)));
354
- height: 100%;
355
- max-height: var(--mlcad-review-max-height);
356
- }
357
- #mlcad-layer-drawer[hidden],
358
- #mlcad-review-drawer[hidden],
359
- #mlcad-measure-drawer[hidden] { display: none; }
360
-
361
- .mlcad-drawer-header {
362
- display: flex; align-items: center; justify-content: space-between;
363
- gap: 6px; padding: 8px 10px;
364
- border-bottom: 1px solid var(--mlcad-ui-border);
365
- font-size: 13px; font-weight: 600;
366
- }
367
- .mlcad-drawer-close {
368
- width: 28px; height: 28px; padding: 0;
369
- border: none; border-radius: 4px;
370
- background: transparent; color: var(--mlcad-ui-muted);
371
- cursor: pointer; font-size: 18px; line-height: 1;
372
- }
373
- .mlcad-drawer-close:hover {
374
- background: rgba(255, 255, 255, 0.08); color: var(--mlcad-ui-text);
375
- }
376
-
377
- .mlcad-drawer-sheet-chrome {
378
- display: none;
379
- position: relative;
380
- }
381
- .mlcad-drawer-grabber {
382
- flex: 1 1 auto;
383
- display: flex;
384
- align-items: center;
385
- justify-content: center;
386
- min-height: 20px;
387
- cursor: ns-resize;
388
- touch-action: none;
389
- }
390
- .mlcad-drawer-grabber::before {
391
- content: '';
392
- position: absolute;
393
- left: 50%;
394
- top: 50%;
395
- transform: translate(-50%, -50%);
396
- width: 36px;
397
- height: 4px;
398
- border-radius: 2px;
399
- background: var(--mlcad-ui-muted);
400
- opacity: 0.75;
401
- }
402
- .mlcad-drawer-sheet-close {
403
- width: 36px; height: 28px; padding: 0;
404
- border: none; background: transparent;
405
- color: var(--mlcad-ui-muted); cursor: pointer;
406
- display: inline-flex; align-items: center; justify-content: center;
407
- flex: 0 0 auto;
408
- position: relative;
409
- z-index: 1;
410
- }
411
- .mlcad-drawer-sheet-close:hover { color: var(--mlcad-ui-text); }
412
- .mlcad-drawer-sheet-close svg { width: 18px; height: 18px; }
413
-
414
- .mlcad-layer-actions {
415
- display: flex; gap: 4px; padding: 6px 8px;
416
- border-bottom: 1px solid var(--mlcad-ui-border);
417
- }
418
- .mlcad-layer-action-btn {
419
- flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
420
- min-height: 30px; padding: 4px 8px;
421
- border: 1px solid var(--mlcad-ui-border);
422
- border-radius: 5px;
423
- background: rgba(255, 255, 255, 0.04);
424
- color: var(--mlcad-ui-text);
425
- font-size: 12px; cursor: pointer;
426
- }
427
- .mlcad-layer-action-btn:hover { background: rgba(255, 255, 255, 0.1); }
428
- .mlcad-layer-action-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
429
-
430
- #mlcad-layer-list {
431
- flex: 1; overflow: auto; padding: 4px 0;
432
- }
433
- .mlcad-layer-item {
434
- display: grid;
435
- grid-template-columns: auto auto 1fr auto;
436
- align-items: center; gap: 6px;
437
- padding: 5px 8px;
438
- font-size: 12px; cursor: pointer;
439
- }
440
- .mlcad-layer-item:hover { background: rgba(255, 255, 255, 0.05); }
441
- .mlcad-layer-item input { margin: 0; cursor: pointer; }
442
- .mlcad-layer-swatch {
443
- width: 12px; height: 12px; border-radius: 2px;
444
- border: 1px solid rgba(255, 255, 255, 0.28);
445
- }
446
- .mlcad-layer-name {
447
- overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
448
- }
449
- .mlcad-layer-zoom {
450
- display: flex; align-items: center; justify-content: center;
451
- width: 22px; height: 22px; padding: 0;
452
- border: 1px solid transparent; border-radius: 4px;
453
- background: transparent; color: var(--mlcad-ui-muted);
454
- cursor: pointer;
455
- }
456
- .mlcad-layer-zoom svg {
457
- width: 14px; height: 14px; display: block;
458
- }
459
- .mlcad-layer-zoom:hover:not(:disabled) {
460
- color: var(--mlcad-accent);
461
- border-color: var(--mlcad-ui-border);
462
- background: rgba(255, 255, 255, 0.06);
463
- }
464
- .mlcad-layer-zoom:disabled { opacity: 0.35; cursor: not-allowed; }
465
-
466
- .mlcad-review-toolbar {
467
- display: flex; gap: 6px; align-items: center;
468
- padding: 6px 8px;
469
- border-bottom: 1px solid var(--mlcad-ui-border);
470
- }
471
- .mlcad-review-search {
472
- flex: 1; min-width: 0;
473
- box-sizing: border-box;
474
- padding: 4px 8px;
475
- border: 1px solid var(--mlcad-ui-border);
476
- border-radius: 4px;
477
- background: rgba(255, 255, 255, 0.04);
478
- color: var(--mlcad-ui-text);
479
- font-size: 12px;
480
- }
481
- .mlcad-review-clear,
482
- .mlcad-review-zoom,
483
- .mlcad-review-delete {
484
- flex: 0 0 auto;
485
- padding: 4px 8px;
486
- border: 1px solid var(--mlcad-ui-border);
487
- border-radius: 4px;
488
- background: rgba(255, 255, 255, 0.04);
489
- color: var(--mlcad-ui-text);
490
- font-size: 12px; cursor: pointer;
491
- }
492
- .mlcad-review-clear:disabled { opacity: 0.5; cursor: default; }
493
- .mlcad-review-delete { color: #f56c6c; border-color: rgba(245, 108, 108, 0.55); }
494
- .mlcad-review-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
495
- .mlcad-review-table {
496
- width: 100%; border-collapse: collapse; font-size: 12px;
497
- }
498
- .mlcad-review-table th,
499
- .mlcad-review-table td {
500
- padding: 4px 8px; text-align: left;
501
- border-bottom: 1px solid var(--mlcad-ui-border);
502
- overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
503
- max-width: 90px;
504
- }
505
- .mlcad-review-table tr.is-selected td {
506
- background: rgba(26, 140, 255, 0.22);
507
- }
508
- .mlcad-review-table tr { cursor: pointer; }
509
- .mlcad-review-empty td { text-align: center; color: var(--mlcad-ui-muted); cursor: default; }
510
- .mlcad-review-detail {
511
- flex: 0 1 auto;
512
- max-height: 52%;
513
- overflow: auto;
514
- border-top: 1px solid var(--mlcad-ui-border);
515
- padding: 8px 10px 14px;
516
- display: flex; flex-direction: column; gap: 6px;
517
- box-sizing: border-box;
518
- }
519
- .mlcad-review-detail[hidden] { display: none; }
520
- .mlcad-review-detail-header {
521
- display: flex; align-items: center; justify-content: space-between; gap: 4px;
522
- }
523
- .mlcad-review-detail-title { font-weight: 600; font-size: 12px; }
524
- .mlcad-review-detail-close {
525
- flex-shrink: 0;
526
- width: 24px; height: 24px; padding: 0;
527
- border: none; border-radius: 4px;
528
- background: transparent; color: var(--mlcad-ui-muted);
529
- cursor: pointer; font-size: 16px; line-height: 1;
530
- }
531
- .mlcad-review-detail-close:hover {
532
- background: rgba(255, 255, 255, 0.08); color: var(--mlcad-ui-text);
533
- }
534
- .mlcad-review-field { display: flex; flex-direction: column; gap: 2px; }
535
- .mlcad-review-field-label { font-size: 11px; color: var(--mlcad-ui-muted); }
536
- .mlcad-review-status,
537
- .mlcad-review-author,
538
- .mlcad-review-text,
539
- .mlcad-review-comment {
540
- box-sizing: border-box; width: 100%;
541
- padding: 4px 6px;
542
- border: 1px solid var(--mlcad-ui-border);
543
- border-radius: 4px;
544
- background: rgba(255, 255, 255, 0.04);
545
- color: var(--mlcad-ui-text);
546
- font-size: 12px;
547
- }
548
- .mlcad-review-author:disabled { opacity: 0.7; }
549
- .mlcad-review-comment { min-height: 44px; resize: vertical; }
550
- .mlcad-review-detail-actions { display: flex; gap: 6px; margin-top: 2px; }
551
-
552
- .mlcad-measure-toolbar {
553
- display: flex; gap: 8px; align-items: center;
554
- padding: 8px 10px; border-bottom: 1px solid var(--mlcad-ui-border);
555
- }
556
- .mlcad-measure-filter {
557
- flex: 1 1 auto; min-width: 0;
558
- display: flex; overflow: hidden;
559
- border: 1px solid var(--mlcad-ui-border); border-radius: 4px;
560
- }
561
- .mlcad-measure-filter-btn {
562
- flex: 1 1 0; min-width: 0; padding: 4px 2px;
563
- border: none; border-right: 1px solid var(--mlcad-ui-border);
564
- background: transparent; color: var(--mlcad-ui-text);
565
- font: inherit; font-size: 11px; cursor: pointer;
566
- white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
567
- }
568
- .mlcad-measure-filter-btn:last-child { border-right: none; }
569
- .mlcad-measure-filter-btn:hover:not(.is-active) {
570
- background: rgba(255, 255, 255, 0.06);
571
- }
572
- .mlcad-measure-filter-btn.is-active {
573
- background: rgba(8, 232, 222, 0.18);
574
- }
575
- .mlcad-measure-clear,
576
- .mlcad-measure-row-delete {
577
- border: 1px solid var(--mlcad-ui-border); border-radius: 4px;
578
- background: rgba(255, 255, 255, 0.04); color: var(--mlcad-ui-text);
579
- padding: 4px 8px; font-size: 12px; cursor: pointer;
580
- }
581
- .mlcad-measure-clear:disabled { opacity: 0.5; cursor: default; }
582
- .mlcad-measure-row-delete { color: #f56c6c; border-color: rgba(245, 108, 108, 0.55); padding: 2px 6px; font-size: 11px; }
583
- .mlcad-measure-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
584
- .mlcad-measure-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
585
- .mlcad-measure-table th,
586
- .mlcad-measure-table td {
587
- padding: 6px 8px; text-align: left; font-size: 12px;
588
- border-bottom: 1px solid var(--mlcad-ui-border);
589
- overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
590
- }
591
- .mlcad-measure-table tr.is-selected td {
592
- background: rgba(8, 232, 222, 0.12);
593
- }
594
- .mlcad-measure-table tr { cursor: pointer; }
595
- .mlcad-measure-empty td { text-align: center; color: var(--mlcad-ui-muted); cursor: default; }
596
- #mlcad-measure-strip-wrap { position: relative; }
597
- #mlcad-measure-drawer {
598
- position: absolute;
599
- left: 100%;
600
- top: 0;
601
- margin-left: var(--mlcad-drawer-gap);
602
- width: min(320px, calc(100vw - 2 * var(--mlcad-ui-inset) - var(--mlcad-toolbar-width) - var(--mlcad-drawer-gap)));
603
- height: 100%;
604
- max-height: var(--mlcad-review-max-height);
605
- }
606
-
607
- /*
608
- * Top canvas chrome: message bar + expiry share one row. Shortcut toolbar
609
- * and snap loupe stack below (see AcExHtmlTopChrome / ShortCutToolbar /
610
- * SnapLoupeMath).
611
- */
612
- #mlcad-top-chrome {
613
- position: absolute;
614
- left: 12px;
615
- right: 12px;
616
- top: 10px;
617
- z-index: var(--mlcad-z-chrome);
618
- display: flex;
619
- align-items: flex-start;
620
- gap: 8px;
621
- box-sizing: border-box;
622
- pointer-events: none;
623
- }
624
- #mlcad-status-bar {
625
- position: relative;
626
- flex: 1 1 auto;
627
- min-width: 0;
628
- /* Block layout so text-overflow: ellipsis works on direct textContent. */
629
- display: block;
630
- min-height: 28px;
631
- line-height: 28px;
632
- padding: 0 12px;
633
- border: 1px solid rgba(0, 0, 0, 0.12);
634
- border-radius: 6px;
635
- background: var(--mlcad-accent);
636
- color: #0b1f1e;
637
- font-size: 12px;
638
- font-weight: 600;
639
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
640
- backdrop-filter: blur(10px);
641
- pointer-events: none;
642
- opacity: 1;
643
- transform: translateY(0);
644
- transition: opacity 0.18s ease, transform 0.18s ease;
645
- /* Shrink before the expiry badge; clip with an ellipsis when too narrow. */
646
- overflow: hidden;
647
- white-space: nowrap;
648
- text-overflow: ellipsis;
649
- }
650
- #mlcad-status-bar:empty,
651
- #mlcad-status-bar[hidden] {
652
- display: none;
653
- opacity: 0;
654
- transform: translateY(-6px);
655
- }
656
-
657
- /* Session panel DOM/CSS comes from shared AcUiMobileSessionPanel. */
658
- #mlcad-root {
659
- --ml-mobile-cmd-collapsed-height: var(--mlcad-toolbar-phone-height, 56px);
660
- }
661
- .ml-mobile-cmd-panel {
662
- z-index: calc(var(--mlcad-z-chrome) + 3);
663
- }
664
-
665
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-snap-strip-wrap,
666
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-measure-strip-wrap,
667
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-markup-strip-wrap,
668
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-zoom-strip-wrap,
669
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-settings-strip-wrap,
670
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-locale-strip-wrap,
671
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-layer-drawer,
672
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-review-drawer,
673
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-measure-drawer {
674
- display: none !important;
675
- }
676
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-toolbar .mlcad-tool-btn:not(#mlcad-toolbar-toggle) {
677
- display: none;
678
- }
679
- #mlcad-sidebar.mlcad-sidebar--collapsed #mlcad-toolbar .mlcad-tool-separator {
680
- display: none;
681
- }
682
-
683
- #mlcad-snap-strip-wrap,
684
- #mlcad-measure-strip-wrap,
685
- #mlcad-markup-strip-wrap,
686
- #mlcad-zoom-strip-wrap,
687
- #mlcad-settings-strip-wrap,
688
- #mlcad-locale-strip-wrap {
689
- flex-shrink: 0;
690
- min-width: 0;
691
- display: flex;
692
- flex-direction: row;
693
- align-items: flex-start;
694
- gap: var(--mlcad-drawer-gap);
695
- }
696
- #mlcad-snap-strip-wrap[hidden],
697
- #mlcad-measure-strip-wrap[hidden],
698
- #mlcad-markup-strip-wrap[hidden],
699
- #mlcad-zoom-strip-wrap[hidden],
700
- #mlcad-settings-strip-wrap[hidden],
701
- #mlcad-locale-strip-wrap[hidden] { display: none; }
702
-
703
- #mlcad-snap-strip,
704
- #mlcad-measure-strip,
705
- #mlcad-markup-strip,
706
- #mlcad-zoom-strip,
707
- #mlcad-settings-strip,
708
- #mlcad-locale-strip {
709
- flex-shrink: 0;
710
- display: flex;
711
- flex-direction: column;
712
- align-items: stretch;
713
- gap: 4px;
714
- padding: 6px;
715
- background: var(--mlcad-ui-bg);
716
- border: 1px solid var(--mlcad-ui-border);
717
- border-radius: 8px;
718
- box-shadow: var(--mlcad-shadow);
719
- backdrop-filter: blur(12px);
720
- }
721
- /* Pad/desktop: same button size as the parent bar so a vertical strip
722
- matches its width and a horizontal strip matches its height. */
723
- #mlcad-snap-strip .mlcad-tool-btn,
724
- #mlcad-measure-strip .mlcad-tool-btn,
725
- #mlcad-markup-strip .mlcad-tool-btn,
726
- #mlcad-zoom-strip .mlcad-tool-btn,
727
- #mlcad-settings-strip .mlcad-tool-btn,
728
- #mlcad-locale-strip .mlcad-tool-btn {
729
- width: var(--mlcad-toolbar-width);
730
- height: var(--mlcad-toolbar-width);
731
- }
732
- #mlcad-measure-strip .mlcad-tool-separator,
733
- #mlcad-markup-strip .mlcad-tool-separator {
734
- margin: 2px 4px;
735
- }
736
-
737
- #mlcad-polar-angles {
738
- flex-shrink: 0;
739
- display: inline-flex;
740
- flex-direction: column;
741
- align-items: stretch;
742
- gap: 4px;
743
- padding: 6px;
744
- max-width: min(280px, calc(100vw - 2 * var(--mlcad-ui-inset) - 3 * var(--mlcad-toolbar-width) - 3 * var(--mlcad-drawer-gap)));
745
- background: var(--mlcad-ui-bg);
746
- border: 1px solid var(--mlcad-ui-border);
747
- border-radius: 8px;
748
- box-shadow: var(--mlcad-shadow);
749
- backdrop-filter: blur(12px);
750
- }
751
- #mlcad-polar-angles[hidden] { display: none; }
752
-
753
- .mlcad-color-input {
754
- position: absolute;
755
- width: 0;
756
- height: 0;
757
- opacity: 0;
758
- pointer-events: none;
759
- }
760
- .mlcad-settings-option-btn {
761
- width: 100%;
762
- box-sizing: border-box;
763
- height: var(--mlcad-toolbar-width);
764
- justify-content: flex-start;
765
- gap: 8px;
766
- padding: 0 10px;
767
- font-size: 11px;
768
- font-weight: 500;
769
- }
770
- .mlcad-settings-option-indicator {
771
- flex-shrink: 0;
772
- width: 10px;
773
- height: 10px;
774
- border: 1px solid var(--mlcad-ui-muted);
775
- border-radius: 2px;
776
- box-sizing: border-box;
777
- transition: background 0.15s ease, border-color 0.15s ease;
778
- }
779
- .mlcad-settings-option-btn.active .mlcad-settings-option-indicator {
780
- background: var(--mlcad-accent);
781
- border-color: var(--mlcad-accent);
782
- }
783
- .mlcad-settings-option-text {
784
- overflow: hidden;
785
- text-overflow: ellipsis;
786
- white-space: nowrap;
787
- pointer-events: none;
788
- line-height: 1.2;
789
- }
790
-
791
- #mlcad-measure-overlays {
792
- position: absolute;
793
- inset: 0;
794
- pointer-events: none;
795
- z-index: var(--mlcad-z-measure);
796
- overflow: hidden;
797
- }
798
- .mlcad-measure-canvas {
799
- position: absolute;
800
- left: 0;
801
- top: 0;
802
- z-index: 1;
803
- pointer-events: none;
804
- }
805
- .mlcad-measure-dot {
806
- position: absolute;
807
- z-index: 3;
808
- /* em size tracks the paired badge font-size (set inline on the dot) */
809
- font-size: 12px;
810
- width: 0.55em;
811
- height: 0.55em;
812
- min-width: 5px;
813
- min-height: 5px;
814
- border-radius: 50%;
815
- background: var(--mlcad-measure-accent);
816
- border: 0.12em solid rgba(255, 255, 255, 0.9);
817
- box-sizing: border-box;
818
- transform: translate(-50%, -50%);
819
- visibility: hidden;
820
- pointer-events: none;
821
- cursor: grab;
822
- }
823
- .mlcad-measure-dot.mlcad-measure-selected {
824
- visibility: visible;
825
- pointer-events: auto;
826
- /* Hard ring at half original em thickness + soft glow */
827
- box-shadow:
828
- 0 0 0 0.06em rgba(255, 213, 79, 0.75),
829
- 0 0 0.35em rgba(255, 213, 79, 0.9),
830
- 0 0 0.7em rgba(255, 213, 79, 0.5);
831
- }
832
- #mlcad-measure-overlays.mlcad-grip-dragging .mlcad-measure-dot {
833
- visibility: hidden !important;
834
- pointer-events: none !important;
835
- }
836
- .mlcad-measure-badge {
837
- position: absolute;
838
- z-index: 2;
839
- /* em padding/radius/border so the capsule scales with font-size */
840
- padding: 0.25em 0.833em;
841
- border-radius: 1.167em;
842
- background: var(--mlcad-ui-bg-elevated);
843
- border: 0.083em solid var(--mlcad-measure-accent-border);
844
- color: var(--mlcad-measure-accent);
845
- font-size: 12px;
846
- font-weight: 600;
847
- white-space: nowrap;
848
- transform: translate(-50%, -50%);
849
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
850
- pointer-events: none;
851
- }
852
- .mlcad-measure-badge--coordinate {
853
- transform: translate(-50%, calc(-50% - 16px));
854
- }
855
- .mlcad-measure-badge.mlcad-measure-selected {
856
- /* Hard ring at half original em thickness + soft glow */
857
- outline: 0.075em solid rgba(255, 213, 79, 0.85);
858
- outline-offset: 0.04em;
859
- box-shadow:
860
- 0 0 0 0.075em rgba(255, 213, 79, 0.4),
861
- 0 0 0.45em rgba(255, 213, 79, 0.85),
862
- 0 0 0.9em rgba(255, 213, 79, 0.55),
863
- 0 2px 8px rgba(0, 0, 0, 0.35);
864
- }
865
- .mlcad-measure-canvas.mlcad-measure-selected {
866
- /* font-size is seeded from the paired badge so em tracks text size */
867
- filter:
868
- drop-shadow(0 0 0.12em #ffd54f)
869
- drop-shadow(0 0 0.3em rgba(255, 213, 79, 0.95))
870
- drop-shadow(0 0 0.6em rgba(255, 213, 79, 0.55));
871
- }
872
-
873
- #mlcad-markup-overlays {
874
- position: absolute;
875
- inset: 0;
876
- pointer-events: none;
877
- z-index: var(--mlcad-z-markup);
878
- overflow: hidden;
879
- }
880
- .mlcad-markup-canvas {
881
- position: absolute;
882
- left: 0;
883
- top: 0;
884
- z-index: 1;
885
- pointer-events: none;
886
- }
887
- .mlcad-markup-badge,
888
- .mlcad-markup-stamp {
889
- position: absolute;
890
- z-index: 2;
891
- padding: 3px 10px;
892
- border-radius: 14px;
893
- background: var(--mlcad-ui-bg-elevated);
894
- border: 1px solid var(--mlcad-markup-accent-border);
895
- color: var(--mlcad-markup-accent);
896
- font-size: 12px;
897
- font-weight: 600;
898
- white-space: pre-wrap;
899
- max-width: 240px;
900
- min-width: 80px;
901
- min-height: 1.75em;
902
- box-sizing: border-box;
903
- transform: translate(-50%, -50%);
904
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
905
- pointer-events: auto;
906
- cursor: grab;
907
- touch-action: none;
908
- user-select: none;
909
- }
910
- .mlcad-markup-stamp {
911
- border-radius: 4px;
912
- border-width: 2px;
913
- text-transform: uppercase;
914
- letter-spacing: 0.04em;
915
- font-size: 11px;
916
- white-space: nowrap;
917
- min-width: 0;
918
- }
919
- .mlcad-markup-preview-dot {
920
- position: absolute;
921
- font-size: 12px;
922
- width: 0.55em;
923
- height: 0.55em;
924
- min-width: 5px;
925
- min-height: 5px;
926
- border-radius: 50%;
927
- background: var(--mlcad-markup-accent);
928
- border: 0.12em solid rgba(255, 255, 255, 0.9);
929
- box-sizing: border-box;
930
- transform: translate(-50%, -50%);
931
- pointer-events: none;
932
- }
933
- .mlcad-markup-dot {
934
- position: absolute;
935
- z-index: 3;
936
- font-size: 12px;
937
- width: 0.55em;
938
- height: 0.55em;
939
- min-width: 5px;
940
- min-height: 5px;
941
- border-radius: 50%;
942
- background: var(--mlcad-markup-accent);
943
- border: 0.12em solid rgba(255, 255, 255, 0.9);
944
- box-sizing: border-box;
945
- transform: translate(-50%, -50%);
946
- visibility: hidden;
947
- pointer-events: none;
948
- cursor: grab;
949
- }
950
- .mlcad-markup-dot.mlcad-markup-selected {
951
- visibility: visible;
952
- pointer-events: auto;
953
- box-shadow:
954
- 0 0 0 0.06em rgba(255, 213, 79, 0.75),
955
- 0 0 0.35em rgba(255, 213, 79, 0.9),
956
- 0 0 0.7em rgba(255, 213, 79, 0.5);
957
- }
958
- #mlcad-markup-overlays.mlcad-grip-dragging .mlcad-markup-dot {
959
- visibility: hidden !important;
960
- pointer-events: none !important;
961
- }
962
- .mlcad-markup-badge.mlcad-markup-selected,
963
- .mlcad-markup-stamp.mlcad-markup-selected {
964
- outline: 0.075em solid rgba(255, 213, 79, 0.85);
965
- outline-offset: 0.04em;
966
- box-shadow:
967
- 0 0 0 0.075em rgba(255, 213, 79, 0.4),
968
- 0 0 0.45em rgba(255, 213, 79, 0.85),
969
- 0 0 0.9em rgba(255, 213, 79, 0.55),
970
- 0 2px 8px rgba(0, 0, 0, 0.35);
971
- }
972
- .mlcad-markup-canvas.mlcad-markup-selected {
973
- filter:
974
- drop-shadow(0 0 0.12em #ffd54f)
975
- drop-shadow(0 0 0.3em rgba(255, 213, 79, 0.95))
976
- drop-shadow(0 0 0.6em rgba(255, 213, 79, 0.55));
977
- }
978
-
979
- #mlcad-loading {
980
- position: fixed; inset: 0; z-index: 100;
981
- display: flex; align-items: center; justify-content: center;
982
- background: #121418;
983
- transition: opacity 0.35s ease, visibility 0.35s ease;
984
- }
985
- #mlcad-loading.mlcad-loading--done {
986
- opacity: 0; visibility: hidden; pointer-events: none;
987
- }
988
- #mlcad-loading.mlcad-loading--gate .mlcad-loading-spinner {
989
- display: none;
990
- }
991
- .mlcad-loading-spinner {
992
- width: 48px; height: 48px; box-sizing: border-box;
993
- border: 3px solid rgba(255, 255, 255, 0.12);
994
- border-top-color: var(--mlcad-accent);
995
- border-radius: 50%;
996
- animation: mlcad-spin 0.85s linear infinite;
997
- }
998
- @keyframes mlcad-spin { to { transform: rotate(360deg); } }
999
-
1000
- #mlcad-access-gate {
1001
- display: flex;
1002
- align-items: center;
1003
- justify-content: center;
1004
- width: 100%;
1005
- max-width: 360px;
1006
- padding: 0 20px;
1007
- box-sizing: border-box;
1008
- }
1009
- #mlcad-access-gate[hidden] {
1010
- display: none !important;
1011
- }
1012
- .mlcad-access-card {
1013
- width: 100%;
1014
- padding: 24px 20px;
1015
- border-radius: 10px;
1016
- border: 1px solid var(--mlcad-ui-border);
1017
- background: var(--mlcad-ui-bg-elevated);
1018
- box-shadow: var(--mlcad-shadow);
1019
- box-sizing: border-box;
1020
- }
1021
- .mlcad-access-title {
1022
- margin: 0 0 8px;
1023
- font-size: 16px;
1024
- font-weight: 600;
1025
- color: var(--mlcad-ui-text);
1026
- text-align: center;
1027
- }
1028
- .mlcad-access-hint {
1029
- margin: 0 0 16px;
1030
- font-size: 13px;
1031
- line-height: 1.45;
1032
- color: var(--mlcad-ui-muted);
1033
- text-align: center;
1034
- }
1035
- .mlcad-access-expiry {
1036
- margin: -8px 0 16px;
1037
- font-size: 12px;
1038
- line-height: 1.4;
1039
- color: var(--mlcad-ui-muted);
1040
- text-align: center;
1041
- }
1042
- .mlcad-access-expiry[hidden] {
1043
- display: none;
1044
- }
1045
- .mlcad-access-expiry.mlcad-expiry-countdown {
1046
- width: fit-content;
1047
- max-width: 100%;
1048
- margin-left: auto;
1049
- margin-right: auto;
1050
- margin-bottom: 16px;
1051
- padding: 6px 10px;
1052
- border-radius: 6px;
1053
- box-sizing: border-box;
1054
- }
1055
- .mlcad-access-field {
1056
- display: flex;
1057
- gap: 8px;
1058
- margin-bottom: 12px;
1059
- }
1060
- .mlcad-access-field input {
1061
- flex: 1 1 auto;
1062
- min-width: 0;
1063
- height: 36px;
1064
- padding: 0 12px;
1065
- border-radius: 6px;
1066
- border: 1px solid var(--mlcad-ui-border);
1067
- background: rgba(0, 0, 0, 0.25);
1068
- color: var(--mlcad-ui-text);
1069
- font: inherit;
1070
- box-sizing: border-box;
1071
- }
1072
- .mlcad-access-field input:focus {
1073
- outline: none;
1074
- border-color: rgba(26, 140, 255, 0.65);
1075
- box-shadow: 0 0 0 2px rgba(26, 140, 255, 0.2);
1076
- }
1077
- .mlcad-access-submit {
1078
- width: 100%;
1079
- height: 36px;
1080
- border: 1px solid rgba(26, 140, 255, 0.55);
1081
- border-radius: 6px;
1082
- background: rgba(26, 140, 255, 0.22);
1083
- color: #fff;
1084
- font: inherit;
1085
- font-weight: 600;
1086
- cursor: pointer;
1087
- }
1088
- .mlcad-access-submit:hover {
1089
- background: rgba(26, 140, 255, 0.32);
1090
- }
1091
- .mlcad-access-error {
1092
- margin: 0;
1093
- font-size: 12px;
1094
- line-height: 1.4;
1095
- color: #ff8a80;
1096
- text-align: center;
1097
- }
1098
- .mlcad-access-error[hidden] {
1099
- display: none;
1100
- }
1101
- .mlcad-access-gate--locked .mlcad-access-submit:disabled,
1102
- .mlcad-access-gate--locked .mlcad-access-field input:disabled {
1103
- opacity: 0.55;
1104
- cursor: not-allowed;
1105
- }
1106
- .mlcad-access-field[hidden],
1107
- .mlcad-access-submit[hidden],
1108
- .mlcad-access-gate--expired .mlcad-access-field,
1109
- .mlcad-access-gate--expired .mlcad-access-submit,
1110
- .mlcad-access-gate--expired #mlcad-access-expiry,
1111
- .mlcad-access-gate--expired #mlcad-access-error {
1112
- display: none !important;
1113
- }
1114
- .mlcad-expiry-badge {
1115
- position: relative;
1116
- flex: 0 0 auto;
1117
- margin-left: auto;
1118
- max-width: none;
1119
- padding: 8px 12px;
1120
- border-radius: 6px;
1121
- border: 1px solid var(--mlcad-ui-border);
1122
- background: var(--mlcad-ui-bg-elevated);
1123
- box-shadow: var(--mlcad-shadow);
1124
- color: var(--mlcad-ui-text);
1125
- font-size: 12px;
1126
- line-height: 1.4;
1127
- white-space: nowrap;
1128
- pointer-events: none;
1129
- box-sizing: border-box;
1130
- }
1131
- .mlcad-expiry-badge[hidden] {
1132
- display: none !important;
1133
- }
1134
- .mlcad-expiry-countdown {
1135
- border-color: rgba(255, 152, 0, 0.55);
1136
- background: rgba(255, 152, 0, 0.16);
1137
- color: #ffcc80;
1138
- font-variant-numeric: tabular-nums;
1139
- }
1140
-
1141
- @media (max-width: ${Co}px) {
1142
- :root {
1143
- --mlcad-drawer-width: min(280px, calc(100vw - 16px));
1144
- --mlcad-ui-inset: 0px;
1145
- --mlcad-toolbar-phone-height: 56px;
1146
- /* Portrait min width (narrower than simple-ui's height - 4). */
1147
- --mlcad-toolbar-phone-btn-size: max(
1148
- 24px,
1149
- calc(var(--mlcad-toolbar-phone-height) - 16px)
1150
- );
1151
- }
1152
- #mlcad-root {
1153
- display: flex;
1154
- flex-direction: column;
1155
- }
1156
- #mlcad-canvas-host {
1157
- position: relative;
1158
- flex: 1 1 auto;
1159
- inset: auto;
1160
- width: 100%;
1161
- min-height: 0;
1162
- }
1163
- #mlcad-sidebar {
1164
- position: relative;
1165
- left: auto;
1166
- top: auto;
1167
- right: auto;
1168
- transform: none;
1169
- width: 100%;
1170
- max-width: none;
1171
- flex: 0 0 auto;
1172
- flex-direction: column-reverse;
1173
- align-items: stretch;
1174
- gap: 0;
1175
- overflow: visible;
1176
- }
1177
- #mlcad-toolbar {
1178
- flex-direction: row;
1179
- width: 100%;
1180
- box-sizing: border-box;
1181
- gap: 0;
1182
- padding: 4px 0;
1183
- border-radius: 0;
1184
- border-left: none;
1185
- border-right: none;
1186
- border-bottom: none;
1187
- }
1188
- #mlcad-toolbar .mlcad-tool-btn {
1189
- flex: 1 1 0;
1190
- width: auto;
1191
- min-width: 0;
1192
- height: auto;
1193
- min-height: var(--mlcad-toolbar-phone-height);
1194
- border-radius: 0;
1195
- padding: 4px 2px;
1196
- }
1197
- #mlcad-toolbar .mlcad-tool-btn-label,
1198
- #mlcad-zoom-strip .mlcad-tool-btn-label,
1199
- #mlcad-measure-strip .mlcad-tool-btn-label,
1200
- #mlcad-markup-strip .mlcad-tool-btn-label,
1201
- #mlcad-settings-strip .mlcad-tool-btn-label,
1202
- #mlcad-locale-strip .mlcad-tool-btn-label,
1203
- #mlcad-snap-strip .mlcad-tool-btn-label {
1204
- display: block;
1205
- max-width: 100%;
1206
- overflow: hidden;
1207
- text-overflow: ellipsis;
1208
- white-space: nowrap;
1209
- }
1210
- /* Drop sticky :focus / touch :hover chrome after closing a strip. */
1211
- #mlcad-toolbar .mlcad-tool-btn:focus,
1212
- #mlcad-toolbar .mlcad-tool-btn:focus-visible {
1213
- outline: none;
1214
- }
1215
- #mlcad-toolbar .mlcad-tool-btn:focus:not(.active):not(.is-menu-open),
1216
- #mlcad-toolbar .mlcad-tool-btn:focus-visible:not(.active):not(.is-menu-open) {
1217
- background: transparent;
1218
- border-color: transparent;
1219
- }
1220
- @media (hover: none) {
1221
- #mlcad-toolbar .mlcad-tool-btn:hover:not(.active):not(.is-menu-open) {
1222
- background: transparent;
1223
- border-color: transparent;
1224
- }
1225
- }
1226
- .mlcad-tool-btn.has-children::after {
1227
- display: none;
1228
- }
1229
- #mlcad-toolbar-toggle,
1230
- #mlcad-toolbar .mlcad-tool-separator {
1231
- display: none !important;
1232
- }
1233
- /* Float above the bottom bar so the wrap does not occupy an in-flow
1234
- rectangle of page background around the rounded strip. */
1235
- #mlcad-sidebar > #mlcad-snap-strip-wrap,
1236
- #mlcad-sidebar > #mlcad-measure-strip-wrap,
1237
- #mlcad-sidebar > #mlcad-markup-strip-wrap,
1238
- #mlcad-sidebar > #mlcad-zoom-strip-wrap,
1239
- #mlcad-sidebar > #mlcad-settings-strip-wrap,
1240
- #mlcad-sidebar > #mlcad-locale-strip-wrap {
1241
- position: absolute;
1242
- left: 0;
1243
- right: 0;
1244
- bottom: 100%;
1245
- width: auto;
1246
- flex-direction: column;
1247
- align-items: stretch;
1248
- background: none;
1249
- box-shadow: none;
1250
- backdrop-filter: none;
1251
- overflow: visible;
1252
- pointer-events: none;
1253
- z-index: calc(var(--mlcad-z-chrome) + 1);
1254
- }
1255
- #mlcad-settings-strip-wrap:not([hidden]) {
1256
- display: flex !important;
1257
- }
1258
- #mlcad-snap-strip,
1259
- #mlcad-measure-strip,
1260
- #mlcad-markup-strip,
1261
- #mlcad-zoom-strip,
1262
- #mlcad-settings-strip,
1263
- #mlcad-locale-strip {
1264
- display: grid;
1265
- /* Fallback before wrap-pack JS: auto-fit stretches a short strip evenly.
1266
- JS then sets an explicit column count so wrapped last rows stay narrow. */
1267
- grid-template-columns: repeat(
1268
- auto-fit,
1269
- minmax(var(--mlcad-toolbar-phone-btn-size), 1fr)
1270
- );
1271
- justify-content: start;
1272
- align-content: flex-start;
1273
- width: auto;
1274
- box-sizing: border-box;
1275
- gap: 0;
1276
- margin: 4px 8px 8px;
1277
- padding: 4px 0;
1278
- border-radius: 8px;
1279
- /* Match active toolbar button outline. */
1280
- border: 1px solid var(--mlcad-tool-btn-active-border);
1281
- box-shadow: none;
1282
- backdrop-filter: none;
1283
- overflow: hidden;
1284
- isolation: isolate;
1285
- clip-path: inset(0 round 8px);
1286
- pointer-events: auto;
1287
- }
1288
- #mlcad-snap-strip .mlcad-tool-btn,
1289
- #mlcad-measure-strip .mlcad-tool-btn,
1290
- #mlcad-markup-strip .mlcad-tool-btn,
1291
- #mlcad-zoom-strip .mlcad-tool-btn,
1292
- #mlcad-settings-strip .mlcad-tool-btn,
1293
- #mlcad-locale-strip .mlcad-tool-btn {
1294
- width: 100%;
1295
- min-width: 0;
1296
- height: auto;
1297
- min-height: var(--mlcad-toolbar-phone-height);
1298
- border-radius: 0;
1299
- padding: 4px 2px;
1300
- box-sizing: border-box;
1301
- }
1302
- #mlcad-measure-strip .mlcad-tool-separator,
1303
- #mlcad-markup-strip .mlcad-tool-separator {
1304
- display: none;
1305
- }
1306
- #mlcad-polar-angles {
1307
- flex-direction: row;
1308
- flex-wrap: wrap;
1309
- max-width: none;
1310
- width: 100%;
1311
- box-sizing: border-box;
1312
- border-radius: 0;
1313
- pointer-events: auto;
1314
- }
1315
- #mlcad-layer-drawer,
1316
- #mlcad-review-drawer,
1317
- #mlcad-measure-drawer {
1318
- position: fixed;
1319
- left: 0;
1320
- right: 0;
1321
- bottom: var(--mlcad-phone-drawer-bottom, var(--mlcad-toolbar-phone-height));
1322
- top: auto;
1323
- margin: 0;
1324
- width: 100%;
1325
- max-width: none;
1326
- height: min(42vh, calc(100vh - var(--mlcad-phone-drawer-bottom, var(--mlcad-toolbar-phone-height)) - 12px));
1327
- max-height: calc(100vh - var(--mlcad-phone-drawer-bottom, var(--mlcad-toolbar-phone-height)) - 12px);
1328
- z-index: calc(var(--mlcad-z-chrome) + 1);
1329
- border-radius: 12px 12px 0 0;
1330
- pointer-events: auto;
1331
- }
1332
- #mlcad-layer-drawer .mlcad-drawer-sheet-chrome,
1333
- #mlcad-review-drawer .mlcad-drawer-sheet-chrome,
1334
- #mlcad-measure-drawer .mlcad-drawer-sheet-chrome {
1335
- display: flex;
1336
- align-items: center;
1337
- flex: 0 0 auto;
1338
- min-height: 28px;
1339
- }
1340
- #mlcad-layer-drawer .mlcad-drawer-header,
1341
- #mlcad-review-drawer .mlcad-drawer-header,
1342
- #mlcad-measure-drawer .mlcad-drawer-header {
1343
- display: none;
1344
- }
1345
- .mlcad-layer-action-btn {
1346
- min-height: 28px;
1347
- padding: 3px 6px;
1348
- font-size: 11px;
1349
- gap: 4px;
1350
- }
1351
- .mlcad-layer-action-btn svg { width: 12px; height: 12px; }
1352
- .mlcad-layer-zoom {
1353
- width: 20px;
1354
- height: 20px;
1355
- }
1356
- .mlcad-layer-zoom svg {
1357
- width: 12px;
1358
- height: 12px;
1359
- }
1360
- #mlcad-top-chrome {
1361
- left: 8px;
1362
- right: 8px;
1363
- top: 8px;
1364
- }
1365
-
1366
- }
1367
-
1368
- /* Pad / coarse pointer: same toolbar as desktop, minus select and pan. */
1369
- @media (max-width: ${So}px), (pointer: coarse) {
1370
- #mlcad-toolbar [data-action="select"],
1371
- #mlcad-toolbar [data-action="pan"] {
1372
- display: none !important;
1373
- }
1374
- }
1375
-
1376
- /*
1377
- * Hide toolbar chrome during measure / markup without changing canvas size.
1378
- * On phone the sidebar is in the flex column; display:none would expand
1379
- * #mlcad-canvas-host and shift the drawing. Session panel floats on top.
1380
- */
1381
- #mlcad-root.mlcad-session-active #mlcad-sidebar {
1382
- visibility: hidden !important;
1383
- pointer-events: none !important;
1384
- }
1385
- `;function ke(t,e="measure",a=!0){const r=e==="measure"?`${zo()}${Lo()}${Po()}`:"";return`
1386
- <div id="mlcad-loading" aria-hidden="true" style="background:${t}">
1387
- <div class="mlcad-loading-spinner"></div>
1388
- <div id="mlcad-access-gate" hidden>
1389
- <form id="mlcad-access-form" class="mlcad-access-card">
1390
- <h2 class="mlcad-access-title" data-i18n-key="access.title" data-i18n-text>Protected drawing</h2>
1391
- <p class="mlcad-access-hint" data-i18n-key="access.passwordPrompt" data-i18n-text>Enter the password to open this file.</p>
1392
- <p id="mlcad-access-expiry" class="mlcad-access-expiry" hidden></p>
1393
- <div class="mlcad-access-field">
1394
- <input
1395
- id="mlcad-access-password"
1396
- type="password"
1397
- autocomplete="off"
1398
- data-i18n-key="access.passwordPlaceholder"
1399
- data-i18n-attr="placeholder aria-label"
1400
- placeholder="Password"
1401
- aria-label="Password"
1402
- />
1403
- </div>
1404
- <button type="submit" class="mlcad-access-submit" data-i18n-key="access.unlock" data-i18n-text>Unlock</button>
1405
- <p id="mlcad-access-error" class="mlcad-access-error" hidden></p>
1406
- </form>
1407
- </div>
1408
- </div>
1409
- <div id="mlcad-root">
1410
- <div id="mlcad-canvas-host">
1411
- <div id="mlcad-top-chrome">
1412
- <footer id="mlcad-status-bar" aria-live="polite" hidden></footer>
1413
- </div>
1414
- </div>
1415
- <aside id="mlcad-sidebar">
1416
- <nav id="mlcad-toolbar" data-i18n-attr="aria-label" data-i18n-key="toolbar.viewerTools" aria-label="Viewer tools"></nav>
1417
- ${r}
1418
- <div id="mlcad-layer-drawer" role="dialog" data-i18n-attr="aria-label" data-i18n-key="layers.title" aria-label="Layers" hidden>
1419
- ${Ae("mlcad-layer-sheet-close","layers.close","Close layers")}
1420
- <div class="mlcad-drawer-header">
1421
- <span data-i18n-key="layers.title" data-i18n-text>Layers</span>
1422
- <button type="button" class="mlcad-drawer-close" id="mlcad-layer-close" data-i18n-key="layers.close" data-i18n-attr="aria-label" aria-label="Close layers">×</button>
1423
- </div>
1424
- <div class="mlcad-layer-actions">
1425
- <button type="button" class="mlcad-layer-action-btn" id="mlcad-layer-show-all">
1426
- ${ne.layerOn}<span data-i18n-key="layers.showAll" data-i18n-text>Show all</span>
1427
- </button>
1428
- <button type="button" class="mlcad-layer-action-btn" id="mlcad-layer-hide-all">
1429
- ${ne.layerOff}<span data-i18n-key="layers.hideAll" data-i18n-text>Hide all</span>
1430
- </button>
1431
- </div>
1432
- <div id="mlcad-layer-list"></div>
1433
- </div>
1434
- </aside>
1435
- </div>
1436
- `}function Ae(t,e,a){return`<div class="mlcad-drawer-sheet-chrome">
1437
- <div class="mlcad-drawer-grabber" role="separator" aria-orientation="horizontal"></div>
1438
- <button type="button" class="mlcad-drawer-sheet-close" id="${t}" data-i18n-key="${e}" data-i18n-attr="aria-label" aria-label="${a}">${ne.chevronDown}</button>
1439
- </div>`}function Po(){return`<div id="mlcad-review-drawer" role="dialog" data-i18n-attr="aria-label" data-i18n-key="review.title" aria-label="Review" hidden>
1440
- ${Ae("mlcad-review-sheet-close","review.close","Close review")}
1441
- <div class="mlcad-drawer-header">
1442
- <span data-i18n-key="review.title" data-i18n-text>Review</span>
1443
- <button type="button" class="mlcad-drawer-close" id="mlcad-review-close" data-i18n-key="review.close" data-i18n-attr="aria-label" aria-label="Close review">×</button>
1444
- </div>
1445
- <div class="mlcad-review-toolbar">
1446
- <input type="search" class="mlcad-review-search" data-i18n-key="review.searchPlaceholder" data-i18n-attr="placeholder" placeholder="Search markups" />
1447
- <button type="button" class="mlcad-review-clear" data-i18n-key="review.clear" data-i18n-text>Clear all</button>
1448
- </div>
1449
- <div class="mlcad-review-table-wrap">
1450
- <table class="mlcad-review-table">
1451
- <thead>
1452
- <tr>
1453
- <th data-review-col="type" data-i18n-key="review.type" data-i18n-text>Type</th>
1454
- <th data-review-col="status" data-i18n-key="review.status" data-i18n-text>Status</th>
1455
- <th data-review-col="author" data-i18n-key="review.author" data-i18n-text>Author</th>
1456
- <th data-review-col="summary" data-i18n-key="review.summary" data-i18n-text>Summary</th>
1457
- </tr>
1458
- </thead>
1459
- <tbody></tbody>
1460
- </table>
1461
- </div>
1462
- <div class="mlcad-review-detail" hidden>
1463
- <div class="mlcad-review-detail-header">
1464
- <div class="mlcad-review-detail-title" data-i18n-key="review.details" data-i18n-text>Details</div>
1465
- <button type="button" class="mlcad-review-detail-close" data-i18n-key="review.closeDetails" data-i18n-attr="title aria-label" title="Close details" aria-label="Close details">×</button>
1466
- </div>
1467
- <div class="mlcad-review-field">
1468
- <label class="mlcad-review-field-label" data-review-field="status" data-i18n-key="review.status" data-i18n-text>Status</label>
1469
- <select class="mlcad-review-status"></select>
1470
- </div>
1471
- <div class="mlcad-review-field">
1472
- <label class="mlcad-review-field-label" data-review-field="author" data-i18n-key="review.author" data-i18n-text>Author</label>
1473
- <input type="text" class="mlcad-review-author" disabled />
1474
- </div>
1475
- <div class="mlcad-review-field">
1476
- <label class="mlcad-review-field-label" data-review-field="label" data-i18n-key="review.label" data-i18n-text>Label</label>
1477
- <input type="text" class="mlcad-review-text" />
1478
- </div>
1479
- <div class="mlcad-review-field">
1480
- <label class="mlcad-review-field-label" data-review-field="comment" data-i18n-key="review.comment" data-i18n-text>Comment</label>
1481
- <textarea class="mlcad-review-comment" rows="2"></textarea>
1482
- </div>
1483
- <div class="mlcad-review-detail-actions">
1484
- <button type="button" class="mlcad-review-zoom" data-i18n-key="review.zoomTo" data-i18n-text>Zoom to</button>
1485
- <button type="button" class="mlcad-review-delete" data-i18n-key="review.delete" data-i18n-text>Delete</button>
1486
- </div>
1487
- </div>
1488
- </div>`}function Lo(){return`<div id="mlcad-measure-drawer" role="dialog" data-i18n-attr="aria-label" data-i18n-key="measurePanel.title" aria-label="Measurements" hidden>
1489
- ${Ae("mlcad-measure-sheet-close","measurePanel.close","Close measurements")}
1490
- <div class="mlcad-drawer-header">
1491
- <span data-i18n-key="measurePanel.title" data-i18n-text>Measurements</span>
1492
- <button type="button" class="mlcad-drawer-close" id="mlcad-measure-close" data-i18n-key="measurePanel.close" data-i18n-attr="aria-label" aria-label="Close measurements">×</button>
1493
- </div>
1494
- <div class="mlcad-measure-toolbar">
1495
- <div class="mlcad-measure-filter" role="group" data-i18n-key="measurePanel.filterGroup" data-i18n-attr="aria-label" aria-label="Filter by type">
1496
- <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="distance" aria-pressed="false" data-i18n-key="measurePanel.filterDistance" data-i18n-text data-i18n-attr="title aria-label" title="Distance">Distance</button>
1497
- <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="arc" aria-pressed="false" data-i18n-key="measurePanel.filterArc" data-i18n-text data-i18n-attr="title aria-label" title="Arc">Arc</button>
1498
- <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="radius" aria-pressed="false" data-i18n-key="measurePanel.filterRadius" data-i18n-text data-i18n-attr="title aria-label" title="Radius">Radius</button>
1499
- <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="angle" aria-pressed="false" data-i18n-key="measurePanel.filterAngle" data-i18n-text data-i18n-attr="title aria-label" title="Angle">Angle</button>
1500
- <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="area" aria-pressed="false" data-i18n-key="measurePanel.filterArea" data-i18n-text data-i18n-attr="title aria-label" title="Area">Area</button>
1501
- </div>
1502
- <button type="button" class="mlcad-measure-clear" data-i18n-key="measurePanel.clear" data-i18n-text>Clear all</button>
1503
- </div>
1504
- <div class="mlcad-measure-table-wrap">
1505
- <table class="mlcad-measure-table">
1506
- <thead>
1507
- <tr>
1508
- <th data-measure-col="type" data-i18n-key="measurePanel.type" data-i18n-text>Type</th>
1509
- <th data-measure-col="value" data-i18n-key="measurePanel.value" data-i18n-text>Value</th>
1510
- <th></th>
1511
- </tr>
1512
- </thead>
1513
- <tbody></tbody>
1514
- </table>
1515
- </div>
1516
- </div>`}function Bo(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.encoded??Ha(t),i=e.viewerRuntime,o=ai(),s=n.compression,l=((a=e.accessManifest)==null?void 0:a.encrypted)===!0,c=`#${t.meta.background.toString(16).padStart(6,"0")}`,d=ye(t.meta.locale)??"en",u=t.meta.viewerMode??"measure",m=t.meta.exportLayouts!==!1,p=e.accessManifest?` <script id="mlcad-access" type="application/json">${rr(JSON.stringify(e.accessManifest))}<\/script>
1517
- `:"",h=l?`${o}+aes-gcm;base64`:`${o}+${s};base64`;return`<!DOCTYPE html>
1518
- <html lang="${d}">
1519
- <head>
1520
- <meta charset="utf-8" />
1521
- <meta name="viewport" content="width=device-width, initial-scale=1" />
1522
- <meta name="generator" content="mlightcad-cad-html-plugin" />
1523
- <title>${er(r)}</title>
1524
- <style>${ve}</style>
1525
- </head>
1526
- <body>
1527
- ${ke(c,u,m)}
1528
- ${p} <script id="mlcad-snapshot" type="${h}">${n.payload}<\/script>
1529
- <script>${ar(i)}<\/script>
1530
- </body>
1531
- </html>`}function Io(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.viewerRuntime,i=`#${t.meta.background.toString(16).padStart(6,"0")}`,o=ye(t.meta.locale)??"en",s=t.meta.viewerMode??"measure",l=t.meta.exportLayouts!==!1,c=(a=e.manifestUrl)==null?void 0:a.trim(),d=JSON.stringify(c&&c!==Mo?{manifestUrl:c}:{});return`<!DOCTYPE html>
1532
- <html lang="${o}">
1533
- <head>
1534
- <meta charset="utf-8" />
1535
- <meta name="viewport" content="width=device-width, initial-scale=1" />
1536
- <meta name="generator" content="mlightcad-cad-html-plugin" />
1537
- <title>${er(r)}</title>
1538
- <style>${ve}</style>
1539
- </head>
1540
- <body>
1541
- ${ke(i,s,l)}
1542
- <script id="mlcad-package" type="application/json">${rr(d)}<\/script>
1543
- <script>${ar(n)}<\/script>
1544
- </body>
1545
- </html>`}function er(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ar(t){return t.replace(/<\/script/gi,"<\\/script")}function rr(t){return t.replace(/</g,"\\u003c")}const Uo=1,Eo=1e5,Do=16,No=12;function To(t,e=Date.now(),a){return t==="never"?null:t==="custom"?a??null:e+t*24*60*60*1e3}function nr(t){var e;const a=!!((e=t.password)!=null&&e.trim());return t.expiresAt!=null||a}function Ut(t){var e;if(!nr(t))return;const a=!!((e=t.password)!=null&&e.trim());return{v:Uo,expiresAt:t.expiresAt,encrypted:a,...a&&t.salt?{salt:t.salt}:{}}}async function ir(t,e){const a=crypto.getRandomValues(new Uint8Array(Do));return{key:await _o(t,a),salt:ze(a)}}async function Me(t,e){const a=crypto.getRandomValues(new Uint8Array(No)),r=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,r)),i=new Uint8Array(a.length+n.length);return i.set(a,0),i.set(n,a.length),i}async function Oo(t,e){const{key:a,salt:r}=await ir(t),n=new Uint8Array($o(e)),i=await Me(a,n);return{encryptedPayload:ze(i),salt:r}}function Fe(t){return ze(t)}async function Ro(t,e){var a;if(!nr(e))return{encoded:t};const r=(a=e.password)==null?void 0:a.trim();if(r){const{encryptedPayload:n,salt:i}=await Oo(r,t.payload);return{encoded:{payload:n,compression:t.compression},manifest:Ut({expiresAt:e.expiresAt,password:r,salt:i})}}return{encoded:t,manifest:Ut({expiresAt:e.expiresAt})}}async function _o(t,e){const a=new TextEncoder,r=await crypto.subtle.importKey("raw",a.encode(t),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:new Uint8Array(e),iterations:Eo,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function ze(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function $o(t){const e=atob(t.trim()),a=new Uint8Array(e.length);for(let r=0;r<e.length;r++)a[r]=e.charCodeAt(r);return a}const jo=256;function Ho(t,e=Nt){return!(e>0)||ue(t)<=e?[t]:t.indices&&t.indices.length>=2?Xo(t,e):Yo(t,e)}function Vo(t,e=Nt){return t.texture?[t]:!(e>0)||me(t)<=e?[t]:t.points?Wo(t,e):!t.indices||t.indices.length<3?sr(t,e):Jo(t,e)}function or(t){return t.linePattern?64+t.linePattern.pattern.length*8:0}function Ce(t){return(t.hatchPattern?128:0)+(t.gradientFill?64:0)}function kt(t,e,a){const r=t-jo-e;return r<a?1:Math.max(1,Math.floor(r/a))}function Yo(t,e){var a;const r=(((a=t.lineDistances)==null?void 0:a.length)??0)>=2,n=24+(r?8:0),i=kt(e,or(t),n),o=t.positions.length/6|0;if(o<=1)return[t];const s=[];for(let l=0;l<o;l+=i){const c=Math.min(i,o-l),d=l*6,u={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(d,d+c*6)};if(dr(t,u),r&&t.lineDistances){const m=l*2;u.lineDistances=t.lineDistances.slice(m,m+c*2)}s.push(u)}return s.length>0?s:[t]}function Xo(t,e){var a;const r=t.indices,n=32+((((a=t.lineDistances)==null?void 0:a.length)??0)>0?8:0),i=kt(e,or(t),n),o=[];for(let s=0;s+1<r.length;){const l=Math.min(i*2,r.length-s),c=l-l%2;if(c<2)break;o.push(Go(t,s,c)),s+=c}return o.length>0?o:[t]}function Go(t,e,a){const r=cr(t.positions,t.indices.subarray(e,e+a),t.lineDistances?[t.lineDistances]:[],[1]),n={layer:t.layer,color:t.color,offset:t.offset,positions:r.positions,indices:r.indices};return dr(t,n),r.attributes[0]&&r.attributes[0].length>0&&(n.lineDistances=r.attributes[0]),n}function Wo(t,e){return t.indices&&t.indices.length>0?Ko(t,e):sr(t,e)}function Ko(t,e){const a=t.indices,r=16+(t.uvs?8:0)+(t.gradientPositions?8:0),n=kt(e,Ce(t),r),i=[];for(let o=0;o<a.length;){const s=Math.min(n,a.length-o);if(s<1)break;i.push(lr(t,o,s)),o+=s}return i.length>0?i:[t]}function sr(t,e){const a=t.positions.length/3|0;if(a<=1)return[t];const r=12+(t.uvs?8:0)+(t.gradientPositions?8:0),n=kt(e,Ce(t),r),i=t.points?1:3,o=Math.max(i,n-n%i),s=[];for(let l=0;l<a;l+=o){const c=Math.min(o,a-l),d=c-c%i;if(d<i)break;s.push(Zo(t,l,d))}return s.length>0?s:[t]}function Jo(t,e){const a=t.indices,r=48+(t.uvs?24:0)+(t.gradientPositions?24:0),n=kt(e,Ce(t),r),i=[];for(let o=0;o+2<a.length;){const s=Math.min(n*3,a.length-o),l=s-s%3;if(l<3)break;i.push(lr(t,o,l)),o+=l}return i.length>0?i:[t]}function Zo(t,e,a){const r=e*3,n={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(r,r+a*3)};return ur(t,n),t.uvs&&(n.uvs=t.uvs.slice(e*2,(e+a)*2)),t.gradientPositions&&(n.gradientPositions=t.gradientPositions.slice(e*2,(e+a)*2)),n}function lr(t,e,a){const r=[],n=[];t.uvs&&(r.push(t.uvs),n.push(2)),t.gradientPositions&&(r.push(t.gradientPositions),n.push(2));const i=cr(t.positions,t.indices.subarray(e,e+a),r,n),o={layer:t.layer,color:t.color,offset:t.offset,positions:i.positions,indices:i.indices};ur(t,o);let s=0;return t.uvs&&(o.uvs=i.attributes[s++]),t.gradientPositions&&(o.gradientPositions=i.attributes[s]),o}function cr(t,e,a,r){const n=new Map,i=[],o=new Uint32Array(e.length),s=a.map(()=>[]);for(let l=0;l<e.length;l++){const c=e[l];let d=n.get(c);if(d==null){d=n.size,n.set(c,d);const u=c*3;i.push(t[u]??0,t[u+1]??0,t[u+2]??0);for(let m=0;m<a.length;m++){const p=r[m],h=a[m],g=c*p;for(let b=0;b<p;b++)s[m].push(h[g+b]??0)}}o[l]=d}return{positions:Float32Array.from(i),indices:o,attributes:s.map(l=>Float32Array.from(l))}}function dr(t,e){t.linePattern&&(e.linePattern=t.linePattern),t.lineWidth!=null&&(e.lineWidth=t.lineWidth),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.excludeFromOsnap&&(e.excludeFromOsnap=!0)}function ur(t,e){t.hatchPattern&&(e.hatchPattern=t.hatchPattern),t.gradientFill&&(e.gradientFill=t.gradientFill),t.side!=null&&(e.side=t.side),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.points&&(e.points=!0)}function qo(t,e,a=Nt){const r=[];let n={lineBatches:[],meshBatches:[],estimatedBytes:64};const i=()=>{n.lineBatches.length===0&&n.meshBatches.length===0&&r.length>0||(r.push(n),n={lineBatches:[],meshBatches:[],estimatedBytes:64})},o=c=>{const d=ue(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.lineBatches.push(c),n.estimatedBytes+=d},s=c=>{const d=me(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.meshBatches.push(c),n.estimatedBytes+=d},l=Math.min(e,a);for(const c of t.lineBatches)for(const d of Ho(c,l))o(d);for(const c of t.meshBatches)for(const d of Vo(c,l))s(d);return(r.length===0||n.lineBatches.length>0||n.meshBatches.length>0)&&i(),r.length===0&&r.push({lineBatches:[],meshBatches:[],estimatedBytes:64}),r}function Qo(t,e){if(t.version!==Y)throw new Error(`Unsupported snapshot version: ${t.version}`);const a=e.maxChunkBytes??yo,r=e.maxBatchBytes??Nt,n=e.maxOsnapChunkBytes??vo,i=Tt,o=as(t.layouts,t.activeLayoutBtrId),s=[],l=[],c=new Map;return o.forEach((d,u)=>{var m;c.set(d.btrId,u);const p=qo(d,a,r),h=[];p.forEach((f,w)=>{const k=`L${u}-${String(w).padStart(3,"0")}`,y=`chunks/${k}.acex.gz`;h.push(k),s.push({kind:"geometry",id:k,href:y,layoutBtrId:d.btrId,lineBatchCount:f.lineBatches.length,meshBatchCount:f.meshBatches.length,chunk:{version:Y,layoutBtrId:d.btrId,lineBatches:f.lineBatches,meshBatches:f.meshBatches}})});const g={btrId:d.btrId,name:d.name,isModelSpace:d.isModelSpace,viewports:d.viewports,...d.savedView?{savedView:d.savedView}:{},chunkIds:h},b=(m=d.osnap)==null?void 0:m.primitives;if(b&&b.length>0){const f=Gn(b,n),w=[];f.forEach((k,y)=>{const z=`L${u}-osnap-${String(y).padStart(3,"0")}`,L=`chunks/${z}.osnap.gz`;w.push(z),s.push({kind:"osnap",id:z,href:L,layoutBtrId:d.btrId,primitiveCount:k.length,primitives:k})}),g.osnapChunkIds=w}l.push(g)}),{jobs:s,layoutRefs:l,layoutIndexByBtrId:c,manifestFileName:i}}function ts(t,e,a,r,n){var i,o;const s=[],l=[],c=[];for(const f of n){const{job:w,uncompressed:k,compressed:y}=f;c.push({path:w.href,bytes:y}),w.kind==="geometry"?s.push({id:w.id,href:w.href,layoutBtrId:w.layoutBtrId,byteLength:k.byteLength,compressedByteLength:y.byteLength,lineBatchCount:w.lineBatchCount,meshBatchCount:w.meshBatchCount}):l.push({id:w.id,href:w.href,layoutBtrId:w.layoutBtrId,byteLength:k.byteLength,compressedByteLength:y.byteLength,primitiveCount:w.primitiveCount})}const d=t.layouts.map(f=>{const w=a.get(f.btrId);return e[w]}),u=new Set(((i=d.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:i.chunkIds)??[]),m=[...s.filter(f=>u.has(f.id)),...s.filter(f=>!u.has(f.id))],p=new Set(((o=d.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:o.osnapChunkIds)??[]),h=[...l.filter(f=>p.has(f.id)),...l.filter(f=>!p.has(f.id))],g={format:"acex-package",packageVersion:xo,snapshotVersion:Y,meta:t.meta,layers:t.layers,activeLayoutBtrId:t.activeLayoutBtrId,layouts:d,chunks:m,...h.length>0?{osnapChunks:h}:{}},b=`${JSON.stringify(g)}
1546
- `;return c.unshift({path:r,bytes:xt(b)}),{manifest:g,manifestFileName:r,files:c}}async function mr(t,e={}){const{jobs:a,layoutRefs:r,layoutIndexByBtrId:n,manifestFileName:i}=Qo(t,e),o=await Promise.all(a.map(async s=>{if(s.kind==="geometry"){const{uncompressed:d,compressed:u}=await wo(s.chunk);return{job:s,uncompressed:d,compressed:u}}const{uncompressed:l,compressed:c}=await Wn({primitives:s.primitives});return{job:s,uncompressed:l,compressed:c}}));return ts(t,r,n,i,o)}async function es(t,e){const a=await mr(t,e),r=Io(t,{title:t.meta.title,viewerRuntime:e.viewerRuntime,...e.manifestUrl?{manifestUrl:e.manifestUrl}:{}});return{html:r,manifest:a.manifest,manifestFileName:a.manifestFileName,files:[{path:"viewer.html",bytes:xt(r)},...a.files]}}function as(t,e){const a=t.find(n=>n.btrId===e),r=t.filter(n=>n.btrId!==e);return a?[a,...r]:[...t]}const rs="application/vnd.mlightcad.acex-chunk;base64",ns="application/vnd.mlightcad.acex-chunk+aes-gcm;base64",pr="data-acex-href";function is(t){var e;let a=0;for(const r of t.layouts){for(const i of r.lineBatches)a+=ue(i);for(const i of r.meshBatches)a+=me(i);const n=(e=r.osnap)==null?void 0:e.primitives;if(n)for(const i of n)a+=$a(i)}return a}function os(t,e=ko){return is(t)>=e}async function ss(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.viewerRuntime,i=`#${t.meta.background.toString(16).padStart(6,"0")}`,o=ye(t.meta.locale)??"en",s=t.meta.viewerMode??"measure",l=t.meta.exportLayouts!==!1,c=e.expiresAt??null,d=((a=e.password)==null?void 0:a.trim())||void 0,u={maxChunkBytes:e.maxChunkBytes??pa,maxBatchBytes:e.maxBatchBytes??e.maxChunkBytes??pa,maxOsnapChunkBytes:e.maxOsnapChunkBytes??Ao},m=await mr(t,u);let p,h,g;if(d){const{key:f,salt:w}=await ir(d);p=Ut({expiresAt:c,password:d,salt:w});const k=new TextEncoder().encode(`${JSON.stringify(m.manifest)}
1547
- `),y=await Me(f,k);h={mode:"embedded",encrypted:!0,encryptedManifest:Fe(y)},g=await cs(m.files,f)}else p=Ut({expiresAt:c}),h={mode:"embedded",manifest:m.manifest},g=ls(m.files);const b=p?` <script id="mlcad-access" type="application/json">${ha(JSON.stringify(p))}<\/script>
1548
- `:"";return`<!DOCTYPE html>
1549
- <html lang="${o}">
1550
- <head>
1551
- <meta charset="utf-8" />
1552
- <meta name="viewport" content="width=device-width, initial-scale=1" />
1553
- <meta name="generator" content="mlightcad-cad-html-plugin" />
1554
- <title>${hr(r)}</title>
1555
- <style>${ve}</style>
1556
- </head>
1557
- <body>
1558
- ${ke(i,s,l)}
1559
- ${b} <script id="mlcad-package" type="application/json">${ha(JSON.stringify(h))}<\/script>
1560
- ${g} <script>${ds(n)}<\/script>
1561
- </body>
1562
- </html>`}function ls(t){const e=[];for(const a of t)a.path!==Tt&&e.push(` <script type="${rs}" ${pr}="${fr(a.path)}">${Fe(a.bytes)}<\/script>
1563
- `);return e.join("")}async function cs(t,e){const a=[];for(const r of t){if(r.path===Tt)continue;const n=await Me(e,r.bytes);a.push(` <script type="${ns}" ${pr}="${fr(r.path)}">${Fe(n)}<\/script>
1564
- `)}return a.join("")}function hr(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function fr(t){return hr(t).replace(/'/g,"&#39;")}function ds(t){return t.replace(/<\/script/gi,"<\\/script")}function ha(t){return t.replace(/</g,"\\u003c")}function us(t){return!t||t.startsWith("/")||t.includes("\\")||t.includes("\0")?!1:t.split("/").every(e=>e.length>0&&e!=="."&&e!==".."&&/^[A-Za-z0-9._-]+$/.test(e))}function ms(t){return t.endsWith(".gz")}function ps(t){const e={};for(const a of t.files){if(!us(a.path))throw new Error(`Unsafe package path: ${a.path}`);ms(a.path)?e[a.path]=[a.bytes,{level:0}]:e[a.path]=[a.bytes,{level:6}]}return Dn(e)}const hs=400;function q(t={}){var e;const a=t.exportFormat==="multi"?"multi":"single";return{exportFormat:a,exportInvisibleLayers:t.exportInvisibleLayers!==!1,exportLayouts:t.exportLayouts!==!1,initialView:t.initialView??"fit",viewerMode:t.viewerMode??"measure",expiryDays:a==="multi"?"never":t.expiryDays??"never",expiresAt:a==="multi"?null:t.expiresAt??null,password:a==="multi"?"":((e=t.password)==null?void 0:e.trim())??""}}function fs(t){const e=t.activeLayoutView,a=e.center,r=e.trCamera.zoom,n=Math.max(e.height,1),i=r*(2*hs)/n;return{centerX:a.x,centerY:a.y,zoom:i}}const gs="./viewer-runtime.iife.js";let vt={};function bs(t){vt={...vt,...t}}function ws(){return{...vt}}function xs(t){return t!=null?String(t):vt.viewerRuntimeUrl!=null?String(vt.viewerRuntimeUrl):gs}const gr="https://mlightcad.com/cad-viewer/docs/";let br=wr(gr);function ys(){return br}function vs(t){br=wr(t)}function wr(t){const e=t.trim();return e?e.replace(/\/+$/,""):gr.replace(/\/+$/,"")}function ks(){return{minX:0,minY:0,maxX:0,maxY:0,valid:!1}}function As(t,e,a){if(e.length<3)return;const r=a[0],n=a[1];for(let i=0;i+2<e.length;i+=3){const o=Qe(e[i],r),s=Qe(e[i+1],n);t.valid?(o<t.minX&&(t.minX=o),o>t.maxX&&(t.maxX=o),s<t.minY&&(t.minY=s),s>t.maxY&&(t.maxY=s)):(t.minX=t.maxX=o,t.minY=t.maxY=s,t.valid=!0)}}function fa(t,e){As(t,e.positions,e.offset)}function Ms(t){return t.valid?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null}function Fs(t,e){const a=ks();for(const r of t)fa(a,r);for(const r of e)fa(a,r);return Ms(a)}function xr(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e??null}function zs(t){if(!t||t.length===0)return null;let e=null;for(const a of t)e=xr(e,a.paper);return e}function Cs(t){return xr(Fs(t.lineBatches,t.meshBatches),zs(t.viewports))}function Ss(t,e,a){if(a)return;const r=Ls(t,e);if(!(r!=null&&r.newIterator))return;const n=[];for(const i of r.newIterator()){if(!(i instanceof Lr)||Br.isDefaultPaperSpaceViewport(i)||typeof i.toGiViewport!="function")continue;const o=i.toGiViewport(),s=o.box,l=o.viewBox,c=ga(s),d=ga(l);if(!c||!d)continue;const u=Number.isFinite(o.viewTwistAngle)?o.viewTwistAngle:i.viewTwistAngle,m=Ps(o,i),p={paper:c,model:d};Number.isFinite(u)&&Math.abs(u)>1e-12&&(p.twist=u),m.length>0&&(p.frozenLayers=m),n.push(p)}return n.length>0?n:void 0}function Ps(t,e){var a;const r=t.frozenLayers;if(r&&r.length>0)return[...r];const n=e.frozenLayerIds;if(!(n!=null&&n.length))return[];const i=(a=e.database)==null?void 0:a.tables.layerTable;if(!i)return[];const o=[];for(const s of n){const l=i.getIdAt(s);l&&o.push(l.name)}return o}function ga(t){if(typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}function Ls(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(!r)return;const n=typeof r.getIdAt=="function"?r.getIdAt(e):void 0;if(n)return n;if(typeof r.newIterator=="function"){for(const o of r.newIterator())if(o.objectId===e)return o}const i=r.modelSpace;if((i==null?void 0:i.objectId)===e)return i}const ba=16/9;function Bs(t,e,a,r=ba){var n,i,o,s;const l=Number.isFinite(r)&&r>0?r:ba;if(a){const d=(o=(i=(n=t.tables)==null?void 0:n.viewportTable)==null?void 0:i.getActiveVportBox)==null?void 0:o.call(i,l);return wa(d)}const c=(s=t.objects)==null?void 0:s.layout;if(c!=null&&c.newIterator){for(const d of c.newIterator())if(d.blockTableRecordId===e)return wa(d.limits)}}function wa(t){if(!t||typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}class Is{build(e,a,r={}){return this.buildSync(e,a,r)}async buildAsync(e,a,r={}){await $();const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>zt(e,p,n),s=la(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{zt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=ya(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=ka(e,i),m=[];for(const p of va(e,c,i))m.push(Aa(e,a,p,d,r,o)),await $();return{version:Y,meta:xa(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}buildSync(e,a,r){const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>zt(e,p,n),s=la(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{zt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=ya(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=ka(e,i),m=[];for(const p of va(e,c,i))m.push(Aa(e,a,p,d,r,o));return{version:Y,meta:xa(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}}function xa(t,e,a,r){const n=a.find(s=>s.btrId===r)??a[0],i=n?Cs(n):null,o=e.initialView??"fit";return{title:t.title,createdAt:new Date().toISOString(),extents:t.extents,viewExtents:i??void 0,units:t.units,grip:t.grip,background:t.background,locale:e.locale??A.currentLocale,initialView:o,viewState:o==="current"?e.viewState:void 0,viewerMode:e.viewerMode??"measure",exportLayouts:e.exportLayouts!==!1,docsBaseUrl:Us()}}function Us(){try{vs(Ir())}catch{}return ys()}function Es(t){return(t.viewerMode??"measure")==="measure"}function zt(t,e,a){if(a)return!0;const r=t.layers.get(e);return r?!r.isOff&&!r.isFrozen:!0}function ya(t){var e;const a=(e=t.objects)==null?void 0:e.layout;if(!(a!=null&&a.newIterator))return[];const r=[];for(const n of a.newIterator()){const i=n.blockTableRecordId;i&&r.push({name:n.layoutName||i,tabOrder:n.tabOrder??0,blockTableRecordId:i})}return r.sort((n,i)=>n.tabOrder-i.tabOrder),r}function va(t,e,a){if(!a)return t.modelSpaceBtrId?[t.modelSpaceBtrId]:[];const r=new Set,n=[];for(const i of e)r.has(i.blockTableRecordId)||(r.add(i.blockTableRecordId),n.push(i.blockTableRecordId));for(const i of t.layouts.keys())r.has(i)||(r.add(i),n.push(i));return n}function ka(t,e){return e&&t.activeLayoutBtrId||t.modelSpaceBtrId}function Aa(t,e,a,r,n,i){const o=[],s=[],l=t.layouts.get(a);if(l)for(const[,m]of l.layers){if(i&&!i(m.name))continue;const p=Ei(m.internalObject);o.push(...p.lineBatches),s.push(...p.meshBatches)}const c=a===t.modelSpaceBtrId,d=Bs(e,a,c,n.canvasAspectRatio);let u;if(Es(n)){const m=performance.now();u=po(e,a,{includeLayer:i}),console.log(`[chtml] osnap catalog ${r.get(a)??a}: ${(performance.now()-m).toFixed(0)} ms (${(u==null?void 0:u.primitives.length)??0} primitives)`)}return{btrId:a,name:r.get(a)??Ds(e,a),isModelSpace:c,lineBatches:o,meshBatches:s,osnap:u,viewports:Ss(e,a,c),...d?{savedView:d}:{}}}function Ds(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(r!=null&&r.newIterator){for(const n of r.newIterator())if(n.objectId===e)return n.name}return e}function K(t,e){console.log(`[chtml] ${t}: ${e.toFixed(0)} ms`)}class Ns{constructor(e={}){this.options=e,this._snapshotBuilder=new Is}async prepareAcTrView2dForHtmlExport(e,a={}){if(!e||!("cadScene"in e)||!e.cadScene)throw new Error("CAD scene is not available. Open a drawing before exporting to HTML.");if(!(e instanceof Ar))throw new Error("HTML export requires a 2D CAD view. Open a drawing before exporting.");const r=q(a),n={includeInvisibleLayers:r.exportInvisibleLayers,includeLayouts:r.exportLayouts};return await e.ensureEntitiesConvertedForExport(n),await $(),e}async convert(e,a={},r){const n=st.instance,i=q(a),o=performance.now();await n.withBusyIndicator(async()=>{await $();const s=n.curDocument;let l=performance.now();const c=await this.prepareAcTrView2dForHtmlExport(r??n.curView,i);K("prepare (missing entities)",performance.now()-l);const d=e||s.fileName||s.docTitle,u=Mr(d);l=performance.now();const m=await this._snapshotBuilder.buildAsync(c.cadScene,s.database,{title:u,background:c.backgroundColor,exportInvisibleLayers:i.exportInvisibleLayers,exportLayouts:i.exportLayouts,initialView:i.initialView,viewerMode:i.viewerMode,viewState:i.initialView==="current"&&(i.exportLayouts||c.activeLayoutBtrId===c.modelSpaceBtrId)?fs(c):void 0,canvasAspectRatio:c.width/Math.max(c.height,1)});K("snapshot build",performance.now()-l),await $(),l=performance.now();const p=await this.loadViewerRuntime();if(K("load viewer runtime",performance.now()-l),await $(),i.exportFormat==="multi"){l=performance.now();const b=await es(m,{viewerRuntime:p});K("package + gzip chunks",performance.now()-l),l=performance.now();const f=ps(b);K("zip package",performance.now()-l),await $(),this.downloadBytes(f,Ie(d,"zip"),"application/zip"),K("chtml total",performance.now()-o);return}const h=To(i.expiryDays,Date.now(),i.expiresAt);l=performance.now();const g=await this.packSelfContainedHtml(m,p,{expiresAt:h,password:i.password||void 0});K("pack self-contained html",performance.now()-l),await $(),this.downloadHtml(g,Ie(d,"html")),K("chtml total",performance.now()-o)})}async packSnapshot(e,a){await st.instance.withBusyIndicator(async()=>{await $();const r=await this.loadViewerRuntime();await $();const n=await this.packSelfContainedHtml(e,r,{expiresAt:null});await $(),this.downloadHtml(n,a)})}async packSelfContainedHtml(e,a,r){if(os(e))return ss(e,{title:e.meta.title,viewerRuntime:a,expiresAt:r.expiresAt,password:r.password});const n=await Ro(Ha(e),{expiresAt:r.expiresAt,password:r.password});return Bo(e,{title:e.meta.title,viewerRuntime:a,encoded:n.encoded,accessManifest:n.manifest})}async loadViewerRuntime(){const e=xs(this.options.viewerRuntimeUrl),a=await fetch(e);if(!a.ok)throw new Error(`Failed to load HTML viewer runtime from "${e}" (${a.status}). Install @mlightcad/cad-html-plugin, copy viewer-runtime.iife.js to your app assets, and set viewerRuntimeUrl on registerLazyHtmlPlugin / createHtmlPlugin / AcApHtmlConvertor.`);return a.text()}downloadHtml(e,a){this.downloadBytes(new TextEncoder().encode(e),a,"text/html;charset=utf-8")}downloadBytes(e,a,r){const n=new Uint8Array(e.byteLength);n.set(e);const i=new Blob([n],{type:r}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=a,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}}class Ts extends kr{constructor(e={}){super(),this.pluginOptions=e}async execute(e){const a=await this.promptOptions();a&&await new Ns(this.pluginOptions).convert(e.doc.fileName||e.doc.docTitle,a,e.view)}async promptOptions(){const e=q(),a=await this.promptExportFormat();if(a===void 0)return;const r=await this.promptYesNo("jig.chtml.exportInvisibleLayers",e.exportInvisibleLayers);if(r===void 0)return;const n=await this.promptYesNo("jig.chtml.exportLayouts",e.exportLayouts);if(n===void 0)return;const i=await this.promptInitialView();if(i===void 0)return;const o=await this.promptViewerMode();if(o!==void 0)return q({exportFormat:a,exportInvisibleLayers:r,exportLayouts:n,initialView:i,viewerMode:o})}async promptExportFormat(){const e=q(),a=new At(A.t("jig.chtml.exportFormat"));a.allowNone=!0;const r=a.keywords.add(A.t("jig.chtml.keywords.single.display"),A.t("jig.chtml.keywords.single.global"),A.t("jig.chtml.keywords.single.local")),n=a.keywords.add(A.t("jig.chtml.keywords.multi.display"),A.t("jig.chtml.keywords.multi.global"),A.t("jig.chtml.keywords.multi.local"));a.keywords.default=e.exportFormat==="multi"?n:r;const i=await st.instance.editor.getKeywords(a);if(i.status!==U.Cancel){if(i.status===U.None)return e.exportFormat;if(i.status===U.OK||i.status===U.Keyword)return i.stringResult?i.stringResult==="Multi"?"multi":"single":e.exportFormat}}async promptYesNo(e,a){const r=new At(A.t(e));r.allowNone=!0;const n=r.keywords.add(A.t("jig.chtml.keywords.yes.display"),A.t("jig.chtml.keywords.yes.global"),A.t("jig.chtml.keywords.yes.local")),i=r.keywords.add(A.t("jig.chtml.keywords.no.display"),A.t("jig.chtml.keywords.no.global"),A.t("jig.chtml.keywords.no.local"));r.keywords.default=a?n:i;const o=await st.instance.editor.getKeywords(r);if(o.status!==U.Cancel){if(o.status===U.None)return a;if(o.status===U.OK||o.status===U.Keyword)return o.stringResult?o.stringResult==="Yes":a}}async promptInitialView(){const e=q(),a=new At(A.t("jig.chtml.initialView"));a.allowNone=!0;const r=a.keywords.add(A.t("jig.chtml.keywords.extents.display"),A.t("jig.chtml.keywords.extents.global"),A.t("jig.chtml.keywords.extents.local")),n=a.keywords.add(A.t("jig.chtml.keywords.current.display"),A.t("jig.chtml.keywords.current.global"),A.t("jig.chtml.keywords.current.local"));a.keywords.default=e.initialView==="current"?n:r;const i=await st.instance.editor.getKeywords(a);if(i.status!==U.Cancel){if(i.status===U.None)return e.initialView;if(i.status===U.OK||i.status===U.Keyword)return i.stringResult?i.stringResult==="Current"?"current":"fit":e.initialView}}async promptViewerMode(){const e=q(),a=new At(A.t("jig.chtml.viewerMode"));a.allowNone=!0;const r=a.keywords.add(A.t("jig.chtml.keywords.view.display"),A.t("jig.chtml.keywords.view.global"),A.t("jig.chtml.keywords.view.local")),n=a.keywords.add(A.t("jig.chtml.keywords.measure.display"),A.t("jig.chtml.keywords.measure.global"),A.t("jig.chtml.keywords.measure.local"));a.keywords.default=e.viewerMode==="view"?r:n;const i=await st.instance.editor.getKeywords(a);if(i.status!==U.Cancel){if(i.status===U.None)return e.viewerMode;if(i.status===U.OK||i.status===U.Keyword)return i.stringResult?i.stringResult==="View"?"view":"measure":e.viewerMode}}}const Os="1.7.6-preview.0",Rs={version:Os};class _s{constructor(e={}){this.options=e,this.name="HtmlPlugin",this.version=Rs.version,this.description="HTML export (-chtml) command",this.registeredCommands=[]}onLoad(e,a){const r=vr.SYSTEMT_COMMAND_GROUP_NAME,n=new Ts(this.options);a.addCommand(r,"-chtml","-chtml",n),this.registeredCommands.push({group:r,name:"-chtml"}),a.lookupGlobalCmd("chtml")||(a.addCommand(r,"chtml","chtml",n),this.registeredCommands.push({group:r,name:"chtml"}))}onUnload(e,a){for(const r of this.registeredCommands)a.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function js(t={}){return t.viewerRuntimeUrl!=null&&bs(t),new _s(ws())}export{go as ACEC_CHUNK_MAGIC,On as ACEO_OSNAP_MAGIC,Rn as ACEO_OSNAP_VERSION,yo as ACEX_DEFAULT_CHUNK_MAX_BYTES,Tt as ACEX_DEFAULT_MANIFEST_FILE,Mo as ACEX_DEFAULT_MANIFEST_HREF,vo as ACEX_DEFAULT_OSNAP_CHUNK_MAX_BYTES,ns as ACEX_EMBEDDED_CHUNK_ENCRYPTED_MIME,pr as ACEX_EMBEDDED_CHUNK_HREF_ATTR,pa as ACEX_EMBEDDED_CHUNK_MAX_BYTES,rs as ACEX_EMBEDDED_CHUNK_MIME,ko as ACEX_EMBEDDED_CHUNK_THRESHOLD_BYTES,Ao as ACEX_EMBEDDED_OSNAP_CHUNK_MAX_BYTES,Nt as ACEX_MAX_GEOMETRY_BATCH_BYTES,xo as ACEX_PACKAGE_VERSION,Ta as ACEX_SNAPSHOT_COMPRESSION,Y as ACEX_SNAPSHOT_VERSION,Ts as AcApExportHtmlCmd,Ns as AcApHtmlConvertor,Is as AcApHtmlSnapshotBuilder,gs as DEFAULT_HTML_VIEWER_RUNTIME_URL,Ys as HTML_PLUGIN_NAME,Xs as HTML_PLUGIN_TRIGGERS,Fe as acExHtmlBytesToBase64,Ut as buildAcExHtmlAccessManifest,es as buildAcExPackageAsync,mr as buildAcExPackageDataAsync,po as buildOsnapCatalog,la as buildViewerMetadata,fs as captureAcApHtmlViewState,Ei as collectBatchesFromObject3D,Zt as compressSnapshotBinary,Oa as compressSnapshotBinaryAsync,bs as configureHtmlPlugin,ir as createAcExHtmlAccessKey,js as createHtmlPlugin,bo as encodeChunkBinary,ja as encodeOsnapCatalogBinary,Ha as encodeSnapshot,Zn as encodeSnapshotBinary,Me as encryptAcExHtmlBytes,Oo as encryptAcExHtmlSnapshotPayload,is as estimateAcExSnapshotGeometryBytes,$a as estimateOsnapPrimitiveBytes,xi as exportActiveBatchedLine2Slice,we as exportActiveBatchedSlice,St as exportBufferGeometrySlice,ws as getHtmlPluginOptions,ya as listDatabaseLayouts,nr as needsAcExHtmlAccessControl,Bo as packHtml,ss as packHtmlEmbeddedPackage,Io as packHtmlPackage,Ro as protectAcExHtmlEncodedSnapshot,To as resolveAcApHtmlExpiresAt,q as resolveAcApHtmlExportOptions,ye as resolveAcExHtmlLocale,xs as resolveViewerRuntimeUrl,os as shouldEmbedAcExChunks,ai as snapshotMimeType,qo as splitLayoutIntoSlices,Gn as splitOsnapPrimitives,ps as zipAcExPackageFiles};