spytial-core 6.0.1 → 6.1.0
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/README.md +1 -1
- package/dist/browser/spytial-core-complete.global.js +2 -2
- package/dist/browser/spytial-core-complete.global.js.map +1 -1
- package/dist/cli/spytial-check.js +2 -2
- package/dist/conformance.js +1 -1
- package/dist/conformance.js.map +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/conformance.mjs.map +1 -1
- package/dist/esm/{chunk-SRI454ZW.mjs → chunk-4IGLZPUH.mjs} +7 -8
- package/dist/esm/chunk-4IGLZPUH.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/structured-input-graph-QYY46FTQ.mjs +4 -0
- package/dist/esm/{structured-input-graph-4SKRJP7A.mjs.map → structured-input-graph-QYY46FTQ.mjs.map} +1 -1
- package/dist/types/language/manifest.d.ts +1 -1
- package/dist/types/layout/layoutinstance.d.ts +2 -3
- package/dist/types/layout/layoutspec.d.ts +4 -5
- package/docs/spytial-language.json +5 -5
- package/docs/spytial-spec.schema.json +6 -6
- package/package.json +1 -1
- package/dist/esm/chunk-SRI454ZW.mjs.map +0 -1
- package/dist/esm/structured-input-graph-4SKRJP7A.mjs +0 -4
|
@@ -536,7 +536,7 @@ TTbdfjnrvxz|~\x80\xA2\xA4U\b
|
|
|
536
536
|
`+t.slice(o+1):c+=t.slice(i),c.slice(1)}function nlt(t){for(var e="",n=0,s,i=0;i<t.length;n>=65536?i+=2:i++)n=Q_(t,i),s=da[n],!s&&eb(n)?(e+=t[i],n>=65536&&(e+=t[i+1])):e+=s||Yut(n);return e}function ilt(t,e,n){var s="",i=t.tag,r,o,a;for(r=0,o=n.length;r<o;r+=1)a=n[r],t.replacer&&(a=t.replacer.call(n,String(r),a)),(Ff(t,e,a,false,false)||typeof a>"u"&&Ff(t,e,null,false,false))&&(s!==""&&(s+=","+(t.condenseFlow?"":" ")),s+=t.dump);t.tag=i,t.dump="["+s+"]";}function t4(t,e,n,s){var i="",r=t.tag,o,a,c;for(o=0,a=n.length;o<a;o+=1)c=n[o],t.replacer&&(c=t.replacer.call(n,String(o),c)),(Ff(t,e+1,c,true,true,false,true)||typeof c>"u"&&Ff(t,e+1,null,true,true,false,true))&&((!s||i!=="")&&(i+=Xw(t,e)),t.dump&&Z_===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=r,t.dump=i||"[]";}function olt(t,e,n){var s="",i=t.tag,r=Object.keys(n),o,a,c,v,y;for(o=0,a=r.length;o<a;o+=1)y="",s!==""&&(y+=", "),t.condenseFlow&&(y+='"'),c=r[o],v=n[c],t.replacer&&(v=t.replacer.call(n,c,v)),Ff(t,e,c,false,false)&&(t.dump.length>1024&&(y+="? "),y+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ff(t,e,v,false,false)&&(y+=t.dump,s+=y));t.tag=i,t.dump="{"+s+"}";}function slt(t,e,n,s){var i="",r=t.tag,o=Object.keys(n),a,c,v,y,g,h;if(t.sortKeys===true)o.sort();else if(typeof t.sortKeys=="function")o.sort(t.sortKeys);else if(t.sortKeys)throw new cu("sortKeys must be a boolean or a function");for(a=0,c=o.length;a<c;a+=1)h="",(!s||i!=="")&&(h+=Xw(t,e)),v=o[a],y=n[v],t.replacer&&(y=t.replacer.call(n,v,y)),Ff(t,e+1,v,true,true,true)&&(g=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,g&&(t.dump&&Z_===t.dump.charCodeAt(0)?h+="?":h+="? "),h+=t.dump,g&&(h+=Xw(t,e)),Ff(t,e+1,y,true,g)&&(t.dump&&Z_===t.dump.charCodeAt(0)?h+=":":h+=": ",h+=t.dump,i+=h));t.tag=r,t.dump=i||"{}";}function e4(t,e,n){var s,i,r,o,a,c;for(i=n?t.explicitTypes:t.implicitTypes,r=0,o=i.length;r<o;r+=1)if(a=i[r],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof e=="object"&&e instanceof a.instanceOf)&&(!a.predicate||a.predicate(e))){if(n?a.multi&&a.representName?t.tag=a.representName(e):t.tag=a.tag:t.tag="?",a.represent){if(c=t.styleMap[a.tag]||a.defaultStyle,m4.call(a.represent)==="[object Function]")s=a.represent(e,c);else if(v4.call(a.represent,c))s=a.represent[c](e,c);else throw new cu("!<"+a.tag+'> tag resolver accepts not "'+c+'" style');t.dump=s;}return true}return false}function Ff(t,e,n,s,i,r,o){t.tag=null,t.dump=n,e4(t,n,false)||e4(t,n,true);var a=m4.call(t.dump),c=s,v;s&&(s=t.flowLevel<0||t.flowLevel>e);var y=a==="[object Object]"||a==="[object Array]",g,h;if(y&&(g=t.duplicates.indexOf(n),h=g!==-1),(t.tag!==null&&t.tag!=="?"||h||t.indent!==2&&e>0)&&(i=false),h&&t.usedDuplicates[g])t.dump="*ref_"+g;else {if(y&&h&&!t.usedDuplicates[g]&&(t.usedDuplicates[g]=true),a==="[object Object]")s&&Object.keys(t.dump).length!==0?(slt(t,e,t.dump,i),h&&(t.dump="&ref_"+g+t.dump)):(olt(t,e,t.dump),h&&(t.dump="&ref_"+g+" "+t.dump));else if(a==="[object Array]")s&&t.dump.length!==0?(t.noArrayIndent&&!o&&e>0?t4(t,e-1,t.dump,i):t4(t,e,t.dump,i),h&&(t.dump="&ref_"+g+t.dump)):(ilt(t,e,t.dump),h&&(t.dump="&ref_"+g+" "+t.dump));else if(a==="[object String]")t.tag!=="?"&&elt(t,t.dump,e,r,c);else {if(a==="[object Undefined]")return false;if(t.skipInvalid)return false;throw new cu("unacceptable kind of an object to dump "+a)}t.tag!==null&&t.tag!=="?"&&(v=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?v="!"+v:v.slice(0,18)==="tag:yaml.org,2002:"?v="!!"+v.slice(18):v="!<"+v+">",t.dump=v+" "+t.dump);}return true}function alt(t,e){var n=[],s=[],i,r;for(Jw(t,n,s),i=0,r=s.length;i<r;i+=1)e.duplicates.push(n[s[i]]);e.usedDuplicates=new Array(r);}function Jw(t,e,n){var s,i,r;if(t!==null&&typeof t=="object")if(i=e.indexOf(t),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(e.push(t),Array.isArray(t))for(i=0,r=t.length;i<r;i+=1)Jw(t[i],e,n);else for(s=Object.keys(t),i=0,r=s.length;i<r;i+=1)Jw(t[s[i]],e,n);}function ult(t,e){e=e||{};var n=new Xut(e);n.noRefs||alt(t,n);var s=t;return n.replacer&&(s=n.replacer.call({"":s},"",s)),Ff(n,0,s,true,true)?n.dump+`
|
|
537
537
|
`:""}var Yst,Wst,Xst,Qst,Jst,Zst,ms,cu,eat,rat,nat,pa,aat,uat,lat,cat,hat,gat,xat,Aat,wat,Rat,Pat,Dat,kat,i4,o4,Bat,jat,Zw,$at,Vat,Yat,Qat,Jat,eut,rut,out,s4,bd,YT,a4,u4,WT,Vw,sut,H6,aut,uut,lut,l4,c4,f4,p4,Ty,z6,wut,Cut,y4,m4,v4,rC,Nut,Z_,Rut,Lut,Iut,Put,Ww,Dut,kut,Mut,Kut,x4,Fut,QT,But,Uut,jut,Hut,_4,b4,Gut,T4,qut,E4,da,zut,$ut,Wut,tb,O4,Qw,A4,w4,F0,llt,clt,C4,N4=Ie(()=>{Yst=r4,Wst=Gst,Xst=qst,Qst=$st,Jst=Vst,Zst=zst,ms={isNothing:Yst,isObject:Wst,toArray:Xst,repeat:Qst,isNegativeZero:Jst,extend:Zst};J_.prototype=Object.create(Error.prototype);J_.prototype.constructor=J_;J_.prototype.toString=function(e){return this.name+": "+n4(this,e)};cu=J_;eat=tat,rat=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],nat=["scalar","sequence","mapping"];pa=oat;Yw.prototype.extend=function(e){var n=[],s=[];if(e instanceof pa)s.push(e);else if(Array.isArray(e))s=s.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(n=n.concat(e.implicit)),e.explicit&&(s=s.concat(e.explicit));else throw new cu("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(r){if(!(r instanceof pa))throw new cu("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(r.loadKind&&r.loadKind!=="scalar")throw new cu("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(r.multi)throw new cu("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),s.forEach(function(r){if(!(r instanceof pa))throw new cu("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(Yw.prototype);return i.implicit=(this.implicit||[]).concat(n),i.explicit=(this.explicit||[]).concat(s),i.compiledImplicit=j6(i,"implicit"),i.compiledExplicit=j6(i,"explicit"),i.compiledTypeMap=sat(i.compiledImplicit,i.compiledExplicit),i};aat=Yw,uat=new pa("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),lat=new pa("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),cat=new pa("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),hat=new aat({explicit:[uat,lat,cat]});gat=new pa("tag:yaml.org,2002:null",{kind:"scalar",resolve:fat,construct:pat,predicate:dat,represent:{canonical:function(){return "~"},lowercase:function(){return "null"},uppercase:function(){return "NULL"},camelcase:function(){return "Null"},empty:function(){return ""}},defaultStyle:"lowercase"});xat=new pa("tag:yaml.org,2002:bool",{kind:"scalar",resolve:yat,construct:mat,predicate:vat,represent:{lowercase:function(t){return t?"true":"false"},uppercase:function(t){return t?"TRUE":"FALSE"},camelcase:function(t){return t?"True":"False"}},defaultStyle:"lowercase"});Aat=new pa("tag:yaml.org,2002:int",{kind:"scalar",resolve:Eat,construct:Sat,predicate:Oat,represent:{binary:function(t){return t>=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),wat=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");Rat=/^[-+]?[0-9]+e/;Pat=new pa("tag:yaml.org,2002:float",{kind:"scalar",resolve:Cat,construct:Nat,predicate:Iat,represent:Lat,defaultStyle:"lowercase"}),Dat=hat.extend({implicit:[gat,xat,Aat,Pat]}),kat=Dat,i4=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),o4=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");Bat=new pa("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Mat,construct:Kat,instanceOf:Date,represent:Fat});jat=new pa("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Uat}),Zw=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
538
538
|
\r`;$at=new pa("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Hat,construct:Gat,predicate:zat,represent:qat}),Vat=Object.prototype.hasOwnProperty,Yat=Object.prototype.toString;Qat=new pa("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Wat,construct:Xat}),Jat=Object.prototype.toString;eut=new pa("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Zat,construct:tut}),rut=Object.prototype.hasOwnProperty;out=new pa("tag:yaml.org,2002:set",{kind:"mapping",resolve:nut,construct:iut}),s4=kat.extend({implicit:[Bat,jat],explicit:[$at,Qat,eut,out]}),bd=Object.prototype.hasOwnProperty,YT=1,a4=2,u4=3,WT=4,Vw=1,sut=2,H6=3,aut=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,uut=/[\x85\u2028\u2029]/,lut=/[,\[\]\{\}]/,l4=/^(?:!|!!|![a-z\-]+!)$/i,c4=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;f4=new Array(256),p4=new Array(256);for(Ty=0;Ty<256;Ty++)f4[Ty]=q6(Ty)?1:0,p4[Ty]=q6(Ty);z6={YAML:function(e,n,s){var i,r,o;e.version!==null&&Yr(e,"duplication of %YAML directive"),s.length!==1&&Yr(e,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(s[0]),i===null&&Yr(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),r!==1&&Yr(e,"unacceptable YAML version of the document"),e.version=s[0],e.checkLineBreaks=o<2,o!==1&&o!==2&&XT(e,"unsupported YAML version of the document");},TAG:function(e,n,s){var i,r;s.length!==2&&Yr(e,"TAG directive accepts exactly two arguments"),i=s[0],r=s[1],l4.test(i)||Yr(e,"ill-formed tag handle (first argument) of the TAG directive"),bd.call(e.tagMap,i)&&Yr(e,'there is a previously declared suffix for "'+i+'" tag handle'),c4.test(r)||Yr(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r);}catch{Yr(e,"tag prefix is malformed: "+r);}e.tagMap[i]=r;}};wut=Out,Cut=Aut,y4={loadAll:wut,load:Cut},m4=Object.prototype.toString,v4=Object.prototype.hasOwnProperty,rC=65279,Nut=9,Z_=10,Rut=13,Lut=32,Iut=33,Put=34,Ww=35,Dut=37,kut=38,Mut=39,Kut=42,x4=44,Fut=45,QT=58,But=61,Uut=62,jut=63,Hut=64,_4=91,b4=93,Gut=96,T4=123,qut=124,E4=125,da={};da[0]="\\0";da[7]="\\a";da[8]="\\b";da[9]="\\t";da[10]="\\n";da[11]="\\v";da[12]="\\f";da[13]="\\r";da[27]="\\e";da[34]='\\"';da[92]="\\\\";da[133]="\\N";da[160]="\\_";da[8232]="\\L";da[8233]="\\P";zut=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],$ut=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;Wut=1,tb=2;O4=1,Qw=2,A4=3,w4=4,F0=5;llt=ult,clt={dump:llt};C4=y4.load,y4.loadAll,clt.dump;});function rb(t){if(typeof t!="string")return;let e=t.trim().toLowerCase();if(e==="solid"||e==="dashed"||e==="dotted")return e}var iC=Ie(()=>{});function oC(t){return typeof t=="string"&&flt.includes(t)}function H0(t){if(!t||typeof t!="object")return;let e=t,n={};return oC(e.size)&&(n.size=e.size),typeof e.color=="string"&&(n.color=e.color),Object.keys(n).length>0?n:void 0}var flt,tE=Ie(()=>{flt=["small","normal","large"];});function R4(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function aC(t,e=""){let n=new Map;for(let s of Object.keys(t)){let i=t[s];if(i==null)continue;let r=e?`${e}.${s}`:s;if(R4(i))for(let[o,a]of aC(i,r))n.set(o,a);else n.set(r,i);}return n}function plt(t){let e={};for(let[n,{value:s}]of t){let i=n.split("."),r=e;for(let o=0;o<i.length-1;o++){let a=i[o],c=r[a];if(R4(c))r=c;else {let v={};r[a]=v,r=v;}}r[i[i.length-1]]=s;}return e}function eE(t,e={}){let n=new Map;for(let{source:s,style:i}of t)for(let[r,o]of aC(i)){let a=n.get(r);if(a===void 0)n.set(r,{source:s,value:o});else if(a.value!==o)throw new sC(r,a,{source:s,value:o},e.context)}if(e.defaults)for(let[s,i]of aC(e.defaults))n.has(s)||n.set(s,{source:"(default)",value:i});return plt(n)}var sC,uC=Ie(()=>{sC=class extends Error{constructor(n,s,i,r){let o=r?` for ${r}`:"";super(`Conflicting style for "${n}"${o}: ${s.source} sets it to ${JSON.stringify(s.value)}, but ${i.source} sets it to ${JSON.stringify(i.value)}. Styles never silently override \u2014 set "${n}" in exactly one matching rule.`);this.path=n;this.existing=s;this.incoming=i;this.context=r;this.name="StyleCollisionError";}};});function glt(t){return typeof t=="string"&&dlt.includes(t)}function ylt(t){if(!t||typeof t!="object")return;let e=t,n={};return typeof e.color=="string"&&(n.color=e.color),glt(e.pattern)&&(n.pattern=e.pattern),typeof e.weight=="number"&&Number.isFinite(e.weight)&&e.weight>0&&(n.weight=e.weight),typeof e.highlight=="string"&&(n.highlight=e.highlight),Object.keys(n).length>0?n:void 0}function mlt(t){if(!t||typeof t!="object")return;let e=t,n={};return oC(e.size)&&(n.size=e.size),typeof e.color=="string"&&(n.color=e.color),Object.keys(n).length>0?n:void 0}function rE(t){let e={};if(!t||typeof t!="object")return e;let n=t,s=ylt(n.lineStyle);s&&(e.lineStyle=s);let i=mlt(n.textStyle);return i&&(e.textStyle=i),typeof n.showLabel=="boolean"&&(e.showLabel=n.showLabel),typeof n.hidden=="boolean"&&(e.hidden=n.hidden),e}function L4(t){let e=t&&typeof t=="object"?t:{},n={};typeof e.value=="string"&&(n.color=e.value);let s=rb(e.style);s&&(n.pattern=s),typeof e.weight=="number"&&Number.isFinite(e.weight)&&e.weight>0&&(n.weight=e.weight),typeof e.highlight=="string"&&(n.highlight=e.highlight);let i={};return Object.keys(n).length>0&&(i.lineStyle=n),typeof e.showLabel=="boolean"&&(i.showLabel=e.showLabel),typeof e.hidden=="boolean"&&(i.hidden=e.hidden),{field:typeof e.field=="string"?e.field:"",selector:typeof e.selector=="string"?e.selector:void 0,filter:typeof e.filter=="string"?e.filter:void 0,style:i}}function vlt(t){return t.selector?`edgeStyle(${t.field} \xB7 ${t.selector})`:`edgeStyle(${t.field})`}function I4(t,e){let n=t.map(s=>({source:vlt(s),style:s.style}));return eE(n,{context:e})}var dlt,lC=Ie(()=>{iC();tE();uC();dlt=["solid","dashed","dotted"];});function oE(t){if(!t)return "";if(t.startsWith("http")||t.startsWith("data:")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;let e=t.indexOf(":");if(e>0){let s=t.substring(0,e),i=t.substring(e+1),r=iE[s];if(r)return r(i)}let n=nb[t];return n||t}function xlt(){return Object.keys(nb)}function _lt(){return Object.keys(iE)}function Tlt(){return Object.keys(iE).map(t=>({prefix:t,label:blt[t]??t,example:`${t}:${t.startsWith("fa")||t==="bi"?"person":"home"}`}))}function Elt(t){return t in nb}function D4(t){let e=nb[t];if(e)return decodeURIComponent(e.slice(P4.length))}function cC(t){if(t)return Slt.get(t)??D4(t)}function Olt(t){let e=t.indexOf(":");return e<=0?false:t.substring(0,e)in iE}var nb,nE,iE,blt,P4,Slt,sE=Ie(()=>{nb={person:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z"/></svg>')}`,"person-fill":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/></svg>')}`,people:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1zm-7.978-1L7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002-.014.002zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4m3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0M6.936 9.28a6 6 0 0 0-1.23-.247A7 7 0 0 0 5 9c-4 0-5 3-5 4q0 1 1 1h4.216A2.24 2.24 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816M4.92 10A5.5 5.5 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0m3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4"/></svg>')}`,home:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/></svg>')}`,house:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/></svg>')}`,building:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M4 2.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm3 0a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm3.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zM4 5.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zM7.5 5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm2.5.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zM4.5 8a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm2.5.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm3.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5z"/><path d="M2 1a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1zm11 0H3v14h3v-2.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5V15h3z"/></svg>')}`,star:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.56.56 0 0 0-.163-.505L1.71 6.745l4.052-.576a.53.53 0 0 0 .393-.288L8 2.223l1.847 3.658a.53.53 0 0 0 .393.288l4.052.575-2.906 2.77a.56.56 0 0 0-.163.506l.694 3.957-3.686-1.894a.5.5 0 0 0-.461 0z"/></svg>')}`,"star-fill":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/></svg>')}`,heart:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143q.09.083.176.171a3 3 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15"/></svg>')}`,"heart-fill":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314"/></svg>')}`,circle:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><circle cx="8" cy="8" r="8"/></svg>')}`,square:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><rect width="16" height="16"/></svg>')}`,triangle:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M7.022 1.566a1.13 1.13 0 0 1 1.96 0l6.857 11.667c.457.778-.092 1.767-.98 1.767H1.144c-.889 0-1.437-.99-.98-1.767z"/></svg>')}`,"tic-x":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="2" y1="2" x2="14" y2="14"/><line x1="14" y1="2" x2="2" y2="14"/></svg>')}`,"tic-o":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><circle cx="8" cy="8" r="6"/></svg>')}`,"arrow-right":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/></svg>')}`,"arrow-left":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/></svg>')}`,"arrow-up":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5"/></svg>')}`,"arrow-down":`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1"/></svg>')}`,check:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/></svg>')}`,x:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg>')}`,plus:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/></svg>')}`,minus:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8"/></svg>')}`,warning:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.15.15 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.2.2 0 0 1-.054.06.1.1 0 0 1-.066.017H1.146a.1.1 0 0 1-.066-.017.2.2 0 0 1-.054-.06.18.18 0 0 1 .002-.183L7.884 2.073a.15.15 0 0 1 .054-.057m1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767z"/><path d="M7.002 12a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z"/></svg>')}`,info:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/></svg>')}`,gear:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"/><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"/></svg>')}`,database:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M4.318 2.687C5.234 2.271 6.536 2 8 2s2.766.27 3.682.687C12.644 3.125 13 3.627 13 4c0 .374-.356.875-1.318 1.313C10.766 5.729 9.464 6 8 6s-2.766-.27-3.682-.687C3.356 4.875 3 4.373 3 4c0-.374.356-.875 1.318-1.313M13 5.698V7c0 .374-.356.875-1.318 1.313C10.766 8.729 9.464 9 8 9s-2.766-.27-3.682-.687C3.356 7.875 3 7.373 3 7V5.698c.271.202.58.378.904.525C4.978 6.711 6.427 7 8 7s3.022-.289 4.096-.777A5 5 0 0 0 13 5.698M14 4c0-1.007-.875-1.755-1.904-2.223C11.022 1.289 9.573 1 8 1s-3.022.289-4.096.777C2.875 2.245 2 2.993 2 4v9c0 1.007.875 1.755 1.904 2.223C4.978 15.71 6.427 16 8 16s3.022-.289 4.096-.777C13.125 14.755 14 14.007 14 13zm-1 4.698V10c0 .374-.356.875-1.318 1.313C10.766 11.729 9.464 12 8 12s-2.766-.27-3.682-.687C3.356 10.875 3 10.373 3 10V8.698c.271.202.58.378.904.525C4.978 9.71 6.427 10 8 10s3.022-.289 4.096-.777A5 5 0 0 0 13 8.698m0 3V13c0 .374-.356.875-1.318 1.313C10.766 14.729 9.464 15 8 15s-2.766-.27-3.682-.687C3.356 13.875 3 13.373 3 13v-1.302c.271.202.58.378.904.525C4.978 12.71 6.427 13 8 13s3.022-.289 4.096-.777c.324-.147.633-.323.904-.525"/></svg>')}`,folder:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3H14.5A1.5 1.5 0 0 1 16 4.5v1.384l-.195-.131a1 1 0 0 0-.163-.084l-.022-.01-.053-.021A.5.5 0 0 0 15.5 5H.5a.5.5 0 0 0-.5.5v.01c.053-.01.108-.017.164-.022L.162 5.5zm-.11 2.13H15.57a.5.5 0 0 1 .49.6l-1.037 5.184A1.5 1.5 0 0 1 13.549 13H2.451a1.5 1.5 0 0 1-1.474-1.22L-.06 6.6a.5.5 0 0 1 .49-.6"/></svg>')}`,file:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M4 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm0 1h8a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1"/></svg>')}`,tree:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8.416.223a.5.5 0 0 0-.832 0l-3 4.5A.5.5 0 0 0 5 5.5h.098L3.076 8.735A.5.5 0 0 0 3.5 9.5h.191l-1.638 3.276a.5.5 0 0 0 .447.724H7V16h2v-2.5h4.5a.5.5 0 0 0 .447-.724L12.31 9.5h.191a.5.5 0 0 0 .424-.765L10.902 5.5H11a.5.5 0 0 0 .416-.777z"/></svg>')}`,flower:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a4 4 0 0 0-4 4v.2A4.5 4.5 0 0 0 5.52 14h4.96A4.5 4.5 0 0 0 12 5.2V5a4 4 0 0 0-4-4"/></svg>')}`,car:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M2.52 3.515A2.5 2.5 0 0 1 4.82 2h6.36a2.5 2.5 0 0 1 2.3 1.515l1.34 3.147a.5.5 0 0 1-.068.51A.5.5 0 0 1 14.5 7H14v3a1 1 0 0 1-1 1h-1a1 1 0 0 1-1-1v-.5H5V10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7h-.5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .034-.18zM4 8.5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1m8 0a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M4.82 3a1.5 1.5 0 0 0-1.38.91L2.46 6h11.08l-.98-2.09A1.5 1.5 0 0 0 11.18 3z"/></svg>')}`,envelope:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1zm13 2.383-4.708 2.825L15 11.105zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741M1 11.105l4.708-2.897L1 5.383z"/></svg>')}`,phone:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M3.654 1.328a.678.678 0 0 0-1.015-.063L1.605 2.3c-.483.484-.661 1.169-.45 1.77a17.6 17.6 0 0 0 4.168 6.608 17.6 17.6 0 0 0 6.608 4.168c.601.211 1.286.033 1.77-.45l1.034-1.034a.678.678 0 0 0-.063-1.015l-2.307-1.794a.68.68 0 0 0-.58-.122l-2.19.547a1.75 1.75 0 0 1-1.657-.459L5.482 8.062a1.75 1.75 0 0 1-.46-1.657l.548-2.19a.68.68 0 0 0-.122-.58zM1.884.511a1.745 1.745 0 0 1 2.612.163L6.29 2.98c.329.423.445.974.315 1.494l-.547 2.19a.68.68 0 0 0 .178.643l2.457 2.457a.68.68 0 0 0 .644.178l2.189-.547a1.75 1.75 0 0 1 1.494.315l2.306 1.794c.829.645.905 1.87.163 2.611l-1.034 1.034c-.74.74-1.846 1.065-2.877.702a18.6 18.6 0 0 1-7.01-4.42 18.6 18.6 0 0 1-4.42-7.009c-.362-1.03-.037-2.137.703-2.877z"/></svg>')}`,flag:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M14.778.085A.5.5 0 0 1 15 .5V8a.5.5 0 0 1-.314.464L14.5 8l.186.464-.003.001-.006.003-.023.009a12 12 0 0 1-.397.15c-.264.095-.631.223-1.047.35-.816.252-1.879.523-2.71.523-.847 0-1.548-.28-2.158-.525l-.028-.01C7.68 8.71 7.14 8.5 6.5 8.5c-.7 0-1.638.23-2.437.477A20 20 0 0 0 3 9.342V15.5a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 1 0v.282c.226-.079.496-.17.79-.26C4.606.272 5.67 0 6.5 0c.84 0 1.524.277 2.121.519l.043.018C9.286.788 9.828 1 10.5 1c.7 0 1.638-.23 2.437-.477a20 20 0 0 0 1.349-.476l.019-.007.004-.002h.001"/></svg>')}`,lock:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2m3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2M5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1"/></svg>')}`,key:`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M0 8a4 4 0 0 1 7.465-2H14a.5.5 0 0 1 .354.146l1.5 1.5a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0L13 9.207l-.646.647a.5.5 0 0 1-.708 0L11 9.207l-.646.647a.5.5 0 0 1-.708 0L9 9.207l-.646.647A.5.5 0 0 1 8 10h-.535A4 4 0 0 1 0 8m4-3a3 3 0 1 0 2.712 4.285A.5.5 0 0 1 7.163 9h.63l.853-.854a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.793-.793-1-1h-6.63a.5.5 0 0 1-.451-.285A3 3 0 0 0 4 5m-1.5 3a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0"/></svg>')}`},nE=`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.5" y="2.5" width="13" height="11" rx="1.5"/><line x1="2" y1="13" x2="14" y2="3" stroke-dasharray="2 1.5"/></svg>')}`,iE={bi:t=>`https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/${t}.svg`,fa:t=>`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/svgs/solid/${t}.svg`,"fa-solid":t=>`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/svgs/solid/${t}.svg`,"fa-regular":t=>`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/svgs/regular/${t}.svg`,"fa-brands":t=>`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/svgs/brands/${t}.svg`,lucide:t=>`https://cdn.jsdelivr.net/npm/lucide-static@0.300.0/icons/${t}.svg`,heroicons:t=>`https://cdn.jsdelivr.net/npm/heroicons@2.1.1/24/outline/${t}.svg`,"heroicons-solid":t=>`https://cdn.jsdelivr.net/npm/heroicons@2.1.1/24/solid/${t}.svg`,tabler:t=>`https://cdn.jsdelivr.net/npm/@tabler/icons@2.44.0/icons/${t}.svg`,simple:t=>`https://cdn.jsdelivr.net/npm/simple-icons@10.4.0/icons/${t}.svg`};blt={bi:"Bootstrap Icons",fa:"FontAwesome (solid)","fa-solid":"FontAwesome (solid)","fa-regular":"FontAwesome (regular)","fa-brands":"FontAwesome (brands)",lucide:"Lucide",heroicons:"Heroicons (outline)","heroicons-solid":"Heroicons (solid)",tabler:"Tabler Icons",simple:"Simple Icons (brands)"};P4="data:image/svg+xml,";Slt=new Map([...Object.values(nb),nE].map(t=>[t,decodeURIComponent(t.slice(P4.length))]));});function wlt(t){return typeof t=="string"&&Alt.includes(t)}function Clt(t){if(!t||typeof t!="object")return;let e=t,n={};return typeof e.color=="string"&&(n.color=e.color),Object.keys(n).length>0?n:void 0}function Nlt(t){if(!t||typeof t!="object")return;let e=t,n={};return typeof e.color=="string"&&(n.color=e.color),typeof e.width=="number"&&Number.isFinite(e.width)&&e.width>0&&(n.width=e.width),Object.keys(n).length>0?n:void 0}function Rlt(t){if(!t||typeof t!="object")return;let e=t,n={};return typeof e.path=="string"&&e.path.length>0&&(n.path=oE(e.path)),wlt(e.placement)&&(n.placement=e.placement),typeof e.opacity=="number"&&Number.isFinite(e.opacity)&&e.opacity>=0&&e.opacity<=1&&(n.opacity=e.opacity),Object.keys(n).length>0?n:void 0}function k4(t){let e={};if(!t||typeof t!="object")return e;let n=t,s=Clt(n.fillStyle);s&&(e.fillStyle=s);let i=Nlt(n.borderStyle);i&&(e.borderStyle=i);let r=H0(n.textStyle);r&&(e.textStyle=r);let o=Rlt(n.iconStyle);return o&&(e.iconStyle=o),typeof n.showLabel=="boolean"&&(e.showLabel=n.showLabel),e}function M4(t){let e=t&&typeof t=="object"?t:{},n=typeof e.selector=="string"?e.selector:"";if(n.trim().length===0)return null;let s={};return typeof e.value=="string"&&(s.borderStyle={color:e.value}),{selector:n,style:s}}function aE(t){let e=t&&typeof t=="object"?t:{},n=typeof e.selector=="string"?e.selector:"";if(n.trim().length===0)return null;let s=typeof e.path=="string"?e.path:"";if(s.length===0)return null;let i=e.showLabels===true;return {selector:n,style:{showLabel:i,iconStyle:{path:oE(s),placement:i?"badge":"full"}}}}function Llt(t){return t.selector?`atomStyle(${t.selector})`:"atomStyle"}function K4(t,e){let n=t.map(s=>({source:Llt(s),style:s.style}));return eE(n,{context:e})}var Alt,hC=Ie(()=>{tE();uC();sE();Alt=["full","badge"];});function Td(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(typeof e.text!="string"||e.text.trim()==="")return;let n={text:e.text};return typeof e.location=="string"&&e.location.trim()!==""&&(n.location=e.location),n}function F4(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ib(t){let e=t.location?` (${F4(t.location)})`:"";return `<code>${F4(t.text)}</code>${e}`}function j4(t){return t&&typeof t=="object"&&(t=t.points),t===true||t==="togroup"?"togroup":t==="fromgroup"?"fromgroup":"none"}function H4(t){if(t==null)return;if(typeof t!="string")throw new Error(`inferredEdge 'draw' must be a string of the form '<end> -> <end>' (each end '_' or a group name). Got: ${JSON.stringify(t)}`);let e=t.split("->");if(e.length!==2)throw new Error(`inferredEdge 'draw' must contain exactly one '->' (e.g. 'regions -> regions' or '_ -> regions'). Got: '${t}'`);let n=r=>{let o=r.trim();if(!o)throw new Error(`inferredEdge 'draw' has an empty endpoint in '${t}'. Each end must be '_' or a group name.`);return o==="_"?null:o},s=n(e[0]),i=n(e[1]);if(!(s===null&&i===null))return {source:s,target:i}}function B4(t,e){if(t==null)throw new Error(`Size ${e} is required and must be greater than 0`);if(typeof t!="number"||Number.isNaN(t)||t<=0)throw new Error(`Size ${e} must be greater than 0`)}function G4(t,e){B4(t.width,`${e} width`),B4(t.height,`${e} height`);}function U4(){return {constraints:{orientation:{relative:[],cyclic:[]},alignment:[],grouping:{byselector:[]}},directives:{atomColors:[],atomStyles:[],sizes:[],icons:[],edgeColors:[],edgeStyles:[],attributes:[],tags:[],hiddenFields:[],inferredEdges:[],hiddenAtoms:[],hideDisconnected:false,hideDisconnectedBuiltIns:false},warnings:[]}}function q0(t){if(!t)return U4();let e=C4(t),n=e?.constraints,s=e?.directives,i=U4(),r=i.warnings,o=[],a=[];if(n&&Array.isArray(n))try{let c=Flt(n,r);i.constraints=c;let v=n;o=v.filter(y=>y.size).map(y=>(G4(y.size,"constraint"),{height:y.size.height,width:y.size.width,selector:y.size.selector})),a=v.filter(y=>y.hideAtom).map(y=>({selector:y.hideAtom.selector,source:Td(y.hideAtom.source)}));}catch(c){let v=c instanceof Error?c.message:String(c);throw new Error(`${v}`)}if(s&&Array.isArray(s))try{let c=Blt(s,r);i.directives=c,i.directives.sizes=[...o,...c.sizes],i.directives.hiddenAtoms=[...a,...c.hiddenAtoms];}catch(c){let v=c instanceof Error?c.message:String(c);throw new Error(`${v}`)}else i.directives.sizes=o,i.directives.hiddenAtoms=a;return Plt(i,r),i}function Plt(t,e){let n=new Set(t.constraints.grouping.byselector.map(s=>s.name));for(let s of t.directives.inferredEdges){if(!s.draw)continue;let i=[...new Set([s.draw.source,s.draw.target])].filter(r=>r!==null);for(let r of i)if(!n.has(r)){let o=n.size>0?` Known group names: ${[...n].join(", ")}.`:" No group constraints are defined.",a=`inferredEdge '${s.name}': draw references group '${r}', but no group constraint with that name exists.${o} This edge will be skipped unless a group '${r}' is defined.`;console.warn(a),e.push({code:"unresolved-reference",message:a,specType:"inferredEdge"});}}}function Dlt(t){let e=new Map,n=[];for(let s of t){let i=`${s.selector.trim()}|${s.direction}|${s.negated}`;e.has(i)?uE(e.get(i),s):(e.set(i,s),n.push(s));}return n}function uE(t,e){!t.source&&e.source&&(t.source=e.source);}function klt(t){let e=new Map,n=[];for(let s of t){let i=`${s.selector.trim()}|${s.directions.sort().join(",")}|${s.negated}`;e.has(i)?uE(e.get(i),s):(e.set(i,s),n.push(s));}return n}function Mlt(t){let e=new Map,n=[];for(let s of t){let i=`${s.selector.trim()}|${s.direction}|${s.negated}`;e.has(i)?uE(e.get(i),s):(e.set(i,s),n.push(s));}return n}function Klt(t){let e=new Map,n=[];for(let s of t){let i=`${s.selector.trim()}|${s.name}|${s.addEdge}`;e.has(i)?uE(e.get(i),s):(e.set(i,s),n.push(s));}return n}function Flt(t,e=[]){let s=t.map(y=>{let g=y.orientation||y.cyclic||y.align||y.group;return g&&g.hold==="never"?{...y,_negated:true}:{...y,_negated:false}}),i=s.filter(y=>y.cyclic).map(y=>{if(!y.cyclic.selector)throw new Error("Cyclic constraint must have a selector");let g=new Sd(y.cyclic.direction||"clockwise",y.cyclic.selector,y._negated);return g.source=Td(y.cyclic.source),g});i=Dlt(i);let r={};i.forEach(y=>{let g=y.selector.trim();if(!r[g])r[g]=y.direction;else if(r[g]!==y.direction)throw new Error(`Inconsistent cyclic constraint for selector ${g}: ${r[g]}, ${y.direction}`)});let o=s.filter(y=>y.orientation).map(y=>{var g=true;let h=y.orientation;if(!h.selector)throw new Error("Orientation constraint must have selector field");if(!h.directions)throw new Error("Orientation constraint must have directions field");let u=new yc(h.directions,h.selector,y._negated);if(u.source=Td(y.orientation.source),g=u.isInternallyConsistent(),!g)throw new Error(u.inconsistencyMessage());return u});o=klt(o);let a=s.filter(y=>y.group).filter(y=>y.group.field);if(a.length>0){let y=g=>{let h=String(g.field),u=g.groupOn,d=g.addToGroup,f=`'${h}' (groupOn: ${u}, addToGroup: ${d})`;return u===0&&d===1?`${f} becomes 'selector: ${h}'`:u===1&&d===0?`${f} becomes 'selector: ~${h}'`:`${f} needs a selector returning (key, member) pairs \u2014 column ${u} of '${h}' as the key, column ${d} as the member`};throw new Error("group's 'field'/'groupOn'/'addToGroup' were removed. Use a group with a binary 'selector' instead: its first column is the group key, its second the members, and it needs a 'name'. "+a.map(g=>y(g.group)).join("; ")+".")}let c=s.filter(y=>y.group).filter(y=>y.group.selector).map(y=>{if(!y.group.selector)throw new Error("Grouping constraint must have a selector.");if(!y.group.name&&!y._negated)throw new Error("Grouping constraint must have a name.");let g=y.group.name||`_not_group_${y.group.selector}`,h=new xh(y.group.selector,g,y.group.addEdge,y._negated);if(h.source=Td(y.group.source),y.group.addEdge&&typeof y.group.addEdge=="object"){let u=rE(y.group.addEdge);h.connectorLineStyle=u.lineStyle,h.connectorTextStyle=u.textStyle;}return h.labelTextStyle=H0(y.group.textStyle),h});c=Klt(c);let v=s.filter(y=>y.align).map(y=>{if(!y.align.selector)throw new Error("Align constraint must have a selector");if(!y.align.direction)throw new Error("Align constraint must have a direction");let g=new Ed(y.align.direction,y.align.selector,y._negated);if(g.source=Td(y.align.source),!g.isInternallyConsistent())throw new Error(g.inconsistencyMessage());return g});return v=Mlt(v),{orientation:{relative:o,cyclic:i},alignment:v,grouping:{byselector:c}}}function Blt(t,e=[]){let n=t,s=(B,P)=>{console.warn(P),e.push({code:"deprecated",message:P,specType:B});},i=n.filter(B=>B.icon);i.length>0&&s("icon","[spytial] 'icon' is deprecated and will be removed in a future major; use 'atomStyle' with an 'iconStyle' block ({ path, placement: full | badge, opacity }), and atomStyle's own 'showLabel' to control the atom's label.");let r=i.map(B=>aE(B.icon)).filter(B=>B!==null),o=[],a=n.filter(B=>B.atomColor);a.length>0&&s("atomColor","[spytial] 'atomColor' is deprecated and will be removed in a future major; use 'atomStyle' with a 'borderStyle' block (value\u2192borderStyle.color), or a 'fillStyle' block for a real interior fill.");let c=a.map(B=>M4(B.atomColor)).filter(B=>B!==null),v=[],y=n.filter(B=>B.size);y.length>0&&s("size","[spytial] 'size' in the 'directives' section is deprecated and will be removed in a future major; it is a constraint \u2014 move it to the 'constraints' section. Its fields and meaning are unchanged.");let g=y.map(B=>(G4(B.size,"directive"),{height:B.size.height,width:B.size.width,selector:B.size.selector})),h=n.filter(B=>B.edgeColor);h.length>0&&s("edgeColor","[spytial] 'edgeColor' is deprecated and will be removed in a future major; use 'edgeStyle' with a 'lineStyle' block (value\u2192lineStyle.color, style\u2192lineStyle.pattern, weight\u2192lineStyle.weight, highlight\u2192lineStyle.highlight).");let u=h.map(B=>L4(B.edgeColor)),d=[],f=n.filter(B=>B.attribute).map(B=>({field:B.attribute.field,selector:B.attribute.selector,filter:B.attribute.filter,textStyle:H0(B.attribute.textStyle)})),l=n.filter(B=>B.hideField).map(B=>({field:B.hideField.field,selector:B.hideField.selector,filter:B.hideField.filter})),p=n.filter(B=>B.flag).map(B=>B.flag),x=p.includes("hideDisconnected"),b=p.includes("hideDisconnectedBuiltIns"),S=false,_=n.filter(B=>B.inferredEdge).map(B=>{let P=B.inferredEdge,K=rE(P);return (P.color!==void 0||P.style!==void 0||P.weight!==void 0||P.highlight!==void 0)&&(S=true),{name:P.name,selector:P.selector,color:K.lineStyle?.color??P.color,style:K.lineStyle?.pattern??P.style,weight:K.lineStyle?.weight??P.weight,highlight:K.lineStyle?.highlight??P.highlight,textStyle:K.textStyle,draw:H4(P.draw)}});S&&s("inferredEdge","[spytial] inferredEdge's inline 'color'/'style'/'weight'/'highlight' are deprecated; use a 'lineStyle' block (color, pattern, weight, highlight) instead.");let T=n.filter(B=>B.hideAtom);T.length>0&&s("hideAtom","[spytial] 'hideAtom' in the 'directives' section is deprecated and will be removed in a future major; it is a constraint \u2014 move it to the 'constraints' section. Its fields and meaning are unchanged.");let k=T.map(B=>({selector:B.hideAtom.selector,source:Td(B.hideAtom.source)})),R=n.filter(B=>B.tag).map(B=>({toTag:B.tag.toTag,name:B.tag.name,value:B.tag.value,textStyle:H0(B.tag.textStyle)})),I=n.filter(B=>B.edgeStyle).map(B=>({field:B.edgeStyle.field,selector:B.edgeStyle.selector,filter:B.edgeStyle.filter,style:rE(B.edgeStyle)}));I=[...I,...u];let F=n.filter(B=>B.atomStyle).map(B=>({selector:B.atomStyle.selector,style:k4(B.atomStyle)}));return F=[...F,...c,...r],{atomColors:v,atomStyles:F,sizes:g,icons:o,edgeColors:d,edgeStyles:I,attributes:f,tags:R,hiddenFields:l,inferredEdges:_,hiddenAtoms:k,hideDisconnected:x,hideDisconnectedBuiltIns:b}}var G0,yc,Ed,Ilt,xh,Sd,Bf=Ie(()=>{N4();lC();hC();tE();G0=class{constructor(e,n=false){this.selector=e,this.negated=n;}isInternallyConsistent(){return true}inconsistencyMessage(){return `Inconsistent Constraint Operation: ${this.selector}`}providedHTML(){return this.source?ib(this.source):null}toHTML(){let e=this.providedHTML();return e||`${this.negated?"NOT ":""}ConstraintOperation with selector <code>${this.selector} </code>.`}},yc=class extends G0{constructor(e,n,s=false){super(n,s),this.directions=e;}isInternallyConsistent(){return !(this.directions.includes("above")&&this.directions.includes("below")||this.directions.includes("left")&&this.directions.includes("right")||this.directions.includes("directlyLeft")&&!this.directions.every(e=>e==="left"||e==="directlyLeft")||this.directions.includes("directlyRight")&&!this.directions.every(e=>e==="right"||e==="directlyRight")||this.directions.includes("directlyAbove")&&!this.directions.every(e=>e==="above"||e==="directlyAbove")||this.directions.includes("directlyBelow")&&!this.directions.every(e=>e==="below"||e==="directlyBelow"))}inconsistencyMessage(){return `Orientation Constraint with directions [${this.directions.join(", ")}] and selector <code>${this.selector}</code> is internally inconsistent.`}toHTML(){let e=this.providedHTML();if(e)return e;let n=this.negated?"NOT ":"",s=this.directions.join(", ");return `${n}OrientationConstraint with directions [${s}] and selector <code>${this.selector}</code>`}},Ed=class extends G0{constructor(e,n,s=false){super(n,s),this.direction=e;}isInternallyConsistent(){return this.direction==="horizontal"||this.direction==="vertical"}inconsistencyMessage(){return `Align Constraint with direction [${this.direction}] and selector <code>${this.selector}</code> is internally inconsistent.`}toHTML(){let e=this.providedHTML();return e||`${this.negated?"NOT ":""}AlignConstraint with direction [${this.direction}] and selector <code>${this.selector}</code>`}},Ilt=["none","togroup","fromgroup"];xh=class extends G0{constructor(e,n,s="none",i=false){super(e,i),this.name=n,this.addEdge=j4(s);}toHTML(){let e=this.providedHTML();if(e)return e;if(this.negated)return `Members selected by <code>${this.selector}</code> cannot form a group`;let n=this.addEdge==="togroup"?" An edge is drawn from the key to the group.":this.addEdge==="fromgroup"?" An edge is drawn from the group to the key.":"";return `GroupBySelector with selector <code>${this.selector}</code>
|
|
539
|
-
and name <code>${this.name}</code>.${n}`}},Sd=class extends G0{constructor(e,n,s=false){super(n,s),this.direction=e;}inconsistencyMessage(){return `Cyclic constraint with direction [${this.direction}] with selector <code>${this.selector}</code> is inconsistent.`}toHTML(){let e=this.providedHTML();return e||`${this.negated?"NOT ":""}Cyclic constraint with direction [${this.direction}] and selector <code>${this.selector}</code>`}};});function Od(t){return t.type==="positional-conflict"}function lE(t){return t.type==="group-overlap"}function fC(t){return t?.type==="hidden-node-conflict"}function Uf(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z4(t){if(t.attributes&&Object.entries(t.attributes).some(([n,s])=>s&&s.length>0)){let n=t.attributes||{},s=Object.entries(n).sort(([a],[c])=>a.localeCompare(c)),i=[],r=2,o=20;for(let a=0;a<Math.min(s.length,r);a++){let[c,v]=s[a];if(v&&v.length>0){let y=v[0];y.length>o&&(y=y.substring(0,o)+"..."),i.push(`${Uf(c)}: ${Uf(y)}`);}}if(s.length>r&&i.push("..."),i.length>0)return `<span data-node-id="${Uf(t.id)}">${Uf(t.label)} (${i.join(", ")})</span>`}return t.label&&t.label!==t.id?`<span data-node-id="${Uf(t.id)}" title="${q4}">${Uf(t.label)} (id = ${Uf(t.id)})</span>`:`<span data-node-id="${Uf(t.id)}" title="${q4}">${Uf(t.id)}</span>`}function Fa(t){let e=z4,s=t.sourceConstraint&&"negated"in t.sourceConstraint&&t.sourceConstraint.negated?"can":"must";if(ni(t)){let i=t;return `${e(i.top)} ${s} be above ${e(i.bottom)}`}else if(ii(t)){let i=t;return `${e(i.left)} ${s} be to the left of ${e(i.right)}`}else if(Fn(t)){let i=t,r=i.axis,o=i.node1,a=i.node2;return r==="x"?`${e(o)} ${s} be vertically aligned with ${e(a)}`:r==="y"?`${e(o)} ${s} be horizontally aligned with ${e(a)}`:`${e(o)} ${s} be aligned with ${e(a)} along the ${r} axis`}else if(Ls(t)){let i=t;return `${e(i.node)} cannot be in group "${i.group.name}", and groups must be contiguous rectangles`}else if(Is(t)){let i=t,r={left:"to the left of",right:"to the right of",top:"above",bottom:"below"};return `Group "${i.groupA.name}" ${s} be ${r[i.side]} group "${i.groupB.name}"`}return `Unknown constraint type: ${t}`}var q4,Ad=Ie(()=>{Ll();q4="This is a unique identifier in the graph. Hover over graph nodes to see their IDs.";});var Ult,jlt,Il,cE=Ie(()=>{(({min:Ult,max:jlt}=Math)),Il=(t,e=0,n=1)=>Ult(jlt(e,t),n);});var Sy,$4=Ie(()=>{cE();Sy=t=>{t._clipped=false,t._unclipped=t.slice(0);for(let e=0;e<=3;e++)e<3?((t[e]<0||t[e]>255)&&(t._clipped=true),t[e]=Il(t[e],0,255)):e===3&&(t[e]=Il(t[e],0,1));return t};});function kr(t){return V4[Object.prototype.toString.call(t)]||"object"}var V4,ob=Ie(()=>{V4={};for(let t of ["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])V4[`[object ${t}]`]=t.toLowerCase();});var pr,Y4=Ie(()=>{ob();pr=(t,e=null)=>t.length>=3?Array.prototype.slice.call(t):kr(t[0])=="object"&&e?e.split("").filter(n=>t[0][n]!==void 0).map(n=>t[0][n]):t[0].slice(0);});var Uu,W4=Ie(()=>{ob();Uu=t=>{if(t.length<2)return null;let e=t.length-1;return kr(t[e])=="string"?t[e].toLowerCase():null};});function gE(t){return [...t.slice(0,3).reverse(),...t.slice(3)]}var hE,fE,pE,Qs,sb,Pl,dE,X4,Q4,Xr=Ie(()=>{$4();cE();ob();Y4();W4();(({PI:hE,min:fE,max:pE}=Math)),Qs=t=>Math.round(t*100)/100,sb=t=>Math.round(t*100)/100,Pl=hE*2,dE=hE/3,X4=hE/180,Q4=180/hE;});var Kr,Wo=Ie(()=>{Kr={format:{},autodetect:[]};});var pC,Pe,An=Ie(()=>{Xr();Wo();pC=class{constructor(...e){let n=this;if(kr(e[0])==="object"&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let s=Uu(e),i=false;if(!s){i=true,Kr.sorted||(Kr.autodetect=Kr.autodetect.sort((r,o)=>o.p-r.p),Kr.sorted=true);for(let r of Kr.autodetect)if(s=r.test(...e),s)break}if(Kr.format[s]){let r=Kr.format[s].apply(null,i?e:e.slice(0,-1));n._rgb=Sy(r);}else throw new Error("unknown format: "+e);n._rgb.length===3&&n._rgb.push(1);}toString(){return kr(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}},Pe=pC;});var J4,Z4=Ie(()=>{J4="3.2.0";});var t8,Qr,Mo=Ie(()=>{An();Z4();t8=(...t)=>new Pe(...t);t8.version=J4;Qr=t8;});var Hlt,wd,dC=Ie(()=>{Hlt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},wd=Hlt;});var Glt,qlt,zlt,yE,gC=Ie(()=>{Glt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,qlt=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,zlt=t=>{if(t.match(Glt)){(t.length===4||t.length===7)&&(t=t.substr(1)),t.length===3&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);let e=parseInt(t,16),n=e>>16,s=e>>8&255,i=e&255;return [n,s,i,1]}if(t.match(qlt)){(t.length===5||t.length===9)&&(t=t.substr(1)),t.length===4&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);let e=parseInt(t,16),n=e>>24&255,s=e>>16&255,i=e>>8&255,r=Math.round((e&255)/255*100)/100;return [n,s,i,r]}throw new Error(`unknown hex color: ${t}`)},yE=zlt;});var mE,$lt,vE,yC=Ie(()=>{Xr();(({round:mE}=Math)),$lt=(...t)=>{let[e,n,s,i]=pr(t,"rgba"),r=Uu(t)||"auto";i===void 0&&(i=1),r==="auto"&&(r=i<1?"rgba":"rgb"),e=mE(e),n=mE(n),s=mE(s);let a="000000"+(e<<16|n<<8|s).toString(16);a=a.substr(a.length-6);let c="0"+mE(i*255).toString(16);switch(c=c.substr(c.length-2),r.toLowerCase()){case "rgba":return `#${a}${c}`;case "argb":return `#${c}${a}`;default:return `#${a}`}},vE=$lt;});var e8=Ie(()=>{An();Wo();Xr();dC();gC();yC();Pe.prototype.name=function(){let t=vE(this._rgb,"rgb");for(let e of Object.keys(wd))if(wd[e]===t)return e.toLowerCase();return t};Kr.format.named=t=>{if(t=t.toLowerCase(),wd[t])return yE(wd[t]);throw new Error("unknown color name: "+t)};Kr.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&wd[t.toLowerCase()])return "named"}});});var r8=Ie(()=>{An();Xr();Pe.prototype.alpha=function(t,e=false){return t!==void 0&&kr(t)==="number"?e?(this._rgb[3]=t,this):new Pe([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]};});var n8=Ie(()=>{An();Pe.prototype.clipped=function(){return this._rgb._clipped||false};});function Dl(t){let e=Vlt.get(String(t).toLowerCase());if(!e)throw new Error("unknown Lab illuminant "+t);ab.labWhitePoint=t,ab.Xn=e[0],ab.Zn=e[1];}function Cd(){return ab.labWhitePoint}var ab,_h,Vlt,Nd=Ie(()=>{ab={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:.008856451679035631,kKE:8,kK:903.2962962962963,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-0.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-0.2040259135167538,m20:-0.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-0.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-0.0685,m20:-0.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-0.008528664575177328,m10:-0.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},_h=ab,Vlt=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);});var Ylt,Wlt,mC,vC,z0,ub=Ie(()=>{Nd();Xr();Ylt=(...t)=>{t=pr(t,"lab");let[e,n,s]=t,[i,r,o]=Wlt(e,n,s),[a,c,v]=vC(i,r,o);return [a,c,v,t.length>3?t[3]:1]},Wlt=(t,e,n)=>{let{kE:s,kK:i,kKE:r,Xn:o,Yn:a,Zn:c}=_h,v=(t+16)/116,y=.002*e+v,g=v-.005*n,h=y*y*y,u=g*g*g,d=h>s?h:(116*y-16)/i,f=t>r?Math.pow((t+16)/116,3):t/i,l=u>s?u:(116*g-16)/i,p=d*o,x=f*a,b=l*c;return [p,x,b]},mC=t=>{let e=Math.sign(t);return t=Math.abs(t),(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*e},vC=(t,e,n)=>{let{MtxAdaptMa:s,MtxAdaptMaI:i,MtxXYZ2RGB:r,RefWhiteRGB:o,Xn:a,Yn:c,Zn:v}=_h,y=a*s.m00+c*s.m10+v*s.m20,g=a*s.m01+c*s.m11+v*s.m21,h=a*s.m02+c*s.m12+v*s.m22,u=o.X*s.m00+o.Y*s.m10+o.Z*s.m20,d=o.X*s.m01+o.Y*s.m11+o.Z*s.m21,f=o.X*s.m02+o.Y*s.m12+o.Z*s.m22,l=(t*s.m00+e*s.m10+n*s.m20)*(u/y),p=(t*s.m01+e*s.m11+n*s.m21)*(d/g),x=(t*s.m02+e*s.m12+n*s.m22)*(f/h),b=l*i.m00+p*i.m10+x*i.m20,S=l*i.m01+p*i.m11+x*i.m21,_=l*i.m02+p*i.m12+x*i.m22,T=mC(b*r.m00+S*r.m10+_*r.m20),k=mC(b*r.m01+S*r.m11+_*r.m21),R=mC(b*r.m02+S*r.m12+_*r.m22);return [T*255,k*255,R*255]},z0=Ylt;});function Qlt(t,e,n){let{Xn:s,Yn:i,Zn:r,kE:o,kK:a}=_h,c=t/s,v=e/i,y=n/r,g=c>o?Math.pow(c,1/3):(a*c+16)/116,h=v>o?Math.pow(v,1/3):(a*v+16)/116,u=y>o?Math.pow(y,1/3):(a*y+16)/116;return [116*h-16,500*(g-h),200*(h-u)]}function xC(t){let e=Math.sign(t);return t=Math.abs(t),(t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*e}var Xlt,_C,$0,lb=Ie(()=>{Nd();Xr();Xlt=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=_C(e,n,s),[c,v,y]=Qlt(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]};_C=(t,e,n)=>{t=xC(t/255),e=xC(e/255),n=xC(n/255);let{MtxRGB2XYZ:s,MtxAdaptMa:i,MtxAdaptMaI:r,Xn:o,Yn:a,Zn:c,As:v,Bs:y,Cs:g}=_h,h=t*s.m00+e*s.m10+n*s.m20,u=t*s.m01+e*s.m11+n*s.m21,d=t*s.m02+e*s.m12+n*s.m22,f=o*i.m00+a*i.m10+c*i.m20,l=o*i.m01+a*i.m11+c*i.m21,p=o*i.m02+a*i.m12+c*i.m22,x=h*i.m00+u*i.m10+d*i.m20,b=h*i.m01+u*i.m11+d*i.m21,S=h*i.m02+u*i.m12+d*i.m22;return x*=f/v,b*=l/y,S*=p/g,h=x*r.m00+b*r.m10+S*r.m20,u=x*r.m01+b*r.m11+S*r.m21,d=x*r.m02+b*r.m12+S*r.m22,[h,u,d]},$0=Xlt;});var Jlt,V0=Ie(()=>{Xr();Mo();An();Wo();ub();lb();Nd();Pe.prototype.lab=function(){return $0(this._rgb)};Jlt=(...t)=>new Pe(...t,"lab");Object.assign(Qr,{lab:Jlt,getLabWhitePoint:Cd,setLabWhitePoint:Dl});Kr.format.lab=z0;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"lab"),kr(t)==="array"&&t.length===3)return "lab"}});});var i8=Ie(()=>{V0();An();Nd();Pe.prototype.darken=function(t=1){let e=this,n=e.lab();return n[0]-=_h.Kn*t,new Pe(n,"lab").alpha(e.alpha(),true)};Pe.prototype.brighten=function(t=1){return this.darken(-t)};Pe.prototype.darker=Pe.prototype.darken;Pe.prototype.brighter=Pe.prototype.brighten;});var o8=Ie(()=>{An();Pe.prototype.get=function(t){let[e,n]=t.split("."),s=this[e]();if(n){let i=e.indexOf(n)-(e.substr(0,2)==="ok"?2:0);if(i>-1)return s[i];throw new Error(`unknown channel ${n} in mode ${e}`)}else return s};});var Zlt,tct,ect,rct,bC,TC=Ie(()=>{An();Xr();(({pow:Zlt}=Math)),tct=1e-7,ect=20;Pe.prototype.luminance=function(t,e="rgb"){if(t!==void 0&&kr(t)==="number"){if(t===0)return new Pe([0,0,0,this._rgb[3]],"rgb");if(t===1)return new Pe([255,255,255,this._rgb[3]],"rgb");let n=this.luminance(),s=ect,i=(o,a)=>{let c=o.interpolate(a,.5,e),v=c.luminance();return Math.abs(t-v)<tct||!s--?c:v>t?i(o,c):i(c,a)},r=(n>t?i(new Pe([0,0,0]),this):i(this,new Pe([255,255,255]))).rgb();return new Pe([...r,this._rgb[3]])}return rct(...this._rgb.slice(0,3))};rct=(t,e,n)=>(t=bC(t),e=bC(e),n=bC(n),.2126*t+.7152*e+.0722*n),bC=t=>(t/=255,t<=.03928?t/12.92:Zlt((t+.055)/1.055,2.4));});var Bi,ju=Ie(()=>{Bi={};});var bh,cb=Ie(()=>{An();Xr();ju();bh=(t,e,n=.5,...s)=>{let i=s[0]||"lrgb";if(!Bi[i]&&!s.length&&(i=Object.keys(Bi)[0]),!Bi[i])throw new Error(`interpolation mode ${i} is not defined`);return kr(t)!=="object"&&(t=new Pe(t)),kr(e)!=="object"&&(e=new Pe(e)),Bi[i](t,e,n).alpha(t.alpha()+n*(e.alpha()-t.alpha()))};});var s8=Ie(()=>{An();cb();Pe.prototype.mix=Pe.prototype.interpolate=function(t,e=.5,...n){return bh(this,t,e,...n)};});var a8=Ie(()=>{An();Pe.prototype.premultiply=function(t=false){let e=this._rgb,n=e[3];return t?(this._rgb=[e[0]*n,e[1]*n,e[2]*n,n],this):new Pe([e[0]*n,e[1]*n,e[2]*n,n],"rgb")};});var nct,ict,oct,xE,EC=Ie(()=>{Xr();(({sin:nct,cos:ict}=Math)),oct=(...t)=>{let[e,n,s]=pr(t,"lch");return isNaN(s)&&(s=0),s=s*X4,[e,ict(s)*n,nct(s)*n]},xE=oct;});var sct,Y0,_E=Ie(()=>{Xr();EC();ub();sct=(...t)=>{t=pr(t,"lch");let[e,n,s]=t,[i,r,o]=xE(e,n,s),[a,c,v]=z0(i,r,o);return [a,c,v,t.length>3?t[3]:1]},Y0=sct;});var act,u8,l8=Ie(()=>{Xr();_E();act=(...t)=>{let e=gE(pr(t,"hcl"));return Y0(...e)},u8=act;});var uct,lct,cct,hct,bE,SC=Ie(()=>{Xr();(({sqrt:uct,atan2:lct,round:cct}=Math)),hct=(...t)=>{let[e,n,s]=pr(t,"lab"),i=uct(n*n+s*s),r=(lct(s,n)*Q4+360)%360;return cct(i*1e4)===0&&(r=Number.NaN),[e,i,r]},bE=hct;});var fct,hb,OC=Ie(()=>{Xr();lb();SC();fct=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=$0(e,n,s),[c,v,y]=bE(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},hb=fct;});var pct,dct,fb=Ie(()=>{Xr();Mo();An();Wo();_E();l8();OC();Pe.prototype.lch=function(){return hb(this._rgb)};Pe.prototype.hcl=function(){return gE(hb(this._rgb))};pct=(...t)=>new Pe(...t,"lch"),dct=(...t)=>new Pe(...t,"hcl");Object.assign(Qr,{lch:pct,hcl:dct});Kr.format.lch=Y0;Kr.format.hcl=u8;["lch","hcl"].forEach(t=>Kr.autodetect.push({p:2,test:(...e)=>{if(e=pr(e,t),kr(e)==="array"&&e.length===3)return t}}));});var c8=Ie(()=>{fb();An();Nd();Pe.prototype.saturate=function(t=1){let e=this,n=e.lch();return n[1]+=_h.Kn*t,n[1]<0&&(n[1]=0),new Pe(n,"lch").alpha(e.alpha(),true)};Pe.prototype.desaturate=function(t=1){return this.saturate(-t)};});var h8=Ie(()=>{An();Xr();Pe.prototype.set=function(t,e,n=false){let[s,i]=t.split("."),r=this[s]();if(i){let o=s.indexOf(i)-(s.substr(0,2)==="ok"?2:0);if(o>-1){if(kr(e)=="string")switch(e.charAt(0)){case "+":r[o]+=+e;break;case "-":r[o]+=+e;break;case "*":r[o]*=+e.substr(1);break;case "/":r[o]/=+e.substr(1);break;default:r[o]=+e;}else if(kr(e)==="number")r[o]=e;else throw new Error("unsupported value for Color.set");let a=new Pe(r,s);return n?(this._rgb=a._rgb,this):a}throw new Error(`unknown channel ${i} in mode ${s}`)}else return r};});var f8=Ie(()=>{V0();An();cb();Pe.prototype.tint=function(t=.5,...e){return bh(this,"white",t,...e)};Pe.prototype.shade=function(t=.5,...e){return bh(this,"black",t,...e)};});var gct,p8=Ie(()=>{An();ju();gct=(t,e,n)=>{let s=t._rgb,i=e._rgb;return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"rgb")};Bi.rgb=gct;});var AC,W0,yct,d8=Ie(()=>{An();ju();(({sqrt:AC,pow:W0}=Math)),yct=(t,e,n)=>{let[s,i,r]=t._rgb,[o,a,c]=e._rgb;return new Pe(AC(W0(s,2)*(1-n)+W0(o,2)*n),AC(W0(i,2)*(1-n)+W0(a,2)*n),AC(W0(r,2)*(1-n)+W0(c,2)*n),"rgb")};Bi.lrgb=yct;});var mct,g8=Ie(()=>{V0();ju();An();mct=(t,e,n)=>{let s=t.lab(),i=e.lab();return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"lab")};Bi.lab=mct;});var kl,Oy=Ie(()=>{An();kl=(t,e,n,s)=>{let i,r;s==="hsl"?(i=t.hsl(),r=e.hsl()):s==="hsv"?(i=t.hsv(),r=e.hsv()):s==="hcg"?(i=t.hcg(),r=e.hcg()):s==="hsi"?(i=t.hsi(),r=e.hsi()):s==="lch"||s==="hcl"?(s="hcl",i=t.hcl(),r=e.hcl()):s==="oklch"&&(i=t.oklch().reverse(),r=e.oklch().reverse());let o,a,c,v,y,g;(s.substr(0,1)==="h"||s==="oklch")&&([o,c,y]=i,[a,v,g]=r);let h,u,d,f;return !isNaN(o)&&!isNaN(a)?(a>o&&a-o>180?f=a-(o+360):a<o&&o-a>180?f=a+360-o:f=a-o,u=o+n*f):isNaN(o)?isNaN(a)?u=Number.NaN:(u=a,(y==1||y==0)&&s!="hsv"&&(h=v)):(u=o,(g==1||g==0)&&s!="hsv"&&(h=c)),h===void 0&&(h=c+n*(v-c)),d=y+n*(g-y),s==="oklch"?new Pe([d,h,u],s):new Pe([u,h,d],s)};});var y8,m8=Ie(()=>{fb();Oy();ju();y8=(t,e,n)=>kl(t,e,n,"lch");Bi.lch=y8;Bi.hcl=y8;});var vct,v8,x8=Ie(()=>{Xr();vct=t=>{if(kr(t)=="number"&&t>=0&&t<=16777215){let e=t>>16,n=t>>8&255,s=t&255;return [e,n,s,1]}throw new Error("unknown num color: "+t)},v8=vct;});var xct,_8,b8=Ie(()=>{Xr();xct=(...t)=>{let[e,n,s]=pr(t,"rgb");return (e<<16)+(n<<8)+s},_8=xct;});var _ct,wC=Ie(()=>{Mo();An();Wo();Xr();x8();b8();Pe.prototype.num=function(){return _8(this._rgb)};_ct=(...t)=>new Pe(...t,"num");Object.assign(Qr,{num:_ct});Kr.format.num=v8;Kr.autodetect.push({p:5,test:(...t)=>{if(t.length===1&&kr(t[0])==="number"&&t[0]>=0&&t[0]<=16777215)return "num"}});});var bct,T8=Ie(()=>{wC();ju();An();bct=(t,e,n)=>{let s=t.num(),i=e.num();return new Pe(s+n*(i-s),"num")};Bi.num=bct;});var Tct,Ect,E8,S8=Ie(()=>{Xr();(({floor:Tct}=Math)),Ect=(...t)=>{t=pr(t,"hcg");let[e,n,s]=t,i,r,o;s=s*255;let a=n*255;if(n===0)i=r=o=s;else {e===360&&(e=0),e>360&&(e-=360),e<0&&(e+=360),e/=60;let c=Tct(e),v=e-c,y=s*(1-n),g=y+a*(1-v),h=y+a*v,u=y+a;switch(c){case 0:[i,r,o]=[u,h,y];break;case 1:[i,r,o]=[g,u,y];break;case 2:[i,r,o]=[y,u,h];break;case 3:[i,r,o]=[y,g,u];break;case 4:[i,r,o]=[h,y,u];break;case 5:[i,r,o]=[u,y,g];break}}return [i,r,o,t.length>3?t[3]:1]},E8=Ect;});var Sct,O8,A8=Ie(()=>{Xr();Sct=(...t)=>{let[e,n,s]=pr(t,"rgb"),i=fE(e,n,s),r=pE(e,n,s),o=r-i,a=o*100/255,c=i/(255-o)*100,v;return o===0?v=Number.NaN:(e===r&&(v=(n-s)/o),n===r&&(v=2+(s-e)/o),s===r&&(v=4+(e-n)/o),v*=60,v<0&&(v+=360)),[v,a,c]},O8=Sct;});var Oct,CC=Ie(()=>{Xr();Mo();An();Wo();S8();A8();Pe.prototype.hcg=function(){return O8(this._rgb)};Oct=(...t)=>new Pe(...t,"hcg");Qr.hcg=Oct;Kr.format.hcg=E8;Kr.autodetect.push({p:1,test:(...t)=>{if(t=pr(t,"hcg"),kr(t)==="array"&&t.length===3)return "hcg"}});});var Act,w8=Ie(()=>{CC();Oy();ju();Act=(t,e,n)=>kl(t,e,n,"hcg");Bi.hcg=Act;});var X0,wct,C8,N8=Ie(()=>{Xr();(({cos:X0}=Math)),wct=(...t)=>{t=pr(t,"hsi");let[e,n,s]=t,i,r,o;return isNaN(e)&&(e=0),isNaN(n)&&(n=0),e>360&&(e-=360),e<0&&(e+=360),e/=360,e<1/3?(o=(1-n)/3,i=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,r=1-(o+i)):e<2/3?(e-=1/3,i=(1-n)/3,r=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,o=1-(i+r)):(e-=2/3,r=(1-n)/3,o=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,i=1-(r+o)),i=Il(s*i*3),r=Il(s*r*3),o=Il(s*o*3),[i*255,r*255,o*255,t.length>3?t[3]:1]},C8=wct;});var Cct,Nct,Rct,Lct,R8,L8=Ie(()=>{Xr();(({min:Cct,sqrt:Nct,acos:Rct}=Math)),Lct=(...t)=>{let[e,n,s]=pr(t,"rgb");e/=255,n/=255,s/=255;let i,r=Cct(e,n,s),o=(e+n+s)/3,a=o>0?1-r/o:0;return a===0?i=NaN:(i=(e-n+(e-s))/2,i/=Nct((e-n)*(e-n)+(e-s)*(n-s)),i=Rct(i),s>n&&(i=Pl-i),i/=Pl),[i*360,a,o]},R8=Lct;});var Ict,NC=Ie(()=>{Xr();Mo();An();Wo();N8();L8();Pe.prototype.hsi=function(){return R8(this._rgb)};Ict=(...t)=>new Pe(...t,"hsi");Qr.hsi=Ict;Kr.format.hsi=C8;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsi"),kr(t)==="array"&&t.length===3)return "hsi"}});});var Pct,I8=Ie(()=>{NC();Oy();ju();Pct=(t,e,n)=>kl(t,e,n,"hsi");Bi.hsi=Pct;});var Dct,pb,RC=Ie(()=>{Xr();Dct=(...t)=>{t=pr(t,"hsl");let[e,n,s]=t,i,r,o;if(n===0)i=r=o=s*255;else {let a=[0,0,0],c=[0,0,0],v=s<.5?s*(1+n):s+n-s*n,y=2*s-v,g=e/360;a[0]=g+1/3,a[1]=g,a[2]=g-1/3;for(let h=0;h<3;h++)a[h]<0&&(a[h]+=1),a[h]>1&&(a[h]-=1),6*a[h]<1?c[h]=y+(v-y)*6*a[h]:2*a[h]<1?c[h]=v:3*a[h]<2?c[h]=y+(v-y)*(2/3-a[h])*6:c[h]=y;[i,r,o]=[c[0]*255,c[1]*255,c[2]*255];}return t.length>3?[i,r,o,t[3]]:[i,r,o,1]},pb=Dct;});var kct,TE,LC=Ie(()=>{Xr();kct=(...t)=>{t=pr(t,"rgba");let[e,n,s]=t;e/=255,n/=255,s/=255;let i=fE(e,n,s),r=pE(e,n,s),o=(r+i)/2,a,c;return r===i?(a=0,c=Number.NaN):a=o<.5?(r-i)/(r+i):(r-i)/(2-r-i),e==r?c=(n-s)/(r-i):n==r?c=2+(s-e)/(r-i):s==r&&(c=4+(e-n)/(r-i)),c*=60,c<0&&(c+=360),t.length>3&&t[3]!==void 0?[c,a,o,t[3]]:[c,a,o]},TE=kct;});var Mct,EE=Ie(()=>{Xr();Mo();An();Wo();RC();LC();Pe.prototype.hsl=function(){return TE(this._rgb)};Mct=(...t)=>new Pe(...t,"hsl");Qr.hsl=Mct;Kr.format.hsl=pb;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsl"),kr(t)==="array"&&t.length===3)return "hsl"}});});var Kct,P8=Ie(()=>{EE();Oy();ju();Kct=(t,e,n)=>kl(t,e,n,"hsl");Bi.hsl=Kct;});var Fct,Bct,D8,k8=Ie(()=>{Xr();(({floor:Fct}=Math)),Bct=(...t)=>{t=pr(t,"hsv");let[e,n,s]=t,i,r,o;if(s*=255,n===0)i=r=o=s;else {e===360&&(e=0),e>360&&(e-=360),e<0&&(e+=360),e/=60;let a=Fct(e),c=e-a,v=s*(1-n),y=s*(1-n*c),g=s*(1-n*(1-c));switch(a){case 0:[i,r,o]=[s,g,v];break;case 1:[i,r,o]=[y,s,v];break;case 2:[i,r,o]=[v,s,g];break;case 3:[i,r,o]=[v,y,s];break;case 4:[i,r,o]=[g,v,s];break;case 5:[i,r,o]=[s,v,y];break}}return [i,r,o,t.length>3?t[3]:1]},D8=Bct;});var Uct,jct,Hct,M8,K8=Ie(()=>{Xr();(({min:Uct,max:jct}=Math)),Hct=(...t)=>{t=pr(t,"rgb");let[e,n,s]=t,i=Uct(e,n,s),r=jct(e,n,s),o=r-i,a,c,v;return v=r/255,r===0?(a=Number.NaN,c=0):(c=o/r,e===r&&(a=(n-s)/o),n===r&&(a=2+(s-e)/o),s===r&&(a=4+(e-n)/o),a*=60,a<0&&(a+=360)),[a,c,v]},M8=Hct;});var Gct,IC=Ie(()=>{Xr();Mo();An();Wo();k8();K8();Pe.prototype.hsv=function(){return M8(this._rgb)};Gct=(...t)=>new Pe(...t,"hsv");Qr.hsv=Gct;Kr.format.hsv=D8;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsv"),kr(t)==="array"&&t.length===3)return "hsv"}});});var qct,F8=Ie(()=>{IC();Oy();ju();qct=(t,e,n)=>kl(t,e,n,"hsv");Bi.hsv=qct;});function Ay(t,e){let n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(o=>[o]));let s=e[0].length,i=e[0].map((o,a)=>e.map(c=>c[a])),r=t.map(o=>i.map(a=>Array.isArray(o)?o.reduce((c,v,y)=>c+v*(a[y]||0),0):a.reduce((c,v)=>c+v*o,0)));return n===1&&(r=r[0]),s===1?r.map(o=>o[0]):r}var PC=Ie(()=>{});function $ct(t){var e=[[1.2268798758459243,-0.5578149944602171,.2813910456659647],[-0.0405757452148008,1.112286803280317,-0.0717110580655164],[-0.0763729366746601,-0.4214933324022432,1.5869240198367816]],n=[[1,.3963377773761749,.2158037573099136],[1,-0.1055613458156586,-0.0638541728258133],[1,-0.0894841775298119,-1.2914855480194092]],s=Ay(n,t);return Ay(e,s.map(i=>i**3))}var zct,Q0,SE=Ie(()=>{Xr();PC();ub();zct=(...t)=>{t=pr(t,"lab");let[e,n,s,...i]=t,[r,o,a]=$ct([e,n,s]),[c,v,y]=vC(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]};Q0=zct;});function Yct(t){let e=[[.819022437996703,.3619062600528904,-0.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],n=[[.210454268309314,.7936177747023054,-0.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-0.8086757549230774]],s=Ay(e,t);return Ay(n,s.map(i=>Math.cbrt(i)))}var Vct,J0,OE=Ie(()=>{Xr();PC();lb();Vct=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),r=_C(e,n,s);return [...Yct(r),...i.length>0&&i[0]<1?[i[0]]:[]]};J0=Vct;});var Wct,DC=Ie(()=>{Xr();Mo();An();Wo();SE();OE();Pe.prototype.oklab=function(){return J0(this._rgb)};Wct=(...t)=>new Pe(...t,"oklab");Object.assign(Qr,{oklab:Wct});Kr.format.oklab=Q0;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"oklab"),kr(t)==="array"&&t.length===3)return "oklab"}});});var Xct,B8=Ie(()=>{DC();ju();An();Xct=(t,e,n)=>{let s=t.oklab(),i=e.oklab();return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"oklab")};Bi.oklab=Xct;});var Qct,U8=Ie(()=>{fb();Oy();ju();Qct=(t,e,n)=>kl(t,e,n,"oklch");Bi.oklch=Qct;});var kC,MC,KC,j8,H8,Jct,G8,Zct,q8=Ie(()=>{An();Xr();(({pow:kC,sqrt:MC,PI:KC,cos:j8,sin:H8,atan2:Jct}=Math)),G8=(t,e="lrgb",n=null)=>{let s=t.length;n||(n=Array.from(new Array(s)).map(()=>1));let i=s/n.reduce(function(g,h){return g+h});if(n.forEach((g,h)=>{n[h]*=i;}),t=t.map(g=>new Pe(g)),e==="lrgb")return Zct(t,n);let r=t.shift(),o=r.get(e),a=[],c=0,v=0;for(let g=0;g<o.length;g++)if(o[g]=(o[g]||0)*n[0],a.push(isNaN(o[g])?0:n[0]),e.charAt(g)==="h"&&!isNaN(o[g])){let h=o[g]/180*KC;c+=j8(h)*n[0],v+=H8(h)*n[0];}let y=r.alpha()*n[0];t.forEach((g,h)=>{let u=g.get(e);y+=g.alpha()*n[h+1];for(let d=0;d<o.length;d++)if(!isNaN(u[d]))if(a[d]+=n[h+1],e.charAt(d)==="h"){let f=u[d]/180*KC;c+=j8(f)*n[h+1],v+=H8(f)*n[h+1];}else o[d]+=u[d]*n[h+1];});for(let g=0;g<o.length;g++)if(e.charAt(g)==="h"){let h=Jct(v/a[g],c/a[g])/KC*180;for(;h<0;)h+=360;for(;h>=360;)h-=360;o[g]=h;}else o[g]=o[g]/a[g];return y/=s,new Pe(o,e).alpha(y>.99999?1:y,true)},Zct=(t,e)=>{let n=t.length,s=[0,0,0,0];for(let i=0;i<t.length;i++){let r=t[i],o=e[i]/n,a=r._rgb;s[0]+=kC(a[0],2)*o,s[1]+=kC(a[1],2)*o,s[2]+=kC(a[2],2)*o,s[3]+=a[3]*o;}return s[0]=MC(s[0]),s[1]=MC(s[1]),s[2]=MC(s[2]),s[3]>.9999999&&(s[3]=1),new Pe(Sy(s))};});function wy(t){let e="rgb",n=Qr("#ccc"),s=0,i=[0,1],r=[0,1],o=[],a=[0,0],c=false,v=[],y=false,g=0,h=1,u=false,d={},f=true,l=1,p=function(R){if(R=R||["#fff","#000"],R&&kr(R)==="string"&&Qr.brewer&&Qr.brewer[R.toLowerCase()]&&(R=Qr.brewer[R.toLowerCase()]),kr(R)==="array"){R.length===1&&(R=[R[0],R[0]]),R=R.slice(0);for(let I=0;I<R.length;I++)R[I]=Qr(R[I]);o.length=0;for(let I=0;I<R.length;I++)o.push(I/(R.length-1));}return T(),v=R},x=function(R){if(c!=null){let I=c.length-1,F=0;for(;F<I&&R>=c[F];)F++;return F-1}return 0},b=R=>R,S=R=>R,_=function(R,I){let F,B;if(I==null&&(I=false),isNaN(R)||R===null)return n;I?B=R:c&&c.length>2?B=x(R)/(c.length-2):h!==g?B=(R-g)/(h-g):B=1,B=S(B),I||(B=b(B)),l!==1&&(B=tht(B,l)),B=a[0]+B*(1-a[0]-a[1]),B=Il(B,0,1);let P=Math.floor(B*1e4);if(f&&d[P])F=d[P];else {if(kr(v)==="array")for(let K=0;K<o.length;K++){let G=o[K];if(B<=G){F=v[K];break}if(B>=G&&K===o.length-1){F=v[K];break}if(B>G&&B<o[K+1]){B=(B-G)/(o[K+1]-G),F=Qr.interpolate(v[K],v[K+1],B,e);break}}else kr(v)==="function"&&(F=v(B));f&&(d[P]=F);}return F};var T=()=>d={};p(t);let k=function(R){let I=Qr(_(R));return y&&I[y]?I[y]():I};return k.classes=function(R){if(R!=null){if(kr(R)==="array")c=R,i=[R[0],R[R.length-1]];else {let I=Qr.analyze(i);R===0?c=[I.min,I.max]:c=Qr.limits(I,"e",R);}return k}return c},k.domain=function(R){if(!arguments.length)return r;r=R.slice(0),g=R[0],h=R[R.length-1],o=[];let I=v.length;if(R.length===I&&g!==h)for(let F of Array.from(R))o.push((F-g)/(h-g));else {for(let F=0;F<I;F++)o.push(F/(I-1));if(R.length>2){let F=R.map((P,K)=>K/(R.length-1)),B=R.map(P=>(P-g)/(h-g));B.every((P,K)=>F[K]===P)||(S=P=>{if(P<=0||P>=1)return P;let K=0;for(;P>=B[K+1];)K++;let G=(P-B[K])/(B[K+1]-B[K]);return F[K]+G*(F[K+1]-F[K])});}}return i=[g,h],k},k.mode=function(R){return arguments.length?(e=R,T(),k):e},k.range=function(R,I){return p(R),k},k.out=function(R){return y=R,k},k.spread=function(R){return arguments.length?(s=R,k):s},k.correctLightness=function(R){return R==null&&(R=true),u=R,T(),u?b=function(I){let F=_(0,true).lab()[0],B=_(1,true).lab()[0],P=F>B,K=_(I,true).lab()[0],G=F+(B-F)*I,V=K-G,Q=0,rt=1,ht=20;for(;Math.abs(V)>.01&&ht-- >0;)(function(){return P&&(V*=-1),V<0?(Q=I,I+=(rt-I)*.5):(rt=I,I+=(Q-I)*.5),K=_(I,true).lab()[0],V=K-G})();return I}:b=I=>I,k},k.padding=function(R){return R!=null?(kr(R)==="number"&&(R=[R,R]),a=R,k):a},k.colors=function(R,I){arguments.length<2&&(I="hex");let F=[];if(arguments.length===0)F=v.slice(0);else if(R===1)F=[k(.5)];else if(R>1){let B=i[0],P=i[1]-B;F=eht(0,R).map(K=>k(B+K/(R-1)*P));}else {t=[];let B=[];if(c&&c.length>2)for(let P=1,K=c.length,G=1<=K;G?P<K:P>K;G?P++:P--)B.push((c[P-1]+c[P])*.5);else B=i;F=B.map(P=>k(P));}return Qr[I]&&(F=F.map(B=>B[I]())),F},k.cache=function(R){return R!=null?(f=R,k):f},k.gamma=function(R){return R!=null?(l=R,k):l},k.nodata=function(R){return R!=null?(n=Qr(R),k):n},k}function eht(t,e,n){let s=[],i=t<e,r=e;for(let o=t;i?o<r:o>r;i?o++:o--)s.push(o);return s}var tht,AE=Ie(()=>{Mo();Xr();({pow:tht}=Math);});var rht,nht,z8,$8=Ie(()=>{An();V0();AE();rht=function(t){let e=[1,1];for(let n=1;n<t;n++){let s=[1];for(let i=1;i<=e.length;i++)s[i]=(e[i]||0)+e[i-1];e=s;}return e},nht=function(t){let e,n,s,i;if(t=t.map(r=>new Pe(r)),t.length===2)[n,s]=t.map(r=>r.lab()),e=function(r){let o=[0,1,2].map(a=>n[a]+r*(s[a]-n[a]));return new Pe(o,"lab")};else if(t.length===3)[n,s,i]=t.map(r=>r.lab()),e=function(r){let o=[0,1,2].map(a=>(1-r)*(1-r)*n[a]+2*(1-r)*r*s[a]+r*r*i[a]);return new Pe(o,"lab")};else if(t.length===4){let r;[n,s,i,r]=t.map(o=>o.lab()),e=function(o){let a=[0,1,2].map(c=>(1-o)*(1-o)*(1-o)*n[c]+3*(1-o)*(1-o)*o*s[c]+3*(1-o)*o*o*i[c]+o*o*o*r[c]);return new Pe(a,"lab")};}else if(t.length>=5){let r,o,a;r=t.map(c=>c.lab()),a=t.length-1,o=rht(a),e=function(c){let v=1-c,y=[0,1,2].map(g=>r.reduce((h,u,d)=>h+o[d]*v**(a-d)*c**d*u[g],0));return new Pe(y,"lab")};}else throw new RangeError("No point in running bezier with only one color.");return e},z8=t=>{let e=nht(t);return e.scale=()=>wy(e),e};});var V8,iht,FC=Ie(()=>{Mo();An();Wo();Xr();({round:V8}=Math);Pe.prototype.rgb=function(t=true){return t===false?this._rgb.slice(0,3):this._rgb.slice(0,3).map(V8)};Pe.prototype.rgba=function(t=true){return this._rgb.slice(0,4).map((e,n)=>n<3?t===false?e:V8(e):e)};iht=(...t)=>new Pe(...t,"rgb");Object.assign(Qr,{rgb:iht});Kr.format.rgb=(...t)=>{let e=pr(t,"rgba");return e[3]===void 0&&(e[3]=1),e};Kr.autodetect.push({p:3,test:(...t)=>{if(t=pr(t,"rgba"),kr(t)==="array"&&(t.length===3||t.length===4&&kr(t[3])=="number"&&t[3]>=0&&t[3]<=1))return "rgb"}});});var mc,Rd,Ld,oht,sht,aht,uht,lht,cht,hht,fht,Y8,W8=Ie(()=>{FC();Mo();mc=(t,e,n)=>{if(!mc[n])throw new Error("unknown blend mode "+n);return mc[n](t,e)},Rd=t=>(e,n)=>{let s=Qr(n).rgb(),i=Qr(e).rgb();return Qr.rgb(t(s,i))},Ld=t=>(e,n)=>{let s=[];return s[0]=t(e[0],n[0]),s[1]=t(e[1],n[1]),s[2]=t(e[2],n[2]),s},oht=t=>t,sht=(t,e)=>t*e/255,aht=(t,e)=>t>e?e:t,uht=(t,e)=>t>e?t:e,lht=(t,e)=>255*(1-(1-t/255)*(1-e/255)),cht=(t,e)=>e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255)),hht=(t,e)=>255*(1-(1-e/255)/(t/255)),fht=(t,e)=>t===255?255:(t=255*(e/255)/(1-t/255),t>255?255:t);mc.normal=Rd(Ld(oht));mc.multiply=Rd(Ld(sht));mc.screen=Rd(Ld(lht));mc.overlay=Rd(Ld(cht));mc.darken=Rd(Ld(aht));mc.lighten=Rd(Ld(uht));mc.dodge=Rd(Ld(fht));mc.burn=Rd(Ld(hht));Y8=mc;});function X8(t=300,e=-1.5,n=1,s=1,i=[0,1]){let r=0,o;kr(i)==="array"?o=i[1]-i[0]:(o=0,i=[i,i]);let a=function(c){let v=Pl*((t+120)/360+e*c),y=pht(i[0]+o*c,s),h=(r!==0?n[0]+c*r:n)*y*(1-y)/2,u=ght(v),d=dht(v),f=y+h*(-0.14861*u+1.78277*d),l=y+h*(-0.29227*u-.90649*d),p=y+h*(1.97294*u);return Qr(Sy([f*255,l*255,p*255,1]))};return a.start=function(c){return c==null?t:(t=c,a)},a.rotations=function(c){return c==null?e:(e=c,a)},a.gamma=function(c){return c==null?s:(s=c,a)},a.hue=function(c){return c==null?n:(n=c,kr(n)==="array"?(r=n[1]-n[0],r===0&&(n=n[1])):r=0,a)},a.lightness=function(c){return c==null?i:(kr(c)==="array"?(i=c,o=c[1]-c[0]):(i=[c,c],o=0),a)},a.scale=()=>Qr.scale(a),a.hue(n),a}var pht,dht,ght,Q8=Ie(()=>{Xr();Mo();({pow:pht,sin:dht,cos:ght}=Math);});var yht,mht,vht,J8,Z8=Ie(()=>{An();yht="0123456789abcdef",{floor:mht,random:vht}=Math,J8=(t=vht)=>{let e="#";for(let n=0;n<6;n++)e+=yht.charAt(mht(t()*16));return new Pe(e,"hex")};});function BC(t,e=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return kr(t)==="object"&&(t=Object.values(t)),t.forEach(s=>{e&&kr(s)==="object"&&(s=s[e]),s!=null&&!isNaN(s)&&(n.values.push(s),n.sum+=s,s<n.min&&(n.min=s),s>n.max&&(n.max=s),n.count+=1);}),n.domain=[n.min,n.max],n.limits=(s,i)=>UC(n,s,i),n}function UC(t,e="equal",n=7){kr(t)=="array"&&(t=BC(t));let{min:s,max:i}=t,r=t.values.sort((a,c)=>a-c);if(n===1)return [s,i];let o=[];if(e.substr(0,1)==="c"&&(o.push(s),o.push(i)),e.substr(0,1)==="e"){o.push(s);for(let a=1;a<n;a++)o.push(s+a/n*(i-s));o.push(i);}else if(e.substr(0,1)==="l"){if(s<=0)throw new Error("Logarithmic scales are only possible for values > 0");let a=Math.LOG10E*t9(s),c=Math.LOG10E*t9(i);o.push(s);for(let v=1;v<n;v++)o.push(xht(10,a+v/n*(c-a)));o.push(i);}else if(e.substr(0,1)==="q"){o.push(s);for(let a=1;a<n;a++){let c=(r.length-1)*a/n,v=_ht(c);if(v===c)o.push(r[v]);else {let y=c-v;o.push(r[v]*(1-y)+r[v+1]*y);}}o.push(i);}else if(e.substr(0,1)==="k"){let a,c=r.length,v=new Array(c),y=new Array(n),g=true,h=0,u=null;u=[],u.push(s);for(let l=1;l<n;l++)u.push(s+l/n*(i-s));for(u.push(i);g;){for(let p=0;p<n;p++)y[p]=0;for(let p=0;p<c;p++){let x=r[p],b=Number.MAX_VALUE,S;for(let _=0;_<n;_++){let T=bht(u[_]-x);T<b&&(b=T,S=_),y[S]++,v[p]=S;}}let l=new Array(n);for(let p=0;p<n;p++)l[p]=null;for(let p=0;p<c;p++)a=v[p],l[a]===null?l[a]=r[p]:l[a]+=r[p];for(let p=0;p<n;p++)l[p]*=1/y[p];g=false;for(let p=0;p<n;p++)if(l[p]!==u[p]){g=true;break}u=l,h++,h>200&&(g=false);}let d={};for(let l=0;l<n;l++)d[l]=[];for(let l=0;l<c;l++)a=v[l],d[a].push(r[l]);let f=[];for(let l=0;l<n;l++)f.push(d[l][0]),f.push(d[l][d[l].length-1]);f=f.sort((l,p)=>l-p),o.push(f[0]);for(let l=1;l<f.length;l+=2){let p=f[l];!isNaN(p)&&o.indexOf(p)===-1&&o.push(p);}}return o}var t9,xht,_ht,bht,jC=Ie(()=>{ob();({log:t9,pow:xht,floor:_ht,abs:bht}=Math);});var e9,r9=Ie(()=>{An();TC();e9=(t,e)=>{t=new Pe(t),e=new Pe(e);let n=t.luminance(),s=e.luminance();return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)};});function s9(t,e,n){return .2126729*Math.pow(t/255,2.4)+.7151522*Math.pow(e/255,2.4)+.072175*Math.pow(n/255,2.4)}var n9,Tht,Eht,i9,wE,o9,a9,u9=Ie(()=>{An();cb();n9=.027,Tht=5e-4,Eht=.1,i9=1.14,wE=.022,o9=1.414,a9=(t,e)=>{t=new Pe(t),e=new Pe(e),t.alpha()<1&&(t=bh(e,t,t.alpha(),"rgb"));let n=s9(...t.rgb()),s=s9(...e.rgb()),i=n>=wE?n:n+Math.pow(wE-n,o9),r=s>=wE?s:s+Math.pow(wE-s,o9),o=Math.pow(r,.56)-Math.pow(i,.57),a=Math.pow(r,.65)-Math.pow(i,.62),c=Math.abs(r-i)<Tht?0:i<r?o*i9:a*i9;return (Math.abs(c)<Eht?0:c>0?c-n9:c+n9)*100};});function p9(t,e,n=1,s=1,i=1){var r=function(gt){return 360*gt/(2*f9)},o=function(gt){return 2*f9*gt/360};t=new Pe(t),e=new Pe(e);let[a,c,v]=Array.from(t.lab()),[y,g,h]=Array.from(e.lab()),u=(a+y)/2,d=jf(Xo(c,2)+Xo(v,2)),f=jf(Xo(g,2)+Xo(h,2)),l=(d+f)/2,p=.5*(1-jf(Xo(l,7)/(Xo(l,7)+Xo(25,7)))),x=c*(1+p),b=g*(1+p),S=jf(Xo(x,2)+Xo(v,2)),_=jf(Xo(b,2)+Xo(h,2)),T=(S+_)/2,k=r(l9(v,x)),R=r(l9(h,b)),I=k>=0?k:k+360,F=R>=0?R:R+360,B=c9(I-F)>180?(I+F+360)/2:(I+F)/2,P=1-.17*CE(o(B-30))+.24*CE(o(2*B))+.32*CE(o(3*B+6))-.2*CE(o(4*B-63)),K=F-I;K=c9(K)<=180?K:F<=I?K+360:K-360,K=2*jf(S*_)*h9(o(K)/2);let G=y-a,V=_-S,Q=1+.015*Xo(u-50,2)/jf(20+Xo(u-50,2)),rt=1+.045*T,ht=1+.015*T*P,it=30*Aht(-Xo((B-275)/25,2)),q=-(2*jf(Xo(T,7)/(Xo(T,7)+Xo(25,7))))*h9(2*o(it)),nt=jf(Xo(G/(n*Q),2)+Xo(V/(s*rt),2)+Xo(K/(i*ht),2)+q*(V/(s*rt))*(K/(i*ht)));return Oht(0,Sht(100,nt))}var jf,Xo,Sht,Oht,l9,c9,CE,h9,Aht,f9,d9=Ie(()=>{An();({sqrt:jf,pow:Xo,min:Sht,max:Oht,atan2:l9,abs:c9,cos:CE,sin:h9,exp:Aht,PI:f9}=Math);});function g9(t,e,n="lab"){t=new Pe(t),e=new Pe(e);let s=t.get(n),i=e.get(n),r=0;for(let o in s){let a=(s[o]||0)-(i[o]||0);r+=a*a;}return Math.sqrt(r)}var y9=Ie(()=>{An();});var m9,v9=Ie(()=>{An();m9=(...t)=>{try{return new Pe(...t),!0}catch{return false}};});var x9,_9=Ie(()=>{Mo();EE();AE();x9={cool(){return wy([Qr.hsl(180,1,.9),Qr.hsl(250,.7,.4)])},hot(){return wy(["#000","#f00","#ff0","#fff"]).mode("rgb")}};});var HC,T9,b9,wht,E9,S9=Ie(()=>{HC={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},T9=Object.keys(HC),b9=new Map(T9.map(t=>[t.toLowerCase(),t])),wht=typeof Proxy=="function"?new Proxy(HC,{get(t,e){let n=e.toLowerCase();if(b9.has(n))return t[b9.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(T9)}}):HC,E9=wht;});var Cht,O9,A9=Ie(()=>{Xr();Cht=(...t)=>{t=pr(t,"cmyk");let[e,n,s,i]=t,r=t.length>4?t[4]:1;return i===1?[0,0,0,r]:[e>=1?0:255*(1-e)*(1-i),n>=1?0:255*(1-n)*(1-i),s>=1?0:255*(1-s)*(1-i),r]},O9=Cht;});var w9,Nht,C9,N9=Ie(()=>{Xr();(({max:w9}=Math)),Nht=(...t)=>{let[e,n,s]=pr(t,"rgb");e=e/255,n=n/255,s=s/255;let i=1-w9(e,w9(n,s)),r=i<1?1/(1-i):0,o=(1-e-i)*r,a=(1-n-i)*r,c=(1-s-i)*r;return [o,a,c,i]},C9=Nht;});var Rht,R9=Ie(()=>{Mo();An();Wo();Xr();A9();N9();Pe.prototype.cmyk=function(){return C9(this._rgb)};Rht=(...t)=>new Pe(...t,"cmyk");Object.assign(Qr,{cmyk:Rht});Kr.format.cmyk=O9;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"cmyk"),kr(t)==="array"&&t.length===4)return "cmyk"}});});var Lht,L9,I9=Ie(()=>{Xr();Lht=(...t)=>{let e=pr(t,"hsla"),n=Uu(t)||"lsa";return e[0]=Qs(e[0]||0)+"deg",e[1]=Qs(e[1]*100)+"%",e[2]=Qs(e[2]*100)+"%",n==="hsla"||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),n="hsla"):e.length=3,`${n.substr(0,3)}(${e.join(" ")})`},L9=Lht;});var Iht,P9,D9=Ie(()=>{Xr();Iht=(...t)=>{let e=pr(t,"lab"),n=Uu(t)||"lab";return e[0]=Qs(e[0])+"%",e[1]=Qs(e[1]),e[2]=Qs(e[2]),n==="laba"||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lab(${e.join(" ")})`},P9=Iht;});var Pht,k9,M9=Ie(()=>{Xr();Pht=(...t)=>{let e=pr(t,"lch"),n=Uu(t)||"lab";return e[0]=Qs(e[0])+"%",e[1]=Qs(e[1]),e[2]=isNaN(e[2])?"none":Qs(e[2])+"deg",n==="lcha"||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lch(${e.join(" ")})`},k9=Pht;});var Dht,K9,F9=Ie(()=>{Xr();Dht=(...t)=>{let e=pr(t,"lab");return e[0]=Qs(e[0]*100)+"%",e[1]=sb(e[1]),e[2]=sb(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklab(${e.join(" ")})`},K9=Dht;});var kht,NE,GC=Ie(()=>{Xr();OE();SC();kht=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=J0(e,n,s),[c,v,y]=bE(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},NE=kht;});var Mht,B9,U9=Ie(()=>{Xr();Mht=(...t)=>{let e=pr(t,"lch");return e[0]=Qs(e[0]*100)+"%",e[1]=sb(e[1]),e[2]=isNaN(e[2])?"none":Qs(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklch(${e.join(" ")})`},B9=Mht;});var qC,Kht,j9,H9=Ie(()=>{Xr();I9();LC();D9();lb();M9();OC();OE();F9();GC();U9();Nd();(({round:qC}=Math)),Kht=(...t)=>{let e=pr(t,"rgba"),n=Uu(t)||"rgb";if(n.substr(0,3)==="hsl")return L9(TE(e),n);if(n.substr(0,3)==="lab"){let s=Cd();Dl("d50");let i=P9($0(e),n);return Dl(s),i}if(n.substr(0,3)==="lch"){let s=Cd();Dl("d50");let i=k9(hb(e),n);return Dl(s),i}return n.substr(0,5)==="oklab"?K9(J0(e)):n.substr(0,5)==="oklch"?B9(NE(e)):(e[0]=qC(e[0]),e[1]=qC(e[1]),e[2]=qC(e[2]),(n==="rgba"||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),n="rgba"),`${n.substr(0,3)}(${e.slice(0,n==="rgb"?3:4).join(" ")})`)},j9=Kht;});var Fht,RE,zC=Ie(()=>{Xr();EC();SE();Fht=(...t)=>{t=pr(t,"lch");let[e,n,s,...i]=t,[r,o,a]=xE(e,n,s),[c,v,y]=Q0(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},RE=Fht;});var Hf,vc,LE,Ml,tv,$C,IE,ev,G9,q9,z9,$9,V9,Y9,W9,X9,Q9,J9,Z9,Z0,Qo,Ba,tK,VC,eK=Ie(()=>{RC();ub();_E();SE();zC();Wo();cE();Nd();Hf=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,vc=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,LE=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,Ml=/\s*/.source,tv=/\s+/.source,$C=/\s*,\s*/.source,IE=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,ev=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,G9=new RegExp("^rgba?\\("+Ml+[Hf,Hf,Hf].join(tv)+ev+"\\)$"),q9=new RegExp("^rgb\\("+Ml+[Hf,Hf,Hf].join($C)+Ml+"\\)$"),z9=new RegExp("^rgba\\("+Ml+[Hf,Hf,Hf,vc].join($C)+Ml+"\\)$"),$9=new RegExp("^hsla?\\("+Ml+[IE,LE,LE].join(tv)+ev+"\\)$"),V9=new RegExp("^hsl?\\("+Ml+[IE,LE,LE].join($C)+Ml+"\\)$"),Y9=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,W9=new RegExp("^lab\\("+Ml+[vc,vc,vc].join(tv)+ev+"\\)$"),X9=new RegExp("^lch\\("+Ml+[vc,vc,IE].join(tv)+ev+"\\)$"),Q9=new RegExp("^oklab\\("+Ml+[vc,vc,vc].join(tv)+ev+"\\)$"),J9=new RegExp("^oklch\\("+Ml+[vc,vc,IE].join(tv)+ev+"\\)$"),{round:Z9}=Math,Z0=t=>t.map((e,n)=>n<=2?Il(Z9(e),0,255):e),Qo=(t,e=0,n=100,s=false)=>(typeof t=="string"&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,s?t=e+(t+1)*.5*(n-e):t=e+t*(n-e)),+t),Ba=(t,e)=>t==="none"?e:t,tK=t=>{if(t=t.toLowerCase().trim(),t==="transparent")return [0,0,0,0];let e;if(Kr.format.named)try{return Kr.format.named(t)}catch{}if((e=t.match(G9))||(e=t.match(q9))){let n=e.slice(1,4);for(let i=0;i<3;i++)n[i]=+Qo(Ba(n[i],0),0,255);n=Z0(n);let s=e[4]!==void 0?+Qo(e[4],0,1):1;return n[3]=s,n}if(e=t.match(z9)){let n=e.slice(1,5);for(let s=0;s<4;s++)n[s]=+Qo(n[s],0,255);return n}if((e=t.match($9))||(e=t.match(V9))){let n=e.slice(1,4);n[0]=+Ba(n[0].replace("deg",""),0),n[1]=+Qo(Ba(n[1],0),0,100)*.01,n[2]=+Qo(Ba(n[2],0),0,100)*.01;let s=Z0(pb(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}if(e=t.match(Y9)){let n=e.slice(1,4);n[1]*=.01,n[2]*=.01;let s=pb(n);for(let i=0;i<3;i++)s[i]=Z9(s[i]);return s[3]=+e[4],s}if(e=t.match(W9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,100),n[1]=Qo(Ba(n[1],0),-125,125,true),n[2]=Qo(Ba(n[2],0),-125,125,true);let s=Cd();Dl("d50");let i=Z0(z0(n));Dl(s);let r=e[4]!==void 0?+Qo(e[4],0,1):1;return i[3]=r,i}if(e=t.match(X9)){let n=e.slice(1,4);n[0]=Qo(n[0],0,100),n[1]=Qo(Ba(n[1],0),0,150,false),n[2]=+Ba(n[2].replace("deg",""),0);let s=Cd();Dl("d50");let i=Z0(Y0(n));Dl(s);let r=e[4]!==void 0?+Qo(e[4],0,1):1;return i[3]=r,i}if(e=t.match(Q9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,1),n[1]=Qo(Ba(n[1],0),-0.4,.4,true),n[2]=Qo(Ba(n[2],0),-0.4,.4,true);let s=Z0(Q0(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}if(e=t.match(J9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,1),n[1]=Qo(Ba(n[1],0),0,.4,false),n[2]=+Ba(n[2].replace("deg",""),0);let s=Z0(RE(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}};tK.test=t=>G9.test(t)||$9.test(t)||W9.test(t)||X9.test(t)||Q9.test(t)||J9.test(t)||q9.test(t)||z9.test(t)||V9.test(t)||Y9.test(t)||t==="transparent";VC=tK;});var Bht,rK=Ie(()=>{Mo();An();Wo();Xr();H9();eK();Pe.prototype.css=function(t){return j9(this._rgb,t)};Bht=(...t)=>new Pe(...t,"css");Qr.css=Bht;Kr.format.css=VC;Kr.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&VC.test(t))return "css"}});});var Uht,nK=Ie(()=>{An();Mo();Wo();Xr();Kr.format.gl=(...t)=>{let e=pr(t,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};Uht=(...t)=>new Pe(...t,"gl");Qr.gl=Uht;Pe.prototype.gl=function(){let t=this._rgb;return [t[0]/255,t[1]/255,t[2]/255,t[3]]};});var jht,iK=Ie(()=>{An();Mo();Xr();Wo();gC();yC();Pe.prototype.hex=function(t){return vE(this._rgb,t)};jht=(...t)=>new Pe(...t,"hex");Qr.hex=jht;Kr.format.hex=yE;Kr.autodetect.push({p:4,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return "hex"}});});var PE,Hht,DE,YC=Ie(()=>{(({log:PE}=Math)),Hht=t=>{let e=t/100,n,s,i;return e<66?(n=255,s=e<6?0:-155.25485562709179-.44596950469579133*(s=e-2)+104.49216199393888*PE(s),i=e<20?0:-254.76935184120902+.8274096064007395*(i=e-10)+115.67994401066147*PE(i)):(n=351.97690566805693+.114206453784165*(n=e-55)-40.25366309332127*PE(n),s=325.4494125711974+.07943456536662342*(s=e-50)-28.0852963507957*PE(s),i=255),[n,s,i,1]},DE=Hht;});var Ght,qht,oK,sK=Ie(()=>{YC();Xr();(({round:Ght}=Math)),qht=(...t)=>{let e=pr(t,"rgb"),n=e[0],s=e[2],i=1e3,r=4e4,o=.4,a;for(;r-i>o;){a=(r+i)*.5;let c=DE(a);c[2]/c[0]>=s/n?r=a:i=a;}return Ght(a)},oK=qht;});var WC,aK=Ie(()=>{Mo();An();Wo();YC();sK();Pe.prototype.temp=Pe.prototype.kelvin=Pe.prototype.temperature=function(){return oK(this._rgb)};WC=(...t)=>new Pe(...t,"temp");Object.assign(Qr,{temp:WC,kelvin:WC,temperature:WC});Kr.format.temp=Kr.format.kelvin=Kr.format.temperature=DE;});var zht,uK=Ie(()=>{Xr();Mo();An();Wo();zC();GC();Pe.prototype.oklch=function(){return NE(this._rgb)};zht=(...t)=>new Pe(...t,"oklch");Object.assign(Qr,{oklch:zht});Kr.format.oklch=RE;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"oklch"),kr(t)==="array"&&t.length===3)return "oklch"}});});var XC,lK=Ie(()=>{Mo();e8();r8();n8();i8();o8();TC();s8();a8();c8();h8();f8();p8();d8();g8();m8();T8();w8();I8();P8();F8();B8();U8();q8();$8();W8();Q8();cb();Z8();AE();jC();r9();u9();d9();y9();jC();v9();Wo();_9();dC();S9();An();R9();rK();nK();CC();iK();NC();EE();IC();V0();fb();wC();FC();aK();DC();uK();Object.assign(Qr,{analyze:BC,average:G8,bezier:z8,blend:Y8,brewer:E9,Color:Pe,colors:wd,contrast:e9,contrastAPCA:a9,cubehelix:X8,deltaE:p9,distance:g9,input:Kr,interpolate:bh,limits:UC,mix:bh,random:J8,scale:wy,scales:x9,valid:m9});XC=Qr;});function QC(t,e){try{let[n,s,i]=XC(t).set("lab.l",e).rgb();return `rgb(${Math.round(n)}, ${Math.round(s)}, ${Math.round(i)})`}catch{return t}}var db,kE=Ie(()=>{lK();db=class{constructor(e){this.colors=this.generateColors(e),this.index=0;}generateColors(e){let n=[];for(let s=0;s<e;s++)n.push(this.phyllotacticColor(s));return n}getNextColor(){return this.index>=this.colors.length&&(this.index=0),this.colors[this.index++]}phyllotacticColor(e){let n=137.5*(Math.PI/180),s=100,i=e*n,r=s*Math.cos(i),o=s*Math.sin(i),a=62,c=r,v=o,y=XC.lab(a,c,v).rgb();return `rgb(${Math.round(y[0])}, ${Math.round(y[1])}, ${Math.round(y[2])})`}};});var vs,Hu,Id;exports.QualitativeConstraintValidator=void 0;var gb=Ie(()=>{Ll();Bf();Ad();Ad();Ad();vs=1,Hu=class Hu{constructor(e=15){this.adj=new Map;this.radj=new Map;this.nodes=new Set;this.nodeSize=new Map;this.edgeProvenance=new Map;this.alignmentRefCount=new Map;this.edgeClaims=new Map;this.addVersion=vs++;this.removeVersion=vs++;this.weightVersion=vs++;this.hasZeroWeightOrderingEdge=false;this.reachMemo=new Map;this.maxWeightMemo=new Map;this.contractedMemo=null;this.sccMemo=null;this.memoAddV=-1;this.memoRemV=-1;this.memoWeightV=-1;this.pendingDeltas=null;this.gap=e;}consumeReachDeltas(){let e=this.pendingDeltas;return this.pendingDeltas=[],e}markDeltasUnknown(){this.pendingDeltas=null;}recordDelta(e,n){if(this.pendingDeltas!==null){if(this.pendingDeltas.length>=Hu.MAX_PENDING_DELTAS){this.pendingDeltas=null;return}this.pendingDeltas.push({from:e,to:n});}}clone(){let e=new Hu(this.gap);for(let n of this.nodes)e.nodes.add(n);for(let[n,s]of this.adj)e.adj.set(n,new Map(s));for(let[n,s]of this.radj)e.radj.set(n,new Map(s));e.nodeSize=new Map(this.nodeSize),e.edgeProvenance=new Map(this.edgeProvenance),e.alignmentRefCount=new Map(this.alignmentRefCount);for(let[n,s]of this.edgeClaims)e.edgeClaims.set(n,[...s]);return e.hasZeroWeightOrderingEdge=this.hasZeroWeightOrderingEdge,e}validateMemo(){if(this.memoAddV!==this.addVersion||this.memoRemV!==this.removeVersion){this.reachMemo.clear(),this.sccMemo=null,this.maxWeightMemo.clear(),this.contractedMemo=null,this.memoAddV=this.addVersion,this.memoRemV=this.removeVersion,this.memoWeightV=this.weightVersion;return}this.memoWeightV!==this.weightVersion&&(this.maxWeightMemo.clear(),this.contractedMemo=null,this.memoWeightV=this.weightVersion);}ensureNode(e,n=0){this.nodes.has(e)||(this.nodes.add(e),this.adj.set(e,new Map),this.radj.set(e,new Map),this.nodeSize.set(e,n));}static provenanceKey(e,n){return `${e}\0${n}`}addEdge(e,n,s,i){let r=(s??this.gap)+(this.nodeSize.get(e)??0);if(this.ensureNode(e),this.ensureNode(n),e===n)return false;let o=this.adj.get(e).get(n);if(o!==void 0&&r<=o)return this.registerClaim(e,n,r,i),true;if(this.canReach(n,e))return false;if(r<=0&&(this.hasZeroWeightOrderingEdge=true),o===void 0||o===0){let a=o===void 0&&!this.hasZeroWeightOrderingEdge&&this.memoAddV===this.addVersion&&this.memoRemV===this.removeVersion;this.adj.get(e).set(n,r),this.radj.get(n).set(e,r),this.weightVersion=vs++,a?(this.applyIncrementalClosure(e,n,r>0),this.addVersion=vs++,this.memoAddV=this.addVersion):(this.addVersion=vs++,this.markDeltasUnknown());}else this.adj.get(e).set(n,r),this.radj.get(n).set(e,r),this.weightVersion=vs++;return this.registerClaim(e,n,r,i),true}registerClaim(e,n,s,i){let r=Hu.provenanceKey(e,n),o=this.edgeClaims.get(r);o?o.push({w:s,c:i}):this.edgeClaims.set(r,[{w:s,c:i}]),this.refreshProvenance(r);}refreshProvenance(e){let n=this.edgeClaims.get(e);if(!n||n.length===0){this.edgeProvenance.delete(e);return}let s,i=-1/0;for(let r of n)r.c!==void 0&&r.w>i&&(i=r.w,s=r.c);s!==void 0?this.edgeProvenance.set(e,s):this.edgeProvenance.delete(e);}removeEdgeClaim(e,n,s,i){let r=(s??this.gap)+(this.nodeSize.get(e)??0),o=Hu.provenanceKey(e,n),a=this.edgeClaims.get(o);if(!a)return;let c=i!==void 0?a.findIndex(g=>g.w===r&&g.c===i):a.findIndex(g=>g.w===r);if(c===-1)return;if(a.splice(c,1),a.length===0){this.edgeClaims.delete(o),this.adj.get(e)?.delete(n)&&(this.radj.get(n)?.delete(e),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.edgeProvenance.delete(o);return}let v=-1/0;for(let g of a)g.w>v&&(v=g.w);let y=this.adj.get(e)?.get(n);y!==void 0&&v<y&&(this.adj.get(e).set(n,v),this.radj.get(n).set(e,v),this.weightVersion=vs++,y>0&&v<=0&&(this.removeVersion=vs++,this.markDeltasUnknown())),this.refreshProvenance(o);}applyIncrementalClosure(e,n,s){let i=this.reachFrom(n);for(let[r,o]of this.reachMemo){let a;if(r===e)a=false;else {let y=o.get(e);if(y===void 0)continue;a=y;}let c=a||s,v=o.get(n);(v===void 0||!v&&c)&&(o.set(n,c),r!==n&&this.recordDelta(r,n));for(let[y,g]of i){let h=c||g,u=o.get(y);(u===void 0||!u&&h)&&(o.set(y,h),r!==y&&this.recordDelta(r,y));}}}hasEdge(e,n){return this.adj.get(e)?.has(n)??false}getEdgeWeight(e,n){return this.adj.get(e)?.get(n)}getEdgeProvenance(e,n){return this.edgeProvenance.get(Hu.provenanceKey(e,n))}canReach(e,n){return e===n?true:this.reachFrom(e).has(n)}reachFrom(e){this.validateMemo();let n=this.reachMemo.get(e);if(n)return n;let s=new Map,i=[e],r=[false];s.set(e,false);let o=0;for(;o<i.length;){let a=i[o],c=r[o];o++;let v=this.adj.get(a);if(v)for(let[y,g]of v){let h=c||g>0,u=s.get(y);(u===void 0||!u&&h)&&(s.set(y,h),i.push(y),r.push(h));}}return s.get(e)===false&&s.delete(e),this.reachMemo.set(e,s),s}isOrdered(e,n){return this.isStrictlyOrdered(e,n)}successors(e){let n=this.adj.get(e);return n?new Set(n.keys()):new Set}predecessors(e){let n=this.radj.get(e);return n?new Set(n.keys()):new Set}topologicalSort(){let e=this.standardTopoSort();if(e)return e;let n=this.getAlignmentClasses(),s=new Map;for(let[y,g]of n)for(let h of g)s.set(h,y);for(let y of this.nodes)s.has(y)||s.set(y,y);let i=new Set;for(let y of this.nodes)i.add(s.get(y));let r=new Map;for(let y of i)r.set(y,new Set);for(let[y,g]of this.adj){let h=s.get(y);for(let[u]of g){let d=s.get(u);h!==d&&r.get(h).add(d);}}let o=new Map;for(let y of i)o.set(y,0);for(let[,y]of r)for(let g of y)o.set(g,(o.get(g)??0)+1);let a=[];for(let[y,g]of o)g===0&&a.push(y);let c=[];for(;a.length>0;){let y=a.shift();c.push(y);for(let g of r.get(y)??[]){let h=(o.get(g)??1)-1;o.set(g,h),h===0&&a.push(g);}}if(c.length!==i.size)return null;let v=[];for(let y of c){let g=n.get(y);g?v.push(...g):v.push(y);}return v}standardTopoSort(){let e=new Map;for(let i of this.nodes)e.set(i,0);for(let[,i]of this.adj)for(let r of i.keys())e.set(r,(e.get(r)??0)+1);let n=[];for(let[i,r]of e)r===0&&n.push(i);let s=[];for(;n.length>0;){let i=n.shift();s.push(i);for(let r of this.adj.get(i)?.keys()??[]){let o=(e.get(r)??1)-1;e.set(r,o),o===0&&n.push(r);}}return s.length===this.nodes.size?s:null}addAlignmentEdges(e,n,s){if(this.ensureNode(e),this.ensureNode(n),e===n)return true;if(this.isStrictlyOrdered(e,n)||this.isStrictlyOrdered(n,e))return false;this.adj.get(e).has(n)||(this.adj.get(e).set(n,0),this.radj.get(n).set(e,0),s&&this.edgeProvenance.set(Hu.provenanceKey(e,n),s),this.addVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.adj.get(n).has(e)||(this.adj.get(n).set(e,0),this.radj.get(e).set(n,0),s&&this.edgeProvenance.set(Hu.provenanceKey(n,e),s),this.addVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown());let i=e<n?`${e}\0${n}`:`${n}\0${e}`;return this.alignmentRefCount.set(i,(this.alignmentRefCount.get(i)??0)+1),true}removeAlignmentEdges(e,n){let s=e<n?`${e}\0${n}`:`${n}\0${e}`,i=(this.alignmentRefCount.get(s)??0)-1;if(i>0){this.alignmentRefCount.set(s,i);return}this.alignmentRefCount.delete(s),this.adj.get(e)?.get(n)===0&&(this.adj.get(e).delete(n),this.radj.get(n).delete(e),this.edgeProvenance.delete(Hu.provenanceKey(e,n)),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.adj.get(n)?.get(e)===0&&(this.adj.get(n).delete(e),this.radj.get(e).delete(n),this.edgeProvenance.delete(Hu.provenanceKey(n,e)),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown());}areAligned(e,n){return e===n?true:this.canReach(e,n)&&this.canReach(n,e)}isStrictlyOrdered(e,n){return e===n?false:this.reachFrom(e).get(n)===true}isProperlyBefore(e,n){if(e===n)return false;let s=this.maxWeightFrom(e).get(n);return s!==void 0&&s>(this.nodeSize.get(e)??0)}entailsSeparation(e,n,s){if(e===n)return false;let i=(s??this.gap)+(this.nodeSize.get(e)??0),r=this.maxWeightFrom(e).get(n);return r!==void 0&&r>=i}maxWeightFrom(e){this.validateMemo();let n=this.maxWeightMemo.get(e);if(n)return n;let{rep:s,adj:i,order:r,members:o}=this.contractedDag(),a=s.get(e)??e,c=new Map;c.set(a,0);for(let y of r){let g=c.get(y);if(g!==void 0)for(let[h,u]of i.get(y)){let d=g+u,f=c.get(h);(f===void 0||d>f)&&c.set(h,d);}}let v=new Map;for(let[y,g]of c){let h=o.get(y);if(h===void 0){v.set(y,g);continue}for(let u of h)v.set(u,g);}return this.maxWeightMemo.set(e,v),v}contractedDag(){if(this.contractedMemo)return this.contractedMemo;let e=new Map,n=this.getAlignmentClasses();for(let[c,v]of n)for(let y of v)e.set(y,c);let s=c=>e.get(c)??c,i=new Map,r=new Map;for(let c of this.nodes){let v=s(c);i.has(v)||(i.set(v,new Map),r.set(v,0));}for(let[c,v]of this.adj){let y=s(c),g=i.get(y);if(g)for(let[h,u]of v){let d=s(h);if(y===d)continue;let f=g.get(d);f===void 0?(g.set(d,u),r.set(d,(r.get(d)??0)+1)):u>f&&g.set(d,u);}}let o=[],a=[];for(let[c,v]of r)v===0&&a.push(c);for(let c=0;c<a.length;c++){let v=a[c];o.push(v);for(let[y]of i.get(v)){let g=(r.get(y)??1)-1;r.set(y,g),g===0&&a.push(y);}}return this.contractedMemo={rep:e,adj:i,order:o,members:n},this.contractedMemo}tarjanSCCs(){if(this.validateMemo(),this.sccMemo)return this.sccMemo;let e=new Map,n=new Map,s=new Set,i=[],r=[],o=0;for(let a of this.nodes){if(e.has(a))continue;let c=[],v=y=>{e.set(y,o),n.set(y,o),o++,i.push(y),s.add(y),c.push({node:y,succs:[...this.adj.get(y)?.keys()??[]],i:0});};for(v(a);c.length>0;){let y=c[c.length-1];if(y.i<y.succs.length){let g=y.succs[y.i++];e.has(g)?s.has(g)&&n.set(y.node,Math.min(n.get(y.node),e.get(g))):v(g);}else {if(c.pop(),n.get(y.node)===e.get(y.node)){let h=[],u;do u=i.pop(),s.delete(u),h.push(u);while(u!==y.node);r.push(h);}let g=c[c.length-1];g&&n.set(g.node,Math.min(n.get(g.node),n.get(y.node)));}}}return this.sccMemo=r,r}getAlignmentClasses(){let e=new Map;for(let n of this.tarjanSCCs())n.length>1&&(n.sort(),e.set(n[0],n));return e}getAlignmentClassOf(e){for(let n of this.tarjanSCCs())if(n.includes(e))return n;return [e]}findPath(e,n){if(e===n)return [];let s=new Set,i=[{node:e,path:[]}];for(s.add(e);i.length>0;){let{node:r,path:o}=i.shift(),a=this.adj.get(r);if(!a)continue;let c=[...a.keys()].sort();for(let v of c){if(v===n)return [...o,[r,v]];s.has(v)||(s.add(v),i.push({node:v,path:[...o,[r,v]]}));}}return null}getPathConstraints(e){let n=[];for(let[s,i]of e){let r=this.edgeProvenance.get(Hu.provenanceKey(s,i));r&&n.push(r);}return n}edgeCount(){let e=0;for(let[,n]of this.adj)e+=n.size;return e}allNodes(){return this.nodes}allEdges(){let e=[];for(let[n,s]of this.adj)for(let i of s.keys())e.push([n,i]);return e}};Hu.MAX_PENDING_DELTAS=65536;Id=Hu,exports.QualitativeConstraintValidator=class t{constructor(e){this.minPadding=15;this.horizontallyAligned=[];this.verticallyAligned=[];this.addedConstraints=[];this.allDisjunctions=[];this.originalDisjunctions=[];this.assignmentTrail=[];this.decisionLevel=0;this.learnedClauses=[];this.activityFlat=new Float64Array(0);this.simplicityFlat=new Float64Array(0);this.elimScratch=new Uint8Array(0);this.branchStride=0;this.activityDecay=.95;this.conflictCount=0;this.restartThreshold=32;this.emptyDisjunctionError=null;this.lubyIndex=0;this.nodeMap=new Map;this.prunedByTransitivity=0;this.prunedByDecomposition=0;this.altVerdictCache=new Map;this.verdictEntryByIndex=[];this.verdictEntryDisj=[];this.probeIndex=new Map;this.additionEpoch=0;this.lastPropagateOkStamp=-1;this.mustHGraph=null;this.mustVGraph=null;this.validationSucceeded=false;this.mustHPairs=null;this.mustVPairs=null;this.mustHAlignmentClasses=null;this.mustVAlignmentClasses=null;this.modalStateBuilt=false;this.layout=e,this.nodes=e.nodes,this.edges=e.edges,this.orientationConstraints=e.constraints,this.groups=e.groups,this.hGraph=new Id(this.minPadding),this.vGraph=new Id(this.minPadding);for(let n of this.nodes)this.nodeMap.set(n.id,n),this.hGraph.ensureNode(n.id,n.width),this.vGraph.ensureNode(n.id,n.height);}validateConstraints(){return this.validateGroupConstraints()||this.validatePositionalConstraints()}validatePositionalConstraints(){this.resetModalQueryState();let e=false;for(let o of this.orientationConstraints)if(this.addConjunctiveConstraint(o)){e=true;break}if(this.addGroupBoundingBoxDisjunctions(),this.allDisjunctions=[...this.layout.disjunctiveConstraints||[]],this.originalDisjunctions=[...this.allDisjunctions],e)return this.enforceMaximalFeasibleSubset(this.buildGlobalMFSError());let n=this.addedConstraints.length;if(this.presolveDisjunctions(),this.emptyDisjunctionError)return this.enforceMaximalFeasibleSubset(this.emptyDisjunctionError);if(this.mustHGraph=this.hGraph.clone(),this.mustVGraph=this.vGraph.clone(),this.allDisjunctions.length>0&&!this.solveCDCL().satisfiable)return this.enforceMaximalFeasibleSubset(this.buildGlobalMFSError());let s=this.addedConstraints.slice(n);s.length>0&&(this.layout.constraints=this.layout.constraints.concat(s));let i=this.computeAlignmentOrders(),r=this.detectNodeOverlaps();return r?this.enforceMaximalFeasibleSubset(r):(this.layout.constraints=this.layout.constraints.concat(i),this.validationSucceeded=true,null)}enforceMaximalFeasibleSubset(e){return e.maximalFeasibleSubset&&(this.layout.constraints=e.maximalFeasibleSubset),this.resetModalQueryState(),e}buildGlobalMFSError(){let{feasibleConstraints:e,infeasibleDisjunctions:n,hGraph:s,vGraph:i}=this.computeMaximalFeasibleSubset(),r=new Set(e),o=this.orientationConstraints.filter(l=>!r.has(l)),a=new Set,c=new Set,v=(l,p,x)=>{let b=l.findPath(p,x);if(b)for(let[S,_]of b){let T=l.getEdgeProvenance(S,_);T&&!c.has(T)&&(c.add(T),a.add(T));}};for(let l of o)if(!c.has(l))if(c.add(l),a.add(l),Fn(l)){let p=l,x=p.axis==="x"?s:i,b=p.node1.id,S=p.node2.id;x.canReach(b,S)&&v(x,b,S),x.canReach(S,b)&&v(x,S,b);}else {let p=this.constraintToEdge(l);if(!p)continue;let x=p.axis==="h"?s:i;v(x,p.to,p.from);}for(let l of n)if(l.alternatives.length>0&&l.alternatives[0].length>0){let p=l.alternatives[0][0];c.has(p)||(c.add(p),a.add(p));let x=this.constraintToEdge(p);if(x){let b=x.axis==="h"?s:i,S=b.findPath(x.to,x.from);if(S)for(let[_,T]of S){let k=b.getEdgeProvenance(_,T);k&&!c.has(k)&&(c.add(k),a.add(k));}}}let y=new Map,g=new Map;for(let l of a){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),g.has(p.toHTML())||g.set(p.toHTML(),[]),y.get(p).push(l),g.get(p.toHTML()).push(Fa(l));}for(let l of n)if(l.alternatives.length===0){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),g.has(p.toHTML())||g.set(p.toHTML(),[]),g.get(p.toHTML()).push(`unsatisfiable: ${p.toHTML()}`);}let u=[...a][0]??this.orientationConstraints[0],d=u?Fa(u):"",f=u?.sourceConstraint??n[0]?.sourceConstraint??this.orientationConstraints[0]?.sourceConstraint;return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${d}" conflicts with existing constraints`,conflictingConstraint:u??void 0,conflictingSourceConstraint:f??void 0,minimalConflictingSet:y,maximalFeasibleSubset:e,errorMessages:{conflictingConstraint:d,conflictingSourceConstraint:f?.toHTML()??"",minimalConflictingConstraints:g}}}presolveDisjunctions(){let e=[];for(let n of this.allDisjunctions){let s=this.findImpliedAlternative(n);if(s!==null){for(let r of n.alternatives[s])this.addedConstraints.push(r);this.prunedByTransitivity++;continue}let i=[];for(let r of n.alternatives)this.isAlternativeFeasible(r)&&i.push(r);if(i.length===0)n.alternatives.length===0?(e.push(n),this.emptyDisjunctionError=this.buildDisjunctiveError(n)):e.push(n);else if(i.length===1){let r=true;for(let o of i[0])if(this.addConjunctiveConstraint(o)){r=false,e.push(n);break}r&&this.prunedByDecomposition++;}else i.length<n.alternatives.length?e.push(new ys(n.sourceConstraint,i)):e.push(n);}this.allDisjunctions=e;}buildDisjunctiveError(e){let n=e.alternatives[0]?.[0]??this.addedConstraints[this.addedConstraints.length-1]??this.orientationConstraints[0],s=new Map;s.set(e.sourceConstraint,e.alternatives[0]??[]);for(let i of this.addedConstraints)s.has(i.sourceConstraint)||s.set(i.sourceConstraint,[]),s.get(i.sourceConstraint).push(i);return {name:"PositionalConstraintError",type:"positional-conflict",message:`No satisfiable alternative for disjunction from ${e.sourceConstraint?.toHTML?.()??"unknown"}`,conflictingConstraint:n,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:s,maximalFeasibleSubset:[...this.addedConstraints]}}addConjunctiveConstraint(e){if(ii(e)){if(!this.hGraph.addEdge(e.left.id,e.right.id,e.minDistance,e))return this.buildConjunctiveError(e);this.addedConstraints.push(e);}else if(ni(e)){if(!this.vGraph.addEdge(e.top.id,e.bottom.id,e.minDistance,e))return this.buildConjunctiveError(e);this.addedConstraints.push(e);}else if(Fn(e)){let n=e,s=n.axis==="x"?this.hGraph:this.vGraph;if(!s.addAlignmentEdges(n.node1.id,n.node2.id,e))return this.buildAlignmentConflictError(e,n.axis);if(n.node1.id!==n.node2.id){let i=n.axis==="x"?this.vGraph:this.hGraph;if(t.classHasDualAxisOverlap(s,i,n.node1.id,n.node2.id,true))return s.removeAlignmentEdges(n.node1.id,n.node2.id),this.buildAlignmentConflictError(e,n.axis)}n.axis==="x"?this.verticallyAligned.push([n.node1,n.node2]):this.horizontallyAligned.push([n.node1,n.node2]),this.addedConstraints.push(e);}else if(Ls(e)||Is(e)){let n=this.addSpatialConstraint(e);if(n)return n;this.addedConstraints.push(e);}return null}addSpatialConstraint(e){if(Ls(e)){let n=e,s=`_group_${n.group.name}`;this.hGraph.ensureNode(s),this.vGraph.ensureNode(s);let i;switch(n.side){case "left":i=this.hGraph.addEdge(n.node.id,s,n.minDistance,e);break;case "right":i=this.hGraph.addEdge(s,n.node.id,n.minDistance,e);break;case "top":i=this.vGraph.addEdge(n.node.id,s,n.minDistance,e);break;case "bottom":i=this.vGraph.addEdge(s,n.node.id,n.minDistance,e);break;default:i=true;}if(!i)return this.buildConjunctiveError(e)}else if(Is(e)&&!this.addQualitativeEdge(e))return this.buildConjunctiveError(e);return null}addGroupBoundingBoxDisjunctions(){let e=new Map;for(let r of this.nodes)e.set(r.id,new Set);let n=new Map;for(let r of this.nodes)n.set(r.id,r);for(let r of this.groups)if(r.nodeIds.length>1&&r.sourceConstraint)for(let o of r.nodeIds)e.get(o)?.add(r);for(let r of this.groups){if(r.nodeIds.length<=1||!r.sourceConstraint||r.negated)continue;let o=new Set(r.nodeIds),a=`_group_${r.name}`;this.hGraph.ensureNode(a),this.vGraph.ensureNode(a);for(let c of this.nodes){if(o.has(c.id))continue;let v=e.get(c.id);if(v&&v.size>0&&(!r.overlapping||[...v].every(d=>d===r||this.isSubGroup(d,r)||this.isSubGroup(r,d))))continue;let y=r.sourceConstraint,g=[[{group:r,node:c,side:"left",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"right",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"top",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"bottom",minDistance:this.minPadding,sourceConstraint:y}]],h=new ys(y,g);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(h);}}let s=5,i=new Map;for(let r of this.groups){if(!r.negated||!r.sourceConstraint)continue;let o=r.sourceConstraint;i.has(o)||i.set(o,[]),i.get(o).push(r);}for(let[r,o]of i){let a=[];for(let v of o){let y=new Set(v.nodeIds),g=v.nodeIds.map(u=>n.get(u)).filter(u=>u!==void 0),h=this.nodes.filter(u=>!y.has(u.id));if(!(g.length<2||h.length===0)){if(g.length>s){let u=b=>({id:`_ng_${v.name}_${b}`,label:"",color:"",groups:[],attributes:{},width:0,height:0,mostSpecificType:"",types:[],showLabels:false}),d=u("l"),f=u("r"),l=u("t"),p=u("b"),x=b=>{let S=new ys(r,b);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(S);};x(g.map(b=>[{left:b,right:d,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{left:f,right:b,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{top:b,bottom:l,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{top:p,bottom:b,minDistance:0,sourceConstraint:r}]));for(let b of h)a.push([{left:d,right:b,minDistance:0,sourceConstraint:r},{left:b,right:f,minDistance:0,sourceConstraint:r},{top:l,bottom:b,minDistance:0,sourceConstraint:r},{top:b,bottom:p,minDistance:0,sourceConstraint:r}]);}else for(let u of h)for(let d of g)for(let f of g)if(d.id!==f.id)for(let l of g)for(let p of g)l.id!==p.id&&a.push([{left:d,right:u,minDistance:0,sourceConstraint:r},{left:u,right:f,minDistance:0,sourceConstraint:r},{top:l,bottom:u,minDistance:0,sourceConstraint:r},{top:u,bottom:p,minDistance:0,sourceConstraint:r}]);}}let c=new ys(r,a);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(c);}for(let r=0;r<this.groups.length;r++)if(!this.groups[r].negated)for(let o=r+1;o<this.groups.length;o++){if(this.groups[o].negated)continue;let a=this.groups[r],c=this.groups[o];if(a.nodeIds.length<=1||c.nodeIds.length<=1||this.isSubGroup(a,c)||this.isSubGroup(c,a)||this.groupIntersection(a,c).length>0)continue;let v=a.sourceConstraint||c.sourceConstraint,y=[[{groupA:a,groupB:c,side:"left",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"right",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"top",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"bottom",minDistance:this.minPadding,sourceConstraint:v}]],g=new ys(v,y);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(g);}return null}groupBoundaryEdges(e){let n=e.side==="left"||e.side==="right"?"h":"v",s=e.side==="right"||e.side==="bottom",i=(r,o)=>({axis:n,from:s?o:r,to:s?r:o});return [i(`_group_${e.groupA.name}`,`_group_${e.groupB.name}`),...e.groupA.nodeIds.flatMap(r=>e.groupB.nodeIds.map(o=>i(r,o)))]}isAlternativeFeasible(e){for(let n of e){if(Is(n)){for(let r of this.groupBoundaryEdges(n)){let o=r.axis==="h"?this.hGraph:this.vGraph;if(r.from===r.to||o.canReach(r.to,r.from))return false}continue}if(Ls(n)){let r=n,a=r.side==="left"||r.side==="right"?this.hGraph:this.vGraph;for(let c of r.group.nodeIds)if(a.areAligned(r.node.id,c))return false;if(!this.isBoundingBoxFeasible(r))return false}if(Fn(n)){let r=n,o=r.axis==="x"?this.hGraph:this.vGraph,a=o.canReach(r.node1.id,r.node2.id),c=o.canReach(r.node2.id,r.node1.id);if(a!==c)return false;if(r.node1.id!==r.node2.id){let v=r.axis==="x"?this.vGraph:this.hGraph;if(t.classHasDualAxisOverlap(o,v,r.node1.id,r.node2.id,false))return false}continue}let s=this.constraintToEdge(n);if(!s)continue;if((s.axis==="h"?this.hGraph:this.vGraph).canReach(s.to,s.from))return false}return true}isBoundingBoxFeasible(e){return t.isBboxFeasibleInGraphs(e,this.hGraph,this.vGraph)}static isBboxFeasibleInGraphs(e,n,s){let i=e.node.id,r=e.group.nodeIds;switch(e.side){case "left":for(let o of r)if(n.isOrdered(o,i))return false;return true;case "right":for(let o of r)if(n.isOrdered(i,o))return false;return true;case "top":for(let o of r)if(s.isOrdered(o,i))return false;return true;case "bottom":for(let o of r)if(s.isOrdered(i,o))return false;return true}}findImpliedAlternative(e){for(let n=0;n<e.alternatives.length;n++){let s=true;for(let i of e.alternatives[n]){if(Fn(i)){let c=i;if(!(c.axis==="x"?this.hGraph:this.vGraph).areAligned(c.node1.id,c.node2.id)){s=false;break}continue}let r=this.constraintToEdge(i);if(!r)continue;let o=r.axis==="h"?this.hGraph:this.vGraph,a=i.minDistance;if(!o.isOrdered(r.from,r.to)||!o.entailsSeparation(r.from,r.to,a)){s=false;break}}if(s)return n}return null}solveCDCL(){if(this.allDisjunctions.length===0)return {satisfiable:true};if(this.pruneDisjunctions(),this.allDisjunctions.length===0)return {satisfiable:true};let e=new Int32Array(this.allDisjunctions.length).fill(-1);this.rebuildBranchIndex(true);let n=this.checkpoint(),s=this.addedConstraints.length,i=0,r=50;for(;i<=r;){if(this.restoreCheckpoint(n),this.addedConstraints.length=s,this.assignmentTrail=[],this.decisionLevel=0,e.fill(-1),i>0){if(this.pruneDisjunctions(),this.allDisjunctions.length===0)return {satisfiable:true};e=new Int32Array(this.allDisjunctions.length).fill(-1),this.rebuildBranchIndex(false);}let o=this.cdclSearchLoop(e);if(o.satisfiable)return {satisfiable:true};if(o.provedUnsat)return this.buildUnsatResult(e);i++,this.updateRestartThreshold();}return this.buildUnsatResult(new Int32Array(this.allDisjunctions.length).fill(-1))}cdclSearchLoop(e){let n=this.allDisjunctions.length,s=0;for(;;){if(this.unitPropagate(e)==="conflict"){if(this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeConflict(e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false};continue}let r=this.graphPropagate(e);if(r!=="ok"){if(this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeTheoryConflict(r.disjunctionIndex,e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false};continue}if(this.allAssigned(e,n))return {satisfiable:true};let{dIdx:o,aIdx:a}=this.pickBranch(e);if(o===-1)return {satisfiable:true};if(this.decisionLevel++,!this.tryAssign(o,a,e,true)){if(e[o]=-1,this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeConflictForDecision(o,a,e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false}}}}unitPropagate(e){let n=true;for(;n;){n=false;for(let s of this.learnedClauses){let i=0,r=null,o=0;for(let a of s){let c=e[a.disjunctionIndex];c===-1?(o++,r=a):(a.sign&&c===a.alternativeIndex||!a.sign&&c!==a.alternativeIndex)&&i++;}if(!(i>0)){if(o===0)return "conflict";if(o===1&&r){let a=r;if(a.sign){if(!this.tryAssign(a.disjunctionIndex,a.alternativeIndex,e,false))return "conflict";n=true;}else {let v=this.getRemainingAlternatives(a.disjunctionIndex,e).filter(y=>y!==a.alternativeIndex);if(v.length===0)return "conflict";if(v.length===1){if(!this.tryAssign(a.disjunctionIndex,v[0],e,false))return "conflict";n=true;}}}}}}return "ok"}graphPropagate(e){if(this.groups.length===0||this.combinedGraphStamp()===this.lastPropagateOkStamp)return "ok";let n=true;for(;n;){n=false,this.consumeGraphDeltas();for(let s=0;s<this.allDisjunctions.length;s++){if(e[s]!==-1)continue;let i=this.allDisjunctions[s],r=this.hGraph.hasZeroWeightOrderingEdge||this.vGraph.hasZeroWeightOrderingEdge,o=this.hGraph.addVersion+this.vGraph.addVersion,a=this.hGraph.removeVersion+this.vGraph.removeVersion,c=null;r||(this.verdictEntryDisj[s]===i?c=this.verdictEntryByIndex[s]:(c=this.verdictEntryFor(i),this.verdictEntryDisj[s]=i,this.verdictEntryByIndex[s]=c));let v=0,y=-1;for(let g=0;g<i.alternatives.length;g++)(c===null?this.isAlternativeFeasible(i.alternatives[g]):this.altFeasibleCached(i,c,g,o,a))&&(v++,y=g);if(v===0)return {conflict:true,disjunctionIndex:s};if(v===1){if(!this.tryAssign(s,y,e,false))return {conflict:true,disjunctionIndex:s};n=true;}}}return this.lastPropagateOkStamp=this.combinedGraphStamp(),"ok"}combinedGraphStamp(){return this.hGraph.addVersion+this.hGraph.removeVersion+this.vGraph.addVersion+this.vGraph.removeVersion}consumeGraphDeltas(){let e=this.hGraph.consumeReachDeltas(),n=this.vGraph.consumeReachDeltas();if(e===null||n===null){this.additionEpoch++;return}for(let s of e)this.dirtyProbe("h",s.from,s.to);for(let s of n)this.dirtyProbe("v",s.from,s.to);}dirtyProbe(e,n,s){let i=this.probeIndex.get(`${e}\0${n}\0${s}`);if(i)for(let{entry:r,aIdx:o}of i)r.verdict[o]===1&&(r.verdict[o]=0);}registerProbes(e,n,s){let i=false,r=(o,a,c)=>{let v=`${o}\0${a}\0${c}`,y=this.probeIndex.get(v);y||(y=[],this.probeIndex.set(v,y)),y.push({entry:e,aIdx:n});};for(let o of s){if(Fn(o)){i=true;continue}if(Is(o)){for(let c of this.groupBoundaryEdges(o))r(c.axis,c.to,c.from);continue}if(Ls(o)){let c=o,v=c.side==="left"||c.side==="right"?"h":"v";for(let y of c.group.nodeIds)r(v,c.node.id,y),r(v,y,c.node.id);}let a=this.constraintToEdge(o);a&&r(a.axis,a.to,a.from);}return i}verdictEntryFor(e){let n=this.altVerdictCache.get(e);if(!n){let s=e.alternatives.length;n={verdict:new Int8Array(s),addStamp:new Float64Array(s),remStamp:new Float64Array(s),hasAlignment:new Uint8Array(s)};for(let i=0;i<s;i++)this.registerProbes(n,i,e.alternatives[i])&&(n.hasAlignment[i]=1);this.altVerdictCache.set(e,n);}return n}altFeasibleCached(e,n,s,i,r){let o=n.hasAlignment[s]?i:this.additionEpoch,a=n.verdict[s];if(a===1&&n.addStamp[s]===o)return true;if(a===2&&n.remStamp[s]===r)return false;let c=this.isAlternativeFeasible(e.alternatives[s]);return n.verdict[s]=c?1:2,n.addStamp[s]=o,n.remStamp[s]=r,c}getRemainingAlternatives(e,n){let s=this.allDisjunctions[e];if(n[e]!==-1)return [n[e]];let i=new Set;for(let o of this.learnedClauses)for(let a of o)a.disjunctionIndex===e&&!a.sign&&o.every(v=>{if(v===a)return true;let y=n[v.disjunctionIndex];return y===-1?false:v.sign?y!==v.alternativeIndex:y===v.alternativeIndex})&&i.add(a.alternativeIndex);let r=[];for(let o=0;o<s.alternatives.length;o++)i.has(o)||r.push(o);return r}tryAssign(e,n,s,i){let r=this.allDisjunctions[e].alternatives[n];for(let o of r)if(!this.addQualitativeEdge(o))return this.undoAlternativeEdges(r,o),false;s[e]=n,this.assignmentTrail.push({disjunctionIndex:e,alternativeIndex:n,decisionLevel:this.decisionLevel,isDecision:i});for(let o of r)this.addedConstraints.push(o);return true}addQualitativeEdge(e){if(ii(e))return this.hGraph.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return this.vGraph.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Ls(e)){let n=e,i=n.side==="left"||n.side==="right"?this.hGraph:this.vGraph;for(let o of n.group.nodeIds)if(i.areAligned(n.node.id,o))return false;if(!this.isBoundingBoxFeasible(n))return false;let r=`_group_${n.group.name}`;switch(this.hGraph.ensureNode(r),this.vGraph.ensureNode(r),n.side){case "left":if(!this.hGraph.addEdge(n.node.id,r,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.hGraph.ensureNode(o),this.hGraph.addEdge(n.node.id,o,n.minDistance,e);return true;case "right":if(!this.hGraph.addEdge(r,n.node.id,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.hGraph.ensureNode(o),this.hGraph.addEdge(o,n.node.id,n.minDistance,e);return true;case "top":if(!this.vGraph.addEdge(n.node.id,r,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.vGraph.ensureNode(o),this.vGraph.addEdge(n.node.id,o,n.minDistance,e);return true;case "bottom":if(!this.vGraph.addEdge(r,n.node.id,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.vGraph.ensureNode(o),this.vGraph.addEdge(o,n.node.id,n.minDistance,e);return true}}if(Is(e)){let n=[];for(let s of this.groupBoundaryEdges(e)){if(!(s.axis==="h"?this.hGraph:this.vGraph).addEdge(s.from,s.to,e.minDistance,e)){for(let r of n)(r.axis==="h"?this.hGraph:this.vGraph).removeEdgeClaim(r.from,r.to,e.minDistance,e);return false}n.push(s);}return true}if(Fn(e)){let n=e;return (n.axis==="x"?this.hGraph:this.vGraph).addAlignmentEdges(n.node1.id,n.node2.id,e)}return true}undoAlternativeEdges(e,n){for(let s of e){if(s===n)break;this.removeQualitativeEdge(s);}}removeQualitativeEdge(e){if(ii(e))this.hGraph.removeEdgeClaim(e.left.id,e.right.id,e.minDistance,e);else if(ni(e))this.vGraph.removeEdgeClaim(e.top.id,e.bottom.id,e.minDistance,e);else if(Ls(e)){let n=e,s=`_group_${n.group.name}`;switch(n.side){case "left":this.hGraph.removeEdgeClaim(n.node.id,s,n.minDistance,e);for(let i of n.group.nodeIds)this.hGraph.removeEdgeClaim(n.node.id,i,n.minDistance,e);break;case "right":this.hGraph.removeEdgeClaim(s,n.node.id,n.minDistance,e);for(let i of n.group.nodeIds)this.hGraph.removeEdgeClaim(i,n.node.id,n.minDistance,e);break;case "top":this.vGraph.removeEdgeClaim(n.node.id,s,n.minDistance,e);for(let i of n.group.nodeIds)this.vGraph.removeEdgeClaim(n.node.id,i,n.minDistance,e);break;case "bottom":this.vGraph.removeEdgeClaim(s,n.node.id,n.minDistance,e);for(let i of n.group.nodeIds)this.vGraph.removeEdgeClaim(i,n.node.id,n.minDistance,e);break}}else if(Is(e))for(let n of this.groupBoundaryEdges(e))(n.axis==="h"?this.hGraph:this.vGraph).removeEdgeClaim(n.from,n.to,e.minDistance,e);else if(Fn(e)){let n=e;(n.axis==="x"?this.hGraph:this.vGraph).removeAlignmentEdges(n.node1.id,n.node2.id);}}analyzeConflict(e){let n=[],s=0,i=0;for(let r of this.assignmentTrail)r.isDecision&&(n.push({disjunctionIndex:r.disjunctionIndex,alternativeIndex:r.alternativeIndex,sign:false}),r.decisionLevel>s?(i=s,s=r.decisionLevel):r.decisionLevel>i&&r.decisionLevel<s&&(i=r.decisionLevel));return n.length===0?{learnedClause:null,backtrackLevel:0}:{learnedClause:n,backtrackLevel:Math.max(0,i)}}analyzeConflictForDecision(e,n,s){let i=this.allDisjunctions[e].alternatives[n],r=new Set;for(let v of i){let y=this.constraintToEdge(v);if(!y)continue;let g=y.axis==="h"?this.hGraph:this.vGraph;if(g.canReach(y.to,y.from)){let h=g.findPath(y.to,y.from);if(h)for(let[u,d]of h){let f=g.getEdgeProvenance(u,d);if(f){let l=this.findTrailEntryForConstraint(f);l!==-1&&r.add(l);}}}}if(r.size>0){let v=[{disjunctionIndex:e,alternativeIndex:n,sign:false}],y=0,g=0;for(let h of r){let u=this.assignmentTrail[h];v.push({disjunctionIndex:u.disjunctionIndex,alternativeIndex:u.alternativeIndex,sign:false}),u.decisionLevel>y?(g=y,y=u.decisionLevel):u.decisionLevel>g&&u.decisionLevel<y&&(g=u.decisionLevel);}return this.decisionLevel>y?(g=y,y=this.decisionLevel):this.decisionLevel>g&&this.decisionLevel<y&&(g=this.decisionLevel),{learnedClause:v,backtrackLevel:Math.max(0,g)}}let o=[{disjunctionIndex:e,alternativeIndex:n,sign:false}],a=0,c=0;for(let v of this.assignmentTrail)o.push({disjunctionIndex:v.disjunctionIndex,alternativeIndex:v.alternativeIndex,sign:false}),v.decisionLevel>a?(c=a,a=v.decisionLevel):v.decisionLevel>c&&v.decisionLevel<a&&(c=v.decisionLevel);return {learnedClause:o,backtrackLevel:Math.max(0,c)}}analyzeTheoryConflict(e,n){let s=this.allDisjunctions[e],i=new Set;for(let r=0;r<s.alternatives.length;r++){let o=s.alternatives[r];for(let a of o){let c=this.constraintToEdge(a);if(!c)continue;let v=c.axis==="h"?this.hGraph:this.vGraph;if(v.canReach(c.to,c.from)){let y=v.findPath(c.to,c.from);if(y)for(let[g,h]of y){let u=v.getEdgeProvenance(g,h);if(u){let d=this.findTrailEntryForConstraint(u);d!==-1&&i.add(d);}}}}}if(i.size>0){let r=[],o=0,a=0;for(let c of i){let v=this.assignmentTrail[c];r.push({disjunctionIndex:v.disjunctionIndex,alternativeIndex:v.alternativeIndex,sign:false}),v.decisionLevel>o?(a=o,o=v.decisionLevel):v.decisionLevel>a&&v.decisionLevel<o&&(a=v.decisionLevel);}if(r.length>0)return {learnedClause:r,backtrackLevel:Math.max(0,a)}}return this.analyzeConflict(n)}findTrailEntryForConstraint(e){for(let n=0;n<this.assignmentTrail.length;n++){let s=this.assignmentTrail[n];if(this.allDisjunctions[s.disjunctionIndex].alternatives[s.alternativeIndex].includes(e))return n}return -1}backtrackTo(e,n){for(;this.assignmentTrail.length>0;){let s=this.assignmentTrail[this.assignmentTrail.length-1];if(s.decisionLevel<=e)break;let i=this.allDisjunctions[s.disjunctionIndex].alternatives[s.alternativeIndex];for(let r of i)this.removeQualitativeEdge(r);this.addedConstraints.length-=i.length,n[s.disjunctionIndex]=-1,this.assignmentTrail.pop();}this.decisionLevel=e;}rebuildBranchIndex(e){let n=this.allDisjunctions.length,s=1;for(let r of this.allDisjunctions)r.alternatives.length>s&&(s=r.alternatives.length);if(s>this.branchStride){let r=this.branchStride,o=this.activityFlat;if(this.branchStride=s,this.activityFlat=new Float64Array(Math.max(n,1)*s),r>0&&!e){let a=Math.floor(o.length/r);for(let c=0;c<a&&c<n;c++)for(let v=0;v<r;v++)this.activityFlat[c*s+v]=o[c*r+v];}}else if(n*this.branchStride>this.activityFlat.length){let r=new Float64Array(n*this.branchStride);e||r.set(this.activityFlat),this.activityFlat=r;}else e&&this.activityFlat.fill(0);let i=Math.max(n,1)*this.branchStride;this.simplicityFlat.length<i&&(this.simplicityFlat=new Float64Array(i),this.elimScratch=new Uint8Array(i)),this.simplicityFlat.fill(0);for(let r=0;r<n;r++){let o=this.allDisjunctions[r].alternatives,a=r*this.branchStride;for(let c=0;c<o.length;c++)this.simplicityFlat[a+c]=1/(1+o[c].length);}}activityAt(e,n){let s=e*this.branchStride+n;return s>=0&&s<this.activityFlat.length?this.activityFlat[s]:0}computeEliminatedFlags(e){if(this.learnedClauses.length===0)return null;let n=this.elimScratch;n.fill(0);let s=this.branchStride;for(let i of this.learnedClauses)for(let r of i){if(r.sign)continue;let o=r.disjunctionIndex*s+r.alternativeIndex;if(o<0||o>=n.length||n[o]===1)continue;let a=true;for(let c of i){if(c===r)continue;let v=e[c.disjunctionIndex];if(v===-1||(c.sign?v===c.alternativeIndex:v!==c.alternativeIndex)){a=false;break}}a&&(n[o]=1);}return n}pickBranch(e){let n=-1,s=-1,i=-1,r=this.computeEliminatedFlags(e),o=this.branchStride;for(let a=0;a<this.allDisjunctions.length;a++){if(e[a]!==-1)continue;let c=this.allDisjunctions[a].alternatives,v=a*o;for(let y=0;y<c.length;y++){if(r!==null&&r[v+y]===1)continue;let g=this.activityFlat[v+y]+this.simplicityFlat[v+y];g>i&&(i=g,n=a,s=y);}}return {dIdx:n,aIdx:s}}bumpActivity(e){for(let n of e){let s=n.disjunctionIndex*this.branchStride+n.alternativeIndex;s>=0&&s<this.activityFlat.length&&(this.activityFlat[s]+=1);}}decayActivity(){let e=this.activityFlat,n=this.activityDecay;for(let s=0;s<e.length;s++)e[s]*=n;}updateRestartThreshold(){this.lubyIndex++,this.restartThreshold=32*this.luby(this.lubyIndex);}luby(e){let n=1,s=1;for(;n<e+1;)n=2*n+1,s*=2;for(;n-1!==e;)n=(n-1)/2,s=s/2,e>=n&&(e-=n);return s}pruneDisjunctions(){let e=[];for(let n of this.allDisjunctions){let s=this.findImpliedAlternative(n);if(s!==null){for(let r of n.alternatives[s])this.addedConstraints.push(r);continue}let i=[];for(let r of n.alternatives)this.isAlternativeFeasible(r)&&i.push(r);if(i.length===0)e.push(n);else if(i.length===1){for(let r of i[0])if(this.addConjunctiveConstraint(r)){e.push(n);break}}else e.push(new ys(n.sourceConstraint,i));}this.allDisjunctions=e;}allAssigned(e,n){for(let s=0;s<n;s++)if(e[s]===-1)return false;return true}checkpoint(){return {hGraph:this.hGraph.clone(),vGraph:this.vGraph.clone(),assignmentTrailLength:this.assignmentTrail.length,addedConstraintsLength:this.addedConstraints.length}}restoreCheckpoint(e){this.hGraph=e.hGraph.clone(),this.vGraph=e.vGraph.clone(),this.altVerdictCache.clear(),this.probeIndex.clear(),this.verdictEntryByIndex.length=0,this.verdictEntryDisj.length=0,this.additionEpoch++;}constraintToEdge(e){if(ii(e))return {axis:"h",from:e.left.id,to:e.right.id};if(ni(e))return {axis:"v",from:e.top.id,to:e.bottom.id};if(Ls(e)){let n=e,s=`_group_${n.group.name}`;switch(n.side){case "left":return {axis:"h",from:n.node.id,to:s};case "right":return {axis:"h",from:s,to:n.node.id};case "top":return {axis:"v",from:n.node.id,to:s};case "bottom":return {axis:"v",from:s,to:n.node.id}}}if(Is(e)){let n=e,s=`_group_${n.groupA.name}`,i=`_group_${n.groupB.name}`;switch(n.side){case "left":return {axis:"h",from:s,to:i};case "right":return {axis:"h",from:i,to:s};case "top":return {axis:"v",from:s,to:i};case "bottom":return {axis:"v",from:i,to:s}}}return null}static addEdgeToGraphsExpanded(e,n,s){if(Ls(e)){let i=e,r=i.node.id;for(let o of i.group.nodeIds)switch(i.side){case "left":if(!n.addEdge(r,o,i.minDistance,e))return false;break;case "right":if(!n.addEdge(o,r,i.minDistance,e))return false;break;case "top":if(!s.addEdge(r,o,i.minDistance,e))return false;break;case "bottom":if(!s.addEdge(o,r,i.minDistance,e))return false;break}return true}if(Is(e)){let i=e;for(let r of i.groupA.nodeIds)for(let o of i.groupB.nodeIds)switch(i.side){case "left":if(!n.addEdge(r,o,i.minDistance,e))return false;break;case "right":if(!n.addEdge(o,r,i.minDistance,e))return false;break;case "top":if(!s.addEdge(r,o,i.minDistance,e))return false;break;case "bottom":if(!s.addEdge(o,r,i.minDistance,e))return false;break}return true}if(ii(e))return n.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Fn(e)){let i=e,r=i.axis==="x"?n:s;if(!r.addAlignmentEdges(i.node1.id,i.node2.id,e))return false;if(i.node1.id!==i.node2.id){let o=i.axis==="x"?s:n;if(t.classHasDualAxisOverlap(r,o,i.node1.id,i.node2.id,true))return r.removeAlignmentEdges(i.node1.id,i.node2.id),false}return true}return true}static alternativeEntailmentRank(e,n,s){let i=[];for(let o of e)if(Ls(o)){let a=o;for(let c of a.group.nodeIds)switch(a.side){case "left":i.push({g:n,from:a.node.id,to:c});break;case "right":i.push({g:n,from:c,to:a.node.id});break;case "top":i.push({g:s,from:a.node.id,to:c});break;case "bottom":i.push({g:s,from:c,to:a.node.id});break}}else if(Is(o)){let a=o;for(let c of a.groupA.nodeIds)for(let v of a.groupB.nodeIds)switch(a.side){case "left":i.push({g:n,from:c,to:v});break;case "right":i.push({g:n,from:v,to:c});break;case "top":i.push({g:s,from:c,to:v});break;case "bottom":i.push({g:s,from:v,to:c});break}}else if(ii(o))i.push({g:n,from:o.left.id,to:o.right.id});else if(ni(o))i.push({g:s,from:o.top.id,to:o.bottom.id});else if(Fn(o)){let a=o,c=a.axis==="x"?n:s;if(a.node1.id!==a.node2.id&&!c.areAligned(a.node1.id,a.node2.id))return 2}let r=true;for(let o of i)if(!o.g.hasEdge(o.from,o.to)&&(r=false,!o.g.isOrdered(o.from,o.to)))return 2;return r?0:1}computeMaximalFeasibleSubset(){let e=new Id(this.minPadding),n=new Id(this.minPadding);for(let a of this.nodes)e.ensureNode(a.id,a.width),n.ensureNode(a.id,a.height);for(let a of this.groups){let c=`_group_${a.name}`;e.ensureNode(c),n.ensureNode(c);}let s=[];for(let a of this.orientationConstraints)t.addEdgeToGraphsExpanded(a,e,n)&&s.push(a);let i=[],r=this.originalDisjunctions.length>0?this.originalDisjunctions:this.allDisjunctions,o=[...r].sort((a,c)=>{let v=r.indexOf(a),y=r.indexOf(c),g=Math.max(...a.alternatives.map((u,d)=>this.activityAt(v,d))),h=Math.max(...c.alternatives.map((u,d)=>this.activityAt(y,d)));return g-h||v-y});for(let a of o){let c=false,v=a.alternatives.map((y,g)=>({alt:y,i:g,rank:t.alternativeEntailmentRank(y,e,n)})).sort((y,g)=>y.rank-g.rank||y.i-g.i);for(let{alt:y}of v){let g=e.clone(),h=n.clone(),u=true;for(let d of y)if(!t.addEdgeToGraphsExpanded(d,g,h)){u=false;break}if(u){for(let d of y)t.addEdgeToGraphsExpanded(d,e,n),s.push(d);c=true;break}}c||i.push(a);}return {feasibleConstraints:s,infeasibleDisjunctions:i,hGraph:e,vGraph:n}}addEdgeToGraphs(e,n,s){if(ii(e))return n.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Fn(e)){let i=e,r=i.axis==="x"?n:s;if(!r.addAlignmentEdges(i.node1.id,i.node2.id,e))return false;if(i.node1.id!==i.node2.id){let o=i.axis==="x"?s:n;if(t.classHasDualAxisOverlap(r,o,i.node1.id,i.node2.id,true))return r.removeAlignmentEdges(i.node1.id,i.node2.id),false}return true}if(Ls(e)){let i=e,r=`_group_${i.group.name}`;switch(n.ensureNode(r),s.ensureNode(r),i.side){case "left":return n.addEdge(i.node.id,r,i.minDistance,e);case "right":return n.addEdge(r,i.node.id,i.minDistance,e);case "top":return s.addEdge(i.node.id,r,i.minDistance,e);case "bottom":return s.addEdge(r,i.node.id,i.minDistance,e)}}if(Is(e)){let i=e,r=`_group_${i.groupA.name}`,o=`_group_${i.groupB.name}`;switch(n.ensureNode(r),n.ensureNode(o),s.ensureNode(r),s.ensureNode(o),i.side){case "left":return n.addEdge(r,o,i.minDistance,e);case "right":return n.addEdge(o,r,i.minDistance,e);case "top":return s.addEdge(r,o,i.minDistance,e);case "bottom":return s.addEdge(o,r,i.minDistance,e)}}return true}buildUnsatResult(e){let{feasibleConstraints:n,infeasibleDisjunctions:s,hGraph:i,vGraph:r}=this.computeMaximalFeasibleSubset(),o=new Map;for(let g of s){let h=g.sourceConstraint;o.has(h)||o.set(h,[]),g.alternatives.length>0&&g.alternatives[0].length>0&&o.get(h).push(g.alternatives[0][0]);}let a;s.length>0&&s[0].alternatives.length>0?a=s[0].alternatives[0][0]:this.orientationConstraints.length>0&&(a=this.orientationConstraints[0]),a||(a=this.orientationConstraints[0]||this.allDisjunctions[0]?.alternatives[0]?.[0]);let c=Fa(a),v=new Map;for(let[g,h]of o.entries()){let u=g.toHTML();v.has(u)||v.set(u,[]),h.forEach(d=>v.get(u).push(Fa(d)));}let y=s.length>0?s[0].sourceConstraint:a.sourceConstraint;return {satisfiable:false,error:{name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${c}" conflicts with existing constraints`,conflictingConstraint:a,conflictingSourceConstraint:y,minimalConflictingSet:o,maximalFeasibleSubset:n,errorMessages:{conflictingConstraint:c,conflictingSourceConstraint:y.toHTML(),minimalConflictingConstraints:v}}}}buildConjunctiveError(e){let n=this.findMinimalConflictSet(e),s=new Map,i=new Map;for(let r of n){let o=r.sourceConstraint;s.has(o)||s.set(o,[]),i.has(o.toHTML())||i.set(o.toHTML(),[]),s.get(o).push(r),i.get(o.toHTML()).push(Fa(r));}return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${Fa(e)}" conflicts with existing constraints`,conflictingConstraint:e,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:s,maximalFeasibleSubset:[...this.addedConstraints],errorMessages:{conflictingConstraint:Fa(e),conflictingSourceConstraint:e.sourceConstraint.toHTML(),minimalConflictingConstraints:i}}}findMinimalConflictSet(e){let n=this.constraintToEdge(e);if(!n)return [];let s=n.axis==="h"?this.hGraph:this.vGraph,i=s.findPath(n.to,n.from);if(!i)return [];let r=[];for(let[o,a]of i){let c=s.getEdgeProvenance(o,a);if(c)r.push(c);else {let v=this.addedConstraints.find(y=>{let g=this.constraintToEdge(y);return g&&g.axis===n.axis&&g.from===o&&g.to===a});v&&r.push(v);}}return r}buildAlignmentConflictError(e,n){this.addedConstraints.push(e);let s=this.findAlignmentConflictSet(n);if(this.addedConstraints.pop(),s.includes(e)||s.push(e),Fn(e)){let c=e,v=n==="x"?this.hGraph:this.vGraph,y=c.node1.id,g=c.node2.id;for(let[h,u]of [[y,g],[g,y]])if(v.canReach(h,u)){let d=v.findPath(h,u);if(d)for(let[f,l]of d){let p=v.getEdgeProvenance(f,l);p&&!s.includes(p)&&s.push(p);}}}let i=new Map,r=new Map;for(let c of s){let v=c.sourceConstraint;i.has(v)||i.set(v,[]),r.has(v.toHTML())||r.set(v.toHTML(),[]),i.get(v).push(c),r.get(v.toHTML()).push(Fa(c));}let o=new Set(s),a=this.addedConstraints.filter(c=>!o.has(c));return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${Fa(e)}" conflicts with alignment constraints`,conflictingConstraint:e,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:i,maximalFeasibleSubset:a,errorMessages:{conflictingConstraint:Fa(e),conflictingSourceConstraint:e.sourceConstraint.toHTML(),minimalConflictingConstraints:r}}}findAlignmentConflictSet(e){let n=e==="x"?this.hGraph:this.vGraph,s=e==="x"?"h":"v",i=[],r=n.getAlignmentClasses(),o=new Map;for(let[c,v]of r)for(let y of v)o.set(y,c);for(let[c,v]of r)for(let y=0;y<v.length;y++)for(let g=y+1;g<v.length;g++){let h=v[y],u=v[g];if(!(n.isStrictlyOrdered(h,u)||n.isStrictlyOrdered(u,h)))continue;let[f,l]=n.isStrictlyOrdered(h,u)?[h,u]:[u,h];for(let x of this.addedConstraints){if(!Fn(x))continue;let b=x;if(b.axis!==e)continue;let S=o.get(b.node1.id),_=o.get(b.node2.id);(S===c||_===c)&&(i.includes(x)||i.push(x));}let p=n.findPath(f,l);if(p)for(let[x,b]of p){let S=n.getEdgeProvenance(x,b);if(S&&!i.includes(S))i.push(S);else if(!S){let _=this.addedConstraints.find(T=>{let k=this.constraintToEdge(T);return k&&k.axis===s&&k.from===x&&k.to===b});_&&!i.includes(_)&&i.push(_);}}return i}let a=[...r.keys()].sort();for(let c=0;c<a.length;c++)for(let v=c+1;v<a.length;v++){let y=r.get(a[c]),g=r.get(a[v]),h=false,u=false;for(let d of y)for(let f of g)n.isOrdered(d,f)&&(h=true),n.isOrdered(f,d)&&(u=true);if(!(!h||!u)){for(let d of this.addedConstraints){if(!Fn(d))continue;let f=d;if(f.axis!==e)continue;let l=o.get(f.node1.id),p=o.get(f.node2.id);(l===a[c]||l===a[v]||p===a[c]||p===a[v])&&(i.includes(d)||i.push(d));}return this.collectOrderingPath(y,g,n,s,i),this.collectOrderingPath(g,y,n,s,i),i}}return i}collectOrderingPath(e,n,s,i,r){for(let o of e)for(let a of n){if(!s.isOrdered(o,a))continue;let c=s.findPath(o,a);if(c)for(let[v,y]of c){let g=s.getEdgeProvenance(v,y);if(g&&!r.includes(g))r.push(g);else if(!g){let h=this.addedConstraints.find(u=>{let d=this.constraintToEdge(u);return d&&d.axis===i&&d.from===v&&d.to===y});h&&!r.includes(h)&&r.push(h);}}return}}validateGroupConstraints(){for(let e=0;e<this.groups.length;e++)if(!this.groups[e].negated)for(let n=e+1;n<this.groups.length;n++){if(this.groups[n].negated)continue;let s=this.groups[e],i=this.groups[n];if(this.isSubGroup(s,i)||this.isSubGroup(i,s))continue;this.groupIntersection(s,i).length>0&&(s.overlapping=true,i.overlapping=true);}return null}computeAlignmentOrders(){let e=new Set(this.nodes.map(a=>a.id));this.verticallyAligned=[];for(let[,a]of this.hGraph.getAlignmentClasses()){let c=a.filter(v=>e.has(v));c.length>=2&&this.verticallyAligned.push(c.map(v=>this.nodeMap.get(v)));}this.horizontallyAligned=[];for(let[,a]of this.vGraph.getAlignmentClasses()){let c=a.filter(v=>e.has(v));c.length>=2&&this.horizontallyAligned.push(c.map(v=>this.nodeMap.get(v)));}let n=[],s=this.hGraph.topologicalSort()||[],i=new Map;s.forEach((a,c)=>i.set(a,c));for(let a of this.horizontallyAligned){a.sort((c,v)=>(i.get(c.id)??0)-(i.get(v.id)??0));for(let c=0;c<a.length-1;c++){let v=new yc(["directlyLeft"],`${a[c].id}->${a[c+1].id}`),y=new K0(v,"Preventing Overlap");n.push({left:a[c],right:a[c+1],minDistance:this.minPadding,sourceConstraint:y});}}let r=this.vGraph.topologicalSort()||[],o=new Map;r.forEach((a,c)=>o.set(a,c));for(let a of this.verticallyAligned){a.sort((c,v)=>(o.get(c.id)??0)-(o.get(v.id)??0));for(let c=0;c<a.length-1;c++){let v=new yc(["directlyAbove"],`${a[c].id}->${a[c+1].id}`),y=new K0(v,"Preventing Overlap");n.push({top:a[c],bottom:a[c+1],minDistance:this.minPadding,sourceConstraint:y});}}return n}detectNodeOverlaps(){for(let e of this.horizontallyAligned){let n=new Set(e.map(s=>s.id));for(let s of this.verticallyAligned){let i=s.filter(r=>n.has(r.id));if(i.length>=2){let r=i[0],o=i[1],a=this.findAlignmentPath(r.id,o.id,"x"),c=this.findAlignmentPath(r.id,o.id,"y"),v=[...a,...c],y=new Map,g=new Map;for(let l of v){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),y.get(p).push(l);let x=p.toHTML();g.has(x)||g.set(x,[]),g.get(x).push(Fa(l));}let h=a.length>0&&a.length<=c.length?this.findConstraintsToBreakAlignment(r.id,o.id,"x"):this.findConstraintsToBreakAlignment(r.id,o.id,"y"),u=new Set(h),d=this.addedConstraints.filter(l=>!u.has(l)),f=v[0]||this.addedConstraints[0];return {name:"PositionalConstraintError",type:"positional-conflict",message:`Alignment constraints force ${r.id} and ${o.id} to occupy the same position`,conflictingConstraint:f,conflictingSourceConstraint:f.sourceConstraint,minimalConflictingSet:y,maximalFeasibleSubset:d,errorMessages:{conflictingConstraint:Fa(f),conflictingSourceConstraint:f.sourceConstraint.toHTML(),minimalConflictingConstraints:g}}}}}return null}findAlignmentPath(e,n,s){let i=new Map;for(let c of this.addedConstraints){if(!Fn(c))continue;let v=c;if(v.axis!==s)continue;let y=v.node1.id,g=v.node2.id;i.has(y)||i.set(y,[]),i.has(g)||i.set(g,[]),i.get(y).push({neighbor:g,constraint:c}),i.get(g).push({neighbor:y,constraint:c});}let r=new Set([e]),o=new Map;o.set(e,null);let a=[e];for(;a.length>0;){let c=a.shift();if(c===n){let v=[],y=n;for(;o.get(y)!==null;){let g=o.get(y);v.push(g.constraint),y=g.node;}return v.reverse()}for(let{neighbor:v,constraint:y}of i.get(c)||[])r.has(v)||(r.add(v),o.set(v,{node:c,constraint:y}),a.push(v));}return []}findConstraintsToBreakAlignment(e,n,s){let i=this.addedConstraints.filter(a=>Fn(a)&&a.axis===s),r=a=>{let c=new Map;for(let g of i){if(a.has(g))continue;let h=g;c.has(h.node1.id)||c.set(h.node1.id,[]),c.has(h.node2.id)||c.set(h.node2.id,[]),c.get(h.node1.id).push(h.node2.id),c.get(h.node2.id).push(h.node1.id);}let v=new Set([e]),y=[e];for(;y.length>0;){let g=y.shift();if(g===n)return true;for(let h of c.get(g)||[])v.has(h)||(v.add(h),y.push(h));}return false};for(let a of i)if(!r(new Set([a])))return [a];let o=new Set;for(let a of i)if(o.add(a),!r(o))return [...o];return [...o]}static classHasDualAxisOverlap(e,n,s,i,r){let o;if(r)o=e.getAlignmentClassOf(s);else {let a=e.getAlignmentClassOf(s),c=e.getAlignmentClassOf(i);o=[...new Set([...a,...c])];}for(let a=0;a<o.length;a++)for(let c=a+1;c<o.length;c++)if(n.areAligned(o[a],o[c]))return true;return false}normalizeAlignment(e){let n=[];for(let i of e){let r=false;for(let o of n)if(i.some(a=>o.some(c=>c.id===a.id))){for(let a of i)o.some(c=>c.id===a.id)||o.push(a);r=true;break}r||n.push([...i]);}let s=true;for(;s;){s=false;for(let i=0;i<n.length;i++){for(let r=i+1;r<n.length;r++)if(n[i].some(o=>n[r].some(a=>o.id===a.id))){for(let o of n[r])n[i].some(a=>a.id===o.id)||n[i].push(o);n.splice(r,1),s=true;break}if(s)break}}return n}isSubGroup(e,n){return e.nodeIds.every(s=>n.nodeIds.includes(s))}groupIntersection(e,n){return e.nodeIds.filter(s=>n.nodeIds.includes(s))}dispose(){this.hGraph=new Id(this.minPadding),this.vGraph=new Id(this.minPadding),this.learnedClauses=[],this.activityFlat=new Float64Array(0),this.simplicityFlat=new Float64Array(0),this.elimScratch=new Uint8Array(0),this.branchStride=0,this.assignmentTrail=[],this.altVerdictCache.clear(),this.probeIndex.clear(),this.verdictEntryByIndex.length=0,this.verdictEntryDisj.length=0,this.lastPropagateOkStamp=-1,this.resetModalQueryState();}getStats(){return {hEdges:this.hGraph.edgeCount(),vEdges:this.vGraph.edgeCount(),learnedClauses:this.learnedClauses.length,conflicts:this.conflictCount,addedConstraints:this.addedConstraints.length,prunedByTransitivity:this.prunedByTransitivity,prunedByDecomposition:this.prunedByDecomposition}}resetModalQueryState(){this.mustHGraph=null,this.mustVGraph=null,this.mustHPairs=null,this.mustVPairs=null,this.mustHAlignmentClasses=null,this.mustVAlignmentClasses=null,this.modalStateBuilt=false,this.validationSucceeded=false;}ensureModalQueryState(){this.modalStateBuilt||!this.validationSucceeded||!this.mustHGraph||!this.mustVGraph||(this.modalStateBuilt=true,this.buildModalQueryState());}buildModalQueryState(){if(!this.mustHGraph||!this.mustVGraph)return;let e=this.nodes.map(n=>n.id);this.mustHPairs=this.collectStrictPairs(this.mustHGraph,e),this.mustVPairs=this.collectStrictPairs(this.mustVGraph,e);for(let n of this.allDisjunctions)n.alternatives.length<2||this.strengthenWithDisjunction(n,e);this.mustHAlignmentClasses=this.collectAlignmentClasses(this.mustHGraph,e),this.mustVAlignmentClasses=this.collectAlignmentClasses(this.mustVGraph,e);}collectStrictPairs(e,n){let s=new Set;for(let i of n)for(let r of n)i!==r&&e.isProperlyBefore(i,r)&&s.add(`${i}\0${r}`);return s}collectAlignmentClasses(e,n){let s=new Map,i=new Set(n);for(let r of n)s.set(r,new Set);for(let[,r]of e.getAlignmentClasses()){let o=r.filter(a=>i.has(a));for(let a of o){let c=s.get(a);if(c)for(let v of o)v!==a&&c.add(v);}}return s}strengthenWithDisjunction(e,n){if(!this.mustHGraph||!this.mustVGraph||!this.mustHPairs||!this.mustVPairs)return;let s=null,i=null,r=null,o=null;for(let a of e.alternatives){let c=this.mustHGraph.clone(),v=this.mustVGraph.clone();for(let d of a)this.addEdgeToGraph(d,c,v);let y=this.collectStrictPairs(c,n),g=this.collectStrictPairs(v,n),h=this.collectAlignmentPairs(c,n),u=this.collectAlignmentPairs(v,n);if(s===null)s=y,i=g,r=h,o=u;else {for(let d of s)y.has(d)||s.delete(d);for(let d of i)g.has(d)||i.delete(d);for(let d of r)h.has(d)||r.delete(d);for(let d of o)u.has(d)||o.delete(d);}}if(s)for(let a of s){this.mustHPairs.add(a);let[c,v]=a.split("\0");this.mustHGraph.addEdge(c,v,1);}if(i)for(let a of i){this.mustVPairs.add(a);let[c,v]=a.split("\0");this.mustVGraph.addEdge(c,v,1);}if(r)for(let a of r){let[c,v]=a.split("\0");this.mustHGraph.addAlignmentEdges(c,v);}if(o)for(let a of o){let[c,v]=a.split("\0");this.mustVGraph.addAlignmentEdges(c,v);}}collectAlignmentPairs(e,n){let s=new Set;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)e.areAligned(n[i],n[r])&&s.add(`${n[i]}\0${n[r]}`);return s}addEdgeToGraph(e,n,s){if(ii(e))n.addEdge(e.left.id,e.right.id,e.minDistance,e);else if(ni(e))s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);else if(Fn(e)){let i=e;(i.axis==="x"?n:s).addAlignmentEdges(i.node1.id,i.node2.id,e);}else if(Is(e))for(let i of this.groupBoundaryEdges(e))(i.axis==="h"?n:s).addEdge(i.from,i.to,e.minDistance,e);else if(Ls(e)){let i=e,r=`_group_${i.group.name}`;switch(n.ensureNode(r),s.ensureNode(r),i.side){case "left":n.addEdge(i.node.id,r,i.minDistance,e);for(let o of i.group.nodeIds)n.ensureNode(o),n.addEdge(i.node.id,o,i.minDistance,e);break;case "right":n.addEdge(r,i.node.id,i.minDistance,e);for(let o of i.group.nodeIds)n.ensureNode(o),n.addEdge(o,i.node.id,i.minDistance,e);break;case "top":s.addEdge(i.node.id,r,i.minDistance,e);for(let o of i.group.nodeIds)s.ensureNode(o),s.addEdge(i.node.id,o,i.minDistance,e);break;case "bottom":s.addEdge(r,i.node.id,i.minDistance,e);for(let o of i.group.nodeIds)s.ensureNode(o),s.addEdge(o,i.node.id,i.minDistance,e);break}}}static pairKey(e,n){return `${e}\0${n}`}getMust(e,n){this.ensureModalQueryState();let s=new Set(this.nodes.map(r=>r.id)),i=new Set;if(!this.mustHPairs||!this.mustVPairs)return i;for(let r of s){if(r===e)continue;let o;switch(n){case "rightOf":o=t.pairKey(e,r),this.mustHPairs.has(o)&&i.add(r);break;case "leftOf":o=t.pairKey(r,e),this.mustHPairs.has(o)&&i.add(r);break;case "below":o=t.pairKey(e,r),this.mustVPairs.has(o)&&i.add(r);break;case "above":o=t.pairKey(r,e),this.mustVPairs.has(o)&&i.add(r);break}}return i}getCannot(e,n){this.ensureModalQueryState();let s=new Set;s.add(e);let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return s;for(let r of this.nodes){if(r.id===e)continue;(n==="leftOf"||n==="above"?i.canReach(e,r.id):i.canReach(r.id,e))&&s.add(r.id);}return s}getCan(e,n){let s=this.getCannot(e,n),i=new Set;for(let r of this.nodes)s.has(r.id)||i.add(r.id);return i}getMustAligned(e,n){return this.ensureModalQueryState(),(n==="x"?this.mustHAlignmentClasses:this.mustVAlignmentClasses)?.get(e)??new Set}getCannotAligned(e,n){this.ensureModalQueryState();let s=new Set;s.add(e);let i=n==="x"?this.mustHGraph:this.mustVGraph,r=n==="x"?this.mustVGraph:this.mustHGraph;if(!i)return s;for(let o of this.nodes)if(o.id!==e){if(i.isStrictlyOrdered(e,o.id)||i.isStrictlyOrdered(o.id,e)){s.add(o.id);continue}r&&t.classHasDualAxisOverlap(i,r,e,o.id,false)&&s.add(o.id);}return s}getCanAligned(e,n){let s=this.getCannotAligned(e,n),i=new Set;for(let r of this.nodes)s.has(r.id)||i.add(r.id);return i}whyMust(e,n,s){if(!this.getMust(e,n).has(s))return null;let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return null;let[r,o]=n==="leftOf"||n==="above"?[s,e]:[e,s];return this.collectPathProvenance(i,r,o)}whyCannot(e,n,s){if(!this.getCannot(e,n).has(s))return null;if(e===s)return [];let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return null;let[r,o]=n==="leftOf"||n==="above"?[e,s]:[s,e];return this.collectPathProvenance(i,r,o)}collectPathProvenance(e,n,s){let i=e.findPath(n,s);if(!i)return [];let r=new Set,o=[];for(let[a,c]of i){let v=e.getEdgeProvenance(a,c);v&&!r.has(v.sourceConstraint)&&(r.add(v.sourceConstraint),o.push(v.sourceConstraint));}return o}getReachable(e,n){let s=new Set(this.nodes.map(r=>r.id)),i=new Set;switch(n){case "rightOf":{for(let r of s)r!==e&&this.hGraph.isProperlyBefore(e,r)&&i.add(r);break}case "leftOf":{for(let r of s)r!==e&&this.hGraph.isProperlyBefore(r,e)&&i.add(r);break}case "below":{for(let r of s)r!==e&&this.vGraph.isProperlyBefore(e,r)&&i.add(r);break}case "above":{for(let r of s)r!==e&&this.vGraph.isProperlyBefore(r,e)&&i.add(r);break}}return i}getAlignedWith(e,n){let s=n==="x"?this.hGraph:this.vGraph,i=new Set(this.nodes.map(a=>a.id)),r=s.getAlignmentClassOf(e),o=new Set;for(let a of r)a!==e&&i.has(a)&&o.add(a);return o}};});function rv(t){switch(t){case "small":return 9;case "large":return 20;default:return 11}}function $ht(t){return typeof t=="string"?{text:t,fontSize:11}:t}function Yht(t){return t===105||t===108||t===73||t===106||t===116||t===102||t===114||t===46||t===44||t===58||t===59||t===39||t===34||t===96||t===124||t===33||t===40||t===41||t===91||t===93||t===123||t===125?.5:t===87||t===77||t===109||t===119||t===64?1.4:t>=65&&t<=90?1.1:1}function cK(t,e,n){if(!t)return 0;let s=0;for(let i=0;i<t.length;i++)s+=Yht(t.charCodeAt(i));return s*e*n}function fK(t,e=[],n={}){let s={...Vht,...n},i=e.map($ht).filter(h=>h.text&&h.text.length>0),r=cK(t||"",14,s.avgGlyphRatio),o=0,a=0;for(let h of i){let u=cK(h.text,h.fontSize,s.avgGlyphRatio);u>o&&(o=u),a+=h.fontSize*1.35;}let v=Math.max(r,o)+s.paddingX,g=14*1.35+a+s.paddingY;return {width:Math.round(hK(v,s.min.w,s.max.w)),height:Math.round(hK(g,s.min.h,s.max.h))}}function hK(t,e,n){return t<e?e:t>n?n:t}var Vht,JC=Ie(()=>{Vht={avgGlyphRatio:.65,paddingX:32,paddingY:26,min:{w:100,h:60},max:{w:280,h:140}};});function Qht(t,e){if(t.kind!=="unresolved-name"||!t.name)return t.message;let n=Xht.has(e)?"constraint":"directive";return `'${t.name}' did not match any type, relation, or atom. This ${n} does not apply to anything.`}function Jht(t){return t.replace(/<[^>]*>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/\s+/g," ").trim()}function Zht(t){return t instanceof ME}function tft(t){let e=[],n=new Set;for(let s of t){let i;if(ii(s))i=`left|${s.left.id}|${s.right.id}|${s.minDistance}`;else if(ni(s))i=`top|${s.top.id}|${s.bottom.id}|${s.minDistance}`;else if(Fn(s)){let[r,o]=[s.node1.id,s.node2.id].sort();i=`align|${s.axis}|${r}|${o}`;}else i=`unknown|${JSON.stringify(s)}`;n.has(i)||(n.add(i),e.push(s));}return e}function eft(t,e,n){switch(n){case "left":return `${e} must be to the left of ${t}`;case "right":return `${e} must be to the right of ${t}`;case "above":return `${e} must be above ${t}`;case "below":return `${e} must be below ${t}`;case "directlyLeft":return `${e} must be directly to the left of ${t}`;case "directlyRight":return `${e} must be directly to the right of ${t}`;case "directlyAbove":return `${e} must be directly above ${t}`;case "directlyBelow":return `${e} must be directly below ${t}`;default:return `${e} is constrained relative to ${t} (${n})`}}function pK(t){let e=t.directives?.icons??[],n=t.directives?.atomColors??[];if(e.length===0&&n.length===0)return t;let i=[...n.map(r=>!r.selector||r.selector.trim().length===0||typeof r.color!="string"||r.color.length===0?null:{selector:r.selector,style:{borderStyle:{color:r.color}}}),...e.map(aE)].filter(r=>r!==null);return {...t,directives:{...t.directives,atomStyles:[...t.directives.atomStyles,...i],icons:[],atomColors:[]}}}var Wht,Xht,ME;exports.AlignmentEdgeStrategy=void 0;exports.ConstraintValidatorStrategy=void 0;var yb,KE;exports.LayoutInstance=void 0;var Cy=Ie(()=>{vd();Ad();iC();Ll();Bf();lC();hC();_T();kE();gb();JC();Wht="univ",Xht=new Set(["orientation","cyclic","align","group","size","hideAtom"]);ME=class t extends Error{constructor(n,s){let i=s&&"selector"in s?s.selector:void 0,r=i?` Selector: ${i}.`:"";super(`Constraint references node "${n}" that is missing from the layout (it may be hidden).${r}`);this.type="unknown-constraint";this.name="MissingNodeConstraintError",this.missingNodeId=n,this.sourceConstraint=s,Object.setPrototypeOf(this,t.prototype);}};exports.AlignmentEdgeStrategy=(s=>(s.NEVER="never",s.DIRECT="direct",s.CONNECTED="connected",s))(exports.AlignmentEdgeStrategy||{}),exports.ConstraintValidatorStrategy=(e=>(e.QUALITATIVE="qualitative",e))(exports.ConstraintValidatorStrategy||{});yb=class{constructor(e,n){this.Path=e;this.LoopsTo=n;}expand(e){let n=this.Path.map(o=>o.id);if(!this.LoopsTo)return n;let s=n.findIndex(o=>o===this.LoopsTo.id);if(s===-1)return n;let i=n.slice(0,s),r=n.slice(s);return i.concat(...Array(e).fill(r))}isSubpathOf(e){let n=this.expand(2),s=e.expand(1);if(s.length>n.length)return false;for(let i=0;i<=n.length-s.length;i++)if(s.every((r,o)=>r===n[i+o]))return true;return false}static areEquivalent(e,n){return e.isSubpathOf(n)&&n.isSubpathOf(e)}};KE=class KE{constructor(e,n,s=0,i=true,r,o){this.hideThisEdge="_h_";this.DEFAULT_NODE_ICON_PATH="";this.DEFAULT_NODE_HEIGHT=60;this.DEFAULT_NODE_WIDTH=100;this.minSepHeight=15;this.minSepWidth=15;this.selectorErrors=[];this.warnings=[];this.warningKeys=new Set;this.hiddenNodeSelectors=new Map;this.hiddenSelectorSources=new Map;this.hiddenNodeConflicts=new Map;this.conflictedHiddenNodes=new Set;this.inferredEdgeGroupStamps=new Map;this.cyclicFragments=[];this.exemptFromHiding=new Set;this.reintroducedNodes=new Set;this.instanceNum=s,this.evaluator=n,this._layoutSpec=pK(e),r!==void 0?this.alignmentEdgeStrategy=r:this.alignmentEdgeStrategy=i?"connected":"never",this.validatorStrategy=o??"qualitative";}recordSelectorError(e,n,s){let i=s instanceof Error?s.message:String(s);this.selectorErrors.push({selector:e,context:n,errorMessage:i});}recordWarning(e){let n=`${e.code}|${e.specType??""}|${e.specIndex??""}|${e.name??e.selector??e.message}`;this.warningKeys.has(n)||(this.warningKeys.add(n),this.warnings.push(e));}recordSpecParseWarnings(){for(let e of this._layoutSpec.warnings??[])this.recordWarning({severity:"warning",code:e.code,message:e.message.replace(/^\[spytial\]\s*/,""),context:"spec",specType:e.specType,label:e.specType??"spec"});}collectSelectorDiagnostics(e,n,s,i,r,o){let a=e.getDiagnostics?.()??[];if(a.length===0)return;let c=typeof o?.toHTML=="function"?Jht(o.toHTML()):`${i}[${r}] \xB7 ${n}`;for(let v of a)this.recordWarning({severity:"warning",code:v.kind,message:Qht(v,i),selector:n,context:s,specType:i,specIndex:r,label:c,name:v.name,suggestion:v.suggestion});}checkSelectorArity(e,n,s,i){let r=e.maxArity();return r===0?true:s==="binary"&&r<2?(this.recordSelectorError(n,i,new exports.SelectorArityError(n,"binary","unary")),false):s==="unary"&&r>1?(this.recordSelectorError(n,i,new exports.SelectorArityError(n,"unary","binary")),false):true}acceptSelectorResult(e,n,s,i,r,o,a){return this.collectSelectorDiagnostics(e,n,s,r,o,a),typeof e.isError=="function"&&e.isError()?(this.recordSelectorError(n,s,new Error(e.prettyPrint())),false):!(i!=="any"&&!this.checkSelectorArity(e,n,i,s))}isNodeHiddenByDirective(e){return this.hiddenNodeSelectors.has(e)}recordHiddenNodeConflict(e,n,s,i,r,o){let a=e.toHTML();this.hiddenNodeConflicts.has(a)||this.hiddenNodeConflicts.set(a,[]),this.hiddenNodeConflicts.get(a).push(n),r&&this.conflictedHiddenNodes.add(s),o&&this.conflictedHiddenNodes.add(i);}recordHiddenGroupMemberConflict(e,n){let s=e.sourceConstraint?.toHTML()??`group <code>${e.name}</code>`,i=`${n} is in group ${e.name}`;this.hiddenNodeConflicts.has(s)||this.hiddenNodeConflicts.set(s,[]),this.hiddenNodeConflicts.get(s).push(i),this.conflictedHiddenNodes.add(n);}get hideDisconnected(){return this._layoutSpec.directives.hideDisconnected||false}get hideDisconnectedBuiltIns(){return this._layoutSpec.directives.hideDisconnectedBuiltIns||false}isAttributeField(e,n,s){let i=this._layoutSpec.directives.attributes.filter(r=>r.field===e);if(i.length===0)return false;if(!n||!s)return i.some(r=>!r.selector&&!r.filter);for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"attribute selector",c),o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"attribute filter",c),a=false;}if(o&&a)return true}return false}isHiddenField(e,n,s){let i=this._layoutSpec.directives.hiddenFields.filter(r=>r.field===e);if(i.length>0)if(!n||!s){if(i.some(r=>!r.selector&&!r.filter))return true}else for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"hidden field selector",c),o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"hidden field filter",c),a=false;}if(o&&a)return true}return !!(n&&s&&this.resolveEdgeStyleForEdge(e,n,s).hidden===true)}normalizeComparableGroupToken(e){let n=e.trim();return n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}buildGroupKeyDisplay(e,n){let s=this.normalizeComparableGroupToken(e),i=(n||"").trim();if(!i)return s||e;let r=this.normalizeComparableGroupToken(i);return r===s?s||r||e:`${i}:${e}`}generateGroups(e,n){let s=this._layoutSpec.constraints.grouping.byselector;if(!s)return [];let i=[];for(let[a,c]of s.entries()){let v=c.selector,y;try{y=this.evaluator.evaluate(v,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(v,"groupBySelector selector",h);continue}if(!this.acceptSelectorResult(y,v,"groupBySelector selector","any","group",a,c))continue;if(y.maxArity()>1){let u=function(d,f,l){return "_g_0_1_"+d+":"+f+"->"+l};let h=y.selectedTwoples();for(var r of h){let d=r[0],f=r[1],l=e.node(d)?.label,p=this.buildGroupKeyDisplay(d,l),x=`${c.name}[${p}]`,b=i.find(S=>S.name===x);if(b)b.nodeIds.push(f);else {let S={name:x,nodeIds:[f],keyNodeId:d,showLabel:!c.negated,labelTextStyle:c.labelTextStyle,sourceConstraint:c,negated:c.negated,keyed:true};if(i.push(S),c.addEdge!=="none"){let[_,T]=c.addEdge==="fromgroup"?[f,d]:[d,f],k=u(x,_,T);e.setEdge(_,T,x,k);}}}}else {let h=y.selectedAtoms();if(h.length===0)continue;let u=h[0],d={name:c.name,nodeIds:h,keyNodeId:u,showLabel:!c.negated,labelTextStyle:c.labelTextStyle,sourceConstraint:c,negated:c.negated,keyed:false};i.push(d);}}return i}generateAttributesAndRemoveEdges(e){let n={},s={};return [...e.edges()].forEach(r=>{let o=r.name,a=this.getRelationName(e,r),c=r.v,v=r.w,y=this.isAttributeField(a,c,v),g=this.isHiddenField(a,c,v);if(g&&y)throw new Error(`${a} cannot be both an attribute and a hidden field.`);if(g){e.removeEdge(r.v,r.w,o);return}if(y){let h=this.getEdgeLabel(e,r),u=r.v,d=r.w,f=e.node(d)?.label||d,l=n[u]||{};l[h]||(l[h]=[],n[u]=l),l[h].push(f);let p=this.getAttributeTextStyle(a,c,v);if(p){let x=s[u]||(s[u]={});x[h]=p;}e.removeEdge(r.v,r.w,o);}}),{attributes:n,textStyles:s}}getAttributeTextStyle(e,n,s){let i=this._layoutSpec.directives.attributes.filter(r=>r.field===e);for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch{o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(v=>v[0]===n&&v[1]===s);}catch{a=false;}if(a)return r.textStyle}}generateTagsForNodes(e,n,s){let i=this._layoutSpec.directives.tags;if(!i||i.length===0)return {attributes:n,textStyles:s};let r={...n},o={...s},a=new Set(e.nodes()),c=(v,y,g)=>{if(!g)return;let h=o[v]||(o[v]={});h[y]=g;};for(let v of i){let y=v.textStyle;try{let h=this.evaluator.evaluate(v.toTag,{instanceIndex:this.instanceNum}).selectedAtoms(),u=this.evaluator.evaluate(v.value,{instanceIndex:this.instanceNum}),d=u.maxArity()>1?u.selectedTuplesAll():u.selectedAtoms().map(l=>[l]),f=new Map;for(let l of d){let p=f.get(l[0]);p?p.push(l):f.set(l[0],[l]);}for(let l of h){if(!a.has(l))continue;r[l]||(r[l]={});let p=f.get(l)??[];if(p.length!==0)for(let x of p)if(x.length===1){let b=v.name;r[l][b]||(r[l][b]=[]);let S=e.node(l)?.label||l;r[l][b].push(String(S)),c(l,b,y);}else if(x.length===2){let b=v.name;r[l][b]||(r[l][b]=[]);let S=x[x.length-1],_=a.has(String(S))&&e.node(String(S))?.label||String(S);r[l][b].push(_),c(l,b,y);}else {let b=x.slice(1,-1),S=x[x.length-1],_=b.map(R=>{let I=String(R);return `[${a.has(I)&&e.node(I)?.label||I}]`}).join(""),T=`${v.name}${_}`;r[l][T]||(r[l][T]=[]);let k=a.has(String(S))&&e.node(String(S))?.label||String(S);r[l][T].push(k),c(l,T,y);}}}catch(g){this.recordSelectorError(`name: ${v.name}, toTag: ${v.toTag}, value: ${v.value}`,"tag directive",g);}}return {attributes:r,textStyles:o}}ensureNoExtraNodes(e,n,s){let i=[...e.nodes()],r=this._layoutSpec.directives.hiddenAtoms,o=[];for(let[a,c]of r.entries())try{let v=this.evaluator.evaluate(c.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(v,c.selector,"hideAtom selector","unary","hideAtom",a))continue;let y=v.selectedAtoms();o.push({selector:c.selector,hiddenSet:new Set(y)}),c.source&&!this.hiddenSelectorSources.has(c.selector)&&this.hiddenSelectorSources.set(c.selector,c.source);}catch(v){this.recordSelectorError(c.selector,"hideAtom selector",v);}i.forEach(a=>{try{let v=n.getAtomType(a)?.isBuiltin||!1,y=e.inEdges(a)||[],g=e.outEdges(a)||[],u=y.length===0&&g.length===0&&(this.hideDisconnectedBuiltIns&&v||this.hideDisconnected),d=!1,f;for(let p of o)if(p.hiddenSet.has(a)){d=!0,f=p.selector;break}let l=u||d;if(d&&this.exemptFromHiding.has(a)){this.reintroducedNodes.add(a);return}if(l&&(e.removeNode(a),d&&f)){this.hiddenNodeSelectors.set(a,f);for(let p of s)p.negated||p.nodeIds.includes(a)&&this.recordHiddenGroupMemberConflict(p,a);}}catch(c){console.error("Failed to identify node type. Defaulting to showing node.",c);}});}collectHiddenAtoms(){if(this.hiddenNodeSelectors.size!==0)return [...this.hiddenNodeSelectors.keys()].sort()}collectCyclicFragments(){if(this.cyclicFragments.length!==0)return this.cyclicFragments.map(e=>[...e])}getMostSpecificType(e,n){return this.getNodeTypes(e,n)[0]}getNodeTypes(e,n){let i=n.getAtomType(e)?.types||[];return i=i.concat(Wht),i}getRelationName(e,n){let s=this.getEdgeLabel(e,n);try{return s.split("[")[0]}catch{return console.warn(`Failed to parse relation name from edge label: ${s}. Defaulting to empty string.`),s}}getEdgeLabel(e,n){return e.edge(n.v,n.w,n.name)}generateLayout(e){this.exemptFromHiding=new Set;let n=this.generateLayoutPass(e);if(this.conflictedHiddenNodes.size===0)return n;let s=new Map,i=new Set,r=new Map,o=()=>{for(let[y,g]of this.hiddenNodeConflicts){let h=s.get(y)??[];for(let u of g)h.includes(u)||h.push(u);s.set(y,h);}this.conflictedHiddenNodes.forEach(y=>i.add(y));for(let[y,g]of this.hiddenNodeSelectors)r.has(y)||r.set(y,g);},a=10,c=1;for(;this.conflictedHiddenNodes.size>0&&c<a;)o(),this.conflictedHiddenNodes.forEach(y=>this.exemptFromHiding.add(y)),n=this.generateLayoutPass(e),c++;this.conflictedHiddenNodes.size>0&&(o(),console.warn(`Hidden-node conflict resolution did not converge after ${c} passes.`));let v=n.layout.nodes.filter(y=>this.reintroducedNodes.has(y.id));if(v.length>0&&(n.layout.reintroducedNodes=v),n.error===null||fC(n.error)){let y=this.buildHiddenNodeConflictInfo(s,i,r);y.reintroducedNodeIds=v.map(g=>g.id),n={...n,error:y};}return n}generateLayoutPass(e){this.selectorErrors=[],this.warnings=[],this.warningKeys.clear(),this.recordSpecParseWarnings(),this.hiddenNodeSelectors=new Map,this.hiddenSelectorSources=new Map,this.hiddenNodeConflicts=new Map,this.conflictedHiddenNodes=new Set,this.reintroducedNodes=new Set,this.inferredEdgeGroupStamps=new Map,this.cyclicFragments=[];let n=e,s=n.generateGraph(this.hideDisconnected,false),{attributes:i,textStyles:r}=this.generateAttributesAndRemoveEdges(s);(({attributes:i,textStyles:r}=this.generateTagsForNodes(s,i,r))),this.addinferredEdges(s);let o=this.generateGroups(s,e);this.addDrawInferredEdges(s,o),this.ensureNoExtraNodes(s,e,o);let a=this.getAtomStyleMap(s,n),{colorMap:c,explicitlyColored:v}=this.getNodeColorMap(s,n,a),y=this.getNodeDisplayContent(s,n,i,r),g=this.getNodeSizeMap(s,y),h=this.getDisconnectedNodes(s),u=s.nodes().map(R=>{let F=s.node(R)?.label||R,B=c[R]||"black",P=v.has(R)?"directive":"default-palette",{height:K,width:G}=g[R],V=this.getMostSpecificType(R,e),Q=this.getNodeTypes(R,e),rt=o.filter(_t=>_t.nodeIds.includes(R)).map(_t=>_t.name),ht=i[R]||{},it=r[R]||{},H,nt=n.getAtoms().find(_t=>_t.id===R);nt?.labels&&(H=nt.labels);let gt=a[R],mt=gt?.iconStyle,At=gt?.showLabel??true,Et=mt?.placement??"full";return {id:R,label:F,name:F,color:B,colorSource:P,fillColor:gt?.fillStyle?.color,borderWidth:gt?.borderStyle?.width,textStyle:gt?.textStyle,groups:rt,attributes:ht,attributeTextStyles:it,labels:H,icon:mt?.path??this.DEFAULT_NODE_ICON_PATH,iconPlacement:Et,iconOpacity:mt?.opacity,height:K,width:G,mostSpecificType:V,types:Q,showLabels:At,disconnected:h.includes(R)}}),d=[],f=0,l=0,p=[],x=[],b=[];try{let R=this.applyRelativeOrientationConstraints(u,s);d=R.conjunctive,b.push(...R.disjunctive),f=d.length;let I=this.applyAlignConstraints(u,s);d=d.concat(I.conjunctive),b.push(...I.disjunctive),l=I.conjunctive.length,console.log(`Generated ${f} orientation constraints and ${l} alignment constraints (deduped + transitive reduction applied)`),this.pruneRedundantAlignmentEdges(s),d=tft(d),x=this.buildCyclicDisjunctions(u,s),b.push(...x),p=this.buildLayoutEdges(s,u,o);}catch(R){if(Zht(R))return this.handleMissingNodeConstraintError(R,{layoutNodes:u,graph:s,groups:o,disconnectedNodes:h,constraints:d});throw R}let S={nodes:u,edges:p,constraints:d,groups:o,disjunctiveConstraints:b.length>0?b:void 0,hiddenAtoms:this.collectHiddenAtoms(),cyclicFragments:this.collectCyclicFragments()};if(this.hiddenNodeConflicts.size>0)return {layout:{...S,edges:this.filterHiddenEdges(S.edges),groups:S.groups.filter(I=>!I.negated),warnings:this.warnings},error:this.buildHiddenNodeConflictInfo(),selectorErrors:this.selectorErrors,warnings:this.warnings};let _=new exports.QualitativeConstraintValidator(S),T=_.validateConstraints();if(T){if(Od(T))return this.handlePositionalConstraintError(T,S);if(lE(T))return this.handleGroupOverlapError(T,S);throw T}d=S.constraints,p=this.filterHiddenEdges(p),S.nodes=u,S.edges=p,S.constraints=d,S.groups=o.filter(R=>!R.negated);let k=_ instanceof exports.QualitativeConstraintValidator?_:void 0;return S.warnings=this.warnings,{layout:S,error:null,selectorErrors:this.selectorErrors,warnings:this.warnings,validator:k}}handleMissingNodeConstraintError(e,n){let s=this.filterHiddenEdges(this.buildLayoutEdges(n.graph,n.layoutNodes,n.groups)),i=n.groups;return {layout:{nodes:n.layoutNodes,edges:s,constraints:n.constraints,groups:i,disjunctiveConstraints:[],warnings:this.warnings,hiddenAtoms:this.collectHiddenAtoms(),cyclicFragments:this.collectCyclicFragments()},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}buildHiddenNodeConflictInfo(e=this.hiddenNodeConflicts,n=this.conflictedHiddenNodes,s=this.hiddenNodeSelectors){let i=new Map,r=new Set;for(let[g,h]of e.entries())i.set(g,h);for(let g of n){let h=s.get(g);h&&r.add(h);}let o=[...n];for(let g of r){let h=this.hiddenSelectorSources.get(g),u=h?ib(h):`hideAtom with selector <code>${g}</code>`,d=[];for(let f of o)s.get(f)===g&&d.push(`${f} is hidden`);d.length>0&&i.set(u,d);}let a=[...e.keys()][0],v={conflictingConstraint:e.get(a)?.[0]||"",conflictingSourceConstraint:a,minimalConflictingConstraints:i};return {name:"HiddenNodeConflictError",type:"hidden-node-conflict",message:`Layout constraints reference atoms [${o.join(", ")}] that a hideAtom directive hides. The hide and the constraints cannot both be satisfied. The diagram shows the layout as if those atoms were not hidden; they are drawn with a dashed outline.`,hiddenNodes:s,droppedConstraints:e,errorMessages:v}}handlePositionalConstraintError(e,n){let s=e.minimalConflictingSet,i=e.maximalFeasibleSubset?n.constraints:n.constraints.filter(o=>![...s.values()].flat().includes(o));return {layout:{nodes:n.nodes,edges:n.edges,constraints:i,groups:n.groups,conflictingConstraints:[...s.values()].flat(),warnings:this.warnings,hiddenAtoms:n.hiddenAtoms,cyclicFragments:n.cyclicFragments},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}handleGroupOverlapError(e,n){let s=e.overlappingNodes.map(v=>v.groups).flat(),i=n.groups.filter(v=>s.includes(v.name)),r=i.flatMap(v=>v.nodeIds),o=n.nodes.filter(v=>r.includes(v.id)),a=n.edges.filter(v=>o.some(y=>v.source.id===y.id)&&o.some(y=>v.target.id===y.id));return {layout:{nodes:o,edges:a,constraints:n.constraints,groups:i,overlappingNodes:e.overlappingNodes,warnings:this.warnings,hiddenAtoms:n.hiddenAtoms,cyclicFragments:n.cyclicFragments},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}buildCyclicDisjunctions(e,n){let s=this._layoutSpec.constraints.orientation.cyclic,i=[];for(let[r,o]of s.entries()){let a;try{a=this.evaluator.evaluate(o.selector,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(o.selector,"cyclic orientation selector",h);continue}if(!this.acceptSelectorResult(a,o.selector,"cyclic orientation selector","binary","cyclic",r,o))continue;let c=a.selectedTwoples(),v=new Map;c.forEach(h=>{let u=h[0],d=h[1],f=this.isNodeHiddenByDirective(u),l=this.isNodeHiddenByDirective(d);if(f||l){let b=`${u} is followed by ${d} in a ${o.direction} cycle`;this.recordHiddenNodeConflict(o,b,u,d,f,l);return}let p=e.find(b=>b.id===u),x=e.find(b=>b.id===d);if(!(!p||!x)){if(this.shouldAddAlignmentEdge(n,u,d)){let b=`_alignment_${u}_${d}_`;n.setEdge(u,d,b,b);}v.has(p)?v.get(p).push(x):v.set(p,[x]);}});let g=this.getFragmentsToConstrain(v).map(h=>h.Path.map(u=>u.id));o.direction==="counterclockwise"&&(g=g.map(h=>h.reverse())),g.forEach(h=>{let u=h.length;if(!o.negated&&u>=2&&this.cyclicFragments.push([...h]),u<=2)return;let d=[];for(let f=0;f<u;f++){let l=this.getCyclicConstraintForFragment(h,e,f,o);d.push(l);}if(o.negated){let f=new ys(o,d),l=qw(f,o);i.push(...l);}else {let f=new ys(o,d);i.push(f);}});}return i}getCyclicConstraintForFragment(e,n,s,i){if(e.length<=2)return [];let o=2*Math.PI/e.length,a={};for(var c=0;c<e.length;c++){let h=(c+s)*o,u=100*Math.cos(h),d=100*Math.sin(h);a[e[c]]={x:u,y:d};}let v=[];for(var y=0;y<e.length;y++)for(var g=0;g<e.length;g++)if(y!==g){let h=e[y],u=e[g],d=a[h],f=a[u];d.x>f.x?v.push(this.leftConstraint(u,h,this.minSepWidth,n,i)):d.x<f.x?v.push(this.leftConstraint(h,u,this.minSepWidth,n,i)):v.push(this.ensureSameXConstraint(h,u,n,i)),d.y>f.y?v.push(this.topConstraint(u,h,this.minSepHeight,n,i)):d.y<f.y?v.push(this.topConstraint(h,u,this.minSepHeight,n,i)):v.push(this.ensureSameYConstraint(h,u,n,i));}return v}getAllPaths(e){let n=[],s=new Set;function i(r,o){o.push(r);let a=e.get(r);if(!e.has(r)||!a||a.length===0){let c=new yb(o,void 0);n.push(c);}else for(let c of a)if(!o.includes(c))i(c,[...o]);else {let v=new yb(o,c);n.push(v);}}for(let r of e.keys())s.has(r)||i(r,[]);return n}getFragmentsToConstrain(e){let n=this.getAllPaths(e),s=n.filter((r,o)=>!n.some((a,c)=>c<o&&yb.areEquivalent(r,a)));return s.filter((r,o)=>!s.some((a,c)=>o!==c&&a.isSubpathOf(r)))}applyRelativeOrientationConstraints(e,n){let s=[],i=[],r=this._layoutSpec.constraints.orientation.relative,o=new Set,a=new Map,c=new Map;return r.forEach((v,y)=>{let g=v.directions,h=v.selector,u;try{u=this.evaluator.evaluate(h,{instanceIndex:this.instanceNum});}catch(f){this.recordSelectorError(h,"orientation selector",f);return}if(!this.acceptSelectorResult(u,h,"orientation selector","binary","orientation",y,v))return;u.selectedTwoples().forEach(f=>{let l=f[0],p=f[1],x=this.isNodeHiddenByDirective(l),b=this.isNodeHiddenByDirective(p);if(x||b){for(let S of g){let _=eft(l,p,S);this.recordHiddenNodeConflict(v,_,l,p,x,b);}return}if(v.negated){if(this.shouldAddAlignmentEdge(n,l,p)){let S=`_alignment_${l}_${p}_`;n.setEdge(l,p,S,S);}if(g.length===1){let S=this.negateOrientationDirection(g[0],l,p,e,v);S.length===1?s.push(S[0][0]):i.push(new ys(v,S));}else {let S=[];for(let _ of g){let T=this.negateOrientationDirection(_,l,p,e,v);S.push(...T);}i.push(new ys(v,S));}return}g.forEach(S=>{if(this.shouldAddAlignmentEdge(n,l,p)){let _=`_alignment_${l}_${p}_`;n.setEdge(l,p,_,_);}if(S=="left"){let _=`left:${p}:${l}:${this.minSepWidth}`;!o.has(_)&&!this.hasTransitivePath(a,p,l)&&(o.add(_),this.addToTransitiveGraph(a,p,l),s.push(this.leftConstraint(p,l,this.minSepWidth,e,v)));}else if(S=="above"){let _=`top:${p}:${l}:${this.minSepHeight}`;!o.has(_)&&!this.hasTransitivePath(c,p,l)&&(o.add(_),this.addToTransitiveGraph(c,p,l),s.push(this.topConstraint(p,l,this.minSepHeight,e,v)));}else if(S=="right"){let _=`left:${l}:${p}:${this.minSepWidth}`;!o.has(_)&&!this.hasTransitivePath(a,l,p)&&(o.add(_),this.addToTransitiveGraph(a,l,p),s.push(this.leftConstraint(l,p,this.minSepWidth,e,v)));}else if(S=="below"){let _=`top:${l}:${p}:${this.minSepHeight}`;!o.has(_)&&!this.hasTransitivePath(c,l,p)&&(o.add(_),this.addToTransitiveGraph(c,l,p),s.push(this.topConstraint(l,p,this.minSepHeight,e,v)));}else if(S=="directlyLeft"){let _=`left:${p}:${l}:${this.minSepWidth}`,T=`align-y:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(a,p,l)&&(o.add(_),this.addToTransitiveGraph(a,p,l),s.push(this.leftConstraint(p,l,this.minSepWidth,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameYConstraint(p,l,e,v)));}else if(S=="directlyAbove"){let _=`top:${p}:${l}:${this.minSepHeight}`,T=`align-x:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(c,p,l)&&(o.add(_),this.addToTransitiveGraph(c,p,l),s.push(this.topConstraint(p,l,this.minSepHeight,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameXConstraint(p,l,e,v)));}else if(S=="directlyRight"){let _=`left:${l}:${p}:${this.minSepWidth}`,T=`align-y:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(a,l,p)&&(o.add(_),this.addToTransitiveGraph(a,l,p),s.push(this.leftConstraint(l,p,this.minSepWidth,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameYConstraint(p,l,e,v)));}else if(S=="directlyBelow"){let _=`top:${l}:${p}:${this.minSepHeight}`,T=`align-x:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(c,l,p)&&(o.add(_),this.addToTransitiveGraph(c,l,p),s.push(this.topConstraint(l,p,this.minSepHeight,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameXConstraint(p,l,e,v)));}});});}),{conjunctive:s,disjunctive:i}}negateOrientationDirection(e,n,s,i,r){switch(e){case "left":return [[this.leftConstraint(n,s,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)]];case "right":return [[this.leftConstraint(s,n,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)]];case "above":return [[this.topConstraint(n,s,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)]];case "below":return [[this.topConstraint(s,n,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)]];case "directlyLeft":return [[this.leftConstraint(n,s,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)],[this.topConstraint(n,s,0,i,r)],[this.topConstraint(s,n,0,i,r)]];case "directlyRight":return [[this.leftConstraint(s,n,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)],[this.topConstraint(n,s,0,i,r)],[this.topConstraint(s,n,0,i,r)]];case "directlyAbove":return [[this.topConstraint(n,s,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)],[this.leftConstraint(n,s,0,i,r)],[this.leftConstraint(s,n,0,i,r)]];case "directlyBelow":return [[this.topConstraint(s,n,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)],[this.leftConstraint(n,s,0,i,r)],[this.leftConstraint(s,n,0,i,r)]];default:return []}}hasTransitivePath(e,n,s){let i=e.get(n);if(!i)return false;if(i.has(s))return true;let r=new Set([n]),o=Array.from(i);for(;o.length>0;){let a=o.shift();if(a===s)return true;if(r.has(a))continue;r.add(a);let c=e.get(a);if(c)for(let v of c)r.has(v)||o.push(v);}return false}addToTransitiveGraph(e,n,s){e.has(n)||e.set(n,new Set),e.get(n).add(s);let i=e.get(s)||new Set;for(let[r,o]of e.entries())if(r===n||o.has(n)){o.add(s);for(let a of i)o.add(a);}}applyAlignConstraints(e,n){let s=[],i=[],r=this._layoutSpec.constraints.alignment,o=new Set;return r.forEach((a,c)=>{let v=a.direction,y=a.selector,g;try{g=this.evaluator.evaluate(y,{instanceIndex:this.instanceNum});}catch(u){this.recordSelectorError(y,"align selector",u);return}if(!this.acceptSelectorResult(g,y,"align selector","binary","align",c,a))return;g.selectedTwoples().forEach(u=>{let d=u[0],f=u[1],l=this.isNodeHiddenByDirective(d),p=this.isNodeHiddenByDirective(f);if(l||p){let b=`${d} is ${v==="horizontal"?"horizontally":"vertically"} aligned with ${f}`;this.recordHiddenNodeConflict(a,b,d,f,l,p);return}if(this.shouldAddAlignmentEdge(n,d,f)){let x=`_alignment_${d}_${f}_`;n.setEdge(d,f,x,x);}if(a.negated){let[x,b]=[d,f].sort(),S=`not-align-${v==="horizontal"?"y":"x"}:${x}:${b}`;if(!o.has(S))if(o.add(S),v==="horizontal"){let _=[this.topConstraint(d,f,0,e,a)],T=[this.topConstraint(f,d,0,e,a)];i.push(new ys(a,[_,T]));}else {let _=[this.leftConstraint(d,f,0,e,a)],T=[this.leftConstraint(f,d,0,e,a)];i.push(new ys(a,[_,T]));}return}if(v==="horizontal"){let[x,b]=[d,f].sort(),S=`align-y:${x}:${b}`;o.has(S)||(o.add(S),s.push(this.ensureSameYConstraint(d,f,e,a)));}else if(v==="vertical"){let[x,b]=[d,f].sort(),S=`align-x:${x}:${b}`;o.has(S)||(o.add(S),s.push(this.ensureSameXConstraint(d,f,e,a)));}});}),{conjunctive:s,disjunctive:i}}shouldAddAlignmentEdge(e,n,s){if(this.alignmentEdgeStrategy==="never")return false;let i=this.hasDirectEdgeBetween(e,n,s);return this.alignmentEdgeStrategy==="direct"?!i:i?false:!this.isConnectedViaPath(e,n,s)}hasDirectEdgeBetween(e,n,s){return typeof e.hasEdge=="function"&&(e.hasEdge(n,s)||e.hasEdge(s,n))||(e.inEdges(n)||[]).some(i=>i.v===s)||(e.outEdges(n)||[]).some(i=>i.w===s)||(e.inEdges(s)||[]).some(i=>i.v===n)||(e.outEdges(s)||[]).some(i=>i.w===n)}isConnectedViaPath(e,n,s,i){let r=new Set,o=[n];for(;o.length>0;){let a=o.shift();if(a===s)return true;if(r.has(a))continue;r.add(a);let c=e.outEdges(a)||[],v=e.inEdges(a)||[];for(let y of [...c,...v]){if(i&&(y.v===i.v&&y.w===i.w&&y.name===i.name||y.v===i.w&&y.w===i.v&&y.name===i.name))continue;let g=y.v===a?y.w:y.v;r.has(g)||o.push(g);}}return false}pruneRedundantAlignmentEdges(e){if(this.alignmentEdgeStrategy!=="connected")return;let n=e.edges().filter(i=>{let r=i.name;return r&&r.includes("_alignment_")}),s=[];for(let i of n)this.isConnectedViaPath(e,i.v,i.w,i)&&(e.removeEdge(i.v,i.w,i.name),s.push(i));s.length>0&&console.log(`Pruned ${s.length} redundant alignment edges out of ${n.length} total alignment edges`);}getDisconnectedNodes(e){let n=e.edges().map(a=>a.w),s=e.edges().map(a=>a.v),i=new Set(e.nodes()),r=new Set([...n,...s]);return [...i].filter(a=>!r.has(a))}buildLayoutEdges(e,n,s=[]){let i=new Map,r=new Map;for(let o of s){o.keyNodeId!=null&&i.set(o.name,o.keyNodeId);let a=o.sourceConstraint;a instanceof xh&&(a.connectorLineStyle||a.connectorTextStyle)&&r.set(o.name,{lineStyle:a.connectorLineStyle,textStyle:a.connectorTextStyle});}return e.edges().map(o=>{let a=o.name,c=e.edge(o.v,o.w,a),v=n.find(F=>F.id===o.v),y=n.find(F=>F.id===o.w),g=this.getRelationName(e,o),h=!!a&&a.startsWith("_g_"),u=h?i.get(c)??o.v:void 0,d=u!==void 0?u:o.v,f=u!==void 0?u===o.v?o.w:o.v:o.w,l=h?r.get(c):void 0,p=l?.lineStyle,x=this.resolveEdgeStyleForEdge(g,d,f),b=p?.color??x.lineStyle?.color??this.getEdgeColor(g,d,f,a),S=p?.pattern??x.lineStyle?.pattern??this.getEdgeStyle(g,d,f,a),_=p?.weight??x.lineStyle?.weight??this.getEdgeWeight(g,d,f,a),T=x.showLabel??this.getEdgeShowLabel(g,d,f,a),k=p?.highlight??x.lineStyle?.highlight??this.getEdgeHighlight(g,d,f,a),R=l?.textStyle??this.getInferredEdgeDirective(a)?.textStyle??x.textStyle;return !v||!y||!a?null:{source:v,target:y,label:c,relationName:g,id:a,color:b,style:S,weight:_,showLabel:T,highlight:k,textStyle:R,groupId:h?c:void 0,keyNodeId:u,sourceGroupId:h?u===o.v?void 0:u===o.w?c:void 0:this.inferredEdgeGroupStamps.get(a)?.sourceGroupId,targetGroupId:h?u===o.v?c:void 0:this.inferredEdgeGroupStamps.get(a)?.targetGroupId}}).filter(o=>o!==null)}filterHiddenEdges(e){return e.filter(n=>!n.id.startsWith(this.hideThisEdge))}getNodeFromId(e,n,s){let i=n.find(r=>r.id===e);if(!i)throw new ME(e,s);return i}leftConstraint(e,n,s,i,r){let o=this.getNodeFromId(e,i,r),a=this.getNodeFromId(n,i,r);return {left:o,right:a,minDistance:s,sourceConstraint:r}}topConstraint(e,n,s,i,r){let o=this.getNodeFromId(e,i,r),a=this.getNodeFromId(n,i,r);return {top:o,bottom:a,minDistance:s,sourceConstraint:r}}ensureSameYConstraint(e,n,s,i){let r=this.getNodeFromId(e,s,i),o=this.getNodeFromId(n,s,i);return {axis:"y",node1:r,node2:o,sourceConstraint:i}}ensureSameXConstraint(e,n,s,i){let r=this.getNodeFromId(e,s,i),o=this.getNodeFromId(n,s,i);return {axis:"x",node1:r,node2:o,sourceConstraint:i}}singletonGroup(e){return {name:`${KE.DISCONNECTED_PREFIX}${e}`,nodeIds:[e],keyNodeId:e,showLabel:false}}getNodeDisplayContent(e,n,s,i){let r={},o=n.getAtoms();for(let a of e.nodes()){let v=e.node(a)?.label||a,y=s[a]||{},g=i[a]||{},h=Object.entries(y).sort(([p],[x])=>p.localeCompare(x)),u=h.map(([p,x])=>`${p}: ${x.join(", ")}`),d=h.map(([p])=>rv(g[p]?.size)),f=o.find(p=>p.id===a),l=[];if(f?.labels)for(let p of Object.values(f.labels))l.push(Array.isArray(p)?p.join(", "):String(p));r[a]={label:v,attributeLines:u,attributeFontSizes:d,skolemLines:l};}return r}getNodeSizeMap(e,n){let s={};this._layoutSpec.directives.sizes.forEach((o,a)=>{let c;try{let g=this.evaluator.evaluate(o.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(g,o.selector,"size selector","unary","size",a))return;c=g.selectedAtoms();}catch(g){this.recordSelectorError(o.selector,"size selector",g);return}let v=o.width,y=o.height;c.forEach(g=>{if(s[g]){let h=s[g];if(h.width!==v||h.height!==y)throw new Error(`Size Conflict: "${g}" cannot have multiple sizes: ${JSON.stringify(h)}, ${JSON.stringify({width:v,height:y})}.`)}s[g]={width:v,height:y};});});let r={w:this.DEFAULT_NODE_WIDTH,h:this.DEFAULT_NODE_HEIGHT};for(let o of e.nodes()){if(s[o])continue;let a=n[o],c=a?.label??"",v=a?[...a.attributeLines.map((y,g)=>({text:y,fontSize:a.attributeFontSizes[g]})),...a.skolemLines]:[];s[o]=fK(c,v,{min:r});}return s}getAtomStyleMap(e,n){let s=this._layoutSpec.directives.atomStyles,i={};if(s.length===0)return i;let r=[...e.nodes()],o=new Set(r),a={};s.forEach((c,v)=>{let y;if(!c.selector)y=r;else try{let g=this.evaluator.evaluate(c.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(g,c.selector,"atomStyle selector","unary","atomStyle",v))return;y=g.selectedAtoms();}catch(g){this.recordSelectorError(c.selector,"atomStyle selector",g);return}y.forEach(g=>{o.has(g)&&(a[g]||(a[g]=[]),a[g].push(c));});});for(let c of r){let v=a[c];!v||v.length===0||(i[c]=K4(v,`atom "${c}"`));}return i}getNodeColorMap(e,n,s){let i={},r=new Set,o=this.getSigColors(n),a=[...e.nodes()];return a.forEach(c=>{let v=s[c]?.borderStyle?.color;v&&(i[c]=v,r.add(c));}),a.forEach(c=>{if(!i[c]){let v=this.getMostSpecificType(c,n);i[c]=o[v];}}),{colorMap:i,explicitlyColored:r}}getEdgeColor(e,n,s,i){let r=this.getInferredEdgeDirective(i);if(r?.color)return r.color;let o=this.findEdgeDirective(e,n,s);return o?.color?o.color:"black"}getEdgeStyle(e,n,s,i){let r=this.getInferredEdgeDirective(i),o=rb(r?.style);if(o)return o;let a=this.findEdgeDirective(e,n,s);return rb(a?.style)}getEdgeHighlight(e,n,s,i){let r=this.getInferredEdgeDirective(i);return r?.highlight?r.highlight:this.findEdgeDirective(e,n,s)?.highlight}getEdgeWeight(e,n,s,i){let r=this.getInferredEdgeDirective(i),o=this.normalizeEdgeWeight(r?.weight,"inferred edge");if(o!==void 0)return o;let a=this.findEdgeDirective(e,n,s);return this.normalizeEdgeWeight(a?.weight,"edge")}getEdgeShowLabel(e,n,s,i){return this.findEdgeDirective(e,n,s)?.showLabel}getInferredEdgeDirective(e){let n="_inferred_";return !e||!e.includes(n)?void 0:this._layoutSpec.directives.inferredEdges.find(i=>e.includes(`${n}<:${i.name}`))}edgeDirectiveMatches(e,n,s,i){if(e.field!==n)return false;if(e.selector)try{if(!this.evaluator.evaluate(e.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(s))return !1}catch(r){return this.recordSelectorError(e.selector,"edge selector",r),false}if(e.filter&&i)try{if(!this.evaluator.evaluate(e.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(a=>a[0]===s&&a[1]===i))return !1}catch(r){return this.recordSelectorError(e.filter,"edge filter",r),false}return true}resolveEdgeStyleForEdge(e,n,s){let i=this._layoutSpec.directives.edgeStyles.filter(r=>this.edgeDirectiveMatches(r,e,n,s));return i.length===0?{}:I4(i,`edge ${e} (${n} \u2192 ${s})`)}findEdgeDirective(e,n,s){let i=this._layoutSpec.directives.edgeColors;for(let r of i){if(r.field!==e)continue;let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"edge selector",c),o=false;}if(!o)continue;let a=true;if(r.filter&&s)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"edge filter",c),a=false;}if(o&&a)return r}}normalizeEdgeWeight(e,n){if(e!=null){if(typeof e!="number"||Number.isNaN(e)||e<=0){console.warn(`Ignoring ${n} weight because it is not a positive number: ${e}`);return}return e}}getSigColors(e){let n={},s=e.getTypes(),i=new db(s.length);return s.forEach(r=>{n[r.id]=i.getNextColor();}),n}getFieldTuples(e,n){return Kf(e.getRelations().filter(s=>s.name===n).flatMap(s=>s.tuples)).map(s=>s.atoms)}getFieldTuplesForSourceAndTarget(e,n,s,i){return this.getFieldTuples(e,n).filter(a=>{let c=a.length;return c<1?false:a[0]===s&&a[c-1]===i})}addinferredEdges(e){let n="_inferred_";this._layoutSpec.directives.inferredEdges.forEach((s,i)=>{if(s.draw)return;let r;try{r=this.evaluator.evaluate(s.selector,{instanceIndex:this.instanceNum});}catch(c){this.recordSelectorError(s.selector,"inferredEdge selector",c);return}if(!this.acceptSelectorResult(r,s.selector,"inferredEdge selector","any","inferredEdge",i))return;let o=r.selectedTuplesAll(),a=`${n}<:${s.name}`;o.forEach(c=>{let v=c.length,y=c[0],g=c[v-1],h=s.name;if(v>2){let f=c.slice(1,v-1).map(l=>e.node(l)?.label||l).join(",");h=`${h}[${f}]`;}let u=c.join("->"),d=`${a}<:${u}`;e.setEdge(y,g,h,d);});});}addDrawInferredEdges(e,n){let s="_inferred_";this._layoutSpec.directives.inferredEdges.forEach((i,r)=>{if(!i.draw)return;let o=i.draw,a=[...new Set([o.source,o.target])].filter(h=>h!==null),c=h=>n.filter(u=>u.sourceConstraint!==void 0&&u.sourceConstraint.name===h);for(let h of a){let u=c(h),d=u.filter(f=>f.keyed!==true);if(d.length>1)throw new Error(`inferredEdge '${i.name}': draw endpoint '${h}' is ambiguous \u2014 ${d.length} group constraints named '${h}' each build a single (unkeyed) group. Rename one of them.`);if(d.length===1&&u.length>1)throw new Error(`inferredEdge '${i.name}': draw endpoint '${h}' is ambiguous \u2014 '${h}' names both a keyed group constraint (one group per key) and a single-group (unary) constraint. Rename one of them.`)}for(let h of a)if(c(h).length===0){console.warn(`[spytial] inferredEdge '${i.name}': skipping \u2014 no '${h}' groups exist in this instance.`);return}let v;try{v=this.evaluator.evaluate(i.selector,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(i.selector,"inferredEdge selector",h);return}if(!this.acceptSelectorResult(v,i.selector,"inferredEdge selector","any","inferredEdge",r))return;let y;v.maxArity()>1?y=v.selectedTuplesAll():y=v.selectedAtoms().map(h=>[h]);let g=`${s}<:${i.name}`;y.forEach(h=>{let u=h.length,d=h[0],f=h[u-1],l=this.resolveDrawEnd(e,n,o.source,d,i.name),p=this.resolveDrawEnd(e,n,o.target,f,i.name);if(!l||!p)return;let x=i.name;if(u>2){let _=h.slice(1,u-1).map(T=>e.node(T)?.label||T).join(",");x=`${x}[${_}]`;}let b=h.join("->"),S=`${g}<:${b}`;e.setEdge(l.anchor,p.anchor,x,S),(l.groupId||p.groupId)&&this.inferredEdgeGroupStamps.set(S,{sourceGroupId:l.groupId,targetGroupId:p.groupId});});});}resolveDrawEnd(e,n,s,i,r){if(s===null)return e.hasNode(i)?{anchor:i}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 endpoint atom '${i}' is not in the graph (hidden or projected away).`),null);let o=n.filter(g=>g.sourceConstraint!==void 0&&g.sourceConstraint.name===s),a=o.find(g=>g.keyed!==true);if(a){let g=a.nodeIds.find(h=>e.hasNode(h));return g?{anchor:g,groupId:a.name}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 group '${a.name}' has no members present in the graph to anchor on.`),null)}let c=o.filter(g=>g.keyed===true&&g.keyNodeId===i);if(c.length===0)return console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 atom '${i}' does not key any '${s}' group in this instance.`),null;if(c.length>1)throw new Error(`inferredEdge '${r}': ambiguous draw endpoint \u2014 atom '${i}' keys ${c.length} groups named '${s}[\u2026]'. Rename one of the group constraints.`);let v=c[0],y=v.nodeIds.find(g=>e.hasNode(g));return y?{anchor:y,groupId:v.name}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 group '${v.name}' has no members present in the graph to anchor on.`),null)}};KE.DISCONNECTED_PREFIX="_d_";exports.LayoutInstance=KE;});function NK(t,e){let n=new jE;for(let[f,l]of e)n.union(f,l);let s=new Set;for(let f of t)s.add(f.before),s.add(f.after);for(let[f,l]of e)s.add(f),s.add(l);if(s.size===0)return {raw:new Map,component:new Map};let i=new Map,r=new Map,o=new Set;for(let f of s)o.add(n.find(f));for(let f of o)i.set(f,[]),r.set(f,0);for(let f of t){let l=n.find(f.before),p=n.find(f.after);if(l===p)return null;i.get(l).push({to:p,gap:f.gap}),r.set(p,r.get(p)+1);}let a=[];for(let[f,l]of r)l===0&&a.push(f);let c=new Map;for(let f of o)c.set(f,0);let v=0;for(;a.length>0;){let f=a.shift();v++;let l=c.get(f);for(let{to:p,gap:x}of i.get(f)){c.set(p,Math.max(c.get(p),l+x));let b=r.get(p)-1;r.set(p,b),b===0&&a.push(p);}}if(v<o.size)return null;let y=new jE;for(let f of t)y.union(f.before,f.after);for(let[f,l]of e)y.union(f,l);let g=new Map,h=0,u=new Map,d=new Map;for(let f of s){u.set(f,c.get(n.find(f)));let l=y.find(f);g.has(l)||g.set(l,h++),d.set(f,g.get(l));}return {raw:u,component:d}}function RK(t,e,n,s){let i=(s==="x"?t.width:t.height)??100,r=(s==="x"?e.width:e.height)??100,o=i/2+r/2+n,a=Math.min(Math.max(i,r)*.1,20);return o+a}function yft(t){let e=[],n=[];return t.forEach((s,i)=>(i%2===0?e:n).push(s)),n.reverse(),[...e,...n]}function mft(t,e){let n=t.map(l=>l.id),s=new Map(t.map(l=>[l.id,l])),i=new Map,r=new Map;for(let l of n)i.set(l,[]),r.set(l,0);let o=new Set;for(let[l,p]of e){if(l===p||!i.has(l)||!i.has(p))continue;let x=`${l}\0${p}`;o.has(x)||(o.add(x),i.get(l).push(p),r.set(p,r.get(p)+1));}let a=new Map;for(let l of n)a.set(l,[]);let c=new Set,v=[],y=l=>{c.add(l),v.push(l);let p=[l];for(;p.length>0;){let x=p.shift();for(let b of i.get(x))c.has(b)||(c.add(b),a.get(x).push(b),p.push(b));}};for(let l of n)(r.get(l)??0)===0&&!c.has(l)&&y(l);for(let l of n)c.has(l)||y(l);let g=new Map,h=new Map,u=new Map,d=new Map,f=l=>{let p=d.get(l);return p===void 0&&(p=d.size,d.set(l,p)),p};for(let l of v){let p=[{id:l,childIndex:0}];for(;p.length>0;){let x=p[p.length-1],b=a.get(x.id);if(x.childIndex<b.length){p.push({id:b[x.childIndex],childIndex:0}),x.childIndex++;continue}p.pop();let S=b.map(R=>g.get(R)).sort((R,I)=>R-I),_=s.get(x.id)?.mostSpecificType??"";g.set(x.id,f(`${_}(${S.join(",")})`)),h.set(x.id,b.reduce((R,I)=>R+h.get(I),1));let T=s.get(x.id)?.width??100,k=b.reduce((R,I)=>R+u.get(I),0)+UE*Math.max(0,b.length-1);u.set(x.id,Math.max(T,k));}}return {children:a,roots:v,hash:g,size:h,width:u}}function LK(t,e,n){let s=t.nodes;if(s.length===0)return null;let i=[],r=[],o=[],a=[];for(let B of t.constraints)ii(B)?i.push({before:B.left.id,after:B.right.id,gap:RK(B.left,B.right,B.minDistance,"x")}):ni(B)?r.push({before:B.top.id,after:B.bottom.id,gap:RK(B.top,B.bottom,B.minDistance,"y")}):Fn(B)&&(B.axis==="x"?o.push([B.node1.id,B.node2.id]):a.push([B.node1.id,B.node2.id]));let c=NK(i,o),v=NK(r,a);if(c===null||v===null)return null;let y=t.edges.map(B=>[B.source.id,B.target.id]),g=mft(s,y),h=new Map,u=new Map,d=B=>{let P=B.filter(G=>c.raw.has(G)),K=B.filter(G=>!c.raw.has(G));return P.sort((G,V)=>c.raw.get(G)-c.raw.get(V)),K.sort((G,V)=>{let Q=g.hash.get(G)-g.hash.get(V);if(Q!==0)return Q;let rt=g.size.get(V)-g.size.get(G);return rt!==0?rt:G<V?-1:1}),[...P,...yft(K)]},f=(B,P)=>{let K=c.raw.get(B),G=c.raw.get(P);return K!==void 0&&G!==void 0&&c.component.get(B)===c.component.get(P)&&Math.abs(K-G)>gft},l=0;for(let B of g.roots){let P=g.width.get(B),K=l+P/2;l+=P+UE*2;let G=[{id:B,centerX:K,y:0}];for(;G.length>0;){let{id:V,centerX:Q,y:rt}=G.pop();h.set(V,Q),u.set(V,rt);let ht=d(g.children.get(V));if(ht.length===0)continue;let it=ht.reduce((q,nt)=>q+g.width.get(nt),0)+UE*Math.max(0,ht.length-1),H=Q-it/2;for(let q of ht){let nt=g.width.get(q);G.push({id:q,centerX:H+nt/2,y:rt+(f(V,q)?0:dft)}),H+=nt+UE;}}}let p=(B,P)=>{let K=new Map;for(let[V,Q]of B.raw){let rt=B.component.get(V),ht=K.get(rt)??{delta:0,count:0};ht.delta+=(P.get(V)??0)-Q,ht.count+=1,K.set(rt,ht);}let G=new Map;for(let[V,Q]of B.raw){let{delta:rt,count:ht}=K.get(B.component.get(V));G.set(V,Q+rt/ht);}return G},x=p(c,h),b=p(v,u),S=new Map,_=1/0,T=-1/0,k=1/0,R=-1/0;for(let B of s){let P=x.get(B.id)??h.get(B.id)??0,K=b.get(B.id)??u.get(B.id)??0;S.set(B.id,{x:P,y:K}),_=Math.min(_,P),T=Math.max(T,P),k=Math.min(k,K),R=Math.max(R,K);}let I=e/2-(_+T)/2,F=n/2-(k+R)/2;for(let B of S.values())B.x+=I,B.y+=F;return S}function IK(t){return t.constraints.some(e=>ii(e)||ni(e)||Fn(e))}var dft,UE,gft,jE,PK=Ie(()=>{Ll();dft=130,UE=40,gft=.5,jE=class{constructor(){this.parent=new Map;}find(e){let n=this.parent.get(e)??e;for(;n!==(this.parent.get(n)??n);)n=this.parent.get(n)??n;let s=e;for(;s!==n;){let i=this.parent.get(s)??s;this.parent.set(s,n),s=i;}return n}union(e,n){let s=this.find(e),i=this.find(n);s!==i&&this.parent.set(s,i);}};});var Fl=qt((h3t,DK)=>{var HE;if(typeof Ma=="function")try{HE=kf();}catch{}HE||(HE=window.graphlib);DK.exports=HE;});var MK=qt((p3t,kK)=>{var vft=LA(),xft=1,_ft=4;function bft(t){return vft(t,xft|_ft)}kK.exports=bft;});var mb=qt((d3t,KK)=>{var Tft=ny(),Eft=lh(),Sft=Xx(),Oft=Mu();function Aft(t,e,n){if(!Oft(n))return false;var s=typeof e;return (s=="number"?Eft(n)&&Sft(e,n.length):s=="string"&&e in n)?Tft(n[e],t):false}KK.exports=Aft;});var UK=qt((g3t,BK)=>{var wft=a_(),Cft=ny(),Nft=mb(),Rft=cd(),FK=Object.prototype,Lft=FK.hasOwnProperty,Ift=wft(function(t,e){t=Object(t);var n=-1,s=e.length,i=s>2?e[2]:void 0;for(i&&Nft(e[0],e[1],i)&&(s=1);++n<s;)for(var r=e[n],o=Rft(r),a=-1,c=o.length;++a<c;){var v=o[a],y=t[v];(y===void 0||Cft(y,FK[v])&&!Lft.call(t,v))&&(t[v]=r[v]);}return t});BK.exports=Ift;});var HK=qt((y3t,jK)=>{var Pft=ch(),Dft=lh(),kft=Df();function Mft(t){return function(e,n,s){var i=Object(e);if(!Dft(e)){var r=Pft(n,3);e=kft(e),n=function(a){return r(i[a],a,i)};}var o=t(e,n,s);return o>-1?i[r?e[o]:o]:void 0}}jK.exports=Mft;});var qK=qt((m3t,GK)=>{var Kft=/\s/;function Fft(t){for(var e=t.length;e--&&Kft.test(t.charAt(e)););return e}GK.exports=Fft;});var $K=qt((v3t,zK)=>{var Bft=qK(),Uft=/^\s+/;function jft(t){return t&&t.slice(0,Bft(t)+1).replace(Uft,"")}zK.exports=jft;});var XK=qt((x3t,WK)=>{var Hft=$K(),VK=Mu(),Gft=uy(),YK=NaN,qft=/^[-+]0x[0-9a-f]+$/i,zft=/^0b[01]+$/i,$ft=/^0o[0-7]+$/i,Vft=parseInt;function Yft(t){if(typeof t=="number")return t;if(Gft(t))return YK;if(VK(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=VK(e)?e+"":e;}if(typeof t!="string")return t===0?t:+t;t=Hft(t);var n=zft.test(t);return n||$ft.test(t)?Vft(t.slice(2),n?2:8):qft.test(t)?YK:+t}WK.exports=Yft;});var iN=qt((_3t,JK)=>{var Wft=XK(),QK=1/0,Xft=17976931348623157e292;function Qft(t){if(!t)return t===0?t:0;if(t=Wft(t),t===QK||t===-QK){var e=t<0?-1:1;return e*Xft}return t===t?t:0}JK.exports=Qft;});var t7=qt((b3t,ZK)=>{var Jft=iN();function Zft(t){var e=Jft(t),n=e%1;return e===e?n?e-n:e:0}ZK.exports=Zft;});var r7=qt((T3t,e7)=>{var tpt=iw(),ept=ch(),rpt=t7(),npt=Math.max;function ipt(t,e,n){var s=t==null?0:t.length;if(!s)return -1;var i=n==null?0:rpt(n);return i<0&&(i=npt(s+i,0)),tpt(t,ept(e,3),i)}e7.exports=ipt;});var i7=qt((E3t,n7)=>{var opt=HK(),spt=r7(),apt=opt(spt);n7.exports=apt;});var oN=qt((S3t,o7)=>{var upt=dT();function lpt(t){var e=t==null?0:t.length;return e?upt(t,1):[]}o7.exports=lpt;});var a7=qt((O3t,s7)=>{var cpt=uT(),hpt=IA(),fpt=cd();function ppt(t,e){return t==null?t:cpt(t,hpt(e),fpt)}s7.exports=ppt;});var l7=qt((A3t,u7)=>{function dpt(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}u7.exports=dpt;});var h7=qt((w3t,c7)=>{var gpt=Vx(),ypt=lT(),mpt=ch();function vpt(t,e){var n={};return e=mpt(e,3),ypt(t,function(s,i,r){gpt(n,i,e(s,i,r));}),n}c7.exports=vpt;});var GE=qt((C3t,f7)=>{var xpt=uy();function _pt(t,e,n){for(var s=-1,i=t.length;++s<i;){var r=t[s],o=e(r);if(o!=null&&(a===void 0?o===o&&!xpt(o):n(o,a)))var a=o,c=r;}return c}f7.exports=_pt;});var d7=qt((N3t,p7)=>{function bpt(t,e){return t>e}p7.exports=bpt;});var y7=qt((R3t,g7)=>{var Tpt=GE(),Ept=d7(),Spt=hd();function Opt(t){return t&&t.length?Tpt(t,Spt,Ept):void 0}g7.exports=Opt;});var sN=qt((L3t,m7)=>{var Apt=Vx(),wpt=ny();function Cpt(t,e,n){(n!==void 0&&!wpt(t[e],n)||n===void 0&&!(e in t))&&Apt(t,e,n);}m7.exports=Cpt;});var _7=qt((I3t,x7)=>{var Npt=ud(),Rpt=r_(),Lpt=dc(),Ipt="[object Object]",Ppt=Function.prototype,Dpt=Object.prototype,v7=Ppt.toString,kpt=Dpt.hasOwnProperty,Mpt=v7.call(Object);function Kpt(t){if(!Lpt(t)||Npt(t)!=Ipt)return false;var e=Rpt(t);if(e===null)return true;var n=kpt.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&v7.call(n)==Mpt}x7.exports=Kpt;});var aN=qt((P3t,b7)=>{function Fpt(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}b7.exports=Fpt;});var E7=qt((D3t,T7)=>{var Bpt=c0(),Upt=cd();function jpt(t){return Bpt(t,Upt(t))}T7.exports=jpt;});var N7=qt((k3t,C7)=>{var S7=sN(),Hpt=dA(),Gpt=CA(),qpt=gA(),zpt=RA(),O7=h0(),A7=Do(),$pt=sw(),Vpt=oy(),Ypt=s0(),Wpt=Mu(),Xpt=_7(),Qpt=d0(),w7=aN(),Jpt=E7();function Zpt(t,e,n,s,i,r,o){var a=w7(t,n),c=w7(e,n),v=o.get(c);if(v){S7(t,n,v);return}var y=r?r(a,c,n+"",t,e,o):void 0,g=y===void 0;if(g){var h=A7(c),u=!h&&Vpt(c),d=!h&&!u&&Qpt(c);y=c,h||u||d?A7(a)?y=a:$pt(a)?y=qpt(a):u?(g=false,y=Hpt(c,true)):d?(g=false,y=Gpt(c,true)):y=[]:Xpt(c)||O7(c)?(y=a,O7(a)?y=Jpt(a):(!Wpt(a)||Ypt(a))&&(y=zpt(c))):g=false;}g&&(o.set(c,y),i(y,c,s,r,o),o.delete(c)),S7(t,n,y);}C7.exports=Zpt;});var I7=qt((M3t,L7)=>{var tdt=$x(),edt=sN(),rdt=uT(),ndt=N7(),idt=Mu(),odt=cd(),sdt=aN();function R7(t,e,n,s,i){t!==e&&rdt(e,function(r,o){if(i||(i=new tdt),idt(r))ndt(t,e,o,n,R7,s,i);else {var a=s?s(sdt(t,o),r,o+"",t,e,i):void 0;a===void 0&&(a=r),edt(t,o,a);}},odt);}L7.exports=R7;});var D7=qt((K3t,P7)=>{var adt=a_(),udt=mb();function ldt(t){return adt(function(e,n){var s=-1,i=n.length,r=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(r=t.length>3&&typeof r=="function"?(i--,r):void 0,o&&udt(n[0],n[1],o)&&(r=i<3?void 0:r,i=1),e=Object(e);++s<i;){var a=n[s];a&&t(e,a,s,r);}return e})}P7.exports=ldt;});var M7=qt((F3t,k7)=>{var cdt=I7(),hdt=D7(),fdt=hdt(function(t,e,n){cdt(t,e,n);});k7.exports=fdt;});var uN=qt((B3t,K7)=>{function pdt(t,e){return t<e}K7.exports=pdt;});var B7=qt((U3t,F7)=>{var ddt=GE(),gdt=uN(),ydt=hd();function mdt(t){return t&&t.length?ddt(t,ydt,gdt):void 0}F7.exports=mdt;});var j7=qt((j3t,U7)=>{var vdt=GE(),xdt=ch(),_dt=uN();function bdt(t,e){return t&&t.length?vdt(t,xdt(e,2),_dt):void 0}U7.exports=bdt;});var G7=qt((H3t,H7)=>{var Tdt=wl(),Edt=function(){return Tdt.Date.now()};H7.exports=Edt;});var $7=qt((G3t,z7)=>{var Sdt=Yx(),Odt=o_(),Adt=Xx(),q7=Mu(),wdt=m0();function Cdt(t,e,n,s){if(!q7(t))return t;e=Odt(e,t);for(var i=-1,r=e.length,o=r-1,a=t;a!=null&&++i<r;){var c=wdt(e[i]),v=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=o){var y=a[c];v=s?s(y,c,a):void 0,v===void 0&&(v=q7(y)?y:Adt(e[i+1])?[]:{});}Sdt(a,c,v),a=a[c];}return t}z7.exports=Cdt;});var Y7=qt((q3t,V7)=>{var Ndt=s_(),Rdt=$7(),Ldt=o_();function Idt(t,e,n){for(var s=-1,i=e.length,r={};++s<i;){var o=e[s],a=Ndt(t,o);n(a,o)&&Rdt(r,Ldt(o,t),a);}return r}V7.exports=Idt;});var X7=qt((z3t,W7)=>{var Pdt=Y7(),Ddt=$A();function kdt(t,e){return Pdt(t,e,function(n,s){return Ddt(t,s)})}W7.exports=kdt;});var J7=qt(($3t,Q7)=>{var Mdt=oN(),Kdt=rw(),Fdt=nw();function Bdt(t){return Fdt(Kdt(t,void 0,Mdt),t+"")}Q7.exports=Bdt;});var tF=qt((V3t,Z7)=>{var Udt=X7(),jdt=J7(),Hdt=jdt(function(t,e){return t==null?{}:Udt(t,e)});Z7.exports=Hdt;});var rF=qt((Y3t,eF)=>{var Gdt=Math.ceil,qdt=Math.max;function zdt(t,e,n,s){for(var i=-1,r=qdt(Gdt((e-t)/(n||1)),0),o=Array(r);r--;)o[s?r:++i]=t,t+=n;return o}eF.exports=zdt;});var iF=qt((W3t,nF)=>{var $dt=rF(),Vdt=mb(),lN=iN();function Ydt(t){return function(e,n,s){return s&&typeof s!="number"&&Vdt(e,n,s)&&(n=s=void 0),e=lN(e),n===void 0?(n=e,e=0):n=lN(n),s=s===void 0?e<n?1:-1:lN(s),$dt(e,n,s,t)}}nF.exports=Ydt;});var sF=qt((X3t,oF)=>{var Wdt=iF(),Xdt=Wdt();oF.exports=Xdt;});var uF=qt((Q3t,aF)=>{function Qdt(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}aF.exports=Qdt;});var hF=qt((J3t,cF)=>{var lF=uy();function Jdt(t,e){if(t!==e){var n=t!==void 0,s=t===null,i=t===t,r=lF(t),o=e!==void 0,a=e===null,c=e===e,v=lF(e);if(!a&&!v&&!r&&t>e||r&&o&&c&&!a&&!v||s&&o&&c||!n&&c||!i)return 1;if(!s&&!r&&!v&&t<e||v&&n&&i&&!s&&!r||a&&n&&i||!o&&i||!c)return -1}return 0}cF.exports=Jdt;});var pF=qt((Z3t,fF)=>{var Zdt=hF();function tgt(t,e,n){for(var s=-1,i=t.criteria,r=e.criteria,o=i.length,a=n.length;++s<o;){var c=Zdt(i[s],r[s]);if(c){if(s>=a)return c;var v=n[s];return c*(v=="desc"?-1:1)}}return t.index-e.index}fF.exports=tgt;});var gF=qt((tMt,dF)=>{var cN=i_(),egt=s_(),rgt=ch(),ngt=QA(),igt=uF(),ogt=Qx(),sgt=pF(),agt=hd(),ugt=Do();function lgt(t,e,n){e.length?e=cN(e,function(r){return ugt(r)?function(o){return egt(o,r.length===1?r[0]:r)}:r}):e=[agt];var s=-1;e=cN(e,ogt(rgt));var i=ngt(t,function(r,o,a){var c=cN(e,function(v){return v(r)});return {criteria:c,index:++s,value:r}});return igt(i,function(r,o){return sgt(r,o,n)})}dF.exports=lgt;});var vF=qt((eMt,mF)=>{var cgt=dT(),hgt=gF(),fgt=a_(),yF=mb(),pgt=fgt(function(t,e){if(t==null)return [];var n=e.length;return n>1&&yF(t,e[0],e[1])?e=[]:n>2&&yF(e[0],e[1],e[2])&&(e=[e[0]]),hgt(t,cgt(e,1),[])});mF.exports=pgt;});var _F=qt((rMt,xF)=>{var dgt=qA(),ggt=0;function ygt(t){var e=++ggt;return dgt(t)+e}xF.exports=ygt;});var TF=qt((nMt,bF)=>{function mgt(t,e,n){for(var s=-1,i=t.length,r=e.length,o={};++s<i;){var a=s<r?e[s]:void 0;n(o,t[s],a);}return o}bF.exports=mgt;});var SF=qt((iMt,EF)=>{var vgt=Yx(),xgt=TF();function _gt(t,e){return xgt(t||[],e||[],vgt)}EF.exports=_gt;});var no=qt((oMt,OF)=>{var qE;if(typeof Ma=="function")try{qE={cloneDeep:MK(),constant:aT(),defaults:UK(),each:DA(),filter:YA(),find:i7(),flatten:oN(),forEach:PA(),forIn:a7(),has:WA(),isUndefined:XA(),last:l7(),map:JA(),mapValues:h7(),max:y7(),merge:M7(),min:B7(),minBy:j7(),now:G7(),pick:tF(),range:sF(),reduce:ZA(),sortBy:vF(),uniqueId:_F(),values:aw(),zipObject:SF()};}catch{}qE||(qE=window._);OF.exports=qE;});var CF=qt((aMt,wF)=>{wF.exports=zE;function zE(){var t={};t._next=t._prev=t,this._sentinel=t;}zE.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return AF(e),e};zE.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&AF(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e;};zE.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,bgt)),n=n._prev;return "["+t.join(", ")+"]"};function AF(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev;}function bgt(t,e){if(t!=="_next"&&t!=="_prev")return e}});var RF=qt((uMt,NF)=>{var qf=no(),Tgt=Fl().Graph,Egt=CF();NF.exports=Ogt;var Sgt=qf.constant(1);function Ogt(t,e){if(t.nodeCount()<=1)return [];var n=wgt(t,e||Sgt),s=Agt(n.graph,n.buckets,n.zeroIdx);return qf.flatten(qf.map(s,function(i){return t.outEdges(i.v,i.w)}),true)}function Agt(t,e,n){for(var s=[],i=e[e.length-1],r=e[0],o;t.nodeCount();){for(;o=r.dequeue();)hN(t,e,n,o);for(;o=i.dequeue();)hN(t,e,n,o);if(t.nodeCount()){for(var a=e.length-2;a>0;--a)if(o=e[a].dequeue(),o){s=s.concat(hN(t,e,n,o,true));break}}}return s}function hN(t,e,n,s,i){var r=i?[]:void 0;return qf.forEach(t.inEdges(s.v),function(o){var a=t.edge(o),c=t.node(o.v);i&&r.push({v:o.v,w:o.w}),c.out-=a,fN(e,n,c);}),qf.forEach(t.outEdges(s.v),function(o){var a=t.edge(o),c=o.w,v=t.node(c);v.in-=a,fN(e,n,v);}),t.removeNode(s.v),r}function wgt(t,e){var n=new Tgt,s=0,i=0;qf.forEach(t.nodes(),function(a){n.setNode(a,{v:a,in:0,out:0});}),qf.forEach(t.edges(),function(a){var c=n.edge(a.v,a.w)||0,v=e(a),y=c+v;n.setEdge(a.v,a.w,y),i=Math.max(i,n.node(a.v).out+=v),s=Math.max(s,n.node(a.w).in+=v);});var r=qf.range(i+s+3).map(function(){return new Egt}),o=s+1;return qf.forEach(n.nodes(),function(a){fN(r,o,n.node(a));}),{graph:n,buckets:r,zeroIdx:o}}function fN(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n);}});var IF=qt((lMt,LF)=>{var Ny=no(),Cgt=RF();LF.exports={run:Ngt,undo:Lgt};function Ngt(t){var e=t.graph().acyclicer==="greedy"?Cgt(t,n(t)):Rgt(t);Ny.forEach(e,function(s){var i=t.edge(s);t.removeEdge(s),i.forwardName=s.name,i.reversed=true,t.setEdge(s.w,s.v,i,Ny.uniqueId("rev"));});function n(s){return function(i){return s.edge(i).weight}}}function Rgt(t){var e=[],n={},s={};function i(r){Ny.has(s,r)||(s[r]=true,n[r]=true,Ny.forEach(t.outEdges(r),function(o){Ny.has(n,o.w)?e.push(o):i(o.w);}),delete n[r]);}return Ny.forEach(t.nodes(),i),e}function Lgt(t){Ny.forEach(t.edges(),function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var s=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,s);}});}});var Ua=qt((cMt,MF)=>{var bi=no(),PF=Fl().Graph;MF.exports={addDummyNode:DF,simplify:Igt,asNonCompoundGraph:Pgt,successorWeights:Dgt,predecessorWeights:kgt,intersectRect:Mgt,buildLayerMatrix:Kgt,normalizeRanks:Fgt,removeEmptyRanks:Bgt,addBorderNode:Ugt,maxRank:kF,partition:jgt,time:Hgt,notime:Ggt};function DF(t,e,n,s){var i;do i=bi.uniqueId(s);while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function Igt(t){var e=new PF().setGraph(t.graph());return bi.forEach(t.nodes(),function(n){e.setNode(n,t.node(n));}),bi.forEach(t.edges(),function(n){var s=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:s.weight+i.weight,minlen:Math.max(s.minlen,i.minlen)});}),e}function Pgt(t){var e=new PF({multigraph:t.isMultigraph()}).setGraph(t.graph());return bi.forEach(t.nodes(),function(n){t.children(n).length||e.setNode(n,t.node(n));}),bi.forEach(t.edges(),function(n){e.setEdge(n,t.edge(n));}),e}function Dgt(t){var e=bi.map(t.nodes(),function(n){var s={};return bi.forEach(t.outEdges(n),function(i){s[i.w]=(s[i.w]||0)+t.edge(i).weight;}),s});return bi.zipObject(t.nodes(),e)}function kgt(t){var e=bi.map(t.nodes(),function(n){var s={};return bi.forEach(t.inEdges(n),function(i){s[i.v]=(s[i.v]||0)+t.edge(i).weight;}),s});return bi.zipObject(t.nodes(),e)}function Mgt(t,e){var n=t.x,s=t.y,i=e.x-n,r=e.y-s,o=t.width/2,a=t.height/2;if(!i&&!r)throw new Error("Not possible to find intersection inside of the rectangle");var c,v;return Math.abs(r)*o>Math.abs(i)*a?(r<0&&(a=-a),c=a*i/r,v=a):(i<0&&(o=-o),c=o,v=o*r/i),{x:n+c,y:s+v}}function Kgt(t){var e=bi.map(bi.range(kF(t)+1),function(){return []});return bi.forEach(t.nodes(),function(n){var s=t.node(n),i=s.rank;bi.isUndefined(i)||(e[i][s.order]=n);}),e}function Fgt(t){var e=bi.min(bi.map(t.nodes(),function(n){return t.node(n).rank}));bi.forEach(t.nodes(),function(n){var s=t.node(n);bi.has(s,"rank")&&(s.rank-=e);});}function Bgt(t){var e=bi.min(bi.map(t.nodes(),function(r){return t.node(r).rank})),n=[];bi.forEach(t.nodes(),function(r){var o=t.node(r).rank-e;n[o]||(n[o]=[]),n[o].push(r);});var s=0,i=t.graph().nodeRankFactor;bi.forEach(n,function(r,o){bi.isUndefined(r)&&o%i!==0?--s:s&&bi.forEach(r,function(a){t.node(a).rank+=s;});});}function Ugt(t,e,n,s){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=s),DF(t,"border",i,e)}function kF(t){return bi.max(bi.map(t.nodes(),function(e){var n=t.node(e).rank;if(!bi.isUndefined(n))return n}))}function jgt(t,e){var n={lhs:[],rhs:[]};return bi.forEach(t,function(s){e(s)?n.lhs.push(s):n.rhs.push(s);}),n}function Hgt(t,e){var n=bi.now();try{return e()}finally{console.log(t+" time: "+(bi.now()-n)+"ms");}}function Ggt(t,e){return e()}});var BF=qt((hMt,FF)=>{var KF=no(),qgt=Ua();FF.exports={run:zgt,undo:Vgt};function zgt(t){t.graph().dummyChains=[],KF.forEach(t.edges(),function(e){$gt(t,e);});}function $gt(t,e){var n=e.v,s=t.node(n).rank,i=e.w,r=t.node(i).rank,o=e.name,a=t.edge(e),c=a.labelRank;if(r!==s+1){t.removeEdge(e);var v,y,g;for(g=0,++s;s<r;++g,++s)a.points=[],y={width:0,height:0,edgeLabel:a,edgeObj:e,rank:s},v=qgt.addDummyNode(t,"edge",y,"_d"),s===c&&(y.width=a.width,y.height=a.height,y.dummy="edge-label",y.labelpos=a.labelpos),t.setEdge(n,v,{weight:a.weight},o),g===0&&t.graph().dummyChains.push(v),n=v;t.setEdge(n,i,{weight:a.weight},o);}}function Vgt(t){KF.forEach(t.graph().dummyChains,function(e){var n=t.node(e),s=n.edgeLabel,i;for(t.setEdge(n.edgeObj,s);n.dummy;)i=t.successors(e)[0],t.removeNode(e),s.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(s.x=n.x,s.y=n.y,s.width=n.width,s.height=n.height),e=i,n=t.node(e);});}});var vb=qt((fMt,UF)=>{var $E=no();UF.exports={longestPath:Ygt,slack:Wgt};function Ygt(t){var e={};function n(s){var i=t.node(s);if($E.has(e,s))return i.rank;e[s]=true;var r=$E.min($E.map(t.outEdges(s),function(o){return n(o.w)-t.edge(o).minlen}));return (r===Number.POSITIVE_INFINITY||r===void 0||r===null)&&(r=0),i.rank=r}$E.forEach(t.sources(),n);}function Wgt(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}});var pN=qt((pMt,jF)=>{var VE=no(),Xgt=Fl().Graph,YE=vb().slack;jF.exports=Qgt;function Qgt(t){var e=new Xgt({directed:false}),n=t.nodes()[0],s=t.nodeCount();e.setNode(n,{});for(var i,r;Jgt(e,t)<s;)i=Zgt(e,t),r=e.hasNode(i.v)?YE(t,i):-YE(t,i),tyt(e,t,r);return e}function Jgt(t,e){function n(s){VE.forEach(e.nodeEdges(s),function(i){var r=i.v,o=s===r?i.w:r;!t.hasNode(o)&&!YE(e,i)&&(t.setNode(o,{}),t.setEdge(s,o,{}),n(o));});}return VE.forEach(t.nodes(),n),t.nodeCount()}function Zgt(t,e){return VE.minBy(e.edges(),function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return YE(e,n)})}function tyt(t,e,n){VE.forEach(t.nodes(),function(s){e.node(s).rank+=n;});}});var WF=qt((dMt,YF)=>{var zf=no(),eyt=pN(),ryt=vb().slack,nyt=vb().longestPath,iyt=Fl().alg.preorder,oyt=Fl().alg.postorder,syt=Ua().simplify;YF.exports=Ry;Ry.initLowLimValues=gN;Ry.initCutValues=dN;Ry.calcCutValue=GF;Ry.leaveEdge=zF;Ry.enterEdge=$F;Ry.exchangeEdges=VF;function Ry(t){t=syt(t),nyt(t);var e=eyt(t);gN(e),dN(e,t);for(var n,s;n=zF(e);)s=$F(e,t,n),VF(e,t,n,s);}function dN(t,e){var n=oyt(t,t.nodes());n=n.slice(0,n.length-1),zf.forEach(n,function(s){ayt(t,e,s);});}function ayt(t,e,n){var s=t.node(n),i=s.parent;t.edge(n,i).cutvalue=GF(t,e,n);}function GF(t,e,n){var s=t.node(n),i=s.parent,r=true,o=e.edge(n,i),a=0;return o||(r=false,o=e.edge(i,n)),a=o.weight,zf.forEach(e.nodeEdges(n),function(c){var v=c.v===n,y=v?c.w:c.v;if(y!==i){var g=v===r,h=e.edge(c).weight;if(a+=g?h:-h,lyt(t,n,y)){var u=t.edge(n,y).cutvalue;a+=g?-u:u;}}}),a}function gN(t,e){arguments.length<2&&(e=t.nodes()[0]),qF(t,{},1,e);}function qF(t,e,n,s,i){var r=n,o=t.node(s);return e[s]=true,zf.forEach(t.neighbors(s),function(a){zf.has(e,a)||(n=qF(t,e,n,a,s));}),o.low=r,o.lim=n++,i?o.parent=i:delete o.parent,n}function zF(t){return zf.find(t.edges(),function(e){return t.edge(e).cutvalue<0})}function $F(t,e,n){var s=n.v,i=n.w;e.hasEdge(s,i)||(s=n.w,i=n.v);var r=t.node(s),o=t.node(i),a=r,c=false;r.lim>o.lim&&(a=o,c=true);var v=zf.filter(e.edges(),function(y){return c===HF(t,t.node(y.v),a)&&c!==HF(t,t.node(y.w),a)});return zf.minBy(v,function(y){return ryt(e,y)})}function VF(t,e,n,s){var i=n.v,r=n.w;t.removeEdge(i,r),t.setEdge(s.v,s.w,{}),gN(t),dN(t,e),uyt(t,e);}function uyt(t,e){var n=zf.find(t.nodes(),function(i){return !e.node(i).parent}),s=iyt(t,n);s=s.slice(1),zf.forEach(s,function(i){var r=t.node(i).parent,o=e.edge(i,r),a=false;o||(o=e.edge(r,i),a=true),e.node(i).rank=e.node(r).rank+(a?o.minlen:-o.minlen);});}function lyt(t,e,n){return t.hasEdge(e,n)}function HF(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}});var ZF=qt((gMt,JF)=>{var cyt=vb(),QF=cyt.longestPath,hyt=pN(),fyt=WF();JF.exports=pyt;function pyt(t){switch(t.graph().ranker){case "network-simplex":XF(t);break;case "tight-tree":gyt(t);break;case "longest-path":dyt(t);break;default:XF(t);}}var dyt=QF;function gyt(t){QF(t),hyt(t);}function XF(t){fyt(t);}});var eB=qt((yMt,tB)=>{var yN=no();tB.exports=yyt;function yyt(t){var e=vyt(t);yN.forEach(t.graph().dummyChains,function(n){for(var s=t.node(n),i=s.edgeObj,r=myt(t,e,i.v,i.w),o=r.path,a=r.lca,c=0,v=o[c],y=true;n!==i.w;){if(s=t.node(n),y){for(;(v=o[c])!==a&&t.node(v).maxRank<s.rank;)c++;v===a&&(y=false);}if(!y){for(;c<o.length-1&&t.node(v=o[c+1]).minRank<=s.rank;)c++;v=o[c];}t.setParent(n,v),n=t.successors(n)[0];}});}function myt(t,e,n,s){var i=[],r=[],o=Math.min(e[n].low,e[s].low),a=Math.max(e[n].lim,e[s].lim),c,v;c=n;do c=t.parent(c),i.push(c);while(c&&(e[c].low>o||a>e[c].lim));for(v=c,c=s;(c=t.parent(c))!==v;)r.push(c);return {path:i.concat(r.reverse()),lca:v}}function vyt(t){var e={},n=0;function s(i){var r=n;yN.forEach(t.children(i),s),e[i]={low:r,lim:n++};}return yN.forEach(t.children(),s),e}});var iB=qt((mMt,nB)=>{var $f=no(),mN=Ua();nB.exports={run:xyt,cleanup:Tyt};function xyt(t){var e=mN.addDummyNode(t,"root",{},"_root"),n=_yt(t),s=$f.max($f.values(n))-1,i=2*s+1;t.graph().nestingRoot=e,$f.forEach(t.edges(),function(o){t.edge(o).minlen*=i;});var r=byt(t)+1;$f.forEach(t.children(),function(o){rB(t,e,i,r,s,n,o);}),t.graph().nodeRankFactor=i;}function rB(t,e,n,s,i,r,o){var a=t.children(o);if(!a.length){o!==e&&t.setEdge(e,o,{weight:0,minlen:n});return}var c=mN.addBorderNode(t,"_bt"),v=mN.addBorderNode(t,"_bb"),y=t.node(o);t.setParent(c,o),y.borderTop=c,t.setParent(v,o),y.borderBottom=v,$f.forEach(a,function(g){rB(t,e,n,s,i,r,g);var h=t.node(g),u=h.borderTop?h.borderTop:g,d=h.borderBottom?h.borderBottom:g,f=h.borderTop?s:2*s,l=u!==d?1:i-r[o]+1;t.setEdge(c,u,{weight:f,minlen:l,nestingEdge:true}),t.setEdge(d,v,{weight:f,minlen:l,nestingEdge:true});}),t.parent(o)||t.setEdge(e,c,{weight:0,minlen:i+r[o]});}function _yt(t){var e={};function n(s,i){var r=t.children(s);r&&r.length&&$f.forEach(r,function(o){n(o,i+1);}),e[s]=i;}return $f.forEach(t.children(),function(s){n(s,1);}),e}function byt(t){return $f.reduce(t.edges(),function(e,n){return e+t.edge(n).weight},0)}function Tyt(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,$f.forEach(t.edges(),function(n){var s=t.edge(n);s.nestingEdge&&t.removeEdge(n);});}});var aB=qt((vMt,sB)=>{var vN=no(),Eyt=Ua();sB.exports=Syt;function Syt(t){function e(n){var s=t.children(n),i=t.node(n);if(s.length&&vN.forEach(s,e),vN.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var r=i.minRank,o=i.maxRank+1;r<o;++r)oB(t,"borderLeft","_bl",n,i,r),oB(t,"borderRight","_br",n,i,r);}}vN.forEach(t.children(),e);}function oB(t,e,n,s,i,r){var o={width:0,height:0,rank:r,borderType:e},a=i[e][r-1],c=Eyt.addDummyNode(t,"border",o,n);i[e][r]=c,t.setParent(c,s),a&&t.setEdge(a,c,{weight:1});}});var hB=qt((xMt,cB)=>{var Eh=no();cB.exports={adjust:Oyt,undo:Ayt};function Oyt(t){var e=t.graph().rankdir.toLowerCase();(e==="lr"||e==="rl")&&lB(t);}function Ayt(t){var e=t.graph().rankdir.toLowerCase();(e==="bt"||e==="rl")&&wyt(t),(e==="lr"||e==="rl")&&(Cyt(t),lB(t));}function lB(t){Eh.forEach(t.nodes(),function(e){uB(t.node(e));}),Eh.forEach(t.edges(),function(e){uB(t.edge(e));});}function uB(t){var e=t.width;t.width=t.height,t.height=e;}function wyt(t){Eh.forEach(t.nodes(),function(e){xN(t.node(e));}),Eh.forEach(t.edges(),function(e){var n=t.edge(e);Eh.forEach(n.points,xN),Eh.has(n,"y")&&xN(n);});}function xN(t){t.y=-t.y;}function Cyt(t){Eh.forEach(t.nodes(),function(e){_N(t.node(e));}),Eh.forEach(t.edges(),function(e){var n=t.edge(e);Eh.forEach(n.points,_N),Eh.has(n,"x")&&_N(n);});}function _N(t){var e=t.x;t.x=t.y,t.y=e;}});var pB=qt((_Mt,fB)=>{var Vf=no();fB.exports=Nyt;function Nyt(t){var e={},n=Vf.filter(t.nodes(),function(a){return !t.children(a).length}),s=Vf.max(Vf.map(n,function(a){return t.node(a).rank})),i=Vf.map(Vf.range(s+1),function(){return []});function r(a){if(!Vf.has(e,a)){e[a]=true;var c=t.node(a);i[c.rank].push(a),Vf.forEach(t.successors(a),r);}}var o=Vf.sortBy(n,function(a){return t.node(a).rank});return Vf.forEach(o,r),i}});var gB=qt((bMt,dB)=>{var kd=no();dB.exports=Ryt;function Ryt(t,e){for(var n=0,s=1;s<e.length;++s)n+=Lyt(t,e[s-1],e[s]);return n}function Lyt(t,e,n){for(var s=kd.zipObject(n,kd.map(n,function(v,y){return y})),i=kd.flatten(kd.map(e,function(v){return kd.sortBy(kd.map(t.outEdges(v),function(y){return {pos:s[y.w],weight:t.edge(y).weight}}),"pos")}),true),r=1;r<n.length;)r<<=1;var o=2*r-1;r-=1;var a=kd.map(new Array(o),function(){return 0}),c=0;return kd.forEach(i.forEach(function(v){var y=v.pos+r;a[y]+=v.weight;for(var g=0;y>0;)y%2&&(g+=a[y+1]),y=y-1>>1,a[y]+=v.weight;c+=v.weight*g;})),c}});var vB=qt((TMt,mB)=>{var yB=no();mB.exports=Iyt;function Iyt(t,e){return yB.map(e,function(n){var s=t.inEdges(n);if(s.length){var i=yB.reduce(s,function(r,o){var a=t.edge(o),c=t.node(o.v);return {sum:r.sum+a.weight*c.order,weight:r.weight+a.weight}},{sum:0,weight:0});return {v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return {v:n}})}});var _B=qt((EMt,xB)=>{var Gu=no();xB.exports=Pyt;function Pyt(t,e){var n={};Gu.forEach(t,function(i,r){var o=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:r};Gu.isUndefined(i.barycenter)||(o.barycenter=i.barycenter,o.weight=i.weight);}),Gu.forEach(e.edges(),function(i){var r=n[i.v],o=n[i.w];!Gu.isUndefined(r)&&!Gu.isUndefined(o)&&(o.indegree++,r.out.push(n[i.w]));});var s=Gu.filter(n,function(i){return !i.indegree});return Dyt(s)}function Dyt(t){var e=[];function n(r){return function(o){o.merged||(Gu.isUndefined(o.barycenter)||Gu.isUndefined(r.barycenter)||o.barycenter>=r.barycenter)&&kyt(r,o);}}function s(r){return function(o){o.in.push(r),--o.indegree===0&&t.push(o);}}for(;t.length;){var i=t.pop();e.push(i),Gu.forEach(i.in.reverse(),n(i)),Gu.forEach(i.out,s(i));}return Gu.map(Gu.filter(e,function(r){return !r.merged}),function(r){return Gu.pick(r,["vs","i","barycenter","weight"])})}function kyt(t,e){var n=0,s=0;t.weight&&(n+=t.barycenter*t.weight,s+=t.weight),e.weight&&(n+=e.barycenter*e.weight,s+=e.weight),t.vs=e.vs.concat(t.vs),t.barycenter=n/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=true;}});var EB=qt((SMt,TB)=>{var xb=no(),Myt=Ua();TB.exports=Kyt;function Kyt(t,e){var n=Myt.partition(t,function(y){return xb.has(y,"barycenter")}),s=n.lhs,i=xb.sortBy(n.rhs,function(y){return -y.i}),r=[],o=0,a=0,c=0;s.sort(Fyt(!!e)),c=bB(r,i,c),xb.forEach(s,function(y){c+=y.vs.length,r.push(y.vs),o+=y.barycenter*y.weight,a+=y.weight,c=bB(r,i,c);});var v={vs:xb.flatten(r,true)};return a&&(v.barycenter=o/a,v.weight=a),v}function bB(t,e,n){for(var s;e.length&&(s=xb.last(e)).i<=n;)e.pop(),t.push(s.vs),n++;return n}function Fyt(t){return function(e,n){return e.barycenter<n.barycenter?-1:e.barycenter>n.barycenter?1:t?n.i-e.i:e.i-n.i}}});var AB=qt((OMt,OB)=>{var Md=no(),Byt=vB(),Uyt=_B(),jyt=EB();OB.exports=SB;function SB(t,e,n,s){var i=t.children(e),r=t.node(e),o=r?r.borderLeft:void 0,a=r?r.borderRight:void 0,c={};o&&(i=Md.filter(i,function(d){return d!==o&&d!==a}));var v=Byt(t,i);Md.forEach(v,function(d){if(t.children(d.v).length){var f=SB(t,d.v,n,s);c[d.v]=f,Md.has(f,"barycenter")&&Gyt(d,f);}});var y=Uyt(v,n);Hyt(y,c);var g=jyt(y,s);if(o&&(g.vs=Md.flatten([o,g.vs,a],true),t.predecessors(o).length)){var h=t.node(t.predecessors(o)[0]),u=t.node(t.predecessors(a)[0]);Md.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+h.order+u.order)/(g.weight+2),g.weight+=2;}return g}function Hyt(t,e){Md.forEach(t,function(n){n.vs=Md.flatten(n.vs.map(function(s){return e[s]?e[s].vs:s}),true);});}function Gyt(t,e){Md.isUndefined(t.barycenter)?(t.barycenter=e.barycenter,t.weight=e.weight):(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight);}});var CB=qt((AMt,wB)=>{var _b=no(),qyt=Fl().Graph;wB.exports=zyt;function zyt(t,e,n){var s=$yt(t),i=new qyt({compound:true}).setGraph({root:s}).setDefaultNodeLabel(function(r){return t.node(r)});return _b.forEach(t.nodes(),function(r){var o=t.node(r),a=t.parent(r);(o.rank===e||o.minRank<=e&&e<=o.maxRank)&&(i.setNode(r),i.setParent(r,a||s),_b.forEach(t[n](r),function(c){var v=c.v===r?c.w:c.v,y=i.edge(v,r),g=_b.isUndefined(y)?0:y.weight;i.setEdge(v,r,{weight:t.edge(c).weight+g});}),_b.has(o,"minRank")&&i.setNode(r,{borderLeft:o.borderLeft[e],borderRight:o.borderRight[e]}));}),i}function $yt(t){for(var e;t.hasNode(e=_b.uniqueId("_root")););return e}});var RB=qt((wMt,NB)=>{var Vyt=no();NB.exports=Yyt;function Yyt(t,e,n){var s={},i;Vyt.forEach(n,function(r){for(var o=t.parent(r),a,c;o;){if(a=t.parent(o),a?(c=s[a],s[a]=o):(c=i,i=o),c&&c!==o){e.setEdge(c,o);return}o=a;}});}});var kB=qt((CMt,DB)=>{var Kd=no(),Wyt=pB(),Xyt=gB(),Qyt=AB(),Jyt=CB(),Zyt=RB(),tmt=Fl().Graph,LB=Ua();DB.exports=emt;function emt(t){var e=LB.maxRank(t),n=IB(t,Kd.range(1,e+1),"inEdges"),s=IB(t,Kd.range(e-1,-1,-1),"outEdges"),i=Wyt(t);PB(t,i);for(var r=Number.POSITIVE_INFINITY,o,a=0,c=0;c<4;++a,++c){rmt(a%2?n:s,a%4>=2),i=LB.buildLayerMatrix(t);var v=Xyt(t,i);v<r&&(c=0,o=Kd.cloneDeep(i),r=v);}PB(t,o);}function IB(t,e,n){return Kd.map(e,function(s){return Jyt(t,s,n)})}function rmt(t,e){var n=new tmt;Kd.forEach(t,function(s){var i=s.graph().root,r=Qyt(s,i,n,e);Kd.forEach(r.vs,function(o,a){s.node(o).order=a;}),Zyt(s,n,r.vs);});}function PB(t,e){Kd.forEach(e,function(n){Kd.forEach(n,function(s,i){t.node(s).order=i;});});}});var zB=qt((NMt,qB)=>{var wn=no(),nmt=Fl().Graph,imt=Ua();qB.exports={positionX:amt,findType1Conflicts:MB,findType2Conflicts:KB,addConflict:bN,hasConflict:FB,verticalAlignment:BB,horizontalCompaction:UB,alignCoordinates:HB,findSmallestWidthAlignment:jB,balance:GB};function MB(t,e){var n={};function s(i,r){var o=0,a=0,c=i.length,v=wn.last(r);return wn.forEach(r,function(y,g){var h=omt(t,y),u=h?t.node(h).order:c;(h||y===v)&&(wn.forEach(r.slice(a,g+1),function(d){wn.forEach(t.predecessors(d),function(f){var l=t.node(f),p=l.order;(p<o||u<p)&&!(l.dummy&&t.node(d).dummy)&&bN(n,f,d);});}),a=g+1,o=u);}),r}return wn.reduce(e,s),n}function KB(t,e){var n={};function s(r,o,a,c,v){var y;wn.forEach(wn.range(o,a),function(g){y=r[g],t.node(y).dummy&&wn.forEach(t.predecessors(y),function(h){var u=t.node(h);u.dummy&&(u.order<c||u.order>v)&&bN(n,h,y);});});}function i(r,o){var a=-1,c,v=0;return wn.forEach(o,function(y,g){if(t.node(y).dummy==="border"){var h=t.predecessors(y);h.length&&(c=t.node(h[0]).order,s(o,v,g,a,c),v=g,a=c);}s(o,v,o.length,c,r.length);}),o}return wn.reduce(e,i),n}function omt(t,e){if(t.node(e).dummy)return wn.find(t.predecessors(e),function(n){return t.node(n).dummy})}function bN(t,e,n){if(e>n){var s=e;e=n,n=s;}var i=t[e];i||(t[e]=i={}),i[n]=true;}function FB(t,e,n){if(e>n){var s=e;e=n,n=s;}return wn.has(t[e],n)}function BB(t,e,n,s){var i={},r={},o={};return wn.forEach(e,function(a){wn.forEach(a,function(c,v){i[c]=c,r[c]=c,o[c]=v;});}),wn.forEach(e,function(a){var c=-1;wn.forEach(a,function(v){var y=s(v);if(y.length){y=wn.sortBy(y,function(f){return o[f]});for(var g=(y.length-1)/2,h=Math.floor(g),u=Math.ceil(g);h<=u;++h){var d=y[h];r[v]===v&&c<o[d]&&!FB(n,v,d)&&(r[d]=v,r[v]=i[v]=i[d],c=o[d]);}}});}),{root:i,align:r}}function UB(t,e,n,s,i){var r={},o=smt(t,e,n,i),a=i?"borderLeft":"borderRight";function c(g,h){for(var u=o.nodes(),d=u.pop(),f={};d;)f[d]?g(d):(f[d]=true,u.push(d),u=u.concat(h(d))),d=u.pop();}function v(g){r[g]=o.inEdges(g).reduce(function(h,u){return Math.max(h,r[u.v]+o.edge(u))},0);}function y(g){var h=o.outEdges(g).reduce(function(d,f){return Math.min(d,r[f.w]-o.edge(f))},Number.POSITIVE_INFINITY),u=t.node(g);h!==Number.POSITIVE_INFINITY&&u.borderType!==a&&(r[g]=Math.max(r[g],h));}return c(v,o.predecessors.bind(o)),c(y,o.successors.bind(o)),wn.forEach(s,function(g){r[g]=r[n[g]];}),r}function smt(t,e,n,s){var i=new nmt,r=t.graph(),o=umt(r.nodesep,r.edgesep,s);return wn.forEach(e,function(a){var c;wn.forEach(a,function(v){var y=n[v];if(i.setNode(y),c){var g=n[c],h=i.edge(g,y);i.setEdge(g,y,Math.max(o(t,v,c),h||0));}c=v;});}),i}function jB(t,e){return wn.minBy(wn.values(e),function(n){var s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return wn.forIn(n,function(r,o){var a=lmt(t,o)/2;s=Math.max(r+a,s),i=Math.min(r-a,i);}),s-i})}function HB(t,e){var n=wn.values(e),s=wn.min(n),i=wn.max(n);wn.forEach(["u","d"],function(r){wn.forEach(["l","r"],function(o){var a=r+o,c=t[a],v;if(c!==e){var y=wn.values(c);v=o==="l"?s-wn.min(y):i-wn.max(y),v&&(t[a]=wn.mapValues(c,function(g){return g+v}));}});});}function GB(t,e){return wn.mapValues(t.ul,function(n,s){if(e)return t[e.toLowerCase()][s];var i=wn.sortBy(wn.map(t,s));return (i[1]+i[2])/2})}function amt(t){var e=imt.buildLayerMatrix(t),n=wn.merge(MB(t,e),KB(t,e)),s={},i;wn.forEach(["u","d"],function(o){i=o==="u"?e:wn.values(e).reverse(),wn.forEach(["l","r"],function(a){a==="r"&&(i=wn.map(i,function(g){return wn.values(g).reverse()}));var c=(o==="u"?t.predecessors:t.successors).bind(t),v=BB(t,i,n,c),y=UB(t,i,v.root,v.align,a==="r");a==="r"&&(y=wn.mapValues(y,function(g){return -g})),s[o+a]=y;});});var r=jB(t,s);return HB(s,r),GB(s,t.graph().align)}function umt(t,e,n){return function(s,i,r){var o=s.node(i),a=s.node(r),c=0,v;if(c+=o.width/2,wn.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case "l":v=-o.width/2;break;case "r":v=o.width/2;break}if(v&&(c+=n?v:-v),v=0,c+=(o.dummy?e:t)/2,c+=(a.dummy?e:t)/2,c+=a.width/2,wn.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case "l":v=a.width/2;break;case "r":v=-a.width/2;break}return v&&(c+=n?v:-v),v=0,c}}function lmt(t,e){return t.node(e).width}});var YB=qt((RMt,VB)=>{var bb=no(),$B=Ua(),cmt=zB().positionX;VB.exports=hmt;function hmt(t){t=$B.asNonCompoundGraph(t),fmt(t),bb.forEach(cmt(t),function(e,n){t.node(n).x=e;});}function fmt(t){var e=$B.buildLayerMatrix(t),n=t.graph().ranksep,s=0;bb.forEach(e,function(i){var r=bb.max(bb.map(i,function(o){return t.node(o).height}));bb.forEach(i,function(o){t.node(o).y=s+r/2;}),s+=r+n;});}});var tU=qt((LMt,ZB)=>{var Gn=no(),WB=IF(),XB=BF(),pmt=ZF(),dmt=Ua().normalizeRanks,gmt=eB(),ymt=Ua().removeEmptyRanks,QB=iB(),mmt=aB(),JB=hB(),vmt=kB(),xmt=YB(),Fd=Ua(),_mt=Fl().Graph;ZB.exports=bmt;function bmt(t,e){var n=e&&e.debugTiming?Fd.time:Fd.notime;n("layout",function(){var s=n(" buildLayoutGraph",function(){return Imt(t)});n(" runLayout",function(){Tmt(s,n);}),n(" updateInputGraph",function(){Emt(t,s);});});}function Tmt(t,e){e(" makeSpaceForEdgeLabels",function(){Pmt(t);}),e(" removeSelfEdges",function(){Hmt(t);}),e(" acyclic",function(){WB.run(t);}),e(" nestingGraph.run",function(){QB.run(t);}),e(" rank",function(){pmt(Fd.asNonCompoundGraph(t));}),e(" injectEdgeLabelProxies",function(){Dmt(t);}),e(" removeEmptyRanks",function(){ymt(t);}),e(" nestingGraph.cleanup",function(){QB.cleanup(t);}),e(" normalizeRanks",function(){dmt(t);}),e(" assignRankMinMax",function(){kmt(t);}),e(" removeEdgeLabelProxies",function(){Mmt(t);}),e(" normalize.run",function(){XB.run(t);}),e(" parentDummyChains",function(){gmt(t);}),e(" addBorderSegments",function(){mmt(t);}),e(" order",function(){vmt(t);}),e(" insertSelfEdges",function(){Gmt(t);}),e(" adjustCoordinateSystem",function(){JB.adjust(t);}),e(" position",function(){xmt(t);}),e(" positionSelfEdges",function(){qmt(t);}),e(" removeBorderNodes",function(){jmt(t);}),e(" normalize.undo",function(){XB.undo(t);}),e(" fixupEdgeLabelCoords",function(){Bmt(t);}),e(" undoCoordinateSystem",function(){JB.undo(t);}),e(" translateGraph",function(){Kmt(t);}),e(" assignNodeIntersects",function(){Fmt(t);}),e(" reversePoints",function(){Umt(t);}),e(" acyclic.undo",function(){WB.undo(t);});}function Emt(t,e){Gn.forEach(t.nodes(),function(n){var s=t.node(n),i=e.node(n);s&&(s.x=i.x,s.y=i.y,e.children(n).length&&(s.width=i.width,s.height=i.height));}),Gn.forEach(t.edges(),function(n){var s=t.edge(n),i=e.edge(n);s.points=i.points,Gn.has(i,"x")&&(s.x=i.x,s.y=i.y);}),t.graph().width=e.graph().width,t.graph().height=e.graph().height;}var Smt=["nodesep","edgesep","ranksep","marginx","marginy"],Omt={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Amt=["acyclicer","ranker","rankdir","align"],wmt=["width","height"],Cmt={width:0,height:0},Nmt=["minlen","weight","width","height","labeloffset"],Rmt={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Lmt=["labelpos"];function Imt(t){var e=new _mt({multigraph:true,compound:true}),n=EN(t.graph());return e.setGraph(Gn.merge({},Omt,TN(n,Smt),Gn.pick(n,Amt))),Gn.forEach(t.nodes(),function(s){var i=EN(t.node(s));e.setNode(s,Gn.defaults(TN(i,wmt),Cmt)),e.setParent(s,t.parent(s));}),Gn.forEach(t.edges(),function(s){var i=EN(t.edge(s));e.setEdge(s,Gn.merge({},Rmt,TN(i,Nmt),Gn.pick(i,Lmt)));}),e}function Pmt(t){var e=t.graph();e.ranksep/=2,Gn.forEach(t.edges(),function(n){var s=t.edge(n);s.minlen*=2,s.labelpos.toLowerCase()!=="c"&&(e.rankdir==="TB"||e.rankdir==="BT"?s.width+=s.labeloffset:s.height+=s.labeloffset);});}function Dmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);if(n.width&&n.height){var s=t.node(e.v),i=t.node(e.w),r={rank:(i.rank-s.rank)/2+s.rank,e};Fd.addDummyNode(t,"edge-proxy",r,"_ep");}});}function kmt(t){var e=0;Gn.forEach(t.nodes(),function(n){var s=t.node(n);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=Gn.max(e,s.maxRank));}),t.graph().maxRank=e;}function Mmt(t){Gn.forEach(t.nodes(),function(e){var n=t.node(e);n.dummy==="edge-proxy"&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e));});}function Kmt(t){var e=Number.POSITIVE_INFINITY,n=0,s=Number.POSITIVE_INFINITY,i=0,r=t.graph(),o=r.marginx||0,a=r.marginy||0;function c(v){var y=v.x,g=v.y,h=v.width,u=v.height;e=Math.min(e,y-h/2),n=Math.max(n,y+h/2),s=Math.min(s,g-u/2),i=Math.max(i,g+u/2);}Gn.forEach(t.nodes(),function(v){c(t.node(v));}),Gn.forEach(t.edges(),function(v){var y=t.edge(v);Gn.has(y,"x")&&c(y);}),e-=o,s-=a,Gn.forEach(t.nodes(),function(v){var y=t.node(v);y.x-=e,y.y-=s;}),Gn.forEach(t.edges(),function(v){var y=t.edge(v);Gn.forEach(y.points,function(g){g.x-=e,g.y-=s;}),Gn.has(y,"x")&&(y.x-=e),Gn.has(y,"y")&&(y.y-=s);}),r.width=n-e+o,r.height=i-s+a;}function Fmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e),s=t.node(e.v),i=t.node(e.w),r,o;n.points?(r=n.points[0],o=n.points[n.points.length-1]):(n.points=[],r=i,o=s),n.points.unshift(Fd.intersectRect(s,r)),n.points.push(Fd.intersectRect(i,o));});}function Bmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);if(Gn.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case "l":n.x-=n.width/2+n.labeloffset;break;case "r":n.x+=n.width/2+n.labeloffset;break}});}function Umt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);n.reversed&&n.points.reverse();});}function jmt(t){Gn.forEach(t.nodes(),function(e){if(t.children(e).length){var n=t.node(e),s=t.node(n.borderTop),i=t.node(n.borderBottom),r=t.node(Gn.last(n.borderLeft)),o=t.node(Gn.last(n.borderRight));n.width=Math.abs(o.x-r.x),n.height=Math.abs(i.y-s.y),n.x=r.x+n.width/2,n.y=s.y+n.height/2;}}),Gn.forEach(t.nodes(),function(e){t.node(e).dummy==="border"&&t.removeNode(e);});}function Hmt(t){Gn.forEach(t.edges(),function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e);}});}function Gmt(t){var e=Fd.buildLayerMatrix(t);Gn.forEach(e,function(n){var s=0;Gn.forEach(n,function(i,r){var o=t.node(i);o.order=r+s,Gn.forEach(o.selfEdges,function(a){Fd.addDummyNode(t,"selfedge",{width:a.label.width,height:a.label.height,rank:o.rank,order:r+ ++s,e:a.e,label:a.label},"_se");}),delete o.selfEdges;});});}function qmt(t){Gn.forEach(t.nodes(),function(e){var n=t.node(e);if(n.dummy==="selfedge"){var s=t.node(n.e.v),i=s.x+s.width/2,r=s.y,o=n.x-i,a=s.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:r-a},{x:i+5*o/6,y:r-a},{x:i+o,y:r},{x:i+5*o/6,y:r+a},{x:i+2*o/3,y:r+a}],n.label.x=n.x,n.label.y=n.y;}});}function TN(t,e){return Gn.mapValues(Gn.pick(t,e),Number)}function EN(t){var e={};return Gn.forEach(t,function(n,s){e[s.toLowerCase()]=n;}),e}});var rU=qt((IMt,eU)=>{var WE=no(),zmt=Ua(),$mt=Fl().Graph;eU.exports={debugOrdering:Vmt};function Vmt(t){var e=zmt.buildLayerMatrix(t),n=new $mt({compound:true,multigraph:true}).setGraph({});return WE.forEach(t.nodes(),function(s){n.setNode(s,{label:s}),n.setParent(s,"layer"+t.node(s).rank);}),WE.forEach(t.edges(),function(s){n.setEdge(s.v,s.w,{},s.name);}),WE.forEach(e,function(s,i){var r="layer"+i;n.setNode(r,{rank:"same"}),WE.reduce(s,function(o,a){return n.setEdge(o,a,{style:"invis"}),a});}),n}});var iU=qt((PMt,nU)=>{nU.exports="0.8.5";});var sU=qt((DMt,oU)=>{oU.exports={graphlib:Fl(),layout:tU(),debug:rU(),util:{time:Ua().time,notime:Ua().notime},version:iU()};});function lU(t){return typeof t=="number"?t:t?.index??-1}var QE,aU,uU,XE,SN;exports.WebColaTranslator=void 0;var JE=Ie(()=>{Ll();PK();QE=Rs(sU()),aU=8,uU=20;XE=class XE{constructor(e,n=800,s=800,i){this.nodeIndexMap=new Map;this.seedPositions=null;this.collapsedGroupAliases=new Map;if(this.FIG_HEIGHT=n,this.FIG_WIDTH=s,this.DEFAULT_X=s/2,this.DEFAULT_Y=n/2,this.instanceLayout=e,this.priorPositionMap=new Map,i?.priorPositions?.positions)for(let v of i.priorPositions.positions)this.priorPositionMap.set(v.id,v);this.lockUnconstrainedNodes=i?.lockUnconstrainedNodes??false,this.collapseSymmetric=i?.collapseSymmetricEdges??true;try{let v=new QE.graphlib.Graph({multigraph:!0});v.setGraph({nodesep:50,ranksep:100,rankdir:"TB"}),v.setDefaultEdgeLabel(()=>({})),e.nodes.forEach(y=>{v.setNode(y.id,{width:y.width,height:y.height});}),e.edges.forEach(y=>{v.setEdge(y.source.id,y.target.id);}),QE.layout(v),this.dagre_graph=v;}catch(v){console.log(v),this.dagre_graph=null;}if((i?.seedMode??globalThis?.SPYTIAL_SEED_MODE??"constraint-aware")!=="dagre"&&this.priorPositionMap.size===0&&IK(e))try{this.seedPositions=LK(e,s,n);}catch(v){console.warn("Constraint-aware seed failed, falling back to DAGRE:",v),this.seedPositions=null;}this.colaNodes=e.nodes.map(v=>this.toColaNode(v));for(let v=0;v<this.colaNodes.length;v++)this.nodeIndexMap.set(this.colaNodes[v].id,v);this.colaEdges=e.edges.map(v=>this.toColaEdge(v)),this.collapseSymmetric&&(this.colaEdges=this.collapseSymmetricEdges(this.colaEdges));let o=this.collapseIdenticalGroups(e.groups);if(this.groupDefinitions=this.determineGroups(o),this.collapsedGroupAliases.size>0)for(let v of this.colaEdges)v.groupId&&(v.groupId=this.collapsedGroupAliases.get(v.groupId)??v.groupId),v.sourceGroupId&&(v.sourceGroupId=this.collapsedGroupAliases.get(v.sourceGroupId)??v.sourceGroupId),v.targetGroupId&&(v.targetGroupId=this.collapsedGroupAliases.get(v.targetGroupId)??v.targetGroupId);this.conflictingConstraints=e.conflictingConstraints||[],this.overlappingNodesData=e.overlappingNodes||[],this.reintroducedNodesData=e.reintroducedNodes||[],this.colaConstraints=e.constraints.flatMap(v=>this.toColaConstraint(v)),this.applyConstraintAwareLocking(this.colaConstraints),this.colaConstraints.length>100&&(this.colaConstraints=this.optimizeConstraints(this.colaConstraints)),this.colaConstraints.length===0&&this.dagre_graph&&this.colaNodes.forEach(v=>v.fixed=1);}optimizeConstraints(e){let n=[],s=[],i=[];for(let a of e)if(a.type==="separation"&&!a.groupBoundary){let c=a;c.axis==="x"&&!c.equality?n.push(c):c.axis==="y"&&!c.equality?s.push(c):i.push(a);}else i.push(a);let r=this.transitiveReductionForSeparation(n),o=this.transitiveReductionForSeparation(s);return [...r,...o,...i]}transitiveReductionForSeparation(e){if(e.length===0)return e;let n=this.colaNodes.length,s=Array(n).fill(null).map(()=>Array(n).fill(null));for(let o of e){let a=o.left,c=o.right;typeof a=="number"&&typeof c=="number"&&a>=0&&a<n&&c>=0&&c<n&&Number.isInteger(a)&&Number.isInteger(c)&&(s[a][c]=o);}let i=Array(n).fill(false).map(()=>Array(n).fill(false));for(let o=0;o<n;o++)for(let a=0;a<n;a++)i[o][a]=s[o][a]!==null;for(let o=0;o<n;o++)for(let a=0;a<n;a++)for(let c=0;c<n;c++)i[a][o]&&i[o][c]&&(i[a][c]=true);let r=[];for(let o of e){let a=o.left,c=o.right,v=false;for(let y=0;y<n;y++)if(y!==a&&y!==c&&s[a][y]!==null&&s[y][c]!==null){v=true;break}v||r.push(o);}return r}getNodeIndex(e){let n=this.nodeIndexMap.get(e);return n===void 0?-1:n}computeHorizontalSeparation(e,n,s){let i=e.visualWidth??e.width??100,r=n.visualWidth??n.width??100,o=i/2+r/2+s,a=Math.max(i,r),c=Math.min(a*.1,20);return o+c}computeVerticalSeparation(e,n,s){let i=e.visualHeight??e.height??60,r=n.visualHeight??n.height??60,o=i/2+r/2+s,a=Math.max(i,r),c=Math.min(a*.1,15);return o+c}leftConstraint(e,n,s){return {type:"separation",axis:"x",left:e,right:n,gap:s}}topConstraint(e,n,s){return {type:"separation",axis:"y",left:e,right:n,gap:s}}heirarchyConstraint(e,n,s){return {type:"hierarchy",parent:e,child:n,gap:s}}toColaNode(e){let n=this.DEFAULT_X,s=this.DEFAULT_Y,i=0,r=this.priorPositionMap.get(e.id);if(r)n=r.x,s=r.y,this.lockUnconstrainedNodes&&(i=1);else if(this.priorPositionMap.size>0){if(console.log(`Node ${e.id}: No prior position found (available: ${Array.from(this.priorPositionMap.keys()).join(", ")})`),this.dagre_graph){let o=this.dagre_graph.node(e.id);o&&(n=o.x,s=o.y);}}else if(this.seedPositions?.has(e.id)){let o=this.seedPositions.get(e.id);n=o.x,s=o.y;}else if(this.dagre_graph){let o=this.dagre_graph.node(e.id);o&&(n=o.x,s=o.y);}return {id:e.id,color:e.color,colorSource:e.colorSource??"default-palette",fillColor:e.fillColor,borderWidth:e.borderWidth,textStyle:e.textStyle,attributes:e.attributes||{},attributeTextStyles:e.attributeTextStyles||{},labels:e.labels,width:e.width+2*(e.disconnected?uU:aU),height:e.height+2*(e.disconnected?uU:aU),visualWidth:e.width,visualHeight:e.height,x:n,y:s,icon:e.icon||"",iconPlacement:e.iconPlacement,iconOpacity:e.iconOpacity,fixed:i,mostSpecificType:e.mostSpecificType,showLabels:e.showLabels,label:e.label}}toColaEdge(e){let n=this.getNodeIndex(e.source.id),s=this.getNodeIndex(e.target.id);return {source:n,target:s,relName:e.relationName,id:e.id,label:e.label,color:e.color,style:e.style,weight:e.weight,highlight:e.highlight,showLabel:e.showLabel,textStyle:e.textStyle,groupId:e.groupId,keyNodeId:e.keyNodeId,sourceGroupId:e.sourceGroupId,targetGroupId:e.targetGroupId}}collapseSymmetricEdges(e){let n=new Map,s=new Set;for(let i of e){if(s.has(i.id))continue;if(i.source===i.target){n.set(i.id,i),s.add(i.id);continue}let r=lU(i.source),o=lU(i.target),a=Math.min(r,o),c=Math.max(r,o),v=`${a}-${c}-${i.label}`,y=e.find(g=>g.id!==i.id&&g.source===i.target&&g.target===i.source&&g.label===i.label&&!s.has(g.id));if(y){let g=i.source<i.target?i:y;n.set(v,{...g,bidirectional:true}),s.add(i.id),s.add(y.id);}else n.set(i.id,i),s.add(i.id);}return Array.from(n.values())}toColaConstraint(e){if(ii(e)){let n=this.colaNodes[this.getNodeIndex(e.left.id)],s=this.colaNodes[this.getNodeIndex(e.right.id)],i=this.computeHorizontalSeparation(n,s,e.minDistance);return this.leftConstraint(this.getNodeIndex(e.left.id),this.getNodeIndex(e.right.id),i)}if(ni(e)){let n=this.colaNodes[this.getNodeIndex(e.top.id)],s=this.colaNodes[this.getNodeIndex(e.bottom.id)],i=this.computeVerticalSeparation(n,s,e.minDistance);return this.topConstraint(this.getNodeIndex(e.top.id),this.getNodeIndex(e.bottom.id),i)}if(Fn(e))return {type:"separation",axis:e.axis,left:this.getNodeIndex(e.node1.id),right:this.getNodeIndex(e.node2.id),gap:0,equality:true};if(Ls(e))return console.log("BoundingBoxConstraint detected."),{type:"noop"};if(Is(e))return this.toColaGroupBoundary(e);throw new Error("Constraint type not recognized")}groupMemberPadding(e){let n=this.collapsedGroupAliases.get(e.name)??e.name,s=this.groupDefinitions.findIndex(r=>r.name===n);if(s<0)throw new Error(`Missing rendered group: ${e.name}`);let i=r=>{let o=this.groupDefinitions[r],a=o.padding,c=new Map;for(let v of o.leaves)c.set(v,a);for(let v of o.groups)for(let[y,g]of i(v))c.set(y,Math.max(c.get(y)??0,a+g));return c};return i(s)}toColaGroupBoundary(e){let n=this.groupMemberPadding(e.groupA),s=this.groupMemberPadding(e.groupB),i=e.side==="left"||e.side==="right"?"x":"y",r=i==="x"?"width":"height",o=e.side==="right"||e.side==="bottom",a=[];for(let[c,v]of n)for(let[y,g]of s){let h=(this.colaNodes[c][r]??0)/2+(this.colaNodes[y][r]??0)/2+v+g+e.minDistance;a.push({type:"separation",axis:i,left:o?y:c,right:o?c:y,gap:h,groupBoundary:true});}return a}classifyConstraintForLocking(e){if(e.type!=="separation")return null;let n=e,s=this.colaNodes[n.left],i=this.colaNodes[n.right];if(!this.priorPositionMap.has(s.id)||!this.priorPositionMap.has(i.id))return {endpoints:[s,i],verdict:"unknown"};let r=(i[n.axis]??0)-(s[n.axis]??0),o=XE.CONSTRAINT_SATISFACTION_TOLERANCE,a=n.equality?Math.abs(r-n.gap)<=o:r+o>=n.gap;return {endpoints:[s,i],verdict:a?"satisfied":"violated"}}applyConstraintAwareLocking(e){let n=this.lockUnconstrainedNodes;if(!(!n&&this.priorPositionMap.size===0))for(let s of e){let i=this.classifyConstraintForLocking(s);if(!i)continue;let[r,o]=i.endpoints;if(!n){r.fixed=0,o.fixed=0;continue}switch(i.verdict){case "satisfied":break;case "violated":r.fixed=0,o.fixed=0;break;case "unknown":this.priorPositionMap.has(r.id)||(r.fixed=0),this.priorPositionMap.has(o.id)||(o.fixed=0);break}}}collapseIdenticalGroups(e){if(e.length===0)return e;let n=new Map;for(let i of e){let r=[...i.nodeIds].sort().join(",");n.has(r)||n.set(r,[]),n.get(r).push(i);}let s=[];for(let i of n.values())if(i.length===1)s.push(i[0]);else {let r={...i[0],name:i.map(o=>o.name).join(" / "),showLabel:i.some(o=>o.showLabel)};for(let o of i)this.collapsedGroupAliases.set(o.name,r.name);s.push(r);}return s}determineGroups(e){let n={};e.forEach(i=>{n[i.name]=i.nodeIds;});let s=this.determineGroupsAndSubgroups(n);return s.forEach(i=>{let r=e.find(c=>c.name===i.name);if(!r)return;let o=r.keyNodeId,a=this.getNodeIndex(o);i.keyNode=a,i.id=r.name,i.showLabel=r.showLabel,r.showLabel&&(i.padding=Math.max(i.padding,20)),i.labelTextStyle=r.labelTextStyle;}),s}isSubGroup(e,n){return e.every(s=>n.includes(s))}determineGroupsAndSubgroups(e){let n={};Object.entries(e).forEach(([r,o])=>{Object.entries(e).forEach(([a,c])=>{r!==a&&(!n[a]||!n[a].includes(r))&&this.isSubGroup(c,o)&&(n[r]?n[r].push(a):n[r]=[a]);});});let s=Object.entries(e).map(([r,o])=>({leaves:o.map(y=>this.getNodeIndex(y)),padding:12,name:r}));return Object.entries(s).map(([r,o])=>{let a=o.leaves,c=o.padding,v=o.name;if(!n[v])return {leaves:a,padding:c,name:v,groups:[]};let y=n[v].map(g=>s.findIndex(u=>u.name===g));return y.forEach(g=>{let h=s[g];a=a.filter(u=>!h.leaves.includes(u));}),{leaves:a,padding:c,name:v,groups:y}})}get nodes(){return this.colaNodes}get links(){return this.colaEdges}get constraints(){return this.colaConstraints}get groups(){return this.groupDefinitions}get conflictingNodes(){let e=[],n=new Map;if(this.instanceLayout)for(let s of this.instanceLayout.nodes)n.set(s.id,s);return this.conflictingConstraints.forEach(s=>{if(ii(s))e.push(s.left),e.push(s.right);else if(ni(s))e.push(s.top),e.push(s.bottom);else if(Fn(s))e.push(s.node1),e.push(s.node2);else if(Ls(s)){e.push(s.node);for(let i of s.group.nodeIds){let r=n.get(i);r&&e.push(r);}}else if(Is(s)){for(let i of s.groupA.nodeIds){let r=n.get(i);r&&e.push(r);}for(let i of s.groupB.nodeIds){let r=n.get(i);r&&e.push(r);}}}),e}get overlappingNodes(){return this.overlappingNodesData}get reintroducedNodes(){return this.reintroducedNodesData}get overlappingGroups(){return (this.instanceLayout?.groups||[]).filter(e=>e.overlapping)}dispose(){this.dagre_graph&&(this.dagre_graph=null);}getMemoryStats(){return {nodeCount:this.colaNodes?.length||0,edgeCount:this.colaEdges?.length||0,groupCount:this.groupDefinitions?.length||0,constraintCount:this.colaConstraints?.length||0,hasDagreGraph:!!this.dagre_graph}}};XE.CONSTRAINT_SATISFACTION_TOLERANCE=.5;SN=XE,exports.WebColaTranslator=class{async translate(e,n=800,s=800,i){return new SN(e,s,n,i)}};});function pU({fontImports:t,fontFamily:e,canvasBackground:n}){return `
|
|
539
|
+
and name <code>${this.name}</code>.${n}`}},Sd=class extends G0{constructor(e,n,s=false){super(n,s),this.direction=e;}inconsistencyMessage(){return `Cyclic constraint with direction [${this.direction}] with selector <code>${this.selector}</code> is inconsistent.`}toHTML(){let e=this.providedHTML();return e||`${this.negated?"NOT ":""}Cyclic constraint with direction [${this.direction}] and selector <code>${this.selector}</code>`}};});function Od(t){return t.type==="positional-conflict"}function lE(t){return t.type==="group-overlap"}function fC(t){return t?.type==="hidden-node-conflict"}function Uf(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z4(t){if(t.attributes&&Object.entries(t.attributes).some(([n,s])=>s&&s.length>0)){let n=t.attributes||{},s=Object.entries(n).sort(([a],[c])=>a.localeCompare(c)),i=[],r=2,o=20;for(let a=0;a<Math.min(s.length,r);a++){let[c,v]=s[a];if(v&&v.length>0){let y=v[0];y.length>o&&(y=y.substring(0,o)+"..."),i.push(`${Uf(c)}: ${Uf(y)}`);}}if(s.length>r&&i.push("..."),i.length>0)return `<span data-node-id="${Uf(t.id)}">${Uf(t.label)} (${i.join(", ")})</span>`}return t.label&&t.label!==t.id?`<span data-node-id="${Uf(t.id)}" title="${q4}">${Uf(t.label)} (id = ${Uf(t.id)})</span>`:`<span data-node-id="${Uf(t.id)}" title="${q4}">${Uf(t.id)}</span>`}function Fa(t){let e=z4,s=t.sourceConstraint&&"negated"in t.sourceConstraint&&t.sourceConstraint.negated?"can":"must";if(ni(t)){let i=t;return `${e(i.top)} ${s} be above ${e(i.bottom)}`}else if(ii(t)){let i=t;return `${e(i.left)} ${s} be to the left of ${e(i.right)}`}else if(Fn(t)){let i=t,r=i.axis,o=i.node1,a=i.node2;return r==="x"?`${e(o)} ${s} be vertically aligned with ${e(a)}`:r==="y"?`${e(o)} ${s} be horizontally aligned with ${e(a)}`:`${e(o)} ${s} be aligned with ${e(a)} along the ${r} axis`}else if(Ls(t)){let i=t;return `${e(i.node)} cannot be in group "${i.group.name}", and groups must be contiguous rectangles`}else if(Is(t)){let i=t,r={left:"to the left of",right:"to the right of",top:"above",bottom:"below"};return `Group "${i.groupA.name}" ${s} be ${r[i.side]} group "${i.groupB.name}"`}return `Unknown constraint type: ${t}`}var q4,Ad=Ie(()=>{Ll();q4="This is a unique identifier in the graph. Hover over graph nodes to see their IDs.";});var Ult,jlt,Il,cE=Ie(()=>{(({min:Ult,max:jlt}=Math)),Il=(t,e=0,n=1)=>Ult(jlt(e,t),n);});var Sy,$4=Ie(()=>{cE();Sy=t=>{t._clipped=false,t._unclipped=t.slice(0);for(let e=0;e<=3;e++)e<3?((t[e]<0||t[e]>255)&&(t._clipped=true),t[e]=Il(t[e],0,255)):e===3&&(t[e]=Il(t[e],0,1));return t};});function kr(t){return V4[Object.prototype.toString.call(t)]||"object"}var V4,ob=Ie(()=>{V4={};for(let t of ["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])V4[`[object ${t}]`]=t.toLowerCase();});var pr,Y4=Ie(()=>{ob();pr=(t,e=null)=>t.length>=3?Array.prototype.slice.call(t):kr(t[0])=="object"&&e?e.split("").filter(n=>t[0][n]!==void 0).map(n=>t[0][n]):t[0].slice(0);});var Uu,W4=Ie(()=>{ob();Uu=t=>{if(t.length<2)return null;let e=t.length-1;return kr(t[e])=="string"?t[e].toLowerCase():null};});function gE(t){return [...t.slice(0,3).reverse(),...t.slice(3)]}var hE,fE,pE,Qs,sb,Pl,dE,X4,Q4,Xr=Ie(()=>{$4();cE();ob();Y4();W4();(({PI:hE,min:fE,max:pE}=Math)),Qs=t=>Math.round(t*100)/100,sb=t=>Math.round(t*100)/100,Pl=hE*2,dE=hE/3,X4=hE/180,Q4=180/hE;});var Kr,Wo=Ie(()=>{Kr={format:{},autodetect:[]};});var pC,Pe,An=Ie(()=>{Xr();Wo();pC=class{constructor(...e){let n=this;if(kr(e[0])==="object"&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let s=Uu(e),i=false;if(!s){i=true,Kr.sorted||(Kr.autodetect=Kr.autodetect.sort((r,o)=>o.p-r.p),Kr.sorted=true);for(let r of Kr.autodetect)if(s=r.test(...e),s)break}if(Kr.format[s]){let r=Kr.format[s].apply(null,i?e:e.slice(0,-1));n._rgb=Sy(r);}else throw new Error("unknown format: "+e);n._rgb.length===3&&n._rgb.push(1);}toString(){return kr(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}},Pe=pC;});var J4,Z4=Ie(()=>{J4="3.2.0";});var t8,Qr,Mo=Ie(()=>{An();Z4();t8=(...t)=>new Pe(...t);t8.version=J4;Qr=t8;});var Hlt,wd,dC=Ie(()=>{Hlt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},wd=Hlt;});var Glt,qlt,zlt,yE,gC=Ie(()=>{Glt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,qlt=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,zlt=t=>{if(t.match(Glt)){(t.length===4||t.length===7)&&(t=t.substr(1)),t.length===3&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);let e=parseInt(t,16),n=e>>16,s=e>>8&255,i=e&255;return [n,s,i,1]}if(t.match(qlt)){(t.length===5||t.length===9)&&(t=t.substr(1)),t.length===4&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);let e=parseInt(t,16),n=e>>24&255,s=e>>16&255,i=e>>8&255,r=Math.round((e&255)/255*100)/100;return [n,s,i,r]}throw new Error(`unknown hex color: ${t}`)},yE=zlt;});var mE,$lt,vE,yC=Ie(()=>{Xr();(({round:mE}=Math)),$lt=(...t)=>{let[e,n,s,i]=pr(t,"rgba"),r=Uu(t)||"auto";i===void 0&&(i=1),r==="auto"&&(r=i<1?"rgba":"rgb"),e=mE(e),n=mE(n),s=mE(s);let a="000000"+(e<<16|n<<8|s).toString(16);a=a.substr(a.length-6);let c="0"+mE(i*255).toString(16);switch(c=c.substr(c.length-2),r.toLowerCase()){case "rgba":return `#${a}${c}`;case "argb":return `#${c}${a}`;default:return `#${a}`}},vE=$lt;});var e8=Ie(()=>{An();Wo();Xr();dC();gC();yC();Pe.prototype.name=function(){let t=vE(this._rgb,"rgb");for(let e of Object.keys(wd))if(wd[e]===t)return e.toLowerCase();return t};Kr.format.named=t=>{if(t=t.toLowerCase(),wd[t])return yE(wd[t]);throw new Error("unknown color name: "+t)};Kr.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&wd[t.toLowerCase()])return "named"}});});var r8=Ie(()=>{An();Xr();Pe.prototype.alpha=function(t,e=false){return t!==void 0&&kr(t)==="number"?e?(this._rgb[3]=t,this):new Pe([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]};});var n8=Ie(()=>{An();Pe.prototype.clipped=function(){return this._rgb._clipped||false};});function Dl(t){let e=Vlt.get(String(t).toLowerCase());if(!e)throw new Error("unknown Lab illuminant "+t);ab.labWhitePoint=t,ab.Xn=e[0],ab.Zn=e[1];}function Cd(){return ab.labWhitePoint}var ab,_h,Vlt,Nd=Ie(()=>{ab={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:.008856451679035631,kKE:8,kK:903.2962962962963,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-0.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-0.2040259135167538,m20:-0.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-0.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-0.0685,m20:-0.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-0.008528664575177328,m10:-0.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},_h=ab,Vlt=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);});var Ylt,Wlt,mC,vC,z0,ub=Ie(()=>{Nd();Xr();Ylt=(...t)=>{t=pr(t,"lab");let[e,n,s]=t,[i,r,o]=Wlt(e,n,s),[a,c,v]=vC(i,r,o);return [a,c,v,t.length>3?t[3]:1]},Wlt=(t,e,n)=>{let{kE:s,kK:i,kKE:r,Xn:o,Yn:a,Zn:c}=_h,v=(t+16)/116,y=.002*e+v,g=v-.005*n,h=y*y*y,u=g*g*g,d=h>s?h:(116*y-16)/i,f=t>r?Math.pow((t+16)/116,3):t/i,l=u>s?u:(116*g-16)/i,p=d*o,x=f*a,b=l*c;return [p,x,b]},mC=t=>{let e=Math.sign(t);return t=Math.abs(t),(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*e},vC=(t,e,n)=>{let{MtxAdaptMa:s,MtxAdaptMaI:i,MtxXYZ2RGB:r,RefWhiteRGB:o,Xn:a,Yn:c,Zn:v}=_h,y=a*s.m00+c*s.m10+v*s.m20,g=a*s.m01+c*s.m11+v*s.m21,h=a*s.m02+c*s.m12+v*s.m22,u=o.X*s.m00+o.Y*s.m10+o.Z*s.m20,d=o.X*s.m01+o.Y*s.m11+o.Z*s.m21,f=o.X*s.m02+o.Y*s.m12+o.Z*s.m22,l=(t*s.m00+e*s.m10+n*s.m20)*(u/y),p=(t*s.m01+e*s.m11+n*s.m21)*(d/g),x=(t*s.m02+e*s.m12+n*s.m22)*(f/h),b=l*i.m00+p*i.m10+x*i.m20,S=l*i.m01+p*i.m11+x*i.m21,_=l*i.m02+p*i.m12+x*i.m22,T=mC(b*r.m00+S*r.m10+_*r.m20),k=mC(b*r.m01+S*r.m11+_*r.m21),R=mC(b*r.m02+S*r.m12+_*r.m22);return [T*255,k*255,R*255]},z0=Ylt;});function Qlt(t,e,n){let{Xn:s,Yn:i,Zn:r,kE:o,kK:a}=_h,c=t/s,v=e/i,y=n/r,g=c>o?Math.pow(c,1/3):(a*c+16)/116,h=v>o?Math.pow(v,1/3):(a*v+16)/116,u=y>o?Math.pow(y,1/3):(a*y+16)/116;return [116*h-16,500*(g-h),200*(h-u)]}function xC(t){let e=Math.sign(t);return t=Math.abs(t),(t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*e}var Xlt,_C,$0,lb=Ie(()=>{Nd();Xr();Xlt=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=_C(e,n,s),[c,v,y]=Qlt(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]};_C=(t,e,n)=>{t=xC(t/255),e=xC(e/255),n=xC(n/255);let{MtxRGB2XYZ:s,MtxAdaptMa:i,MtxAdaptMaI:r,Xn:o,Yn:a,Zn:c,As:v,Bs:y,Cs:g}=_h,h=t*s.m00+e*s.m10+n*s.m20,u=t*s.m01+e*s.m11+n*s.m21,d=t*s.m02+e*s.m12+n*s.m22,f=o*i.m00+a*i.m10+c*i.m20,l=o*i.m01+a*i.m11+c*i.m21,p=o*i.m02+a*i.m12+c*i.m22,x=h*i.m00+u*i.m10+d*i.m20,b=h*i.m01+u*i.m11+d*i.m21,S=h*i.m02+u*i.m12+d*i.m22;return x*=f/v,b*=l/y,S*=p/g,h=x*r.m00+b*r.m10+S*r.m20,u=x*r.m01+b*r.m11+S*r.m21,d=x*r.m02+b*r.m12+S*r.m22,[h,u,d]},$0=Xlt;});var Jlt,V0=Ie(()=>{Xr();Mo();An();Wo();ub();lb();Nd();Pe.prototype.lab=function(){return $0(this._rgb)};Jlt=(...t)=>new Pe(...t,"lab");Object.assign(Qr,{lab:Jlt,getLabWhitePoint:Cd,setLabWhitePoint:Dl});Kr.format.lab=z0;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"lab"),kr(t)==="array"&&t.length===3)return "lab"}});});var i8=Ie(()=>{V0();An();Nd();Pe.prototype.darken=function(t=1){let e=this,n=e.lab();return n[0]-=_h.Kn*t,new Pe(n,"lab").alpha(e.alpha(),true)};Pe.prototype.brighten=function(t=1){return this.darken(-t)};Pe.prototype.darker=Pe.prototype.darken;Pe.prototype.brighter=Pe.prototype.brighten;});var o8=Ie(()=>{An();Pe.prototype.get=function(t){let[e,n]=t.split("."),s=this[e]();if(n){let i=e.indexOf(n)-(e.substr(0,2)==="ok"?2:0);if(i>-1)return s[i];throw new Error(`unknown channel ${n} in mode ${e}`)}else return s};});var Zlt,tct,ect,rct,bC,TC=Ie(()=>{An();Xr();(({pow:Zlt}=Math)),tct=1e-7,ect=20;Pe.prototype.luminance=function(t,e="rgb"){if(t!==void 0&&kr(t)==="number"){if(t===0)return new Pe([0,0,0,this._rgb[3]],"rgb");if(t===1)return new Pe([255,255,255,this._rgb[3]],"rgb");let n=this.luminance(),s=ect,i=(o,a)=>{let c=o.interpolate(a,.5,e),v=c.luminance();return Math.abs(t-v)<tct||!s--?c:v>t?i(o,c):i(c,a)},r=(n>t?i(new Pe([0,0,0]),this):i(this,new Pe([255,255,255]))).rgb();return new Pe([...r,this._rgb[3]])}return rct(...this._rgb.slice(0,3))};rct=(t,e,n)=>(t=bC(t),e=bC(e),n=bC(n),.2126*t+.7152*e+.0722*n),bC=t=>(t/=255,t<=.03928?t/12.92:Zlt((t+.055)/1.055,2.4));});var Bi,ju=Ie(()=>{Bi={};});var bh,cb=Ie(()=>{An();Xr();ju();bh=(t,e,n=.5,...s)=>{let i=s[0]||"lrgb";if(!Bi[i]&&!s.length&&(i=Object.keys(Bi)[0]),!Bi[i])throw new Error(`interpolation mode ${i} is not defined`);return kr(t)!=="object"&&(t=new Pe(t)),kr(e)!=="object"&&(e=new Pe(e)),Bi[i](t,e,n).alpha(t.alpha()+n*(e.alpha()-t.alpha()))};});var s8=Ie(()=>{An();cb();Pe.prototype.mix=Pe.prototype.interpolate=function(t,e=.5,...n){return bh(this,t,e,...n)};});var a8=Ie(()=>{An();Pe.prototype.premultiply=function(t=false){let e=this._rgb,n=e[3];return t?(this._rgb=[e[0]*n,e[1]*n,e[2]*n,n],this):new Pe([e[0]*n,e[1]*n,e[2]*n,n],"rgb")};});var nct,ict,oct,xE,EC=Ie(()=>{Xr();(({sin:nct,cos:ict}=Math)),oct=(...t)=>{let[e,n,s]=pr(t,"lch");return isNaN(s)&&(s=0),s=s*X4,[e,ict(s)*n,nct(s)*n]},xE=oct;});var sct,Y0,_E=Ie(()=>{Xr();EC();ub();sct=(...t)=>{t=pr(t,"lch");let[e,n,s]=t,[i,r,o]=xE(e,n,s),[a,c,v]=z0(i,r,o);return [a,c,v,t.length>3?t[3]:1]},Y0=sct;});var act,u8,l8=Ie(()=>{Xr();_E();act=(...t)=>{let e=gE(pr(t,"hcl"));return Y0(...e)},u8=act;});var uct,lct,cct,hct,bE,SC=Ie(()=>{Xr();(({sqrt:uct,atan2:lct,round:cct}=Math)),hct=(...t)=>{let[e,n,s]=pr(t,"lab"),i=uct(n*n+s*s),r=(lct(s,n)*Q4+360)%360;return cct(i*1e4)===0&&(r=Number.NaN),[e,i,r]},bE=hct;});var fct,hb,OC=Ie(()=>{Xr();lb();SC();fct=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=$0(e,n,s),[c,v,y]=bE(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},hb=fct;});var pct,dct,fb=Ie(()=>{Xr();Mo();An();Wo();_E();l8();OC();Pe.prototype.lch=function(){return hb(this._rgb)};Pe.prototype.hcl=function(){return gE(hb(this._rgb))};pct=(...t)=>new Pe(...t,"lch"),dct=(...t)=>new Pe(...t,"hcl");Object.assign(Qr,{lch:pct,hcl:dct});Kr.format.lch=Y0;Kr.format.hcl=u8;["lch","hcl"].forEach(t=>Kr.autodetect.push({p:2,test:(...e)=>{if(e=pr(e,t),kr(e)==="array"&&e.length===3)return t}}));});var c8=Ie(()=>{fb();An();Nd();Pe.prototype.saturate=function(t=1){let e=this,n=e.lch();return n[1]+=_h.Kn*t,n[1]<0&&(n[1]=0),new Pe(n,"lch").alpha(e.alpha(),true)};Pe.prototype.desaturate=function(t=1){return this.saturate(-t)};});var h8=Ie(()=>{An();Xr();Pe.prototype.set=function(t,e,n=false){let[s,i]=t.split("."),r=this[s]();if(i){let o=s.indexOf(i)-(s.substr(0,2)==="ok"?2:0);if(o>-1){if(kr(e)=="string")switch(e.charAt(0)){case "+":r[o]+=+e;break;case "-":r[o]+=+e;break;case "*":r[o]*=+e.substr(1);break;case "/":r[o]/=+e.substr(1);break;default:r[o]=+e;}else if(kr(e)==="number")r[o]=e;else throw new Error("unsupported value for Color.set");let a=new Pe(r,s);return n?(this._rgb=a._rgb,this):a}throw new Error(`unknown channel ${i} in mode ${s}`)}else return r};});var f8=Ie(()=>{V0();An();cb();Pe.prototype.tint=function(t=.5,...e){return bh(this,"white",t,...e)};Pe.prototype.shade=function(t=.5,...e){return bh(this,"black",t,...e)};});var gct,p8=Ie(()=>{An();ju();gct=(t,e,n)=>{let s=t._rgb,i=e._rgb;return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"rgb")};Bi.rgb=gct;});var AC,W0,yct,d8=Ie(()=>{An();ju();(({sqrt:AC,pow:W0}=Math)),yct=(t,e,n)=>{let[s,i,r]=t._rgb,[o,a,c]=e._rgb;return new Pe(AC(W0(s,2)*(1-n)+W0(o,2)*n),AC(W0(i,2)*(1-n)+W0(a,2)*n),AC(W0(r,2)*(1-n)+W0(c,2)*n),"rgb")};Bi.lrgb=yct;});var mct,g8=Ie(()=>{V0();ju();An();mct=(t,e,n)=>{let s=t.lab(),i=e.lab();return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"lab")};Bi.lab=mct;});var kl,Oy=Ie(()=>{An();kl=(t,e,n,s)=>{let i,r;s==="hsl"?(i=t.hsl(),r=e.hsl()):s==="hsv"?(i=t.hsv(),r=e.hsv()):s==="hcg"?(i=t.hcg(),r=e.hcg()):s==="hsi"?(i=t.hsi(),r=e.hsi()):s==="lch"||s==="hcl"?(s="hcl",i=t.hcl(),r=e.hcl()):s==="oklch"&&(i=t.oklch().reverse(),r=e.oklch().reverse());let o,a,c,v,y,g;(s.substr(0,1)==="h"||s==="oklch")&&([o,c,y]=i,[a,v,g]=r);let h,u,d,f;return !isNaN(o)&&!isNaN(a)?(a>o&&a-o>180?f=a-(o+360):a<o&&o-a>180?f=a+360-o:f=a-o,u=o+n*f):isNaN(o)?isNaN(a)?u=Number.NaN:(u=a,(y==1||y==0)&&s!="hsv"&&(h=v)):(u=o,(g==1||g==0)&&s!="hsv"&&(h=c)),h===void 0&&(h=c+n*(v-c)),d=y+n*(g-y),s==="oklch"?new Pe([d,h,u],s):new Pe([u,h,d],s)};});var y8,m8=Ie(()=>{fb();Oy();ju();y8=(t,e,n)=>kl(t,e,n,"lch");Bi.lch=y8;Bi.hcl=y8;});var vct,v8,x8=Ie(()=>{Xr();vct=t=>{if(kr(t)=="number"&&t>=0&&t<=16777215){let e=t>>16,n=t>>8&255,s=t&255;return [e,n,s,1]}throw new Error("unknown num color: "+t)},v8=vct;});var xct,_8,b8=Ie(()=>{Xr();xct=(...t)=>{let[e,n,s]=pr(t,"rgb");return (e<<16)+(n<<8)+s},_8=xct;});var _ct,wC=Ie(()=>{Mo();An();Wo();Xr();x8();b8();Pe.prototype.num=function(){return _8(this._rgb)};_ct=(...t)=>new Pe(...t,"num");Object.assign(Qr,{num:_ct});Kr.format.num=v8;Kr.autodetect.push({p:5,test:(...t)=>{if(t.length===1&&kr(t[0])==="number"&&t[0]>=0&&t[0]<=16777215)return "num"}});});var bct,T8=Ie(()=>{wC();ju();An();bct=(t,e,n)=>{let s=t.num(),i=e.num();return new Pe(s+n*(i-s),"num")};Bi.num=bct;});var Tct,Ect,E8,S8=Ie(()=>{Xr();(({floor:Tct}=Math)),Ect=(...t)=>{t=pr(t,"hcg");let[e,n,s]=t,i,r,o;s=s*255;let a=n*255;if(n===0)i=r=o=s;else {e===360&&(e=0),e>360&&(e-=360),e<0&&(e+=360),e/=60;let c=Tct(e),v=e-c,y=s*(1-n),g=y+a*(1-v),h=y+a*v,u=y+a;switch(c){case 0:[i,r,o]=[u,h,y];break;case 1:[i,r,o]=[g,u,y];break;case 2:[i,r,o]=[y,u,h];break;case 3:[i,r,o]=[y,g,u];break;case 4:[i,r,o]=[h,y,u];break;case 5:[i,r,o]=[u,y,g];break}}return [i,r,o,t.length>3?t[3]:1]},E8=Ect;});var Sct,O8,A8=Ie(()=>{Xr();Sct=(...t)=>{let[e,n,s]=pr(t,"rgb"),i=fE(e,n,s),r=pE(e,n,s),o=r-i,a=o*100/255,c=i/(255-o)*100,v;return o===0?v=Number.NaN:(e===r&&(v=(n-s)/o),n===r&&(v=2+(s-e)/o),s===r&&(v=4+(e-n)/o),v*=60,v<0&&(v+=360)),[v,a,c]},O8=Sct;});var Oct,CC=Ie(()=>{Xr();Mo();An();Wo();S8();A8();Pe.prototype.hcg=function(){return O8(this._rgb)};Oct=(...t)=>new Pe(...t,"hcg");Qr.hcg=Oct;Kr.format.hcg=E8;Kr.autodetect.push({p:1,test:(...t)=>{if(t=pr(t,"hcg"),kr(t)==="array"&&t.length===3)return "hcg"}});});var Act,w8=Ie(()=>{CC();Oy();ju();Act=(t,e,n)=>kl(t,e,n,"hcg");Bi.hcg=Act;});var X0,wct,C8,N8=Ie(()=>{Xr();(({cos:X0}=Math)),wct=(...t)=>{t=pr(t,"hsi");let[e,n,s]=t,i,r,o;return isNaN(e)&&(e=0),isNaN(n)&&(n=0),e>360&&(e-=360),e<0&&(e+=360),e/=360,e<1/3?(o=(1-n)/3,i=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,r=1-(o+i)):e<2/3?(e-=1/3,i=(1-n)/3,r=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,o=1-(i+r)):(e-=2/3,r=(1-n)/3,o=(1+n*X0(Pl*e)/X0(dE-Pl*e))/3,i=1-(r+o)),i=Il(s*i*3),r=Il(s*r*3),o=Il(s*o*3),[i*255,r*255,o*255,t.length>3?t[3]:1]},C8=wct;});var Cct,Nct,Rct,Lct,R8,L8=Ie(()=>{Xr();(({min:Cct,sqrt:Nct,acos:Rct}=Math)),Lct=(...t)=>{let[e,n,s]=pr(t,"rgb");e/=255,n/=255,s/=255;let i,r=Cct(e,n,s),o=(e+n+s)/3,a=o>0?1-r/o:0;return a===0?i=NaN:(i=(e-n+(e-s))/2,i/=Nct((e-n)*(e-n)+(e-s)*(n-s)),i=Rct(i),s>n&&(i=Pl-i),i/=Pl),[i*360,a,o]},R8=Lct;});var Ict,NC=Ie(()=>{Xr();Mo();An();Wo();N8();L8();Pe.prototype.hsi=function(){return R8(this._rgb)};Ict=(...t)=>new Pe(...t,"hsi");Qr.hsi=Ict;Kr.format.hsi=C8;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsi"),kr(t)==="array"&&t.length===3)return "hsi"}});});var Pct,I8=Ie(()=>{NC();Oy();ju();Pct=(t,e,n)=>kl(t,e,n,"hsi");Bi.hsi=Pct;});var Dct,pb,RC=Ie(()=>{Xr();Dct=(...t)=>{t=pr(t,"hsl");let[e,n,s]=t,i,r,o;if(n===0)i=r=o=s*255;else {let a=[0,0,0],c=[0,0,0],v=s<.5?s*(1+n):s+n-s*n,y=2*s-v,g=e/360;a[0]=g+1/3,a[1]=g,a[2]=g-1/3;for(let h=0;h<3;h++)a[h]<0&&(a[h]+=1),a[h]>1&&(a[h]-=1),6*a[h]<1?c[h]=y+(v-y)*6*a[h]:2*a[h]<1?c[h]=v:3*a[h]<2?c[h]=y+(v-y)*(2/3-a[h])*6:c[h]=y;[i,r,o]=[c[0]*255,c[1]*255,c[2]*255];}return t.length>3?[i,r,o,t[3]]:[i,r,o,1]},pb=Dct;});var kct,TE,LC=Ie(()=>{Xr();kct=(...t)=>{t=pr(t,"rgba");let[e,n,s]=t;e/=255,n/=255,s/=255;let i=fE(e,n,s),r=pE(e,n,s),o=(r+i)/2,a,c;return r===i?(a=0,c=Number.NaN):a=o<.5?(r-i)/(r+i):(r-i)/(2-r-i),e==r?c=(n-s)/(r-i):n==r?c=2+(s-e)/(r-i):s==r&&(c=4+(e-n)/(r-i)),c*=60,c<0&&(c+=360),t.length>3&&t[3]!==void 0?[c,a,o,t[3]]:[c,a,o]},TE=kct;});var Mct,EE=Ie(()=>{Xr();Mo();An();Wo();RC();LC();Pe.prototype.hsl=function(){return TE(this._rgb)};Mct=(...t)=>new Pe(...t,"hsl");Qr.hsl=Mct;Kr.format.hsl=pb;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsl"),kr(t)==="array"&&t.length===3)return "hsl"}});});var Kct,P8=Ie(()=>{EE();Oy();ju();Kct=(t,e,n)=>kl(t,e,n,"hsl");Bi.hsl=Kct;});var Fct,Bct,D8,k8=Ie(()=>{Xr();(({floor:Fct}=Math)),Bct=(...t)=>{t=pr(t,"hsv");let[e,n,s]=t,i,r,o;if(s*=255,n===0)i=r=o=s;else {e===360&&(e=0),e>360&&(e-=360),e<0&&(e+=360),e/=60;let a=Fct(e),c=e-a,v=s*(1-n),y=s*(1-n*c),g=s*(1-n*(1-c));switch(a){case 0:[i,r,o]=[s,g,v];break;case 1:[i,r,o]=[y,s,v];break;case 2:[i,r,o]=[v,s,g];break;case 3:[i,r,o]=[v,y,s];break;case 4:[i,r,o]=[g,v,s];break;case 5:[i,r,o]=[s,v,y];break}}return [i,r,o,t.length>3?t[3]:1]},D8=Bct;});var Uct,jct,Hct,M8,K8=Ie(()=>{Xr();(({min:Uct,max:jct}=Math)),Hct=(...t)=>{t=pr(t,"rgb");let[e,n,s]=t,i=Uct(e,n,s),r=jct(e,n,s),o=r-i,a,c,v;return v=r/255,r===0?(a=Number.NaN,c=0):(c=o/r,e===r&&(a=(n-s)/o),n===r&&(a=2+(s-e)/o),s===r&&(a=4+(e-n)/o),a*=60,a<0&&(a+=360)),[a,c,v]},M8=Hct;});var Gct,IC=Ie(()=>{Xr();Mo();An();Wo();k8();K8();Pe.prototype.hsv=function(){return M8(this._rgb)};Gct=(...t)=>new Pe(...t,"hsv");Qr.hsv=Gct;Kr.format.hsv=D8;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"hsv"),kr(t)==="array"&&t.length===3)return "hsv"}});});var qct,F8=Ie(()=>{IC();Oy();ju();qct=(t,e,n)=>kl(t,e,n,"hsv");Bi.hsv=qct;});function Ay(t,e){let n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(o=>[o]));let s=e[0].length,i=e[0].map((o,a)=>e.map(c=>c[a])),r=t.map(o=>i.map(a=>Array.isArray(o)?o.reduce((c,v,y)=>c+v*(a[y]||0),0):a.reduce((c,v)=>c+v*o,0)));return n===1&&(r=r[0]),s===1?r.map(o=>o[0]):r}var PC=Ie(()=>{});function $ct(t){var e=[[1.2268798758459243,-0.5578149944602171,.2813910456659647],[-0.0405757452148008,1.112286803280317,-0.0717110580655164],[-0.0763729366746601,-0.4214933324022432,1.5869240198367816]],n=[[1,.3963377773761749,.2158037573099136],[1,-0.1055613458156586,-0.0638541728258133],[1,-0.0894841775298119,-1.2914855480194092]],s=Ay(n,t);return Ay(e,s.map(i=>i**3))}var zct,Q0,SE=Ie(()=>{Xr();PC();ub();zct=(...t)=>{t=pr(t,"lab");let[e,n,s,...i]=t,[r,o,a]=$ct([e,n,s]),[c,v,y]=vC(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]};Q0=zct;});function Yct(t){let e=[[.819022437996703,.3619062600528904,-0.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],n=[[.210454268309314,.7936177747023054,-0.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-0.8086757549230774]],s=Ay(e,t);return Ay(n,s.map(i=>Math.cbrt(i)))}var Vct,J0,OE=Ie(()=>{Xr();PC();lb();Vct=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),r=_C(e,n,s);return [...Yct(r),...i.length>0&&i[0]<1?[i[0]]:[]]};J0=Vct;});var Wct,DC=Ie(()=>{Xr();Mo();An();Wo();SE();OE();Pe.prototype.oklab=function(){return J0(this._rgb)};Wct=(...t)=>new Pe(...t,"oklab");Object.assign(Qr,{oklab:Wct});Kr.format.oklab=Q0;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"oklab"),kr(t)==="array"&&t.length===3)return "oklab"}});});var Xct,B8=Ie(()=>{DC();ju();An();Xct=(t,e,n)=>{let s=t.oklab(),i=e.oklab();return new Pe(s[0]+n*(i[0]-s[0]),s[1]+n*(i[1]-s[1]),s[2]+n*(i[2]-s[2]),"oklab")};Bi.oklab=Xct;});var Qct,U8=Ie(()=>{fb();Oy();ju();Qct=(t,e,n)=>kl(t,e,n,"oklch");Bi.oklch=Qct;});var kC,MC,KC,j8,H8,Jct,G8,Zct,q8=Ie(()=>{An();Xr();(({pow:kC,sqrt:MC,PI:KC,cos:j8,sin:H8,atan2:Jct}=Math)),G8=(t,e="lrgb",n=null)=>{let s=t.length;n||(n=Array.from(new Array(s)).map(()=>1));let i=s/n.reduce(function(g,h){return g+h});if(n.forEach((g,h)=>{n[h]*=i;}),t=t.map(g=>new Pe(g)),e==="lrgb")return Zct(t,n);let r=t.shift(),o=r.get(e),a=[],c=0,v=0;for(let g=0;g<o.length;g++)if(o[g]=(o[g]||0)*n[0],a.push(isNaN(o[g])?0:n[0]),e.charAt(g)==="h"&&!isNaN(o[g])){let h=o[g]/180*KC;c+=j8(h)*n[0],v+=H8(h)*n[0];}let y=r.alpha()*n[0];t.forEach((g,h)=>{let u=g.get(e);y+=g.alpha()*n[h+1];for(let d=0;d<o.length;d++)if(!isNaN(u[d]))if(a[d]+=n[h+1],e.charAt(d)==="h"){let f=u[d]/180*KC;c+=j8(f)*n[h+1],v+=H8(f)*n[h+1];}else o[d]+=u[d]*n[h+1];});for(let g=0;g<o.length;g++)if(e.charAt(g)==="h"){let h=Jct(v/a[g],c/a[g])/KC*180;for(;h<0;)h+=360;for(;h>=360;)h-=360;o[g]=h;}else o[g]=o[g]/a[g];return y/=s,new Pe(o,e).alpha(y>.99999?1:y,true)},Zct=(t,e)=>{let n=t.length,s=[0,0,0,0];for(let i=0;i<t.length;i++){let r=t[i],o=e[i]/n,a=r._rgb;s[0]+=kC(a[0],2)*o,s[1]+=kC(a[1],2)*o,s[2]+=kC(a[2],2)*o,s[3]+=a[3]*o;}return s[0]=MC(s[0]),s[1]=MC(s[1]),s[2]=MC(s[2]),s[3]>.9999999&&(s[3]=1),new Pe(Sy(s))};});function wy(t){let e="rgb",n=Qr("#ccc"),s=0,i=[0,1],r=[0,1],o=[],a=[0,0],c=false,v=[],y=false,g=0,h=1,u=false,d={},f=true,l=1,p=function(R){if(R=R||["#fff","#000"],R&&kr(R)==="string"&&Qr.brewer&&Qr.brewer[R.toLowerCase()]&&(R=Qr.brewer[R.toLowerCase()]),kr(R)==="array"){R.length===1&&(R=[R[0],R[0]]),R=R.slice(0);for(let I=0;I<R.length;I++)R[I]=Qr(R[I]);o.length=0;for(let I=0;I<R.length;I++)o.push(I/(R.length-1));}return T(),v=R},x=function(R){if(c!=null){let I=c.length-1,F=0;for(;F<I&&R>=c[F];)F++;return F-1}return 0},b=R=>R,S=R=>R,_=function(R,I){let F,B;if(I==null&&(I=false),isNaN(R)||R===null)return n;I?B=R:c&&c.length>2?B=x(R)/(c.length-2):h!==g?B=(R-g)/(h-g):B=1,B=S(B),I||(B=b(B)),l!==1&&(B=tht(B,l)),B=a[0]+B*(1-a[0]-a[1]),B=Il(B,0,1);let P=Math.floor(B*1e4);if(f&&d[P])F=d[P];else {if(kr(v)==="array")for(let K=0;K<o.length;K++){let G=o[K];if(B<=G){F=v[K];break}if(B>=G&&K===o.length-1){F=v[K];break}if(B>G&&B<o[K+1]){B=(B-G)/(o[K+1]-G),F=Qr.interpolate(v[K],v[K+1],B,e);break}}else kr(v)==="function"&&(F=v(B));f&&(d[P]=F);}return F};var T=()=>d={};p(t);let k=function(R){let I=Qr(_(R));return y&&I[y]?I[y]():I};return k.classes=function(R){if(R!=null){if(kr(R)==="array")c=R,i=[R[0],R[R.length-1]];else {let I=Qr.analyze(i);R===0?c=[I.min,I.max]:c=Qr.limits(I,"e",R);}return k}return c},k.domain=function(R){if(!arguments.length)return r;r=R.slice(0),g=R[0],h=R[R.length-1],o=[];let I=v.length;if(R.length===I&&g!==h)for(let F of Array.from(R))o.push((F-g)/(h-g));else {for(let F=0;F<I;F++)o.push(F/(I-1));if(R.length>2){let F=R.map((P,K)=>K/(R.length-1)),B=R.map(P=>(P-g)/(h-g));B.every((P,K)=>F[K]===P)||(S=P=>{if(P<=0||P>=1)return P;let K=0;for(;P>=B[K+1];)K++;let G=(P-B[K])/(B[K+1]-B[K]);return F[K]+G*(F[K+1]-F[K])});}}return i=[g,h],k},k.mode=function(R){return arguments.length?(e=R,T(),k):e},k.range=function(R,I){return p(R),k},k.out=function(R){return y=R,k},k.spread=function(R){return arguments.length?(s=R,k):s},k.correctLightness=function(R){return R==null&&(R=true),u=R,T(),u?b=function(I){let F=_(0,true).lab()[0],B=_(1,true).lab()[0],P=F>B,K=_(I,true).lab()[0],G=F+(B-F)*I,V=K-G,Q=0,rt=1,ht=20;for(;Math.abs(V)>.01&&ht-- >0;)(function(){return P&&(V*=-1),V<0?(Q=I,I+=(rt-I)*.5):(rt=I,I+=(Q-I)*.5),K=_(I,true).lab()[0],V=K-G})();return I}:b=I=>I,k},k.padding=function(R){return R!=null?(kr(R)==="number"&&(R=[R,R]),a=R,k):a},k.colors=function(R,I){arguments.length<2&&(I="hex");let F=[];if(arguments.length===0)F=v.slice(0);else if(R===1)F=[k(.5)];else if(R>1){let B=i[0],P=i[1]-B;F=eht(0,R).map(K=>k(B+K/(R-1)*P));}else {t=[];let B=[];if(c&&c.length>2)for(let P=1,K=c.length,G=1<=K;G?P<K:P>K;G?P++:P--)B.push((c[P-1]+c[P])*.5);else B=i;F=B.map(P=>k(P));}return Qr[I]&&(F=F.map(B=>B[I]())),F},k.cache=function(R){return R!=null?(f=R,k):f},k.gamma=function(R){return R!=null?(l=R,k):l},k.nodata=function(R){return R!=null?(n=Qr(R),k):n},k}function eht(t,e,n){let s=[],i=t<e,r=e;for(let o=t;i?o<r:o>r;i?o++:o--)s.push(o);return s}var tht,AE=Ie(()=>{Mo();Xr();({pow:tht}=Math);});var rht,nht,z8,$8=Ie(()=>{An();V0();AE();rht=function(t){let e=[1,1];for(let n=1;n<t;n++){let s=[1];for(let i=1;i<=e.length;i++)s[i]=(e[i]||0)+e[i-1];e=s;}return e},nht=function(t){let e,n,s,i;if(t=t.map(r=>new Pe(r)),t.length===2)[n,s]=t.map(r=>r.lab()),e=function(r){let o=[0,1,2].map(a=>n[a]+r*(s[a]-n[a]));return new Pe(o,"lab")};else if(t.length===3)[n,s,i]=t.map(r=>r.lab()),e=function(r){let o=[0,1,2].map(a=>(1-r)*(1-r)*n[a]+2*(1-r)*r*s[a]+r*r*i[a]);return new Pe(o,"lab")};else if(t.length===4){let r;[n,s,i,r]=t.map(o=>o.lab()),e=function(o){let a=[0,1,2].map(c=>(1-o)*(1-o)*(1-o)*n[c]+3*(1-o)*(1-o)*o*s[c]+3*(1-o)*o*o*i[c]+o*o*o*r[c]);return new Pe(a,"lab")};}else if(t.length>=5){let r,o,a;r=t.map(c=>c.lab()),a=t.length-1,o=rht(a),e=function(c){let v=1-c,y=[0,1,2].map(g=>r.reduce((h,u,d)=>h+o[d]*v**(a-d)*c**d*u[g],0));return new Pe(y,"lab")};}else throw new RangeError("No point in running bezier with only one color.");return e},z8=t=>{let e=nht(t);return e.scale=()=>wy(e),e};});var V8,iht,FC=Ie(()=>{Mo();An();Wo();Xr();({round:V8}=Math);Pe.prototype.rgb=function(t=true){return t===false?this._rgb.slice(0,3):this._rgb.slice(0,3).map(V8)};Pe.prototype.rgba=function(t=true){return this._rgb.slice(0,4).map((e,n)=>n<3?t===false?e:V8(e):e)};iht=(...t)=>new Pe(...t,"rgb");Object.assign(Qr,{rgb:iht});Kr.format.rgb=(...t)=>{let e=pr(t,"rgba");return e[3]===void 0&&(e[3]=1),e};Kr.autodetect.push({p:3,test:(...t)=>{if(t=pr(t,"rgba"),kr(t)==="array"&&(t.length===3||t.length===4&&kr(t[3])=="number"&&t[3]>=0&&t[3]<=1))return "rgb"}});});var mc,Rd,Ld,oht,sht,aht,uht,lht,cht,hht,fht,Y8,W8=Ie(()=>{FC();Mo();mc=(t,e,n)=>{if(!mc[n])throw new Error("unknown blend mode "+n);return mc[n](t,e)},Rd=t=>(e,n)=>{let s=Qr(n).rgb(),i=Qr(e).rgb();return Qr.rgb(t(s,i))},Ld=t=>(e,n)=>{let s=[];return s[0]=t(e[0],n[0]),s[1]=t(e[1],n[1]),s[2]=t(e[2],n[2]),s},oht=t=>t,sht=(t,e)=>t*e/255,aht=(t,e)=>t>e?e:t,uht=(t,e)=>t>e?t:e,lht=(t,e)=>255*(1-(1-t/255)*(1-e/255)),cht=(t,e)=>e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255)),hht=(t,e)=>255*(1-(1-e/255)/(t/255)),fht=(t,e)=>t===255?255:(t=255*(e/255)/(1-t/255),t>255?255:t);mc.normal=Rd(Ld(oht));mc.multiply=Rd(Ld(sht));mc.screen=Rd(Ld(lht));mc.overlay=Rd(Ld(cht));mc.darken=Rd(Ld(aht));mc.lighten=Rd(Ld(uht));mc.dodge=Rd(Ld(fht));mc.burn=Rd(Ld(hht));Y8=mc;});function X8(t=300,e=-1.5,n=1,s=1,i=[0,1]){let r=0,o;kr(i)==="array"?o=i[1]-i[0]:(o=0,i=[i,i]);let a=function(c){let v=Pl*((t+120)/360+e*c),y=pht(i[0]+o*c,s),h=(r!==0?n[0]+c*r:n)*y*(1-y)/2,u=ght(v),d=dht(v),f=y+h*(-0.14861*u+1.78277*d),l=y+h*(-0.29227*u-.90649*d),p=y+h*(1.97294*u);return Qr(Sy([f*255,l*255,p*255,1]))};return a.start=function(c){return c==null?t:(t=c,a)},a.rotations=function(c){return c==null?e:(e=c,a)},a.gamma=function(c){return c==null?s:(s=c,a)},a.hue=function(c){return c==null?n:(n=c,kr(n)==="array"?(r=n[1]-n[0],r===0&&(n=n[1])):r=0,a)},a.lightness=function(c){return c==null?i:(kr(c)==="array"?(i=c,o=c[1]-c[0]):(i=[c,c],o=0),a)},a.scale=()=>Qr.scale(a),a.hue(n),a}var pht,dht,ght,Q8=Ie(()=>{Xr();Mo();({pow:pht,sin:dht,cos:ght}=Math);});var yht,mht,vht,J8,Z8=Ie(()=>{An();yht="0123456789abcdef",{floor:mht,random:vht}=Math,J8=(t=vht)=>{let e="#";for(let n=0;n<6;n++)e+=yht.charAt(mht(t()*16));return new Pe(e,"hex")};});function BC(t,e=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return kr(t)==="object"&&(t=Object.values(t)),t.forEach(s=>{e&&kr(s)==="object"&&(s=s[e]),s!=null&&!isNaN(s)&&(n.values.push(s),n.sum+=s,s<n.min&&(n.min=s),s>n.max&&(n.max=s),n.count+=1);}),n.domain=[n.min,n.max],n.limits=(s,i)=>UC(n,s,i),n}function UC(t,e="equal",n=7){kr(t)=="array"&&(t=BC(t));let{min:s,max:i}=t,r=t.values.sort((a,c)=>a-c);if(n===1)return [s,i];let o=[];if(e.substr(0,1)==="c"&&(o.push(s),o.push(i)),e.substr(0,1)==="e"){o.push(s);for(let a=1;a<n;a++)o.push(s+a/n*(i-s));o.push(i);}else if(e.substr(0,1)==="l"){if(s<=0)throw new Error("Logarithmic scales are only possible for values > 0");let a=Math.LOG10E*t9(s),c=Math.LOG10E*t9(i);o.push(s);for(let v=1;v<n;v++)o.push(xht(10,a+v/n*(c-a)));o.push(i);}else if(e.substr(0,1)==="q"){o.push(s);for(let a=1;a<n;a++){let c=(r.length-1)*a/n,v=_ht(c);if(v===c)o.push(r[v]);else {let y=c-v;o.push(r[v]*(1-y)+r[v+1]*y);}}o.push(i);}else if(e.substr(0,1)==="k"){let a,c=r.length,v=new Array(c),y=new Array(n),g=true,h=0,u=null;u=[],u.push(s);for(let l=1;l<n;l++)u.push(s+l/n*(i-s));for(u.push(i);g;){for(let p=0;p<n;p++)y[p]=0;for(let p=0;p<c;p++){let x=r[p],b=Number.MAX_VALUE,S;for(let _=0;_<n;_++){let T=bht(u[_]-x);T<b&&(b=T,S=_),y[S]++,v[p]=S;}}let l=new Array(n);for(let p=0;p<n;p++)l[p]=null;for(let p=0;p<c;p++)a=v[p],l[a]===null?l[a]=r[p]:l[a]+=r[p];for(let p=0;p<n;p++)l[p]*=1/y[p];g=false;for(let p=0;p<n;p++)if(l[p]!==u[p]){g=true;break}u=l,h++,h>200&&(g=false);}let d={};for(let l=0;l<n;l++)d[l]=[];for(let l=0;l<c;l++)a=v[l],d[a].push(r[l]);let f=[];for(let l=0;l<n;l++)f.push(d[l][0]),f.push(d[l][d[l].length-1]);f=f.sort((l,p)=>l-p),o.push(f[0]);for(let l=1;l<f.length;l+=2){let p=f[l];!isNaN(p)&&o.indexOf(p)===-1&&o.push(p);}}return o}var t9,xht,_ht,bht,jC=Ie(()=>{ob();({log:t9,pow:xht,floor:_ht,abs:bht}=Math);});var e9,r9=Ie(()=>{An();TC();e9=(t,e)=>{t=new Pe(t),e=new Pe(e);let n=t.luminance(),s=e.luminance();return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)};});function s9(t,e,n){return .2126729*Math.pow(t/255,2.4)+.7151522*Math.pow(e/255,2.4)+.072175*Math.pow(n/255,2.4)}var n9,Tht,Eht,i9,wE,o9,a9,u9=Ie(()=>{An();cb();n9=.027,Tht=5e-4,Eht=.1,i9=1.14,wE=.022,o9=1.414,a9=(t,e)=>{t=new Pe(t),e=new Pe(e),t.alpha()<1&&(t=bh(e,t,t.alpha(),"rgb"));let n=s9(...t.rgb()),s=s9(...e.rgb()),i=n>=wE?n:n+Math.pow(wE-n,o9),r=s>=wE?s:s+Math.pow(wE-s,o9),o=Math.pow(r,.56)-Math.pow(i,.57),a=Math.pow(r,.65)-Math.pow(i,.62),c=Math.abs(r-i)<Tht?0:i<r?o*i9:a*i9;return (Math.abs(c)<Eht?0:c>0?c-n9:c+n9)*100};});function p9(t,e,n=1,s=1,i=1){var r=function(gt){return 360*gt/(2*f9)},o=function(gt){return 2*f9*gt/360};t=new Pe(t),e=new Pe(e);let[a,c,v]=Array.from(t.lab()),[y,g,h]=Array.from(e.lab()),u=(a+y)/2,d=jf(Xo(c,2)+Xo(v,2)),f=jf(Xo(g,2)+Xo(h,2)),l=(d+f)/2,p=.5*(1-jf(Xo(l,7)/(Xo(l,7)+Xo(25,7)))),x=c*(1+p),b=g*(1+p),S=jf(Xo(x,2)+Xo(v,2)),_=jf(Xo(b,2)+Xo(h,2)),T=(S+_)/2,k=r(l9(v,x)),R=r(l9(h,b)),I=k>=0?k:k+360,F=R>=0?R:R+360,B=c9(I-F)>180?(I+F+360)/2:(I+F)/2,P=1-.17*CE(o(B-30))+.24*CE(o(2*B))+.32*CE(o(3*B+6))-.2*CE(o(4*B-63)),K=F-I;K=c9(K)<=180?K:F<=I?K+360:K-360,K=2*jf(S*_)*h9(o(K)/2);let G=y-a,V=_-S,Q=1+.015*Xo(u-50,2)/jf(20+Xo(u-50,2)),rt=1+.045*T,ht=1+.015*T*P,it=30*Aht(-Xo((B-275)/25,2)),q=-(2*jf(Xo(T,7)/(Xo(T,7)+Xo(25,7))))*h9(2*o(it)),nt=jf(Xo(G/(n*Q),2)+Xo(V/(s*rt),2)+Xo(K/(i*ht),2)+q*(V/(s*rt))*(K/(i*ht)));return Oht(0,Sht(100,nt))}var jf,Xo,Sht,Oht,l9,c9,CE,h9,Aht,f9,d9=Ie(()=>{An();({sqrt:jf,pow:Xo,min:Sht,max:Oht,atan2:l9,abs:c9,cos:CE,sin:h9,exp:Aht,PI:f9}=Math);});function g9(t,e,n="lab"){t=new Pe(t),e=new Pe(e);let s=t.get(n),i=e.get(n),r=0;for(let o in s){let a=(s[o]||0)-(i[o]||0);r+=a*a;}return Math.sqrt(r)}var y9=Ie(()=>{An();});var m9,v9=Ie(()=>{An();m9=(...t)=>{try{return new Pe(...t),!0}catch{return false}};});var x9,_9=Ie(()=>{Mo();EE();AE();x9={cool(){return wy([Qr.hsl(180,1,.9),Qr.hsl(250,.7,.4)])},hot(){return wy(["#000","#f00","#ff0","#fff"]).mode("rgb")}};});var HC,T9,b9,wht,E9,S9=Ie(()=>{HC={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},T9=Object.keys(HC),b9=new Map(T9.map(t=>[t.toLowerCase(),t])),wht=typeof Proxy=="function"?new Proxy(HC,{get(t,e){let n=e.toLowerCase();if(b9.has(n))return t[b9.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(T9)}}):HC,E9=wht;});var Cht,O9,A9=Ie(()=>{Xr();Cht=(...t)=>{t=pr(t,"cmyk");let[e,n,s,i]=t,r=t.length>4?t[4]:1;return i===1?[0,0,0,r]:[e>=1?0:255*(1-e)*(1-i),n>=1?0:255*(1-n)*(1-i),s>=1?0:255*(1-s)*(1-i),r]},O9=Cht;});var w9,Nht,C9,N9=Ie(()=>{Xr();(({max:w9}=Math)),Nht=(...t)=>{let[e,n,s]=pr(t,"rgb");e=e/255,n=n/255,s=s/255;let i=1-w9(e,w9(n,s)),r=i<1?1/(1-i):0,o=(1-e-i)*r,a=(1-n-i)*r,c=(1-s-i)*r;return [o,a,c,i]},C9=Nht;});var Rht,R9=Ie(()=>{Mo();An();Wo();Xr();A9();N9();Pe.prototype.cmyk=function(){return C9(this._rgb)};Rht=(...t)=>new Pe(...t,"cmyk");Object.assign(Qr,{cmyk:Rht});Kr.format.cmyk=O9;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"cmyk"),kr(t)==="array"&&t.length===4)return "cmyk"}});});var Lht,L9,I9=Ie(()=>{Xr();Lht=(...t)=>{let e=pr(t,"hsla"),n=Uu(t)||"lsa";return e[0]=Qs(e[0]||0)+"deg",e[1]=Qs(e[1]*100)+"%",e[2]=Qs(e[2]*100)+"%",n==="hsla"||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),n="hsla"):e.length=3,`${n.substr(0,3)}(${e.join(" ")})`},L9=Lht;});var Iht,P9,D9=Ie(()=>{Xr();Iht=(...t)=>{let e=pr(t,"lab"),n=Uu(t)||"lab";return e[0]=Qs(e[0])+"%",e[1]=Qs(e[1]),e[2]=Qs(e[2]),n==="laba"||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lab(${e.join(" ")})`},P9=Iht;});var Pht,k9,M9=Ie(()=>{Xr();Pht=(...t)=>{let e=pr(t,"lch"),n=Uu(t)||"lab";return e[0]=Qs(e[0])+"%",e[1]=Qs(e[1]),e[2]=isNaN(e[2])?"none":Qs(e[2])+"deg",n==="lcha"||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lch(${e.join(" ")})`},k9=Pht;});var Dht,K9,F9=Ie(()=>{Xr();Dht=(...t)=>{let e=pr(t,"lab");return e[0]=Qs(e[0]*100)+"%",e[1]=sb(e[1]),e[2]=sb(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklab(${e.join(" ")})`},K9=Dht;});var kht,NE,GC=Ie(()=>{Xr();OE();SC();kht=(...t)=>{let[e,n,s,...i]=pr(t,"rgb"),[r,o,a]=J0(e,n,s),[c,v,y]=bE(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},NE=kht;});var Mht,B9,U9=Ie(()=>{Xr();Mht=(...t)=>{let e=pr(t,"lch");return e[0]=Qs(e[0]*100)+"%",e[1]=sb(e[1]),e[2]=isNaN(e[2])?"none":Qs(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklch(${e.join(" ")})`},B9=Mht;});var qC,Kht,j9,H9=Ie(()=>{Xr();I9();LC();D9();lb();M9();OC();OE();F9();GC();U9();Nd();(({round:qC}=Math)),Kht=(...t)=>{let e=pr(t,"rgba"),n=Uu(t)||"rgb";if(n.substr(0,3)==="hsl")return L9(TE(e),n);if(n.substr(0,3)==="lab"){let s=Cd();Dl("d50");let i=P9($0(e),n);return Dl(s),i}if(n.substr(0,3)==="lch"){let s=Cd();Dl("d50");let i=k9(hb(e),n);return Dl(s),i}return n.substr(0,5)==="oklab"?K9(J0(e)):n.substr(0,5)==="oklch"?B9(NE(e)):(e[0]=qC(e[0]),e[1]=qC(e[1]),e[2]=qC(e[2]),(n==="rgba"||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),n="rgba"),`${n.substr(0,3)}(${e.slice(0,n==="rgb"?3:4).join(" ")})`)},j9=Kht;});var Fht,RE,zC=Ie(()=>{Xr();EC();SE();Fht=(...t)=>{t=pr(t,"lch");let[e,n,s,...i]=t,[r,o,a]=xE(e,n,s),[c,v,y]=Q0(r,o,a);return [c,v,y,...i.length>0&&i[0]<1?[i[0]]:[]]},RE=Fht;});var Hf,vc,LE,Ml,tv,$C,IE,ev,G9,q9,z9,$9,V9,Y9,W9,X9,Q9,J9,Z9,Z0,Qo,Ba,tK,VC,eK=Ie(()=>{RC();ub();_E();SE();zC();Wo();cE();Nd();Hf=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,vc=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,LE=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,Ml=/\s*/.source,tv=/\s+/.source,$C=/\s*,\s*/.source,IE=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,ev=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,G9=new RegExp("^rgba?\\("+Ml+[Hf,Hf,Hf].join(tv)+ev+"\\)$"),q9=new RegExp("^rgb\\("+Ml+[Hf,Hf,Hf].join($C)+Ml+"\\)$"),z9=new RegExp("^rgba\\("+Ml+[Hf,Hf,Hf,vc].join($C)+Ml+"\\)$"),$9=new RegExp("^hsla?\\("+Ml+[IE,LE,LE].join(tv)+ev+"\\)$"),V9=new RegExp("^hsl?\\("+Ml+[IE,LE,LE].join($C)+Ml+"\\)$"),Y9=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,W9=new RegExp("^lab\\("+Ml+[vc,vc,vc].join(tv)+ev+"\\)$"),X9=new RegExp("^lch\\("+Ml+[vc,vc,IE].join(tv)+ev+"\\)$"),Q9=new RegExp("^oklab\\("+Ml+[vc,vc,vc].join(tv)+ev+"\\)$"),J9=new RegExp("^oklch\\("+Ml+[vc,vc,IE].join(tv)+ev+"\\)$"),{round:Z9}=Math,Z0=t=>t.map((e,n)=>n<=2?Il(Z9(e),0,255):e),Qo=(t,e=0,n=100,s=false)=>(typeof t=="string"&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,s?t=e+(t+1)*.5*(n-e):t=e+t*(n-e)),+t),Ba=(t,e)=>t==="none"?e:t,tK=t=>{if(t=t.toLowerCase().trim(),t==="transparent")return [0,0,0,0];let e;if(Kr.format.named)try{return Kr.format.named(t)}catch{}if((e=t.match(G9))||(e=t.match(q9))){let n=e.slice(1,4);for(let i=0;i<3;i++)n[i]=+Qo(Ba(n[i],0),0,255);n=Z0(n);let s=e[4]!==void 0?+Qo(e[4],0,1):1;return n[3]=s,n}if(e=t.match(z9)){let n=e.slice(1,5);for(let s=0;s<4;s++)n[s]=+Qo(n[s],0,255);return n}if((e=t.match($9))||(e=t.match(V9))){let n=e.slice(1,4);n[0]=+Ba(n[0].replace("deg",""),0),n[1]=+Qo(Ba(n[1],0),0,100)*.01,n[2]=+Qo(Ba(n[2],0),0,100)*.01;let s=Z0(pb(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}if(e=t.match(Y9)){let n=e.slice(1,4);n[1]*=.01,n[2]*=.01;let s=pb(n);for(let i=0;i<3;i++)s[i]=Z9(s[i]);return s[3]=+e[4],s}if(e=t.match(W9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,100),n[1]=Qo(Ba(n[1],0),-125,125,true),n[2]=Qo(Ba(n[2],0),-125,125,true);let s=Cd();Dl("d50");let i=Z0(z0(n));Dl(s);let r=e[4]!==void 0?+Qo(e[4],0,1):1;return i[3]=r,i}if(e=t.match(X9)){let n=e.slice(1,4);n[0]=Qo(n[0],0,100),n[1]=Qo(Ba(n[1],0),0,150,false),n[2]=+Ba(n[2].replace("deg",""),0);let s=Cd();Dl("d50");let i=Z0(Y0(n));Dl(s);let r=e[4]!==void 0?+Qo(e[4],0,1):1;return i[3]=r,i}if(e=t.match(Q9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,1),n[1]=Qo(Ba(n[1],0),-0.4,.4,true),n[2]=Qo(Ba(n[2],0),-0.4,.4,true);let s=Z0(Q0(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}if(e=t.match(J9)){let n=e.slice(1,4);n[0]=Qo(Ba(n[0],0),0,1),n[1]=Qo(Ba(n[1],0),0,.4,false),n[2]=+Ba(n[2].replace("deg",""),0);let s=Z0(RE(n)),i=e[4]!==void 0?+Qo(e[4],0,1):1;return s[3]=i,s}};tK.test=t=>G9.test(t)||$9.test(t)||W9.test(t)||X9.test(t)||Q9.test(t)||J9.test(t)||q9.test(t)||z9.test(t)||V9.test(t)||Y9.test(t)||t==="transparent";VC=tK;});var Bht,rK=Ie(()=>{Mo();An();Wo();Xr();H9();eK();Pe.prototype.css=function(t){return j9(this._rgb,t)};Bht=(...t)=>new Pe(...t,"css");Qr.css=Bht;Kr.format.css=VC;Kr.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&VC.test(t))return "css"}});});var Uht,nK=Ie(()=>{An();Mo();Wo();Xr();Kr.format.gl=(...t)=>{let e=pr(t,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};Uht=(...t)=>new Pe(...t,"gl");Qr.gl=Uht;Pe.prototype.gl=function(){let t=this._rgb;return [t[0]/255,t[1]/255,t[2]/255,t[3]]};});var jht,iK=Ie(()=>{An();Mo();Xr();Wo();gC();yC();Pe.prototype.hex=function(t){return vE(this._rgb,t)};jht=(...t)=>new Pe(...t,"hex");Qr.hex=jht;Kr.format.hex=yE;Kr.autodetect.push({p:4,test:(t,...e)=>{if(!e.length&&kr(t)==="string"&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return "hex"}});});var PE,Hht,DE,YC=Ie(()=>{(({log:PE}=Math)),Hht=t=>{let e=t/100,n,s,i;return e<66?(n=255,s=e<6?0:-155.25485562709179-.44596950469579133*(s=e-2)+104.49216199393888*PE(s),i=e<20?0:-254.76935184120902+.8274096064007395*(i=e-10)+115.67994401066147*PE(i)):(n=351.97690566805693+.114206453784165*(n=e-55)-40.25366309332127*PE(n),s=325.4494125711974+.07943456536662342*(s=e-50)-28.0852963507957*PE(s),i=255),[n,s,i,1]},DE=Hht;});var Ght,qht,oK,sK=Ie(()=>{YC();Xr();(({round:Ght}=Math)),qht=(...t)=>{let e=pr(t,"rgb"),n=e[0],s=e[2],i=1e3,r=4e4,o=.4,a;for(;r-i>o;){a=(r+i)*.5;let c=DE(a);c[2]/c[0]>=s/n?r=a:i=a;}return Ght(a)},oK=qht;});var WC,aK=Ie(()=>{Mo();An();Wo();YC();sK();Pe.prototype.temp=Pe.prototype.kelvin=Pe.prototype.temperature=function(){return oK(this._rgb)};WC=(...t)=>new Pe(...t,"temp");Object.assign(Qr,{temp:WC,kelvin:WC,temperature:WC});Kr.format.temp=Kr.format.kelvin=Kr.format.temperature=DE;});var zht,uK=Ie(()=>{Xr();Mo();An();Wo();zC();GC();Pe.prototype.oklch=function(){return NE(this._rgb)};zht=(...t)=>new Pe(...t,"oklch");Object.assign(Qr,{oklch:zht});Kr.format.oklch=RE;Kr.autodetect.push({p:2,test:(...t)=>{if(t=pr(t,"oklch"),kr(t)==="array"&&t.length===3)return "oklch"}});});var XC,lK=Ie(()=>{Mo();e8();r8();n8();i8();o8();TC();s8();a8();c8();h8();f8();p8();d8();g8();m8();T8();w8();I8();P8();F8();B8();U8();q8();$8();W8();Q8();cb();Z8();AE();jC();r9();u9();d9();y9();jC();v9();Wo();_9();dC();S9();An();R9();rK();nK();CC();iK();NC();EE();IC();V0();fb();wC();FC();aK();DC();uK();Object.assign(Qr,{analyze:BC,average:G8,bezier:z8,blend:Y8,brewer:E9,Color:Pe,colors:wd,contrast:e9,contrastAPCA:a9,cubehelix:X8,deltaE:p9,distance:g9,input:Kr,interpolate:bh,limits:UC,mix:bh,random:J8,scale:wy,scales:x9,valid:m9});XC=Qr;});function QC(t,e){try{let[n,s,i]=XC(t).set("lab.l",e).rgb();return `rgb(${Math.round(n)}, ${Math.round(s)}, ${Math.round(i)})`}catch{return t}}var db,kE=Ie(()=>{lK();db=class{constructor(e){this.colors=this.generateColors(e),this.index=0;}generateColors(e){let n=[];for(let s=0;s<e;s++)n.push(this.phyllotacticColor(s));return n}getNextColor(){return this.index>=this.colors.length&&(this.index=0),this.colors[this.index++]}phyllotacticColor(e){let n=137.5*(Math.PI/180),s=100,i=e*n,r=s*Math.cos(i),o=s*Math.sin(i),a=62,c=r,v=o,y=XC.lab(a,c,v).rgb();return `rgb(${Math.round(y[0])}, ${Math.round(y[1])}, ${Math.round(y[2])})`}};});var vs,Hu,Id;exports.QualitativeConstraintValidator=void 0;var gb=Ie(()=>{Ll();Bf();Ad();Ad();Ad();vs=1,Hu=class Hu{constructor(e=15){this.adj=new Map;this.radj=new Map;this.nodes=new Set;this.nodeSize=new Map;this.edgeProvenance=new Map;this.alignmentRefCount=new Map;this.edgeClaims=new Map;this.addVersion=vs++;this.removeVersion=vs++;this.weightVersion=vs++;this.hasZeroWeightOrderingEdge=false;this.reachMemo=new Map;this.maxWeightMemo=new Map;this.contractedMemo=null;this.sccMemo=null;this.memoAddV=-1;this.memoRemV=-1;this.memoWeightV=-1;this.pendingDeltas=null;this.gap=e;}consumeReachDeltas(){let e=this.pendingDeltas;return this.pendingDeltas=[],e}markDeltasUnknown(){this.pendingDeltas=null;}recordDelta(e,n){if(this.pendingDeltas!==null){if(this.pendingDeltas.length>=Hu.MAX_PENDING_DELTAS){this.pendingDeltas=null;return}this.pendingDeltas.push({from:e,to:n});}}clone(){let e=new Hu(this.gap);for(let n of this.nodes)e.nodes.add(n);for(let[n,s]of this.adj)e.adj.set(n,new Map(s));for(let[n,s]of this.radj)e.radj.set(n,new Map(s));e.nodeSize=new Map(this.nodeSize),e.edgeProvenance=new Map(this.edgeProvenance),e.alignmentRefCount=new Map(this.alignmentRefCount);for(let[n,s]of this.edgeClaims)e.edgeClaims.set(n,[...s]);return e.hasZeroWeightOrderingEdge=this.hasZeroWeightOrderingEdge,e}validateMemo(){if(this.memoAddV!==this.addVersion||this.memoRemV!==this.removeVersion){this.reachMemo.clear(),this.sccMemo=null,this.maxWeightMemo.clear(),this.contractedMemo=null,this.memoAddV=this.addVersion,this.memoRemV=this.removeVersion,this.memoWeightV=this.weightVersion;return}this.memoWeightV!==this.weightVersion&&(this.maxWeightMemo.clear(),this.contractedMemo=null,this.memoWeightV=this.weightVersion);}ensureNode(e,n=0){this.nodes.has(e)||(this.nodes.add(e),this.adj.set(e,new Map),this.radj.set(e,new Map),this.nodeSize.set(e,n));}static provenanceKey(e,n){return `${e}\0${n}`}addEdge(e,n,s,i){let r=(s??this.gap)+(this.nodeSize.get(e)??0);if(this.ensureNode(e),this.ensureNode(n),e===n)return false;let o=this.adj.get(e).get(n);if(o!==void 0&&r<=o)return this.registerClaim(e,n,r,i),true;if(this.canReach(n,e))return false;if(r<=0&&(this.hasZeroWeightOrderingEdge=true),o===void 0||o===0){let a=o===void 0&&!this.hasZeroWeightOrderingEdge&&this.memoAddV===this.addVersion&&this.memoRemV===this.removeVersion;this.adj.get(e).set(n,r),this.radj.get(n).set(e,r),this.weightVersion=vs++,a?(this.applyIncrementalClosure(e,n,r>0),this.addVersion=vs++,this.memoAddV=this.addVersion):(this.addVersion=vs++,this.markDeltasUnknown());}else this.adj.get(e).set(n,r),this.radj.get(n).set(e,r),this.weightVersion=vs++;return this.registerClaim(e,n,r,i),true}registerClaim(e,n,s,i){let r=Hu.provenanceKey(e,n),o=this.edgeClaims.get(r);o?o.push({w:s,c:i}):this.edgeClaims.set(r,[{w:s,c:i}]),this.refreshProvenance(r);}refreshProvenance(e){let n=this.edgeClaims.get(e);if(!n||n.length===0){this.edgeProvenance.delete(e);return}let s,i=-1/0;for(let r of n)r.c!==void 0&&r.w>i&&(i=r.w,s=r.c);s!==void 0?this.edgeProvenance.set(e,s):this.edgeProvenance.delete(e);}removeEdgeClaim(e,n,s,i){let r=(s??this.gap)+(this.nodeSize.get(e)??0),o=Hu.provenanceKey(e,n),a=this.edgeClaims.get(o);if(!a)return;let c=i!==void 0?a.findIndex(g=>g.w===r&&g.c===i):a.findIndex(g=>g.w===r);if(c===-1)return;if(a.splice(c,1),a.length===0){this.edgeClaims.delete(o),this.adj.get(e)?.delete(n)&&(this.radj.get(n)?.delete(e),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.edgeProvenance.delete(o);return}let v=-1/0;for(let g of a)g.w>v&&(v=g.w);let y=this.adj.get(e)?.get(n);y!==void 0&&v<y&&(this.adj.get(e).set(n,v),this.radj.get(n).set(e,v),this.weightVersion=vs++,y>0&&v<=0&&(this.removeVersion=vs++,this.markDeltasUnknown())),this.refreshProvenance(o);}applyIncrementalClosure(e,n,s){let i=this.reachFrom(n);for(let[r,o]of this.reachMemo){let a;if(r===e)a=false;else {let y=o.get(e);if(y===void 0)continue;a=y;}let c=a||s,v=o.get(n);(v===void 0||!v&&c)&&(o.set(n,c),r!==n&&this.recordDelta(r,n));for(let[y,g]of i){let h=c||g,u=o.get(y);(u===void 0||!u&&h)&&(o.set(y,h),r!==y&&this.recordDelta(r,y));}}}hasEdge(e,n){return this.adj.get(e)?.has(n)??false}getEdgeWeight(e,n){return this.adj.get(e)?.get(n)}getEdgeProvenance(e,n){return this.edgeProvenance.get(Hu.provenanceKey(e,n))}canReach(e,n){return e===n?true:this.reachFrom(e).has(n)}reachFrom(e){this.validateMemo();let n=this.reachMemo.get(e);if(n)return n;let s=new Map,i=[e],r=[false];s.set(e,false);let o=0;for(;o<i.length;){let a=i[o],c=r[o];o++;let v=this.adj.get(a);if(v)for(let[y,g]of v){let h=c||g>0,u=s.get(y);(u===void 0||!u&&h)&&(s.set(y,h),i.push(y),r.push(h));}}return s.get(e)===false&&s.delete(e),this.reachMemo.set(e,s),s}isOrdered(e,n){return this.isStrictlyOrdered(e,n)}successors(e){let n=this.adj.get(e);return n?new Set(n.keys()):new Set}predecessors(e){let n=this.radj.get(e);return n?new Set(n.keys()):new Set}topologicalSort(){let e=this.standardTopoSort();if(e)return e;let n=this.getAlignmentClasses(),s=new Map;for(let[y,g]of n)for(let h of g)s.set(h,y);for(let y of this.nodes)s.has(y)||s.set(y,y);let i=new Set;for(let y of this.nodes)i.add(s.get(y));let r=new Map;for(let y of i)r.set(y,new Set);for(let[y,g]of this.adj){let h=s.get(y);for(let[u]of g){let d=s.get(u);h!==d&&r.get(h).add(d);}}let o=new Map;for(let y of i)o.set(y,0);for(let[,y]of r)for(let g of y)o.set(g,(o.get(g)??0)+1);let a=[];for(let[y,g]of o)g===0&&a.push(y);let c=[];for(;a.length>0;){let y=a.shift();c.push(y);for(let g of r.get(y)??[]){let h=(o.get(g)??1)-1;o.set(g,h),h===0&&a.push(g);}}if(c.length!==i.size)return null;let v=[];for(let y of c){let g=n.get(y);g?v.push(...g):v.push(y);}return v}standardTopoSort(){let e=new Map;for(let i of this.nodes)e.set(i,0);for(let[,i]of this.adj)for(let r of i.keys())e.set(r,(e.get(r)??0)+1);let n=[];for(let[i,r]of e)r===0&&n.push(i);let s=[];for(;n.length>0;){let i=n.shift();s.push(i);for(let r of this.adj.get(i)?.keys()??[]){let o=(e.get(r)??1)-1;e.set(r,o),o===0&&n.push(r);}}return s.length===this.nodes.size?s:null}addAlignmentEdges(e,n,s){if(this.ensureNode(e),this.ensureNode(n),e===n)return true;if(this.isStrictlyOrdered(e,n)||this.isStrictlyOrdered(n,e))return false;this.adj.get(e).has(n)||(this.adj.get(e).set(n,0),this.radj.get(n).set(e,0),s&&this.edgeProvenance.set(Hu.provenanceKey(e,n),s),this.addVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.adj.get(n).has(e)||(this.adj.get(n).set(e,0),this.radj.get(e).set(n,0),s&&this.edgeProvenance.set(Hu.provenanceKey(n,e),s),this.addVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown());let i=e<n?`${e}\0${n}`:`${n}\0${e}`;return this.alignmentRefCount.set(i,(this.alignmentRefCount.get(i)??0)+1),true}removeAlignmentEdges(e,n){let s=e<n?`${e}\0${n}`:`${n}\0${e}`,i=(this.alignmentRefCount.get(s)??0)-1;if(i>0){this.alignmentRefCount.set(s,i);return}this.alignmentRefCount.delete(s),this.adj.get(e)?.get(n)===0&&(this.adj.get(e).delete(n),this.radj.get(n).delete(e),this.edgeProvenance.delete(Hu.provenanceKey(e,n)),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown()),this.adj.get(n)?.get(e)===0&&(this.adj.get(n).delete(e),this.radj.get(e).delete(n),this.edgeProvenance.delete(Hu.provenanceKey(n,e)),this.removeVersion=vs++,this.weightVersion=vs++,this.markDeltasUnknown());}areAligned(e,n){return e===n?true:this.canReach(e,n)&&this.canReach(n,e)}isStrictlyOrdered(e,n){return e===n?false:this.reachFrom(e).get(n)===true}isProperlyBefore(e,n){if(e===n)return false;let s=this.maxWeightFrom(e).get(n);return s!==void 0&&s>(this.nodeSize.get(e)??0)}entailsSeparation(e,n,s){if(e===n)return false;let i=(s??this.gap)+(this.nodeSize.get(e)??0),r=this.maxWeightFrom(e).get(n);return r!==void 0&&r>=i}maxWeightFrom(e){this.validateMemo();let n=this.maxWeightMemo.get(e);if(n)return n;let{rep:s,adj:i,order:r,members:o}=this.contractedDag(),a=s.get(e)??e,c=new Map;c.set(a,0);for(let y of r){let g=c.get(y);if(g!==void 0)for(let[h,u]of i.get(y)){let d=g+u,f=c.get(h);(f===void 0||d>f)&&c.set(h,d);}}let v=new Map;for(let[y,g]of c){let h=o.get(y);if(h===void 0){v.set(y,g);continue}for(let u of h)v.set(u,g);}return this.maxWeightMemo.set(e,v),v}contractedDag(){if(this.contractedMemo)return this.contractedMemo;let e=new Map,n=this.getAlignmentClasses();for(let[c,v]of n)for(let y of v)e.set(y,c);let s=c=>e.get(c)??c,i=new Map,r=new Map;for(let c of this.nodes){let v=s(c);i.has(v)||(i.set(v,new Map),r.set(v,0));}for(let[c,v]of this.adj){let y=s(c),g=i.get(y);if(g)for(let[h,u]of v){let d=s(h);if(y===d)continue;let f=g.get(d);f===void 0?(g.set(d,u),r.set(d,(r.get(d)??0)+1)):u>f&&g.set(d,u);}}let o=[],a=[];for(let[c,v]of r)v===0&&a.push(c);for(let c=0;c<a.length;c++){let v=a[c];o.push(v);for(let[y]of i.get(v)){let g=(r.get(y)??1)-1;r.set(y,g),g===0&&a.push(y);}}return this.contractedMemo={rep:e,adj:i,order:o,members:n},this.contractedMemo}tarjanSCCs(){if(this.validateMemo(),this.sccMemo)return this.sccMemo;let e=new Map,n=new Map,s=new Set,i=[],r=[],o=0;for(let a of this.nodes){if(e.has(a))continue;let c=[],v=y=>{e.set(y,o),n.set(y,o),o++,i.push(y),s.add(y),c.push({node:y,succs:[...this.adj.get(y)?.keys()??[]],i:0});};for(v(a);c.length>0;){let y=c[c.length-1];if(y.i<y.succs.length){let g=y.succs[y.i++];e.has(g)?s.has(g)&&n.set(y.node,Math.min(n.get(y.node),e.get(g))):v(g);}else {if(c.pop(),n.get(y.node)===e.get(y.node)){let h=[],u;do u=i.pop(),s.delete(u),h.push(u);while(u!==y.node);r.push(h);}let g=c[c.length-1];g&&n.set(g.node,Math.min(n.get(g.node),n.get(y.node)));}}}return this.sccMemo=r,r}getAlignmentClasses(){let e=new Map;for(let n of this.tarjanSCCs())n.length>1&&(n.sort(),e.set(n[0],n));return e}getAlignmentClassOf(e){for(let n of this.tarjanSCCs())if(n.includes(e))return n;return [e]}findPath(e,n){if(e===n)return [];let s=new Set,i=[{node:e,path:[]}];for(s.add(e);i.length>0;){let{node:r,path:o}=i.shift(),a=this.adj.get(r);if(!a)continue;let c=[...a.keys()].sort();for(let v of c){if(v===n)return [...o,[r,v]];s.has(v)||(s.add(v),i.push({node:v,path:[...o,[r,v]]}));}}return null}getPathConstraints(e){let n=[];for(let[s,i]of e){let r=this.edgeProvenance.get(Hu.provenanceKey(s,i));r&&n.push(r);}return n}edgeCount(){let e=0;for(let[,n]of this.adj)e+=n.size;return e}allNodes(){return this.nodes}allEdges(){let e=[];for(let[n,s]of this.adj)for(let i of s.keys())e.push([n,i]);return e}};Hu.MAX_PENDING_DELTAS=65536;Id=Hu,exports.QualitativeConstraintValidator=class t{constructor(e){this.minPadding=15;this.horizontallyAligned=[];this.verticallyAligned=[];this.addedConstraints=[];this.allDisjunctions=[];this.originalDisjunctions=[];this.assignmentTrail=[];this.decisionLevel=0;this.learnedClauses=[];this.activityFlat=new Float64Array(0);this.simplicityFlat=new Float64Array(0);this.elimScratch=new Uint8Array(0);this.branchStride=0;this.activityDecay=.95;this.conflictCount=0;this.restartThreshold=32;this.emptyDisjunctionError=null;this.lubyIndex=0;this.nodeMap=new Map;this.prunedByTransitivity=0;this.prunedByDecomposition=0;this.altVerdictCache=new Map;this.verdictEntryByIndex=[];this.verdictEntryDisj=[];this.probeIndex=new Map;this.additionEpoch=0;this.lastPropagateOkStamp=-1;this.mustHGraph=null;this.mustVGraph=null;this.validationSucceeded=false;this.mustHPairs=null;this.mustVPairs=null;this.mustHAlignmentClasses=null;this.mustVAlignmentClasses=null;this.modalStateBuilt=false;this.layout=e,this.nodes=e.nodes,this.edges=e.edges,this.orientationConstraints=e.constraints,this.groups=e.groups,this.hGraph=new Id(this.minPadding),this.vGraph=new Id(this.minPadding);for(let n of this.nodes)this.nodeMap.set(n.id,n),this.hGraph.ensureNode(n.id,n.width),this.vGraph.ensureNode(n.id,n.height);}validateConstraints(){return this.validateGroupConstraints()||this.validatePositionalConstraints()}validatePositionalConstraints(){this.resetModalQueryState();let e=false;for(let o of this.orientationConstraints)if(this.addConjunctiveConstraint(o)){e=true;break}if(this.addGroupBoundingBoxDisjunctions(),this.allDisjunctions=[...this.layout.disjunctiveConstraints||[]],this.originalDisjunctions=[...this.allDisjunctions],e)return this.enforceMaximalFeasibleSubset(this.buildGlobalMFSError());let n=this.addedConstraints.length;if(this.presolveDisjunctions(),this.emptyDisjunctionError)return this.enforceMaximalFeasibleSubset(this.emptyDisjunctionError);if(this.mustHGraph=this.hGraph.clone(),this.mustVGraph=this.vGraph.clone(),this.allDisjunctions.length>0&&!this.solveCDCL().satisfiable)return this.enforceMaximalFeasibleSubset(this.buildGlobalMFSError());let s=this.addedConstraints.slice(n);s.length>0&&(this.layout.constraints=this.layout.constraints.concat(s));let i=this.computeAlignmentOrders(),r=this.detectNodeOverlaps();return r?this.enforceMaximalFeasibleSubset(r):(this.layout.constraints=this.layout.constraints.concat(i),this.validationSucceeded=true,null)}enforceMaximalFeasibleSubset(e){return e.maximalFeasibleSubset&&(this.layout.constraints=e.maximalFeasibleSubset),this.resetModalQueryState(),e}buildGlobalMFSError(){let{feasibleConstraints:e,infeasibleDisjunctions:n,hGraph:s,vGraph:i}=this.computeMaximalFeasibleSubset(),r=new Set(e),o=this.orientationConstraints.filter(l=>!r.has(l)),a=new Set,c=new Set,v=(l,p,x)=>{let b=l.findPath(p,x);if(b)for(let[S,_]of b){let T=l.getEdgeProvenance(S,_);T&&!c.has(T)&&(c.add(T),a.add(T));}};for(let l of o)if(!c.has(l))if(c.add(l),a.add(l),Fn(l)){let p=l,x=p.axis==="x"?s:i,b=p.node1.id,S=p.node2.id;x.canReach(b,S)&&v(x,b,S),x.canReach(S,b)&&v(x,S,b);}else {let p=this.constraintToEdge(l);if(!p)continue;let x=p.axis==="h"?s:i;v(x,p.to,p.from);}for(let l of n)if(l.alternatives.length>0&&l.alternatives[0].length>0){let p=l.alternatives[0][0];c.has(p)||(c.add(p),a.add(p));let x=this.constraintToEdge(p);if(x){let b=x.axis==="h"?s:i,S=b.findPath(x.to,x.from);if(S)for(let[_,T]of S){let k=b.getEdgeProvenance(_,T);k&&!c.has(k)&&(c.add(k),a.add(k));}}}let y=new Map,g=new Map;for(let l of a){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),g.has(p.toHTML())||g.set(p.toHTML(),[]),y.get(p).push(l),g.get(p.toHTML()).push(Fa(l));}for(let l of n)if(l.alternatives.length===0){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),g.has(p.toHTML())||g.set(p.toHTML(),[]),g.get(p.toHTML()).push(`unsatisfiable: ${p.toHTML()}`);}let u=[...a][0]??this.orientationConstraints[0],d=u?Fa(u):"",f=u?.sourceConstraint??n[0]?.sourceConstraint??this.orientationConstraints[0]?.sourceConstraint;return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${d}" conflicts with existing constraints`,conflictingConstraint:u??void 0,conflictingSourceConstraint:f??void 0,minimalConflictingSet:y,maximalFeasibleSubset:e,errorMessages:{conflictingConstraint:d,conflictingSourceConstraint:f?.toHTML()??"",minimalConflictingConstraints:g}}}presolveDisjunctions(){let e=[];for(let n of this.allDisjunctions){let s=this.findImpliedAlternative(n);if(s!==null){for(let r of n.alternatives[s])this.addedConstraints.push(r);this.prunedByTransitivity++;continue}let i=[];for(let r of n.alternatives)this.isAlternativeFeasible(r)&&i.push(r);if(i.length===0)n.alternatives.length===0?(e.push(n),this.emptyDisjunctionError=this.buildDisjunctiveError(n)):e.push(n);else if(i.length===1){let r=true;for(let o of i[0])if(this.addConjunctiveConstraint(o)){r=false,e.push(n);break}r&&this.prunedByDecomposition++;}else i.length<n.alternatives.length?e.push(new ys(n.sourceConstraint,i)):e.push(n);}this.allDisjunctions=e;}buildDisjunctiveError(e){let n=e.alternatives[0]?.[0]??this.addedConstraints[this.addedConstraints.length-1]??this.orientationConstraints[0],s=new Map;s.set(e.sourceConstraint,e.alternatives[0]??[]);for(let i of this.addedConstraints)s.has(i.sourceConstraint)||s.set(i.sourceConstraint,[]),s.get(i.sourceConstraint).push(i);return {name:"PositionalConstraintError",type:"positional-conflict",message:`No satisfiable alternative for disjunction from ${e.sourceConstraint?.toHTML?.()??"unknown"}`,conflictingConstraint:n,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:s,maximalFeasibleSubset:[...this.addedConstraints]}}addConjunctiveConstraint(e){if(ii(e)){if(!this.hGraph.addEdge(e.left.id,e.right.id,e.minDistance,e))return this.buildConjunctiveError(e);this.addedConstraints.push(e);}else if(ni(e)){if(!this.vGraph.addEdge(e.top.id,e.bottom.id,e.minDistance,e))return this.buildConjunctiveError(e);this.addedConstraints.push(e);}else if(Fn(e)){let n=e,s=n.axis==="x"?this.hGraph:this.vGraph;if(!s.addAlignmentEdges(n.node1.id,n.node2.id,e))return this.buildAlignmentConflictError(e,n.axis);if(n.node1.id!==n.node2.id){let i=n.axis==="x"?this.vGraph:this.hGraph;if(t.classHasDualAxisOverlap(s,i,n.node1.id,n.node2.id,true))return s.removeAlignmentEdges(n.node1.id,n.node2.id),this.buildAlignmentConflictError(e,n.axis)}n.axis==="x"?this.verticallyAligned.push([n.node1,n.node2]):this.horizontallyAligned.push([n.node1,n.node2]),this.addedConstraints.push(e);}else if(Ls(e)||Is(e)){let n=this.addSpatialConstraint(e);if(n)return n;this.addedConstraints.push(e);}return null}addSpatialConstraint(e){if(Ls(e)){let n=e,s=`_group_${n.group.name}`;this.hGraph.ensureNode(s),this.vGraph.ensureNode(s);let i;switch(n.side){case "left":i=this.hGraph.addEdge(n.node.id,s,n.minDistance,e);break;case "right":i=this.hGraph.addEdge(s,n.node.id,n.minDistance,e);break;case "top":i=this.vGraph.addEdge(n.node.id,s,n.minDistance,e);break;case "bottom":i=this.vGraph.addEdge(s,n.node.id,n.minDistance,e);break;default:i=true;}if(!i)return this.buildConjunctiveError(e)}else if(Is(e)&&!this.addQualitativeEdge(e))return this.buildConjunctiveError(e);return null}addGroupBoundingBoxDisjunctions(){let e=new Map;for(let r of this.nodes)e.set(r.id,new Set);let n=new Map;for(let r of this.nodes)n.set(r.id,r);for(let r of this.groups)if(r.nodeIds.length>1&&r.sourceConstraint)for(let o of r.nodeIds)e.get(o)?.add(r);for(let r of this.groups){if(r.nodeIds.length<=1||!r.sourceConstraint||r.negated)continue;let o=new Set(r.nodeIds),a=`_group_${r.name}`;this.hGraph.ensureNode(a),this.vGraph.ensureNode(a);for(let c of this.nodes){if(o.has(c.id))continue;let v=e.get(c.id);if(v&&v.size>0&&(!r.overlapping||[...v].every(d=>d===r||this.isSubGroup(d,r)||this.isSubGroup(r,d))))continue;let y=r.sourceConstraint,g=[[{group:r,node:c,side:"left",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"right",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"top",minDistance:this.minPadding,sourceConstraint:y}],[{group:r,node:c,side:"bottom",minDistance:this.minPadding,sourceConstraint:y}]],h=new ys(y,g);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(h);}}let s=5,i=new Map;for(let r of this.groups){if(!r.negated||!r.sourceConstraint)continue;let o=r.sourceConstraint;i.has(o)||i.set(o,[]),i.get(o).push(r);}for(let[r,o]of i){let a=[];for(let v of o){let y=new Set(v.nodeIds),g=v.nodeIds.map(u=>n.get(u)).filter(u=>u!==void 0),h=this.nodes.filter(u=>!y.has(u.id));if(!(g.length<2||h.length===0)){if(g.length>s){let u=b=>({id:`_ng_${v.name}_${b}`,label:"",color:"",groups:[],attributes:{},width:0,height:0,mostSpecificType:"",types:[],showLabels:false}),d=u("l"),f=u("r"),l=u("t"),p=u("b"),x=b=>{let S=new ys(r,b);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(S);};x(g.map(b=>[{left:b,right:d,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{left:f,right:b,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{top:b,bottom:l,minDistance:0,sourceConstraint:r}])),x(g.map(b=>[{top:p,bottom:b,minDistance:0,sourceConstraint:r}]));for(let b of h)a.push([{left:d,right:b,minDistance:0,sourceConstraint:r},{left:b,right:f,minDistance:0,sourceConstraint:r},{top:l,bottom:b,minDistance:0,sourceConstraint:r},{top:b,bottom:p,minDistance:0,sourceConstraint:r}]);}else for(let u of h)for(let d of g)for(let f of g)if(d.id!==f.id)for(let l of g)for(let p of g)l.id!==p.id&&a.push([{left:d,right:u,minDistance:0,sourceConstraint:r},{left:u,right:f,minDistance:0,sourceConstraint:r},{top:l,bottom:u,minDistance:0,sourceConstraint:r},{top:u,bottom:p,minDistance:0,sourceConstraint:r}]);}}let c=new ys(r,a);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(c);}for(let r=0;r<this.groups.length;r++)if(!this.groups[r].negated)for(let o=r+1;o<this.groups.length;o++){if(this.groups[o].negated)continue;let a=this.groups[r],c=this.groups[o];if(a.nodeIds.length<=1||c.nodeIds.length<=1||this.isSubGroup(a,c)||this.isSubGroup(c,a)||this.groupIntersection(a,c).length>0)continue;let v=a.sourceConstraint||c.sourceConstraint,y=[[{groupA:a,groupB:c,side:"left",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"right",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"top",minDistance:this.minPadding,sourceConstraint:v}],[{groupA:a,groupB:c,side:"bottom",minDistance:this.minPadding,sourceConstraint:v}]],g=new ys(v,y);this.layout.disjunctiveConstraints||(this.layout.disjunctiveConstraints=[]),this.layout.disjunctiveConstraints.push(g);}return null}groupBoundaryEdges(e){let n=e.side==="left"||e.side==="right"?"h":"v",s=e.side==="right"||e.side==="bottom",i=(r,o)=>({axis:n,from:s?o:r,to:s?r:o});return [i(`_group_${e.groupA.name}`,`_group_${e.groupB.name}`),...e.groupA.nodeIds.flatMap(r=>e.groupB.nodeIds.map(o=>i(r,o)))]}isAlternativeFeasible(e){for(let n of e){if(Is(n)){for(let r of this.groupBoundaryEdges(n)){let o=r.axis==="h"?this.hGraph:this.vGraph;if(r.from===r.to||o.canReach(r.to,r.from))return false}continue}if(Ls(n)){let r=n,a=r.side==="left"||r.side==="right"?this.hGraph:this.vGraph;for(let c of r.group.nodeIds)if(a.areAligned(r.node.id,c))return false;if(!this.isBoundingBoxFeasible(r))return false}if(Fn(n)){let r=n,o=r.axis==="x"?this.hGraph:this.vGraph,a=o.canReach(r.node1.id,r.node2.id),c=o.canReach(r.node2.id,r.node1.id);if(a!==c)return false;if(r.node1.id!==r.node2.id){let v=r.axis==="x"?this.vGraph:this.hGraph;if(t.classHasDualAxisOverlap(o,v,r.node1.id,r.node2.id,false))return false}continue}let s=this.constraintToEdge(n);if(!s)continue;if((s.axis==="h"?this.hGraph:this.vGraph).canReach(s.to,s.from))return false}return true}isBoundingBoxFeasible(e){return t.isBboxFeasibleInGraphs(e,this.hGraph,this.vGraph)}static isBboxFeasibleInGraphs(e,n,s){let i=e.node.id,r=e.group.nodeIds;switch(e.side){case "left":for(let o of r)if(n.isOrdered(o,i))return false;return true;case "right":for(let o of r)if(n.isOrdered(i,o))return false;return true;case "top":for(let o of r)if(s.isOrdered(o,i))return false;return true;case "bottom":for(let o of r)if(s.isOrdered(i,o))return false;return true}}findImpliedAlternative(e){for(let n=0;n<e.alternatives.length;n++){let s=true;for(let i of e.alternatives[n]){if(Fn(i)){let c=i;if(!(c.axis==="x"?this.hGraph:this.vGraph).areAligned(c.node1.id,c.node2.id)){s=false;break}continue}let r=this.constraintToEdge(i);if(!r)continue;let o=r.axis==="h"?this.hGraph:this.vGraph,a=i.minDistance;if(!o.isOrdered(r.from,r.to)||!o.entailsSeparation(r.from,r.to,a)){s=false;break}}if(s)return n}return null}solveCDCL(){if(this.allDisjunctions.length===0)return {satisfiable:true};if(this.pruneDisjunctions(),this.allDisjunctions.length===0)return {satisfiable:true};let e=new Int32Array(this.allDisjunctions.length).fill(-1);this.rebuildBranchIndex(true);let n=this.checkpoint(),s=this.addedConstraints.length,i=0,r=50;for(;i<=r;){if(this.restoreCheckpoint(n),this.addedConstraints.length=s,this.assignmentTrail=[],this.decisionLevel=0,e.fill(-1),i>0){if(this.pruneDisjunctions(),this.allDisjunctions.length===0)return {satisfiable:true};e=new Int32Array(this.allDisjunctions.length).fill(-1),this.rebuildBranchIndex(false);}let o=this.cdclSearchLoop(e);if(o.satisfiable)return {satisfiable:true};if(o.provedUnsat)return this.buildUnsatResult(e);i++,this.updateRestartThreshold();}return this.buildUnsatResult(new Int32Array(this.allDisjunctions.length).fill(-1))}cdclSearchLoop(e){let n=this.allDisjunctions.length,s=0;for(;;){if(this.unitPropagate(e)==="conflict"){if(this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeConflict(e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false};continue}let r=this.graphPropagate(e);if(r!=="ok"){if(this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeTheoryConflict(r.disjunctionIndex,e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false};continue}if(this.allAssigned(e,n))return {satisfiable:true};let{dIdx:o,aIdx:a}=this.pickBranch(e);if(o===-1)return {satisfiable:true};if(this.decisionLevel++,!this.tryAssign(o,a,e,true)){if(e[o]=-1,this.decisionLevel===0)return {satisfiable:false,provedUnsat:true};let{learnedClause:v,backtrackLevel:y}=this.analyzeConflictForDecision(o,a,e);if(v&&(this.learnedClauses.push(v),this.bumpActivity(v),this.decayActivity()),this.conflictCount++,s++,this.backtrackTo(y,e),s>=this.restartThreshold)return {satisfiable:false,provedUnsat:false}}}}unitPropagate(e){let n=true;for(;n;){n=false;for(let s of this.learnedClauses){let i=0,r=null,o=0;for(let a of s){let c=e[a.disjunctionIndex];c===-1?(o++,r=a):(a.sign&&c===a.alternativeIndex||!a.sign&&c!==a.alternativeIndex)&&i++;}if(!(i>0)){if(o===0)return "conflict";if(o===1&&r){let a=r;if(a.sign){if(!this.tryAssign(a.disjunctionIndex,a.alternativeIndex,e,false))return "conflict";n=true;}else {let v=this.getRemainingAlternatives(a.disjunctionIndex,e).filter(y=>y!==a.alternativeIndex);if(v.length===0)return "conflict";if(v.length===1){if(!this.tryAssign(a.disjunctionIndex,v[0],e,false))return "conflict";n=true;}}}}}}return "ok"}graphPropagate(e){if(this.groups.length===0||this.combinedGraphStamp()===this.lastPropagateOkStamp)return "ok";let n=true;for(;n;){n=false,this.consumeGraphDeltas();for(let s=0;s<this.allDisjunctions.length;s++){if(e[s]!==-1)continue;let i=this.allDisjunctions[s],r=this.hGraph.hasZeroWeightOrderingEdge||this.vGraph.hasZeroWeightOrderingEdge,o=this.hGraph.addVersion+this.vGraph.addVersion,a=this.hGraph.removeVersion+this.vGraph.removeVersion,c=null;r||(this.verdictEntryDisj[s]===i?c=this.verdictEntryByIndex[s]:(c=this.verdictEntryFor(i),this.verdictEntryDisj[s]=i,this.verdictEntryByIndex[s]=c));let v=0,y=-1;for(let g=0;g<i.alternatives.length;g++)(c===null?this.isAlternativeFeasible(i.alternatives[g]):this.altFeasibleCached(i,c,g,o,a))&&(v++,y=g);if(v===0)return {conflict:true,disjunctionIndex:s};if(v===1){if(!this.tryAssign(s,y,e,false))return {conflict:true,disjunctionIndex:s};n=true;}}}return this.lastPropagateOkStamp=this.combinedGraphStamp(),"ok"}combinedGraphStamp(){return this.hGraph.addVersion+this.hGraph.removeVersion+this.vGraph.addVersion+this.vGraph.removeVersion}consumeGraphDeltas(){let e=this.hGraph.consumeReachDeltas(),n=this.vGraph.consumeReachDeltas();if(e===null||n===null){this.additionEpoch++;return}for(let s of e)this.dirtyProbe("h",s.from,s.to);for(let s of n)this.dirtyProbe("v",s.from,s.to);}dirtyProbe(e,n,s){let i=this.probeIndex.get(`${e}\0${n}\0${s}`);if(i)for(let{entry:r,aIdx:o}of i)r.verdict[o]===1&&(r.verdict[o]=0);}registerProbes(e,n,s){let i=false,r=(o,a,c)=>{let v=`${o}\0${a}\0${c}`,y=this.probeIndex.get(v);y||(y=[],this.probeIndex.set(v,y)),y.push({entry:e,aIdx:n});};for(let o of s){if(Fn(o)){i=true;continue}if(Is(o)){for(let c of this.groupBoundaryEdges(o))r(c.axis,c.to,c.from);continue}if(Ls(o)){let c=o,v=c.side==="left"||c.side==="right"?"h":"v";for(let y of c.group.nodeIds)r(v,c.node.id,y),r(v,y,c.node.id);}let a=this.constraintToEdge(o);a&&r(a.axis,a.to,a.from);}return i}verdictEntryFor(e){let n=this.altVerdictCache.get(e);if(!n){let s=e.alternatives.length;n={verdict:new Int8Array(s),addStamp:new Float64Array(s),remStamp:new Float64Array(s),hasAlignment:new Uint8Array(s)};for(let i=0;i<s;i++)this.registerProbes(n,i,e.alternatives[i])&&(n.hasAlignment[i]=1);this.altVerdictCache.set(e,n);}return n}altFeasibleCached(e,n,s,i,r){let o=n.hasAlignment[s]?i:this.additionEpoch,a=n.verdict[s];if(a===1&&n.addStamp[s]===o)return true;if(a===2&&n.remStamp[s]===r)return false;let c=this.isAlternativeFeasible(e.alternatives[s]);return n.verdict[s]=c?1:2,n.addStamp[s]=o,n.remStamp[s]=r,c}getRemainingAlternatives(e,n){let s=this.allDisjunctions[e];if(n[e]!==-1)return [n[e]];let i=new Set;for(let o of this.learnedClauses)for(let a of o)a.disjunctionIndex===e&&!a.sign&&o.every(v=>{if(v===a)return true;let y=n[v.disjunctionIndex];return y===-1?false:v.sign?y!==v.alternativeIndex:y===v.alternativeIndex})&&i.add(a.alternativeIndex);let r=[];for(let o=0;o<s.alternatives.length;o++)i.has(o)||r.push(o);return r}tryAssign(e,n,s,i){let r=this.allDisjunctions[e].alternatives[n];for(let o of r)if(!this.addQualitativeEdge(o))return this.undoAlternativeEdges(r,o),false;s[e]=n,this.assignmentTrail.push({disjunctionIndex:e,alternativeIndex:n,decisionLevel:this.decisionLevel,isDecision:i});for(let o of r)this.addedConstraints.push(o);return true}addQualitativeEdge(e){if(ii(e))return this.hGraph.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return this.vGraph.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Ls(e)){let n=e,i=n.side==="left"||n.side==="right"?this.hGraph:this.vGraph;for(let o of n.group.nodeIds)if(i.areAligned(n.node.id,o))return false;if(!this.isBoundingBoxFeasible(n))return false;let r=`_group_${n.group.name}`;switch(this.hGraph.ensureNode(r),this.vGraph.ensureNode(r),n.side){case "left":if(!this.hGraph.addEdge(n.node.id,r,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.hGraph.ensureNode(o),this.hGraph.addEdge(n.node.id,o,n.minDistance,e);return true;case "right":if(!this.hGraph.addEdge(r,n.node.id,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.hGraph.ensureNode(o),this.hGraph.addEdge(o,n.node.id,n.minDistance,e);return true;case "top":if(!this.vGraph.addEdge(n.node.id,r,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.vGraph.ensureNode(o),this.vGraph.addEdge(n.node.id,o,n.minDistance,e);return true;case "bottom":if(!this.vGraph.addEdge(r,n.node.id,n.minDistance,e))return false;for(let o of n.group.nodeIds)this.vGraph.ensureNode(o),this.vGraph.addEdge(o,n.node.id,n.minDistance,e);return true}}if(Is(e)){let n=[];for(let s of this.groupBoundaryEdges(e)){if(!(s.axis==="h"?this.hGraph:this.vGraph).addEdge(s.from,s.to,e.minDistance,e)){for(let r of n)(r.axis==="h"?this.hGraph:this.vGraph).removeEdgeClaim(r.from,r.to,e.minDistance,e);return false}n.push(s);}return true}if(Fn(e)){let n=e;return (n.axis==="x"?this.hGraph:this.vGraph).addAlignmentEdges(n.node1.id,n.node2.id,e)}return true}undoAlternativeEdges(e,n){for(let s of e){if(s===n)break;this.removeQualitativeEdge(s);}}removeQualitativeEdge(e){if(ii(e))this.hGraph.removeEdgeClaim(e.left.id,e.right.id,e.minDistance,e);else if(ni(e))this.vGraph.removeEdgeClaim(e.top.id,e.bottom.id,e.minDistance,e);else if(Ls(e)){let n=e,s=`_group_${n.group.name}`;switch(n.side){case "left":this.hGraph.removeEdgeClaim(n.node.id,s,n.minDistance,e);for(let i of n.group.nodeIds)this.hGraph.removeEdgeClaim(n.node.id,i,n.minDistance,e);break;case "right":this.hGraph.removeEdgeClaim(s,n.node.id,n.minDistance,e);for(let i of n.group.nodeIds)this.hGraph.removeEdgeClaim(i,n.node.id,n.minDistance,e);break;case "top":this.vGraph.removeEdgeClaim(n.node.id,s,n.minDistance,e);for(let i of n.group.nodeIds)this.vGraph.removeEdgeClaim(n.node.id,i,n.minDistance,e);break;case "bottom":this.vGraph.removeEdgeClaim(s,n.node.id,n.minDistance,e);for(let i of n.group.nodeIds)this.vGraph.removeEdgeClaim(i,n.node.id,n.minDistance,e);break}}else if(Is(e))for(let n of this.groupBoundaryEdges(e))(n.axis==="h"?this.hGraph:this.vGraph).removeEdgeClaim(n.from,n.to,e.minDistance,e);else if(Fn(e)){let n=e;(n.axis==="x"?this.hGraph:this.vGraph).removeAlignmentEdges(n.node1.id,n.node2.id);}}analyzeConflict(e){let n=[],s=0,i=0;for(let r of this.assignmentTrail)r.isDecision&&(n.push({disjunctionIndex:r.disjunctionIndex,alternativeIndex:r.alternativeIndex,sign:false}),r.decisionLevel>s?(i=s,s=r.decisionLevel):r.decisionLevel>i&&r.decisionLevel<s&&(i=r.decisionLevel));return n.length===0?{learnedClause:null,backtrackLevel:0}:{learnedClause:n,backtrackLevel:Math.max(0,i)}}analyzeConflictForDecision(e,n,s){let i=this.allDisjunctions[e].alternatives[n],r=new Set;for(let v of i){let y=this.constraintToEdge(v);if(!y)continue;let g=y.axis==="h"?this.hGraph:this.vGraph;if(g.canReach(y.to,y.from)){let h=g.findPath(y.to,y.from);if(h)for(let[u,d]of h){let f=g.getEdgeProvenance(u,d);if(f){let l=this.findTrailEntryForConstraint(f);l!==-1&&r.add(l);}}}}if(r.size>0){let v=[{disjunctionIndex:e,alternativeIndex:n,sign:false}],y=0,g=0;for(let h of r){let u=this.assignmentTrail[h];v.push({disjunctionIndex:u.disjunctionIndex,alternativeIndex:u.alternativeIndex,sign:false}),u.decisionLevel>y?(g=y,y=u.decisionLevel):u.decisionLevel>g&&u.decisionLevel<y&&(g=u.decisionLevel);}return this.decisionLevel>y?(g=y,y=this.decisionLevel):this.decisionLevel>g&&this.decisionLevel<y&&(g=this.decisionLevel),{learnedClause:v,backtrackLevel:Math.max(0,g)}}let o=[{disjunctionIndex:e,alternativeIndex:n,sign:false}],a=0,c=0;for(let v of this.assignmentTrail)o.push({disjunctionIndex:v.disjunctionIndex,alternativeIndex:v.alternativeIndex,sign:false}),v.decisionLevel>a?(c=a,a=v.decisionLevel):v.decisionLevel>c&&v.decisionLevel<a&&(c=v.decisionLevel);return {learnedClause:o,backtrackLevel:Math.max(0,c)}}analyzeTheoryConflict(e,n){let s=this.allDisjunctions[e],i=new Set;for(let r=0;r<s.alternatives.length;r++){let o=s.alternatives[r];for(let a of o){let c=this.constraintToEdge(a);if(!c)continue;let v=c.axis==="h"?this.hGraph:this.vGraph;if(v.canReach(c.to,c.from)){let y=v.findPath(c.to,c.from);if(y)for(let[g,h]of y){let u=v.getEdgeProvenance(g,h);if(u){let d=this.findTrailEntryForConstraint(u);d!==-1&&i.add(d);}}}}}if(i.size>0){let r=[],o=0,a=0;for(let c of i){let v=this.assignmentTrail[c];r.push({disjunctionIndex:v.disjunctionIndex,alternativeIndex:v.alternativeIndex,sign:false}),v.decisionLevel>o?(a=o,o=v.decisionLevel):v.decisionLevel>a&&v.decisionLevel<o&&(a=v.decisionLevel);}if(r.length>0)return {learnedClause:r,backtrackLevel:Math.max(0,a)}}return this.analyzeConflict(n)}findTrailEntryForConstraint(e){for(let n=0;n<this.assignmentTrail.length;n++){let s=this.assignmentTrail[n];if(this.allDisjunctions[s.disjunctionIndex].alternatives[s.alternativeIndex].includes(e))return n}return -1}backtrackTo(e,n){for(;this.assignmentTrail.length>0;){let s=this.assignmentTrail[this.assignmentTrail.length-1];if(s.decisionLevel<=e)break;let i=this.allDisjunctions[s.disjunctionIndex].alternatives[s.alternativeIndex];for(let r of i)this.removeQualitativeEdge(r);this.addedConstraints.length-=i.length,n[s.disjunctionIndex]=-1,this.assignmentTrail.pop();}this.decisionLevel=e;}rebuildBranchIndex(e){let n=this.allDisjunctions.length,s=1;for(let r of this.allDisjunctions)r.alternatives.length>s&&(s=r.alternatives.length);if(s>this.branchStride){let r=this.branchStride,o=this.activityFlat;if(this.branchStride=s,this.activityFlat=new Float64Array(Math.max(n,1)*s),r>0&&!e){let a=Math.floor(o.length/r);for(let c=0;c<a&&c<n;c++)for(let v=0;v<r;v++)this.activityFlat[c*s+v]=o[c*r+v];}}else if(n*this.branchStride>this.activityFlat.length){let r=new Float64Array(n*this.branchStride);e||r.set(this.activityFlat),this.activityFlat=r;}else e&&this.activityFlat.fill(0);let i=Math.max(n,1)*this.branchStride;this.simplicityFlat.length<i&&(this.simplicityFlat=new Float64Array(i),this.elimScratch=new Uint8Array(i)),this.simplicityFlat.fill(0);for(let r=0;r<n;r++){let o=this.allDisjunctions[r].alternatives,a=r*this.branchStride;for(let c=0;c<o.length;c++)this.simplicityFlat[a+c]=1/(1+o[c].length);}}activityAt(e,n){let s=e*this.branchStride+n;return s>=0&&s<this.activityFlat.length?this.activityFlat[s]:0}computeEliminatedFlags(e){if(this.learnedClauses.length===0)return null;let n=this.elimScratch;n.fill(0);let s=this.branchStride;for(let i of this.learnedClauses)for(let r of i){if(r.sign)continue;let o=r.disjunctionIndex*s+r.alternativeIndex;if(o<0||o>=n.length||n[o]===1)continue;let a=true;for(let c of i){if(c===r)continue;let v=e[c.disjunctionIndex];if(v===-1||(c.sign?v===c.alternativeIndex:v!==c.alternativeIndex)){a=false;break}}a&&(n[o]=1);}return n}pickBranch(e){let n=-1,s=-1,i=-1,r=this.computeEliminatedFlags(e),o=this.branchStride;for(let a=0;a<this.allDisjunctions.length;a++){if(e[a]!==-1)continue;let c=this.allDisjunctions[a].alternatives,v=a*o;for(let y=0;y<c.length;y++){if(r!==null&&r[v+y]===1)continue;let g=this.activityFlat[v+y]+this.simplicityFlat[v+y];g>i&&(i=g,n=a,s=y);}}return {dIdx:n,aIdx:s}}bumpActivity(e){for(let n of e){let s=n.disjunctionIndex*this.branchStride+n.alternativeIndex;s>=0&&s<this.activityFlat.length&&(this.activityFlat[s]+=1);}}decayActivity(){let e=this.activityFlat,n=this.activityDecay;for(let s=0;s<e.length;s++)e[s]*=n;}updateRestartThreshold(){this.lubyIndex++,this.restartThreshold=32*this.luby(this.lubyIndex);}luby(e){let n=1,s=1;for(;n<e+1;)n=2*n+1,s*=2;for(;n-1!==e;)n=(n-1)/2,s=s/2,e>=n&&(e-=n);return s}pruneDisjunctions(){let e=[];for(let n of this.allDisjunctions){let s=this.findImpliedAlternative(n);if(s!==null){for(let r of n.alternatives[s])this.addedConstraints.push(r);continue}let i=[];for(let r of n.alternatives)this.isAlternativeFeasible(r)&&i.push(r);if(i.length===0)e.push(n);else if(i.length===1){for(let r of i[0])if(this.addConjunctiveConstraint(r)){e.push(n);break}}else e.push(new ys(n.sourceConstraint,i));}this.allDisjunctions=e;}allAssigned(e,n){for(let s=0;s<n;s++)if(e[s]===-1)return false;return true}checkpoint(){return {hGraph:this.hGraph.clone(),vGraph:this.vGraph.clone(),assignmentTrailLength:this.assignmentTrail.length,addedConstraintsLength:this.addedConstraints.length}}restoreCheckpoint(e){this.hGraph=e.hGraph.clone(),this.vGraph=e.vGraph.clone(),this.altVerdictCache.clear(),this.probeIndex.clear(),this.verdictEntryByIndex.length=0,this.verdictEntryDisj.length=0,this.additionEpoch++;}constraintToEdge(e){if(ii(e))return {axis:"h",from:e.left.id,to:e.right.id};if(ni(e))return {axis:"v",from:e.top.id,to:e.bottom.id};if(Ls(e)){let n=e,s=`_group_${n.group.name}`;switch(n.side){case "left":return {axis:"h",from:n.node.id,to:s};case "right":return {axis:"h",from:s,to:n.node.id};case "top":return {axis:"v",from:n.node.id,to:s};case "bottom":return {axis:"v",from:s,to:n.node.id}}}if(Is(e)){let n=e,s=`_group_${n.groupA.name}`,i=`_group_${n.groupB.name}`;switch(n.side){case "left":return {axis:"h",from:s,to:i};case "right":return {axis:"h",from:i,to:s};case "top":return {axis:"v",from:s,to:i};case "bottom":return {axis:"v",from:i,to:s}}}return null}static addEdgeToGraphsExpanded(e,n,s){if(Ls(e)){let i=e,r=i.node.id;for(let o of i.group.nodeIds)switch(i.side){case "left":if(!n.addEdge(r,o,i.minDistance,e))return false;break;case "right":if(!n.addEdge(o,r,i.minDistance,e))return false;break;case "top":if(!s.addEdge(r,o,i.minDistance,e))return false;break;case "bottom":if(!s.addEdge(o,r,i.minDistance,e))return false;break}return true}if(Is(e)){let i=e;for(let r of i.groupA.nodeIds)for(let o of i.groupB.nodeIds)switch(i.side){case "left":if(!n.addEdge(r,o,i.minDistance,e))return false;break;case "right":if(!n.addEdge(o,r,i.minDistance,e))return false;break;case "top":if(!s.addEdge(r,o,i.minDistance,e))return false;break;case "bottom":if(!s.addEdge(o,r,i.minDistance,e))return false;break}return true}if(ii(e))return n.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Fn(e)){let i=e,r=i.axis==="x"?n:s;if(!r.addAlignmentEdges(i.node1.id,i.node2.id,e))return false;if(i.node1.id!==i.node2.id){let o=i.axis==="x"?s:n;if(t.classHasDualAxisOverlap(r,o,i.node1.id,i.node2.id,true))return r.removeAlignmentEdges(i.node1.id,i.node2.id),false}return true}return true}static alternativeEntailmentRank(e,n,s){let i=[];for(let o of e)if(Ls(o)){let a=o;for(let c of a.group.nodeIds)switch(a.side){case "left":i.push({g:n,from:a.node.id,to:c});break;case "right":i.push({g:n,from:c,to:a.node.id});break;case "top":i.push({g:s,from:a.node.id,to:c});break;case "bottom":i.push({g:s,from:c,to:a.node.id});break}}else if(Is(o)){let a=o;for(let c of a.groupA.nodeIds)for(let v of a.groupB.nodeIds)switch(a.side){case "left":i.push({g:n,from:c,to:v});break;case "right":i.push({g:n,from:v,to:c});break;case "top":i.push({g:s,from:c,to:v});break;case "bottom":i.push({g:s,from:v,to:c});break}}else if(ii(o))i.push({g:n,from:o.left.id,to:o.right.id});else if(ni(o))i.push({g:s,from:o.top.id,to:o.bottom.id});else if(Fn(o)){let a=o,c=a.axis==="x"?n:s;if(a.node1.id!==a.node2.id&&!c.areAligned(a.node1.id,a.node2.id))return 2}let r=true;for(let o of i)if(!o.g.hasEdge(o.from,o.to)&&(r=false,!o.g.isOrdered(o.from,o.to)))return 2;return r?0:1}computeMaximalFeasibleSubset(){let e=new Id(this.minPadding),n=new Id(this.minPadding);for(let a of this.nodes)e.ensureNode(a.id,a.width),n.ensureNode(a.id,a.height);for(let a of this.groups){let c=`_group_${a.name}`;e.ensureNode(c),n.ensureNode(c);}let s=[];for(let a of this.orientationConstraints)t.addEdgeToGraphsExpanded(a,e,n)&&s.push(a);let i=[],r=this.originalDisjunctions.length>0?this.originalDisjunctions:this.allDisjunctions,o=[...r].sort((a,c)=>{let v=r.indexOf(a),y=r.indexOf(c),g=Math.max(...a.alternatives.map((u,d)=>this.activityAt(v,d))),h=Math.max(...c.alternatives.map((u,d)=>this.activityAt(y,d)));return g-h||v-y});for(let a of o){let c=false,v=a.alternatives.map((y,g)=>({alt:y,i:g,rank:t.alternativeEntailmentRank(y,e,n)})).sort((y,g)=>y.rank-g.rank||y.i-g.i);for(let{alt:y}of v){let g=e.clone(),h=n.clone(),u=true;for(let d of y)if(!t.addEdgeToGraphsExpanded(d,g,h)){u=false;break}if(u){for(let d of y)t.addEdgeToGraphsExpanded(d,e,n),s.push(d);c=true;break}}c||i.push(a);}return {feasibleConstraints:s,infeasibleDisjunctions:i,hGraph:e,vGraph:n}}addEdgeToGraphs(e,n,s){if(ii(e))return n.addEdge(e.left.id,e.right.id,e.minDistance,e);if(ni(e))return s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);if(Fn(e)){let i=e,r=i.axis==="x"?n:s;if(!r.addAlignmentEdges(i.node1.id,i.node2.id,e))return false;if(i.node1.id!==i.node2.id){let o=i.axis==="x"?s:n;if(t.classHasDualAxisOverlap(r,o,i.node1.id,i.node2.id,true))return r.removeAlignmentEdges(i.node1.id,i.node2.id),false}return true}if(Ls(e)){let i=e,r=`_group_${i.group.name}`;switch(n.ensureNode(r),s.ensureNode(r),i.side){case "left":return n.addEdge(i.node.id,r,i.minDistance,e);case "right":return n.addEdge(r,i.node.id,i.minDistance,e);case "top":return s.addEdge(i.node.id,r,i.minDistance,e);case "bottom":return s.addEdge(r,i.node.id,i.minDistance,e)}}if(Is(e)){let i=e,r=`_group_${i.groupA.name}`,o=`_group_${i.groupB.name}`;switch(n.ensureNode(r),n.ensureNode(o),s.ensureNode(r),s.ensureNode(o),i.side){case "left":return n.addEdge(r,o,i.minDistance,e);case "right":return n.addEdge(o,r,i.minDistance,e);case "top":return s.addEdge(r,o,i.minDistance,e);case "bottom":return s.addEdge(o,r,i.minDistance,e)}}return true}buildUnsatResult(e){let{feasibleConstraints:n,infeasibleDisjunctions:s,hGraph:i,vGraph:r}=this.computeMaximalFeasibleSubset(),o=new Map;for(let g of s){let h=g.sourceConstraint;o.has(h)||o.set(h,[]),g.alternatives.length>0&&g.alternatives[0].length>0&&o.get(h).push(g.alternatives[0][0]);}let a;s.length>0&&s[0].alternatives.length>0?a=s[0].alternatives[0][0]:this.orientationConstraints.length>0&&(a=this.orientationConstraints[0]),a||(a=this.orientationConstraints[0]||this.allDisjunctions[0]?.alternatives[0]?.[0]);let c=Fa(a),v=new Map;for(let[g,h]of o.entries()){let u=g.toHTML();v.has(u)||v.set(u,[]),h.forEach(d=>v.get(u).push(Fa(d)));}let y=s.length>0?s[0].sourceConstraint:a.sourceConstraint;return {satisfiable:false,error:{name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${c}" conflicts with existing constraints`,conflictingConstraint:a,conflictingSourceConstraint:y,minimalConflictingSet:o,maximalFeasibleSubset:n,errorMessages:{conflictingConstraint:c,conflictingSourceConstraint:y.toHTML(),minimalConflictingConstraints:v}}}}buildConjunctiveError(e){let n=this.findMinimalConflictSet(e),s=new Map,i=new Map;for(let r of n){let o=r.sourceConstraint;s.has(o)||s.set(o,[]),i.has(o.toHTML())||i.set(o.toHTML(),[]),s.get(o).push(r),i.get(o.toHTML()).push(Fa(r));}return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${Fa(e)}" conflicts with existing constraints`,conflictingConstraint:e,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:s,maximalFeasibleSubset:[...this.addedConstraints],errorMessages:{conflictingConstraint:Fa(e),conflictingSourceConstraint:e.sourceConstraint.toHTML(),minimalConflictingConstraints:i}}}findMinimalConflictSet(e){let n=this.constraintToEdge(e);if(!n)return [];let s=n.axis==="h"?this.hGraph:this.vGraph,i=s.findPath(n.to,n.from);if(!i)return [];let r=[];for(let[o,a]of i){let c=s.getEdgeProvenance(o,a);if(c)r.push(c);else {let v=this.addedConstraints.find(y=>{let g=this.constraintToEdge(y);return g&&g.axis===n.axis&&g.from===o&&g.to===a});v&&r.push(v);}}return r}buildAlignmentConflictError(e,n){this.addedConstraints.push(e);let s=this.findAlignmentConflictSet(n);if(this.addedConstraints.pop(),s.includes(e)||s.push(e),Fn(e)){let c=e,v=n==="x"?this.hGraph:this.vGraph,y=c.node1.id,g=c.node2.id;for(let[h,u]of [[y,g],[g,y]])if(v.canReach(h,u)){let d=v.findPath(h,u);if(d)for(let[f,l]of d){let p=v.getEdgeProvenance(f,l);p&&!s.includes(p)&&s.push(p);}}}let i=new Map,r=new Map;for(let c of s){let v=c.sourceConstraint;i.has(v)||i.set(v,[]),r.has(v.toHTML())||r.set(v.toHTML(),[]),i.get(v).push(c),r.get(v.toHTML()).push(Fa(c));}let o=new Set(s),a=this.addedConstraints.filter(c=>!o.has(c));return {name:"PositionalConstraintError",type:"positional-conflict",message:`Constraint "${Fa(e)}" conflicts with alignment constraints`,conflictingConstraint:e,conflictingSourceConstraint:e.sourceConstraint,minimalConflictingSet:i,maximalFeasibleSubset:a,errorMessages:{conflictingConstraint:Fa(e),conflictingSourceConstraint:e.sourceConstraint.toHTML(),minimalConflictingConstraints:r}}}findAlignmentConflictSet(e){let n=e==="x"?this.hGraph:this.vGraph,s=e==="x"?"h":"v",i=[],r=n.getAlignmentClasses(),o=new Map;for(let[c,v]of r)for(let y of v)o.set(y,c);for(let[c,v]of r)for(let y=0;y<v.length;y++)for(let g=y+1;g<v.length;g++){let h=v[y],u=v[g];if(!(n.isStrictlyOrdered(h,u)||n.isStrictlyOrdered(u,h)))continue;let[f,l]=n.isStrictlyOrdered(h,u)?[h,u]:[u,h];for(let x of this.addedConstraints){if(!Fn(x))continue;let b=x;if(b.axis!==e)continue;let S=o.get(b.node1.id),_=o.get(b.node2.id);(S===c||_===c)&&(i.includes(x)||i.push(x));}let p=n.findPath(f,l);if(p)for(let[x,b]of p){let S=n.getEdgeProvenance(x,b);if(S&&!i.includes(S))i.push(S);else if(!S){let _=this.addedConstraints.find(T=>{let k=this.constraintToEdge(T);return k&&k.axis===s&&k.from===x&&k.to===b});_&&!i.includes(_)&&i.push(_);}}return i}let a=[...r.keys()].sort();for(let c=0;c<a.length;c++)for(let v=c+1;v<a.length;v++){let y=r.get(a[c]),g=r.get(a[v]),h=false,u=false;for(let d of y)for(let f of g)n.isOrdered(d,f)&&(h=true),n.isOrdered(f,d)&&(u=true);if(!(!h||!u)){for(let d of this.addedConstraints){if(!Fn(d))continue;let f=d;if(f.axis!==e)continue;let l=o.get(f.node1.id),p=o.get(f.node2.id);(l===a[c]||l===a[v]||p===a[c]||p===a[v])&&(i.includes(d)||i.push(d));}return this.collectOrderingPath(y,g,n,s,i),this.collectOrderingPath(g,y,n,s,i),i}}return i}collectOrderingPath(e,n,s,i,r){for(let o of e)for(let a of n){if(!s.isOrdered(o,a))continue;let c=s.findPath(o,a);if(c)for(let[v,y]of c){let g=s.getEdgeProvenance(v,y);if(g&&!r.includes(g))r.push(g);else if(!g){let h=this.addedConstraints.find(u=>{let d=this.constraintToEdge(u);return d&&d.axis===i&&d.from===v&&d.to===y});h&&!r.includes(h)&&r.push(h);}}return}}validateGroupConstraints(){for(let e=0;e<this.groups.length;e++)if(!this.groups[e].negated)for(let n=e+1;n<this.groups.length;n++){if(this.groups[n].negated)continue;let s=this.groups[e],i=this.groups[n];if(this.isSubGroup(s,i)||this.isSubGroup(i,s))continue;this.groupIntersection(s,i).length>0&&(s.overlapping=true,i.overlapping=true);}return null}computeAlignmentOrders(){let e=new Set(this.nodes.map(a=>a.id));this.verticallyAligned=[];for(let[,a]of this.hGraph.getAlignmentClasses()){let c=a.filter(v=>e.has(v));c.length>=2&&this.verticallyAligned.push(c.map(v=>this.nodeMap.get(v)));}this.horizontallyAligned=[];for(let[,a]of this.vGraph.getAlignmentClasses()){let c=a.filter(v=>e.has(v));c.length>=2&&this.horizontallyAligned.push(c.map(v=>this.nodeMap.get(v)));}let n=[],s=this.hGraph.topologicalSort()||[],i=new Map;s.forEach((a,c)=>i.set(a,c));for(let a of this.horizontallyAligned){a.sort((c,v)=>(i.get(c.id)??0)-(i.get(v.id)??0));for(let c=0;c<a.length-1;c++){let v=new yc(["directlyLeft"],`${a[c].id}->${a[c+1].id}`),y=new K0(v,"Preventing Overlap");n.push({left:a[c],right:a[c+1],minDistance:this.minPadding,sourceConstraint:y});}}let r=this.vGraph.topologicalSort()||[],o=new Map;r.forEach((a,c)=>o.set(a,c));for(let a of this.verticallyAligned){a.sort((c,v)=>(o.get(c.id)??0)-(o.get(v.id)??0));for(let c=0;c<a.length-1;c++){let v=new yc(["directlyAbove"],`${a[c].id}->${a[c+1].id}`),y=new K0(v,"Preventing Overlap");n.push({top:a[c],bottom:a[c+1],minDistance:this.minPadding,sourceConstraint:y});}}return n}detectNodeOverlaps(){for(let e of this.horizontallyAligned){let n=new Set(e.map(s=>s.id));for(let s of this.verticallyAligned){let i=s.filter(r=>n.has(r.id));if(i.length>=2){let r=i[0],o=i[1],a=this.findAlignmentPath(r.id,o.id,"x"),c=this.findAlignmentPath(r.id,o.id,"y"),v=[...a,...c],y=new Map,g=new Map;for(let l of v){let p=l.sourceConstraint;y.has(p)||y.set(p,[]),y.get(p).push(l);let x=p.toHTML();g.has(x)||g.set(x,[]),g.get(x).push(Fa(l));}let h=a.length>0&&a.length<=c.length?this.findConstraintsToBreakAlignment(r.id,o.id,"x"):this.findConstraintsToBreakAlignment(r.id,o.id,"y"),u=new Set(h),d=this.addedConstraints.filter(l=>!u.has(l)),f=v[0]||this.addedConstraints[0];return {name:"PositionalConstraintError",type:"positional-conflict",message:`Alignment constraints force ${r.id} and ${o.id} to occupy the same position`,conflictingConstraint:f,conflictingSourceConstraint:f.sourceConstraint,minimalConflictingSet:y,maximalFeasibleSubset:d,errorMessages:{conflictingConstraint:Fa(f),conflictingSourceConstraint:f.sourceConstraint.toHTML(),minimalConflictingConstraints:g}}}}}return null}findAlignmentPath(e,n,s){let i=new Map;for(let c of this.addedConstraints){if(!Fn(c))continue;let v=c;if(v.axis!==s)continue;let y=v.node1.id,g=v.node2.id;i.has(y)||i.set(y,[]),i.has(g)||i.set(g,[]),i.get(y).push({neighbor:g,constraint:c}),i.get(g).push({neighbor:y,constraint:c});}let r=new Set([e]),o=new Map;o.set(e,null);let a=[e];for(;a.length>0;){let c=a.shift();if(c===n){let v=[],y=n;for(;o.get(y)!==null;){let g=o.get(y);v.push(g.constraint),y=g.node;}return v.reverse()}for(let{neighbor:v,constraint:y}of i.get(c)||[])r.has(v)||(r.add(v),o.set(v,{node:c,constraint:y}),a.push(v));}return []}findConstraintsToBreakAlignment(e,n,s){let i=this.addedConstraints.filter(a=>Fn(a)&&a.axis===s),r=a=>{let c=new Map;for(let g of i){if(a.has(g))continue;let h=g;c.has(h.node1.id)||c.set(h.node1.id,[]),c.has(h.node2.id)||c.set(h.node2.id,[]),c.get(h.node1.id).push(h.node2.id),c.get(h.node2.id).push(h.node1.id);}let v=new Set([e]),y=[e];for(;y.length>0;){let g=y.shift();if(g===n)return true;for(let h of c.get(g)||[])v.has(h)||(v.add(h),y.push(h));}return false};for(let a of i)if(!r(new Set([a])))return [a];let o=new Set;for(let a of i)if(o.add(a),!r(o))return [...o];return [...o]}static classHasDualAxisOverlap(e,n,s,i,r){let o;if(r)o=e.getAlignmentClassOf(s);else {let a=e.getAlignmentClassOf(s),c=e.getAlignmentClassOf(i);o=[...new Set([...a,...c])];}for(let a=0;a<o.length;a++)for(let c=a+1;c<o.length;c++)if(n.areAligned(o[a],o[c]))return true;return false}normalizeAlignment(e){let n=[];for(let i of e){let r=false;for(let o of n)if(i.some(a=>o.some(c=>c.id===a.id))){for(let a of i)o.some(c=>c.id===a.id)||o.push(a);r=true;break}r||n.push([...i]);}let s=true;for(;s;){s=false;for(let i=0;i<n.length;i++){for(let r=i+1;r<n.length;r++)if(n[i].some(o=>n[r].some(a=>o.id===a.id))){for(let o of n[r])n[i].some(a=>a.id===o.id)||n[i].push(o);n.splice(r,1),s=true;break}if(s)break}}return n}isSubGroup(e,n){return e.nodeIds.every(s=>n.nodeIds.includes(s))}groupIntersection(e,n){return e.nodeIds.filter(s=>n.nodeIds.includes(s))}dispose(){this.hGraph=new Id(this.minPadding),this.vGraph=new Id(this.minPadding),this.learnedClauses=[],this.activityFlat=new Float64Array(0),this.simplicityFlat=new Float64Array(0),this.elimScratch=new Uint8Array(0),this.branchStride=0,this.assignmentTrail=[],this.altVerdictCache.clear(),this.probeIndex.clear(),this.verdictEntryByIndex.length=0,this.verdictEntryDisj.length=0,this.lastPropagateOkStamp=-1,this.resetModalQueryState();}getStats(){return {hEdges:this.hGraph.edgeCount(),vEdges:this.vGraph.edgeCount(),learnedClauses:this.learnedClauses.length,conflicts:this.conflictCount,addedConstraints:this.addedConstraints.length,prunedByTransitivity:this.prunedByTransitivity,prunedByDecomposition:this.prunedByDecomposition}}resetModalQueryState(){this.mustHGraph=null,this.mustVGraph=null,this.mustHPairs=null,this.mustVPairs=null,this.mustHAlignmentClasses=null,this.mustVAlignmentClasses=null,this.modalStateBuilt=false,this.validationSucceeded=false;}ensureModalQueryState(){this.modalStateBuilt||!this.validationSucceeded||!this.mustHGraph||!this.mustVGraph||(this.modalStateBuilt=true,this.buildModalQueryState());}buildModalQueryState(){if(!this.mustHGraph||!this.mustVGraph)return;let e=this.nodes.map(n=>n.id);this.mustHPairs=this.collectStrictPairs(this.mustHGraph,e),this.mustVPairs=this.collectStrictPairs(this.mustVGraph,e);for(let n of this.allDisjunctions)n.alternatives.length<2||this.strengthenWithDisjunction(n,e);this.mustHAlignmentClasses=this.collectAlignmentClasses(this.mustHGraph,e),this.mustVAlignmentClasses=this.collectAlignmentClasses(this.mustVGraph,e);}collectStrictPairs(e,n){let s=new Set;for(let i of n)for(let r of n)i!==r&&e.isProperlyBefore(i,r)&&s.add(`${i}\0${r}`);return s}collectAlignmentClasses(e,n){let s=new Map,i=new Set(n);for(let r of n)s.set(r,new Set);for(let[,r]of e.getAlignmentClasses()){let o=r.filter(a=>i.has(a));for(let a of o){let c=s.get(a);if(c)for(let v of o)v!==a&&c.add(v);}}return s}strengthenWithDisjunction(e,n){if(!this.mustHGraph||!this.mustVGraph||!this.mustHPairs||!this.mustVPairs)return;let s=null,i=null,r=null,o=null;for(let a of e.alternatives){let c=this.mustHGraph.clone(),v=this.mustVGraph.clone();for(let d of a)this.addEdgeToGraph(d,c,v);let y=this.collectStrictPairs(c,n),g=this.collectStrictPairs(v,n),h=this.collectAlignmentPairs(c,n),u=this.collectAlignmentPairs(v,n);if(s===null)s=y,i=g,r=h,o=u;else {for(let d of s)y.has(d)||s.delete(d);for(let d of i)g.has(d)||i.delete(d);for(let d of r)h.has(d)||r.delete(d);for(let d of o)u.has(d)||o.delete(d);}}if(s)for(let a of s){this.mustHPairs.add(a);let[c,v]=a.split("\0");this.mustHGraph.addEdge(c,v,1);}if(i)for(let a of i){this.mustVPairs.add(a);let[c,v]=a.split("\0");this.mustVGraph.addEdge(c,v,1);}if(r)for(let a of r){let[c,v]=a.split("\0");this.mustHGraph.addAlignmentEdges(c,v);}if(o)for(let a of o){let[c,v]=a.split("\0");this.mustVGraph.addAlignmentEdges(c,v);}}collectAlignmentPairs(e,n){let s=new Set;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)e.areAligned(n[i],n[r])&&s.add(`${n[i]}\0${n[r]}`);return s}addEdgeToGraph(e,n,s){if(ii(e))n.addEdge(e.left.id,e.right.id,e.minDistance,e);else if(ni(e))s.addEdge(e.top.id,e.bottom.id,e.minDistance,e);else if(Fn(e)){let i=e;(i.axis==="x"?n:s).addAlignmentEdges(i.node1.id,i.node2.id,e);}else if(Is(e))for(let i of this.groupBoundaryEdges(e))(i.axis==="h"?n:s).addEdge(i.from,i.to,e.minDistance,e);else if(Ls(e)){let i=e,r=`_group_${i.group.name}`;switch(n.ensureNode(r),s.ensureNode(r),i.side){case "left":n.addEdge(i.node.id,r,i.minDistance,e);for(let o of i.group.nodeIds)n.ensureNode(o),n.addEdge(i.node.id,o,i.minDistance,e);break;case "right":n.addEdge(r,i.node.id,i.minDistance,e);for(let o of i.group.nodeIds)n.ensureNode(o),n.addEdge(o,i.node.id,i.minDistance,e);break;case "top":s.addEdge(i.node.id,r,i.minDistance,e);for(let o of i.group.nodeIds)s.ensureNode(o),s.addEdge(i.node.id,o,i.minDistance,e);break;case "bottom":s.addEdge(r,i.node.id,i.minDistance,e);for(let o of i.group.nodeIds)s.ensureNode(o),s.addEdge(o,i.node.id,i.minDistance,e);break}}}static pairKey(e,n){return `${e}\0${n}`}getMust(e,n){this.ensureModalQueryState();let s=new Set(this.nodes.map(r=>r.id)),i=new Set;if(!this.mustHPairs||!this.mustVPairs)return i;for(let r of s){if(r===e)continue;let o;switch(n){case "rightOf":o=t.pairKey(e,r),this.mustHPairs.has(o)&&i.add(r);break;case "leftOf":o=t.pairKey(r,e),this.mustHPairs.has(o)&&i.add(r);break;case "below":o=t.pairKey(e,r),this.mustVPairs.has(o)&&i.add(r);break;case "above":o=t.pairKey(r,e),this.mustVPairs.has(o)&&i.add(r);break}}return i}getCannot(e,n){this.ensureModalQueryState();let s=new Set;s.add(e);let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return s;for(let r of this.nodes){if(r.id===e)continue;(n==="leftOf"||n==="above"?i.canReach(e,r.id):i.canReach(r.id,e))&&s.add(r.id);}return s}getCan(e,n){let s=this.getCannot(e,n),i=new Set;for(let r of this.nodes)s.has(r.id)||i.add(r.id);return i}getMustAligned(e,n){return this.ensureModalQueryState(),(n==="x"?this.mustHAlignmentClasses:this.mustVAlignmentClasses)?.get(e)??new Set}getCannotAligned(e,n){this.ensureModalQueryState();let s=new Set;s.add(e);let i=n==="x"?this.mustHGraph:this.mustVGraph,r=n==="x"?this.mustVGraph:this.mustHGraph;if(!i)return s;for(let o of this.nodes)if(o.id!==e){if(i.isStrictlyOrdered(e,o.id)||i.isStrictlyOrdered(o.id,e)){s.add(o.id);continue}r&&t.classHasDualAxisOverlap(i,r,e,o.id,false)&&s.add(o.id);}return s}getCanAligned(e,n){let s=this.getCannotAligned(e,n),i=new Set;for(let r of this.nodes)s.has(r.id)||i.add(r.id);return i}whyMust(e,n,s){if(!this.getMust(e,n).has(s))return null;let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return null;let[r,o]=n==="leftOf"||n==="above"?[s,e]:[e,s];return this.collectPathProvenance(i,r,o)}whyCannot(e,n,s){if(!this.getCannot(e,n).has(s))return null;if(e===s)return [];let i=n==="leftOf"||n==="rightOf"?this.mustHGraph:this.mustVGraph;if(!i)return null;let[r,o]=n==="leftOf"||n==="above"?[e,s]:[s,e];return this.collectPathProvenance(i,r,o)}collectPathProvenance(e,n,s){let i=e.findPath(n,s);if(!i)return [];let r=new Set,o=[];for(let[a,c]of i){let v=e.getEdgeProvenance(a,c);v&&!r.has(v.sourceConstraint)&&(r.add(v.sourceConstraint),o.push(v.sourceConstraint));}return o}getReachable(e,n){let s=new Set(this.nodes.map(r=>r.id)),i=new Set;switch(n){case "rightOf":{for(let r of s)r!==e&&this.hGraph.isProperlyBefore(e,r)&&i.add(r);break}case "leftOf":{for(let r of s)r!==e&&this.hGraph.isProperlyBefore(r,e)&&i.add(r);break}case "below":{for(let r of s)r!==e&&this.vGraph.isProperlyBefore(e,r)&&i.add(r);break}case "above":{for(let r of s)r!==e&&this.vGraph.isProperlyBefore(r,e)&&i.add(r);break}}return i}getAlignedWith(e,n){let s=n==="x"?this.hGraph:this.vGraph,i=new Set(this.nodes.map(a=>a.id)),r=s.getAlignmentClassOf(e),o=new Set;for(let a of r)a!==e&&i.has(a)&&o.add(a);return o}};});function rv(t){switch(t){case "small":return 9;case "large":return 20;default:return 11}}function $ht(t){return typeof t=="string"?{text:t,fontSize:11}:t}function Yht(t){return t===105||t===108||t===73||t===106||t===116||t===102||t===114||t===46||t===44||t===58||t===59||t===39||t===34||t===96||t===124||t===33||t===40||t===41||t===91||t===93||t===123||t===125?.5:t===87||t===77||t===109||t===119||t===64?1.4:t>=65&&t<=90?1.1:1}function cK(t,e,n){if(!t)return 0;let s=0;for(let i=0;i<t.length;i++)s+=Yht(t.charCodeAt(i));return s*e*n}function fK(t,e=[],n={}){let s={...Vht,...n},i=e.map($ht).filter(h=>h.text&&h.text.length>0),r=cK(t||"",14,s.avgGlyphRatio),o=0,a=0;for(let h of i){let u=cK(h.text,h.fontSize,s.avgGlyphRatio);u>o&&(o=u),a+=h.fontSize*1.35;}let v=Math.max(r,o)+s.paddingX,g=14*1.35+a+s.paddingY;return {width:Math.round(hK(v,s.min.w,s.max.w)),height:Math.round(hK(g,s.min.h,s.max.h))}}function hK(t,e,n){return t<e?e:t>n?n:t}var Vht,JC=Ie(()=>{Vht={avgGlyphRatio:.65,paddingX:32,paddingY:26,min:{w:100,h:60},max:{w:280,h:140}};});function Qht(t,e){if(t.kind!=="unresolved-name"||!t.name)return t.message;let n=Xht.has(e)?"constraint":"directive";return `'${t.name}' did not match any type, relation, or atom. This ${n} does not apply to anything.`}function Jht(t){return t.replace(/<[^>]*>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/\s+/g," ").trim()}function Zht(t){return t instanceof ME}function tft(t){let e=[],n=new Set;for(let s of t){let i;if(ii(s))i=`left|${s.left.id}|${s.right.id}|${s.minDistance}`;else if(ni(s))i=`top|${s.top.id}|${s.bottom.id}|${s.minDistance}`;else if(Fn(s)){let[r,o]=[s.node1.id,s.node2.id].sort();i=`align|${s.axis}|${r}|${o}`;}else i=`unknown|${JSON.stringify(s)}`;n.has(i)||(n.add(i),e.push(s));}return e}function eft(t,e,n){switch(n){case "left":return `${e} must be to the left of ${t}`;case "right":return `${e} must be to the right of ${t}`;case "above":return `${e} must be above ${t}`;case "below":return `${e} must be below ${t}`;case "directlyLeft":return `${e} must be directly to the left of ${t}`;case "directlyRight":return `${e} must be directly to the right of ${t}`;case "directlyAbove":return `${e} must be directly above ${t}`;case "directlyBelow":return `${e} must be directly below ${t}`;default:return `${e} is constrained relative to ${t} (${n})`}}function pK(t){let e=t.directives?.icons??[],n=t.directives?.atomColors??[];if(e.length===0&&n.length===0)return t;let i=[...n.map(r=>!r.selector||r.selector.trim().length===0||typeof r.color!="string"||r.color.length===0?null:{selector:r.selector,style:{borderStyle:{color:r.color}}}),...e.map(aE)].filter(r=>r!==null);return {...t,directives:{...t.directives,atomStyles:[...t.directives.atomStyles,...i],icons:[],atomColors:[]}}}var Wht,Xht,ME;exports.AlignmentEdgeStrategy=void 0;exports.ConstraintValidatorStrategy=void 0;var yb,KE;exports.LayoutInstance=void 0;var Cy=Ie(()=>{vd();Ad();iC();Ll();Bf();lC();hC();_T();kE();gb();JC();Wht="univ",Xht=new Set(["orientation","cyclic","align","group","size","hideAtom"]);ME=class t extends Error{constructor(n,s){let i=s&&"selector"in s?s.selector:void 0,r=i?` Selector: ${i}.`:"";super(`Constraint references node "${n}" that is missing from the layout (it may be hidden).${r}`);this.type="unknown-constraint";this.name="MissingNodeConstraintError",this.missingNodeId=n,this.sourceConstraint=s,Object.setPrototypeOf(this,t.prototype);}};exports.AlignmentEdgeStrategy=(s=>(s.NEVER="never",s.DIRECT="direct",s.CONNECTED="connected",s))(exports.AlignmentEdgeStrategy||{}),exports.ConstraintValidatorStrategy=(e=>(e.QUALITATIVE="qualitative",e))(exports.ConstraintValidatorStrategy||{});yb=class{constructor(e,n){this.Path=e;this.LoopsTo=n;}expand(e){let n=this.Path.map(o=>o.id);if(!this.LoopsTo)return n;let s=n.findIndex(o=>o===this.LoopsTo.id);if(s===-1)return n;let i=n.slice(0,s),r=n.slice(s);return i.concat(...Array(e).fill(r))}isSubpathOf(e){let n=this.expand(2),s=e.expand(1);if(s.length>n.length)return false;for(let i=0;i<=n.length-s.length;i++)if(s.every((r,o)=>r===n[i+o]))return true;return false}static areEquivalent(e,n){return e.isSubpathOf(n)&&n.isSubpathOf(e)}};KE=class KE{constructor(e,n,s=0,i=true,r,o){this.hideThisEdge="_h_";this.DEFAULT_NODE_ICON_PATH="";this.DEFAULT_NODE_HEIGHT=60;this.DEFAULT_NODE_WIDTH=100;this.minSepHeight=15;this.minSepWidth=15;this.selectorErrors=[];this.warnings=[];this.warningKeys=new Set;this.hiddenNodeSelectors=new Map;this.hiddenSelectorSources=new Map;this.hiddenNodeConflicts=new Map;this.conflictedHiddenNodes=new Set;this.inferredEdgeGroupStamps=new Map;this.cyclicFragments=[];this.exemptFromHiding=new Set;this.reintroducedNodes=new Set;this.instanceNum=s,this.evaluator=n,this._layoutSpec=pK(e),r!==void 0?this.alignmentEdgeStrategy=r:this.alignmentEdgeStrategy=i?"connected":"never",this.validatorStrategy=o??"qualitative";}recordSelectorError(e,n,s){let i=s instanceof Error?s.message:String(s);this.selectorErrors.push({selector:e,context:n,errorMessage:i});}recordWarning(e){let n=`${e.code}|${e.specType??""}|${e.specIndex??""}|${e.name??e.selector??e.message}`;this.warningKeys.has(n)||(this.warningKeys.add(n),this.warnings.push(e));}recordSpecParseWarnings(){for(let e of this._layoutSpec.warnings??[])this.recordWarning({severity:"warning",code:e.code,message:e.message.replace(/^\[spytial\]\s*/,""),context:"spec",specType:e.specType,label:e.specType??"spec"});}collectSelectorDiagnostics(e,n,s,i,r,o){let a=e.getDiagnostics?.()??[];if(a.length===0)return;let c=typeof o?.toHTML=="function"?Jht(o.toHTML()):`${i}[${r}] \xB7 ${n}`;for(let v of a)this.recordWarning({severity:"warning",code:v.kind,message:Qht(v,i),selector:n,context:s,specType:i,specIndex:r,label:c,name:v.name,suggestion:v.suggestion});}checkSelectorArity(e,n,s,i){let r=e.maxArity();return r===0?true:s==="binary"&&r<2?(this.recordSelectorError(n,i,new exports.SelectorArityError(n,"binary","unary")),false):s==="unary"&&r>1?(this.recordSelectorError(n,i,new exports.SelectorArityError(n,"unary","binary")),false):true}acceptSelectorResult(e,n,s,i,r,o,a){return this.collectSelectorDiagnostics(e,n,s,r,o,a),typeof e.isError=="function"&&e.isError()?(this.recordSelectorError(n,s,new Error(e.prettyPrint())),false):!(i!=="any"&&!this.checkSelectorArity(e,n,i,s))}isNodeHiddenByDirective(e){return this.hiddenNodeSelectors.has(e)}recordHiddenNodeConflict(e,n,s,i,r,o){let a=e.toHTML();this.hiddenNodeConflicts.has(a)||this.hiddenNodeConflicts.set(a,[]),this.hiddenNodeConflicts.get(a).push(n),r&&this.conflictedHiddenNodes.add(s),o&&this.conflictedHiddenNodes.add(i);}recordHiddenGroupMemberConflict(e,n){let s=e.sourceConstraint?.toHTML()??`group <code>${e.name}</code>`,i=`${n} is in group ${e.name}`;this.hiddenNodeConflicts.has(s)||this.hiddenNodeConflicts.set(s,[]),this.hiddenNodeConflicts.get(s).push(i),this.conflictedHiddenNodes.add(n);}get hideDisconnected(){return this._layoutSpec.directives.hideDisconnected||false}get hideDisconnectedBuiltIns(){return this._layoutSpec.directives.hideDisconnectedBuiltIns||false}isAttributeField(e,n,s){let i=this._layoutSpec.directives.attributes.filter(r=>r.field===e);if(i.length===0)return false;if(!n||!s)return i.some(r=>!r.selector&&!r.filter);for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"attribute selector",c),o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"attribute filter",c),a=false;}if(o&&a)return true}return false}isHiddenField(e,n,s){let i=this._layoutSpec.directives.hiddenFields.filter(r=>r.field===e);if(i.length>0)if(!n||!s){if(i.some(r=>!r.selector&&!r.filter))return true}else for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"hidden field selector",c),o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"hidden field filter",c),a=false;}if(o&&a)return true}return !!(n&&s&&this.resolveEdgeStyleForEdge(e,n,s).hidden===true)}normalizeComparableGroupToken(e){let n=e.trim();return n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}buildGroupKeyDisplay(e,n){let s=this.normalizeComparableGroupToken(e),i=(n||"").trim();if(!i)return s||e;let r=this.normalizeComparableGroupToken(i);return r===s?s||r||e:`${i}:${e}`}generateGroups(e,n){let s=this._layoutSpec.constraints.grouping.byselector;if(!s)return [];let i=[];for(let[a,c]of s.entries()){let v=c.selector,y;try{y=this.evaluator.evaluate(v,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(v,"groupBySelector selector",h);continue}if(!this.acceptSelectorResult(y,v,"groupBySelector selector","any","group",a,c))continue;if(y.maxArity()>1){let u=function(d,f,l){return "_g_0_1_"+d+":"+f+"->"+l};let h=y.selectedTwoples();for(var r of h){let d=r[0],f=r[1],l=e.node(d)?.label,p=this.buildGroupKeyDisplay(d,l),x=`${c.name}[${p}]`,b=i.find(S=>S.name===x);if(b)b.nodeIds.push(f);else {let S={name:x,nodeIds:[f],keyNodeId:d,showLabel:!c.negated,labelTextStyle:c.labelTextStyle,sourceConstraint:c,negated:c.negated,keyed:true};if(i.push(S),c.addEdge!=="none"){let[_,T]=c.addEdge==="fromgroup"?[f,d]:[d,f],k=u(x,_,T);e.setEdge(_,T,x,k);}}}}else {let h=y.selectedAtoms();if(h.length===0)continue;let u=h[0],d={name:c.name,nodeIds:h,keyNodeId:u,showLabel:!c.negated,labelTextStyle:c.labelTextStyle,sourceConstraint:c,negated:c.negated,keyed:false};i.push(d);}}return i}generateAttributesAndRemoveEdges(e){let n={},s={};return [...e.edges()].forEach(r=>{let o=r.name,a=this.getRelationName(e,r),c=r.v,v=r.w,y=this.isAttributeField(a,c,v),g=this.isHiddenField(a,c,v);if(g&&y)throw new Error(`${a} cannot be both an attribute and a hidden field.`);if(g){e.removeEdge(r.v,r.w,o);return}if(y){let h=this.getEdgeLabel(e,r),u=r.v,d=r.w,f=e.node(d)?.label||d,l=n[u]||{};l[h]||(l[h]=[],n[u]=l),l[h].push(f);let p=this.getAttributeTextStyle(a,c,v);if(p){let x=s[u]||(s[u]={});x[h]=p;}e.removeEdge(r.v,r.w,o);}}),{attributes:n,textStyles:s}}getAttributeTextStyle(e,n,s){let i=this._layoutSpec.directives.attributes.filter(r=>r.field===e);for(let r of i){let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch{o=false;}if(!o)continue;let a=true;if(r.filter)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(v=>v[0]===n&&v[1]===s);}catch{a=false;}if(a)return r.textStyle}}generateTagsForNodes(e,n,s){let i=this._layoutSpec.directives.tags;if(!i||i.length===0)return {attributes:n,textStyles:s};let r={...n},o={...s},a=new Set(e.nodes()),c=(v,y,g)=>{if(!g)return;let h=o[v]||(o[v]={});h[y]=g;};for(let v of i){let y=v.textStyle;try{let h=this.evaluator.evaluate(v.toTag,{instanceIndex:this.instanceNum}).selectedAtoms(),u=this.evaluator.evaluate(v.value,{instanceIndex:this.instanceNum}),d=u.maxArity()>1?u.selectedTuplesAll():u.selectedAtoms().map(l=>[l]),f=new Map;for(let l of d){let p=f.get(l[0]);p?p.push(l):f.set(l[0],[l]);}for(let l of h){if(!a.has(l))continue;r[l]||(r[l]={});let p=f.get(l)??[];if(p.length!==0)for(let x of p)if(x.length===1){let b=v.name;r[l][b]||(r[l][b]=[]);let S=e.node(l)?.label||l;r[l][b].push(String(S)),c(l,b,y);}else if(x.length===2){let b=v.name;r[l][b]||(r[l][b]=[]);let S=x[x.length-1],_=a.has(String(S))&&e.node(String(S))?.label||String(S);r[l][b].push(_),c(l,b,y);}else {let b=x.slice(1,-1),S=x[x.length-1],_=`[${b.map(R=>{let I=String(R);return a.has(I)&&e.node(I)?.label||I}).join(",")}]`,T=`${v.name}${_}`;r[l][T]||(r[l][T]=[]);let k=a.has(String(S))&&e.node(String(S))?.label||String(S);r[l][T].push(k),c(l,T,y);}}}catch(g){this.recordSelectorError(`name: ${v.name}, toTag: ${v.toTag}, value: ${v.value}`,"tag directive",g);}}return {attributes:r,textStyles:o}}ensureNoExtraNodes(e,n,s){let i=[...e.nodes()],r=this._layoutSpec.directives.hiddenAtoms,o=[];for(let[a,c]of r.entries())try{let v=this.evaluator.evaluate(c.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(v,c.selector,"hideAtom selector","unary","hideAtom",a))continue;let y=v.selectedAtoms();o.push({selector:c.selector,hiddenSet:new Set(y)}),c.source&&!this.hiddenSelectorSources.has(c.selector)&&this.hiddenSelectorSources.set(c.selector,c.source);}catch(v){this.recordSelectorError(c.selector,"hideAtom selector",v);}i.forEach(a=>{try{let v=n.getAtomType(a)?.isBuiltin||!1,y=e.inEdges(a)||[],g=e.outEdges(a)||[],u=y.length===0&&g.length===0&&(this.hideDisconnectedBuiltIns&&v||this.hideDisconnected),d=!1,f;for(let p of o)if(p.hiddenSet.has(a)){d=!0,f=p.selector;break}let l=u||d;if(d&&this.exemptFromHiding.has(a)){this.reintroducedNodes.add(a);return}if(l&&(e.removeNode(a),d&&f)){this.hiddenNodeSelectors.set(a,f);for(let p of s)p.negated||p.nodeIds.includes(a)&&this.recordHiddenGroupMemberConflict(p,a);}}catch(c){console.error("Failed to identify node type. Defaulting to showing node.",c);}});}collectHiddenAtoms(){if(this.hiddenNodeSelectors.size!==0)return [...this.hiddenNodeSelectors.keys()].sort()}collectCyclicFragments(){if(this.cyclicFragments.length!==0)return this.cyclicFragments.map(e=>[...e])}getMostSpecificType(e,n){return this.getNodeTypes(e,n)[0]}getNodeTypes(e,n){let i=n.getAtomType(e)?.types||[];return i=i.concat(Wht),i}getRelationName(e,n){let s=this.getEdgeLabel(e,n);try{return s.split("[")[0]}catch{return console.warn(`Failed to parse relation name from edge label: ${s}. Defaulting to empty string.`),s}}getEdgeLabel(e,n){return e.edge(n.v,n.w,n.name)}generateLayout(e){this.exemptFromHiding=new Set;let n=this.generateLayoutPass(e);if(this.conflictedHiddenNodes.size===0)return n;let s=new Map,i=new Set,r=new Map,o=()=>{for(let[y,g]of this.hiddenNodeConflicts){let h=s.get(y)??[];for(let u of g)h.includes(u)||h.push(u);s.set(y,h);}this.conflictedHiddenNodes.forEach(y=>i.add(y));for(let[y,g]of this.hiddenNodeSelectors)r.has(y)||r.set(y,g);},a=10,c=1;for(;this.conflictedHiddenNodes.size>0&&c<a;)o(),this.conflictedHiddenNodes.forEach(y=>this.exemptFromHiding.add(y)),n=this.generateLayoutPass(e),c++;this.conflictedHiddenNodes.size>0&&(o(),console.warn(`Hidden-node conflict resolution did not converge after ${c} passes.`));let v=n.layout.nodes.filter(y=>this.reintroducedNodes.has(y.id));if(v.length>0&&(n.layout.reintroducedNodes=v),n.error===null||fC(n.error)){let y=this.buildHiddenNodeConflictInfo(s,i,r);y.reintroducedNodeIds=v.map(g=>g.id),n={...n,error:y};}return n}generateLayoutPass(e){this.selectorErrors=[],this.warnings=[],this.warningKeys.clear(),this.recordSpecParseWarnings(),this.hiddenNodeSelectors=new Map,this.hiddenSelectorSources=new Map,this.hiddenNodeConflicts=new Map,this.conflictedHiddenNodes=new Set,this.reintroducedNodes=new Set,this.inferredEdgeGroupStamps=new Map,this.cyclicFragments=[];let n=e,s=n.generateGraph(this.hideDisconnected,false),{attributes:i,textStyles:r}=this.generateAttributesAndRemoveEdges(s);(({attributes:i,textStyles:r}=this.generateTagsForNodes(s,i,r))),this.addinferredEdges(s);let o=this.generateGroups(s,e);this.addDrawInferredEdges(s,o),this.ensureNoExtraNodes(s,e,o);let a=this.getAtomStyleMap(s,n),{colorMap:c,explicitlyColored:v}=this.getNodeColorMap(s,n,a),y=this.getNodeDisplayContent(s,n,i,r),g=this.getNodeSizeMap(s,y),h=this.getDisconnectedNodes(s),u=s.nodes().map(R=>{let F=s.node(R)?.label||R,B=c[R]||"black",P=v.has(R)?"directive":"default-palette",{height:K,width:G}=g[R],V=this.getMostSpecificType(R,e),Q=this.getNodeTypes(R,e),rt=o.filter(_t=>_t.nodeIds.includes(R)).map(_t=>_t.name),ht=i[R]||{},it=r[R]||{},H,nt=n.getAtoms().find(_t=>_t.id===R);nt?.labels&&(H=nt.labels);let gt=a[R],mt=gt?.iconStyle,At=gt?.showLabel??true,Et=mt?.placement??"full";return {id:R,label:F,name:F,color:B,colorSource:P,fillColor:gt?.fillStyle?.color,borderWidth:gt?.borderStyle?.width,textStyle:gt?.textStyle,groups:rt,attributes:ht,attributeTextStyles:it,labels:H,icon:mt?.path??this.DEFAULT_NODE_ICON_PATH,iconPlacement:Et,iconOpacity:mt?.opacity,height:K,width:G,mostSpecificType:V,types:Q,showLabels:At,disconnected:h.includes(R)}}),d=[],f=0,l=0,p=[],x=[],b=[];try{let R=this.applyRelativeOrientationConstraints(u,s);d=R.conjunctive,b.push(...R.disjunctive),f=d.length;let I=this.applyAlignConstraints(u,s);d=d.concat(I.conjunctive),b.push(...I.disjunctive),l=I.conjunctive.length,console.log(`Generated ${f} orientation constraints and ${l} alignment constraints (deduped + transitive reduction applied)`),this.pruneRedundantAlignmentEdges(s),d=tft(d),x=this.buildCyclicDisjunctions(u,s),b.push(...x),p=this.buildLayoutEdges(s,u,o);}catch(R){if(Zht(R))return this.handleMissingNodeConstraintError(R,{layoutNodes:u,graph:s,groups:o,disconnectedNodes:h,constraints:d});throw R}let S={nodes:u,edges:p,constraints:d,groups:o,disjunctiveConstraints:b.length>0?b:void 0,hiddenAtoms:this.collectHiddenAtoms(),cyclicFragments:this.collectCyclicFragments()};if(this.hiddenNodeConflicts.size>0)return {layout:{...S,edges:this.filterHiddenEdges(S.edges),groups:S.groups.filter(I=>!I.negated),warnings:this.warnings},error:this.buildHiddenNodeConflictInfo(),selectorErrors:this.selectorErrors,warnings:this.warnings};let _=new exports.QualitativeConstraintValidator(S),T=_.validateConstraints();if(T){if(Od(T))return this.handlePositionalConstraintError(T,S);if(lE(T))return this.handleGroupOverlapError(T,S);throw T}d=S.constraints,p=this.filterHiddenEdges(p),S.nodes=u,S.edges=p,S.constraints=d,S.groups=o.filter(R=>!R.negated);let k=_ instanceof exports.QualitativeConstraintValidator?_:void 0;return S.warnings=this.warnings,{layout:S,error:null,selectorErrors:this.selectorErrors,warnings:this.warnings,validator:k}}handleMissingNodeConstraintError(e,n){let s=this.filterHiddenEdges(this.buildLayoutEdges(n.graph,n.layoutNodes,n.groups)),i=n.groups;return {layout:{nodes:n.layoutNodes,edges:s,constraints:n.constraints,groups:i,disjunctiveConstraints:[],warnings:this.warnings,hiddenAtoms:this.collectHiddenAtoms(),cyclicFragments:this.collectCyclicFragments()},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}buildHiddenNodeConflictInfo(e=this.hiddenNodeConflicts,n=this.conflictedHiddenNodes,s=this.hiddenNodeSelectors){let i=new Map,r=new Set;for(let[g,h]of e.entries())i.set(g,h);for(let g of n){let h=s.get(g);h&&r.add(h);}let o=[...n];for(let g of r){let h=this.hiddenSelectorSources.get(g),u=h?ib(h):`hideAtom with selector <code>${g}</code>`,d=[];for(let f of o)s.get(f)===g&&d.push(`${f} is hidden`);d.length>0&&i.set(u,d);}let a=[...e.keys()][0],v={conflictingConstraint:e.get(a)?.[0]||"",conflictingSourceConstraint:a,minimalConflictingConstraints:i};return {name:"HiddenNodeConflictError",type:"hidden-node-conflict",message:`Layout constraints reference atoms [${o.join(", ")}] that a hideAtom directive hides. The hide and the constraints cannot both be satisfied. The diagram shows the layout as if those atoms were not hidden; they are drawn with a dashed outline.`,hiddenNodes:s,droppedConstraints:e,errorMessages:v}}handlePositionalConstraintError(e,n){let s=e.minimalConflictingSet,i=e.maximalFeasibleSubset?n.constraints:n.constraints.filter(o=>![...s.values()].flat().includes(o));return {layout:{nodes:n.nodes,edges:n.edges,constraints:i,groups:n.groups,conflictingConstraints:[...s.values()].flat(),warnings:this.warnings,hiddenAtoms:n.hiddenAtoms,cyclicFragments:n.cyclicFragments},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}handleGroupOverlapError(e,n){let s=e.overlappingNodes.map(v=>v.groups).flat(),i=n.groups.filter(v=>s.includes(v.name)),r=i.flatMap(v=>v.nodeIds),o=n.nodes.filter(v=>r.includes(v.id)),a=n.edges.filter(v=>o.some(y=>v.source.id===y.id)&&o.some(y=>v.target.id===y.id));return {layout:{nodes:o,edges:a,constraints:n.constraints,groups:i,overlappingNodes:e.overlappingNodes,warnings:this.warnings,hiddenAtoms:n.hiddenAtoms,cyclicFragments:n.cyclicFragments},error:e,selectorErrors:this.selectorErrors,warnings:this.warnings}}buildCyclicDisjunctions(e,n){let s=this._layoutSpec.constraints.orientation.cyclic,i=[];for(let[r,o]of s.entries()){let a;try{a=this.evaluator.evaluate(o.selector,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(o.selector,"cyclic orientation selector",h);continue}if(!this.acceptSelectorResult(a,o.selector,"cyclic orientation selector","binary","cyclic",r,o))continue;let c=a.selectedTwoples(),v=new Map;c.forEach(h=>{let u=h[0],d=h[1],f=this.isNodeHiddenByDirective(u),l=this.isNodeHiddenByDirective(d);if(f||l){let b=`${u} is followed by ${d} in a ${o.direction} cycle`;this.recordHiddenNodeConflict(o,b,u,d,f,l);return}let p=e.find(b=>b.id===u),x=e.find(b=>b.id===d);if(!(!p||!x)){if(this.shouldAddAlignmentEdge(n,u,d)){let b=`_alignment_${u}_${d}_`;n.setEdge(u,d,b,b);}v.has(p)?v.get(p).push(x):v.set(p,[x]);}});let g=this.getFragmentsToConstrain(v).map(h=>h.Path.map(u=>u.id));o.direction==="counterclockwise"&&(g=g.map(h=>h.reverse())),g.forEach(h=>{let u=h.length;if(!o.negated&&u>=2&&this.cyclicFragments.push([...h]),u<=2)return;let d=[];for(let f=0;f<u;f++){let l=this.getCyclicConstraintForFragment(h,e,f,o);d.push(l);}if(o.negated){let f=new ys(o,d),l=qw(f,o);i.push(...l);}else {let f=new ys(o,d);i.push(f);}});}return i}getCyclicConstraintForFragment(e,n,s,i){if(e.length<=2)return [];let o=2*Math.PI/e.length,a={};for(var c=0;c<e.length;c++){let h=(c+s)*o,u=100*Math.cos(h),d=100*Math.sin(h);a[e[c]]={x:u,y:d};}let v=[];for(var y=0;y<e.length;y++)for(var g=0;g<e.length;g++)if(y!==g){let h=e[y],u=e[g],d=a[h],f=a[u];d.x>f.x?v.push(this.leftConstraint(u,h,this.minSepWidth,n,i)):d.x<f.x?v.push(this.leftConstraint(h,u,this.minSepWidth,n,i)):v.push(this.ensureSameXConstraint(h,u,n,i)),d.y>f.y?v.push(this.topConstraint(u,h,this.minSepHeight,n,i)):d.y<f.y?v.push(this.topConstraint(h,u,this.minSepHeight,n,i)):v.push(this.ensureSameYConstraint(h,u,n,i));}return v}getAllPaths(e){let n=[],s=new Set;function i(r,o){o.push(r);let a=e.get(r);if(!e.has(r)||!a||a.length===0){let c=new yb(o,void 0);n.push(c);}else for(let c of a)if(!o.includes(c))i(c,[...o]);else {let v=new yb(o,c);n.push(v);}}for(let r of e.keys())s.has(r)||i(r,[]);return n}getFragmentsToConstrain(e){let n=this.getAllPaths(e),s=n.filter((r,o)=>!n.some((a,c)=>c<o&&yb.areEquivalent(r,a)));return s.filter((r,o)=>!s.some((a,c)=>o!==c&&a.isSubpathOf(r)))}applyRelativeOrientationConstraints(e,n){let s=[],i=[],r=this._layoutSpec.constraints.orientation.relative,o=new Set,a=new Map,c=new Map;return r.forEach((v,y)=>{let g=v.directions,h=v.selector,u;try{u=this.evaluator.evaluate(h,{instanceIndex:this.instanceNum});}catch(f){this.recordSelectorError(h,"orientation selector",f);return}if(!this.acceptSelectorResult(u,h,"orientation selector","binary","orientation",y,v))return;u.selectedTwoples().forEach(f=>{let l=f[0],p=f[1],x=this.isNodeHiddenByDirective(l),b=this.isNodeHiddenByDirective(p);if(x||b){for(let S of g){let _=eft(l,p,S);this.recordHiddenNodeConflict(v,_,l,p,x,b);}return}if(v.negated){if(this.shouldAddAlignmentEdge(n,l,p)){let S=`_alignment_${l}_${p}_`;n.setEdge(l,p,S,S);}if(g.length===1){let S=this.negateOrientationDirection(g[0],l,p,e,v);S.length===1?s.push(S[0][0]):i.push(new ys(v,S));}else {let S=[];for(let _ of g){let T=this.negateOrientationDirection(_,l,p,e,v);S.push(...T);}i.push(new ys(v,S));}return}g.forEach(S=>{if(this.shouldAddAlignmentEdge(n,l,p)){let _=`_alignment_${l}_${p}_`;n.setEdge(l,p,_,_);}if(S=="left"){let _=`left:${p}:${l}:${this.minSepWidth}`;!o.has(_)&&!this.hasTransitivePath(a,p,l)&&(o.add(_),this.addToTransitiveGraph(a,p,l),s.push(this.leftConstraint(p,l,this.minSepWidth,e,v)));}else if(S=="above"){let _=`top:${p}:${l}:${this.minSepHeight}`;!o.has(_)&&!this.hasTransitivePath(c,p,l)&&(o.add(_),this.addToTransitiveGraph(c,p,l),s.push(this.topConstraint(p,l,this.minSepHeight,e,v)));}else if(S=="right"){let _=`left:${l}:${p}:${this.minSepWidth}`;!o.has(_)&&!this.hasTransitivePath(a,l,p)&&(o.add(_),this.addToTransitiveGraph(a,l,p),s.push(this.leftConstraint(l,p,this.minSepWidth,e,v)));}else if(S=="below"){let _=`top:${l}:${p}:${this.minSepHeight}`;!o.has(_)&&!this.hasTransitivePath(c,l,p)&&(o.add(_),this.addToTransitiveGraph(c,l,p),s.push(this.topConstraint(l,p,this.minSepHeight,e,v)));}else if(S=="directlyLeft"){let _=`left:${p}:${l}:${this.minSepWidth}`,T=`align-y:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(a,p,l)&&(o.add(_),this.addToTransitiveGraph(a,p,l),s.push(this.leftConstraint(p,l,this.minSepWidth,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameYConstraint(p,l,e,v)));}else if(S=="directlyAbove"){let _=`top:${p}:${l}:${this.minSepHeight}`,T=`align-x:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(c,p,l)&&(o.add(_),this.addToTransitiveGraph(c,p,l),s.push(this.topConstraint(p,l,this.minSepHeight,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameXConstraint(p,l,e,v)));}else if(S=="directlyRight"){let _=`left:${l}:${p}:${this.minSepWidth}`,T=`align-y:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(a,l,p)&&(o.add(_),this.addToTransitiveGraph(a,l,p),s.push(this.leftConstraint(l,p,this.minSepWidth,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameYConstraint(p,l,e,v)));}else if(S=="directlyBelow"){let _=`top:${l}:${p}:${this.minSepHeight}`,T=`align-x:${p}:${l}`;!o.has(_)&&!this.hasTransitivePath(c,l,p)&&(o.add(_),this.addToTransitiveGraph(c,l,p),s.push(this.topConstraint(l,p,this.minSepHeight,e,v))),o.has(T)||(o.add(T),s.push(this.ensureSameXConstraint(p,l,e,v)));}});});}),{conjunctive:s,disjunctive:i}}negateOrientationDirection(e,n,s,i,r){switch(e){case "left":return [[this.leftConstraint(n,s,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)]];case "right":return [[this.leftConstraint(s,n,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)]];case "above":return [[this.topConstraint(n,s,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)]];case "below":return [[this.topConstraint(s,n,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)]];case "directlyLeft":return [[this.leftConstraint(n,s,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)],[this.topConstraint(n,s,0,i,r)],[this.topConstraint(s,n,0,i,r)]];case "directlyRight":return [[this.leftConstraint(s,n,0,i,r)],[this.ensureSameXConstraint(n,s,i,r)],[this.topConstraint(n,s,0,i,r)],[this.topConstraint(s,n,0,i,r)]];case "directlyAbove":return [[this.topConstraint(n,s,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)],[this.leftConstraint(n,s,0,i,r)],[this.leftConstraint(s,n,0,i,r)]];case "directlyBelow":return [[this.topConstraint(s,n,0,i,r)],[this.ensureSameYConstraint(n,s,i,r)],[this.leftConstraint(n,s,0,i,r)],[this.leftConstraint(s,n,0,i,r)]];default:return []}}hasTransitivePath(e,n,s){let i=e.get(n);if(!i)return false;if(i.has(s))return true;let r=new Set([n]),o=Array.from(i);for(;o.length>0;){let a=o.shift();if(a===s)return true;if(r.has(a))continue;r.add(a);let c=e.get(a);if(c)for(let v of c)r.has(v)||o.push(v);}return false}addToTransitiveGraph(e,n,s){e.has(n)||e.set(n,new Set),e.get(n).add(s);let i=e.get(s)||new Set;for(let[r,o]of e.entries())if(r===n||o.has(n)){o.add(s);for(let a of i)o.add(a);}}applyAlignConstraints(e,n){let s=[],i=[],r=this._layoutSpec.constraints.alignment,o=new Set;return r.forEach((a,c)=>{let v=a.direction,y=a.selector,g;try{g=this.evaluator.evaluate(y,{instanceIndex:this.instanceNum});}catch(u){this.recordSelectorError(y,"align selector",u);return}if(!this.acceptSelectorResult(g,y,"align selector","binary","align",c,a))return;g.selectedTwoples().forEach(u=>{let d=u[0],f=u[1],l=this.isNodeHiddenByDirective(d),p=this.isNodeHiddenByDirective(f);if(l||p){let b=`${d} is ${v==="horizontal"?"horizontally":"vertically"} aligned with ${f}`;this.recordHiddenNodeConflict(a,b,d,f,l,p);return}if(this.shouldAddAlignmentEdge(n,d,f)){let x=`_alignment_${d}_${f}_`;n.setEdge(d,f,x,x);}if(a.negated){let[x,b]=[d,f].sort(),S=`not-align-${v==="horizontal"?"y":"x"}:${x}:${b}`;if(!o.has(S))if(o.add(S),v==="horizontal"){let _=[this.topConstraint(d,f,0,e,a)],T=[this.topConstraint(f,d,0,e,a)];i.push(new ys(a,[_,T]));}else {let _=[this.leftConstraint(d,f,0,e,a)],T=[this.leftConstraint(f,d,0,e,a)];i.push(new ys(a,[_,T]));}return}if(v==="horizontal"){let[x,b]=[d,f].sort(),S=`align-y:${x}:${b}`;o.has(S)||(o.add(S),s.push(this.ensureSameYConstraint(d,f,e,a)));}else if(v==="vertical"){let[x,b]=[d,f].sort(),S=`align-x:${x}:${b}`;o.has(S)||(o.add(S),s.push(this.ensureSameXConstraint(d,f,e,a)));}});}),{conjunctive:s,disjunctive:i}}shouldAddAlignmentEdge(e,n,s){if(this.alignmentEdgeStrategy==="never")return false;let i=this.hasDirectEdgeBetween(e,n,s);return this.alignmentEdgeStrategy==="direct"?!i:i?false:!this.isConnectedViaPath(e,n,s)}hasDirectEdgeBetween(e,n,s){return typeof e.hasEdge=="function"&&(e.hasEdge(n,s)||e.hasEdge(s,n))||(e.inEdges(n)||[]).some(i=>i.v===s)||(e.outEdges(n)||[]).some(i=>i.w===s)||(e.inEdges(s)||[]).some(i=>i.v===n)||(e.outEdges(s)||[]).some(i=>i.w===n)}isConnectedViaPath(e,n,s,i){let r=new Set,o=[n];for(;o.length>0;){let a=o.shift();if(a===s)return true;if(r.has(a))continue;r.add(a);let c=e.outEdges(a)||[],v=e.inEdges(a)||[];for(let y of [...c,...v]){if(i&&(y.v===i.v&&y.w===i.w&&y.name===i.name||y.v===i.w&&y.w===i.v&&y.name===i.name))continue;let g=y.v===a?y.w:y.v;r.has(g)||o.push(g);}}return false}pruneRedundantAlignmentEdges(e){if(this.alignmentEdgeStrategy!=="connected")return;let n=e.edges().filter(i=>{let r=i.name;return r&&r.includes("_alignment_")}),s=[];for(let i of n)this.isConnectedViaPath(e,i.v,i.w,i)&&(e.removeEdge(i.v,i.w,i.name),s.push(i));s.length>0&&console.log(`Pruned ${s.length} redundant alignment edges out of ${n.length} total alignment edges`);}getDisconnectedNodes(e){let n=e.edges().map(a=>a.w),s=e.edges().map(a=>a.v),i=new Set(e.nodes()),r=new Set([...n,...s]);return [...i].filter(a=>!r.has(a))}buildLayoutEdges(e,n,s=[]){let i=new Map,r=new Map;for(let o of s){o.keyNodeId!=null&&i.set(o.name,o.keyNodeId);let a=o.sourceConstraint;a instanceof xh&&(a.connectorLineStyle||a.connectorTextStyle)&&r.set(o.name,{lineStyle:a.connectorLineStyle,textStyle:a.connectorTextStyle});}return e.edges().map(o=>{let a=o.name,c=e.edge(o.v,o.w,a),v=n.find(F=>F.id===o.v),y=n.find(F=>F.id===o.w),g=this.getRelationName(e,o),h=!!a&&a.startsWith("_g_"),u=h?i.get(c)??o.v:void 0,d=u!==void 0?u:o.v,f=u!==void 0?u===o.v?o.w:o.v:o.w,l=h?r.get(c):void 0,p=l?.lineStyle,x=this.resolveEdgeStyleForEdge(g,d,f),b=p?.color??x.lineStyle?.color??this.getEdgeColor(g,d,f,a),S=p?.pattern??x.lineStyle?.pattern??this.getEdgeStyle(g,d,f,a),_=p?.weight??x.lineStyle?.weight??this.getEdgeWeight(g,d,f,a),T=x.showLabel??this.getEdgeShowLabel(g,d,f,a),k=p?.highlight??x.lineStyle?.highlight??this.getEdgeHighlight(g,d,f,a),R=l?.textStyle??this.getInferredEdgeDirective(a)?.textStyle??x.textStyle;return !v||!y||!a?null:{source:v,target:y,label:c,relationName:g,id:a,color:b,style:S,weight:_,showLabel:T,highlight:k,textStyle:R,groupId:h?c:void 0,keyNodeId:u,sourceGroupId:h?u===o.v?void 0:u===o.w?c:void 0:this.inferredEdgeGroupStamps.get(a)?.sourceGroupId,targetGroupId:h?u===o.v?c:void 0:this.inferredEdgeGroupStamps.get(a)?.targetGroupId}}).filter(o=>o!==null)}filterHiddenEdges(e){return e.filter(n=>!n.id.startsWith(this.hideThisEdge))}getNodeFromId(e,n,s){let i=n.find(r=>r.id===e);if(!i)throw new ME(e,s);return i}leftConstraint(e,n,s,i,r){let o=this.getNodeFromId(e,i,r),a=this.getNodeFromId(n,i,r);return {left:o,right:a,minDistance:s,sourceConstraint:r}}topConstraint(e,n,s,i,r){let o=this.getNodeFromId(e,i,r),a=this.getNodeFromId(n,i,r);return {top:o,bottom:a,minDistance:s,sourceConstraint:r}}ensureSameYConstraint(e,n,s,i){let r=this.getNodeFromId(e,s,i),o=this.getNodeFromId(n,s,i);return {axis:"y",node1:r,node2:o,sourceConstraint:i}}ensureSameXConstraint(e,n,s,i){let r=this.getNodeFromId(e,s,i),o=this.getNodeFromId(n,s,i);return {axis:"x",node1:r,node2:o,sourceConstraint:i}}singletonGroup(e){return {name:`${KE.DISCONNECTED_PREFIX}${e}`,nodeIds:[e],keyNodeId:e,showLabel:false}}getNodeDisplayContent(e,n,s,i){let r={},o=n.getAtoms();for(let a of e.nodes()){let v=e.node(a)?.label||a,y=s[a]||{},g=i[a]||{},h=Object.entries(y).sort(([p],[x])=>p.localeCompare(x)),u=h.map(([p,x])=>`${p}: ${x.join(", ")}`),d=h.map(([p])=>rv(g[p]?.size)),f=o.find(p=>p.id===a),l=[];if(f?.labels)for(let p of Object.values(f.labels))l.push(Array.isArray(p)?p.join(", "):String(p));r[a]={label:v,attributeLines:u,attributeFontSizes:d,skolemLines:l};}return r}getNodeSizeMap(e,n){let s={};this._layoutSpec.directives.sizes.forEach((o,a)=>{let c;try{let g=this.evaluator.evaluate(o.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(g,o.selector,"size selector","unary","size",a))return;c=g.selectedAtoms();}catch(g){this.recordSelectorError(o.selector,"size selector",g);return}let v=o.width,y=o.height;c.forEach(g=>{if(s[g]){let h=s[g];if(h.width!==v||h.height!==y)throw new Error(`Size Conflict: "${g}" cannot have multiple sizes: ${JSON.stringify(h)}, ${JSON.stringify({width:v,height:y})}.`)}s[g]={width:v,height:y};});});let r={w:this.DEFAULT_NODE_WIDTH,h:this.DEFAULT_NODE_HEIGHT};for(let o of e.nodes()){if(s[o])continue;let a=n[o],c=a?.label??"",v=a?[...a.attributeLines.map((y,g)=>({text:y,fontSize:a.attributeFontSizes[g]})),...a.skolemLines]:[];s[o]=fK(c,v,{min:r});}return s}getAtomStyleMap(e,n){let s=this._layoutSpec.directives.atomStyles,i={};if(s.length===0)return i;let r=[...e.nodes()],o=new Set(r),a={};s.forEach((c,v)=>{let y;if(!c.selector)y=r;else try{let g=this.evaluator.evaluate(c.selector,{instanceIndex:this.instanceNum});if(!this.acceptSelectorResult(g,c.selector,"atomStyle selector","unary","atomStyle",v))return;y=g.selectedAtoms();}catch(g){this.recordSelectorError(c.selector,"atomStyle selector",g);return}y.forEach(g=>{o.has(g)&&(a[g]||(a[g]=[]),a[g].push(c));});});for(let c of r){let v=a[c];!v||v.length===0||(i[c]=K4(v,`atom "${c}"`));}return i}getNodeColorMap(e,n,s){let i={},r=new Set,o=this.getSigColors(n),a=[...e.nodes()];return a.forEach(c=>{let v=s[c]?.borderStyle?.color;v&&(i[c]=v,r.add(c));}),a.forEach(c=>{if(!i[c]){let v=this.getMostSpecificType(c,n);i[c]=o[v];}}),{colorMap:i,explicitlyColored:r}}getEdgeColor(e,n,s,i){let r=this.getInferredEdgeDirective(i);if(r?.color)return r.color;let o=this.findEdgeDirective(e,n,s);return o?.color?o.color:"black"}getEdgeStyle(e,n,s,i){let r=this.getInferredEdgeDirective(i),o=rb(r?.style);if(o)return o;let a=this.findEdgeDirective(e,n,s);return rb(a?.style)}getEdgeHighlight(e,n,s,i){let r=this.getInferredEdgeDirective(i);return r?.highlight?r.highlight:this.findEdgeDirective(e,n,s)?.highlight}getEdgeWeight(e,n,s,i){let r=this.getInferredEdgeDirective(i),o=this.normalizeEdgeWeight(r?.weight,"inferred edge");if(o!==void 0)return o;let a=this.findEdgeDirective(e,n,s);return this.normalizeEdgeWeight(a?.weight,"edge")}getEdgeShowLabel(e,n,s,i){return this.findEdgeDirective(e,n,s)?.showLabel}getInferredEdgeDirective(e){let n="_inferred_";return !e||!e.includes(n)?void 0:this._layoutSpec.directives.inferredEdges.find(i=>e.includes(`${n}<:${i.name}`))}edgeDirectiveMatches(e,n,s,i){if(e.field!==n)return false;if(e.selector)try{if(!this.evaluator.evaluate(e.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(s))return !1}catch(r){return this.recordSelectorError(e.selector,"edge selector",r),false}if(e.filter&&i)try{if(!this.evaluator.evaluate(e.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(a=>a[0]===s&&a[1]===i))return !1}catch(r){return this.recordSelectorError(e.filter,"edge filter",r),false}return true}resolveEdgeStyleForEdge(e,n,s){let i=this._layoutSpec.directives.edgeStyles.filter(r=>this.edgeDirectiveMatches(r,e,n,s));return i.length===0?{}:I4(i,`edge ${e} (${n} \u2192 ${s})`)}findEdgeDirective(e,n,s){let i=this._layoutSpec.directives.edgeColors;for(let r of i){if(r.field!==e)continue;let o=true;if(r.selector)try{o=this.evaluator.evaluate(r.selector,{instanceIndex:this.instanceNum}).selectedAtoms().includes(n);}catch(c){this.recordSelectorError(r.selector,"edge selector",c),o=false;}if(!o)continue;let a=true;if(r.filter&&s)try{a=this.evaluator.evaluate(r.filter,{instanceIndex:this.instanceNum}).selectedTwoples().some(y=>y[0]===n&&y[1]===s);}catch(c){this.recordSelectorError(r.filter,"edge filter",c),a=false;}if(o&&a)return r}}normalizeEdgeWeight(e,n){if(e!=null){if(typeof e!="number"||Number.isNaN(e)||e<=0){console.warn(`Ignoring ${n} weight because it is not a positive number: ${e}`);return}return e}}getSigColors(e){let n={},s=e.getTypes(),i=new db(s.length);return s.forEach(r=>{n[r.id]=i.getNextColor();}),n}getFieldTuples(e,n){return Kf(e.getRelations().filter(s=>s.name===n).flatMap(s=>s.tuples)).map(s=>s.atoms)}getFieldTuplesForSourceAndTarget(e,n,s,i){return this.getFieldTuples(e,n).filter(a=>{let c=a.length;return c<1?false:a[0]===s&&a[c-1]===i})}addinferredEdges(e){let n="_inferred_";this._layoutSpec.directives.inferredEdges.forEach((s,i)=>{if(s.draw)return;let r;try{r=this.evaluator.evaluate(s.selector,{instanceIndex:this.instanceNum});}catch(c){this.recordSelectorError(s.selector,"inferredEdge selector",c);return}if(!this.acceptSelectorResult(r,s.selector,"inferredEdge selector","any","inferredEdge",i))return;let o=r.selectedTuplesAll(),a=`${n}<:${s.name}`;o.forEach(c=>{let v=c.length,y=c[0],g=c[v-1],h=s.name;if(v>2){let f=c.slice(1,v-1).map(l=>e.node(l)?.label||l).join(",");h=`${h}[${f}]`;}let u=c.join("->"),d=`${a}<:${u}`;e.setEdge(y,g,h,d);});});}addDrawInferredEdges(e,n){let s="_inferred_";this._layoutSpec.directives.inferredEdges.forEach((i,r)=>{if(!i.draw)return;let o=i.draw,a=[...new Set([o.source,o.target])].filter(h=>h!==null),c=h=>n.filter(u=>u.sourceConstraint!==void 0&&u.sourceConstraint.name===h);for(let h of a){let u=c(h),d=u.filter(f=>f.keyed!==true);if(d.length>1)throw new Error(`inferredEdge '${i.name}': draw endpoint '${h}' is ambiguous \u2014 ${d.length} group constraints named '${h}' each build a single (unkeyed) group. Rename one of them.`);if(d.length===1&&u.length>1)throw new Error(`inferredEdge '${i.name}': draw endpoint '${h}' is ambiguous \u2014 '${h}' names both a keyed group constraint (one group per key) and a single-group (unary) constraint. Rename one of them.`)}for(let h of a)if(c(h).length===0){console.warn(`[spytial] inferredEdge '${i.name}': skipping \u2014 no '${h}' groups exist in this instance.`);return}let v;try{v=this.evaluator.evaluate(i.selector,{instanceIndex:this.instanceNum});}catch(h){this.recordSelectorError(i.selector,"inferredEdge selector",h);return}if(!this.acceptSelectorResult(v,i.selector,"inferredEdge selector","any","inferredEdge",r))return;let y;v.maxArity()>1?y=v.selectedTuplesAll():y=v.selectedAtoms().map(h=>[h]);let g=`${s}<:${i.name}`;y.forEach(h=>{let u=h.length,d=h[0],f=h[u-1],l=this.resolveDrawEnd(e,n,o.source,d,i.name),p=this.resolveDrawEnd(e,n,o.target,f,i.name);if(!l||!p)return;let x=i.name;if(u>2){let _=h.slice(1,u-1).map(T=>e.node(T)?.label||T).join(",");x=`${x}[${_}]`;}let b=h.join("->"),S=`${g}<:${b}`;e.setEdge(l.anchor,p.anchor,x,S),(l.groupId||p.groupId)&&this.inferredEdgeGroupStamps.set(S,{sourceGroupId:l.groupId,targetGroupId:p.groupId});});});}resolveDrawEnd(e,n,s,i,r){if(s===null)return e.hasNode(i)?{anchor:i}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 endpoint atom '${i}' is not in the graph (hidden or projected away).`),null);let o=n.filter(g=>g.sourceConstraint!==void 0&&g.sourceConstraint.name===s),a=o.find(g=>g.keyed!==true);if(a){let g=a.nodeIds.find(h=>e.hasNode(h));return g?{anchor:g,groupId:a.name}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 group '${a.name}' has no members present in the graph to anchor on.`),null)}let c=o.filter(g=>g.keyed===true&&g.keyNodeId===i);if(c.length===0)return console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 atom '${i}' does not key any '${s}' group in this instance.`),null;if(c.length>1)throw new Error(`inferredEdge '${r}': ambiguous draw endpoint \u2014 atom '${i}' keys ${c.length} groups named '${s}[\u2026]'. Rename one of the group constraints.`);let v=c[0],y=v.nodeIds.find(g=>e.hasNode(g));return y?{anchor:y,groupId:v.name}:(console.warn(`[spytial] inferredEdge '${r}': skipping edge \u2014 group '${v.name}' has no members present in the graph to anchor on.`),null)}};KE.DISCONNECTED_PREFIX="_d_";exports.LayoutInstance=KE;});function NK(t,e){let n=new jE;for(let[f,l]of e)n.union(f,l);let s=new Set;for(let f of t)s.add(f.before),s.add(f.after);for(let[f,l]of e)s.add(f),s.add(l);if(s.size===0)return {raw:new Map,component:new Map};let i=new Map,r=new Map,o=new Set;for(let f of s)o.add(n.find(f));for(let f of o)i.set(f,[]),r.set(f,0);for(let f of t){let l=n.find(f.before),p=n.find(f.after);if(l===p)return null;i.get(l).push({to:p,gap:f.gap}),r.set(p,r.get(p)+1);}let a=[];for(let[f,l]of r)l===0&&a.push(f);let c=new Map;for(let f of o)c.set(f,0);let v=0;for(;a.length>0;){let f=a.shift();v++;let l=c.get(f);for(let{to:p,gap:x}of i.get(f)){c.set(p,Math.max(c.get(p),l+x));let b=r.get(p)-1;r.set(p,b),b===0&&a.push(p);}}if(v<o.size)return null;let y=new jE;for(let f of t)y.union(f.before,f.after);for(let[f,l]of e)y.union(f,l);let g=new Map,h=0,u=new Map,d=new Map;for(let f of s){u.set(f,c.get(n.find(f)));let l=y.find(f);g.has(l)||g.set(l,h++),d.set(f,g.get(l));}return {raw:u,component:d}}function RK(t,e,n,s){let i=(s==="x"?t.width:t.height)??100,r=(s==="x"?e.width:e.height)??100,o=i/2+r/2+n,a=Math.min(Math.max(i,r)*.1,20);return o+a}function yft(t){let e=[],n=[];return t.forEach((s,i)=>(i%2===0?e:n).push(s)),n.reverse(),[...e,...n]}function mft(t,e){let n=t.map(l=>l.id),s=new Map(t.map(l=>[l.id,l])),i=new Map,r=new Map;for(let l of n)i.set(l,[]),r.set(l,0);let o=new Set;for(let[l,p]of e){if(l===p||!i.has(l)||!i.has(p))continue;let x=`${l}\0${p}`;o.has(x)||(o.add(x),i.get(l).push(p),r.set(p,r.get(p)+1));}let a=new Map;for(let l of n)a.set(l,[]);let c=new Set,v=[],y=l=>{c.add(l),v.push(l);let p=[l];for(;p.length>0;){let x=p.shift();for(let b of i.get(x))c.has(b)||(c.add(b),a.get(x).push(b),p.push(b));}};for(let l of n)(r.get(l)??0)===0&&!c.has(l)&&y(l);for(let l of n)c.has(l)||y(l);let g=new Map,h=new Map,u=new Map,d=new Map,f=l=>{let p=d.get(l);return p===void 0&&(p=d.size,d.set(l,p)),p};for(let l of v){let p=[{id:l,childIndex:0}];for(;p.length>0;){let x=p[p.length-1],b=a.get(x.id);if(x.childIndex<b.length){p.push({id:b[x.childIndex],childIndex:0}),x.childIndex++;continue}p.pop();let S=b.map(R=>g.get(R)).sort((R,I)=>R-I),_=s.get(x.id)?.mostSpecificType??"";g.set(x.id,f(`${_}(${S.join(",")})`)),h.set(x.id,b.reduce((R,I)=>R+h.get(I),1));let T=s.get(x.id)?.width??100,k=b.reduce((R,I)=>R+u.get(I),0)+UE*Math.max(0,b.length-1);u.set(x.id,Math.max(T,k));}}return {children:a,roots:v,hash:g,size:h,width:u}}function LK(t,e,n){let s=t.nodes;if(s.length===0)return null;let i=[],r=[],o=[],a=[];for(let B of t.constraints)ii(B)?i.push({before:B.left.id,after:B.right.id,gap:RK(B.left,B.right,B.minDistance,"x")}):ni(B)?r.push({before:B.top.id,after:B.bottom.id,gap:RK(B.top,B.bottom,B.minDistance,"y")}):Fn(B)&&(B.axis==="x"?o.push([B.node1.id,B.node2.id]):a.push([B.node1.id,B.node2.id]));let c=NK(i,o),v=NK(r,a);if(c===null||v===null)return null;let y=t.edges.map(B=>[B.source.id,B.target.id]),g=mft(s,y),h=new Map,u=new Map,d=B=>{let P=B.filter(G=>c.raw.has(G)),K=B.filter(G=>!c.raw.has(G));return P.sort((G,V)=>c.raw.get(G)-c.raw.get(V)),K.sort((G,V)=>{let Q=g.hash.get(G)-g.hash.get(V);if(Q!==0)return Q;let rt=g.size.get(V)-g.size.get(G);return rt!==0?rt:G<V?-1:1}),[...P,...yft(K)]},f=(B,P)=>{let K=c.raw.get(B),G=c.raw.get(P);return K!==void 0&&G!==void 0&&c.component.get(B)===c.component.get(P)&&Math.abs(K-G)>gft},l=0;for(let B of g.roots){let P=g.width.get(B),K=l+P/2;l+=P+UE*2;let G=[{id:B,centerX:K,y:0}];for(;G.length>0;){let{id:V,centerX:Q,y:rt}=G.pop();h.set(V,Q),u.set(V,rt);let ht=d(g.children.get(V));if(ht.length===0)continue;let it=ht.reduce((q,nt)=>q+g.width.get(nt),0)+UE*Math.max(0,ht.length-1),H=Q-it/2;for(let q of ht){let nt=g.width.get(q);G.push({id:q,centerX:H+nt/2,y:rt+(f(V,q)?0:dft)}),H+=nt+UE;}}}let p=(B,P)=>{let K=new Map;for(let[V,Q]of B.raw){let rt=B.component.get(V),ht=K.get(rt)??{delta:0,count:0};ht.delta+=(P.get(V)??0)-Q,ht.count+=1,K.set(rt,ht);}let G=new Map;for(let[V,Q]of B.raw){let{delta:rt,count:ht}=K.get(B.component.get(V));G.set(V,Q+rt/ht);}return G},x=p(c,h),b=p(v,u),S=new Map,_=1/0,T=-1/0,k=1/0,R=-1/0;for(let B of s){let P=x.get(B.id)??h.get(B.id)??0,K=b.get(B.id)??u.get(B.id)??0;S.set(B.id,{x:P,y:K}),_=Math.min(_,P),T=Math.max(T,P),k=Math.min(k,K),R=Math.max(R,K);}let I=e/2-(_+T)/2,F=n/2-(k+R)/2;for(let B of S.values())B.x+=I,B.y+=F;return S}function IK(t){return t.constraints.some(e=>ii(e)||ni(e)||Fn(e))}var dft,UE,gft,jE,PK=Ie(()=>{Ll();dft=130,UE=40,gft=.5,jE=class{constructor(){this.parent=new Map;}find(e){let n=this.parent.get(e)??e;for(;n!==(this.parent.get(n)??n);)n=this.parent.get(n)??n;let s=e;for(;s!==n;){let i=this.parent.get(s)??s;this.parent.set(s,n),s=i;}return n}union(e,n){let s=this.find(e),i=this.find(n);s!==i&&this.parent.set(s,i);}};});var Fl=qt((h3t,DK)=>{var HE;if(typeof Ma=="function")try{HE=kf();}catch{}HE||(HE=window.graphlib);DK.exports=HE;});var MK=qt((p3t,kK)=>{var vft=LA(),xft=1,_ft=4;function bft(t){return vft(t,xft|_ft)}kK.exports=bft;});var mb=qt((d3t,KK)=>{var Tft=ny(),Eft=lh(),Sft=Xx(),Oft=Mu();function Aft(t,e,n){if(!Oft(n))return false;var s=typeof e;return (s=="number"?Eft(n)&&Sft(e,n.length):s=="string"&&e in n)?Tft(n[e],t):false}KK.exports=Aft;});var UK=qt((g3t,BK)=>{var wft=a_(),Cft=ny(),Nft=mb(),Rft=cd(),FK=Object.prototype,Lft=FK.hasOwnProperty,Ift=wft(function(t,e){t=Object(t);var n=-1,s=e.length,i=s>2?e[2]:void 0;for(i&&Nft(e[0],e[1],i)&&(s=1);++n<s;)for(var r=e[n],o=Rft(r),a=-1,c=o.length;++a<c;){var v=o[a],y=t[v];(y===void 0||Cft(y,FK[v])&&!Lft.call(t,v))&&(t[v]=r[v]);}return t});BK.exports=Ift;});var HK=qt((y3t,jK)=>{var Pft=ch(),Dft=lh(),kft=Df();function Mft(t){return function(e,n,s){var i=Object(e);if(!Dft(e)){var r=Pft(n,3);e=kft(e),n=function(a){return r(i[a],a,i)};}var o=t(e,n,s);return o>-1?i[r?e[o]:o]:void 0}}jK.exports=Mft;});var qK=qt((m3t,GK)=>{var Kft=/\s/;function Fft(t){for(var e=t.length;e--&&Kft.test(t.charAt(e)););return e}GK.exports=Fft;});var $K=qt((v3t,zK)=>{var Bft=qK(),Uft=/^\s+/;function jft(t){return t&&t.slice(0,Bft(t)+1).replace(Uft,"")}zK.exports=jft;});var XK=qt((x3t,WK)=>{var Hft=$K(),VK=Mu(),Gft=uy(),YK=NaN,qft=/^[-+]0x[0-9a-f]+$/i,zft=/^0b[01]+$/i,$ft=/^0o[0-7]+$/i,Vft=parseInt;function Yft(t){if(typeof t=="number")return t;if(Gft(t))return YK;if(VK(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=VK(e)?e+"":e;}if(typeof t!="string")return t===0?t:+t;t=Hft(t);var n=zft.test(t);return n||$ft.test(t)?Vft(t.slice(2),n?2:8):qft.test(t)?YK:+t}WK.exports=Yft;});var iN=qt((_3t,JK)=>{var Wft=XK(),QK=1/0,Xft=17976931348623157e292;function Qft(t){if(!t)return t===0?t:0;if(t=Wft(t),t===QK||t===-QK){var e=t<0?-1:1;return e*Xft}return t===t?t:0}JK.exports=Qft;});var t7=qt((b3t,ZK)=>{var Jft=iN();function Zft(t){var e=Jft(t),n=e%1;return e===e?n?e-n:e:0}ZK.exports=Zft;});var r7=qt((T3t,e7)=>{var tpt=iw(),ept=ch(),rpt=t7(),npt=Math.max;function ipt(t,e,n){var s=t==null?0:t.length;if(!s)return -1;var i=n==null?0:rpt(n);return i<0&&(i=npt(s+i,0)),tpt(t,ept(e,3),i)}e7.exports=ipt;});var i7=qt((E3t,n7)=>{var opt=HK(),spt=r7(),apt=opt(spt);n7.exports=apt;});var oN=qt((S3t,o7)=>{var upt=dT();function lpt(t){var e=t==null?0:t.length;return e?upt(t,1):[]}o7.exports=lpt;});var a7=qt((O3t,s7)=>{var cpt=uT(),hpt=IA(),fpt=cd();function ppt(t,e){return t==null?t:cpt(t,hpt(e),fpt)}s7.exports=ppt;});var l7=qt((A3t,u7)=>{function dpt(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}u7.exports=dpt;});var h7=qt((w3t,c7)=>{var gpt=Vx(),ypt=lT(),mpt=ch();function vpt(t,e){var n={};return e=mpt(e,3),ypt(t,function(s,i,r){gpt(n,i,e(s,i,r));}),n}c7.exports=vpt;});var GE=qt((C3t,f7)=>{var xpt=uy();function _pt(t,e,n){for(var s=-1,i=t.length;++s<i;){var r=t[s],o=e(r);if(o!=null&&(a===void 0?o===o&&!xpt(o):n(o,a)))var a=o,c=r;}return c}f7.exports=_pt;});var d7=qt((N3t,p7)=>{function bpt(t,e){return t>e}p7.exports=bpt;});var y7=qt((R3t,g7)=>{var Tpt=GE(),Ept=d7(),Spt=hd();function Opt(t){return t&&t.length?Tpt(t,Spt,Ept):void 0}g7.exports=Opt;});var sN=qt((L3t,m7)=>{var Apt=Vx(),wpt=ny();function Cpt(t,e,n){(n!==void 0&&!wpt(t[e],n)||n===void 0&&!(e in t))&&Apt(t,e,n);}m7.exports=Cpt;});var _7=qt((I3t,x7)=>{var Npt=ud(),Rpt=r_(),Lpt=dc(),Ipt="[object Object]",Ppt=Function.prototype,Dpt=Object.prototype,v7=Ppt.toString,kpt=Dpt.hasOwnProperty,Mpt=v7.call(Object);function Kpt(t){if(!Lpt(t)||Npt(t)!=Ipt)return false;var e=Rpt(t);if(e===null)return true;var n=kpt.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&v7.call(n)==Mpt}x7.exports=Kpt;});var aN=qt((P3t,b7)=>{function Fpt(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}b7.exports=Fpt;});var E7=qt((D3t,T7)=>{var Bpt=c0(),Upt=cd();function jpt(t){return Bpt(t,Upt(t))}T7.exports=jpt;});var N7=qt((k3t,C7)=>{var S7=sN(),Hpt=dA(),Gpt=CA(),qpt=gA(),zpt=RA(),O7=h0(),A7=Do(),$pt=sw(),Vpt=oy(),Ypt=s0(),Wpt=Mu(),Xpt=_7(),Qpt=d0(),w7=aN(),Jpt=E7();function Zpt(t,e,n,s,i,r,o){var a=w7(t,n),c=w7(e,n),v=o.get(c);if(v){S7(t,n,v);return}var y=r?r(a,c,n+"",t,e,o):void 0,g=y===void 0;if(g){var h=A7(c),u=!h&&Vpt(c),d=!h&&!u&&Qpt(c);y=c,h||u||d?A7(a)?y=a:$pt(a)?y=qpt(a):u?(g=false,y=Hpt(c,true)):d?(g=false,y=Gpt(c,true)):y=[]:Xpt(c)||O7(c)?(y=a,O7(a)?y=Jpt(a):(!Wpt(a)||Ypt(a))&&(y=zpt(c))):g=false;}g&&(o.set(c,y),i(y,c,s,r,o),o.delete(c)),S7(t,n,y);}C7.exports=Zpt;});var I7=qt((M3t,L7)=>{var tdt=$x(),edt=sN(),rdt=uT(),ndt=N7(),idt=Mu(),odt=cd(),sdt=aN();function R7(t,e,n,s,i){t!==e&&rdt(e,function(r,o){if(i||(i=new tdt),idt(r))ndt(t,e,o,n,R7,s,i);else {var a=s?s(sdt(t,o),r,o+"",t,e,i):void 0;a===void 0&&(a=r),edt(t,o,a);}},odt);}L7.exports=R7;});var D7=qt((K3t,P7)=>{var adt=a_(),udt=mb();function ldt(t){return adt(function(e,n){var s=-1,i=n.length,r=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(r=t.length>3&&typeof r=="function"?(i--,r):void 0,o&&udt(n[0],n[1],o)&&(r=i<3?void 0:r,i=1),e=Object(e);++s<i;){var a=n[s];a&&t(e,a,s,r);}return e})}P7.exports=ldt;});var M7=qt((F3t,k7)=>{var cdt=I7(),hdt=D7(),fdt=hdt(function(t,e,n){cdt(t,e,n);});k7.exports=fdt;});var uN=qt((B3t,K7)=>{function pdt(t,e){return t<e}K7.exports=pdt;});var B7=qt((U3t,F7)=>{var ddt=GE(),gdt=uN(),ydt=hd();function mdt(t){return t&&t.length?ddt(t,ydt,gdt):void 0}F7.exports=mdt;});var j7=qt((j3t,U7)=>{var vdt=GE(),xdt=ch(),_dt=uN();function bdt(t,e){return t&&t.length?vdt(t,xdt(e,2),_dt):void 0}U7.exports=bdt;});var G7=qt((H3t,H7)=>{var Tdt=wl(),Edt=function(){return Tdt.Date.now()};H7.exports=Edt;});var $7=qt((G3t,z7)=>{var Sdt=Yx(),Odt=o_(),Adt=Xx(),q7=Mu(),wdt=m0();function Cdt(t,e,n,s){if(!q7(t))return t;e=Odt(e,t);for(var i=-1,r=e.length,o=r-1,a=t;a!=null&&++i<r;){var c=wdt(e[i]),v=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=o){var y=a[c];v=s?s(y,c,a):void 0,v===void 0&&(v=q7(y)?y:Adt(e[i+1])?[]:{});}Sdt(a,c,v),a=a[c];}return t}z7.exports=Cdt;});var Y7=qt((q3t,V7)=>{var Ndt=s_(),Rdt=$7(),Ldt=o_();function Idt(t,e,n){for(var s=-1,i=e.length,r={};++s<i;){var o=e[s],a=Ndt(t,o);n(a,o)&&Rdt(r,Ldt(o,t),a);}return r}V7.exports=Idt;});var X7=qt((z3t,W7)=>{var Pdt=Y7(),Ddt=$A();function kdt(t,e){return Pdt(t,e,function(n,s){return Ddt(t,s)})}W7.exports=kdt;});var J7=qt(($3t,Q7)=>{var Mdt=oN(),Kdt=rw(),Fdt=nw();function Bdt(t){return Fdt(Kdt(t,void 0,Mdt),t+"")}Q7.exports=Bdt;});var tF=qt((V3t,Z7)=>{var Udt=X7(),jdt=J7(),Hdt=jdt(function(t,e){return t==null?{}:Udt(t,e)});Z7.exports=Hdt;});var rF=qt((Y3t,eF)=>{var Gdt=Math.ceil,qdt=Math.max;function zdt(t,e,n,s){for(var i=-1,r=qdt(Gdt((e-t)/(n||1)),0),o=Array(r);r--;)o[s?r:++i]=t,t+=n;return o}eF.exports=zdt;});var iF=qt((W3t,nF)=>{var $dt=rF(),Vdt=mb(),lN=iN();function Ydt(t){return function(e,n,s){return s&&typeof s!="number"&&Vdt(e,n,s)&&(n=s=void 0),e=lN(e),n===void 0?(n=e,e=0):n=lN(n),s=s===void 0?e<n?1:-1:lN(s),$dt(e,n,s,t)}}nF.exports=Ydt;});var sF=qt((X3t,oF)=>{var Wdt=iF(),Xdt=Wdt();oF.exports=Xdt;});var uF=qt((Q3t,aF)=>{function Qdt(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}aF.exports=Qdt;});var hF=qt((J3t,cF)=>{var lF=uy();function Jdt(t,e){if(t!==e){var n=t!==void 0,s=t===null,i=t===t,r=lF(t),o=e!==void 0,a=e===null,c=e===e,v=lF(e);if(!a&&!v&&!r&&t>e||r&&o&&c&&!a&&!v||s&&o&&c||!n&&c||!i)return 1;if(!s&&!r&&!v&&t<e||v&&n&&i&&!s&&!r||a&&n&&i||!o&&i||!c)return -1}return 0}cF.exports=Jdt;});var pF=qt((Z3t,fF)=>{var Zdt=hF();function tgt(t,e,n){for(var s=-1,i=t.criteria,r=e.criteria,o=i.length,a=n.length;++s<o;){var c=Zdt(i[s],r[s]);if(c){if(s>=a)return c;var v=n[s];return c*(v=="desc"?-1:1)}}return t.index-e.index}fF.exports=tgt;});var gF=qt((tMt,dF)=>{var cN=i_(),egt=s_(),rgt=ch(),ngt=QA(),igt=uF(),ogt=Qx(),sgt=pF(),agt=hd(),ugt=Do();function lgt(t,e,n){e.length?e=cN(e,function(r){return ugt(r)?function(o){return egt(o,r.length===1?r[0]:r)}:r}):e=[agt];var s=-1;e=cN(e,ogt(rgt));var i=ngt(t,function(r,o,a){var c=cN(e,function(v){return v(r)});return {criteria:c,index:++s,value:r}});return igt(i,function(r,o){return sgt(r,o,n)})}dF.exports=lgt;});var vF=qt((eMt,mF)=>{var cgt=dT(),hgt=gF(),fgt=a_(),yF=mb(),pgt=fgt(function(t,e){if(t==null)return [];var n=e.length;return n>1&&yF(t,e[0],e[1])?e=[]:n>2&&yF(e[0],e[1],e[2])&&(e=[e[0]]),hgt(t,cgt(e,1),[])});mF.exports=pgt;});var _F=qt((rMt,xF)=>{var dgt=qA(),ggt=0;function ygt(t){var e=++ggt;return dgt(t)+e}xF.exports=ygt;});var TF=qt((nMt,bF)=>{function mgt(t,e,n){for(var s=-1,i=t.length,r=e.length,o={};++s<i;){var a=s<r?e[s]:void 0;n(o,t[s],a);}return o}bF.exports=mgt;});var SF=qt((iMt,EF)=>{var vgt=Yx(),xgt=TF();function _gt(t,e){return xgt(t||[],e||[],vgt)}EF.exports=_gt;});var no=qt((oMt,OF)=>{var qE;if(typeof Ma=="function")try{qE={cloneDeep:MK(),constant:aT(),defaults:UK(),each:DA(),filter:YA(),find:i7(),flatten:oN(),forEach:PA(),forIn:a7(),has:WA(),isUndefined:XA(),last:l7(),map:JA(),mapValues:h7(),max:y7(),merge:M7(),min:B7(),minBy:j7(),now:G7(),pick:tF(),range:sF(),reduce:ZA(),sortBy:vF(),uniqueId:_F(),values:aw(),zipObject:SF()};}catch{}qE||(qE=window._);OF.exports=qE;});var CF=qt((aMt,wF)=>{wF.exports=zE;function zE(){var t={};t._next=t._prev=t,this._sentinel=t;}zE.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return AF(e),e};zE.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&AF(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e;};zE.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,bgt)),n=n._prev;return "["+t.join(", ")+"]"};function AF(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev;}function bgt(t,e){if(t!=="_next"&&t!=="_prev")return e}});var RF=qt((uMt,NF)=>{var qf=no(),Tgt=Fl().Graph,Egt=CF();NF.exports=Ogt;var Sgt=qf.constant(1);function Ogt(t,e){if(t.nodeCount()<=1)return [];var n=wgt(t,e||Sgt),s=Agt(n.graph,n.buckets,n.zeroIdx);return qf.flatten(qf.map(s,function(i){return t.outEdges(i.v,i.w)}),true)}function Agt(t,e,n){for(var s=[],i=e[e.length-1],r=e[0],o;t.nodeCount();){for(;o=r.dequeue();)hN(t,e,n,o);for(;o=i.dequeue();)hN(t,e,n,o);if(t.nodeCount()){for(var a=e.length-2;a>0;--a)if(o=e[a].dequeue(),o){s=s.concat(hN(t,e,n,o,true));break}}}return s}function hN(t,e,n,s,i){var r=i?[]:void 0;return qf.forEach(t.inEdges(s.v),function(o){var a=t.edge(o),c=t.node(o.v);i&&r.push({v:o.v,w:o.w}),c.out-=a,fN(e,n,c);}),qf.forEach(t.outEdges(s.v),function(o){var a=t.edge(o),c=o.w,v=t.node(c);v.in-=a,fN(e,n,v);}),t.removeNode(s.v),r}function wgt(t,e){var n=new Tgt,s=0,i=0;qf.forEach(t.nodes(),function(a){n.setNode(a,{v:a,in:0,out:0});}),qf.forEach(t.edges(),function(a){var c=n.edge(a.v,a.w)||0,v=e(a),y=c+v;n.setEdge(a.v,a.w,y),i=Math.max(i,n.node(a.v).out+=v),s=Math.max(s,n.node(a.w).in+=v);});var r=qf.range(i+s+3).map(function(){return new Egt}),o=s+1;return qf.forEach(n.nodes(),function(a){fN(r,o,n.node(a));}),{graph:n,buckets:r,zeroIdx:o}}function fN(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n);}});var IF=qt((lMt,LF)=>{var Ny=no(),Cgt=RF();LF.exports={run:Ngt,undo:Lgt};function Ngt(t){var e=t.graph().acyclicer==="greedy"?Cgt(t,n(t)):Rgt(t);Ny.forEach(e,function(s){var i=t.edge(s);t.removeEdge(s),i.forwardName=s.name,i.reversed=true,t.setEdge(s.w,s.v,i,Ny.uniqueId("rev"));});function n(s){return function(i){return s.edge(i).weight}}}function Rgt(t){var e=[],n={},s={};function i(r){Ny.has(s,r)||(s[r]=true,n[r]=true,Ny.forEach(t.outEdges(r),function(o){Ny.has(n,o.w)?e.push(o):i(o.w);}),delete n[r]);}return Ny.forEach(t.nodes(),i),e}function Lgt(t){Ny.forEach(t.edges(),function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var s=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,s);}});}});var Ua=qt((cMt,MF)=>{var bi=no(),PF=Fl().Graph;MF.exports={addDummyNode:DF,simplify:Igt,asNonCompoundGraph:Pgt,successorWeights:Dgt,predecessorWeights:kgt,intersectRect:Mgt,buildLayerMatrix:Kgt,normalizeRanks:Fgt,removeEmptyRanks:Bgt,addBorderNode:Ugt,maxRank:kF,partition:jgt,time:Hgt,notime:Ggt};function DF(t,e,n,s){var i;do i=bi.uniqueId(s);while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function Igt(t){var e=new PF().setGraph(t.graph());return bi.forEach(t.nodes(),function(n){e.setNode(n,t.node(n));}),bi.forEach(t.edges(),function(n){var s=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:s.weight+i.weight,minlen:Math.max(s.minlen,i.minlen)});}),e}function Pgt(t){var e=new PF({multigraph:t.isMultigraph()}).setGraph(t.graph());return bi.forEach(t.nodes(),function(n){t.children(n).length||e.setNode(n,t.node(n));}),bi.forEach(t.edges(),function(n){e.setEdge(n,t.edge(n));}),e}function Dgt(t){var e=bi.map(t.nodes(),function(n){var s={};return bi.forEach(t.outEdges(n),function(i){s[i.w]=(s[i.w]||0)+t.edge(i).weight;}),s});return bi.zipObject(t.nodes(),e)}function kgt(t){var e=bi.map(t.nodes(),function(n){var s={};return bi.forEach(t.inEdges(n),function(i){s[i.v]=(s[i.v]||0)+t.edge(i).weight;}),s});return bi.zipObject(t.nodes(),e)}function Mgt(t,e){var n=t.x,s=t.y,i=e.x-n,r=e.y-s,o=t.width/2,a=t.height/2;if(!i&&!r)throw new Error("Not possible to find intersection inside of the rectangle");var c,v;return Math.abs(r)*o>Math.abs(i)*a?(r<0&&(a=-a),c=a*i/r,v=a):(i<0&&(o=-o),c=o,v=o*r/i),{x:n+c,y:s+v}}function Kgt(t){var e=bi.map(bi.range(kF(t)+1),function(){return []});return bi.forEach(t.nodes(),function(n){var s=t.node(n),i=s.rank;bi.isUndefined(i)||(e[i][s.order]=n);}),e}function Fgt(t){var e=bi.min(bi.map(t.nodes(),function(n){return t.node(n).rank}));bi.forEach(t.nodes(),function(n){var s=t.node(n);bi.has(s,"rank")&&(s.rank-=e);});}function Bgt(t){var e=bi.min(bi.map(t.nodes(),function(r){return t.node(r).rank})),n=[];bi.forEach(t.nodes(),function(r){var o=t.node(r).rank-e;n[o]||(n[o]=[]),n[o].push(r);});var s=0,i=t.graph().nodeRankFactor;bi.forEach(n,function(r,o){bi.isUndefined(r)&&o%i!==0?--s:s&&bi.forEach(r,function(a){t.node(a).rank+=s;});});}function Ugt(t,e,n,s){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=s),DF(t,"border",i,e)}function kF(t){return bi.max(bi.map(t.nodes(),function(e){var n=t.node(e).rank;if(!bi.isUndefined(n))return n}))}function jgt(t,e){var n={lhs:[],rhs:[]};return bi.forEach(t,function(s){e(s)?n.lhs.push(s):n.rhs.push(s);}),n}function Hgt(t,e){var n=bi.now();try{return e()}finally{console.log(t+" time: "+(bi.now()-n)+"ms");}}function Ggt(t,e){return e()}});var BF=qt((hMt,FF)=>{var KF=no(),qgt=Ua();FF.exports={run:zgt,undo:Vgt};function zgt(t){t.graph().dummyChains=[],KF.forEach(t.edges(),function(e){$gt(t,e);});}function $gt(t,e){var n=e.v,s=t.node(n).rank,i=e.w,r=t.node(i).rank,o=e.name,a=t.edge(e),c=a.labelRank;if(r!==s+1){t.removeEdge(e);var v,y,g;for(g=0,++s;s<r;++g,++s)a.points=[],y={width:0,height:0,edgeLabel:a,edgeObj:e,rank:s},v=qgt.addDummyNode(t,"edge",y,"_d"),s===c&&(y.width=a.width,y.height=a.height,y.dummy="edge-label",y.labelpos=a.labelpos),t.setEdge(n,v,{weight:a.weight},o),g===0&&t.graph().dummyChains.push(v),n=v;t.setEdge(n,i,{weight:a.weight},o);}}function Vgt(t){KF.forEach(t.graph().dummyChains,function(e){var n=t.node(e),s=n.edgeLabel,i;for(t.setEdge(n.edgeObj,s);n.dummy;)i=t.successors(e)[0],t.removeNode(e),s.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(s.x=n.x,s.y=n.y,s.width=n.width,s.height=n.height),e=i,n=t.node(e);});}});var vb=qt((fMt,UF)=>{var $E=no();UF.exports={longestPath:Ygt,slack:Wgt};function Ygt(t){var e={};function n(s){var i=t.node(s);if($E.has(e,s))return i.rank;e[s]=true;var r=$E.min($E.map(t.outEdges(s),function(o){return n(o.w)-t.edge(o).minlen}));return (r===Number.POSITIVE_INFINITY||r===void 0||r===null)&&(r=0),i.rank=r}$E.forEach(t.sources(),n);}function Wgt(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}});var pN=qt((pMt,jF)=>{var VE=no(),Xgt=Fl().Graph,YE=vb().slack;jF.exports=Qgt;function Qgt(t){var e=new Xgt({directed:false}),n=t.nodes()[0],s=t.nodeCount();e.setNode(n,{});for(var i,r;Jgt(e,t)<s;)i=Zgt(e,t),r=e.hasNode(i.v)?YE(t,i):-YE(t,i),tyt(e,t,r);return e}function Jgt(t,e){function n(s){VE.forEach(e.nodeEdges(s),function(i){var r=i.v,o=s===r?i.w:r;!t.hasNode(o)&&!YE(e,i)&&(t.setNode(o,{}),t.setEdge(s,o,{}),n(o));});}return VE.forEach(t.nodes(),n),t.nodeCount()}function Zgt(t,e){return VE.minBy(e.edges(),function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return YE(e,n)})}function tyt(t,e,n){VE.forEach(t.nodes(),function(s){e.node(s).rank+=n;});}});var WF=qt((dMt,YF)=>{var zf=no(),eyt=pN(),ryt=vb().slack,nyt=vb().longestPath,iyt=Fl().alg.preorder,oyt=Fl().alg.postorder,syt=Ua().simplify;YF.exports=Ry;Ry.initLowLimValues=gN;Ry.initCutValues=dN;Ry.calcCutValue=GF;Ry.leaveEdge=zF;Ry.enterEdge=$F;Ry.exchangeEdges=VF;function Ry(t){t=syt(t),nyt(t);var e=eyt(t);gN(e),dN(e,t);for(var n,s;n=zF(e);)s=$F(e,t,n),VF(e,t,n,s);}function dN(t,e){var n=oyt(t,t.nodes());n=n.slice(0,n.length-1),zf.forEach(n,function(s){ayt(t,e,s);});}function ayt(t,e,n){var s=t.node(n),i=s.parent;t.edge(n,i).cutvalue=GF(t,e,n);}function GF(t,e,n){var s=t.node(n),i=s.parent,r=true,o=e.edge(n,i),a=0;return o||(r=false,o=e.edge(i,n)),a=o.weight,zf.forEach(e.nodeEdges(n),function(c){var v=c.v===n,y=v?c.w:c.v;if(y!==i){var g=v===r,h=e.edge(c).weight;if(a+=g?h:-h,lyt(t,n,y)){var u=t.edge(n,y).cutvalue;a+=g?-u:u;}}}),a}function gN(t,e){arguments.length<2&&(e=t.nodes()[0]),qF(t,{},1,e);}function qF(t,e,n,s,i){var r=n,o=t.node(s);return e[s]=true,zf.forEach(t.neighbors(s),function(a){zf.has(e,a)||(n=qF(t,e,n,a,s));}),o.low=r,o.lim=n++,i?o.parent=i:delete o.parent,n}function zF(t){return zf.find(t.edges(),function(e){return t.edge(e).cutvalue<0})}function $F(t,e,n){var s=n.v,i=n.w;e.hasEdge(s,i)||(s=n.w,i=n.v);var r=t.node(s),o=t.node(i),a=r,c=false;r.lim>o.lim&&(a=o,c=true);var v=zf.filter(e.edges(),function(y){return c===HF(t,t.node(y.v),a)&&c!==HF(t,t.node(y.w),a)});return zf.minBy(v,function(y){return ryt(e,y)})}function VF(t,e,n,s){var i=n.v,r=n.w;t.removeEdge(i,r),t.setEdge(s.v,s.w,{}),gN(t),dN(t,e),uyt(t,e);}function uyt(t,e){var n=zf.find(t.nodes(),function(i){return !e.node(i).parent}),s=iyt(t,n);s=s.slice(1),zf.forEach(s,function(i){var r=t.node(i).parent,o=e.edge(i,r),a=false;o||(o=e.edge(r,i),a=true),e.node(i).rank=e.node(r).rank+(a?o.minlen:-o.minlen);});}function lyt(t,e,n){return t.hasEdge(e,n)}function HF(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}});var ZF=qt((gMt,JF)=>{var cyt=vb(),QF=cyt.longestPath,hyt=pN(),fyt=WF();JF.exports=pyt;function pyt(t){switch(t.graph().ranker){case "network-simplex":XF(t);break;case "tight-tree":gyt(t);break;case "longest-path":dyt(t);break;default:XF(t);}}var dyt=QF;function gyt(t){QF(t),hyt(t);}function XF(t){fyt(t);}});var eB=qt((yMt,tB)=>{var yN=no();tB.exports=yyt;function yyt(t){var e=vyt(t);yN.forEach(t.graph().dummyChains,function(n){for(var s=t.node(n),i=s.edgeObj,r=myt(t,e,i.v,i.w),o=r.path,a=r.lca,c=0,v=o[c],y=true;n!==i.w;){if(s=t.node(n),y){for(;(v=o[c])!==a&&t.node(v).maxRank<s.rank;)c++;v===a&&(y=false);}if(!y){for(;c<o.length-1&&t.node(v=o[c+1]).minRank<=s.rank;)c++;v=o[c];}t.setParent(n,v),n=t.successors(n)[0];}});}function myt(t,e,n,s){var i=[],r=[],o=Math.min(e[n].low,e[s].low),a=Math.max(e[n].lim,e[s].lim),c,v;c=n;do c=t.parent(c),i.push(c);while(c&&(e[c].low>o||a>e[c].lim));for(v=c,c=s;(c=t.parent(c))!==v;)r.push(c);return {path:i.concat(r.reverse()),lca:v}}function vyt(t){var e={},n=0;function s(i){var r=n;yN.forEach(t.children(i),s),e[i]={low:r,lim:n++};}return yN.forEach(t.children(),s),e}});var iB=qt((mMt,nB)=>{var $f=no(),mN=Ua();nB.exports={run:xyt,cleanup:Tyt};function xyt(t){var e=mN.addDummyNode(t,"root",{},"_root"),n=_yt(t),s=$f.max($f.values(n))-1,i=2*s+1;t.graph().nestingRoot=e,$f.forEach(t.edges(),function(o){t.edge(o).minlen*=i;});var r=byt(t)+1;$f.forEach(t.children(),function(o){rB(t,e,i,r,s,n,o);}),t.graph().nodeRankFactor=i;}function rB(t,e,n,s,i,r,o){var a=t.children(o);if(!a.length){o!==e&&t.setEdge(e,o,{weight:0,minlen:n});return}var c=mN.addBorderNode(t,"_bt"),v=mN.addBorderNode(t,"_bb"),y=t.node(o);t.setParent(c,o),y.borderTop=c,t.setParent(v,o),y.borderBottom=v,$f.forEach(a,function(g){rB(t,e,n,s,i,r,g);var h=t.node(g),u=h.borderTop?h.borderTop:g,d=h.borderBottom?h.borderBottom:g,f=h.borderTop?s:2*s,l=u!==d?1:i-r[o]+1;t.setEdge(c,u,{weight:f,minlen:l,nestingEdge:true}),t.setEdge(d,v,{weight:f,minlen:l,nestingEdge:true});}),t.parent(o)||t.setEdge(e,c,{weight:0,minlen:i+r[o]});}function _yt(t){var e={};function n(s,i){var r=t.children(s);r&&r.length&&$f.forEach(r,function(o){n(o,i+1);}),e[s]=i;}return $f.forEach(t.children(),function(s){n(s,1);}),e}function byt(t){return $f.reduce(t.edges(),function(e,n){return e+t.edge(n).weight},0)}function Tyt(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,$f.forEach(t.edges(),function(n){var s=t.edge(n);s.nestingEdge&&t.removeEdge(n);});}});var aB=qt((vMt,sB)=>{var vN=no(),Eyt=Ua();sB.exports=Syt;function Syt(t){function e(n){var s=t.children(n),i=t.node(n);if(s.length&&vN.forEach(s,e),vN.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var r=i.minRank,o=i.maxRank+1;r<o;++r)oB(t,"borderLeft","_bl",n,i,r),oB(t,"borderRight","_br",n,i,r);}}vN.forEach(t.children(),e);}function oB(t,e,n,s,i,r){var o={width:0,height:0,rank:r,borderType:e},a=i[e][r-1],c=Eyt.addDummyNode(t,"border",o,n);i[e][r]=c,t.setParent(c,s),a&&t.setEdge(a,c,{weight:1});}});var hB=qt((xMt,cB)=>{var Eh=no();cB.exports={adjust:Oyt,undo:Ayt};function Oyt(t){var e=t.graph().rankdir.toLowerCase();(e==="lr"||e==="rl")&&lB(t);}function Ayt(t){var e=t.graph().rankdir.toLowerCase();(e==="bt"||e==="rl")&&wyt(t),(e==="lr"||e==="rl")&&(Cyt(t),lB(t));}function lB(t){Eh.forEach(t.nodes(),function(e){uB(t.node(e));}),Eh.forEach(t.edges(),function(e){uB(t.edge(e));});}function uB(t){var e=t.width;t.width=t.height,t.height=e;}function wyt(t){Eh.forEach(t.nodes(),function(e){xN(t.node(e));}),Eh.forEach(t.edges(),function(e){var n=t.edge(e);Eh.forEach(n.points,xN),Eh.has(n,"y")&&xN(n);});}function xN(t){t.y=-t.y;}function Cyt(t){Eh.forEach(t.nodes(),function(e){_N(t.node(e));}),Eh.forEach(t.edges(),function(e){var n=t.edge(e);Eh.forEach(n.points,_N),Eh.has(n,"x")&&_N(n);});}function _N(t){var e=t.x;t.x=t.y,t.y=e;}});var pB=qt((_Mt,fB)=>{var Vf=no();fB.exports=Nyt;function Nyt(t){var e={},n=Vf.filter(t.nodes(),function(a){return !t.children(a).length}),s=Vf.max(Vf.map(n,function(a){return t.node(a).rank})),i=Vf.map(Vf.range(s+1),function(){return []});function r(a){if(!Vf.has(e,a)){e[a]=true;var c=t.node(a);i[c.rank].push(a),Vf.forEach(t.successors(a),r);}}var o=Vf.sortBy(n,function(a){return t.node(a).rank});return Vf.forEach(o,r),i}});var gB=qt((bMt,dB)=>{var kd=no();dB.exports=Ryt;function Ryt(t,e){for(var n=0,s=1;s<e.length;++s)n+=Lyt(t,e[s-1],e[s]);return n}function Lyt(t,e,n){for(var s=kd.zipObject(n,kd.map(n,function(v,y){return y})),i=kd.flatten(kd.map(e,function(v){return kd.sortBy(kd.map(t.outEdges(v),function(y){return {pos:s[y.w],weight:t.edge(y).weight}}),"pos")}),true),r=1;r<n.length;)r<<=1;var o=2*r-1;r-=1;var a=kd.map(new Array(o),function(){return 0}),c=0;return kd.forEach(i.forEach(function(v){var y=v.pos+r;a[y]+=v.weight;for(var g=0;y>0;)y%2&&(g+=a[y+1]),y=y-1>>1,a[y]+=v.weight;c+=v.weight*g;})),c}});var vB=qt((TMt,mB)=>{var yB=no();mB.exports=Iyt;function Iyt(t,e){return yB.map(e,function(n){var s=t.inEdges(n);if(s.length){var i=yB.reduce(s,function(r,o){var a=t.edge(o),c=t.node(o.v);return {sum:r.sum+a.weight*c.order,weight:r.weight+a.weight}},{sum:0,weight:0});return {v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return {v:n}})}});var _B=qt((EMt,xB)=>{var Gu=no();xB.exports=Pyt;function Pyt(t,e){var n={};Gu.forEach(t,function(i,r){var o=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:r};Gu.isUndefined(i.barycenter)||(o.barycenter=i.barycenter,o.weight=i.weight);}),Gu.forEach(e.edges(),function(i){var r=n[i.v],o=n[i.w];!Gu.isUndefined(r)&&!Gu.isUndefined(o)&&(o.indegree++,r.out.push(n[i.w]));});var s=Gu.filter(n,function(i){return !i.indegree});return Dyt(s)}function Dyt(t){var e=[];function n(r){return function(o){o.merged||(Gu.isUndefined(o.barycenter)||Gu.isUndefined(r.barycenter)||o.barycenter>=r.barycenter)&&kyt(r,o);}}function s(r){return function(o){o.in.push(r),--o.indegree===0&&t.push(o);}}for(;t.length;){var i=t.pop();e.push(i),Gu.forEach(i.in.reverse(),n(i)),Gu.forEach(i.out,s(i));}return Gu.map(Gu.filter(e,function(r){return !r.merged}),function(r){return Gu.pick(r,["vs","i","barycenter","weight"])})}function kyt(t,e){var n=0,s=0;t.weight&&(n+=t.barycenter*t.weight,s+=t.weight),e.weight&&(n+=e.barycenter*e.weight,s+=e.weight),t.vs=e.vs.concat(t.vs),t.barycenter=n/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=true;}});var EB=qt((SMt,TB)=>{var xb=no(),Myt=Ua();TB.exports=Kyt;function Kyt(t,e){var n=Myt.partition(t,function(y){return xb.has(y,"barycenter")}),s=n.lhs,i=xb.sortBy(n.rhs,function(y){return -y.i}),r=[],o=0,a=0,c=0;s.sort(Fyt(!!e)),c=bB(r,i,c),xb.forEach(s,function(y){c+=y.vs.length,r.push(y.vs),o+=y.barycenter*y.weight,a+=y.weight,c=bB(r,i,c);});var v={vs:xb.flatten(r,true)};return a&&(v.barycenter=o/a,v.weight=a),v}function bB(t,e,n){for(var s;e.length&&(s=xb.last(e)).i<=n;)e.pop(),t.push(s.vs),n++;return n}function Fyt(t){return function(e,n){return e.barycenter<n.barycenter?-1:e.barycenter>n.barycenter?1:t?n.i-e.i:e.i-n.i}}});var AB=qt((OMt,OB)=>{var Md=no(),Byt=vB(),Uyt=_B(),jyt=EB();OB.exports=SB;function SB(t,e,n,s){var i=t.children(e),r=t.node(e),o=r?r.borderLeft:void 0,a=r?r.borderRight:void 0,c={};o&&(i=Md.filter(i,function(d){return d!==o&&d!==a}));var v=Byt(t,i);Md.forEach(v,function(d){if(t.children(d.v).length){var f=SB(t,d.v,n,s);c[d.v]=f,Md.has(f,"barycenter")&&Gyt(d,f);}});var y=Uyt(v,n);Hyt(y,c);var g=jyt(y,s);if(o&&(g.vs=Md.flatten([o,g.vs,a],true),t.predecessors(o).length)){var h=t.node(t.predecessors(o)[0]),u=t.node(t.predecessors(a)[0]);Md.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+h.order+u.order)/(g.weight+2),g.weight+=2;}return g}function Hyt(t,e){Md.forEach(t,function(n){n.vs=Md.flatten(n.vs.map(function(s){return e[s]?e[s].vs:s}),true);});}function Gyt(t,e){Md.isUndefined(t.barycenter)?(t.barycenter=e.barycenter,t.weight=e.weight):(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight);}});var CB=qt((AMt,wB)=>{var _b=no(),qyt=Fl().Graph;wB.exports=zyt;function zyt(t,e,n){var s=$yt(t),i=new qyt({compound:true}).setGraph({root:s}).setDefaultNodeLabel(function(r){return t.node(r)});return _b.forEach(t.nodes(),function(r){var o=t.node(r),a=t.parent(r);(o.rank===e||o.minRank<=e&&e<=o.maxRank)&&(i.setNode(r),i.setParent(r,a||s),_b.forEach(t[n](r),function(c){var v=c.v===r?c.w:c.v,y=i.edge(v,r),g=_b.isUndefined(y)?0:y.weight;i.setEdge(v,r,{weight:t.edge(c).weight+g});}),_b.has(o,"minRank")&&i.setNode(r,{borderLeft:o.borderLeft[e],borderRight:o.borderRight[e]}));}),i}function $yt(t){for(var e;t.hasNode(e=_b.uniqueId("_root")););return e}});var RB=qt((wMt,NB)=>{var Vyt=no();NB.exports=Yyt;function Yyt(t,e,n){var s={},i;Vyt.forEach(n,function(r){for(var o=t.parent(r),a,c;o;){if(a=t.parent(o),a?(c=s[a],s[a]=o):(c=i,i=o),c&&c!==o){e.setEdge(c,o);return}o=a;}});}});var kB=qt((CMt,DB)=>{var Kd=no(),Wyt=pB(),Xyt=gB(),Qyt=AB(),Jyt=CB(),Zyt=RB(),tmt=Fl().Graph,LB=Ua();DB.exports=emt;function emt(t){var e=LB.maxRank(t),n=IB(t,Kd.range(1,e+1),"inEdges"),s=IB(t,Kd.range(e-1,-1,-1),"outEdges"),i=Wyt(t);PB(t,i);for(var r=Number.POSITIVE_INFINITY,o,a=0,c=0;c<4;++a,++c){rmt(a%2?n:s,a%4>=2),i=LB.buildLayerMatrix(t);var v=Xyt(t,i);v<r&&(c=0,o=Kd.cloneDeep(i),r=v);}PB(t,o);}function IB(t,e,n){return Kd.map(e,function(s){return Jyt(t,s,n)})}function rmt(t,e){var n=new tmt;Kd.forEach(t,function(s){var i=s.graph().root,r=Qyt(s,i,n,e);Kd.forEach(r.vs,function(o,a){s.node(o).order=a;}),Zyt(s,n,r.vs);});}function PB(t,e){Kd.forEach(e,function(n){Kd.forEach(n,function(s,i){t.node(s).order=i;});});}});var zB=qt((NMt,qB)=>{var wn=no(),nmt=Fl().Graph,imt=Ua();qB.exports={positionX:amt,findType1Conflicts:MB,findType2Conflicts:KB,addConflict:bN,hasConflict:FB,verticalAlignment:BB,horizontalCompaction:UB,alignCoordinates:HB,findSmallestWidthAlignment:jB,balance:GB};function MB(t,e){var n={};function s(i,r){var o=0,a=0,c=i.length,v=wn.last(r);return wn.forEach(r,function(y,g){var h=omt(t,y),u=h?t.node(h).order:c;(h||y===v)&&(wn.forEach(r.slice(a,g+1),function(d){wn.forEach(t.predecessors(d),function(f){var l=t.node(f),p=l.order;(p<o||u<p)&&!(l.dummy&&t.node(d).dummy)&&bN(n,f,d);});}),a=g+1,o=u);}),r}return wn.reduce(e,s),n}function KB(t,e){var n={};function s(r,o,a,c,v){var y;wn.forEach(wn.range(o,a),function(g){y=r[g],t.node(y).dummy&&wn.forEach(t.predecessors(y),function(h){var u=t.node(h);u.dummy&&(u.order<c||u.order>v)&&bN(n,h,y);});});}function i(r,o){var a=-1,c,v=0;return wn.forEach(o,function(y,g){if(t.node(y).dummy==="border"){var h=t.predecessors(y);h.length&&(c=t.node(h[0]).order,s(o,v,g,a,c),v=g,a=c);}s(o,v,o.length,c,r.length);}),o}return wn.reduce(e,i),n}function omt(t,e){if(t.node(e).dummy)return wn.find(t.predecessors(e),function(n){return t.node(n).dummy})}function bN(t,e,n){if(e>n){var s=e;e=n,n=s;}var i=t[e];i||(t[e]=i={}),i[n]=true;}function FB(t,e,n){if(e>n){var s=e;e=n,n=s;}return wn.has(t[e],n)}function BB(t,e,n,s){var i={},r={},o={};return wn.forEach(e,function(a){wn.forEach(a,function(c,v){i[c]=c,r[c]=c,o[c]=v;});}),wn.forEach(e,function(a){var c=-1;wn.forEach(a,function(v){var y=s(v);if(y.length){y=wn.sortBy(y,function(f){return o[f]});for(var g=(y.length-1)/2,h=Math.floor(g),u=Math.ceil(g);h<=u;++h){var d=y[h];r[v]===v&&c<o[d]&&!FB(n,v,d)&&(r[d]=v,r[v]=i[v]=i[d],c=o[d]);}}});}),{root:i,align:r}}function UB(t,e,n,s,i){var r={},o=smt(t,e,n,i),a=i?"borderLeft":"borderRight";function c(g,h){for(var u=o.nodes(),d=u.pop(),f={};d;)f[d]?g(d):(f[d]=true,u.push(d),u=u.concat(h(d))),d=u.pop();}function v(g){r[g]=o.inEdges(g).reduce(function(h,u){return Math.max(h,r[u.v]+o.edge(u))},0);}function y(g){var h=o.outEdges(g).reduce(function(d,f){return Math.min(d,r[f.w]-o.edge(f))},Number.POSITIVE_INFINITY),u=t.node(g);h!==Number.POSITIVE_INFINITY&&u.borderType!==a&&(r[g]=Math.max(r[g],h));}return c(v,o.predecessors.bind(o)),c(y,o.successors.bind(o)),wn.forEach(s,function(g){r[g]=r[n[g]];}),r}function smt(t,e,n,s){var i=new nmt,r=t.graph(),o=umt(r.nodesep,r.edgesep,s);return wn.forEach(e,function(a){var c;wn.forEach(a,function(v){var y=n[v];if(i.setNode(y),c){var g=n[c],h=i.edge(g,y);i.setEdge(g,y,Math.max(o(t,v,c),h||0));}c=v;});}),i}function jB(t,e){return wn.minBy(wn.values(e),function(n){var s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return wn.forIn(n,function(r,o){var a=lmt(t,o)/2;s=Math.max(r+a,s),i=Math.min(r-a,i);}),s-i})}function HB(t,e){var n=wn.values(e),s=wn.min(n),i=wn.max(n);wn.forEach(["u","d"],function(r){wn.forEach(["l","r"],function(o){var a=r+o,c=t[a],v;if(c!==e){var y=wn.values(c);v=o==="l"?s-wn.min(y):i-wn.max(y),v&&(t[a]=wn.mapValues(c,function(g){return g+v}));}});});}function GB(t,e){return wn.mapValues(t.ul,function(n,s){if(e)return t[e.toLowerCase()][s];var i=wn.sortBy(wn.map(t,s));return (i[1]+i[2])/2})}function amt(t){var e=imt.buildLayerMatrix(t),n=wn.merge(MB(t,e),KB(t,e)),s={},i;wn.forEach(["u","d"],function(o){i=o==="u"?e:wn.values(e).reverse(),wn.forEach(["l","r"],function(a){a==="r"&&(i=wn.map(i,function(g){return wn.values(g).reverse()}));var c=(o==="u"?t.predecessors:t.successors).bind(t),v=BB(t,i,n,c),y=UB(t,i,v.root,v.align,a==="r");a==="r"&&(y=wn.mapValues(y,function(g){return -g})),s[o+a]=y;});});var r=jB(t,s);return HB(s,r),GB(s,t.graph().align)}function umt(t,e,n){return function(s,i,r){var o=s.node(i),a=s.node(r),c=0,v;if(c+=o.width/2,wn.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case "l":v=-o.width/2;break;case "r":v=o.width/2;break}if(v&&(c+=n?v:-v),v=0,c+=(o.dummy?e:t)/2,c+=(a.dummy?e:t)/2,c+=a.width/2,wn.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case "l":v=a.width/2;break;case "r":v=-a.width/2;break}return v&&(c+=n?v:-v),v=0,c}}function lmt(t,e){return t.node(e).width}});var YB=qt((RMt,VB)=>{var bb=no(),$B=Ua(),cmt=zB().positionX;VB.exports=hmt;function hmt(t){t=$B.asNonCompoundGraph(t),fmt(t),bb.forEach(cmt(t),function(e,n){t.node(n).x=e;});}function fmt(t){var e=$B.buildLayerMatrix(t),n=t.graph().ranksep,s=0;bb.forEach(e,function(i){var r=bb.max(bb.map(i,function(o){return t.node(o).height}));bb.forEach(i,function(o){t.node(o).y=s+r/2;}),s+=r+n;});}});var tU=qt((LMt,ZB)=>{var Gn=no(),WB=IF(),XB=BF(),pmt=ZF(),dmt=Ua().normalizeRanks,gmt=eB(),ymt=Ua().removeEmptyRanks,QB=iB(),mmt=aB(),JB=hB(),vmt=kB(),xmt=YB(),Fd=Ua(),_mt=Fl().Graph;ZB.exports=bmt;function bmt(t,e){var n=e&&e.debugTiming?Fd.time:Fd.notime;n("layout",function(){var s=n(" buildLayoutGraph",function(){return Imt(t)});n(" runLayout",function(){Tmt(s,n);}),n(" updateInputGraph",function(){Emt(t,s);});});}function Tmt(t,e){e(" makeSpaceForEdgeLabels",function(){Pmt(t);}),e(" removeSelfEdges",function(){Hmt(t);}),e(" acyclic",function(){WB.run(t);}),e(" nestingGraph.run",function(){QB.run(t);}),e(" rank",function(){pmt(Fd.asNonCompoundGraph(t));}),e(" injectEdgeLabelProxies",function(){Dmt(t);}),e(" removeEmptyRanks",function(){ymt(t);}),e(" nestingGraph.cleanup",function(){QB.cleanup(t);}),e(" normalizeRanks",function(){dmt(t);}),e(" assignRankMinMax",function(){kmt(t);}),e(" removeEdgeLabelProxies",function(){Mmt(t);}),e(" normalize.run",function(){XB.run(t);}),e(" parentDummyChains",function(){gmt(t);}),e(" addBorderSegments",function(){mmt(t);}),e(" order",function(){vmt(t);}),e(" insertSelfEdges",function(){Gmt(t);}),e(" adjustCoordinateSystem",function(){JB.adjust(t);}),e(" position",function(){xmt(t);}),e(" positionSelfEdges",function(){qmt(t);}),e(" removeBorderNodes",function(){jmt(t);}),e(" normalize.undo",function(){XB.undo(t);}),e(" fixupEdgeLabelCoords",function(){Bmt(t);}),e(" undoCoordinateSystem",function(){JB.undo(t);}),e(" translateGraph",function(){Kmt(t);}),e(" assignNodeIntersects",function(){Fmt(t);}),e(" reversePoints",function(){Umt(t);}),e(" acyclic.undo",function(){WB.undo(t);});}function Emt(t,e){Gn.forEach(t.nodes(),function(n){var s=t.node(n),i=e.node(n);s&&(s.x=i.x,s.y=i.y,e.children(n).length&&(s.width=i.width,s.height=i.height));}),Gn.forEach(t.edges(),function(n){var s=t.edge(n),i=e.edge(n);s.points=i.points,Gn.has(i,"x")&&(s.x=i.x,s.y=i.y);}),t.graph().width=e.graph().width,t.graph().height=e.graph().height;}var Smt=["nodesep","edgesep","ranksep","marginx","marginy"],Omt={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Amt=["acyclicer","ranker","rankdir","align"],wmt=["width","height"],Cmt={width:0,height:0},Nmt=["minlen","weight","width","height","labeloffset"],Rmt={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Lmt=["labelpos"];function Imt(t){var e=new _mt({multigraph:true,compound:true}),n=EN(t.graph());return e.setGraph(Gn.merge({},Omt,TN(n,Smt),Gn.pick(n,Amt))),Gn.forEach(t.nodes(),function(s){var i=EN(t.node(s));e.setNode(s,Gn.defaults(TN(i,wmt),Cmt)),e.setParent(s,t.parent(s));}),Gn.forEach(t.edges(),function(s){var i=EN(t.edge(s));e.setEdge(s,Gn.merge({},Rmt,TN(i,Nmt),Gn.pick(i,Lmt)));}),e}function Pmt(t){var e=t.graph();e.ranksep/=2,Gn.forEach(t.edges(),function(n){var s=t.edge(n);s.minlen*=2,s.labelpos.toLowerCase()!=="c"&&(e.rankdir==="TB"||e.rankdir==="BT"?s.width+=s.labeloffset:s.height+=s.labeloffset);});}function Dmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);if(n.width&&n.height){var s=t.node(e.v),i=t.node(e.w),r={rank:(i.rank-s.rank)/2+s.rank,e};Fd.addDummyNode(t,"edge-proxy",r,"_ep");}});}function kmt(t){var e=0;Gn.forEach(t.nodes(),function(n){var s=t.node(n);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=Gn.max(e,s.maxRank));}),t.graph().maxRank=e;}function Mmt(t){Gn.forEach(t.nodes(),function(e){var n=t.node(e);n.dummy==="edge-proxy"&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e));});}function Kmt(t){var e=Number.POSITIVE_INFINITY,n=0,s=Number.POSITIVE_INFINITY,i=0,r=t.graph(),o=r.marginx||0,a=r.marginy||0;function c(v){var y=v.x,g=v.y,h=v.width,u=v.height;e=Math.min(e,y-h/2),n=Math.max(n,y+h/2),s=Math.min(s,g-u/2),i=Math.max(i,g+u/2);}Gn.forEach(t.nodes(),function(v){c(t.node(v));}),Gn.forEach(t.edges(),function(v){var y=t.edge(v);Gn.has(y,"x")&&c(y);}),e-=o,s-=a,Gn.forEach(t.nodes(),function(v){var y=t.node(v);y.x-=e,y.y-=s;}),Gn.forEach(t.edges(),function(v){var y=t.edge(v);Gn.forEach(y.points,function(g){g.x-=e,g.y-=s;}),Gn.has(y,"x")&&(y.x-=e),Gn.has(y,"y")&&(y.y-=s);}),r.width=n-e+o,r.height=i-s+a;}function Fmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e),s=t.node(e.v),i=t.node(e.w),r,o;n.points?(r=n.points[0],o=n.points[n.points.length-1]):(n.points=[],r=i,o=s),n.points.unshift(Fd.intersectRect(s,r)),n.points.push(Fd.intersectRect(i,o));});}function Bmt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);if(Gn.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case "l":n.x-=n.width/2+n.labeloffset;break;case "r":n.x+=n.width/2+n.labeloffset;break}});}function Umt(t){Gn.forEach(t.edges(),function(e){var n=t.edge(e);n.reversed&&n.points.reverse();});}function jmt(t){Gn.forEach(t.nodes(),function(e){if(t.children(e).length){var n=t.node(e),s=t.node(n.borderTop),i=t.node(n.borderBottom),r=t.node(Gn.last(n.borderLeft)),o=t.node(Gn.last(n.borderRight));n.width=Math.abs(o.x-r.x),n.height=Math.abs(i.y-s.y),n.x=r.x+n.width/2,n.y=s.y+n.height/2;}}),Gn.forEach(t.nodes(),function(e){t.node(e).dummy==="border"&&t.removeNode(e);});}function Hmt(t){Gn.forEach(t.edges(),function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e);}});}function Gmt(t){var e=Fd.buildLayerMatrix(t);Gn.forEach(e,function(n){var s=0;Gn.forEach(n,function(i,r){var o=t.node(i);o.order=r+s,Gn.forEach(o.selfEdges,function(a){Fd.addDummyNode(t,"selfedge",{width:a.label.width,height:a.label.height,rank:o.rank,order:r+ ++s,e:a.e,label:a.label},"_se");}),delete o.selfEdges;});});}function qmt(t){Gn.forEach(t.nodes(),function(e){var n=t.node(e);if(n.dummy==="selfedge"){var s=t.node(n.e.v),i=s.x+s.width/2,r=s.y,o=n.x-i,a=s.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:r-a},{x:i+5*o/6,y:r-a},{x:i+o,y:r},{x:i+5*o/6,y:r+a},{x:i+2*o/3,y:r+a}],n.label.x=n.x,n.label.y=n.y;}});}function TN(t,e){return Gn.mapValues(Gn.pick(t,e),Number)}function EN(t){var e={};return Gn.forEach(t,function(n,s){e[s.toLowerCase()]=n;}),e}});var rU=qt((IMt,eU)=>{var WE=no(),zmt=Ua(),$mt=Fl().Graph;eU.exports={debugOrdering:Vmt};function Vmt(t){var e=zmt.buildLayerMatrix(t),n=new $mt({compound:true,multigraph:true}).setGraph({});return WE.forEach(t.nodes(),function(s){n.setNode(s,{label:s}),n.setParent(s,"layer"+t.node(s).rank);}),WE.forEach(t.edges(),function(s){n.setEdge(s.v,s.w,{},s.name);}),WE.forEach(e,function(s,i){var r="layer"+i;n.setNode(r,{rank:"same"}),WE.reduce(s,function(o,a){return n.setEdge(o,a,{style:"invis"}),a});}),n}});var iU=qt((PMt,nU)=>{nU.exports="0.8.5";});var sU=qt((DMt,oU)=>{oU.exports={graphlib:Fl(),layout:tU(),debug:rU(),util:{time:Ua().time,notime:Ua().notime},version:iU()};});function lU(t){return typeof t=="number"?t:t?.index??-1}var QE,aU,uU,XE,SN;exports.WebColaTranslator=void 0;var JE=Ie(()=>{Ll();PK();QE=Rs(sU()),aU=8,uU=20;XE=class XE{constructor(e,n=800,s=800,i){this.nodeIndexMap=new Map;this.seedPositions=null;this.collapsedGroupAliases=new Map;if(this.FIG_HEIGHT=n,this.FIG_WIDTH=s,this.DEFAULT_X=s/2,this.DEFAULT_Y=n/2,this.instanceLayout=e,this.priorPositionMap=new Map,i?.priorPositions?.positions)for(let v of i.priorPositions.positions)this.priorPositionMap.set(v.id,v);this.lockUnconstrainedNodes=i?.lockUnconstrainedNodes??false,this.collapseSymmetric=i?.collapseSymmetricEdges??true;try{let v=new QE.graphlib.Graph({multigraph:!0});v.setGraph({nodesep:50,ranksep:100,rankdir:"TB"}),v.setDefaultEdgeLabel(()=>({})),e.nodes.forEach(y=>{v.setNode(y.id,{width:y.width,height:y.height});}),e.edges.forEach(y=>{v.setEdge(y.source.id,y.target.id);}),QE.layout(v),this.dagre_graph=v;}catch(v){console.log(v),this.dagre_graph=null;}if((i?.seedMode??globalThis?.SPYTIAL_SEED_MODE??"constraint-aware")!=="dagre"&&this.priorPositionMap.size===0&&IK(e))try{this.seedPositions=LK(e,s,n);}catch(v){console.warn("Constraint-aware seed failed, falling back to DAGRE:",v),this.seedPositions=null;}this.colaNodes=e.nodes.map(v=>this.toColaNode(v));for(let v=0;v<this.colaNodes.length;v++)this.nodeIndexMap.set(this.colaNodes[v].id,v);this.colaEdges=e.edges.map(v=>this.toColaEdge(v)),this.collapseSymmetric&&(this.colaEdges=this.collapseSymmetricEdges(this.colaEdges));let o=this.collapseIdenticalGroups(e.groups);if(this.groupDefinitions=this.determineGroups(o),this.collapsedGroupAliases.size>0)for(let v of this.colaEdges)v.groupId&&(v.groupId=this.collapsedGroupAliases.get(v.groupId)??v.groupId),v.sourceGroupId&&(v.sourceGroupId=this.collapsedGroupAliases.get(v.sourceGroupId)??v.sourceGroupId),v.targetGroupId&&(v.targetGroupId=this.collapsedGroupAliases.get(v.targetGroupId)??v.targetGroupId);this.conflictingConstraints=e.conflictingConstraints||[],this.overlappingNodesData=e.overlappingNodes||[],this.reintroducedNodesData=e.reintroducedNodes||[],this.colaConstraints=e.constraints.flatMap(v=>this.toColaConstraint(v)),this.applyConstraintAwareLocking(this.colaConstraints),this.colaConstraints.length>100&&(this.colaConstraints=this.optimizeConstraints(this.colaConstraints)),this.colaConstraints.length===0&&this.dagre_graph&&this.colaNodes.forEach(v=>v.fixed=1);}optimizeConstraints(e){let n=[],s=[],i=[];for(let a of e)if(a.type==="separation"&&!a.groupBoundary){let c=a;c.axis==="x"&&!c.equality?n.push(c):c.axis==="y"&&!c.equality?s.push(c):i.push(a);}else i.push(a);let r=this.transitiveReductionForSeparation(n),o=this.transitiveReductionForSeparation(s);return [...r,...o,...i]}transitiveReductionForSeparation(e){if(e.length===0)return e;let n=this.colaNodes.length,s=Array(n).fill(null).map(()=>Array(n).fill(null));for(let o of e){let a=o.left,c=o.right;typeof a=="number"&&typeof c=="number"&&a>=0&&a<n&&c>=0&&c<n&&Number.isInteger(a)&&Number.isInteger(c)&&(s[a][c]=o);}let i=Array(n).fill(false).map(()=>Array(n).fill(false));for(let o=0;o<n;o++)for(let a=0;a<n;a++)i[o][a]=s[o][a]!==null;for(let o=0;o<n;o++)for(let a=0;a<n;a++)for(let c=0;c<n;c++)i[a][o]&&i[o][c]&&(i[a][c]=true);let r=[];for(let o of e){let a=o.left,c=o.right,v=false;for(let y=0;y<n;y++)if(y!==a&&y!==c&&s[a][y]!==null&&s[y][c]!==null){v=true;break}v||r.push(o);}return r}getNodeIndex(e){let n=this.nodeIndexMap.get(e);return n===void 0?-1:n}computeHorizontalSeparation(e,n,s){let i=e.visualWidth??e.width??100,r=n.visualWidth??n.width??100,o=i/2+r/2+s,a=Math.max(i,r),c=Math.min(a*.1,20);return o+c}computeVerticalSeparation(e,n,s){let i=e.visualHeight??e.height??60,r=n.visualHeight??n.height??60,o=i/2+r/2+s,a=Math.max(i,r),c=Math.min(a*.1,15);return o+c}leftConstraint(e,n,s){return {type:"separation",axis:"x",left:e,right:n,gap:s}}topConstraint(e,n,s){return {type:"separation",axis:"y",left:e,right:n,gap:s}}heirarchyConstraint(e,n,s){return {type:"hierarchy",parent:e,child:n,gap:s}}toColaNode(e){let n=this.DEFAULT_X,s=this.DEFAULT_Y,i=0,r=this.priorPositionMap.get(e.id);if(r)n=r.x,s=r.y,this.lockUnconstrainedNodes&&(i=1);else if(this.priorPositionMap.size>0){if(console.log(`Node ${e.id}: No prior position found (available: ${Array.from(this.priorPositionMap.keys()).join(", ")})`),this.dagre_graph){let o=this.dagre_graph.node(e.id);o&&(n=o.x,s=o.y);}}else if(this.seedPositions?.has(e.id)){let o=this.seedPositions.get(e.id);n=o.x,s=o.y;}else if(this.dagre_graph){let o=this.dagre_graph.node(e.id);o&&(n=o.x,s=o.y);}return {id:e.id,color:e.color,colorSource:e.colorSource??"default-palette",fillColor:e.fillColor,borderWidth:e.borderWidth,textStyle:e.textStyle,attributes:e.attributes||{},attributeTextStyles:e.attributeTextStyles||{},labels:e.labels,width:e.width+2*(e.disconnected?uU:aU),height:e.height+2*(e.disconnected?uU:aU),visualWidth:e.width,visualHeight:e.height,x:n,y:s,icon:e.icon||"",iconPlacement:e.iconPlacement,iconOpacity:e.iconOpacity,fixed:i,mostSpecificType:e.mostSpecificType,showLabels:e.showLabels,label:e.label}}toColaEdge(e){let n=this.getNodeIndex(e.source.id),s=this.getNodeIndex(e.target.id);return {source:n,target:s,relName:e.relationName,id:e.id,label:e.label,color:e.color,style:e.style,weight:e.weight,highlight:e.highlight,showLabel:e.showLabel,textStyle:e.textStyle,groupId:e.groupId,keyNodeId:e.keyNodeId,sourceGroupId:e.sourceGroupId,targetGroupId:e.targetGroupId}}collapseSymmetricEdges(e){let n=new Map,s=new Set;for(let i of e){if(s.has(i.id))continue;if(i.source===i.target){n.set(i.id,i),s.add(i.id);continue}let r=lU(i.source),o=lU(i.target),a=Math.min(r,o),c=Math.max(r,o),v=`${a}-${c}-${i.label}`,y=e.find(g=>g.id!==i.id&&g.source===i.target&&g.target===i.source&&g.label===i.label&&!s.has(g.id));if(y){let g=i.source<i.target?i:y;n.set(v,{...g,bidirectional:true}),s.add(i.id),s.add(y.id);}else n.set(i.id,i),s.add(i.id);}return Array.from(n.values())}toColaConstraint(e){if(ii(e)){let n=this.colaNodes[this.getNodeIndex(e.left.id)],s=this.colaNodes[this.getNodeIndex(e.right.id)],i=this.computeHorizontalSeparation(n,s,e.minDistance);return this.leftConstraint(this.getNodeIndex(e.left.id),this.getNodeIndex(e.right.id),i)}if(ni(e)){let n=this.colaNodes[this.getNodeIndex(e.top.id)],s=this.colaNodes[this.getNodeIndex(e.bottom.id)],i=this.computeVerticalSeparation(n,s,e.minDistance);return this.topConstraint(this.getNodeIndex(e.top.id),this.getNodeIndex(e.bottom.id),i)}if(Fn(e))return {type:"separation",axis:e.axis,left:this.getNodeIndex(e.node1.id),right:this.getNodeIndex(e.node2.id),gap:0,equality:true};if(Ls(e))return console.log("BoundingBoxConstraint detected."),{type:"noop"};if(Is(e))return this.toColaGroupBoundary(e);throw new Error("Constraint type not recognized")}groupMemberPadding(e){let n=this.collapsedGroupAliases.get(e.name)??e.name,s=this.groupDefinitions.findIndex(r=>r.name===n);if(s<0)throw new Error(`Missing rendered group: ${e.name}`);let i=r=>{let o=this.groupDefinitions[r],a=o.padding,c=new Map;for(let v of o.leaves)c.set(v,a);for(let v of o.groups)for(let[y,g]of i(v))c.set(y,Math.max(c.get(y)??0,a+g));return c};return i(s)}toColaGroupBoundary(e){let n=this.groupMemberPadding(e.groupA),s=this.groupMemberPadding(e.groupB),i=e.side==="left"||e.side==="right"?"x":"y",r=i==="x"?"width":"height",o=e.side==="right"||e.side==="bottom",a=[];for(let[c,v]of n)for(let[y,g]of s){let h=(this.colaNodes[c][r]??0)/2+(this.colaNodes[y][r]??0)/2+v+g+e.minDistance;a.push({type:"separation",axis:i,left:o?y:c,right:o?c:y,gap:h,groupBoundary:true});}return a}classifyConstraintForLocking(e){if(e.type!=="separation")return null;let n=e,s=this.colaNodes[n.left],i=this.colaNodes[n.right];if(!this.priorPositionMap.has(s.id)||!this.priorPositionMap.has(i.id))return {endpoints:[s,i],verdict:"unknown"};let r=(i[n.axis]??0)-(s[n.axis]??0),o=XE.CONSTRAINT_SATISFACTION_TOLERANCE,a=n.equality?Math.abs(r-n.gap)<=o:r+o>=n.gap;return {endpoints:[s,i],verdict:a?"satisfied":"violated"}}applyConstraintAwareLocking(e){let n=this.lockUnconstrainedNodes;if(!(!n&&this.priorPositionMap.size===0))for(let s of e){let i=this.classifyConstraintForLocking(s);if(!i)continue;let[r,o]=i.endpoints;if(!n){r.fixed=0,o.fixed=0;continue}switch(i.verdict){case "satisfied":break;case "violated":r.fixed=0,o.fixed=0;break;case "unknown":this.priorPositionMap.has(r.id)||(r.fixed=0),this.priorPositionMap.has(o.id)||(o.fixed=0);break}}}collapseIdenticalGroups(e){if(e.length===0)return e;let n=new Map;for(let i of e){let r=[...i.nodeIds].sort().join(",");n.has(r)||n.set(r,[]),n.get(r).push(i);}let s=[];for(let i of n.values())if(i.length===1)s.push(i[0]);else {let r={...i[0],name:i.map(o=>o.name).join(" / "),showLabel:i.some(o=>o.showLabel)};for(let o of i)this.collapsedGroupAliases.set(o.name,r.name);s.push(r);}return s}determineGroups(e){let n={};e.forEach(i=>{n[i.name]=i.nodeIds;});let s=this.determineGroupsAndSubgroups(n);return s.forEach(i=>{let r=e.find(c=>c.name===i.name);if(!r)return;let o=r.keyNodeId,a=this.getNodeIndex(o);i.keyNode=a,i.id=r.name,i.showLabel=r.showLabel,r.showLabel&&(i.padding=Math.max(i.padding,20)),i.labelTextStyle=r.labelTextStyle;}),s}isSubGroup(e,n){return e.every(s=>n.includes(s))}determineGroupsAndSubgroups(e){let n={};Object.entries(e).forEach(([r,o])=>{Object.entries(e).forEach(([a,c])=>{r!==a&&(!n[a]||!n[a].includes(r))&&this.isSubGroup(c,o)&&(n[r]?n[r].push(a):n[r]=[a]);});});let s=Object.entries(e).map(([r,o])=>({leaves:o.map(y=>this.getNodeIndex(y)),padding:12,name:r}));return Object.entries(s).map(([r,o])=>{let a=o.leaves,c=o.padding,v=o.name;if(!n[v])return {leaves:a,padding:c,name:v,groups:[]};let y=n[v].map(g=>s.findIndex(u=>u.name===g));return y.forEach(g=>{let h=s[g];a=a.filter(u=>!h.leaves.includes(u));}),{leaves:a,padding:c,name:v,groups:y}})}get nodes(){return this.colaNodes}get links(){return this.colaEdges}get constraints(){return this.colaConstraints}get groups(){return this.groupDefinitions}get conflictingNodes(){let e=[],n=new Map;if(this.instanceLayout)for(let s of this.instanceLayout.nodes)n.set(s.id,s);return this.conflictingConstraints.forEach(s=>{if(ii(s))e.push(s.left),e.push(s.right);else if(ni(s))e.push(s.top),e.push(s.bottom);else if(Fn(s))e.push(s.node1),e.push(s.node2);else if(Ls(s)){e.push(s.node);for(let i of s.group.nodeIds){let r=n.get(i);r&&e.push(r);}}else if(Is(s)){for(let i of s.groupA.nodeIds){let r=n.get(i);r&&e.push(r);}for(let i of s.groupB.nodeIds){let r=n.get(i);r&&e.push(r);}}}),e}get overlappingNodes(){return this.overlappingNodesData}get reintroducedNodes(){return this.reintroducedNodesData}get overlappingGroups(){return (this.instanceLayout?.groups||[]).filter(e=>e.overlapping)}dispose(){this.dagre_graph&&(this.dagre_graph=null);}getMemoryStats(){return {nodeCount:this.colaNodes?.length||0,edgeCount:this.colaEdges?.length||0,groupCount:this.groupDefinitions?.length||0,constraintCount:this.colaConstraints?.length||0,hasDagreGraph:!!this.dagre_graph}}};XE.CONSTRAINT_SATISFACTION_TOLERANCE=.5;SN=XE,exports.WebColaTranslator=class{async translate(e,n=800,s=800,i){return new SN(e,s,n,i)}};});function pU({fontImports:t,fontFamily:e,canvasBackground:n}){return `
|
|
540
540
|
${t}
|
|
541
541
|
:host {
|
|
542
542
|
display: block;
|
|
@@ -1635,7 +1635,7 @@ enum super export new try finally debug spy switch this match case with __proto_
|
|
|
1635
1635
|
`).trim()}function Tvt(t,e={}){let{includeBuiltInTypes:n=false,includeTypeHierarchy:s=true}=e,i=t.getTypes(),r=qT(t.getRelations()),o=n?i:i.filter(c=>!c.isBuiltin),a=[];for(let c of o){if(a.push(`CREATE TABLE ${c.id} (`),a.push(" id VARCHAR PRIMARY KEY"),s&&c.types.length>1){let v=c.types[1];a.push(` -- extends ${v}`);}a.push(");"),a.push("");}for(let c of r)if(c.types.length!==0&&!(!n&&c.types.every(v=>{let y=i.find(g=>g.id===v);return y&&y.isBuiltin}))){a.push(`CREATE TABLE ${c.name} (`);for(let v=0;v<c.types.length;v++){let y=c.types[v],g=v===0?"source":v===1?"target":`arg${v}`,h=o.some(u=>u.id===y)?` REFERENCES ${y}(id)`:"";a.push(` ${g}_${y} VARCHAR${h}${v<c.types.length-1?",":""}`);}a.push(");"),a.push("");}return a.join(`
|
|
1636
1636
|
`).trim()}function Evt(t,e={}){let{includeBuiltInTypes:n=false}=e,s=t.getTypes(),i=t.getRelations(),r=n?s:s.filter(a=>!a.isBuiltin),o=[];o.push("Types:");for(let a of r){let c=a.atoms.length,v=a.isBuiltin?" (built-in)":"",y=a.types.length>1?` extends ${a.types.slice(1).join(", ")}`:"";o.push(`- ${a.id}${y} (${c} atom${c!==1?"s":""})${v}`);}o.push(""),o.push("Relations:");for(let a of i){if(!n&&a.types.every(y=>{let g=s.find(h=>h.id===y);return g&&g.isBuiltin}))continue;let c=a.tuples.length,v=a.types.length>0?a.types.join(" -> "):"untyped";o.push(`- ${a.name}: ${v} (${c} tuple${c!==1?"s":""})`);}return o.join(`
|
|
1637
1637
|
`)}Cy();gb();Bf();Bf();_T();HN();M0();var Ub=Rs(Uw());vd();M0();var Svt=Ub.synthesizeSelector?Ub:Ub.default,{synthesizeSelector:Ovt,synthesizeBinaryRelation:Avt,synthesizeSelectorWithWhy:wvt,synthesizeBinaryRelationWithWhy:Cvt}=Svt;function Nvt(t){return t instanceof exports.SGraphQueryEvaluator}function Rvt(t,e=3){let n=t.map(s=>({atoms:new Set(s.atoms),datum:md(s.dataInstance)}));return Ovt(n,e)}function Lvt(t,e=3){let n=t.map(s=>({pairs:new Set(s.pairs),datum:md(s.dataInstance)}));return Avt(n,e)}function Ivt(t,e=3){let n=t.map(s=>({atoms:new Set(s.atoms),datum:md(s.dataInstance)}));return wvt(n,e)}function Pvt(t,e=3){let n=t.map(s=>({pairs:new Set(s.pairs),datum:md(s.dataInstance)}));return Cvt(n,e)}function Dvt(t,e){return e.map(n=>`${n}(${t})`).join(`
|
|
1638
|
-
`)}function kvt(t,e){return `align ${e}(${t})`}function Mvt(t,e){return `color ${e}(${t})`}var pR=class extends Error{constructor(e){super(e),this.name="SelectorSynthesisError";}};var dR=class{constructor(){this.currentError=null;this.errorCallbacks=[];}setError(e){this.currentError=e,this.notifyCallbacks();}clearError(){this.currentError=null,this.notifyCallbacks();}getCurrentError(){return this.currentError}onErrorChange(e){this.errorCallbacks.push(e);}hasError(){return this.currentError!==null}notifyCallbacks(){this.errorCallbacks.forEach(e=>e(this.currentError));}};iS();Cy();M0();JE();var Kvt=800,Fvt=600;async function Jj(t,e,n={}){let s=n.figWidth??Kvt,i=n.figHeight??Fvt,r=new exports.SGraphQueryEvaluator;r.initialize({sourceData:e});let o=new exports.LayoutInstance(t,r,0,true),{layout:a}=o.generateLayout(e),c,v=null;if(n.policy&&n.prevInstance&&n.currInstance){let l={priorState:n.priorPositions??{positions:[],transform:{k:1,x:0,y:0}},prevInstance:n.prevInstance,currInstance:n.currInstance,spec:t},p=n.policy.apply(l);p.effectivePriorState&&(c={priorPositions:p.effectivePriorState,lockUnconstrainedNodes:p.useReducedIterations},v={positions:p.effectivePriorState.positions.map(x=>({...x})),transform:{...p.effectivePriorState.transform}});}else n.priorPositions&&(c={priorPositions:n.priorPositions,lockUnconstrainedNodes:n.lockUnconstrainedNodes??false});let g=await new exports.WebColaTranslator().translate(a,s,i,c);new(Py()).Layout().linkDistance(150).convergenceThreshold(.1).avoidOverlaps(true).handleDisconnected(true).nodes(g.colaNodes).groups(g.groups).links(g.colaEdges).constraints(g.colaConstraints).size([g.FIG_WIDTH,g.FIG_HEIGHT]).start(0,10,20,1);let u={positions:g.colaNodes.map(f=>({id:f.id,x:f.x??0,y:f.y??0})),transform:{k:1,x:0,y:0}},d=a.edges.map(f=>({source:f.source.id,target:f.target.id,rel:f.relationName}));return {positions:u,edges:d,constraints:a.constraints,nodes:g.colaNodes,groups:g.groups,seed:v}}Ll();var UH=Rs(BH());Ll();function MS(t,e){if(t.positions.length===0)return {positions:[],transform:{...t.transform}};let n=new Map(t.positions.map(c=>[c.id,{x:c.x,y:c.y}])),s=new Set(n.keys());for(let c of e)ii(c)?(s.add(c.left.id),s.add(c.right.id)):ni(c)?(s.add(c.top.id),s.add(c.bottom.id)):Fn(c)&&(s.add(c.node1.id),s.add(c.node2.id));let i=new BE,r=new Map,o=new Map;for(let c of s)r.set(c,new Gf),o.set(c,new Gf);for(let c of e)if(ii(c)){let v=r.get(c.left.id),y=r.get(c.right.id);i.addConstraint(new xc(v.plus(c.minDistance??0),ga.Le,y,xs.required));}else if(ni(c)){let v=o.get(c.top.id),y=o.get(c.bottom.id);i.addConstraint(new xc(v.plus(c.minDistance??0),ga.Le,y,xs.required));}else if(Fn(c)){let v=c.axis==="x"?r.get(c.node1.id):o.get(c.node1.id),y=c.axis==="x"?r.get(c.node2.id):o.get(c.node2.id);i.addConstraint(new xc(v,ga.Eq,y,xs.required));}for(let[c,v]of n)i.addEditVariable(r.get(c),xs.weak),i.addEditVariable(o.get(c),xs.weak),i.suggestValue(r.get(c),v.x),i.suggestValue(o.get(c),v.y);return i.updateVariables(),{positions:t.positions.map(c=>({id:c.id,x:r.get(c.id).value(),y:o.get(c.id).value()})),transform:{...t.transform}}}function jH(t,e,n={}){if(t.positions.length<2)return {positions:t.positions.map(g=>({...g})),transform:{...t.transform}};let s=n.iterations??30,i=n.figWidth??800,r=n.figHeight??600,o=new Map;t.positions.forEach((g,h)=>o.set(g.id,h));let a=t.positions.map((g,h)=>({index:h,id:g.id,x:g.x,y:g.y})),c=[];for(let g=0;g<a.length;g++)for(let h=g+1;h<a.length;h++){let u=a[g].x-a[h].x,d=a[g].y-a[h].y,f=Math.hypot(u,d);f>0&&c.push({source:g,target:h,length:f});}let v=[];for(let g of e)if(ii(g)){let h=o.get(g.left.id),u=o.get(g.right.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:"x",left:h,right:u,gap:g.minDistance??0});}else if(ni(g)){let h=o.get(g.top.id),u=o.get(g.bottom.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:"y",left:h,right:u,gap:g.minDistance??0});}else if(Fn(g)){let h=o.get(g.node1.id),u=o.get(g.node2.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:g.axis,left:h,right:u,gap:0,equality:true});}return new UH.Layout().convergenceThreshold(.01).avoidOverlaps(false).handleDisconnected(false).nodes(a).links(c).linkDistance(g=>g.length).constraints(v).size([i,r]).start(s,0,0,0),{positions:a.map(g=>({id:g.id,x:g.x,y:g.y})),transform:{...t.transform}}}var HH=t=>`${t.source}->${t.target}#${t.rel}`,_s=t=>{let e=new Map,n=Number.isFinite(t.transform?.k)&&t.transform.k>0?t.transform.k:1,s=Number.isFinite(t.transform?.x)?t.transform.x:0,i=Number.isFinite(t.transform?.y)?t.transform.y:0;for(let r of t.positions)e.set(r.id,{x:r.x*n+s,y:r.y*n+i});return e};function KS(t,e,n){let s=_s(t),i=_s(e),r=0;for(let[o,a]of i){if(!s.has(o)||n&&!n.has(o))continue;let c=s.get(o),v=a.x-c.x,y=a.y-c.y;r+=v*v+y*y;}return r}function qH(t,e,n,s,i){let r=_s(t),o=_s(n),a=new Set(e.map(HH)),c=0;for(let v of s){if(!a.has(HH(v))||i&&(!i.has(v.source)||!i.has(v.target)))continue;let y=r.get(v.source),g=r.get(v.target),h=o.get(v.source),u=o.get(v.target);if(!y||!g||!h||!u)continue;let d=g.x-y.x,f=g.y-y.y,l=u.x-h.x,p=u.y-h.y,x=l-d,b=p-f;c+=x*x+b*b;}return c}function FS(t,e,n){let s=_s(t),i=_s(e),r=[];for(let a of e.positions)s.has(a.id)&&(n&&!n.has(a.id)||r.push(a.id));let o=0;for(let a=0;a<r.length;a++){let c=i.get(r[a]),v=s.get(r[a]);for(let y=a+1;y<r.length;y++){let g=i.get(r[y]),h=s.get(r[y]),u=Math.hypot(g.x-c.x,g.y-c.y),d=Math.hypot(h.x-v.x,h.y-v.y),f=u-d;o+=f*f;}}return o}function GH(t){return t.length===0?null:t.reduce((e,n)=>e+n,0)/t.length}function zH(t,e,n){let s=_s(t),i=_s(e),r=[],o=[];for(let[y,g]of i){let h=s.get(y);if(!h)continue;let u=Math.hypot(g.x-h.x,g.y-h.y);n.has(y)?r.push(u):o.push(u);}let a=null;if(r.length>0&&o.length>0){let y=0;for(let g of r)for(let h of o)g>h?y+=1:g===h&&(y+=.5);a=y/(r.length*o.length);}let c=new Set,v=new Set;for(let[y]of i)s.has(y)&&(n.has(y)?c.add(y):v.add(y));return {auc:a,changedMeanDrift:GH(r),stableMeanDrift:GH(o),changedPositional:c.size>0?KS(t,e,c):null,stablePositional:v.size>0?KS(t,e,v):null,changedPairwiseDistance:c.size>=2?FS(t,e,c):null,stablePairwiseDistance:v.size>=2?FS(t,e,v):null,changedCount:r.length,stableCount:o.length}}function Yxt(t,e,n){let s=t.visualWidth??t.width??100,i=e.visualWidth??e.width??100,r=s/2+i/2+n,o=Math.min(Math.max(s,i)*.1,20);return r+o}function Wxt(t,e,n){let s=t.visualHeight??t.height??60,i=e.visualHeight??e.height??60,r=s/2+i/2+n,o=Math.min(Math.max(s,i)*.1,15);return r+o}function $H(t,e,n=5){let s=new Map(e.map(o=>[o.id,o])),i=0,r=0;for(let o of t)if(ii(o)){let a=s.get(o.left.id),c=s.get(o.right.id);if(!a||!c)continue;let v=Yxt(a,c,o.minDistance),y=(c.x??0)-(a.x??0);i+=1,y+n>=v&&(r+=1);}else if(ni(o)){let a=s.get(o.top.id),c=s.get(o.bottom.id);if(!a||!c)continue;let v=Wxt(a,c,o.minDistance),y=(c.y??0)-(a.y??0);i+=1,y+n>=v&&(r+=1);}else if(Fn(o)){let a=s.get(o.node1.id),c=s.get(o.node2.id);if(!a||!c)continue;let v=o.axis==="x"?a.x??0:a.y??0,y=o.axis==="x"?c.x??0:c.y??0;i+=1,Math.abs(v-y)<=n&&(r+=1);}return i===0?1:r/i}function VH(t,e,n=.5){let s=_s(t),i=_s(e),r=new Set;for(let[o,a]of i){let c=s.get(o);c&&Math.abs(a.x-c.x)<=n&&Math.abs(a.y-c.y)<=n&&r.add(o);}return r}function Xxt(t,e,n,s){if(t.x===n.x&&t.y===n.y||t.x===s.x&&t.y===s.y||e.x===n.x&&e.y===n.y||e.x===s.x&&e.y===s.y)return false;let i=(v,y,g)=>(y.x-v.x)*(g.y-v.y)-(y.y-v.y)*(g.x-v.x),r=i(n,s,t),o=i(n,s,e),a=i(t,e,n),c=i(t,e,s);return (r>0&&o<0||r<0&&o>0)&&(a>0&&c<0||a<0&&c>0)}function YH(t,e,n){let s=_s(t),i=_s(e),r=[];for(let[c]of i)s.has(c)&&(n&&!n.has(c)||r.push(c));if(r.sort(),r.length<2)return null;let o=0,a=0;for(let c=0;c<r.length;c++){let v=s.get(r[c]),y=i.get(r[c]);for(let g=c+1;g<r.length;g++){let h=s.get(r[g]),u=i.get(r[g]),d=v.x<h.x&&y.x<u.x||v.x>h.x&&y.x>u.x||v.x===h.x&&y.x===u.x,f=v.y<h.y&&y.y<u.y||v.y>h.y&&y.y>u.y||v.y===h.y&&y.y===u.y;d&&f&&(o+=1),a+=1;}}return a===0?null:o/a}function WH(t,e,n=3,s){let i=_s(t),r=_s(e),o=[];for(let[y]of r)i.has(y)&&(s&&!s.has(y)||o.push(y));if(o.sort(),o.length<n+1)return null;let a=(y,g)=>{let h=y.get(g),u=[];for(let d of o){if(d===g)continue;let f=y.get(d);u.push({id:d,d:Math.hypot(f.x-h.x,f.y-h.y)});}return u.sort((d,f)=>d.d-f.d||d.id.localeCompare(f.id)),new Set(u.slice(0,n).map(d=>d.id))},c=0,v=0;for(let y of o){let g=a(i,y),h=a(r,y),u=new Set([...g,...h]);if(u.size===0)continue;let d=0;for(let f of g)h.has(f)&&(d+=1);c+=d/u.size,v+=1;}return v===0?null:c/v}function BS(t,e){let n=_s(t),s=[];for(let r of e){let o=n.get(r.source),a=n.get(r.target);!o||!a||s.push({a:o,b:a});}let i=0;for(let r=0;r<s.length;r++)for(let o=r+1;o<s.length;o++)Xxt(s[r].a,s[r].b,s[o].a,s[o].b)&&(i+=1);return i}function XH(t,e,n,s){return Math.abs(BS(n,s)-BS(t,e))}function QH(t,e,n){let s=_s(t),i=_s(e),r=0,o=0,a=0;for(let c of n){let v=s.get(c),y=i.get(c);if(!v||!y)continue;let g=y.x-v.x,h=y.y-v.y,u=Math.hypot(g,h);u!==0&&(r+=g/u,o+=h/u,a+=1);}return a===0?null:Math.hypot(r,o)/a}function JH(t,e,n,s=5){let i=_s(t),r=_s(e),o=0,a=0;for(let c of n){let v=i.get(c),y=r.get(c);!v||!y||(o+=1,Math.hypot(y.x-v.x,y.y-v.y)<=s&&(a+=1));}return o===0?null:a/o}function ZH(t,e){if(t.positions.length===0)return 0;let n=MS(t,e),s=new Map(n.positions.map(r=>[r.id,r])),i=0;for(let r of t.positions){let o=s.get(r.id);o&&(i+=Math.hypot(o.x-r.x,o.y-r.y));}return i}var UR="2026-08-25",jR={note:"`languageVersion` is the date the language last changed (YYYY-MM-DD). If it has not moved since the manifest you generated against, nothing you emit needs revisiting. `spytialCoreVersion` records which release produced this file.",deprecations:"A deprecated form keeps parsing and keeps its meaning while it is listed in `deprecations`, and each entry names its replacement and the rewrite to apply. Removal is signalled by `languageVersion` moving, not by the `spytialCoreVersion` major: a removed form leaves this manifest and becomes a parse error, so check `languageVersion` before assuming a spec you generated earlier still parses."},Qxt={name:"textStyle",description:"Styling for a label. Reused by every form that renders text \u2014 an atom's own label, attribute and tag lines, edge labels, and a group label.",fields:[{name:"size",type:"enum",values:["small","normal","large"],enforcement:"value-ignored",default:"normal",description:"Font-size tier relative to the node label: `large` renders bigger than the label, `normal` smaller, `small` smaller still."},{name:"color",type:"color",description:"Any CSS color. Unset inherits the node label color, so dark mode still adapts."}]},Jxt={name:"lineStyle",description:"Styling for an edge's drawn line. Reused by edgeStyle, inferredEdge, and a group's addEdge connector.",fields:[{name:"color",type:"color",description:"Any CSS color."},{name:"pattern",type:"enum",values:["solid","dashed","dotted"],enforcement:"value-ignored",description:"Dash pattern of the line."},{name:"weight",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Line thickness in pixels. Must be > 0; a non-positive or non-numeric weight is dropped."},{name:"highlight",type:"color",description:"A wider, translucent underlay drawn beneath the line. Orthogonal to color and pattern."}]},Zxt={name:"fillStyle",description:"An atom's interior fill. Opt-in: the default look is unfilled, with only the border and label marking the node.",fields:[{name:"color",type:"color",description:"Any CSS color."}]},t_t={name:"borderStyle",description:"An atom's outline.",fields:[{name:"color",type:"color",description:"Any CSS color."},{name:"width",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Outline thickness in pixels. Must be > 0; anything else is dropped."}]},e_t={name:"iconStyle",description:"An icon drawn on an atom. Every leaf is optional, including `path`, so a supertype rule can supply the icon and a subtype rule tune only its opacity.",fields:[{name:"path",type:"icon-path",description:"A bundled icon name (`person`), an icon-pack reference (`bi:person-fill`), a URL, or a path. Resolved to a concrete URL or data URI at parse time. An iconStyle with no path draws nothing."},{name:"placement",type:"enum",values:["full","badge"],enforcement:"value-ignored",default:"full",description:"`full` \u2014 the icon occupies the box, which stays transparent unless a fillStyle.color is given. `badge` \u2014 a small marker in the top-right corner, secondary to the label."},{name:"opacity",type:"number",minimum:0,maximum:1,enforcement:"value-ignored",default:1,description:"Alpha in [0,1]. Out-of-range values are dropped rather than clamped. Fade a `full` icon to use it as a watermark behind the label."}]},tG=[Qxt,Jxt,Zxt,t_t,e_t],Vu=(t,e)=>({name:t,type:"block",block:t,description:e}),Uy=t=>[{arity:"unary",minColumns:1,maxColumns:1,meaning:t}],r_t={arity:"binary",minColumns:2,maxColumns:2,meaning:"Each tuple is one (first, last) pair, and the constraint applies to it."},n_t={arity:"n-ary",minColumns:3,meaning:"Accepted: the pair is the tuple's first and last atom. The columns between are ignored."},HR=[r_t,n_t],US={name:"selector",type:"selector",arity:"unary",accepts:Uy("The set of source atoms the directive is narrowed to."),description:"Apply only to edges whose source atom is in this set. Omit to apply to every source atom."},jS={name:"filter",type:"selector",arity:"n-ary",accepts:[{arity:"n-ary",minColumns:2,meaning:"A tuple matches on its first and last atom, so a longer tuple filters the same relation ends a pair would. A unary result matches nothing \u2014 the directive is then scoped to no tuples at all."}],description:"Apply only to the (source, target, \u2026) tuples this selector returns. Use it to scope a directive to part of a relation, e.g. only the tuples whose value is True."},i_t={id:"orientation",yamlKey:"orientation",label:"Orientation",description:"Place the two ends of each selected tuple relative to one another.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:"Returns (source, target) pairs. The constraint applies to each pair."},{name:"directions",type:"enum-list",values:["above","below","left","right","directlyAbove","directlyBelow","directlyLeft","directlyRight"],required:true,enforcement:"parse-error",listRules:{atMostOneOf:[["above","below"],["left","right"]],narrowsListTo:{directlyAbove:["above","directlyAbove"],directlyBelow:["below","directlyBelow"],directlyLeft:["left","directlyLeft"],directlyRight:["right","directlyRight"]}},description:"Where the TARGET sits relative to the SOURCE. `directions: [above]` on selector `parent` places each tuple's target above its source. The `directly*` variants additionally enforce axis alignment.",note:"The direction is target-relative-to-source. Getting this backwards is the most common spec bug \u2014 transpose the selector (`~parent`) rather than flipping the direction if the relation reads the other way."}],example:{selector:"parent",directions:["above"]},note:"Contradictory direction sets are rejected at parse time: `above` with `below`, `left` with `right`, and a `directly*` variant combined with anything other than its own non-direct counterpart. Values outside the listed set are NOT rejected \u2014 they parse and then match nothing."},o_t={id:"cyclic",yamlKey:"cyclic",label:"Cyclic",description:"Arrange the selected atoms around the perimeter of a circle, in the order the selector defines.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:'Returns (a, b) pairs meaning "b follows a around the circle".'},{name:"direction",type:"enum",values:["clockwise","counterclockwise"],default:"clockwise",enforcement:"unchecked",description:"Which way the cycle runs."}],example:{selector:"nextState",direction:"clockwise"},note:"Two cyclic constraints on the same selector with different directions is a parse error. An unrecognized direction string is not rejected at parse time."},s_t={id:"align",yamlKey:"align",label:"Align",description:"Put the selected atoms on a shared horizontal or vertical line.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:"Returns the pairs of atoms to align with one another."},{name:"direction",type:"enum",values:["horizontal","vertical"],required:true,enforcement:"parse-error",description:"`horizontal` gives the atoms a shared Y coordinate; `vertical` a shared X coordinate. An unrecognized value is a parse error."}],example:{selector:"siblings",direction:"horizontal"}},a_t={id:"group",yamlKey:"group",label:"Group (by selector)",description:"Draw a hull around a set of atoms. For tuples (a, b), (a, c), \u2026 the group is keyed by `a` and contains {b, c, \u2026}.",sections:["constraints"],valueShape:"mapping",discriminator:{field:"field",present:false},supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:[{arity:"binary",minColumns:2,maxColumns:2,meaning:"One group per distinct first atom: the first column is the key, the last the members. The group is named `<name>[<key>]`, which is what a keyed `inferredEdge` `draw` end attaches to."},{arity:"n-ary",minColumns:3,meaning:"As binary \u2014 the key is the tuple's first atom and the member its last, ignoring the columns between."},{arity:"unary",minColumns:1,maxColumns:1,meaning:"One single group holding every selected atom, with no key. It is named `<name>` with no `[key]` suffix, and a `draw` end naming it attaches there whatever the end's atom is."}],required:true,enforcement:"unchecked",description:"First column is the group key, second the members. A unary selector builds a single unkeyed group.",note:"A `group` with neither `selector` nor `field` is silently dropped \u2014 it matches neither grouping form. That is the one case where omitting this field is not an error but a no-op."},{name:"name",type:"string",required:true,enforcement:"parse-error",description:"Display name on the group, and the handle an `inferredEdge` `draw` endpoint refers to. Required unless the constraint is negated (`hold: never`), where a name is generated."},{name:"addEdge",type:"enum",values:["none","togroup","fromgroup"],default:"none",enforcement:"value-ignored",description:"Draw a connector between the group key and the group: `togroup` points key \u2192 group, `fromgroup` points group \u2192 key, `none` draws nothing.",alternativeForm:{type:"block",description:"Block form also styles the connector, which is an edge and so takes the shared edge blocks: `{ points: <direction>, lineStyle: {\u2026}, textStyle: {\u2026} }`.",fields:[{name:"points",type:"enum",values:["none","togroup","fromgroup"],default:"none",description:"The connector direction \u2014 the same value the bare string form carries."},Vu("lineStyle","The connector's line."),Vu("textStyle","The connector's label.")]},note:"The legacy boolean `true` is still accepted and means `togroup`."},Vu("textStyle","The group's own label. Only `color` applies today \u2014 group labels auto-fit their box, so `size` is reserved.")],example:{selector:"Team.members",name:"Team"}},u_t={id:"size",yamlKey:"size",label:"Size",description:"Set the width and height of matching nodes, in pixels.",sections:["constraints"],deprecatedSections:["directives"],sectionDeprecation:{reason:"Size fixes a node's geometry, which is what the layout solves over \u2014 not presentation layered on a solved layout. It is a constraint. The directives section still accepts it, identically, behind a deprecation warning.",warningSpecType:"size"},valueShape:"mapping",supportsHold:false,fields:[{name:"width",type:"number",required:true,enforcement:"parse-error",exclusiveMinimum:0,description:"Node width in pixels. Required, and must be a number greater than 0."},{name:"height",type:"number",required:true,enforcement:"parse-error",exclusiveMinimum:0,description:"Node height in pixels. Required, and must be a number greater than 0."},{name:"selector",type:"selector",arity:"unary",accepts:Uy("The nodes to resize."),description:"Which nodes to resize. Omit to resize every node."}],example:{selector:"ImportantNode",width:150,height:80},note:"`hold: never` is not supported and is silently ignored."},l_t={id:"hideAtom",yamlKey:"hideAtom",label:"Hide atom",description:"Remove matching atoms from the diagram.",sections:["constraints"],deprecatedSections:["directives"],sectionDeprecation:{reason:"Hiding an atom changes what the layout has to place, and can make a spec unsatisfiable against the other constraints \u2014 it is a constraint, not presentation. The directives section still accepts it, identically, behind a deprecation warning.",warningSpecType:"hideAtom"},valueShape:"mapping",supportsHold:false,fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms to hide."),required:true,enforcement:"unchecked",description:"Which atoms to hide."}],example:{selector:"HelperNode"},note:"`hold: never` is not supported and is silently ignored. Hiding an atom that a layout constraint places, or that a group contains, makes the spec unsatisfiable: the layout reports a hidden-node conflict and draws a counterfactual with the conflicting atoms outlined. Hiding a keyed group's key is fine \u2014 the key is not inside the group."},c_t={id:"flag",yamlKey:"flag",label:"Flag",description:"Toggle a whole-diagram rendering behaviour.",sections:["directives"],valueShape:"scalar",supportsHold:false,fields:[{name:"flag",type:"enum",values:["hideDisconnected","hideDisconnectedBuiltIns"],required:true,enforcement:"unchecked",description:"`hideDisconnected` hides every atom with no edges; `hideDisconnectedBuiltIns` hides only the disconnected built-in atoms (Int, String, \u2026). Any other value is silently ignored."}],example:{flag:"hideDisconnectedBuiltIns"},note:"Written as a bare scalar: `- flag: hideDisconnected`, not a mapping."},h_t={id:"atomStyle",yamlKey:"atomStyle",label:"Atom style",description:"Style matching atoms. An atom is a composite of an interior fill, an outline, an icon, and its label, so each is its own block.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms this rule styles."),description:"Which atoms to style. Omit to style every atom."},Vu("fillStyle","The node's interior fill."),Vu("borderStyle","The node's outline."),Vu("iconStyle","An icon drawn on the node."),Vu("textStyle","The node's own label."),{name:"showLabel",type:"boolean",default:true,description:"Whether the atom's label is drawn. Independent of the icon: `iconStyle.placement` controls the icon's geometry, this controls the label."}],example:{selector:"Person",borderStyle:{color:"#0369a1"}},note:"Rules compose: a supertype selector already returns subtype atoms, so a `Node` rule and a `RedNode` rule both apply to a RedNode atom and their set properties gap-fill each other. Two rules setting the SAME property to DIFFERENT values is a hard error at layout time \u2014 styles never silently override."},f_t={id:"edgeStyle",yamlKey:"edgeStyle",label:"Edge style",description:"Style the edges of a relation: the drawn line, the label, and visibility.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation whose edges this styles."},US,jS,Vu("lineStyle","The drawn line."),Vu("textStyle","The edge label."),{name:"showLabel",type:"boolean",default:true,description:"Whether the edge label is drawn."},{name:"hidden",type:"boolean",default:false,description:"Hide the edge entirely while keeping the relation in the data."}],example:{field:"parent",lineStyle:{color:"blue",pattern:"dashed"}},note:"Like atomStyle, overlapping rules compose and a genuine disagreement is an error rather than a silent override."},p_t={id:"attribute",yamlKey:"attribute",label:"Attribute",description:"Render a relation as a key-value line on its source node instead of as an edge.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation to fold into the source node. Its edges are removed from the graph."},{...US,description:"Apply only to these source atoms. Omit to apply to every source atom."},jS,Vu("textStyle","This attribute line's own styling.")],example:{field:"age",selector:"Person"},note:"Multiple targets for the same source become a list. Unlike `tag`, this removes the edge."},d_t={id:"tag",yamlKey:"tag",label:"Tag",description:"Add a computed key-value line to matching nodes, without touching the graph structure.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"toTag",type:"selector",arity:"unary",accepts:Uy("The atoms that receive the tag."),required:true,enforcement:"unchecked",description:"Which atoms receive the tag."},{name:"name",type:"string",required:true,enforcement:"unchecked",description:"The label shown before the value."},{name:"value",type:"selector",arity:"n-ary",accepts:[{arity:"n-ary",minColumns:2,meaning:"One line per tuple whose first atom is the tagged atom: the last column is the value and any columns between become the key, as `name[k1][k2]: value`. A binary result is the plain `name: value` case."},{arity:"unary",minColumns:1,maxColumns:1,meaning:'A membership tag: an atom in the result is tagged with its own label, as `name: <label>`. The value carries no more than "this atom is in the set".'}],required:true,enforcement:"unchecked",description:"Evaluated per tagged atom; its result becomes the value. A binary result shows as `name: value`; a longer tuple shows one line per tuple, as `name[k1][k2]: value`. A unary result tags each selected atom with its own label."},Vu("textStyle","This tag line's own styling.")],example:{toTag:"Person",name:"age",value:"age"},note:"Unlike `attribute`, tags do not remove edges."},g_t={id:"hideField",yamlKey:"hideField",label:"Hide field",description:"Hide a relation's edges.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation to hide."},US,{...jS,description:"Hide only the tuples this selector returns."}],example:{field:"internal"}},y_t={id:"inferredEdge",yamlKey:"inferredEdge",label:"Inferred edge",description:"Draw an edge that is not in the data, computed from a selector.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"name",type:"string",required:true,enforcement:"unchecked",description:"The label drawn on the edge."},{name:"selector",type:"selector",arity:"binary",accepts:[{arity:"binary",minColumns:2,maxColumns:2,meaning:"One edge per tuple, from its first atom to its last."},{arity:"n-ary",minColumns:3,meaning:"One edge from the tuple's first atom to its last. Unlike the constraints, the columns between are not discarded: their labels are appended to the edge label as `<name>[m1,m2]`."},{arity:"unary",minColumns:1,maxColumns:1,requires:"draw",meaning:"One edge per atom, the atom feeding both ends \u2014 the shape `draw: _ -> <group>` needs, connecting each atom to its own group. Without `draw` a unary selector draws nothing at all: the engine reads this field as tuples, and single-atom tuples are dropped before any edge is made."}],required:true,enforcement:"unchecked",description:"Returns the (source, target) pairs to connect. May be unary when `draw` is given \u2014 the single atom then feeds both ends."},{name:"draw",type:"string",enforcement:"parse-error",pattern:"^\\s*[^\\s](?:(?!->)[\\s\\S])*->(?:(?!->)[\\s\\S])*[^\\s]\\s*$",description:"Reinterpret what each end attaches to, as `<end> -> <end>`. Each end is `_` (the atom itself, the default) or the name of a `group` constraint, in which case the end attaches to that group's hull. The left end applies to the first atom of each tuple, the right end to the last.",note:"Parsed strictly: a value that is not a string, or that does not contain exactly one `->`, is a parse error. A group name that no `group` constraint defines is not \u2014 it raises a warning (code `unresolved-reference`, specType `inferredEdge`) and the edge is skipped at layout time, so a fragment that names a group defined in another fragment still parses. `draw` never reorders \u2014 transpose the selector (`~connected`) to flip an edge."},Vu("lineStyle","The drawn line."),Vu("textStyle","The edge label."),{name:"color",type:"color",description:"Legacy inline line color.",deprecated:{replacedBy:"lineStyle.color"}},{name:"style",type:"enum",values:["solid","dashed","dotted"],description:"Legacy inline dash pattern.",deprecated:{replacedBy:"lineStyle.pattern"}},{name:"weight",type:"number",exclusiveMinimum:0,description:"Legacy inline line thickness.",deprecated:{replacedBy:"lineStyle.weight"}},{name:"highlight",type:"color",description:"Legacy inline highlight underlay.",deprecated:{replacedBy:"lineStyle.highlight"}}],example:{name:"reachable",selector:"^parent",lineStyle:{color:"gray",pattern:"dotted"}},note:"Using any of the legacy inline `color`/`style`/`weight`/`highlight` keys raises a deprecation warning with specType `inferredEdge`. The block form wins when both are given. If an end's atom keys no group of that name in a given instance, that one edge is skipped with a console warning \u2014 data-dependent, not a spec error."},m_t={id:"icon",yamlKey:"icon",label:"Icon",description:"Assign an icon to matching atoms.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"atomStyle",reason:"The single `showLabels` boolean drove label visibility and icon geometry at once. atomStyle splits those into two independent knobs, which is what makes a faded watermark, or a hidden label with no icon, expressible.",mapping:{path:"iconStyle.path",selector:"selector","showLabels: false":"showLabel: false + iconStyle.placement: full","showLabels: true":"showLabel: true + iconStyle.placement: badge"},warningSpecType:"icon"},fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms that get the icon."),required:true,enforcement:"unchecked",description:'Which atoms get the icon. Omitting it drops the directive entirely \u2014 it never means "every atom".'},{name:"path",type:"icon-path",required:true,enforcement:"unchecked",description:"Bundled name, icon-pack reference, URL, or path. Omitting it drops the directive."},{name:"showLabels",type:"boolean",default:false,description:"Whether the atom's label is drawn alongside the icon."}],example:{selector:"Person",path:"person",showLabels:true}},v_t={id:"atomColor",yamlKey:"atomColor",label:"Atom color",description:"Set the color of matching atoms.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"atomStyle",reason:"atomStyle expresses the same recolor and also reaches the fill, the icon, and the label. The rewrite is border-preserving, so an existing diagram is unchanged.",mapping:{value:"borderStyle.color",selector:"selector"},warningSpecType:"atomColor"},fields:[{name:"value",type:"color",required:true,enforcement:"unchecked",description:"Any CSS color. Applies to the node's outline, not its fill."},{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms to recolor."),required:true,enforcement:"unchecked",description:'Which atoms to recolor. Omitting it drops the directive \u2014 it never means "every atom".'}],example:{selector:"Person",value:"#ff5733"}},x_t={id:"edgeColor",yamlKey:"edgeColor",label:"Edge color",description:"Style a relation's edges with flat, inline keys.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"edgeStyle",reason:"edgeStyle groups the same knobs into the shared lineStyle/textStyle blocks that every other form uses.",mapping:{value:"lineStyle.color",style:"lineStyle.pattern",weight:"lineStyle.weight",highlight:"lineStyle.highlight",field:"field",selector:"selector",filter:"filter",showLabel:"showLabel",hidden:"hidden"},warningSpecType:"edgeColor"},fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation whose edges this styles."},{name:"value",type:"color",required:true,enforcement:"unchecked",description:"Line color."},US,jS,{name:"style",type:"enum",values:["solid","dashed","dotted"],enforcement:"value-ignored",description:"Dash pattern. Trimmed and lowercased before matching, unlike `lineStyle.pattern`."},{name:"weight",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Line thickness in pixels."},{name:"highlight",type:"color",description:"A wider, translucent underlay beneath the line."},{name:"showLabel",type:"boolean",default:true,description:"Whether the edge label is drawn."},{name:"hidden",type:"boolean",default:false,description:"Hide the edge entirely."}],example:{field:"parent",value:"blue"}},zd=[i_t,o_t,s_t,a_t,u_t,l_t,c_t,h_t,f_t,p_t,d_t,g_t,y_t,m_t,v_t,x_t],__t={field:"source",fields:[{name:"text",type:"string",required:true,enforcement:"value-ignored",description:"The rule exactly as its author wrote it in the host surface \u2014 a Python decorator, a Rust attribute, a Forge annotation. Shown (escaped, as code) in conflict reports and warnings in place of the engine\u2019s own description of the rule. A missing or empty `text` makes the whole `source` block ignored."},{name:"location",type:"string",description:"Where the rule was written, e.g. `tree.py:12`. Appended to the displayed text."}],supportedBy:zd.filter(t=>t.valueShape!=="scalar").map(t=>t.id),displayedBy:["orientation","cyclic","align","group","hideAtom"],note:"For generators only \u2014 hand-written YAML needs no `source`, because there the YAML is the author\u2019s text. Accepted on every block-bodied item so a generator can stamp it uniformly. The engine carries and displays it for the forms that appear in conflict reports (the `displayedBy` list: the layout constraints and `hideAtom`); on the rest it parses and is ignored. Duplicate rules de-duplicate to one entry, which keeps the first provided source."},b_t={field:"hold",values:["always","never"],default:"always",supportedBy:zd.filter(t=>t.supportsHold).map(t=>t.id),note:"`hold: never` negates a constraint: it asserts the relationship must not hold. Only the value `never` has an effect \u2014 `always`, any other string, and an absent field all mean the positive constraint. Double negation is not supported. `size` and `hideAtom` accept the key syntactically but ignore it."},T_t={sections:["constraints","directives"],unknownKeys:"ignored",sectionShape:"list",notes:["Both sections are optional; an empty document is valid and yields an empty spec.","Each section must be a YAML list of single-key mappings. A section written as a mapping instead of a list is ignored wholesale, without an error.","Unrecognized top-level keys, unrecognized list items, and unrecognized fields inside a known item are all ignored silently. Nothing in the parser will tell you about a typo \u2014 validate against this manifest first.","`size` and `hideAtom` are constraints. Both are still accepted among the directives, with identical meaning, but that placement is deprecated and warns \u2014 emit them under `constraints`. Each item lists where to write it in `sections`, and any tolerated-but-deprecated placement in `deprecatedSections`.","Duplicate constraints (same selector and same parameters) are de-duplicated at parse time.","Parsing returns advisory `warnings` alongside the spec. Each carries a `code` (currently `deprecated`) and a `specType` naming the form, so a consumer can surface them without matching prose.","Every block-bodied item accepts an optional `source` block carrying the rule as its author wrote it in the host surface; conflict reports cite that text instead of the engine\u2019s own rendering. See the top-level `source` entry for the block\u2019s shape and which items display it.","The old group-by-field shape, `group: { field, groupOn, addToGroup }`, is removed. It is a parse error, not a silently ignored key, so an old spec fails loudly instead of losing its grouping. Write a `group` whose binary `selector` has the key in its first column and the members in its second; over `worksIn: Employee -> Department`, `groupOn: 1` / `addToGroup: 0` becomes `selector: ~worksIn` plus a `name`, and `groupOn: 0` / `addToGroup: 1` becomes `selector: worksIn`."]},E_t=[...zd.filter(t=>t.deprecated).map(t=>({id:t.id,kind:"item",path:t.yamlKey,...t.deprecated})),...zd.filter(t=>t.deprecatedSections?.length).flatMap(t=>t.deprecatedSections.map(e=>({id:`${t.id}@${e}`,kind:"placement",path:`${e}[].${t.yamlKey}`,replacedBy:`${t.sections[0]}[].${t.yamlKey}`,reason:t.sectionDeprecation.reason,mapping:{[`${e}[].${t.yamlKey}`]:`${t.sections[0]}[].${t.yamlKey}`},warningSpecType:t.sectionDeprecation.warningSpecType}))),...zd.flatMap(t=>t.fields.filter(e=>e.deprecated).map(e=>({id:`${t.id}.${e.name}`,kind:"field",path:`${t.yamlKey}.${e.name}`,replacedBy:`${t.yamlKey}.${e.deprecated.replacedBy}`,reason:e.deprecated.reason??`Superseded by ${e.deprecated.replacedBy}.`,mapping:{[e.name]:e.deprecated.replacedBy},warningSpecType:t.yamlKey})))],S_t={reference:"https://github.com/sidprasad/spytial-core/blob/main/docs/YAML_SPECIFICATION.md",constraints:"https://sidprasad.github.io/spytial-core/#/constraints",directives:"https://sidprasad.github.io/spytial-core/#/directives",selectors:"https://sidprasad.github.io/spytial-core/#/selectors",jsonSchema:"https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@main/docs/spytial-spec.schema.json",manifest:"https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@main/docs/spytial-language.json"};function eG(t){return {language:"spytial-layout-spec",languageVersion:UR,spytialCoreVersion:t,versioning:jR,document:T_t,hold:b_t,source:__t,blocks:tG,items:zd,deprecations:E_t,documentation:S_t}}function rG(){return zd}function nG(t){return zd.find(e=>e.id===t)}function iG(){return tG}var O_t="https://json-schema.org/draft/2020-12/schema",A_t=t=>`urn:spytial:layout-spec-schema:${t}`,oG={selector:"string",relation:"string",string:"string",color:"string","icon-path":"string",number:"number",integer:"integer",boolean:"boolean"};function sG(t){let e=[t.description];if(t.arity){let n=a=>a.maxColumns===void 0?`${a.minColumns}+ columns`:a.maxColumns===1?"1 column":`${a.maxColumns} columns`,s=t.accepts??[],i=s.find(a=>a.arity===t.arity),r=s.filter(a=>a!==i),o=i?`${t.arity} \u2014 ${n(i)}`:t.arity;e.push(r.length>0?`Selector arity: ${o} (also accepted: ${r.map(a=>a.requires?`${n(a)}, with \`${a.requires}\``:n(a)).join("; ")}).`:`Selector arity: ${o}.`);}return t.default!==void 0&&e.push(`Default when omitted: ${JSON.stringify(t.default)}.`),t.deprecated&&e.push(`Deprecated \u2014 use \`${t.deprecated.replacedBy}\` instead.`),t.note&&e.push(t.note),e.join(" ")}function uG(t){let e={description:sG(t)};switch(t.deprecated&&(e.deprecated=true),t.type){case "enum":e.type="string",e.enum=[...t.values??[]];break;case "enum-list":{e.type="array",e.minItems=1,e.items={type:"string",enum:[...t.values??[]]};let n=[];for(let s of t.listRules?.atMostOneOf??[])n.push({not:{allOf:s.map(i=>({contains:{const:i}}))},description:`At most one of: ${s.join(", ")}.`});for(let[s,i]of Object.entries(t.listRules?.narrowsListTo??{}))n.push({if:{contains:{const:s}},then:{items:{enum:[...i]}},description:`With \`${s}\`, the only other value allowed is ${i.filter(r=>r!==s).join(", ")}.`});n.length>0&&(e.allOf=n);break}case "block":t.block?e.$ref=`#/$defs/${t.block}`:Object.assign(e,Qb(t.fields??[]));break;default:{let n=oG[t.type];n&&(e.type=n),n==="string"&&t.required&&(e.minLength=1),t.pattern!==void 0&&(e.pattern=t.pattern);break}}if(t.exclusiveMinimum!==void 0&&(e.exclusiveMinimum=t.exclusiveMinimum),t.minimum!==void 0&&(e.minimum=t.minimum),t.maximum!==void 0&&(e.maximum=t.maximum),t.alternativeForm){let n={...e};delete n.description;let s=t.alternativeForm.type==="block"?{...Qb(t.alternativeForm.fields??[]),description:t.alternativeForm.description}:{type:oG[t.alternativeForm.type]??"string"};return {description:sG(t),oneOf:[n,s,{const:true,deprecated:true,description:"Legacy spelling of `togroup`."}]}}return e}function Qb(t){let e={};for(let i of t)e[i.name]=uG(i);let n=t.filter(i=>i.required).map(i=>i.name),s={type:"object",properties:e,additionalProperties:false};return n.length>0&&(s.required=n),s}function w_t(t,e){let n=Qb(t.fields);if(t.supportsHold&&(n.properties.hold={type:"string",enum:["always","never"],description:"Negation. `never` asserts the constraint must not hold; `always` (the default) is the positive form."}),e.source.supportedBy.includes(t.id)&&(n.properties.source={$ref:"#/$defs/source",description:e.source.displayedBy.includes(t.id)?"The rule as its author wrote it in the host surface. Cited in conflict reports in place of the engine\u2019s own rendering.":"The rule as its author wrote it in the host surface. Accepted here for uniform generation; not displayed for this item today."}),t.discriminator)if(t.discriminator.present){let s=new Set([...n.required??[],t.discriminator.field]);n.required=[...s];}else n.not={required:[t.discriminator.field]};return t.id==="group"&&(n.required=(n.required??[]).filter(s=>s!=="name"),n.required.length===0&&delete n.required,n.allOf=[{if:{not:{properties:{hold:{const:"never"}},required:["hold"]}},then:{required:["name"]}}]),n}function C_t(t,e){let n=t.valueShape==="scalar"?uG(t.fields[0]):w_t(t,e),s={title:t.label,description:t.deprecated?`${t.description} DEPRECATED \u2014 use \`${t.deprecated.replacedBy}\` instead. ${t.deprecated.reason}`:t.description,type:"object",properties:{[t.yamlKey]:n},required:[t.yamlKey],additionalProperties:false};return t.deprecated&&(s.deprecated=true),s}function aG(t,e){let n=t.items.filter(i=>i.sections.includes(e)),s=t.items.filter(i=>i.deprecatedSections?.includes(e));return {type:["array","null"],description:e==="constraints"?"Structural layout: where nodes end up relative to one another.":"Presentation: how nodes and edges look, and what is shown at all.",items:{oneOf:[...n.map(i=>({$ref:`#/$defs/${GR(i)}`})),...s.map(i=>({$ref:`#/$defs/${GR(i)}`,deprecated:true,description:`\`${i.yamlKey}\` here is deprecated \u2014 write it under \`${i.sections[0]}\`. ${i.sectionDeprecation.reason}`}))]}}}function GR(t){return t.id.replace(/\./g,"_")}function lG(t){let e={};for(let n of t.blocks)e[n.name]={description:n.description,...Qb(n.fields)};e.source={description:t.source.note,...Qb(t.source.fields)};for(let n of t.items)e[GR(n)]=C_t(n,t);return {$schema:O_t,$id:A_t(t.languageVersion),title:"Spytial layout specification",description:`A Spytial spec: constraints (structural layout) and directives (presentation). Spec language ${t.languageVersion}, from spytial-core ${t.spytialCoreVersion}. This schema is stricter than the engine parser, which silently ignores anything it does not recognize \u2014 validating here is how a misspelled key or an out-of-range value gets caught at all. Fetch it from https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@<tag>/docs/spytial-spec.schema.json; pin a tag, since the @main path is overwritten each release.`,"x-spytial-language-version":t.languageVersion,"x-spytial-core-version":t.spytialCoreVersion,type:"object",properties:{constraints:aG(t,"constraints"),directives:aG(t,"directives")},additionalProperties:false,$defs:e}}var N_t=zR.default??zR,R_t=$R.default??$R;if(typeof window<"u"){let t=window;t.d3||(t.d3=N_t),t.cola||(t.cola=R_t),Promise.resolve().then(()=>(cS(),ej)).then(({WebColaCnDGraph:e})=>(typeof customElements<"u"&&!customElements.get("webcola-cnd-graph")&&customElements.define("webcola-cnd-graph",e),Promise.resolve().then(()=>($N(),nj)).then(({StructuredInputGraph:n})=>{typeof customElements<"u"&&!customElements.get("structured-input-graph")&&customElements.define("structured-input-graph",n);}))).catch(console.error);}var L_t="6.0.1",qR=class{constructor(e={}){this.config={debug:false,version:L_t,...e};}init(){this.config.debug;}getConfig(){return {...this.config}}updateConfig(e){this.config={...this.config,...e};}},d8t=t=>new qR(t);/*! Bundled license information:
|
|
1638
|
+
`)}function kvt(t,e){return `align ${e}(${t})`}function Mvt(t,e){return `color ${e}(${t})`}var pR=class extends Error{constructor(e){super(e),this.name="SelectorSynthesisError";}};var dR=class{constructor(){this.currentError=null;this.errorCallbacks=[];}setError(e){this.currentError=e,this.notifyCallbacks();}clearError(){this.currentError=null,this.notifyCallbacks();}getCurrentError(){return this.currentError}onErrorChange(e){this.errorCallbacks.push(e);}hasError(){return this.currentError!==null}notifyCallbacks(){this.errorCallbacks.forEach(e=>e(this.currentError));}};iS();Cy();M0();JE();var Kvt=800,Fvt=600;async function Jj(t,e,n={}){let s=n.figWidth??Kvt,i=n.figHeight??Fvt,r=new exports.SGraphQueryEvaluator;r.initialize({sourceData:e});let o=new exports.LayoutInstance(t,r,0,true),{layout:a}=o.generateLayout(e),c,v=null;if(n.policy&&n.prevInstance&&n.currInstance){let l={priorState:n.priorPositions??{positions:[],transform:{k:1,x:0,y:0}},prevInstance:n.prevInstance,currInstance:n.currInstance,spec:t},p=n.policy.apply(l);p.effectivePriorState&&(c={priorPositions:p.effectivePriorState,lockUnconstrainedNodes:p.useReducedIterations},v={positions:p.effectivePriorState.positions.map(x=>({...x})),transform:{...p.effectivePriorState.transform}});}else n.priorPositions&&(c={priorPositions:n.priorPositions,lockUnconstrainedNodes:n.lockUnconstrainedNodes??false});let g=await new exports.WebColaTranslator().translate(a,s,i,c);new(Py()).Layout().linkDistance(150).convergenceThreshold(.1).avoidOverlaps(true).handleDisconnected(true).nodes(g.colaNodes).groups(g.groups).links(g.colaEdges).constraints(g.colaConstraints).size([g.FIG_WIDTH,g.FIG_HEIGHT]).start(0,10,20,1);let u={positions:g.colaNodes.map(f=>({id:f.id,x:f.x??0,y:f.y??0})),transform:{k:1,x:0,y:0}},d=a.edges.map(f=>({source:f.source.id,target:f.target.id,rel:f.relationName}));return {positions:u,edges:d,constraints:a.constraints,nodes:g.colaNodes,groups:g.groups,seed:v}}Ll();var UH=Rs(BH());Ll();function MS(t,e){if(t.positions.length===0)return {positions:[],transform:{...t.transform}};let n=new Map(t.positions.map(c=>[c.id,{x:c.x,y:c.y}])),s=new Set(n.keys());for(let c of e)ii(c)?(s.add(c.left.id),s.add(c.right.id)):ni(c)?(s.add(c.top.id),s.add(c.bottom.id)):Fn(c)&&(s.add(c.node1.id),s.add(c.node2.id));let i=new BE,r=new Map,o=new Map;for(let c of s)r.set(c,new Gf),o.set(c,new Gf);for(let c of e)if(ii(c)){let v=r.get(c.left.id),y=r.get(c.right.id);i.addConstraint(new xc(v.plus(c.minDistance??0),ga.Le,y,xs.required));}else if(ni(c)){let v=o.get(c.top.id),y=o.get(c.bottom.id);i.addConstraint(new xc(v.plus(c.minDistance??0),ga.Le,y,xs.required));}else if(Fn(c)){let v=c.axis==="x"?r.get(c.node1.id):o.get(c.node1.id),y=c.axis==="x"?r.get(c.node2.id):o.get(c.node2.id);i.addConstraint(new xc(v,ga.Eq,y,xs.required));}for(let[c,v]of n)i.addEditVariable(r.get(c),xs.weak),i.addEditVariable(o.get(c),xs.weak),i.suggestValue(r.get(c),v.x),i.suggestValue(o.get(c),v.y);return i.updateVariables(),{positions:t.positions.map(c=>({id:c.id,x:r.get(c.id).value(),y:o.get(c.id).value()})),transform:{...t.transform}}}function jH(t,e,n={}){if(t.positions.length<2)return {positions:t.positions.map(g=>({...g})),transform:{...t.transform}};let s=n.iterations??30,i=n.figWidth??800,r=n.figHeight??600,o=new Map;t.positions.forEach((g,h)=>o.set(g.id,h));let a=t.positions.map((g,h)=>({index:h,id:g.id,x:g.x,y:g.y})),c=[];for(let g=0;g<a.length;g++)for(let h=g+1;h<a.length;h++){let u=a[g].x-a[h].x,d=a[g].y-a[h].y,f=Math.hypot(u,d);f>0&&c.push({source:g,target:h,length:f});}let v=[];for(let g of e)if(ii(g)){let h=o.get(g.left.id),u=o.get(g.right.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:"x",left:h,right:u,gap:g.minDistance??0});}else if(ni(g)){let h=o.get(g.top.id),u=o.get(g.bottom.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:"y",left:h,right:u,gap:g.minDistance??0});}else if(Fn(g)){let h=o.get(g.node1.id),u=o.get(g.node2.id);h!==void 0&&u!==void 0&&v.push({type:"separation",axis:g.axis,left:h,right:u,gap:0,equality:true});}return new UH.Layout().convergenceThreshold(.01).avoidOverlaps(false).handleDisconnected(false).nodes(a).links(c).linkDistance(g=>g.length).constraints(v).size([i,r]).start(s,0,0,0),{positions:a.map(g=>({id:g.id,x:g.x,y:g.y})),transform:{...t.transform}}}var HH=t=>`${t.source}->${t.target}#${t.rel}`,_s=t=>{let e=new Map,n=Number.isFinite(t.transform?.k)&&t.transform.k>0?t.transform.k:1,s=Number.isFinite(t.transform?.x)?t.transform.x:0,i=Number.isFinite(t.transform?.y)?t.transform.y:0;for(let r of t.positions)e.set(r.id,{x:r.x*n+s,y:r.y*n+i});return e};function KS(t,e,n){let s=_s(t),i=_s(e),r=0;for(let[o,a]of i){if(!s.has(o)||n&&!n.has(o))continue;let c=s.get(o),v=a.x-c.x,y=a.y-c.y;r+=v*v+y*y;}return r}function qH(t,e,n,s,i){let r=_s(t),o=_s(n),a=new Set(e.map(HH)),c=0;for(let v of s){if(!a.has(HH(v))||i&&(!i.has(v.source)||!i.has(v.target)))continue;let y=r.get(v.source),g=r.get(v.target),h=o.get(v.source),u=o.get(v.target);if(!y||!g||!h||!u)continue;let d=g.x-y.x,f=g.y-y.y,l=u.x-h.x,p=u.y-h.y,x=l-d,b=p-f;c+=x*x+b*b;}return c}function FS(t,e,n){let s=_s(t),i=_s(e),r=[];for(let a of e.positions)s.has(a.id)&&(n&&!n.has(a.id)||r.push(a.id));let o=0;for(let a=0;a<r.length;a++){let c=i.get(r[a]),v=s.get(r[a]);for(let y=a+1;y<r.length;y++){let g=i.get(r[y]),h=s.get(r[y]),u=Math.hypot(g.x-c.x,g.y-c.y),d=Math.hypot(h.x-v.x,h.y-v.y),f=u-d;o+=f*f;}}return o}function GH(t){return t.length===0?null:t.reduce((e,n)=>e+n,0)/t.length}function zH(t,e,n){let s=_s(t),i=_s(e),r=[],o=[];for(let[y,g]of i){let h=s.get(y);if(!h)continue;let u=Math.hypot(g.x-h.x,g.y-h.y);n.has(y)?r.push(u):o.push(u);}let a=null;if(r.length>0&&o.length>0){let y=0;for(let g of r)for(let h of o)g>h?y+=1:g===h&&(y+=.5);a=y/(r.length*o.length);}let c=new Set,v=new Set;for(let[y]of i)s.has(y)&&(n.has(y)?c.add(y):v.add(y));return {auc:a,changedMeanDrift:GH(r),stableMeanDrift:GH(o),changedPositional:c.size>0?KS(t,e,c):null,stablePositional:v.size>0?KS(t,e,v):null,changedPairwiseDistance:c.size>=2?FS(t,e,c):null,stablePairwiseDistance:v.size>=2?FS(t,e,v):null,changedCount:r.length,stableCount:o.length}}function Yxt(t,e,n){let s=t.visualWidth??t.width??100,i=e.visualWidth??e.width??100,r=s/2+i/2+n,o=Math.min(Math.max(s,i)*.1,20);return r+o}function Wxt(t,e,n){let s=t.visualHeight??t.height??60,i=e.visualHeight??e.height??60,r=s/2+i/2+n,o=Math.min(Math.max(s,i)*.1,15);return r+o}function $H(t,e,n=5){let s=new Map(e.map(o=>[o.id,o])),i=0,r=0;for(let o of t)if(ii(o)){let a=s.get(o.left.id),c=s.get(o.right.id);if(!a||!c)continue;let v=Yxt(a,c,o.minDistance),y=(c.x??0)-(a.x??0);i+=1,y+n>=v&&(r+=1);}else if(ni(o)){let a=s.get(o.top.id),c=s.get(o.bottom.id);if(!a||!c)continue;let v=Wxt(a,c,o.minDistance),y=(c.y??0)-(a.y??0);i+=1,y+n>=v&&(r+=1);}else if(Fn(o)){let a=s.get(o.node1.id),c=s.get(o.node2.id);if(!a||!c)continue;let v=o.axis==="x"?a.x??0:a.y??0,y=o.axis==="x"?c.x??0:c.y??0;i+=1,Math.abs(v-y)<=n&&(r+=1);}return i===0?1:r/i}function VH(t,e,n=.5){let s=_s(t),i=_s(e),r=new Set;for(let[o,a]of i){let c=s.get(o);c&&Math.abs(a.x-c.x)<=n&&Math.abs(a.y-c.y)<=n&&r.add(o);}return r}function Xxt(t,e,n,s){if(t.x===n.x&&t.y===n.y||t.x===s.x&&t.y===s.y||e.x===n.x&&e.y===n.y||e.x===s.x&&e.y===s.y)return false;let i=(v,y,g)=>(y.x-v.x)*(g.y-v.y)-(y.y-v.y)*(g.x-v.x),r=i(n,s,t),o=i(n,s,e),a=i(t,e,n),c=i(t,e,s);return (r>0&&o<0||r<0&&o>0)&&(a>0&&c<0||a<0&&c>0)}function YH(t,e,n){let s=_s(t),i=_s(e),r=[];for(let[c]of i)s.has(c)&&(n&&!n.has(c)||r.push(c));if(r.sort(),r.length<2)return null;let o=0,a=0;for(let c=0;c<r.length;c++){let v=s.get(r[c]),y=i.get(r[c]);for(let g=c+1;g<r.length;g++){let h=s.get(r[g]),u=i.get(r[g]),d=v.x<h.x&&y.x<u.x||v.x>h.x&&y.x>u.x||v.x===h.x&&y.x===u.x,f=v.y<h.y&&y.y<u.y||v.y>h.y&&y.y>u.y||v.y===h.y&&y.y===u.y;d&&f&&(o+=1),a+=1;}}return a===0?null:o/a}function WH(t,e,n=3,s){let i=_s(t),r=_s(e),o=[];for(let[y]of r)i.has(y)&&(s&&!s.has(y)||o.push(y));if(o.sort(),o.length<n+1)return null;let a=(y,g)=>{let h=y.get(g),u=[];for(let d of o){if(d===g)continue;let f=y.get(d);u.push({id:d,d:Math.hypot(f.x-h.x,f.y-h.y)});}return u.sort((d,f)=>d.d-f.d||d.id.localeCompare(f.id)),new Set(u.slice(0,n).map(d=>d.id))},c=0,v=0;for(let y of o){let g=a(i,y),h=a(r,y),u=new Set([...g,...h]);if(u.size===0)continue;let d=0;for(let f of g)h.has(f)&&(d+=1);c+=d/u.size,v+=1;}return v===0?null:c/v}function BS(t,e){let n=_s(t),s=[];for(let r of e){let o=n.get(r.source),a=n.get(r.target);!o||!a||s.push({a:o,b:a});}let i=0;for(let r=0;r<s.length;r++)for(let o=r+1;o<s.length;o++)Xxt(s[r].a,s[r].b,s[o].a,s[o].b)&&(i+=1);return i}function XH(t,e,n,s){return Math.abs(BS(n,s)-BS(t,e))}function QH(t,e,n){let s=_s(t),i=_s(e),r=0,o=0,a=0;for(let c of n){let v=s.get(c),y=i.get(c);if(!v||!y)continue;let g=y.x-v.x,h=y.y-v.y,u=Math.hypot(g,h);u!==0&&(r+=g/u,o+=h/u,a+=1);}return a===0?null:Math.hypot(r,o)/a}function JH(t,e,n,s=5){let i=_s(t),r=_s(e),o=0,a=0;for(let c of n){let v=i.get(c),y=r.get(c);!v||!y||(o+=1,Math.hypot(y.x-v.x,y.y-v.y)<=s&&(a+=1));}return o===0?null:a/o}function ZH(t,e){if(t.positions.length===0)return 0;let n=MS(t,e),s=new Map(n.positions.map(r=>[r.id,r])),i=0;for(let r of t.positions){let o=s.get(r.id);o&&(i+=Math.hypot(o.x-r.x,o.y-r.y));}return i}var UR="2026-09-18",jR={note:"`languageVersion` is the date the language last changed (YYYY-MM-DD). If it has not moved since the manifest you generated against, nothing you emit needs revisiting. `spytialCoreVersion` records which release produced this file.",deprecations:"A deprecated form keeps parsing and keeps its meaning while it is listed in `deprecations`, and each entry names its replacement and the rewrite to apply. Removal is signalled by `languageVersion` moving, not by the `spytialCoreVersion` major: a removed form leaves this manifest and becomes a parse error, so check `languageVersion` before assuming a spec you generated earlier still parses."},Qxt={name:"textStyle",description:"Styling for a label. Reused by every form that renders text \u2014 an atom's own label, attribute and tag lines, edge labels, and a group label.",fields:[{name:"size",type:"enum",values:["small","normal","large"],enforcement:"value-ignored",default:"normal",description:"Font-size tier relative to the node label: `large` renders bigger than the label, `normal` smaller, `small` smaller still."},{name:"color",type:"color",description:"Any CSS color. Unset inherits the node label color, so dark mode still adapts."}]},Jxt={name:"lineStyle",description:"Styling for an edge's drawn line. Reused by edgeStyle, inferredEdge, and a group's addEdge connector.",fields:[{name:"color",type:"color",description:"Any CSS color."},{name:"pattern",type:"enum",values:["solid","dashed","dotted"],enforcement:"value-ignored",description:"Dash pattern of the line."},{name:"weight",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Line thickness in pixels. Must be > 0; a non-positive or non-numeric weight is dropped."},{name:"highlight",type:"color",description:"A wider, translucent underlay drawn beneath the line. Orthogonal to color and pattern."}]},Zxt={name:"fillStyle",description:"An atom's interior fill. Opt-in: the default look is unfilled, with only the border and label marking the node.",fields:[{name:"color",type:"color",description:"Any CSS color."}]},t_t={name:"borderStyle",description:"An atom's outline.",fields:[{name:"color",type:"color",description:"Any CSS color."},{name:"width",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Outline thickness in pixels. Must be > 0; anything else is dropped."}]},e_t={name:"iconStyle",description:"An icon drawn on an atom. Every leaf is optional, including `path`, so a supertype rule can supply the icon and a subtype rule tune only its opacity.",fields:[{name:"path",type:"icon-path",description:"A bundled icon name (`person`), an icon-pack reference (`bi:person-fill`), a URL, or a path. Resolved to a concrete URL or data URI at parse time. An iconStyle with no path draws nothing."},{name:"placement",type:"enum",values:["full","badge"],enforcement:"value-ignored",default:"full",description:"`full` \u2014 the icon occupies the box, which stays transparent unless a fillStyle.color is given. `badge` \u2014 a small marker in the top-right corner, secondary to the label."},{name:"opacity",type:"number",minimum:0,maximum:1,enforcement:"value-ignored",default:1,description:"Alpha in [0,1]. Out-of-range values are dropped rather than clamped. Fade a `full` icon to use it as a watermark behind the label."}]},tG=[Qxt,Jxt,Zxt,t_t,e_t],Vu=(t,e)=>({name:t,type:"block",block:t,description:e}),Uy=t=>[{arity:"unary",minColumns:1,maxColumns:1,meaning:t}],r_t={arity:"binary",minColumns:2,maxColumns:2,meaning:"Each tuple is one (first, last) pair, and the constraint applies to it."},n_t={arity:"n-ary",minColumns:3,meaning:"Accepted: the pair is the tuple's first and last atom. The columns between are ignored."},HR=[r_t,n_t],US={name:"selector",type:"selector",arity:"unary",accepts:Uy("The set of source atoms the directive is narrowed to."),description:"Apply only to edges whose source atom is in this set. Omit to apply to every source atom."},jS={name:"filter",type:"selector",arity:"n-ary",accepts:[{arity:"n-ary",minColumns:2,meaning:"A tuple matches on its first and last atom, so a longer tuple filters the same relation ends a pair would. A unary result matches nothing \u2014 the directive is then scoped to no tuples at all."}],description:"Apply only to the (source, target, \u2026) tuples this selector returns. Use it to scope a directive to part of a relation, e.g. only the tuples whose value is True."},i_t={id:"orientation",yamlKey:"orientation",label:"Orientation",description:"Place the two ends of each selected tuple relative to one another.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:"Returns (source, target) pairs. The constraint applies to each pair."},{name:"directions",type:"enum-list",values:["above","below","left","right","directlyAbove","directlyBelow","directlyLeft","directlyRight"],required:true,enforcement:"parse-error",listRules:{atMostOneOf:[["above","below"],["left","right"]],narrowsListTo:{directlyAbove:["above","directlyAbove"],directlyBelow:["below","directlyBelow"],directlyLeft:["left","directlyLeft"],directlyRight:["right","directlyRight"]}},description:"Where the TARGET sits relative to the SOURCE. `directions: [above]` on selector `parent` places each tuple's target above its source. The `directly*` variants additionally enforce axis alignment.",note:"The direction is target-relative-to-source. Getting this backwards is the most common spec bug \u2014 transpose the selector (`~parent`) rather than flipping the direction if the relation reads the other way."}],example:{selector:"parent",directions:["above"]},note:"Contradictory direction sets are rejected at parse time: `above` with `below`, `left` with `right`, and a `directly*` variant combined with anything other than its own non-direct counterpart. Values outside the listed set are NOT rejected \u2014 they parse and then match nothing."},o_t={id:"cyclic",yamlKey:"cyclic",label:"Cyclic",description:"Arrange the selected atoms around the perimeter of a circle, in the order the selector defines.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:'Returns (a, b) pairs meaning "b follows a around the circle".'},{name:"direction",type:"enum",values:["clockwise","counterclockwise"],default:"clockwise",enforcement:"unchecked",description:"Which way the cycle runs."}],example:{selector:"nextState",direction:"clockwise"},note:"Two cyclic constraints on the same selector with different directions is a parse error. An unrecognized direction string is not rejected at parse time."},s_t={id:"align",yamlKey:"align",label:"Align",description:"Put the selected atoms on a shared horizontal or vertical line.",sections:["constraints"],valueShape:"mapping",supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:HR,required:true,enforcement:"parse-error",description:"Returns the pairs of atoms to align with one another."},{name:"direction",type:"enum",values:["horizontal","vertical"],required:true,enforcement:"parse-error",description:"`horizontal` gives the atoms a shared Y coordinate; `vertical` a shared X coordinate. An unrecognized value is a parse error."}],example:{selector:"siblings",direction:"horizontal"}},a_t={id:"group",yamlKey:"group",label:"Group (by selector)",description:"Draw a hull around a set of atoms. For tuples (a, b), (a, c), \u2026 the group is keyed by `a` and contains {b, c, \u2026}.",sections:["constraints"],valueShape:"mapping",discriminator:{field:"field",present:false},supportsHold:true,fields:[{name:"selector",type:"selector",arity:"binary",accepts:[{arity:"binary",minColumns:2,maxColumns:2,meaning:"One group per distinct first atom: the first column is the key, the last the members. The group is named `<name>[<key>]`, which is what a keyed `inferredEdge` `draw` end attaches to."},{arity:"n-ary",minColumns:3,meaning:"As binary \u2014 the key is the tuple's first atom and the member its last, ignoring the columns between."},{arity:"unary",minColumns:1,maxColumns:1,meaning:"One single group holding every selected atom, with no key. It is named `<name>` with no `[key]` suffix, and a `draw` end naming it attaches there whatever the end's atom is."}],required:true,enforcement:"unchecked",description:"First column is the group key, second the members. A unary selector builds a single unkeyed group.",note:"A `group` with neither `selector` nor `field` is silently dropped \u2014 it matches neither grouping form. That is the one case where omitting this field is not an error but a no-op."},{name:"name",type:"string",required:true,enforcement:"parse-error",description:"Display name on the group, and the handle an `inferredEdge` `draw` endpoint refers to. Required unless the constraint is negated (`hold: never`), where a name is generated."},{name:"addEdge",type:"enum",values:["none","togroup","fromgroup"],default:"none",enforcement:"value-ignored",description:"Draw a connector between the group key and the group: `togroup` points key \u2192 group, `fromgroup` points group \u2192 key, `none` draws nothing.",alternativeForm:{type:"block",description:"Block form also styles the connector, which is an edge and so takes the shared edge blocks: `{ points: <direction>, lineStyle: {\u2026}, textStyle: {\u2026} }`.",fields:[{name:"points",type:"enum",values:["none","togroup","fromgroup"],default:"none",description:"The connector direction \u2014 the same value the bare string form carries."},Vu("lineStyle","The connector's line."),Vu("textStyle","The connector's label.")]},note:"The legacy boolean `true` is still accepted and means `togroup`."},Vu("textStyle","The group's own label. Only `color` applies today \u2014 group labels auto-fit their box, so `size` is reserved.")],example:{selector:"Team.members",name:"Team"}},u_t={id:"size",yamlKey:"size",label:"Size",description:"Set the width and height of matching nodes, in pixels.",sections:["constraints"],deprecatedSections:["directives"],sectionDeprecation:{reason:"Size fixes a node's geometry, which is what the layout solves over \u2014 not presentation layered on a solved layout. It is a constraint. The directives section still accepts it, identically, behind a deprecation warning.",warningSpecType:"size"},valueShape:"mapping",supportsHold:false,fields:[{name:"width",type:"number",required:true,enforcement:"parse-error",exclusiveMinimum:0,description:"Node width in pixels. Required, and must be a number greater than 0."},{name:"height",type:"number",required:true,enforcement:"parse-error",exclusiveMinimum:0,description:"Node height in pixels. Required, and must be a number greater than 0."},{name:"selector",type:"selector",arity:"unary",accepts:Uy("The nodes to resize."),description:"Which nodes to resize. Omit to resize every node."}],example:{selector:"ImportantNode",width:150,height:80},note:"`hold: never` is not supported and is silently ignored."},l_t={id:"hideAtom",yamlKey:"hideAtom",label:"Hide atom",description:"Remove matching atoms from the diagram.",sections:["constraints"],deprecatedSections:["directives"],sectionDeprecation:{reason:"Hiding an atom changes what the layout has to place, and can make a spec unsatisfiable against the other constraints \u2014 it is a constraint, not presentation. The directives section still accepts it, identically, behind a deprecation warning.",warningSpecType:"hideAtom"},valueShape:"mapping",supportsHold:false,fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms to hide."),required:true,enforcement:"unchecked",description:"Which atoms to hide."}],example:{selector:"HelperNode"},note:"`hold: never` is not supported and is silently ignored. Hiding an atom that a layout constraint places, or that a group contains, makes the spec unsatisfiable: the layout reports a hidden-node conflict and draws a counterfactual with the conflicting atoms outlined. Hiding a keyed group's key is fine \u2014 the key is not inside the group."},c_t={id:"flag",yamlKey:"flag",label:"Flag",description:"Toggle a whole-diagram rendering behaviour.",sections:["directives"],valueShape:"scalar",supportsHold:false,fields:[{name:"flag",type:"enum",values:["hideDisconnected","hideDisconnectedBuiltIns"],required:true,enforcement:"unchecked",description:"`hideDisconnected` hides every atom with no edges; `hideDisconnectedBuiltIns` hides only the disconnected built-in atoms (Int, String, \u2026). Any other value is silently ignored."}],example:{flag:"hideDisconnectedBuiltIns"},note:"Written as a bare scalar: `- flag: hideDisconnected`, not a mapping."},h_t={id:"atomStyle",yamlKey:"atomStyle",label:"Atom style",description:"Style matching atoms. An atom is a composite of an interior fill, an outline, an icon, and its label, so each is its own block.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms this rule styles."),description:"Which atoms to style. Omit to style every atom."},Vu("fillStyle","The node's interior fill."),Vu("borderStyle","The node's outline."),Vu("iconStyle","An icon drawn on the node."),Vu("textStyle","The node's own label."),{name:"showLabel",type:"boolean",default:true,description:"Whether the atom's label is drawn. Independent of the icon: `iconStyle.placement` controls the icon's geometry, this controls the label."}],example:{selector:"Person",borderStyle:{color:"#0369a1"}},note:"Rules compose: a supertype selector already returns subtype atoms, so a `Node` rule and a `RedNode` rule both apply to a RedNode atom and their set properties gap-fill each other. Two rules setting the SAME property to DIFFERENT values is a hard error at layout time \u2014 styles never silently override."},f_t={id:"edgeStyle",yamlKey:"edgeStyle",label:"Edge style",description:"Style the edges of a relation: the drawn line, the label, and visibility.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation whose edges this styles."},US,jS,Vu("lineStyle","The drawn line."),Vu("textStyle","The edge label."),{name:"showLabel",type:"boolean",default:true,description:"Whether the edge label is drawn."},{name:"hidden",type:"boolean",default:false,description:"Hide the edge entirely while keeping the relation in the data."}],example:{field:"parent",lineStyle:{color:"blue",pattern:"dashed"}},note:"Like atomStyle, overlapping rules compose and a genuine disagreement is an error rather than a silent override."},p_t={id:"attribute",yamlKey:"attribute",label:"Attribute",description:"Render a relation as a key-value line on its source node instead of as an edge.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation to fold into the source node. Its edges are removed from the graph."},{...US,description:"Apply only to these source atoms. Omit to apply to every source atom."},jS,Vu("textStyle","This attribute line's own styling.")],example:{field:"age",selector:"Person"},note:"Multiple targets for the same source become a list. Unlike `tag`, this removes the edge."},d_t={id:"tag",yamlKey:"tag",label:"Tag",description:"Add a computed key-value line to matching nodes, without touching the graph structure.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"toTag",type:"selector",arity:"unary",accepts:Uy("The atoms that receive the tag."),required:true,enforcement:"unchecked",description:"Which atoms receive the tag."},{name:"name",type:"string",required:true,enforcement:"unchecked",description:"The literal label shown before the value; this field is not a selector."},{name:"value",type:"selector",arity:"n-ary",accepts:[{arity:"n-ary",minColumns:2,meaning:"One line per tuple whose first atom is the tagged atom: the last column is the value and any columns between become one comma-separated key tuple, as `name[k1,k2]: value`. A binary result is the plain `name: value` case."},{arity:"unary",minColumns:1,maxColumns:1,meaning:'A membership tag: an atom in the result is tagged with its own label, as `name: <label>`. The value carries no more than "this atom is in the set".'}],required:true,enforcement:"unchecked",description:"Evaluated once; each tuple is attached to the tagged atom in its first column. A binary result shows as `name: value`; a longer tuple shows one line per tuple, as `name[k1,k2]: value`. A unary result tags each selected atom with its own label."},Vu("textStyle","This tag line's own styling.")],example:{toTag:"Person",name:"age",value:"age"},note:"Unlike `attribute`, tags do not remove edges."},g_t={id:"hideField",yamlKey:"hideField",label:"Hide field",description:"Hide a relation's edges.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation to hide."},US,{...jS,description:"Hide only the tuples this selector returns."}],example:{field:"internal"}},y_t={id:"inferredEdge",yamlKey:"inferredEdge",label:"Inferred edge",description:"Draw an edge that is not in the data, computed from a selector.",sections:["directives"],valueShape:"mapping",supportsHold:false,fields:[{name:"name",type:"string",required:true,enforcement:"unchecked",description:"The label drawn on the edge."},{name:"selector",type:"selector",arity:"binary",accepts:[{arity:"binary",minColumns:2,maxColumns:2,meaning:"One edge per tuple, from its first atom to its last."},{arity:"n-ary",minColumns:3,meaning:"One edge from the tuple's first atom to its last. Unlike the constraints, the columns between are not discarded: their labels are appended to the edge label as `<name>[m1,m2]`."},{arity:"unary",minColumns:1,maxColumns:1,requires:"draw",meaning:"One edge per atom, the atom feeding both ends \u2014 the shape `draw: _ -> <group>` needs, connecting each atom to its own group. Without `draw` a unary selector draws nothing at all: the engine reads this field as tuples, and single-atom tuples are dropped before any edge is made."}],required:true,enforcement:"unchecked",description:"Returns the (source, target) pairs to connect. May be unary when `draw` is given \u2014 the single atom then feeds both ends."},{name:"draw",type:"string",enforcement:"parse-error",pattern:"^\\s*[^\\s](?:(?!->)[\\s\\S])*->(?:(?!->)[\\s\\S])*[^\\s]\\s*$",description:"Reinterpret what each end attaches to, as `<end> -> <end>`. Each end is `_` (the atom itself, the default) or the name of a `group` constraint, in which case the end attaches to that group's hull. The left end applies to the first atom of each tuple, the right end to the last.",note:"Parsed strictly: a value that is not a string, or that does not contain exactly one `->`, is a parse error. A group name that no `group` constraint defines is not \u2014 it raises a warning (code `unresolved-reference`, specType `inferredEdge`) and the edge is skipped at layout time, so a fragment that names a group defined in another fragment still parses. `draw` never reorders \u2014 transpose the selector (`~connected`) to flip an edge."},Vu("lineStyle","The drawn line."),Vu("textStyle","The edge label."),{name:"color",type:"color",description:"Legacy inline line color.",deprecated:{replacedBy:"lineStyle.color"}},{name:"style",type:"enum",values:["solid","dashed","dotted"],description:"Legacy inline dash pattern.",deprecated:{replacedBy:"lineStyle.pattern"}},{name:"weight",type:"number",exclusiveMinimum:0,description:"Legacy inline line thickness.",deprecated:{replacedBy:"lineStyle.weight"}},{name:"highlight",type:"color",description:"Legacy inline highlight underlay.",deprecated:{replacedBy:"lineStyle.highlight"}}],example:{name:"reachable",selector:"^parent",lineStyle:{color:"gray",pattern:"dotted"}},note:"Using any of the legacy inline `color`/`style`/`weight`/`highlight` keys raises a deprecation warning with specType `inferredEdge`. The block form wins when both are given. If an end's atom keys no group of that name in a given instance, that one edge is skipped with a console warning \u2014 data-dependent, not a spec error."},m_t={id:"icon",yamlKey:"icon",label:"Icon",description:"Assign an icon to matching atoms.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"atomStyle",reason:"The single `showLabels` boolean drove label visibility and icon geometry at once. atomStyle splits those into two independent knobs, which is what makes a faded watermark, or a hidden label with no icon, expressible.",mapping:{path:"iconStyle.path",selector:"selector","showLabels: false":"showLabel: false + iconStyle.placement: full","showLabels: true":"showLabel: true + iconStyle.placement: badge"},warningSpecType:"icon"},fields:[{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms that get the icon."),required:true,enforcement:"unchecked",description:'Which atoms get the icon. Omitting it drops the directive entirely \u2014 it never means "every atom".'},{name:"path",type:"icon-path",required:true,enforcement:"unchecked",description:"Bundled name, icon-pack reference, URL, or path. Omitting it drops the directive."},{name:"showLabels",type:"boolean",default:false,description:"Whether the atom's label is drawn alongside the icon."}],example:{selector:"Person",path:"person",showLabels:true}},v_t={id:"atomColor",yamlKey:"atomColor",label:"Atom color",description:"Set the color of matching atoms.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"atomStyle",reason:"atomStyle expresses the same recolor and also reaches the fill, the icon, and the label. The rewrite is border-preserving, so an existing diagram is unchanged.",mapping:{value:"borderStyle.color",selector:"selector"},warningSpecType:"atomColor"},fields:[{name:"value",type:"color",required:true,enforcement:"unchecked",description:"Any CSS color. Applies to the node's outline, not its fill."},{name:"selector",type:"selector",arity:"unary",accepts:Uy("The atoms to recolor."),required:true,enforcement:"unchecked",description:'Which atoms to recolor. Omitting it drops the directive \u2014 it never means "every atom".'}],example:{selector:"Person",value:"#ff5733"}},x_t={id:"edgeColor",yamlKey:"edgeColor",label:"Edge color",description:"Style a relation's edges with flat, inline keys.",sections:["directives"],valueShape:"mapping",supportsHold:false,deprecated:{replacedBy:"edgeStyle",reason:"edgeStyle groups the same knobs into the shared lineStyle/textStyle blocks that every other form uses.",mapping:{value:"lineStyle.color",style:"lineStyle.pattern",weight:"lineStyle.weight",highlight:"lineStyle.highlight",field:"field",selector:"selector",filter:"filter",showLabel:"showLabel",hidden:"hidden"},warningSpecType:"edgeColor"},fields:[{name:"field",type:"relation",required:true,enforcement:"unchecked",description:"The relation whose edges this styles."},{name:"value",type:"color",required:true,enforcement:"unchecked",description:"Line color."},US,jS,{name:"style",type:"enum",values:["solid","dashed","dotted"],enforcement:"value-ignored",description:"Dash pattern. Trimmed and lowercased before matching, unlike `lineStyle.pattern`."},{name:"weight",type:"number",exclusiveMinimum:0,enforcement:"value-ignored",description:"Line thickness in pixels."},{name:"highlight",type:"color",description:"A wider, translucent underlay beneath the line."},{name:"showLabel",type:"boolean",default:true,description:"Whether the edge label is drawn."},{name:"hidden",type:"boolean",default:false,description:"Hide the edge entirely."}],example:{field:"parent",value:"blue"}},zd=[i_t,o_t,s_t,a_t,u_t,l_t,c_t,h_t,f_t,p_t,d_t,g_t,y_t,m_t,v_t,x_t],__t={field:"source",fields:[{name:"text",type:"string",required:true,enforcement:"value-ignored",description:"The rule exactly as its author wrote it in the host surface \u2014 a Python decorator, a Rust attribute, a Forge annotation. Shown (escaped, as code) in conflict reports and warnings in place of the engine\u2019s own description of the rule. A missing or empty `text` makes the whole `source` block ignored."},{name:"location",type:"string",description:"Where the rule was written, e.g. `tree.py:12`. Appended to the displayed text."}],supportedBy:zd.filter(t=>t.valueShape!=="scalar").map(t=>t.id),displayedBy:["orientation","cyclic","align","group","hideAtom"],note:"For generators only \u2014 hand-written YAML needs no `source`, because there the YAML is the author\u2019s text. Accepted on every block-bodied item so a generator can stamp it uniformly. The engine carries and displays it for the forms that appear in conflict reports (the `displayedBy` list: the layout constraints and `hideAtom`); on the rest it parses and is ignored. Duplicate rules de-duplicate to one entry, which keeps the first provided source."},b_t={field:"hold",values:["always","never"],default:"always",supportedBy:zd.filter(t=>t.supportsHold).map(t=>t.id),note:"`hold: never` negates a constraint: it asserts the relationship must not hold. Only the value `never` has an effect \u2014 `always`, any other string, and an absent field all mean the positive constraint. Double negation is not supported. `size` and `hideAtom` accept the key syntactically but ignore it."},T_t={sections:["constraints","directives"],unknownKeys:"ignored",sectionShape:"list",notes:["Both sections are optional; an empty document is valid and yields an empty spec.","Each section must be a YAML list of single-key mappings. A section written as a mapping instead of a list is ignored wholesale, without an error.","Unrecognized top-level keys, unrecognized list items, and unrecognized fields inside a known item are all ignored silently. Nothing in the parser will tell you about a typo \u2014 validate against this manifest first.","`size` and `hideAtom` are constraints. Both are still accepted among the directives, with identical meaning, but that placement is deprecated and warns \u2014 emit them under `constraints`. Each item lists where to write it in `sections`, and any tolerated-but-deprecated placement in `deprecatedSections`.","Duplicate constraints (same selector and same parameters) are de-duplicated at parse time.","Parsing returns advisory `warnings` alongside the spec. Each carries a `code` (currently `deprecated`) and a `specType` naming the form, so a consumer can surface them without matching prose.","Every block-bodied item accepts an optional `source` block carrying the rule as its author wrote it in the host surface; conflict reports cite that text instead of the engine\u2019s own rendering. See the top-level `source` entry for the block\u2019s shape and which items display it.","The old group-by-field shape, `group: { field, groupOn, addToGroup }`, is removed. It is a parse error, not a silently ignored key, so an old spec fails loudly instead of losing its grouping. Write a `group` whose binary `selector` has the key in its first column and the members in its second; over `worksIn: Employee -> Department`, `groupOn: 1` / `addToGroup: 0` becomes `selector: ~worksIn` plus a `name`, and `groupOn: 0` / `addToGroup: 1` becomes `selector: worksIn`."]},E_t=[...zd.filter(t=>t.deprecated).map(t=>({id:t.id,kind:"item",path:t.yamlKey,...t.deprecated})),...zd.filter(t=>t.deprecatedSections?.length).flatMap(t=>t.deprecatedSections.map(e=>({id:`${t.id}@${e}`,kind:"placement",path:`${e}[].${t.yamlKey}`,replacedBy:`${t.sections[0]}[].${t.yamlKey}`,reason:t.sectionDeprecation.reason,mapping:{[`${e}[].${t.yamlKey}`]:`${t.sections[0]}[].${t.yamlKey}`},warningSpecType:t.sectionDeprecation.warningSpecType}))),...zd.flatMap(t=>t.fields.filter(e=>e.deprecated).map(e=>({id:`${t.id}.${e.name}`,kind:"field",path:`${t.yamlKey}.${e.name}`,replacedBy:`${t.yamlKey}.${e.deprecated.replacedBy}`,reason:e.deprecated.reason??`Superseded by ${e.deprecated.replacedBy}.`,mapping:{[e.name]:e.deprecated.replacedBy},warningSpecType:t.yamlKey})))],S_t={reference:"https://github.com/sidprasad/spytial-core/blob/main/docs/YAML_SPECIFICATION.md",constraints:"https://sidprasad.github.io/spytial-core/#/constraints",directives:"https://sidprasad.github.io/spytial-core/#/directives",selectors:"https://sidprasad.github.io/spytial-core/#/selectors",jsonSchema:"https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@main/docs/spytial-spec.schema.json",manifest:"https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@main/docs/spytial-language.json"};function eG(t){return {language:"spytial-layout-spec",languageVersion:UR,spytialCoreVersion:t,versioning:jR,document:T_t,hold:b_t,source:__t,blocks:tG,items:zd,deprecations:E_t,documentation:S_t}}function rG(){return zd}function nG(t){return zd.find(e=>e.id===t)}function iG(){return tG}var O_t="https://json-schema.org/draft/2020-12/schema",A_t=t=>`urn:spytial:layout-spec-schema:${t}`,oG={selector:"string",relation:"string",string:"string",color:"string","icon-path":"string",number:"number",integer:"integer",boolean:"boolean"};function sG(t){let e=[t.description];if(t.arity){let n=a=>a.maxColumns===void 0?`${a.minColumns}+ columns`:a.maxColumns===1?"1 column":`${a.maxColumns} columns`,s=t.accepts??[],i=s.find(a=>a.arity===t.arity),r=s.filter(a=>a!==i),o=i?`${t.arity} \u2014 ${n(i)}`:t.arity;e.push(r.length>0?`Selector arity: ${o} (also accepted: ${r.map(a=>a.requires?`${n(a)}, with \`${a.requires}\``:n(a)).join("; ")}).`:`Selector arity: ${o}.`);}return t.default!==void 0&&e.push(`Default when omitted: ${JSON.stringify(t.default)}.`),t.deprecated&&e.push(`Deprecated \u2014 use \`${t.deprecated.replacedBy}\` instead.`),t.note&&e.push(t.note),e.join(" ")}function uG(t){let e={description:sG(t)};switch(t.deprecated&&(e.deprecated=true),t.type){case "enum":e.type="string",e.enum=[...t.values??[]];break;case "enum-list":{e.type="array",e.minItems=1,e.items={type:"string",enum:[...t.values??[]]};let n=[];for(let s of t.listRules?.atMostOneOf??[])n.push({not:{allOf:s.map(i=>({contains:{const:i}}))},description:`At most one of: ${s.join(", ")}.`});for(let[s,i]of Object.entries(t.listRules?.narrowsListTo??{}))n.push({if:{contains:{const:s}},then:{items:{enum:[...i]}},description:`With \`${s}\`, the only other value allowed is ${i.filter(r=>r!==s).join(", ")}.`});n.length>0&&(e.allOf=n);break}case "block":t.block?e.$ref=`#/$defs/${t.block}`:Object.assign(e,Qb(t.fields??[]));break;default:{let n=oG[t.type];n&&(e.type=n),n==="string"&&t.required&&(e.minLength=1),t.pattern!==void 0&&(e.pattern=t.pattern);break}}if(t.exclusiveMinimum!==void 0&&(e.exclusiveMinimum=t.exclusiveMinimum),t.minimum!==void 0&&(e.minimum=t.minimum),t.maximum!==void 0&&(e.maximum=t.maximum),t.alternativeForm){let n={...e};delete n.description;let s=t.alternativeForm.type==="block"?{...Qb(t.alternativeForm.fields??[]),description:t.alternativeForm.description}:{type:oG[t.alternativeForm.type]??"string"};return {description:sG(t),oneOf:[n,s,{const:true,deprecated:true,description:"Legacy spelling of `togroup`."}]}}return e}function Qb(t){let e={};for(let i of t)e[i.name]=uG(i);let n=t.filter(i=>i.required).map(i=>i.name),s={type:"object",properties:e,additionalProperties:false};return n.length>0&&(s.required=n),s}function w_t(t,e){let n=Qb(t.fields);if(t.supportsHold&&(n.properties.hold={type:"string",enum:["always","never"],description:"Negation. `never` asserts the constraint must not hold; `always` (the default) is the positive form."}),e.source.supportedBy.includes(t.id)&&(n.properties.source={$ref:"#/$defs/source",description:e.source.displayedBy.includes(t.id)?"The rule as its author wrote it in the host surface. Cited in conflict reports in place of the engine\u2019s own rendering.":"The rule as its author wrote it in the host surface. Accepted here for uniform generation; not displayed for this item today."}),t.discriminator)if(t.discriminator.present){let s=new Set([...n.required??[],t.discriminator.field]);n.required=[...s];}else n.not={required:[t.discriminator.field]};return t.id==="group"&&(n.required=(n.required??[]).filter(s=>s!=="name"),n.required.length===0&&delete n.required,n.allOf=[{if:{not:{properties:{hold:{const:"never"}},required:["hold"]}},then:{required:["name"]}}]),n}function C_t(t,e){let n=t.valueShape==="scalar"?uG(t.fields[0]):w_t(t,e),s={title:t.label,description:t.deprecated?`${t.description} DEPRECATED \u2014 use \`${t.deprecated.replacedBy}\` instead. ${t.deprecated.reason}`:t.description,type:"object",properties:{[t.yamlKey]:n},required:[t.yamlKey],additionalProperties:false};return t.deprecated&&(s.deprecated=true),s}function aG(t,e){let n=t.items.filter(i=>i.sections.includes(e)),s=t.items.filter(i=>i.deprecatedSections?.includes(e));return {type:["array","null"],description:e==="constraints"?"Structural layout: where nodes end up relative to one another.":"Presentation: how nodes and edges look, and what is shown at all.",items:{oneOf:[...n.map(i=>({$ref:`#/$defs/${GR(i)}`})),...s.map(i=>({$ref:`#/$defs/${GR(i)}`,deprecated:true,description:`\`${i.yamlKey}\` here is deprecated \u2014 write it under \`${i.sections[0]}\`. ${i.sectionDeprecation.reason}`}))]}}}function GR(t){return t.id.replace(/\./g,"_")}function lG(t){let e={};for(let n of t.blocks)e[n.name]={description:n.description,...Qb(n.fields)};e.source={description:t.source.note,...Qb(t.source.fields)};for(let n of t.items)e[GR(n)]=C_t(n,t);return {$schema:O_t,$id:A_t(t.languageVersion),title:"Spytial layout specification",description:`A Spytial spec: constraints (structural layout) and directives (presentation). Spec language ${t.languageVersion}, from spytial-core ${t.spytialCoreVersion}. This schema is stricter than the engine parser, which silently ignores anything it does not recognize \u2014 validating here is how a misspelled key or an out-of-range value gets caught at all. Fetch it from https://cdn.jsdelivr.net/gh/sidprasad/spytial-core@<tag>/docs/spytial-spec.schema.json; pin a tag, since the @main path is overwritten each release.`,"x-spytial-language-version":t.languageVersion,"x-spytial-core-version":t.spytialCoreVersion,type:"object",properties:{constraints:aG(t,"constraints"),directives:aG(t,"directives")},additionalProperties:false,$defs:e}}var N_t=zR.default??zR,R_t=$R.default??$R;if(typeof window<"u"){let t=window;t.d3||(t.d3=N_t),t.cola||(t.cola=R_t),Promise.resolve().then(()=>(cS(),ej)).then(({WebColaCnDGraph:e})=>(typeof customElements<"u"&&!customElements.get("webcola-cnd-graph")&&customElements.define("webcola-cnd-graph",e),Promise.resolve().then(()=>($N(),nj)).then(({StructuredInputGraph:n})=>{typeof customElements<"u"&&!customElements.get("structured-input-graph")&&customElements.define("structured-input-graph",n);}))).catch(console.error);}var L_t="6.1.0",qR=class{constructor(e={}){this.config={debug:false,version:L_t,...e};}init(){this.config.debug;}getConfig(){return {...this.config}}updateConfig(e){this.config={...this.config,...e};}},d8t=t=>new qR(t);/*! Bundled license information:
|
|
1639
1639
|
|
|
1640
1640
|
forge-expr-evaluator/dist/forge-expr-evaluator.bundle.js:
|
|
1641
1641
|
(*! For license information please see forge-expr-evaluator.bundle.js.LICENSE.txt *)
|