markuno_lib 1.2.31 → 1.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/markcad.js CHANGED
@@ -506,13 +506,13 @@ ClipperLib.ExPolygon=function(){this.outer=null,this.holes=null},ClipperLib.JS.A
506
506
  */
507
507
  function alignByMinDist(sag1,sag2,isopen){const n1=sag1.length,n2=sag2.length;if(n1<1||n2<1)return sag2.slice();let bestOffset=0,minSum=1/0;for(let k=0;k<n2;k++){const p0=sag1[0],q0=sag2[k%n2],dx0=p0.x-q0.x,dy0=p0.y-q0.y,p1=sag1[n1-1],q1=sag2[isopen?Math.min(k+n1-1,n2-1):(k+n1-1)%n2],dx1=p1.x-q1.x,dy1=p1.y-q1.y,sum=dx0*dx0+dy0*dy0+dx1*dx1+dy1*dy1;sum<minSum&&(minSum=sum,bestOffset=k)}return[...sag2.slice(bestOffset),...sag2.slice(0,bestOffset)]}function shapeclip(){function toclipformat(pts){let tm=pts.map((e=>({X:Math.round(1e4*e.x),Y:Math.round(1e4*e.y)})));return ensureOrientation(tm)}function fromclipformat(pts){return pts.map((e=>({x:e.X/1e4,y:e.Y/1e4})))}const ensureOrientation=poly=>ClipperLib.Clipper.Orientation(poly)?poly:poly.slice().reverse();function orientation(pt){if(!pt.length)return 0;let area=0;const n=pt.length;for(let i=0;i<n;i++){const current=pt[i],next=pt[(i+1)%n];area+=current.X*next.Y-next.X*current.Y}return area>0?1:area<0?-1:0}const _inflate=(pt,delta,cut=!1)=>{const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.AddPath(pt,ClipperLib.JoinType.jtMiter,cut||2==pt.length?ClipperLib.EndType.etOpenButt:ClipperLib.EndType.etClosedPolygon);const solution=new ClipperLib.Paths;return co.Execute(solution,delta),solution};function _inflateopen(pts,delta){const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.ArcTolerance=.25;const DD=1e4*delta,pshape=toclipformat(pts);co.AddPath(pshape,ClipperLib.JoinType.jtMiter,ClipperLib.EndType.etClosedPolygon);const solution=new ClipperLib.Paths;co.Execute(solution,DD);let tm=fromclipformat(solution[0]);return getshape().frompt(tm)}return{offset(shape,delta,full=!1){const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.ArcTolerance=.25;const DD=1e4*Math.abs(delta),pshape=toclipformat(shape.pt);co.AddPath(pshape,ClipperLib.JoinType.jtMiter,ClipperLib.EndType.etOpenButt);const solution=new ClipperLib.Paths;co.Execute(solution,DD);let tm=fromclipformat(solution[0]);return full?getshape().frompt(tm):getshape().frompt(getptsoffset(shape.pt,tm,delta))},inflate:function inflate(shape,delta=2,mantainorder=!1,isopen=0){let pshape=toclipformat(shape.pt),tm=_inflate(pshape,1e4*delta);if(!tm||!tm.length)return getshape().frompt([]);let p2=getshape().frompt(fromclipformat(tm[0]));if(mantainorder){p2.orient!=shape.orient&&p2.reverse();let p3=alignByMinDist(shape.pt,p2.pt,isopen);if(p2.frompt(p3),isopen>0&&shape.pt.length>=3){function estendi1(sh1,sh2){let l1=sh1.segment(0).ruotata(-Math.PI/2,200,!0),l2=sh1.segment(-2).ruotata(-Math.PI/2,200),q2=sh2.segment(-2).interseca(l2),q1=sh2.segment(0).interseca(l1);q1&&(sh2.pt[0]=q1),q2&&(sh2.pt[sh2.pt.length-1]=q2)}function estendi2(sh1,sh2){let lfin=sh1.segment(-1),l2=sh2.segment(0),q1=lfin.interseca(l2);q1&&(sh2.pt[0]=q1),l2=sh2.segment(-2);let q2=lfin.interseca(l2);q2&&(sh2.pt[sh2.pt.length-1]=q2)}1==isopen?estendi1(shape,p2):estendi2(shape,p2)}}return p2},inflateopen:_inflateopen,inflateclose(shape,delta){let p2=_inflateopen(shape.pt,delta);p2.orient!=shape.orient&&p2.reverse();let p3=alignByMinDist(shape.pt,p2.pt,0);return p2.frompt(p3),p2},inflatecornici(shape,delta=2,linetruncateini,linetruncateend){let l1=new Linea2(shape.pt[0],shape.pt[shape.npt-1]),len1=l1.len,l2=l1.perpendicolare(l1.p1,len1),l3=l1.perpendicolare(l1.p2,len1);l2.isparallela(shape.segment(0))&&(l2=l1.perpendicolare(l1.puntot(.1),len1)),l3.isparallela(shape.segment(shape.npt-2))&&(l3=l1.perpendicolare(l1.puntot(.9),len1));let n2=Math.floor(shape.npt/2),{t:t}=l2.proiezionet(shape.pt[n2]),t2=2*(t>0?-1:1),px2=l2.puntot(t2),px3=l3.puntot(t2),p2=_inflateopen([...shape.pt,px3,px2],delta),idx=p2.pt.reduce(((imin,p,i)=>(p.x-px2.x)**2+(p.y-px2.y)**2<(p2.pt[imin].x-px2.x)**2+(p2.pt[imin].y-px2.y)**2?i:imin),0);return p2.pt=p2.pt.slice(idx+2).concat(p2.pt.slice(0,idx)),p2.orient!=shape.orient&&p2.reverse(),linetruncateini&&(shape.truncatebefore(linetruncateini),p2.truncatebefore(linetruncateini)),linetruncateend&&(p2.truncateafter(linetruncateend),shape.truncateafter(linetruncateend)),p2},intersecasplitter(areabase,forma1){const clipper=new ClipperLib.Clipper,pt1=[toclipformat(forma1.pt)],pt2=[toclipformat(areabase.pt)];clipper.AddPaths(pt1,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(pt2,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;let res;if(clipper.Execute(ClipperLib.ClipType.ctIntersection,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero)&&solution.length>0){const path=solution[0];if(1===orientation(path)){res=getshape().frompt(fromclipformat(path)),res.orient!=forma1.orient&&res.reverse();for(let iu=0;iu<forma1.pt.length;iu++){let p2=forma1.pt[iu],id=res.pt.findIndex((p=>Math.abs(p.x-p2.x)<.01&&Math.abs(p.y-p2.y)<.01));if(id>0){id-=iu,0!=id&&res.selezionaprimo(id);break}}}}return res},offsetpts(pts,delta=.01){const DELTA=1e4*delta;let tm=_inflate(toclipformat(pts),DELTA);if(tm&&tm.length)return fromclipformat(tm[0])},areesplitter(shapept,clipspt,useInflatedClipping=!0){if(!Array.isArray(shapept)||shapept.length<3)return;if(!clipspt||0==clipspt.length)return[shapept];const subj=new ClipperLib.Paths,clip=new ClipperLib.Paths;let shape_in=useInflatedClipping?_inflate(toclipformat(shapept),-100):[toclipformat(shapept)],clips_in=useInflatedClipping?clipspt.flatMap((c=>_inflate(toclipformat(c),100))):clipspt.map((c=>toclipformat(c)));for(let s of shape_in)subj.push(s);for(let c of clips_in)clip.push(c);const clipper=new ClipperLib.Clipper;clipper.AddPaths(subj,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(clip,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;if(!clipper.Execute(ClipperLib.ClipType.ctDifference,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero))return;let res=[];for(let x of solution)if(useInflatedClipping){const restored=_inflate(x,100);for(const r of restored)1===orientation(r)&&res.push(fromclipformat(r))}else if(x.length>4&&1==orientation(x)){const cleaned=_inflate(x,-100);if(cleaned.length>0)for(let cc of cleaned){const restored=_inflate(cc,100);for(const rr of restored)1===orientation(rr)&&res.push(fromclipformat(rr))}}else 1==orientation(x)&&res.push(fromclipformat(x));return res},unisci(shapes,holes,cuts){const subj=new ClipperLib.Paths,clip=new ClipperLib.Paths;for(let hh of shapes){let h2=[toclipformat(hh.pt)];for(let h of h2)subj.push(h)}if(holes&&holes.length)for(let hh of holes){let h1=toclipformat(hh.pt);clip.push(h1)}if(cuts&&cuts.length)for(let hh of cuts){let h1=toclipformat(hh.pt),h2=_inflate(h1,1,!0);for(let h of h2)clip.push(h)}const clipper=new ClipperLib.Clipper;clipper.AddPaths(subj,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(clip,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;if(clipper.Execute(ClipperLib.ClipType.ctDifference,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero)){let res=[],holes=[];for(let x of solution)if(1==orientation(x)){let yy=[x];for(let y of yy)res.push({shape:getshape().frompt(fromclipformat(y)),holes:[]})}else holes.push(getshape().frompt(fromclipformat(x)));for(let h of holes)for(let s of res)if(s.shape.pointinshape(h.pt[0])){s.holes.push(h);break}return res}return[]}}}class Vis2d{constructor(name,scalalinea=1){this.name=name,this.clear(scalalinea)}clear(scalalinea=1){return this.vec=[],this.gr={},this._sl=scalalinea,this}creategr(name="grp"){return this.gr[name]||(this.gr[name]=new Vis2d(name,this._sl)),this.gr[name]}push(x=0,y=0,op={}){"number"==typeof op&&(op={rot:op}),op||(op={}),this.vec.push({type:"push",x:x,y:y,op:op})}pop(){this.vec.push({type:"pop"})}randomcolor(transp="100%"){return`hsl(${Math.floor(360*Math.random())}, 50%, 40%,${transp})`}addgr(gr){let name=gr;gr?.name&&(name=gr.name),this.gr[name]?this.vec.push({type:"group",name:name}):this.vec.push({type:"err",err:`addgroup: ${name} => missing`})}addquota(x1,y1,x2,y2,d=0,text="",scalafont=1,spessore=.25){this.vec.push({type:"quota",x1:x1,y1:y1,x2:x2,y2:y2,d:d,text:text,spessore:spessore,color:"black",scalafont:scalafont})}addqpunto(x1,y1,x2,y2,d=0,text="",scalafont=1,spessore=.25){this.vec.push({type:"qpunto",x1:x1,y1:y1,x2:x2,y2:y2,d:d,text:text,spessore:spessore,color:"black",scalafont:scalafont})}addpoint(p,id=-1,color="red",spessore=8){return p&&this.vec.push({type:"point",p:p,id:id,color:color,spessore:spessore*this._sl}),this}addline(l,id=-1,color=void 0,spessore=1){return l&&this.vec.push({type:"line",l:l,id:id,color:color,spessore:spessore*this._sl}),this}addrect(l,id=-1,color=void 0,spessore=1){return l&&this.vec.push({type:"rect",l:l,id:id,color:color,spessore:spessore*this._sl}),this}addrecta(l,id=-1,color=void 0){return l&&this.vec.push({type:"recta",l:l,id:id,color:color,spessore:0}),this}addshape(s,color=void 0,spessore=1){return s&&this.vec.push({type:"shape",s:s,color:color||this.randomcolor(),spessore:spessore*this._sl}),this}addshapelin(s,color=void 0,spessore=1){return s&&this.vec.push({type:"shapelin",s:s,color:color||this.randomcolor(),spessore:spessore*this._sl}),this}addarea(s,color=void 0){return s&&this.vec.push({type:"area",s:s,color:color||this.randomcolor()}),this}addoffset(x,y){return this.vec.push({type:"offset",x:x||0,y:y||0}),this}}function checkoggetto(oggetti,tipo,cod){if("h"==tipo&&(tipo="o"),oggetti||(oggetti=[]),"number"==typeof cod&&!["a","as"].includes(tipo))return{cod:"__",macro:"",sps:cod};let bb=oggetti.find((e=>e.tipo.includes(tipo)&&e.cod==cod));return bb||(bb={cod:"__",macro:"",sps:0}),"a"!=tipo&&"as"!=tipo||"__"==bb.cod||bb.color||(bb.color=`hsl(${function stringToHue(str){let hash=0;for(let i=0;i<str.length;i++)hash=31*hash+str.charCodeAt(i)>>>0;return Math.floor(.6180339887*hash%1*360)}(bb.cod)}, 95%, 97%`),bb}function getbordi(oggetti,bordo){let bordi,uguali=!1;if(Array.isArray(bordo)){bordo.length=4;let b0=bordo[0]||"";bordi=bordo.map((b=>checkoggetto(oggetti,"b",b||b0))),uguali=bordi.every((b=>b.sps===bordi[0].sps))}else{let tm=checkoggetto(oggetti,"b",bordo);bordi=[tm,tm,tm,tm],uguali=!0}return{bordi:bordi,uguali:uguali,senza:!(bordi[0].sps||bordi[1].sps||bordi[2].sps||bordi[3].sps),bl:bordi[0].sps,bt:bordi[1].sps,br:bordi[2].sps,bb:bordi[3].sps}}function elaborapercorso(sh1,bordo,taglio,oggetti,countid=0){let sh2,sh3,p1h,p2h,p3h,p4h,p1v,p2v,p3v,p4v,p1s,p2s,line1,line2,i1,i2,dati=[],draws=[];function eseguipezzo(l1,l2,bordo,shape){let info=l1.infoquad(l2);if(info&&info.distanza){let s0=getshape().frompt(shape||[l1.p1,l1.p2,l2.p2,l2.p1]),s1=s0.clone();(info.sx||info.sy)&&s1.move(-info.sx||0,-info.sy||0),info.angle&&s1.rotate(-info.angle||0);let tm={id:++countid,type:`b${bordo}`,info:info};shape&&(tm.shape=s1.pt),draws.push({type:`b${bordo}`,pt:s0.pt}),dati.push(tm)}}countid=countid||0;let np=sh1.pt.length,idr=np-1;oggetti||(oggetti=[]);let{bordi:bordi,uguali:uguali,senza:senza}=getbordi(oggetti,bordo);if(uguali)if(senza||!bordi[0].sps)sh2=sh1.clone();else{let b=bordi[0].sps;sh2=shapeclip().inflate(sh1,-b,!0)}else{let b,ll=[],pp=[];for(let i=0;i<np;i++){b=0==i?bordi[0].sps:i==idr-1?bordi[2].sps:i==idr?bordi[3].sps:bordi[1].sps,"number"!=typeof b&&(b=0);let l=sh1.segment(i).offset(-b);ll.push(l)}for(let i=0;i<np;i++){let p=ll[i].interseca(ll[(i-1+np)%np]);pp.push(p)}sh2=getshape().frompt(pp)}if(!senza){p1h=sh2.segment(idr).interseca(sh1.segment(0)),p2h=sh2.segment(1).interseca(sh1.segment(0)),p3h=sh1.segment(idr-1).interseca(sh2.segment(idr-2)),p4h=sh1.segment(idr-1).interseca(sh2.segment(idr)),p1v=sh1.segment(idr).interseca(sh2.segment(0)),p2v=sh1.segment(1).interseca(sh2.segment(0)),p3v=sh1.segment(idr-2).interseca(sh2.segment(idr-1)),p4v=sh1.segment(idr).interseca(sh2.segment(idr-1)),i1=1,i2=idr-2,line1=sh2.segment(0),line2=sh2.segment(idr-1);for(let i=1;i<idr-1;i++){let l=sh1.segment(i),p=l.interseca(line1);p&&l.onsegment(p)&&(i1=i,p2v=p),p=l.interseca(line2),p&&l.onsegment(p)&&(i2=i,p3v=p)}i1-=1,i2=idr-2-i2;let p1=sh1.pt[0],p2=sh2.pt[0],p3=sh2.pt[idr],p4=sh1.pt[idr];switch(taglio[0]){case"v":eseguipezzo(new Linea2(p4v,p1v),sh2.segment(idr),3),p2=p1v,p3=p4v;break;case"o":eseguipezzo(sh1.segment(idr),new Linea2(p4h,p1h),3),p1=p1h,p4=p4h;break;default:eseguipezzo(sh1.segment(idr),sh2.segment(idr),3)}switch(p1s=sh1.pt.slice(1,idr),p2s=sh2.pt.slice(1,idr),taglio[1]){case"v":eseguipezzo(new Linea2(p1,sh1.pt[1]),new Linea2(p2,p2v),0),eseguipezzo(new Linea2(sh1.pt[idr-1],p4),new Linea2(p3v,p3),2),i1&&(p1s=p1s.slice(i1)),i2&&(p1s=p1s.slice(0,-i2)),p1s[0]=p2v,p1s[p1s.length-1]=p3v;break;case"o":eseguipezzo(new Linea2(p1,p2h),new Linea2(p2,sh2.pt[1]),0),eseguipezzo(new Linea2(p3h,p4),new Linea2(sh2.pt[idr-1],p3),2),p2s[0]=p2h,p2s[p2s.length-1]=p3h;break;default:eseguipezzo(new Linea2(p1,sh1.pt[1]),new Linea2(p2,sh2.pt[1]),0),eseguipezzo(new Linea2(sh1.pt[idr-1],p4),new Linea2(sh2.pt[idr-1],p3),2)}if(sh3=getshape().frompt(p2s),p1s.length<8&&p1s.length==p2s.length)for(let i=0;i<p1s.length-1;i++)eseguipezzo(new Linea2(p1s[i],p1s[i+1]),new Linea2(p2s[i],p2s[i+1]),1);else{let sh3=getshape().frompt([...p1s,...p2s.reverse()]),l3=new Linea2(p1s[0],p1s[p1s.length-1]),l4=l3.offset(-bordo[1]);eseguipezzo(l3,l4,1,sh3.pt)}}return{countid:countid,shape2:sh2,shapetop:sh3,bordi:bordi,dati:dati,draws:draws}}function creaprofiloesterno(ff,oggetti){let sh1,{x:x,y:y,tipo:tipo,bordo:bordo,taglio:taglio,h1:h1,h2:h2,l1:l1,l2:l2,forma:forma}=ff;x=x<50?50:x,y=y<50?50:y,l1=l1||0,l2=l2||0,h1=h1||0,h2=h2||0;let pts=[0,0];switch(tipo){case"i":case"d":pts.push(l1>0&&l1<x?l1:0,h1>0&&h1<y?y-h1:y),pts.push(l2>0&&l2<x-l1?x-l2:x,h2>0&&h2<y&&h2!=h1?y-h2:y);break;case"a":if(forma){let tm=getshape().fromstr(forma);tm.alignline({x:l1,y:y-h1},{x:x-l2,y:y-h2}),pts.push(...tm.vec)}else if((h1||h2)&&h1>=0&&h1<Math.min(y,x/2)&&h2>=0&&h2<Math.min(y,x/2)){let tm=getshape().fromstr(`a30;${l1||0};${y-h1};${x/2};${y};${x-l2};${y-h2}`);pts.push(...tm.vec)}else pts.push(0,y,x,y);break;case"s":l1>0&&h1>0?pts.push(0,y-h1,l1,y):pts.push(0,y),l2&&l2<x-l1&&h2>0&&h2<y?pts.push(x-l2,y,x,y-h2):pts.push(x,y);break;default:pts.push(0,y,x,y)}pts.push(x,0),sh1=getshape().fromvec(pts);let{countid:countid,shape2:shape2,shapetop:shapetop,bordi:bordi,dati:dati,draws:draws}=elaborapercorso(sh1,bordo,taglio,oggetti,ff.countid);return ff.countid=countid,{shape:sh1,internalshape:shape2,shape2:shape2,shapetop:shapetop,bordi:bordi,dati:dati,draws:draws}}
508
508
  /**
509
- * Genera segmenti basati su intervalli e punti di interruzione
510
- * @param {Array<{a: number, b: number}>} t1 - Array di oggetti che rappresentano intervalli con coordinate a e b
511
- * @param {Array<number>} [t2] - Array opzionale di punti di interruzione
512
- * @param {boolean} [interna=false] - Se true, usa i bordi interni degli intervalli
513
- * @param {boolean} [allbreak=false] - Se true, considera ogni punto degli intervalli come una rottura
514
- * @returns {Array<{a: number, b: number}>} Array di segmenti generati
515
- */const tipi={i:"inclinato",a:"arco",d:"diagonali",s:"smussato",x:"normale"},tagli={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},tipocut={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},tipoalign={l:"sinistra",c:"centro",r:"destra"};function findareacod(areacodes,x,y){let mindist=1/0,minkey="";for(let k of areacodes){let dist=(k.x-x)**2+(k.y-y)**2;dist<mindist&&(mindist=dist,minkey=k.k)}return minkey}function generatesegments(t1,t2,interna=!1,allbreak=!1){let t3=[];if(t1?.length>=2){if(allbreak){let tm=[];for(let t of t1)tm.push({a:t.a,b:t.a}),t.a!=t.b&&tm.push({a:t.b,b:t.b});t1=tm}if(t1=t1.sort(((a,b)=>a.a-b.a)),t2?.length){let j=0;for(let i=1;i<t1.length;i++){const ε=1e-6;t2.find((e=>e>t1[i-1].b+ε&&e<t1[i].a-ε))&&(i-1>j&&(interna?t3.push({a:t1[j].b,b:t1[i-1].a}):t3.push({a:t1[j].a,b:t1[i-1].b})),j=i)}j<t1.length-1&&(interna?t3.push({a:t1[j].b,b:t1[t1.length-1].a}):t3.push({a:t1[j].a,b:t1[t1.length-1].b}))}else t3.push({a:t1[0].b,b:t1[t1.length-1].a})}return t3}function makedivisions(ff,shape2,oggetti){let draws=[],areas=[],dati=[],lines=[],{x:dx,y:dy,oriz:oriz,vert:vert,tipo:tipo,minvano:minvano,minvanox:minvanox,minvanoy:minvanoy}=ff,{bb:bb,bt:bt,bl:bl,br:br}=getbordi(oggetti,ff.bordo);minvanox=minvanox||minvano||50,minvanoy=minvanoy||minvano||50;let{dati:h1,punti:ph}=ordinabase(oggetti,"o",oriz,dy,minvanoy,bb,bt,tipo),{dati:v1,punti:pv}=ordinabase(oggetti,"v",vert,dx,minvanox,bl,br),shapecontorno=shape2.clone();function adddatilin(type,cod,l0,l1,sp,id){if("l"==type)areas.push([l0.p1,l0.p2]);else{let ptx=[l0.p1,l0.p2,l1.p2,l1.p1];areas.push(ptx);let s1=getshape().frompt(ptx);if(shapecontorno?.pt&&(s1.orient!=shapecontorno.orient&&s1.reverse(),s1=shapeclip().intersecasplitter(shapecontorno,s1)),s1){s1.pt.length>=4&&(l0.p1=s1.pt[0],l0.p2=s1.pt[1],l1.p1=s1.pt[s1.pt.length-1],l1.p2=s1.pt[s1.pt.length-2]),lines.push([l0.p1.x+("v"==type?sp:0),l0.p1.y+("v"!=type?sp:0),l0.p2.x+("v"==type?sp:0),l0.p2.y+("v"!=type?sp:0)]);let info=l0.infoquad(l1);if(info&&info.distanza){let s2=s1.clone(),c2=checkoggetto(oggetti,type,cod);(info.sx||info.sy)&&s2.move(-info.sx||0,-info.sy||0),info.angle&&s2.rotate(-info.angle||0);let tm={id:id,type:type,cod:cod,c2:c2,shape:s2.pt,info:info};dati.push(tm),tm?.shape&&draws.push({type:type,sx:tm.info.sx,sy:tm.info.sy,rot:tm.info.angle,pt:tm.shape})}}}}function isinseg(segs,v){return!!segs.find((e=>e.a<=v&&e.b>=v))}v1.forEach(((v,i)=>{v.segs=generatesegments(ph,v.cuts,!0),v.segs.forEach(((s,j)=>{let l0=new Linea2({x:v.x,y:s.a},{x:v.x,y:s.b}),l1=new Linea2({x:v.x+v.sp,y:s.a},{x:v.x+v.sp,y:s.b});adddatilin(v.sp?"v":"l",v.cod,l0,l1,v.sp/2,v.id)}))}));for(let h of h1){let cuts=[...h.cuts],pv1=[...pv];for(let v of v1)pv1.push({a:v.x,b:v.x+v.sp}),isinseg(v.segs,h.x+h.sp/2)&&cuts.push(v.x+v.sp/2);h.segs=generatesegments(pv1,cuts,!0,!0);for(let s of h.segs){let l1=new Linea2({x:s.b,y:h.x+h.sp},{x:s.a,y:h.x+h.sp}),l0=new Linea2({x:s.b,y:h.x},{x:s.a,y:h.x});adddatilin(h.sp?"o":"l",h.cod,l0,l1,h.sp,h.id)}}let res=shapeclip().areesplitter(shape2.pt,areas),areacodes=function getareacodes(ff){let k1,x1,k2,x2,out=[];for(let i=0;i<=ff.vert.length;i++){if(0==i)k1="v0",x1=0;else{let t=ff.vert[i-1];k1=`${t.dir}${t.id}`,x1=t._v}for(let j=0;j<=ff.oriz.length;j++){if(0==j)k2="o0",x2=0;else{let t=ff.oriz[j-1];k2=`${t.dir}${t.id}`,x2=t._v}out.push({k:k1+k2,x:x1,y:x2})}}return out}(ff);for(let d of res){let s=getshape().frompt(d),{p1:p1,width:width,height:height,isrect:isrect}=s.dims(),ix=s.pt.findIndex((p=>Math.abs(p.x-p1.x)<.001&&Math.abs(p.y-p1.y)<.001));ix>0&&s.selezionaprimo(ix),s.pt.length&&(s.move(-p1.x,-p1.y),1==s.orient&&s.reverse());let k=findareacod(areacodes,p1.x,p1.y),cod=ff.aree[k]||ff.area||"",c2=checkoggetto(oggetti,"a",cod);dati.push({id:k,cod:cod,c2:c2,type:"a",shape:isrect?null:s.pt,info:{isrect:isrect?1:0,sx:p1.x,sy:p1.y,rot:0,width:width,height:height}}),draws.push({type:isrect?"a":"as",sx:p1.x,sy:p1.y,dx:width,dy:height,id:k,cod:cod,rot:0,pt:s.pt,color:c2.color})}return{ff:ff,h1:h1,ph:ph,v1:v1,pv:pv,draws:draws,lines:lines,dati:dati}}function ordinabase(oggetti,dir,hh,dd,minvano,b1,b2,tipo){let d1=[];if(hh){for(let h of hh){let sp=checkoggetto(oggetti,dir,h.cod).sps||0,x=0;switch(h.tipo){case"d-":x=dd-h.v;break;case"p":x=dd*h.v/100;break;case"p-":x=dd*(100-h.v)/100;break;default:x=h.v}if(sp&&"c"==h.align?x-=sp/2:sp&&"r"==h.align&&(x-=sp),x=Math.round(10*x)/10,h._x0=x,h._x1=x+sp,h._v=x+sp/2,h._valid=x>0&&x<dd,x>b1&&x<dd-b2){let cuts=[];h.cuts&&h.cuts.length&&h.cuts.forEach((c=>{cuts.push(c<0?dd+c:c)})),d1.push({id:h.id,x:x,sp:sp,cuts:cuts,cod:h.cod})}}d1.sort(((a,b)=>a.x-b.x))}let d2=[],p0=b1;"a"==tipo&&(dd*=1.3);for(let i=0;i<d1.length;i++){let d=d1[i];d.x>=p0+minvano&&d.x+d.sp<=dd-b2-minvano&&(d.min=p0+minvano,d.max=dd-b2-minvano,d2.length>0&&(d2[d2.length-1].max=d.x-minvano),d2.push(d),p0=d.x+d.sp)}let d3=[];d3.push({a:b1,b:b1});for(let d of d2)d3.push({a:d.x,b:d.x+d.sp});return d3.push({a:dd-b2,b:dd-b2}),{dati:d2,punti:d3}}function check(ff){let{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2,vert:vert,oriz:oriz,aree:aree,forma:forma,countid:countid}=ff;return x=x||1e3,x<200&&(x=200),y=y||1e3,y<200&&(y=200),h1=h1||y1||0,h2=h2||y2||0,l1=l1||d1||x1||0,l2=l2||d2||x2||0,h1<0&&h1>y-100&&(h1=0),h2<0&&h2>y-100&&(h2=0),(l2<0||l2>x-l1)&&(l2=0),(l1<0||l1>x-l2)&&(l1=0),minvano=minvano||50,forma&&(tipo="a"),area=area||"__",bordo=bordo||"__",priority=priority||"v",taglio=tagli[taglio]?taglio:"dd",tipo=tipi[tipo]?tipo:"x",vert=vert||[],oriz=oriz||[],aree=aree||{},goriz=goriz||void 0,gvert=gvert||void 0,countid=countid||1,{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,vert:vert,oriz:oriz,aree:aree,countid:countid}}function newcount(ff){return ff.countid++,ff.countid}function addtaglio(ff,dir,tipodim,dim,cod,align="c",cuts=[]){return{dir:dir,id:newcount(ff),tipo:tipocut[tipodim]?tipodim:"d",align:tipoalign[align]?align:"c",v:dim,cod:cod,cuts:cuts||[]}}function addoriz(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.goriz||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"o",tipodim,dim,cod,align,cuts);return ff.oriz||(ff.oriz=[]),ff.oriz.push(tm),ff}var SP=Object.freeze({__proto__:null,addhoriz:function addhoriz(ff,tipodim,dim,cod,align,cuts){return addoriz(ff,tipodim,dim,cod,align,cuts)},addoriz:addoriz,addvert:function addvert(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.gvert||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"v",tipodim,dim,cod,align,cuts);return ff.vert||(ff.vert=[]),ff.vert.push(tm),ff},calcoladivisioni:
509
+ * Genera segmenti basati su intervalli e punti di interruzione
510
+ * @param {Array<{a: number, b: number}>} t1 - Array di oggetti che rappresentano intervalli con coordinate a e b
511
+ * @param {Array<number>} [t2] - Array opzionale di punti di interruzione
512
+ * @param {boolean} [interna=false] - Se true, usa i bordi interni degli intervalli
513
+ * @param {boolean} [allbreak=false] - Se true, considera ogni punto degli intervalli come una rottura
514
+ * @returns {Array<{a: number, b: number}>} Array di segmenti generati
515
+ */const tipi={x:"normale",s:"smussato",i:"inclinato",a:"arco/sagomato",d:"diagonali"},tagli={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},tipocut={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},tipoalign={l:"sinistra",c:"centro",r:"destra"};function findareacod(areacodes,x,y){let mindist=1/0,minkey="";for(let k of areacodes){let dist=(k.x-x)**2+(k.y-y)**2;dist<mindist&&(mindist=dist,minkey=k.k)}return minkey}function generatesegments(t1,t2,interna=!1,allbreak=!1){let t3=[];if(t1?.length>=2){if(allbreak){let tm=[];for(let t of t1)tm.push({a:t.a,b:t.a}),t.a!=t.b&&tm.push({a:t.b,b:t.b});t1=tm}if(t1=t1.sort(((a,b)=>a.a-b.a)),t2?.length){let j=0;for(let i=1;i<t1.length;i++){const ε=1e-6;t2.find((e=>e>t1[i-1].b+ε&&e<t1[i].a-ε))&&(i-1>j&&(interna?t3.push({a:t1[j].b,b:t1[i-1].a}):t3.push({a:t1[j].a,b:t1[i-1].b})),j=i)}j<t1.length-1&&(interna?t3.push({a:t1[j].b,b:t1[t1.length-1].a}):t3.push({a:t1[j].a,b:t1[t1.length-1].b}))}else t3.push({a:t1[0].b,b:t1[t1.length-1].a})}return t3}function makedivisions(ff,shape2,oggetti){let draws=[],areas=[],dati=[],lines=[],{x:dx,y:dy,oriz:oriz,vert:vert,tipo:tipo,minvano:minvano,minvanox:minvanox,minvanoy:minvanoy}=ff,{bb:bb,bt:bt,bl:bl,br:br}=getbordi(oggetti,ff.bordo);minvanox=minvanox||minvano||50,minvanoy=minvanoy||minvano||50;let{dati:h1,punti:ph}=ordinabase(oggetti,"o",oriz,dy,minvanoy,bb,bt,tipo),{dati:v1,punti:pv}=ordinabase(oggetti,"v",vert,dx,minvanox,bl,br),shapecontorno=shape2.clone();function adddatilin(type,cod,l0,l1,sp,id){if("l"==type)areas.push([l0.p1,l0.p2]);else{let ptx=[l0.p1,l0.p2,l1.p2,l1.p1];areas.push(ptx);let s1=getshape().frompt(ptx);if(shapecontorno?.pt&&(s1.orient!=shapecontorno.orient&&s1.reverse(),s1=shapeclip().intersecasplitter(shapecontorno,s1)),s1){s1.pt.length>=4&&(l0.p1=s1.pt[0],l0.p2=s1.pt[1],l1.p1=s1.pt[s1.pt.length-1],l1.p2=s1.pt[s1.pt.length-2]),lines.push([l0.p1.x+("v"==type?sp:0),l0.p1.y+("v"!=type?sp:0),l0.p2.x+("v"==type?sp:0),l0.p2.y+("v"!=type?sp:0)]);let info=l0.infoquad(l1);if(info&&info.distanza){let s2=s1.clone(),c2=checkoggetto(oggetti,type,cod);(info.sx||info.sy)&&s2.move(-info.sx||0,-info.sy||0),info.angle&&s2.rotate(-info.angle||0);let tm={id:id,type:type,cod:cod,c2:c2,shape:s2.pt,info:info};dati.push(tm),tm?.shape&&draws.push({type:type,sx:tm.info.sx,sy:tm.info.sy,rot:tm.info.angle,pt:tm.shape})}}}}function isinseg(segs,v){return!!segs.find((e=>e.a<=v&&e.b>=v))}v1.forEach(((v,i)=>{v.segs=generatesegments(ph,v.cuts,!0),v.segs.forEach(((s,j)=>{let l0=new Linea2({x:v.x,y:s.a},{x:v.x,y:s.b}),l1=new Linea2({x:v.x+v.sp,y:s.a},{x:v.x+v.sp,y:s.b});adddatilin(v.sp?"v":"l",v.cod,l0,l1,v.sp/2,v.id)}))}));for(let h of h1){let cuts=[...h.cuts],pv1=[...pv];for(let v of v1)pv1.push({a:v.x,b:v.x+v.sp}),isinseg(v.segs,h.x+h.sp/2)&&cuts.push(v.x+v.sp/2);h.segs=generatesegments(pv1,cuts,!0,!0);for(let s of h.segs){let l1=new Linea2({x:s.b,y:h.x+h.sp},{x:s.a,y:h.x+h.sp}),l0=new Linea2({x:s.b,y:h.x},{x:s.a,y:h.x});adddatilin(h.sp?"o":"l",h.cod,l0,l1,h.sp,h.id)}}let res=shapeclip().areesplitter(shape2.pt,areas),areacodes=function getareacodes(ff){let k1,x1,k2,x2,out=[];for(let i=0;i<=ff.vert.length;i++){if(0==i)k1="v0",x1=0;else{let t=ff.vert[i-1];k1=`${t.dir}${t.id}`,x1=t._v}for(let j=0;j<=ff.oriz.length;j++){if(0==j)k2="o0",x2=0;else{let t=ff.oriz[j-1];k2=`${t.dir}${t.id}`,x2=t._v}out.push({k:k1+k2,x:x1,y:x2})}}return out}(ff);for(let d of res){let s=getshape().frompt(d),{p1:p1,width:width,height:height,isrect:isrect}=s.dims(),ix=s.pt.findIndex((p=>Math.abs(p.x-p1.x)<.001&&Math.abs(p.y-p1.y)<.001));ix>0&&s.selezionaprimo(ix),s.pt.length&&(s.move(-p1.x,-p1.y),1==s.orient&&s.reverse());let k=findareacod(areacodes,p1.x,p1.y),cod=ff.aree[k]||ff.area||"",c2=checkoggetto(oggetti,"a",cod);dati.push({id:k,cod:cod,c2:c2,type:"a",shape:isrect?null:s.pt,info:{isrect:isrect?1:0,sx:p1.x,sy:p1.y,rot:0,width:width,height:height}}),draws.push({type:isrect?"a":"as",sx:p1.x,sy:p1.y,dx:width,dy:height,id:k,cod:cod,rot:0,pt:s.pt,color:c2.color})}return{ff:ff,h1:h1,ph:ph,v1:v1,pv:pv,draws:draws,lines:lines,dati:dati}}function ordinabase(oggetti,dir,hh,dd,minvano,b1,b2,tipo){let d1=[];if(hh){for(let h of hh){let sp=checkoggetto(oggetti,dir,h.cod).sps||0,x=0;switch(h.tipo){case"d-":x=dd-h.v;break;case"p":x=dd*h.v/100;break;case"p-":x=dd*(100-h.v)/100;break;default:x=h.v}if(sp&&"c"==h.align?x-=sp/2:sp&&"r"==h.align&&(x-=sp),x=Math.round(10*x)/10,h._x0=x,h._x1=x+sp,h._v=x+sp/2,h._valid=x>0&&x<dd,x>b1&&x<dd-b2){let cuts=[];h.cuts&&h.cuts.length&&h.cuts.forEach((c=>{cuts.push(c<0?dd+c:c)})),d1.push({id:h.id,x:x,sp:sp,cuts:cuts,cod:h.cod})}}d1.sort(((a,b)=>a.x-b.x))}let d2=[],p0=b1;"a"==tipo&&(dd*=1.3);for(let i=0;i<d1.length;i++){let d=d1[i];d.x>=p0+minvano&&d.x+d.sp<=dd-b2-minvano&&(d.min=p0+minvano,d.max=dd-b2-minvano,d2.length>0&&(d2[d2.length-1].max=d.x-minvano),d2.push(d),p0=d.x+d.sp)}let d3=[];d3.push({a:b1,b:b1});for(let d of d2)d3.push({a:d.x,b:d.x+d.sp});return d3.push({a:dd-b2,b:dd-b2}),{dati:d2,punti:d3}}function check(ff){let{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2,vert:vert,oriz:oriz,aree:aree,forma:forma,countid:countid}=ff;return x=x||1e3,x<200&&(x=200),y=y||1e3,y<200&&(y=200),h1=h1||y1||0,h2=h2||y2||0,l1=l1||d1||x1||0,l2=l2||d2||x2||0,h1<0&&h1>y-100&&(h1=0),h2<0&&h2>y-100&&(h2=0),(l2<0||l2>x-l1)&&(l2=0),(l1<0||l1>x-l2)&&(l1=0),minvano=minvano||50,forma&&(tipo="a"),area=area||"__",bordo=bordo||"__",priority=priority||"v",taglio=tagli[taglio]?taglio:"dd",tipo=tipi[tipo]?tipo:"x",vert=vert||[],oriz=oriz||[],aree=aree||{},goriz=goriz||void 0,gvert=gvert||void 0,countid=countid||1,{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,vert:vert,oriz:oriz,aree:aree,countid:countid}}function newcount(ff){return ff.countid++,ff.countid}function addtaglio(ff,dir,tipodim,dim,cod,align="c",cuts=[]){return{dir:dir,id:newcount(ff),tipo:tipocut[tipodim]?tipodim:"d",align:tipoalign[align]?align:"c",v:dim,cod:cod,cuts:cuts||[]}}function addoriz(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.goriz||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"o",tipodim,dim,cod,align,cuts);return ff.oriz||(ff.oriz=[]),ff.oriz.push(tm),ff}var SP=Object.freeze({__proto__:null,addhoriz:function addhoriz(ff,tipodim,dim,cod,align,cuts){return addoriz(ff,tipodim,dim,cod,align,cuts)},addoriz:addoriz,addvert:function addvert(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.gvert||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"v",tipodim,dim,cod,align,cuts);return ff.vert||(ff.vert=[]),ff.vert.push(tm),ff},calcoladivisioni:
516
516
  /**
517
517
  * Ordina e calcola le posizioni di taglio lungo una dimensione, gestendo bordi e spazi minimi
518
518
  * @param {Array<Object>} hh - Array di oggetti che definiscono i tagli
@@ -523,7 +523,7 @@ function alignByMinDist(sag1,sag2,isopen){const n1=sag1.length,n2=sag2.length;if
523
523
  * - dati: Array di oggetti con le posizioni elaborate dei tagli
524
524
  * - punti: Array di oggetti {a,b} che definiscono inizio e fine di ogni segmento
525
525
  */
526
- function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipoalign:tipoalign,tipocut:tipocut});function fondilinee(linee){const out=linee.slice();out.forEach((e=>e.valid=!0));for(let i=0;i<out.length;i++)if(!1!==out[i].valid)if(out[i].len<.1)out[i].valid=!1;else for(let j=i+1;j<out.length;j++){if(!1===out[j].valid)continue;const a=out[i],b=out[j];if(!a||!b)continue;if(!a.isparallela(b))continue;const a1_su_b=b.onsegment(a.p1,.1),a2_su_b=b.onsegment(a.p2,.1),b1_su_a=a.onsegment(b.p1,.1),b2_su_a=a.onsegment(b.p2,.1);if(!(a1_su_b||a2_su_b||b1_su_a||b2_su_a))continue;const dot=a.dx*b.dx+a.dy*b.dy,pa1=0,pa2=1,rb1=a.proiezionet(b.p1),rb2=a.proiezionet(b.p2);if(!rb1||!rb2)continue;const pb1=rb1.t,pb2=rb2.t;if(dot>0){const tmin=Math.min(pa1,pa2,pb1,pb2),tmax=Math.max(pa1,pa2,pb1,pb2),pmin=a.puntot(tmin),pmax=a.puntot(tmax),fus=new Linea2(pmin,pmax);out[i].valid=!1,out[j].valid=!1,fus.len>=.1&&(fus.valid=!0,out.push(fus))}else if(dot<0){const a_min=Math.min(pa1,pa2),a_max=Math.max(pa1,pa2),b_min=Math.min(pb1,pb2),b_max=Math.max(pb1,pb2),ov_min=Math.max(a_min,b_min),ov_max=Math.min(a_max,b_max);if(ov_min>ov_max+.1)continue;const gmin=Math.min(a_min,b_min),gmax=Math.max(a_max,b_max);if(gmin<ov_min-.1){const s1=new Linea2(a.puntot(gmin),a.puntot(ov_min));s1.len>=.1&&(s1.valid=!0,out.push(s1))}if(ov_max<gmax-.1){const s2=new Linea2(a.puntot(ov_max),a.puntot(gmax));s2.len>=.1&&(s2.valid=!0,out.push(s2))}out[i].valid=!1,out[j].valid=!1}}const res=out.filter((s=>s.valid)),tt=[];function samepoint(p1,p2){return Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y)<.1}for(let r of res){let fi=-1,fe=-1;for(let i=0;i<tt.length;i++){let t=tt[i];if(fi<0&&samepoint(t[0],r.p2)&&(tt[i]=[r.p1,...t],fi=i),fe<0&&samepoint(t[t.length-1],r.p1)&&(tt[i]=[...t,r.p2],fe=i),fi>=0&&fe>=0)break}fi<0&&fe<0?tt.push([r.p1,r.p2]):fi>=0&&fe>=0&&fi!=fe&&(tt[fi]=[...tt[fi],...tt[fe]],tt.splice(fe,1))}return tt}async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&&macro.head&&macro.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&&parametri.length)for(const param of parametri)await _parsepars(param);if(macro&&macro.head&&macro.head.length){let tm=macro.head.filter((e=>!["g"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){let rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname,order:order}=pos;if("number"==typeof order&&g2.traverse((child=>{child.isMesh&&(child.renderOrder=order)})),tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
526
+ function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:tipoalign,tipocut:tipocut});function fondilinee(linee){const out=linee.slice();out.forEach((e=>e.valid=!0));for(let i=0;i<out.length;i++)if(!1!==out[i].valid)if(out[i].len<.1)out[i].valid=!1;else for(let j=i+1;j<out.length;j++){if(!1===out[j].valid)continue;const a=out[i],b=out[j];if(!a||!b)continue;if(!a.isparallela(b))continue;const a1_su_b=b.onsegment(a.p1,.1),a2_su_b=b.onsegment(a.p2,.1),b1_su_a=a.onsegment(b.p1,.1),b2_su_a=a.onsegment(b.p2,.1);if(!(a1_su_b||a2_su_b||b1_su_a||b2_su_a))continue;const dot=a.dx*b.dx+a.dy*b.dy,pa1=0,pa2=1,rb1=a.proiezionet(b.p1),rb2=a.proiezionet(b.p2);if(!rb1||!rb2)continue;const pb1=rb1.t,pb2=rb2.t;if(dot>0){const tmin=Math.min(pa1,pa2,pb1,pb2),tmax=Math.max(pa1,pa2,pb1,pb2),pmin=a.puntot(tmin),pmax=a.puntot(tmax),fus=new Linea2(pmin,pmax);out[i].valid=!1,out[j].valid=!1,fus.len>=.1&&(fus.valid=!0,out.push(fus))}else if(dot<0){const a_min=Math.min(pa1,pa2),a_max=Math.max(pa1,pa2),b_min=Math.min(pb1,pb2),b_max=Math.max(pb1,pb2),ov_min=Math.max(a_min,b_min),ov_max=Math.min(a_max,b_max);if(ov_min>ov_max+.1)continue;const gmin=Math.min(a_min,b_min),gmax=Math.max(a_max,b_max);if(gmin<ov_min-.1){const s1=new Linea2(a.puntot(gmin),a.puntot(ov_min));s1.len>=.1&&(s1.valid=!0,out.push(s1))}if(ov_max<gmax-.1){const s2=new Linea2(a.puntot(ov_max),a.puntot(gmax));s2.len>=.1&&(s2.valid=!0,out.push(s2))}out[i].valid=!1,out[j].valid=!1}}const res=out.filter((s=>s.valid)),tt=[];function samepoint(p1,p2){return Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y)<.1}for(let r of res){let fi=-1,fe=-1;for(let i=0;i<tt.length;i++){let t=tt[i];if(fi<0&&samepoint(t[0],r.p2)&&(tt[i]=[r.p1,...t],fi=i),fe<0&&samepoint(t[t.length-1],r.p1)&&(tt[i]=[...t,r.p2],fe=i),fi>=0&&fe>=0)break}fi<0&&fe<0?tt.push([r.p1,r.p2]):fi>=0&&fe>=0&&fi!=fe&&(tt[fi]=[...tt[fi],...tt[fe]],tt.splice(fe,1))}return tt}async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&&macro.head&&macro.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&&parametri.length)for(const param of parametri)await _parsepars(param);if(macro&&macro.head&&macro.head.length){let tm=macro.head.filter((e=>!["g"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){let rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname,order:order}=pos;if("number"==typeof order&&g2.traverse((child=>{child.isMesh&&(child.renderOrder=order)})),tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
527
527
  /**
528
528
  * Crea una linea 3D
529
529
  * @param {Object} l - Oggetto contenente punti p1 e p2
package/bin/markuno.js CHANGED
@@ -261,8 +261,8 @@ this.amb=amb,this.azzera()}azzera(){this.key=`${this.cat}/${this.name}`,this.loc
261
261
  * @returns {Array<{class: string, text: string}>} Array di token con classi CSS
262
262
  */function muParsecode(tt,isvar){tt||(tt=" "),tt.endsWith("\n")&&(tt+=" ");const tm=[{class:"",text:tt}];for(let i=0;i<tm.length;i++)if(!tm[i].class){{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(\/\*[^]+?\*\/)/im,(m=>[{class:"comment",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(!tm[i].class){{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(\/\/.*)$/im,(m=>[{class:"commento2",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(!tm[i].class){{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(^\s*\{.+?\})/m,(m=>[{class:"header",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(!tm[i].class){{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(^\s*:\w+)(.*?$)/m,(m=>[{class:"param",text:m[1]},{class:"param2",text:m[2]}]));fl&&tm.splice(i,1,...tk)}if(!isvar){if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(^\s*!\w+)/m,(m=>[{class:"function",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(#let.? +)([\w_.]+)/im,(m=>[{class:"comando",text:m[1]},{class:"variabile",text:m[2]}]));fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(#(push|pop|select|cases|endselect|ifndef|elseifndef|ifdef|endif|elseifdef|variante|forvar|for|endfor|continue|break|inc|macro|default|letm|lets|letv|lett|leto|cat))/im,(m=>[{class:"comando",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(#(if\s*|elseif\s*))/im,(m=>[{class:"comando",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(#(else|i |m |f |j |case|def ))/im,(m=>[{class:"comando",text:m[1]}]));fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parsevariabili(tm[i].text);fl&&tm.splice(i,1,...tk)}if(tm[i].class)continue;{const{fl:fl,tk:tk}=parseexp(tm[i].text,/(\$[\w_.]+)/im,(m=>[{class:"variabile",text:m[1]}]));fl&&tm.splice(i,1,...tk)}}}}}}return tm}function toruleset(rs){const o={};if(rs&&rs.length)for(const r of rs)o[r.cod]=r;return o}function headerconvert(tt){const rr=muClComments(tt,!1);tt={};let grp={r:[]},fl=!1;for(const r of rr){const m=/^\s*\{(h|head|header)\s+(\w+)\}/im.exec(r);if(m)grp={cod:m[2],des:m[2],r:[]},fl=!1,tt[m[2]]=grp;else if(!/^\s*:/.exec(r)){const v=r.split(","),t={cod:clean(v[0])};let tm;tm=(v[1]||"").trim(),tm&&(t.des=tm),tm=clean(v[2]),tm&&(t.tipo=tm),tm=clean(v[3]),tm&&(t.alias=tm),tm=clean(v[4]),tm&&(t.valid=tm),tm=clean(v[5]),tm&&(t.visible=tm),t.cod&&(fl||"sep"!=t.tipo?grp.r.push(t):(grp.des=t.des,grp.valid=t.valid,grp.visible=t.visible,fl=!0))}}return tt}function aliasconvert(tt){const rr=muClComments(tt.toLowerCase(),!1),tx={};for(const r of rr)if(!/^\s*:/.exec(r)){const v=getcolonne(r);v[0]&&v[1]&&(tx[v[0]]={cod:v[1]})}return tx}class Ambiente{#headers=void 0;#alias=void 0;#deriva=void 0;#typos=void 0;constructor(cat=".",maxdelays=100,righevuote=!1){this.righevuote=righevuote,this.maxdelays=maxdelays,this.setcatalog(cat),this.fndotcallback=void 0}setcatalog(cat){return cat=clean(cat),this.cat!=cat&&(this.cat=cat,this.item=this.rule=this.model="",this.azzera(!0)),cat}get muvalutatore(){return{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}}azzera(mode=!1){
263
263
  /** @type {Variabile} */
264
- this.vari=new Variabile,this.ruleset={},this.fndotcallback&&this.vari.setfndot(this.fndotcallback),this.ruleheader="",mode&&(
264
+ this.imgpreview={},this.vari=new Variabile,this.ruleset={},this.fndotcallback&&this.vari.setfndot(this.fndotcallback),this.ruleheader="",mode&&(
265
265
  /** @type {Object.<string, Macro>} */
266
266
  this.macro={},
267
267
  /** @type {Object.<string, Variante>} */
268
- this.varianti={},this.varelenco={},this.macroelenco={},this.scripts={},this.#headers=void 0,this.#alias=void 0,this.#deriva=void 0,this.#typos=void 0)}setfndot(fndotcallback){this.fndotcallback=fndotcallback,this.vari.setfndot(fndotcallback)}async#checkelencovar(cat){if(cbInfo&&!this.varelenco[cat]){const tm=await cbInfo("headers",cat,"_varianti");Array.isArray(tm)?this.varelenco[cat]=tm:tm.vars&&(this.varelenco[cat]=tm.vars,tm.alias&&(this.#alias=tm.alias)),this.varelenco[cat]||(this.varelenco[cat]=[])}}parseheaderfrominfo(tm){if(tm&&tm.length>0)for(const t of tm)switch(t.tipo){case"_headers":"string"==typeof t.value&&(t.value=headerconvert(t.value)),this.#headers=t.value||{};break;case"_alias":"string"==typeof t.value&&(t.value=aliasconvert(t.value)),this.#alias=t.value||{};break;case"_typos":if("string"==typeof t.value){const tips=fromjson(t.value);for(const tp in tips){const tq=tips[tp];tq.db&&(tq.db=muClean(muClComments(tq.db))),tq.list&&(tq.list=muClean(muClComments(tq.list)))}t.value=tips}this.#typos=t.value||{}}}setitem(item,rule,model,ruleset=[],datadelgiorno=0){this.item=clean(item,!0),this.rule=clean(rule,!0),this.model=clean(model,!0),this.ruleset=toruleset(ruleset),this.data=datadelgiorno||(new Date).toInt()}async getheader(cod){let tm;return!this.#headers&&cbInfo&&(tm=await cbInfo("headers",this.cat,"_headers"),this.parseheaderfrominfo(tm)),this.#headers||(this.#headers={}),this.#headers[cod]}async getalias(){let tm;return!this.#alias&&cbInfo&&(tm=await cbInfo("headers",this.cat,"_alias"),this.parseheaderfrominfo(tm)),this.#alias||(this.#alias={}),this.#alias}get deriva(){return this.#deriva,this.#deriva||[]}async getmacro(riga){try{if("string"==typeof riga&&(riga={tipo:"M",contenuto:riga}),!riga||!riga.contenuto)return;const rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(riga.contenuto);if(!rr)return void errori.add("Macro non valida:"+riga.contenuto,riga);let macro=clean(rr[1],!0);macro.includes("$")&&(macro=await this.vari.valuta(macro));const pars=getcolonne(rr[2]),{name:name,cat:cat}=checkmu(macro,this.cat);this.cat=cat;const ky=`${cat}/${name}`;if(!this.macro[ky]){const tm=new Macro(this,name);await tm.load()?this.macro[ky]=tm:errori.add(`macro fail to load ${ky}`,riga)}return macro=this.macro[ky],macro?{macro:macro,pars:pars}:(errori.add(`macro non trovata ${ky}`,riga),{})}catch(error){errori.add(geterrdes(error),`ambiente.getmacro: ${riga?.contenuto}`)}}async getvariante(cod){const{name:name,cat:cat}=checkmu(cod,this.cat);let n2=name,altri={};if(cat==this.cat&&this.#alias&&this.#alias[name]&&(altri=this.#alias[name]||{},n2=altri.cod),await this.#checkelencovar(cat),this.varelenco[cat]&&!this.varelenco[cat].includes(name))return;const key=`${cat}/${n2}`;let vv;return this.varianti[key]?vv=this.varianti[key]:(vv=new Variante(this),await vv.load(key,cat),this.varianti[key]=vv),altri&&(altri.des&&(vv.des=altri.des),altri.vdef&&(vv.vdef=altri.vdef)),vv}async varcompila(v,callback){const xx=new Variante(this);if(await xx.load(v,this.cat,!0),xx.alias){(await this.getalias())[v]=xx.alias}callback("variants",{cod:v,des:xx.des||"",alias:xx.alias,info:xx.alias?"":JSON.stringify(getOggetto(xx,["amb"]))})}async macrocompila(v,callback){const mac=new Macro(this,v);await mac.loadAndCompile(`${v}.mu`);const t=mac.getmacro();callback("macros",{cod:v,info:JSON.stringify(t),isgenera:mac.isgenera,isheader:mac.isheader,iscodice:mac.iscodice})}async barrecompila(articolibarre,titolibarre,callback){const cc=new CodiceBarra;await cc.compila(articolibarre,titolibarre);for(const x in cc.barre){callback("barcodes",{cod:x,des:"",info:JSON.stringify(cc.barre[x])})}return cc}async tojson(d){let tm;return cbFunc&&(tm=await cbFunc("json",d)),tm}async compila(info,callback){if(callback){for(const v of info.var)await this.varcompila(v,callback);for(const v of info.mu)await this.macrocompila(v,callback);if(callback("infos",{cod:"info",des:info.cat,info:JSON.stringify({cat:info.cat,md:info.info})}),this.#headers=void 0,this.#alias=void 0,this.#deriva=void 0,this.#typos=void 0,cbInfo){const tm=await cbInfo("headers",this.cat,["_headers","_alias","_deriva","_typos"]);this.parseheaderfrominfo(tm)}this.#headers?callback("infos",{cod:"headers",des:"",info:JSON.stringify(this.#headers)}):logga("missing headers"),this.#alias&&callback("infos",{cod:"alias",des:"",info:JSON.stringify(this.#alias)}),this.#deriva&&callback("infos",{cod:"deriva",des:"",info:JSON.stringify(this.#deriva)}),this.#typos&&callback("infos",{cod:"typos",des:"tipologie",info:JSON.stringify(this.#typos)})}}async checkvarianti(cat,vars){if(!cat||!vars?.length)return;cat=checkname(cat),await this.#checkelencovar(cat);const t=this.varelenco[cat],vn=[];for(let v of vars){v=clean(v,!0);const nn=`${cat}/${v}`;this.varianti[nn]||t&&t.includes(v)&&vn.push(v)}if(vn.length&&cbGetVariante){const xv=await cbGetVariante(cat,vn);if(xv&&xv.length)for(const x of xv){const{name:name,content:content}=x,vv=new Variante(this);vv.setheader(name,cat),content&&await vv.loadContentExtended(content),this.varianti[vv.key]=vv}}}async getheaderfromdb(name){const totale=await cbInfo("header",this.cat,name,!this.#deriva);let{head:head,rows:rows,macros:macros,deriva:deriva,llvars:llvars}=totale;for(const r of rows)r.cod=clean(r.cod),r.alias=clean(r.alias),r.t=clean(r.t);if(!llvars){llvars=new Set;for(const r of rows)if("p"==r.tipo);else{const nn=r.alias?r.alias:r.cod;llvars.add(nn)}llvars=[...llvars]}this.#deriva||(this.#deriva=deriva),await this.#checkelencovar(this.cat),head.cod=clean(head.cod),head.rule=clean(head.rule),head.ruledef=head.ruledef||[];const vn=[],t=this.varelenco[this.cat];for(const nn of llvars)this.varianti[`${this.cat}/${nn}`]||t&&t.includes(nn)&&vn.push(nn);if(vn.length&&cbGetVariante){const vars=await cbGetVariante(this.cat,vn);if(vars&&vars.length)for(const x of vars){const{name:name,content:content}=x,vv=new Variante(this);vv.setheader(name,this.cat),content&&await vv.loadContentExtended(content),this.varianti[vv.key]=vv}}return{head:head,rows:rows,macros:macros}}async getlinkedmacros(rule,macros){const getkey=n=>n.includes("/")?n:`${this.cat}/${n}`,cl=[];let k;if(rule&&(k=getkey(rule),this.macro[k]||cl.push(rule)),macros&&"string"==typeof macros){const vv=macros.split(";");for(const v of vv)k=getkey(v),this.macro[k]||cl.push(v)}if(cl&&cl.length>0&&cbGetMacro){const tm=await cbGetMacro(this.cat,cl);if(tm&&tm.length>0)for(const x of tm){const m=new Macro(this,x.name);for(const t in x.content){const contenuto=x.content[t];m[t]=contenuto}this.macro[m.key]=m}}}async setruleheader(rule,pars,ruleset){const{name:name,cat:cat}=checkmu(rule,this.cat);ruleset&&ruleset.length&&(this.ruleset=toruleset(ruleset));const ky=`${cat}/${name}`;if(!this.macro[ky]){const totale=await this.getheaderfromdb(name),{head:head,rows:rows,macros:macros}=totale;await this.getlinkedmacros(head.rule,macros);const tm=new Macro(this,name);if(!head)return void errori.add("Missing rule: "+rule);if(head.rule){const k2=this.macro[`${cat}/${head.rule}`];if(k2)for(const x in k2)["cat","name","key"].includes(x)||(tm[x]=k2[x])}rows&&rows.length&&(tm.head=rows),this.macro[ky]=tm}this.ruleheader=ky;const mc=this.macro[ky];return errori.azzera(),await mc.setparametri(pars),mc}getruleheader(){return this.macro[this.ruleheader]}async setvariante(cod,opz){return await impostavariante(this,null,cod,opz)}async valuta(codice){let output;return"string"==typeof codice&&(codice=muClean(muClComments(codice,this.righevuote))),Array.isArray(codice)&&(logga("m1",codice),output=await muEval(this,null,codice)),output}setinfos(tm){tm&&(this.#headers=tm.headers,this.#alias=tm.alias,this.#deriva=void 0,this.#typos=tm.typos)}async splitteroggetti(name){let data=await this.getvariante(name),cl=[];return data?.rows&&Object.values(data.rows).forEach((v=>{cl.push({tipo:v.v[2]||"",cod:v.v[0]||"",des:v.v[1]||"",macro:v.v[4]||"",sps:parseInt(v.v[3])||0})})),cl.length||cl.push({tipo:"avob",cod:"__",des:"Vuoto",macro:"",sps:0}),cl}}function toJson(t){return JSON.stringify(t,null,2)}function clamp(n,min=-1/0,max=1/0){return(n=Number(n)||0)<min&&(n=min),n>max&&(n=max),n}function gettipocolonna(cod){return tipicolonna.find((x=>x.cod==cod))?.des||tipicolonna[0].des}function gettipofolder(cod){return tipicolonna.find((x=>x.cod==cod))?.folder||""}function newVariabile(){return new Variabile}async function newVariante(cod,cat,amb){const xx=new Variante(amb);return await xx.load(cod,cat),xx}function newAmbiente(cat,maxmillis=100){return new Ambiente(cat,maxmillis)}function newMacro(amb,name){return new Macro(amb,name)}function muValuta(mu,codice,azzera){azzera&&mu.azzera();return mu.valuta(codice)}function muInit(cat,cbGetMacro,cbGetVariante,cbFunc,cbInfo,cbGetFile,cbLogga){const mu=new Ambiente(cat);return setcallbacks(cbGetMacro,cbGetVariante,cbFunc,cbInfo,cbGetFile,cbLogga),mu}function muCompileScript(codice){return codice&&"object"==typeof codice?codice:codice.startsWith("{")&&codice.endsWith("}")||codice.startsWith("[")&&codice.endsWith("]")?JSON.stringify(codice):muClean(muClComments(codice))}async function muEvalScript(/** @type {Ambiente} */amb,codice,pars,reset=!0){if(codice=muCompileScript(codice),reset&&amb.azzera(),pars)for(const p of pars){const{v:v,o:o}=getcouple(p);amb.vari.add(v,o)}return{output:await muEval(amb,null,codice,{}),vari:amb.vari.dictionary,errori:errori}}const tonum=(s,dec=-1)=>{if(!s)return 0;let n=0;if("number"==typeof s)n=s||0;else if("string"==typeof s){const x=(s=s.replaceAll(",",".")).match(/^-?[0-9.]+$/);n=x&&x.length>0?Number(x[0])||0:muCalc(s)}if(dec>=0)switch(dec){case 0:n=Math.round(n);break;case 1:n=Math.round(10*n)/10;break;case 2:n=Math.round(100*n)/100;break;case 3:n=Math.round(1e3*n)/1e3;break;case 4:n=Math.round(1e4*n)/1e4;break;case 5:n=Math.round(1e5*n)/1e5;break;case 6:n=Math.round(1e6*n)/1e6}return n||0};Date.prototype.toInt||(Date.prototype.toInt=function(){return this.getDate()+100*(this.getMonth()+1)+1e4*this.getFullYear()}),Date.prototype.toFloat||(Date.prototype.toFloat=function(){return Math.floor(1e4*this.getDate()+1e6*(this.getMonth()+1)+1e8*this.getFullYear()+100*this.getHours()+this.getMinutes()+.5)/1e4});const mustr={mus:{variants:{cod:"s",des:"s",alias:"s",info:"s",md:"s",__pk:"cod"},extras:{tipo:"s",cod:"s",info:"s",__pk:"tipo, cod"},macros:{cod:"s",des:"s",info:"s",md:"s",def:"s",isgenera:"i",iscodice:"i",isheader:"i",__pk:"cod"},infos:{cod:"s",des:"s",info:"s",__pk:"cod"},barcodes:{cod:"s",des:"s",info:"s",__pk:"cod"}}};export{Ambiente,CodiceBarra,Macro,Variabile,Variante,checkmu,checkname,clamp,clean,dammivariante,errori,fromjson,getOggetto,getcolonne,getcouple,geterrdes,getheaddims,gettipocolonna,gettipofolder,hash,impostavariante,intvaluta,isJsonStr,isObject,muInit as jsTest,logga,muCalc,muClComments,muClean,muCompileScript,muEval,muEvalScript,muGenerate,muInit,muLimits,muParsecode,muValuta,mustr,newAmbiente,newMacro,newVariabile,newVariante,parselimitifromdb,parselimitifromrule,parsevar,poppars,pushpars,quote,setOggetto,sortrows,testsync,tipicolonna,tipifree,tipiheader,tk,toCadPars,toJson,tonum,xdt};
268
+ this.varianti={},this.varelenco={},this.macroelenco={},this.scripts={},this.#headers=void 0,this.#alias=void 0,this.#deriva=void 0,this.#typos=void 0)}setimgpreview(cod,img){img?this.imgpreview[cod]=img:delete this.imgpreview[cod]}getimgpreview(cod){return this?.imgpreview[cod||""]}setfndot(fndotcallback){this.fndotcallback=fndotcallback,this.vari.setfndot(fndotcallback)}async#checkelencovar(cat){if(cbInfo&&!this.varelenco[cat]){const tm=await cbInfo("headers",cat,"_varianti");Array.isArray(tm)?this.varelenco[cat]=tm:tm.vars&&(this.varelenco[cat]=tm.vars,tm.alias&&(this.#alias=tm.alias)),this.varelenco[cat]||(this.varelenco[cat]=[])}}parseheaderfrominfo(tm){if(tm&&tm.length>0)for(const t of tm)switch(t.tipo){case"_headers":"string"==typeof t.value&&(t.value=headerconvert(t.value)),this.#headers=t.value||{};break;case"_alias":"string"==typeof t.value&&(t.value=aliasconvert(t.value)),this.#alias=t.value||{};break;case"_typos":if("string"==typeof t.value){const tips=fromjson(t.value);for(const tp in tips){const tq=tips[tp];tq.db&&(tq.db=muClean(muClComments(tq.db))),tq.list&&(tq.list=muClean(muClComments(tq.list)))}t.value=tips}this.#typos=t.value||{}}}setitem(item,rule,model,ruleset=[],datadelgiorno=0){this.item=clean(item,!0),this.rule=clean(rule,!0),this.model=clean(model,!0),this.ruleset=toruleset(ruleset),this.data=datadelgiorno||(new Date).toInt()}async getheader(cod){let tm;return!this.#headers&&cbInfo&&(tm=await cbInfo("headers",this.cat,"_headers"),this.parseheaderfrominfo(tm)),this.#headers||(this.#headers={}),this.#headers[cod]}async getalias(){let tm;return!this.#alias&&cbInfo&&(tm=await cbInfo("headers",this.cat,"_alias"),this.parseheaderfrominfo(tm)),this.#alias||(this.#alias={}),this.#alias}get deriva(){return this.#deriva,this.#deriva||[]}async getmacro(riga){try{if("string"==typeof riga&&(riga={tipo:"M",contenuto:riga}),!riga||!riga.contenuto)return;const rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(riga.contenuto);if(!rr)return void errori.add("Macro non valida:"+riga.contenuto,riga);let macro=clean(rr[1],!0);macro.includes("$")&&(macro=await this.vari.valuta(macro));const pars=getcolonne(rr[2]),{name:name,cat:cat}=checkmu(macro,this.cat);this.cat=cat;const ky=`${cat}/${name}`;if(!this.macro[ky]){const tm=new Macro(this,name);await tm.load()?this.macro[ky]=tm:errori.add(`macro fail to load ${ky}`,riga)}return macro=this.macro[ky],macro?{macro:macro,pars:pars}:(errori.add(`macro non trovata ${ky}`,riga),{})}catch(error){errori.add(geterrdes(error),`ambiente.getmacro: ${riga?.contenuto}`)}}async getvariante(cod){const{name:name,cat:cat}=checkmu(cod,this.cat);let n2=name,altri={};if(cat==this.cat&&this.#alias&&this.#alias[name]&&(altri=this.#alias[name]||{},n2=altri.cod),await this.#checkelencovar(cat),this.varelenco[cat]&&!this.varelenco[cat].includes(name))return;const key=`${cat}/${n2}`;let vv;return this.varianti[key]?vv=this.varianti[key]:(vv=new Variante(this),await vv.load(key,cat),this.varianti[key]=vv),altri&&(altri.des&&(vv.des=altri.des),altri.vdef&&(vv.vdef=altri.vdef)),vv}async varcompila(v,callback){const xx=new Variante(this);if(await xx.load(v,this.cat,!0),xx.alias){(await this.getalias())[v]=xx.alias}callback("variants",{cod:v,des:xx.des||"",alias:xx.alias,info:xx.alias?"":JSON.stringify(getOggetto(xx,["amb"]))})}async macrocompila(v,callback){const mac=new Macro(this,v);await mac.loadAndCompile(`${v}.mu`);const t=mac.getmacro();callback("macros",{cod:v,info:JSON.stringify(t),isgenera:mac.isgenera,isheader:mac.isheader,iscodice:mac.iscodice})}async barrecompila(articolibarre,titolibarre,callback){const cc=new CodiceBarra;await cc.compila(articolibarre,titolibarre);for(const x in cc.barre){callback("barcodes",{cod:x,des:"",info:JSON.stringify(cc.barre[x])})}return cc}async tojson(d){let tm;return cbFunc&&(tm=await cbFunc("json",d)),tm}async compila(info,callback){if(callback){for(const v of info.var)await this.varcompila(v,callback);for(const v of info.mu)await this.macrocompila(v,callback);if(callback("infos",{cod:"info",des:info.cat,info:JSON.stringify({cat:info.cat,md:info.info})}),this.#headers=void 0,this.#alias=void 0,this.#deriva=void 0,this.#typos=void 0,cbInfo){const tm=await cbInfo("headers",this.cat,["_headers","_alias","_deriva","_typos"]);this.parseheaderfrominfo(tm)}this.#headers?callback("infos",{cod:"headers",des:"",info:JSON.stringify(this.#headers)}):logga("missing headers"),this.#alias&&callback("infos",{cod:"alias",des:"",info:JSON.stringify(this.#alias)}),this.#deriva&&callback("infos",{cod:"deriva",des:"",info:JSON.stringify(this.#deriva)}),this.#typos&&callback("infos",{cod:"typos",des:"tipologie",info:JSON.stringify(this.#typos)})}}async checkvarianti(cat,vars){if(!cat||!vars?.length)return;cat=checkname(cat),await this.#checkelencovar(cat);const t=this.varelenco[cat],vn=[];for(let v of vars){v=clean(v,!0);const nn=`${cat}/${v}`;this.varianti[nn]||t&&t.includes(v)&&vn.push(v)}if(vn.length&&cbGetVariante){const xv=await cbGetVariante(cat,vn);if(xv&&xv.length)for(const x of xv){const{name:name,content:content}=x,vv=new Variante(this);vv.setheader(name,cat),content&&await vv.loadContentExtended(content),this.varianti[vv.key]=vv}}}async getheaderfromdb(name){const totale=await cbInfo("header",this.cat,name,!this.#deriva);let{head:head,rows:rows,macros:macros,deriva:deriva,llvars:llvars}=totale;for(const r of rows)r.cod=clean(r.cod),r.alias=clean(r.alias),r.t=clean(r.t);if(!llvars){llvars=new Set;for(const r of rows)if("p"==r.tipo);else{const nn=r.alias?r.alias:r.cod;llvars.add(nn)}llvars=[...llvars]}this.#deriva||(this.#deriva=deriva),await this.#checkelencovar(this.cat),head.cod=clean(head.cod),head.rule=clean(head.rule),head.ruledef=head.ruledef||[];const vn=[],t=this.varelenco[this.cat];for(const nn of llvars)this.varianti[`${this.cat}/${nn}`]||t&&t.includes(nn)&&vn.push(nn);if(vn.length&&cbGetVariante){const vars=await cbGetVariante(this.cat,vn);if(vars&&vars.length)for(const x of vars){const{name:name,content:content}=x,vv=new Variante(this);vv.setheader(name,this.cat),content&&await vv.loadContentExtended(content),this.varianti[vv.key]=vv}}return{head:head,rows:rows,macros:macros}}async getlinkedmacros(rule,macros){const getkey=n=>n.includes("/")?n:`${this.cat}/${n}`,cl=[];let k;if(rule&&(k=getkey(rule),this.macro[k]||cl.push(rule)),macros&&"string"==typeof macros){const vv=macros.split(";");for(const v of vv)k=getkey(v),this.macro[k]||cl.push(v)}if(cl&&cl.length>0&&cbGetMacro){const tm=await cbGetMacro(this.cat,cl);if(tm&&tm.length>0)for(const x of tm){const m=new Macro(this,x.name);for(const t in x.content){const contenuto=x.content[t];m[t]=contenuto}this.macro[m.key]=m}}}async setruleheader(rule,pars,ruleset){const{name:name,cat:cat}=checkmu(rule,this.cat);ruleset&&ruleset.length&&(this.ruleset=toruleset(ruleset));const ky=`${cat}/${name}`;if(!this.macro[ky]){const totale=await this.getheaderfromdb(name),{head:head,rows:rows,macros:macros}=totale;await this.getlinkedmacros(head.rule,macros);const tm=new Macro(this,name);if(!head)return void errori.add("Missing rule: "+rule);if(head.rule){const k2=this.macro[`${cat}/${head.rule}`];if(k2)for(const x in k2)["cat","name","key"].includes(x)||(tm[x]=k2[x])}rows&&rows.length&&(tm.head=rows),this.macro[ky]=tm}this.ruleheader=ky;const mc=this.macro[ky];return errori.azzera(),await mc.setparametri(pars),mc}getruleheader(){return this.macro[this.ruleheader]}async setvariante(cod,opz){return await impostavariante(this,null,cod,opz)}async valuta(codice){let output;return"string"==typeof codice&&(codice=muClean(muClComments(codice,this.righevuote))),Array.isArray(codice)&&(logga("m1",codice),output=await muEval(this,null,codice)),output}setinfos(tm){tm&&(this.#headers=tm.headers,this.#alias=tm.alias,this.#deriva=void 0,this.#typos=tm.typos)}async splitteroggetti(name){let data=await this.getvariante(name),cl=[];return data?.rows&&Object.values(data.rows).forEach((v=>{cl.push({tipo:v.v[2]||"",cod:v.v[0]||"",des:v.v[1]||"",macro:v.v[4]||"",sps:parseInt(v.v[3])||0})})),cl.length||cl.push({tipo:"avob",cod:"__",des:"Vuoto",macro:"",sps:0}),cl}}function toJson(t){return JSON.stringify(t,null,2)}function clamp(n,min=-1/0,max=1/0){return(n=Number(n)||0)<min&&(n=min),n>max&&(n=max),n}function gettipocolonna(cod){return tipicolonna.find((x=>x.cod==cod))?.des||tipicolonna[0].des}function gettipofolder(cod){return tipicolonna.find((x=>x.cod==cod))?.folder||""}function newVariabile(){return new Variabile}async function newVariante(cod,cat,amb){const xx=new Variante(amb);return await xx.load(cod,cat),xx}function newAmbiente(cat,maxmillis=100){return new Ambiente(cat,maxmillis)}function newMacro(amb,name){return new Macro(amb,name)}function muValuta(mu,codice,azzera){azzera&&mu.azzera();return mu.valuta(codice)}function muInit(cat,cbGetMacro,cbGetVariante,cbFunc,cbInfo,cbGetFile,cbLogga){const mu=new Ambiente(cat);return setcallbacks(cbGetMacro,cbGetVariante,cbFunc,cbInfo,cbGetFile,cbLogga),mu}function muCompileScript(codice){return codice&&"object"==typeof codice?codice:codice.startsWith("{")&&codice.endsWith("}")||codice.startsWith("[")&&codice.endsWith("]")?JSON.stringify(codice):muClean(muClComments(codice))}async function muEvalScript(/** @type {Ambiente} */amb,codice,pars,reset=!0){if(codice=muCompileScript(codice),reset&&amb.azzera(),pars)for(const p of pars){const{v:v,o:o}=getcouple(p);amb.vari.add(v,o)}return{output:await muEval(amb,null,codice,{}),vari:amb.vari.dictionary,errori:errori}}const tonum=(s,dec=-1)=>{if(!s)return 0;let n=0;if("number"==typeof s)n=s||0;else if("string"==typeof s){const x=(s=s.replaceAll(",",".")).match(/^-?[0-9.]+$/);n=x&&x.length>0?Number(x[0])||0:muCalc(s)}if(dec>=0)switch(dec){case 0:n=Math.round(n);break;case 1:n=Math.round(10*n)/10;break;case 2:n=Math.round(100*n)/100;break;case 3:n=Math.round(1e3*n)/1e3;break;case 4:n=Math.round(1e4*n)/1e4;break;case 5:n=Math.round(1e5*n)/1e5;break;case 6:n=Math.round(1e6*n)/1e6}return n||0};Date.prototype.toInt||(Date.prototype.toInt=function(){return this.getDate()+100*(this.getMonth()+1)+1e4*this.getFullYear()}),Date.prototype.toFloat||(Date.prototype.toFloat=function(){return Math.floor(1e4*this.getDate()+1e6*(this.getMonth()+1)+1e8*this.getFullYear()+100*this.getHours()+this.getMinutes()+.5)/1e4});const mustr={mus:{variants:{cod:"s",des:"s",alias:"s",info:"s",md:"s",__pk:"cod"},extras:{tipo:"s",cod:"s",info:"s",__pk:"tipo, cod"},macros:{cod:"s",des:"s",info:"s",md:"s",def:"s",isgenera:"i",iscodice:"i",isheader:"i",__pk:"cod"},infos:{cod:"s",des:"s",info:"s",__pk:"cod"},barcodes:{cod:"s",des:"s",info:"s",__pk:"cod"}}};export{Ambiente,CodiceBarra,Macro,Variabile,Variante,checkmu,checkname,clamp,clean,dammivariante,errori,fromjson,getOggetto,getcolonne,getcouple,geterrdes,getheaddims,gettipocolonna,gettipofolder,hash,impostavariante,intvaluta,isJsonStr,isObject,muInit as jsTest,logga,muCalc,muClComments,muClean,muCompileScript,muEval,muEvalScript,muGenerate,muInit,muLimits,muParsecode,muValuta,mustr,newAmbiente,newMacro,newVariabile,newVariante,parselimitifromdb,parselimitifromrule,parsevar,poppars,pushpars,quote,setOggetto,sortrows,testsync,tipicolonna,tipifree,tipiheader,tk,toCadPars,toJson,tonum,xdt};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markuno_lib",
3
- "version": "1.2.31",
3
+ "version": "1.2.32",
4
4
  "description": "Croswil Markuno Language Lib",
5
5
  "author": "Croswil SRL",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -238,12 +238,16 @@ export var SP: Readonly<{
238
238
  od: string;
239
239
  };
240
240
  tipi: {
241
+ x: string;
242
+ s: string;
241
243
  i: string;
242
244
  a: string;
243
245
  d: string;
244
- s: string;
245
- x: string;
246
246
  };
247
+ tipilocks: {
248
+ cod: string;
249
+ des: string;
250
+ }[];
247
251
  tipoalign: {
248
252
  l: string;
249
253
  c: string;
@@ -15,6 +15,7 @@ export class Ambiente {
15
15
  };
16
16
  azzera(mode?: boolean): void;
17
17
  /** @type {Variabile} */
18
+ imgpreview: {};
18
19
  vari: Variabile;
19
20
  ruleset: {};
20
21
  ruleheader: string;
@@ -25,6 +26,8 @@ export class Ambiente {
25
26
  varelenco: {};
26
27
  macroelenco: {};
27
28
  scripts: {};
29
+ setimgpreview(cod: any, img: any): void;
30
+ getimgpreview(cod: any): any;
28
31
  setfndot(fndotcallback: any): void;
29
32
  fndotcallback: any;
30
33
  parseheaderfrominfo(tm: any): void;