graphane
Version:
Data Visualization Microframework
1 lines • 30.2 kB
JavaScript
/* graphane - 1.0.1 [component] */ (()=>{var un="function",de="undefined",S="object",L="string",W="array",v="number",k="boolean",ln="date",fn="symbol",X="",at=",";var hn=";",H=(t,e)=>typeof t===e,J=(t,e)=>t instanceof e,y=t=>H(t,S),N=t=>H(t,L),f=t=>H(t,un),pe=t=>H(t,v)&&!isNaN(t),ct=t=>!Number.isNaN(t),g=t=>H(t,de),me=t=>H(t,fn),ye=t=>H(t,k),P=t=>Array.isArray(t),Mt=t=>J(t,Date)&&!isNaN(t),w=t=>t===null,ut=t=>t.replace(/-([a-z0-9])/g,(e,n)=>n.toUpperCase());function dn(t){if(N(t))try{return JSON.parse(`{${t.replace(/^\s*{/,"").replace(/}\s*$/,"").split(/((?:[^;^,"']|"[^"]*"|'[^']*')+)/).filter(e=>!["",";",","].includes(e.trim())).map(e=>e.split(":")).map(e=>`"${e[0].trim()}":${M(e[1].trim(),void 0,!0)}`).join(",")}}`)}catch{try{return M(t)}catch(n){console.error(n);return}}if(y(t))return t}function ge(t){if(N(t))return t.trim().startsWith("[")?(t.match(/\[(.*?)[^\]]]/g)||[]).map(e=>ge(e.substring(1,e.length-1))):t.split(/[,;]/).map(e=>M(e.trim()));if(P(t))return t}function M(t,e,n=!1){if(!N(t))return t;if(t=pn(t.trim()),e===W)return ge(t);if(e===S)return dn(t);if(g(e)||e===v){if(g(t)||t==="")return;let r=+t;if(ct(r)||e===v)return r}if(g(e)||e===k){if(t==="true")return!0;if(t==="false")return!1;if(e===k)return t==="0"?!1:!!t}if(e===ln){try{let r=new Date(t);if(ct(r.getTime()))return r}catch{}return}if(g(e)||e===L)return n?`"${t}"`:t}function pn(t){return t[0]==="'"&&t[t.length-1]==="'"||t[0]==='"'&&t[t.length-1]==='"'?t.substring(1,t.length-1):t}function lt(t){return/^\s*{/.test(t)&&/}\s*$/.test(t)}function ft(t){return/^\s*\[/.test(t)&&/]\s*$/.test(t)}function ht(t){let e=[],n=t.split(/(\r\n|\r|\n)/).map(r=>r.trim()).filter(r=>r);return n.length===0?[]:n.length===1?M(n[0]):n.reduce((r,i,o)=>{let c={},s=i.split(/((?:[^;^,"']|"[^"]*"|'[^']*')+)/).filter(a=>![X,hn,at].includes(a.trim()));return o===0?(e=[...s.map(a=>M(a))],r):(s.forEach((a,u)=>{c[e[u]]=M(a)}),r.push(c),r)},[])}function K(t){let e=`return (${t});`,n=new Function(e)();return f(n)?n():n}var Ee=new WeakSet,rt=!1,Pt=(t,e)=>!y(t)||w(t)||!f(e)?t:function n(r){if(Ee.has(r))return r;for(let o in r)y(r[o])&&!w(r[o])&&(r[o]=n(r[o]));let i=new Proxy(r,{get(o,c){let s=Reflect.get(r,c);return f(s)&&Mt(o)&&N(c)&&c.substring(0,3)==="set"&&f(e)&&(s=function(...a){let u=Reflect.get(o,c).apply(o,a);return!rt&&e(t),u}),Mt(o)?s.bind(o):s},set(o,c,s){let a,u=o[c]===s;return y(s)&&!w(s)?a=Reflect.set(o,c,n(s)):a=Reflect.set(o,c,s),!rt&&!u&&e(t),a},deleteProperty(o,c){let s=Reflect.deleteProperty(o,c);return!rt&&e(t),s}});return Ee.add(i),i}(t);Pt.stop=()=>rt=!0;Pt.start=()=>rt=!1;var dt=Pt;var it=!1,pt=!0;function mn(t){return t===null?null:t.constructor?new t.constructor:{}}function B(t){if(!y(t))return t;let e=t===null?null:Object.assign(mn(t),t);for(let n in e)y(e[n])&&(e[n]=B(e[n]));return e}function xe(t,e){let n=[],r=[];function i(c,s){if(w(c)||w(s))return it;if(f(c.valueOf)&&f(s.valueOf)&&(c!==c.valueOf()||s!==s.valueOf()))return c.valueOf()===s.valueOf()&&c.constructor===s.constructor;if(n.indexOf(c)>-1&&r.indexOf(s)>-1)return pt;let a=Object.keys(c),u=Object.keys(s);if(a.length!==u.length)return it;if(a.length>0){n.push(c),r.push(s);let d=a.length;for(;d--;){let h=a[d];if(!o(c[h],s[h]))return it}}return pt}function o(c,s){if(c===s)return pt;let a=typeof c;return a!==typeof s?it:a===v&&isNaN(c)&&isNaN(s)?pt:a===S?i(c,s):it}return o(t,e)}function Ne(t,e){let n=t,r=N(e)?e.split("."):e;for(let i=0;i<r.length;i++){if(g(n[r[i]]))return;n=n[r[i]]}return n}function mt(t,...e){if(typeof t!="object"||t===null)throw new TypeError("Target must be a non-null object");return e.forEach(n=>{typeof n!="object"||n===null||Object.keys(n).forEach(r=>{let i=n[r],o=t[r];i&&typeof i=="object"?((!o||typeof o!="object")&&(t[r]=Array.isArray(i)?[]:{}),mt(t[r],i)):t[r]=i})}),t}var Ut=globalThis.GRAPHANE_PREFIX||"g-",E=Symbol(),G=Symbol(),$=Symbol(),It=Object.defineProperty;function yn(t,e,n,r=!1){if(!(t.ready===!1||!e))if(r)n?t.setAttribute(e,X):t.removeAttribute(e);else{let i=w(n)||g(n)?X:n.toString();t.hasAttribute(e)&&t.getAttribute(e)!==i&&t.setAttribute(e,i)}}function gn(t){this[E]={};let e=t;do{let n=yt.get(e);for(let r in n)if(n.hasOwnProperty(r)&&this.hasOwnProperty(r)){let i=this[r];delete this[r],this[r]=g(i)?B(n[r]):i}else r in this[E]||(this[E][r]=B(n[r]));e=Object.getPrototypeOf(e)}while(e!==HTMLElement)}function En(){new MutationObserver(t=>{t.some(e=>!e.attributeName)&&this[$]("update"),(g(this.ready)||this.ready)&&f(this[G])&&this[G](t)}).observe(this,{attributes:!0,childList:!0,subtree:!0,characterData:!0})}var yt=new WeakMap,Z=class extends HTMLElement{constructor(){super(),gn.call(this,new.target),f(this[G])&&En.call(this)}[$](e,n={},r=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n,composed:r}))}};function xn(t,e){e.propertyName||(e.propertyName=ut(e.name)),$e(t,{...e,name:e.propertyName,attribute:e.name});let n=Object.getPrototypeOf(t),r="observedAttributes",i=Object.getOwnPropertyDescriptor(t,r),o=Object.getOwnPropertyDescriptor(n,r),c=i?i.get:void 0;It(t,r,$n(t,e,n,c,i,o));let s="attributeChangedCallback",a=Object.getOwnPropertyDescriptor(t.prototype,s),u=Object.getOwnPropertyDescriptor(n.prototype,s),d=a?a.value:void 0;It(t.prototype,s,Nn(e,d,u))}function Nn(t,e,n){return{value:function(r,i,o){if(t.name===r){let c=t.propertyName;this[c]!==o&&(t.type===k?this[c]=this.hasAttribute(t.name):this[c]=M(o,t.type))}else e&&e.apply(this,arguments);n?.value&&n.value.apply(this,arguments)},enumerable:!1,writable:!0,configurable:!0}}function $n(t,e,n,r,i,o){let c={enumerable:!1,configurable:!0};return i?o?c.get=function(){return[e.name,...r.call(t),...o.get.call(n)]}:c.get=function(){return[e.name,...r.call(t)]}:c.get=o?function(){return[e.name,...o.get.call(n)]}:function(){return[e.name]},c}function $e(t,e){It(t.prototype,e.name,{set:Se(e),get:An(e),configurable:!0,enumerable:!1}),yt.has(t)||yt.set(t,{}),yt.get(t)[e.name]=e.value}function Sn(t,e){w(t.posUpdateEvent)||(t.posUpdateEvent?this[$](t.posUpdateEvent,{[t.name]:e}):this[$]("update",{[t.name]:e})),f(t.posUpdate)?t.posUpdate.call(this,e):f(this[t.posUpdate])&&this[t.posUpdate]()}function Se(t){return function(e){let n=this[E];f(t.preUpdate)&&!t.preUpdate.call(this,e)||(t.schema&&(dt.stop(),e=t.schema.normalize(e),dt.start()),!(!y(e)&&xe(n[t.name],e))&&(f(t.set)?t.set.call(this,e):n[t.name]=N(e)&&t.type?M(e,t.type):e,t.attribute&&![W,S].includes(t.type)&&yn(this,t.attribute,e,t.type===k),Sn.call(this,t,e)))}}function An(t){return function(){if(f(t.get))return t.get.call(this);{let e=this[E];switch(t.type){case v:return g(e[t.name])?void 0:Number(e[t.name]);case k:return!!e[t.name];case S:case W:return dt(e[t.name]||(t.type===S?{}:[]),n=>Se(t).call(this,n));default:return e[t.name]}}}}function Tn(t,e){e=Ut+e.toLowerCase(),customElements.get(e)||customElements.define(e,t)}function Ae(t,e={}){return e.prop=(...n)=>(n.forEach(r=>$e(t,{...r})),e),e.attr=(...n)=>(n.forEach(r=>xn(t,{...r})),e),e.tag=n=>(Tn(t,n),e),e.extension=e.ext=n=>(n.call(e,e,t),e),e}Z.CHANGE=G;Z.FIRE_EVENT=$;function Dt(t,e){let n=new WeakMap;return function(...r){clearTimeout(n.get(this)),n.set(this,setTimeout(()=>{t.apply(this,r)},e))}}function Ft(t,e){let n=new WeakMap,r=[];return function(...i){return clearTimeout(n.get(this)),new Promise((o,c)=>{r.push({resolve:o,reject:c}),n.set(this,setTimeout(()=>{try{let s=t.apply(this,i);r.forEach(a=>a.resolve(s))}catch(s){r.forEach(a=>a.reject(s))}finally{r.length=0}},e))})}}function Vt(t,e){return function(...n){if(t.apply(this,n))return e.apply(this,n)}}function kt(t,e){return function(...n){let r=t.apply(this,n);return f(r.then)?r.then(i=>e.call(this,i)||i):e.call(this,r)||r}}var Te=1,Bt=Symbol(),Gt=Symbol(),Q=Symbol(),b=Symbol(),we=Symbol(),Ht=Symbol(),be=(t,e)=>t[e]?.forEach(n=>f(n)&&n.apply(t)),R=class extends Z{constructor(e){super(),this.attachShadow({mode:"open"}),this[E].ready=e||!1,this[E].rendered=!1,g(e)&&(this.ready=!0)}get ready(){return this[E].ready}set ready(e){let n=this[E],r=n.ready;n.ready=!!e,r===!1&&n.ready===!0&&(this[$]("ready",{ready:!0}),f(this[b])&&this[b]())}get rendered(){return this[E].rendered}set rendered(e){let n=this[E],r=n.rendered;n.rendered=!!e,r===!1&&n.rendered===!0&&this[$]("render",{rendered:!0})}connectedCallback(){let e=this.getBoundingClientRect(),n=getComputedStyle(this).flexDirection,r=()=>{let{width:i,height:o}=this.getBoundingClientRect(),c=getComputedStyle(this).flexDirection;(i!==e.width||o!==e.height||c!==n)&&(f(this[we])&&this[we](i,o,i-e.width,o-e.height),e={width:i,height:o},n=c,this[$]("resize",e)),this[E]._resizeObserver=window.requestAnimationFrame(r)};r(),be(this,Bt)}disconnectedCallback(){window.cancelAnimationFrame(this[E]._resizeObserver),be(this,Gt)}};R.prototype[Bt]=[];R.prototype[Gt]=[];function wn(t,e){let n={name:e.name.startsWith("--")?e.name:`--${Ut}${e.name}`,initialValue:e.initialValue??e.value??"",syntax:e.syntax??"*",inherits:e.inherits??!0};t.prototype[Ht]||(t.prototype[Ht]={}),t.prototype[Ht][n.name]=n}function bn(t){if(f(t.prototype[b])){let e=t.prototype[b];t.prototype[b]=Vt(function(){return this.rendered=!1,this.ready},Ft(kt(async function(){return e.apply(this)},function(n){this.rendered=n!==!1,this.rendered&&f(this[Q])&&this[Q]()}),Te))}if(f(t.prototype[Q])){let e=t.prototype[Q];t.prototype[Q]=Vt(function(n){return n&&(this[E].rendered=!0),this.ready&&this[E].rendered},Ft(kt(async function(...n){return e.apply(this,n)},function(){this[$]("refresh")}),Te))}}function gt(t){bn(t);let e=Ae(t,{style:(...n)=>(n.forEach(r=>wn(t,{...r})),e)});return e}R.RENDER=b;R.REFRESH=Q;R.ONCONNECT=Bt;R.ONDISCONNECT=Gt;var Rn="intersection.enter",On="intersection.exit",Et=Symbol();function vn(t){let e=r=>this.dispatchEvent(new CustomEvent(r,{bubbles:!0,cancelable:!0,composed:!0})),n=!1;this[Et]&&this[Et].disconnect(),this[Et]=new IntersectionObserver(r=>{r.forEach(i=>{i.isIntersecting&&i.intersectionRatio>=t?n||(n=!0,e(Rn)):(n=!1,e(On))})},{root:null,rootMargin:"0px",threshold:Array(21).fill(0).map((r,i)=>i*.05)}),this[Et].observe(this._el||this)}var zt=vn;var Re=Symbol();function Cn(t){t.attr({name:"intersection-once-class",type:L,value:""}).attr({name:"intersection-class",type:L,value:""}).attr({name:"intersection-ratio",type:v,value:0,posUpdate:_n})}var Oe=(t,e)=>e&&e.split(/\s+/).forEach(n=>t.add(n)),Ln=(t,e)=>e&&e.split(/\s+/).forEach(n=>t.remove(n)),ve=(t,e)=>{e.preventDefault();let n=()=>{t.removeEventListener("render",n),t[$](e.type,e.detail,e.composed)};t.addEventListener("render",n)};function _n(){let t=this[E];if(this[Re])return zt.call(this,t.intersectionRatio);this[Re]=!0;let e=this.classList;this.addEventListener("intersection.enter",n=>{Oe(e,t.intersectionOnceClass),Oe(e,t.intersectionClass),this.rendered||ve(this,n)}),this.addEventListener("intersection.exit",n=>{Ln(e,t.intersectionClass),this.rendered||ve(this,n)}),zt.call(this,t.intersectionRatio)}var Ce=Cn;var Kt="gSVGObject",Mn="http://www.w3.org/2000/svg",Pn="svg",qt="d",Le="transform",Me="appendChild",Xt="insertBefore",_e="insertAdjacentElement",Pe="attach",Ie="innerHTML",Yt=new WeakMap,Wt=new Set,In=t=>me(t)||t.startsWith("_")||["el","gSVG","then"].includes(t),Un=()=>Kt+Math.random().toString(32).substring(2),Zt=t=>y(t)&&!w(t)&&t[Symbol.toStringTag]===Kt,Dn=t=>At(document.createElementNS(Mn,t)),xt=t=>N(t)?Dn(t):y(t)&&t!==null?Zt(t)?t:At(t):t,Fn=t=>({content:Ie,source:"outerHTML",parent:"parentElement",next:"nextElementSibling",previous:"previousElementSibling",add:Me,addBefore:Xt})[t]||t,Vn=t=>["append","before","after",Me,Xt,_e].includes(t)?function(...e){let n=[],r=[],i=[];return t===_e?(n.push(e[0]),r.push(xt(e[1]))):t===Xt?(r.push(xt(e[0])),i.push(e[1]||this.firstChild||null)):r.push(...e.map(xt)),r.every(o=>o?._el)?(this[t](...n,...r.map(o=>o._el),...i),r.forEach(o=>o._el.dispatchEvent(new Event(Pe))),r.length>1?r:r[0]):null}:null,St=class{constructor(e){this._el=e,this.gSVG=z}get[Symbol.toStringTag](){return Kt}get el(){return this._el}attachTo(e){return(y(e)?Zt(e)?e._el:e:document.querySelector(e)).appendChild(this._el),this._el.dispatchEvent(new Event(Pe)),this}id(e){return e?(this._el.setAttribute("id",e),this):this._el.id||(this._el.id=Un())}ref(){return`#${this.id()}`}url(){return`url(${this.ref()})`}parents(){let e=[],n=this;for(;n=n.parentElement();)e.push(n);return e}top(){return this.parents().pop()||this}},At=t=>{if(!y(t)||w(t))return null;if(Yt.has(t))return Yt.get(t);let e=new Proxy(new St(t),{get(n,r){if(In(r))return n[r];if(!g(n[r]))return(...c)=>(D(e,r,c),n[r].call(e,...c));if([qt,Le,"$"+qt,"$"+Le].includes(r)){let c="";r[0]==="$"&&(r=r.substring(1));let a=r===qt?kn:Hn,u=new Proxy(d=>(D(e,r,[d]),g(d)?t.getAttribute(r):(d?t.setAttribute(r,d):t.removeAttribute(r),e)),{get(d,h){return h in d?Reflect.get(d,h):(...T)=>{if(h===Symbol.toPrimitive){let I=c;return c="",I}return c+=a(e,h,T),t?.setAttribute(r,c),u}}});return u}let i=Fn(r),o=Vn(i)||t[i];return f(o)?(...c)=>{D(e,r,c);let s=o.call(t,...c);return g(s)?e:De(s)}:Ue(t,i,e)}});return Yt.set(t,e),e},Ue=(t,e,n,r)=>{let i=e.replace(/_/g,"-"),o=(...c)=>{if(D(n,r?`${r}.${e}`:e,c),c.length===0){let a=t?.hasAttribute&&t.hasAttribute(i)?t.getAttribute(i):t[i];return De(a)}let s=c[0];if(J(t,CSSStyleDeclaration))return t[i]=s,n;if(i in t&&!Wt.has(i)){let a=t[i];if(String(a)===String(s))return n;try{t[i]=s}catch{Wt.add(i)}if(y(t[i])&&t[i]===s||t[i]!==a||i===Ie)return n;Wt.add(i)}return s!==0&&!s?t?.removeAttribute&&t.removeAttribute(i):t?.setAttribute&&t.setAttribute(i,ye(s)?"":String(c)),n};return new Proxy(o,{get(c,s){let a=t[i][s];return f(a)?(...u)=>(D(n,`${e}.${s}`,u),a.call(t[i],...u)||n):Ue(t[i],s,n,i)},set(c,s,a){return t[i][s]=a,!0}})},De=t=>J(t,HTMLCollection)||J(t,NodeList)?[...t].map(e=>At(e)):J(t,SVGElement)?At(t):N(t)?t===""||isNaN(t)?t:Number(t):t,Fe=[],D=(t,e,n,r=[])=>{for(let i of Fe)i(z,t,e,n,r)},Nt={},kn=(t,e,n)=>(D(t,`d.${e}`,n,Object.keys(Nt).map(r=>`d.${r}`)),Nt[e]?Nt[e].apply(t,n):`${e}${n.join(at)}`),Hn=(t,e,n)=>(D(t,`transform.${e}`,n),`${e}(${n.join(at)})`);function z(t){return D(null,X,[t]),xt(g(t)?Pn:t)}z.isWrapped=Zt;var $t=t=>e=>f(e)?e(t):Object.assign(t,e),Jt={install:Ve,extendConstructor:$t(z),extendInstance:$t(St.prototype),extendPath:$t(Nt),beforeEveryCall(t){f(t)&&Fe.push(t)}};Jt.extendSetup=$t(Jt);function Ve(t){return t(Jt),z}z.install=Ve;var st=z;var Qt=new Map,Bn=/function\s+([\p{L}\p{Nl}$_][\p{L}\p{Nl}$_\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*)\s*\(/gmu,Gn=async function(){}.constructor;function Tt(t,e,n=!1){let r=`${t.join(",")} ${e}`;if(Qt.has(r))return Qt.get(r);let i=new(n?Gn:Function)(...t,e);return Qt.set(r,i),i}function ke(t,e){let n=[...e.matchAll(Bn)].map(i=>i[1]);return Tt(Object.keys(t),`${e}; return {${n.map(i=>`${i}: typeof ${i} === 'function' ? ${i} : undefined`)}}; `)(...Object.values(t))}function jt(t){try{return new Function(`let ${t} = 0`),!0}catch{return!1}}var te="animate",zn="path",He="d",Be="transform",qe="rotate",q="translate",Ge="inherit",ze="finished",qn=[qe,"skewX","skewY"],Yn=[q,"width","height","x","y","cx","cy","r","rx","ry","dx","dy"],Wn=(t,e)=>["text","tspan"].includes(t)&&["x","y"].includes(e),ee=!1;if(window.matchMedia){let t=window.matchMedia("(prefers-reduced-motion: reduce)");ee=t.matches,t.addEventListener("change",()=>{ee=t.matches})}var Xn=t=>t.replace(/([A-Z])/g,"-$1").toLowerCase();function Jn(t,e={duration:200},n=null,r=null){let i=this.gSVG,o=l=>{let p=y(l)?{...l}:{duration:l};return ee&&(p.duration=0),p.fill="none",p},c=l=>{l=P(l)?l:[l];let p=window.getComputedStyle(this._el),m=[],x=new Set;for(let C of l){let A={};for(let V in C){let O=ut(V);A[O]=h(C[V],O),!(O in p)||Wn(this.tagName(),O)?x.add(O):O===He?A.d=`${zn}("${A.d}")`:O===Be&&(A.transform=u(A.transform))}m.push(A)}return a(x,m),m},s=[],a=(l,p)=>{if(l.size){let m=new KeyframeEffect(null,p).getKeyframes();for(let x of l){let C=i(te).attributeName(x).dur(nt.duration+"ms").fill("freeze");if(p.length===1)C.to(p[0][x]);else{let A=[],V=[];for(let O in m){let an=m[O];x in p[O]&&(A.push(an.computedOffset),V.push(p[O][x]))}A[0]!==0&&(A.unshift(0),V.unshift(this[x]()||Ge)),A[A.length-1]!==1&&(A.push(1),V.push(this[x]()||Ge)),C.keyTimes(A.join(";")).values(V.join(";"))}s.push(C),C.attachTo(this),C.beginElementAt(nt.delay||0)}}},u=l=>{N(l)&&(l=JSON.parse("{"+l.replace(/\s*\(\s*/g,":[").replace(/\s*\)\s*/g,"],").split(/\s*,\s*|\s.*/).join(",").replace(/(\w+):/g,'"$1":').replace(/,$/,"")+"}"));let p="";for(let m in l)if(m===qe){let x=d(l[m]);x.length>1&&(p+=`${q}(${h(x[1],q)},${h(x[2],q)}) `),p+=`${m}(${h(x[0],m)}) `,x.length>1&&(p+=`${q}(-${h(x[1],q)},-${h(x[2],q)}) `)}else p+=`${m}(${d(l[m]).map(x=>h(x,m)).join(",")}) `;return p},d=l=>P(l)?l:String(l).split(/\s+|,/),h=(l,p)=>qn.includes(p)?l+"deg":Yn.includes(p)?l+"px":l,T=l=>N(l)?l.replace(/(deg)|(px)/g,"").trim():l,I=l=>l.replace(/(path\s*\(\s*["'])|(["']\s*\)\s*$)/g,"").trim().replace(/([a-zA-Z])\s*/g,"$1").replace(/\s+/g,","),_t=l=>{let p=/translate\((.*)px,(.*)px\) rotate\((.*)deg\) translate\((.*)px,(.*)px\)\s+/,m=p.exec(l);return m&&Number(m[1])===Number(m[4])*-1&&Number(m[2])===Number(m[5])*-1?l=l.replace(p,`rotate(${m[3]}, ${m[1]}, ${m[2]})`):l=T(l),l},nt=o(e),U=c(t),Y=this._el.animate(U,nt);return Y.ready.then(()=>f(n)&&n.call(this,Y)),Y.finished.then(()=>{let l=U[U.length-1];for(let p in l){let m=Xn(p);m.startsWith("text-")?this._el.style[p]=l[p]:p!=="offset"&&p in l&&this._el.setAttribute(m,m===He?I(l[p]):m===Be?_t(l[p]):T(l[p]))}s.forEach(p=>{p[ze](!0);let m=this._el.querySelectorAll(te),x=this._el.querySelectorAll(`${te}[${ze}]`);m.length===x.length&&m.forEach(C=>C.remove())}),f(r)&&r.call(this,Y)}),this}function Kn(t){t.extendInstance({animateTo:Jn})}var Ye=Kn;var bt={},We=Symbol(),Qe=Symbol(),_=Symbol(),j=Symbol(),wt=Symbol(),re=Symbol(),Xe=Symbol(),ne="error",Zn="unknown",Je='an invalid "g-for" expression',Qn="undefined",jn="NaN (Not a Number)",Rt=(t,e)=>new Error(`The expression "${t}" return ${e} value`),Ke="class",Ze="style",tr=(t,e,n)=>{throw new Error(t+` in ${e} `+n)},er=(t=>e=>t[e]||e)("attributeName attributeType baseFrequency calcMode clipPathUnits diffuseConstant edgeMode gradientTransform gradientUnits kernelMatrix kernelUnitLength lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox xChannelSelector yChannelSelector zoomAndPan".split(" ").reduce((t,e)=>(t[e.toLowerCase()]=e,t),{}));function je(t){if(!t?.el?.parentNode)return null;let e=document.createComment(" ref ");return t.parentNode().insertBefore(e,t.el),t.remove(),e[re]=t,e}function nr(t){let e=t[re];return t.parentNode.insertBefore(e.el,t),t.remove(),e}tt({name:"g-content",exec(t,{expr:e,data:n,evalExpr:r}){let i={...n,$$:{fromURL:async a=>{let u=await fetch(a);if(u.status===200)return u.text();console.warn(`Failed to load URL: ${a} (${u.status})`)},element:t,currentContent:t.content}},o=r(e,i),c=new CustomEvent("load",{bubbles:!0,detail:t}),s=a=>g(a)?"":a;y(o)&&o.then?o.then(a=>{t.content(s(a)),t.dispatchEvent(c)}):(t.content(s(o)),t.dispatchEvent(c))}});tt({name:"g-if",exec(t,{expr:e,data:n,evalExpr:r}){if(!r(e,n))return t[_]&&(t[_].forEach(i=>i.remove()),delete t[_]),je(t)}});tt({name:"g-bind",alias:":",arg:!0,exec(t,{expr:e,arg:n,data:r,evalExpr:i}){n=er(n);let o=t._el,c={...r,$$:["d","transform"].includes(n)?t["$"+n]:{}};Object.assign(c.$$,{get element(){return t},get attribute(){return n},currentValue(){return n===Ke?[...o.classList]:n===Ze?[...o.style].reduce((a,u)=>(a[u]=o.style[u],a),{}):t[n]()},dynamic(a,u=200,d=0){return t.animateTo((P(a)?a:[a]).map(h=>y(h)&&"offset"in h?{[n]:h.value,offset:h.offset}:{[n]:h}),{duration:u,delay:d}),Xe}});let s=i(e,c);if(g(s))throw Rt(e,Qn);if(n===Ke){let a=h=>t.classList.add(h),u=h=>t.classList.remove(h),d=h=>Object.entries(h).forEach(([T,I])=>I?a(T):u(T));if(P(s)){s.forEach(h=>N(h)?a(h):y(h)?d(h):void 0);return}if(y(s)){d(s);return}s&&a(s);return}if(n===Ze){Object.entries(s).forEach(([a,u])=>t.style[a](u));return}s!==Xe&&t[n](s)}});tt({name:"g-on",alias:"@",arg:!0,exec(t,{expr:e,arg:n,data:r,evalExpr:i,error:o,code:c}){t[wt]=t[wt]||{};let s=t[wt][n]=t[wt][n]||new Map;s.has(e)&&t.removeEventListener(n,s.get(e));let a=function(u){try{let d=i(e,r,t);f(d)&&d.call(t,u)}catch(d){o(d.message,{directive:"g-on",argument:n,expression:e,toString(){return`g-on:${n}="${e}"`}},c)}};t.addEventListener(n,a),s.set(e,a),n==="init"&&!t[We]&&(t[We]=!0,t.dispatchEvent(new Event("init")))}});tt({name:"g-for",tmpl:!0,exec(t,{expr:e,data:n,error:r}){t[_]=t[_]||[];let i=t.gSVG(je(t)),o=0;return or(e,n,c=>{if(t[_][o])ot(t[_][o],c,r,!1);else{let s=t.gSVG(t.tagName());s[j]=t[j].filter(a=>a.name!=="g-for"),[...t.attributes()].forEach(a=>{a.name!=="g-for"&&s.setAttribute(a.name,a.value)}),t.children().forEach(a=>{s.add(a.cloneNode(!0))}),i.before(s),ot(s,c,r),s[Qe]=!0,t[_].push(s)}o++},c=>{for(;t[_].length>c.length;)t[_].pop().remove()}),!0}});function tt({name:t,alias:e,arg:n,tmpl:r,exec:i}){let o=`^(${t}${n?":":""}${e?`|${e})`:")"}${n?"(.*)$":"$"}`,c=new RegExp(o,"i");bt[t]={name:t,alias:e,arg:n,tmpl:r,exec:i,check:c}}function rr(t){for(let e in bt){let n=bt[e],r=n.check.exec(t);if(r){let i=r[2];return{...n,arg:i}}}}function ir(t){return t.replace(/[{}()[\]]/g,"").split(",").map(e=>(e.includes(":")?e.split(":")[1].trim():e).trim())}function sr(t,e){return t[Symbol.iterator]?e==="of"?{iterator:[...t],type:W}:{type:ne}:pe(t)?{iterator:Array(t<0?0:0|t).fill(0).map((n,r)=>r+(e==="of"?0:1)),type:v}:y(t)?e==="in"?{iterator:Object.entries(t).map(n=>n.reverse()),type:S}:{type:ne}:{iterator:t,type:Zn}}function tn(t,e,n=null){let r=Object.keys(e).filter(jt),o=Tt(r,`return ( ${t} ); `).apply(n,r.map(c=>e[c]));if(!ct(o))throw Rt(t,jn);return o}function or(t,e,n,r){let i="__$$i",o="__$$c",c="__$$f",s=t.match(/^\s*([\s\S]+?)[\s*|)}\]](of|in)[\s*|({[]([\s\S]+?)\s*$/);if(!s)throw Rt(t,Je);let[,a,u,d]=s;u=u.trim(),a=a.trim(),d=d.trim();let h=tn(d,e)||[],{iterator:T,type:I}=sr(h,u);if(I===ne)throw Rt(t,Je);I===S&&!a.startsWith("[")&&(a=`[${a.replace(/(^\()|(\)$)/g,"")}]`);let _t=ir(a),nt=a.startsWith("(")?a:`(${a})`,U=Object.keys(e).filter(jt),Y=` ${i}.forEach(${nt} => { ${o}({${U}${U.length?",":""}${_t.join(",")}}); }); ${c}(${i}); `;return Tt([...U,i,o,c],Y)(...U.map(p=>e[p]),T,n,r)}function ot(t,e,n,r=!0){if(r&&t[Qe])return;let i=t.outerHTML();t[j]=t[j]||[];let o=t.attributes();for(let s of[...o]){let a=s.name,u=rr(a);u&&(t[j].push({...u,expr:s.value}),t.removeAttribute(a))}let c=!1;for(let s of t[j]){c=s.tmpl||c;try{if(s.exec(t,{...s,data:e,evalExpr:tn,error:n,code:i}))return}catch(a){n(a.message,{directive:s.name,argument:s.arg,expression:s.expr,toString(){return`${s.name}${s.arg?":"+s.arg:""}="${s.expr}"`}},i)}}if(!c)for(let s of t.childNodes())s.el[re]?ot(nr(s.el),e,n):s.el?.nodeType===1&&ot(s,e,n)}function cr(t={},e=tr){ot(this,t,e),this.dispatchEvent(new Event("render"))}function ar(){return this.outerHTML().replaceAll("<!-- ref -->","")}function ur(t){t.install(Ye),t.extendInstance({render:cr,source:ar}),t.extendSetup({extendTemplate:{defineDirective:tt,getDirective(e){return bt[e]}}})}var en=ur;var nn=t=>Math.round(t*1e4)/1e4;function ie(t){return(t-90)*Math.PI/180}function Ot(t,e,n,r){let i=ie(r);return{x:nn(t+n*Math.cos(i)),y:nn(e+n*Math.sin(i))}}function vt(t,e,n,r,i=0){i=Math.abs(i)>=360?i%360:i,r=Math.abs(r)>360?r%360:r,r=Math.abs(r)===360?r>0?359.9:-359.9:r;let o=i+r,c=r>0?1:0,s=Math.abs(o-i)<=180?0:1,a=i<0?(360+i)%360:i,u=o<0?(360+o)%360:o,d=Ot(t,e,n,a),h=Ot(t,e,n,u);return`M${d.x},${d.y}A${n},${n},0,${s},${c},${h.x},${h.y}`}function lr(t,e,n,r,i,o=0){let c=vt(t,e,n+r/2,i,o),s=vt(t,e,n-r/2,-i,o+i);return c+"L"+s.substring(1)+"Z"}function fr(t,e,n,r,i=0){return`${vt(t,e,n,r,i)}L${t},${e}Z`}function hr(t){t.extendConstructor({polar2cartesian:Ot,degrees2radians:ie}),t.extendComposer&&t.extendComposer({polar2cartesian:Ot,degrees2radians:ie}),t.extendPath({arc:vt,barArc:lr,circleSlice:fr})}var rn=hr;var oe=Symbol(),se=Symbol(),sn=(t,e,n)=>Object.defineProperty(t,e,{enumerable:!1,configurable:!0,writable:!0,value:n}),dr=(t,e)=>e===oe?t:Ne(t,e);function ce(t={}){if(!y(t))return t;let e={};function n(r,i,o,c){r in t||(e[r]||(e[r]={}),sn(t,r,(s=void 0,a=oe)=>{if(N(s)||g(s)){if(a=s||oe,a in e[r])return e[r][a];s=t}let u=s.reduce((d,h)=>{let T=dr(h,a);return g(T)?d:d===se?T:o(d,T)},f(i)?i():i);return u=f(c)?c(u):u,t!==s&&(e[r][a]=u),u===i?0:u}),sn(t,r+"Before",(s,a)=>t[r](t.slice(0,s),a)))}return n("$min",se,(r,i)=>i>r?r:i),n("$max",se,(r,i)=>i<r?r:i),n("$count",0,r=>r+1),n("$sum",0,(r,i)=>i+r),n("$avg",()=>({n:0,i:0}),(r,i)=>(r.n++,r.i+=Number(i),r),r=>isNaN(r.i/r.n)?0:r.i/r.n),n("$distinct",()=>new Set,(r,i)=>(r.add(i),r),r=>[...r]),t}var pr="composer",ae="update",et="svg",ue="methods",le="config",fe="data",Ct="-src",on=t=>`script[type=${t}],g-script[type=${t}]`,cn=["0px","auto"],mr=t=>{let e=getComputedStyle(t.el);return cn.includes(e.width)&&cn.includes(e.height)},F=class extends R{static install(e){st.install(e)}#e=null;#r=!1;#i=!1;#t=[];#n=[];#h=Dt(function(e,n){this[$](e,n)},1);#s(e,n,r,i){let o={message:e,scope:n,code:r,toString:()=>`${e}${n?` in ${n}`:""} ${r}`};i.push(o),console.warn(`Graphane Composer - Error: ${o}`),this.#h.call(this,"error",this.errors)}#d(e){return e.length=0,(n,r="",i="")=>this.#s(n,r,i,this.#t)}async#c(e){let n=await fetch(e);if(n.status!==200)throw new Error(`${n.statusText} (${n.status}): ${n.url}`);return n.text()}async#p(){let e=[...this.querySelectorAll(on("plugin"))];for(let n of e){let r=n.getAttribute("src");if(r){let i=new URL(r,document.location.href);try{let o=await import(i.href);o?.default&&st.install(o.default)}catch(o){this.#s(o.message,"plugin",r,this.#n)}}}}async#a(){let e=this[E];if(this.#e=null,e.content.innerHTML="",e.svgSrc)try{e.content.innerHTML=await this.#c(e.svgSrc)}catch(r){this.#s(r.message,et,e.svgSrc,this.#n)}else{let r=this.querySelector("template")?.content||this.querySelector(et);r&&e.content.append(r.cloneNode(!0))}let n=e.content.querySelector(et);return this.#e=n?st(n):null,!0}async#o(e,n){let r=this[E],i=e+"Src",o=this.querySelector(on(e));o&&(r[i]=o.getAttribute("src"));let c=r[i]?await this.#c(r[i]).catch(s=>this.#s(s.message,e,r[i],this.#n)):o?.textContent;if(c)try{r[e]=n(c)}catch(s){this.#s(s.message,e,c,this.#n)}}#u(){return this.#o(ue,e=>ke({$:this},e))}#l(){return this.#o(le,K)}#f(){return this.#o(fe,e=>lt(e)||ft(e)?K(e):ht(e))}constructor(){super();let e=this[E];this.shadowRoot.innerHTML=` <style> :host { display : inline-block; width : max-content; height : max-content; } </style><span></span>`,e.content=this.shadowRoot.querySelector("span")}[b](){return!this.load()}async[G](e){let n=[];for(let r of e){let i=r.target;if(i===this&&!r.attributeName)return this.load();if(i.tagName.toLowerCase()===et)n.push(this.#a());else if(i.tagName==="SCRIPT"){let o={data:this.#f,methods:this.#u,config:this.#l}[i.type.toLowerCase()];o&&n.push(o())}}if(n.length)return await Promise.all(n),this.update()}async load(){return this.#r=!1,this.#n=[],await this.#p(),await Promise.all([this.#a(),this.#l(),this.#u(),this.#f()]),this.#r=!0,this[$]("load"),this.update(!0)}async update(e=!1){if(!(this.#i&&!e)&&this.#e){this.rendered=!1,this.#i=!0;let n=this[E],r=n.methods?.data?n.methods.data(ce(B(n.data))):ce(B(n.data)),i={...n.methods,...P(r)?{}:r,data:r,$:this};await this.#e.render(i,this.#d(this.#t)),mr(this.#e)&&this.#e.width("100%").height("100%"),this.#i=!1,this.rendered=!0}}get[et](){return this.#e}get loaded(){return this.#r}get errors(){return[...this.#n,...this.#t]}get version(){return"1.0.1"}};F.prototype.update=Dt(F.prototype.update,1);gt(F).ext(Ce).attr({name:et+Ct,type:L,value:"",posUpdate:b}).attr({name:fe,type:S,value:[],posUpdate:ae}).attr({name:fe+Ct,type:L,posUpdate:b}).prop({name:ue,type:S,value:{},posUpdate:ae}).attr({name:ue+Ct,type:L,posUpdate:b}).attr({name:le,type:S,value:{},posUpdate:ae}).attr({name:le+Ct,type:L,posUpdate:b}).attr({name:"value",set(t){this.data={value:t}},get(){return this.data?.value}}).tag(pr);var yr=t=>{t.extendSetup({extendComposer(e){f(e)?e(F.prototype):Object.assign(F.prototype,e)}})};st.install(yr).install(en).install(rn);var Lt=class extends R{constructor(){super(),this.shadowRoot.addEventListener("load",e=>{this[$]("load",{...e.detail,data:this.data,config:this.config})}),this.shadowRoot.addEventListener("update",e=>{this[$]("update",{...e.detail,data:this.data,config:this.config})}),this.shadowRoot.addEventListener("render",e=>{this[$]("render",{...e.detail,data:this.data,config:this.config})}),this.#r(),this.#i()}async#e(e){let n=await fetch(e);if(n.status!==200)throw new Error(`${n.statusText} (${n.status}): ${n.url}`);return n.text()}async#r(){let e=this.querySelector("script[type=data],g-script[type=data]"),n=e?.getAttribute("src")||this.getAttribute("data-src"),r=n?await this.#e(n):e?.textContent;r&&(this.data=lt(r)||ft(r)?K(r):ht(r))}async#i(){let e=this.querySelector("script[type=config],g-script[type=config]"),n=e?.getAttribute("src")||this.getAttribute("config-src"),r=n?await this.#e(n):e?.textContent;r&&(this.config=K(r))}get#t(){return this.shadowRoot.querySelector("g-composer")}set data(e){if(this.#t?.loaded)this.#t.data=e;else{let n=()=>{this.#t.data=e,this.removeEventListener("load",n)};this.addEventListener("load",n)}}get data(){return this.#t.data}set config(e){if(this.#t?.loaded)mt(this.#t.config,e);else{let n=()=>{mt(this.#t.config,e),this.removeEventListener("load",n)};this.addEventListener("load",n)}}get config(){return this.#t.config}get loaded(){return this.#t.loaded}};gt(Lt).attr({name:"value",set(t){this.data={value:t}},get(){return this.data?.value}});function he(t,e){let n=customElements.get(t);return n||(n=class extends Lt{constructor(){super(),this.shadowRoot.innerHTML=` <style> :host { display : inline-block; width : max-content; height : max-content; } g-composer { width : auto; height : auto; } </style> ${e} `}},customElements.define(t,n)),n}(typeof gobalThis<"u"?globalThis:window).defineComponent=he;})();