UNPKG

@tracespace/renderer

Version:

Render @tracespace/plotter image trees as SVGs.

3 lines (2 loc) 23.2 kB
(function(h,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@tracespace/plotter"),require("@tracespace/xml-id")):typeof define=="function"&&define.amd?define(["exports","@tracespace/plotter","@tracespace/xml-id"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h.TracespaceRenderer={},h.TracespacePlotter,h.TracespaceXmlId))})(this,function(h,g,J){"use strict";class C{constructor(l,t,o){this.property=l,this.normal=t,o&&(this.space=o)}}C.prototype.property={},C.prototype.normal={},C.prototype.space=null;function T(n,l){const t={},o={};let r=-1;for(;++r<n.length;)Object.assign(t,n[r].property),Object.assign(o,n[r].normal);return new C(t,o,l)}function w(n){return n.toLowerCase()}class m{constructor(l,t){this.property=l,this.attribute=t}}m.prototype.space=null,m.prototype.boolean=!1,m.prototype.booleanish=!1,m.prototype.overloadedBoolean=!1,m.prototype.number=!1,m.prototype.commaSeparated=!1,m.prototype.spaceSeparated=!1,m.prototype.commaOrSpaceSeparated=!1,m.prototype.mustUseProperty=!1,m.prototype.defined=!1;let Q=0;const i=b(),c=b(),R=b(),e=b(),s=b(),v=b(),f=b();function b(){return 2**++Q}const P=Object.freeze(Object.defineProperty({__proto__:null,boolean:i,booleanish:c,commaOrSpaceSeparated:f,commaSeparated:v,number:e,overloadedBoolean:R,spaceSeparated:s},Symbol.toStringTag,{value:"Module"})),M=Object.keys(P);class L extends m{constructor(l,t,o,r){let u=-1;if(super(l,t),B(this,"space",r),typeof o=="number")for(;++u<M.length;){const a=M[u];B(this,M[u],(o&P[a])===P[a])}}}L.prototype.defined=!0;function B(n,l,t){t&&(n[l]=t)}const nn={}.hasOwnProperty;function x(n){const l={},t={};let o;for(o in n.properties)if(nn.call(n.properties,o)){const r=n.properties[o],u=new L(o,n.transform(n.attributes||{},o),r,n.space);n.mustUseProperty&&n.mustUseProperty.includes(o)&&(u.mustUseProperty=!0),l[o]=u,t[w(o)]=o,t[w(u.attribute)]=o}return new C(l,t,n.space)}const I=x({space:"xlink",transform(n,l){return"xlink:"+l.slice(5).toLowerCase()},properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),N=x({space:"xml",transform(n,l){return"xml:"+l.slice(3).toLowerCase()},properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function U(n,l){return l in n?n[l]:l}function z(n,l){return U(n,l.toLowerCase())}const F=x({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:z,properties:{xmlns:null,xmlnsXLink:null}}),H=x({transform(n,l){return l==="role"?l:"aria-"+l.slice(4).toLowerCase()},properties:{ariaActiveDescendant:null,ariaAtomic:c,ariaAutoComplete:null,ariaBusy:c,ariaChecked:c,ariaColCount:e,ariaColIndex:e,ariaColSpan:e,ariaControls:s,ariaCurrent:null,ariaDescribedBy:s,ariaDetails:null,ariaDisabled:c,ariaDropEffect:s,ariaErrorMessage:null,ariaExpanded:c,ariaFlowTo:s,ariaGrabbed:c,ariaHasPopup:null,ariaHidden:c,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:s,ariaLevel:e,ariaLive:null,ariaModal:c,ariaMultiLine:c,ariaMultiSelectable:c,ariaOrientation:null,ariaOwns:s,ariaPlaceholder:null,ariaPosInSet:e,ariaPressed:c,ariaReadOnly:c,ariaRelevant:null,ariaRequired:c,ariaRoleDescription:s,ariaRowCount:e,ariaRowIndex:e,ariaRowSpan:e,ariaSelected:c,ariaSetSize:e,ariaSort:null,ariaValueMax:e,ariaValueMin:e,ariaValueNow:e,ariaValueText:null,role:null}}),ln=x({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:z,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:v,acceptCharset:s,accessKey:s,action:null,allow:null,allowFullScreen:i,allowPaymentRequest:i,allowUserMedia:i,alt:null,as:null,async:i,autoCapitalize:null,autoComplete:s,autoFocus:i,autoPlay:i,capture:i,charSet:null,checked:i,cite:null,className:s,cols:e,colSpan:null,content:null,contentEditable:c,controls:i,controlsList:s,coords:e|v,crossOrigin:null,data:null,dateTime:null,decoding:null,default:i,defer:i,dir:null,dirName:null,disabled:i,download:R,draggable:c,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:i,formTarget:null,headers:s,height:e,hidden:i,high:e,href:null,hrefLang:null,htmlFor:s,httpEquiv:s,id:null,imageSizes:null,imageSrcSet:null,inputMode:null,integrity:null,is:null,isMap:i,itemId:null,itemProp:s,itemRef:s,itemScope:i,itemType:s,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:i,low:e,manifest:null,max:null,maxLength:e,media:null,method:null,min:null,minLength:e,multiple:i,muted:i,name:null,nonce:null,noModule:i,noValidate:i,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:i,optimum:e,pattern:null,ping:s,placeholder:null,playsInline:i,poster:null,preload:null,readOnly:i,referrerPolicy:null,rel:s,required:i,reversed:i,rows:e,rowSpan:e,sandbox:s,scope:null,scoped:i,seamless:i,selected:i,shape:null,size:e,sizes:null,slot:null,span:e,spellCheck:c,src:null,srcDoc:null,srcLang:null,srcSet:null,start:e,step:null,style:null,tabIndex:e,target:null,title:null,translate:null,type:null,typeMustMatch:i,useMap:null,value:c,width:e,wrap:null,align:null,aLink:null,archive:s,axis:null,background:null,bgColor:null,border:e,borderColor:null,bottomMargin:e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:i,declare:i,event:null,face:null,frame:null,frameBorder:null,hSpace:e,leftMargin:e,link:null,longDesc:null,lowSrc:null,marginHeight:e,marginWidth:e,noResize:i,noHref:i,noShade:i,noWrap:i,object:null,profile:null,prompt:null,rev:null,rightMargin:e,rules:null,scheme:null,scrolling:c,standby:null,summary:null,text:null,topMargin:e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:e,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:i,disableRemotePlayback:i,prefix:null,property:null,results:e,security:null,unselectable:null}}),en=x({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:U,properties:{about:f,accentHeight:e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:e,amplitude:e,arabicForm:null,ascent:e,attributeName:null,attributeType:null,azimuth:e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:e,by:null,calcMode:null,capHeight:e,className:s,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:e,diffuseConstant:e,direction:null,display:null,dur:null,divisor:e,dominantBaseline:null,download:i,dx:null,dy:null,edgeMode:null,editable:null,elevation:e,enableBackground:null,end:null,event:null,exponent:e,externalResourcesRequired:null,fill:null,fillOpacity:e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:v,g2:v,glyphName:v,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:e,horizOriginX:e,horizOriginY:e,id:null,ideographic:e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:e,k:e,k1:e,k2:e,k3:e,k4:e,kernelMatrix:f,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:e,overlineThickness:e,paintOrder:null,panose1:null,path:null,pathLength:e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:s,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:e,pointsAtY:e,pointsAtZ:e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:f,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:f,rev:f,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:f,requiredFeatures:f,requiredFonts:f,requiredFormats:f,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:e,specularExponent:e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:e,strikethroughThickness:e,string:null,stroke:null,strokeDashArray:f,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:e,strokeOpacity:e,strokeWidth:null,style:null,surfaceScale:e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:f,tabIndex:e,tableValues:null,target:null,targetX:e,targetY:e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:f,to:null,transform:null,u1:null,u2:null,underlinePosition:e,underlineThickness:e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:e,values:null,vAlphabetic:e,vMathematical:e,vectorEffect:null,vHanging:e,vIdeographic:e,version:null,vertAdvY:e,vertOriginX:e,vertOriginY:e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),on=/^data[-\w.:]+$/i,$=/-[a-z]/g,tn=/[A-Z]/g;function rn(n,l){const t=w(l);let o=l,r=m;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&on.test(l)){if(l.charAt(4)==="-"){const u=l.slice(5).replace($,un);o="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=l.slice(4);if(!$.test(u)){let a=u.replace(tn,an);a.charAt(0)!=="-"&&(a="-"+a),l="data"+a}}r=L}return new r(o,l)}function an(n){return"-"+n.toLowerCase()}function un(n){return n.charAt(1).toUpperCase()}T([N,I,F,H,ln],"html");const sn=T([N,I,F,H,en],"svg"),j=/[#.]/g;function cn(n,l){const t=n||"",o={};let r=0,u,a;for(;r<t.length;){j.lastIndex=r;const d=j.exec(t),S=t.slice(r,d?d.index:t.length);S&&(u?u==="#"?o.id=S:Array.isArray(o.className)?o.className.push(S):o.className=[S]:a=S,r+=S.length),d&&(u=d[0],r++)}return{type:"element",tagName:a||l||"div",properties:o,children:[]}}function V(n){const l=String(n||"").trim();return l?l.split(/[ \t\n\r\f]+/g):[]}function _(n){const l=[],t=String(n||"");let o=t.indexOf(","),r=0,u=!1;for(;!u;){o===-1&&(o=t.length,u=!0);const a=t.slice(r,o).trim();(a||!u)&&l.push(a),r=o+1,o=t.indexOf(",",r)}return l}const pn=new Set(["menu","submit","reset","button"]),O={}.hasOwnProperty;function dn(n,l,t){const o=t&&mn(t);return function(u,a,...d){let S=-1,p;if(u==null)p={type:"root",children:[]},d.unshift(a);else if(p=cn(u,l),p.tagName=p.tagName.toLowerCase(),o&&O.call(o,p.tagName)&&(p.tagName=o[p.tagName]),gn(a,p.tagName)){let k;for(k in a)O.call(a,k)&&hn(n,p.properties,k,a[k])}else d.unshift(a);for(;++S<d.length;)A(p.children,d[S]);return p.type==="element"&&p.tagName==="template"&&(p.content={type:"root",children:p.children},p.children=[]),p}}function gn(n,l){return n==null||typeof n!="object"||Array.isArray(n)?!1:l==="input"||!n.type||typeof n.type!="string"?!0:"children"in n&&Array.isArray(n.children)?!1:l==="button"?pn.has(n.type.toLowerCase()):!("value"in n)}function hn(n,l,t,o){const r=rn(n,t);let u=-1,a;if(o!=null){if(typeof o=="number"){if(Number.isNaN(o))return;a=o}else typeof o=="boolean"?a=o:typeof o=="string"?r.spaceSeparated?a=V(o):r.commaSeparated?a=_(o):r.commaOrSpaceSeparated?a=V(_(o).join(" ")):a=G(r,r.property,o):Array.isArray(o)?a=o.concat():a=r.property==="style"?fn(o):String(o);if(Array.isArray(a)){const d=[];for(;++u<a.length;)d[u]=G(r,r.property,a[u]);a=d}r.property==="className"&&Array.isArray(l.className)&&(a=l.className.concat(a)),l[r.property]=a}}function A(n,l){let t=-1;if(l!=null)if(typeof l=="string"||typeof l=="number")n.push({type:"text",value:String(l)});else if(Array.isArray(l))for(;++t<l.length;)A(n,l[t]);else if(typeof l=="object"&&"type"in l)l.type==="root"?A(n,l.children):n.push(l);else throw new Error("Expected node, nodes, or string, got `"+l+"`")}function G(n,l,t){if(typeof t=="string"){if(n.number&&t&&!Number.isNaN(Number(t)))return Number(t);if((n.boolean||n.overloadedBoolean)&&(t===""||w(t)===w(l)))return!0}return t}function fn(n){const l=[];let t;for(t in n)O.call(n,t)&&l.push([t,n[t]].join(": "));return l.join("; ")}function mn(n){const l={};let t=-1;for(;++t<n.length;)l[n[t].toLowerCase()]=n[t];return l}const y=dn(sn,"g",["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"]);function D(n){return n.type===g.IMAGE_SHAPE?yn(n):Sn(n)}function yn(n){const{shape:l}=n;return E(l)}function E(n){switch(n.type){case g.CIRCLE:{const{cx:l,cy:t,r:o}=n;return y("circle",{cx:l,cy:-t,r:o})}case g.RECTANGLE:{const{x:l,y:t,xSize:o,ySize:r,r:u}=n;return y("rect",{x:l,y:-t-r,width:o,height:r,rx:u,ry:u})}case g.POLYGON:{const l=n.points.map(([t,o])=>`${t},${-o}`).join(" ");return y("polygon",{points:l})}case g.OUTLINE:return y("path",{d:q(n.segments)});case g.LAYERED_SHAPE:{const l=g.BoundingBox.fromShape(n),t=J.random(),o=[];let r=[];for(const[u,a]of n.shapes.entries())if(a.erase&&!g.BoundingBox.isEmpty(l)){const d=`${t}__${u}`;o.push(y("clipPath",{id:d},[E(a)])),r=[y("g",{clipPath:`url(#${d})`},r)]}else r.push(E(a));return o.length>0&&r.unshift(y("defs",o)),r.length===1?r[0]:y("g",r)}default:return y("g")}}function Sn(n){const l=q(n.segments),t=n.type===g.IMAGE_PATH?{strokeWidth:n.width,fill:"none"}:{};return y("path",{...t,d:l})}function q(n){const l=[];for(const[t,o]of n.entries()){const r=n[t-1],{start:u,end:a}=o;if((!r||!g.positionsEqual(r.end,u))&&l.push(`M${u[0]} ${-u[1]}`),o.type===g.LINE)l.push(`L${a[0]} ${-a[1]}`);else if(o.type===g.ARC){const d=o.end[2]-o.start[2],S=Math.abs(d),{center:p,radius:k}=o,Y=d<0?"1":"0";let Z=S<=Math.PI?"0":"1";if(S===2*Math.PI){const[vn,xn]=[2*p[0]-a[0],-(2*p[1]-a[1])];Z="0",l.push(`A${k} ${k} 0 0 ${Y} ${vn} ${xn}`)}l.push(`A${k} ${k} 0 ${Z} ${Y} ${a[0]} ${-a[1]}`)}}return l.join("")}const W={version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},K={"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"0","fill-rule":"evenodd","clip-rule":"evenodd",fill:"currentColor",stroke:"currentColor"};function kn(n,l){const{units:t,size:o,children:r}=n;return l=l??X(o),y("svg",{...W,...K,viewBox:l.join(" "),width:`${l[2]}${t}`,height:`${l[3]}${t}`},r.map(D))}function bn(n){return y("g",{},n.children.map(D))}function X(n){return g.BoundingBox.isEmpty(n)?[0,0,0,0]:[n[0],-n[3],n[2]-n[0],n[3]-n[1]]}h.BASE_IMAGE_PROPS=K,h.BASE_SVG_PROPS=W,h.render=kn,h.renderFragment=bn,h.renderGraphic=D,h.sizeToViewBox=X,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=tracespace-renderer.umd.cjs.map