semiotic 3.10.2 → 3.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -26
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/behaviorContracts.cjs +15 -5
- package/ai/behaviorContracts.d.cts +3 -0
- package/ai/cli.js +17 -166
- package/ai/componentMetadata.cjs +68 -15
- package/ai/componentMetadata.d.cts +3 -0
- package/ai/dist/diagnose-operation.js +3 -0
- package/ai/dist/mcp-server.js +59 -59
- package/ai/reference.md +6 -6
- package/ai/schema.json +1 -1
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +2 -2
- package/ai/task-packets/compare-category-totals.json +7 -7
- package/ai/task-packets/compare-category-totals.md +3 -3
- package/ai/task-packets/correct-published-chart.json +7 -7
- package/ai/task-packets/correct-published-chart.md +3 -3
- package/ai/task-packets/index.json +6 -6
- package/ai/task-packets/update-live-chart.json +7 -7
- package/ai/task-packets/update-live-chart.md +3 -3
- package/dist/c-2MHSD3TN.min.js +209 -0
- package/dist/{c-PZ3NEGNG.min.js → c-6XGGN5OS.min.js} +1 -1
- package/dist/{c-FDUQDCBC.min.js → c-CO4NDAD6.min.js} +23 -23
- package/dist/c-EK6XI2U7.min.js +26 -0
- package/dist/c-FMCUQ6JX.min.js +1 -0
- package/dist/{c-C4KIXUWU.min.js → c-GK263BF4.min.js} +1 -1
- package/dist/{c-TTKWXGAI.min.js → c-HNHKIMIV.min.js} +3 -3
- package/dist/c-IJCZGUG6.min.js +31 -0
- package/dist/{c-4XLHPQTP.min.js → c-JBWPJNTJ.min.js} +1 -1
- package/dist/{c-4MD53L2J.min.js → c-JC76YAHB.min.js} +28 -28
- package/dist/{c-VXIYF7V2.min.js → c-JOPGDP6N.min.js} +1 -1
- package/dist/c-KWP4QTCM.min.js +4 -0
- package/dist/c-LRV7PO45.min.js +393 -0
- package/dist/c-LVHJJUOF.min.js +1 -0
- package/dist/c-M43PK7K4.min.js +1 -0
- package/dist/c-NUBZ63VU.min.js +1 -0
- package/dist/{c-7ASK4WBF.min.js → c-PITYSOPK.min.js} +1 -1
- package/dist/{c-2TW5H5PD.min.js → c-QPO24R7Q.min.js} +1 -1
- package/dist/{c-SG2Y7EBY.min.js → c-RWHLEUX6.min.js} +1 -1
- package/dist/{c-4JKDJUYD.min.js → c-S746GRV4.min.js} +1 -1
- package/dist/{c-KGROWFT2.min.js → c-SAP5KY6R.min.js} +2 -2
- package/dist/c-UMGHCBH5.min.js +114 -0
- package/dist/c-UQBWSYKI.min.js +41 -0
- package/dist/{c-6ZU3QVLB.min.js → c-VEMCBQZZ.min.js} +33 -33
- package/dist/{c-IPYGNVN6.min.js → c-WD2RL76M.min.js} +45 -45
- package/dist/{c-PQOZPM4G.min.js → c-YL7HJL5J.min.js} +1 -1
- package/dist/c-Z6GRGS53.min.js +1 -0
- package/dist/components/CategoryColors.d.ts +7 -0
- package/dist/components/LinkedCharts.d.ts +2 -1
- package/dist/components/ai/chartClinic.d.ts +1 -1
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +2 -2
- package/dist/components/charts/shared/{chartDefinitionPilot.d.ts → chartDefinition.d.ts} +30 -34
- package/dist/components/charts/shared/chartDefinitions.d.ts +10 -0
- package/dist/components/charts/shared/chartDefinitionsNetwork.d.ts +17 -0
- package/dist/components/charts/shared/chartDefinitionsOrdinal.d.ts +23 -0
- package/dist/components/charts/shared/chartDefinitionsPhysics.d.ts +17 -0
- package/dist/components/charts/shared/chartDefinitionsRealtime.d.ts +12 -0
- package/dist/components/charts/shared/chartDefinitionsXY.d.ts +26 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -1
- package/dist/components/data/transforms.d.ts +1 -0
- package/dist/components/server/serverChartConfigs.d.ts +36 -36
- package/dist/components/server/serverChartConfigsNetwork.generated.d.ts +17 -0
- package/dist/components/server/serverChartConfigsOrdinal.generated.d.ts +23 -0
- package/dist/components/server/serverChartConfigsPhysics.generated.d.ts +17 -0
- package/dist/components/server/serverChartConfigsRealtime.generated.d.ts +13 -0
- package/dist/components/server/serverChartConfigsXY.generated.d.ts +22 -0
- package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +5 -0
- package/dist/geo.min.js +3 -3
- package/dist/geo.module.min.js +10 -10
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics-matter.min.js +4 -1
- package/dist/physics-matter.module.min.js +1 -1
- package/dist/physics-rapier.min.js +4 -1
- package/dist/physics-rapier.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/semiotic-ai-core.min.js +3 -3
- package/dist/semiotic-ai-core.module.min.js +3 -3
- package/dist/semiotic-ai.module.min.js +7 -7
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-atlas-selection.module.min.js +1 -1
- package/dist/semiotic-client-cjs-shared.min.js +903 -902
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +3 -3
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +3 -3
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +13 -13
- package/dist/semiotic-server-edge-node.module.min.js +393 -391
- package/dist/semiotic-server-edge.min.js +393 -391
- package/dist/semiotic-server-edge.module.min.js +374 -372
- package/dist/semiotic-server-node.min.js +393 -391
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic.module.min.js +10 -10
- package/dist/server.min.js +393 -391
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +12 -8
- package/dist/c-3OFVBWQY.min.js +0 -1
- package/dist/c-6IVBV5NO.min.js +0 -1
- package/dist/c-72CBVNYX.min.js +0 -209
- package/dist/c-7LY46QUI.min.js +0 -41
- package/dist/c-AKLBQMQF.min.js +0 -391
- package/dist/c-F2GGJB2S.min.js +0 -31
- package/dist/c-G53AVC42.min.js +0 -113
- package/dist/c-HQ27AHMC.min.js +0 -1
- package/dist/c-IHWZ2C6D.min.js +0 -26
- package/dist/c-MOP2NGLH.min.js +0 -1
- package/dist/c-PKY4JFY5.min.js +0 -1
- package/dist/c-UBHICVSC.min.js +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function e(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let r=Di.get(e);if(r){let e=r.get(t);if(e)return e}else r=/* @__PURE__ */new Map,Di.set(e,r);let a=new Proxy(e,{get(e,r,a){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){let e=`${t}:${r}`;Ai.has(e)||(Ai.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,a)}});return r.set(t,a),a}function t(e,t,r){let a=[];for(let i of t){let t=Na(i.source),n=Na(i.target),o=null;if(t===e?o=n:n===e&&(o=t),o){let e=r.get(o);e&&(0!==e.x||0!==e.y)&&a.push({x:e.x,y:e.y})}}return a}function r(e,t,r=2,a=.6){let i=[],n=n=>{let o=a*Math.max(n,.2);for(let a of i){let i=a.x??e[0]/2,n=a.y??e[1]/2,l=a.vx??0,s=a.vy??0,c=t(a)+r,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),f=Math.min(e[1]/2,c),h=Math.max(e[1]/2,e[1]-c),g=i+l,m=n+s;u>g?a.vx=l+(u-g)*o:g>d&&(a.vx=l+(d-g)*o),f>m?a.vy=s+(f-m)*o:m>h&&(a.vy=s+(h-m)*o)}};return n.initialize=e=>{i=e},n}function a(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function i(e){return e.data&&"object"==typeof e.data?e.data:e}function n(e,t,r){if(t)return r?.selectedStyle&&Object.assign(e,r.selectedStyle),e;let a=r?.unselectedOpacity??ni;return e.opacity=a,e.fillOpacity=a,e.strokeOpacity=a,r?.unselectedStyle&&Object.assign(e,r.unselectedStyle),e}function o(e,t,r){if(e)return t?a=>{let o={...e(a)};return t.isActive?n(o,t.predicate(i(a)),r):o}:e}function l(e,t,r){if(e)return t?a=>{let o={...e(a)};if(!t.isActive)return o;let l=i(a),s="object"==typeof a.source?i(a.source):null,c="object"==typeof a.target?i(a.target):null;return n(o,s||c?!!s&&t.predicate(s)||!!c&&t.predicate(c):t.predicate(l),r)}:e}function s(e,t){if(!e)return[];let r=[],a=e=>{r.push(e);let i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(a)};return a(e),r}function c(e,t,r,a){if(e&&e.length>0)return e;let i=/* @__PURE__ */new Set;return t.forEach(e=>{let t="function"==typeof r?r(e):e[r],n="function"==typeof a?a(e):e[a];i.add(t),i.add(n)}),Array.from(i).map(e=>({id:e}))}function u(e){return"function"==typeof e?e:t=>t[e]||1}function d({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:a,edgeOpacity:i,baseStyle:n={}}){return o=>{let l={fillOpacity:i,...n};if("function"==typeof e)l.fill=e(o);else if("source"===e){let e="object"==typeof o.source?o.source:null;t&&e?l.fill=mi(e.data||e,t,r):e&&(l.fill=a(e,e.index).fill)}else if("target"===e){let e="object"==typeof o.target?o.target:null;t&&e?l.fill=mi(e.data||e,t,r):e&&(l.fill=a(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*i);return l}}function f(e){let{nodes:t,edges:r,inferNodes:a=!0,sourceAccessor:i="source",targetAccessor:n="target",colorBy:o,colorScheme:l,showLegend:s,legendPosition:u,legendInteraction:d,frameLegend:f,selection:h,linkedHover:g,onObservation:m,onClick:p,mobileInteraction:y,mobileSemantics:b,chartType:v,chartId:k,marginDefaults:x,userMargin:S,width:w,height:M,hasTitle:L,loading:P,loadingContent:T,emptyContent:A,emptyDataKey:D="edges"}=e,I=Ei(()=>ri(r),[r]),C=Ei(()=>ri(t),[t]),E=void 0===t&&void 0===r,[O,N]=Oi([]),B=Ci(e=>{N(t=>t.length===e.length&&t.every((t,r)=>t===e[r])?t:e)},[]),$=ii(P,w,M,T),H=$?null:ai("nodes"===D?void 0===t?void 0:C:void 0===r?void 0:I,w,M,A),R=Ei(()=>a?c(C,I,i,n):C,[a,C,I,i,n]),F=Ya(),W=Ei(()=>Array.isArray(l)&&l.length>0?l:[...hi(l,F,fi)],[l,F]),_=Ei(()=>_a(R,o),[R,o]),z=Ei(()=>E&&O.length>0?O:_,[E,O,_]),j=Ei(()=>E?z.map(e=>({[Ni]:e})):R,[E,z,R]),X=Ga(j,E&&o?Ni:o,l),Y=ja(d,o,z),{legend:q,margin:G,legendPosition:U,legendMarginReserved:V}=za({data:R,colorBy:o,colorScale:X,showLegend:s,legendPosition:u,userMargin:S,defaults:x,categories:z,chartWidth:w,chartHeight:M,frameLegend:f,hasTitle:L}),K=Ei(()=>{let e={};return q&&V&&(e.__legendMarginReservedFor=q),E&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=B),e},[q,V,E,o,B]),Q=Ei(()=>li(y,{width:w,mobileSemantics:b}),[y,w,b]),Z=Ua({selection:h,linkedHover:g,fallbackFields:o?["string"==typeof o?o:""]:[],unwrapData:!0,onObservation:m,onClick:p,mobileInteraction:Q,chartType:v,chartId:k}),{customHoverBehavior:J,customClickBehavior:ee,activeSelectionHook:te,hoverSelectionHook:re,crosshairSourceId:ae}=Z,ie=Ei(()=>re||(Y.legendSelectionHook?Y.legendSelectionHook:te),[re,Y.legendSelectionHook,te]),ne=Ta(h);return{safeNodes:R,safeEdges:I,colorScale:X,effectivePalette:W,themeCategorical:F,allCategories:z,legendState:Y,legend:q,margin:G,legendPosition:U,legendBehaviorProps:K,mobileInteraction:Q,customHoverBehavior:J,customClickBehavior:ee,activeSelectionHook:te,hoverSelectionHook:re,effectiveSelectionHook:ie,resolvedSelection:ne,crosshairSourceId:ae,loadingEl:$,emptyEl:H}}function h(e){return e?"function"==typeof e?e:t=>t[e]??1:e=>e.value??1}function g(e,t,r){let a=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!a)return e;let i=[],n=0;for(;a.length>n;){let e=a[n];if("M"===e||"L"===e||"C"===e||"Q"===e)for(i.push(e),n++;a.length>n&&!isNaN(Number(a[n]));)i.push(Number(a[n])+t+""),n++,a.length>n&&!isNaN(Number(a[n]))&&(i.push(Number(a[n])+r+""),n++);else if("A"===e)for(i.push(e),n++;a.length>n&&!isNaN(Number(a[n]));)i.push(a[n++]),a.length>n&&i.push(a[n++]),a.length>n&&i.push(a[n++]),a.length>n&&i.push(a[n++]),a.length>n&&i.push(a[n++]),a.length>n&&(i.push(Number(a[n])+t+""),n++),a.length>n&&(i.push(Number(a[n])+r+""),n++);else"Z"===e||"z"===e?(i.push(e),n++):(i.push(a[n]),n++)}return i.join(" ")}function m(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function p(e){function t(t){var r=[t],c=[t];for(a[t]=i[t]=d,n[t]=!0,d+=1;c.length>0;){var u=e[t=c[c.length-1]];if(u.length>o[t]){for(var g=o[t];u.length>g;++g){var m=u[g];if(0>a[m]){a[m]=i[m]=d,n[m]=!0,d+=1,r.push(m),c.push(m);break}n[m]&&(i[t]=0|Math.min(i[t],i[m])),l[m]>=0&&s[t].push(l[m])}o[t]=g}else{if(i[t]===a[t]){var p=[],y=[],b=0;for(g=r.length-1;g>=0;--g){var v=r[g];if(n[v]=!1,p.push(v),y.push(s[v]),b+=s[v].length,l[v]=f.length,v===t){r.length=g;break}}f.push(p);var k=Array(b);for(g=0;y.length>g;g++)for(var x=0;y[g].length>x;x++)k[--b]=y[g][x];h.push(k)}c.pop()}}}for(var r=e.length,a=Array(r),i=Array(r),n=Array(r),o=Array(r),l=Array(r),s=Array(r),c=0;r>c;++c)a[c]=-1,i[c]=0,n[c]=!1,o[c]=0,l[c]=-1,s[c]=[];var u,d=0,f=[],h=[];for(c=0;r>c;++c)0>a[c]&&t(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),u=[g[0]];for(var m=1;g.length>m;m++)g[m]!==g[m-1]&&u.push(g[m]);h[c]=u}}return{components:f,adjacencyList:h}}function y(e,t){function r(e){u[e]=!1,d.hasOwnProperty(e)&&Object.keys(d[e]).forEach(function(t){delete d[e][t],u[t]&&r(t)})}function a(e){var t,n,o=!1;for(c.push(e),u[e]=!0,t=0;f[e].length>t;t++)(n=f[e][t])===l?(i(l,c),o=!0):u[n]||(o=a(n));if(o)r(e);else for(t=0;f[e].length>t;t++){var s=d[n=f[e][t]];s||(d[n]=s={}),s[n]=!0}return c.pop(),o}function i(e,r){var a=[].concat(r).concat(e);t?t(a):s.push(a)}function n(t){for(var r=0;e.length>r;r++)(t>r||!e[r])&&(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}function o(t){n(t);for(var r,a=p(e).components.filter(function(e){return e.length>1}),i=1/0,o=0;a.length>o;o++)for(var l=0;a[o].length>l;l++)i>a[o][l]&&(i=a[o][l],r=o);var s=a[r];return!!s&&{leastVertex:i,adjList:e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})})}}var l,s=[],c=[],u=[],d={},f=[];l=0;for(var h=e.length;h>l;){var g=o(l);if(l=g.leastVertex,f=g.adjList){for(var m=0;f.length>m;m++)for(var y=0;f[m].length>y;y++){var b=f[m][y];u[+b]=!1,d[b]={}}a(l),l+=1}else l=h}if(!t)return s}function b(e){return e.y0-e.y1>0?"up":"down"}function v(e,t){return t(e.source)==t(e.target)}function k(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),!(t>1||r>1)}function x(e){return e.target.x0-e.source.x1}function S(e,t){var r=M(e),a=x(t)/Math.tan(r);return"up"==b(e)?e.y1-a:e.y1+a}function w(e,t){var r=M(e),a=x(t)/Math.tan(r);return"up"==b(e)?e.y1+a:e.y1-a}function M(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function L(e,t){return t(e)}function P(e){return A(e.source)}function T(e){return A(e.target)}function A(e){return(e.y0+e.y1)/2}function D(e){return e.virtual?0:e.value}function I(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!v(e,t)?r+1:r});var a=0;return e.targetLinks.forEach(function(e){a=e.circular&&!v(e,t)?a+1:a}),r+a}function C(e){return e.target.depth}function E(e,t){return e.sourceLinks.length?e.depth:t-1}function O(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function B(e,t){return e.y1-t.y1}function $(e,t){return t.y1-e.y1}function H(e,t){return F(e.source,t.source)||e.index-t.index}function R(e,t){return F(e.target,t.target)||e.index-t.index}function F(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function W(e,t){return _(e)==_(t)?"bottom"==e.circularLinkType?N(e,t):O(e,t):_(t)-_(e)}function _(e){return e.target.column-e.source.column}function z(e,t){let r=e;return r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var a=r.links.filter(function(r){return L(r.source,t)==L(e,t)}),i=a.length;i>1&&a.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!X(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=S(t,e);return e.y1-r}if(t.target.column>e.target.column)return S(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var n=e.y0;a.forEach(function(e){e.y0=n+e.width/2,n+=e.width}),a.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var n=r+1,o=0;i>n;n++)o+=a[n].width;t.y0=e.y1-o-t.width/2}})}),r}function j(e,t){let r=e;return r.nodes.forEach(function(e){var a=r.links.filter(function(r){return L(r.target,t)==L(e,t)}),i=a.length;i>1&&a.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!X(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=w(t,e);return e.y0-r}if(t.source.column>e.source.column)return w(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var n=e.y0;a.forEach(function(e){e.y1=n+e.width/2,n+=e.width}),a.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var n=r+1,o=0;i>n;n++)o+=a[n].width;t.y1=e.y1-o-t.width/2}})}),r}function X(e,t){return Y(e)==Y(t)}function Y(e){return e.y0-e.y1>0?"up":"down"}function q(e){var t=e.source.x1,r=e.y0,a=e.target.x0,i=e.y1,n=(t+a)/2;return"M"+t+","+r+"C"+n+","+r+" "+n+","+i+" "+a+","+i}function G(e,t,r,a,i){let n=e;var o=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,o))});var l=Ki(n.links,function(e){return e.source.y0});n.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=n.links.filter(function(e){return e.circular});return s.sort(function(e,t){return t.value-e.value}),s.forEach(function(e,t){e._circularStub=t>=4}),U(n.links.filter(function(e){return"top"==e.circularLinkType}),t,r),U(n.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),n.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+a,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,v(e,t)&&k(e))e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var o=e.source.column,s=e.circularLinkType,c=n.links.filter(function(e){return e.source.column==o&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?N:O);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2+i*r+u),u+=t._circularWidth||t.width}),o=e.target.column,(c=n.links.filter(function(e){return e.target.column==o&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?$:B),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2+i*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(n.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?K(e):q(e)}),n}function U(e,t,r){e.sort(W);var a=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var n=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(v(e,t)&&k(e))e.circularPathData.verticalBuffer=n+e._circularWidth/2;else{for(var o=0;a.length>o;o++){var l=a[o];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&V(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;n=s>n?s:n}}e.circularPathData.verticalBuffer=n+e._circularWidth/2}}),e}function V(e,t){return!(t.target.column>e.source.column||e.target.column>t.source.column)}function K(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}function Q(e){return function(){return e}}function Z(e){return e.index}function J(e){return e.nodes}function ee(e){return e.links}function te(e,t){var r=/* @__PURE__ */new Map;return tn(e,t).forEach(function(e,t){r.set(t,e[0])}),r}function re(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=te(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var a=e.source,i=e.target;"object"!=typeof a&&(a=e.source=m(r,a)),"object"!=typeof i&&(i=e.target=m(r,i)),a.sourceLinks.push(e),i.targetLinks.push(e)})}function ae(e,t){var r=0;if(null==t){for(var a=[],i=0;e.links.length>i;i++){var n=e.links[i],o=n.source.index,l=n.target.index;a[o]||(a[o]=[]),a[l]||(a[l]=[]),-1===a[o].indexOf(l)&&a[o].push(l)}var s=y(a);s.sort(function(e,t){return e.length-t.length});var c={};for(i=0;s.length>i;i++){var u=s[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,a=e.source.index;t===a||c[a]&&c[a][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}function ie(e,t){var r=0,a=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:a>r?"top":"bottom","top"==i.circularLinkType?r++:a++,e.nodes.forEach(function(e){(L(e,t)==L(i.source,t)||L(e,t)==L(i.target,t))&&(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),v(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function ne(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Ji(e.sourceLinks,D),Ji(e.targetLinks,D)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}function oe(e,t,r){var a,i,n;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var o=0,l=t(e.nodes[0]);e.nodes.forEach(function(e){o=t(e)==l?o:o+1,l=t(e)==l?l:t(e),e.column=o})}for(a=e.nodes,i=[],n=0;a.length;++n,a=i,i=[])a.forEach(function(e){e.depth=n,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(a=e.nodes,i=[],n=0;a.length;++n,a=i,i=[])a.forEach(function(e){e.height=n,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,n):e.column})}function le(e,t,r){var a=rn(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=Qi(a,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Ji(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var n=Zi(e.nodes,function(e){return e.column});e.nodes.forEach(n>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/n),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})}function se(e){var t=0,r=0;return e.targetLinks.forEach(function(e){if(!e.circular){var a=e.value||1;r+=A(e.source)*a,t+=a}}),e.sourceLinks.forEach(function(e){if(!e.circular){var a=e.value||1;r+=A(e.target)*a,t+=a}}),t>0?r/t:NaN}function ce(e,t,r){var a=rn(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});a.forEach(function(i,n){var o=i.length;if(t)i.sort(t);else if(n>0){var l=/* @__PURE__ */new Map;i.forEach(function(e,t){var r=se(e);l.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var r=l.get(e),a=l.get(t),i=r.bc,n=a.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(n)?isNaN(i)?isNaN(n)?r.idx-a.idx:1:-1:i-n})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?I(t,r)-I(e,r):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==a.length-1&&1==o||0==t.depth&&1==o?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==I(t,r)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/o*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-o/2+i,t.y1=t.y0+t.value*e.ky)})})}function ue(e,t,r,a,i,n){function o(t,r){var a=s.length;s.forEach(function(i){var n=i.length,o=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&I(i,r)>0){var s=en(i.sourceLinks,T),c=en(i.targetLinks,P),u=s&&c?(s+c)/2:s||c;if(u){var d=(u-A(i))*t*.3;i.y0+=d,i.y1+=d}}else if(0==o&&1==n)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(o==a-1&&1==n)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=en(i.sourceLinks,T),h=en(i.targetLinks,P),g=((f&&h?(f+h)/2:f||h)-A(i))*t;i.y0+=g,i.y1+=g}})})}function l(){s.forEach(function(r){var n,o,l,s=e.y0,c=r.length;for(r.sort(t||F),l=0;c>l;++l)(o=s-(n=r[l]).y0)>0&&(n.y0+=o,n.y1+=o),s=n.y1+a;if((o=s-a-e.y1)>0)for(s=n.y0-=o,n.y1-=o,l=c-2;l>=0;--l)(o=(n=r[l]).y1+i-s)>0&&(n.y0-=o,n.y1-=o),s=n.y0})}var s=rn(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});l();for(var c=1,u=n;u>0;--u)o(c*=.99,r),l()}function de(e){e.nodes.forEach(function(e){e.sourceLinks.sort(R),e.targetLinks.sort(H)}),e.nodes.forEach(function(e){var t=e.y0,r=t,a=e.y1,i=a;e.sourceLinks.forEach(function(e){e.circular?(e.y0=a-e.width/2,a-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function fe(e){var t=e.nodes,r=e.links,a=!1,i=!1;if(r.forEach(function(e){"top"==e.circularLinkType?a=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==a||0==i){let a=function(t){return(t-n)/(o-n)*(e.y1-e.y0)+e.y0};var n=Qi(t,function(e){return e.y0}),o=Zi(t,function(e){return e.y1}),l=(e.y1-e.y0)/(o-n);1>l?(t.forEach(function(e){e.y0=a(e.y0),e.y1=a(e.y1)}),r.forEach(function(e){e.y0=a(e.y0),e.y1=a(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,r=a(e.y0)-e.y0;e.y0=a(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}function he(){function e(){var e={nodes:g.apply(null,arguments),links:m.apply(null,arguments)};return t(e),e}function t(e){e.x0=r,e.y0=a,e.x1=i,e.y1=n,e.py=0,re(e,c),ae(e,d),ie(e,c),ne(e),oe(e,d,u);var t=l;if(null!==s){var g=rn(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=Zi(g,function(e){return e.length});m>1&&(t=Math.max(1,(n-a)*s/(m-1)))}le(e,t,o),ce(e,d,c),ue(e,d,c,t,t,f),de(e),G(e,c,h,10,8),ce(e,d,c),ue(e,d,c,t,t,f),de(e),G(e,c,h,10,8),z(e,c),j(e,c),fe(e),G(e,c,h,10,8)}var r=0,a=0,i=1,n=1,o=24,l=8,s=null,c=Z,u=E,d=void 0,f=32,h=2,g=J,m=ee;return e.update=function(e){return de(e),G(e,c,h,10,8),e},e.nodeWidth=function(t){return arguments.length?(o=+t,e):o},e.nodePadding=function(t){return arguments.length?(l=+t,e):l},e.nodePaddingRatio=function(t){return arguments.length?(s=+t,e):s},e.nodes=function(t){return arguments.length?(g="function"==typeof t?t:Q(t),e):g},e.links=function(t){return arguments.length?(m="function"==typeof t?t:Q(t),e):m},e.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:Q(t),e):c},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:Q(t),e):u},e.nodeSort=function(t){return arguments.length?(d=t,e):d},e.iterations=function(t){return arguments.length?(f=+t,e):f},e.circularLinkGap=function(t){return arguments.length?(h=+t,e):h},e.extent=function(t){return arguments.length?(r=+t[0][0],a=+t[0][1],i=+t[1][0],n=+t[1][1],e):[[r,a],[i,n]]},e.size=function(t){return arguments.length?(r=a=0,i=+t[0],n=+t[1],e):[i-r,n-a]},e}function ge(e){let{sx:t,sTop:r,sBot:a,tx:i,tTop:n,tBot:o,cp1X:l,cp2X:s}=e,c=(r+a)/2,u=(n+o)/2;return{pathD:[`M${t},${r}`,`C${l},${r} ${s},${n} ${i},${n}`,`L${i},${o}`,`C${s},${o} ${l},${a} ${t},${a}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:l,y:c},{x:s,y:u},{x:i,y:u}],halfWidth:(a-r)/2}}}function me(e){let t=e.sankeyWidth/2,r=(e._circularWidth??e.sankeyWidth)/2,a=e.circularPathData;if(!a||"down"===e.direction)return null;if(e._circularStub){let r=a.sourceX,i=a.sourceY,n=a.targetX,o=a.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;let l=Math.max(15,Math.min(40,.33*(a.rightFullExtent-r))),s=Math.max(15,Math.min(40,.33*(n-a.leftFullExtent)));return`M${r},${i-t}L${r+l},${i-t}L${r+l},${i+t}L${r},${i+t}ZM${n},${o-t}L${n-s},${o-t}L${n-s},${o+t}L${n},${o+t}Z`}let i=a.sourceX,n=a.sourceY,o=a.targetX,l=a.targetY,s=a.rightFullExtent,c=a.leftFullExtent,u=a.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${n-d*t}L${s},${n-d*t}L${s+r},${n-d*t+d*f}L${s+r},${u+d*r-d*f}L${s+r-f},${u+d*r}L${c-r+f},${u+d*r}L${c-r},${u+d*r-d*f}L${c-r},${l-d*t+d*f}L${c-r+f},${l-d*t}L${o},${l-d*t}L${o},${l+d*t}L${c+r},${l+d*t}L${c+r},${u-d*r}L${s-r},${u-d*r}L${s-r},${n+d*t}L${i},${n+d*t}Z`}function pe(e="static"){return fn[e]??fn.static}function ye(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:hn.has(e.kind)?"fatal":"warn"}function be(e){let t=[],r=[];for(let a of e)"fatal"===ye(a)?t.push(a):r.push(a);return{fatal:t,warnings:r}}function ve(e,t,r,a={}){let i=pe(a.usageMode??"static"),n=[],o=/* @__PURE__ */new Set;for(let t of e)o.has(t.id)&&n.push({kind:"duplicate-node",id:t.id,severity:i.duplicateIds}),o.add(t.id);let l=/* @__PURE__ */new Set,s=Array.isArray(r)&&2===r.length,c=s&&Number.isFinite(r[0])&&Number.isFinite(r[1]);(!s||!c||!c||r[0]>r[1])&&n.push({kind:"invalid-domain"});for(let t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(let e of t)l.has(e.id)&&n.push({kind:"duplicate-edge",id:e.id,severity:i.duplicateIds}),l.add(e.id),o.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&n.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||0>=e.value)&&n.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&n.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function ke(e,t,r="static"){if("strip"!==pe(r).invalidSystemTime)return e;let a=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===a.size?e:e.map(e=>{if(!a.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}function xe(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Se(e){if(!e?.layoutQuality)return[];let t=[],r=e.layoutQuality,a=e.layoutQualityBefore;e.compressedPadding&&t.push({severity:"warning",code:"PROCESS_SANKEY_COMPRESSED_PADDING",message:"Lane gaps were compressed to fit peaks into the plot height.",fix:'Increase height, lower maxValueScale, use packing="reuse", or reduce concurrent peaks.'}),r.transitOcclusion>=gn&&t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_TRANSIT",message:`High transit occlusion (${r.transitOcclusion.toFixed(1)}) — ribbons cross dense intermediate lanes.`,fix:'Try laneOrder="crossing-min+inside-out", packing="reuse", or lanePlacement="hug" with a modest maxValueScale.'}),r.verticalUtilization>=mn&&t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_UTILIZATION",message:`Lane utilization is ${Math.round(100*r.verticalUtilization)}% of plot height.`,fix:"Increase chart height or cap band scale with maxValueScale."});let i=e.crossingsAfter??r.crossings;return null!=i&&i>=pn&&t.push({severity:"warning",code:"PROCESS_SANKEY_RESIDUAL_CROSSINGS",message:`Ordering left ${i} edge-pair crossings`+(a?` (from ${a.crossings})`:"")+".",fix:'Prefer laneOrder="crossing-min" or "crossing-min+inside-out"; check for unavoidable fan-outs.'}),t}function we(e){if(!e?.layoutQuality)return null;let t=e.layoutQuality,r=e.layoutQualityBefore,a=e.crossingsAfter??t.crossings;return[`ProcessSankey layout uses ${e.slots?.length??"?"} packed lane(s).`,null!=a?`Edge-pair crossings ${r?r.crossings+" → ":""}${a}.`:null,`Pixel path length ${r?Math.round(r.pixelLength)+" → ":""}${Math.round(t.pixelLength)}.`,`Transit occlusion ${r?r.transitOcclusion.toFixed(1)+" → ":""}${t.transitOcclusion.toFixed(1)}.`,`Lane utilization ${Math.round(100*t.verticalUtilization)}%.`,e.compressedPadding?"Lane gaps were compressed to fit the plot.":null].filter(Boolean).join(" ")}function Me(e){let t=[],r=e.domain;null==r?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):(!Array.isArray(r)||2!==r.length||!Number.isFinite(Number(r[0]))||!Number.isFinite(Number(r[1])))&&t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});let a=e.edges;if(Array.isArray(a)&&a.length>0){let e=a[0];(null==e.startTime||null==e.endTime)&&t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}let i=e.nodes,n=Array.isArray(i)?i.length:0;return!0===e.showLabels&&n>=24&&t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${n} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),(Array.isArray(a)?a.length:0)>=80&&null==e.layoutExecution&&"off"!==e.packing&&t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Le(e,t,r,a={}){let i=!1!==a.inferOpeningStock,n=[];for(let t of r){let r=Number(t.value);if(!Number.isFinite(r))continue;let a=Number(t.endTime);t.target===e&&Number.isFinite(a)&&n.push({time:a,delta:r});let i=Number(t.startTime);if(t.source===e&&Number.isFinite(i)&&n.push({time:i,delta:-r}),t.target===e&&null!=t.systemOutTime){let e=Number(t.systemOutTime);Number.isFinite(e)&&n.push({time:e,delta:-r})}}n.sort((e,t)=>e.time-t.time||t.delta-e.delta);let o=0,l=0,s=0;for(let e of n)o+=e.delta,l=Math.min(l,o),t>=e.time&&(s+=e.delta);return i?s-l:s}function Pe(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Te(e,t){let r=0,a=e.length-1,i=-1;for(;a>=r;){let n=r+a>>>1;e[n].at>t?a=n-1:(i=n,r=n+1)}return 0>i?{at:t,before:0,after:0}:e[i]}function Ae(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};let r=[],a=[0];for(let i=0;e.length-1>i;i++){let n=e[i],o=e[i+1],l=[.../* @__PURE__ */new Set([...n.map(e=>e.at),...o.map(e=>e.at)])].sort((e,t)=>e-t),s=0;for(let e of l){let t=Te(n,e),r=Te(o,e);s=Math.max(s,t.after+r.before)}r.push(s),a.push(a[a.length-1]+s+t)}return{adjacentClearance:r,positions:a}}function De(e,t,r,a={}){let i=[...e];if(1>=i.length)return i;let n=[...i],o=r(i),l=1,s=Math.max(0,a.passes??6),c=Math.max(1,a.maxEvaluations??1/0);for(let e=0;s>e&&c>l;e++){let e=new Map(i.map((e,t)=>[e,t])),s=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map;for(let r of t){let t=e.get(r.source),a=e.get(r.target);if(null==t||null==a)continue;let i=Number.isFinite(r.weight)&&r.weight>0?r.weight:1;s.set(r.source,(s.get(r.source)??0)+a*i),c.set(r.source,(c.get(r.source)??0)+i),s.set(r.target,(s.get(r.target)??0)+t*i),c.set(r.target,(c.get(r.target)??0)+i)}i=i.map((e,t)=>({item:e,index:t,barycenter:(s.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(a.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);let u=r(i);if(l++,o>u)o=u,n=[...i];else if(u===o)break}return n}function Ie(e,t,r={}){let a=[...e];if(1>=a.length)return a;let i=t(a),n=1,o=Math.max(0,r.passes??6),l=Math.max(1,r.maxEvaluations??1/0);for(let e=0;o>e&&l>n;e++){let e=!1;for(let r=0;a.length-1>r&&l>n;r++){[a[r],a[r+1]]=[a[r+1],a[r]];let o=t(a);n++,i>o?(i=o,e=!0):[a[r],a[r+1]]=[a[r+1],a[r]]}if(!e)break}return a}function Ce(e,t,r={}){let a=[...e],i=a.length;if(1>=i||i>(r.maxItems??8))return a;let n=Math.max(1,r.maxEvaluations??1/0),o=0,l=[...a],s=1/0,c=()=>{if(o>=n)return;let e=t(a);o++,s>e&&(s=e,l=[...a])};c();let u=Array(i).fill(0),d=0;for(;i>d&&n>o;)if(d>u[d]){let e=d%2==0?0:u[d];[a[e],a[d]]=[a[d],a[e]],c(),u[d]++,d=0}else u[d]=0,d++;return l}function Ee(e,t,r=()=>!0){let a=0;for(let i=0;e.length>i;i++){let[n,o]=t(e[i]);for(let l=i+1;e.length>l;l++){if(!r(e[i],e[l]))continue;let[s,c]=t(e[l]);0>(n-s)*(o-c)&&a++}}return a}function Oe(){/* @__PURE__ */
|
|
2
|
+
return Object.create(null)}function Ne(e,t){return t>e?-1:e>t?1:0}function Be(e){return e.occupants.map(e=>e.id).sort(Ne).join("\0")}function $e(e,t,r=0){return e.slice(0,-1).map((a,i)=>null!=a.group&&a.group===e[i+1].group?r:t)}function He(e,t){return e.map(e=>{let r=/* @__PURE__ */new Map;for(let a of e.occupants){let e=t[a.id];if(e)for(let t of e.samples){let e=r.get(t.t)??{before:0,after:0},a=t.boundaryOffset??0;r.set(t.t,{before:Math.max(e.before,t.topMass-a),after:Math.max(e.after,t.botMass+a)})}}return[...r].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function Re(e,t,r){return Ae(He([e,t],r)).adjacentClearance[0]??0}function Fe(e,t,r){if(0===e.length)return[];let{padding:a,plotH:i,valueScale:n}=r,o=r.stackValueScale??n,l=$e(e,a,r.groupPadding??0),s=[a+e[0].peak.topPeak*o];for(let r=1;e.length>r;r++)s.push(s[r-1]+t[r-1]*o+l[r-1]);let c=s[s.length-1]+e[e.length-1].peak.botPeak*o+a;if(c>i&&c>0){let e=i/c;for(let t=0;s.length>t;t++)s[t]*=e}return s}function We(e,t){let r=(e.boundaryOffset??0)*t,a=e.value*t;if("out"===e.kind){let i=e.sideMassBefore*t;return r+("top"===e.side?a/2-i:i-a/2)}let i=e.sideMassAfter*t;return r+("top"===e.side?a/2-i:i-a/2)}function _e(e,t,r,a,i,n,o){let l=e.length;if(0===l)return[];let{padding:s,plotH:c,valueScale:u}=o,d=$e(e,s,o.groupPadding??0),f=i.map((e,t)=>e*u+d[t]),h=s+e[0].peak.topPeak*u,g=c-s-e[l-1].peak.botPeak*u;if(f.reduce((e,t)=>e+t,0)+1e-6>=g-h)return Fe(e,i,o);let m=1===l?[(h+g)/2]:[...n];for(let e=0;12>e;e++){let e=Array(l).fill(0),i=Array(l).fill(0);for(let n of r){let r=t[n.source],o=t[n.target];if(null==r||null==o||r===o)continue;let l=a[n.source]?.localAttachments.get(n.id),s=a[n.target]?.localAttachments.get(n.id);if(!l||!s)continue;let c=n.value>0&&Number.isFinite(n.value)?n.value:1,d=We(l,u),f=We(s,u);e[r]+=(m[o]+f-d)*c,i[r]+=c,e[o]+=(m[r]+d-f)*c,i[o]+=c}let n=m.map((t,r)=>0===i[r]?t:.45*t+e[r]/i[r]*.55),o=Ea({desired:n,minGaps:f,weights:i.map(e=>Math.max(1,e)),min:h,max:g}),s=0;for(let e=0;l>e;e++)s=Math.max(s,Math.abs(o[e]-m[e]));if(m=o,.01>s)break}return m}function ze(e,t,r,a,i,n){let o=n.adjacentClearance?[...n.adjacentClearance]:Ae(He(a,r)).adjacentClearance,l=Fe(a,o,n),s="hug"===n.lanePlacement?_e(a,i,t,r,o,l,n):[...l];if("hug"===n.lanePlacement){let r=t=>{let r=Oe();for(let a of e)r[a.id]=t[i[a.id]];return r};je(r(s),t)>je(r(l),t)+1e-6&&(s=[...l])}let c=Oe();for(let t of e)c[t.id]=s[i[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],a=r[t.id];!Number.isFinite(e)||!a||(u=Math.min(u,e-a.topPeak*n.valueScale),d=Math.max(d,e+a.botPeak*n.valueScale))}return{adjacentClearance:o,centerlines:c,slotCenter:s,stackCenter:l,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&n.plotH>0?Math.max(0,Math.min(1,(d-u)/n.plotH)):0}}function je(e,t){let r=0;for(let a of t){let t=e[a.source],i=e[a.target];Number.isFinite(t)&&Number.isFinite(i)&&(r+=Math.abs(t-i)*(a.value>0?a.value:1))}return r}function Xe(e,t){let r=e?.samples;if(!r||0===r.length||r[0].t>t)return{top:0,bot:0};let a=0,i=r.length-1,n=0;for(;i>=a;){let e=a+i>>>1;r[e].t>t?i=e-1:(n=e,a=e+1)}let o=r[n].boundaryOffset??0;return{top:r[n].topMass-o,bot:r[n].botMass+o}}function Ye(e,t,r,a,i){let n=1-i;return n*n*n*e+3*n*n*i*t+3*n*i*i*r+i*i*i*a}function qe(e,t){let r=0,a=1;for(let i=0;28>i;i++){let i=(r+a)/2;Ye(0,t,t,1,i)<e?r=i:a=i}return(r+a)/2}function Ge(e,t,r){let a=t+We(e,r),i=e.value*r/2;return[a-i,a+i]}function Ue(e,t,r,a){return Math.max(0,Math.min(t,a)-Math.max(e,r))/Math.max(1e-9,t-e)}function Ve(e,t,r,a,i,n,o){let{valueScale:l,domain:s,mode:c="quality"}=o,u="source"===o.ribbonLane?.85:"target"===o.ribbonLane?.15:.5,d=0;for(let o of e){let e=a[o.source],f=a[o.target];if(null==e||null==f||2>Math.abs(e-f))continue;let h=t[o.source]?.localAttachments.get(o.id),g=t[o.target]?.localAttachments.get(o.id);if(!h||!g)continue;let m=Math.max(o.startTime,s?.[0]??-1/0),p=Math.min(o.endTime,s?.[1]??1/0);if(m>=p)continue;let[y,b]=Ge(h,i[o.source],l),[v,k]=Ge(g,i[o.target],l),x=Math.min(e,f)+1,S=Math.max(e,f)-1;for(let e=x;S>=e;e++){let a=r[e];if(!a)continue;let s=[m,p];if("quality"===c)for(let e of a.occupants)for(let r of t[e.id]?.samples??[])r.t>m&&p>r.t&&s.push(r.t);let f=e=>{let r=qe((e-m)/(p-m),u),s=Ye(y,y,v,v,r),c=Ye(b,b,k,k,r),d=0;for(let r of a.occupants){if(r.id===o.source||r.id===o.target)continue;let a=n[r.id];if(null!=a?.start&&a.start>e||null!=a?.end&&e>a.end)continue;let u=Xe(t[r.id],e),f=i[r.id];d=Math.max(d,Ue(s,c,f-u.top*l,f+u.bot*l))}return d},h=[...new Set(s)].sort((e,t)=>e-t),g=0;for(let e=0;h.length-1>e;e++){let t=h[e],r=h[e+1]-t;g+=(f(t+.25*r)+f(t+.5*r)+f(t+.75*r))/3*r}d+=g/(p-m)*(o.value>0?o.value:1)}}return d}function Ke(e,t,r,a,i,n,o,l,s,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:je(o,r),transitOcclusion:Ve(r,a,i,n,o,l,{valueScale:s,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function Qe(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ze(e,t){return e.map(e=>({t:Qe(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Je(e,t,r){let a=t+(e.boundaryOffset??0)*r,i=e.value*r;if("out"===e.kind){let t=e.sideMassBefore*r;if("top"===e.side){let e=a-t;return[e,e+i]}let n=a+t;return[n-i,n]}let n=e.sideMassAfter*r;if("top"===e.side){let e=a-n;return[e,e+i]}let o=a+n;return[o-i,o]}function et(e,t,r,a,i){if(0===e.length)return null;let n=Ze(e,i),o=e=>t+(n[e].boundaryOffset??0)*r,l=e=>o(e)-n[e].topMass*r,s=e=>o(e)+n[e].botMass*r,c=`M${a(n[0].t)},${l(0)}`;for(let e=1;n.length>e;e++)c+=` L${a(n[e].t)},${l(e)}`;c+=` L${a(n[n.length-1].t)},${s(n.length-1)}`;for(let e=n.length-2;e>=0;e--)c+=` L${a(n[e].t)},${s(e)}`;return c+" Z"}function tt(e,t,r,a,i,n){let o=r.nodeData[e];if(!o||0===o.samples.length)return[];let l=r.valueScale,s=r.centerlines[e],c=Ze(o.samples,i),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],f=a(u.t),h=a(d.t),g=e=>a(Qe(e,i)),m=[],p=(e,t,r,a)=>`M${e},${t} L${r},${t} L${r},${a} L${e},${a} Z`;for(let r of t){if(r.source===e&&null!=r.systemInTime&&Number.isFinite(r.systemInTime)){let e=o.localAttachments.get(r.id),t=n?.get(r.id)??r.startTime;if(e&&"out"===e.kind&&t>r.systemInTime){let a=g(r.systemInTime),n=g(t),o=null!=i&&i[0]>r.systemInTime,c=o?a:a-20,u=o?Math.min(n,a+20):a,d=Math.max(f,c);if(n>d){let[t,r]=Je(e,s,l);m.push({pathD:p(d,t,n,r),x0:c,x1:u,from:0,to:1})}}}if(r.target===e&&null!=r.systemOutTime&&Number.isFinite(r.systemOutTime)){let e=o.localAttachments.get(r.id);if(e&&"in"===e.kind&&r.systemOutTime>r.endTime){let t=g(r.systemOutTime),a=g(r.endTime),i=t+20,n=Math.min(h,i);if(n>a){let[r,o]=Je(e,s,l);m.push({pathD:p(a,r,n,o),x0:t,x1:i,from:1,to:0})}}}}return m}function rt(e,t){let r=Oe(),a=Oe();for(let t of e)r[t.id]=[],a[t.id]=[];for(let e of t)a[e.source]&&a[e.source].push(e),r[e.target]&&r[e.target].push(e);return{incoming:r,outgoing:a}}function at(e,t,r,a="temporal"){let i="temporal"===a?(e,t)=>e.endTime-t.endTime||Ne(e.id,t.id):(e,t)=>t.value-e.value||Ne(e.id,t.id),n="temporal"===a?(e,t)=>e.startTime-t.startTime||Ne(e.id,t.id):(e,t)=>t.value-e.value||Ne(e.id,t.id),o=/* @__PURE__ */new Map;for(let e of t)o.set(e.id,{});let l=(e,t)=>{let r=/* @__PURE__ */new Map;for(let a of e){let e=a[t];r.has(e)||r.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let i=r.get(e);i.edges.push(a),i.total+=a.value,i.earliestStart=Math.min(i.earliestStart,a.startTime),i.latestEnd=Math.max(i.latestEnd,a.endTime)}let o=[...r.values()];o.sort("temporal"===a?(e,r)=>"target"===t?e.earliestStart-r.earliestStart||Ne(e.partner,r.partner):e.latestEnd-r.latestEnd||Ne(e.partner,r.partner):(e,t)=>t.total-e.total||Ne(e.partner,t.partner));for(let e of o)e.edges.sort("target"===t?n:i);return o};for(let t of e){let e=r.outgoing[t.id],a=r.incoming[t.id];if(0===a.length)l(e,"target").forEach((e,t)=>{let r=t%2==0?"top":"bot";for(let t of e.edges)o.get(t.id).sourceSide=r});else if(0===e.length)l(a,"source").forEach((e,t)=>{let r=t%2==0?"top":"bot";for(let t of e.edges)o.get(t.id).targetSide=r});else{let t=l(a,"source"),r=l(e,"target"),i=Math.max(t.length,r.length);for(let e=0;i>e;e++){let a=e%2==0?"top":"bot";if(t[e])for(let r of t[e].edges)o.get(r.id).targetSide=a;if(r[e])for(let t of r[e].edges)o.get(t.id).sourceSide=a}}}return o}function it(e,t,r,a,i="temporal"){let n=t.incoming[e.id],o=t.outgoing[e.id],l=[];for(let e of n)l.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:r.get(e.id).targetSide});for(let e of o)l.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:r.get(e.id).sourceSide});let s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=(e,t)=>{if(!a||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;let r=a.get(e.edge.id)?.target,i=a.get(t.edge.id)?.target;return"number"==typeof r&&Number.isFinite(r)&&"number"==typeof i&&Number.isFinite(i)&&r!==i?"top"===e.side?r-i:i-r:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let r=a.get(e.edge.id)?.source,i=a.get(t.edge.id)?.source;return"number"==typeof r&&Number.isFinite(r)&&"number"==typeof i&&Number.isFinite(i)&&r!==i?"top"===e.side?i-r:r-i:0}return 0},u=()=>{l.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(s[e.kind]??99)-(s[t.kind]??99)||c(e,t)||Ne(e.edge?.id??"",t.edge?.id??"")||Ne(e.side,t.side)||e.delta-t.delta)},d=l.length?yi(l.map(e=>e.time)):null,f=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=f?f-1:null!=d&&Number.isFinite(d)?d-1:null;u();let g=null,m=0;for(let e of l)e.time!==g&&(g=e.time,m=0),e.sequence=m++;let p=e=>({time:e.time,phase:0,sequence:e.sequence??0}),y=[],b=0,v=0;for(let e of l)if("out"===e.kind){let t=Math.abs(e.delta),r=t-("top"===e.side?b:v);if(r>0){let t="top"===e.side?"bot":"top",a=Math.min(r,"top"===t?b:v);if(a>0){let i=p(e);y.push({...i,delta:-a,kind:"transfer-out",side:t}),y.push({...i,delta:+a,kind:"transfer-in",side:e.side}),"top"===t?b-=a:v-=a,"top"===e.side?b+=a:v+=a,r-=a}r>0&&null!==h&&(y.push({time:h,delta:+r,kind:"create",side:e.side}),"top"===e.side?b+=r:v+=r)}"top"===e.side?b-=t:v-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?b+=t:v+=t}l.push(...y),u();let k=0,x=0,S=0,w=0,M=0,L=0,P=[],T=/* @__PURE__ */new Map,A=e=>{P.push({t:e,topMass:k,botMass:x,...Math.abs(S)>1e-12&&{boundaryOffset:S}})},D=()=>{w=Math.max(w,k+x),M=Math.max(M,k-S),L=Math.max(L,x+S)};for(let e of l){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&A(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?k:x;T.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(S)>1e-12&&{boundaryOffset:S}})}"top"===e.side?k+=e.delta:x+=e.delta,"transfer-in"===e.kind?(S+="top"===e.side?e.delta:-e.delta,D(),A(e.time)):"transfer-out"!==e.kind&&(D(),"out"===e.kind&&1e-12>=k+x&&(S=0),A(e.time))}let I=[],C=0;for(;P.length>C;){let e=C;for(;P.length>e+1&&P[e+1].t===P[C].t;)e++;I.push(P[C]);for(let t=C+1;e>=t;t++){let e=I[I.length-1];(P[t].topMass!==e.topMass||P[t].botMass!==e.botMass||(P[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&I.push(P[t])}C=e+1}let E=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,O=null;for(let e of o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===O||O>e.systemInTime)&&(O=e.systemInTime);let N=null;for(let e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===N||e.systemOutTime>N)&&(N=e.systemOutTime);if(I.length>0){let e=I[I.length-1],t=Math.max(E??-1/0,N??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let r,a=I[0],i=I.find(e=>e.topMass+e.botMass>0),n=1/0;null!=f&&Number.isFinite(f)&&a.t>f&&a.topMass+a.botMass>0&&(n=f,r=a),i&&null!=O&&Number.isFinite(O)&&i.t>O&&n>O&&(n=O,r=i),r&&Number.isFinite(n)&&I.unshift({t:n,topMass:r.topMass,botMass:r.botMass,...null!=r.boundaryOffset&&{boundaryOffset:r.boundaryOffset}})}let B=I;if("max"===i&&null!=f&&null!=E&&E>f){let e,t=0;for(let r of I){let a=r.topMass+r.botMass;a>t&&(t=a,e=r)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};B=[...I.filter(e=>f>e.t),{t:f,...t},{t:E,...t},...I.filter(e=>e.t>E)]}}return{samples:B,peak:w,topPeak:M,botPeak:L,localAttachments:T}}function nt(e,t,r,a){let i=/* @__PURE__ */new Map;for(let n of e){let e=t[n.source]?.localAttachments.get(n.id),o=t[n.target]?.localAttachments.get(n.id),l=r[n.source],s=r[n.target];if(!(e&&o&&Number.isFinite(l)&&Number.isFinite(s)))continue;let c=Je(e,l,a),u=Je(o,s,a);i.set(n.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return i}function ot(e,t){let r=(e,r)=>{for(let a of e){let e=/* @__PURE__ */new Map;for(let i of a){let a=`${("out"===r?t.get(i.id)?.sourceSide:t.get(i.id)?.targetSide)??""}\0${"out"===r?i.startTime:i.endTime}`,n="out"===r?`${i.target}\0${i.endTime}`:`${i.source}\0${i.startTime}`,o=e.get(a);if(null!=o&&o!==n)return!0;e.set(a,n)}}return!1};return r(Object.values(e.outgoing),"out")||r(Object.values(e.incoming),"in")}function lt(e,t,r){let a=/* @__PURE__ */new Map,i=[];for(let t of e)i.push({time:t.startTime,kind:"out",edge:t}),i.push({time:t.endTime,kind:"in",edge:t});i.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||Ne(e.edge.id,t.edge.id));let n=e=>{let t=a.get(e);return t||(t={top:0,bot:0},a.set(e,t)),t},o=(e,t,r)=>{let a="top"===t?"bot":"top",i=Math.min(r,e[t]);e[t]-=i;let n=r-i;n>0&&(e[a]=Math.max(0,e[a]-n))};for(let e of i){let{edge:a}=e;if("in"===e.kind){let e=t.get(a.id)?.targetSide??"bot";n(a.target)[e]+=a.value;continue}let i=n(a.source),l=t.get(a.id),s=l.sourceSide??"bot";if(r[a.source]===r[a.target]){let e=i.top>=a.value,t=i.bot>=a.value;e!==t?s=e?"top":"bot":!e&&!t&&i.top!==i.bot&&(s=i.top>i.bot?"top":"bot"),l.sourceSide=s,l.targetSide=s}o(i,s,a.value)}}function st(e,t,r,a){for(let i of e){let e=t.incoming[i.id],n=t.outgoing[i.id];if(0===e.length||0===n.length)continue;let o=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let a of e)"top"===r.get(a.id).targetSide?t.inTop+=a.value:t.inBot+=a.value;for(let e of n)"top"===r.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},l=(e,t)=>{let i=o(),l="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=l||0>=s)return!1;let c=Math.min(l,s),u=n.filter(t=>!a.has(t.id)&&r.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||Ne(e.id,t.id));return 0!==u.length&&(r.get(u[0].id).sourceSide=t,!0)},s=n.length+1;for(;s-- >0&&(l("top","bot")||l("bot","top")););}}function ct(e){let t=Oe();return e.forEach((e,r)=>{for(let a of e.occupants)t[a.id]=r}),t}function ut(e,t,r){e.splice(0,e.length,...r);let a=ct(r);for(let e of Object.keys(t))delete t[e];Object.assign(t,a)}function dt(e){let t=/* @__PURE__ */new Map,r=[];e.forEach((e,a)=>{if(!e.group)return void r.push({anchor:a,stableId:Be(e),slots:[e]});let i=t.get(e.group)??{indexes:[],slots:[]};i.indexes.push(a),i.slots.push(e),t.set(e.group,i)});for(let[e,a]of t)r.push({anchor:a.indexes.reduce((e,t)=>e+t,0)/a.indexes.length,stableId:`${e}\0${a.slots.map(Be).join("\0")}`,slots:a.slots});return r.sort((e,t)=>e.anchor-t.anchor||Ne(e.stableId,t.stableId))}function ft(e){return e.some(e=>e.group)?dt(e).flatMap(e=>e.slots):[...e]}function ht(e){let t=/* @__PURE__ */new Set;for(let r of e)if(r.group){if(t.has(r.group))return!0;t.add(r.group)}return!1}function gt(e){return e.flatMap(e=>e.slots)}function mt(e,t){let r=/* @__PURE__ */new Map;for(let t of e)for(let e of t.slots)r.set(e,t);let a=/* @__PURE__ */new Map;for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(!t||!i||t===i)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,o=i.stableId>t.stableId?`${t.stableId}\0${i.stableId}`:`${i.stableId}\0${t.stableId}`,l=a.get(o);l?l.weight=(l.weight??0)+n:a.set(o,{source:t,target:i,weight:n})}return[...a.values()]}function pt(e,t,r){let a=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(let r of e.slots)a.set(r,t)}),e.map((e,i)=>{if(1>=e.slots.length)return e;let n=/* @__PURE__ */new Map;for(let t of e.slots)n.set(t,0);for(let e of t){let t=a.get(e.source),r=a.get(e.target);if(null==t||null==r)continue;let o=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===i&&r!==i){let t=r>i?1:-1;n.set(e.source,(n.get(e.source)??0)+o*t)}else if(r===i&&t!==i){let r=t>i?1:-1;n.set(e.target,(n.get(e.target)??0)+o*r)}}let o=[...e.slots].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0)||r(e,t));return{...e,slots:o}})}function yt(e,t){e.some(e=>e.group)&&ut(e,t,ft(e))}function bt(e,t,r=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+r>=e.cost}function vt({order:e,after:t,nodes:r,edges:a,outgoingPartners:i,incomingPartners:n,slotForNode:o,averageGap:l,evaluate:s}){let c=(r,i)=>{let n=[...new Set(i.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),o=e.indexOf(r),c=n[0],u=n[n.length-1];if(3>n.length||!n.includes(o)||u-c+1!==n.length||1>=Math.abs(2*o-c-u))return;let d=[...e];d.splice(o,1),d.splice(c+u>>1,0,r);let f=ft(d),h=s(f),g=new Set(r.occupants.map(e=>e.id)),m=new Set(i.flatMap(e=>e.occupants.map(e=>e.id))),p=a.reduce((e,t)=>g.has(t.source)&&m.has(t.target)||g.has(t.target)&&m.has(t.source)?e+(t.value>0?t.value:1):e,0);bt(h,t,Math.abs(2*o-c-u)*l*Math.max(1,p))&&(e=f,t=h)};for(let[e,t]of i)!n.has(e)&&t.size>=3&&c(o.get(e),[...t].map(e=>o.get(e)));for(let e of r){let t=o.get(e.id);!e.group&&t.group&&(n.get(e.id)?.size??0)>=3&&c(t,[...n.get(e.id)??[]].map(e=>o.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,r)=>r.indexOf(e)===t))}return{order:e,after:t}}function kt(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function xt(e,t){return Ee(t,t=>[e[t.source],e[t.target]],kt)}function St(e,t){let r=0;for(let a of t){let t=e[a.source],i=e[a.target];null==t||null==i||(r+=Math.abs(t-i)*(a.value>0?a.value:1))}return r}function wt(e,t,r){let[a,i]=r.get(e.first),[n,o]=r.get(e.second);return 0>(t.get(a)-t.get(n))*(t.get(i)-t.get(o))?1:0}function Mt(e,t,r,a,i,n,o){let l=[...i],s=new Map(i.map(e=>[e,Be(e)])),c=/* @__PURE__ */new Map;for(let e of i)for(let t of e.occupants)c.set(t.id,e);let u=/* @__PURE__ */new Map,d=[];for(let e of t){let t=c.get(e.source),r=c.get(e.target);!t||!r||(u.set(e,[t,r]),t!==r&&d.push({source:t,target:r,weight:e.value}))}let f=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let r=e+1;t.length>r;r++){if(!u.has(t[r])||!kt(t[e],t[r]))continue;let a=/* @__PURE__ */new Set([...u.get(t[e]),...u.get(t[r])]);f.push({index:f.length,first:t[e],second:t[r],involvedSlots:a})}let h=/* @__PURE__ */new Map;for(let e of i)h.set(e,[]);for(let e of f)for(let t of e.involvedSlots)h.get(t)?.push(e);let g=new Uint32Array(f.length),m=0,p=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),y=o.plotH/Math.max(1,i.length),b=i.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,p)*(Math.max(1,o.plotH)+y*Math.max(b,i.length)+1e-6*Math.max(1,i.length-1))+1,k=4*y,x={fullCrossing:0,localCrossing:0},S=/* @__PURE__ */new Map,w=(e,t)=>{let a=S.get(e);a||(a=/* @__PURE__ */new Map,S.set(e,a));let i=a.get(t);if(null!=i)return i;let n=Re(e,t,r);return a.set(t,n),n},M=new Map(i.map((e,t)=>[e,t])),L=t.flatMap(e=>{let t=u.get(e);return t?[{source:M.get(t[0]),target:M.get(t[1]),weight:e.value>0?e.value:1}]:[]}),P=/* @__PURE__ */new Map;for(let e of t){let t=u.get(e);t&&P.set(e,{source:M.get(t[0]),target:M.get(t[1])})}let T=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,D=/* @__PURE__ */new Map,I=(e,t,r)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(r)};for(let e of t)I(T,e.source,e.target),I(A,e.target,e.source),I(D,e.source,e.target),I(D,e.target,e.source);let C=e=>1===T.get(e.source)?.size&&T.get(e.source).has(e.target)||1===D.get(e.source)?.size||1===D.get(e.target)?.size,E=t.flatMap(e=>{if(!C(e))return[];let t=P.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),O=e=>{let t=0;for(let r of E)t+=Math.max(0,Math.abs(e[r.source]-e[r.target])-1)*r.weight;return t*k},N=e=>{let t=new Int16Array(i.length);for(let r=0;e.length>r;r++)t[M.get(e[r])]=r;return O(t)},B=f.map(e=>{let t=P.get(e.first),r=P.get(e.second);return[t.source,t.target,r.source,r.target]}),$=new Int16Array(i.length),H=new Float64Array(i.length),R=new Float64Array(i.length+1),F=e=>{for(let t=0;e.length>t;t++)$[M.get(e[t])]=t;let t=0;for(let[e,r,a,i]of B)0>($[e]-$[a])*($[r]-$[i])&&t++;if(e.length>0){let t=M.get(e[0]);H[t]=o.padding+e[0].peak.topPeak*o.valueScale;for(let t=1;e.length>t;t++){let r=M.get(e[t-1]),a=M.get(e[t]);H[a]=H[r]+w(e[t-1],e[t])*o.valueScale+o.padding}let r=M.get(e[e.length-1]),a=H[r]+e[e.length-1].peak.botPeak*o.valueScale+o.padding;if(a>o.plotH&&a>0){let e=o.plotH/a;for(let t=0;H.length>t;t++)H[t]*=e}}R[0]=0;for(let t=0;e.length>t;t++)R[t+1]=R[t]+e[t].peak.topPeak+e[t].peak.botPeak;let r=0,a=0,i=0;for(let e of L){let t=$[e.source],n=$[e.target];if(r+=Math.abs(t-n)*e.weight,a+=Math.abs(H[e.source]-H[e.target])*e.weight,Math.abs(t-n)>=2){let r=Math.min(t,n)+1;i+=(R[Math.max(t,n)]-R[r])*e.weight}}return t*v+a+i*y+O($)+1e-6*r},W=(e,r)=>{let a=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)a[t+1]=a[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0;for(let e of t){let t=r[e.source],n=r[e.target];if(null==t||null==n||2>Math.abs(t-n))continue;let o=Math.min(t,n)+1;i+=(a[Math.max(t,n)]-a[o])*(e.value>0?e.value:1)}return i},_=a=>{let i=ct(a),n=a.slice(0,-1).map((e,t)=>w(e,a[t+1])),l=ze(e,t,r,a,i,{plotH:o.plotH,padding:o.padding,valueScale:o.valueScale,lanePlacement:o.lanePlacement??"stack",groupPadding:o.groupPadding,adjacentClearance:n});return{map:i,geometry:l,weightedLength:St(i,t),pixelLength:je(l.centerlines,t),transitOcclusion:W(a,i)}},z=(e,t,r)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*y+N(r)+1e-6*t.weightedLength}),j=(e,t)=>{let r=t;if(null==r){let t=new Map(e.map((e,t)=>[e,t]));r=f.reduce((e,r)=>e+wt(r,t,u),0),x.fullCrossing++}return z(r,_(e),e)},X=(e,i,n="quality")=>{let l=i;if(null==l){let t=new Map(e.map((e,t)=>[e,t]));l=f.reduce((e,r)=>e+wt(r,t,u),0),x.fullCrossing++}let s=_(e);return z(l,{...s,transitOcclusion:Ve(t,r,e,s.map,s.geometry.centerlines,a,{valueScale:o.valueScale,ribbonLane:o.ribbonLane,domain:o.domain,mode:n})},e)},Y=[...l],q=(e,t)=>Ne(s.get(e),s.get(t)),G=ht(Y),U=e=>{let t=De(e,d,e=>j(e).cost,{passes:6,compare:q,maxEvaluations:vn}),r=j(t),a=vn;for(let e=0;6>e&&a>0;e++){let i=!1,n=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&n.reverse();for(let e of n){if(0>=a--)break;let n=t[e],o=t[e+1],l=new Map(t.map((e,t)=>[e,t])),s=0,c=[];m++;for(let e of[...h.get(n)??[],...h.get(o)??[]])g[e.index]!==m&&(g[e.index]=m,c.push(e),s+=wt(e,l,u));[t[e],t[e+1]]=[o,n];let d=new Map(l);d.set(n,e+1),d.set(o,e);let f=0;for(let e of c)f+=wt(e,d,u);x.localCrossing+=c.length;let p=j(t,r.crossings-s+f);r.cost>p.cost?(r=p,i=!0):[t[e],t[e+1]]=[n,o]}if(!i)break}return t},V=e=>{let t=U(e);if((e.length>8?1/0:yn(e.length)*(e.length+L.length+B.length))>bn)return t;let r=Ce(e,F,{maxItems:8,maxEvaluations:5e4}),a=X(r),i=X(t);return a.crossings!==i.crossings&&i.crossings>a.crossings?r:t},K="geometry-refine"===o.mode;if(K||"crossing-min"!==o.laneOrder&&"crossing-min+inside-out"!==o.laneOrder){if(!K&&"inside-out"===o.laneOrder)if(G){let e=dt(Y),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),r=[...e].sort((e,r)=>t(r)-t(e)||Ne(e.stableId,r.stableId)),a=Array(r.length),i=Math.floor((r.length-1)/2)-1,n=Math.floor((r.length-1)/2)+1;r.length>0&&(a[Math.floor((r.length-1)/2)]=r[0]);for(let e=1;r.length>e;e++)e%2==1&&r.length>n||0>i?a[n++]=r[e]:a[i--]=r[e];Y=gt(a)}else{let e=[...Y].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||q(e,t)),t=Array(e.length),r=Math.floor((e.length-1)/2)-1,a=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let i=1;e.length>i;i++)i%2==1&&e.length>a||0>r?t[a++]=e[i]:t[r--]=e[i];Y=t}}else Y=G?(e=>{let t=dt(e);if(1>=t.length)return gt(t);let r=e=>j(gt(e)).cost;if(t=dt(V(e)),t=pt(t,d,q),t=De(t,mt(t,d),r,{passes:6,compare:(e,t)=>Ne(e.stableId,t.stableId),maxEvaluations:vn}),t=Ie(t,r,{passes:8,maxEvaluations:vn}),(t.length>8?1/0:yn(t.length)*(t.length+L.length+B.length))<=bn){let e=Ce(t,e=>F(gt(e)),{maxItems:8,maxEvaluations:5e4}),r=gt(e),a=gt(t),i=X(r),n=X(a);i.crossings!==n.crossings?t=n.crossings>i.crossings?e:t:n.cost>i.cost&&(t=e)}return t=pt(t,d,q),gt(t)})(Y):V(Y);if(!K&&"crossing-min+inside-out"===o.laneOrder&&Y.length>1)if(G){let e=dt(Y),t=j(gt(e)),r=gt(e),a=t,i=Math.floor((e.length-1)/2),n=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),o=[...e].sort((e,t)=>n(t)-n(e)||Ne(e.stableId,t.stableId));for(let n of o){let o=e.indexOf(n);if(o===i)continue;e.splice(o,1),e.splice(i,0,n);let l=gt(e),s=j(l);s.cost>t.cost?(e.splice(i,1),e.splice(o,0,n)):(t=s,a.cost>s.cost&&(r=l,a=s))}Y=r}else{let e=j(Y),t=[...Y],r=e,a=Math.floor((Y.length-1)/2),i=[...Y].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||q(e,t));for(let n of i){let i=Y.indexOf(n);if(i===a)continue;Y.splice(i,1),Y.splice(a,0,n);let o=j(Y);o.cost>e.cost?(Y.splice(a,1),Y.splice(i,0,n)):(e=o,r.cost>o.cost&&(t=[...Y],r=o))}Y=t}if((K||"crossing-min"===o.laneOrder||"crossing-min+inside-out"===o.laneOrder)&&Y.length>1)if(G){let e=dt(Y),t=X(gt(e),void 0,"score");for(let r=0;6>r&&e.length>1;r++){let r=!1;for(let a=0;e.length-1>a;a++){[e[a],e[a+1]]=[e[a+1],e[a]];let i=gt(e),n=X(i,void 0,"score");t.cost>n.cost?(Y=i,t=n,r=!0):[e[a],e[a+1]]=[e[a+1],e[a]]}if(!r)break}e=pt(dt(Y),d,q),Y=gt(e)}else{let e=X(Y,void 0,"score");for(let t=0;Y.length-1>t;t++){let r=Y[t],a=Y[t+1],i=new Map(Y.map((e,t)=>[e,t])),n=0,o=[];m++;for(let e of[...h.get(r)??[],...h.get(a)??[]])g[e.index]!==m&&(g[e.index]=m,o.push(e),n+=wt(e,i,u));[Y[t],Y[t+1]]=[a,r];let l=new Map(i);l.set(r,t+1),l.set(a,t);let s=0;for(let e of o)s+=wt(e,l,u);x.localCrossing+=o.length;let c=X(Y,e.crossings-n+s,"score");e.cost>c.cost?e=c:[Y[t],Y[t+1]]=[r,a]}}let Q=ft(l);Y=ft(Y);let Z=X(Y),J=X(Q);if(K){let e=N(Q),t=N(Y);(Z.crossings>J.crossings||Z.crossings===J.crossings&&t>e+1e-9||Z.cost>J.cost)&&(Y=Q,Z=J)}else Z.cost>J.cost&&(Y=Q,Z=J);let ee=vt({order:Y,after:Z,nodes:e,edges:t,outgoingPartners:T,incomingPartners:A,slotForNode:c,averageGap:y,evaluate:X});return Y=ee.order,Z=ee.after,ut(i,n,Y),{before:J,after:Z,initialOrder:l.map(e=>s.get(e)),evaluations:x}}function Lt(e,t,r){let a=new Map(r.map((e,t)=>[e,t]));ut(e,t,[...e].sort((e,t)=>(a.get(Be(e))??1/0)-(a.get(Be(t))??1/0)||Ne(Be(e),Be(t))))}function Pt(e,t,r){let a=e.map(e=>{let a=e.occupants.map(e=>({id:e.id,end:r[e.id]?.end??e.end})),i=0,n=0;for(let e of a){let r=t[e.id];i=Math.max(i,r?.topPeak||0),n=Math.max(n,r?.botPeak||0)}return{occupants:a,peak:{topPeak:i,botPeak:n},...null!=e.group?{group:e.group}:{}}}),i=Oe();return a.forEach((e,t)=>{for(let r of e.occupants)i[r.id]=t}),{slots:a,slotByNode:i}}function Tt(e,t,r,a){return`${e.map(e=>{let t=r[e.id],i=a[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,i?.start??"",i?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}function At(e){return kn.get(e)}function Dt(e,t){for(kn.has(e)&&kn.delete(e),kn.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(Oe(),t.slotByNode)});kn.size>12;){let e=kn.keys().next().value;if(null==e)break;kn.delete(e)}}function It(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function Ct(e,t){return Ne(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Et(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let a of e)r.has(a.source)||r.set(a.source,/* @__PURE__ */new Set),t.has(a.target)||t.set(a.target,/* @__PURE__ */new Set),r.get(a.source).add(a.target),t.get(a.target).add(a.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...r].map(([e,t])=>[e,t.size]))}}function Ot(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,a=(e,t,r,a)=>{let i=e.get(t);i||(i=/* @__PURE__ */new Map,e.set(t,i)),i.set(r,(i.get(r)??0)+a)};for(let i of e){let e=i.value>0&&Number.isFinite(i.value)?i.value:1;a(t,i.source,i.target,e),a(r,i.target,i.source,e)}let i=/* @__PURE__ */new Map,n=e=>{if(i.has(e))return;let a=t.get(e),n=r.get(e),o=/* @__PURE__ */new Map;for(let[e,t]of a??[])o.set(e,(o.get(e)??0)+t);for(let[e,t]of n??[])o.set(e,(o.get(e)??0)+t);if(1===o.size){let[t,r]=[...o][0];i.set(e,{partner:t,weight:r})}};for(let t of e)n(t.source),n(t.target);return i}function Nt(e,t,r){let a=r.get(e),i=r.get(t);return!a||!i||a.partner===i.partner||a.partner===t||i.partner===e}function Bt(e,t,r){return!!r.has(e)&&t.some(t=>!Nt(e,t,r))}function $t(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function Ht(e,t,r,a,i,n){let o=/* @__PURE__ */new Set,l=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),s=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(let e of a)o.add(Ct(e.source,e.target)),l.get(e.target)?.add(e.source),s.get(e.source)?.add(e.target);let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let r=0;e.length>r;r++)for(let a=r+1;e.length>a;a++){let i=Ct(e[r],e[a]);t instanceof Map?t.set(i,[e[r],e[a]]):t.add(i)}};for(let e of s.values())d([...e],c);for(let e of l.values())d([...e],u);let f=/* @__PURE__ */new Set;for(let[e,[a,i]]of c)u.has(e)&&(It(t[a],t[i])||It(r[a],r[i])&&(f.add(a),f.add(i)));return{conflicts:(e,r)=>{let a=i.get(e),l=i.get(r);return!((null==a||null==l||a===l)&&(null!=a==(null!=l)||o.has(Ct(e,r))||n.has(e)&&n.has(r)&&Nt(e,r,n))&&!It(t[e],t[r])&&(!f.has(e)&&!f.has(r)||o.has(Ct(e,r))))}}}function Rt(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,r)=>t[e.id].start-t[r.id].start||t[e.id].end-t[r.id].end||Ne(e.id,r.id)).map(e=>e.id)}function Ft(e,t,r=/* @__PURE__ */new Map){let a=[],i=[];for(let n of e){let e=a.findIndex(e=>e.every(e=>!t.conflicts(n,e))&&!Bt(n,e,r));-1===e&&!r.has(n)&&(e=a.findIndex(e=>e.every(e=>!t.conflicts(n,e)))),-1===e&&(e=a.length,a.push([])),a[e].push(n),i.push(e)}return{assignment:i,slotCount:a.length}}function Wt(e,t,r,a){if(12>=e.length||1>=a.slotCount)return a.assignment;let i=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>/* @__PURE__ */new Map),o=Et(r);for(let e of r){let t=i.get(e.source),r=i.get(e.target);if(null==t||null==r||t===r)continue;let a=$t(e,o);n[t].set(r,(n[t].get(r)??0)+a),n[r].set(t,(n[r].get(t)??0)+a)}let l=Ot(r),s=e.map(e=>l.get(e)?.weight??0),c=Array.from({length:e.length},()=>/* @__PURE__ */new Map),u=0;for(let r=0;e.length-1>r&&5e4>u;r++)if(l.has(e[r]))for(let a=r+1;e.length>a;a++){if(!l.has(e[a])||t.conflicts(e[r],e[a]))continue;u++;let i=Math.min(s[r],s[a])||Math.max(s[r],s[a]),n=Nt(e[r],e[a],l)?i:-i;if(Math.abs(n)>Sn&&(c[r].set(a,n),c[a].set(r,n),u>=5e4))break}let d=[...a.assignment],f=Array.from({length:a.slotCount},()=>[]);d.forEach((e,t)=>f[e].push(t));let h=(e,t,r)=>{let a=d[t],i=d[r],n=0,o=/* @__PURE__ */new Set;for(let l of[t,r])for(let[s,c]of e[l]){let e=s>l?`${l}:${s}`:`${s}:${l}`;if(o.has(e))continue;o.add(e);let u=(l===t?i:a)===(s===t?i:s===r?a:d[s]);d[l]===d[s]!==u&&(n+=u?c:-c)}return n},g=(e,t,r)=>{let a=0;for(let[i,n]of e[t]){let e=r===d[i];d[t]===d[i]!==e&&(a+=e?n:-n)}return a},m=(e,t)=>e>Sn||Sn>=Math.abs(e)&&t>Sn,p=(e,t,r,a)=>e>r+Sn||Sn>=Math.abs(e-r)&&t>a+Sn,y=0;for(let r=0;32>r&&xn>y;r++){let r=null,a=-1,i=-1,o=-1,l=-1/0,s=-1/0;for(let u=0;e.length>u;u++){for(let h=0;f.length>h&&y++<xn;h++){if(h===d[u]||!f[h].every(r=>!t.conflicts(e[u],e[r])))continue;let y=g(n,u,h),b=g(c,u,h);m(y,b)&&p(y,b,l,s)&&(r="move",a=u,i=-1,o=h,l=y,s=b)}if(y>=xn)break}for(let u=0;e.length-1>u;u++){for(let g=u+1;e.length>g&&y++<xn;g++){let y=d[u],b=d[g];if(y===b||!f[b].every(r=>r===g||!t.conflicts(e[u],e[r]))||!f[y].every(r=>r===u||!t.conflicts(e[g],e[r])))continue;let v=h(n,u,g),k=h(c,u,g);m(v,k)&&p(v,k,l,s)&&(r="swap",a=u,i=g,o=-1,l=v,s=k)}if(y>=xn)break}if(null==r||-1===a)break;if("move"===r){let e=d[a];f[e].splice(f[e].indexOf(a),1),f[o].push(a),d[a]=o;continue}let u=d[a],b=d[i];f[u].splice(f[u].indexOf(a),1,i),f[b].splice(f[b].indexOf(i),1,a),d[a]=b,d[i]=u}return d}function _t(e,t){for(let r=0;Math.min(e.length,t.length)>r;r++)if(e[r]!==t[r])return t[r]>e[r];return t.length>e.length}function zt(e,t,r,a){if(0===e.length||e.length>12||1>=a.slotCount)return a.assignment;let i=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Float64Array(e.length)),o=Array.from({length:e.length},()=>/* @__PURE__ */new Map),l=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=Et(r);for(let e of r){let t=i.get(e.source),r=i.get(e.target);if(null==t||null==r||t===r)continue;let a=$t(e,s);n[t][r]+=a,n[r][t]+=a,l[t].set(r,(l[t].get(r)??0)+a),o[r].set(t,(o[r].get(t)??0)+a)}let c=Ot(r),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let r=t+1;e.length>r;r++){for(let[e,a]of o[t])d[t][r]+=Math.min(a,o[r].get(e)??0);for(let[e,a]of l[t])d[t][r]+=Math.min(a,l[r].get(e)??0);if(c.has(e[t])&&c.has(e[r])){let a=Math.min(u[t],u[r])||Math.max(u[t],u[r]);d[t][r]+=Nt(e[t],e[r],c)?a:-a}d[r][t]=d[t][r]}let f=[...a.assignment],h=(t=>{let r=0,a=0;for(let i=0;e.length>i;i++)for(let o=i+1;e.length>o;o++)t[i]===t[o]&&(r+=n[i][o],a+=d[i][o]);return{flow:r,affinity:a}})(f),g=0,m=Array(e.length).fill(-1),p=Array.from({length:a.slotCount},()=>[]),y=(r,i,o,l)=>{if(g>=75e3)return;if(r===e.length)return g++,void((o>h.flow||o===h.flow&&l>h.affinity||o===h.flow&&l===h.affinity&&_t(m,f))&&(f=[...m],h={flow:o,affinity:l}));let s=Math.min(i+1,a.slotCount-1);for(let a=0;s>=a;a++){if(p[a].some(a=>t.conflicts(e[r],e[a])))continue;let s=0,c=0;for(let e of p[a])s+=n[r][e],c+=d[r][e];if(m[r]=a,p[a].push(r),y(r+1,Math.max(i,a),o+s,l+c),p[a].pop(),m[r]=-1,g>=75e3)return}};return m[0]=0,p[0].push(0),y(1,0,0,0),f}function jt(e,t){let r=1/0,a=-1/0;for(let t of e?.samples??[])1e-9>=t.topMass+t.botMass||(r=Math.min(r,t.t),a=Math.max(a,t.t));return Number.isFinite(r)&&Number.isFinite(a)?(null!=t.start&&(r=Math.max(r,t.start)),null!=t.end&&(a=Math.min(a,t.end)),r>a?{start:null,end:null}:{start:r,end:a}):{start:null,end:null}}function Xt(e,t,r,a){let i=Tt(e,t,r,a),n=At(i);if(n)return Pt(n.slots,r,a);let o=Oe();for(let t of e)o[t.id]=jt(r[t.id],a[t.id]);let l=Rt(e,o),s=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=Ot(t),d=Ht(l,o,a,t,c,u),f=Ft(l,d,u),h=zt(l,d,t,{...f,assignment:Wt(l,d,t,f)}),g=/* @__PURE__ */new Map,m=h.map(e=>(g.has(e)||g.set(e,g.size),g.get(e))),p=Array.from({length:g.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),y=Oe();l.forEach((e,t)=>{let r=m[t],a=p[r];a.occupants.push({id:e,end:o[e].end??-1/0});let i=s.get(e)?.group;i&&(a.group=i),y[e]=r});for(let t of[...e].sort((e,t)=>Ne(e.id,t.id)))null==y[t.id]&&(p[0].occupants.push({id:t.id,end:-1/0}),y[t.id]=0);for(let e of p){e.occupants.sort((e,t)=>(o[e.id].start??1/0)-(o[t.id].start??1/0)||Ne(e.id,t.id));for(let t of e.occupants){let a=r[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,a?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,a?.botPeak||0)}}let b={slots:p,slotByNode:y};return Dt(i,b),b}function Yt(e){return e.topMass+e.botMass}function qt(e){let t=/* @__PURE__ */new Map;for(let r of e.samples){if(Number.isNaN(r.t))continue;let e=t.get(r.t);e||(e=[],t.set(r.t,e)),e.push(r)}let r=0,a=-1/0;return i=>{i>=a||(r=0),a=i;let n=t.get(i);if(n){let e=n.reduce((e,t)=>Yt(t)<Yt(e)?e:t,n[0]);return{exact:n,sample:e}}for(;e.samples.length>r&&i>=e.samples[r].t;)r++;return{exact:n,sample:e.samples[r-1]??null}}}function Gt(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]))}function Ut(e,t,r,a,i,n,o=0){let l=/* @__PURE__ */new Map;for(let r of e){if(!r.group||!t[r.id])continue;let e=l.get(r.group)??[];e.push(r),l.set(r.group,e)}if(0===l.size||0>=n)return t;let s=Gt(t);for(let[e,c]of l){let l=r.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===l.length)continue;let u=l[0].slot,d=l.at(-1).slot,f=i[u.occupants[0]?.id],h=i[d.occupants[0]?.id];if(!Number.isFinite(f)||!Number.isFinite(h))continue;let g=(f-u.peak.topPeak*n+(h+d.peak.botPeak*n))/2,m=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),p=/* @__PURE__ */new Map;for(let e of c)p.set(e.id,/* @__PURE__ */new Map);let y=new Map(c.map(e=>[e.id,qt(t[e.id])]));for(let e of m){let t=/* @__PURE__ */new Map;for(let r of c){let{sample:i}=y.get(r.id)(e);if(!i||1e-9>=Yt(i))continue;let n=a[r.id];if(null==n)continue;let o=t.get(n)??[];o.push({node:r,sample:i}),t.set(n,o)}let r=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Yt(e)))}));if(0===r.length)continue;let l=g-(r.reduce((e,t)=>e+t.mass,0)*n+Math.max(0,o)*Math.max(0,r.length-1))/2;for(let t of r){for(let{node:r,sample:a}of t.active){let t=(l-i[r.id])/n+a.topMass-(a.boundaryOffset??0);p.get(r.id).set(e,t)}l+=t.mass*n+Math.max(0,o)}}for(let e of c){let r=t[e.id],a=s[e.id],i=p.get(e.id),n=y.get(e.id),o=[];for(let e of m){let t=i.get(e),{exact:r,sample:a}=n(e);r?o.push(...r.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!a||1e-9>=Yt(a)||o.push({...a,t:e,boundaryOffset:(a.boundaryOffset??0)+t})}a.samples=o,a.localAttachments=new Map([...r.localAttachments].map(([e,t])=>{let r=i.get(t.time);return[e,{...t,...null!=r?{boundaryOffset:(t.boundaryOffset??0)+r}:{}}]}))}}return s}function Vt(e,t,r,a,i){let{plotH:n,padding:o,valueScale:l,packing:s,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:f=0,ribbonLane:h="both",domain:g}=i,m=Oe(),p=Oe();for(let t of e)m[t.id]=r[t.id].topPeak||0,p[t.id]=r[t.id].botPeak||0;let y="half"===u,b=Oe();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,r=Array.isArray(t.xExtent)?t.xExtent[1]:null,i=null!=e&&Number.isFinite(e)?e:1/0,n=null!=r&&Number.isFinite(r)?r:-1/0;for(let e of a.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);let t=y?(e.startTime+e.endTime)/2:e.endTime;t>n&&(n=t)}for(let e of a.incoming[t.id]){let t=y?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>n&&(n=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>n&&(n=e.systemOutTime)}b[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(n)?n:null}}let v=Oe(),k=[],x=[];if(i.frozenSlots){let e=Pt(i.frozenSlots,r,b);k=e.slots,v=e.slotByNode,x=k.map(Be)}else if("reuse"===s){let a=Xt(e,t,r,b);k=a.slots,v=a.slotByNode}else e.forEach((e,t)=>{k.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:m[e.id],botPeak:p[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});yt(k,v),0===x.length&&(x=k.map(Be));let S=null;i.frozenSlots||(i.fixedSlotOrder?Lt(k,v,i.fixedSlotOrder):i.runOrdering&&c&&"insertion"!==c&&(S=Mt(e,t,r,b,k,v,{plotH:n,padding:o,valueScale:l,groupPadding:f,laneOrder:c,ribbonLane:h,domain:g}))),yt(k,v);let w=ze(e,t,r,k,v,{plotH:n,padding:o,valueScale:l,stackValueScale:i.stackValueScale,lanePlacement:d,groupPadding:f}),M=0===k.length?0:k[0].peak.topPeak+w.adjacentClearance.reduce((e,t)=>e+t,0)+k[k.length-1].peak.botPeak,L=S?.before.crossings??null,P=S?.after.crossings??null,T=S?.before.weightedLength??null,A=S?.after.weightedLength??null;return{effectiveSlotsHeight:M,centerlines:w.centerlines,laneLifetime:b,slots:k,slotByNode:v,slotCenter:w.slotCenter,stackCenter:w.stackCenter,verticalUtilization:w.verticalUtilization,selectedSlotOrder:k.map(Be),initialSlotOrder:x,ordering:S,crossingsBefore:L,crossingsAfter:P,lengthBefore:T,lengthAfter:A}}function Kt(e,t,r){let{plotH:a,pairing:i="temporal",packing:n="reuse",laneOrder:o="crossing-min",lifetimeMode:l="half",maxValueScale:s,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:f="both",domain:h}=r,g=Number.isFinite(d)?Math.max(0,d):0,m=rt(e,t),p=at(e,t,m,i),y=Oe();for(let t of e)y[t.id]=it(t,m,p,void 0,u);let b=Vt(e,t,y,m,{plotH:a,padding:12,valueScale:1,packing:n,laneOrder:o,lifetimeMode:l,runOrdering:!0,lanePlacement:"stack",groupPadding:g,ribbonLane:f,domain:h}),v=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),k=/* @__PURE__ */new Set;for(let e of t){let t=b.slotByNode[e.source],r=b.slotByNode[e.target];if(void 0===t||void 0===r)continue;let a=p.get(e.id);t!==r?t>r?(a.sourceSide="top",a.targetSide="bot"):(a.sourceSide="bot",a.targetSide="top"):(k.add(e.id),a.sourceSide="bot",a.targetSide="bot")}for(let t of e){let e=m.outgoing[t.id],r=m.incoming[t.id],a=new Set(e.map(e=>p.get(e.id).sourceSide)),i=new Set(r.map(e=>p.get(e.id).targetSide));if(1===a.size&&r.length>0){let e=[...a][0];for(let t of r)b.slotByNode[t.source]===b.slotByNode[t.target]&&(p.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){let t=[...i][0];for(let r of e)b.slotByNode[r.source]===b.slotByNode[r.target]&&(p.get(r.id).sourceSide=t)}}lt(t,p,b.slotByNode),st(e,m,p,k),y=Oe();for(let t of e)y[t.id]=it(t,m,p,void 0,u);let x=Vt(e,t,y,m,{plotH:a,padding:12,valueScale:1,packing:n,laneOrder:o,lifetimeMode:l,frozenSlots:v,lanePlacement:"stack",groupPadding:g,ribbonLane:f,domain:h}),S=x.effectiveSlotsHeight??x.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),w=x.slots.slice(0,-1).reduce((e,t,r)=>e+(null!=t.group&&t.group===x.slots[r+1].group?1:0),0),M=Math.max(1,x.slots.length+1-w),L=Math.min(12,Math.max(0,.35*a-w*g)/M),P=2*L+$e(x.slots,L,g).reduce((e,t)=>e+t,0),T=S>0?Math.max(0,(a-P)/S):1,A=Number.isFinite(s)&&s>0?Math.min(T,s):T,D=Vt(e,t,y,m,{plotH:a,padding:L,valueScale:A,packing:n,laneOrder:o,lifetimeMode:l,frozenSlots:v,lanePlacement:c,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T}),I=Number.isFinite(s)&&s>0&&T>s+1e-12;if("insertion"!==o&&("hug"===c||I)&&D.slots.length>1&&(Mt(e,t,y,D.laneLifetime,D.slots,D.slotByNode,{plotH:a,padding:L,valueScale:A,groupPadding:g,laneOrder:o,ribbonLane:f,domain:h,lanePlacement:c,mode:"geometry-refine"}),D=Vt(e,t,y,m,{plotH:a,padding:L,valueScale:A,packing:n,laneOrder:o,lifetimeMode:l,frozenSlots:D.slots,fixedSlotOrder:D.slots.map(Be),lanePlacement:c,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T})),ot(m,p)){let r=nt(t,y,D.centerlines,A);y=Oe();for(let t of e)y[t.id]=it(t,m,p,r,u);D=Vt(e,t,y,m,{plotH:a,padding:L,valueScale:A,packing:n,laneOrder:o,lifetimeMode:l,frozenSlots:D.slots,fixedSlotOrder:D.slots.map(Be),lanePlacement:c,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T})}let C=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),E=[...D.slots].sort((e,t)=>(C.get(Be(e))??1/0)-(C.get(Be(t))??1/0)||Ne(Be(e),Be(t))),O=Oe();E.forEach((e,t)=>{for(let r of e.occupants)O[r.id]=t});let N=ze(e,t,y,E,O,{plotH:a,padding:L,valueScale:A,stackValueScale:T,lanePlacement:"stack",groupPadding:g}),B=Ut(e,y,E,O,N.centerlines,A,g),$=Ke(xt(O,t),St(O,t),t,B,E,O,N.centerlines,D.laneLifetime,A,N.verticalUtilization,f,h);y=Ut(e,y,D.slots,D.slotByNode,D.centerlines,A,g);let H=Ke(xt(D.slotByNode,t),St(D.slotByNode,t),t,y,D.slots,D.slotByNode,D.centerlines,D.laneLifetime,A,D.verticalUtilization,f,h);return{nodeData:y,sides:p,valueScale:A,padding:L,compressedPadding:12>L,centerlines:D.centerlines,laneLifetime:D.laneLifetime,slots:D.slots,slotByNode:D.slotByNode,crossingsBefore:"insertion"===o?null:$.crossings,crossingsAfter:"insertion"===o?null:H.crossings,lengthBefore:"insertion"===o?null:$.weightedLength,lengthAfter:"insertion"===o?null:H.weightedLength,layoutQualityBefore:$,layoutQuality:H}}function Qt(e,t,r,a="horizontal"){return"vertical"===a?{top:e?38:t?28:16,right:24,bottom:24,left:r?72:24}:{top:e?30:t?24:8,right:80,bottom:r?28:8,left:80}}function Zt(e){let t=e.layout,r=e.nodes,a=e.orientation,i=e.plotW,n=e.plotH,o=e.timelineExtent,l=e.axisTicks,s=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,f=e.colorOf,h=e.toTime,g=e.xScale,{centerlines:m,laneLifetime:p,nodeData:y,valueScale:b,compressedPadding:v,crossingsBefore:k,crossingsAfter:x,layoutQualityBefore:S,layoutQuality:w}=t,M=null,L=null;for(let e of r){let t=p[e.id];if(!t||null===t.start||null===t.end)continue;let r=g(t.start),a=g(t.end);(null===M||M>r)&&(M=r),(null===L||a>L)&&(L=a)}let P=e=>Math.max(0,Math.min(o,e)),T=P(M??0),A=Math.max(T,P(L??o)),D=l.map((e,t)=>({tick:e,index:t,coordinate:g(h(e.date))})).filter(({coordinate:e})=>e>=T-.5&&A+.5>=e),I=null!==(x??null)&&null!=S&&null!=w,C=s&&(I||u.length>0)?/* @__PURE__ */In("g",{fill:On,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */In(An,{children:[
|
|
3
|
+
/* @__PURE__ */In("text",{x:i,y:-14,children:["crossings: ",k," → ",x," ","pixel length: ",Math.round(S.pixelLength)," → ",Math.round(w.pixelLength)]}),
|
|
4
|
+
/* @__PURE__ */In("text",{x:i,y:-3,children:["transit: ",S.transitOcclusion.toFixed(1)," → ",w.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*w.verticalUtilization),"%"]})]}),u.map((e,t)=>/* @__PURE__ */In("text",{x:i,y:I?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,E=v?/* @__PURE__ */Dn("text",{x:i,y:"vertical"===a?-3:2,fontSize:10,fill:On,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,O=(e,t)=>f?f(e,t):Cn;/* @__PURE__ */
|
|
5
|
+
return In("g","vertical"===a?{children:[C,E,D.map(({index:e,coordinate:t})=>/* @__PURE__ */Dn("line",{x1:0,y1:t,x2:i,y2:t,stroke:Cn,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&r.map((e,t)=>{let r=p[e.id];if(!r||null===r.start)return null;let a=y[e.id],i=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},n=m[e.id]+(i.botPeak-i.topPeak)*b/2,o=g(r.start),l=g(r.end),s=O(e.id,t);/* @__PURE__ */
|
|
6
|
+
return In("g",{children:[
|
|
7
|
+
/* @__PURE__ */Dn("line",{x1:n,y1:o,x2:n,y2:l,stroke:s,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
|
|
8
|
+
/* @__PURE__ */Dn("line",{x1:n-4,y1:o,x2:n+4,y2:o,stroke:s,strokeOpacity:.5}),
|
|
9
|
+
/* @__PURE__ */Dn("line",{x1:n-4,y1:l,x2:n+4,y2:l,stroke:s,strokeOpacity:.5})]},"lane-"+e.id)}),
|
|
10
|
+
/* @__PURE__ */Dn("line",{x1:-4,y1:T,x2:-4,y2:A,stroke:Cn}),D.map(({tick:e,index:t,coordinate:r})=>{let a=h(e.date),i=null!=e.label?e.label:d?d(new Date(a)):"";/* @__PURE__ */
|
|
11
|
+
return In("g",{transform:`translate(-4,${r})`,children:[
|
|
12
|
+
/* @__PURE__ */Dn("line",{x2:-6,stroke:Cn}),
|
|
13
|
+
/* @__PURE__ */Dn("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:En,children:i})]},t)})]}:{children:[C,E,D.map(({index:e,coordinate:t})=>/* @__PURE__ */Dn("line",{x1:t,y1:0,x2:t,y2:n,stroke:Cn,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&r.map((e,t)=>{let r=p[e.id];if(!r||null===r.start)return null;let a=y[e.id],i=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},n=m[e.id]+(i.botPeak-i.topPeak)*b/2,o=g(r.start),l=g(r.end),s=O(e.id,t);/* @__PURE__ */
|
|
14
|
+
return In("g",{children:[
|
|
15
|
+
/* @__PURE__ */Dn("line",{x1:o,y1:n,x2:l,y2:n,stroke:s,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
|
|
16
|
+
/* @__PURE__ */Dn("line",{x1:o,y1:n-4,x2:o,y2:n+4,stroke:s,strokeOpacity:.5}),
|
|
17
|
+
/* @__PURE__ */Dn("line",{x1:l,y1:n-4,x2:l,y2:n+4,stroke:s,strokeOpacity:.5})]},"lane-"+e.id)}),
|
|
18
|
+
/* @__PURE__ */Dn("line",{x1:T,y1:n+4,x2:A,y2:n+4,stroke:Cn}),D.map(({tick:e,index:t,coordinate:r})=>{let a=h(e.date),i=null!=e.label?e.label:d?d(new Date(a)):"";/* @__PURE__ */
|
|
19
|
+
return In("g",{transform:`translate(${r},${n+4})`,children:[
|
|
20
|
+
/* @__PURE__ */Dn("line",{y2:6,stroke:Cn}),
|
|
21
|
+
/* @__PURE__ */Dn("text",{y:20,textAnchor:"middle",fontSize:11,fill:En,children:i})]},t)})]})}function Jt(e,t,r,a,i,n,o,l,s={}){let c,u,d,f,h=i,g=e=>l?Math.max(l[0],Math.min(l[1],e)):e,m=n(g(e.time)),p=n(g(r.time)),y=e.value*h,b=r.value*h,v=t+(e.boundaryOffset??0)*h,k=a+(r.boundaryOffset??0)*h,x=e.sideMassBefore*h,S=r.sideMassAfter*h;"top"===e.side?(c=v-x,u=c+y):(u=v+x,c=u-y),"top"===r.side?(d=k-S,f=d+b):(f=k+S,d=f-b);let w=s.sourceRunwayStart,M=s.minRun,L=Math.abs((d+f)/2-(c+u)/2),P=p-m,T="number"==typeof w&&Number.isFinite(w),A="number"==typeof M&&Number.isFinite(M)&&M>0;if(T&&L>1e-9&&P>0&&("auto"===M||A)){let t="source"===o?.85:"target"===o?.15:.5,r="auto"===M?Math.min(144,Math.sqrt(8*L/(1.5*Math.min(t*t,(1-t)*(1-t))))):M;if(r>P){let t=n(g(Math.min(w,e.time)));Number.isFinite(t)&&(m=Math.min(m,Math.max(Math.min(m,t),p-r)))}}let D="source"===o?m+.85*(p-m):"target"===o?m+.15*(p-m):(m+p)/2;return{sx:m,sTop:c,sBot:u,tx:p,tTop:d,tBot:f,cp1X:D,cp2X:D}}function er(e,t,r,a,i,n){let o=new Map(t),l=/* @__PURE__ */new Map;for(let t of e){let e=n?.get(t.source),r=null==e?"node:"+t.source:"group:"+e,a=l.get(r)??/* @__PURE__ */new Map,i=a.get(t.startTime)??[];i.push(t),a.set(t.startTime,i),l.set(r,a)}for(let e of l.values())for(let[n,l]of e){if(!l.some(e=>r.has(e.id)))continue;let e=l.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let s=a(n),c=Math.min(...e.map(e=>e.sx));if(c>=s-1e-9)continue;let u=Math.max(...l.map(e=>{let t=r.get(e.id);return null==t?s:Math.min(s,a(t))})),d=Math.min(s,Math.max(c,u));for(let e of l){let r=t.get(e.id),a=d+(r.tx-d)*("source"===i?.85:"target"===i?.15:.5);o.set(e.id,{...r,sx:d,cp1X:a,cp2X:a})}}return o}function tr(e,t,r){let a=new Set(t.map(e=>e.target)),i=new Map(e.map(e=>[e.id,e])),n=/* @__PURE__ */new Map;for(let e of t){if(a.has(e.source))continue;let t=n.get(e.source)??[];t.push(e),n.set(e.source,t)}let o=/* @__PURE__ */new Map;for(let t of e){if(!t.group)continue;let e=o.get(t.group)??[];e.push(t),o.set(t.group,e)}let l=/* @__PURE__ */new Set;for(let[e,t]of o){let r=t.flatMap(e=>n.get(e.id)??[]),i=new Set(r.map(e=>e.startTime));r.length>0&&1===i.size&&t.every(e=>{let t=e.xExtent?.[0],i=r[0].startTime;return!a.has(e.id)&&(n.get(e.id)?.length??0)>0&&Number.isFinite(t)&&i>t})&&l.add(e)}let s=/* @__PURE__ */new Map;for(let[e,t]of n){let a=i.get(e);if(a?.group&&!l.has(a.group))continue;let n=a?.xExtent?.[0],o=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=o[0]?.startTime-1,u=null;for(let e=0;o.length>e;){let t=o[e].startTime,a=e+1;for(;o.length>a&&o[a].startTime===t;)a++;for(let t=e;a>t;t++){let e=o[t],a=Number.isFinite(n)&&e.startTime>n,i=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!a&&!i)continue;let l=r[0];a&&(l=Math.max(l,n)),i&&(l=Math.max(l,e.systemInTime)),!a&&i&&Number.isFinite(c)&&(l=Math.max(l,c)),null!=u&&(l=Math.max(l,u)),e.startTime>l&&s.set(e.id,l)}u=t,e=a}}for(let[e,t]of o){if(!l.has(e))continue;let r=t.flatMap(e=>n.get(e.id)??[]);if(!r.every(e=>s.has(e.id))){for(let e of r)s.delete(e.id);continue}let a=Math.max(...r.map(e=>s.get(e.id)));for(let e of r)s.set(e.id,a)}return s}function rr(e,t,r,a,i){let n=/* @__PURE__ */new Map;for(let o of e){if(!r.has(o.id))continue;let e=t.get(o.id);if(!e||e.sx>=a(o.startTime)-1e-9)continue;let l=i(e.sx);Number.isFinite(l)&&o.startTime>l&&n.set(o.id,l)}return n}function ar(e,t,r){let a=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let[e,t]of r??[]){let r=i.get(t)??[];r.push(e),i.set(t,r)}for(let n of e){let e=t.get(n.id);if(null==e||!Number.isFinite(e)||e>=n.startTime)continue;let o=r?.get(n.source),l=null==o?[n.source]:i.get(o)??[n.source];for(let t of l){let r=a.get(t)??/* @__PURE__ */new Map,i=r.get(n.startTime);r.set(n.startTime,null==i?e:Math.min(i,e)),a.set(t,r)}}return a}function ir(e,t){return t&&0!==t.size?e.map(e=>{let r=t.get(e.t);return null==r?e:{...e,t:r}}):e}function nr(e){return Math.max(18,11*e.length*.58)}function or(e){let t=1.22*nr(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function lr(e,t){let r=e.labelX-nr(e.labelText),a=t.labelX-nr(t.labelText);return t.labelX+3>=r&&e.labelX+3>=a}function sr(e,t){let r=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;r.length>e;e+=1){let t=8;for(let a=0;e>a;a+=1)lr(r[e],r[a])&&(t=Math.max(t,r[a].labelY+16));r[e].labelY=Math.max(r[e].labelY,t)}for(let e=r.length-1;e>=0;e-=1){let a=t-8;for(let t=e+1;r.length>t;t+=1)lr(r[e],r[t])&&(a=Math.min(a,r[t].labelY-16));r[e].labelY=Math.min(r[e].labelY,a)}}}function cr(e,t,r){let a=e.map(e=>({...e})),i=/* @__PURE__ */new Map;for(let e of a){let r=t[e.id];if(null==r)continue;let a=i.get(r)??[];a.push(e),i.set(r,a)}let n=e=>{if(2>e.length)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,a=(e.length-1)/2;e.forEach((e,i)=>{e.labelY=Math.max(8,Math.min(r-8,t+16*(i-a)))})};for(let e of i.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=-1/0;for(let a of e){let e=a.labelX-nr(a.labelText);t.length>0&&e>r+3&&(n(t),t=[],r=-1/0),t.push(a),r=Math.max(r,a.labelX)}n(t)}return sr(a,r),a}function ur(e,t,r){let a=e.map(e=>({...e}));for(let e of a){let r=1.22*nr(e.labelText)+4;e.labelX=t-4>r?Math.max(r/2+2,Math.min(t-r/2-2,e.labelX)):t/2}let i=[],n=[...a].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of n){let t=i[i.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?i.push([e]):t.push(e)}for(let e of i){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],a=/* @__PURE__ */new Map;for(let r of e){let[e,i]=or(r),n=t.findIndex(t=>e>t+8);-1===n&&(n=t.length),t[n]=i,a.set(r,n)}let i=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=14*t.length+8>i;for(let t of e){let e=a.get(t)??0;t.labelY=n?Math.min(r-8,12+14*e):Math.max(8,i-14*e)}}return a}function dr(e,t,r,a,i={}){if(!1===a)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===a)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let n=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*r)/14e3)));Number.isFinite(i.maxLabels)&&i.maxLabels>=0&&(n=Math.min(n,Math.floor(i.maxLabels)));let o=e.map((e,t)=>{let r=i.priorityById?.get(e.id),a=Math.abs(e.labelY);return{band:e,index:t,score:null!=r&&Number.isFinite(r)?1e6*r+nr(e.labelText):nr(e.labelText)+.01*a}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),l=new Set(o.slice(0,n).map(e=>e.band.id));return e.map(e=>l.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}function fr(e){return e.replace(Wn,(e,t,r)=>`${r},${t}`)}function hr(e){if(!e)return;let t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function gr(e){return{...e,pathD:fr(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function mr(e,t){return"horizontal"===t?e:{...e,pathD:fr(e.pathD),gradientStubs:e.gradientStubs?.map(gr),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function pr(e,t){return"horizontal"===t?e:{...e,pathD:fr(e.pathD),bezier:hr(e.bezier)}}function yr(e){let{nodes:t,edges:r,domain:a,plotW:i,plotH:n,ribbonLane:o,ribbonMinRun:l=0,edgeOpacity:s,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:f=!0,labelPriorityAccessor:h,maxLabels:g,selectionDatum:m="raw",styleRules:p,colorBy:y,valueAccessor:b,usageMode:v="static"}=e,k="vertical"===d?n:i,x="vertical"===d?i:n,S=ve(t,r,a,{usageMode:v}),{fatal:w,warnings:M}=be(S),L=ke(r,S,v),P=Fn().domain(a).range([0,k]);if(w.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==f},issues:w,warnings:M,xScale:P};let T=Kt(t,L,{plotH:x,...u,ribbonLane:o,domain:a}),{centerlines:A,nodeData:D,valueScale:I}=T,C=Ka(y,b),E=[],O=[],N=0===l?/* @__PURE__ */new Map:tr(t,L,a),B=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),$=/* @__PURE__ */new Map;for(let e of L){let t=D[e.source]?.localAttachments.get(e.id),r=D[e.target]?.localAttachments.get(e.id);!t||!r||$.set(e.id,Jt(t,A[e.source],r,A[e.target],I,P,o,a,{minRun:l,sourceRunwayStart:N.get(e.id)}))}let H=er(L,$,N,P,o,B),R=rr(L,H,N,P,e=>a[0]+e/k*(a[1]-a[0])),F=ar(L,R,B);t.forEach((e,t)=>{let r=D[e.id];if(!r||0===r.samples.length)return;let i=ir(r.samples,F.get(e.id)),n=et(i,A[e.id],I,P,a);if(!n)return;let o,l,s=Ze(i,a),u=s.find(e=>e.topMass+e.botMass>0)||s[0],f=A[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*I/2,h=c(e.id,t),g=h,m=.5,y=e.__raw??e;if(p&&p.length>0){let e=Qa(y,p,C(y));"string"==typeof e.fill?h=e.fill:null!=e.fill&&pi(e.fill)&&(l=e.fill,h=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:h),"string"==typeof e.stroke&&(g=e.stroke),"number"==typeof e.strokeWidth&&(m=e.strokeWidth),"number"==typeof e.fillOpacity&&(o=e.fillOpacity),"number"==typeof e.opacity&&null==o&&(o=e.opacity)}let b=tt(e.id,L,T,P,a,R);E.push({id:e.id,pathD:n,fill:h,stroke:g,strokeWidth:m,...null!=o&&{fillOpacity:o},...l&&{hatchFill:l},...b.length>0&&{gradientStubs:b},rawDatum:y,labelX:P("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:f,labelText:e.label??e.id})});let W=/* @__PURE__ */new Map;t.forEach((e,t)=>W.set(e.id,t)),L.forEach(e=>{let t=H.get(e.id);if(!t)return;let r=W.get(e.source)??0,a=c(e.source,r),{pathD:i,bezier:n}=ge(t),o=e.__raw??e,l="function"==typeof s?Number(s(o)):s,u=Number.isFinite(l)?Math.max(0,Math.min(1,l)):.35;O.push({id:e.id,pathD:i,fill:a,opacity:u,rawDatum:o,bezier:n})});let _=cr(E,T.slotByNode,x).map(e=>mr(e,d)),z="vertical"===d?ur(_,i,n):_,j=/* @__PURE__ */new Map;if(null!=h)for(let e of t){let t=e.__raw??e,r="function"==typeof h?h(t):Number(t[h]);Number.isFinite(r)&&j.set(e.id,r)}let X=dr(z,i,n,f,{...j.size>0&&{priorityById:j},...null!=g&&{maxLabels:g}});return{layout:T,layoutConfig:{bands:X,ribbons:O.map(e=>pr(e,d)),showLabels:!1!==f,selectionDatum:m},issues:[],warnings:M,xScale:P}}function br(e,t,r="reuse",a="crossing-min"){return e*e*("reuse"===r?80:1)+t*t*(a&&"insertion"!==a?40:1)+10*(e+t)}function vr(e,t,r,a="reuse",i="crossing-min",n=5e4){return"sync"!==e&&("worker"===e||br(t,r,a,i)>=n)}function kr(){return"u">typeof window&&"u">typeof Worker}function xr(){return"string"==typeof import.meta.url&&import.meta.url?new Worker(new URL("./processSankeyLayoutWorker.js",import.meta.url),{type:"module",name:"semiotic-process-sankey-layout"}):new Worker(Fa("processSankeyLayoutWorker.js"),{type:"module",name:"semiotic-process-sankey-layout"})}function Sr(e){if(!e)return null;let t=e.sides,r=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:r}}function wr(e,t){return kr()?jn.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}function Mr(e,t,r){let a=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),i=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:r.get(e.id)??{id:e.id}})),n=_n().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:a,ribbons:i,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:n}}function Lr(e){if(!e||0===e.length)return!1;for(let t of e)if("function"==typeof t.when||"function"==typeof t.style)return!0;return!1}function Pr(e){return!!(Lr(e.styleRules)||"function"==typeof e.edgeOpacity||"function"==typeof e.labelPriorityAccessor||e.styleRules&&e.styleRules.length>0&&("function"==typeof e.colorBy||"function"==typeof e.valueAccessor))}function Tr(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function Ar(e){let t=Tr(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function Dr(e){let t=Tr(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}function Ir(e,t,r){return{input:{nodes:e.nodes.map(Ar),edges:e.edges.map(Dr),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:r}}async function Cr(e,t){let{execution:r="auto",workerThreshold:a,signal:i,colorById:n,fallbackPalette:o=["#475569"],rawNodeById:l=/* @__PURE__ */new Map,rawEdgeById:s=/* @__PURE__ */new Map}=t,c=e.layoutOpts.packing??"reuse",u=e.layoutOpts.laneOrder??"crossing-min";if(!kr()||Pr(e)||!vr(r,e.nodes.length,e.edges.length,c,u,a))return yr(e);try{return Mr(await wr(Ir(e,n,o),i),l,s)}catch(t){if("AbortError"===t?.name)throw t;return yr(e)}}function Er(e,t,r){return!(typeof window>"u"||!kr()||Pr(e))&&vr(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",r)}function Or(e,t){let r=oi(),{execution:a="auto",workerThreshold:i,colorById:n,fallbackPalette:o,rawNodeById:l,rawEdgeById:s}=t,c=Bn(()=>Object.keys(n).sort().map(e=>`${e}:${n[e]}`).join("|"),[n]),u=Bn(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,c]:"null",[e,c]),d=!!e&&!r&&Er(e,a,i),f=Bn(()=>e?d?null:yr(e):Xn([0,1],1),[u,d,e]),h=$n(r),[g,m]=Hn(()=>e?r?{...yr(e),status:"ready",error:null}:d?{...Xn(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...yr(e),status:"ready",error:null}:{...Xn([0,1],1),status:"ready",error:null});return Nn(()=>{if(h.current)return void(h.current=!1);if(!e||!d)return;let t=new AbortController;return m(e=>({...e,status:"pending",error:null})),Cr(e,{execution:a,workerThreshold:i,signal:t.signal,colorById:n,fallbackPalette:o,rawNodeById:l,rawEdgeById:s}).then(e=>{m({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&m(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[u,d,a,i,o,l,s]),f?{...f,status:"ready",error:null}:g}function Nr(e,t){return"function"==typeof e?e(t):t[e]}function Br(e){let{ref:t,rawNodesProp:r,rawEdgesProp:a,nodeIdAccessor:i,edgeIdAccessor:n,sourceAccessor:o,targetAccessor:l,scalesRef:s,layoutSnapshotRef:u}=e,[d,f]=Un([]),[h,g]=Un([]),m=Gn(d),p=Gn(h);m.current=d,p.current=h;let y=Yn(e=>{m.current=e,f(e)},[]),b=Yn(e=>{p.current=e,g(e)},[]),v=void 0!==a,k=ri(v?a:d),x=qn(()=>{let e=ri(r??[]),t=h;if(0===e.length&&0===t.length)return c([],k,o,l);let a=/* @__PURE__ */new Set,n=[];for(let t of e){let e=Nr(i,t)+"";a.has(e)||(a.add(e),n.push(t))}for(let e of t){let t=Nr(i,e)+"";a.has(t)||(a.add(t),n.push(e))}let s=c([],k,o,l);for(let e of s)a.has(e.id)||(a.add(e.id),n.push(e));return n},[r,h,k,i,o,l]),S=Gn(null),w=Yn((e,t)=>{let r=Nr(n,e);return null!=r?r+"":`${Nr(o,e)}-${Nr(l,e)}-${t}`},[n,o,l]),M=Yn(e=>{if(null==e)return!1;let t=e;return null!=Nr(o,t)&&null!=Nr(l,t)},[o,l]),L=Yn(e=>Nr(i,e)+"",[i]);return Aa(t,{variant:"network",frameRef:S,overrides:{push(e){if(M(e)){if(v)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");y([...m.current,e])}else b([...p.current,e])},pushMany(e){let t=[],r=[];for(let a of e)M(a)?t.push(a):r.push(a);t.length>0&&(v?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):y([...m.current,...t])),r.length>0&&b([...p.current,...r])},remove(e){let t=new Set(Array.isArray(e)?e:[e]),r=[];if(!v){let e=m.current,a=[];for(let i=0;e.length>i;i++){let n=e[i];t.has(w(n,i))?r.push(n):a.push(n)}a.length!==e.length&&y(a)}let a=p.current,n=[];for(let e of a){let a=Nr(i,e)+"";t.has(a)?r.push(e):n.push(e)}return n.length!==a.length&&b(n),r},update(e,t){let r=new Set(Array.isArray(e)?e:[e]),a=[];if(!v){let e=!1,i=m.current.map((i,n)=>r.has(w(i,n))?(a.push(i),e=!0,t(i)):i);e&&y(i)}let n=!1,o=p.current.map(e=>{let o=Nr(i,e)+"";return r.has(o)?(a.push(e),n=!0,t(e)):e});return n&&b(o),a},clear(){v||y([]),b([]),S.current?.clear()},getData:()=>k??[],getScales:()=>s.current,getCustomLayout:()=>u.current}}),{rawNodes:x,rawEdges:k,frameRef:S,getNodeId:L,getEdgeId:w,isControlled:v}}function $r(e){if(!e)return[];let t=/* @__PURE__ */new Set,r=[];for(let a of e.samples){let e=a.topMass+a.botMass,i=`${a.t}:${e}`;t.has(i)||(t.add(i),r.push({t:a.t,total:e}))}return r}function Hr(e,t=5){if(t>=e.length)return e.slice();let r=[...e].sort((e,t)=>e.total-t.total),a=r.length-1,i=[{...r[0],mark:"min"},{...r[Math.floor(.25*a)],mark:"q25"},{...r[Math.floor(.5*a)],mark:"median"},{...r[Math.floor(.75*a)],mark:"q75"},{...r[a],mark:"max"}],n=/* @__PURE__ */new Set,o=[];for(let e of i)n.has(e.t)||(n.add(e.t),o.push(e));return o.sort((e,t)=>e.t-t.t)}function Rr(e,t){return"scene"===t?e:e.data}function Fr(e,t,r){return!t?.isActive||t.predicate(Rr(e,r))}function Wr(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function _r(e){let{tooltip:t,enableHover:r,layout:a,timeFormat:i,valueFormat:n,sourceAccessor:o,targetAccessor:l,valueAccessor:s,startTimeAccessor:c,endTimeAccessor:u}=e,d=Kn(()=>!1!==t&&r&&void 0!==t&&!0!==t&&Ja(t)||null,[t,r]),f=Vn(e=>i?i(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[i]),h=Vn(e=>n?n(e):e+"",[n]);return Vn(e=>{if(!e||!e.data)return null;let t=e.data;if(!Wr(t))return null;let r=t.data;if(d)return d(r);if("band"===t.__kind){let e=t.id,r=a?$r(a.nodeData[e]):[],i=5,n=r.length>i?r.length:null,o=Hr(r,i);/* @__PURE__ */
|
|
22
|
+
return eo("div",{style:{minWidth:160},children:[
|
|
23
|
+
/* @__PURE__ */Jn("div",{style:{fontWeight:600,marginBottom:4},children:e}),o.length>0&&/* @__PURE__ */eo("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[
|
|
24
|
+
/* @__PURE__ */Jn("thead",{children:/* @__PURE__ */eo("tr",{style:{opacity:.6},children:[
|
|
25
|
+
/* @__PURE__ */Jn("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),
|
|
26
|
+
/* @__PURE__ */Jn("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=n&&/* @__PURE__ */Jn("th",{})]})}),
|
|
27
|
+
/* @__PURE__ */Jn("tbody",{children:o.map((e,t)=>/* @__PURE__ */eo("tr",{children:[
|
|
28
|
+
/* @__PURE__ */Jn("td",{style:{paddingRight:8},children:f(e.t)}),
|
|
29
|
+
/* @__PURE__ */Jn("td",{style:{textAlign:"right"},children:h(e.total)}),null!=n&&/* @__PURE__ */Jn("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=n&&/* @__PURE__ */eo("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",o.length," of ",n," samples"]})]})}let i=r,n=Nr(o,i),g=Nr(l,i),m=Nr(s,i),p=Nr(c,i),y=Nr(u,i);/* @__PURE__ */
|
|
30
|
+
return eo("div",{style:{minWidth:160},children:[
|
|
31
|
+
/* @__PURE__ */eo("div",{style:{fontWeight:600,marginBottom:4},children:[n+""," → ",g+""]}),
|
|
32
|
+
/* @__PURE__ */eo("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=m&&/* @__PURE__ */eo(Zn,{children:[
|
|
33
|
+
/* @__PURE__ */Jn("span",{style:{opacity:.6},children:"value"}),
|
|
34
|
+
/* @__PURE__ */Jn("span",{style:{textAlign:"right"},children:h(Number(m))})]}),null!=p&&/* @__PURE__ */eo(Zn,{children:[
|
|
35
|
+
/* @__PURE__ */Jn("span",{style:{opacity:.6},children:"start"}),
|
|
36
|
+
/* @__PURE__ */Jn("span",{style:{textAlign:"right"},children:f(Pe(p))})]}),null!=y&&/* @__PURE__ */eo(Zn,{children:[
|
|
37
|
+
/* @__PURE__ */Jn("span",{style:{opacity:.6},children:"end"}),
|
|
38
|
+
/* @__PURE__ */Jn("span",{style:{textAlign:"right"},children:f(Pe(y))})]})]})]})},[a,d,f,h,o,l,s,c,u])}function zr(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function jr(e){let[t,r,a]=zr(e);return.299*t+.587*r+.114*a>150?"#222":"#fff"}function Xr(e){if(e)return"function"==typeof e?e:t=>t[e]}function Yr(e,t,r){let a=t.nodeIDAccessor;return"function"==typeof a?a(e.data)+"":"string"==typeof a&&void 0!==e.data[a]?e.data[a]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function qr(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Gr(e){return"number"==typeof e?e:5}function Ur(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:ho}function Vr(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Kr(t,r,a,i,n,o){let l=[],s=[],c=[],u=a.treeOrientation||"vertical",d="radial"===u,f=i[0]/2,h=i[1]/2,g=Gr(a.nodeSize);for(let r of t){let t=r.x,i=r.y;d&&(t+=f,i+=h);let o=n(e(r,"nodeStyle")),s=o.fill||Vr(a);if(a.colorByDepth&&void 0!==r.depth){let e=Ur(a);s=e[r.depth%e.length]}l.push({type:"circle",cx:t,cy:i,r:g,style:{fill:s,stroke:o.stroke||a.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor},datum:r,id:r.id,label:r.id,depth:r.depth})}let m=a.edgeOpacity??.5;for(let t of r){let r="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!r||!i)continue;let n=r.x,l=r.y,c=i.x,g=i.y;d&&(n+=f,l+=h,c+=f,g+=h);let p=Jr(n,l,c,g,u),y=o(e(t,"edgeStyle"));s.push({type:"curved",pathD:p,style:{fill:"none",stroke:y.stroke||a.themeSemantic?.border||a.themeSemantic?.secondary||"#999",strokeWidth:y.strokeWidth??1.5,opacity:y.opacity??m,cursor:y.cursor},datum:t})}if(!1!==a.showLabels){let e=qr(a.nodeLabel);for(let r of t){let t=e?e(r):r.id;if(!t)continue;let a,i,n,o=r.x,l=r.y;if(d&&(o+=f,l+=h),d){let e=o-f,t=l-h,r=Math.sqrt(e*e+t*t);r>0?(a=o+e/r*10,i=l+t/r*10,n=0>e?"end":"start"):(a=o,i=l-12,n="middle")}else"horizontal"===u?(r.data?.children&&0!==r.data.children.length?(a=o-g-6,n="end"):(a=o+g+6,n="start"),i=l):(a=o,i=l+g+14,n="middle");c.push({x:a,y:i,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:l,sceneEdges:s,labels:c}}function Qr(t,r,a,i){let n=[],o=[];for(let a of t){let t=a.x1-a.x0,o=a.y1-a.y0;if(0>=t||0>=o)continue;let l=i(e(a,"nodeStyle")),s=l.fill||Vr(r);if(r.colorByDepth&&void 0!==a.depth){let e=Ur(r);s=e[a.depth%e.length]}n.push({type:"rect",x:a.x0,y:a.y0,w:t,h:o,style:{fill:s,stroke:l.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:l.strokeWidth??1,opacity:l.opacity,fillOpacity:l.fillOpacity,strokeOpacity:l.strokeOpacity,cursor:l.cursor},datum:a,id:a.id,label:a.id,depth:a.depth})}if(!1!==r.showLabels){let a=qr(r.nodeLabel),n=r.labelMode||"leaf",l="partition"===r.chartType;for(let s of t){let t=s.x1-s.x0,c=s.y1-s.y0;if(0>=t||0>=c)continue;let u=!(s.data?.children&&s.data.children.length>0);if(!l&&("leaf"===n&&!u||"parent"===n&&u))continue;let d=a?a(s):s.id;if(!d)continue;if((u?30:40)>t||(u?16:14)>c)continue;let f=i(e(s,"nodeStyle")).fill||Vr(r);if(r.colorByDepth&&void 0!==s.depth){let e=Ur(r);f=e[s.depth%e.length]}let h="string"==typeof f?jr(f):r.themeSemantic?.text??"#000";o.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:n,sceneEdges:[],labels:o}}function Zr(t,r,a,i){let n=[],o=[];for(let a of t){let t=a.__radius??5;if(0>=t)continue;let o=i(e(a,"nodeStyle")),l=o.fill||Vr(r);if(r.colorByDepth&&void 0!==a.depth){let e=Ur(r);l=e[a.depth%e.length]}n.push({type:"circle",cx:a.x,cy:a.y,r:t,style:{fill:l,stroke:o.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7,cursor:o.cursor},datum:a,id:a.id,label:a.id,depth:a.depth})}if(!1!==r.showLabels){let a=qr(r.nodeLabel);for(let n of t){let t=n.__radius??5,l=a?a(n):n.id;if(!l||15>t)continue;let s=!(n.data?.children&&n.data.children.length>0),c=i(e(n,"nodeStyle")).fill||Vr(r);if(r.colorByDepth&&void 0!==n.depth){let e=Ur(r);c=e[n.depth%e.length]}if(s){let e="string"==typeof c?jr(c):r.themeSemantic?.text??"#000";o.push({x:n.x,y:n.y,text:l+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else o.push({x:n.x,y:n.y-t+14,text:l+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:r.themeSemantic?.text||"#000",stroke:r.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:n,sceneEdges:[],labels:o}}function Jr(e,t,r,a,i){if("horizontal"===i){let i=(e+r)/2;return`M ${e},${t} C ${i},${t} ${i},${a} ${r},${a}`}if("radial"===i){let i=(e+r)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+a)/2} T ${r},${a}`}{let i=(t+a)/2;return`M ${e},${t} C ${e},${i} ${r},${i} ${r},${a}`}}function ea(e,t,r,a){let i=t.treeOrientation||"vertical",n=oo();n.size("horizontal"===i?[a,r]:"radial"===i?[2*Math.PI,Math.min(r,a)/2*.8]:[r,a]),n(e)}function ta(e,t,r,a){let i=t.treeOrientation||"vertical",n=lo();n.size("horizontal"===i?[a,r]:"radial"===i?[2*Math.PI,Math.min(r,a)/2*.8]:[r,a]),n(e)}function ra(e,t,r,a){let i=t.padding??4,n=t.paddingTop??0,o=so().size([r,a]).tile(fo).padding(i);n>0&&o.paddingTop(n),o(e)}function aa(e,t,r,a){let i=t.padding??4;co().size([r,a]).padding(i)(e)}function ia(e,t,r,a){uo().size([r,a]).padding(t.padding??1)(e)}function na(e,t,r){let a=r.treeOrientation||"vertical";if("radial"===a){let r=t.x,a=t.y;e.x=a*Math.cos(r-Math.PI/2),e.y=a*Math.sin(r-Math.PI/2)}else"horizontal"===a?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function oa(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function la(e,t){let r=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}function sa(e){let t=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:r,margin:a,className:i,layout:n="tree",orientation:c="vertical",childrenAccessor:d="children",valueAccessor:h="value",nodeIdAccessor:g="name",colorBy:m,colorScheme:p,colorByDepth:y=!1,styleRules:b,edgeStyle:v="curve",nodeLabel:k,nodeSize:x=5,tooltip:S,frameProps:w={},onObservation:M,onClick:L,chartId:P,selection:T,linkedHover:A,loading:D,loadingContent:I,legendInteraction:C,legendPosition:E,stroke:O,strokeWidth:N,opacity:B}=e,{width:$,height:H,enableHover:R,showLegend:F,showLabels:W=!0,title:_,description:z,summary:j,accessibleTable:X}=t,Y=f({nodes:io(()=>s(r??null,d),[r,d]),edges:void 0,inferNodes:!1,colorBy:y?void 0:m,colorScheme:p,showLegend:F,legendPosition:E,legendInteraction:C,frameLegend:w,selection:T,linkedHover:A,onObservation:M,onClick:L,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:P,marginDefaults:t.marginDefaults,userMargin:a,width:$,height:H,hasTitle:!!_,loading:D,loadingContent:I}),q=io(()=>/* @__PURE__ */new Map,[]),G=io(()=>e=>{let t={stroke:"black",strokeWidth:1};return t.fill=y?gi[(e.depth||0)%gi.length]:m?mi(e.data||e,m,Y.colorScale):qa(void 0,Y.themeCategorical,p,void 0,q),t},[m,y,Y.colorScale,Y.themeCategorical,p,q]),U=io(()=>Ka(m,h),[m,h]),V=io(()=>Za(G,b,U,e=>e.data||e),[G,b,U]),K=io(()=>Ha(V,{stroke:O,strokeWidth:N,opacity:B}),[V,O,N,B]),Q=io(()=>o(K,Y.effectiveSelectionHook,Y.resolvedSelection),[K,Y.effectiveSelectionHook,Y.resolvedSelection]),Z=io(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),J=io(()=>Ha(Z,{stroke:O,strokeWidth:N,opacity:B}),[Z,O,N,B]),ee=io(()=>l(J,Y.effectiveSelectionHook,Y.resolvedSelection),[J,Y.effectiveSelectionHook,Y.resolvedSelection]),te=io(()=>{if("treemap"===n||"circlepack"===n||"partition"===n)return u(h)},[n,h]),re=La({componentName:"TreeDiagram",data:r});return re?/* @__PURE__ */mo(ei,{componentName:"TreeDiagram",message:re,width:$,height:H}):Y.loadingEl?Y.loadingEl:/* @__PURE__ */mo(ti,{componentName:"TreeDiagram",width:$,height:H,children:/* @__PURE__ */mo(Ia,{chartType:n,...null!=r&&{data:r},size:[$,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Y.margin,...Y.legendBehaviorProps,nodeIDAccessor:g,childrenAccessor:d,hierarchySum:te,treeOrientation:c,edgeType:v,nodeStyle:Q,edgeStyle:ee,colorBy:m,colorScheme:Y.effectivePalette,colorByDepth:y,nodeSize:x,nodeLabel:W?k||g:void 0,showLabels:W,enableHover:R,tooltipContent:!1===S?()=>null:Ja(S)||void 0,...$a({linkedHover:A,selection:T,onObservation:M,onClick:L,mobileInteraction:Y.mobileInteraction,customHoverBehavior:Y.customHoverBehavior,customClickBehavior:Y.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:Y.legend,legendPosition:Y.legendPosition,...C&&"none"!==C&&{legendHoverBehavior:Y.legendState.onLegendHover,legendClickBehavior:Y.legendState.onLegendClick,legendHighlightedCategory:Y.legendState.highlightedCategory,legendIsolatedCategories:Y.legendState.isolatedCategories},className:i,title:_,description:z,summary:j,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...w})})}function ca(e){let t=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:r,margin:a,className:i,childrenAccessor:n="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,styleRules:m,labelMode:p="leaf",nodeLabel:y,padding:b=4,paddingTop:v,nodeStyle:k,tooltip:x,frameProps:S={},selection:w,linkedHover:M,onObservation:L,onClick:P,chartId:T,loading:A,loadingContent:D,legendInteraction:I,legendPosition:C,stroke:E,strokeWidth:O,opacity:N}=e,{nodeStyle:B,...$}=S,{width:H,height:R,enableHover:F,showLegend:W,showLabels:_=!0,title:z,description:j,summary:X,accessibleTable:Y}=t,q=f({nodes:po(()=>s(r??null,n),[r,n]),edges:void 0,inferNodes:!1,colorBy:g?void 0:d,colorScheme:h,showLegend:W,legendPosition:C,legendInteraction:I,frameLegend:$,selection:w,linkedHover:M,onObservation:L,onClick:P,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:T,marginDefaults:t.marginDefaults,userMargin:a,width:H,height:R,hasTitle:!!z,loading:A,loadingContent:D}),G=q.customHoverBehavior,U=yo(e=>{if(!e)return G(null);let t=e.data||e;G({data:t?.data||t})},[G]),V=po(()=>/* @__PURE__ */new Map,[]),K=po(()=>e=>{let t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=g?gi[(e.depth||0)%gi.length]:d?mi(e.data||e,d,q.colorScale):qa(void 0,q.themeCategorical,h,void 0,V),t},[d,g,q.colorScale,q.themeCategorical,h,V]),Q=po(()=>Ka(d,l),[d,l]),Z=po(()=>Za(K,m,Q,e=>e.data||e),[K,m,Q]),J=po(()=>k||B?e=>({...Z(e),...B?B(e)??{}:{},...k?k(e)??{}:{}}):Z,[Z,k,B]),ee=po(()=>Ha(J,{stroke:E,strokeWidth:O,opacity:N}),[J,E,O,N]),te=po(()=>o(ee,q.effectiveSelectionHook,q.resolvedSelection),[ee,q.effectiveSelectionHook,q.resolvedSelection]),re=po(()=>u(l),[l]),ae=void 0!==v?v:!_||"parent"!==p&&"all"!==p?void 0:18,ie=La({componentName:"Treemap",data:r});return ie?/* @__PURE__ */bo(ei,{componentName:"Treemap",message:ie,width:H,height:R}):q.loadingEl?q.loadingEl:/* @__PURE__ */bo(ti,{componentName:"Treemap",width:H,height:R,children:/* @__PURE__ */bo(Ia,{chartType:"treemap",...null!=r&&{data:r},size:[H,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:q.margin,...q.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:n,hierarchySum:re,padding:b,paddingTop:ae,nodeStyle:te,colorBy:d,colorScheme:q.effectivePalette,colorByDepth:g,nodeLabel:_?y||c:void 0,showLabels:_,labelMode:p,enableHover:F,tooltipContent:!1===x?()=>null:Ja(x)||void 0,...$a({linkedHover:M,selection:w,onObservation:L,onClick:P,mobileInteraction:q.mobileInteraction,customHoverBehavior:U,customClickBehavior:q.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:q.legend,legendPosition:q.legendPosition,...I&&"none"!==I&&{legendHoverBehavior:q.legendState.onLegendHover,legendClickBehavior:q.legendState.onLegendClick,legendHighlightedCategory:q.legendState.highlightedCategory,legendIsolatedCategories:q.legendState.isolatedCategories},className:i,title:z,description:j,summary:X,accessibleTable:Y,...null!=e.animate&&{animate:e.animate},...$})})}function ua(e){let t=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:r,margin:a,className:i,childrenAccessor:n="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,styleRules:m,nodeLabel:p,circleOpacity:y=.7,padding:b=4,tooltip:v,frameProps:k={},onObservation:x,onClick:S,chartId:w,selection:M,linkedHover:L,loading:P,loadingContent:T,legendInteraction:A,legendPosition:D,stroke:I,strokeWidth:C,opacity:E}=e,{width:O,height:N,enableHover:B,showLegend:$,showLabels:H=!0,title:R,description:F,summary:W,accessibleTable:_}=t,z=f({nodes:vo(()=>s(r??null,n),[r,n]),edges:void 0,inferNodes:!1,colorBy:g?void 0:d,colorScheme:h,showLegend:$,legendPosition:D,legendInteraction:A,frameLegend:k,selection:M,linkedHover:L,onObservation:x,onClick:S,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:w,marginDefaults:t.marginDefaults,userMargin:a,width:O,height:N,hasTitle:!!R,loading:P,loadingContent:T}),j=vo(()=>/* @__PURE__ */new Map,[]),X=vo(()=>e=>{let t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=g?gi[(e.depth||0)%gi.length]:d?mi(e.data||e,d,z.colorScale):qa(void 0,z.themeCategorical,h,void 0,j),t},[d,g,z.colorScale,y,z.themeCategorical,h,j]),Y=vo(()=>Ka(d,l),[d,l]),q=vo(()=>Za(X,m,Y,e=>e.data||e),[X,m,Y]),G=vo(()=>Ha(q,{stroke:I,strokeWidth:C,opacity:E}),[q,I,C,E]),U=vo(()=>o(G,z.effectiveSelectionHook,z.resolvedSelection),[G,z.effectiveSelectionHook,z.resolvedSelection]),V=vo(()=>u(l),[l]),K=La({componentName:"CirclePack",data:r});return K?/* @__PURE__ */ko(ei,{componentName:"CirclePack",message:K,width:O,height:N}):z.loadingEl?z.loadingEl:/* @__PURE__ */ko(ti,{componentName:"CirclePack",width:O,height:N,children:/* @__PURE__ */ko(Ia,{chartType:"circlepack",...null!=r&&{data:r},size:[O,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:z.margin,...z.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:n,hierarchySum:V,padding:b,nodeStyle:U,colorBy:d,colorScheme:z.effectivePalette,colorByDepth:g,nodeLabel:H?p||c:void 0,showLabels:H,enableHover:B,tooltipContent:!1===v?()=>null:Ja(v)||void 0,...$a({linkedHover:L,selection:M,onObservation:x,onClick:S,mobileInteraction:z.mobileInteraction,customHoverBehavior:z.customHoverBehavior,customClickBehavior:z.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:z.legend,legendPosition:z.legendPosition,...A&&"none"!==A&&{legendHoverBehavior:z.legendState.onLegendHover,legendClickBehavior:z.legendState.onLegendClick,legendHighlightedCategory:z.legendState.highlightedCategory,legendIsolatedCategories:z.legendState.isolatedCategories},className:i,title:R,description:F,summary:W,accessibleTable:_,...null!=e.animate&&{animate:e.animate},...k})})}function da(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:"u">typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function fa(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function ha(e){if("function"==typeof e)return e;let t=e||"children";return e=>e[t]||null}function ga(e){if("function"==typeof e)return e;let t=e||"name";return e=>(e[t]??"")+""}function ma(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function pa(e,t,r,a,i){function n(e){let t=g.get(e)??0;return g.set(e,t+1),0===t?e:`${e}__${t}`}let o=ha(r.childrenAccessor),l=ga(r.nodeIDAccessor),s=fa(r.orbitMode),c=r.orbitSize??2.95,u=r.orbitEccentricity??1,d="number"==typeof c?()=>c:c,f="number"==typeof u?()=>u:u,h=da(r);h.metaMap.clear(),a.length=0,i.length=0;let g=/* @__PURE__ */new Map,m=t[0]/2,p=t[1]/2,y=Math.min(t[0],t[1])/2*.85,b=n(l(e));a.push({id:b,x:m,y:p,x0:m,x1:m,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,c,u,g,m,p){let y=o(t);if(!y?.length)return;let b=y.length,v=0,k=0,x=0;for(;b>k;)k+=s[Math.min(x,s.length-1)],x++,v++;let S=0;for(let b=0;v>b;b++){let k=s[Math.min(b,s.length-1)],x=y.slice(S,S+k);if(!x.length)break;let w=(b+1)/v,M={id:r,depth:m,data:t,parentId:r},L=p?g/d(M)*w:g*w,P=So().value(e=>o(e)?.length?4:1).sort(null)(x),T=f(M);for(let t=0;x.length>t;t++){let o=(P[t].startAngle+P[t].endAngle)/2,s=x[t],d=n(l(s)),f=c+L*Math.sin(o),g=u+L*Math.cos(o)*T;a.push({id:d,x:f,y:g,x0:f,x1:f,y0:g,y1:g,width:0,height:0,value:0,depth:m,data:s}),h.metaMap.set(d,{ring:L,angle:o,depth:m,parentId:r,eccentricity:T}),i.push({source:r,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:d}}),e(s,d,f,g,L,m+1,!0)}S+=k}}(e,b,m,p,y,1,!1)}function ya(e,t,r,a){let i=da(t),n=t.orbitSpeed??.25,o=t.orbitRevolution??ma(t.orbitRevolutionStyle),l=(("u">typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=n*(Math.PI/6),c=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,t);for(let t of e){let e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;let r=c.get(e.parentId);if(!r)continue;let a=e.angle+l*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(a),t.y=r.y+e.ring*Math.cos(a)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}function ba(e){let t=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:r,margin:a,className:i,childrenAccessor:n="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,styleRules:h,orbitMode:g="flat",orbitSize:m=2.95,speed:p=.25,revolution:y,revolutionStyle:b,eccentricity:v=1,showRings:k=!0,nodeRadius:x=6,showLabels:S=!1,animated:w=!0,tooltip:M,foregroundGraphics:L,annotations:P,frameProps:T={},onObservation:A,onClick:D,chartId:I,selection:C,linkedHover:E,loading:O,loadingContent:N,legendPosition:B,legendInteraction:$,stroke:H,strokeWidth:R,opacity:F}=e,{width:W,height:_,enableHover:z,showLegend:j,title:X,description:Y,summary:q,accessibleTable:G}=t,U=f({nodes:xo(()=>s(r,n),[r,n]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:j,legendPosition:B,legendInteraction:$,frameLegend:T,selection:C,linkedHover:E,onObservation:A,onClick:D,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:I,marginDefaults:si(t),userMargin:a,width:W,height:_,hasTitle:!!X,loading:O,loadingContent:N}),V=xo(()=>/* @__PURE__ */new Map,[]),{colorScale:K,customClickBehavior:Q,customHoverBehavior:Z,themeCategorical:J}=U,ee=xo(()=>{if(Array.isArray(u))return u;let e=di[u];return Array.isArray(e)?e:fi},[u]),te=xo(()=>e=>{let t={stroke:"#fff",strokeWidth:1},r=0===(e.depth??0);return t.fill=d?r?ee[0]:Lo[(e.depth||0)%Lo.length]:c?mi(e.data||e,c,K):qa(void 0,J,u,void 0,V),t.opacity=r?1:.85,t},[c,d,K,ee,J,u,V]),re=xo(()=>Ka(c,"value"),[c]),ae=xo(()=>Za(te,h,re,e=>e.data||e),[te,h,re]),ie=xo(()=>Ha(ae,{stroke:H,strokeWidth:R,opacity:F}),[ae,H,R,F]),ne=xo(()=>o(ie,U.effectiveSelectionHook,U.resolvedSelection),[ie,U.effectiveSelectionHook,U.resolvedSelection]),oe=xo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),le=xo(()=>e=>{Z(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Z]),se=xo(()=>e=>{Q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Q]),ce=La({componentName:"OrbitDiagram",data:r});return ce?/* @__PURE__ */Mo(ei,{componentName:"OrbitDiagram",message:ce,width:W,height:_}):U.loadingEl?U.loadingEl:/* @__PURE__ */Mo(ti,{componentName:"OrbitDiagram",width:W,height:_,children:/* @__PURE__ */Mo(Ia,{chartType:"orbit",...null!=r&&{data:r},size:[W,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:U.margin,...U.legendBehaviorProps,nodeIDAccessor:l,childrenAccessor:n,nodeStyle:ne,edgeStyle:oe,colorBy:c,colorScheme:U.effectivePalette,colorByDepth:d,nodeSize:x,nodeLabel:S?l:void 0,showLabels:S,enableHover:!w&&z,tooltipContent:w?void 0:!1===M?()=>null:Ja(M)||void 0,...$a({linkedHover:E,selection:C,onObservation:A,onClick:D,mobileInteraction:U.mobileInteraction,customHoverBehavior:le,customClickBehavior:se,linkedHoverInClickPredicate:!1}),legend:U.legend,legendPosition:U.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},foregroundGraphics:L,annotations:P,className:i,title:X,description:Y,summary:q,orbitMode:g,orbitSize:m,orbitSpeed:p,orbitRevolution:y,orbitRevolutionStyle:b,orbitEccentricity:v,orbitShowRings:k,orbitAnimated:w,accessibleTable:G,...null!=e.animate&&{animate:e.animate},...T})})}function va(e,t,r={}){let a=r.iterations??260,i=r.repulsion??5200,n=r.linkDistance??165,o=r.linkStrength??.045,l=r.centerStrength??.018,s=r.damping??.84,c=r.nodeRadius??12,u=r.nodePadding??3,d=r.inset??.06,f=Ra(r.seed??1),h=/* @__PURE__ */new Map;for(let t of e)h.set(t.id,0);for(let e of t)h.set(e.source,(h.get(e.source)??0)+1),h.set(e.target,(h.get(e.target)??0)+1);let g=500,m=e.map(e=>({id:e.id,data:e,x:200+600*f(),y:200+600*f()})),p=e=>"function"==typeof c?c(e.data):c,y=new Set(e.map(e=>e.id)),b=t.filter(e=>y.has(e.source)&&y.has(e.target)).map(e=>({source:e.source,target:e.target}));if(a>0){let e=No(m).randomSource(f).alphaDecay(1-Math.pow(.001,1/a)).velocityDecay(Math.max(0,Math.min(1,1-s))).force("charge",Oo().strength(e=>{let t=h.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",Co(e=>p(e)+u).strength(.9).iterations(2)).force("center",Io(g,g).strength(.8)).force("x",Bo(g).strength(l)).force("y",$o(g).strength(l));b.length>0&&e.force("link",Eo(b).id(e=>e.id).distance(n).strength(e=>{let t="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(h.get("string"==typeof e.source?e.source:e.source.id)??1,h.get(t)??1));return o/.045/r})),e.stop();for(let t=0;a>t;t+=1)e.tick()}let v=1/0,k=1/0,x=-1/0,S=-1/0;for(let e of m){let t=e.x??g,r=e.y??g;v>t&&(v=t),k>r&&(k=r),t>x&&(x=t),r>S&&(S=r)}let w=x-v,M=S-k,L={};for(let e of m)Object.defineProperty(L,e.id,{value:{x:0===w?.5:d+((e.x??g)-v)/w*(1-2*d),y:0===M?.5:d+((e.y??g)-k)/M*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return L}import{a as ka,b as xa,c as Sa,d as wa}from"./c-HLGTD5SJ.min.js";import{b as Ma}from"./c-YL7HJL5J.min.js";import{c as La,d as Pa}from"./c-IBRLFKWA.min.js";import{a as Ta,c as Aa}from"./c-FMCUQ6JX.min.js";import{a as Da,b as Ia}from"./c-RWHLEUX6.min.js";import{a as Ca}from"./c-YMFUIO54.min.js";import{a as Ea}from"./c-TIDKVMMZ.min.js";import{e as Oa,f as Na}from"./c-U5XVLSHN.min.js";import{X as Ba,Y as $a,_ as Ha}from"./c-SAP5KY6R.min.js";import{a as Ra}from"./c-RHDOOQ4X.min.js";import{a as Fa}from"./c-LVHJJUOF.min.js";import{B as Wa,Bb as _a,Cb as za,Db as ja,Ea as Xa,Fb as Ya,Ib as qa,Jb as Ga,Lb as Ua,Nb as Va,Qb as Ka,Tb as Qa,Ub as Za,Va as Ja,_a as ei,ab as ti,b as ri,bb as ai,cb as ii,jb as ni,ka as oi,sb as li,tb as si,w as ci}from"./c-UMGHCBH5.min.js";import{a as ui,l as di,m as fi,o as hi,q as gi,r as mi}from"./c-Y342FJ6K.min.js";import{r as pi}from"./c-3BYZXCX3.min.js";import{b as yi}from"./c-3PFVJFBK.min.js";import{useMemo as bi,forwardRef as vi,useRef as ki}from"react";import{forceSimulation as xi,forceCenter as Si,forceX as wi,forceY as Mi,forceLink as Li,forceManyBody as Pi,forceCollide as Ti}from"d3-force";var Ai=/* @__PURE__ */new Set,Di=/* @__PURE__ */new WeakMap,Ii={supportsStreaming:!0,hierarchical:!1,computeLayout(e,i,n,o){if(0===e.length)return;let l=n.forceStrength??.1,s=o[0]/2,c=o[1]/2,u=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),d=Math.min(.5,.06+1.8*(1-u)),f=n.__previousPositions,h=0,g=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=f?.get(t.id);e?h++:r?(t.x=r.x,t.y=r.y,h++):g.push(t)}let m=h>0&&.3>=(e.length>0?g.length/e.length:1);if(m){let r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,t);for(let e of g){let n=t(e.id,i,r);if(n.length>0){let t=0,r=0;for(let e of n)t+=e.x,r+=e.y;let i=a(e.id),o=i%360*(Math.PI/180),l=(10+i%20)*u;e.x=t/n.length+l*Math.cos(o),e.y=r/n.length+l*Math.sin(o)}else{let t=a(e.id),r=t%360*(Math.PI/180),i=(15+t%30)*u;e.x=s+i*Math.cos(r),e.y=c+i*Math.sin(r)}}}else{let t=2.399963229728653;for(let r=0;e.length>r;r++){let a=e[r];if(null==a.x||null==a.y||0===a.x&&0===a.y){let e=10*Math.sqrt(r+.5)*u,i=r*t;a.x=s+e*Math.cos(i),a.y=c+e*Math.sin(i)}}}let p=n.__skipForceSimulation||0===n.iterations?0:m?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),y=Ca(n.nodeSize,n.nodeSizeRange,e),b=e=>y(e);if(p>0){let t=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map;for(let r of e)t.set(r.id,0),a.set(r.id,r);for(let e of i){let r=Na(e.source),a=Na(e.target);t.set(r,(t.get(r)??0)+1),t.set(a,(t.get(a)??0)+1)}let f=Li().strength(e=>{let r=e.weight,a=Na(e.source),i=Na(e.target),n=Math.max(1,Math.min(t.get(a)??1,t.get(i)??1));return Math.min(2.5,(r&&r>0?Math.sqrt(r):1)*l/(.1*n))}).distance(e=>{let t="string"==typeof e.source?a.get(e.source):e.source,r="string"==typeof e.target?a.get(e.target):e.target,i=(t?b(t):0)+(r?b(r):0)+Math.max(6,12*u);return Math.max(16,40*u,i)}).id(e=>e.id),h=xi();if((void 0!==n.random||void 0!==n.seed)&&h.randomSource(n.random??Xa(n.seed)),h.force("charge",Pi().strength(e=>{let r=t.get(e.id)??0;return-15*u*b(e)*Math.sqrt(r+1)})).force("collide",Ti(e=>b(e)+3*u).strength(.9).iterations(2)).force("center",Si(s,c).strength(.8)).force("x",wi(s).strength(d)).force("y",Mi(c).strength(d)).force("bounds",r(o,b)),h.nodes(e),i.length>0){let e=i.map(e=>({...e,source:Na(e.source),target:Na(e.target)}));f.links(e),h.force("link",f)}m?h.alpha(.3):.1>h.alpha()&&h.alpha(1),h.stop();for(let e=0;p>e;++e)h.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=b(t),r=p>0?2:0,a=Math.min(o[0]/2,e+r),i=Math.min(o[1]/2,e+r);t.x=Math.max(a,Math.min(o[0]-a,t.x)),t.y=Math.max(i,Math.min(o[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let v=/* @__PURE__ */new Map;for(let t of e)v.set(t.id,t);for(let e of i){if("string"==typeof e.source){let t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=v.get(e.target);t&&(e.target=t)}}},buildScene(t,r,a,i){let n=a.nodeStyle,o=a.edgeStyle,l=Ca(a.nodeSize,a.nodeSizeRange,t),s=Array.isArray(a.colorScheme)?a.colorScheme:a.themeCategorical&&a.themeCategorical.length>0?a.themeCategorical:ui,c=/* @__PURE__ */new Map;t.forEach((e,t)=>{c.set(e.id,s[t%s.length])});let u=[],d=[],f=[];for(let r of t){if(null==r.x||null==r.y)continue;let t=l(e(r,"nodeSize")),i=n?n(e(r,"nodeStyle")):{},o={fill:i.fill||c.get(r.id)||a.themeSemantic?.primary||"#007bff",stroke:i.stroke||a.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity,cursor:i.cursor};u.push({type:"circle",cx:r.x,cy:r.y,r:t,style:o,datum:r,id:r.id,label:r.id})}let h=/* @__PURE__ */new Map;for(let e of t)h.set(e.id,e);for(let t of r){let r="object"==typeof t.source?t.source:h.get(t.source),i="object"==typeof t.target?t.target:h.get(t.target);if(!r||!i||null==r.x||null==r.y||null==i.x||null==i.y)continue;let n=o?o(e(t,"edgeStyle")):{};d.push({type:"line",x1:r.x,y1:r.y,x2:i.x,y2:i.y,style:{stroke:n.stroke||a.themeSemantic?.border||a.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6,cursor:n.cursor},datum:t})}if(!1!==a.showLabels){let r=Oa(a.nodeLabel);for(let a of t){if(null==a.x||null==a.y)continue;let t=r?r(a):a.id;if(!t)continue;let i=l(e(a,"nodeSize"));f.push({x:a.x,y:a.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:u,sceneEdges:d,labels:f}}};Da("force",Ii);import{useCallback as Ci,useMemo as Ei,useState as Oi}from"react";var Ni="__streamNetworkCategory";import{jsx as Bi}from"react/jsx-runtime";Da("force",Ii);var $i=vi(function(e,t){let r=ki(null);Aa(t,{variant:"network",frameRef:r});let a=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:i,edges:n,margin:s,className:c,nodeIdAccessor:u,nodeIDAccessor:d,sourceAccessor:h="source",targetAccessor:g="target",nodeLabel:m,colorBy:p,colorScheme:y,styleRules:b,nodeSize:v=8,nodeSizeRange:k=[5,20],nodeStroke:x,nodeStrokeWidth:S,edgeWidth:w,edgeColor:M,edgeOpacity:L,iterations:P=300,forceStrength:T=.1,layoutExecution:A="auto",layoutLoadingContent:D,onLayoutStateChange:I,tooltip:C,frameProps:E={},onObservation:O,onClick:N,chartId:B,selection:$,linkedHover:H,loading:R,loadingContent:F,emptyContent:W,legendInteraction:_,legendPosition:z,stroke:j,strokeWidth:X,opacity:Y}=e,q=u??d??"id",{width:G,height:U,enableHover:V,showLegend:K,showLabels:Q=!1,title:Z,description:J,summary:ee,accessibleTable:te}=a,re=f({nodes:i,edges:n,inferNodes:!1,nodeIdAccessor:q,sourceAccessor:h,targetAccessor:g,colorBy:p,colorScheme:y,showLegend:K,legendPosition:z,legendInteraction:_,frameLegend:E,selection:$,linkedHover:H,onObservation:O,onClick:N,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ForceDirectedGraph",chartId:B,marginDefaults:a.marginDefaults,userMargin:s,width:G,height:U,hasTitle:!!Z,loading:R,loadingContent:F,emptyContent:W,emptyDataKey:"nodes"}),ae=bi(()=>/* @__PURE__ */new Map,[]),ie=bi(()=>e=>{let t={};return t.fill=p?mi(e.data||e,p,re.colorScale):qa(void 0,re.themeCategorical,y,void 0,ae),"number"==typeof v&&(t.r=v),t},[p,re.colorScale,v,re.themeCategorical,y,ae]),ne=bi(()=>Ka(p,"number"==typeof v?void 0:v),[p,v]),oe=bi(()=>Ha(Za(ie,b,ne,e=>e.data||e),{stroke:x??j,strokeWidth:S??X,opacity:Y}),[ie,b,ne,x,j,S,X,Y]),le=bi(()=>o(oe,re.effectiveSelectionHook,re.resolvedSelection),[oe,re.effectiveSelectionHook,re.resolvedSelection]),se=M??j??"#999",ce=L??Y??.6,ue=X??1,de=bi(()=>e=>{let t,r=e.data||e;if(void 0===w)t=ue;else if("number"==typeof w)t=w;else if("function"==typeof w)t=w(r);else{let e=r[w],a="number"==typeof e?e:Number(e);t=Number.isFinite(a)&&a>0?a:ue}return{stroke:se,strokeWidth:t,opacity:ce}},[w,se,ce,ue]),fe=bi(()=>l(de,re.effectiveSelectionHook,re.resolvedSelection),[de,re.effectiveSelectionHook,re.resolvedSelection]),he=bi(()=>{if(Q&&m)return"function"==typeof m?m:e=>e.data?.[m]??e[m]??e.id},[Q,m]),ge=Pa({componentName:"ForceDirectedGraph",nodes:i,edges:n,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:q}});return ge?/* @__PURE__ */Bi(ei,{componentName:"ForceDirectedGraph",message:ge,width:G,height:U}):re.loadingEl?re.loadingEl:re.emptyEl?re.emptyEl:/* @__PURE__ */Bi(ti,{componentName:"ForceDirectedGraph",width:G,height:U,children:/* @__PURE__ */Bi(Ia,{ref:r,chartType:"force",...null!=i&&{nodes:re.safeNodes},...null!=n&&{edges:re.safeEdges},size:[G,U],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:re.margin,...re.legendBehaviorProps,nodeIDAccessor:q,sourceAccessor:h,targetAccessor:g,iterations:P,forceStrength:T,layoutExecution:A,layoutLoadingContent:D,onLayoutStateChange:I,nodeStyle:le,edgeStyle:fe,colorBy:p,colorScheme:re.effectivePalette,nodeSize:v,nodeSizeRange:k,nodeLabel:he,showLabels:Q,enableHover:V,tooltipContent:!1===C?()=>null:Ja(C)||void 0,...$a({linkedHover:H,selection:$,onObservation:O,onClick:N,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:re.legend,legendPosition:re.legendPosition,..._&&"none"!==_&&{legendHoverBehavior:re.legendState.onLegendHover,legendClickBehavior:re.legendState.onLegendClick,legendHighlightedCategory:re.legendState.highlightedCategory,legendIsolatedCategories:re.legendState.isolatedCategories},className:c,title:Z,description:J,summary:ee,accessibleTable:te,...null!=e.animate&&{animate:e.animate},...E})})});$i.displayName="ForceDirectedGraph";import{useMemo as Hi,forwardRef as Ri,useRef as Fi}from"react";import{chord as Wi,ribbon as _i}from"d3-chord";import{arc as zi}from"d3-shape";var ji=ui,Xi={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,a){if(0===e.length)return;let{padAngle:i=.01,groupWidth:n=20,sortGroups:o}=r,l=Math.min(a[0],a[1])/2,s=l-n,c=a[0]/2,u=a[1]/2,d=h(r.valueAccessor),f=/* @__PURE__ */new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);let g=e.length,m=Array.from({length:g},()=>Array(g).fill(0));for(let e of t){let t=Na(e.source),r=Na(e.target),a=f.get(t),i=f.get(r);if(void 0===a||void 0===i)continue;let n=d(e);m[a][i]=n}let p=Wi().padAngle(i);o&&p.sortGroups(o);let y=p(m),b=y.groups,v=zi().innerRadius(s).outerRadius(l);for(let t of b){let r=e[t.index],a=v.centroid({innerRadius:s,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});r.x=a[0]+c,r.y=a[1]+u,r.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}let k=/* @__PURE__ */new Map;for(let t of e)k.set(t.id,t);for(let e of t){let t=Na(e.source),r=Na(e.target),a=k.get(t),i=k.get(r);a&&(e.source=a),i&&(e.target=i)}let x=/* @__PURE__ */new Map;for(let e of t){let t=Na(e.source),r=Na(e.target);x.set(`${t}\0${r}`,e)}for(let t of y){let r=e[t.source.index].id,a=e[t.target.index].id,i=x.get(`${r}\0${a}`)||x.get(`${a}\0${r}`);i&&(i.__chordData=t)}},buildScene(t,r,a,i){let{groupWidth:n=20,edgeOpacity:o=.5}=a,l=Math.min(i[0],i[1])/2,s=l-n,c=i[0]/2,u=i[1]/2,d=a.nodeStyle,f=a.edgeStyle,h=a.edgeColorBy||"source",m=Array.isArray(a.colorScheme)?a.colorScheme:a.themeCategorical&&a.themeCategorical.length>0?a.themeCategorical:ji,p=/* @__PURE__ */new Map;t.forEach((e,t)=>{p.set(e.id,m[t%m.length])});let y=_i().radius(s),b=[],v=[],k=[];for(let r=0;t.length>r;r++){let a=t[r],i=a.__arcData;if(!i)continue;let n=d?d(e(a,"nodeStyle")):{},o={fill:("string"==typeof n.fill?n.fill:void 0)||p.get(a.id)||m[r%m.length],stroke:n.stroke||"black",strokeWidth:n.strokeWidth??1,opacity:n.opacity,cursor:n.cursor};b.push({type:"arc",cx:c,cy:u,innerR:s,outerR:l,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:o,datum:a,id:a.id,label:a.id})}for(let t of r){let r=t.__chordData;if(!r)continue;let i=y(r);if(!i)continue;let n=g(i,c,u),l=a.themeSemantic?.border||a.themeSemantic?.secondary||"#999",s=f?f(e(t,"edgeStyle")):{};if(f)l=("string"==typeof s.fill?s.fill:void 0)||l;else{let e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;"target"===h&&r?l=p.get(r.id)||l:e&&(l=p.get(e.id)||l)}v.push({type:"ribbon",pathD:n,style:{fill:l,fillOpacity:s.fillOpacity??o,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity,cursor:s.cursor},datum:t})}if(!1!==a.showLabels){let e=Oa(a.nodeLabel),r=l+12;for(let a of t){let t=a.__arcData;if(!t)continue;let i=e?e(a):a.id;if(!i)continue;let n=(t.startAngle+t.endAngle)/2,o=n-Math.PI/2;k.push({x:c+Math.cos(o)*r,y:u+Math.sin(o)*r,text:i+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:b,sceneEdges:v,labels:k}}};Da("chord",Xi);import{jsx as Yi}from"react/jsx-runtime";Da("chord",Xi);var qi=Ri(function(e,t){let r=Fi(null);Aa(t,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});let a=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:i,edges:n,margin:s,className:c,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:m="id",colorBy:p,colorScheme:y,styleRules:b,edgeColorBy:v="source",padAngle:k=.01,groupWidth:x=20,sortGroups:S,nodeLabel:w,edgeOpacity:M=.5,tooltip:L,frameProps:P={},onObservation:T,onClick:A,chartId:D,selection:I,linkedHover:C,loading:E,loadingContent:O,emptyContent:N,legendPosition:B,legendInteraction:$,stroke:H,strokeWidth:R,opacity:F}=e,{width:W,height:_,enableHover:z,showLegend:j,showLabels:X=!0,title:Y,description:q,summary:G,accessibleTable:U}=a,V=f({nodes:i,edges:n,inferNodes:!0,nodeIdAccessor:m,sourceAccessor:u,targetAccessor:h,colorBy:p,colorScheme:y,showLegend:j,legendPosition:B,legendInteraction:$,frameLegend:P,selection:I,linkedHover:C,onObservation:T,onClick:A,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ChordDiagram",chartId:D,marginDefaults:a.marginDefaults,userMargin:s,width:W,height:_,hasTitle:!!Y,loading:E,loadingContent:O,emptyContent:N}),K=Hi(()=>/* @__PURE__ */new Map,[]),Q=Hi(()=>/* @__PURE__ */new Map,[]),Z=V.safeNodes.length>0||V.allCategories.length>0,J=Hi(()=>{if(Z)return(e,t)=>{let r={stroke:"black",strokeWidth:1};if(p)r.fill=mi(e.data||e,p,V.colorScale);else{let a=Array.isArray(y)?y:di[y]||fi,i=Array.isArray(a)?a:fi,n=(e.id??e.data?.[m]??"")+"";Q.has(n)||Q.set(n,Q.size);let o=e.index??t??Q.get(n);r.fill=i[o%i.length]}return r}},[Z,p,V.colorScale,y,m,Q]),ee=Hi(()=>Ka(p),[p]),te=Hi(()=>{if(J||b&&b.length>0)return Ha(Za(J,b,ee,e=>e.data||e),{stroke:H,strokeWidth:R,opacity:F})},[J,b,ee,H,R,F]),re=Hi(()=>o(te,V.effectiveSelectionHook,V.resolvedSelection),[te,V.effectiveSelectionHook,V.resolvedSelection]),ae=Hi(()=>{if(Z)return d({edgeColorBy:v,colorBy:p,colorScale:V.colorScale,nodeStyleFn:re||(e=>({fill:qa(void 0,V.themeCategorical,y,void 0,K)})),edgeOpacity:M,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:M}})},[Z,v,p,V.colorScale,re,M,V.themeCategorical,y,K]),ie=Hi(()=>ae?Ha(ae,{stroke:H,strokeWidth:R,opacity:F}):void 0,[ae,H,R,F]),ne=Hi(()=>l(ie,V.effectiveSelectionHook,V.resolvedSelection),[ie,V.effectiveSelectionHook,V.resolvedSelection]),oe=Hi(()=>{if(!X)return;let e=w||m;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[X,w,m]),le=Pa({componentName:"ChordDiagram",edges:n,edgesRequired:!0});return le?/* @__PURE__ */Yi(ei,{componentName:"ChordDiagram",message:le,width:W,height:_}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:/* @__PURE__ */Yi(ti,{componentName:"ChordDiagram",width:W,height:_,children:/* @__PURE__ */Yi(Ia,{ref:r,chartType:"chord",...V.safeNodes.length>0&&{nodes:V.safeNodes},...null!=n&&{edges:V.safeEdges},size:[W,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:V.margin,...V.legendBehaviorProps,nodeIDAccessor:m,sourceAccessor:u,targetAccessor:h,valueAccessor:g,padAngle:k,groupWidth:x,sortGroups:S,nodeStyle:re,edgeStyle:ne,colorBy:p,colorScheme:V.effectivePalette,edgeColorBy:v,edgeOpacity:M,nodeLabel:oe,showLabels:X,enableHover:z,tooltipContent:!1===L?()=>null:Ja(L)||void 0,...$a({linkedHover:C,selection:I,onObservation:T,onClick:A,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:V.legend,legendPosition:V.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},className:c,title:Y,description:q,summary:G,accessibleTable:U,...null!=e.animate&&{animate:e.animate},...P})})});qi.displayName="ChordDiagram";import{useMemo as Gi,forwardRef as Ui,useRef as Vi}from"react";import{min as Ki}from"d3-array";import{min as Qi,max as Zi,sum as Ji,mean as en,group as tn,groups as rn}from"d3-array";import{interpolateNumber as an}from"d3-interpolate";import{line as nn,curveLinearClosed as on}from"d3-shape";var ln=e=>{let t,r,a,i,n,o,l,s,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,a=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,n=e.source.x1,o=e.target.x0,l=an(n,o),s=l(.5),c=l(.5),`M${t},${n}C${t},${s} ${r},${c} ${r},${o}L${a},${o}C${a},${c} ${i},${s} ${i},${n}Z`;let u=e.sankeyWidth/2,d=an(e.source.x1,e.target.x0),{pathD:f}=ge({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return f},sn={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(C))-1:0},justify:E},cn={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,a){if(0===e.length)return;let i,n="vertical"===r.orientation?"down":"right",o=r.nodeAlign||"justify",l=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.iterations??100,u=e.map(e=>({...e})),d=t.map(e=>({...e,source:Na(e.source),target:Na(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));i="down"===n?[[0,0],[a[1],a[0]]]:[[0,0],[a[0],a[1]]];let f=he().extent(i).links(d).nodes(u).nodeAlign(sn[o]||E).nodeId(e=>e.id).nodeWidth(l).iterations(c);f.nodePaddingRatio&&f.nodePaddingRatio(s),f();{let e=1/0,t=-1/0,r=1/0,i=-1/0;for(let a of u)e>a.x0&&(e=a.x0),a.x1>t&&(t=a.x1),r>a.y0&&(r=a.y0),a.y1>i&&(i=a.y1);for(let a of d){if(!a.circular||!a.circularPathData)continue;let n=a.circularPathData,o=(a._circularWidth??a.width??0)/2;e>n.leftFullExtent-o&&(e=n.leftFullExtent-o),n.rightFullExtent+o>t&&(t=n.rightFullExtent+o),r>n.verticalFullExtent-o&&(r=n.verticalFullExtent-o),n.verticalFullExtent+o>i&&(i=n.verticalFullExtent+o)}let n=t-e,o=i-r,l=a[0],s=a[1];if(n>0&&o>0&&(0>e||0>r||t>l||i>s)){let t=Math.min(l/n,s/o),a=-e*t+(l-n*t)/2,i=-r*t+(s-o*t)/2;for(let e of u)e.x0=e.x0*t+a,e.x1=e.x1*t+a,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(let e of d)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){let r=e.circularPathData;r.sourceX=r.sourceX*t+a,r.targetX=r.targetX*t+a,r.sourceY=r.sourceY*t+i,r.targetY=r.targetY*t+i,r.rightFullExtent=r.rightFullExtent*t+a,r.leftFullExtent=r.leftFullExtent*t+a,r.verticalFullExtent=r.verticalFullExtent*t+i,r.rightInnerExtent=r.rightInnerExtent*t+a,r.leftInnerExtent=r.leftInnerExtent*t+a,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+i,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+i,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}let h=/* @__PURE__ */new Map;for(let t of e)h.set(t.id,t);for(let e of u){let t=h.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}let g=/* @__PURE__ */new Map;for(let e of t)if(e._edgeKey)g.set(e._edgeKey,e);else{let t=Na(e.source),r=Na(e.target);g.set(`${t}\0${r}`,e)}for(let e of d){let t=Na(e.source),r=Na(e.target),a=g.get(e._edgeKey?e._edgeKey:`${t}\0${r}`);if(a){a.y0=e.y0,a.y1=e.y1,a.sankeyWidth=e.width??0,a.circular=!!e.circular,a.circularPathData=e.circularPathData,a._circularWidth=e._circularWidth,a._circularStub=e._circularStub,a.path=e.path,a.circularLinkType=e.circularLinkType,a.direction=n;let i=h.get(t),o=h.get(r);i&&(a.source=i),o&&(a.target=o)}}},buildScene(t,r,a,i){let n="vertical"===a.orientation?"down":"right",o=a.nodeStyle,l=a.edgeStyle,s=a.edgeOpacity??.5,c=a.edgeColorBy||"source",u=Array.isArray(a.colorScheme)?a.colorScheme:a.themeCategorical&&a.themeCategorical.length>0?a.themeCategorical:ui,d=/* @__PURE__ */new Map;t.forEach((e,t)=>{d.set(e.id,u[t%u.length])});let f=[],h=[],g=[],m=/* @__PURE__ */new Map;for(let r of t){let t=r.x1-r.x0,a=r.y1-r.y0;if(0>=t||0>=a)continue;let i=o?o(e(r,"nodeStyle")):{},l={fill:i.fill||d.get(r.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity,cursor:i.cursor};m.set(r.id,("string"==typeof l.fill?l.fill:null)||d.get(r.id)||"#4d430c"),f.push("down"===n?{type:"rect",x:r.y0,y:r.x0,w:a,h:t,style:l,datum:r,id:r.id,label:r.id}:{type:"rect",x:r.x0,y:r.y0,w:t,h:a,style:l,datum:r,id:r.id,label:r.id})}let p=[...r].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let t of p){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;let r="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!r||!i)continue;let n=a.themeSemantic?.border||a.themeSemantic?.secondary||"#999";n="function"==typeof c?c(t)||n:"target"===c?m.get(i.id)||d.get(i.id)||n:m.get(r.id)||d.get(r.id)||n;let o,u=l?l(e(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){let e=t.circularPathData,r=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),i=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),o=u.fill||n;h.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-r}L${e.sourceX+a},${e.sourceY-r}L${e.sourceX+a},${e.sourceY+r}L${e.sourceX},${e.sourceY+r}Z`,style:{fill:o,fillOpacity:u.fillOpacity??s,stroke:"none",opacity:u.opacity,cursor:u.cursor},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),h.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-r}L${e.targetX-i},${e.targetY-r}L${e.targetX-i},${e.targetY+r}L${e.targetX},${e.targetY+r}Z`,style:{fill:o,fillOpacity:u.fillOpacity??s,stroke:"none",opacity:u.opacity,cursor:u.cursor},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-i,x1:e.targetX}});continue}o=t.circular&&t.circularPathData?me(t):ln(t),o&&h.push({type:"bezier",pathD:o,bezierCache:t.bezier,style:{fill:u.fill||n,fillOpacity:u.fillOpacity??s,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity,cursor:u.cursor},datum:t})}if(!1!==a.showLabels){let e=Oa(a.nodeLabel);for(let r of t){let t=r.x1-r.x0,a=r.y1-r.y0;if(0>=t||0>=a)continue;let o,l,s,c=e?e(r):r.id;c&&("down"===n?(o=r.y0+(r.y1-r.y0)/2,l=r.x1+14,s="start"):(i[0]/2>r.x0+t/2?(o=r.x0-6,s="end"):(o=r.x1+6,s="start"),l=r.y0+a/2),g.push({x:o,y:l,text:c+"",anchor:"down"===n?"middle":s,baseline:"middle",fontSize:11}))}}return{sceneNodes:f,sceneEdges:h,labels:g}}};Da("sankey",cn);import{jsx as un}from"react/jsx-runtime";Da("sankey",cn);var dn=Ui(function(e,t){let r=Vi(null);Aa(t,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});let a=Va(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:i,edges:n,margin:s,className:c,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:m="id",colorBy:p,colorScheme:y,styleRules:b,edgeColorBy:v="source",orientation:k="horizontal",nodeAlign:x="justify",nodePaddingRatio:S=.05,nodeWidth:w=15,nodeLabel:M,edgeOpacity:L=.5,edgeSort:P,tooltip:T,frameProps:A={},onObservation:D,onClick:I,chartId:C,selection:E,linkedHover:O,loading:N,loadingContent:B,emptyContent:$,showLegend:H,legendPosition:R,legendInteraction:F,stroke:W,strokeWidth:_,opacity:z}=e,{width:j,height:X,enableHover:Y,showLabels:q=!0,title:G,description:U,summary:V,accessibleTable:K}=a,Q=f({nodes:i,edges:n,inferNodes:!0,nodeIdAccessor:m,sourceAccessor:u,targetAccessor:h,colorBy:p,colorScheme:y,showLegend:H,legendPosition:R,legendInteraction:F,frameLegend:A,selection:E,linkedHover:O,onObservation:D,onClick:I,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"SankeyDiagram",chartId:C,marginDefaults:a.marginDefaults,userMargin:s,width:j,height:X,hasTitle:!!G,loading:N,loadingContent:B,emptyContent:$}),Z=Gi(()=>/* @__PURE__ */new Map,[]),J=Gi(()=>e=>{let t={stroke:"black",strokeWidth:1};return t.fill=p?mi(e.data||e,p,Q.colorScale):qa(void 0,Q.themeCategorical,y,void 0,Z),t},[p,Q.colorScale,Q.themeCategorical,y,Z]),ee=Gi(()=>Ka(p,g),[p,g]),te=Gi(()=>Ha(Za(J,b,ee,e=>e.data||e),{stroke:W,strokeWidth:_,opacity:z}),[J,b,ee,W,_,z]),re=Gi(()=>o(te,Q.effectiveSelectionHook,Q.resolvedSelection),[te,Q.effectiveSelectionHook,Q.resolvedSelection]),ae=Gi(()=>d({edgeColorBy:v,colorBy:p,colorScale:Q.colorScale,nodeStyleFn:re,edgeOpacity:L,baseStyle:{stroke:"none",strokeWidth:0}}),[v,p,Q.colorScale,re,L]),ie=Gi(()=>Ha(ae,{stroke:W,strokeWidth:_,opacity:z}),[ae,W,_,z]),ne=Gi(()=>l(ie,Q.effectiveSelectionHook,Q.resolvedSelection),[ie,Q.effectiveSelectionHook,Q.resolvedSelection]),oe=Gi(()=>{if(!q)return;let e=M||m;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[q,M,m]),le=Pa({componentName:"SankeyDiagram",edges:n,edgesRequired:!0});return le?/* @__PURE__ */un(ei,{componentName:"SankeyDiagram",message:le,width:j,height:X}):Q.loadingEl?Q.loadingEl:Q.emptyEl?Q.emptyEl:/* @__PURE__ */un(ti,{componentName:"SankeyDiagram",width:j,height:X,children:/* @__PURE__ */un(Ia,{ref:r,chartType:"sankey",...Q.safeNodes.length>0&&{nodes:Q.safeNodes},...null!=n&&{edges:Q.safeEdges},size:[j,X],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Q.margin,...Q.legendBehaviorProps,nodeIDAccessor:m,sourceAccessor:u,targetAccessor:h,valueAccessor:g,orientation:k,nodeAlign:x,nodePaddingRatio:S,nodeWidth:w,nodeStyle:re,edgeStyle:ne,colorBy:p,colorScheme:Q.effectivePalette,edgeColorBy:v,edgeOpacity:L,edgeSort:P,nodeLabel:oe,showLabels:q,enableHover:Y,tooltipContent:!1===T?()=>null:Ja(T)||void 0,...$a({linkedHover:O,selection:E,onObservation:D,onClick:I,mobileInteraction:Q.mobileInteraction,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:Q.legend,legendPosition:Q.legendPosition,...F&&"none"!==F&&{legendHoverBehavior:Q.legendState.onLegendHover,legendClickBehavior:Q.legendState.onLegendClick,legendHighlightedCategory:Q.legendState.highlightedCategory,legendIsolatedCategories:Q.legendState.isolatedCategories},className:c,title:G,description:U,summary:V,accessibleTable:K,...null!=e.animate&&{animate:e.animate},...A})})});dn.displayName="SankeyDiagram";var fn={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},hn=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),gn=8,mn=.92,pn=3,yn=e=>{let t=1;for(let r=2;e>=r;r++)t*=r;return t},bn=828*yn(8),vn=3e3,kn=/* @__PURE__ */new Map,xn=1e5,Sn=1e-9;import{forwardRef as wn,useMemo as Mn,useRef as Ln,useCallback as Pn,useEffect as Tn}from"react";import{Fragment as An,jsx as Dn,jsxs as In}from"react/jsx-runtime";var Cn="var(--semiotic-grid, #94a3b8)",En="var(--semiotic-text-secondary, #475569)",On="var(--semiotic-text-secondary, #94a3b8)";import{useEffect as Nn,useMemo as Bn,useRef as $n,useState as Hn}from"react";import{scaleTime as Rn}from"d3-scale";import{scaleTime as Fn}from"d3-scale";var Wn=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;import{scaleTime as _n}from"d3-scale";var zn=class{constructor(e=xr()){this.session=new Sa({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{let t=e,{requestId:r,error:a}=xa(t);return a?{requestId:r,ok:!1,error:ka(a)}:{requestId:r,ok:!0,payload:{layout:Sr(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},jn=wa(()=>new zn),Xn=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:Rn().domain(e).range([0,t])});import{useCallback as Yn,useMemo as qn,useRef as Gn,useState as Un}from"react";import{useCallback as Vn,useMemo as Kn}from"react";var Qn=e=>{let{bands:t=[],ribbons:r=[],showLabels:a=!0,selectionDatum:i="raw"}=e.config,n=e.selection??null,o=[];for(let e of r){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},r=!Fr(t,n,i);o.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:r?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!Fr({__kind:"band",data:e.rawDatum,id:e.id},n,i);for(let r=0;e.gradientStubs.length>r;r++){let a=e.gradientStubs[r];o.push({type:"bezier",pathD:a.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:a.x0,x1:a.x1,...null!=a.y0&&{y0:a.y0},...null!=a.y1&&{y1:a.y1},from:a.from,to:a.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${r}`}})}}for(let e of t){let t=!(!e.gradientStubs||0>=e.gradientStubs.length),r={__kind:"band",data:e.rawDatum,id:e.id},a=!Fr(r,n,i);o.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:a?.22:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...a&&t?{opacity:.22}:{}},datum:r})}let l=a?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),r=e.labelText.trim().length>0,a=t&&n?.isActive&&Fr({__kind:"band",data:e.rawDatum,id:e.id},n,i),o=r?e.labelText:a?e.labelFullText:"";return o.trim()?[{x:e.labelX,y:e.labelY,text:o,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:o,labels:l}};import{Fragment as Zn,jsx as Jn,jsxs as eo}from"react/jsx-runtime";import{jsx as to,jsxs as ro}from"react/jsx-runtime";var ao=wn(function(e,t){let{nodes:r,edges:a,domain:i,axisTicks:n=[],nodeIdAccessor:o="id",nodeLabel:l,sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:u="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:g,systemOutTimeAccessor:m,xExtentAccessor:p="xExtent",groupBy:y,edgeIdAccessor:b="id",colorBy:v,colorScheme:k,showLegend:x,legendPosition:S="right",orientation:w="horizontal",pairing:M="temporal",packing:L="reuse",laneOrder:P="crossing-min",maxValueScale:T,lanePlacement:A="stack",nodeSizing:D="temporal",groupPadding:I=0,ribbonLane:C="both",ribbonMinRun:E=0,lifetimeMode:O="half",showLaneRails:N=!1,showQualityReadout:B=!1,showLabels:$=!0,labelPriorityAccessor:H,maxLabels:R,selectionDatum:F="raw",styleRules:W,layoutExecution:_="auto",layoutWorkerThreshold:z,layoutLoadingContent:j,onLayoutStateChange:X,width:Y=600,height:q=400,margin:G,title:U,description:V,summary:K,accessibleTable:Q,responsiveWidth:Z,responsiveHeight:J,loading:ee,loadingContent:te,emptyContent:re,edgeOpacity:ae=.35,timeFormat:ie,valueFormat:ne,tooltip:oe,enableHover:le=!0,onObservation:se,onClick:ce,selection:ue,linkedHover:de,showParticles:fe=!1,particleStyle:he,chartId:ge,frameProps:me={}}=e,pe=Ln(null),ye=Ln(null),{rawNodes:be,rawEdges:ve,frameRef:ke,getNodeId:Se,getEdgeId:we}=Br({ref:t,rawNodesProp:r,rawEdgesProp:a,nodeIdAccessor:o,edgeIdAccessor:b,sourceAccessor:s,targetAccessor:c,scalesRef:pe,layoutSnapshotRef:ye}),{nodes:Me,edges:Le,domain:Te,rawNodeById:Ae,rawEdgeById:De}=Mn(()=>{let e=(be??[]).map(e=>{let t=Se(e),r=l?Nr(l,e):t,a={id:t,label:null==r?t:r+"",__raw:e},i=y?Nr(y,e):null;null!=i&&i+""!=""&&(a.group=i+"");let n=p?Nr(p,e):null;if(Array.isArray(n)&&2===n.length){let e=Pe(n[0]),t=Pe(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(a.xExtent=[e,t])}return a}),t=(ve??[]).map((e,t)=>{let r={id:we(e,t),source:Nr(s,e)+"",target:Nr(c,e)+"",value:Number(Nr(u,e)),startTime:Pe(Nr(d,e)),endTime:Pe(Nr(h,e)),__raw:e};if(g){let t=Pe(Nr(g,e));Number.isFinite(t)&&(r.systemInTime=t)}if(m){let t=Pe(Nr(m,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),r=[Pe(i[0]),Pe(i[1])],a=/* @__PURE__ */new Map;for(let t of e)null!=t.__raw&&a.set(t.id,t.__raw);let n=/* @__PURE__ */new Map;for(let e of t)null!=e.__raw&&n.set(e.id,e.__raw);return{nodes:e,edges:t,domain:r,rawNodeById:a,rawEdgeById:n}},[be,ve,i,Se,we,l,p,y,s,c,u,d,h,g,m]),Ie=f({nodes:be,edges:ve,inferNodes:!1,nodeIdAccessor:o,sourceAccessor:s,targetAccessor:c,colorBy:v,colorScheme:k,showLegend:!1,legendPosition:S,frameLegend:me,selection:ue,linkedHover:de,onObservation:se,onClick:ce?(e,t)=>{Wr(e)?ce(e.data,t):ce(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:ge,marginDefaults:Qt(!!U,B,n.length>0,w),userMargin:G,width:Y,height:q,hasTitle:!!U,loading:ee,loadingContent:te,emptyContent:re}),Ce=Object.hasOwn(me,"legend"),Ee=!Ce&&(x??!!v)&&!!v,Oe=Pn((e,t)=>{if(v&&be){let t=Ae.get(e);if(t)return mi(t,v,Ie.colorScale)}return Ie.effectivePalette[t%Ie.effectivePalette.length]||"#475569"},[v,be,Ae,Ie.colorScale,Ie.effectivePalette]),Ne=Mn(()=>{if(!Ee||!v)return;let e=/* @__PURE__ */new Map;(be??[]).forEach((t,r)=>{let a=Nr(v,t),i=null==a?"":a+"";!i||e.has(i)||e.set(i,{label:i,color:Oe(Se(t),r)})});let t=Array.from(e.values());return 0===t.length?void 0:{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}},[Ee,v,be,Oe,Se]),Be=Ce?me.legend:Ne,$e=Mn(()=>{let e={...Ie.margin};if(Be){let t={...e};Wa(e,{legend:Be,position:Ie.legendPosition,size:[Y,q],hasTitle:!!U,legendLayout:me.legendLayout,minimumMargin:"right"===Ie.legendPosition||"left"===Ie.legendPosition?140:"top"===Ie.legendPosition?50:80}),ci(e,t,[Y,q],Ie.legendPosition)}return e},[Ie.margin,Ie.legendPosition,Be,Y,q,U,me.legendLayout]),He=Y-$e.left-$e.right,Re=q-$e.top-$e.bottom,Fe="vertical"===w?Re:He,We=Or(Mn(()=>He>0&&Re>0?{nodes:Me,edges:Le,domain:Te,plotW:He,plotH:Re,orientation:w,ribbonLane:C,ribbonMinRun:E,edgeOpacity:"function"==typeof ae?e=>ae(e):ae,colorOf:Oe,showLabels:$,labelPriorityAccessor:H,maxLabels:R,selectionDatum:F,styleRules:W,usageMode:"push",colorBy:v,valueAccessor:u,layoutOpts:{pairing:M,packing:L,laneOrder:P,lifetimeMode:O,maxValueScale:T,lanePlacement:A,nodeSizing:D,groupPadding:I}}:null,[Me,Le,Te,He,Re,w,C,E,ae,Oe,$,H,R,F,W,v,u,M,L,P,O,T,A,D,I]),{execution:_,workerThreshold:z,colorById:Mn(()=>Object.fromEntries(Me.map((e,t)=>[e.id,Oe(e.id,t)])),[Me,Oe]),fallbackPalette:Ie.effectivePalette,rawNodeById:Ae,rawEdgeById:De}),{issues:_e,warnings:ze,layout:je,xScale:Xe}=We,Ye=We.layoutConfig,qe=We.status;pe.current=je?{time:Xe,centerlines:je.centerlines}:{time:Xe},ye.current=je?{layout:je,nodes:Me,edges:Le,bands:Ye.bands,ribbons:Ye.ribbons,warnings:ze,status:qe}:null;let Ge=Ln(X);Ge.current=X,Tn(()=>{Ge.current?.(qe)},[qe]),Tn(()=>{0!==ze.length&&console.warn("ProcessSankey warnings:",ze.map(xe).join("; "))},[ze]);let Ue=void 0!==Be&&!Object.hasOwn(me,"margin"),Ve=_r({tooltip:oe,enableHover:le,layout:je,timeFormat:ie,valueFormat:ne,sourceAccessor:s,targetAccessor:c,valueAccessor:u,startTimeAccessor:d,endTimeAccessor:h}),Ke=Mn(()=>{if(!je)return null;let e=ze.map(e=>xe(e));return Zt({layout:je,nodes:Me,orientation:w,plotW:He,plotH:Re,timelineExtent:Fe,axisTicks:n,showQualityReadout:B,showLaneRails:N,warnings:e,timeFormat:ie?e=>ie(e):void 0,colorOf:Oe,toTime:Pe,xScale:e=>Number(Xe(e))})},[je,Me,w,He,Re,Fe,n,B,N,ze,ie,Oe,Xe]),Qe=Mn(()=>(be??[]).map(e=>({id:Se(e),data:e})),[be,Se]),Ze=Mn(()=>{let e=/* @__PURE__ */new Map;for(let t of Ye.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ye]),Je=Mn(()=>(ve??[]).map((e,t)=>{let r=we(e,t),a=Number(Nr(u,e));return{id:r,source:Nr(s,e)+"",target:Nr(c,e)+"",value:Number.isFinite(a)?a:0,bezier:Ze.get(r),data:e}}),[ve,we,s,c,u,Ze]);return _e.length>0?/* @__PURE__ */ro("svg",{width:Y,height:q,role:"img","aria-label":U??"Process Sankey validation failed",children:[
|
|
39
|
+
/* @__PURE__ */to("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),_e.map((e,t)=>/* @__PURE__ */to("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+xe(e)},t))]}):Ie.loadingEl?Ie.loadingEl:Ie.emptyEl?Ie.emptyEl:/* @__PURE__ */ro("div",{style:{position:"relative",width:Y,height:q},children:["pending"===qe&&!1!==j&&!je&&/* @__PURE__ */to("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:ii(!0,Y,q,j)}),
|
|
40
|
+
/* @__PURE__ */to(Ia,{ref:ke,chartType:"force",nodes:Qe,edges:Je,customNetworkLayout:Qn,layoutConfig:Ye,size:[Y,q],responsiveWidth:Z,responsiveHeight:J,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:$e,title:U,description:V??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:K,accessibleTable:Q,enableHover:le,tooltipContent:!1===oe?()=>null:Ve,backgroundGraphics:Ke,showParticles:fe,particleStyle:he,legend:Be,legendPosition:Ie.legendPosition,...Ue&&{__legendMarginReservedFor:Be},...$a({linkedHover:de,selection:ue,onObservation:se,onClick:ce,mobileInteraction:Ie.mobileInteraction,customHoverBehavior:Ie.customHoverBehavior,customClickBehavior:Ie.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:ge,colorScheme:Array.isArray(k)?k:void 0,layoutSelection:Ie.effectiveSelectionHook,...me})]})});ao.displayName="ProcessSankey";import{useMemo as io}from"react";import{hierarchy as no,tree as oo,cluster as lo,treemap as so,pack as co,partition as uo,treemapBinary as fo}from"d3-hierarchy";var ho=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],go={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,a){let i=r.__hierarchyRoot;if(!i)return;let n=r.chartType,o=Xr(r.childrenAccessor),l=r.hierarchySum,s="function"==typeof l?l:"string"==typeof l?e=>Number(e[l])||0:e=>Number(e.value)||0,c=no(i,o);c.sum(s),c.sort((e,t)=>(t.value??0)-(e.value??0));let[u,d]=a;switch(n){case"tree":ea(c,r,u,d);break;case"cluster":ta(c,r,u,d);break;case"treemap":ra(c,r,u,d);break;case"circlepack":aa(c,r,u,d);break;case"partition":ia(c,r,u,d)}let f=c.descendants();e.length=0,t.length=0;let h=/* @__PURE__ */new Map;for(let t=0;f.length>t;t++){let a=f[t],i={id:Yr(a,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:a.value??0,depth:a.depth,data:a.data,createdByFrame:!0};"tree"===n||"cluster"===n?na(i,a,r):"treemap"===n||"partition"===n?oa(i,a):"circlepack"===n&&la(i,a),i.__hierarchyNode=a,e.push(i),h.set(a,i)}if("tree"===n||"cluster"===n)for(let e of f)if(e.parent){let r=h.get(e.parent),a=h.get(e);r&&a&&t.push({source:r,target:a,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,a){let i=r.nodeStyle||(()=>({})),n=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return Kr(e,t,r,a,i,n);case"treemap":case"partition":return Qr(e,r,0,i);case"circlepack":return Zr(e,r,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};Da("tree",go),Da("cluster",go),Da("treemap",go),Da("circlepack",go),Da("partition",go);import{jsx as mo}from"react/jsx-runtime";Da("tree",go),Da("cluster",go),Da("treemap",go),Da("circlepack",go),Da("partition",go),sa.displayName="TreeDiagram";import{useMemo as po,useCallback as yo}from"react";import{jsx as bo}from"react/jsx-runtime";Da("treemap",go),ca.displayName="Treemap";import{useMemo as vo}from"react";import{jsx as ko}from"react/jsx-runtime";Da("circlepack",go),ua.displayName="CirclePack";import{useMemo as xo}from"react";import{pie as So}from"d3-shape";var wo={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,a){let i=r.__hierarchyRoot;i&&pa(i,a,r,e,t)},buildScene(t,r,a,i){let n=a.nodeStyle,o=a.edgeStyle,l=a.nodeSize,s="number"==typeof l?()=>l:"function"==typeof l?l:()=>6,c=[],u=[],d=[];if(!1!==a.orbitShowRings){let e=da(a),r=/* @__PURE__ */new Map;for(let e of t)r.set(e.id,e);let i=/* @__PURE__ */new Map;for(let[,t]of e.metaMap){if(!t.parentId)continue;let e=r.get(t.parentId);if(!e)continue;let a=`${t.parentId}:${t.ring}`;i.has(a)||i.set(a,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}let n=48,o={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:r,ecc:a}]of i)for(let i=0;n>i;i++){let l=i/n*Math.PI*2,s=(i+1)/n*Math.PI*2;u.push({type:"line",x1:e+r*Math.sin(l),y1:t+r*Math.cos(l)*a,x2:e+r*Math.sin(s),y2:t+r*Math.cos(s)*a,style:o,datum:null})}}for(let r of t){if(null==r.x||null==r.y)continue;let t=s(e(r,"nodeSize")),i=n?n(e(r,"nodeStyle")):{};c.push({type:"circle",cx:r.x,cy:r.y,r:t,style:{fill:i.fill||a.themeSemantic?.primary||"#6366f1",stroke:i.stroke||a.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(r.depth??0)?1:.85),cursor:i.cursor},datum:r,id:r.id,label:r.id,depth:r.depth})}let f=/* @__PURE__ */new Map;for(let e of t)f.set(e.id,e);for(let t of r){let r="object"==typeof t.source?t.source:f.get(t.source),a="object"==typeof t.target?t.target:f.get(t.target);if(!r||!a||null==r.x||null==a.x)continue;let i=o?o(e(t,"edgeStyle")):{};u.push({type:"line",x1:r.x,y1:r.y,x2:a.x,y2:a.y,style:{stroke:i.stroke||"rgba(128,128,128,0.35)",strokeWidth:i.strokeWidth??.5,opacity:i.opacity??1,cursor:i.cursor},datum:t})}if(a.showLabels){let r=a.nodeLabel;for(let a of t){let t=s(e(a,"nodeSize"));if(4>=t)continue;let i="function"==typeof r?r(a):r?a.data?.[r]??a.id:a.id;d.push({x:a.x,y:a.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:u,labels:d}},tick:(e,t,r,a,i)=>!1!==r.orbitAnimated&&(ya(e,r),!0)};Da("orbit",wo);import{jsx as Mo}from"react/jsx-runtime";Da("orbit",wo);var Lo=gi;ba.displayName="OrbitDiagram";import{forwardRef as Po,useMemo as To}from"react";import{jsx as Ao}from"react/jsx-runtime";var Do=Po(function(e,t){let{nodes:r,edges:a,layout:i,layoutConfig:n,onLayoutError:o,nodeIDAccessor:l="id",sourceAccessor:s="source",targetAccessor:c="target",margin:u,className:d,colorBy:f,colorScheme:h,tooltip:g,selection:m,linkedHover:p,onObservation:y,onClick:b,chartId:v,annotations:k,autoPlaceAnnotations:x,frameProps:S={}}=e,{frameRef:w,resolved:M,normalizedMargin:L}=Ma({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),P=To(()=>ri(r),[r]),T=To(()=>ri(a),[a]),A=To(()=>void 0===r&&void 0===a?void 0:[...P,...T],[a,r,T,P]),D=li(e.mobileInteraction,{mode:e.mode,width:M.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:I,customClickBehavior:C,activeSelectionHook:E}=Ua({selection:m,linkedHover:p,fallbackFields:"string"==typeof f?[f]:[],onObservation:y,onClick:b,chartType:"NetworkCustomChart",chartId:v,colorByField:"string"==typeof f?f:void 0,mobileInteraction:D}),O=To(()=>E?.isActive?{isActive:!0,predicate:E.predicate}:null,[E?.isActive,E?.predicate]),{width:N,height:B,enableHover:$,title:H,description:R,summary:F,accessibleTable:W}=M,_=To(()=>Ja(g),[g]),z=ii(e.loading,N,B,e.loadingContent),j=z?null:ai(A,N,B,e.emptyContent);if(z||j)return z||j;let X={chartType:"force",...null!=r&&{nodes:P},...null!=a&&{edges:T},customNetworkLayout:i,layoutConfig:n,onLayoutError:o,nodeIDAccessor:l,sourceAccessor:s,targetAccessor:c,colorBy:f,colorScheme:h,size:[N,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:L,enableHover:$,...Ba({title:H,description:R,summary:F,accessibleTable:W,className:d,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:x}),...!1===g?{tooltipContent:()=>null}:_?{tooltipContent:_}:{},...$a({forceHoverBehavior:null!=v,forceClickBehavior:null!=v,linkedHover:p,selection:m,onObservation:y,onClick:b,mobileInteraction:D,customHoverBehavior:I,customClickBehavior:C,linkedHoverInClickPredicate:!1}),layoutSelection:O,...null!=k&&{annotations:k},...S};/* @__PURE__ */
|
|
41
|
+
return Ao(ti,{componentName:"NetworkCustomChart",width:N,height:B,children:/* @__PURE__ */Ao(Ia,{ref:w,...X})})});Do.displayName="NetworkCustomChart";import{forceCenter as Io,forceCollide as Co,forceLink as Eo,forceManyBody as Oo,forceSimulation as No,forceX as Bo,forceY as $o}from"d3-force";export{Ii as a,$i as b,Xi as c,qi as d,cn as e,dn as f,ve as g,xe as h,Se as i,we as j,Me as k,Le as l,Pe as m,ao as n,go as o,sa as p,ca as q,ua as r,wo as s,ba as t,Do as u,va as v};
|