@markgrafhq/markgraf-embed 0.1.25 → 0.1.26

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.

Potentially problematic release.


This version of @markgrafhq/markgraf-embed might be problematic. Click here for more details.

@@ -1,40 +1,40 @@
1
- var kG=(function(hc){"use strict";function Om(t){let e=0,n;return()=>{if(e===2)return n;if(e===1)throw new Error("Binding demanded before initialized");return e=1,n=t(),e=2,n}}function g(){throw new Error("Failed pattern match")}function Jr(t,e){return e>0?Math.floor(t/e):e<0?-Math.floor(t/-e):0}const Xe=t=>e=>t,V=function(t){return function(e){for(var n=e.length,r=new Array(n),o=0;o<n;o++)r[o]=t(e[o]);return r}},qm={map:V},k1=t=>t,Et=typeof Array.prototype.flatMap=="function"?function(t){return function(e){return t.flatMap(e)}}:function(t){return function(e){for(var n=[],r=t.length,o=0;o<r;o++)for(var i=e(t[o]),a=i.length,s=0;s<a;s++)n.push(i[s]);return n}},Vm=function(t){return function(e){return{}.hasOwnProperty.call(e,t)}},$m=function(t){return function(e){return e[t]}},ae=function(t){return t.toString()},Po=function(t){var e=t.toString();return isNaN(e+".0")?e:e+".0"},Um=function(t){var e=t.length;return'"'+t.replace(/[\0-\x1F\x7F"\\]/g,function(n,r){switch(n){case'"':case"\\":return"\\"+n;case"\x07":return"\\a";case"\b":return"\\b";case"\f":return"\\f";case`
2
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";case"\v":return"\\v"}var o=r+1,i=o<e&&t[o]>="0"&&t[o]<="9"?"\\&":"";return"\\"+n.charCodeAt(0).toString(10)+i})+'"'},pc=t=>t,Be=pc("LT"),Me=pc("GT"),nn=pc("EQ"),J=(t,e)=>({tag:t,_1:e}),T=J("Nothing"),Vt=t=>J("Just",t),L1=t=>{if(t.tag==="Nothing")return!0;if(t.tag==="Just")return!1;g()},S1=t=>{if(t.tag==="Nothing")return!1;if(t.tag==="Just")return!0;g()},Dt=(t,e)=>({tag:t,_1:e}),Xm=t=>Dt("Right",t),Ym={map:t=>e=>{if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",t(e._1));g()}},E1={apply:t=>e=>{if(t.tag==="Left")return Dt("Left",t._1);if(t.tag==="Right"){if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",t._1(e._1))}g()},Functor0:()=>Ym},Km={bind:t=>{if(t.tag==="Left"){const e=t._1;return n=>Dt("Left",e)}if(t.tag==="Right"){const e=t._1;return n=>n(e)}g()},Apply0:()=>E1},jm={pure:Xm,Apply0:()=>E1},P1={Applicative0:()=>jm,Bind1:()=>Km},Zm=t=>t,t2={map:t=>e=>t(e)},G1={apply:t=>e=>t(e),Functor0:()=>t2},e2={bind:t=>e=>e(t),Apply0:()=>G1},n2={pure:Zm,Apply0:()=>G1},Qn={Applicative0:()=>n2,Bind1:()=>e2},r2=function(t){return function(){return t}},o2={apply:t=>e=>()=>{const n=t(),r=e();return mc.pure(n(r))()},Functor0:()=>i2},mc={pure:r2,Apply0:()=>o2},i2={map:t=>e=>()=>{const n=e();return t(n)}},ki=(t,e)=>({tag:t,_1:e}),yc=t=>ki("Loop",t),a2=t=>ki("Done",t),s2={tailRecM:t=>{const e=n=>{let r=n,o=!0,i;for(;o;){const a=r;if(a.tag==="Loop"){r=t(a._1);continue}if(a.tag==="Done"){o=!1,i=a._1;continue}g()}return i};return n=>e(t(n))},Monad0:()=>Qn},u2=function(t){return function(e){return function(){return t(e())}}},c2=function(t){return function(){return t}},g2=function(t){return function(e){return function(){return e(t())()}}},_2={map:u2},f2={Applicative0:()=>xc,Bind1:()=>l2},l2={bind:g2,Apply0:()=>R1},R1={apply:t=>e=>()=>{const n=t(),r=e();return xc.pure(n(r))()},Functor0:()=>_2},xc={pure:c2,Apply0:()=>R1},d2={tailRecM:t=>e=>{const n=t(e);return()=>{let r=n();for(;r.tag==="Loop";){const i=r;if(i.tag==="Loop"){r=t(i._1)();continue}i.tag!=="Done"&&g()}const o=r;if(o.tag==="Done")return o._1;g()}},Monad0:()=>f2},h2=function(t){return function(e){return function(n){return function(){return t(e,n)}}}},p2=function(t,e,n,r){return n>=0&&n<r.length?t(r[n]):e},Tc=function(t){return t.length},m2=function(t,e,n){return n.length>0?t(n.pop()):e},y2=h2(function(t,e){return e.push(t)}),x2=(t,e)=>({tag:"Iterator",_1:t,_2:e}),T2=t=>e=>n=>()=>{let r=!1;const o=e._2;for(;!r;){const i=o.value,a=e._1(i);if(a.tag==="Just"&&t(a._1)){n.push(a._1),e._2.value;const s=e._2.value;e._2.value=s+1|0;continue}r=!0}},w2=t=>e=>()=>{let n=!1;const r=t._2;for(;!n;){const o=r.value,i=r.value;r.value=i+1|0;const a=t._1(o);if(a.tag==="Just"){e(a._1)();continue}if(a.tag==="Nothing"){n=!0;continue}g()}},Li=function(t){return function(e){return function(n){for(var r=e,o=n.length,i=o-1;i>=0;i--)r=t(n[i])(r);return r}}},v=function(t){return function(e){return function(n){for(var r=e,o=n.length,i=0;i<o;i++)r=t(r)(n[i]);return r}}},Go=t=>{const e=t.Apply0();return n=>r=>n.foldr(o=>{const i=r(o);return a=>e.apply(e.Functor0().map(s=>k1)(i))(a)})(t.pure())},Si=t=>{const e=Go(t);return n=>{const r=e(n);return o=>i=>r(i)(o)}},N2={foldr:t=>e=>n=>{if(n.tag==="Nothing")return e;if(n.tag==="Just")return t(n._1)(e);g()},foldl:t=>e=>n=>{if(n.tag==="Nothing")return e;if(n.tag==="Just")return t(e)(n._1);g()},foldMap:t=>{const e=t.mempty;return n=>r=>{if(r.tag==="Nothing")return e;if(r.tag==="Just")return n(r._1);g()}}},Wt={foldr:Li,foldl:v,foldMap:t=>{const e=t.mempty;return n=>Wt.foldr(r=>o=>t.Semigroup0().append(n(r))(o))(e)}},S=(t,e)=>({tag:"Tuple",_1:t,_2:e}),Ln=t=>e=>S(t,e),cs=t=>t._2,gs=t=>t._1,Ht=function(t){return function(e){for(var n=e.length,r=Array(n),o=0;o<n;o++)r[o]=t(o)(e[o]);return r}};var wc=function(t){return function(e){return t===e}};const J2=wc,v2=wc,sa=wc,Nc=function(t){return function(e){return function(n){if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(!t(e[r])(n[r]))return!1;return!0}}},vr={eq:sa},C2={eq:v2},ro={eq:J2};var Jc=function(t){return function(e){return function(n){return function(r){return function(o){return r<o?t:r===o?e:n}}}}};const b2=Jc,k2=Jc,R={compare:Jc(Be)(nn)(Me),Eq0:()=>vr},at={compare:k2(Be)(nn)(Me),Eq0:()=>C2},ut={compare:b2(Be)(nn)(Me),Eq0:()=>ro},ua=function(t){return t},L2=(function(){function t(o){return[o]}function e(o){return function(i){return[o,i]}}function n(o){return function(i){return function(a){return[o,i,a]}}}function r(o){return function(i){return o.concat(i)}}return function(o){return function(i){return function(a){return function(s){return function(u){function c(_,f){switch(f-_){case 0:return a([]);case 1:return i(t)(s(u[_]));case 2:return o(i(e)(s(u[_])))(s(u[_+1]));case 3:return o(o(i(n)(s(u[_])))(s(u[_+1])))(s(u[_+2]));default:var l=_+Math.floor((f-_)/4)*2;return o(i(r)(c(_,l)))(c(l,f))}}return c(0,u.length)}}}}}})(),S2=t=>t,oo={traverse:t=>{const e=t.Apply0();return L2(e.apply)(e.Functor0().map)(t.pure)},sequence:t=>oo.traverse(t)(S2),Functor0:()=>qm,Foldable1:()=>Wt},$t=function(t,e){for(var n=t>e?-1:1,r=new Array(n*(e-t)+1),o=t,i=0;o!==e;)r[i++]=o,o+=n;return r[i]=o,r};var E2=function(t,e){if(t<1)return[];var n=new Array(t);return n.fill(e)},P2=function(t,e){for(var n=[],r=0,o=0;o<t;o++)n[r++]=e;return n};const Ro=typeof Array.prototype.fill=="function"?E2:P2,Bt=(function(){function t(o,i){this.head=o,this.tail=i}var e={};function n(o){return function(i){return new t(o,i)}}function r(o){for(var i=[],a=0,s=o;s!==e;)i[a++]=s.head,s=s.tail;return i}return function(o,i){return r(o(n)(e)(i))}})(),G2=function(t){return t.length},Pt=function(t,e,n){return n.length===0?t({}):e(n[0])(n.slice(1))},A1=function(t,e,n,r){for(var o=0;o<r.length;o++){var i=n(r[o]);if(e(i))return i}return t},Or=function(t,e,n,r){for(var o=0,i=r.length;o<i;o++)if(n(r[o]))return t(o);return e},I1=function(t,e,n,r,o){if(n<0||n>o.length)return e;var i=o.slice();return i.splice(n,0,r),t(i)},F1=function(t,e,n,r){if(n<0||n>=r.length)return e;var o=r.slice();return o.splice(n,1),t(o)},io=function(t,e,n,r,o){if(n<0||n>=o.length)return e;var i=o.slice();return i[n]=r,t(i)},ee=function(t){return t.slice().reverse()},Tn=function(t){if(t.length<=1e4)return Array.prototype.concat.apply([],t);for(var e=[],n=0,r=t.length;n<r;n++)for(var o=t[n],i=0,a=o.length;i<a;i++)e.push(o[i]);return e},gt=function(t,e){return e.filter(t)},R2=function(t,e,n){for(var r=n.length,o=e,i=new Array(r),a=0;a<r;a++)o=t(o)(n[a]),i[a]=o;return i},A2=(function(){function t(e,n,r,o,i,a){var s,u,c,_,f,l,d;for(s=i+(a-i>>1),s-i>1&&t(e,n,o,r,i,s),a-s>1&&t(e,n,o,r,s,a),u=i,c=s,_=i;u<s&&c<a;)f=o[u],l=o[c],d=n(e(f)(l)),d>0?(r[_++]=l,++c):(r[_++]=f,++u);for(;u<s;)r[_++]=o[u++];for(;c<a;)r[_++]=o[c++]}return function(e,n,r){var o;return r.length<2?r:(o=r.slice(0),t(e,n,o,r.slice(0),0,r.length),o)}})(),Rt=function(t,e,n){return n.slice(t,e)},Oe=function(t,e,n){for(var r=e.length<n.length?e.length:n.length,o=new Array(r),i=0;i<r;i++)o[i]=t(e[i])(n[i]);return o},ue=function(t,e){for(var n=e.length,r=0;r<n;r++)if(t(e[r]))return!0;return!1},vc=function(t,e){for(var n=e.length,r=0;r<n;r++)if(!t(e[r]))return!1;return!0},Gt=t=>e=>A2(t,n=>{if(n==="GT")return 1;if(n==="EQ")return 0;if(n==="LT")return-1;g()},e),I2=t=>e=>Gt(n=>r=>t.compare(e(n))(e(r))),wt=t=>e=>(()=>{const n=y2(e);return()=>{const r=[...t];return n(r)(),r}})()(),_r=t=>{if(t.length===0)return t.length-1|0,T;const e=t.length-1|0;return e>=0&&e<t.length?J("Just",{init:Rt(0,t.length-1|0,t),last:t[e]}):T},F2=t=>e=>n=>t>=0&&t<n.length?io(Vt,T,t,e(n[t]),n):T,Cr=t=>e=>{const n=(r=>{let o=r,i=!0,a;for(;i;){const s=o;if(s>=0&&s<e.length){if(t(e[s])){o=s+1|0;continue}i=!1,a=J("Just",s);continue}i=!1,a=T}return a})(0);if(n.tag==="Just")return n._1===0?{init:[],rest:e}:{init:Rt(0,n._1,e),rest:Rt(n._1,e.length,e)};if(n.tag==="Nothing")return{init:e,rest:[]};g()},Ei=t=>e=>{const n=Gt(r=>o=>t(r._2)(o._2))(Ht(Ln)(e));return 0<n.length?V(cs)(I2(ut)(gs)((()=>{const r=[n[0]];for(const o of n){const i=t((()=>{const a=r.length-1|0;if(a>=0&&a<r.length)return r[a]._2;g()})())(o._2);(i==="LT"||i==="GT"||i!=="EQ")&&r.push(o)}return r})())):[]},D2=t=>e=>{const n=[],r=x2(o=>o>=0&&o<e.length?J("Just",e[o]):T,{value:0});return w2(r)(o=>()=>{const i=[];i.push(o),T2(t(o))(r)(i)(),n.push(i)})(),n},ne=t=>e=>{const n=Or(Vt,T,t,e);return n.tag==="Just"?J("Just",e[n._1]):T},ca=t=>e=>gt(t,e),gn=t=>e=>n=>{const r=Or(Vt,T,o=>t.eq(o)(e),n);if(r.tag==="Nothing")return!1;if(r.tag==="Just")return!0;g()},_s=t=>e=>Et(e)(t),Tt=t=>_s(e=>{const n=t(e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[n._1];g()}),ga=isFinite;function Cc(t,e,n,r){var o=parseFloat(t);return e(o)?n(o):r}const re=Math.abs,z2=Math.acos,Ao=function(t){return function(e){return Math.atan2(t,e)}},fs=Math.ceil,_n=Math.cos,Pi=Math.exp,nr=Math.floor,ls=Math.log,B2=function(t){return function(e){return Math.min(t,e)}},bc=function(t){return function(e){return Math.pow(t,e)}},Wn=Math.round,Ye=Math.sin,Ke=Math.sqrt,M2=Math.tan,Q2=function(t){return function(e){return function(n){return(n|0)===n?t(n):e}}},rt=function(t){return t},W2=(function(t){return function(e){return function(n){var r;n<11?r="[0-"+(n-1).toString()+"]":n===11?r="[0-9a]":r="[0-9a-"+String.fromCharCode(86+n)+"]";var o=new RegExp("^[\\+\\-]?"+r+"+$","i");return function(i){if(o.test(i)){var a=parseInt(i,n);return(a|0)===a?t(a):e}else return e}}}})(Vt)(T)(10),D1=Q2(Vt)(T),he=t=>{if(!ga(t))return 0;if(t>=rt(2147483647))return 2147483647;if(t<=rt(-2147483648))return-2147483648;const e=D1(t);if(e.tag==="Nothing")return 0;if(e.tag==="Just")return e._1;g()},yt=(t,e,n)=>({tag:t,_1:e,_2:n}),D=yt("Nil"),ce={foldr:t=>e=>{const n=ce.foldl(o=>i=>t(i)(o))(e),r=(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s;if(f.tag==="Nil"){u=!1,c=_;continue}if(f.tag==="Cons"){a=yt("Cons",f._1,_),s=f._2;continue}g()}return c})(D);return o=>n(r(o))},foldl:t=>e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=o;if(u.tag==="Nil"){i=!1,a=s;continue}if(u.tag==="Cons"){r=t(s)(u._1),o=u._2;continue}g()}return a},foldMap:t=>{const e=t.mempty;return n=>ce.foldl(r=>{const o=t.Semigroup0().append(r);return i=>o(n(i))})(e)}},H2=function(t){return function(e){return function(n){return function(r){return function(o){return function(i){for(var a=[],s=i;;){var u=o(s);a.push(n(u));var c=r(u);if(t(c))return a;s=e(c)}}}}}}},O2=t=>{if(t.tag==="Just")return t._1;g()},q2={unfoldr1:H2(L1)(O2)(gs)(cs)},V2=function(t){return function(e){return function(n){return function(r){return function(o){return function(i){for(var a=[],s=i;;){var u=o(s);if(t(u))return a;var c=e(u);a.push(n(c)),s=r(c)}}}}}}},$2=t=>{if(t.tag==="Just")return t._1;g()},wn={unfoldr:V2(L1)($2)(gs)(cs),Unfoldable10:()=>q2},Zt=(t,e,n,r,o,i,a)=>({tag:t,_1:e,_2:n,_3:r,_4:o,_5:i,_6:a}),Nn=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),ds=(t,e,n)=>({tag:"Split",_1:t,_2:e,_3:n}),z1=(t,e,n)=>({tag:"SplitLast",_1:t,_2:e,_3:n}),M=Zt("Leaf"),fr=Nn("IterLeaf"),Se=(t,e,n,r)=>{if(n.tag==="Leaf"){if(r.tag==="Leaf")return Zt("Node",1,1,t,e,n,r);if(r.tag==="Node")return Zt("Node",1+r._1|0,1+r._2|0,t,e,n,r);g()}if(n.tag==="Node"){if(r.tag==="Leaf")return Zt("Node",1+n._1|0,1+n._2|0,t,e,n,r);if(r.tag==="Node")return Zt("Node",n._1>r._1?1+n._1|0:1+r._1|0,(1+n._2|0)+r._2|0,t,e,n,r)}g()},rn=(t,e,n,r)=>{if(n.tag==="Leaf")return r.tag==="Leaf"?Zt("Node",1,1,t,e,M,M):r.tag==="Node"&&r._1>1?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?Se(r._5._3,r._5._4,Se(t,e,n,r._5._5),Se(r._3,r._4,r._5._6,r._6)):Se(r._3,r._4,Se(t,e,n,r._5),r._6):Se(t,e,n,r);if(n.tag==="Node")return r.tag==="Node"?r._1>(n._1+1|0)?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?Se(r._5._3,r._5._4,Se(t,e,n,r._5._5),Se(r._3,r._4,r._5._6,r._6)):Se(r._3,r._4,Se(t,e,n,r._5),r._6):n._1>(r._1+1|0)?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?Se(n._6._3,n._6._4,Se(n._3,n._4,n._5,n._6._5),Se(t,e,n._6._6,r)):Se(n._3,n._4,n._5,Se(t,e,n._6,r)):Se(t,e,n,r):r.tag==="Leaf"&&n._1>1?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?Se(n._6._3,n._6._4,Se(n._3,n._4,n._5,n._6._5),Se(t,e,n._6._6,r)):Se(n._3,n._4,n._5,Se(t,e,n._6,r)):Se(t,e,n,r);g()},Gi=(t,e,n)=>{if(n.tag==="Leaf")return ds(T,M,M);if(n.tag==="Node"){const r=t(e)(n._3);if(r==="LT"){const o=Gi(t,e,n._5);return ds(o._1,o._2,rn(n._3,n._4,o._3,n._6))}if(r==="GT"){const o=Gi(t,e,n._6);return ds(o._1,rn(n._3,n._4,n._5,o._2),o._3)}if(r==="EQ")return ds(J("Just",n._4),n._5,n._6)}g()},B1=(t,e,n,r)=>{if(r.tag==="Leaf")return z1(t,e,n);if(r.tag==="Node"){const o=B1(r._3,r._4,r._5,r._6);return z1(o._1,o._2,rn(t,e,n,o._3))}g()},Ri=(t,e)=>{if(t.tag==="Leaf")return e;if(t.tag==="Node"){const n=B1(t._3,t._4,t._5,t._6);return rn(n._1,n._2,n._3,e)}g()},lr=(t,e,n)=>{if(e.tag==="Leaf")return M;if(n.tag==="Leaf")return e;if(n.tag==="Node"){const r=Gi(t,n._3,e);return Ri(lr(t,r._2,n._5),lr(t,r._3,n._6))}g()},hs=(t,e,n,r)=>{if(n.tag==="Leaf"||r.tag==="Leaf")return M;if(r.tag==="Node"){const o=Gi(t,r._3,n),i=hs(t,e,o._2,r._5),a=hs(t,e,o._3,r._6);if(o._1.tag==="Just")return rn(r._3,e(o._1._1)(r._4),i,a);if(o._1.tag==="Nothing")return Ri(i,a)}g()},je=(t,e,n,r)=>{if(n.tag==="Leaf")return r;if(r.tag==="Leaf")return n;if(r.tag==="Node"){const o=Gi(t,r._3,n),i=je(t,e,o._2,r._5),a=je(t,e,o._3,r._6);if(o._1.tag==="Just")return rn(r._3,e(o._1._1)(r._4),i,a);if(o._1.tag==="Nothing")return rn(r._3,r._4,i,a)}g()},M1=t=>e=>n=>{const r=o=>{if(o.tag==="Leaf")return M;if(o.tag==="Node"){const i=t.compare(n)(o._3);if(i==="LT")return rn(o._3,o._4,r(o._5),o._6);if(i==="GT")return rn(o._3,o._4,o._5,r(o._6));if(i==="EQ"){const a=e(o._4);if(a.tag==="Nothing")return Ri(o._5,o._6);if(a.tag==="Just")return Zt("Node",o._1,o._2,o._3,a._1,o._5,o._6)}}g()};return r},U2=t=>e=>{const n=r=>{if(r.tag==="Leaf")return M;if(r.tag==="Node"){const o=e(r._3)(r._4);if(o.tag==="Just")return rn(r._3,o._1,n(r._5),n(r._6));if(o.tag==="Nothing")return Ri(n(r._5),n(r._6))}g()};return n},dr=(t=>e=>n=>{let r=n,o=!0,i;for(;o;){const a=r;if(a.tag==="IterLeaf"){o=!1,i=e();continue}if(a.tag==="IterEmit"){o=!1,i=t(a._1,a._2,a._3);continue}if(a.tag==="IterNode"){r=(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Leaf"){f=!1,l=d;continue}if(h.tag==="Node"){if(h._6.tag==="Leaf"){c=Nn("IterEmit",h._3,h._4,d),_=h._5;continue}c=Nn("IterEmit",h._3,h._4,Nn("IterNode",h._6,d)),_=h._5;continue}g()}return l})(a._2)(a._1);continue}g()}return i})((t,e,n)=>J("Just",S(S(t,e),n)))(t=>T),Mt=t=>e=>n=>r=>{const o=i=>{if(i.tag==="Leaf")return Zt("Node",1,1,n,r,M,M);if(i.tag==="Node"){const a=t.compare(n)(i._3);if(a==="LT")return rn(i._3,i._4,o(i._5),i._6);if(a==="GT")return rn(i._3,i._4,i._5,o(i._6));if(a==="EQ")return Zt("Node",i._1,i._2,n,e(i._4)(r),i._5,i._6)}g()};return o},it=t=>e=>n=>{const r=o=>{if(o.tag==="Leaf")return Zt("Node",1,1,e,n,M,M);if(o.tag==="Node"){const i=t.compare(e)(o._3);if(i==="LT")return rn(o._3,o._4,r(o._5),o._6);if(i==="GT")return rn(o._3,o._4,o._5,r(o._6));if(i==="EQ")return Zt("Node",o._1,o._2,e,n,o._5,o._6)}g()};return r},fe=t=>e=>e.foldl(n=>r=>it(t)(r._1)(r._2)(n))(M),Ai=t=>e=>{const n=r=>{if(r.tag==="Leaf")return M;if(r.tag==="Node"){const o=t.compare(e)(r._3);if(o==="LT")return rn(r._3,r._4,n(r._5),r._6);if(o==="GT")return rn(r._3,r._4,r._5,n(r._6));if(o==="EQ")return Ri(r._5,r._6)}g()};return n},Q1=t=>{const e=t.compare;return n=>r=>o=>{const i=Gi(e,r,o),a=n(i._1);if(a.tag==="Nothing")return Ri(i._2,i._3);if(a.tag==="Just")return rn(r,a._1,i._2,i._3);g()}},ve=function(t){return function(e){return t+e|0}},hr=function(t){return function(e){return t+e}},ao=function(t){return function(e){if(e===0)return 0;var n=Math.abs(e);return(t%n+n)%n}},X2=function(t){return function(e){return t+e}},xe=function(t){return function(e){return t.length===0?e:e.length===0?t:t.concat(e)}},Y2={append:X2},K2={append:xe},j2={mempty:"",Semigroup0:()=>Y2},Z2={mempty:[],Semigroup0:()=>K2},_a=null;function Sn(t,e,n){return t==null?e:n(t)}function bG(t){return t}function kc(t){return function(e){return function(n){return t.apply(n,[e])}}}const ty=kc(Number.prototype.toPrecision),ey=kc(Number.prototype.toFixed),ny=kc(Number.prototype.toExponential),Io=(t,e)=>({tag:t,_1:e}),Fo=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Do=t=>{if(t.tag==="Precision")return ty(t._1);if(t.tag==="Fixed")return ey(t._1);if(t.tag==="Exponential")return ny(t._1);g()},W1=function(t){return function(){console.log(t)}};function H1(t){return function(){return t.getContext("2d")}}function O1(t){return function(){return t.width}}function q1(t){return function(){return t.height}}function V1(t){return function(e){return function(){t.width=e}}}function $1(t){return function(e){return function(){t.height=e}}}function Lc(t){return function(e){return function(){t.lineWidth=e}}}function ry(t){return function(e){return function(){t.fillStyle=e}}}function oy(t){return function(e){return function(){t.strokeStyle=e}}}function Sc(t){return function(e){return function(){t.lineCap=e}}}function Ec(t){return function(e){return function(){t.lineJoin=e}}}function iy(t){return function(e){return function(){t.globalCompositeOperation=e}}}function ay(t){return function(e){return function(){t.globalAlpha=e}}}function U1(t){return function(){t.beginPath()}}function Pc(t){return function(){t.stroke()}}function Gc(t){return function(){t.fill()}}function sy(t){return function(){t.clip()}}function fa(t){return function(e){return function(n){return function(){t.lineTo(e,n)}}}}function X1(t){return function(e){return function(n){return function(){t.moveTo(e,n)}}}}function Y1(t){return function(){t.closePath()}}function uy(t){return function(e){return function(){t.fillRect(e.x,e.y,e.width,e.height)}}}function cy(t){return function(e){return function(){t.clearRect(e.x,e.y,e.width,e.height)}}}function ps(t){return function(e){return function(){t.scale(e.scaleX,e.scaleY)}}}function K1(t){return function(e){return function(){t.translate(e.translateX,e.translateY)}}}function gy(t){return function(e){return function(){t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}}}function _y(t){return function(e){return function(){t.textAlign=e}}}function fy(t){return function(e){return function(){t.textBaseline=e}}}function ly(t){return function(e){return function(){t.font=e}}}function dy(t){return function(e){return function(n){return function(r){return function(){t.fillText(e,n,r)}}}}}function br(t){return function(){t.save()}}function kr(t){return function(){t.restore()}}function la(t){return function(e){return function(){t.quadraticCurveTo(e.cpx,e.cpy,e.x,e.y)}}}function hy(t){return function(e){return function(){t.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y)}}}const j1=t=>t,Rc=t=>t,Ac=t=>t,Ic=t=>t,ms=t=>t,py=ms("BaselineTop"),my=ms("BaselineMiddle"),yy=ms("BaselineAlphabetic"),xy=ms("BaselineBottom"),Ty=Ic("AlignLeft"),wy=Ic("AlignRight"),Ny=Ic("AlignCenter"),Fc=Ac("BevelJoin"),Dc=Ac("RoundJoin"),zc=Ac("MiterJoin"),Bc=Rc("Round"),Mc=Rc("Square"),Qc=Rc("Butt"),Jy=j1("SourceOver"),vy=j1("Difference"),Cy=t=>e=>fy(t)((()=>{if(e==="BaselineTop")return"top";if(e==="BaselineHanging")return"hanging";if(e==="BaselineMiddle")return"middle";if(e==="BaselineAlphabetic")return"alphabetic";if(e==="BaselineIdeographic")return"ideographic";if(e==="BaselineBottom")return"bottom";g()})()),by=t=>e=>_y(t)((()=>{if(e==="AlignLeft")return"left";if(e==="AlignRight")return"right";if(e==="AlignCenter")return"center";if(e==="AlignStart")return"start";if(e==="AlignEnd")return"end";g()})()),Wc=t=>e=>{if(e==="BevelJoin")return Ec(t)("bevel");if(e==="RoundJoin")return Ec(t)("round");if(e==="MiterJoin")return Ec(t)("miter");g()},Hc=t=>e=>{if(e==="Round")return Sc(t)("round");if(e==="Square")return Sc(t)("square");if(e==="Butt")return Sc(t)("butt");g()},Z1=t=>e=>iy(t)((()=>{if(e==="SourceOver")return"source-over";if(e==="SourceIn")return"source-in";if(e==="SourceOut")return"source-out";if(e==="SourceAtop")return"source-atop";if(e==="DestinationOver")return"destination-over";if(e==="DestinationIn")return"destination-in";if(e==="DestinationOut")return"destination-out";if(e==="DestinationAtop")return"destination-atop";if(e==="Lighter")return"lighter";if(e==="Copy")return"copy";if(e==="Xor")return"xor";if(e==="Multiply")return"multiply";if(e==="Screen")return"screen";if(e==="Overlay")return"overlay";if(e==="Darken")return"darken";if(e==="Lighten")return"lighten";if(e==="ColorDodge")return"color-dodge";if(e==="ColorBurn")return"color-burn";if(e==="HardLight")return"hard-light";if(e==="SoftLight")return"soft-light";if(e==="Difference")return"difference";if(e==="Exclusion")return"exclusion";if(e==="Hue")return"hue";if(e==="Saturation")return"saturation";if(e==="Color")return"color";if(e==="Luminosity")return"luminosity";g()})()),tf={foldrWithIndex:t=>e=>{const n=Li(o=>{const i=o._1,a=o._2;return s=>t(i)(a)(s)})(e),r=Ht(Ln);return o=>n(r(o))},foldlWithIndex:t=>e=>{const n=v(o=>i=>t(i._1)(o)(i._2))(e),r=Ht(Ln);return o=>n(r(o))},foldMapWithIndex:t=>{const e=t.mempty;return n=>tf.foldrWithIndex(r=>o=>i=>t.Semigroup0().append(n(r)(o))(i))(e)},Foldable0:()=>Wt},ky=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ly=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ys=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Sy=t=>e=>n=>r=>n<=0||r<=0||e.bounds.w<=0||e.bounds.h<=0?1:t?ky(e.bounds.w/n)(e.bounds.h/r):Ly(e.bounds.w/n)(e.bounds.h/r),ef=t=>e=>n=>{const r=t.widthPx/t.heightPx,o=n.w/n.h;if(t.widthPx<=0||t.heightPx<=0){const a=1/ys(.05)(1)(e);return{w:n.w*a,h:n.h*a}}if(r>o){const a=1/ys(.05)(1)(e);return{w:n.h*r*a,h:n.h*a}}const i=1/ys(.05)(1)(e);return{w:n.w*i,h:n.w/r*i}},nf=t=>e=>n=>r=>o=>{const i=t+o/2,a=t+e-o/2,s=t+e/2,u=n+r/2;return o>=e?s:ys(i)(a)(u)},rf=t=>e=>n=>r=>({x:nf(t.bounds.x)(t.bounds.w)(e.x)(e.w)(n),y:nf(t.bounds.y)(t.bounds.h)(e.y)(e.h)(r)}),da=t=>e=>n=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:Sy(t)(e)(n.w)(n.h)}),Ey=t=>e=>n=>r=>{const o={x:r.x-t.padding,y:r.y-t.padding,w:r.w+t.padding*2,h:r.h+t.padding*2},i=ef(e)(.65)(o),a=rf(n)(o)(i.w)(i.h),s={x:a.x-i.w/2,y:a.y-i.h/2,w:i.w,h:i.h};return{focus:r,paddedFocus:o,viewport:s,camera:da(e.widthPx>0&&e.heightPx>0)(n)(s)}},Py=t=>e=>n=>r=>o=>{const i={x:o.x*r.scale+r.tx,y:o.y*r.scale+r.ty,w:o.w*r.scale,h:o.h*r.scale},a=t.padding*r.scale,s={x:i.x-a,y:i.y-a,w:i.w+a*2,h:i.h+a*2},u=ef(e)(.7)(s),c=rf(n)(s)(u.w)(u.h),_={x:c.x-u.w/2,y:c.y-u.h/2,w:u.w,h:u.h};return{footprint:i,viewport:_,camera:da(e.widthPx>0&&e.heightPx>0)(n)(_)}},Gy=t=>e=>n=>{const r=t.widthPx/t.heightPx,o=n.w/n.h;return t.widthPx<=0||t.heightPx<=0?da(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.w*.8,a=n.h*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})()):r>o?da(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.w*.8,a=n.w/r*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})()):da(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.h*r*.8,a=n.h*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})())},fn={foldr:t=>e=>{const n=ce.foldr(t)(e);return r=>n((()=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,yt("Cons",i._3,o(i._6,a)));g()};return o(r,D)})())}},Ry=t=>{const e={append:(()=>{const n=t.compare;return r=>o=>je(n,Xe,r,o)})()};return{mempty:M,Semigroup0:()=>e}},ha=function(t){return function(e){if(t>=0&&t<e.length)return e.charAt(t);throw new Error("Data.String.Unsafe.charAt: Invalid index.")}},Jn=function(t){return t.join("")},Hn=function(t){return t.split("")},En=function(t){return t},Pn=function(t){return t.length},of=function(t){return function(e){return e.substr(0,t)}},Ii=function(t){return function(e){return e.substring(t)}},af=function(t){return function(e){return{before:e.substring(0,t),after:e.substring(t)}}},Ay=t=>e=>{const n=af(Pn(e)-Pn(t)|0)(e);return n.after===t?J("Just",n.before):T},rr=t=>e=>{const n=af(Pn(t))(e);return n.before===t?J("Just",n.after):T},Iy=function(t){var e=null;return function(){return t===void 0||(e=t(),t=void 0),e}},Fy=function(t){return t()},Dy=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},zy=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},zo=t=>BigInt(t),By=t=>Number(t),xs=t=>e=>t+e,Ts=t=>e=>t*e,Oc=t=>e=>t-e,sf=0n,ws=1n,uf=t=>e=>t^e,pa=t=>e=>t&e,qc=t=>e=>t<<e,Vc=t=>e=>t>>e,My=t=>e=>t==e,Qy=t=>e=>t===e?0:t>e?1:-1,Wy={eq:My},cf={compare:t=>e=>{const n=Qy(t)(e);return n===1?Me:n===0?nn:Be},Eq0:()=>Wy},Hy=Dy(Vt)(T),Oy=zy(Vt)(T),gf=function(t){throw new Error(t)},_f=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=at.compare(e._1)(n._1);return r==="LT"?Be:r==="GT"?Me:at.compare(e._2)(n._2)},Eq0:()=>t}})(),qy=t=>e=>re(t._1-e._1)+re(t._2-e._2),Bo=t=>t,Ns=t=>t,Re=Ns("North"),Ae=Ns("South"),qr=Ns("East"),Vr=Ns("West"),so=Bo("Rectangle"),Vy=Bo("Cylinder"),$y=Bo("Parallelogram"),Uy=Bo("Diamond"),Xy=Bo("Ellipse"),Yy=Bo("Document"),Ky=Bo("Cloud"),ff=t=>t,jy=(t,e)=>({tag:t,_1:e}),$c=t=>t,Fi=(t,e)=>({tag:t,_1:e}),Uc=(t,e)=>({tag:t,_1:e}),ma=$c("Animated"),Zy=$c("StaticStill"),tx=$c("TitleCard"),ex=Uc("First"),lf=ff("Forward"),df=ff("Backward"),nx=Fi("ExitNode"),hf=fe(R)(Wt),rx=t=>Li(e=>n=>({nodes:je(R.compare,Xe,e.nodes,n.nodes),edges:je(R.compare,Xe,e.edges,n.edges)}))({nodes:M,edges:M})(t.keyframes),ox=t=>e=>({entering:{nodes:lr(R.compare,e.nodes,t.nodes),edges:lr(R.compare,e.edges,t.edges)},leaving:{nodes:lr(R.compare,t.nodes,e.nodes),edges:lr(R.compare,t.edges,e.edges)},surviving:{nodes:hs(R.compare,Xe,t.nodes,e.nodes),edges:hs(R.compare,Xe,t.edges,e.edges)}}),Js=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Di=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},vs=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Xc=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},ix=v(t=>e=>it(R)(e)()(t))(M),ax=v(t=>e=>it(R)(e)()(t))(M),sx=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),pf=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},mf=fe(R)(Wt),Cs=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:Js(r.minX)(o.x),minY:Js(r.minY)(o.y),maxX:Di(r.maxX)(o.x),maxY:Di(r.maxY)(o.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},ux=t=>e=>n=>ix(Et(Bt(fn.foldr,n))(r=>{const o=vs(r)(t);if(o.tag==="Just")return gt(i=>!Xc(i)(e),[o._1.source,o._1.target]);if(o.tag==="Nothing")return[];g()})),cx=t=>t.kind.tag==="SendToken"?J("Just",S(t.kind._1.edge,{source:t.kind._1.from,target:t.kind._1.to})):T,gx=t=>t.tag==="DataFlow"?Tt(cx)(t._1.events):[],_x=t=>e=>ax(Tt(n=>Xc(n._2.source)(e)||Xc(n._2.target)(e)?J("Just",n._1):T)(sx(t))),pr=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:Js(r.minX)(o.x),minY:Js(r.minY)(o.y),maxX:Di(r.maxX)(o.x+o.w),maxY:Di(r.maxY)(o.y+o.h)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x+e._1.head.w,maxY:e._1.head.y+e._1.head.h})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},ya=t=>e=>n=>{if(n.tag==="Leaf")return t.bounds;const r=_x(e)(n),o=[...Tt(i=>{const a=pf(i)(t.nodes);return a.tag==="Just"?J("Just",{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h}):T})(Bt(fn.foldr,je(R.compare,Xe,n,ux(e)(n)(r)))),...Tt(i=>{const a=vs(i)(t.edges);return a.tag==="Just"?J("Just",Cs(a._1)):T})(Bt(fn.foldr,r))];return o.length===0?t.bounds:pr(o)},xa=t=>e=>n=>{const r=[...Tt(o=>o)([(()=>{const o=vs(n)(t.edges);return o.tag==="Just"?J("Just",Cs(o._1)):T})()]),...(()=>{const o=vs(n)(e);if(o.tag==="Just")return Tt(i=>{const a=pf(i)(t.nodes);return a.tag==="Just"?J("Just",{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h}):T})([o._1.source,o._1.target]);if(o.tag==="Nothing")return[];g()})()];return r.length===0?ya(t)(e)(M):pr(r)},ln=t=>e=>{const n=t.bounds.w/Di(1e-4)(e.zoom),r=t.bounds.h/Di(1e-4)(e.zoom);return{x:e.center.x-n/2,y:e.center.y-r/2,w:n,h:r}},fx=t=>je(R.compare,Xe,mf(V(e=>S(e.id,{source:e.from.node,target:e.to.node}))(t.graph.edges)),mf(Et(t.scenes)(gx))),Yc=t=>t,lx=t=>t,bs=Yc("Linear"),Lr=Yc("EaseInOutQuad"),dx=Yc("SpringBouncy"),Ta=t=>e=>n=>{const r=Ke(1-e*e),o=t*r;return 1-Pi(-e*t*n)*(_n(o*n)+e/r*Ye(o*n))},hx=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Mo=t=>e=>(()=>{if(t==="Linear")return lx;if(t==="EaseInQuad")return n=>n*n;if(t==="EaseOutQuad")return n=>1-(1-n)*(1-n);if(t==="EaseInOutQuad")return n=>n<.5?2*n*n:1-2*(1-n)*(1-n);if(t==="EaseInCubic")return n=>n*n*n;if(t==="EaseOutCubic")return n=>1-(1-n)*(1-n)*(1-n);if(t==="EaseInOutCubic")return n=>n<.5?4*n*n*n:1-(-2*n+2)*(-2*n+2)*(-2*n+2)/2;if(t==="EaseOutExpo")return n=>n>=1?1:1-bc(2)(-10*n);if(t==="Spring")return n=>1-(1+6*n)*Pi(-6*n);if(t==="SpringBouncy")return Ta(6)(.7);g()})()(hx(e)),ks=t=>t,yf=t=>t,xf=t=>t,On=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ls=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Ss=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},px=t=>e=>{const n=ut.compare(t._1)(e._1);return n==="LT"?Be:n==="GT"?Me:at.compare(t._2)(e._2)},mx=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},yx=xf("Hold"),xx=xf("Gap"),qn=yf("LinearLerp"),uo=yf("ComposedLogLerp"),Kc=ks("Overview"),wa=ks("DiveHome"),co=ks("DiveTransition"),Es=ks("ActionFocus"),Tx=t=>e=>n=>{const r=t.widthPx>0&&t.heightPx>0,o=t.widthPx/On(1e-6)(t.heightPx),i=e.bounds.w/On(1e-6)(n.zoom),a=e.bounds.h/On(1e-6)(n.zoom),s=i/On(1e-6)(a),u=r&&o<s?i/o:a,c=r&&o>s?a*o:i;return{x:n.center.x-c/2,y:n.center.y-u/2,w:c,h:u}},jc=t=>e=>n=>{const r=n.center.y-e.center.y,o=n.center.x-e.center.x,i=Ke(o*o+r*r),a=n.zoom-e.zoom,s=a<0?-a:a;return Ls(t.minTransition)(t.maxTransition)(On(t.panSpeed<=0?t.minTransition:i/t.panSpeed)(t.zoomSpeed<=0?t.minTransition:s/t.zoomSpeed))},wx=t=>({startT:t.startT,endT:t.endT,fromCam:t.fromCam,toCam:t.toCam,easing:t.easing,interp:t.interp,intent:t.intent}),Nx=v(t=>e=>{const n=t.length-1|0;return n>=0&&n<t.length&&t[n]===e?t:wt(t)(e)})([]),Ps=t=>e=>n=>{const r=Ls(0)(1)((n-t)/On(1e-6)(e-t));return r*r*r*(r*(r*6-15)+10)},Jx=t=>e=>{const n=t.x-e.x;return(n<0?-n<.001:n<.001)&&(()=>{const r=t.y-e.y;return(r<0?-r<.001:r<.001)&&(()=>{const o=t.w-e.w;return(o<0?-o<.001:o<.001)&&(()=>{const i=t.h-e.h;return i<0?-i<.001:i<.001})()})()})()},vx=t=>e=>t.tag==="Just"?e.tag==="Just"&&Jx(t._1)(e._1):t.tag==="Nothing"&&e.tag==="Nothing",Tf=t=>e=>n=>r=>({center:{x:r.center.x*n.scale+n.tx,y:r.center.y*n.scale+n.ty},zoom:r.zoom*t.bounds.w/On(1e-6)(n.scale*e.bounds.w)}),Zc=t=>e=>n=>r=>({center:{x:t.center.x+(e.center.x-t.center.x)*n,y:t.center.y+(e.center.y-t.center.y)*n},zoom:Pi((()=>{const o=ls(On(1e-6)(t.zoom));return o+(ls(On(1e-6)(e.zoom))-o)*r})())}),Cx=v(t=>e=>{if(t.tag==="Nothing")return J("Just",e);if(t.tag==="Just")return e.endT>t._1.endT?J("Just",e):J("Just",t._1);g()})(T),bx=t=>e=>n=>r=>{if(t<=0)return r;const o=Pi(-t*e);return{center:{x:r.center.x+(n.center.x-r.center.x)*o,y:r.center.y+(n.center.y-r.center.y)*o},zoom:Pi((()=>{const i=ls(On(1e-6)(r.zoom));return i+(ls(On(1e-6)(n.zoom))-i)*o})())}},tg=t=>e=>n=>e.zoom>=t.zoom?Ps(.3)(1)(n):Ps(0)(.7)(n),kx={padding:24,easing:Lr,minimumReadableLabelPx:12,minimumVisibleLabelPx:5,labelBasePx:11,panSpeed:1500,zoomSpeed:4,minTransition:.15,maxTransition:.6,cameraDecay:0},Qo=t=>e=>n=>r=>o=>{const i=Tx(e)(n)(r),a=o.x-t.padding,s=o.y-t.padding;return a>=i.x&&s>=i.y&&a+o.w+t.padding*2<=i.x+i.w&&s+o.h+t.padding*2<=i.y+i.h},Lx=t=>e=>n=>r=>o=>tf.foldlWithIndex(i=>a=>s=>{const u=(()=>{if(s.kind==="Hold"){const c=(()=>{if(i===0)return s.toCam;if(s.focus.tag==="Just"){if(s.intent==="ActionFocus")return(e.widthPx<=0||e.heightPx<=0)&&Qo(t)(e)(n)(a.prev)(s.focus._1)||a.prev.zoom>=s.toCam.zoom*.995&&Qo(t)(e)(n)(a.prev)(s.focus._1)?a.prev:Qo(t)(e)(n)({center:a.prev.center,zoom:s.toCam.zoom})(s.focus._1)?{...s.toCam,center:a.prev.center}:{...s.toCam,center:{...s.toCam.center,x:(()=>{const _=n.bounds.w/On(1e-6)(s.toCam.zoom);if(_<=0)return s.toCam.center.x;const f=s.focus._1.x+s.focus._1.w/2,l=e.widthPx<=0?0:Ss(_/4)(6*_/e.widthPx),d=a.prev.center.x+_/2-l,h=f<a.prev.center.x-_/2+l?f-l+_/2:f>d?f+l-_/2:a.prev.center.x;return _>=n.bounds.w?n.bounds.x+n.bounds.w/2:Ls(n.bounds.x+_/2)(n.bounds.x+n.bounds.w-_/2)(h)})()}};if(Qo(t)(e)(n)(a.prev)(s.focus._1))return a.prev;if(Qo(t)(e)(n)({center:a.prev.center,zoom:s.toCam.zoom})(s.focus._1))return{...s.toCam,center:a.prev.center}}return s.toCam})();return{startT:s.startT,endT:s.endT,fromCam:c,toCam:c,easing:s.easing,interp:qn,focus:s.focus,intent:s.intent}}if(s.kind==="Gap")return{startT:s.startT,endT:s.endT,fromCam:a.prev,toCam:(()=>{const c=i+1|0,_=Or(Vt,T,f=>f.kind==="Hold",c<1?o:Rt(c,o.length,o));if(_.tag==="Just"){const f=(i+1|0)+_._1|0;return f>=0&&f<o.length?(()=>{if(o[f].focus.tag==="Just")return Qo(t)(e)(n)(a.prev)(o[f].focus._1);if(o[f].focus.tag==="Nothing")return!1;g()})()?a.prev:o[f].fromCam:a.prev}if(_.tag==="Nothing")return a.prev;g()})(),easing:s.easing,interp:qn,focus:T,intent:s.intent};g()})();return{acc:wt(a.acc)(u),prev:u.toCam}})({acc:[],prev:r})(o).acc,Sx=t=>e=>n=>r=>o=>i=>{const a=(u,c)=>Ss(jc(t)(u.toCam)(c.toCam))(u.endT-u.startT),s=v(u=>c=>{if(u.pending.tag==="Nothing")return{acc:u.acc,pending:J("Just",c)};if(u.pending.tag==="Just"){if(!(c.fromCam.zoom===c.toCam.zoom&&c.fromCam.center.x===c.toCam.center.x&&c.fromCam.center.y===c.toCam.center.y)||(()=>{if(c.focus.tag==="Just")return Qo(t)(e)(n)(u.pending._1.toCam)(c.focus._1);if(c.focus.tag==="Nothing")return!1;g()})()||(()=>{const _=u.pending._1.toCam.center.x-c.toCam.center.x;return(_<0?-_<8:_<8)&&(()=>{const f=u.pending._1.toCam.center.y-c.toCam.center.y;return(f<0?-f<8:f<8)&&(()=>{const l=u.pending._1.toCam.zoom-c.toCam.zoom;return l<0?-l<.08:l<.08})()})()})()||a(u.pending._1,c)<=0)return{acc:wt(u.acc)(u.pending._1),pending:J("Just",c)};if((()=>{const _=c.startT;return ue(f=>re(f-_)<1e-4,o)})()){const _={startT:c.startT,endT:c.startT+Ss(jc(t)(u.pending._1.toCam)(c.toCam))(c.endT-c.startT),fromCam:u.pending._1.toCam,toCam:c.toCam,easing:c.easing,interp:qn,focus:c.focus,intent:c.intent},f={...c,startT:_.endT,fromCam:c.toCam};return f.startT<f.endT?{acc:wt(wt(u.acc)(u.pending._1))(_),pending:J("Just",f)}:{acc:wt(u.acc)(u.pending._1),pending:J("Just",_)}}return{acc:wt(wt(u.acc)({...u.pending._1,endT:c.startT-a(u.pending._1,c)}))({startT:c.startT-a(u.pending._1,c),endT:c.startT,fromCam:u.pending._1.toCam,toCam:c.toCam,easing:c.easing,interp:qn,focus:c.focus,intent:c.intent}),pending:J("Just",c)}}g()})({acc:[],pending:T})(i);if(s.pending.tag==="Nothing")return s.acc;if(s.pending.tag==="Just")return wt(s.acc)(s.pending._1);g()},Ex=t=>e=>n=>{const r=e.w+n*2,o=e.h+n*2;return r<=0||o<=0||t.bounds.w<=0||t.bounds.h<=0?1:Ss(t.bounds.w/r)(t.bounds.h/o)},Px=t=>e=>n=>e.zoom>=t.zoom?Zc(t)(e)(Ps(0)(.45)(n))(tg(t)(e)(n)):Zc(t)(e)(Ps(.55)(1)(n))(tg(t)(e)(n)),Gx=t=>e=>n=>{const r=n.endT<=n.startT?1:(e-n.startT)/(n.endT-n.startT),o=Mo(n.easing)(Ls(0)(1)(r));if(n.interp==="LinearLerp")return{center:{x:n.fromCam.center.x+(n.toCam.center.x-n.fromCam.center.x)*o,y:n.fromCam.center.y+(n.toCam.center.y-n.fromCam.center.y)*o},zoom:n.fromCam.zoom+(n.toCam.zoom-n.fromCam.zoom)*o};if(n.interp==="LogLerp")return Zc(n.fromCam)(n.toCam)(o)(o);if(n.interp==="ComposedLogLerp")return Px(n.fromCam)(n.toCam)(r);g()},Rx=t=>e=>{if(t.tag==="Just"){if(e.tag==="Just")return J("Just",pr([t._1,e._1]));if(e.tag==="Nothing")return J("Just",t._1);g()}if(t.tag==="Nothing"){if(e.tag==="Just")return J("Just",e._1);if(e.tag==="Nothing")return T}g()},Ax=v(t=>e=>{const n=t.length-1|0,r=n>=0&&n<t.length?J("Just",t[n]):T;return r.tag==="Just"&&r._1.fromCam.zoom===r._1.toCam.zoom&&r._1.fromCam.center.x===r._1.toCam.center.x&&r._1.fromCam.center.y===r._1.toCam.center.y&&e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y&&(!(r._1.intent==="ActionFocus"||e.intent==="ActionFocus")||(r._1.intent==="Overview"?e.intent==="Overview":r._1.intent==="DiveHome"?e.intent==="DiveHome":r._1.intent==="DiveTransition"?e.intent==="DiveTransition":r._1.intent==="ActionFocus"&&e.intent==="ActionFocus")&&vx(r._1.focus)(e.focus))&&(()=>{const o=r._1.toCam.center.x-e.toCam.center.x;return(o<0?-o<8:o<8)&&(()=>{const i=r._1.toCam.center.y-e.toCam.center.y;return(i<0?-i<8:i<8)&&(()=>{const a=r._1.toCam.zoom-e.toCam.zoom;return a<0?-a<.08:a<.08})()})()})()?wt((()=>{const o=t.length-1|0;return o<1?[]:Rt(0,o,t)})())({...r._1,endT:e.endT,focus:Rx(r._1.focus)(e.focus)}):wt(t)(e)})([]),Ix=t=>{const e=Gt(n=>r=>px(S((()=>{if(r.intent==="DiveTransition")return 3;if(r.intent==="ActionFocus")return 2;if(r.intent==="DiveHome")return 1;if(r.intent==="Overview")return 0;g()})(),r.startT))(S((()=>{if(n.intent==="DiveTransition")return 3;if(n.intent==="ActionFocus")return 2;if(n.intent==="DiveHome")return 1;if(n.intent==="Overview")return 0;g()})(),n.startT)))(t);return 0<e.length?J("Just",e[0]):T},Gs=t=>e=>n=>r=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:On(r)(Ex(e)(n)(t.padding))}),Fx=t=>e=>n=>r=>o=>i=>{const a=Gs(t)(n)(n.bounds)(0),s=gt(c=>c>=0&&c<=r,Nx(Gt(at.compare)([0,r,...o,...Et(i)(c=>[c.startT,c.endT])]))),u=(c,_)=>ue(f=>f.priority>=1,gt(f=>f.startT<=_&&_<f.endT,i))?Ey(t)(e)(n)(pr(c)).camera:Gs(t)(n)(pr(c))(0);return V(wx)(Sx(t)(e)(n)(a)(o)(Ax(Lx(t)(e)(n)(a)(Tt(c=>{const _=(c._1+c._2)/2;if(c._2<=c._1)return T;const f=V(l=>l.bbox)(gt(l=>l.priority===v(mx)(0)(V(d=>d.priority)(gt(d=>d.startT<=_&&_<d.endT,i))),gt(l=>l.startT<=_&&_<l.endT,i)));return f.length===0?J("Just",{kind:xx,startT:c._1,endT:c._2,fromCam:a,toCam:a,easing:t.easing,focus:T,intent:Kc}):J("Just",{kind:yx,startT:c._1,endT:c._2,fromCam:u(f,_),toCam:u(f,_),easing:t.easing,focus:J("Just",pr(f)),intent:ue(l=>l.priority>=1,gt(l=>l.startT<=_&&_<l.endT,i))?Es:Kc})})(Oe(Ln,s,Rt(1,s.length,s)))))))},Wo=t=>e=>n=>r=>{const o=Ix(gt(i=>r>=i.startT&&r<i.endT,n));if(o.tag==="Just")return{camera:Gx()(r)(o._1),intent:o._1.intent};if(o.tag==="Nothing"){const i=Cx(n);return i.tag==="Just"&&r>=i._1.endT?{camera:i._1.toCam,intent:i._1.intent}:{camera:(()=>{const a=Gs(t)(e)(e.bounds)(0);return 0<n.length?n[0].fromCam:a})(),intent:0<n.length?n[0].intent:Kc}}g()};function go(t){return t.charCodeAt(0)}function wf(t){return String.fromCharCode(t)}const or=function(t){return function(e){return function(n){return n.replace(new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),e)}}},zi=function(t){return function(e){return e.split(t)}},Na=function(t){return t.trim()},Vn=function(t){return function(e){return e.join(t)}};var Dx=typeof Array.from=="function",zx=typeof Symbol<"u"&&Symbol!=null&&typeof Symbol.iterator<"u"&&typeof String.prototype[Symbol.iterator]=="function",Bx=typeof String.prototype.fromCodePoint=="function",Mx=typeof String.prototype.codePointAt=="function";const Qx=function(t){return Mx?function(e){return e.codePointAt(0)}:t},Wx=function(t){return Bx?String.fromCodePoint:t},Hx=function(t){return function(e){return zx?function(n){for(var r="",o=n[Symbol.iterator](),i=0;i<e;++i){var a=o.next();if(a.done)return r;r+=a.value}return r}:t(e)}},Ox=function(t){return function(e){return Dx?function(n){return Array.from(n,e)}:t}},Rs=t=>{const e=Pn(t);if(e===0)return T;if(e===1)return J("Just",{head:go(ha(0)(t)),tail:""});const n=go(ha(1)(t)),r=go(ha(0)(t));return 55296<=r&&r<=56319&&56320<=n&&n<=57343?J("Just",{head:(((r-55296|0)*1024|0)+(n-56320|0)|0)+65536|0,tail:Ii(2)(t)}):J("Just",{head:r,tail:Ii(1)(t)})},qx=t=>{const e=Rs(t);return e.tag==="Just"?J("Just",S(e._1.head,e._1.tail)):T},Vx=t=>wn.unfoldr(qx)(t),Nf=Qx(t=>{const e=go(ha(0)(t));if(55296<=e&&e<=56319&&Pn(t)>1){const n=go(ha(1)(t));if(56320<=n&&n<=57343)return(((e-55296|0)*1024|0)+(n-56320|0)|0)+65536|0}return e}),on=Ox(Vx)(Nf),$x=t=>on(t).length,eg=t=>En(t>=0&&t<=65535?wf(t):t<0?"\0":"\uFFFF"),Ux=Wx(t=>t<=65535?eg(t):eg(Jr(t-65536|0,1024)+55296|0)+eg(ao(t-65536|0)(1024)+56320|0)),Jf=t=>e=>{if(t<1)return"";const n=Rs(e);return n.tag==="Just"?Ux(n._1.head)+Jf(t-1|0)(n._1.tail):e},Ie=Hx(Jf),Xx=t=>e=>e===""?T:J("Just",Nf(e)),vf=v(hr)(0),Yx=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Sr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},As=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Cf=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Kx=t=>{const e={top:0,bottom:0,left:0,right:0},n=t.shape==="Cloud"?{...e,top:t.h*.38}:t.shape==="Cylinder"?{...e,bottom:5}:t.shape==="Document"?{...e,bottom:t.h*.05}:e;return[{x:t.x-n.left,y:t.y-n.top},{x:t.x+t.w+n.right,y:t.y+t.h+n.bottom}]},Ho=t=>e=>{const n=Oe(a=>s=>({a,b:s,len:(()=>{const u=s.y-a.y,c=s.x-a.x;return Ke(c*c+u*u)})()}),t,Rt(1,t.length,t)),r=vf(V(a=>a.len)(n)),o=Yx(0)(r)(e*r),i=a=>s=>u=>{let c=a,_=s,f=u,l=!0,d;for(;l;){const h=c,p=_,m=f,x=Pt(y=>T,y=>w=>J("Just",{head:y,tail:w}),h);if(x.tag==="Nothing"){const y=t.length-1|0;if(y>=0&&y<t.length){l=!1,d=t[y];continue}l=!1,d=m;continue}if(x.tag==="Just"){if(p<=x._1.head.len){const y=x._1.head.len<=0?0:p/x._1.head.len;l=!1,d={x:x._1.head.a.x+(x._1.head.b.x-x._1.head.a.x)*y,y:x._1.head.a.y+(x._1.head.b.y-x._1.head.a.y)*y};continue}c=x._1.tail,_=p-x._1.head.len,f=m;continue}g()}return d};return 0<t.length?J("Just",i(n)(o)(t[0])):T},jx=t=>e=>{const n=Sr(1e-6)(t.scale);return{x:(e.x-t.tx)/n,y:(e.y-t.ty)/n,w:e.w/n,h:e.h/n}},Ja=t=>vf(Oe(e=>n=>{const r=n.y-e.y,o=n.x-e.x;return Ke(o*o+r*r)},t,Rt(1,t.length,t))),Zx=t=>e=>n=>r=>o=>{const i=0<t.length?J("Just",t[0]):T,a=(()=>{if(i.tag==="Nothing")return e;if(i.tag==="Just")return i._1;g()})(),s=t.length-1|0,u=s>=0&&s<t.length?J("Just",t[s]):T,c=(()=>{if(u.tag==="Nothing")return n;if(u.tag==="Just")return u._1;g()})(),_=Sr(.05)(1-o.pre-o.post),f=r<o.pre?0:r>1-o.post?1:(r-o.pre)/_,l=c.x-n.x,d=2*(()=>{const N=c.y-n.y;return(l<0?-l:l)+(N<0?-N:N)})(),h=a.x-e.x,p=2*(()=>{const N=a.y-e.y;return(h<0?-h:h)+(N<0?-N:N)})(),m=p+Ja(t)+d,x=m<=1e-4?1:1-d/m,y=m<=1e-4?0:p/m;if(f<=y){const N=y<=1e-4?1:f/y;return{x:e.x+(a.x-e.x)*N,y:e.y+(a.y-e.y)*N}}if(f>=x){const N=x>=1?0:(f-x)/(1-x);return{x:c.x+(n.x-c.x)*N,y:c.y+(n.y-c.y)*N}}const w=Ho(t)((f-y)/Sr(1e-4)(x-y));if(w.tag==="Nothing")return a;if(w.tag==="Just")return w._1;g()},bf=t=>e=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),[...(()=>{const r=(o,i)=>{if(o.tag==="Leaf")return i;if(o.tag==="Node")return r(o._5,yt("Cons",o._4,r(o._6,i)));g()};return Et(Bt(ce.foldr,r(t,D)))(Kx)})(),...Tn((()=>{const r=(o,i)=>{if(o.tag==="Leaf")return i;if(o.tag==="Node")return r(o._5,yt("Cons",o._4,r(o._6,i)));g()};return Bt(ce.foldr,r(e,D))})())]);if(n.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(n.tag==="Just"){const r=v(o=>i=>({minX:As(o.minX)(i.x),minY:As(o.minY)(i.y),maxX:Sr(o.maxX)(i.x),maxY:Sr(o.maxY)(i.y)}))({minX:n._1.head.x,minY:n._1.head.y,maxX:n._1.head.x,maxY:n._1.head.y})(n._1.tail);return{x:r.minX,y:r.minY,w:r.maxX-r.minX,h:r.maxY-r.minY}}g()},ng={scale:1,tx:0,ty:0},tT=t=>e=>{const n=Sr(4)(.15*As(e.w)(e.h)),r=Sr(1)(t.w),o=Sr(1)(t.h),i=Sr(1)(e.w-2*n),a=Sr(1)(e.h-2*n),s=.55*As(i/r)(a/o);return{scale:s,tx:e.x+n+(i-r*s)/2-t.x*s,ty:e.y+n+(a-o*s)/2+2.5-t.y*s}},eT=t=>e=>(n=>r=>o=>{let i=n,a=r,s=o,u=!0,c;for(;u;){const _=i,f=a,l=s,d=Pt(h=>T,h=>p=>J("Just",{head:h,tail:p}),f);if(d.tag==="Nothing"){u=!1,c=l;continue}if(d.tag==="Just"){const h=Cf(d._1.head)(_.interiors);if(h.tag==="Nothing"){u=!1,c=l;continue}if(h.tag==="Just"){i=h._1,a=d._1.tail,s=(()=>{const p=tT(h._1.layout.bounds)((()=>{const m=Cf(d._1.head)(_.layout.nodes);if(m.tag==="Nothing")return{x:0,y:0,w:1,h:1,label:"",shape:so};if(m.tag==="Just")return m._1;g()})());return{scale:l.scale*p.scale,tx:l.scale*p.tx+l.tx,ty:l.scale*p.ty+l.ty}})();continue}}g()}return c})(t)(e)(ng),kf=t=>t,Is=(t,e)=>({tag:t,_1:e}),Bi=(t,e,n)=>({tag:t,_1:e,_2:n}),Lf=t=>t,Oo=(t,e,n,r,o,i,a,s,u)=>({tag:t,_1:e,_2:n,_3:r,_4:o,_5:i,_6:a,_7:s,_8:u}),rg=Lf("PlopIn"),nT=Lf("PlopOut"),rT=kf("DiveIn"),oT=kf("DiveOut"),Mi=(t,e,n)=>({tag:t,_1:e,_2:n}),iT=t=>t,Qi=(t,e)=>({tag:t,_1:e}),Sf=(t,e)=>({tag:t,_1:e}),og=t=>t,Fs=(t,e)=>({tag:t,_1:e}),ig=Fs("NotYet"),Ef=Fs("Consumed"),aT=og("FromSource"),Pf=og("FromTarget"),sT=og("FromBoth"),ag=Qi("Hidden"),Gf=Qi("Visible"),sg=iT("ExtendFromSource"),ug=Mi("Retracted"),Rf=Mi("Extended"),uT={eq:t=>e=>t.tag==="Retracted"?e.tag==="Retracted":t.tag==="Extending"?e.tag==="Extending"&&(t._1==="ExtendFromSource"?e._1==="ExtendFromSource":t._1==="ExtendFromTarget"&&e._1==="ExtendFromTarget")&&t._2===e._2:t.tag==="Extended"?e.tag==="Extended":t.tag==="Retracting"&&e.tag==="Retracting"&&(t._1==="FromSource"?e._1==="FromSource":t._1==="FromTarget"?e._1==="FromTarget":t._1==="FromBoth"&&e._1==="FromBoth")&&t._2===e._2},Af=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},va=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Ca=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},cg=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),cT=t=>e=>{if(e.scene.tag==="Structural")return e.scene._1.to;if(e.scene.tag==="DataFlow")return e.scene._1.keyframe;if(e.scene.tag==="Hold")return e.scene._1;if(e.scene.tag==="EnterNode"||e.scene.tag==="ExitNode"||e.scene.tag==="StepScene")return t;g()},gg=t=>e=>{const n=Af(e)(t.keyframes);if(n.tag==="Nothing")return M;if(n.tag==="Just")return n._1.nodes;g()},If=t=>e=>va(e)(t.activePlopOuts)?!0:va(e)(t.pastPlopOuts)?!1:va(e)(t.activeNodes)?!0:va(e)(t.futurePlopIns)?!1:va(e)(t.currentNodes),gT=v(cT),Wi=t=>e=>{if(e<t.startT)return Bi("AtKeyframe",t.initialKeyframe);const n=ne(r=>e>=r.startT&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return Bi("InTransition",n._1.scene._1.from,n._1.scene._1.to);if(n._1.scene.tag==="DataFlow")return Bi("AtKeyframe",n._1.scene._1.keyframe);if(n._1.scene.tag==="Hold")return Bi("AtKeyframe",n._1.scene._1);if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode"||n._1.scene.tag==="StepScene")return Bi("AtKeyframe",t.initialKeyframe);g()}if(n.tag==="Nothing")return Bi("AtKeyframe",gT(t.initialKeyframe)(t.spans));g()},_g=t=>e=>{const n=Af(e)(t.keyframes);if(n.tag==="Nothing")return M;if(n.tag==="Just")return n._1.edges;g()},_T=t=>e=>Ca(e)(t.activeRetracts)?!0:Ca(e)(t.pastRetracts)?!1:Ca(e)(t.activeEdges)?!0:Ca(e)(t.futureExtends)?!1:Ca(e)(t.currentEdges),Ff=t=>e=>{const n=Wi(t)(e);if(n.tag==="AtKeyframe")return gg(t)(n._1);if(n.tag==="InTransition")return je(R.compare,Xe,gg(t)(n._1),gg(t)(n._2));g()},Df=t=>e=>{const n=Wi(t)(e);if(n.tag==="AtKeyframe")return _g(t)(n._1);if(n.tag==="InTransition")return je(R.compare,Xe,_g(t)(n._1),_g(t)(n._2));g()},zf=t=>e=>v(n=>r=>{const o=e>=r.startT&&e<r.endT;return r.target.tag==="NodeWindow"?{...n,activeNodes:o?it(R)(r.target._1)()(n.activeNodes):n.activeNodes,activePlopOuts:o&&r.target._2==="PlopOut"?it(R)(r.target._1)()(n.activePlopOuts):n.activePlopOuts,pastPlopOuts:r.endT<=e&&r.target._2==="PlopOut"?it(R)(r.target._1)()(n.pastPlopOuts):n.pastPlopOuts,futurePlopIns:r.startT>e&&r.target._2==="PlopIn"?it(R)(r.target._1)()(n.futurePlopIns):n.futurePlopIns}:r.target.tag==="EdgeWindow"?{...n,activeEdges:o?it(R)(r.target._1)()(n.activeEdges):n.activeEdges,activeRetracts:o&&r.target._2.tag==="Retract"?it(R)(r.target._1)()(n.activeRetracts):n.activeRetracts,pastRetracts:r.endT<=e&&r.target._2.tag==="Retract"?it(R)(r.target._1)()(n.pastRetracts):n.pastRetracts,futureExtends:r.startT>e&&r.target._2.tag==="Extend"?it(R)(r.target._1)()(n.futureExtends):n.futureExtends}:n})({currentNodes:Ff(t)(e),currentEdges:Df(t)(e),activeNodes:M,activePlopOuts:M,pastPlopOuts:M,futurePlopIns:M,activeEdges:M,activeRetracts:M,pastRetracts:M,futureExtends:M})(t.windows),fT=t=>e=>{const n=zf(t)(e);return Tt(r=>If(n)(r._1)?J("Just",{x:r._2.x,y:r._2.y,w:r._2.w,h:r._2.h}):T)(cg(t.layout.nodes))},lT=t=>e=>{const n=fT(t)(e);return n.length===0?T:J("Just",pr(n))},ba=t=>e=>{const n=zf(t)(e),r=[...Tt(o=>If(n)(o._1)?J("Just",{x:o._2.x,y:o._2.y,w:o._2.w,h:o._2.h}):T)(cg(t.layout.nodes)),...Tt(o=>_T(n)(o._1)?J("Just",Cs(o._2)):T)(cg(t.layout.edges))];return r.length===0?T:J("Just",pr(r))},fg=t=>t,Ds=(t,e)=>({tag:t,_1:e}),zs={eq:Nc(sa)},lg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Bf=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Er=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Mf=Wt.foldMap(Ry(R)),ka=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Qf=fe(R)(Wt),dT=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},hT=fe(R)(Wt),pT=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},mT=fe(R)(Wt),yT=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Wf=Ds("Closed"),xT=Ds("Open"),Hf=fg("Backdrop"),TT=fg("FlyThrough"),an=fg("Active"),Bs=t=>e=>n=>{const r=ne(o=>zs.eq(o.path)(e)&&n>=o.startT&&n<o.endT)(t.segments);if(r.tag==="Just")return J("Just",r._1);if(r.tag==="Nothing")return ne(o=>zs.eq(o.path)(e))(t.segments);g()},wT=t=>{const e=ne(n=>n.path.length===0)(t.segments);if(e.tag==="Just")return e._1.edgeEndpoints;if(e.tag==="Nothing")return M;g()},NT=t=>({startT:0,endT:t.totalDuration,path:[],layout:t.layout,placement:ng,windows:t.windows,spans:t.spans,keyframes:t.keyframes,initialKeyframe:t.initialKeyframe,edgeEndpoints:wT(t)}),JT=t=>V(e=>e<1?[]:Rt(0,e,t))($t(0,t.length-1|0)),dg=t=>e=>n=>{const r=lg(e)(t.keyframes);if(r.tag==="Just")return Bf(n)(r._1.labels);if(r.tag==="Nothing")return T;g()},vT=t=>e=>Tt(n=>Bf(e)(n.labels))((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._4,n(r._6,o)));g()};return Bt(ce.foldr,n(t.keyframes,D))})()),CT=v(t=>e=>{const n=_r(t);return n.tag==="Just"&&e.startT<=n._1.last.endT+1e-6?wt(n._1.init)({...n._1.last,endT:Er(n._1.last.endT)(e.endT),windows:wt(n._1.last.windows)(e)}):wt(t)({endT:e.endT,windows:[e]})})([]),bT=t=>e=>n=>Mf(r=>Mf(o=>o.target.tag==="FillWindow"?o.startT<=n?Zt("Node",1,1,o.target._2,void 0,M,M):M:o.target.tag==="TokenWindow"&&o.startT+(o.endT-o.startT)*.25<=n?Zt("Node",1,1,o.target._4,void 0,M,M):M)(r.windows))(gt(r=>n<=r.endT+t,CT(Gt(r=>o=>at.compare(r.startT)(o.startT))(gt(r=>r.target.tag==="FillWindow"||r.target.tag==="TokenWindow",e))))),kT=t=>e=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),vT(t)(e));if(n.tag==="Nothing")return!1;if(n.tag==="Just"){const r=n._1.head;return ue(o=>o!==r,n._1.tail)}g()},LT=t=>e=>n=>ue(r=>r.endT<=e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n,t),ST=t=>e=>n=>ue(r=>r.endT<=e&&r.target.tag==="RelabelWindow"&&r.target._1===n,t),ET=t=>e=>n=>{const r=Wi(t)(e);if(r.tag==="AtKeyframe")return dg(t)(r._1)(n);if(r.tag==="InTransition")return ST(t.windows)(e)(n)?dg(t)(r._2)(n):dg(t)(r._1)(n);g()},PT=t=>e=>n=>ue(r=>r.endT<=e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopOut"&&r.target._1===n,t),GT=t=>e=>n=>ue(r=>r.startT>e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopIn"&&r.target._1===n,t),RT=t=>e=>n=>ue(r=>r.startT>e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"&&r.target._1===n,t),AT=t=>e=>{const n=Wi(t)(e);if(n.tag==="AtKeyframe")return Ie(3)(n._1)==="kf-"?"":n._1;if(n.tag==="InTransition")return Ie(3)(n._2)==="kf-"?"":n._2;g()},IT=t=>e=>{const n=Wi(t)(e),r=lg((()=>{if(n.tag==="AtKeyframe")return n._1;if(n.tag==="InTransition")return n._2;g()})())(t.keyframes);if(r.tag==="Just")return r._1.kind;if(r.tag==="Nothing")return ma;g()},Of=t=>{const e=A1(T,S1,o=>(()=>{const i=lg((()=>{if(o.scene.tag==="Structural")return o.scene._1.to;if(o.scene.tag==="DataFlow")return o.scene._1.keyframe;if(o.scene.tag==="Hold")return o.scene._1;if(o.scene.tag==="EnterNode"||o.scene.tag==="ExitNode"||o.scene.tag==="StepScene")return t.initialKeyframe;g()})())(t.keyframes);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return i._1.nodes.tag==="Leaf";g()})()?T:J("Just",Er(o.startT)(o.endT-1e-4)),t.spans),n=(()=>{if(e.tag==="Nothing")return t.startT;if(e.tag==="Just")return e._1;g()})(),r=ne(o=>o.target.tag==="NodeWindow"&&o.target._2==="PlopIn")(Gt(o=>i=>at.compare(o.startT)(i.startT))(t.windows));if(r.tag==="Nothing")return n;if(r.tag==="Just")return Er(r._1.startT)(r._1.endT-1e-4);g()},La=t=>e=>n=>ne(r=>n(r)&&e>=r.startT&&e<r.endT)(t),FT={segment:{startT:0,endT:0,path:[],layout:{nodes:M,edges:M,bounds:{x:0,y:0,w:0,h:0},chipExtras:M,edgeLabels:M},placement:ng,windows:[],spans:[],keyframes:M,initialKeyframe:"",edgeEndpoints:M},state:{animationTime:0,nodes:M,nodeLabels:M,edgeEndpoints:M,edges:M,tokens:M,camera:{center:{x:0,y:0},zoom:1},frameTitle:"",staticKind:ma,visited:M,nodeFadeAlpha:M,nodeLabelFadeAlpha:M,edgeFadeAlpha:M,nodeInvert:M},bgAlpha:1,minis:[],role:an},qf=t=>{const e=t.levels.length-1|0;return e>=0&&e<t.levels.length?t.levels[e]:FT},Vf=t=>e=>{const n=t.endT-t.startT;return n<=0?1:Er(0)(ka(1)((e-t.startT)/n))},DT=t=>e=>n=>tg(Wo(t.cameraConfig)(t.layout)(t.cameraSpans)(n.startT).camera)(Wo(t.cameraConfig)(t.layout)(t.cameraSpans)(n.endT).camera)(Vf(n)(e)),$f=t=>e=>n=>{const r=Er(0)(ka(1)((n-t)/Er(1e-6)(e-t)));return r*r*r*(r*(r*6-15)+10)},Uf=t=>{if(t.tag==="Closed")return 0;if(t.tag==="Opening")return $f(.3)(1)(t._1);if(t.tag==="Open")return 1;if(t.tag==="Closing")return 1-$f(0)(.7)(t._1);g()},zT=t=>{const e=Uf(t);return e<=0||e>=1?0:Ye(3.141592653589793*e)},qo=t=>e=>{const n=t.endT-t.startT;return n<=0?1:Er(0)(ka(1)((e-t.startT)/n))},BT=t=>e=>Qf(Tt(n=>{const r=La(t.windows)(e)(o=>o.target.tag==="RelabelWindow"&&o.target._1===n);if(r.tag==="Just")return r._1.target.tag==="RelabelWindow"?J("Just",S(n,Sf("RelabelingNode",{oldLabel:r._1.target._2,newLabel:r._1.target._3,progress:qo(r._1)(e)}))):T;if(r.tag==="Nothing"){if(kT(t)(n)){const o=ET(t)(e)(n);if(o.tag==="Just")return J("Just",S(n,Sf("StaticNodeLabel",o._1)));if(o.tag==="Nothing")return T;g()}return T}g()})((()=>{const n=r=>{if(r.tag==="Leaf")return M;if(r.tag==="Node")return Zt("Node",r._1,r._2,r._3,void 0,n(r._5),n(r._6));g()};return Bt(fn.foldr,n(t.layout.nodes))})())),MT=t=>e=>n=>r=>o=>{const i=La(e)(n)(a=>a.target.tag==="EdgeWindow"&&a.target._2.tag==="Retract"&&a.target._1===o);if(i.tag==="Just"){const a=Mo(t.timing.edgeEasing)(qo(i._1)(n)),s=i._1.target.tag==="EdgeWindow"?i._1.target._2:Is("Extend",sg);if(s.tag==="Retract")return Mi("Retracting",s._1,a);if(s.tag==="Extend")return Mi("Extending",s._1,a);g()}if(i.tag==="Nothing"){if(LT(e)(n)(o))return ug;const a=La(e)(n)(s=>s.target.tag==="EdgeWindow"&&s.target._1===o);if(a.tag==="Just"){const s=Mo(t.timing.edgeEasing)(qo(a._1)(n)),u=a._1.target.tag==="EdgeWindow"?a._1.target._2:Is("Extend",sg);if(u.tag==="Retract")return Mi("Retracting",u._1,s);if(u.tag==="Extend")return Mi("Extending",u._1,s);g()}if(a.tag==="Nothing")return RT(e)(n)(o)?ug:dT(o)(r)?Rf:ug}g()},QT=t=>e=>n=>{const r=Df(e)(n);return hT(V(o=>S(o,MT(t)(e.windows)(n)(r)(o)))((()=>{const o=i=>{if(i.tag==="Leaf")return M;if(i.tag==="Node")return Zt("Node",i._1,i._2,i._3,void 0,o(i._5),o(i._6));g()};return Bt(fn.foldr,o(e.layout.edges))})()))},WT=t=>e=>n=>r=>{const o=La(t)(e)(i=>i.target.tag==="NodeWindow"&&i.target._1===r&&i.target._2==="PlopOut");if(o.tag==="Just"){const i=qo(o._1)(e),a=o._1.target.tag==="NodeWindow"?o._1.target._2:rg;if(a==="PlopIn")return Qi("PloppingIn",i);if(a==="PlopOut")return Qi("PloppingOut",i);g()}if(o.tag==="Nothing"){if(PT(t)(e)(r))return ag;const i=La(t)(e)(a=>a.target.tag==="NodeWindow"&&a.target._1===r);if(i.tag==="Just"){const a=qo(i._1)(e),s=i._1.target.tag==="NodeWindow"?i._1.target._2:rg;if(s==="PlopIn")return Qi("PloppingIn",a);if(s==="PlopOut")return Qi("PloppingOut",a);g()}if(i.tag==="Nothing")return GT(t)(e)(r)?ag:pT(r)(n)?Gf:ag}g()},HT=t=>e=>{const n=Ff(t)(e);return Qf(V(r=>S(r,WT(t.windows)(e)(n)(r)))((()=>{const r=o=>{if(o.tag==="Leaf")return M;if(o.tag==="Node")return Zt("Node",o._1,o._2,o._3,void 0,r(o._5),r(o._6));g()};return Bt(fn.foldr,r(t.layout.nodes))})()))},OT=t=>e=>n=>e.target.tag==="TokenWindow"?S(e.target._1,n<e.startT?ig:n>=e.endT?Ef:Fs("Travelling",{edge:e.target._2,direction:e.target._3,progress:Mo(t.timing.tokenEasing)(qo(e)(n)),labels:e.target._6,source:e.target._4,target:e.target._5,holdPre:e.target._7,holdPost:e.target._8})):e.target.tag==="FillWindow"?S(e.target._1,n<e.startT?ig:n>=e.endT?Ef:Fs("Filling",{node:e.target._2,progress:qo(e)(n),labels:e.target._3})):S("",ig),qT=t=>e=>n=>mT(V(r=>OT(t)(r)(n))(gt(r=>r.target.tag==="TokenWindow"||r.target.tag==="FillWindow",e))),VT=t=>e=>n=>({animationTime:n,nodes:HT(e)(n),nodeLabels:BT(e)(n),edgeEndpoints:e.edgeEndpoints,edges:QT(t)(e)(n),tokens:qT(t)(e.windows)(n),camera:Wo(t.cameraConfig)(e.layout)(t.cameraSpans)(n).camera,frameTitle:AT(e)(n),staticKind:IT(e)(n),visited:bT(t.timing.hatchHold)(e.windows)(n),nodeFadeAlpha:M,nodeLabelFadeAlpha:M,edgeFadeAlpha:M,nodeInvert:M}),Hi=t=>e=>n=>r=>({segment:n,state:VT(t)(n)(e),bgAlpha:1,minis:$T(t)(e)(n),role:r}),$T=t=>e=>n=>Tt(r=>{const o=Bs(t)(wt(n.path)(r))(e);if(o.tag==="Just")return J("Just",{...Hi(t)(yT(o._1.startT)(o._1.endT-1e-4)(e))(o._1)(Hf),bgAlpha:0});if(o.tag==="Nothing")return T;g()})((()=>{const r=o=>{if(o.tag==="Leaf")return M;if(o.tag==="Node")return Zt("Node",o._1,o._2,o._3,void 0,r(o._5),r(o._6));g()};return Bt(fn.foldr,r(n.layout.nodes))})()),UT=t=>e=>{if(t.direction==="DiveIn")return Of(e);if(t.direction==="DiveOut")return t.startT-1e-4;g()},Xf=t=>e=>Tt(n=>{const r=ne(o=>o.direction==="DiveIn"&&zs.eq(o.childPath)((()=>{const i=n.length+1|0;return i<1?[]:Rt(0,i,e)})()))(t.dives);if(r.tag==="Just"){const o=Bs(t)(n)(r._1.startT-1e-4);if(o.tag==="Just")return J("Just",(()=>{const i=Hi(t)(r._1.startT-1e-4)(o._1)(Hf);return{...i,state:{...i.state,nodeFadeAlpha:Zt("Node",1,1,r._1.node,0,M,M)}}})());if(o.tag==="Nothing")return T;g()}if(r.tag==="Nothing")return T;g()})(JT(e)),Yf=t=>e=>{const n=gt(o=>e>=o.startT&&e<o.endT,t.segments),r=n.length-1|0;return r>=0&&r<n.length?n[r]:NT(t)},XT=t=>e=>n=>r=>{const o=s=>{const u=Hi(t)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT;g()})())(s)(TT);return{...u,bgAlpha:1,minis:gt(c=>!zs.eq(c.segment.path)(n.childPath),u.minis),state:{...u.state,edgeFadeAlpha:M,nodeFadeAlpha:Zt("Node",1,1,n.node,0,M,M),nodeInvert:M,tokens:M}}},i=Bs(t)(n.parentPath)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT;g()})()),a=Bs(t)(n.childPath)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})());return[...Xf(t)(n.parentPath),...(()=>{if(i.tag==="Just"){if(a.tag==="Just")return[o(i._1),{...Hi(t)(UT(n)(a._1))(a._1)(an),bgAlpha:1}];if(a.tag==="Nothing")return[o(i._1)];g()}if(i.tag==="Nothing")return[Hi(t)(e)(Yf(t)(e))(an)];g()})()]},YT=t=>e=>ne(n=>e>=n.startT&&e<n.endT)(t.dives),KT=t=>e=>{const n=Yf(t)(e),r=t.dives.length!==0,o=Wo(t.cameraConfig)(t.layout)(t.cameraSpans)(e).camera,i=Xf(t)(n.path),a=Hi(t)(n.path.length===0?e:Er(e)(Of(n)))(n)(an),s={...a,state:{...a.state,camera:o}},u=YT(t)(e);if(u.tag==="Just"){const c=Vf(u._1)(e);return{levels:XT(t)(e)(u._1)(DT(t)(e)(u._1)),camera:o,rootLayout:t.layout,hasDives:r,portalState:(()=>{if(u._1.direction==="DiveIn")return Ds("Opening",Er(0)(ka(1)(c)));if(u._1.direction==="DiveOut")return Ds("Closing",Er(0)(ka(1)(c)));g()})()}}if(u.tag==="Nothing")return{levels:wt(i)(s),camera:o,rootLayout:t.layout,hasDives:r,portalState:n.path.length===0?Wf:xT};g()},jT=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ZT=t=>{const e=t.length;return(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(u>=e){a=!1,s=c;continue}const _=f=>l=>{let d=f,h=l,p=!0,m;for(;p;){const x=d,y=h;if(x>=e){p=!1,m=y;continue}if(u>=0&&u<t.length){if(x>=0&&x<t.length){d=x+1|0,h=(()=>{const w=t[u].position,N=t[u].size,b=t[x].position,C=t[x].size;return w._1<b._1+C._1&&b._1<w._1+N._1&&w._2<b._2+C._2&&b._2<w._2+N._2})()?y+1|0:y;continue}d=x+1|0,h=y;continue}p=!1,m=y}return m};o=u+1|0,i=_(u+1|0)(c)}return s})(0)(0)},Kf=t=>v(e=>n=>e+qy(n.start)(n.end))(0)(t.segments),tw=t=>e=>n=>({crossingCount:v(r=>o=>r+o.jumps.length|0)(0)(e),bendCount:v(r=>o=>r+o.bends.length|0)(0)(e),totalEdgeLength:v(r=>o=>r+Kf(o))(0)(e),maxEdgeLength:v(r=>o=>jT(r)(Kf(o)))(0)(e),nodeOverlapCount:ZT(t),constraintViolations:n,jumpCount:v(r=>o=>r+o.jumps.length|0)(0)(e)}),hg=t=>t,de=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},pg=hg("LEFT"),ew=hg("RIGHT"),jf=hg("UNDEFINED"),nw={eq:t=>e=>t==="LEFT"?e==="LEFT":t==="RIGHT"?e==="RIGHT":t==="UP"?e==="UP":t==="DOWN"?e==="DOWN":t==="UNDEFINED"&&e==="UNDEFINED"},rw={compare:t=>e=>{if(t==="LEFT")return e==="LEFT"?nn:Be;if(e==="LEFT")return Me;if(t==="RIGHT")return e==="RIGHT"?nn:Be;if(e==="RIGHT")return Me;if(t==="UP")return e==="UP"?nn:Be;if(e==="UP")return Me;if(t==="DOWN")return e==="DOWN"?nn:Be;if(e==="DOWN")return Me;if(t==="UNDEFINED"&&e==="UNDEFINED")return nn;g()},Eq0:()=>nw},ow=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){if(t==="LEFT"){if(i._3==="LEFT"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="LEFT"){n=i._6;continue}if(t==="RIGHT"){if(i._3==="RIGHT"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="RIGHT"){n=i._6;continue}if(t==="UP"){if(i._3==="UP"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="UP"){n=i._6;continue}if(t==="DOWN"){if(i._3==="DOWN"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="DOWN"){n=i._6;continue}if(t==="UNDEFINED"&&i._3==="UNDEFINED"){r=!1,o=!0;continue}}g()}return o},iw={x:0,y:0},Gn=t=>e=>n=>{const r=de(t)(n.cNodes);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cNodes:it(ut)(t)(e(r._1))(n.cNodes)};g()},Sa=t=>e=>n=>{const r=de(t)(n.cGroups);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cGroups:it(ut)(t)(e(r._1))(n.cGroups)};g()},aw=t=>v(e=>n=>Gn(n)(r=>({...r,hitboxPreCompaction:r.hitbox}))(e))(t)(t.cNodeOrder),sw=t=>{const e=v(n=>r=>{const o=de(r)(t.cNodes);if(o.tag==="Nothing")return n;if(o.tag==="Just")return v(i=>a=>Mt(ut)(xe)(a)([r])(i))(n)(o._1.constraints);g()})(M)(t.cNodeOrder);return v(n=>r=>Gn(r)(o=>({...o,constraints:(()=>{const i=de(r)(e);if(i.tag==="Nothing")return[];if(i.tag==="Just")return i._1;g()})()}))(n))(t)(t.cNodeOrder)},uw=t=>e=>Gn(t)(n=>({...n,ignoreSpacing:{left:n.ignoreSpacing.left||e.left,right:n.ignoreSpacing.right||e.right,up:n.ignoreSpacing.up||e.up,down:n.ignoreSpacing.down||e.down}})),cw=t=>{const e=v(n=>r=>Sa(r)(o=>({...o,outDegree:o.outDegreeReal}))(n))(t)(t.cGroupOrder);return v(n=>r=>Gn(r)(o=>({...o,startPos:-1e308}))(n))(e)(e.cNodeOrder)},ir={left:!1,right:!1,up:!1,down:!1},gw={horizontalSpacing:t=>e=>0,verticalSpacing:t=>e=>0},mg=t=>v(e=>n=>{const r=de(n)(e.cGroups);if(r.tag==="Nothing")return e;if(r.tag==="Just"){const o=v(a=>s=>{const u=de(s)(e.cNodes);if(u.tag==="Nothing")return a;if(u.tag==="Just"){if(a.tag==="Nothing")return J("Just",s);if(a.tag==="Just"){const c=de(a._1)(e.cNodes);if(c.tag==="Nothing")return J("Just",s);if(c.tag==="Just")return u._1.hitbox.x<c._1.hitbox.x?J("Just",s):J("Just",a._1)}}g()})(T)(r._1.cNodes),i=Sa(n)(a=>({...a,reference:o}))(e);if(o.tag==="Nothing")return i;if(o.tag==="Just"){const a=de(o._1)(i.cNodes);if(a.tag==="Nothing")return i;if(a.tag==="Just"){const s=a._1;return v(u=>c=>Gn(c)(_=>({..._,cGroupOffset:{x:_.hitbox.x-s.hitbox.x,y:_.hitbox.y-s.hitbox.y}}))(u))(i)(r._1.cNodes)}}}g()})(t)(t.cGroupOrder),Rn=t=>mg({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return M;if(n.tag==="Node")return Zt("Node",n._1,n._2,n._3,{...n._4,hitbox:{...n._4.hitbox,x:-n._4.hitbox.x-n._4.hitbox.width}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),Pr=t=>mg({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return M;if(n.tag==="Node")return Zt("Node",n._1,n._2,n._3,{...n._4,hitbox:{x:n._4.hitbox.y,y:n._4.hitbox.x,width:n._4.hitbox.height,height:n._4.hitbox.width},cGroupOffset:{x:n._4.cGroupOffset.y,y:n._4.cGroupOffset.x}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),Zf=t=>{const e=v(n=>r=>Sa(r)(o=>({...o,outDegree:0,outDegreeReal:0,incomingConstraints:[]}))(n))(t)(t.cGroupOrder);return v(n=>r=>{const o=de(r)(n.cNodes);if(o.tag==="Nothing")return n;if(o.tag==="Just"){if(o._1.cGroup.tag==="Nothing")return n;if(o._1.cGroup.tag==="Just"){const i=o._1.cGroup._1;return v(a=>s=>{const u=de(s)(a.cNodes);if(u.tag==="Nothing")return a;if(u.tag==="Just")return u._1.cGroup.tag==="Just"&&u._1.cGroup._1!==i?Sa(u._1.cGroup._1)(c=>({...c,outDegree:c.outDegree+1|0,outDegreeReal:c.outDegreeReal+1|0}))(Sa(i)(c=>gn(ro)(s)(c.incomingConstraints)?c:{...c,incomingConstraints:[...c.incomingConstraints,s]})(a)):a;g()})(n)(o._1.constraints)}}g()})(e)(e.cNodeOrder)},Ms=t=>{const e=sw(t.cGraph);return{...t,cGraph:Zf(v(n=>r=>Gn(r)(o=>({...o,startPos:-1e308}))(n))(e)(e.cNodeOrder))}},_w=t=>e=>v(n=>r=>{if(t==="LEFT"||t==="UP"){const i=r._2;return Gn(r._1)(a=>({...a,constraints:[...a.constraints,i]}))(n)}const o=r._1;return Gn(r._2)(i=>({...i,constraints:[...i.constraints,o]}))(n)})(e)(t==="LEFT"||t==="RIGHT"?e.predefinedHorizontalConstraints:e.predefinedVerticalConstraints),ar=t=>{const e={...t,cGraph:_w(t.direction)({...t.cGraph,cNodes:(()=>{const n=r=>{if(r.tag==="Leaf")return M;if(r.tag==="Node")return Zt("Node",r._1,r._2,r._3,{...r._4,constraints:[]},n(r._5),n(r._6));g()};return n(t.cGraph.cNodes)})()})};return{...e,cGraph:Zf((()=>{if(e.constraintAlgorithm.tag==="Nothing")return e.cGraph;if(e.constraintAlgorithm.tag==="Just")return e.constraintAlgorithm._1(e);g()})())}},fw=t=>e=>n=>{const r={...n,direction:e};if(t==="UNDEFINED")return e==="LEFT"?ar(r):e==="RIGHT"?ar({...r,cGraph:Rn(r.cGraph)}):e==="UP"?ar({...r,cGraph:Pr(r.cGraph)}):e==="DOWN"?ar({...r,cGraph:Rn(Pr(r.cGraph))}):r;if(t==="LEFT")return e==="RIGHT"?Ms({...r,cGraph:Rn(r.cGraph)}):e==="UP"?ar({...r,cGraph:Pr(r.cGraph)}):e==="DOWN"?ar({...r,cGraph:Rn(Pr(r.cGraph))}):r;if(t==="RIGHT")return e==="LEFT"?Ms({...r,cGraph:Rn(r.cGraph)}):e==="UP"?ar({...r,cGraph:Pr(Rn(r.cGraph))}):e==="DOWN"?ar({...r,cGraph:Rn(Pr(Rn(r.cGraph)))}):r;if(t==="UP")return e==="LEFT"?ar({...r,cGraph:Pr(r.cGraph)}):e==="RIGHT"?ar({...r,cGraph:Rn(Pr(r.cGraph))}):e==="DOWN"?Ms({...r,cGraph:Rn(r.cGraph)}):r;if(t==="DOWN")return e==="LEFT"?ar({...r,cGraph:Pr(Rn(r.cGraph))}):e==="RIGHT"?ar({...r,cGraph:Rn(Pr(Rn(r.cGraph)))}):e==="UP"?Ms({...r,cGraph:Rn(r.cGraph)}):r;g()},tl=t=>e=>e.finished||!ow(t)(e.cGraph.supportedDirections)||(t==="LEFT"?e.direction==="LEFT":t==="RIGHT"?e.direction==="RIGHT":t==="UP"?e.direction==="UP":t==="DOWN"?e.direction==="DOWN":t==="UNDEFINED"&&e.direction==="UNDEFINED")?e:fw(e.direction)(t)(e),lw=t=>{if(t.finished)return t;const e=t.direction==="UNDEFINED"?tl(pg)(t):t,n={...e,cGraph:cw(e.cGraph)};if(n.compactionAlgorithm.tag==="Nothing")return n;if(n.compactionAlgorithm.tag==="Just")return n.compactionAlgorithm._1(n);g()},el=t=>e=>n=>{const r=de(t)(n.cNodes),o=de(e)(n.cGroups);return r.tag==="Just"&&o.tag==="Just"?(()=>{if(r._1.cGroup.tag==="Nothing")return!1;if(r._1.cGroup.tag==="Just")return!0;g()})()&&(r._1.cGroup.tag==="Nothing"||!(r._1.cGroup.tag==="Just"&&r._1.cGroup._1===e))?n:{...n,cNodes:it(ut)(t)({...r._1,cGroup:J("Just",e)})(n.cNodes),cGroups:it(ut)(e)({...o._1,cNodes:gn(ro)(t)(o._1.cNodes)?o._1.cNodes:[...o._1.cNodes,t],reference:(()=>{if(o._1.reference.tag==="Nothing")return J("Just",t);if(o._1.reference.tag==="Just")return J("Just",o._1.reference._1);g()})()})(n.cGroups)}:n},nl=t=>e=>({id:e.nextCNodeId,graph:{...e,cNodes:it(ut)(e.nextCNodeId)({id:e.nextCNodeId,origin:t.origin,kind:t.kind,cGroup:T,cGroupOffset:iw,hitbox:t.hitbox,hitboxPreCompaction:t.hitbox,constraints:[],startPos:-1e308,ignoreSpacing:ir})(e.cNodes),cNodeOrder:[...e.cNodeOrder,e.nextCNodeId],nextCNodeId:e.nextCNodeId+1|0}}),yg=t=>e=>{const n=e.nextCGroupId;return{id:n,graph:v(r=>o=>el(o)(n)(r))({...e,cGroups:it(ut)(n)({id:n,master:t.master,cNodes:[],startPos:-1e308,incomingConstraints:[],outDegree:0,outDegreeReal:0,reference:T,delta:0,deltaNormalized:0})(e.cGroups),cGroupOrder:[...e.cGroupOrder,n],nextCGroupId:n+1|0})(t.nodes)}},dw=t=>v(e=>n=>{const r=de(n)(e.cNodes);return r.tag==="Just"&&r._1.cGroup.tag==="Nothing"?yg({master:T,nodes:[n]})(e).graph:e})(t)(t.cNodeOrder),hw=t=>({cGraph:aw(dw(mg(t))),direction:jf,compactionAlgorithm:T,constraintAlgorithm:T,spacingsHandler:gw,lockFun:T,finished:!1}),pw=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},mw=t=>e=>{const n=at.compare(t._1)(e._1);return n==="LT"?Be:n==="GT"?Me:ut.compare(t._2)(e._2)},yw=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),rl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},ol=t=>t.kind.tag==="Nothing"?!1:t.kind.tag==="Just"&&t.kind._1==="vs",il=t=>t.kind.tag==="Nothing"||!(t.kind.tag==="Just"&&t.kind._1==="vs"),Qs=t=>e=>mw(S(t.hitbox.x+t.hitbox.width/2,t.id))(S(e.hitbox.x+e.hitbox.width/2,e.id)),xw=t=>e=>{const n=Or(Vt,T,r=>Qs(t)(r)==="LT",e);if(n.tag==="Just"){const r=I1(Vt,T,n._1,t,e);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return wt(e)(t);g()},al=t=>e=>{const n=gt(o=>Qs(o)(t)==="LT",e),r=n.length-1|0;return r>=0&&r<n.length?J("Just",n[r]):T},Tw=t=>e=>{const n=xw(e)(t.intervals),r=ne(i=>Qs(e)(i)==="LT")(n),o=it(ut)(e.id)((()=>{const i=al(e)(n);return i.tag==="Just"?J("Just",i._1.id):T})())(t.cand);return{...t,intervals:n,cand:(()=>{if(r.tag==="Just")return it(ut)(r._1.id)(J("Just",e.id))(o);if(r.tag==="Nothing")return o;g()})()}},ww=t=>e=>{const n=at.compare(t.low?t.node.hitbox.y:t.node.hitbox.y+t.node.hitbox.height)(e.low?e.node.hitbox.y:e.node.hitbox.y+e.node.hitbox.height);return n==="EQ"?t.low?t.low&&!e.low?Me:nn:e.low?Be:nn:n},Nw=t=>v(e=>n=>Gn(n.id)(r=>({...r,constraints:[]}))(e))(t)(Tt(e=>de(e)(t.cNodes))(t.cNodeOrder)),xg=t=>e=>v(n=>r=>{const o=de(r._1)(n.cNodes);if(o.tag==="Just")return Gn(r._1)(i=>({...i,constraints:[...i.constraints,...r._2]}))(n);if(o.tag==="Nothing")return n;g()})(e)(yw(t)),sl=t=>e=>e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?e.ignoreSpacing.up?e.ignoreSpacing.down?e:{...e,hitbox:{...e.hitbox,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t-.01,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t,height:e.hitbox.height+2*t}},ul=t=>e=>n=>v(r=>o=>n(o)?Gn(o.id)(sl(t))(r):r)(e)(Tt(r=>de(r)(e.cNodes))(e.cNodeOrder)),Jw=t=>e=>{const n=(r,o,i)=>{const a=Gn(i)(sl(t))(r);return o.length<=1?a:v(s=>u=>u===i?s:Gn(u)(c=>c.ignoreSpacing.up?{...c,hitbox:{...c.hitbox,y:c.hitbox.y+t+.01,height:c.hitbox.height-t-.01}}:c.ignoreSpacing.down?{...c,hitbox:{...c.hitbox,height:c.hitbox.height-t-.01}}:c)(s))(a)(o)};return v(r=>o=>{if(o.master.tag==="Nothing")return 0<o.cNodes.length?n(r,o.cNodes,o.cNodes[0]):r;if(o.master.tag==="Just")return n(r,o.cNodes,o.master._1);g()})(e)(Tt(r=>de(r)(e.cGroups))(e.cGroupOrder))},vw=t=>e=>{const n=al(e)(t.intervals),r=ne(i=>Qs(e)(i)==="LT")(t.intervals),o=n.tag==="Just"&&(()=>{const i=rl(e.id)(t.cand);return(i.tag==="Nothing"?!1:i.tag==="Just"&&(i._1.tag==="Nothing"?!1:i._1.tag==="Just"&&i._1._1===n._1.id))&&n._1.cGroup.tag==="Just"&&e.cGroup.tag==="Just"&&n._1.cGroup._1!==e.cGroup._1})()?Mt(ut)(xe)(n._1.id)([e.id])(t.constraints):t.constraints;return{...t,constraints:r.tag==="Just"&&(()=>{const i=rl(r._1.id)(t.cand);return(i.tag==="Nothing"?!1:i.tag==="Just"&&(i._1.tag==="Nothing"?!1:i._1.tag==="Just"&&i._1._1===e.id))&&e.cGroup.tag==="Just"&&r._1.cGroup.tag==="Just"&&e.cGroup._1!==r._1.cGroup._1})()?Mt(ut)(xe)(e.id)([r._1.id])(o):o,intervals:gt(i=>i.id!==e.id,t.intervals)}},Cw=t=>e=>e.low?Tw(t)(e.node):vw(t)(e.node),Tg=t=>e=>v(Cw)({intervals:[],cand:M,constraints:M})(Gt(ww)(Et(gt(t,Tt(n=>de(n)(e.cNodes))(e.cNodeOrder)))(n=>[{node:n,low:!0},{node:n,low:!1}]))).constraints,bw=t=>e=>{const n=pw(0)(t/2-.5),r=xg(Tg(ol)(ul(n)(e)(ol)))(e),o=xg(Tg(il)(ul(n)(r)(il)))(r);return xg(Tg(i=>!0)(Jw(n)(o)))(o)},kw=t=>e=>bw(t)(Nw(e.cGraph)),Ws=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},cl=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},wg=t=>e=>n=>r=>o=>({id:t,representedEdges:[o],affectedBends:[e,n],hitbox:{x:Ws(e._1)(n._1),y:Ws(e._2)(n._2),width:re(e._1-n._1),height:re(e._2-n._2)},ignoreSpacing:ir,potentialGroupParents:(()=>{if(r.tag==="Nothing")return[];if(r.tag==="Just")return[r._1];g()})(),aPort:T}),Lw=t=>e=>{const n=Ws(t.hitbox.x)(e.hitbox.x),r=Ws(t.hitbox.y)(e.hitbox.y);return{...t,representedEdges:[...t.representedEdges,...e.representedEdges],affectedBends:[...t.affectedBends,...e.affectedBends],potentialGroupParents:[...t.potentialGroupParents,...e.potentialGroupParents],hitbox:{x:n,y:r,width:cl(t.hitbox.x+t.hitbox.width)(e.hitbox.x+e.hitbox.width)-n,height:cl(t.hitbox.y+t.hitbox.height)(e.hitbox.y+e.hitbox.height)-r},ignoreSpacing:{left:t.ignoreSpacing.left||e.ignoreSpacing.left,right:t.ignoreSpacing.right||e.ignoreSpacing.right,up:t.ignoreSpacing.up||e.ignoreSpacing.up,down:t.ignoreSpacing.down||e.ignoreSpacing.down},aPort:(()=>{if(t.aPort.tag==="Just")return t.aPort;if(t.aPort.tag==="Nothing")return e.aPort;g()})()}},Sw=t=>e=>re(t.hitbox.x-e.hitbox.x)<=1e-4&&e.hitbox.y-(t.hitbox.y+t.hitbox.height)<=1e-4&&t.hitbox.y-(e.hitbox.y+e.hitbox.height)<=1e-4,Ew=t=>e=>re(t.hitbox.x-e.hitbox.x)<=1e-4?at.compare(t.hitbox.y)(e.hitbox.y):t.hitbox.x<e.hitbox.x?Be:Me,gl=(t,e)=>({tag:t,_1:e}),Ng=fe(R)(Wt),Hs=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},_l=(()=>{const t={eq:n=>r=>n._1===r._1&&(n._2.tag==="Nothing"?r._2.tag==="Nothing":n._2.tag==="Just"&&r._2.tag==="Just"&&n._2._1===r._2._1)},e={compare:n=>r=>{const o=R.compare(n._1)(r._1);if(o==="LT")return Be;if(o==="GT")return Me;if(n._2.tag==="Nothing")return r._2.tag==="Nothing"?nn:Be;if(r._2.tag==="Nothing")return Me;if(n._2.tag==="Just"&&r._2.tag==="Just")return R.compare(n._2._1)(r._2._1);g()},Eq0:()=>t};return v(n=>r=>it(e)(r)()(n))(M)})(),$r=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Pw=v(t=>e=>it(rw)(e)()(t))(M),Jg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=_f.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Gw=t=>e=>{const n=Ng(V(i=>S(i.id,i))(t)),r=Tt(i=>Hs(i)(n))(e),o=ut.compare((()=>{const i=_l(V(a=>S(a.from.node,a.from.port))(r));if(i.tag==="Leaf")return 0;if(i.tag==="Node")return i._2;g()})())((()=>{const i=_l(V(a=>S(a.to.node,a.to.port))(r));if(i.tag==="Leaf")return 0;if(i.tag==="Node")return i._2;g()})());if(o==="LT")return{...ir,left:!0,right:!1};if(o==="GT")return{...ir,left:!1,right:!0};if(o==="EQ")return ir;g()},Rw=t=>Tt(e=>{if(e.direction==="V")return J("Just",{start:e.start,end:e.end});if(e.direction==="H")return T;g()})(t.segments),Os=t=>e=>n=>r=>{if(r.tag==="Just"){const o=$r(n)(e);if(o.tag==="Just"){const i=ne(a=>a.id===r._1)(o._1);if(i.tag==="Just")return i._1.side;if(i.tag==="Nothing")return t;g()}if(o.tag==="Nothing")return t;g()}if(r.tag==="Nothing")return t;g()},Aw=t=>e=>n=>{const r=nl({origin:J("Just",gl("SegmentOrigin",n)),kind:J("Just","vs"),hitbox:n.hitbox})(e.cGraph),o=uw(r.id)(n.ignoreSpacing)(r.graph);return{...e,cGraph:(()=>{if(0<n.potentialGroupParents.length){const i=de(n.potentialGroupParents[0])(o.cNodes);if(i.tag==="Just"){if(i._1.cGroup.tag==="Just")return el(r.id)(i._1.cGroup._1)(o);if(i._1.cGroup.tag==="Nothing")return o;g()}if(i.tag==="Nothing")return o;g()}return yg({master:J("Just",r.id),nodes:[r.id]})(o).graph})(),edgeToCs:v(i=>a=>Mt(R)(xe)(a)([r.id])(i))(e.edgeToCs)(n.representedEdges),lockMap:it(ut)(r.id)(Gw(t)(n.representedEdges))(e.lockMap)}},Iw=t=>e=>n=>{const r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),Gt(Ew)(e));if(r.tag==="Nothing")return n;if(r.tag==="Just"){const o=v(i=>a=>Sw(i.survivor)(a)?{...i,survivor:Lw(i.survivor)(a)}:{survivor:a,merged:[...i.merged,i.survivor]})({survivor:r._1.head,merged:[]})(r._1.tail);return v(Aw(t))(n)([...o.merged,o.survivor])}g()},Fw=t=>({cGraph:{cNodes:M,cNodeOrder:[],cGroups:M,cGroupOrder:[],supportedDirections:Pw([jf,pg,ew]),predefinedHorizontalConstraints:[],predefinedVerticalConstraints:[],nextCNodeId:0,nextCGroupId:0},nodeToC:M,edgeToCs:M,lockMap:M}),Dw=t=>{const e=rt(4);return{x:t.position._1*e,y:t.position._2*e,width:t.size._1*e,height:t.size._2*e}},zw=t=>e=>n=>v(r=>o=>{const i=nl({origin:J("Just",gl("NodeOrigin",o.node)),kind:T,hitbox:Dw(o)})(r.cGraph),a=$r(o.node)(t),s=(()=>{if(a.tag==="Nothing")return S(0,0);if(a.tag==="Just")return a._1;g()})();return{...r,cGraph:yg({master:J("Just",i.id),nodes:[i.id]})(i.graph).graph,nodeToC:it(R)(o.node)(i.id)(r.nodeToC),lockMap:it(ut)(i.id)((()=>{const u=s._1-s._2|0;return u<0?{...ir,left:!0}:u>0?{...ir,right:!0}:ir})())(r.lockMap)}})(n)(e),Bw=t=>v(e=>n=>Mt(R)(r=>o=>S(r._1+o._1|0,r._2+o._2|0))(n.to.node)(S(1,0))(Mt(R)(r=>o=>S(r._1+o._1|0,r._2+o._2|0))(n.from.node)(S(0,1))(e)))(M)(t),Mw=t=>v(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?it(R)(n.origin._1._1)(n.hitbox.x)(e):e)(M)(Tt(e=>de(e)(t.cNodes))(t.cNodeOrder)),Qw=t=>v(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?it(R)(n.origin._1._1)(n.hitbox.x-n.hitboxPreCompaction.x)(e):e)(M)(Tt(e=>de(e)(t.cNodes))(t.cNodeOrder)),Ww=t=>v(e=>n=>{if(n.origin.tag==="Just"&&n.origin._1.tag==="SegmentOrigin"){const r=n.hitbox.x-n.hitboxPreCompaction.x;return v(o=>i=>it(_f)(i)(r)(o))(e)(n.origin._1._1.affectedBends)}return e})(M)(Tt(e=>de(e)(t.cNodes))(t.cNodeOrder)),fl=t=>{const e=Ng(V(n=>S(n.id,n))(t.edges));return Tt(n=>{const r=Hs(n.edge)(e);if(r.tag==="Just")return n.reversed?J("Just",{edgeId:n.edge,src:r._1.to.node,tgt:r._1.from.node,srcSide:Os(qr)(t.ports)(r._1.to.node)(r._1.to.port),tgtSide:Os(Vr)(t.ports)(r._1.from.node)(r._1.from.port),path:n}):J("Just",{edgeId:n.edge,src:r._1.from.node,tgt:r._1.to.node,srcSide:Os(qr)(t.ports)(r._1.from.node)(r._1.from.port),tgtSide:Os(Vr)(t.ports)(r._1.to.node)(r._1.to.port),path:n});if(r.tag==="Nothing")return T;g()})(t.paths)},Hw=t=>e=>{const n=Et(e)(r=>{if(r.src===r.tgt)return[];if((r.srcSide==="North"||r.srcSide==="South")&&(r.tgtSide==="North"||r.tgtSide==="South"))return[];const o=$r(r.tgt)(t.nodeToC),i=(()=>{if(o.tag==="Just")return de(o._1)(t.cGraph.cNodes);if(o.tag==="Nothing")return T;g()})(),a=$r(r.src)(t.nodeToC),s=(()=>{if(a.tag==="Just")return de(a._1)(t.cGraph.cNodes);if(a.tag==="Nothing")return T;g()})(),u=(()=>{if(s.tag==="Just"){if(i.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(i._1.cGroup.tag==="Just")return J("Just",{srcGroup:s._1.cGroup._1,tgtGroup:i._1.cGroup._1,delta:0,weight:100});if(i._1.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(i.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()})(),c=d=>h=>p=>{if(s.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(p.cGroup.tag==="Just")return d(p.hitbox.x)&&p.cGroup._1!==s._1.cGroup._1?J("Just",h(p.cGroup._1)(s._1.cGroup._1)):T;if(p.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()},_=Tt(d=>de(d)(t.cGraph.cNodes))((()=>{const d=Hs(r.edgeId)(t.edgeToCs);if(d.tag==="Nothing")return[];if(d.tag==="Just")return d._1;g()})()),f=(()=>{if(s.tag==="Just"&&r.srcSide==="West"){const d=s._1;return Tt(c(h=>h<d.hitbox.x)(h=>p=>({srcGroup:h,tgtGroup:p,delta:1,weight:100})))(_)}return[]})(),l=(()=>{if(s.tag==="Just"&&r.tgtSide==="East"){const d=s._1;return Tt(c(h=>h>d.hitbox.x)(h=>p=>({srcGroup:p,tgtGroup:h,delta:1,weight:100})))(_)}return[]})();if(u.tag==="Nothing")return[];if(u.tag==="Just")return[u._1,...f,...l];g()});return{sameEdgeVerticalSegments:r=>o=>r.origin.tag==="Just"&&r.origin._1.tag==="SegmentOrigin"&&o.origin.tag==="Just"&&o.origin._1.tag==="SegmentOrigin"&&(()=>{const i=o.origin._1._1;return ue(a=>gn(vr)(a)(i.representedEdges),r.origin._1._1.representedEdges)})(),vsLNodePair:r=>o=>r.origin.tag==="Just"&&o.origin.tag==="Just"&&(r.origin._1.tag==="SegmentOrigin"?o.origin._1.tag==="NodeOrigin":r.origin._1.tag==="NodeOrigin"&&o.origin._1.tag==="SegmentOrigin"),edgeLengthEdges:r=>n}},Ow=t=>e=>{const n=rt(4),r=Mw(t),o=Qw(t),i=Ng(V(s=>S(s.id,S(s.from.node,s.to.node)))(e.edges)),a=Ww(t);return{nodes:V(s=>{const u=$r(s.node)(r);if(u.tag==="Just")return{...s,position:S(u._1/n,s.position._2)};if(u.tag==="Nothing")return s;g()})(e.nodes),edges:V(s=>{const u=Hs(s.edge)(i),c=(()=>{if(u.tag==="Nothing")return s.segments;if(u.tag==="Just"){const _=$r(u._1._1)(o),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})(),l=$r(u._1._2)(o),d=(()=>{if(l.tag==="Nothing")return 0;if(l.tag==="Just")return l._1;g()})();return Ht((()=>{const h=s.reversed?d:f,p=s.reversed?f:d,m=s.segments.length;return x=>y=>{if(y.direction==="V"){const w=(()=>{if(x===0)return h;if(x===(m-1|0))return p;const N=Jg(y.start)(a);if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})();return{...y,start:S(y.start._1+w,y.start._2),end:S(y.end._1+w,y.end._2)}}if(y.direction==="H")return{...y,start:S((()=>{if(x===0)return y.start._1+h;const w=Jg(y.start)(a);if(w.tag==="Nothing")return y.start._1+0;if(w.tag==="Just")return y.start._1+w._1;g()})(),y.start._2),end:S((()=>{if(x===(m-1|0))return y.end._1+p;const w=Jg(y.end)(a);if(w.tag==="Nothing")return y.end._1+0;if(w.tag==="Just")return y.end._1+w._1;g()})(),y.end._2)};g()}})())(s.segments)}g()})();return{...s,segments:c,bends:Oe(_=>f=>_.end,c,Rt(1,c.length,c))}})(e.paths)}},qw=t=>e=>n=>r=>o=>i=>{const a=wg(o.nextId)(i._2.start)(i._2.end)(T)(t.edgeId),s=(()=>{if(i._1===0){if(e.tag==="Nothing")return a;if(e.tag==="Just")return{...a,ignoreSpacing:i._2.end._2<e._1.y?{...a.ignoreSpacing,down:!0}:i._2.end._2>e._1.y+e._1.height?{...a.ignoreSpacing,up:!0}:{...a.ignoreSpacing,up:!0,down:!0}};g()}return a})();return{nextId:o.nextId+1|0,segments:[...o.segments,(()=>{if(i._1===r){if(n.tag==="Nothing")return s;if(n.tag==="Just")return{...s,ignoreSpacing:i._2.start._2<n._1.y?{...s.ignoreSpacing,down:!0}:i._2.start._2>n._1.y+n._1.height?{...s.ignoreSpacing,up:!0}:{...s.ignoreSpacing,up:!0,down:!0}};g()}return s})()]}},ll=t=>e=>n=>r=>o=>i=>({nextId:i.nextId+1|0,segments:[...i.segments,{...wg(i.nextId)(r.start)(S(r.start._1,o.down?n.y:n.y+n.height))(J("Just",e))(t.edgeId),aPort:J("Just",{node:t.src,side:o.side}),ignoreSpacing:o.down?{...ir,down:!0}:{...ir,up:!0}}]}),qs=t=>e=>n=>r=>o=>i=>({nextId:i.nextId+1|0,segments:[...i.segments,{...wg(i.nextId)(r.end)(S(r.end._1,o.down?n.y:n.y+n.height))(J("Just",e))(t.edgeId),aPort:J("Just",{node:t.tgt,side:o.side}),ignoreSpacing:o.down?{...ir,down:!0}:{...ir,up:!0}}]}),Vw=t=>e=>n=>{if(n.src===n.tgt)return e;const r=$r(n.src)(t.nodeToC),o=$r(n.tgt)(t.nodeToC),i=(()=>{if(r.tag==="Just"){const _=de(r._1)(t.cGraph.cNodes);return _.tag==="Just"?J("Just",_._1.hitbox):T}if(r.tag==="Nothing")return T;g()})(),a=(()=>{if(o.tag==="Just"){const _=de(o._1)(t.cGraph.cNodes);return _.tag==="Just"?J("Just",_._1.hitbox):T}if(o.tag==="Nothing")return T;g()})(),s=Rw(n.path),u=v(qw(n)(i)(a)(s.length-1|0))(e)(Ht(_=>f=>S(_,f))(s));if(0<s.length){const _=(()=>{if(r.tag==="Just"&&i.tag==="Just"){if(n.srcSide==="North")return ll(n)(r._1)(i._1)(s[0])({side:Re,down:!0})(u);if(n.srcSide==="South")return ll(n)(r._1)(i._1)(s[0])({side:Ae,down:!1})(u)}return u})(),f=s.length-1|0;if(f>=0&&f<s.length&&o.tag==="Just"&&a.tag==="Just"){if(n.tgtSide==="North")return qs(n)(o._1)(a._1)(s[f])({side:Re,down:!0})(_);if(n.tgtSide==="South")return qs(n)(o._1)(a._1)(s[f])({side:Ae,down:!1})(_)}return _}const c=s.length-1|0;if(c>=0&&c<s.length&&o.tag==="Just"&&a.tag==="Just"){if(n.tgtSide==="North")return qs(n)(o._1)(a._1)(s[c])({side:Re,down:!0})(u);if(n.tgtSide==="South")return qs(n)(o._1)(a._1)(s[c])({side:Ae,down:!1})(u)}return u},$w=t=>e=>n=>Iw(t)(v(Vw(n))({nextId:0,segments:[]})(e).segments)(n),Uw=t=>$w(t.edges)(fl(t))(zw(Bw(t.edges))(t.nodes)(Fw())),Ur=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},vg=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Cg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Xw=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Yw=t=>{const e=t.Eq0();return n=>r=>{const o=s=>{let u=s,c=!0,_;for(;c;){const f=u,l=Pt(d=>T,d=>h=>J("Just",{head:d,tail:h}),f.queue);if(l.tag==="Nothing"){c=!1,_=f;continue}if(l.tag==="Just"){const d=l._1.head;if((p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=!1;continue}if(w.tag==="Node"){const N=t.compare(d)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=!0;continue}}g()}return y})(f.removedNodes)){u={...f,queue:l._1.tail};continue}const h=ne(p=>!Ur(p.eid)(f.removedEdges)&&(e.eq(p.src)(d)||e.eq(p.tgt)(d)))(r);if(h.tag==="Nothing"){u={...f,queue:l._1.tail};continue}if(h.tag==="Just"){const p=e.eq(h._1.src)(d)?h._1.tgt:h._1.src,m={...f,degree:it(t)(p)((()=>{const x=(y=>{let w=y,N=!0,b;for(;N;){const C=w;if(C.tag==="Leaf"){N=!1,b=T;continue}if(C.tag==="Node"){const L=t.compare(p)(C._3);if(L==="LT"){w=C._5;continue}if(L==="GT"){w=C._6;continue}if(L==="EQ"){N=!1,b=J("Just",C._4);continue}}g()}return b})(f.degree);if(x.tag==="Nothing")return-1;if(x.tag==="Just")return x._1-1|0;g()})())(f.degree),removedNodes:it(t)(d)()(f.removedNodes),removedEdges:it(ut)(h._1.eid)()(f.removedEdges),record:[...f.record,{node:d,neighbour:p,viaSrc:e.eq(h._1.src)(d)}],queue:l._1.tail};if((()=>{const x=(w=>{let N=w,b=!0,C;for(;b;){const L=N;if(L.tag==="Leaf"){b=!1,C=T;continue}if(L.tag==="Node"){const E=t.compare(p)(L._3);if(E==="LT"){N=L._5;continue}if(E==="GT"){N=L._6;continue}if(E==="EQ"){b=!1,C=J("Just",L._4);continue}}g()}return C})(m.degree),y=w=>{let N=w,b=!0,C;for(;b;){const L=N;if(L.tag==="Leaf"){b=!1,C=!1;continue}if(L.tag==="Node"){const E=t.compare(p)(L._3);if(E==="LT"){N=L._5;continue}if(E==="GT"){N=L._6;continue}if(E==="EQ"){b=!1,C=!0;continue}}g()}return C};return(()=>{if(x.tag==="Nothing")return!1;if(x.tag==="Just")return x._1===1;g()})()&&!y(m.removedNodes)})()){u={...m,queue:[...m.queue,p]};continue}u=m;continue}}g()}return _},i=v(s=>u=>Mt(t)(ve)(u.src)(1)(Mt(t)(ve)(u.tgt)(1)(s)))(M)(r),a=o({degree:i,removedNodes:M,removedEdges:M,record:[],queue:gt(s=>{const u=(c=>{let _=c,f=!0,l;for(;f;){const d=_;if(d.tag==="Leaf"){f=!1,l=T;continue}if(d.tag==="Node"){const h=t.compare(s)(d._3);if(h==="LT"){_=d._5;continue}if(h==="GT"){_=d._6;continue}if(h==="EQ"){f=!1,l=J("Just",d._4);continue}}g()}return l})(i);if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1===1;g()},n)});return{coreNodes:gt(s=>!(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=!1;continue}if(l.tag==="Node"){const d=t.compare(s)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=!0;continue}}g()}return f})(a.removedNodes),n),coreEdges:gt(s=>!Ur(s.eid)(a.removedEdges),r),removed:a.record}}},Kw=t=>e=>n=>v(r=>o=>{const i=o.neighbour,a=(()=>{const s=(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=T;continue}if(l.tag==="Node"){const d=t.compare(i)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=J("Just",l._4);continue}}g()}return f})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();return it(t)(o.node)(o.viaSrc?a-1|0:a+1|0)(r)})(n)(ee(e)),bg=t=>{const e=t.Eq0();return n=>r=>o=>{const i={...o,treeNode:it(t)(r)()(o.treeNode)};return v(a=>s=>{if(Ur(s.eid)(a.st.edgeVisited))return a;const u={...a.st,edgeVisited:it(ut)(s.eid)()(a.st.edgeVisited)},c=e.eq(s.src)((()=>{const _=s.src,f=d=>{let h=d,p=!0,m;for(;p;){const x=h;if(x.tag==="Leaf"){p=!1,m=!1;continue}if(x.tag==="Node"){const y=t.compare(_)(x._3);if(y==="LT"){h=x._5;continue}if(y==="GT"){h=x._6;continue}if(y==="EQ"){p=!1,m=!0;continue}}g()}return m},l=s.tgt;return f(u.treeNode)&&!(d=>{let h=d,p=!0,m;for(;p;){const x=h;if(x.tag==="Leaf"){p=!1,m=!1;continue}if(x.tag==="Node"){const y=t.compare(l)(x._3);if(y==="LT"){h=x._5;continue}if(y==="GT"){h=x._6;continue}if(y==="EQ"){p=!1,m=!0;continue}}g()}return m})(u.treeNode)})()?s.src:(()=>{const _=s.tgt,f=d=>{let h=d,p=!0,m;for(;p;){const x=h;if(x.tag==="Leaf"){p=!1,m=!1;continue}if(x.tag==="Node"){const y=t.compare(_)(x._3);if(y==="LT"){h=x._5;continue}if(y==="GT"){h=x._6;continue}if(y==="EQ"){p=!1,m=!0;continue}}g()}return m},l=s.src;return f(u.treeNode)&&!(d=>{let h=d,p=!0,m;for(;p;){const x=h;if(x.tag==="Leaf"){p=!1,m=!1;continue}if(x.tag==="Node"){const y=t.compare(l)(x._3);if(y==="LT"){h=x._5;continue}if(y==="GT"){h=x._6;continue}if(y==="EQ"){p=!1,m=!0;continue}}g()}return m})(u.treeNode)})()?s.tgt:s.src)?s.tgt:s.src;if(Ur(s.eid)(u.treeEdge)){if((f=>{let l=f,d=!0,h;for(;d;){const p=l;if(p.tag==="Leaf"){d=!1,h=!1;continue}if(p.tag==="Node"){const m=t.compare(c)(p._3);if(m==="LT"){l=p._5;continue}if(m==="GT"){l=p._6;continue}if(m==="EQ"){d=!1,h=!0;continue}}g()}return h})(u.treeNode))return{...a,st:u};const _=bg(t)(n)(c)(u);return{count:a.count+_.count|0,st:_.st}}if((()=>{const _=l=>{let d=l,h=!0,p;for(;h;){const m=d;if(m.tag==="Leaf"){h=!1,p=!1;continue}if(m.tag==="Node"){const x=t.compare(c)(m._3);if(x==="LT"){d=m._5;continue}if(x==="GT"){d=m._6;continue}if(x==="EQ"){h=!1,p=!0;continue}}g()}return p},f=s.tgt;return!_(u.treeNode)&&(()=>{const l=(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=T;continue}if(w.tag==="Node"){const N=t.compare(f)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=J("Just",w._4);continue}}g()}return y})(u.layer),d=s.src,h=(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=T;continue}if(w.tag==="Node"){const N=t.compare(d)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=J("Just",w._4);continue}}g()}return y})(u.layer);if(l.tag==="Nothing"){if(h.tag==="Nothing")return s.delta===0;if(h.tag==="Just")return s.delta===-h._1;g()}if(l.tag==="Just"){if(h.tag==="Nothing")return s.delta===(l._1-0|0);if(h.tag==="Just")return s.delta===(l._1-h._1|0)}g()})()})()){const _=bg(t)(n)(c)({...u,treeEdge:it(ut)(s.eid)()(u.treeEdge)});return{count:a.count+_.count|0,st:_.st}}return{...a,st:u}})({count:1,st:i})(gt(a=>(e.eq(a.src)(r)||e.eq(a.tgt)(r))&&!Ur(a.eid)(i.edgeVisited),n))}},Vs=t=>e=>n=>r=>{const o=r.src,i=(l=>{let d=l,h=!0,p;for(;h;){const m=d;if(m.tag==="Leaf"){h=!1,p=T;continue}if(m.tag==="Node"){const x=t.compare(o)(m._3);if(x==="LT"){d=m._5;continue}if(x==="GT"){d=m._6;continue}if(x==="EQ"){h=!1,p=J("Just",m._4);continue}}g()}return p})(e.poID),a=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})(),s=r.tgt,u=(l=>{let d=l,h=!0,p;for(;h;){const m=d;if(m.tag==="Leaf"){h=!1,p=T;continue}if(m.tag==="Node"){const x=t.compare(s)(m._3);if(x==="LT"){d=m._5;continue}if(x==="GT"){d=m._6;continue}if(x==="EQ"){h=!1,p=J("Just",m._4);continue}}g()}return p})(e.poID),c=(()=>{if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()})(),_=(l=>{let d=l,h=!0,p;for(;h;){const m=d;if(m.tag==="Leaf"){h=!1,p=T;continue}if(m.tag==="Node"){const x=t.compare(n)(m._3);if(x==="LT"){d=m._5;continue}if(x==="GT"){d=m._6;continue}if(x==="EQ"){h=!1,p=J("Just",m._4);continue}}g()}return p})(e.poID),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})();return(()=>{const l=r.src,d=(h=>{let p=h,m=!0,x;for(;m;){const y=p;if(y.tag==="Leaf"){m=!1,x=T;continue}if(y.tag==="Node"){const w=t.compare(l)(y._3);if(w==="LT"){p=y._5;continue}if(w==="GT"){p=y._6;continue}if(w==="EQ"){m=!1,x=J("Just",y._4);continue}}g()}return x})(e.lowestPoID);return(()=>{if(d.tag==="Nothing")return 0<=f;if(d.tag==="Just")return d._1<=f;g()})()&&(()=>{const h=r.tgt;return f<=a&&(()=>{const p=(m=>{let x=m,y=!0,w;for(;y;){const N=x;if(N.tag==="Leaf"){y=!1,w=T;continue}if(N.tag==="Node"){const b=t.compare(h)(N._3);if(b==="LT"){x=N._5;continue}if(b==="GT"){x=N._6;continue}if(b==="EQ"){y=!1,w=J("Just",N._4);continue}}g()}return w})(e.lowestPoID);return(()=>{if(p.tag==="Nothing")return 0<=f;if(p.tag==="Just")return p._1<=f;g()})()&&f<=c})()})()})()?a>=c:a<c},jw=t=>{const e=fe(t)(Wt);return n=>({layer:e(V(r=>S(r,0))(n)),treeNode:M,treeEdge:M,poID:M,lowestPoID:M,cutvalue:M,postOrder:1,edgeVisited:M})},Zw=t=>e=>n=>v(r=>o=>{if((()=>{const _=o.src,f=h=>{let p=h,m=!0,x;for(;m;){const y=p;if(y.tag==="Leaf"){m=!1,x=!1;continue}if(y.tag==="Node"){const w=t.compare(_)(y._3);if(w==="LT"){p=y._5;continue}if(w==="GT"){p=y._6;continue}if(w==="EQ"){m=!1,x=!0;continue}}g()}return x},l=o.tgt,d=h=>{let p=h,m=!0,x;for(;m;){const y=p;if(y.tag==="Leaf"){m=!1,x=!1;continue}if(y.tag==="Node"){const w=t.compare(l)(y._3);if(w==="LT"){p=y._5;continue}if(w==="GT"){p=y._6;continue}if(w==="EQ"){m=!1,x=!0;continue}}g()}return x};return f(n.treeNode)===d(n.treeNode)})())return r;const i=o.tgt,a=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=T;continue}if(h.tag==="Node"){const p=t.compare(i)(h._3);if(p==="LT"){f=h._5;continue}if(p==="GT"){f=h._6;continue}if(p==="EQ"){l=!1,d=J("Just",h._4);continue}}g()}return d})(n.layer),s=o.src,u=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=T;continue}if(h.tag==="Node"){const p=t.compare(s)(h._3);if(p==="LT"){f=h._5;continue}if(p==="GT"){f=h._6;continue}if(p==="EQ"){l=!1,d=J("Just",h._4);continue}}g()}return d})(n.layer),c=(()=>{if(a.tag==="Nothing"){if(u.tag==="Nothing")return-o.delta;if(u.tag==="Just")return-u._1-o.delta|0;g()}if(a.tag==="Just"){if(u.tag==="Nothing")return(a._1-0|0)-o.delta|0;if(u.tag==="Just")return(a._1-u._1|0)-o.delta|0}g()})();return c<r.slack?{edge:J("Just",o),slack:c}:r})({edge:T,slack:1e9})(e).edge,tN=t=>{const e=fe(t)(Wt);return n=>r=>{const o=v(i=>a=>vg(i)((()=>{const s=(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=T;continue}if(l.tag==="Node"){const d=t.compare(a)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=J("Just",l._4);continue}}g()}return f})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(1e9)(n);return e(V(i=>S(i,(()=>{const a=(s=>{let u=s,c=!0,_;for(;c;){const f=u;if(f.tag==="Leaf"){c=!1,_=T;continue}if(f.tag==="Node"){const l=t.compare(i)(f._3);if(l==="LT"){u=f._5;continue}if(l==="GT"){u=f._6;continue}if(l==="EQ"){c=!1,_=J("Just",f._4);continue}}g()}return _})(r);if(a.tag==="Nothing")return-o;if(a.tag==="Just")return a._1-o|0;g()})()))(n))}},dl=t=>{const e=t.Eq0();return n=>r=>o=>{const i=v(s=>u=>{const c=dl(t)(n)(e.eq(u.src)(r)?u.tgt:u.src)({...s.st,edgeVisited:it(ut)(u.eid)()(s.st.edgeVisited)});return{lowest:vg(s.lowest)(c.lowest),st:c.st}})({lowest:1e9,st:o})(gt(s=>Ur(s.eid)(o.treeEdge)&&(e.eq(s.src)(r)||e.eq(s.tgt)(r))&&!Ur(s.eid)(o.edgeVisited),n)),a=vg(i.lowest)(i.st.postOrder);return{lowest:a,st:{...i.st,poID:it(t)(r)(i.st.postOrder)(i.st.poID),lowestPoID:it(t)(r)(a)(i.st.lowestPoID),postOrder:i.st.postOrder+1|0}}}},hl=t=>{const e=dl(t);return n=>r=>o=>0<n.length?e(r)(n[0])({...o,edgeVisited:M,postOrder:1,poID:M,lowestPoID:M}).st:o},eN=t=>{const e=t.Eq0();return n=>r=>o=>gt(i=>Ur(i.eid)(r.treeEdge)&&(e.eq(i.src)(o)||e.eq(i.tgt)(o)),n)},nN=t=>e=>ne(n=>{const r=Cg(n.eid)(e.cutvalue);return Ur(n.eid)(e.treeEdge)&&(()=>{if(r.tag==="Nothing")return!1;if(r.tag==="Just")return r._1<-1e-10;g()})()})(t),pl=t=>{const e=bg(t);return n=>r=>o=>{const i=0<n.length?J("Just",n[0]):T;if(i.tag==="Nothing")return o;if(i.tag==="Just"){const a=e(r)(i._1)({...o,edgeVisited:M,treeNode:M,treeEdge:M});if(a.count>=n.length)return a.st;const s=Zw(t)(r)(a.st);if(s.tag==="Nothing")return a.st;if(s.tag==="Just"){const u=s._1.tgt,c=(h=>{let p=h,m=!0,x;for(;m;){const y=p;if(y.tag==="Leaf"){m=!1,x=T;continue}if(y.tag==="Node"){const w=t.compare(u)(y._3);if(w==="LT"){p=y._5;continue}if(w==="GT"){p=y._6;continue}if(w==="EQ"){m=!1,x=J("Just",y._4);continue}}g()}return x})(a.st.layer),_=s._1.src,f=(h=>{let p=h,m=!0,x;for(;m;){const y=p;if(y.tag==="Leaf"){m=!1,x=T;continue}if(y.tag==="Node"){const w=t.compare(_)(y._3);if(w==="LT"){p=y._5;continue}if(w==="GT"){p=y._6;continue}if(w==="EQ"){m=!1,x=J("Just",y._4);continue}}g()}return x})(a.st.layer),l=(()=>{if(c.tag==="Nothing"){if(f.tag==="Nothing")return-s._1.delta;if(f.tag==="Just")return-f._1-s._1.delta|0;g()}if(c.tag==="Just"){if(f.tag==="Nothing")return(c._1-0|0)-s._1.delta|0;if(f.tag==="Just")return(c._1-f._1|0)-s._1.delta|0}g()})(),d=(()=>{const h=s._1.tgt;return(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=!1;continue}if(w.tag==="Node"){const N=t.compare(h)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=!0;continue}}g()}return y})(a.st.treeNode)})()?-l:l;return pl(t)(n)(r)({...a.st,layer:v(h=>p=>(m=>{let x=m,y=!0,w;for(;y;){const N=x;if(N.tag==="Leaf"){y=!1,w=!1;continue}if(N.tag==="Node"){const b=t.compare(p)(N._3);if(b==="LT"){x=N._5;continue}if(b==="GT"){x=N._6;continue}if(b==="EQ"){y=!1,w=!0;continue}}g()}return w})(a.st.treeNode)?it(t)(p)((()=>{const m=(x=>{let y=x,w=!0,N;for(;w;){const b=y;if(b.tag==="Leaf"){w=!1,N=T;continue}if(b.tag==="Node"){const C=t.compare(p)(b._3);if(C==="LT"){y=b._5;continue}if(C==="GT"){y=b._6;continue}if(C==="EQ"){w=!1,N=J("Just",b._4);continue}}g()}return N})(a.st.layer);if(m.tag==="Nothing")return 0+d|0;if(m.tag==="Just")return m._1+d|0;g()})())(h):h)(a.st.layer)(n)})}}g()}},rN=t=>e=>n=>r=>v(o=>i=>{if(Vs(t)(r)(i.src)(n)&&!Vs(t)(r)(i.tgt)(n)){const a=i.tgt,s=(f=>{let l=f,d=!0,h;for(;d;){const p=l;if(p.tag==="Leaf"){d=!1,h=T;continue}if(p.tag==="Node"){const m=t.compare(a)(p._3);if(m==="LT"){l=p._5;continue}if(m==="GT"){l=p._6;continue}if(m==="EQ"){d=!1,h=J("Just",p._4);continue}}g()}return h})(r.layer),u=i.src,c=(f=>{let l=f,d=!0,h;for(;d;){const p=l;if(p.tag==="Leaf"){d=!1,h=T;continue}if(p.tag==="Node"){const m=t.compare(u)(p._3);if(m==="LT"){l=p._5;continue}if(m==="GT"){l=p._6;continue}if(m==="EQ"){d=!1,h=J("Just",p._4);continue}}g()}return h})(r.layer),_=(()=>{if(s.tag==="Nothing"){if(c.tag==="Nothing")return-i.delta;if(c.tag==="Just")return-c._1-i.delta|0;g()}if(s.tag==="Just"){if(c.tag==="Nothing")return(s._1-0|0)-i.delta|0;if(c.tag==="Just")return(s._1-c._1|0)-i.delta|0}g()})();if(_<o.slack)return{edge:J("Just",i),slack:_}}return o})({edge:T,slack:1e9})(e).edge,oN=t=>{const e=t.Eq0();return n=>r=>o=>i=>{const a=i.tgt,s=i.src;return v(u=>c=>{if((()=>{const _=Cg(c.eid)(r.cutvalue);if(_.tag==="Just")return!0;if(_.tag==="Nothing")return!1;g()})()){const _=Cg(c.eid)(r.cutvalue),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})();return e.eq(s)(c.src)||e.eq(a)(c.tgt)?u-(f-c.weight):u+(f-c.weight)}return e.eq(o)(s)?e.eq(c.src)(o)?u+c.weight:u-c.weight:e.eq(c.src)(o)?u-c.weight:u+c.weight})(i.weight)(gt(u=>u.eid!==i.eid&&(e.eq(u.src)(o)||e.eq(u.tgt)(o)),n))}},iN=t=>{const e=oN(t);return n=>r=>o=>{const i=(a,s,u)=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=T;continue}if(h.tag==="Node"){const p=t.compare(a)(h._3);if(p==="LT"){f=h._5;continue}if(p==="GT"){f=h._6;continue}if(p==="EQ"){l=!1,d=J("Just",h._4);continue}}g()}return d})(u);if(c.tag==="Just")return it(t)(a)(gt(_=>_.eid!==s.eid,c._1))(u);if(c.tag==="Nothing")return u;g()};return(a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c,h=(m=>{let x=m,y=!0,w;for(;y;){const N=x;if(N.tag==="Leaf"){y=!1,w=T;continue}if(N.tag==="Node"){const b=t.compare(d)(N._3);if(b==="LT"){x=N._5;continue}if(b==="GT"){x=N._6;continue}if(b==="EQ"){y=!1,w=J("Just",N._4);continue}}g()}return w})(l.unknown),p=(()=>{if(h.tag==="Nothing")return[];if(h.tag==="Just")return h._1;g()})();if(p.length===1){const m=t.Eq0().eq(p[0].src)(d)?p[0].tgt:p[0].src;u={unknown:i(d,p[0],i(m,p[0],l.unknown)),cutvalue:it(ut)(p[0].eid)(e(n)(l)(d)(p[0]))(l.cutvalue)},c=m;continue}_=!1,f=l}return f})(r)(o)}},ml=t=>{const e=t.Eq0(),n=t.Eq0(),r={eq:c=>_=>c.delta===_.delta&&c.eid===_.eid&&n.eq(c.src)(_.src)&&e.eq(c.tgt)(_.tgt)&&c.weight===_.weight},o={compare:c=>_=>{const f=ut.compare(c.delta)(_.delta);if(f==="LT"||f==="GT"||f!=="EQ")return f;const l=ut.compare(c.eid)(_.eid);if(l==="LT"||l==="GT"||l!=="EQ")return l;const d=t.compare(c.src)(_.src);if(d==="LT"||d==="GT"||d!=="EQ")return d;const h=t.compare(c.tgt)(_.tgt);if(h==="LT"||h==="GT"||h!=="EQ")return h;const p=at.compare(c.weight)(_.weight);return p==="LT"||p==="GT"||p!=="EQ"?p:nn},Eq0:()=>r},i=v(c=>_=>it(o)(_)()(c))(M),a=eN(t),s=fe(t)(Wt),u=iN(t);return c=>_=>f=>{const l={unknown:s(V(d=>S(d,Bt(fn.foldr,i(a(_)(f)(d)))))(c)),cutvalue:M};return{...f,cutvalue:v(u(_))(l)(gt(d=>{const h=(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=T;continue}if(w.tag==="Node"){const N=t.compare(d)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=J("Just",w._4);continue}}g()}return y})(l.unknown);if(h.tag==="Nothing")return!1;if(h.tag==="Just")return h._1.length===1;g()},c)).cutvalue}}},aN=t=>{const e=hl(t),n=ml(t);return r=>o=>i=>a=>s=>{const u={...s,treeEdge:it(ut)(a.eid)()(Ai(ut)(i.eid)(s.treeEdge))},c=a.tgt,_=(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=T;continue}if(w.tag==="Node"){const N=t.compare(c)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=J("Just",w._4);continue}}g()}return y})(u.layer),f=a.src,l=(p=>{let m=p,x=!0,y;for(;x;){const w=m;if(w.tag==="Leaf"){x=!1,y=T;continue}if(w.tag==="Node"){const N=t.compare(f)(w._3);if(N==="LT"){m=w._5;continue}if(N==="GT"){m=w._6;continue}if(N==="EQ"){x=!1,y=J("Just",w._4);continue}}g()}return y})(u.layer),d=(()=>{if(_.tag==="Nothing"){if(l.tag==="Nothing")return-a.delta;if(l.tag==="Just")return-l._1-a.delta|0;g()}if(_.tag==="Just"){if(l.tag==="Nothing")return(_._1-0|0)-a.delta|0;if(l.tag==="Just")return(_._1-l._1|0)-a.delta|0}g()})(),h=Vs(t)(u)(a.tgt)(i)?d:-d;return n(r)(o)(e(r)(o)({...u,layer:v(p=>m=>Vs(t)(u)(m)(i)?p:it(t)(m)((()=>{const x=(y=>{let w=y,N=!0,b;for(;N;){const C=w;if(C.tag==="Leaf"){N=!1,b=T;continue}if(C.tag==="Node"){const L=t.compare(m)(C._3);if(L==="LT"){w=C._5;continue}if(L==="GT"){w=C._6;continue}if(L==="EQ"){N=!1,b=J("Just",C._4);continue}}g()}return b})(u.layer);if(x.tag==="Nothing")return 0+h|0;if(x.tag==="Just")return x._1+h|0;g()})())(p))(u.layer)(r)}))}},sN=t=>{const e=aN(t);return n=>r=>o=>i=>(a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c;if(l===0){_=!1,f=d;continue}const h=nN(o)(d);if(h.tag==="Nothing"){_=!1,f=d;continue}if(h.tag==="Just"){const p=rN(t)(o)(h._1)(d);if(p.tag==="Nothing"){_=!1,f=d;continue}if(p.tag==="Just"){u=l-1|0,c=e(r)(o)(h._1)(p._1)(d);continue}}g()}return f})(n)(i)},uN=t=>{const e=ml(t),n=hl(t),r=pl(t);return o=>i=>a=>e(o)(i)(n(o)(i)(r(o)(i)(a)))},yl=t=>e=>v(n=>r=>Mt(t)(xe)(e(r))([r])(n))(M),cN=t=>{const e=fe(t)(Wt);return n=>r=>o=>{const i=u=>c=>_=>f=>{let l=u,d=c,h=_,p=f,m=!0,x;for(;m;){const y=l,w=d,N=h,b=p,C=Pt(L=>T,L=>E=>J("Just",{head:L,tail:E}),N);if(C.tag==="Nothing"){m=!1,x=b;continue}if(C.tag==="Just"){const L=C._1.head,E=(P=>{let G=P,j=!0,nt;for(;j;){const O=G;if(O.tag==="Leaf"){j=!1,nt=T;continue}if(O.tag==="Node"){const $=t.compare(L)(O._3);if($==="LT"){G=O._5;continue}if($==="GT"){G=O._6;continue}if($==="EQ"){j=!1,nt=J("Just",O._4);continue}}g()}return nt})(b.layer),I=(()=>{if(E.tag==="Nothing")return 0;if(E.tag==="Just")return E._1;g()})(),W=v(P=>G=>{const j=G.tgt,nt=($=>{let H=$,A=!0,B;for(;A;){const z=H;if(z.tag==="Leaf"){A=!1,B=T;continue}if(z.tag==="Node"){const Q=t.compare(j)(z._3);if(Q==="LT"){H=z._5;continue}if(Q==="GT"){H=z._6;continue}if(Q==="EQ"){A=!1,B=J("Just",z._4);continue}}g()}return B})(P.incident),O=(()=>{if(nt.tag==="Nothing")return-1;if(nt.tag==="Just")return nt._1-1|0;g()})();return{st:{...P.st,layer:it(t)(G.tgt)(Xw((()=>{const $=G.tgt,H=(A=>{let B=A,z=!0,Q;for(;z;){const F=B;if(F.tag==="Leaf"){z=!1,Q=T;continue}if(F.tag==="Node"){const X=t.compare($)(F._3);if(X==="LT"){B=F._5;continue}if(X==="GT"){B=F._6;continue}if(X==="EQ"){z=!1,Q=J("Just",F._4);continue}}g()}return Q})(P.st.layer);if(H.tag==="Nothing")return 0;if(H.tag==="Just")return H._1;g()})())(I+G.delta|0))(P.st.layer)},incident:it(t)(G.tgt)(O)(P.incident),queue:O===0?[...P.queue,G.tgt]:P.queue}})({st:b,incident:w,queue:C._1.tail})((()=>{const P=(G=>{let j=G,nt=!0,O;for(;nt;){const $=j;if($.tag==="Leaf"){nt=!1,O=T;continue}if($.tag==="Node"){const H=t.compare(L)($._3);if(H==="LT"){j=$._5;continue}if(H==="GT"){j=$._6;continue}if(H==="EQ"){nt=!1,O=J("Just",$._4);continue}}g()}return O})(y);if(P.tag==="Nothing")return[];if(P.tag==="Just")return P._1;g()})());l=y,d=W.incident,h=W.queue,p=W.st;continue}g()}return x},a=yl(t)(u=>u.tgt)(r),s=e(V(u=>S(u,(()=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=T;continue}if(h.tag==="Node"){const p=t.compare(u)(h._3);if(p==="LT"){f=h._5;continue}if(p==="GT"){f=h._6;continue}if(p==="EQ"){l=!1,d=J("Just",h._4);continue}}g()}return d})(a);if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1.length;g()})()))(n));return i(yl(t)(u=>u.src)(r))(s)(gt(u=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=T;continue}if(h.tag==="Node"){const p=t.compare(u)(h._3);if(p==="LT"){f=h._5;continue}if(p==="GT"){f=h._6;continue}if(p==="EQ"){l=!1,d=J("Just",h._4);continue}}g()}return d})(s);if(c.tag==="Nothing")return!0;if(c.tag==="Just")return c._1===0;g()},n))(o)}},gN=t=>{const e=jw(t),n=cN(t),r=uN(t),o=sN(t);return i=>a=>{const s=n(i)(a)(e(i));return a.length===0?s.layer:o(4*i.length|0)(i)(a)(r(i)(a)(s)).layer}},xl=t=>{const e=tN(t),n=gN(t),r=Yw(t);return o=>i=>{if(o.length===0)return M;if(o.length<40)return e(o)(n(o)(i));const a=r(o)(i);return e(o)(Kw(t)(a.removed)(n(a.coreNodes)(a.coreEdges)))}},Tl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},kg=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},_N=xl(ut),Ea=t=>e=>({...e,edges:[...e.edges,{src:t.src,tgt:t.tgt,delta:t.delta,weight:t.weight,eid:e.nextEid}],nextEid:e.nextEid+1|0}),fN=t=>e=>n=>{if(n.cGroup.tag==="Nothing")return e;if(n.cGroup.tag==="Just"){const r=rt((()=>{const o=Tl(n.cGroup._1)(t);if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})());return Gn(n.id)(o=>({...o,hitbox:{...o.hitbox,x:r+o.cGroupOffset.x}}))(e)}g()},lN=t=>e=>({...e,cGraph:v(fN(t))(e.cGraph)((()=>{const n=e.cGraph;return Tt(r=>de(r)(n.cNodes))(n.cNodeOrder)})())}),dN=t=>e=>n=>r=>o=>{const i=he(fs(e.cGroupOffset.x-t.cGroupOffset.x));return Ea({src:o.nextNodeId,tgt:r,delta:kg(0)(-i),weight:1})(Ea({src:o.nextNodeId,tgt:n,delta:kg(0)(i),weight:1})({...o,nodes:[...o.nodes,o.nextNodeId],nextNodeId:o.nextNodeId+1|0}))},hN=t=>e=>n=>r=>o=>i=>a=>{const s=kg(0)(he(fs(n.cGroupOffset.x+n.hitbox.width+(e.direction==="LEFT"||e.direction==="RIGHT"?e.spacingsHandler.horizontalSpacing(n)(r):e.spacingsHandler.verticalSpacing(n)(r))-r.cGroupOffset.x)));return t.sameEdgeVerticalSegments(n)(r)?dN(n)(r)(o)(i)(a):Ea({src:o,tgt:i,delta:s,weight:t.vsLNodePair(n)(r)?2:1})(a)},pN=t=>e=>n=>r=>o=>{const i=de(o)(e.cGraph.cNodes);if(i.tag==="Nothing")return r;if(i.tag==="Just")return(n.cGroup.tag==="Nothing"?i._1.cGroup.tag==="Nothing":n.cGroup.tag==="Just"&&i._1.cGroup.tag==="Just"&&n.cGroup._1===i._1.cGroup._1)?r:n.cGroup.tag==="Just"&&i._1.cGroup.tag==="Just"?hN(t)(e)(n)(i._1)(n.cGroup._1)(i._1.cGroup._1)(r):r;g()},mN=t=>e=>n=>r=>v(pN(t)(e)(r))(n)(r.constraints),yN=t=>e=>Ea({src:e.srcGroup,tgt:e.tgtGroup,delta:e.delta,weight:e.weight})(t),xN=t=>{const e=v(o=>i=>Mt(ut)(ve)(i.tgt)(1)(o))(M)(t.edges),n=gt(o=>{const i=Tl(o)(e);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return i._1===0;g()},t.nodes);if(n.length<=1)return t;const r=t.nextNodeId;return v(o=>i=>Ea({src:r,tgt:i,delta:1,weight:0})(o))({...t,nodes:[...t.nodes,r],nextNodeId:r+1|0})(n)},TN=t=>e=>{const n=xN(v(yN)(v(mN(t)(e))({nodes:e.cGraph.cGroupOrder,edges:[],nextNodeId:e.cGraph.nextCGroupId,nextEid:0})((()=>{const r=e.cGraph;return Tt(o=>de(o)(r.cNodes))(r.cNodeOrder)})()))(t.edgeLengthEdges(e.cGraph)));return{nodes:n.nodes,edges:n.edges}},wN=t=>e=>{const n=TN(t)(e);return lN(_N(n.nodes)(n.edges))(e)},wl=t=>t,Te=wl("H"),we=wl("V"),NN=t=>S(t._2,t._1),Nl=t=>({...t,position:S(t.position._2,t.position._1),size:S(t.size._2,t.size._1)}),JN=t=>({start:S(t.start._2,t.start._1),end:S(t.end._2,t.end._1),direction:(()=>{if(t.direction==="H")return we;if(t.direction==="V")return Te;g()})()}),Jl=t=>({...t,segments:V(JN)(t.segments),bends:V(NN)(t.bends)}),vN=t=>({nodes:V(Nl)(t.nodes),edges:t.edges,paths:V(Jl)(t.paths),ports:t.ports}),CN={nodeNode:8,edgeNode:4,edgeEdge:10},bN=t=>e=>({horizontalSpacing:n=>r=>{if(e.sameEdgeVerticalSegments(n)(r)||n.ignoreSpacing.right||r.ignoreSpacing.left)return 0;const o=r.kind.tag==="Nothing"?!1:r.kind.tag==="Just"&&r.kind._1==="vs";return n.kind.tag!=="Nothing"&&n.kind.tag==="Just"&&n.kind._1==="vs"?o?t.edgeEdge:t.edgeNode:o?t.edgeNode:t.nodeNode},verticalSpacing:n=>r=>{if(e.sameEdgeVerticalSegments(n)(r))return 1;if(n.hitbox.y<=r.hitbox.y?n.ignoreSpacing.down||r.ignoreSpacing.up:n.ignoreSpacing.up||r.ignoreSpacing.down)return 0;const o=r.kind.tag==="Nothing"?!1:r.kind.tag==="Just"&&r.kind._1==="vs";return n.kind.tag!=="Nothing"&&n.kind.tag==="Just"&&n.kind._1==="vs"?o?t.edgeEdge:t.edgeNode:o?t.edgeNode:t.nodeNode}}),kN=t=>e=>wN(e),LN=t=>e=>n=>{const r=vN(n),o=Uw(r),i=Hw(o)(fl(r)),a=Ow(tl(pg)(lw({...hw(o.cGraph),compactionAlgorithm:J("Just",kN()(i)),constraintAlgorithm:J("Just",kw(e.edgeEdge)),spacingsHandler:bN(e)(i)})).cGraph)({nodes:r.nodes,edges:r.edges,paths:r.paths});return{nodes:V(Nl)(a.nodes),edges:V(Jl)(a.edges)}},vl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Cl=t=>Ie(3)(t)==="$d:",SN=t=>e=>n=>v(r=>o=>{const i=vl(o.from.node)(t),a=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})(),s=vl(o.to.node)(t),u=(()=>{if(s.tag==="Nothing")return-a;if(s.tag==="Just")return s._1-a|0;g()})();if(u<=1)return{...r,edges:[...r.edges,o],chains:[...r.chains,{edgeId:o.id,nodes:[o.from.node,o.to.node]}]};const c=o.id,_=V(l=>"$d:"+c+":"+ae(l))($t(1,u-1|0)),f=[o.from.node,..._,o.to.node];return{...r,layers:v(l=>d=>{const h=d._2,p=F2(a+d._1|0)(m=>[...m,h])(l);if(p.tag==="Nothing")return l;if(p.tag==="Just")return p._1;g()})(r.layers)(Oe(Ln,$t(1,u-1|0),_)),edges:[...r.edges,...Oe(l=>d=>({id:c+":"+l+"->"+d,from:{node:l,port:o.from.port},to:{node:d,port:o.to.port},label:T}),f,Rt(1,f.length,f))],chains:[...r.chains,{edgeId:o.id,nodes:f}]}})({layers:n,edges:[],chains:[]})(e),bl=t=>t,Oi=fe(ut)(Wt),Kt=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},kl=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bt=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},kt=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},qi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},EN=t=>e=>{const n=ut.compare(t._1)(e._1);return n==="LT"?Be:n==="GT"?Me:ut.compare(t._2)(e._2)},Vi=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},PN=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),GN=t=>t,Ll=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},RN=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},$s=bl("Regular"),Us=bl("Critical"),Sl=t=>e=>{const n=v(a=>s=>it(R)(s.node)(s)(a))(M)(e),r=1.25*rt(4),o=(a,s,u)=>(c=>_=>f=>{let l=c,d=_,h=f,p=!0,m;for(;p;){const x=l,y=d,w=h;if(w.critical){p=!1,m=w;continue}const N=Pt(C=>T,C=>L=>J("Just",{head:C,tail:L}),x),b=Pt(C=>T,C=>L=>J("Just",{head:C,tail:L}),y);if(N.tag==="Just"&&b.tag==="Just"){const C=N._1.head>b._1.head-a&&N._1.head<b._1.head+a?{...w,critical:!0}:N._1.head>b._1.head-r&&N._1.head<b._1.head+r?{...w,conflicts:w.conflicts+1|0}:w;if(C.critical){p=!1,m=C;continue}if(N._1.head<=b._1.head){l=N._1.tail,d=y,h=C;continue}l=x,d=b._1.tail,h=C;continue}p=!1,m=w}return m})(s)(u)({conflicts:0,critical:!1}),i=(a,s,u)=>{if(kt(v(kt)(-1e18)(s.incoming))(v(kt)(-1e18)(s.outgoing))-bt(v(bt)(1e18)(s.incoming))(v(bt)(1e18)(s.outgoing))<.001||kt(v(kt)(-1e18)(u.incoming))(v(kt)(-1e18)(u.outgoing))-bt(v(bt)(1e18)(u.incoming))(v(bt)(1e18)(u.outgoing))<.001)return[];const c=o(a,s.outgoing,u.incoming),_=o(a,u.outgoing,s.incoming);if(c.critical||_.critical)return[...c.critical?[{src:u.id,tgt:s.id,weight:1,kind:Us}]:[],..._.critical?[{src:s.id,tgt:u.id,weight:1,kind:Us}]:[]];const f=bt(v(bt)(1e18)(s.incoming))(v(bt)(1e18)(s.outgoing)),l=kt(v(kt)(-1e18)(s.incoming))(v(kt)(-1e18)(s.outgoing)),d=bt(v(bt)(1e18)(u.incoming))(v(bt)(1e18)(u.outgoing)),h=kt(v(kt)(-1e18)(u.incoming))(v(kt)(-1e18)(u.outgoing)),p=(1*c.conflicts|0)+(16*(v(x=>y=>y>h?x:y>=d?x+1|0:x)(0)(s.outgoing)+v(x=>y=>y>l?x:y>=f?x+1|0:x)(0)(u.incoming)|0)|0)|0,m=(1*_.conflicts|0)+(16*(v(x=>y=>y>l?x:y>=f?x+1|0:x)(0)(u.outgoing)+v(x=>y=>y>h?x:y>=d?x+1|0:x)(0)(s.incoming)|0)|0)|0;return p<m?[{src:s.id,tgt:u.id,weight:m-p|0,kind:$s}]:p>m?[{src:u.id,tgt:s.id,weight:p-m|0,kind:$s}]:p>0?[{src:s.id,tgt:u.id,weight:0,kind:$s},{src:u.id,tgt:s.id,weight:0,kind:$s}]:[]};return v(a=>s=>v(u=>c=>it(R)(c._1)(c._2)(u))(a)((()=>{const u=v(P=>G=>{const j=G.edge.from.node+"|"+(()=>{if(G.edge.from.port.tag==="Just")return G.edge.from.port._1;if(G.edge.from.port.tag==="Nothing")return"_auto_"+G.edge.id;g()})(),nt=Ll(j)(P.entries);if(nt.tag==="Nothing")return{...P,entries:it(R)(j)({id:0,members:[G.edge.id],incoming:[G.fromPos._1],outgoing:[G.toPos._1],slot:0,mark:0,splitBy:T,splitPartner:T})(P.entries),order:[...P.order,j]};if(nt.tag==="Just")return{...P,entries:it(R)(j)({...nt._1,members:[...nt._1.members,G.edge.id],incoming:[...Cr(O=>O<G.fromPos._1)(nt._1.incoming).init,G.fromPos._1,...Cr(O=>O<=G.fromPos._1)(nt._1.incoming).rest],outgoing:[...Cr(O=>O<G.toPos._1)(nt._1.outgoing).init,G.toPos._1,...Cr(O=>O<=G.toPos._1)(nt._1.outgoing).rest]})(P.entries)};g()})({entries:M,order:[]})(s._2),c=Ht(P=>G=>({...G,id:P}))(Tt(P=>Ll(P)(u.entries))(u.order));if(c.length===0)return[];const _=v(P=>G=>P.prev.tag==="Just"&&G-P.prev._1<1e-9?P:{prev:J("Just",G),out:[...P.out,G]})({prev:T,out:[]})(Gt(at.compare)([...Et(c)(P=>P.incoming),...Et(c)(P=>P.outgoing)])).out,f=_.length<2?.2*r:.2*v(P=>G=>{if(P.prev.tag==="Nothing")return{prev:J("Just",G),mn:P.mn};if(P.prev.tag==="Just")return{prev:J("Just",G),mn:bt(P.mn)(G-P.prev._1)};g()})({prev:T,mn:1e18})(_).mn,l={segments:c,deps:(()=>{const P=c.length;return Et(Et($t(0,P-2|0))(G=>Et($t(G+1|0,P-1|0))(j=>[S(G,j)])))(G=>G._1>=0&&G._1<c.length?G._2>=0&&G._2<c.length?i(f,c[G._1],c[G._2]):[]:[])})()},d=gt(P=>{if(P.kind==="Critical")return!0;if(P.kind==="Regular")return!1;g()},l.deps),h=(()=>{if(d.length<2)return l;const P=Oi((()=>{const $=l.segments;return V(H=>S(H.id,H.mark))((()=>{const H=$.length,A=z=>{let Q=z,F=!0,X;for(;F;){const q=Q,U=ne(Y=>{const ot=Kt(Y)(q.inWeight);if(ot.tag==="Nothing")return!0;if(ot.tag==="Just")return ot._1===0;g()})(q.remaining);if(U.tag==="Nothing"){F=!1,X=q;continue}if(U.tag==="Just"){const Y=U._1;Q={...q,inWeight:v(ot=>Z=>Mt(ut)(ve)(Z.tgt)(-Z.weight)(ot))(q.inWeight)((()=>{const ot=Kt(Y)(q.depsBySrc);if(ot.tag==="Nothing")return[];if(ot.tag==="Just")return ot._1;g()})()),marks:it(ut)(Y)(q.nextSource)(q.marks),nextSource:q.nextSource+1|0,outWeight:v(ot=>Z=>Mt(ut)(ve)(Z.src)(-Z.weight)(ot))(q.outWeight)((()=>{const ot=Kt(Y)(q.depsByTgt);if(ot.tag==="Nothing")return[];if(ot.tag==="Just")return ot._1;g()})()),remaining:gt(ot=>ot!==Y,q.remaining)};continue}g()}return X},B=z=>{let Q=z,F=!0,X;for(;F;){const q=Q,U=ne(Y=>{const ot=Kt(Y)(q.outWeight);if(ot.tag==="Nothing")return!0;if(ot.tag==="Just")return ot._1===0;g()})(q.remaining);if(U.tag==="Nothing"){F=!1,X=q;continue}if(U.tag==="Just"){const Y=U._1;Q={...q,inWeight:v(ot=>Z=>Mt(ut)(ve)(Z.tgt)(-Z.weight)(ot))(q.inWeight)((()=>{const ot=Kt(Y)(q.depsBySrc);if(ot.tag==="Nothing")return[];if(ot.tag==="Just")return ot._1;g()})()),marks:it(ut)(Y)(q.nextSink)(q.marks),nextSink:q.nextSink-1|0,outWeight:v(ot=>Z=>Mt(ut)(ve)(Z.src)(-Z.weight)(ot))(q.outWeight)((()=>{const ot=Kt(Y)(q.depsByTgt);if(ot.tag==="Nothing")return[];if(ot.tag==="Just")return ot._1;g()})()),remaining:gt(ot=>ot!==Y,q.remaining)};continue}g()}return X};return(z=>{let Q=z,F=!0,X;for(;F;){const q=A(B(Q));if(q.remaining.length===0){F=!1,X=V(U=>{const Y=Kt(U.id)(q.marks),ot=(()=>{if(Y.tag==="Nothing")return U.id;if(Y.tag==="Just")return Y._1;g()})();return{...U,mark:ot<H?(ot+H|0)+1|0:ot}})($);continue}Q=(()=>{const U=ot=>{const Z=Kt(ot)(q.outWeight),ft=Kt(ot)(q.inWeight);return(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()-(()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()|0},Y=Gt(ot=>Z=>ut.compare(U(Z))(U(ot)))(q.remaining);if(0<Y.length){const ot=Y[0];return{...q,inWeight:v(Z=>ft=>Mt(ut)(ve)(ft.tgt)(-ft.weight)(Z))(q.inWeight)((()=>{const Z=Kt(ot)(q.depsBySrc);if(Z.tag==="Nothing")return[];if(Z.tag==="Just")return Z._1;g()})()),marks:it(ut)(ot)(q.nextSource)(q.marks),nextSource:q.nextSource+1|0,outWeight:v(Z=>ft=>Mt(ut)(ve)(ft.src)(-ft.weight)(Z))(q.outWeight)((()=>{const Z=Kt(ot)(q.depsByTgt);if(Z.tag==="Nothing")return[];if(Z.tag==="Just")return Z._1;g()})()),remaining:gt(Z=>Z!==ot,q.remaining)}}return q})()}return X})({remaining:V(z=>z.id)($),marks:M,inWeight:v(z=>Q=>Mt(ut)(ve)(Q.tgt)(Q.weight)(z))(M)(d),outWeight:v(z=>Q=>Mt(ut)(ve)(Q.src)(Q.weight)(z))(M)(d),depsBySrc:v(z=>Q=>Mt(ut)(xe)(Q.src)([Q])(z))(M)(d),depsByTgt:v(z=>Q=>Mt(ut)(xe)(Q.tgt)([Q])(z))(M)(d),nextSink:H-1|0,nextSource:H+1|0})})())})()),G=gt($=>{const H=Kt($.src)(P),A=Kt($.tgt)(P);return(()=>{if(H.tag==="Nothing")return 0;if(H.tag==="Just")return H._1;g()})()>(()=>{if(A.tag==="Nothing")return 0;if(A.tag==="Just")return A._1;g()})()},d);if(G.length===0)return l;const j=v($=>H=>{if(gn(ro)(H.src)($.decisions)||gn(ro)(H.tgt)($.decisions))return $;const A=Kt(H.src)($.segMap),B=Kt(H.tgt)($.segMap);if(A.tag==="Just"&&B.tag==="Just"){const z=(A._1.incoming.length+A._1.outgoing.length|0)>2&&(B._1.incoming.length+B._1.outgoing.length|0)<=2,Q=z?B._1:A._1;return{decisions:[...$.decisions,Q.id],segMap:it(ut)(Q.id)({...Q,splitBy:J("Just",z?A._1.id:B._1.id)})($.segMap)}}return $})({decisions:[],segMap:Oi(V($=>S($.id,$))(l.segments))})(G),nt=j.segMap,O=v($=>H=>{const A=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(H.outgoing)),B=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(H.outgoing)),z=gt(U=>U.a.startPosition<=B&&U.a.endPosition>=A,Ht(U=>Y=>({i:U,a:Y}))($.freeAreas));if(z.length===0){const U={...H,incoming:Gt(at.compare)(H.incoming),outgoing:Gt(at.compare)([(A+B)/2]),splitPartner:J("Just",$.nextId)},Y={id:$.nextId,incoming:Gt(at.compare)([(A+B)/2]),mark:0,members:H.members,outgoing:Gt(at.compare)(H.outgoing),slot:0,splitBy:T,splitPartner:J("Just",H.id)};return{segMap:it(ut)(Y.id)(Y)(it(ut)(U.id)(U)($.segMap)),freeAreas:$.freeAreas,nextId:$.nextId+1|0}}const Q=0<z.length?J("Just",z[0]):T,F=(()=>{if(Q.tag==="Nothing")return{i:0,a:{startPosition:0,endPosition:0,size:0}};if(Q.tag==="Just"){if(z.length===1)return Q._1;const U=V(Y=>({c:Y,rating:(()=>{const ot=(Y.a.startPosition+Y.a.endPosition)/2,Z=[ot],ft=[ot],Lt=v((()=>{const Nt=$.segMap;return St=>te=>{const Jt=Kt(te.tgt)(Nt);if(Jt.tag==="Nothing")return St;if(Jt.tag==="Just"){const Yt=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),Ft=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),vt=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(Z)),mt=(()=>{const qt=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(Z)),jt=v(se=>Je=>Je>Ft?se:Je>=Yt?se+1|0:se)(0)(Z)+v(se=>Je=>Je>qt?se:Je>=vt?se+1|0:se)(0)(Jt._1.incoming)|0,en=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(Z)),He=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(Z)),Bn=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),Mn=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),Ue=v(se=>Je=>Je>He?se:Je>=en?se+1|0:se)(0)(Jt._1.outgoing)+v(se=>Je=>Je>Mn?se:Je>=Bn?se+1|0:se)(0)(H.incoming)|0;return jt===Ue?jt>0?{...St,deps:St.deps+2|0,crossings:St.crossings+jt|0}:St:{...St,deps:St.deps+1|0,crossings:St.crossings+Vi(jt)(Ue)|0}})(),lt=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),xt=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),It=bt(v(bt)(1e18)(ft))(v(bt)(1e18)(H.outgoing)),ht=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)(H.outgoing)),Ct=v(qt=>jt=>jt>xt?qt:jt>=lt?qt+1|0:qt)(0)(H.outgoing)+v(qt=>jt=>jt>ht?qt:jt>=It?qt+1|0:qt)(0)(Jt._1.incoming)|0,Qt=bt(v(bt)(1e18)(ft))(v(bt)(1e18)(H.outgoing)),zt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)(H.outgoing)),ie=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),_e=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),cn=v(qt=>jt=>jt>zt?qt:jt>=Qt?qt+1|0:qt)(0)(Jt._1.outgoing)+v(qt=>jt=>jt>_e?qt:jt>=ie?qt+1|0:qt)(0)(ft)|0;return Ct===cn?Ct>0?{...mt,deps:mt.deps+2|0,crossings:mt.crossings+Ct|0}:mt:{...mt,deps:mt.deps+1|0,crossings:mt.crossings+Vi(Ct)(cn)|0}}g()}})())(v((()=>{const Nt=$.segMap;return St=>te=>{const Jt=Kt(te.src)(Nt);if(Jt.tag==="Nothing")return St;if(Jt.tag==="Just"){const Yt=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),Ft=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),vt=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(Z)),mt=(()=>{const qt=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(Z)),jt=v(se=>Je=>Je>Ft?se:Je>=Yt?se+1|0:se)(0)(Z)+v(se=>Je=>Je>qt?se:Je>=vt?se+1|0:se)(0)(Jt._1.incoming)|0,en=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(Z)),He=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(Z)),Bn=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),Mn=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),Ue=v(se=>Je=>Je>He?se:Je>=en?se+1|0:se)(0)(Jt._1.outgoing)+v(se=>Je=>Je>Mn?se:Je>=Bn?se+1|0:se)(0)(H.incoming)|0;return jt===Ue?jt>0?{...St,deps:St.deps+2|0,crossings:St.crossings+jt|0}:St:{...St,deps:St.deps+1|0,crossings:St.crossings+Vi(jt)(Ue)|0}})(),lt=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),xt=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),It=bt(v(bt)(1e18)(ft))(v(bt)(1e18)(H.outgoing)),ht=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)(H.outgoing)),Ct=v(qt=>jt=>jt>xt?qt:jt>=lt?qt+1|0:qt)(0)(H.outgoing)+v(qt=>jt=>jt>ht?qt:jt>=It?qt+1|0:qt)(0)(Jt._1.incoming)|0,Qt=bt(v(bt)(1e18)(ft))(v(bt)(1e18)(H.outgoing)),zt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)(H.outgoing)),ie=bt(v(bt)(1e18)(Jt._1.incoming))(v(bt)(1e18)(Jt._1.outgoing)),_e=kt(v(kt)(-1e18)(Jt._1.incoming))(v(kt)(-1e18)(Jt._1.outgoing)),cn=v(qt=>jt=>jt>zt?qt:jt>=Qt?qt+1|0:qt)(0)(Jt._1.outgoing)+v(qt=>jt=>jt>_e?qt:jt>=ie?qt+1|0:qt)(0)(ft)|0;return Ct===cn?Ct>0?{...mt,deps:mt.deps+2|0,crossings:mt.crossings+Ct|0}:mt:{...mt,deps:mt.deps+1|0,crossings:mt.crossings+Vi(Ct)(cn)|0}}g()}})())({crossings:0,deps:0})(gt(Nt=>Nt.tgt===H.id,l.deps)))(gt(Nt=>Nt.src===H.id,l.deps)),dt=(()=>{if(H.splitBy.tag==="Just")return Kt(H.splitBy._1)($.segMap);if(H.splitBy.tag==="Nothing")return T;g()})();if(dt.tag==="Just")return{...Lt,deps:Lt.deps+2|0,crossings:(()=>{const Nt=bt(v(bt)(1e18)(dt._1.incoming))(v(bt)(1e18)(dt._1.outgoing)),St=bt(v(bt)(1e18)(ft))(v(bt)(1e18)(H.outgoing)),te=kt(v(kt)(-1e18)(dt._1.incoming))(v(kt)(-1e18)(dt._1.outgoing)),Jt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)(H.outgoing)),Yt=bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(Z));return Lt.crossings+(()=>{const Ft=bt(v(bt)(1e18)(dt._1.incoming))(v(bt)(1e18)(dt._1.outgoing)),vt=kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(Z)),mt=kt(v(kt)(-1e18)(dt._1.incoming))(v(kt)(-1e18)(dt._1.outgoing));return((v(lt=>xt=>xt>te?lt:xt>=Nt?lt+1|0:lt)(0)(Z)+v(lt=>xt=>xt>vt?lt:xt>=Yt?lt+1|0:lt)(0)(dt._1.incoming)|0)+v(lt=>xt=>xt>Jt?lt:xt>=St?lt+1|0:lt)(0)(dt._1.outgoing)|0)+v(lt=>xt=>xt>mt?lt:xt>=Ft?lt+1|0:lt)(0)(ft)|0})()|0})()};if(dt.tag==="Nothing")return Lt;g()})()}))(z);return v(Y=>ot=>ot.rating.crossings<Y.rating.crossings||!(ot.rating.crossings>Y.rating.crossings)&&(ot.rating.deps<Y.rating.deps||!(ot.rating.deps>Y.rating.deps)&&ot.c.a.size>Y.c.a.size)?ot:Y)(0<U.length?U[0]:{c:Q._1,rating:{crossings:1e6,deps:1e6}})(U).c}g()})(),X={...H,incoming:Gt(at.compare)(H.incoming),outgoing:Gt(at.compare)([(F.a.startPosition+F.a.endPosition)/2]),splitPartner:J("Just",$.nextId)},q={id:$.nextId,incoming:Gt(at.compare)([(F.a.startPosition+F.a.endPosition)/2]),mark:0,members:H.members,outgoing:Gt(at.compare)(H.outgoing),slot:0,splitBy:T,splitPartner:J("Just",H.id)};return{segMap:it(ut)(q.id)(q)(it(ut)(X.id)(X)($.segMap)),freeAreas:(()=>{if(F.i>=0&&F.i<$.freeAreas.length){const U=F1(Vt,T,F.i,$.freeAreas),Y=(()=>{if(U.tag==="Nothing")return $.freeAreas;if(U.tag==="Just")return U._1;g()})();if($.freeAreas[F.i].size/2<f)return Y;const ot=($.freeAreas[F.i].startPosition+$.freeAreas[F.i].endPosition)/2,Z=ot-f,ft=ot+f;return[...F.i<1?[]:Rt(0,F.i,Y),...$.freeAreas[F.i].startPosition<=Z?[{startPosition:$.freeAreas[F.i].startPosition,endPosition:Z,size:Z-$.freeAreas[F.i].startPosition}]:[],...ft<=$.freeAreas[F.i].endPosition?[{startPosition:ft,endPosition:$.freeAreas[F.i].endPosition,size:$.freeAreas[F.i].endPosition-ft}]:[],...F.i<1?Y:Rt(F.i,Y.length,Y)]}return $.freeAreas})(),nextId:$.nextId+1|0}})({segMap:nt,freeAreas:(()=>{const $=Gt(at.compare)([...Et(l.segments)(H=>H.incoming),...Et(l.segments)(H=>H.outgoing)]);return Tt(GN)(Oe(H=>A=>A-H>=2*f?J("Just",{startPosition:H+f,endPosition:A-f,size:A-H-2*f}):T,$,Rt(1,$.length,$)))})(),nextId:l.segments.length})(Gt($=>H=>at.compare(kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)($.outgoing))-bt(v(bt)(1e18)($.incoming))(v(bt)(1e18)($.outgoing)))(kt(v(kt)(-1e18)(H.incoming))(v(kt)(-1e18)(H.outgoing))-bt(v(bt)(1e18)(H.incoming))(v(bt)(1e18)(H.outgoing))))(Tt($=>Kt($)(nt))(j.decisions)));return{segments:(()=>{const $=(H,A)=>{if(H.tag==="Leaf")return A;if(H.tag==="Node")return $(H._5,yt("Cons",H._4,$(H._6,A)));g()};return Bt(ce.foldr,$(O.segMap,D))})(),deps:(()=>{const $=O.segMap,H=(z,Q)=>{if(z.tag==="Leaf")return Q;if(z.tag==="Node")return H(z._5,yt("Cons",z._4,H(z._6,Q)));g()},A=Bt(ce.foldr,H($,D)),B=A.length;return[...Et(Et($t(0,B-2|0))(z=>Et($t(z+1|0,B-1|0))(Q=>[S(z,Q)])))(z=>z._1>=0&&z._1<A.length?z._2>=0&&z._2<A.length?A[z._1].splitPartner.tag!=="Nothing"&&A[z._1].splitPartner.tag==="Just"&&A[z._1].splitPartner._1===A[z._2].id||A[z._2].splitPartner.tag!=="Nothing"&&A[z._2].splitPartner.tag==="Just"&&A[z._2].splitPartner._1===A[z._1].id?[]:i(f,A[z._1],A[z._2]):[]:[]),...Et(A)(z=>z.splitBy.tag==="Just"&&z.splitPartner.tag==="Just"&&(()=>{const Q=Kt(z.splitPartner._1)($);if(Q.tag==="Nothing")return!1;if(Q.tag==="Just")return!0;g()})()&&(()=>{const Q=Kt(z.splitBy._1)($);if(Q.tag==="Nothing")return!1;if(Q.tag==="Just")return!0;g()})()?[{src:z.id,tgt:z.splitBy._1,weight:1,kind:Us},{src:z.splitBy._1,tgt:z.splitPartner._1,weight:1,kind:Us}]:[])]})()}})(),p=h.segments,m=p.length,x=P=>{let G=P,j=!0,nt;for(;j;){const O=G,$=ne(H=>{const A=Kt(H)(O.inWeight);if(A.tag==="Nothing")return!0;if(A.tag==="Just")return A._1===0;g()})(O.remaining);if($.tag==="Nothing"){j=!1,nt=O;continue}if($.tag==="Just"){const H=$._1;G={...O,inWeight:v(A=>B=>Mt(ut)(ve)(B.tgt)(-B.weight)(A))(O.inWeight)((()=>{const A=Kt(H)(O.depsBySrc);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),marks:it(ut)(H)(O.nextSource)(O.marks),nextSource:O.nextSource+1|0,outWeight:v(A=>B=>Mt(ut)(ve)(B.src)(-B.weight)(A))(O.outWeight)((()=>{const A=Kt(H)(O.depsByTgt);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),remaining:gt(A=>A!==H,O.remaining)};continue}g()}return nt},y=P=>{let G=P,j=!0,nt;for(;j;){const O=G,$=ne(H=>{const A=Kt(H)(O.outWeight);if(A.tag==="Nothing")return!0;if(A.tag==="Just")return A._1===0;g()})(O.remaining);if($.tag==="Nothing"){j=!1,nt=O;continue}if($.tag==="Just"){const H=$._1;G={...O,inWeight:v(A=>B=>Mt(ut)(ve)(B.tgt)(-B.weight)(A))(O.inWeight)((()=>{const A=Kt(H)(O.depsBySrc);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),marks:it(ut)(H)(O.nextSink)(O.marks),nextSink:O.nextSink-1|0,outWeight:v(A=>B=>Mt(ut)(ve)(B.src)(-B.weight)(A))(O.outWeight)((()=>{const A=Kt(H)(O.depsByTgt);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),remaining:gt(A=>A!==H,O.remaining)};continue}g()}return nt},w=(P=>{let G=P,j=!0,nt;for(;j;){const O=x(y(G));if(O.remaining.length===0){j=!1,nt=V($=>{const H=Kt($.id)(O.marks),A=(()=>{if(H.tag==="Nothing")return $.id;if(H.tag==="Just")return H._1;g()})();return{...$,mark:A<m?(A+m|0)+1|0:A}})(p);continue}G=(()=>{const $=A=>{const B=Kt(A)(O.outWeight),z=Kt(A)(O.inWeight);return(()=>{if(B.tag==="Nothing")return 0;if(B.tag==="Just")return B._1;g()})()-(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})()|0},H=Gt(A=>B=>ut.compare($(B))($(A)))(O.remaining);if(0<H.length){const A=H[0];return{...O,inWeight:v(B=>z=>Mt(ut)(ve)(z.tgt)(-z.weight)(B))(O.inWeight)((()=>{const B=Kt(A)(O.depsBySrc);if(B.tag==="Nothing")return[];if(B.tag==="Just")return B._1;g()})()),marks:it(ut)(A)(O.nextSource)(O.marks),nextSource:O.nextSource+1|0,outWeight:v(B=>z=>Mt(ut)(ve)(z.src)(-z.weight)(B))(O.outWeight)((()=>{const B=Kt(A)(O.depsByTgt);if(B.tag==="Nothing")return[];if(B.tag==="Just")return B._1;g()})()),remaining:gt(B=>B!==A,O.remaining)}}return O})()}return nt})({remaining:V(P=>P.id)(p),marks:M,inWeight:v(P=>G=>Mt(ut)(ve)(G.tgt)(G.weight)(P))(M)(h.deps),outWeight:v(P=>G=>Mt(ut)(ve)(G.src)(G.weight)(P))(M)(h.deps),depsBySrc:v(P=>G=>Mt(ut)(xe)(G.src)([G])(P))(M)(h.deps),depsByTgt:v(P=>G=>Mt(ut)(xe)(G.tgt)([G])(P))(M)(h.deps),nextSink:m-1|0,nextSource:m+1|0}),N=(()=>{const P=(()=>{const nt=Oi(V(O=>S(O.id,O.mark))(w));return{segments:w,deps:Tt(O=>(()=>{if(O.kind==="Critical")return!0;if(O.kind==="Regular")return!1;g()})()?J("Just",O):(()=>{const $=Kt(O.src)(nt),H=Kt(O.tgt)(nt);return(()=>{if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})()>(()=>{if(H.tag==="Nothing")return 0;if(H.tag==="Just")return H._1;g()})()})()?O.weight===0?T:J("Just",{src:O.tgt,tgt:O.src,weight:O.weight,kind:O.kind}):J("Just",O))(h.deps)}})(),G=v(nt=>O=>Mt(ut)(ve)(O.tgt)(1)(nt))(M)(P.deps),j=(nt=>{let O=nt,$=!0,H;for(;$;){const A=O,B=Pt(z=>T,z=>Q=>J("Just",{head:z,tail:Q}),A.queue);if(B.tag==="Nothing"){$=!1,H=A;continue}if(B.tag==="Just"){O=v((()=>{const z=Kt(B._1.head)(A.slots),Q=(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})();return F=>X=>{const q=Kt(X)(F.inDegree),U=(()=>{if(q.tag==="Nothing")return-1;if(q.tag==="Just")return q._1-1|0;g()})();return{...F,slots:it(ut)(X)(kl((()=>{const Y=Kt(X)(F.slots);if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1;g()})())(Q+1|0))(F.slots),inDegree:it(ut)(X)(U)(F.inDegree),queue:U===0?[...F.queue,X]:F.queue}}})())({...A,queue:B._1.tail})((()=>{const z=Kt(B._1.head)(A.adj);if(z.tag==="Nothing")return[];if(z.tag==="Just")return z._1;g()})());continue}g()}return H})({slots:Oi(V(nt=>S(nt.id,0))(P.segments)),inDegree:G,adj:v(nt=>O=>Mt(ut)(xe)(O.src)([O.tgt])(nt))(M)(P.deps),queue:V(nt=>nt.id)(gt(nt=>{const O=Kt(nt.id)(G);if(O.tag==="Nothing")return!0;if(O.tag==="Just")return O._1===0;g()},P.segments))});return Gt(nt=>O=>ut.compare(nt.slot)(O.slot))(V(nt=>({...nt,slot:(()=>{const O=Kt(nt.id)(j.slots);if(O.tag==="Nothing")return 0;if(O.tag==="Just")return O._1;g()})()}))(P.segments))})(),b=1+v(P=>G=>kl(P)(G.slot))(0)(N)|0,C=Et(N)(P=>P.members),L=gt(P=>gn(vr)(P.edge.id)(C),t),E=v(kt)(-1e18)(V(P=>P.fromPos._2)(L)),I=v(bt)(1e18)(V(P=>P.toPos._2)(L));if(E>I){const P=Oi(V(G=>S(G.id,G))(N));return Tn(V(G=>V(j=>S(j,{slot:G.slot,slotCount:b,gapTop:I,gapBottom:E,partner:(()=>{if(G.splitPartner.tag==="Just"){const nt=Kt(G.splitPartner._1)(P);if(nt.tag==="Just")return J("Just",{slot:nt._1.slot,splitX:0<nt._1.incoming.length?nt._1.incoming[0]:0});if(nt.tag==="Nothing")return T;g()}if(G.splitPartner.tag==="Nothing")return T;g()})()}))(G.members))(gt(G=>{if(G.splitPartner.tag==="Just"){const j=Kt(G.splitPartner._1)(P);return!(j.tag==="Just"&&(()=>{if(j._1.splitBy.tag==="Nothing")return!1;if(j._1.splitBy.tag==="Just")return!0;g()})())}if(G.splitPartner.tag==="Nothing")return!0;g()},N)))}const W=Oi(V(P=>S(P.id,P))(N));return Tn(V(P=>V(G=>S(G,{slot:P.slot,slotCount:b,gapTop:E,gapBottom:I,partner:(()=>{if(P.splitPartner.tag==="Just"){const j=Kt(P.splitPartner._1)(W);if(j.tag==="Just")return J("Just",{slot:j._1.slot,splitX:0<j._1.incoming.length?j._1.incoming[0]:0});if(j.tag==="Nothing")return T;g()}if(P.splitPartner.tag==="Nothing")return T;g()})()}))(P.members))(gt(P=>{if(P.splitPartner.tag==="Just"){const G=Kt(P.splitPartner._1)(W);return!(G.tag==="Just"&&(()=>{if(G._1.splitBy.tag==="Nothing")return!1;if(G._1.splitBy.tag==="Just")return!0;g()})())}if(P.splitPartner.tag==="Nothing")return!0;g()},N)))})()))(M)(PN(v(a=>s=>{const u=qi(s.edge.from.node)(n);if(u.tag==="Just"){const c=qi(s.edge.to.node)(n);return c.tag==="Just"&&u._1.layer!==c._1.layer?Mt(ut)(xe)(Vi(u._1.layer)(c._1.layer))([s])(a):a}return a})(M)((()=>{const a=s=>S((()=>{const u=qi(s.edge.from.node)(n);return u.tag==="Just"?u._1.layer:1e6})(),(()=>{const u=qi(s.edge.from.node)(n);return u.tag==="Just"?u._1.order:1e6})());return Gt(s=>u=>EN(a(s))(a(u)))(t)})())))},AN=t=>e=>{const n=Sl(t)(e),r=v(o=>i=>it(R)(i.node)(i)(o))(M)(e);return v(o=>i=>{const a=qi(i.edge.from.node)(r);if(a.tag==="Just"){const s=qi(i.edge.to.node)(r);if(s.tag==="Just"&&a._1.layer!==s._1.layer){const u=RN(i.edge.id)(n);if(u.tag==="Just")return it(ut)(Vi(a._1.layer)(s._1.layer))(u._1.slotCount)(o)}return o}return o})(M)(t)},Lg=fe(R)(Wt),Xr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Sg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},IN=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t._1)(i._3._1);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(t._2==="North"){if(i._3._2==="North"){r=!1,o=J("Just",i._4);continue}n=i._5;continue}if(i._3._2==="North"){n=i._6;continue}if(t._2==="South"){if(i._3._2==="South"){r=!1,o=J("Just",i._4);continue}n=i._5;continue}if(i._3._2==="South"){n=i._6;continue}if(t._2==="East"){if(i._3._2==="East"){r=!1,o=J("Just",i._4);continue}n=i._5;continue}if(i._3._2==="East"){n=i._6;continue}if(t._2==="West"&&i._3._2==="West"){r=!1,o=J("Just",i._4);continue}}g()}return o},El=t=>e=>{const n=e.position._1+e.size._1,r=e.position._2*2+e.size._2,o=e.position._1*2+e.size._1,i=e.position._2+e.size._2;if(t==="South")return S(o,i*2);if(t==="North")return S(o,e.position._2*2);if(t==="East")return S(n*2,r);if(t==="West")return S(e.position._1*2,r);g()},Eg=t=>e=>{const n=rt(4);if(t==="South")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="North")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="East")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};if(t==="West")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};g()},Pl=t=>e=>v(n=>r=>Mt(t)(xe)(e(r))([r])(n))(M),Gl=t=>e=>n=>r=>{const o=(t==="South"||t==="North")&&(e==="East"||e==="West")&&(()=>{if(t==="South")return r._2>n._2;if(t==="North")return r._2<n._2;if(t==="East")return r._2>n._2;if(t==="West")return r._2<n._2;g()})()&&(()=>{if(e==="East")return n._1>r._1;if(e==="West"||e==="North")return n._1<r._1;if(e==="South")return n._1>r._1;g()})(),i=(t==="East"||t==="West")&&(e==="North"||e==="South")&&(()=>{if(t==="South")return r._1>n._1;if(t==="North")return r._1<n._1;if(t==="East")return r._1>n._1;if(t==="West")return r._1<n._1;g()})()&&(()=>{if(e==="East")return n._2>r._2;if(e==="West"||e==="North")return n._2<r._2;if(e==="South")return n._2>r._2;g()})();return(t==="South"?e==="North"&&n._1===r._1&&r._2>n._2:t==="North"?e==="South"&&n._1===r._1&&r._2<n._2:t==="East"?e==="West"&&n._2===r._2&&r._1>n._1:t==="West"&&e==="East"&&n._2===r._2&&r._1<n._1)?0:o||i?1:2},Rl=t=>e=>{const n=t.hi-t.lo,r=(t.lo+t.hi)/2,o=e.length;return o===0?M:Lg(o===1?V(i=>S(i,r))(e):Ht(i=>a=>S(a,t.lo+rt(i+1|0)*n/rt(o+1|0)))(e))},Al=t=>e=>n=>r=>o=>{const i=Pl(R)(d=>d.to.node)(t),a=Pl(R)(d=>d.from.node)(t),s=v(d=>h=>it(R)(h.node)(h)(d))(M)(e),u=(d,h,p)=>{const m=Xr(d)(s);if(m.tag==="Nothing")return S(0,0);if(m.tag==="Just"){const x=Xr(d)(n);if(x.tag==="Nothing"){const y=rt(4);if(p==="South")return S(m._1.position._1*y+m._1.size._1*y/2,(m._1.position._2+m._1.size._2)*y);if(p==="North")return S(m._1.position._1*y+m._1.size._1*y/2,m._1.position._2*y);if(p==="East")return S((m._1.position._1+m._1.size._1)*y,m._1.position._2*y+m._1.size._2*y/2);if(p==="West")return S(m._1.position._1*y,m._1.position._2*y+m._1.size._2*y/2);g()}if(x.tag==="Just"){const y=ne(w=>w.id===h)(x._1);if(y.tag==="Nothing"){const w=rt(4);if(p==="South")return S(m._1.position._1*w+m._1.size._1*w/2,(m._1.position._2+m._1.size._2)*w);if(p==="North")return S(m._1.position._1*w+m._1.size._1*w/2,m._1.position._2*w);if(p==="East")return S((m._1.position._1+m._1.size._1)*w,m._1.position._2*w+m._1.size._2*w/2);if(p==="West")return S(m._1.position._1*w,m._1.position._2*w+m._1.size._2*w/2);g()}if(y.tag==="Just"){const w=rt(4);if(y._1.side==="North")return S(m._1.position._1*w+rt(y._1.offset)*w,m._1.position._2*w);if(y._1.side==="South")return S(m._1.position._1*w+rt(y._1.offset)*w,(m._1.position._2+m._1.size._2)*w);if(y._1.side==="East")return S((m._1.position._1+m._1.size._1)*w,m._1.position._2*w+rt(y._1.offset)*w);if(y._1.side==="West")return S(m._1.position._1*w,m._1.position._2*w+rt(y._1.offset)*w)}}}g()},c=Lg(Et(r)(d=>{if(d.nodes.length<=2)return[];const h=rt(4);if(1<d.nodes.length){const p=Xr(d.nodes[1])(s);if(p.tag==="Nothing")return[];if(p.tag==="Just"){const m=p._1.position._1*h+p._1.size._1*h/2;return V(x=>S(x,m))(Oe(x=>y=>d.edgeId+":"+x+"->"+y,d.nodes,Rt(1,d.nodes.length,d.nodes)))}g()}return[]})),_=d=>{const h=Xr(d.from.node)(s),p=Xr(d.to.node)(s);if(h.tag==="Just"&&p.tag==="Just"){const m=h._1,x=p._1,y=Gt(w=>N=>ut.compare(w.score)(N.score))(V(w=>{const N=w._1,b=w._2;return{from:N,to:b,score:(()=>{const C=(W,P,G,j,nt)=>{const O=Eg(W)(P),$=Eg(W)(G);return O.lo<$.hi&&$.lo<O.hi&&(N==="South"?b==="North"&&nt._2>j._2:N==="North"?b==="South"&&nt._2<j._2:N==="East"?b==="West"&&nt._1>j._1:N==="West"&&b==="East"&&nt._1<j._1)?0:Gl(N)(b)(j)(nt)},L=El(N)(m),E=El(b)(x),I=Gl(N)(b)(L)(E);return(()=>{if(I>0){if(N==="South")return b==="North"?C(Ae,m,x,L,E)*10|0:I*10|0;if(N==="North")return b==="South"?C(Re,m,x,L,E)*10|0:I*10|0;if(N==="East")return b==="West"?C(qr,m,x,L,E)*10|0:I*10|0;if(N==="West"&&b==="East")return C(Vr,m,x,L,E)*10|0}return I*10|0})()+(N==="South"?b==="North"?x.layer>=m.layer?0:20:15:N==="North"?b==="South"?x.layer<=m.layer?0:20:15:N==="East"?b==="West"?5:15:N==="West"&&b==="East"?5:15)|0})()}})([S(Ae,Re),S(qr,Re),S(Vr,Re),S(Ae,qr),S(Ae,Vr),S(Re,Ae),S(Re,qr),S(Re,Vr),S(qr,Ae),S(Vr,Ae),S(qr,Vr),S(Vr,qr)]));if(0<y.length)return{from:y[0].from,to:y[0].to}}return{from:Ae,to:Re}},f=Lg(V(d=>S(d.id,_(d)))(t)),l=(d,h,p,m,x,y)=>{const w=rt(4),N=Xr(h)(s);if(N.tag==="Nothing")return S(0,0);if(N.tag==="Just"){const b=IN(S(p,d))(o);if(b.tag==="Just"){const C=N._1.position._1*w+b._1,L=rt(4);if(d==="South")return S(C,(N._1.position._2+N._1.size._2)*L);if(d==="North")return S(C,N._1.position._2*L);if(d==="East")return S((N._1.position._1+N._1.size._1)*L,C);if(d==="West")return S(N._1.position._1*L,C);g()}if(b.tag==="Nothing"){const C=Eg(d)(N._1),L=(C.lo+C.hi)/2,E=Sg(p)(Rl(C)(V(P=>P.id)(Gt(P=>G=>at.compare(x(d)(P))(x(d)(G)))(gt(P=>{const G=Sg(P.id)(f);if(G.tag==="Just"){const j=y(G._1);return j==="North"?d==="North":j==="South"?d==="South":j==="East"?d==="East":j==="West"&&d==="West"}if(G.tag==="Nothing")return!0;g()},(()=>{const P=Xr(h)(m);if(P.tag==="Nothing")return[];if(P.tag==="Just")return P._1;g()})()))))),I=(()=>{if(E.tag==="Nothing")return L;if(E.tag==="Just")return E._1;g()})(),W=rt(4);if(d==="South")return S(I,(N._1.position._2+N._1.size._2)*W);if(d==="North")return S(I,N._1.position._2*W);if(d==="East")return S((N._1.position._1+N._1.size._1)*W,I);if(d==="West")return S(N._1.position._1*W,I)}}g()};return V(d=>{const h=Sg(d.edge.id)(c);if(h.tag==="Nothing")return d;if(h.tag==="Just")return{...d,fromPos:Ie(3)(d.edge.from.node)==="$d:"?S(h._1,d.fromPos._2):d.fromPos,toPos:Ie(3)(d.edge.to.node)==="$d:"?S(h._1,d.toPos._2):d.toPos};g()})(V(d=>{if(d.from.port.tag==="Just"&&d.to.port.tag==="Just")return{edge:d,fromPos:u(d.from.node,d.from.port._1,Ae),toPos:u(d.to.node,d.to.port._1,Re),fromSide:Ae,toSide:Re};const h=_(d);return{edge:d,fromPos:l(h.from,d.from.node,d.id,a,p=>m=>{const x=Xr(m.to.node)(s);if(x.tag==="Nothing")return 0;if(x.tag==="Just"){const y=rt(4);if(p==="South"||p==="North")return x._1.position._1*y+x._1.size._1*y/2;if(p==="East"||p==="West")return x._1.position._2*y+x._1.size._2*y/2}g()},p=>p.from),toPos:l(h.to,d.to.node,d.id,i,p=>m=>{const x=Xr(m.from.node)(s);if(x.tag==="Nothing")return 0;if(x.tag==="Just"){const y=rt(4);if(p==="South"||p==="North")return x._1.position._1*y+x._1.size._1*y/2;if(p==="East"||p==="West")return x._1.position._2*y+x._1.size._2*y/2}g()},p=>p.to),fromSide:h.from,toSide:h.to}})(t))},Xs=(()=>{const t={eq:e=>n=>e._1===n._1&&(e._2==="North"?n._2==="North":e._2==="South"?n._2==="South":e._2==="East"?n._2==="East":e._2==="West"&&n._2==="West")};return{compare:e=>n=>{const r=R.compare(e._1)(n._1);if(r==="LT")return Be;if(r==="GT")return Me;if(e._2==="North")return n._2==="North"?nn:Be;if(n._2==="North")return Me;if(e._2==="South")return n._2==="South"?nn:Be;if(n._2==="South")return Me;if(e._2==="East")return n._2==="East"?nn:Be;if(n._2==="East")return Me;if(e._2==="West"&&n._2==="West")return nn;g()},Eq0:()=>t}})(),FN=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=Xs.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},DN=fe(R)(Wt),Pg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},zN=fe(Xs)(Wt),Il=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),$i=t=>e=>n=>r=>{const o=FN(S(e,n))(t);if(o.tag==="Nothing")return r;if(o.tag==="Just")return o._1;g()},Fl=t=>e=>n=>{const r=DN(Tn(V(a=>Ht(s=>u=>S(u,s))(a))(t))),o=(a,s)=>{if(a==="South"){const u=Pg(s.to.node)(r);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()}if(a==="North"){const u=Pg(s.from.node)(r);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()}return 0},i=a=>v(s=>u=>je(Xs.compare,Xe,zN(V(c=>S(S(c._1,a),c._2))(Il(Rl({lo:0,hi:(()=>{const c=Pg(u._1)(n);if(c.tag==="Just")return c._1._1;if(c.tag==="Nothing")return Ie(3)(u._1)==="$d:"?0:1;g()})()})(V(c=>c.id)(Gt(c=>_=>ut.compare(o(a,c))(o(a,_)))(u._2)))))),s))(M)(Il(v(s=>u=>u.from.node===u.to.node?s:a==="South"?Mt(R)(xe)(u.from.node)([u])(s):a==="North"?Mt(R)(xe)(u.to.node)([u])(s):s)(M)(e)));return je(Xs.compare,Xe,i(Re),i(Ae))},Dl=t=>t,zl=t=>t,Bl=t=>t,BN=v(t=>e=>it(R)(e)()(t))(M),MN=(()=>{const t=wn.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return J("Just",S(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._3,n(r._6,o)));g()};return n(e,D)})())})(),_t=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},$n=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Gr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Rr=fe(R)(Wt),Gg=Q1(R),Rg=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),QN=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},WN=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Ml=Bl("VDown"),Ql=Bl("VUp"),HN=zl("ForwardPhase"),ON=zl("StackPhase"),Wl=Dl("HRight"),Hl=Dl("HLeft"),Ol=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},qN=t=>e=>n=>{const r=v(a=>s=>Mt(R)(ve)(s.tgt)(1)(a))(M)(t),o=MN(BN([...V(a=>a.src)(t),...V(a=>a.tgt)(t),...(()=>{const a=(s,u)=>{if(s.tag==="Leaf")return u;if(s.tag==="Node")return a(s._5,yt("Cons",s._4,a(s._6,u)));g()};return Bt(ce.foldr,a(e,D))})()])),i=v(a=>s=>Mt(R)(xe)(s.src)([{target:s.tgt,sep:s.sep}])(a))(M)(t);return(a=>s=>u=>{let c=a,_=s,f=u,l=!0,d;for(;l;){const h=c,p=_,m=f,x=Pt(y=>T,y=>w=>J("Just",{head:y,tail:w}),h);if(x.tag==="Nothing"){l=!1,d=m;continue}if(x.tag==="Just"){const y=_t(x._1.head)(m),w=(()=>{if(y.tag==="Nothing")return 0;if(y.tag==="Just")return y._1;g()})(),N=v(b=>C=>{const L=_t(C.target)(b.result),E=w+C.sep,I=_t(C.target)(b.indeg),W=(()=>{if(I.tag==="Nothing")return-1;if(I.tag==="Just")return I._1-1|0;g()})();return{newQueue:W===0?[...b.newQueue,C.target]:b.newQueue,result:it(R)(C.target)((()=>{if(L.tag==="Nothing")return E;if(L.tag==="Just"){if(n==="VDown")return $n(L._1)(E);if(n==="VUp")return Gr(L._1)(E)}g()})())(b.result),indeg:it(R)(C.target)(W)(b.indeg)}})({newQueue:[],result:m,indeg:p})((()=>{const b=_t(x._1.head)(i);if(b.tag==="Nothing")return[];if(b.tag==="Just")return b._1;g()})());c=[...x._1.tail,...N.newQueue],_=N.indeg,f=N.result;continue}g()}return d})(gt(a=>{const s=_t(a)(r);if(s.tag==="Nothing")return!0;if(s.tag==="Just")return s._1===0;g()},o))(r)(v(a=>s=>it(R)(s)(0)(a))(M)(o))},VN=t=>{const e=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return e(i._5,yt("Cons",i._4,e(i._6,a)));g()},n=Bt(ce.foldr,e(t,D)),r=v($n)(999999)(n);if(r===0||n.length===0)return t;const o=i=>{if(i.tag==="Leaf")return M;if(i.tag==="Node")return Zt("Node",i._1,i._2,i._3,i._4-r,o(i._5),o(i._6));g()};return o(t)},ql=t=>{const e=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return e(i._5,yt("Cons",i._4,e(i._6,a)));g()},n=e(t,D),r=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=Gr(f)(l._1),u=l._2;continue}g()}return _},o=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=$n(f)(l._1),u=l._2;continue}g()}return _};return r(-999999)(n)-o(999999)(n)},Pa=t=>e=>(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(u===e){a=!1,s=c;continue}o=(()=>{const _=_t(u)(t.align);if(_.tag==="Nothing")return e;if(_.tag==="Just")return _._1;g()})(),i=[...c,u]}return s})((()=>{const n=_t(e)(t.align);if(n.tag==="Nothing")return e;if(n.tag==="Just")return n._1;g()})())([e]),$N=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>{const f=(A,B,z)=>{const Q=A.from.node===B?A.from.port:A.to.node===B?A.to.port:T;if(Q.tag==="Just"){const F=_t(B)(o);if(F.tag==="Just"){const X=ne(q=>q.id===Q._1)(F._1);if(X.tag==="Just"){const q=rt(X._1.offset)*rt(4);return z==="North"||z==="South"?q:0}if(X.tag==="Nothing"){const q=_t(B)(r),U=$i(a)(A.id)(z)((()=>{if(q.tag==="Nothing")return .5;if(q.tag==="Just")return q._1._1/2;g()})());return z==="North"||z==="South"?U:0}g()}if(F.tag==="Nothing"){const X=_t(B)(r),q=$i(a)(A.id)(z)((()=>{if(X.tag==="Nothing")return .5;if(X.tag==="Just")return X._1._1/2;g()})());return z==="North"||z==="South"?q:0}g()}if(Q.tag==="Nothing"){const F=_t(B)(r),X=$i(a)(A.id)(z)((()=>{if(F.tag==="Nothing")return .5;if(F.tag==="Just")return F._1._1/2;g()})());return z==="North"||z==="South"?X:0}g()},l=(A,B)=>{if(A.from.node===B){if(_==="HRight")return Ae;if(_==="HLeft")return Re;g()}if(_==="HRight")return Re;if(_==="HLeft")return Ae;g()},d=(A,B,z)=>v(Q=>F=>it(R)(F)((()=>{const X=_t(F)(Q);if(X.tag==="Nothing")return 0+B;if(X.tag==="Just")return X._1+B;g()})())(Q))(z)(Pa(u)(A)),h=(()=>{if(_==="HRight")return n;if(_==="HLeft")return ee(n);g()})(),p=A=>{const B=_t(A)(r);if(B.tag==="Nothing")return 1;if(B.tag==="Just")return B._1._1;g()},m=Rr(Tn(Ht(A=>B=>V(z=>S(z,A))(B))(n))),x=(A,B)=>Ie(3)(A)==="$d:"&&Ie(3)(B)==="$d:"||Ie(3)(A)==="$d:"||Ie(3)(B)==="$d:"?10:rt(t.nodeGap),y=v(A=>B=>Gg(z=>J("Just",[...(()=>{if(z.tag==="Nothing")return[];if(z.tag==="Just")return z._1;g()})(),B]))(B.to.node)(A))(M)(i),w=v(A=>B=>Gg(z=>J("Just",[...(()=>{if(z.tag==="Nothing")return[];if(z.tag==="Just")return z._1;g()})(),B]))(B.from.node)(A))(M)(i),N=Tn(n),b=v(A=>B=>{const z=_t(B)(u.root),Q=(()=>{if(z.tag==="Nothing")return B;if(z.tag==="Just")return z._1;g()})();return B===Q?A:Gg(F=>J("Just",(()=>{if(F.tag==="Nothing")return!0;if(F.tag==="Just")return F._1;g()})()&&Ie(3)(B)==="$d:"))(Q)(A)})(Rr(V(A=>S(A,!0))(Ei(R.compare)((()=>{const A=(B,z)=>{if(B.tag==="Leaf")return z;if(B.tag==="Node")return A(B._5,yt("Cons",B._4,A(B._6,z)));g()};return Bt(ce.foldr,A(u.root,D))})()))))(N),C=(A,B)=>{const z=A.free,Q=_t(z)(u.root),F=(()=>{if(Q.tag==="Nothing")return z;if(Q.tag==="Just")return Q._1;g()})(),X=_t(F)(b),q=(()=>{if(X.tag==="Nothing")return!0;if(X.tag==="Just")return X._1;g()})();return v(U=>Y=>{if(U.edge.tag==="Just")return U;if(U.edge.tag==="Nothing"){if((()=>{const dt=_t(F)(B.su);return!q&&(()=>{const Nt=_t(Y.from.node)(m);return Y.from.node!==Y.to.node&&(()=>{const St=_t(Y.to.node)(m);return(()=>{if(Nt.tag==="Nothing")return-1;if(Nt.tag==="Just")return Nt._1;g()})()===(()=>{if(St.tag==="Nothing")return-1;if(St.tag==="Just")return St._1;g()})()})()})()||(()=>{if(dt.tag==="Nothing")return!1;if(dt.tag==="Just")return dt._1;g()})()})())return U;const ot=Y.from.node===z?Y.to.node:Y.from.node,Z=_t(ot)(u.root),ft=(()=>{if(Z.tag==="Nothing")return ot;if(Z.tag==="Just")return Z._1;g()})(),Lt=ft!==F;return Lt&&(()=>{const dt=_t(ft)(B.blockFinished);if(dt.tag==="Nothing")return!1;if(dt.tag==="Just")return dt._1;g()})()?{...U,edge:J("Just",Y),hasEdges:!0}:{...U,hasEdges:U.hasEdges||Lt}}g()})({edge:T,hasEdges:!1})((()=>{if(A.isRoot){if(_==="HRight"){const U=_t(z)(y);if(U.tag==="Nothing")return[];if(U.tag==="Just")return U._1;g()}if(_==="HLeft"){const U=_t(z)(w);if(U.tag==="Nothing")return[];if(U.tag==="Just")return U._1}g()}if(_==="HRight"){const U=_t(z)(w);if(U.tag==="Nothing")return[];if(U.tag==="Just")return U._1;g()}if(_==="HLeft"){const U=_t(z)(y);if(U.tag==="Nothing")return[];if(U.tag==="Just")return U._1}g()})())},L=(A,B,z,Q)=>{const F=(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})(),X={free:B,isRoot:z},q=C(X,Q);if(q.edge.tag==="Nothing")return q.hasEdges?{thresh:F,state:{...Q,queue:[...Q.queue,X]}}:{thresh:F,state:Q};if(q.edge.tag==="Just"){const U=q.edge._1.from.node===B?q.edge._1.to.node:q.edge._1.from.node;return{thresh:(()=>{const Y=_t((()=>{const Lt=_t(U)(u.root);if(Lt.tag==="Nothing")return U;if(Lt.tag==="Just")return Lt._1;g()})())(Q.x),ot=_t(U)(s),Z=_t(B)(s),ft=(()=>{if(Y.tag==="Just")return Y._1;if(Y.tag==="Nothing")return T;g()})();return(()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(ot.tag==="Nothing")return 0;if(ot.tag==="Just")return ot._1;g()})()+f(q.edge._1,U,(()=>{if(z){if(_==="HRight")return Ae;if(_==="HLeft")return Re;g()}if(_==="HRight")return Re;if(_==="HLeft")return Ae;g()})())-(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()-f(q.edge._1,B,(()=>{if(z){if(_==="HRight")return Re;if(_==="HLeft")return Ae;g()}if(_==="HRight")return Ae;if(_==="HLeft")return Re;g()})())})(),state:{...Q,su:it(R)((()=>{const Y=_t(q.edge._1.from.node)(u.root);if(Y.tag==="Nothing")return q.edge._1.from.node;if(Y.tag==="Just")return Y._1;g()})())(!0)(it(R)((()=>{const Y=_t(q.edge._1.to.node)(u.root);if(Y.tag==="Nothing")return q.edge._1.to.node;if(Y.tag==="Just")return Y._1;g()})())(!0)(Q.su))}}}g()},E=(A,B,z,Q)=>{const F=B===A,X=_t(B)(u.align),q=(()=>{if(X.tag==="Nothing")return B===A;if(X.tag==="Just")return X._1===A;g()})();if(!(F||q))return{thresh:z,state:Q};const U=(()=>{if(c==="VDown")return F&&z<=-1e18;if(c==="VUp")return F&&z>=1e18;g()})()?L(A,B,!0,Q):{thresh:z,state:Q};return(()=>{if(c==="VDown")return U.thresh<=-1e18&&q;if(c==="VUp")return U.thresh>=1e18&&q;g()})()?L(A,B,!1,U.state):U},I=A=>B=>z=>{const Q=_t(z)(e.nodeIndex),F=(()=>{if(Q.tag==="Nothing")return 0;if(Q.tag==="Just")return Q._1;g()})(),X=ne(Z=>gn(vr)(z)(Z))(h),q=(()=>{if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1;g()})(),U=q.length;if((()=>{if(c==="VDown")return F<=0;if(c==="VUp")return F>=(U-1|0);g()})()){const Z=E(A,z,B.thresh,B.st);return{...B,st:Z.state,thresh:Z.thresh}}const Y=(()=>{if(c==="VDown")return F-1|0;if(c==="VUp")return F+1|0;g()})(),ot=Y>=0&&Y<q.length?J("Just",q[Y]):T;if(ot.tag==="Nothing")return B;if(ot.tag==="Just"){const Z=_t(ot._1)(u.root),ft=(()=>{if(Z.tag==="Nothing")return ot._1;if(Z.tag==="Just")return Z._1;g()})(),Lt=E(A,z,B.thresh,W(ft)(B.st)),dt=(()=>{const zt=_t(A)(Lt.state.sink);if(zt.tag==="Nothing")return A===A;if(zt.tag==="Just")return zt._1===A;g()})()?{...Lt.state,sink:it(R)(A)((()=>{const zt=_t(ft)(Lt.state.sink);if(zt.tag==="Nothing")return ft;if(zt.tag==="Just")return zt._1;g()})())(Lt.state.sink)}:Lt.state,Nt=_t(ft)(dt.sink),St=(()=>{if(Nt.tag==="Nothing")return ft;if(Nt.tag==="Just")return Nt._1;g()})(),te=_t(A)(dt.sink),Jt=(()=>{if(te.tag==="Nothing")return A;if(te.tag==="Just")return te._1;g()})();if(Jt===St){const zt=_t(ft)(dt.x),ie=(()=>{if(zt.tag==="Just")return zt._1;if(zt.tag==="Nothing")return T;g()})(),_e=(()=>{if(ie.tag==="Nothing")return 0;if(ie.tag==="Just")return ie._1;g()})(),cn=_t(A)(dt.x),qt=(()=>{if(cn.tag==="Just")return cn._1;if(cn.tag==="Nothing")return T;g()})(),jt=(()=>{if(qt.tag==="Nothing")return 0;if(qt.tag==="Just")return qt._1;g()})(),en=x(z,ot._1),He=_t(ot._1)(s),Bn=_t(z)(s),Mn=(()=>{if(He.tag==="Nothing")return 0;if(He.tag==="Just")return He._1;g()})()-(()=>{if(Bn.tag==="Nothing")return 0;if(Bn.tag==="Just")return Bn._1;g()})();if(c==="VDown"){const Ue=Gr(_e+Mn+p(ot._1)+en)(Lt.thresh);return{st:{...dt,x:it(R)(A)(J("Just",B.initial?Ue:Gr(jt)(Ue)))(dt.x)},initial:!1,thresh:Lt.thresh}}if(c==="VUp"){const Ue=$n(_e+Mn-en-p(z))(Lt.thresh);return{st:{...dt,x:it(R)(A)(J("Just",B.initial?Ue:$n(jt)(Ue)))(dt.x)},initial:!1,thresh:Lt.thresh}}g()}const Yt=_t(ft)(dt.x),Ft=(()=>{if(Yt.tag==="Just")return Yt._1;if(Yt.tag==="Nothing")return T;g()})(),vt=(()=>{if(Ft.tag==="Nothing")return 0;if(Ft.tag==="Just")return Ft._1;g()})(),mt=_t(A)(dt.x),lt=(()=>{if(mt.tag==="Just")return mt._1;if(mt.tag==="Nothing")return T;g()})(),xt=(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})(),It=rt(t.nodeGap),ht=_t(z)(s),Ct=_t(ot._1)(s),Qt=(()=>{if(ht.tag==="Nothing")return 0;if(ht.tag==="Just")return ht._1;g()})()-(()=>{if(Ct.tag==="Nothing")return 0;if(Ct.tag==="Just")return Ct._1;g()})();return{st:{...dt,classEdges:[...dt.classEdges,{src:Jt,tgt:St,sep:(()=>{if(c==="VDown")return xt+Qt-vt-p(ot._1)-It;if(c==="VUp")return xt+Qt+p(z)+It-vt;g()})()}]},initial:B.initial,thresh:Lt.thresh}}g()},W=A=>B=>{const z=_t(A)(B.x),Q=(()=>{if(z.tag==="Just")return z._1;if(z.tag==="Nothing")return T;g()})();if(Q.tag==="Just")return B;if(Q.tag==="Nothing"){const F=v(I(A))({st:{...B,x:it(R)(A)(J("Just",0))(B.x)},initial:!0,thresh:(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})()})(Pa(u)(A));return{...F.st,blockFinished:it(R)(A)(!0)(F.st.blockFinished)}}g()},P=v(A=>B=>v(z=>Q=>{const F=_t(Q)(u.root),X=(()=>{if(F.tag==="Nothing")return Q;if(F.tag==="Just")return F._1;g()})();return X===Q?W(X)(z):z})(A)((()=>{if(c==="VDown")return B;if(c==="VUp")return ee(B);g()})()))({x:Rr(V(A=>S(A,T))(N)),sink:Rr(V(A=>S(A,A))(N)),classEdges:[],su:M,blockFinished:M,queue:[]})(h),G=qN(P.classEdges)(P.sink)(c),j=(A,B,z,Q)=>{const F=_t(B)(Q),X=_t(B)(s);return(()=>{if(F.tag==="Nothing")return 0;if(F.tag==="Just")return F._1;g()})()+(()=>{if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1;g()})()+f(A,B,z)},nt=Rr(V(A=>S(A,!0))(Ei(R.compare)((()=>{const A=(B,z)=>{if(B.tag==="Leaf")return z;if(B.tag==="Node")return A(B._5,yt("Cons",B._4,A(B._6,z)));g()};return Bt(ce.foldr,A(u.root,D))})()))),O=A=>B=>z=>{const Q=C(z,{su:B.su,blockFinished:nt}),F={phase:A,ppFree:z.free,ppIsRoot:z.isRoot,edgeId:T,delta:0,avail:0,shift:0,freeSu:(()=>{const X=_t((()=>{const q=_t(z.free)(u.root);if(q.tag==="Nothing")return z.free;if(q.tag==="Just")return q._1;g()})())(B.su);if(X.tag==="Nothing")return!1;if(X.tag==="Just")return X._1;g()})(),hasEdges:Q.hasEdges,candCount:(()=>{if(z.isRoot){if(_==="HRight"){const X=_t(z.free)(y);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length;g()}if(_==="HLeft"){const X=_t(z.free)(w);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length}g()}if(_==="HRight"){const X=_t(z.free)(w);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length;g()}if(_==="HLeft"){const X=_t(z.free)(y);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length}g()})()};if(Q.edge.tag==="Nothing")return{...B,stack:[...B.stack,z],trace:[...B.trace,F],x:B.x};if(Q.edge.tag==="Just"){const X=Q.edge._1.from.node===z.free?S(Q.edge._1.from.node,Q.edge._1.to.node):S(Q.edge._1.to.node,Q.edge._1.from.node),q=j(Q.edge._1,X._1,l(Q.edge._1,X._1),B.x)-j(Q.edge._1,X._2,l(Q.edge._1,X._2),B.x),U=_t(X._1)(u.root),Y=(()=>{if(U.tag==="Nothing")return X._1;if(U.tag==="Just")return U._1;g()})(),ot={...F,edgeId:J("Just",Q.edge._1.id),delta:q};if(q>0&&q<1e300){const Z=v(dt=>Nt=>{const St=_t(Nt)(m),te=(()=>{if(St.tag==="Nothing")return-1;if(St.tag==="Just")return St._1;g()})();if(te>=0&&te<n.length){const Ft=n[te],vt=_t(Nt)(e.nodeIndex),mt=(()=>{if(vt.tag==="Nothing")return-2;if(vt.tag==="Just")return vt._1-1|0;g()})();return mt>=0&&mt<Ft.length?$n(dt)((()=>{const lt=_t(Nt)(B.x),xt=_t(Nt)(s),It=_t(Ft[mt])(B.x),ht=_t(Ft[mt])(s);return(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+(()=>{if(xt.tag==="Nothing")return 0;if(xt.tag==="Just")return xt._1;g()})()-((()=>{if(It.tag==="Nothing")return 0;if(It.tag==="Just")return It._1;g()})()+(()=>{if(ht.tag==="Nothing")return 0;if(ht.tag==="Just")return ht._1;g()})()+p(Ft[mt])+x(Nt,Ft[mt]))})()):dt}const Jt=_t(Nt)(e.nodeIndex),Yt=(()=>{if(Jt.tag==="Nothing")return-2;if(Jt.tag==="Just")return Jt._1-1|0;g()})();return Yt>=0&&Yt<0?$n(dt)((()=>{const Ft=_t(Nt)(B.x),vt=_t(Nt)(s),mt=_t([][Yt])(B.x),lt=_t([][Yt])(s);return(()=>{if(Ft.tag==="Nothing")return 0;if(Ft.tag==="Just")return Ft._1;g()})()+(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1;g()})()-((()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+p([][Yt])+x(Nt,[][Yt]))})()):dt})(q)(Pa(u)(Y)),ft=Z>0?-Z:0,Lt={...B,x:Z>0?d(Y,ft,B.x):B.x,trace:[...B.trace,{...ot,avail:Z,shift:ft}]};return Z>0?Lt:{...Lt,stack:[...Lt.stack,z]}}if(q<0&&-q<1e300){const Z=v(dt=>Nt=>{const St=_t(Nt)(m),te=(()=>{if(St.tag==="Nothing")return-1;if(St.tag==="Just")return St._1;g()})();if(te>=0&&te<n.length){const Ft=n[te],vt=_t(Nt)(e.nodeIndex),mt=(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1+1|0;g()})();return mt>=0&&mt<Ft.length?$n(dt)((()=>{const lt=_t(Ft[mt])(B.x),xt=_t(Ft[mt])(s),It=_t(Nt)(B.x),ht=_t(Nt)(s);return(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+(()=>{if(xt.tag==="Nothing")return 0;if(xt.tag==="Just")return xt._1;g()})()-((()=>{if(It.tag==="Nothing")return 0;if(It.tag==="Just")return It._1;g()})()+(()=>{if(ht.tag==="Nothing")return 0;if(ht.tag==="Just")return ht._1;g()})()+p(Nt)+x(Nt,Ft[mt]))})()):dt}const Jt=_t(Nt)(e.nodeIndex),Yt=(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1+1|0;g()})();return Yt>=0&&Yt<0?$n(dt)((()=>{const Ft=_t([][Yt])(B.x),vt=_t([][Yt])(s),mt=_t(Nt)(B.x),lt=_t(Nt)(s);return(()=>{if(Ft.tag==="Nothing")return 0;if(Ft.tag==="Just")return Ft._1;g()})()+(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1;g()})()-((()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+p(Nt)+x(Nt,[][Yt]))})()):dt})(-q)(Pa(u)(Y)),ft=Z>0?Z:0,Lt={...B,x:Z>0?d(Y,ft,B.x):B.x,trace:[...B.trace,{...ot,avail:Z,shift:ft}]};return Z>0?Lt:{...Lt,stack:[...Lt.stack,z]}}return{...B,stack:[...B.stack,z],trace:[...B.trace,ot],x:B.x}}g()},$=v(O(HN))({x:Rr(V(A=>S(A,(()=>{const B=_t(A)(u.root),z=(()=>{if(B.tag==="Nothing")return A;if(B.tag==="Just")return B._1;g()})(),Q=_t(z)(P.x),F=_t((()=>{const q=_t(z)(P.sink);if(q.tag==="Nothing")return z;if(q.tag==="Just")return q._1;g()})())(G),X=(()=>{if(Q.tag==="Just")return Q._1;if(Q.tag==="Nothing")return T;g()})();return(()=>{if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1;g()})()+(()=>{if(F.tag==="Nothing")return 0;if(F.tag==="Just")return F._1;g()})()})()))(N)),su:P.su,stack:[],trace:[]})(P.queue),H=v(O(ON))({...$,stack:[]})(ee($.stack));return{x:H.x,queue:P.queue,trace:H.trace}},UN=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>$N(t)(e)(n)(r)(o)(i)(a)(s)(u)(c)(_).x,XN=t=>e=>n=>r=>o=>i=>{const a=(u,c,_)=>{const f=_t(c)(n),l=(()=>{if(f.tag==="Nothing")return .5;if(f.tag==="Just")return f._1._1/2;g()})(),d=u.from.node===c?u.from.port:u.to.node===c?u.to.port:T;if(d.tag==="Just"){const h=_t(c)(e);if(h.tag==="Just"){const p=ne(m=>m.id===d._1)(h._1);if(p.tag==="Just"){const m=rt(p._1.offset)*rt(4);return _==="North"||_==="South"?m:0}if(p.tag==="Nothing"){const m=$i(o)(u.id)(_)(l);return _==="North"||_==="South"?m:0}g()}if(h.tag==="Nothing"){const p=$i(o)(u.id)(_)(l);return _==="North"||_==="South"?p:0}g()}if(d.tag==="Nothing"){const h=$i(o)(u.id)(_)(l);return _==="North"||_==="South"?h:0}g()},s=u=>c=>_=>f=>{let l=u,d=c,h=_,p=f,m=!0,x;for(;m;){const y=l,w=d,N=h,b=Pt(C=>T,C=>L=>J("Just",{head:C,tail:L}),p);if(b.tag==="Nothing"){m=!1,x=y;continue}if(b.tag==="Just"){const C=b._1.head,L=ne(I=>I.from.node===N&&I.to.node===C||I.from.node===C&&I.to.node===N)(r),E=(()=>{if(L.tag==="Nothing")return w+0;if(L.tag==="Just")return w+(a(L._1,N,L._1.from.node===N?Ae:Re)-a(L._1,C,L._1.from.node===C?Ae:Re));g()})();l=it(R)(C)(E)(y),d=E,h=C,p=b._1.tail;continue}g()}return x};return v(u=>c=>{const _=Pt(d=>T,d=>h=>J("Just",{head:d,tail:h}),Pa(t)(c)),f=(()=>{if(_.tag==="Nothing")return it(R)(c)(0)(M);if(_.tag==="Just")return s(it(R)(_._1.head)(0)(M))(0)(_._1.head)(_._1.tail);g()})(),l=v(d=>h=>Gr(d)(-h._2))(0)(Rg(f));return v(d=>h=>it(R)(h._1)(h._2+l)(d))(u)(Rg(f))})(M)(Ei(R.compare)((()=>{const u=(c,_)=>{if(c.tag==="Leaf")return _;if(c.tag==="Node")return u(c._5,yt("Cons",c._4,u(c._6,_)));g()};return Bt(ce.foldr,u(t.root,D))})()))},YN=t=>e=>{const n=(o,i,a)=>Ie(3)(i)==="$d:"&&vc(Cl,(()=>{const s=_t(i)(t.preds);if(s.tag==="Nothing")return[];if(s.tag==="Just")return s._1;g()})()),r=o=>i=>a=>s=>u=>c=>_=>{let f=o,l=i,d=s,h=c,p=_,m=!0,x;for(;m;){const y=f,w=l,N=d,b=h,C=p,L=w.length;if(C>=L){m=!1,x=y;continue}const E=C>=0&&C<w.length?J("Just",w[C]):T,I=(()=>{if(E.tag==="Nothing")return"";if(E.tag==="Just")return E._1;g()})(),W=n(t,I);if(C===(L-1|0)||W){const P=(()=>{if(W){const G=_t(I)(t.preds),j=(()=>{if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})();if(0<j.length){const nt=N-1|0,O=_t(j[0])(t.nodeIndex);if(O.tag==="Nothing")return nt;if(O.tag==="Just")return O._1;g()}}return N-1|0})();f=v(G=>j=>{if(j>=0&&j<w.length){const nt=w[j];return n(t,nt)?G:v(O=>$=>{const H=_t($)(t.nodeIndex),A=(()=>{if(H.tag==="Nothing")return 0;if(H.tag==="Just")return H._1;g()})();return A<b||A>P?it(R)($+"\u2192"+nt)()(O):O})(G)((()=>{const O=_t(nt)(t.preds);if(O.tag==="Nothing")return[];if(O.tag==="Just")return O._1;g()})())}return n(t,"")?G:v(nt=>O=>{const $=_t(O)(t.nodeIndex),H=(()=>{if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})();return H<b||H>P?it(R)(O+"\u2192")()(nt):nt})(G)((()=>{const nt=_t("")(t.preds);if(nt.tag==="Nothing")return[];if(nt.tag==="Just")return nt._1;g()})())})(y)($t(0,C)),l=w,d=N,h=P,p=C+1|0;continue}f=y,l=w,d=N,h=b,p=C+1|0}return x};return e.length<3?M:v(o=>i=>{if(i>=0&&i<e.length){const a=e[i];return r(o)((()=>{const s=i+1|0;return s>=0&&s<e.length?e[s]:[]})())(a)(a.length)(i)(0)(0)}return r(o)((()=>{const a=i+1|0;return a>=0&&a<e.length?e[a]:[]})())([])(0)(i)(0)(0)})(M)($t(1,e.length-2|0))},KN=t=>e=>n=>r=>o=>{const i=Tn(e),a=v(s=>u=>{const c=v(_=>f=>{const l=(()=>{if(o==="HRight"){const m=_t(f)(t.preds);if(m.tag==="Nothing")return[];if(m.tag==="Just")return m._1;g()}if(o==="HLeft"){const m=_t(f)(t.succs);if(m.tag==="Nothing")return[];if(m.tag==="Just")return m._1}g()})(),d=l.length;if(d===0)return _;const h=Jr(d-1|0,2),p=Jr(d,2);return v(m=>x=>{if((()=>{const y=_t(f)(m.align);if(y.tag==="Nothing")return f!==f;if(y.tag==="Just")return y._1!==f;g()})())return m;if(x>=0&&x<l.length){const y=_t(l[x])(t.nodeIndex),w=(()=>{if(y.tag==="Nothing")return 0;if(y.tag==="Just")return y._1;g()})();if(!(Ol(l[x]+"\u2192"+f)(n)||Ol(f+"\u2192"+l[x])(n))&&(()=>{if(r==="VDown")return m.r<w;if(r==="VUp")return m.r>w;g()})()){const N=_t(l[x])(m.root),b=(()=>{if(N.tag==="Nothing")return l[x];if(N.tag==="Just")return N._1;g()})();return{root:it(R)(f)(b)(m.root),align:it(R)(l[x])(f)(it(R)(f)(b)(m.align)),r:w}}}return m})(_)((()=>{if(r==="VDown")return $t(h,p);if(r==="VUp")return ee($t(h,p));g()})())})({root:s.root,align:s.align,r:(()=>{if(r==="VDown")return-1;if(r==="VUp")return 999999;g()})()})((()=>{if(r==="VDown")return u;if(r==="VUp")return ee(u);g()})());return{root:c.root,align:c.align}})({root:Rr(V(s=>S(s,s))(i)),align:Rr(V(s=>S(s,s))(i))})((()=>{if(o==="HRight")return e;if(o==="HLeft")return ee(e);g()})());return{root:a.root,align:a.align}},Ys=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>{const _=KN(e)(n)(s)(u)(c),f=XN(_)(o)(r)(i)(a)(c);return U2()(l=>d=>J("Just",(()=>{const h=_t(l)(f);if(h.tag==="Nothing")return d+0;if(h.tag==="Just")return d+h._1;g()})()))(UN(t)(e)(n)(r)(o)(i)(a)(f)(_)(u)(c))},Vl=t=>e=>Ht(n=>r=>v(o=>i=>i>=0&&i<e.length?i>=0&&i<t.length?o+e[i]+t[i]:o+e[i]+0:i>=0&&i<t.length?o+1+t[i]:o+1)(0)((()=>{const o=$t(0,e.length-1|0);return n<1?[]:Rt(0,n,o)})()))(e),jN=t=>e=>n=>r=>o=>i=>a=>{const s=QN(0)(e.length-1|0),u=rt(t.layerGap),c=a(Ro(s,u)),_=AN(Al(o)(c)(r)(i)(M))(c);return V(f=>{const l=WN(f)(_);return l.tag==="Just"&&l._1>0?Gr(u)(2+rt(l._1-1|0)*2.5):u})($t(0,s-1|0))},$l=t=>e=>n=>r=>vc(o=>v(i=>a=>{if(!i.ok)return i;const s=_t(a)(r),u=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})(),c=_t(a)(n),_=(()=>{if(c.tag==="Nothing")return u+1;if(c.tag==="Just")return u+c._1._1;g()})();return u+1e-4>i.pos&&_+1e-4>i.pos?{ok:!0,pos:_}:{ok:!1,pos:i.pos}})({ok:!0,pos:-1e18})(o).ok,e),ZN=t=>e=>n=>r=>{const o=Gt(i=>a=>at.compare(i.w)(a.w))(V(i=>({l:i,w:ql(i)}))(gt($l()(e)(n),r)));return 0<o.length?J("Just",o[0].l):T},tJ=t=>e=>{const n=Rr(Tn(V(Ht(o=>i=>S(i,o)))(t))),r=o=>Gt(i=>a=>ut.compare((()=>{const s=_t(i)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})())((()=>{const s=_t(a)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(o);return{preds:(()=>{const o=i=>{if(i.tag==="Leaf")return M;if(i.tag==="Node")return Zt("Node",i._1,i._2,i._3,r(i._4),o(i._5),o(i._6));g()};return o(v(i=>a=>Mt(R)(xe)(a.to.node)([a.from.node])(i))(M)(e))})(),succs:(()=>{const o=i=>{if(i.tag==="Leaf")return M;if(i.tag==="Node")return Zt("Node",i._1,i._2,i._3,r(i._4),o(i._5),o(i._6));g()};return o(v(i=>a=>Mt(R)(xe)(a.from.node)([a.to.node])(i))(M)(e))})(),nodeIndex:n}},eJ=t=>e=>{const n=Gt(f=>l=>at.compare(f.w)(l.w))(Ht(f=>l=>({i:f,l,w:ql(l)}))(e)),r=0<n.length?J("Just",n[0]):T,o=(()=>{if(r.tag==="Just")return r._1.i;if(r.tag==="Nothing")return 0;g()})(),i=o>=0&&o<e.length?J("Just",e[o]):T,a=(()=>{if(i.tag==="Just")return(f=>l=>{let d=f,h=l,p=!0,m;for(;p;){const x=d,y=h;if(y.tag==="Nil"){p=!1,m=x;continue}if(y.tag==="Cons"){d=$n(x)(y._1),h=y._2;continue}g()}return m})(999999)((()=>{const f=(l,d)=>{if(l.tag==="Leaf")return d;if(l.tag==="Node")return f(l._5,yt("Cons",l._4,f(l._6,d)));g()};return f(i._1,D)})());if(i.tag==="Nothing")return 0;g()})(),s=f=>v(l=>d=>Gr(l)((()=>{const h=_t(d._1)(t);if(h.tag==="Nothing")return d._2+1;if(h.tag==="Just")return d._2+h._1._1;g()})()))(-999999)(Rg(f)),u=o>=0&&o<e.length?J("Just",e[o]):T,c=(()=>{if(u.tag==="Just")return s(u._1);if(u.tag==="Nothing")return 0;g()})(),_=Oe(f=>l=>{const d=h=>{if(h.tag==="Leaf")return M;if(h.tag==="Node")return Zt("Node",h._1,h._2,h._3,h._4+l,d(h._5),d(h._6));g()};return d(f)},e,Ht(f=>l=>ao(f)(2)===0?a-(d=>h=>{let p=d,m=h,x=!0,y;for(;x;){const w=p,N=m;if(N.tag==="Nil"){x=!1,y=w;continue}if(N.tag==="Cons"){p=$n(w)(N._1),m=N._2;continue}g()}return y})(999999)((()=>{const d=(h,p)=>{if(h.tag==="Leaf")return p;if(h.tag==="Node")return d(h._5,yt("Cons",h._4,d(h._6,p)));g()};return d(l,D)})()):c-s(l))(e));return VN(v(f=>l=>{const d=Gt(at.compare)(Tt(_t(l))(_));return it(R)(l)(d.length===4?1<d.length&&2<d.length?(d[1]+d[2])/2:0:0<d.length?d[0]:0)(f)})(M)(Ei(R.compare)(Tn(V(f=>{const l=d=>{if(d.tag==="Leaf")return M;if(d.tag==="Node")return Zt("Node",d._1,d._2,d._3,void 0,l(d._5),l(d._6));g()};return Bt(fn.foldr,l(f))})(_)))))},nJ=t=>e=>n=>r=>o=>i=>{const a=tJ(e)(o),s=YN(a)(e),u={nodeGap:t.nodeGap*4|0},c=je(R.compare,Xe,Rr(V(d=>S(d,S(1,1)))(gt(Cl,Tn(e)))),(()=>{const d=h=>{if(h.tag==="Leaf")return M;if(h.tag==="Node")return Zt("Node",h._1,h._2,h._3,S(h._4._1*rt(4),h._4._2),d(h._5),d(h._6));g()};return d(n)})()),_=[Ys(u)(a)(e)(c)(r)(o)(i)(s)(Ml)(Wl),Ys(u)(a)(e)(c)(r)(o)(i)(s)(Ql)(Wl),Ys(u)(a)(e)(c)(r)(o)(i)(s)(Ml)(Hl),Ys(u)(a)(e)(c)(r)(o)(i)(s)(Ql)(Hl)],f=eJ(c)(_);if($l()(e)(c)(f))return f;const l=ZN()(e)(c)(_);if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return _[0];g()},rJ=t=>e=>n=>r=>{const o=A1(T,S1,i=>i.node===e?J("Just",i.position):T,t);if(o.tag==="Nothing")return t;if(o.tag==="Just"){const i=o._1;return V(a=>a.node===n?{...a,position:S(i._1+r._1,i._2+r._2)}:a)(t)}g()},oJ=t=>e=>n=>r=>{const o=gt(a=>gn(vr)(a.node)(e),t),i=(()=>{if(n==="Vertical"){if(r==="Start")return v(a=>s=>$n(a)(s.position._1))(99999)(o);if(r==="End")return v(a=>s=>Gr(a)(s.position._1))(0)(o);if(r==="Center"){const a=v(s=>u=>s+u.position._1)(0)(o);return o.length===0?0:a/rt(o.length)}g()}if(n==="Horizontal"){if(r==="Start")return v(a=>s=>$n(a)(s.position._2))(99999)(o);if(r==="End")return v(a=>s=>Gr(a)(s.position._2))(0)(o);if(r==="Center"){const a=v(s=>u=>s+u.position._2)(0)(o);return o.length===0?0:a/rt(o.length)}}g()})();return V(a=>{if(gn(vr)(a.node)(e)){if(n==="Vertical")return{...a,position:S(i,a.position._2)};if(n==="Horizontal")return{...a,position:S(a.position._1,i)};g()}return a})(t)},iJ=t=>e=>v(n=>r=>r.tag==="AlignGroup"?oJ(n)(r._1.nodes)(r._1.axis)(r._1.alignment):r.tag==="RelativePosition"?rJ(n)(r._1.anchor)(r._1.target)(r._1.offset):n)(e)(t),aJ=t=>e=>n=>r=>o=>i=>a=>s=>{const u=V(f=>v(l=>d=>Gr(l)((()=>{const h=_t(d)(r);if(h.tag==="Nothing")return 1;if(h.tag==="Just")return h._1._2;g()})()))(1)(f))(n),c=nJ(t)(n)(r)(o)(i)(s),_=Vl(jN(t)(n)(r)(o)(i)(a)(f=>{const l=Vl(f)(u);return Tn(Ht(d=>h=>Ht(p=>m=>({node:m,position:S((()=>{const x=_t(m)(c);return(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})()/rt(4)})(),d>=0&&d<l.length?l[d]:0),size:(()=>{const x=Ie(3)(m)==="$d:"?S(0,1):S(1,1),y=_t(m)(r);if(y.tag==="Nothing")return x;if(y.tag==="Just")return y._1;g()})(),layer:d,order:p}))(h))(n))}))(u);return iJ(e)(Tn(Ht(f=>l=>Ht(d=>h=>({node:h,position:S((()=>{const p=_t(h)(c);return(()=>{if(p.tag==="Nothing")return 0;if(p.tag==="Just")return p._1;g()})()/rt(4)})(),f>=0&&f<_.length?_[f]:0),size:(()=>{const p=Ie(3)(h)==="$d:"?S(0,1):S(1,1),m=_t(h)(r);if(m.tag==="Nothing")return p;if(m.tag==="Just")return m._1;g()})(),layer:f,order:d}))(l))(n)))},Ag=qc(ws)(zo(32)),Ul=qc(ws)(zo(31)),Ga=(()=>{const t=Hy("25214903917");if(t.tag==="Nothing")return sf;if(t.tag==="Just")return t._1;g()})(),Ra=Oc(qc(ws)(zo(48)))(ws),sJ=t=>{const e=Oy(t);return pa(uf((()=>{if(e.tag==="Nothing")return sf;if(e.tag==="Just")return e._1;g()})())(Ga))(Ra)},Ig=zo(11),Ks=t=>e=>{const n=pa(xs(Ts(e)(Ga))(Ig))(Ra);return S((()=>{const r=D1(By(Vc(n)(zo(48-t|0))));if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()})(),n)},uJ=t=>{const e=Ks(26)(t),n=Ks(27)(e._2);return S((rt(e._1)*bc(2)(27)+rt(n._1))/bc(2)(53),n._2)},cJ=t=>e=>{const n=v(r=>o=>{const i=uJ(r.finalR);return{rs:[...r.rs,i._1],finalR:i._2}})({rs:[],finalR:t})(e);return S(V(r=>r.x)(Gt(r=>o=>at.compare(r.k)(o.k))(Oe(r=>o=>({x:r,k:o}),e,n.rs))),n.finalR)},gJ=t=>{const e=pa(xs(Ts(t)(Ga))(Ig))(Ra),n=pa(xs(Ts(e)(Ga))(Ig))(Ra);return S(xs(Ts((()=>{const r=Vc(e)(zo(16));return cf.compare(r)(Ul)!=="LT"?Oc(r)(Ag):r})())(Ag))((()=>{const r=Vc(n)(zo(16));return cf.compare(r)(Ul)!=="LT"?Oc(r)(Ag):r})()),n)},Aa=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},js=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Fg=fe(R)(Wt),Ui=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Zs=fe(R)(Wt),_J=Nc(sa),fJ=v(hr)(0),lJ=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Xl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},dJ=t=>e=>n=>{if(t>=0&&t<n.length){const r=n[t];if(e>=0&&e<n.length){const o=io(Vt,T,t,n[e],n);if(o.tag==="Just")return io(Vt,T,e,r,o._1);if(o.tag==="Nothing")return T;g()}}return T},hJ=t=>e=>n=>r=>o=>Fg(v(i=>a=>{const s=Gt(u=>c=>ut.compare((()=>{const _=Aa(u.id)(o);if(_.tag==="Nothing")return 1e6;if(_.tag==="Just")return _._1;g()})())((()=>{const _=Aa(c.id)(o);if(_.tag==="Nothing")return 1e6;if(_.tag==="Just")return _._1;g()})()))(gt(u=>js(u.to.node)(n),gt(u=>u.from.node===a,r)));return{ranks:[...i.ranks,...Ht(u=>c=>S(c.id,rt((i.rankSum+u|0)+1|0)))(s)],rankSum:i.rankSum+s.length|0}})({ranks:[],rankSum:0})(t).ranks),pJ=t=>e=>n=>r=>o=>Fg(v(i=>a=>{const s=Gt(c=>_=>{const f=ut.compare((()=>{const l=Ui(_.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=Ui(c.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})());return f==="EQ"?ut.compare((()=>{const l=Aa(c.id)(o);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})())((()=>{const l=Aa(_.id)(o);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})()):f})(gt(c=>js(c.from.node)(n),gt(c=>c.to.node===a,r))),u=s.length;return{ranks:[...i.ranks,...Ht(c=>_=>S(_.id,rt((i.rankSum+u|0)-c|0)))(s)],rankSum:i.rankSum+u|0}})({ranks:[],rankSum:0})(t).ranks),Dg=t=>e=>n=>{const r=Zs(Ht(s=>u=>S(u,s))(t)),o=Zs(Ht(s=>u=>S(u,s))(e)),i=Tt(s=>{const u=Ui(s.from.node)(r),c=Ui(s.to.node)(o);if(u.tag==="Just"&&c.tag==="Just")return J("Just",S(u._1,c._1));const _=Ui(s.from.node)(o),f=Ui(s.to.node)(r);return _.tag==="Just"&&f.tag==="Just"?J("Just",S(f._1,_._1)):T})(n),a=i.length;return v(s=>u=>v(c=>_=>u>=0&&u<i.length&&_>=0&&_<i.length&&((i[u]._1-i[_]._1|0)*(i[u]._2-i[_]._2|0)|0)<0?c+1|0:c)(s)($t(u+1|0,a-1|0)))(0)($t(0,a-2|0))},mJ=t=>e=>n=>r=>{const o=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l>=(f.length-1|0)){c=!1,_=f;continue}if(l>=0&&l<f.length){const d=l+1|0;if(d>=0&&d<f.length){const h=f[l],p=f[d];if(ue(w=>w.before===h&&w.after===p,r)){s=f,u=l+1|0;continue}const m=io(Vt,T,l,p,f),x=(()=>{if(m.tag==="Just")return io(Vt,T,l+1|0,h,m._1);if(m.tag==="Nothing")return T;g()})(),y=(()=>{if(x.tag==="Nothing")return f;if(x.tag==="Just")return x._1;g()})();if(Dg(e)(y)(n)<Dg(e)(f)(n)){s=y,u=l+1|0;continue}s=f,u=l+1|0;continue}c=!1,_=f;continue}c=!1,_=f}return _};return(i=>{let a=i,s=!0,u;for(;s;){const c=a,_=o(c)(0);if(_J(_)(c)){s=!1,u=c;continue}a=_}return u})(t)},tu=t=>e=>v(n=>r=>{if(r>=0&&r<t.length){const o=t[r],i=r+1|0;if(i>=0&&i<t.length)return n+Dg(o)(t[i])(e)|0}return n})(0)($t(0,t.length-2|0)),yJ=(()=>{const t=e=>{if(e.length<7){const i=a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c,h=d-1|0;if(h>=0&&h<l.length){if(d>=0&&d<l.length&&d>0&&l[h].key>l[d].key){const p=dJ(d-1|0)(d)(l);if(p.tag==="Just"){u=p._1,c=d-1|0;continue}if(p.tag==="Nothing"){_=!1,f=l;continue}g()}_=!1,f=l;continue}_=!1,f=l}return f};return v(a=>s=>i(a)(s))(e)($t(1,e.length-1|0))}const n=Jr(e.length,2),r=t(Rt(0,n,e)),o=t(Rt(n,e.length,e));return(i=>a=>s=>{let u=i,c=a,_=s,f=!0,l;for(;f;){const d=u,h=c,p=_;if(h>=0&&h<r.length){if(p>=0&&p<o.length){if(r[h].key>o[p].key){u=wt(d)(o[p]),c=h,_=p+1|0;continue}u=wt(d)(r[h]),c=h+1|0,_=p;continue}f=!1,l=[...d,...h<1?r:Rt(h,r.length,r)];continue}f=!1,l=[...d,...p<1?o:Rt(p,o.length,o)]}return l})([])(0)(0)};return t})(),xJ=t=>e=>n=>{const r=Tt(c=>c.tag==="OrderConstraint"?J("Just",{before:c._1.before,after:c._1.after}):T)(t.constraints),o=c=>v(_=>f=>{const l=f.after,d=f.before,h=Or(Vt,T,m=>m===d,_),p=Or(Vt,T,m=>m===l,_);if(h.tag==="Just"&&p.tag==="Just"&&h._1>p._1){const m=F1(Vt,T,h._1,_),x=(()=>{if(m.tag==="Nothing")return _;if(m.tag==="Just")return m._1;g()})(),y=I1(Vt,T,p._1,d,x);if(y.tag==="Nothing")return x;if(y.tag==="Just")return y._1;g()}return _})(c)(r),i=Fg(Ht(c=>_=>S(_.id,c))(n)),a=(c,_,f)=>{const l=c.length;return v(d=>h=>{const p=_?h-1|0:h+1|0,m=p>=0&&p<d._1.length?J("Just",d._1[p]):T;if(m.tag==="Just"){const x=h>=0&&h<d._1.length?J("Just",d._1[h]):T;if(x.tag==="Just"){const y=Zs(Ht(L=>E=>S(E,L))(m._1)),w=Zs(Ht(L=>E=>S(E,L))(x._1)),N=_?hJ(m._1)(y)(w)(n)(i):pJ(m._1)(y)(w)(n)(i),b=v(L=>E=>{const I=Tt(P=>Aa(P.id)(N))(gt(_?P=>P.to.node===E._2&&js(P.from.node)(y):P=>P.from.node===E._2&&js(P.to.node)(y),n));if(I.length===0)return{...L,items:[...L.items,{n:E._2,key:T,origIdx:E._1}]};const W=Ks(24)(L.r);return{items:[...L.items,{n:E._2,key:J("Just",(fJ(I)+(rt(W._1)*4172325152040912e-24-.03500000014901161))/rt(I.length)),origIdx:E._1}],r:W._2}})({items:[],r:d._2})(Ht(Ln)(x._1)),C=io(Vt,T,h,mJ(o(V(L=>L.n)(yJ((()=>{const L=b.items,E=I=>W=>{let P=I,G=W,j=!0,nt;for(;j;){const O=P,$=G;if(O>=0&&O<L.length){if(L[O].key.tag==="Just"){j=!1,nt=L[O].key._1;continue}if(L[O].key.tag==="Nothing"){P=O+1|0,G=$;continue}g()}j=!1,nt=$}return nt};return(I=>W=>P=>{let G=I,j=W,nt=P,O=!0,$;for(;O;){const H=G,A=j,B=nt;if(H>=0&&H<L.length){if(L[H].key.tag==="Just"){G=H+1|0,j=L[H].key._1,nt=[...B,{n:L[H].n,key:L[H].key._1,origIdx:L[H].origIdx}];continue}if(L[H].key.tag==="Nothing"){const z=(A+E(H+1|0)(A+1))/2;G=H+1|0,j=z,nt=[...B,{n:L[H].n,key:z,origIdx:L[H].origIdx}];continue}g()}O=!1,$=B}return $})(0)(-1)([])})()))))(m._1)(n)(r),d._1);if(C.tag==="Just")return S(C._1,b.r);if(C.tag==="Nothing")return S(d._1,d._2);g()}if(x.tag==="Nothing")return S(d._1,d._2);g()}if(m.tag==="Nothing")return S(d._1,d._2);g()})(S(c,f))(_?$t(1,l-1|0):ee($t(0,l-2|0)))},s=v(c=>_=>it(R)(_.from.node)()(it(R)(_.to.node)()(c)))(M)(n),u=v(c=>_=>{if(c.result.crossings===0)return c;const f=y=>w=>N=>b=>{let C=y,L=w,E=N,I=b,W=!0,P;for(;W;){const G=C,j=L,nt=E,O=I;if(nt===0){W=!1,P={layout:G,crossings:0,random:O};continue}const $=a(G,j,O),H=tu($._1)(n);if(H<nt){C=$._1,L=!j,E=H,I=$._2;continue}W=!1,P={layout:G,crossings:nt,random:$._2}}return P},l=Ks(1)(c.result.random),d=l._1!==0,h=t.modelOrder.tag==="Leaf",p=(c.firstTry||c.secondTry)&&!h?c.firstTry:d,m=(()=>{if(!h){const b=a(e,p,l._2);return f(b._1)(!p)(tu(b._1)(n))(b._2)}const y=p?0:lJ(0)(e.length-1|0),w=y>=0&&y<e.length?J("Just",e[y]):T;if(w.tag==="Just"&&w._1.length>1){const b=gt(C=>Xl(C)(s),w._1);if(b.length>1){const C=cJ(l._2)(b),L=C._1,E=io(Vt,T,y,o(v(I=>W=>Xl(W)(s)?I.idx>=0&&I.idx<L.length?{idx:I.idx+1|0,result:[...I.result,L[I.idx]]}:{idx:I.idx,result:[...I.result,W]}:{idx:I.idx,result:[...I.result,W]})({idx:0,result:[]})(w._1).result),e);if(E.tag==="Just"){const I=a(E._1,p,C._2);return f(I._1)(!p)(tu(I._1)(n))(I._2)}}}const N=a(e,p,l._2);return f(N._1)(!p)(tu(N._1)(n))(N._2)})(),x=c.secondTry?!1:c.secondTry;return c.firstTry?{result:m.crossings<c.result.crossings?{layout:m.layout,crossings:m.crossings,random:m.random}:{...c.result,random:m.random},firstTry:!1,secondTry:!0}:{result:m.crossings<c.result.crossings?{layout:m.layout,crossings:m.crossings,random:m.random}:{...c.result,random:m.random},firstTry:c.firstTry,secondTry:x}})({result:{layout:e,crossings:1e9,random:pa(uf(gJ(sJ(1))._1)(Ga))(Ra)},firstTry:t.modelOrder.tag!=="Leaf",secondTry:!1})($t(1,t.iterations)).result;return e.length<=0||t.iterations<=0?e:u.layout},TJ=t=>t,Yl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},dn=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Xi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Ia=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=R.compare(e._1)(n._1);return r==="LT"?Be:r==="GT"?Me:R.compare(e._2)(n._2)},Eq0:()=>t}})(),wJ=fe(R)(Wt),NJ=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=Ia.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},JJ=TJ("Greedy"),zg=t=>e=>n=>v(r=>o=>{if(o.from.node===o.to.node)return r;if(o.from.node===e&&!Yl(o.to.node)(r.marks)){const i=dn(o.to.node)(r.inDeg),a=(()=>{if(i.tag==="Nothing")return-1;if(i.tag==="Just")return i._1-1|0;g()})(),s=it(R)(o.to.node)(a)(r.inDeg);return(()=>{const u=dn(o.to.node)(r.outDeg);return a<=0&&(()=>{if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1>0;g()})()&&!gn(vr)(o.to.node)(r.sources)})()?{...r,inDeg:s,sources:[...r.sources,o.to.node]}:{...r,inDeg:s}}if(o.to.node===e&&!Yl(o.from.node)(r.marks)){const i=dn(o.from.node)(r.outDeg),a=(()=>{if(i.tag==="Nothing")return-1;if(i.tag==="Just")return i._1-1|0;g()})(),s=it(R)(o.from.node)(a)(r.outDeg);return(()=>{const u=dn(o.from.node)(r.inDeg);return a<=0&&(()=>{if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1>0;g()})()&&!gn(vr)(o.from.node)(r.sinks)})()?{...r,outDeg:s,sinks:[...r.sinks,o.from.node]}:{...r,outDeg:s}}return r})({...n,remaining:gt(r=>r!==e,n.remaining)})(t),vJ=v(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return it(R)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return it(R)(e._1.node)(0)(t);if(e._1.pin.tag==="LastLayer")return it(R)(e._1.node)(99999)(t)}return t})(M),Kl=t=>e=>n=>{const r=dn(e)(t),o=dn(n)(t);return r.tag==="Just"&&o.tag==="Just"&&r._1>o._1},jl=t=>e=>n=>r=>{if(Xi(n)(r.visited)||Xi(n)(r.visiting))return r;const o=v(CJ(t)(e)(n))({...r,visiting:it(R)(n)()(r.visiting)})((()=>{const i=dn(n)(e);if(i.tag==="Nothing")return[];if(i.tag==="Just")return i._1;g()})());return{...o,visiting:Ai(R)(n)(o.visiting),visited:it(R)(n)()(o.visited)}},CJ=t=>e=>n=>r=>o=>Kl(t)(n)(o)?{...r,backEdges:it(Ia)(S(n,o))()(r.backEdges)}:Xi(o)(r.visiting)?{...r,backEdges:it(Ia)(S(n,o))()(r.backEdges)}:Xi(o)(r.visited)?r:jl(t)(e)(o)(r),bJ=t=>e=>n=>{const r=l=>{let d=l,h=!0,p;for(;h;){const m=d,x=Pt(y=>T,y=>w=>J("Just",{head:y,tail:w}),m.sinks);if(x.tag==="Just"){d=zg(n)(x._1.head)({...m,sinks:x._1.tail,marks:it(R)(x._1.head)(m.nextRight)(m.marks),nextRight:m.nextRight-1|0});continue}if(x.tag==="Nothing"){const y=Pt(w=>T,w=>N=>J("Just",{head:w,tail:N}),m.sources);if(y.tag==="Just"){d=zg(n)(y._1.head)({...m,sources:y._1.tail,marks:it(R)(y._1.head)(m.nextLeft)(m.marks),nextLeft:m.nextLeft+1|0});continue}if(y.tag==="Nothing"){const w=b=>{const C=dn(b)(m.outDeg),L=dn(b)(m.inDeg);return(()=>{if(C.tag==="Nothing")return 0;if(C.tag==="Just")return C._1;g()})()-(()=>{if(L.tag==="Nothing")return 0;if(L.tag==="Just")return L._1;g()})()|0},N=Gt(b=>C=>{const L=ut.compare(w(C))(w(b));return L==="EQ"?ut.compare((()=>{const E=dn(b)(e);if(E.tag==="Nothing")return 1e6;if(E.tag==="Just")return E._1;g()})())((()=>{const E=dn(C)(e);if(E.tag==="Nothing")return 1e6;if(E.tag==="Just")return E._1;g()})()):L})(m.remaining);if(0<N.length){const b=N[0];d=zg(n)(b)({...m,remaining:gt(C=>C!==b,m.remaining),marks:it(R)(b)(m.nextLeft)(m.marks),nextLeft:m.nextLeft+1|0});continue}h=!1,p=m;continue}}g()}return p},o=Ei(R.compare)([...V(l=>l.from.node)(n),...V(l=>l.to.node)(n)]),i=gt(l=>l.from.node!==l.to.node,n),a=v(l=>d=>Mt(R)(ve)(d.to.node)(1)(l))(M)(i),s=v(l=>d=>Mt(R)(ve)(d.from.node)(1)(l))(M)(i),u=gt(l=>{const d=dn(l)(a);if(d.tag==="Nothing")return!0;if(d.tag==="Just")return d._1===0;g()},o),c=gt(l=>{const d=dn(l)(s);if(d.tag==="Nothing")return!0;if(d.tag==="Just")return d._1===0;g()},o),_=o.length+1|0,f=v(l=>d=>{const h=dn(d)(l);return h.tag==="Just"&&h._1<0?it(R)(d)(h._1+_|0)(l):l})(r({remaining:gt(l=>!gn(vr)(l)(u)&&!gn(vr)(l)(c),o),marks:M,inDeg:a,outDeg:s,sources:u,sinks:c,nextLeft:1,nextRight:-1}).marks)(o);return v(l=>d=>{if(d.from.node===d.to.node)return l;if(Kl(t)(d.from.node)(d.to.node))return it(Ia)(S(d.from.node,d.to.node))()(l);const h=dn(d.from.node)(f),p=dn(d.to.node)(f);return h.tag==="Just"&&p.tag==="Just"&&h._1>p._1?it(Ia)(S(d.from.node,d.to.node))()(l):l})(M)(n)},kJ=v(t=>e=>Mt(R)(xe)(e.from.node)([e.to.node])(t))(M),LJ=t=>e=>{const n=kJ(e),r=Ei(R.compare)([...V(i=>i.from.node)(e),...V(i=>i.to.node)(e)]),o=v(i=>a=>it(R)(a.to.node)()(i))(M)(e);return v(i=>a=>jl(t)(n)(a)(i))({visiting:M,visited:M,backEdges:M})([...gt(i=>!Xi(i)(o),r),...gt(i=>Xi(i)(o),r)]).backEdges},SJ=t=>e=>n=>r=>{const o=wJ(Ht(s=>u=>S(u,s))(e)),i=vJ(n),a=(()=>{if(t==="DepthFirst")return LJ(i)(r);if(t==="Greedy")return bJ(i)(o)(r);g()})();return{edges:V(s=>NJ(S(s.from.node,s.to.node))(a)?{...s,from:s.to,to:s.from}:s)(r),reversedEdges:a}},Zl=Wt.foldMap((()=>{const t={append:e=>n=>e||n};return{mempty:!1,Semigroup0:()=>t}})()),Ee=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Pe=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Fa=t=>e=>n=>r=>Zl(o=>n>=o.x&&n<o.x+o.w&&e>o.y&&t<o.y+o.h)(r),eu=t=>e=>n=>r=>Fa(Ee(e)(n))(Pe(e)(n))(r)(t),nu=rt(4),EJ=_s(t=>{if(t.direction==="H"){const e=Ee(t.start._1)(t.end._1);return[{x:e,y:t.start._2-1,w:Pe(t.start._1)(t.end._1)-e,h:2}]}if(t.direction==="V"){const e=Ee(t.start._2)(t.end._2);return[{x:t.start._1-1,y:e,w:2,h:Pe(t.start._2)(t.end._2)-e}]}g()}),Da=ca(t=>{const e=t.start._1-t.end._1;return!((e<0?-e<1e-6:e<1e-6)&&(()=>{const n=t.start._2-t.end._2;return n<0?-n<1e-6:n<1e-6})())}),PJ=t=>e=>n=>{const r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),e);if(r.tag==="Nothing")return[{start:t.start,end:n.end,direction:t.direction}];if(r.tag==="Just"){const o=(r._1.head.direction==="H"?t.direction==="H":r._1.head.direction==="V"&&t.direction==="V")?[{start:t.start,end:r._1.head.end,direction:t.direction}]:[t,r._1.head],i=_r(r._1.tail);if(i.tag==="Nothing"){const a=o.length-1|0;return a>=0&&a<o.length&&(o[a].direction==="H"?n.direction==="H":o[a].direction==="V"&&n.direction==="V")?[...(()=>{const s=o.length-1|0;return s<1?[]:Rt(0,s,o)})(),{start:o[a].start,end:n.end,direction:n.direction}]:[...o,n]}if(i.tag==="Just")return(i._1.last.direction==="H"?n.direction==="H":i._1.last.direction==="V"&&n.direction==="V")?[...o,...i._1.init,{start:i._1.last.start,end:n.end,direction:n.direction}]:[...o,...r._1.tail,n]}g()},za=t=>{const e=r=>o=>{const i=Pt(a=>T,a=>s=>J("Just",{head:a,tail:s}),o);if(i.tag==="Nothing")return[r];if(i.tag==="Just")return(r.direction==="H"?i._1.head.direction==="H":r.direction==="V"&&i._1.head.direction==="V")&&(()=>{if(r.direction==="H")return r.end._1-r.start._1>=0==i._1.head.end._1-i._1.head.start._1>=0;if(r.direction==="V")return r.end._2-r.start._2>=0==i._1.head.end._2-i._1.head.start._2>=0;g()})()?e({start:r.start,end:i._1.head.end,direction:r.direction})(i._1.tail):[r,...e(i._1.head)(i._1.tail)];g()},n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),t);if(n.tag==="Nothing")return[];if(n.tag==="Just")return e(n._1.head)(n._1.tail);g()},Ba=t=>e=>n=>r=>Zl(o=>n>=o.y&&n<o.y+o.h&&e>o.x&&t<o.x+o.w)(r),Ma=t=>e=>n=>r=>Ba(Ee(e)(n))(Pe(e)(n))(r)(t),GJ=t=>e=>n=>r=>{const o=n+2|0,i=o<1?e:Rt(o,e.length,e),a=n<1?[]:Rt(0,n,e),s=(n+1|0)===(r-1|0),u=n===0,c=n>=0&&n<e.length?J("Just",e[n]):T;if(c.tag==="Just"){const _=n+1|0,f=_>=0&&_<e.length?J("Just",e[_]):T;if(f.tag==="Just"){const l=c._1.start._1===f._1.end._1&&(!u||c._1.direction==="V")&&(!s||f._1.direction==="V")&&!eu(t)(Ee(c._1.start._2)(f._1.end._2))(Pe(c._1.start._2)(f._1.end._2))(c._1.start._1)?J("Just",[...a,{start:c._1.start,end:f._1.end,direction:we},...i]):T,d=c._1.start._2===f._1.end._2&&(!u||c._1.direction==="H")&&(!s||f._1.direction==="H")&&!Ma(t)(Ee(c._1.start._1)(f._1.end._1))(Pe(c._1.start._1)(f._1.end._1))(c._1.start._2)?J("Just",[...a,{start:c._1.start,end:f._1.end,direction:Te},...i]):T;return l.tag==="Nothing"?d:l}if(f.tag==="Nothing")return T;g()}if(c.tag==="Nothing")return T;g()},RJ=t=>e=>{const n=e.length;return(r=>{let o=r,i=!0,a;for(;i;){const s=o;if((s+1|0)>=n){i=!1,a=e;continue}const u=GJ(t)(e)(s)(n);if(u.tag==="Just"){i=!1,a=u._1;continue}if(u.tag==="Nothing"){o=s+1|0;continue}g()}return a})(0)},AJ=t=>e=>n=>r=>{const o=(l,d,h)=>!eu(t)(Ee(d)(h))(Pe(d)(h))(l),i=n+3|0,a=i<1?e:Rt(i,e.length,e),s=n<1?[]:Rt(0,n,e),u=(n+2|0)===(r-1|0),c=n===0,_=(l,d,h)=>!Ma(t)(Ee(d)(h))(Pe(d)(h))(l),f=n>=0&&n<e.length?J("Just",e[n]):T;if(f.tag==="Just"){const l=n+2|0,d=l>=0&&l<e.length?J("Just",e[l]):T;if(d.tag==="Just"){const h=f._1.start._1===d._1.end._1&&(!c||f._1.direction==="V")&&(!u||d._1.direction==="V")&&o(f._1.start._1,f._1.start._2,d._1.end._2)?J("Just",[...s,{start:f._1.start,end:d._1.end,direction:we},...a]):f._1.start._2===d._1.end._2&&(!c||f._1.direction==="H")&&(!u||d._1.direction==="H")&&_(f._1.start._2,f._1.start._1,d._1.end._1)?J("Just",[...s,{start:f._1.start,end:d._1.end,direction:Te},...a]):T,p=(!c||f._1.direction==="V")&&(!u||d._1.direction==="H")&&o(f._1.start._1,f._1.start._2,d._1.end._2)&&_(d._1.end._2,f._1.start._1,d._1.end._1)?J("Just",[...s,{start:f._1.start,end:S(f._1.start._1,d._1.end._2),direction:we},{start:S(f._1.start._1,d._1.end._2),end:d._1.end,direction:Te},...a]):T,m=(!c||f._1.direction==="H")&&(!u||d._1.direction==="V")&&_(f._1.start._2,f._1.start._1,d._1.end._1)&&o(d._1.end._1,f._1.start._2,d._1.end._2)?J("Just",[...s,{start:f._1.start,end:S(d._1.end._1,f._1.start._2),direction:Te},{start:S(d._1.end._1,f._1.start._2),end:d._1.end,direction:we},...a]):T,x=p.tag==="Nothing"?m:p;return h.tag==="Nothing"?x:h}if(d.tag==="Nothing")return T;g()}if(f.tag==="Nothing")return T;g()},IJ=t=>e=>{const n=e.length;return(r=>{let o=r,i=!0,a;for(;i;){const s=o;if((s+2|0)>=n){i=!1,a=e;continue}const u=AJ(t)(e)(s)(n);if(u.tag==="Just"){i=!1,a=u._1;continue}if(u.tag==="Nothing"){o=s+1|0;continue}g()}return a})(0)},FJ=t=>{const e=n=>{let r=n,o=!0,i;for(;o;){const a=r,s=za(Da(RJ(t)(IJ(t)(a))));if(s.length<a.length){r=s;continue}o=!1,i=s}return i};return n=>e(za(Da(n)))},DJ=t=>e=>n=>r=>{const o=Ee(n)(r),i=Pe(n)(r),a=gt(u=>e>=u.y&&e<u.y+u.h&&u.x+u.w>o&&u.x<i,t);if(r>n){const u=Gt(c=>_=>at.compare(c.x)(_.x))(a);return 0<u.length?u[0].x-1:(n+r)/2}const s=Gt(u=>c=>at.compare(c.x)(u.x))(V(u=>({...u,x:u.x+u.w}))(a));return 0<s.length?s[0].x+1:(n+r)/2},zJ=t=>e=>n=>r=>{const o=Ee(n)(r),i=Pe(n)(r),a=gt(u=>e>=u.x&&e<u.x+u.w&&u.y+u.h>o&&u.y<i,t);if(r>n){const u=Gt(c=>_=>at.compare(c.y)(_.y))(a);return 0<u.length?u[0].y-1:(n+r)/2}const s=Gt(u=>c=>at.compare(c.y)(u.y))(V(u=>({...u,y:u.y+u.h}))(a));return 0<s.length?s[0].y+1:(n+r)/2},BJ=t=>e=>n=>r=>{const o=Ee(n)(r),i=Pe(n)(r),a=gt(u=>e>=u.y&&e<u.y+u.h&&u.x+u.w>o&&u.x<i,t);if(r>n){const u=Gt(c=>_=>at.compare(_.x)(c.x))(V(c=>({...c,x:c.x+c.w}))(a));return 0<u.length?u[0].x:(n+r)/2}const s=Gt(u=>c=>at.compare(u.x)(c.x))(a);return 0<s.length?s[0].x-1:(n+r)/2},MJ=t=>e=>n=>r=>{const o=Ee(n)(r),i=Pe(n)(r),a=gt(u=>e>=u.x&&e<u.x+u.w&&u.y+u.h>o&&u.y<i,t);if(r>n){const u=Gt(c=>_=>at.compare(_.y)(c.y))(V(c=>({...c,y:c.y+c.h}))(a));return 0<u.length?u[0].y:(n+r)/2}const s=Gt(u=>c=>at.compare(u.y)(c.y))(a);return 0<s.length?s[0].y-1:(n+r)/2},td=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i;if(_>100){a=!1,s=c;continue}if(!u(c+_)){a=!1,s=c+_;continue}if(!u(c-_)){a=!1,s=c-_;continue}r=u,o=c,i=_+1}return s},ed=t=>e=>n=>r=>o=>{const i=Ee(e)(n),a=Pe(e)(n);if(!Fa(i)(a)(r)(t))return r;if(!Fa(i)(a)(o)(t))return o;const s=(r+o)/2;return Fa(i)(a)(s)(t)?td(u=>Fa(i)(a)(u)(t))(s)(1):s},QJ=t=>e=>n=>r=>o=>{const i=Ee(e)(n),a=Pe(e)(n);if(!Ba(i)(a)(r)(t))return r;if(!Ba(i)(a)(o)(t))return o;const s=(r+o)/2;return Ba(i)(a)(s)(t)?td(u=>Ba(i)(a)(u)(t))(s)(1):s},WJ=t=>e=>n=>r=>{const o=Ee(e)(n),i=Pe(e)(n),a=gt(c=>r>=c.x&&r<c.x+c.w&&c.y+c.h>o&&c.y<i,t),s=v(c=>_=>Pe(c)(_.x+_.w+4))(r+4)(a),u=v(c=>_=>Ee(c)(_.x-4))(r-4)(a);return(()=>{const c=s-r,_=u-r;return(c<0?-c:c)<=(_<0?-_:_)})()?s:u},HJ=t=>e=>n=>r=>{const o=Ee(e)(n),i=Pe(e)(n),a=gt(c=>r>=c.y&&r<c.y+c.h&&c.x+c.w>o&&c.x<i,t),s=v(c=>_=>Pe(c)(_.y+_.h+4))(r+4)(a),u=v(c=>_=>Ee(c)(_.y-4))(r-4)(a);return(()=>{const c=s-r,_=u-r;return(c<0?-c:c)<=(_<0?-_:_)})()?s:u},OJ=t=>e=>n=>r=>o=>i=>a=>{const s=(()=>{if(r==="South")return S(o._1,o._2+4);if(r==="North")return S(o._1,o._2-4);if(r==="East")return S(o._1+4,o._2);if(r==="West")return S(o._1-4,o._2);g()})(),u=(()=>{if(i==="South")return S(a._1,a._2+4);if(i==="North")return S(a._1,a._2-4);if(i==="East")return S(a._1+4,a._2);if(i==="West")return S(a._1-4,a._2);g()})(),c=(b,C,L)=>!eu(e)(Ee(C)(L))(Pe(C)(L))(b),_=(b,C,L)=>!eu(n)(Ee(C)(L))(Pe(C)(L))(b),f=(b,C,L,E)=>t.tag==="Just"&&!Ma(n)(Ee(b)(C))(Pe(b)(C))(t._1)?t._1:QJ(e)(b)(C)(L)(E),l=(b,C,L,E)=>{if(b===L){const W=WJ(e)(C)(E)(b),P=zJ(e)(b)(C)(E),G=MJ(e)(b)(C)(E);return[{start:S(b,C),end:S(b,P),direction:we},{start:S(b,P),end:S(W,P),direction:Te},{start:S(W,P),end:S(W,G),direction:we},{start:S(W,G),end:S(L,G),direction:Te},{start:S(L,G),end:S(L,E),direction:we}]}const I=f(b,L,C,E);return[{start:S(b,C),end:S(b,I),direction:we},{start:S(b,I),end:S(L,I),direction:Te},{start:S(L,I),end:S(L,E),direction:we}]},d=(b,C,L,E)=>{if(C===E){const W=HJ(e)(b)(L)(C),P=DJ(e)(C)(b)(L),G=BJ(e)(C)(b)(L);return[{start:S(b,C),end:S(P,C),direction:Te},{start:S(P,C),end:S(P,W),direction:we},{start:S(P,W),end:S(G,W),direction:Te},{start:S(G,W),end:S(G,E),direction:we},{start:S(G,E),end:S(L,E),direction:Te}]}const I=ed(e)(C)(E)(b)(L);return[{start:S(b,C),end:S(I,C),direction:Te},{start:S(I,C),end:S(I,E),direction:we},{start:S(I,E),end:S(L,E),direction:Te}]},h=(b,C,L)=>!Ma(e)(Ee(C)(L))(Pe(C)(L))(b),p=(b,C,L)=>!Ma(n)(Ee(C)(L))(Pe(C)(L))(b),m=(b,C,L,E)=>{if(p(C,b,L)&&_(L,C,E))return[{start:S(b,C),end:S(L,C),direction:Te},{start:S(L,C),end:S(L,E),direction:we}];const I=ed(e)(C)(E)(b)(L);return[{start:S(b,C),end:S(I,C),direction:Te},{start:S(I,C),end:S(I,E),direction:we},{start:S(I,E),end:S(L,E),direction:Te}]},x=(b,C,L,E)=>{if(_(b,C,E)&&p(E,b,L))return[{start:S(b,C),end:S(b,E),direction:we},{start:S(b,E),end:S(L,E),direction:Te}];const I=f(b,L,C,E);return[{start:S(b,C),end:S(b,I),direction:we},{start:S(b,I),end:S(L,I),direction:Te},{start:S(L,I),end:S(L,E),direction:we}]},y=(()=>{if(r==="South")return i==="North"?s._1===u._1&&c(s._1,s._2,u._2)?[{start:S(s._1,s._2),end:S(u._1,u._2),direction:we}]:l(s._1,s._2,u._1,u._2):i==="East"||i==="West"?x(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="North")return i==="South"?s._1===u._1&&c(s._1,s._2,u._2)?[{start:S(s._1,s._2),end:S(u._1,u._2),direction:we}]:l(s._1,s._2,u._1,u._2):i==="East"||i==="West"?x(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="East")return i==="West"?s._2===u._2&&h(s._2,s._1,u._1)?[{start:S(s._1,s._2),end:S(u._1,u._2),direction:Te}]:d(s._1,s._2,u._1,u._2):i==="North"||i==="South"?m(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="West"){if(i==="East")return s._2===u._2&&h(s._2,s._1,u._1)?[{start:S(s._1,s._2),end:S(u._1,u._2),direction:Te}]:d(s._1,s._2,u._1,u._2);if(i==="North"||i==="South")return m(s._1,s._2,u._1,u._2)}return l(s._1,s._2,u._1,u._2)})(),w=(()=>{if(r==="South"||r==="North")return we;if(r==="East"||r==="West")return Te;g()})(),N={start:S(u._1,u._2),end:S(a._1,a._2),direction:(()=>{if(i==="South"||i==="North")return we;if(i==="East"||i==="West")return Te;g()})()};return s._1===u._1&&s._2===u._2?[{start:S(o._1,o._2),end:S(a._1,a._2),direction:w}]:PJ({start:S(o._1,o._2),end:S(s._1,s._2),direction:w})(y)(N)},qJ=V(t=>({x:t.position._1*nu-2,y:t.position._2*nu-2,w:t.size._1*nu+4,h:t.size._2*nu+4})),nd=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Yi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},VJ=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),Bg=t=>e=>t.gapTop+1*rt(4)+rt(e)*2.5*rt(4),$J=t=>e=>{const n=nd(e.edge.id)(t);if(n.tag==="Just"){if(n._1.partner.tag==="Just")return J("Just",{slot1Y:Bg(n._1)(n._1.slot),splitX:n._1.partner._1.splitX,slot2Y:Bg(n._1)(n._1.partner._1.slot)});if(n._1.partner.tag==="Nothing")return T;g()}if(n.tag==="Nothing")return T;g()},UJ=t=>e=>{const n=v(r=>o=>it(R)(o.node)(o)(r))(M)(e);return Tn(Ht(r=>o=>{const i=Yi(o.node)(n);if(i.tag==="Nothing")return[];if(i.tag==="Just"){const a=i._1;return Ht(s=>u=>{const c=o.edges.length,_=rt(4),f=a.position._1*_,l=a.position._2*_,d=a.size._2*_,h=rt((2*c|0)+1|0),p=l+d*rt(c-s|0)/h,m=l+d*rt((c+1|0)+s|0)/h,x=f-_*2.5*rt(s+1|0),y=[{start:S(f,p),end:S(x,p),direction:Te},{start:S(x,p),end:S(x,m),direction:we},{start:S(x,m),end:S(f,m),direction:Te}];return{edge:u.id,segments:y,bends:Oe(w=>N=>w.end,y,Rt(1,3,y)),bendType:[],jumps:[],reversed:!1}})(o.edges)}g()})(V(r=>({node:r._1,edges:r._2}))(VJ(v(r=>o=>Mt(R)(xe)(o.from.node)([o])(r))(M)(t)))))},XJ=t=>e=>{const n=v(i=>a=>it(R)(a.node)(a)(i))(M)(e),r=i=>{const a=Yi(i)(n);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1.position._1;g()},o=i=>{const a=Yi(i)(n);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1.layer;g()};return Gt(i=>a=>{const s=ut.compare(o(i.edge.from.node))(o(a.edge.from.node));if(s==="EQ"){const u=at.compare(r(i.edge.from.node))(r(a.edge.from.node));return u==="EQ"?at.compare(r(i.edge.to.node))(r(a.edge.to.node)):u}return s})(t)},hn=t=>{const e=rt(4);return{x:t.position._1*e-2,y:t.position._2*e-2,w:t.size._1*e+4,h:t.size._2*e+4}},YJ=t=>t.from.node===t.to.node,KJ=t=>e=>n=>r=>{const o=FJ(n)(OJ(t)(e)(n)(r.fromSide)(r.fromPos)(r.toSide)(r.toPos));return{edge:r.edge.id,segments:o,bends:Oe(i=>a=>i.end,o,Rt(1,o.length,o)),bendType:[],jumps:[],reversed:!1}},jJ=t=>e=>n=>r=>{const o=[{start:S(r.fromPos._1,r.fromPos._2),end:S(r.fromPos._1,t.slot1Y),direction:we},{start:S(r.fromPos._1,t.slot1Y),end:S(t.splitX,t.slot1Y),direction:Te},{start:S(t.splitX,t.slot1Y),end:S(t.splitX,t.slot2Y),direction:we},{start:S(t.splitX,t.slot2Y),end:S(r.toPos._1,t.slot2Y),direction:Te},{start:S(r.toPos._1,t.slot2Y),end:S(r.toPos._1,r.toPos._2),direction:we}];return{edge:r.edge.id,segments:o,bends:Oe(i=>a=>i.end,o,Rt(1,5,o)),bendType:[],jumps:[],reversed:!1}},ZJ=t=>e=>n=>{const r=Yi(t.edge.from.node)(n);if(r.tag==="Just"){const i=Yi(t.edge.to.node)(n);return i.tag==="Just"?gt(a=>!(a.h===hn(r._1).h&&a.w===hn(r._1).w&&a.x===hn(r._1).x&&a.y===hn(r._1).y)&&!(a.h===hn(i._1).h&&a.w===hn(i._1).w&&a.x===hn(i._1).x&&a.y===hn(i._1).y),e):gt(a=>!(a.h===hn(r._1).h&&a.w===hn(r._1).w&&a.x===hn(r._1).x&&a.y===hn(r._1).y),e)}const o=Yi(t.edge.to.node)(n);return o.tag==="Just"?gt(i=>!(i.h===hn(o._1).h&&i.w===hn(o._1).w&&i.x===hn(o._1).x&&i.y===hn(o._1).y),e):gt(i=>!0,e)},tv=t=>e=>{const n=nd(e.edge.id)(t);if(n.tag==="Just")return J("Just",Bg(n._1)(n._1.slot));if(n.tag==="Nothing")return T;g()},ev=t=>e=>n=>r=>o=>{const i=v(c=>_=>it(R)(_.node)(_)(c))(M)(e),a=qJ(e),s=Al(gt(c=>c.from.node!==c.to.node,t))(e)(n)(r)(o),u=Sl(s)(e);return[...UJ(gt(YJ,t))(e),...v(c=>_=>{const f=ZJ(_)(a)(i),l=[...f,...c.edgeObstacles],d=$J(u)(_),h=(()=>{if(d.tag==="Just")return jJ(d._1)(f)(l)(_);if(d.tag==="Nothing")return KJ(tv(u)(_))(f)(l)(_);g()})();return{results:[...c.results,h],edgeObstacles:[...c.edgeObstacles,...EJ(h.segments)]}})({results:[],edgeObstacles:[]})(XJ(s)(e)).results]},_o=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},fo=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},nv=t=>e=>n=>{if(t.start._1!==e.start._1)return T;const r=fo(_o(t.start._2)(t.end._2))(_o(e.start._2)(e.end._2)),o=_o(fo(t.start._2)(t.end._2))(fo(e.start._2)(e.end._2));return r<o?J("Just",{position:S(t.start._1,(r+o)/2),crossingEdge:n}):T},rv=t=>e=>n=>{if(t.start._2!==e.start._2)return T;const r=fo(_o(t.start._1)(t.end._1))(_o(e.start._1)(e.end._1)),o=_o(fo(t.start._1)(t.end._1))(fo(e.start._1)(e.end._1));return r<o?J("Just",{position:S((r+o)/2,t.start._2),crossingEdge:n}):T},ov=t=>e=>n=>{if(t.direction==="H")return rv(t)(e)(n);if(t.direction==="V")return nv(t)(e)(n);g()},iv=t=>e=>n=>{const r=t+1|0,o=r<1?n:Rt(r,n.length,n);return Et(e.segments)(i=>Et(o)(a=>Tt(s=>ov(i)(s)(a.edge))(gt(s=>s.direction==="H"?i.direction==="H":s.direction==="V"&&i.direction==="V",a.segments))))},av=t=>e=>n=>e.start._1>_o(t.start._1)(t.end._1)&&e.start._1<fo(t.start._1)(t.end._1)&&t.start._2>_o(e.start._2)(e.end._2)&&t.start._2<fo(e.start._2)(e.end._2)?J("Just",{position:S(e.start._1,t.start._2),crossingEdge:n}):T,sv=t=>e=>Et(gt(n=>n.direction==="H",t.segments))(n=>Et(e)(r=>Tt(o=>av(n)(o)(r.edge))(gt(o=>o.direction==="V",r.segments)))),uv=t=>e=>n=>[...sv(e)(gt(r=>r.edge!==e.edge,n)),...iv(t)(e)(n)],rd=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},cv=v(t=>e=>it(R)(e)()(t))(M),ru=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},gv=xl(R),Ar=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},od=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Mg=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},_v=fe(ut)(Wt),fv=t=>e=>je(R.compare,Xe,t,e),id=Ht(t=>e=>({src:e.src,tgt:e.tgt,delta:1,weight:1,eid:t})),lv=t=>v(e=>n=>({base:(()=>{const r=o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s;if(f.tag==="Nil"){u=!1,c=_;continue}if(f.tag==="Cons"){a=rd(_)(f._1),s=f._2;continue}g()}return c};return(e.base+r(0)((()=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,yt("Cons",i._4,o(i._6,a)));g()};return o(n,D)})())|0)+1|0})(),result:[...e.result,(()=>{if(e.base===0)return n;const r=o=>{if(o.tag==="Leaf")return M;if(o.tag==="Node")return Zt("Node",o._1,o._2,o._3,o._4+e.base|0,r(o._5),r(o._6));g()};return r(n)})()]}))({base:0,result:[]})(t).result,dv=t=>e=>{const n=cv(t);return gv(t)(id(gt(r=>ru(r.src)(n)&&ru(r.tgt)(n),e)))},hv=t=>e=>{const n=v(o=>i=>Mt(R)(xe)(i.tgt)([i.src])(Mt(R)(xe)(i.src)([i.tgt])(o)))(M)(e),r=o=>i=>a=>{let s=o,u=i,c=a,_=!0,f;for(;_;){const l=s,d=u,h=c,p=Pt(m=>T,m=>x=>J("Just",{head:m,tail:x}),l);if(p.tag==="Nothing"){_=!1,f={nodes:h};continue}if(p.tag==="Just"){if(ru(p._1.head)(d)){s=p._1.tail,u=d,c=h;continue}s=[...p._1.tail,...(()=>{const m=Ar(p._1.head)(n);if(m.tag==="Nothing")return[];if(m.tag==="Just")return m._1;g()})()],u=it(R)(p._1.head)()(d),c=[...h,p._1.head];continue}g()}return f};return v(o=>i=>{if(ru(i)(o.visited))return o;const a=r([i])(o.visited)([]);return{...o,visited:v(s=>u=>it(R)(u)()(s))(o.visited)(a.nodes),components:[...o.components,a.nodes]}})({visited:M,components:[]})(t).components},pv=t=>e=>n=>{const r=v(i=>a=>Mt(R)(ve)(a.tgt)(1)(i))(M)(e),o=v(i=>a=>Mt(R)(ve)(a.src)(1)(i))(M)(e);return v(i=>a=>{const s=Ar(a)(r),u=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();if((()=>{const y=Ar(a)(o);return(()=>{if(y.tag==="Nothing")return u!==0;if(y.tag==="Just")return u!==y._1;g()})()||u===0})())return i;const c=Ar(a)(i.layers),_=(()=>{if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1;g()})(),f=i.layers,l=v(y=>w=>w.tgt===a?{...y,mIn:od(y.mIn)((()=>{const N=Ar(a)(f),b=Ar(w.src)(f);return(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})()-(()=>{if(b.tag==="Nothing")return 0;if(b.tag==="Just")return b._1;g()})()|0})())}:w.src===a?{...y,mOut:od(y.mOut)((()=>{const N=Ar(w.tgt)(f),b=Ar(a)(f);return(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})()-(()=>{if(b.tag==="Nothing")return 0;if(b.tag==="Just")return b._1;g()})()|0})())}:y)({mIn:1e9,mOut:1e9})(e),d=l.mIn===1e9?-1:l.mIn,h=l.mOut===1e9?-1:l.mOut;if(d<0||h<0)return i;const p=(_-d|0)+1|0,m=(_+h|0)-1|0;if(m<p)return i;const x=v(y=>w=>{const N=Mg(w)(i.filling),b=(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})();return b<y.bestFill?{best:w,bestFill:b}:y})({best:_,bestFill:(()=>{const y=Mg(_)(i.filling);if(y.tag==="Nothing")return 0;if(y.tag==="Just")return y._1;g()})()})($t(p,m));return x.best===_?i:{layers:it(R)(a)(x.best)(i.layers),filling:it(ut)(_)((()=>{const y=Mg(_)(i.filling);if(y.tag==="Nothing")return-1;if(y.tag==="Just")return y._1-1|0;g()})())(it(ut)(x.best)(x.bestFill+1|0)(i.filling))}})({layers:n,filling:_v(V(i=>S(i,v(a=>s=>(()=>{const u=Ar(s)(n);return u.tag==="Nothing"?!1:u.tag==="Just"&&u._1===i})()?a+1|0:a)(0)(t)))($t(0,v(i=>a=>rd(i)((()=>{const s=Ar(a)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(0)(t))))})(t).layers},mv=t=>e=>pv(t)(id(e))(v(fv)(M)(lv(V(n=>dv(n)(e))(hv(t)(e))))),yv=t=>t,Vo=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},ou=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ad=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),xv=yv("NetworkSimplex"),Tv=t=>e=>v(n=>r=>{const o=v(ou)(0)(Tt(i=>Vo(i)(n))(r));return v(i=>a=>it(R)(a)(o)(i))(n)(r)})(e)(t),wv=t=>e=>({layers:V(n=>gt(r=>{const o=Vo(r)(e);return o.tag==="Nothing"?!1:o.tag==="Just"&&o._1===n},t))($t(0,(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(c.tag==="Nil"){a=!1,s=u;continue}if(c.tag==="Cons"){o=ou(u)(c._1),i=c._2;continue}g()}return s})(0)((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._4,n(r._6,o)));g()};return n(e,D)})()))),nodeLayer:e}),Nv=t=>e=>n=>{const r=v(o=>i=>it(R)(i)(!0)(o))(M)(e);return v(o=>i=>it(R)(i._1)(i._2)(o))(mv(e)(Tt(o=>o.from.node===o.to.node||(()=>{const i=Vo(o.from.node)(r);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return!i._1;g()})()||(()=>{const i=Vo(o.to.node)(r);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return!i._1;g()})()?T:J("Just",{src:o.from.node,tgt:o.to.node}))(t)))(ad(n))},Jv=t=>e=>n=>r=>{const o=s=>u=>{const c=Vo(u)(s);if(c.tag==="Just")return s;if(c.tag==="Nothing"){const _=gt(l=>l!==u,(()=>{const l=Vo(u)(t);if(l.tag==="Nothing")return[];if(l.tag==="Just")return l._1;g()})()),f=v(o)(s)(_);return it(R)(u)(1+v(ou)(0)(Tt(l=>Vo(l)(f))(_))|0)(f)}g()},i=v(o)(M)(n),a=(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Nil"){f=!1,l=d;continue}if(h.tag==="Cons"){c=ou(d)(h._1),_=h._2;continue}g()}return l})(1)((()=>{const s=(u,c)=>{if(u.tag==="Leaf")return c;if(u.tag==="Node")return s(u._5,yt("Cons",u._4,s(u._6,c)));g()};return s(i,D)})());return v(s=>u=>it(R)(u._1)(u._2)(s))((()=>{const s=u=>{if(u.tag==="Leaf")return M;if(u.tag==="Node")return Zt("Node",u._1,u._2,u._3,a-u._4|0,s(u._5),s(u._6));g()};return s(i)})())(ad(r))},vv=v(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return it(R)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return it(R)(e._1.node)(0)(t)}return t})(M),Cv=v(t=>e=>Mt(R)(xe)(e.to.node)([e.from.node])(t))(M),bv=v(t=>e=>Mt(R)(xe)(e.from.node)([e.to.node])(t))(M),kv=t=>e=>n=>r=>{const o=bv(n),i=Cv(n),a=vv(e);return wv(r)(Tv(Tt(s=>s.tag==="SameLayer"?J("Just",s._1.nodes):T)(e))((()=>{if(t==="LongestPath")return Jv(o)(i)(r)(a);if(t==="NetworkSimplex")return Nv(n)(r)(a);g()})()))},Lv=fe(R)(Wt),Sv=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},sd=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},ud=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Qa=fe(R)(Wt),Ev=fe(R)(Wt),cd=(()=>{const t=V(e=>({start:e.end,end:e.start,direction:e.direction}));return e=>ee(t(e))})(),Pv=t=>e=>n=>r=>{const o=Lv(V(a=>S(a.edge,a))(r)),i=a=>0<a.nodes.length&&(()=>{const s=Sv(a.edgeId)(n);return s.tag==="Just"&&a.nodes[0]!==s._1._1})();return V(a=>{if(a.nodes.length<=2){const _=sd(a.edgeId)(o);if(_.tag==="Just"){const f=i(a),l=za(Da(f?cd(_._1.segments):_._1.segments));return{..._._1,edge:a.edgeId,segments:l,bends:Oe(d=>h=>d.end,l,Rt(1,l.length,l)),reversed:f}}if(_.tag==="Nothing")return{edge:a.edgeId,segments:[],bends:[],bendType:[],jumps:[],reversed:!1};g()}const s=Et(Tt(_=>sd(_)(o))(Oe(_=>f=>a.edgeId+":"+_+"->"+f,a.nodes,Rt(1,a.nodes.length,a.nodes))))(_=>_.segments),u=i(a),c=za(Da(u?cd(s):s));return{edge:a.edgeId,segments:c,bends:Oe(_=>f=>_.end,c,Rt(1,c.length,c)),bendType:[],jumps:[],reversed:u}})(t)},Gv={layers:[],edges:[],chains:[]},gd={nodeGap:3,layerGap:2,iterations:8,layerer:xv,cycleBreaker:JJ,compactPostRouting:!0,compactionSpacings:CN},Rv=t=>({pos:S(0,0),size:S(v(e=>n=>ud(e)(n.position._1+n.size._1))(0)(t),v(e=>n=>ud(e)(n.position._2+n.size._2))(0)(t))}),Av=t=>e=>n=>{const r=Qa(V(c=>S(c.id,c.ports))(e.nodes)),o=gt(c=>Ie(3)(c.node)!=="$d:",n.placements),i=Pv(n.withDummies.chains)(n.acyclic.reversedEdges)(Ev(V(c=>S(c.id,S(c.from.node,c.to.node)))(e.edges)))(ev(n.withDummies.edges)(n.placements)(r)(n.withDummies.chains)(Fl(n.ordered)(gt(c=>c.from.node!==c.to.node,n.withDummies.edges))((()=>{const c=_=>{if(_.tag==="Leaf")return M;if(_.tag==="Node")return Zt("Node",_._1,_._2,_._3,S(_._4._1*4,_._4._2),c(_._5),c(_._6));g()};return c(Qa(V(_=>S(_.id,_.size))(e.nodes)))})()))),a=t.compactPostRouting?LN()(t.compactionSpacings)({nodes:o,edges:e.edges,paths:i,ports:r}):{nodes:o,edges:i},s=V(c=>{const _=za(Da(c.segments));return{...c,segments:_,bends:Oe(f=>l=>f.end,_,Rt(1,_.length,_))}})(a.edges),u=Ht(c=>_=>({..._,jumps:uv(c)(_)(s)}))(s);return{nodes:a.nodes,edges:u,boundingBox:Rv(a.nodes),metrics:tw(a.nodes)(u)(0)}},_d=t=>e=>n=>{const r=Qa(V(i=>S(i.id,i.size))(e.nodes)),o={...n,placements:aJ({nodeGap:t.nodeGap,layerGap:t.layerGap})(e.constraints)(n.ordered)(r)(Qa(V(i=>S(i.id,i.ports))(e.nodes)))(n.withDummies.edges)(n.withDummies.chains)(Fl(n.ordered)(n.withDummies.edges)((()=>{const i=a=>{if(a.tag==="Leaf")return M;if(a.tag==="Node")return Zt("Node",a._1,a._2,a._3,S(a._4._1*4,a._4._2),i(a._5),i(a._6));g()};return i(r)})()))};return{pipeline:o,result:Av(t)(e)(o)}},Iv=t=>e=>n=>_d(t)(e)({...n,ordered:xJ({iterations:t.iterations,constraints:e.constraints,modelOrder:Qa(Ht(r=>o=>S(o.id,r))(e.nodes))})(n.withDummies.layers)(n.withDummies.edges)}),Fv=t=>e=>n=>Iv(t)(e)({...n,withDummies:SN(n.layered.nodeLayer)(n.acyclic.edges)(n.layered.layers)}),fd=t=>e=>{const n=V(o=>o.id)(e.nodes),r=SJ(t.cycleBreaker)(n)(e.constraints)(e.edges);return Fv(t)(e)({acyclic:r,layered:kv(t.layerer)(e.constraints)(r.edges)(n),withDummies:Gv,ordered:[],placements:[]})},ld=fe(R)(Wt),Ki=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},iu=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},lo=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Dv=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},zv=t=>e=>n=>{const r=n.result.nodes,o=ld(V(a=>S(a.node,a))(r)),i=n.result.boundingBox.size._1;return ld(Tt(a=>{const s=lo(a.id)(o);if(s.tag==="Just"){const u=lo(a.id)(n.pipeline.layered.nodeLayer);if(u.tag==="Just"){const c=u._1,_=Pt(f=>T,f=>l=>J("Just",{head:f,tail:l}),gt(f=>f.length>=2,[Tt(f=>{if(f.to.node===a.id){const l=lo(f.from.node)(n.pipeline.layered.nodeLayer);if(l.tag==="Just")return l._1>=c?T:lo(f.from.node)(o);if(l.tag==="Nothing")return T;g()}return T})(e.edges),Tt(f=>{if(f.from.node===a.id){const l=lo(f.to.node)(n.pipeline.layered.nodeLayer);if(l.tag==="Just")return l._1<=c?T:lo(f.to.node)(o);if(l.tag==="Nothing")return T;g()}return T})(e.edges)]));if(_.tag==="Just"){const f=iu(v(Ki)((()=>{const p=Pt(m=>T,m=>x=>J("Just",{head:m,tail:x}),V(m=>m.position._1+m.size._1*.5)(_._1.head));if(p.tag==="Nothing")return a.size._1;if(p.tag==="Just")return Ki(a.size._1)(v(Ki)(p._1.head)(p._1.tail)-v(iu)(p._1.head)(p._1.tail)+2);g()})())(V(p=>{const m=Pt(x=>T,x=>y=>J("Just",{head:x,tail:y}),V(x=>x.position._1+x.size._1*.5)(p));if(m.tag==="Nothing")return a.size._1;if(m.tag==="Just")return Ki(a.size._1)(v(Ki)(m._1.head)(m._1.tail)-v(iu)(m._1.head)(m._1.tail)+2);g()})(_._1.tail)))(a.size._1+rt(v(Dv)(_._1.head.length)(V(G2)(_._1.tail))-1|0)),l=s._1.position._1,d=l+s._1.size._1,h=gt(p=>{const m=lo(p.node)(n.pipeline.layered.nodeLayer);return p.node!==a.id&&(m.tag==="Nothing"?!1:m.tag==="Just"&&m._1===c)},r);return f>a.size._1+.5&&f<=v(p=>m=>m.position._1>=d?iu(p)(m.position._1-rt(t.nodeGap)):p)(i)(h)-v(p=>m=>m.position._1+m.size._1<=l?Ki(p)(m.position._1+m.size._1+rt(t.nodeGap)):p)(0)(h)?J("Just",S(a.id,S(f,a.size._2))):T}if(_.tag==="Nothing")return T;g()}if(u.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()})(e.nodes))},Bv=t=>e=>{const n=fd(t)(e),r=zv(t)(e)(n),o=_d(t)({...e,nodes:V(i=>{const a=lo(i.id)(r);if(a.tag==="Just")return{...i,size:a._1};if(a.tag==="Nothing")return i;g()})(e.nodes)})(n.pipeline);return r.tag==="Leaf"?n:o},au=t=>t,Mv=t=>t,Yr=au("RunText"),Qg=au("RunCode"),Wg=au("RunHighlight"),Hg=au("RunCodeHighlight"),Qv=t=>{const e=r=>{const o=Pt(i=>T,i=>a=>J("Just",{head:i,tail:a}),r);if(o.tag==="Nothing")return[];if(o.tag==="Just"){if(o._1.head==="\\"){const i=Pt(a=>T,a=>s=>J("Just",{head:a,tail:s}),o._1.tail);if(i.tag==="Nothing")return[o._1.head];if(i.tag==="Just")return[o._1.head,i._1.head,...e(i._1.tail)];g()}return o._1.head==="="&&0<o._1.tail.length&&o._1.tail[0]==="="?e(Rt(1,o._1.tail.length,o._1.tail)):[o._1.head,...e(o._1.tail)]}g()},n=rr("md:")(t);if(n.tag==="Nothing")return t;if(n.tag==="Just")return Jn(e(Hn(n._1)));g()},Wv=t=>"md:"+t,An=t=>{const e=(()=>{const r=rr("md:")(t);if(r.tag==="Just")return!0;if(r.tag==="Nothing")return!1;g()})()?Wv:Mv,n=zi(`
3
- `)((()=>{const r=rr("md:")(t);if(r.tag==="Just")return r._1;if(r.tag==="Nothing")return t;g()})());return n.length===0?[e("")]:V(e)(n)},Og=t=>e=>n=>e.length===0?n:wt(n)({style:t,text:Jn(e)}),Hv=t=>({code:!t.code,highlight:t.highlight,buf:[],runs:Og((()=>{if(!t.highlight){if(!t.code)return Yr;if(t.code)return Qg;g()}if(t.highlight){if(!t.code)return Wg;if(t.code)return Hg}g()})())(t.buf)(t.runs)}),Ov=t=>({code:t.code,highlight:!t.highlight,buf:[],runs:Og((()=>{if(!t.highlight){if(!t.code)return Yr;if(t.code)return Qg;g()}if(t.highlight){if(!t.code)return Wg;if(t.code)return Hg}g()})())(t.buf)(t.runs)}),qv=t=>e=>0<e.length?{...t,buf:wt(t.buf)(e[0])}:{...t,buf:wt(t.buf)("\\")},Vv=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=Pt(f=>T,f=>l=>J("Just",{head:f,tail:l}),i);if(_.tag==="Nothing"){a=!1,s=c;continue}if(_.tag==="Just"){if(_._1.head==="\\"){r=u,o=qv(c)(_._1.tail),i=Rt(1,_._1.tail.length,_._1.tail);continue}if(_._1.head==="`"){r=u,o=Hv(c),i=_._1.tail;continue}if(u&&_._1.head==="="&&0<_._1.tail.length&&_._1.tail[0]==="="){r=u,o=Ov(c),i=Rt(1,_._1.tail.length,_._1.tail);continue}r=u,o={...c,buf:wt(c.buf)(_._1.head)},i=_._1.tail;continue}g()}return s},sr=t=>{const e=Vv((()=>{const n=rr("md:")(t);if(n.tag==="Just")return!0;if(n.tag==="Nothing")return!1;g()})())({code:!1,highlight:!1,buf:[],runs:[]})(Hn((()=>{const n=rr("md:")(t);if(n.tag==="Just")return n._1;if(n.tag==="Nothing")return t;g()})()));return Og((()=>{if(!e.highlight){if(!e.code)return Yr;if(e.code)return Qg;g()}if(e.highlight){if(!e.code)return Wg;if(e.code)return Hg}g()})())(e.buf)(e.runs)},ur=(()=>{const t=Vn(""),e=V(n=>n.text);return n=>t(e(sr(n)))})();let qg=null;function $v(){return qg||(typeof document>"u"?null:(qg=document.createElement("canvas").getContext("2d"),qg))}const dd=new Map,Uv=t=>e=>n=>r=>()=>{const o=`${n} ${e}px ${t}|${r}`,i=dd.get(o);if(i!==void 0)return i;const a=$v();if(!a)return r.length*e*.62;a.font=`${n} ${e}px ${t}`;const s=a.measureText(r).width;return dd.set(o,s),s},Xv=oo.traverse(mc),Yv=v(hr)(0),$o=(()=>{const t=or(`\r
4
- `)(" "),e=or(`
5
- `)(" "),n=(()=>{const r=or("\r")(" "),o=(()=>{const i=or(" ")(" ");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),hd=t=>e=>{const n=Xv(r=>{const o=(()=>{if(r.style==="RunText")return t.text;if(r.style==="RunCode")return t.code;if(r.style==="RunHighlight")return t.text;if(r.style==="RunCodeHighlight")return t.code;g()})();return Uv(o.family)(o.size)(o.weight)($o(r.text))})(sr($o(e)));return()=>{const r=n();return Yv(r)}},pd={text:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:"500"},code:{family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",size:11,weight:"400"}},Kv=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ji=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},jv=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},md=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Zv=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},yd=t=>Jn(ee(Cr(e=>e===" ")(ee(Cr(e=>e===" ")(Hn(t)).rest)).rest)),tC=t=>v(e=>n=>n._1>0&&(n._2===" "||n._2==="-"||n._2==="_"||n._2===".")?J("Just",n._1):e)(T)(Ht(Ln)(t)),Vg=t=>e=>{if(t<=0)return[e];if(Pn(e)<=t)return[e];const n=Hn(e),r=t<1?[]:Rt(0,t,n),o=tC(r);if(o.tag==="Just"){const i=yd(of(!(o._1>=0&&o._1<r.length)||r[o._1]===" "?o._1:o._1+1|0)(e)),a=yd(Ii(o._1+1|0)(e));return a===""?[i]:[i,...Vg(t)(a)]}if(o.tag==="Nothing"){const i=of(t)(e),a=Ii(t)(e);return a===""?[i]:[i,...Vg(t)(a)]}g()},eC={cellW:7,cellH:3,maxLineWidth:20},nC=t=>e=>{const n=V(i=>S((()=>{if(i.label.tag==="Just")return i.label._1;if(i.label.tag==="Nothing")return i.id;g()})(),i))(e.nodes),r=ji(1)(Jr((jv(t.maxLineWidth)(v(i=>a=>ji(i)(Pn(a._1)))(0)(n))+2|0)+t.cellW|0,t.cellW)),o=(r*t.cellW|0)-1|0;return{...e,nodes:V(i=>{const a=Et(zi(`
6
- `)(i._1))(Vg(o)),s=v(f=>l=>ji(f)(Pn(l)))(0)(a),u=ji(1)(Jr(a.length+t.cellH|0,t.cellH))+(i._2.shape==="Cylinder"||i._2.shape==="Document"?1:0)|0,c=i._2.shape==="Cylinder"?ji(1)(Jr((s+2|0)+t.cellW|0,t.cellW)):r,_=s>o?Jr((s+2|0)+t.cellW|0,t.cellW):c;return{...i._2,size:S(i._2.size._1!==1?md(i._2.size._1)(rt(_)):rt(_),i._2.size._2!==1?i._2.size._2:rt(u))}})(n)}},rC=t=>e=>n=>({...n,nodes:V(r=>{const o=Zv(r.id)(e);if(o.tag==="Nothing")return r;if(o.tag==="Just")return{...r,size:S(md(r.size._1)(rt(ji(1)(he(fs(r.shape==="Cylinder"?(o._1+0)/t:(o._1+32)/t))))),r.size._2)};g()})(n.nodes)}),su=t=>t,oC=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Uo=su("TopSide"),Xo=su("BottomSide"),Yo=su("LeftSide"),Ko=su("RightSide"),iC=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},xd=t=>e=>n=>{const r=oC(t.h*.12)(t.w*.2),o=t.w/2;return(e<0?t.y+r:t.y+t.h-r)+e*r*Ke(iC((()=>{const i=(n-(t.x+o))/o;return 1-i*i})()))},pn=t=>e=>n=>r=>{let o=t,i=e,a=n,s=r,u=!0,c;for(;u;){const _=o,f=i,l=a,d=s;if(_==="Rectangle"){if(l==="TopSide"){u=!1,c=f.y;continue}if(l==="BottomSide"){u=!1,c=f.y+f.h;continue}if(l==="LeftSide"){u=!1,c=f.x;continue}if(l==="RightSide"){u=!1,c=f.x+f.w;continue}o=so,i=f,a=l,s=d;continue}if(_==="Cylinder"){if(l==="TopSide"){u=!1,c=xd(f)(-1)(d);continue}if(l==="BottomSide"){u=!1,c=xd(f)(1)(d);continue}if(l==="LeftSide"){u=!1,c=f.x;continue}if(l==="RightSide"){u=!1,c=f.x+f.w;continue}}o=so,i=f,a=l,s=d}return c},Td=t=>e=>{const n=e.y-t.y,r=n<0?-n:n,o=e.x-(t.x+t.w),i=o<0?-o:o,a=e.x-t.x,s=a<0?-a:a,u=e.y-(t.y+t.h),c=u<0?-u:u;return r<=c&&r<=s&&r<=i?Uo:c<=s&&c<=i?Xo:s<=i?Yo:Ko},aC=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),$g=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},jo=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Wa=fe(R)(Wt),Kr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Zo=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ug=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},sC=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},uC=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},cC=v(t=>e=>it(R)(e)()(t))(M),gC=v(t=>e=>it(R)(e)()(t))(M),Ha=oo.traverse(mc),Oa=fe(R)(Wt),_C=t=>e=>je(R.compare,Xe,t,e),fC=v(t=>e=>it(R)(e)()(t))(M),lC=fe(R)(Wt),dC=t=>e=>je(R.compare,Xe,t,e),hC=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},pC=t=>e=>{const n=Wa(V(r=>S(r._1,(()=>{const o=$g(r._1)(t);if(o.tag==="Nothing")return r._2;if(o.tag==="Just"){const i=jo(o._1._2)(e.nodes),a=jo(o._1._1)(e.nodes),s=(()=>{if(a.tag==="Nothing")return r._2;if(a.tag==="Just"){const u=Pt(c=>T,c=>_=>J("Just",{head:c,tail:_}),r._2);if(u.tag==="Nothing")return r._2;if(u.tag==="Just")return[(()=>{const c=Pt(d=>T,d=>h=>J("Just",{head:d,tail:h}),u._1.tail),_=c.tag==="Just"?J("Just",c._1.head):T,f={x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h},l=(()=>{if(_.tag==="Just"){if((_._1.x>u._1.head.x?_._1.x-u._1.head.x<.5:u._1.head.x-_._1.x<.5)&&u._1.head.x>=f.x-.5&&u._1.head.x<=f.x+f.w+.5)return _._1.y>=f.y+f.h?J("Just",Xo):_._1.y<=f.y?J("Just",Uo):T;if((_._1.y>u._1.head.y?_._1.y-u._1.head.y<.5:u._1.head.y-_._1.y<.5)&&u._1.head.y>=f.y-.5&&u._1.head.y<=f.y+f.h+.5){if(_._1.x>=f.x+f.w)return J("Just",Ko);if(_._1.x<=f.x)return J("Just",Yo)}return T}if(_.tag==="Nothing")return T;g()})();if(l.tag==="Just"){if(l._1==="TopSide")return{...u._1.head,y:pn(a._1.shape)(f)(Uo)(u._1.head.x)};if(l._1==="BottomSide")return{...u._1.head,y:pn(a._1.shape)(f)(Xo)(u._1.head.x)};if(l._1==="LeftSide")return{...u._1.head,x:pn(a._1.shape)(f)(Yo)(u._1.head.y)};if(l._1==="RightSide")return{...u._1.head,x:pn(a._1.shape)(f)(Ko)(u._1.head.y)};g()}if(l.tag==="Nothing"){const d={x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h},h=Td(d)(u._1.head);if(h==="TopSide")return{...u._1.head,y:pn(a._1.shape)(d)(Uo)(u._1.head.x)};if(h==="BottomSide")return{...u._1.head,y:pn(a._1.shape)(d)(Xo)(u._1.head.x)};if(h==="LeftSide")return{...u._1.head,x:pn(a._1.shape)(d)(Yo)(u._1.head.y)};if(h==="RightSide")return{...u._1.head,x:pn(a._1.shape)(d)(Ko)(u._1.head.y)}}g()})(),...u._1.tail]}g()})();if(i.tag==="Nothing")return s;if(i.tag==="Just"){const u=_r(s);if(u.tag==="Nothing")return s;if(u.tag==="Just")return wt(u._1.init)((()=>{const c=_r(u._1.init),_=c.tag==="Just"?J("Just",c._1.last):T,f={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},l=(()=>{if(_.tag==="Just"){if((_._1.x>u._1.last.x?_._1.x-u._1.last.x<.5:u._1.last.x-_._1.x<.5)&&u._1.last.x>=f.x-.5&&u._1.last.x<=f.x+f.w+.5)return _._1.y>=f.y+f.h?J("Just",Xo):_._1.y<=f.y?J("Just",Uo):T;if((_._1.y>u._1.last.y?_._1.y-u._1.last.y<.5:u._1.last.y-_._1.y<.5)&&u._1.last.y>=f.y-.5&&u._1.last.y<=f.y+f.h+.5){if(_._1.x>=f.x+f.w)return J("Just",Ko);if(_._1.x<=f.x)return J("Just",Yo)}return T}if(_.tag==="Nothing")return T;g()})();if(l.tag==="Just"){if(l._1==="TopSide")return{...u._1.last,y:pn(i._1.shape)(f)(Uo)(u._1.last.x)};if(l._1==="BottomSide")return{...u._1.last,y:pn(i._1.shape)(f)(Xo)(u._1.last.x)};if(l._1==="LeftSide")return{...u._1.last,x:pn(i._1.shape)(f)(Yo)(u._1.last.y)};if(l._1==="RightSide")return{...u._1.last,x:pn(i._1.shape)(f)(Ko)(u._1.last.y)};g()}if(l.tag==="Nothing"){const d={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},h=Td(d)(u._1.last);if(h==="TopSide")return{...u._1.last,y:pn(i._1.shape)(d)(Uo)(u._1.last.x)};if(h==="BottomSide")return{...u._1.last,y:pn(i._1.shape)(d)(Xo)(u._1.last.x)};if(h==="LeftSide")return{...u._1.last,x:pn(i._1.shape)(d)(Yo)(u._1.last.y)};if(h==="RightSide")return{...u._1.last,x:pn(i._1.shape)(d)(Ko)(u._1.last.y)}}g()})())}}g()})()))(aC(e.edges)));return{...e,edges:n,bounds:bf(e.nodes)(n)}},mC=t=>{const e=r=>{let o=r,i=!0,a;for(;i;){const s=o,u=v(c=>_=>{if(c.tag==="Just")return c;if(c.tag==="Nothing"){const f=_>=0&&_<s.length?J("Just",s[_]):T;if(f.tag==="Just"){const l=_+1|0,d=l>=0&&l<s.length?J("Just",s[l]):T;if(d.tag==="Just"){const h=_+2|0,p=h>=0&&h<s.length?J("Just",s[h]):T;if(p.tag==="Just"){const m=_+3|0,x=m>=0&&m<s.length?J("Just",s[m]):T;if(x.tag==="Just"){const y=f._1.y===d._1.y&&d._1.x===p._1.x&&p._1.y===x._1.y&&(d._1.x-f._1.x)*(x._1.x-p._1.x)<0&&x._1.x>=Zo(f._1.x)(d._1.x)&&x._1.x<=Kr(f._1.x)(d._1.x)?J("Just",{x:x._1.x,y:f._1.y}):f._1.x===d._1.x&&d._1.y===p._1.y&&p._1.x===x._1.x&&(d._1.y-f._1.y)*(x._1.y-p._1.y)<0&&x._1.y>=Zo(f._1.y)(d._1.y)&&x._1.y<=Kr(f._1.y)(d._1.y)?J("Just",{x:f._1.x,y:x._1.y}):T;if(y.tag==="Just"){const w=y._1;return ue(N=>w.x===x._1.x?w.x>N.x&&w.x<N.x+N.w&&Kr(Zo(w.y)(x._1.y))(N.y)<Zo(Kr(w.y)(x._1.y))(N.y+N.h):w.y===x._1.y?w.y>N.y&&w.y<N.y+N.h&&Kr(Zo(w.x)(x._1.x))(N.x)<Zo(Kr(w.x)(x._1.x))(N.x+N.w):!0,t)?T:J("Just",[...(()=>{const N=_+1|0;return N<1?[]:Rt(0,N,s)})(),w,x._1,...(()=>{const N=_+4|0;return N<1?s:Rt(N,s.length,s)})()])}if(y.tag==="Nothing")return T;g()}if(x.tag==="Nothing")return T;g()}if(p.tag==="Nothing")return T;g()}if(d.tag==="Nothing")return T;g()}if(f.tag==="Nothing")return T}g()})(T)(s.length<4?[]:$t(0,s.length-4|0));if(u.tag==="Nothing"){i=!1,a=s;continue}if(u.tag==="Just"){o=v(c=>_=>{const f=_r(c);if(f.tag==="Nothing")return[_];if(f.tag==="Just"){if(f._1.last.x===_.x&&f._1.last.y===_.y)return c;const l=f._1.init.length-1|0;return l>=0&&l<f._1.init.length&&(f._1.init[l].x===f._1.last.x&&f._1.last.x===_.x||f._1.init[l].y===f._1.last.y&&f._1.last.y===_.y)?wt(f._1.init)(_):wt(c)(_)}g()})([])(u._1);continue}g()}return a},n=v(r=>o=>{const i=_r(r);if(i.tag==="Nothing")return[o];if(i.tag==="Just"){if(i._1.last.x===o.x&&i._1.last.y===o.y)return r;const a=i._1.init.length-1|0;return a>=0&&a<i._1.init.length&&(i._1.init[a].x===i._1.last.x&&i._1.last.x===o.x||i._1.init[a].y===i._1.last.y&&i._1.last.y===o.y)?wt(i._1.init)(o):wt(r)(o)}g()})([]);return r=>e(n(r))},yC=t=>e=>n=>{const r=ne(o=>o.id===n)(t.graph.edges);if(r.tag==="Just")return J("Just",r._1);if(r.tag==="Nothing")return $g(n)(e);g()},xC=t=>e=>n=>r=>({x:r.position._1*t,y:r.position._2*t,w:r.size._1*t,h:r.size._2*t,label:(()=>{const o=jo(r.node)(e);if(o.tag==="Just")return o._1;if(o.tag==="Nothing")return r.node;g()})(),shape:(()=>{const o=jo(r.node)(n);if(o.tag==="Nothing")return so;if(o.tag==="Just")return o._1;g()})()}),TC=t=>({id:t,size:S(1,1),ports:[],label:J("Just",t),shape:so}),wd=t=>e=>n=>{const r=Tt(i=>jo(e)(i.labels))(t.keyframes),o=Pt(i=>T,i=>a=>J("Just",{head:i,tail:a}),r);if(o.tag==="Nothing")return[n];if(o.tag==="Just")return[n,...r];g()},wC=t=>e=>n=>r=>S(r.node,xC(t)(e)(n)(r)),Nd=t=>An(t),Jd=t=>{const e=zi(`
7
- `)(t),n=e.length===0?[""]:e;return n.length*Ug(1)(v(r=>o=>Ug(r)(Pn(o)))(0)(n))|0},NC=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return"";if(e.tag==="Just")return v(n=>r=>Jd(r)>Jd(n)?r:n)(e._1.head)(e._1.tail);g()},JC=t=>e=>NC(wd(t)(e.id)((()=>{if(e.label.tag==="Just")return e.label._1;if(e.label.tag==="Nothing")return e.id;g()})())),vd=t=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,yt("Cons",n._4,e(n._6,r)));g()};return Bt(ce.foldr,e(t.interiors,D))},vC=t=>Wa(Tt(e=>J("Just",S(e.edge,{id:e.edge,from:{node:e.from,port:T},to:{node:e.to,port:T},label:T})))(Et(t.scenes)(e=>e.tag==="DataFlow"?Tt(n=>n.kind.tag==="SendToken"?J("Just",n.kind._1):T)(e._1.events):[]))),Cd=t=>{const e=rx(t),n=V(o=>({...o,label:J("Just",JC(t)(o))}))(gt(o=>sC(o.id)(e.nodes),t.graph.nodes)),r=gt(o=>uC(o.id)(e.edges),t.graph.edges);return{nodes:[...n,...V(TC)(Bt(fn.foldr,lr(R.compare,e.nodes,cC(V(o=>o.id)(n)))))],edges:[...r,...Tt(yC(t)(vC(t)))(Bt(fn.foldr,lr(R.compare,e.edges,gC(V(o=>o.id)(r)))))],constraints:t.graph.constraints}},CC=t=>{const e=Ha(n=>{const r=Ha(hd(pd))(wd(t)(n.id)((()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})()));return()=>{const o=r();return S(n.id,v(Kr)(0)(o))}})(Cd(t).nodes);return()=>{const n=e();return Oa(n)}},bd=t=>{const e=CC(t);return()=>{const n=e(),r=Ha(bd)(vd(t))();return v(_C)(n)(r)}},bC=t=>e=>n=>{const r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),n.segments);if(r.tag==="Nothing")return[];if(r.tag==="Just")return mC(e)([{x:r._1.head.start._1*t,y:r._1.head.start._2*t},...V(o=>({x:o.end._1*t,y:o.end._2*t}))([r._1.head,...r._1.tail])]);g()},kC=t=>e=>{const n=Oa(V(r=>S(r.id,r))(t.nodes));return{...e,nodes:V(r=>{const o=jo(r.id)(n);return o.tag==="Just"&&o._1.size._2===1?{...r,size:S(r.size._1,Zo(r.size._2)(rt(Ug(1)(Jr(An((()=>{if(r.label.tag==="Just")return r.label._1;if(r.label.tag==="Nothing")return r.id;g()})()).length+3|0,3))+(r.shape==="Cylinder"||r.shape==="Document"?1:0)|0)))}:r})(e.nodes)}},LC=t=>e=>n=>S(n.edge,bC(t)(e)(n)),SC=t=>e=>n=>r=>{const o=V(wC(rt(4)*t)(e)(n))(r.nodes),i=Oa(o),a=Wa(V(LC(t)(V(s=>s._2)(o)))(r.edges));return{nodes:i,edges:a,bounds:bf(i)(a),chipExtras:M,edgeLabels:M}},EC=t=>e=>({...pC(Wa(V(n=>S(n.id,S(n.from.node,n.to.node)))(e.edges)))(SC(8)(Oa(V(n=>S(n.id,(()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})()))(e.nodes)))(Oa(V(n=>S(n.id,n.shape))(e.nodes)))(t.stretchNodes?Bv(gd)(e).result:fd(gd)(e).result)),edgeLabels:Wa(Tt(n=>n.label.tag==="Just"?J("Just",S(n.id,n.label._1)):T)(e.edges))}),PC=t=>v(e=>n=>{if(n.tag==="Structural")return e;if(n.tag==="DataFlow")return v(r=>o=>{if(o.kind.tag==="SendToken")return v(i=>a=>it(R)(a)()(i))(r)(o.kind._1.labels);if(o.kind.tag==="FillNodeWithoutTransition")return v(i=>a=>it(R)(a)()(i))(r)(o.kind._1.labels);g()})(e)(n._1.events);if(n.tag==="Hold"||n.tag==="EnterNode"||n.tag==="ExitNode"||n.tag==="StepScene")return e;g()})(M)(t.scenes),GC=t=>{const e=Ha(n=>{const r=hd(pd)(n);return()=>{const o=r();return S(n,{labelW:o,charCount:Pn(ur($o(n))),lineCount:1})}})(Bt(fn.foldr,fC(Et(Bt(fn.foldr,PC(t)))(Nd))));return()=>{const n=e();return lC(n)}},kd=t=>{const e=GC(t);return()=>{const n=e(),r=Ha(kd)(vd(t))();return v(dC)(n)(r)}},RC=rt(4)*8,AC=t=>Et(t.scenes)(e=>{if(e.tag==="Structural")return[];if(e.tag==="DataFlow")return e._1.events;if(e.tag==="Hold")return[];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];if(e.tag==="StepScene")return[];g()}),IC=t=>e=>n=>{const r=o=>{const i=Tt(a=>{const s=hC(a)(t);return s.tag==="Just"?J("Just",{w:s._1.labelW+28,h:rt(Kv(1)(s._1.lineCount))*13.2+12}):T})(Et(o)(Nd));return i.length===0?T:J("Just",{w:v(Kr)(0)(V(a=>a.w)(i)),h:v(Kr)(0)(V(a=>a.h)(i))})};return v(o=>i=>{if(i.kind.tag==="SendToken"){const a=$g(i.kind._1.edge)(n.edges),s=r(i.kind._1.labels);if(s.tag==="Just"&&a.tag==="Just"){const u=s._1;return Mt(R)(xe)(i.kind._1.edge)(V(c=>({x:c.x+14+u.w,y:c.y-6-8-u.h}))(a._1))(o)}return o}if(i.kind.tag==="FillNodeWithoutTransition"){const a=jo(i.kind._1.node)(n.nodes),s=r(i.kind._1.labels);return s.tag==="Just"&&a.tag==="Just"?Mt(R)(xe)("__fill__:"+i.kind._1.node)((()=>{const u=a._1.y-s._1.h-14,c=a._1.x+a._1.w/2,_=c-s._1.w/2,f=c+s._1.w/2,l=a._1.y-14;return[{x:_,y:u},{x:f,y:u},{x:_,y:l},{x:f,y:l}]})())(o):o}g()})(M)(AC(e))},Ld=t=>e=>n=>{const r=Cd(n);return{layout:(()=>{const o=EC(n)(kC(r)(rC(RC)(t)(nC(eC)(r))));return{...o,chipExtras:IC(e)(n)(o)}})(),interiors:(()=>{const o=Ld(t)(e),i=a=>{if(a.tag==="Leaf")return M;if(a.tag==="Node")return Zt("Node",a._1,a._2,a._3,o(a._4),i(a._5),i(a._6));g()};return i(n.interiors)})()}},Sd=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Xg=t=>e=>n=>{const r=t<.05?t:.05,o=(a,s)=>{if(s.tag==="Leaf")return a;if(s.tag==="Node")return o((()=>{const u=Sd(s._3)(n),c=(()=>{if(u.tag==="Just")return u._1;if(u.tag==="Nothing")return{x:s._4.x,y:s._4.y,vx:0,vy:0};g()})(),_=c.vx+(180*(s._4.x-c.x)-22*c.vx)*r,f=c.vy+(180*(s._4.y-c.y)-22*c.vy)*r;return it(R)(s._3)({x:c.x+_*r,y:c.y+f*r,vx:_,vy:f})(o(a,s._5))})(),s._6);g()},i=o(M,e);return{springs:i,applied:(()=>{const a=(s,u)=>{if(u.tag==="Leaf")return s;if(u.tag==="Node")return a((()=>{const c=a(s,u._5),_=Sd(u._3)(i);if(_.tag==="Just")return it(R)(u._3)({...u._4,x:_._1.x,y:_._1.y})(c);if(_.tag==="Nothing")return it(R)(u._3)(u._4)(c);g()})(),u._6);g()};return a(M,e)})()}},tt=(t,e)=>({tag:"CatQueue",_1:t,_2:e}),FC=t=>{let e=t,n=!0,r;for(;n;){const o=e;if(o._1.tag==="Nil"){if(o._2.tag==="Nil"){n=!1,r=T;continue}e=tt((i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=yt("Cons",l._1,f),u=l._2;continue}g()}return _})(D)(o._2),D);continue}if(o._1.tag==="Cons"){n=!1,r=J("Just",S(o._1._1,tt(o._1._2,o._2)));continue}g()}return r},et=(t,e,n)=>({tag:t,_1:e,_2:n}),ct=et("CatNil"),DC=t=>e=>{if(t.tag==="CatNil")return e;if(e.tag==="CatNil")return t;if(t.tag==="CatCons")return et("CatCons",t._1,tt(t._2._1,yt("Cons",e,t._2._2)));g()},zC=t=>e=>n=>{const r=o=>i=>a=>{let s=o,u=i,c=a,_=!0,f;for(;_;){const l=s,d=u,h=c;if(h.tag==="Nil"){_=!1,f=d;continue}if(h.tag==="Cons"){s=l,u=l(d)(h._1),c=h._2;continue}g()}return f};return(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s,l=FC(_);if(l.tag==="Nothing"){u=!1,c=r(d=>h=>h(d))(e)(f);continue}if(l.tag==="Just"){a=l._1._2,s=yt("Cons",t(l._1._1),f);continue}g()}return c})(n)(D)},BC=t=>{if(t.tag==="CatNil")return T;if(t.tag==="CatCons")return J("Just",S(t._1,t._2._1.tag==="Nil"&&t._2._2.tag==="Nil"?ct:zC(DC)(ct)(t._2)));g()},K=(t,e)=>({tag:"Free",_1:t,_2:e}),st=(t,e,n)=>({tag:t,_1:e,_2:n}),Ed=t=>{let e=t,n=!0,r;for(;n;){const o=e;if(o._1.tag==="Return"){const i=BC(o._2);if(i.tag==="Nothing"){n=!1,r=st("Return",o._1._1);continue}if(i.tag==="Just"){e=(()=>{const a=i._1._1(o._1._1);return K(a._1,(()=>{if(a._2.tag==="CatNil")return i._1._2;if(i._1._2.tag==="CatNil")return a._2;if(a._2.tag==="CatCons")return et("CatCons",a._2._1,tt(a._2._2._1,yt("Cons",i._1._2,a._2._2._2)));g()})())})();continue}g()}if(o._1.tag==="Bind"){n=!1,r=st("Bind",o._1._1,i=>{const a=o._1._2(i);return K(a._1,(()=>{if(a._2.tag==="CatNil")return o._2;if(o._2.tag==="CatNil")return a._2;if(a._2.tag==="CatCons")return et("CatCons",a._2._1,tt(a._2._2._1,yt("Cons",o._2,a._2._2._2)));g()})())});continue}g()}return r},MC=t=>e=>{const n=e.Monad0(),r=n.Bind1().Apply0().Functor0();return o=>e.tailRecM(i=>{const a=Ed(i);if(a.tag==="Return")return r.map(a2)(n.Applicative0().pure(a._1));if(a.tag==="Bind")return r.map(yc)(o(t.map(a._2)(a._1)));g()})},QC=t=>e=>n=>{const r=Ed(n);if(r.tag==="Return")return e(r._1);if(r.tag==="Bind")return t(r._1)(r._2);g()},Yg={Applicative0:()=>ho,Bind1:()=>Pd},WC={map:t=>e=>Pd.bind(e)(n=>ho.pure(t(n)))},Pd={bind:t=>e=>K(t._1,(()=>{if(t._2.tag==="CatNil")return et("CatCons",e,tt(D,D));if(t._2.tag==="CatCons")return et("CatCons",t._2._1,tt(t._2._2._1,yt("Cons",et("CatCons",e,tt(D,D)),t._2._2._2)));g()})()),Apply0:()=>Gd},Gd={apply:t=>e=>{const n=r=>K(e._1,(()=>{if(e._2.tag==="CatNil")return et("CatCons",o=>ho.pure(r(o)),tt(D,D));if(e._2.tag==="CatCons")return et("CatCons",e._2._1,tt(e._2._2._1,yt("Cons",et("CatCons",o=>ho.pure(r(o)),tt(D,D)),e._2._2._2)));g()})());return K(t._1,(()=>{if(t._2.tag==="CatNil")return et("CatCons",n,tt(D,D));if(t._2.tag==="CatCons")return et("CatCons",t._2._1,tt(t._2._2._1,yt("Cons",et("CatCons",n,tt(D,D)),t._2._2._2)));g()})())},Functor0:()=>WC},ho={pure:t=>K(st("Return",t),ct),Apply0:()=>Gd},HC=()=>()=>()=>t=>e=>n=>Vm(n.type)(t)?$m(n.type)(t)(n.value):e(n),OC={map:t=>e=>({type:e.type,value:e.map(t)(e.value),map:e.map})},qC=t=>gf("Data.Functor.Variant: pattern match failure ["+t.type+"]"),VC=()=>()=>()=>t=>HC()()()(t)(qC);(function(){var t={},e="Pure",n="Throw",r="Catch",o="Sync",i="Async",a="Bind",s="Bracket",u="Fork",c="Sequential",_="Map",f="Apply",l="Alt",d="Cons",h="Resume",p="Release",m="Finalizer",x="Finalized",y="Forked";function w(Q,F,X,q){this.tag=Q,this._1=F,this._2=X,this._3=q}function N(Q){var F=function(X,q,U){return new w(Q,X,q,U)};return F.tag=Q,F}function b(Q){return new w(e,void 0)}function C(Q){try{Q()}catch(F){setTimeout(function(){throw F},0)}}function L(Q,F,X){try{return F(X())}catch(q){return Q(q)}}function E(Q,F,X){try{return F(X)()}catch(q){return X(Q(q))(),b}}var I=(function(){var Q=1024,F=0,X=0,q=new Array(Q),U=!1;function Y(){var ot;for(U=!0;F!==0;)F--,ot=q[X],q[X]=void 0,X=(X+1)%Q,ot();U=!1}return{isDraining:function(){return U},enqueue:function(ot){var Z;F===Q&&(Z=U,Y(),U=Z),q[(X+F)%Q]=ot,F++,U||Y()}}})();function W(Q){var F={},X=0,q=0;return{register:function(U){var Y=X++;U.onComplete({rethrow:!0,handler:function(ot){return function(){q--,delete F[Y]}}})(),F[Y]=U,q++},isEmpty:function(){return q===0},killAll:function(U,Y){return function(){if(q===0)return Y();var ot=0,Z={};function ft(dt){Z[dt]=F[dt].kill(U,function(Nt){return function(){delete Z[dt],ot--,Q.isLeft(Nt)&&Q.fromLeft(Nt)&&setTimeout(function(){throw Q.fromLeft(Nt)},0),ot===0&&Y()}})()}for(var Lt in F)F.hasOwnProperty(Lt)&&(ot++,ft(Lt));return F={},X=0,q=0,function(dt){return new w(o,function(){for(var Nt in Z)Z.hasOwnProperty(Nt)&&Z[Nt]()})}}}}}var P=0,G=1,j=2,nt=3,O=4,$=5,H=6;function A(Q,F,X){var q=0,U=P,Y=X,ot=null,Z=null,ft=null,Lt=null,dt=null,Nt=0,St=0,te=null,Jt=!0;function Yt(lt){for(var xt,It,ht;;)switch(xt=null,It=null,ht=null,U){case j:U=G;try{Y=ft(Y),Lt===null?ft=null:(ft=Lt._1,Lt=Lt._2)}catch(Qt){U=$,ot=Q.left(Qt),Y=null}break;case nt:Q.isLeft(Y)?(U=$,ot=Y,Y=null):ft===null?U=$:(U=j,Y=Q.fromRight(Y));break;case G:switch(Y.tag){case a:ft&&(Lt=new w(d,ft,Lt)),ft=Y._2,U=G,Y=Y._1;break;case e:ft===null?(U=$,Y=Q.right(Y._1)):(U=j,Y=Y._1);break;case o:U=nt,Y=L(Q.left,Q.right,Y._1);break;case i:U=O,Y=E(Q.left,Y._1,function(Qt){return function(){q===lt&&(q++,I.enqueue(function(){q===lt+1&&(U=nt,Y=Qt,Yt(q))}))}});return;case n:U=$,ot=Q.left(Y._1),Y=null;break;case r:ft===null?dt=new w(d,Y,dt,Z):dt=new w(d,Y,new w(d,new w(h,ft,Lt),dt,Z),Z),ft=null,Lt=null,U=G,Y=Y._1;break;case s:Nt++,ft===null?dt=new w(d,Y,dt,Z):dt=new w(d,Y,new w(d,new w(h,ft,Lt),dt,Z),Z),ft=null,Lt=null,U=G,Y=Y._1;break;case u:U=nt,xt=A(Q,F,Y._2),F&&F.register(xt),Y._1&&xt.run(),Y=Q.right(xt);break;case c:U=G,Y=z(Q,F,Y._1);break}break;case $:if(ft=null,Lt=null,dt===null)U=H,Y=Z||ot||Y;else switch(xt=dt._3,ht=dt._1,dt=dt._2,ht.tag){case r:Z&&Z!==xt&&Nt===0?U=$:ot&&(U=G,Y=ht._2(Q.fromLeft(ot)),ot=null);break;case h:Z&&Z!==xt&&Nt===0||ot?U=$:(ft=ht._1,Lt=ht._2,U=j,Y=Q.fromRight(Y));break;case s:Nt--,ot===null&&(It=Q.fromRight(Y),dt=new w(d,new w(p,ht._2,It),dt,xt),(Z===xt||Nt>0)&&(U=G,Y=ht._3(It)));break;case p:dt=new w(d,new w(x,Y,ot),dt,Z),U=G,Z&&Z!==xt&&Nt===0?Y=ht._1.killed(Q.fromLeft(Z))(ht._2):ot?Y=ht._1.failed(Q.fromLeft(ot))(ht._2):Y=ht._1.completed(Q.fromRight(Y))(ht._2),ot=null,Nt++;break;case m:Nt++,dt=new w(d,new w(x,Y,ot),dt,Z),U=G,Y=ht._1;break;case x:Nt--,U=$,Y=ht._1,ot=ht._2;break}break;case H:for(var Ct in te)te.hasOwnProperty(Ct)&&(Jt=Jt&&te[Ct].rethrow,C(te[Ct].handler(Y)));te=null,Z&&ot?setTimeout(function(){throw Q.fromLeft(ot)},0):Q.isLeft(Y)&&Jt&&setTimeout(function(){if(Jt)throw Q.fromLeft(Y)},0);return;case P:U=G;break;case O:return}}function Ft(lt){return function(){if(U===H)return Jt=Jt&&lt.rethrow,lt.handler(Y)(),function(){};var xt=St++;return te=te||{},te[xt]=lt,function(){te!==null&&delete te[xt]}}}function vt(lt,xt){return function(){if(U===H)return xt(Q.right(void 0))(),function(){};var It=Ft({rethrow:!1,handler:function(){return xt(Q.right(void 0))}})();switch(U){case P:Z=Q.left(lt),U=H,Y=Z,Yt(q);break;case O:Z===null&&(Z=Q.left(lt)),Nt===0&&(U===O&&(dt=new w(d,new w(m,Y(lt)),dt,Z)),U=$,Y=null,ot=null,Yt(++q));break;default:Z===null&&(Z=Q.left(lt)),Nt===0&&(U=$,Y=null,ot=null)}return It}}function mt(lt){return function(){var xt=Ft({rethrow:!1,handler:lt})();return U===P&&Yt(q),xt}}return{kill:vt,join:mt,onComplete:Ft,isSuspended:function(){return U===P},run:function(){U===P&&(I.isDraining()?Yt(q):I.enqueue(function(){Yt(q)}))}}}function B(Q,F,X,q){var U=0,Y={},ot=0,Z={},ft=new Error("[ParAff] Early exit"),Lt=null,dt=t;function Nt(Ft,vt,mt){var lt=vt,xt=null,It=null,ht=0,Ct={},Qt,zt;t:for(;;)switch(Qt=null,lt.tag){case y:if(lt._3===t&&(Qt=Y[lt._1],Ct[ht++]=Qt.kill(Ft,function(ie){return function(){ht--,ht===0&&mt(ie)()}})),xt===null)break t;lt=xt._2,It===null?xt=null:(xt=It._1,It=It._2);break;case _:lt=lt._2;break;case f:case l:xt&&(It=new w(d,xt,It)),xt=lt,lt=lt._1;break}if(ht===0)mt(Q.right(void 0))();else for(zt=0,Qt=ht;zt<Qt;zt++)Ct[zt]=Ct[zt]();return Ct}function St(Ft,vt,mt){var lt,xt,It,ht,Ct,Qt;for(Q.isLeft(Ft)?(lt=Ft,xt=null):(xt=Ft,lt=null);;){if(It=null,ht=null,Ct=null,Qt=null,Lt!==null)return;if(vt===null){q(lt||xt)();return}if(vt._3!==t)return;switch(vt.tag){case _:lt===null?(vt._3=Q.right(vt._1(Q.fromRight(xt))),xt=vt._3):vt._3=lt;break;case f:if(It=vt._1._3,ht=vt._2._3,lt){if(vt._3=lt,Ct=!0,Qt=ot++,Z[Qt]=Nt(ft,lt===It?vt._2:vt._1,function(){return function(){delete Z[Qt],Ct?Ct=!1:mt===null?St(lt,null,null):St(lt,mt._1,mt._2)}}),Ct){Ct=!1;return}}else{if(It===t||ht===t)return;xt=Q.right(Q.fromRight(It)(Q.fromRight(ht))),vt._3=xt}break;case l:if(It=vt._1._3,ht=vt._2._3,It===t&&Q.isLeft(ht)||ht===t&&Q.isLeft(It))return;if(It!==t&&Q.isLeft(It)&&ht!==t&&Q.isLeft(ht))lt=xt===It?ht:It,xt=null,vt._3=lt;else if(vt._3=xt,Ct=!0,Qt=ot++,Z[Qt]=Nt(ft,xt===It?vt._2:vt._1,function(){return function(){delete Z[Qt],Ct?Ct=!1:mt===null?St(xt,null,null):St(xt,mt._1,mt._2)}}),Ct){Ct=!1;return}break}mt===null?vt=null:(vt=mt._1,mt=mt._2)}}function te(Ft){return function(vt){return function(){delete Y[Ft._1],Ft._3=vt,St(vt,Ft._2._1,Ft._2._2)}}}function Jt(){var Ft=G,vt=X,mt=null,lt=null,xt,It;t:for(;;)switch(xt=null,It=null,Ft){case G:switch(vt.tag){case _:mt&&(lt=new w(d,mt,lt)),mt=new w(_,vt._1,t,t),vt=vt._2;break;case f:mt&&(lt=new w(d,mt,lt)),mt=new w(f,t,vt._2,t),vt=vt._1;break;case l:mt&&(lt=new w(d,mt,lt)),mt=new w(l,t,vt._2,t),vt=vt._1;break;default:It=U++,Ft=$,xt=vt,vt=new w(y,It,new w(d,mt,lt),t),xt=A(Q,F,xt),xt.onComplete({rethrow:!1,handler:te(vt)})(),Y[It]=xt,F&&F.register(xt)}break;case $:if(mt===null)break t;mt._1===t?(mt._1=vt,Ft=G,vt=mt._2,mt._2=t):(mt._2=vt,vt=mt,lt===null?mt=null:(mt=lt._1,lt=lt._2))}for(dt=vt,It=0;It<U;It++)Y[It].run()}function Yt(Ft,vt){Lt=Q.left(Ft);var mt;for(var lt in Z)if(Z.hasOwnProperty(lt)){mt=Z[lt];for(lt in mt)mt.hasOwnProperty(lt)&&mt[lt]()}Z=null;var xt=Nt(Ft,dt,vt);return function(It){return new w(i,function(ht){return function(){for(var Ct in xt)xt.hasOwnProperty(Ct)&&xt[Ct]();return b}})}}return Jt(),function(Ft){return new w(i,function(vt){return function(){return Yt(Ft,vt)}})}}function z(Q,F,X){return new w(i,function(q){return function(){return B(Q,F,X,q)}})}return w.EMPTY=t,w.Pure=N(e),w.Throw=N(n),w.Catch=N(r),w.Sync=N(o),w.Async=N(i),w.Bind=N(a),w.Bracket=N(s),w.Fork=N(u),w.Seq=N(c),w.ParMap=N(_),w.ParApply=N(f),w.ParAlt=N(l),w.Fiber=A,w.Supervisor=W,w.Scheduler=I,w.nonCanceler=b,w})();const $C=t=>e=>QC(n=>r=>t({type:n.type,value:n.map(o=>r(o))(n.value),map:n.map}))(e),UC=t=>{const e=t.Bind1(),n=t.Applicative0().pure;return r=>{const o=Om(()=>$C(i=>e.bind(r(i))(o()))(n));return o()}};let Rd=null;function XC(){return Rd||(typeof document>"u"?null:Rd=document.createElement("canvas").getContext("2d"))}const Kg=new Map;function Ad(t,e,n,r,o,i){const a=`${n} ${e}px ${t}`,s=a+"|"+r;if(Kg.has(s))return Kg.get(s);const u=XC();if(!u)return i;u.font=a;const c=o(u.measureText(r)),_=typeof document<"u"?document.fonts:null;if(!_||_.check(a))Kg.set(s,c);else if(_&&_.load)try{_.load(a)}catch{}return c}const YC=(t,e,n,r)=>Ad(t,e,n,r,o=>o.width,-1),KC=(t,e,n,r)=>Ad(t,e,n,r,o=>({ascent:o.actualBoundingBoxAscent,descent:o.actualBoundingBoxDescent}),{ascent:-1,descent:-1}),uu=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),Id=t=>t,Fd={map:t=>e=>{if(e.tag==="MeasureText")return uu("MeasureText",e._1,e._2,n=>t(e._3(n)));if(e.tag==="MeasureInk")return uu("MeasureInk",e._1,e._2,n=>t(e._3(n)));g()}},jg=t=>e=>{const n=YC(t.family,t.size,t.weight,$o(e));return n<0?rt(on(e).length)*t.size*.62:n},Zg=t=>e=>{const n=KC(t.family,t.size,t.weight,$o(e));return n.ascent<0?{ascent:t.size*.72,descent:t.size*.2}:n},jC=t=>e=>K(st("Bind",{type:"metrics",value:uu("MeasureInk",t,e,Id),map:Fd.map},n=>K(st("Return",n),ct)),ct),ti=t=>e=>K(st("Bind",{type:"metrics",value:uu("MeasureText",t,e,Id),map:Fd.map},n=>K(st("Return",n),ct)),ct),Dd=t=>t,zd=t=>t,cu=t=>t,Bd=t=>t,Md=t=>t,Xt=(t,e,n,r,o)=>({tag:t,_1:e,_2:n,_3:r,_4:o}),Qd=t=>t,t_=t=>t,ZC=t_("BaselineTop"),Un=t_("BaselineMiddle"),tb=t_("BaselineBottom"),po=Qd("AlignLeft"),ei=Qd("AlignCenter"),Ze=Md("RoundJoin"),qa=Md("MiterJoin"),In=Bd("ButtCap"),Ir=Bd("RoundCap"),eb=cu("LayerPolyOut"),nb=cu("LayerPolyIn"),rb=cu("LayerNodeMask"),ob=cu("LayerOverlay"),mo=zd("NonZero"),e_=zd("EvenOdd"),Wd=Dd("Normal"),gu=Dd("Difference"),Ne={r:255,g:255,b:255,a:255},ni=[5],Ce={map:t=>e=>{if(e.tag==="FillPath")return Xt("FillPath",e._1,e._2,t(e._3));if(e.tag==="StrokePath")return Xt("StrokePath",e._1,e._2,t(e._3));if(e.tag==="FillStrokePath")return Xt("FillStrokePath",e._1,e._2,e._3,t(e._4));if(e.tag==="DrawText")return Xt("DrawText",e._1,t(e._2));if(e.tag==="DrawTextAffine")return Xt("DrawTextAffine",e._1,e._2,t(e._3));if(e.tag==="PushTransform")return Xt("PushTransform",e._1,t(e._2));if(e.tag==="PopTransform")return Xt("PopTransform",t(e._1));if(e.tag==="PushClip")return Xt("PushClip",e._1,e._2,t(e._3));if(e.tag==="PopClip")return Xt("PopClip",t(e._1));if(e.tag==="PushBlend")return Xt("PushBlend",e._1,t(e._2));if(e.tag==="PopBlend")return Xt("PopBlend",t(e._1));if(e.tag==="PushAlpha")return Xt("PushAlpha",e._1,t(e._2));if(e.tag==="PopAlpha")return Xt("PopAlpha",t(e._1));if(e.tag==="PushBlur")return Xt("PushBlur",e._1,t(e._2));if(e.tag==="PopBlur")return Xt("PopBlur",t(e._1));if(e.tag==="PushLayer")return Xt("PushLayer",e._1,t(e._2));if(e.tag==="PopLayer")return Xt("PopLayer",t(e._1));if(e.tag==="SetViewport")return Xt("SetViewport",e._1,t(e._2));if(e.tag==="ClearBackground")return Xt("ClearBackground",e._1,t(e._2));if(e.tag==="BackgroundDots")return Xt("BackgroundDots",e._1,t(e._2));g()}},jr={r:26,g:26,b:26,a:255},n_=t=>e=>Math.imul(t,e),Zi=t=>{const e=t+1831565813|0,n=n_(e^e>>>15)(e|1),r=n^(n+n_(n^n>>>7)(n|61)|0),o=r^r>>>14;return{prng:o,value:o<0?(rt(o)+4294967296)/4294967296:rt(o)/4294967296}},Fe=t=>e=>n=>{const r=Zi(n);return{prng:r.prng,value:t+r.value*(e-t)}},r_=t=>e=>v(n=>r=>n_(n^r)(-2048144789))(e)(V(go)(Hn(t))),ib=t=>t,Hd=t=>t,ab=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},vn=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Od=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},o_=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},sb=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ub=Hd("FlatLevel"),cb=Hd("NestedLevel"),i_=ib("GenieSilhouette"),gb=t=>e=>n=>r=>{if(e)return{prng:t,yLift:0};const o=Zi(t);return{prng:o.prng,yLift:o.value*n.yJitter*r}},_b=t=>e=>n=>r=>{if(e)return{prng:t,dx:0};const o=Zi(t);return{prng:o.prng,dx:(o.value*2-1)*n.xJitter*r}},qd=t=>e=>{const n=e.cy-t.cy,r=e.cx-t.cx,o=Ke(r*r+n*n),i=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=Ke(ab(0)(t.r*t.r-i*i)),s=t.cx+i*r/o,u=t.cy+i*n/o,c={x:s-a*n/o,y:u+a*r/o},_={x:s+a*n/o,y:u-a*r/o};return o===0||o>t.r+e.r?{x:(t.cx+e.cx)/2,y:t.cy}:c.y<_.y?c:_},_u=t=>e=>{const n=vn(e)(vn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},fb=t=>e=>n=>r=>o=>i=>{if(e)return{prng:t,r:o};if(n)return{prng:t,r:o*(1+i.rJitter)};if(r)return{prng:t,r:o*i.smallScale};const a=Zi(t);return{prng:a.prng,r:o*(1+a.value*i.rJitter)}},Vd=t=>{const e=vn(t.w)(t.h)/2;return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,4,t.x+t.w-e+.5522847498307936*e,t.y,t.x+t.w,t.y+e-.5522847498307936*e,t.x+t.w,t.y+e,4,t.x+t.w,t.y+e+.5522847498307936*e,t.x+t.w-e+.5522847498307936*e,t.y+t.h,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,4,t.x+e-.5522847498307936*e,t.y+t.h,t.x,t.y+e+.5522847498307936*e,t.x,t.y+e,4,t.x,t.y+e-.5522847498307936*e,t.x+e-.5522847498307936*e,t.y,t.x+e,t.y,5]},lb=t=>e=>n=>{const r=Zi(t),o=e.length;return o===0?{prng:t,idx:-1}:{prng:r.prng,idx:(()=>{const i=Od(0)(o-1|0)(he(nr(r.value*rt(n))));return i>=0&&i<e.length?e[i]:-1})()}},db=t=>e=>{const n=Zi(t),r=e.length;return r===0?{prng:t,idx:-1}:{prng:n.prng,idx:(()=>{const o=Od(0)(r-1|0)(he(nr(n.value*rt(r))));return o>=0&&o<e.length?e[o]:-1})()}},$d=t=>{const e=vn(t.w*.18)(t.h*.6);return[1,t.x+e,t.y,2,t.x+t.w,t.y,2,t.x+t.w-e,t.y+t.h,2,t.x,t.y+t.h,5]},Ud=t=>[1,t.x,t.y,2,t.x+t.w,t.y,2,t.x+t.w,t.y+t.h*.85,4,t.x+t.w*.66,t.y+t.h*1.05,t.x+t.w*.34,t.y+t.h*.65,t.x,t.y+t.h*.85,5],Xd={rBase:1.2,stepRatio:.7,rJitter:.35,yJitter:.2,xJitter:.2,heroShift:.2,smallScale:.85,smallShift:.15,seed:7,minN:3},hb=t=>{const e=vn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,o=t.x+n;return[1,t.x,r,4,t.x,r+.5522847498*e,o-.5522847498*n,r+e,o,r+e,4,o+.5522847498*n,r+e,t.x+t.w,r+.5522847498*e,t.x+t.w,r]},Yd=t=>{const e=vn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+t.h+5,o=t.y+e,i=r-e,a=t.x+n;return[1,t.x,o,4,t.x,o-.5522847498*e,a-.5522847498*n,t.y,a,t.y,4,a+.5522847498*n,t.y,t.x+t.w,o-.5522847498*e,t.x+t.w,o,2,t.x+t.w,i,4,t.x+t.w,i+.5522847498*e,a+.5522847498*n,r,a,r,4,a-.5522847498*n,r,t.x,i+.5522847498*e,t.x,i,5]},Kd=t=>e=>{const n=e.y+e.h,r=B2(t.rBase*e.h)(e.w/(2*(1+(rt(t.minN)-1)*t.stepRatio))),o=e.w-2*r,i=2*r*t.stepRatio,a=o_(t.minN)(o<=0||i<=0?t.minN:he(Wn(o/i))+1|0),s=a>=3?$t(1,a-2|0):[],u=s.length,c=Jr(u+1|0,2),_=c<1?[]:Rt(0,c,s),f=db(t.seed)((()=>{const m=u-c|0;return m<1?s:Rt(m,s.length,s)})()),l=f.idx,d=lb(f.prng)(gt(m=>m!==l,_))(o_(1)(_.length-(gn(ro)(l)(_)?1:0)|0)),h=d.idx,p=a>=2?o/(rt(a)-1):0;return v(m=>x=>{const y=x===h,w=x===l,N=x===0||x===(a-1|0),b=fb(m.prng)(N)(w)(y)(r)(t),C=gb(b.prng)(N)(t)(e.h),L=_b(C.prng)(N)(t)(p);return{prng:L.prng,circles:wt(m.circles)({cx:e.x+sb(b.r)(e.w-b.r)((a>=2?r+rt(x)/(rt(a)-1)*o+L.dx:r+0*o+L.dx)+(w?t.heroShift*p:y?-1*t.smallShift*p:0)),cy:n-C.yLift,r:b.r})}})({prng:d.prng,circles:[]})($t(0,a-1|0)).circles},jd=t=>e=>{const n=t.length;return Ht(r=>o=>({c:o,p1:(()=>{if(r===0)return{x:o.cx-o.r,y:e};const i=r-1|0;return i>=0&&i<t.length?qd(t[i])(o):{x:o.cx-o.r,y:e}})(),p2:(()=>{if(r===(n-1|0))return{x:o.cx+o.r,y:e};const i=r+1|0;return i>=0&&i<t.length?qd(o)(t[i]):{x:o.cx+o.r,y:e}})()}))(t)},Zd=t=>{const e=vn(t.h*.4)(t.w*.2);return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,2,t.x+t.w,t.y+t.h/2,2,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,2,t.x,t.y+t.h/2,5]},pb=t=>e=>n=>{const r=Ao(e.y-t.cy)(e.x-t.cx),o=Ao(n.y-t.cy)(n.x-t.cx),i=o>r?o-r:o+6.283185307179586-r,a=o_(1)(he(fs(i/1.5707963267948966))),s=i/rt(a),u=1.3333333333333333*M2(s/4);return Et($t(0,a-1|0))(c=>{const _=r+rt(c+1|0)*s,f=t.cx+t.r*_n(_),l=t.cy+t.r*Ye(_),d=r+rt(c)*s;return[4,t.cx+t.r*_n(d)-u*t.r*Ye(d),t.cy+t.r*Ye(d)+u*t.r*_n(d),f+u*t.r*Ye(_),l-u*t.r*_n(_),f,l]})},th=t=>e=>{const n=t.h*.38,r=jd(Kd(Xd)({x:t.x,y:t.y-n,w:t.w,h:n}))(t.y),o=vn(e)(vn(t.w/2)(t.h/2));return 0<r.length?[1,r[0].p1.x,r[0].p1.y,...Et(r)(i=>pb(i.c)(i.p1)(i.p2)),2,t.x+t.w,t.y+t.h-o,3,t.x+t.w,t.y+t.h,t.x+t.w-o,t.y+t.h,2,t.x+o,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-o,2,r[0].p1.x,r[0].p1.y,5]:_u(t)(e)},ri=t=>e=>n=>r=>o=>i=>{if(e==="Rectangle")return t.drawRoundedRect(n)(r)(o)(i);if(e==="Cylinder"){const a=Yd(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Parallelogram"){const a=$d(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Diamond"){const a=Zd(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Ellipse"){const a=Vd(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Document"){const a=Ud(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Cloud"){const a=th(n)(r);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}return t.drawRoundedRect(n)(r)(o)(i)},mb={fillPath:t=>e=>K(st("Bind",{type:"render",value:Xt("FillPath",t,e,void 0),map:Ce.map},n=>K(st("Return",n),ct)),ct),strokePath:t=>e=>K(st("Bind",{type:"render",value:Xt("StrokePath",t,e,void 0),map:Ce.map},n=>K(st("Return",n),ct)),ct),fillStrokePath:t=>e=>n=>K(st("Bind",{type:"render",value:Xt("FillStrokePath",t,e,n,void 0),map:Ce.map},r=>K(st("Return",r),ct)),ct),drawRoundedRect:t=>e=>n=>r=>{if(n.tag==="Just"){if(r.tag==="Just")return K(st("Bind",{type:"render",value:Xt("FillStrokePath",_u(t)(e),n._1,r._1,void 0),map:Ce.map},o=>K(st("Return",o),ct)),ct);if(r.tag==="Nothing")return K(st("Bind",{type:"render",value:Xt("FillPath",_u(t)(e),n._1,void 0),map:Ce.map},o=>K(st("Return",o),ct)),ct);g()}if(n.tag==="Nothing"){if(r.tag==="Just")return K(st("Bind",{type:"render",value:Xt("StrokePath",_u(t)(e),r._1,void 0),map:Ce.map},o=>K(st("Return",o),ct)),ct);if(r.tag==="Nothing")return K(st("Return",void 0),ct)}g()},drawText:t=>K(st("Bind",{type:"render",value:Xt("DrawText",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),drawTextAffine:t=>e=>K(st("Bind",{type:"render",value:Xt("DrawTextAffine",t,e,void 0),map:Ce.map},n=>K(st("Return",n),ct)),ct),pushTransform:t=>K(st("Bind",{type:"render",value:Xt("PushTransform",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popTransform:K(st("Bind",{type:"render",value:Xt("PopTransform",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushBakedTransform:t=>K(st("Bind",{type:"render",value:Xt("PushTransform",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popBakedTransform:K(st("Bind",{type:"render",value:Xt("PopTransform",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushClip:t=>e=>K(st("Bind",{type:"render",value:Xt("PushClip",t,e,void 0),map:Ce.map},n=>K(st("Return",n),ct)),ct),popClip:K(st("Bind",{type:"render",value:Xt("PopClip",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushBlend:t=>K(st("Bind",{type:"render",value:Xt("PushBlend",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popBlend:K(st("Bind",{type:"render",value:Xt("PopBlend",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushAlpha:t=>K(st("Bind",{type:"render",value:Xt("PushAlpha",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popAlpha:K(st("Bind",{type:"render",value:Xt("PopAlpha",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushBlur:t=>K(st("Bind",{type:"render",value:Xt("PushBlur",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popBlur:K(st("Bind",{type:"render",value:Xt("PopBlur",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),pushLayer:t=>K(st("Bind",{type:"render",value:Xt("PushLayer",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),popLayer:K(st("Bind",{type:"render",value:Xt("PopLayer",void 0),map:Ce.map},t=>K(st("Return",t),ct)),ct),setViewport:t=>K(st("Bind",{type:"render",value:Xt("SetViewport",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),clearBackground:t=>K(st("Bind",{type:"render",value:Xt("ClearBackground",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),backgroundDots:t=>K(st("Bind",{type:"render",value:Xt("BackgroundDots",t,void 0),map:Ce.map},e=>K(st("Return",e),ct)),ct),measureText:t=>e=>ti(t)(e),measureInk:t=>e=>jC(t)(e),insideTokenStyle:t=>K(st("Return",i_),ct),Monad0:()=>Yg},yb=t=>()=>t.clip("evenodd"),xb=t=>e=>()=>{t.filter=`blur(${e}px)`},Tb=t=>e=>()=>{const n=e>0?t.canvas.width/e:1;t.setTransform(n,0,0,n,0,0)},wb=t=>e=>n=>r=>o=>()=>{const i=e>0?t.canvas.width/e:1;t.setTransform(i*n,0,0,i*n,i*r,i*o)},Nb=t=>e=>()=>{const n=Math.max(8,Math.ceil(8/Math.max(e.tile,.001))),r=Math.max(2,Math.round(e.tile*n)),o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d");i.scale(n,n),i.fillStyle=e.bgCss,i.fillRect(0,0,e.tile,e.tile),i.fillStyle=e.dotCss,i.beginPath(),i.arc(e.tile/2,e.tile/2,e.dotR,0,2*Math.PI),i.fill();const a=t.createPattern(o,"repeat");a&&typeof a.setTransform=="function"&&a.setTransform(new DOMMatrix().translateSelf(e.ox,e.oy).scaleSelf(1/n,1/n)),t.save(),t.fillStyle=a,t.fillRect(e.vx,e.vy,e.vw,e.vh),t.restore()},a_=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},s_=t=>e=>n=>{const r=e.stroke;return()=>{const o=r.value,i=oy(t)(n);if(o!==n)return i(),e.stroke.value=n}},Jb=t=>e=>n=>{const r=e.font;return()=>{const o=r.value,i=ly(t)(n);if(o!==n)return i(),e.font.value=n}},Va=t=>e=>n=>{const r=e.fill;return()=>{const o=r.value,i=ry(t)(n);if(o!==n)return i(),e.fill.value=n}},fu=t=>e=>{const n=e.length,r=i=>{if(i>=n)return()=>{};const a=i>=0&&i<e.length?e[i]:0;if(a===1){const s=X1(t)((()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})()),u=r(i+3|0);return()=>(s(),u())}if(a===2){const s=fa(t)((()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})()),u=r(i+3|0);return()=>(s(),u())}if(a===3){const s=la(t)({cpx:(()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})(),cpy:(()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=i+3|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=i+4|0;return c>=0&&c<e.length?e[c]:0})()}),u=r(i+5|0);return()=>(s(),u())}if(a===4){const s=hy(t)({cp1x:(()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})(),cp1y:(()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})(),cp2x:(()=>{const c=i+3|0;return c>=0&&c<e.length?e[c]:0})(),cp2y:(()=>{const c=i+4|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=i+5|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=i+6|0;return c>=0&&c<e.length?e[c]:0})()}),u=r(i+7|0);return()=>(s(),u())}if(a===5){const s=Y1(t),u=r(i+1|0);return()=>(s(),u())}return()=>{}},o=U1(t);return()=>(o(),r(0)())},vb=t=>e=>n=>r=>o=>i=>{const a=a_(i)(a_(r/2)(o/2)),s=X1(t)(e+a)(n);return()=>(s(),fa(t)(e+r-a)(n)(),la(t)({cpx:e+r,cpy:n,x:e+r,y:n+a})(),fa(t)(e+r)(n+o-a)(),la(t)({cpx:e+r,cpy:n+o,x:e+r-a,y:n+o})(),fa(t)(e+a)(n+o)(),la(t)({cpx:e,cpy:n+o,x:e,y:n+o-a})(),fa(t)(e)(n+a)(),la(t)({cpx:e,cpy:n,x:e+a,y:n})(),Y1(t)())},Cb=()=>({font:{value:""},fill:{value:""},stroke:{value:""}}),eh=t=>e=>{const n=cy(t)({x:0,y:0,width:e.width,height:e.height});return()=>{n();const r=Cb();return{ctx:t,surface:e,styleCache:r,maskDepth:{value:0},groupAlpha:{value:1},alphaSaves:{value:[]}}}},bb={map:t=>e=>n=>{const r=e(n);return()=>{const o=r();return t(o)}}},kb=t=>ae(t.weight)+" "+Po(t.size)+"px "+t.family,Fr=t=>{const e=Po(rt(t.a)/255);return t.a>=255?"rgb("+ae(t.r)+","+ae(t.g)+","+ae(t.b)+")":"rgba("+ae(t.r)+","+ae(t.g)+","+ae(t.b)+","+e+")"},Lb=t=>e=>n=>r=>{const o=br(t);return()=>(o(),Tb(t)(e.width)(),Va(t)(n)(Fr(r))(),uy(t)({x:0,y:0,width:e.width,height:e.height})(),kr(t)(),n.font.value="",n.fill.value="",n.stroke.value="")},Sb=t=>e=>n=>{const r=e.font;return()=>(r.value="",e.fill.value="",e.stroke.value="",Nb(t)({vx:n.viewport.vx,vy:n.viewport.vy,vw:n.viewport.vw,vh:n.viewport.vh,bgCss:Fr(n.bgColor),dotCss:Fr(n.dotColor),tile:n.tile,dotR:n.dotRadius,ox:n.origin.x,oy:n.origin.y})())},Eb=t=>e=>n=>r=>{const o=Va(t)(e)(Fr(r));return()=>(o(),fu(t)(n)(),Gc(t)())},Pb=t=>e=>n=>r=>o=>{const i=Va(t)(e)(Fr(r));return()=>(i(),s_(t)(e)(Fr(o.color))(),Lc(t)(o.width)(),Wc(t)((()=>{if(o.lineJoin==="RoundJoin")return Dc;if(o.lineJoin==="BevelJoin")return Fc;if(o.lineJoin==="MiterJoin")return zc;g()})())(),Hc(t)((()=>{if(o.lineCap==="ButtCap")return Qc;if(o.lineCap==="RoundCap")return Bc;if(o.lineCap==="SquareCap")return Mc;g()})())(),fu(t)(n)(),Gc(t)(),Pc(t)())},Gb=t=>e=>n=>r=>o=>i=>{const a=U1(t);return()=>{if(a(),vb(t)(n.x)(n.y)(n.w)(n.h)(r)(),o.tag==="Just"?(Va(t)(e)(Fr(o._1.color))(),Gc(t)()):o.tag==="Nothing"||g(),i.tag==="Just")return s_(t)(e)(Fr(i._1.color))(),Lc(t)(i._1.width)(),Wc(t)((()=>{if(i._1.lineJoin==="RoundJoin")return Dc;if(i._1.lineJoin==="BevelJoin")return Fc;if(i._1.lineJoin==="MiterJoin")return zc;g()})())(),Hc(t)((()=>{if(i._1.lineCap==="ButtCap")return Qc;if(i._1.lineCap==="RoundCap")return Bc;if(i._1.lineCap==="SquareCap")return Mc;g()})())(),Pc(t)();i.tag!=="Nothing"&&g()}},Rb=t=>e=>n=>r=>{const o=s_(t)(e)(Fr(r.color));return()=>(o(),Lc(t)(r.width)(),Wc(t)((()=>{if(r.lineJoin==="RoundJoin")return Dc;if(r.lineJoin==="BevelJoin")return Fc;if(r.lineJoin==="MiterJoin")return zc;g()})())(),Hc(t)((()=>{if(r.lineCap==="ButtCap")return Qc;if(r.lineCap==="RoundCap")return Bc;if(r.lineCap==="SquareCap")return Mc;g()})())(),fu(t)(n)(),Pc(t)())},nh=t=>e=>n=>{const r=Va(t)(e)(Fr(n.color));return()=>(r(),Jb(t)(e)(kb(n.font))(),by(t)((()=>{if(n.align==="AlignLeft")return Ty;if(n.align==="AlignCenter")return Ny;if(n.align==="AlignRight")return wy;g()})())(),Cy(t)((()=>{if(n.baseline==="BaselineTop")return py;if(n.baseline==="BaselineMiddle")return my;if(n.baseline==="BaselineAlphabetic")return yy;if(n.baseline==="BaselineBottom")return xy;g()})())(),dy(t)(n.content)(n.x)(n.y)())},rh={apply:t=>e=>n=>{const r=t(n),o=e(n);return()=>{const i=r(),a=o();return i(a)}},Functor0:()=>bb},Ab={bind:t=>e=>n=>{const r=t(n);return()=>{const o=r();return e(o)(n)()}},Apply0:()=>rh},Ib=t=>e=>n=>{const r=a_(e.width/n.vw)(e.height/n.vh);return wb(t)(e.width)(r)((e.width-n.vw*r)/2-n.vx*r)((e.height-n.vh*r)/2-n.vy*r)},Fb={pure:t=>e=>()=>t,Apply0:()=>rh},oh={Applicative0:()=>Fb,Bind1:()=>Ab},u_={fillPath:t=>e=>n=>{const r=Eb(n.ctx)(n.styleCache)(t)(e.color),o=n.maskDepth;return()=>{if(o.value===0)return r()}},strokePath:t=>e=>n=>{const r=Rb(n.ctx)(n.styleCache)(t)(e),o=n.maskDepth;return()=>{if(o.value===0)return r()}},fillStrokePath:t=>e=>n=>r=>{const o=Pb(r.ctx)(r.styleCache)(t)(e.color)(n),i=r.maskDepth;return()=>{if(i.value===0)return o()}},drawRoundedRect:t=>e=>n=>r=>o=>{const i=Gb(o.ctx)(o.styleCache)(t)(e)(n)(r),a=o.maskDepth;return()=>{if(a.value===0)return i()}},drawText:t=>e=>{const n=nh(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},drawTextAffine:t=>e=>n=>{const r=br(n.ctx),o=n.maskDepth;return()=>{if(o.value===0)return r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",gy(n.ctx)(t)(),nh(n.ctx)(n.styleCache)(e)(),kr(n.ctx)(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value=""}},pushTransform:t=>e=>{const n=br(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",K1(e.ctx)({translateX:t.tx,translateY:t.ty})(),ps(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popTransform:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBakedTransform:t=>e=>{const n=br(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",K1(e.ctx)({translateX:t.tx,translateY:t.ty})(),ps(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popBakedTransform:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushClip:t=>e=>n=>{const r=br(n.ctx),o=n.maskDepth;return()=>{if(o.value===0){if(r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",fu(n.ctx)(t)(),e==="NonZero")return sy(n.ctx)();if(e==="EvenOdd")return yb(n.ctx)();g()}}},popClip:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBlend:t=>e=>{const n=br(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){if(n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",t==="Normal")return Z1(e.ctx)(Jy)();if(t==="Difference")return Z1(e.ctx)(vy)();g()}}},popBlend:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushAlpha:t=>e=>{const n=br(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="";const o=e.groupAlpha.value,i=e.alphaSaves.value;e.alphaSaves.value=[...i,o];const a=o*t;return e.groupAlpha.value=a,ay(e.ctx)(a)()}}},popAlpha:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0){e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value="";const r=t.alphaSaves.value,o=_r(r);if(o.tag==="Just")return t.alphaSaves.value=o._1.init,t.groupAlpha.value=o._1.last;if(o.tag==="Nothing")return t.groupAlpha.value=1;g()}}},pushBlur:t=>e=>{const n=br(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="";const o=xb(e.ctx)(t);if(t>=.01)return o()}}},popBlur:t=>{const e=kr(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushLayer:t=>e=>{if(t==="LayerNodeMask"){const n=e.maskDepth;return()=>{const r=n.value;n.value=r+1|0}}return()=>{}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;if(n>0)return t.maskDepth.value=r}},setViewport:t=>e=>{const n=Ib(e.ctx)(e.surface)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},clearBackground:t=>e=>{const n=Lb(e.ctx)(e.surface)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},backgroundDots:t=>e=>{const n=Sb(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},measureText:t=>e=>n=>{const r=jg(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Zg(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>i_,Monad0:()=>oh},Db=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},$a=t=>e=>n=>{const r=Db(.05)(1-t-e);return n<t?0:n>1-e?1:(n-t)/r},c_=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},zb=t=>{if(t.tag==="Retracted")return{lo:0,hi:0};if(t.tag==="Extended")return{lo:0,hi:1};if(t.tag==="Extending"){if(t._1==="ExtendFromSource")return{lo:0,hi:c_(t._2)};if(t._1==="ExtendFromTarget")return{lo:1-t._2,hi:1};g()}if(t.tag==="Retracting"){if(t._1==="FromSource")return{lo:t._2,hi:1};if(t._1==="FromTarget")return{lo:0,hi:1-t._2};if(t._1==="FromBoth")return{lo:t._2/2,hi:1-t._2/2}}g()},oi=t=>{if(t.tag==="Hidden")return{alpha:0,scale:1};if(t.tag==="Visible")return{alpha:1,scale:1};if(t.tag==="PloppingIn")return{alpha:c_(t._1),scale:1};if(t.tag==="PloppingOut")return{alpha:c_(1-t._1),scale:1};g()};function Bb(t,e){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function Mb(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r++){const o=t[r],i=t[(r+1)%e];n[r]={a:o,b:i,len:Bb(o,i)}}return n}function Qb(t,e,n){let r=0;for(let o=0;o<t.length;o++){const i=t[o],a=r,s=a+i.len;if(n<=s){const u=i.len>1e-6?(n-a)/i.len:0;return{x:i.a.x+(i.b.x-i.a.x)*u,y:i.a.y+(i.b.y-i.a.y)*u}}r=s}return e.length>0?e[e.length-1]:{x:0,y:0}}function ih(t,e){if(e.length===0)return[];const n=Mb(e);let r=0;for(let i=0;i<n.length;i++)r+=n[i].len;const o=new Array(t);for(let i=0;i<t;i++)o[i]=Qb(n,e,i*r/t);return o}function Wb(t,e){const n=e.length;if(n===0)return e;const r=(t%n+n)%n|0,o=new Array(n);for(let i=0;i<n;i++)o[i]=e[(i+r)%n];return o}function Hb(t,e){const n=e.length;if(n===0)return e;let r=0,o=1/0;for(let i=0;i<n;i++){let a=0;for(let s=0;s<n;s++){const u=t[s]||{x:0,y:0},c=e[(s+i)%n]||{x:0,y:0},_=u.x-c.x,f=u.y-c.y;a+=_*_+f*f}a<o&&(o=a,r=i)}return Wb(r,e)}const ah=t=>e=>n=>{const r=ih(t,e),o=ih(t,n),i=Hb(r,o);return{from:r,to:i}};function sh(t){const e=t.length;if(e===0)return{x:0,y:0};let n=0,r=0;for(let o=0;o<e;o++)n+=t[o].x,r+=t[o].y;return{x:n/e,y:r/e}}function Ob(t,e){const n=e.x-t.x,r=e.y-t.y,o=Math.sqrt(n*n+r*r);return o<=1e-4?{x:1,y:0}:{x:n/o,y:r/o}}function qb(t,e){const n=e.length;if(n===0)return e;const r=new Array(n);for(let o=0;o<n;o++){const i=e[((o-1)%n+n)%n],a=e[((o+1)%n+n)%n],s=e[o];r[o]={x:s.x+((i.x+a.x)/2-s.x)*t,y:s.y+((i.y+a.y)/2-s.y)*t}}return r}function Vb(t){return t<0?0:t>1?1:t}const uh=t=>e=>n=>r=>{const o=e.length;if(o===0)return[];const i=sh(e),a=sh(n),s=Ob(i,a),u=new Array(o);let c=1/0,_=-1/0;for(let d=0;d<o;d++){const h=e[d],p=(h.x-i.x)*s.x+(h.y-i.y)*s.y;u[d]=p,p<c&&(c=p),p>_&&(_=p)}const f=_-c;let l=new Array(o);for(let d=0;d<o;d++){const h=e[d],p=n[d];if(p===void 0){l[d]=h;continue}const m=f<=1e-4?0:r.maxDelay*(1-(u[d]-c)/f),x=Math.max(1e-4,1-m),y=Vb((t-m)/x),w=y*y*(3-2*y);l[d]={x:h.x+(p.x-h.x)*w,y:h.y+(p.y-h.y)*w}}for(let d=0;d<r.smoothPasses;d++)l=qb(.5,l);return l},ch=(t,e)=>({tag:t,_1:e}),gh=(t,e)=>({tag:t,_1:e}),pe=(t,e,n)=>({tag:t,_1:e,_2:n}),_h=t=>t,lu=(t,e)=>({tag:t,_1:e}),du=(t,e)=>({tag:t,_1:e}),hu=t=>t,ii=t=>({tag:"FloorOverlay",_1:t}),Ge=(t,e,n)=>({tag:t,_1:e,_2:n}),yo=(t,e)=>({tag:t,_1:e}),ai=(t,e)=>({tag:t,_1:e}),fh=(t,e)=>({tag:t,_1:e}),lh=t=>t,dh=(t,e)=>({tag:t,_1:e}),si=(t,e,n)=>({tag:t,_1:e,_2:n}),hh=t=>t,$b=t=>t,ui=hh("NormalTransform"),Ub=hh("BakedTransform"),ph=lh("TokenOutside"),mh=lh("TokenInside"),yh=ai("PlainText"),Xb=yo("Watermark"),Yb=hu("NodeShadow"),Kb=hu("NodeDoorwayFrame"),xh=hu("NodeBody"),jb=hu("NodeInversion"),g_=_h("LabelsShown"),pu=_h("LabelsHidden"),cr={map:t=>e=>{if(e.tag==="BeginFrame")return Ge("BeginFrame",e._1,t(e._2));if(e.tag==="EndFrame")return Ge("EndFrame",t(e._1));if(e.tag==="BeginGroup")return Ge("BeginGroup",e._1,t(e._2));if(e.tag==="EndGroup")return Ge("EndGroup",e._1,t(e._2));if(e.tag==="Background")return Ge("Background",e._1,t(e._2));if(e.tag==="Overlay")return Ge("Overlay",e._1,t(e._2));if(e.tag==="Node")return Ge("Node",e._1,t(e._2));if(e.tag==="Edge")return Ge("Edge",e._1,t(e._2));if(e.tag==="Text")return Ge("Text",e._1,t(e._2));if(e.tag==="Token")return Ge("Token",e._1,t(e._2));if(e.tag==="AskInsideTokenStyle")return Ge("AskInsideTokenStyle",e._1,n=>t(e._2(n)));g()}},Th=t=>e=>ti(t)(e),Zb=t=>{const e=t.Bind1().Apply0().Functor0(),n=UC(t);return r=>o=>n(VC()()()({scene:i=>{if(i.tag==="BeginFrame"){const a=i._2;return e.map(s=>a)(r.beginFrame(i._1))}if(i.tag==="EndFrame"){const a=i._1;return e.map(s=>a)(r.endFrame)}if(i.tag==="BeginGroup"){const a=i._2;return e.map(s=>a)(r.beginGroup(i._1))}if(i.tag==="EndGroup"){const a=i._2;return e.map(s=>a)(r.endGroup(i._1))}if(i.tag==="Background"){const a=i._2;return e.map(s=>a)(r.background(i._1))}if(i.tag==="Overlay"){const a=i._2;return e.map(s=>a)(r.overlay(i._1))}if(i.tag==="Node"){const a=i._2;return e.map(s=>a)(r.node(i._1))}if(i.tag==="Edge"){const a=i._2;return e.map(s=>a)(r.edge(i._1))}if(i.tag==="Text"){const a=i._2;return e.map(s=>a)(r.text(i._1))}if(i.tag==="Token"){const a=i._2;return e.map(s=>a)(r.token(i._1))}if(i.tag==="AskInsideTokenStyle")return e.map(i._2)(r.insideTokenStyle(i._1));g()},metrics:i=>{if(i.tag==="MeasureText")return e.map(i._3)(r.measureText(i._1)(i._2));if(i.tag==="MeasureInk")return e.map(i._3)(r.measureInk(i._1)(i._2));g()}}))(o)},t3=t=>K(st("Bind",{type:"scene",value:Ge("AskInsideTokenStyle",t,$b),map:cr.map},e=>K(st("Return",e),ct)),ct),wh=t=>K(st("Bind",{type:"scene",value:Ge("Background",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),Nh=t=>K(st("Bind",{type:"scene",value:Ge("Edge",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),mu=t=>K(st("Bind",{type:"scene",value:Ge("Node",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),ci=t=>K(st("Bind",{type:"scene",value:Ge("Overlay",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),gi=t=>K(st("Bind",{type:"scene",value:Ge("Text",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),Jh=t=>K(st("Bind",{type:"scene",value:Ge("Token",t,void 0),map:cr.map},e=>K(st("Return",e),ct)),ct),e3=t=>e=>K(st("Bind",{type:"scene",value:Ge("BeginFrame",t,void 0),map:cr.map},n=>K(st("Return",n),ct)),et("CatCons",()=>K(e._1,(()=>{if(e._2.tag==="CatNil")return et("CatCons",()=>K(st("Bind",{type:"scene",value:Ge("EndFrame",void 0),map:cr.map},n=>K(st("Return",n),ct)),ct),tt(D,D));if(e._2.tag==="CatCons")return et("CatCons",e._2._1,tt(e._2._2._1,yt("Cons",et("CatCons",()=>K(st("Bind",{type:"scene",value:Ge("EndFrame",void 0),map:cr.map},n=>K(st("Return",n),ct)),ct),tt(D,D)),e._2._2._2)));g()})()),tt(D,D))),ke=t=>e=>K(st("Bind",{type:"scene",value:Ge("BeginGroup",t,void 0),map:cr.map},n=>K(st("Return",n),ct)),et("CatCons",()=>{const n=()=>K(st("Bind",{type:"scene",value:Ge("EndGroup",t,void 0),map:cr.map},r=>K(st("Return",r),ct)),ct);return K(e._1,(()=>{if(e._2.tag==="CatNil")return et("CatCons",n,tt(D,D));if(e._2.tag==="CatCons")return et("CatCons",e._2._1,tt(e._2._2._1,yt("Cons",et("CatCons",n,tt(D,D)),e._2._2._2)));g()})())},tt(D,D))),Dr=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},vh=v(hr)(0),Ch=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},n3=v(t=>e=>t+e.len)(0),bh=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Et(Rt(1,t.length,t))(n=>[2,n.x,n.y]),5];g()},r3=t=>e=>{const n=Dr(e)(Dr(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},o3=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Et(e._1.tail)(n=>[2,n.x,n.y])];g()},xo=t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h};if(t.shape==="Cylinder")return Yd(e);if(t.shape==="Parallelogram")return $d(e);if(t.shape==="Diamond")return Zd(e);if(t.shape==="Ellipse")return Vd(e);if(t.shape==="Document")return Ud(e);if(t.shape==="Cloud")return th(e)(7);if(t.shape==="Rectangle")return r3(e)(7);g()},De=t=>e=>n=>V(r=>{const o=rt(r)/rt(n);return{x:t.x+(e.x-t.x)*o,y:t.y+(e.y-t.y)*o}})($t(0,n-1|0)),i3=t=>{const e=vn(t.w*.18)(t.h*.6);return[...De({x:t.x+e,y:t.y})({x:t.x+t.w,y:t.y})(16),...De({x:t.x+t.w,y:t.y})({x:t.x+t.w-e,y:t.y+t.h})(16),...De({x:t.x+t.w-e,y:t.y+t.h})({x:t.x,y:t.y+t.h})(16),...De({x:t.x,y:t.y+t.h})({x:t.x+e,y:t.y})(16)]},__=t=>e=>{const n=Dr(t)(Dr(e.w/2)(e.h/2));return{...e,x:e.x+n,y:e.y+n,w:e.w-2*n,h:e.h-2*n}},f_=t=>e=>{const n=e.y-t.y,r=e.x-t.x;return Ke(r*r+n*n)},a3=t=>Oe(e=>n=>({a:e,b:n,len:f_(e)(n)}),t,Rt(1,t.length,t)),kh=t=>e=>{const n=e.length-1|0,r=n>=0&&n<e.length?J("Just",e[n]):T,o=(()=>{if(r.tag==="Just")return[r._1];if(r.tag==="Nothing")return[];g()})(),i=0<e.length?J("Just",e[0]):T,a=(()=>{if(i.tag==="Just")return i._1;if(i.tag==="Nothing")return{x:0,y:0};g()})(),s=e.length;return s<3?e:[a,...Et($t(1,s-2|0))(u=>{const c=u+1|0,_=c>=0&&c<e.length?J("Just",e[c]):T,f=u>=0&&u<e.length?J("Just",e[u]):T,l=u-1|0,d=l>=0&&l<e.length?J("Just",e[l]):T;if(d.tag==="Just"&&f.tag==="Just"&&_.tag==="Just"){const h=f._1,p=f_(h)(_._1),m=f_(d._1)(h),x=Dr(t)(p/2),y=Dr(t)(m/2),w=p>0?x/p:0,N=h.x+(_._1.x-h.x)*w,b=h.y+(_._1.y-h.y)*w,C=m>0?y/m:0,L=h.x+(d._1.x-h.x)*C,E=h.y+(d._1.y-h.y)*C;return V(I=>{const W=rt(I)/rt(10),P=1-W;return{x:P*P*L+2*P*W*h.x+W*W*N,y:P*P*E+2*P*W*h.y+W*W*b}})($t(0,10))}return[]}),...o]},s3=t=>e=>n=>r=>o=>V(i=>{const a=rt(i)/rt(o),s=1-a,u=a*a*a,c=3*s*a*a,_=3*s*s*a,f=s*s*s;return{x:f*t.x+_*e.x+c*n.x+u*r.x,y:f*t.y+_*e.y+c*n.y+u*r.y}})($t(0,o-1|0)),u3=t=>[...De({x:t.x,y:t.y})({x:t.x+t.w,y:t.y})(12),...De({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h*.85})(12),...s3({x:t.x+t.w,y:t.y+t.h*.85})({x:t.x+t.w*.66,y:t.y+t.h*1.05})({x:t.x+t.w*.34,y:t.y+t.h*.65})({x:t.x,y:t.y+t.h*.85})(32),...De({x:t.x,y:t.y+t.h*.85})({x:t.x,y:t.y})(12)],Lh=t=>e=>V(n=>{const r=6.283185307179586*rt(n)/rt(64);return{x:t.x+e*_n(r),y:t.y+e*Ye(r)}})($t(0,63)),Sh=t=>e=>{const n=.5522847498*e;return[1,t.x+e,t.y,4,t.x+e,t.y+n,t.x+n,t.y+e,t.x,t.y+e,4,t.x-n,t.y+e,t.x-e,t.y+n,t.x-e,t.y,4,t.x-e,t.y-n,t.x-n,t.y-e,t.x,t.y-e,4,t.x+n,t.y-e,t.x+e,t.y-n,t.x+e,t.y,5]},c3=t=>{const e=t.y+t.h/2,n=vn(t.h*.4)(t.w*.2);return[...De({x:t.x+n,y:t.y})({x:t.x+t.w-n,y:t.y})(10),...De({x:t.x+t.w-n,y:t.y})({x:t.x+t.w,y:e})(8),...De({x:t.x+t.w,y:e})({x:t.x+t.w-n,y:t.y+t.h})(8),...De({x:t.x+t.w-n,y:t.y+t.h})({x:t.x+n,y:t.y+t.h})(10),...De({x:t.x+n,y:t.y+t.h})({x:t.x,y:e})(8),...De({x:t.x,y:e})({x:t.x+n,y:t.y})(8)]},l_=t=>{const e=t.length;return e===0?{x:0,y:0}:{x:vh(V(n=>n.x)(t))/rt(e),y:vh(V(n=>n.y)(t))/rt(e)}},yu=t=>e=>n=>r=>o=>V(i=>{const a=n+(r-n)*(rt(i)/rt(o));return{x:t.x+e*_n(a),y:t.y+e*Ye(a)}})($t(0,o-1|0)),d_=t=>e=>{const n=Dr(t)(Dr(e.w/2)(e.h/2));return[...De({x:e.x+n,y:e.y})({x:e.x+e.w-n,y:e.y})(6),...yu({x:e.x+e.w-n,y:e.y+n})(n)(4.71238898038469)(6.283185307179586)(12),...De({x:e.x+e.w,y:e.y+n})({x:e.x+e.w,y:e.y+e.h-n})(6),...yu({x:e.x+e.w-n,y:e.y+e.h-n})(n)(0)(1.5707963267948966)(12),...De({x:e.x+e.w-n,y:e.y+e.h})({x:e.x+n,y:e.y+e.h})(6),...yu({x:e.x+n,y:e.y+e.h-n})(n)(1.5707963267948966)(3.141592653589793)(12),...De({x:e.x,y:e.y+e.h-n})({x:e.x,y:e.y+n})(6),...yu({x:e.x+n,y:e.y+n})(n)(3.141592653589793)(4.71238898038469)(12)]},xu=t=>e=>n=>r=>o=>i=>V(a=>{const s=r+(o-r)*(rt(a)/rt(i));return{x:t.x+e*_n(s),y:t.y+n*Ye(s)}})($t(0,i-1|0)),g3=t=>{const e=t.h*.38;return[...Et(jd(Kd(Xd)({x:t.x,y:t.y-e,w:t.w,h:e}))(t.y))(n=>{const r=Ao(n.p2.y-n.c.cy)(n.p2.x-n.c.cx),o=Ao(n.p1.y-n.c.cy)(n.p1.x-n.c.cx);return xu({x:n.c.cx,y:n.c.cy})(n.c.r)(n.c.r)(o)(r>o?r:r+6.283185307179586)(16)}),...De({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h})(8),...De({x:t.x+t.w,y:t.y+t.h})({x:t.x,y:t.y+t.h})(12),...De({x:t.x,y:t.y+t.h})({x:t.x,y:t.y})(8)]},_3=t=>{const e=Dr(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,o=t.y+t.h+5-e-2,i=t.x+n;return[...xu({x:i,y:r})(n)(e)(3.141592653589793)(6.283185307179586)(24),...De({x:t.x+t.w,y:r})({x:t.x+t.w,y:o})(12),...xu({x:i,y:o})(n)(e)(0)(3.141592653589793)(24),...De({x:t.x,y:o})({x:t.x,y:r})(12)]},_i=t=>e=>e.shape==="Cylinder"?_3(e):e.shape==="Parallelogram"?i3(e):e.shape==="Diamond"?c3(e):e.shape==="Ellipse"?d_(vn(e.w)(e.h)/2)(e):e.shape==="Document"?u3(e):e.shape==="Cloud"?g3(e):d_(t)(e),f3=t=>{const e=Dr(t.h*.075)(t.w*.075),n=t.w/2;return xu({x:t.x+n,y:t.y+e})(n)(e)(0)(3.141592653589793)(24)},l3=t=>e=>n=>v(r=>o=>{const i=r.pos+o.len,a=n<i?(n-r.pos)/o.len:1,s={x:o.a.x+(o.b.x-o.a.x)*a,y:o.a.y+(o.b.y-o.a.y)*a},u=e>r.pos?(e-r.pos)/o.len:0,c={x:o.a.x+(o.b.x-o.a.x)*u,y:o.a.y+(o.b.y-o.a.y)*u},_=r.points.length-1|0,f=_>=0&&_<r.points.length?(()=>{const l=r.points[_].x-c.x;return(l<0?-l<1e-4:l<1e-4)&&(()=>{const d=r.points[_].y-c.y;return d<0?-d<1e-4:d<1e-4})()})()?wt(r.points)(s):[...r.points,c,s]:[c,s];return o.len<=0||i<=e||r.pos>=n?{...r,pos:i}:{pos:i,points:f}})({pos:0,points:[]})(t).points,d3=t=>e=>n=>{const r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),t);if(r.tag==="Nothing")return[];if(r.tag==="Just"){const o=a3(t),i=n3(o),a=Ch(0)(i)(e*i),s=Ch(0)(i)(n*i);return s<=a?[]:l3(o)(a)(s)}g()},h3=t=>e=>n=>r=>{const o=r.x-n.x,i=r.y-n.y,a=e.x-t.x,s=e.y-t.y,u=n.x-t.x,c=n.y-t.y,_=a*i-s*o,f=(u*i-c*o)/_,l=(u*s-c*a)/_;return(_<0?-_<1e-9:_<1e-9)?T:f>=0&&f<=1&&l>=0&&l<=1?J("Just",f):T},p3=t=>e=>n=>{const r=Gt(o=>i=>at.compare(o.t)(i.t))(Tt(o=>{const i=h3(e)(n)(o._1)(o._2);return i.tag==="Just"?J("Just",{t:i._1,p:{x:e.x+(n.x-e.x)*i._1,y:e.y+(n.y-e.y)*i._1}}):T})(Oe(Ln,t,[...Rt(1,t.length,t),...Rt(0,1,t)])));return 0<r.length?J("Just",r[0].p):T},Eh=t=>e=>{const n=_r(e);if(n.tag==="Nothing")return e;if(n.tag==="Just"){const r=n._1.init.length-1|0;if(r>=0&&r<n._1.init.length){const o=p3(t)(n._1.init[r])(n._1.last);if(o.tag==="Just")return wt(n._1.init)(o._1);if(o.tag==="Nothing")return e;g()}return e}g()},To=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},h_=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},m3=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},y3=t=>e=>{const n=To(0)(t.y+4-e.y)+To(0)(e.y+e.h-(t.y+t.h-4)),r=To(0)(t.x+4-e.x)+To(0)(e.x+e.w-(t.x+t.w-4));return r*e.h+n*e.w+r*n},x3=t=>e=>{const n=t.y+t.h-6,r=t.y+6,o=t.x+14,i=t.x+t.w-14,a=v(To)(0)(V(s=>o-10<s.x+s.w+12&&i+10>s.x-12&&r-10<s.y+s.h+12&&n+10>s.y-12?h_((s.x+s.w+12-(o-10))/.7071067811865476)((n+10-(s.y-12))/.7071067811865476):0)(e));return{...t,x:t.x+a*.7071067811865476,y:t.y-a*.7071067811865476}},T3=t=>e=>{const n=h_(t.x+t.w)(e.x+e.w)-To(t.x)(e.x),r=h_(t.y+t.h)(e.y+e.h)-To(t.y)(e.y);return t.x<e.x+e.w&&t.x+t.w>e.x&&t.y<e.y+e.h&&t.y+t.h>e.y?n*r:0},Ph=t=>e=>n=>r=>{const o=t+4,i=To(0)(e-8),a=o+i-n;return n<=i?m3(o)(a)(r):t+(e-n)/2},p_=t=>e=>({...e,x:Ph(t.x)(t.w)(e.w)(e.x),y:Ph(t.y)(t.h)(e.h)(e.y)}),w3=t=>{const e=2*t.token.x-t.rect.x-t.rect.w,n=t.token.y-t.rect.h/2,r=t.token.x-t.rect.w/2,o=2*t.token.y-t.rect.y-t.rect.h;return[{...t.rect,x:t.rect.x,y:t.rect.y},{...t.rect,x:e,y:t.rect.y},{...t.rect,x:t.rect.x,y:o},{...t.rect,x:e,y:o},{...t.rect,x:t.rect.x,y:n},{...t.rect,x:e,y:n},{...t.rect,x:r,y:t.rect.y},{...t.rect,x:r,y:o}]},N3=t=>e=>n=>r=>o=>{const i=o.y+o.h/2-n.token.y,a=o.y-r.y;return(()=>{const s=o.x+o.w/2-n.token.x,u=o.x-r.x;return 1e6*y3(t)(o)+1e4*v(c=>_=>c+T3(o)(_))(0)(e)+.05*(u*u+a*a)+.01*(s*s+i*i)})()+(o.y>n.token.y?100:0)},J3=t=>e=>n=>r=>{const o=a=>{const s=p_(t)(a);return{rect:s,score:N3(t)(e)(n)(r)(s)}},i=Pt(a=>T,a=>s=>J("Just",{head:a,tail:s}),[r,n.rect,...w3(n)]);if(i.tag==="Nothing")return p_(t)(r);if(i.tag==="Just")return v(a=>s=>{const u=o(s);return u.score<a.score?u:a})(o(i._1.head))(i._1.tail).rect;g()},v3=t=>e=>n=>v(r=>o=>{const i=x3(o.rect)(r.obstacles),a=i.x>=t.x+4&&i.y>=t.y+4&&i.x+i.w<=t.x+t.w-4&&i.y+i.h<=t.y+t.h-4?i:J3(t)(r.obstacles)(o)(i);return{acc:it(R)(o.id)(a)(r.acc),obstacles:wt(r.obstacles)(a)}})({acc:M,obstacles:e})(n).acc,m_=t=>t,Zr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},fi=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},C3=Si(xc)(Wt),b3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},k3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Gh=m_("SegMove"),L3=m_("SegLine"),S3=m_("SegQuad"),Rh={offset:.4,passes:1,rMax:1.5},Ah=t=>he(nr(t.x*7919+t.y*3001+t.w*113+t.h*17+1))*-1640531535|0,Tu=t=>e=>n=>()=>{t.push(3),t.push(e.x),t.push(e.y),t.push(n.x),t.push(n.y)},wu=t=>e=>()=>{t.push(1),t.push(e.x),t.push(e.y)},to=t=>e=>()=>{t.push(2),t.push(e.x),t.push(e.y)},Ua=(()=>{const t=v(e=>n=>((e*31|0)+he(nr(n.x*100))|0)+he(nr(n.y*100))|0)(1);return e=>t(e)*-1640531535|0})(),E3=t=>{const e=[];let n=0,r={x:0,y:0};for(;n<t.length;){const o=n,i=r,a=o>=0&&o<t.length?J("Just",t[o]):T;if(a.tag==="Nothing"){n=t.length;continue}if(a.tag==="Just"){if(a._1===1){const s={x:(()=>{const u=o+1|0;return u>=0&&u<t.length?t[u]:0})(),y:(()=>{const u=o+2|0;return u>=0&&u<t.length?t[u]:0})()};e.push({kind:Gh,m:i,c:i,p:s,len:0}),r=s,n=o+3|0;continue}if(a._1===2){const s={x:(()=>{const _=o+1|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+2|0;return _>=0&&_<t.length?t[_]:0})()},u=s.x-i.x,c=s.y-i.y;e.push({kind:L3,m:i,c:i,p:s,len:Ke(u*u+c*c)}),r=s,n=o+3|0;continue}if(a._1===3){const s={x:(()=>{const _=o+3|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+4|0;return _>=0&&_<t.length?t[_]:0})()},u=s.x-i.x,c=s.y-i.y;e.push({kind:S3,m:i,c:{x:(()=>{const _=o+1|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+2|0;return _>=0&&_<t.length?t[_]:0})()},p:s,len:Ke(u*u+c*c)*1.05}),r=s,n=o+5|0;continue}if(a._1===5){e.push({kind:Gh,m:i,c:i,p:i,len:0}),n=o+1|0;continue}n=t.length;continue}g()}return e},P3=t=>e=>{const n=e.length-1|0,r=n<1?[]:Rt(0,n,e),o=(()=>{const a=r.length-1|0;return a>=0&&a<r.length?J("Just",r[a]):T})(),i=e.length-1|0;if(i>=0&&i<e.length&&o.tag==="Just"){const a=e[i].y-o._1.y,s=e[i].x-o._1.x,u=Ke(s*s+a*a);return u<=1e-4?e:wt((()=>{const c=e.length-1|0;return c<1?[]:Rt(0,c,e)})())({x:e[i].x+s/u*t,y:e[i].y+a/u*t})}return e},G3=t=>e=>n=>ee(v(r=>o=>{const i=Fe(0)(t)(r.prng),a=Fe(0)(6.283185307179586)(i.prng);return{prng:a.prng,out:[{x:o.x+i.value*_n(a.value),y:o.y+i.value*Ye(a.value)},...r.out]}})({prng:e,out:[]})(n).out),R3=t=>e=>n=>{if(e.kind==="SegMove")return wu(t)(e.p);if(e.kind==="SegLine")return to(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});if(e.kind==="SegQuad")return to(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});g()},A3=t=>e=>{if(e.kind==="SegMove")return wu(t)(e.p);if(e.kind==="SegLine")return to(t)(e.p);if(e.kind==="SegQuad")return Tu(t)(e.c)(e.p);g()},Ih=t=>e=>{const n=E3(e),r=v(s=>u=>s+u.len)(0)(n)*Zr(0)(fi(1)(t)),o=[];let i=0,a=0;for(;a<n.length;){const s=a,u=i;if(s>=0&&s<n.length){if(u+n[s].len<=r){const c=n[s];A3(o)(c)(),i=u+c.len,a=s+1|0;continue}if(u>=r){a=n.length;continue}R3(o)(n[s])((r-u)/Zr(n[s].len)(1e-4))()}a=n.length}return o},Fh={offset:1.5,passes:2,rMax:14,overshoot:2.5},Dh=t=>e=>n=>r=>{const o=r.y-n.y,i=n.y-e.y,a=r.x-n.x,s=Ke(a*a+o*o),u=n.x-e.x,c=Ke(u*u+i*i),_=fi(t.rMax*(z2(c>0&&s>0?Zr(-1)(fi(1)((u*a+i*o)/(c*s))):1)/3.141592653589793))(.4*fi(c)(s));return{inP:c>0?{x:n.x-u/c*_,y:n.y-i/c*_}:n,curr:n,outP:s>0?{x:n.x+a/s*_,y:n.y+o/s*_}:n}},zh=t=>e=>{const n=e.length,r=[],o=0<e.length?J("Just",e[0]):T;if(o.tag==="Just"?wu(r)(o._1)():o.tag==="Nothing"||g(),n>=3){let a=1;for(;a<=(n-2|0);){const s=a,u=s+1|0;if(u>=0&&u<e.length){if(s>=0&&s<e.length){const c=s-1|0;if(c>=0&&c<e.length){const _=Dh(t)(e[c])(e[s])(e[u]);to(r)(_.inP)(),Tu(r)(_.curr)(_.outP)()}}a=s+1|0;continue}a=s+1|0}}const i=e.length-1|0;return i>=0&&i<e.length&&n>=2&&to(r)(e[i])(),r},I3=t=>e=>n=>r=>o=>{if(o.length<4)return zh(t)(o);const i=0<o.length?J("Just",o[0]):T,a=(()=>{if(i.tag==="Nothing")return{x:0,y:0};if(i.tag==="Just")return i._1;g()})(),s=o.length-1|0,u=ao(ao(e)(s)+s|0)(s),c=d=>{const h=ao(d+s|0)(s);return h>=0&&h<o.length?o[h]:a},_=V(d=>Dh(t)(c((u+d|0)-1|0))(c(u+d|0))(c((u+d|0)+1|0)))($t(0,s-1|0)),f=[],l=0<_.length?J("Just",_[0]):T;if(l.tag==="Just")if(wu(f)(l._1.outP)(),C3((()=>{const d=Pt(h=>T,h=>p=>J("Just",p),_);if(d.tag==="Nothing")return[];if(d.tag==="Just")return d._1;g()})())(d=>{const h=to(f)(d.inP);return()=>(h(),Tu(f)(d.curr)(d.outP)())})(),n)to(f)(l._1.inP)(),Tu(f)(l._1.curr)(l._1.outP)(),f.push(5);else{const d=_.length-1|0;d>=0&&d<_.length?to(f)((()=>{const h=1-r;return{x:_[d].outP.x+(l._1.inP.x-_[d].outP.x)*h,y:_[d].outP.y+(l._1.inP.y-_[d].outP.y)*h}})())():to(f)(l._1.inP)()}else l.tag==="Nothing"||g();return f},ta=t=>e=>n=>r=>{const o=b3(1)(r.length-1|0),i=Fe(0)(rt(o))(r_("shape")(e)),a=k3(o-1|0)(he(nr(i.value))),s=i.prng;return V(u=>{const c=Fe(0)(1)(r_(ae(u))(s)),_=Fe(-.18)(.3)(c.prng),f=c.value<.7,l=Fe(.5)(.85)(_.prng),d=G3(t.offset)(l.prng)(r);return{path:n?I3(t)(a)(f)(_.value)(d):zh(t)(d),alpha:l.value}})($t(0,t.passes-1|0))},F3=t=>e=>n=>ta(t)(e)(!0)([{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h},{x:n.x,y:n.y}]),D3=t=>e=>n=>{const r=Zr(0)(fi(1)(n)),o=e.h/rt(4),i=Zr(6)(o*1.4);return Tt(a=>a)(V(a=>{if(r<Zr(0)(rt(a)/rt(4)-.05))return T;const s=r_(ae(a))(t),u=Zr(0)(rt(a)/rt(4)-.05),c=ao(a)(2)===0,_=c?e.x-2:e.x+e.w+2,f=c?e.x+e.w+2:e.x-2,l=e.y+(rt(a)+.5)*o;return J("Just",{path:Ih(Zr(0)(fi(1)((r-u)/Zr(1e-4)(fi(1)(rt(a+1|0)/rt(4)+.05)-u))))((()=>{const d={rMax:2,offset:.6,passes:1},h=ee(v(m=>x=>{const y=Fe(-o*.08)(o*.08)(m.prng);return{prng:y.prng,out:[{x:_+(f-_)*(rt(x)/rt(4)),y:l+y.value},...m.out]}})({prng:s,out:[]})($t(0,4)).out),p=h.length<2?[]:ta(d)(s)(!1)(h);return 0<p.length?p[0].path:[]})()),width:i,alpha:1})})($t(0,3)))},y_=(t,e,n)=>({tag:t,_1:e,_2:n}),Xa=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),Bh=t=>t,Nu=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},sn=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),z3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},li=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},me=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},B3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},gr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},di=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},zr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},M3=Wt.foldMap(Z2),Ju=oo.traverse(ho),ea=v(hr)(0),Mh=fe(R)(Wt),Qh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Q3=Q1(R),W3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},x_=Bh("FullTokenGeometry"),H3=Bh("ConvexInsideGeometry"),hi=t=>{const e=t.Apply0();return n=>v(r=>o=>e.apply(e.Functor0().map(i=>k1)(r))(n(o)))(t.pure())},Xn=hi(ho),Wh=t=>e=>n=>r=>o=>i=>{const a={x:n.x+n.w/2,y:n.y+n.h/2},s={x:e.x+e.w/2,y:e.y+e.h/2},u=$a(o)(i)(r),c=0<t.length?J("Just",t[0]):T,_=(()=>{if(c.tag==="Just")return c._1;if(c.tag==="Nothing")return s;g()})(),f=t.length-1|0,l=f>=0&&f<t.length?J("Just",t[f]):T,d=(()=>{if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return a;g()})(),h=_.x-s.x,p=2*(()=>{const C=_.y-s.y;return(h<0?-h:h)+(C<0?-C:C)})(),m=d.x-a.x,x=2*(()=>{const C=d.y-a.y;return(m<0?-m:m)+(C<0?-C:C)})(),y=p+Ja(t)+x,w=y<=1e-4?1:1-x/y,N=y<=1e-4?0:p/y,b=w-N;return{progress:u,morphOutEnd:N,morphInStart:w,outT:(()=>{if(N<=1e-4)return 1;const C=u/N,L=C<0?0:C>1?1:C;return L*L*(3-2*L)})(),inT:(()=>{if(w>=1)return 0;const C=(u-w)/(1-w),L=C<0?0:C>1?1:C;return L*L*(3-2*L)})(),pathStart:_,pathEnd:d,travelPt:(()=>{const C=Ho(t)(Nu(0)(1)(b<=1e-4?0:(u-N)/b));if(C.tag==="Just")return C._1;if(C.tag==="Nothing")return _;g()})()}},Hh=t=>e=>n=>r=>o=>i=>{const a=Wh(t)(e)(n)(r)(o)(i),s=ah(128)(_i(4)(e))(Lh(a.pathStart)(6)),u=ah(128)(Lh(a.pathEnd)(6))(_i(4)(n)),c={maxDelay:.4,smoothPasses:2};return a.progress<a.morphOutEnd?si("PolyShape",uh(a.outT)(s.from)(s.to)(c)):a.progress>=a.morphInStart?si("PolyShape",uh(a.inT)(u.from)(u.to)(c)):si("CircleShape",a.travelPt,6)},T_=t=>e=>n=>r=>o=>i=>{const a=Hh(t)(e)(n)(r)(o)(i);if(a.tag==="PolyShape")return l_(a._1);if(a.tag==="CircleShape")return a._1;g()},O3=t=>{const e=n=>{const r=ne(o=>n.x>=o._2.x-1&&n.x<=o._2.x+o._2.w+1&&n.y>=o._2.y-1&&n.y<=o._2.y+o._2.h+1)(sn(t.nodes));return r.tag==="Just"?J("Just",r._1._2):T};return n=>{const r=(()=>{if(0<n.length){const i=e(n[0]);if(i.tag==="Just")return ee(Eh(_i(7)(i._1))(ee(n)))}return n})(),o=r.length-1|0;if(o>=0&&o<r.length){const i=e(r[o]);if(i.tag==="Just")return Eh(_i(7)(i._1))(r)}return r}},na=t=>({nodes:t.nodes,edges:(()=>{const e=O3(t),n=r=>{if(r.tag==="Leaf")return M;if(r.tag==="Node")return Zt("Node",r._1,r._2,r._3,e(r._4),n(r._5),n(r._6));g()};return n(t.edges)})()}),q3=t=>e=>{const n=((t.bg.r+t.bg.g|0)+t.bg.b|0)<384,r=n?90:104,o=n?165:122,i=a=>z3(255)(li(0)(he(Wn(o+r*Ye(e+a)))));return{r:i(0),g:i(-2.0943951023931953),b:i(-4.1887902047863905),a:255}},Oh=t=>e=>{if(t<=0)return[];const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return on(n._1.head.text).length<=t?[n._1.head,...Oh(t-on(n._1.head.text).length|0)(n._1.tail)]:[{...n._1.head,text:Ie(t)(n._1.head.text)}];g()},w_=(()=>{const t={r:24,g:24,b:27,a:255},e={r:244,g:244,b:245,a:255},n={r:248,g:249,b:246,a:255},r={r:26,g:26,b:26,a:255},o={r:28,g:101,b:192,a:255},i={r:247,g:248,b:250,a:255},a={r:42,g:48,b:60,a:255},s={r:120,g:130,b:146,a:255};return u=>{if(u==="Light")return{bg:{r:255,g:255,b:255,a:255},bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:211,b:209,a:255},shadowFill:{r:255,g:255,b:255,a:255},shadowDot:{r:26,g:26,b:26,a:255},chip:{r:255,g:235,b:130,a:255},chipShadow:{r:214,g:211,b:209,a:255},chipText:jr,nodeFill:Ne,nodeStroke:jr,text:jr,edge:jr,arrowFill:jr,tokenOutsideFill:jr,tokenOutsideStroke:Ne,tokenInside:Ne,tokenInsideStroke:Ne,tokenInsideBlend:gu,tokenInsideAlpha:1,chipPillFill:jr,chipPillText:Ne,chipHairline:{r:26,g:26,b:26,a:90},trailDot:jr,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Dark")return{bg:t,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:63,g:63,b:70,a:255},shadowFill:t,shadowDot:e,chip:{r:234,g:179,b:8,a:255},chipShadow:{r:0,g:0,b:0,a:120},chipText:t,nodeFill:jr,nodeStroke:e,text:e,edge:e,arrowFill:e,tokenOutsideFill:Ne,tokenOutsideStroke:Ne,tokenInside:Ne,tokenInsideStroke:Ne,tokenInsideBlend:gu,tokenInsideAlpha:1,chipPillFill:e,chipPillText:t,chipHairline:{r:244,g:244,b:245,a:120},trailDot:e,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Blueprint")return{bg:o,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:90,g:160,b:230,a:255},shadowFill:o,shadowDot:Ne,chip:Ne,chipShadow:{r:0,g:0,b:0,a:120},chipText:o,nodeFill:o,nodeStroke:Ne,text:Ne,edge:Ne,arrowFill:Ne,tokenOutsideFill:Ne,tokenOutsideStroke:Ne,tokenInside:Ne,tokenInsideStroke:Ne,tokenInsideBlend:Wd,tokenInsideAlpha:.35,chipPillFill:Ne,chipPillText:o,chipHairline:{r:255,g:255,b:255,a:120},trailDot:Ne,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Whiteboard")return{bg:n,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:0,g:0,b:0,a:0},shadowFill:n,shadowDot:r,chip:{r:217,g:74,b:56,a:255},chipShadow:{r:26,g:26,b:26,a:60},chipText:n,nodeFill:n,nodeStroke:r,text:r,edge:r,arrowFill:r,tokenOutsideFill:r,tokenOutsideStroke:n,tokenInside:n,tokenInsideStroke:n,tokenInsideBlend:Wd,tokenInsideAlpha:1,chipPillFill:r,chipPillText:n,chipHairline:{r:26,g:26,b:26,a:90},trailDot:r,wobble:!0,fontFamily:"Supermarker, Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Isometric")return{bg:i,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:218,b:224,a:255},shadowFill:i,shadowDot:a,chip:{r:255,g:235,b:130,a:255},chipShadow:{r:100,g:110,b:125,a:90},chipText:a,nodeFill:{r:236,g:239,b:244,a:255},nodeStroke:a,text:a,edge:s,arrowFill:s,tokenOutsideFill:a,tokenOutsideStroke:Ne,tokenInside:Ne,tokenInsideStroke:Ne,tokenInsideBlend:gu,tokenInsideAlpha:1,chipPillFill:a,chipPillText:Ne,chipHairline:{r:60,g:66,b:78,a:90},trailDot:a,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};g()}})(),N_=t=>e=>Et(sn(t))(n=>{const r=me(n._1)(e.nodes);return r.tag==="Just"&&oi(r._1).alpha>0?xo(n._2):[]}),V3=t=>e=>n=>[1,t.vx,t.vy,2,t.vx+t.vw,t.vy,2,t.vx+t.vw,t.vy+t.vh,2,t.vx,t.vy+t.vh,5,...N_(e)(n)],$3=t=>e=>n=>{const r=(o,i)=>he(Wn(rt(o)+(rt(i)-rt(o))*n));return{r:r(t.r,e.r),g:r(t.g,e.g),b:r(t.b,e.b),a:r(t.a,e.a)}},U3=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=oo.traverse(r);return i=>a=>{const s=Hn(a),u=.32*i.size;return o(c=>n.bind(c===0?r.pure(0):t.measureText(i)(Ie(c)(a)))(_=>n.bind(t.measureText(i)(Ie(c+1|0)(a)))(f=>n.bind(t.measureInk(i)(c>=0&&c<s.length?En(s[c]):" "))(l=>r.pure({x:_,w:f-_,up:l.ascent-u,down:l.descent+u})))))($t(0,s.length-1|0))}},qh=t=>[...xo({...t,x:t.x-1.25,y:t.y-1.25,w:t.w+2.5,h:t.h+2.5}),...xo({...t,y:t.y-5})],X3=t=>e=>{const n=o=>(o.x-e.x)*(o.x-e.x)+(o.y-e.y)*(o.y-e.y),r=v(o=>i=>n(i)<n(o)?i:o)({x:t.x,y:t.y})([{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x,y:t.y+t.h},{x:t.x+t.w,y:t.y+t.h}]);return V(o=>{const i=rt(o)/5;return{x:r.x+(e.x-r.x)*i,y:r.y+(e.y-r.y)*i}})([1,2,3,4])},Ya=t=>e=>n=>{const r=B3(ae(e)+":"+ae(n))(t);if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()},Y3=t=>e=>{const n=e.length;return v(r=>o=>v(i=>a=>it(R)(ae(o)+":"+ae(a))(a>=0&&a<e.length&&o>=0&&o<t.length?t[o]===e[a]?1+Ya(i)(o+1|0)(a+1|0)|0:li(Ya(i)(o+1|0)(a))(Ya(i)(o)(a+1|0)):0)(i))(r)(n<=0?[]:ee($t(0,n-1|0))))(M)((()=>{const r=t.length;return r<=0?[]:ee($t(0,r-1|0))})())},J_=t=>An(t),K3=t=>e=>n=>{const r=e*n;return Nu(0)(1)(r/t)},j3=t=>e=>n=>r=>o=>i=>{const a=Wh(t)(e)(n)(r)(o)(i);return a.progress<a.morphOutEnd?y_("InsideRect",__(2)(e)):a.progress>=a.morphInStart?y_("InsideRect",__(2)(n)):y_("InsideBall",a.travelPt,6)},v_=t=>e=>n=>r=>o=>i=>a=>s=>{const u=(c,_)=>Jh({id:c,pass:t,geometry:fh("FlatToken",_),position:(()=>{if(_.tag==="CircleShape")return _._1;if(_.tag==="PolyShape")return l_(_._1);g()})(),plan:dh("FlatTokenPlan",{wobble:n,fill:a,stroke:s})});return Xn(c=>{if(c._2.tag==="Travelling"){const _=me(c._2._1.target)(r),f=me(c._2._1.source)(r);if(f.tag==="Just"&&_.tag==="Just"){const l=zr(c._2._1.edge)(o);if(l.tag==="Just"){const d=(()=>{if(c._2._1.direction==="Forward")return l._1;if(c._2._1.direction==="Backward")return ee(l._1);g()})();return u(c._1,(()=>{if(e==="FullTokenGeometry")return Hh(d)(f._1)(_._1)(c._2._1.progress)(c._2._1.holdPre)(c._2._1.holdPost);if(e==="ConvexInsideGeometry"){const h=j3(d)(f._1)(_._1)(c._2._1.progress)(c._2._1.holdPre)(c._2._1.holdPost);if(h.tag==="InsideRect")return si("PolyShape",d_(4)(h._1));if(h.tag==="InsideBall")return si("CircleShape",h._1,h._2)}g()})())}if(l.tag==="Nothing"){const d=$a(c._2._1.holdPre)(c._2._1.holdPost)(c._2._1.progress),h={x:f._1.x+f._1.w/2,y:f._1.y+f._1.h/2},p={x:_._1.x+_._1.w/2,y:_._1.y+_._1.h/2};return ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",(()=>{if(d<.5){const x=d*2;return 1-gr(0)(di(1)(x))*gr(0)(di(1)(x))*(3-2*gr(0)(di(1)(x)))}const m=(d-.5)*2;return gr(0)(di(1)(m))*gr(0)(di(1)(m))*(3-2*gr(0)(di(1)(m)))})())]})(u(c._1,si("CircleShape",d<.5?h:p,6)))}g()}return K(st("Return",void 0),ct)}if(c._2.tag==="Filling"){if(n)return K(st("Return",void 0),ct);const _=me(c._2._1.node)(r);if(_.tag==="Just")return u(c._1,si("PolyShape",_i(4)(e==="ConvexInsideGeometry"?__(2)(_._1):_._1)));if(_.tag==="Nothing")return K(st("Return",void 0),ct);g()}return K(st("Return",void 0),ct)})(sn(i.tokens))},Z3=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0();return o=>n.bind((()=>{const i=r.pure();if(o.clear.tag==="Nothing")return i;if(o.clear.tag==="Just")return t.clearBackground(o.clear._1);g()})())(()=>n.bind(t.setViewport(o.viewport))(()=>{const i=r.pure();if(o.dots.tag==="Nothing")return i;if(o.dots.tag==="Just")return t.backgroundDots(o.dots._1);g()}))},Vh=t=>e=>n=>r=>ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",n.fadeAlpha),pe("GroupTransform",ui,{tx:t.x*(1-n.popScale),ty:(t.y+t.h)*(1-n.popScale),sx:n.popScale,sy:n.popScale}),pe("GroupTransform",ui,{tx:0,ty:e.y*(1-n.flipY),sx:1,sy:n.flipY})]})(gi(r)),tk=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=_=>f=>{const l=Pt(d=>T,d=>h=>J("Just",{head:d,tail:h}),f);if(l.tag==="Nothing")return K(st("Return",void 0),ct);if(l.tag==="Just"){const d=l._1,h=ti(i)(En(d.head)),p=m=>{const x=gi({owner:yo("NodeText",o),text:En(d.head),spec:{x:_,y:s-n*i.size*.11*Ye(e*5-_*.22),content:En(d.head),font:i,color:$3(r.text)(q3(r)(e*2.2+_*.16))(n),align:po,baseline:Un},bounds:T,plan:t});return K(x._1,(()=>{if(x._2.tag==="CatNil")return et("CatCons",()=>c(_+m)(d.tail),tt(D,D));if(x._2.tag==="CatCons")return et("CatCons",x._2._1,tt(x._2._2._1,yt("Cons",et("CatCons",()=>c(_+m)(d.tail),tt(D,D)),x._2._2._2)));g()})())};return K(h._1,(()=>{if(h._2.tag==="CatNil")return et("CatCons",p,tt(D,D));if(h._2.tag==="CatCons")return et("CatCons",h._2._1,tt(h._2._2._1,yt("Cons",et("CatCons",p,tt(D,D)),h._2._2._2)));g()})())}g()};return c(a)(Hn(u))},$h=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>a==="RunHighlight"||a==="RunCodeHighlight"?tk(t)(e)(n)(r)(o)(i)(s)(u)(c):gi({owner:yo("NodeText",o),text:c,spec:{x:s,y:u,content:c,font:i,color:r.text,align:po,baseline:Un},bounds:T,plan:t}),ek=t=>e=>n=>r=>o=>i=>a=>Vh(o)(i)(a)({owner:yo("TokenText",t),text:n,spec:{x:i.x,y:i.y,content:n,font:{family:e.fontFamily,size:11,weight:500},color:e.chipText,align:ei,baseline:Un},bounds:J("Just",o),plan:ai("TokenFillingText",{shadow:{...o,y:o.y+1.5},shadowFill:{color:e.chipShadow,flat:!0},radius:6,fill:{color:e.chip,flat:!0},stroke:{color:e.chipHairline,width:1,lineJoin:Ze,lineCap:In},leader:[1,i.x,o.y+o.h,2,r.x+r.w/2,r.y]})}),nk={offset:.8,passes:2,rMax:5},C_=t=>e=>n=>r=>{const o=na(n);return ke({path:[],role:an,layer:J("Just",eb),effects:[pe("GroupClip",V3(e)(o.nodes)(r),e_)]})(v_(ph)(x_)(t.wobble)(o.nodes)(o.edges)(r)(t.tokenOutsideFill)(t.tokenOutsideStroke))},Uh=t=>e=>n=>r=>{if(e.tokenInsideBlend==="Difference"){const o=na(n),i=t3(t),a=s=>{const u=ke({path:[],role:an,layer:J("Just",nb),effects:[pe("GroupBlend",gu),pe("GroupClip",N_(o.nodes)(r),mo)]})(v_(mh)(s==="ConvexAbsorb"?H3:x_)(e.wobble)(o.nodes)(o.edges)(r)(e.tokenInside)(e.tokenInsideStroke)),c=()=>ke({path:[],role:an,layer:J("Just",rb),effects:[]})(Xn(_=>{const f=me(_._1)(r.nodes);return f.tag==="Just"&&oi(f._1).alpha>0?ci(ii({path:xo(_._2),fill:J("Just",{color:Ne,flat:!1}),stroke:T})):K(st("Return",void 0),ct)})(sn(o.nodes)));return K(u._1,(()=>{if(u._2.tag==="CatNil")return et("CatCons",c,tt(D,D));if(u._2.tag==="CatCons")return et("CatCons",u._2._1,tt(u._2._2._1,yt("Cons",et("CatCons",c,tt(D,D)),u._2._2._2)));g()})())};return K(i._1,(()=>{if(i._2.tag==="CatNil")return et("CatCons",a,tt(D,D));if(i._2.tag==="CatCons")return et("CatCons",i._2._1,tt(i._2._2._1,yt("Cons",et("CatCons",a,tt(D,D)),i._2._2._2)));g()})())}if(e.tokenInsideBlend==="Normal"){const o=na(n);return ke({path:[],role:an,layer:T,effects:[pe("GroupClip",N_(o.nodes)(r),mo),pe("GroupAlpha",e.tokenInsideAlpha)]})(v_(mh)(x_)(e.wobble)(o.nodes)(o.edges)(r)(e.tokenInside)(e.tokenInsideStroke))}g()},Xh=t=>e=>n=>r=>t.strokePath((()=>{const o=Pt(i=>T,i=>a=>J("Just",{head:i,tail:a}),V(i=>i.pt)(R2(i=>a=>{const s=rt(a)/rt(72),u=Fe(-.18)(.18)(i.prng),c=Fe(-.1)(.1)(u.prng),_=Fe(-.07)(.07)(c.prng),f=n*(.05+.55*s)*(1+c.value),l=s*28.274333882308138+u.value;return{prng:_.prng,pt:{x:e.x+_n(l)*f+_.value*n,y:e.y+Ye(l)*f+_.value*n}}},{prng:137,pt:{x:e.x,y:e.y}},$t(0,72))));if(o.tag==="Just")return[1,o._1.head.x,o._1.head.y,...M3(i=>[2,i.x,i.y])(o._1.tail)];if(o.tag==="Nothing")return[];g()})())({color:r,width:5.5,lineJoin:Ze,lineCap:Ir}),rk=t=>{const e=t.Monad0().Applicative0();return n=>{if(n.geometry.tag==="FlatToken"&&n.plan.tag==="FlatTokenPlan"){if(n.geometry._1.tag==="CircleShape")return n.plan._1.wobble?Xh(t)(n.geometry._1._1)(n.geometry._1._2)({r:200,g:35,b:30,a:220}):t.fillStrokePath(Sh(n.geometry._1._1)(n.geometry._1._2))({color:n.plan._1.fill,flat:!0})({color:n.plan._1.stroke,width:1,lineJoin:Ze,lineCap:In});if(n.geometry._1.tag==="PolyShape")return n.plan._1.wobble&&n.geometry._1._1.length>=3?Xh(t)(l_(n.geometry._1._1))(6)({r:200,g:35,b:30,a:220}):n.geometry._1._1.length>=3?t.fillStrokePath(bh(n.geometry._1._1))({color:n.plan._1.fill,flat:!0})({color:n.plan._1.stroke,width:1,lineJoin:Ze,lineCap:In}):e.pure();g()}return e.pure()}},ok=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=t.popClip,i=t.popTransform,a=t.popAlpha;return s=>u=>c=>_=>f=>{const l=oi(f),d=c*l.alpha,h={..._,y:_.y+5},p=_.x+_.w/2,m=_.y+_.h/2,x=qh(h),y=r.bind(t.pushAlpha(d))(()=>r.bind(t.pushTransform({tx:p*(1-l.scale),ty:m*(1-l.scale),sx:l.scale,sy:l.scale}))(()=>r.bind(t.pushClip(x)(e_))(()=>r.bind(ri(t)(h.shape)({x:h.x,y:h.y,w:h.w,h:h.h})(7)(J("Just",{color:s.shadowFill,flat:!0}))(T))(()=>r.bind((()=>{const w=r.bind(t.pushClip(xo(h))(mo))(()=>r.bind(t.backgroundDots({viewport:{vx:h.x,vy:h.y,vw:h.w,vh:h.h},bgColor:s.bgTransparent,dotColor:s.shadowDot,tile:1.6,dotRadius:.25,origin:{x:0,y:0}}))(()=>o));return u&&!s.wobble?w:n.pure()})())(()=>r.bind(ri(t)(h.shape)({x:h.x,y:h.y,w:h.w,h:h.h})(7)(T)(J("Just",{color:s.nodeStroke,width:1.25,lineJoin:Ze,lineCap:In})))(()=>r.bind(o)(()=>r.bind(i)(()=>a))))))));return d>0&&!s.wobble?y:n.pure()}},ik=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,o=hi(e.Applicative0());return i=>a=>s=>o(u=>n.bind(t.pushAlpha(u.alpha))(()=>n.bind(t.strokePath(u.path)({color:i.nodeFill,width:u.width,lineJoin:Ze,lineCap:Ir}))(()=>r)))(D3(Ah(a)+7777|0)(a)(s))},ak=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,o=e.Applicative0(),i=hi(o),a=t.popClip,s=hi(o),u=oo.traverse(o),c=U3(t),_=ik(t),f=t.popTransform;return l=>d=>h=>p=>m=>x=>y=>w=>N=>b=>{const C=B=>n.bind(t.pushAlpha(B.alpha))(()=>n.bind(t.strokePath(B.path)({color:h.nodeStroke,width:2,lineJoin:Ze,lineCap:Ir}))(()=>r)),L={family:h.fontFamily,size:h.wobble?15:11,weight:h.wobble?800:500},E=An(N.label===""?w:N.label),I=L.size*1.2,W=N.shape==="Cylinder"?t.strokePath(hb({x:N.x,y:N.y,w:N.w,h:N.h}))({color:h.nodeStroke,width:1.25,lineJoin:Ze,lineCap:In}):o.pure(),P=(N.shape==="Cylinder"?(N.y+(N.y+N.h+5-2*vn(N.h*.075)(N.w*.075)))/2:(N.y+N.y+N.h)/2)-rt(E.length)*I/2+I/2,G=b.tag==="PloppingOut"&&h.wobble?b._1:-1,j=G>=0,nt=oi(b),O=j?{alpha:1,scale:1}:nt,$=N.x+N.w/2,H=N.y+N.h/2,A=n.bind(t.pushAlpha(O.alpha))(()=>n.bind(t.pushTransform({tx:$*(1-O.scale),ty:H*(1-O.scale),sx:O.scale,sy:O.scale}))(()=>{const B={x:N.x,y:N.y,w:N.w,h:N.h},z={color:h.nodeStroke,width:h.wobble?2:1.25*d,lineJoin:Ze,lineCap:h.wobble?Ir:In},Q=(()=>{if(h.wobble){if(N.shape==="Rectangle")return i(C)(F3(Fh)(Ah(B))(B));const F=_i(7)(N);return n.bind(i(C)((()=>{const X=Ua(F);return F.length<4?[]:ta(Rh)(X)(!0)(F)})()))(()=>s(X=>i(C)((()=>{const q=Ua(X);return X.length<2?[]:ta(Rh)(q)(!1)(X)})()))(N.shape==="Cylinder"?[f3(N)]:[]))}return n.bind(ri(t)(N.shape)(B)(7)(T)(J("Just",z)))(()=>W)})();return n.bind((()=>{if(m.tag==="Nothing")return n.bind(t.pushAlpha(p))(()=>n.bind(h.wobble?Q:n.bind(ri(t)(N.shape)(B)(7)(J("Just",{color:h.nodeFill,flat:!1}))(J("Just",z)))(()=>W))(()=>n.bind((()=>{if(y.tag==="Just"&&h.wobble&&!j){const F=y._1;return n.bind(u(c(L))(E))(X=>{const q=Gt(ht=>Ct=>at.compare(ht.x)(Ct.x)),U=he(nr(N.x*7919+N.y*3001))*-1640531535|0,Y=Fe(5)(7.5)(U),ot=Fe(0)(Y.value)(Y.prng),Z=-(1+2*Fe(-1)(1)(ot.prng).value*3.141592653589793/180),ft=(ht,Ct,Qt,zt,ie)=>q(Tt(_e=>_e)([Z*Ct+ht>=zt&&Z*Ct+ht<=ie?J("Just",{x:Ct,y:Z*Ct+ht}):T,Z*Qt+ht>=zt&&Z*Qt+ht<=ie?J("Just",{x:Qt,y:Z*Qt+ht}):T,(()=>{const _e=(zt-ht)/Z;return _e>=Ct&&_e<=Qt?J("Just",{x:_e,y:zt}):T})(),(()=>{const _e=(ie-ht)/Z;return _e>=Ct&&_e<=Qt?J("Just",{x:_e,y:ie}):T})()])),Lt=Y.value,dt=ao(F.frameHash)(3),Nt=dt===0?{r:200,g:35,b:30,a:220}:dt===1?{r:35,g:150,b:80,a:220}:{r:30,g:80,b:200,a:220},St=N.x+N.w/2,te=Tn(Ht(ht=>Ct=>Ht((()=>{const Qt=P+rt(ht)*I,zt=St-v(ie=>_e=>ie+_e.w)(0)(Ct)/2;return ie=>_e=>{const cn=L.size*.1,qt=ie-1|0,jt=qt>=0&&qt<Ct.length&&ie>0?(Ct[qt].x+Ct[qt].w+_e.x)/2:_e.x-cn;return{x:zt+jt-1,y:Qt-_e.up-1,w:gr(0)((()=>{const en=ie+1|0;return en>=0&&en<Ct.length&&ie<(Ct.length-1|0)?(_e.x+_e.w+Ct[en].x)/2-jt:_e.x+_e.w+cn-jt})())+2,h:_e.up+_e.down+2}}})())(Ct))(X)),Jt=N.y+4,Yt=N.x+N.w-4,Ft=N.x+4,vt=Jt-Z*Ft+ot.value,mt=N.y+N.h-4,lt=Et(Et(Ht(ht=>Ct=>{const Qt=(Ct.from.x+Ct.to.x)/2,zt=(Ct.from.y+Ct.to.y)/2,ie=Fe(-1)(1)(U+(911*(ht+1|0)|0)|0),_e=Fe(-3)(5)(ie.prng),cn=ie.value*3.141592653589793/180,qt=_n(cn),jt=Ye(cn),en=He=>({x:Qt+(He.x-Qt)*qt-(He.y-zt)*jt,y:zt+(He.x-Qt)*jt+(He.y-zt)*qt});return{from:(()=>{const He=en(Ct.from),Bn=He.y-zt,Mn=He.x-Qt,Ue=Ke(Mn*Mn+Bn*Bn),se=Ue<1e-4?1:(Ue+_e.value)/Ue;return{x:Qt+Mn*se,y:zt+Bn*se}})(),to:(()=>{const He=en(Ct.to),Bn=Fe(-3)(5)(_e.prng).value,Mn=He.y-zt,Ue=He.x-Qt,se=Ke(Ue*Ue+Mn*Mn),Je=se<1e-4?1:(se+Bn)/se;return{x:Qt+Ue*Je,y:zt+Mn*Je}})()}})(Tt(ht=>{const Ct=ft(vt+rt(ht)*Lt,Ft,Yt,Jt,mt);return Ct.length===2?J("Just",{from:Ct[0],to:Ct[1]}):T})($t(0,li(1)(he(nr((mt-Z*Yt-vt)/Lt)))))))(ht=>gt(Ct=>Ct.to.x-Ct.from.x>1,v(Ct=>Qt=>Et(Ct)(zt=>{const ie=ft(zt.from.y-Z*zt.from.x,Qt.x,Qt.x+Qt.w,Qt.y,Qt.y+Qt.h);return ie.length===2?ie[0].x>zt.from.x+.001&&ie[1].x<zt.to.x-.001?[{from:zt.from,to:ie[0]},{from:ie[1],to:zt.to}]:ie[0].x<=zt.from.x+.001&&ie[1].x<zt.to.x-.001?[{from:ie[1],to:zt.to}]:ie[0].x>zt.from.x+.001&&ie[1].x>=zt.to.x-.001?[{from:zt.from,to:ie[0]}]:[]:[zt]}))([ht])(te))))(ht=>(()=>{const Ct=ht.to.x-ht.from.x;return Ke(2)*(Ct>=0?Ct:-Ct)<=28})()?[ht]:[{from:ht.from,to:{x:ht.from.x+(ht.to.x-ht.from.x)*.495,y:ht.from.y+(ht.to.y-ht.from.y)*.495}},{from:{x:ht.from.x+(ht.to.x-ht.from.x)*.505,y:ht.from.y+(ht.to.y-ht.from.y)*.505},to:ht.to}]),xt=lt.length,It=ht=>gr(0)(di(1)(F.t*rt(xt)-rt(ht)));return n.bind(t.pushClip(bh(_i(7)(N)))(mo))(()=>n.bind(i(ht=>{const Ct=ht._1,Qt=Fe(1.4)(1.9)(U+(1303*(Ct+1|0)|0)|0),zt=Fe(.35)(.8)(Qt.prng),ie=i(_e=>n.bind(t.pushAlpha(_e.alpha*zt.value))(()=>n.bind(t.strokePath(Ih(It(Ct))(_e.path))({color:Nt,width:Qt.value,lineJoin:Ze,lineCap:Ir}))(()=>r)))(ta({...Fh,rMax:0,offset:.5})(U+(53*(Ct+1|0)|0)|0)(!1)([ht._2.from,ht._2.to]));return It(Ct)>0?ie:o.pure()})(Ht(Ln)(lt)))(()=>a))})}return o.pure()})())(()=>n.bind((()=>{if(l==="LabelsShown"){const F=n.bind(t.pushAlpha(x))(()=>n.bind(i(X=>t.drawText({x:N.x+N.w/2,y:P+rt(X._1)*I,content:X._2,font:L,color:h.text,align:ei,baseline:Un}))(Ht(Ln)(E)))(()=>r));return x>0?F:o.pure()}if(l==="LabelsHidden")return o.pure();g()})())(()=>n.bind((()=>{const F=_(h)(B)(G);return j?F:o.pure()})())(()=>r)))));if(m.tag==="Just"){const F=m._1;return n.bind((()=>{const X=n.bind(t.pushAlpha(p))(()=>n.bind(ri(t)(N.shape)(B)(7)(J("Just",{color:h.nodeFill,flat:!1}))(T))(()=>r));return p>0&&!h.wobble?X:o.pure()})())(()=>{const X=n.bind(t.pushAlpha(F))(()=>n.bind(Q)(()=>r));return F>0?X:o.pure()})}g()})())(()=>n.bind(f)(()=>r))}));return O.alpha*gr(p)((()=>{if(m.tag==="Nothing")return p;if(m.tag==="Just")return m._1;g()})())>0?A:o.pure()}},Yh=t=>e=>n=>Xn((()=>{const r=na(e).edges;return o=>{const i=zr(o._1)(n.edges);if(i.tag==="Just"){const a=zr(o._1)(n.edgeFadeAlpha),s=(()=>{if(a.tag==="Nothing")return 1;if(a.tag==="Just")return a._1;g()})(),u=Nh({id:o._1,geometry:ch("FlatRoute",(()=>{const c=zr(o._1)(r);if(c.tag==="Nothing")return o._2;if(c.tag==="Just")return c._1;g()})()),visible:zb(i._1),arrow:(()=>{const c=rr("conn:")(o._1);if(c.tag==="Just")return!1;if(c.tag==="Nothing")return!0;g()})(),settlingAtTarget:i._1.tag==="Extending"&&i._1._1==="ExtendFromSource",plan:gh("FlatEdgePlan",t)});return s===1?u:ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",s)]})(u)}if(i.tag==="Nothing")return K(st("Return",void 0),ct);g()}})())(sn(e.edges)),sk=t=>e=>n=>{const r={family:t.fontFamily,size:11,weight:500};return Xn(o=>{if(o._2===""||(()=>{const s=zr(o._1)(n.edges);return s.tag==="Nothing"||!(s.tag==="Just"&&uT.eq(s._1)(Rf))})())return K(st("Return",void 0),ct);const i=zr(o._1)(e.edges),a=(()=>{if(i.tag==="Just")return Ho(i._1)(.5);if(i.tag==="Nothing")return T;g()})();if(a.tag==="Nothing")return K(st("Return",void 0),ct);if(a.tag==="Just"){const s=a._1,u=ti(r)(o._2),c=_=>{const f=_+12;return gi({owner:yo("EdgeText",o._1),text:o._2,spec:{x:s.x,y:s.y,content:o._2,font:r,color:t.chipPillText,align:ei,baseline:Un},bounds:J("Just",{x:s.x-f/2,y:s.y-8.5,w:f,h:17}),plan:ai("RoundedText",{radius:3,fill:J("Just",{color:t.chipPillFill,flat:!0}),stroke:T})})};return K(u._1,(()=>{if(u._2.tag==="CatNil")return et("CatCons",c,tt(D,D));if(u._2.tag==="CatCons")return et("CatCons",u._2._1,tt(u._2._2._1,yt("Cons",et("CatCons",c,tt(D,D)),u._2._2._2)));g()})())}g()})(sn(e.edgeLabels))},uk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=t.popClip,i=t.popTransform,a=t.popAlpha;return s=>u=>c=>_=>f=>{const l=oi(f),d=c*l.alpha,h=_.x+_.w/2,p=_.y-5+_.h/2,m=qh(_),x=r.bind(t.pushAlpha(d))(()=>r.bind(t.pushTransform({tx:h*(1-l.scale),ty:p*(1-l.scale),sx:l.scale,sy:l.scale}))(()=>r.bind(t.pushClip(m)(e_))(()=>r.bind(ri(t)(_.shape)({x:_.x,y:_.y,w:_.w,h:_.h})(7)(J("Just",{color:s.shadowFill,flat:!0}))(T))(()=>r.bind((()=>{const y=r.bind(t.pushClip(xo(_))(mo))(()=>r.bind(t.backgroundDots({viewport:{vx:_.x,vy:_.y,vw:_.w,vh:_.h},bgColor:s.bgTransparent,dotColor:s.shadowDot,tile:1.6,dotRadius:.25,origin:{x:0,y:0}}))(()=>o));return u?y:n.pure()})())(()=>r.bind(ri(t)(_.shape)({x:_.x,y:_.y,w:_.w,h:_.h})(7)(T)(J("Just",{color:s.nodeStroke,width:1.25,lineJoin:Ze,lineCap:In})))(()=>r.bind(o)(()=>r.bind(i)(()=>a))))))));return d>0&&!s.wobble?x:n.pure()}},ck=t=>{const e=ok(t),n=uk(t),r=ak(t);return o=>{if(o.geometry.tag==="FlatNode"&&o.plan.tag==="FlatNodePlan"){const i={x:o.geometry._1.bounds.x,y:o.geometry._1.bounds.y,w:o.geometry._1.bounds.w,h:o.geometry._1.bounds.h,label:o.plan._1.label,shape:o.geometry._1.shape};if(o.role==="NodeShadow")return e(o.plan._1.palette)(o.plan._1.inkBoost>0)(o.alpha)(i)(o.plan._1.animState);if(o.role==="NodeDoorwayFrame")return n(o.plan._1.palette)(o.plan._1.inkBoost>0)(o.alpha)(i)(o.plan._1.animState);if(o.role==="NodeBody"||o.role==="NodeInversion")return r(pu)(o.plan._1.inkBoost)(o.plan._1.palette)(o.alpha)(o.plan._1.outlineAlpha)(0)(o.plan._1.arrival)(o.id)(i)(o.plan._1.animState);g()}return t.Monad0().Applicative0().pure()}},gk=t=>e=>{const n=Hn(t),r=n.length,o=Hn(e),i=o.length,a=Y3(n)(o);return(s=>u=>c=>{let _=s,f=u,l=c,d=!0,h;for(;d;){const p=_,m=f,x=l;if(p>=r&&m>=i){d=!1,h=ee(x);continue}if(p>=r){if(m>=0&&m<o.length){_=p,f=m+1|0,l=[Xa("DiffInsert",m,o[m]),...x];continue}d=!1,h=ee(x);continue}if(m>=i){if(p>=0&&p<n.length){_=p+1|0,f=m,l=[Xa("DiffDelete",p,n[p]),...x];continue}d=!1,h=ee(x);continue}if(m>=0&&m<o.length){if(p>=0&&p<n.length){if(n[p]===o[m]){_=p+1|0,f=m+1|0,l=[Xa("DiffKeep",p,m,n[p]),...x];continue}if(Ya(a)(p+1|0)(m)>=Ya(a)(p)(m+1|0)){_=p+1|0,f=m,l=[Xa("DiffDelete",p,n[p]),...x];continue}_=p,f=m+1|0,l=[Xa("DiffInsert",m,o[m]),...x];continue}d=!1,h=ee(x);continue}d=!1,h=ee(x)}return h})(0)(0)([])},Kh=t=>e=>n=>r=>o=>Xn(i=>{if(t.tag==="Just"&&i._1===t._1)return K(st("Return",void 0),ct);const a=me(i._1)(o.nodes);if(a.tag==="Just"){const s=me(i._1)(o.nodeLabels),u=(()=>{if(s.tag==="Nothing")return i._2;if(s.tag==="Just"){if(s._1.tag==="StaticNodeLabel")return{...i._2,label:s._1._1===""?i._1:s._1._1};if(s._1.tag==="RelabelingNode")return{...i._2,label:(()=>{const c=s._1._1.progress<.5?s._1._1.oldLabel:s._1._1.newLabel;return c===""?i._1:c})()}}g()})();return mu({id:i._1,role:Yb,geometry:lu("FlatNode",{shape:u.shape,bounds:{x:u.x,y:u.y,w:u.w,h:u.h}}),alpha:(()=>{const c=me(i._1)(o.nodeFadeAlpha),_=(()=>{if(c.tag==="Nothing")return 1;if(c.tag==="Just")return c._1;g()})();return _<1?0:_})(),plan:du("FlatNodePlan",{palette:e,label:(()=>{const c=me(i._1)(o.nodeLabels);if(c.tag==="Just"){if(c._1.tag==="StaticNodeLabel")return c._1._1===""?i._1:c._1._1;if(c._1.tag==="RelabelingNode"){const _=c._1._1.progress<.5?c._1._1.oldLabel:c._1._1.newLabel;return _===""?i._1:_}g()}if(c.tag==="Nothing")return u.label===""?i._1:u.label;g()})(),labelVisibility:pu,inkBoost:n?1:0,labelAlpha:0,outlineAlpha:T,arrival:T,animState:a._1})})}if(a.tag==="Nothing")return K(st("Return",void 0),ct);g()})(sn(r.nodes)),b_=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=sr(u),_=l=>d=>h=>{const p=Pt(x=>T,x=>y=>J("Just",{head:x,tail:y}),h),m=Pt(x=>T,x=>y=>J("Just",{head:x,tail:y}),d);if(m.tag==="Just"&&p.tag==="Just"){const x=$h(t)(e)(n)(r)(o)(m._1.head.style==="RunCode"||m._1.head.style==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(m._1.head.style)(l)(s)(m._1.head.text);return K(x._1,(()=>{if(x._2.tag==="CatNil")return et("CatCons",()=>_(l+p._1.head)(m._1.tail)(p._1.tail),tt(D,D));if(x._2.tag==="CatCons")return et("CatCons",x._2._1,tt(x._2._2._1,yt("Cons",et("CatCons",()=>_(l+p._1.head)(m._1.tail)(p._1.tail),tt(D,D)),x._2._2._2)));g()})())}return K(st("Return",void 0),ct)};if(c.length===1&&c[0].style==="RunText")return gi({owner:yo("NodeText",o),text:c[0].text,spec:{x:a,y:s,content:c[0].text,font:i,color:r.text,align:ei,baseline:Un},bounds:T,plan:t});const f=Ju(l=>ti(l.style==="RunCode"||l.style==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(l.text))(c);return K(f._1,(()=>{if(f._2.tag==="CatNil")return et("CatCons",l=>_(a-ea(l)/2)(c)(l),tt(D,D));if(f._2.tag==="CatCons")return et("CatCons",f._2._1,tt(f._2._2._1,yt("Cons",et("CatCons",l=>_(a-ea(l)/2)(c)(l),tt(D,D)),f._2._2._2)));g()})())},_k=t=>e=>{const n=Ju(r=>ti(r.style==="RunCode"||r.style==="RunCodeHighlight"?{...t,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:t)(r.text))(sr(e));return K(n._1,(()=>{if(n._2.tag==="CatNil")return et("CatCons",r=>K(st("Return",ea(r)),ct),tt(D,D));if(n._2.tag==="CatCons")return et("CatCons",n._2._1,tt(n._2._2._1,yt("Cons",et("CatCons",r=>K(st("Return",ea(r)),ct),tt(D,D)),n._2._2._2)));g()})())},jh=t=>e=>n=>r=>{const o=An(r===""?t:r),i=n.size*1.2,a=(e.shape==="Cylinder"?(e.y+(e.y+e.h+5-2*vn(e.h*.075)(e.w*.075)))/2:(e.y+e.y+e.h)/2)-rt(o.length)*i/2+i/2,s=Ju(_k(n))(o),u=c=>K(st("Return",Ht(_=>f=>({line:ur(f),runs:sr(f),left:_>=0&&_<c.length?e.x+e.w/2-c[_]/2:e.x+e.w/2-0,y:a+rt(_)*i}))(o)),ct);return K(s._1,(()=>{if(s._2.tag==="CatNil")return et("CatCons",u,tt(D,D));if(s._2.tag==="CatCons")return et("CatCons",s._2._1,tt(s._2._2._1,yt("Cons",et("CatCons",u,tt(D,D)),s._2._2._2)));g()})())},fk=t=>e=>n=>{const r=Ju(o=>ti(o.style==="RunCode"||o.style==="RunCodeHighlight"?{...t,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:t)(o.text))(Oh(e)(n));return K(r._1,(()=>{if(r._2.tag==="CatNil")return et("CatCons",o=>K(st("Return",ea(o)),ct),tt(D,D));if(r._2.tag==="CatCons")return et("CatCons",r._2._1,tt(r._2._2._1,yt("Cons",et("CatCons",o=>K(st("Return",ea(o)),ct),tt(D,D)),r._2._2._2)));g()})())},Zh=t=>{const e=n=>{if(n.tag==="Leaf")return M;if(n.tag==="Node")return Zt("Node",n._1,n._2,n._3,p_({x:t.vx,y:t.vy,w:t.vw,h:t.vh})(n._4),e(n._5),e(n._6));g()};return e},lk=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=hi(r);return i=>a=>s=>u=>c=>_=>{const f=on(_).length,l=rt(f+1|0),d=m=>{const x=(s*l-rt(m))/1.5,y=x<0?0:x>1?1:x;return y*y*(3-2*y)},h=(m=>{let x=m,y=!0,w;for(;y;){const N=x;if(N>=f){y=!1,w=N;continue}if(d(N)>=1){x=N+1|0;continue}y=!1,w=N}return w})(0),p=h>=f?[]:Cr(m=>d(m)>0)($t(h,f-1|0)).init;return n.bind((()=>{const m=t.drawText({x:u,y:c,content:Ie(h)(_),font:i,color:a,align:po,baseline:Un});return h>0?m:r.pure()})())(()=>o(m=>n.bind(t.measureText(i)(Ie(m)(_)))(x=>{const y=d(m);return t.drawText({x:u+x,y:c-(1-y)*10,content:Ie(1)(Ii(Pn(Ie(m)(_)))(_)),font:i,color:{...a,a:he(nr(y*rt(a.a)))},align:po,baseline:Un})}))(p))}},dk=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=hi(r),i=lk(t);return a=>{const s={...a.spec,content:Qv(a.spec.content)};if(a.plan.tag==="PlainText")return t.drawText(s);if(a.plan.tag==="RoundedText")return n.bind((()=>{const u=r.pure();if(a.bounds.tag==="Nothing")return u;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(a.plan._1.radius)(a.plan._1.fill)(a.plan._1.stroke);g()})())(()=>t.drawText(s));if(a.plan.tag==="TokenTravelText"){const u=a.plan._1;return n.bind(o(c=>t.fillPath(Sh(c)(1.5))(u.trailFill))(u.trail))(()=>n.bind((()=>{const c=r.pure();if(a.bounds.tag==="Nothing")return c;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(u.radius)(J("Just",u.fill))(T);g()})())(()=>i(s.font)(s.color)(u.reveal)(u.textLeft)(s.y)(ur(a.text))))}if(a.plan.tag==="TokenFillingText"){const u=a.plan._1;return n.bind(t.drawRoundedRect(u.shadow)(u.radius)(J("Just",u.shadowFill))(T))(()=>n.bind((()=>{const c=r.pure();if(a.bounds.tag==="Nothing")return c;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(u.radius)(J("Just",u.fill))(J("Just",u.stroke));g()})())(()=>n.bind(t.strokePath(u.leader)(u.stroke))(()=>t.drawText(s))))}if(a.plan.tag==="AffineText")return t.drawTextAffine(a.plan._1)(s);g()}},hk=t=>e=>n=>r=>o=>i=>a=>Vh(r)(o)(i)({owner:yo("TokenText",t),text:n.line,spec:{x:o.x,y:o.y,content:n.line,font:{family:e.fontFamily,size:11,weight:500},color:e.chipPillText,align:po,baseline:Un},bounds:J("Just",r),plan:ai("TokenTravelText",{trail:X3(r)(a),trailFill:{color:e.trailDot,flat:!0},radius:3,fill:{color:e.chipPillFill,flat:!0},textLeft:r.x+14,reveal:(()=>{const s=n.phaseInLabel/.45;return s<0?0:s>1?1:s})()})}),vu=t=>e=>n=>r=>{const o=V(d=>rt(li(1)(on(d).length)))(r),i=gr(1)(v(hr)(0)(o)),a=$a(e)(n)(t),s=a*i,u=li(1)(r.length),c=(d=>h=>p=>{let m=d,x=h,y=p,w=!0,N;for(;w;){const b=m,C=x,L=Pt(E=>T,E=>I=>J("Just",{head:E,tail:I}),y);if(L.tag==="Nothing"){w=!1,N=li(0)(u-1|0);continue}if(L.tag==="Just"){if(C+L._1.head>=s){w=!1,N=b;continue}m=b+1|0,x=C+L._1.head,y=L._1.tail;continue}g()}return N})(0)(0)(o),_=v(hr)(0)(c<1?[]:Rt(0,c,o)),f=_/i;if(c>=0&&c<o.length){const d=(_+o[c])/i;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(d<=f)return 1;const h=(a-f)/(d-f);return h<0?0:h>1?1:h})()}}const l=(_+1)/i;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(l<=f)return 1;const d=(a-f)/(l-f);return d<0?0:d>1?1:d})()}},tp=t=>e=>n=>r=>o=>t.Bind1().bind(e({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(vu(r)(0)(0)(V(ua)(o)).line))(i=>{const a=i+28;return t.Applicative0().pure({x:n.x+n.w/2-a/2,y:n.y-25.2-14,w:a,h:25.2})}),pk=t=>{const e=t.Bind1(),n=t.Applicative0(),r=oo.traverse(n);return o=>i=>a=>e.Apply0().Functor0().map(s=>Mh(Tt(u=>u)(s)))(r(s=>{if(s._2.tag==="Filling"&&s._2._1.labels.length!==0){const u=me(s._2._1.node)(i);if(u.tag==="Just")return e.bind(tp(t)(o)(u._1)(s._2._1.progress)(s._2._1.labels))(c=>n.pure(J("Just",S(s._1,c))));if(u.tag==="Nothing")return n.pure(T);g()}return n.pure(T)})(sn(a.tokens)))},mk=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=T_(n)(r)(o)(i)(a)(s);return t.Bind1().bind(e({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(vu(i)(a)(s)(Et(u)(J_)).line))(_=>t.Applicative0().pure({x:c.x+14+_/2-_/2-14,y:c.y-6-8-6.6-6,w:_+28,h:25.2}))},yk=t=>{const e=t.Bind1(),n=t.Applicative0(),r=oo.traverse(n);return o=>i=>a=>s=>e.Apply0().Functor0().map(u=>Mh(Tt(c=>c)(u)))(r(u=>{if(u._2.tag==="Travelling"&&u._2._1.labels.length!==0){const c=me(u._2._1.target)(i),_=me(u._2._1.source)(i),f=zr(u._2._1.edge)(a);if(f.tag==="Just"&&_.tag==="Just"&&c.tag==="Just"){const l=(()=>{if(u._2._1.direction==="Forward")return f._1;if(u._2._1.direction==="Backward")return ee(f._1);g()})(),d=T_(l)(_._1)(c._1)(u._2._1.progress)(u._2._1.holdPre)(u._2._1.holdPost);return e.bind(mk(t)(o)(l)(_._1)(c._1)(u._2._1.progress)(u._2._1.holdPre)(u._2._1.holdPost)(u._2._1.labels))(h=>n.pure(J("Just",S(u._1,{id:u._1,rect:h,token:d}))))}}return n.pure(T)})(sn(s.tokens)))},k_=t=>{const e=t.Bind1(),n=yk(t),r=pk(t);return o=>i=>a=>s=>{const u=na(a);return e.bind(n(o)(u.nodes)(u.edges)(s))(c=>e.bind(r(o)(u.nodes)(s))(_=>t.Applicative0().pure(v3({x:i.vx,y:i.vy,w:i.vw,h:i.vh})([...Tt(f=>{const l=me(f._1)(s.nodes);return l.tag==="Just"&&oi(l._1).alpha>0?J("Just",{x:f._2.x,y:f._2.y,w:f._2.w,h:f._2.h}):T})(sn(u.nodes)),...(()=>{const f=(l,d)=>{if(l.tag==="Leaf")return d;if(l.tag==="Node")return f(l._5,yt("Cons",l._4,f(l._6,d)));g()};return Bt(ce.foldr,f(_,D))})()])(Tt(f=>Qh(f)(c))((()=>{const f=l=>{if(l.tag==="Leaf")return M;if(l.tag==="Node")return Zt("Node",l._1,l._2,l._3,void 0,f(l._5),f(l._6));g()};return Gt(R.compare)(Bt(fn.foldr,f(c)))})())))))}},xk=k_(Yg),L_=t=>e=>n=>{const r=(e*rt(t+1|0)-rt(n))/1.5,o=r<0?0:r>1?1:r;return o*o*(3-2*o)},ra=t=>e=>n=>{const r=fk(t)(n)(e.runs);return K(r._1,(()=>{if(r._2.tag==="CatNil")return et("CatCons",o=>K(st("Return",e.left+o),ct),tt(D,D));if(r._2.tag==="CatCons")return et("CatCons",r._2._1,tt(r._2._2._1,yt("Cons",et("CatCons",o=>K(st("Return",e.left+o),ct),tt(D,D)),r._2._2._2)));g()})())},Tk=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=u<0?0:u>1?1:u,_=gr(8)(i.size*.9),f=(p,m,x,y,w)=>{const N=ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",p)]})($h(t)(e)(1)(n)(r)(w==="RunCode"||w==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(w)(m)(x)(En(y)));return p>.001?N:K(st("Return",void 0),ct)},l=(p,m)=>{const x=on(p.line).length;return L_(x)(c)((x-m|0)-1|0)},d=jh(r)(o)(i)(a),h=p=>{const m=jh(r)(o)(i)(s),x=y=>Xn(w=>{const N=w>=0&&w<p.length?J("Just",p[w]):T,b=w>=0&&w<y.length?J("Just",y[w]):T;return Xn(C=>{if(C.tag==="DiffKeep"){if(N.tag==="Just"){if(b.tag==="Just"){const L=b._1,E=N._1,I=ra(i)(E)(C._1),W=P=>{const G=ra(i)(L)(C._2),j=nt=>f(1,P+(nt-P)*c,E.y+(L.y-E.y)*c,C._3,(()=>{if(c<.5){const $=Et(E.runs)(H=>Ro(on(H.text).length,H.style));return C._1>=0&&C._1<$.length?$[C._1]:Yr}const O=Et(L.runs)($=>Ro(on($.text).length,$.style));return C._2>=0&&C._2<O.length?O[C._2]:Yr})());return K(G._1,(()=>{if(G._2.tag==="CatNil")return et("CatCons",j,tt(D,D));if(G._2.tag==="CatCons")return et("CatCons",G._2._1,tt(G._2._2._1,yt("Cons",et("CatCons",j,tt(D,D)),G._2._2._2)));g()})())};return K(I._1,(()=>{if(I._2.tag==="CatNil")return et("CatCons",W,tt(D,D));if(I._2.tag==="CatCons")return et("CatCons",I._2._1,tt(I._2._2._1,yt("Cons",et("CatCons",W,tt(D,D)),I._2._2._2)));g()})())}if(b.tag==="Nothing"){const L=N._1,E=ra(i)(L)(C._1),I=W=>{const P=l(L,C._1);return f(1-P,W,L.y-_*P,C._3,(()=>{const G=Et(L.runs)(j=>Ro(on(j.text).length,j.style));return C._1>=0&&C._1<G.length?G[C._1]:Yr})())};return K(E._1,(()=>{if(E._2.tag==="CatNil")return et("CatCons",I,tt(D,D));if(E._2.tag==="CatCons")return et("CatCons",E._2._1,tt(E._2._2._1,yt("Cons",et("CatCons",I,tt(D,D)),E._2._2._2)));g()})())}g()}if(N.tag==="Nothing"){if(b.tag==="Just"){const L=b._1,E=ra(i)(L)(C._2),I=W=>{const P=L_(on(L.line).length)(c)(C._2);return f(P,W,L.y-_*(1-P),C._3,(()=>{const G=Et(L.runs)(j=>Ro(on(j.text).length,j.style));return C._2>=0&&C._2<G.length?G[C._2]:Yr})())};return K(E._1,(()=>{if(E._2.tag==="CatNil")return et("CatCons",I,tt(D,D));if(E._2.tag==="CatCons")return et("CatCons",E._2._1,tt(E._2._2._1,yt("Cons",et("CatCons",I,tt(D,D)),E._2._2._2)));g()})())}if(b.tag==="Nothing")return K(st("Return",void 0),ct)}g()}if(C.tag==="DiffDelete"){if(N.tag==="Just"){const L=N._1,E=ra(i)(L)(C._1),I=W=>{const P=l(L,C._1);return f(1-P,W,L.y-_*P,C._2,(()=>{const G=Et(L.runs)(j=>Ro(on(j.text).length,j.style));return C._1>=0&&C._1<G.length?G[C._1]:Yr})())};return K(E._1,(()=>{if(E._2.tag==="CatNil")return et("CatCons",I,tt(D,D));if(E._2.tag==="CatCons")return et("CatCons",E._2._1,tt(E._2._2._1,yt("Cons",et("CatCons",I,tt(D,D)),E._2._2._2)));g()})())}if(N.tag==="Nothing")return K(st("Return",void 0),ct);g()}if(C.tag==="DiffInsert"){if(b.tag==="Just"){const L=b._1,E=ra(i)(L)(C._1),I=W=>{const P=L_(on(L.line).length)(c)(C._1);return f(P,W,L.y-_*(1-P),C._2,(()=>{const G=Et(L.runs)(j=>Ro(on(j.text).length,j.style));return C._1>=0&&C._1<G.length?G[C._1]:Yr})())};return K(E._1,(()=>{if(E._2.tag==="CatNil")return et("CatCons",I,tt(D,D));if(E._2.tag==="CatCons")return et("CatCons",E._2._1,tt(E._2._2._1,yt("Cons",et("CatCons",I,tt(D,D)),E._2._2._2)));g()})())}if(b.tag==="Nothing")return K(st("Return",void 0),ct)}g()})(gk((()=>{if(N.tag==="Nothing")return"";if(N.tag==="Just")return N._1.line;g()})())((()=>{if(b.tag==="Nothing")return"";if(b.tag==="Just")return b._1.line;g()})()))})($t(0,li(p.length)(y.length)-1|0));return K(m._1,(()=>{if(m._2.tag==="CatNil")return et("CatCons",x,tt(D,D));if(m._2.tag==="CatCons")return et("CatCons",m._2._1,tt(m._2._2._1,yt("Cons",et("CatCons",x,tt(D,D)),m._2._2._2)));g()})())};return K(d._1,(()=>{if(d._2.tag==="CatNil")return et("CatCons",h,tt(D,D));if(d._2.tag==="CatCons")return et("CatCons",d._2._1,tt(d._2._2._1,yt("Cons",et("CatCons",h,tt(D,D)),d._2._2._2)));g()})())},S_=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=oi(s),_=s.tag==="PloppingOut"&&n.wobble?{alpha:1,scale:1}:c,f=An((()=>{if(u.tag==="Just"){if(u._1.tag==="StaticNodeLabel")return u._1._1===""?i:u._1._1;if(u._1.tag==="RelabelingNode"){const y=u._1._1.progress<.5?u._1._1.oldLabel:u._1._1.newLabel;return y===""?i:y}g()}if(u.tag==="Nothing")return a.label===""?i:a.label;g()})()),l={family:n.fontFamily,size:n.wobble?15:11,weight:n.wobble?800:500},d=l.size*1.2,h=(a.shape==="Cylinder"?(a.y+(a.y+a.h+5-2*vn(a.h*.075)(a.w*.075)))/2:(a.y+a.y+a.h)/2)-rt(f.length)*d/2+d/2,p=(y,w)=>{const N=ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",y)]})(Xn(b=>b_(t)(e)(1)(n)(i)(l)(a.x+a.w/2)(h+rt(b._1)*d)(b._2))(Ht(Ln)(An(w))));return y>.001?N:K(st("Return",void 0),ct)},m=(y,w)=>Xn(N=>b_(t)(e)(y)(n)(i)(l)(a.x+a.w/2)(h+rt(N._1)*d)(N._2))(Ht(Ln)(An(w))),x=ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",_.alpha*r),pe("GroupTransform",ui,{tx:(a.x+a.w/2)*(1-_.scale),ty:(a.y+a.h/2)*(1-_.scale),sx:_.scale,sy:_.scale}),pe("GroupAlpha",o)]})((()=>{if(u.tag==="Just"&&u._1.tag==="RelabelingNode"&&ur(u._1._1.oldLabel)===ur(u._1._1.newLabel)&&!ue(y=>ue(w=>w.style==="RunHighlight"||w.style==="RunCodeHighlight",sr(y)),An(u._1._1.oldLabel))&&ue(y=>ue(w=>w.style==="RunHighlight"||w.style==="RunCodeHighlight",sr(y)),An(u._1._1.newLabel)))return m(u._1._1.progress<0?0:u._1._1.progress>1?1:u._1._1.progress,u._1._1.newLabel);if(u.tag==="Just"&&u._1.tag==="RelabelingNode"&&ur(u._1._1.oldLabel)===ur(u._1._1.newLabel)&&ue(y=>ue(w=>w.style==="RunHighlight"||w.style==="RunCodeHighlight",sr(y)),An(u._1._1.oldLabel))&&!ue(y=>ue(w=>w.style==="RunHighlight"||w.style==="RunCodeHighlight",sr(y)),An(u._1._1.newLabel)))return m(u._1._1.progress<0?1:u._1._1.progress>1?0:1-u._1._1.progress,u._1._1.oldLabel);if(u.tag==="Just"&&u._1.tag==="RelabelingNode"){if(ur(u._1._1.oldLabel)===ur(u._1._1.newLabel)){const y=u._1._1,w=p(y.progress<0?1:y.progress>1?0:1-y.progress,y.oldLabel),N=()=>p(y.progress<0?0:y.progress>1?1:y.progress,y.newLabel);return K(w._1,(()=>{if(w._2.tag==="CatNil")return et("CatCons",N,tt(D,D));if(w._2.tag==="CatCons")return et("CatCons",w._2._1,tt(w._2._2._1,yt("Cons",et("CatCons",N,tt(D,D)),w._2._2._2)));g()})())}return Tk(t)(e)(n)(i)(a)(l)(u._1._1.oldLabel)(u._1._1.newLabel)(u._1._1.progress)}return Xn(y=>b_(t)(e)(1)(n)(i)(l)(a.x+a.w/2)(h+rt(y._1)*d)(y._2))(Ht(Ln)(f))})());return o>0&&_.alpha*r>0?x:K(st("Return",void 0),ct)},ep=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>f=>l=>{const d=mu({id:c,role:t,geometry:lu("FlatNode",{shape:_.shape,bounds:{x:_.x,y:_.y,w:_.w,h:_.h}}),alpha:i,plan:du("FlatNodePlan",{palette:o,label:(()=>{if(l.tag==="Just"){if(l._1.tag==="StaticNodeLabel")return l._1._1===""?c:l._1._1;if(l._1.tag==="RelabelingNode"){const p=l._1._1.progress<.5?l._1._1.oldLabel:l._1._1.newLabel;return p===""?c:p}g()}if(l.tag==="Nothing")return _.label===""?c:_.label;g()})(),labelVisibility:n,inkBoost:r,labelAlpha:s,outlineAlpha:a,arrival:u,animState:f})}),h=()=>{if(n==="LabelsHidden")return K(st("Return",void 0),ct);if(n==="LabelsShown")return S_(yh)(e)(o)(i)(s)(c)(_)(f)(l);g()};return K(d._1,(()=>{if(d._2.tag==="CatNil")return et("CatCons",h,tt(D,D));if(d._2.tag==="CatCons")return et("CatCons",d._2._1,tt(d._2._2._1,yt("Cons",et("CatCons",h,tt(D,D)),d._2._2._2)));g()})())},np=t=>e=>n=>{const r={...t,nodeFill:t.text,text:t.nodeFill,nodeStroke:t.nodeFill};return Xn(o=>{const i=me(o._1)(n.nodes),a=me(o._1)(e.nodes),s=a.tag==="Just"&&i.tag==="Just"?ke({path:[],role:an,layer:T,effects:[pe("GroupAlpha",o._2)]})(ep(jb)(n.animationTime)(g_)(1)(r)(1)(T)(1)(T)(o._1)((()=>{const u=me(o._1)(n.nodeLabels);if(u.tag==="Nothing")return a._1;if(u.tag==="Just"){if(u._1.tag==="StaticNodeLabel")return{...a._1,label:u._1._1===""?o._1:u._1._1};if(u._1.tag==="RelabelingNode")return{...a._1,label:(()=>{const c=u._1._1.progress<.5?u._1._1.oldLabel:u._1._1.newLabel;return c===""?o._1:c})()}}g()})())(i._1)(me(o._1)(n.nodeLabels))):K(st("Return",void 0),ct);return o._2>0?s:K(st("Return",void 0),ct)})(sn(n.nodeInvert))},rp=t=>e=>n=>{const r=Ta(6)(.55)(Nu(0)(1)((1-t)/.06)),o=t>.94,i=o&&n>1e-4,a=Ta(6)(.55)(Nu(0)(1)(t/.06)),s=t<.06,u=s&&e>1e-4,c=o&&n<=1e-4;return{popScale:u?a:i?r:1,flipY:s&&e<=1e-4?a:c?r:1,fadeAlpha:(()=>{if(u){const _=t/.06;return _<0?.55:_>1?1:.55+.44999999999999996*_}if(i){const _=(1-t)/.06;return _<0?.55:_>1?1:.55+.44999999999999996*_}return 1})()}},Cu=t=>e=>n=>r=>{const o=na(e);return ke({path:[],role:an,layer:J("Just",ob),effects:[]})(Xn((()=>{const i=o.nodes,a=o.edges;return s=>{if(s._2.tag==="Travelling"){if(s._2._1.labels.length!==0){const u=me(s._2._1.target)(i),c=me(s._2._1.source)(i),_=zr(s._2._1.edge)(a),f=Qh(s._1)(r);if(f.tag==="Just"&&_.tag==="Just"&&c.tag==="Just"&&u.tag==="Just")return hk(s._1)(t)(vu(s._2._1.progress)(s._2._1.holdPre)(s._2._1.holdPost)(Et(s._2._1.labels)(J_)))(f._1)({x:f._1.x+f._1.w/2,y:f._1.y+f._1.h/2})(rp(s._2._1.progress)(s._2._1.holdPre)(s._2._1.holdPost))(T_((()=>{if(s._2._1.direction==="Forward")return _._1;if(s._2._1.direction==="Backward")return ee(_._1);g()})())(c._1)(u._1)(s._2._1.progress)(s._2._1.holdPre)(s._2._1.holdPost))}return K(st("Return",void 0),ct)}if(s._2.tag==="Filling"&&s._2._1.labels.length!==0){const u=me(s._2._1.node)(i);if(u.tag==="Just"){const c=u._1,_=tp(Yg)(Th)(c)(s._2._1.progress)(s._2._1.labels),f=l=>ek(s._1)(t)(vu(s._2._1.progress)(0)(0)(Et(s._2._1.labels)(J_)).line)(c)(l)({x:l.x+l.w/2,y:l.y+l.h/2})(rp(s._2._1.progress)(0)(0));return K(_._1,(()=>{if(_._2.tag==="CatNil")return et("CatCons",f,tt(D,D));if(_._2.tag==="CatCons")return et("CatCons",_._2._1,tt(_._2._2._1,yt("Cons",et("CatCons",f,tt(D,D)),_._2._2._2)));g()})())}if(u.tag==="Nothing")return K(st("Return",void 0),ct);g()}return K(st("Return",void 0),ct)}})())(sn(n.tokens)))},op=t=>e=>n=>r=>{const o=xk(Th)(e)(n)(r);return K(o._1,(()=>{if(o._2.tag==="CatNil")return et("CatCons",i=>Cu(t)(n)(r)(i),tt(D,D));if(o._2.tag==="CatCons")return et("CatCons",o._2._1,tt(o._2._2._1,yt("Cons",et("CatCons",i=>Cu(t)(n)(r)(i),tt(D,D)),o._2._2._2)));g()})())},wk=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>o=>{const i=o.length-1|0,a=i<1?[]:Rt(0,i,o),s=a.length-1|0,u=s>=0&&s<a.length?J("Just",a[s]):T,c=o.length-1|0,_=c>=0&&c<o.length?J("Just",o[c]):T;if(_.tag==="Just"&&u.tag==="Just"){const f=Fe(.78)(1.18)(Ua(o)+19|0),l=Fe(.4)(.62)(f.prng),d=r.wobble?8.75*l.value:4.375,h=Fe(.4)(.62)(l.prng),p=r.wobble?8.75*h.value:4.375,m=_._1.y-u._1.y,x=_._1.x-u._1.x,y=Ke(x*x+m*m),w=m/y,N=-w,b=x/y,C=_._1.x+b*.875,L=_._1.y+w*.875,E=r.wobble?8.75*f.value:8.75,I=C-b*E,W=L-w*E,P=I+N*d,G=W+b*d,j=[1,C,L,2,I+N*4.375,W+b*4.375,2,I-N*4.375,W-b*4.375,5],nt=I-N*p,O=W-b*p,$={color:r.arrowFill,width:2,lineJoin:Ze,lineCap:Ir};return y<=1e-4?n.pure():r.wobble?e.Bind1().bind(t.strokePath([1,P,G,2,C,L])($))(()=>t.strokePath([1,nt,O,2,C,L])($)):t.fillPath(j)({color:r.arrowFill,flat:!0})}return n.pure()}},Nk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=hi(n),i=t.popAlpha,a=wk(t);return s=>u=>c=>_=>f=>{const l=kh(8)(_),d=c&&f.hi>=.9&&(1-f.hi)*Ja(l)<=8.75?1:f.hi;if(d<=f.lo)return n.pure();const h=d3(l)(f.lo)(d);if(h.length===0)return n.pure();const p={color:s.edge,width:s.wobble?2:.9375,lineJoin:Ze,lineCap:Ir},m=s.wobble?Fe(-10)(4)(Ua(h)).value:0,x=s.wobble?P3(m)(h):h;return r.bind(s.wobble?o(y=>r.bind(t.pushAlpha(y.alpha))(()=>r.bind(t.strokePath(y.path)(p))(()=>i)))((()=>{const y=Ua(h);return x.length<2?[]:ta(nk)(y)(!1)(x)})()):t.strokePath(o3(h))(p))(()=>{const y=a(s)(x);return u&&d>=.999?y:n.pure()})}},Jk=t=>{const e=Nk(t);return n=>n.geometry.tag==="FlatRoute"&&n.plan.tag==="FlatEdgePlan"?e(n.plan._1)(n.arrow)(n.settlingAtTarget)(n.geometry._1)(n.visible):t.Monad0().Applicative0().pure()},vk=t=>e=>{const n=i=>{const a=me(i)(t.nodes);if(a.tag==="Nothing")return!1;if(a.tag==="Just"){const s=a._1;return!ue(u=>0<u._2.length&&u._2[0].x>=s.x&&u._2[0].x<=s.x+s.w&&u._2[0].y>=s.y&&u._2[0].y<=s.y+s.h,sn(t.edges))}g()},r=v(i=>a=>(i*31|0)+go(a)|0)(5381)(Hn(e.frameTitle)),o=i=>{const a=me(i)(t.nodes);if(a.tag==="Nothing")return!1;if(a.tag==="Just"){const s=a._1;return!ue(u=>{const c=u._2.length-1|0;return c>=0&&c<u._2.length&&u._2[c].x>=s.x&&u._2[c].x<=s.x+s.w&&u._2[c].y>=s.y&&u._2[c].y<=s.y+s.h},sn(t.edges))}g()};return v(i=>a=>{const s=a._2;return Q3(u=>{if(u.tag==="Nothing")return J("Just",s);if(u.tag==="Just")return J("Just",{t:gr(u._1.t)(s.t),angle:s.t>=u._1.t?s.angle:u._1.angle,bigCircle:u._1.bigCircle||s.bigCircle,frameHash:u._1.frameHash});g()})(a._1)(i)})(M)(Et(sn(e.tokens))(i=>{if(i._2.tag==="Filling"){const a=i._2._1.node;return[S(a,{t:1,angle:(()=>{const s=Tt(u=>(()=>{const c=me(a)(t.nodes),_=u._2.length-1|0;return _>=0&&_<u._2.length&&c.tag==="Just"&&u._2[_].x>=c._1.x&&u._2[_].x<=c._1.x+c._1.w&&u._2[_].y>=c._1.y&&u._2[_].y<=c._1.y+c._1.h})()?J("Just",u._2):T)(sn(t.edges));if(0<s.length){const u=s[0].length-1|0,c=u<1?[]:Rt(0,u,s[0]),_=c.length-1|0;if(_>=0&&_<c.length){const f=s[0].length-1|0;return f>=0&&f<s[0].length?Ao(s[0][f].y-c[_].y)(s[0][f].x-c[_].x):0}s[0].length-1|0}return 0})(),bigCircle:n(a)||o(a),frameHash:r})]}if(i._2.tag==="Travelling"){if(i._2._1.progress>=.75)return[S(i._2._1.target,{t:(i._2._1.progress-.75)/.25,angle:(()=>{const a=zr(i._2._1.edge)(t.edges);if(a.tag==="Just"){const s=a._1.length-1|0,u=s<1?[]:Rt(0,s,a._1),c=u.length-1|0;if(c>=0&&c<u.length){const _=a._1.length-1|0;return _>=0&&_<a._1.length?Ao(a._1[_].y-u[c].y)(a._1[_].x-u[c].x):0}return a._1.length-1|0,0}if(a.tag==="Nothing")return 0;g()})(),bigCircle:n(i._2._1.target)||o(i._2._1.target),frameHash:r})];if(i._2._1.progress<.25)return[S(i._2._1.source,{t:i._2._1.progress/.25,angle:(()=>{const a=zr(i._2._1.edge)(t.edges);if(a.tag==="Just")return 1<a._1.length&&0<a._1.length?Ao(a._1[1].y-a._1[0].y)(a._1[1].x-a._1[0].x):0;if(a.tag==="Nothing")return 0;g()})(),bigCircle:n(i._2._1.source)||o(i._2._1.source),frameHash:r})]}return[]}))},Ck=t=>v(e=>n=>(e*31|0)+go(n)|0)(5381)(Hn(t.frameTitle)),ip=t=>e=>n=>r=>o=>i=>a=>{const s=Ck(a),u=vk(i)(a);return Xn(c=>{const _=me(c._1)(a.nodes);if(_.tag==="Just")return ep(xh)(a.animationTime)(e)(r)(o)((()=>{const f=me(c._1)(a.nodeFadeAlpha);if(f.tag==="Nothing")return 1;if(f.tag==="Just")return f._1;g()})())(t(c._1))((()=>{const f=me(c._1)(a.nodeLabelFadeAlpha);if(f.tag==="Nothing")return n*1;if(f.tag==="Just")return n*f._1;g()})())((()=>{const f=me(c._1)(u);return f.tag==="Just"?J("Just",f._1):f.tag==="Nothing"&&W3(c._1)(a.visited)?J("Just",{t:1,angle:0,bigCircle:!1,frameHash:s}):T})())(c._1)((()=>{const f=me(c._1)(a.nodeLabels);if(f.tag==="Nothing")return c._2;if(f.tag==="Just"){if(f._1.tag==="StaticNodeLabel")return{...c._2,label:f._1._1===""?c._1:f._1._1};if(f._1.tag==="RelabelingNode")return{...c._2,label:(()=>{const l=f._1._1.progress<.5?f._1._1.oldLabel:f._1._1.newLabel;return l===""?c._1:l})()}}g()})())(_._1)(me(c._1)(a.nodeLabels));if(_.tag==="Nothing")return K(st("Return",void 0),ct);g()})(sn(i.nodes))},bk=t=>t,ap=t=>e=>{const n=e.vw/e.vh,r=e.vh*t,o={...e,vx:e.vx-(r-e.vw)/2,vw:r},i=e.vw/t,a={...e,vy:e.vy-(i-e.vh)/2,vh:i};return t<=0||e.vw<=0||e.vh<=0?e:t>n?o:t<n?a:e},E_=t=>e=>t.width<=0||t.height<=0?e:ap(t.width/t.height)(e),kk=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},sp=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},up=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},P_=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},cp=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Lk=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},G_=(()=>{const t=wn.unfoldr(dr);return e=>t(Nn("IterNode",e,fr))})(),Sk=Go(ho)(Wt),Ek=t=>e=>{const n=Ye(t.angle),r=_n(t.angle);return{a:r,b:n,c:0,d:1,e:-e*r,f:e*n-t.boxHeight/2}},Pk=t=>[t.box.ground.a,t.box.ground.b,t.box.ground.c,t.box.ground.d,t.box.top.a,t.box.top.b,t.box.top.c,t.box.top.d],R_=t=>e=>{const n=r=>kk(0)(255)(he(Wn(rt(r)*t)));return{r:n(e.r),g:n(e.g),b:n(e.b),a:e.a}},tn=t=>e=>n=>r=>({x:(e-n)*_n(t.angle),y:(e+n)*Ye(t.angle)-r}),A_=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Et(e._1.tail)(n=>[2,n.x,n.y]),5];g()},Gk=t=>e=>n=>{const r=n.id,o=n.np,i=mu({id:r,role:xh,geometry:lu("IsoSlab",{south:[n.box.ground.d,n.box.ground.c,n.box.top.c,n.box.top.d],east:[n.box.ground.b,n.box.ground.c,n.box.top.c,n.box.top.b],top:[n.box.top.a,n.box.top.b,n.box.top.c,n.box.top.d]}),alpha:1,plan:du("IsoNodePlan",{config:t,palette:e})}),a=()=>gi({owner:yo("NodeText",r),text:o.label,spec:{x:o.x+o.w/2,y:0,content:o.label,font:{family:e.fontFamily,size:11,weight:600},color:e.text,align:ei,baseline:Un},bounds:T,plan:ai("AffineText",Ek(t)(o.y+o.h))});return K(i._1,(()=>{if(i._2.tag==="CatNil")return et("CatCons",a,tt(D,D));if(i._2.tag==="CatCons")return et("CatCons",i._2._1,tt(i._2._2._1,yt("Cons",et("CatCons",a,tt(D,D)),i._2._2._2)));g()})())},Rk=t=>e=>n=>r=>o=>{const i=Oe(Ln,o,Rt(1,o.length,o)),a=i.length-1|0;return Ht(s=>u=>({depth:(u._1.x+u._1.y+u._2.x+u._2.y)/2,draw:Nh({id:n,geometry:ch("IsoSegments",[[tn(t)(u._1.x)(u._1.y)(0),tn(t)(u._2.x)(u._2.y)(0)]]),visible:{lo:0,hi:1},arrow:r&&s===a,settlingAtTarget:!1,plan:gh("IsoEdgePlan",{config:t,palette:e})})}))(i)},Ak=t=>e=>n=>r=>o=>{const i=(()=>{if(t==="Forward")return o;if(t==="Backward")return ee(o);g()})();if(0<i.length){const s=Ho(i)(sp(0)(1)($a(n)(r)(e)));if(s.tag==="Nothing")return i[0];if(s.tag==="Just")return s._1;g()}const a=Ho(i)(sp(0)(1)($a(n)(r)(e)));if(a.tag==="Nothing")return{x:0,y:0};if(a.tag==="Just")return a._1;g()},Ik=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Et(e._1.tail)(n=>[2,n.x,n.y])];g()},Fk=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{vx:0,vy:0,vw:0,vh:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:up(r.minX)(o.x),minY:up(r.minY)(o.y),maxX:P_(r.maxX)(o.x),maxY:P_(r.maxY)(o.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{vx:n.minX-40,vy:n.minY-40,vw:n.maxX-n.minX+80,vh:n.maxY-n.minY+80}}g()},Dk=t=>{const e=t.Monad0(),n=e.Bind1();return r=>{if(r.geometry.tag==="IsoSlab"&&r.plan.tag==="IsoNodePlan"){const o=r.geometry._1,i=r.plan._1.palette,a=(s,u)=>t.fillStrokePath(A_(s))({color:u,flat:!0})({color:i.nodeStroke,width:1,lineJoin:Ze,lineCap:In});return n.bind(a(o.south,R_(.66)(i.nodeFill)))(()=>n.bind(a(o.east,R_(.82)(i.nodeFill)))(()=>a(o.top,i.nodeFill)))}return e.Applicative0().pure()}},zk=t=>{const e=t.Monad0(),n=e.Bind1();return r=>{if(r.geometry.tag==="IsoCube"&&r.plan.tag==="IsoTokenPlan"){const o=r.geometry._1,i=r.plan._1.palette,a=(s,u)=>t.fillStrokePath(A_(s))({color:R_(u)(i.tokenOutsideFill),flat:!0})({color:i.tokenOutsideStroke,width:1,lineJoin:Ze,lineCap:In});return n.bind(a(o.south,.66))(()=>n.bind(a(o.east,.82))(()=>a(o.top,1)))}return e.Applicative0().pure()}},Bk={angle:.5235987755982988,boxHeight:26,transparentBg:!0},Mk=t=>e=>n=>{const r=cp(t)(n.nodeLabels);if(r.tag==="Just"){if(r._1.tag==="StaticNodeLabel")return r._1._1===""?t:r._1._1;if(r._1.tag==="RelabelingNode"){const o=r._1._1.progress<.5?r._1._1.oldLabel:r._1._1.newLabel;return o===""?t:o}g()}if(r.tag==="Nothing")return e.label===""?t:e.label;g()},Qk=t=>e=>n=>{const r=n.x-5.5,o=n.x+5.5,i=n.y-5.5,a=n.y+5.5,s=e+11,u=tn(t)(o)(i)(s),c=tn(t)(o)(a)(s),_=tn(t)(r)(a)(s),f=tn(t)(o)(a)(e);return{south:[tn(t)(r)(a)(e),f,c,_],east:[tn(t)(o)(i)(e),f,c,u],top:[tn(t)(r)(i)(s),u,c,_]}},Wk=t=>e=>n=>r=>{const o=r._1,i=(a,s)=>({depth:s.x+s.y,draw:Jh({id:o,pass:ph,geometry:fh("IsoCube",Qk(t)(a)(s)),position:s,plan:dh("IsoTokenPlan",{config:t,palette:e,baseZ:a})})});if(r._2.tag==="Travelling"){const a=Lk(r._2._1.edge)(n.edges);return a.tag==="Just"?J("Just",i(0,Ak(r._2._1.direction)(r._2._1.progress)(r._2._1.holdPre)(r._2._1.holdPost)(a._1))):T}if(r._2.tag==="Filling"){const a=cp(r._2._1.node)(n.nodes);if(a.tag==="Just")return J("Just",i(t.boxHeight,{x:a._1.x+a._1.w/2,y:a._1.y+a._1.h/2}))}return T},Hk=t=>e=>{const n=e.y+e.h,r=e.x+e.w;return{ground:{a:tn(t)(e.x)(e.y)(0),b:tn(t)(r)(e.y)(0),c:tn(t)(r)(n)(0),d:tn(t)(e.x)(n)(0)},top:{a:tn(t)(e.x)(e.y)(t.boxHeight),b:tn(t)(r)(e.y)(t.boxHeight),c:tn(t)(r)(n)(t.boxHeight),d:tn(t)(e.x)(n)(t.boxHeight)},depth:(e.x+r)/2+(e.y+n)/2}},gp=t=>e=>V(n=>({id:n._1,np:n._2,box:Hk(t)(n._2)}))(G_(e.nodes)),Ok=t=>e=>[...Et(gp(t)(e))(Pk),...(()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._4,n(r._6,o)));g()};return Et(Bt(ce.foldr,n(e.edges,D)))(V(r=>tn(t)(r.x)(r.y)(0)))})()],qk=t=>e=>n=>V(r=>({...r,np:{...r.np,label:Mk(r.id)(r.np)(n)}}))(gp(t)(e)),Vk=t=>e=>n=>r=>{const o=w_(e),i=[...Et(G_(n.edges))(u=>Rk(t)(o)(u._1)((()=>{const c=rr("conn:")(u._1);if(c.tag==="Just")return!1;if(c.tag==="Nothing")return!0;g()})())(u._2)),...V(u=>({depth:u.box.depth,draw:Gk(t)(o)(u)}))(qk(t)(n)(r)),...Tt(Wk(t)(o)(n))(G_(r.tokens))],a=wh({viewport:Fk(Ok(t)(n)),clear:J("Just",t.transparentBg?o.bgTransparent:o.bg),dots:T}),s=()=>Sk(u=>u.draw)(Gt(u=>c=>at.compare(u.depth)(c.depth))(i));return K(a._1,(()=>{if(a._2.tag==="CatNil")return et("CatCons",s,tt(D,D));if(a._2.tag==="CatCons")return et("CatCons",a._2._1,tt(a._2._2._1,yt("Cons",et("CatCons",s,tt(D,D)),a._2._2._2)));g()})())},$k=t=>{const e=t.to.y-t.from.y,n=t.to.x-t.from.x,r=P_(1e-4)(Ke(n*n+e*e)),o=e/r,i=n/r,a=t.to.y-o*7,s=t.to.x-i*7;return A_([t.to,{x:s-o*3,y:a+i*3},{x:s+o*3,y:a-i*3}])},Uk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Go(n)(Wt);return o=>{if(o.geometry.tag==="IsoSegments"&&o.plan.tag==="IsoEdgePlan"){const i=o.plan._1.palette,a=o.geometry._1;return e.Bind1().bind(r(s=>t.strokePath(Ik(s))({color:i.edge,width:1.5,lineJoin:Ze,lineCap:Ir}))(a))(()=>{const s=a.length-1|0;if(s>=0&&s<a.length){const c=a[s],_=c.length-1|0,f=_<1?[]:Rt(0,_,c),l=f.length-1|0;if(l>=0&&l<f.length){const h=a.length-1|0,p=(()=>{if(h>=0&&h<a.length){const m=a[h],x=m.length-1|0;if(x>=0&&x<m.length)return t.fillPath($k({from:f[l],to:m[x]}))({color:i.arrowFill,flat:!0})}return n.pure()})();return o.arrow?p:n.pure()}a.length-1|0;const d=n.pure();return o.arrow?d:n.pure()}a.length-1|0;const u=n.pure();return o.arrow?u:n.pure()})}return n.pure()}},_p=t=>t,qe=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},wo=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Xk=_p("Split"),Yk=_p("Fall"),un=t=>e=>n=>r=>{const o=n?0:1,i=1-re(r.x-o)*Ye(e)*1.1,a=re(i)<.06?i<0?-.06:.06:i,s=t.y+t.h/2,u=t.x+t.w/2;return{x:u+(t.x+(o+(r.x-o)*_n(e))*t.w-u)/a,y:s+(t.y+r.y*t.h-s)/a}},Kk=t=>e=>n=>{const r=un(t)(e)(n)({x:.5,y:.5}),o=t.x+.5*t.w,i=un(t)(e)(n)({x:.5,y:0}),a=n?0:1,s=t.x+a*t.w,u=un(t)(e)(n)({x:a,y:0}),c=un(t)(e)(n)({x:a,y:1}),_=(c.y-u.y)/qe(1e-6)(t.h),f=(c.x-u.x)/qe(1e-6)(t.h),l=o-s,d=(i.y-u.y)/(re(l)<1e-6?l<0?-1e-6:1e-6:l),h=t.y+t.h/2,p=t.x+t.w/2,m=o-s,x=(i.x-u.x)/(re(m)<1e-6?m<0?-1e-6:1e-6:m);return{a:x,b:d,c:f,d:_,e:r.x-x*p-f*h,f:r.y-d*p-_*h}},I_=t=>{const e=qe(0)(t)*3.05,n=_n(e);return{expansion:1+Ye(e)*.16,verticalScale:re(n)<.06?n<0?-.06:.06:n}},No=t=>e=>n=>{const r=I_(e),o=t.x+t.w/2,i=t.y+t.h;return{x:o+(t.x+n.x*t.w-o)*r.expansion,y:i+(t.y+n.y*t.h-i)*r.verticalScale}},jk=t=>e=>{const n=I_(e),r=No(t)(e)({x:.5,y:.5});return{a:n.expansion,b:0,c:0,d:n.verticalScale,e:r.x-n.expansion*(t.x+t.w/2),f:r.y-n.verticalScale*(t.y+t.h/2)}},Zk=t=>qe(0)(t.w)/qe(1e-6)(qe(0)(t.h))>=4?Yk:Xk,tL=t=>e=>n=>{const r=n/qe(1e-6)(t.h),o=n/qe(1e-6)(t.w),i=(s,u,c)=>{const _=No(t)(e)(s),f=No(t)(e)(u),l=No(t)(e)(c);return[4,_.x,_.y,f.x,f.y,l.x,l.y]},a=[...(()=>{const s=No(t)(e)({x:o,y:0});return[1,s.x,s.y]})(),...i({x:o*.44771525016920644,y:0},{x:0,y:r*.44771525016920644},{x:0,y:r}),...(()=>{const s=No(t)(e)({x:0,y:1-r});return[2,s.x,s.y]})(),...i({x:0,y:1-r*.44771525016920644},{x:o*.44771525016920644,y:1},{x:o,y:1}),...(()=>{const s=No(t)(e)({x:1-o,y:1});return[2,s.x,s.y]})(),...i({x:1-o*.44771525016920644,y:1},{x:1,y:1-r*.44771525016920644},{x:1,y:1-r}),...(()=>{const s=No(t)(e)({x:1,y:r});return[2,s.x,s.y]})(),...i({x:1,y:r*.44771525016920644},{x:1-o*.44771525016920644,y:0},{x:1-o,y:0}),...ni];return{face:a,labelAffine:jk(t)(e),labelVisible:I_(e).verticalScale>0,outline:a}},F_=t=>Ta(10.8)(.48)(wo(1)(qe(0)(t)))/Ta(10.8)(.48)(1),eL=t=>e=>{const n=F_(wo(1)(qe(0)((1-wo(1)(qe(0)(t))-.48)/.5))*.48)/F_(.48);if(e<0){const r=wo(1)(qe(0)((t-.25)/.28));return F_(r*r*r)}return wo(1)(re(1-n))},nL=t=>eL((()=>{if(t.tag==="Closed")return 0;if(t.tag==="Opening")return t._1;if(t.tag==="Open")return 1;if(t.tag==="Closing")return 1-t._1;g()})())(t.tag==="Opening"?-1:t.tag==="Closing"?1:0),fp=t=>e=>n=>{const r=wo(1)(qe(0)((n-t)/qe(1e-6)(e-t)));return r*r*(3-2*r)},lp=t=>e=>n=>r=>{const o=n/qe(1e-6)(t.h),i=n/qe(1e-6)(t.w),a=fp(.08)(.2)(e),s=o*a,u=i*a,c=qe(0)(e)*1.91986,_=(f,l,d)=>{const h=un(t)(c)(r)(r?f:{...f,x:1-f.x}),p=un(t)(c)(r)(r?l:{...l,x:1-l.x}),m=un(t)(c)(r)(r?d:{...d,x:1-d.x});return[4,h.x,h.y,p.x,p.y,m.x,m.y]};return{leaf:{face:[...(()=>{const f={x:i,y:0},l=un(t)(c)(r)(r?f:{...f,x:1-f.x});return[1,l.x,l.y]})(),..._({x:i*.44771525016920644,y:0},{x:0,y:o*.44771525016920644},{x:0,y:o}),...(()=>{const f={x:0,y:1-o},l=un(t)(c)(r)(r?f:{...f,x:1});return[2,l.x,l.y]})(),..._({x:0,y:1-o*.44771525016920644},{x:i*.44771525016920644,y:1},{x:i,y:1}),...(()=>{const f={x:.5-u,y:1},l=un(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:.5-u*.44771525016920644,y:1},{x:.5,y:1-s*.44771525016920644},{x:.5,y:1-s}),...(()=>{const f={x:.5,y:s},l=un(t)(c)(r)(r?f:{...f,x:.5});return[2,l.x,l.y]})(),..._({x:.5,y:s*.44771525016920644},{x:.5-u*.44771525016920644,y:0},{x:.5-u,y:0}),...ni],labelAffine:Kk(t)(c)(r),labelVisible:_n(c)>0,outline:[...(()=>{const f={x:.5,y:s},l=un(t)(c)(r)(r?f:{...f,x:.5});return[1,l.x,l.y]})(),..._({x:.5,y:s*.44771525016920644},{x:.5-u*.44771525016920644,y:0},{x:.5-u,y:0}),...(()=>{const f={x:i,y:0},l=un(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:i*.44771525016920644,y:0},{x:0,y:o*.44771525016920644},{x:0,y:o}),...(()=>{const f={x:0,y:1-o},l=un(t)(c)(r)(r?f:{...f,x:1});return[2,l.x,l.y]})(),..._({x:0,y:1-o*.44771525016920644},{x:i*.44771525016920644,y:1},{x:i,y:1}),...(()=>{const f={x:.5-u,y:1},l=un(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:.5-u*.44771525016920644,y:1},{x:.5,y:1-s*.44771525016920644},{x:.5,y:1-s})]},seam:[...(()=>{const f={x:.5,y:s},l=un(t)(c)(r)(r?f:{...f,x:.5});return[1,l.x,l.y]})(),...(()=>{const f={x:.5,y:1-s},l=un(t)(c)(r)(r?f:{...f,x:.5});return[2,l.x,l.y]})()]}},rL=t=>e=>n=>{const r=fp(.08)(.26)(e),o=lp(t)(e)(n)(!1),i=lp(t)(e)(n)(!0);return{leaves:[i.leaf,o.leaf],seams:[{alpha:r,path:i.seam},{alpha:r,path:o.seam}]}},oL=t=>e=>n=>qe(0)(wo(t)(wo(qe(0)(e)/2)(qe(0)(n)/2))),iL=t=>e=>n=>{const r=oL(n)(e.w)(e.h),o=nL(t),i=Zk(e);if(i==="Fall")return{leaves:[tL(e)(o)(r)],seams:[]};if(i==="Split")return rL(e)(o)(r);g()},dp=(t,e)=>({tag:t,_1:e}),D_=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},aL=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},pi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},z_=Si(ho)(Wt),sL=dp("ResolvedLabels"),Ka=t=>e=>{const n=D_(1)(e.rootLayout.bounds.w),r=e.portalState.tag==="Closed"&&e.levels.length===1,o=ln(e.rootLayout)(e.camera),i=r?1:aL(0)(1)(o.w/n),a=t.padding*i*i*(()=>{if(r)return 1;if(e.portalState.tag==="Opening"||e.portalState.tag==="Closing"){if(e.portalState.tag==="Closed")return 1;if(e.portalState.tag==="Opening")return 1-e.portalState._1;if(e.portalState.tag==="Open")return 0;if(e.portalState.tag==="Closing")return 1-(1-e.portalState._1);g()}return 0})();return(()=>{if(t.outputAspect.tag==="Nothing")return bk;if(t.outputAspect.tag==="Just")return ap(t.outputAspect._1);g()})()({vx:o.x-a,vy:o.y-a,vw:o.w+2*a,vh:o.h+2*a})},uL=t=>e=>{if(e.tag==="Nothing")return[];if(e.tag==="Just"){const n=pi(e._1)(t.segment.layout.nodes);if(n.tag==="Nothing")return[];if(n.tag==="Just"){const r=n._1.x*t.segment.placement.scale+t.segment.placement.tx,o=n._1.y*t.segment.placement.scale+t.segment.placement.ty,i=n._1.w*t.segment.placement.scale,a=n._1.h*t.segment.placement.scale;return[1,r,o,2,r+i,o,2,r+i,o+a,2,r,o+a,5]}}g()},B_=t=>e=>{const n=jx(e.segment.placement)({x:t.vx,y:t.vy,w:t.vw,h:t.vh});return{vx:n.x,vy:n.y,vw:n.w,vh:n.h}},M_=t=>e=>t===""?K(st("Return",void 0),ct):gi({owner:Xb,text:t,spec:{x:e.vx+6,y:e.vy+6,content:t,font:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:9,weight:600},color:{r:180,g:180,b:180,a:255},align:po,baseline:ZC},bounds:T,plan:yh}),cL=t=>e=>n=>r=>o=>i=>a=>s=>{const u=w_(t.theme),c=(()=>{if(s.tag==="ResolvedLabels")return op(u)(o)(i)(a);if(s.tag==="SpringLabels")return Cu(u)(i)(a)(Zh(o)(s._1));g()})(),_=wh({viewport:o,clear:J("Just",t.transparentBg?u.bgTransparent:u.bg),dots:T}),f=()=>{const l=ke({path:[],role:an,layer:T,effects:n<1?[pe("GroupAlpha",n)]:[]})((()=>{const d=Yh(u)(i)(a),h=()=>{const p=Kh(r)(u)(t.halftoneShadows)(i)(a),m=()=>{const x=ip(w=>r.tag!=="Nothing"&&r.tag==="Just"&&r._1===w?J("Just",0):T)(g_)(1)(1)(u)(i)(a),y=()=>{const w=np(u)(i)(a),N=()=>{const b=C_(u)(o)(i)(a),C=()=>{const L=Uh(ub)(u)(i)(a),E=()=>{const I=()=>{const W=sk(u)(i)(a);return a.staticKind!=="Animated"?W:K(st("Return",void 0),ct)};return K(c._1,(()=>{if(c._2.tag==="CatNil")return et("CatCons",I,tt(D,D));if(c._2.tag==="CatCons")return et("CatCons",c._2._1,tt(c._2._2._1,yt("Cons",et("CatCons",I,tt(D,D)),c._2._2._2)));g()})())};return K(L._1,(()=>{if(L._2.tag==="CatNil")return et("CatCons",E,tt(D,D));if(L._2.tag==="CatCons")return et("CatCons",L._2._1,tt(L._2._2._1,yt("Cons",et("CatCons",E,tt(D,D)),L._2._2._2)));g()})())};return K(b._1,(()=>{if(b._2.tag==="CatNil")return et("CatCons",C,tt(D,D));if(b._2.tag==="CatCons")return et("CatCons",b._2._1,tt(b._2._2._1,yt("Cons",et("CatCons",C,tt(D,D)),b._2._2._2)));g()})())};return K(w._1,(()=>{if(w._2.tag==="CatNil")return et("CatCons",N,tt(D,D));if(w._2.tag==="CatCons")return et("CatCons",w._2._1,tt(w._2._2._1,yt("Cons",et("CatCons",N,tt(D,D)),w._2._2._2)));g()})())};return K(x._1,(()=>{if(x._2.tag==="CatNil")return et("CatCons",y,tt(D,D));if(x._2.tag==="CatCons")return et("CatCons",x._2._1,tt(x._2._2._1,yt("Cons",et("CatCons",y,tt(D,D)),x._2._2._2)));g()})())};return K(p._1,(()=>{if(p._2.tag==="CatNil")return et("CatCons",m,tt(D,D));if(p._2.tag==="CatCons")return et("CatCons",p._2._1,tt(p._2._2._1,yt("Cons",et("CatCons",m,tt(D,D)),p._2._2._2)));g()})())};return K(d._1,(()=>{if(d._2.tag==="CatNil")return et("CatCons",h,tt(D,D));if(d._2.tag==="CatCons")return et("CatCons",d._2._1,tt(d._2._2._1,yt("Cons",et("CatCons",h,tt(D,D)),d._2._2._2)));g()})())})());return n>0?K(l._1,(()=>{if(l._2.tag==="CatNil")return et("CatCons",()=>M_(t.watermark)(o),tt(D,D));if(l._2.tag==="CatCons")return et("CatCons",l._2._1,tt(l._2._2._1,yt("Cons",et("CatCons",()=>M_(t.watermark)(o),tt(D,D)),l._2._2._2)));g()})()):K(st("Return",void 0),et("CatCons",()=>M_(t.watermark)(o),tt(D,D)))};return K(_._1,(()=>{if(_._2.tag==="CatNil")return et("CatCons",f,tt(D,D));if(_._2.tag==="CatCons")return et("CatCons",_._2._1,tt(_._2._2._1,yt("Cons",et("CatCons",f,tt(D,D)),_._2._2._2)));g()})())},gL=t=>e=>n=>r=>o=>i=>{const a=i.segment.path.length-1|0,s=a>=0&&a<i.segment.path.length?J("Just",i.segment.path[a]):T;if(s.tag==="Nothing")return K(st("Return",void 0),ct);if(s.tag==="Just"){const u=pi(s._1)(o.segment.layout.nodes);if(u.tag==="Nothing")return K(st("Return",void 0),ct);if(u.tag==="Just"){const c=u._1,_=pi(s._1)(o.state.nodes),f=(()=>{if(_.tag==="Nothing")return Gf;if(_.tag==="Just")return _._1;g()})(),l={color:t.nodeStroke,width:t.wobble?2:1.25,lineJoin:Ze,lineCap:Ir},d={...l,width:1.25},h=iL(r)({x:c.x,y:c.y,w:c.w,h:c.h})(7);return ke({path:o.segment.path,role:o.role,layer:T,effects:[pe("GroupAlpha",o.bgAlpha),pe("GroupTransform",ui,n)]})((()=>{const p=mu({id:s._1,role:Kb,geometry:lu("FlatNode",{shape:c.shape,bounds:{x:c.x,y:c.y+5,w:c.w,h:c.h}}),alpha:1,plan:du("FlatNodePlan",{palette:t,label:c.label,labelVisibility:pu,inkBoost:e?1:0,labelAlpha:0,outlineAlpha:J("Just",1),arrival:T,animState:f})}),m=()=>{const x=ci(ii({path:xo(c),fill:T,stroke:J("Just",l)})),y=()=>{const w=z_(h.leaves)(b=>{const C=ci(ii({path:b.face,fill:J("Just",{color:t.nodeFill,flat:!1}),stroke:T}));if(C._2.tag==="CatNil")return K(C._1,et("CatCons",()=>ci(ii({path:b.outline,fill:T,stroke:J("Just",l)})),tt(D,yt("Cons",et("CatCons",()=>{const L=ke({path:o.segment.path,role:o.role,layer:T,effects:[pe("GroupClip",b.face,mo)]})(S_(ai("AffineText",b.labelAffine))(o.state.animationTime)(t)(1)(1)(s._1)(c)(f)(pi(s._1)(o.state.nodeLabels)));return b.labelVisible?L:K(st("Return",void 0),ct)},tt(D,D)),D))));if(C._2.tag==="CatCons")return K(C._1,et("CatCons",C._2._1,tt(C._2._2._1,yt("Cons",et("CatCons",()=>{const L=ke({path:o.segment.path,role:o.role,layer:T,effects:[pe("GroupClip",b.face,mo)]})(S_(ai("AffineText",b.labelAffine))(o.state.animationTime)(t)(1)(1)(s._1)(c)(f)(pi(s._1)(o.state.nodeLabels)));return b.labelVisible?L:K(st("Return",void 0),ct)},tt(D,D)),yt("Cons",et("CatCons",()=>ci(ii({path:b.outline,fill:T,stroke:J("Just",l)})),tt(D,D)),C._2._2._2)))));g()}),N=()=>z_(h.seams)(b=>{const C=ke({path:o.segment.path,role:o.role,layer:T,effects:[pe("GroupAlpha",b.alpha)]})(ci(ii({path:b.path,fill:T,stroke:J("Just",d)})));return b.alpha>0?C:K(st("Return",void 0),ct)});return K(w._1,(()=>{if(w._2.tag==="CatNil")return et("CatCons",N,tt(D,D));if(w._2.tag==="CatCons")return et("CatCons",w._2._1,tt(w._2._2._1,yt("Cons",et("CatCons",N,tt(D,D)),w._2._2._2)));g()})())};return K(x._1,(()=>{if(x._2.tag==="CatNil")return et("CatCons",y,tt(D,D));if(x._2.tag==="CatCons")return et("CatCons",x._2._1,tt(x._2._2._1,yt("Cons",et("CatCons",y,tt(D,D)),x._2._2._2)));g()})())};return K(p._1,(()=>{if(p._2.tag==="CatNil")return et("CatCons",m,tt(D,D));if(p._2.tag==="CatCons")return et("CatCons",p._2._1,tt(p._2._2._1,yt("Cons",et("CatCons",m,tt(D,D)),p._2._2._2)));g()})())})())}}g()},hp=t=>e=>n=>r=>o=>i=>a=>s=>{const u=[1,e.viewport.vx,e.viewport.vy,2,e.viewport.vx+e.viewport.vw,e.viewport.vy,2,e.viewport.vx+e.viewport.vw,e.viewport.vy+e.viewport.vh,2,e.viewport.vx,e.viewport.vy+e.viewport.vh,5],c=s.state,_={tx:a.segment.placement.tx,ty:a.segment.placement.ty,sx:a.segment.placement.scale,sy:a.segment.placement.scale},f=w_(t.theme),l=s.segment.layout,d={vx:l.bounds.x-1e3,vy:l.bounds.y-1e3,vw:l.bounds.w+2e3,vh:l.bounds.h+2e3},h=s.segment.path.length-1|0,p=h>=0&&h<s.segment.path.length?pi(s.segment.path[h])(a.segment.layout.nodes):T,m=K3(5)(11)(s.segment.placement.scale*n),x=m>0?g_:pu,y=B_(e.viewport)(s),w=(()=>{if(x==="LabelsHidden")return K(st("Return",void 0),ct);if(x==="LabelsShown")return ke({path:s.segment.path,role:s.role,layer:T,effects:m<1?[pe("GroupAlpha",m)]:[]})(o.tag==="Leaf"?op(f)(y)(l)(c):Cu(f)(l)(c)(Zh(y)(o)));g()})(),N={tx:s.segment.placement.tx,ty:s.segment.placement.ty,sx:s.segment.placement.scale,sy:s.segment.placement.scale},b=ke({path:s.segment.path,role:s.role,layer:T,effects:[pe("GroupAlpha",s.bgAlpha)]})((()=>{const L=ke({path:s.segment.path,role:s.role,layer:T,effects:[pe("GroupClip",(()=>{if(Uf(r)>=.52)return u;const I=uL(a)((()=>{const W=s.segment.path.length-1|0;return W>=0&&W<s.segment.path.length?J("Just",s.segment.path[W]):T})());return I.length===0?u:I})(),mo)]})((()=>{const I=(()=>{if(p.tag==="Just")return ke({path:a.segment.path,role:a.role,layer:T,effects:[pe("GroupTransform",ui,_)]})(ci(ii({path:xo({...p._1,x:p._1.x+1,y:p._1.y+1,w:p._1.w-2,h:p._1.h-2}),fill:J("Just",{color:f.bg,flat:!0}),stroke:T})));if(p.tag==="Nothing")return K(st("Return",void 0),ct);g()})(),W=(a.role==="Active"||a.role==="FlyThrough")&&!t.transparentBg?I:K(st("Return",void 0),ct),P=()=>{const G=ke({path:s.segment.path,role:s.role,layer:T,effects:[pe("GroupTransform",ui,N)]})((()=>{const nt=Yh(f)(l)(c),O=()=>{const $=Kh(i)(f)(t.halftoneShadows)(l)(c),H=()=>{const A=ip(z=>i.tag!=="Nothing"&&i.tag==="Just"&&i._1===z?J("Just",0):T)(x)(m)(1)(f)(l)(c),B=()=>{const z=np(f)(l)(c);return K(z._1,(()=>{if(z._2.tag==="CatNil")return et("CatCons",()=>C_(f)(d)(l)(c),tt(D,D));if(z._2.tag==="CatCons")return et("CatCons",z._2._1,tt(z._2._2._1,yt("Cons",et("CatCons",()=>C_(f)(d)(l)(c),tt(D,D)),z._2._2._2)));g()})())};return K(A._1,(()=>{if(A._2.tag==="CatNil")return et("CatCons",B,tt(D,D));if(A._2.tag==="CatCons")return et("CatCons",A._2._1,tt(A._2._2._1,yt("Cons",et("CatCons",B,tt(D,D)),A._2._2._2)));g()})())};return K($._1,(()=>{if($._2.tag==="CatNil")return et("CatCons",H,tt(D,D));if($._2.tag==="CatCons")return et("CatCons",$._2._1,tt($._2._2._1,yt("Cons",et("CatCons",H,tt(D,D)),$._2._2._2)));g()})())};return K(nt._1,(()=>{if(nt._2.tag==="CatNil")return et("CatCons",O,tt(D,D));if(nt._2.tag==="CatCons")return et("CatCons",nt._2._1,tt(nt._2._2._1,yt("Cons",et("CatCons",O,tt(D,D)),nt._2._2._2)));g()})())})()),j=()=>ke({path:s.segment.path,role:s.role,layer:T,effects:[pe("GroupTransform",Ub,N)]})(Uh(cb)(f)(l)(c));return K(G._1,(()=>{if(G._2.tag==="CatNil")return et("CatCons",j,tt(D,D));if(G._2.tag==="CatCons")return et("CatCons",G._2._1,tt(G._2._2._1,yt("Cons",et("CatCons",j,tt(D,D)),G._2._2._2)));g()})())};return K(W._1,(()=>{if(W._2.tag==="CatNil")return et("CatCons",P,tt(D,D));if(W._2.tag==="CatCons")return et("CatCons",W._2._1,tt(W._2._2._1,yt("Cons",et("CatCons",P,tt(D,D)),W._2._2._2)));g()})())})()),E=()=>ke({path:s.segment.path,role:s.role,layer:T,effects:[pe("GroupTransform",ui,N)]})(w);return K(L._1,(()=>{if(L._2.tag==="CatNil")return et("CatCons",E,tt(D,D));if(L._2.tag==="CatCons")return et("CatCons",L._2._1,tt(L._2._2._1,yt("Cons",et("CatCons",E,tt(D,D)),L._2._2._2)));g()})())})()),C=()=>a.role==="FlyThrough"?gL(f)(t.halftoneShadows)(_)(r)(a)(s):K(st("Return",void 0),ct);return K(b._1,(()=>{if(b._2.tag==="CatNil")return et("CatCons",C,tt(D,D));if(b._2.tag==="CatCons")return et("CatCons",b._2._1,tt(b._2._2._1,yt("Cons",et("CatCons",C,tt(D,D)),b._2._2._2)));g()})())},_L=t=>e=>n=>r=>z_(r.minis)(o=>{const i=hp(t)(e)(n)(Wf)(M)(T)(r)(o);return(()=>{const a=o.segment.path.length-1|0;return o.bgAlpha>0&&a>=0&&a<o.segment.path.length&&(()=>{const s=pi(o.segment.path[a])(r.state.nodes);if(s.tag==="Just")return s._1.tag==="Hidden"?!1:s._1.tag!=="PloppingOut";if(s.tag==="Nothing")return!1;g()})()})()?i:K(st("Return",void 0),ct)}),fL=t=>e=>n=>{if(t.theme==="Isometric")return Vk({...Bk,transparentBg:t.transparentBg})(t.theme)(qf(n).segment.layout)(qf(n).state);const r=Ka(t)(n),o={tileScale:n.hasDives?r.vw/D_(1)(n.rootLayout.bounds.w):1,viewport:r},i=s=>u=>{if(u.length===0)return K(st("Return",void 0),ct);const c=Pt(_=>T,_=>f=>J("Just",{head:_,tail:f}),u);if(c.tag==="Nothing")return K(st("Return",void 0),ct);if(c.tag==="Just"){const _=hp(t)(o)(n.camera.zoom)(n.portalState)(c._1.head.role==="Active"?e:M)((()=>{if(c._1.head.role==="FlyThrough"&&0<c._1.tail.length){const f=c._1.tail[0].segment.path.length-1|0;if(f>=0&&f<c._1.tail[0].segment.path.length)return J("Just",c._1.tail[0].segment.path[f])}return T})())(s)(c._1.head);return c._1.head.role==="Active"||c._1.head.role==="FlyThrough"?K(_._1,(()=>{if(_._2.tag==="CatNil")return et("CatCons",()=>i(c._1.head)(c._1.tail),tt(D,D));if(_._2.tag==="CatCons")return et("CatCons",_._2._1,tt(_._2._2._1,yt("Cons",et("CatCons",()=>i(c._1.head)(c._1.tail),tt(D,D)),_._2._2._2)));g()})()):K(st("Return",void 0),et("CatCons",()=>i(c._1.head)(c._1.tail),tt(D,D)))}g()},a=Pt(s=>T,s=>u=>J("Just",{head:s,tail:u}),n.levels);if(a.tag==="Nothing")return K(st("Return",void 0),ct);if(a.tag==="Just"){const s=a._1.tail,u=a._1.head,c=cL(t)(n.hasDives?r.vw/D_(1)(n.rootLayout.bounds.w):1)(u.role==="Active"||u.role==="FlyThrough"?u.bgAlpha:0)((()=>{if(u.role==="FlyThrough"&&0<s.length){const f=s[0].segment.path.length-1|0;if(f>=0&&f<s[0].segment.path.length)return J("Just",s[0].segment.path[f])}return T})())(r)(u.segment.layout)(u.state)(s.length===0&&e.tag!=="Leaf"?dp("SpringLabels",e):sL),_=()=>{const f=_L(t)(o)(n.camera.zoom)(u);return u.role==="Active"||u.role==="FlyThrough"?K(f._1,(()=>{if(f._2.tag==="CatNil")return et("CatCons",()=>i(u)(s),tt(D,D));if(f._2.tag==="CatCons")return et("CatCons",f._2._1,tt(f._2._2._1,yt("Cons",et("CatCons",()=>i(u)(s),tt(D,D)),f._2._2._2)));g()})()):K(st("Return",void 0),et("CatCons",()=>i(u)(s),tt(D,D)))};return K(c._1,(()=>{if(c._2.tag==="CatNil")return et("CatCons",_,tt(D,D));if(c._2.tag==="CatCons")return et("CatCons",c._2._1,tt(c._2._2._1,yt("Cons",et("CatCons",_,tt(D,D)),c._2._2._2)));g()})())}g()},Q_=t=>e=>n=>e3({viewport:Ka(t)(n),camera:n.camera})(fL(t)(e)(n)),lL=t=>e=>{if(e.fill.tag==="Just"){if(e.stroke.tag==="Just")return t.fillStrokePath(e.path)(e.fill._1)(e.stroke._1);if(e.stroke.tag==="Nothing")return t.fillPath(e.path)(e.fill._1);g()}if(e.fill.tag==="Nothing"){if(e.stroke.tag==="Just")return t.strokePath(e.path)(e.stroke._1);if(e.stroke.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()},dL=t=>e=>lL(t)(e._1),hL=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Go(n)(Wt),o=t.popTransform,i=t.popBakedTransform,a=(()=>{const u=t.popClip,c=t.popAlpha,_=t.popBlend,f=t.popBlur;return l=>{if(l.tag==="GroupTransform"){if(l._1==="NormalTransform")return o;if(l._1==="BakedTransform")return i;g()}if(l.tag==="GroupClip")return u;if(l.tag==="GroupAlpha")return c;if(l.tag==="GroupBlend")return _;if(l.tag==="GroupBlur")return f;g()}})(),s=t.popLayer;return u=>e.Bind1().bind(r(a)(ee(u.effects)))(()=>{if(u.layer.tag==="Just")return s;if(u.layer.tag==="Nothing")return n.pure();g()})},pL=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Go(n)(Wt);return o=>e.Bind1().bind((()=>{if(o.layer.tag==="Just")return t.pushLayer(o.layer._1);if(o.layer.tag==="Nothing")return n.pure();g()})())(()=>r(i=>{if(i.tag==="GroupTransform"){if(i._1==="NormalTransform")return t.pushTransform(i._2);if(i._1==="BakedTransform")return t.pushBakedTransform(i._2);g()}if(i.tag==="GroupClip")return t.pushClip(i._1)(i._2);if(i.tag==="GroupAlpha")return t.pushAlpha(i._1);if(i.tag==="GroupBlend")return t.pushBlend(i._1);if(i.tag==="GroupBlur")return t.pushBlur(i._1);g()})(o.effects))},pp=t=>{const e=t.Monad0(),n=ck(t),r=Dk(t),o=Jk(t),i=Uk(t),a=rk(t),s=zk(t);return Zb(e)({beginFrame:u=>t.setViewport(u.viewport),endFrame:e.Applicative0().pure(),beginGroup:pL(t),endGroup:hL(t),background:Z3(t),overlay:dL(t),node:u=>{if(u.geometry.tag==="FlatNode")return n(u);if(u.geometry.tag==="IsoSlab")return r(u);g()},edge:u=>{if(u.geometry.tag==="FlatRoute")return o(u);if(u.geometry.tag==="IsoSegments")return i(u);g()},text:dk(t),token:u=>{if(u.geometry.tag==="FlatToken")return a(u);if(u.geometry.tag==="IsoCube")return s(u);g()},insideTokenStyle:t.insideTokenStyle,measureText:t.measureText,measureInk:t.measureInk})},mL=k_(oh)(u_.measureText),mp=pp(u_),yp=t=>Ka({padding:24,outputAspect:t.width<=0||t.height<=0?T:J("Just",t.width/t.height)}),yL=t=>e=>n=>r=>o=>i=>a=>{const s={padding:24,transparentBg:(()=>{if(e==="TransparentBackground")return!0;if(e==="PaintBackground")return!1;g()})(),halftoneShadows:!1,watermark:"",theme:t,outputAspect:r.width<=0||r.height<=0?T:J("Just",r.width/r.height)},u=eh(n)(r);return()=>{const c=u(),_=o.levels.length-1|0;if(_>=0&&_<o.levels.length){const l=mL(B_(yp(r)(o))(o.levels[_]))(o.levels[_].segment.layout)(o.levels[_].state)(c)(),d=Xg(i)(l)(a);return mp(Q_(s)(d.applied)(o))(c)(),d.springs}const f=Xg(i)(M)(a);return mp(Q_(s)(f.applied)(o))(c)(),f.springs}},ja=t=>"rgb("+ae(t.r)+","+ae(t.g)+","+ae(t.b)+")",mi=t=>t===1?7:t===2?10:t===3?14:t===4?13:t===5?5:t===6?1:t===7?4:t===8?1:t===9?2:t===10?1:t===11?2:t===12?1:t===18?2:t===19?1:t===13?2:t===14?1:t===15||t===16?5:1,le=Do(Io("Fixed",Fo(0)(20)(2))),W_=t=>{const e=n=>{const r=n>=0&&n<t.length?J("Just",t[n]):T;if(r.tag==="Just")return r._1===1?["M",le((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+3|0)]:r._1===2?["L",le((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+3|0)]:r._1===3?["Q",le((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+3|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+4|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+5|0)]:r._1===4?["C",le((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+3|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+4|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+5|0;return o>=0&&o<t.length?t[o]:0})()),le((()=>{const o=n+6|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+7|0)]:r._1===5?["Z",...e(n+1|0)]:[];if(r.tag==="Nothing")return[];g()};return Vn(" ")(e(0))},xL=t=>le(t.vx)+" "+le(t.vy)+" "+le(t.vw)+" "+le(t.vh),Yn=t=>e=>he(nr(e>=0&&e<t.length?t[e]:0)),H_=t=>e=>{const n=Yn(t.ops)(e+1|0);return Rt(n,n+Yn(t.ops)(e+2|0)|0,t.paths)},xp=(()=>{const t=or("&")("&amp;"),e=or("<")("&lt;"),n=(()=>{const r=or(">")("&gt;"),o=(()=>{const i=or('"')("&quot;");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),TL={vx:0,vy:0,vw:1,vh:1},wL=t=>(e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i>=0&&i<t.length){if(t[i]===15){const a=i+1|0;r=!1,o={vx:a>=0&&a<t.length?t[a]:0,vy:(()=>{const s=a+1|0;return s>=0&&s<t.length?t[s]:0})(),vw:(()=>{const s=a+2|0;return s>=0&&s<t.length?t[s]:0})(),vh:(()=>{const s=a+3|0;return s>=0&&s<t.length?t[s]:0})()};continue}n=i+mi(t[i])|0;continue}r=!1,o=TL}return o})(0),Za=t=>e=>({r:Yn(t)(e),g:Yn(t)(e+1|0),b:Yn(t)(e+2|0),a:Yn(t)(e+3|0)}),Tp=t=>e=>({color:Za(t)(e),width:(()=>{const n=e+4|0;return n>=0&&n<t.length?t[n]:0})(),join:Yn(t)(e+5|0),cap:Yn(t)(e+6|0)}),NL=t=>e=>'<rect x="'+le(t.vx)+'" y="'+le(t.vy)+'" width="'+le(t.vw)+'" height="'+le(t.vh)+'" fill="'+ja(e)+'" opacity="'+le(rt(e.a)/255)+'"/>',JL=t=>e=>'<path d="'+W_(t)+'" fill="'+ja(e)+'" fill-opacity="'+le(rt(e.a)/255)+'"/>',wp=t=>' stroke="'+ja(t.color)+'" stroke-opacity="'+le(rt(t.color.a)/255)+'" stroke-width="'+le(t.width)+'" stroke-linejoin="'+(t.join===0?"round":t.join===1?"bevel":"miter")+'" stroke-linecap="'+(t.cap===0?"butt":t.cap===1?"round":"square")+'"',vL=t=>e=>n=>'<path d="'+W_(t)+'" fill="'+ja(e)+'" fill-opacity="'+le(rt(e.a)/255)+'"'+wp(n)+"/>",CL=t=>e=>'<path d="'+W_(t)+'" fill="none"'+wp(e)+"/>",bL=t=>e=>{const n=Za(t.ops)(e+7|0),r=Yn(t.ops)(e+12|0),o=Yn(t.ops)(e+11|0);return'<text x="'+le((()=>{const i=e+1|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'" y="'+le((()=>{const i=e+2|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'"'+(r===0?' dy="0.8em"':r===1?' dy="0.32em"':"")+' fill="'+ja(n)+'" fill-opacity="'+le(rt(n.a)/255)+'" font-size="'+le((()=>{const i=e+5|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'" font-family="'+xp((()=>{const i=Yn(t.ops)(e+4|0);return i>=0&&i<t.strs.length?t.strs[i]+", ui-sans-serif, system-ui, sans-serif":", ui-sans-serif, system-ui, sans-serif"})())+'" font-weight="'+ae(Yn(t.ops)(e+6|0))+'" text-anchor="'+(o===0?"start":o===1?"middle":"end")+'">'+xp((()=>{const i=Yn(t.ops)(e+3|0);return i>=0&&i<t.strs.length?t.strs[i]:""})())+"</text>"},yi=t=>e=>n=>{const r=n>=0&&n<e.ops.length?J("Just",e.ops[n]):T;if(r.tag==="Just")return r._1===1?JL(H_(e)(n))(Za(e.ops)(n+3|0))+yi(t)(e)(n+mi(r._1)|0):r._1===2?CL(H_(e)(n))(Tp(e.ops)(n+3|0))+yi(t)(e)(n+mi(r._1)|0):r._1===3?vL(H_(e)(n))(Za(e.ops)(n+3|0))(Tp(e.ops)(n+7|0))+yi(t)(e)(n+mi(r._1)|0):r._1===4?bL(e)(n)+yi(t)(e)(n+mi(r._1)|0):r._1===16?NL(t)(Za(e.ops)(n+1|0))+yi(t)(e)(n+mi(r._1)|0):yi(t)(e)(n+mi(r._1)|0);if(r.tag==="Nothing")return"";g()},kL=t=>{const e=wL(t.ops);return{viewBox:xL(e),body:yi(e)(t)(0),vx:e.vx,vy:e.vy,vw:e.vw,vh:e.vh}},LL=MC(OC)(d2),Np=t=>e=>{const n=t.strs;return()=>{const r=Tc(n);return t.strs.push(e),r}},bu=t=>e=>{const n=t.paths;return()=>{const r=Tc(n);return t.paths.push(...e),{offset:r,len:e.length}}},SL=t=>e=>{const n=e.tx,r=t.ops;return()=>{r.push(n),t.ops.push(e.ty),t.ops.push(e.sx),t.ops.push(e.sy)}},Jp=t=>e=>{const n=e.vx,r=t.ops;return()=>{r.push(n),t.ops.push(e.vy),t.ops.push(e.vw),t.ops.push(e.vh)}},eo=t=>e=>{const n=rt(e),r=t.ops;return()=>{r.push(n)}},ku=t=>e=>{const n=e.len,r=eo(t)(e.offset);return()=>(r(),eo(t)(n)())},EL=()=>{const t=[],e=[],n=[],r=[];return r.push(1),{ops:t,paths:e,strs:n,alphaStack:r}},PL=t=>{if(t.tag==="MeasureText"){const e=t._3(jg(t._1)(t._2));return()=>e}if(t.tag==="MeasureInk"){const e=t._3(Zg(t._1)(t._2));return()=>e}g()},vp=t=>{const e=t.alphaStack;return()=>{const n=Tc(e);if(n===0)return 1;const r=p2(Vt,T,n-1|0,t.alphaStack);if(r.tag==="Nothing")return 1;if(r.tag==="Just")return r._1;g()}},xi=t=>e=>{const n=vp(t);return()=>{const r=n();return eo(t)(e.r)(),eo(t)(e.g)(),eo(t)(e.b)(),eo(t)(he(nr(rt(e.a)*r+.5)))()}},Cp=t=>e=>{const n=xi(t)(e.color);return()=>{n(),t.ops.push(e.width),t.ops.push((()=>{if(e.lineJoin==="RoundJoin")return 0;if(e.lineJoin==="BevelJoin")return 1;if(e.lineJoin==="MiterJoin")return 2;g()})()),t.ops.push((()=>{if(e.lineCap==="ButtCap")return 0;if(e.lineCap==="RoundCap")return 1;if(e.lineCap==="SquareCap")return 2;g()})())}},GL=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r;if(s.tag==="FillPath"){const u=s._3,c=s._2,_=bu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(1),ku(a)(f)(),xi(a)(c.color)(),u};continue}if(s.tag==="StrokePath"){const u=s._3,c=s._2,_=bu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(2),ku(a)(f)(),Cp(a)(c)(),u};continue}if(s.tag==="FillStrokePath"){const u=s._2,c=s._4,_=s._3,f=bu(a)(s._1);o=!1,i=()=>{const l=f();return a.ops.push(3),ku(a)(l)(),xi(a)(u.color)(),Cp(a)(_)(),c};continue}if(s.tag==="DrawText"){const u=s._2,c=s._1,_=Np(a)($o(c.content));o=!1,i=()=>{const f=_(),l=Np(a)(c.font.family)();return a.ops.push(4),a.ops.push(c.x),a.ops.push(c.y),eo(a)(f)(),eo(a)(l)(),a.ops.push(c.font.size),eo(a)(c.font.weight)(),xi(a)(c.color)(),a.ops.push((()=>{if(c.align==="AlignLeft")return 0;if(c.align==="AlignCenter")return 1;if(c.align==="AlignRight")return 2;g()})()),a.ops.push((()=>{if(c.baseline==="BaselineTop")return 0;if(c.baseline==="BaselineMiddle")return 1;if(c.baseline==="BaselineAlphabetic")return 2;if(c.baseline==="BaselineBottom")return 3;g()})()),u};continue}if(s.tag==="DrawTextAffine"){n=a,r=Xt("DrawText",{...s._2,x:s._1.a*s._2.x+s._1.c*s._2.y+s._1.e,y:s._1.b*s._2.x+s._1.d*s._2.y+s._1.f},s._3);continue}if(s.tag==="PushTransform"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(5),SL(a)(c)(),u);continue}if(s.tag==="PopTransform"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(6),u);continue}if(s.tag==="PushClip"){const u=s._3,c=s._2,_=bu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(7),ku(a)(f)(),a.ops.push((()=>{if(c==="NonZero")return 0;if(c==="EvenOdd")return 1;g()})()),u};continue}if(s.tag==="PopClip"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(8),u);continue}if(s.tag==="PushBlend"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(9),a.ops.push((()=>{if(u==="Normal")return 0;if(u==="Difference")return 1;g()})()),c);continue}if(s.tag==="PopBlend"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(10),u);continue}if(s.tag==="PushAlpha"){const u=s._1,c=s._2,_=vp(a);o=!1,i=()=>{const f=_();return a.alphaStack.push(f*u),a.ops.push(11),a.ops.push(u),c};continue}if(s.tag==="PopAlpha"){const u=s._1,c=a.alphaStack;o=!1,i=()=>(m2(Vt,T,c),a.ops.push(12),u);continue}if(s.tag==="PushBlur"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(18),a.ops.push(c),u);continue}if(s.tag==="PopBlur"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(19),u);continue}if(s.tag==="PushLayer"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(13),a.ops.push((()=>{if(u==="LayerBase")return 0;if(u==="LayerPolyOut")return 1;if(u==="LayerPolyIn")return 2;if(u==="LayerNodeMask")return 3;if(u==="LayerOverlay")return 4;g()})()),c);continue}if(s.tag==="PopLayer"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(14),u);continue}if(s.tag==="SetViewport"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(15),Jp(a)(c)(),u);continue}if(s.tag==="ClearBackground"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(16),xi(a)(u)(),c);continue}if(s.tag==="BackgroundDots"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(17),Jp(a)(c.viewport)(),xi(a)(c.bgColor)(),xi(a)(c.dotColor)(),a.ops.push(c.tile),a.ops.push(c.dotRadius),a.ops.push(c.origin.x),a.ops.push(c.origin.y),u);continue}g()}return i},RL=t=>e=>e.type==="metrics"?PL(e.value):e.type==="render"?GL(t)(e.value):gf("Data.Functor.Variant: pattern match failure ["+e.type+"]"),AL=t=>{const e=EL();return LL(RL(e))(t)(),{ops:e.ops,paths:e.paths,strs:e.strs}},IL=t=>t,ts=t=>t,O_=ts("Light"),FL=ts("Dark"),DL=ts("Blueprint"),zL=ts("Whiteboard"),BL=ts("Isometric"),ML=IL("TransparentBackground"),Jo=t=>"rgb("+ae(t.r)+","+ae(t.g)+","+ae(t.b)+")",Lu=Do(Io("Fixed",Fo(0)(20)(6))),Br=Do(Io("Fixed",Fo(0)(20)(4))),QL=t=>"translate("+Br(t.tx)+","+Br(t.ty)+") scale("+Br(t.sx)+","+Br(t.sy)+")",Ot=Do(Io("Fixed",Fo(0)(20)(2))),q_=t=>{const e=[];let n=0;for(;n<t.length;){const r=n,o=r>=0&&r<t.length?J("Just",t[r]):T;if(o.tag==="Nothing"){n=t.length;continue}if(o.tag==="Just"){if(o._1===1){e.push("M"),e.push(Ot((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),n=r+3|0;continue}if(o._1===2){e.push("L"),e.push(Ot((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),n=r+3|0;continue}if(o._1===3){e.push("Q"),e.push(Ot((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+3|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+4|0;return i>=0&&i<t.length?t[i]:0})())),n=r+5|0;continue}if(o._1===4){e.push("C"),e.push(Ot((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+3|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+4|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+5|0;return i>=0&&i<t.length?t[i]:0})())),e.push(Ot((()=>{const i=r+6|0;return i>=0&&i<t.length?t[i]:0})())),n=r+7|0;continue}if(o._1===5){e.push("Z"),n=r+1|0;continue}n=t.length;continue}g()}return Vn(" ")(e)},WL={map:t=>e=>n=>{const r=e(n);return()=>{const o=r();return t(o)}}},V_=(()=>{const t=or("&")("&amp;"),e=or("<")("&lt;"),n=(()=>{const r=or(">")("&gt;"),o=(()=>{const i=or('"')("&quot;");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),HL=t=>{if(t.style==="RunText"||t.style==="RunHighlight")return"<tspan>"+V_(t.text)+"</tspan>";if(t.style==="RunCode"||t.style==="RunCodeHighlight")return`<tspan font-family="'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace" font-weight="400">`+V_(t.text)+"</tspan>";g()},$e=t=>e=>{const n=e.maskDepth;return()=>{n.value===0&&e.out.push(t)}},OL=t=>e=>{const n=[];let r=0;const o=i=>{const a=i>=0&&i<e.length?t.sx*e[i]+t.tx:t.sx*0+t.tx;return()=>{n.push(a),n.push((()=>{const s=i+1|0;return s>=0&&s<e.length?t.sy*e[s]+t.ty:t.sy*0+t.ty})())}};for(;r<e.length;){const i=r,a=i>=0&&i<e.length?J("Just",e[i]):T;if(a.tag==="Nothing"){r=e.length;continue}if(a.tag==="Just"){if(a._1===1){n.push(a._1),o(i+1|0)(),r=i+3|0;continue}if(a._1===2){n.push(a._1),o(i+1|0)(),r=i+3|0;continue}if(a._1===3){n.push(a._1),o(i+1|0)(),o(i+3|0)(),r=i+5|0;continue}if(a._1===4){n.push(a._1),o(i+1|0)(),o(i+3|0)(),o(i+5|0)(),r=i+7|0;continue}if(a._1===5){n.push(a._1),r=i+1|0;continue}r=e.length;continue}g()}return n},Su=t=>e=>{const n=t.bake;return()=>{const r=n.value;if(r.tag==="Nothing")return e;if(r.tag==="Just")return OL(r._1)(e);g()}},bp={apply:t=>e=>n=>{const r=t(n),o=e(n);return()=>{const i=r(),a=o();return i(a)}},Functor0:()=>WL},qL={bind:t=>e=>n=>{const r=t(n);return()=>{const o=r();return e(o)(n)()}},Apply0:()=>bp},VL={pure:t=>e=>()=>t,Apply0:()=>bp},kp={Applicative0:()=>VL,Bind1:()=>qL},$L=t=>e=>'<defs><pattern id="'+t+'" x="'+Ot(e.origin.x)+'" y="'+Ot(e.origin.y)+'" width="'+Ot(e.tile)+'" height="'+Ot(e.tile)+'" patternUnits="userSpaceOnUse">'+(e.bgColor.a===0?"":'<rect width="'+Ot(e.tile)+'" height="'+Ot(e.tile)+'" fill="'+Jo(e.bgColor)+'" fill-opacity="'+Ot(rt(e.bgColor.a)/255)+'"/>')+'<circle cx="'+Ot(e.tile/2)+'" cy="'+Ot(e.tile/2)+'" r="'+Ot(e.dotRadius)+'" fill="'+Jo(e.dotColor)+'"/></pattern></defs><rect x="'+Ot(e.viewport.vx)+'" y="'+Ot(e.viewport.vy)+'" width="'+Ot(e.viewport.vw)+'" height="'+Ot(e.viewport.vh)+'" fill="url(#'+t+')"/>',Lp=t=>e=>'<path d="'+q_(t)+'" fill="'+Jo(e)+'" fill-opacity="'+Ot(rt(e.a)/255)+'"/>',UL=t=>e=>n=>r=>'<rect x="'+Ot(t.x)+'" y="'+Ot(t.y)+'" width="'+Ot(t.w)+'" height="'+Ot(t.h)+'" rx="'+Ot(e)+'"'+(()=>{if(n.tag==="Just")return' fill="'+Jo(n._1.color)+'" fill-opacity="'+Ot(rt(n._1.color.a)/255)+'"';if(n.tag==="Nothing")return' fill="none"';g()})()+(()=>{if(r.tag==="Just")return' stroke="'+Jo(r._1.color)+'" stroke-opacity="'+Ot(rt(r._1.color.a)/255)+'" stroke-width="'+Ot(r._1.width)+'" stroke-linejoin="'+(()=>{if(r._1.lineJoin==="RoundJoin")return"round";if(r._1.lineJoin==="BevelJoin")return"bevel";if(r._1.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(r._1.lineCap==="ButtCap")return"butt";if(r._1.lineCap==="RoundCap")return"round";if(r._1.lineCap==="SquareCap")return"square";g()})()+'"';if(r.tag==="Nothing")return"";g()})()+"/>",Sp=t=>e=>'<path d="'+q_(t)+'" fill="none" stroke="'+Jo(e.color)+'" stroke-opacity="'+Ot(rt(e.color.a)/255)+'" stroke-width="'+Ot(e.width)+'" stroke-linejoin="'+(()=>{if(e.lineJoin==="RoundJoin")return"round";if(e.lineJoin==="BevelJoin")return"bevel";if(e.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(e.lineCap==="ButtCap")return"butt";if(e.lineCap==="RoundCap")return"round";if(e.lineCap==="SquareCap")return"square";g()})()+'"/>',Ep=t=>{const e=sr($o(t.content));return'<text x="'+Ot(t.x)+'" y="'+Ot(t.y)+'"'+(()=>{if(t.baseline==="BaselineTop")return' dy="0.8em"';if(t.baseline==="BaselineMiddle")return' dy="0.32em"';if(t.baseline==="BaselineAlphabetic"||t.baseline==="BaselineBottom")return"";g()})()+' fill="'+Jo(t.color)+'" fill-opacity="'+Ot(rt(t.color.a)/255)+'" font-size="'+Ot(t.font.size)+'" font-family="Ilisarniq, ui-sans-serif, system-ui, sans-serif" font-weight="'+ae(t.font.weight)+'" text-anchor="'+(()=>{if(t.align==="AlignLeft")return"start";if(t.align==="AlignCenter")return"middle";if(t.align==="AlignRight")return"end";g()})()+'">'+(e.length===1&&e[0].style==="RunText"?V_(e[0].text):Vn("")(V(HL)(e)))+"</text>"},XL=t=>"matrix("+Br(t.a)+" "+Br(t.b)+" "+Br(t.c)+" "+Br(t.d)+" "+Br(t.e)+" "+Br(t.f)+")",Pp={fillPath:t=>e=>n=>{const r=Su(n)(t);return()=>{const o=r();return $e(Lp(o)(e.color))(n)()}},strokePath:t=>e=>n=>{const r=Su(n)(t);return()=>{const o=r(),i=n.bake.value;return $e(Sp(o)((()=>{if(i.tag==="Nothing")return e;if(i.tag==="Just")return{...e,width:i._1.sx*e.width};g()})()))(n)()}},fillStrokePath:t=>e=>n=>r=>{const o=Su(r)(t);return()=>{const i=o(),a=r.bake.value;return $e(Lp(i)(e.color)+Sp(i)((()=>{if(a.tag==="Nothing")return n;if(a.tag==="Just")return{...n,width:a._1.sx*n.width};g()})()))(r)()}},drawRoundedRect:t=>e=>n=>r=>o=>{const i=o.bake;return()=>{const a=i.value;return $e(UL((()=>{if(a.tag==="Nothing")return t;if(a.tag==="Just")return{x:a._1.sx*t.x+a._1.tx,y:a._1.sy*t.y+a._1.ty,w:a._1.sx*t.w,h:a._1.sy*t.h};g()})())((()=>{if(a.tag==="Nothing")return e;if(a.tag==="Just")return a._1.sx*e;g()})())(n)(r.tag==="Just"?J("Just",(()=>{if(a.tag==="Nothing")return r._1;if(a.tag==="Just")return{...r._1,width:a._1.sx*r._1.width};g()})()):T))(o)()}},drawText:t=>e=>{const n=e.bake;return()=>{const r=n.value;return $e(Ep((()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return{...t,x:r._1.sx*t.x+r._1.tx,y:r._1.sy*t.y+r._1.ty,font:{...t.font,size:r._1.sx*t.font.size}};g()})()))(e)()}},drawTextAffine:t=>e=>$e((()=>{const n='transform="'+XL(t)+'"';return(n===""?"<g>":"<g "+n+">")+Ep(e)+"</g>"})()),pushTransform:t=>$e((()=>{const e='transform="'+QL(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popTransform:$e("</g>"),pushBakedTransform:t=>e=>{const n=e.bake;return()=>{n.value=J("Just",t)}},popBakedTransform:t=>{const e=t.bake;return()=>{e.value=T}},pushClip:t=>e=>n=>{const r=n.clipCounter;return()=>{const o=r.value;n.clipCounter.value=o+1|0;const i=Su(n)(t)(),a="clip"+ae(o);return $e((()=>{const s='clip-path="url(#'+a+')"';return'<defs><clipPath id="'+a+'"><path d="'+q_(i)+'"'+(()=>{if(e==="EvenOdd")return' clip-rule="evenodd"';if(e==="NonZero")return"";g()})()+"/></clipPath></defs>"+(s===""?"<g>":"<g "+s+">")})())(n)()}},popClip:$e("</g>"),pushBlend:t=>$e((()=>{const e=(()=>{if(t==="Normal")return'style="mix-blend-mode: normal"';if(t==="Difference")return'style="mix-blend-mode: difference"';g()})();return e===""?"<g>":"<g "+e+">"})()),popBlend:$e("</g>"),pushAlpha:t=>$e((()=>{const e='opacity="'+Ot(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popAlpha:$e("</g>"),pushBlur:t=>e=>{if(t<.01)return $e("<g>")(e);const n=e.patternCounter;return()=>{const r=n.value;e.patternCounter.value=r+1|0;const o="lvl-blur-"+ae(r);return $e((()=>{const i='filter="url(#'+o+')"';return'<defs><filter id="'+o+'" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="'+Ot(t)+'"/></filter></defs>'+(i===""?"<g>":"<g "+i+">")})())(e)()}},popBlur:$e("</g>"),pushLayer:t=>e=>{const n=(()=>{if(t==="LayerNodeMask"){const r=e.maskDepth;return()=>{const o=r.value;e.maskDepth.value=o+1|0}}return()=>{}})();return()=>{n(),e.out.push("<g>")}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;n>0&&(t.maskDepth.value=r),t.out.push("</g>")}},setViewport:t=>e=>()=>{},clearBackground:t=>e=>$e('<rect x="'+Ot(e.viewport.vx)+'" y="'+Ot(e.viewport.vy)+'" width="'+Ot(e.viewport.vw)+'" height="'+Ot(e.viewport.vh)+'" fill="'+Jo(t)+'" opacity="'+Ot(rt(t.a)/255)+'"/>')(e),backgroundDots:t=>e=>{const n=e.patternCounter;return()=>{const r=n.value;return e.patternCounter.value=r+1|0,$e($L("bg-dots-"+ae(r))(t))(e)()}},measureText:t=>e=>n=>{const r=jg(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Zg(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>i_,Monad0:()=>kp},YL=pp(Pp),KL=k_(kp)(Pp.measureText),jL=t=>e=>n=>r=>o=>{const i={padding:24,transparentBg:(()=>{if(r==="TransparentBackground")return!0;if(r==="PaintBackground")return!1;g()})(),halftoneShadows:!1,watermark:"",theme:n,outputAspect:t},a=Ka(i)(o);return{viewBox:Lu(a.vx)+" "+Lu(a.vy)+" "+Lu(a.vw)+" "+Lu(a.vh),body:(()=>{const s=[],u={value:0},c={value:0},_={value:0},f={value:T};return YL(Q_(i)(e)(o))({out:s,maskDepth:u,clipCounter:c,patternCounter:_,viewport:a,bake:f})(),Vn("")(s)})(),vx:a.vx,vy:a.vy,vw:a.vw,vh:a.vh}},ZL=t=>e=>n=>r=>o=>i=>{const a={padding:24,transparentBg:(()=>{if(n==="TransparentBackground")return!0;if(n==="PaintBackground")return!1;g()})(),outputAspect:t},s=Xg(o)((()=>{const u=[],c={value:0},_={value:0},f={value:0},l={value:T},d=r.levels.length-1|0;if(d>=0&&d<r.levels.length){const h=B_(Ka(a)(r))(r.levels[d]);return KL(h)(r.levels[d].segment.layout)(r.levels[d].state)({out:u,maskDepth:c,clipCounter:_,patternCounter:f,viewport:h,bake:l})()}return M})())(i);return{parts:jL(t)(s.applied)(e)(n)(r),springs:s.springs}},Gp=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Rp=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Eu=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Ap=t=>e=>Gp(t.lo)(e.lo)<=Rp(t.hi)(e.hi)?J("Just",{lo:Gp(t.lo)(e.lo),hi:Rp(t.hi)(e.hi)}):T,$_=t=>e=>{const n=(()=>{if(e.tag==="Just")return Ap(t)(e._1);if(e.tag==="Nothing")return T;g()})();if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},Pu={deadZoneWidth:.85,deadZoneHeight:1,hardZoneWidth:.85,hardZoneHeight:1},Ip=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>{const f=r<=o?{lo:n+r-o/2,hi:n+o/2}:{lo:n+o/2,hi:n+r-o/2},l=a.tag==="Just"?J("Just",a._1.size<=o?{lo:a._1.lo+a._1.size-o/2,hi:a._1.lo+o/2}:{lo:a._1.lo+o/2,hi:a._1.lo+a._1.size-o/2}):T,d=(()=>{if(a.tag==="Just")return a._1.size<=o;if(a.tag==="Nothing")return!1;g()})(),h=(()=>{if(d){if(l.tag==="Nothing")return f;if(l.tag==="Just")return l._1;g()}const y=(()=>{if(l.tag==="Just")return Ap(f)(l._1);if(l.tag==="Nothing")return T;g()})();if(y.tag==="Nothing")return f;if(y.tag==="Just")return y._1;g()})(),p=$_(h)(s.tag==="Just"?J("Just",(()=>{const y=o*e;if(y<s._1.size){const w=s._1.lo+s._1.size/2;return{lo:w,hi:w}}return{lo:s._1.lo+s._1.size-y/2,hi:s._1.lo+y/2}})()):T),m=(()=>{if(a.tag==="Just")return Eu(h.lo)(h.hi)(a._1.lo+a._1.size/2);if(a.tag==="Nothing")return Eu(h.lo)(h.hi)(i);g()})(),x=$_(c.tag==="Just"&&c._1.size<=o?$_(p)(J("Just",(()=>{if(o<c._1.size){const y=c._1.lo+c._1.size/2;return{lo:y,hi:y}}return{lo:c._1.lo+c._1.size-o/2,hi:c._1.lo+o/2}})())):p)(s.tag==="Just"?J("Just",(()=>{const y=o*t;if(y<s._1.size){const w=s._1.lo+s._1.size/2;return{lo:w,hi:w}}return{lo:s._1.lo+s._1.size-y/2,hi:s._1.lo+y/2}})()):T);if(u.tag==="Just"){const y=u.tag==="Just"&&_.tag==="Just"&&re(_._1)>.001?u._1.lo+u._1.size/2+_._1*o/6:i;return d?m:Eu(x.lo)(x.hi)(y)}if(u.tag==="Nothing"){const y=s.tag==="Just"&&_.tag==="Just"&&re(_._1)>.001?s._1.lo+s._1.size/2+_._1*o/6:i;return d?m:Eu(x.lo)(x.hi)(y)}g()},Gu=t=>e=>n=>r=>o=>({x:Ip(t.deadZoneWidth)(t.hardZoneWidth)(e.x)(e.w)(n.w)(r.x)(o.visibleBounds.tag==="Just"?J("Just",{lo:o.visibleBounds._1.x,size:o.visibleBounds._1.w}):T)(o.subject.tag==="Just"?J("Just",{lo:o.subject._1.x,size:o.subject._1.w}):T)(o.guide.tag==="Just"?J("Just",{lo:o.guide._1.x,size:o.guide._1.w}):T)(o.mustSee.tag==="Just"?J("Just",{lo:o.mustSee._1.x,size:o.mustSee._1.w}):T)(o.lookAhead.tag==="Just"?J("Just",o.lookAhead._1.x):T),y:Ip(t.deadZoneHeight)(t.hardZoneHeight)(e.y)(e.h)(n.h)(r.y)(o.visibleBounds.tag==="Just"?J("Just",{lo:o.visibleBounds._1.y,size:o.visibleBounds._1.h}):T)(o.subject.tag==="Just"?J("Just",{lo:o.subject._1.y,size:o.subject._1.h}):T)(o.guide.tag==="Just"?J("Just",{lo:o.guide._1.y,size:o.guide._1.h}):T)(o.mustSee.tag==="Just"?J("Just",{lo:o.mustSee._1.y,size:o.mustSee._1.h}):T)(o.lookAhead.tag==="Just"?J("Just",o.lookAhead._1.y):T)}),ge=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},mn=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Kn=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},t5=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Cn=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ti=Nc(sa),Fp=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},no=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},e5=t=>t,n5=t=>e=>mn(0)(1)((t-e.pre)/ge(.05)(1-e.pre-e.post)),Dp=t=>e=>n=>{const r=Kn(n)(t.nodes),o=Kn(e)(t.nodes);if(o.tag==="Just"&&r.tag==="Just"){const i=r._1.x+r._1.w/2-(o._1.x+o._1.w/2),a=r._1.y+r._1.h/2-(o._1.y+o._1.h/2),s=ge(re(i))(re(a));return s<=.001?{x:0,y:0}:{x:i/s,y:a/s}}return{x:0,y:0}},U_=t=>e=>n=>r=>o=>i=>{const a=s=>{if(s)return 0<e.length?e[0]:{x:0,y:0};const u=e.length-1|0;return u>=0&&u<e.length?e[u]:{x:0,y:0}};return Zx(e)((()=>{const s=a(!0),u=Kn(n)(t.nodes);return u.tag==="Just"?{x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2}:s})())((()=>{const s=a(!1),u=Kn(r)(t.nodes);return u.tag==="Just"?{x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2}:s})())(o)(i)},r5=t=>e=>t.labelBasePx*.62*rt(v(t5)(0)(V($x)(Et(e)(n=>zi(`
8
- `)(n))))),o5=t=>e=>rt(Pn(ur(e)))*t*.62,i5=t=>{const e=r=>o=>i=>{let a=r,s=o,u=i,c=!0,_;for(;c;){const f=a,l=s,d=Pt(h=>T,h=>p=>J("Just",{head:h,tail:p}),u);if(d.tag==="Nothing"){c=!1,_=wt(f)(l);continue}if(d.tag==="Just"){if(re(l.endT-d._1.head.startT)<1e-4){const h={...l.toCam,zoom:ge(l.toCam.zoom)(d._1.head.fromCam.zoom)};a=wt(f)({...l,toCam:h}),s={...d._1.head,fromCam:h},u=d._1.tail;continue}a=wt(f)(l),s=d._1.head,u=d._1.tail;continue}g()}return _},n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),t);if(n.tag==="Nothing")return[];if(n.tag==="Just")return e([])(n._1.head)(n._1.tail);g()},Ru=(()=>{const t=v(e=>n=>{const r=e.previous.tag==="Just"&&re(e.previous._1.endT-n.startT)<1e-4?{...n,fromCam:e.previous._1.toCam}:n;return{previous:J("Just",r),spans:wt(e.spans)(r)}})({previous:T,spans:[]});return e=>t(e).spans})(),zp=t=>e=>n=>{const r=(t+e)/2,o=n-r,i=o<0?-1:1,a=(e-t)/2,s=a*.15,u=a-s,c=o<0?-o:o;return e<=t?(t+e)/2:c<=u?n:r+i*(a-s*Pi(-(c-u)/s))},Au=t=>e=>n=>r=>{const o=ne(i=>Ti(i.path)(e)&&(re(i.endT-n)<1e-4||re(i.startT-r)<1e-4))(t.segments);if(o.tag==="Just")return J("Just",o._1);if(o.tag==="Nothing")return ne(i=>Ti(i.path)(e))(t.segments);g()},a5=t=>Tt(e=>{const n=lT(t)(ge(e.startT)(e.endT-1e-4));if(n.tag==="Nothing")return T;if(n.tag==="Just")return J("Just",{startT:e.startT,endT:e.endT,bbox:t.layout.bounds,priority:0});g()}),X_=(()=>{const t=(n,r,o,i,a)=>{let s=n,u=r,c=o,_=i,f=a,l=!0,d;for(;l;){if(s===0){const h=Pt(p=>T,p=>m=>J("Just",{head:p,tail:m}),u);if(h.tag==="Nothing"){l=!1,d=[];continue}if(h.tag==="Just"){s=1,u=h._1.head,c=h._1.head,_=!1,f=h._1.tail;continue}g()}if(s===1){const h=u,p=c,m=_,x=f,y=Pt(w=>T,w=>N=>J("Just",{head:w,tail:N}),x);if(y.tag==="Just"&&p.intent==="Overview"&&y._1.head.intent==="Overview"&&!(p.fromCam.zoom===p.toCam.zoom&&p.fromCam.center.x===p.toCam.center.x&&p.fromCam.center.y===p.toCam.center.y)&&!(y._1.head.fromCam.zoom===y._1.head.toCam.zoom&&y._1.head.fromCam.center.x===y._1.head.toCam.center.x&&y._1.head.fromCam.center.y===y._1.head.toCam.center.y)&&re(p.toCam.center.x-y._1.head.fromCam.center.x)<1e-4&&re(p.toCam.center.y-y._1.head.fromCam.center.y)<1e-4&&re(p.toCam.zoom-y._1.head.fromCam.zoom)<1e-4&&re(p.endT-y._1.head.startT)<1e-4){s=1,u=h,c=y._1.head,_=!0,f=y._1.tail;continue}l=!1,d=[m?{...h,endT:p.endT,toCam:p.toCam,easing:p.easing,interp:qn}:h,...e(x)]}}return d},e=n=>t(0,n);return e})(),s5=t=>e=>{const n=E_({width:t.widthPx,height:t.heightPx})({vx:e.bounds.x,vy:e.bounds.y,vw:e.bounds.w,vh:e.bounds.h});return{w:n.vw,h:n.vh}},Y_=t=>e=>n=>r=>{const o=ge(n.center.x-r.x)(r.x+r.w-n.center.x),i=ge(n.center.y-r.y)(r.y+r.h-n.center.y),a=s5(t)(e);return Cn(o<=0?n.zoom:a.w/(o*2))(i<=0?n.zoom:a.h/(i*2))},Bp=t=>e=>n=>r=>o=>{const i=(s,u)=>{const c=An(u);return Tn(Ht(_=>f=>{const l=t*1.2,d=s.y+s.h/2-rt(c.length)*l/2+rt(_)*l;return v(h=>p=>{const m=rt(Pn(ur(p.text)))*t*.62;return{x:h.x+m,boxes:p.style==="RunHighlight"||p.style==="RunCodeHighlight"?wt(h.boxes)({x:h.x,y:d,w:m,h:l}):h.boxes}})({x:s.x+s.w/2-rt(Pn(ur(f)))*t*.62/2,boxes:[]})(sr(f)).boxes})(c))},a=Kn(n)(e.layout.nodes);if(a.tag==="Just"){const s=[...i(a._1,r),...i(a._1,o)];return s.length===0?T:J("Just",pr(s))}if(a.tag==="Nothing")return T;g()},Mp=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=_r(s);if(u.tag==="Just"&&u._1.last.intent==="Overview"){n=[u._1.last,...a],r=u._1.init;continue}o=!1,i={prefix:s,overview:a}}return i},u5=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=Pt(c=>T,c=>_=>J("Just",{head:c,tail:_}),s);if(u.tag==="Just"&&u._1.head.intent==="Overview"){n=wt(a)(u._1.head),r=u._1.tail;continue}o=!1,i={overview:a,rest:s}}return i},c5=t=>e=>n=>r=>{const o=v(ge)(r.startT-t.maxTransition)(Tt(i=>i.startT>r.startT+1e-4?T:i.target.tag==="NodeWindow"&&i.target._2==="PlopIn"&&i.target._1===r.target?J("Just",i.startT):T)(e.windows));return mn(0)(1)((n-o)/ge(1e-4)(r.startT-o))},g5=t=>e=>n=>{const r=Tt(o=>o.scene.tag==="StepScene"?J("Just",o.startT):T)(e.spans);return v(o=>i=>{const a=Or(Vt,T,s=>s.startT<i+1e-4&&s.endT>=i-1e-4,o);if(a.tag==="Nothing")return o;if(a.tag==="Just"){const s=a._1>=0&&a._1<o.length?J("Just",o[a._1]):T;if(s.tag==="Nothing")return o;if(s.tag==="Just"){if(s._1.startT>=i-1e-4)return o;const u=ne(p=>p>i+1e-4)(r),c=(()=>{if(u.tag==="Nothing")return e.endT;if(u.tag==="Just")return u._1;g()})(),_=Gt(at.compare)(Tt(p=>p.startT>=i-1e-4&&p.startT<c-1e-4&&(p.target.tag==="RelabelWindow"||(p.target.tag==="EdgeWindow"?p.target._2.tag==="Extend":p.target.tag==="TokenWindow"||p.target.tag==="FillWindow"))?J("Just",p.startT):T)(e.windows)),f=0<_.length?_[0]:i,l=a._1+1|0,d=l<1?o:Rt(l,o.length,o),h=Or(Vt,T,p=>p.intent==="ActionFocus"&&p.startT>=f-1e-4&&p.startT<c-1e-4,d);if(h.tag==="Nothing")return o;if(h.tag==="Just"){const p=h._1>=0&&h._1<d.length?J("Just",d[h._1]):T;if(p.tag==="Nothing")return o;if(p.tag==="Just"){const m=(a._1+h._1|0)+2|0,x=m<1?o:Rt(m,o.length,o),y=s._1.toCam.zoom===p._1.toCam.zoom&&s._1.toCam.center.x===p._1.toCam.center.x&&s._1.toCam.center.y===p._1.toCam.center.y?s._1.fromCam:s._1.toCam,w=wt(a._1<1?[]:Rt(0,a._1,o))({...s._1,endT:i,toCam:y}),N=p._1.startT-i;if(N<=1e-4)return[...w,{...p._1,fromCam:y},...x];const b=y.zoom===p._1.toCam.zoom&&y.center.x===p._1.toCam.center.x&&y.center.y===p._1.toCam.center.y,C=b?i+0:i+Cn(N)(jc(t)(y)(p._1.toCam)),L={...p._1,startT:C,endT:p._1.startT,fromCam:p._1.toCam,toCam:p._1.toCam},E={...p._1,startT:i,endT:C,fromCam:y};return[...w,...b?[]:[E],...L.endT>L.startT+1e-4?[L]:[],{...p._1,fromCam:p._1.toCam},...x]}}}}g()})(n)(r)},_5=t=>e=>n=>r=>({...r,fromCam:Tf(t)(e)(n)(r.fromCam),toCam:Tf(t)(e)(n)(r.toCam)}),f5=t=>e=>n=>r=>o=>i=>a=>{const s=a*a*(3-2*a),u=Dp(t)(e)(n),c=(()=>{if(r)return 1;const f=mn(0)(1)(i/.12);return f*f*(3-2*f)})(),_={x:0+(u.x-0)*c,y:0+(u.y-0)*c};if(o.tag==="Just"){const f=Dp(t)(o._1.source)(o._1.target);return{x:_.x+(f.x-_.x)*s,y:_.y+(f.y-_.y)*s}}if(o.tag==="Nothing")return _;g()},l5=t=>e=>n=>ue(r=>r.endT<=e&&r.target.tag==="RelabelWindow"&&r.target._1===n,t),d5=t=>e=>n=>{const r=Kn(n)(t.layout.nodes),o=r.tag==="Just"&&r._1.label!==""?r._1.label:n,i=Wi(t)(e),a=(()=>{if(i.tag==="AtKeyframe")return Fp(i._1)(t.keyframes);if(i.tag==="InTransition")return Fp(l5(t.windows)(e)(n)?i._2:i._1)(t.keyframes);g()})(),s=(()=>{if(a.tag==="Just")return Kn(n)(a._1.labels);if(a.tag==="Nothing")return T;g()})();if(s.tag==="Nothing")return o;if(s.tag==="Just")return s._1;g()},h5=t=>e=>n=>r=>{const o=Kn(r)(e.layout.nodes);if(o.tag==="Just"){const i=An(d5(e)(n)(r)),a=v(ge)(t)(V(o5(t))(i)),s=ge(t)(rt(i.length)*t*1.2);return J("Just",{x:o._1.x+o._1.w/2-a/2,y:o._1.y+o._1.h/2-s/2,w:a,h:s})}if(o.tag==="Nothing")return T;g()},p5=t=>e=>n=>{if(e.length===0)return n;const r=Cn(160)(r5(t)(e)+32)/2;return{x:n.x-r,y:n.y-30.6,w:n.w+r+r,h:n.h+40.6}},jn=t=>e=>n=>r=>o=>{const i={width:e.widthPx,height:e.heightPx},a=E_(i)((()=>{if(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0){const s=ln(n)(o);return{vx:s.x-t.padding,vy:s.y-t.padding,vw:s.w+t.padding*2,vh:s.h+t.padding*2}}return{vx:ln(n)(o).x,vy:ln(n)(o).y,vw:ln(n)(o).w,vh:ln(n)(o).h}})());return t.labelBasePx*r.placement.scale*(i.width<=0||a.vw<=0?0:i.width/a.vw)},Qp=t=>e=>n=>r=>o=>{const i=jn(t)(e)(n)(r)(o);return i<=t.minimumReadableLabelPx?o:{...o,zoom:o.zoom*t.minimumReadableLabelPx/i}},Iu=t=>e=>n=>r=>(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s,l=jn(t)(e)(n)(r)(f);if(e.widthPx<=0||e.heightPx<=0||l<=0||l>=t.minimumReadableLabelPx){u=!1,c=f;continue}if(_<=0){u=!1,c=f;continue}a=_-1|0,s={...f,zoom:f.zoom*t.minimumReadableLabelPx/l}}return c})(8),Mr=t=>e=>n=>r=>{const o=E_({width:t.widthPx,height:t.heightPx})((()=>{const i=ln(n)(r);return{vx:i.x-e,vy:i.y-e,vw:i.w+e*2,vh:i.h+e*2}})());return{x:o.vx,y:o.vy,w:o.vw,h:o.vh}},m5=t=>e=>n=>r=>{const o=Kn(e)(t.nodes);if(o.tag==="Just"){const i=o._1.x+o._1.w/2,a=o._1.y+o._1.h/2,s=Kn(n)(t.nodes);if(s.tag==="Just")return J("Just",{x:i+(s._1.x+s._1.w/2-i)*r-6,y:a+(s._1.y+s._1.h/2-a)*r-6,w:12,h:12})}return T},K_=t=>e=>n=>r=>o=>i=>{const a=V((()=>{const s=t.padding;return u=>({x:u.x-s,y:u.y-s,w:u.w+s*2,h:u.h+s*2})})())(Tt(h5(t.labelBasePx)(e)(n))([r,o]));return a.length===0?i:pr([i,...a])},y5=t=>e=>n=>r=>o=>i=>a=>s=>{const u=K_(t)(e)(n)(r)(o)(s);if(i.tag==="Nothing")return u;if(i.tag==="Just"){const c=K_(t)(e)(n)(i._1.source)(i._1.target)(s),_=a*a*(3-2*a);return{x:u.x+(c.x-u.x)*_,y:u.y+(c.y-u.y)*_,w:u.w+(c.w-u.w)*_,h:u.h+(c.h-u.h)*_}}g()},Wp=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>{const _=i.x-6,f=i.y-6;return J("Just",{visibleBounds:(()=>{const l=ba(e)(n);return l.tag==="Just"?J("Just",{x:l._1.x*e.placement.scale+e.placement.tx,y:l._1.y*e.placement.scale+e.placement.ty,w:l._1.w*e.placement.scale,h:l._1.h*e.placement.scale}):T})(),subject:J("Just",{x:_*e.placement.scale+e.placement.tx,y:f*e.placement.scale+e.placement.ty,w:12*e.placement.scale,h:12*e.placement.scale}),guide:(()=>{const l=m5(e.layout)(r)(o)(a);return l.tag==="Just"?J("Just",{x:l._1.x*e.placement.scale+e.placement.tx,y:l._1.y*e.placement.scale+e.placement.ty,w:l._1.w*e.placement.scale,h:l._1.h*e.placement.scale}):T})(),mustSee:J("Just",(()=>{const l=y5(t)(e)(n)(r)(o)(c)(s)({x:_-t.padding,y:f-t.padding,w:12+t.padding*2,h:12+t.padding*2});return{x:l.x*e.placement.scale+e.placement.tx,y:l.y*e.placement.scale+e.placement.ty,w:l.w*e.placement.scale,h:l.h*e.placement.scale}})()),lookAhead:J("Just",f5(e.layout)(r)(o)(u)(c)(a)(s))})},Fu=t=>e=>n=>r=>o=>i=>{const a=K_(t)(e)(n)(r)(o)(i);return{x:a.x,y:i.y,w:a.w,h:i.h}},x5=t=>e=>n=>r=>o=>i=>{if(o.tag==="Nothing")return i.zoom;if(o.tag==="Just")return ge(0)(Y_(e)(n)(i)((()=>{const a=t.padding*r.placement.scale;return{x:o._1.x-a,y:o._1.y-a,w:o._1.w+a*2,h:o._1.h+a*2}})()));g()},T5=t=>e=>n=>r=>o=>{if(o.intent==="Overview"||o.intent==="DiveHome"||o.intent==="DiveTransition"||o.intent!=="ActionFocus")return o;const i=Iu(t)(e)(n)(r);return{...o,fromCam:i(o.fromCam),toCam:i(o.toCam)}},w5=t=>e=>n=>r=>{const o=no(r)(e.edgeEndpoints),i=no(r)(e.layout.edges);if(i.tag==="Just"&&o.tag==="Just"){const a=xa(e.layout)(e.edgeEndpoints)(r),s=Fu(t)(e)(n)(o._1.source)(o._1.target)(Cs(i._1));return{x:s.x,y:a.y,w:s.w,h:a.h}}return xa(e.layout)(e.edgeEndpoints)(r)},Hp=t=>e=>n=>r=>{const o=kh(8)(t);if(n==="ExtendFromSource")return{path:o,source:e.source,target:e.target,progress:mn(0)(1)(r)};if(n==="ExtendFromTarget")return{path:ee(o),source:e.target,target:e.source,progress:mn(0)(1)(r)};g()},N5=t=>e=>n=>r=>{const o=t.padding*.75,i=rt(48),a=n.layout;return _s(s=>{if(s.target.tag==="NodeWindow")return[];if(s.target.tag==="RelabelWindow")return[(()=>{const u=ya(a)(r)(Zt("Node",1,1,s.target._1,void 0,M,M));return{startT:s.startT,endT:s.endT,bbox:(()=>{const c=Bp(t.labelBasePx)(n)(s.target._1)(s.target._2)(s.target._3);if(c.tag==="Nothing")return u;if(c.tag==="Just")return c._1;g()})(),priority:1}})()];if(s.target.tag==="EdgeWindow"){if(s.target._2.tag==="Extend"){const u=no(s.target._1)(r),c=no(s.target._1)(a.edges);if(c.tag==="Just"&&u.tag==="Just"){const _=u._1,f=c._1;return Et($t(0,47))(l=>{const d=s.startT+(s.endT-s.startT)*(rt(l)/i),h=s.startT+(s.endT-s.startT)*(rt(l+1|0)/i),p=Hp(f)(_)(s.target._2._1)(Mo(e)(((d+h)/2-s.startT)/ge(1e-4)(s.endT-s.startT))),m=0<p.path.length?p.path[0]:{x:0,y:0},x=Ho(p.path)(p.progress),y=(()=>{if(x.tag==="Nothing")return m;if(x.tag==="Just")return x._1;g()})();return[{startT:d,endT:h,bbox:Fu(t)(n)((d+h)/2)(p.source)(p.target)({x:y.x-6,y:y.y-6,w:12,h:12}),priority:1}]})}return[{startT:s.startT,endT:s.endT,bbox:xa(a)(r)(s.target._1),priority:1}]}if(s.target._2.tag==="Retract")return[];g()}if(s.target.tag==="TokenWindow"){const u=no(s.target._2)(a.edges);if(u.tag==="Just"){const c=(()=>{if(s.target._3==="Forward")return u._1;if(s.target._3==="Backward")return ee(u._1);g()})();return Et($t(0,47))(_=>{const f=s.startT+(s.endT-s.startT)*(rt(_)/i),l=s.startT+(s.endT-s.startT)*(rt(_+1|0)/i),d=U_(a)(c)(s.target._4)(s.target._5)(((f+l)/2-s.startT)/ge(1e-4)(s.endT-s.startT))({pre:s.target._7,post:s.target._8});return[{startT:f,endT:l,bbox:Fu(t)(n)((f+l)/2)(s.target._4)(s.target._5)({x:d.x-o,y:d.y-o,w:0+o*2,h:0+o*2}),priority:1}]})}if(u.tag==="Nothing")return[{startT:s.startT,endT:s.endT,bbox:xa(a)(r)(s.target._2),priority:1}];g()}if(s.target.tag==="FillWindow")return[{startT:s.startT,endT:s.endT,bbox:p5(t)(s.target._3)(ya(a)(r)(Zt("Node",1,1,s.target._2,void 0,M,M))),priority:1}];g()})},J5=t=>e=>n=>r=>o=>i=>[...a5(i)(gt(a=>a.startT>=i.startT&&a.endT<=i.endT,o.spans)),...N5(t)(e)(i)(r)(i.windows)],v5=t=>e=>n=>r=>o=>i=>a=>Fx(t)(e)(a.layout)(i.endT)(Tt(s=>s.scene.tag==="StepScene"?J("Just",s.startT):T)(a.spans))(J5(t)(n)(r)(o)(i)(a)),C5=t=>e=>n=>{const r=ln(t)(n);return e.x>=r.x&&e.x+e.w<=r.x+r.w},Op=t=>e=>(()=>{if(e.subject.tag==="Nothing")return!0;if(e.subject.tag==="Just")return e.subject._1.x>=t.x&&e.subject._1.y>=t.y&&e.subject._1.x+e.subject._1.w<=t.x+t.w&&e.subject._1.y+e.subject._1.h<=t.y+t.h;g()})()&&(()=>{if(e.mustSee.tag==="Nothing")return!0;if(e.mustSee.tag==="Just")return e.mustSee._1.x>=t.x&&e.mustSee._1.y>=t.y&&e.mustSee._1.x+e.mustSee._1.w<=t.x+t.w&&e.mustSee._1.y+e.mustSee._1.h<=t.y+t.h;g()})(),qp=t=>e=>n=>r=>n>=e?mn(t+e-n/2)(t+n/2)(r):t+e/2,Vp=t=>e=>n=>r=>{if((()=>{const a=ln(e)(n);return r.x>=a.x&&r.y>=a.y&&r.x+r.w<=a.x+a.w&&r.y+r.h<=a.y+a.h})())return n;const o={...n,zoom:Cn(n.zoom)(Y_(t)(e)({...n,center:{x:r.x+r.w/2,y:r.y+r.h/2}})(r))},i=ln(e)(o);return{...o,center:{x:qp(r.x)(r.w)(i.w)(n.center.x),y:qp(r.y)(r.h)(i.h)(n.center.y)}}},b5=t=>e=>n=>{const r=t.x+t.w/2,o=n>=t.w?{lo:r,hi:r}:{lo:t.x+n/2,hi:t.x+t.w-n/2};if(n>=e.w){const u=ge(o.lo)(e.x+e.w-n/2),c=Cn(o.hi)(e.x+n/2);return u<=c?{lo:u,hi:c}:o}const i=e.x+e.w/2;if(n>=e.w){const u=ge(o.lo)(i),c=Cn(o.hi)(i);return u<=c?{lo:u,hi:c}:o}const a=ge(o.lo)(e.x+n/2),s=Cn(o.hi)(e.x+e.w-n/2);return a<=s?{lo:a,hi:s}:o},k5=t=>e=>n=>n.endT<=t||n.startT>=e?T:J("Just",{...n,startT:ge(t)(n.startT),endT:Cn(e)(n.endT)}),L5=t=>e=>n=>r=>o=>i=>a=>Tt(k5(a.startT)(a.endT))(V(_5(r)(a.layout)(a.placement))(v5(t)(e)(n)(o)(a.edgeEndpoints)(i)(a))),S5=t=>e=>n=>r=>o=>i=>{const a=ba(r)(o),s=a.tag==="Just"?J("Just",{x:a._1.x*r.placement.scale+r.placement.tx,y:a._1.y*r.placement.scale+r.placement.ty,w:a._1.w*r.placement.scale,h:a._1.h*r.placement.scale}):T,u=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(i),c=t.padding*r.placement.scale,_={x:r.layout.bounds.x*r.placement.scale+r.placement.tx-c,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-c,w:r.layout.bounds.w*r.placement.scale+c*2,h:r.layout.bounds.h*r.placement.scale+c*2};return(()=>{if(s.tag==="Nothing")return!1;if(s.tag==="Just")return s._1.x>=u.x&&s._1.y>=u.y&&s._1.x+s._1.w<=u.x+u.w&&s._1.y+s._1.h<=u.y+u.h;g()})()?i:{...i,center:Gu(Pu)(_)({w:u.w,h:u.h})(i.center)({visibleBounds:s,subject:T,guide:T,mustSee:T,lookAhead:T})}},$p=t=>e=>n=>r=>{const o=Cn(r.zoom)(t.bounds.w/ge(1e-4)(e.w));return{...r,center:{...r.center,x:(()=>{const i=b5(t.bounds)(e)(t.bounds.w/ge(1e-4)(o));return mn(i.lo)(i.hi)(n.center.x)})()},zoom:o}},E5=t=>e=>n=>{const r=t.bounds.h/ge(1e-4)(n.zoom),o=t.bounds.w/ge(1e-4)(n.zoom);return{...n,center:{x:o>=e.w?e.x+e.w/2:zp(e.x+o/2)(e.x+e.w-o/2)(n.center.x),y:r>=e.h?e.y+e.h/2:zp(e.y+r/2)(e.y+e.h-r/2)(n.center.y)}}},wi=t=>e=>n=>E5(t)((()=>{const r=e*n.placement.scale;return{x:n.layout.bounds.x*n.placement.scale+n.placement.tx-r,y:n.layout.bounds.y*n.placement.scale+n.placement.ty-r,w:n.layout.bounds.w*n.placement.scale+r*2,h:n.layout.bounds.h*n.placement.scale+r*2}})()),P5=t=>e=>n=>r=>{const o=ln(t)(r),i=t.bounds,a=s=>{const u=wi(t)(e)(n)(s);return wi(t)(e)(n)({...u,zoom:ge(u.zoom)(ge(i.w/ge(1e-4)(2*Cn(u.center.x-o.x)(o.x+o.w-u.center.x)))(i.h/ge(1e-4)(2*Cn(u.center.y-o.y)(o.y+o.h-u.center.y))))})};return s=>a(a(s))},G5=t=>e=>n=>r=>wi(n)(t.padding)(r)(Py(t)(e)(n)(r.placement)(r.layout.bounds).camera),Up=t=>e=>n=>r=>o=>{const i=G5(t)(e)(n)(o),a=ne(s=>s.direction==="DiveIn"&&Ti(s.childPath)(o.path))(r.dives);if(a.tag==="Just"){const s=Au(r)(a._1.parentPath)(a._1.startT)(a._1.endT);if(s.tag==="Just"){const u=Kn(a._1.node)(s._1.layout.nodes);if(u.tag==="Just"){const c=u._1.w*s._1.placement.scale,_=u._1.h*s._1.placement.scale,f=Cn(c)(_*2),l=Gy(e)(n)({h:_,w:f,x:u._1.x*s._1.placement.scale+s._1.placement.tx+(c-f)*.5,y:u._1.y*s._1.placement.scale+s._1.placement.ty});return P5(n)(t.padding)(o)(l)(l.zoom>i.zoom?l:i)}if(u.tag==="Nothing")return i;g()}if(s.tag==="Nothing")return i;g()}if(a.tag==="Nothing")return i;g()},Xp=t=>e=>n=>r=>o=>{const i=ln(n)(o);return(()=>{const a=r.layout.bounds.x*r.placement.scale+r.placement.tx,s=r.layout.bounds.y*r.placement.scale+r.placement.ty;return a>=i.x&&s>=i.y&&a+r.layout.bounds.w*r.placement.scale<=i.x+i.w&&s+r.layout.bounds.h*r.placement.scale<=i.y+i.h})()&&jn(t)(e)(n)(r)(o)>=t.minimumReadableLabelPx},Yp=t=>e=>n=>r=>o=>i=>Xp(t)(e)(n)(r)(o)?o:Qp(t)(e)(n)(r)(i),R5=t=>e=>n=>{const r=u5([])(n),o=Pt(u=>T,u=>c=>J("Just",{head:u,tail:c}),r.rest),i=r.overview.length-1|0,a=i>=0&&i<r.overview.length?J("Just",r.overview[i]):T,s=0<r.overview.length?J("Just",r.overview[0]):T;if(s.tag==="Just"){if(a.tag==="Just"){if(o.tag==="Just")return re(s._1.startT-e.startT)<1e-4&&o._1.head.intent==="ActionFocus"?[{startT:s._1.startT,endT:a._1.endT,fromCam:t,toCam:t,easing:s._1.easing,interp:qn,intent:wa},{...o._1.head,fromCam:t},...o._1.tail]:n;if(o.tag==="Nothing"&&re(s._1.startT-e.startT)<1e-4)return[{startT:s._1.startT,endT:a._1.endT,fromCam:t,toCam:t,easing:s._1.easing,interp:qn,intent:wa}]}return n}if(s.tag==="Nothing"&&a.tag==="Nothing"&&o.tag==="Just"&&re(o._1.head.startT-e.startT)<1e-4&&o._1.head.intent==="ActionFocus"){const u=Pt(c=>T,c=>_=>J("Just",{head:c,tail:_}),o._1.tail);if(u.tag==="Nothing")return[{startT:o._1.head.startT,endT:o._1.head.endT,fromCam:t,toCam:t,easing:o._1.head.easing,interp:qn,intent:wa}];if(u.tag==="Just")return[{startT:o._1.head.startT,endT:o._1.head.endT,fromCam:t,toCam:t,easing:o._1.head.easing,interp:qn,intent:wa},{...u._1.head,fromCam:t},...u._1.tail];g()}return n},Kp=t=>e=>n=>r=>o=>i=>a=>{if(o.tag==="Nothing")return a;if(o.tag==="Just"){const s=t.padding*r.placement.scale,u={x:o._1.x-s,y:o._1.y-s,w:o._1.w+s*2,h:o._1.h+s*2},c={x:u.x+u.w/2,y:u.y+u.h/2},_={...a,center:c},f={..._,zoom:Y_(e)(n)(_)(u)},l=ln(n)(f);return i.tag==="Nothing"?{...f,center:{x:l.w>=o._1.w?o._1.x+o._1.w/2:mn(o._1.x+l.w/2)(o._1.x+o._1.w-l.w/2)(c.x),y:l.h>=o._1.h?o._1.y+o._1.h/2:mn(o._1.y+l.h/2)(o._1.y+o._1.h-l.h/2)(c.y)}}:i.tag==="Just"?{...f,center:{x:l.w>=o._1.w?o._1.x+o._1.w/2:mn(o._1.x+l.w/2)(o._1.x+o._1.w-l.w/2)(i._1.x+i._1.w/2),y:l.h>=o._1.h?o._1.y+o._1.h/2:mn(o._1.y+l.h/2)(o._1.y+o._1.h-l.h/2)(i._1.y+i._1.h/2)}}:{...f,center:{x:(()=>{if(l.w>=o._1.w)return o._1.x+o._1.w/2;g()})(),y:(()=>{if(l.h>=o._1.h)return o._1.y+o._1.h/2;g()})()}}}g()},j_=t=>e=>n=>r=>o=>i=>a=>{const s=t.padding*r.placement.scale,u={x:r.layout.bounds.x*r.placement.scale+r.placement.tx-s,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-s,w:r.layout.bounds.w*r.placement.scale+s*2,h:r.layout.bounds.h*r.placement.scale+s*2},c=x=>Op(Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(x))(i),_=x=>y=>w=>N=>{let b=x,C=y,L=w,E=N,I=!0,W;for(;I;){const P=b,G=C,j=L,nt=E;if(P<=0){I=!1,W=nt;continue}const O={...o,zoom:(G+j)/2},$=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(O),H={...O,center:Gu(Pu)(u)({w:$.w,h:$.h})(o.center)(i)};if(c(H)){b=P-1|0,C=H.zoom,L=j,E=H;continue}b=P-1|0,C=G,L=H.zoom,E=nt}return W},f=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(a),l=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(o),d=jn(t)(e)(n)(r)(o)>=t.minimumReadableLabelPx-.001,h={...o,center:Gu(Pu)(u)({w:l.w,h:l.h})(o.center)(i)},p=Op(Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(h))(i),m={...a,center:Gu(Pu)(u)({w:f.w,h:f.h})(o.center)(i)};return m.zoom>h.zoom&&c(m)?m:d&&p?h:m.zoom>=h.zoom||!c(m)?m:_(12)(m.zoom)(o.zoom)(m)},A5=t=>e=>{const n=ge(t.minTransition)(t.maxTransition);return v(r=>o=>V((()=>{const i=o.startT,a=o.toCam;return s=>{const u=i-n,c=mn(0)(1)((s.endT-u)/n),_=c*c*(3-2*c);return s.endT<=u||s.endT>i+1e-4?s:{...s,toCam:{center:{x:s.toCam.center.x+(a.center.x-s.toCam.center.x)*_,y:s.toCam.center.y+(a.center.y-s.toCam.center.y)*_},zoom:s.toCam.zoom+(a.zoom-s.toCam.zoom)*_}}}})())(r))(e)(gt(r=>r.endT<=r.startT+1e-4,e))},I5=t=>e=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[{...n._1.head,fromCam:t},...n._1.tail];g()},F5=t=>V(e=>{const n=ne(i=>e.startT<i.startT&&e.endT>=i.startT-1e-4)(t),r=(()=>{if(n.tag==="Just")return{...e,endT:n._1.startT,toCam:n._1.fromCam};if(n.tag==="Nothing")return e;g()})(),o=ne(i=>r.startT<=i.endT+1e-4&&r.endT>i.endT)(t);if(o.tag==="Just")return{...r,startT:o._1.endT,fromCam:o._1.toCam};if(o.tag==="Nothing")return r;g()}),jp=t=>e=>{const n=i=>{const a=Gt(at.compare)(Tt(s=>s.target.tag==="EdgeWindow"&&s.target._2.tag==="Extend"&&re(s.endT-i)<1e-4?J("Just",s.startT):T)(t.windows));return 0<a.length?a[0]:i},r=i=>a=>s=>{let u=i,c=a,_=s,f=!0,l;for(;f;){const d=u,h=c,p=Pt(m=>T,m=>x=>J("Just",{head:m,tail:x}),_);if(p.tag==="Nothing"){f=!1,l=wt(d)(h);continue}if(p.tag==="Just"){if((h.intent==="Overview"||vc(m=>m.target.tag==="RelabelWindow",gt(m=>m.startT<h.endT-1e-4&&m.endT>h.startT+1e-4&&(m.target.tag==="RelabelWindow"?!0:m.target.tag==="EdgeWindow"?m.target._2.tag==="Extend":m.target.tag==="TokenWindow"||m.target.tag==="FillWindow"),t.windows)))&&p._1.head.intent==="ActionFocus"&&re(h.endT-p._1.head.startT)<1e-4&&(h.fromCam.zoom===h.toCam.zoom&&h.fromCam.center.x===h.toCam.center.x&&h.fromCam.center.y===h.toCam.center.y||re(h.startT-ge(h.startT)(n(p._1.head.startT)-(p._1.head.endT-p._1.head.startT)))<1e-4)&&(()=>{const m=p._1.head.startT;return!(p._1.head.fromCam.zoom===p._1.head.toCam.zoom&&p._1.head.fromCam.center.x===p._1.head.toCam.center.x&&p._1.head.fromCam.center.y===p._1.head.toCam.center.y)&&(()=>{const x=p._1.head.startT;return ue(y=>re(y.startT-m)<1e-4&&(y.target.tag==="RelabelWindow"?!0:y.target.tag==="EdgeWindow"?y.target._2.tag==="Extend":y.target.tag==="TokenWindow"||y.target.tag==="FillWindow"),t.windows)&&!ue(y=>re(y.startT-x)<1e-4&&(y.target.tag==="TokenWindow"||y.target.tag==="EdgeWindow"&&y.target._2.tag==="Extend"),t.windows)})()})()){const m=n(p._1.head.startT),x=ge(h.startT)(m-(p._1.head.endT-p._1.head.startT)),y={...h,endT:x};u=wt(y.endT>y.startT?wt(d)(y):d)({...p._1.head,startT:x,endT:m,fromCam:re(x-h.startT)<1e-4?h.fromCam:h.toCam}),c={...p._1.head,startT:m,fromCam:p._1.head.toCam},_=p._1.tail;continue}u=wt(d)(h),c=p._1.head,_=p._1.tail;continue}g()}return l},o=Pt(i=>T,i=>a=>J("Just",{head:i,tail:a}),e);if(o.tag==="Nothing")return[];if(o.tag==="Just")return r([])(o._1.head)(o._1.tail);g()},D5=t=>e=>n=>r=>o=>i=>{const a={x:r.layout.bounds.x*r.placement.scale+r.placement.tx,y:r.layout.bounds.y*r.placement.scale+r.placement.ty,w:r.layout.bounds.w*r.placement.scale,h:r.layout.bounds.h*r.placement.scale},s=$p(n)(a)(o)(i);return a.w/ge(1e-4)(a.h)>=.33&&i.zoom/ge(1e-4)(s.zoom)<=1.25&&ln(n)(s).w>=a.w-.001&&jn(t)(e)(n)(r)(s)>=t.minimumReadableLabelPx*1?s:i},z5=t=>e=>n=>r=>o=>i=>a=>{const s=r.layout.bounds.w*r.placement.scale,u=s/ge(1e-4)(r.layout.bounds.h*r.placement.scale);if(o.tag==="Nothing")return a;if(o.tag==="Just"){if(C5(n)(o._1)(a))return a;const c=$p(n)(o._1)(i)(a);return a.zoom/ge(1e-4)(c.zoom)<=1.25&&(jn(t)(e)(n)(r)(c)>=t.minimumReadableLabelPx-.001||o._1.w>=s-.001&&u>=.33&&jn(t)(e)(n)(r)(c)>=t.minimumReadableLabelPx*1)?c:a}g()},Zp=t=>e=>n=>r=>o=>i=>a=>{const s={...a,center:(()=>{if(i.tag==="Nothing")return a.center;if(i.tag==="Just")return{x:i._1.x+i._1.w/2,y:i._1.y+i._1.h/2};g()})()},u=jn(t)(e)(n)(r)(s);return z5(t)(e)(n)(r)(o)(a)(D5(t)(e)(n)(r)(a)(u<=0?s:{...s,zoom:(()=>{const c=x5(t)(e)(n)(r)(i)(s);return(_=>f=>{let l=_,d=f,h=!0,p;for(;h;){const m=l,x=d,y=jn(t)(e)(n)(r)({...s,zoom:x});if(m<=0||re(y-t.minimumReadableLabelPx)<.001){h=!1,p=x;continue}l=m-1|0,d=Cn(y<=0?x:x*t.minimumReadableLabelPx/y)(c)}return p})(4)(Cn(u<=0?s.zoom:s.zoom*t.minimumReadableLabelPx/u)(c))})()}))},t0=t=>e=>n=>r=>o=>i=>a=>jn(t)(e)(n)(r)(a)>=t.minimumReadableLabelPx?a:Zp(t)(e)(n)(r)(o)(i)(a),Z_=t=>e=>n=>r=>o=>i=>a=>e.widthPx<=0||e.heightPx<=0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t0(t)(e)(n)(r)(o)(i)(Kp(t)(e)(n)(r)(o)(i)(a)):Xp(t)(e)(n)(r)(a)?a:Zp(t)(e)(n)(r)(o)(i)(a),B5=t=>e=>n=>{const r=Gt(o=>i=>at.compare(o.startT)(i.startT))(gt(o=>o.startT>=e.endT-1e-4&&o.startT-e.endT<=1.1001&&o.target.tag==="TokenWindow",t.windows));return 0<r.length&&r[0].target.tag==="TokenWindow"&&r[0].target._4===n?J("Just",{source:r[0].target._4,target:r[0].target._5,startT:r[0].startT}):T},M5=t=>e=>n=>{const r=Gt(i=>a=>at.compare(i.endT)(a.endT))(gt(i=>i.endT<=e.startT+1e-4&&e.startT-i.endT<=1.1001&&i.target.tag==="TokenWindow",t.windows)),o=r.length-1|0;return o>=0&&o<r.length&&r[o].target.tag==="TokenWindow"&&r[o].target._5===n},e0=t=>e=>n=>r=>o=>{if(r.target.tag==="TokenWindow"){const i=no(r.target._2)(n.layout.edges);if(i.tag==="Just"){const a=(o-r.startT)/ge(1e-4)(r.endT-r.startT),s=B5(n)(r)(r.target._5);return Wp(t)(n)(o)(r.target._4)(r.target._5)(U_(n.layout)((()=>{if(r.target._3==="Forward")return i._1;if(r.target._3==="Backward")return ee(i._1);g()})())(r.target._4)(r.target._5)(a)({pre:r.target._7,post:r.target._8}))(n5(a)({pre:r.target._7,post:r.target._8}))(s.tag==="Just"?c5(t)(n)(o)(s._1):0)(M5(n)(r)(r.target._4))(s)}if(i.tag==="Nothing")return T;g()}if(r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"){const i=no(r.target._1)(n.layout.edges);if(i.tag==="Just"){const a=no(r.target._1)(n.edgeEndpoints);if(a.tag==="Just"){const s=Hp(i._1)(a._1)(r.target._2._1)(Mo(e)((o-r.startT)/ge(1e-4)(r.endT-r.startT)));return Wp(t)(n)(o)(s.source)(s.target)((()=>{const u=0<s.path.length?s.path[0]:{x:0,y:0},c=Ho(s.path)(s.progress);if(c.tag==="Nothing")return u;if(c.tag==="Just")return c._1;g()})())(s.progress)(0)(!1)(T)}if(a.tag==="Nothing")return T;g()}if(i.tag==="Nothing")return T;g()}return T},n0=t=>{const e=n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i,_=Pt(f=>T,f=>l=>J("Just",{head:f,tail:l}),c);if(_.tag==="Just"&&_._1.head.intent==="Overview"){o=wt(u)(_._1.head),i=_._1.tail;continue}a=!1,s={overview:u,rest:c}}return s};return(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=Pt(_=>T,_=>f=>J("Just",{head:_,tail:f}),i);if(c.tag==="Nothing"){a=!1,s=u;continue}if(c.tag==="Just"){if(c._1.head.intent==="Overview"){const _=e([c._1.head])(c._1.tail),f=Pt(h=>T,h=>p=>J("Just",{head:h,tail:p}),_.rest),l=u.length-1|0,d=l>=0&&l<u.length?J("Just",u[l]):T;if(d.tag==="Just"&&f.tag==="Just"&&d._1.intent==="ActionFocus"&&(()=>{const h=_.overview.length-1|0;return f._1.head.intent==="ActionFocus"&&(h>=0&&h<_.overview.length&&0<_.overview.length?_.overview[h].endT-_.overview[0].startT<=1.1001:!0)})()&&0<_.overview.length){const h=_.overview.length-1|0;if(h>=0&&h<_.overview.length){o=wt(u)({startT:_.overview[0].startT,endT:_.overview[h].endT,fromCam:d._1.toCam,toCam:d._1.toCam,easing:_.overview[0].easing,interp:qn,intent:Es}),i=[{...f._1.head,fromCam:d._1.toCam},...f._1.tail];continue}}o=[...u,..._.overview],i=_.rest;continue}o=wt(u)(c._1.head),i=c._1.tail;continue}g()}return s})([])(t)},Q5=t=>e=>n=>{const r=Mp([])(n),o=r.overview.length-1|0;if(o>=0&&o<r.overview.length){if(0<r.overview.length){const i=r.prefix.length-1|0;if(i>=0&&i<r.prefix.length&&r.prefix[i].intent==="ActionFocus"&&re(r.overview[o].endT-e.endT)<1e-4)return[...r.prefix,{startT:r.overview[0].startT,endT:r.overview[o].endT,fromCam:r.prefix[i].toCam,toCam:r.prefix[i].toCam,easing:r.overview[0].easing,interp:qn,intent:Es}]}return n}return 0<r.overview.length&&r.prefix.length-1|0,n},r0=t=>e=>n=>{const r=Mp([])(n),o=r.overview.length-1|0;if(o>=0&&o<r.overview.length){if(0<r.overview.length){const i=r.prefix.length-1|0;if(i>=0&&i<r.prefix.length&&(()=>{const a=r.overview[o].endT;return r.prefix[i].intent==="ActionFocus"&&(()=>{const s=r.overview.length-1|0;return ue(u=>u.direction==="DiveIn"&&Ti(u.parentPath)(t.path)&&re(u.startT-a)<1e-4,e)&&(s>=0&&s<r.overview.length&&0<r.overview.length?r.overview[s].endT-r.overview[0].startT<=1.1001:!0)})()})())return[...r.prefix,{startT:r.overview[0].startT,endT:r.overview[o].endT,fromCam:r.prefix[i].toCam,toCam:r.prefix[i].toCam,easing:r.overview[0].easing,interp:qn,intent:Es}]}return n}return n},vo=t=>e=>{const n=e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4,r=i=>n<i.startT?i.startT-n:n>i.endT?n-i.endT:0,o=Gt(i=>a=>{const s=at.compare(r(i))(r(a));return s==="EQ"?at.compare(a.startT)(i.startT):s})(gt(i=>e.startT<i.endT-1e-4&&e.endT>i.startT+1e-4&&(i.target.tag==="RelabelWindow"?!0:i.target.tag==="EdgeWindow"?i.target._2.tag==="Extend":i.target.tag==="TokenWindow"||i.target.tag==="FillWindow"),t.windows));return 0<o.length?mn(o[0].startT+1e-4)(o[0].endT-1e-4)(e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4):e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4},W5=t=>e=>n=>r=>o=>i=>a=>s=>{if(a.tag==="Nothing")return wi(n)(t.padding)(r)(s);if(a.tag==="Just"){const u=t.padding*r.placement.scale,c={x:a._1.x-u,y:a._1.y-u,w:a._1.w+u*2,h:a._1.h+u*2},_={visibleBounds:(()=>{const f=ba(r)(vo(r)(o));return f.tag==="Just"?J("Just",{x:f._1.x*r.placement.scale+r.placement.tx,y:f._1.y*r.placement.scale+r.placement.ty,w:f._1.w*r.placement.scale,h:f._1.h*r.placement.scale}):T})(),subject:J("Just",a._1),guide:T,mustSee:J("Just",c),lookAhead:T};return(()=>{const f=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(i);return c.x>=f.x&&c.y>=f.y&&c.x+c.w<=f.x+f.w&&c.y+c.h<=f.y+f.h&&jn(t)(e)(n)(r)(i)>=t.minimumReadableLabelPx-.001&&i.zoom>=s.zoom*.995})()?i:j_(t)(e)(n)(r)(i)(_)(s)}g()},H5=t=>e=>{const n=e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4,r=i=>n<i.startT?i.startT-n:n>i.endT?n-i.endT:0,o=Gt(i=>a=>at.compare(r(i))(r(a)))(gt(i=>e.startT<i.endT-1e-4&&e.endT>i.startT+1e-4&&(i.target.tag==="TokenWindow"||i.target.tag==="EdgeWindow"&&i.target._2.tag==="Extend"),t.windows));return 0<o.length?J("Just",o[0]):T},t1=t=>e=>n=>r=>o=>{const i=H5(n)(r);if(i.tag==="Just")return e0(t)(e)(n)(i._1)(mn(i._1.startT+1e-4)(i._1.endT-1e-4)(o));if(i.tag==="Nothing")return T;g()},O5=t=>e=>n=>{const r=n.fromCam.zoom===n.toCam.zoom&&n.fromCam.center.x===n.toCam.center.x&&n.fromCam.center.y===n.toCam.center.y?(n.startT+n.endT)/2:n.endT+1e-4,o=a=>r<a.startT?a.startT-r:r>a.endT?r-a.endT:0,i=Gt(a=>s=>at.compare(o(a))(o(s)))(gt(a=>n.startT<a.endT-1e-4&&n.endT>a.startT+1e-4&&a.target.tag==="TokenWindow",e.windows));return 0<i.length?e0(t)(bs)(e)(i[0])(mn(i[0].startT+1e-4)(i[0].endT-1e-4)(vo(e)(n))):T},Du=t=>e=>n=>r=>o=>i=>a=>s=>{const u=O5(t)(r)(o);if(u.tag==="Nothing")return W5(t)(e)(n)(r)(o)(i)(a)(s);if(u.tag==="Just")return j_(t)(e)(n)(r)(i)(u._1)((()=>{const c=Mr(e)(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(s),_=r.layout.bounds.x*r.placement.scale+r.placement.tx,f=r.layout.bounds.y*r.placement.scale+r.placement.ty;return _>=c.x&&f>=c.y&&_+r.layout.bounds.w*r.placement.scale<=c.x+c.w&&f+r.layout.bounds.h*r.placement.scale<=c.y+c.h})()?s:Qp(t)(e)(n)(r)(s));g()},zu=t=>e=>n=>{const r=Tt(o=>o.target.tag==="RelabelWindow"?J("Just",(()=>{const i=ya(e.layout)(e.edgeEndpoints)(Zt("Node",1,1,o.target._1,void 0,M,M)),a=Bp(t.labelBasePx)(e)(o.target._1)(o.target._2)(o.target._3);if(a.tag==="Nothing")return i;if(a.tag==="Just")return a._1;g()})()):o.target.tag==="EdgeWindow"?o.target._2.tag==="Extend"?J("Just",w5(t)(e)(n)(o.target._1)):T:o.target.tag==="TokenWindow"?J("Just",(()=>{const i=no(o.target._2)(e.layout.edges);if(i.tag==="Nothing")return xa(e.layout)(e.edgeEndpoints)(o.target._2);if(i.tag==="Just"){const a=U_(e.layout)((()=>{if(o.target._3==="Forward")return i._1;if(o.target._3==="Backward")return ee(i._1);g()})())(o.target._4)(o.target._5)((n-o.startT)/ge(1e-4)(o.endT-o.startT))({pre:o.target._7,post:o.target._8});return Fu(t)(e)(n)(o.target._4)(o.target._5)({x:a.x-6,y:a.y-6,w:12,h:12})}g()})()):o.target.tag==="FillWindow"?J("Just",ya(e.layout)(e.edgeEndpoints)(Zt("Node",1,1,o.target._2,void 0,M,M))):T)(gt(o=>o.startT<=n&&n<o.endT,e.windows));return r.length===0?T:J("Just",(()=>{const o=pr(r);return{x:o.x*e.placement.scale+e.placement.tx,y:o.y*e.placement.scale+e.placement.ty,w:o.w*e.placement.scale,h:o.h*e.placement.scale}})())},e1=t=>e=>{const n=ba(t)(e.endT+1e-4);return n.tag==="Just"?J("Just",{x:n._1.x*t.placement.scale+t.placement.tx,y:n._1.y*t.placement.scale+t.placement.ty,w:n._1.w*t.placement.scale,h:n._1.h*t.placement.scale}):T},q5=t=>e=>n=>r=>o=>{const i=e1(r)(o),a=Iu(t)(e)(n)(r);if(o.intent==="DiveHome"||o.intent==="ActionFocus"||o.intent==="Overview")return o;const s=u=>{const c=a(u);return i.tag==="Just"&&(()=>{const _=ln(n)(c);return!(i._1.x>=_.x&&i._1.y>=_.y&&i._1.x+i._1.w<=_.x+_.w&&i._1.y+i._1.h<=_.y+_.h)})()?u:c};return{...o,fromCam:s(o.fromCam),toCam:s(o.toCam)}},V5=t=>e=>n=>r=>o=>i=>{const a=zu(t)(r)(vo(r)(i)),s=e1(r)(i),u=c=>{const _=Kp(t)(e)(n)(r)(s)(a)(c),f={..._,zoom:Cn(o.zoom)(_.zoom)};return Du(t)(e)(n)(r)(i)(f)(a)(t0(t)(e)(n)(r)(s)(a)(f))};return{...i,fromCam:u(i.fromCam),toCam:u(i.toCam)}},$5=t=>e=>n=>r=>o=>i=>i.intent==="ActionFocus"?V5(t)(e)(n)(r)(o)(i):{...i,fromCam:Yp(t)(e)(n)(r)(o)(i.fromCam),toCam:Yp(t)(e)(n)(r)(o)(i.toCam)},U5=t=>e=>n=>r=>o=>i=>{const a=o(i.fromCam),s=o(i.toCam),u=zu(t)(r)(vo(r)(i)),c=e1(r)(i);return a.zoom===s.zoom&&a.center.x===s.center.x&&a.center.y===s.center.y?{...i,fromCam:Du(t)(e)(n)(r)(i)(a)(u)(Z_(t)(e)(n)(r)(c)(u)(a)),toCam:Du(t)(e)(n)(r)(i)(a)(u)(Z_(t)(e)(n)(r)(c)(u)(s))}:{...i,fromCam:a,toCam:Du(t)(e)(n)(r)(i)(a)(u)(Z_(t)(e)(n)(r)(c)(u)(s))}},X5=t=>e=>n=>r=>o=>o.intent==="ActionFocus"?U5(t)(e)(n)(r)(e5)(o):o,Bu=t=>e=>n=>r=>o=>i=>a=>{const s=(f,l,d,h)=>{const p=t1(t)(n)(a)(f)(l);if(p.tag==="Just")return j_(t)(e)(r)(a)(d)(p._1)(h);if(p.tag==="Nothing")return h;g()},u=Gs(t)(r)((()=>{const f=ba(a)(a.startT+1e-4);if(f.tag==="Nothing")return r.bounds;if(f.tag==="Just")return f._1;g()})())(0),c=f=>l=>d=>{let h=f,p=l,m=d,x=!0,y;for(;x;){const w=h,N=p,b=Pt(C=>T,C=>L=>J("Just",{head:C,tail:L}),m);if(b.tag==="Nothing"){x=!1,y=wt(w)(N);continue}if(b.tag==="Just"){if((N.intent==="Overview"||N.intent==="ActionFocus"&&N.fromCam.zoom===N.toCam.zoom&&N.fromCam.center.x===N.toCam.center.x&&N.fromCam.center.y===N.toCam.center.y)&&re(N.endT-b._1.head.startT)<1e-4&&t1(t)(n)(a)(b._1.head)(vo(a)(b._1.head)).tag!=="Nothing"){const C={...b._1.head,fromCam:b._1.head.toCam};h=wt(w)({...N,toCam:C.fromCam}),p=C,m=b._1.tail;continue}h=wt(w)(N),p=b._1.head,m=b._1.tail;continue}g()}return y},_=Ru(A5(t)(jp(a)((()=>{const f=Pt(l=>T,l=>d=>J("Just",{head:l,tail:d}),v(l=>d=>{const h=l.previous.tag==="Just"&&re(l.previous._1.endT-d.startT)<1e-4?{...d,fromCam:l.previous._1.toCam}:d,p=(y,w)=>{const N=zu(t)(a)(vo(a)(h));return N.tag==="Just"&&(()=>{const b=Mr(e)(a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(w),C=t.padding*a.placement.scale;return(()=>{const L=N._1.x-C,E=N._1.y-C;return L>=b.x&&E>=b.y&&L+N._1.w+C*2<=b.x+b.w&&E+N._1.h+C*2<=b.y+b.h})()&&jn(t)(e)(r)(a)(w)>=t.minimumReadableLabelPx-.001})()?w:S5(t)(e)(r)(a)(y)(w)},m=t1(t)(n)(a)(h)(vo(a)(h)),x=(()=>{if(m.tag==="Just"){const y=s(h,h.startT,h.fromCam,h.fromCam);return{...h,fromCam:y,toCam:s(h,h.endT,y,h.toCam),easing:bs}}if(m.tag==="Nothing")return h.intent==="Overview"?h:(()=>{const y=zu(t)(a)(vo(a)(h));if(y.tag==="Nothing")return!1;if(y.tag==="Just"){const w=Mr(e)(a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(h.fromCam),N=t.padding*a.placement.scale;return(()=>{const b=y._1.x-N,C=y._1.y-N;return b>=w.x&&C>=w.y&&b+y._1.w+N*2<=w.x+w.w&&C+y._1.h+N*2<=w.y+w.h})()&&jn(t)(e)(r)(a)(h.fromCam)>=t.minimumReadableLabelPx-.001&&h.fromCam.zoom>=h.toCam.zoom*.995}g()})()?{...h,toCam:h.fromCam}:{...h,fromCam:p(h.startT,h.fromCam),toCam:p(h.endT,h.toCam)};g()})();return{previous:J("Just",x),spans:wt(l.spans)(x)}})({previous:T,spans:[]})(X_(i5(V(T5(t)(e)(r)(a))(Ru(V(q5(t)(e)(r)(a))(g5(t)(a)(jp(a)((()=>{const l=L5(t)(e)(n)(r)(o)(i)(a);if(a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0)return r0(a)(i.dives)(n0(X_(Ru(V(X5(t)(e)(r)(a))(l)))));const d=Up(t)(e)(r)(i)(a);return l.length===0?[{startT:a.startT,endT:a.endT,fromCam:d,toCam:d,easing:bs,interp:qn,intent:wa}]:Q5()(a)(R5(d)(a)(r0(a)(i.dives)(n0(X_(Ru(I5(d)(V($5(t)(e)(r)(a)(d))(l))))))))})())))))))).spans);if(f.tag==="Nothing")return[];if(f.tag==="Just")return c([])(f._1.head)(f._1.tail);g()})())));if(a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0&&a.startT<=1e-4){const f=ge(t.minTransition)(t.maxTransition),l=(d,h)=>{if(d>=f)return h;const p=Mo(t.easing)(mn(0)(1)(d/f));return{center:{x:u.center.x+(h.center.x-u.center.x)*p,y:u.center.y+(h.center.y-u.center.y)*p},zoom:u.zoom+(h.zoom-u.zoom)*p}};return V(d=>({...d,fromCam:l(d.startT,d.fromCam),toCam:l(d.endT,d.toCam)}))(_)}return _},Y5=t=>e=>n=>r=>o=>i=>Gt(a=>s=>at.compare(a.startT)(s.startT))(Et(i.segments)(Bu(t)(e)(n)(r)(o)(i))),es=t=>e=>n=>r=>o=>i=>a=>s=>{if(a.direction==="DiveIn"){const u=wi(r)(t.padding)(s)(Wo(t)(r)(Bu(t)(e)(n)(r)(o)(i)(s))(a.startT-1e-4).camera),c=Iu(t)(e)(r)(s)(u),_=Kn(a.node)(s.layout.nodes);return a.direction==="DiveIn"&&_.tag==="Just"?Vp(e)(r)(c)({x:_._1.x*s.placement.scale+s.placement.tx+_._1.w*s.placement.scale/2-.5,y:_._1.y*s.placement.scale+s.placement.ty+_._1.h*s.placement.scale/2-.5,w:1,h:1}):u}if(a.direction==="DiveOut"){const u=wi(r)(t.padding)(s)(Wo(t)(r)(Bu(t)(e)(n)(r)(o)(i)(s))(a.endT+1e-4).camera),c=Iu(t)(e)(r)(s)(u),_=Kn(a.node)(s.layout.nodes);return a.direction==="DiveIn"&&_.tag==="Just"?Vp(e)(r)(c)({x:_._1.x*s.placement.scale+s.placement.tx+_._1.w*s.placement.scale/2-.5,y:_._1.y*s.placement.scale+s.placement.ty+_._1.h*s.placement.scale/2-.5,w:1,h:1}):u}g()},K5=t=>e=>n=>r=>o=>i=>Et(i.dives)(a=>{const s=Au(i)(a.parentPath)(a.startT)(a.endT);if(s.tag==="Just"){const u=a.childPath,c=ne(_=>Ti(_.path)(u))(i.segments);if(c.tag==="Just"){const _=Bu(t)(e)(n)(r)(o)(i)(c._1),f=Up(t)(e)(r)(i)(c._1),l=es(t)(e)(n)(r)(o)(i)(a)(s._1),d=(()=>{if(a.direction==="DiveIn")return f;if(a.direction==="DiveOut")return wi(r)(t.padding)(c._1)(Wo(t)(r)(_)(a.startT-1e-4).camera);g()})();if(a.direction==="DiveIn"){const h=ne(p=>p.direction==="DiveIn"&&Ti(p.parentPath)(a.childPath)&&re(p.startT-a.endT)<1e-4)(i.dives);if(h.tag==="Just"){const p=Au(i)(h._1.parentPath)(h._1.startT)(h._1.endT);if(p.tag==="Just"){if(a.direction==="DiveIn"&&a.endT-a.startT>.12){const m=a.endT-.12,x={easing:Lr,endT:m,fromCam:l,intent:co,interp:uo,startT:a.startT,toCam:es(t)(e)(n)(r)(o)(i)(h._1)(p._1)};return[x,{...x,startT:m,endT:a.endT,fromCam:es(t)(e)(n)(r)(o)(i)(h._1)(p._1)}]}return[{startT:a.startT,endT:a.endT,fromCam:l,toCam:d,easing:Lr,interp:uo,intent:co}]}if(p.tag==="Nothing")return[{startT:a.startT,endT:a.endT,fromCam:l,toCam:d,easing:Lr,interp:uo,intent:co}];g()}if(h.tag==="Nothing")return[{startT:a.startT,endT:a.endT,fromCam:l,toCam:d,easing:Lr,interp:uo,intent:co}];g()}if(a.direction==="DiveOut"){const h=ne(p=>p.direction==="DiveIn"&&Ti(p.parentPath)(a.childPath)&&re(p.startT-a.endT)<1e-4)(i.dives);if(h.tag==="Just"){const p=Au(i)(h._1.parentPath)(h._1.startT)(h._1.endT);if(p.tag==="Just"){if(a.direction==="DiveIn"&&a.endT-a.startT>.12){const m=a.endT-.12,x={easing:Lr,endT:m,fromCam:d,intent:co,interp:uo,startT:a.startT,toCam:es(t)(e)(n)(r)(o)(i)(h._1)(p._1)};return[x,{...x,startT:m,endT:a.endT,fromCam:es(t)(e)(n)(r)(o)(i)(h._1)(p._1)}]}return[{startT:a.startT,endT:a.endT,fromCam:d,toCam:l,easing:Lr,interp:uo,intent:co}]}if(p.tag==="Nothing")return[{startT:a.startT,endT:a.endT,fromCam:d,toCam:l,easing:Lr,interp:uo,intent:co}];g()}if(h.tag==="Nothing")return[{startT:a.startT,endT:a.endT,fromCam:d,toCam:l,easing:Lr,interp:uo,intent:co}]}g()}if(c.tag==="Nothing")return[];g()}if(s.tag==="Nothing")return[];g()}),o0=t=>e=>n=>r=>o=>i=>{const a=K5(t)(e)(n)(r)(o)(i);return[...a,...F5(a)(Y5(t)(e)(n)(r)(o)(i))]},Co=(t,e)=>({tag:t,_1:e}),Mu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Fn=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},i0=fe(R)(Wt),a0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},s0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Qu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Wu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},Ni=(()=>{const t=wn.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return J("Just",S(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._3,n(r._6,o)));g()};return n(e,D)})())})(),j5=v(t=>e=>it(R)(e)()(t))(M),n1=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},u0=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Z5=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Hu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},tS=Co("NoKeyframes"),eS=t=>Co("DuplicateEventId",t),nS=t=>Co("UnknownEvent",t),rS=t=>e=>({...e,cameraSpans:o0(e.cameraConfig)(t)(e.timing.edgeEasing)(e.layout)(e.keyframes)({endT:e.totalDuration,spans:e.spans,windows:e.windows,segments:e.segments,dives:e.dives}),cameraViewport:t}),oS=t=>e=>n=>r=>{const o=Mu(r.edge)(e.edges),i=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return Ja(o._1);g()})(),a=Fn(t.minTokenDuration)(Fn(rt(v(s=>u=>s+on(u).length|0)(0)(r.labels))*t.tokenReadSecPerChar)(t.tokenSpeed<=0?0:i/t.tokenSpeed))+n.post;return{duration:a,holdPre:0,holdPost:a<=0?0:n.post/a}},iS=_s(t=>{const e=zi(`
9
- `)(t);return e.length===0?[""]:e}),aS=t=>e=>i0(Tt(n=>{if(n.kind.tag==="SendToken")return J("Just",S(n.id,{post:(()=>{const r=n.id;return(()=>{const o=n.kind._1.to;return ue(i=>{if(i.kind.tag==="SendToken")return(i.when.tag==="First"?!1:i.when.tag==="After"&&i.when._1===r)&&i.kind._1.from===o;if(i.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})()}));if(n.kind.tag==="FillNodeWithoutTransition")return T;g()})(e)),sS=t=>{if(t.event.kind.tag==="SendToken")return J("Just",{startT:t.startT,endT:t.endT,target:Oo("TokenWindow",t.event.id,t.event.kind._1.edge,t.event.kind._1.direction,t.event.kind._1.from,t.event.kind._1.to,t.event.kind._1.labels,t.holdPre,t.holdPost)});if(t.event.kind.tag==="FillNodeWithoutTransition")return J("Just",{startT:t.startT,endT:t.endT,target:Oo("FillWindow",t.event.id,t.event.kind._1.node,t.event.kind._1.labels)});g()},uS=t=>Tt((()=>{const e=t.path;return n=>n.target.tag==="TokenWindow"?J("Just",{path:e,eventId:n.target._1,window:n,from:n.target._4,to:n.target._5,labels:n.target._6,holdPre:n.target._7,holdPost:n.target._8}):T})())(t.windows),cS=t=>e=>n=>{const r=Mu(n)(t);if(r.tag==="Nothing")return Pf;if(r.tag==="Just"){const o=a0(r._1.target)(e);return a0(r._1.source)(e)?o?sT:aT:Pf}g()},c0=t=>e=>{if(t.tag==="Just"&&t._1>e.endT+1e-4){const n=Fn(0)(e.endT-e.startT),r=Fn(e.startT)(t._1-n);return{...e,startT:r,endT:r+n}}return e},g0=V(ua),gS={post:0},_S=t=>e=>n=>r=>o=>{const i=s0(o.event.id)(n),a=(()=>{if(i.tag==="Nothing")return gS;if(i.tag==="Just")return i._1;g()})(),s=(()=>{if(o.event.when.tag==="First")return 0;if(o.event.when.tag==="At")return o.event.when._1;if(o.event.when.tag==="After"){const c=o.event.when._1,_=ne(f=>f.event.id===c)(r);if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1.endT;g()}if(o.event.when.tag==="With"){const c=o.event.when._1,_=ne(f=>f.event.id===c)(r);if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1.startT}g()})(),u=(()=>{if(o.event.kind.tag==="SendToken")return oS(t)(e)(a)(o.event.kind._1);if(o.event.kind.tag==="FillNodeWithoutTransition")return{duration:t.plop,holdPre:0,holdPost:0};g()})();return wt(r)({startT:s,endT:s+u.duration,event:o.event,holdPre:u.holdPre,holdPost:u.holdPost})},_0=t=>e=>n=>v(_S(t)(e)(aS(t)(n)))([])(Ht(r=>o=>({event:o}))(n)),fS=t=>v(e=>n=>{const r=_r(e);if(r.tag==="Nothing")return[n];if(r.tag==="Just")return n.startT<=r._1.last.endT+1e-4?wt(r._1.init)({...r._1.last,endT:Fn(r._1.last.endT)(n.endT)}):wt(e)(n);g()})([])(Gt(e=>n=>at.compare(e.startT)(n.startT))(t)),lS=t=>e=>{const n=Qu(e)(t.interiors);if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},dS=t=>e=>{const n=Gt(at.compare)(Tt(r=>r.target.tag==="RelabelWindow"?r.target._1===e?J("Just",r.startT):T:r.target.tag==="TokenWindow"?r.target._4===e||r.target._5===e?J("Just",r.startT):T:r.target.tag==="FillWindow"&&r.target._2===e?J("Just",r.startT):T)(t));return 0<n.length?J("Just",n[0]):T},hS=t=>e=>{const n=Gt(at.compare)(Tt(r=>r.target.tag==="TokenWindow"&&r.target._2===e?J("Just",r.startT):T)(t));return 0<n.length?J("Just",n[0]):T},pS=t=>e=>e.target.tag==="NodeWindow"?e.target._2==="PlopIn"?c0(dS(t.windows)(e.target._1))(e):e:e.target.tag==="EdgeWindow"&&e.target._2.tag==="Extend"?c0(hS(t.windows)(e.target._1))(e):e,mS=t=>({...t,windows:Gt(e=>n=>at.compare(e.startT)(n.startT))(V(pS(t))(t.windows))}),yS=t=>{if(t.when.tag==="First")return[];if(t.when.tag==="At")return[];if(t.when.tag==="After")return[t.when._1];if(t.when.tag==="With")return[t.when._1];g()},Ou={id:"",nodes:M,edges:M,labels:M,kind:ma},xS=t=>e=>ox((()=>{const n=Wu(e.from)(t);if(n.tag==="Nothing")return Ou;if(n.tag==="Just")return n._1;g()})())((()=>{const n=Wu(e.to)(t);if(n.tag==="Nothing")return Ou;if(n.tag==="Just")return n._1;g()})()),TS=t=>e=>{const n=Qu(e)(t.interiors);if(n.tag==="Nothing")return{layout:t.layout,interiors:M};if(n.tag==="Just")return n._1;g()},f0={id:"",index:-1,kind:"",name:"",time:0,endTime:0,path:[],tokenIndex:-1,lineIndex:-1,text:"",from:"",to:""},wS=t=>e=>e.scene.tag==="StepScene"?J("Just",{...f0,id:"step:"+e.scene._1,kind:"step",name:e.scene._1,time:e.startT,endTime:e.startT,path:g0(t)}):T,NS=t=>Tt(wS(t.path))(t.spans),r1=t=>e=>n=>r=>{const o=Mu(r)(n.edges);if(o.tag==="Just")return t<=0?e:Fn(e)(Ja(o._1)/t);if(o.tag==="Nothing")return e;g()},l0=t=>e=>n=>r=>o=>{const i=Wu(o.to)(n),a=(()=>{if(i.tag==="Nothing")return Ou;if(i.tag==="Just")return i._1;g()})(),s=t.plop,u=Wu(o.from)(n),c=(()=>{if(u.tag==="Nothing")return Ou;if(u.tag==="Just")return u._1;g()})(),_=xS(n)(o),f=V(y=>({startT:0,endT:0+r1(t.edgeSpeed)(t.minEdgeDuration)(e)(y),target:Oo("EdgeWindow",y,Is("Extend",sg))}))(Ni(_.entering.edges)),l=V(y=>({startT:0,endT:s,target:Oo("NodeWindow",y,rg)}))(Ni(_.entering.nodes)),d=V(y=>({startT:0,endT:t.plop,target:Oo("RelabelWindow",y.node,y.oldLabel,y.newLabel)}))(Tt(y=>{const w=Qu(y)(c.labels);if(w.tag==="Just"){const N=Qu(y)(a.labels);if(N.tag==="Just")return w._1===N._1?T:J("Just",{node:y,oldLabel:w._1,newLabel:N._1});if(N.tag==="Nothing")return T;g()}if(w.tag==="Nothing")return T;g()})(Ni(_.surviving.nodes))),h=v(Fn)(0)(V(y=>r1(t.edgeSpeed)(t.minEdgeDuration)(e)(y))(Ni(_.leaving.edges))),p=y=>ue(w=>{const N=Mu(w)(r);if(N.tag==="Just")return N._1.source===y||N._1.target===y;if(N.tag==="Nothing")return!1;g()},Ni(_.leaving.edges))?h:0,m=V(y=>({startT:p(y),endT:p(y)+t.plop,target:Oo("NodeWindow",y,nT)}))(Ni(_.leaving.nodes)),x=V(y=>({startT:0,endT:r1(t.edgeSpeed)(t.minEdgeDuration)(e)(y),target:Oo("EdgeWindow",y,Is("Retract",cS(r)(_.leaving.nodes)(y)))}))(Ni(_.leaving.edges));return{duration:(()=>{const y=Gt(at.compare)([...V(N=>N.endT)(x),...V(N=>N.endT)(m),...V(N=>N.endT)(l),...V(N=>N.endT)(d),...V(N=>N.endT)(f)]),w=y.length-1|0;return w>=0&&w<y.length?y[w]+t.gap:t.gap})(),windows:[...x,...m,...l,...d,...f]}},JS=t=>e=>n=>r=>o=>i=>V((()=>{const a=o.startT;return s=>({...s,startT:s.startT+a,endT:s.endT+a})})())(l0(t)(e)(n)(r)(i).windows),vS=t=>Tt(e=>Bt(Li,e).length>1?J("Just",(()=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),Bt(Li,e));if(n.tag==="Just")return n._1.head;if(n.tag==="Nothing")return"";g()})()):T)(D2(sa)(Gt(R.compare)(t))),CS=t=>{const e=V(r=>r.id)(t),n=j5(e);return[...V(eS)(vS(e)),...V(nS)(gt(r=>!n1(r)(n),Et(t)(yS)))]},bS=t=>{const e=i0(V(r=>S(r.id,(()=>{if(r.when.tag==="First")return[];if(r.when.tag==="At")return[];if(r.when.tag==="After")return[r.when._1];if(r.when.tag==="With")return[r.when._1];g()})()))(t)),n=r=>o=>i=>{if(n1(i)(o))return[Co("ScheduleCycle",[...Bt(fn.foldr,o),i])];if(n1(i)(r))return[];const a=s0(i)(e);if(a.tag==="Nothing")return[];if(a.tag==="Just")return Et(a._1)(n(it(R)(i)()(r))(it(R)(i)()(o)));g()};return Et(t)(r=>n(M)(M)(r.id))},kS={plop:.5,gap:0,edgeSpeed:350,minEdgeDuration:.3,tokenSpeed:250,minTokenDuration:1.8,tokenHold:0,stillHold:1.8,hatchHold:0,tokenReadSecPerChar:.06,nodeEasing:dx,edgeEasing:Lr,tokenEasing:bs,diveDur:2.45,retreatDur:2.45},LS=t=>e=>n=>r=>V((()=>{const o=n.startT;return i=>({...i,startT:i.startT+o,endT:i.endT+o})})())(Tt(sS)(_0(t)(e)(r.events))),SS=t=>e=>n=>r=>o=>{if(o.scene.tag==="Structural")return JS(t)(e)(n)(r)(o)(o.scene._1);if(o.scene.tag==="Hold")return[];if(o.scene.tag==="DataFlow")return LS(t)(e)(o)(o.scene._1);if(o.scene.tag==="EnterNode")return[];if(o.scene.tag==="ExitNode")return[];if(o.scene.tag==="StepScene")return[];g()},ES=t=>e=>n=>{const r=_0(t)(e)(n.events);return r.length===0?t.gap:v(Fn)(0)(V(o=>o.endT)(r))+t.gap},PS=t=>e=>n=>r=>o=>{if(o.tag==="Structural")return l0(t)(e)(n)(r)(o._1).duration;if(o.tag==="Hold")return t.stillHold;if(o.tag==="DataFlow")return ES(t)(e)(o._1);if(o.tag==="EnterNode"||o.tag==="ExitNode"||o.tag==="StepScene")return 0;g()},d0=t=>e=>n=>r=>o=>i=>{const a=eT(e)(r),s=n.layout,u=hf(V(m=>S(m.id,m))(o.keyframes)),c=0<o.keyframes.length?J("Just",o.keyframes[0]):T,_=(()=>{if(c.tag==="Just")return c._1.id;if(c.tag==="Nothing")return"";g()})(),f=fx(o),l=m=>({startT:m.runStart,endT:m.t,path:r,layout:s,placement:a,windows:m.runWindows,spans:m.runSpans,keyframes:u,initialKeyframe:_,edgeEndpoints:f}),d=m=>({segments:m.runSpans.length===0?m.segments:wt(m.segments)(l(m)),spans:m.spans,windows:m.windows,dives:m.dives}),h=v(m=>x=>{if(x.tag==="EnterNode"){const b=d(m),C=m.runSpans.length===0?{...b,segments:wt(b.segments)(l(m))}:b,L=m.t+t.diveDur,E=wt(r)(x._1),I=d0(t)(e)(TS(n)(x._1))(E)(lS(o)(x._1))(L),W=I.endT+t.retreatDur;return{...m,t:W,runStart:W,runSpans:[],runWindows:[],segments:[...C.segments,...I.segments],spans:[...C.spans,...I.spans],windows:[...C.windows,...I.windows],dives:[...C.dives,{startT:m.t,endT:L,node:x._1,parentPath:r,childPath:E,direction:rT},...I.dives,{startT:I.endT,endT:W,node:x._1,parentPath:r,childPath:E,direction:oT}]}}if(x.tag==="ExitNode")return m;const y=m.t+PS(t)(s)(u)(f)(x),w={startT:m.t,endT:y,scene:x},N=SS(t)(s)(u)(f)(w);return{...m,t:y,runSpans:wt(m.runSpans)(w),runWindows:[...m.runWindows,...N],spans:wt(m.spans)(w),windows:[...m.windows,...N]}})({t:i,runStart:i,runSpans:[],runWindows:[],segments:[],spans:[],windows:[],dives:[]})(o.scenes),p=d(h);return{endT:h.t,spans:p.spans,windows:Gt(m=>x=>at.compare(m.startT)(x.startT))(p.windows),segments:p.segments,dives:p.dives}},GS=t=>e=>{const n=at.compare(t.time)(e.time);return n==="EQ"?R.compare(t.id)(e.id):n},Zn=t=>e=>e-v(n=>r=>n+Fn(0)(u0(e)(r.endT)-r.startT))(0)(t),RS=t=>e=>{const n=Fn(t.startT)(e.startT),r=u0(t.endT)(e.endT);return r>n+1e-4?J("Just",{startT:n,endT:r}):T},AS=t=>e=>{if(e.scene.tag==="Structural"){const n=v(r=>o=>({cursor:Fn(r.cursor)(o.endT),cuts:o.startT>r.cursor+1e-4?wt(r.cuts)({startT:r.cursor,endT:o.startT}):r.cuts}))({cursor:e.startT,cuts:[]})(Gt(r=>o=>at.compare(r.startT)(o.startT))(Tt(RS(e))(t)));return e.endT>n.cursor+1e-4?wt(n.cuts)({startT:n.cursor,endT:e.endT}):n.cuts}return[]},IS=t=>{const e=fS(Et(t.spans)(AS(t.windows)));return e.length===0?t:{...t,endT:Zn(e)(t.endT),spans:V(n=>({...n,startT:Zn(e)(n.startT),endT:Zn(e)(n.endT)}))(t.spans),windows:Gt(n=>r=>at.compare(n.startT)(r.startT))(V(n=>({...n,startT:Zn(e)(n.startT),endT:Zn(e)(n.endT)}))(t.windows)),segments:V(n=>({...n,startT:Zn(e)(n.startT),endT:Zn(e)(n.endT),spans:V(r=>({...r,startT:Zn(e)(r.startT),endT:Zn(e)(r.endT)}))(n.spans),windows:Gt(r=>o=>at.compare(r.startT)(o.startT))(V(r=>({...r,startT:Zn(e)(r.startT),endT:Zn(e)(r.endT)}))(n.windows))}))(t.segments),dives:V(n=>({...n,startT:Zn(e)(n.startT),endT:Zn(e)(n.endT)}))(t.dives)}},FS=t=>{const e=V(mS)(t.segments);return IS({...t,segments:e,windows:Gt(n=>r=>at.compare(n.startT)(r.startT))(Et(e)(n=>n.windows))})},DS=t=>e=>n=>{const r=Fn(.05)(1-t-e),o=u=>{if(u<=0)return 0;if(u>=1)return 1;const c=t+u*r;return c<0?0:c>1?1:c},i=iS(n),a=V(u=>rt(Z5(1)(on(u).length)))(i),s=Fn(1)(v(hr)(0)(a));return Ht(u=>c=>({lineIndex:u,text:c,start:o(v(hr)(0)(u<1?[]:Rt(0,u,a))/s),end:o(u>=0&&u<a.length?(v(hr)(0)(u<1?[]:Rt(0,u,a))+a[u])/s:(v(hr)(0)(u<1?[]:Rt(0,u,a))+1)/s)}))(i)},zS=t=>{const e=Fn(0)(t.window.endT-t.window.startT);return V(n=>({...f0,id:"token:"+t.eventId+":line:"+ae(n.lineIndex),kind:"tokenLine",time:t.window.startT+n.start*e,endTime:t.window.startT+n.end*e,path:g0(t.path),tokenIndex:t.tokenIndex,lineIndex:n.lineIndex,text:n.text,from:t.from,to:t.to}))(DS(t.holdPre)(t.holdPost)(t.labels))},BS=t=>Et(Ht(e=>n=>({path:n.path,eventId:n.eventId,window:n.window,from:n.from,to:n.to,labels:n.labels,holdPre:n.holdPre,holdPost:n.holdPost,tokenIndex:e}))(Et(t)(uS)))(zS),MS=t=>Ht(e=>n=>({...n,index:e}))(Gt(GS)([...Et(t.segments)(NS),...BS(t.segments)])),QS=t=>e=>{if(e.tag==="Structural")return Tt(n=>n)([Hu(e._1.from)(t)?T:J("Just",Co("UnknownKeyframe",e._1.from)),Hu(e._1.to)(t)?T:J("Just",Co("UnknownKeyframe",e._1.to))]);if(e.tag==="Hold")return Tt(n=>n)([Hu(e._1)(t)?T:J("Just",Co("UnknownKeyframe",e._1))]);if(e.tag==="DataFlow")return[...Tt(n=>n)([Hu(e._1.keyframe)(t)?T:J("Just",Co("UnknownKeyframe",e._1.keyframe))]),...CS(e._1.events),...bS(e._1.events)];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];if(e.tag==="StepScene")return[];g()},WS=t=>e=>{const n=Et(e)(QS(t));return n.length===0?Dt("Right",void 0):Dt("Left",n)},HS=t=>e=>n=>r=>o=>{if(0<r.keyframes.length){const i=r.keyframes[0],a=hf(V(u=>S(u.id,u))(r.keyframes)),s=WS(a)(r.scenes);return(()=>{if(s.tag==="Left"){const u=s._1;return c=>Dt("Left",u)}if(s.tag==="Right"){const u=s._1;return c=>c(u)}g()})()(()=>{const u=FS(d0(n)(o)(o)([])(r)(0)),c=r.minimumFontSize.tag==="Just"&&r.minimumFontSize._1>0?{...t,minimumReadableLabelPx:r.minimumFontSize._1}:t;return Dt("Right",{totalDuration:u.endT,windows:u.windows,spans:u.spans,keyframes:a,initialKeyframe:i.id,timing:n,layout:o.layout,cameraSpans:o0(c)(e)(n.edgeEasing)(o.layout)(a)(u),cameraConfig:c,cameraViewport:e,levelTree:o,segments:u.segments,dives:u.dives,cues:MS(u),seed:r.seed})})}return Dt("Left",[tS])},Ji=t=>({bind:e=>n=>r=>t.Bind1().bind(e(r))(o=>n(o._1)(o._2)),Apply0:()=>h0(t)}),h0=t=>{const e=t.Bind1().Apply0().Functor0(),n={map:r=>o=>i=>e.map(a=>S(r(a._1),a._2))(o(i))};return{apply:(()=>{const r=Ji(t);return o=>i=>r.bind(o)(a=>r.bind(i)(s=>vi(t).pure(a(s))))})(),Functor0:()=>n}},vi=t=>({pure:e=>n=>t.Applicative0().pure(S(e,n)),Apply0:()=>h0(t)}),p0=t=>{const e={Applicative0:()=>vi(t),Bind1:()=>Ji(t)};return{state:n=>r=>t.Applicative0().pure(n(r)),Monad0:()=>e}},tr=(t,e)=>({tag:"ParseError",_1:t,_2:e}),k=(t,e,n)=>({tag:"ParseState",_1:t,_2:e,_3:n}),qu=(t,e,n)=>({tag:t,_1:e,_2:n}),OS=t=>qu("More",t),qS=t=>qu("Lift",t),VS={defer:t=>{const e=Iy(t);return(n,r,o,i,a)=>Fy(e)(n,r,o,i,a)}},m0={map:t=>e=>(n,r,o,i,a)=>r(s=>e(n,r,o,i,(u,c)=>r(_=>a(u,t(c)))))},$S={alt:t=>e=>(n,r,o,i,a)=>{const s=n._1,u=n._2;return r(c=>t(k(s,u,!1),r,o,(_,f)=>{const l=_._3;return r(d=>l?i(_,f):e(n,r,o,i,a))},a))},Functor0:()=>m0},US=t=>{const e=t.Monad0();return n=>r=>{const o=i=>{let a=i,s=!0,u;for(;s;){const c=a();if(c.tag==="More"){a=c._1;continue}if(c.tag==="Lift"){s=!1,u=e.Bind1().Apply0().Functor0().map(yc)(c._1);continue}if(c.tag==="Stop"){s=!1,u=e.Applicative0().pure(ki("Done",S(c._2,c._1)));continue}g()}return u};return t.tailRecM(o)(i=>r(n,OS,qS,(a,s)=>qu("Stop",a,Dt("Left",s)),(a,s)=>qu("Stop",a,Dt("Right",s))))}},Dn=(t,e,n,r,o)=>o(t,t._2),XS={index:0,line:1,column:1},y0=(t=>{const e=US(t);return n=>r=>t.Monad0().Bind1().Apply0().Functor0().map(gs)(e(k(n,XS,!1))(r))})(s2),Vu=(t,e,n,r,o)=>o(k(t._1,t._2,!0),void 0),x0={apply:t=>e=>(n,r,o,i,a)=>r(s=>t(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?k(u._1,u._2,!0):u;return e(f,r,o,i,(l,d)=>r(h=>a(f._3&&!l._3?k(l._1,l._2,!0):l,c(d))))}))),Functor0:()=>m0},T0={pure:t=>(e,n,r,o,i)=>i(e,t),Apply0:()=>x0},YS={bind:t=>e=>(n,r,o,i,a)=>r(s=>t(n,r,o,i,(u,c)=>r(_=>e(c)(n._3&&!u._3?k(u._1,u._2,!0):u,r,o,i,a)))),Apply0:()=>x0},KS={Applicative0:()=>T0,Bind1:()=>YS},$u=t=>(e,n,r,o,i)=>n(a=>Dn(e,n,r,o,(s,u)=>n(c=>o(e._3&&!s._3?k(s._1,s._2,!0):s,tr(t,u))))),jS={empty:$u("No alternative"),Alt0:()=>$S},ZS={Applicative0:()=>T0,Plus1:()=>jS},ze=(t=>e=>{const n=e.Plus1().Alt0(),r=e.Applicative0();return o=>t.tailRecM(i=>t.Monad0().Bind1().bind(n.alt(n.Functor0().map(yc)(o))(r.pure(ki("Done",void 0))))(a=>r.pure((()=>{if(a.tag==="Loop")return ki("Loop",yt("Cons",a._1,i));if(a.tag==="Done")return ki("Done",(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Nil"){f=!1,l=d;continue}if(h.tag==="Cons"){c=yt("Cons",h._1,d),_=h._2;continue}g()}return l})(D)(i));g()})())))(D)})({tailRecM:t=>e=>(n,r,o,i,a)=>{const s=(u,c,_)=>t(c)(u,r,o,i,(f,l)=>{const d=u._3&&!f._3?k(f._1,f._2,!0):f;if(l.tag==="Loop")return _===0?r(h=>s(d,l._1,30)):s(d,l._1,_-1|0);if(l.tag==="Done")return a(d,l._1);g()});return s(n,e,30)},Monad0:()=>KS})(ZS),pt=t=>e=>{const n=$u("Expected "+e);return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>t(k(u,c,!1),o,i,(f,l)=>{const d=f._3;return o(h=>d?a(f,l):n(r,o,i,a,s))},s))}},bo=t=>(e,n,r,o,i)=>{const a=e._3,s=e._1,u=e._2;return n(c=>{const _=(f,l)=>{const d=f._3;return n(h=>d?o(k(f._1,f._2,a),l):i(e,void 0))};return n(f=>n(l=>t(k(s,u,!1),n,r,(d,h)=>_(k(d._1,d._2,!1),h),(d,h)=>n(p=>n(m=>$u("Negated parser succeeded")(d,n,r,_,(x,y)=>n(w=>i(d._3&&!x._3?k(x._1,x._2,!0):x,y))))))))})},t4=t=>{const e=t.foldr(n=>r=>{if(r.tag==="Nothing")return J("Just",n);if(r.tag==="Just")return J("Just",(o,i,a,s,u)=>{const c=o._1,_=o._2;return i(f=>n(k(c,_,!1),i,a,(l,d)=>{const h=l._3;return i(p=>h?s(l,d):r._1(o,i,a,s,u))},u))});g()})(T);return n=>{const r=e(n);if(r.tag==="Nothing")return $u("No alternative");if(r.tag==="Just")return r._1;g()}},w0=t=>e=>n=>(r,o,i,a,s)=>o(u=>o(c=>o(_=>o(f=>t(r,o,i,a,(l,d)=>o(h=>o(p=>{const m=r._3&&!l._3?k(l._1,l._2,!0):l;return n(m,o,i,a,(x,y)=>o(w=>{const N=m._3&&!x._3?k(x._1,x._2,!0):x;return o(b=>o(C=>{const L=r._3&&!N._3?k(N._1,N._2,!0):N;return e(L,o,i,a,(E,I)=>o(W=>s(L._3&&!E._3?k(E._1,E._2,!0):E,y)))}))}))}))))))),o1=t=>e=>n=>{if(e===10)return{index:t.index+1|0,line:t.line+1|0,column:1};if(e===13){const r=Xx()(n);return r.tag==="Just"&&r._1===10?{index:t.index+1|0,line:t.line,column:t.column}:{index:t.index+1|0,line:t.line+1|0,column:1}}return e===9?{index:t.index+1|0,line:t.line,column:(t.column+8|0)-ao(t.column-1|0)(8)|0}:{index:t.index+1|0,line:t.line,column:t.column+1|0}},e4=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i,f=Rs(c);if(f.tag==="Nothing"){a=!1,s=u;continue}if(f.tag==="Just"){r=f._1.tail===""?o1(u)(f._1.head)(_):o1(u)(f._1.head)(f._1.tail),o=f._1.tail,i=_;continue}g()}return s},At=t=>(e,n,r,o,i)=>{const a=Rs(e._1);if(a.tag==="Nothing")return o(e,tr("Unexpected EOF",e._2));if(a.tag==="Just"){if(a._1.head<0||a._1.head>65535)return o(e,tr("Expected Char",e._2));if(a._1.head>=0&&a._1.head<=65535){const s=wf(a._1.head);return t(s)?i(k(a._1.tail,o1(e._2)(a._1.head)(a._1.tail),!0),s):o(e,tr("Predicate unsatisfied",e._2))}}g()},oa=(t,e,n,r,o)=>t._1===""?o(k(t._1,t._2,!0),void 0):r(t,tr("Expected EOF",t._2)),n4=t=>(e,n,r,o,i)=>{const a=t(e._1);if(a.tag==="Left")return o(e,tr(a._1,e._2));if(a.tag==="Right")return i(k(a._1.remainder,e4(e._2)(a._1.consumed)(a._1.remainder),a._1.consumed!==""),a._1.value);g()},Le=t=>n4(e=>{const n=rr(t)(e);return n.tag==="Just"?Dt("Right",{value:t,consumed:t,remainder:n._1}):Dt("Left","Expected "+Um(t))}),i1=At(t=>!0),N0=(t,e)=>({tag:t,_1:e}),J0=(t,e,n)=>({tag:t,_1:e,_2:n}),r4=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},v0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},o4=t=>e=>v(n=>r=>(()=>{if(n.tag==="Left"){const o=n._1;return i=>Dt("Left",o)}if(n.tag==="Right"){const o=n._1;return i=>i(o)}g()})()(o=>t(o)(r)))(Dt("Right",e)),C0=t=>e=>n=>r4(t)(n.values)?Dt("Right",{...n,values:it(R)(t)(e)(n.values)}):Dt("Left","label has no placeholder `"+t+"`"),b0=(()=>{const t=bo((e,n,r,o,i)=>{const a=e._3;return Le("{{")(e,n,r,(s,u)=>o(k(s._1,s._2,a),u),i)});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i1(e._3&&!s._3?k(s._1,s._2,!0):s,n,r,o,i))))})(),i4=(()=>{const t=bo((e,n,r,o,i)=>{const a=e._3;return Le("}}")(e,n,r,(s,u)=>o(k(s._1,s._2,a),u),i)});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i1(e._3&&!s._3?k(s._1,s._2,!0):s,n,r,o,i))))})(),ia=t=>Vn("")(V(e=>{if(e.tag==="LabelText")return e._1;if(e.tag==="LabelSlot"){const n=v0(e._1)(t.values);if(n.tag==="Just")return n._1;if(n.tag==="Nothing")return""}g()})(t.parts)),a4=(t,e,n,r,o)=>e(i=>b0(t,e,n,r,(a,s)=>e(u=>{const c=ze(b0),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?k(l._1,l._2,!0):l,J0("ParsedText",Jn([s,...Bt(ce.foldr,d)]))))))}))),s4=t=>t===" "||t===" "||t===`
10
- `||t==="\r",k0=(()=>{const t=ze(At(s4));return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(s,void 0))))})(),u4=t=>t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_",c4=t=>t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"||t>="0"&&t<="9"||t==="-",g4=(t,e,n,r,o)=>e(i=>At(u4)(t,e,n,r,(a,s)=>e(u=>{const c=ze(At(c4)),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?k(l._1,l._2,!0):l,En(s)+Jn(Bt(ce.foldr,d))))))}))),_4=(t,e,n,r,o)=>e(i=>Le("{{")(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?k(a._1,a._2,!0):a;return e(_=>k0(c,e,n,r,(f,l)=>e(d=>{const h=c._3&&!f._3?k(f._1,f._2,!0):f;return e(p=>g4(h,e,n,r,(m,x)=>e(y=>{const w=h._3&&!m._3?k(m._1,m._2,!0):m;return e(N=>k0(w,e,n,r,(b,C)=>e(L=>{const E=pt(At(W=>W===":"))("':'"),I=w._3&&!b._3?k(b._1,b._2,!0):b;return e(W=>E(I,e,n,r,(P,G)=>e(j=>{const nt=ze(i4),O=I._3&&!P._3?k(P._1,P._2,!0):P;return e($=>e(H=>nt(O,e,n,r,(A,B)=>e(z=>{const Q=Jn(Bt(ce.foldr,B));return e(F=>{const X=O._3&&!A._3?k(A._1,A._2,!0):A;return e(q=>Le("}}")(X,e,n,r,(U,Y)=>e(ot=>o(X._3&&!U._3?k(U._1,U._2,!0):U,J0("ParsedSlot",x,Na(Q))))))})}))))})))})))})))})))}))),f4=(()=>{const t=ze((e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>_4(k(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>f?o(c,_):a4(e,n,r,o,i))},i))});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(s,Bt(ce.foldr,u)))))})(),l4=t=>{const e=o4(n=>r=>{if(r.tag==="ParsedText")return Dt("Right",{...n,parts:wt(n.parts)(N0("LabelText",r._1))});if(r.tag==="ParsedSlot"){const o=v0(r._1)(n.values);return o.tag==="Just"&&o._1!==r._2?Dt("Left","placeholder `"+r._1+"` has conflicting initial values"):Dt("Right",{parts:wt(n.parts)(N0("LabelSlot",r._1)),values:it(R)(r._1)(r._2)(n.values)})}g()})({parts:[],values:M})(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",e._1);g()},Uu=t=>{const e=y0(t)((n,r,o,i,a)=>r(s=>r(u=>f4(n,r,o,i,(c,_)=>r(f=>r(l=>{const d=n._3&&!c._3?k(c._1,c._2,!0):c;return oa(d,r,o,i,(h,p)=>r(m=>a(d._3&&!h._3?k(h._1,h._2,!0):h,_)))}))))));if(e.tag==="Left")return Dt("Left",e._1._1);if(e.tag==="Right")return l4(e._1);g()},Ci=(t,e)=>({tag:t,_1:e}),Qr=(t,e)=>({tag:t,_1:e}),Xu=t=>t,er=(t,e)=>({tag:t,_1:e}),a1=t=>t,L0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},d4=fe(R)(Wt),S0=(()=>{const t=wn.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return J("Just",S(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._3,n(r._6,o)));g()};return n(e,D)})())})(),be=p0(Qn),h4=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},p4=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},m4=fe(R)(Wt),s1=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},y4=v(t=>e=>it(R)(e)()(t))(M),Ut=Ji(Qn),Ve=be.state(t=>S(t,t)),ye=vi(Qn),E0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},P0=Go(ye),u1=P0(Wt),x4=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},mr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},yr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},T4=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Yu=t=>e=>n=>v(r=>o=>t.Bind1().bind(r)(i=>e(i)(o)))(t.Applicative0().pure(n)),w4=v(t=>e=>it(R)(e)()(t))(M),N4=(()=>{const t=(e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=o;if(u.tag==="Nil"){i=!1,a=s;continue}if(u.tag==="Cons"){r=it(R)(u._1)()(s),o=u._2;continue}g()}return a})(M);return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._3,n(r._6,o)));g()};return n(e,D)})())})(),J4=v(t=>e=>it(R)(e)()(t))(M),v4=P0(N2),C4=a1("AnimatedSurface"),b4=a1("StillSurface"),k4=a1("SequenceSurface"),L4=er("Exit"),Ku=Xu("AnimatedKeyframe"),c1=Xu("Still"),S4=Xu("Title"),G0=Xu("StepMarker"),E4=t=>Qr("Par",t),P4=t=>Qr("Seq",t),G4=t=>Qr("GroupSeq",t),R0=t=>Ci("StepDive",t),R4={line:0,column:0,endLine:0,endColumn:0},A4=t=>e=>n=>{const r=Or(Vt,T,o=>o._1===t,n);if(r.tag==="Just"){const o=io(Vt,T,r._1,S(t,e),n);if(o.tag==="Nothing")return n;if(o.tag==="Just")return o._1;g()}if(r.tag==="Nothing")return wt(n)(S(t,e));g()},I4=t=>e=>V(n=>n._1===t?S(n._1,{...n._2,label:J("Just",e)}):S(n._1,n._2)),A0=t=>d4(Tt(e=>{const n=L0(e)(t.currLabels);return n.tag==="Just"?J("Just",S(e,n._1)):T})(S0(t.currNodes))),I0=t=>{const e=t.compare;return n=>v(r=>o=>je(e,Xe,r,n(o)))(M)},g1=I0(R),_1=I0(R),F0=t=>e=>be.state(n=>S(void 0,{...n,graphNodes:I4(t)(ia(e))(n.graphNodes),currLabels:it(R)(t)(ia(e))(n.currLabels),currLabelTemplates:it(R)(t)(e)(n.currLabelTemplates)})),F4=t=>{const e=t.span;return be.state(n=>S(void 0,{...n,currentSpan:e}))},D4=rt(4)*8,z4=t=>t.tag==="Just"&&ga(t._1)&&t._1>0?S(h4(1)(t._1/D4),1):S(1,1),B4=t=>e=>({structural:[...t.structural,...e.structural],flow:t.flow||e.flow,dives:[...t.dives,...e.dives]}),M4=t=>e=>e.kind==="Animated"||p4(e.id)(t),D0={graphNodes:[],graphEdges:M,currNodes:M,currEdges:M,currLabels:M,currLabelTemplates:M,keyframes:[],scenes:[],kfCounter:0,eventCounter:0,currentKf:T,currentSpan:R4,error:T,enterStack:[],interiorOf:M,stepNames:M},z0=t=>e=>n=>{const r=Bt(fn.foldr,n);return Vn(", ")(V(e)(Rt(0,6,r)))+(r.length>6?", \u2026":"")},Q4=t=>e=>{const n=s1(e)(m4(V(r=>S(r.id,r))(t.graph.edges)));if(n.tag==="Just")return(()=>{const r=rr("conn:")(n._1.id);if(r.tag==="Just")return!1;if(r.tag==="Nothing")return!0;g()})()?n._1.from.node+" -> "+n._1.to.node:n._1.from.node+" -- "+n._1.to.node;if(n.tag==="Nothing")return e;g()},W4=t=>e=>n=>{const r=z0()(ua)(e),o=z0()(Q4(t))(n);return(r===""?"animated flow contains unused topology: every animated node or edge must be visited by a token or fill.":"animated flow contains unused topology: every animated node or edge must be visited by a token or fill. Unused nodes: "+r+".")+(o===""?"":" Unused edges: "+o+".")+" Move context-only topology into a `still`/`title`, remove it, or add token/fill events."},H4=t=>{if(t.kind.tag==="SendToken")return y4([t.kind._1.from,t.kind._1.to]);if(t.kind.tag==="FillNodeWithoutTransition")return Zt("Node",1,1,t.kind._1.node,void 0,M,M);g()},O4=t=>g1(H4)(t.events),q4=t=>{if(t.kind.tag==="SendToken")return Zt("Node",1,1,t.kind._1.edge,void 0,M,M);if(t.kind.tag==="FillNodeWithoutTransition")return M;g()},V4=t=>_1(q4)(t.events),xr=t=>be.state(e=>S(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:J("Just",{msg:t,line:e.currentSpan.line,column:e.currentSpan.column,endLine:e.currentSpan.endLine,endColumn:e.currentSpan.endColumn})};g()})())),$4=u1(t=>Ut.bind(Ve)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing")return E0(t.node)(e.interiorOf)?xr("node "+t.node+" has more than one `inside` block"):be.state(n=>S(void 0,{...n,interiorOf:it(R)(t.node)(t.doc)(n.interiorOf)}));g()})),U4=t=>Ut.bind(Ve)(e=>{const n=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ae(e.kfCounter);if(ue(o=>o.id===n,e.keyframes))return xr("duplicate frame name "+n);const r={...e,keyframes:wt(e.keyframes)({id:n,nodes:e.currNodes,edges:e.currEdges,labels:A0(e),kind:ma}),kfCounter:e.kfCounter+1|0,currentKf:J("Just",n)};return be.state(o=>S(void 0,r))}),Qe=t=>e=>Ut.bind(be.state(n=>S(void 0,{...n,currentSpan:t})))(()=>xr(e)),B0=t=>e=>Ut.bind(Ve)(n=>x4(e)(n.stepNames)?Qe(t)("duplicate step name "+e):be.state(r=>S(void 0,{...r,scenes:wt(r.scenes)(Fi("StepScene",e)),stepNames:it(R)(e)()(r.stepNames)}))),X4=t=>{if(t.ops.tag==="Leaf"){const e=t.ops._1;return Ut.bind((()=>{const n=e.span;return be.state(r=>S(void 0,{...r,currentSpan:n}))})())(()=>e.op.tag==="Step"?B0(e.span)(e.op._1.name):xr("step marker frame did not contain a step"))}if(t.ops.tag==="Seq"&&t.ops._1.length===1&&t.ops._1[0].tag==="Leaf"){const e=t.ops._1[0]._1;return Ut.bind((()=>{const n=e.span;return be.state(r=>S(void 0,{...r,currentSpan:n}))})())(()=>e.op.tag==="Step"?B0(e.span)(e.op._1.name):xr("step marker frame did not contain a step"))}return xr("step marker frame did not contain a step")},Y4=t=>Ut.bind((()=>{const e=t.span;return be.state(n=>S(void 0,{...n,currentSpan:e}))})())(()=>Ut.bind(Ve)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing"){if(t.op.tag==="Enter"){if(!mr(t.op._1.id)(e.currNodes))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot dive into node "+t.op._1.id+": does not exist");if(!E0(t.op._1.id)(e.interiorOf))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot enter node "+t.op._1.id+": it has no `inside` block. Add the block at the document level, alongside the animated statements:\n\ninside "+t.op._1.id+` {
1
+ var iA=(function(Cc){"use strict";function f2(t){let e=0,n;return()=>{if(e===2)return n;if(e===1)throw new Error("Binding demanded before initialized");return e=1,n=t(),e=2,n}}function g(){throw new Error("Failed pattern match")}function Lr(t,e){return e>0?Math.floor(t/e):e<0?-Math.floor(t/-e):0}const je=t=>e=>t,Y=function(t){return function(e){for(var n=e.length,r=new Array(n),o=0;o<n;o++)r[o]=t(e[o]);return r}},d2={map:Y},O1=t=>t,St=typeof Array.prototype.flatMap=="function"?function(t){return function(e){return t.flatMap(e)}}:function(t){return function(e){for(var n=[],r=t.length,o=0;o<r;o++)for(var i=e(t[o]),a=i.length,s=0;s<a;s++)n.push(i[s]);return n}},l2=function(t){return function(e){return{}.hasOwnProperty.call(e,t)}},h2=function(t){return function(e){return e[t]}},ue=function(t){return t.toString()},bn=function(t){var e=t.toString();return isNaN(e+".0")?e:e+".0"},p2=function(t){var e=t.length;return'"'+t.replace(/[\0-\x1F\x7F"\\]/g,function(n,r){switch(n){case'"':case"\\":return"\\"+n;case"\x07":return"\\a";case"\b":return"\\b";case"\f":return"\\f";case`
2
+ `:return"\\n";case"\r":return"\\r";case" ":return"\\t";case"\v":return"\\v"}var o=r+1,i=o<e&&t[o]>="0"&&t[o]<="9"?"\\&":"";return"\\"+n.charCodeAt(0).toString(10)+i})+'"'},Lc=t=>t,Qe=Lc("LT"),Me=Lc("GT"),sn=Lc("EQ"),w=(t,e)=>({tag:t,_1:e}),y=w("Nothing"),Xt=t=>w("Just",t),W1=t=>{if(t.tag==="Nothing")return!0;if(t.tag==="Just")return!1;g()},H1=t=>{if(t.tag==="Nothing")return!1;if(t.tag==="Just")return!0;g()},Dt=(t,e)=>({tag:t,_1:e}),m2=t=>Dt("Right",t),y2={map:t=>e=>{if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",t(e._1));g()}},$1={apply:t=>e=>{if(t.tag==="Left")return Dt("Left",t._1);if(t.tag==="Right"){if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",t._1(e._1))}g()},Functor0:()=>y2},x2={bind:t=>{if(t.tag==="Left"){const e=t._1;return n=>Dt("Left",e)}if(t.tag==="Right"){const e=t._1;return n=>n(e)}g()},Apply0:()=>$1},J2={pure:m2,Apply0:()=>$1},q1={Applicative0:()=>J2,Bind1:()=>x2},w2=t=>t,T2={map:t=>e=>t(e)},V1={apply:t=>e=>t(e),Functor0:()=>T2},N2={bind:t=>e=>e(t),Apply0:()=>V1},v2={pure:w2,Apply0:()=>V1},Vn={Applicative0:()=>v2,Bind1:()=>N2},b2=function(t){return function(){return t}},C2={apply:t=>e=>()=>{const n=t(),r=e();return kc.pure(n(r))()},Functor0:()=>L2},kc={pure:b2,Apply0:()=>C2},L2={map:t=>e=>()=>{const n=e();return t(n)}},Bi=(t,e)=>({tag:t,_1:e}),Sc=t=>Bi("Loop",t),k2=t=>Bi("Done",t),S2={tailRecM:t=>{const e=n=>{let r=n,o=!0,i;for(;o;){const a=r;if(a.tag==="Loop"){r=t(a._1);continue}if(a.tag==="Done"){o=!1,i=a._1;continue}g()}return i};return n=>e(t(n))},Monad0:()=>Vn},E2=function(t){return function(e){return function(){return t(e())}}},P2=function(t){return function(){return t}},G2=function(t){return function(e){return function(){return e(t())()}}},A2={map:E2},B2={Applicative0:()=>Ec,Bind1:()=>R2},R2={bind:G2,Apply0:()=>U1},U1={apply:t=>e=>()=>{const n=t(),r=e();return Ec.pure(n(r))()},Functor0:()=>A2},Ec={pure:P2,Apply0:()=>U1},D2={tailRecM:t=>e=>{const n=t(e);return()=>{let r=n();for(;r.tag==="Loop";){const i=r;if(i.tag==="Loop"){r=t(i._1)();continue}i.tag!=="Done"&&g()}const o=r;if(o.tag==="Done")return o._1;g()}},Monad0:()=>B2},F2=function(t){return function(e){return function(n){return function(){return t(e,n)}}}},z2=function(t,e,n,r){return n>=0&&n<r.length?t(r[n]):e},Pc=function(t){return t.length},I2=function(t,e,n){return n.length>0?t(n.pop()):e},Q2=F2(function(t,e){return e.push(t)}),M2=(t,e)=>({tag:"Iterator",_1:t,_2:e}),O2=t=>e=>n=>()=>{let r=!1;const o=e._2;for(;!r;){const i=o.value,a=e._1(i);if(a.tag==="Just"&&t(a._1)){n.push(a._1),e._2.value;const s=e._2.value;e._2.value=s+1|0;continue}r=!0}},W2=t=>e=>()=>{let n=!1;const r=t._2;for(;!n;){const o=r.value,i=r.value;r.value=i+1|0;const a=t._1(o);if(a.tag==="Just"){e(a._1)();continue}if(a.tag==="Nothing"){n=!0;continue}g()}},Ri=function(t){return function(e){return function(n){for(var r=e,o=n.length,i=o-1;i>=0;i--)r=t(n[i])(r);return r}}},v=function(t){return function(e){return function(n){for(var r=e,o=n.length,i=0;i<o;i++)r=t(r)(n[i]);return r}}},Do=t=>{const e=t.Apply0();return n=>r=>n.foldr(o=>{const i=r(o);return a=>e.apply(e.Functor0().map(s=>O1)(i))(a)})(t.pure())},Di=t=>{const e=Do(t);return n=>{const r=e(n);return o=>i=>r(i)(o)}},H2={foldr:t=>e=>n=>{if(n.tag==="Nothing")return e;if(n.tag==="Just")return t(n._1)(e);g()},foldl:t=>e=>n=>{if(n.tag==="Nothing")return e;if(n.tag==="Just")return t(e)(n._1);g()},foldMap:t=>{const e=t.mempty;return n=>r=>{if(r.tag==="Nothing")return e;if(r.tag==="Just")return n(r._1);g()}}},Qt={foldr:Ri,foldl:v,foldMap:t=>{const e=t.mempty;return n=>Qt.foldr(r=>o=>t.Semigroup0().append(n(r))(o))(e)}},E=(t,e)=>({tag:"Tuple",_1:t,_2:e}),Cn=t=>e=>E(t,e),Js=t=>t._2,ws=t=>t._1,Mt=function(t){return function(e){for(var n=e.length,r=Array(n),o=0;o<n;o++)r[o]=t(o)(e[o]);return r}};var Gc=function(t){return function(e){return t===e}};const $2=Gc,q2=Gc,Fi=Gc,Ts=function(t){return function(e){return function(n){if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(!t(e[r])(n[r]))return!1;return!0}}},kr={eq:Fi},V2={eq:q2},io={eq:$2};var Ac=function(t){return function(e){return function(n){return function(r){return function(o){return r<o?t:r===o?e:n}}}}};const U2=Ac,K2=Ac,B={compare:Ac(Qe)(sn)(Me),Eq0:()=>kr},at={compare:K2(Qe)(sn)(Me),Eq0:()=>V2},ut={compare:U2(Qe)(sn)(Me),Eq0:()=>io},wa=function(t){return t},Y2=(function(){function t(o){return[o]}function e(o){return function(i){return[o,i]}}function n(o){return function(i){return function(a){return[o,i,a]}}}function r(o){return function(i){return o.concat(i)}}return function(o){return function(i){return function(a){return function(s){return function(u){function c(_,f){switch(f-_){case 0:return a([]);case 1:return i(t)(s(u[_]));case 2:return o(i(e)(s(u[_])))(s(u[_+1]));case 3:return o(o(i(n)(s(u[_])))(s(u[_+1])))(s(u[_+2]));default:var l=_+Math.floor((f-_)/4)*2;return o(i(r)(c(_,l)))(c(l,f))}}return c(0,u.length)}}}}}})(),X2=t=>t,ao={traverse:t=>{const e=t.Apply0();return Y2(e.apply)(e.Functor0().map)(t.pure)},sequence:t=>ao.traverse(t)(X2),Functor0:()=>d2,Foldable1:()=>Qt},Ut=function(t,e){for(var n=t>e?-1:1,r=new Array(n*(e-t)+1),o=t,i=0;o!==e;)r[i++]=o,o+=n;return r[i]=o,r};var Z2=function(t,e){if(t<1)return[];var n=new Array(t);return n.fill(e)},j2=function(t,e){for(var n=[],r=0,o=0;o<t;o++)n[r++]=e;return n};const Fo=typeof Array.prototype.fill=="function"?Z2:j2,It=(function(){function t(o,i){this.head=o,this.tail=i}var e={};function n(o){return function(i){return new t(o,i)}}function r(o){for(var i=[],a=0,s=o;s!==e;)i[a++]=s.head,s=s.tail;return i}return function(o,i){return r(o(n)(e)(i))}})(),ty=function(t){return t.length},Ft=function(t,e,n){return n.length===0?t({}):e(n[0])(n.slice(1))},K1=function(t,e,n,r){for(var o=0;o<r.length;o++){var i=n(r[o]);if(e(i))return i}return t},zo=function(t,e,n,r){for(var o=0,i=r.length;o<i;o++)if(n(r[o]))return t(o);return e},Y1=function(t,e,n,r,o){if(n<0||n>o.length)return e;var i=o.slice();return i.splice(n,0,r),t(i)},X1=function(t,e,n,r){if(n<0||n>=r.length)return e;var o=r.slice();return o.splice(n,1),t(o)},so=function(t,e,n,r,o){if(n<0||n>=o.length)return e;var i=o.slice();return i[n]=r,t(i)},re=function(t){return t.slice().reverse()},Ln=function(t){if(t.length<=1e4)return Array.prototype.concat.apply([],t);for(var e=[],n=0,r=t.length;n<r;n++)for(var o=t[n],i=0,a=o.length;i<a;i++)e.push(o[i]);return e},_t=function(t,e){return e.filter(t)},ey=function(t,e,n){for(var r=n.length,o=e,i=new Array(r),a=0;a<r;a++)o=t(o)(n[a]),i[a]=o;return i},ny=(function(){function t(e,n,r,o,i,a){var s,u,c,_,f,l,d;for(s=i+(a-i>>1),s-i>1&&t(e,n,o,r,i,s),a-s>1&&t(e,n,o,r,s,a),u=i,c=s,_=i;u<s&&c<a;)f=o[u],l=o[c],d=n(e(f)(l)),d>0?(r[_++]=l,++c):(r[_++]=f,++u);for(;u<s;)r[_++]=o[u++];for(;c<a;)r[_++]=o[c++]}return function(e,n,r){var o;return r.length<2?r:(o=r.slice(0),t(e,n,o,r.slice(0),0,r.length),o)}})(),Bt=function(t,e,n){return n.slice(t,e)},Oe=function(t,e,n){for(var r=e.length<n.length?e.length:n.length,o=new Array(r),i=0;i<r;i++)o[i]=t(e[i])(n[i]);return o},oe=function(t,e){for(var n=e.length,r=0;r<n;r++)if(t(e[r]))return!0;return!1},Bc=function(t,e){for(var n=e.length,r=0;r<n;r++)if(!t(e[r]))return!1;return!0},Pt=t=>e=>ny(t,n=>{if(n==="GT")return 1;if(n==="EQ")return 0;if(n==="LT")return-1;g()},e),ry=t=>e=>Pt(n=>r=>t.compare(e(n))(e(r))),Et=t=>e=>(()=>{const n=Q2(e);return()=>{const r=[...t];return n(r)(),r}})()(),Sr=t=>{if(t.length===0)return t.length-1|0,y;const e=t.length-1|0;return e>=0&&e<t.length?w("Just",{init:Bt(0,t.length-1|0,t),last:t[e]}):y},oy=t=>e=>n=>t>=0&&t<n.length?so(Xt,y,t,e(n[t]),n):y,Er=t=>e=>{const n=(r=>{let o=r,i=!0,a;for(;i;){const s=o;if(s>=0&&s<e.length){if(t(e[s])){o=s+1|0;continue}i=!1,a=w("Just",s);continue}i=!1,a=y}return a})(0);if(n.tag==="Just")return n._1===0?{init:[],rest:e}:{init:Bt(0,n._1,e),rest:Bt(n._1,e.length,e)};if(n.tag==="Nothing")return{init:e,rest:[]};g()},$r=t=>e=>{const n=Pt(r=>o=>t(r._2)(o._2))(Mt(Cn)(e));return 0<n.length?Y(Js)(ry(ut)(ws)((()=>{const r=[n[0]];for(const o of n){const i=t((()=>{const a=r.length-1|0;if(a>=0&&a<r.length)return r[a]._2;g()})())(o._2);(i==="LT"||i==="GT"||i!=="EQ")&&r.push(o)}return r})())):[]},iy=t=>e=>{const n=[],r=M2(o=>o>=0&&o<e.length?w("Just",e[o]):y,{value:0});return W2(r)(o=>()=>{const i=[];i.push(o),O2(t(o))(r)(i)(),n.push(i)})(),n},te=t=>e=>{const n=zo(Xt,y,t,e);return n.tag==="Just"?w("Just",e[n._1]):y},Ta=t=>e=>_t(t,e),mn=t=>e=>n=>{const r=zo(Xt,y,o=>t.eq(o)(e),n);if(r.tag==="Nothing")return!1;if(r.tag==="Just")return!0;g()},Ns=t=>e=>St(e)(t),ht=t=>Ns(e=>{const n=t(e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[n._1];g()}),Na=isFinite;function Rc(t,e,n,r){var o=parseFloat(t);return e(o)?n(o):r}const xe=Math.abs,ay=Math.acos,Io=function(t){return function(e){return Math.atan2(t,e)}},vs=Math.ceil,yn=Math.cos,uo=Math.exp,ar=Math.floor,co=Math.log,sy=function(t){return function(e){return Math.min(t,e)}},Dc=function(t){return function(e){return Math.pow(t,e)}},Un=Math.round,tn=Math.sin,qe=Math.sqrt,uy=Math.tan,cy=function(t){return function(e){return function(n){return(n|0)===n?t(n):e}}},ot=function(t){return t},gy=(function(t){return function(e){return function(n){var r;n<11?r="[0-"+(n-1).toString()+"]":n===11?r="[0-9a]":r="[0-9a-"+String.fromCharCode(86+n)+"]";var o=new RegExp("^[\\+\\-]?"+r+"+$","i");return function(i){if(o.test(i)){var a=parseInt(i,n);return(a|0)===a?t(a):e}else return e}}}})(Xt)(y)(10),Z1=cy(Xt)(y),he=t=>{if(!Na(t))return 0;if(t>=ot(2147483647))return 2147483647;if(t<=ot(-2147483648))return-2147483648;const e=Z1(t);if(e.tag==="Nothing")return 0;if(e.tag==="Just")return e._1;g()},Jt=(t,e,n)=>({tag:t,_1:e,_2:n}),z=Jt("Nil"),ge={foldr:t=>e=>{const n=ge.foldl(o=>i=>t(i)(o))(e),r=(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s;if(f.tag==="Nil"){u=!1,c=_;continue}if(f.tag==="Cons"){a=Jt("Cons",f._1,_),s=f._2;continue}g()}return c})(z);return o=>n(r(o))},foldl:t=>e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=o;if(u.tag==="Nil"){i=!1,a=s;continue}if(u.tag==="Cons"){r=t(s)(u._1),o=u._2;continue}g()}return a},foldMap:t=>{const e=t.mempty;return n=>ge.foldl(r=>{const o=t.Semigroup0().append(r);return i=>o(n(i))})(e)}},_y=function(t){return function(e){return function(n){return function(r){return function(o){return function(i){for(var a=[],s=i;;){var u=o(s);a.push(n(u));var c=r(u);if(t(c))return a;s=e(c)}}}}}}},fy=t=>{if(t.tag==="Just")return t._1;g()},dy={unfoldr1:_y(W1)(fy)(ws)(Js)},ly=function(t){return function(e){return function(n){return function(r){return function(o){return function(i){for(var a=[],s=i;;){var u=o(s);if(t(u))return a;var c=e(u);a.push(n(c)),s=r(c)}}}}}}},hy=t=>{if(t.tag==="Just")return t._1;g()},un={unfoldr:ly(W1)(hy)(ws)(Js),Unfoldable10:()=>dy},ee=(t,e,n,r,o,i,a)=>({tag:t,_1:e,_2:n,_3:r,_4:o,_5:i,_6:a}),cn=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),bs=(t,e,n)=>({tag:"Split",_1:t,_2:e,_3:n}),j1=(t,e,n)=>({tag:"SplitLast",_1:t,_2:e,_3:n}),O=ee("Leaf"),Kn=cn("IterLeaf"),Pe=(t,e,n,r)=>{if(n.tag==="Leaf"){if(r.tag==="Leaf")return ee("Node",1,1,t,e,n,r);if(r.tag==="Node")return ee("Node",1+r._1|0,1+r._2|0,t,e,n,r);g()}if(n.tag==="Node"){if(r.tag==="Leaf")return ee("Node",1+n._1|0,1+n._2|0,t,e,n,r);if(r.tag==="Node")return ee("Node",n._1>r._1?1+n._1|0:1+r._1|0,(1+n._2|0)+r._2|0,t,e,n,r)}g()},gn=(t,e,n,r)=>{if(n.tag==="Leaf")return r.tag==="Leaf"?ee("Node",1,1,t,e,O,O):r.tag==="Node"&&r._1>1?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?Pe(r._5._3,r._5._4,Pe(t,e,n,r._5._5),Pe(r._3,r._4,r._5._6,r._6)):Pe(r._3,r._4,Pe(t,e,n,r._5),r._6):Pe(t,e,n,r);if(n.tag==="Node")return r.tag==="Node"?r._1>(n._1+1|0)?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?Pe(r._5._3,r._5._4,Pe(t,e,n,r._5._5),Pe(r._3,r._4,r._5._6,r._6)):Pe(r._3,r._4,Pe(t,e,n,r._5),r._6):n._1>(r._1+1|0)?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?Pe(n._6._3,n._6._4,Pe(n._3,n._4,n._5,n._6._5),Pe(t,e,n._6._6,r)):Pe(n._3,n._4,n._5,Pe(t,e,n._6,r)):Pe(t,e,n,r):r.tag==="Leaf"&&n._1>1?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?Pe(n._6._3,n._6._4,Pe(n._3,n._4,n._5,n._6._5),Pe(t,e,n._6._6,r)):Pe(n._3,n._4,n._5,Pe(t,e,n._6,r)):Pe(t,e,n,r);g()},zi=(t,e,n)=>{if(n.tag==="Leaf")return bs(y,O,O);if(n.tag==="Node"){const r=t(e)(n._3);if(r==="LT"){const o=zi(t,e,n._5);return bs(o._1,o._2,gn(n._3,n._4,o._3,n._6))}if(r==="GT"){const o=zi(t,e,n._6);return bs(o._1,gn(n._3,n._4,n._5,o._2),o._3)}if(r==="EQ")return bs(w("Just",n._4),n._5,n._6)}g()},tf=(t,e,n,r)=>{if(r.tag==="Leaf")return j1(t,e,n);if(r.tag==="Node"){const o=tf(r._3,r._4,r._5,r._6);return j1(o._1,o._2,gn(t,e,n,o._3))}g()},Ii=(t,e)=>{if(t.tag==="Leaf")return e;if(t.tag==="Node"){const n=tf(t._3,t._4,t._5,t._6);return gn(n._1,n._2,n._3,e)}g()},Yn=(t,e,n)=>{if(e.tag==="Leaf")return O;if(n.tag==="Leaf")return e;if(n.tag==="Node"){const r=zi(t,n._3,e);return Ii(Yn(t,r._2,n._5),Yn(t,r._3,n._6))}g()},Cs=(t,e,n,r)=>{if(n.tag==="Leaf"||r.tag==="Leaf")return O;if(r.tag==="Node"){const o=zi(t,r._3,n),i=Cs(t,e,o._2,r._5),a=Cs(t,e,o._3,r._6);if(o._1.tag==="Just")return gn(r._3,e(o._1._1)(r._4),i,a);if(o._1.tag==="Nothing")return Ii(i,a)}g()},en=(t,e,n,r)=>{if(n.tag==="Leaf")return r;if(r.tag==="Leaf")return n;if(r.tag==="Node"){const o=zi(t,r._3,n),i=en(t,e,o._2,r._5),a=en(t,e,o._3,r._6);if(o._1.tag==="Just")return gn(r._3,e(o._1._1)(r._4),i,a);if(o._1.tag==="Nothing")return gn(r._3,r._4,i,a)}g()},ef=t=>e=>n=>{const r=o=>{if(o.tag==="Leaf")return O;if(o.tag==="Node"){const i=t.compare(n)(o._3);if(i==="LT")return gn(o._3,o._4,r(o._5),o._6);if(i==="GT")return gn(o._3,o._4,o._5,r(o._6));if(i==="EQ"){const a=e(o._4);if(a.tag==="Nothing")return Ii(o._5,o._6);if(a.tag==="Just")return ee("Node",o._1,o._2,o._3,a._1,o._5,o._6)}}g()};return r},Fc=t=>e=>{const n=r=>{if(r.tag==="Leaf")return O;if(r.tag==="Node"){const o=e(r._3)(r._4);if(o.tag==="Just")return gn(r._3,o._1,n(r._5),n(r._6));if(o.tag==="Nothing")return Ii(n(r._5),n(r._6))}g()};return n},Xn=(t=>e=>n=>{let r=n,o=!0,i;for(;o;){const a=r;if(a.tag==="IterLeaf"){o=!1,i=e();continue}if(a.tag==="IterEmit"){o=!1,i=t(a._1,a._2,a._3);continue}if(a.tag==="IterNode"){r=(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Leaf"){f=!1,l=d;continue}if(h.tag==="Node"){if(h._6.tag==="Leaf"){c=cn("IterEmit",h._3,h._4,d),_=h._5;continue}c=cn("IterEmit",h._3,h._4,cn("IterNode",h._6,d)),_=h._5;continue}g()}return l})(a._2)(a._1);continue}g()}return i})((t,e,n)=>w("Just",E(E(t,e),n)))(t=>y),Ot=t=>e=>n=>r=>{const o=i=>{if(i.tag==="Leaf")return ee("Node",1,1,n,r,O,O);if(i.tag==="Node"){const a=t.compare(n)(i._3);if(a==="LT")return gn(i._3,i._4,o(i._5),i._6);if(a==="GT")return gn(i._3,i._4,i._5,o(i._6));if(a==="EQ")return ee("Node",i._1,i._2,n,e(i._4)(r),i._5,i._6)}g()};return o},it=t=>e=>n=>{const r=o=>{if(o.tag==="Leaf")return ee("Node",1,1,e,n,O,O);if(o.tag==="Node"){const i=t.compare(e)(o._3);if(i==="LT")return gn(o._3,o._4,r(o._5),o._6);if(i==="GT")return gn(o._3,o._4,o._5,r(o._6));if(i==="EQ")return ee("Node",o._1,o._2,e,n,o._5,o._6)}g()};return r},fe=t=>e=>e.foldl(n=>r=>it(t)(r._1)(r._2)(n))(O),Qi=t=>e=>{const n=r=>{if(r.tag==="Leaf")return O;if(r.tag==="Node"){const o=t.compare(e)(r._3);if(o==="LT")return gn(r._3,r._4,n(r._5),r._6);if(o==="GT")return gn(r._3,r._4,r._5,n(r._6));if(o==="EQ")return Ii(r._5,r._6)}g()};return n},nf=t=>{const e=t.compare;return n=>r=>o=>{const i=zi(e,r,o),a=n(i._1);if(a.tag==="Nothing")return Ii(i._2,i._3);if(a.tag==="Just")return gn(r,a._1,i._2,i._3);g()}},be=function(t){return function(e){return t+e|0}},xr=function(t){return function(e){return t+e}},go=function(t){return function(e){if(e===0)return 0;var n=Math.abs(e);return(t%n+n)%n}},py=function(t){return function(e){return t+e}},Je=function(t){return function(e){return t.length===0?e:e.length===0?t:t.concat(e)}},my={append:py},yy={append:Je},rf={mempty:"",Semigroup0:()=>my},xy={mempty:[],Semigroup0:()=>yy},va=null;function An(t,e,n){return t==null?e:n(t)}function oA(t){return t}function zc(t){return function(e){return function(n){return t.apply(n,[e])}}}const Jy=zc(Number.prototype.toPrecision),wy=zc(Number.prototype.toFixed),Ty=zc(Number.prototype.toExponential),Qo=(t,e)=>({tag:t,_1:e}),Mo=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Oo=t=>{if(t.tag==="Precision")return Jy(t._1);if(t.tag==="Fixed")return wy(t._1);if(t.tag==="Exponential")return Ty(t._1);g()},of=function(t){return function(){console.log(t)}};function af(t){return function(){return t.getContext("2d")}}function sf(t){return function(){return t.width}}function uf(t){return function(){return t.height}}function cf(t){return function(e){return function(){t.width=e}}}function gf(t){return function(e){return function(){t.height=e}}}function Ls(t){return function(e){return function(){t.lineWidth=e}}}function Ny(t){return function(e){return function(){t.setLineDash(e)}}}function _f(t){return function(e){return function(){t.fillStyle=e}}}function ff(t){return function(e){return function(){t.strokeStyle=e}}}function Ic(t){return function(e){return function(){t.lineCap=e}}}function Qc(t){return function(e){return function(){t.lineJoin=e}}}function vy(t){return function(e){return function(){t.globalCompositeOperation=e}}}function by(t){return function(e){return function(){t.globalAlpha=e}}}function df(t){return function(){t.beginPath()}}function Mc(t){return function(){t.stroke()}}function Oc(t){return function(){t.fill()}}function Cy(t){return function(){t.clip()}}function ba(t){return function(e){return function(n){return function(){t.lineTo(e,n)}}}}function lf(t){return function(e){return function(n){return function(){t.moveTo(e,n)}}}}function hf(t){return function(){t.closePath()}}function Ly(t){return function(e){return function(){t.fillRect(e.x,e.y,e.width,e.height)}}}function ky(t){return function(e){return function(){t.strokeRect(e.x,e.y,e.width,e.height)}}}function Sy(t){return function(e){return function(){t.clearRect(e.x,e.y,e.width,e.height)}}}function Ca(t){return function(e){return function(){t.scale(e.scaleX,e.scaleY)}}}function pf(t){return function(e){return function(){t.translate(e.translateX,e.translateY)}}}function Ey(t){return function(e){return function(){t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}}}function Py(t){return function(e){return function(){t.textAlign=e}}}function Gy(t){return function(e){return function(){t.textBaseline=e}}}function mf(t){return function(e){return function(){t.font=e}}}function yf(t){return function(e){return function(n){return function(r){return function(){t.fillText(e,n,r)}}}}}function sr(t){return function(){t.save()}}function ur(t){return function(){t.restore()}}function La(t){return function(e){return function(){t.quadraticCurveTo(e.cpx,e.cpy,e.x,e.y)}}}function Ay(t){return function(e){return function(){t.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y)}}}const xf=t=>t,Wc=t=>t,Hc=t=>t,$c=t=>t,ks=t=>t,By=ks("BaselineTop"),Ry=ks("BaselineMiddle"),Dy=ks("BaselineAlphabetic"),Fy=ks("BaselineBottom"),zy=$c("AlignLeft"),Iy=$c("AlignRight"),Qy=$c("AlignCenter"),qc=Hc("BevelJoin"),Vc=Hc("RoundJoin"),Uc=Hc("MiterJoin"),Kc=Wc("Round"),Yc=Wc("Square"),Xc=Wc("Butt"),My=xf("SourceOver"),Oy=xf("Difference"),Wy=t=>e=>Gy(t)((()=>{if(e==="BaselineTop")return"top";if(e==="BaselineHanging")return"hanging";if(e==="BaselineMiddle")return"middle";if(e==="BaselineAlphabetic")return"alphabetic";if(e==="BaselineIdeographic")return"ideographic";if(e==="BaselineBottom")return"bottom";g()})()),Hy=t=>e=>Py(t)((()=>{if(e==="AlignLeft")return"left";if(e==="AlignRight")return"right";if(e==="AlignCenter")return"center";if(e==="AlignStart")return"start";if(e==="AlignEnd")return"end";g()})()),Zc=t=>e=>{if(e==="BevelJoin")return Qc(t)("bevel");if(e==="RoundJoin")return Qc(t)("round");if(e==="MiterJoin")return Qc(t)("miter");g()},jc=t=>e=>{if(e==="Round")return Ic(t)("round");if(e==="Square")return Ic(t)("square");if(e==="Butt")return Ic(t)("butt");g()},Jf=t=>e=>vy(t)((()=>{if(e==="SourceOver")return"source-over";if(e==="SourceIn")return"source-in";if(e==="SourceOut")return"source-out";if(e==="SourceAtop")return"source-atop";if(e==="DestinationOver")return"destination-over";if(e==="DestinationIn")return"destination-in";if(e==="DestinationOut")return"destination-out";if(e==="DestinationAtop")return"destination-atop";if(e==="Lighter")return"lighter";if(e==="Copy")return"copy";if(e==="Xor")return"xor";if(e==="Multiply")return"multiply";if(e==="Screen")return"screen";if(e==="Overlay")return"overlay";if(e==="Darken")return"darken";if(e==="Lighten")return"lighten";if(e==="ColorDodge")return"color-dodge";if(e==="ColorBurn")return"color-burn";if(e==="HardLight")return"hard-light";if(e==="SoftLight")return"soft-light";if(e==="Difference")return"difference";if(e==="Exclusion")return"exclusion";if(e==="Hue")return"hue";if(e==="Saturation")return"saturation";if(e==="Color")return"color";if(e==="Luminosity")return"luminosity";g()})()),wf={foldrWithIndex:t=>e=>{const n=Ri(o=>{const i=o._1,a=o._2;return s=>t(i)(a)(s)})(e),r=Mt(Cn);return o=>n(r(o))},foldlWithIndex:t=>e=>{const n=v(o=>i=>t(i._1)(o)(i._2))(e),r=Mt(Cn);return o=>n(r(o))},foldMapWithIndex:t=>{const e=t.mempty;return n=>wf.foldrWithIndex(r=>o=>i=>t.Semigroup0().append(n(r)(o))(i))(e)},Foldable0:()=>Qt},$y=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},qy=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ss=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Vy=t=>e=>n=>r=>n<=0||r<=0||e.bounds.w<=0||e.bounds.h<=0?1:t?$y(e.bounds.w/n)(e.bounds.h/r):qy(e.bounds.w/n)(e.bounds.h/r),Tf=t=>e=>n=>{const r=t.widthPx/t.heightPx,o=n.w/n.h;if(t.widthPx<=0||t.heightPx<=0){const a=1/Ss(.05)(1)(e);return{w:n.w*a,h:n.h*a}}if(r>o){const a=1/Ss(.05)(1)(e);return{w:n.h*r*a,h:n.h*a}}const i=1/Ss(.05)(1)(e);return{w:n.w*i,h:n.w/r*i}},Nf=t=>e=>n=>r=>o=>{const i=t+o/2,a=t+e-o/2,s=t+e/2,u=n+r/2;return o>=e?s:Ss(i)(a)(u)},vf=t=>e=>n=>r=>({x:Nf(t.bounds.x)(t.bounds.w)(e.x)(e.w)(n),y:Nf(t.bounds.y)(t.bounds.h)(e.y)(e.h)(r)}),ka=t=>e=>n=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:Vy(t)(e)(n.w)(n.h)}),bf=t=>e=>n=>r=>{const o={x:r.x-t.padding,y:r.y-t.padding,w:r.w+t.padding*2,h:r.h+t.padding*2},i=Tf(e)(.65)(o),a=vf(n)(o)(i.w)(i.h),s={x:a.x-i.w/2,y:a.y-i.h/2,w:i.w,h:i.h};return{focus:r,paddedFocus:o,viewport:s,camera:ka(e.widthPx>0&&e.heightPx>0)(n)(s)}},Uy=t=>e=>n=>r=>o=>{const i={x:o.x*r.scale+r.tx,y:o.y*r.scale+r.ty,w:o.w*r.scale,h:o.h*r.scale},a=t.padding*r.scale,s={x:i.x-a,y:i.y-a,w:i.w+a*2,h:i.h+a*2},u=Tf(e)(1)(s),c=vf(n)(s)(u.w)(u.h),_={x:c.x-u.w/2,y:c.y-u.h/2,w:u.w,h:u.h};return{footprint:i,viewport:_,camera:ka(e.widthPx>0&&e.heightPx>0)(n)(_)}},Ky=t=>e=>n=>{const r=t.widthPx/t.heightPx,o=n.w/n.h;return t.widthPx<=0||t.heightPx<=0?ka(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.w*.8,a=n.h*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})()):r>o?ka(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.w*.8,a=n.w/r*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})()):ka(t.widthPx>0&&t.heightPx>0)(e)((()=>{const i=n.h*r*.8,a=n.h*.8;return{x:n.x+n.w/2-i/2,y:n.y+n.h/2-a/2,w:i,h:a}})())},xn={foldr:t=>e=>{const n=ge.foldr(t)(e);return r=>n((()=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,Jt("Cons",i._3,o(i._6,a)));g()};return o(r,z)})())}},Yy=t=>{const e={append:(()=>{const n=t.compare;return r=>o=>en(n,je,r,o)})()};return{mempty:O,Semigroup0:()=>e}},Sa=function(t){return function(e){if(t>=0&&t<e.length)return e.charAt(t);throw new Error("Data.String.Unsafe.charAt: Invalid index.")}},kn=function(t){return t.join("")},Bn=function(t){return t.split("")},Rn=function(t){return t},Dn=function(t){return t.length},Cf=function(t){return function(e){return e.substr(0,t)}},Mi=function(t){return function(e){return e.substring(t)}},Lf=function(t){return function(e){return{before:e.substring(0,t),after:e.substring(t)}}},Xy=t=>e=>{const n=Lf(Dn(e)-Dn(t)|0)(e);return n.after===t?w("Just",n.before):y},cr=t=>e=>{const n=Lf(Dn(t))(e);return n.before===t?w("Just",n.after):y},Zy=function(t){var e=null;return function(){return t===void 0||(e=t(),t=void 0),e}},jy=function(t){return t()},tx=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},ex=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},Wo=t=>BigInt(t),nx=t=>Number(t),Es=t=>e=>t+e,Ps=t=>e=>t*e,tg=t=>e=>t-e,kf=0n,Gs=1n,Sf=t=>e=>t^e,Ea=t=>e=>t&e,eg=t=>e=>t<<e,ng=t=>e=>t>>e,rx=t=>e=>t==e,ox=t=>e=>t===e?0:t>e?1:-1,ix={eq:rx},Ef={compare:t=>e=>{const n=ox(t)(e);return n===1?Me:n===0?sn:Qe},Eq0:()=>ix},ax=tx(Xt)(y),sx=ex(Xt)(y),Pf=function(t){throw new Error(t)},Gf=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=at.compare(e._1)(n._1);return r==="LT"?Qe:r==="GT"?Me:at.compare(e._2)(n._2)},Eq0:()=>t}})(),ux=t=>e=>xe(t._1-e._1)+xe(t._2-e._2),Ho=t=>t,As=t=>t,De=As("North"),Fe=As("South"),qr=As("East"),Vr=As("West"),_o=Ho("Rectangle"),cx=Ho("Cylinder"),gx=Ho("Parallelogram"),_x=Ho("Diamond"),fx=Ho("Ellipse"),dx=Ho("Document"),lx=Ho("Cloud"),Af=t=>t,hx=(t,e)=>({tag:t,_1:e}),rg=t=>t,Oi=(t,e)=>({tag:t,_1:e}),og=(t,e)=>({tag:t,_1:e}),Pa=rg("Animated"),px=rg("StaticStill"),mx=rg("TitleCard"),yx=og("First"),Bf=Af("Forward"),Rf=Af("Backward"),xx=Oi("ExitNode"),Df=fe(B)(Qt),Jx=t=>Ri(e=>n=>({nodes:en(B.compare,je,e.nodes,n.nodes),edges:en(B.compare,je,e.edges,n.edges)}))({nodes:O,edges:O})(t.keyframes),wx=t=>e=>({entering:{nodes:Yn(B.compare,e.nodes,t.nodes),edges:Yn(B.compare,e.edges,t.edges)},leaving:{nodes:Yn(B.compare,t.nodes,e.nodes),edges:Yn(B.compare,t.edges,e.edges)},surviving:{nodes:Cs(B.compare,je,t.nodes,e.nodes),edges:Cs(B.compare,je,t.edges,e.edges)}}),Bs=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Wi=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Rs=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},ig=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Tx=v(t=>e=>it(B)(e)()(t))(O),Nx=v(t=>e=>it(B)(e)()(t))(O),vx=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),Ff=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},zf=fe(B)(Qt),Ga=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:Bs(r.minX)(o.x),minY:Bs(r.minY)(o.y),maxX:Wi(r.maxX)(o.x),maxY:Wi(r.maxY)(o.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},bx=t=>e=>n=>Tx(St(It(xn.foldr,n))(r=>{const o=Rs(r)(t);if(o.tag==="Just")return _t(i=>!ig(i)(e),[o._1.source,o._1.target]);if(o.tag==="Nothing")return[];g()})),Cx=t=>t.kind.tag==="SendToken"?w("Just",E(t.kind._1.edge,{source:t.kind._1.from,target:t.kind._1.to})):y,Lx=t=>t.tag==="DataFlow"?ht(Cx)(t._1.events):[],kx=t=>e=>Nx(ht(n=>ig(n._2.source)(e)||ig(n._2.target)(e)?w("Just",n._1):y)(vx(t))),ae=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:Bs(r.minX)(o.x),minY:Bs(r.minY)(o.y),maxX:Wi(r.maxX)(o.x+o.w),maxY:Wi(r.maxY)(o.y+o.h)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x+e._1.head.w,maxY:e._1.head.y+e._1.head.h})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},ag=t=>e=>n=>{if(n.tag==="Leaf")return t.bounds;const r=kx(e)(n),o=[...ht(i=>{const a=Ff(i)(t.nodes);return a.tag==="Just"?w("Just",{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h}):y})(It(xn.foldr,en(B.compare,je,n,bx(e)(n)(r)))),...ht(i=>{const a=Rs(i)(t.edges);return a.tag==="Just"?w("Just",Ga(a._1)):y})(It(xn.foldr,r))];return o.length===0?t.bounds:ae(o)},$o=t=>e=>n=>{const r=[...ht(o=>o)([(()=>{const o=Rs(n)(t.edges);return o.tag==="Just"?w("Just",Ga(o._1)):y})()]),...(()=>{const o=Rs(n)(e);if(o.tag==="Just")return ht(i=>{const a=Ff(i)(t.nodes);return a.tag==="Just"?w("Just",{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h}):y})([o._1.source,o._1.target]);if(o.tag==="Nothing")return[];g()})()];return r.length===0?ag(t)(e)(O):ae(r)},gr=t=>e=>{const n=t.bounds.w/Wi(1e-4)(e.zoom),r=t.bounds.h/Wi(1e-4)(e.zoom);return{x:e.center.x-n/2,y:e.center.y-r/2,w:n,h:r}},Sx=t=>en(B.compare,je,zf(Y(e=>E(e.id,{source:e.from.node,target:e.to.node}))(t.graph.edges)),zf(St(t.scenes)(Lx))),sg=t=>e=>n=>r=>{if(e<=0)return r;if(t<=0)return{position:r.position+r.velocity*e,velocity:r.velocity};const o=r.velocity-n.velocity,i=r.position-n.position,a=uo(-t*e),s=o+t*i;return{position:n.position+n.velocity*e+(i+s*e)*a,velocity:n.velocity+(o-t*s*e)*a}},ug=t=>t,Ex=t=>t,cg=ug("Linear"),_r=ug("EaseInOutQuad"),Px=ug("SpringBouncy"),qo=t=>e=>n=>{const r=qe(1-e*e),o=t*r;return 1-uo(-e*t*n)*(yn(o*n)+e/r*tn(o*n))},Gx=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Hi=t=>e=>(()=>{if(t==="Linear")return Ex;if(t==="EaseInQuad")return n=>n*n;if(t==="EaseOutQuad")return n=>1-(1-n)*(1-n);if(t==="EaseInOutQuad")return n=>n<.5?2*n*n:1-2*(1-n)*(1-n);if(t==="EaseInCubic")return n=>n*n*n;if(t==="EaseOutCubic")return n=>1-(1-n)*(1-n)*(1-n);if(t==="EaseInOutCubic")return n=>n<.5?4*n*n*n:1-(-2*n+2)*(-2*n+2)*(-2*n+2)/2;if(t==="EaseOutExpo")return n=>n>=1?1:1-Dc(2)(-10*n);if(t==="Spring")return n=>1-(1+6*n)*uo(-6*n);if(t==="SpringBouncy")return qo(6)(.7);g()})()(Gx(e)),Ds=t=>t,Fs=(t,e)=>({tag:t,_1:e}),If=t=>t,ke=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},zs=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Is=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ax=t=>e=>{const n=ut.compare(t._1)(e._1);return n==="LT"?Qe:n==="GT"?Me:at.compare(t._2)(e._2)},Bx=If("Hold"),Rx=If("Gap"),Dx=Fs("LinearLerp"),Vo=Fs("LogLerp"),fo=Fs("ComposedLogLerp"),Qf=Fs("StationaryShot"),Qs=Ds("Overview"),Mf=Ds("DiveHome"),lo=Ds("DiveTransition"),Fx=Ds("ActionFocus"),zx={eq:t=>e=>t.tag==="LinearLerp"?e.tag==="LinearLerp":t.tag==="LogLerp"?e.tag==="LogLerp":t.tag==="ComposedLogLerp"?e.tag==="ComposedLogLerp":t.tag==="StationaryShot"?e.tag==="StationaryShot":t.tag==="SpringInterp"&&e.tag==="SpringInterp"&&t._1.frequency===e._1.frequency&&t._1.initialVelocity.center.x===e._1.initialVelocity.center.x&&t._1.initialVelocity.center.y===e._1.initialVelocity.center.y&&t._1.initialVelocity.zoomLog===e._1.initialVelocity.zoomLog&&t._1.target.center.x===e._1.target.center.x&&t._1.target.center.y===e._1.target.center.y&&t._1.target.zoom===e._1.target.zoom&&t._1.targetVelocity.center.x===e._1.targetVelocity.center.x&&t._1.targetVelocity.center.y===e._1.targetVelocity.center.y&&t._1.targetVelocity.zoomLog===e._1.targetVelocity.zoomLog},Ms={center:{x:0,y:0},zoomLog:0},Of=t=>e=>n=>{const r=t.widthPx>0&&t.heightPx>0,o=t.widthPx/ke(1e-6)(t.heightPx),i=e.bounds.w/ke(1e-6)(n.zoom),a=e.bounds.h/ke(1e-6)(n.zoom),s=i/ke(1e-6)(a),u=r&&o<s?i/o:a,c=r&&o>s?a*o:i;return{x:n.center.x-c/2,y:n.center.y-u/2,w:c,h:u}},Ix=t=>({startT:t.startT,endT:t.endT,fromCam:t.fromCam,toCam:t.toCam,easing:t.easing,interp:t.interp,intent:t.intent}),Qx=v(t=>e=>{const n=t.length-1|0;return n>=0&&n<t.length&&t[n]===e?t:Et(t)(e)})([]),Os=t=>e=>n=>{const r=zs(0)(1)((n-t)/ke(1e-6)(e-t));return r*r*r*(r*(r*6-15)+10)},Wf=t=>e=>n=>r=>o=>{const i=xe(co(ke(1e-6)(o.zoom))-co(ke(1e-6)(r.zoom))),a=Of(e)(n)({...r,zoom:ke(ke(1e-6)(r.zoom))(ke(1e-6)(o.zoom))}),s=(o.center.y-r.center.y)*e.heightPx/ke(1e-6)(a.h),u=(o.center.x-r.center.x)*e.widthPx/ke(1e-6)(a.w),c=qe(u*u+s*s);return ke(t.minTransition)(ke(t.panSpeed<=0?t.minTransition:2*c/t.panSpeed)(t.zoomSpeed<=0?t.minTransition:2*i/t.zoomSpeed))},Mx=t=>e=>{const n=t.x-e.x;return(n<0?-n<.001:n<.001)&&(()=>{const r=t.y-e.y;return(r<0?-r<.001:r<.001)&&(()=>{const o=t.w-e.w;return(o<0?-o<.001:o<.001)&&(()=>{const i=t.h-e.h;return i<0?-i<.001:i<.001})()})()})()},Ox=t=>e=>t.tag==="Just"?e.tag==="Just"&&Mx(t._1)(e._1):t.tag==="Nothing"&&e.tag==="Nothing",gg=t=>e=>n=>r=>({center:{x:r.center.x*n.scale+n.tx,y:r.center.y*n.scale+n.ty},zoom:r.zoom*t.bounds.w/ke(1e-6)(n.scale*e.bounds.w)}),Ws=t=>e=>n=>r=>({center:{x:t.center.x+(e.center.x-t.center.x)*n,y:t.center.y+(e.center.y-t.center.y)*n},zoom:uo((()=>{const o=co(ke(1e-6)(t.zoom));return o+(co(ke(1e-6)(e.zoom))-o)*r})())}),Wx=t=>v(e=>n=>{if(n.endT>t)return e;if(e.tag==="Nothing")return w("Just",n);if(e.tag==="Just")return n.endT>e._1.endT?w("Just",n):w("Just",e._1);g()})(y),Hx=t=>e=>n=>r=>{if(t<=0)return r;const o=uo(-t*e);return{center:{x:r.center.x+(n.center.x-r.center.x)*o,y:r.center.y+(n.center.y-r.center.y)*o},zoom:uo((()=>{const i=co(ke(1e-6)(r.zoom));return i+(co(ke(1e-6)(n.zoom))-i)*o})())}},_g=t=>e=>n=>e.zoom>=t.zoom?Os(.3)(1)(n):Os(0)(.7)(n),$x={padding:24,easing:_r,minimumReadableLabelPx:12,minimumVisibleLabelPx:5,labelBasePx:11,panSpeed:420,zoomSpeed:1.4,minTransition:.25,maxTransition:.6,cameraDecay:0},Uo=t=>e=>n=>r=>o=>{const i=Of(e)(n)(r),a=o.x-t.padding,s=o.y-t.padding;return a>=i.x&&s>=i.y&&a+o.w+t.padding*2<=i.x+i.w&&s+o.h+t.padding*2<=i.y+i.h},qx=t=>e=>n=>r=>o=>wf.foldlWithIndex(i=>a=>s=>{const u=(()=>{if(s.kind==="Hold"){const c=(()=>{if(i===0)return s.toCam;if(s.focus.tag==="Just"){if(s.intent==="ActionFocus")return(e.widthPx<=0||e.heightPx<=0)&&Uo(t)(e)(n)(a.prev)(s.focus._1)||a.prev.zoom>=s.toCam.zoom*.995&&Uo(t)(e)(n)(a.prev)(s.focus._1)?a.prev:Uo(t)(e)(n)({center:a.prev.center,zoom:s.toCam.zoom})(s.focus._1)?{...s.toCam,center:a.prev.center}:{...s.toCam,center:{...s.toCam.center,x:(()=>{const _=n.bounds.w/ke(1e-6)(s.toCam.zoom);if(_<=0)return s.toCam.center.x;const f=s.focus._1.x+s.focus._1.w/2,l=e.widthPx<=0?0:Is(_/4)(6*_/e.widthPx),d=a.prev.center.x+_/2-l,h=f<a.prev.center.x-_/2+l?f-l+_/2:f>d?f+l-_/2:a.prev.center.x;return _>=n.bounds.w?n.bounds.x+n.bounds.w/2:zs(n.bounds.x+_/2)(n.bounds.x+n.bounds.w-_/2)(h)})()}};if(Uo(t)(e)(n)(a.prev)(s.focus._1))return a.prev;if(Uo(t)(e)(n)({center:a.prev.center,zoom:s.toCam.zoom})(s.focus._1))return{...s.toCam,center:a.prev.center}}return s.toCam})();return{startT:s.startT,endT:s.endT,fromCam:c,toCam:c,easing:s.easing,interp:s.stationary?Qf:Dx,focus:s.focus,intent:s.intent}}if(s.kind==="Gap")return{startT:s.startT,endT:s.endT,fromCam:a.prev,toCam:(()=>{const c=i+1|0,_=zo(Xt,y,f=>f.kind==="Hold",c<1?o:Bt(c,o.length,o));if(_.tag==="Just"){const f=(i+1|0)+_._1|0;return f>=0&&f<o.length?(()=>{if(o[f].focus.tag==="Just")return Uo(t)(e)(n)(a.prev)(o[f].focus._1);if(o[f].focus.tag==="Nothing")return!1;g()})()?a.prev:o[f].fromCam:a.prev}if(_.tag==="Nothing")return a.prev;g()})(),easing:s.easing,interp:Vo,focus:y,intent:s.intent};g()})();return{acc:Et(a.acc)(u),prev:u.toCam}})({acc:[],prev:r})(o).acc,Vx=t=>e=>n=>r=>o=>i=>{const a=(u,c)=>Is(Wf(t)(e)(n)(u.toCam)(c.toCam))(u.endT-u.startT),s=v(u=>c=>{if(u.pending.tag==="Nothing")return{acc:u.acc,pending:w("Just",c)};if(u.pending.tag==="Just"){if(!(c.fromCam.zoom===c.toCam.zoom&&c.fromCam.center.x===c.toCam.center.x&&c.fromCam.center.y===c.toCam.center.y)||(()=>{if(c.focus.tag==="Just")return Uo(t)(e)(n)(u.pending._1.toCam)(c.focus._1);if(c.focus.tag==="Nothing")return!1;g()})()||(()=>{const _=u.pending._1.toCam.center.x-c.toCam.center.x;return(_<0?-_<8:_<8)&&(()=>{const f=u.pending._1.toCam.center.y-c.toCam.center.y;return(f<0?-f<8:f<8)&&(()=>{const l=u.pending._1.toCam.zoom-c.toCam.zoom;return l<0?-l<.08:l<.08})()})()})()||a(u.pending._1,c)<=0)return{acc:Et(u.acc)(u.pending._1),pending:w("Just",c)};if((()=>{const _=c.startT;return oe(f=>xe(f-_)<1e-4,o)})()){const _={startT:c.startT,endT:c.startT+Is(Wf(t)(e)(n)(u.pending._1.toCam)(c.toCam))(c.endT-c.startT),fromCam:u.pending._1.toCam,toCam:c.toCam,easing:c.easing,interp:Vo,focus:c.focus,intent:c.intent},f={...c,startT:_.endT,fromCam:c.toCam};return f.startT<f.endT?{acc:Et(Et(u.acc)(u.pending._1))(_),pending:w("Just",f)}:{acc:Et(u.acc)(u.pending._1),pending:w("Just",_)}}return{acc:Et(Et(u.acc)({...u.pending._1,endT:c.startT-a(u.pending._1,c)}))({startT:c.startT-a(u.pending._1,c),endT:c.startT,fromCam:u.pending._1.toCam,toCam:c.toCam,easing:c.easing,interp:Vo,focus:c.focus,intent:c.intent}),pending:w("Just",c)}}g()})({acc:[],pending:y})(i);if(s.pending.tag==="Nothing")return s.acc;if(s.pending.tag==="Just")return Et(s.acc)(s.pending._1);g()},Ux=t=>e=>n=>{const r=e.w+n*2,o=e.h+n*2;return r<=0||o<=0||t.bounds.w<=0||t.bounds.h<=0?1:Is(t.bounds.w/r)(t.bounds.h/o)},Kx=t=>e=>n=>e.zoom>=t.zoom?Ws(t)(e)(Os(0)(.45)(n))(_g(t)(e)(n)):Ws(t)(e)(Os(.55)(1)(n))(_g(t)(e)(n)),Yx=t=>e=>{if(t.tag==="Just"){if(e.tag==="Just")return w("Just",ae([t._1,e._1]));if(e.tag==="Nothing")return w("Just",t._1);g()}if(t.tag==="Nothing"){if(e.tag==="Just")return w("Just",e._1);if(e.tag==="Nothing")return y}g()},Xx=v(t=>e=>{const n=t.length-1|0,r=n>=0&&n<t.length?w("Just",t[n]):y;return r.tag==="Just"&&r._1.fromCam.zoom===r._1.toCam.zoom&&r._1.fromCam.center.x===r._1.toCam.center.x&&r._1.fromCam.center.y===r._1.toCam.center.y&&e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y&&(r._1.toCam.zoom===e.toCam.zoom&&r._1.toCam.center.x===e.toCam.center.x&&r._1.toCam.center.y===e.toCam.center.y?r._1.intent==="Overview"?e.intent==="Overview":r._1.intent==="DiveHome"?e.intent==="DiveHome":r._1.intent==="DiveTransition"?e.intent==="DiveTransition":r._1.intent==="ActionFocus"&&e.intent==="ActionFocus":!(r._1.intent==="ActionFocus"||e.intent==="ActionFocus")||(r._1.intent==="Overview"?e.intent==="Overview":r._1.intent==="DiveHome"?e.intent==="DiveHome":r._1.intent==="DiveTransition"?e.intent==="DiveTransition":r._1.intent==="ActionFocus"&&e.intent==="ActionFocus")&&Ox(r._1.focus)(e.focus))&&(()=>{const o=r._1.toCam.center.x-e.toCam.center.x;return(o<0?-o<8:o<8)&&(()=>{const i=r._1.toCam.center.y-e.toCam.center.y;return(i<0?-i<8:i<8)&&(()=>{const a=r._1.toCam.zoom-e.toCam.zoom;return a<0?-a<.08:a<.08})()})()})()?Et((()=>{const o=t.length-1|0;return o<1?[]:Bt(0,o,t)})())({...r._1,endT:e.endT,focus:Yx(r._1.focus)(e.focus)}):Et(t)(e)})([]),Zx=t=>{const e=Pt(n=>r=>Ax(E((()=>{if(r.intent==="DiveTransition")return 3;if(r.intent==="ActionFocus")return 2;if(r.intent==="DiveHome")return 1;if(r.intent==="Overview")return 0;g()})(),r.startT))(E((()=>{if(n.intent==="DiveTransition")return 3;if(n.intent==="ActionFocus")return 2;if(n.intent==="DiveHome")return 1;if(n.intent==="Overview")return 0;g()})(),n.startT)))(t);return 0<e.length?w("Just",e[0]):y},jx=t=>e=>{const n=e.endT<=e.startT?1:(t-e.startT)/(e.endT-e.startT),r=Hi(e.easing)(zs(0)(1)(n));if(e.interp.tag==="SpringInterp"){const o=zs(0)(ke(0)(e.endT-e.startT))(t-e.startT),i=sg(e.interp._1.frequency)(o)({position:e.interp._1.target.center.x,velocity:e.interp._1.targetVelocity.center.x})({position:e.fromCam.center.x,velocity:e.interp._1.initialVelocity.center.x}),a=sg(e.interp._1.frequency)(o)({position:e.interp._1.target.center.y,velocity:e.interp._1.targetVelocity.center.y})({position:e.fromCam.center.y,velocity:e.interp._1.initialVelocity.center.y}),s=sg(e.interp._1.frequency)(o)({position:co(ke(1e-6)(e.interp._1.target.zoom)),velocity:e.interp._1.targetVelocity.zoomLog})({position:co(ke(1e-6)(e.fromCam.zoom)),velocity:e.interp._1.initialVelocity.zoomLog});return{camera:{center:{x:i.position,y:a.position},zoom:uo(s.position)},velocity:{center:{x:i.velocity,y:a.velocity},zoomLog:s.velocity}}}if(e.interp.tag==="LinearLerp")return{camera:{center:{x:e.fromCam.center.x+(e.toCam.center.x-e.fromCam.center.x)*r,y:e.fromCam.center.y+(e.toCam.center.y-e.fromCam.center.y)*r},zoom:e.fromCam.zoom+(e.toCam.zoom-e.fromCam.zoom)*r},velocity:Ms};if(e.interp.tag==="LogLerp")return{camera:Ws(e.fromCam)(e.toCam)(r)(r),velocity:Ms};if(e.interp.tag==="ComposedLogLerp")return{camera:Kx(e.fromCam)(e.toCam)(n),velocity:Ms};if(e.interp.tag==="StationaryShot")return{camera:Ws(e.fromCam)(e.toCam)(r)(r),velocity:Ms};g()},fg=t=>e=>n=>r=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:ke(r)(Ux(e)(n)(t.padding))}),tJ=t=>e=>n=>r=>o=>i=>{const a=fg(t)(n)(n.bounds)(0),s=_t(u=>u>=0&&u<=r,Qx(Pt(at.compare)([0,r,...o,...St(i)(u=>[u.startT,u.endT])])));return Y(Ix)(Vx(t)(e)(n)(a)(o)(Xx(qx(t)(e)(n)(a)(ht(u=>{const c=(u._1+u._2)/2,_=v(d=>h=>h.startT>c||c>=h.endT?d:h.priority>d.topPriority?{topPriority:h.priority,bboxes:[h.bbox],actionActive:d.actionActive||h.priority>=1,continuous:h.continuous,stationary:h.stationary}:h.priority===d.topPriority?{...d,bboxes:Et(d.bboxes)(h.bbox),actionActive:d.actionActive||h.priority>=1,continuous:d.continuous||h.continuous,stationary:d.stationary||h.stationary}:{...d,actionActive:d.actionActive||h.priority>=1})({topPriority:0,bboxes:[],actionActive:!1,continuous:!1,stationary:!1})(i);if(u._2<=u._1)return y;if(_.bboxes.length===0)return w("Just",{kind:Rx,startT:u._1,endT:u._2,fromCam:a,toCam:a,easing:t.easing,focus:y,stationary:!1,intent:Qs});const f=ae(_.bboxes),l=_.actionActive?bf(t)(e)(n)(f).camera:fg(t)(n)(f)(0);return w("Just",{kind:Bx,startT:u._1,endT:u._2,fromCam:l,toCam:l,easing:_.continuous?cg:t.easing,focus:w("Just",f),intent:_.actionActive?Fx:Qs,stationary:_.stationary})})(Oe(Cn,s,Bt(1,s.length,s)))))))},Ko=t=>e=>n=>r=>{const o=Zx(_t(i=>r>=i.startT&&r<i.endT,n));if(o.tag==="Just")return{camera:jx(r)(o._1).camera,intent:o._1.intent};if(o.tag==="Nothing"){const i=Wx(r)(n);if(i.tag==="Just")return{camera:i._1.toCam,intent:i._1.intent};if(i.tag==="Nothing")return{camera:(()=>{const a=fg(t)(e)(e.bounds)(0);return 0<n.length?n[0].fromCam:a})(),intent:0<n.length?n[0].intent:Qs}}g()};function Ur(t){return t.charCodeAt(0)}function Hf(t){return String.fromCharCode(t)}const fr=function(t){return function(e){return function(n){return n.replace(new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),e)}}},$i=function(t){return function(e){return e.split(t)}},Aa=function(t){return t.trim()},Zn=function(t){return function(e){return e.join(t)}};var eJ=typeof Array.from=="function",nJ=typeof Symbol<"u"&&Symbol!=null&&typeof Symbol.iterator<"u"&&typeof String.prototype[Symbol.iterator]=="function",rJ=typeof String.prototype.fromCodePoint=="function",oJ=typeof String.prototype.codePointAt=="function";const iJ=function(t){return oJ?function(e){return e.codePointAt(0)}:t},aJ=function(t){return rJ?String.fromCodePoint:t},sJ=function(t){return function(e){return nJ?function(n){for(var r="",o=n[Symbol.iterator](),i=0;i<e;++i){var a=o.next();if(a.done)return r;r+=a.value}return r}:t(e)}},uJ=function(t){return function(e){return eJ?function(n){return Array.from(n,e)}:t}},Hs=t=>{const e=Dn(t);if(e===0)return y;if(e===1)return w("Just",{head:Ur(Sa(0)(t)),tail:""});const n=Ur(Sa(1)(t)),r=Ur(Sa(0)(t));return 55296<=r&&r<=56319&&56320<=n&&n<=57343?w("Just",{head:(((r-55296|0)*1024|0)+(n-56320|0)|0)+65536|0,tail:Mi(2)(t)}):w("Just",{head:r,tail:Mi(1)(t)})},cJ=t=>{const e=Hs(t);return e.tag==="Just"?w("Just",E(e._1.head,e._1.tail)):y},gJ=t=>un.unfoldr(cJ)(t),$f=iJ(t=>{const e=Ur(Sa(0)(t));if(55296<=e&&e<=56319&&Dn(t)>1){const n=Ur(Sa(1)(t));if(56320<=n&&n<=57343)return(((e-55296|0)*1024|0)+(n-56320|0)|0)+65536|0}return e}),_n=uJ(gJ)($f),_J=t=>_n(t).length,dg=t=>Rn(t>=0&&t<=65535?Hf(t):t<0?"\0":"\uFFFF"),fJ=aJ(t=>t<=65535?dg(t):dg(Lr(t-65536|0,1024)+55296|0)+dg(go(t-65536|0)(1024)+56320|0)),qf=t=>e=>{if(t<1)return"";const n=Hs(e);return n.tag==="Just"?fJ(n._1.head)+qf(t-1|0)(n._1.tail):e},Ve=sJ(qf),dJ=t=>e=>e===""?y:w("Just",$f(e)),Vf=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},$s=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Uf=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},qi=t=>e=>Vf(t.w/$s(1e-6)(e.w))(t.h/$s(1e-6)(e.h)),Kf=t=>e=>n=>r=>n<e?t+e/2:Uf(t+e-n/2)(t+n/2)(r),Yf=t=>e=>n=>r=>n>=e?t+e/2:Uf(t+n/2)(t+e-n/2)(r),Xf=t=>e=>n=>({x:Yf(t.x)(t.w)(e.w)(n.x),y:Yf(t.y)(t.h)(e.h)(n.y)}),Zf=t=>e=>n=>({x:Kf(t.x)(t.w)(e.w)(n.x),y:Kf(t.y)(t.h)(e.h)(n.y)}),Vi=t=>{const e=t.visibleBounds.tag==="Just"?w("Just",{x:t.visibleBounds._1.x-t.padding,y:t.visibleBounds._1.y-t.padding,w:t.visibleBounds._1.w+2*t.padding,h:t.visibleBounds._1.h+2*t.padding}):y,n=e.tag==="Just"?w("Just",qi(t.frameAtUnitZoom)(e._1)):y,r=t.fallbackActionBounds.tag==="Just"?w("Just",{x:t.fallbackActionBounds._1.x-t.padding,y:t.fallbackActionBounds._1.y-t.padding,w:t.fallbackActionBounds._1.w+2*t.padding,h:t.fallbackActionBounds._1.h+2*t.padding}):y,o=$s(1e-6)(t.zoomCap),i=(()=>{if(n.tag==="Nothing")return!1;if(n.tag==="Just")return n._1>=o;g()})(),a=t.actionBounds.tag==="Just"?w("Just",{x:t.actionBounds._1.x-t.padding,y:t.actionBounds._1.y-t.padding,w:t.actionBounds._1.w+2*t.padding,h:t.actionBounds._1.h+2*t.padding}):y,s=a.tag==="Just"&&qi(t.frameAtUnitZoom)(a._1)>=o,u=(()=>{if(e.tag==="Nothing")return t.worldBounds;if(e.tag==="Just")return e._1;g()})(),c=(()=>{if(r.tag==="Just")return r._1;if(r.tag==="Nothing"){if(a.tag==="Nothing")return u;if(a.tag==="Just")return a._1}g()})(),_=(()=>{if(i){if(e.tag==="Nothing")return t.worldBounds;if(e.tag==="Just")return e._1;g()}if(s){if(a.tag==="Nothing")return c;if(a.tag==="Just")return a._1;g()}return c})(),f=(()=>{if(i){if(n.tag==="Nothing")return o;if(n.tag==="Just")return n._1;g()}return Vf(o)(qi(t.frameAtUnitZoom)(_))})(),l={w:t.frameAtUnitZoom.w/f,h:t.frameAtUnitZoom.h/f};return{center:Xf(t.worldBounds)(l)(i||s?{x:_.x+_.w/2,y:_.y+_.h/2}:Zf(_)(l)((()=>{const d={x:_.x+_.w/2,y:_.y+_.h/2};if(t.actionGuideBounds.tag==="Nothing")return d;if(t.actionGuideBounds.tag==="Just")return{x:t.actionGuideBounds._1.x+t.actionGuideBounds._1.w/2,y:t.actionGuideBounds._1.y+t.actionGuideBounds._1.h/2};g()})())),zoom:f}},Ui=t=>{const e=(()=>{if(t.bounds.tag==="Nothing")return t.worldBounds;if(t.bounds.tag==="Just")return{x:t.bounds._1.x-t.padding,y:t.bounds._1.y-t.padding,w:t.bounds._1.w+2*t.padding,h:t.bounds._1.h+2*t.padding};g()})(),n=qi(t.frameAtUnitZoom)(e),r=$s(1e-6)(t.zoomFloor),o=n>=r,i=o?n:r,a={w:t.frameAtUnitZoom.w/i,h:t.frameAtUnitZoom.h/i},s=t.actionTextBounds.tag==="Just"?w("Just",{x:t.actionTextBounds._1.x-t.padding,y:t.actionTextBounds._1.y-t.padding,w:t.actionTextBounds._1.w+2*t.padding,h:t.actionTextBounds._1.h+2*t.padding}):y,u=(()=>{if(s.tag==="Nothing")return!1;if(s.tag==="Just")return qi(t.frameAtUnitZoom)(s._1)>=r;g()})(),c=t.actionGuideBounds.tag==="Just"?w("Just",{x:t.actionGuideBounds._1.x-t.padding,y:t.actionGuideBounds._1.y-t.padding,w:t.actionGuideBounds._1.w+2*t.padding,h:t.actionGuideBounds._1.h+2*t.padding}):y,_=t.actionBounds.tag==="Just"?w("Just",{x:t.actionBounds._1.x-t.padding,y:t.actionBounds._1.y-t.padding,w:t.actionBounds._1.w+2*t.padding,h:t.actionBounds._1.h+2*t.padding}):y,f=(()=>{if(_.tag==="Nothing")return!1;if(_.tag==="Just")return qi(t.frameAtUnitZoom)(_._1)>=r;g()})(),l=(()=>{if(o)return e;if(f){if(_.tag==="Nothing")return e;if(_.tag==="Just")return _._1;g()}if(u){if(s.tag==="Nothing")return e;if(s.tag==="Just")return s._1;g()}const m=(()=>{if(_.tag==="Nothing")return e;if(_.tag==="Just")return _._1;g()})(),p=(()=>{if(s.tag==="Nothing")return m;if(s.tag==="Just")return s._1;g()})();if(c.tag==="Nothing")return p;if(c.tag==="Just")return c._1;g()})(),d={x:l.x+l.w/2,y:l.y+l.h/2},h=(()=>{if(c.tag==="Nothing")return d;if(c.tag==="Just")return{x:c._1.x+c._1.w/2,y:c._1.y+c._1.h/2};g()})();return{center:Xf(t.worldBounds)(a)(o?{x:l.x+l.w/2,y:l.y+l.h/2}:f||u?Zf(l)(a)(h):{x:l.x+l.w/2,y:l.y+l.h/2}),zoom:i}},jf=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},td=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},qs=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ed=t=>e=>jf(t.lo)(e.lo)<=td(t.hi)(e.hi)?w("Just",{lo:jf(t.lo)(e.lo),hi:td(t.hi)(e.hi)}):y,lg=t=>e=>{const n=(()=>{if(e.tag==="Just")return ed(t)(e._1);if(e.tag==="Nothing")return y;g()})();if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},hg={deadZoneWidth:.85,deadZoneHeight:1,hardZoneWidth:.85,hardZoneHeight:.8},nd=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>{const f=r<=o?{lo:n+r-o/2,hi:n+o/2}:{lo:n+o/2,hi:n+r-o/2},l=a.tag==="Just"?w("Just",a._1.size<=o?{lo:a._1.lo+a._1.size-o/2,hi:a._1.lo+o/2}:{lo:a._1.lo+o/2,hi:a._1.lo+a._1.size-o/2}):y,d=(()=>{if(a.tag==="Just")return a._1.size<=o;if(a.tag==="Nothing")return!1;g()})(),h=(()=>{if(d){if(l.tag==="Nothing")return f;if(l.tag==="Just")return l._1;g()}const J=(()=>{if(l.tag==="Just")return ed(f)(l._1);if(l.tag==="Nothing")return y;g()})();if(J.tag==="Nothing")return f;if(J.tag==="Just")return J._1;g()})(),m=lg(h)(s.tag==="Just"?w("Just",(()=>{const J=o*e;if(J<s._1.size){const T=s._1.lo+s._1.size/2;return{lo:T,hi:T}}return{lo:s._1.lo+s._1.size-J/2,hi:s._1.lo+J/2}})()):y),p=(()=>{if(a.tag==="Just")return qs(h.lo)(h.hi)(a._1.lo+a._1.size/2);if(a.tag==="Nothing")return qs(h.lo)(h.hi)(i);g()})(),x=lg(c.tag==="Just"&&c._1.size<=o?lg(m)(w("Just",(()=>{if(o<c._1.size){const J=c._1.lo+c._1.size/2;return{lo:J,hi:J}}return{lo:c._1.lo+c._1.size-o/2,hi:c._1.lo+o/2}})())):m)(s.tag==="Just"?w("Just",(()=>{const J=o*t;if(J<s._1.size){const T=s._1.lo+s._1.size/2;return{lo:T,hi:T}}return{lo:s._1.lo+s._1.size-J/2,hi:s._1.lo+J/2}})()):y);if(u.tag==="Just"){const J=u.tag==="Just"&&_.tag==="Just"&&xe(_._1)>.001?u._1.lo+u._1.size/2+_._1*o/6:i;return d?p:qs(x.lo)(x.hi)(J)}if(u.tag==="Nothing"){const J=s.tag==="Just"&&_.tag==="Just"&&xe(_._1)>.001?s._1.lo+s._1.size/2+_._1*o/6:i;return d?p:qs(x.lo)(x.hi)(J)}g()},pg=t=>e=>n=>r=>o=>({x:nd(t.deadZoneWidth)(t.hardZoneWidth)(e.x)(e.w)(n.w)(r.x)(o.visibleBounds.tag==="Just"?w("Just",{lo:o.visibleBounds._1.x,size:o.visibleBounds._1.w}):y)(o.subject.tag==="Just"?w("Just",{lo:o.subject._1.x,size:o.subject._1.w}):y)(o.guide.tag==="Just"?w("Just",{lo:o.guide._1.x,size:o.guide._1.w}):y)(o.mustSee.tag==="Just"?w("Just",{lo:o.mustSee._1.x,size:o.mustSee._1.w}):y)(o.lookAhead.tag==="Just"?w("Just",o.lookAhead._1.x):y),y:nd(t.deadZoneHeight)(t.hardZoneHeight)(e.y)(e.h)(n.h)(r.y)(o.visibleBounds.tag==="Just"?w("Just",{lo:o.visibleBounds._1.y,size:o.visibleBounds._1.h}):y)(o.subject.tag==="Just"?w("Just",{lo:o.subject._1.y,size:o.subject._1.h}):y)(o.guide.tag==="Just"?w("Just",{lo:o.guide._1.y,size:o.guide._1.h}):y)(o.mustSee.tag==="Just"?w("Just",{lo:o.mustSee._1.y,size:o.mustSee._1.h}):y)(o.lookAhead.tag==="Just"?w("Just",o.lookAhead._1.y):y)}),rd=v(xr)(0),lJ=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Pr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Vs=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},od=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},hJ=t=>{const e={top:0,bottom:0,left:0,right:0},n=t.shape==="Cloud"?{...e,top:t.h*.38}:t.shape==="Cylinder"?{...e,bottom:5}:t.shape==="Document"?{...e,bottom:t.h*.05}:e;return[{x:t.x-n.left,y:t.y-n.top},{x:t.x+t.w+n.right,y:t.y+t.h+n.bottom}]},Yo=t=>e=>{const n=Oe(a=>s=>({a,b:s,len:(()=>{const u=s.y-a.y,c=s.x-a.x;return qe(c*c+u*u)})()}),t,Bt(1,t.length,t)),r=rd(Y(a=>a.len)(n)),o=lJ(0)(r)(e*r),i=a=>s=>u=>{let c=a,_=s,f=u,l=!0,d;for(;l;){const h=c,m=_,p=f,x=Ft(J=>y,J=>T=>w("Just",{head:J,tail:T}),h);if(x.tag==="Nothing"){const J=t.length-1|0;if(J>=0&&J<t.length){l=!1,d=t[J];continue}l=!1,d=p;continue}if(x.tag==="Just"){if(m<=x._1.head.len){const J=x._1.head.len<=0?0:m/x._1.head.len;l=!1,d={x:x._1.head.a.x+(x._1.head.b.x-x._1.head.a.x)*J,y:x._1.head.a.y+(x._1.head.b.y-x._1.head.a.y)*J};continue}c=x._1.tail,_=m-x._1.head.len,f=p;continue}g()}return d};return 0<t.length?w("Just",i(n)(o)(t[0])):y},pJ=t=>e=>{const n=Pr(1e-6)(t.scale);return{x:(e.x-t.tx)/n,y:(e.y-t.ty)/n,w:e.w/n,h:e.h/n}},Ba=t=>rd(Oe(e=>n=>{const r=n.y-e.y,o=n.x-e.x;return qe(o*o+r*r)},t,Bt(1,t.length,t))),mJ=t=>e=>n=>r=>o=>{const i=0<t.length?w("Just",t[0]):y,a=(()=>{if(i.tag==="Nothing")return e;if(i.tag==="Just")return i._1;g()})(),s=t.length-1|0,u=s>=0&&s<t.length?w("Just",t[s]):y,c=(()=>{if(u.tag==="Nothing")return n;if(u.tag==="Just")return u._1;g()})(),_=Pr(.05)(1-o.pre-o.post),f=r<o.pre?0:r>1-o.post?1:(r-o.pre)/_,l=c.x-n.x,d=2*(()=>{const N=c.y-n.y;return(l<0?-l:l)+(N<0?-N:N)})(),h=a.x-e.x,m=2*(()=>{const N=a.y-e.y;return(h<0?-h:h)+(N<0?-N:N)})(),p=m+Ba(t)+d,x=p<=1e-4?1:1-d/p,J=p<=1e-4?0:m/p;if(f<=J){const N=J<=1e-4?1:f/J;return{x:e.x+(a.x-e.x)*N,y:e.y+(a.y-e.y)*N}}if(f>=x){const N=x>=1?0:(f-x)/(1-x);return{x:c.x+(n.x-c.x)*N,y:c.y+(n.y-c.y)*N}}const T=Yo(t)((f-J)/Pr(1e-4)(x-J));if(T.tag==="Nothing")return a;if(T.tag==="Just")return T._1;g()},id=t=>e=>{const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),[...(()=>{const r=(o,i)=>{if(o.tag==="Leaf")return i;if(o.tag==="Node")return r(o._5,Jt("Cons",o._4,r(o._6,i)));g()};return St(It(ge.foldr,r(t,z)))(hJ)})(),...Ln((()=>{const r=(o,i)=>{if(o.tag==="Leaf")return i;if(o.tag==="Node")return r(o._5,Jt("Cons",o._4,r(o._6,i)));g()};return It(ge.foldr,r(e,z))})())]);if(n.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(n.tag==="Just"){const r=v(o=>i=>({minX:Vs(o.minX)(i.x),minY:Vs(o.minY)(i.y),maxX:Pr(o.maxX)(i.x),maxY:Pr(o.maxY)(i.y)}))({minX:n._1.head.x,minY:n._1.head.y,maxX:n._1.head.x,maxY:n._1.head.y})(n._1.tail);return{x:r.minX,y:r.minY,w:r.maxX-r.minX,h:r.maxY-r.minY}}g()},mg={scale:1,tx:0,ty:0},yJ=t=>e=>{const n=Pr(4)(.15*Vs(e.w)(e.h)),r=Pr(1)(t.w),o=Pr(1)(t.h),i=Pr(1)(e.w-2*n),a=Pr(1)(e.h-2*n),s=.55*Vs(i/r)(a/o);return{scale:s,tx:e.x+n+(i-r*s)/2-t.x*s,ty:e.y+n+(a-o*s)/2+2.5-t.y*s}},xJ=t=>e=>(n=>r=>o=>{let i=n,a=r,s=o,u=!0,c;for(;u;){const _=i,f=a,l=s,d=Ft(h=>y,h=>m=>w("Just",{head:h,tail:m}),f);if(d.tag==="Nothing"){u=!1,c=l;continue}if(d.tag==="Just"){const h=od(d._1.head)(_.interiors);if(h.tag==="Nothing"){u=!1,c=l;continue}if(h.tag==="Just"){i=h._1,a=d._1.tail,s=(()=>{const m=yJ(h._1.layout.bounds)((()=>{const p=od(d._1.head)(_.layout.nodes);if(p.tag==="Nothing")return{x:0,y:0,w:1,h:1,label:"",shape:_o};if(p.tag==="Just")return p._1;g()})());return{scale:l.scale*m.scale,tx:l.scale*m.tx+l.tx,ty:l.scale*m.ty+l.ty}})();continue}}g()}return c})(t)(e)(mg),JJ=t=>t,ad=t=>e=>{const n=e.vw/e.vh,r=e.vh*t,o={...e,vx:e.vx-(r-e.vw)/2,vw:r},i=e.vw/t,a={...e,vy:e.vy-(i-e.vh)/2,vh:i};return t<=0||e.vw<=0||e.vh<=0?e:t>n?o:t<n?a:e},yg=t=>e=>t.width<=0||t.height<=0?e:ad(t.width/t.height)(e),nt=(t,e)=>({tag:"CatQueue",_1:t,_2:e}),wJ=t=>{let e=t,n=!0,r;for(;n;){const o=e;if(o._1.tag==="Nil"){if(o._2.tag==="Nil"){n=!1,r=y;continue}e=nt((i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=Jt("Cons",l._1,f),u=l._2;continue}g()}return _})(z)(o._2),z);continue}if(o._1.tag==="Cons"){n=!1,r=w("Just",E(o._1._1,nt(o._1._2,o._2)));continue}g()}return r},rt=(t,e,n)=>({tag:t,_1:e,_2:n}),ct=rt("CatNil"),TJ=t=>e=>{if(t.tag==="CatNil")return e;if(e.tag==="CatNil")return t;if(t.tag==="CatCons")return rt("CatCons",t._1,nt(t._2._1,Jt("Cons",e,t._2._2)));g()},NJ=t=>e=>n=>{const r=o=>i=>a=>{let s=o,u=i,c=a,_=!0,f;for(;_;){const l=s,d=u,h=c;if(h.tag==="Nil"){_=!1,f=d;continue}if(h.tag==="Cons"){s=l,u=l(d)(h._1),c=h._2;continue}g()}return f};return(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s,l=wJ(_);if(l.tag==="Nothing"){u=!1,c=r(d=>h=>h(d))(e)(f);continue}if(l.tag==="Just"){a=l._1._2,s=Jt("Cons",t(l._1._1),f);continue}g()}return c})(n)(z)},vJ=t=>{if(t.tag==="CatNil")return y;if(t.tag==="CatCons")return w("Just",E(t._1,t._2._1.tag==="Nil"&&t._2._2.tag==="Nil"?ct:NJ(TJ)(ct)(t._2)));g()},j=(t,e)=>({tag:"Free",_1:t,_2:e}),st=(t,e,n)=>({tag:t,_1:e,_2:n}),sd=t=>{let e=t,n=!0,r;for(;n;){const o=e;if(o._1.tag==="Return"){const i=vJ(o._2);if(i.tag==="Nothing"){n=!1,r=st("Return",o._1._1);continue}if(i.tag==="Just"){e=(()=>{const a=i._1._1(o._1._1);return j(a._1,(()=>{if(a._2.tag==="CatNil")return i._1._2;if(i._1._2.tag==="CatNil")return a._2;if(a._2.tag==="CatCons")return rt("CatCons",a._2._1,nt(a._2._2._1,Jt("Cons",i._1._2,a._2._2._2)));g()})())})();continue}g()}if(o._1.tag==="Bind"){n=!1,r=st("Bind",o._1._1,i=>{const a=o._1._2(i);return j(a._1,(()=>{if(a._2.tag==="CatNil")return o._2;if(o._2.tag==="CatNil")return a._2;if(a._2.tag==="CatCons")return rt("CatCons",a._2._1,nt(a._2._2._1,Jt("Cons",o._2,a._2._2._2)));g()})())});continue}g()}return r},bJ=t=>e=>{const n=e.Monad0(),r=n.Bind1().Apply0().Functor0();return o=>e.tailRecM(i=>{const a=sd(i);if(a.tag==="Return")return r.map(k2)(n.Applicative0().pure(a._1));if(a.tag==="Bind")return r.map(Sc)(o(t.map(a._2)(a._1)));g()})},CJ=t=>e=>n=>{const r=sd(n);if(r.tag==="Return")return e(r._1);if(r.tag==="Bind")return t(r._1)(r._2);g()},xg={Applicative0:()=>ho,Bind1:()=>ud},LJ={map:t=>e=>ud.bind(e)(n=>ho.pure(t(n)))},ud={bind:t=>e=>j(t._1,(()=>{if(t._2.tag==="CatNil")return rt("CatCons",e,nt(z,z));if(t._2.tag==="CatCons")return rt("CatCons",t._2._1,nt(t._2._2._1,Jt("Cons",rt("CatCons",e,nt(z,z)),t._2._2._2)));g()})()),Apply0:()=>cd},cd={apply:t=>e=>{const n=r=>j(e._1,(()=>{if(e._2.tag==="CatNil")return rt("CatCons",o=>ho.pure(r(o)),nt(z,z));if(e._2.tag==="CatCons")return rt("CatCons",e._2._1,nt(e._2._2._1,Jt("Cons",rt("CatCons",o=>ho.pure(r(o)),nt(z,z)),e._2._2._2)));g()})());return j(t._1,(()=>{if(t._2.tag==="CatNil")return rt("CatCons",n,nt(z,z));if(t._2.tag==="CatCons")return rt("CatCons",t._2._1,nt(t._2._2._1,Jt("Cons",rt("CatCons",n,nt(z,z)),t._2._2._2)));g()})())},Functor0:()=>LJ},ho={pure:t=>j(st("Return",t),ct),Apply0:()=>cd},Us=t=>t,kJ=t=>t,Kr=Us("RunText"),Jg=Us("RunCode"),wg=Us("RunHighlight"),Tg=Us("RunCodeHighlight"),SJ=t=>{const e=r=>{const o=Ft(i=>y,i=>a=>w("Just",{head:i,tail:a}),r);if(o.tag==="Nothing")return[];if(o.tag==="Just"){if(o._1.head==="\\"){const i=Ft(a=>y,a=>s=>w("Just",{head:a,tail:s}),o._1.tail);if(i.tag==="Nothing")return[o._1.head];if(i.tag==="Just")return[o._1.head,i._1.head,...e(i._1.tail)];g()}return o._1.head==="="&&0<o._1.tail.length&&o._1.tail[0]==="="?e(Bt(1,o._1.tail.length,o._1.tail)):[o._1.head,...e(o._1.tail)]}g()},n=cr("md:")(t);if(n.tag==="Nothing")return t;if(n.tag==="Just")return kn(e(Bn(n._1)));g()},EJ=t=>"md:"+t,Fn=t=>{const e=(()=>{const r=cr("md:")(t);if(r.tag==="Just")return!0;if(r.tag==="Nothing")return!1;g()})()?EJ:kJ,n=$i(`
3
+ `)((()=>{const r=cr("md:")(t);if(r.tag==="Just")return r._1;if(r.tag==="Nothing")return t;g()})());return n.length===0?[e("")]:Y(e)(n)},Ng=t=>e=>n=>e.length===0?n:Et(n)({style:t,text:kn(e)}),PJ=t=>({code:!t.code,highlight:t.highlight,buf:[],runs:Ng((()=>{if(!t.highlight){if(!t.code)return Kr;if(t.code)return Jg;g()}if(t.highlight){if(!t.code)return wg;if(t.code)return Tg}g()})())(t.buf)(t.runs)}),GJ=t=>({code:t.code,highlight:!t.highlight,buf:[],runs:Ng((()=>{if(!t.highlight){if(!t.code)return Kr;if(t.code)return Jg;g()}if(t.highlight){if(!t.code)return wg;if(t.code)return Tg}g()})())(t.buf)(t.runs)}),AJ=t=>e=>0<e.length?{...t,buf:Et(t.buf)(e[0])}:{...t,buf:Et(t.buf)("\\")},BJ=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=Ft(f=>y,f=>l=>w("Just",{head:f,tail:l}),i);if(_.tag==="Nothing"){a=!1,s=c;continue}if(_.tag==="Just"){if(_._1.head==="\\"){r=u,o=AJ(c)(_._1.tail),i=Bt(1,_._1.tail.length,_._1.tail);continue}if(_._1.head==="`"){r=u,o=PJ(c),i=_._1.tail;continue}if(u&&_._1.head==="="&&0<_._1.tail.length&&_._1.tail[0]==="="){r=u,o=GJ(c),i=Bt(1,_._1.tail.length,_._1.tail);continue}r=u,o={...c,buf:Et(c.buf)(_._1.head)},i=_._1.tail;continue}g()}return s},dr=t=>{const e=BJ((()=>{const n=cr("md:")(t);if(n.tag==="Just")return!0;if(n.tag==="Nothing")return!1;g()})())({code:!1,highlight:!1,buf:[],runs:[]})(Bn((()=>{const n=cr("md:")(t);if(n.tag==="Just")return n._1;if(n.tag==="Nothing")return t;g()})()));return Ng((()=>{if(!e.highlight){if(!e.code)return Kr;if(e.code)return Jg;g()}if(e.highlight){if(!e.code)return wg;if(e.code)return Tg}g()})())(e.buf)(e.runs)},lr=(()=>{const t=Zn(""),e=Y(n=>n.text);return n=>t(e(dr(n)))})();let vg=null;function RJ(){return vg||(typeof document>"u"?null:(vg=document.createElement("canvas").getContext("2d"),vg))}const gd=new Map,DJ=t=>e=>n=>r=>()=>{const o=`${n} ${e}px ${t}|${r}`,i=gd.get(o);if(i!==void 0)return i;const a=RJ();if(!a)return r.length*e*.62;a.font=`${n} ${e}px ${t}`;const s=a.measureText(r).width;return gd.set(o,s),s},FJ=ao.traverse(kc),zJ=v(xr)(0),Xo=(()=>{const t=fr(`\r
4
+ `)(" "),e=fr(`
5
+ `)(" "),n=(()=>{const r=fr("\r")(" "),o=(()=>{const i=fr(" ")(" ");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),_d=t=>e=>{const n=FJ(r=>{const o=(()=>{if(r.style==="RunText")return t.text;if(r.style==="RunCode")return t.code;if(r.style==="RunHighlight")return t.text;if(r.style==="RunCodeHighlight")return t.code;g()})();return DJ(o.family)(o.size)(o.weight)(Xo(r.text))})(dr(Xo(e)));return()=>{const r=n();return zJ(r)}},fd={text:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:"500"},code:{family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",size:11,weight:"400"}},IJ=()=>()=>()=>t=>e=>n=>l2(n.type)(t)?h2(n.type)(t)(n.value):e(n),QJ={map:t=>e=>({type:e.type,value:e.map(t)(e.value),map:e.map})},MJ=t=>Pf("Data.Functor.Variant: pattern match failure ["+t.type+"]"),OJ=()=>()=>()=>t=>IJ()()()(t)(MJ);(function(){var t={},e="Pure",n="Throw",r="Catch",o="Sync",i="Async",a="Bind",s="Bracket",u="Fork",c="Sequential",_="Map",f="Apply",l="Alt",d="Cons",h="Resume",m="Release",p="Finalizer",x="Finalized",J="Forked";function T(W,D,X,V){this.tag=W,this._1=D,this._2=X,this._3=V}function N(W){var D=function(X,V,K){return new T(W,X,V,K)};return D.tag=W,D}function k(W){return new T(e,void 0)}function C(W){try{W()}catch(D){setTimeout(function(){throw D},0)}}function P(W,D,X){try{return D(X())}catch(V){return W(V)}}function G(W,D,X){try{return D(X)()}catch(V){return X(W(V))(),k}}var R=(function(){var W=1024,D=0,X=0,V=new Array(W),K=!1;function Z(){var tt;for(K=!0;D!==0;)D--,tt=V[X],V[X]=void 0,X=(X+1)%W,tt();K=!1}return{isDraining:function(){return K},enqueue:function(tt){var et;D===W&&(et=K,Z(),K=et),V[(X+D)%W]=tt,D++,K||Z()}}})();function U(W){var D={},X=0,V=0;return{register:function(K){var Z=X++;K.onComplete({rethrow:!0,handler:function(tt){return function(){V--,delete D[Z]}}})(),D[Z]=K,V++},isEmpty:function(){return V===0},killAll:function(K,Z){return function(){if(V===0)return Z();var tt=0,et={};function ft(dt){et[dt]=D[dt].kill(K,function(mt){return function(){delete et[dt],tt--,W.isLeft(mt)&&W.fromLeft(mt)&&setTimeout(function(){throw W.fromLeft(mt)},0),tt===0&&Z()}})()}for(var Nt in D)D.hasOwnProperty(Nt)&&(tt++,ft(Nt));return D={},X=0,V=0,function(dt){return new T(o,function(){for(var mt in et)et.hasOwnProperty(mt)&&et[mt]()})}}}}}var S=0,b=1,I=2,H=3,Q=4,q=5,$=6;function A(W,D,X){var V=0,K=S,Z=X,tt=null,et=null,ft=null,Nt=null,dt=null,mt=0,bt=0,Ht=null,Tt=!0;function Vt(gt){for(var wt,Rt,yt;;)switch(wt=null,Rt=null,yt=null,K){case I:K=b;try{Z=ft(Z),Nt===null?ft=null:(ft=Nt._1,Nt=Nt._2)}catch(Wt){K=q,tt=W.left(Wt),Z=null}break;case H:W.isLeft(Z)?(K=q,tt=Z,Z=null):ft===null?K=q:(K=I,Z=W.fromRight(Z));break;case b:switch(Z.tag){case a:ft&&(Nt=new T(d,ft,Nt)),ft=Z._2,K=b,Z=Z._1;break;case e:ft===null?(K=q,Z=W.right(Z._1)):(K=I,Z=Z._1);break;case o:K=H,Z=P(W.left,W.right,Z._1);break;case i:K=Q,Z=G(W.left,Z._1,function(Wt){return function(){V===gt&&(V++,R.enqueue(function(){V===gt+1&&(K=H,Z=Wt,Vt(V))}))}});return;case n:K=q,tt=W.left(Z._1),Z=null;break;case r:ft===null?dt=new T(d,Z,dt,et):dt=new T(d,Z,new T(d,new T(h,ft,Nt),dt,et),et),ft=null,Nt=null,K=b,Z=Z._1;break;case s:mt++,ft===null?dt=new T(d,Z,dt,et):dt=new T(d,Z,new T(d,new T(h,ft,Nt),dt,et),et),ft=null,Nt=null,K=b,Z=Z._1;break;case u:K=H,wt=A(W,D,Z._2),D&&D.register(wt),Z._1&&wt.run(),Z=W.right(wt);break;case c:K=b,Z=M(W,D,Z._1);break}break;case q:if(ft=null,Nt=null,dt===null)K=$,Z=et||tt||Z;else switch(wt=dt._3,yt=dt._1,dt=dt._2,yt.tag){case r:et&&et!==wt&&mt===0?K=q:tt&&(K=b,Z=yt._2(W.fromLeft(tt)),tt=null);break;case h:et&&et!==wt&&mt===0||tt?K=q:(ft=yt._1,Nt=yt._2,K=I,Z=W.fromRight(Z));break;case s:mt--,tt===null&&(Rt=W.fromRight(Z),dt=new T(d,new T(m,yt._2,Rt),dt,wt),(et===wt||mt>0)&&(K=b,Z=yt._3(Rt)));break;case m:dt=new T(d,new T(x,Z,tt),dt,et),K=b,et&&et!==wt&&mt===0?Z=yt._1.killed(W.fromLeft(et))(yt._2):tt?Z=yt._1.failed(W.fromLeft(tt))(yt._2):Z=yt._1.completed(W.fromRight(Z))(yt._2),tt=null,mt++;break;case p:mt++,dt=new T(d,new T(x,Z,tt),dt,et),K=b,Z=yt._1;break;case x:mt--,K=q,Z=yt._1,tt=yt._2;break}break;case $:for(var Ct in Ht)Ht.hasOwnProperty(Ct)&&(Tt=Tt&&Ht[Ct].rethrow,C(Ht[Ct].handler(Z)));Ht=null,et&&tt?setTimeout(function(){throw W.fromLeft(tt)},0):W.isLeft(Z)&&Tt&&setTimeout(function(){if(Tt)throw W.fromLeft(Z)},0);return;case S:K=b;break;case Q:return}}function At(gt){return function(){if(K===$)return Tt=Tt&&gt.rethrow,gt.handler(Z)(),function(){};var wt=bt++;return Ht=Ht||{},Ht[wt]=gt,function(){Ht!==null&&delete Ht[wt]}}}function vt(gt,wt){return function(){if(K===$)return wt(W.right(void 0))(),function(){};var Rt=At({rethrow:!1,handler:function(){return wt(W.right(void 0))}})();switch(K){case S:et=W.left(gt),K=$,Z=et,Vt(V);break;case Q:et===null&&(et=W.left(gt)),mt===0&&(K===Q&&(dt=new T(d,new T(p,Z(gt)),dt,et)),K=q,Z=null,tt=null,Vt(++V));break;default:et===null&&(et=W.left(gt)),mt===0&&(K=q,Z=null,tt=null)}return Rt}}function pt(gt){return function(){var wt=At({rethrow:!1,handler:gt})();return K===S&&Vt(V),wt}}return{kill:vt,join:pt,onComplete:At,isSuspended:function(){return K===S},run:function(){K===S&&(R.isDraining()?Vt(V):R.enqueue(function(){Vt(V)}))}}}function F(W,D,X,V){var K=0,Z={},tt=0,et={},ft=new Error("[ParAff] Early exit"),Nt=null,dt=t;function mt(At,vt,pt){var gt=vt,wt=null,Rt=null,yt=0,Ct={},Wt,zt;t:for(;;)switch(Wt=null,gt.tag){case J:if(gt._3===t&&(Wt=Z[gt._1],Ct[yt++]=Wt.kill(At,function(se){return function(){yt--,yt===0&&pt(se)()}})),wt===null)break t;gt=wt._2,Rt===null?wt=null:(wt=Rt._1,Rt=Rt._2);break;case _:gt=gt._2;break;case f:case l:wt&&(Rt=new T(d,wt,Rt)),wt=gt,gt=gt._1;break}if(yt===0)pt(W.right(void 0))();else for(zt=0,Wt=yt;zt<Wt;zt++)Ct[zt]=Ct[zt]();return Ct}function bt(At,vt,pt){var gt,wt,Rt,yt,Ct,Wt;for(W.isLeft(At)?(gt=At,wt=null):(wt=At,gt=null);;){if(Rt=null,yt=null,Ct=null,Wt=null,Nt!==null)return;if(vt===null){V(gt||wt)();return}if(vt._3!==t)return;switch(vt.tag){case _:gt===null?(vt._3=W.right(vt._1(W.fromRight(wt))),wt=vt._3):vt._3=gt;break;case f:if(Rt=vt._1._3,yt=vt._2._3,gt){if(vt._3=gt,Ct=!0,Wt=tt++,et[Wt]=mt(ft,gt===Rt?vt._2:vt._1,function(){return function(){delete et[Wt],Ct?Ct=!1:pt===null?bt(gt,null,null):bt(gt,pt._1,pt._2)}}),Ct){Ct=!1;return}}else{if(Rt===t||yt===t)return;wt=W.right(W.fromRight(Rt)(W.fromRight(yt))),vt._3=wt}break;case l:if(Rt=vt._1._3,yt=vt._2._3,Rt===t&&W.isLeft(yt)||yt===t&&W.isLeft(Rt))return;if(Rt!==t&&W.isLeft(Rt)&&yt!==t&&W.isLeft(yt))gt=wt===Rt?yt:Rt,wt=null,vt._3=gt;else if(vt._3=wt,Ct=!0,Wt=tt++,et[Wt]=mt(ft,wt===Rt?vt._2:vt._1,function(){return function(){delete et[Wt],Ct?Ct=!1:pt===null?bt(wt,null,null):bt(wt,pt._1,pt._2)}}),Ct){Ct=!1;return}break}pt===null?vt=null:(vt=pt._1,pt=pt._2)}}function Ht(At){return function(vt){return function(){delete Z[At._1],At._3=vt,bt(vt,At._2._1,At._2._2)}}}function Tt(){var At=b,vt=X,pt=null,gt=null,wt,Rt;t:for(;;)switch(wt=null,Rt=null,At){case b:switch(vt.tag){case _:pt&&(gt=new T(d,pt,gt)),pt=new T(_,vt._1,t,t),vt=vt._2;break;case f:pt&&(gt=new T(d,pt,gt)),pt=new T(f,t,vt._2,t),vt=vt._1;break;case l:pt&&(gt=new T(d,pt,gt)),pt=new T(l,t,vt._2,t),vt=vt._1;break;default:Rt=K++,At=q,wt=vt,vt=new T(J,Rt,new T(d,pt,gt),t),wt=A(W,D,wt),wt.onComplete({rethrow:!1,handler:Ht(vt)})(),Z[Rt]=wt,D&&D.register(wt)}break;case q:if(pt===null)break t;pt._1===t?(pt._1=vt,At=b,vt=pt._2,pt._2=t):(pt._2=vt,vt=pt,gt===null?pt=null:(pt=gt._1,gt=gt._2))}for(dt=vt,Rt=0;Rt<K;Rt++)Z[Rt].run()}function Vt(At,vt){Nt=W.left(At);var pt;for(var gt in et)if(et.hasOwnProperty(gt)){pt=et[gt];for(gt in pt)pt.hasOwnProperty(gt)&&pt[gt]()}et=null;var wt=mt(At,dt,vt);return function(Rt){return new T(i,function(yt){return function(){for(var Ct in wt)wt.hasOwnProperty(Ct)&&wt[Ct]();return k}})}}return Tt(),function(At){return new T(i,function(vt){return function(){return Vt(At,vt)}})}}function M(W,D,X){return new T(i,function(V){return function(){return F(W,D,X,V)}})}return T.EMPTY=t,T.Pure=N(e),T.Throw=N(n),T.Catch=N(r),T.Sync=N(o),T.Async=N(i),T.Bind=N(a),T.Bracket=N(s),T.Fork=N(u),T.Seq=N(c),T.ParMap=N(_),T.ParApply=N(f),T.ParAlt=N(l),T.Fiber=A,T.Supervisor=U,T.Scheduler=R,T.nonCanceler=k,T})();const WJ=t=>e=>CJ(n=>r=>t({type:n.type,value:n.map(o=>r(o))(n.value),map:n.map}))(e),HJ=t=>{const e=t.Bind1(),n=t.Applicative0().pure;return r=>{const o=f2(()=>WJ(i=>e.bind(r(i))(o()))(n));return o()}};let dd=null;function $J(){return dd||(typeof document>"u"?null:dd=document.createElement("canvas").getContext("2d"))}const bg=new Map;function ld(t,e,n,r,o,i){const a=`${n} ${e}px ${t}`,s=a+"|"+r;if(bg.has(s))return bg.get(s);const u=$J();if(!u)return i;u.font=a;const c=o(u.measureText(r)),_=typeof document<"u"?document.fonts:null;if(!_||_.check(a))bg.set(s,c);else if(_&&_.load)try{_.load(a)}catch{}return c}const qJ=(t,e,n,r)=>ld(t,e,n,r,o=>o.width,-1),VJ=(t,e,n,r)=>ld(t,e,n,r,o=>({ascent:o.actualBoundingBoxAscent,descent:o.actualBoundingBoxDescent}),{ascent:-1,descent:-1}),Ks=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),hd=t=>t,pd={map:t=>e=>{if(e.tag==="MeasureText")return Ks("MeasureText",e._1,e._2,n=>t(e._3(n)));if(e.tag==="MeasureInk")return Ks("MeasureInk",e._1,e._2,n=>t(e._3(n)));g()}},Cg=t=>e=>{const n=qJ(t.family,t.size,t.weight,Xo(e));return n<0?ot(_n(e).length)*t.size*.62:n},Lg=t=>e=>{const n=VJ(t.family,t.size,t.weight,Xo(e));return n.ascent<0?{ascent:t.size*.72,descent:t.size*.2}:n},UJ=t=>e=>j(st("Bind",{type:"metrics",value:Ks("MeasureInk",t,e,hd),map:pd.map},n=>j(st("Return",n),ct)),ct),Zo=t=>e=>j(st("Bind",{type:"metrics",value:Ks("MeasureText",t,e,hd),map:pd.map},n=>j(st("Return",n),ct)),ct),md=t=>t,yd=t=>t,Ys=t=>t,xd=t=>t,Jd=t=>t,Yt=(t,e,n,r,o)=>({tag:t,_1:e,_2:n,_3:r,_4:o}),wd=t=>t,kg=t=>t,KJ=kg("BaselineTop"),jn=kg("BaselineMiddle"),YJ=kg("BaselineBottom"),po=wd("AlignLeft"),jo=wd("AlignCenter"),nn=Jd("RoundJoin"),Ra=Jd("MiterJoin"),zn=xd("ButtCap"),Gr=xd("RoundCap"),XJ=Ys("LayerPolyOut"),ZJ=Ys("LayerPolyIn"),jJ=Ys("LayerNodeMask"),tw=Ys("LayerOverlay"),ti=yd("NonZero"),Sg=yd("EvenOdd"),Td=md("Normal"),Xs=md("Difference"),we={r:255,g:255,b:255,a:255},mo=[5],Ce={map:t=>e=>{if(e.tag==="FillPath")return Yt("FillPath",e._1,e._2,t(e._3));if(e.tag==="StrokePath")return Yt("StrokePath",e._1,e._2,t(e._3));if(e.tag==="FillStrokePath")return Yt("FillStrokePath",e._1,e._2,e._3,t(e._4));if(e.tag==="DrawText")return Yt("DrawText",e._1,t(e._2));if(e.tag==="DrawTextAffine")return Yt("DrawTextAffine",e._1,e._2,t(e._3));if(e.tag==="PushTransform")return Yt("PushTransform",e._1,t(e._2));if(e.tag==="PopTransform")return Yt("PopTransform",t(e._1));if(e.tag==="PushClip")return Yt("PushClip",e._1,e._2,t(e._3));if(e.tag==="PopClip")return Yt("PopClip",t(e._1));if(e.tag==="PushBlend")return Yt("PushBlend",e._1,t(e._2));if(e.tag==="PopBlend")return Yt("PopBlend",t(e._1));if(e.tag==="PushAlpha")return Yt("PushAlpha",e._1,t(e._2));if(e.tag==="PopAlpha")return Yt("PopAlpha",t(e._1));if(e.tag==="PushBlur")return Yt("PushBlur",e._1,t(e._2));if(e.tag==="PopBlur")return Yt("PopBlur",t(e._1));if(e.tag==="PushLayer")return Yt("PushLayer",e._1,t(e._2));if(e.tag==="PopLayer")return Yt("PopLayer",t(e._1));if(e.tag==="SetViewport")return Yt("SetViewport",e._1,t(e._2));if(e.tag==="ClearBackground")return Yt("ClearBackground",e._1,t(e._2));if(e.tag==="BackgroundDots")return Yt("BackgroundDots",e._1,t(e._2));g()}},Yr={r:26,g:26,b:26,a:255},Eg=t=>e=>Math.imul(t,e),Ki=t=>{const e=t+1831565813|0,n=Eg(e^e>>>15)(e|1),r=n^(n+Eg(n^n>>>7)(n|61)|0),o=r^r>>>14;return{prng:o,value:o<0?(ot(o)+4294967296)/4294967296:ot(o)/4294967296}},Ge=t=>e=>n=>{const r=Ki(n);return{prng:r.prng,value:t+r.value*(e-t)}},Pg=t=>e=>v(n=>r=>Eg(n^r)(-2048144789))(e)(Y(Ur)(Bn(t))),ew=t=>t,Nd=t=>t,nw=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Sn=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},vd=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Gg=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},rw=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ow=Nd("FlatLevel"),iw=Nd("NestedLevel"),Ag=ew("GenieSilhouette"),aw=t=>e=>n=>r=>{if(e)return{prng:t,yLift:0};const o=Ki(t);return{prng:o.prng,yLift:o.value*n.yJitter*r}},sw=t=>e=>n=>r=>{if(e)return{prng:t,dx:0};const o=Ki(t);return{prng:o.prng,dx:(o.value*2-1)*n.xJitter*r}},bd=t=>e=>{const n=e.cy-t.cy,r=e.cx-t.cx,o=qe(r*r+n*n),i=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=qe(nw(0)(t.r*t.r-i*i)),s=t.cx+i*r/o,u=t.cy+i*n/o,c={x:s-a*n/o,y:u+a*r/o},_={x:s+a*n/o,y:u-a*r/o};return o===0||o>t.r+e.r?{x:(t.cx+e.cx)/2,y:t.cy}:c.y<_.y?c:_},Zs=t=>e=>{const n=Sn(e)(Sn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},uw=t=>e=>n=>r=>o=>i=>{if(e)return{prng:t,r:o};if(n)return{prng:t,r:o*(1+i.rJitter)};if(r)return{prng:t,r:o*i.smallScale};const a=Ki(t);return{prng:a.prng,r:o*(1+a.value*i.rJitter)}},Cd=t=>{const e=Sn(t.w)(t.h)/2;return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,4,t.x+t.w-e+.5522847498307936*e,t.y,t.x+t.w,t.y+e-.5522847498307936*e,t.x+t.w,t.y+e,4,t.x+t.w,t.y+e+.5522847498307936*e,t.x+t.w-e+.5522847498307936*e,t.y+t.h,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,4,t.x+e-.5522847498307936*e,t.y+t.h,t.x,t.y+e+.5522847498307936*e,t.x,t.y+e,4,t.x,t.y+e-.5522847498307936*e,t.x+e-.5522847498307936*e,t.y,t.x+e,t.y,5]},cw=t=>e=>n=>{const r=Ki(t),o=e.length;return o===0?{prng:t,idx:-1}:{prng:r.prng,idx:(()=>{const i=vd(0)(o-1|0)(he(ar(r.value*ot(n))));return i>=0&&i<e.length?e[i]:-1})()}},gw=t=>e=>{const n=Ki(t),r=e.length;return r===0?{prng:t,idx:-1}:{prng:n.prng,idx:(()=>{const o=vd(0)(r-1|0)(he(ar(n.value*ot(r))));return o>=0&&o<e.length?e[o]:-1})()}},Ld=t=>{const e=Sn(t.w*.18)(t.h*.6);return[1,t.x+e,t.y,2,t.x+t.w,t.y,2,t.x+t.w-e,t.y+t.h,2,t.x,t.y+t.h,5]},kd=t=>[1,t.x,t.y,2,t.x+t.w,t.y,2,t.x+t.w,t.y+t.h*.85,4,t.x+t.w*.66,t.y+t.h*1.05,t.x+t.w*.34,t.y+t.h*.65,t.x,t.y+t.h*.85,5],Sd={rBase:1.2,stepRatio:.7,rJitter:.35,yJitter:.2,xJitter:.2,heroShift:.2,smallScale:.85,smallShift:.15,seed:7,minN:3},_w=t=>{const e=Sn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,o=t.x+n;return[1,t.x,r,4,t.x,r+.5522847498*e,o-.5522847498*n,r+e,o,r+e,4,o+.5522847498*n,r+e,t.x+t.w,r+.5522847498*e,t.x+t.w,r]},Ed=t=>{const e=Sn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+t.h+5,o=t.y+e,i=r-e,a=t.x+n;return[1,t.x,o,4,t.x,o-.5522847498*e,a-.5522847498*n,t.y,a,t.y,4,a+.5522847498*n,t.y,t.x+t.w,o-.5522847498*e,t.x+t.w,o,2,t.x+t.w,i,4,t.x+t.w,i+.5522847498*e,a+.5522847498*n,r,a,r,4,a-.5522847498*n,r,t.x,i+.5522847498*e,t.x,i,5]},Pd=t=>e=>{const n=e.y+e.h,r=sy(t.rBase*e.h)(e.w/(2*(1+(ot(t.minN)-1)*t.stepRatio))),o=e.w-2*r,i=2*r*t.stepRatio,a=Gg(t.minN)(o<=0||i<=0?t.minN:he(Un(o/i))+1|0),s=a>=3?Ut(1,a-2|0):[],u=s.length,c=Lr(u+1|0,2),_=c<1?[]:Bt(0,c,s),f=gw(t.seed)((()=>{const p=u-c|0;return p<1?s:Bt(p,s.length,s)})()),l=f.idx,d=cw(f.prng)(_t(p=>p!==l,_))(Gg(1)(_.length-(mn(io)(l)(_)?1:0)|0)),h=d.idx,m=a>=2?o/(ot(a)-1):0;return v(p=>x=>{const J=x===h,T=x===l,N=x===0||x===(a-1|0),k=uw(p.prng)(N)(T)(J)(r)(t),C=aw(k.prng)(N)(t)(e.h),P=sw(C.prng)(N)(t)(m);return{prng:P.prng,circles:Et(p.circles)({cx:e.x+rw(k.r)(e.w-k.r)((a>=2?r+ot(x)/(ot(a)-1)*o+P.dx:r+0*o+P.dx)+(T?t.heroShift*m:J?-1*t.smallShift*m:0)),cy:n-C.yLift,r:k.r})}})({prng:d.prng,circles:[]})(Ut(0,a-1|0)).circles},Gd=t=>e=>{const n=t.length;return Mt(r=>o=>({c:o,p1:(()=>{if(r===0)return{x:o.cx-o.r,y:e};const i=r-1|0;return i>=0&&i<t.length?bd(t[i])(o):{x:o.cx-o.r,y:e}})(),p2:(()=>{if(r===(n-1|0))return{x:o.cx+o.r,y:e};const i=r+1|0;return i>=0&&i<t.length?bd(o)(t[i]):{x:o.cx+o.r,y:e}})()}))(t)},Ad=t=>{const e=Sn(t.h*.4)(t.w*.2);return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,2,t.x+t.w,t.y+t.h/2,2,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,2,t.x,t.y+t.h/2,5]},fw=t=>e=>n=>{const r=Io(e.y-t.cy)(e.x-t.cx),o=Io(n.y-t.cy)(n.x-t.cx),i=o>r?o-r:o+6.283185307179586-r,a=Gg(1)(he(vs(i/1.5707963267948966))),s=i/ot(a),u=1.3333333333333333*uy(s/4);return St(Ut(0,a-1|0))(c=>{const _=r+ot(c+1|0)*s,f=t.cx+t.r*yn(_),l=t.cy+t.r*tn(_),d=r+ot(c)*s;return[4,t.cx+t.r*yn(d)-u*t.r*tn(d),t.cy+t.r*tn(d)+u*t.r*yn(d),f+u*t.r*tn(_),l-u*t.r*yn(_),f,l]})},Bd=t=>e=>{const n=t.h*.38,r=Gd(Pd(Sd)({x:t.x,y:t.y-n,w:t.w,h:n}))(t.y),o=Sn(e)(Sn(t.w/2)(t.h/2));return 0<r.length?[1,r[0].p1.x,r[0].p1.y,...St(r)(i=>fw(i.c)(i.p1)(i.p2)),2,t.x+t.w,t.y+t.h-o,3,t.x+t.w,t.y+t.h,t.x+t.w-o,t.y+t.h,2,t.x+o,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-o,2,r[0].p1.x,r[0].p1.y,5]:Zs(t)(e)},ei=t=>e=>n=>r=>o=>i=>{if(e==="Rectangle")return t.drawRoundedRect(n)(r)(o)(i);if(e==="Cylinder"){const a=Ed(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Parallelogram"){const a=Ld(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Diamond"){const a=Ad(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Ellipse"){const a=Cd(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Document"){const a=kd(n);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Cloud"){const a=Bd(n)(r);if(o.tag==="Just"){if(i.tag==="Just")return t.fillStrokePath(a)(o._1)(i._1);if(i.tag==="Nothing")return t.fillPath(a)(o._1);g()}if(o.tag==="Nothing"){if(i.tag==="Just")return t.strokePath(a)(i._1);if(i.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}return t.drawRoundedRect(n)(r)(o)(i)},dw={fillPath:t=>e=>j(st("Bind",{type:"render",value:Yt("FillPath",t,e,void 0),map:Ce.map},n=>j(st("Return",n),ct)),ct),strokePath:t=>e=>j(st("Bind",{type:"render",value:Yt("StrokePath",t,e,void 0),map:Ce.map},n=>j(st("Return",n),ct)),ct),fillStrokePath:t=>e=>n=>j(st("Bind",{type:"render",value:Yt("FillStrokePath",t,e,n,void 0),map:Ce.map},r=>j(st("Return",r),ct)),ct),drawRoundedRect:t=>e=>n=>r=>{if(n.tag==="Just"){if(r.tag==="Just")return j(st("Bind",{type:"render",value:Yt("FillStrokePath",Zs(t)(e),n._1,r._1,void 0),map:Ce.map},o=>j(st("Return",o),ct)),ct);if(r.tag==="Nothing")return j(st("Bind",{type:"render",value:Yt("FillPath",Zs(t)(e),n._1,void 0),map:Ce.map},o=>j(st("Return",o),ct)),ct);g()}if(n.tag==="Nothing"){if(r.tag==="Just")return j(st("Bind",{type:"render",value:Yt("StrokePath",Zs(t)(e),r._1,void 0),map:Ce.map},o=>j(st("Return",o),ct)),ct);if(r.tag==="Nothing")return j(st("Return",void 0),ct)}g()},drawText:t=>j(st("Bind",{type:"render",value:Yt("DrawText",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),drawTextAffine:t=>e=>j(st("Bind",{type:"render",value:Yt("DrawTextAffine",t,e,void 0),map:Ce.map},n=>j(st("Return",n),ct)),ct),pushTransform:t=>j(st("Bind",{type:"render",value:Yt("PushTransform",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popTransform:j(st("Bind",{type:"render",value:Yt("PopTransform",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushBakedTransform:t=>j(st("Bind",{type:"render",value:Yt("PushTransform",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popBakedTransform:j(st("Bind",{type:"render",value:Yt("PopTransform",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushClip:t=>e=>j(st("Bind",{type:"render",value:Yt("PushClip",t,e,void 0),map:Ce.map},n=>j(st("Return",n),ct)),ct),popClip:j(st("Bind",{type:"render",value:Yt("PopClip",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushBlend:t=>j(st("Bind",{type:"render",value:Yt("PushBlend",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popBlend:j(st("Bind",{type:"render",value:Yt("PopBlend",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushAlpha:t=>j(st("Bind",{type:"render",value:Yt("PushAlpha",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popAlpha:j(st("Bind",{type:"render",value:Yt("PopAlpha",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushBlur:t=>j(st("Bind",{type:"render",value:Yt("PushBlur",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popBlur:j(st("Bind",{type:"render",value:Yt("PopBlur",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),pushLayer:t=>j(st("Bind",{type:"render",value:Yt("PushLayer",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),popLayer:j(st("Bind",{type:"render",value:Yt("PopLayer",void 0),map:Ce.map},t=>j(st("Return",t),ct)),ct),setViewport:t=>j(st("Bind",{type:"render",value:Yt("SetViewport",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),clearBackground:t=>j(st("Bind",{type:"render",value:Yt("ClearBackground",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),backgroundDots:t=>j(st("Bind",{type:"render",value:Yt("BackgroundDots",t,void 0),map:Ce.map},e=>j(st("Return",e),ct)),ct),measureText:t=>e=>Zo(t)(e),measureInk:t=>e=>UJ(t)(e),insideTokenStyle:t=>j(st("Return",Ag),ct),Monad0:()=>xg},Ar=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Rd=v(xr)(0),Dd=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},lw=v(t=>e=>t+e.len)(0),Fd=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...St(Bt(1,t.length,t))(n=>[2,n.x,n.y]),5];g()},hw=t=>e=>{const n=Ar(e)(Ar(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},pw=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...St(e._1.tail)(n=>[2,n.x,n.y])];g()},yo=t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h};if(t.shape==="Cylinder")return Ed(e);if(t.shape==="Parallelogram")return Ld(e);if(t.shape==="Diamond")return Ad(e);if(t.shape==="Ellipse")return Cd(e);if(t.shape==="Document")return kd(e);if(t.shape==="Cloud")return Bd(e)(7);if(t.shape==="Rectangle")return hw(e)(7);g()},ze=t=>e=>n=>Y(r=>{const o=ot(r)/ot(n);return{x:t.x+(e.x-t.x)*o,y:t.y+(e.y-t.y)*o}})(Ut(0,n-1|0)),mw=t=>{const e=Sn(t.w*.18)(t.h*.6);return[...ze({x:t.x+e,y:t.y})({x:t.x+t.w,y:t.y})(16),...ze({x:t.x+t.w,y:t.y})({x:t.x+t.w-e,y:t.y+t.h})(16),...ze({x:t.x+t.w-e,y:t.y+t.h})({x:t.x,y:t.y+t.h})(16),...ze({x:t.x,y:t.y+t.h})({x:t.x+e,y:t.y})(16)]},Bg=t=>e=>{const n=Ar(t)(Ar(e.w/2)(e.h/2));return{...e,x:e.x+n,y:e.y+n,w:e.w-2*n,h:e.h-2*n}},Rg=t=>e=>{const n=e.y-t.y,r=e.x-t.x;return qe(r*r+n*n)},yw=t=>Oe(e=>n=>({a:e,b:n,len:Rg(e)(n)}),t,Bt(1,t.length,t)),zd=t=>e=>{const n=e.length-1|0,r=n>=0&&n<e.length?w("Just",e[n]):y,o=(()=>{if(r.tag==="Just")return[r._1];if(r.tag==="Nothing")return[];g()})(),i=0<e.length?w("Just",e[0]):y,a=(()=>{if(i.tag==="Just")return i._1;if(i.tag==="Nothing")return{x:0,y:0};g()})(),s=e.length;return s<3?e:[a,...St(Ut(1,s-2|0))(u=>{const c=u+1|0,_=c>=0&&c<e.length?w("Just",e[c]):y,f=u>=0&&u<e.length?w("Just",e[u]):y,l=u-1|0,d=l>=0&&l<e.length?w("Just",e[l]):y;if(d.tag==="Just"&&f.tag==="Just"&&_.tag==="Just"){const h=f._1,m=Rg(h)(_._1),p=Rg(d._1)(h),x=Ar(t)(m/2),J=Ar(t)(p/2),T=m>0?x/m:0,N=h.x+(_._1.x-h.x)*T,k=h.y+(_._1.y-h.y)*T,C=p>0?J/p:0,P=h.x+(d._1.x-h.x)*C,G=h.y+(d._1.y-h.y)*C;return Y(R=>{const U=ot(R)/ot(10),S=1-U;return{x:S*S*P+2*S*U*h.x+U*U*N,y:S*S*G+2*S*U*h.y+U*U*k}})(Ut(0,10))}return[]}),...o]},xw=t=>e=>n=>r=>o=>Y(i=>{const a=ot(i)/ot(o),s=1-a,u=a*a*a,c=3*s*a*a,_=3*s*s*a,f=s*s*s;return{x:f*t.x+_*e.x+c*n.x+u*r.x,y:f*t.y+_*e.y+c*n.y+u*r.y}})(Ut(0,o-1|0)),Jw=t=>[...ze({x:t.x,y:t.y})({x:t.x+t.w,y:t.y})(12),...ze({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h*.85})(12),...xw({x:t.x+t.w,y:t.y+t.h*.85})({x:t.x+t.w*.66,y:t.y+t.h*1.05})({x:t.x+t.w*.34,y:t.y+t.h*.65})({x:t.x,y:t.y+t.h*.85})(32),...ze({x:t.x,y:t.y+t.h*.85})({x:t.x,y:t.y})(12)],Id=t=>e=>Y(n=>{const r=6.283185307179586*ot(n)/ot(64);return{x:t.x+e*yn(r),y:t.y+e*tn(r)}})(Ut(0,63)),Qd=t=>e=>{const n=.5522847498*e;return[1,t.x+e,t.y,4,t.x+e,t.y+n,t.x+n,t.y+e,t.x,t.y+e,4,t.x-n,t.y+e,t.x-e,t.y+n,t.x-e,t.y,4,t.x-e,t.y-n,t.x-n,t.y-e,t.x,t.y-e,4,t.x+n,t.y-e,t.x+e,t.y-n,t.x+e,t.y,5]},ww=t=>{const e=t.y+t.h/2,n=Sn(t.h*.4)(t.w*.2);return[...ze({x:t.x+n,y:t.y})({x:t.x+t.w-n,y:t.y})(10),...ze({x:t.x+t.w-n,y:t.y})({x:t.x+t.w,y:e})(8),...ze({x:t.x+t.w,y:e})({x:t.x+t.w-n,y:t.y+t.h})(8),...ze({x:t.x+t.w-n,y:t.y+t.h})({x:t.x+n,y:t.y+t.h})(10),...ze({x:t.x+n,y:t.y+t.h})({x:t.x,y:e})(8),...ze({x:t.x,y:e})({x:t.x+n,y:t.y})(8)]},Dg=t=>{const e=t.length;return e===0?{x:0,y:0}:{x:Rd(Y(n=>n.x)(t))/ot(e),y:Rd(Y(n=>n.y)(t))/ot(e)}},js=t=>e=>n=>r=>o=>Y(i=>{const a=n+(r-n)*(ot(i)/ot(o));return{x:t.x+e*yn(a),y:t.y+e*tn(a)}})(Ut(0,o-1|0)),Fg=t=>e=>{const n=Ar(t)(Ar(e.w/2)(e.h/2));return[...ze({x:e.x+n,y:e.y})({x:e.x+e.w-n,y:e.y})(6),...js({x:e.x+e.w-n,y:e.y+n})(n)(4.71238898038469)(6.283185307179586)(12),...ze({x:e.x+e.w,y:e.y+n})({x:e.x+e.w,y:e.y+e.h-n})(6),...js({x:e.x+e.w-n,y:e.y+e.h-n})(n)(0)(1.5707963267948966)(12),...ze({x:e.x+e.w-n,y:e.y+e.h})({x:e.x+n,y:e.y+e.h})(6),...js({x:e.x+n,y:e.y+e.h-n})(n)(1.5707963267948966)(3.141592653589793)(12),...ze({x:e.x,y:e.y+e.h-n})({x:e.x,y:e.y+n})(6),...js({x:e.x+n,y:e.y+n})(n)(3.141592653589793)(4.71238898038469)(12)]},tu=t=>e=>n=>r=>o=>i=>Y(a=>{const s=r+(o-r)*(ot(a)/ot(i));return{x:t.x+e*yn(s),y:t.y+n*tn(s)}})(Ut(0,i-1|0)),Tw=t=>{const e=t.h*.38;return[...St(Gd(Pd(Sd)({x:t.x,y:t.y-e,w:t.w,h:e}))(t.y))(n=>{const r=Io(n.p2.y-n.c.cy)(n.p2.x-n.c.cx),o=Io(n.p1.y-n.c.cy)(n.p1.x-n.c.cx);return tu({x:n.c.cx,y:n.c.cy})(n.c.r)(n.c.r)(o)(r>o?r:r+6.283185307179586)(16)}),...ze({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h})(8),...ze({x:t.x+t.w,y:t.y+t.h})({x:t.x,y:t.y+t.h})(12),...ze({x:t.x,y:t.y+t.h})({x:t.x,y:t.y})(8)]},Nw=t=>{const e=Ar(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,o=t.y+t.h+5-e-2,i=t.x+n;return[...tu({x:i,y:r})(n)(e)(3.141592653589793)(6.283185307179586)(24),...ze({x:t.x+t.w,y:r})({x:t.x+t.w,y:o})(12),...tu({x:i,y:o})(n)(e)(0)(3.141592653589793)(24),...ze({x:t.x,y:o})({x:t.x,y:r})(12)]},ni=t=>e=>e.shape==="Cylinder"?Nw(e):e.shape==="Parallelogram"?mw(e):e.shape==="Diamond"?ww(e):e.shape==="Ellipse"?Fg(Sn(e.w)(e.h)/2)(e):e.shape==="Document"?Jw(e):e.shape==="Cloud"?Tw(e):Fg(t)(e),vw=t=>{const e=Ar(t.h*.075)(t.w*.075),n=t.w/2;return tu({x:t.x+n,y:t.y+e})(n)(e)(0)(3.141592653589793)(24)},bw=t=>e=>n=>v(r=>o=>{const i=r.pos+o.len,a=n<i?(n-r.pos)/o.len:1,s={x:o.a.x+(o.b.x-o.a.x)*a,y:o.a.y+(o.b.y-o.a.y)*a},u=e>r.pos?(e-r.pos)/o.len:0,c={x:o.a.x+(o.b.x-o.a.x)*u,y:o.a.y+(o.b.y-o.a.y)*u},_=r.points.length-1|0,f=_>=0&&_<r.points.length?(()=>{const l=r.points[_].x-c.x;return(l<0?-l<1e-4:l<1e-4)&&(()=>{const d=r.points[_].y-c.y;return d<0?-d<1e-4:d<1e-4})()})()?Et(r.points)(s):[...r.points,c,s]:[c,s];return o.len<=0||i<=e||r.pos>=n?{...r,pos:i}:{pos:i,points:f}})({pos:0,points:[]})(t).points,Cw=t=>e=>n=>{const r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),t);if(r.tag==="Nothing")return[];if(r.tag==="Just"){const o=yw(t),i=lw(o),a=Dd(0)(i)(e*i),s=Dd(0)(i)(n*i);return s<=a?[]:bw(o)(a)(s)}g()},Lw=t=>e=>n=>r=>{const o=r.x-n.x,i=r.y-n.y,a=e.x-t.x,s=e.y-t.y,u=n.x-t.x,c=n.y-t.y,_=a*i-s*o,f=(u*i-c*o)/_,l=(u*s-c*a)/_;return(_<0?-_<1e-9:_<1e-9)?y:f>=0&&f<=1&&l>=0&&l<=1?w("Just",f):y},kw=t=>e=>n=>{const r=Pt(o=>i=>at.compare(o.t)(i.t))(ht(o=>{const i=Lw(e)(n)(o._1)(o._2);return i.tag==="Just"?w("Just",{t:i._1,p:{x:e.x+(n.x-e.x)*i._1,y:e.y+(n.y-e.y)*i._1}}):y})(Oe(Cn,t,[...Bt(1,t.length,t),...Bt(0,1,t)])));return 0<r.length?w("Just",r[0].p):y},Md=t=>e=>{const n=Sr(e);if(n.tag==="Nothing")return e;if(n.tag==="Just"){const r=n._1.init.length-1|0;if(r>=0&&r<n._1.init.length){const o=kw(t)(n._1.init[r])(n._1.last);if(o.tag==="Just")return Et(n._1.init)(o._1);if(o.tag==="Nothing")return e;g()}return e}g()},Od=t=>t,eu=(t,e)=>({tag:t,_1:e}),Yi=(t,e,n)=>({tag:t,_1:e,_2:n}),Wd=t=>t,ri=(t,e,n,r,o,i,a,s,u)=>({tag:t,_1:e,_2:n,_3:r,_4:o,_5:i,_6:a,_7:s,_8:u}),zg=Wd("PlopIn"),Sw=Wd("PlopOut"),Ew=Od("DiveIn"),Pw=Od("DiveOut"),Hd=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Xi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Zi=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Ig=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),Gw=t=>e=>{if(e.scene.tag==="Structural")return e.scene._1.to;if(e.scene.tag==="DataFlow")return e.scene._1.keyframe;if(e.scene.tag==="Hold")return e.scene._1;if(e.scene.tag==="EnterNode"||e.scene.tag==="ExitNode"||e.scene.tag==="StepScene")return t;g()},Qg=t=>e=>{const n=Hd(e)(t.keyframes);if(n.tag==="Nothing")return O;if(n.tag==="Just")return n._1.nodes;g()},$d=t=>e=>Xi(e)(t.activePlopOuts)?!0:Xi(e)(t.pastPlopOuts)?!1:Xi(e)(t.activeNodes)?!0:Xi(e)(t.futurePlopIns)?!1:Xi(e)(t.currentNodes),Aw=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n,t),Bw=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopOut"&&r.target._1===n,t),Rw=t=>e=>n=>oe(r=>r.startT>e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopIn"&&r.target._1===n,t),Dw=t=>e=>n=>oe(r=>r.startT>e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"&&r.target._1===n,t),nu=t=>e=>n=>oe(r=>n(r)&&e>=r.startT&&e<r.endT,t),Fw=v(Gw),ji=t=>e=>{if(e<t.startT)return Yi("AtKeyframe",t.initialKeyframe);const n=te(r=>e>=r.startT&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return Yi("InTransition",n._1.scene._1.from,n._1.scene._1.to);if(n._1.scene.tag==="DataFlow")return Yi("AtKeyframe",n._1.scene._1.keyframe);if(n._1.scene.tag==="Hold")return Yi("AtKeyframe",n._1.scene._1);if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode"||n._1.scene.tag==="StepScene")return Yi("AtKeyframe",t.initialKeyframe);g()}if(n.tag==="Nothing")return Yi("AtKeyframe",Fw(t.initialKeyframe)(t.spans));g()},Mg=t=>e=>{const n=Hd(e)(t.keyframes);if(n.tag==="Nothing")return O;if(n.tag==="Just")return n._1.edges;g()},zw=t=>e=>Zi(e)(t.activeRetracts)?!0:Zi(e)(t.pastRetracts)?!1:Zi(e)(t.activeEdges)?!0:Zi(e)(t.futureExtends)?!1:Zi(e)(t.currentEdges),Og=t=>e=>{const n=ji(t)(e);if(n.tag==="AtKeyframe")return Qg(t)(n._1);if(n.tag==="InTransition")return en(B.compare,je,Qg(t)(n._1),Qg(t)(n._2));g()},qd=t=>e=>n=>nu(t.windows)(e)(r=>r.target.tag==="NodeWindow"&&r.target._1===n&&r.target._2==="PlopOut")?!0:Bw(t.windows)(e)(n)?!1:nu(t.windows)(e)(r=>r.target.tag==="NodeWindow"&&r.target._1===n)?!0:Rw(t.windows)(e)(n)?!1:Xi(n)(Og(t)(e)),Wg=t=>e=>{const n=ji(t)(e);if(n.tag==="AtKeyframe")return Mg(t)(n._1);if(n.tag==="InTransition")return en(B.compare,je,Mg(t)(n._1),Mg(t)(n._2));g()},Iw=t=>e=>n=>nu(t.windows)(e)(r=>r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n)?!0:Aw(t.windows)(e)(n)?!1:nu(t.windows)(e)(r=>r.target.tag==="EdgeWindow"&&r.target._1===n)?!0:Dw(t.windows)(e)(n)?!1:Zi(n)(Wg(t)(e)),Vd=t=>e=>v(n=>r=>{const o=e>=r.startT&&e<r.endT;return r.target.tag==="NodeWindow"?{...n,activeNodes:o?it(B)(r.target._1)()(n.activeNodes):n.activeNodes,activePlopOuts:o&&r.target._2==="PlopOut"?it(B)(r.target._1)()(n.activePlopOuts):n.activePlopOuts,pastPlopOuts:r.endT<=e&&r.target._2==="PlopOut"?it(B)(r.target._1)()(n.pastPlopOuts):n.pastPlopOuts,futurePlopIns:r.startT>e&&r.target._2==="PlopIn"?it(B)(r.target._1)()(n.futurePlopIns):n.futurePlopIns}:r.target.tag==="EdgeWindow"?{...n,activeEdges:o?it(B)(r.target._1)()(n.activeEdges):n.activeEdges,activeRetracts:o&&r.target._2.tag==="Retract"?it(B)(r.target._1)()(n.activeRetracts):n.activeRetracts,pastRetracts:r.endT<=e&&r.target._2.tag==="Retract"?it(B)(r.target._1)()(n.pastRetracts):n.pastRetracts,futureExtends:r.startT>e&&r.target._2.tag==="Extend"?it(B)(r.target._1)()(n.futureExtends):n.futureExtends}:n})({currentNodes:Og(t)(e),currentEdges:Wg(t)(e),activeNodes:O,activePlopOuts:O,pastPlopOuts:O,futurePlopIns:O,activeEdges:O,activeRetracts:O,pastRetracts:O,futureExtends:O})(t.windows),Qw=t=>e=>{const n=Vd(t)(e);return ht(r=>$d(n)(r._1)?w("Just",{x:r._2.x,y:r._2.y,w:r._2.w,h:r._2.h}):y)(Ig(t.layout.nodes))},Mw=t=>e=>{const n=Qw(t)(e);return n.length===0?y:w("Just",ae(n))},Da=t=>e=>{const n=Vd(t)(e),r=[...ht(o=>$d(n)(o._1)?w("Just",{x:o._2.x,y:o._2.y,w:o._2.w,h:o._2.h}):y)(Ig(t.layout.nodes)),...ht(o=>zw(n)(o._1)?w("Just",Ga(o._2)):y)(Ig(t.layout.edges))];return r.length===0?y:w("Just",ae(r))},Ow=t=>e=>e.map(t),ne=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},rn=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},Ye=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Ww=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},En=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},xo=Ts(Fi),oi=t=>t,Ud=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Jr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Hw=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),$w=t=>e=>rn(0)(1)((t-e.pre)/ne(.05)(1-e.pre-e.post)),Kd=t=>e=>n=>{const r=Ye(n)(t.nodes),o=Ye(e)(t.nodes);if(o.tag==="Just"&&r.tag==="Just"){const i=r._1.x+r._1.w/2-(o._1.x+o._1.w/2),a=r._1.y+r._1.h/2-(o._1.y+o._1.h/2),s=ne(xe(i))(xe(a));return s<=.001?{x:0,y:0}:{x:i/s,y:a/s}}return{x:0,y:0}},Hg=t=>e=>n=>r=>o=>i=>{const a=s=>{if(s)return 0<e.length?e[0]:{x:0,y:0};const u=e.length-1|0;return u>=0&&u<e.length?e[u]:{x:0,y:0}};return mJ(e)((()=>{const s=a(!0),u=Ye(n)(t.nodes);return u.tag==="Just"?{x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2}:s})())((()=>{const s=a(!1),u=Ye(r)(t.nodes);return u.tag==="Just"?{x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2}:s})())(o)(i)},qw=t=>e=>t.labelBasePx*.62*ot(v(Ww)(0)(Y(_J)(St(e)(n=>$i(`
6
+ `)(n))))),ru=t=>e=>n=>rn(0)(1)((n-t)/ne(1e-4)(e-t)),Vw=t=>e=>ot(Dn(lr(e)))*t*.62,Yd=t=>e=>n=>{const r=(t+e)/2,o=n-r,i=o<0?-1:1,a=(e-t)/2,s=a*.15,u=a-s,c=o<0?-o:o;return e<=t?(t+e)/2:c<=u?n:r+i*(a-s*uo(-(c-u)/s))},$g=t=>e=>n=>({...n,center:{x:e.w>t.w?n.center.x+(e.x+e.w/2-(t.x+t.w/2)):e.x<t.x?n.center.x+(e.x-t.x):e.x+e.w>t.x+t.w?n.center.x+(e.x+e.w-t.x-t.w):n.center.x+0,y:e.h>t.h?n.center.y+(e.y+e.h/2-(t.y+t.h/2)):e.y<t.y?n.center.y+(e.y-t.y):e.y+e.h>t.y+t.h?n.center.y+(e.y+e.h-t.y-t.h):n.center.y+0}}),Fa=t=>e=>n=>r=>{const o=te(i=>xo(i.path)(e)&&(xe(i.endT-n)<1e-4||xe(i.startT-r)<1e-4))(t.segments);if(o.tag==="Just")return w("Just",o._1);if(o.tag==="Nothing")return te(i=>xo(i.path)(e))(t.segments);g()},Uw=t=>ht(e=>{const n=Mw(t)(ne(e.startT)(e.endT-1e-4));if(n.tag==="Nothing")return y;if(n.tag==="Just")return w("Just",{startT:e.startT,endT:e.endT,bbox:n._1,priority:0,continuous:!1,stationary:!1});g()}),Kw=t=>e=>{const n=yg({width:t.widthPx,height:t.heightPx})({vx:e.bounds.x,vy:e.bounds.y,vw:e.bounds.w,vh:e.bounds.h});return{w:n.vw,h:n.vh}},Yw=t=>e=>n=>r=>{const o=ne(n.center.x-r.x)(r.x+r.w-n.center.x),i=ne(n.center.y-r.y)(r.y+r.h-n.center.y),a=Kw(t)(e);return En(o<=0?n.zoom:a.w/(o*2))(i<=0?n.zoom:a.h/(i*2))},Xd=t=>e=>n=>r=>o=>{const i=(s,u)=>{const c=Fn(u);return Ln(Mt(_=>f=>{const l=t*1.2,d=s.y+s.h/2-ot(c.length)*l/2+ot(_)*l;return v(h=>m=>{const p=ot(Dn(lr(m.text)))*t*.62;return{x:h.x+p,boxes:m.style==="RunHighlight"||m.style==="RunCodeHighlight"?Et(h.boxes)({x:h.x,y:d,w:p,h:l}):h.boxes}})({x:s.x+s.w/2-ot(Dn(lr(f)))*t*.62/2,boxes:[]})(dr(f)).boxes})(c))},a=Ye(n)(e.layout.nodes);if(a.tag==="Just"){const s=[...i(a._1,r),...i(a._1,o)];return s.length===0?y:w("Just",ae(s))}if(a.tag==="Nothing")return y;g()},qg=t=>e=>n=>{const r=Fn(n),o=v(ne)(t)(Y(Vw(t))(r)),i=ne(t)(ot(r.length)*t*1.2);return w("Just",{x:e.x+e.w/2-o/2,y:e.y+e.h/2-i/2,w:o,h:i})},Xw=t=>e=>n=>r=>{const o=v(ne)(r.startT-t.maxTransition)(ht(i=>i.startT>r.startT+1e-4?y:i.target.tag==="NodeWindow"&&i.target._2==="PlopIn"&&i.target._1===r.target?w("Just",i.startT):y)(e.windows));return rn(0)(1)((n-o)/ne(1e-4)(r.startT-o))},Zd=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),ht(oi)(t));if(e.tag==="Nothing")return y;if(e.tag==="Just")return w("Just",v(n=>r=>({whole:ae([n.whole,r.whole]),text:(()=>{if(n.text.tag==="Just"){if(r.text.tag==="Just")return w("Just",ae([n.text._1,r.text._1]));if(r.text.tag==="Nothing")return w("Just",n.text._1);g()}if(n.text.tag==="Nothing"){if(r.text.tag==="Just")return w("Just",r.text._1);if(r.text.tag==="Nothing")return y}g()})(),guide:(()=>{if(n.guide.tag==="Just"){if(r.guide.tag==="Just")return w("Just",ae([n.guide._1,r.guide._1]));if(r.guide.tag==="Nothing")return w("Just",n.guide._1);g()}if(n.guide.tag==="Nothing"){if(r.guide.tag==="Just")return w("Just",r.guide._1);if(r.guide.tag==="Nothing")return y}g()})()}))(e._1.head)(e._1.tail));g()},Zw=t=>e=>n=>r=>({...r,fromCam:gg(t)(e)(n)(r.fromCam),toCam:gg(t)(e)(n)(r.toCam)}),jw=t=>e=>n=>r=>o=>i=>a=>{const s=a*a*(3-2*a),u=Kd(t)(e)(n),c=(()=>{if(r)return 1;const f=rn(0)(1)(i/.12);return f*f*(3-2*f)})(),_={x:0+(u.x-0)*c,y:0+(u.y-0)*c};if(o.tag==="Just"){const f=Kd(t)(o._1.source)(o._1.target);return{x:_.x+(f.x-_.x)*s,y:_.y+(f.y-_.y)*s}}if(o.tag==="Nothing")return _;g()},tT=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="RelabelWindow"&&r.target._1===n,t),eT=t=>e=>n=>{const r=Ye(n)(t.layout.nodes),o=r.tag==="Just"&&r._1.label!==""?r._1.label:n,i=ji(t)(e),a=(()=>{if(i.tag==="AtKeyframe")return Ud(i._1)(t.keyframes);if(i.tag==="InTransition")return Ud(tT(t.windows)(e)(n)?i._2:i._1)(t.keyframes);g()})(),s=(()=>{if(a.tag==="Just")return Ye(n)(a._1.labels);if(a.tag==="Nothing")return y;g()})();if(s.tag==="Nothing")return o;if(s.tag==="Just")return s._1;g()},ou=t=>e=>n=>r=>{const o=Ye(r)(e.layout.nodes);if(o.tag==="Just")return qg(t)(o._1)(eT(e)(n)(r));if(o.tag==="Nothing")return y;g()},nT=t=>e=>n=>{if(e.length===0)return n;const r=En(160)(qw(t)(e)+32)/2;return{x:n.x-r,y:n.y-30.6,w:n.w+r+r,h:n.h+40.6}},ii=t=>e=>n=>r=>o=>{const i={width:e.widthPx,height:e.heightPx},a=yg(i)((()=>{if(r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0){const s=gr(n)(o);return{vx:s.x-t.padding,vy:s.y-t.padding,vw:s.w+t.padding*2,vh:s.h+t.padding*2}}return{vx:gr(n)(o).x,vy:gr(n)(o).y,vw:gr(n)(o).w,vh:gr(n)(o).h}})());return t.labelBasePx*r.placement.scale*(i.width<=0||a.vw<=0?0:i.width/a.vw)},jd=t=>e=>n=>r=>(o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s,l=ii(t)(e)(n)(r)(f);if(e.widthPx<=0||e.heightPx<=0||l<=0||l>=t.minimumReadableLabelPx){u=!1,c=f;continue}if(_<=0){u=!1,c=f;continue}a=_-1|0,s={...f,zoom:f.zoom*t.minimumReadableLabelPx/l}}return c})(8),fn=t=>e=>n=>r=>{const o=yg({width:t.widthPx,height:t.heightPx})((()=>{const i=gr(n)(r);return{vx:i.x-e,vy:i.y-e,vw:i.w+e*2,vh:i.h+e*2}})());return{x:o.vx,y:o.vy,w:o.vw,h:o.vh}},rT=t=>e=>n=>r=>{const o=Ye(e)(t.nodes);if(o.tag==="Just"){const i=o._1.x+o._1.w/2,a=o._1.y+o._1.h/2,s=Ye(n)(t.nodes);if(s.tag==="Just")return w("Just",{x:i+(s._1.x+s._1.w/2-i)*r-6,y:a+(s._1.y+s._1.h/2-a)*r-6,w:12,h:12})}return y},Vg=t=>e=>n=>r=>o=>i=>{const a=Y((()=>{const s=t.padding;return u=>({x:u.x-s,y:u.y-s,w:u.w+s*2,h:u.h+s*2})})())(ht(ou(t.labelBasePx)(e)(n))([r,o]));return a.length===0?i:ae([i,...a])},oT=t=>e=>n=>r=>o=>i=>a=>s=>{const u=Vg(t)(e)(n)(r)(o)(s);if(i.tag==="Nothing")return u;if(i.tag==="Just"){const c=Vg(t)(e)(n)(i._1.source)(i._1.target)(s),_=a*a*(3-2*a);return{x:u.x+(c.x-u.x)*_,y:u.y+(c.y-u.y)*_,w:u.w+(c.w-u.w)*_,h:u.h+(c.h-u.h)*_}}g()},tl=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>{const _=i.x-6,f=i.y-6;return w("Just",{visibleBounds:(()=>{const l=Da(e)(n);return l.tag==="Just"?w("Just",{x:l._1.x*e.placement.scale+e.placement.tx,y:l._1.y*e.placement.scale+e.placement.ty,w:l._1.w*e.placement.scale,h:l._1.h*e.placement.scale}):y})(),subject:w("Just",{x:_*e.placement.scale+e.placement.tx,y:f*e.placement.scale+e.placement.ty,w:12*e.placement.scale,h:12*e.placement.scale}),guide:(()=>{const l=rT(e.layout)(r)(o)(a);return l.tag==="Just"?w("Just",{x:l._1.x*e.placement.scale+e.placement.tx,y:l._1.y*e.placement.scale+e.placement.ty,w:l._1.w*e.placement.scale,h:l._1.h*e.placement.scale}):y})(),mustSee:w("Just",(()=>{const l=oT(t)(e)(n)(r)(o)(c)(s)({x:_-t.padding,y:f-t.padding,w:12+t.padding*2,h:12+t.padding*2});return{x:l.x*e.placement.scale+e.placement.tx,y:l.y*e.placement.scale+e.placement.ty,w:l.w*e.placement.scale,h:l.h*e.placement.scale}})()),lookAhead:w("Just",jw(e.layout)(r)(o)(u)(c)(a)(s))})},iu=t=>e=>n=>r=>o=>i=>{const a=Vg(t)(e)(n)(r)(o)(i);return{x:a.x,y:i.y,w:a.w,h:i.h}},iT=t=>e=>n=>r=>o=>i=>a=>s=>{let u=t,c=e,_=n,f=r,l=o,d=i,h=a,m=s,p=!0,x;for(;p;){const J=u,T=c,N=_,k=f,C=l,P=d,G=h,R=m,U=N.path.length!==0,S=fn(J)(N.path.length===0||N.placement.scale===1&&N.placement.tx===0&&N.placement.ty===0?k.padding:0)(T)(R),b=ne(P)(R.zoom*En(S.w/ne(1e-4)(C.w))(S.h/ne(1e-4)(C.h)));if(G<=0){p=!1,x=R;continue}if(U&&xe(b-R.zoom)<1e-6){p=!1,x=R;continue}if(U){u=J,c=T,_=N,f=k,l=C,d=P,h=G-1|0,m={...R,zoom:b};continue}if(C.w<=S.w+.001&&C.h<=S.h+.001){p=!1,x=R;continue}if(b>=R.zoom-1e-6){p=!1,x=R;continue}u=J,c=T,_=N,f=k,l=C,d=P,h=G-1|0,m={...R,zoom:b}}return x},aT=t=>e=>n=>r=>{const o=Jr(r)(e.edgeEndpoints),i=Jr(r)(e.layout.edges);if(i.tag==="Just"&&o.tag==="Just"){const a=$o(e.layout)(e.edgeEndpoints)(r),s=iu(t)(e)(n)(o._1.source)(o._1.target)(Ga(i._1));return{x:s.x,y:a.y,w:s.w,h:a.h}}return $o(e.layout)(e.edgeEndpoints)(r)},el=t=>e=>n=>r=>{const o=zd(8)(t);if(n==="ExtendFromSource")return{path:o,source:e.source,target:e.target,progress:rn(0)(1)(r)};if(n==="ExtendFromTarget")return{path:re(o),source:e.target,target:e.source,progress:rn(0)(1)(r)};g()},sT=t=>e=>n=>r=>o=>i=>{const a=t.padding*.75,s=ot(48),u=o.layout;return Ns(c=>{if(c.target.tag==="NodeWindow")return[];if(c.target.tag==="RelabelWindow")return[(()=>{const _=ag(u)(i)(ee("Node",1,1,c.target._1,void 0,O,O));return{startT:c.startT,endT:c.endT,bbox:(()=>{const f=Xd(t.labelBasePx)(o)(c.target._1)(c.target._2)(c.target._3);if(f.tag==="Nothing")return _;if(f.tag==="Just")return f._1;g()})(),priority:1,continuous:!1,stationary:!1}})()];if(c.target.tag==="EdgeWindow"){if(c.target._2.tag==="Extend"){const _=Jr(c.target._1)(i),f=Jr(c.target._1)(u.edges);if(f.tag==="Just"&&_.tag==="Just"){const l=_._1,d=f._1;return St(Ut(0,47))(h=>{const m=c.startT+(c.endT-c.startT)*(ot(h)/s),p=c.startT+(c.endT-c.startT)*(ot(h+1|0)/s),x=el(d)(l)(c.target._2._1)(Hi(r)(((m+p)/2-c.startT)/ne(1e-4)(c.endT-c.startT))),J=0<x.path.length?x.path[0]:{x:0,y:0},T=Yo(x.path)(x.progress),N=(()=>{if(T.tag==="Nothing")return J;if(T.tag==="Just")return T._1;g()})();return[{startT:m,endT:p,bbox:iu(t)(o)((m+p)/2)(x.source)(x.target)({x:N.x-6,y:N.y-6,w:12,h:12}),priority:1,continuous:!0,stationary:!1}]})}return[{startT:c.startT,endT:c.endT,bbox:$o(u)(i)(c.target._1),priority:1,continuous:!1,stationary:!1}]}if(c.target._2.tag==="Retract")return[];g()}if(c.target.tag==="TokenWindow"){if(e.widthPx>=e.heightPx*1.5&&o.path.length===0)return[{startT:c.startT,endT:c.endT,bbox:iu(t)(o)((c.startT+c.endT)/2)(c.target._4)(c.target._5)((()=>{const f=ht(l=>{const d=Ye(l)(u.nodes);return d.tag==="Just"?w("Just",{x:d._1.x,y:d._1.y,w:d._1.w,h:d._1.h}):y})([c.target._4,c.target._5]);return f.length===0?$o(u)(i)(c.target._2):ae(f)})()),priority:1,continuous:!1,stationary:!1}];const _=Jr(c.target._2)(u.edges);if(_.tag==="Just"){const f=(()=>{if(c.target._3==="Forward")return _._1;if(c.target._3==="Backward")return re(_._1);g()})(),l=St(Ut(0,47))(h=>{const m=c.startT+(c.endT-c.startT)*(ot(h)/s),p=c.startT+(c.endT-c.startT)*(ot(h+1|0)/s),x=Hg(u)(f)(c.target._4)(c.target._5)(((m+p)/2-c.startT)/ne(1e-4)(c.endT-c.startT))({pre:c.target._7,post:c.target._8});return[{startT:m,endT:p,bbox:iu(t)(o)((m+p)/2)(c.target._4)(c.target._5)({x:x.x-a,y:x.y-a,w:0+a*2,h:0+a*2}),priority:1,continuous:!0,stationary:!1}]}),d=ae(Y(h=>h.bbox)(l));return(()=>{const h=gg(n)(u)(o.placement)(bf(t)(e)(u)(d).camera),m=fn(e)(o.path.length===0||o.placement.scale===1&&o.placement.tx===0&&o.placement.ty===0?t.padding:0)(n)(h);return ii(t)(e)(n)(o)(h)>=t.minimumReadableLabelPx-.001&&(()=>{const p=d.x*o.placement.scale+o.placement.tx,x=d.y*o.placement.scale+o.placement.ty;return p>=m.x-.001&&x>=m.y-.001&&p+d.w*o.placement.scale<=m.x+m.w+.001&&x+d.h*o.placement.scale<=m.y+m.h+.001})()})()?[{startT:c.startT,endT:c.endT,bbox:d,priority:1,continuous:!1,stationary:!0}]:l}if(_.tag==="Nothing")return[{startT:c.startT,endT:c.endT,bbox:$o(u)(i)(c.target._2),priority:1,continuous:!1,stationary:!1}];g()}if(c.target.tag==="FillWindow")return[{startT:c.startT,endT:c.endT,bbox:nT(t)(c.target._3)(ag(u)(i)(ee("Node",1,1,c.target._2,void 0,O,O))),priority:1,continuous:!1,stationary:!1}];g()})},uT=t=>e=>n=>r=>o=>i=>a=>s=>[...Uw(s)(_t(u=>u.startT>=s.startT&&u.endT<=s.endT,a.spans)),...sT(t)(e)(n)(r)(s)(i)(s.windows)],cT=t=>e=>n=>r=>o=>i=>a=>s=>tJ(t)(e)(s.layout)(a.endT)(ht(u=>u.scene.tag==="StepScene"?w("Just",u.startT):y)(s.spans))(uT(t)(e)(n)(r)(o)(i)(a)(s)),nl=t=>e=>(()=>{if(e.subject.tag==="Nothing")return!0;if(e.subject.tag==="Just")return e.subject._1.x>=t.x&&e.subject._1.y>=t.y&&e.subject._1.x+e.subject._1.w<=t.x+t.w&&e.subject._1.y+e.subject._1.h<=t.y+t.h;g()})()&&(()=>{if(e.mustSee.tag==="Nothing")return!0;if(e.mustSee.tag==="Just")return e.mustSee._1.x>=t.x&&e.mustSee._1.y>=t.y&&e.mustSee._1.x+e.mustSee._1.w<=t.x+t.w&&e.mustSee._1.y+e.mustSee._1.h<=t.y+t.h;g()})(),rl=t=>e=>n=>r=>n>=e?rn(t+e-n/2)(t+n/2)(r):t+e/2,ol=t=>e=>n=>r=>{if((()=>{const a=gr(e)(n);return r.x>=a.x&&r.y>=a.y&&r.x+r.w<=a.x+a.w&&r.y+r.h<=a.y+a.h})())return n;const o={...n,zoom:En(n.zoom)(Yw(t)(e)({...n,center:{x:r.x+r.w/2,y:r.y+r.h/2}})(r))},i=gr(e)(o);return{...o,center:{x:rl(r.x)(r.w)(i.w)(n.center.x),y:rl(r.y)(r.h)(i.h)(n.center.y)}}},gT=t=>e=>n=>{const r=t.x+t.w/2,o=n>=t.w?{lo:r,hi:r}:{lo:t.x+n/2,hi:t.x+t.w-n/2};if(n>=e.w){const u=ne(o.lo)(e.x+e.w-n/2),c=En(o.hi)(e.x+n/2);return u<=c?{lo:u,hi:c}:o}const i=e.x+e.w/2;if(n>=e.w){const u=ne(o.lo)(i),c=En(o.hi)(i);return u<=c?{lo:u,hi:c}:o}const a=ne(o.lo)(e.x+n/2),s=En(o.hi)(e.x+e.w-n/2);return a<=s?{lo:a,hi:s}:o},au=t=>e=>{if(t.tag==="Just"){if(e.tag==="Just")return w("Just",ae([t._1,e._1]));if(e.tag==="Nothing")return w("Just",t._1);g()}if(t.tag==="Nothing"){if(e.tag==="Just")return w("Just",e._1);if(e.tag==="Nothing")return y}g()},_T=t=>e=>n=>n.endT<=t||n.startT>=e?y:w("Just",{...n,startT:ne(t)(n.startT),endT:En(e)(n.endT)}),fT=t=>e=>n=>r=>o=>i=>a=>ht(_T(a.startT)(a.endT))(Y(Zw(r)(a.layout)(a.placement))(cT(t)(e)(r)(n)(o)(a.edgeEndpoints)(i)(a))),dT=t=>e=>n=>r=>{const o=En(r.zoom)(t.bounds.w/ne(1e-4)(e.w));return{...r,center:{...r.center,x:(()=>{const i=gT(t.bounds)(e)(t.bounds.w/ne(1e-4)(o));return rn(i.lo)(i.hi)(n.center.x)})()},zoom:o}},lT=t=>e=>n=>{const r=t.bounds.h/ne(1e-4)(n.zoom),o=t.bounds.w/ne(1e-4)(n.zoom);return{...n,center:{x:o>=e.w?e.x+e.w/2:Yd(e.x+o/2)(e.x+e.w-o/2)(n.center.x),y:r>=e.h?e.y+e.h/2:Yd(e.y+r/2)(e.y+e.h-r/2)(n.center.y)}}},ta=t=>e=>n=>lT(t)((()=>{const r=e*n.placement.scale;return{x:n.layout.bounds.x*n.placement.scale+n.placement.tx-r,y:n.layout.bounds.y*n.placement.scale+n.placement.ty-r,w:n.layout.bounds.w*n.placement.scale+r*2,h:n.layout.bounds.h*n.placement.scale+r*2}})()),hT=t=>e=>n=>r=>{const o=gr(t)(r),i=t.bounds,a=s=>{const u=ta(t)(e)(n)(s);return ta(t)(e)(n)({...u,zoom:ne(u.zoom)(ne(i.w/ne(1e-4)(2*En(u.center.x-o.x)(o.x+o.w-u.center.x)))(i.h/ne(1e-4)(2*En(u.center.y-o.y)(o.y+o.h-u.center.y))))})};return s=>a(a(s))},pT=t=>e=>n=>r=>ta(n)(t.padding)(r)(Uy(t)(e)(n)(r.placement)(r.layout.bounds).camera),mT=t=>e=>n=>r=>o=>{const i=pT(t)(e)(n)(o),a=te(s=>s.direction==="DiveIn"&&xo(s.childPath)(o.path))(r.dives);if(a.tag==="Just"){const s=Fa(r)(a._1.parentPath)(a._1.startT)(a._1.endT);if(s.tag==="Just"){const u=Ye(a._1.node)(s._1.layout.nodes);if(u.tag==="Just"){const c=u._1.w*s._1.placement.scale,_=u._1.h*s._1.placement.scale,f=En(c)(_*2),l=Ky(e)(n)({h:_,w:f,x:u._1.x*s._1.placement.scale+s._1.placement.tx+(c-f)*.5,y:u._1.y*s._1.placement.scale+s._1.placement.ty});return hT(n)(t.padding)(o)(l)(l.zoom>i.zoom?l:i)}if(u.tag==="Nothing")return i;g()}if(s.tag==="Nothing")return i;g()}if(a.tag==="Nothing")return i;g()},ea=t=>e=>n=>r=>o=>i=>{if(r.direction==="DiveIn"){const a=ta(n)(t.padding)(o)(Ko(t)(n)(i)(r.startT-1e-4).camera),s=jd(t)(e)(n)(o)(a),u=Ye(r.node)(o.layout.nodes);return r.direction==="DiveIn"&&u.tag==="Just"?ol(e)(n)(s)({x:u._1.x*o.placement.scale+o.placement.tx+u._1.w*o.placement.scale/2-.5,y:u._1.y*o.placement.scale+o.placement.ty+u._1.h*o.placement.scale/2-.5,w:1,h:1}):a}if(r.direction==="DiveOut"){const a=ta(n)(t.padding)(o)(Ko(t)(n)(i)(r.endT+1e-4).camera),s=jd(t)(e)(n)(o)(a),u=Ye(r.node)(o.layout.nodes);return r.direction==="DiveIn"&&u.tag==="Just"?ol(e)(n)(s)({x:u._1.x*o.placement.scale+o.placement.tx+u._1.w*o.placement.scale/2-.5,y:u._1.y*o.placement.scale+o.placement.ty+u._1.h*o.placement.scale/2-.5,w:1,h:1}):a}g()},yT=t=>t.target.tag==="NodeWindow"||t.target.tag==="RelabelWindow"||t.target.tag==="EdgeWindow"||t.target.tag==="TokenWindow"||t.target.tag==="FillWindow",il=t=>Pt(at.compare)($r(at.compare)(St(_t(yT,t.windows))(e=>[e.startT,e.endT]))),al=t=>e=>n=>r=>o=>i=>{if(o.tag==="Just"){if(i.tag==="Just"){const a=ae([o._1,i._1]);return r<e?w("Just",(()=>{const s=ru(t)(e)(r);return{x:o._1.x+(a.x-o._1.x)*s,y:o._1.y+(a.y-o._1.y)*s,w:o._1.w+(a.w-o._1.w)*s,h:o._1.h+(a.h-o._1.h)*s}})()):w("Just",(()=>{const s=ru(e)(n)(r);return{x:a.x+(i._1.x-a.x)*s,y:a.y+(i._1.y-a.y)*s,w:a.w+(i._1.w-a.w)*s,h:a.h+(i._1.h-a.h)*s}})())}if(i.tag==="Nothing")return w("Just",(()=>{const a=ru(t)(n)(r);return{x:o._1.x+(o._1.x+o._1.w/2-o._1.x)*a,y:o._1.y+(o._1.y+o._1.h/2-o._1.y)*a,w:o._1.w+-o._1.w*a,h:o._1.h+-o._1.h*a}})());g()}if(o.tag==="Nothing"){if(i.tag==="Just")return w("Just",(()=>{const a=i._1.x+i._1.w/2,s=i._1.y+i._1.h/2,u=ru(t)(n)(r);return{x:a+(i._1.x-a)*u,y:s+(i._1.y-s)*u,w:0+(i._1.w-0)*u,h:0+(i._1.h-0)*u}})());if(i.tag==="Nothing")return y}g()},sl=t=>e=>n=>r=>{const o=r.path.length===0?t.minimumReadableLabelPx*1:t.minimumReadableLabelPx*1.8;return(i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u,d=ii(t)(e)(n)(r)(l);if(f<=0){c=!1,_=l.zoom;continue}if(e.widthPx<=0||e.heightPx<=0){c=!1,_=l.zoom;continue}if(d<=0){c=!1,_=l.zoom;continue}if(xe(d-o)<.001){c=!1,_=l.zoom;continue}s=f-1|0,u={...l,zoom:l.zoom*o/d}}return _})(12)({center:(()=>{const i=t.padding*r.placement.scale;return{x:r.layout.bounds.x*r.placement.scale+r.placement.tx-i+(r.layout.bounds.w*r.placement.scale+i*2)/2,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-i+(r.layout.bounds.h*r.placement.scale+i*2)/2}})(),zoom:1})},Ug=t=>e=>n=>r=>o=>{const i=fn(t)(e)(n)(o);return{...o,center:{x:i.w>r.w+ne(1)(xe(r.w))*1e-9?o.center.x+(r.x+r.w/2-(i.x+i.w/2)):i.x<r.x?o.center.x+(r.x-i.x):i.x+i.w>r.x+r.w?o.center.x+(r.x+r.w-i.x-i.w):o.center.x+0,y:i.h>r.h+ne(1)(xe(r.h))*1e-9?o.center.y+(r.y+r.h/2-(i.y+i.h/2)):i.y<r.y?o.center.y+(r.y-i.y):i.y+i.h>r.y+r.h?o.center.y+(r.y+r.h-i.y-i.h):o.center.y+0}}},xT=t=>e=>n=>r=>Ug(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)((()=>{const o=t.padding*r.placement.scale;return{x:r.layout.bounds.x*r.placement.scale+r.placement.tx-o,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-o,w:r.layout.bounds.w*r.placement.scale+o*2,h:r.layout.bounds.h*r.placement.scale+o*2}})()),Jo=t=>e=>n=>r=>o=>i=>{const a=sl(t)(e)(n)(r),s=(()=>{if(r.path.length===0)return{x:n.bounds.x-t.padding,y:n.bounds.y-t.padding,w:n.bounds.w+t.padding*2,h:n.bounds.h+t.padding*2};const m=t.padding*r.placement.scale;return{x:r.layout.bounds.x*r.placement.scale+r.placement.tx-m,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-m,w:r.layout.bounds.w*r.placement.scale+m*2,h:r.layout.bounds.h*r.placement.scale+m*2}})(),u=r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0,c=r.path.length!==0,_=r.path.length===0?a:0,f=Ug(e)(u)(n)(s)({...i,zoom:ne(a)(i.zoom)}),l=fn(e)(u)(n)(f),d=(()=>{if(o.tag==="Nothing")return f;if(o.tag==="Just")return iT(e)(n)(r)(t)(o._1)(_)(12)(f);g()})(),h=fn(e)(u)(n)(d);if(o.tag==="Nothing")return f;if(o.tag==="Just")return c?$g(h)(o._1)(d):o._1.x>=l.x-.001&&o._1.y>=l.y-.001&&o._1.x+o._1.w<=l.x+l.w+.001&&o._1.y+o._1.h<=l.y+l.h+.001?f:o._1.w<=h.w+.001&&o._1.h<=h.h+.001?$g(h)(o._1)(d):Ug(e)(u)(n)(ae([s,o._1]))($g(h)(o._1)(d));g()},JT=t=>e=>n=>r=>o=>i=>a=>{const s=t.padding*r.placement.scale,u={x:r.layout.bounds.x*r.placement.scale+r.placement.tx-s,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-s,w:r.layout.bounds.w*r.placement.scale+s*2,h:r.layout.bounds.h*r.placement.scale+s*2},c=x=>nl(fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(x))(i),_=x=>J=>T=>N=>{let k=x,C=J,P=T,G=N,R=!0,U;for(;R;){const S=k,b=C,I=P,H=G;if(S<=0){R=!1,U=H;continue}const Q={...o,zoom:(b+I)/2},q=fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(Q),$={...Q,center:pg(hg)(u)({w:q.w,h:q.h})(o.center)(i)};if(c($)){k=S-1|0,C=$.zoom,P=I,G=$;continue}k=S-1|0,C=b,P=$.zoom,G=H}return U},f=fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(a),l=fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(o),d=ii(t)(e)(n)(r)(o)>=t.minimumReadableLabelPx-.001,h={...o,center:pg(hg)(u)({w:l.w,h:l.h})(o.center)(i)},m=nl(fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)(h))(i),p={...a,center:pg(hg)(u)({w:f.w,h:f.h})(o.center)(i)};return p.zoom>h.zoom&&c(p)?p:d&&m?h:p.zoom>=h.zoom||!c(p)?p:_(12)(p.zoom)(o.zoom)(p)},wT=t=>Y(e=>{const n=te(i=>e.startT<i.startT&&e.endT>=i.startT-1e-4)(t),r=(()=>{if(n.tag==="Just")return{...e,endT:n._1.startT,toCam:n._1.fromCam,easing:_r,interp:Vo,intent:Mf};if(n.tag==="Nothing")return e;g()})(),o=te(i=>r.startT<=i.endT+1e-4&&r.endT>i.endT)(t);if(o.tag==="Just")return{...r,startT:o._1.endT,fromCam:o._1.toCam,easing:_r,interp:Vo,intent:Mf};if(o.tag==="Nothing")return r;g()}),TT=t=>e=>n=>r=>o=>i=>a=>{const s=r.layout.bounds.w*r.placement.scale,u=s/ne(1e-4)(r.layout.bounds.h*r.placement.scale);if(o.tag==="Nothing")return a;if(o.tag==="Just"){const c=dT(n)(o._1)(i)(a);return ii(t)(e)(n)(r)(c)>=t.minimumReadableLabelPx-.001||o._1.w>=s-.001&&u>=.33&&ii(t)(e)(n)(r)(c)>=t.minimumReadableLabelPx*1?c:a}g()},NT=t=>e=>n=>{const r=Pt(o=>i=>at.compare(o.startT)(i.startT))(_t(o=>o.startT>=e.endT-1e-4&&o.startT-e.endT<=1.1001&&o.target.tag==="TokenWindow",t.windows));return 0<r.length&&r[0].target.tag==="TokenWindow"&&r[0].target._4===n?w("Just",{source:r[0].target._4,target:r[0].target._5,startT:r[0].startT}):y},vT=t=>e=>n=>{const r=Pt(i=>a=>at.compare(i.endT)(a.endT))(_t(i=>i.endT<=e.startT+1e-4&&e.startT-i.endT<=1.1001&&i.target.tag==="TokenWindow",t.windows)),o=r.length-1|0;return o>=0&&o<r.length&&r[o].target.tag==="TokenWindow"&&r[o].target._5===n},bT=t=>e=>n=>r=>o=>{if(r.target.tag==="TokenWindow"){const i=Jr(r.target._2)(n.layout.edges);if(i.tag==="Just"){const a=(o-r.startT)/ne(1e-4)(r.endT-r.startT),s=NT(n)(r)(r.target._5);return tl(t)(n)(o)(r.target._4)(r.target._5)(Hg(n.layout)((()=>{if(r.target._3==="Forward")return i._1;if(r.target._3==="Backward")return re(i._1);g()})())(r.target._4)(r.target._5)(a)({pre:r.target._7,post:r.target._8}))($w(a)({pre:r.target._7,post:r.target._8}))(s.tag==="Just"?Xw(t)(n)(o)(s._1):0)(vT(n)(r)(r.target._4))(s)}if(i.tag==="Nothing")return y;g()}if(r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"){const i=Jr(r.target._1)(n.layout.edges);if(i.tag==="Just"){const a=Jr(r.target._1)(n.edgeEndpoints);if(a.tag==="Just"){const s=el(i._1)(a._1)(r.target._2._1)(Hi(e)((o-r.startT)/ne(1e-4)(r.endT-r.startT)));return tl(t)(n)(o)(s.source)(s.target)((()=>{const u=0<s.path.length?s.path[0]:{x:0,y:0},c=Yo(s.path)(s.progress);if(c.tag==="Nothing")return u;if(c.tag==="Just")return c._1;g()})())(s.progress)(0)(!1)(y)}if(a.tag==="Nothing")return y;g()}if(i.tag==="Nothing")return y;g()}return y},CT=t=>e=>{const n=e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4,r=i=>n<i.startT?i.startT-n:n>i.endT?n-i.endT:0,o=Pt(i=>a=>{const s=at.compare(r(i))(r(a));return s==="EQ"?at.compare(a.startT)(i.startT):s})(_t(i=>e.startT<i.endT-1e-4&&e.endT>i.startT+1e-4&&(i.target.tag==="RelabelWindow"?!0:i.target.tag==="EdgeWindow"?i.target._2.tag==="Extend":i.target.tag==="TokenWindow"||i.target.tag==="FillWindow"),t.windows));return 0<o.length?rn(o[0].startT+1e-4)(o[0].endT-1e-4)(e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4):e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y?(e.startT+e.endT)/2:e.endT+1e-4},LT=t=>e=>n=>{const r=n.fromCam.zoom===n.toCam.zoom&&n.fromCam.center.x===n.toCam.center.x&&n.fromCam.center.y===n.toCam.center.y?(n.startT+n.endT)/2:n.endT+1e-4,o=a=>r<a.startT?a.startT-r:r>a.endT?r-a.endT:0,i=Pt(a=>s=>at.compare(o(a))(o(s)))(_t(a=>n.startT<a.endT-1e-4&&n.endT>a.startT+1e-4&&a.target.tag==="TokenWindow",e.windows));return 0<i.length?bT(t)(cg)(e)(i[0])(rn(i[0].startT+1e-4)(i[0].endT-1e-4)(CT(e)(n))):y},Br=t=>e=>n=>{const r=(i,a)=>{const s=ht(ou(t.labelBasePx)(e)(n))([i,a]);return s.length===0?y:w("Just",ae(s))},o=Ft(i=>y,i=>a=>w("Just",{head:i,tail:a}),ht(i=>{if(i.startT<=n&&n<i.endT){if(i.target.tag==="NodeWindow"){const a=Ye(i.target._1)(e.layout.nodes);if(a.tag==="Just")return w("Just",{whole:(()=>{const s=_t(c=>(c._2.source===i.target._1||c._2.target===i.target._1)&&qd(e)(n)(c._2.source)&&qd(e)(n)(c._2.target)&&Iw(e)(n)(c._1),Hw(e.edgeEndpoints)),u=[...ht(c=>{const _=Ye(c)(e.layout.nodes);return _.tag==="Just"?w("Just",{x:_._1.x,y:_._1.y,w:_._1.w,h:_._1.h}):y})($r(B.compare)([...St(s)(c=>[c._2.source,c._2.target]),i.target._1])),...ht(c=>{const _=Jr(c._1)(e.layout.edges);return _.tag==="Just"?w("Just",Ga(_._1)):y})(s)];return u.length===0?{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h}:ae(u)})(),text:ou(t.labelBasePx)(e)(n)(i.target._1),guide:y});if(a.tag==="Nothing")return y;g()}if(i.target.tag==="RelabelWindow"){const a=Ye(i.target._1)(e.layout.nodes);if(a.tag==="Just"){const s=ht(oi)([qg(t.labelBasePx)(a._1)(i.target._2),qg(t.labelBasePx)(a._1)(i.target._3)]),u=s.length===0?y:w("Just",ae(s)),c={x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h};return w("Just",{whole:(()=>{if(u.tag==="Just")return ae([c,u._1]);if(u.tag==="Nothing")return c;g()})(),text:u,guide:Xd(t.labelBasePx)(e)(i.target._1)(i.target._2)(i.target._3)})}if(a.tag==="Nothing")return y;g()}if(i.target.tag==="EdgeWindow")return w("Just",(()=>{const a=aT(t)(e)(n)(i.target._1),s=Jr(i.target._1)(e.edgeEndpoints);if(s.tag==="Just"){const u=r(s._1.source,s._1.target);return{whole:(()=>{if(u.tag==="Nothing")return a;if(u.tag==="Just")return u._1;g()})(),text:u,guide:w("Just",a)}}if(s.tag==="Nothing")return{whole:$o(e.layout)(e.edgeEndpoints)(i.target._1),text:y,guide:w("Just",a)};g()})());if(i.target.tag==="TokenWindow")return w("Just",(()=>{const a=r(i.target._4,i.target._5),s=Jr(i.target._2)(e.layout.edges),u=(()=>{if(s.tag==="Nothing")return $o(e.layout)(e.edgeEndpoints)(i.target._2);if(s.tag==="Just"){const c=Hg(e.layout)((()=>{if(i.target._3==="Forward")return s._1;if(i.target._3==="Backward")return re(s._1);g()})())(i.target._4)(i.target._5)((n-i.startT)/ne(1e-4)(i.endT-i.startT))({pre:i.target._7,post:i.target._8});return{x:c.x-6,y:c.y-6,w:12,h:12}}g()})();return{whole:(()=>{const c=ht(oi)([(()=>{const _=ht(f=>{const l=Ye(f)(e.layout.nodes);return l.tag==="Just"?w("Just",{x:l._1.x,y:l._1.y,w:l._1.w,h:l._1.h}):y})([i.target._4,i.target._5]);return _.length===0?y:w("Just",ae(_))})(),a]);return c.length===0?u:ae(c)})(),text:a,guide:w("Just",u)}})());if(i.target.tag==="FillWindow"){const a=Ye(i.target._2)(e.layout.nodes);if(a.tag==="Just")return w("Just",{whole:{x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h},text:ou(t.labelBasePx)(e)(n)(i.target._2),guide:y});if(a.tag==="Nothing")return y;g()}}return y})(e.windows));return o.tag==="Just"?w("Just",(()=>{const i=ae(Y(c=>c.whole)([o._1.head,...o._1.tail])),a=ht(oi)(Y(c=>c.text)([o._1.head,...o._1.tail])),s=a.length===0?y:w("Just",ae(a)),u=ht(oi)(Y(c=>c.guide)([o._1.head,...o._1.tail]));return u.length===0?{whole:{x:i.x*e.placement.scale+e.placement.tx,y:i.y*e.placement.scale+e.placement.ty,w:i.w*e.placement.scale,h:i.h*e.placement.scale},text:s.tag==="Just"?w("Just",{x:s._1.x*e.placement.scale+e.placement.tx,y:s._1.y*e.placement.scale+e.placement.ty,w:s._1.w*e.placement.scale,h:s._1.h*e.placement.scale}):y,guide:y}:{whole:{x:i.x*e.placement.scale+e.placement.tx,y:i.y*e.placement.scale+e.placement.ty,w:i.w*e.placement.scale,h:i.h*e.placement.scale},text:s.tag==="Just"?w("Just",{x:s._1.x*e.placement.scale+e.placement.tx,y:s._1.y*e.placement.scale+e.placement.ty,w:s._1.w*e.placement.scale,h:s._1.h*e.placement.scale}):y,guide:w("Just",{x:ae(u).x*e.placement.scale+e.placement.tx,y:ae(u).y*e.placement.scale+e.placement.ty,w:ae(u).w*e.placement.scale,h:ae(u).h*e.placement.scale})}})()):y},za=t=>e=>n=>r=>o=>{const i=t.padding*r.placement.scale;return au((()=>{const a=Br(t)(r)(o);return a.tag==="Just"?w("Just",{x:a._1.whole.x-i,y:a._1.whole.y-i,w:a._1.whole.w+i*2,h:a._1.whole.h+i*2}):y})())(w("Just",(()=>{const a={x:r.layout.bounds.x*r.placement.scale+r.placement.tx-i,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-i,w:r.layout.bounds.w*r.placement.scale+i*2,h:r.layout.bounds.h*r.placement.scale+i*2},s=Da(r)(o);return s.tag==="Just"?{x:s._1.x*r.placement.scale+r.placement.tx-i,y:s._1.y*r.placement.scale+r.placement.ty-i,w:s._1.w*r.placement.scale+i*2,h:s._1.h*r.placement.scale+i*2}:a})()))},kT=t=>e=>n=>r=>o=>St(r.dives)(i=>{const a=Fa(r)(i.parentPath)(i.startT)(i.endT);if(a.tag==="Just"){const s=i.childPath,u=te(c=>xo(c.path)(s))(r.segments);if(u.tag==="Just"){const c=o(u._1),_=Jo(t)(e)(n)(u._1)(za(t)(e)(n)(u._1)(u._1.startT+2e-4))(mT(t)(e)(n)(r)(u._1)),f=c.length===0?_:ta(n)(t.padding)(u._1)(Ko(t)(n)(c)(i.startT-1e-4).camera),l=ea(t)(e)(n)(i)(a._1)(o(a._1)),d=(()=>{if(i.direction==="DiveIn")return _;if(i.direction==="DiveOut"){const h=te(m=>m.direction==="DiveOut"&&xo(m.parentPath)(i.childPath)&&xe(m.endT-i.startT)<1e-4)(r.dives);if(h.tag==="Just"){const m=Fa(r)(h._1.parentPath)(h._1.startT)(h._1.endT);if(m.tag==="Just")return ea(t)(e)(n)(h._1)(m._1)(o(m._1));if(m.tag==="Nothing")return f;g()}if(h.tag==="Nothing")return f}g()})();if(i.direction==="DiveIn"){const h=te(m=>m.direction==="DiveIn"&&xo(m.parentPath)(i.childPath)&&xe(m.startT-i.endT)<1e-4)(r.dives);if(h.tag==="Just"){const m=Fa(r)(h._1.parentPath)(h._1.startT)(h._1.endT);if(m.tag==="Just"){if(i.direction==="DiveIn"&&i.endT-i.startT>.12){const p=i.endT-.12,x={easing:_r,endT:p,fromCam:l,intent:lo,interp:fo,startT:i.startT,toCam:ea(t)(e)(n)(h._1)(m._1)(o(m._1))};return[x,{...x,startT:p,endT:i.endT,fromCam:ea(t)(e)(n)(h._1)(m._1)(o(m._1))}]}return[{startT:i.startT,endT:i.endT,fromCam:l,toCam:d,easing:_r,interp:fo,intent:lo}]}if(m.tag==="Nothing")return[{startT:i.startT,endT:i.endT,fromCam:l,toCam:d,easing:_r,interp:fo,intent:lo}];g()}if(h.tag==="Nothing")return[{startT:i.startT,endT:i.endT,fromCam:l,toCam:d,easing:_r,interp:fo,intent:lo}];g()}if(i.direction==="DiveOut"){const h=te(m=>m.direction==="DiveIn"&&xo(m.parentPath)(i.childPath)&&xe(m.startT-i.endT)<1e-4)(r.dives);if(h.tag==="Just"){const m=Fa(r)(h._1.parentPath)(h._1.startT)(h._1.endT);if(m.tag==="Just"){if(i.direction==="DiveIn"&&i.endT-i.startT>.12){const p=i.endT-.12,x={easing:_r,endT:p,fromCam:d,intent:lo,interp:fo,startT:i.startT,toCam:ea(t)(e)(n)(h._1)(m._1)(o(m._1))};return[x,{...x,startT:p,endT:i.endT,fromCam:ea(t)(e)(n)(h._1)(m._1)(o(m._1))}]}return[{startT:i.startT,endT:i.endT,fromCam:d,toCam:l,easing:_r,interp:fo,intent:lo}]}if(m.tag==="Nothing")return[{startT:i.startT,endT:i.endT,fromCam:d,toCam:l,easing:_r,interp:fo,intent:lo}];g()}if(h.tag==="Nothing")return[{startT:i.startT,endT:i.endT,fromCam:d,toCam:l,easing:_r,interp:fo,intent:lo}]}g()}if(u.tag==="Nothing")return[];g()}if(a.tag==="Nothing")return[];g()}),Ia=t=>e=>n=>r=>o=>{const i=t.padding*r.placement.scale,a=fn(e)(r.path.length===0||r.placement.scale===1&&r.placement.tx===0&&r.placement.ty===0?t.padding:0)(n)({center:(()=>{const h=t.padding*r.placement.scale;return{x:r.layout.bounds.x*r.placement.scale+r.placement.tx-h+(r.layout.bounds.w*r.placement.scale+h*2)/2,y:r.layout.bounds.y*r.placement.scale+r.placement.ty-h+(r.layout.bounds.h*r.placement.scale+h*2)/2}})(),zoom:sl(t)(e)(n)(r)}),s=h=>h.w<=a.w+.001&&h.h<=a.h+.001,u=Br(t)(r)(o),c=(()=>{const h=au(u.tag==="Just"?w("Just",{x:u._1.whole.x-i,y:u._1.whole.y-i,w:u._1.whole.w+i*2,h:u._1.whole.h+i*2}):y)((()=>{const m=Da(r)(o);return m.tag==="Just"?w("Just",{x:m._1.x*r.placement.scale+r.placement.tx-i,y:m._1.y*r.placement.scale+r.placement.ty-i,w:m._1.w*r.placement.scale+i*2,h:m._1.h*r.placement.scale+i*2}):y})());if(h.tag==="Nothing")return!1;if(h.tag==="Just")return s(h._1);g()})()?i/2:i,_=u.tag==="Just"?w("Just",{x:u._1.whole.x-c,y:u._1.whole.y-c,w:u._1.whole.w+c*2,h:u._1.whole.h+c*2}):y,f=h=>{if(_.tag==="Nothing")return h;if(_.tag==="Just")return ae([h,{x:_._1.x+_._1.w/2,y:_._1.y+_._1.h/2,w:0,h:0}]);g()},l=(()=>{if(u.tag==="Just")return u._1.guide;if(u.tag==="Nothing")return y;g()})();if(l.tag==="Just"){const h=(()=>{if(u.tag==="Just")return u._1.text;if(u.tag==="Nothing")return y;g()})();return h.tag==="Just"&&s({x:h._1.x-c,y:h._1.y-c,w:h._1.w+c*2,h:h._1.h+c*2})?r.path.length!==0?za(t)(e)(n)(r)(o):_.tag==="Just"&&s(_._1)?w("Just",_._1):w("Just",f({x:h._1.x-c,y:h._1.y-c,w:h._1.w+c*2,h:h._1.h+c*2})):r.path.length!==0?za(t)(e)(n)(r)(o):_.tag==="Just"&&s(_._1)?w("Just",_._1):w("Just",f({x:l._1.x-c,y:l._1.y-c,w:l._1.w+c*2,h:l._1.h+c*2}))}const d=(()=>{if(u.tag==="Just")return u._1.text;if(u.tag==="Nothing")return y;g()})();return d.tag==="Just"?r.path.length!==0?za(t)(e)(n)(r)(o):_.tag==="Just"&&s(_._1)?w("Just",_._1):w("Just",f({x:d._1.x-c,y:d._1.y-c,w:d._1.w+c*2,h:d._1.h+c*2})):r.path.length!==0?za(t)(e)(n)(r)(o):_.tag==="Just"&&s(_._1)?w("Just",_._1):_.tag==="Just"?w("Just",f(_._1)):y},ST=t=>e=>n=>r=>o=>i=>{const a=Ia(t)(e)(n)(r)(i),s=u=>Ia(t)(e)(n)(r)(rn(r.startT)(r.endT)(u));return au(a)((()=>{const u=ht(oi)(Mt(c=>_=>{const f=ne(_-t.maxTransition)((()=>{const m=c-1|0;return m>=0&&m<o.length?(o[m]+_)/2:r.startT})()),l=En(_+t.maxTransition)((()=>{const m=c+1|0;return m>=0&&m<o.length?(o[m]+_)/2:r.endT})());if(i<f-1e-4||i>l+1e-4)return y;const d=s(_-1e-4),h=s(_+1e-4);return al(f)(_)(l)(i)(i<_?a:d)(i<_?h:a)})(o));return u.length===0?y:w("Just",ae(u))})())},ET=t=>e=>n=>r=>o=>i=>o<=r.startT+1e-4?xT(t)(e)(n)(r)(i):Jo(t)(e)(n)(r)(ST(t)(e)(n)(r)(il(r))(o))(i),PT=t=>e=>n=>r=>o=>i=>{const a=Ia(t)(e)(n)(r)(i);return au(a)((()=>{const s=ht(u=>i<u.left-1e-4||i>u.right+1e-4?y:al(u.left)(u.boundary)(u.right)(i)(i<u.boundary?a:u.before)(i<u.boundary?u.after:a))(o);return s.length===0?y:w("Just",ae(s))})())},GT=t=>e=>n=>r=>o=>{const i=a=>Ia(t)(e)(n)(r)(rn(r.startT)(r.endT)(a));return Mt(a=>s=>({boundary:s,left:ne(s-t.maxTransition)((()=>{const u=a-1|0;return u>=0&&u<o.length?(o[u]+s)/2:r.startT})()),right:En(s+t.maxTransition)((()=>{const u=a+1|0;return u>=0&&u<o.length?(o[u]+s)/2:r.endT})()),before:i(s-1e-4),after:i(s+1e-4)}))(o)},AT=t=>e=>n=>r=>o=>i=>a=>{const s=e.widthPx>=e.heightPx*1.5&&a.path.length===0,u=S=>s&&oe(b=>b.startT<=S&&S<b.endT&&(b.target.tag==="TokenWindow"||b.target.tag==="FillWindow"),a.windows),c=S=>b=>{let I=S,H=b,Q=!0,q;for(;Q;){const $=I,A=H,F=ii(t)(e)(r)(a)(A);if($<=0){Q=!1,q=A.zoom;continue}if(e.widthPx<=0||e.heightPx<=0){Q=!1,q=A.zoom;continue}if(F<=0){Q=!1,q=A.zoom;continue}if(xe(F-t.minimumReadableLabelPx)<.001){Q=!1,q=A.zoom;continue}I=$-1|0,H={...A,zoom:A.zoom*t.minimumReadableLabelPx/F}}return q},_=t.padding*a.placement.scale/2,f=s?.016666666666666666:1e-4,l=t.padding*a.placement.scale,d={x:a.layout.bounds.x*a.placement.scale+a.placement.tx-l,y:a.layout.bounds.y*a.placement.scale+a.placement.ty-l,w:a.layout.bounds.w*a.placement.scale+l*2,h:a.layout.bounds.h*a.placement.scale+l*2},h={center:{x:d.x+d.w/2,y:d.y+d.h/2},zoom:1},m=c(12)(h),p=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(h),x=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)({...h,zoom:m}),J={w:x.w*m,h:x.h*m},T=(S,b)=>{const I=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(b);return Bc(H=>{if(H.tag==="Nothing")return!0;if(H.tag==="Just")return H._1.x>=I.x-.001&&H._1.y>=I.y-.001&&H._1.x+H._1.w<=I.x+I.w+.001&&H._1.y+H._1.h<=I.y+I.h+.001;g()},S)},N=ht(S=>{if(S.target.tag==="RelabelWindow"){const b=Br(t)(a)((S.startT+S.endT)/2);if(b.tag==="Just")return w("Just",{window:S,bounds:(()=>{if(b._1.text.tag==="Just")return ae([b._1.whole,b._1.text._1]);if(b._1.text.tag==="Nothing")return b._1.whole;g()})(),preparers:(()=>{const I=S.startT;return _t(H=>I>=H.endT-1e-4&&I<=H.endT+t.maxTransition&&H.target.tag==="TokenWindow"&&H.target._5===S.target._1,a.windows)})()})}return y})(a.windows),k=ht(S=>S.target.tag==="NodeWindow"||S.target.tag==="RelabelWindow"||S.target.tag==="EdgeWindow"||S.target.tag==="TokenWindow"||S.target.tag==="FillWindow"?w("Just",{window:S,afterStart:Br(t)(a)(S.startT+1e-4),beforeEnd:Br(t)(a)(S.endT-1e-4)}):y)(a.windows),C=S=>u(S)?Br(t)(a)(S):Zd([(()=>{const b=v(I=>H=>H.window.endT>S+1e-4||H.window.endT<S-t.maxTransition||I.tag==="Just"&&I._1.window.endT>=H.window.endT?I:w("Just",H))(y)(k);if(b.tag==="Just")return b._1.beforeEnd;if(b.tag==="Nothing")return y;g()})(),Br(t)(a)(S),(()=>{const b=v(I=>H=>H.window.startT<S-1e-4||H.window.startT>S+t.maxTransition||I.tag==="Just"&&I._1.window.startT<=H.window.startT?I:w("Just",H))(y)(k);if(b.tag==="Just")return b._1.afterStart;if(b.tag==="Nothing")return y;g()})()]),P=(S,b)=>{const I=Da(a)(S),H=I.tag==="Just"?w("Just",{x:I._1.x*a.placement.scale+a.placement.tx,y:I._1.y*a.placement.scale+a.placement.ty,w:I._1.w*a.placement.scale,h:I._1.h*a.placement.scale}):y,Q=ht(A=>A.window.endT>=S-1e-4&&A.window.startT<=S+t.maxTransition&&A.window.target.tag==="RelabelWindow"||oe(F=>F.startT<=S+1e-4&&F.endT>=S-1e-4,A.preparers)?w("Just",A.bounds):y)(N),q=Q.length===0?y:w("Just",ae(Q));if(b.tag==="Just"){if(q.tag==="Just"){const F=(()=>{if(H.tag==="Just")return w("Just",ae([H._1,ae([q._1,b._1.whole])]));if(H.tag==="Nothing")return w("Just",ae([q._1,b._1.whole]));g()})();return a.path.length===0?Ui({worldBounds:d,bounds:F,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})}if(q.tag==="Nothing"){const F=(()=>{if(H.tag==="Just")return w("Just",ae([H._1,b._1.whole]));if(H.tag==="Nothing")return w("Just",b._1.whole);g()})();return a.path.length===0?Ui({worldBounds:d,bounds:F,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})}const A=(H.tag==="Just"&&g(),void g());return a.path.length===0?Ui({worldBounds:d,bounds:A,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})}if(q.tag==="Just"){const A=(()=>{if(H.tag==="Just")return w("Just",ae([H._1,q._1]));if(H.tag==="Nothing")return w("Just",q._1);g()})();return a.path.length===0?Ui({worldBounds:d,bounds:A,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})}if(q.tag==="Nothing"){const A=(()=>{if(H.tag==="Just")return w("Just",H._1);if(H.tag==="Nothing")return y;g()})();return a.path.length===0?Ui({worldBounds:d,bounds:A,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})}const $=(H.tag==="Just"&&g(),void g());return a.path.length===0?Ui({worldBounds:d,bounds:$,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,actionTextBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:{w:p.w,h:p.h},padding:_,zoomFloor:m}):Vi({worldBounds:d,visibleBounds:H,actionBounds:b.tag==="Just"?w("Just",b._1.whole):y,fallbackActionBounds:(()=>{if(b.tag==="Just")return b._1.text;if(b.tag==="Nothing")return y;g()})(),actionGuideBounds:(()=>{if(b.tag==="Just")return b._1.guide;if(b.tag==="Nothing")return y;g()})(),frameAtUnitZoom:J,zoomCap:m,padding:_})},G=il(a),R=GT(t)(e)(r)(a)(G),U=S=>u(S)?Ia(t)(e)(r)(a)(S):PT(t)(e)(r)(a)(R)(S);return v(S=>b=>{const I=rn(a.startT)(a.endT)(b.startT+1e-4),H=rn(a.startT)(a.endT)(b.endT+1e-4),Q=(I+H)/2,q=b.intent==="ActionFocus"&&u(Q),$=b.intent==="ActionFocus"?Q:H,A=q?[U(Q)]:Y(mt=>U(mt))((()=>{const mt=b.easing==="Linear"?6:2,bt=b.endT-b.startT;return Y(Ht=>rn(a.startT)(a.endT)(b.startT+bt*ot(Ht)/ot(mt)+1e-4))(Ut(0,mt))})()),F=ht(oi)(A),M=F.length===0?y:w("Just",ae(F)),W=A.length-1|0,D=W>=0&&W<A.length?w("Just",A[W]):y,X=(()=>{if(D.tag==="Just")return D._1;if(D.tag==="Nothing")return U(H);g()})(),V=zx.eq(b.interp)(Qf)&&T(A,b.toCam),K=V&&!q?b.toCam:P(H,C($)),Z=0<A.length?Jo(t)(e)(r)(a)(A[0])(P(I,C(I))):Jo(t)(e)(r)(a)(U(I))(P(I,C(I))),tt=(()=>{if(S.previous.tag==="Nothing")return Z;if(S.previous.tag==="Just")return S.previous._1;g()})(),et=(()=>{if(s)return K;const mt=LT(t)(a)(b);return mt.tag==="Just"&&b.easing==="Linear"?JT(t)(e)(r)(a)(tt)(mt._1)(K):K})(),ft=Jo(t)(e)(r)(a)(X)(tt),Nt=Jo(t)(e)(r)(a)(M)(TT(t)(e)(r)(a)(M)(tt)(q&&K.zoom>tt.zoom+1e-4||!V&&q?Jo(t)(e)(r)(a)(X)(et):T(A,tt)&&(!q||tt.zoom>=K.zoom-1e-4)?tt:(()=>{const mt=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(tt),bt=(ft.center.y-tt.center.y)*e.heightPx/ne(1e-4)(mt.h),Ht=(ft.center.x-tt.center.x)*e.widthPx/ne(1e-4)(mt.w);return qe(Ht*Ht+bt*bt)<=12})()?ft:Jo(t)(e)(r)(a)(X)(et))),dt=(()=>{if(b.easing==="Linear"){const mt=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(tt),bt=(Nt.center.y-tt.center.y)*e.heightPx/ne(1e-4)(mt.h),Ht=(Nt.center.x-tt.center.x)*e.widthPx/ne(1e-4)(mt.w),Tt=qe(Ht*Ht+bt*bt),Vt=t.panSpeed*ne(0)(b.endT-b.startT),At=Tt<=Vt||Tt<=1e-4?1:Vt/Tt,vt={...Nt,center:{x:tt.center.x+(Nt.center.x-tt.center.x)*At,y:tt.center.y+(Nt.center.y-tt.center.y)*At}};if((()=>{const pt=U(rn(a.startT)(a.endT)(b.endT+1e-4));if(pt.tag==="Nothing")return!0;if(pt.tag==="Just"){const gt=fn(e)(a.path.length===0||a.placement.scale===1&&a.placement.tx===0&&a.placement.ty===0?t.padding:0)(r)(vt);return pt._1.x>=gt.x-.001&&pt._1.y>=gt.y-.001&&pt._1.x+pt._1.w<=gt.x+gt.w+.001&&pt._1.y+pt._1.h<=gt.y+gt.h+.001}g()})())return vt}return Nt})();return{previous:w("Just",dt),spans:Et(S.spans)({startT:b.startT,endT:b.endT,fromCam:tt,toCam:dt,easing:b.easing,interp:Vo,intent:b.intent})}})({previous:y,spans:[]})(_t(S=>S.endT-S.startT>=f,(()=>{const S=Pt(at.compare)($r(at.compare)(St(G)(I=>[ne(I-t.maxTransition)((()=>{const H=_t(q=>q<I,G),Q=H.length-1|0;return Q>=0&&Q<H.length?(H[Q]+I)/2:a.startT})()),I,En(I+t.maxTransition)((()=>{const H=_t(Q=>Q>I,G);return 0<H.length?(H[0]+I)/2:a.endT})())]))),b=fT(t)(e)(n)(r)(o)(i)(a);return St((()=>{if(b.length===0){const I=P(rn(a.startT)(a.endT)(a.startT+1e-4),C(rn(a.startT)(a.endT)(a.startT+1e-4)));return[{startT:a.startT,endT:a.endT,fromCam:I,toCam:I,easing:t.easing,interp:Vo,intent:Qs}]}return b})())(I=>{const H=[I.startT,...Et(_t(Q=>Q>I.startT+1e-4&&Q<I.endT-1e-4,S))(I.endT)];return Y(Q=>({...I,startT:Q._1,endT:Q._2}))(Oe(Cn,H,Bt(1,H.length,H)))})})())).spans},BT=t=>e=>n=>r=>o=>i=>Ow(a=>({segment:a,spans:AT(t)(e)(n)(r)(o)(i)(a)}))(i.segments),ul=t=>e=>n=>r=>o=>i=>{const a=BT(t)(e)(n)(r)(o)(i),s=Pt(c=>_=>at.compare(c.startT)(_.startT))(St(a)(c=>c.spans)),u=kT(t)(e)(r)(i)(c=>{const _=te(f=>xo(f.segment.path)(c.path)&&f.segment.startT===c.startT&&f.segment.endT===c.endT)(a);return _.tag==="Just"?_._1.spans:[]});return[...u,...u.length===0?s:wT(u)(s)]},RT=t=>e=>n=>{const r=v(o=>i=>!(i.target.tag==="NodeWindow"||i.target.tag==="RelabelWindow"||i.target.tag==="EdgeWindow"||i.target.tag==="TokenWindow"||i.target.tag==="FillWindow")||i.endT>n+1e-4||i.endT<n-t.maxTransition||o.tag==="Just"&&o._1.endT>=i.endT?o:w("Just",i))(y)(e.windows);if(r.tag==="Just")return Br(t)(e)(r._1.endT-1e-4);if(r.tag==="Nothing")return y;g()},DT=t=>e=>n=>{const r=v(o=>i=>!(i.target.tag==="NodeWindow"||i.target.tag==="RelabelWindow"||i.target.tag==="EdgeWindow"||i.target.tag==="TokenWindow"||i.target.tag==="FillWindow")||i.startT<n-1e-4||i.startT>n+t.maxTransition||o.tag==="Just"&&o._1.startT<=i.startT?o:w("Just",i))(y)(e.windows);if(r.tag==="Just")return Br(t)(e)(r._1.startT+1e-4);if(r.tag==="Nothing")return y;g()},FT=t=>e=>n=>Zd([RT(t)(e)(n),Br(t)(e)(n),DT(t)(e)(n)]),zT=t=>e=>n=>{const r=FT(t)(e)(n);return{level:(()=>{const o=t.padding*e.placement.scale;return{x:e.layout.bounds.x*e.placement.scale+e.placement.tx-o,y:e.layout.bounds.y*e.placement.scale+e.placement.ty-o,w:e.layout.bounds.w*e.placement.scale+o*2,h:e.layout.bounds.h*e.placement.scale+o*2}})(),visible:(()=>{const o=Da(e)(n);return o.tag==="Just"?w("Just",{x:o._1.x*e.placement.scale+e.placement.tx,y:o._1.y*e.placement.scale+e.placement.ty,w:o._1.w*e.placement.scale,h:o._1.h*e.placement.scale}):y})(),action:r.tag==="Just"?w("Just",r._1.whole):y,actionText:(()=>{if(r.tag==="Just")return r._1.text;if(r.tag==="Nothing")return y;g()})(),actionGuide:(()=>{if(r.tag==="Just")return r._1.guide;if(r.tag==="Nothing")return y;g()})()}},na=(t,e,n)=>({tag:t,_1:e,_2:n}),IT=t=>t,ai=(t,e)=>({tag:t,_1:e}),cl=(t,e)=>({tag:t,_1:e}),Kg=t=>t,su=(t,e)=>({tag:t,_1:e}),Yg=su("NotYet"),gl=su("Consumed"),QT=Kg("FromSource"),_l=Kg("FromTarget"),MT=Kg("FromBoth"),uu=ai("Hidden"),Xg=ai("Visible"),Zg=IT("ExtendFromSource"),cu=na("Retracted"),gu=na("Extended"),OT={eq:t=>e=>t.tag==="Retracted"?e.tag==="Retracted":t.tag==="Extending"?e.tag==="Extending"&&(t._1==="ExtendFromSource"?e._1==="ExtendFromSource":t._1==="ExtendFromTarget"&&e._1==="ExtendFromTarget")&&t._2===e._2:t.tag==="Extended"?e.tag==="Extended":t.tag==="Retracting"&&e.tag==="Retracting"&&(t._1==="FromSource"?e._1==="FromSource":t._1==="FromTarget"?e._1==="FromTarget":t._1==="FromBoth"&&e._1==="FromBoth")&&t._2===e._2},jg=t=>t,_u=(t,e)=>({tag:t,_1:e}),ra={eq:Ts(Fi)},WT=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),t_=fe(B)(Qt),Xr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},fl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},In=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},e_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},n_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},dl=Qt.foldMap(Yy(B)),si=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},HT=fe(B)(Qt),$T=fe(B)(Qt),qT=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ll=_u("Closed"),VT=_u("Open"),hl=jg("Backdrop"),UT=jg("FlyThrough"),dn=jg("Active"),fu=t=>e=>n=>{const r=te(o=>ra.eq(o.path)(e)&&n>=o.startT&&n<o.endT)(t.segments);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return te(o=>ra.eq(o.path)(e))(t.segments);g()},KT=t=>{const e=te(n=>n.path.length===0)(t.segments);if(e.tag==="Just")return e._1.edgeEndpoints;if(e.tag==="Nothing")return O;g()},YT=t=>({startT:0,endT:t.totalDuration,path:[],layout:t.layout,placement:mg,windows:t.windows,spans:t.spans,keyframes:t.keyframes,initialKeyframe:t.initialKeyframe,edgeEndpoints:KT(t)}),du=t=>e=>n=>({...n,minis:Y(r=>{const o=du(t)(e)({...r,state:{...r.state,tokens:O,nodeInvert:O,visited:O}});return(()=>{const i=r.segment.path;return oe(a=>a.direction==="DiveOut"&&ra.eq(a.childPath)(i)&&a.endT<=e+1e-4,t.dives)})()?{...o,bgAlpha:1}:o})(n.minis)}),XT=t=>Y(e=>e<1?[]:Bt(0,e,t))(Ut(0,t.length-1|0)),ZT=t=>e=>Y(n=>ra.eq(n.segment.path)(t)?{...n,bgAlpha:e,state:{...n.state,tokens:O,nodeInvert:O,visited:O}}:n),jT=t=>v(e=>n=>(e*31|0)+Ur(n)|0)(7)(Bn(t)),tN=t=>e=>n=>({...n,state:{...n.state,nodes:t_(Y(r=>E(r._1,t(r._1)(r._2)))(WT(n.state.nodes))),edges:(()=>{const r=o=>{if(o.tag==="Leaf")return O;if(o.tag==="Node")return ee("Node",o._1,o._2,o._3,e(o._4),r(o._5),r(o._6));g()};return r(n.state.edges)})()}}),r_=t=>e=>n=>{const r=Xr(e)(t.keyframes);if(r.tag==="Just")return fl(n)(r._1.labels);if(r.tag==="Nothing")return y;g()},eN=t=>e=>ht(n=>fl(e)(n.labels))((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._4,n(r._6,o)));g()};return It(ge.foldr,n(t.keyframes,z))})()),nN=v(t=>e=>{const n=Sr(t);return n.tag==="Just"&&e.startT<=n._1.last.endT+1e-6?Et(n._1.init)({...n._1.last,endT:In(n._1.last.endT)(e.endT),windows:Et(n._1.last.windows)(e)}):Et(t)({endT:e.endT,windows:[e]})})([]),rN=t=>v(e=>n=>{if(!e.leading)return e;if(n.scene.tag==="Structural"){if((()=>{const r=Xr(n.scene._1.to)(t.keyframes),o=Xr(e.keyframe)(t.keyframes);return!(o.tag==="Just"&&r.tag==="Just"&&Yn(B.compare,o._1.nodes,r._1.nodes).tag==="Leaf"&&Yn(B.compare,o._1.edges,r._1.edges).tag==="Leaf")})())return{...e,leading:!1};if((()=>{const r=Xr(n.scene._1.to)(t.keyframes);if(r.tag==="Nothing")return!0;if(r.tag==="Just")return!r._1.authored;g()})())return{...e,keyframe:n.scene._1.to};if(!e.namedSceneSeen)return{...e,keyframe:n.scene._1.to,namedSceneSeen:!0}}return{...e,leading:!1}})({keyframe:t.initialKeyframe,leading:!0,namedSceneSeen:(()=>{const e=Xr(t.initialKeyframe)(t.keyframes);if(e.tag==="Just")return!(e._1.nodes.tag==="Leaf"&&e._1.edges.tag==="Leaf");if(e.tag==="Nothing")return!1;g()})()})(t.spans).keyframe,pl=t=>{const e=Xr(rN(t))(t.keyframes);if(e.tag==="Just")return{nodes:e._1.nodes,edges:e._1.edges};if(e.tag==="Nothing")return{nodes:O,edges:O};g()},oN=t=>{const e=pl(t);return v(In)(t.startT)(ht(n=>n.target.tag==="NodeWindow"?n.target._2==="PlopIn"&&e_(n.target._1)(e.nodes)?w("Just",n.endT):y:n.target.tag==="EdgeWindow"&&n.target._2.tag==="Extend"&&n_(n.target._1)(e.edges)?w("Just",n.endT):y)(t.windows))},ml=t=>e=>{const n=pl(t);return{...e,state:{...e.state,nodes:Fc()(r=>o=>w("Just",e_(r)(n.nodes)?Xg:o))(e.state.nodes),edges:Fc()(r=>o=>w("Just",n_(r)(n.edges)?gu:o))(e.state.edges)}}},iN=t=>e=>n=>e.path.length===0||t>=oN(e)?n:ml(e)(n),aN=t=>e=>n=>dl(r=>dl(o=>o.target.tag==="FillWindow"?o.startT<=n?ee("Node",1,1,o.target._2,void 0,O,O):O:o.target.tag==="TokenWindow"&&o.startT+(o.endT-o.startT)*.25<=n?ee("Node",1,1,o.target._4,void 0,O,O):O)(r.windows))(_t(r=>n<=r.endT+t,nN(Pt(r=>o=>at.compare(r.startT)(o.startT))(_t(r=>r.target.tag==="FillWindow"||r.target.tag==="TokenWindow",e))))),sN=t=>e=>{const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),eN(t)(e));if(n.tag==="Nothing")return!1;if(n.tag==="Just"){const r=n._1.head;return oe(o=>o!==r,n._1.tail)}g()},uN=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n,t),cN=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="RelabelWindow"&&r.target._1===n,t),gN=t=>e=>n=>{const r=ji(t)(e);if(r.tag==="AtKeyframe")return r_(t)(r._1)(n);if(r.tag==="InTransition")return cN(t.windows)(e)(n)?r_(t)(r._2)(n):r_(t)(r._1)(n);g()},_N=t=>e=>n=>oe(r=>r.endT<=e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopOut"&&r.target._1===n,t),fN=t=>e=>n=>oe(r=>r.startT>e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopIn"&&r.target._1===n,t),dN=t=>e=>n=>oe(r=>r.startT>e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"&&r.target._1===n,t),lN=t=>e=>{const n=ji(t)(e),r=(()=>{if(n.tag==="AtKeyframe")return n._1;if(n.tag==="InTransition")return n._2;g()})(),o=Xr(r)(t.keyframes);return o.tag==="Just"&&o._1.authored?r:""},hN=t=>e=>{const n=ji(t)(e),r=Xr((()=>{if(n.tag==="AtKeyframe")return n._1;if(n.tag==="InTransition")return n._2;g()})())(t.keyframes);if(r.tag==="Just")return r._1.kind;if(r.tag==="Nothing")return Pa;g()},yl=t=>{const e=K1(y,H1,o=>(()=>{const i=Xr((()=>{if(o.scene.tag==="Structural")return o.scene._1.to;if(o.scene.tag==="DataFlow")return o.scene._1.keyframe;if(o.scene.tag==="Hold")return o.scene._1;if(o.scene.tag==="EnterNode"||o.scene.tag==="ExitNode"||o.scene.tag==="StepScene")return t.initialKeyframe;g()})())(t.keyframes);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return i._1.nodes.tag==="Leaf";g()})()?y:w("Just",In(o.startT)(o.endT-1e-4)),t.spans),n=(()=>{if(e.tag==="Nothing")return t.startT;if(e.tag==="Just")return e._1;g()})(),r=te(o=>o.target.tag==="NodeWindow"&&o.target._2==="PlopIn")(Pt(o=>i=>at.compare(o.startT)(i.startT))(t.windows));if(r.tag==="Nothing")return n;if(r.tag==="Just")return In(r._1.startT)(r._1.endT-1e-4);g()},Qa=t=>e=>n=>te(r=>n(r)&&e>=r.startT&&e<r.endT)(t),pN={segment:{startT:0,endT:0,path:[],layout:{nodes:O,edges:O,bounds:{x:0,y:0,w:0,h:0},chipExtras:O,edgeLabels:O},placement:mg,windows:[],spans:[],keyframes:O,initialKeyframe:"",edgeEndpoints:O},state:{animationTime:0,nodes:O,nodeLabels:O,edgeEndpoints:O,edges:O,tokens:O,camera:{center:{x:0,y:0},zoom:1},frameTitle:"",staticKind:Pa,visited:O,nodeFadeAlpha:O,nodeLabelFadeAlpha:O,edgeFadeAlpha:O,nodeInvert:O},bgAlpha:1,minis:[],role:dn},xl=t=>{const e=t.levels.length-1|0;return e>=0&&e<t.levels.length?t.levels[e]:pN},Ma=t=>e=>{const n=t.endT-t.startT;return n<=0?1:In(0)(si(1)((e-t.startT)/n))},mN=t=>e=>n=>_g(Ko(t.cameraConfig)(t.layout)(t.cameraSpans)(n.startT).camera)(Ko(t.cameraConfig)(t.layout)(t.cameraSpans)(n.endT).camera)(Ma(n)(e)),Jl=t=>e=>n=>{const r=In(0)(si(1)((n-t)/In(1e-6)(e-t)));return r*r*r*(r*(r*6-15)+10)},wl=t=>{if(t.tag==="Closed")return 0;if(t.tag==="Opening")return Jl(.3)(1)(t._1);if(t.tag==="Open")return 1;if(t.tag==="Closing")return 1-Jl(0)(.7)(t._1);g()},yN=t=>{const e=wl(t);return e<=0||e>=1?0:tn(3.141592653589793*e)},xN=t=>e=>n=>In(0)(si(1)((n-Ge(0)(.3)(t+jT(e)|0).value)/.7)),ui=t=>e=>{const n=t.endT-t.startT;return n<=0?1:In(0)(si(1)((e-t.startT)/n))},JN=t=>e=>t_(ht(n=>{const r=Qa(t.windows)(e)(o=>o.target.tag==="RelabelWindow"&&o.target._1===n);if(r.tag==="Just")return r._1.target.tag==="RelabelWindow"?w("Just",E(n,cl("RelabelingNode",{oldLabel:r._1.target._2,newLabel:r._1.target._3,progress:ui(r._1)(e)}))):y;if(r.tag==="Nothing"){if(sN(t)(n)){const o=gN(t)(e)(n);if(o.tag==="Just")return w("Just",E(n,cl("StaticNodeLabel",o._1)));if(o.tag==="Nothing")return y;g()}return y}g()})((()=>{const n=r=>{if(r.tag==="Leaf")return O;if(r.tag==="Node")return ee("Node",r._1,r._2,r._3,void 0,n(r._5),n(r._6));g()};return It(xn.foldr,n(t.layout.nodes))})())),wN=t=>e=>n=>r=>o=>{const i=Qa(e)(n)(a=>a.target.tag==="EdgeWindow"&&a.target._2.tag==="Retract"&&a.target._1===o);if(i.tag==="Just"){const a=Hi(t.timing.edgeEasing)(ui(i._1)(n)),s=i._1.target.tag==="EdgeWindow"?i._1.target._2:eu("Extend",Zg);if(s.tag==="Retract")return na("Retracting",s._1,a);if(s.tag==="Extend")return na("Extending",s._1,a);g()}if(i.tag==="Nothing"){if(uN(e)(n)(o))return cu;const a=Qa(e)(n)(s=>s.target.tag==="EdgeWindow"&&s.target._1===o);if(a.tag==="Just"){const s=Hi(t.timing.edgeEasing)(ui(a._1)(n)),u=a._1.target.tag==="EdgeWindow"?a._1.target._2:eu("Extend",Zg);if(u.tag==="Retract")return na("Retracting",u._1,s);if(u.tag==="Extend")return na("Extending",u._1,s);g()}if(a.tag==="Nothing")return dN(e)(n)(o)?cu:n_(o)(r)?gu:cu}g()},TN=t=>e=>n=>{const r=Wg(e)(n);return HT(Y(o=>E(o,wN(t)(e.windows)(n)(r)(o)))((()=>{const o=i=>{if(i.tag==="Leaf")return O;if(i.tag==="Node")return ee("Node",i._1,i._2,i._3,void 0,o(i._5),o(i._6));g()};return It(xn.foldr,o(e.layout.edges))})()))},NN=t=>e=>n=>r=>{const o=Qa(t)(e)(i=>i.target.tag==="NodeWindow"&&i.target._1===r&&i.target._2==="PlopOut");if(o.tag==="Just"){const i=ui(o._1)(e),a=o._1.target.tag==="NodeWindow"?o._1.target._2:zg;if(a==="PlopIn")return ai("PloppingIn",i);if(a==="PlopOut")return ai("PloppingOut",i);g()}if(o.tag==="Nothing"){if(_N(t)(e)(r))return uu;const i=Qa(t)(e)(a=>a.target.tag==="NodeWindow"&&a.target._1===r);if(i.tag==="Just"){const a=ui(i._1)(e),s=i._1.target.tag==="NodeWindow"?i._1.target._2:zg;if(s==="PlopIn")return ai("PloppingIn",a);if(s==="PlopOut")return ai("PloppingOut",a);g()}if(i.tag==="Nothing")return fN(t)(e)(r)?uu:e_(r)(n)?Xg:uu}g()},vN=t=>e=>{const n=Og(t)(e);return t_(Y(r=>E(r,NN(t.windows)(e)(n)(r)))((()=>{const r=o=>{if(o.tag==="Leaf")return O;if(o.tag==="Node")return ee("Node",o._1,o._2,o._3,void 0,r(o._5),r(o._6));g()};return It(xn.foldr,r(t.layout.nodes))})()))},bN=t=>e=>n=>e.target.tag==="TokenWindow"?E(e.target._1,n<e.startT?Yg:n>=e.endT?gl:su("Travelling",{edge:e.target._2,direction:e.target._3,progress:Hi(t.timing.tokenEasing)(ui(e)(n)),labels:e.target._6,source:e.target._4,target:e.target._5,holdPre:e.target._7,holdPost:e.target._8})):e.target.tag==="FillWindow"?E(e.target._1,n<e.startT?Yg:n>=e.endT?gl:su("Filling",{node:e.target._2,progress:ui(e)(n),labels:e.target._3})):E("",Yg),CN=t=>e=>n=>$T(Y(r=>bN(t)(r)(n))(_t(r=>r.target.tag==="TokenWindow"||r.target.tag==="FillWindow",e))),LN=t=>e=>n=>({animationTime:n,nodes:vN(e)(n),nodeLabels:JN(e)(n),edgeEndpoints:e.edgeEndpoints,edges:TN(t)(e)(n),tokens:CN(t)(e.windows)(n),camera:Ko(t.cameraConfig)(e.layout)(t.cameraSpans)(n).camera,frameTitle:lN(e)(n),staticKind:hN(e)(n),visited:aN(t.timing.hatchHold)(e.windows)(n),nodeFadeAlpha:O,nodeLabelFadeAlpha:O,edgeFadeAlpha:O,nodeInvert:O}),oa=t=>e=>n=>r=>({segment:n,state:LN(t)(n)(e),bgAlpha:1,minis:kN(t)(e)(n),role:r}),kN=t=>e=>n=>ht(r=>{const o=fu(t)(Et(n.path)(r))(e);if(o.tag==="Just")return w("Just",{...oa(t)(qT(o._1.startT)(o._1.endT-1e-4)(e))(o._1)(hl),bgAlpha:0});if(o.tag==="Nothing")return y;g()})((()=>{const r=o=>{if(o.tag==="Leaf")return O;if(o.tag==="Node")return ee("Node",o._1,o._2,o._3,void 0,r(o._5),r(o._6));g()};return It(xn.foldr,r(n.layout.nodes))})()),SN=t=>e=>{if(t.direction==="DiveIn")return yl(e);if(t.direction==="DiveOut")return t.startT-1e-4;g()},EN=t=>e=>n=>e>=1?n:tN(r=>o=>o.tag==="Hidden"?uu:ai("PloppingIn",In(.4)(xN(t)(r)(e))))(r=>r.tag==="Retracted"?cu:gu)(n),Tl=t=>e=>ht(n=>{const r=te(o=>o.direction==="DiveIn"&&ra.eq(o.childPath)((()=>{const i=n.length+1|0;return i<1?[]:Bt(0,i,e)})()))(t.dives);if(r.tag==="Just"){const o=fu(t)(n)(r._1.startT-1e-4);if(o.tag==="Just")return w("Just",(()=>{const i=oa(t)(r._1.startT-1e-4)(o._1)(hl);return{...i,state:{...i.state,nodeFadeAlpha:ee("Node",1,1,r._1.node,0,O,O)}}})());if(o.tag==="Nothing")return y;g()}if(r.tag==="Nothing")return y;g()})(XT(e)),Nl=t=>e=>{const n=_t(o=>e>=o.startT&&e<o.endT,t.segments),r=n.length-1|0;return r>=0&&r<n.length?n[r]:YT(t)},PN=t=>e=>n=>r=>{const o=c=>{const _=oa(t)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT;g()})())(c)(UT);return{..._,bgAlpha:1,minis:(()=>{if(n.direction==="DiveIn")return _t(f=>!ra.eq(f.segment.path)(n.childPath),_.minis);if(n.direction==="DiveOut")return n.childPath.length>1?ZT(n.childPath)(Ma(n)(e))(du(t)(n.startT)(_).minis):du(t)(n.startT)(_).minis;g()})(),state:{..._.state,edgeFadeAlpha:O,nodeFadeAlpha:ee("Node",1,1,n.node,0,O,O),nodeInvert:O,tokens:O}}},i=fu(t)(n.parentPath)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT;g()})()),a=fu(t)(n.childPath)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})()),s=n.direction==="DiveOut"&&n.childPath.length>1?1-Ma(n)(e):1,u=In(0)(si(1)((Ma(n)(e)-.25)/.55));return[...Tl(t)(n.parentPath),...(()=>{if(i.tag==="Just"){if(a.tag==="Just")return[o(i._1),(()=>{const c=ml(a._1)(oa(t)(SN(n)(a._1))(a._1)(dn)),_={...c,bgAlpha:s,state:{...c.state,tokens:O,nodeInvert:O,visited:O}};if(n.direction==="DiveIn")return EN(t.seed)(u)(_);if(n.direction==="DiveOut")return du(t)(n.startT)(_);g()})()];if(a.tag==="Nothing")return[o(i._1)];g()}if(i.tag==="Nothing")return[oa(t)(e)(Nl(t)(e))(dn)];g()})()]},GN=t=>e=>te(n=>e>=n.startT&&e<n.endT)(t.dives),AN=t=>e=>{const n=Nl(t)(e),r=t.dives.length!==0,o=Ko(t.cameraConfig)(t.layout)(t.cameraSpans)(e).camera,i=ET(t.cameraConfig)(t.cameraViewport)(t.layout)(n)(e)(o),a=Tl(t)(n.path),s=iN(e)(n)(oa(t)(n.path.length===0?e:In(e)(yl(n)))(n)(dn)),u={...s,state:{...s.state,camera:i}},c=GN(t)(e);if(c.tag==="Just"){const _=Ma(c._1)(e);return{levels:PN(t)(e)(c._1)(mN(t)(e)(c._1)),camera:o,rootLayout:t.layout,hasDives:r,portalState:(()=>{if(c._1.direction==="DiveIn")return _u("Opening",In(0)(si(1)(_)));if(c._1.direction==="DiveOut")return _u("Closing",In(0)(si(1)(_)));g()})()}}if(c.tag==="Nothing")return{levels:Et(a)(u),camera:i,rootLayout:t.layout,hasDives:r,portalState:n.path.length===0?ll:VT};g()},BN=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},RN=t=>{const e=t.length;return(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(u>=e){a=!1,s=c;continue}const _=f=>l=>{let d=f,h=l,m=!0,p;for(;m;){const x=d,J=h;if(x>=e){m=!1,p=J;continue}if(u>=0&&u<t.length){if(x>=0&&x<t.length){d=x+1|0,h=(()=>{const T=t[u].position,N=t[u].size,k=t[x].position,C=t[x].size;return T._1<k._1+C._1&&k._1<T._1+N._1&&T._2<k._2+C._2&&k._2<T._2+N._2})()?J+1|0:J;continue}d=x+1|0,h=J;continue}m=!1,p=J}return p};o=u+1|0,i=_(u+1|0)(c)}return s})(0)(0)},vl=t=>v(e=>n=>e+ux(n.start)(n.end))(0)(t.segments),DN=t=>e=>n=>({crossingCount:v(r=>o=>r+o.jumps.length|0)(0)(e),bendCount:v(r=>o=>r+o.bends.length|0)(0)(e),totalEdgeLength:v(r=>o=>r+vl(o))(0)(e),maxEdgeLength:v(r=>o=>BN(r)(vl(o)))(0)(e),nodeOverlapCount:RN(t),constraintViolations:n,jumpCount:v(r=>o=>r+o.jumps.length|0)(0)(e)}),o_=t=>t,le=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},i_=o_("LEFT"),FN=o_("RIGHT"),bl=o_("UNDEFINED"),zN={eq:t=>e=>t==="LEFT"?e==="LEFT":t==="RIGHT"?e==="RIGHT":t==="UP"?e==="UP":t==="DOWN"?e==="DOWN":t==="UNDEFINED"&&e==="UNDEFINED"},IN={compare:t=>e=>{if(t==="LEFT")return e==="LEFT"?sn:Qe;if(e==="LEFT")return Me;if(t==="RIGHT")return e==="RIGHT"?sn:Qe;if(e==="RIGHT")return Me;if(t==="UP")return e==="UP"?sn:Qe;if(e==="UP")return Me;if(t==="DOWN")return e==="DOWN"?sn:Qe;if(e==="DOWN")return Me;if(t==="UNDEFINED"&&e==="UNDEFINED")return sn;g()},Eq0:()=>zN},QN=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){if(t==="LEFT"){if(i._3==="LEFT"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="LEFT"){n=i._6;continue}if(t==="RIGHT"){if(i._3==="RIGHT"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="RIGHT"){n=i._6;continue}if(t==="UP"){if(i._3==="UP"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="UP"){n=i._6;continue}if(t==="DOWN"){if(i._3==="DOWN"){r=!1,o=!0;continue}n=i._5;continue}if(i._3==="DOWN"){n=i._6;continue}if(t==="UNDEFINED"&&i._3==="UNDEFINED"){r=!1,o=!0;continue}}g()}return o},MN={x:0,y:0},Qn=t=>e=>n=>{const r=le(t)(n.cNodes);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cNodes:it(ut)(t)(e(r._1))(n.cNodes)};g()},Oa=t=>e=>n=>{const r=le(t)(n.cGroups);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cGroups:it(ut)(t)(e(r._1))(n.cGroups)};g()},ON=t=>v(e=>n=>Qn(n)(r=>({...r,hitboxPreCompaction:r.hitbox}))(e))(t)(t.cNodeOrder),WN=t=>{const e=v(n=>r=>{const o=le(r)(t.cNodes);if(o.tag==="Nothing")return n;if(o.tag==="Just")return v(i=>a=>Ot(ut)(Je)(a)([r])(i))(n)(o._1.constraints);g()})(O)(t.cNodeOrder);return v(n=>r=>Qn(r)(o=>({...o,constraints:(()=>{const i=le(r)(e);if(i.tag==="Nothing")return[];if(i.tag==="Just")return i._1;g()})()}))(n))(t)(t.cNodeOrder)},HN=t=>e=>Qn(t)(n=>({...n,ignoreSpacing:{left:n.ignoreSpacing.left||e.left,right:n.ignoreSpacing.right||e.right,up:n.ignoreSpacing.up||e.up,down:n.ignoreSpacing.down||e.down}})),$N=t=>{const e=v(n=>r=>Oa(r)(o=>({...o,outDegree:o.outDegreeReal}))(n))(t)(t.cGroupOrder);return v(n=>r=>Qn(r)(o=>({...o,startPos:-1e308}))(n))(e)(e.cNodeOrder)},hr={left:!1,right:!1,up:!1,down:!1},qN={horizontalSpacing:t=>e=>0,verticalSpacing:t=>e=>0},a_=t=>v(e=>n=>{const r=le(n)(e.cGroups);if(r.tag==="Nothing")return e;if(r.tag==="Just"){const o=v(a=>s=>{const u=le(s)(e.cNodes);if(u.tag==="Nothing")return a;if(u.tag==="Just"){if(a.tag==="Nothing")return w("Just",s);if(a.tag==="Just"){const c=le(a._1)(e.cNodes);if(c.tag==="Nothing")return w("Just",s);if(c.tag==="Just")return u._1.hitbox.x<c._1.hitbox.x?w("Just",s):w("Just",a._1)}}g()})(y)(r._1.cNodes),i=Oa(n)(a=>({...a,reference:o}))(e);if(o.tag==="Nothing")return i;if(o.tag==="Just"){const a=le(o._1)(i.cNodes);if(a.tag==="Nothing")return i;if(a.tag==="Just"){const s=a._1;return v(u=>c=>Qn(c)(_=>({..._,cGroupOffset:{x:_.hitbox.x-s.hitbox.x,y:_.hitbox.y-s.hitbox.y}}))(u))(i)(r._1.cNodes)}}}g()})(t)(t.cGroupOrder),Mn=t=>a_({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return O;if(n.tag==="Node")return ee("Node",n._1,n._2,n._3,{...n._4,hitbox:{...n._4.hitbox,x:-n._4.hitbox.x-n._4.hitbox.width}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),Rr=t=>a_({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return O;if(n.tag==="Node")return ee("Node",n._1,n._2,n._3,{...n._4,hitbox:{x:n._4.hitbox.y,y:n._4.hitbox.x,width:n._4.hitbox.height,height:n._4.hitbox.width},cGroupOffset:{x:n._4.cGroupOffset.y,y:n._4.cGroupOffset.x}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),Cl=t=>{const e=v(n=>r=>Oa(r)(o=>({...o,outDegree:0,outDegreeReal:0,incomingConstraints:[]}))(n))(t)(t.cGroupOrder);return v(n=>r=>{const o=le(r)(n.cNodes);if(o.tag==="Nothing")return n;if(o.tag==="Just"){if(o._1.cGroup.tag==="Nothing")return n;if(o._1.cGroup.tag==="Just"){const i=o._1.cGroup._1;return v(a=>s=>{const u=le(s)(a.cNodes);if(u.tag==="Nothing")return a;if(u.tag==="Just")return u._1.cGroup.tag==="Just"&&u._1.cGroup._1!==i?Oa(u._1.cGroup._1)(c=>({...c,outDegree:c.outDegree+1|0,outDegreeReal:c.outDegreeReal+1|0}))(Oa(i)(c=>mn(io)(s)(c.incomingConstraints)?c:{...c,incomingConstraints:[...c.incomingConstraints,s]})(a)):a;g()})(n)(o._1.constraints)}}g()})(e)(e.cNodeOrder)},lu=t=>{const e=WN(t.cGraph);return{...t,cGraph:Cl(v(n=>r=>Qn(r)(o=>({...o,startPos:-1e308}))(n))(e)(e.cNodeOrder))}},VN=t=>e=>v(n=>r=>{if(t==="LEFT"||t==="UP"){const i=r._2;return Qn(r._1)(a=>({...a,constraints:[...a.constraints,i]}))(n)}const o=r._1;return Qn(r._2)(i=>({...i,constraints:[...i.constraints,o]}))(n)})(e)(t==="LEFT"||t==="RIGHT"?e.predefinedHorizontalConstraints:e.predefinedVerticalConstraints),pr=t=>{const e={...t,cGraph:VN(t.direction)({...t.cGraph,cNodes:(()=>{const n=r=>{if(r.tag==="Leaf")return O;if(r.tag==="Node")return ee("Node",r._1,r._2,r._3,{...r._4,constraints:[]},n(r._5),n(r._6));g()};return n(t.cGraph.cNodes)})()})};return{...e,cGraph:Cl((()=>{if(e.constraintAlgorithm.tag==="Nothing")return e.cGraph;if(e.constraintAlgorithm.tag==="Just")return e.constraintAlgorithm._1(e);g()})())}},UN=t=>e=>n=>{const r={...n,direction:e};if(t==="UNDEFINED")return e==="LEFT"?pr(r):e==="RIGHT"?pr({...r,cGraph:Mn(r.cGraph)}):e==="UP"?pr({...r,cGraph:Rr(r.cGraph)}):e==="DOWN"?pr({...r,cGraph:Mn(Rr(r.cGraph))}):r;if(t==="LEFT")return e==="RIGHT"?lu({...r,cGraph:Mn(r.cGraph)}):e==="UP"?pr({...r,cGraph:Rr(r.cGraph)}):e==="DOWN"?pr({...r,cGraph:Mn(Rr(r.cGraph))}):r;if(t==="RIGHT")return e==="LEFT"?lu({...r,cGraph:Mn(r.cGraph)}):e==="UP"?pr({...r,cGraph:Rr(Mn(r.cGraph))}):e==="DOWN"?pr({...r,cGraph:Mn(Rr(Mn(r.cGraph)))}):r;if(t==="UP")return e==="LEFT"?pr({...r,cGraph:Rr(r.cGraph)}):e==="RIGHT"?pr({...r,cGraph:Mn(Rr(r.cGraph))}):e==="DOWN"?lu({...r,cGraph:Mn(r.cGraph)}):r;if(t==="DOWN")return e==="LEFT"?pr({...r,cGraph:Rr(Mn(r.cGraph))}):e==="RIGHT"?pr({...r,cGraph:Mn(Rr(Mn(r.cGraph)))}):e==="UP"?lu({...r,cGraph:Mn(r.cGraph)}):r;g()},Ll=t=>e=>e.finished||!QN(t)(e.cGraph.supportedDirections)||(t==="LEFT"?e.direction==="LEFT":t==="RIGHT"?e.direction==="RIGHT":t==="UP"?e.direction==="UP":t==="DOWN"?e.direction==="DOWN":t==="UNDEFINED"&&e.direction==="UNDEFINED")?e:UN(e.direction)(t)(e),KN=t=>{if(t.finished)return t;const e=t.direction==="UNDEFINED"?Ll(i_)(t):t,n={...e,cGraph:$N(e.cGraph)};if(n.compactionAlgorithm.tag==="Nothing")return n;if(n.compactionAlgorithm.tag==="Just")return n.compactionAlgorithm._1(n);g()},kl=t=>e=>n=>{const r=le(t)(n.cNodes),o=le(e)(n.cGroups);return r.tag==="Just"&&o.tag==="Just"?(()=>{if(r._1.cGroup.tag==="Nothing")return!1;if(r._1.cGroup.tag==="Just")return!0;g()})()&&(r._1.cGroup.tag==="Nothing"||!(r._1.cGroup.tag==="Just"&&r._1.cGroup._1===e))?n:{...n,cNodes:it(ut)(t)({...r._1,cGroup:w("Just",e)})(n.cNodes),cGroups:it(ut)(e)({...o._1,cNodes:mn(io)(t)(o._1.cNodes)?o._1.cNodes:[...o._1.cNodes,t],reference:(()=>{if(o._1.reference.tag==="Nothing")return w("Just",t);if(o._1.reference.tag==="Just")return w("Just",o._1.reference._1);g()})()})(n.cGroups)}:n},Sl=t=>e=>({id:e.nextCNodeId,graph:{...e,cNodes:it(ut)(e.nextCNodeId)({id:e.nextCNodeId,origin:t.origin,kind:t.kind,cGroup:y,cGroupOffset:MN,hitbox:t.hitbox,hitboxPreCompaction:t.hitbox,constraints:[],startPos:-1e308,ignoreSpacing:hr})(e.cNodes),cNodeOrder:[...e.cNodeOrder,e.nextCNodeId],nextCNodeId:e.nextCNodeId+1|0}}),s_=t=>e=>{const n=e.nextCGroupId;return{id:n,graph:v(r=>o=>kl(o)(n)(r))({...e,cGroups:it(ut)(n)({id:n,master:t.master,cNodes:[],startPos:-1e308,incomingConstraints:[],outDegree:0,outDegreeReal:0,reference:y,delta:0,deltaNormalized:0})(e.cGroups),cGroupOrder:[...e.cGroupOrder,n],nextCGroupId:n+1|0})(t.nodes)}},YN=t=>v(e=>n=>{const r=le(n)(e.cNodes);return r.tag==="Just"&&r._1.cGroup.tag==="Nothing"?s_({master:y,nodes:[n]})(e).graph:e})(t)(t.cNodeOrder),XN=t=>({cGraph:ON(YN(a_(t))),direction:bl,compactionAlgorithm:y,constraintAlgorithm:y,spacingsHandler:qN,lockFun:y,finished:!1}),ZN=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},jN=t=>e=>{const n=at.compare(t._1)(e._1);return n==="LT"?Qe:n==="GT"?Me:ut.compare(t._2)(e._2)},tv=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),El=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Pl=t=>t.kind.tag==="Nothing"?!1:t.kind.tag==="Just"&&t.kind._1==="vs",Gl=t=>t.kind.tag==="Nothing"||!(t.kind.tag==="Just"&&t.kind._1==="vs"),hu=t=>e=>jN(E(t.hitbox.x+t.hitbox.width/2,t.id))(E(e.hitbox.x+e.hitbox.width/2,e.id)),ev=t=>e=>{const n=zo(Xt,y,r=>hu(t)(r)==="LT",e);if(n.tag==="Just"){const r=Y1(Xt,y,n._1,t,e);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return Et(e)(t);g()},Al=t=>e=>{const n=_t(o=>hu(o)(t)==="LT",e),r=n.length-1|0;return r>=0&&r<n.length?w("Just",n[r]):y},nv=t=>e=>{const n=ev(e)(t.intervals),r=te(i=>hu(e)(i)==="LT")(n),o=it(ut)(e.id)((()=>{const i=Al(e)(n);return i.tag==="Just"?w("Just",i._1.id):y})())(t.cand);return{...t,intervals:n,cand:(()=>{if(r.tag==="Just")return it(ut)(r._1.id)(w("Just",e.id))(o);if(r.tag==="Nothing")return o;g()})()}},rv=t=>e=>{const n=at.compare(t.low?t.node.hitbox.y:t.node.hitbox.y+t.node.hitbox.height)(e.low?e.node.hitbox.y:e.node.hitbox.y+e.node.hitbox.height);return n==="EQ"?t.low?t.low&&!e.low?Me:sn:e.low?Qe:sn:n},ov=t=>v(e=>n=>Qn(n.id)(r=>({...r,constraints:[]}))(e))(t)(ht(e=>le(e)(t.cNodes))(t.cNodeOrder)),u_=t=>e=>v(n=>r=>{const o=le(r._1)(n.cNodes);if(o.tag==="Just")return Qn(r._1)(i=>({...i,constraints:[...i.constraints,...r._2]}))(n);if(o.tag==="Nothing")return n;g()})(e)(tv(t)),Bl=t=>e=>e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?e.ignoreSpacing.up?e.ignoreSpacing.down?e:{...e,hitbox:{...e.hitbox,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t-.01,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t,height:e.hitbox.height+2*t}},Rl=t=>e=>n=>v(r=>o=>n(o)?Qn(o.id)(Bl(t))(r):r)(e)(ht(r=>le(r)(e.cNodes))(e.cNodeOrder)),iv=t=>e=>{const n=(r,o,i)=>{const a=Qn(i)(Bl(t))(r);return o.length<=1?a:v(s=>u=>u===i?s:Qn(u)(c=>c.ignoreSpacing.up?{...c,hitbox:{...c.hitbox,y:c.hitbox.y+t+.01,height:c.hitbox.height-t-.01}}:c.ignoreSpacing.down?{...c,hitbox:{...c.hitbox,height:c.hitbox.height-t-.01}}:c)(s))(a)(o)};return v(r=>o=>{if(o.master.tag==="Nothing")return 0<o.cNodes.length?n(r,o.cNodes,o.cNodes[0]):r;if(o.master.tag==="Just")return n(r,o.cNodes,o.master._1);g()})(e)(ht(r=>le(r)(e.cGroups))(e.cGroupOrder))},av=t=>e=>{const n=Al(e)(t.intervals),r=te(i=>hu(e)(i)==="LT")(t.intervals),o=n.tag==="Just"&&(()=>{const i=El(e.id)(t.cand);return(i.tag==="Nothing"?!1:i.tag==="Just"&&(i._1.tag==="Nothing"?!1:i._1.tag==="Just"&&i._1._1===n._1.id))&&n._1.cGroup.tag==="Just"&&e.cGroup.tag==="Just"&&n._1.cGroup._1!==e.cGroup._1})()?Ot(ut)(Je)(n._1.id)([e.id])(t.constraints):t.constraints;return{...t,constraints:r.tag==="Just"&&(()=>{const i=El(r._1.id)(t.cand);return(i.tag==="Nothing"?!1:i.tag==="Just"&&(i._1.tag==="Nothing"?!1:i._1.tag==="Just"&&i._1._1===e.id))&&e.cGroup.tag==="Just"&&r._1.cGroup.tag==="Just"&&e.cGroup._1!==r._1.cGroup._1})()?Ot(ut)(Je)(e.id)([r._1.id])(o):o,intervals:_t(i=>i.id!==e.id,t.intervals)}},sv=t=>e=>e.low?nv(t)(e.node):av(t)(e.node),c_=t=>e=>v(sv)({intervals:[],cand:O,constraints:O})(Pt(rv)(St(_t(t,ht(n=>le(n)(e.cNodes))(e.cNodeOrder)))(n=>[{node:n,low:!0},{node:n,low:!1}]))).constraints,uv=t=>e=>{const n=ZN(0)(t/2-.5),r=u_(c_(Pl)(Rl(n)(e)(Pl)))(e),o=u_(c_(Gl)(Rl(n)(r)(Gl)))(r);return u_(c_(i=>!0)(iv(n)(o)))(o)},cv=t=>e=>uv(t)(ov(e.cGraph)),pu=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Dl=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},g_=t=>e=>n=>r=>o=>({id:t,representedEdges:[o],affectedBends:[e,n],hitbox:{x:pu(e._1)(n._1),y:pu(e._2)(n._2),width:xe(e._1-n._1),height:xe(e._2-n._2)},ignoreSpacing:hr,potentialGroupParents:(()=>{if(r.tag==="Nothing")return[];if(r.tag==="Just")return[r._1];g()})(),aPort:y}),gv=t=>e=>{const n=pu(t.hitbox.x)(e.hitbox.x),r=pu(t.hitbox.y)(e.hitbox.y);return{...t,representedEdges:[...t.representedEdges,...e.representedEdges],affectedBends:[...t.affectedBends,...e.affectedBends],potentialGroupParents:[...t.potentialGroupParents,...e.potentialGroupParents],hitbox:{x:n,y:r,width:Dl(t.hitbox.x+t.hitbox.width)(e.hitbox.x+e.hitbox.width)-n,height:Dl(t.hitbox.y+t.hitbox.height)(e.hitbox.y+e.hitbox.height)-r},ignoreSpacing:{left:t.ignoreSpacing.left||e.ignoreSpacing.left,right:t.ignoreSpacing.right||e.ignoreSpacing.right,up:t.ignoreSpacing.up||e.ignoreSpacing.up,down:t.ignoreSpacing.down||e.ignoreSpacing.down},aPort:(()=>{if(t.aPort.tag==="Just")return t.aPort;if(t.aPort.tag==="Nothing")return e.aPort;g()})()}},_v=t=>e=>xe(t.hitbox.x-e.hitbox.x)<=1e-4&&e.hitbox.y-(t.hitbox.y+t.hitbox.height)<=1e-4&&t.hitbox.y-(e.hitbox.y+e.hitbox.height)<=1e-4,fv=t=>e=>xe(t.hitbox.x-e.hitbox.x)<=1e-4?at.compare(t.hitbox.y)(e.hitbox.y):t.hitbox.x<e.hitbox.x?Qe:Me,Fl=(t,e)=>({tag:t,_1:e}),__=fe(B)(Qt),mu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},zl=(()=>{const t={eq:n=>r=>n._1===r._1&&(n._2.tag==="Nothing"?r._2.tag==="Nothing":n._2.tag==="Just"&&r._2.tag==="Just"&&n._2._1===r._2._1)},e={compare:n=>r=>{const o=B.compare(n._1)(r._1);if(o==="LT")return Qe;if(o==="GT")return Me;if(n._2.tag==="Nothing")return r._2.tag==="Nothing"?sn:Qe;if(r._2.tag==="Nothing")return Me;if(n._2.tag==="Just"&&r._2.tag==="Just")return B.compare(n._2._1)(r._2._1);g()},Eq0:()=>t};return v(n=>r=>it(e)(r)()(n))(O)})(),Zr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},dv=v(t=>e=>it(IN)(e)()(t))(O),f_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=Gf.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},lv=t=>e=>{const n=__(Y(i=>E(i.id,i))(t)),r=ht(i=>mu(i)(n))(e),o=ut.compare((()=>{const i=zl(Y(a=>E(a.from.node,a.from.port))(r));if(i.tag==="Leaf")return 0;if(i.tag==="Node")return i._2;g()})())((()=>{const i=zl(Y(a=>E(a.to.node,a.to.port))(r));if(i.tag==="Leaf")return 0;if(i.tag==="Node")return i._2;g()})());if(o==="LT")return{...hr,left:!0,right:!1};if(o==="GT")return{...hr,left:!1,right:!0};if(o==="EQ")return hr;g()},hv=t=>ht(e=>{if(e.direction==="V")return w("Just",{start:e.start,end:e.end});if(e.direction==="H")return y;g()})(t.segments),yu=t=>e=>n=>r=>{if(r.tag==="Just"){const o=Zr(n)(e);if(o.tag==="Just"){const i=te(a=>a.id===r._1)(o._1);if(i.tag==="Just")return i._1.side;if(i.tag==="Nothing")return t;g()}if(o.tag==="Nothing")return t;g()}if(r.tag==="Nothing")return t;g()},pv=t=>e=>n=>{const r=Sl({origin:w("Just",Fl("SegmentOrigin",n)),kind:w("Just","vs"),hitbox:n.hitbox})(e.cGraph),o=HN(r.id)(n.ignoreSpacing)(r.graph);return{...e,cGraph:(()=>{if(0<n.potentialGroupParents.length){const i=le(n.potentialGroupParents[0])(o.cNodes);if(i.tag==="Just"){if(i._1.cGroup.tag==="Just")return kl(r.id)(i._1.cGroup._1)(o);if(i._1.cGroup.tag==="Nothing")return o;g()}if(i.tag==="Nothing")return o;g()}return s_({master:w("Just",r.id),nodes:[r.id]})(o).graph})(),edgeToCs:v(i=>a=>Ot(B)(Je)(a)([r.id])(i))(e.edgeToCs)(n.representedEdges),lockMap:it(ut)(r.id)(lv(t)(n.representedEdges))(e.lockMap)}},mv=t=>e=>n=>{const r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),Pt(fv)(e));if(r.tag==="Nothing")return n;if(r.tag==="Just"){const o=v(i=>a=>_v(i.survivor)(a)?{...i,survivor:gv(i.survivor)(a)}:{survivor:a,merged:[...i.merged,i.survivor]})({survivor:r._1.head,merged:[]})(r._1.tail);return v(pv(t))(n)([...o.merged,o.survivor])}g()},yv=t=>({cGraph:{cNodes:O,cNodeOrder:[],cGroups:O,cGroupOrder:[],supportedDirections:dv([bl,i_,FN]),predefinedHorizontalConstraints:[],predefinedVerticalConstraints:[],nextCNodeId:0,nextCGroupId:0},nodeToC:O,edgeToCs:O,lockMap:O}),xv=t=>{const e=ot(4);return{x:t.position._1*e,y:t.position._2*e,width:t.size._1*e,height:t.size._2*e}},Jv=t=>e=>n=>v(r=>o=>{const i=Sl({origin:w("Just",Fl("NodeOrigin",o.node)),kind:y,hitbox:xv(o)})(r.cGraph),a=Zr(o.node)(t),s=(()=>{if(a.tag==="Nothing")return E(0,0);if(a.tag==="Just")return a._1;g()})();return{...r,cGraph:s_({master:w("Just",i.id),nodes:[i.id]})(i.graph).graph,nodeToC:it(B)(o.node)(i.id)(r.nodeToC),lockMap:it(ut)(i.id)((()=>{const u=s._1-s._2|0;return u<0?{...hr,left:!0}:u>0?{...hr,right:!0}:hr})())(r.lockMap)}})(n)(e),wv=t=>v(e=>n=>Ot(B)(r=>o=>E(r._1+o._1|0,r._2+o._2|0))(n.to.node)(E(1,0))(Ot(B)(r=>o=>E(r._1+o._1|0,r._2+o._2|0))(n.from.node)(E(0,1))(e)))(O)(t),Tv=t=>v(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?it(B)(n.origin._1._1)(n.hitbox.x)(e):e)(O)(ht(e=>le(e)(t.cNodes))(t.cNodeOrder)),Nv=t=>v(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?it(B)(n.origin._1._1)(n.hitbox.x-n.hitboxPreCompaction.x)(e):e)(O)(ht(e=>le(e)(t.cNodes))(t.cNodeOrder)),vv=t=>v(e=>n=>{if(n.origin.tag==="Just"&&n.origin._1.tag==="SegmentOrigin"){const r=n.hitbox.x-n.hitboxPreCompaction.x;return v(o=>i=>it(Gf)(i)(r)(o))(e)(n.origin._1._1.affectedBends)}return e})(O)(ht(e=>le(e)(t.cNodes))(t.cNodeOrder)),Il=t=>{const e=__(Y(n=>E(n.id,n))(t.edges));return ht(n=>{const r=mu(n.edge)(e);if(r.tag==="Just")return n.reversed?w("Just",{edgeId:n.edge,src:r._1.to.node,tgt:r._1.from.node,srcSide:yu(qr)(t.ports)(r._1.to.node)(r._1.to.port),tgtSide:yu(Vr)(t.ports)(r._1.from.node)(r._1.from.port),path:n}):w("Just",{edgeId:n.edge,src:r._1.from.node,tgt:r._1.to.node,srcSide:yu(qr)(t.ports)(r._1.from.node)(r._1.from.port),tgtSide:yu(Vr)(t.ports)(r._1.to.node)(r._1.to.port),path:n});if(r.tag==="Nothing")return y;g()})(t.paths)},bv=t=>e=>{const n=St(e)(r=>{if(r.src===r.tgt)return[];if((r.srcSide==="North"||r.srcSide==="South")&&(r.tgtSide==="North"||r.tgtSide==="South"))return[];const o=Zr(r.tgt)(t.nodeToC),i=(()=>{if(o.tag==="Just")return le(o._1)(t.cGraph.cNodes);if(o.tag==="Nothing")return y;g()})(),a=Zr(r.src)(t.nodeToC),s=(()=>{if(a.tag==="Just")return le(a._1)(t.cGraph.cNodes);if(a.tag==="Nothing")return y;g()})(),u=(()=>{if(s.tag==="Just"){if(i.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(i._1.cGroup.tag==="Just")return w("Just",{srcGroup:s._1.cGroup._1,tgtGroup:i._1.cGroup._1,delta:0,weight:100});if(i._1.cGroup.tag==="Nothing")return y;g()}if(s._1.cGroup.tag==="Nothing")return y;g()}if(i.tag==="Nothing")return y;g()}if(s.tag==="Nothing")return y;g()})(),c=d=>h=>m=>{if(s.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(m.cGroup.tag==="Just")return d(m.hitbox.x)&&m.cGroup._1!==s._1.cGroup._1?w("Just",h(m.cGroup._1)(s._1.cGroup._1)):y;if(m.cGroup.tag==="Nothing")return y;g()}if(s._1.cGroup.tag==="Nothing")return y;g()}if(s.tag==="Nothing")return y;g()},_=ht(d=>le(d)(t.cGraph.cNodes))((()=>{const d=mu(r.edgeId)(t.edgeToCs);if(d.tag==="Nothing")return[];if(d.tag==="Just")return d._1;g()})()),f=(()=>{if(s.tag==="Just"&&r.srcSide==="West"){const d=s._1;return ht(c(h=>h<d.hitbox.x)(h=>m=>({srcGroup:h,tgtGroup:m,delta:1,weight:100})))(_)}return[]})(),l=(()=>{if(s.tag==="Just"&&r.tgtSide==="East"){const d=s._1;return ht(c(h=>h>d.hitbox.x)(h=>m=>({srcGroup:m,tgtGroup:h,delta:1,weight:100})))(_)}return[]})();if(u.tag==="Nothing")return[];if(u.tag==="Just")return[u._1,...f,...l];g()});return{sameEdgeVerticalSegments:r=>o=>r.origin.tag==="Just"&&r.origin._1.tag==="SegmentOrigin"&&o.origin.tag==="Just"&&o.origin._1.tag==="SegmentOrigin"&&(()=>{const i=o.origin._1._1;return oe(a=>mn(kr)(a)(i.representedEdges),r.origin._1._1.representedEdges)})(),vsLNodePair:r=>o=>r.origin.tag==="Just"&&o.origin.tag==="Just"&&(r.origin._1.tag==="SegmentOrigin"?o.origin._1.tag==="NodeOrigin":r.origin._1.tag==="NodeOrigin"&&o.origin._1.tag==="SegmentOrigin"),edgeLengthEdges:r=>n}},Cv=t=>e=>{const n=ot(4),r=Tv(t),o=Nv(t),i=__(Y(s=>E(s.id,E(s.from.node,s.to.node)))(e.edges)),a=vv(t);return{nodes:Y(s=>{const u=Zr(s.node)(r);if(u.tag==="Just")return{...s,position:E(u._1/n,s.position._2)};if(u.tag==="Nothing")return s;g()})(e.nodes),edges:Y(s=>{const u=mu(s.edge)(i),c=(()=>{if(u.tag==="Nothing")return s.segments;if(u.tag==="Just"){const _=Zr(u._1._1)(o),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})(),l=Zr(u._1._2)(o),d=(()=>{if(l.tag==="Nothing")return 0;if(l.tag==="Just")return l._1;g()})();return Mt((()=>{const h=s.reversed?d:f,m=s.reversed?f:d,p=s.segments.length;return x=>J=>{if(J.direction==="V"){const T=(()=>{if(x===0)return h;if(x===(p-1|0))return m;const N=f_(J.start)(a);if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})();return{...J,start:E(J.start._1+T,J.start._2),end:E(J.end._1+T,J.end._2)}}if(J.direction==="H")return{...J,start:E((()=>{if(x===0)return J.start._1+h;const T=f_(J.start)(a);if(T.tag==="Nothing")return J.start._1+0;if(T.tag==="Just")return J.start._1+T._1;g()})(),J.start._2),end:E((()=>{if(x===(p-1|0))return J.end._1+m;const T=f_(J.end)(a);if(T.tag==="Nothing")return J.end._1+0;if(T.tag==="Just")return J.end._1+T._1;g()})(),J.end._2)};g()}})())(s.segments)}g()})();return{...s,segments:c,bends:Oe(_=>f=>_.end,c,Bt(1,c.length,c))}})(e.paths)}},Lv=t=>e=>n=>r=>o=>i=>{const a=g_(o.nextId)(i._2.start)(i._2.end)(y)(t.edgeId),s=(()=>{if(i._1===0){if(e.tag==="Nothing")return a;if(e.tag==="Just")return{...a,ignoreSpacing:i._2.end._2<e._1.y?{...a.ignoreSpacing,down:!0}:i._2.end._2>e._1.y+e._1.height?{...a.ignoreSpacing,up:!0}:{...a.ignoreSpacing,up:!0,down:!0}};g()}return a})();return{nextId:o.nextId+1|0,segments:[...o.segments,(()=>{if(i._1===r){if(n.tag==="Nothing")return s;if(n.tag==="Just")return{...s,ignoreSpacing:i._2.start._2<n._1.y?{...s.ignoreSpacing,down:!0}:i._2.start._2>n._1.y+n._1.height?{...s.ignoreSpacing,up:!0}:{...s.ignoreSpacing,up:!0,down:!0}};g()}return s})()]}},Ql=t=>e=>n=>r=>o=>i=>({nextId:i.nextId+1|0,segments:[...i.segments,{...g_(i.nextId)(r.start)(E(r.start._1,o.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.src,side:o.side}),ignoreSpacing:o.down?{...hr,down:!0}:{...hr,up:!0}}]}),xu=t=>e=>n=>r=>o=>i=>({nextId:i.nextId+1|0,segments:[...i.segments,{...g_(i.nextId)(r.end)(E(r.end._1,o.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.tgt,side:o.side}),ignoreSpacing:o.down?{...hr,down:!0}:{...hr,up:!0}}]}),kv=t=>e=>n=>{if(n.src===n.tgt)return e;const r=Zr(n.src)(t.nodeToC),o=Zr(n.tgt)(t.nodeToC),i=(()=>{if(r.tag==="Just"){const _=le(r._1)(t.cGraph.cNodes);return _.tag==="Just"?w("Just",_._1.hitbox):y}if(r.tag==="Nothing")return y;g()})(),a=(()=>{if(o.tag==="Just"){const _=le(o._1)(t.cGraph.cNodes);return _.tag==="Just"?w("Just",_._1.hitbox):y}if(o.tag==="Nothing")return y;g()})(),s=hv(n.path),u=v(Lv(n)(i)(a)(s.length-1|0))(e)(Mt(_=>f=>E(_,f))(s));if(0<s.length){const _=(()=>{if(r.tag==="Just"&&i.tag==="Just"){if(n.srcSide==="North")return Ql(n)(r._1)(i._1)(s[0])({side:De,down:!0})(u);if(n.srcSide==="South")return Ql(n)(r._1)(i._1)(s[0])({side:Fe,down:!1})(u)}return u})(),f=s.length-1|0;if(f>=0&&f<s.length&&o.tag==="Just"&&a.tag==="Just"){if(n.tgtSide==="North")return xu(n)(o._1)(a._1)(s[f])({side:De,down:!0})(_);if(n.tgtSide==="South")return xu(n)(o._1)(a._1)(s[f])({side:Fe,down:!1})(_)}return _}const c=s.length-1|0;if(c>=0&&c<s.length&&o.tag==="Just"&&a.tag==="Just"){if(n.tgtSide==="North")return xu(n)(o._1)(a._1)(s[c])({side:De,down:!0})(u);if(n.tgtSide==="South")return xu(n)(o._1)(a._1)(s[c])({side:Fe,down:!1})(u)}return u},Sv=t=>e=>n=>mv(t)(v(kv(n))({nextId:0,segments:[]})(e).segments)(n),Ev=t=>Sv(t.edges)(Il(t))(Jv(wv(t.edges))(t.nodes)(yv())),jr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},d_=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},l_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Pv=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Gv=t=>{const e=t.Eq0();return n=>r=>{const o=s=>{let u=s,c=!0,_;for(;c;){const f=u,l=Ft(d=>y,d=>h=>w("Just",{head:d,tail:h}),f.queue);if(l.tag==="Nothing"){c=!1,_=f;continue}if(l.tag==="Just"){const d=l._1.head;if((m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=!1;continue}if(T.tag==="Node"){const N=t.compare(d)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=!0;continue}}g()}return J})(f.removedNodes)){u={...f,queue:l._1.tail};continue}const h=te(m=>!jr(m.eid)(f.removedEdges)&&(e.eq(m.src)(d)||e.eq(m.tgt)(d)))(r);if(h.tag==="Nothing"){u={...f,queue:l._1.tail};continue}if(h.tag==="Just"){const m=e.eq(h._1.src)(d)?h._1.tgt:h._1.src,p={...f,degree:it(t)(m)((()=>{const x=(J=>{let T=J,N=!0,k;for(;N;){const C=T;if(C.tag==="Leaf"){N=!1,k=y;continue}if(C.tag==="Node"){const P=t.compare(m)(C._3);if(P==="LT"){T=C._5;continue}if(P==="GT"){T=C._6;continue}if(P==="EQ"){N=!1,k=w("Just",C._4);continue}}g()}return k})(f.degree);if(x.tag==="Nothing")return-1;if(x.tag==="Just")return x._1-1|0;g()})())(f.degree),removedNodes:it(t)(d)()(f.removedNodes),removedEdges:it(ut)(h._1.eid)()(f.removedEdges),record:[...f.record,{node:d,neighbour:m,viaSrc:e.eq(h._1.src)(d)}],queue:l._1.tail};if((()=>{const x=(T=>{let N=T,k=!0,C;for(;k;){const P=N;if(P.tag==="Leaf"){k=!1,C=y;continue}if(P.tag==="Node"){const G=t.compare(m)(P._3);if(G==="LT"){N=P._5;continue}if(G==="GT"){N=P._6;continue}if(G==="EQ"){k=!1,C=w("Just",P._4);continue}}g()}return C})(p.degree),J=T=>{let N=T,k=!0,C;for(;k;){const P=N;if(P.tag==="Leaf"){k=!1,C=!1;continue}if(P.tag==="Node"){const G=t.compare(m)(P._3);if(G==="LT"){N=P._5;continue}if(G==="GT"){N=P._6;continue}if(G==="EQ"){k=!1,C=!0;continue}}g()}return C};return(()=>{if(x.tag==="Nothing")return!1;if(x.tag==="Just")return x._1===1;g()})()&&!J(p.removedNodes)})()){u={...p,queue:[...p.queue,m]};continue}u=p;continue}}g()}return _},i=v(s=>u=>Ot(t)(be)(u.src)(1)(Ot(t)(be)(u.tgt)(1)(s)))(O)(r),a=o({degree:i,removedNodes:O,removedEdges:O,record:[],queue:_t(s=>{const u=(c=>{let _=c,f=!0,l;for(;f;){const d=_;if(d.tag==="Leaf"){f=!1,l=y;continue}if(d.tag==="Node"){const h=t.compare(s)(d._3);if(h==="LT"){_=d._5;continue}if(h==="GT"){_=d._6;continue}if(h==="EQ"){f=!1,l=w("Just",d._4);continue}}g()}return l})(i);if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1===1;g()},n)});return{coreNodes:_t(s=>!(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=!1;continue}if(l.tag==="Node"){const d=t.compare(s)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=!0;continue}}g()}return f})(a.removedNodes),n),coreEdges:_t(s=>!jr(s.eid)(a.removedEdges),r),removed:a.record}}},Av=t=>e=>n=>v(r=>o=>{const i=o.neighbour,a=(()=>{const s=(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=y;continue}if(l.tag==="Node"){const d=t.compare(i)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=w("Just",l._4);continue}}g()}return f})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();return it(t)(o.node)(o.viaSrc?a-1|0:a+1|0)(r)})(n)(re(e)),h_=t=>{const e=t.Eq0();return n=>r=>o=>{const i={...o,treeNode:it(t)(r)()(o.treeNode)};return v(a=>s=>{if(jr(s.eid)(a.st.edgeVisited))return a;const u={...a.st,edgeVisited:it(ut)(s.eid)()(a.st.edgeVisited)},c=e.eq(s.src)((()=>{const _=s.src,f=d=>{let h=d,m=!0,p;for(;m;){const x=h;if(x.tag==="Leaf"){m=!1,p=!1;continue}if(x.tag==="Node"){const J=t.compare(_)(x._3);if(J==="LT"){h=x._5;continue}if(J==="GT"){h=x._6;continue}if(J==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.tgt;return f(u.treeNode)&&!(d=>{let h=d,m=!0,p;for(;m;){const x=h;if(x.tag==="Leaf"){m=!1,p=!1;continue}if(x.tag==="Node"){const J=t.compare(l)(x._3);if(J==="LT"){h=x._5;continue}if(J==="GT"){h=x._6;continue}if(J==="EQ"){m=!1,p=!0;continue}}g()}return p})(u.treeNode)})()?s.src:(()=>{const _=s.tgt,f=d=>{let h=d,m=!0,p;for(;m;){const x=h;if(x.tag==="Leaf"){m=!1,p=!1;continue}if(x.tag==="Node"){const J=t.compare(_)(x._3);if(J==="LT"){h=x._5;continue}if(J==="GT"){h=x._6;continue}if(J==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.src;return f(u.treeNode)&&!(d=>{let h=d,m=!0,p;for(;m;){const x=h;if(x.tag==="Leaf"){m=!1,p=!1;continue}if(x.tag==="Node"){const J=t.compare(l)(x._3);if(J==="LT"){h=x._5;continue}if(J==="GT"){h=x._6;continue}if(J==="EQ"){m=!1,p=!0;continue}}g()}return p})(u.treeNode)})()?s.tgt:s.src)?s.tgt:s.src;if(jr(s.eid)(u.treeEdge)){if((f=>{let l=f,d=!0,h;for(;d;){const m=l;if(m.tag==="Leaf"){d=!1,h=!1;continue}if(m.tag==="Node"){const p=t.compare(c)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){d=!1,h=!0;continue}}g()}return h})(u.treeNode))return{...a,st:u};const _=h_(t)(n)(c)(u);return{count:a.count+_.count|0,st:_.st}}if((()=>{const _=l=>{let d=l,h=!0,m;for(;h;){const p=d;if(p.tag==="Leaf"){h=!1,m=!1;continue}if(p.tag==="Node"){const x=t.compare(c)(p._3);if(x==="LT"){d=p._5;continue}if(x==="GT"){d=p._6;continue}if(x==="EQ"){h=!1,m=!0;continue}}g()}return m},f=s.tgt;return!_(u.treeNode)&&(()=>{const l=(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=y;continue}if(T.tag==="Node"){const N=t.compare(f)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=w("Just",T._4);continue}}g()}return J})(u.layer),d=s.src,h=(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=y;continue}if(T.tag==="Node"){const N=t.compare(d)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=w("Just",T._4);continue}}g()}return J})(u.layer);if(l.tag==="Nothing"){if(h.tag==="Nothing")return s.delta===0;if(h.tag==="Just")return s.delta===-h._1;g()}if(l.tag==="Just"){if(h.tag==="Nothing")return s.delta===(l._1-0|0);if(h.tag==="Just")return s.delta===(l._1-h._1|0)}g()})()})()){const _=h_(t)(n)(c)({...u,treeEdge:it(ut)(s.eid)()(u.treeEdge)});return{count:a.count+_.count|0,st:_.st}}return{...a,st:u}})({count:1,st:i})(_t(a=>(e.eq(a.src)(r)||e.eq(a.tgt)(r))&&!jr(a.eid)(i.edgeVisited),n))}},Ju=t=>e=>n=>r=>{const o=r.src,i=(l=>{let d=l,h=!0,m;for(;h;){const p=d;if(p.tag==="Leaf"){h=!1,m=y;continue}if(p.tag==="Node"){const x=t.compare(o)(p._3);if(x==="LT"){d=p._5;continue}if(x==="GT"){d=p._6;continue}if(x==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),a=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})(),s=r.tgt,u=(l=>{let d=l,h=!0,m;for(;h;){const p=d;if(p.tag==="Leaf"){h=!1,m=y;continue}if(p.tag==="Node"){const x=t.compare(s)(p._3);if(x==="LT"){d=p._5;continue}if(x==="GT"){d=p._6;continue}if(x==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),c=(()=>{if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()})(),_=(l=>{let d=l,h=!0,m;for(;h;){const p=d;if(p.tag==="Leaf"){h=!1,m=y;continue}if(p.tag==="Node"){const x=t.compare(n)(p._3);if(x==="LT"){d=p._5;continue}if(x==="GT"){d=p._6;continue}if(x==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})();return(()=>{const l=r.src,d=(h=>{let m=h,p=!0,x;for(;p;){const J=m;if(J.tag==="Leaf"){p=!1,x=y;continue}if(J.tag==="Node"){const T=t.compare(l)(J._3);if(T==="LT"){m=J._5;continue}if(T==="GT"){m=J._6;continue}if(T==="EQ"){p=!1,x=w("Just",J._4);continue}}g()}return x})(e.lowestPoID);return(()=>{if(d.tag==="Nothing")return 0<=f;if(d.tag==="Just")return d._1<=f;g()})()&&(()=>{const h=r.tgt;return f<=a&&(()=>{const m=(p=>{let x=p,J=!0,T;for(;J;){const N=x;if(N.tag==="Leaf"){J=!1,T=y;continue}if(N.tag==="Node"){const k=t.compare(h)(N._3);if(k==="LT"){x=N._5;continue}if(k==="GT"){x=N._6;continue}if(k==="EQ"){J=!1,T=w("Just",N._4);continue}}g()}return T})(e.lowestPoID);return(()=>{if(m.tag==="Nothing")return 0<=f;if(m.tag==="Just")return m._1<=f;g()})()&&f<=c})()})()})()?a>=c:a<c},Bv=t=>{const e=fe(t)(Qt);return n=>({layer:e(Y(r=>E(r,0))(n)),treeNode:O,treeEdge:O,poID:O,lowestPoID:O,cutvalue:O,postOrder:1,edgeVisited:O})},Rv=t=>e=>n=>v(r=>o=>{if((()=>{const _=o.src,f=h=>{let m=h,p=!0,x;for(;p;){const J=m;if(J.tag==="Leaf"){p=!1,x=!1;continue}if(J.tag==="Node"){const T=t.compare(_)(J._3);if(T==="LT"){m=J._5;continue}if(T==="GT"){m=J._6;continue}if(T==="EQ"){p=!1,x=!0;continue}}g()}return x},l=o.tgt,d=h=>{let m=h,p=!0,x;for(;p;){const J=m;if(J.tag==="Leaf"){p=!1,x=!1;continue}if(J.tag==="Node"){const T=t.compare(l)(J._3);if(T==="LT"){m=J._5;continue}if(T==="GT"){m=J._6;continue}if(T==="EQ"){p=!1,x=!0;continue}}g()}return x};return f(n.treeNode)===d(n.treeNode)})())return r;const i=o.tgt,a=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=y;continue}if(h.tag==="Node"){const m=t.compare(i)(h._3);if(m==="LT"){f=h._5;continue}if(m==="GT"){f=h._6;continue}if(m==="EQ"){l=!1,d=w("Just",h._4);continue}}g()}return d})(n.layer),s=o.src,u=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=y;continue}if(h.tag==="Node"){const m=t.compare(s)(h._3);if(m==="LT"){f=h._5;continue}if(m==="GT"){f=h._6;continue}if(m==="EQ"){l=!1,d=w("Just",h._4);continue}}g()}return d})(n.layer),c=(()=>{if(a.tag==="Nothing"){if(u.tag==="Nothing")return-o.delta;if(u.tag==="Just")return-u._1-o.delta|0;g()}if(a.tag==="Just"){if(u.tag==="Nothing")return(a._1-0|0)-o.delta|0;if(u.tag==="Just")return(a._1-u._1|0)-o.delta|0}g()})();return c<r.slack?{edge:w("Just",o),slack:c}:r})({edge:y,slack:1e9})(e).edge,Dv=t=>{const e=fe(t)(Qt);return n=>r=>{const o=v(i=>a=>d_(i)((()=>{const s=(u=>{let c=u,_=!0,f;for(;_;){const l=c;if(l.tag==="Leaf"){_=!1,f=y;continue}if(l.tag==="Node"){const d=t.compare(a)(l._3);if(d==="LT"){c=l._5;continue}if(d==="GT"){c=l._6;continue}if(d==="EQ"){_=!1,f=w("Just",l._4);continue}}g()}return f})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(1e9)(n);return e(Y(i=>E(i,(()=>{const a=(s=>{let u=s,c=!0,_;for(;c;){const f=u;if(f.tag==="Leaf"){c=!1,_=y;continue}if(f.tag==="Node"){const l=t.compare(i)(f._3);if(l==="LT"){u=f._5;continue}if(l==="GT"){u=f._6;continue}if(l==="EQ"){c=!1,_=w("Just",f._4);continue}}g()}return _})(r);if(a.tag==="Nothing")return-o;if(a.tag==="Just")return a._1-o|0;g()})()))(n))}},Ml=t=>{const e=t.Eq0();return n=>r=>o=>{const i=v(s=>u=>{const c=Ml(t)(n)(e.eq(u.src)(r)?u.tgt:u.src)({...s.st,edgeVisited:it(ut)(u.eid)()(s.st.edgeVisited)});return{lowest:d_(s.lowest)(c.lowest),st:c.st}})({lowest:1e9,st:o})(_t(s=>jr(s.eid)(o.treeEdge)&&(e.eq(s.src)(r)||e.eq(s.tgt)(r))&&!jr(s.eid)(o.edgeVisited),n)),a=d_(i.lowest)(i.st.postOrder);return{lowest:a,st:{...i.st,poID:it(t)(r)(i.st.postOrder)(i.st.poID),lowestPoID:it(t)(r)(a)(i.st.lowestPoID),postOrder:i.st.postOrder+1|0}}}},Ol=t=>{const e=Ml(t);return n=>r=>o=>0<n.length?e(r)(n[0])({...o,edgeVisited:O,postOrder:1,poID:O,lowestPoID:O}).st:o},Fv=t=>{const e=t.Eq0();return n=>r=>o=>_t(i=>jr(i.eid)(r.treeEdge)&&(e.eq(i.src)(o)||e.eq(i.tgt)(o)),n)},zv=t=>e=>te(n=>{const r=l_(n.eid)(e.cutvalue);return jr(n.eid)(e.treeEdge)&&(()=>{if(r.tag==="Nothing")return!1;if(r.tag==="Just")return r._1<-1e-10;g()})()})(t),Wl=t=>{const e=h_(t);return n=>r=>o=>{const i=0<n.length?w("Just",n[0]):y;if(i.tag==="Nothing")return o;if(i.tag==="Just"){const a=e(r)(i._1)({...o,edgeVisited:O,treeNode:O,treeEdge:O});if(a.count>=n.length)return a.st;const s=Rv(t)(r)(a.st);if(s.tag==="Nothing")return a.st;if(s.tag==="Just"){const u=s._1.tgt,c=(h=>{let m=h,p=!0,x;for(;p;){const J=m;if(J.tag==="Leaf"){p=!1,x=y;continue}if(J.tag==="Node"){const T=t.compare(u)(J._3);if(T==="LT"){m=J._5;continue}if(T==="GT"){m=J._6;continue}if(T==="EQ"){p=!1,x=w("Just",J._4);continue}}g()}return x})(a.st.layer),_=s._1.src,f=(h=>{let m=h,p=!0,x;for(;p;){const J=m;if(J.tag==="Leaf"){p=!1,x=y;continue}if(J.tag==="Node"){const T=t.compare(_)(J._3);if(T==="LT"){m=J._5;continue}if(T==="GT"){m=J._6;continue}if(T==="EQ"){p=!1,x=w("Just",J._4);continue}}g()}return x})(a.st.layer),l=(()=>{if(c.tag==="Nothing"){if(f.tag==="Nothing")return-s._1.delta;if(f.tag==="Just")return-f._1-s._1.delta|0;g()}if(c.tag==="Just"){if(f.tag==="Nothing")return(c._1-0|0)-s._1.delta|0;if(f.tag==="Just")return(c._1-f._1|0)-s._1.delta|0}g()})(),d=(()=>{const h=s._1.tgt;return(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=!1;continue}if(T.tag==="Node"){const N=t.compare(h)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=!0;continue}}g()}return J})(a.st.treeNode)})()?-l:l;return Wl(t)(n)(r)({...a.st,layer:v(h=>m=>(p=>{let x=p,J=!0,T;for(;J;){const N=x;if(N.tag==="Leaf"){J=!1,T=!1;continue}if(N.tag==="Node"){const k=t.compare(m)(N._3);if(k==="LT"){x=N._5;continue}if(k==="GT"){x=N._6;continue}if(k==="EQ"){J=!1,T=!0;continue}}g()}return T})(a.st.treeNode)?it(t)(m)((()=>{const p=(x=>{let J=x,T=!0,N;for(;T;){const k=J;if(k.tag==="Leaf"){T=!1,N=y;continue}if(k.tag==="Node"){const C=t.compare(m)(k._3);if(C==="LT"){J=k._5;continue}if(C==="GT"){J=k._6;continue}if(C==="EQ"){T=!1,N=w("Just",k._4);continue}}g()}return N})(a.st.layer);if(p.tag==="Nothing")return 0+d|0;if(p.tag==="Just")return p._1+d|0;g()})())(h):h)(a.st.layer)(n)})}}g()}},Iv=t=>e=>n=>r=>v(o=>i=>{if(Ju(t)(r)(i.src)(n)&&!Ju(t)(r)(i.tgt)(n)){const a=i.tgt,s=(f=>{let l=f,d=!0,h;for(;d;){const m=l;if(m.tag==="Leaf"){d=!1,h=y;continue}if(m.tag==="Node"){const p=t.compare(a)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){d=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),u=i.src,c=(f=>{let l=f,d=!0,h;for(;d;){const m=l;if(m.tag==="Leaf"){d=!1,h=y;continue}if(m.tag==="Node"){const p=t.compare(u)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){d=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),_=(()=>{if(s.tag==="Nothing"){if(c.tag==="Nothing")return-i.delta;if(c.tag==="Just")return-c._1-i.delta|0;g()}if(s.tag==="Just"){if(c.tag==="Nothing")return(s._1-0|0)-i.delta|0;if(c.tag==="Just")return(s._1-c._1|0)-i.delta|0}g()})();if(_<o.slack)return{edge:w("Just",i),slack:_}}return o})({edge:y,slack:1e9})(e).edge,Qv=t=>{const e=t.Eq0();return n=>r=>o=>i=>{const a=i.tgt,s=i.src;return v(u=>c=>{if((()=>{const _=l_(c.eid)(r.cutvalue);if(_.tag==="Just")return!0;if(_.tag==="Nothing")return!1;g()})()){const _=l_(c.eid)(r.cutvalue),f=(()=>{if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1;g()})();return e.eq(s)(c.src)||e.eq(a)(c.tgt)?u-(f-c.weight):u+(f-c.weight)}return e.eq(o)(s)?e.eq(c.src)(o)?u+c.weight:u-c.weight:e.eq(c.src)(o)?u-c.weight:u+c.weight})(i.weight)(_t(u=>u.eid!==i.eid&&(e.eq(u.src)(o)||e.eq(u.tgt)(o)),n))}},Mv=t=>{const e=Qv(t);return n=>r=>o=>{const i=(a,s,u)=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=y;continue}if(h.tag==="Node"){const m=t.compare(a)(h._3);if(m==="LT"){f=h._5;continue}if(m==="GT"){f=h._6;continue}if(m==="EQ"){l=!1,d=w("Just",h._4);continue}}g()}return d})(u);if(c.tag==="Just")return it(t)(a)(_t(_=>_.eid!==s.eid,c._1))(u);if(c.tag==="Nothing")return u;g()};return(a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c,h=(p=>{let x=p,J=!0,T;for(;J;){const N=x;if(N.tag==="Leaf"){J=!1,T=y;continue}if(N.tag==="Node"){const k=t.compare(d)(N._3);if(k==="LT"){x=N._5;continue}if(k==="GT"){x=N._6;continue}if(k==="EQ"){J=!1,T=w("Just",N._4);continue}}g()}return T})(l.unknown),m=(()=>{if(h.tag==="Nothing")return[];if(h.tag==="Just")return h._1;g()})();if(m.length===1){const p=t.Eq0().eq(m[0].src)(d)?m[0].tgt:m[0].src;u={unknown:i(d,m[0],i(p,m[0],l.unknown)),cutvalue:it(ut)(m[0].eid)(e(n)(l)(d)(m[0]))(l.cutvalue)},c=p;continue}_=!1,f=l}return f})(r)(o)}},Hl=t=>{const e=t.Eq0(),n=t.Eq0(),r={eq:c=>_=>c.delta===_.delta&&c.eid===_.eid&&n.eq(c.src)(_.src)&&e.eq(c.tgt)(_.tgt)&&c.weight===_.weight},o={compare:c=>_=>{const f=ut.compare(c.delta)(_.delta);if(f==="LT"||f==="GT"||f!=="EQ")return f;const l=ut.compare(c.eid)(_.eid);if(l==="LT"||l==="GT"||l!=="EQ")return l;const d=t.compare(c.src)(_.src);if(d==="LT"||d==="GT"||d!=="EQ")return d;const h=t.compare(c.tgt)(_.tgt);if(h==="LT"||h==="GT"||h!=="EQ")return h;const m=at.compare(c.weight)(_.weight);return m==="LT"||m==="GT"||m!=="EQ"?m:sn},Eq0:()=>r},i=v(c=>_=>it(o)(_)()(c))(O),a=Fv(t),s=fe(t)(Qt),u=Mv(t);return c=>_=>f=>{const l={unknown:s(Y(d=>E(d,It(xn.foldr,i(a(_)(f)(d)))))(c)),cutvalue:O};return{...f,cutvalue:v(u(_))(l)(_t(d=>{const h=(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=y;continue}if(T.tag==="Node"){const N=t.compare(d)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=w("Just",T._4);continue}}g()}return J})(l.unknown);if(h.tag==="Nothing")return!1;if(h.tag==="Just")return h._1.length===1;g()},c)).cutvalue}}},Ov=t=>{const e=Ol(t),n=Hl(t);return r=>o=>i=>a=>s=>{const u={...s,treeEdge:it(ut)(a.eid)()(Qi(ut)(i.eid)(s.treeEdge))},c=a.tgt,_=(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=y;continue}if(T.tag==="Node"){const N=t.compare(c)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=w("Just",T._4);continue}}g()}return J})(u.layer),f=a.src,l=(m=>{let p=m,x=!0,J;for(;x;){const T=p;if(T.tag==="Leaf"){x=!1,J=y;continue}if(T.tag==="Node"){const N=t.compare(f)(T._3);if(N==="LT"){p=T._5;continue}if(N==="GT"){p=T._6;continue}if(N==="EQ"){x=!1,J=w("Just",T._4);continue}}g()}return J})(u.layer),d=(()=>{if(_.tag==="Nothing"){if(l.tag==="Nothing")return-a.delta;if(l.tag==="Just")return-l._1-a.delta|0;g()}if(_.tag==="Just"){if(l.tag==="Nothing")return(_._1-0|0)-a.delta|0;if(l.tag==="Just")return(_._1-l._1|0)-a.delta|0}g()})(),h=Ju(t)(u)(a.tgt)(i)?d:-d;return n(r)(o)(e(r)(o)({...u,layer:v(m=>p=>Ju(t)(u)(p)(i)?m:it(t)(p)((()=>{const x=(J=>{let T=J,N=!0,k;for(;N;){const C=T;if(C.tag==="Leaf"){N=!1,k=y;continue}if(C.tag==="Node"){const P=t.compare(p)(C._3);if(P==="LT"){T=C._5;continue}if(P==="GT"){T=C._6;continue}if(P==="EQ"){N=!1,k=w("Just",C._4);continue}}g()}return k})(u.layer);if(x.tag==="Nothing")return 0+h|0;if(x.tag==="Just")return x._1+h|0;g()})())(m))(u.layer)(r)}))}},Wv=t=>{const e=Ov(t);return n=>r=>o=>i=>(a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c;if(l===0){_=!1,f=d;continue}const h=zv(o)(d);if(h.tag==="Nothing"){_=!1,f=d;continue}if(h.tag==="Just"){const m=Iv(t)(o)(h._1)(d);if(m.tag==="Nothing"){_=!1,f=d;continue}if(m.tag==="Just"){u=l-1|0,c=e(r)(o)(h._1)(m._1)(d);continue}}g()}return f})(n)(i)},Hv=t=>{const e=Hl(t),n=Ol(t),r=Wl(t);return o=>i=>a=>e(o)(i)(n(o)(i)(r(o)(i)(a)))},$l=t=>e=>v(n=>r=>Ot(t)(Je)(e(r))([r])(n))(O),$v=t=>{const e=fe(t)(Qt);return n=>r=>o=>{const i=u=>c=>_=>f=>{let l=u,d=c,h=_,m=f,p=!0,x;for(;p;){const J=l,T=d,N=h,k=m,C=Ft(P=>y,P=>G=>w("Just",{head:P,tail:G}),N);if(C.tag==="Nothing"){p=!1,x=k;continue}if(C.tag==="Just"){const P=C._1.head,G=(S=>{let b=S,I=!0,H;for(;I;){const Q=b;if(Q.tag==="Leaf"){I=!1,H=y;continue}if(Q.tag==="Node"){const q=t.compare(P)(Q._3);if(q==="LT"){b=Q._5;continue}if(q==="GT"){b=Q._6;continue}if(q==="EQ"){I=!1,H=w("Just",Q._4);continue}}g()}return H})(k.layer),R=(()=>{if(G.tag==="Nothing")return 0;if(G.tag==="Just")return G._1;g()})(),U=v(S=>b=>{const I=b.tgt,H=(q=>{let $=q,A=!0,F;for(;A;){const M=$;if(M.tag==="Leaf"){A=!1,F=y;continue}if(M.tag==="Node"){const W=t.compare(I)(M._3);if(W==="LT"){$=M._5;continue}if(W==="GT"){$=M._6;continue}if(W==="EQ"){A=!1,F=w("Just",M._4);continue}}g()}return F})(S.incident),Q=(()=>{if(H.tag==="Nothing")return-1;if(H.tag==="Just")return H._1-1|0;g()})();return{st:{...S.st,layer:it(t)(b.tgt)(Pv((()=>{const q=b.tgt,$=(A=>{let F=A,M=!0,W;for(;M;){const D=F;if(D.tag==="Leaf"){M=!1,W=y;continue}if(D.tag==="Node"){const X=t.compare(q)(D._3);if(X==="LT"){F=D._5;continue}if(X==="GT"){F=D._6;continue}if(X==="EQ"){M=!1,W=w("Just",D._4);continue}}g()}return W})(S.st.layer);if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})())(R+b.delta|0))(S.st.layer)},incident:it(t)(b.tgt)(Q)(S.incident),queue:Q===0?[...S.queue,b.tgt]:S.queue}})({st:k,incident:T,queue:C._1.tail})((()=>{const S=(b=>{let I=b,H=!0,Q;for(;H;){const q=I;if(q.tag==="Leaf"){H=!1,Q=y;continue}if(q.tag==="Node"){const $=t.compare(P)(q._3);if($==="LT"){I=q._5;continue}if($==="GT"){I=q._6;continue}if($==="EQ"){H=!1,Q=w("Just",q._4);continue}}g()}return Q})(J);if(S.tag==="Nothing")return[];if(S.tag==="Just")return S._1;g()})());l=J,d=U.incident,h=U.queue,m=U.st;continue}g()}return x},a=$l(t)(u=>u.tgt)(r),s=e(Y(u=>E(u,(()=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=y;continue}if(h.tag==="Node"){const m=t.compare(u)(h._3);if(m==="LT"){f=h._5;continue}if(m==="GT"){f=h._6;continue}if(m==="EQ"){l=!1,d=w("Just",h._4);continue}}g()}return d})(a);if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1.length;g()})()))(n));return i($l(t)(u=>u.src)(r))(s)(_t(u=>{const c=(_=>{let f=_,l=!0,d;for(;l;){const h=f;if(h.tag==="Leaf"){l=!1,d=y;continue}if(h.tag==="Node"){const m=t.compare(u)(h._3);if(m==="LT"){f=h._5;continue}if(m==="GT"){f=h._6;continue}if(m==="EQ"){l=!1,d=w("Just",h._4);continue}}g()}return d})(s);if(c.tag==="Nothing")return!0;if(c.tag==="Just")return c._1===0;g()},n))(o)}},qv=t=>{const e=Bv(t),n=$v(t),r=Hv(t),o=Wv(t);return i=>a=>{const s=n(i)(a)(e(i));return a.length===0?s.layer:o(4*i.length|0)(i)(a)(r(i)(a)(s)).layer}},ql=t=>{const e=Dv(t),n=qv(t),r=Gv(t);return o=>i=>{if(o.length===0)return O;if(o.length<40)return e(o)(n(o)(i));const a=r(o)(i);return e(o)(Av(t)(a.removed)(n(a.coreNodes)(a.coreEdges)))}},Vl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},p_=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Vv=ql(ut),Wa=t=>e=>({...e,edges:[...e.edges,{src:t.src,tgt:t.tgt,delta:t.delta,weight:t.weight,eid:e.nextEid}],nextEid:e.nextEid+1|0}),Uv=t=>e=>n=>{if(n.cGroup.tag==="Nothing")return e;if(n.cGroup.tag==="Just"){const r=ot((()=>{const o=Vl(n.cGroup._1)(t);if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})());return Qn(n.id)(o=>({...o,hitbox:{...o.hitbox,x:r+o.cGroupOffset.x}}))(e)}g()},Kv=t=>e=>({...e,cGraph:v(Uv(t))(e.cGraph)((()=>{const n=e.cGraph;return ht(r=>le(r)(n.cNodes))(n.cNodeOrder)})())}),Yv=t=>e=>n=>r=>o=>{const i=he(vs(e.cGroupOffset.x-t.cGroupOffset.x));return Wa({src:o.nextNodeId,tgt:r,delta:p_(0)(-i),weight:1})(Wa({src:o.nextNodeId,tgt:n,delta:p_(0)(i),weight:1})({...o,nodes:[...o.nodes,o.nextNodeId],nextNodeId:o.nextNodeId+1|0}))},Xv=t=>e=>n=>r=>o=>i=>a=>{const s=p_(0)(he(vs(n.cGroupOffset.x+n.hitbox.width+(e.direction==="LEFT"||e.direction==="RIGHT"?e.spacingsHandler.horizontalSpacing(n)(r):e.spacingsHandler.verticalSpacing(n)(r))-r.cGroupOffset.x)));return t.sameEdgeVerticalSegments(n)(r)?Yv(n)(r)(o)(i)(a):Wa({src:o,tgt:i,delta:s,weight:t.vsLNodePair(n)(r)?2:1})(a)},Zv=t=>e=>n=>r=>o=>{const i=le(o)(e.cGraph.cNodes);if(i.tag==="Nothing")return r;if(i.tag==="Just")return(n.cGroup.tag==="Nothing"?i._1.cGroup.tag==="Nothing":n.cGroup.tag==="Just"&&i._1.cGroup.tag==="Just"&&n.cGroup._1===i._1.cGroup._1)?r:n.cGroup.tag==="Just"&&i._1.cGroup.tag==="Just"?Xv(t)(e)(n)(i._1)(n.cGroup._1)(i._1.cGroup._1)(r):r;g()},jv=t=>e=>n=>r=>v(Zv(t)(e)(r))(n)(r.constraints),tb=t=>e=>Wa({src:e.srcGroup,tgt:e.tgtGroup,delta:e.delta,weight:e.weight})(t),eb=t=>{const e=v(o=>i=>Ot(ut)(be)(i.tgt)(1)(o))(O)(t.edges),n=_t(o=>{const i=Vl(o)(e);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return i._1===0;g()},t.nodes);if(n.length<=1)return t;const r=t.nextNodeId;return v(o=>i=>Wa({src:r,tgt:i,delta:1,weight:0})(o))({...t,nodes:[...t.nodes,r],nextNodeId:r+1|0})(n)},nb=t=>e=>{const n=eb(v(tb)(v(jv(t)(e))({nodes:e.cGraph.cGroupOrder,edges:[],nextNodeId:e.cGraph.nextCGroupId,nextEid:0})((()=>{const r=e.cGraph;return ht(o=>le(o)(r.cNodes))(r.cNodeOrder)})()))(t.edgeLengthEdges(e.cGraph)));return{nodes:n.nodes,edges:n.edges}},rb=t=>e=>{const n=nb(t)(e);return Kv(Vv(n.nodes)(n.edges))(e)},Ul=t=>t,Te=Ul("H"),Ne=Ul("V"),ob=t=>E(t._2,t._1),Kl=t=>({...t,position:E(t.position._2,t.position._1),size:E(t.size._2,t.size._1)}),ib=t=>({start:E(t.start._2,t.start._1),end:E(t.end._2,t.end._1),direction:(()=>{if(t.direction==="H")return Ne;if(t.direction==="V")return Te;g()})()}),Yl=t=>({...t,segments:Y(ib)(t.segments),bends:Y(ob)(t.bends)}),ab=t=>({nodes:Y(Kl)(t.nodes),edges:t.edges,paths:Y(Yl)(t.paths),ports:t.ports}),sb={nodeNode:8,edgeNode:4,edgeEdge:10},ub=t=>e=>({horizontalSpacing:n=>r=>{if(e.sameEdgeVerticalSegments(n)(r)||n.ignoreSpacing.right||r.ignoreSpacing.left)return 0;const o=r.kind.tag==="Nothing"?!1:r.kind.tag==="Just"&&r.kind._1==="vs";return n.kind.tag!=="Nothing"&&n.kind.tag==="Just"&&n.kind._1==="vs"?o?t.edgeEdge:t.edgeNode:o?t.edgeNode:t.nodeNode},verticalSpacing:n=>r=>{if(e.sameEdgeVerticalSegments(n)(r))return 1;if(n.hitbox.y<=r.hitbox.y?n.ignoreSpacing.down||r.ignoreSpacing.up:n.ignoreSpacing.up||r.ignoreSpacing.down)return 0;const o=r.kind.tag==="Nothing"?!1:r.kind.tag==="Just"&&r.kind._1==="vs";return n.kind.tag!=="Nothing"&&n.kind.tag==="Just"&&n.kind._1==="vs"?o?t.edgeEdge:t.edgeNode:o?t.edgeNode:t.nodeNode}}),cb=t=>e=>rb(e),gb=t=>e=>n=>{const r=ab(n),o=Ev(r),i=bv(o)(Il(r)),a=Cv(Ll(i_)(KN({...XN(o.cGraph),compactionAlgorithm:w("Just",cb()(i)),constraintAlgorithm:w("Just",cv(e.edgeEdge)),spacingsHandler:ub(e)(i)})).cGraph)({nodes:r.nodes,edges:r.edges,paths:r.paths});return{nodes:Y(Kl)(a.nodes),edges:Y(Yl)(a.edges)}},Xl=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Zl=t=>Ve(3)(t)==="$d:",_b=t=>e=>n=>v(r=>o=>{const i=Xl(o.from.node)(t),a=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})(),s=Xl(o.to.node)(t),u=(()=>{if(s.tag==="Nothing")return-a;if(s.tag==="Just")return s._1-a|0;g()})();if(u<=1)return{...r,edges:[...r.edges,o],chains:[...r.chains,{edgeId:o.id,nodes:[o.from.node,o.to.node]}]};const c=o.id,_=Y(l=>"$d:"+c+":"+ue(l))(Ut(1,u-1|0)),f=[o.from.node,..._,o.to.node];return{...r,layers:v(l=>d=>{const h=d._2,m=oy(a+d._1|0)(p=>[...p,h])(l);if(m.tag==="Nothing")return l;if(m.tag==="Just")return m._1;g()})(r.layers)(Oe(Cn,Ut(1,u-1|0),_)),edges:[...r.edges,...Oe(l=>d=>({id:c+":"+l+"->"+d,from:{node:l,port:o.from.port},to:{node:d,port:o.to.port},label:y}),f,Bt(1,f.length,f))],chains:[...r.chains,{edgeId:o.id,nodes:f}]}})({layers:n,edges:[],chains:[]})(e),jl=t=>t,ia=fe(ut)(Qt),Zt=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},th=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Lt=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},kt=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},aa=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},fb=t=>e=>{const n=ut.compare(t._1)(e._1);return n==="LT"?Qe:n==="GT"?Me:ut.compare(t._2)(e._2)},sa=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},db=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),lb=t=>t,eh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},hb=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},wu=jl("Regular"),Tu=jl("Critical"),nh=t=>e=>{const n=v(a=>s=>it(B)(s.node)(s)(a))(O)(e),r=1.25*ot(4),o=(a,s,u)=>(c=>_=>f=>{let l=c,d=_,h=f,m=!0,p;for(;m;){const x=l,J=d,T=h;if(T.critical){m=!1,p=T;continue}const N=Ft(C=>y,C=>P=>w("Just",{head:C,tail:P}),x),k=Ft(C=>y,C=>P=>w("Just",{head:C,tail:P}),J);if(N.tag==="Just"&&k.tag==="Just"){const C=N._1.head>k._1.head-a&&N._1.head<k._1.head+a?{...T,critical:!0}:N._1.head>k._1.head-r&&N._1.head<k._1.head+r?{...T,conflicts:T.conflicts+1|0}:T;if(C.critical){m=!1,p=C;continue}if(N._1.head<=k._1.head){l=N._1.tail,d=J,h=C;continue}l=x,d=k._1.tail,h=C;continue}m=!1,p=T}return p})(s)(u)({conflicts:0,critical:!1}),i=(a,s,u)=>{if(kt(v(kt)(-1e18)(s.incoming))(v(kt)(-1e18)(s.outgoing))-Lt(v(Lt)(1e18)(s.incoming))(v(Lt)(1e18)(s.outgoing))<.001||kt(v(kt)(-1e18)(u.incoming))(v(kt)(-1e18)(u.outgoing))-Lt(v(Lt)(1e18)(u.incoming))(v(Lt)(1e18)(u.outgoing))<.001)return[];const c=o(a,s.outgoing,u.incoming),_=o(a,u.outgoing,s.incoming);if(c.critical||_.critical)return[...c.critical?[{src:u.id,tgt:s.id,weight:1,kind:Tu}]:[],..._.critical?[{src:s.id,tgt:u.id,weight:1,kind:Tu}]:[]];const f=Lt(v(Lt)(1e18)(s.incoming))(v(Lt)(1e18)(s.outgoing)),l=kt(v(kt)(-1e18)(s.incoming))(v(kt)(-1e18)(s.outgoing)),d=Lt(v(Lt)(1e18)(u.incoming))(v(Lt)(1e18)(u.outgoing)),h=kt(v(kt)(-1e18)(u.incoming))(v(kt)(-1e18)(u.outgoing)),m=(1*c.conflicts|0)+(16*(v(x=>J=>J>h?x:J>=d?x+1|0:x)(0)(s.outgoing)+v(x=>J=>J>l?x:J>=f?x+1|0:x)(0)(u.incoming)|0)|0)|0,p=(1*_.conflicts|0)+(16*(v(x=>J=>J>l?x:J>=f?x+1|0:x)(0)(u.outgoing)+v(x=>J=>J>h?x:J>=d?x+1|0:x)(0)(s.incoming)|0)|0)|0;return m<p?[{src:s.id,tgt:u.id,weight:p-m|0,kind:wu}]:m>p?[{src:u.id,tgt:s.id,weight:m-p|0,kind:wu}]:m>0?[{src:s.id,tgt:u.id,weight:0,kind:wu},{src:u.id,tgt:s.id,weight:0,kind:wu}]:[]};return v(a=>s=>v(u=>c=>it(B)(c._1)(c._2)(u))(a)((()=>{const u=v(S=>b=>{const I=b.edge.from.node+"|"+(()=>{if(b.edge.from.port.tag==="Just")return b.edge.from.port._1;if(b.edge.from.port.tag==="Nothing")return"_auto_"+b.edge.id;g()})(),H=eh(I)(S.entries);if(H.tag==="Nothing")return{...S,entries:it(B)(I)({id:0,members:[b.edge.id],incoming:[b.fromPos._1],outgoing:[b.toPos._1],slot:0,mark:0,splitBy:y,splitPartner:y})(S.entries),order:[...S.order,I]};if(H.tag==="Just")return{...S,entries:it(B)(I)({...H._1,members:[...H._1.members,b.edge.id],incoming:[...Er(Q=>Q<b.fromPos._1)(H._1.incoming).init,b.fromPos._1,...Er(Q=>Q<=b.fromPos._1)(H._1.incoming).rest],outgoing:[...Er(Q=>Q<b.toPos._1)(H._1.outgoing).init,b.toPos._1,...Er(Q=>Q<=b.toPos._1)(H._1.outgoing).rest]})(S.entries)};g()})({entries:O,order:[]})(s._2),c=Mt(S=>b=>({...b,id:S}))(ht(S=>eh(S)(u.entries))(u.order));if(c.length===0)return[];const _=v(S=>b=>S.prev.tag==="Just"&&b-S.prev._1<1e-9?S:{prev:w("Just",b),out:[...S.out,b]})({prev:y,out:[]})(Pt(at.compare)([...St(c)(S=>S.incoming),...St(c)(S=>S.outgoing)])).out,f=_.length<2?.2*r:.2*v(S=>b=>{if(S.prev.tag==="Nothing")return{prev:w("Just",b),mn:S.mn};if(S.prev.tag==="Just")return{prev:w("Just",b),mn:Lt(S.mn)(b-S.prev._1)};g()})({prev:y,mn:1e18})(_).mn,l={segments:c,deps:(()=>{const S=c.length;return St(St(Ut(0,S-2|0))(b=>St(Ut(b+1|0,S-1|0))(I=>[E(b,I)])))(b=>b._1>=0&&b._1<c.length?b._2>=0&&b._2<c.length?i(f,c[b._1],c[b._2]):[]:[])})()},d=_t(S=>{if(S.kind==="Critical")return!0;if(S.kind==="Regular")return!1;g()},l.deps),h=(()=>{if(d.length<2)return l;const S=ia((()=>{const q=l.segments;return Y($=>E($.id,$.mark))((()=>{const $=q.length,A=M=>{let W=M,D=!0,X;for(;D;){const V=W,K=te(Z=>{const tt=Zt(Z)(V.inWeight);if(tt.tag==="Nothing")return!0;if(tt.tag==="Just")return tt._1===0;g()})(V.remaining);if(K.tag==="Nothing"){D=!1,X=V;continue}if(K.tag==="Just"){const Z=K._1;W={...V,inWeight:v(tt=>et=>Ot(ut)(be)(et.tgt)(-et.weight)(tt))(V.inWeight)((()=>{const tt=Zt(Z)(V.depsBySrc);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),marks:it(ut)(Z)(V.nextSource)(V.marks),nextSource:V.nextSource+1|0,outWeight:v(tt=>et=>Ot(ut)(be)(et.src)(-et.weight)(tt))(V.outWeight)((()=>{const tt=Zt(Z)(V.depsByTgt);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),remaining:_t(tt=>tt!==Z,V.remaining)};continue}g()}return X},F=M=>{let W=M,D=!0,X;for(;D;){const V=W,K=te(Z=>{const tt=Zt(Z)(V.outWeight);if(tt.tag==="Nothing")return!0;if(tt.tag==="Just")return tt._1===0;g()})(V.remaining);if(K.tag==="Nothing"){D=!1,X=V;continue}if(K.tag==="Just"){const Z=K._1;W={...V,inWeight:v(tt=>et=>Ot(ut)(be)(et.tgt)(-et.weight)(tt))(V.inWeight)((()=>{const tt=Zt(Z)(V.depsBySrc);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),marks:it(ut)(Z)(V.nextSink)(V.marks),nextSink:V.nextSink-1|0,outWeight:v(tt=>et=>Ot(ut)(be)(et.src)(-et.weight)(tt))(V.outWeight)((()=>{const tt=Zt(Z)(V.depsByTgt);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),remaining:_t(tt=>tt!==Z,V.remaining)};continue}g()}return X};return(M=>{let W=M,D=!0,X;for(;D;){const V=A(F(W));if(V.remaining.length===0){D=!1,X=Y(K=>{const Z=Zt(K.id)(V.marks),tt=(()=>{if(Z.tag==="Nothing")return K.id;if(Z.tag==="Just")return Z._1;g()})();return{...K,mark:tt<$?(tt+$|0)+1|0:tt}})(q);continue}W=(()=>{const K=tt=>{const et=Zt(tt)(V.outWeight),ft=Zt(tt)(V.inWeight);return(()=>{if(et.tag==="Nothing")return 0;if(et.tag==="Just")return et._1;g()})()-(()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()|0},Z=Pt(tt=>et=>ut.compare(K(et))(K(tt)))(V.remaining);if(0<Z.length){const tt=Z[0];return{...V,inWeight:v(et=>ft=>Ot(ut)(be)(ft.tgt)(-ft.weight)(et))(V.inWeight)((()=>{const et=Zt(tt)(V.depsBySrc);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),marks:it(ut)(tt)(V.nextSource)(V.marks),nextSource:V.nextSource+1|0,outWeight:v(et=>ft=>Ot(ut)(be)(ft.src)(-ft.weight)(et))(V.outWeight)((()=>{const et=Zt(tt)(V.depsByTgt);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),remaining:_t(et=>et!==tt,V.remaining)}}return V})()}return X})({remaining:Y(M=>M.id)(q),marks:O,inWeight:v(M=>W=>Ot(ut)(be)(W.tgt)(W.weight)(M))(O)(d),outWeight:v(M=>W=>Ot(ut)(be)(W.src)(W.weight)(M))(O)(d),depsBySrc:v(M=>W=>Ot(ut)(Je)(W.src)([W])(M))(O)(d),depsByTgt:v(M=>W=>Ot(ut)(Je)(W.tgt)([W])(M))(O)(d),nextSink:$-1|0,nextSource:$+1|0})})())})()),b=_t(q=>{const $=Zt(q.src)(S),A=Zt(q.tgt)(S);return(()=>{if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})()>(()=>{if(A.tag==="Nothing")return 0;if(A.tag==="Just")return A._1;g()})()},d);if(b.length===0)return l;const I=v(q=>$=>{if(mn(io)($.src)(q.decisions)||mn(io)($.tgt)(q.decisions))return q;const A=Zt($.src)(q.segMap),F=Zt($.tgt)(q.segMap);if(A.tag==="Just"&&F.tag==="Just"){const M=(A._1.incoming.length+A._1.outgoing.length|0)>2&&(F._1.incoming.length+F._1.outgoing.length|0)<=2,W=M?F._1:A._1;return{decisions:[...q.decisions,W.id],segMap:it(ut)(W.id)({...W,splitBy:w("Just",M?A._1.id:F._1.id)})(q.segMap)}}return q})({decisions:[],segMap:ia(Y(q=>E(q.id,q))(l.segments))})(b),H=I.segMap,Q=v(q=>$=>{const A=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)($.outgoing)),F=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)($.outgoing)),M=_t(K=>K.a.startPosition<=F&&K.a.endPosition>=A,Mt(K=>Z=>({i:K,a:Z}))(q.freeAreas));if(M.length===0){const K={...$,incoming:Pt(at.compare)($.incoming),outgoing:Pt(at.compare)([(A+F)/2]),splitPartner:w("Just",q.nextId)},Z={id:q.nextId,incoming:Pt(at.compare)([(A+F)/2]),mark:0,members:$.members,outgoing:Pt(at.compare)($.outgoing),slot:0,splitBy:y,splitPartner:w("Just",$.id)};return{segMap:it(ut)(Z.id)(Z)(it(ut)(K.id)(K)(q.segMap)),freeAreas:q.freeAreas,nextId:q.nextId+1|0}}const W=0<M.length?w("Just",M[0]):y,D=(()=>{if(W.tag==="Nothing")return{i:0,a:{startPosition:0,endPosition:0,size:0}};if(W.tag==="Just"){if(M.length===1)return W._1;const K=Y(Z=>({c:Z,rating:(()=>{const tt=(Z.a.startPosition+Z.a.endPosition)/2,et=[tt],ft=[tt],Nt=v((()=>{const mt=q.segMap;return bt=>Ht=>{const Tt=Zt(Ht.tgt)(mt);if(Tt.tag==="Nothing")return bt;if(Tt.tag==="Just"){const Vt=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),At=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),vt=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)(et)),pt=(()=>{const qt=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)(et)),jt=v(ce=>ve=>ve>At?ce:ve>=Vt?ce+1|0:ce)(0)(et)+v(ce=>ve=>ve>qt?ce:ve>=vt?ce+1|0:ce)(0)(Tt._1.incoming)|0,an=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)(et)),$e=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)(et)),$n=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),qn=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),Ze=v(ce=>ve=>ve>$e?ce:ve>=an?ce+1|0:ce)(0)(Tt._1.outgoing)+v(ce=>ve=>ve>qn?ce:ve>=$n?ce+1|0:ce)(0)($.incoming)|0;return jt===Ze?jt>0?{...bt,deps:bt.deps+2|0,crossings:bt.crossings+jt|0}:bt:{...bt,deps:bt.deps+1|0,crossings:bt.crossings+sa(jt)(Ze)|0}})(),gt=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),wt=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),Rt=Lt(v(Lt)(1e18)(ft))(v(Lt)(1e18)($.outgoing)),yt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)($.outgoing)),Ct=v(qt=>jt=>jt>wt?qt:jt>=gt?qt+1|0:qt)(0)($.outgoing)+v(qt=>jt=>jt>yt?qt:jt>=Rt?qt+1|0:qt)(0)(Tt._1.incoming)|0,Wt=Lt(v(Lt)(1e18)(ft))(v(Lt)(1e18)($.outgoing)),zt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)($.outgoing)),se=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),_e=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),pn=v(qt=>jt=>jt>zt?qt:jt>=Wt?qt+1|0:qt)(0)(Tt._1.outgoing)+v(qt=>jt=>jt>_e?qt:jt>=se?qt+1|0:qt)(0)(ft)|0;return Ct===pn?Ct>0?{...pt,deps:pt.deps+2|0,crossings:pt.crossings+Ct|0}:pt:{...pt,deps:pt.deps+1|0,crossings:pt.crossings+sa(Ct)(pn)|0}}g()}})())(v((()=>{const mt=q.segMap;return bt=>Ht=>{const Tt=Zt(Ht.src)(mt);if(Tt.tag==="Nothing")return bt;if(Tt.tag==="Just"){const Vt=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),At=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),vt=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)(et)),pt=(()=>{const qt=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)(et)),jt=v(ce=>ve=>ve>At?ce:ve>=Vt?ce+1|0:ce)(0)(et)+v(ce=>ve=>ve>qt?ce:ve>=vt?ce+1|0:ce)(0)(Tt._1.incoming)|0,an=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)(et)),$e=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)(et)),$n=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),qn=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),Ze=v(ce=>ve=>ve>$e?ce:ve>=an?ce+1|0:ce)(0)(Tt._1.outgoing)+v(ce=>ve=>ve>qn?ce:ve>=$n?ce+1|0:ce)(0)($.incoming)|0;return jt===Ze?jt>0?{...bt,deps:bt.deps+2|0,crossings:bt.crossings+jt|0}:bt:{...bt,deps:bt.deps+1|0,crossings:bt.crossings+sa(jt)(Ze)|0}})(),gt=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),wt=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),Rt=Lt(v(Lt)(1e18)(ft))(v(Lt)(1e18)($.outgoing)),yt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)($.outgoing)),Ct=v(qt=>jt=>jt>wt?qt:jt>=gt?qt+1|0:qt)(0)($.outgoing)+v(qt=>jt=>jt>yt?qt:jt>=Rt?qt+1|0:qt)(0)(Tt._1.incoming)|0,Wt=Lt(v(Lt)(1e18)(ft))(v(Lt)(1e18)($.outgoing)),zt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)($.outgoing)),se=Lt(v(Lt)(1e18)(Tt._1.incoming))(v(Lt)(1e18)(Tt._1.outgoing)),_e=kt(v(kt)(-1e18)(Tt._1.incoming))(v(kt)(-1e18)(Tt._1.outgoing)),pn=v(qt=>jt=>jt>zt?qt:jt>=Wt?qt+1|0:qt)(0)(Tt._1.outgoing)+v(qt=>jt=>jt>_e?qt:jt>=se?qt+1|0:qt)(0)(ft)|0;return Ct===pn?Ct>0?{...pt,deps:pt.deps+2|0,crossings:pt.crossings+Ct|0}:pt:{...pt,deps:pt.deps+1|0,crossings:pt.crossings+sa(Ct)(pn)|0}}g()}})())({crossings:0,deps:0})(_t(mt=>mt.tgt===$.id,l.deps)))(_t(mt=>mt.src===$.id,l.deps)),dt=(()=>{if($.splitBy.tag==="Just")return Zt($.splitBy._1)(q.segMap);if($.splitBy.tag==="Nothing")return y;g()})();if(dt.tag==="Just")return{...Nt,deps:Nt.deps+2|0,crossings:(()=>{const mt=Lt(v(Lt)(1e18)(dt._1.incoming))(v(Lt)(1e18)(dt._1.outgoing)),bt=Lt(v(Lt)(1e18)(ft))(v(Lt)(1e18)($.outgoing)),Ht=kt(v(kt)(-1e18)(dt._1.incoming))(v(kt)(-1e18)(dt._1.outgoing)),Tt=kt(v(kt)(-1e18)(ft))(v(kt)(-1e18)($.outgoing)),Vt=Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)(et));return Nt.crossings+(()=>{const At=Lt(v(Lt)(1e18)(dt._1.incoming))(v(Lt)(1e18)(dt._1.outgoing)),vt=kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)(et)),pt=kt(v(kt)(-1e18)(dt._1.incoming))(v(kt)(-1e18)(dt._1.outgoing));return((v(gt=>wt=>wt>Ht?gt:wt>=mt?gt+1|0:gt)(0)(et)+v(gt=>wt=>wt>vt?gt:wt>=Vt?gt+1|0:gt)(0)(dt._1.incoming)|0)+v(gt=>wt=>wt>Tt?gt:wt>=bt?gt+1|0:gt)(0)(dt._1.outgoing)|0)+v(gt=>wt=>wt>pt?gt:wt>=At?gt+1|0:gt)(0)(ft)|0})()|0})()};if(dt.tag==="Nothing")return Nt;g()})()}))(M);return v(Z=>tt=>tt.rating.crossings<Z.rating.crossings||!(tt.rating.crossings>Z.rating.crossings)&&(tt.rating.deps<Z.rating.deps||!(tt.rating.deps>Z.rating.deps)&&tt.c.a.size>Z.c.a.size)?tt:Z)(0<K.length?K[0]:{c:W._1,rating:{crossings:1e6,deps:1e6}})(K).c}g()})(),X={...$,incoming:Pt(at.compare)($.incoming),outgoing:Pt(at.compare)([(D.a.startPosition+D.a.endPosition)/2]),splitPartner:w("Just",q.nextId)},V={id:q.nextId,incoming:Pt(at.compare)([(D.a.startPosition+D.a.endPosition)/2]),mark:0,members:$.members,outgoing:Pt(at.compare)($.outgoing),slot:0,splitBy:y,splitPartner:w("Just",$.id)};return{segMap:it(ut)(V.id)(V)(it(ut)(X.id)(X)(q.segMap)),freeAreas:(()=>{if(D.i>=0&&D.i<q.freeAreas.length){const K=X1(Xt,y,D.i,q.freeAreas),Z=(()=>{if(K.tag==="Nothing")return q.freeAreas;if(K.tag==="Just")return K._1;g()})();if(q.freeAreas[D.i].size/2<f)return Z;const tt=(q.freeAreas[D.i].startPosition+q.freeAreas[D.i].endPosition)/2,et=tt-f,ft=tt+f;return[...D.i<1?[]:Bt(0,D.i,Z),...q.freeAreas[D.i].startPosition<=et?[{startPosition:q.freeAreas[D.i].startPosition,endPosition:et,size:et-q.freeAreas[D.i].startPosition}]:[],...ft<=q.freeAreas[D.i].endPosition?[{startPosition:ft,endPosition:q.freeAreas[D.i].endPosition,size:q.freeAreas[D.i].endPosition-ft}]:[],...D.i<1?Z:Bt(D.i,Z.length,Z)]}return q.freeAreas})(),nextId:q.nextId+1|0}})({segMap:H,freeAreas:(()=>{const q=Pt(at.compare)([...St(l.segments)($=>$.incoming),...St(l.segments)($=>$.outgoing)]);return ht(lb)(Oe($=>A=>A-$>=2*f?w("Just",{startPosition:$+f,endPosition:A-f,size:A-$-2*f}):y,q,Bt(1,q.length,q)))})(),nextId:l.segments.length})(Pt(q=>$=>at.compare(kt(v(kt)(-1e18)(q.incoming))(v(kt)(-1e18)(q.outgoing))-Lt(v(Lt)(1e18)(q.incoming))(v(Lt)(1e18)(q.outgoing)))(kt(v(kt)(-1e18)($.incoming))(v(kt)(-1e18)($.outgoing))-Lt(v(Lt)(1e18)($.incoming))(v(Lt)(1e18)($.outgoing))))(ht(q=>Zt(q)(H))(I.decisions)));return{segments:(()=>{const q=($,A)=>{if($.tag==="Leaf")return A;if($.tag==="Node")return q($._5,Jt("Cons",$._4,q($._6,A)));g()};return It(ge.foldr,q(Q.segMap,z))})(),deps:(()=>{const q=Q.segMap,$=(M,W)=>{if(M.tag==="Leaf")return W;if(M.tag==="Node")return $(M._5,Jt("Cons",M._4,$(M._6,W)));g()},A=It(ge.foldr,$(q,z)),F=A.length;return[...St(St(Ut(0,F-2|0))(M=>St(Ut(M+1|0,F-1|0))(W=>[E(M,W)])))(M=>M._1>=0&&M._1<A.length?M._2>=0&&M._2<A.length?A[M._1].splitPartner.tag!=="Nothing"&&A[M._1].splitPartner.tag==="Just"&&A[M._1].splitPartner._1===A[M._2].id||A[M._2].splitPartner.tag!=="Nothing"&&A[M._2].splitPartner.tag==="Just"&&A[M._2].splitPartner._1===A[M._1].id?[]:i(f,A[M._1],A[M._2]):[]:[]),...St(A)(M=>M.splitBy.tag==="Just"&&M.splitPartner.tag==="Just"&&(()=>{const W=Zt(M.splitPartner._1)(q);if(W.tag==="Nothing")return!1;if(W.tag==="Just")return!0;g()})()&&(()=>{const W=Zt(M.splitBy._1)(q);if(W.tag==="Nothing")return!1;if(W.tag==="Just")return!0;g()})()?[{src:M.id,tgt:M.splitBy._1,weight:1,kind:Tu},{src:M.splitBy._1,tgt:M.splitPartner._1,weight:1,kind:Tu}]:[])]})()}})(),m=h.segments,p=m.length,x=S=>{let b=S,I=!0,H;for(;I;){const Q=b,q=te($=>{const A=Zt($)(Q.inWeight);if(A.tag==="Nothing")return!0;if(A.tag==="Just")return A._1===0;g()})(Q.remaining);if(q.tag==="Nothing"){I=!1,H=Q;continue}if(q.tag==="Just"){const $=q._1;b={...Q,inWeight:v(A=>F=>Ot(ut)(be)(F.tgt)(-F.weight)(A))(Q.inWeight)((()=>{const A=Zt($)(Q.depsBySrc);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),marks:it(ut)($)(Q.nextSource)(Q.marks),nextSource:Q.nextSource+1|0,outWeight:v(A=>F=>Ot(ut)(be)(F.src)(-F.weight)(A))(Q.outWeight)((()=>{const A=Zt($)(Q.depsByTgt);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),remaining:_t(A=>A!==$,Q.remaining)};continue}g()}return H},J=S=>{let b=S,I=!0,H;for(;I;){const Q=b,q=te($=>{const A=Zt($)(Q.outWeight);if(A.tag==="Nothing")return!0;if(A.tag==="Just")return A._1===0;g()})(Q.remaining);if(q.tag==="Nothing"){I=!1,H=Q;continue}if(q.tag==="Just"){const $=q._1;b={...Q,inWeight:v(A=>F=>Ot(ut)(be)(F.tgt)(-F.weight)(A))(Q.inWeight)((()=>{const A=Zt($)(Q.depsBySrc);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),marks:it(ut)($)(Q.nextSink)(Q.marks),nextSink:Q.nextSink-1|0,outWeight:v(A=>F=>Ot(ut)(be)(F.src)(-F.weight)(A))(Q.outWeight)((()=>{const A=Zt($)(Q.depsByTgt);if(A.tag==="Nothing")return[];if(A.tag==="Just")return A._1;g()})()),remaining:_t(A=>A!==$,Q.remaining)};continue}g()}return H},T=(S=>{let b=S,I=!0,H;for(;I;){const Q=x(J(b));if(Q.remaining.length===0){I=!1,H=Y(q=>{const $=Zt(q.id)(Q.marks),A=(()=>{if($.tag==="Nothing")return q.id;if($.tag==="Just")return $._1;g()})();return{...q,mark:A<p?(A+p|0)+1|0:A}})(m);continue}b=(()=>{const q=A=>{const F=Zt(A)(Q.outWeight),M=Zt(A)(Q.inWeight);return(()=>{if(F.tag==="Nothing")return 0;if(F.tag==="Just")return F._1;g()})()-(()=>{if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})()|0},$=Pt(A=>F=>ut.compare(q(F))(q(A)))(Q.remaining);if(0<$.length){const A=$[0];return{...Q,inWeight:v(F=>M=>Ot(ut)(be)(M.tgt)(-M.weight)(F))(Q.inWeight)((()=>{const F=Zt(A)(Q.depsBySrc);if(F.tag==="Nothing")return[];if(F.tag==="Just")return F._1;g()})()),marks:it(ut)(A)(Q.nextSource)(Q.marks),nextSource:Q.nextSource+1|0,outWeight:v(F=>M=>Ot(ut)(be)(M.src)(-M.weight)(F))(Q.outWeight)((()=>{const F=Zt(A)(Q.depsByTgt);if(F.tag==="Nothing")return[];if(F.tag==="Just")return F._1;g()})()),remaining:_t(F=>F!==A,Q.remaining)}}return Q})()}return H})({remaining:Y(S=>S.id)(m),marks:O,inWeight:v(S=>b=>Ot(ut)(be)(b.tgt)(b.weight)(S))(O)(h.deps),outWeight:v(S=>b=>Ot(ut)(be)(b.src)(b.weight)(S))(O)(h.deps),depsBySrc:v(S=>b=>Ot(ut)(Je)(b.src)([b])(S))(O)(h.deps),depsByTgt:v(S=>b=>Ot(ut)(Je)(b.tgt)([b])(S))(O)(h.deps),nextSink:p-1|0,nextSource:p+1|0}),N=(()=>{const S=(()=>{const H=ia(Y(Q=>E(Q.id,Q.mark))(T));return{segments:T,deps:ht(Q=>(()=>{if(Q.kind==="Critical")return!0;if(Q.kind==="Regular")return!1;g()})()?w("Just",Q):(()=>{const q=Zt(Q.src)(H),$=Zt(Q.tgt)(H);return(()=>{if(q.tag==="Nothing")return 0;if(q.tag==="Just")return q._1;g()})()>(()=>{if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})()})()?Q.weight===0?y:w("Just",{src:Q.tgt,tgt:Q.src,weight:Q.weight,kind:Q.kind}):w("Just",Q))(h.deps)}})(),b=v(H=>Q=>Ot(ut)(be)(Q.tgt)(1)(H))(O)(S.deps),I=(H=>{let Q=H,q=!0,$;for(;q;){const A=Q,F=Ft(M=>y,M=>W=>w("Just",{head:M,tail:W}),A.queue);if(F.tag==="Nothing"){q=!1,$=A;continue}if(F.tag==="Just"){Q=v((()=>{const M=Zt(F._1.head)(A.slots),W=(()=>{if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})();return D=>X=>{const V=Zt(X)(D.inDegree),K=(()=>{if(V.tag==="Nothing")return-1;if(V.tag==="Just")return V._1-1|0;g()})();return{...D,slots:it(ut)(X)(th((()=>{const Z=Zt(X)(D.slots);if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})())(W+1|0))(D.slots),inDegree:it(ut)(X)(K)(D.inDegree),queue:K===0?[...D.queue,X]:D.queue}}})())({...A,queue:F._1.tail})((()=>{const M=Zt(F._1.head)(A.adj);if(M.tag==="Nothing")return[];if(M.tag==="Just")return M._1;g()})());continue}g()}return $})({slots:ia(Y(H=>E(H.id,0))(S.segments)),inDegree:b,adj:v(H=>Q=>Ot(ut)(Je)(Q.src)([Q.tgt])(H))(O)(S.deps),queue:Y(H=>H.id)(_t(H=>{const Q=Zt(H.id)(b);if(Q.tag==="Nothing")return!0;if(Q.tag==="Just")return Q._1===0;g()},S.segments))});return Pt(H=>Q=>ut.compare(H.slot)(Q.slot))(Y(H=>({...H,slot:(()=>{const Q=Zt(H.id)(I.slots);if(Q.tag==="Nothing")return 0;if(Q.tag==="Just")return Q._1;g()})()}))(S.segments))})(),k=1+v(S=>b=>th(S)(b.slot))(0)(N)|0,C=St(N)(S=>S.members),P=_t(S=>mn(kr)(S.edge.id)(C),t),G=v(kt)(-1e18)(Y(S=>S.fromPos._2)(P)),R=v(Lt)(1e18)(Y(S=>S.toPos._2)(P));if(G>R){const S=ia(Y(b=>E(b.id,b))(N));return Ln(Y(b=>Y(I=>E(I,{slot:b.slot,slotCount:k,gapTop:R,gapBottom:G,partner:(()=>{if(b.splitPartner.tag==="Just"){const H=Zt(b.splitPartner._1)(S);if(H.tag==="Just")return w("Just",{slot:H._1.slot,splitX:0<H._1.incoming.length?H._1.incoming[0]:0});if(H.tag==="Nothing")return y;g()}if(b.splitPartner.tag==="Nothing")return y;g()})()}))(b.members))(_t(b=>{if(b.splitPartner.tag==="Just"){const I=Zt(b.splitPartner._1)(S);return!(I.tag==="Just"&&(()=>{if(I._1.splitBy.tag==="Nothing")return!1;if(I._1.splitBy.tag==="Just")return!0;g()})())}if(b.splitPartner.tag==="Nothing")return!0;g()},N)))}const U=ia(Y(S=>E(S.id,S))(N));return Ln(Y(S=>Y(b=>E(b,{slot:S.slot,slotCount:k,gapTop:G,gapBottom:R,partner:(()=>{if(S.splitPartner.tag==="Just"){const I=Zt(S.splitPartner._1)(U);if(I.tag==="Just")return w("Just",{slot:I._1.slot,splitX:0<I._1.incoming.length?I._1.incoming[0]:0});if(I.tag==="Nothing")return y;g()}if(S.splitPartner.tag==="Nothing")return y;g()})()}))(S.members))(_t(S=>{if(S.splitPartner.tag==="Just"){const b=Zt(S.splitPartner._1)(U);return!(b.tag==="Just"&&(()=>{if(b._1.splitBy.tag==="Nothing")return!1;if(b._1.splitBy.tag==="Just")return!0;g()})())}if(S.splitPartner.tag==="Nothing")return!0;g()},N)))})()))(O)(db(v(a=>s=>{const u=aa(s.edge.from.node)(n);if(u.tag==="Just"){const c=aa(s.edge.to.node)(n);return c.tag==="Just"&&u._1.layer!==c._1.layer?Ot(ut)(Je)(sa(u._1.layer)(c._1.layer))([s])(a):a}return a})(O)((()=>{const a=s=>E((()=>{const u=aa(s.edge.from.node)(n);return u.tag==="Just"?u._1.layer:1e6})(),(()=>{const u=aa(s.edge.from.node)(n);return u.tag==="Just"?u._1.order:1e6})());return Pt(s=>u=>fb(a(s))(a(u)))(t)})())))},pb=t=>e=>{const n=nh(t)(e),r=v(o=>i=>it(B)(i.node)(i)(o))(O)(e);return v(o=>i=>{const a=aa(i.edge.from.node)(r);if(a.tag==="Just"){const s=aa(i.edge.to.node)(r);if(s.tag==="Just"&&a._1.layer!==s._1.layer){const u=hb(i.edge.id)(n);if(u.tag==="Just")return it(ut)(sa(a._1.layer)(s._1.layer))(u._1.slotCount)(o)}return o}return o})(O)(t)},m_=fe(B)(Qt),to=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},y_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},mb=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t._1)(i._3._1);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(t._2==="North"){if(i._3._2==="North"){r=!1,o=w("Just",i._4);continue}n=i._5;continue}if(i._3._2==="North"){n=i._6;continue}if(t._2==="South"){if(i._3._2==="South"){r=!1,o=w("Just",i._4);continue}n=i._5;continue}if(i._3._2==="South"){n=i._6;continue}if(t._2==="East"){if(i._3._2==="East"){r=!1,o=w("Just",i._4);continue}n=i._5;continue}if(i._3._2==="East"){n=i._6;continue}if(t._2==="West"&&i._3._2==="West"){r=!1,o=w("Just",i._4);continue}}g()}return o},rh=t=>e=>{const n=e.position._1+e.size._1,r=e.position._2*2+e.size._2,o=e.position._1*2+e.size._1,i=e.position._2+e.size._2;if(t==="South")return E(o,i*2);if(t==="North")return E(o,e.position._2*2);if(t==="East")return E(n*2,r);if(t==="West")return E(e.position._1*2,r);g()},x_=t=>e=>{const n=ot(4);if(t==="South")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="North")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="East")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};if(t==="West")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};g()},oh=t=>e=>v(n=>r=>Ot(t)(Je)(e(r))([r])(n))(O),ih=t=>e=>n=>r=>{const o=(t==="South"||t==="North")&&(e==="East"||e==="West")&&(()=>{if(t==="South")return r._2>n._2;if(t==="North")return r._2<n._2;if(t==="East")return r._2>n._2;if(t==="West")return r._2<n._2;g()})()&&(()=>{if(e==="East")return n._1>r._1;if(e==="West"||e==="North")return n._1<r._1;if(e==="South")return n._1>r._1;g()})(),i=(t==="East"||t==="West")&&(e==="North"||e==="South")&&(()=>{if(t==="South")return r._1>n._1;if(t==="North")return r._1<n._1;if(t==="East")return r._1>n._1;if(t==="West")return r._1<n._1;g()})()&&(()=>{if(e==="East")return n._2>r._2;if(e==="West"||e==="North")return n._2<r._2;if(e==="South")return n._2>r._2;g()})();return(t==="South"?e==="North"&&n._1===r._1&&r._2>n._2:t==="North"?e==="South"&&n._1===r._1&&r._2<n._2:t==="East"?e==="West"&&n._2===r._2&&r._1>n._1:t==="West"&&e==="East"&&n._2===r._2&&r._1<n._1)?0:o||i?1:2},ah=t=>e=>{const n=t.hi-t.lo,r=(t.lo+t.hi)/2,o=e.length;return o===0?O:m_(o===1?Y(i=>E(i,r))(e):Mt(i=>a=>E(a,t.lo+ot(i+1|0)*n/ot(o+1|0)))(e))},sh=t=>e=>n=>r=>o=>{const i=oh(B)(d=>d.to.node)(t),a=oh(B)(d=>d.from.node)(t),s=v(d=>h=>it(B)(h.node)(h)(d))(O)(e),u=(d,h,m)=>{const p=to(d)(s);if(p.tag==="Nothing")return E(0,0);if(p.tag==="Just"){const x=to(d)(n);if(x.tag==="Nothing"){const J=ot(4);if(m==="South")return E(p._1.position._1*J+p._1.size._1*J/2,(p._1.position._2+p._1.size._2)*J);if(m==="North")return E(p._1.position._1*J+p._1.size._1*J/2,p._1.position._2*J);if(m==="East")return E((p._1.position._1+p._1.size._1)*J,p._1.position._2*J+p._1.size._2*J/2);if(m==="West")return E(p._1.position._1*J,p._1.position._2*J+p._1.size._2*J/2);g()}if(x.tag==="Just"){const J=te(T=>T.id===h)(x._1);if(J.tag==="Nothing"){const T=ot(4);if(m==="South")return E(p._1.position._1*T+p._1.size._1*T/2,(p._1.position._2+p._1.size._2)*T);if(m==="North")return E(p._1.position._1*T+p._1.size._1*T/2,p._1.position._2*T);if(m==="East")return E((p._1.position._1+p._1.size._1)*T,p._1.position._2*T+p._1.size._2*T/2);if(m==="West")return E(p._1.position._1*T,p._1.position._2*T+p._1.size._2*T/2);g()}if(J.tag==="Just"){const T=ot(4);if(J._1.side==="North")return E(p._1.position._1*T+ot(J._1.offset)*T,p._1.position._2*T);if(J._1.side==="South")return E(p._1.position._1*T+ot(J._1.offset)*T,(p._1.position._2+p._1.size._2)*T);if(J._1.side==="East")return E((p._1.position._1+p._1.size._1)*T,p._1.position._2*T+ot(J._1.offset)*T);if(J._1.side==="West")return E(p._1.position._1*T,p._1.position._2*T+ot(J._1.offset)*T)}}}g()},c=m_(St(r)(d=>{if(d.nodes.length<=2)return[];const h=ot(4);if(1<d.nodes.length){const m=to(d.nodes[1])(s);if(m.tag==="Nothing")return[];if(m.tag==="Just"){const p=m._1.position._1*h+m._1.size._1*h/2;return Y(x=>E(x,p))(Oe(x=>J=>d.edgeId+":"+x+"->"+J,d.nodes,Bt(1,d.nodes.length,d.nodes)))}g()}return[]})),_=d=>{const h=to(d.from.node)(s),m=to(d.to.node)(s);if(h.tag==="Just"&&m.tag==="Just"){const p=h._1,x=m._1,J=Pt(T=>N=>ut.compare(T.score)(N.score))(Y(T=>{const N=T._1,k=T._2;return{from:N,to:k,score:(()=>{const C=(U,S,b,I,H)=>{const Q=x_(U)(S),q=x_(U)(b);return Q.lo<q.hi&&q.lo<Q.hi&&(N==="South"?k==="North"&&H._2>I._2:N==="North"?k==="South"&&H._2<I._2:N==="East"?k==="West"&&H._1>I._1:N==="West"&&k==="East"&&H._1<I._1)?0:ih(N)(k)(I)(H)},P=rh(N)(p),G=rh(k)(x),R=ih(N)(k)(P)(G);return(()=>{if(R>0){if(N==="South")return k==="North"?C(Fe,p,x,P,G)*10|0:R*10|0;if(N==="North")return k==="South"?C(De,p,x,P,G)*10|0:R*10|0;if(N==="East")return k==="West"?C(qr,p,x,P,G)*10|0:R*10|0;if(N==="West"&&k==="East")return C(Vr,p,x,P,G)*10|0}return R*10|0})()+(N==="South"?k==="North"?x.layer>=p.layer?0:20:15:N==="North"?k==="South"?x.layer<=p.layer?0:20:15:N==="East"?k==="West"?5:15:N==="West"&&k==="East"?5:15)|0})()}})([E(Fe,De),E(qr,De),E(Vr,De),E(Fe,qr),E(Fe,Vr),E(De,Fe),E(De,qr),E(De,Vr),E(qr,Fe),E(Vr,Fe),E(qr,Vr),E(Vr,qr)]));if(0<J.length)return{from:J[0].from,to:J[0].to}}return{from:Fe,to:De}},f=m_(Y(d=>E(d.id,_(d)))(t)),l=(d,h,m,p,x,J)=>{const T=ot(4),N=to(h)(s);if(N.tag==="Nothing")return E(0,0);if(N.tag==="Just"){const k=mb(E(m,d))(o);if(k.tag==="Just"){const C=N._1.position._1*T+k._1,P=ot(4);if(d==="South")return E(C,(N._1.position._2+N._1.size._2)*P);if(d==="North")return E(C,N._1.position._2*P);if(d==="East")return E((N._1.position._1+N._1.size._1)*P,C);if(d==="West")return E(N._1.position._1*P,C);g()}if(k.tag==="Nothing"){const C=x_(d)(N._1),P=(C.lo+C.hi)/2,G=y_(m)(ah(C)(Y(S=>S.id)(Pt(S=>b=>at.compare(x(d)(S))(x(d)(b)))(_t(S=>{const b=y_(S.id)(f);if(b.tag==="Just"){const I=J(b._1);return I==="North"?d==="North":I==="South"?d==="South":I==="East"?d==="East":I==="West"&&d==="West"}if(b.tag==="Nothing")return!0;g()},(()=>{const S=to(h)(p);if(S.tag==="Nothing")return[];if(S.tag==="Just")return S._1;g()})()))))),R=(()=>{if(G.tag==="Nothing")return P;if(G.tag==="Just")return G._1;g()})(),U=ot(4);if(d==="South")return E(R,(N._1.position._2+N._1.size._2)*U);if(d==="North")return E(R,N._1.position._2*U);if(d==="East")return E((N._1.position._1+N._1.size._1)*U,R);if(d==="West")return E(N._1.position._1*U,R)}}g()};return Y(d=>{const h=y_(d.edge.id)(c);if(h.tag==="Nothing")return d;if(h.tag==="Just")return{...d,fromPos:Ve(3)(d.edge.from.node)==="$d:"?E(h._1,d.fromPos._2):d.fromPos,toPos:Ve(3)(d.edge.to.node)==="$d:"?E(h._1,d.toPos._2):d.toPos};g()})(Y(d=>{if(d.from.port.tag==="Just"&&d.to.port.tag==="Just")return{edge:d,fromPos:u(d.from.node,d.from.port._1,Fe),toPos:u(d.to.node,d.to.port._1,De),fromSide:Fe,toSide:De};const h=_(d);return{edge:d,fromPos:l(h.from,d.from.node,d.id,a,m=>p=>{const x=to(p.to.node)(s);if(x.tag==="Nothing")return 0;if(x.tag==="Just"){const J=ot(4);if(m==="South"||m==="North")return x._1.position._1*J+x._1.size._1*J/2;if(m==="East"||m==="West")return x._1.position._2*J+x._1.size._2*J/2}g()},m=>m.from),toPos:l(h.to,d.to.node,d.id,i,m=>p=>{const x=to(p.from.node)(s);if(x.tag==="Nothing")return 0;if(x.tag==="Just"){const J=ot(4);if(m==="South"||m==="North")return x._1.position._1*J+x._1.size._1*J/2;if(m==="East"||m==="West")return x._1.position._2*J+x._1.size._2*J/2}g()},m=>m.to),fromSide:h.from,toSide:h.to}})(t))},Nu=(()=>{const t={eq:e=>n=>e._1===n._1&&(e._2==="North"?n._2==="North":e._2==="South"?n._2==="South":e._2==="East"?n._2==="East":e._2==="West"&&n._2==="West")};return{compare:e=>n=>{const r=B.compare(e._1)(n._1);if(r==="LT")return Qe;if(r==="GT")return Me;if(e._2==="North")return n._2==="North"?sn:Qe;if(n._2==="North")return Me;if(e._2==="South")return n._2==="South"?sn:Qe;if(n._2==="South")return Me;if(e._2==="East")return n._2==="East"?sn:Qe;if(n._2==="East")return Me;if(e._2==="West"&&n._2==="West")return sn;g()},Eq0:()=>t}})(),yb=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=Nu.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},xb=fe(B)(Qt),J_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Jb=fe(Nu)(Qt),uh=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),ua=t=>e=>n=>r=>{const o=yb(E(e,n))(t);if(o.tag==="Nothing")return r;if(o.tag==="Just")return o._1;g()},ch=t=>e=>n=>{const r=xb(Ln(Y(a=>Mt(s=>u=>E(u,s))(a))(t))),o=(a,s)=>{if(a==="South"){const u=J_(s.to.node)(r);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()}if(a==="North"){const u=J_(s.from.node)(r);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1;g()}return 0},i=a=>v(s=>u=>en(Nu.compare,je,Jb(Y(c=>E(E(c._1,a),c._2))(uh(ah({lo:0,hi:(()=>{const c=J_(u._1)(n);if(c.tag==="Just")return c._1._1;if(c.tag==="Nothing")return Ve(3)(u._1)==="$d:"?0:1;g()})()})(Y(c=>c.id)(Pt(c=>_=>ut.compare(o(a,c))(o(a,_)))(u._2)))))),s))(O)(uh(v(s=>u=>u.from.node===u.to.node?s:a==="South"?Ot(B)(Je)(u.from.node)([u])(s):a==="North"?Ot(B)(Je)(u.to.node)([u])(s):s)(O)(e)));return en(Nu.compare,je,i(De),i(Fe))},gh=t=>t,_h=t=>t,fh=t=>t,wb=v(t=>e=>it(B)(e)()(t))(O),Tb=(()=>{const t=un.unfoldr(e=>{if(e.tag==="Nil")return y;if(e.tag==="Cons")return w("Just",E(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._3,n(r._6,o)));g()};return n(e,z)})())})(),lt=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},tr=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Dr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Fr=fe(B)(Qt),w_=nf(B),T_=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),Nb=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},vb=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},dh=fh("VDown"),lh=fh("VUp"),bb=_h("ForwardPhase"),Cb=_h("StackPhase"),hh=gh("HRight"),ph=gh("HLeft"),mh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Lb=t=>e=>n=>{const r=v(a=>s=>Ot(B)(be)(s.tgt)(1)(a))(O)(t),o=Tb(wb([...Y(a=>a.src)(t),...Y(a=>a.tgt)(t),...(()=>{const a=(s,u)=>{if(s.tag==="Leaf")return u;if(s.tag==="Node")return a(s._5,Jt("Cons",s._4,a(s._6,u)));g()};return It(ge.foldr,a(e,z))})()])),i=v(a=>s=>Ot(B)(Je)(s.src)([{target:s.tgt,sep:s.sep}])(a))(O)(t);return(a=>s=>u=>{let c=a,_=s,f=u,l=!0,d;for(;l;){const h=c,m=_,p=f,x=Ft(J=>y,J=>T=>w("Just",{head:J,tail:T}),h);if(x.tag==="Nothing"){l=!1,d=p;continue}if(x.tag==="Just"){const J=lt(x._1.head)(p),T=(()=>{if(J.tag==="Nothing")return 0;if(J.tag==="Just")return J._1;g()})(),N=v(k=>C=>{const P=lt(C.target)(k.result),G=T+C.sep,R=lt(C.target)(k.indeg),U=(()=>{if(R.tag==="Nothing")return-1;if(R.tag==="Just")return R._1-1|0;g()})();return{newQueue:U===0?[...k.newQueue,C.target]:k.newQueue,result:it(B)(C.target)((()=>{if(P.tag==="Nothing")return G;if(P.tag==="Just"){if(n==="VDown")return tr(P._1)(G);if(n==="VUp")return Dr(P._1)(G)}g()})())(k.result),indeg:it(B)(C.target)(U)(k.indeg)}})({newQueue:[],result:p,indeg:m})((()=>{const k=lt(x._1.head)(i);if(k.tag==="Nothing")return[];if(k.tag==="Just")return k._1;g()})());c=[...x._1.tail,...N.newQueue],_=N.indeg,f=N.result;continue}g()}return d})(_t(a=>{const s=lt(a)(r);if(s.tag==="Nothing")return!0;if(s.tag==="Just")return s._1===0;g()},o))(r)(v(a=>s=>it(B)(s)(0)(a))(O)(o))},kb=t=>{const e=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return e(i._5,Jt("Cons",i._4,e(i._6,a)));g()},n=It(ge.foldr,e(t,z)),r=v(tr)(999999)(n);if(r===0||n.length===0)return t;const o=i=>{if(i.tag==="Leaf")return O;if(i.tag==="Node")return ee("Node",i._1,i._2,i._3,i._4-r,o(i._5),o(i._6));g()};return o(t)},yh=t=>{const e=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return e(i._5,Jt("Cons",i._4,e(i._6,a)));g()},n=e(t,z),r=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=Dr(f)(l._1),u=l._2;continue}g()}return _},o=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l.tag==="Nil"){c=!1,_=f;continue}if(l.tag==="Cons"){s=tr(f)(l._1),u=l._2;continue}g()}return _};return r(-999999)(n)-o(999999)(n)},Ha=t=>e=>(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(u===e){a=!1,s=c;continue}o=(()=>{const _=lt(u)(t.align);if(_.tag==="Nothing")return e;if(_.tag==="Just")return _._1;g()})(),i=[...c,u]}return s})((()=>{const n=lt(e)(t.align);if(n.tag==="Nothing")return e;if(n.tag==="Just")return n._1;g()})())([e]),Sb=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>{const f=(A,F,M)=>{const W=A.from.node===F?A.from.port:A.to.node===F?A.to.port:y;if(W.tag==="Just"){const D=lt(F)(o);if(D.tag==="Just"){const X=te(V=>V.id===W._1)(D._1);if(X.tag==="Just"){const V=ot(X._1.offset)*ot(4);return M==="North"||M==="South"?V:0}if(X.tag==="Nothing"){const V=lt(F)(r),K=ua(a)(A.id)(M)((()=>{if(V.tag==="Nothing")return .5;if(V.tag==="Just")return V._1._1/2;g()})());return M==="North"||M==="South"?K:0}g()}if(D.tag==="Nothing"){const X=lt(F)(r),V=ua(a)(A.id)(M)((()=>{if(X.tag==="Nothing")return .5;if(X.tag==="Just")return X._1._1/2;g()})());return M==="North"||M==="South"?V:0}g()}if(W.tag==="Nothing"){const D=lt(F)(r),X=ua(a)(A.id)(M)((()=>{if(D.tag==="Nothing")return .5;if(D.tag==="Just")return D._1._1/2;g()})());return M==="North"||M==="South"?X:0}g()},l=(A,F)=>{if(A.from.node===F){if(_==="HRight")return Fe;if(_==="HLeft")return De;g()}if(_==="HRight")return De;if(_==="HLeft")return Fe;g()},d=(A,F,M)=>v(W=>D=>it(B)(D)((()=>{const X=lt(D)(W);if(X.tag==="Nothing")return 0+F;if(X.tag==="Just")return X._1+F;g()})())(W))(M)(Ha(u)(A)),h=(()=>{if(_==="HRight")return n;if(_==="HLeft")return re(n);g()})(),m=A=>{const F=lt(A)(r);if(F.tag==="Nothing")return 1;if(F.tag==="Just")return F._1._1;g()},p=Fr(Ln(Mt(A=>F=>Y(M=>E(M,A))(F))(n))),x=(A,F)=>Ve(3)(A)==="$d:"&&Ve(3)(F)==="$d:"||Ve(3)(A)==="$d:"||Ve(3)(F)==="$d:"?10:ot(t.nodeGap),J=v(A=>F=>w_(M=>w("Just",[...(()=>{if(M.tag==="Nothing")return[];if(M.tag==="Just")return M._1;g()})(),F]))(F.to.node)(A))(O)(i),T=v(A=>F=>w_(M=>w("Just",[...(()=>{if(M.tag==="Nothing")return[];if(M.tag==="Just")return M._1;g()})(),F]))(F.from.node)(A))(O)(i),N=Ln(n),k=v(A=>F=>{const M=lt(F)(u.root),W=(()=>{if(M.tag==="Nothing")return F;if(M.tag==="Just")return M._1;g()})();return F===W?A:w_(D=>w("Just",(()=>{if(D.tag==="Nothing")return!0;if(D.tag==="Just")return D._1;g()})()&&Ve(3)(F)==="$d:"))(W)(A)})(Fr(Y(A=>E(A,!0))($r(B.compare)((()=>{const A=(F,M)=>{if(F.tag==="Leaf")return M;if(F.tag==="Node")return A(F._5,Jt("Cons",F._4,A(F._6,M)));g()};return It(ge.foldr,A(u.root,z))})()))))(N),C=(A,F)=>{const M=A.free,W=lt(M)(u.root),D=(()=>{if(W.tag==="Nothing")return M;if(W.tag==="Just")return W._1;g()})(),X=lt(D)(k),V=(()=>{if(X.tag==="Nothing")return!0;if(X.tag==="Just")return X._1;g()})();return v(K=>Z=>{if(K.edge.tag==="Just")return K;if(K.edge.tag==="Nothing"){if((()=>{const dt=lt(D)(F.su);return!V&&(()=>{const mt=lt(Z.from.node)(p);return Z.from.node!==Z.to.node&&(()=>{const bt=lt(Z.to.node)(p);return(()=>{if(mt.tag==="Nothing")return-1;if(mt.tag==="Just")return mt._1;g()})()===(()=>{if(bt.tag==="Nothing")return-1;if(bt.tag==="Just")return bt._1;g()})()})()})()||(()=>{if(dt.tag==="Nothing")return!1;if(dt.tag==="Just")return dt._1;g()})()})())return K;const tt=Z.from.node===M?Z.to.node:Z.from.node,et=lt(tt)(u.root),ft=(()=>{if(et.tag==="Nothing")return tt;if(et.tag==="Just")return et._1;g()})(),Nt=ft!==D;return Nt&&(()=>{const dt=lt(ft)(F.blockFinished);if(dt.tag==="Nothing")return!1;if(dt.tag==="Just")return dt._1;g()})()?{...K,edge:w("Just",Z),hasEdges:!0}:{...K,hasEdges:K.hasEdges||Nt}}g()})({edge:y,hasEdges:!1})((()=>{if(A.isRoot){if(_==="HRight"){const K=lt(M)(J);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1;g()}if(_==="HLeft"){const K=lt(M)(T);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1}g()}if(_==="HRight"){const K=lt(M)(T);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1;g()}if(_==="HLeft"){const K=lt(M)(J);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1}g()})())},P=(A,F,M,W)=>{const D=(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})(),X={free:F,isRoot:M},V=C(X,W);if(V.edge.tag==="Nothing")return V.hasEdges?{thresh:D,state:{...W,queue:[...W.queue,X]}}:{thresh:D,state:W};if(V.edge.tag==="Just"){const K=V.edge._1.from.node===F?V.edge._1.to.node:V.edge._1.from.node;return{thresh:(()=>{const Z=lt((()=>{const Nt=lt(K)(u.root);if(Nt.tag==="Nothing")return K;if(Nt.tag==="Just")return Nt._1;g()})())(W.x),tt=lt(K)(s),et=lt(F)(s),ft=(()=>{if(Z.tag==="Just")return Z._1;if(Z.tag==="Nothing")return y;g()})();return(()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(tt.tag==="Nothing")return 0;if(tt.tag==="Just")return tt._1;g()})()+f(V.edge._1,K,(()=>{if(M){if(_==="HRight")return Fe;if(_==="HLeft")return De;g()}if(_==="HRight")return De;if(_==="HLeft")return Fe;g()})())-(()=>{if(et.tag==="Nothing")return 0;if(et.tag==="Just")return et._1;g()})()-f(V.edge._1,F,(()=>{if(M){if(_==="HRight")return De;if(_==="HLeft")return Fe;g()}if(_==="HRight")return Fe;if(_==="HLeft")return De;g()})())})(),state:{...W,su:it(B)((()=>{const Z=lt(V.edge._1.from.node)(u.root);if(Z.tag==="Nothing")return V.edge._1.from.node;if(Z.tag==="Just")return Z._1;g()})())(!0)(it(B)((()=>{const Z=lt(V.edge._1.to.node)(u.root);if(Z.tag==="Nothing")return V.edge._1.to.node;if(Z.tag==="Just")return Z._1;g()})())(!0)(W.su))}}}g()},G=(A,F,M,W)=>{const D=F===A,X=lt(F)(u.align),V=(()=>{if(X.tag==="Nothing")return F===A;if(X.tag==="Just")return X._1===A;g()})();if(!(D||V))return{thresh:M,state:W};const K=(()=>{if(c==="VDown")return D&&M<=-1e18;if(c==="VUp")return D&&M>=1e18;g()})()?P(A,F,!0,W):{thresh:M,state:W};return(()=>{if(c==="VDown")return K.thresh<=-1e18&&V;if(c==="VUp")return K.thresh>=1e18&&V;g()})()?P(A,F,!1,K.state):K},R=A=>F=>M=>{const W=lt(M)(e.nodeIndex),D=(()=>{if(W.tag==="Nothing")return 0;if(W.tag==="Just")return W._1;g()})(),X=te(et=>mn(kr)(M)(et))(h),V=(()=>{if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1;g()})(),K=V.length;if((()=>{if(c==="VDown")return D<=0;if(c==="VUp")return D>=(K-1|0);g()})()){const et=G(A,M,F.thresh,F.st);return{...F,st:et.state,thresh:et.thresh}}const Z=(()=>{if(c==="VDown")return D-1|0;if(c==="VUp")return D+1|0;g()})(),tt=Z>=0&&Z<V.length?w("Just",V[Z]):y;if(tt.tag==="Nothing")return F;if(tt.tag==="Just"){const et=lt(tt._1)(u.root),ft=(()=>{if(et.tag==="Nothing")return tt._1;if(et.tag==="Just")return et._1;g()})(),Nt=G(A,M,F.thresh,U(ft)(F.st)),dt=(()=>{const zt=lt(A)(Nt.state.sink);if(zt.tag==="Nothing")return A===A;if(zt.tag==="Just")return zt._1===A;g()})()?{...Nt.state,sink:it(B)(A)((()=>{const zt=lt(ft)(Nt.state.sink);if(zt.tag==="Nothing")return ft;if(zt.tag==="Just")return zt._1;g()})())(Nt.state.sink)}:Nt.state,mt=lt(ft)(dt.sink),bt=(()=>{if(mt.tag==="Nothing")return ft;if(mt.tag==="Just")return mt._1;g()})(),Ht=lt(A)(dt.sink),Tt=(()=>{if(Ht.tag==="Nothing")return A;if(Ht.tag==="Just")return Ht._1;g()})();if(Tt===bt){const zt=lt(ft)(dt.x),se=(()=>{if(zt.tag==="Just")return zt._1;if(zt.tag==="Nothing")return y;g()})(),_e=(()=>{if(se.tag==="Nothing")return 0;if(se.tag==="Just")return se._1;g()})(),pn=lt(A)(dt.x),qt=(()=>{if(pn.tag==="Just")return pn._1;if(pn.tag==="Nothing")return y;g()})(),jt=(()=>{if(qt.tag==="Nothing")return 0;if(qt.tag==="Just")return qt._1;g()})(),an=x(M,tt._1),$e=lt(tt._1)(s),$n=lt(M)(s),qn=(()=>{if($e.tag==="Nothing")return 0;if($e.tag==="Just")return $e._1;g()})()-(()=>{if($n.tag==="Nothing")return 0;if($n.tag==="Just")return $n._1;g()})();if(c==="VDown"){const Ze=Dr(_e+qn+m(tt._1)+an)(Nt.thresh);return{st:{...dt,x:it(B)(A)(w("Just",F.initial?Ze:Dr(jt)(Ze)))(dt.x)},initial:!1,thresh:Nt.thresh}}if(c==="VUp"){const Ze=tr(_e+qn-an-m(M))(Nt.thresh);return{st:{...dt,x:it(B)(A)(w("Just",F.initial?Ze:tr(jt)(Ze)))(dt.x)},initial:!1,thresh:Nt.thresh}}g()}const Vt=lt(ft)(dt.x),At=(()=>{if(Vt.tag==="Just")return Vt._1;if(Vt.tag==="Nothing")return y;g()})(),vt=(()=>{if(At.tag==="Nothing")return 0;if(At.tag==="Just")return At._1;g()})(),pt=lt(A)(dt.x),gt=(()=>{if(pt.tag==="Just")return pt._1;if(pt.tag==="Nothing")return y;g()})(),wt=(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})(),Rt=ot(t.nodeGap),yt=lt(M)(s),Ct=lt(tt._1)(s),Wt=(()=>{if(yt.tag==="Nothing")return 0;if(yt.tag==="Just")return yt._1;g()})()-(()=>{if(Ct.tag==="Nothing")return 0;if(Ct.tag==="Just")return Ct._1;g()})();return{st:{...dt,classEdges:[...dt.classEdges,{src:Tt,tgt:bt,sep:(()=>{if(c==="VDown")return wt+Wt-vt-m(tt._1)-Rt;if(c==="VUp")return wt+Wt+m(M)+Rt-vt;g()})()}]},initial:F.initial,thresh:Nt.thresh}}g()},U=A=>F=>{const M=lt(A)(F.x),W=(()=>{if(M.tag==="Just")return M._1;if(M.tag==="Nothing")return y;g()})();if(W.tag==="Just")return F;if(W.tag==="Nothing"){const D=v(R(A))({st:{...F,x:it(B)(A)(w("Just",0))(F.x)},initial:!0,thresh:(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})()})(Ha(u)(A));return{...D.st,blockFinished:it(B)(A)(!0)(D.st.blockFinished)}}g()},S=v(A=>F=>v(M=>W=>{const D=lt(W)(u.root),X=(()=>{if(D.tag==="Nothing")return W;if(D.tag==="Just")return D._1;g()})();return X===W?U(X)(M):M})(A)((()=>{if(c==="VDown")return F;if(c==="VUp")return re(F);g()})()))({x:Fr(Y(A=>E(A,y))(N)),sink:Fr(Y(A=>E(A,A))(N)),classEdges:[],su:O,blockFinished:O,queue:[]})(h),b=Lb(S.classEdges)(S.sink)(c),I=(A,F,M,W)=>{const D=lt(F)(W),X=lt(F)(s);return(()=>{if(D.tag==="Nothing")return 0;if(D.tag==="Just")return D._1;g()})()+(()=>{if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1;g()})()+f(A,F,M)},H=Fr(Y(A=>E(A,!0))($r(B.compare)((()=>{const A=(F,M)=>{if(F.tag==="Leaf")return M;if(F.tag==="Node")return A(F._5,Jt("Cons",F._4,A(F._6,M)));g()};return It(ge.foldr,A(u.root,z))})()))),Q=A=>F=>M=>{const W=C(M,{su:F.su,blockFinished:H}),D={phase:A,ppFree:M.free,ppIsRoot:M.isRoot,edgeId:y,delta:0,avail:0,shift:0,freeSu:(()=>{const X=lt((()=>{const V=lt(M.free)(u.root);if(V.tag==="Nothing")return M.free;if(V.tag==="Just")return V._1;g()})())(F.su);if(X.tag==="Nothing")return!1;if(X.tag==="Just")return X._1;g()})(),hasEdges:W.hasEdges,candCount:(()=>{if(M.isRoot){if(_==="HRight"){const X=lt(M.free)(J);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length;g()}if(_==="HLeft"){const X=lt(M.free)(T);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length}g()}if(_==="HRight"){const X=lt(M.free)(T);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length;g()}if(_==="HLeft"){const X=lt(M.free)(J);if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1.length}g()})()};if(W.edge.tag==="Nothing")return{...F,stack:[...F.stack,M],trace:[...F.trace,D],x:F.x};if(W.edge.tag==="Just"){const X=W.edge._1.from.node===M.free?E(W.edge._1.from.node,W.edge._1.to.node):E(W.edge._1.to.node,W.edge._1.from.node),V=I(W.edge._1,X._1,l(W.edge._1,X._1),F.x)-I(W.edge._1,X._2,l(W.edge._1,X._2),F.x),K=lt(X._1)(u.root),Z=(()=>{if(K.tag==="Nothing")return X._1;if(K.tag==="Just")return K._1;g()})(),tt={...D,edgeId:w("Just",W.edge._1.id),delta:V};if(V>0&&V<1e300){const et=v(dt=>mt=>{const bt=lt(mt)(p),Ht=(()=>{if(bt.tag==="Nothing")return-1;if(bt.tag==="Just")return bt._1;g()})();if(Ht>=0&&Ht<n.length){const At=n[Ht],vt=lt(mt)(e.nodeIndex),pt=(()=>{if(vt.tag==="Nothing")return-2;if(vt.tag==="Just")return vt._1-1|0;g()})();return pt>=0&&pt<At.length?tr(dt)((()=>{const gt=lt(mt)(F.x),wt=lt(mt)(s),Rt=lt(At[pt])(F.x),yt=lt(At[pt])(s);return(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+(()=>{if(wt.tag==="Nothing")return 0;if(wt.tag==="Just")return wt._1;g()})()-((()=>{if(Rt.tag==="Nothing")return 0;if(Rt.tag==="Just")return Rt._1;g()})()+(()=>{if(yt.tag==="Nothing")return 0;if(yt.tag==="Just")return yt._1;g()})()+m(At[pt])+x(mt,At[pt]))})()):dt}const Tt=lt(mt)(e.nodeIndex),Vt=(()=>{if(Tt.tag==="Nothing")return-2;if(Tt.tag==="Just")return Tt._1-1|0;g()})();return Vt>=0&&Vt<0?tr(dt)((()=>{const At=lt(mt)(F.x),vt=lt(mt)(s),pt=lt([][Vt])(F.x),gt=lt([][Vt])(s);return(()=>{if(At.tag==="Nothing")return 0;if(At.tag==="Just")return At._1;g()})()+(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1;g()})()-((()=>{if(pt.tag==="Nothing")return 0;if(pt.tag==="Just")return pt._1;g()})()+(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+m([][Vt])+x(mt,[][Vt]))})()):dt})(V)(Ha(u)(Z)),ft=et>0?-et:0,Nt={...F,x:et>0?d(Z,ft,F.x):F.x,trace:[...F.trace,{...tt,avail:et,shift:ft}]};return et>0?Nt:{...Nt,stack:[...Nt.stack,M]}}if(V<0&&-V<1e300){const et=v(dt=>mt=>{const bt=lt(mt)(p),Ht=(()=>{if(bt.tag==="Nothing")return-1;if(bt.tag==="Just")return bt._1;g()})();if(Ht>=0&&Ht<n.length){const At=n[Ht],vt=lt(mt)(e.nodeIndex),pt=(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1+1|0;g()})();return pt>=0&&pt<At.length?tr(dt)((()=>{const gt=lt(At[pt])(F.x),wt=lt(At[pt])(s),Rt=lt(mt)(F.x),yt=lt(mt)(s);return(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+(()=>{if(wt.tag==="Nothing")return 0;if(wt.tag==="Just")return wt._1;g()})()-((()=>{if(Rt.tag==="Nothing")return 0;if(Rt.tag==="Just")return Rt._1;g()})()+(()=>{if(yt.tag==="Nothing")return 0;if(yt.tag==="Just")return yt._1;g()})()+m(mt)+x(mt,At[pt]))})()):dt}const Tt=lt(mt)(e.nodeIndex),Vt=(()=>{if(Tt.tag==="Nothing")return 0;if(Tt.tag==="Just")return Tt._1+1|0;g()})();return Vt>=0&&Vt<0?tr(dt)((()=>{const At=lt([][Vt])(F.x),vt=lt([][Vt])(s),pt=lt(mt)(F.x),gt=lt(mt)(s);return(()=>{if(At.tag==="Nothing")return 0;if(At.tag==="Just")return At._1;g()})()+(()=>{if(vt.tag==="Nothing")return 0;if(vt.tag==="Just")return vt._1;g()})()-((()=>{if(pt.tag==="Nothing")return 0;if(pt.tag==="Just")return pt._1;g()})()+(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+m(mt)+x(mt,[][Vt]))})()):dt})(-V)(Ha(u)(Z)),ft=et>0?et:0,Nt={...F,x:et>0?d(Z,ft,F.x):F.x,trace:[...F.trace,{...tt,avail:et,shift:ft}]};return et>0?Nt:{...Nt,stack:[...Nt.stack,M]}}return{...F,stack:[...F.stack,M],trace:[...F.trace,tt],x:F.x}}g()},q=v(Q(bb))({x:Fr(Y(A=>E(A,(()=>{const F=lt(A)(u.root),M=(()=>{if(F.tag==="Nothing")return A;if(F.tag==="Just")return F._1;g()})(),W=lt(M)(S.x),D=lt((()=>{const V=lt(M)(S.sink);if(V.tag==="Nothing")return M;if(V.tag==="Just")return V._1;g()})())(b),X=(()=>{if(W.tag==="Just")return W._1;if(W.tag==="Nothing")return y;g()})();return(()=>{if(X.tag==="Nothing")return 0;if(X.tag==="Just")return X._1;g()})()+(()=>{if(D.tag==="Nothing")return 0;if(D.tag==="Just")return D._1;g()})()})()))(N)),su:S.su,stack:[],trace:[]})(S.queue),$=v(Q(Cb))({...q,stack:[]})(re(q.stack));return{x:$.x,queue:S.queue,trace:$.trace}},Eb=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>Sb(t)(e)(n)(r)(o)(i)(a)(s)(u)(c)(_).x,Pb=t=>e=>n=>r=>o=>i=>{const a=(u,c,_)=>{const f=lt(c)(n),l=(()=>{if(f.tag==="Nothing")return .5;if(f.tag==="Just")return f._1._1/2;g()})(),d=u.from.node===c?u.from.port:u.to.node===c?u.to.port:y;if(d.tag==="Just"){const h=lt(c)(e);if(h.tag==="Just"){const m=te(p=>p.id===d._1)(h._1);if(m.tag==="Just"){const p=ot(m._1.offset)*ot(4);return _==="North"||_==="South"?p:0}if(m.tag==="Nothing"){const p=ua(o)(u.id)(_)(l);return _==="North"||_==="South"?p:0}g()}if(h.tag==="Nothing"){const m=ua(o)(u.id)(_)(l);return _==="North"||_==="South"?m:0}g()}if(d.tag==="Nothing"){const h=ua(o)(u.id)(_)(l);return _==="North"||_==="South"?h:0}g()},s=u=>c=>_=>f=>{let l=u,d=c,h=_,m=f,p=!0,x;for(;p;){const J=l,T=d,N=h,k=Ft(C=>y,C=>P=>w("Just",{head:C,tail:P}),m);if(k.tag==="Nothing"){p=!1,x=J;continue}if(k.tag==="Just"){const C=k._1.head,P=te(R=>R.from.node===N&&R.to.node===C||R.from.node===C&&R.to.node===N)(r),G=(()=>{if(P.tag==="Nothing")return T+0;if(P.tag==="Just")return T+(a(P._1,N,P._1.from.node===N?Fe:De)-a(P._1,C,P._1.from.node===C?Fe:De));g()})();l=it(B)(C)(G)(J),d=G,h=C,m=k._1.tail;continue}g()}return x};return v(u=>c=>{const _=Ft(d=>y,d=>h=>w("Just",{head:d,tail:h}),Ha(t)(c)),f=(()=>{if(_.tag==="Nothing")return it(B)(c)(0)(O);if(_.tag==="Just")return s(it(B)(_._1.head)(0)(O))(0)(_._1.head)(_._1.tail);g()})(),l=v(d=>h=>Dr(d)(-h._2))(0)(T_(f));return v(d=>h=>it(B)(h._1)(h._2+l)(d))(u)(T_(f))})(O)($r(B.compare)((()=>{const u=(c,_)=>{if(c.tag==="Leaf")return _;if(c.tag==="Node")return u(c._5,Jt("Cons",c._4,u(c._6,_)));g()};return It(ge.foldr,u(t.root,z))})()))},Gb=t=>e=>{const n=(o,i,a)=>Ve(3)(i)==="$d:"&&Bc(Zl,(()=>{const s=lt(i)(t.preds);if(s.tag==="Nothing")return[];if(s.tag==="Just")return s._1;g()})()),r=o=>i=>a=>s=>u=>c=>_=>{let f=o,l=i,d=s,h=c,m=_,p=!0,x;for(;p;){const J=f,T=l,N=d,k=h,C=m,P=T.length;if(C>=P){p=!1,x=J;continue}const G=C>=0&&C<T.length?w("Just",T[C]):y,R=(()=>{if(G.tag==="Nothing")return"";if(G.tag==="Just")return G._1;g()})(),U=n(t,R);if(C===(P-1|0)||U){const S=(()=>{if(U){const b=lt(R)(t.preds),I=(()=>{if(b.tag==="Nothing")return[];if(b.tag==="Just")return b._1;g()})();if(0<I.length){const H=N-1|0,Q=lt(I[0])(t.nodeIndex);if(Q.tag==="Nothing")return H;if(Q.tag==="Just")return Q._1;g()}}return N-1|0})();f=v(b=>I=>{if(I>=0&&I<T.length){const H=T[I];return n(t,H)?b:v(Q=>q=>{const $=lt(q)(t.nodeIndex),A=(()=>{if($.tag==="Nothing")return 0;if($.tag==="Just")return $._1;g()})();return A<k||A>S?it(B)(q+"\u2192"+H)()(Q):Q})(b)((()=>{const Q=lt(H)(t.preds);if(Q.tag==="Nothing")return[];if(Q.tag==="Just")return Q._1;g()})())}return n(t,"")?b:v(H=>Q=>{const q=lt(Q)(t.nodeIndex),$=(()=>{if(q.tag==="Nothing")return 0;if(q.tag==="Just")return q._1;g()})();return $<k||$>S?it(B)(Q+"\u2192")()(H):H})(b)((()=>{const H=lt("")(t.preds);if(H.tag==="Nothing")return[];if(H.tag==="Just")return H._1;g()})())})(J)(Ut(0,C)),l=T,d=N,h=S,m=C+1|0;continue}f=J,l=T,d=N,h=k,m=C+1|0}return x};return e.length<3?O:v(o=>i=>{if(i>=0&&i<e.length){const a=e[i];return r(o)((()=>{const s=i+1|0;return s>=0&&s<e.length?e[s]:[]})())(a)(a.length)(i)(0)(0)}return r(o)((()=>{const a=i+1|0;return a>=0&&a<e.length?e[a]:[]})())([])(0)(i)(0)(0)})(O)(Ut(1,e.length-2|0))},Ab=t=>e=>n=>r=>o=>{const i=Ln(e),a=v(s=>u=>{const c=v(_=>f=>{const l=(()=>{if(o==="HRight"){const p=lt(f)(t.preds);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()}if(o==="HLeft"){const p=lt(f)(t.succs);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1}g()})(),d=l.length;if(d===0)return _;const h=Lr(d-1|0,2),m=Lr(d,2);return v(p=>x=>{if((()=>{const J=lt(f)(p.align);if(J.tag==="Nothing")return f!==f;if(J.tag==="Just")return J._1!==f;g()})())return p;if(x>=0&&x<l.length){const J=lt(l[x])(t.nodeIndex),T=(()=>{if(J.tag==="Nothing")return 0;if(J.tag==="Just")return J._1;g()})();if(!(mh(l[x]+"\u2192"+f)(n)||mh(f+"\u2192"+l[x])(n))&&(()=>{if(r==="VDown")return p.r<T;if(r==="VUp")return p.r>T;g()})()){const N=lt(l[x])(p.root),k=(()=>{if(N.tag==="Nothing")return l[x];if(N.tag==="Just")return N._1;g()})();return{root:it(B)(f)(k)(p.root),align:it(B)(l[x])(f)(it(B)(f)(k)(p.align)),r:T}}}return p})(_)((()=>{if(r==="VDown")return Ut(h,m);if(r==="VUp")return re(Ut(h,m));g()})())})({root:s.root,align:s.align,r:(()=>{if(r==="VDown")return-1;if(r==="VUp")return 999999;g()})()})((()=>{if(r==="VDown")return u;if(r==="VUp")return re(u);g()})());return{root:c.root,align:c.align}})({root:Fr(Y(s=>E(s,s))(i)),align:Fr(Y(s=>E(s,s))(i))})((()=>{if(o==="HRight")return e;if(o==="HLeft")return re(e);g()})());return{root:a.root,align:a.align}},vu=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>{const _=Ab(e)(n)(s)(u)(c),f=Pb(_)(o)(r)(i)(a)(c);return Fc()(l=>d=>w("Just",(()=>{const h=lt(l)(f);if(h.tag==="Nothing")return d+0;if(h.tag==="Just")return d+h._1;g()})()))(Eb(t)(e)(n)(r)(o)(i)(a)(f)(_)(u)(c))},xh=t=>e=>Mt(n=>r=>v(o=>i=>i>=0&&i<e.length?i>=0&&i<t.length?o+e[i]+t[i]:o+e[i]+0:i>=0&&i<t.length?o+1+t[i]:o+1)(0)((()=>{const o=Ut(0,e.length-1|0);return n<1?[]:Bt(0,n,o)})()))(e),Bb=t=>e=>n=>r=>o=>i=>a=>{const s=Nb(0)(e.length-1|0),u=ot(t.layerGap),c=a(Fo(s,u)),_=pb(sh(o)(c)(r)(i)(O))(c);return Y(f=>{const l=vb(f)(_);return l.tag==="Just"&&l._1>0?Dr(u)(2+ot(l._1-1|0)*2.5):u})(Ut(0,s-1|0))},Jh=t=>e=>n=>r=>Bc(o=>v(i=>a=>{if(!i.ok)return i;const s=lt(a)(r),u=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})(),c=lt(a)(n),_=(()=>{if(c.tag==="Nothing")return u+1;if(c.tag==="Just")return u+c._1._1;g()})();return u+1e-4>i.pos&&_+1e-4>i.pos?{ok:!0,pos:_}:{ok:!1,pos:i.pos}})({ok:!0,pos:-1e18})(o).ok,e),Rb=t=>e=>n=>r=>{const o=Pt(i=>a=>at.compare(i.w)(a.w))(Y(i=>({l:i,w:yh(i)}))(_t(Jh()(e)(n),r)));return 0<o.length?w("Just",o[0].l):y},Db=t=>e=>{const n=Fr(Ln(Y(Mt(o=>i=>E(i,o)))(t))),r=o=>Pt(i=>a=>ut.compare((()=>{const s=lt(i)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})())((()=>{const s=lt(a)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(o);return{preds:(()=>{const o=i=>{if(i.tag==="Leaf")return O;if(i.tag==="Node")return ee("Node",i._1,i._2,i._3,r(i._4),o(i._5),o(i._6));g()};return o(v(i=>a=>Ot(B)(Je)(a.to.node)([a.from.node])(i))(O)(e))})(),succs:(()=>{const o=i=>{if(i.tag==="Leaf")return O;if(i.tag==="Node")return ee("Node",i._1,i._2,i._3,r(i._4),o(i._5),o(i._6));g()};return o(v(i=>a=>Ot(B)(Je)(a.from.node)([a.to.node])(i))(O)(e))})(),nodeIndex:n}},Fb=t=>e=>{const n=Pt(f=>l=>at.compare(f.w)(l.w))(Mt(f=>l=>({i:f,l,w:yh(l)}))(e)),r=0<n.length?w("Just",n[0]):y,o=(()=>{if(r.tag==="Just")return r._1.i;if(r.tag==="Nothing")return 0;g()})(),i=o>=0&&o<e.length?w("Just",e[o]):y,a=(()=>{if(i.tag==="Just")return(f=>l=>{let d=f,h=l,m=!0,p;for(;m;){const x=d,J=h;if(J.tag==="Nil"){m=!1,p=x;continue}if(J.tag==="Cons"){d=tr(x)(J._1),h=J._2;continue}g()}return p})(999999)((()=>{const f=(l,d)=>{if(l.tag==="Leaf")return d;if(l.tag==="Node")return f(l._5,Jt("Cons",l._4,f(l._6,d)));g()};return f(i._1,z)})());if(i.tag==="Nothing")return 0;g()})(),s=f=>v(l=>d=>Dr(l)((()=>{const h=lt(d._1)(t);if(h.tag==="Nothing")return d._2+1;if(h.tag==="Just")return d._2+h._1._1;g()})()))(-999999)(T_(f)),u=o>=0&&o<e.length?w("Just",e[o]):y,c=(()=>{if(u.tag==="Just")return s(u._1);if(u.tag==="Nothing")return 0;g()})(),_=Oe(f=>l=>{const d=h=>{if(h.tag==="Leaf")return O;if(h.tag==="Node")return ee("Node",h._1,h._2,h._3,h._4+l,d(h._5),d(h._6));g()};return d(f)},e,Mt(f=>l=>go(f)(2)===0?a-(d=>h=>{let m=d,p=h,x=!0,J;for(;x;){const T=m,N=p;if(N.tag==="Nil"){x=!1,J=T;continue}if(N.tag==="Cons"){m=tr(T)(N._1),p=N._2;continue}g()}return J})(999999)((()=>{const d=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return d(h._5,Jt("Cons",h._4,d(h._6,m)));g()};return d(l,z)})()):c-s(l))(e));return kb(v(f=>l=>{const d=Pt(at.compare)(ht(lt(l))(_));return it(B)(l)(d.length===4?1<d.length&&2<d.length?(d[1]+d[2])/2:0:0<d.length?d[0]:0)(f)})(O)($r(B.compare)(Ln(Y(f=>{const l=d=>{if(d.tag==="Leaf")return O;if(d.tag==="Node")return ee("Node",d._1,d._2,d._3,void 0,l(d._5),l(d._6));g()};return It(xn.foldr,l(f))})(_)))))},zb=t=>e=>n=>r=>o=>i=>{const a=Db(e)(o),s=Gb(a)(e),u={nodeGap:t.nodeGap*4|0},c=en(B.compare,je,Fr(Y(d=>E(d,E(1,1)))(_t(Zl,Ln(e)))),(()=>{const d=h=>{if(h.tag==="Leaf")return O;if(h.tag==="Node")return ee("Node",h._1,h._2,h._3,E(h._4._1*ot(4),h._4._2),d(h._5),d(h._6));g()};return d(n)})()),_=[vu(u)(a)(e)(c)(r)(o)(i)(s)(dh)(hh),vu(u)(a)(e)(c)(r)(o)(i)(s)(lh)(hh),vu(u)(a)(e)(c)(r)(o)(i)(s)(dh)(ph),vu(u)(a)(e)(c)(r)(o)(i)(s)(lh)(ph)],f=Fb(c)(_);if(Jh()(e)(c)(f))return f;const l=Rb()(e)(c)(_);if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return _[0];g()},Ib=t=>e=>n=>r=>{const o=K1(y,H1,i=>i.node===e?w("Just",i.position):y,t);if(o.tag==="Nothing")return t;if(o.tag==="Just"){const i=o._1;return Y(a=>a.node===n?{...a,position:E(i._1+r._1,i._2+r._2)}:a)(t)}g()},Qb=t=>e=>n=>r=>{const o=_t(a=>mn(kr)(a.node)(e),t),i=(()=>{if(n==="Vertical"){if(r==="Start")return v(a=>s=>tr(a)(s.position._1))(99999)(o);if(r==="End")return v(a=>s=>Dr(a)(s.position._1))(0)(o);if(r==="Center"){const a=v(s=>u=>s+u.position._1)(0)(o);return o.length===0?0:a/ot(o.length)}g()}if(n==="Horizontal"){if(r==="Start")return v(a=>s=>tr(a)(s.position._2))(99999)(o);if(r==="End")return v(a=>s=>Dr(a)(s.position._2))(0)(o);if(r==="Center"){const a=v(s=>u=>s+u.position._2)(0)(o);return o.length===0?0:a/ot(o.length)}}g()})();return Y(a=>{if(mn(kr)(a.node)(e)){if(n==="Vertical")return{...a,position:E(i,a.position._2)};if(n==="Horizontal")return{...a,position:E(a.position._1,i)};g()}return a})(t)},Mb=t=>e=>v(n=>r=>r.tag==="AlignGroup"?Qb(n)(r._1.nodes)(r._1.axis)(r._1.alignment):r.tag==="RelativePosition"?Ib(n)(r._1.anchor)(r._1.target)(r._1.offset):n)(e)(t),Ob=t=>e=>n=>r=>o=>i=>a=>s=>{const u=Y(f=>v(l=>d=>Dr(l)((()=>{const h=lt(d)(r);if(h.tag==="Nothing")return 1;if(h.tag==="Just")return h._1._2;g()})()))(1)(f))(n),c=zb(t)(n)(r)(o)(i)(s),_=xh(Bb(t)(n)(r)(o)(i)(a)(f=>{const l=xh(f)(u);return Ln(Mt(d=>h=>Mt(m=>p=>({node:p,position:E((()=>{const x=lt(p)(c);return(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})()/ot(4)})(),d>=0&&d<l.length?l[d]:0),size:(()=>{const x=Ve(3)(p)==="$d:"?E(0,1):E(1,1),J=lt(p)(r);if(J.tag==="Nothing")return x;if(J.tag==="Just")return J._1;g()})(),layer:d,order:m}))(h))(n))}))(u);return Mb(e)(Ln(Mt(f=>l=>Mt(d=>h=>({node:h,position:E((()=>{const m=lt(h)(c);return(()=>{if(m.tag==="Nothing")return 0;if(m.tag==="Just")return m._1;g()})()/ot(4)})(),f>=0&&f<_.length?_[f]:0),size:(()=>{const m=Ve(3)(h)==="$d:"?E(0,1):E(1,1),p=lt(h)(r);if(p.tag==="Nothing")return m;if(p.tag==="Just")return p._1;g()})(),layer:f,order:d}))(l))(n)))},N_=eg(Gs)(Wo(32)),wh=eg(Gs)(Wo(31)),$a=(()=>{const t=ax("25214903917");if(t.tag==="Nothing")return kf;if(t.tag==="Just")return t._1;g()})(),qa=tg(eg(Gs)(Wo(48)))(Gs),Wb=t=>{const e=sx(t);return Ea(Sf((()=>{if(e.tag==="Nothing")return kf;if(e.tag==="Just")return e._1;g()})())($a))(qa)},v_=Wo(11),bu=t=>e=>{const n=Ea(Es(Ps(e)($a))(v_))(qa);return E((()=>{const r=Z1(nx(ng(n)(Wo(48-t|0))));if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()})(),n)},Hb=t=>{const e=bu(26)(t),n=bu(27)(e._2);return E((ot(e._1)*Dc(2)(27)+ot(n._1))/Dc(2)(53),n._2)},$b=t=>e=>{const n=v(r=>o=>{const i=Hb(r.finalR);return{rs:[...r.rs,i._1],finalR:i._2}})({rs:[],finalR:t})(e);return E(Y(r=>r.x)(Pt(r=>o=>at.compare(r.k)(o.k))(Oe(r=>o=>({x:r,k:o}),e,n.rs))),n.finalR)},qb=t=>{const e=Ea(Es(Ps(t)($a))(v_))(qa),n=Ea(Es(Ps(e)($a))(v_))(qa);return E(Es(Ps((()=>{const r=ng(e)(Wo(16));return Ef.compare(r)(wh)!=="LT"?tg(r)(N_):r})())(N_))((()=>{const r=ng(n)(Wo(16));return Ef.compare(r)(wh)!=="LT"?tg(r)(N_):r})()),n)},Va=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Cu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},b_=fe(B)(Qt),ca=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Lu=fe(B)(Qt),Vb=Ts(Fi),Ub=v(xr)(0),Kb=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Th=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Yb=t=>e=>n=>{if(t>=0&&t<n.length){const r=n[t];if(e>=0&&e<n.length){const o=so(Xt,y,t,n[e],n);if(o.tag==="Just")return so(Xt,y,e,r,o._1);if(o.tag==="Nothing")return y;g()}}return y},Xb=t=>e=>n=>r=>o=>b_(v(i=>a=>{const s=Pt(u=>c=>ut.compare((()=>{const _=Va(u.id)(o);if(_.tag==="Nothing")return 1e6;if(_.tag==="Just")return _._1;g()})())((()=>{const _=Va(c.id)(o);if(_.tag==="Nothing")return 1e6;if(_.tag==="Just")return _._1;g()})()))(_t(u=>Cu(u.to.node)(n),_t(u=>u.from.node===a,r)));return{ranks:[...i.ranks,...Mt(u=>c=>E(c.id,ot((i.rankSum+u|0)+1|0)))(s)],rankSum:i.rankSum+s.length|0}})({ranks:[],rankSum:0})(t).ranks),Zb=t=>e=>n=>r=>o=>b_(v(i=>a=>{const s=Pt(c=>_=>{const f=ut.compare((()=>{const l=ca(_.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=ca(c.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})());return f==="EQ"?ut.compare((()=>{const l=Va(c.id)(o);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})())((()=>{const l=Va(_.id)(o);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})()):f})(_t(c=>Cu(c.from.node)(n),_t(c=>c.to.node===a,r))),u=s.length;return{ranks:[...i.ranks,...Mt(c=>_=>E(_.id,ot((i.rankSum+u|0)-c|0)))(s)],rankSum:i.rankSum+u|0}})({ranks:[],rankSum:0})(t).ranks),C_=t=>e=>n=>{const r=Lu(Mt(s=>u=>E(u,s))(t)),o=Lu(Mt(s=>u=>E(u,s))(e)),i=ht(s=>{const u=ca(s.from.node)(r),c=ca(s.to.node)(o);if(u.tag==="Just"&&c.tag==="Just")return w("Just",E(u._1,c._1));const _=ca(s.from.node)(o),f=ca(s.to.node)(r);return _.tag==="Just"&&f.tag==="Just"?w("Just",E(f._1,_._1)):y})(n),a=i.length;return v(s=>u=>v(c=>_=>u>=0&&u<i.length&&_>=0&&_<i.length&&((i[u]._1-i[_]._1|0)*(i[u]._2-i[_]._2|0)|0)<0?c+1|0:c)(s)(Ut(u+1|0,a-1|0)))(0)(Ut(0,a-2|0))},jb=t=>e=>n=>r=>{const o=i=>a=>{let s=i,u=a,c=!0,_;for(;c;){const f=s,l=u;if(l>=(f.length-1|0)){c=!1,_=f;continue}if(l>=0&&l<f.length){const d=l+1|0;if(d>=0&&d<f.length){const h=f[l],m=f[d];if(oe(T=>T.before===h&&T.after===m,r)){s=f,u=l+1|0;continue}const p=so(Xt,y,l,m,f),x=(()=>{if(p.tag==="Just")return so(Xt,y,l+1|0,h,p._1);if(p.tag==="Nothing")return y;g()})(),J=(()=>{if(x.tag==="Nothing")return f;if(x.tag==="Just")return x._1;g()})();if(C_(e)(J)(n)<C_(e)(f)(n)){s=J,u=l+1|0;continue}s=f,u=l+1|0;continue}c=!1,_=f;continue}c=!1,_=f}return _};return(i=>{let a=i,s=!0,u;for(;s;){const c=a,_=o(c)(0);if(Vb(_)(c)){s=!1,u=c;continue}a=_}return u})(t)},ku=t=>e=>v(n=>r=>{if(r>=0&&r<t.length){const o=t[r],i=r+1|0;if(i>=0&&i<t.length)return n+C_(o)(t[i])(e)|0}return n})(0)(Ut(0,t.length-2|0)),tC=(()=>{const t=e=>{if(e.length<7){const i=a=>s=>{let u=a,c=s,_=!0,f;for(;_;){const l=u,d=c,h=d-1|0;if(h>=0&&h<l.length){if(d>=0&&d<l.length&&d>0&&l[h].key>l[d].key){const m=Yb(d-1|0)(d)(l);if(m.tag==="Just"){u=m._1,c=d-1|0;continue}if(m.tag==="Nothing"){_=!1,f=l;continue}g()}_=!1,f=l;continue}_=!1,f=l}return f};return v(a=>s=>i(a)(s))(e)(Ut(1,e.length-1|0))}const n=Lr(e.length,2),r=t(Bt(0,n,e)),o=t(Bt(n,e.length,e));return(i=>a=>s=>{let u=i,c=a,_=s,f=!0,l;for(;f;){const d=u,h=c,m=_;if(h>=0&&h<r.length){if(m>=0&&m<o.length){if(r[h].key>o[m].key){u=Et(d)(o[m]),c=h,_=m+1|0;continue}u=Et(d)(r[h]),c=h+1|0,_=m;continue}f=!1,l=[...d,...h<1?r:Bt(h,r.length,r)];continue}f=!1,l=[...d,...m<1?o:Bt(m,o.length,o)]}return l})([])(0)(0)};return t})(),eC=t=>e=>n=>{const r=ht(c=>c.tag==="OrderConstraint"?w("Just",{before:c._1.before,after:c._1.after}):y)(t.constraints),o=c=>v(_=>f=>{const l=f.after,d=f.before,h=zo(Xt,y,p=>p===d,_),m=zo(Xt,y,p=>p===l,_);if(h.tag==="Just"&&m.tag==="Just"&&h._1>m._1){const p=X1(Xt,y,h._1,_),x=(()=>{if(p.tag==="Nothing")return _;if(p.tag==="Just")return p._1;g()})(),J=Y1(Xt,y,m._1,d,x);if(J.tag==="Nothing")return x;if(J.tag==="Just")return J._1;g()}return _})(c)(r),i=b_(Mt(c=>_=>E(_.id,c))(n)),a=(c,_,f)=>{const l=c.length;return v(d=>h=>{const m=_?h-1|0:h+1|0,p=m>=0&&m<d._1.length?w("Just",d._1[m]):y;if(p.tag==="Just"){const x=h>=0&&h<d._1.length?w("Just",d._1[h]):y;if(x.tag==="Just"){const J=Lu(Mt(P=>G=>E(G,P))(p._1)),T=Lu(Mt(P=>G=>E(G,P))(x._1)),N=_?Xb(p._1)(J)(T)(n)(i):Zb(p._1)(J)(T)(n)(i),k=v(P=>G=>{const R=ht(S=>Va(S.id)(N))(_t(_?S=>S.to.node===G._2&&Cu(S.from.node)(J):S=>S.from.node===G._2&&Cu(S.to.node)(J),n));if(R.length===0)return{...P,items:[...P.items,{n:G._2,key:y,origIdx:G._1}]};const U=bu(24)(P.r);return{items:[...P.items,{n:G._2,key:w("Just",(Ub(R)+(ot(U._1)*4172325152040912e-24-.03500000014901161))/ot(R.length)),origIdx:G._1}],r:U._2}})({items:[],r:d._2})(Mt(Cn)(x._1)),C=so(Xt,y,h,jb(o(Y(P=>P.n)(tC((()=>{const P=k.items,G=R=>U=>{let S=R,b=U,I=!0,H;for(;I;){const Q=S,q=b;if(Q>=0&&Q<P.length){if(P[Q].key.tag==="Just"){I=!1,H=P[Q].key._1;continue}if(P[Q].key.tag==="Nothing"){S=Q+1|0,b=q;continue}g()}I=!1,H=q}return H};return(R=>U=>S=>{let b=R,I=U,H=S,Q=!0,q;for(;Q;){const $=b,A=I,F=H;if($>=0&&$<P.length){if(P[$].key.tag==="Just"){b=$+1|0,I=P[$].key._1,H=[...F,{n:P[$].n,key:P[$].key._1,origIdx:P[$].origIdx}];continue}if(P[$].key.tag==="Nothing"){const M=(A+G($+1|0)(A+1))/2;b=$+1|0,I=M,H=[...F,{n:P[$].n,key:M,origIdx:P[$].origIdx}];continue}g()}Q=!1,q=F}return q})(0)(-1)([])})()))))(p._1)(n)(r),d._1);if(C.tag==="Just")return E(C._1,k.r);if(C.tag==="Nothing")return E(d._1,d._2);g()}if(x.tag==="Nothing")return E(d._1,d._2);g()}if(p.tag==="Nothing")return E(d._1,d._2);g()})(E(c,f))(_?Ut(1,l-1|0):re(Ut(0,l-2|0)))},s=v(c=>_=>it(B)(_.from.node)()(it(B)(_.to.node)()(c)))(O)(n),u=v(c=>_=>{if(c.result.crossings===0)return c;const f=J=>T=>N=>k=>{let C=J,P=T,G=N,R=k,U=!0,S;for(;U;){const b=C,I=P,H=G,Q=R;if(H===0){U=!1,S={layout:b,crossings:0,random:Q};continue}const q=a(b,I,Q),$=ku(q._1)(n);if($<H){C=q._1,P=!I,G=$,R=q._2;continue}U=!1,S={layout:b,crossings:H,random:q._2}}return S},l=bu(1)(c.result.random),d=l._1!==0,h=t.modelOrder.tag==="Leaf",m=(c.firstTry||c.secondTry)&&!h?c.firstTry:d,p=(()=>{if(!h){const k=a(e,m,l._2);return f(k._1)(!m)(ku(k._1)(n))(k._2)}const J=m?0:Kb(0)(e.length-1|0),T=J>=0&&J<e.length?w("Just",e[J]):y;if(T.tag==="Just"&&T._1.length>1){const k=_t(C=>Th(C)(s),T._1);if(k.length>1){const C=$b(l._2)(k),P=C._1,G=so(Xt,y,J,o(v(R=>U=>Th(U)(s)?R.idx>=0&&R.idx<P.length?{idx:R.idx+1|0,result:[...R.result,P[R.idx]]}:{idx:R.idx,result:[...R.result,U]}:{idx:R.idx,result:[...R.result,U]})({idx:0,result:[]})(T._1).result),e);if(G.tag==="Just"){const R=a(G._1,m,C._2);return f(R._1)(!m)(ku(R._1)(n))(R._2)}}}const N=a(e,m,l._2);return f(N._1)(!m)(ku(N._1)(n))(N._2)})(),x=c.secondTry?!1:c.secondTry;return c.firstTry?{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:!1,secondTry:!0}:{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:c.firstTry,secondTry:x}})({result:{layout:e,crossings:1e9,random:Ea(Sf(qb(Wb(1))._1)($a))(qa)},firstTry:t.modelOrder.tag!=="Leaf",secondTry:!1})(Ut(1,t.iterations)).result;return e.length<=0||t.iterations<=0?e:u.layout},nC=t=>t,Nh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Jn=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},ga=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Ua=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=B.compare(e._1)(n._1);return r==="LT"?Qe:r==="GT"?Me:B.compare(e._2)(n._2)},Eq0:()=>t}})(),rC=fe(B)(Qt),oC=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=Ua.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},iC=nC("Greedy"),L_=t=>e=>n=>v(r=>o=>{if(o.from.node===o.to.node)return r;if(o.from.node===e&&!Nh(o.to.node)(r.marks)){const i=Jn(o.to.node)(r.inDeg),a=(()=>{if(i.tag==="Nothing")return-1;if(i.tag==="Just")return i._1-1|0;g()})(),s=it(B)(o.to.node)(a)(r.inDeg);return(()=>{const u=Jn(o.to.node)(r.outDeg);return a<=0&&(()=>{if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1>0;g()})()&&!mn(kr)(o.to.node)(r.sources)})()?{...r,inDeg:s,sources:[...r.sources,o.to.node]}:{...r,inDeg:s}}if(o.to.node===e&&!Nh(o.from.node)(r.marks)){const i=Jn(o.from.node)(r.outDeg),a=(()=>{if(i.tag==="Nothing")return-1;if(i.tag==="Just")return i._1-1|0;g()})(),s=it(B)(o.from.node)(a)(r.outDeg);return(()=>{const u=Jn(o.from.node)(r.inDeg);return a<=0&&(()=>{if(u.tag==="Nothing")return!1;if(u.tag==="Just")return u._1>0;g()})()&&!mn(kr)(o.from.node)(r.sinks)})()?{...r,outDeg:s,sinks:[...r.sinks,o.from.node]}:{...r,outDeg:s}}return r})({...n,remaining:_t(r=>r!==e,n.remaining)})(t),aC=v(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return it(B)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return it(B)(e._1.node)(0)(t);if(e._1.pin.tag==="LastLayer")return it(B)(e._1.node)(99999)(t)}return t})(O),vh=t=>e=>n=>{const r=Jn(e)(t),o=Jn(n)(t);return r.tag==="Just"&&o.tag==="Just"&&r._1>o._1},bh=t=>e=>n=>r=>{if(ga(n)(r.visited)||ga(n)(r.visiting))return r;const o=v(sC(t)(e)(n))({...r,visiting:it(B)(n)()(r.visiting)})((()=>{const i=Jn(n)(e);if(i.tag==="Nothing")return[];if(i.tag==="Just")return i._1;g()})());return{...o,visiting:Qi(B)(n)(o.visiting),visited:it(B)(n)()(o.visited)}},sC=t=>e=>n=>r=>o=>vh(t)(n)(o)?{...r,backEdges:it(Ua)(E(n,o))()(r.backEdges)}:ga(o)(r.visiting)?{...r,backEdges:it(Ua)(E(n,o))()(r.backEdges)}:ga(o)(r.visited)?r:bh(t)(e)(o)(r),uC=t=>e=>n=>{const r=l=>{let d=l,h=!0,m;for(;h;){const p=d,x=Ft(J=>y,J=>T=>w("Just",{head:J,tail:T}),p.sinks);if(x.tag==="Just"){d=L_(n)(x._1.head)({...p,sinks:x._1.tail,marks:it(B)(x._1.head)(p.nextRight)(p.marks),nextRight:p.nextRight-1|0});continue}if(x.tag==="Nothing"){const J=Ft(T=>y,T=>N=>w("Just",{head:T,tail:N}),p.sources);if(J.tag==="Just"){d=L_(n)(J._1.head)({...p,sources:J._1.tail,marks:it(B)(J._1.head)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}if(J.tag==="Nothing"){const T=k=>{const C=Jn(k)(p.outDeg),P=Jn(k)(p.inDeg);return(()=>{if(C.tag==="Nothing")return 0;if(C.tag==="Just")return C._1;g()})()-(()=>{if(P.tag==="Nothing")return 0;if(P.tag==="Just")return P._1;g()})()|0},N=Pt(k=>C=>{const P=ut.compare(T(C))(T(k));return P==="EQ"?ut.compare((()=>{const G=Jn(k)(e);if(G.tag==="Nothing")return 1e6;if(G.tag==="Just")return G._1;g()})())((()=>{const G=Jn(C)(e);if(G.tag==="Nothing")return 1e6;if(G.tag==="Just")return G._1;g()})()):P})(p.remaining);if(0<N.length){const k=N[0];d=L_(n)(k)({...p,remaining:_t(C=>C!==k,p.remaining),marks:it(B)(k)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}h=!1,m=p;continue}}g()}return m},o=$r(B.compare)([...Y(l=>l.from.node)(n),...Y(l=>l.to.node)(n)]),i=_t(l=>l.from.node!==l.to.node,n),a=v(l=>d=>Ot(B)(be)(d.to.node)(1)(l))(O)(i),s=v(l=>d=>Ot(B)(be)(d.from.node)(1)(l))(O)(i),u=_t(l=>{const d=Jn(l)(a);if(d.tag==="Nothing")return!0;if(d.tag==="Just")return d._1===0;g()},o),c=_t(l=>{const d=Jn(l)(s);if(d.tag==="Nothing")return!0;if(d.tag==="Just")return d._1===0;g()},o),_=o.length+1|0,f=v(l=>d=>{const h=Jn(d)(l);return h.tag==="Just"&&h._1<0?it(B)(d)(h._1+_|0)(l):l})(r({remaining:_t(l=>!mn(kr)(l)(u)&&!mn(kr)(l)(c),o),marks:O,inDeg:a,outDeg:s,sources:u,sinks:c,nextLeft:1,nextRight:-1}).marks)(o);return v(l=>d=>{if(d.from.node===d.to.node)return l;if(vh(t)(d.from.node)(d.to.node))return it(Ua)(E(d.from.node,d.to.node))()(l);const h=Jn(d.from.node)(f),m=Jn(d.to.node)(f);return h.tag==="Just"&&m.tag==="Just"&&h._1>m._1?it(Ua)(E(d.from.node,d.to.node))()(l):l})(O)(n)},cC=v(t=>e=>Ot(B)(Je)(e.from.node)([e.to.node])(t))(O),gC=t=>e=>{const n=cC(e),r=$r(B.compare)([...Y(i=>i.from.node)(e),...Y(i=>i.to.node)(e)]),o=v(i=>a=>it(B)(a.to.node)()(i))(O)(e);return v(i=>a=>bh(t)(n)(a)(i))({visiting:O,visited:O,backEdges:O})([..._t(i=>!ga(i)(o),r),..._t(i=>ga(i)(o),r)]).backEdges},_C=t=>e=>n=>r=>{const o=rC(Mt(s=>u=>E(u,s))(e)),i=aC(n),a=(()=>{if(t==="DepthFirst")return gC(i)(r);if(t==="Greedy")return uC(i)(o)(r);g()})();return{edges:Y(s=>oC(E(s.from.node,s.to.node))(a)?{...s,from:s.to,to:s.from}:s)(r),reversedEdges:a}},Ch=Qt.foldMap((()=>{const t={append:e=>n=>e||n};return{mempty:!1,Semigroup0:()=>t}})()),Ae=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Be=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ka=t=>e=>n=>r=>Ch(o=>n>=o.x&&n<o.x+o.w&&e>o.y&&t<o.y+o.h)(r),Su=t=>e=>n=>r=>Ka(Ae(e)(n))(Be(e)(n))(r)(t),Eu=ot(4),fC=Ns(t=>{if(t.direction==="H"){const e=Ae(t.start._1)(t.end._1);return[{x:e,y:t.start._2-1,w:Be(t.start._1)(t.end._1)-e,h:2}]}if(t.direction==="V"){const e=Ae(t.start._2)(t.end._2);return[{x:t.start._1-1,y:e,w:2,h:Be(t.start._2)(t.end._2)-e}]}g()}),Ya=Ta(t=>{const e=t.start._1-t.end._1;return!((e<0?-e<1e-6:e<1e-6)&&(()=>{const n=t.start._2-t.end._2;return n<0?-n<1e-6:n<1e-6})())}),dC=t=>e=>n=>{const r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),e);if(r.tag==="Nothing")return[{start:t.start,end:n.end,direction:t.direction}];if(r.tag==="Just"){const o=(r._1.head.direction==="H"?t.direction==="H":r._1.head.direction==="V"&&t.direction==="V")?[{start:t.start,end:r._1.head.end,direction:t.direction}]:[t,r._1.head],i=Sr(r._1.tail);if(i.tag==="Nothing"){const a=o.length-1|0;return a>=0&&a<o.length&&(o[a].direction==="H"?n.direction==="H":o[a].direction==="V"&&n.direction==="V")?[...(()=>{const s=o.length-1|0;return s<1?[]:Bt(0,s,o)})(),{start:o[a].start,end:n.end,direction:n.direction}]:[...o,n]}if(i.tag==="Just")return(i._1.last.direction==="H"?n.direction==="H":i._1.last.direction==="V"&&n.direction==="V")?[...o,...i._1.init,{start:i._1.last.start,end:n.end,direction:n.direction}]:[...o,...r._1.tail,n]}g()},Xa=t=>{const e=r=>o=>{const i=Ft(a=>y,a=>s=>w("Just",{head:a,tail:s}),o);if(i.tag==="Nothing")return[r];if(i.tag==="Just")return(r.direction==="H"?i._1.head.direction==="H":r.direction==="V"&&i._1.head.direction==="V")&&(()=>{if(r.direction==="H")return r.end._1-r.start._1>=0==i._1.head.end._1-i._1.head.start._1>=0;if(r.direction==="V")return r.end._2-r.start._2>=0==i._1.head.end._2-i._1.head.start._2>=0;g()})()?e({start:r.start,end:i._1.head.end,direction:r.direction})(i._1.tail):[r,...e(i._1.head)(i._1.tail)];g()},n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),t);if(n.tag==="Nothing")return[];if(n.tag==="Just")return e(n._1.head)(n._1.tail);g()},Za=t=>e=>n=>r=>Ch(o=>n>=o.y&&n<o.y+o.h&&e>o.x&&t<o.x+o.w)(r),ja=t=>e=>n=>r=>Za(Ae(e)(n))(Be(e)(n))(r)(t),lC=t=>e=>n=>r=>{const o=n+2|0,i=o<1?e:Bt(o,e.length,e),a=n<1?[]:Bt(0,n,e),s=(n+1|0)===(r-1|0),u=n===0,c=n>=0&&n<e.length?w("Just",e[n]):y;if(c.tag==="Just"){const _=n+1|0,f=_>=0&&_<e.length?w("Just",e[_]):y;if(f.tag==="Just"){const l=c._1.start._1===f._1.end._1&&(!u||c._1.direction==="V")&&(!s||f._1.direction==="V")&&!Su(t)(Ae(c._1.start._2)(f._1.end._2))(Be(c._1.start._2)(f._1.end._2))(c._1.start._1)?w("Just",[...a,{start:c._1.start,end:f._1.end,direction:Ne},...i]):y,d=c._1.start._2===f._1.end._2&&(!u||c._1.direction==="H")&&(!s||f._1.direction==="H")&&!ja(t)(Ae(c._1.start._1)(f._1.end._1))(Be(c._1.start._1)(f._1.end._1))(c._1.start._2)?w("Just",[...a,{start:c._1.start,end:f._1.end,direction:Te},...i]):y;return l.tag==="Nothing"?d:l}if(f.tag==="Nothing")return y;g()}if(c.tag==="Nothing")return y;g()},hC=t=>e=>{const n=e.length;return(r=>{let o=r,i=!0,a;for(;i;){const s=o;if((s+1|0)>=n){i=!1,a=e;continue}const u=lC(t)(e)(s)(n);if(u.tag==="Just"){i=!1,a=u._1;continue}if(u.tag==="Nothing"){o=s+1|0;continue}g()}return a})(0)},pC=t=>e=>n=>r=>{const o=(l,d,h)=>!Su(t)(Ae(d)(h))(Be(d)(h))(l),i=n+3|0,a=i<1?e:Bt(i,e.length,e),s=n<1?[]:Bt(0,n,e),u=(n+2|0)===(r-1|0),c=n===0,_=(l,d,h)=>!ja(t)(Ae(d)(h))(Be(d)(h))(l),f=n>=0&&n<e.length?w("Just",e[n]):y;if(f.tag==="Just"){const l=n+2|0,d=l>=0&&l<e.length?w("Just",e[l]):y;if(d.tag==="Just"){const h=f._1.start._1===d._1.end._1&&(!c||f._1.direction==="V")&&(!u||d._1.direction==="V")&&o(f._1.start._1,f._1.start._2,d._1.end._2)?w("Just",[...s,{start:f._1.start,end:d._1.end,direction:Ne},...a]):f._1.start._2===d._1.end._2&&(!c||f._1.direction==="H")&&(!u||d._1.direction==="H")&&_(f._1.start._2,f._1.start._1,d._1.end._1)?w("Just",[...s,{start:f._1.start,end:d._1.end,direction:Te},...a]):y,m=(!c||f._1.direction==="V")&&(!u||d._1.direction==="H")&&o(f._1.start._1,f._1.start._2,d._1.end._2)&&_(d._1.end._2,f._1.start._1,d._1.end._1)?w("Just",[...s,{start:f._1.start,end:E(f._1.start._1,d._1.end._2),direction:Ne},{start:E(f._1.start._1,d._1.end._2),end:d._1.end,direction:Te},...a]):y,p=(!c||f._1.direction==="H")&&(!u||d._1.direction==="V")&&_(f._1.start._2,f._1.start._1,d._1.end._1)&&o(d._1.end._1,f._1.start._2,d._1.end._2)?w("Just",[...s,{start:f._1.start,end:E(d._1.end._1,f._1.start._2),direction:Te},{start:E(d._1.end._1,f._1.start._2),end:d._1.end,direction:Ne},...a]):y,x=m.tag==="Nothing"?p:m;return h.tag==="Nothing"?x:h}if(d.tag==="Nothing")return y;g()}if(f.tag==="Nothing")return y;g()},mC=t=>e=>{const n=e.length;return(r=>{let o=r,i=!0,a;for(;i;){const s=o;if((s+2|0)>=n){i=!1,a=e;continue}const u=pC(t)(e)(s)(n);if(u.tag==="Just"){i=!1,a=u._1;continue}if(u.tag==="Nothing"){o=s+1|0;continue}g()}return a})(0)},yC=t=>{const e=n=>{let r=n,o=!0,i;for(;o;){const a=r,s=Xa(Ya(hC(t)(mC(t)(a))));if(s.length<a.length){r=s;continue}o=!1,i=s}return i};return n=>e(Xa(Ya(n)))},xC=t=>e=>n=>r=>{const o=Ae(n)(r),i=Be(n)(r),a=_t(u=>e>=u.y&&e<u.y+u.h&&u.x+u.w>o&&u.x<i,t);if(r>n){const u=Pt(c=>_=>at.compare(c.x)(_.x))(a);return 0<u.length?u[0].x-1:(n+r)/2}const s=Pt(u=>c=>at.compare(c.x)(u.x))(Y(u=>({...u,x:u.x+u.w}))(a));return 0<s.length?s[0].x+1:(n+r)/2},JC=t=>e=>n=>r=>{const o=Ae(n)(r),i=Be(n)(r),a=_t(u=>e>=u.x&&e<u.x+u.w&&u.y+u.h>o&&u.y<i,t);if(r>n){const u=Pt(c=>_=>at.compare(c.y)(_.y))(a);return 0<u.length?u[0].y-1:(n+r)/2}const s=Pt(u=>c=>at.compare(c.y)(u.y))(Y(u=>({...u,y:u.y+u.h}))(a));return 0<s.length?s[0].y+1:(n+r)/2},wC=t=>e=>n=>r=>{const o=Ae(n)(r),i=Be(n)(r),a=_t(u=>e>=u.y&&e<u.y+u.h&&u.x+u.w>o&&u.x<i,t);if(r>n){const u=Pt(c=>_=>at.compare(_.x)(c.x))(Y(c=>({...c,x:c.x+c.w}))(a));return 0<u.length?u[0].x:(n+r)/2}const s=Pt(u=>c=>at.compare(u.x)(c.x))(a);return 0<s.length?s[0].x-1:(n+r)/2},TC=t=>e=>n=>r=>{const o=Ae(n)(r),i=Be(n)(r),a=_t(u=>e>=u.x&&e<u.x+u.w&&u.y+u.h>o&&u.y<i,t);if(r>n){const u=Pt(c=>_=>at.compare(_.y)(c.y))(Y(c=>({...c,y:c.y+c.h}))(a));return 0<u.length?u[0].y:(n+r)/2}const s=Pt(u=>c=>at.compare(u.y)(c.y))(a);return 0<s.length?s[0].y-1:(n+r)/2},Lh=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i;if(_>100){a=!1,s=c;continue}if(!u(c+_)){a=!1,s=c+_;continue}if(!u(c-_)){a=!1,s=c-_;continue}r=u,o=c,i=_+1}return s},kh=t=>e=>n=>r=>o=>{const i=Ae(e)(n),a=Be(e)(n);if(!Ka(i)(a)(r)(t))return r;if(!Ka(i)(a)(o)(t))return o;const s=(r+o)/2;return Ka(i)(a)(s)(t)?Lh(u=>Ka(i)(a)(u)(t))(s)(1):s},NC=t=>e=>n=>r=>o=>{const i=Ae(e)(n),a=Be(e)(n);if(!Za(i)(a)(r)(t))return r;if(!Za(i)(a)(o)(t))return o;const s=(r+o)/2;return Za(i)(a)(s)(t)?Lh(u=>Za(i)(a)(u)(t))(s)(1):s},vC=t=>e=>n=>r=>{const o=Ae(e)(n),i=Be(e)(n),a=_t(c=>r>=c.x&&r<c.x+c.w&&c.y+c.h>o&&c.y<i,t),s=v(c=>_=>Be(c)(_.x+_.w+4))(r+4)(a),u=v(c=>_=>Ae(c)(_.x-4))(r-4)(a);return(()=>{const c=s-r,_=u-r;return(c<0?-c:c)<=(_<0?-_:_)})()?s:u},bC=t=>e=>n=>r=>{const o=Ae(e)(n),i=Be(e)(n),a=_t(c=>r>=c.y&&r<c.y+c.h&&c.x+c.w>o&&c.x<i,t),s=v(c=>_=>Be(c)(_.y+_.h+4))(r+4)(a),u=v(c=>_=>Ae(c)(_.y-4))(r-4)(a);return(()=>{const c=s-r,_=u-r;return(c<0?-c:c)<=(_<0?-_:_)})()?s:u},CC=t=>e=>n=>r=>o=>i=>a=>{const s=(()=>{if(r==="South")return E(o._1,o._2+4);if(r==="North")return E(o._1,o._2-4);if(r==="East")return E(o._1+4,o._2);if(r==="West")return E(o._1-4,o._2);g()})(),u=(()=>{if(i==="South")return E(a._1,a._2+4);if(i==="North")return E(a._1,a._2-4);if(i==="East")return E(a._1+4,a._2);if(i==="West")return E(a._1-4,a._2);g()})(),c=(k,C,P)=>!Su(e)(Ae(C)(P))(Be(C)(P))(k),_=(k,C,P)=>!Su(n)(Ae(C)(P))(Be(C)(P))(k),f=(k,C,P,G)=>t.tag==="Just"&&!ja(n)(Ae(k)(C))(Be(k)(C))(t._1)?t._1:NC(e)(k)(C)(P)(G),l=(k,C,P,G)=>{if(k===P){const U=vC(e)(C)(G)(k),S=JC(e)(k)(C)(G),b=TC(e)(k)(C)(G);return[{start:E(k,C),end:E(k,S),direction:Ne},{start:E(k,S),end:E(U,S),direction:Te},{start:E(U,S),end:E(U,b),direction:Ne},{start:E(U,b),end:E(P,b),direction:Te},{start:E(P,b),end:E(P,G),direction:Ne}]}const R=f(k,P,C,G);return[{start:E(k,C),end:E(k,R),direction:Ne},{start:E(k,R),end:E(P,R),direction:Te},{start:E(P,R),end:E(P,G),direction:Ne}]},d=(k,C,P,G)=>{if(C===G){const U=bC(e)(k)(P)(C),S=xC(e)(C)(k)(P),b=wC(e)(C)(k)(P);return[{start:E(k,C),end:E(S,C),direction:Te},{start:E(S,C),end:E(S,U),direction:Ne},{start:E(S,U),end:E(b,U),direction:Te},{start:E(b,U),end:E(b,G),direction:Ne},{start:E(b,G),end:E(P,G),direction:Te}]}const R=kh(e)(C)(G)(k)(P);return[{start:E(k,C),end:E(R,C),direction:Te},{start:E(R,C),end:E(R,G),direction:Ne},{start:E(R,G),end:E(P,G),direction:Te}]},h=(k,C,P)=>!ja(e)(Ae(C)(P))(Be(C)(P))(k),m=(k,C,P)=>!ja(n)(Ae(C)(P))(Be(C)(P))(k),p=(k,C,P,G)=>{if(m(C,k,P)&&_(P,C,G))return[{start:E(k,C),end:E(P,C),direction:Te},{start:E(P,C),end:E(P,G),direction:Ne}];const R=kh(e)(C)(G)(k)(P);return[{start:E(k,C),end:E(R,C),direction:Te},{start:E(R,C),end:E(R,G),direction:Ne},{start:E(R,G),end:E(P,G),direction:Te}]},x=(k,C,P,G)=>{if(_(k,C,G)&&m(G,k,P))return[{start:E(k,C),end:E(k,G),direction:Ne},{start:E(k,G),end:E(P,G),direction:Te}];const R=f(k,P,C,G);return[{start:E(k,C),end:E(k,R),direction:Ne},{start:E(k,R),end:E(P,R),direction:Te},{start:E(P,R),end:E(P,G),direction:Ne}]},J=(()=>{if(r==="South")return i==="North"?s._1===u._1&&c(s._1,s._2,u._2)?[{start:E(s._1,s._2),end:E(u._1,u._2),direction:Ne}]:l(s._1,s._2,u._1,u._2):i==="East"||i==="West"?x(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="North")return i==="South"?s._1===u._1&&c(s._1,s._2,u._2)?[{start:E(s._1,s._2),end:E(u._1,u._2),direction:Ne}]:l(s._1,s._2,u._1,u._2):i==="East"||i==="West"?x(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="East")return i==="West"?s._2===u._2&&h(s._2,s._1,u._1)?[{start:E(s._1,s._2),end:E(u._1,u._2),direction:Te}]:d(s._1,s._2,u._1,u._2):i==="North"||i==="South"?p(s._1,s._2,u._1,u._2):l(s._1,s._2,u._1,u._2);if(r==="West"){if(i==="East")return s._2===u._2&&h(s._2,s._1,u._1)?[{start:E(s._1,s._2),end:E(u._1,u._2),direction:Te}]:d(s._1,s._2,u._1,u._2);if(i==="North"||i==="South")return p(s._1,s._2,u._1,u._2)}return l(s._1,s._2,u._1,u._2)})(),T=(()=>{if(r==="South"||r==="North")return Ne;if(r==="East"||r==="West")return Te;g()})(),N={start:E(u._1,u._2),end:E(a._1,a._2),direction:(()=>{if(i==="South"||i==="North")return Ne;if(i==="East"||i==="West")return Te;g()})()};return s._1===u._1&&s._2===u._2?[{start:E(o._1,o._2),end:E(a._1,a._2),direction:T}]:dC({start:E(o._1,o._2),end:E(s._1,s._2),direction:T})(J)(N)},LC=Y(t=>({x:t.position._1*Eu-2,y:t.position._2*Eu-2,w:t.size._1*Eu+4,h:t.size._2*Eu+4})),Sh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},_a=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},kC=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),k_=t=>e=>t.gapTop+1*ot(4)+ot(e)*2.5*ot(4),SC=t=>e=>{const n=Sh(e.edge.id)(t);if(n.tag==="Just"){if(n._1.partner.tag==="Just")return w("Just",{slot1Y:k_(n._1)(n._1.slot),splitX:n._1.partner._1.splitX,slot2Y:k_(n._1)(n._1.partner._1.slot)});if(n._1.partner.tag==="Nothing")return y;g()}if(n.tag==="Nothing")return y;g()},EC=t=>e=>{const n=v(r=>o=>it(B)(o.node)(o)(r))(O)(e);return Ln(Mt(r=>o=>{const i=_a(o.node)(n);if(i.tag==="Nothing")return[];if(i.tag==="Just"){const a=i._1;return Mt(s=>u=>{const c=o.edges.length,_=ot(4),f=a.position._1*_,l=a.position._2*_,d=a.size._2*_,h=ot((2*c|0)+1|0),m=l+d*ot(c-s|0)/h,p=l+d*ot((c+1|0)+s|0)/h,x=f-_*2.5*ot(s+1|0),J=[{start:E(f,m),end:E(x,m),direction:Te},{start:E(x,m),end:E(x,p),direction:Ne},{start:E(x,p),end:E(f,p),direction:Te}];return{edge:u.id,segments:J,bends:Oe(T=>N=>T.end,J,Bt(1,3,J)),bendType:[],jumps:[],reversed:!1}})(o.edges)}g()})(Y(r=>({node:r._1,edges:r._2}))(kC(v(r=>o=>Ot(B)(Je)(o.from.node)([o])(r))(O)(t)))))},PC=t=>e=>{const n=v(i=>a=>it(B)(a.node)(a)(i))(O)(e),r=i=>{const a=_a(i)(n);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1.position._1;g()},o=i=>{const a=_a(i)(n);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1.layer;g()};return Pt(i=>a=>{const s=ut.compare(o(i.edge.from.node))(o(a.edge.from.node));if(s==="EQ"){const u=at.compare(r(i.edge.from.node))(r(a.edge.from.node));return u==="EQ"?at.compare(r(i.edge.to.node))(r(a.edge.to.node)):u}return s})(t)},wn=t=>{const e=ot(4);return{x:t.position._1*e-2,y:t.position._2*e-2,w:t.size._1*e+4,h:t.size._2*e+4}},GC=t=>t.from.node===t.to.node,AC=t=>e=>n=>r=>{const o=yC(n)(CC(t)(e)(n)(r.fromSide)(r.fromPos)(r.toSide)(r.toPos));return{edge:r.edge.id,segments:o,bends:Oe(i=>a=>i.end,o,Bt(1,o.length,o)),bendType:[],jumps:[],reversed:!1}},BC=t=>e=>n=>r=>{const o=[{start:E(r.fromPos._1,r.fromPos._2),end:E(r.fromPos._1,t.slot1Y),direction:Ne},{start:E(r.fromPos._1,t.slot1Y),end:E(t.splitX,t.slot1Y),direction:Te},{start:E(t.splitX,t.slot1Y),end:E(t.splitX,t.slot2Y),direction:Ne},{start:E(t.splitX,t.slot2Y),end:E(r.toPos._1,t.slot2Y),direction:Te},{start:E(r.toPos._1,t.slot2Y),end:E(r.toPos._1,r.toPos._2),direction:Ne}];return{edge:r.edge.id,segments:o,bends:Oe(i=>a=>i.end,o,Bt(1,5,o)),bendType:[],jumps:[],reversed:!1}},RC=t=>e=>n=>{const r=_a(t.edge.from.node)(n);if(r.tag==="Just"){const i=_a(t.edge.to.node)(n);return i.tag==="Just"?_t(a=>!(a.h===wn(r._1).h&&a.w===wn(r._1).w&&a.x===wn(r._1).x&&a.y===wn(r._1).y)&&!(a.h===wn(i._1).h&&a.w===wn(i._1).w&&a.x===wn(i._1).x&&a.y===wn(i._1).y),e):_t(a=>!(a.h===wn(r._1).h&&a.w===wn(r._1).w&&a.x===wn(r._1).x&&a.y===wn(r._1).y),e)}const o=_a(t.edge.to.node)(n);return o.tag==="Just"?_t(i=>!(i.h===wn(o._1).h&&i.w===wn(o._1).w&&i.x===wn(o._1).x&&i.y===wn(o._1).y),e):_t(i=>!0,e)},DC=t=>e=>{const n=Sh(e.edge.id)(t);if(n.tag==="Just")return w("Just",k_(n._1)(n._1.slot));if(n.tag==="Nothing")return y;g()},FC=t=>e=>n=>r=>o=>{const i=v(c=>_=>it(B)(_.node)(_)(c))(O)(e),a=LC(e),s=sh(_t(c=>c.from.node!==c.to.node,t))(e)(n)(r)(o),u=nh(s)(e);return[...EC(_t(GC,t))(e),...v(c=>_=>{const f=RC(_)(a)(i),l=[...f,...c.edgeObstacles],d=SC(u)(_),h=(()=>{if(d.tag==="Just")return BC(d._1)(f)(l)(_);if(d.tag==="Nothing")return AC(DC(u)(_))(f)(l)(_);g()})();return{results:[...c.results,h],edgeObstacles:[...c.edgeObstacles,...fC(h.segments)]}})({results:[],edgeObstacles:[]})(PC(s)(e)).results]},wo=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},To=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},zC=t=>e=>n=>{if(t.start._1!==e.start._1)return y;const r=To(wo(t.start._2)(t.end._2))(wo(e.start._2)(e.end._2)),o=wo(To(t.start._2)(t.end._2))(To(e.start._2)(e.end._2));return r<o?w("Just",{position:E(t.start._1,(r+o)/2),crossingEdge:n}):y},IC=t=>e=>n=>{if(t.start._2!==e.start._2)return y;const r=To(wo(t.start._1)(t.end._1))(wo(e.start._1)(e.end._1)),o=wo(To(t.start._1)(t.end._1))(To(e.start._1)(e.end._1));return r<o?w("Just",{position:E((r+o)/2,t.start._2),crossingEdge:n}):y},QC=t=>e=>n=>{if(t.direction==="H")return IC(t)(e)(n);if(t.direction==="V")return zC(t)(e)(n);g()},MC=t=>e=>n=>{const r=t+1|0,o=r<1?n:Bt(r,n.length,n);return St(e.segments)(i=>St(o)(a=>ht(s=>QC(i)(s)(a.edge))(_t(s=>s.direction==="H"?i.direction==="H":s.direction==="V"&&i.direction==="V",a.segments))))},OC=t=>e=>n=>e.start._1>wo(t.start._1)(t.end._1)&&e.start._1<To(t.start._1)(t.end._1)&&t.start._2>wo(e.start._2)(e.end._2)&&t.start._2<To(e.start._2)(e.end._2)?w("Just",{position:E(e.start._1,t.start._2),crossingEdge:n}):y,WC=t=>e=>St(_t(n=>n.direction==="H",t.segments))(n=>St(e)(r=>ht(o=>OC(n)(o)(r.edge))(_t(o=>o.direction==="V",r.segments)))),HC=t=>e=>n=>[...WC(e)(_t(r=>r.edge!==e.edge,n)),...MC(t)(e)(n)],Eh=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},$C=v(t=>e=>it(B)(e)()(t))(O),Pu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},qC=ql(B),zr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Ph=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},S_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},VC=fe(ut)(Qt),UC=t=>e=>en(B.compare,je,t,e),Gh=Mt(t=>e=>({src:e.src,tgt:e.tgt,delta:1,weight:1,eid:t})),KC=t=>v(e=>n=>({base:(()=>{const r=o=>i=>{let a=o,s=i,u=!0,c;for(;u;){const _=a,f=s;if(f.tag==="Nil"){u=!1,c=_;continue}if(f.tag==="Cons"){a=Eh(_)(f._1),s=f._2;continue}g()}return c};return(e.base+r(0)((()=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,Jt("Cons",i._4,o(i._6,a)));g()};return o(n,z)})())|0)+1|0})(),result:[...e.result,(()=>{if(e.base===0)return n;const r=o=>{if(o.tag==="Leaf")return O;if(o.tag==="Node")return ee("Node",o._1,o._2,o._3,o._4+e.base|0,r(o._5),r(o._6));g()};return r(n)})()]}))({base:0,result:[]})(t).result,YC=t=>e=>{const n=$C(t);return qC(t)(Gh(_t(r=>Pu(r.src)(n)&&Pu(r.tgt)(n),e)))},XC=t=>e=>{const n=v(o=>i=>Ot(B)(Je)(i.tgt)([i.src])(Ot(B)(Je)(i.src)([i.tgt])(o)))(O)(e),r=o=>i=>a=>{let s=o,u=i,c=a,_=!0,f;for(;_;){const l=s,d=u,h=c,m=Ft(p=>y,p=>x=>w("Just",{head:p,tail:x}),l);if(m.tag==="Nothing"){_=!1,f={nodes:h};continue}if(m.tag==="Just"){if(Pu(m._1.head)(d)){s=m._1.tail,u=d,c=h;continue}s=[...m._1.tail,...(()=>{const p=zr(m._1.head)(n);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()})()],u=it(B)(m._1.head)()(d),c=[...h,m._1.head];continue}g()}return f};return v(o=>i=>{if(Pu(i)(o.visited))return o;const a=r([i])(o.visited)([]);return{...o,visited:v(s=>u=>it(B)(u)()(s))(o.visited)(a.nodes),components:[...o.components,a.nodes]}})({visited:O,components:[]})(t).components},ZC=t=>e=>n=>{const r=v(i=>a=>Ot(B)(be)(a.tgt)(1)(i))(O)(e),o=v(i=>a=>Ot(B)(be)(a.src)(1)(i))(O)(e);return v(i=>a=>{const s=zr(a)(r),u=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();if((()=>{const J=zr(a)(o);return(()=>{if(J.tag==="Nothing")return u!==0;if(J.tag==="Just")return u!==J._1;g()})()||u===0})())return i;const c=zr(a)(i.layers),_=(()=>{if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1;g()})(),f=i.layers,l=v(J=>T=>T.tgt===a?{...J,mIn:Ph(J.mIn)((()=>{const N=zr(a)(f),k=zr(T.src)(f);return(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})()-(()=>{if(k.tag==="Nothing")return 0;if(k.tag==="Just")return k._1;g()})()|0})())}:T.src===a?{...J,mOut:Ph(J.mOut)((()=>{const N=zr(T.tgt)(f),k=zr(a)(f);return(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})()-(()=>{if(k.tag==="Nothing")return 0;if(k.tag==="Just")return k._1;g()})()|0})())}:J)({mIn:1e9,mOut:1e9})(e),d=l.mIn===1e9?-1:l.mIn,h=l.mOut===1e9?-1:l.mOut;if(d<0||h<0)return i;const m=(_-d|0)+1|0,p=(_+h|0)-1|0;if(p<m)return i;const x=v(J=>T=>{const N=S_(T)(i.filling),k=(()=>{if(N.tag==="Nothing")return 0;if(N.tag==="Just")return N._1;g()})();return k<J.bestFill?{best:T,bestFill:k}:J})({best:_,bestFill:(()=>{const J=S_(_)(i.filling);if(J.tag==="Nothing")return 0;if(J.tag==="Just")return J._1;g()})()})(Ut(m,p));return x.best===_?i:{layers:it(B)(a)(x.best)(i.layers),filling:it(ut)(_)((()=>{const J=S_(_)(i.filling);if(J.tag==="Nothing")return-1;if(J.tag==="Just")return J._1-1|0;g()})())(it(ut)(x.best)(x.bestFill+1|0)(i.filling))}})({layers:n,filling:VC(Y(i=>E(i,v(a=>s=>(()=>{const u=zr(s)(n);return u.tag==="Nothing"?!1:u.tag==="Just"&&u._1===i})()?a+1|0:a)(0)(t)))(Ut(0,v(i=>a=>Eh(i)((()=>{const s=zr(a)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(0)(t))))})(t).layers},jC=t=>e=>ZC(t)(Gh(e))(v(UC)(O)(KC(Y(n=>YC(n)(e))(XC(t)(e))))),t3=t=>t,ci=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Gu=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ah=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),e3=t3("NetworkSimplex"),n3=t=>e=>v(n=>r=>{const o=v(Gu)(0)(ht(i=>ci(i)(n))(r));return v(i=>a=>it(B)(a)(o)(i))(n)(r)})(e)(t),r3=t=>e=>({layers:Y(n=>_t(r=>{const o=ci(r)(e);return o.tag==="Nothing"?!1:o.tag==="Just"&&o._1===n},t))(Ut(0,(n=>r=>{let o=n,i=r,a=!0,s;for(;a;){const u=o,c=i;if(c.tag==="Nil"){a=!1,s=u;continue}if(c.tag==="Cons"){o=Gu(u)(c._1),i=c._2;continue}g()}return s})(0)((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._4,n(r._6,o)));g()};return n(e,z)})()))),nodeLayer:e}),o3=t=>e=>n=>{const r=v(o=>i=>it(B)(i)(!0)(o))(O)(e);return v(o=>i=>it(B)(i._1)(i._2)(o))(jC(e)(ht(o=>o.from.node===o.to.node||(()=>{const i=ci(o.from.node)(r);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return!i._1;g()})()||(()=>{const i=ci(o.to.node)(r);if(i.tag==="Nothing")return!0;if(i.tag==="Just")return!i._1;g()})()?y:w("Just",{src:o.from.node,tgt:o.to.node}))(t)))(Ah(n))},i3=t=>e=>n=>r=>{const o=s=>u=>{const c=ci(u)(s);if(c.tag==="Just")return s;if(c.tag==="Nothing"){const _=_t(l=>l!==u,(()=>{const l=ci(u)(t);if(l.tag==="Nothing")return[];if(l.tag==="Just")return l._1;g()})()),f=v(o)(s)(_);return it(B)(u)(1+v(Gu)(0)(ht(l=>ci(l)(f))(_))|0)(f)}g()},i=v(o)(O)(n),a=(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Nil"){f=!1,l=d;continue}if(h.tag==="Cons"){c=Gu(d)(h._1),_=h._2;continue}g()}return l})(1)((()=>{const s=(u,c)=>{if(u.tag==="Leaf")return c;if(u.tag==="Node")return s(u._5,Jt("Cons",u._4,s(u._6,c)));g()};return s(i,z)})());return v(s=>u=>it(B)(u._1)(u._2)(s))((()=>{const s=u=>{if(u.tag==="Leaf")return O;if(u.tag==="Node")return ee("Node",u._1,u._2,u._3,a-u._4|0,s(u._5),s(u._6));g()};return s(i)})())(Ah(r))},a3=v(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return it(B)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return it(B)(e._1.node)(0)(t)}return t})(O),s3=v(t=>e=>Ot(B)(Je)(e.to.node)([e.from.node])(t))(O),u3=v(t=>e=>Ot(B)(Je)(e.from.node)([e.to.node])(t))(O),c3=t=>e=>n=>r=>{const o=u3(n),i=s3(n),a=a3(e);return r3(r)(n3(ht(s=>s.tag==="SameLayer"?w("Just",s._1.nodes):y)(e))((()=>{if(t==="LongestPath")return i3(o)(i)(r)(a);if(t==="NetworkSimplex")return o3(n)(r)(a);g()})()))},g3=fe(B)(Qt),_3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Bh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Rh=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ts=fe(B)(Qt),f3=fe(B)(Qt),Dh=(()=>{const t=Y(e=>({start:e.end,end:e.start,direction:e.direction}));return e=>re(t(e))})(),d3=t=>e=>n=>r=>{const o=g3(Y(a=>E(a.edge,a))(r)),i=a=>0<a.nodes.length&&(()=>{const s=_3(a.edgeId)(n);return s.tag==="Just"&&a.nodes[0]!==s._1._1})();return Y(a=>{if(a.nodes.length<=2){const _=Bh(a.edgeId)(o);if(_.tag==="Just"){const f=i(a),l=Xa(Ya(f?Dh(_._1.segments):_._1.segments));return{..._._1,edge:a.edgeId,segments:l,bends:Oe(d=>h=>d.end,l,Bt(1,l.length,l)),reversed:f}}if(_.tag==="Nothing")return{edge:a.edgeId,segments:[],bends:[],bendType:[],jumps:[],reversed:!1};g()}const s=St(ht(_=>Bh(_)(o))(Oe(_=>f=>a.edgeId+":"+_+"->"+f,a.nodes,Bt(1,a.nodes.length,a.nodes))))(_=>_.segments),u=i(a),c=Xa(Ya(u?Dh(s):s));return{edge:a.edgeId,segments:c,bends:Oe(_=>f=>_.end,c,Bt(1,c.length,c)),bendType:[],jumps:[],reversed:u}})(t)},l3={layers:[],edges:[],chains:[]},Fh={nodeGap:3,layerGap:2,iterations:8,layerer:e3,cycleBreaker:iC,compactPostRouting:!0,compactionSpacings:sb},h3=t=>({pos:E(0,0),size:E(v(e=>n=>Rh(e)(n.position._1+n.size._1))(0)(t),v(e=>n=>Rh(e)(n.position._2+n.size._2))(0)(t))}),p3=t=>e=>n=>{const r=ts(Y(c=>E(c.id,c.ports))(e.nodes)),o=_t(c=>Ve(3)(c.node)!=="$d:",n.placements),i=d3(n.withDummies.chains)(n.acyclic.reversedEdges)(f3(Y(c=>E(c.id,E(c.from.node,c.to.node)))(e.edges)))(FC(n.withDummies.edges)(n.placements)(r)(n.withDummies.chains)(ch(n.ordered)(_t(c=>c.from.node!==c.to.node,n.withDummies.edges))((()=>{const c=_=>{if(_.tag==="Leaf")return O;if(_.tag==="Node")return ee("Node",_._1,_._2,_._3,E(_._4._1*4,_._4._2),c(_._5),c(_._6));g()};return c(ts(Y(_=>E(_.id,_.size))(e.nodes)))})()))),a=t.compactPostRouting?gb()(t.compactionSpacings)({nodes:o,edges:e.edges,paths:i,ports:r}):{nodes:o,edges:i},s=Y(c=>{const _=Xa(Ya(c.segments));return{...c,segments:_,bends:Oe(f=>l=>f.end,_,Bt(1,_.length,_))}})(a.edges),u=Mt(c=>_=>({..._,jumps:HC(c)(_)(s)}))(s);return{nodes:a.nodes,edges:u,boundingBox:h3(a.nodes),metrics:DN(a.nodes)(u)(0)}},zh=t=>e=>n=>{const r=ts(Y(i=>E(i.id,i.size))(e.nodes)),o={...n,placements:Ob({nodeGap:t.nodeGap,layerGap:t.layerGap})(e.constraints)(n.ordered)(r)(ts(Y(i=>E(i.id,i.ports))(e.nodes)))(n.withDummies.edges)(n.withDummies.chains)(ch(n.ordered)(n.withDummies.edges)((()=>{const i=a=>{if(a.tag==="Leaf")return O;if(a.tag==="Node")return ee("Node",a._1,a._2,a._3,E(a._4._1*4,a._4._2),i(a._5),i(a._6));g()};return i(r)})()))};return{pipeline:o,result:p3(t)(e)(o)}},m3=t=>e=>n=>zh(t)(e)({...n,ordered:eC({iterations:t.iterations,constraints:e.constraints,modelOrder:ts(Mt(r=>o=>E(o.id,r))(e.nodes))})(n.withDummies.layers)(n.withDummies.edges)}),y3=t=>e=>n=>m3(t)(e)({...n,withDummies:_b(n.layered.nodeLayer)(n.acyclic.edges)(n.layered.layers)}),Ih=t=>e=>{const n=Y(o=>o.id)(e.nodes),r=_C(t.cycleBreaker)(n)(e.constraints)(e.edges);return y3(t)(e)({acyclic:r,layered:c3(t.layerer)(e.constraints)(r.edges)(n),withDummies:l3,ordered:[],placements:[]})},Qh=fe(B)(Qt),fa=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Au=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},No=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},x3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},J3=t=>e=>n=>{const r=n.result.nodes,o=Qh(Y(a=>E(a.node,a))(r)),i=n.result.boundingBox.size._1;return Qh(ht(a=>{const s=No(a.id)(o);if(s.tag==="Just"){const u=No(a.id)(n.pipeline.layered.nodeLayer);if(u.tag==="Just"){const c=u._1,_=Ft(f=>y,f=>l=>w("Just",{head:f,tail:l}),_t(f=>f.length>=2,[ht(f=>{if(f.to.node===a.id){const l=No(f.from.node)(n.pipeline.layered.nodeLayer);if(l.tag==="Just")return l._1>=c?y:No(f.from.node)(o);if(l.tag==="Nothing")return y;g()}return y})(e.edges),ht(f=>{if(f.from.node===a.id){const l=No(f.to.node)(n.pipeline.layered.nodeLayer);if(l.tag==="Just")return l._1<=c?y:No(f.to.node)(o);if(l.tag==="Nothing")return y;g()}return y})(e.edges)]));if(_.tag==="Just"){const f=Au(v(fa)((()=>{const m=Ft(p=>y,p=>x=>w("Just",{head:p,tail:x}),Y(p=>p.position._1+p.size._1*.5)(_._1.head));if(m.tag==="Nothing")return a.size._1;if(m.tag==="Just")return fa(a.size._1)(v(fa)(m._1.head)(m._1.tail)-v(Au)(m._1.head)(m._1.tail)+2);g()})())(Y(m=>{const p=Ft(x=>y,x=>J=>w("Just",{head:x,tail:J}),Y(x=>x.position._1+x.size._1*.5)(m));if(p.tag==="Nothing")return a.size._1;if(p.tag==="Just")return fa(a.size._1)(v(fa)(p._1.head)(p._1.tail)-v(Au)(p._1.head)(p._1.tail)+2);g()})(_._1.tail)))(a.size._1+ot(v(x3)(_._1.head.length)(Y(ty)(_._1.tail))-1|0)),l=s._1.position._1,d=l+s._1.size._1,h=_t(m=>{const p=No(m.node)(n.pipeline.layered.nodeLayer);return m.node!==a.id&&(p.tag==="Nothing"?!1:p.tag==="Just"&&p._1===c)},r);return f>a.size._1+.5&&f<=v(m=>p=>p.position._1>=d?Au(m)(p.position._1-ot(t.nodeGap)):m)(i)(h)-v(m=>p=>p.position._1+p.size._1<=l?fa(m)(p.position._1+p.size._1+ot(t.nodeGap)):m)(0)(h)?w("Just",E(a.id,E(f,a.size._2))):y}if(_.tag==="Nothing")return y;g()}if(u.tag==="Nothing")return y;g()}if(s.tag==="Nothing")return y;g()})(e.nodes))},w3=t=>e=>{const n=Ih(t)(e),r=J3(t)(e)(n),o=zh(t)({...e,nodes:Y(i=>{const a=No(i.id)(r);if(a.tag==="Just")return{...i,size:a._1};if(a.tag==="Nothing")return i;g()})(e.nodes)})(n.pipeline);return r.tag==="Leaf"?n:o},T3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},da=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},N3=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Mh=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},v3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Oh=t=>kn(re(Er(e=>e===" ")(re(Er(e=>e===" ")(Bn(t)).rest)).rest)),b3=t=>v(e=>n=>n._1>0&&(n._2===" "||n._2==="-"||n._2==="_"||n._2===".")?w("Just",n._1):e)(y)(Mt(Cn)(t)),E_=t=>e=>{if(t<=0)return[e];if(Dn(e)<=t)return[e];const n=Bn(e),r=t<1?[]:Bt(0,t,n),o=b3(r);if(o.tag==="Just"){const i=Oh(Cf(!(o._1>=0&&o._1<r.length)||r[o._1]===" "?o._1:o._1+1|0)(e)),a=Oh(Mi(o._1+1|0)(e));return a===""?[i]:[i,...E_(t)(a)]}if(o.tag==="Nothing"){const i=Cf(t)(e),a=Mi(t)(e);return a===""?[i]:[i,...E_(t)(a)]}g()},C3={cellW:7,cellH:3,maxLineWidth:20},L3=t=>e=>{const n=Y(i=>E((()=>{if(i.label.tag==="Just")return i.label._1;if(i.label.tag==="Nothing")return i.id;g()})(),i))(e.nodes),r=da(1)(Lr((N3(t.maxLineWidth)(v(i=>a=>da(i)(Dn(a._1)))(0)(n))+2|0)+t.cellW|0,t.cellW)),o=(r*t.cellW|0)-1|0;return{...e,nodes:Y(i=>{const a=St($i(`
7
+ `)(i._1))(E_(o)),s=v(f=>l=>da(f)(Dn(l)))(0)(a),u=da(1)(Lr(a.length+t.cellH|0,t.cellH))+(i._2.shape==="Cylinder"||i._2.shape==="Document"?1:0)|0,c=i._2.shape==="Cylinder"?da(1)(Lr((s+2|0)+t.cellW|0,t.cellW)):r,_=s>o?Lr((s+2|0)+t.cellW|0,t.cellW):c;return{...i._2,size:E(i._2.size._1!==1?Mh(i._2.size._1)(ot(_)):ot(_),i._2.size._2!==1?i._2.size._2:ot(u))}})(n)}},k3=t=>e=>n=>({...n,nodes:Y(r=>{const o=v3(r.id)(e);if(o.tag==="Nothing")return r;if(o.tag==="Just")return{...r,size:E(Mh(r.size._1)(ot(da(1)(he(vs(r.shape==="Cylinder"?(o._1+0)/t:(o._1+32)/t))))),r.size._2)};g()})(n.nodes)}),Bu=t=>t,S3=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},gi=Bu("TopSide"),_i=Bu("BottomSide"),fi=Bu("LeftSide"),di=Bu("RightSide"),E3=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Wh=t=>e=>n=>{const r=S3(t.h*.12)(t.w*.2),o=t.w/2;return(e<0?t.y+r:t.y+t.h-r)+e*r*qe(E3((()=>{const i=(n-(t.x+o))/o;return 1-i*i})()))},Tn=t=>e=>n=>r=>{let o=t,i=e,a=n,s=r,u=!0,c;for(;u;){const _=o,f=i,l=a,d=s;if(_==="Rectangle"){if(l==="TopSide"){u=!1,c=f.y;continue}if(l==="BottomSide"){u=!1,c=f.y+f.h;continue}if(l==="LeftSide"){u=!1,c=f.x;continue}if(l==="RightSide"){u=!1,c=f.x+f.w;continue}o=_o,i=f,a=l,s=d;continue}if(_==="Cylinder"){if(l==="TopSide"){u=!1,c=Wh(f)(-1)(d);continue}if(l==="BottomSide"){u=!1,c=Wh(f)(1)(d);continue}if(l==="LeftSide"){u=!1,c=f.x;continue}if(l==="RightSide"){u=!1,c=f.x+f.w;continue}}o=_o,i=f,a=l,s=d}return c},Hh=t=>e=>{const n=e.y-t.y,r=n<0?-n:n,o=e.x-(t.x+t.w),i=o<0?-o:o,a=e.x-t.x,s=a<0?-a:a,u=e.y-(t.y+t.h),c=u<0?-u:u;return r<=c&&r<=s&&r<=i?gi:c<=s&&c<=i?_i:s<=i?fi:di},P3=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),P_=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},li=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},es=fe(B)(Qt),eo=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},hi=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},G_=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},G3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},A3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},B3=v(t=>e=>it(B)(e)()(t))(O),R3=v(t=>e=>it(B)(e)()(t))(O),ns=ao.traverse(kc),rs=fe(B)(Qt),D3=t=>e=>en(B.compare,je,t,e),F3=v(t=>e=>it(B)(e)()(t))(O),z3=fe(B)(Qt),I3=t=>e=>en(B.compare,je,t,e),Q3=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},M3=t=>e=>{const n=es(Y(r=>E(r._1,(()=>{const o=P_(r._1)(t);if(o.tag==="Nothing")return r._2;if(o.tag==="Just"){const i=li(o._1._2)(e.nodes),a=li(o._1._1)(e.nodes),s=(()=>{if(a.tag==="Nothing")return r._2;if(a.tag==="Just"){const u=Ft(c=>y,c=>_=>w("Just",{head:c,tail:_}),r._2);if(u.tag==="Nothing")return r._2;if(u.tag==="Just")return[(()=>{const c=Ft(d=>y,d=>h=>w("Just",{head:d,tail:h}),u._1.tail),_=c.tag==="Just"?w("Just",c._1.head):y,f={x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h},l=(()=>{if(_.tag==="Just"){if((_._1.x>u._1.head.x?_._1.x-u._1.head.x<.5:u._1.head.x-_._1.x<.5)&&u._1.head.x>=f.x-.5&&u._1.head.x<=f.x+f.w+.5)return _._1.y>=f.y+f.h?w("Just",_i):_._1.y<=f.y?w("Just",gi):y;if((_._1.y>u._1.head.y?_._1.y-u._1.head.y<.5:u._1.head.y-_._1.y<.5)&&u._1.head.y>=f.y-.5&&u._1.head.y<=f.y+f.h+.5){if(_._1.x>=f.x+f.w)return w("Just",di);if(_._1.x<=f.x)return w("Just",fi)}return y}if(_.tag==="Nothing")return y;g()})();if(l.tag==="Just"){if(l._1==="TopSide")return{...u._1.head,y:Tn(a._1.shape)(f)(gi)(u._1.head.x)};if(l._1==="BottomSide")return{...u._1.head,y:Tn(a._1.shape)(f)(_i)(u._1.head.x)};if(l._1==="LeftSide")return{...u._1.head,x:Tn(a._1.shape)(f)(fi)(u._1.head.y)};if(l._1==="RightSide")return{...u._1.head,x:Tn(a._1.shape)(f)(di)(u._1.head.y)};g()}if(l.tag==="Nothing"){const d={x:a._1.x,y:a._1.y,w:a._1.w,h:a._1.h},h=Hh(d)(u._1.head);if(h==="TopSide")return{...u._1.head,y:Tn(a._1.shape)(d)(gi)(u._1.head.x)};if(h==="BottomSide")return{...u._1.head,y:Tn(a._1.shape)(d)(_i)(u._1.head.x)};if(h==="LeftSide")return{...u._1.head,x:Tn(a._1.shape)(d)(fi)(u._1.head.y)};if(h==="RightSide")return{...u._1.head,x:Tn(a._1.shape)(d)(di)(u._1.head.y)}}g()})(),...u._1.tail]}g()})();if(i.tag==="Nothing")return s;if(i.tag==="Just"){const u=Sr(s);if(u.tag==="Nothing")return s;if(u.tag==="Just")return Et(u._1.init)((()=>{const c=Sr(u._1.init),_=c.tag==="Just"?w("Just",c._1.last):y,f={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},l=(()=>{if(_.tag==="Just"){if((_._1.x>u._1.last.x?_._1.x-u._1.last.x<.5:u._1.last.x-_._1.x<.5)&&u._1.last.x>=f.x-.5&&u._1.last.x<=f.x+f.w+.5)return _._1.y>=f.y+f.h?w("Just",_i):_._1.y<=f.y?w("Just",gi):y;if((_._1.y>u._1.last.y?_._1.y-u._1.last.y<.5:u._1.last.y-_._1.y<.5)&&u._1.last.y>=f.y-.5&&u._1.last.y<=f.y+f.h+.5){if(_._1.x>=f.x+f.w)return w("Just",di);if(_._1.x<=f.x)return w("Just",fi)}return y}if(_.tag==="Nothing")return y;g()})();if(l.tag==="Just"){if(l._1==="TopSide")return{...u._1.last,y:Tn(i._1.shape)(f)(gi)(u._1.last.x)};if(l._1==="BottomSide")return{...u._1.last,y:Tn(i._1.shape)(f)(_i)(u._1.last.x)};if(l._1==="LeftSide")return{...u._1.last,x:Tn(i._1.shape)(f)(fi)(u._1.last.y)};if(l._1==="RightSide")return{...u._1.last,x:Tn(i._1.shape)(f)(di)(u._1.last.y)};g()}if(l.tag==="Nothing"){const d={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},h=Hh(d)(u._1.last);if(h==="TopSide")return{...u._1.last,y:Tn(i._1.shape)(d)(gi)(u._1.last.x)};if(h==="BottomSide")return{...u._1.last,y:Tn(i._1.shape)(d)(_i)(u._1.last.x)};if(h==="LeftSide")return{...u._1.last,x:Tn(i._1.shape)(d)(fi)(u._1.last.y)};if(h==="RightSide")return{...u._1.last,x:Tn(i._1.shape)(d)(di)(u._1.last.y)}}g()})())}}g()})()))(P3(e.edges)));return{...e,edges:n,bounds:id(e.nodes)(n)}},O3=t=>{const e=r=>{let o=r,i=!0,a;for(;i;){const s=o,u=v(c=>_=>{if(c.tag==="Just")return c;if(c.tag==="Nothing"){const f=_>=0&&_<s.length?w("Just",s[_]):y;if(f.tag==="Just"){const l=_+1|0,d=l>=0&&l<s.length?w("Just",s[l]):y;if(d.tag==="Just"){const h=_+2|0,m=h>=0&&h<s.length?w("Just",s[h]):y;if(m.tag==="Just"){const p=_+3|0,x=p>=0&&p<s.length?w("Just",s[p]):y;if(x.tag==="Just"){const J=f._1.y===d._1.y&&d._1.x===m._1.x&&m._1.y===x._1.y&&(d._1.x-f._1.x)*(x._1.x-m._1.x)<0&&x._1.x>=hi(f._1.x)(d._1.x)&&x._1.x<=eo(f._1.x)(d._1.x)?w("Just",{x:x._1.x,y:f._1.y}):f._1.x===d._1.x&&d._1.y===m._1.y&&m._1.x===x._1.x&&(d._1.y-f._1.y)*(x._1.y-m._1.y)<0&&x._1.y>=hi(f._1.y)(d._1.y)&&x._1.y<=eo(f._1.y)(d._1.y)?w("Just",{x:f._1.x,y:x._1.y}):y;if(J.tag==="Just"){const T=J._1;return oe(N=>T.x===x._1.x?T.x>N.x&&T.x<N.x+N.w&&eo(hi(T.y)(x._1.y))(N.y)<hi(eo(T.y)(x._1.y))(N.y+N.h):T.y===x._1.y?T.y>N.y&&T.y<N.y+N.h&&eo(hi(T.x)(x._1.x))(N.x)<hi(eo(T.x)(x._1.x))(N.x+N.w):!0,t)?y:w("Just",[...(()=>{const N=_+1|0;return N<1?[]:Bt(0,N,s)})(),T,x._1,...(()=>{const N=_+4|0;return N<1?s:Bt(N,s.length,s)})()])}if(J.tag==="Nothing")return y;g()}if(x.tag==="Nothing")return y;g()}if(m.tag==="Nothing")return y;g()}if(d.tag==="Nothing")return y;g()}if(f.tag==="Nothing")return y}g()})(y)(s.length<4?[]:Ut(0,s.length-4|0));if(u.tag==="Nothing"){i=!1,a=s;continue}if(u.tag==="Just"){o=v(c=>_=>{const f=Sr(c);if(f.tag==="Nothing")return[_];if(f.tag==="Just"){if(f._1.last.x===_.x&&f._1.last.y===_.y)return c;const l=f._1.init.length-1|0;return l>=0&&l<f._1.init.length&&(f._1.init[l].x===f._1.last.x&&f._1.last.x===_.x||f._1.init[l].y===f._1.last.y&&f._1.last.y===_.y)?Et(f._1.init)(_):Et(c)(_)}g()})([])(u._1);continue}g()}return a},n=v(r=>o=>{const i=Sr(r);if(i.tag==="Nothing")return[o];if(i.tag==="Just"){if(i._1.last.x===o.x&&i._1.last.y===o.y)return r;const a=i._1.init.length-1|0;return a>=0&&a<i._1.init.length&&(i._1.init[a].x===i._1.last.x&&i._1.last.x===o.x||i._1.init[a].y===i._1.last.y&&i._1.last.y===o.y)?Et(i._1.init)(o):Et(r)(o)}g()})([]);return r=>e(n(r))},W3=t=>e=>n=>{const r=te(o=>o.id===n)(t.graph.edges);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return P_(n)(e);g()},H3=t=>e=>n=>r=>({x:r.position._1*t,y:r.position._2*t,w:r.size._1*t,h:r.size._2*t,label:(()=>{const o=li(r.node)(e);if(o.tag==="Just")return o._1;if(o.tag==="Nothing")return r.node;g()})(),shape:(()=>{const o=li(r.node)(n);if(o.tag==="Nothing")return _o;if(o.tag==="Just")return o._1;g()})()}),$3=t=>({id:t,size:E(1,1),ports:[],label:w("Just",t),shape:_o}),$h=t=>e=>n=>{const r=ht(i=>li(e)(i.labels))(t.keyframes),o=Ft(i=>y,i=>a=>w("Just",{head:i,tail:a}),r);if(o.tag==="Nothing")return[n];if(o.tag==="Just")return[n,...r];g()},q3=t=>e=>n=>r=>E(r.node,H3(t)(e)(n)(r)),qh=t=>Fn(t),Vh=t=>{const e=$i(`
8
+ `)(t),n=e.length===0?[""]:e;return n.length*G_(1)(v(r=>o=>G_(r)(Dn(o)))(0)(n))|0},V3=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return"";if(e.tag==="Just")return v(n=>r=>Vh(r)>Vh(n)?r:n)(e._1.head)(e._1.tail);g()},U3=t=>e=>V3($h(t)(e.id)((()=>{if(e.label.tag==="Just")return e.label._1;if(e.label.tag==="Nothing")return e.id;g()})())),Uh=t=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Jt("Cons",n._4,e(n._6,r)));g()};return It(ge.foldr,e(t.interiors,z))},K3=t=>es(ht(e=>w("Just",E(e.edge,{id:e.edge,from:{node:e.from,port:y},to:{node:e.to,port:y},label:y})))(St(t.scenes)(e=>e.tag==="DataFlow"?ht(n=>n.kind.tag==="SendToken"?w("Just",n.kind._1):y)(e._1.events):[]))),Kh=t=>{const e=Jx(t),n=Y(o=>({...o,label:w("Just",U3(t)(o))}))(_t(o=>G3(o.id)(e.nodes),t.graph.nodes)),r=_t(o=>A3(o.id)(e.edges),t.graph.edges);return{nodes:[...n,...Y($3)(It(xn.foldr,Yn(B.compare,e.nodes,B3(Y(o=>o.id)(n)))))],edges:[...r,...ht(W3(t)(K3(t)))(It(xn.foldr,Yn(B.compare,e.edges,R3(Y(o=>o.id)(r)))))],constraints:t.graph.constraints}},Y3=t=>{const e=ns(n=>{const r=ns(_d(fd))($h(t)(n.id)((()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})()));return()=>{const o=r();return E(n.id,v(eo)(0)(o))}})(Kh(t).nodes);return()=>{const n=e();return rs(n)}},Yh=t=>{const e=Y3(t);return()=>{const n=e(),r=ns(Yh)(Uh(t))();return v(D3)(n)(r)}},X3=t=>e=>n=>{const r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),n.segments);if(r.tag==="Nothing")return[];if(r.tag==="Just")return O3(e)([{x:r._1.head.start._1*t,y:r._1.head.start._2*t},...Y(o=>({x:o.end._1*t,y:o.end._2*t}))([r._1.head,...r._1.tail])]);g()},Z3=t=>e=>{const n=rs(Y(r=>E(r.id,r))(t.nodes));return{...e,nodes:Y(r=>{const o=li(r.id)(n);return o.tag==="Just"&&o._1.size._2===1?{...r,size:E(r.size._1,hi(r.size._2)(ot(G_(1)(Lr(Fn((()=>{if(r.label.tag==="Just")return r.label._1;if(r.label.tag==="Nothing")return r.id;g()})()).length+3|0,3))+(r.shape==="Cylinder"||r.shape==="Document"?1:0)|0)))}:r})(e.nodes)}},j3=t=>e=>n=>E(n.edge,X3(t)(e)(n)),tL=t=>e=>n=>r=>{const o=Y(q3(ot(4)*t)(e)(n))(r.nodes),i=rs(o),a=es(Y(j3(t)(Y(s=>s._2)(o)))(r.edges));return{nodes:i,edges:a,bounds:id(i)(a),chipExtras:O,edgeLabels:O}},eL=t=>e=>({...M3(es(Y(n=>E(n.id,E(n.from.node,n.to.node)))(e.edges)))(tL(8)(rs(Y(n=>E(n.id,(()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})()))(e.nodes)))(rs(Y(n=>E(n.id,n.shape))(e.nodes)))(t.stretchNodes?w3(Fh)(e).result:Ih(Fh)(e).result)),edgeLabels:es(ht(n=>n.label.tag==="Just"?w("Just",E(n.id,n.label._1)):y)(e.edges))}),nL=t=>v(e=>n=>{if(n.tag==="Structural")return e;if(n.tag==="DataFlow")return v(r=>o=>{if(o.kind.tag==="SendToken")return v(i=>a=>it(B)(a)()(i))(r)(o.kind._1.labels);if(o.kind.tag==="FillNodeWithoutTransition")return v(i=>a=>it(B)(a)()(i))(r)(o.kind._1.labels);g()})(e)(n._1.events);if(n.tag==="Hold"||n.tag==="EnterNode"||n.tag==="ExitNode"||n.tag==="StepScene")return e;g()})(O)(t.scenes),rL=t=>{const e=ns(n=>{const r=_d(fd)(n);return()=>{const o=r();return E(n,{labelW:o,charCount:Dn(lr(Xo(n))),lineCount:1})}})(It(xn.foldr,F3(St(It(xn.foldr,nL(t)))(qh))));return()=>{const n=e();return z3(n)}},Xh=t=>{const e=rL(t);return()=>{const n=e(),r=ns(Xh)(Uh(t))();return v(I3)(n)(r)}},oL=ot(4)*8,iL=t=>St(t.scenes)(e=>{if(e.tag==="Structural")return[];if(e.tag==="DataFlow")return e._1.events;if(e.tag==="Hold")return[];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];if(e.tag==="StepScene")return[];g()}),aL=t=>e=>n=>{const r=o=>{const i=ht(a=>{const s=Q3(a)(t);return s.tag==="Just"?w("Just",{w:s._1.labelW+28,h:ot(T3(1)(s._1.lineCount))*13.2+12}):y})(St(o)(qh));return i.length===0?y:w("Just",{w:v(eo)(0)(Y(a=>a.w)(i)),h:v(eo)(0)(Y(a=>a.h)(i))})};return v(o=>i=>{if(i.kind.tag==="SendToken"){const a=P_(i.kind._1.edge)(n.edges),s=r(i.kind._1.labels);if(s.tag==="Just"&&a.tag==="Just"){const u=s._1;return Ot(B)(Je)(i.kind._1.edge)(Y(c=>({x:c.x+14+u.w,y:c.y-6-8-u.h}))(a._1))(o)}return o}if(i.kind.tag==="FillNodeWithoutTransition"){const a=li(i.kind._1.node)(n.nodes),s=r(i.kind._1.labels);return s.tag==="Just"&&a.tag==="Just"?Ot(B)(Je)("__fill__:"+i.kind._1.node)((()=>{const u=a._1.y-s._1.h-14,c=a._1.x+a._1.w/2,_=c-s._1.w/2,f=c+s._1.w/2,l=a._1.y-14;return[{x:_,y:u},{x:f,y:u},{x:_,y:l},{x:f,y:l}]})())(o):o}g()})(O)(iL(e))},Zh=t=>e=>n=>{const r=Kh(n);return{layout:(()=>{const o=eL(n)(Z3(r)(k3(oL)(t)(L3(C3)(r))));return{...o,chipExtras:aL(e)(n)(o)}})(),interiors:(()=>{const o=Zh(t)(e),i=a=>{if(a.tag==="Leaf")return O;if(a.tag==="Node")return ee("Node",a._1,a._2,a._3,o(a._4),i(a._5),i(a._6));g()};return i(n.interiors)})()}},jh=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},A_=t=>e=>n=>{const r=t<.05?t:.05,o=(a,s)=>{if(s.tag==="Leaf")return a;if(s.tag==="Node")return o((()=>{const u=jh(s._3)(n),c=(()=>{if(u.tag==="Just")return u._1;if(u.tag==="Nothing")return{x:s._4.x,y:s._4.y,vx:0,vy:0};g()})(),_=c.vx+(180*(s._4.x-c.x)-22*c.vx)*r,f=c.vy+(180*(s._4.y-c.y)-22*c.vy)*r;return it(B)(s._3)({x:c.x+_*r,y:c.y+f*r,vx:_,vy:f})(o(a,s._5))})(),s._6);g()},i=o(O,e);return{springs:i,applied:(()=>{const a=(s,u)=>{if(u.tag==="Leaf")return s;if(u.tag==="Node")return a((()=>{const c=a(s,u._5),_=jh(u._3)(i);if(_.tag==="Just")return it(B)(u._3)({...u._4,x:_._1.x,y:_._1.y})(c);if(_.tag==="Nothing")return it(B)(u._3)(u._4)(c);g()})(),u._6);g()};return a(O,e)})()}},sL=t=>()=>t.clip("evenodd"),uL=t=>e=>()=>{t.filter=`blur(${e}px)`},cL=t=>e=>()=>{const n=e>0?t.canvas.width/e:1;t.setTransform(n,0,0,n,0,0)},gL=t=>e=>n=>r=>o=>()=>{const i=e>0?t.canvas.width/e:1;t.setTransform(i*n,0,0,i*n,i*r,i*o)},_L=t=>e=>()=>{const n=Math.max(8,Math.ceil(8/Math.max(e.tile,.001))),r=Math.max(2,Math.round(e.tile*n)),o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d");i.scale(n,n),i.fillStyle=e.bgCss,i.fillRect(0,0,e.tile,e.tile),i.fillStyle=e.dotCss,i.beginPath(),i.arc(e.tile/2,e.tile/2,e.dotR,0,2*Math.PI),i.fill();const a=t.createPattern(o,"repeat");a&&typeof a.setTransform=="function"&&a.setTransform(new DOMMatrix().translateSelf(e.ox,e.oy).scaleSelf(1/n,1/n)),t.save(),t.fillStyle=a,t.fillRect(e.vx,e.vy,e.vw,e.vh),t.restore()},B_=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},R_=t=>e=>n=>{const r=e.stroke;return()=>{const o=r.value,i=ff(t)(n);if(o!==n)return i(),e.stroke.value=n}},fL=t=>e=>n=>{const r=e.font;return()=>{const o=r.value,i=mf(t)(n);if(o!==n)return i(),e.font.value=n}},os=t=>e=>n=>{const r=e.fill;return()=>{const o=r.value,i=_f(t)(n);if(o!==n)return i(),e.fill.value=n}},Ru=t=>e=>{const n=e.length,r=i=>{if(i>=n)return()=>{};const a=i>=0&&i<e.length?e[i]:0;if(a===1){const s=lf(t)((()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})()),u=r(i+3|0);return()=>(s(),u())}if(a===2){const s=ba(t)((()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})()),u=r(i+3|0);return()=>(s(),u())}if(a===3){const s=La(t)({cpx:(()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})(),cpy:(()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=i+3|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=i+4|0;return c>=0&&c<e.length?e[c]:0})()}),u=r(i+5|0);return()=>(s(),u())}if(a===4){const s=Ay(t)({cp1x:(()=>{const c=i+1|0;return c>=0&&c<e.length?e[c]:0})(),cp1y:(()=>{const c=i+2|0;return c>=0&&c<e.length?e[c]:0})(),cp2x:(()=>{const c=i+3|0;return c>=0&&c<e.length?e[c]:0})(),cp2y:(()=>{const c=i+4|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=i+5|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=i+6|0;return c>=0&&c<e.length?e[c]:0})()}),u=r(i+7|0);return()=>(s(),u())}if(a===5){const s=hf(t),u=r(i+1|0);return()=>(s(),u())}return()=>{}},o=df(t);return()=>(o(),r(0)())},dL=t=>e=>n=>r=>o=>i=>{const a=B_(i)(B_(r/2)(o/2)),s=lf(t)(e+a)(n);return()=>(s(),ba(t)(e+r-a)(n)(),La(t)({cpx:e+r,cpy:n,x:e+r,y:n+a})(),ba(t)(e+r)(n+o-a)(),La(t)({cpx:e+r,cpy:n+o,x:e+r-a,y:n+o})(),ba(t)(e+a)(n+o)(),La(t)({cpx:e,cpy:n+o,x:e,y:n+o-a})(),ba(t)(e)(n+a)(),La(t)({cpx:e,cpy:n,x:e+a,y:n})(),hf(t)())},lL=()=>({font:{value:""},fill:{value:""},stroke:{value:""}}),tp=t=>e=>{const n=Sy(t)({x:0,y:0,width:e.width,height:e.height});return()=>{n();const r=lL();return{ctx:t,surface:e,styleCache:r,maskDepth:{value:0},groupAlpha:{value:1},alphaSaves:{value:[]}}}},hL={map:t=>e=>n=>{const r=e(n);return()=>{const o=r();return t(o)}}},pL=t=>ue(t.weight)+" "+bn(t.size)+"px "+t.family,Ir=t=>{const e=bn(ot(t.a)/255);return t.a>=255?"rgb("+ue(t.r)+","+ue(t.g)+","+ue(t.b)+")":"rgba("+ue(t.r)+","+ue(t.g)+","+ue(t.b)+","+e+")"},mL=t=>e=>n=>r=>{const o=sr(t);return()=>(o(),cL(t)(e.width)(),os(t)(n)(Ir(r))(),Ly(t)({x:0,y:0,width:e.width,height:e.height})(),ur(t)(),n.font.value="",n.fill.value="",n.stroke.value="")},yL=t=>e=>n=>{const r=e.font;return()=>(r.value="",e.fill.value="",e.stroke.value="",_L(t)({vx:n.viewport.vx,vy:n.viewport.vy,vw:n.viewport.vw,vh:n.viewport.vh,bgCss:Ir(n.bgColor),dotCss:Ir(n.dotColor),tile:n.tile,dotR:n.dotRadius,ox:n.origin.x,oy:n.origin.y})())},xL=t=>e=>n=>r=>{const o=os(t)(e)(Ir(r));return()=>(o(),Ru(t)(n)(),Oc(t)())},JL=t=>e=>n=>r=>o=>{const i=os(t)(e)(Ir(r));return()=>(i(),R_(t)(e)(Ir(o.color))(),Ls(t)(o.width)(),Zc(t)((()=>{if(o.lineJoin==="RoundJoin")return Vc;if(o.lineJoin==="BevelJoin")return qc;if(o.lineJoin==="MiterJoin")return Uc;g()})())(),jc(t)((()=>{if(o.lineCap==="ButtCap")return Xc;if(o.lineCap==="RoundCap")return Kc;if(o.lineCap==="SquareCap")return Yc;g()})())(),Ru(t)(n)(),Oc(t)(),Mc(t)())},wL=t=>e=>n=>r=>o=>i=>{const a=df(t);return()=>{if(a(),dL(t)(n.x)(n.y)(n.w)(n.h)(r)(),o.tag==="Just"?(os(t)(e)(Ir(o._1.color))(),Oc(t)()):o.tag==="Nothing"||g(),i.tag==="Just")return R_(t)(e)(Ir(i._1.color))(),Ls(t)(i._1.width)(),Zc(t)((()=>{if(i._1.lineJoin==="RoundJoin")return Vc;if(i._1.lineJoin==="BevelJoin")return qc;if(i._1.lineJoin==="MiterJoin")return Uc;g()})())(),jc(t)((()=>{if(i._1.lineCap==="ButtCap")return Xc;if(i._1.lineCap==="RoundCap")return Kc;if(i._1.lineCap==="SquareCap")return Yc;g()})())(),Mc(t)();i.tag!=="Nothing"&&g()}},TL=t=>e=>n=>r=>{const o=R_(t)(e)(Ir(r.color));return()=>(o(),Ls(t)(r.width)(),Zc(t)((()=>{if(r.lineJoin==="RoundJoin")return Vc;if(r.lineJoin==="BevelJoin")return qc;if(r.lineJoin==="MiterJoin")return Uc;g()})())(),jc(t)((()=>{if(r.lineCap==="ButtCap")return Xc;if(r.lineCap==="RoundCap")return Kc;if(r.lineCap==="SquareCap")return Yc;g()})())(),Ru(t)(n)(),Mc(t)())},ep=t=>e=>n=>{const r=os(t)(e)(Ir(n.color));return()=>(r(),fL(t)(e)(pL(n.font))(),Hy(t)((()=>{if(n.align==="AlignLeft")return zy;if(n.align==="AlignCenter")return Qy;if(n.align==="AlignRight")return Iy;g()})())(),Wy(t)((()=>{if(n.baseline==="BaselineTop")return By;if(n.baseline==="BaselineMiddle")return Ry;if(n.baseline==="BaselineAlphabetic")return Dy;if(n.baseline==="BaselineBottom")return Fy;g()})())(),yf(t)(n.content)(n.x)(n.y)())},np={apply:t=>e=>n=>{const r=t(n),o=e(n);return()=>{const i=r(),a=o();return i(a)}},Functor0:()=>hL},NL={bind:t=>e=>n=>{const r=t(n);return()=>{const o=r();return e(o)(n)()}},Apply0:()=>np},vL=t=>e=>n=>{const r=B_(e.width/n.vw)(e.height/n.vh);return gL(t)(e.width)(r)((e.width-n.vw*r)/2-n.vx*r)((e.height-n.vh*r)/2-n.vy*r)},bL={pure:t=>e=>()=>t,Apply0:()=>np},rp={Applicative0:()=>bL,Bind1:()=>NL},D_={fillPath:t=>e=>n=>{const r=xL(n.ctx)(n.styleCache)(t)(e.color),o=n.maskDepth;return()=>{if(o.value===0)return r()}},strokePath:t=>e=>n=>{const r=TL(n.ctx)(n.styleCache)(t)(e),o=n.maskDepth;return()=>{if(o.value===0)return r()}},fillStrokePath:t=>e=>n=>r=>{const o=JL(r.ctx)(r.styleCache)(t)(e.color)(n),i=r.maskDepth;return()=>{if(i.value===0)return o()}},drawRoundedRect:t=>e=>n=>r=>o=>{const i=wL(o.ctx)(o.styleCache)(t)(e)(n)(r),a=o.maskDepth;return()=>{if(a.value===0)return i()}},drawText:t=>e=>{const n=ep(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},drawTextAffine:t=>e=>n=>{const r=sr(n.ctx),o=n.maskDepth;return()=>{if(o.value===0)return r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",Ey(n.ctx)(t)(),ep(n.ctx)(n.styleCache)(e)(),ur(n.ctx)(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value=""}},pushTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",pf(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ca(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popTransform:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBakedTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",pf(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ca(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popBakedTransform:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushClip:t=>e=>n=>{const r=sr(n.ctx),o=n.maskDepth;return()=>{if(o.value===0){if(r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",Ru(n.ctx)(t)(),e==="NonZero")return Cy(n.ctx)();if(e==="EvenOdd")return sL(n.ctx)();g()}}},popClip:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBlend:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){if(n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",t==="Normal")return Jf(e.ctx)(My)();if(t==="Difference")return Jf(e.ctx)(Oy)();g()}}},popBlend:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushAlpha:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="";const o=e.groupAlpha.value,i=e.alphaSaves.value;e.alphaSaves.value=[...i,o];const a=o*t;return e.groupAlpha.value=a,by(e.ctx)(a)()}}},popAlpha:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0){e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value="";const r=t.alphaSaves.value,o=Sr(r);if(o.tag==="Just")return t.alphaSaves.value=o._1.init,t.groupAlpha.value=o._1.last;if(o.tag==="Nothing")return t.groupAlpha.value=1;g()}}},pushBlur:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="";const o=uL(e.ctx)(t);if(t>=.01)return o()}}},popBlur:t=>{const e=ur(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushLayer:t=>e=>{if(t==="LayerNodeMask"){const n=e.maskDepth;return()=>{const r=n.value;n.value=r+1|0}}return()=>{}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;if(n>0)return t.maskDepth.value=r}},setViewport:t=>e=>{const n=vL(e.ctx)(e.surface)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},clearBackground:t=>e=>{const n=mL(e.ctx)(e.surface)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},backgroundDots:t=>e=>{const n=yL(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},measureText:t=>e=>n=>{const r=Cg(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Lg(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>Ag,Monad0:()=>rp},CL=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},is=t=>e=>n=>{const r=CL(.05)(1-t-e);return n<t?0:n>1-e?1:(n-t)/r},F_=t=>{const e=at.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=at.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},LL=t=>{if(t.tag==="Retracted")return{lo:0,hi:0};if(t.tag==="Extended")return{lo:0,hi:1};if(t.tag==="Extending"){if(t._1==="ExtendFromSource")return{lo:0,hi:F_(t._2)};if(t._1==="ExtendFromTarget")return{lo:1-t._2,hi:1};g()}if(t.tag==="Retracting"){if(t._1==="FromSource")return{lo:t._2,hi:1};if(t._1==="FromTarget")return{lo:0,hi:1-t._2};if(t._1==="FromBoth")return{lo:t._2/2,hi:1-t._2/2}}g()},pi=t=>{if(t.tag==="Hidden")return{alpha:0,scale:1};if(t.tag==="Visible")return{alpha:1,scale:1};if(t.tag==="PloppingIn")return{alpha:t._1>0?1:0,scale:qo(8)(.6)(F_(t._1))};if(t.tag==="PloppingOut")return{alpha:t._1<1?1:0,scale:qo(8)(.6)(F_(1-t._1))};g()};function kL(t,e){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function SL(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r++){const o=t[r],i=t[(r+1)%e];n[r]={a:o,b:i,len:kL(o,i)}}return n}function EL(t,e,n){let r=0;for(let o=0;o<t.length;o++){const i=t[o],a=r,s=a+i.len;if(n<=s){const u=i.len>1e-6?(n-a)/i.len:0;return{x:i.a.x+(i.b.x-i.a.x)*u,y:i.a.y+(i.b.y-i.a.y)*u}}r=s}return e.length>0?e[e.length-1]:{x:0,y:0}}function op(t,e){if(e.length===0)return[];const n=SL(e);let r=0;for(let i=0;i<n.length;i++)r+=n[i].len;const o=new Array(t);for(let i=0;i<t;i++)o[i]=EL(n,e,i*r/t);return o}function PL(t,e){const n=e.length;if(n===0)return e;const r=(t%n+n)%n|0,o=new Array(n);for(let i=0;i<n;i++)o[i]=e[(i+r)%n];return o}function GL(t,e){const n=e.length;if(n===0)return e;let r=0,o=1/0;for(let i=0;i<n;i++){let a=0;for(let s=0;s<n;s++){const u=t[s]||{x:0,y:0},c=e[(s+i)%n]||{x:0,y:0},_=u.x-c.x,f=u.y-c.y;a+=_*_+f*f}a<o&&(o=a,r=i)}return PL(r,e)}const ip=t=>e=>n=>{const r=op(t,e),o=op(t,n),i=GL(r,o);return{from:r,to:i}};function ap(t){const e=t.length;if(e===0)return{x:0,y:0};let n=0,r=0;for(let o=0;o<e;o++)n+=t[o].x,r+=t[o].y;return{x:n/e,y:r/e}}function AL(t,e){const n=e.x-t.x,r=e.y-t.y,o=Math.sqrt(n*n+r*r);return o<=1e-4?{x:1,y:0}:{x:n/o,y:r/o}}function BL(t,e){const n=e.length;if(n===0)return e;const r=new Array(n);for(let o=0;o<n;o++){const i=e[((o-1)%n+n)%n],a=e[((o+1)%n+n)%n],s=e[o];r[o]={x:s.x+((i.x+a.x)/2-s.x)*t,y:s.y+((i.y+a.y)/2-s.y)*t}}return r}function RL(t){return t<0?0:t>1?1:t}const sp=t=>e=>n=>r=>{const o=e.length;if(o===0)return[];const i=ap(e),a=ap(n),s=AL(i,a),u=new Array(o);let c=1/0,_=-1/0;for(let d=0;d<o;d++){const h=e[d],m=(h.x-i.x)*s.x+(h.y-i.y)*s.y;u[d]=m,m<c&&(c=m),m>_&&(_=m)}const f=_-c;let l=new Array(o);for(let d=0;d<o;d++){const h=e[d],m=n[d];if(m===void 0){l[d]=h;continue}const p=f<=1e-4?0:r.maxDelay*(1-(u[d]-c)/f),x=Math.max(1e-4,1-p),J=RL((t-p)/x),T=J*J*(3-2*J);l[d]={x:h.x+(m.x-h.x)*T,y:h.y+(m.y-h.y)*T}}for(let d=0;d<r.smoothPasses;d++)l=BL(.5,l);return l},up=(t,e)=>({tag:t,_1:e}),cp=(t,e)=>({tag:t,_1:e}),pe=(t,e,n)=>({tag:t,_1:e,_2:n}),gp=t=>t,Du=(t,e)=>({tag:t,_1:e}),Fu=(t,e)=>({tag:t,_1:e}),zu=t=>t,mi=t=>({tag:"FloorOverlay",_1:t}),Re=(t,e,n)=>({tag:t,_1:e,_2:n}),vo=(t,e)=>({tag:t,_1:e}),la=(t,e)=>({tag:t,_1:e}),_p=(t,e)=>({tag:t,_1:e}),fp=t=>t,dp=(t,e)=>({tag:t,_1:e}),yi=(t,e,n)=>({tag:t,_1:e,_2:n}),lp=t=>t,DL=t=>t,xi=lp("NormalTransform"),FL=lp("BakedTransform"),hp=fp("TokenOutside"),pp=fp("TokenInside"),mp=la("PlainText"),zL=vo("Watermark"),IL=zu("NodeShadow"),QL=zu("NodeDoorwayFrame"),yp=zu("NodeBody"),ML=zu("NodeInversion"),z_=gp("LabelsShown"),Iu=gp("LabelsHidden"),mr={map:t=>e=>{if(e.tag==="BeginFrame")return Re("BeginFrame",e._1,t(e._2));if(e.tag==="EndFrame")return Re("EndFrame",t(e._1));if(e.tag==="BeginGroup")return Re("BeginGroup",e._1,t(e._2));if(e.tag==="EndGroup")return Re("EndGroup",e._1,t(e._2));if(e.tag==="Background")return Re("Background",e._1,t(e._2));if(e.tag==="Overlay")return Re("Overlay",e._1,t(e._2));if(e.tag==="Node")return Re("Node",e._1,t(e._2));if(e.tag==="Edge")return Re("Edge",e._1,t(e._2));if(e.tag==="Text")return Re("Text",e._1,t(e._2));if(e.tag==="Token")return Re("Token",e._1,t(e._2));if(e.tag==="AskInsideTokenStyle")return Re("AskInsideTokenStyle",e._1,n=>t(e._2(n)));g()}},xp=t=>e=>Zo(t)(e),OL=t=>{const e=t.Bind1().Apply0().Functor0(),n=HJ(t);return r=>o=>n(OJ()()()({scene:i=>{if(i.tag==="BeginFrame"){const a=i._2;return e.map(s=>a)(r.beginFrame(i._1))}if(i.tag==="EndFrame"){const a=i._1;return e.map(s=>a)(r.endFrame)}if(i.tag==="BeginGroup"){const a=i._2;return e.map(s=>a)(r.beginGroup(i._1))}if(i.tag==="EndGroup"){const a=i._2;return e.map(s=>a)(r.endGroup(i._1))}if(i.tag==="Background"){const a=i._2;return e.map(s=>a)(r.background(i._1))}if(i.tag==="Overlay"){const a=i._2;return e.map(s=>a)(r.overlay(i._1))}if(i.tag==="Node"){const a=i._2;return e.map(s=>a)(r.node(i._1))}if(i.tag==="Edge"){const a=i._2;return e.map(s=>a)(r.edge(i._1))}if(i.tag==="Text"){const a=i._2;return e.map(s=>a)(r.text(i._1))}if(i.tag==="Token"){const a=i._2;return e.map(s=>a)(r.token(i._1))}if(i.tag==="AskInsideTokenStyle")return e.map(i._2)(r.insideTokenStyle(i._1));g()},metrics:i=>{if(i.tag==="MeasureText")return e.map(i._3)(r.measureText(i._1)(i._2));if(i.tag==="MeasureInk")return e.map(i._3)(r.measureInk(i._1)(i._2));g()}}))(o)},WL=t=>j(st("Bind",{type:"scene",value:Re("AskInsideTokenStyle",t,DL),map:mr.map},e=>j(st("Return",e),ct)),ct),Jp=t=>j(st("Bind",{type:"scene",value:Re("Background",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),wp=t=>j(st("Bind",{type:"scene",value:Re("Edge",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),Qu=t=>j(st("Bind",{type:"scene",value:Re("Node",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),Ji=t=>j(st("Bind",{type:"scene",value:Re("Overlay",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),wi=t=>j(st("Bind",{type:"scene",value:Re("Text",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),Tp=t=>j(st("Bind",{type:"scene",value:Re("Token",t,void 0),map:mr.map},e=>j(st("Return",e),ct)),ct),HL=t=>e=>j(st("Bind",{type:"scene",value:Re("BeginFrame",t,void 0),map:mr.map},n=>j(st("Return",n),ct)),rt("CatCons",()=>j(e._1,(()=>{if(e._2.tag==="CatNil")return rt("CatCons",()=>j(st("Bind",{type:"scene",value:Re("EndFrame",void 0),map:mr.map},n=>j(st("Return",n),ct)),ct),nt(z,z));if(e._2.tag==="CatCons")return rt("CatCons",e._2._1,nt(e._2._2._1,Jt("Cons",rt("CatCons",()=>j(st("Bind",{type:"scene",value:Re("EndFrame",void 0),map:mr.map},n=>j(st("Return",n),ct)),ct),nt(z,z)),e._2._2._2)));g()})()),nt(z,z))),Se=t=>e=>j(st("Bind",{type:"scene",value:Re("BeginGroup",t,void 0),map:mr.map},n=>j(st("Return",n),ct)),rt("CatCons",()=>{const n=()=>j(st("Bind",{type:"scene",value:Re("EndGroup",t,void 0),map:mr.map},r=>j(st("Return",r),ct)),ct);return j(e._1,(()=>{if(e._2.tag==="CatNil")return rt("CatCons",n,nt(z,z));if(e._2.tag==="CatCons")return rt("CatCons",e._2._1,nt(e._2._2._1,Jt("Cons",rt("CatCons",n,nt(z,z)),e._2._2._2)));g()})())},nt(z,z))),bo=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},I_=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},$L=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},qL=t=>e=>{const n=bo(0)(t.y+4-e.y)+bo(0)(e.y+e.h-(t.y+t.h-4)),r=bo(0)(t.x+4-e.x)+bo(0)(e.x+e.w-(t.x+t.w-4));return r*e.h+n*e.w+r*n},VL=t=>e=>{const n=t.y+t.h-6,r=t.y+6,o=t.x+14,i=t.x+t.w-14,a=v(bo)(0)(Y(s=>o-10<s.x+s.w+12&&i+10>s.x-12&&r-10<s.y+s.h+12&&n+10>s.y-12?I_((s.x+s.w+12-(o-10))/.7071067811865476)((n+10-(s.y-12))/.7071067811865476):0)(e));return{...t,x:t.x+a*.7071067811865476,y:t.y-a*.7071067811865476}},UL=t=>e=>{const n=I_(t.x+t.w)(e.x+e.w)-bo(t.x)(e.x),r=I_(t.y+t.h)(e.y+e.h)-bo(t.y)(e.y);return t.x<e.x+e.w&&t.x+t.w>e.x&&t.y<e.y+e.h&&t.y+t.h>e.y?n*r:0},Np=t=>e=>n=>r=>{const o=t+4,i=bo(0)(e-8),a=o+i-n;return n<=i?$L(o)(a)(r):t+(e-n)/2},Q_=t=>e=>({...e,x:Np(t.x)(t.w)(e.w)(e.x),y:Np(t.y)(t.h)(e.h)(e.y)}),KL=t=>{const e=2*t.token.x-t.rect.x-t.rect.w,n=t.token.y-t.rect.h/2,r=t.token.x-t.rect.w/2,o=2*t.token.y-t.rect.y-t.rect.h;return[{...t.rect,x:t.rect.x,y:t.rect.y},{...t.rect,x:e,y:t.rect.y},{...t.rect,x:t.rect.x,y:o},{...t.rect,x:e,y:o},{...t.rect,x:t.rect.x,y:n},{...t.rect,x:e,y:n},{...t.rect,x:r,y:t.rect.y},{...t.rect,x:r,y:o}]},YL=t=>e=>n=>r=>o=>{const i=o.y+o.h/2-n.token.y,a=o.y-r.y;return(()=>{const s=o.x+o.w/2-n.token.x,u=o.x-r.x;return 1e6*qL(t)(o)+1e4*v(c=>_=>c+UL(o)(_))(0)(e)+.05*(u*u+a*a)+.01*(s*s+i*i)})()+(o.y>n.token.y?100:0)},XL=t=>e=>n=>r=>{const o=a=>{const s=Q_(t)(a);return{rect:s,score:YL(t)(e)(n)(r)(s)}},i=Ft(a=>y,a=>s=>w("Just",{head:a,tail:s}),[r,n.rect,...KL(n)]);if(i.tag==="Nothing")return Q_(t)(r);if(i.tag==="Just")return v(a=>s=>{const u=o(s);return u.score<a.score?u:a})(o(i._1.head))(i._1.tail).rect;g()},ZL=t=>e=>n=>v(r=>o=>{const i=VL(o.rect)(r.obstacles),a=i.x>=t.x+4&&i.y>=t.y+4&&i.x+i.w<=t.x+t.w-4&&i.y+i.h<=t.y+t.h-4?i:XL(t)(r.obstacles)(o)(i);return{acc:it(B)(o.id)(a)(r.acc),obstacles:Et(r.obstacles)(a)}})({acc:O,obstacles:e})(n).acc,M_=t=>t,no=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ti=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},jL=Di(Ec)(Qt),tk=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ek=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},vp=M_("SegMove"),nk=M_("SegLine"),rk=M_("SegQuad"),bp={offset:.4,passes:1,rMax:1.5},Cp=t=>he(ar(t.x*7919+t.y*3001+t.w*113+t.h*17+1))*-1640531535|0,Mu=t=>e=>n=>()=>{t.push(3),t.push(e.x),t.push(e.y),t.push(n.x),t.push(n.y)},Ou=t=>e=>()=>{t.push(1),t.push(e.x),t.push(e.y)},ro=t=>e=>()=>{t.push(2),t.push(e.x),t.push(e.y)},as=(()=>{const t=v(e=>n=>((e*31|0)+he(ar(n.x*100))|0)+he(ar(n.y*100))|0)(1);return e=>t(e)*-1640531535|0})(),ok=t=>{const e=[];let n=0,r={x:0,y:0};for(;n<t.length;){const o=n,i=r,a=o>=0&&o<t.length?w("Just",t[o]):y;if(a.tag==="Nothing"){n=t.length;continue}if(a.tag==="Just"){if(a._1===1){const s={x:(()=>{const u=o+1|0;return u>=0&&u<t.length?t[u]:0})(),y:(()=>{const u=o+2|0;return u>=0&&u<t.length?t[u]:0})()};e.push({kind:vp,m:i,c:i,p:s,len:0}),r=s,n=o+3|0;continue}if(a._1===2){const s={x:(()=>{const _=o+1|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+2|0;return _>=0&&_<t.length?t[_]:0})()},u=s.x-i.x,c=s.y-i.y;e.push({kind:nk,m:i,c:i,p:s,len:qe(u*u+c*c)}),r=s,n=o+3|0;continue}if(a._1===3){const s={x:(()=>{const _=o+3|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+4|0;return _>=0&&_<t.length?t[_]:0})()},u=s.x-i.x,c=s.y-i.y;e.push({kind:rk,m:i,c:{x:(()=>{const _=o+1|0;return _>=0&&_<t.length?t[_]:0})(),y:(()=>{const _=o+2|0;return _>=0&&_<t.length?t[_]:0})()},p:s,len:qe(u*u+c*c)*1.05}),r=s,n=o+5|0;continue}if(a._1===5){e.push({kind:vp,m:i,c:i,p:i,len:0}),n=o+1|0;continue}n=t.length;continue}g()}return e},ik=t=>e=>{const n=e.length-1|0,r=n<1?[]:Bt(0,n,e),o=(()=>{const a=r.length-1|0;return a>=0&&a<r.length?w("Just",r[a]):y})(),i=e.length-1|0;if(i>=0&&i<e.length&&o.tag==="Just"){const a=e[i].y-o._1.y,s=e[i].x-o._1.x,u=qe(s*s+a*a);return u<=1e-4?e:Et((()=>{const c=e.length-1|0;return c<1?[]:Bt(0,c,e)})())({x:e[i].x+s/u*t,y:e[i].y+a/u*t})}return e},ak=t=>e=>n=>re(v(r=>o=>{const i=Ge(0)(t)(r.prng),a=Ge(0)(6.283185307179586)(i.prng);return{prng:a.prng,out:[{x:o.x+i.value*yn(a.value),y:o.y+i.value*tn(a.value)},...r.out]}})({prng:e,out:[]})(n).out),sk=t=>e=>n=>{if(e.kind==="SegMove")return Ou(t)(e.p);if(e.kind==="SegLine")return ro(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});if(e.kind==="SegQuad")return ro(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});g()},uk=t=>e=>{if(e.kind==="SegMove")return Ou(t)(e.p);if(e.kind==="SegLine")return ro(t)(e.p);if(e.kind==="SegQuad")return Mu(t)(e.c)(e.p);g()},Lp=t=>e=>{const n=ok(e),r=v(s=>u=>s+u.len)(0)(n)*no(0)(Ti(1)(t)),o=[];let i=0,a=0;for(;a<n.length;){const s=a,u=i;if(s>=0&&s<n.length){if(u+n[s].len<=r){const c=n[s];uk(o)(c)(),i=u+c.len,a=s+1|0;continue}if(u>=r){a=n.length;continue}sk(o)(n[s])((r-u)/no(n[s].len)(1e-4))()}a=n.length}return o},kp={offset:1.5,passes:2,rMax:14,overshoot:2.5},Sp=t=>e=>n=>r=>{const o=r.y-n.y,i=n.y-e.y,a=r.x-n.x,s=qe(a*a+o*o),u=n.x-e.x,c=qe(u*u+i*i),_=Ti(t.rMax*(ay(c>0&&s>0?no(-1)(Ti(1)((u*a+i*o)/(c*s))):1)/3.141592653589793))(.4*Ti(c)(s));return{inP:c>0?{x:n.x-u/c*_,y:n.y-i/c*_}:n,curr:n,outP:s>0?{x:n.x+a/s*_,y:n.y+o/s*_}:n}},Ep=t=>e=>{const n=e.length,r=[],o=0<e.length?w("Just",e[0]):y;if(o.tag==="Just"?Ou(r)(o._1)():o.tag==="Nothing"||g(),n>=3){let a=1;for(;a<=(n-2|0);){const s=a,u=s+1|0;if(u>=0&&u<e.length){if(s>=0&&s<e.length){const c=s-1|0;if(c>=0&&c<e.length){const _=Sp(t)(e[c])(e[s])(e[u]);ro(r)(_.inP)(),Mu(r)(_.curr)(_.outP)()}}a=s+1|0;continue}a=s+1|0}}const i=e.length-1|0;return i>=0&&i<e.length&&n>=2&&ro(r)(e[i])(),r},ck=t=>e=>n=>r=>o=>{if(o.length<4)return Ep(t)(o);const i=0<o.length?w("Just",o[0]):y,a=(()=>{if(i.tag==="Nothing")return{x:0,y:0};if(i.tag==="Just")return i._1;g()})(),s=o.length-1|0,u=go(go(e)(s)+s|0)(s),c=d=>{const h=go(d+s|0)(s);return h>=0&&h<o.length?o[h]:a},_=Y(d=>Sp(t)(c((u+d|0)-1|0))(c(u+d|0))(c((u+d|0)+1|0)))(Ut(0,s-1|0)),f=[],l=0<_.length?w("Just",_[0]):y;if(l.tag==="Just")if(Ou(f)(l._1.outP)(),jL((()=>{const d=Ft(h=>y,h=>m=>w("Just",m),_);if(d.tag==="Nothing")return[];if(d.tag==="Just")return d._1;g()})())(d=>{const h=ro(f)(d.inP);return()=>(h(),Mu(f)(d.curr)(d.outP)())})(),n)ro(f)(l._1.inP)(),Mu(f)(l._1.curr)(l._1.outP)(),f.push(5);else{const d=_.length-1|0;d>=0&&d<_.length?ro(f)((()=>{const h=1-r;return{x:_[d].outP.x+(l._1.inP.x-_[d].outP.x)*h,y:_[d].outP.y+(l._1.inP.y-_[d].outP.y)*h}})())():ro(f)(l._1.inP)()}else l.tag==="Nothing"||g();return f},ha=t=>e=>n=>r=>{const o=tk(1)(r.length-1|0),i=Ge(0)(ot(o))(Pg("shape")(e)),a=ek(o-1|0)(he(ar(i.value))),s=i.prng;return Y(u=>{const c=Ge(0)(1)(Pg(ue(u))(s)),_=Ge(-.18)(.3)(c.prng),f=c.value<.7,l=Ge(.5)(.85)(_.prng),d=ak(t.offset)(l.prng)(r);return{path:n?ck(t)(a)(f)(_.value)(d):Ep(t)(d),alpha:l.value}})(Ut(0,t.passes-1|0))},gk=t=>e=>n=>ha(t)(e)(!0)([{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h},{x:n.x,y:n.y}]),_k=t=>e=>n=>{const r=no(0)(Ti(1)(n)),o=e.h/ot(4),i=no(6)(o*1.4);return ht(a=>a)(Y(a=>{if(r<no(0)(ot(a)/ot(4)-.05))return y;const s=Pg(ue(a))(t),u=no(0)(ot(a)/ot(4)-.05),c=go(a)(2)===0,_=c?e.x-2:e.x+e.w+2,f=c?e.x+e.w+2:e.x-2,l=e.y+(ot(a)+.5)*o;return w("Just",{path:Lp(no(0)(Ti(1)((r-u)/no(1e-4)(Ti(1)(ot(a+1|0)/ot(4)+.05)-u))))((()=>{const d={rMax:2,offset:.6,passes:1},h=re(v(p=>x=>{const J=Ge(-o*.08)(o*.08)(p.prng);return{prng:J.prng,out:[{x:_+(f-_)*(ot(x)/ot(4)),y:l+J.value},...p.out]}})({prng:s,out:[]})(Ut(0,4)).out),m=h.length<2?[]:ha(d)(s)(!1)(h);return 0<m.length?m[0].path:[]})()),width:i,alpha:1})})(Ut(0,3)))},O_=(t,e,n)=>({tag:t,_1:e,_2:n}),ss=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),Pp=t=>t,Wu=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ln=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),fk=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ni=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},me=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},dk=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},yr=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},vi=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Qr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},lk=Qt.foldMap(xy),Hu=ao.traverse(ho),pa=v(xr)(0),Gp=fe(B)(Qt),Ap=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},hk=nf(B),pk=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},W_=Pp("FullTokenGeometry"),mk=Pp("ConvexInsideGeometry"),bi=t=>{const e=t.Apply0();return n=>v(r=>o=>e.apply(e.Functor0().map(i=>O1)(r))(n(o)))(t.pure())},er=bi(ho),Bp=t=>e=>n=>r=>o=>i=>{const a={x:n.x+n.w/2,y:n.y+n.h/2},s={x:e.x+e.w/2,y:e.y+e.h/2},u=is(o)(i)(r),c=0<t.length?w("Just",t[0]):y,_=(()=>{if(c.tag==="Just")return c._1;if(c.tag==="Nothing")return s;g()})(),f=t.length-1|0,l=f>=0&&f<t.length?w("Just",t[f]):y,d=(()=>{if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return a;g()})(),h=_.x-s.x,m=2*(()=>{const C=_.y-s.y;return(h<0?-h:h)+(C<0?-C:C)})(),p=d.x-a.x,x=2*(()=>{const C=d.y-a.y;return(p<0?-p:p)+(C<0?-C:C)})(),J=m+Ba(t)+x,T=J<=1e-4?1:1-x/J,N=J<=1e-4?0:m/J,k=T-N;return{progress:u,morphOutEnd:N,morphInStart:T,outT:(()=>{if(N<=1e-4)return 1;const C=u/N,P=C<0?0:C>1?1:C;return P*P*(3-2*P)})(),inT:(()=>{if(T>=1)return 0;const C=(u-T)/(1-T),P=C<0?0:C>1?1:C;return P*P*(3-2*P)})(),pathStart:_,pathEnd:d,travelPt:(()=>{const C=Yo(t)(Wu(0)(1)(k<=1e-4?0:(u-N)/k));if(C.tag==="Just")return C._1;if(C.tag==="Nothing")return _;g()})()}},Rp=t=>e=>n=>r=>o=>i=>{const a=Bp(t)(e)(n)(r)(o)(i),s=ip(128)(ni(4)(e))(Id(a.pathStart)(6)),u=ip(128)(Id(a.pathEnd)(6))(ni(4)(n)),c={maxDelay:.4,smoothPasses:2};return a.progress<a.morphOutEnd?yi("PolyShape",sp(a.outT)(s.from)(s.to)(c)):a.progress>=a.morphInStart?yi("PolyShape",sp(a.inT)(u.from)(u.to)(c)):yi("CircleShape",a.travelPt,6)},H_=t=>e=>n=>r=>o=>i=>{const a=Rp(t)(e)(n)(r)(o)(i);if(a.tag==="PolyShape")return Dg(a._1);if(a.tag==="CircleShape")return a._1;g()},yk=t=>{const e=n=>{const r=te(o=>n.x>=o._2.x-1&&n.x<=o._2.x+o._2.w+1&&n.y>=o._2.y-1&&n.y<=o._2.y+o._2.h+1)(ln(t.nodes));return r.tag==="Just"?w("Just",r._1._2):y};return n=>{const r=(()=>{if(0<n.length){const i=e(n[0]);if(i.tag==="Just")return re(Md(ni(7)(i._1))(re(n)))}return n})(),o=r.length-1|0;if(o>=0&&o<r.length){const i=e(r[o]);if(i.tag==="Just")return Md(ni(7)(i._1))(r)}return r}},$_=t=>({nodes:t.nodes,edges:(()=>{const e=yk(t),n=r=>{if(r.tag==="Leaf")return O;if(r.tag==="Node")return ee("Node",r._1,r._2,r._3,e(r._4),n(r._5),n(r._6));g()};return n(t.edges)})()}),xk=t=>e=>{const n=((t.bg.r+t.bg.g|0)+t.bg.b|0)<384,r=n?90:104,o=n?165:122,i=a=>fk(255)(Ni(0)(he(Un(o+r*tn(e+a)))));return{r:i(0),g:i(-2.0943951023931953),b:i(-4.1887902047863905),a:255}},Dp=t=>e=>{if(t<=0)return[];const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return _n(n._1.head.text).length<=t?[n._1.head,...Dp(t-_n(n._1.head.text).length|0)(n._1.tail)]:[{...n._1.head,text:Ve(t)(n._1.head.text)}];g()},q_=(()=>{const t={r:24,g:24,b:27,a:255},e={r:244,g:244,b:245,a:255},n={r:248,g:249,b:246,a:255},r={r:26,g:26,b:26,a:255},o={r:28,g:101,b:192,a:255},i={r:247,g:248,b:250,a:255},a={r:42,g:48,b:60,a:255},s={r:120,g:130,b:146,a:255};return u=>{if(u==="Light")return{bg:{r:255,g:255,b:255,a:255},bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:211,b:209,a:255},shadowFill:{r:255,g:255,b:255,a:255},shadowDot:{r:26,g:26,b:26,a:255},chip:{r:255,g:235,b:130,a:255},chipShadow:{r:214,g:211,b:209,a:255},chipText:Yr,nodeFill:we,nodeStroke:Yr,text:Yr,edge:Yr,arrowFill:Yr,tokenOutsideFill:Yr,tokenOutsideStroke:we,tokenInside:we,tokenInsideStroke:we,tokenInsideBlend:Xs,tokenInsideAlpha:1,chipPillFill:Yr,chipPillText:we,chipHairline:{r:26,g:26,b:26,a:90},trailDot:Yr,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Dark")return{bg:t,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:63,g:63,b:70,a:255},shadowFill:t,shadowDot:e,chip:{r:234,g:179,b:8,a:255},chipShadow:{r:0,g:0,b:0,a:120},chipText:t,nodeFill:Yr,nodeStroke:e,text:e,edge:e,arrowFill:e,tokenOutsideFill:we,tokenOutsideStroke:we,tokenInside:we,tokenInsideStroke:we,tokenInsideBlend:Xs,tokenInsideAlpha:1,chipPillFill:e,chipPillText:t,chipHairline:{r:244,g:244,b:245,a:120},trailDot:e,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Blueprint")return{bg:o,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:90,g:160,b:230,a:255},shadowFill:o,shadowDot:we,chip:we,chipShadow:{r:0,g:0,b:0,a:120},chipText:o,nodeFill:o,nodeStroke:we,text:we,edge:we,arrowFill:we,tokenOutsideFill:we,tokenOutsideStroke:we,tokenInside:we,tokenInsideStroke:we,tokenInsideBlend:Td,tokenInsideAlpha:.35,chipPillFill:we,chipPillText:o,chipHairline:{r:255,g:255,b:255,a:120},trailDot:we,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Whiteboard")return{bg:n,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:0,g:0,b:0,a:0},shadowFill:n,shadowDot:r,chip:{r:217,g:74,b:56,a:255},chipShadow:{r:26,g:26,b:26,a:60},chipText:n,nodeFill:n,nodeStroke:r,text:r,edge:r,arrowFill:r,tokenOutsideFill:r,tokenOutsideStroke:n,tokenInside:n,tokenInsideStroke:n,tokenInsideBlend:Td,tokenInsideAlpha:1,chipPillFill:r,chipPillText:n,chipHairline:{r:26,g:26,b:26,a:90},trailDot:r,wobble:!0,fontFamily:"Supermarker, Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(u==="Isometric")return{bg:i,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:218,b:224,a:255},shadowFill:i,shadowDot:a,chip:{r:255,g:235,b:130,a:255},chipShadow:{r:100,g:110,b:125,a:90},chipText:a,nodeFill:{r:236,g:239,b:244,a:255},nodeStroke:a,text:a,edge:s,arrowFill:s,tokenOutsideFill:a,tokenOutsideStroke:we,tokenInside:we,tokenInsideStroke:we,tokenInsideBlend:Xs,tokenInsideAlpha:1,chipPillFill:a,chipPillText:we,chipHairline:{r:60,g:66,b:78,a:90},trailDot:a,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};g()}})(),V_=t=>e=>St(ln(t))(n=>{const r=me(n._1)(e.nodes);return r.tag==="Just"&&pi(r._1).alpha>0?yo(n._2):[]}),Jk=t=>e=>n=>[1,t.vx,t.vy,2,t.vx+t.vw,t.vy,2,t.vx+t.vw,t.vy+t.vh,2,t.vx,t.vy+t.vh,5,...V_(e)(n)],wk=t=>e=>n=>{const r=(o,i)=>he(Un(ot(o)+(ot(i)-ot(o))*n));return{r:r(t.r,e.r),g:r(t.g,e.g),b:r(t.b,e.b),a:r(t.a,e.a)}},Tk=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=ao.traverse(r);return i=>a=>{const s=Bn(a),u=.32*i.size;return o(c=>n.bind(c===0?r.pure(0):t.measureText(i)(Ve(c)(a)))(_=>n.bind(t.measureText(i)(Ve(c+1|0)(a)))(f=>n.bind(t.measureInk(i)(c>=0&&c<s.length?Rn(s[c]):" "))(l=>r.pure({x:_,w:f-_,up:l.ascent-u,down:l.descent+u})))))(Ut(0,s.length-1|0))}},Fp=t=>[...yo({...t,x:t.x-1.25,y:t.y-1.25,w:t.w+2.5,h:t.h+2.5}),...yo({...t,y:t.y-5})],Nk=t=>e=>{const n=o=>(o.x-e.x)*(o.x-e.x)+(o.y-e.y)*(o.y-e.y),r=v(o=>i=>n(i)<n(o)?i:o)({x:t.x,y:t.y})([{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x,y:t.y+t.h},{x:t.x+t.w,y:t.y+t.h}]);return Y(o=>{const i=ot(o)/5;return{x:r.x+(e.x-r.x)*i,y:r.y+(e.y-r.y)*i}})([1,2,3,4])},us=t=>e=>n=>{const r=dk(ue(e)+":"+ue(n))(t);if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()},vk=t=>e=>{const n=e.length;return v(r=>o=>v(i=>a=>it(B)(ue(o)+":"+ue(a))(a>=0&&a<e.length&&o>=0&&o<t.length?t[o]===e[a]?1+us(i)(o+1|0)(a+1|0)|0:Ni(us(i)(o+1|0)(a))(us(i)(o)(a+1|0)):0)(i))(r)(n<=0?[]:re(Ut(0,n-1|0))))(O)((()=>{const r=t.length;return r<=0?[]:re(Ut(0,r-1|0))})())},U_=t=>Fn(t),bk=t=>e=>n=>{const r=e*n;return Wu(0)(1)(r/t)},Ck=t=>e=>n=>r=>o=>i=>{const a=Bp(t)(e)(n)(r)(o)(i);return a.progress<a.morphOutEnd?O_("InsideRect",Bg(2)(e)):a.progress>=a.morphInStart?O_("InsideRect",Bg(2)(n)):O_("InsideBall",a.travelPt,6)},K_=t=>e=>n=>r=>o=>i=>a=>s=>{const u=(c,_)=>Tp({id:c,pass:t,geometry:_p("FlatToken",_),position:(()=>{if(_.tag==="CircleShape")return _._1;if(_.tag==="PolyShape")return Dg(_._1);g()})(),plan:dp("FlatTokenPlan",{wobble:n,fill:a,stroke:s})});return er(c=>{if(c._2.tag==="Travelling"){const _=me(c._2._1.target)(r),f=me(c._2._1.source)(r);if(f.tag==="Just"&&_.tag==="Just"){const l=Qr(c._2._1.edge)(o);if(l.tag==="Just"){const d=(()=>{if(c._2._1.direction==="Forward")return l._1;if(c._2._1.direction==="Backward")return re(l._1);g()})();return u(c._1,(()=>{if(e==="FullTokenGeometry")return Rp(d)(f._1)(_._1)(c._2._1.progress)(c._2._1.holdPre)(c._2._1.holdPost);if(e==="ConvexInsideGeometry"){const h=Ck(d)(f._1)(_._1)(c._2._1.progress)(c._2._1.holdPre)(c._2._1.holdPost);if(h.tag==="InsideRect")return yi("PolyShape",Fg(4)(h._1));if(h.tag==="InsideBall")return yi("CircleShape",h._1,h._2)}g()})())}if(l.tag==="Nothing"){const d=is(c._2._1.holdPre)(c._2._1.holdPost)(c._2._1.progress),h={x:f._1.x+f._1.w/2,y:f._1.y+f._1.h/2},m={x:_._1.x+_._1.w/2,y:_._1.y+_._1.h/2};return Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",(()=>{if(d<.5){const x=d*2;return 1-yr(0)(vi(1)(x))*yr(0)(vi(1)(x))*(3-2*yr(0)(vi(1)(x)))}const p=(d-.5)*2;return yr(0)(vi(1)(p))*yr(0)(vi(1)(p))*(3-2*yr(0)(vi(1)(p)))})())]})(u(c._1,yi("CircleShape",d<.5?h:m,6)))}g()}return j(st("Return",void 0),ct)}if(c._2.tag==="Filling"){if(n)return j(st("Return",void 0),ct);const _=me(c._2._1.node)(r);if(_.tag==="Just")return u(c._1,yi("PolyShape",ni(4)(e==="ConvexInsideGeometry"?Bg(2)(_._1):_._1)));if(_.tag==="Nothing")return j(st("Return",void 0),ct);g()}return j(st("Return",void 0),ct)})(ln(i.tokens))},Lk=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0();return o=>n.bind((()=>{const i=r.pure();if(o.clear.tag==="Nothing")return i;if(o.clear.tag==="Just")return t.clearBackground(o.clear._1);g()})())(()=>n.bind(t.setViewport(o.viewport))(()=>{const i=r.pure();if(o.dots.tag==="Nothing")return i;if(o.dots.tag==="Just")return t.backgroundDots(o.dots._1);g()}))},zp=t=>e=>n=>r=>Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",n.fadeAlpha),pe("GroupTransform",xi,{tx:t.x*(1-n.popScale),ty:(t.y+t.h)*(1-n.popScale),sx:n.popScale,sy:n.popScale}),pe("GroupTransform",xi,{tx:0,ty:e.y*(1-n.flipY),sx:1,sy:n.flipY})]})(wi(r)),kk=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=_=>f=>{const l=Ft(d=>y,d=>h=>w("Just",{head:d,tail:h}),f);if(l.tag==="Nothing")return j(st("Return",void 0),ct);if(l.tag==="Just"){const d=l._1,h=Zo(i)(Rn(d.head)),m=p=>{const x=wi({owner:vo("NodeText",o),text:Rn(d.head),spec:{x:_,y:s-n*i.size*.11*tn(e*5-_*.22),content:Rn(d.head),font:i,color:wk(r.text)(xk(r)(e*2.2+_*.16))(n),align:po,baseline:jn},bounds:y,plan:t});return j(x._1,(()=>{if(x._2.tag==="CatNil")return rt("CatCons",()=>c(_+p)(d.tail),nt(z,z));if(x._2.tag==="CatCons")return rt("CatCons",x._2._1,nt(x._2._2._1,Jt("Cons",rt("CatCons",()=>c(_+p)(d.tail),nt(z,z)),x._2._2._2)));g()})())};return j(h._1,(()=>{if(h._2.tag==="CatNil")return rt("CatCons",m,nt(z,z));if(h._2.tag==="CatCons")return rt("CatCons",h._2._1,nt(h._2._2._1,Jt("Cons",rt("CatCons",m,nt(z,z)),h._2._2._2)));g()})())}g()};return c(a)(Bn(u))},Ip=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>a==="RunHighlight"||a==="RunCodeHighlight"?kk(t)(e)(n)(r)(o)(i)(s)(u)(c):wi({owner:vo("NodeText",o),text:c,spec:{x:s,y:u,content:c,font:i,color:r.text,align:po,baseline:jn},bounds:y,plan:t}),Sk=t=>e=>n=>r=>o=>i=>a=>zp(o)(i)(a)({owner:vo("TokenText",t),text:n,spec:{x:i.x,y:i.y,content:n,font:{family:e.fontFamily,size:11,weight:500},color:e.chipText,align:jo,baseline:jn},bounds:w("Just",o),plan:la("TokenFillingText",{shadow:{...o,y:o.y+1.5},shadowFill:{color:e.chipShadow,flat:!0},radius:6,fill:{color:e.chip,flat:!0},stroke:{color:e.chipHairline,width:1,lineJoin:nn,lineCap:zn},leader:[1,i.x,o.y+o.h,2,r.x+r.w/2,r.y]})}),Ek={offset:.8,passes:2,rMax:5},Y_=t=>e=>n=>r=>Se({path:[],role:dn,layer:w("Just",XJ),effects:[pe("GroupClip",Jk(n)(t.nodes)(r),Sg)]})(K_(hp)(W_)(e.wobble)(t.nodes)(t.edges)(r)(e.tokenOutsideFill)(e.tokenOutsideStroke)),Qp=t=>e=>n=>r=>{if(n.tokenInsideBlend==="Difference"){const o=WL(e),i=a=>{const s=Se({path:[],role:dn,layer:w("Just",ZJ),effects:[pe("GroupBlend",Xs),pe("GroupClip",V_(t.nodes)(r),ti)]})(K_(pp)(a==="ConvexAbsorb"?mk:W_)(n.wobble)(t.nodes)(t.edges)(r)(n.tokenInside)(n.tokenInsideStroke)),u=()=>Se({path:[],role:dn,layer:w("Just",jJ),effects:[]})(er(c=>{const _=me(c._1)(r.nodes);return _.tag==="Just"&&pi(_._1).alpha>0?Ji(mi({path:yo(c._2),fill:w("Just",{color:we,flat:!1}),stroke:y})):j(st("Return",void 0),ct)})(ln(t.nodes)));return j(s._1,(()=>{if(s._2.tag==="CatNil")return rt("CatCons",u,nt(z,z));if(s._2.tag==="CatCons")return rt("CatCons",s._2._1,nt(s._2._2._1,Jt("Cons",rt("CatCons",u,nt(z,z)),s._2._2._2)));g()})())};return j(o._1,(()=>{if(o._2.tag==="CatNil")return rt("CatCons",i,nt(z,z));if(o._2.tag==="CatCons")return rt("CatCons",o._2._1,nt(o._2._2._1,Jt("Cons",rt("CatCons",i,nt(z,z)),o._2._2._2)));g()})())}if(n.tokenInsideBlend==="Normal")return Se({path:[],role:dn,layer:y,effects:[pe("GroupClip",V_(t.nodes)(r),ti),pe("GroupAlpha",n.tokenInsideAlpha)]})(K_(pp)(W_)(n.wobble)(t.nodes)(t.edges)(r)(n.tokenInside)(n.tokenInsideStroke));g()},Mp=t=>e=>n=>r=>t.strokePath((()=>{const o=Ft(i=>y,i=>a=>w("Just",{head:i,tail:a}),Y(i=>i.pt)(ey(i=>a=>{const s=ot(a)/ot(72),u=Ge(-.18)(.18)(i.prng),c=Ge(-.1)(.1)(u.prng),_=Ge(-.07)(.07)(c.prng),f=n*(.05+.55*s)*(1+c.value),l=s*28.274333882308138+u.value;return{prng:_.prng,pt:{x:e.x+yn(l)*f+_.value*n,y:e.y+tn(l)*f+_.value*n}}},{prng:137,pt:{x:e.x,y:e.y}},Ut(0,72))));if(o.tag==="Just")return[1,o._1.head.x,o._1.head.y,...lk(i=>[2,i.x,i.y])(o._1.tail)];if(o.tag==="Nothing")return[];g()})())({color:r,width:5.5,lineJoin:nn,lineCap:Gr}),Pk=t=>{const e=t.Monad0().Applicative0();return n=>{if(n.geometry.tag==="FlatToken"&&n.plan.tag==="FlatTokenPlan"){if(n.geometry._1.tag==="CircleShape")return n.plan._1.wobble?Mp(t)(n.geometry._1._1)(n.geometry._1._2)({r:200,g:35,b:30,a:220}):t.fillStrokePath(Qd(n.geometry._1._1)(n.geometry._1._2))({color:n.plan._1.fill,flat:!0})({color:n.plan._1.stroke,width:1,lineJoin:nn,lineCap:zn});if(n.geometry._1.tag==="PolyShape")return n.plan._1.wobble&&n.geometry._1._1.length>=3?Mp(t)(Dg(n.geometry._1._1))(6)({r:200,g:35,b:30,a:220}):n.geometry._1._1.length>=3?t.fillStrokePath(Fd(n.geometry._1._1))({color:n.plan._1.fill,flat:!0})({color:n.plan._1.stroke,width:1,lineJoin:nn,lineCap:zn}):e.pure();g()}return e.pure()}},Gk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=t.popClip,i=t.popTransform,a=t.popAlpha;return s=>u=>c=>_=>f=>{const l=pi(f),d=c*l.alpha,h={..._,y:_.y+5},m=_.x+_.w/2,p=_.y+_.h/2,x=Fp(h),J=r.bind(t.pushAlpha(d))(()=>r.bind(t.pushTransform({tx:m*(1-l.scale),ty:p*(1-l.scale),sx:l.scale,sy:l.scale}))(()=>r.bind(t.pushClip(x)(Sg))(()=>r.bind(ei(t)(h.shape)({x:h.x,y:h.y,w:h.w,h:h.h})(7)(w("Just",{color:s.shadowFill,flat:!0}))(y))(()=>r.bind((()=>{const T=r.bind(t.pushClip(yo(h))(ti))(()=>r.bind(t.backgroundDots({viewport:{vx:h.x,vy:h.y,vw:h.w,vh:h.h},bgColor:s.bgTransparent,dotColor:s.shadowDot,tile:1.6,dotRadius:.25,origin:{x:0,y:0}}))(()=>o));return u&&!s.wobble?T:n.pure()})())(()=>r.bind(ei(t)(h.shape)({x:h.x,y:h.y,w:h.w,h:h.h})(7)(y)(w("Just",{color:s.nodeStroke,width:1.25,lineJoin:nn,lineCap:zn})))(()=>r.bind(o)(()=>r.bind(i)(()=>a))))))));return d>0&&!s.wobble?J:n.pure()}},Ak=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,o=bi(e.Applicative0());return i=>a=>s=>o(u=>n.bind(t.pushAlpha(u.alpha))(()=>n.bind(t.strokePath(u.path)({color:i.nodeFill,width:u.width,lineJoin:nn,lineCap:Gr}))(()=>r)))(_k(Cp(a)+7777|0)(a)(s))},Bk=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,o=e.Applicative0(),i=bi(o),a=t.popClip,s=bi(o),u=ao.traverse(o),c=Tk(t),_=Ak(t),f=t.popTransform;return l=>d=>h=>m=>p=>x=>J=>T=>N=>k=>{const C=F=>n.bind(t.pushAlpha(F.alpha))(()=>n.bind(t.strokePath(F.path)({color:h.nodeStroke,width:2,lineJoin:nn,lineCap:Gr}))(()=>r)),P={family:h.fontFamily,size:h.wobble?15:11,weight:h.wobble?800:500},G=Fn(N.label===""?T:N.label),R=P.size*1.2,U=N.shape==="Cylinder"?t.strokePath(_w({x:N.x,y:N.y,w:N.w,h:N.h}))({color:h.nodeStroke,width:1.25,lineJoin:nn,lineCap:zn}):o.pure(),S=(N.shape==="Cylinder"?(N.y+(N.y+N.h+5-2*Sn(N.h*.075)(N.w*.075)))/2:(N.y+N.y+N.h)/2)-ot(G.length)*R/2+R/2,b=k.tag==="PloppingOut"&&h.wobble?k._1:-1,I=b>=0,H=pi(k),Q=I?{alpha:1,scale:1}:H,q=N.x+N.w/2,$=N.y+N.h/2,A=n.bind(t.pushAlpha(Q.alpha))(()=>n.bind(t.pushTransform({tx:q*(1-Q.scale),ty:$*(1-Q.scale),sx:Q.scale,sy:Q.scale}))(()=>{const F={x:N.x,y:N.y,w:N.w,h:N.h},M={color:h.nodeStroke,width:h.wobble?2:1.25*d,lineJoin:nn,lineCap:h.wobble?Gr:zn},W=(()=>{if(h.wobble){if(N.shape==="Rectangle")return i(C)(gk(kp)(Cp(F))(F));const D=ni(7)(N);return n.bind(i(C)((()=>{const X=as(D);return D.length<4?[]:ha(bp)(X)(!0)(D)})()))(()=>s(X=>i(C)((()=>{const V=as(X);return X.length<2?[]:ha(bp)(V)(!1)(X)})()))(N.shape==="Cylinder"?[vw(N)]:[]))}return n.bind(ei(t)(N.shape)(F)(7)(y)(w("Just",M)))(()=>U)})();return n.bind((()=>{if(p.tag==="Nothing")return n.bind(t.pushAlpha(m))(()=>n.bind(h.wobble?W:n.bind(ei(t)(N.shape)(F)(7)(w("Just",{color:h.nodeFill,flat:!1}))(w("Just",M)))(()=>U))(()=>n.bind((()=>{if(J.tag==="Just"&&h.wobble&&!I){const D=J._1;return n.bind(u(c(P))(G))(X=>{const V=Pt(yt=>Ct=>at.compare(yt.x)(Ct.x)),K=he(ar(N.x*7919+N.y*3001))*-1640531535|0,Z=Ge(5)(7.5)(K),tt=Ge(0)(Z.value)(Z.prng),et=-(1+2*Ge(-1)(1)(tt.prng).value*3.141592653589793/180),ft=(yt,Ct,Wt,zt,se)=>V(ht(_e=>_e)([et*Ct+yt>=zt&&et*Ct+yt<=se?w("Just",{x:Ct,y:et*Ct+yt}):y,et*Wt+yt>=zt&&et*Wt+yt<=se?w("Just",{x:Wt,y:et*Wt+yt}):y,(()=>{const _e=(zt-yt)/et;return _e>=Ct&&_e<=Wt?w("Just",{x:_e,y:zt}):y})(),(()=>{const _e=(se-yt)/et;return _e>=Ct&&_e<=Wt?w("Just",{x:_e,y:se}):y})()])),Nt=Z.value,dt=go(D.frameHash)(3),mt=dt===0?{r:200,g:35,b:30,a:220}:dt===1?{r:35,g:150,b:80,a:220}:{r:30,g:80,b:200,a:220},bt=N.x+N.w/2,Ht=Ln(Mt(yt=>Ct=>Mt((()=>{const Wt=S+ot(yt)*R,zt=bt-v(se=>_e=>se+_e.w)(0)(Ct)/2;return se=>_e=>{const pn=P.size*.1,qt=se-1|0,jt=qt>=0&&qt<Ct.length&&se>0?(Ct[qt].x+Ct[qt].w+_e.x)/2:_e.x-pn;return{x:zt+jt-1,y:Wt-_e.up-1,w:yr(0)((()=>{const an=se+1|0;return an>=0&&an<Ct.length&&se<(Ct.length-1|0)?(_e.x+_e.w+Ct[an].x)/2-jt:_e.x+_e.w+pn-jt})())+2,h:_e.up+_e.down+2}}})())(Ct))(X)),Tt=N.y+4,Vt=N.x+N.w-4,At=N.x+4,vt=Tt-et*At+tt.value,pt=N.y+N.h-4,gt=St(St(Mt(yt=>Ct=>{const Wt=(Ct.from.x+Ct.to.x)/2,zt=(Ct.from.y+Ct.to.y)/2,se=Ge(-1)(1)(K+(911*(yt+1|0)|0)|0),_e=Ge(-3)(5)(se.prng),pn=se.value*3.141592653589793/180,qt=yn(pn),jt=tn(pn),an=$e=>({x:Wt+($e.x-Wt)*qt-($e.y-zt)*jt,y:zt+($e.x-Wt)*jt+($e.y-zt)*qt});return{from:(()=>{const $e=an(Ct.from),$n=$e.y-zt,qn=$e.x-Wt,Ze=qe(qn*qn+$n*$n),ce=Ze<1e-4?1:(Ze+_e.value)/Ze;return{x:Wt+qn*ce,y:zt+$n*ce}})(),to:(()=>{const $e=an(Ct.to),$n=Ge(-3)(5)(_e.prng).value,qn=$e.y-zt,Ze=$e.x-Wt,ce=qe(Ze*Ze+qn*qn),ve=ce<1e-4?1:(ce+$n)/ce;return{x:Wt+Ze*ve,y:zt+qn*ve}})()}})(ht(yt=>{const Ct=ft(vt+ot(yt)*Nt,At,Vt,Tt,pt);return Ct.length===2?w("Just",{from:Ct[0],to:Ct[1]}):y})(Ut(0,Ni(1)(he(ar((pt-et*Vt-vt)/Nt)))))))(yt=>_t(Ct=>Ct.to.x-Ct.from.x>1,v(Ct=>Wt=>St(Ct)(zt=>{const se=ft(zt.from.y-et*zt.from.x,Wt.x,Wt.x+Wt.w,Wt.y,Wt.y+Wt.h);return se.length===2?se[0].x>zt.from.x+.001&&se[1].x<zt.to.x-.001?[{from:zt.from,to:se[0]},{from:se[1],to:zt.to}]:se[0].x<=zt.from.x+.001&&se[1].x<zt.to.x-.001?[{from:se[1],to:zt.to}]:se[0].x>zt.from.x+.001&&se[1].x>=zt.to.x-.001?[{from:zt.from,to:se[0]}]:[]:[zt]}))([yt])(Ht))))(yt=>(()=>{const Ct=yt.to.x-yt.from.x;return qe(2)*(Ct>=0?Ct:-Ct)<=28})()?[yt]:[{from:yt.from,to:{x:yt.from.x+(yt.to.x-yt.from.x)*.495,y:yt.from.y+(yt.to.y-yt.from.y)*.495}},{from:{x:yt.from.x+(yt.to.x-yt.from.x)*.505,y:yt.from.y+(yt.to.y-yt.from.y)*.505},to:yt.to}]),wt=gt.length,Rt=yt=>yr(0)(vi(1)(D.t*ot(wt)-ot(yt)));return n.bind(t.pushClip(Fd(ni(7)(N)))(ti))(()=>n.bind(i(yt=>{const Ct=yt._1,Wt=Ge(1.4)(1.9)(K+(1303*(Ct+1|0)|0)|0),zt=Ge(.35)(.8)(Wt.prng),se=i(_e=>n.bind(t.pushAlpha(_e.alpha*zt.value))(()=>n.bind(t.strokePath(Lp(Rt(Ct))(_e.path))({color:mt,width:Wt.value,lineJoin:nn,lineCap:Gr}))(()=>r)))(ha({...kp,rMax:0,offset:.5})(K+(53*(Ct+1|0)|0)|0)(!1)([yt._2.from,yt._2.to]));return Rt(Ct)>0?se:o.pure()})(Mt(Cn)(gt)))(()=>a))})}return o.pure()})())(()=>n.bind((()=>{if(l==="LabelsShown"){const D=n.bind(t.pushAlpha(x))(()=>n.bind(i(X=>t.drawText({x:N.x+N.w/2,y:S+ot(X._1)*R,content:X._2,font:P,color:h.text,align:jo,baseline:jn}))(Mt(Cn)(G)))(()=>r));return x>0?D:o.pure()}if(l==="LabelsHidden")return o.pure();g()})())(()=>n.bind((()=>{const D=_(h)(F)(b);return I?D:o.pure()})())(()=>r)))));if(p.tag==="Just"){const D=p._1;return n.bind((()=>{const X=n.bind(t.pushAlpha(m))(()=>n.bind(ei(t)(N.shape)(F)(7)(w("Just",{color:h.nodeFill,flat:!1}))(y))(()=>r));return m>0&&!h.wobble?X:o.pure()})())(()=>{const X=n.bind(t.pushAlpha(D))(()=>n.bind(W)(()=>r));return D>0?X:o.pure()})}g()})())(()=>n.bind(f)(()=>r))}));return Q.alpha*yr(m)((()=>{if(p.tag==="Nothing")return m;if(p.tag==="Just")return p._1;g()})())>0?A:o.pure()}},Op=t=>e=>n=>r=>er(o=>{const i=Qr(o._1)(r.edges);if(i.tag==="Just"){const a=Qr(o._1)(r.edgeFadeAlpha),s=(()=>{if(a.tag==="Nothing")return 1;if(a.tag==="Just")return a._1;g()})(),u=wp({id:o._1,geometry:up("FlatRoute",(()=>{const c=Qr(o._1)(t.edges);if(c.tag==="Nothing")return o._2;if(c.tag==="Just")return c._1;g()})()),visible:LL(i._1),arrow:(()=>{const c=cr("conn:")(o._1);if(c.tag==="Just")return!1;if(c.tag==="Nothing")return!0;g()})(),settlingAtTarget:i._1.tag==="Extending"&&i._1._1==="ExtendFromSource",plan:cp("FlatEdgePlan",e)});return s===1?u:Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",s)]})(u)}if(i.tag==="Nothing")return j(st("Return",void 0),ct);g()})(ln(n.edges)),Rk=t=>e=>n=>{const r={family:t.fontFamily,size:11,weight:500};return er(o=>{if(o._2===""||(()=>{const s=Qr(o._1)(n.edges);return s.tag==="Nothing"||!(s.tag==="Just"&&OT.eq(s._1)(gu))})())return j(st("Return",void 0),ct);const i=Qr(o._1)(e.edges),a=(()=>{if(i.tag==="Just")return Yo(i._1)(.5);if(i.tag==="Nothing")return y;g()})();if(a.tag==="Nothing")return j(st("Return",void 0),ct);if(a.tag==="Just"){const s=a._1,u=Zo(r)(o._2),c=_=>{const f=_+12;return wi({owner:vo("EdgeText",o._1),text:o._2,spec:{x:s.x,y:s.y,content:o._2,font:r,color:t.chipPillText,align:jo,baseline:jn},bounds:w("Just",{x:s.x-f/2,y:s.y-8.5,w:f,h:17}),plan:la("RoundedText",{radius:3,fill:w("Just",{color:t.chipPillFill,flat:!0}),stroke:y})})};return j(u._1,(()=>{if(u._2.tag==="CatNil")return rt("CatCons",c,nt(z,z));if(u._2.tag==="CatCons")return rt("CatCons",u._2._1,nt(u._2._2._1,Jt("Cons",rt("CatCons",c,nt(z,z)),u._2._2._2)));g()})())}g()})(ln(e.edgeLabels))},Dk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=t.popClip,i=t.popTransform,a=t.popAlpha;return s=>u=>c=>_=>f=>{const l=pi(f),d=c*l.alpha,h=_.x+_.w/2,m=_.y-5+_.h/2,p=Fp(_),x=r.bind(t.pushAlpha(d))(()=>r.bind(t.pushTransform({tx:h*(1-l.scale),ty:m*(1-l.scale),sx:l.scale,sy:l.scale}))(()=>r.bind(t.pushClip(p)(Sg))(()=>r.bind(ei(t)(_.shape)({x:_.x,y:_.y,w:_.w,h:_.h})(7)(w("Just",{color:s.shadowFill,flat:!0}))(y))(()=>r.bind((()=>{const J=r.bind(t.pushClip(yo(_))(ti))(()=>r.bind(t.backgroundDots({viewport:{vx:_.x,vy:_.y,vw:_.w,vh:_.h},bgColor:s.bgTransparent,dotColor:s.shadowDot,tile:1.6,dotRadius:.25,origin:{x:0,y:0}}))(()=>o));return u?J:n.pure()})())(()=>r.bind(ei(t)(_.shape)({x:_.x,y:_.y,w:_.w,h:_.h})(7)(y)(w("Just",{color:s.nodeStroke,width:1.25,lineJoin:nn,lineCap:zn})))(()=>r.bind(o)(()=>r.bind(i)(()=>a))))))));return d>0&&!s.wobble?x:n.pure()}},Fk=t=>{const e=Gk(t),n=Dk(t),r=Bk(t);return o=>{if(o.geometry.tag==="FlatNode"&&o.plan.tag==="FlatNodePlan"){const i={x:o.geometry._1.bounds.x,y:o.geometry._1.bounds.y,w:o.geometry._1.bounds.w,h:o.geometry._1.bounds.h,label:o.plan._1.label,shape:o.geometry._1.shape};if(o.role==="NodeShadow")return e(o.plan._1.palette)(o.plan._1.inkBoost>0)(o.alpha)(i)(o.plan._1.animState);if(o.role==="NodeDoorwayFrame")return n(o.plan._1.palette)(o.plan._1.inkBoost>0)(o.alpha)(i)(o.plan._1.animState);if(o.role==="NodeBody"||o.role==="NodeInversion")return r(Iu)(o.plan._1.inkBoost)(o.plan._1.palette)(o.alpha)(o.plan._1.outlineAlpha)(0)(o.plan._1.arrival)(o.id)(i)(o.plan._1.animState);g()}return t.Monad0().Applicative0().pure()}},zk=t=>e=>{const n=Bn(t),r=n.length,o=Bn(e),i=o.length,a=vk(n)(o);return(s=>u=>c=>{let _=s,f=u,l=c,d=!0,h;for(;d;){const m=_,p=f,x=l;if(m>=r&&p>=i){d=!1,h=re(x);continue}if(m>=r){if(p>=0&&p<o.length){_=m,f=p+1|0,l=[ss("DiffInsert",p,o[p]),...x];continue}d=!1,h=re(x);continue}if(p>=i){if(m>=0&&m<n.length){_=m+1|0,f=p,l=[ss("DiffDelete",m,n[m]),...x];continue}d=!1,h=re(x);continue}if(p>=0&&p<o.length){if(m>=0&&m<n.length){if(n[m]===o[p]){_=m+1|0,f=p+1|0,l=[ss("DiffKeep",m,p,n[m]),...x];continue}if(us(a)(m+1|0)(p)>=us(a)(m)(p+1|0)){_=m+1|0,f=p,l=[ss("DiffDelete",m,n[m]),...x];continue}_=m,f=p+1|0,l=[ss("DiffInsert",p,o[p]),...x];continue}d=!1,h=re(x);continue}d=!1,h=re(x)}return h})(0)(0)([])},Wp=t=>e=>n=>r=>o=>er(i=>{if(t.tag==="Just"&&i._1===t._1)return j(st("Return",void 0),ct);const a=me(i._1)(o.nodes);if(a.tag==="Just"){const s=me(i._1)(o.nodeLabels),u=(()=>{if(s.tag==="Nothing")return i._2;if(s.tag==="Just"){if(s._1.tag==="StaticNodeLabel")return{...i._2,label:s._1._1===""?i._1:s._1._1};if(s._1.tag==="RelabelingNode")return{...i._2,label:(()=>{const c=s._1._1.progress<.5?s._1._1.oldLabel:s._1._1.newLabel;return c===""?i._1:c})()}}g()})();return Qu({id:i._1,role:IL,geometry:Du("FlatNode",{shape:u.shape,bounds:{x:u.x,y:u.y,w:u.w,h:u.h}}),alpha:(()=>{const c=me(i._1)(o.nodeFadeAlpha),_=(()=>{if(c.tag==="Nothing")return 1;if(c.tag==="Just")return c._1;g()})();return _<1?0:_})(),plan:Fu("FlatNodePlan",{palette:e,label:(()=>{const c=me(i._1)(o.nodeLabels);if(c.tag==="Just"){if(c._1.tag==="StaticNodeLabel")return c._1._1===""?i._1:c._1._1;if(c._1.tag==="RelabelingNode"){const _=c._1._1.progress<.5?c._1._1.oldLabel:c._1._1.newLabel;return _===""?i._1:_}g()}if(c.tag==="Nothing")return u.label===""?i._1:u.label;g()})(),labelVisibility:Iu,inkBoost:n?1:0,labelAlpha:0,outlineAlpha:y,arrival:y,animState:a._1})})}if(a.tag==="Nothing")return j(st("Return",void 0),ct);g()})(ln(r.nodes)),X_=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=dr(u),_=l=>d=>h=>{const m=Ft(x=>y,x=>J=>w("Just",{head:x,tail:J}),h),p=Ft(x=>y,x=>J=>w("Just",{head:x,tail:J}),d);if(p.tag==="Just"&&m.tag==="Just"){const x=Ip(t)(e)(n)(r)(o)(p._1.head.style==="RunCode"||p._1.head.style==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(p._1.head.style)(l)(s)(p._1.head.text);return j(x._1,(()=>{if(x._2.tag==="CatNil")return rt("CatCons",()=>_(l+m._1.head)(p._1.tail)(m._1.tail),nt(z,z));if(x._2.tag==="CatCons")return rt("CatCons",x._2._1,nt(x._2._2._1,Jt("Cons",rt("CatCons",()=>_(l+m._1.head)(p._1.tail)(m._1.tail),nt(z,z)),x._2._2._2)));g()})())}return j(st("Return",void 0),ct)};if(c.length===1&&c[0].style==="RunText")return wi({owner:vo("NodeText",o),text:c[0].text,spec:{x:a,y:s,content:c[0].text,font:i,color:r.text,align:jo,baseline:jn},bounds:y,plan:t});const f=Hu(l=>Zo(l.style==="RunCode"||l.style==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(l.text))(c);return j(f._1,(()=>{if(f._2.tag==="CatNil")return rt("CatCons",l=>_(a-pa(l)/2)(c)(l),nt(z,z));if(f._2.tag==="CatCons")return rt("CatCons",f._2._1,nt(f._2._2._1,Jt("Cons",rt("CatCons",l=>_(a-pa(l)/2)(c)(l),nt(z,z)),f._2._2._2)));g()})())},Ik=t=>e=>{const n=Hu(r=>Zo(r.style==="RunCode"||r.style==="RunCodeHighlight"?{...t,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:t)(r.text))(dr(e));return j(n._1,(()=>{if(n._2.tag==="CatNil")return rt("CatCons",r=>j(st("Return",pa(r)),ct),nt(z,z));if(n._2.tag==="CatCons")return rt("CatCons",n._2._1,nt(n._2._2._1,Jt("Cons",rt("CatCons",r=>j(st("Return",pa(r)),ct),nt(z,z)),n._2._2._2)));g()})())},Hp=t=>e=>n=>r=>{const o=Fn(r===""?t:r),i=n.size*1.2,a=(e.shape==="Cylinder"?(e.y+(e.y+e.h+5-2*Sn(e.h*.075)(e.w*.075)))/2:(e.y+e.y+e.h)/2)-ot(o.length)*i/2+i/2,s=Hu(Ik(n))(o),u=c=>j(st("Return",Mt(_=>f=>({line:lr(f),runs:dr(f),left:_>=0&&_<c.length?e.x+e.w/2-c[_]/2:e.x+e.w/2-0,y:a+ot(_)*i}))(o)),ct);return j(s._1,(()=>{if(s._2.tag==="CatNil")return rt("CatCons",u,nt(z,z));if(s._2.tag==="CatCons")return rt("CatCons",s._2._1,nt(s._2._2._1,Jt("Cons",rt("CatCons",u,nt(z,z)),s._2._2._2)));g()})())},Qk=t=>e=>n=>{const r=Hu(o=>Zo(o.style==="RunCode"||o.style==="RunCodeHighlight"?{...t,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:t)(o.text))(Dp(e)(n));return j(r._1,(()=>{if(r._2.tag==="CatNil")return rt("CatCons",o=>j(st("Return",pa(o)),ct),nt(z,z));if(r._2.tag==="CatCons")return rt("CatCons",r._2._1,nt(r._2._2._1,Jt("Cons",rt("CatCons",o=>j(st("Return",pa(o)),ct),nt(z,z)),r._2._2._2)));g()})())},$p=t=>{const e=n=>{if(n.tag==="Leaf")return O;if(n.tag==="Node")return ee("Node",n._1,n._2,n._3,Q_({x:t.vx,y:t.vy,w:t.vw,h:t.vh})(n._4),e(n._5),e(n._6));g()};return e},Mk=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=bi(r);return i=>a=>s=>u=>c=>_=>{const f=_n(_).length,l=ot(f+1|0),d=p=>{const x=(s*l-ot(p))/1.5,J=x<0?0:x>1?1:x;return J*J*(3-2*J)},h=(p=>{let x=p,J=!0,T;for(;J;){const N=x;if(N>=f){J=!1,T=N;continue}if(d(N)>=1){x=N+1|0;continue}J=!1,T=N}return T})(0),m=h>=f?[]:Er(p=>d(p)>0)(Ut(h,f-1|0)).init;return n.bind((()=>{const p=t.drawText({x:u,y:c,content:Ve(h)(_),font:i,color:a,align:po,baseline:jn});return h>0?p:r.pure()})())(()=>o(p=>n.bind(t.measureText(i)(Ve(p)(_)))(x=>{const J=d(p);return t.drawText({x:u+x,y:c-(1-J)*10,content:Ve(1)(Mi(Dn(Ve(p)(_)))(_)),font:i,color:{...a,a:he(ar(J*ot(a.a)))},align:po,baseline:jn})}))(m))}},Ok=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),o=bi(r),i=Mk(t);return a=>{const s={...a.spec,content:SJ(a.spec.content)};if(a.plan.tag==="PlainText")return t.drawText(s);if(a.plan.tag==="RoundedText")return n.bind((()=>{const u=r.pure();if(a.bounds.tag==="Nothing")return u;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(a.plan._1.radius)(a.plan._1.fill)(a.plan._1.stroke);g()})())(()=>t.drawText(s));if(a.plan.tag==="TokenTravelText"){const u=a.plan._1;return n.bind(o(c=>t.fillPath(Qd(c)(1.5))(u.trailFill))(u.trail))(()=>n.bind((()=>{const c=r.pure();if(a.bounds.tag==="Nothing")return c;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(u.radius)(w("Just",u.fill))(y);g()})())(()=>i(s.font)(s.color)(u.reveal)(u.textLeft)(s.y)(lr(a.text))))}if(a.plan.tag==="TokenFillingText"){const u=a.plan._1;return n.bind(t.drawRoundedRect(u.shadow)(u.radius)(w("Just",u.shadowFill))(y))(()=>n.bind((()=>{const c=r.pure();if(a.bounds.tag==="Nothing")return c;if(a.bounds.tag==="Just")return t.drawRoundedRect(a.bounds._1)(u.radius)(w("Just",u.fill))(w("Just",u.stroke));g()})())(()=>n.bind(t.strokePath(u.leader)(u.stroke))(()=>t.drawText(s))))}if(a.plan.tag==="AffineText")return t.drawTextAffine(a.plan._1)(s);g()}},Wk=t=>e=>n=>r=>o=>i=>a=>zp(r)(o)(i)({owner:vo("TokenText",t),text:n.line,spec:{x:o.x,y:o.y,content:n.line,font:{family:e.fontFamily,size:11,weight:500},color:e.chipPillText,align:po,baseline:jn},bounds:w("Just",r),plan:la("TokenTravelText",{trail:Nk(r)(a),trailFill:{color:e.trailDot,flat:!0},radius:3,fill:{color:e.chipPillFill,flat:!0},textLeft:r.x+14,reveal:(()=>{const s=n.phaseInLabel/.45;return s<0?0:s>1?1:s})()})}),$u=t=>e=>n=>r=>{const o=Y(d=>ot(Ni(1)(_n(d).length)))(r),i=yr(1)(v(xr)(0)(o)),a=is(e)(n)(t),s=a*i,u=Ni(1)(r.length),c=(d=>h=>m=>{let p=d,x=h,J=m,T=!0,N;for(;T;){const k=p,C=x,P=Ft(G=>y,G=>R=>w("Just",{head:G,tail:R}),J);if(P.tag==="Nothing"){T=!1,N=Ni(0)(u-1|0);continue}if(P.tag==="Just"){if(C+P._1.head>=s){T=!1,N=k;continue}p=k+1|0,x=C+P._1.head,J=P._1.tail;continue}g()}return N})(0)(0)(o),_=v(xr)(0)(c<1?[]:Bt(0,c,o)),f=_/i;if(c>=0&&c<o.length){const d=(_+o[c])/i;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(d<=f)return 1;const h=(a-f)/(d-f);return h<0?0:h>1?1:h})()}}const l=(_+1)/i;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(l<=f)return 1;const d=(a-f)/(l-f);return d<0?0:d>1?1:d})()}},qp=t=>e=>n=>r=>o=>t.Bind1().bind(e({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})($u(r)(0)(0)(Y(wa)(o)).line))(i=>{const a=i+28;return t.Applicative0().pure({x:n.x+n.w/2-a/2,y:n.y-25.2-14,w:a,h:25.2})}),Hk=t=>{const e=t.Bind1(),n=t.Applicative0(),r=ao.traverse(n);return o=>i=>a=>e.Apply0().Functor0().map(s=>Gp(ht(u=>u)(s)))(r(s=>{if(s._2.tag==="Filling"&&s._2._1.labels.length!==0){const u=me(s._2._1.node)(i);if(u.tag==="Just")return e.bind(qp(t)(o)(u._1)(s._2._1.progress)(s._2._1.labels))(c=>n.pure(w("Just",E(s._1,c))));if(u.tag==="Nothing")return n.pure(y);g()}return n.pure(y)})(ln(a.tokens)))},$k=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=H_(n)(r)(o)(i)(a)(s);return t.Bind1().bind(e({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})($u(i)(a)(s)(St(u)(U_)).line))(_=>t.Applicative0().pure({x:c.x+14+_/2-_/2-14,y:c.y-6-8-6.6-6,w:_+28,h:25.2}))},qk=t=>{const e=t.Bind1(),n=t.Applicative0(),r=ao.traverse(n);return o=>i=>a=>s=>e.Apply0().Functor0().map(u=>Gp(ht(c=>c)(u)))(r(u=>{if(u._2.tag==="Travelling"&&u._2._1.labels.length!==0){const c=me(u._2._1.target)(i),_=me(u._2._1.source)(i),f=Qr(u._2._1.edge)(a);if(f.tag==="Just"&&_.tag==="Just"&&c.tag==="Just"){const l=(()=>{if(u._2._1.direction==="Forward")return f._1;if(u._2._1.direction==="Backward")return re(f._1);g()})(),d=H_(l)(_._1)(c._1)(u._2._1.progress)(u._2._1.holdPre)(u._2._1.holdPost);return e.bind($k(t)(o)(l)(_._1)(c._1)(u._2._1.progress)(u._2._1.holdPre)(u._2._1.holdPost)(u._2._1.labels))(h=>n.pure(w("Just",E(u._1,{id:u._1,rect:h,token:d}))))}}return n.pure(y)})(ln(s.tokens)))},Vp=t=>{const e=t.Bind1(),n=qk(t),r=Hk(t);return o=>i=>a=>s=>e.bind(n(o)(a.nodes)(a.edges)(s))(u=>e.bind(r(o)(a.nodes)(s))(c=>t.Applicative0().pure(ZL({x:i.vx,y:i.vy,w:i.vw,h:i.vh})([...ht(_=>{const f=me(_._1)(s.nodes);return f.tag==="Just"&&pi(f._1).alpha>0?w("Just",{x:_._2.x,y:_._2.y,w:_._2.w,h:_._2.h}):y})(ln(a.nodes)),...(()=>{const _=(f,l)=>{if(f.tag==="Leaf")return l;if(f.tag==="Node")return _(f._5,Jt("Cons",f._4,_(f._6,l)));g()};return It(ge.foldr,_(c,z))})()])(ht(_=>Ap(_)(u))((()=>{const _=f=>{if(f.tag==="Leaf")return O;if(f.tag==="Node")return ee("Node",f._1,f._2,f._3,void 0,_(f._5),_(f._6));g()};return Pt(B.compare)(It(xn.foldr,_(u)))})())))))},Vk=Vp(xg),Up=t=>{const e=Vp(t);return n=>r=>o=>e(n)(r)($_(o))},Z_=t=>e=>n=>{const r=(e*ot(t+1|0)-ot(n))/1.5,o=r<0?0:r>1?1:r;return o*o*(3-2*o)},ma=t=>e=>n=>{const r=Qk(t)(n)(e.runs);return j(r._1,(()=>{if(r._2.tag==="CatNil")return rt("CatCons",o=>j(st("Return",e.left+o),ct),nt(z,z));if(r._2.tag==="CatCons")return rt("CatCons",r._2._1,nt(r._2._2._1,Jt("Cons",rt("CatCons",o=>j(st("Return",e.left+o),ct),nt(z,z)),r._2._2._2)));g()})())},Uk=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=u<0?0:u>1?1:u,_=yr(8)(i.size*.9),f=(m,p,x,J,T)=>{const N=Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",m)]})(Ip(t)(e)(1)(n)(r)(T==="RunCode"||T==="RunCodeHighlight"?{...i,family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",weight:400}:i)(T)(p)(x)(Rn(J)));return m>.001?N:j(st("Return",void 0),ct)},l=(m,p)=>{const x=_n(m.line).length;return Z_(x)(c)((x-p|0)-1|0)},d=Hp(r)(o)(i)(a),h=m=>{const p=Hp(r)(o)(i)(s),x=J=>er(T=>{const N=T>=0&&T<m.length?w("Just",m[T]):y,k=T>=0&&T<J.length?w("Just",J[T]):y;return er(C=>{if(C.tag==="DiffKeep"){if(N.tag==="Just"){if(k.tag==="Just"){const P=k._1,G=N._1,R=ma(i)(G)(C._1),U=S=>{const b=ma(i)(P)(C._2),I=H=>f(1,S+(H-S)*c,G.y+(P.y-G.y)*c,C._3,(()=>{if(c<.5){const q=St(G.runs)($=>Fo(_n($.text).length,$.style));return C._1>=0&&C._1<q.length?q[C._1]:Kr}const Q=St(P.runs)(q=>Fo(_n(q.text).length,q.style));return C._2>=0&&C._2<Q.length?Q[C._2]:Kr})());return j(b._1,(()=>{if(b._2.tag==="CatNil")return rt("CatCons",I,nt(z,z));if(b._2.tag==="CatCons")return rt("CatCons",b._2._1,nt(b._2._2._1,Jt("Cons",rt("CatCons",I,nt(z,z)),b._2._2._2)));g()})())};return j(R._1,(()=>{if(R._2.tag==="CatNil")return rt("CatCons",U,nt(z,z));if(R._2.tag==="CatCons")return rt("CatCons",R._2._1,nt(R._2._2._1,Jt("Cons",rt("CatCons",U,nt(z,z)),R._2._2._2)));g()})())}if(k.tag==="Nothing"){const P=N._1,G=ma(i)(P)(C._1),R=U=>{const S=l(P,C._1);return f(1-S,U,P.y-_*S,C._3,(()=>{const b=St(P.runs)(I=>Fo(_n(I.text).length,I.style));return C._1>=0&&C._1<b.length?b[C._1]:Kr})())};return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())}g()}if(N.tag==="Nothing"){if(k.tag==="Just"){const P=k._1,G=ma(i)(P)(C._2),R=U=>{const S=Z_(_n(P.line).length)(c)(C._2);return f(S,U,P.y-_*(1-S),C._3,(()=>{const b=St(P.runs)(I=>Fo(_n(I.text).length,I.style));return C._2>=0&&C._2<b.length?b[C._2]:Kr})())};return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())}if(k.tag==="Nothing")return j(st("Return",void 0),ct)}g()}if(C.tag==="DiffDelete"){if(N.tag==="Just"){const P=N._1,G=ma(i)(P)(C._1),R=U=>{const S=l(P,C._1);return f(1-S,U,P.y-_*S,C._2,(()=>{const b=St(P.runs)(I=>Fo(_n(I.text).length,I.style));return C._1>=0&&C._1<b.length?b[C._1]:Kr})())};return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())}if(N.tag==="Nothing")return j(st("Return",void 0),ct);g()}if(C.tag==="DiffInsert"){if(k.tag==="Just"){const P=k._1,G=ma(i)(P)(C._1),R=U=>{const S=Z_(_n(P.line).length)(c)(C._1);return f(S,U,P.y-_*(1-S),C._2,(()=>{const b=St(P.runs)(I=>Fo(_n(I.text).length,I.style));return C._1>=0&&C._1<b.length?b[C._1]:Kr})())};return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())}if(k.tag==="Nothing")return j(st("Return",void 0),ct)}g()})(zk((()=>{if(N.tag==="Nothing")return"";if(N.tag==="Just")return N._1.line;g()})())((()=>{if(k.tag==="Nothing")return"";if(k.tag==="Just")return k._1.line;g()})()))})(Ut(0,Ni(m.length)(J.length)-1|0));return j(p._1,(()=>{if(p._2.tag==="CatNil")return rt("CatCons",x,nt(z,z));if(p._2.tag==="CatCons")return rt("CatCons",p._2._1,nt(p._2._2._1,Jt("Cons",rt("CatCons",x,nt(z,z)),p._2._2._2)));g()})())};return j(d._1,(()=>{if(d._2.tag==="CatNil")return rt("CatCons",h,nt(z,z));if(d._2.tag==="CatCons")return rt("CatCons",d._2._1,nt(d._2._2._1,Jt("Cons",rt("CatCons",h,nt(z,z)),d._2._2._2)));g()})())},Kp=t=>e=>n=>r=>o=>i=>a=>s=>u=>{const c=pi(s),_=s.tag==="PloppingOut"&&n.wobble?{alpha:1,scale:1}:c,f=Fn((()=>{if(u.tag==="Just"){if(u._1.tag==="StaticNodeLabel")return u._1._1===""?i:u._1._1;if(u._1.tag==="RelabelingNode"){const J=u._1._1.progress<.5?u._1._1.oldLabel:u._1._1.newLabel;return J===""?i:J}g()}if(u.tag==="Nothing")return a.label===""?i:a.label;g()})()),l={family:n.fontFamily,size:n.wobble?15:11,weight:n.wobble?800:500},d=l.size*1.2,h=(a.shape==="Cylinder"?(a.y+(a.y+a.h+5-2*Sn(a.h*.075)(a.w*.075)))/2:(a.y+a.y+a.h)/2)-ot(f.length)*d/2+d/2,m=(J,T)=>{const N=Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",J)]})(er(k=>X_(t)(e)(1)(n)(i)(l)(a.x+a.w/2)(h+ot(k._1)*d)(k._2))(Mt(Cn)(Fn(T))));return J>.001?N:j(st("Return",void 0),ct)},p=(J,T)=>er(N=>X_(t)(e)(J)(n)(i)(l)(a.x+a.w/2)(h+ot(N._1)*d)(N._2))(Mt(Cn)(Fn(T))),x=Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",_.alpha*r),pe("GroupTransform",xi,{tx:(a.x+a.w/2)*(1-_.scale),ty:(a.y+a.h/2)*(1-_.scale),sx:_.scale,sy:_.scale}),pe("GroupAlpha",o)]})((()=>{if(u.tag==="Just"&&u._1.tag==="RelabelingNode"&&lr(u._1._1.oldLabel)===lr(u._1._1.newLabel)&&!oe(J=>oe(T=>T.style==="RunHighlight"||T.style==="RunCodeHighlight",dr(J)),Fn(u._1._1.oldLabel))&&oe(J=>oe(T=>T.style==="RunHighlight"||T.style==="RunCodeHighlight",dr(J)),Fn(u._1._1.newLabel)))return p(u._1._1.progress<0?0:u._1._1.progress>1?1:u._1._1.progress,u._1._1.newLabel);if(u.tag==="Just"&&u._1.tag==="RelabelingNode"&&lr(u._1._1.oldLabel)===lr(u._1._1.newLabel)&&oe(J=>oe(T=>T.style==="RunHighlight"||T.style==="RunCodeHighlight",dr(J)),Fn(u._1._1.oldLabel))&&!oe(J=>oe(T=>T.style==="RunHighlight"||T.style==="RunCodeHighlight",dr(J)),Fn(u._1._1.newLabel)))return p(u._1._1.progress<0?1:u._1._1.progress>1?0:1-u._1._1.progress,u._1._1.oldLabel);if(u.tag==="Just"&&u._1.tag==="RelabelingNode"){if(lr(u._1._1.oldLabel)===lr(u._1._1.newLabel)){const J=u._1._1,T=m(J.progress<0?1:J.progress>1?0:1-J.progress,J.oldLabel),N=()=>m(J.progress<0?0:J.progress>1?1:J.progress,J.newLabel);return j(T._1,(()=>{if(T._2.tag==="CatNil")return rt("CatCons",N,nt(z,z));if(T._2.tag==="CatCons")return rt("CatCons",T._2._1,nt(T._2._2._1,Jt("Cons",rt("CatCons",N,nt(z,z)),T._2._2._2)));g()})())}return Uk(t)(e)(n)(i)(a)(l)(u._1._1.oldLabel)(u._1._1.newLabel)(u._1._1.progress)}return er(J=>X_(t)(e)(1)(n)(i)(l)(a.x+a.w/2)(h+ot(J._1)*d)(J._2))(Mt(Cn)(f))})());return o>0&&_.alpha*r>0?x:j(st("Return",void 0),ct)},Yp=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>f=>l=>{const d=Qu({id:c,role:t,geometry:Du("FlatNode",{shape:_.shape,bounds:{x:_.x,y:_.y,w:_.w,h:_.h}}),alpha:i,plan:Fu("FlatNodePlan",{palette:o,label:(()=>{if(l.tag==="Just"){if(l._1.tag==="StaticNodeLabel")return l._1._1===""?c:l._1._1;if(l._1.tag==="RelabelingNode"){const m=l._1._1.progress<.5?l._1._1.oldLabel:l._1._1.newLabel;return m===""?c:m}g()}if(l.tag==="Nothing")return _.label===""?c:_.label;g()})(),labelVisibility:n,inkBoost:r,labelAlpha:s,outlineAlpha:a,arrival:u,animState:f})}),h=()=>{if(n==="LabelsHidden")return j(st("Return",void 0),ct);if(n==="LabelsShown")return Kp(mp)(e)(o)(i)(s)(c)(_)(f)(l);g()};return j(d._1,(()=>{if(d._2.tag==="CatNil")return rt("CatCons",h,nt(z,z));if(d._2.tag==="CatCons")return rt("CatCons",d._2._1,nt(d._2._2._1,Jt("Cons",rt("CatCons",h,nt(z,z)),d._2._2._2)));g()})())},Xp=t=>e=>n=>{const r={...t,nodeFill:t.text,text:t.nodeFill,nodeStroke:t.nodeFill};return er(o=>{const i=me(o._1)(n.nodes),a=me(o._1)(e.nodes),s=a.tag==="Just"&&i.tag==="Just"?Se({path:[],role:dn,layer:y,effects:[pe("GroupAlpha",o._2)]})(Yp(ML)(n.animationTime)(z_)(1)(r)(1)(y)(1)(y)(o._1)((()=>{const u=me(o._1)(n.nodeLabels);if(u.tag==="Nothing")return a._1;if(u.tag==="Just"){if(u._1.tag==="StaticNodeLabel")return{...a._1,label:u._1._1===""?o._1:u._1._1};if(u._1.tag==="RelabelingNode")return{...a._1,label:(()=>{const c=u._1._1.progress<.5?u._1._1.oldLabel:u._1._1.newLabel;return c===""?o._1:c})()}}g()})())(i._1)(me(o._1)(n.nodeLabels))):j(st("Return",void 0),ct);return o._2>0?s:j(st("Return",void 0),ct)})(ln(n.nodeInvert))},Zp=t=>e=>n=>{const r=qo(6)(.55)(Wu(0)(1)((1-t)/.06)),o=t>.94,i=o&&n>1e-4,a=qo(6)(.55)(Wu(0)(1)(t/.06)),s=t<.06,u=s&&e>1e-4,c=o&&n<=1e-4;return{popScale:u?a:i?r:1,flipY:s&&e<=1e-4?a:c?r:1,fadeAlpha:(()=>{if(u){const _=t/.06;return _<0?.55:_>1?1:.55+.44999999999999996*_}if(i){const _=(1-t)/.06;return _<0?.55:_>1?1:.55+.44999999999999996*_}return 1})()}},qu=t=>e=>n=>r=>Se({path:[],role:dn,layer:w("Just",tw),effects:[]})(er((()=>{const o=t.nodes,i=t.edges;return a=>{if(a._2.tag==="Travelling"){if(a._2._1.labels.length!==0){const s=me(a._2._1.target)(o),u=me(a._2._1.source)(o),c=Qr(a._2._1.edge)(i),_=Ap(a._1)(r);if(_.tag==="Just"&&c.tag==="Just"&&u.tag==="Just"&&s.tag==="Just")return Wk(a._1)(e)($u(a._2._1.progress)(a._2._1.holdPre)(a._2._1.holdPost)(St(a._2._1.labels)(U_)))(_._1)({x:_._1.x+_._1.w/2,y:_._1.y+_._1.h/2})(Zp(a._2._1.progress)(a._2._1.holdPre)(a._2._1.holdPost))(H_((()=>{if(a._2._1.direction==="Forward")return c._1;if(a._2._1.direction==="Backward")return re(c._1);g()})())(u._1)(s._1)(a._2._1.progress)(a._2._1.holdPre)(a._2._1.holdPost))}return j(st("Return",void 0),ct)}if(a._2.tag==="Filling"&&a._2._1.labels.length!==0){const s=me(a._2._1.node)(o);if(s.tag==="Just"){const u=s._1,c=qp(xg)(xp)(u)(a._2._1.progress)(a._2._1.labels),_=f=>Sk(a._1)(e)($u(a._2._1.progress)(0)(0)(St(a._2._1.labels)(U_)).line)(u)(f)({x:f.x+f.w/2,y:f.y+f.h/2})(Zp(a._2._1.progress)(0)(0));return j(c._1,(()=>{if(c._2.tag==="CatNil")return rt("CatCons",_,nt(z,z));if(c._2.tag==="CatCons")return rt("CatCons",c._2._1,nt(c._2._2._1,Jt("Cons",rt("CatCons",_,nt(z,z)),c._2._2._2)));g()})())}if(s.tag==="Nothing")return j(st("Return",void 0),ct);g()}return j(st("Return",void 0),ct)}})())(ln(n.tokens))),jp=t=>e=>n=>r=>{const o=Vk(xp)(n)(t)(r);return j(o._1,(()=>{if(o._2.tag==="CatNil")return rt("CatCons",i=>qu(t)(e)(r)(i),nt(z,z));if(o._2.tag==="CatCons")return rt("CatCons",o._2._1,nt(o._2._2._1,Jt("Cons",rt("CatCons",i=>qu(t)(e)(r)(i),nt(z,z)),o._2._2._2)));g()})())},Kk=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>o=>{const i=o.length-1|0,a=i<1?[]:Bt(0,i,o),s=a.length-1|0,u=s>=0&&s<a.length?w("Just",a[s]):y,c=o.length-1|0,_=c>=0&&c<o.length?w("Just",o[c]):y;if(_.tag==="Just"&&u.tag==="Just"){const f=Ge(.78)(1.18)(as(o)+19|0),l=Ge(.4)(.62)(f.prng),d=r.wobble?8.75*l.value:4.375,h=Ge(.4)(.62)(l.prng),m=r.wobble?8.75*h.value:4.375,p=_._1.y-u._1.y,x=_._1.x-u._1.x,J=qe(x*x+p*p),T=p/J,N=-T,k=x/J,C=_._1.x+k*.875,P=_._1.y+T*.875,G=r.wobble?8.75*f.value:8.75,R=C-k*G,U=P-T*G,S=R+N*d,b=U+k*d,I=R-N*m,H=U-k*m,Q=[1,C,P,2,S,b,2,I,H,...mo],q={color:r.arrowFill,width:2,lineJoin:nn,lineCap:Gr};return J<=1e-4?n.pure():r.wobble?e.Bind1().bind(t.strokePath([1,S,b,2,C,P])(q))(()=>t.strokePath([1,I,H,2,C,P])(q)):t.fillPath(Q)({color:r.arrowFill,flat:!0})}return n.pure()}},Yk=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),o=bi(n),i=t.popAlpha,a=Kk(t);return s=>u=>c=>_=>f=>{const l=zd(8)(_),d=c&&(1-f.hi)*Ba(l)<=8.75?1:f.hi;if(d<=f.lo)return n.pure();const h=Cw(l)(f.lo)(d);if(h.length===0)return n.pure();const m={color:s.edge,width:s.wobble?2:.9375,lineJoin:nn,lineCap:Gr},p=s.wobble?Ge(-10)(4)(as(h)).value:0,x=s.wobble?ik(p)(h):h;return r.bind(s.wobble?o(J=>r.bind(t.pushAlpha(J.alpha))(()=>r.bind(t.strokePath(J.path)(m))(()=>i)))((()=>{const J=as(h);return x.length<2?[]:ha(Ek)(J)(!1)(x)})()):t.strokePath(pw(h))(m))(()=>{const J=a(s)(x);return u&&d>=.999?J:n.pure()})}},Xk=t=>{const e=Yk(t);return n=>n.geometry.tag==="FlatRoute"&&n.plan.tag==="FlatEdgePlan"?e(n.plan._1)(n.arrow)(n.settlingAtTarget)(n.geometry._1)(n.visible):t.Monad0().Applicative0().pure()},Zk=t=>e=>{const n=i=>{const a=me(i)(t.nodes);if(a.tag==="Nothing")return!1;if(a.tag==="Just"){const s=a._1;return!oe(u=>0<u._2.length&&u._2[0].x>=s.x&&u._2[0].x<=s.x+s.w&&u._2[0].y>=s.y&&u._2[0].y<=s.y+s.h,ln(t.edges))}g()},r=v(i=>a=>(i*31|0)+Ur(a)|0)(5381)(Bn(e.frameTitle)),o=i=>{const a=me(i)(t.nodes);if(a.tag==="Nothing")return!1;if(a.tag==="Just"){const s=a._1;return!oe(u=>{const c=u._2.length-1|0;return c>=0&&c<u._2.length&&u._2[c].x>=s.x&&u._2[c].x<=s.x+s.w&&u._2[c].y>=s.y&&u._2[c].y<=s.y+s.h},ln(t.edges))}g()};return v(i=>a=>{const s=a._2;return hk(u=>{if(u.tag==="Nothing")return w("Just",s);if(u.tag==="Just")return w("Just",{t:yr(u._1.t)(s.t),angle:s.t>=u._1.t?s.angle:u._1.angle,bigCircle:u._1.bigCircle||s.bigCircle,frameHash:u._1.frameHash});g()})(a._1)(i)})(O)(St(ln(e.tokens))(i=>{if(i._2.tag==="Filling"){const a=i._2._1.node;return[E(a,{t:1,angle:(()=>{const s=ht(u=>(()=>{const c=me(a)(t.nodes),_=u._2.length-1|0;return _>=0&&_<u._2.length&&c.tag==="Just"&&u._2[_].x>=c._1.x&&u._2[_].x<=c._1.x+c._1.w&&u._2[_].y>=c._1.y&&u._2[_].y<=c._1.y+c._1.h})()?w("Just",u._2):y)(ln(t.edges));if(0<s.length){const u=s[0].length-1|0,c=u<1?[]:Bt(0,u,s[0]),_=c.length-1|0;if(_>=0&&_<c.length){const f=s[0].length-1|0;return f>=0&&f<s[0].length?Io(s[0][f].y-c[_].y)(s[0][f].x-c[_].x):0}s[0].length-1|0}return 0})(),bigCircle:n(a)||o(a),frameHash:r})]}if(i._2.tag==="Travelling"){if(i._2._1.progress>=.75)return[E(i._2._1.target,{t:(i._2._1.progress-.75)/.25,angle:(()=>{const a=Qr(i._2._1.edge)(t.edges);if(a.tag==="Just"){const s=a._1.length-1|0,u=s<1?[]:Bt(0,s,a._1),c=u.length-1|0;if(c>=0&&c<u.length){const _=a._1.length-1|0;return _>=0&&_<a._1.length?Io(a._1[_].y-u[c].y)(a._1[_].x-u[c].x):0}return a._1.length-1|0,0}if(a.tag==="Nothing")return 0;g()})(),bigCircle:n(i._2._1.target)||o(i._2._1.target),frameHash:r})];if(i._2._1.progress<.25)return[E(i._2._1.source,{t:i._2._1.progress/.25,angle:(()=>{const a=Qr(i._2._1.edge)(t.edges);if(a.tag==="Just")return 1<a._1.length&&0<a._1.length?Io(a._1[1].y-a._1[0].y)(a._1[1].x-a._1[0].x):0;if(a.tag==="Nothing")return 0;g()})(),bigCircle:n(i._2._1.source)||o(i._2._1.source),frameHash:r})]}return[]}))},jk=t=>v(e=>n=>(e*31|0)+Ur(n)|0)(5381)(Bn(t.frameTitle)),t0=t=>e=>n=>r=>o=>i=>a=>{const s=jk(a),u=Zk(i)(a);return er(c=>{const _=me(c._1)(a.nodes);if(_.tag==="Just")return Yp(yp)(a.animationTime)(e)(r)(o)((()=>{const f=me(c._1)(a.nodeFadeAlpha);if(f.tag==="Nothing")return 1;if(f.tag==="Just")return f._1;g()})())(t(c._1))((()=>{const f=me(c._1)(a.nodeLabelFadeAlpha);if(f.tag==="Nothing")return n*1;if(f.tag==="Just")return n*f._1;g()})())((()=>{const f=me(c._1)(u);return f.tag==="Just"?w("Just",f._1):f.tag==="Nothing"&&pk(c._1)(a.visited)?w("Just",{t:1,angle:0,bigCircle:!1,frameHash:s}):y})())(c._1)((()=>{const f=me(c._1)(a.nodeLabels);if(f.tag==="Nothing")return c._2;if(f.tag==="Just"){if(f._1.tag==="StaticNodeLabel")return{...c._2,label:f._1._1===""?c._1:f._1._1};if(f._1.tag==="RelabelingNode")return{...c._2,label:(()=>{const l=f._1._1.progress<.5?f._1._1.oldLabel:f._1._1.newLabel;return l===""?c._1:l})()}}g()})())(_._1)(me(c._1)(a.nodeLabels));if(_.tag==="Nothing")return j(st("Return",void 0),ct);g()})(ln(i.nodes))},t5=t=>e=>n=>{const r=ut.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=ut.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},e0=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},n0=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},j_=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},r0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},e5=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},t1=(()=>{const t=un.unfoldr(Xn);return e=>t(cn("IterNode",e,Kn))})(),n5=Do(ho)(Qt),r5=t=>e=>{const n=tn(t.angle),r=yn(t.angle);return{a:r,b:n,c:0,d:1,e:-e*r,f:e*n-t.boxHeight/2}},o5=t=>[t.box.ground.a,t.box.ground.b,t.box.ground.c,t.box.ground.d,t.box.top.a,t.box.top.b,t.box.top.c,t.box.top.d],e1=t=>e=>{const n=r=>t5(0)(255)(he(Un(ot(r)*t)));return{r:n(e.r),g:n(e.g),b:n(e.b),a:e.a}},on=t=>e=>n=>r=>({x:(e-n)*yn(t.angle),y:(e+n)*tn(t.angle)-r}),n1=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...St(e._1.tail)(n=>[2,n.x,n.y]),5];g()},i5=t=>e=>n=>{const r=n.id,o=n.np,i=Qu({id:r,role:yp,geometry:Du("IsoSlab",{south:[n.box.ground.d,n.box.ground.c,n.box.top.c,n.box.top.d],east:[n.box.ground.b,n.box.ground.c,n.box.top.c,n.box.top.b],top:[n.box.top.a,n.box.top.b,n.box.top.c,n.box.top.d]}),alpha:1,plan:Fu("IsoNodePlan",{config:t,palette:e})}),a=()=>wi({owner:vo("NodeText",r),text:o.label,spec:{x:o.x+o.w/2,y:0,content:o.label,font:{family:e.fontFamily,size:11,weight:600},color:e.text,align:jo,baseline:jn},bounds:y,plan:la("AffineText",r5(t)(o.y+o.h))});return j(i._1,(()=>{if(i._2.tag==="CatNil")return rt("CatCons",a,nt(z,z));if(i._2.tag==="CatCons")return rt("CatCons",i._2._1,nt(i._2._2._1,Jt("Cons",rt("CatCons",a,nt(z,z)),i._2._2._2)));g()})())},a5=t=>e=>n=>r=>o=>{const i=Oe(Cn,o,Bt(1,o.length,o)),a=i.length-1|0;return Mt(s=>u=>({depth:(u._1.x+u._1.y+u._2.x+u._2.y)/2,draw:wp({id:n,geometry:up("IsoSegments",[[on(t)(u._1.x)(u._1.y)(0),on(t)(u._2.x)(u._2.y)(0)]]),visible:{lo:0,hi:1},arrow:r&&s===a,settlingAtTarget:!1,plan:cp("IsoEdgePlan",{config:t,palette:e})})}))(i)},s5=t=>e=>n=>r=>o=>{const i=(()=>{if(t==="Forward")return o;if(t==="Backward")return re(o);g()})();if(0<i.length){const s=Yo(i)(e0(0)(1)(is(n)(r)(e)));if(s.tag==="Nothing")return i[0];if(s.tag==="Just")return s._1;g()}const a=Yo(i)(e0(0)(1)(is(n)(r)(e)));if(a.tag==="Nothing")return{x:0,y:0};if(a.tag==="Just")return a._1;g()},u5=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...St(e._1.tail)(n=>[2,n.x,n.y])];g()},c5=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{vx:0,vy:0,vw:0,vh:0};if(e.tag==="Just"){const n=v(r=>o=>({minX:n0(r.minX)(o.x),minY:n0(r.minY)(o.y),maxX:j_(r.maxX)(o.x),maxY:j_(r.maxY)(o.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{vx:n.minX-40,vy:n.minY-40,vw:n.maxX-n.minX+80,vh:n.maxY-n.minY+80}}g()},g5=t=>{const e=t.Monad0(),n=e.Bind1();return r=>{if(r.geometry.tag==="IsoSlab"&&r.plan.tag==="IsoNodePlan"){const o=r.geometry._1,i=r.plan._1.palette,a=(s,u)=>t.fillStrokePath(n1(s))({color:u,flat:!0})({color:i.nodeStroke,width:1,lineJoin:nn,lineCap:zn});return n.bind(a(o.south,e1(.66)(i.nodeFill)))(()=>n.bind(a(o.east,e1(.82)(i.nodeFill)))(()=>a(o.top,i.nodeFill)))}return e.Applicative0().pure()}},_5=t=>{const e=t.Monad0(),n=e.Bind1();return r=>{if(r.geometry.tag==="IsoCube"&&r.plan.tag==="IsoTokenPlan"){const o=r.geometry._1,i=r.plan._1.palette,a=(s,u)=>t.fillStrokePath(n1(s))({color:e1(u)(i.tokenOutsideFill),flat:!0})({color:i.tokenOutsideStroke,width:1,lineJoin:nn,lineCap:zn});return n.bind(a(o.south,.66))(()=>n.bind(a(o.east,.82))(()=>a(o.top,1)))}return e.Applicative0().pure()}},f5={angle:.5235987755982988,boxHeight:26,transparentBg:!0},d5=t=>e=>n=>{const r=r0(t)(n.nodeLabels);if(r.tag==="Just"){if(r._1.tag==="StaticNodeLabel")return r._1._1===""?t:r._1._1;if(r._1.tag==="RelabelingNode"){const o=r._1._1.progress<.5?r._1._1.oldLabel:r._1._1.newLabel;return o===""?t:o}g()}if(r.tag==="Nothing")return e.label===""?t:e.label;g()},l5=t=>e=>n=>{const r=n.x-5.5,o=n.x+5.5,i=n.y-5.5,a=n.y+5.5,s=e+11,u=on(t)(o)(i)(s),c=on(t)(o)(a)(s),_=on(t)(r)(a)(s),f=on(t)(o)(a)(e);return{south:[on(t)(r)(a)(e),f,c,_],east:[on(t)(o)(i)(e),f,c,u],top:[on(t)(r)(i)(s),u,c,_]}},h5=t=>e=>n=>r=>{const o=r._1,i=(a,s)=>({depth:s.x+s.y,draw:Tp({id:o,pass:hp,geometry:_p("IsoCube",l5(t)(a)(s)),position:s,plan:dp("IsoTokenPlan",{config:t,palette:e,baseZ:a})})});if(r._2.tag==="Travelling"){const a=e5(r._2._1.edge)(n.edges);return a.tag==="Just"?w("Just",i(0,s5(r._2._1.direction)(r._2._1.progress)(r._2._1.holdPre)(r._2._1.holdPost)(a._1))):y}if(r._2.tag==="Filling"){const a=r0(r._2._1.node)(n.nodes);if(a.tag==="Just")return w("Just",i(t.boxHeight,{x:a._1.x+a._1.w/2,y:a._1.y+a._1.h/2}))}return y},p5=t=>e=>{const n=e.y+e.h,r=e.x+e.w;return{ground:{a:on(t)(e.x)(e.y)(0),b:on(t)(r)(e.y)(0),c:on(t)(r)(n)(0),d:on(t)(e.x)(n)(0)},top:{a:on(t)(e.x)(e.y)(t.boxHeight),b:on(t)(r)(e.y)(t.boxHeight),c:on(t)(r)(n)(t.boxHeight),d:on(t)(e.x)(n)(t.boxHeight)},depth:(e.x+r)/2+(e.y+n)/2}},o0=t=>e=>Y(n=>({id:n._1,np:n._2,box:p5(t)(n._2)}))(t1(e.nodes)),m5=t=>e=>[...St(o0(t)(e))(o5),...(()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._4,n(r._6,o)));g()};return St(It(ge.foldr,n(e.edges,z)))(Y(r=>on(t)(r.x)(r.y)(0)))})()],y5=t=>e=>n=>Y(r=>({...r,np:{...r.np,label:d5(r.id)(r.np)(n)}}))(o0(t)(e)),x5=t=>e=>n=>r=>{const o=q_(e),i=[...St(t1(n.edges))(u=>a5(t)(o)(u._1)((()=>{const c=cr("conn:")(u._1);if(c.tag==="Just")return!1;if(c.tag==="Nothing")return!0;g()})())(u._2)),...Y(u=>({depth:u.box.depth,draw:i5(t)(o)(u)}))(y5(t)(n)(r)),...ht(h5(t)(o)(n))(t1(r.tokens))],a=Jp({viewport:c5(m5(t)(n)),clear:w("Just",t.transparentBg?o.bgTransparent:o.bg),dots:y}),s=()=>n5(u=>u.draw)(Pt(u=>c=>at.compare(u.depth)(c.depth))(i));return j(a._1,(()=>{if(a._2.tag==="CatNil")return rt("CatCons",s,nt(z,z));if(a._2.tag==="CatCons")return rt("CatCons",a._2._1,nt(a._2._2._1,Jt("Cons",rt("CatCons",s,nt(z,z)),a._2._2._2)));g()})())},J5=t=>{const e=t.to.y-t.from.y,n=t.to.x-t.from.x,r=j_(1e-4)(qe(n*n+e*e)),o=e/r,i=n/r,a=t.to.y-o*7,s=t.to.x-i*7;return n1([t.to,{x:s-o*3,y:a+i*3},{x:s+o*3,y:a-i*3}])},w5=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Do(n)(Qt);return o=>{if(o.geometry.tag==="IsoSegments"&&o.plan.tag==="IsoEdgePlan"){const i=o.plan._1.palette,a=o.geometry._1;return e.Bind1().bind(r(s=>t.strokePath(u5(s))({color:i.edge,width:1.5,lineJoin:nn,lineCap:Gr}))(a))(()=>{const s=a.length-1|0;if(s>=0&&s<a.length){const c=a[s],_=c.length-1|0,f=_<1?[]:Bt(0,_,c),l=f.length-1|0;if(l>=0&&l<f.length){const h=a.length-1|0,m=(()=>{if(h>=0&&h<a.length){const p=a[h],x=p.length-1|0;if(x>=0&&x<p.length)return t.fillPath(J5({from:f[l],to:p[x]}))({color:i.arrowFill,flat:!0})}return n.pure()})();return o.arrow?m:n.pure()}a.length-1|0;const d=n.pure();return o.arrow?d:n.pure()}a.length-1|0;const u=n.pure();return o.arrow?u:n.pure()})}return n.pure()}},i0=t=>t,Ue=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Co=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},T5=i0("Split"),N5=i0("Fall"),hn=t=>e=>n=>r=>{const o=n?0:1,i=1-xe(r.x-o)*tn(e)*1.1,a=xe(i)<.06?i<0?-.06:.06:i,s=t.y+t.h/2,u=t.x+t.w/2;return{x:u+(t.x+(o+(r.x-o)*yn(e))*t.w-u)/a,y:s+(t.y+r.y*t.h-s)/a}},v5=t=>e=>n=>{const r=hn(t)(e)(n)({x:.5,y:.5}),o=t.x+.5*t.w,i=hn(t)(e)(n)({x:.5,y:0}),a=n?0:1,s=t.x+a*t.w,u=hn(t)(e)(n)({x:a,y:0}),c=hn(t)(e)(n)({x:a,y:1}),_=(c.y-u.y)/Ue(1e-6)(t.h),f=(c.x-u.x)/Ue(1e-6)(t.h),l=o-s,d=(i.y-u.y)/(xe(l)<1e-6?l<0?-1e-6:1e-6:l),h=t.y+t.h/2,m=t.x+t.w/2,p=o-s,x=(i.x-u.x)/(xe(p)<1e-6?p<0?-1e-6:1e-6:p);return{a:x,b:d,c:f,d:_,e:r.x-x*m-f*h,f:r.y-d*m-_*h}},r1=t=>{const e=Ue(0)(t)*3.05,n=yn(e);return{expansion:1+tn(e)*.16,verticalScale:xe(n)<.06?n<0?-.06:.06:n}},Lo=t=>e=>n=>{const r=r1(e),o=t.x+t.w/2,i=t.y+t.h;return{x:o+(t.x+n.x*t.w-o)*r.expansion,y:i+(t.y+n.y*t.h-i)*r.verticalScale}},b5=t=>e=>{const n=r1(e),r=Lo(t)(e)({x:.5,y:.5});return{a:n.expansion,b:0,c:0,d:n.verticalScale,e:r.x-n.expansion*(t.x+t.w/2),f:r.y-n.verticalScale*(t.y+t.h/2)}},C5=t=>Ue(0)(t.w)/Ue(1e-6)(Ue(0)(t.h))>=4?N5:T5,L5=t=>e=>n=>{const r=n/Ue(1e-6)(t.h),o=n/Ue(1e-6)(t.w),i=(s,u,c)=>{const _=Lo(t)(e)(s),f=Lo(t)(e)(u),l=Lo(t)(e)(c);return[4,_.x,_.y,f.x,f.y,l.x,l.y]},a=[...(()=>{const s=Lo(t)(e)({x:o,y:0});return[1,s.x,s.y]})(),...i({x:o*.44771525016920644,y:0},{x:0,y:r*.44771525016920644},{x:0,y:r}),...(()=>{const s=Lo(t)(e)({x:0,y:1-r});return[2,s.x,s.y]})(),...i({x:0,y:1-r*.44771525016920644},{x:o*.44771525016920644,y:1},{x:o,y:1}),...(()=>{const s=Lo(t)(e)({x:1-o,y:1});return[2,s.x,s.y]})(),...i({x:1-o*.44771525016920644,y:1},{x:1,y:1-r*.44771525016920644},{x:1,y:1-r}),...(()=>{const s=Lo(t)(e)({x:1,y:r});return[2,s.x,s.y]})(),...i({x:1,y:r*.44771525016920644},{x:1-o*.44771525016920644,y:0},{x:1-o,y:0}),...mo];return{face:a,labelAffine:b5(t)(e),labelVisible:r1(e).verticalScale>0,outline:a}},o1=t=>qo(10.8)(.48)(Co(1)(Ue(0)(t)))/qo(10.8)(.48)(1),k5=t=>e=>{const n=o1(Co(1)(Ue(0)((1-Co(1)(Ue(0)(t))-.48)/.5))*.48)/o1(.48);if(e<0){const r=Co(1)(Ue(0)((t-.25)/.28));return o1(r*r*r)}return Co(1)(xe(1-n))},S5=t=>k5((()=>{if(t.tag==="Closed")return 0;if(t.tag==="Opening")return t._1;if(t.tag==="Open")return 1;if(t.tag==="Closing")return 1-t._1;g()})())(t.tag==="Opening"?-1:t.tag==="Closing"?1:0),a0=t=>e=>n=>{const r=Co(1)(Ue(0)((n-t)/Ue(1e-6)(e-t)));return r*r*(3-2*r)},s0=t=>e=>n=>r=>{const o=n/Ue(1e-6)(t.h),i=n/Ue(1e-6)(t.w),a=a0(.08)(.2)(e),s=o*a,u=i*a,c=Ue(0)(e)*1.91986,_=(f,l,d)=>{const h=hn(t)(c)(r)(r?f:{...f,x:1-f.x}),m=hn(t)(c)(r)(r?l:{...l,x:1-l.x}),p=hn(t)(c)(r)(r?d:{...d,x:1-d.x});return[4,h.x,h.y,m.x,m.y,p.x,p.y]};return{leaf:{face:[...(()=>{const f={x:i,y:0},l=hn(t)(c)(r)(r?f:{...f,x:1-f.x});return[1,l.x,l.y]})(),..._({x:i*.44771525016920644,y:0},{x:0,y:o*.44771525016920644},{x:0,y:o}),...(()=>{const f={x:0,y:1-o},l=hn(t)(c)(r)(r?f:{...f,x:1});return[2,l.x,l.y]})(),..._({x:0,y:1-o*.44771525016920644},{x:i*.44771525016920644,y:1},{x:i,y:1}),...(()=>{const f={x:.5-u,y:1},l=hn(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:.5-u*.44771525016920644,y:1},{x:.5,y:1-s*.44771525016920644},{x:.5,y:1-s}),...(()=>{const f={x:.5,y:s},l=hn(t)(c)(r)(r?f:{...f,x:.5});return[2,l.x,l.y]})(),..._({x:.5,y:s*.44771525016920644},{x:.5-u*.44771525016920644,y:0},{x:.5-u,y:0}),...mo],labelAffine:v5(t)(c)(r),labelVisible:yn(c)>0,outline:[...(()=>{const f={x:.5,y:s},l=hn(t)(c)(r)(r?f:{...f,x:.5});return[1,l.x,l.y]})(),..._({x:.5,y:s*.44771525016920644},{x:.5-u*.44771525016920644,y:0},{x:.5-u,y:0}),...(()=>{const f={x:i,y:0},l=hn(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:i*.44771525016920644,y:0},{x:0,y:o*.44771525016920644},{x:0,y:o}),...(()=>{const f={x:0,y:1-o},l=hn(t)(c)(r)(r?f:{...f,x:1});return[2,l.x,l.y]})(),..._({x:0,y:1-o*.44771525016920644},{x:i*.44771525016920644,y:1},{x:i,y:1}),...(()=>{const f={x:.5-u,y:1},l=hn(t)(c)(r)(r?f:{...f,x:1-f.x});return[2,l.x,l.y]})(),..._({x:.5-u*.44771525016920644,y:1},{x:.5,y:1-s*.44771525016920644},{x:.5,y:1-s})]},seam:[...(()=>{const f={x:.5,y:s},l=hn(t)(c)(r)(r?f:{...f,x:.5});return[1,l.x,l.y]})(),...(()=>{const f={x:.5,y:1-s},l=hn(t)(c)(r)(r?f:{...f,x:.5});return[2,l.x,l.y]})()]}},E5=t=>e=>n=>{const r=a0(.08)(.26)(e),o=s0(t)(e)(n)(!1),i=s0(t)(e)(n)(!0);return{leaves:[i.leaf,o.leaf],seams:[{alpha:r,path:i.seam},{alpha:r,path:o.seam}]}},P5=t=>e=>n=>Ue(0)(Co(t)(Co(Ue(0)(e)/2)(Ue(0)(n)/2))),G5=t=>e=>n=>{const r=P5(n)(e.w)(e.h),o=S5(t),i=C5(e);if(i==="Fall")return{leaves:[L5(e)(o)(r)],seams:[]};if(i==="Split")return E5(e)(o)(r);g()},u0=(t,e)=>({tag:t,_1:e}),i1=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},A5=t=>e=>n=>{const r=at.compare(t)(n),o=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),i=at.compare(e)(o);if(i==="LT"||i==="EQ")return e;if(i==="GT")return o;g()},ya=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},a1=Di(ho)(Qt),B5=u0("ResolvedLabels"),cs=t=>e=>{const n=i1(1)(e.rootLayout.bounds.w),r=e.portalState.tag==="Closed"&&e.levels.length===1,o=gr(e.rootLayout)(e.camera),i=r?1:A5(0)(1)(o.w/n),a=t.padding*i*i*(()=>{if(r)return 1;if(e.portalState.tag==="Opening"||e.portalState.tag==="Closing"){if(e.portalState.tag==="Closed")return 1;if(e.portalState.tag==="Opening")return 1-e.portalState._1;if(e.portalState.tag==="Open")return 0;if(e.portalState.tag==="Closing")return 1-(1-e.portalState._1);g()}return 0})();return(()=>{if(t.outputAspect.tag==="Nothing")return JJ;if(t.outputAspect.tag==="Just")return ad(t.outputAspect._1);g()})()({vx:o.x-a,vy:o.y-a,vw:o.w+2*a,vh:o.h+2*a})},R5=t=>e=>{if(e.tag==="Nothing")return[];if(e.tag==="Just"){const n=ya(e._1)(t.segment.layout.nodes);if(n.tag==="Nothing")return[];if(n.tag==="Just"){const r=n._1.x*t.segment.placement.scale+t.segment.placement.tx,o=n._1.y*t.segment.placement.scale+t.segment.placement.ty,i=n._1.w*t.segment.placement.scale,a=n._1.h*t.segment.placement.scale;return[1,r,o,2,r+i,o,2,r+i,o+a,2,r,o+a,5]}}g()},s1=t=>e=>{const n=pJ(e.segment.placement)({x:t.vx,y:t.vy,w:t.vw,h:t.vh});return{vx:n.x,vy:n.y,vw:n.w,vh:n.h}},u1=t=>e=>t===""?j(st("Return",void 0),ct):wi({owner:zL,text:t,spec:{x:e.vx+6,y:e.vy+6,content:t,font:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:9,weight:600},color:{r:180,g:180,b:180,a:255},align:po,baseline:KJ},bounds:y,plan:mp}),D5=t=>e=>n=>r=>o=>i=>a=>s=>{const u=$_(i),c=q_(t.theme),_=(()=>{if(s.tag==="ResolvedLabels")return jp(u)(c)(o)(a);if(s.tag==="SpringLabels")return qu(u)(c)(a)($p(o)(s._1));g()})(),f=Jp({viewport:o,clear:w("Just",t.transparentBg?c.bgTransparent:c.bg),dots:y}),l=()=>{const d=Se({path:[],role:dn,layer:y,effects:n<1?[pe("GroupAlpha",n)]:[]})((()=>{const h=Op(u)(c)(i)(a),m=()=>{const p=Wp(r)(c)(t.halftoneShadows)(i)(a),x=()=>{const J=t0(N=>r.tag!=="Nothing"&&r.tag==="Just"&&r._1===N?w("Just",0):y)(z_)(1)(1)(c)(i)(a),T=()=>{const N=Xp(c)(i)(a),k=()=>{const C=Y_(u)(c)(o)(a),P=()=>{const G=Qp(u)(ow)(c)(a),R=()=>{const U=()=>{const S=Rk(c)(i)(a);return a.staticKind!=="Animated"?S:j(st("Return",void 0),ct)};return j(_._1,(()=>{if(_._2.tag==="CatNil")return rt("CatCons",U,nt(z,z));if(_._2.tag==="CatCons")return rt("CatCons",_._2._1,nt(_._2._2._1,Jt("Cons",rt("CatCons",U,nt(z,z)),_._2._2._2)));g()})())};return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())};return j(C._1,(()=>{if(C._2.tag==="CatNil")return rt("CatCons",P,nt(z,z));if(C._2.tag==="CatCons")return rt("CatCons",C._2._1,nt(C._2._2._1,Jt("Cons",rt("CatCons",P,nt(z,z)),C._2._2._2)));g()})())};return j(N._1,(()=>{if(N._2.tag==="CatNil")return rt("CatCons",k,nt(z,z));if(N._2.tag==="CatCons")return rt("CatCons",N._2._1,nt(N._2._2._1,Jt("Cons",rt("CatCons",k,nt(z,z)),N._2._2._2)));g()})())};return j(J._1,(()=>{if(J._2.tag==="CatNil")return rt("CatCons",T,nt(z,z));if(J._2.tag==="CatCons")return rt("CatCons",J._2._1,nt(J._2._2._1,Jt("Cons",rt("CatCons",T,nt(z,z)),J._2._2._2)));g()})())};return j(p._1,(()=>{if(p._2.tag==="CatNil")return rt("CatCons",x,nt(z,z));if(p._2.tag==="CatCons")return rt("CatCons",p._2._1,nt(p._2._2._1,Jt("Cons",rt("CatCons",x,nt(z,z)),p._2._2._2)));g()})())};return j(h._1,(()=>{if(h._2.tag==="CatNil")return rt("CatCons",m,nt(z,z));if(h._2.tag==="CatCons")return rt("CatCons",h._2._1,nt(h._2._2._1,Jt("Cons",rt("CatCons",m,nt(z,z)),h._2._2._2)));g()})())})());return n>0?j(d._1,(()=>{if(d._2.tag==="CatNil")return rt("CatCons",()=>u1(t.watermark)(o),nt(z,z));if(d._2.tag==="CatCons")return rt("CatCons",d._2._1,nt(d._2._2._1,Jt("Cons",rt("CatCons",()=>u1(t.watermark)(o),nt(z,z)),d._2._2._2)));g()})()):j(st("Return",void 0),rt("CatCons",()=>u1(t.watermark)(o),nt(z,z)))};return j(f._1,(()=>{if(f._2.tag==="CatNil")return rt("CatCons",l,nt(z,z));if(f._2.tag==="CatCons")return rt("CatCons",f._2._1,nt(f._2._2._1,Jt("Cons",rt("CatCons",l,nt(z,z)),f._2._2._2)));g()})())},F5=t=>e=>n=>r=>o=>i=>{const a=i.segment.path.length-1|0,s=a>=0&&a<i.segment.path.length?w("Just",i.segment.path[a]):y;if(s.tag==="Nothing")return j(st("Return",void 0),ct);if(s.tag==="Just"){const u=ya(s._1)(o.segment.layout.nodes);if(u.tag==="Nothing")return j(st("Return",void 0),ct);if(u.tag==="Just"){const c=u._1,_=ya(s._1)(o.state.nodes),f=(()=>{if(_.tag==="Nothing")return Xg;if(_.tag==="Just")return _._1;g()})(),l={color:t.nodeStroke,width:t.wobble?2:1.25,lineJoin:nn,lineCap:Gr},d={...l,width:1.25},h=G5(r)({x:c.x,y:c.y,w:c.w,h:c.h})(7);return Se({path:o.segment.path,role:o.role,layer:y,effects:[pe("GroupAlpha",o.bgAlpha),pe("GroupTransform",xi,n)]})((()=>{const m=Qu({id:s._1,role:QL,geometry:Du("FlatNode",{shape:c.shape,bounds:{x:c.x,y:c.y+5,w:c.w,h:c.h}}),alpha:1,plan:Fu("FlatNodePlan",{palette:t,label:c.label,labelVisibility:Iu,inkBoost:e?1:0,labelAlpha:0,outlineAlpha:w("Just",1),arrival:y,animState:f})}),p=()=>{const x=Ji(mi({path:yo(c),fill:y,stroke:w("Just",l)})),J=()=>{const T=a1(h.leaves)(k=>{const C=Se({path:o.segment.path,role:o.role,layer:y,effects:[pe("GroupAlpha",1)]})(Ji(mi({path:k.face,fill:w("Just",{color:t.nodeFill,flat:!1}),stroke:y}))),P=()=>{const G=Se({path:o.segment.path,role:o.role,layer:y,effects:[pe("GroupClip",k.face,ti)]})(Kp(la("AffineText",k.labelAffine))(o.state.animationTime)(t)(1)(1)(s._1)(c)(f)(ya(s._1)(o.state.nodeLabels)));return k.labelVisible?G:j(st("Return",void 0),ct)};return j(C._1,(()=>{if((()=>{if(C._2.tag==="CatNil"||C._2.tag==="CatCons")return!1;g()})())return rt("CatCons",P,nt(z,z));if((()=>{if(C._2.tag==="CatNil"||C._2.tag==="CatCons")return!0;g()})())return rt("CatCons",(()=>{if(C._2.tag==="CatNil")return()=>Ji(mi({path:k.outline,fill:y,stroke:w("Just",l)}));if(C._2.tag==="CatCons")return C._2._1;g()})(),nt((()=>{if(C._2.tag==="CatNil")return z;if(C._2.tag==="CatCons")return C._2._2._1;g()})(),Jt("Cons",rt("CatCons",P,nt(z,z)),(()=>{if(C._2.tag==="CatNil")return z;if(C._2.tag==="CatCons")return Jt("Cons",rt("CatCons",()=>Ji(mi({path:k.outline,fill:y,stroke:w("Just",l)})),nt(z,z)),C._2._2._2);g()})())));g()})())}),N=()=>a1(h.seams)(k=>{const C=Se({path:o.segment.path,role:o.role,layer:y,effects:[pe("GroupAlpha",k.alpha)]})(Ji(mi({path:k.path,fill:y,stroke:w("Just",d)})));return k.alpha>0?C:j(st("Return",void 0),ct)});return j(T._1,(()=>{if(T._2.tag==="CatNil")return rt("CatCons",N,nt(z,z));if(T._2.tag==="CatCons")return rt("CatCons",T._2._1,nt(T._2._2._1,Jt("Cons",rt("CatCons",N,nt(z,z)),T._2._2._2)));g()})())};return j(x._1,(()=>{if(x._2.tag==="CatNil")return rt("CatCons",J,nt(z,z));if(x._2.tag==="CatCons")return rt("CatCons",x._2._1,nt(x._2._2._1,Jt("Cons",rt("CatCons",J,nt(z,z)),x._2._2._2)));g()})())};return j(m._1,(()=>{if(m._2.tag==="CatNil")return rt("CatCons",p,nt(z,z));if(m._2.tag==="CatCons")return rt("CatCons",m._2._1,nt(m._2._2._1,Jt("Cons",rt("CatCons",p,nt(z,z)),m._2._2._2)));g()})())})())}}g()},c1=t=>e=>n=>r=>a1(r.minis)(o=>{const i=c0(t)(e)(n)(ll)(O)(y)(r)(o);return(()=>{const a=o.segment.path.length-1|0;return o.bgAlpha>0&&a>=0&&a<o.segment.path.length&&(()=>{const s=ya(o.segment.path[a])(r.state.nodes);if(s.tag==="Just")return s._1.tag==="Hidden"?!1:s._1.tag!=="PloppingOut";if(s.tag==="Nothing")return!1;g()})()})()?i:j(st("Return",void 0),ct)}),c0=t=>e=>n=>r=>o=>i=>a=>s=>{const u=[1,e.viewport.vx,e.viewport.vy,2,e.viewport.vx+e.viewport.vw,e.viewport.vy,2,e.viewport.vx+e.viewport.vw,e.viewport.vy+e.viewport.vh,2,e.viewport.vx,e.viewport.vy+e.viewport.vh,5],c=s.state,_={tx:a.segment.placement.tx,ty:a.segment.placement.ty,sx:a.segment.placement.scale,sy:a.segment.placement.scale},f=q_(t.theme),l=s.segment.layout,d={vx:l.bounds.x-1e3,vy:l.bounds.y-1e3,vw:l.bounds.w+2e3,vh:l.bounds.h+2e3},h=$_(l),m=s.segment.path.length-1|0,p=m>=0&&m<s.segment.path.length?ya(s.segment.path[m])(a.segment.layout.nodes):y,x=bk(5)(11)(s.segment.placement.scale*n),J=x>0?z_:Iu,T=s1(e.viewport)(s),N=(()=>{if(J==="LabelsHidden")return j(st("Return",void 0),ct);if(J==="LabelsShown")return Se({path:s.segment.path,role:s.role,layer:y,effects:x<1?[pe("GroupAlpha",x)]:[]})(o.tag==="Leaf"?jp(h)(f)(T)(c):qu(h)(f)(c)($p(T)(o)));g()})(),k={tx:s.segment.placement.tx,ty:s.segment.placement.ty,sx:s.segment.placement.scale,sy:s.segment.placement.scale},C=Se({path:s.segment.path,role:s.role,layer:y,effects:[pe("GroupAlpha",s.bgAlpha)]})((()=>{const G=Se({path:s.segment.path,role:s.role,layer:y,effects:[pe("GroupClip",(()=>{if(wl(r)>=.52)return u;const U=R5(a)((()=>{const S=s.segment.path.length-1|0;return S>=0&&S<s.segment.path.length?w("Just",s.segment.path[S]):y})());return U.length===0?u:U})(),ti)]})((()=>{const U=(()=>{if(p.tag==="Just")return Se({path:a.segment.path,role:a.role,layer:y,effects:[pe("GroupTransform",xi,_)]})(Ji(mi({path:yo({...p._1,x:p._1.x+1,y:p._1.y+1,w:p._1.w-2,h:p._1.h-2}),fill:w("Just",{color:f.bg,flat:!0}),stroke:y})));if(p.tag==="Nothing")return j(st("Return",void 0),ct);g()})(),S=(a.role==="Active"||a.role==="FlyThrough")&&!t.transparentBg?U:j(st("Return",void 0),ct),b=()=>{const I=Se({path:s.segment.path,role:s.role,layer:y,effects:[pe("GroupTransform",xi,k)]})((()=>{const Q=Op(h)(f)(l)(c),q=()=>{const $=Wp(i)(f)(t.halftoneShadows)(l)(c),A=()=>{const F=t0(W=>i.tag!=="Nothing"&&i.tag==="Just"&&i._1===W?w("Just",0):y)(J)(x)(1)(f)(l)(c),M=()=>{const W=Xp(f)(l)(c);return j(W._1,(()=>{if(W._2.tag==="CatNil")return rt("CatCons",()=>Y_(h)(f)(d)(c),nt(z,z));if(W._2.tag==="CatCons")return rt("CatCons",W._2._1,nt(W._2._2._1,Jt("Cons",rt("CatCons",()=>Y_(h)(f)(d)(c),nt(z,z)),W._2._2._2)));g()})())};return j(F._1,(()=>{if(F._2.tag==="CatNil")return rt("CatCons",M,nt(z,z));if(F._2.tag==="CatCons")return rt("CatCons",F._2._1,nt(F._2._2._1,Jt("Cons",rt("CatCons",M,nt(z,z)),F._2._2._2)));g()})())};return j($._1,(()=>{if($._2.tag==="CatNil")return rt("CatCons",A,nt(z,z));if($._2.tag==="CatCons")return rt("CatCons",$._2._1,nt($._2._2._1,Jt("Cons",rt("CatCons",A,nt(z,z)),$._2._2._2)));g()})())};return j(Q._1,(()=>{if(Q._2.tag==="CatNil")return rt("CatCons",q,nt(z,z));if(Q._2.tag==="CatCons")return rt("CatCons",Q._2._1,nt(Q._2._2._1,Jt("Cons",rt("CatCons",q,nt(z,z)),Q._2._2._2)));g()})())})()),H=()=>{const Q=Se({path:s.segment.path,role:s.role,layer:y,effects:[pe("GroupTransform",FL,k)]})(Qp(h)(iw)(f)(c));return j(Q._1,(()=>{if(Q._2.tag==="CatNil")return rt("CatCons",()=>c1(t)(e)(n)(s),nt(z,z));if(Q._2.tag==="CatCons")return rt("CatCons",Q._2._1,nt(Q._2._2._1,Jt("Cons",rt("CatCons",()=>c1(t)(e)(n)(s),nt(z,z)),Q._2._2._2)));g()})())};return j(I._1,(()=>{if(I._2.tag==="CatNil")return rt("CatCons",H,nt(z,z));if(I._2.tag==="CatCons")return rt("CatCons",I._2._1,nt(I._2._2._1,Jt("Cons",rt("CatCons",H,nt(z,z)),I._2._2._2)));g()})())};return j(S._1,(()=>{if(S._2.tag==="CatNil")return rt("CatCons",b,nt(z,z));if(S._2.tag==="CatCons")return rt("CatCons",S._2._1,nt(S._2._2._1,Jt("Cons",rt("CatCons",b,nt(z,z)),S._2._2._2)));g()})())})()),R=()=>Se({path:s.segment.path,role:s.role,layer:y,effects:[pe("GroupTransform",xi,k)]})(N);return j(G._1,(()=>{if(G._2.tag==="CatNil")return rt("CatCons",R,nt(z,z));if(G._2.tag==="CatCons")return rt("CatCons",G._2._1,nt(G._2._2._1,Jt("Cons",rt("CatCons",R,nt(z,z)),G._2._2._2)));g()})())})()),P=()=>{const G=F5(f)(t.halftoneShadows)(_)(r)(a)(s);return a.role==="FlyThrough"&&(r.tag==="Opening"||r.tag==="Closing")?G:j(st("Return",void 0),ct)};return j(C._1,(()=>{if(C._2.tag==="CatNil")return rt("CatCons",P,nt(z,z));if(C._2.tag==="CatCons")return rt("CatCons",C._2._1,nt(C._2._2._1,Jt("Cons",rt("CatCons",P,nt(z,z)),C._2._2._2)));g()})())},z5=t=>e=>n=>{if(t.theme==="Isometric")return x5({...f5,transparentBg:t.transparentBg})(t.theme)(xl(n).segment.layout)(xl(n).state);const r=cs(t)(n),o={tileScale:n.hasDives?r.vw/i1(1)(n.rootLayout.bounds.w):1,viewport:r},i=s=>u=>{if(u.length===0)return j(st("Return",void 0),ct);const c=Ft(_=>y,_=>f=>w("Just",{head:_,tail:f}),u);if(c.tag==="Nothing")return j(st("Return",void 0),ct);if(c.tag==="Just"){const _=c0(t)(o)(n.camera.zoom)(n.portalState)(c._1.head.role==="Active"?e:O)((()=>{if(c._1.head.role==="FlyThrough"&&0<c._1.tail.length){const f=c._1.tail[0].segment.path.length-1|0;if(f>=0&&f<c._1.tail[0].segment.path.length)return w("Just",c._1.tail[0].segment.path[f])}return y})())(s)(c._1.head);return c._1.head.role==="Active"||c._1.head.role==="FlyThrough"?j(_._1,(()=>{if(_._2.tag==="CatNil")return rt("CatCons",()=>i(c._1.head)(c._1.tail),nt(z,z));if(_._2.tag==="CatCons")return rt("CatCons",_._2._1,nt(_._2._2._1,Jt("Cons",rt("CatCons",()=>i(c._1.head)(c._1.tail),nt(z,z)),_._2._2._2)));g()})()):j(st("Return",void 0),rt("CatCons",()=>i(c._1.head)(c._1.tail),nt(z,z)))}g()},a=Ft(s=>y,s=>u=>w("Just",{head:s,tail:u}),n.levels);if(a.tag==="Nothing")return j(st("Return",void 0),ct);if(a.tag==="Just"){const s=a._1.tail,u=a._1.head,c=D5(t)(n.hasDives?r.vw/i1(1)(n.rootLayout.bounds.w):1)(u.role==="Active"||u.role==="FlyThrough"?u.bgAlpha:0)((()=>{if(u.role==="FlyThrough"&&0<s.length){const f=s[0].segment.path.length-1|0;if(f>=0&&f<s[0].segment.path.length)return w("Just",s[0].segment.path[f])}return y})())(r)(u.segment.layout)(u.state)(s.length===0&&e.tag!=="Leaf"?u0("SpringLabels",e):B5),_=()=>{const f=c1(t)(o)(n.camera.zoom)(u);return u.role==="Active"||u.role==="FlyThrough"?j(f._1,(()=>{if(f._2.tag==="CatNil")return rt("CatCons",()=>i(u)(s),nt(z,z));if(f._2.tag==="CatCons")return rt("CatCons",f._2._1,nt(f._2._2._1,Jt("Cons",rt("CatCons",()=>i(u)(s),nt(z,z)),f._2._2._2)));g()})()):j(st("Return",void 0),rt("CatCons",()=>i(u)(s),nt(z,z)))};return j(c._1,(()=>{if(c._2.tag==="CatNil")return rt("CatCons",_,nt(z,z));if(c._2.tag==="CatCons")return rt("CatCons",c._2._1,nt(c._2._2._1,Jt("Cons",rt("CatCons",_,nt(z,z)),c._2._2._2)));g()})())}g()},g1=t=>e=>n=>HL({viewport:cs(t)(n),camera:n.camera})(z5(t)(e)(n)),I5=t=>e=>{if(e.fill.tag==="Just"){if(e.stroke.tag==="Just")return t.fillStrokePath(e.path)(e.fill._1)(e.stroke._1);if(e.stroke.tag==="Nothing")return t.fillPath(e.path)(e.fill._1);g()}if(e.fill.tag==="Nothing"){if(e.stroke.tag==="Just")return t.strokePath(e.path)(e.stroke._1);if(e.stroke.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()},Q5=t=>e=>I5(t)(e._1),M5=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Do(n)(Qt),o=t.popTransform,i=t.popBakedTransform,a=(()=>{const u=t.popClip,c=t.popAlpha,_=t.popBlend,f=t.popBlur;return l=>{if(l.tag==="GroupTransform"){if(l._1==="NormalTransform")return o;if(l._1==="BakedTransform")return i;g()}if(l.tag==="GroupClip")return u;if(l.tag==="GroupAlpha")return c;if(l.tag==="GroupBlend")return _;if(l.tag==="GroupBlur")return f;g()}})(),s=t.popLayer;return u=>e.Bind1().bind(r(a)(re(u.effects)))(()=>{if(u.layer.tag==="Just")return s;if(u.layer.tag==="Nothing")return n.pure();g()})},O5=t=>{const e=t.Monad0(),n=e.Applicative0(),r=Do(n)(Qt);return o=>e.Bind1().bind((()=>{if(o.layer.tag==="Just")return t.pushLayer(o.layer._1);if(o.layer.tag==="Nothing")return n.pure();g()})())(()=>r(i=>{if(i.tag==="GroupTransform"){if(i._1==="NormalTransform")return t.pushTransform(i._2);if(i._1==="BakedTransform")return t.pushBakedTransform(i._2);g()}if(i.tag==="GroupClip")return t.pushClip(i._1)(i._2);if(i.tag==="GroupAlpha")return t.pushAlpha(i._1);if(i.tag==="GroupBlend")return t.pushBlend(i._1);if(i.tag==="GroupBlur")return t.pushBlur(i._1);g()})(o.effects))},g0=t=>{const e=t.Monad0(),n=Fk(t),r=g5(t),o=Xk(t),i=w5(t),a=Pk(t),s=_5(t);return OL(e)({beginFrame:u=>t.setViewport(u.viewport),endFrame:e.Applicative0().pure(),beginGroup:O5(t),endGroup:M5(t),background:Lk(t),overlay:Q5(t),node:u=>{if(u.geometry.tag==="FlatNode")return n(u);if(u.geometry.tag==="IsoSlab")return r(u);g()},edge:u=>{if(u.geometry.tag==="FlatRoute")return o(u);if(u.geometry.tag==="IsoSegments")return i(u);g()},text:Ok(t),token:u=>{if(u.geometry.tag==="FlatToken")return a(u);if(u.geometry.tag==="IsoCube")return s(u);g()},insideTokenStyle:t.insideTokenStyle,measureText:t.measureText,measureInk:t.measureInk})},W5=Up(rp)(D_.measureText),_0=g0(D_),_1=t=>cs({padding:24,outputAspect:t.width<=0||t.height<=0?y:w("Just",t.width/t.height)}),H5=t=>e=>n=>r=>o=>i=>a=>{const s={padding:24,transparentBg:(()=>{if(e==="TransparentBackground")return!0;if(e==="PaintBackground")return!1;g()})(),halftoneShadows:!1,watermark:"",theme:t,outputAspect:r.width<=0||r.height<=0?y:w("Just",r.width/r.height)},u=tp(n)(r);return()=>{const c=u(),_=o.levels.length-1|0;if(_>=0&&_<o.levels.length){const l=W5(s1(_1(r)(o))(o.levels[_]))(o.levels[_].segment.layout)(o.levels[_].state)(c)(),d=A_(i)(l)(a);return _0(g1(s)(d.applied)(o))(c)(),d.springs}const f=A_(i)(O)(a);return _0(g1(s)(f.applied)(o))(c)(),f.springs}},gs=t=>"rgb("+ue(t.r)+","+ue(t.g)+","+ue(t.b)+")",Ci=t=>t===1?7:t===2?10:t===3?14:t===4?13:t===5?5:t===6?1:t===7?4:t===8?1:t===9?2:t===10?1:t===11?2:t===12?1:t===18?2:t===19?1:t===13?2:t===14?1:t===15||t===16?5:1,de=Oo(Qo("Fixed",Mo(0)(20)(2))),f1=t=>{const e=n=>{const r=n>=0&&n<t.length?w("Just",t[n]):y;if(r.tag==="Just")return r._1===1?["M",de((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+3|0)]:r._1===2?["L",de((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+3|0)]:r._1===3?["Q",de((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+3|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+4|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+5|0)]:r._1===4?["C",de((()=>{const o=n+1|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+2|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+3|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+4|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+5|0;return o>=0&&o<t.length?t[o]:0})()),de((()=>{const o=n+6|0;return o>=0&&o<t.length?t[o]:0})()),...e(n+7|0)]:r._1===5?["Z",...e(n+1|0)]:[];if(r.tag==="Nothing")return[];g()};return Zn(" ")(e(0))},$5=t=>de(t.vx)+" "+de(t.vy)+" "+de(t.vw)+" "+de(t.vh),nr=t=>e=>he(ar(e>=0&&e<t.length?t[e]:0)),d1=t=>e=>{const n=nr(t.ops)(e+1|0);return Bt(n,n+nr(t.ops)(e+2|0)|0,t.paths)},f0=(()=>{const t=fr("&")("&amp;"),e=fr("<")("&lt;"),n=(()=>{const r=fr(">")("&gt;"),o=(()=>{const i=fr('"')("&quot;");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),q5={vx:0,vy:0,vw:1,vh:1},V5=t=>(e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i>=0&&i<t.length){if(t[i]===15){const a=i+1|0;r=!1,o={vx:a>=0&&a<t.length?t[a]:0,vy:(()=>{const s=a+1|0;return s>=0&&s<t.length?t[s]:0})(),vw:(()=>{const s=a+2|0;return s>=0&&s<t.length?t[s]:0})(),vh:(()=>{const s=a+3|0;return s>=0&&s<t.length?t[s]:0})()};continue}n=i+Ci(t[i])|0;continue}r=!1,o=q5}return o})(0),_s=t=>e=>({r:nr(t)(e),g:nr(t)(e+1|0),b:nr(t)(e+2|0),a:nr(t)(e+3|0)}),d0=t=>e=>({color:_s(t)(e),width:(()=>{const n=e+4|0;return n>=0&&n<t.length?t[n]:0})(),join:nr(t)(e+5|0),cap:nr(t)(e+6|0)}),U5=t=>e=>'<rect x="'+de(t.vx)+'" y="'+de(t.vy)+'" width="'+de(t.vw)+'" height="'+de(t.vh)+'" fill="'+gs(e)+'" opacity="'+de(ot(e.a)/255)+'"/>',K5=t=>e=>'<path d="'+f1(t)+'" fill="'+gs(e)+'" fill-opacity="'+de(ot(e.a)/255)+'"/>',l0=t=>' stroke="'+gs(t.color)+'" stroke-opacity="'+de(ot(t.color.a)/255)+'" stroke-width="'+de(t.width)+'" stroke-linejoin="'+(t.join===0?"round":t.join===1?"bevel":"miter")+'" stroke-linecap="'+(t.cap===0?"butt":t.cap===1?"round":"square")+'"',Y5=t=>e=>n=>'<path d="'+f1(t)+'" fill="'+gs(e)+'" fill-opacity="'+de(ot(e.a)/255)+'"'+l0(n)+"/>",X5=t=>e=>'<path d="'+f1(t)+'" fill="none"'+l0(e)+"/>",Z5=t=>e=>{const n=_s(t.ops)(e+7|0),r=nr(t.ops)(e+12|0),o=nr(t.ops)(e+11|0);return'<text x="'+de((()=>{const i=e+1|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'" y="'+de((()=>{const i=e+2|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'"'+(r===0?' dy="0.8em"':r===1?' dy="0.32em"':"")+' fill="'+gs(n)+'" fill-opacity="'+de(ot(n.a)/255)+'" font-size="'+de((()=>{const i=e+5|0;return i>=0&&i<t.ops.length?t.ops[i]:0})())+'" font-family="'+f0((()=>{const i=nr(t.ops)(e+4|0);return i>=0&&i<t.strs.length?t.strs[i]+", ui-sans-serif, system-ui, sans-serif":", ui-sans-serif, system-ui, sans-serif"})())+'" font-weight="'+ue(nr(t.ops)(e+6|0))+'" text-anchor="'+(o===0?"start":o===1?"middle":"end")+'">'+f0((()=>{const i=nr(t.ops)(e+3|0);return i>=0&&i<t.strs.length?t.strs[i]:""})())+"</text>"},Li=t=>e=>n=>{const r=n>=0&&n<e.ops.length?w("Just",e.ops[n]):y;if(r.tag==="Just")return r._1===1?K5(d1(e)(n))(_s(e.ops)(n+3|0))+Li(t)(e)(n+Ci(r._1)|0):r._1===2?X5(d1(e)(n))(d0(e.ops)(n+3|0))+Li(t)(e)(n+Ci(r._1)|0):r._1===3?Y5(d1(e)(n))(_s(e.ops)(n+3|0))(d0(e.ops)(n+7|0))+Li(t)(e)(n+Ci(r._1)|0):r._1===4?Z5(e)(n)+Li(t)(e)(n+Ci(r._1)|0):r._1===16?U5(t)(_s(e.ops)(n+1|0))+Li(t)(e)(n+Ci(r._1)|0):Li(t)(e)(n+Ci(r._1)|0);if(r.tag==="Nothing")return"";g()},j5=t=>{const e=V5(t.ops);return{viewBox:$5(e),body:Li(e)(t)(0),vx:e.vx,vy:e.vy,vw:e.vw,vh:e.vh}},tS=bJ(QJ)(D2),h0=t=>e=>{const n=t.strs;return()=>{const r=Pc(n);return t.strs.push(e),r}},Vu=t=>e=>{const n=t.paths;return()=>{const r=Pc(n);return t.paths.push(...e),{offset:r,len:e.length}}},eS=t=>e=>{const n=e.tx,r=t.ops;return()=>{r.push(n),t.ops.push(e.ty),t.ops.push(e.sx),t.ops.push(e.sy)}},p0=t=>e=>{const n=e.vx,r=t.ops;return()=>{r.push(n),t.ops.push(e.vy),t.ops.push(e.vw),t.ops.push(e.vh)}},oo=t=>e=>{const n=ot(e),r=t.ops;return()=>{r.push(n)}},Uu=t=>e=>{const n=e.len,r=oo(t)(e.offset);return()=>(r(),oo(t)(n)())},nS=()=>{const t=[],e=[],n=[],r=[];return r.push(1),{ops:t,paths:e,strs:n,alphaStack:r}},rS=t=>{if(t.tag==="MeasureText"){const e=t._3(Cg(t._1)(t._2));return()=>e}if(t.tag==="MeasureInk"){const e=t._3(Lg(t._1)(t._2));return()=>e}g()},m0=t=>{const e=t.alphaStack;return()=>{const n=Pc(e);if(n===0)return 1;const r=z2(Xt,y,n-1|0,t.alphaStack);if(r.tag==="Nothing")return 1;if(r.tag==="Just")return r._1;g()}},ki=t=>e=>{const n=m0(t);return()=>{const r=n();return oo(t)(e.r)(),oo(t)(e.g)(),oo(t)(e.b)(),oo(t)(he(ar(ot(e.a)*r+.5)))()}},y0=t=>e=>{const n=ki(t)(e.color);return()=>{n(),t.ops.push(e.width),t.ops.push((()=>{if(e.lineJoin==="RoundJoin")return 0;if(e.lineJoin==="BevelJoin")return 1;if(e.lineJoin==="MiterJoin")return 2;g()})()),t.ops.push((()=>{if(e.lineCap==="ButtCap")return 0;if(e.lineCap==="RoundCap")return 1;if(e.lineCap==="SquareCap")return 2;g()})())}},oS=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r;if(s.tag==="FillPath"){const u=s._3,c=s._2,_=Vu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(1),Uu(a)(f)(),ki(a)(c.color)(),u};continue}if(s.tag==="StrokePath"){const u=s._3,c=s._2,_=Vu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(2),Uu(a)(f)(),y0(a)(c)(),u};continue}if(s.tag==="FillStrokePath"){const u=s._2,c=s._4,_=s._3,f=Vu(a)(s._1);o=!1,i=()=>{const l=f();return a.ops.push(3),Uu(a)(l)(),ki(a)(u.color)(),y0(a)(_)(),c};continue}if(s.tag==="DrawText"){const u=s._2,c=s._1,_=h0(a)(Xo(c.content));o=!1,i=()=>{const f=_(),l=h0(a)(c.font.family)();return a.ops.push(4),a.ops.push(c.x),a.ops.push(c.y),oo(a)(f)(),oo(a)(l)(),a.ops.push(c.font.size),oo(a)(c.font.weight)(),ki(a)(c.color)(),a.ops.push((()=>{if(c.align==="AlignLeft")return 0;if(c.align==="AlignCenter")return 1;if(c.align==="AlignRight")return 2;g()})()),a.ops.push((()=>{if(c.baseline==="BaselineTop")return 0;if(c.baseline==="BaselineMiddle")return 1;if(c.baseline==="BaselineAlphabetic")return 2;if(c.baseline==="BaselineBottom")return 3;g()})()),u};continue}if(s.tag==="DrawTextAffine"){n=a,r=Yt("DrawText",{...s._2,x:s._1.a*s._2.x+s._1.c*s._2.y+s._1.e,y:s._1.b*s._2.x+s._1.d*s._2.y+s._1.f},s._3);continue}if(s.tag==="PushTransform"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(5),eS(a)(c)(),u);continue}if(s.tag==="PopTransform"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(6),u);continue}if(s.tag==="PushClip"){const u=s._3,c=s._2,_=Vu(a)(s._1);o=!1,i=()=>{const f=_();return a.ops.push(7),Uu(a)(f)(),a.ops.push((()=>{if(c==="NonZero")return 0;if(c==="EvenOdd")return 1;g()})()),u};continue}if(s.tag==="PopClip"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(8),u);continue}if(s.tag==="PushBlend"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(9),a.ops.push((()=>{if(u==="Normal")return 0;if(u==="Difference")return 1;g()})()),c);continue}if(s.tag==="PopBlend"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(10),u);continue}if(s.tag==="PushAlpha"){const u=s._1,c=s._2,_=m0(a);o=!1,i=()=>{const f=_();return a.alphaStack.push(f*u),a.ops.push(11),a.ops.push(u),c};continue}if(s.tag==="PopAlpha"){const u=s._1,c=a.alphaStack;o=!1,i=()=>(I2(Xt,y,c),a.ops.push(12),u);continue}if(s.tag==="PushBlur"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(18),a.ops.push(c),u);continue}if(s.tag==="PopBlur"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(19),u);continue}if(s.tag==="PushLayer"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(13),a.ops.push((()=>{if(u==="LayerBase")return 0;if(u==="LayerPolyOut")return 1;if(u==="LayerPolyIn")return 2;if(u==="LayerNodeMask")return 3;if(u==="LayerOverlay")return 4;g()})()),c);continue}if(s.tag==="PopLayer"){const u=s._1,c=a.ops;o=!1,i=()=>(c.push(14),u);continue}if(s.tag==="SetViewport"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(15),p0(a)(c)(),u);continue}if(s.tag==="ClearBackground"){const u=s._1,c=s._2,_=a.ops;o=!1,i=()=>(_.push(16),ki(a)(u)(),c);continue}if(s.tag==="BackgroundDots"){const u=s._2,c=s._1,_=a.ops;o=!1,i=()=>(_.push(17),p0(a)(c.viewport)(),ki(a)(c.bgColor)(),ki(a)(c.dotColor)(),a.ops.push(c.tile),a.ops.push(c.dotRadius),a.ops.push(c.origin.x),a.ops.push(c.origin.y),u);continue}g()}return i},iS=t=>e=>e.type==="metrics"?rS(e.value):e.type==="render"?oS(t)(e.value):Pf("Data.Functor.Variant: pattern match failure ["+e.type+"]"),aS=t=>{const e=nS();return tS(iS(e))(t)(),{ops:e.ops,paths:e.paths,strs:e.strs}},sS=t=>t,fs=t=>t,l1=fs("Light"),uS=fs("Dark"),cS=fs("Blueprint"),gS=fs("Whiteboard"),_S=fs("Isometric"),fS=sS("TransparentBackground"),ko=t=>"rgb("+ue(t.r)+","+ue(t.g)+","+ue(t.b)+")",Ku=Oo(Qo("Fixed",Mo(0)(20)(6))),Mr=Oo(Qo("Fixed",Mo(0)(20)(4))),dS=t=>"translate("+Mr(t.tx)+","+Mr(t.ty)+") scale("+Mr(t.sx)+","+Mr(t.sy)+")",$t=Oo(Qo("Fixed",Mo(0)(20)(2))),h1=t=>{const e=[];let n=0;for(;n<t.length;){const r=n,o=r>=0&&r<t.length?w("Just",t[r]):y;if(o.tag==="Nothing"){n=t.length;continue}if(o.tag==="Just"){if(o._1===1){e.push("M"),e.push($t((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),n=r+3|0;continue}if(o._1===2){e.push("L"),e.push($t((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),n=r+3|0;continue}if(o._1===3){e.push("Q"),e.push($t((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+3|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+4|0;return i>=0&&i<t.length?t[i]:0})())),n=r+5|0;continue}if(o._1===4){e.push("C"),e.push($t((()=>{const i=r+1|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+2|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+3|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+4|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+5|0;return i>=0&&i<t.length?t[i]:0})())),e.push($t((()=>{const i=r+6|0;return i>=0&&i<t.length?t[i]:0})())),n=r+7|0;continue}if(o._1===5){e.push("Z"),n=r+1|0;continue}n=t.length;continue}g()}return Zn(" ")(e)},lS={map:t=>e=>n=>{const r=e(n);return()=>{const o=r();return t(o)}}},p1=(()=>{const t=fr("&")("&amp;"),e=fr("<")("&lt;"),n=(()=>{const r=fr(">")("&gt;"),o=(()=>{const i=fr('"')("&quot;");return a=>i(r(a))})();return i=>o(e(i))})();return r=>n(t(r))})(),hS=t=>{if(t.style==="RunText"||t.style==="RunHighlight")return"<tspan>"+p1(t.text)+"</tspan>";if(t.style==="RunCode"||t.style==="RunCodeHighlight")return`<tspan font-family="'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace" font-weight="400">`+p1(t.text)+"</tspan>";g()},Xe=t=>e=>{const n=e.maskDepth;return()=>{n.value===0&&e.out.push(t)}},pS=t=>e=>{const n=[];let r=0;const o=i=>{const a=i>=0&&i<e.length?t.sx*e[i]+t.tx:t.sx*0+t.tx;return()=>{n.push(a),n.push((()=>{const s=i+1|0;return s>=0&&s<e.length?t.sy*e[s]+t.ty:t.sy*0+t.ty})())}};for(;r<e.length;){const i=r,a=i>=0&&i<e.length?w("Just",e[i]):y;if(a.tag==="Nothing"){r=e.length;continue}if(a.tag==="Just"){if(a._1===1){n.push(a._1),o(i+1|0)(),r=i+3|0;continue}if(a._1===2){n.push(a._1),o(i+1|0)(),r=i+3|0;continue}if(a._1===3){n.push(a._1),o(i+1|0)(),o(i+3|0)(),r=i+5|0;continue}if(a._1===4){n.push(a._1),o(i+1|0)(),o(i+3|0)(),o(i+5|0)(),r=i+7|0;continue}if(a._1===5){n.push(a._1),r=i+1|0;continue}r=e.length;continue}g()}return n},Yu=t=>e=>{const n=t.bake;return()=>{const r=n.value;if(r.tag==="Nothing")return e;if(r.tag==="Just")return pS(r._1)(e);g()}},x0={apply:t=>e=>n=>{const r=t(n),o=e(n);return()=>{const i=r(),a=o();return i(a)}},Functor0:()=>lS},mS={bind:t=>e=>n=>{const r=t(n);return()=>{const o=r();return e(o)(n)()}},Apply0:()=>x0},yS={pure:t=>e=>()=>t,Apply0:()=>x0},J0={Applicative0:()=>yS,Bind1:()=>mS},xS=t=>e=>'<defs><pattern id="'+t+'" x="'+$t(e.origin.x)+'" y="'+$t(e.origin.y)+'" width="'+$t(e.tile)+'" height="'+$t(e.tile)+'" patternUnits="userSpaceOnUse">'+(e.bgColor.a===0?"":'<rect width="'+$t(e.tile)+'" height="'+$t(e.tile)+'" fill="'+ko(e.bgColor)+'" fill-opacity="'+$t(ot(e.bgColor.a)/255)+'"/>')+'<circle cx="'+$t(e.tile/2)+'" cy="'+$t(e.tile/2)+'" r="'+$t(e.dotRadius)+'" fill="'+ko(e.dotColor)+'"/></pattern></defs><rect x="'+$t(e.viewport.vx)+'" y="'+$t(e.viewport.vy)+'" width="'+$t(e.viewport.vw)+'" height="'+$t(e.viewport.vh)+'" fill="url(#'+t+')"/>',w0=t=>e=>'<path d="'+h1(t)+'" fill="'+ko(e)+'" fill-opacity="'+$t(ot(e.a)/255)+'"/>',JS=t=>e=>n=>r=>'<rect x="'+$t(t.x)+'" y="'+$t(t.y)+'" width="'+$t(t.w)+'" height="'+$t(t.h)+'" rx="'+$t(e)+'"'+(()=>{if(n.tag==="Just")return' fill="'+ko(n._1.color)+'" fill-opacity="'+$t(ot(n._1.color.a)/255)+'"';if(n.tag==="Nothing")return' fill="none"';g()})()+(()=>{if(r.tag==="Just")return' stroke="'+ko(r._1.color)+'" stroke-opacity="'+$t(ot(r._1.color.a)/255)+'" stroke-width="'+$t(r._1.width)+'" stroke-linejoin="'+(()=>{if(r._1.lineJoin==="RoundJoin")return"round";if(r._1.lineJoin==="BevelJoin")return"bevel";if(r._1.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(r._1.lineCap==="ButtCap")return"butt";if(r._1.lineCap==="RoundCap")return"round";if(r._1.lineCap==="SquareCap")return"square";g()})()+'"';if(r.tag==="Nothing")return"";g()})()+"/>",T0=t=>e=>'<path d="'+h1(t)+'" fill="none" stroke="'+ko(e.color)+'" stroke-opacity="'+$t(ot(e.color.a)/255)+'" stroke-width="'+$t(e.width)+'" stroke-linejoin="'+(()=>{if(e.lineJoin==="RoundJoin")return"round";if(e.lineJoin==="BevelJoin")return"bevel";if(e.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(e.lineCap==="ButtCap")return"butt";if(e.lineCap==="RoundCap")return"round";if(e.lineCap==="SquareCap")return"square";g()})()+'"/>',N0=t=>{const e=dr(Xo(t.content));return'<text x="'+$t(t.x)+'" y="'+$t(t.y)+'"'+(()=>{if(t.baseline==="BaselineTop")return' dy="0.8em"';if(t.baseline==="BaselineMiddle")return' dy="0.32em"';if(t.baseline==="BaselineAlphabetic"||t.baseline==="BaselineBottom")return"";g()})()+' fill="'+ko(t.color)+'" fill-opacity="'+$t(ot(t.color.a)/255)+'" font-size="'+$t(t.font.size)+'" font-family="Ilisarniq, ui-sans-serif, system-ui, sans-serif" font-weight="'+ue(t.font.weight)+'" text-anchor="'+(()=>{if(t.align==="AlignLeft")return"start";if(t.align==="AlignCenter")return"middle";if(t.align==="AlignRight")return"end";g()})()+'">'+(e.length===1&&e[0].style==="RunText"?p1(e[0].text):Zn("")(Y(hS)(e)))+"</text>"},wS=t=>"matrix("+Mr(t.a)+" "+Mr(t.b)+" "+Mr(t.c)+" "+Mr(t.d)+" "+Mr(t.e)+" "+Mr(t.f)+")",v0={fillPath:t=>e=>n=>{const r=Yu(n)(t);return()=>{const o=r();return Xe(w0(o)(e.color))(n)()}},strokePath:t=>e=>n=>{const r=Yu(n)(t);return()=>{const o=r(),i=n.bake.value;return Xe(T0(o)((()=>{if(i.tag==="Nothing")return e;if(i.tag==="Just")return{...e,width:i._1.sx*e.width};g()})()))(n)()}},fillStrokePath:t=>e=>n=>r=>{const o=Yu(r)(t);return()=>{const i=o(),a=r.bake.value;return Xe(w0(i)(e.color)+T0(i)((()=>{if(a.tag==="Nothing")return n;if(a.tag==="Just")return{...n,width:a._1.sx*n.width};g()})()))(r)()}},drawRoundedRect:t=>e=>n=>r=>o=>{const i=o.bake;return()=>{const a=i.value;return Xe(JS((()=>{if(a.tag==="Nothing")return t;if(a.tag==="Just")return{x:a._1.sx*t.x+a._1.tx,y:a._1.sy*t.y+a._1.ty,w:a._1.sx*t.w,h:a._1.sy*t.h};g()})())((()=>{if(a.tag==="Nothing")return e;if(a.tag==="Just")return a._1.sx*e;g()})())(n)(r.tag==="Just"?w("Just",(()=>{if(a.tag==="Nothing")return r._1;if(a.tag==="Just")return{...r._1,width:a._1.sx*r._1.width};g()})()):y))(o)()}},drawText:t=>e=>{const n=e.bake;return()=>{const r=n.value;return Xe(N0((()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return{...t,x:r._1.sx*t.x+r._1.tx,y:r._1.sy*t.y+r._1.ty,font:{...t.font,size:r._1.sx*t.font.size}};g()})()))(e)()}},drawTextAffine:t=>e=>Xe((()=>{const n='transform="'+wS(t)+'"';return(n===""?"<g>":"<g "+n+">")+N0(e)+"</g>"})()),pushTransform:t=>Xe((()=>{const e='transform="'+dS(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popTransform:Xe("</g>"),pushBakedTransform:t=>e=>{const n=e.bake;return()=>{n.value=w("Just",t)}},popBakedTransform:t=>{const e=t.bake;return()=>{e.value=y}},pushClip:t=>e=>n=>{const r=n.clipCounter;return()=>{const o=r.value;n.clipCounter.value=o+1|0;const i=Yu(n)(t)(),a="clip"+ue(o);return Xe((()=>{const s='clip-path="url(#'+a+')"';return'<defs><clipPath id="'+a+'"><path d="'+h1(i)+'"'+(()=>{if(e==="EvenOdd")return' clip-rule="evenodd"';if(e==="NonZero")return"";g()})()+"/></clipPath></defs>"+(s===""?"<g>":"<g "+s+">")})())(n)()}},popClip:Xe("</g>"),pushBlend:t=>Xe((()=>{const e=(()=>{if(t==="Normal")return'style="mix-blend-mode: normal"';if(t==="Difference")return'style="mix-blend-mode: difference"';g()})();return e===""?"<g>":"<g "+e+">"})()),popBlend:Xe("</g>"),pushAlpha:t=>Xe((()=>{const e='opacity="'+$t(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popAlpha:Xe("</g>"),pushBlur:t=>e=>{if(t<.01)return Xe("<g>")(e);const n=e.patternCounter;return()=>{const r=n.value;e.patternCounter.value=r+1|0;const o="lvl-blur-"+ue(r);return Xe((()=>{const i='filter="url(#'+o+')"';return'<defs><filter id="'+o+'" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="'+$t(t)+'"/></filter></defs>'+(i===""?"<g>":"<g "+i+">")})())(e)()}},popBlur:Xe("</g>"),pushLayer:t=>e=>{const n=(()=>{if(t==="LayerNodeMask"){const r=e.maskDepth;return()=>{const o=r.value;e.maskDepth.value=o+1|0}}return()=>{}})();return()=>{n(),e.out.push("<g>")}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;n>0&&(t.maskDepth.value=r),t.out.push("</g>")}},setViewport:t=>e=>()=>{},clearBackground:t=>e=>Xe('<rect x="'+$t(e.viewport.vx)+'" y="'+$t(e.viewport.vy)+'" width="'+$t(e.viewport.vw)+'" height="'+$t(e.viewport.vh)+'" fill="'+ko(t)+'" opacity="'+$t(ot(t.a)/255)+'"/>')(e),backgroundDots:t=>e=>{const n=e.patternCounter;return()=>{const r=n.value;return e.patternCounter.value=r+1|0,Xe(xS("bg-dots-"+ue(r))(t))(e)()}},measureText:t=>e=>n=>{const r=Cg(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Lg(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>Ag,Monad0:()=>J0},TS=g0(v0),NS=Up(J0)(v0.measureText),vS=t=>e=>n=>r=>o=>{const i={padding:24,transparentBg:(()=>{if(r==="TransparentBackground")return!0;if(r==="PaintBackground")return!1;g()})(),halftoneShadows:!1,watermark:"",theme:n,outputAspect:t},a=cs(i)(o);return{viewBox:Ku(a.vx)+" "+Ku(a.vy)+" "+Ku(a.vw)+" "+Ku(a.vh),body:(()=>{const s=[],u={value:0},c={value:0},_={value:0},f={value:y};return TS(g1(i)(e)(o))({out:s,maskDepth:u,clipCounter:c,patternCounter:_,viewport:a,bake:f})(),Zn("")(s)})(),vx:a.vx,vy:a.vy,vw:a.vw,vh:a.vh}},bS=t=>e=>n=>r=>o=>i=>{const a={padding:24,transparentBg:(()=>{if(n==="TransparentBackground")return!0;if(n==="PaintBackground")return!1;g()})(),outputAspect:t},s=A_(o)((()=>{const u=[],c={value:0},_={value:0},f={value:0},l={value:y},d=r.levels.length-1|0;if(d>=0&&d<r.levels.length){const h=s1(cs(a)(r))(r.levels[d]);return NS(h)(r.levels[d].segment.layout)(r.levels[d].state)({out:u,maskDepth:c,clipCounter:_,patternCounter:f,viewport:h,bake:l})()}return O})())(i);return{parts:vS(t)(s.applied)(e)(n)(r),springs:s.springs}},So=(t,e)=>({tag:t,_1:e}),Xu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},On=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},b0=fe(B)(Qt),C0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},L0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Zu=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},ju=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Si=(()=>{const t=un.unfoldr(e=>{if(e.tag==="Nil")return y;if(e.tag==="Cons")return w("Just",E(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._3,n(r._6,o)));g()};return n(e,z)})())})(),CS=v(t=>e=>it(B)(e)()(t))(O),m1=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},LS=Ts(Fi),k0=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},kS=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},tc=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},SS=So("NoKeyframes"),ES=t=>So("DuplicateEventId",t),PS=t=>So("UnknownEvent",t),GS=t=>e=>({...e,cameraSpans:ul(e.cameraConfig)(t)(e.timing.edgeEasing)(e.layout)(e.keyframes)({endT:e.totalDuration,spans:e.spans,windows:e.windows,segments:e.segments,dives:e.dives}),cameraViewport:t}),AS=t=>e=>n=>r=>{const o=Xu(r.edge)(e.edges),i=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return Ba(o._1);g()})(),a=On(t.minTokenDuration)(On(ot(v(s=>u=>s+_n(u).length|0)(0)(r.labels))*t.tokenReadSecPerChar)(t.tokenSpeed<=0?0:i/t.tokenSpeed))+n.post;return{duration:a,holdPre:0,holdPost:a<=0?0:n.post/a}},BS=Ns(t=>{const e=$i(`
9
+ `)(t);return e.length===0?[""]:e}),RS=t=>e=>b0(ht(n=>{if(n.kind.tag==="SendToken")return w("Just",E(n.id,{post:(()=>{const r=n.id;return(()=>{const o=n.kind._1.to;return oe(i=>{if(i.kind.tag==="SendToken")return(i.when.tag==="First"?!1:i.when.tag==="After"&&i.when._1===r)&&i.kind._1.from===o;if(i.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})()}));if(n.kind.tag==="FillNodeWithoutTransition")return y;g()})(e)),DS=t=>{if(t.event.kind.tag==="SendToken")return w("Just",{startT:t.startT,endT:t.endT,target:ri("TokenWindow",t.event.id,t.event.kind._1.edge,t.event.kind._1.direction,t.event.kind._1.from,t.event.kind._1.to,t.event.kind._1.labels,t.holdPre,t.holdPost)});if(t.event.kind.tag==="FillNodeWithoutTransition")return w("Just",{startT:t.startT,endT:t.endT,target:ri("FillWindow",t.event.id,t.event.kind._1.node,t.event.kind._1.labels)});g()},FS=t=>ht((()=>{const e=t.path;return n=>n.target.tag==="TokenWindow"?w("Just",{path:e,eventId:n.target._1,window:n,from:n.target._4,to:n.target._5,labels:n.target._6,holdPre:n.target._7,holdPost:n.target._8}):y})())(t.windows),zS=t=>e=>n=>{const r=Xu(n)(t);if(r.tag==="Nothing")return _l;if(r.tag==="Just"){const o=C0(r._1.target)(e);return C0(r._1.source)(e)?o?MT:QT:_l}g()},S0=t=>e=>{if(t.tag==="Just"&&t._1>e.endT+1e-4){const n=On(0)(e.endT-e.startT),r=On(e.startT)(t._1-n);return{...e,startT:r,endT:r+n}}return e},E0=Y(wa),IS={post:0},QS=t=>e=>n=>r=>o=>{const i=L0(o.event.id)(n),a=(()=>{if(i.tag==="Nothing")return IS;if(i.tag==="Just")return i._1;g()})(),s=(()=>{if(o.event.when.tag==="First")return 0;if(o.event.when.tag==="At")return o.event.when._1;if(o.event.when.tag==="After"){const c=o.event.when._1,_=te(f=>f.event.id===c)(r);if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1.endT;g()}if(o.event.when.tag==="With"){const c=o.event.when._1,_=te(f=>f.event.id===c)(r);if(_.tag==="Nothing")return 0;if(_.tag==="Just")return _._1.startT}g()})(),u=(()=>{if(o.event.kind.tag==="SendToken")return AS(t)(e)(a)(o.event.kind._1);if(o.event.kind.tag==="FillNodeWithoutTransition")return{duration:t.plop,holdPre:0,holdPost:0};g()})();return Et(r)({startT:s,endT:s+u.duration,event:o.event,holdPre:u.holdPre,holdPost:u.holdPost})},P0=t=>e=>n=>v(QS(t)(e)(RS(t)(n)))([])(Mt(r=>o=>({event:o}))(n)),MS=t=>v(e=>n=>{const r=Sr(e);if(r.tag==="Nothing")return[n];if(r.tag==="Just")return n.startT<=r._1.last.endT+1e-4?Et(r._1.init)({...r._1.last,endT:On(r._1.last.endT)(n.endT)}):Et(e)(n);g()})([])(Pt(e=>n=>at.compare(e.startT)(n.startT))(t)),OS=t=>e=>{const n=Zu(e)(t.interiors);if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},WS=t=>e=>{const n=Pt(at.compare)(ht(r=>r.target.tag==="RelabelWindow"?r.target._1===e?w("Just",r.startT):y:r.target.tag==="TokenWindow"?r.target._4===e||r.target._5===e?w("Just",r.startT):y:r.target.tag==="FillWindow"&&r.target._2===e?w("Just",r.startT):y)(t));return 0<n.length?w("Just",n[0]):y},HS=t=>e=>{const n=Pt(at.compare)(ht(r=>r.target.tag==="TokenWindow"&&r.target._2===e?w("Just",r.startT):y)(t));return 0<n.length?w("Just",n[0]):y},$S=t=>e=>e.target.tag==="NodeWindow"?e.target._2==="PlopIn"?S0(WS(t.windows)(e.target._1))(e):e:e.target.tag==="EdgeWindow"&&e.target._2.tag==="Extend"?S0(HS(t.windows)(e.target._1))(e):e,qS=t=>({...t,windows:Pt(e=>n=>at.compare(e.startT)(n.startT))(Y($S(t))(t.windows))}),VS=t=>{if(t.when.tag==="First")return[];if(t.when.tag==="At")return[];if(t.when.tag==="After")return[t.when._1];if(t.when.tag==="With")return[t.when._1];g()},ec={id:"",nodes:O,edges:O,labels:O,kind:Pa,authored:!1},US=t=>e=>wx((()=>{const n=ju(e.from)(t);if(n.tag==="Nothing")return ec;if(n.tag==="Just")return n._1;g()})())((()=>{const n=ju(e.to)(t);if(n.tag==="Nothing")return ec;if(n.tag==="Just")return n._1;g()})()),KS=t=>e=>{const n=Zu(e)(t.interiors);if(n.tag==="Nothing")return{layout:t.layout,interiors:O};if(n.tag==="Just")return n._1;g()},G0={id:"",index:-1,kind:"",name:"",time:0,endTime:0,path:[],tokenIndex:-1,lineIndex:-1,text:"",from:"",to:""},YS=t=>e=>e.scene.tag==="StepScene"?w("Just",{...G0,id:"step:"+e.scene._1,kind:"step",name:e.scene._1,time:e.startT,endTime:e.startT,path:E0(t)}):y,XS=t=>ht(YS(t.path))(t.spans),y1=t=>e=>n=>r=>{const o=Xu(r)(n.edges);if(o.tag==="Just")return t<=0?e:On(e)(Ba(o._1)/t);if(o.tag==="Nothing")return e;g()},A0=t=>e=>n=>r=>o=>{const i=ju(o.to)(n),a=(()=>{if(i.tag==="Nothing")return ec;if(i.tag==="Just")return i._1;g()})(),s=t.plop,u=ju(o.from)(n),c=(()=>{if(u.tag==="Nothing")return ec;if(u.tag==="Just")return u._1;g()})(),_=US(n)(o),f=Y(J=>({startT:0,endT:0+y1(t.edgeSpeed)(t.minEdgeDuration)(e)(J),target:ri("EdgeWindow",J,eu("Extend",Zg))}))(Si(_.entering.edges)),l=Y(J=>({startT:0,endT:s,target:ri("NodeWindow",J,zg)}))(Si(_.entering.nodes)),d=Y(J=>({startT:0,endT:t.plop,target:ri("RelabelWindow",J.node,J.oldLabel,J.newLabel)}))(ht(J=>{const T=Zu(J)(c.labels);if(T.tag==="Just"){const N=Zu(J)(a.labels);if(N.tag==="Just")return T._1===N._1?y:w("Just",{node:J,oldLabel:T._1,newLabel:N._1});if(N.tag==="Nothing")return y;g()}if(T.tag==="Nothing")return y;g()})(Si(_.surviving.nodes))),h=v(On)(0)(Y(J=>y1(t.edgeSpeed)(t.minEdgeDuration)(e)(J))(Si(_.leaving.edges))),m=J=>oe(T=>{const N=Xu(T)(r);if(N.tag==="Just")return N._1.source===J||N._1.target===J;if(N.tag==="Nothing")return!1;g()},Si(_.leaving.edges))?h:0,p=Y(J=>({startT:m(J),endT:m(J)+t.plop,target:ri("NodeWindow",J,Sw)}))(Si(_.leaving.nodes)),x=Y(J=>({startT:0,endT:y1(t.edgeSpeed)(t.minEdgeDuration)(e)(J),target:ri("EdgeWindow",J,eu("Retract",zS(r)(_.leaving.nodes)(J)))}))(Si(_.leaving.edges));return{duration:(()=>{const J=Pt(at.compare)([...Y(N=>N.endT)(x),...Y(N=>N.endT)(p),...Y(N=>N.endT)(l),...Y(N=>N.endT)(d),...Y(N=>N.endT)(f)]),T=J.length-1|0;return T>=0&&T<J.length?J[T]+t.gap:t.gap})(),windows:[...x,...p,...l,...d,...f]}},ZS=t=>e=>n=>r=>o=>i=>Y((()=>{const a=o.startT;return s=>({...s,startT:s.startT+a,endT:s.endT+a})})())(A0(t)(e)(n)(r)(i).windows),jS=t=>ht(e=>It(Ri,e).length>1?w("Just",(()=>{const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),It(Ri,e));if(n.tag==="Just")return n._1.head;if(n.tag==="Nothing")return"";g()})()):y)(iy(Fi)(Pt(B.compare)(t))),tE=t=>{const e=Y(r=>r.id)(t),n=CS(e);return[...Y(ES)(jS(e)),...Y(PS)(_t(r=>!m1(r)(n),St(t)(VS)))]},eE=t=>{const e=b0(Y(r=>E(r.id,(()=>{if(r.when.tag==="First")return[];if(r.when.tag==="At")return[];if(r.when.tag==="After")return[r.when._1];if(r.when.tag==="With")return[r.when._1];g()})()))(t)),n=r=>o=>i=>{if(m1(i)(o))return[So("ScheduleCycle",[...It(xn.foldr,o),i])];if(m1(i)(r))return[];const a=L0(i)(e);if(a.tag==="Nothing")return[];if(a.tag==="Just")return St(a._1)(n(it(B)(i)()(r))(it(B)(i)()(o)));g()};return St(t)(r=>n(O)(O)(r.id))},nE={plop:.5,gap:0,edgeSpeed:350,minEdgeDuration:.3,tokenSpeed:250,minTokenDuration:1.8,tokenHold:0,stillHold:1.8,hatchHold:0,tokenReadSecPerChar:.06,nodeEasing:Px,edgeEasing:_r,tokenEasing:cg,diveDur:2.45,retreatDur:2.45},rE=t=>e=>n=>r=>Y((()=>{const o=n.startT;return i=>({...i,startT:i.startT+o,endT:i.endT+o})})())(ht(DS)(P0(t)(e)(r.events))),oE=t=>e=>n=>r=>o=>{if(o.scene.tag==="Structural")return ZS(t)(e)(n)(r)(o)(o.scene._1);if(o.scene.tag==="Hold")return[];if(o.scene.tag==="DataFlow")return rE(t)(e)(o)(o.scene._1);if(o.scene.tag==="EnterNode")return[];if(o.scene.tag==="ExitNode")return[];if(o.scene.tag==="StepScene")return[];g()},iE=t=>e=>n=>{const r=P0(t)(e)(n.events);return r.length===0?t.gap:v(On)(0)(Y(o=>o.endT)(r))+t.gap},aE=t=>e=>n=>r=>o=>{if(o.tag==="Structural")return A0(t)(e)(n)(r)(o._1).duration;if(o.tag==="Hold")return t.stillHold;if(o.tag==="DataFlow")return iE(t)(e)(o._1);if(o.tag==="EnterNode"||o.tag==="ExitNode"||o.tag==="StepScene")return 0;g()},B0=t=>e=>n=>r=>o=>i=>{const a=xJ(e)(r),s=n.layout,u=Df(Y(p=>E(p.id,p))(o.keyframes)),c=0<o.keyframes.length?w("Just",o.keyframes[0]):y,_=(()=>{if(c.tag==="Just")return c._1.id;if(c.tag==="Nothing")return"";g()})(),f=Sx(o),l=p=>({startT:p.runStart,endT:p.t,path:r,layout:s,placement:a,windows:p.runWindows,spans:p.runSpans,keyframes:u,initialKeyframe:_,edgeEndpoints:f}),d=p=>({segments:p.runSpans.length===0?p.segments:Et(p.segments)(l(p)),spans:p.spans,windows:p.windows,dives:p.dives}),h=v(p=>x=>{if(x.tag==="EnterNode"){const k=d(p),C=p.runSpans.length===0?{...k,segments:Et(k.segments)(l(p))}:k,P=p.t+t.diveDur,G=Et(r)(x._1),R=B0(t)(e)(KS(n)(x._1))(G)(OS(o)(x._1))(P),U=R.endT+t.retreatDur;return{...p,t:U,runStart:U,runSpans:[],runWindows:[],segments:[...C.segments,...R.segments],spans:[...C.spans,...R.spans],windows:[...C.windows,...R.windows],dives:[...C.dives,{startT:p.t,endT:P,node:x._1,parentPath:r,childPath:G,direction:Ew},...R.dives,{startT:R.endT,endT:U,node:x._1,parentPath:r,childPath:G,direction:Pw}]}}if(x.tag==="ExitNode")return p;const J=p.t+aE(t)(s)(u)(f)(x),T={startT:p.t,endT:J,scene:x},N=oE(t)(s)(u)(f)(T);return{...p,t:J,runSpans:Et(p.runSpans)(T),runWindows:[...p.runWindows,...N],spans:Et(p.spans)(T),windows:[...p.windows,...N]}})({t:i,runStart:i,runSpans:[],runWindows:[],segments:[],spans:[],windows:[],dives:[]})(o.scenes),m=d(h);return{endT:h.t,spans:m.spans,windows:Pt(p=>x=>at.compare(p.startT)(x.startT))(m.windows),segments:r.length===0||oe(p=>LS(p.path)(r),m.segments)?m.segments:Et(m.segments)(l(h)),dives:m.dives}},sE=t=>e=>{const n=at.compare(t.time)(e.time);return n==="EQ"?B.compare(t.id)(e.id):n},rr=t=>e=>e-v(n=>r=>n+On(0)(k0(e)(r.endT)-r.startT))(0)(t),uE=t=>e=>{const n=On(t.startT)(e.startT),r=k0(t.endT)(e.endT);return r>n+1e-4?w("Just",{startT:n,endT:r}):y},cE=t=>e=>{if(e.scene.tag==="Structural"){const n=v(r=>o=>({cursor:On(r.cursor)(o.endT),cuts:o.startT>r.cursor+1e-4?Et(r.cuts)({startT:r.cursor,endT:o.startT}):r.cuts}))({cursor:e.startT,cuts:[]})(Pt(r=>o=>at.compare(r.startT)(o.startT))(ht(uE(e))(t)));return e.endT>n.cursor+1e-4?Et(n.cuts)({startT:n.cursor,endT:e.endT}):n.cuts}return[]},gE=t=>{const e=MS(St(t.spans)(cE(t.windows)));return e.length===0?t:{...t,endT:rr(e)(t.endT),spans:Y(n=>({...n,startT:rr(e)(n.startT),endT:rr(e)(n.endT)}))(t.spans),windows:Pt(n=>r=>at.compare(n.startT)(r.startT))(Y(n=>({...n,startT:rr(e)(n.startT),endT:rr(e)(n.endT)}))(t.windows)),segments:Y(n=>({...n,startT:rr(e)(n.startT),endT:rr(e)(n.endT),spans:Y(r=>({...r,startT:rr(e)(r.startT),endT:rr(e)(r.endT)}))(n.spans),windows:Pt(r=>o=>at.compare(r.startT)(o.startT))(Y(r=>({...r,startT:rr(e)(r.startT),endT:rr(e)(r.endT)}))(n.windows))}))(t.segments),dives:Y(n=>({...n,startT:rr(e)(n.startT),endT:rr(e)(n.endT)}))(t.dives)}},_E=t=>{const e=Y(qS)(t.segments);return gE({...t,segments:e,windows:Pt(n=>r=>at.compare(n.startT)(r.startT))(St(e)(n=>n.windows))})},fE=t=>e=>n=>{const r=On(.05)(1-t-e),o=u=>{if(u<=0)return 0;if(u>=1)return 1;const c=t+u*r;return c<0?0:c>1?1:c},i=BS(n),a=Y(u=>ot(kS(1)(_n(u).length)))(i),s=On(1)(v(xr)(0)(a));return Mt(u=>c=>({lineIndex:u,text:c,start:o(v(xr)(0)(u<1?[]:Bt(0,u,a))/s),end:o(u>=0&&u<a.length?(v(xr)(0)(u<1?[]:Bt(0,u,a))+a[u])/s:(v(xr)(0)(u<1?[]:Bt(0,u,a))+1)/s)}))(i)},dE=t=>{const e=On(0)(t.window.endT-t.window.startT);return Y(n=>({...G0,id:"token:"+t.eventId+":line:"+ue(n.lineIndex),kind:"tokenLine",time:t.window.startT+n.start*e,endTime:t.window.startT+n.end*e,path:E0(t.path),tokenIndex:t.tokenIndex,lineIndex:n.lineIndex,text:n.text,from:t.from,to:t.to}))(fE(t.holdPre)(t.holdPost)(t.labels))},lE=t=>St(Mt(e=>n=>({path:n.path,eventId:n.eventId,window:n.window,from:n.from,to:n.to,labels:n.labels,holdPre:n.holdPre,holdPost:n.holdPost,tokenIndex:e}))(St(t)(FS)))(dE),hE=t=>Mt(e=>n=>({...n,index:e}))(Pt(sE)([...St(t.segments)(XS),...lE(t.segments)])),pE=t=>e=>{if(e.tag==="Structural")return ht(n=>n)([tc(e._1.from)(t)?y:w("Just",So("UnknownKeyframe",e._1.from)),tc(e._1.to)(t)?y:w("Just",So("UnknownKeyframe",e._1.to))]);if(e.tag==="Hold")return ht(n=>n)([tc(e._1)(t)?y:w("Just",So("UnknownKeyframe",e._1))]);if(e.tag==="DataFlow")return[...ht(n=>n)([tc(e._1.keyframe)(t)?y:w("Just",So("UnknownKeyframe",e._1.keyframe))]),...tE(e._1.events),...eE(e._1.events)];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];if(e.tag==="StepScene")return[];g()},mE=t=>e=>{const n=St(e)(pE(t));return n.length===0?Dt("Right",void 0):Dt("Left",n)},yE=t=>e=>n=>r=>o=>{if(0<r.keyframes.length){const i=r.keyframes[0],a=Df(Y(u=>E(u.id,u))(r.keyframes)),s=mE(a)(r.scenes);return(()=>{if(s.tag==="Left"){const u=s._1;return c=>Dt("Left",u)}if(s.tag==="Right"){const u=s._1;return c=>c(u)}g()})()(()=>{const u=_E(B0(n)(o)(o)([])(r)(0)),c=r.minimumFontSize.tag==="Just"&&r.minimumFontSize._1>0?{...t,minimumReadableLabelPx:r.minimumFontSize._1}:t;return Dt("Right",{totalDuration:u.endT,windows:u.windows,spans:u.spans,keyframes:a,initialKeyframe:i.id,timing:n,layout:o.layout,cameraSpans:ul(c)(e)(n.edgeEasing)(o.layout)(a)(u),cameraConfig:c,cameraViewport:e,levelTree:o,segments:u.segments,dives:u.dives,cues:hE(u),seed:r.seed})})}return Dt("Left",[SS])},Ei=t=>({bind:e=>n=>r=>t.Bind1().bind(e(r))(o=>n(o._1)(o._2)),Apply0:()=>R0(t)}),R0=t=>{const e=t.Bind1().Apply0().Functor0(),n={map:r=>o=>i=>e.map(a=>E(r(a._1),a._2))(o(i))};return{apply:(()=>{const r=Ei(t);return o=>i=>r.bind(o)(a=>r.bind(i)(s=>Pi(t).pure(a(s))))})(),Functor0:()=>n}},Pi=t=>({pure:e=>n=>t.Applicative0().pure(E(e,n)),Apply0:()=>R0(t)}),D0=t=>{const e={Applicative0:()=>Pi(t),Bind1:()=>Ei(t)};return{state:n=>r=>t.Applicative0().pure(n(r)),Monad0:()=>e}},or=(t,e)=>({tag:"ParseError",_1:t,_2:e}),L=(t,e,n)=>({tag:"ParseState",_1:t,_2:e,_3:n}),nc=(t,e,n)=>({tag:t,_1:e,_2:n}),xE=t=>nc("More",t),JE=t=>nc("Lift",t),wE={defer:t=>{const e=Zy(t);return(n,r,o,i,a)=>jy(e)(n,r,o,i,a)}},F0={map:t=>e=>(n,r,o,i,a)=>r(s=>e(n,r,o,i,(u,c)=>r(_=>a(u,t(c)))))},TE={alt:t=>e=>(n,r,o,i,a)=>{const s=n._1,u=n._2;return r(c=>t(L(s,u,!1),r,o,(_,f)=>{const l=_._3;return r(d=>l?i(_,f):e(n,r,o,i,a))},a))},Functor0:()=>F0},NE=t=>{const e=t.Monad0();return n=>r=>{const o=i=>{let a=i,s=!0,u;for(;s;){const c=a();if(c.tag==="More"){a=c._1;continue}if(c.tag==="Lift"){s=!1,u=e.Bind1().Apply0().Functor0().map(Sc)(c._1);continue}if(c.tag==="Stop"){s=!1,u=e.Applicative0().pure(Bi("Done",E(c._2,c._1)));continue}g()}return u};return t.tailRecM(o)(i=>r(n,xE,JE,(a,s)=>nc("Stop",a,Dt("Left",s)),(a,s)=>nc("Stop",a,Dt("Right",s))))}},Wn=(t,e,n,r,o)=>o(t,t._2),vE={index:0,line:1,column:1},z0=(t=>{const e=NE(t);return n=>r=>t.Monad0().Bind1().Apply0().Functor0().map(ws)(e(L(n,vE,!1))(r))})(S2),rc=(t,e,n,r,o)=>o(L(t._1,t._2,!0),void 0),I0={apply:t=>e=>(n,r,o,i,a)=>r(s=>t(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?L(u._1,u._2,!0):u;return e(f,r,o,i,(l,d)=>r(h=>a(f._3&&!l._3?L(l._1,l._2,!0):l,c(d))))}))),Functor0:()=>F0},Q0={pure:t=>(e,n,r,o,i)=>i(e,t),Apply0:()=>I0},bE={bind:t=>e=>(n,r,o,i,a)=>r(s=>t(n,r,o,i,(u,c)=>r(_=>e(c)(n._3&&!u._3?L(u._1,u._2,!0):u,r,o,i,a)))),Apply0:()=>I0},CE={Applicative0:()=>Q0,Bind1:()=>bE},oc=t=>(e,n,r,o,i)=>n(a=>Wn(e,n,r,o,(s,u)=>n(c=>o(e._3&&!s._3?L(s._1,s._2,!0):s,or(t,u))))),LE={empty:oc("No alternative"),Alt0:()=>TE},kE={Applicative0:()=>Q0,Plus1:()=>LE},Ie=(t=>e=>{const n=e.Plus1().Alt0(),r=e.Applicative0();return o=>t.tailRecM(i=>t.Monad0().Bind1().bind(n.alt(n.Functor0().map(Sc)(o))(r.pure(Bi("Done",void 0))))(a=>r.pure((()=>{if(a.tag==="Loop")return Bi("Loop",Jt("Cons",a._1,i));if(a.tag==="Done")return Bi("Done",(s=>u=>{let c=s,_=u,f=!0,l;for(;f;){const d=c,h=_;if(h.tag==="Nil"){f=!1,l=d;continue}if(h.tag==="Cons"){c=Jt("Cons",h._1,d),_=h._2;continue}g()}return l})(z)(i));g()})())))(z)})({tailRecM:t=>e=>(n,r,o,i,a)=>{const s=(u,c,_)=>t(c)(u,r,o,i,(f,l)=>{const d=u._3&&!f._3?L(f._1,f._2,!0):f;if(l.tag==="Loop")return _===0?r(h=>s(d,l._1,30)):s(d,l._1,_-1|0);if(l.tag==="Done")return a(d,l._1);g()});return s(n,e,30)},Monad0:()=>CE})(kE),xt=t=>e=>{const n=oc("Expected "+e);return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>t(L(u,c,!1),o,i,(f,l)=>{const d=f._3;return o(h=>d?a(f,l):n(r,o,i,a,s))},s))}},Eo=t=>(e,n,r,o,i)=>{const a=e._3,s=e._1,u=e._2;return n(c=>{const _=(f,l)=>{const d=f._3;return n(h=>d?o(L(f._1,f._2,a),l):i(e,void 0))};return n(f=>n(l=>t(L(s,u,!1),n,r,(d,h)=>_(L(d._1,d._2,!1),h),(d,h)=>n(m=>n(p=>oc("Negated parser succeeded")(d,n,r,_,(x,J)=>n(T=>i(d._3&&!x._3?L(x._1,x._2,!0):x,J))))))))})},SE=t=>{const e=t.foldr(n=>r=>{if(r.tag==="Nothing")return w("Just",n);if(r.tag==="Just")return w("Just",(o,i,a,s,u)=>{const c=o._1,_=o._2;return i(f=>n(L(c,_,!1),i,a,(l,d)=>{const h=l._3;return i(m=>h?s(l,d):r._1(o,i,a,s,u))},u))});g()})(y);return n=>{const r=e(n);if(r.tag==="Nothing")return oc("No alternative");if(r.tag==="Just")return r._1;g()}},M0=t=>e=>n=>(r,o,i,a,s)=>o(u=>o(c=>o(_=>o(f=>t(r,o,i,a,(l,d)=>o(h=>o(m=>{const p=r._3&&!l._3?L(l._1,l._2,!0):l;return n(p,o,i,a,(x,J)=>o(T=>{const N=p._3&&!x._3?L(x._1,x._2,!0):x;return o(k=>o(C=>{const P=r._3&&!N._3?L(N._1,N._2,!0):N;return e(P,o,i,a,(G,R)=>o(U=>s(P._3&&!G._3?L(G._1,G._2,!0):G,J)))}))}))}))))))),x1=t=>e=>n=>{if(e===10)return{index:t.index+1|0,line:t.line+1|0,column:1};if(e===13){const r=dJ()(n);return r.tag==="Just"&&r._1===10?{index:t.index+1|0,line:t.line,column:t.column}:{index:t.index+1|0,line:t.line+1|0,column:1}}return e===9?{index:t.index+1|0,line:t.line,column:(t.column+8|0)-go(t.column-1|0)(8)|0}:{index:t.index+1|0,line:t.line,column:t.column+1|0}},EE=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i,f=Hs(c);if(f.tag==="Nothing"){a=!1,s=u;continue}if(f.tag==="Just"){r=f._1.tail===""?x1(u)(f._1.head)(_):x1(u)(f._1.head)(f._1.tail),o=f._1.tail,i=_;continue}g()}return s},Gt=t=>(e,n,r,o,i)=>{const a=Hs(e._1);if(a.tag==="Nothing")return o(e,or("Unexpected EOF",e._2));if(a.tag==="Just"){if(a._1.head<0||a._1.head>65535)return o(e,or("Expected Char",e._2));if(a._1.head>=0&&a._1.head<=65535){const s=Hf(a._1.head);return t(s)?i(L(a._1.tail,x1(e._2)(a._1.head)(a._1.tail),!0),s):o(e,or("Predicate unsatisfied",e._2))}}g()},xa=(t,e,n,r,o)=>t._1===""?o(L(t._1,t._2,!0),void 0):r(t,or("Expected EOF",t._2)),PE=t=>(e,n,r,o,i)=>{const a=t(e._1);if(a.tag==="Left")return o(e,or(a._1,e._2));if(a.tag==="Right")return i(L(a._1.remainder,EE(e._2)(a._1.consumed)(a._1.remainder),a._1.consumed!==""),a._1.value);g()},Ee=t=>PE(e=>{const n=cr(t)(e);return n.tag==="Just"?Dt("Right",{value:t,consumed:t,remainder:n._1}):Dt("Left","Expected "+p2(t))}),J1=Gt(t=>!0),O0=(t,e)=>({tag:t,_1:e}),W0=(t,e,n)=>({tag:t,_1:e,_2:n}),GE=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},H0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},AE=t=>e=>v(n=>r=>(()=>{if(n.tag==="Left"){const o=n._1;return i=>Dt("Left",o)}if(n.tag==="Right"){const o=n._1;return i=>i(o)}g()})()(o=>t(o)(r)))(Dt("Right",e)),$0=t=>e=>n=>GE(t)(n.values)?Dt("Right",{...n,values:it(B)(t)(e)(n.values)}):Dt("Left","label has no placeholder `"+t+"`"),q0=(()=>{const t=Eo((e,n,r,o,i)=>{const a=e._3;return Ee("{{")(e,n,r,(s,u)=>o(L(s._1,s._2,a),u),i)});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>J1(e._3&&!s._3?L(s._1,s._2,!0):s,n,r,o,i))))})(),BE=(()=>{const t=Eo((e,n,r,o,i)=>{const a=e._3;return Ee("}}")(e,n,r,(s,u)=>o(L(s._1,s._2,a),u),i)});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>J1(e._3&&!s._3?L(s._1,s._2,!0):s,n,r,o,i))))})(),Ja=t=>Zn("")(Y(e=>{if(e.tag==="LabelText")return e._1;if(e.tag==="LabelSlot"){const n=H0(e._1)(t.values);if(n.tag==="Just")return n._1;if(n.tag==="Nothing")return""}g()})(t.parts)),RE=(t,e,n,r,o)=>e(i=>q0(t,e,n,r,(a,s)=>e(u=>{const c=Ie(q0),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?L(l._1,l._2,!0):l,W0("ParsedText",kn([s,...It(ge.foldr,d)]))))))}))),DE=t=>t===" "||t===" "||t===`
10
+ `||t==="\r",V0=(()=>{const t=Ie(Gt(DE));return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(s,void 0))))})(),FE=t=>t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_",zE=t=>t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"||t>="0"&&t<="9"||t==="-",IE=(t,e,n,r,o)=>e(i=>Gt(FE)(t,e,n,r,(a,s)=>e(u=>{const c=Ie(Gt(zE)),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?L(l._1,l._2,!0):l,Rn(s)+kn(It(ge.foldr,d))))))}))),QE=(t,e,n,r,o)=>e(i=>Ee("{{")(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?L(a._1,a._2,!0):a;return e(_=>V0(c,e,n,r,(f,l)=>e(d=>{const h=c._3&&!f._3?L(f._1,f._2,!0):f;return e(m=>IE(h,e,n,r,(p,x)=>e(J=>{const T=h._3&&!p._3?L(p._1,p._2,!0):p;return e(N=>V0(T,e,n,r,(k,C)=>e(P=>{const G=xt(Gt(U=>U===":"))("':'"),R=T._3&&!k._3?L(k._1,k._2,!0):k;return e(U=>G(R,e,n,r,(S,b)=>e(I=>{const H=Ie(BE),Q=R._3&&!S._3?L(S._1,S._2,!0):S;return e(q=>e($=>H(Q,e,n,r,(A,F)=>e(M=>{const W=kn(It(ge.foldr,F));return e(D=>{const X=Q._3&&!A._3?L(A._1,A._2,!0):A;return e(V=>Ee("}}")(X,e,n,r,(K,Z)=>e(tt=>o(X._3&&!K._3?L(K._1,K._2,!0):K,W0("ParsedSlot",x,Aa(W))))))})}))))})))})))})))})))}))),ME=(()=>{const t=Ie((e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>QE(L(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>f?o(c,_):RE(e,n,r,o,i))},i))});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(s,It(ge.foldr,u)))))})(),OE=t=>{const e=AE(n=>r=>{if(r.tag==="ParsedText")return Dt("Right",{...n,parts:Et(n.parts)(O0("LabelText",r._1))});if(r.tag==="ParsedSlot"){const o=H0(r._1)(n.values);return o.tag==="Just"&&o._1!==r._2?Dt("Left","placeholder `"+r._1+"` has conflicting initial values"):Dt("Right",{parts:Et(n.parts)(O0("LabelSlot",r._1)),values:it(B)(r._1)(r._2)(n.values)})}g()})({parts:[],values:O})(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",e._1);g()},ic=t=>{const e=z0(t)((n,r,o,i,a)=>r(s=>r(u=>ME(n,r,o,i,(c,_)=>r(f=>r(l=>{const d=n._3&&!c._3?L(c._1,c._2,!0):c;return xa(d,r,o,i,(h,m)=>r(p=>a(d._3&&!h._3?L(h._1,h._2,!0):h,_)))}))))));if(e.tag==="Left")return Dt("Left",e._1._1);if(e.tag==="Right")return OE(e._1);g()},Gi=(t,e)=>({tag:t,_1:e}),Or=(t,e)=>({tag:t,_1:e}),ac=t=>t,ir=(t,e)=>({tag:t,_1:e}),w1=t=>t,U0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},WE=fe(B)(Qt),K0=(()=>{const t=un.unfoldr(e=>{if(e.tag==="Nil")return y;if(e.tag==="Cons")return w("Just",E(e._1,e._2));g()});return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._3,n(r._6,o)));g()};return n(e,z)})())})(),Le=D0(Vn),HE=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},$E=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},qE=fe(B)(Qt),T1=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},VE=v(t=>e=>it(B)(e)()(t))(O),Kt=Ei(Vn),Ke=Le.state(t=>E(t,t)),ye=Pi(Vn),Y0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},X0=Do(ye),N1=X0(Qt),UE=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},wr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Tr=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},KE=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},sc=t=>e=>n=>v(r=>o=>t.Bind1().bind(r)(i=>e(i)(o)))(t.Applicative0().pure(n)),YE=v(t=>e=>it(B)(e)()(t))(O),XE=(()=>{const t=(e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=o;if(u.tag==="Nil"){i=!1,a=s;continue}if(u.tag==="Cons"){r=it(B)(u._1)()(s),o=u._2;continue}g()}return a})(O);return e=>t((()=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._3,n(r._6,o)));g()};return n(e,z)})())})(),ZE=v(t=>e=>it(B)(e)()(t))(O),jE=X0(H2),t4=w1("AnimatedSurface"),e4=w1("StillSurface"),n4=w1("SequenceSurface"),r4=ir("Exit"),uc=ac("AnimatedKeyframe"),v1=ac("Still"),o4=ac("Title"),Z0=ac("StepMarker"),i4=t=>Or("Par",t),a4=t=>Or("Seq",t),s4=t=>Or("GroupSeq",t),j0=t=>Gi("StepDive",t),u4={line:0,column:0,endLine:0,endColumn:0},c4=t=>e=>n=>{const r=zo(Xt,y,o=>o._1===t,n);if(r.tag==="Just"){const o=so(Xt,y,r._1,E(t,e),n);if(o.tag==="Nothing")return n;if(o.tag==="Just")return o._1;g()}if(r.tag==="Nothing")return Et(n)(E(t,e));g()},g4=t=>e=>Y(n=>n._1===t?E(n._1,{...n._2,label:w("Just",e)}):E(n._1,n._2)),tm=t=>WE(ht(e=>{const n=U0(e)(t.currLabels);return n.tag==="Just"?w("Just",E(e,n._1)):y})(K0(t.currNodes))),em=t=>{const e=t.compare;return n=>v(r=>o=>en(e,je,r,n(o)))(O)},b1=em(B),C1=em(B),nm=t=>e=>Le.state(n=>E(void 0,{...n,graphNodes:g4(t)(Ja(e))(n.graphNodes),currLabels:it(B)(t)(Ja(e))(n.currLabels),currLabelTemplates:it(B)(t)(e)(n.currLabelTemplates)})),_4=t=>{const e=t.span;return Le.state(n=>E(void 0,{...n,currentSpan:e}))},f4=ot(4)*8,d4=t=>t.tag==="Just"&&Na(t._1)&&t._1>0?E(HE(1)(t._1/f4),1):E(1,1),l4=t=>e=>({structural:[...t.structural,...e.structural],flow:t.flow||e.flow,dives:[...t.dives,...e.dives]}),h4=t=>e=>e.kind==="Animated"||$E(e.id)(t),rm={graphNodes:[],graphEdges:O,currNodes:O,currEdges:O,currLabels:O,currLabelTemplates:O,keyframes:[],scenes:[],kfCounter:0,eventCounter:0,currentKf:y,currentSpan:u4,error:y,enterStack:[],interiorOf:O,stepNames:O},om=t=>e=>n=>{const r=It(xn.foldr,n);return Zn(", ")(Y(e)(Bt(0,6,r)))+(r.length>6?", \u2026":"")},p4=t=>e=>{const n=T1(e)(qE(Y(r=>E(r.id,r))(t.graph.edges)));if(n.tag==="Just")return(()=>{const r=cr("conn:")(n._1.id);if(r.tag==="Just")return!1;if(r.tag==="Nothing")return!0;g()})()?n._1.from.node+" -> "+n._1.to.node:n._1.from.node+" -- "+n._1.to.node;if(n.tag==="Nothing")return e;g()},m4=t=>e=>n=>{const r=om()(wa)(e),o=om()(p4(t))(n);return(r===""?"animated flow contains unused topology: every animated node or edge must be visited by a token or fill.":"animated flow contains unused topology: every animated node or edge must be visited by a token or fill. Unused nodes: "+r+".")+(o===""?"":" Unused edges: "+o+".")+" Move context-only topology into a `still`/`title`, remove it, or add token/fill events."},y4=t=>{if(t.kind.tag==="SendToken")return VE([t.kind._1.from,t.kind._1.to]);if(t.kind.tag==="FillNodeWithoutTransition")return ee("Node",1,1,t.kind._1.node,void 0,O,O);g()},x4=t=>b1(y4)(t.events),J4=t=>{if(t.kind.tag==="SendToken")return ee("Node",1,1,t.kind._1.edge,void 0,O,O);if(t.kind.tag==="FillNodeWithoutTransition")return O;g()},w4=t=>C1(J4)(t.events),Nr=t=>Le.state(e=>E(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:w("Just",{msg:t,line:e.currentSpan.line,column:e.currentSpan.column,endLine:e.currentSpan.endLine,endColumn:e.currentSpan.endColumn})};g()})())),T4=N1(t=>Kt.bind(Ke)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing")return Y0(t.node)(e.interiorOf)?Nr("node "+t.node+" has more than one `inside` block"):Le.state(n=>E(void 0,{...n,interiorOf:it(B)(t.node)(t.doc)(n.interiorOf)}));g()})),N4=t=>Kt.bind(Ke)(e=>{const n=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ue(e.kfCounter);if(oe(o=>o.id===n,e.keyframes))return Nr("duplicate frame name "+n);const r={...e,keyframes:Et(e.keyframes)({id:n,nodes:e.currNodes,edges:e.currEdges,labels:tm(e),kind:Pa,authored:(()=>{if(t.tag==="Just")return t._1!=="";if(t.tag==="Nothing")return!1;g()})()}),kfCounter:e.kfCounter+1|0,currentKf:w("Just",n)};return Le.state(o=>E(void 0,r))}),We=t=>e=>Kt.bind(Le.state(n=>E(void 0,{...n,currentSpan:t})))(()=>Nr(e)),im=t=>e=>Kt.bind(Ke)(n=>UE(e)(n.stepNames)?We(t)("duplicate step name "+e):Le.state(r=>E(void 0,{...r,scenes:Et(r.scenes)(Oi("StepScene",e)),stepNames:it(B)(e)()(r.stepNames)}))),v4=t=>{if(t.ops.tag==="Leaf"){const e=t.ops._1;return Kt.bind((()=>{const n=e.span;return Le.state(r=>E(void 0,{...r,currentSpan:n}))})())(()=>e.op.tag==="Step"?im(e.span)(e.op._1.name):Nr("step marker frame did not contain a step"))}if(t.ops.tag==="Seq"&&t.ops._1.length===1&&t.ops._1[0].tag==="Leaf"){const e=t.ops._1[0]._1;return Kt.bind((()=>{const n=e.span;return Le.state(r=>E(void 0,{...r,currentSpan:n}))})())(()=>e.op.tag==="Step"?im(e.span)(e.op._1.name):Nr("step marker frame did not contain a step"))}return Nr("step marker frame did not contain a step")},b4=t=>Kt.bind((()=>{const e=t.span;return Le.state(n=>E(void 0,{...n,currentSpan:e}))})())(()=>Kt.bind(Ke)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing"){if(t.op.tag==="Enter"){if(!wr(t.op._1.id)(e.currNodes))return We(0<t.operands.length?t.operands[0]:t.span)("cannot dive into node "+t.op._1.id+": does not exist");if(!Y0(t.op._1.id)(e.interiorOf))return We(0<t.operands.length?t.operands[0]:t.span)("cannot enter node "+t.op._1.id+": it has no `inside` block. Add the block at the document level, alongside the animated statements:\n\ninside "+t.op._1.id+` {
11
11
  + detail: Detail
12
- }`);const n=t.op._1;return be.state(r=>S(void 0,{...r,enterStack:wt(r.enterStack)(n.id),scenes:wt(r.scenes)(Fi("EnterNode",n.id))}))}if(t.op.tag==="Exit"){const n=_r(e.enterStack);if(n.tag==="Nothing")return xr("`out` without a matching `into`");if(n.tag==="Just"){const r=n._1.init;return be.state(o=>S(void 0,{...o,enterStack:r,scenes:wt(o.scenes)(nx)}))}g()}return ye.pure()}g()})),ju={structural:[],flow:!1,dives:[]},K4=Ut.bind(Ve)(t=>{if(t.error.tag==="Just")return ye.pure();if(t.error.tag==="Nothing"){if(t.currentKf.tag==="Just"){const e=t.currentKf._1;return be.state(n=>S(void 0,{...n,scenes:wt(n.scenes)(Fi("Hold",e))}))}if(t.currentKf.tag==="Nothing")return ye.pure()}g()}),j4=t=>e=>Ut.bind(Ve)(n=>{const r="ev-"+ae(n.eventCounter);return Ut.bind((()=>{const o={...n,eventCounter:n.eventCounter+1|0};return be.state(i=>S(void 0,o))})())(()=>ye.pure({events:[{id:r,kind:e,when:t}],firstId:J("Just",r),lastId:J("Just",r)}))}),Z4=t=>t.tag==="DataFlow"?J("Just",t._1):T,tE=t=>Tt(e=>s1(e)(t.graphEdges))(Bt(Li,S0(t.currEdges))),eE=t=>e=>{const n=gt(o=>o.from.node===e.id||o.to.node===e.id,tE(t)),r=Yu(P1)(o=>i=>{const a=i.from+"->"+e.id,s=e.id+"->"+i.to,u=i.from+"->"+i.to,c="via "+i.from+" "+i.to+": no edge "+i.from+"\u2192"+e.id;if(!yr(a)(t.currEdges))return Dt("Left",c);const _="via "+i.from+" "+i.to+": no edge "+e.id+"\u2192"+i.to;if(!yr(s)(t.currEdges))return Dt("Left",_);const f="via "+i.from+" "+i.to+": would create "+i.from+"\u2192"+i.to+" but it already exists";return yr(u)(t.currEdges)||T4(u)(o.synthesized)?Dt("Left",f):Dt("Right",{consumed:it(R)(a)()(it(R)(s)()(o.consumed)),synthesized:it(R)(u)({id:u,from:{node:i.from,port:T},to:{node:i.to,port:T},label:T})(o.synthesized)})})({consumed:M,synthesized:M})(e.via);return(()=>{if(r.tag==="Left"){const o=r._1;return i=>Dt("Left",o)}if(r.tag==="Right"){const o=r._1;return i=>i(o)}g()})()(o=>{const i=o.consumed,a=gt(s=>!yr(s.id)(i),n);return a.length===0?Dt("Right",{nextCurrEdges:je(R.compare,Xe,lr(R.compare,t.currEdges,w4(V(s=>s.id)(n))),N4((()=>{const s=u=>{if(u.tag==="Leaf")return M;if(u.tag==="Node")return Zt("Node",u._1,u._2,u._3,void 0,s(u._5),s(u._6));g()};return s(o.synthesized)})())),synthesized:o.synthesized}):Dt("Left","cannot delete node "+e.id+": still connected ("+Vn(", ")(V(s=>(()=>{const u=rr("conn:")(s.id);if(u.tag==="Just")return!1;if(u.tag==="Nothing")return!0;g()})()?s.from.node+"\u2192"+s.to.node:s.from.node+"--"+s.to.node)(a))+"). Use `- a -> b` or `- a -- b` to drop them, or `via a b` to merge "+e.id+"'s endpoints.")})},M0=t=>e=>n=>{if(t){if(e){const i=0<n.operands.length?n.operands[0]:n.span,a=1<n.operands.length?n.operands[1]:n.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}}return 0<n.operands.length?n.operands[0]:n.span}if(e)return 1<n.operands.length?n.operands[1]:n.span;const r=0<n.operands.length?n.operands[0]:n.span,o=1<n.operands.length?n.operands[1]:n.span;return{line:r.line,column:r.column,endLine:o.endLine,endColumn:o.endColumn}},Q0=t=>{if(t.tag==="Leaf")return[t._1];if(t.tag==="Par"||t.tag==="Seq"||t.tag==="GroupSeq")return Et(t._1)(Q0);g()},nE=t=>({nodes:V(cs)(t.graphNodes),edges:(()=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,yt("Cons",n._4,e(n._6,r)));g()};return Bt(ce.foldr,e(t.graphEdges,D))})(),constraints:[]}),f1=t=>{if(t.tag==="Leaf")return t._1.op.tag==="AddNode"||t._1.op.tag==="DelNode"||t._1.op.tag==="ModNode"||t._1.op.tag==="ModNodeSlot"||t._1.op.tag==="AddEdge"||t._1.op.tag==="DelEdge"||t._1.op.tag==="RepointEdge"?{...ju,structural:[t._1]}:t._1.op.tag==="Enter"||t._1.op.tag==="Exit"?{...ju,dives:[t._1]}:{...ju,flow:!0};if(t.tag==="Seq"||t.tag==="GroupSeq"||t.tag==="Par")return v(B4)(ju)(V(f1)(t._1));g()},Zu=t=>{if(t.tag==="Leaf")return t._1.op.tag==="AddNode"||t._1.op.tag==="DelNode"||t._1.op.tag==="ModNode"||t._1.op.tag==="ModNodeSlot"||t._1.op.tag==="AddEdge"||t._1.op.tag==="DelEdge"||t._1.op.tag==="RepointEdge"?[Ci("StepStructural",[t._1])]:t._1.op.tag==="Enter"||t._1.op.tag==="Exit"?[Ci("StepDive",t._1)]:[Ci("StepFlow",t)];if(t.tag==="Seq")return Et(t._1)(Zu);if(t.tag==="GroupSeq")return oE(t)(t._1);if(t.tag==="Par")return rE(t)(t._1);g()},rE=t=>e=>{const n=f1(t);return n.structural.length!==0&&!n.flow&&n.dives.length===0?[Ci("StepStructural",n.structural)]:n.structural.length===0&&n.flow&&n.dives.length===0?[Ci("StepFlow",t)]:n.structural.length===0&&!n.flow&&n.dives.length!==0?V(R0)(n.dives):Et(e)(Zu)},oE=t=>e=>{const n=f1(t);return n.structural.length===0&&n.flow&&n.dives.length===0?[Ci("StepFlow",t)]:n.structural.length===0&&!n.flow&&n.dives.length!==0?V(R0)(n.dives):Et(e)(Zu)},iE=t=>e=>Ut.bind(Ve)(n=>{const r=e.from+"->"+e.to,o=e.newFrom+"->"+e.newTo;return yr(r)(n.currEdges)?mr(e.newFrom)(n.currNodes)?mr(e.newTo)(n.currNodes)?r!==o&&yr(o)(n.currEdges)?Qe((()=>{const i=2<t.operands.length?t.operands[2]:t.span,a=3<t.operands.length?t.operands[3]:t.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}})())("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": target edge already exists"):be.state(i=>S(void 0,{...i,currEdges:it(R)(o)()(Ai(R)(r)(i.currEdges)),graphEdges:it(R)(o)({id:o,from:{node:e.newFrom,port:T},to:{node:e.newTo,port:T},label:T})(i.graphEdges)})):Qe(3<t.operands.length?t.operands[3]:t.span)("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newTo):Qe(2<t.operands.length?t.operands[2]:t.span)("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newFrom):Qe((()=>{const i=0<t.operands.length?t.operands[0]:t.span,a=1<t.operands.length?t.operands[1]:t.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}})())("cannot repoint "+e.from+"\u2192"+e.to+": edge does not exist")}),aE=t=>e=>{const n=Tt(Z4)(e.scenes),r=gt(M4(J4(V(a=>a.keyframe)(n))),e.keyframes),o=lr(R.compare,g1(a=>a.nodes)(r),g1(O4)(n)),i=lr(R.compare,_1(a=>a.edges)(r),_1(V4)(n));return t!=="AnimatedSurface"||n.length===0||o.tag==="Leaf"&&i.tag==="Leaf"?T:J("Just",W4(e)(o)(i))},sE=t=>e=>{const n=e.to+"->"+e.from,r=e.from+"->"+e.to,o=e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;if(yr(r)(t.currEdges))return J("Just",{id:r,direction:lf});if(yr(n)(t.currEdges))return J("Just",{id:n,direction:df});const i=s1(o)(t.graphEdges);if(i.tag==="Just")return yr(o)(t.currEdges)?J("Just",{id:o,direction:i._1.from.node===e.from&&i._1.to.node===e.to?lf:df}):T;if(i.tag==="Nothing")return T;g()},uE=t=>e=>{if(e.op.tag==="Token"){const n=e.op._1;return Ut.bind(Ve)(r=>{const o=!mr(n.from)(r.currNodes),i=!mr(n.to)(r.currNodes);if(o||i)return Ut.bind(Qe(M0(o)(i)(e))(o?i?"token references unknown node: "+n.from+", "+n.to:"token references unknown node: "+n.from:i?"token references unknown node: "+n.to:"token references unknown node: "))(()=>ye.pure({events:[],firstId:T,lastId:T}));const a=sE(r)(n);if(a.tag==="Just")return j4(t)(jy("SendToken",{from:n.from,to:n.to,edge:a._1.id,direction:a._1.direction,labels:n.labels}));if(a.tag==="Nothing")return Ut.bind(Qe((()=>{const s=0<e.operands.length?e.operands[0]:e.span,u=1<e.operands.length?e.operands[1]:e.span;return{line:s.line,column:s.column,endLine:u.endLine,endColumn:u.endColumn}})())("token "+n.from+"\u2192"+n.to+": no edge between "+n.from+" and "+n.to))(()=>ye.pure({events:[],firstId:T,lastId:T}));g()})}return ye.pure({events:[],firstId:T,lastId:T})},cE=t=>e=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return ye.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Ut.bind(ns(t)(n._1.head))(o=>Ut.bind(Yu({Applicative0:()=>vi(Qn),Bind1:()=>Ji(Qn)})(i=>a=>Ut.bind(ns((()=>{if(i.lastId.tag==="Just")return Uc("After",i.lastId._1);if(i.lastId.tag==="Nothing")return t;g()})())(a))(s=>ye.pure({events:[...i.events,...s.events],firstId:(()=>{if(i.firstId.tag==="Just")return J("Just",i.firstId._1);if(i.firstId.tag==="Nothing")return s.firstId;g()})(),lastId:(()=>{if(s.lastId.tag==="Just")return J("Just",s.lastId._1);if(s.lastId.tag==="Nothing")return i.lastId;g()})()})))(o)(r))(i=>ye.pure(i)))}g()},gE=t=>e=>{const n=Pt(r=>T,r=>o=>J("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return ye.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Ut.bind(ns(t)(n._1.head))(o=>Ut.bind(_E((()=>{if(o.firstId.tag==="Just")return Uc("With",o.firstId._1);if(o.firstId.tag==="Nothing")return t;g()})())(r))(i=>ye.pure({events:[...o.events,...i.events],firstId:o.firstId,lastId:(()=>{if(o.lastId.tag==="Just")return J("Just",o.lastId._1);if(o.lastId.tag==="Nothing")return i.lastId;g()})()})))}g()},ns=t=>e=>{if(e.tag==="Leaf"){const n=e._1;return Ut.bind((()=>{const r=n.span;return be.state(o=>S(void 0,{...o,currentSpan:r}))})())(()=>uE(t)(n))}if(e.tag==="Seq"||e.tag==="GroupSeq")return cE(t)(e._1);if(e.tag==="Par")return gE(t)(e._1);g()},_E=t=>Yu({Applicative0:()=>vi(Qn),Bind1:()=>Ji(Qn)})(e=>n=>Ut.bind(ns(t)(n))(r=>ye.pure({events:[...e.events,...r.events],firstId:(()=>{if(e.firstId.tag==="Just")return J("Just",e.firstId._1);if(e.firstId.tag==="Nothing")return r.firstId;g()})(),lastId:(()=>{if(r.lastId.tag==="Just")return J("Just",r.lastId._1);if(r.lastId.tag==="Nothing")return e.lastId;g()})()})))({events:[],firstId:T,lastId:T}),fE=t=>Ut.bind(Ve)(e=>{if(e.currentKf.tag==="Nothing")return xr("flow ops before any structural frame");if(e.currentKf.tag==="Just"){const n=e.currentKf._1;return Ut.bind(ns(ex)(t))(r=>Ut.bind(Ve)(o=>{const i={...o,scenes:wt(o.scenes)(Fi("DataFlow",{keyframe:n,events:r.events,focus:T}))};return be.state(a=>S(void 0,i))}))}g()}),lE=t=>e=>be.state(n=>S(void 0,{...n,graphNodes:A4(t.id)({id:t.id,size:z4(t.width),ports:[],label:J("Just",ia(e)),shape:t.shape})(n.graphNodes),currNodes:it(R)(t.id)()(n.currNodes),currLabels:it(R)(t.id)(ia(e))(n.currLabels),currLabelTemplates:it(R)(t.id)(e)(n.currLabelTemplates)})),dE=t=>{if(t.op.tag==="AddNode"){const e=t.op._1;return Ut.bind(Ve)(n=>{if(mr(e.id)(n.currNodes))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot add node "+e.id+": already exists");const r=Uu(e.label);if(r.tag==="Left")return Qe(0<t.operands.length?t.operands[0]:t.span)("invalid label for node "+e.id+": "+r._1);if(r.tag==="Right")return lE(e)(r._1);g()})}if(t.op.tag==="DelNode"){const e=t.op._1;return Ut.bind(Ve)(n=>{if(!mr(e.id)(n.currNodes))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot delete node "+e.id+": does not exist");const r=eE(n)(e);if(r.tag==="Left")return Qe(0<t.operands.length?t.operands[0]:t.span)(r._1);if(r.tag==="Right"){const o=r._1;return be.state(i=>S(void 0,{...i,currNodes:Ai(R)(e.id)(i.currNodes),currEdges:o.nextCurrEdges,graphEdges:je(R.compare,Xe,o.synthesized,i.graphEdges)}))}g()})}if(t.op.tag==="ModNode"){const e=t.op._1;return Ut.bind(Ve)(n=>{if(!mr(e.id)(n.currNodes))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot relabel node "+e.id+": does not exist");if(e.label.tag==="Just"){const r=Uu(e.label._1);if(r.tag==="Left")return Qe(0<t.operands.length?t.operands[0]:t.span)("invalid label for node "+e.id+": "+r._1);if(r.tag==="Right")return F0(e.id)(r._1);g()}if(e.label.tag==="Nothing")return ye.pure();g()})}if(t.op.tag==="ModNodeSlot"){const e=t.op._1;return Ut.bind(Ve)(n=>{if(!mr(e.id)(n.currNodes))return Qe(0<t.operands.length?t.operands[0]:t.span)("cannot update placeholder on node "+e.id+": does not exist");const r=L0(e.id)(n.currLabelTemplates);if(r.tag==="Nothing")return Qe(1<t.operands.length?t.operands[1]:t.span)("node "+e.id+" label has no placeholder `"+e.slot+"`");if(r.tag==="Just"){const o=C0(e.slot)(e.value)(r._1);if(o.tag==="Left")return Qe(1<t.operands.length?t.operands[1]:t.span)("node "+e.id+" "+o._1);if(o.tag==="Right")return F0(e.id)(o._1)}g()})}if(t.op.tag==="AddEdge"){const e=t.op._1;return Ut.bind(Ve)(n=>{const r=!mr(e.from)(n.currNodes),o=!mr(e.to)(n.currNodes);if(r||o)return Qe(M0(r)(o)(t))((e.directed?"cannot add edge ":"cannot add connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": unknown node "+(r?o?e.from+", "+e.to:e.from:o?e.to:""));const i=e.directed?e.from+"->"+e.to:e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;return yr(i)(n.currEdges)?Qe((()=>{const a=0<t.operands.length?t.operands[0]:t.span,s=1<t.operands.length?t.operands[1]:t.span;return{line:a.line,column:a.column,endLine:s.endLine,endColumn:s.endColumn}})())((e.directed?"cannot add edge ":"cannot add connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": already exists"):be.state(a=>S(void 0,{...a,graphEdges:it(R)(i)({id:i,from:{node:e.from,port:T},to:{node:e.to,port:T},label:e.label})(a.graphEdges),currEdges:it(R)(i)()(a.currEdges)}))})}if(t.op.tag==="DelEdge"){const e=t.op._1;return Ut.bind(Ve)(n=>{const r=e.directed?e.from+"->"+e.to:e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;return yr(r)(n.currEdges)?be.state(o=>S(void 0,{...o,currEdges:Ai(R)(r)(o.currEdges)})):Qe((()=>{const o=0<t.operands.length?t.operands[0]:t.span,i=1<t.operands.length?t.operands[1]:t.span;return{line:o.line,column:o.column,endLine:i.endLine,endColumn:i.endColumn}})())((e.directed?"cannot delete edge ":"cannot delete connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": does not exist")})}return t.op.tag==="RepointEdge"?iE(t)(t.op._1):ye.pure()},hE=t=>Ut.bind((()=>{const e=t.span;return be.state(n=>S(void 0,{...n,currentSpan:e}))})())(()=>dE(t)),W0=t=>e=>n=>Ut.bind(u1(hE)(n))(()=>Ut.bind(Ve)(r=>{const o=e.tag==="Just"&&e._1!==""?e._1:"kf-"+ae(r.kfCounter);if(ue(a=>a.id===o,r.keyframes))return Ut.bind(v4(F4)(0<n.length?J("Just",n[0]):T))(()=>xr("duplicate frame name "+o));const i={...r,keyframes:wt(r.keyframes)({id:o,nodes:r.currNodes,edges:r.currEdges,labels:A0(r),kind:t}),kfCounter:r.kfCounter+1|0,currentKf:J("Just",o),scenes:(()=>{if(r.currentKf.tag==="Nothing")return r.scenes;if(r.currentKf.tag==="Just")return wt(r.scenes)(Fi("Structural",{from:r.currentKf._1,to:o,focus:T}));g()})()};return be.state(a=>S(void 0,i))})),pE=t=>e=>n=>{if(n.tag==="StepStructural")return Ut.bind((()=>{const r=W0(ma)(e?T:t)(n._1);return n._1.length!==0?r:ye.pure()})())(()=>ye.pure(!0));if(n.tag==="StepFlow"){const r=n._1,o=!e&&(()=>{if(t.tag==="Just")return t._1!=="";if(t.tag==="Nothing")return!1;g()})();return Ut.bind((()=>{const i=U4(t);return o?i:ye.pure()})())(()=>Ut.bind(fE(r))(()=>ye.pure(e||o)))}if(n.tag==="StepDive")return Ut.bind(Y4(n._1))(()=>ye.pure(e));g()},H0=t=>e=>n=>{const r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),n);if(r.tag==="Nothing")return ye.pure();if(r.tag==="Just"){const o=r._1.head,i=r._1.tail;return Ut.bind(Ve)(a=>{if(a.error.tag==="Just")return ye.pure();if(a.error.tag==="Nothing")return Ut.bind(pE(t)(e)(o))(s=>H0(t)(s)(i));g()})}g()},O0=t=>e=>{const n=Q0(e.ops),r=gt(i=>i.op.tag==="AddNode"||i.op.tag==="DelNode"||i.op.tag==="ModNode"||i.op.tag==="ModNodeSlot"||i.op.tag==="AddEdge"||i.op.tag==="DelEdge"||i.op.tag==="RepointEdge",n),o=gt(i=>!(i.op.tag==="AddNode"||i.op.tag==="DelNode"||i.op.tag==="ModNode"||i.op.tag==="ModNodeSlot"||i.op.tag==="AddEdge"||i.op.tag==="DelEdge"||i.op.tag==="RepointEdge"),n);return 0<o.length?Ut.bind((()=>{const i=o[0].span;return be.state(a=>S(void 0,{...a,currentSpan:i}))})())(()=>xr("still/title blocks hold a still snapshot; they cannot contain movement tokens (`api ~> db`) or dive commands (`into`/`out`)")):t==="TitleCard"&&r.length===0?xr(e.name.tag==="Just"&&e.name._1!==""?'title "'+e.name._1+'" has an empty body; give it nodes/edges to title, or use a still':"title has an empty body; give it nodes/edges to title, or use a still"):Ut.bind(W0(t)(e.name)(r))(()=>K4)},mE=t=>Ut.bind(Ve)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing"){if(t.kind==="AnimatedKeyframe")return H0(t.name)(!1)(Zu(t.ops));if(t.kind==="Still")return O0(Zy)(t);if(t.kind==="Title")return O0(tx)(t);if(t.kind==="StepMarker")return X4(t)}g()}),q0=t=>Ut.bind($4(t.interiors))(()=>Ut.bind(u1(mE)(t.frames))(()=>Ut.bind(Ve)(e=>{if(e.error.tag==="Just")return ye.pure(Dt("Left",e.error._1));if(e.error.tag==="Nothing"){const n=yE(t.interiors);if(n.tag==="Left")return ye.pure(Dt("Left",n._1));if(n.tag==="Right"){const r={seed:t.seed,minimumFontSize:t.minimumFontSize,stretchNodes:t.stretchNodes,graph:nE(e),keyframes:e.keyframes,scenes:e.scenes,interiors:n._1};return ye.pure((()=>{const o=aE(t.mode)(r);if(o.tag==="Just")return Dt("Left",{msg:o._1,line:0,column:0,endLine:0,endColumn:0});if(o.tag==="Nothing")return Dt("Right",r);g()})())}}g()}))),yE=t=>{const e=Yu(P1)(n=>r=>{const o=q0(r.doc)(D0)._1;return(()=>{if(o.tag==="Left"){const i=o._1;return a=>Dt("Left",i)}if(o.tag==="Right"){const i=o._1;return a=>a(i)}g()})()(i=>Dt("Right",it(R)(r.node)(i)(n)))})(M)(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",e._1);g()},tc=(t,e)=>({tag:t,_1:e}),l1=t4(Wt),xE=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},TE=fe(R)(Wt),V0=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},rs=(()=>{const t=pt(At(r=>r==="}"))("'}'"),e=pt(At(r=>r==="#"))("'#'"),n=At(r=>r===`
13
- `||r==="\r");return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>o(f=>t(k(u,c,!1),o,i,(l,d)=>o(h=>{const p=r._1,m=r._2;return o(x=>o(y=>e(k(p,m,!1),o,i,(w,N)=>o(b=>{const C=r._1,L=r._2;return o(E=>o(I=>n(k(C,L,!1),o,i,(W,P)=>o(G=>oa(r,o,i,a,s)),(W,P)=>o(G=>s(k(C,L,!1),void 0)))))}),(w,N)=>o(b=>s(k(p,m,!1),void 0)))))}),(l,d)=>o(h=>s(k(u,c,!1),void 0)))))}})(),bn=t=>(e,n,r,o,i)=>n(a=>Dn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>t(_,n,r,o,(l,d)=>n(h=>{const p=_._3&&!l._3?k(l._1,l._2,!0):l;return n(m=>Dn(p,n,r,o,(x,y)=>n(w=>i(p._3&&!x._3?k(x._1,x._2,!0):x,S(d,{line:u.line,column:u.column,endLine:y.line,endColumn:y.column})))))})))}))),wE=(()=>{const t=At(e=>e===" "||e===" "||e===`
14
- `||e==="\r");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?k(s._1,s._2,!0):s,void 0))))})(),$0=(t,e,n,r,o)=>e(i=>Le("#")(t,e,n,r,(a,s)=>e(u=>{const c=ze(At(f=>f!==`
15
- `)),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?k(l._1,l._2,!0):l,void 0))))}))),U0=pt((()=>{const t=pt(At(n=>n==="}"))("'}'"),e=At(n=>n===`
16
- `||n==="\r");return(n,r,o,i,a)=>{const s=n._1,u=n._2;return r(c=>r(_=>t(k(s,u,!1),r,o,(f,l)=>r(d=>{const h=n._1,p=n._2;return r(m=>r(x=>$0(k(h,p,!1),r,o,(y,w)=>{const N=y._3;return r(b=>{if(N)return i(y,w);const C=n._1,L=n._2;return r(E=>r(I=>e(k(C,L,!1),r,o,(W,P)=>{const G=W._3;return r(j=>G?i(W,P):oa(n,r,o,i,a))},(W,P)=>r(G=>a(W,void 0)))))})},(y,w)=>r(N=>a(y,void 0)))))}),(f,l)=>r(d=>a(k(s,u,!1),void 0)))))}})())("newline or '}' (statements end at the end of the line)"),yn=(()=>{const t=ze((e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>wE(k(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>f?o(c,_):$0(e,n,r,o,i))},i))});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?k(s._1,s._2,!0):s,void 0))))})(),X0=(()=>{const t=At(e=>e!=="|");return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>n(c=>Le("\\|")(k(a,s,!1),n,r,(_,f)=>n(l=>n(d=>t(e,n,r,o,(h,p)=>n(m=>i(h,En(p)))))),(_,f)=>n(l=>i(_,"|")))))}})(),NE=pt(l1([(t,e,n,r,o)=>e(i=>{const a=t._3;return Le("->")(t,e,n,(s,u)=>r(k(s._1,s._2,a),u),(s,u)=>e(c=>o(s,!0)))}),(t,e,n,r,o)=>e(i=>{const a=t._3;return Le("--")(t,e,n,(s,u)=>r(k(s._1,s._2,a),u),(s,u)=>e(c=>o(s,!1)))})]))("edge arrow '->' or '--'"),JE=t=>t!==`
17
- `&&t!=="\r"&&t!=="#"&&t!=="}"&&t!=="{",ec=At(t=>t>="a"&&t<="z"||t>="A"&&t<="Z"),vE=t=>t===" "||t===" "||t==="\r",CE=t=>Jn(ee(Cr(vE)(ee(Hn(t))).rest)),d1=t=>t===`
18
- `||t==="\r"||t==="#"||t==="}",bE=t=>t===`
19
- `||t==="\r"||t==="#"||t==="}"||t==="{",kE=t=>t!=="{"&&t!==`
20
- `&&t!=="\r",Y0=t=>Na(t)==="",LE=t=>ee(Cr(Y0)(ee(Cr(Y0)(t).rest)).rest),SE=t=>(e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=Pt(c=>T,c=>_=>J("Just",{head:c,tail:_}),o);if(u.tag==="Just"&&(u._1.head===" "||u._1.head===" ")){r=s+1|0,o=u._1.tail;continue}i=!1,a=s}return a})(0)(Hn(t)),EE=t=>{const e=Pt(n=>T,n=>r=>J("Just",{head:n,tail:r}),V(SE)(gt(n=>Na(n)!=="",t)));if(e.tag==="Nothing")return 0;if(e.tag==="Just")return v(xE)(e._1.head)(e._1.tail);g()},PE=(()=>{const t=pt(At(e=>e==="-"))("'-'");return(e,n,r,o,i)=>{const a=e._3;return n(s=>t(e,n,r,(u,c)=>o(k(u._1,u._2,a),c),(u,c)=>n(_=>{const f=bo((()=>{const d=pt(At(p=>p===">"))("'>'"),h=pt(At(p=>p==="-"))("'-'");return(p,m,x,y,w)=>{const N=p._1,b=p._2;return m(C=>d(k(N,b,!1),m,x,(L,E)=>{const I=L._3;return m(W=>I?y(L,E):h(p,m,x,y,w))},w))}})()),l=e._3&&!u._3?k(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,p)=>o(k(h._1,h._2,a),p),(h,p)=>n(m=>i(l._3&&!h._3?k(h._1,h._2,!0):h,"-"))))})))}})(),oe=(()=>{const t=ze(At(e=>e===" "||e===" "));return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?k(s._1,s._2,!0):s,void 0))))})(),ko=(()=>{const t=At(e=>e===" "||e===" ");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>oe(e._3&&!s._3?k(s._1,s._2,!0):s,n,r,o,i))))})(),K0=(t,e,n,r,o)=>e(i=>e(a=>oe(t,e,n,r,(s,u)=>e(c=>e(_=>{const f=t._3&&!s._3?k(s._1,s._2,!0):s;return rs(f,e,n,r,(l,d)=>e(h=>o(f._3&&!l._3?k(l._1,l._2,!0):l,d)))}))))),j0=(t,e,n,r,o)=>e(i=>oe(t,e,n,r,(a,s)=>e(u=>{const c=pt(At(f=>f==="-"))("'-'"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>{const l=(p,m)=>e(x=>(()=>{if(m.tag==="Just")return(y,w,N,b,C)=>w(L=>NE(y,w,N,b,(E,I)=>w(W=>C(E,J("Just",I)))));if(m.tag==="Nothing")return(y,w,N,b,C)=>C(y,T);g()})()(_._3&&!p._3?k(p._1,p._2,!0):p,e,n,r,o)),d=_._1,h=_._2;return e(p=>e(m=>c(k(d,h,!1),e,n,(x,y)=>e(w=>l(_,T)),(x,y)=>e(w=>l(k(d,h,!1),J("Just",y))))))})}))),GE=t=>{const e=rr("Expected ")(t),n=(()=>{if(e.tag==="Nothing")return t;if(e.tag==="Just")return e._1;g()})();return n==="'{'"?"Open the block with `{`.":n==="integer (seed value)"?"Put an integer after `seed`.":n==="number (min-font-size value)"?"Put a positive number after `min-font-size`.":n==="positive min-font-size value"?"`min-font-size` must be greater than zero.":n==="closing '}'"?"Close this block with `}`.":n===`closing '"' (unterminated string)`?'This string is unterminated; close it with `"`.':n==="closing '|'"?"Close this pipe label with `|`.":n==="space after '+'"?"Put a space after `+`: `+ api: API`.":n==="node identifier after '+'"?"Put a node id after `+`: `+ api: API`.":n==="space after '-'"?"Put a space after `-`: `- api`.":n==="node identifier after '-'"?"Put a node id after `-`: `- api`.":n==="space after '~'"?"Put a space after `~`: `~ api: API` or `~ api -> db => api -> cache`.":n==="node relabel label"?"Give the replacement label after `~ api`: `~ api: API`.":n==="node placeholder value"?"Give the replacement value after the placeholder name: `~ total.count: 3`.":n==="node identifier"?"Put a node identifier here.":n==="space after 'inside'"?"Put a space after `inside`: `inside api { ... }`.":n==="node identifier after 'inside'"?"Tell `inside` which node owns this interior: `inside api { ... }`.":n==="source node identifier after 'via'"?"Put the source node after `via`: `via a b`.":n==="target node identifier after 'via'"?"Put the second endpoint after `via`: `via a b`.":n==="source node identifier"?"Put a source node identifier here.":n==="new source node identifier"?"Put the new source node identifier after `=>`.":n==="new target node identifier"?"Put the new target node identifier after the replacement arrow.":n==="edge arrow '->' or '--'"?"Use `->` for a directed edge or `--` for an undirected edge.":n==="source edge arrow '->'"?"Use `->` in the edge you are changing: `~ api -> db => api -> cache`.":n==="replacement edge arrow '->'"?"Use `->` in the replacement edge: `~ api -> db => api -> cache`.":n==="repoint separator '=>'"?"Use `=>` before the replacement edge: `~ api -> db => api -> cache`.":n==="target node identifier"?"Put a target node after the arrow.":n==="'~>'"?"Use `~>` for movement from left to right.":n==="'<~'"?"Use `<~` for movement from right to left.":n==="'->' or '<-'"?"Use `~>` / `<~` for movement tokens.":n==='label ("\u2026", : rest-of-line, or |\u2026|)'?'label must use `: text`, `"text"`, or `|multi-line|`.':n==="attribute key"?"Start each attribute with a name, like `shape`.":n==="':'"?"Put `:` between the attribute name and value: `{shape: cylinder}`.":n==="attribute value"?"Put an attribute value after `:`.":n==="closing '}' for attributes"?"Close the attribute block with `}`.":n==="space after 'into'"?"Put a space after `into`: `into api`.":n==="node identifier after 'into'"?"Tell `into` which node to dive into.":n==="space after 'step'"?"Put a space after `step`: `step request`.":n==="step name"?"Name the step: `step request`.":n==="newline or '}' (statements end at the end of the line)"?"This statement has extra text. Put the next statement on a new line or close the block with `}`.":n==="statement (+ node, - node, + edge, - edge, ~ node, into, out, or 'a ~> b'/'a <~ b')"?"I don't recognize this statement. Start with `+`, `-`, `~`, `into`, `out`, `par`, `seq`, or movement like `api ~> db`.":n==="'scene', 'still', 'title', 'step', 'inside', a statement, or end of input"?"Start with a statement like `+ api: API`, a marker like `step request`, or a block with `scene`, `still`, `title`, or `inside`.":n},RE=t=>{const e=Na(t),n=rr('"')(e),r=(()=>{if(n.tag==="Just")return Ay('"')(n._1);if(n.tag==="Nothing")return T;g()})(),o=(()=>{if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()})();return o===""?T:J("Just",o)},Z0=t=>e=>t!=="AnimatedSurface"&&e.statements.length!==0?{...e,frames:wt(e.frames)((()=>{if(t==="StillSurface")return{name:T,ops:Qr("Seq",e.statements),kind:c1};if(t==="SequenceSurface")return{name:T,ops:Qr("Seq",e.statements),kind:Ku};if(t==="AnimatedSurface")return{name:T,ops:Qr("Seq",e.statements),kind:Ku};g()})()),statements:[]}:e,AE=(()=>{const t=pt(At(e=>e==="\\"))("'\\\\'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>i1(_,n,r,o,(l,d)=>n(h=>i(_._3&&!l._3?k(l._1,l._2,!0):l,d==="n"?`
21
- `:d==="t"?" ":d==="r"?"\r":d))))})))})(),IE=(()=>{const t=At(e=>e!=='"'&&e!=="\\"&&e!==`
22
- `);return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>AE(k(a,s,!1),n,r,(c,_)=>n(f=>t(e,n,r,o,i)),i))}})(),tm=(()=>{const t=pt(At(e=>e==='"'))(`'"'`);return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=ze(IE),f=e._3&&!s._3?k(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(p=>{const m=pt(pt(At(y=>y==='"'))(`'"'`))(`closing '"' (unterminated string)`),x=f._3&&!d._3?k(d._1,d._2,!0):d;return n(y=>m(x,n,r,o,(w,N)=>n(b=>i(x._3&&!w._3?k(w._1,w._2,!0):w,Jn(Bt(ce.foldr,h))))))})))})))})(),FE={frames:[],statements:[]},em=t=>{const e=LE(zi(`
23
- `)(t));return Vn(`
24
- `)(V(CE)(V(Ii(EE(e)))(e)))},DE=(t,e,n,r,o)=>{const i=t._3;return e(a=>Le("|md")(t,e,n,(s,u)=>r(k(s._1,s._2,i),u),(s,u)=>e(c=>{const _=pt((l,d,h,p,m)=>{const x=l._1,y=l._2;return d(w=>Le(`\r
25
- `)(k(x,y,!1),d,h,(N,b)=>{const C=N._3;return d(L=>{if(C)return p(N,b);const E=l._1,I=l._2;return d(W=>Le(`
26
- `)(k(E,I,!1),d,h,(P,G)=>{const j=P._3;return d(nt=>j?p(P,G):Le("\r")(l,d,h,p,m))},m))})},m))})("newline after '|md'"),f=t._3&&!s._3?k(s._1,s._2,!0):s;return e(l=>_(f,e,n,(d,h)=>r(k(d._1,d._2,i),h),(d,h)=>e(p=>{const m=ze(X0),x=f._3&&!d._3?k(d._1,d._2,!0):d;return e(y=>m(x,e,n,(w,N)=>r(k(w._1,w._2,i),N),(w,N)=>e(b=>{const C=pt(pt(At(E=>E==="|"))("'|'"))("closing '|'"),L=x._3&&!w._3?k(w._1,w._2,!0):w;return e(E=>C(L,e,n,(I,W)=>r(k(I._1,I._2,i),W),(I,W)=>e(P=>o(L._3&&!I._3?k(I._1,I._2,!0):I,"md:"+em(Vn("")(Bt(ce.foldr,N)))))))})))})))})))},zE=(()=>{const t=pt(At(e=>e==="|"))("'|'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=ze(X0),f=e._3&&!s._3?k(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(p=>{const m=pt(pt(At(y=>y==="|"))("'|'"))("closing '|'"),x=f._3&&!d._3?k(d._1,d._2,!0):d;return n(y=>m(x,n,r,o,(w,N)=>n(b=>i(x._3&&!w._3?k(w._1,w._2,!0):w,em(Vn("")(Bt(ce.foldr,h)))))))})))})))})(),Tr=At(t=>t>="0"&&t<="9"),BE=(()=>{const t=pt(At(e=>e==="_"))("'_'");return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>ec(k(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>{if(f)return o(c,_);const d=e._1,h=e._2;return n(p=>Tr(k(d,h,!1),n,r,(m,x)=>{const y=m._3;return n(w=>{if(y)return o(m,x);const N=e._1,b=e._2;return n(C=>t(k(N,b,!1),n,r,(L,E)=>{const I=L._3;return n(W=>I?o(L,E):PE(e,n,r,o,i))},i))})},i))})},i))}})(),We=(()=>{const t=pt(At(e=>e==="_"))("'_'");return(e,n,r,o,i)=>n(a=>{const s=(_,f)=>n(l=>{const d=ze(BE),h=e._3&&!_._3?k(_._1,_._2,!0):_;return n(p=>d(h,n,r,o,(m,x)=>n(y=>i(h._3&&!m._3?k(m._1,m._2,!0):m,En(f)+Jn(Bt(ce.foldr,x))))))}),u=e._1,c=e._2;return n(_=>ec(k(u,c,!1),n,r,(f,l)=>{const d=f._3;return n(h=>d?o(f,l):t(e,n,r,o,s))},s))})})(),ME=t=>e=>n=>(r,o,i,a,s)=>o(u=>oe(r,o,i,a,(c,_)=>o(f=>{const l=bn(pt(We)("target node identifier")),d=r._3&&!c._3?k(c._1,c._2,!0):c;return o(h=>l(d,o,i,a,(p,m)=>o(x=>s(d._3&&!p._3?k(p._1,p._2,!0):p,{op:er("DelEdge",{from:t,to:m._1,directed:n}),operands:[e,m._2]}))))}))),QE=(t,e,n,r,o)=>e(i=>Dn(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?k(a._1,a._2,!0):a;return e(_=>{const f=c._3;return e(l=>We(c,e,n,(d,h)=>r(k(d._1,d._2,f),h),(d,h)=>e(p=>{const m=c._3&&!d._3?k(d._1,d._2,!0):d;return e(x=>oe(m,e,n,(y,w)=>r(k(y._1,y._2,f),w),(y,w)=>e(N=>{const b=m._3&&!y._3?k(y._1,y._2,!0):y;return e(C=>{const L=(W,P)=>e(G=>{const j=b._3&&!W._3?k(W._1,W._2,!0):W;return e(nt=>r(c._3&&!j._3?k(j._1,j._2,!0):j,tr("Use `~>` / `<~` for movement tokens.",s)))}),E=b._1,I=b._2;return e(W=>Le("->")(k(E,I,!1),e,n,(P,G)=>{const j=P._3;return e(nt=>j?r(k(P._1,P._2,f),G):Le("<-")(b,e,n,(O,$)=>r(k(O._1,O._2,f),$),L))},L))})})))})))})}))),WE=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>bn(We)(t,e,n,(u,c)=>r(k(u._1,u._2,a),c),(u,c)=>e(_=>{const f=t._3&&!u._3?k(u._1,u._2,!0):u;return e(l=>oe(f,e,n,(d,h)=>r(k(d._1,d._2,a),h),(d,h)=>e(p=>{const m=pt(At(y=>y==="~"))("'~'"),x=f._3&&!d._3?k(d._1,d._2,!0):d;return e(y=>{const w=(C,L)=>e(E=>{const I=x._3&&!C._3?k(C._1,C._2,!0):C;return e(W=>{const P=c._1,G=c._2,j=t._3&&!I._3?k(I._1,I._2,!0):I;return e(nt=>oe(j,e,n,r,(O,$)=>e(H=>{const A=pt(At(Q=>Q==="~"))("'~'"),B=pt(At(Q=>Q==="<"))("'<'"),z=j._3&&!O._3?k(O._1,O._2,!0):O;return e(Q=>{const F=(U,Y)=>e(ot=>{const Z=Y==="~"?pt(Le("~>"))("'~>'"):pt(Le("<~"))("'<~'"),ft=z._3&&!U._3?k(U._1,U._2,!0):U;return e(Lt=>Z(ft,e,n,r,(dt,Nt)=>e(St=>o(ft._3&&!dt._3?k(dt._1,dt._2,!0):dt,S(P,S(G,Nt))))))}),X=z._1,q=z._2;return e(U=>A(k(X,q,!1),e,n,(Y,ot)=>{const Z=Y._3;return e(ft=>Z?r(z,ot):B(z,e,n,(Lt,dt)=>r(z,dt),(Lt,dt)=>F(z,dt)))},(Y,ot)=>F(z,ot)))})})))})}),N=x._1,b=x._2;return e(C=>m(k(N,b,!1),e,n,(L,E)=>{const I=L._3;return e(W=>I?r(k(x._1,x._2,a),E):e(P=>Le("<~")(x,e,n,(G,j)=>r(k(x._1,x._2,a),j),(G,j)=>e(nt=>w(x)))))},(L,E)=>w(x)))})})))})))}),HE=t=>e=>{const n=pt(Le("->"))("source edge arrow '->'");return(r,o,i,a,s)=>o(u=>n(r,o,i,a,(c,_)=>o(f=>{const l=r._3&&!c._3?k(c._1,c._2,!0):c;return o(d=>oe(l,o,i,a,(h,p)=>o(m=>{const x=bn(pt(We)("target node identifier")),y=l._3&&!h._3?k(h._1,h._2,!0):h;return o(w=>x(y,o,i,a,(N,b)=>o(C=>{const L=b._1,E=b._2,I=y._3&&!N._3?k(N._1,N._2,!0):N;return o(W=>oe(I,o,i,a,(P,G)=>o(j=>{const nt=pt(Le("=>"))("repoint separator '=>'"),O=I._3&&!P._3?k(P._1,P._2,!0):P;return o($=>nt(O,o,i,a,(H,A)=>o(B=>{const z=O._3&&!H._3?k(H._1,H._2,!0):H;return o(Q=>oe(z,o,i,a,(F,X)=>o(q=>{const U=bn(pt(We)("new source node identifier")),Y=z._3&&!F._3?k(F._1,F._2,!0):F;return o(ot=>U(Y,o,i,a,(Z,ft)=>o(Lt=>{const dt=ft._1,Nt=ft._2,St=Y._3&&!Z._3?k(Z._1,Z._2,!0):Z;return o(te=>oe(St,o,i,a,(Jt,Yt)=>o(Ft=>{const vt=pt(Le("->"))("replacement edge arrow '->'"),mt=St._3&&!Jt._3?k(Jt._1,Jt._2,!0):Jt;return o(lt=>vt(mt,o,i,a,(xt,It)=>o(ht=>{const Ct=mt._3&&!xt._3?k(xt._1,xt._2,!0):xt;return o(Qt=>oe(Ct,o,i,a,(zt,ie)=>o(_e=>{const cn=bn(pt(We)("new target node identifier")),qt=Ct._3&&!zt._3?k(zt._1,zt._2,!0):zt;return o(jt=>cn(qt,o,i,a,(en,He)=>o(Bn=>s(qt._3&&!en._3?k(en._1,en._2,!0):en,{op:er("RepointEdge",{from:t,to:L,newFrom:dt,newTo:He._1}),operands:[e,E,Nt,He._2]}))))})))})))})))})))})))})))})))})))})))})))},OE=(t,e,n,r,o)=>e(i=>Tr(t,e,n,r,(a,s)=>e(u=>{const c=ze(Tr),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const p=W2(En(s)+Jn(Bt(ce.foldr,d)));return(()=>{if(p.tag==="Just"){const m=p._1;return(x,y,w,N,b)=>b(x,m)}if(p.tag==="Nothing")return(m,x,y,w,N)=>N(m,0);g()})()(_._3&&!l._3?k(l._1,l._2,!0):l,e,n,r,o)})))}))),nm=t=>(e,n,r,o,i)=>{const a=e._3;return n(s=>Le(t)(e,n,r,(u,c)=>o(k(u._1,u._2,a),c),(u,c)=>n(_=>{const f=bo((()=>{const d=pt(At(p=>p==="_"))("'_'"),h=pt(At(p=>p==="-"))("'-'");return(p,m,x,y,w)=>{const N=p._1,b=p._2;return m(C=>ec(k(N,b,!1),m,x,(L,E)=>{const I=L._3;return m(W=>{if(I)return y(L,E);const P=p._1,G=p._2;return m(j=>Tr(k(P,G,!1),m,x,(nt,O)=>{const $=nt._3;return m(H=>{if($)return y(nt,O);const A=p._1,B=p._2;return m(z=>d(k(A,B,!1),m,x,(Q,F)=>{const X=Q._3;return m(q=>X?y(Q,F):h(p,m,x,y,w))},w))})},w))})},w))}})()),l=e._3&&!u._3?k(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,p)=>o(k(h._1,h._2,a),p),(h,p)=>n(m=>{const x=l._3&&!h._3?k(h._1,h._2,!0):h;return n(y=>yn(x,n,r,(w,N)=>o(k(w._1,w._2,a),N),(w,N)=>n(b=>i(x._3&&!w._3?k(w._1,w._2,!0):w,t))))})))})))},qE=(t,e,n,r,o)=>e(i=>nm("stretch-nodes")(t,e,n,r,(a,s)=>e(u=>o(a,void 0)))),VE=(t,e,n,r,o)=>e(i=>e(a=>Tr(t,e,n,r,(s,u)=>e(c=>{const _=ze(Tr),f=t._3&&!s._3?k(s._1,s._2,!0):s;return e(l=>_(f,e,n,r,(d,h)=>e(p=>{const m=f._3&&!d._3?k(d._1,d._2,!0):d,x=En(u)+Jn(Bt(ce.foldr,h));return e(y=>{const w=pt(At(b=>b==="."))("'.'"),N=t._3&&!m._3?k(m._1,m._2,!0):m;return e(b=>{const C=(I,W)=>e(P=>{const G=Cc((()=>{if(W.tag==="Nothing")return x+"";if(W.tag==="Just")return x+W._1;g()})(),ga,Vt,T);return(()=>{if(G.tag==="Just"){const j=G._1;return(nt,O,$,H,A)=>A(nt,j)}if(G.tag==="Nothing")return(j,nt,O,$,H)=>H(j,0);g()})()(N._3&&!I._3?k(I._1,I._2,!0):I,e,n,r,o)}),L=N._1,E=N._2;return e(I=>e(W=>{const P=(G,j)=>{const nt=G._3;return e(O=>nt?r(G,j):C(N,T))};return e(G=>w(k(L,E,!1),e,n,P,(j,nt)=>e(O=>e($=>e(H=>Tr(j,e,n,P,(A,B)=>e(z=>{const Q=ze(Tr),F=j._3&&!A._3?k(A._1,A._2,!0):A;return e(X=>Q(F,e,n,P,(q,U)=>e(Y=>{const ot=F._3&&!q._3?k(q._1,q._2,!0):q,Z=En(B)+Jn(Bt(ce.foldr,U));return e(ft=>{const Lt=j._3&&!ot._3?k(ot._1,ot._2,!0):ot,dt=En(nt)+Z;return e(Nt=>C(Lt,J("Just",dt)))})})))})))))))}))})})})))})))),$E=(t,e,n,r,o)=>e(i=>Tr(t,e,n,r,(a,s)=>e(u=>{const c=ze((()=>{const f=pt(At(l=>l==="."))("'.'");return(l,d,h,p,m)=>{const x=l._1,y=l._2;return d(w=>Tr(k(x,y,!1),d,h,(N,b)=>{const C=N._3;return d(L=>C?p(N,b):f(l,d,h,p,m))},m))}})()),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?k(l._1,l._2,!0):l,En(s)+Jn(Bt(ce.foldr,d))))))}))),kn=t=>(e,n,r,o,i)=>{const a=e._3;return n(s=>Le(t)(e,n,r,(u,c)=>o(k(u._1,u._2,a),c),(u,c)=>n(_=>{const f=bo((()=>{const d=pt(At(p=>p==="_"))("'_'"),h=pt(At(p=>p==="-"))("'-'");return(p,m,x,y,w)=>{const N=p._1,b=p._2;return m(C=>ec(k(N,b,!1),m,x,(L,E)=>{const I=L._3;return m(W=>{if(I)return y(L,E);const P=p._1,G=p._2;return m(j=>Tr(k(P,G,!1),m,x,(nt,O)=>{const $=nt._3;return m(H=>{if($)return y(nt,O);const A=p._1,B=p._2;return m(z=>d(k(A,B,!1),m,x,(Q,F)=>{const X=Q._3;return m(q=>X?y(Q,F):h(p,m,x,y,w))},w))})},w))})},w))}})()),l=e._3&&!u._3?k(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,p)=>o(k(h._1,h._2,a),p),(h,p)=>n(m=>i(l._3&&!h._3?k(h._1,h._2,!0):h,void 0))))})))},UE=(t,e,n,r,o)=>e(i=>kn("into")(t,e,n,r,(a,s)=>e(u=>{const c=pt(ko)("space after 'into'"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const p=bn(pt(We)("node identifier after 'into'")),m=_._3&&!l._3?k(l._1,l._2,!0):l;return e(x=>p(m,e,n,r,(y,w)=>e(N=>o(m._3&&!y._3?k(y._1,y._2,!0):y,{op:er("Enter",{id:w._1}),operands:[w._2]}))))})))}))),XE=(t,e,n,r,o)=>e(i=>Dn(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?k(a._1,a._2,!0):a;return e(_=>kn("min-font-size")(c,e,n,r,(f,l)=>e(d=>{const h=c._3&&!f._3?k(f._1,f._2,!0):f;return e(p=>oe(h,e,n,r,(m,x)=>e(y=>{const w=pt(VE)("number (min-font-size value)"),N=h._3&&!m._3?k(m._1,m._2,!0):m;return e(b=>w(N,e,n,r,(C,L)=>e(E=>(L>0?((I,W,P,G,j)=>W(nt=>yn(I,W,P,G,(O,$)=>W(H=>j(O,L))))):(I,W,P,G,j)=>G(I,tr("positive min-font-size value",s)))(N._3&&!C._3?k(C._1,C._2,!0):C,e,n,r,o))))})))})))}))),YE=(t,e,n,r,o)=>e(i=>kn("out")(t,e,n,r,(a,s)=>e(u=>o(t._3&&!a._3?k(a._1,a._2,!0):a,{op:L4,operands:[]})))),KE=(t,e,n,r,o)=>e(i=>kn("seed")(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?k(a._1,a._2,!0):a;return e(_=>oe(c,e,n,r,(f,l)=>e(d=>{const h=pt(OE)("integer (seed value)"),p=c._3&&!f._3?k(f._1,f._2,!0):f;return e(m=>h(p,e,n,r,(x,y)=>e(w=>{const N=p._3&&!x._3?k(x._1,x._2,!0):x;return e(b=>yn(N,e,n,r,(C,L)=>e(E=>o(N._3&&!C._3?k(C._1,C._2,!0):C,y))))})))})))}))),rm=(t,e,n,r,o)=>{const i=t._3;return e(a=>kn("diagram")(t,e,n,(s,u)=>r(k(s._1,s._2,i),u),(s,u)=>e(c=>{const _=pt(ko)("space after 'diagram'"),f=t._3&&!s._3?k(s._1,s._2,!0):s;return e(l=>_(f,e,n,(d,h)=>r(k(d._1,d._2,i),h),(d,h)=>e(p=>{const m=pt(kn("sequence"))("diagram mode"),x=f._3&&!d._3?k(d._1,d._2,!0):d;return e(y=>m(x,e,n,(w,N)=>r(k(w._1,w._2,i),N),(w,N)=>e(b=>{const C=x._3&&!w._3?k(w._1,w._2,!0):w;return e(L=>K0(C,e,n,(E,I)=>r(k(E._1,E._2,i),I),(E,I)=>e(W=>o(C._3&&!E._3?k(E._1,E._2,!0):E,k4))))})))})))})))},om=(t,e,n,r,o)=>{const i=t._3;return e(a=>kn("still")(t,e,n,(s,u)=>r(k(s._1,s._2,i),u),(s,u)=>e(c=>{const _=t._3&&!s._3?k(s._1,s._2,!0):s;return e(f=>K0(_,e,n,(l,d)=>r(k(l._1,l._2,i),d),(l,d)=>e(h=>o(_._3&&!l._3?k(l._1,l._2,!0):l,b4))))})))},im=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>om(k(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>_?r(u,c):rm(t,e,n,r,o))},o))},jE=t=>(e,n,r,o,i)=>n(a=>Dn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>{const l=_._3;return im(_,n,r,(d,h)=>o(k(d._1,d._2,l),h),(d,h)=>n(p=>o(_._3&&!d._3?k(d._1,d._2,!0):d,tr((()=>{if(t==="AnimatedSurface")return"Put diagram mode headers at the top of the document.";if(t==="AnimatedSurface")return"This document already declares `animation`; choose one diagram mode.";if(t==="StillSurface")return"This document already declares `still`; choose one diagram mode.";if(t==="SequenceSurface")return"This document already declares `diagram sequence`; choose one diagram mode.";g()})(),u))))})}))),ZE=t=>(e,n,r,o,i)=>n(a=>Dn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>{const l=(p,m)=>n(x=>(()=>{if(m.tag==="Just"){const y=(()=>{if(t==="AnimatedSurface")return"This document already declares `animation`; choose one diagram mode.";if(t==="StillSurface")return"This document already declares `still`; choose one diagram mode.";if(t==="SequenceSurface")return"This document already declares `diagram sequence`; choose one diagram mode.";g()})();return(w,N,b,C,L)=>C(w,tr(y,u))}if(m.tag==="Nothing")return(y,w,N,b,C)=>C(y,void 0);g()})()(_._3&&!p._3?k(p._1,p._2,!0):p,n,r,o,i)),d=_._1,h=_._2;return n(p=>n(m=>im(k(d,h,!1),n,r,(x,y)=>{const w=x._3;return n(N=>w?o(x,y):l(_,T))},(x,y)=>n(w=>l(x,J("Just",y))))))})}))),tP=(t,e,n,r,o)=>e(i=>{const a=(c,_)=>e(f=>{const l=t._3&&!c._3?k(c._1,c._2,!0):c;return e(d=>yn(l,e,n,r,(h,p)=>e(m=>{const x=l._3&&!h._3?k(h._1,h._2,!0):h;return e(y=>ZE(_)(x,e,n,r,(w,N)=>e(b=>o(x._3&&!w._3?k(w._1,w._2,!0):w,_))))})))}),s=t._1,u=t._2;return e(c=>om(k(s,u,!1),e,n,(_,f)=>{const l=_._3;return e(d=>l?r(_,f):rm(t,e,n,r,a))},a))}),eP=(t,e,n,r,o)=>e(i=>{const a=(c,_)=>e(f=>o(c,(()=>{if(_.tag==="Nothing")return C4;if(_.tag==="Just")return _._1;g()})())),s=t._1,u=t._2;return e(c=>e(_=>tP(k(s,u,!1),e,n,(f,l)=>{const d=f._3;return e(h=>d?r(f,l):a(t,T))},(f,l)=>e(d=>a(f,J("Just",l))))))}),nP=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>oe(t,e,n,(u,c)=>r(k(u._1,u._2,a),c),(u,c)=>e(_=>kn("via")(t._3&&!u._3?k(u._1,u._2,!0):u,e,n,(f,l)=>r(k(f._1,f._2,a),l),(f,l)=>e(d=>{const h=t._3&&!f._3?k(f._1,f._2,!0):f;return e(p=>Vu(h,e,n,r,(m,x)=>e(y=>{const w=h._3&&!m._3?k(m._1,m._2,!0):m;return e(N=>ko(w,e,n,r,(b,C)=>e(L=>{const E=pt(We)("source node identifier after 'via'"),I=w._3&&!b._3?k(b._1,b._2,!0):b;return e(W=>E(I,e,n,r,(P,G)=>e(j=>{const nt=I._3&&!P._3?k(P._1,P._2,!0):P;return e(O=>oe(nt,e,n,r,($,H)=>e(A=>{const B=pt(We)("target node identifier after 'via'"),z=nt._3&&!$._3?k($._1,$._2,!0):$;return e(Q=>B(z,e,n,r,(F,X)=>e(q=>o(z._3&&!F._3?k(F._1,F._2,!0):F,{from:G,to:X}))))})))})))})))})))})))))}),rP=t=>e=>{const n=ze(nP);return(r,o,i,a,s)=>o(u=>n(r,o,i,a,(c,_)=>o(f=>s(r._3&&!c._3?k(c._1,c._2,!0):c,{op:er("DelNode",{id:t,via:Bt(ce.foldr,_)}),operands:[e]}))))},oP=(()=>{const t=pt(At(e=>e==="-"))("'-'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=pt(ko)("space after '-'"),f=e._3&&!s._3?k(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(p=>{const m=bn(pt(We)("node identifier after '-'")),x=f._3&&!d._3?k(d._1,d._2,!0):d;return n(y=>m(x,n,r,o,(w,N)=>n(b=>{const C=N._1,L=N._2,E=x._3&&!w._3?k(w._1,w._2,!0):w;return n(I=>j0(E,n,r,o,(W,P)=>n(G=>(()=>{if(P.tag==="Just")return ME(C)(L)(P._1);if(P.tag==="Nothing")return rP(C)(L);g()})()(E._3&&!W._3?k(W._1,W._2,!0):W,n,r,o,i))))})))})))})))})(),wr=t=>e=>(n,r,o,i,a)=>r(s=>Dn(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?k(u._1,u._2,!0):u;return r(l=>kn(t)(f,r,o,i,(d,h)=>r(p=>i(f._3&&!d._3?k(d._1,d._2,!0):d,tr(e,c)))))}))),iP=t=>t==="AnimatedSurface"?(e,n,r,o,i)=>n(a=>Dn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>kn("step")(_,n,r,o,(l,d)=>n(h=>{const p=pt(ko)("space after 'step'"),m=_._3&&!l._3?k(l._1,l._2,!0):l;return n(x=>p(m,n,r,o,(y,w)=>n(N=>{const b=bn(pt(We)("step name")),C=m._3&&!y._3?k(y._1,y._2,!0):y;return n(L=>b(C,n,r,o,(E,I)=>n(W=>{const P=I._1,G=I._2,j=C._3&&!E._3?k(E._1,E._2,!0):E;return n(nt=>Dn(j,n,r,o,(O,$)=>n(H=>{const A=j._3&&!O._3?k(O._1,O._2,!0):O;return n(B=>oe(A,n,r,o,(z,Q)=>n(F=>{const X=A._3&&!z._3?k(z._1,z._2,!0):z;return n(q=>U0(X,n,r,o,(U,Y)=>n(ot=>{const Z=X._3&&!U._3?k(U._1,U._2,!0):U;return n(ft=>yn(Z,n,r,o,(Lt,dt)=>n(Nt=>{const St={line:u.line,column:u.column,endLine:$.line,endColumn:$.column};return i(Z._3&&!Lt._3?k(Lt._1,Lt._2,!0):Lt,{name:J("Just",P),ops:Qr("Leaf",{op:er("Step",{name:P}),line:St.line,column:St.column,endLine:St.endLine,endColumn:St.endColumn,span:St,operands:[G]}),kind:G0})})))})))})))})))})))})))})))}))):wr("step")("`step` markers are only supported in animated diagrams."),aP=(()=>{const t=pt(At(e=>e===":"))("':'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>oe(_,n,r,o,(l,d)=>n(h=>{const p=ze(At(JE)),m=_._3&&!l._3?k(l._1,l._2,!0):l;return n(x=>p(m,n,r,o,(y,w)=>n(N=>i(m._3&&!y._3?k(y._1,y._2,!0):y,Na(Jn(Bt(ce.foldr,w)))))))})))})))})(),am=pt((t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>aP(k(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>DE(k(l,d,!1),e,n,(p,m)=>{const x=p._3;return e(y=>{if(x)return r(p,m);const w=t._1,N=t._2;return e(b=>zE(k(w,N,!1),e,n,(C,L)=>{const E=C._3;return e(I=>E?r(C,L):tm(t,e,n,r,o))},o))})},o))})},o))})('label ("\u2026", : rest-of-line, or |\u2026|)'),sm=(t,e,n,r,o)=>e(i=>oe(t,e,n,r,(a,s)=>e(u=>am(t._3&&!a._3?k(a._1,a._2,!0):a,e,n,r,o)))),nc=t=>(e,n,r,o,i)=>n(a=>oe(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?k(s._1,s._2,!0):s;return n(f=>{const l=(p,m)=>n(x=>(m?((y,w,N,b,C)=>C(y,T)):(y,w,N,b,C)=>w(L=>sm(y,w,N,b,(E,I)=>w(W=>C(E,J("Just",I))))))(_._3&&!p._3?k(p._1,p._2,!0):p,n,r,o,i)),d=_._1,h=_._2;return n(p=>{const m=(x,y)=>{const w=x._3;return n(N=>w?o(x,y):l(_,!1))};return n(x=>n(y=>n(w=>oa(k(d,h,!1),n,r,(N,b)=>{const C=N._3;return n(L=>C?m(k(d,h,!1),b):n(E=>At(t)(k(d,h,!1),n,r,(I,W)=>m(k(d,h,!1),W),(I,W)=>n(P=>n(G=>l(k(d,h,!1),!0))))))},(N,b)=>n(C=>n(L=>l(k(d,h,!1),!0)))))))})})}))),sP=t=>e=>n=>(r,o,i,a,s)=>o(u=>oe(r,o,i,a,(c,_)=>o(f=>{const l=bn(pt(We)("target node identifier")),d=r._3&&!c._3?k(c._1,c._2,!0):c;return o(h=>l(d,o,i,a,(p,m)=>o(x=>{const y=m._1,w=m._2,N=d._3&&!p._3?k(p._1,p._2,!0):p;return o(b=>nc(d1)(N,o,i,a,(C,L)=>o(E=>s(N._3&&!C._3?k(C._1,C._2,!0):C,{op:er("AddEdge",{from:t,to:y,label:L.tag==="Just"?J("Just",L._1):T,directed:n}),operands:[e,w]}))))})))}))),uP=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>bn(We)(t,e,n,(u,c)=>r(k(u._1,u._2,a),c),(u,c)=>e(_=>{const f=t._3&&!u._3?k(u._1,u._2,!0):u;return e(l=>oe(f,e,n,(d,h)=>r(k(d._1,d._2,a),h),(d,h)=>e(p=>{const m=pt(At(y=>y==="<"))("'<'"),x=f._3&&!d._3?k(d._1,d._2,!0):d;return e(y=>m(x,e,n,(w,N)=>r(k(x._1,x._2,a),N),(w,N)=>e(b=>{const C=bo((E,I,W,P,G)=>{const j=E._3;return Le("<-")(E,I,W,(nt,O)=>P(k(nt._1,nt._2,j),O),G)}),L=x._3&&!x._3?k(x._1,x._2,!0):x;return e(E=>C(L,e,n,(I,W)=>r(k(I._1,I._2,a),W),(I,W)=>e(P=>{const G=L._3&&!I._3?k(I._1,I._2,!0):I;return e(j=>{const nt=c._1,O=c._2,$=t._3&&!G._3?k(G._1,G._2,!0):G;return e(H=>oe($,e,n,r,(A,B)=>e(z=>{const Q=pt(Le("<~"))("'<~'"),F=$._3&&!A._3?k(A._1,A._2,!0):A;return e(X=>Q(F,e,n,r,(q,U)=>e(Y=>{const ot=F._3&&!q._3?k(q._1,q._2,!0):q;return e(Z=>oe(ot,e,n,r,(ft,Lt)=>e(dt=>{const Nt=bn(pt(We)("target node identifier")),St=ot._3&&!ft._3?k(ft._1,ft._2,!0):ft;return e(te=>Nt(St,e,n,r,(Jt,Yt)=>e(Ft=>{const vt=Yt._1,mt=Yt._2,lt=St._3&&!Jt._3?k(Jt._1,Jt._2,!0):Jt;return e(xt=>nc(d1)(lt,e,n,r,(It,ht)=>e(Ct=>o(lt._3&&!It._3?k(It._1,It._2,!0):It,{op:er("Token",{from:vt,to:nt,labels:(()=>{if(ht.tag==="Nothing")return[];if(ht.tag==="Just")return[ht._1];g()})()}),operands:[mt,O]}))))})))})))})))})))})})))})))})))})))}),cP=(t,e,n,r,o)=>e(i=>WE(t,e,n,r,(a,s)=>e(u=>{const c=s._2._2,_=s._1,f=s._2._1,l=t._3&&!a._3?k(a._1,a._2,!0):a;return e(d=>oe(l,e,n,r,(h,p)=>e(m=>{const x=bn(pt(We)("target node identifier")),y=l._3&&!h._3?k(h._1,h._2,!0):h;return e(w=>x(y,e,n,r,(N,b)=>e(C=>{const L=b._1,E=b._2,I=y._3&&!N._3?k(N._1,N._2,!0):N;return e(W=>nc(d1)(I,e,n,r,(P,G)=>e(j=>(c==="<~"?((nt,O,$,H,A)=>A(nt,{op:er("Token",{from:L,to:_,labels:(()=>{if(G.tag==="Nothing")return[];if(G.tag==="Just")return[G._1];g()})()}),operands:c==="<~"?[E,f]:[f,E]})):(nt,O,$,H,A)=>A(nt,{op:er("Token",{from:_,to:L,labels:(()=>{if(G.tag==="Nothing")return[];if(G.tag==="Just")return[G._1];g()})()}),operands:c==="<~"?[E,f]:[f,E]}))(I._3&&!P._3?k(P._1,P._2,!0):P,e,n,r,o))))})))})))}))),gP=(t,e,n,r,o)=>e(i=>nc(bE)(t,e,n,r,(a,s)=>e(u=>o(a,(()=>{if(s.tag==="Nothing")return"";if(s.tag==="Just")return s._1;g()})())))),_P=t=>e=>n=>r=>(o,i,a,s,u)=>i(c=>Dn(o,i,a,s,(_,f)=>i(l=>{const d=o._3&&!_._3?k(_._1,_._2,!0):_;return i(h=>{const p=(y,w)=>i(N=>(()=>{if(w.tag==="Just")return(b,C,L,E,I)=>E(b,tr("node placeholder value",f));if(w.tag==="Nothing")return(b,C,L,E,I)=>C(W=>sm(b,C,L,E,(P,G)=>C(j=>I(b._3&&!P._3?k(P._1,P._2,!0):P,{op:er("ModNodeSlot",{id:t,slot:n,value:G}),operands:[e,r]}))));g()})()(d._3&&!y._3?k(y._1,y._2,!0):y,i,a,s,u)),m=d._1,x=d._2;return i(y=>i(w=>rs(k(m,x,!1),i,a,(N,b)=>i(C=>p(d,T)),(N,b)=>i(C=>p(k(m,x,!1),J("Just",b))))))})}))),fP=t=>e=>(n,r,o,i,a)=>r(s=>Dn(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?k(u._1,u._2,!0):u;return r(l=>{const d=(m,x)=>r(y=>(()=>{if(x.tag==="Just")return(w,N,b,C,L)=>C(w,tr("node relabel label",c));if(x.tag==="Nothing")return(w,N,b,C,L)=>N(E=>am(w,N,b,C,(I,W)=>N(P=>L(w._3&&!I._3?k(I._1,I._2,!0):I,{op:er("ModNode",{id:t,label:J("Just",W)}),operands:[e]}))));g()})()(f._3&&!m._3?k(m._1,m._2,!0):m,r,o,i,a)),h=f._1,p=f._2;return r(m=>r(x=>rs(k(h,p,!1),r,o,(y,w)=>r(N=>d(f,T)),(y,w)=>r(N=>d(k(h,p,!1),J("Just",w))))))})}))),lP=(()=>{const t=pt(At(e=>e==="~"))("'~'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=pt(ko)("space after '~'"),f=e._3&&!s._3?k(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(p=>{const m=bn(pt(We)("source node identifier")),x=f._3&&!d._3?k(d._1,d._2,!0):d;return n(y=>m(x,n,r,o,(w,N)=>n(b=>{const C=N._1,L=N._2,E=pt(At(P=>P==="."))("'.'"),I=bn(pt(We)("placeholder name")),W=x._3&&!w._3?k(w._1,w._2,!0):w;return n(P=>{const G=(O,$)=>n(H=>(()=>{if($.tag==="Just")return _P(C)(L)($._1._1)($._1._2);if($.tag==="Nothing")return(A,B,z,Q,F)=>B(X=>oe(A,B,z,Q,(q,U)=>B(Y=>{const ot=pt(At(ft=>ft==="-"))("'-'"),Z=A._3&&!q._3?k(q._1,q._2,!0):q;return B(ft=>{const Lt=(St,te)=>B(Jt=>(()=>{if(te.tag==="Just")return HE(C)(L);if(te.tag==="Nothing")return fP(C)(L);g()})()(Z._3&&!St._3?k(St._1,St._2,!0):St,B,z,Q,F)),dt=Z._1,Nt=Z._2;return B(St=>B(te=>ot(k(dt,Nt,!1),B,z,(Jt,Yt)=>B(Ft=>Lt(Z,T)),(Jt,Yt)=>B(Ft=>Lt(k(dt,Nt,!1),J("Just",Yt))))))})})));g()})()(W._3&&!O._3?k(O._1,O._2,!0):O,n,r,o,i)),j=W._1,nt=W._2;return n(O=>n($=>{const H=(A,B)=>{const z=A._3;return n(Q=>z?o(A,B):G(W,T))};return n(A=>n(B=>E(k(j,nt,!1),n,r,(z,Q)=>H(k(z._1,z._2,!1),Q),(z,Q)=>n(F=>n(X=>I(z,n,r,(q,U)=>H(k(q._1,q._2,!1),U),(q,U)=>n(Y=>{const ot=z._3&&!q._3?k(q._1,q._2,!0):q;return n(Z=>G(ot,J("Just",U)))})))))))}))})})))})))})))})(),h1=w0((()=>{const t=pt(At(e=>e==="{"))("'{'");return(e,n,r,o,i)=>n(a=>n(s=>t(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?k(u._1,u._2,!0):u;return yn(l,n,r,o,(d,h)=>n(p=>i(l._3&&!d._3?k(d._1,d._2,!0):d,h)))})))))})())(pt((()=>{const t=pt(At(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>n(s=>yn(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?k(u._1,u._2,!0):u;return t(l,n,r,o,(d,h)=>n(p=>i(l._3&&!d._3?k(d._1,d._2,!0):d,h)))})))))})())("closing '}'")),dP=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>tm(k(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>$E(k(l,d,!1),e,n,(p,m)=>{const x=p._3;return e(y=>x?r(p,m):We(t,e,n,r,o))},o))})},o))},um=(t,e,n,r,o)=>e(i=>oe(t,e,n,r,(a,s)=>e(u=>{const c=pt(We)("attribute key"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const p=_._3&&!l._3?k(l._1,l._2,!0):l;return e(m=>oe(p,e,n,r,(x,y)=>e(w=>{const N=pt(pt(At(C=>C===":"))("':'"))("':'"),b=p._3&&!x._3?k(x._1,x._2,!0):x;return e(C=>N(b,e,n,r,(L,E)=>e(I=>{const W=b._3&&!L._3?k(L._1,L._2,!0):L;return e(P=>oe(W,e,n,r,(G,j)=>e(nt=>{const O=pt(dP)("attribute value"),$=W._3&&!G._3?k(G._1,G._2,!0):G;return e(H=>O($,e,n,r,(A,B)=>e(z=>{const Q=$._3&&!A._3?k(A._1,A._2,!0):A;return e(F=>oe(Q,e,n,r,(X,q)=>e(U=>o(Q._3&&!X._3?k(X._1,X._2,!0):X,S(d,B)))))})))})))})))})))})))}))),hP=w0((()=>{const t=pt(At(e=>e==="{"))("'{'");return(e,n,r,o,i)=>n(a=>n(s=>t(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?k(u._1,u._2,!0):u;return oe(l,n,r,o,(d,h)=>n(p=>i(l._3&&!d._3?k(d._1,d._2,!0):d,h)))})))))})())(pt((()=>{const t=pt(At(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>n(s=>oe(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?k(u._1,u._2,!0):u;return t(l,n,r,o,(d,h)=>n(p=>i(l._3&&!d._3?k(d._1,d._2,!0):d,h)))})))))})())("closing '}' for attributes"))((()=>{const t=pt(At(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>{const s=(_,f)=>n(l=>(()=>{if(f.tag==="Just")return(d,h,p,m,x)=>x(d,M);if(f.tag==="Nothing")return(d,h,p,m,x)=>h(y=>um(d,h,p,m,(w,N)=>h(b=>{const C=ze((()=>{const E=pt(At(I=>I===","))("','");return(I,W,P,G,j)=>{const nt=I._3;return W(O=>W($=>W(H=>W(A=>W(B=>W(z=>oe(I,W,P,(Q,F)=>G(k(Q._1,Q._2,nt),F),(Q,F)=>W(X=>W(q=>{const U=I._3&&!Q._3?k(Q._1,Q._2,!0):Q;return E(U,W,P,(Y,ot)=>G(k(Y._1,Y._2,nt),ot),(Y,ot)=>W(Z=>{const ft=U._3&&!Y._3?k(Y._1,Y._2,!0):Y;return W(Lt=>W(dt=>{const Nt=I._3&&!ft._3?k(ft._1,ft._2,!0):ft;return oe(Nt,W,P,(St,te)=>G(k(St._1,St._2,nt),te),(St,te)=>W(Jt=>{const Yt=Nt._3&&!St._3?k(St._1,St._2,!0):St;return W(Ft=>W(vt=>{const mt=I._3&&!Yt._3?k(Yt._1,Yt._2,!0):Yt;return um(mt,W,P,(lt,xt)=>G(k(lt._1,lt._2,nt),xt),(lt,xt)=>W(It=>j(mt._3&&!lt._3?k(lt._1,lt._2,!0):lt,xt)))}))}))}))}))})))))))))}})()),L=d._3&&!w._3?k(w._1,w._2,!0):w;return h(E=>C(L,h,p,m,(I,W)=>h(P=>x(L._3&&!I._3?k(I._1,I._2,!0):I,TE([N,...Bt(ce.foldr,W)])))))})));g()})()(e._3&&!_._3?k(_._1,_._2,!0):_,n,r,o,i)),u=e._1,c=e._2;return n(_=>n(f=>t(k(u,c,!1),n,r,(l,d)=>n(h=>s(e,T)),(l,d)=>n(h=>s(k(u,c,!1),J("Just",d))))))})})()),pP=(t,e,n,r,o)=>e(i=>oe(t,e,n,r,(a,s)=>e(u=>{const c=pt(At(f=>f==="{"))("'{'"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>{const l=(p,m)=>e(x=>(()=>{if(m.tag==="Just")return hP;if(m.tag==="Nothing")return(y,w,N,b,C)=>C(y,M);g()})()(_._3&&!p._3?k(p._1,p._2,!0):p,e,n,r,o)),d=_._1,h=_._2;return e(p=>e(m=>c(k(d,h,!1),e,n,(x,y)=>e(w=>l(_,T)),(x,y)=>e(w=>l(k(d,h,!1),J("Just",y))))))})}))),mP=t=>e=>(n,r,o,i,a)=>r(s=>gP(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?k(u._1,u._2,!0):u;return r(l=>pP(f,r,o,i,(d,h)=>r(p=>a(f._3&&!d._3?k(d._1,d._2,!0):d,{op:er("AddNode",{id:t,label:c,shape:(()=>{const m=V0("shape")(h);if(m.tag==="Just")return m._1==="rectangle"||m._1==="rect"?so:m._1==="cylinder"||m._1==="cyl"?Vy:m._1==="parallelogram"?$y:m._1==="diamond"?Uy:m._1==="ellipse"?Xy:m._1==="document"||m._1==="doc"?Yy:m._1==="cloud"?Ky:so;if(m.tag==="Nothing")return so;g()})(),width:(()=>{const m=V0("width")(h);if(m.tag==="Just")return Cc(m._1,ga,Vt,T);if(m.tag==="Nothing")return T;g()})()}),operands:[e]}))))}))),yP=(()=>{const t=pt(At(e=>e==="+"))("'+'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=pt(ko)("space after '+'"),f=e._3&&!s._3?k(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(p=>{const m=bn(pt(We)("node identifier after '+'")),x=f._3&&!d._3?k(d._1,d._2,!0):d;return n(y=>m(x,n,r,o,(w,N)=>n(b=>{const C=N._1,L=N._2,E=x._3&&!w._3?k(w._1,w._2,!0):w;return n(I=>j0(E,n,r,o,(W,P)=>n(G=>(()=>{if(P.tag==="Just")return sP(C)(L)(P._1);if(P.tag==="Nothing")return mP(C)(L);g()})()(E._3&&!W._3?k(W._1,W._2,!0):W,n,r,o,i))))})))})))})))})(),xP=(t,e,n,r,o)=>e(i=>Dn(t,e,n,r,(a,s)=>e(u=>{const c=pt(l1([wr("+node")("Node additions use `+ api: API`."),wr("+edge")("Graph edges use `+ api -> db`."),wr("+conn")("Undirected graph edges use `+ api -- db`."),wr("-node")("Node removals use `- api`."),wr("-edge")("Graph edge removals use `- api -> db`."),wr("-conn")("Undirected graph edge removals use `- api -- db`."),wr("~edge")("Graph edge repoints use `~ api -> db => api -> cache`."),wr("enter")("Dive commands use `into api`."),wr("exit")("Return from a dive with `out`."),QE,yP,oP,lP,cP,uP,UE,YE]))("statement (+ node, - node, + edge, - edge, ~ node, into, out, or 'a ~> b'/'a <~ b')"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const p=_._3&&!l._3?k(l._1,l._2,!0):l;return e(m=>Dn(p,e,n,r,(x,y)=>e(w=>{const N={line:s.line,column:s.column,endLine:y.line,endColumn:y.column};return o(p._3&&!x._3?k(x._1,x._2,!0):x,Qr("Leaf",{op:d.op,line:N.line,column:N.column,endLine:N.endLine,endColumn:N.endColumn,span:N,operands:d.operands}))})))})))}))),cm=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>yn(t,e,n,(u,c)=>r(k(u._1,u._2,a),c),(u,c)=>e(_=>{const f=bo(pt(At(d=>d==="}"))("'}'")),l=t._3&&!u._3?k(u._1,u._2,!0):u;return e(d=>f(l,e,n,(h,p)=>r(k(h._1,h._2,a),p),(h,p)=>e(m=>bo(oa)(l._3&&!h._3?k(h._1,h._2,!0):h,e,n,(x,y)=>r(k(x._1,x._2,a),y),(x,y)=>e(w=>{const N=t._3&&!x._3?k(x._1,x._2,!0):x;return e(b=>Vu(N,e,n,r,(C,L)=>e(E=>{const I=l1([wP,TP,xP]),W=N._3&&!C._3?k(C._1,C._2,!0):C;return e(P=>I(W,e,n,r,(G,j)=>e(nt=>{const O=W._3&&!G._3?k(G._1,G._2,!0):G;return e($=>oe(O,e,n,r,(H,A)=>e(B=>{const z=O._3&&!H._3?k(H._1,H._2,!0):H;return e(Q=>U0(z,e,n,r,(F,X)=>e(q=>{const U=z._3&&!F._3?k(F._1,F._2,!0):F;return e(Y=>yn(U,e,n,r,(ot,Z)=>e(ft=>o(U._3&&!ot._3?k(ot._1,ot._2,!0):ot,j))))})))})))})))})))})))))})))}),TP=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>{const u=(c,_)=>{const f=c._3;return e(l=>f?r(c,_):e(d=>{const h=t._3;return e(p=>kn("seq")(t,e,n,(m,x)=>r(k(m._1,m._2,h),x),(m,x)=>e(y=>{const w=t._3&&!m._3?k(m._1,m._2,!0):m;return e(N=>oe(w,e,n,(b,C)=>r(k(b._1,b._2,h),C),(b,C)=>e(L=>rs(w._3&&!b._3?k(b._1,b._2,!0):b,e,n,(E,I)=>r(k(E._1,E._2,h),I),(E,I)=>e(W=>{const P=t._3&&!E._3?k(E._1,E._2,!0):E;return e(G=>Vu(P,e,n,r,(j,nt)=>e(O=>{const $=pt(pt(At(A=>A==="{"))("'{'"))("'{'"),H=P._3&&!j._3?k(j._1,j._2,!0):j;return e(A=>$(H,e,n,r,(B,z)=>e(Q=>o(H._3&&!B._3?k(B._1,B._2,!0):B,Qr("GroupSeq",[])))))})))})))))})))}))};return e(c=>e(_=>kn("seq")(k(i,a,!1),e,n,(f,l)=>u(k(f._1,f._2,!1),l),(f,l)=>e(d=>e(h=>oe(f,e,n,(p,m)=>u(k(p._1,p._2,!1),m),(p,m)=>e(x=>{const y=f._3&&!p._3?k(p._1,p._2,!0):p;return pt(At(w=>w==="{"))("'{'")(y,e,n,(w,N)=>u(k(y._1,y._2,!1),N),(w,N)=>e(b=>h1(p1(G4))(y,e,n,u,o)))})))))))})},wP=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>{const u=(c,_)=>{const f=c._3;return e(l=>f?r(c,_):e(d=>{const h=t._3;return e(p=>kn("par")(t,e,n,(m,x)=>r(k(m._1,m._2,h),x),(m,x)=>e(y=>{const w=t._3&&!m._3?k(m._1,m._2,!0):m;return e(N=>oe(w,e,n,(b,C)=>r(k(b._1,b._2,h),C),(b,C)=>e(L=>rs(w._3&&!b._3?k(b._1,b._2,!0):b,e,n,(E,I)=>r(k(E._1,E._2,h),I),(E,I)=>e(W=>{const P=t._3&&!E._3?k(E._1,E._2,!0):E;return e(G=>Vu(P,e,n,r,(j,nt)=>e(O=>{const $=pt(pt(At(A=>A==="{"))("'{'"))("'{'"),H=P._3&&!j._3?k(j._1,j._2,!0):j;return e(A=>$(H,e,n,r,(B,z)=>e(Q=>o(H._3&&!B._3?k(B._1,B._2,!0):B,Qr("Par",[])))))})))})))))})))}))};return e(c=>e(_=>kn("par")(k(i,a,!1),e,n,(f,l)=>u(k(f._1,f._2,!1),l),(f,l)=>e(d=>e(h=>oe(f,e,n,(p,m)=>u(k(p._1,p._2,!1),m),(p,m)=>e(x=>{const y=f._3&&!p._3?k(p._1,p._2,!0):p;return pt(At(w=>w==="{"))("'{'")(y,e,n,(w,N)=>u(k(y._1,y._2,!1),N),(w,N)=>e(b=>h1(p1(E4))(y,e,n,u,o)))})))))))})},p1=t=>{const e=ze(cm);return(n,r,o,i,a)=>r(s=>e(n,r,o,i,(u,c)=>r(_=>a(n._3&&!u._3?k(u._1,u._2,!0):u,t(Bt(ce.foldr,c))))))},m1=t=>e=>(n,r,o,i,a)=>r(s=>nm(t)(n,r,o,i,(u,c)=>r(_=>{const f=ze(At(kE)),l=n._3&&!u._3?k(u._1,u._2,!0):u;return r(d=>f(l,r,o,i,(h,p)=>r(m=>{const x=pt(pt(At(w=>w==="{"))("'{'"))("'{'"),y=l._3&&!h._3?k(h._1,h._2,!0):h;return r(w=>x(y,r,o,i,(N,b)=>r(C=>{const L=y._3&&!N._3?k(N._1,N._2,!0):N;return r(E=>yn(L,r,o,i,(I,W)=>r(P=>{const G=p1(P4),j=L._3&&!I._3?k(I._1,I._2,!0):I;return r(nt=>G(j,r,o,i,(O,$)=>r(H=>{const A=j._3&&!O._3?k(O._1,O._2,!0):O;return r(B=>yn(A,r,o,i,(z,Q)=>r(F=>{const X=pt(pt(At(U=>U==="}"))("'}'"))("closing '}'"),q=A._3&&!z._3?k(z._1,z._2,!0):z;return r(U=>X(q,r,o,i,(Y,ot)=>r(Z=>{const ft=q._3&&!Y._3?k(Y._1,Y._2,!0):Y;return r(Lt=>yn(ft,r,o,i,(dt,Nt)=>r(St=>a(ft._3&&!dt._3?k(dt._1,dt._2,!0):dt,{name:RE(Jn(Bt(ce.foldr,p))),ops:$,kind:e}))))})))})))})))})))})))})))}))),NP=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>wr("keyframe")("Drop the `keyframe` wrapper; Markgraf animates statements in order.")(k(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>m1("scene")(Ku)(k(l,d,!1),e,n,(p,m)=>{const x=p._3;return e(y=>{if(x)return r(p,m);const w=t._1,N=t._2;return e(b=>m1("still")(c1)(k(w,N,!1),e,n,(C,L)=>{const E=C._3;return e(I=>E?r(C,L):m1("title")(S4)(t,e,n,r,o))},o))})},o))})},o))},JP=t=>e=>n=>{if(t==="AnimatedSurface")return{...e,frames:wt(e.frames)({name:T,ops:n,kind:Ku})};if(t==="StillSurface")return{...e,statements:wt(e.statements)(n)};if(t==="SequenceSurface")return{...e,statements:wt(e.statements)(n)};g()},vP=t=>e=>n=>{if(n.tag==="TopFrame"){const r=Z0(t)(e);return{...r,frames:wt(r.frames)((()=>{if(t==="AnimatedSurface")return n._1;if(t==="StillSurface")return{...n._1,kind:n._1.kind==="AnimatedKeyframe"?c1:n._1.kind==="StepMarker"?G0:n._1.kind};if(t==="SequenceSurface")return n._1;g()})())}}if(n.tag==="TopStatement")return JP(t)(e)(n._1);if(n.tag==="TopInside")return e;g()},CP=t=>{const e=v(vP(t))(FE);return n=>Z0(t)(e(n)).frames},bP=t=>VS.defer(e=>{const n=iP(t);return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>jE(t)(k(u,c,!1),o,i,(f,l)=>{const d=f._3;return o(h=>{if(d)return a(f,l);const p=r._1,m=r._2;return o(x=>o(y=>kP(k(p,m,!1),o,i,(w,N)=>{const b=w._3;return o(C=>{if(b)return a(w,N);const L=r._1,E=r._2;return o(I=>o(W=>n(k(L,E,!1),o,i,(P,G)=>{const j=P._3;return o(nt=>{if(j)return a(P,G);const O=r._1,$=r._2;return o(H=>o(A=>NP(k(O,$,!1),o,i,(B,z)=>{const Q=B._3;return o(F=>Q?a(B,z):o(X=>cm(r,o,i,a,(q,U)=>o(Y=>s(q,tc("TopStatement",U))))))},(B,z)=>o(Q=>s(B,tc("TopFrame",z))))))})},(P,G)=>o(j=>s(P,tc("TopFrame",G))))))})},(w,N)=>o(b=>s(w,tc("TopInside",N))))))})},s))}}),kP=(t,e,n,r,o)=>e(i=>kn("inside")(t,e,n,r,(a,s)=>e(u=>{const c=pt(ko)("space after 'inside'"),_=t._3&&!a._3?k(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const p=pt(We)("node identifier after 'inside'"),m=_._3&&!l._3?k(l._1,l._2,!0):l;return e(x=>p(m,e,n,r,(y,w)=>e(N=>{const b=m._3&&!y._3?k(y._1,y._2,!0):y;return e(C=>yn(b,e,n,r,(L,E)=>e(I=>{const W=b._3&&!L._3?k(L._1,L._2,!0):L;return e(P=>h1(gm)(W,e,n,r,(G,j)=>e(nt=>{const O=W._3&&!G._3?k(G._1,G._2,!0):G;return e($=>yn(O,e,n,r,(H,A)=>e(B=>o(O._3&&!H._3?k(H._1,H._2,!0):H,{node:w,doc:j}))))})))})))})))})))}))),gm=(t,e,n,r,o)=>e(i=>eP(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?k(a._1,a._2,!0):a;return e(_=>{const f=(h,p)=>e(m=>{const x=c._3&&!h._3?k(h._1,h._2,!0):h;return e(y=>{const w=(C,L)=>e(E=>{const I=x._3&&!C._3?k(C._1,C._2,!0):C;return e(W=>{const P=(G,j)=>e(nt=>{const O=ze(bP(s)),$=I._3&&!G._3?k(G._1,G._2,!0):G;return e(H=>O($,e,n,r,(A,B)=>e(z=>{const Q=Bt(ce.foldr,B);return o($._3&&!A._3?k(A._1,A._2,!0):A,{seed:(()=>{if(p.tag==="Nothing")return 0;if(p.tag==="Just")return p._1;g()})(),minimumFontSize:L,stretchNodes:j,mode:s,frames:CP(s)(Q),interiors:Tt(F=>{if(F.tag==="TopInside")return J("Just",F._1);if(F.tag==="TopFrame"||F.tag==="TopStatement")return T;g()})(Q)})})))});return e(G=>{const j=I._1,nt=I._2;return e(O=>e($=>qE(k(j,nt,!1),e,n,(H,A)=>{const B=H._3;return e(z=>B?r(H,A):e(Q=>P(I,!1)))},(H,A)=>e(B=>e(z=>P(H,!0))))))})})}),N=x._1,b=x._2;return e(C=>e(L=>XE(k(N,b,!1),e,n,(E,I)=>{const W=E._3;return e(P=>W?r(E,I):w(x,T))},(E,I)=>e(W=>w(E,J("Just",I))))))})}),l=c._1,d=c._2;return e(h=>e(p=>KE(k(l,d,!1),e,n,(m,x)=>{const y=m._3;return e(w=>y?r(m,x):f(c,T))},(m,x)=>e(y=>f(m,J("Just",x))))))})}))),LP=(()=>{const t=pt((e,n,r,o,i)=>n(a=>n(s=>yn(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?k(u._1,u._2,!0):u;return oa(l,n,r,o,(d,h)=>n(p=>i(l._3&&!d._3?k(d._1,d._2,!0):d,h)))}))))))("'scene', 'still', 'title', 'step', 'inside', a statement, or end of input");return(e,n,r,o,i)=>n(a=>n(s=>n(u=>n(c=>yn(e,n,r,o,(_,f)=>n(l=>n(d=>{const h=e._3&&!_._3?k(_._1,_._2,!0):_;return gm(h,n,r,o,(p,m)=>n(x=>{const y=h._3&&!p._3?k(p._1,p._2,!0):p;return n(w=>n(N=>{const b=e._3&&!y._3?k(y._1,y._2,!0):y;return t(b,n,r,o,(C,L)=>n(E=>i(b._3&&!C._3?k(C._1,C._2,!0):C,m)))}))}))})))))))})(),SP=t=>{const e=y0(t)(LP);if(e.tag==="Left")return Dt("Left",{msg:GE(e._1._1),line:e._1._2.line,column:e._1._2.column,endLine:e._1._2.line,endColumn:e._1._2.column+1|0});if(e.tag==="Right")return Dt("Right",e._1);g()},EP=t=>{const e=SP(t);if(e.tag==="Left")return Dt("Left",e._1.msg);if(e.tag==="Right")return Dt("Right",e._1);g()},PP=()=>({tag:"ParFrag"}),_m=t=>t,GP=_m("Sync"),RP=_m("SelfMsg"),AP=PP(),Lo=p0(Qn),zn=Ji(Qn),Nr=Lo.state(t=>S(t,t)),So=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=R.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},fm=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},rc=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Eo=vi(Qn),IP=t=>e=>v(n=>r=>Ji(Qn).bind(n)(o=>t(o)(r)))(vi(Qn).pure(e)),lm=Go(Eo)(Wt),dm=t=>e=>Lo.state(n=>S(void 0,{...n,lifelines:M1(R)(r=>J("Just",{...r,label:ia(e)}))(t)(n.lifelines),labelTemplates:it(R)(t)(e)(n.labelTemplates)})),os=t=>Lo.state(e=>S(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:J("Just",t)};g()})())),FP=t=>e=>n=>zn.bind(Nr)(r=>{const o=So(t)(r.labelTemplates);if(o.tag==="Nothing")return os("node "+t+" label has no placeholder `"+e+"`");if(o.tag==="Just"){const i=C0(e)(n)(o._1);if(i.tag==="Left")return os("node "+t+" "+i._1);if(i.tag==="Right")return dm(t)(i._1)}g()}),DP=t=>e=>{const n=Uu(e);if(n.tag==="Left")return os("invalid label for node "+t+": "+n._1);if(n.tag==="Right")return dm(t)(n._1);g()},zP=t=>e=>n=>{const r=So(n)(t.lifelines);return So(e)(t.lifelines).tag==="Nothing"?r.tag==="Nothing"?e+", "+n:e:r.tag==="Nothing"?n:""},BP={lifelines:M,labelTemplates:M,lifelineOrder:[],messages:[],fragments:[],frameEndRows:[],row:0,error:T},MP=t=>e=>n=>zn.bind(Nr)(r=>{const o=So(t)(r.lifelines),i=So(e)(r.lifelines);if(o.tag==="Just"&&i.tag==="Just"){const a={...r,messages:[{fromCol:o._1.column,toCol:i._1.column,labels:n,row:r.row,kind:t===e?RP:GP},...r.messages],row:r.row+1|0};return Lo.state(s=>S(void 0,a))}return os("token references unknown node: "+zP(r)(t)(e))}),QP=t=>Lo.state(e=>S(void 0,{...e,lifelines:M1(R)(n=>J("Just",{...n,destroyedAt:J("Just",e.row)}))(t)(e.lifelines)})),WP=t=>e=>{const n=e.lifelineOrder.length,r=Pt(o=>T,o=>i=>J("Just",{head:o,tail:i}),t);if(r.tag==="Nothing")return{fromCol:0,toCol:rc(0)(e.lifelineOrder.length-1|0)};if(r.tag==="Just")return v(o=>i=>({fromCol:fm(o.fromCol)(fm(i.fromCol)(i.toCol)),toCol:rc(o.toCol)(rc(i.fromCol)(i.toCol))}))({fromCol:n,toCol:0})(t);g()},HP=t=>({lifelines:Tt(e=>So(e)(t.lifelines))(t.lifelineOrder),messages:ee(t.messages),fragments:ee(t.fragments),frameEndRows:t.frameEndRows,totalRows:t.row}),OP=t=>e=>zn.bind(Nr)(n=>{const r=So(t)(n.lifelines);if(r.tag==="Just")return Eo.pure();if(r.tag==="Nothing"){const o={...n,lifelines:it(R)(t)({id:t,label:ia(e),column:n.lifelineOrder.length,createdAt:n.row,destroyedAt:T})(n.lifelines),labelTemplates:it(R)(t)(e)(n.labelTemplates),lifelineOrder:wt(n.lifelineOrder)(t),row:n.row>0||n.messages.length!==0?n.row+1|0:n.row};return Lo.state(i=>S(void 0,o))}g()}),qP=t=>e=>zn.bind(Nr)(n=>{const r=So(t)(n.lifelines);if(r.tag==="Just")return Eo.pure();if(r.tag==="Nothing"){const o=Uu(e);if(o.tag==="Left")return os("invalid label for node "+t+": "+o._1);if(o.tag==="Right")return OP(t)(o._1)}g()}),VP=t=>{if(t.tag==="AddNode")return qP(t._1.id)(t._1.label);if(t.tag==="DelNode")return QP(t._1.id);if(t.tag==="ModNode"){if(t._1.label.tag==="Just")return DP(t._1.id)(t._1.label._1);if(t._1.label.tag==="Nothing")return Eo.pure();g()}return t.tag==="ModNodeSlot"?FP(t._1.id)(t._1.slot)(t._1.value):t.tag==="Token"?MP(t._1.from)(t._1.to)(t._1.labels):Eo.pure()},$P=t=>zn.bind(Nr)(e=>{const n=e.row;return zn.bind(IP(r=>o=>zn.bind(Nr)(i=>{const a=r.childMessages.length===0?r.dividers:[i.row,...r.dividers],s=i.messages;return zn.bind(y1(o))(()=>zn.bind(Nr)(u=>Eo.pure({dividers:a,childMessages:[...r.childMessages,...(()=>{const c=u.messages.length-s.length|0;return c<1?[]:Rt(0,c,u.messages)})()]})))}))({dividers:[],childMessages:[]})(t))(r=>zn.bind(Nr)(o=>{const i=WP(r.childMessages)(o),a={kind:AP,label:"par",fromRow:n,toRow:rc(o.row)(n+1|0),fromCol:i.fromCol,toCol:i.toCol,regionDividers:ee(r.dividers)},s=Lo.state(u=>S(void 0,{...u,fragments:[a,...u.fragments]}));return r.childMessages.length>=2?s:Eo.pure()}))}),y1=t=>{if(t.tag==="Leaf")return VP(t._1.op);if(t.tag==="Seq"||t.tag==="GroupSeq")return lm(y1)(t._1);if(t.tag==="Par")return $P(t._1);g()},UP=t=>{const e=zn.bind(lm(n=>zn.bind(Nr)(r=>zn.bind(y1(n.ops))(()=>zn.bind(Nr)(o=>{const i=Lo.state(a=>S(void 0,{...a,frameEndRows:wt(a.frameEndRows)(a.row-1|0)}));return(o.messages.length-r.messages.length|0)>0?i:Eo.pure()}))))(t.frames))(()=>Nr)(BP)._1;if(e.error.tag==="Just")return Dt("Left",e.error._1);if(e.error.tag==="Nothing")return Dt("Right",HP(e));g()},XP=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},YP={padding:24,headerHeight:36,headerWidth:120,columnSpacing:160,rowHeight:36,topGap:24,bottomGap:24},KP=t=>{const e=84+rt(XP(1)(t.totalRows))*36,n=Ht(r=>o=>({lifeline:o,x:84+rt(r)*160}))(t.lifelines);return{metrics:YP,columns:n,width:(()=>{const r=n.length-1|0;return r>=0&&r<n.length?n[r].x+84:48})(),height:e+48,headerTop:24,headerBottom:60,bodyTop:84,bodyBottom:e,diagram:t}},jP=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=T;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=J("Just",i._4);continue}}g()}return o},hm=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},pm=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},mm=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ZP=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},t6=v(t=>e=>it(ut)(e)()(t))(M),e6={r:255,g:255,b:255,a:255},oc={r:26,g:26,b:26,a:255},n6={color:{r:232,g:232,b:232,a:255},flat:!0},r6={r:232,g:232,b:232,a:255},ic=t=>e=>n=>r=>o=>[1,t+o,e,2,n-o,e,3,n,e,n,e+o,2,n,r-o,3,n,r,n-o,r,2,t+o,r,3,t,r,t,r-o,2,t,e+o,3,t,e,t+o,e,...ni],ym=t=>e=>n=>({...n,stack:wt(n.stack)(t),openedAt:it(ut)(t)(e)(n.openedAt)}),ac=t=>e=>{const n=e.stack.length-1|0;if(n>=0&&n<e.stack.length){const r=jP(e.stack[n])(e.openedAt),o=(()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return r._1;g()})();return{...e,stack:e.stack.length===0?[]:Rt(0,e.stack.length-1|0,e.stack),openedAt:Ai(ut)(e.stack[n])(e.openedAt),spans:wt(e.spans)({col:e.stack[n],fromRow:o,toRow:hm(o)(t)})}}return e},xm=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i,f=_.stack.length-1|0;if(f>=0&&f<_.stack.length){if(u(_.stack[f])){a=!1,s=_;continue}r=u,o=c,i=ac(c)(_);continue}a=!1,s=_}return s},Tm=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=s.stack.length-1|0;if(u>=0&&u<s.stack.length){n=a,r=ac(a)(s);continue}o=!1,i=s}return i},o6=t=>e=>{const n=gn(ro)(e.fromCol)(t.stack)?xm((()=>{const r=e.fromCol;return o=>r===o})())(e.row-1|0)(t):ym(e.fromCol)(e.row)(Tm(e.row-1|0)(t));if(gn(ro)(e.toCol)(n.stack)){const r=xm((()=>{const o=e.toCol;return i=>o===i})())(e.row-1|0)(ac(e.row)(n));return{...r,returnRows:it(ut)(e.row)()(r.returnRows)}}return ym(e.toCol)(e.row)(n)},i6=t=>e=>n=>{const r=o6(e)(n);return pm(n.row)(t)?Tm(n.row)(r):r},sc={color:{r:26,g:26,b:26,a:255},width:1.5,lineJoin:qa,lineCap:Ir},wm={r:26,g:26,b:26,a:255},a6={color:{r:130,g:130,b:130,a:255},width:1,lineJoin:qa,lineCap:In},Nm={color:{r:26,g:26,b:26,a:255},width:1.5,lineJoin:qa,lineCap:In},s6={color:{r:244,g:244,b:244,a:255},flat:!0},Jm=t=>e=>n=>ue(r=>r.col===e&&r.fromRow<=n&&n<=r.toRow,t),vm={color:{r:90,g:90,b:90,a:255},width:1,lineJoin:qa,lineCap:In},u6={stack:[],openedAt:M,spans:[],returnRows:M},c6={color:{r:150,g:150,b:150,a:255},width:1,lineJoin:qa,lineCap:In},g6=t=>e=>n=>r=>o=>{const i=e.bodyTop+(rt(o)+.5)*e.metrics.rowHeight-e.metrics.rowHeight/2;return t.strokePath([1,n,i,2,r,i])(c6)},_6=t=>{const e=t.Monad0(),n=e.Bind1(),r=Si(e.Applicative0())(Wt);return o=>i=>{const a=o.bodyTop+(rt(i.fromRow)+.5)*o.metrics.rowHeight-o.metrics.rowHeight/2-6,s=i.fromCol>=0&&i.fromCol<o.columns.length?o.columns[i.fromCol].x-16:o.metrics.padding-16,u=[1,s,a,2,s+38,a,2,s+32,a+14,2,s,a+14,...ni],c=i.toCol>=0&&i.toCol<o.columns.length?o.columns[i.toCol].x+16:o.metrics.padding+16,_=o.bodyTop+(rt(hm(i.toRow)(i.fromRow+1|0)-1|0)+.5)*o.metrics.rowHeight+o.metrics.rowHeight/2+6;return n.bind(t.strokePath([1,s,a,2,c,a,2,c,_,2,s,_,...ni])(vm))(()=>n.bind(t.fillStrokePath(u)(n6)(vm))(()=>n.bind(t.drawText({x:s+6,y:a+7,content:"par",font:{family:"Inter",size:11,weight:700},color:oc,align:po,baseline:Un}))(()=>r(i.regionDividers)(g6(t)(o)(s)(c)))))}},Cm=t=>e=>t>=e?[]:[S(t,mm(e)(t+6)),...Cm(t+10)(e)],f6=t=>e=>{if(e<=t)return[];const n=r=>r>=e?[]:[S(r,mm(e)(r+6)),...n(r+10)];return n(t)},l6=t=>{const e=Si(t.Monad0().Applicative0())(Wt);return n=>r=>e(f6(n.headerTop+n.metrics.headerHeight+rt(r.lifeline.createdAt)*n.metrics.rowHeight+4)((()=>{if(r.lifeline.destroyedAt.tag==="Just")return n.bodyTop+(rt(r.lifeline.destroyedAt._1)+.5)*n.metrics.rowHeight;if(r.lifeline.destroyedAt.tag==="Nothing")return n.bodyBottom;g()})()))(o=>t.strokePath([1,r.x,o._1,2,r.x,o._2])(a6))},bm=t=>e=>t<=e?[]:[S(t,ZP(e)(t-6)),...bm(t-6-4)(e)],d6=t=>e=>t===e?[]:t<e?Cm(t)(e):bm(t)(e),h6=t=>{const e=t.Monad0().Bind1();return n=>r=>{const o=n.headerTop+rt(r.lifeline.createdAt)*n.metrics.rowHeight,i=n.metrics.headerWidth/2,a=o+n.metrics.headerHeight,s=ic(r.x-i)(o)(r.x+i)(a)(6);return e.bind(t.fillStrokePath(ic(r.x-i)(o+5)(r.x+i)(a+5)(6))({color:r6,flat:!0})(Nm))(()=>e.bind(t.fillStrokePath(s)(s6)(Nm))(()=>t.drawText({x:r.x,y:o+n.metrics.headerHeight/2,content:r.lifeline.label,font:{family:"Inter",size:14,weight:600},color:oc,align:ei,baseline:Un})))}},p6=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=s.stack.length-1|0;if(u>=0&&u<s.stack.length){n=a,r=ac(a)(s);continue}o=!1,i=s}return i},m6=t=>p6((()=>{const e=t.diagram.messages.length-1|0;return e>=0&&e<t.diagram.messages.length?t.diagram.messages[e].row:0})())(v(i6(t6(t.diagram.frameEndRows)))(u6)(gt(e=>e.kind==="Sync"||e.kind!=="SelfMsg",t.diagram.messages))),y6=t=>{const e=t.Monad0().Bind1();return n=>r=>{const o=n.bodyTop+(rt(r.row)+.5)*n.metrics.rowHeight,i=r.fromCol>=0&&r.fromCol<n.columns.length?n.columns[r.fromCol].x:n.metrics.padding,a=o-n.metrics.rowHeight*.3,s=i+36,u=o+n.metrics.rowHeight*.3,c=i+10,_=[1,i,u,2,c,u-5,2,c,u+5,...ni];return e.bind(t.strokePath([1,i,a,2,s,a,2,s,u,2,i,u])(sc))(()=>e.bind(t.fillPath(_)({color:wm,flat:!0}))(()=>t.drawText({x:i+42,y:o,content:Vn(" ")(V(ua)(r.labels)),font:{family:"Inter",size:12,weight:400},color:oc,align:po,baseline:Un})))}},x6=t=>{const e=t.Monad0(),n=e.Bind1(),r=Si(e.Applicative0())(Wt);return o=>i=>a=>s=>{const u=a?o.bodyTop+(rt(s.row)+.5)*o.metrics.rowHeight+o.metrics.rowHeight*.5:o.bodyTop+(rt(s.row)+.5)*o.metrics.rowHeight,c=s.toCol>=s.fromCol?1:-1,_=(s.fromCol>=0&&s.fromCol<o.columns.length?o.columns[s.fromCol].x:o.metrics.padding)+(Jm(i)(s.fromCol)(s.row)?c*6:c*0),f=(s.toCol>=0&&s.toCol<o.columns.length?o.columns[s.toCol].x:o.metrics.padding)-(Jm(i)(s.toCol)(s.row)?c*6:c*0),l=f-c*10,d=a?t.strokePath([1,l,u-5,2,f,u,2,l,u+5])(sc):t.fillPath([1,f,u,2,l,u-5,2,l,u+5,...ni])({color:wm,flat:!0});return n.bind(a?r(d6(_)(f))(h=>t.strokePath([1,h._1,u,2,h._2,u])(sc)):t.strokePath([1,_,u,2,f,u])(sc))(()=>n.bind(d)(()=>t.drawText({x:(_+f)/2,y:u-6,content:Vn(" ")(V(ua)(s.labels)),font:{family:"Inter",size:12,weight:400},color:oc,align:ei,baseline:tb})))}},T6=t=>{const e=y6(t),n=x6(t);return r=>o=>i=>a=>{if(a.kind==="SelfMsg")return e(r)(a);if(a.kind==="Sync")return n(r)(o)(pm(a.row)(i))(a);g()}},km={color:{r:26,g:26,b:26,a:255},width:1.25,lineJoin:Ze,lineCap:In},w6={color:{r:232,g:232,b:232,a:255},flat:!0},N6={color:{r:252,g:252,b:252,a:255},flat:!0},J6=t=>e=>n=>{const r=n.col>=0&&n.col<e.columns.length?e.columns[n.col].x:e.metrics.padding,o=e.bodyTop+(rt(n.fromRow)+.5)*e.metrics.rowHeight,i=e.bodyTop+(rt(n.toRow)+.5)*e.metrics.rowHeight+e.metrics.rowHeight*.5,a=ic(r-6)(o)(r+6)(i)(3);return t.Monad0().Bind1().bind(t.fillStrokePath(ic(r-6)(o+5)(r+6)(i+5)(3))(w6)(km))(()=>t.fillStrokePath(a)(N6)(km))},Lm=t=>{const e=t.Monad0(),n=e.Bind1(),r=Si(e.Applicative0())(Wt),o=h6(t),i=l6(t),a=_6(t),s=T6(t);return u=>{const c=m6(u);return n.bind(t.setViewport({vx:0,vy:0,vw:u.width,vh:u.height}))(()=>n.bind(t.clearBackground(e6))(()=>n.bind(r(u.columns)(o(u)))(()=>n.bind(r(u.columns)(i(u)))(()=>n.bind(r(c.spans)(J6(t)(u)))(()=>n.bind(r(u.diagram.fragments)(a(u)))(()=>r(u.diagram.messages)(s(u)(c.spans)(c.returnRows))))))))}},v6=Lm(mb);function Sm(t){return function(e){return function(){return t.add(e)}}}function x1(t,e,n,r){if(typeof window<"u"){var o=window[n];if(o!=null&&r instanceof o)return e(r)}for(var i=r;i!=null;){var a=Object.getPrototypeOf(i),s=a.constructor.name;if(s===n)return e(r);if(s==="Object")return t;i=a}return t}function Em(t){return function(){return t.classList}}function xn(t){return function(e){return function(n){return function(){n.setAttribute(t,e)}}}}function C6(t){return function(e){return function(){return e.getAttribute(t)}}}const b6=t=>{const e=C6(t);return n=>{const r=e(n);return()=>{const o=r();return Sn(o,T,Vt)}}};function k6(t){return function(e){return function(){e.textContent=t}}}function L6(t){return function(){return function(e){return t(e)()}}}function S6(t){return function(e){return function(n){return function(r){return function(){return r.addEventListener(t,e,n)}}}}}const T1=function(){return window};function E6(t){return function(e){return function(){e.value=t}}}function P6(t){return function(){return t.valueAsNumber}}function G6(t){return function(){return t.value}}function w1(t){return function(e){return function(){return e.requestAnimationFrame(t)}}}const is=t=>t,as=t=>()=>{const e=t.getBoundingClientRect?.(),n=e?.width||t.clientWidth||0,r=e?.height||t.clientHeight||0;return{width:n,height:r}},Pm=t=>e=>()=>{let n=0;const r=()=>{n||(n=requestAnimationFrame(()=>{n=0,e()}))},o=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return o?.observe(t),window.addEventListener("resize",r),()=>{n&&cancelAnimationFrame(n),o?.disconnect(),window.removeEventListener("resize",r)}},Gm=()=>window.devicePixelRatio||1,Rm=()=>performance.now()/1e3,R6=t=>e=>n=>r=>o=>()=>{const i=Math.max(1,e||t.clientWidth||r),a=Math.max(1,n||t.clientHeight||o),s="Markgraf needs more room",u=`Resize to at least ${Math.round(r)} \xD7 ${Math.round(o)} px`;if(t.setAttribute("data-mg-too-small","1"),t.setAttribute("data-mg-viewport-css-width",String(e||0)),t.setAttribute("data-mg-viewport-css-height",String(n||0)),t.setAttribute("data-mg-camera-vw","0"),t.setAttribute("data-mg-camera-vh","0"),t.setAttribute("data-mg-camera-zoom","0"),t instanceof SVGElement){t.setAttribute("viewBox",`0 0 ${i} ${a}`),t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.innerHTML=`
12
+ }`);const n=t.op._1;return Le.state(r=>E(void 0,{...r,enterStack:Et(r.enterStack)(n.id),scenes:Et(r.scenes)(Oi("EnterNode",n.id))}))}if(t.op.tag==="Exit"){const n=Sr(e.enterStack);if(n.tag==="Nothing")return Nr("`out` without a matching `into`");if(n.tag==="Just"){const r=n._1.init;return Le.state(o=>E(void 0,{...o,enterStack:r,scenes:Et(o.scenes)(xx)}))}g()}return ye.pure()}g()})),cc={structural:[],flow:!1,dives:[]},C4=Kt.bind(Ke)(t=>{if(t.error.tag==="Just")return ye.pure();if(t.error.tag==="Nothing"){if(t.currentKf.tag==="Just"){const e=t.currentKf._1;return Le.state(n=>E(void 0,{...n,scenes:Et(n.scenes)(Oi("Hold",e))}))}if(t.currentKf.tag==="Nothing")return ye.pure()}g()}),L4=t=>e=>Kt.bind(Ke)(n=>{const r="ev-"+ue(n.eventCounter);return Kt.bind((()=>{const o={...n,eventCounter:n.eventCounter+1|0};return Le.state(i=>E(void 0,o))})())(()=>ye.pure({events:[{id:r,kind:e,when:t}],firstId:w("Just",r),lastId:w("Just",r)}))}),k4=t=>t.tag==="DataFlow"?w("Just",t._1):y,S4=t=>ht(e=>T1(e)(t.graphEdges))(It(Ri,K0(t.currEdges))),E4=t=>e=>{const n=_t(o=>o.from.node===e.id||o.to.node===e.id,S4(t)),r=sc(q1)(o=>i=>{const a=i.from+"->"+e.id,s=e.id+"->"+i.to,u=i.from+"->"+i.to,c="via "+i.from+" "+i.to+": no edge "+i.from+"\u2192"+e.id;if(!Tr(a)(t.currEdges))return Dt("Left",c);const _="via "+i.from+" "+i.to+": no edge "+e.id+"\u2192"+i.to;if(!Tr(s)(t.currEdges))return Dt("Left",_);const f="via "+i.from+" "+i.to+": would create "+i.from+"\u2192"+i.to+" but it already exists";return Tr(u)(t.currEdges)||KE(u)(o.synthesized)?Dt("Left",f):Dt("Right",{consumed:it(B)(a)()(it(B)(s)()(o.consumed)),synthesized:it(B)(u)({id:u,from:{node:i.from,port:y},to:{node:i.to,port:y},label:y})(o.synthesized)})})({consumed:O,synthesized:O})(e.via);return(()=>{if(r.tag==="Left"){const o=r._1;return i=>Dt("Left",o)}if(r.tag==="Right"){const o=r._1;return i=>i(o)}g()})()(o=>{const i=o.consumed,a=_t(s=>!Tr(s.id)(i),n);return a.length===0?Dt("Right",{nextCurrEdges:en(B.compare,je,Yn(B.compare,t.currEdges,YE(Y(s=>s.id)(n))),XE((()=>{const s=u=>{if(u.tag==="Leaf")return O;if(u.tag==="Node")return ee("Node",u._1,u._2,u._3,void 0,s(u._5),s(u._6));g()};return s(o.synthesized)})())),synthesized:o.synthesized}):Dt("Left","cannot delete node "+e.id+": still connected ("+Zn(", ")(Y(s=>(()=>{const u=cr("conn:")(s.id);if(u.tag==="Just")return!1;if(u.tag==="Nothing")return!0;g()})()?s.from.node+"\u2192"+s.to.node:s.from.node+"--"+s.to.node)(a))+"). Use `- a -> b` or `- a -- b` to drop them, or `via a b` to merge "+e.id+"'s endpoints.")})},am=t=>e=>n=>{if(t){if(e){const i=0<n.operands.length?n.operands[0]:n.span,a=1<n.operands.length?n.operands[1]:n.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}}return 0<n.operands.length?n.operands[0]:n.span}if(e)return 1<n.operands.length?n.operands[1]:n.span;const r=0<n.operands.length?n.operands[0]:n.span,o=1<n.operands.length?n.operands[1]:n.span;return{line:r.line,column:r.column,endLine:o.endLine,endColumn:o.endColumn}},sm=t=>{if(t.tag==="Leaf")return[t._1];if(t.tag==="Par"||t.tag==="Seq"||t.tag==="GroupSeq")return St(t._1)(sm);g()},P4=t=>({nodes:Y(Js)(t.graphNodes),edges:(()=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Jt("Cons",n._4,e(n._6,r)));g()};return It(ge.foldr,e(t.graphEdges,z))})(),constraints:[]}),L1=t=>{if(t.tag==="Leaf")return t._1.op.tag==="AddNode"||t._1.op.tag==="DelNode"||t._1.op.tag==="ModNode"||t._1.op.tag==="ModNodeSlot"||t._1.op.tag==="AddEdge"||t._1.op.tag==="DelEdge"||t._1.op.tag==="RepointEdge"?{...cc,structural:[t._1]}:t._1.op.tag==="Enter"||t._1.op.tag==="Exit"?{...cc,dives:[t._1]}:{...cc,flow:!0};if(t.tag==="Seq"||t.tag==="GroupSeq"||t.tag==="Par")return v(l4)(cc)(Y(L1)(t._1));g()},gc=t=>{if(t.tag==="Leaf")return t._1.op.tag==="AddNode"||t._1.op.tag==="DelNode"||t._1.op.tag==="ModNode"||t._1.op.tag==="ModNodeSlot"||t._1.op.tag==="AddEdge"||t._1.op.tag==="DelEdge"||t._1.op.tag==="RepointEdge"?[Gi("StepStructural",[t._1])]:t._1.op.tag==="Enter"||t._1.op.tag==="Exit"?[Gi("StepDive",t._1)]:[Gi("StepFlow",t)];if(t.tag==="Seq")return St(t._1)(gc);if(t.tag==="GroupSeq")return A4(t)(t._1);if(t.tag==="Par")return G4(t)(t._1);g()},G4=t=>e=>{const n=L1(t);return n.structural.length!==0&&!n.flow&&n.dives.length===0?[Gi("StepStructural",n.structural)]:n.structural.length===0&&n.flow&&n.dives.length===0?[Gi("StepFlow",t)]:n.structural.length===0&&!n.flow&&n.dives.length!==0?Y(j0)(n.dives):St(e)(gc)},A4=t=>e=>{const n=L1(t);return n.structural.length===0&&n.flow&&n.dives.length===0?[Gi("StepFlow",t)]:n.structural.length===0&&!n.flow&&n.dives.length!==0?Y(j0)(n.dives):St(e)(gc)},B4=t=>e=>Kt.bind(Ke)(n=>{const r=e.from+"->"+e.to,o=e.newFrom+"->"+e.newTo;return Tr(r)(n.currEdges)?wr(e.newFrom)(n.currNodes)?wr(e.newTo)(n.currNodes)?r!==o&&Tr(o)(n.currEdges)?We((()=>{const i=2<t.operands.length?t.operands[2]:t.span,a=3<t.operands.length?t.operands[3]:t.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}})())("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": target edge already exists"):Le.state(i=>E(void 0,{...i,currEdges:it(B)(o)()(Qi(B)(r)(i.currEdges)),graphEdges:it(B)(o)({id:o,from:{node:e.newFrom,port:y},to:{node:e.newTo,port:y},label:y})(i.graphEdges)})):We(3<t.operands.length?t.operands[3]:t.span)("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newTo):We(2<t.operands.length?t.operands[2]:t.span)("cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newFrom):We((()=>{const i=0<t.operands.length?t.operands[0]:t.span,a=1<t.operands.length?t.operands[1]:t.span;return{line:i.line,column:i.column,endLine:a.endLine,endColumn:a.endColumn}})())("cannot repoint "+e.from+"\u2192"+e.to+": edge does not exist")}),R4=t=>e=>{const n=ht(k4)(e.scenes),r=_t(h4(ZE(Y(a=>a.keyframe)(n))),e.keyframes),o=Yn(B.compare,b1(a=>a.nodes)(r),b1(x4)(n)),i=Yn(B.compare,C1(a=>a.edges)(r),C1(w4)(n));return t!=="AnimatedSurface"||n.length===0||o.tag==="Leaf"&&i.tag==="Leaf"?y:w("Just",m4(e)(o)(i))},D4=t=>e=>{const n=e.to+"->"+e.from,r=e.from+"->"+e.to,o=e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;if(Tr(r)(t.currEdges))return w("Just",{id:r,direction:Bf});if(Tr(n)(t.currEdges))return w("Just",{id:n,direction:Rf});const i=T1(o)(t.graphEdges);if(i.tag==="Just")return Tr(o)(t.currEdges)?w("Just",{id:o,direction:i._1.from.node===e.from&&i._1.to.node===e.to?Bf:Rf}):y;if(i.tag==="Nothing")return y;g()},F4=t=>e=>{if(e.op.tag==="Token"){const n=e.op._1;return Kt.bind(Ke)(r=>{const o=!wr(n.from)(r.currNodes),i=!wr(n.to)(r.currNodes);if(o||i)return Kt.bind(We(am(o)(i)(e))(o?i?"token references unknown node: "+n.from+", "+n.to:"token references unknown node: "+n.from:i?"token references unknown node: "+n.to:"token references unknown node: "))(()=>ye.pure({events:[],firstId:y,lastId:y}));const a=D4(r)(n);if(a.tag==="Just")return L4(t)(hx("SendToken",{from:n.from,to:n.to,edge:a._1.id,direction:a._1.direction,labels:n.labels}));if(a.tag==="Nothing")return Kt.bind(We((()=>{const s=0<e.operands.length?e.operands[0]:e.span,u=1<e.operands.length?e.operands[1]:e.span;return{line:s.line,column:s.column,endLine:u.endLine,endColumn:u.endColumn}})())("token "+n.from+"\u2192"+n.to+": no edge between "+n.from+" and "+n.to))(()=>ye.pure({events:[],firstId:y,lastId:y}));g()})}return ye.pure({events:[],firstId:y,lastId:y})},z4=t=>e=>{const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return ye.pure({events:[],firstId:y,lastId:y});if(n.tag==="Just"){const r=n._1.tail;return Kt.bind(ds(t)(n._1.head))(o=>Kt.bind(sc({Applicative0:()=>Pi(Vn),Bind1:()=>Ei(Vn)})(i=>a=>Kt.bind(ds((()=>{if(i.lastId.tag==="Just")return og("After",i.lastId._1);if(i.lastId.tag==="Nothing")return t;g()})())(a))(s=>ye.pure({events:[...i.events,...s.events],firstId:(()=>{if(i.firstId.tag==="Just")return w("Just",i.firstId._1);if(i.firstId.tag==="Nothing")return s.firstId;g()})(),lastId:(()=>{if(s.lastId.tag==="Just")return w("Just",s.lastId._1);if(s.lastId.tag==="Nothing")return i.lastId;g()})()})))(o)(r))(i=>ye.pure(i)))}g()},I4=t=>e=>{const n=Ft(r=>y,r=>o=>w("Just",{head:r,tail:o}),e);if(n.tag==="Nothing")return ye.pure({events:[],firstId:y,lastId:y});if(n.tag==="Just"){const r=n._1.tail;return Kt.bind(ds(t)(n._1.head))(o=>Kt.bind(Q4((()=>{if(o.firstId.tag==="Just")return og("With",o.firstId._1);if(o.firstId.tag==="Nothing")return t;g()})())(r))(i=>ye.pure({events:[...o.events,...i.events],firstId:o.firstId,lastId:(()=>{if(o.lastId.tag==="Just")return w("Just",o.lastId._1);if(o.lastId.tag==="Nothing")return i.lastId;g()})()})))}g()},ds=t=>e=>{if(e.tag==="Leaf"){const n=e._1;return Kt.bind((()=>{const r=n.span;return Le.state(o=>E(void 0,{...o,currentSpan:r}))})())(()=>F4(t)(n))}if(e.tag==="Seq"||e.tag==="GroupSeq")return z4(t)(e._1);if(e.tag==="Par")return I4(t)(e._1);g()},Q4=t=>sc({Applicative0:()=>Pi(Vn),Bind1:()=>Ei(Vn)})(e=>n=>Kt.bind(ds(t)(n))(r=>ye.pure({events:[...e.events,...r.events],firstId:(()=>{if(e.firstId.tag==="Just")return w("Just",e.firstId._1);if(e.firstId.tag==="Nothing")return r.firstId;g()})(),lastId:(()=>{if(r.lastId.tag==="Just")return w("Just",r.lastId._1);if(r.lastId.tag==="Nothing")return e.lastId;g()})()})))({events:[],firstId:y,lastId:y}),M4=t=>Kt.bind(Ke)(e=>{if(e.currentKf.tag==="Nothing")return Nr("flow ops before any structural frame");if(e.currentKf.tag==="Just"){const n=e.currentKf._1;return Kt.bind(ds(yx)(t))(r=>Kt.bind(Ke)(o=>{const i={...o,scenes:Et(o.scenes)(Oi("DataFlow",{keyframe:n,events:r.events,focus:y}))};return Le.state(a=>E(void 0,i))}))}g()}),O4=t=>e=>Le.state(n=>E(void 0,{...n,graphNodes:c4(t.id)({id:t.id,size:d4(t.width),ports:[],label:w("Just",Ja(e)),shape:t.shape})(n.graphNodes),currNodes:it(B)(t.id)()(n.currNodes),currLabels:it(B)(t.id)(Ja(e))(n.currLabels),currLabelTemplates:it(B)(t.id)(e)(n.currLabelTemplates)})),W4=t=>{if(t.op.tag==="AddNode"){const e=t.op._1;return Kt.bind(Ke)(n=>{if(wr(e.id)(n.currNodes))return We(0<t.operands.length?t.operands[0]:t.span)("cannot add node "+e.id+": already exists");const r=ic(e.label);if(r.tag==="Left")return We(0<t.operands.length?t.operands[0]:t.span)("invalid label for node "+e.id+": "+r._1);if(r.tag==="Right")return O4(e)(r._1);g()})}if(t.op.tag==="DelNode"){const e=t.op._1;return Kt.bind(Ke)(n=>{if(!wr(e.id)(n.currNodes))return We(0<t.operands.length?t.operands[0]:t.span)("cannot delete node "+e.id+": does not exist");const r=E4(n)(e);if(r.tag==="Left")return We(0<t.operands.length?t.operands[0]:t.span)(r._1);if(r.tag==="Right"){const o=r._1;return Le.state(i=>E(void 0,{...i,currNodes:Qi(B)(e.id)(i.currNodes),currEdges:o.nextCurrEdges,graphEdges:en(B.compare,je,o.synthesized,i.graphEdges)}))}g()})}if(t.op.tag==="ModNode"){const e=t.op._1;return Kt.bind(Ke)(n=>{if(!wr(e.id)(n.currNodes))return We(0<t.operands.length?t.operands[0]:t.span)("cannot relabel node "+e.id+": does not exist");if(e.label.tag==="Just"){const r=ic(e.label._1);if(r.tag==="Left")return We(0<t.operands.length?t.operands[0]:t.span)("invalid label for node "+e.id+": "+r._1);if(r.tag==="Right")return nm(e.id)(r._1);g()}if(e.label.tag==="Nothing")return ye.pure();g()})}if(t.op.tag==="ModNodeSlot"){const e=t.op._1;return Kt.bind(Ke)(n=>{if(!wr(e.id)(n.currNodes))return We(0<t.operands.length?t.operands[0]:t.span)("cannot update placeholder on node "+e.id+": does not exist");const r=U0(e.id)(n.currLabelTemplates);if(r.tag==="Nothing")return We(1<t.operands.length?t.operands[1]:t.span)("node "+e.id+" label has no placeholder `"+e.slot+"`");if(r.tag==="Just"){const o=$0(e.slot)(e.value)(r._1);if(o.tag==="Left")return We(1<t.operands.length?t.operands[1]:t.span)("node "+e.id+" "+o._1);if(o.tag==="Right")return nm(e.id)(o._1)}g()})}if(t.op.tag==="AddEdge"){const e=t.op._1;return Kt.bind(Ke)(n=>{const r=!wr(e.from)(n.currNodes),o=!wr(e.to)(n.currNodes);if(r||o)return We(am(r)(o)(t))((e.directed?"cannot add edge ":"cannot add connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": unknown node "+(r?o?e.from+", "+e.to:e.from:o?e.to:""));const i=e.directed?e.from+"->"+e.to:e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;return Tr(i)(n.currEdges)?We((()=>{const a=0<t.operands.length?t.operands[0]:t.span,s=1<t.operands.length?t.operands[1]:t.span;return{line:a.line,column:a.column,endLine:s.endLine,endColumn:s.endColumn}})())((e.directed?"cannot add edge ":"cannot add connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": already exists"):Le.state(a=>E(void 0,{...a,graphEdges:it(B)(i)({id:i,from:{node:e.from,port:y},to:{node:e.to,port:y},label:e.label})(a.graphEdges),currEdges:it(B)(i)()(a.currEdges)}))})}if(t.op.tag==="DelEdge"){const e=t.op._1;return Kt.bind(Ke)(n=>{const r=e.directed?e.from+"->"+e.to:e.from<=e.to?"conn:"+e.from+"--"+e.to:"conn:"+e.to+"--"+e.from;return Tr(r)(n.currEdges)?Le.state(o=>E(void 0,{...o,currEdges:Qi(B)(r)(o.currEdges)})):We((()=>{const o=0<t.operands.length?t.operands[0]:t.span,i=1<t.operands.length?t.operands[1]:t.span;return{line:o.line,column:o.column,endLine:i.endLine,endColumn:i.endColumn}})())((e.directed?"cannot delete edge ":"cannot delete connection ")+(e.directed?e.from+"\u2192"+e.to:e.from+"--"+e.to)+": does not exist")})}return t.op.tag==="RepointEdge"?B4(t)(t.op._1):ye.pure()},H4=t=>Kt.bind((()=>{const e=t.span;return Le.state(n=>E(void 0,{...n,currentSpan:e}))})())(()=>W4(t)),um=t=>e=>n=>Kt.bind(N1(H4)(n))(()=>Kt.bind(Ke)(r=>{const o=e.tag==="Just"&&e._1!==""?e._1:"kf-"+ue(r.kfCounter);if(oe(a=>a.id===o,r.keyframes))return Kt.bind(jE(_4)(0<n.length?w("Just",n[0]):y))(()=>Nr("duplicate frame name "+o));const i={...r,keyframes:Et(r.keyframes)({id:o,nodes:r.currNodes,edges:r.currEdges,labels:tm(r),kind:t,authored:(()=>{if(e.tag==="Just")return e._1!=="";if(e.tag==="Nothing")return!1;g()})()}),kfCounter:r.kfCounter+1|0,currentKf:w("Just",o),scenes:(()=>{if(r.currentKf.tag==="Nothing")return r.scenes;if(r.currentKf.tag==="Just")return Et(r.scenes)(Oi("Structural",{from:r.currentKf._1,to:o,focus:y}));g()})()};return Le.state(a=>E(void 0,i))})),$4=t=>e=>n=>{if(n.tag==="StepStructural")return Kt.bind((()=>{const r=um(Pa)(e?y:t)(n._1);return n._1.length!==0?r:ye.pure()})())(()=>ye.pure(!0));if(n.tag==="StepFlow"){const r=n._1,o=!e&&(()=>{if(t.tag==="Just")return t._1!=="";if(t.tag==="Nothing")return!1;g()})();return Kt.bind((()=>{const i=N4(t);return o?i:ye.pure()})())(()=>Kt.bind(M4(r))(()=>ye.pure(e||o)))}if(n.tag==="StepDive")return Kt.bind(b4(n._1))(()=>ye.pure(e));g()},cm=t=>e=>n=>{const r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),n);if(r.tag==="Nothing")return ye.pure();if(r.tag==="Just"){const o=r._1.head,i=r._1.tail;return Kt.bind(Ke)(a=>{if(a.error.tag==="Just")return ye.pure();if(a.error.tag==="Nothing")return Kt.bind($4(t)(e)(o))(s=>cm(t)(s)(i));g()})}g()},gm=t=>e=>{const n=sm(e.ops),r=_t(i=>i.op.tag==="AddNode"||i.op.tag==="DelNode"||i.op.tag==="ModNode"||i.op.tag==="ModNodeSlot"||i.op.tag==="AddEdge"||i.op.tag==="DelEdge"||i.op.tag==="RepointEdge",n),o=_t(i=>!(i.op.tag==="AddNode"||i.op.tag==="DelNode"||i.op.tag==="ModNode"||i.op.tag==="ModNodeSlot"||i.op.tag==="AddEdge"||i.op.tag==="DelEdge"||i.op.tag==="RepointEdge"),n);return 0<o.length?Kt.bind((()=>{const i=o[0].span;return Le.state(a=>E(void 0,{...a,currentSpan:i}))})())(()=>Nr("still/title blocks hold a still snapshot; they cannot contain movement tokens (`api ~> db`) or dive commands (`into`/`out`)")):t==="TitleCard"&&r.length===0?Nr(e.name.tag==="Just"&&e.name._1!==""?'title "'+e.name._1+'" has an empty body; give it nodes/edges to title, or use a still':"title has an empty body; give it nodes/edges to title, or use a still"):Kt.bind(um(t)(e.name)(r))(()=>C4)},q4=t=>Kt.bind(Ke)(e=>{if(e.error.tag==="Just")return ye.pure();if(e.error.tag==="Nothing"){if(t.kind==="AnimatedKeyframe")return cm(t.name)(!1)(gc(t.ops));if(t.kind==="Still")return gm(px)(t);if(t.kind==="Title")return gm(mx)(t);if(t.kind==="StepMarker")return v4(t)}g()}),_m=t=>Kt.bind(T4(t.interiors))(()=>Kt.bind(N1(q4)(t.frames))(()=>Kt.bind(Ke)(e=>{if(e.error.tag==="Just")return ye.pure(Dt("Left",e.error._1));if(e.error.tag==="Nothing"){const n=V4(t.interiors);if(n.tag==="Left")return ye.pure(Dt("Left",n._1));if(n.tag==="Right"){const r={seed:t.seed,minimumFontSize:t.minimumFontSize,stretchNodes:t.stretchNodes,graph:P4(e),keyframes:e.keyframes,scenes:e.scenes,interiors:n._1};return ye.pure((()=>{const o=R4(t.mode)(r);if(o.tag==="Just")return Dt("Left",{msg:o._1,line:0,column:0,endLine:0,endColumn:0});if(o.tag==="Nothing")return Dt("Right",r);g()})())}}g()}))),V4=t=>{const e=sc(q1)(n=>r=>{const o=_m(r.doc)(rm)._1;return(()=>{if(o.tag==="Left"){const i=o._1;return a=>Dt("Left",i)}if(o.tag==="Right"){const i=o._1;return a=>a(i)}g()})()(i=>Dt("Right",it(B)(r.node)(i)(n)))})(O)(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",e._1);g()},_c=(t,e)=>({tag:t,_1:e}),k1=SE(Qt),U4=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},K4=fe(B)(Qt),fm=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},ls=(()=>{const t=xt(Gt(r=>r==="}"))("'}'"),e=xt(Gt(r=>r==="#"))("'#'"),n=Gt(r=>r===`
13
+ `||r==="\r");return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>o(f=>t(L(u,c,!1),o,i,(l,d)=>o(h=>{const m=r._1,p=r._2;return o(x=>o(J=>e(L(m,p,!1),o,i,(T,N)=>o(k=>{const C=r._1,P=r._2;return o(G=>o(R=>n(L(C,P,!1),o,i,(U,S)=>o(b=>xa(r,o,i,a,s)),(U,S)=>o(b=>s(L(C,P,!1),void 0)))))}),(T,N)=>o(k=>s(L(m,p,!1),void 0)))))}),(l,d)=>o(h=>s(L(u,c,!1),void 0)))))}})(),Pn=t=>(e,n,r,o,i)=>n(a=>Wn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>t(_,n,r,o,(l,d)=>n(h=>{const m=_._3&&!l._3?L(l._1,l._2,!0):l;return n(p=>Wn(m,n,r,o,(x,J)=>n(T=>i(m._3&&!x._3?L(x._1,x._2,!0):x,E(d,{line:u.line,column:u.column,endLine:J.line,endColumn:J.column})))))})))}))),Y4=(()=>{const t=Gt(e=>e===" "||e===" "||e===`
14
+ `||e==="\r");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?L(s._1,s._2,!0):s,void 0))))})(),dm=(t,e,n,r,o)=>e(i=>Ee("#")(t,e,n,r,(a,s)=>e(u=>{const c=Ie(Gt(f=>f!==`
15
+ `)),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?L(l._1,l._2,!0):l,void 0))))}))),lm=xt((()=>{const t=xt(Gt(n=>n==="}"))("'}'"),e=Gt(n=>n===`
16
+ `||n==="\r");return(n,r,o,i,a)=>{const s=n._1,u=n._2;return r(c=>r(_=>t(L(s,u,!1),r,o,(f,l)=>r(d=>{const h=n._1,m=n._2;return r(p=>r(x=>dm(L(h,m,!1),r,o,(J,T)=>{const N=J._3;return r(k=>{if(N)return i(J,T);const C=n._1,P=n._2;return r(G=>r(R=>e(L(C,P,!1),r,o,(U,S)=>{const b=U._3;return r(I=>b?i(U,S):xa(n,r,o,i,a))},(U,S)=>r(b=>a(U,void 0)))))})},(J,T)=>r(N=>a(J,void 0)))))}),(f,l)=>r(d=>a(L(s,u,!1),void 0)))))}})())("newline or '}' (statements end at the end of the line)"),Nn=(()=>{const t=Ie((e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>Y4(L(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>f?o(c,_):dm(e,n,r,o,i))},i))});return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?L(s._1,s._2,!0):s,void 0))))})(),hm=(()=>{const t=Gt(e=>e!=="|");return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>n(c=>Ee("\\|")(L(a,s,!1),n,r,(_,f)=>n(l=>n(d=>t(e,n,r,o,(h,m)=>n(p=>i(h,Rn(m)))))),(_,f)=>n(l=>i(_,"|")))))}})(),X4=xt(k1([(t,e,n,r,o)=>e(i=>{const a=t._3;return Ee("->")(t,e,n,(s,u)=>r(L(s._1,s._2,a),u),(s,u)=>e(c=>o(s,!0)))}),(t,e,n,r,o)=>e(i=>{const a=t._3;return Ee("--")(t,e,n,(s,u)=>r(L(s._1,s._2,a),u),(s,u)=>e(c=>o(s,!1)))})]))("edge arrow '->' or '--'"),Z4=t=>t!==`
17
+ `&&t!=="\r"&&t!=="#"&&t!=="}"&&t!=="{",fc=Gt(t=>t>="a"&&t<="z"||t>="A"&&t<="Z"),j4=t=>t===" "||t===" "||t==="\r",t6=t=>kn(re(Er(j4)(re(Bn(t))).rest)),S1=t=>t===`
18
+ `||t==="\r"||t==="#"||t==="}",e6=t=>t===`
19
+ `||t==="\r"||t==="#"||t==="}"||t==="{",n6=t=>t!=="{"&&t!==`
20
+ `&&t!=="\r",pm=t=>Aa(t)==="",r6=t=>re(Er(pm)(re(Er(pm)(t).rest)).rest),o6=t=>(e=>n=>{let r=e,o=n,i=!0,a;for(;i;){const s=r,u=Ft(c=>y,c=>_=>w("Just",{head:c,tail:_}),o);if(u.tag==="Just"&&(u._1.head===" "||u._1.head===" ")){r=s+1|0,o=u._1.tail;continue}i=!1,a=s}return a})(0)(Bn(t)),i6=t=>{const e=Ft(n=>y,n=>r=>w("Just",{head:n,tail:r}),Y(o6)(_t(n=>Aa(n)!=="",t)));if(e.tag==="Nothing")return 0;if(e.tag==="Just")return v(U4)(e._1.head)(e._1.tail);g()},a6=(()=>{const t=xt(Gt(e=>e==="-"))("'-'");return(e,n,r,o,i)=>{const a=e._3;return n(s=>t(e,n,r,(u,c)=>o(L(u._1,u._2,a),c),(u,c)=>n(_=>{const f=Eo((()=>{const d=xt(Gt(m=>m===">"))("'>'"),h=xt(Gt(m=>m==="-"))("'-'");return(m,p,x,J,T)=>{const N=m._1,k=m._2;return p(C=>d(L(N,k,!1),p,x,(P,G)=>{const R=P._3;return p(U=>R?J(P,G):h(m,p,x,J,T))},T))}})()),l=e._3&&!u._3?L(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,m)=>o(L(h._1,h._2,a),m),(h,m)=>n(p=>i(l._3&&!h._3?L(h._1,h._2,!0):h,"-"))))})))}})(),ie=(()=>{const t=Ie(Gt(e=>e===" "||e===" "));return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>i(e._3&&!s._3?L(s._1,s._2,!0):s,void 0))))})(),Po=(()=>{const t=Gt(e=>e===" "||e===" ");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>ie(e._3&&!s._3?L(s._1,s._2,!0):s,n,r,o,i))))})(),mm=(t,e,n,r,o)=>e(i=>e(a=>ie(t,e,n,r,(s,u)=>e(c=>e(_=>{const f=t._3&&!s._3?L(s._1,s._2,!0):s;return ls(f,e,n,r,(l,d)=>e(h=>o(f._3&&!l._3?L(l._1,l._2,!0):l,d)))}))))),ym=(t,e,n,r,o)=>e(i=>ie(t,e,n,r,(a,s)=>e(u=>{const c=xt(Gt(f=>f==="-"))("'-'"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>{const l=(m,p)=>e(x=>(()=>{if(p.tag==="Just")return(J,T,N,k,C)=>T(P=>X4(J,T,N,k,(G,R)=>T(U=>C(G,w("Just",R)))));if(p.tag==="Nothing")return(J,T,N,k,C)=>C(J,y);g()})()(_._3&&!m._3?L(m._1,m._2,!0):m,e,n,r,o)),d=_._1,h=_._2;return e(m=>e(p=>c(L(d,h,!1),e,n,(x,J)=>e(T=>l(_,y)),(x,J)=>e(T=>l(L(d,h,!1),w("Just",J))))))})}))),s6=t=>{const e=cr("Expected ")(t),n=(()=>{if(e.tag==="Nothing")return t;if(e.tag==="Just")return e._1;g()})();return n==="'{'"?"Open the block with `{`.":n==="integer (seed value)"?"Put an integer after `seed`.":n==="number (min-font-size value)"?"Put a positive number after `min-font-size`.":n==="positive min-font-size value"?"`min-font-size` must be greater than zero.":n==="closing '}'"?"Close this block with `}`.":n===`closing '"' (unterminated string)`?'This string is unterminated; close it with `"`.':n==="closing '|'"?"Close this pipe label with `|`.":n==="space after '+'"?"Put a space after `+`: `+ api: API`.":n==="node identifier after '+'"?"Put a node id after `+`: `+ api: API`.":n==="space after '-'"?"Put a space after `-`: `- api`.":n==="node identifier after '-'"?"Put a node id after `-`: `- api`.":n==="space after '~'"?"Put a space after `~`: `~ api: API` or `~ api -> db => api -> cache`.":n==="node relabel label"?"Give the replacement label after `~ api`: `~ api: API`.":n==="node placeholder value"?"Give the replacement value after the placeholder name: `~ total.count: 3`.":n==="node identifier"?"Put a node identifier here.":n==="space after 'inside'"?"Put a space after `inside`: `inside api { ... }`.":n==="node identifier after 'inside'"?"Tell `inside` which node owns this interior: `inside api { ... }`.":n==="source node identifier after 'via'"?"Put the source node after `via`: `via a b`.":n==="target node identifier after 'via'"?"Put the second endpoint after `via`: `via a b`.":n==="source node identifier"?"Put a source node identifier here.":n==="new source node identifier"?"Put the new source node identifier after `=>`.":n==="new target node identifier"?"Put the new target node identifier after the replacement arrow.":n==="edge arrow '->' or '--'"?"Use `->` for a directed edge or `--` for an undirected edge.":n==="source edge arrow '->'"?"Use `->` in the edge you are changing: `~ api -> db => api -> cache`.":n==="replacement edge arrow '->'"?"Use `->` in the replacement edge: `~ api -> db => api -> cache`.":n==="repoint separator '=>'"?"Use `=>` before the replacement edge: `~ api -> db => api -> cache`.":n==="target node identifier"?"Put a target node after the arrow.":n==="'~>'"?"Use `~>` for movement from left to right.":n==="'<~'"?"Use `<~` for movement from right to left.":n==="'->' or '<-'"?"Use `~>` / `<~` for movement tokens.":n==='label ("\u2026", : rest-of-line, or |\u2026|)'?'label must use `: text`, `"text"`, or `|multi-line|`.':n==="attribute key"?"Start each attribute with a name, like `shape`.":n==="':'"?"Put `:` between the attribute name and value: `{shape: cylinder}`.":n==="attribute value"?"Put an attribute value after `:`.":n==="closing '}' for attributes"?"Close the attribute block with `}`.":n==="space after 'into'"?"Put a space after `into`: `into api`.":n==="node identifier after 'into'"?"Tell `into` which node to dive into.":n==="space after 'step'"?"Put a space after `step`: `step request`.":n==="step name"?"Name the step: `step request`.":n==="newline or '}' (statements end at the end of the line)"?"This statement has extra text. Put the next statement on a new line or close the block with `}`.":n==="statement (+ node, - node, + edge, - edge, ~ node, into, out, or 'a ~> b'/'a <~ b')"?"I don't recognize this statement. Start with `+`, `-`, `~`, `into`, `out`, `par`, `seq`, or movement like `api ~> db`.":n==="'scene', 'still', 'title', 'step', 'inside', a statement, or end of input"?"Start with a statement like `+ api: API`, a marker like `step request`, or a block with `scene`, `still`, `title`, or `inside`.":n},u6=t=>{const e=Aa(t),n=cr('"')(e),r=(()=>{if(n.tag==="Just")return Xy('"')(n._1);if(n.tag==="Nothing")return y;g()})(),o=(()=>{if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()})();return o===""?y:w("Just",o)},xm=t=>e=>t!=="AnimatedSurface"&&e.statements.length!==0?{...e,frames:Et(e.frames)((()=>{if(t==="StillSurface")return{name:y,ops:Or("Seq",e.statements),kind:v1};if(t==="SequenceSurface")return{name:y,ops:Or("Seq",e.statements),kind:uc};if(t==="AnimatedSurface")return{name:y,ops:Or("Seq",e.statements),kind:uc};g()})()),statements:[]}:e,c6=(()=>{const t=xt(Gt(e=>e==="\\"))("'\\\\'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>J1(_,n,r,o,(l,d)=>n(h=>i(_._3&&!l._3?L(l._1,l._2,!0):l,d==="n"?`
21
+ `:d==="t"?" ":d==="r"?"\r":d))))})))})(),g6=(()=>{const t=Gt(e=>e!=='"'&&e!=="\\"&&e!==`
22
+ `);return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>c6(L(a,s,!1),n,r,(c,_)=>n(f=>t(e,n,r,o,i)),i))}})(),Jm=(()=>{const t=xt(Gt(e=>e==='"'))(`'"'`);return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=Ie(g6),f=e._3&&!s._3?L(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(m=>{const p=xt(xt(Gt(J=>J==='"'))(`'"'`))(`closing '"' (unterminated string)`),x=f._3&&!d._3?L(d._1,d._2,!0):d;return n(J=>p(x,n,r,o,(T,N)=>n(k=>i(x._3&&!T._3?L(T._1,T._2,!0):T,kn(It(ge.foldr,h))))))})))})))})(),_6={frames:[],statements:[]},wm=t=>{const e=r6($i(`
23
+ `)(t));return Zn(`
24
+ `)(Y(t6)(Y(Mi(i6(e)))(e)))},f6=(t,e,n,r,o)=>{const i=t._3;return e(a=>Ee("|md")(t,e,n,(s,u)=>r(L(s._1,s._2,i),u),(s,u)=>e(c=>{const _=xt((l,d,h,m,p)=>{const x=l._1,J=l._2;return d(T=>Ee(`\r
25
+ `)(L(x,J,!1),d,h,(N,k)=>{const C=N._3;return d(P=>{if(C)return m(N,k);const G=l._1,R=l._2;return d(U=>Ee(`
26
+ `)(L(G,R,!1),d,h,(S,b)=>{const I=S._3;return d(H=>I?m(S,b):Ee("\r")(l,d,h,m,p))},p))})},p))})("newline after '|md'"),f=t._3&&!s._3?L(s._1,s._2,!0):s;return e(l=>_(f,e,n,(d,h)=>r(L(d._1,d._2,i),h),(d,h)=>e(m=>{const p=Ie(hm),x=f._3&&!d._3?L(d._1,d._2,!0):d;return e(J=>p(x,e,n,(T,N)=>r(L(T._1,T._2,i),N),(T,N)=>e(k=>{const C=xt(xt(Gt(G=>G==="|"))("'|'"))("closing '|'"),P=x._3&&!T._3?L(T._1,T._2,!0):T;return e(G=>C(P,e,n,(R,U)=>r(L(R._1,R._2,i),U),(R,U)=>e(S=>o(P._3&&!R._3?L(R._1,R._2,!0):R,"md:"+wm(Zn("")(It(ge.foldr,N)))))))})))})))})))},d6=(()=>{const t=xt(Gt(e=>e==="|"))("'|'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=Ie(hm),f=e._3&&!s._3?L(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(m=>{const p=xt(xt(Gt(J=>J==="|"))("'|'"))("closing '|'"),x=f._3&&!d._3?L(d._1,d._2,!0):d;return n(J=>p(x,n,r,o,(T,N)=>n(k=>i(x._3&&!T._3?L(T._1,T._2,!0):T,wm(Zn("")(It(ge.foldr,h)))))))})))})))})(),vr=Gt(t=>t>="0"&&t<="9"),l6=(()=>{const t=xt(Gt(e=>e==="_"))("'_'");return(e,n,r,o,i)=>{const a=e._1,s=e._2;return n(u=>fc(L(a,s,!1),n,r,(c,_)=>{const f=c._3;return n(l=>{if(f)return o(c,_);const d=e._1,h=e._2;return n(m=>vr(L(d,h,!1),n,r,(p,x)=>{const J=p._3;return n(T=>{if(J)return o(p,x);const N=e._1,k=e._2;return n(C=>t(L(N,k,!1),n,r,(P,G)=>{const R=P._3;return n(U=>R?o(P,G):a6(e,n,r,o,i))},i))})},i))})},i))}})(),He=(()=>{const t=xt(Gt(e=>e==="_"))("'_'");return(e,n,r,o,i)=>n(a=>{const s=(_,f)=>n(l=>{const d=Ie(l6),h=e._3&&!_._3?L(_._1,_._2,!0):_;return n(m=>d(h,n,r,o,(p,x)=>n(J=>i(h._3&&!p._3?L(p._1,p._2,!0):p,Rn(f)+kn(It(ge.foldr,x))))))}),u=e._1,c=e._2;return n(_=>fc(L(u,c,!1),n,r,(f,l)=>{const d=f._3;return n(h=>d?o(f,l):t(e,n,r,o,s))},s))})})(),h6=t=>e=>n=>(r,o,i,a,s)=>o(u=>ie(r,o,i,a,(c,_)=>o(f=>{const l=Pn(xt(He)("target node identifier")),d=r._3&&!c._3?L(c._1,c._2,!0):c;return o(h=>l(d,o,i,a,(m,p)=>o(x=>s(d._3&&!m._3?L(m._1,m._2,!0):m,{op:ir("DelEdge",{from:t,to:p._1,directed:n}),operands:[e,p._2]}))))}))),p6=(t,e,n,r,o)=>e(i=>Wn(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?L(a._1,a._2,!0):a;return e(_=>{const f=c._3;return e(l=>He(c,e,n,(d,h)=>r(L(d._1,d._2,f),h),(d,h)=>e(m=>{const p=c._3&&!d._3?L(d._1,d._2,!0):d;return e(x=>ie(p,e,n,(J,T)=>r(L(J._1,J._2,f),T),(J,T)=>e(N=>{const k=p._3&&!J._3?L(J._1,J._2,!0):J;return e(C=>{const P=(U,S)=>e(b=>{const I=k._3&&!U._3?L(U._1,U._2,!0):U;return e(H=>r(c._3&&!I._3?L(I._1,I._2,!0):I,or("Use `~>` / `<~` for movement tokens.",s)))}),G=k._1,R=k._2;return e(U=>Ee("->")(L(G,R,!1),e,n,(S,b)=>{const I=S._3;return e(H=>I?r(L(S._1,S._2,f),b):Ee("<-")(k,e,n,(Q,q)=>r(L(Q._1,Q._2,f),q),P))},P))})})))})))})}))),m6=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>Pn(He)(t,e,n,(u,c)=>r(L(u._1,u._2,a),c),(u,c)=>e(_=>{const f=t._3&&!u._3?L(u._1,u._2,!0):u;return e(l=>ie(f,e,n,(d,h)=>r(L(d._1,d._2,a),h),(d,h)=>e(m=>{const p=xt(Gt(J=>J==="~"))("'~'"),x=f._3&&!d._3?L(d._1,d._2,!0):d;return e(J=>{const T=(C,P)=>e(G=>{const R=x._3&&!C._3?L(C._1,C._2,!0):C;return e(U=>{const S=c._1,b=c._2,I=t._3&&!R._3?L(R._1,R._2,!0):R;return e(H=>ie(I,e,n,r,(Q,q)=>e($=>{const A=xt(Gt(W=>W==="~"))("'~'"),F=xt(Gt(W=>W==="<"))("'<'"),M=I._3&&!Q._3?L(Q._1,Q._2,!0):Q;return e(W=>{const D=(K,Z)=>e(tt=>{const et=Z==="~"?xt(Ee("~>"))("'~>'"):xt(Ee("<~"))("'<~'"),ft=M._3&&!K._3?L(K._1,K._2,!0):K;return e(Nt=>et(ft,e,n,r,(dt,mt)=>e(bt=>o(ft._3&&!dt._3?L(dt._1,dt._2,!0):dt,E(S,E(b,mt))))))}),X=M._1,V=M._2;return e(K=>A(L(X,V,!1),e,n,(Z,tt)=>{const et=Z._3;return e(ft=>et?r(M,tt):F(M,e,n,(Nt,dt)=>r(M,dt),(Nt,dt)=>D(M,dt)))},(Z,tt)=>D(M,tt)))})})))})}),N=x._1,k=x._2;return e(C=>p(L(N,k,!1),e,n,(P,G)=>{const R=P._3;return e(U=>R?r(L(x._1,x._2,a),G):e(S=>Ee("<~")(x,e,n,(b,I)=>r(L(x._1,x._2,a),I),(b,I)=>e(H=>T(x)))))},(P,G)=>T(x)))})})))})))}),y6=t=>e=>{const n=xt(Ee("->"))("source edge arrow '->'");return(r,o,i,a,s)=>o(u=>n(r,o,i,a,(c,_)=>o(f=>{const l=r._3&&!c._3?L(c._1,c._2,!0):c;return o(d=>ie(l,o,i,a,(h,m)=>o(p=>{const x=Pn(xt(He)("target node identifier")),J=l._3&&!h._3?L(h._1,h._2,!0):h;return o(T=>x(J,o,i,a,(N,k)=>o(C=>{const P=k._1,G=k._2,R=J._3&&!N._3?L(N._1,N._2,!0):N;return o(U=>ie(R,o,i,a,(S,b)=>o(I=>{const H=xt(Ee("=>"))("repoint separator '=>'"),Q=R._3&&!S._3?L(S._1,S._2,!0):S;return o(q=>H(Q,o,i,a,($,A)=>o(F=>{const M=Q._3&&!$._3?L($._1,$._2,!0):$;return o(W=>ie(M,o,i,a,(D,X)=>o(V=>{const K=Pn(xt(He)("new source node identifier")),Z=M._3&&!D._3?L(D._1,D._2,!0):D;return o(tt=>K(Z,o,i,a,(et,ft)=>o(Nt=>{const dt=ft._1,mt=ft._2,bt=Z._3&&!et._3?L(et._1,et._2,!0):et;return o(Ht=>ie(bt,o,i,a,(Tt,Vt)=>o(At=>{const vt=xt(Ee("->"))("replacement edge arrow '->'"),pt=bt._3&&!Tt._3?L(Tt._1,Tt._2,!0):Tt;return o(gt=>vt(pt,o,i,a,(wt,Rt)=>o(yt=>{const Ct=pt._3&&!wt._3?L(wt._1,wt._2,!0):wt;return o(Wt=>ie(Ct,o,i,a,(zt,se)=>o(_e=>{const pn=Pn(xt(He)("new target node identifier")),qt=Ct._3&&!zt._3?L(zt._1,zt._2,!0):zt;return o(jt=>pn(qt,o,i,a,(an,$e)=>o($n=>s(qt._3&&!an._3?L(an._1,an._2,!0):an,{op:ir("RepointEdge",{from:t,to:P,newFrom:dt,newTo:$e._1}),operands:[e,G,mt,$e._2]}))))})))})))})))})))})))})))})))})))})))})))},x6=(t,e,n,r,o)=>e(i=>vr(t,e,n,r,(a,s)=>e(u=>{const c=Ie(vr),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const m=gy(Rn(s)+kn(It(ge.foldr,d)));return(()=>{if(m.tag==="Just"){const p=m._1;return(x,J,T,N,k)=>k(x,p)}if(m.tag==="Nothing")return(p,x,J,T,N)=>N(p,0);g()})()(_._3&&!l._3?L(l._1,l._2,!0):l,e,n,r,o)})))}))),Tm=t=>(e,n,r,o,i)=>{const a=e._3;return n(s=>Ee(t)(e,n,r,(u,c)=>o(L(u._1,u._2,a),c),(u,c)=>n(_=>{const f=Eo((()=>{const d=xt(Gt(m=>m==="_"))("'_'"),h=xt(Gt(m=>m==="-"))("'-'");return(m,p,x,J,T)=>{const N=m._1,k=m._2;return p(C=>fc(L(N,k,!1),p,x,(P,G)=>{const R=P._3;return p(U=>{if(R)return J(P,G);const S=m._1,b=m._2;return p(I=>vr(L(S,b,!1),p,x,(H,Q)=>{const q=H._3;return p($=>{if(q)return J(H,Q);const A=m._1,F=m._2;return p(M=>d(L(A,F,!1),p,x,(W,D)=>{const X=W._3;return p(V=>X?J(W,D):h(m,p,x,J,T))},T))})},T))})},T))}})()),l=e._3&&!u._3?L(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,m)=>o(L(h._1,h._2,a),m),(h,m)=>n(p=>{const x=l._3&&!h._3?L(h._1,h._2,!0):h;return n(J=>Nn(x,n,r,(T,N)=>o(L(T._1,T._2,a),N),(T,N)=>n(k=>i(x._3&&!T._3?L(T._1,T._2,!0):T,t))))})))})))},J6=(t,e,n,r,o)=>e(i=>Tm("stretch-nodes")(t,e,n,r,(a,s)=>e(u=>o(a,void 0)))),w6=(t,e,n,r,o)=>e(i=>e(a=>vr(t,e,n,r,(s,u)=>e(c=>{const _=Ie(vr),f=t._3&&!s._3?L(s._1,s._2,!0):s;return e(l=>_(f,e,n,r,(d,h)=>e(m=>{const p=f._3&&!d._3?L(d._1,d._2,!0):d,x=Rn(u)+kn(It(ge.foldr,h));return e(J=>{const T=xt(Gt(k=>k==="."))("'.'"),N=t._3&&!p._3?L(p._1,p._2,!0):p;return e(k=>{const C=(R,U)=>e(S=>{const b=Rc((()=>{if(U.tag==="Nothing")return x+"";if(U.tag==="Just")return x+U._1;g()})(),Na,Xt,y);return(()=>{if(b.tag==="Just"){const I=b._1;return(H,Q,q,$,A)=>A(H,I)}if(b.tag==="Nothing")return(I,H,Q,q,$)=>$(I,0);g()})()(N._3&&!R._3?L(R._1,R._2,!0):R,e,n,r,o)}),P=N._1,G=N._2;return e(R=>e(U=>{const S=(b,I)=>{const H=b._3;return e(Q=>H?r(b,I):C(N,y))};return e(b=>T(L(P,G,!1),e,n,S,(I,H)=>e(Q=>e(q=>e($=>vr(I,e,n,S,(A,F)=>e(M=>{const W=Ie(vr),D=I._3&&!A._3?L(A._1,A._2,!0):A;return e(X=>W(D,e,n,S,(V,K)=>e(Z=>{const tt=D._3&&!V._3?L(V._1,V._2,!0):V,et=Rn(F)+kn(It(ge.foldr,K));return e(ft=>{const Nt=I._3&&!tt._3?L(tt._1,tt._2,!0):tt,dt=Rn(H)+et;return e(mt=>C(Nt,w("Just",dt)))})})))})))))))}))})})})))})))),T6=(t,e,n,r,o)=>e(i=>vr(t,e,n,r,(a,s)=>e(u=>{const c=Ie((()=>{const f=xt(Gt(l=>l==="."))("'.'");return(l,d,h,m,p)=>{const x=l._1,J=l._2;return d(T=>vr(L(x,J,!1),d,h,(N,k)=>{const C=N._3;return d(P=>C?m(N,k):f(l,d,h,m,p))},p))}})()),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>o(_._3&&!l._3?L(l._1,l._2,!0):l,Rn(s)+kn(It(ge.foldr,d))))))}))),Gn=t=>(e,n,r,o,i)=>{const a=e._3;return n(s=>Ee(t)(e,n,r,(u,c)=>o(L(u._1,u._2,a),c),(u,c)=>n(_=>{const f=Eo((()=>{const d=xt(Gt(m=>m==="_"))("'_'"),h=xt(Gt(m=>m==="-"))("'-'");return(m,p,x,J,T)=>{const N=m._1,k=m._2;return p(C=>fc(L(N,k,!1),p,x,(P,G)=>{const R=P._3;return p(U=>{if(R)return J(P,G);const S=m._1,b=m._2;return p(I=>vr(L(S,b,!1),p,x,(H,Q)=>{const q=H._3;return p($=>{if(q)return J(H,Q);const A=m._1,F=m._2;return p(M=>d(L(A,F,!1),p,x,(W,D)=>{const X=W._3;return p(V=>X?J(W,D):h(m,p,x,J,T))},T))})},T))})},T))}})()),l=e._3&&!u._3?L(u._1,u._2,!0):u;return n(d=>f(l,n,r,(h,m)=>o(L(h._1,h._2,a),m),(h,m)=>n(p=>i(l._3&&!h._3?L(h._1,h._2,!0):h,void 0))))})))},N6=(t,e,n,r,o)=>e(i=>Gn("into")(t,e,n,r,(a,s)=>e(u=>{const c=xt(Po)("space after 'into'"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const m=Pn(xt(He)("node identifier after 'into'")),p=_._3&&!l._3?L(l._1,l._2,!0):l;return e(x=>m(p,e,n,r,(J,T)=>e(N=>o(p._3&&!J._3?L(J._1,J._2,!0):J,{op:ir("Enter",{id:T._1}),operands:[T._2]}))))})))}))),v6=(t,e,n,r,o)=>e(i=>Wn(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?L(a._1,a._2,!0):a;return e(_=>Gn("min-font-size")(c,e,n,r,(f,l)=>e(d=>{const h=c._3&&!f._3?L(f._1,f._2,!0):f;return e(m=>ie(h,e,n,r,(p,x)=>e(J=>{const T=xt(w6)("number (min-font-size value)"),N=h._3&&!p._3?L(p._1,p._2,!0):p;return e(k=>T(N,e,n,r,(C,P)=>e(G=>(P>0?((R,U,S,b,I)=>U(H=>Nn(R,U,S,b,(Q,q)=>U($=>I(Q,P))))):(R,U,S,b,I)=>b(R,or("positive min-font-size value",s)))(N._3&&!C._3?L(C._1,C._2,!0):C,e,n,r,o))))})))})))}))),b6=(t,e,n,r,o)=>e(i=>Gn("out")(t,e,n,r,(a,s)=>e(u=>o(t._3&&!a._3?L(a._1,a._2,!0):a,{op:r4,operands:[]})))),C6=(t,e,n,r,o)=>e(i=>Gn("seed")(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?L(a._1,a._2,!0):a;return e(_=>ie(c,e,n,r,(f,l)=>e(d=>{const h=xt(x6)("integer (seed value)"),m=c._3&&!f._3?L(f._1,f._2,!0):f;return e(p=>h(m,e,n,r,(x,J)=>e(T=>{const N=m._3&&!x._3?L(x._1,x._2,!0):x;return e(k=>Nn(N,e,n,r,(C,P)=>e(G=>o(N._3&&!C._3?L(C._1,C._2,!0):C,J))))})))})))}))),Nm=(t,e,n,r,o)=>{const i=t._3;return e(a=>Gn("diagram")(t,e,n,(s,u)=>r(L(s._1,s._2,i),u),(s,u)=>e(c=>{const _=xt(Po)("space after 'diagram'"),f=t._3&&!s._3?L(s._1,s._2,!0):s;return e(l=>_(f,e,n,(d,h)=>r(L(d._1,d._2,i),h),(d,h)=>e(m=>{const p=xt(Gn("sequence"))("diagram mode"),x=f._3&&!d._3?L(d._1,d._2,!0):d;return e(J=>p(x,e,n,(T,N)=>r(L(T._1,T._2,i),N),(T,N)=>e(k=>{const C=x._3&&!T._3?L(T._1,T._2,!0):T;return e(P=>mm(C,e,n,(G,R)=>r(L(G._1,G._2,i),R),(G,R)=>e(U=>o(C._3&&!G._3?L(G._1,G._2,!0):G,n4))))})))})))})))},vm=(t,e,n,r,o)=>{const i=t._3;return e(a=>Gn("still")(t,e,n,(s,u)=>r(L(s._1,s._2,i),u),(s,u)=>e(c=>{const _=t._3&&!s._3?L(s._1,s._2,!0):s;return e(f=>mm(_,e,n,(l,d)=>r(L(l._1,l._2,i),d),(l,d)=>e(h=>o(_._3&&!l._3?L(l._1,l._2,!0):l,e4))))})))},bm=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>vm(L(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>_?r(u,c):Nm(t,e,n,r,o))},o))},L6=t=>(e,n,r,o,i)=>n(a=>Wn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>{const l=_._3;return bm(_,n,r,(d,h)=>o(L(d._1,d._2,l),h),(d,h)=>n(m=>o(_._3&&!d._3?L(d._1,d._2,!0):d,or((()=>{if(t==="AnimatedSurface")return"Put diagram mode headers at the top of the document.";if(t==="AnimatedSurface")return"This document already declares `animation`; choose one diagram mode.";if(t==="StillSurface")return"This document already declares `still`; choose one diagram mode.";if(t==="SequenceSurface")return"This document already declares `diagram sequence`; choose one diagram mode.";g()})(),u))))})}))),k6=t=>(e,n,r,o,i)=>n(a=>Wn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>{const l=(m,p)=>n(x=>(()=>{if(p.tag==="Just"){const J=(()=>{if(t==="AnimatedSurface")return"This document already declares `animation`; choose one diagram mode.";if(t==="StillSurface")return"This document already declares `still`; choose one diagram mode.";if(t==="SequenceSurface")return"This document already declares `diagram sequence`; choose one diagram mode.";g()})();return(T,N,k,C,P)=>C(T,or(J,u))}if(p.tag==="Nothing")return(J,T,N,k,C)=>C(J,void 0);g()})()(_._3&&!m._3?L(m._1,m._2,!0):m,n,r,o,i)),d=_._1,h=_._2;return n(m=>n(p=>bm(L(d,h,!1),n,r,(x,J)=>{const T=x._3;return n(N=>T?o(x,J):l(_,y))},(x,J)=>n(T=>l(x,w("Just",J))))))})}))),S6=(t,e,n,r,o)=>e(i=>{const a=(c,_)=>e(f=>{const l=t._3&&!c._3?L(c._1,c._2,!0):c;return e(d=>Nn(l,e,n,r,(h,m)=>e(p=>{const x=l._3&&!h._3?L(h._1,h._2,!0):h;return e(J=>k6(_)(x,e,n,r,(T,N)=>e(k=>o(x._3&&!T._3?L(T._1,T._2,!0):T,_))))})))}),s=t._1,u=t._2;return e(c=>vm(L(s,u,!1),e,n,(_,f)=>{const l=_._3;return e(d=>l?r(_,f):Nm(t,e,n,r,a))},a))}),E6=(t,e,n,r,o)=>e(i=>{const a=(c,_)=>e(f=>o(c,(()=>{if(_.tag==="Nothing")return t4;if(_.tag==="Just")return _._1;g()})())),s=t._1,u=t._2;return e(c=>e(_=>S6(L(s,u,!1),e,n,(f,l)=>{const d=f._3;return e(h=>d?r(f,l):a(t,y))},(f,l)=>e(d=>a(f,w("Just",l))))))}),P6=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>ie(t,e,n,(u,c)=>r(L(u._1,u._2,a),c),(u,c)=>e(_=>Gn("via")(t._3&&!u._3?L(u._1,u._2,!0):u,e,n,(f,l)=>r(L(f._1,f._2,a),l),(f,l)=>e(d=>{const h=t._3&&!f._3?L(f._1,f._2,!0):f;return e(m=>rc(h,e,n,r,(p,x)=>e(J=>{const T=h._3&&!p._3?L(p._1,p._2,!0):p;return e(N=>Po(T,e,n,r,(k,C)=>e(P=>{const G=xt(He)("source node identifier after 'via'"),R=T._3&&!k._3?L(k._1,k._2,!0):k;return e(U=>G(R,e,n,r,(S,b)=>e(I=>{const H=R._3&&!S._3?L(S._1,S._2,!0):S;return e(Q=>ie(H,e,n,r,(q,$)=>e(A=>{const F=xt(He)("target node identifier after 'via'"),M=H._3&&!q._3?L(q._1,q._2,!0):q;return e(W=>F(M,e,n,r,(D,X)=>e(V=>o(M._3&&!D._3?L(D._1,D._2,!0):D,{from:b,to:X}))))})))})))})))})))})))))}),G6=t=>e=>{const n=Ie(P6);return(r,o,i,a,s)=>o(u=>n(r,o,i,a,(c,_)=>o(f=>s(r._3&&!c._3?L(c._1,c._2,!0):c,{op:ir("DelNode",{id:t,via:It(ge.foldr,_)}),operands:[e]}))))},A6=(()=>{const t=xt(Gt(e=>e==="-"))("'-'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=xt(Po)("space after '-'"),f=e._3&&!s._3?L(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(m=>{const p=Pn(xt(He)("node identifier after '-'")),x=f._3&&!d._3?L(d._1,d._2,!0):d;return n(J=>p(x,n,r,o,(T,N)=>n(k=>{const C=N._1,P=N._2,G=x._3&&!T._3?L(T._1,T._2,!0):T;return n(R=>ym(G,n,r,o,(U,S)=>n(b=>(()=>{if(S.tag==="Just")return h6(C)(P)(S._1);if(S.tag==="Nothing")return G6(C)(P);g()})()(G._3&&!U._3?L(U._1,U._2,!0):U,n,r,o,i))))})))})))})))})(),br=t=>e=>(n,r,o,i,a)=>r(s=>Wn(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?L(u._1,u._2,!0):u;return r(l=>Gn(t)(f,r,o,i,(d,h)=>r(m=>i(f._3&&!d._3?L(d._1,d._2,!0):d,or(e,c)))))}))),B6=t=>t==="AnimatedSurface"?(e,n,r,o,i)=>n(a=>Wn(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>Gn("step")(_,n,r,o,(l,d)=>n(h=>{const m=xt(Po)("space after 'step'"),p=_._3&&!l._3?L(l._1,l._2,!0):l;return n(x=>m(p,n,r,o,(J,T)=>n(N=>{const k=Pn(xt(He)("step name")),C=p._3&&!J._3?L(J._1,J._2,!0):J;return n(P=>k(C,n,r,o,(G,R)=>n(U=>{const S=R._1,b=R._2,I=C._3&&!G._3?L(G._1,G._2,!0):G;return n(H=>Wn(I,n,r,o,(Q,q)=>n($=>{const A=I._3&&!Q._3?L(Q._1,Q._2,!0):Q;return n(F=>ie(A,n,r,o,(M,W)=>n(D=>{const X=A._3&&!M._3?L(M._1,M._2,!0):M;return n(V=>lm(X,n,r,o,(K,Z)=>n(tt=>{const et=X._3&&!K._3?L(K._1,K._2,!0):K;return n(ft=>Nn(et,n,r,o,(Nt,dt)=>n(mt=>{const bt={line:u.line,column:u.column,endLine:q.line,endColumn:q.column};return i(et._3&&!Nt._3?L(Nt._1,Nt._2,!0):Nt,{name:w("Just",S),ops:Or("Leaf",{op:ir("Step",{name:S}),line:bt.line,column:bt.column,endLine:bt.endLine,endColumn:bt.endColumn,span:bt,operands:[b]}),kind:Z0})})))})))})))})))})))})))})))}))):br("step")("`step` markers are only supported in animated diagrams."),R6=(()=>{const t=xt(Gt(e=>e===":"))("':'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>ie(_,n,r,o,(l,d)=>n(h=>{const m=Ie(Gt(Z4)),p=_._3&&!l._3?L(l._1,l._2,!0):l;return n(x=>m(p,n,r,o,(J,T)=>n(N=>i(p._3&&!J._3?L(J._1,J._2,!0):J,Aa(kn(It(ge.foldr,T)))))))})))})))})(),Cm=xt((t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>R6(L(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>f6(L(l,d,!1),e,n,(m,p)=>{const x=m._3;return e(J=>{if(x)return r(m,p);const T=t._1,N=t._2;return e(k=>d6(L(T,N,!1),e,n,(C,P)=>{const G=C._3;return e(R=>G?r(C,P):Jm(t,e,n,r,o))},o))})},o))})},o))})('label ("\u2026", : rest-of-line, or |\u2026|)'),Lm=(t,e,n,r,o)=>e(i=>ie(t,e,n,r,(a,s)=>e(u=>Cm(t._3&&!a._3?L(a._1,a._2,!0):a,e,n,r,o)))),dc=t=>(e,n,r,o,i)=>n(a=>ie(e,n,r,o,(s,u)=>n(c=>{const _=e._3&&!s._3?L(s._1,s._2,!0):s;return n(f=>{const l=(m,p)=>n(x=>(p?((J,T,N,k,C)=>C(J,y)):(J,T,N,k,C)=>T(P=>Lm(J,T,N,k,(G,R)=>T(U=>C(G,w("Just",R))))))(_._3&&!m._3?L(m._1,m._2,!0):m,n,r,o,i)),d=_._1,h=_._2;return n(m=>{const p=(x,J)=>{const T=x._3;return n(N=>T?o(x,J):l(_,!1))};return n(x=>n(J=>n(T=>xa(L(d,h,!1),n,r,(N,k)=>{const C=N._3;return n(P=>C?p(L(d,h,!1),k):n(G=>Gt(t)(L(d,h,!1),n,r,(R,U)=>p(L(d,h,!1),U),(R,U)=>n(S=>n(b=>l(L(d,h,!1),!0))))))},(N,k)=>n(C=>n(P=>l(L(d,h,!1),!0)))))))})})}))),D6=t=>e=>n=>(r,o,i,a,s)=>o(u=>ie(r,o,i,a,(c,_)=>o(f=>{const l=Pn(xt(He)("target node identifier")),d=r._3&&!c._3?L(c._1,c._2,!0):c;return o(h=>l(d,o,i,a,(m,p)=>o(x=>{const J=p._1,T=p._2,N=d._3&&!m._3?L(m._1,m._2,!0):m;return o(k=>dc(S1)(N,o,i,a,(C,P)=>o(G=>s(N._3&&!C._3?L(C._1,C._2,!0):C,{op:ir("AddEdge",{from:t,to:J,label:P.tag==="Just"?w("Just",P._1):y,directed:n}),operands:[e,T]}))))})))}))),F6=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>Pn(He)(t,e,n,(u,c)=>r(L(u._1,u._2,a),c),(u,c)=>e(_=>{const f=t._3&&!u._3?L(u._1,u._2,!0):u;return e(l=>ie(f,e,n,(d,h)=>r(L(d._1,d._2,a),h),(d,h)=>e(m=>{const p=xt(Gt(J=>J==="<"))("'<'"),x=f._3&&!d._3?L(d._1,d._2,!0):d;return e(J=>p(x,e,n,(T,N)=>r(L(x._1,x._2,a),N),(T,N)=>e(k=>{const C=Eo((G,R,U,S,b)=>{const I=G._3;return Ee("<-")(G,R,U,(H,Q)=>S(L(H._1,H._2,I),Q),b)}),P=x._3&&!x._3?L(x._1,x._2,!0):x;return e(G=>C(P,e,n,(R,U)=>r(L(R._1,R._2,a),U),(R,U)=>e(S=>{const b=P._3&&!R._3?L(R._1,R._2,!0):R;return e(I=>{const H=c._1,Q=c._2,q=t._3&&!b._3?L(b._1,b._2,!0):b;return e($=>ie(q,e,n,r,(A,F)=>e(M=>{const W=xt(Ee("<~"))("'<~'"),D=q._3&&!A._3?L(A._1,A._2,!0):A;return e(X=>W(D,e,n,r,(V,K)=>e(Z=>{const tt=D._3&&!V._3?L(V._1,V._2,!0):V;return e(et=>ie(tt,e,n,r,(ft,Nt)=>e(dt=>{const mt=Pn(xt(He)("target node identifier")),bt=tt._3&&!ft._3?L(ft._1,ft._2,!0):ft;return e(Ht=>mt(bt,e,n,r,(Tt,Vt)=>e(At=>{const vt=Vt._1,pt=Vt._2,gt=bt._3&&!Tt._3?L(Tt._1,Tt._2,!0):Tt;return e(wt=>dc(S1)(gt,e,n,r,(Rt,yt)=>e(Ct=>o(gt._3&&!Rt._3?L(Rt._1,Rt._2,!0):Rt,{op:ir("Token",{from:vt,to:H,labels:(()=>{if(yt.tag==="Nothing")return[];if(yt.tag==="Just")return[yt._1];g()})()}),operands:[pt,Q]}))))})))})))})))})))})})))})))})))})))}),z6=(t,e,n,r,o)=>e(i=>m6(t,e,n,r,(a,s)=>e(u=>{const c=s._2._2,_=s._1,f=s._2._1,l=t._3&&!a._3?L(a._1,a._2,!0):a;return e(d=>ie(l,e,n,r,(h,m)=>e(p=>{const x=Pn(xt(He)("target node identifier")),J=l._3&&!h._3?L(h._1,h._2,!0):h;return e(T=>x(J,e,n,r,(N,k)=>e(C=>{const P=k._1,G=k._2,R=J._3&&!N._3?L(N._1,N._2,!0):N;return e(U=>dc(S1)(R,e,n,r,(S,b)=>e(I=>(c==="<~"?((H,Q,q,$,A)=>A(H,{op:ir("Token",{from:P,to:_,labels:(()=>{if(b.tag==="Nothing")return[];if(b.tag==="Just")return[b._1];g()})()}),operands:c==="<~"?[G,f]:[f,G]})):(H,Q,q,$,A)=>A(H,{op:ir("Token",{from:_,to:P,labels:(()=>{if(b.tag==="Nothing")return[];if(b.tag==="Just")return[b._1];g()})()}),operands:c==="<~"?[G,f]:[f,G]}))(R._3&&!S._3?L(S._1,S._2,!0):S,e,n,r,o))))})))})))}))),I6=(t,e,n,r,o)=>e(i=>dc(e6)(t,e,n,r,(a,s)=>e(u=>o(a,(()=>{if(s.tag==="Nothing")return"";if(s.tag==="Just")return s._1;g()})())))),Q6=t=>e=>n=>r=>(o,i,a,s,u)=>i(c=>Wn(o,i,a,s,(_,f)=>i(l=>{const d=o._3&&!_._3?L(_._1,_._2,!0):_;return i(h=>{const m=(J,T)=>i(N=>(()=>{if(T.tag==="Just")return(k,C,P,G,R)=>G(k,or("node placeholder value",f));if(T.tag==="Nothing")return(k,C,P,G,R)=>C(U=>Lm(k,C,P,G,(S,b)=>C(I=>R(k._3&&!S._3?L(S._1,S._2,!0):S,{op:ir("ModNodeSlot",{id:t,slot:n,value:b}),operands:[e,r]}))));g()})()(d._3&&!J._3?L(J._1,J._2,!0):J,i,a,s,u)),p=d._1,x=d._2;return i(J=>i(T=>ls(L(p,x,!1),i,a,(N,k)=>i(C=>m(d,y)),(N,k)=>i(C=>m(L(p,x,!1),w("Just",k))))))})}))),M6=t=>e=>(n,r,o,i,a)=>r(s=>Wn(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?L(u._1,u._2,!0):u;return r(l=>{const d=(p,x)=>r(J=>(()=>{if(x.tag==="Just")return(T,N,k,C,P)=>C(T,or("node relabel label",c));if(x.tag==="Nothing")return(T,N,k,C,P)=>N(G=>Cm(T,N,k,C,(R,U)=>N(S=>P(T._3&&!R._3?L(R._1,R._2,!0):R,{op:ir("ModNode",{id:t,label:w("Just",U)}),operands:[e]}))));g()})()(f._3&&!p._3?L(p._1,p._2,!0):p,r,o,i,a)),h=f._1,m=f._2;return r(p=>r(x=>ls(L(h,m,!1),r,o,(J,T)=>r(N=>d(f,y)),(J,T)=>r(N=>d(L(h,m,!1),w("Just",T))))))})}))),O6=(()=>{const t=xt(Gt(e=>e==="~"))("'~'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=xt(Po)("space after '~'"),f=e._3&&!s._3?L(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(m=>{const p=Pn(xt(He)("source node identifier")),x=f._3&&!d._3?L(d._1,d._2,!0):d;return n(J=>p(x,n,r,o,(T,N)=>n(k=>{const C=N._1,P=N._2,G=xt(Gt(S=>S==="."))("'.'"),R=Pn(xt(He)("placeholder name")),U=x._3&&!T._3?L(T._1,T._2,!0):T;return n(S=>{const b=(Q,q)=>n($=>(()=>{if(q.tag==="Just")return Q6(C)(P)(q._1._1)(q._1._2);if(q.tag==="Nothing")return(A,F,M,W,D)=>F(X=>ie(A,F,M,W,(V,K)=>F(Z=>{const tt=xt(Gt(ft=>ft==="-"))("'-'"),et=A._3&&!V._3?L(V._1,V._2,!0):V;return F(ft=>{const Nt=(bt,Ht)=>F(Tt=>(()=>{if(Ht.tag==="Just")return y6(C)(P);if(Ht.tag==="Nothing")return M6(C)(P);g()})()(et._3&&!bt._3?L(bt._1,bt._2,!0):bt,F,M,W,D)),dt=et._1,mt=et._2;return F(bt=>F(Ht=>tt(L(dt,mt,!1),F,M,(Tt,Vt)=>F(At=>Nt(et,y)),(Tt,Vt)=>F(At=>Nt(L(dt,mt,!1),w("Just",Vt))))))})})));g()})()(U._3&&!Q._3?L(Q._1,Q._2,!0):Q,n,r,o,i)),I=U._1,H=U._2;return n(Q=>n(q=>{const $=(A,F)=>{const M=A._3;return n(W=>M?o(A,F):b(U,y))};return n(A=>n(F=>G(L(I,H,!1),n,r,(M,W)=>$(L(M._1,M._2,!1),W),(M,W)=>n(D=>n(X=>R(M,n,r,(V,K)=>$(L(V._1,V._2,!1),K),(V,K)=>n(Z=>{const tt=M._3&&!V._3?L(V._1,V._2,!0):V;return n(et=>b(tt,w("Just",K)))})))))))}))})})))})))})))})(),E1=M0((()=>{const t=xt(Gt(e=>e==="{"))("'{'");return(e,n,r,o,i)=>n(a=>n(s=>t(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?L(u._1,u._2,!0):u;return Nn(l,n,r,o,(d,h)=>n(m=>i(l._3&&!d._3?L(d._1,d._2,!0):d,h)))})))))})())(xt((()=>{const t=xt(Gt(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>n(s=>Nn(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?L(u._1,u._2,!0):u;return t(l,n,r,o,(d,h)=>n(m=>i(l._3&&!d._3?L(d._1,d._2,!0):d,h)))})))))})())("closing '}'")),W6=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>Jm(L(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>T6(L(l,d,!1),e,n,(m,p)=>{const x=m._3;return e(J=>x?r(m,p):He(t,e,n,r,o))},o))})},o))},km=(t,e,n,r,o)=>e(i=>ie(t,e,n,r,(a,s)=>e(u=>{const c=xt(He)("attribute key"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const m=_._3&&!l._3?L(l._1,l._2,!0):l;return e(p=>ie(m,e,n,r,(x,J)=>e(T=>{const N=xt(xt(Gt(C=>C===":"))("':'"))("':'"),k=m._3&&!x._3?L(x._1,x._2,!0):x;return e(C=>N(k,e,n,r,(P,G)=>e(R=>{const U=k._3&&!P._3?L(P._1,P._2,!0):P;return e(S=>ie(U,e,n,r,(b,I)=>e(H=>{const Q=xt(W6)("attribute value"),q=U._3&&!b._3?L(b._1,b._2,!0):b;return e($=>Q(q,e,n,r,(A,F)=>e(M=>{const W=q._3&&!A._3?L(A._1,A._2,!0):A;return e(D=>ie(W,e,n,r,(X,V)=>e(K=>o(W._3&&!X._3?L(X._1,X._2,!0):X,E(d,F)))))})))})))})))})))})))}))),H6=M0((()=>{const t=xt(Gt(e=>e==="{"))("'{'");return(e,n,r,o,i)=>n(a=>n(s=>t(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?L(u._1,u._2,!0):u;return ie(l,n,r,o,(d,h)=>n(m=>i(l._3&&!d._3?L(d._1,d._2,!0):d,h)))})))))})())(xt((()=>{const t=xt(Gt(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>n(s=>ie(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?L(u._1,u._2,!0):u;return t(l,n,r,o,(d,h)=>n(m=>i(l._3&&!d._3?L(d._1,d._2,!0):d,h)))})))))})())("closing '}' for attributes"))((()=>{const t=xt(Gt(e=>e==="}"))("'}'");return(e,n,r,o,i)=>n(a=>{const s=(_,f)=>n(l=>(()=>{if(f.tag==="Just")return(d,h,m,p,x)=>x(d,O);if(f.tag==="Nothing")return(d,h,m,p,x)=>h(J=>km(d,h,m,p,(T,N)=>h(k=>{const C=Ie((()=>{const G=xt(Gt(R=>R===","))("','");return(R,U,S,b,I)=>{const H=R._3;return U(Q=>U(q=>U($=>U(A=>U(F=>U(M=>ie(R,U,S,(W,D)=>b(L(W._1,W._2,H),D),(W,D)=>U(X=>U(V=>{const K=R._3&&!W._3?L(W._1,W._2,!0):W;return G(K,U,S,(Z,tt)=>b(L(Z._1,Z._2,H),tt),(Z,tt)=>U(et=>{const ft=K._3&&!Z._3?L(Z._1,Z._2,!0):Z;return U(Nt=>U(dt=>{const mt=R._3&&!ft._3?L(ft._1,ft._2,!0):ft;return ie(mt,U,S,(bt,Ht)=>b(L(bt._1,bt._2,H),Ht),(bt,Ht)=>U(Tt=>{const Vt=mt._3&&!bt._3?L(bt._1,bt._2,!0):bt;return U(At=>U(vt=>{const pt=R._3&&!Vt._3?L(Vt._1,Vt._2,!0):Vt;return km(pt,U,S,(gt,wt)=>b(L(gt._1,gt._2,H),wt),(gt,wt)=>U(Rt=>I(pt._3&&!gt._3?L(gt._1,gt._2,!0):gt,wt)))}))}))}))}))})))))))))}})()),P=d._3&&!T._3?L(T._1,T._2,!0):T;return h(G=>C(P,h,m,p,(R,U)=>h(S=>x(P._3&&!R._3?L(R._1,R._2,!0):R,K4([N,...It(ge.foldr,U)])))))})));g()})()(e._3&&!_._3?L(_._1,_._2,!0):_,n,r,o,i)),u=e._1,c=e._2;return n(_=>n(f=>t(L(u,c,!1),n,r,(l,d)=>n(h=>s(e,y)),(l,d)=>n(h=>s(L(u,c,!1),w("Just",d))))))})})()),$6=(t,e,n,r,o)=>e(i=>ie(t,e,n,r,(a,s)=>e(u=>{const c=xt(Gt(f=>f==="{"))("'{'"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>{const l=(m,p)=>e(x=>(()=>{if(p.tag==="Just")return H6;if(p.tag==="Nothing")return(J,T,N,k,C)=>C(J,O);g()})()(_._3&&!m._3?L(m._1,m._2,!0):m,e,n,r,o)),d=_._1,h=_._2;return e(m=>e(p=>c(L(d,h,!1),e,n,(x,J)=>e(T=>l(_,y)),(x,J)=>e(T=>l(L(d,h,!1),w("Just",J))))))})}))),q6=t=>e=>(n,r,o,i,a)=>r(s=>I6(n,r,o,i,(u,c)=>r(_=>{const f=n._3&&!u._3?L(u._1,u._2,!0):u;return r(l=>$6(f,r,o,i,(d,h)=>r(m=>a(f._3&&!d._3?L(d._1,d._2,!0):d,{op:ir("AddNode",{id:t,label:c,shape:(()=>{const p=fm("shape")(h);if(p.tag==="Just")return p._1==="rectangle"||p._1==="rect"?_o:p._1==="cylinder"||p._1==="cyl"?cx:p._1==="parallelogram"?gx:p._1==="diamond"?_x:p._1==="ellipse"?fx:p._1==="document"||p._1==="doc"?dx:p._1==="cloud"?lx:_o;if(p.tag==="Nothing")return _o;g()})(),width:(()=>{const p=fm("width")(h);if(p.tag==="Just")return Rc(p._1,Na,Xt,y);if(p.tag==="Nothing")return y;g()})()}),operands:[e]}))))}))),V6=(()=>{const t=xt(Gt(e=>e==="+"))("'+'");return(e,n,r,o,i)=>n(a=>t(e,n,r,o,(s,u)=>n(c=>{const _=xt(Po)("space after '+'"),f=e._3&&!s._3?L(s._1,s._2,!0):s;return n(l=>_(f,n,r,o,(d,h)=>n(m=>{const p=Pn(xt(He)("node identifier after '+'")),x=f._3&&!d._3?L(d._1,d._2,!0):d;return n(J=>p(x,n,r,o,(T,N)=>n(k=>{const C=N._1,P=N._2,G=x._3&&!T._3?L(T._1,T._2,!0):T;return n(R=>ym(G,n,r,o,(U,S)=>n(b=>(()=>{if(S.tag==="Just")return D6(C)(P)(S._1);if(S.tag==="Nothing")return q6(C)(P);g()})()(G._3&&!U._3?L(U._1,U._2,!0):U,n,r,o,i))))})))})))})))})(),U6=(t,e,n,r,o)=>e(i=>Wn(t,e,n,r,(a,s)=>e(u=>{const c=xt(k1([br("+node")("Node additions use `+ api: API`."),br("+edge")("Graph edges use `+ api -> db`."),br("+conn")("Undirected graph edges use `+ api -- db`."),br("-node")("Node removals use `- api`."),br("-edge")("Graph edge removals use `- api -> db`."),br("-conn")("Undirected graph edge removals use `- api -- db`."),br("~edge")("Graph edge repoints use `~ api -> db => api -> cache`."),br("enter")("Dive commands use `into api`."),br("exit")("Return from a dive with `out`."),p6,V6,A6,O6,z6,F6,N6,b6]))("statement (+ node, - node, + edge, - edge, ~ node, into, out, or 'a ~> b'/'a <~ b')"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const m=_._3&&!l._3?L(l._1,l._2,!0):l;return e(p=>Wn(m,e,n,r,(x,J)=>e(T=>{const N={line:s.line,column:s.column,endLine:J.line,endColumn:J.column};return o(m._3&&!x._3?L(x._1,x._2,!0):x,Or("Leaf",{op:d.op,line:N.line,column:N.column,endLine:N.endLine,endColumn:N.endColumn,span:N,operands:d.operands}))})))})))}))),Sm=(t,e,n,r,o)=>e(i=>{const a=t._3;return e(s=>Nn(t,e,n,(u,c)=>r(L(u._1,u._2,a),c),(u,c)=>e(_=>{const f=Eo(xt(Gt(d=>d==="}"))("'}'")),l=t._3&&!u._3?L(u._1,u._2,!0):u;return e(d=>f(l,e,n,(h,m)=>r(L(h._1,h._2,a),m),(h,m)=>e(p=>Eo(xa)(l._3&&!h._3?L(h._1,h._2,!0):h,e,n,(x,J)=>r(L(x._1,x._2,a),J),(x,J)=>e(T=>{const N=t._3&&!x._3?L(x._1,x._2,!0):x;return e(k=>rc(N,e,n,r,(C,P)=>e(G=>{const R=k1([Y6,K6,U6]),U=N._3&&!C._3?L(C._1,C._2,!0):C;return e(S=>R(U,e,n,r,(b,I)=>e(H=>{const Q=U._3&&!b._3?L(b._1,b._2,!0):b;return e(q=>ie(Q,e,n,r,($,A)=>e(F=>{const M=Q._3&&!$._3?L($._1,$._2,!0):$;return e(W=>lm(M,e,n,r,(D,X)=>e(V=>{const K=M._3&&!D._3?L(D._1,D._2,!0):D;return e(Z=>Nn(K,e,n,r,(tt,et)=>e(ft=>o(K._3&&!tt._3?L(tt._1,tt._2,!0):tt,I))))})))})))})))})))})))))})))}),K6=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>{const u=(c,_)=>{const f=c._3;return e(l=>f?r(c,_):e(d=>{const h=t._3;return e(m=>Gn("seq")(t,e,n,(p,x)=>r(L(p._1,p._2,h),x),(p,x)=>e(J=>{const T=t._3&&!p._3?L(p._1,p._2,!0):p;return e(N=>ie(T,e,n,(k,C)=>r(L(k._1,k._2,h),C),(k,C)=>e(P=>ls(T._3&&!k._3?L(k._1,k._2,!0):k,e,n,(G,R)=>r(L(G._1,G._2,h),R),(G,R)=>e(U=>{const S=t._3&&!G._3?L(G._1,G._2,!0):G;return e(b=>rc(S,e,n,r,(I,H)=>e(Q=>{const q=xt(xt(Gt(A=>A==="{"))("'{'"))("'{'"),$=S._3&&!I._3?L(I._1,I._2,!0):I;return e(A=>q($,e,n,r,(F,M)=>e(W=>o($._3&&!F._3?L(F._1,F._2,!0):F,Or("GroupSeq",[])))))})))})))))})))}))};return e(c=>e(_=>Gn("seq")(L(i,a,!1),e,n,(f,l)=>u(L(f._1,f._2,!1),l),(f,l)=>e(d=>e(h=>ie(f,e,n,(m,p)=>u(L(m._1,m._2,!1),p),(m,p)=>e(x=>{const J=f._3&&!m._3?L(m._1,m._2,!0):m;return xt(Gt(T=>T==="{"))("'{'")(J,e,n,(T,N)=>u(L(J._1,J._2,!1),N),(T,N)=>e(k=>E1(P1(s4))(J,e,n,u,o)))})))))))})},Y6=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>{const u=(c,_)=>{const f=c._3;return e(l=>f?r(c,_):e(d=>{const h=t._3;return e(m=>Gn("par")(t,e,n,(p,x)=>r(L(p._1,p._2,h),x),(p,x)=>e(J=>{const T=t._3&&!p._3?L(p._1,p._2,!0):p;return e(N=>ie(T,e,n,(k,C)=>r(L(k._1,k._2,h),C),(k,C)=>e(P=>ls(T._3&&!k._3?L(k._1,k._2,!0):k,e,n,(G,R)=>r(L(G._1,G._2,h),R),(G,R)=>e(U=>{const S=t._3&&!G._3?L(G._1,G._2,!0):G;return e(b=>rc(S,e,n,r,(I,H)=>e(Q=>{const q=xt(xt(Gt(A=>A==="{"))("'{'"))("'{'"),$=S._3&&!I._3?L(I._1,I._2,!0):I;return e(A=>q($,e,n,r,(F,M)=>e(W=>o($._3&&!F._3?L(F._1,F._2,!0):F,Or("Par",[])))))})))})))))})))}))};return e(c=>e(_=>Gn("par")(L(i,a,!1),e,n,(f,l)=>u(L(f._1,f._2,!1),l),(f,l)=>e(d=>e(h=>ie(f,e,n,(m,p)=>u(L(m._1,m._2,!1),p),(m,p)=>e(x=>{const J=f._3&&!m._3?L(m._1,m._2,!0):m;return xt(Gt(T=>T==="{"))("'{'")(J,e,n,(T,N)=>u(L(J._1,J._2,!1),N),(T,N)=>e(k=>E1(P1(i4))(J,e,n,u,o)))})))))))})},P1=t=>{const e=Ie(Sm);return(n,r,o,i,a)=>r(s=>e(n,r,o,i,(u,c)=>r(_=>a(n._3&&!u._3?L(u._1,u._2,!0):u,t(It(ge.foldr,c))))))},G1=t=>e=>(n,r,o,i,a)=>r(s=>Tm(t)(n,r,o,i,(u,c)=>r(_=>{const f=Ie(Gt(n6)),l=n._3&&!u._3?L(u._1,u._2,!0):u;return r(d=>f(l,r,o,i,(h,m)=>r(p=>{const x=xt(xt(Gt(T=>T==="{"))("'{'"))("'{'"),J=l._3&&!h._3?L(h._1,h._2,!0):h;return r(T=>x(J,r,o,i,(N,k)=>r(C=>{const P=J._3&&!N._3?L(N._1,N._2,!0):N;return r(G=>Nn(P,r,o,i,(R,U)=>r(S=>{const b=P1(a4),I=P._3&&!R._3?L(R._1,R._2,!0):R;return r(H=>b(I,r,o,i,(Q,q)=>r($=>{const A=I._3&&!Q._3?L(Q._1,Q._2,!0):Q;return r(F=>Nn(A,r,o,i,(M,W)=>r(D=>{const X=xt(xt(Gt(K=>K==="}"))("'}'"))("closing '}'"),V=A._3&&!M._3?L(M._1,M._2,!0):M;return r(K=>X(V,r,o,i,(Z,tt)=>r(et=>{const ft=V._3&&!Z._3?L(Z._1,Z._2,!0):Z;return r(Nt=>Nn(ft,r,o,i,(dt,mt)=>r(bt=>a(ft._3&&!dt._3?L(dt._1,dt._2,!0):dt,{name:u6(kn(It(ge.foldr,m))),ops:q,kind:e}))))})))})))})))})))})))})))}))),X6=(t,e,n,r,o)=>{const i=t._1,a=t._2;return e(s=>br("keyframe")("Drop the `keyframe` wrapper; Markgraf animates statements in order.")(L(i,a,!1),e,n,(u,c)=>{const _=u._3;return e(f=>{if(_)return r(u,c);const l=t._1,d=t._2;return e(h=>G1("scene")(uc)(L(l,d,!1),e,n,(m,p)=>{const x=m._3;return e(J=>{if(x)return r(m,p);const T=t._1,N=t._2;return e(k=>G1("still")(v1)(L(T,N,!1),e,n,(C,P)=>{const G=C._3;return e(R=>G?r(C,P):G1("title")(o4)(t,e,n,r,o))},o))})},o))})},o))},Z6=t=>e=>n=>{if(t==="AnimatedSurface")return{...e,frames:Et(e.frames)({name:y,ops:n,kind:uc})};if(t==="StillSurface")return{...e,statements:Et(e.statements)(n)};if(t==="SequenceSurface")return{...e,statements:Et(e.statements)(n)};g()},j6=t=>e=>n=>{if(n.tag==="TopFrame"){const r=xm(t)(e);return{...r,frames:Et(r.frames)((()=>{if(t==="AnimatedSurface")return n._1;if(t==="StillSurface")return{...n._1,kind:n._1.kind==="AnimatedKeyframe"?v1:n._1.kind==="StepMarker"?Z0:n._1.kind};if(t==="SequenceSurface")return n._1;g()})())}}if(n.tag==="TopStatement")return Z6(t)(e)(n._1);if(n.tag==="TopInside")return e;g()},tP=t=>{const e=v(j6(t))(_6);return n=>xm(t)(e(n)).frames},eP=t=>wE.defer(e=>{const n=B6(t);return(r,o,i,a,s)=>{const u=r._1,c=r._2;return o(_=>L6(t)(L(u,c,!1),o,i,(f,l)=>{const d=f._3;return o(h=>{if(d)return a(f,l);const m=r._1,p=r._2;return o(x=>o(J=>nP(L(m,p,!1),o,i,(T,N)=>{const k=T._3;return o(C=>{if(k)return a(T,N);const P=r._1,G=r._2;return o(R=>o(U=>n(L(P,G,!1),o,i,(S,b)=>{const I=S._3;return o(H=>{if(I)return a(S,b);const Q=r._1,q=r._2;return o($=>o(A=>X6(L(Q,q,!1),o,i,(F,M)=>{const W=F._3;return o(D=>W?a(F,M):o(X=>Sm(r,o,i,a,(V,K)=>o(Z=>s(V,_c("TopStatement",K))))))},(F,M)=>o(W=>s(F,_c("TopFrame",M))))))})},(S,b)=>o(I=>s(S,_c("TopFrame",b))))))})},(T,N)=>o(k=>s(T,_c("TopInside",N))))))})},s))}}),nP=(t,e,n,r,o)=>e(i=>Gn("inside")(t,e,n,r,(a,s)=>e(u=>{const c=xt(Po)("space after 'inside'"),_=t._3&&!a._3?L(a._1,a._2,!0):a;return e(f=>c(_,e,n,r,(l,d)=>e(h=>{const m=xt(He)("node identifier after 'inside'"),p=_._3&&!l._3?L(l._1,l._2,!0):l;return e(x=>m(p,e,n,r,(J,T)=>e(N=>{const k=p._3&&!J._3?L(J._1,J._2,!0):J;return e(C=>Nn(k,e,n,r,(P,G)=>e(R=>{const U=k._3&&!P._3?L(P._1,P._2,!0):P;return e(S=>E1(Em)(U,e,n,r,(b,I)=>e(H=>{const Q=U._3&&!b._3?L(b._1,b._2,!0):b;return e(q=>Nn(Q,e,n,r,($,A)=>e(F=>o(Q._3&&!$._3?L($._1,$._2,!0):$,{node:T,doc:I}))))})))})))})))})))}))),Em=(t,e,n,r,o)=>e(i=>E6(t,e,n,r,(a,s)=>e(u=>{const c=t._3&&!a._3?L(a._1,a._2,!0):a;return e(_=>{const f=(h,m)=>e(p=>{const x=c._3&&!h._3?L(h._1,h._2,!0):h;return e(J=>{const T=(C,P)=>e(G=>{const R=x._3&&!C._3?L(C._1,C._2,!0):C;return e(U=>{const S=(b,I)=>e(H=>{const Q=Ie(eP(s)),q=R._3&&!b._3?L(b._1,b._2,!0):b;return e($=>Q(q,e,n,r,(A,F)=>e(M=>{const W=It(ge.foldr,F);return o(q._3&&!A._3?L(A._1,A._2,!0):A,{seed:(()=>{if(m.tag==="Nothing")return 0;if(m.tag==="Just")return m._1;g()})(),minimumFontSize:P,stretchNodes:I,mode:s,frames:tP(s)(W),interiors:ht(D=>{if(D.tag==="TopInside")return w("Just",D._1);if(D.tag==="TopFrame"||D.tag==="TopStatement")return y;g()})(W)})})))});return e(b=>{const I=R._1,H=R._2;return e(Q=>e(q=>J6(L(I,H,!1),e,n,($,A)=>{const F=$._3;return e(M=>F?r($,A):e(W=>S(R,!1)))},($,A)=>e(F=>e(M=>S($,!0))))))})})}),N=x._1,k=x._2;return e(C=>e(P=>v6(L(N,k,!1),e,n,(G,R)=>{const U=G._3;return e(S=>U?r(G,R):T(x,y))},(G,R)=>e(U=>T(G,w("Just",R))))))})}),l=c._1,d=c._2;return e(h=>e(m=>C6(L(l,d,!1),e,n,(p,x)=>{const J=p._3;return e(T=>J?r(p,x):f(c,y))},(p,x)=>e(J=>f(p,w("Just",x))))))})}))),rP=(()=>{const t=xt((e,n,r,o,i)=>n(a=>n(s=>Nn(e,n,r,o,(u,c)=>n(_=>n(f=>{const l=e._3&&!u._3?L(u._1,u._2,!0):u;return xa(l,n,r,o,(d,h)=>n(m=>i(l._3&&!d._3?L(d._1,d._2,!0):d,h)))}))))))("'scene', 'still', 'title', 'step', 'inside', a statement, or end of input");return(e,n,r,o,i)=>n(a=>n(s=>n(u=>n(c=>Nn(e,n,r,o,(_,f)=>n(l=>n(d=>{const h=e._3&&!_._3?L(_._1,_._2,!0):_;return Em(h,n,r,o,(m,p)=>n(x=>{const J=h._3&&!m._3?L(m._1,m._2,!0):m;return n(T=>n(N=>{const k=e._3&&!J._3?L(J._1,J._2,!0):J;return t(k,n,r,o,(C,P)=>n(G=>i(k._3&&!C._3?L(C._1,C._2,!0):C,p)))}))}))})))))))})(),oP=t=>{const e=z0(t)(rP);if(e.tag==="Left")return Dt("Left",{msg:s6(e._1._1),line:e._1._2.line,column:e._1._2.column,endLine:e._1._2.line,endColumn:e._1._2.column+1|0});if(e.tag==="Right")return Dt("Right",e._1);g()},iP=t=>{const e=oP(t);if(e.tag==="Left")return Dt("Left",e._1.msg);if(e.tag==="Right")return Dt("Right",e._1);g()},aP=()=>({tag:"ParFrag"}),Pm=t=>t,sP=Pm("Sync"),uP=Pm("SelfMsg"),cP=aP(),Go=D0(Vn),Hn=Ei(Vn),Cr=Go.state(t=>E(t,t)),Ao=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=B.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Gm=t=>e=>{const n=ut.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},lc=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Bo=Pi(Vn),gP=t=>e=>v(n=>r=>Ei(Vn).bind(n)(o=>t(o)(r)))(Pi(Vn).pure(e)),Am=Do(Bo)(Qt),Bm=t=>e=>Go.state(n=>E(void 0,{...n,lifelines:ef(B)(r=>w("Just",{...r,label:Ja(e)}))(t)(n.lifelines),labelTemplates:it(B)(t)(e)(n.labelTemplates)})),hs=t=>Go.state(e=>E(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:w("Just",t)};g()})())),_P=t=>e=>n=>Hn.bind(Cr)(r=>{const o=Ao(t)(r.labelTemplates);if(o.tag==="Nothing")return hs("node "+t+" label has no placeholder `"+e+"`");if(o.tag==="Just"){const i=$0(e)(n)(o._1);if(i.tag==="Left")return hs("node "+t+" "+i._1);if(i.tag==="Right")return Bm(t)(i._1)}g()}),fP=t=>e=>{const n=ic(e);if(n.tag==="Left")return hs("invalid label for node "+t+": "+n._1);if(n.tag==="Right")return Bm(t)(n._1);g()},dP=t=>e=>n=>{const r=Ao(n)(t.lifelines);return Ao(e)(t.lifelines).tag==="Nothing"?r.tag==="Nothing"?e+", "+n:e:r.tag==="Nothing"?n:""},lP={lifelines:O,labelTemplates:O,lifelineOrder:[],messages:[],fragments:[],frameEndRows:[],row:0,error:y},hP=t=>e=>n=>Hn.bind(Cr)(r=>{const o=Ao(t)(r.lifelines),i=Ao(e)(r.lifelines);if(o.tag==="Just"&&i.tag==="Just"){const a={...r,messages:[{fromCol:o._1.column,toCol:i._1.column,labels:n,row:r.row,kind:t===e?uP:sP},...r.messages],row:r.row+1|0};return Go.state(s=>E(void 0,a))}return hs("token references unknown node: "+dP(r)(t)(e))}),pP=t=>Go.state(e=>E(void 0,{...e,lifelines:ef(B)(n=>w("Just",{...n,destroyedAt:w("Just",e.row)}))(t)(e.lifelines)})),mP=t=>e=>{const n=e.lifelineOrder.length,r=Ft(o=>y,o=>i=>w("Just",{head:o,tail:i}),t);if(r.tag==="Nothing")return{fromCol:0,toCol:lc(0)(e.lifelineOrder.length-1|0)};if(r.tag==="Just")return v(o=>i=>({fromCol:Gm(o.fromCol)(Gm(i.fromCol)(i.toCol)),toCol:lc(o.toCol)(lc(i.fromCol)(i.toCol))}))({fromCol:n,toCol:0})(t);g()},yP=t=>({lifelines:ht(e=>Ao(e)(t.lifelines))(t.lifelineOrder),messages:re(t.messages),fragments:re(t.fragments),frameEndRows:t.frameEndRows,totalRows:t.row}),xP=t=>e=>Hn.bind(Cr)(n=>{const r=Ao(t)(n.lifelines);if(r.tag==="Just")return Bo.pure();if(r.tag==="Nothing"){const o={...n,lifelines:it(B)(t)({id:t,label:Ja(e),column:n.lifelineOrder.length,createdAt:n.row,destroyedAt:y})(n.lifelines),labelTemplates:it(B)(t)(e)(n.labelTemplates),lifelineOrder:Et(n.lifelineOrder)(t),row:n.row>0||n.messages.length!==0?n.row+1|0:n.row};return Go.state(i=>E(void 0,o))}g()}),JP=t=>e=>Hn.bind(Cr)(n=>{const r=Ao(t)(n.lifelines);if(r.tag==="Just")return Bo.pure();if(r.tag==="Nothing"){const o=ic(e);if(o.tag==="Left")return hs("invalid label for node "+t+": "+o._1);if(o.tag==="Right")return xP(t)(o._1)}g()}),wP=t=>{if(t.tag==="AddNode")return JP(t._1.id)(t._1.label);if(t.tag==="DelNode")return pP(t._1.id);if(t.tag==="ModNode"){if(t._1.label.tag==="Just")return fP(t._1.id)(t._1.label._1);if(t._1.label.tag==="Nothing")return Bo.pure();g()}return t.tag==="ModNodeSlot"?_P(t._1.id)(t._1.slot)(t._1.value):t.tag==="Token"?hP(t._1.from)(t._1.to)(t._1.labels):Bo.pure()},TP=t=>Hn.bind(Cr)(e=>{const n=e.row;return Hn.bind(gP(r=>o=>Hn.bind(Cr)(i=>{const a=r.childMessages.length===0?r.dividers:[i.row,...r.dividers],s=i.messages;return Hn.bind(A1(o))(()=>Hn.bind(Cr)(u=>Bo.pure({dividers:a,childMessages:[...r.childMessages,...(()=>{const c=u.messages.length-s.length|0;return c<1?[]:Bt(0,c,u.messages)})()]})))}))({dividers:[],childMessages:[]})(t))(r=>Hn.bind(Cr)(o=>{const i=mP(r.childMessages)(o),a={kind:cP,label:"par",fromRow:n,toRow:lc(o.row)(n+1|0),fromCol:i.fromCol,toCol:i.toCol,regionDividers:re(r.dividers)},s=Go.state(u=>E(void 0,{...u,fragments:[a,...u.fragments]}));return r.childMessages.length>=2?s:Bo.pure()}))}),A1=t=>{if(t.tag==="Leaf")return wP(t._1.op);if(t.tag==="Seq"||t.tag==="GroupSeq")return Am(A1)(t._1);if(t.tag==="Par")return TP(t._1);g()},NP=t=>{const e=Hn.bind(Am(n=>Hn.bind(Cr)(r=>Hn.bind(A1(n.ops))(()=>Hn.bind(Cr)(o=>{const i=Go.state(a=>E(void 0,{...a,frameEndRows:Et(a.frameEndRows)(a.row-1|0)}));return(o.messages.length-r.messages.length|0)>0?i:Bo.pure()}))))(t.frames))(()=>Cr)(lP)._1;if(e.error.tag==="Just")return Dt("Left",e.error._1);if(e.error.tag==="Nothing")return Dt("Right",yP(e));g()},vP=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bP={padding:24,headerHeight:36,headerWidth:120,columnSpacing:160,rowHeight:36,topGap:24,bottomGap:24},CP=t=>{const e=84+ot(vP(1)(t.totalRows))*36,n=Mt(r=>o=>({lifeline:o,x:84+ot(r)*160}))(t.lifelines);return{metrics:bP,columns:n,width:(()=>{const r=n.length-1|0;return r>=0&&r<n.length?n[r].x+84:48})(),height:e+48,headerTop:24,headerBottom:60,bodyTop:84,bodyBottom:e,diagram:t}},LP=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=y;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=w("Just",i._4);continue}}g()}return o},Rm=t=>e=>{const n=ut.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Dm=t=>e=>{let n=e,r=!0,o;for(;r;){const i=n;if(i.tag==="Leaf"){r=!1,o=!1;continue}if(i.tag==="Node"){const a=ut.compare(t)(i._3);if(a==="LT"){n=i._5;continue}if(a==="GT"){n=i._6;continue}if(a==="EQ"){r=!1,o=!0;continue}}g()}return o},Fm=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},kP=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},SP=v(t=>e=>it(ut)(e)()(t))(O),EP={r:255,g:255,b:255,a:255},hc={r:26,g:26,b:26,a:255},PP={color:{r:232,g:232,b:232,a:255},flat:!0},GP={r:232,g:232,b:232,a:255},pc=t=>e=>n=>r=>o=>[1,t+o,e,2,n-o,e,3,n,e,n,e+o,2,n,r-o,3,n,r,n-o,r,2,t+o,r,3,t,r,t,r-o,2,t,e+o,3,t,e,t+o,e,...mo],zm=t=>e=>n=>({...n,stack:Et(n.stack)(t),openedAt:it(ut)(t)(e)(n.openedAt)}),mc=t=>e=>{const n=e.stack.length-1|0;if(n>=0&&n<e.stack.length){const r=LP(e.stack[n])(e.openedAt),o=(()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return r._1;g()})();return{...e,stack:e.stack.length===0?[]:Bt(0,e.stack.length-1|0,e.stack),openedAt:Qi(ut)(e.stack[n])(e.openedAt),spans:Et(e.spans)({col:e.stack[n],fromRow:o,toRow:Rm(o)(t)})}}return e},Im=t=>e=>n=>{let r=t,o=e,i=n,a=!0,s;for(;a;){const u=r,c=o,_=i,f=_.stack.length-1|0;if(f>=0&&f<_.stack.length){if(u(_.stack[f])){a=!1,s=_;continue}r=u,o=c,i=mc(c)(_);continue}a=!1,s=_}return s},Qm=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=s.stack.length-1|0;if(u>=0&&u<s.stack.length){n=a,r=mc(a)(s);continue}o=!1,i=s}return i},AP=t=>e=>{const n=mn(io)(e.fromCol)(t.stack)?Im((()=>{const r=e.fromCol;return o=>r===o})())(e.row-1|0)(t):zm(e.fromCol)(e.row)(Qm(e.row-1|0)(t));if(mn(io)(e.toCol)(n.stack)){const r=Im((()=>{const o=e.toCol;return i=>o===i})())(e.row-1|0)(mc(e.row)(n));return{...r,returnRows:it(ut)(e.row)()(r.returnRows)}}return zm(e.toCol)(e.row)(n)},BP=t=>e=>n=>{const r=AP(e)(n);return Dm(n.row)(t)?Qm(n.row)(r):r},yc={color:{r:26,g:26,b:26,a:255},width:1.5,lineJoin:Ra,lineCap:Gr},Mm={r:26,g:26,b:26,a:255},RP={color:{r:130,g:130,b:130,a:255},width:1,lineJoin:Ra,lineCap:zn},Om={color:{r:26,g:26,b:26,a:255},width:1.5,lineJoin:Ra,lineCap:zn},DP={color:{r:244,g:244,b:244,a:255},flat:!0},Wm=t=>e=>n=>oe(r=>r.col===e&&r.fromRow<=n&&n<=r.toRow,t),Hm={color:{r:90,g:90,b:90,a:255},width:1,lineJoin:Ra,lineCap:zn},FP={stack:[],openedAt:O,spans:[],returnRows:O},zP={color:{r:150,g:150,b:150,a:255},width:1,lineJoin:Ra,lineCap:zn},IP=t=>e=>n=>r=>o=>{const i=e.bodyTop+(ot(o)+.5)*e.metrics.rowHeight-e.metrics.rowHeight/2;return t.strokePath([1,n,i,2,r,i])(zP)},QP=t=>{const e=t.Monad0(),n=e.Bind1(),r=Di(e.Applicative0())(Qt);return o=>i=>{const a=o.bodyTop+(ot(i.fromRow)+.5)*o.metrics.rowHeight-o.metrics.rowHeight/2-6,s=i.fromCol>=0&&i.fromCol<o.columns.length?o.columns[i.fromCol].x-16:o.metrics.padding-16,u=[1,s,a,2,s+38,a,2,s+32,a+14,2,s,a+14,...mo],c=i.toCol>=0&&i.toCol<o.columns.length?o.columns[i.toCol].x+16:o.metrics.padding+16,_=o.bodyTop+(ot(Rm(i.toRow)(i.fromRow+1|0)-1|0)+.5)*o.metrics.rowHeight+o.metrics.rowHeight/2+6;return n.bind(t.strokePath([1,s,a,2,c,a,2,c,_,2,s,_,...mo])(Hm))(()=>n.bind(t.fillStrokePath(u)(PP)(Hm))(()=>n.bind(t.drawText({x:s+6,y:a+7,content:"par",font:{family:"Inter",size:11,weight:700},color:hc,align:po,baseline:jn}))(()=>r(i.regionDividers)(IP(t)(o)(s)(c)))))}},$m=t=>e=>t>=e?[]:[E(t,Fm(e)(t+6)),...$m(t+10)(e)],MP=t=>e=>{if(e<=t)return[];const n=r=>r>=e?[]:[E(r,Fm(e)(r+6)),...n(r+10)];return n(t)},OP=t=>{const e=Di(t.Monad0().Applicative0())(Qt);return n=>r=>e(MP(n.headerTop+n.metrics.headerHeight+ot(r.lifeline.createdAt)*n.metrics.rowHeight+4)((()=>{if(r.lifeline.destroyedAt.tag==="Just")return n.bodyTop+(ot(r.lifeline.destroyedAt._1)+.5)*n.metrics.rowHeight;if(r.lifeline.destroyedAt.tag==="Nothing")return n.bodyBottom;g()})()))(o=>t.strokePath([1,r.x,o._1,2,r.x,o._2])(RP))},qm=t=>e=>t<=e?[]:[E(t,kP(e)(t-6)),...qm(t-6-4)(e)],WP=t=>e=>t===e?[]:t<e?$m(t)(e):qm(t)(e),HP=t=>{const e=t.Monad0().Bind1();return n=>r=>{const o=n.headerTop+ot(r.lifeline.createdAt)*n.metrics.rowHeight,i=n.metrics.headerWidth/2,a=o+n.metrics.headerHeight,s=pc(r.x-i)(o)(r.x+i)(a)(6);return e.bind(t.fillStrokePath(pc(r.x-i)(o+5)(r.x+i)(a+5)(6))({color:GP,flat:!0})(Om))(()=>e.bind(t.fillStrokePath(s)(DP)(Om))(()=>t.drawText({x:r.x,y:o+n.metrics.headerHeight/2,content:r.lifeline.label,font:{family:"Inter",size:14,weight:600},color:hc,align:jo,baseline:jn})))}},$P=t=>e=>{let n=t,r=e,o=!0,i;for(;o;){const a=n,s=r,u=s.stack.length-1|0;if(u>=0&&u<s.stack.length){n=a,r=mc(a)(s);continue}o=!1,i=s}return i},qP=t=>$P((()=>{const e=t.diagram.messages.length-1|0;return e>=0&&e<t.diagram.messages.length?t.diagram.messages[e].row:0})())(v(BP(SP(t.diagram.frameEndRows)))(FP)(_t(e=>e.kind==="Sync"||e.kind!=="SelfMsg",t.diagram.messages))),VP=t=>{const e=t.Monad0().Bind1();return n=>r=>{const o=n.bodyTop+(ot(r.row)+.5)*n.metrics.rowHeight,i=r.fromCol>=0&&r.fromCol<n.columns.length?n.columns[r.fromCol].x:n.metrics.padding,a=o-n.metrics.rowHeight*.3,s=i+36,u=o+n.metrics.rowHeight*.3,c=i+10,_=[1,i,u,2,c,u-5,2,c,u+5,...mo];return e.bind(t.strokePath([1,i,a,2,s,a,2,s,u,2,i,u])(yc))(()=>e.bind(t.fillPath(_)({color:Mm,flat:!0}))(()=>t.drawText({x:i+42,y:o,content:Zn(" ")(Y(wa)(r.labels)),font:{family:"Inter",size:12,weight:400},color:hc,align:po,baseline:jn})))}},UP=t=>{const e=t.Monad0(),n=e.Bind1(),r=Di(e.Applicative0())(Qt);return o=>i=>a=>s=>{const u=a?o.bodyTop+(ot(s.row)+.5)*o.metrics.rowHeight+o.metrics.rowHeight*.5:o.bodyTop+(ot(s.row)+.5)*o.metrics.rowHeight,c=s.toCol>=s.fromCol?1:-1,_=(s.fromCol>=0&&s.fromCol<o.columns.length?o.columns[s.fromCol].x:o.metrics.padding)+(Wm(i)(s.fromCol)(s.row)?c*6:c*0),f=(s.toCol>=0&&s.toCol<o.columns.length?o.columns[s.toCol].x:o.metrics.padding)-(Wm(i)(s.toCol)(s.row)?c*6:c*0),l=f-c*10,d=a?t.strokePath([1,l,u-5,2,f,u,2,l,u+5])(yc):t.fillPath([1,f,u,2,l,u-5,2,l,u+5,...mo])({color:Mm,flat:!0});return n.bind(a?r(WP(_)(f))(h=>t.strokePath([1,h._1,u,2,h._2,u])(yc)):t.strokePath([1,_,u,2,f,u])(yc))(()=>n.bind(d)(()=>t.drawText({x:(_+f)/2,y:u-6,content:Zn(" ")(Y(wa)(s.labels)),font:{family:"Inter",size:12,weight:400},color:hc,align:jo,baseline:YJ})))}},KP=t=>{const e=VP(t),n=UP(t);return r=>o=>i=>a=>{if(a.kind==="SelfMsg")return e(r)(a);if(a.kind==="Sync")return n(r)(o)(Dm(a.row)(i))(a);g()}},Vm={color:{r:26,g:26,b:26,a:255},width:1.25,lineJoin:nn,lineCap:zn},YP={color:{r:232,g:232,b:232,a:255},flat:!0},XP={color:{r:252,g:252,b:252,a:255},flat:!0},ZP=t=>e=>n=>{const r=n.col>=0&&n.col<e.columns.length?e.columns[n.col].x:e.metrics.padding,o=e.bodyTop+(ot(n.fromRow)+.5)*e.metrics.rowHeight,i=e.bodyTop+(ot(n.toRow)+.5)*e.metrics.rowHeight+e.metrics.rowHeight*.5,a=pc(r-6)(o)(r+6)(i)(3);return t.Monad0().Bind1().bind(t.fillStrokePath(pc(r-6)(o+5)(r+6)(i+5)(3))(YP)(Vm))(()=>t.fillStrokePath(a)(XP)(Vm))},Um=t=>{const e=t.Monad0(),n=e.Bind1(),r=Di(e.Applicative0())(Qt),o=HP(t),i=OP(t),a=QP(t),s=KP(t);return u=>{const c=qP(u);return n.bind(t.setViewport({vx:0,vy:0,vw:u.width,vh:u.height}))(()=>n.bind(t.clearBackground(EP))(()=>n.bind(r(u.columns)(o(u)))(()=>n.bind(r(u.columns)(i(u)))(()=>n.bind(r(c.spans)(ZP(t)(u)))(()=>n.bind(r(u.diagram.fragments)(a(u)))(()=>r(u.diagram.messages)(s(u)(c.spans)(c.returnRows))))))))}},jP=Um(dw);function Km(t){return function(e){return function(){return t.add(e)}}}function B1(t,e,n,r){if(typeof window<"u"){var o=window[n];if(o!=null&&r instanceof o)return e(r)}for(var i=r;i!=null;){var a=Object.getPrototypeOf(i),s=a.constructor.name;if(s===n)return e(r);if(s==="Object")return t;i=a}return t}function Ym(t){return function(){return t.classList}}function vn(t){return function(e){return function(n){return function(){n.setAttribute(t,e)}}}}function tG(t){return function(e){return function(){return e.getAttribute(t)}}}const Xm=t=>{const e=tG(t);return n=>{const r=e(n);return()=>{const o=r();return An(o,y,Xt)}}};function eG(t){return function(e){return function(){e.textContent=t}}}function nG(t){return function(){return function(e){return t(e)()}}}function rG(t){return function(e){return function(n){return function(r){return function(){return r.addEventListener(t,e,n)}}}}}const R1=function(){return window};function oG(t){return function(e){return function(){e.value=t}}}function iG(t){return function(){return t.valueAsNumber}}function aG(t){return function(){return t.value}}function D1(t){return function(e){return function(){return e.requestAnimationFrame(t)}}}const ps=t=>t,ms=t=>()=>{const e=t.getBoundingClientRect?.(),n=e?.width||t.clientWidth||0,r=e?.height||t.clientHeight||0;return{width:n,height:r}},Zm=t=>e=>()=>{let n=0;const r=()=>{n||(n=requestAnimationFrame(()=>{n=0,e()}))},o=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return o?.observe(t),window.addEventListener("resize",r),()=>{n&&cancelAnimationFrame(n),o?.disconnect(),window.removeEventListener("resize",r)}},jm=()=>window.devicePixelRatio||1,t2=()=>performance.now()/1e3,sG=t=>e=>n=>r=>o=>()=>{const i=Math.max(1,e||t.clientWidth||r),a=Math.max(1,n||t.clientHeight||o),s="Markgraf needs more room",u=`Resize to at least ${Math.round(r)} \xD7 ${Math.round(o)} px`;if(t.setAttribute("data-mg-too-small","1"),t.setAttribute("data-mg-viewport-css-width",String(e||0)),t.setAttribute("data-mg-viewport-css-height",String(n||0)),t.setAttribute("data-mg-camera-vw","0"),t.setAttribute("data-mg-camera-vh","0"),t.setAttribute("data-mg-camera-zoom","0"),t instanceof SVGElement){t.setAttribute("viewBox",`0 0 ${i} ${a}`),t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.innerHTML=`
27
27
  <rect x="0" y="0" width="${i}" height="${a}" rx="16" fill="#111827"/>
28
28
  <text x="${i/2}" y="${a/2-10}" text-anchor="middle" dominant-baseline="middle" fill="#f9fafb" font-family="system-ui, sans-serif" font-size="18" font-weight="700">${s}</text>
29
29
  <text x="${i/2}" y="${a/2+18}" text-anchor="middle" dominant-baseline="middle" fill="#cbd5e1" font-family="system-ui, sans-serif" font-size="13">${u}</text>
30
- `;return}if(t instanceof HTMLCanvasElement){const c=window.devicePixelRatio||1;t.width=Math.max(1,Math.round(i*c)),t.height=Math.max(1,Math.round(a*c));const _=t.getContext("2d");if(!_)return;_.save(),_.scale(c,c),_.clearRect(0,0,i,a),_.fillStyle="#111827",_.fillRect(0,0,i,a),_.textAlign="center",_.textBaseline="middle",_.fillStyle="#f9fafb",_.font="700 18px system-ui, sans-serif",_.fillText(s,i/2,a/2-10),_.fillStyle="#cbd5e1",_.font="13px system-ui, sans-serif",_.fillText(u,i/2,a/2+18),_.restore();return}t.textContent=`${s}. ${u}.`},ss=(t,e)=>{e.innerHTML=t},uc=(t,e,n)=>{t.style.setProperty(e,n)},A6=(t,e)=>t.querySelector(`[data-mg="${e}"]`),cc=t=>e=>t===e,gc=new WeakMap,N1=new WeakSet,I6=`#version 300 es
30
+ `;return}if(t instanceof HTMLCanvasElement){const c=window.devicePixelRatio||1;t.width=Math.max(1,Math.round(i*c)),t.height=Math.max(1,Math.round(a*c));const _=t.getContext("2d");if(!_)return;_.save(),_.scale(c,c),_.clearRect(0,0,i,a),_.fillStyle="#111827",_.fillRect(0,0,i,a),_.textAlign="center",_.textBaseline="middle",_.fillStyle="#f9fafb",_.font="700 18px system-ui, sans-serif",_.fillText(s,i/2,a/2-10),_.fillStyle="#cbd5e1",_.font="13px system-ui, sans-serif",_.fillText(u,i/2,a/2+18),_.restore();return}t.textContent=`${s}. ${u}.`},ys=(t,e)=>{e.innerHTML=t},xc=(t,e,n)=>{t.style.setProperty(e,n)},uG=(t,e)=>t.querySelector(`[data-mg="${e}"]`),Jc=t=>e=>t===e,wc=new WeakMap,F1=new WeakSet,cG=`#version 300 es
31
31
  precision highp float;
32
32
  out vec2 vUv;
33
33
  void main() {
34
34
  vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
35
35
  vUv = p;
36
36
  gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
37
- }`,F6=`#version 300 es
37
+ }`,gG=`#version 300 es
38
38
  precision highp float;
39
39
  uniform sampler2D uScene;
40
40
  uniform float uStrength;
@@ -58,7 +58,7 @@ void main() {
58
58
  float flicker = sin(uTime * 21.7) * 0.004 + sin(uTime * 7.1) * 0.003;
59
59
  color.rgb *= 1.0 + flicker * film;
60
60
  fragColor = color;
61
- }`,Am=(t,e,n)=>{const r=t.createShader(e);if(!r)throw new Error("Unable to allocate zoom shader");if(t.shaderSource(r,n),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const o=t.getShaderInfoLog(r)||"Zoom shader compilation failed";throw t.deleteShader(r),new Error(o)}return r},D6=(t,e,n)=>{const r=Am(t,t.VERTEX_SHADER,e),o=Am(t,t.FRAGMENT_SHADER,n),i=t.createProgram();if(!i)throw new Error("Unable to allocate zoom program");if(t.attachShader(i,r),t.attachShader(i,o),t.linkProgram(i),t.deleteShader(r),t.deleteShader(o),!t.getProgramParameter(i,t.LINK_STATUS)){const a=t.getProgramInfoLog(i)||"Zoom shader link failed";throw t.deleteProgram(i),new Error(a)}return i},z6=t=>{if(typeof document>"u"||typeof t?.getContext!="function"||!t.parentElement)return null;const e=document.createElement("canvas"),n=e.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1});if(!n)return null;const r=t.parentElement,o=r.style.position,i=getComputedStyle(r).position==="static";i&&(r.style.position="relative"),e.dataset.mg="velocity-pass",e.setAttribute("aria-hidden","true"),Object.assign(e.style,{display:"none",left:`${t.offsetLeft}px`,pointerEvents:"none",position:"absolute",top:`${t.offsetTop}px`,zIndex:"1"}),t.insertAdjacentElement("afterend",e);try{const a=D6(n,I6,F6),s=n.createTexture();if(!s)throw new Error("Unable to allocate zoom texture");return n.bindTexture(n.TEXTURE_2D,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.useProgram(a),n.uniform1i(n.getUniformLocation(a,"uScene"),0),{changedPosition:i,gl:n,overlay:e,overlayHeight:-1,overlayLeft:-1,overlayTop:-1,overlayWidth:-1,parent:r,program:a,restorePosition:o,restoreVisibility:t.style.visibility,sceneTextureHeight:0,sceneTextureWidth:0,source:t,texture:s,zoomFilmAmountLocation:n.getUniformLocation(a,"uFilmAmount"),zoomStrengthLocation:n.getUniformLocation(a,"uStrength"),zoomTimeLocation:n.getUniformLocation(a,"uTime")}}catch{return e.remove(),i&&r.style.position==="relative"&&(r.style.position=o),null}},B6=(t,e)=>{e&&(e.overlay.style.display!=="none"&&(e.overlay.style.display="none"),t.style.visibility!==e.restoreVisibility&&(t.style.visibility=e.restoreVisibility)),t.getAttribute("data-mg-gpu-pass")!=="idle"&&t.setAttribute("data-mg-gpu-pass","idle")},_c=(t,e)=>{let n=gc.get(t);if(Number(e)<.008){B6(t,n);return}if(N1.has(t)){t.setAttribute("data-mg-gpu-pass","unavailable");return}if(!n){try{n=z6(t)}catch{n=null}if(!n){N1.add(t),t.setAttribute("data-mg-gpu-pass","unavailable");return}gc.set(t,n)}const{gl:r,overlay:o,program:i,texture:a}=n,s=Math.max(1,t.width),u=Math.max(1,t.height);o.width!==s&&(o.width=s),o.height!==u&&(o.height=u);const c=t.offsetLeft,_=t.offsetTop,f=t.clientWidth,l=t.clientHeight;n.overlayLeft!==c&&(o.style.left=`${c}px`,n.overlayLeft=c),n.overlayTop!==_&&(o.style.top=`${_}px`,n.overlayTop=_),n.overlayWidth!==f&&(o.style.width=`${f}px`,n.overlayWidth=f),n.overlayHeight!==l&&(o.style.height=`${l}px`,n.overlayHeight=l),o.style.display!=="block"&&(o.style.display="block"),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a),n.sceneTextureWidth!==s||n.sceneTextureHeight!==u?(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),n.sceneTextureWidth=s,n.sceneTextureHeight=u):r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,t),r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,s,u),r.useProgram(i);const d=Math.max(0,Math.min(1,Number(e)||0));r.uniform1f(n.zoomFilmAmountLocation,Math.sqrt(d)),r.uniform1f(n.zoomTimeLocation,performance.now()/1e3),r.uniform1f(n.zoomStrengthLocation,d),r.drawArrays(r.TRIANGLES,0,3),t.getAttribute("data-mg-gpu-pass")!=="active"&&t.setAttribute("data-mg-gpu-pass","active"),t.style.visibility!=="hidden"&&(t.style.visibility="hidden")},M6=t=>{const e=gc.get(t);e&&(e.gl.deleteTexture(e.texture),e.gl.deleteProgram(e.program),e.overlay.remove(),t.style.visibility=e.restoreVisibility,e.changedPosition&&e.parent.style.position==="relative"&&(e.parent.style.position=e.restorePosition)),gc.delete(t),N1.delete(t),t.removeAttribute("data-mg-gpu-pass")},Im=(t,e)=>({tag:t,_1:e}),Fm=t=>t,Q6=(t,e,n)=>({tag:t,_1:e,_2:n}),bi=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},W6=Lm(u_),H6=Wt.foldMap(j2),fc=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},J1=Q6("AutoSize"),O6=Fm("CanvasRenderer"),q6=Fm("SvgRenderer"),V6=t=>e=>{const n=t-e*rt(he(nr(t/e)));return e<=0?0:n<0?n+e:n},aa=t=>v(e=>n=>{const r=t(n);return()=>(e(),r())})(()=>{}),$6=t=>{const e=b6("data-markgraf-theme")(t);return()=>{const n=e();if(n.tag==="Just")return n._1==="light"?O_:n._1==="dark"?FL:n._1==="blueprint"?DL:n._1==="whiteboard"?zL:n._1==="isometric"?BL:O_;if(n.tag==="Nothing")return O_;g()}},U6=`
61
+ }`,e2=(t,e,n)=>{const r=t.createShader(e);if(!r)throw new Error("Unable to allocate zoom shader");if(t.shaderSource(r,n),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const o=t.getShaderInfoLog(r)||"Zoom shader compilation failed";throw t.deleteShader(r),new Error(o)}return r},_G=(t,e,n)=>{const r=e2(t,t.VERTEX_SHADER,e),o=e2(t,t.FRAGMENT_SHADER,n),i=t.createProgram();if(!i)throw new Error("Unable to allocate zoom program");if(t.attachShader(i,r),t.attachShader(i,o),t.linkProgram(i),t.deleteShader(r),t.deleteShader(o),!t.getProgramParameter(i,t.LINK_STATUS)){const a=t.getProgramInfoLog(i)||"Zoom shader link failed";throw t.deleteProgram(i),new Error(a)}return i},fG=t=>{if(typeof document>"u"||typeof t?.getContext!="function"||!t.parentElement)return null;const e=document.createElement("canvas"),n=e.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1});if(!n)return null;const r=t.parentElement,o=r.style.position,i=getComputedStyle(r).position==="static";i&&(r.style.position="relative"),e.dataset.mg="velocity-pass",e.setAttribute("aria-hidden","true"),Object.assign(e.style,{display:"none",left:`${t.offsetLeft}px`,pointerEvents:"none",position:"absolute",top:`${t.offsetTop}px`,zIndex:"1"}),t.insertAdjacentElement("afterend",e);try{const a=_G(n,cG,gG),s=n.createTexture();if(!s)throw new Error("Unable to allocate zoom texture");return n.bindTexture(n.TEXTURE_2D,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.useProgram(a),n.uniform1i(n.getUniformLocation(a,"uScene"),0),{changedPosition:i,gl:n,overlay:e,overlayHeight:-1,overlayLeft:-1,overlayTop:-1,overlayWidth:-1,parent:r,program:a,restorePosition:o,restoreVisibility:t.style.visibility,sceneTextureHeight:0,sceneTextureWidth:0,source:t,texture:s,zoomFilmAmountLocation:n.getUniformLocation(a,"uFilmAmount"),zoomStrengthLocation:n.getUniformLocation(a,"uStrength"),zoomTimeLocation:n.getUniformLocation(a,"uTime")}}catch{return e.remove(),i&&r.style.position==="relative"&&(r.style.position=o),null}},dG=(t,e)=>{e&&(e.overlay.style.display!=="none"&&(e.overlay.style.display="none"),t.style.visibility!==e.restoreVisibility&&(t.style.visibility=e.restoreVisibility)),t.getAttribute("data-mg-gpu-pass")!=="idle"&&t.setAttribute("data-mg-gpu-pass","idle")},Tc=(t,e)=>{let n=wc.get(t);if(Number(e)<.008){dG(t,n);return}if(F1.has(t)){t.setAttribute("data-mg-gpu-pass","unavailable");return}if(!n){try{n=fG(t)}catch{n=null}if(!n){F1.add(t),t.setAttribute("data-mg-gpu-pass","unavailable");return}wc.set(t,n)}const{gl:r,overlay:o,program:i,texture:a}=n,s=Math.max(1,t.width),u=Math.max(1,t.height);o.width!==s&&(o.width=s),o.height!==u&&(o.height=u);const c=t.offsetLeft,_=t.offsetTop,f=t.clientWidth,l=t.clientHeight;n.overlayLeft!==c&&(o.style.left=`${c}px`,n.overlayLeft=c),n.overlayTop!==_&&(o.style.top=`${_}px`,n.overlayTop=_),n.overlayWidth!==f&&(o.style.width=`${f}px`,n.overlayWidth=f),n.overlayHeight!==l&&(o.style.height=`${l}px`,n.overlayHeight=l),o.style.display!=="block"&&(o.style.display="block"),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a),n.sceneTextureWidth!==s||n.sceneTextureHeight!==u?(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),n.sceneTextureWidth=s,n.sceneTextureHeight=u):r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,t),r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,s,u),r.useProgram(i);const d=Math.max(0,Math.min(1,Number(e)||0));r.uniform1f(n.zoomFilmAmountLocation,Math.sqrt(d)),r.uniform1f(n.zoomTimeLocation,performance.now()/1e3),r.uniform1f(n.zoomStrengthLocation,d),r.drawArrays(r.TRIANGLES,0,3),t.getAttribute("data-mg-gpu-pass")!=="active"&&t.setAttribute("data-mg-gpu-pass","active"),t.style.visibility!=="hidden"&&(t.style.visibility="hidden")},lG=t=>{const e=wc.get(t);e&&(e.gl.deleteTexture(e.texture),e.gl.deleteProgram(e.program),e.overlay.remove(),t.style.visibility=e.restoreVisibility,e.changedPosition&&e.parent.style.position==="relative"&&(e.parent.style.position=e.restorePosition)),wc.delete(t),F1.delete(t),t.removeAttribute("data-mg-gpu-pass")},n2=(t,e)=>({tag:t,_1:e}),r2=t=>t,hG=(t,e,n)=>({tag:t,_1:e,_2:n}),Ro=t=>e=>{const n=at.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},pG=Um(D_),mG=Qt.foldMap(rf),Nc=t=>e=>{const n=at.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},yG=Qt.foldMap(rf),z1=hG("AutoSize"),xG=r2("CanvasRenderer"),JG=r2("SvgRenderer"),wG=t=>e=>{const n=t-e*ot(he(ar(t/e)));return e<=0?0:n<0?n+e:n},Ai=t=>v(e=>n=>{const r=t(n);return()=>(e(),r())})(()=>{}),TG=t=>{const e=Xm("data-markgraf-theme")(t);return()=>{const n=e();if(n.tag==="Just")return n._1==="light"?l1:n._1==="dark"?uS:n._1==="blueprint"?cS:n._1==="whiteboard"?gS:n._1==="isometric"?_S:l1;if(n.tag==="Nothing")return l1;g()}},NG=`
62
62
  <canvas data-mg="stage" tabindex="0"></canvas>
63
63
  <div data-mg="play-overlay" aria-hidden="true"></div>
64
64
  <div data-mg="bar">
@@ -75,6 +75,6 @@ void main() {
75
75
  <option value="2">2\xD7</option>
76
76
  </select>
77
77
  </div>
78
- `,Dm=t=>e=>{const n=Sn(t,T,Vt);if(n.tag==="Just"){const r=Sn(n._1.stopAt,T,Vt);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return e;g()},X6=t=>e=>{const n=o=>r(o),r=o=>({...o,state:{...o.state,animationTime:t},minis:V(n)(o.minis)});return{...e,levels:V(r)(e.levels)}},zm=t=>e=>({...e,state:{...e.state,camera:t},minis:V(n=>zm(t)(n))(e.minis)}),Y6=t=>e=>n=>{const r=ln(n.rootLayout)(n.camera),o=xn("data-mg-too-small")("0")(t);return()=>(o(),xn("data-mg-camera-vw")(Po(r.w))(t)(),xn("data-mg-camera-vh")(Po(r.h))(t)(),xn("data-mg-camera-zoom")(Po(n.camera.zoom))(t)(),xn("data-mg-viewport-css-width")(Po(e.w))(t)(),xn("data-mg-viewport-css-height")(Po(e.h))(t)())},K6=t=>{const e=UP(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",KP(e._1));g()},j6=t=>e=>n=>{if(e.tag==="FixedSize")return()=>({w:e._1,h:e._2});if(e.tag==="AutoSize"){const r=as(t);return()=>{const o=r(),i=o.width<=0?n.width:o.width;return{w:i,h:o.height<=0?i*n.height/bi(1)(n.width):o.height}}}g()},Z6=t=>ue(e=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,yt("Cons",r._4,n(r._6,o)));g()};return ue(r=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,yt("Cons",i._4,o(i._6,a)));g()};return ue(i=>ue(a=>a.style==="RunHighlight"||a.style==="RunCodeHighlight",sr(i)),Bt(ce.foldr,o(r.labels,D)))},Bt(ce.foldr,n(e.keyframes,D)))},t.segments),tG=t=>e=>n=>{const r=kL(AL(v6(n))),o=xn("viewBox")(r.viewBox)(t);return()=>(o(),xn("preserveAspectRatio")("xMidYMid meet")(t)(),e.tag==="FixedSize"?(xn("width")(ae(he(Wn(e._1))))(t)(),xn("height")(ae(he(Wn(e._2))))(t)()):e.tag==="AutoSize"||g(),ss(r.body,t))},eG=t=>e=>n=>{const r=is(t),o=j6(t)(e)(n);return()=>{const i=o(),a=Gm(),s=i.w*a,u=i.h*a,c=O1(r)(),_=q1(r)(),f=V1(r)(s);c!==s&&f();const l=$1(r)(u);_!==u&&l(),e.tag==="FixedSize"?(uc(t,"width",ae(he(Wn(i.w)))+"px"),uc(t,"height",ae(he(Wn(i.h)))+"px")):e.tag==="AutoSize"||g();const d=H1(r)();br(d)(),ps(d)({scaleX:a,scaleY:a})();const h=eh(d)({width:i.w,height:i.h})();return W6(n)(h)(),kr(d)()}},nG=t=>e=>n=>r=>{if(e==="CanvasRenderer")return eG(t)(n)(r);if(e==="SvgRenderer")return tG(t)(n)(r);g()},rG=t=>e=>n=>r=>()=>{let o=!1,i=()=>{},a=[];const s=()=>{const c=o,_=nG(t)(e)(n)(r);if(!c)return _()},u={time:0,keyframe:"sequence",playing:!1};return s(),i=Pm(t)(()=>{s();const c=a;return aa(_=>_(u))(c)()})(),{play:()=>{},playWith:c=>()=>{},pause:()=>{},toggle:()=>{},seek:c=>()=>{},seekCue:c=>()=>{},seekStep:c=>()=>{},playToCue:c=>_=>()=>{},playToStep:c=>_=>()=>{},playNext:c=>()=>{},playPrevious:c=>()=>{},setSpeed:c=>()=>{},currentTime:(()=>{const c=u.time;return()=>c})(),currentKeyframe:(()=>{const c=u.keyframe;return()=>c})(),isPlaying:()=>!1,duration:0,cues:[],steps:[],subscribe:c=>()=>{a=wt(a)(c),c(u)();const _=ca(f=>!cc(f)(c));return()=>{a=_(a)}},subscribeCue:c=>()=>()=>{},subscribeComplete:c=>()=>()=>{},destroy:()=>(o=!0,i())}},Wr=t=>e=>n=>()=>{const r=A6(t,e),o=Sn(r,T,Vt);if(o.tag==="Just")return n(o._1)();o.tag!=="Nothing"&&g()},oG=t=>e=>{const n=e.totalDuration<=0?1:e.totalDuration,r=H6(o=>'<span class="mg-tick" style="left:'+Do(Io("Fixed",Fo(0)(20)(2)))(100*o.startT/n)+'%" data-label="'+(()=>{if(o.scene.tag==="Structural")return o.scene._1.to;if(o.scene.tag==="DataFlow")return o.scene._1.keyframe;if(o.scene.tag==="Hold")return o.scene._1;if(o.scene.tag==="EnterNode"||o.scene.tag==="ExitNode")return"";if(o.scene.tag==="StepScene")return o.scene._1;g()})()+'"></span>')(e.spans);return Wr(t)("ticks")(o=>()=>ss(r,o))},iG=t=>e=>n=>Wr(t)("scrub")(r=>{const o=x1(T,Vt,"HTMLInputElement",r);if(o.tag==="Nothing")return()=>{};if(o.tag==="Just")return n<=0?()=>{}:E6(ae(he(Wn(e/n*1e3))))(o._1);g()}),v1=t=>e=>n=>{const r=L6(o=>n);return()=>{const o=r();return S6(t)(o)(!1)(e)()}},aG=t=>e=>{const n=Em(t);return()=>{const r=n();return Sm(r)("markgraf-embed")(),ss(`
78
+ `,o2=t=>e=>{const n=An(t,y,Xt);if(n.tag==="Just"){const r=An(n._1.stopAt,y,Xt);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return e;g()},vG=t=>e=>{const n=o=>r(o),r=o=>({...o,state:{...o.state,animationTime:t},minis:Y(n)(o.minis)});return{...e,levels:Y(r)(e.levels)}},i2=t=>e=>({...e,state:{...e.state,camera:t},minis:Y(n=>i2(t)(n))(e.minis)}),bG=t=>e=>n=>{const r=gr(n.rootLayout)(n.camera),o=vn("data-mg-too-small")("0")(t);return()=>(o(),vn("data-mg-camera-vw")(bn(r.w))(t)(),vn("data-mg-camera-vh")(bn(r.h))(t)(),vn("data-mg-camera-zoom")(bn(n.camera.zoom))(t)(),vn("data-mg-viewport-css-width")(bn(e.w))(t)(),vn("data-mg-viewport-css-height")(bn(e.h))(t)())},CG=t=>{const e=NP(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right")return Dt("Right",CP(e._1));g()},LG=t=>e=>n=>{if(e.tag==="FixedSize")return()=>({w:e._1,h:e._2});if(e.tag==="AutoSize"){const r=ms(t);return()=>{const o=r(),i=o.width<=0?n.width:o.width;return{w:i,h:o.height<=0?i*n.height/Ro(1)(n.width):o.height}}}g()},kG=t=>oe(e=>{const n=(r,o)=>{if(r.tag==="Leaf")return o;if(r.tag==="Node")return n(r._5,Jt("Cons",r._4,n(r._6,o)));g()};return oe(r=>{const o=(i,a)=>{if(i.tag==="Leaf")return a;if(i.tag==="Node")return o(i._5,Jt("Cons",i._4,o(i._6,a)));g()};return oe(i=>oe(a=>a.style==="RunHighlight"||a.style==="RunCodeHighlight",dr(i)),It(ge.foldr,o(r.labels,z)))},It(ge.foldr,n(e.keyframes,z)))},t.segments),SG=t=>e=>n=>{const r=j5(aS(jP(n))),o=vn("viewBox")(r.viewBox)(t);return()=>(o(),vn("preserveAspectRatio")("xMidYMid meet")(t)(),e.tag==="FixedSize"?(vn("width")(ue(he(Un(e._1))))(t)(),vn("height")(ue(he(Un(e._2))))(t)()):e.tag==="AutoSize"||g(),ys(r.body,t))},EG=t=>e=>n=>{const r=ps(t),o=LG(t)(e)(n);return()=>{const i=o(),a=jm(),s=i.w*a,u=i.h*a,c=sf(r)(),_=uf(r)(),f=cf(r)(s);c!==s&&f();const l=gf(r)(u);_!==u&&l(),e.tag==="FixedSize"?(xc(t,"width",ue(he(Un(i.w)))+"px"),xc(t,"height",ue(he(Un(i.h)))+"px")):e.tag==="AutoSize"||g();const d=af(r)();sr(d)(),Ca(d)({scaleX:a,scaleY:a})();const h=tp(d)({width:i.w,height:i.h})();return pG(n)(h)(),ur(d)()}},PG=t=>e=>n=>r=>{if(e==="CanvasRenderer")return EG(t)(n)(r);if(e==="SvgRenderer")return SG(t)(n)(r);g()},GG=t=>e=>n=>r=>()=>{let o=!1,i=()=>{},a=[];const s=()=>{const c=o,_=PG(t)(e)(n)(r);if(!c)return _()},u={time:0,keyframe:"sequence",playing:!1};return s(),i=Zm(t)(()=>{s();const c=a;return Ai(_=>_(u))(c)()})(),{play:()=>{},playWith:c=>()=>{},pause:()=>{},toggle:()=>{},seek:c=>()=>{},seekCue:c=>()=>{},seekStep:c=>()=>{},playToCue:c=>_=>()=>{},playToStep:c=>_=>()=>{},playNext:c=>()=>{},playPrevious:c=>()=>{},setSpeed:c=>()=>{},currentTime:(()=>{const c=u.time;return()=>c})(),currentKeyframe:(()=>{const c=u.keyframe;return()=>c})(),isPlaying:()=>!1,duration:0,cues:[],steps:[],subscribe:c=>()=>{a=Et(a)(c),c(u)();const _=Ta(f=>!Jc(f)(c));return()=>{a=_(a)}},subscribeCue:c=>()=>()=>{},subscribeComplete:c=>()=>()=>{},destroy:()=>(o=!0,i())}},Wr=t=>e=>n=>()=>{const r=uG(t,e),o=An(r,y,Xt);if(o.tag==="Just")return n(o._1)();o.tag!=="Nothing"&&g()},AG=t=>e=>{const n=e.totalDuration<=0?1:e.totalDuration,r=mG(o=>'<span class="mg-tick" style="left:'+Oo(Qo("Fixed",Mo(0)(20)(2)))(100*o.startT/n)+'%" data-label="'+(()=>{if(o.scene.tag==="Structural")return o.scene._1.to;if(o.scene.tag==="DataFlow")return o.scene._1.keyframe;if(o.scene.tag==="Hold")return o.scene._1;if(o.scene.tag==="EnterNode"||o.scene.tag==="ExitNode")return"";if(o.scene.tag==="StepScene")return o.scene._1;g()})()+'"></span>')(e.spans);return Wr(t)("ticks")(o=>()=>ys(r,o))},BG=t=>e=>n=>Wr(t)("scrub")(r=>{const o=B1(y,Xt,"HTMLInputElement",r);if(o.tag==="Nothing")return()=>{};if(o.tag==="Just")return n<=0?()=>{}:oG(ue(he(Un(e/n*1e3))))(o._1);g()}),I1=t=>e=>n=>{const r=nG(o=>n);return()=>{const o=r();return rG(t)(o)(!1)(e)()}},RG=t=>e=>{const n=Ym(t);return()=>{const r=n();return Km(r)("markgraf-embed")(),ys(`
79
79
  <svg data-mg="stage" tabindex="0" role="img" aria-label="Markgraf sequence diagram"></svg>
80
- `,t),Wr(t)("stage")(o=>{const i=rG(o)(q6)(J1)(e);return()=>{const a=T1();w1(()=>{i()})(a)()}})()}},sG=t=>e=>{const n=Sn(t,T,Vt);if(n.tag==="Just"){const r=Sn(n._1.loop,T,Vt);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return e;g()},C1=t=>e=>{const n=ne(r=>r.startT<=e&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return n._1.scene._1.to;if(n._1.scene.tag==="DataFlow")return n._1.scene._1.keyframe;if(n._1.scene.tag==="Hold")return n._1.scene._1;if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return"";if(n._1.scene.tag==="StepScene")return n._1.scene._1;g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;if(r>=0&&r<t.spans.length){if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="Hold")return t.spans[r].scene._1;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return"";if(t.spans[r].scene.tag==="StepScene")return t.spans[r].scene._1;g()}return""}g()},uG=t=>e=>Wr(t)("speed")(n=>{const r=x1(T,Vt,"HTMLSelectElement",n);if(r.tag==="Nothing")return()=>{};if(r.tag==="Just")return v1("change")(n)((()=>{const o=G6(r._1);return()=>{const i=o(),a=Cc(i,ga,Vt,T);if(a.tag==="Just")return e(a._1)();a.tag!=="Nothing"&&g()}})());g()}),cG=t=>e=>n=>Wr(t)("scrub")(r=>{const o=x1(T,Vt,"HTMLInputElement",r);if(o.tag==="Nothing")return()=>{};if(o.tag==="Just")return v1("input")(r)((()=>{const i=P6(o._1);return()=>{const a=i();return n.pause(),n.seek(a/1e3*e.totalDuration)()}})());g()}),gG=t=>e=>n=>{const r=oG(t)(e);return()=>{r(),Wr(t)("play")(o=>xn("data-mg-playing")("1")(o))(),uG(t)(n.setSpeed)(),Wr(t)("play")(o=>v1("click")(o)(n.toggle))(),cG(t)(e)(n)(),n.subscribe(o=>{const i=iG(t)(o.time)(e.totalDuration);return()=>(i(),Wr(t)("time")(a=>k6(Do(Io("Fixed",Fo(0)(20)(2)))(o.time)+" / "+Do(Io("Fixed",Fo(0)(20)(2)))(e.totalDuration))(a))(),Wr(t)("play")(a=>xn("data-mg-playing")(o.playing?"1":"0")(a))())})()}},_G=t=>e=>{if(e.tag==="FixedSize")return()=>({widthPx:e._1,heightPx:e._2});if(e.tag==="AutoSize"){const n=as(t);return()=>{const r=n();return{widthPx:r.width<=0?200:r.width,heightPx:r.height<=0?180:r.height}}}g()},fG=t=>e=>n=>{const r=_G(t)(e);return()=>{const o=r(),i=bd(n)(),a=kd(n)(),s=HS(kx)(o)(kS)(n)(Ld(i)(a)(n));if(s.tag==="Left")return Dt("Left","precompute failed");if(s.tag==="Right")return Dt("Right",{schedule:s._1});g()}},lG=t=>e=>(()=>{const n=Sn(t,T,Vt);if(n.tag==="Just")return{...n._1,direction:e<0?"backward":"forward"};if(n.tag==="Nothing")return{direction:e<0?"backward":"forward",speed:_a,duration:_a,loop:_a,stopAt:_a};g()})(),Bm=t=>e=>{const n=Sn(t,T,Vt);if(n.tag==="Just"){const r=Sn(n._1.direction,T,Vt);if(r.tag==="Just"){if(r._1==="backward"||r._1==="reverse")return-1;if(r._1==="forward")return 1}return e}if(n.tag==="Nothing")return e;g()},dG=t=>e=>{const n=gt(o=>o.time<=e+1e-4,t),r=n.length-1|0;return r>=0&&r<n.length?n[r].index:-1},hG=t=>e=>{if(e.tag==="FixedSize"){const n=e._1<=0||e._2<=0?T:J("Just",e._1/e._2);return()=>n}if(e.tag==="AutoSize"){const n=as(t);return()=>{const r=n();return r.width<=0||r.height<=0?T:J("Just",r.width/r.height)}}g()},us=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>f=>()=>{const l=Rm(),d=_.value,h=c.value,p=d===0?0:l-d,m=h+p;_.value=l,c.value=m;const x=(()=>{if(n.tag==="FixedSize")return{w:n._1,h:n._2};if(n.tag==="AutoSize"){const E=as(t)();return{w:E.width<=0?200:E.width,h:E.height<=0?180:E.height}}g()})();if(x.w<200||x.h<180){if(R6(t)(x.w)(x.h)(200)(180)(),e==="CanvasRenderer")return _c(is(t),0);if(e==="SvgRenderer")return;g()}const y=a.value,w=(()=>{if(y.tag==="Just"&&y._1.w===x.w&&y._1.h===x.h)return y._1.schedule;const E={widthPx:x.w,heightPx:x.h},I=E.heightPx===i.cameraViewport.heightPx&&E.widthPx===i.cameraViewport.widthPx?i:rS(E)(i);return a.value=J("Just",{w:x.w,h:x.h,schedule:I}),I})(),N=X6(m)(KT(w)(fc(f)(w.totalDuration))),b=u.value,C=(()=>{if(b.tag==="Nothing")return N.camera;if(b.tag==="Just")return bx(i.cameraConfig.cameraDecay)(p)(b._1)(N.camera);g()})();u.value=J("Just",C);const L={...N,camera:C,levels:V(zm(C))(N.levels)};if(Y6(t)(x)(L)(),e==="CanvasRenderer"){const E=is(t),I=yp({width:0,height:0})(L),W=(()=>{if(n.tag==="FixedSize")return{w:n._1,h:n._2};if(n.tag==="AutoSize"){const Q=as(t)();return{w:Q.width,h:Q.height<=0?I.vw<=0?Q.width:Q.width*I.vh/I.vw:Q.height}}g()})(),P=Gm(),G=W.w*P,j=W.h*P,nt=O1(E)(),O=q1(E)(),$=V1(E)(G);nt!==G&&$();const H=$1(E)(j);O!==j&&H(),n.tag==="FixedSize"?(uc(t,"width",ae(he(Wn(W.w)))+"px"),uc(t,"height",ae(he(Wn(W.h)))+"px")):n.tag==="AutoSize"||g();const A=H1(E)();br(A)(),ps(A)({scaleX:P,scaleY:P})();const B=s.value,z=yL(r)(o)(A)({width:W.w,height:W.h})(L)(p)(B)();return s.value=z,kr(A)(),_c(E,zT(L.portalState))}if(e==="SvgRenderer"){const E=s.value,I=hG(t)(n)(),W=ZL(I)(r)(o)(L)(p)(E);return s.value=W.springs,xn("viewBox")(W.parts.viewBox)(t)(),xn("preserveAspectRatio")("xMidYMid meet")(t)(),n.tag==="FixedSize"?(xn("width")(ae(he(Wn(n._1))))(t)(),xn("height")(ae(he(Wn(n._2))))(t)()):n.tag==="AutoSize"||g(),ss(W.parts.body,t)}g()},pG=t=>{const e=q0(t)(D0)._1;if(e.tag==="Left")return Dt("Left",e._1.msg);if(e.tag==="Right")return Dt("Right",e._1);g()},Mm=t=>{const e=EP(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right"){if(e._1.mode==="SequenceSurface"){const r=K6(e._1);if(r.tag==="Left")return Dt("Left",r._1);if(r.tag==="Right")return Dt("Right",Im("LoadedSequence",r._1));g()}const n=pG(e._1);if(n.tag==="Left")return Dt("Left",n._1);if(n.tag==="Right")return Dt("Right",Im("LoadedAnimation",n._1))}g()},mG=t=>{const e=Mm(t);if(e.tag==="Left")return e._1;if(e.tag==="Right")return _a;g()},Qm=t=>e=>n=>r=>{const o=n+1e-4>=e?gt(a=>a.time>e+1e-4&&a.time<=n+1e-4,t):[...gt(a=>a.time>e+1e-4,t),...gt(a=>a.time<=n+1e-4,t)],i=n<=e+1e-4?ee(gt(a=>a.time<e-1e-4&&a.time>=n-1e-4,t)):[...ee(gt(a=>a.time<e-1e-4,t)),...ee(gt(a=>a.time>=n-1e-4,t))];return(()=>{const a=n-e;return a<0?-a<=1e-4:a<=1e-4})()?[]:r>=0?o:i},yG=t=>e=>n=>r=>ne(o=>ue(i=>i===o.kind,e)&&(o.time>n+1e-4||(()=>{const i=o.time-n;return(i<0?-i<=1e-4:i<=1e-4)&&o.index>r})()))(t),xG=t=>e=>n=>r=>{const o=gt(a=>ue(s=>s===a.kind,e)&&(a.time<n-1e-4||(()=>{const s=a.time-n;return(s<0?-s<=1e-4:s<=1e-4)&&a.index<r})()),t),i=o.length-1|0;return i>=0&&i<o.length?J("Just",o[i]):T},b1=t=>e=>n=>{const r=Sn(e,T,Vt);if(r.tag==="Just"){const o=Sn(r._1.speed,T,Vt);if(o.tag==="Just"){const i=bi(1e-4)(o._1<0?-o._1:o._1);return()=>t.value=i}if(o.tag==="Nothing"){const i=Sn(r._1.duration,T,Vt);if(i.tag==="Just"&&n.tag==="Just"){const a=n._1/i._1,s=bi(1e-4)(a<0?-a:a);if(i._1>0)return()=>t.value=s}return()=>{}}g()}if(r.tag==="Nothing")return()=>{};g()},TG=t=>e=>n=>r=>{const o=r.time-e,i=o<0?-o<=1e-4:o<=1e-4,a=r.time<e-1e-4||i&&r.index<n,s=a?-1:1,u=r.time>e+1e-4||i&&r.index>n,c=Sn(t,T,Vt);if(c.tag==="Just"){const _=Sn(c._1.direction,T,Vt);if(_.tag==="Just"){if(_._1==="forward")return i||u?J("Just",1):T;if(_._1==="backward"||_._1==="reverse")return i||a?J("Just",-1):T}return J("Just",s)}if(c.tag==="Nothing")return J("Just",s);g()},wG=t=>e=>n=>r=>o=>i=>()=>{const a={value:1};let s=1,u=!0,c=T,_=-1,f=!0,l=!1,d=0,h=0;const p={value:M},m={value:T},x={value:0},y={value:0},w={value:T};let N=!1,b=()=>{},C=[],L=[],E=[];if(us(t)(n)(r)(o)(i)(e)(w)(p)(m)(x)(y)(0)(),n==="CanvasRenderer"&&e.dives.length!==0){const F=is(t);_c(F,.01),_c(F,0)}const I=F=>{const X=F.index;return()=>{_=X;const q=L;return aa(U=>U(F))(q)()}},W=F=>()=>{const X=C,q=f,U={time:F,keyframe:C1(e)(F),playing:q};return aa(Y=>Y(U))(X)()},P=()=>(f=!1,c=T,W(d)()),G=F=>()=>(d=F,us(t)(n)(r)(o)(i)(e)(w)(p)(m)(x)(y)(F)(),W(F)()),j=F=>{const X=bi(0)(fc(e.totalDuration)(F));return()=>(d=X,_=dG(e.cues)(X),h=0,c=T,m.value=T,us(t)(n)(r)(o)(i)(e)(w)(p)(m)(x)(y)(X)(),W(X)())},nt=(F,X,q,U,Y)=>()=>{f=!1,c=T;const ot=d;W(ot)();const Z={reason:F,direction:X<0?"backward":"forward",targetId:q,targetStep:U,reached:Y,time:ot},ft=E;return aa(Lt=>Lt(Z))(ft)()},O=Z6(e),$=()=>{if(!N){if(l=!1,f){const F=Rm(),X=h;h=F;const q=a.value,U=s,Y=u,ot=c,Z=d,ft=X===0?Z+0*q*U:Z+(F-X)*q*U;if(ot.tag==="Just"){const Lt=U>=0?ot._1.cue.time>=Z-1e-4&&ot._1.cue.time<=ft+1e-4:ot._1.cue.time<=Z+1e-4&&ot._1.cue.time>=ft-1e-4,dt=Lt?ot._1.cue.time:bi(0)(fc(e.totalDuration)(ft));(U>=0?dt+1e-4<Z:dt>Z+1e-4)&&(m.value=T),G(dt)(),aa(St=>I(St))(Qm(e.cues)(Z)(dt)(U))();const Nt=nt("target",U,ot._1.targetId,ot._1.targetStep,!0);Lt&&Nt(),Lt||H()}else if(ot.tag==="Nothing"){const Lt=U>=0?e.totalDuration:0,dt=!Y&&(U>=0?Lt>=Z-1e-4&&Lt<=ft+1e-4:Lt<=Z+1e-4&&Lt>=ft-1e-4),Nt=Y?V6(ft)(e.totalDuration+.8):bi(0)(fc(e.totalDuration)(ft));(U>=0?Nt+1e-4<Z:Nt>Z+1e-4)&&(m.value=T),G(Nt)(),aa(te=>I(te))(Qm(e.cues)(Z)(Nt)(U))();const St=nt("boundary",U,"","",!0);dt&&St(),dt||H()}else g()}if(O&&!f){const F=d;return us(t)(n)(r)(o)(i)(e)(w)(p)(m)(x)(y)(F)(),H()}}},H=()=>{if(!N&&!l){l=!0;const F=T1();w1($)(F)()}},A=()=>(h=0,f=!0,H()),B=()=>(s=1,u=!0,c=T,A(),W(d)()),z=(F,X)=>()=>{const q=d;return s=F,u=!1,c=T,b1(a)(X)(J("Just",F>=0?e.totalDuration-q:q))(),A()},Q=(F,X)=>()=>{const q=d,U=_,Y=TG(X)(q)(U)(F);if(Y.tag==="Nothing")return z(Bm(X)(1),X)();if(Y.tag==="Just"){const ot=F.time-q,Z=ot<0?-ot:ot;return s=Y._1,u=!1,c=J("Just",{cue:F,direction:Y._1,targetId:F.id,targetStep:F.name}),b1(a)(X)(J("Just",Z))(),Z<=1e-4?(j(F.time)(),I(F)(),nt("target",Y._1,F.id,F.name,!0)()):A()}g()};return b=Pm(t)(()=>{if(!N){const F=d;return us(t)(n)(r)(o)(i)(e)(w)(p)(m)(x)(y)(F)(),W(F)()}})(),A(),{play:B,playWith:F=>{const X=Bm(F)(1);return()=>(s=X,u=sG(F)(!1),c=T,b1(a)(F)(T)(),A(),W(d)())},pause:P,toggle:()=>f?P():B(),seek:F=>j(F),seekCue:F=>{const X=ne(q=>q.id===F)(e.cues);if(X.tag==="Nothing")return()=>{};if(X.tag==="Just"){const q=X._1,U=j(q.time);return()=>(U(),I(q)())}g()},seekStep:F=>{const X=ne(q=>q.kind==="step"&&q.name===F)(e.cues);if(X.tag==="Nothing")return()=>{};if(X.tag==="Just"){const q=X._1,U=j(q.time);return()=>(U(),I(q)())}g()},playToCue:F=>X=>{const q=ne(U=>U.id===F)(e.cues);if(q.tag==="Nothing")return()=>{};if(q.tag==="Just")return Q(q._1,X);g()},playToStep:F=>X=>{const q=ne(U=>U.kind==="step"&&U.name===F)(e.cues);if(q.tag==="Nothing")return()=>{};if(q.tag==="Just")return Q(q._1,X);g()},playNext:F=>()=>{const X=d,q=_,U=yG(e.cues)(Dm(F)(["step"]))(X)(q);if(U.tag==="Nothing")return z(1,F)();if(U.tag==="Just")return Q(U._1,F)();g()},playPrevious:F=>()=>{const X=d,q=_,U=xG(e.cues)(Dm(F)(["step"]))(X)(q);if(U.tag==="Nothing")return z(-1,F)();if(U.tag==="Just")return Q(U._1,lG(F)(-1))();g()},setSpeed:F=>{const X=bi(1e-4)(F<0?-F:F);return()=>a.value=X},currentTime:()=>d,currentKeyframe:()=>{const F=d;return C1(e)(F)},isPlaying:()=>f,duration:e.totalDuration,cues:e.cues,steps:gt(F=>F.kind==="step",e.cues),subscribe:F=>()=>{C=wt(C)(F);const X=d,q=f;F({time:X,keyframe:C1(e)(X),playing:q})();const U=ca(Y=>!cc(Y)(F));return()=>{C=U(C)}},subscribeCue:F=>()=>{L=wt(L)(F);const X=ca(q=>!cc(q)(F));return()=>{L=X(L)}},subscribeComplete:F=>()=>{E=wt(E)(F);const X=ca(q=>!cc(q)(F));return()=>{E=X(E)}},destroy:()=>{if(N=!0,b(),n==="CanvasRenderer")return M6(is(t));n!=="SvgRenderer"&&g()}}},NG=t=>e=>{const n=Em(t);return()=>{const r=n();Sm(r)("markgraf-embed")();const o=$6(t)();return ss(U6,t),Wr(t)("stage")(i=>{const a=fG(i)(J1)(e);return()=>{const s=T1();w1(()=>{const u=a();if(u.tag==="Left")return W1("[markgraf] precompute failed")();if(u.tag==="Right"){const c=wG(i)(u._1.schedule)(O6)(J1)(o)(ML)();return gG(t)(u._1.schedule)(c)()}g()})(s)()}})()}},Wm=t=>e=>{const n=Mm(e);if(n.tag==="Left")return W1("[markgraf] parse failed: "+n._1);if(n.tag==="Right"){if(n._1.tag==="LoadedAnimation")return NG(t)(n._1._1);if(n._1.tag==="LoadedSequence")return aG(t)(n._1._1)}g()},JG=t=>{const e=t.getAttribute("data-markgraf-src-b64");if(e)try{return decodeURIComponent(escape(atob(e)))}catch{return atob(e)}return t.getAttribute("data-markgraf-src")||t.textContent||""};let Hr=null;const lc=t=>t.querySelector('[data-mg="play"]')?.dataset.mgPlaying==="1",vG=t=>{const e=t.querySelector('[data-mg="play"]');if(!e)return;e.addEventListener("click",()=>{queueMicrotask(()=>{lc(t)?(Hr&&Hr!==t&&lc(Hr)&&Hr.querySelector('[data-mg="play"]').click(),Hr=t):Hr===t&&(Hr=null)})});const n=r=>{r.preventDefault(),e.click()};t.querySelector('[data-mg="stage"]')?.addEventListener("click",n)},CG=t=>{if(t.dataset.markgrafMounted==="1")return;t.dataset.markgrafMounted="1";const e=JG(t),n=t.dataset.markgrafPaused==="true";t.textContent="",Wm(t)(e)(),t.querySelector('[data-mg="play"]')&&(n?lc(t)&&t.querySelector('[data-mg="play"]').click():Hr===null?Hr=t:lc(t)&&t.querySelector('[data-mg="play"]').click(),vG(t))},dc=(t=document)=>{t.querySelectorAll("[data-markgraf]").forEach(CG)},Hm=()=>{document.addEventListener("keydown",t=>{if(t.code!=="Space"&&t.key!==" ")return;const e=t.target,n=e&&e.closest?.("[data-markgraf]");if(!n){const o=e?.tagName,i=(e?.type||"").toLowerCase();if(e?.isContentEditable||o==="TEXTAREA"||o==="SELECT"||o==="INPUT"&&!["range","checkbox","radio","button","submit","reset"].includes(i))return}const r=n||Hr||document.querySelector("[data-markgraf]");r&&(t.preventDefault(),r.querySelector('[data-mg="play"]')?.click())})};if(typeof window<"u"){const t=e=>{const n=mG(e);return n==null?{ok:!0}:{ok:!1,error:n}};window.markgraf={mount:(e,n)=>Wm(e)(n)(),mountAll:dc,tryParse:t},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{dc(),Hm()}):(dc(),Hm())}return hc.mountAll=dc,Object.defineProperty(hc,Symbol.toStringTag,{value:"Module"}),hc})({});
80
+ `,t),Wr(t)("stage")(o=>{const i=GG(o)(JG)(z1)(e);return()=>{const a=R1();D1(()=>{i()})(a)()}})()}},DG=t=>e=>{const n=An(t,y,Xt);if(n.tag==="Just"){const r=An(n._1.loop,y,Xt);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return e;g()},Q1=t=>e=>{const n=te(r=>r.startT<=e&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return n._1.scene._1.to;if(n._1.scene.tag==="DataFlow")return n._1.scene._1.keyframe;if(n._1.scene.tag==="Hold")return n._1.scene._1;if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return"";if(n._1.scene.tag==="StepScene")return n._1.scene._1;g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;if(r>=0&&r<t.spans.length){if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="Hold")return t.spans[r].scene._1;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return"";if(t.spans[r].scene.tag==="StepScene")return t.spans[r].scene._1;g()}return""}g()},FG=t=>e=>Wr(t)("speed")(n=>{const r=B1(y,Xt,"HTMLSelectElement",n);if(r.tag==="Nothing")return()=>{};if(r.tag==="Just")return I1("change")(n)((()=>{const o=aG(r._1);return()=>{const i=o(),a=Rc(i,Na,Xt,y);if(a.tag==="Just")return e(a._1)();a.tag!=="Nothing"&&g()}})());g()}),zG=t=>e=>n=>Wr(t)("scrub")(r=>{const o=B1(y,Xt,"HTMLInputElement",r);if(o.tag==="Nothing")return()=>{};if(o.tag==="Just")return I1("input")(r)((()=>{const i=iG(o._1);return()=>{const a=i();return n.pause(),n.seek(a/1e3*e.totalDuration)()}})());g()}),IG=t=>e=>n=>{const r=AG(t)(e);return()=>{r(),Wr(t)("play")(o=>vn("data-mg-playing")("1")(o))(),FG(t)(n.setSpeed)(),Wr(t)("play")(o=>I1("click")(o)(n.toggle))(),zG(t)(e)(n)(),n.subscribe(o=>{const i=BG(t)(o.time)(e.totalDuration);return()=>(i(),Wr(t)("time")(a=>eG(Oo(Qo("Fixed",Mo(0)(20)(2)))(o.time)+" / "+Oo(Qo("Fixed",Mo(0)(20)(2)))(e.totalDuration))(a))(),Wr(t)("play")(a=>vn("data-mg-playing")(o.playing?"1":"0")(a))())})()}},QG=t=>e=>{if(e.tag==="FixedSize")return()=>({widthPx:e._1,heightPx:e._2});if(e.tag==="AutoSize"){const n=ms(t);return()=>{const r=n();return{widthPx:r.width<=0?200:r.width,heightPx:r.height<=0?180:r.height}}}g()},MG=t=>e=>n=>{const r=QG(t)(e);return()=>{const o=r(),i=Yh(n)(),a=Xh(n)(),s=yE($x)(o)(nE)(n)(Zh(i)(a)(n));if(s.tag==="Left")return Dt("Left","precompute failed");if(s.tag==="Right")return Dt("Right",{schedule:s._1});g()}},OG=t=>e=>(()=>{const n=An(t,y,Xt);if(n.tag==="Just")return{...n._1,direction:e<0?"backward":"forward"};if(n.tag==="Nothing")return{direction:e<0?"backward":"forward",speed:va,duration:va,loop:va,stopAt:va};g()})(),a2=t=>e=>{const n=An(t,y,Xt);if(n.tag==="Just"){const r=An(n._1.direction,y,Xt);if(r.tag==="Just"){if(r._1==="backward"||r._1==="reverse")return-1;if(r._1==="forward")return 1}return e}if(n.tag==="Nothing")return e;g()},WG=t=>e=>{const n=_t(o=>o.time<=e+1e-4,t),r=n.length-1|0;return r>=0&&r<n.length?n[r].index:-1},s2=t=>e=>[{label:"PAN BOUNDS",color:"#22c55e",box:e.level},...(()=>{if(e.visible.tag==="Nothing")return[];if(e.visible.tag==="Just")return[{label:"VISIBLE CONTENT",color:"#f59e0b",box:e.visible._1}];g()})(),...(()=>{if(e.action.tag==="Nothing")return[];if(e.action.tag==="Just")return[{label:"ACTION BOXES",color:"#f43f5e",box:e.action._1}];g()})(),...(()=>{if(e.actionText.tag==="Nothing")return[];if(e.actionText.tag==="Just")return[{label:"ACTION TEXT",color:"#a855f7",box:e.actionText._1}];g()})(),...(()=>{if(e.actionGuide.tag==="Nothing")return[];if(e.actionGuide.tag==="Just")return[{label:"ACTION DETAIL",color:"#a3a3a3",box:e.actionGuide._1}];g()})(),{label:"OUTPUT",color:"#38bdf8",box:{x:t.vx,y:t.vy,w:t.vw,h:t.vh}},{label:"RAW CAMERA FRAME",color:"#2563eb",box:e.camera}],HG=t=>e=>n=>r=>o=>{const i=sr(t);return()=>(i(),Ls(t)(1.5)(),Ny(t)([6,4])(),mf(t)("bold 10px monospace")(),Ai(a=>{const s={x:(a.box.x-r.vx)*e/r.vw,y:(a.box.y-r.vy)*n/r.vh,width:a.box.w*e/r.vw,height:a.box.h*n/r.vh},u=ff(t)(a.color);return()=>(u(),_f(t)(a.color)(),ky(t)(s)(),yf(t)(a.label)(s.x+4)(s.y+12)())})(s2(r)(o))(),ur(t)())},$G=t=>e=>n=>'<g data-mg-camera-bounds="1" pointer-events="none">'+yG(r=>'<rect x="'+bn(r.box.x)+'" y="'+bn(r.box.y)+'" width="'+bn(r.box.w)+'" height="'+bn(r.box.h)+'" fill="none" stroke="'+r.color+'" stroke-width="1.5" stroke-dasharray="6 4" vector-effect="non-scaling-stroke"/><text x="'+bn(r.box.x+4*t)+'" y="'+bn(r.box.y+12*t)+'" fill="'+r.color+'" stroke="#09090b" stroke-width="'+bn(3*t)+'" paint-order="stroke" font-family="monospace" font-size="'+bn(10*t)+'">'+r.label+"</text>")(s2(e)(n))+"</g>",qG=t=>e=>n=>{const r=n.levels.length-1|0;if(r>=0&&r<n.levels.length){const o=zT(t.cameraConfig)(n.levels[r].segment)(e);return w("Just",{action:o.action,actionText:o.actionText,actionGuide:o.actionGuide,camera:gr(n.rootLayout)(n.camera),level:o.level,visible:o.visible})}return y},VG=t=>e=>{if(e.tag==="FixedSize"){const n=e._1<=0||e._2<=0?y:w("Just",e._1/e._2);return()=>n}if(e.tag==="AutoSize"){const n=ms(t);return()=>{const r=n();return r.width<=0||r.height<=0?y:w("Just",r.width/r.height)}}g()},xs=t=>e=>n=>r=>o=>i=>a=>s=>u=>c=>_=>f=>()=>{const l=t2(),d=_.value,h=c.value,m=d===0?0:l-d,p=h+m;_.value=l,c.value=p;const x=(()=>{if(n.tag==="FixedSize")return{w:n._1,h:n._2};if(n.tag==="AutoSize"){const S=ms(t)();return{w:S.width<=0?200:S.width,h:S.height<=0?180:S.height}}g()})();if(x.w<200||x.h<180){if(sG(t)(x.w)(x.h)(200)(180)(),e==="CanvasRenderer")return Tc(ps(t),0);if(e==="SvgRenderer")return;g()}const J=a.value,T=(()=>{if(J.tag==="Just"&&J._1.w===x.w&&J._1.h===x.h)return J._1.schedule;const S={widthPx:x.w,heightPx:x.h},b=S.heightPx===i.cameraViewport.heightPx&&S.widthPx===i.cameraViewport.widthPx?i:GS(S)(i);return a.value=w("Just",{w:x.w,h:x.h,schedule:b}),b})(),N=Nc(f)(T.totalDuration),k=vG(p)(AN(T)(N)),C=u.value,P=(()=>{if(C.tag==="Nothing")return k.camera;if(C.tag==="Just")return Hx(i.cameraConfig.cameraDecay)(m)(C._1)(k.camera);g()})();u.value=w("Just",P);const G={...k,camera:P,levels:Y(i2(P))(k.levels)};bG(t)(x)(G)();const R=Xm("data-mg-debug-camera")(t)(),U=(()=>{if(R.tag==="Nothing")return!1;if(R.tag==="Just")return!0;g()})()?qG(T)(N)(G):y;if(e==="CanvasRenderer"){const S=ps(t),b=_1({width:0,height:0})(G),I=(()=>{if(n.tag==="FixedSize")return{w:n._1,h:n._2};if(n.tag==="AutoSize"){const V=ms(t)();return{w:V.width,h:V.height<=0?b.vw<=0?V.width:V.width*b.vh/b.vw:V.height}}g()})(),H=jm(),Q=I.w*H,q=I.h*H,$=sf(S)(),A=uf(S)(),F=cf(S)(Q);$!==Q&&F();const M=gf(S)(q);A!==q&&M(),n.tag==="FixedSize"?(xc(t,"width",ue(he(Un(I.w)))+"px"),xc(t,"height",ue(he(Un(I.h)))+"px")):n.tag==="AutoSize"||g();const W=af(S)();sr(W)(),Ca(W)({scaleX:H,scaleY:H})();const D=s.value,X=H5(r)(o)(W)({width:I.w,height:I.h})(G)(m)(D)();return s.value=X,ur(W)(),U.tag==="Just"?(sr(W)(),Ca(W)({scaleX:H,scaleY:H})(),HG(W)(I.w)(I.h)(_1({width:I.w,height:I.h})(G))(U._1)(),ur(W)()):U.tag==="Nothing"||g(),Tc(S,yN(G.portalState))}if(e==="SvgRenderer"){const S=s.value,b=VG(t)(n)(),I=bS(b)(r)(o)(G)(m)(S);s.value=I.springs,vn("viewBox")(I.parts.viewBox)(t)(),vn("preserveAspectRatio")("xMidYMid meet")(t)(),n.tag==="FixedSize"?(vn("width")(ue(he(Un(n._1))))(t)(),vn("height")(ue(he(Un(n._2))))(t)()):n.tag==="AutoSize"||g();const H=$G(I.parts.vw/Ro(1)(x.w))({vx:I.parts.vx,vy:I.parts.vy,vw:I.parts.vw,vh:I.parts.vh});return ys((()=>{if(U.tag==="Nothing")return I.parts.body+"";if(U.tag==="Just")return I.parts.body+H(U._1);g()})(),t)}g()},UG=t=>{const e=_m(t)(rm)._1;if(e.tag==="Left")return Dt("Left",e._1.msg);if(e.tag==="Right")return Dt("Right",e._1);g()},u2=t=>{const e=iP(t);if(e.tag==="Left")return Dt("Left",e._1);if(e.tag==="Right"){if(e._1.mode==="SequenceSurface"){const r=CG(e._1);if(r.tag==="Left")return Dt("Left",r._1);if(r.tag==="Right")return Dt("Right",n2("LoadedSequence",r._1));g()}const n=UG(e._1);if(n.tag==="Left")return Dt("Left",n._1);if(n.tag==="Right")return Dt("Right",n2("LoadedAnimation",n._1))}g()},KG=t=>{const e=u2(t);if(e.tag==="Left")return e._1;if(e.tag==="Right")return va;g()},c2=t=>e=>n=>r=>{const o=n+1e-4>=e?_t(a=>a.time>e+1e-4&&a.time<=n+1e-4,t):[..._t(a=>a.time>e+1e-4,t),..._t(a=>a.time<=n+1e-4,t)],i=n<=e+1e-4?re(_t(a=>a.time<e-1e-4&&a.time>=n-1e-4,t)):[...re(_t(a=>a.time<e-1e-4,t)),...re(_t(a=>a.time>=n-1e-4,t))];return(()=>{const a=n-e;return a<0?-a<=1e-4:a<=1e-4})()?[]:r>=0?o:i},YG=t=>e=>n=>r=>te(o=>oe(i=>i===o.kind,e)&&(o.time>n+1e-4||(()=>{const i=o.time-n;return(i<0?-i<=1e-4:i<=1e-4)&&o.index>r})()))(t),XG=t=>e=>n=>r=>{const o=_t(a=>oe(s=>s===a.kind,e)&&(a.time<n-1e-4||(()=>{const s=a.time-n;return(s<0?-s<=1e-4:s<=1e-4)&&a.index<r})()),t),i=o.length-1|0;return i>=0&&i<o.length?w("Just",o[i]):y},M1=t=>e=>n=>{const r=An(e,y,Xt);if(r.tag==="Just"){const o=An(r._1.speed,y,Xt);if(o.tag==="Just"){const i=Ro(1e-4)(o._1<0?-o._1:o._1);return()=>t.value=i}if(o.tag==="Nothing"){const i=An(r._1.duration,y,Xt);if(i.tag==="Just"&&n.tag==="Just"){const a=n._1/i._1,s=Ro(1e-4)(a<0?-a:a);if(i._1>0)return()=>t.value=s}return()=>{}}g()}if(r.tag==="Nothing")return()=>{};g()},ZG=t=>e=>n=>r=>{const o=r.time-e,i=o<0?-o<=1e-4:o<=1e-4,a=r.time<e-1e-4||i&&r.index<n,s=a?-1:1,u=r.time>e+1e-4||i&&r.index>n,c=An(t,y,Xt);if(c.tag==="Just"){const _=An(c._1.direction,y,Xt);if(_.tag==="Just"){if(_._1==="forward")return i||u?w("Just",1):y;if(_._1==="backward"||_._1==="reverse")return i||a?w("Just",-1):y}return w("Just",s)}if(c.tag==="Nothing")return w("Just",s);g()},jG=t=>e=>n=>r=>o=>i=>()=>{const a={value:1};let s=1,u=!0,c=y,_=-1,f=!0,l=!1,d=0,h=0;const m={value:O},p={value:y},x={value:0},J={value:0},T={value:y};let N=!1,k=()=>{},C=[],P=[],G=[];if(xs(t)(n)(r)(o)(i)(e)(T)(m)(p)(x)(J)(0)(),n==="CanvasRenderer"&&e.dives.length!==0){const D=ps(t);Tc(D,.01),Tc(D,0)}const R=D=>{const X=D.index;return()=>{_=X;const V=P;return Ai(K=>K(D))(V)()}},U=D=>()=>{const X=C,V=f,K={time:D,keyframe:Q1(e)(D),playing:V};return Ai(Z=>Z(K))(X)()},S=()=>(f=!1,c=y,U(d)()),b=D=>()=>(d=D,xs(t)(n)(r)(o)(i)(e)(T)(m)(p)(x)(J)(D)(),U(D)()),I=D=>{const X=Ro(0)(Nc(e.totalDuration)(D));return()=>(d=X,_=WG(e.cues)(X),h=0,c=y,p.value=y,xs(t)(n)(r)(o)(i)(e)(T)(m)(p)(x)(J)(X)(),U(X)())},H=(D,X,V,K,Z)=>()=>{f=!1,c=y;const tt=d;U(tt)();const et={reason:D,direction:X<0?"backward":"forward",targetId:V,targetStep:K,reached:Z,time:tt},ft=G;return Ai(Nt=>Nt(et))(ft)()},Q=kG(e),q=()=>{if(!N){if(l=!1,f){const D=t2(),X=h;h=D;const V=a.value,K=s,Z=u,tt=c,et=d,ft=X===0?et+0*V*K:et+(D-X)*V*K;if(tt.tag==="Just"){const Nt=K>=0?tt._1.cue.time>=et-1e-4&&tt._1.cue.time<=ft+1e-4:tt._1.cue.time<=et+1e-4&&tt._1.cue.time>=ft-1e-4,dt=Nt?tt._1.cue.time:Ro(0)(Nc(e.totalDuration)(ft));(K>=0?dt+1e-4<et:dt>et+1e-4)&&(p.value=y),b(dt)(),Ai(bt=>R(bt))(c2(e.cues)(et)(dt)(K))();const mt=H("target",K,tt._1.targetId,tt._1.targetStep,!0);Nt&&mt(),Nt||$()}else if(tt.tag==="Nothing"){const Nt=K>=0?e.totalDuration:0,dt=!Z&&(K>=0?Nt>=et-1e-4&&Nt<=ft+1e-4:Nt<=et+1e-4&&Nt>=ft-1e-4),mt=Z?wG(ft)(e.totalDuration+.8):Ro(0)(Nc(e.totalDuration)(ft));(K>=0?mt+1e-4<et:mt>et+1e-4)&&(p.value=y),b(mt)(),Ai(Ht=>R(Ht))(c2(e.cues)(et)(mt)(K))();const bt=H("boundary",K,"","",!0);dt&&bt(),dt||$()}else g()}if(Q&&!f){const D=d;return xs(t)(n)(r)(o)(i)(e)(T)(m)(p)(x)(J)(D)(),$()}}},$=()=>{if(!N&&!l){l=!0;const D=R1();D1(q)(D)()}},A=()=>(h=0,f=!0,$()),F=()=>(s=1,u=!0,c=y,A(),U(d)()),M=(D,X)=>()=>{const V=d;return s=D,u=!1,c=y,M1(a)(X)(w("Just",D>=0?e.totalDuration-V:V))(),A()},W=(D,X)=>()=>{const V=d,K=_,Z=ZG(X)(V)(K)(D);if(Z.tag==="Nothing")return M(a2(X)(1),X)();if(Z.tag==="Just"){const tt=D.time-V,et=tt<0?-tt:tt;return s=Z._1,u=!1,c=w("Just",{cue:D,direction:Z._1,targetId:D.id,targetStep:D.name}),M1(a)(X)(w("Just",et))(),et<=1e-4?(I(D.time)(),R(D)(),H("target",Z._1,D.id,D.name,!0)()):A()}g()};return k=Zm(t)(()=>{if(!N){const D=d;return xs(t)(n)(r)(o)(i)(e)(T)(m)(p)(x)(J)(D)(),U(D)()}})(),A(),{play:F,playWith:D=>{const X=a2(D)(1);return()=>(s=X,u=DG(D)(!1),c=y,M1(a)(D)(y)(),A(),U(d)())},pause:S,toggle:()=>f?S():F(),seek:D=>I(D),seekCue:D=>{const X=te(V=>V.id===D)(e.cues);if(X.tag==="Nothing")return()=>{};if(X.tag==="Just"){const V=X._1,K=I(V.time);return()=>(K(),R(V)())}g()},seekStep:D=>{const X=te(V=>V.kind==="step"&&V.name===D)(e.cues);if(X.tag==="Nothing")return()=>{};if(X.tag==="Just"){const V=X._1,K=I(V.time);return()=>(K(),R(V)())}g()},playToCue:D=>X=>{const V=te(K=>K.id===D)(e.cues);if(V.tag==="Nothing")return()=>{};if(V.tag==="Just")return W(V._1,X);g()},playToStep:D=>X=>{const V=te(K=>K.kind==="step"&&K.name===D)(e.cues);if(V.tag==="Nothing")return()=>{};if(V.tag==="Just")return W(V._1,X);g()},playNext:D=>()=>{const X=d,V=_,K=YG(e.cues)(o2(D)(["step"]))(X)(V);if(K.tag==="Nothing")return M(1,D)();if(K.tag==="Just")return W(K._1,D)();g()},playPrevious:D=>()=>{const X=d,V=_,K=XG(e.cues)(o2(D)(["step"]))(X)(V);if(K.tag==="Nothing")return M(-1,D)();if(K.tag==="Just")return W(K._1,OG(D)(-1))();g()},setSpeed:D=>{const X=Ro(1e-4)(D<0?-D:D);return()=>a.value=X},currentTime:()=>d,currentKeyframe:()=>{const D=d;return Q1(e)(D)},isPlaying:()=>f,duration:e.totalDuration,cues:e.cues,steps:_t(D=>D.kind==="step",e.cues),subscribe:D=>()=>{C=Et(C)(D);const X=d,V=f;D({time:X,keyframe:Q1(e)(X),playing:V})();const K=Ta(Z=>!Jc(Z)(D));return()=>{C=K(C)}},subscribeCue:D=>()=>{P=Et(P)(D);const X=Ta(V=>!Jc(V)(D));return()=>{P=X(P)}},subscribeComplete:D=>()=>{G=Et(G)(D);const X=Ta(V=>!Jc(V)(D));return()=>{G=X(G)}},destroy:()=>{if(N=!0,k(),n==="CanvasRenderer")return lG(ps(t));n!=="SvgRenderer"&&g()}}},tA=t=>e=>{const n=Ym(t);return()=>{const r=n();Km(r)("markgraf-embed")();const o=TG(t)();return ys(NG,t),Wr(t)("stage")(i=>{const a=MG(i)(z1)(e);return()=>{const s=R1();D1(()=>{const u=a();if(u.tag==="Left")return of("[markgraf] precompute failed")();if(u.tag==="Right"){const c=jG(i)(u._1.schedule)(xG)(z1)(o)(fS)();return IG(t)(u._1.schedule)(c)()}g()})(s)()}})()}},g2=t=>e=>{const n=u2(e);if(n.tag==="Left")return of("[markgraf] parse failed: "+n._1);if(n.tag==="Right"){if(n._1.tag==="LoadedAnimation")return tA(t)(n._1._1);if(n._1.tag==="LoadedSequence")return RG(t)(n._1._1)}g()},eA=t=>{const e=t.getAttribute("data-markgraf-src-b64");if(e)try{return decodeURIComponent(escape(atob(e)))}catch{return atob(e)}return t.getAttribute("data-markgraf-src")||t.textContent||""};let Hr=null;const vc=t=>t.querySelector('[data-mg="play"]')?.dataset.mgPlaying==="1",nA=t=>{const e=t.querySelector('[data-mg="play"]');if(!e)return;e.addEventListener("click",()=>{queueMicrotask(()=>{vc(t)?(Hr&&Hr!==t&&vc(Hr)&&Hr.querySelector('[data-mg="play"]').click(),Hr=t):Hr===t&&(Hr=null)})});const n=r=>{r.preventDefault(),e.click()};t.querySelector('[data-mg="stage"]')?.addEventListener("click",n)},rA=t=>{if(t.dataset.markgrafMounted==="1")return;t.dataset.markgrafMounted="1";const e=eA(t),n=t.dataset.markgrafPaused==="true";t.textContent="",g2(t)(e)(),t.querySelector('[data-mg="play"]')&&(n?vc(t)&&t.querySelector('[data-mg="play"]').click():Hr===null?Hr=t:vc(t)&&t.querySelector('[data-mg="play"]').click(),nA(t))},bc=(t=document)=>{t.querySelectorAll("[data-markgraf]").forEach(rA)},_2=()=>{document.addEventListener("keydown",t=>{if(t.code!=="Space"&&t.key!==" ")return;const e=t.target,n=e&&e.closest?.("[data-markgraf]");if(!n){const o=e?.tagName,i=(e?.type||"").toLowerCase();if(e?.isContentEditable||o==="TEXTAREA"||o==="SELECT"||o==="INPUT"&&!["range","checkbox","radio","button","submit","reset"].includes(i))return}const r=n||Hr||document.querySelector("[data-markgraf]");r&&(t.preventDefault(),r.querySelector('[data-mg="play"]')?.click())})};if(typeof window<"u"){const t=e=>{const n=KG(e);return n==null?{ok:!0}:{ok:!1,error:n}};window.markgraf={mount:(e,n)=>g2(e)(n)(),mountAll:bc,tryParse:t},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{bc(),_2()}):(bc(),_2())}return Cc.mountAll=bc,Object.defineProperty(Cc,Symbol.toStringTag,{value:"Module"}),Cc})({});