semiotic 3.8.2 → 3.8.3

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.
Files changed (113) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +34 -33
  3. package/ai/schema.json +1 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/{chunk-chunk-C6EJ4IOD.module.min.js → chunk-chunk-2CCFBTQC.module.min.js} +1 -1
  7. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  8. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  9. package/dist/{chunk-chunk-H4PPRW6N.module.min.js → chunk-chunk-5APBQXZA.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-NO4MCQVD.module.min.js → chunk-chunk-5RKXZQ2P.module.min.js} +1 -1
  11. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  12. package/dist/{chunk-chunk-7LHMKRKE.module.min.js → chunk-chunk-7FW6EGLP.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-RH5TSQPH.module.min.js → chunk-chunk-7OEOSCBP.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-FAKO3RGQ.module.min.js → chunk-chunk-A63CTACR.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  16. package/dist/{chunk-chunk-ZLKRTF5N.module.min.js → chunk-chunk-AZJUDQRM.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-W3DB2MN4.module.min.js → chunk-chunk-B6V35LMY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  19. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  20. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  21. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  22. package/dist/{chunk-chunk-T27ZEV6A.module.min.js → chunk-chunk-GWSWSPXN.module.min.js} +1 -1
  23. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  24. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  25. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  26. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  27. package/dist/{chunk-chunk-Z5KXAVQD.module.min.js → chunk-chunk-L3H6DQCR.module.min.js} +1 -1
  28. package/dist/{chunk-chunk-5WEFWNUW.module.min.js → chunk-chunk-M7VYYHCE.module.min.js} +1 -1
  29. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  30. package/dist/{chunk-chunk-2VUEY5TH.module.min.js → chunk-chunk-N72SWNBV.module.min.js} +1 -1
  31. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  32. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  33. package/dist/{chunk-chunk-2UN3ANRN.module.min.js → chunk-chunk-SA3D43RA.module.min.js} +1 -1
  34. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  35. package/dist/{chunk-chunk-DNY43POY.module.min.js → chunk-chunk-UHSZEB74.module.min.js} +1 -1
  36. package/dist/{chunk-chunk-CYIML3AV.module.min.js → chunk-chunk-XQYVEKEJ.module.min.js} +1 -1
  37. package/dist/{chunk-chunk-27HVVXS6.module.min.js → chunk-chunk-Y6AXCRVO.module.min.js} +1 -1
  38. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  40. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  41. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  42. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  43. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  44. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  45. package/dist/components/charts/shared/hooks.d.ts +13 -80
  46. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  47. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  48. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  49. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  50. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  51. package/dist/components/legendLayout.d.ts +31 -0
  52. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  53. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  54. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  55. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  56. package/dist/components/server/staticLegend.d.ts +7 -1
  57. package/dist/components/server/staticSVGChrome.d.ts +57 -0
  58. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  59. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  60. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  61. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  62. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  63. package/dist/components/stream/canvasBackground.d.ts +7 -0
  64. package/dist/components/stream/networkTypes.d.ts +2 -4
  65. package/dist/components/stream/renderBackend.d.ts +14 -0
  66. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  67. package/dist/components/types/legendTypes.d.ts +16 -3
  68. package/dist/geo.min.js +1 -1
  69. package/dist/geo.module.min.js +1 -1
  70. package/dist/network.min.js +1 -1
  71. package/dist/network.module.min.js +1 -1
  72. package/dist/ordinal.min.js +1 -1
  73. package/dist/ordinal.module.min.js +1 -1
  74. package/dist/physics.min.js +1 -1
  75. package/dist/physics.module.min.js +1 -1
  76. package/dist/realtime.min.js +1 -1
  77. package/dist/realtime.module.min.js +1 -1
  78. package/dist/semiotic-ai-core.min.js +1 -1
  79. package/dist/semiotic-ai-core.module.min.js +1 -1
  80. package/dist/semiotic-ai.min.js +1 -1
  81. package/dist/semiotic-ai.module.min.js +1 -1
  82. package/dist/semiotic-experimental.min.js +1 -1
  83. package/dist/semiotic-experimental.module.min.js +1 -1
  84. package/dist/semiotic-realtime-core.min.js +1 -1
  85. package/dist/semiotic-realtime-core.module.min.js +1 -1
  86. package/dist/semiotic-recipes-core.module.min.js +1 -1
  87. package/dist/semiotic-recipes.module.min.js +1 -1
  88. package/dist/semiotic-server-edge.min.js +1 -1
  89. package/dist/semiotic-server-edge.module.min.js +1 -1
  90. package/dist/semiotic-server-node.min.js +1 -1
  91. package/dist/semiotic-server-node.module.min.js +1 -1
  92. package/dist/semiotic-utils-core.module.min.js +1 -1
  93. package/dist/semiotic-utils.module.min.js +1 -1
  94. package/dist/semiotic.min.js +1 -1
  95. package/dist/semiotic.module.min.js +1 -1
  96. package/dist/server.min.js +1 -1
  97. package/dist/server.module.min.js +1 -1
  98. package/dist/xy.min.js +1 -1
  99. package/dist/xy.module.min.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/chunk-chunk-6F6GEAQU.module.min.js +0 -1
  102. package/dist/chunk-chunk-BHYTYMY2.module.min.js +0 -2
  103. package/dist/chunk-chunk-E7MIQX7D.module.min.js +0 -2
  104. package/dist/chunk-chunk-ES4DCG3L.module.min.js +0 -1
  105. package/dist/chunk-chunk-IFYPMWKY.module.min.js +0 -1
  106. package/dist/chunk-chunk-L6D3I3V7.module.min.js +0 -2
  107. package/dist/chunk-chunk-ODUZEEBH.module.min.js +0 -2
  108. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +0 -2
  109. package/dist/chunk-chunk-STZFFTAN.module.min.js +0 -2
  110. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +0 -2
  111. package/dist/chunk-chunk-WDIN4LRC.module.min.js +0 -1
  112. package/dist/chunk-chunk-XOYX77KF.module.min.js +0 -2
  113. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{createProcessJourneyLedger as e,processJourneyRows as t,updateProcessJourney as n}from"./chunk-chunk-YWZB3KPI.module.min.js";import{BuiltInPhysicsEngineAdapter as s,CollisionSwarmChart as i,EventDropChart as o,GaltonBoardChart as r,GauntletChart as a,GuantletChart as c,PhysicalFlowChart as l,PhysicsCustomChart as d,PhysicsPileChart as u,PhysicsPipelineStore as h,PhysicsSVGOverlay as m,PhysicsSedimentAccumulator as p,ProcessFlowChart as f,StreamPhysicsFrame as g,StreamPhysicsFrame_default as y,absorbRegion as k,aggregateRegionCounts as x,bodiesToAnnotationAnchors as b,bodyGroupSpec as v,buildCollisionSwarmPhysics as w,buildEventDropPhysics as I,buildGaltonBoardPhysics as D,buildPhysicalFlowPhysics as M,buildPhysicsAnnotationContext as A,buildPhysicsPile as T,buildProcessFlowPhysics as S,capacitatedRegion as C,chargeGateRegion as $,collidersFromPlotBounds as E,collidersFromXScaleBins as N,composePhysicsControllers as j,createCapacityQueueController as R,createDefaultPhysicsEngineAdapter as P,createDependencyGateController as W,createPortalController as B,createServiceLevelController as F,createServiceResourcePoolController as L,evaluatePhysicsBodyBudget as q,forceFieldRegion as O,groupCompletionRows as z,membraneRegion as U,normalizePhysicsAnnotations as Z,physicsProcessBoundaryColliders as H,physicsProcessGroupSemanticItems as X,physicsProcessRegionSemanticItem as Y,physicsProcessStageSemanticItems as J,planGauntletPropertyWork as K,portalRegion as V,pressureFieldRegion as G,processChrome as Q,processLaneWalls as _,processStageLayout as ee,processStageRegions as te,processVolumePolygons as ne,regionCountsToProjectionRows as se,replaceGauntletNegative as ie,routeSurfaceRegion as oe,sedimentHeightfield as re,stageTargetInVolume as ae}from"./chunk-chunk-Z5KXAVQD.module.min.js";import{mulberry32 as ce}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as le,makeRuleValueResolver as de,matchesThreshold as ue,resolveStyleRules as he,ruleMatches as me}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-STZFFTAN.module.min.js";import{compileMotionEncoding as pe,deriveMotionVector as fe,hatchFillId as ge,hatchPatternDef as ye,isHatchFill as ke,opacityFromAge as xe,resolveMotionAccessor as be,resolveMotionAge as ve,resolveMotionVector as we,resolveSvgFill as Ie}from"./chunk-chunk-ODUZEEBH.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";function De(e){const{data:t,encoding:n,defaults:s={},scales:i}=e,o=pe({data:t,encoding:n}),r=[],a=new Map,c=[],l=[],d=new Map;return o.rows.forEach((e,t)=>{const{id:o,datum:u}=e,h=Math.max(0,be(n.appearance?.size,u,t)??s.size??6),m=be(n.appearance?.shape,u,t)??s.shape??{type:"circle",radius:h},p=e.placement.x??s.x??0,f=e.placement.y??s.y??0,g=i?.x?i.x(p):p,y=i?.y?i.y(f):f,k=be(n.appearance?.color,u,t)??s.color,x=be(n.appearance?.opacity,u,t)??s.opacity,b=be(n.appearance?.stroke,u,t)??s.stroke,v=be(n.appearance?.strokeWidth,u,t)??s.strokeWidth,w=be(n.time?.spawnAt,u,t)??e.time.arrival,I=e.kinematics.velocityX,D=e.kinematics.velocityY,M=be(n.dynamics?.mass,u,t)??s.mass??1,A=be(n.dynamics?.friction,u,t),T=be(n.dynamics?.restitution,u,t),S=be(n.dynamics?.bodyCollisions,u,t),C={id:o,x:g,y:y,mass:M,shape:{...m},datum:u,...null!=w&&{spawnAt:w},...null!=I&&{vx:I},...null!=D&&{vy:D},...null!=A&&{friction:A},...null!=T&&{restitution:T},...null!=S&&{bodyCollisions:S}},$={...null!=k&&{fill:k},...null!=x&&{opacity:x},...null!=b&&{stroke:b},...null!=v&&{strokeWidth:v}},E={id:o,datum:u,appearance:{color:k,opacity:x,shape:m,size:h,stroke:b,strokeWidth:v},placement:{x:g,y:y,lane:e.placement.lane,space:n.placement?.space??"world"},time:{arrival:w,spawnAt:w,basis:n.time?.basis??"simulation",unit:n.time?.unit},kinematics:{velocityX:I,velocityY:D,space:n.kinematics?.space??"world"},dynamics:{bodyCollisions:S,friction:A,mass:M,restitution:T},process:e.process,evidence:e.evidence,accessible:e.accessible,spawn:C};r.push(E),a.set(o,E),c.push(C),d.set(o,$),l.push({id:o,bodyId:o,label:e.accessible.label,description:e.accessible.description,datum:u,x:g,y:y,group:e.accessible.group})}),{rows:r,byId:a,spawns:c,semanticItems:l,bodyStyle:e=>d.get(e.id)??{}}}function Me(e){return t=>{const n=De({data:t.data,encoding:e.encoding,defaults:e.defaults,scales:t.scales}),s=e.extend?.(t,n)??{};return{...s,initialSpawns:n.spawns,bodyStyle:n.bodyStyle,semanticItems:[...n.semanticItems,...s.semanticItems??[]]}}}var Ae=[.1,.5,.9],Te=1e6;function Se(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ce(e,t,n,s,i){return"function"==typeof s?s(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(e,s??i)}function $e(e){const t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function Ee(e,t,n,s){const i=e.flatMap((e,i)=>{const o=Se(Ce(e,i,t,n,"time")),r=Se(Ce(e,i,t,s,"value"));return null==o||null==r?[]:[{time:$e(o),value:r,index:i}]});i.sort((e,t)=>e.time-t.time||e.index-t.index);const o=[];for(const e of i){const t=o[o.length-1];t?.time===e.time?t.value=e.value:o.push({time:e.time,value:e.value})}return o}function Ne(e,t,n,s){if(!e.length)return null;const i=e[0],o=e[e.length-1];if(i.time>t)return"clamp"===s?i.value:null;if(t>o.time)return"clamp"===s?o.value:null;const r=function(e,t){let n=0,s=e.length;for(;s>n;){const i=n+s>>>1;t>e[i].time?n=i+1:s=i}return n}(e,t),a=e[r];if(a?.time===t)return a.value;const c=e[Math.max(0,r-1)];return"step"!==n&&a&&a.time!==c.time?c.value+(t-c.time)/(a.time-c.time)*(a.value-c.value):c.value}function je(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,s=Math.floor(n),i=Math.ceil(n);return s===i?e[s]:e[s]+(e[i]-e[s])*(n-s)}function Re(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",s=function(e){const t=(e??Ae).map(e=>{const t=Se(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return $e(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),i=function(e){if(Array.isArray(e)){if(e.length>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(e.map(Se).filter(e=>null!=e).map($e))).sort((e,t)=>e-t)}const t=e,n=Se(t.start),s=Se(t.end),i=Se(t.step);if(null==n||null==s||null==i||0>=i||n>s)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const o=Math.floor((s-n)/i)+1;if(o>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const r=[],a=1e-10*Math.max(1,Math.abs(s),Math.abs(n));for(let e=0;o>e;e+=1){const t=n+e*i;if(t>s+a)break;r.push($e(Math.min(t,s)))}if(r.length&&a>=Math.abs(r[r.length-1]-s)||r.push($e(s)),r.length>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(r)).sort((e,t)=>e-t)}(e.sampleAt),o=e.runs.map(t=>Ee(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:i.map(e=>{const i=o.map(s=>Ne(s,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),r={};for(const e of s)r[e]=i.length?je(i,e):null;return{time:e,count:i.length,min:i.length?i[0]:null,max:i.length?i[i.length-1]:null,median:i.length?je(i,.5):null,quantiles:r}}),quantiles:s,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Pe(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function We(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Se(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const s=$e(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,s))throw Error(`comparePhysicsTrace could not find quantile ${s} in the reference envelope`);return e.quantiles[s]??null}function Be(e,t,n){return t>e?"below":e>n?"above":"inside"}function Fe(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const s=e.value-e.lower,i=t.value-t.lower,o=e.value-e.upper,r=t.value-t.upper,a=[0,1];for(const[e,t]of[[s,i],[o,r]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,d=0;for(let s=0;a.length-1>s;s+=1){const i=a[s],o=a[s+1];if(i>=o)continue;const r=(i+o)/2,u=(o-i)*n,h=Be(e.value+(t.value-e.value)*r,e.lower+(t.lower-e.lower)*r,e.upper+(t.upper-e.upper)*r);"below"===h?c+=u:"above"===h?d+=u:l+=u}return{below:c,inside:l,above:d,observed:n}}function Le(e,t,n={}){const s=n.interpolation??t.interpolation,i=n.outsideDomain??t.outsideDomain,o=Ee(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),r=n.lower??Pe(t,"lower"),a=n.upper??Pe(t,"upper"),c=t.points.map(e=>{const t=Ne(o,e.time,s,i),n=We(e,r),c=We(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Be(t,n,c)}});let l=0,d=0,u=0,h=0,m=null,p=0,f=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?d+=1:"above"===e.status&&(u+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,m=e.time),n>p&&(p=n,f=e.time)}let g=0,y=0,k=0,x=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],i=Math.max(0,n.time-t.time);if(i>0){if("linear"===s){const e=Fe(t,n);g+=e.below,y+=e.inside,k+=e.above,x+=e.observed;continue}"unobserved"!==t.status&&(x+=i,"below"===t.status?g+=i:"above"===t.status?k+=i:y+=i)}}const b=c[0]?.time,v=c[c.length-1]?.time,w=null==b||null==v?0:Math.max(0,v-b);return{points:c,sampleCount:c.length,observedSamples:l+d+u,belowSamples:l,insideSamples:d,aboveSamples:u,totalDuration:w,observedDuration:x,unobservedDuration:Math.max(0,w-x),belowDuration:g,insideDuration:y,aboveDuration:k,peakExcess:h,peakExcessAt:m,peakDeficit:p,peakDeficitAt:f}}function qe(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Oe(e,t,n,s){const i="function"==typeof e?e(t,n):e;return Number.isFinite(i)?Number(i):s}function ze(e,t,n){return qe(e[t])??n}function Ue(e,t){return"number"==typeof e?e:e?.[t]??0}function Ze(e){const{band:t,idPrefix:n,plot:s,projection:i}=e,{includeBoundaryWalls:o=!0,includeInteriorWalls:r=!0,wallThickness:a=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const s of e.values){const i=e.scale(s);Number.isFinite(i)&&(n.add(Number(i)),n.add(Number(i)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=o?c.length-1:c.length-2,d=[];for(let e=o?0:1;l>=e;e+=1){if(!r&&e>0&&c.length-1>e)continue;const t=c[e];d.push({id:`${n}-wall-${e}`,shape:"x"===i?{type:"aabb",x:t,y:s.y+s.height/2,width:a,height:s.height}:{type:"aabb",x:s.x+s.width/2,y:t,width:s.width,height:a}})}return d}function He(e){const{plot:t,idPrefix:n="physics-scale",bounds:s={},xBins:i,xBands:o,yBands:r}=e,a=[];if(!1!==s&&a.push(...E(t,{idPrefix:n,...s})),i){const{idPrefix:e,yTop:s,yBottom:o,...r}=i;a.push(...N({...r,idPrefix:e??n+"-xbin",yTop:s??t.y,yBottom:o??t.y+t.height}))}return o&&a.push(...Ze({band:o,idPrefix:o.idPrefix??n+"-xband",plot:t,projection:"x"})),r&&a.push(...Ze({band:r,idPrefix:r.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function Xe(e){const{plot:t,rows:n,columns:s=n+1,pegRadius:i=3,idPrefix:o="galton-peg",yStart:r=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:d=.04}=e,u=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(s));if(0===u)return[];const m=u>1?(a-r)/(u-1):0,p=t.width/h,f=[];for(let e=0;u>e;e+=1){const n=c&&e%2==1?p/2:0;for(let s=0;h>s;s+=1){const a=t.x+p*(s+.5)+n;t.x+i>a||a>t.x+t.width-i||f.push({id:`${o}-${e}-${s}`,shape:{type:"aabb",x:a,y:r+e*m,width:2*i,height:2*i},restitution:l,friction:d})}}return f}function Ye(e,t={}){const{idPrefix:n="physics-token",radius:s=5,shape:i,mass:o,vx:r,vy:a,spawnAt:c,seed:l=1,jitter:d,datum:u}=t,h=ce(l),m=Ue(d,"x"),p=Ue(d,"y");return e.map((e,l)=>{const d=Oe(t.x,e,l,ze(e,"x",0)),f=Oe(t.y,e,l,ze(e,"y",0)),g=Oe(s,e,l,5),y="function"==typeof i?i(e,l):i??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:d+(h()-.5)*m,y:f+(h()-.5)*p,vx:Oe(r,e,l,0),vy:Oe(a,e,l,0),mass:Oe(o,e,l,1),spawnAt:Oe(c,e,l,void 0),shape:y,datum:u?u(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Je(e,t={}){const{idPrefix:n="sediment",collider:s=!0,colliderThickness:i=1,restitution:o=.05,friction:r=.2,...a}=t,c=re(e,a),l=s?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+i/2,width:e.width,height:i},restitution:o,friction:r})):[];return{columns:c,colliders:l}}function Ke(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:s=1,startAt:i=0,rebase:o=!0,sort:r=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return qe("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:i+(o?t-c:t)})).sort((e,t)=>r?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:i,timeAccessor:"spawnAt",timeScale:s}}}import{forwardRef as Ve,useCallback as Ge,useEffect as Qe,useImperativeHandle as _e,useMemo as et,useRef as tt,useState as nt}from"react";function st(e,t,n={}){const s=new Set,i=[...e.get(t)??[]];let o=0;for(;i.length>o;){const t=i[o];if(o+=1,!s.has(t)){s.add(t);for(const n of e.get(t)??[])i.push(n)}}return n.includeStart&&s.add(t),s}function it(e,t,n){return be(n,e,t)}function ot(e,t){return t>e?-1:e>t?1:0}function rt(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function at(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function ct(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function lt(e){const t=[],n=new Map,s=[],i=new Set;e.data.forEach((o,r)=>{const a=(it(o,r,e.taskIDAccessor)??"")+"";if(!a)return void t.push({code:"duplicate-task-id",message:`Task row ${r} has an empty id.`,taskIDs:[]});if(n.has(a))return void t.push({code:"duplicate-task-id",message:`Task id "${a}" occurs more than once.`,taskIDs:[a]});const c=(it(o,r,e.laneAccessor)??"Unassigned")+"";i.has(c)||(i.add(c),s.push(c));const l=it(o,r,e.dependencyAccessor)??[],d=Array.from(new Set(Array.from(l,e=>e+""))).sort(ot),u=it(o,r,e.blockerAccessor),h=it(o,r,e.statusAccessor)??(u?"blocked":"waiting");n.set(a,{id:a,label:(it(o,r,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:r,datum:o,dependencyIDs:d,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:it(o,r,e.startAccessor),end:it(o,r,e.endAccessor),progress:ct(it(o,r,e.progressAccessor)),status:h,completionTime:it(o,r,e.completionTimeAccessor),blockerReason:u||void 0,milestone:!!it(o,r,e.milestoneAccessor)})});const o=e.laneOrder?[...e.laneOrder,...s.filter(t=>!e.laneOrder?.includes(t))]:s,r=new Map(o.map((e,t)=>[e,t]));for(const e of n.values())e.laneIndex=r.get(e.lane)??0;const a=new Map,c=new Map;for(const e of n.keys())a.set(e,[]),c.set(e,[]);const l=[],d=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of d)e.dependencyIDs.forEach((s,i)=>{const o=n.get(s);if(!o)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${s}".`,taskIDs:[e.id,s]});const r={id:rt(s,e.id),sourceID:s,targetID:e.id,sourceIndex:o.index,targetIndex:e.index,socketID:at(e.id,i),socketIndex:i};l.push(r),a.get(e.id)?.push(r),c.get(s)?.push(r),e.incomingEdgeIDs.push(r.id),e.socketIDs.push(r.socketID),o.outgoingEdgeIDs.push(r.id)});for(const e of a.values())e.sort((e,t)=>ot(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=at(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>ot(e.targetID,t.targetID));for(const e of n.values()){const t=a.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(c.get(e.id)??[]).map(e=>e.id)}const u=new Map,h=new Map;for(const e of n.keys())u.set(e,a.get(e)?.length??0),h.set(e,0);const m=[...n.keys()].filter(e=>0===u.get(e)).sort(ot);let p=0;for(;m.length;){const e=m.shift();p+=1;for(const t of c.get(e)??[]){const n=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,n);const s=(u.get(t.targetID)??0)-1;if(u.set(t.targetID,s),0===s){const e=m.findIndex(e=>e>t.targetID);0>e?m.push(t.targetID):m.splice(e,0,t.targetID)}}}if(p!==n.size){const e=[...n.keys()].filter(e=>(u.get(e)??0)>0).sort(ot);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let f=0;const g=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of g)e.level=h.get(e.id)??0,f=Math.max(f,e.level);return{nodes:g,edges:l,byID:n,incoming:a,outgoing:c,lanes:o,maxLevel:f,diagnostics:t,valid:0===t.length}}function dt(e,t,n={}){const s=Math.max(240,t.width),i=Math.max(220,t.height),o=t.paddingX??48,r=t.paddingTop??48,a=t.paddingBottom??44,c=Math.max(70,(s-2*o)/Math.max(1,e.lanes.length)),l=Math.max(76,(i-r-a)/Math.max(1,e.maxLevel+1)),d=Math.min(n.taskWidth??112,Math.max(58,.78*c)),u=Math.min(n.taskHeight??58,.64*l),h=n.socketRadius??5,m=Math.max(1,Math.round(n.gutterCount??3)),p=new Map;for(const t of e.nodes){const e=`${t.laneIndex}:${t.level}`,n=p.get(e)??[];n.push(t),p.set(e,n)}for(const e of p.values())e.sort((e,t)=>ot(e.id,t.id));const f=e.nodes.map(e=>{const t=p.get(`${e.laneIndex}:${e.level}`)??[e],n=Math.max(0,t.findIndex(t=>t.id===e.id));return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:o+c*(e.laneIndex+.5),y:r+l*(e.level+.5)+(n-(t.length-1)/2)*Math.min(18,.3*u),width:d,height:u}}),g=new Map(f.map(e=>[e.taskID,e])),y=[],k=[];e.edges.forEach((t,n)=>{const s=g.get(t.sourceID),i=g.get(t.targetID);if(!s||!i)return;const o=e.incoming.get(t.targetID)??[],r=Math.min(.72*i.width,14*Math.max(1,o.length-1)),a=o.length>1?i.x-r/2+r*t.socketIndex/(o.length-1):i.x,c=i.y-i.height/2-h-2;y.push({id:t.socketID,edgeID:t.id,taskID:i.taskID,index:t.socketIndex,x:a,y:c,radius:h});const l={x:s.x,y:s.y+s.height/2+3},d=Math.min(c-10,l.y+.48*Math.max(18,c-l.y)+7*(n%m-(m-1)/2));var u;k.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(u=[l,{x:l.x,y:d},{x:a,y:d},{x:a,y:c}],u.filter((e,t)=>{const n=u[t-1];return!n||n.x!==e.x||n.y!==e.y}))})});const x=new Map(y.map(e=>[e.id,e])),b=new Map(k.map(e=>[e.edgeID,e]));return{tasks:f,sockets:y,routes:k,taskByID:g,socketByID:x,routeByEdgeID:b}}function ut(e,t,n="all"){const s=Array.from(new Set(t)).sort(ot),i=new Set,o=()=>s.every(e=>i.has(e));return{taskID:e,mode:n,incomingEdgeIDs:s,deliver:e=>s.includes(e)?(i.add(e),o()):o(),reset:(e=[])=>{i.clear();for(const t of e)s.includes(t)&&i.add(t)},isSatisfied:o,getSnapshot:()=>({taskID:e,mode:n,incomingEdgeIDs:[...s],deliveredEdgeIDs:[...i].sort(ot),satisfied:o()})}}function ht(e){return e instanceof Date?e.getTime():Number(e)}function mt(e,t){const n=ht("object"!=typeof t||t instanceof Date?t:t.currentTime),s=e.map((e,t)=>({event:e,index:t,time:ht(e.at)})).filter(e=>Number.isFinite(e.time)&&n>=e.time).sort((e,t)=>e.time-t.time||e.index-t.index),i=new Set,o=new Map,r=new Set,a=new Set;for(const{event:e}of s)"task-completed"===e.type?(i.add(e.taskID),o.delete(e.taskID)):"task-blocked"===e.type?o.set(e.taskID,e.reason):"task-unblocked"===e.type?o.delete(e.taskID):"dependency-delivered"===e.type?r.add(e.edgeID):"task-armed"===e.type&&a.add(e.taskID);return{currentTime:n,appliedEvents:s.map(e=>e.event),completedTaskIDs:i,blockedByTaskID:o,deliveredEdgeIDs:r,armedTaskIDs:a}}function pt(e,t,n={}){const s=new Set(n.completedTaskIDs??[]),i=[...st(function(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target);return n}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(n.isComplete?n.isComplete(e):s.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),o=Array.from(new Set(i.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:i.length,affectedLaneCount:o.length,downstreamTaskIDs:i.map(e=>e.id),affectedLanes:o}}var ft=[];function gt(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function yt(e){if(null==e.completionTime)return null;const t=gt(e.completionTime,NaN);return Number.isFinite(t)?t:null}function kt(e,t,n,s){const i=new Set;for(const o of e.nodes){const r=e.incoming.get(o.id)??[];(s.has(o.id)||!n.has(o.id)&&r.every(e=>t.has(e.id)))&&i.add(o.id)}return i}function xt(e,t,n,s){const i=e.nodes.map(yt).filter(e=>null!=e),o=i.length?Math.min(...i)-1:0,r="replay"!==t||s?n:o,a=new Set,c=new Map;for(const n of e.nodes){const e=yt(n);(null!=e&&r>=e||"done"===n.status&&"replay"!==t)&&a.add(n.id),n.blockerReason&&!a.has(n.id)&&c.set(n.id,n.blockerReason)}const l=new Set;if("replay"!==t||s)for(const t of e.edges)a.has(t.sourceID)&&l.add(t.id);return{currentTime:r,playing:!1,completed:a,delivered:l,inFlight:new Set,armed:kt(e,l,c,a),blockers:c,previewTaskID:null}}function bt(e){return{...e,completed:new Set(e.completed),delivered:new Set(e.delivered),inFlight:new Set(e.inFlight),armed:new Set(e.armed),blockers:new Map(e.blockers)}}function vt(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function wt(e){const t=vt(e.body);if(!t||2>t.route.length)return null;const n=function(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}(t.route),s=function(e,t){let n=1/0,s=0,i=0;for(let o=1;t.length>o;o+=1){const r=t[o-1],a=t[o],c=a.x-r.x,l=a.y-r.y,d=c*c+l*l,u=Math.sqrt(d);if(0>=u)continue;const h=Math.max(0,Math.min(1,((e.x-r.x)*c+(e.y-r.y)*l)/d)),m=Math.hypot(e.x-(r.x+c*h),e.y-(r.y+l*h));n>m&&(n=m,s=i+h*u),i+=u}return s}(e.body,t.route),i=function(e,t){if(2>e.length)return{point:e[0]??{x:0,y:0},tangent:{x:0,y:1}};let n=0;for(let s=1;e.length>s;s+=1){const i=e[s-1],o=e[s],r=o.x-i.x,a=o.y-i.y,c=Math.hypot(r,a);if(c>0){if(n+c>=t){const e=Math.max(0,Math.min(1,(t-n)/c));return{point:{x:i.x+r*e,y:i.y+a*e},tangent:{x:r/c,y:a/c}}}n+=c}}const s=e[e.length-2],i=e[e.length-1],o=i.x-s.x,r=i.y-s.y,a=Math.hypot(o,r)||1;return{point:i,tangent:{x:o/a,y:r/a}}}(t.route,Math.min(n,s+22));return{x:2.5*(78*i.tangent.x-e.body.vx)+8*(i.point.x-e.body.x),y:2.5*(78*i.tangent.y-e.body.vy)+8*(i.point.y-e.body.y)}}function It(e,t){const n=t.points[0]??{x:0,y:0},s=t.points[1]??n,i=s.x-n.x,o=s.y-n.y,r=Math.hypot(i,o)||1;return{id:"dependency-ball:"+e.id,x:n.x,y:n.y,vx:i/r*42,vy:o/r*42,mass:.7,restitution:.02,friction:.12,bodyCollisions:!1,shape:{type:"circle",radius:5},datum:{kind:"dependency-ball",edgeID:e.id,sourceID:e.sourceID,targetID:e.targetID,route:t.points}}}import{jsx as Dt,jsxs as Mt}from"react/jsx-runtime";function At({machine:e,layout:t,runtime:n,downstreamSet:s,selectedSet:i,width:o,height:r,seed:a,reduced:c,onSelectTask:l}){return Mt("svg",{"aria-hidden":"true",width:o,height:r,viewBox:`0 0 ${o} ${r}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Dt("defs",{children:Dt("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Dt("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,n)=>{const s=t.tasks.filter(e=>e.laneIndex===n),i=s[0]?.x??0;return Mt("g",{children:[Dt("line",{x1:i,x2:i,y1:32,y2:r-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Dt("text",{x:i,y:23,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{const t=n.delivered.has(e.edgeID),i=n.inFlight.has(e.edgeID),o=s.has(e.targetID)||s.has(e.sourceID),r=e.points.map(e=>`${e.x},${e.y}`).join(" ");return Dt("polyline",{points:r,fill:"none",stroke:o?"var(--semiotic-highlight, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:o?4:i?3:2,strokeOpacity:t||i||o?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{const t=n.delivered.has(e.edgeID);return Mt("g",{children:[Dt("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-background, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&Dt("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{const o=t.taskByID.get(e.id);if(!o)return null;const r=n.completed.has(e.id),d=n.blockers.has(e.id),u=n.previewTaskID===e.id,h=i.has(e.id)||u,m=s.has(e.id),p=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-muted, #75818a)"}(e,n),f=o.x-o.width/2,g=o.y-o.height/2,y=Math.max(2,o.height*e.progress);return Mt("g",{children:[Mt("g",{style:{transform:`rotate(${r?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:c?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+a+")"},children:[Dt("rect",{x:f,y:g,width:o.width,height:o.height,rx:e.milestone?12:4,fill:"var(--semiotic-background, #fff)",stroke:h||m?"var(--semiotic-highlight, #e08a1e)":p,strokeWidth:h?4:m?3:2}),Dt("rect",{x:f+3,y:g+o.height-y+1,width:o.width-6,height:Math.max(0,y-4),rx:2,fill:p,opacity:r?.86:.46})]}),d&&Mt("g",{opacity:u?.28:1,children:[Dt("line",{x1:f-8,x2:f+14,y1:o.y+9,y2:o.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Dt("circle",{cx:f-8,cy:o.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),Mt("g",{onPointerDown:()=>l(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Dt("rect",{x:f,y:g,width:o.width,height:o.height,fill:"transparent"}),Dt("text",{x:o.x,y:o.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),Mt("text",{x:o.x,y:o.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-muted, #5f6b72)",children:[Math.round(100*e.progress),"% · ",r?"done":d?"blocked":n.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}import{jsx as Tt,jsxs as St}from"react/jsx-runtime";var Ct={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},$t=Ve(function(e,t){const{data:n,taskIDAccessor:s,labelAccessor:i,laneAccessor:o,dependencyAccessor:r,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:d,completionTimeAccessor:u,blockerAccessor:h,milestoneAccessor:m,mode:p="snapshot",insight:f="blocker-amplification",currentTime:g,controls:k=!1,selectedTaskIDs:x,onSelectionChange:b,onObservation:v,reducedMotion:w,seed:I=31,width:D=920,height:M=620,responsiveWidth:A,responsiveHeight:T,title:S="Dependency chain reaction",description:C,className:$,accessibleTable:E=!0,enableHover:N=!0}=e,j=tt(null),[R,P]=nt([]),W=x?Array.from(x):R,B=et(()=>new Set(W),[W]),F=gt(g,1/0),L="settle"===w,q=et(()=>lt({data:n,taskIDAccessor:s,labelAccessor:i,laneAccessor:o,dependencyAccessor:r,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:d,completionTimeAccessor:u,blockerAccessor:h,milestoneAccessor:m}),[n,s,i,o,r,a,c,l,d,u,h,m]),O=et(()=>dt(q,{width:D,height:M}),[q,D,M]),[z,U]=nt(()=>xt(q,p,F,L)),Z=tt(z),H=Ge(e=>{Z.current=e,U(e)},[]),X=Ge(e=>v?.(e),[v]);Qe(()=>{const e=xt(q,p,F,L);j.current?.clear(),Z.current=e,U(e)},[q,p,F,L]);const Y=Ge(e=>{const t=B.has(e)?W.filter(t=>t!==e):[e];x||P(t),b?.(t)},[x,b,B,W]),J=Ge(e=>{if(L)return;const t=bt(Z.current),n=[];for(const s of q.outgoing.get(e)??[]){if(t.delivered.has(s.id)||t.inFlight.has(s.id))continue;const e=O.routeByEdgeID.get(s.id);e&&(t.inFlight.add(s.id),n.push(It(s,e)))}n.length&&(H(t),j.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[H,O,q,L]),K=Ge((e,t)=>{const n=q.byID.get(e),s=Z.current;if(!n||s.completed.has(e))return;const i=bt(s);i.completed.add(e),i.blockers.delete(e),i.armed.add(e),null!=t&&(i.currentTime=t),H(i),X({type:"task-completed",taskID:e,datum:n.datum}),J(e)},[H,X,q,J]),V=Ge(e=>{const t=bt(Z.current),n=[],s=[];for(const s of e){if(t.delivered.has(s))continue;const e=q.edges.find(e=>e.id===s);e&&(t.delivered.add(s),t.inFlight.delete(s),n.push(e))}for(const e of n){const n=q.byID.get(e.targetID);!n||t.blockers.has(n.id)||t.armed.has(n.id)||(q.incoming.get(n.id)??[]).every(e=>t.delivered.has(e.id))&&(t.armed.add(n.id),s.push(n.id))}if(n.length){H(t);for(const e of n)X({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of s)X({type:"task-armed",taskID:e})}},[H,X,q]),G=Ge((e,t)=>{const n=[],s=[];for(const e of t.readBodies()){const t=vt(e);if(!t||Z.current.delivered.has(t.edgeID))continue;const i=t.route[t.route.length-1];i&&9>=Math.hypot(e.x-i.x,e.y-i.y)&&(n.push(t.edgeID),s.push(e.id))}s.length&&t.remove(s),n.length&&V(n)},[V]),Q=Ge(()=>{const e=bt(Z.current);for(const t of q.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=kt(q,e.delivered,e.blockers,e.completed),e.playing=!1,j.current?.settle(),H(e),X({type:"machine-settled"})},[H,X,q]),_=Ge(()=>{const e=bt(Z.current);e.playing=!1,H(e)},[H]),ee=Ge(()=>{const e=Z.current,t=q.nodes.map(e=>({node:e,time:yt(e)})).filter(t=>null!=t.time&&t.time>e.currentTime&&!e.completed.has(t.node.id)).sort((e,t)=>e.time-t.time||e.node.index-t.node.index)[0];if(t)return void K(t.node.id,t.time);_();const n=[...e.blockers.keys()].map(t=>pt(q,t,{completedTaskIDs:e.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);n[0]&&X({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[X,q,_,K]),te=Ge(()=>{if(L)return void Q();const e=bt(Z.current);e.playing=!0,H(e)},[H,L,Q]);Qe(()=>{if(!z.playing||"replay"!==p||L)return;const e=window.setInterval(ee,760);return()=>window.clearInterval(e)},[p,L,z.playing,ee]);const ne=Ge(()=>{j.current?.clear(),H(xt(q,p,F,L))},[H,q,p,F,L]),se=Ge(e=>{if(!q.byID.has(e))return;const t=bt(Z.current);t.previewTaskID=e,H(t);const n=pt(q,e,{completedTaskIDs:t.completed});X({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[H,X,q]),ie=Ge(()=>{const e=bt(Z.current);e.previewTaskID=null,H(e)},[H]),oe=Ge((e,t)=>{if(!q.byID.has(e))return;const n=bt(Z.current);n.blockers.set(e,t),n.armed.delete(e),H(n)},[H,q]),re=Ge(e=>{if(!q.byID.has(e))return;const t=bt(Z.current);t.blockers.delete(e),(q.incoming.get(e)??[]).every(e=>t.delivered.has(e.id))&&t.armed.add(e),H(t)},[H,q]),ae=Ge(e=>pt(q,e,{completedTaskIDs:Z.current.completed}),[q]),ce=Ge(()=>{const e=Z.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...W],tasks:q.nodes.map(t=>({taskID:t.id,completed:e.completed.has(t.id),armed:e.armed.has(t.id),blocked:e.blockers.has(t.id),blockerReason:e.blockers.get(t.id)})),dependencies:q.edges.map(t=>({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,state:e.delivered.has(t.id)?"delivered":e.inFlight.has(t.id)?"in-flight":"waiting"}))}},[q,W]);_e(t,()=>({play:te,pause:_,step:ee,reset:ne,settle:Q,previewResolve:se,clearPreview:ie,completeTask:K,blockTask:oe,unblockTask:re,getAmplification:ae,getMachineState:ce}),[oe,ie,ae,ce,_,K,te,se,ne,Q,ee,re]);const le=z.previewTaskID??W[0]??null,de=le?pt(q,le,{completedTaskIDs:z.completed}):null,ue=et(()=>new Set(de?.downstreamTaskIDs??[]),[de?.downstreamTaskIDs]),he=et(()=>function(e,t,n){return e.nodes.flatMap(s=>{const i=t.taskByID.get(s.id);if(!i)return[];const o=e.incoming.get(s.id)??[],r=o.filter(e=>n.delivered.has(e.id)).length,a=n.blockers.get(s.id),c=n.completed.has(s.id)?"completed":a?"blocked: "+a:n.armed.has(s.id)?"armed":"waiting";return[{id:s.id,label:`${s.label}, ${s.lane}, ${Math.round(100*s.progress)}%, ${c}`,description:`${r} of ${o.length} prerequisites delivered.`,datum:s.datum,x:i.x,y:i.y,width:i.width,height:i.height,shape:"rect",group:s.lane}]})}(q,O,z),[O,q,z]),me=et(()=>Tt(At,{machine:q,layout:O,runtime:z,downstreamSet:ue,selectedSet:B,width:D,height:M,seed:I,reduced:L,onSelectTask:Y}),[ue,M,O,q,L,z,I,Y,B,D]),pe=et(()=>{const e=[...z.blockers.keys()].map(e=>pt(q,e,{completedTaskIDs:z.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);return e.length?e.map(e=>`${q.byID.get(e.blockerID)?.label??e.blockerID} affects ${e.downstreamTaskCount} unfinished tasks across ${e.affectedLaneCount} lanes.`).join(" "):"No explicit blockers are active."},[q,z.blockers,z.completed]),fe=et(()=>[{id:"chain-left",shape:{type:"segment",x1:2,y1:0,x2:2,y2:M,thickness:4}},{id:"chain-right",shape:{type:"segment",x1:D-2,y1:0,x2:D-2,y2:M,thickness:4}},{id:"chain-top",shape:{type:"segment",x1:0,y1:2,x2:D,y2:2,thickness:4}},{id:"chain-bottom",shape:{type:"segment",x1:0,y1:M-2,x2:D,y2:M-2,thickness:4}}],[M,D]),ge=!0===k?["play","pause","step","reset","settle"]:k||[];return St("div",q.valid?{className:$,style:{width:D,maxWidth:"100%",position:"relative"},children:[ge.length>0&&Tt("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:ge.map(e=>Tt("button",{type:"button",onClick:"play"===e?te:"pause"===e?_:"step"===e?ee:"reset"===e?ne:Q,"aria-pressed":"play"===e?z.playing:void 0,children:e[0].toUpperCase()+e.slice(1)},e))}),Tt(y,{ref:j,size:[D,M],responsiveWidth:A,responsiveHeight:T,title:S,description:C??"Tasks are arranged by workstream and dependency depth. Balls represent satisfied prerequisites; task completion remains an explicit data event.",summary:`${pe}${de&&"blocker-amplification"===f?` Selected task reaches ${de.downstreamTaskCount} unfinished tasks across ${de.affectedLaneCount} lanes.`:""}`,accessibleTable:!1,enableHover:N,initialSpawns:ft,bodyForces:wt,bodyStyle:{fill:"var(--semiotic-accent, #f0a329)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.25},bodySemanticItems:!1,semanticItems:he,onSemanticItemActivate:e=>e.id&&Y(e.id),foregroundGraphics:()=>me,paused:L,continuous:z.inFlight.size>0,onTick:G,config:{bodyLimit:Math.max(16,q.edges.length+4),colliders:fe,settleStepLimit:2200,kernel:{seed:I,gravity:{x:0,y:7},fixedDt:1/60,cellSize:28,collisionIterations:2,velocityDamping:.992,restitution:.02,friction:.12,maxVelocity:150,sleepSpeed:1.1,sleepAfter:.8},observation:{chartType:"ChainReactionChart"}}}),E&&St("table",{style:Ct,children:[Tt("caption",{children:pe}),Tt("thead",{children:St("tr",{children:[Tt("th",{children:"Task"}),Tt("th",{children:"Lane"}),Tt("th",{children:"Progress"}),Tt("th",{children:"State"}),Tt("th",{children:"Waiting on"}),Tt("th",{children:"Downstream reach"})]})}),Tt("tbody",{children:q.nodes.map(e=>{const t=pt(q,e.id,{completedTaskIDs:z.completed});return St("tr",{children:[Tt("th",{scope:"row",children:e.label}),Tt("td",{children:e.lane}),St("td",{children:[Math.round(100*e.progress),"%"]}),Tt("td",{children:z.completed.has(e.id)?"Completed":z.blockers.has(e.id)?"Blocked":z.armed.has(e.id)?"Armed":"Waiting"}),Tt("td",{children:z.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!z.completed.has(e)).join(", ")||"None")}),St("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:$,role:"alert",style:{width:D,maxWidth:"100%"},children:[Tt("strong",{children:"ChainReactionChart could not compile this dependency graph."}),Tt("ul",{children:q.diagnostics.map((e,t)=>Tt("li",{children:e.message},`${e.code}-${t}`))})]})});$t.displayName="ChainReactionChart";var Et=y;export{s as BuiltInPhysicsEngineAdapter,$t as ChainReactionChart,i as CollisionSwarmChart,o as EventDropChart,r as GaltonBoardChart,a as GauntletChart,c as GuantletChart,l as PhysicalFlowChart,d as PhysicsCustomChart,u as PhysicsPileChart,h as PhysicsPipelineStore,m as PhysicsSVGOverlay,p as PhysicsSedimentAccumulator,f as ProcessFlowChart,g as StreamPhysicsFrame,k as absorbRegion,x as aggregateRegionCounts,Ke as arrivalReplay,b as bodiesToAnnotationAnchors,v as bodyGroupSpec,w as buildCollisionSwarmPhysics,I as buildEventDropPhysics,D as buildGaltonBoardPhysics,M as buildPhysicalFlowPhysics,A as buildPhysicsAnnotationContext,T as buildPhysicsPile,S as buildProcessFlowPhysics,pt as calculateBlockerAmplification,C as capacitatedRegion,$ as chargeGateRegion,He as collidersFromScales,Le as comparePhysicsTrace,lt as compileDependencyMachine,pe as compileMotionEncoding,De as compilePhysicsEncoding,j as composePhysicsControllers,le as composeStyleRules,R as createCapacityQueueController,P as createDefaultPhysicsEngineAdapter,W as createDependencyGateController,ut as createLogicalJoin,Me as createPhysicsEncodingLayout,B as createPortalController,e as createProcessJourneyLedger,F as createServiceLevelController,L as createServiceResourcePoolController,Et as default,fe as deriveMotionVector,q as evaluatePhysicsBodyBudget,O as forceFieldRegion,Xe as galtonPegs,z as groupCompletionRows,ge as hatchFillId,ye as hatchPatternDef,ke as isHatchFill,de as makeRuleValueResolver,ue as matchesThreshold,U as membraneRegion,Z as normalizePhysicsAnnotations,xe as opacityFromAge,H as physicsProcessBoundaryColliders,X as physicsProcessGroupSemanticItems,Y as physicsProcessRegionSemanticItem,J as physicsProcessStageSemanticItems,Re as physicsReferenceEnvelope,K as planGauntletPropertyWork,V as portalRegion,G as pressureFieldRegion,Q as processChrome,t as processJourneyRows,_ as processLaneWalls,ee as processStageLayout,te as processStageRegions,ne as processVolumePolygons,se as regionCountsToProjectionRows,ie as replaceGauntletNegative,mt as replayStateTransitions,be as resolveMotionAccessor,ve as resolveMotionAge,we as resolveMotionVector,he as resolveStyleRules,Ie as resolveSvgFill,dt as routeDependencyTracks,oe as routeSurfaceRegion,me as ruleMatches,Je as sedimentBake,re as sedimentHeightfield,Ye as spawnFromTokens,ae as stageTargetInVolume,n as updateProcessJourney};
2
+ import{createProcessJourneyLedger as e,processJourneyRows as t,updateProcessJourney as n}from"./chunk-chunk-YWZB3KPI.module.min.js";import{BuiltInPhysicsEngineAdapter as s,CollisionSwarmChart as i,EventDropChart as o,GaltonBoardChart as r,GauntletChart as a,GuantletChart as c,PhysicalFlowChart as l,PhysicsCustomChart as d,PhysicsPileChart as u,PhysicsPipelineStore as h,PhysicsSVGOverlay as m,PhysicsSedimentAccumulator as p,ProcessFlowChart as f,StreamPhysicsFrame as g,StreamPhysicsFrame_default as y,absorbRegion as k,aggregateRegionCounts as x,bodiesToAnnotationAnchors as b,bodyGroupSpec as v,buildCollisionSwarmPhysics as w,buildEventDropPhysics as I,buildGaltonBoardPhysics as D,buildPhysicalFlowPhysics as M,buildPhysicsAnnotationContext as A,buildPhysicsPile as T,buildProcessFlowPhysics as S,capacitatedRegion as C,chargeGateRegion as $,collidersFromPlotBounds as E,collidersFromXScaleBins as N,composePhysicsControllers as j,createCapacityQueueController as R,createDefaultPhysicsEngineAdapter as P,createDependencyGateController as W,createPortalController as B,createServiceLevelController as F,createServiceResourcePoolController as L,evaluatePhysicsBodyBudget as q,forceFieldRegion as O,groupCompletionRows as z,membraneRegion as H,normalizePhysicsAnnotations as U,physicsProcessBoundaryColliders as Z,physicsProcessGroupSemanticItems as X,physicsProcessRegionSemanticItem as Y,physicsProcessStageSemanticItems as G,planGauntletPropertyWork as J,portalRegion as K,pressureFieldRegion as Q,processChrome as V,processLaneWalls as _,processStageLayout as ee,processStageRegions as te,processVolumePolygons as ne,regionCountsToProjectionRows as se,replaceGauntletNegative as ie,routeSurfaceRegion as oe,sedimentHeightfield as re,stageTargetInVolume as ae}from"./chunk-chunk-L3H6DQCR.module.min.js";import{mulberry32 as ce}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as le,makeRuleValueResolver as de,matchesThreshold as ue,resolveStyleRules as he,ruleMatches as me}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-SANERMIZ.module.min.js";import{compileMotionEncoding as pe,deriveMotionVector as fe,hatchFillId as ge,hatchPatternDef as ye,isHatchFill as ke,opacityFromAge as xe,resolveMotionAccessor as be,resolveMotionAge as ve,resolveMotionVector as we,resolveSvgFill as Ie}from"./chunk-chunk-6HSGDMTA.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";function De(e){const{data:t,encoding:n,defaults:s={},scales:i}=e,o=pe({data:t,encoding:n}),r=[],a=new Map,c=[],l=[],d=new Map;return o.rows.forEach((e,t)=>{const{id:o,datum:u}=e,h=Math.max(0,be(n.appearance?.size,u,t)??s.size??6),m=be(n.appearance?.shape,u,t)??s.shape??{type:"circle",radius:h},p=e.placement.x??s.x??0,f=e.placement.y??s.y??0,g=i?.x?i.x(p):p,y=i?.y?i.y(f):f,k=be(n.appearance?.color,u,t)??s.color,x=be(n.appearance?.opacity,u,t)??s.opacity,b=be(n.appearance?.stroke,u,t)??s.stroke,v=be(n.appearance?.strokeWidth,u,t)??s.strokeWidth,w=be(n.time?.spawnAt,u,t)??e.time.arrival,I=e.kinematics.velocityX,D=e.kinematics.velocityY,M=be(n.dynamics?.mass,u,t)??s.mass??1,A=be(n.dynamics?.friction,u,t),T=be(n.dynamics?.restitution,u,t),S=be(n.dynamics?.bodyCollisions,u,t),C={id:o,x:g,y:y,mass:M,shape:{...m},datum:u,...null!=w&&{spawnAt:w},...null!=I&&{vx:I},...null!=D&&{vy:D},...null!=A&&{friction:A},...null!=T&&{restitution:T},...null!=S&&{bodyCollisions:S}},$={...null!=k&&{fill:k},...null!=x&&{opacity:x},...null!=b&&{stroke:b},...null!=v&&{strokeWidth:v}},E={id:o,datum:u,appearance:{color:k,opacity:x,shape:m,size:h,stroke:b,strokeWidth:v},placement:{x:g,y:y,lane:e.placement.lane,space:n.placement?.space??"world"},time:{arrival:w,spawnAt:w,basis:n.time?.basis??"simulation",unit:n.time?.unit},kinematics:{velocityX:I,velocityY:D,space:n.kinematics?.space??"world"},dynamics:{bodyCollisions:S,friction:A,mass:M,restitution:T},process:e.process,evidence:e.evidence,accessible:e.accessible,spawn:C};r.push(E),a.set(o,E),c.push(C),d.set(o,$),l.push({id:o,bodyId:o,label:e.accessible.label,description:e.accessible.description,datum:u,x:g,y:y,group:e.accessible.group})}),{rows:r,byId:a,spawns:c,semanticItems:l,bodyStyle:e=>d.get(e.id)??{}}}function Me(e){return t=>{const n=De({data:t.data,encoding:e.encoding,defaults:e.defaults,scales:t.scales}),s=e.extend?.(t,n)??{};return{...s,initialSpawns:n.spawns,bodyStyle:n.bodyStyle,semanticItems:[...n.semanticItems,...s.semanticItems??[]]}}}var Ae=[.1,.5,.9],Te=1e6;function Se(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ce(e,t,n,s,i){return"function"==typeof s?s(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(e,s??i)}function $e(e){const t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function Ee(e,t,n,s){const i=e.flatMap((e,i)=>{const o=Se(Ce(e,i,t,n,"time")),r=Se(Ce(e,i,t,s,"value"));return null==o||null==r?[]:[{time:$e(o),value:r,index:i}]});i.sort((e,t)=>e.time-t.time||e.index-t.index);const o=[];for(const e of i){const t=o[o.length-1];t?.time===e.time?t.value=e.value:o.push({time:e.time,value:e.value})}return o}function Ne(e,t,n,s){if(!e.length)return null;const i=e[0],o=e[e.length-1];if(i.time>t)return"clamp"===s?i.value:null;if(t>o.time)return"clamp"===s?o.value:null;const r=function(e,t){let n=0,s=e.length;for(;s>n;){const i=n+s>>>1;t>e[i].time?n=i+1:s=i}return n}(e,t),a=e[r];if(a?.time===t)return a.value;const c=e[Math.max(0,r-1)];return"step"!==n&&a&&a.time!==c.time?c.value+(t-c.time)/(a.time-c.time)*(a.value-c.value):c.value}function je(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,s=Math.floor(n),i=Math.ceil(n);return s===i?e[s]:e[s]+(e[i]-e[s])*(n-s)}function Re(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",s=function(e){const t=(e??Ae).map(e=>{const t=Se(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return $e(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),i=function(e){if(Array.isArray(e)){if(e.length>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(e.map(Se).filter(e=>null!=e).map($e))).sort((e,t)=>e-t)}const t=e,n=Se(t.start),s=Se(t.end),i=Se(t.step);if(null==n||null==s||null==i||0>=i||n>s)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const o=Math.floor((s-n)/i)+1;if(o>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const r=[],a=1e-10*Math.max(1,Math.abs(s),Math.abs(n));for(let e=0;o>e;e+=1){const t=n+e*i;if(t>s+a)break;r.push($e(Math.min(t,s)))}if(r.length&&a>=Math.abs(r[r.length-1]-s)||r.push($e(s)),r.length>Te)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(r)).sort((e,t)=>e-t)}(e.sampleAt),o=e.runs.map(t=>Ee(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:i.map(e=>{const i=o.map(s=>Ne(s,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),r={};for(const e of s)r[e]=i.length?je(i,e):null;return{time:e,count:i.length,min:i.length?i[0]:null,max:i.length?i[i.length-1]:null,median:i.length?je(i,.5):null,quantiles:r}}),quantiles:s,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Pe(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function We(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Se(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const s=$e(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,s))throw Error(`comparePhysicsTrace could not find quantile ${s} in the reference envelope`);return e.quantiles[s]??null}function Be(e,t,n){return t>e?"below":e>n?"above":"inside"}function Fe(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const s=e.value-e.lower,i=t.value-t.lower,o=e.value-e.upper,r=t.value-t.upper,a=[0,1];for(const[e,t]of[[s,i],[o,r]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,d=0;for(let s=0;a.length-1>s;s+=1){const i=a[s],o=a[s+1];if(i>=o)continue;const r=(i+o)/2,u=(o-i)*n,h=Be(e.value+(t.value-e.value)*r,e.lower+(t.lower-e.lower)*r,e.upper+(t.upper-e.upper)*r);"below"===h?c+=u:"above"===h?d+=u:l+=u}return{below:c,inside:l,above:d,observed:n}}function Le(e,t,n={}){const s=n.interpolation??t.interpolation,i=n.outsideDomain??t.outsideDomain,o=Ee(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),r=n.lower??Pe(t,"lower"),a=n.upper??Pe(t,"upper"),c=t.points.map(e=>{const t=Ne(o,e.time,s,i),n=We(e,r),c=We(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Be(t,n,c)}});let l=0,d=0,u=0,h=0,m=null,p=0,f=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?d+=1:"above"===e.status&&(u+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,m=e.time),n>p&&(p=n,f=e.time)}let g=0,y=0,k=0,x=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],i=Math.max(0,n.time-t.time);if(i>0){if("linear"===s){const e=Fe(t,n);g+=e.below,y+=e.inside,k+=e.above,x+=e.observed;continue}"unobserved"!==t.status&&(x+=i,"below"===t.status?g+=i:"above"===t.status?k+=i:y+=i)}}const b=c[0]?.time,v=c[c.length-1]?.time,w=null==b||null==v?0:Math.max(0,v-b);return{points:c,sampleCount:c.length,observedSamples:l+d+u,belowSamples:l,insideSamples:d,aboveSamples:u,totalDuration:w,observedDuration:x,unobservedDuration:Math.max(0,w-x),belowDuration:g,insideDuration:y,aboveDuration:k,peakExcess:h,peakExcessAt:m,peakDeficit:p,peakDeficitAt:f}}function qe(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Oe(e,t,n,s){const i="function"==typeof e?e(t,n):e;return Number.isFinite(i)?Number(i):s}function ze(e,t,n){return qe(e[t])??n}function He(e,t){return"number"==typeof e?e:e?.[t]??0}function Ue(e){const{band:t,idPrefix:n,plot:s,projection:i}=e,{includeBoundaryWalls:o=!0,includeInteriorWalls:r=!0,wallThickness:a=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const s of e.values){const i=e.scale(s);Number.isFinite(i)&&(n.add(Number(i)),n.add(Number(i)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=o?c.length-1:c.length-2,d=[];for(let e=o?0:1;l>=e;e+=1){if(!r&&e>0&&c.length-1>e)continue;const t=c[e];d.push({id:`${n}-wall-${e}`,shape:"x"===i?{type:"aabb",x:t,y:s.y+s.height/2,width:a,height:s.height}:{type:"aabb",x:s.x+s.width/2,y:t,width:s.width,height:a}})}return d}function Ze(e){const{plot:t,idPrefix:n="physics-scale",bounds:s={},xBins:i,xBands:o,yBands:r}=e,a=[];if(!1!==s&&a.push(...E(t,{idPrefix:n,...s})),i){const{idPrefix:e,yTop:s,yBottom:o,...r}=i;a.push(...N({...r,idPrefix:e??n+"-xbin",yTop:s??t.y,yBottom:o??t.y+t.height}))}return o&&a.push(...Ue({band:o,idPrefix:o.idPrefix??n+"-xband",plot:t,projection:"x"})),r&&a.push(...Ue({band:r,idPrefix:r.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function Xe(e){const{plot:t,rows:n,columns:s=n+1,pegRadius:i=3,idPrefix:o="galton-peg",yStart:r=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:d=.04}=e,u=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(s));if(0===u)return[];const m=u>1?(a-r)/(u-1):0,p=t.width/h,f=[];for(let e=0;u>e;e+=1){const n=c&&e%2==1?p/2:0;for(let s=0;h>s;s+=1){const a=t.x+p*(s+.5)+n;t.x+i>a||a>t.x+t.width-i||f.push({id:`${o}-${e}-${s}`,shape:{type:"aabb",x:a,y:r+e*m,width:2*i,height:2*i},restitution:l,friction:d})}}return f}function Ye(e,t={}){const{idPrefix:n="physics-token",radius:s=5,shape:i,mass:o,vx:r,vy:a,spawnAt:c,seed:l=1,jitter:d,datum:u}=t,h=ce(l),m=He(d,"x"),p=He(d,"y");return e.map((e,l)=>{const d=Oe(t.x,e,l,ze(e,"x",0)),f=Oe(t.y,e,l,ze(e,"y",0)),g=Oe(s,e,l,5),y="function"==typeof i?i(e,l):i??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:d+(h()-.5)*m,y:f+(h()-.5)*p,vx:Oe(r,e,l,0),vy:Oe(a,e,l,0),mass:Oe(o,e,l,1),spawnAt:Oe(c,e,l,void 0),shape:y,datum:u?u(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Ge(e,t={}){const{idPrefix:n="sediment",collider:s=!0,colliderThickness:i=1,restitution:o=.05,friction:r=.2,...a}=t,c=re(e,a),l=s?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+i/2,width:e.width,height:i},restitution:o,friction:r})):[];return{columns:c,colliders:l}}function Je(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:s=1,startAt:i=0,rebase:o=!0,sort:r=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return qe("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:i+(o?t-c:t)})).sort((e,t)=>r?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:i,timeAccessor:"spawnAt",timeScale:s}}}import{forwardRef as Ke,useCallback as Qe,useEffect as Ve,useImperativeHandle as _e,useMemo as et,useRef as tt,useState as nt}from"react";function st(e,t,n={}){const s=new Set,i=[...e.get(t)??[]];let o=0;for(;i.length>o;){const t=i[o];if(o+=1,!s.has(t)){s.add(t);for(const n of e.get(t)??[])i.push(n)}}return n.includeStart&&s.add(t),s}function it(e,t,n){return be(n,e,t)}function ot(e,t){return t>e?-1:e>t?1:0}function rt(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function at(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function ct(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function lt(e){const t=[],n=new Map,s=[],i=new Set;e.data.forEach((o,r)=>{const a=(it(o,r,e.taskIDAccessor)??"")+"";if(!a)return void t.push({code:"duplicate-task-id",message:`Task row ${r} has an empty id.`,taskIDs:[]});if(n.has(a))return void t.push({code:"duplicate-task-id",message:`Task id "${a}" occurs more than once.`,taskIDs:[a]});const c=(it(o,r,e.laneAccessor)??"Unassigned")+"";i.has(c)||(i.add(c),s.push(c));const l=it(o,r,e.dependencyAccessor)??[],d=Array.from(new Set(Array.from(l,e=>e+""))).sort(ot),u=it(o,r,e.blockerAccessor),h=it(o,r,e.statusAccessor)??(u?"blocked":"waiting");n.set(a,{id:a,label:(it(o,r,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:r,datum:o,dependencyIDs:d,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:it(o,r,e.startAccessor),end:it(o,r,e.endAccessor),progress:ct(it(o,r,e.progressAccessor)),status:h,completionTime:it(o,r,e.completionTimeAccessor),blockerReason:u||void 0,milestone:!!it(o,r,e.milestoneAccessor)})});const o=e.laneOrder?[...e.laneOrder,...s.filter(t=>!e.laneOrder?.includes(t))]:s,r=new Map(o.map((e,t)=>[e,t]));for(const e of n.values())e.laneIndex=r.get(e.lane)??0;const a=new Map,c=new Map;for(const e of n.keys())a.set(e,[]),c.set(e,[]);const l=[],d=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of d)e.dependencyIDs.forEach((s,i)=>{const o=n.get(s);if(!o)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${s}".`,taskIDs:[e.id,s]});const r={id:rt(s,e.id),sourceID:s,targetID:e.id,sourceIndex:o.index,targetIndex:e.index,socketID:at(e.id,i),socketIndex:i};l.push(r),a.get(e.id)?.push(r),c.get(s)?.push(r),e.incomingEdgeIDs.push(r.id),e.socketIDs.push(r.socketID),o.outgoingEdgeIDs.push(r.id)});for(const e of a.values())e.sort((e,t)=>ot(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=at(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>ot(e.targetID,t.targetID));for(const e of n.values()){const t=a.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(c.get(e.id)??[]).map(e=>e.id)}const u=new Map,h=new Map;for(const e of n.keys())u.set(e,a.get(e)?.length??0),h.set(e,0);const m=[...n.keys()].filter(e=>0===u.get(e)).sort(ot);let p=0;for(;m.length;){const e=m.shift();p+=1;for(const t of c.get(e)??[]){const n=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,n);const s=(u.get(t.targetID)??0)-1;if(u.set(t.targetID,s),0===s){const e=m.findIndex(e=>e>t.targetID);0>e?m.push(t.targetID):m.splice(e,0,t.targetID)}}}if(p!==n.size){const e=[...n.keys()].filter(e=>(u.get(e)??0)>0).sort(ot);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let f=0;const g=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of g)e.level=h.get(e.id)??0,f=Math.max(f,e.level);return{nodes:g,edges:l,byID:n,incoming:a,outgoing:c,lanes:o,maxLevel:f,diagnostics:t,valid:0===t.length}}function dt(e,t,n={}){const s=Math.max(240,t.width),i=Math.max(220,t.height),o=t.paddingX??48,r=t.paddingTop??48,a=t.paddingBottom??44,c=Math.max(70,(s-2*o)/Math.max(1,e.lanes.length)),l=Math.max(76,(i-r-a)/Math.max(1,e.maxLevel+1)),d=Math.min(n.taskWidth??112,Math.max(58,.78*c)),u=Math.min(n.taskHeight??58,.64*l),h=n.socketRadius??5,m=Math.max(1,Math.round(n.gutterCount??3)),p=new Map;for(const t of e.nodes){const e=`${t.laneIndex}:${t.level}`,n=p.get(e)??[];n.push(t),p.set(e,n)}for(const e of p.values())e.sort((e,t)=>ot(e.id,t.id));const f=e.nodes.map(e=>{const t=p.get(`${e.laneIndex}:${e.level}`)??[e],n=Math.max(0,t.findIndex(t=>t.id===e.id));return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:o+c*(e.laneIndex+.5),y:r+l*(e.level+.5)+(n-(t.length-1)/2)*Math.min(18,.3*u),width:d,height:u}}),g=new Map(f.map(e=>[e.taskID,e])),y=[],k=[];e.edges.forEach((t,n)=>{const s=g.get(t.sourceID),i=g.get(t.targetID);if(!s||!i)return;const o=e.incoming.get(t.targetID)??[],r=Math.min(.72*i.width,14*Math.max(1,o.length-1)),a=o.length>1?i.x-r/2+r*t.socketIndex/(o.length-1):i.x,c=i.y-i.height/2-h-2;y.push({id:t.socketID,edgeID:t.id,taskID:i.taskID,index:t.socketIndex,x:a,y:c,radius:h});const l={x:s.x,y:s.y+s.height/2+3},d=Math.min(c-10,l.y+.48*Math.max(18,c-l.y)+7*(n%m-(m-1)/2));var u;k.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(u=[l,{x:l.x,y:d},{x:a,y:d},{x:a,y:c}],u.filter((e,t)=>{const n=u[t-1];return!n||n.x!==e.x||n.y!==e.y}))})});const x=new Map(y.map(e=>[e.id,e])),b=new Map(k.map(e=>[e.edgeID,e]));return{tasks:f,sockets:y,routes:k,taskByID:g,socketByID:x,routeByEdgeID:b}}function ut(e,t,n="all"){const s=Array.from(new Set(t)).sort(ot),i=new Set,o=()=>s.every(e=>i.has(e));return{taskID:e,mode:n,incomingEdgeIDs:s,deliver:e=>s.includes(e)?(i.add(e),o()):o(),reset:(e=[])=>{i.clear();for(const t of e)s.includes(t)&&i.add(t)},isSatisfied:o,getSnapshot:()=>({taskID:e,mode:n,incomingEdgeIDs:[...s],deliveredEdgeIDs:[...i].sort(ot),satisfied:o()})}}function ht(e){return e instanceof Date?e.getTime():Number(e)}function mt(e,t){const n=ht("object"!=typeof t||t instanceof Date?t:t.currentTime),s=e.map((e,t)=>({event:e,index:t,time:ht(e.at)})).filter(e=>Number.isFinite(e.time)&&n>=e.time).sort((e,t)=>e.time-t.time||e.index-t.index),i=new Set,o=new Map,r=new Set,a=new Set;for(const{event:e}of s)"task-completed"===e.type?(i.add(e.taskID),o.delete(e.taskID)):"task-blocked"===e.type?o.set(e.taskID,e.reason):"task-unblocked"===e.type?o.delete(e.taskID):"dependency-delivered"===e.type?r.add(e.edgeID):"task-armed"===e.type&&a.add(e.taskID);return{currentTime:n,appliedEvents:s.map(e=>e.event),completedTaskIDs:i,blockedByTaskID:o,deliveredEdgeIDs:r,armedTaskIDs:a}}function pt(e,t,n={}){const s=new Set(n.completedTaskIDs??[]),i=[...st(function(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target);return n}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(n.isComplete?n.isComplete(e):s.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),o=Array.from(new Set(i.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:i.length,affectedLaneCount:o.length,downstreamTaskIDs:i.map(e=>e.id),affectedLanes:o}}var ft=[];function gt(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function yt(e){if(null==e.completionTime)return null;const t=gt(e.completionTime,NaN);return Number.isFinite(t)?t:null}function kt(e,t,n,s){const i=new Set;for(const o of e.nodes){const r=e.incoming.get(o.id)??[];(s.has(o.id)||!n.has(o.id)&&r.every(e=>t.has(e.id)))&&i.add(o.id)}return i}function xt(e,t,n,s){const i=e.nodes.map(yt).filter(e=>null!=e),o=i.length?Math.min(...i)-1:0,r="replay"!==t||s?n:o,a=new Set,c=new Map;for(const n of e.nodes){const e=yt(n);(null!=e&&r>=e||"done"===n.status&&"replay"!==t)&&a.add(n.id),n.blockerReason&&!a.has(n.id)&&c.set(n.id,n.blockerReason)}const l=new Set;if("replay"!==t||s)for(const t of e.edges)a.has(t.sourceID)&&l.add(t.id);return{currentTime:r,playing:!1,completed:a,delivered:l,inFlight:new Set,armed:kt(e,l,c,a),blockers:c,previewTaskID:null}}function bt(e){return{...e,completed:new Set(e.completed),delivered:new Set(e.delivered),inFlight:new Set(e.inFlight),armed:new Set(e.armed),blockers:new Map(e.blockers)}}function vt(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function wt(e){const t=vt(e.body);if(!t||2>t.route.length)return null;const n=function(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}(t.route),s=function(e,t){let n=1/0,s=0,i=0;for(let o=1;t.length>o;o+=1){const r=t[o-1],a=t[o],c=a.x-r.x,l=a.y-r.y,d=c*c+l*l,u=Math.sqrt(d);if(0>=u)continue;const h=Math.max(0,Math.min(1,((e.x-r.x)*c+(e.y-r.y)*l)/d)),m=Math.hypot(e.x-(r.x+c*h),e.y-(r.y+l*h));n>m&&(n=m,s=i+h*u),i+=u}return s}(e.body,t.route),i=function(e,t){if(2>e.length)return{point:e[0]??{x:0,y:0},tangent:{x:0,y:1}};let n=0;for(let s=1;e.length>s;s+=1){const i=e[s-1],o=e[s],r=o.x-i.x,a=o.y-i.y,c=Math.hypot(r,a);if(c>0){if(n+c>=t){const e=Math.max(0,Math.min(1,(t-n)/c));return{point:{x:i.x+r*e,y:i.y+a*e},tangent:{x:r/c,y:a/c}}}n+=c}}const s=e[e.length-2],i=e[e.length-1],o=i.x-s.x,r=i.y-s.y,a=Math.hypot(o,r)||1;return{point:i,tangent:{x:o/a,y:r/a}}}(t.route,Math.min(n,s+22));return{x:2.5*(78*i.tangent.x-e.body.vx)+8*(i.point.x-e.body.x),y:2.5*(78*i.tangent.y-e.body.vy)+8*(i.point.y-e.body.y)}}function It(e,t){const n=t.points[0]??{x:0,y:0},s=t.points[1]??n,i=s.x-n.x,o=s.y-n.y,r=Math.hypot(i,o)||1;return{id:"dependency-ball:"+e.id,x:n.x,y:n.y,vx:i/r*42,vy:o/r*42,mass:.7,restitution:.02,friction:.12,bodyCollisions:!1,shape:{type:"circle",radius:5},datum:{kind:"dependency-ball",edgeID:e.id,sourceID:e.sourceID,targetID:e.targetID,route:t.points}}}import{jsx as Dt,jsxs as Mt}from"react/jsx-runtime";function At({machine:e,layout:t,runtime:n,downstreamSet:s,selectedSet:i,width:o,height:r,seed:a,reduced:c,onSelectTask:l}){return Mt("svg",{"aria-hidden":"true",width:o,height:r,viewBox:`0 0 ${o} ${r}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Dt("defs",{children:Dt("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Dt("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,n)=>{const s=t.tasks.filter(e=>e.laneIndex===n),i=s[0]?.x??0;return Mt("g",{children:[Dt("line",{x1:i,x2:i,y1:32,y2:r-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Dt("text",{x:i,y:23,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{const t=n.delivered.has(e.edgeID),i=n.inFlight.has(e.edgeID),o=s.has(e.targetID)||s.has(e.sourceID),r=e.points.map(e=>`${e.x},${e.y}`).join(" ");return Dt("polyline",{points:r,fill:"none",stroke:o?"var(--semiotic-highlight, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:o?4:i?3:2,strokeOpacity:t||i||o?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{const t=n.delivered.has(e.edgeID);return Mt("g",{children:[Dt("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-background, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&Dt("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{const o=t.taskByID.get(e.id);if(!o)return null;const r=n.completed.has(e.id),d=n.blockers.has(e.id),u=n.previewTaskID===e.id,h=i.has(e.id)||u,m=s.has(e.id),p=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-muted, #75818a)"}(e,n),f=o.x-o.width/2,g=o.y-o.height/2,y=Math.max(2,o.height*e.progress);return Mt("g",{children:[Mt("g",{style:{transform:`rotate(${r?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:c?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+a+")"},children:[Dt("rect",{x:f,y:g,width:o.width,height:o.height,rx:e.milestone?12:4,fill:"var(--semiotic-background, #fff)",stroke:h||m?"var(--semiotic-highlight, #e08a1e)":p,strokeWidth:h?4:m?3:2}),Dt("rect",{x:f+3,y:g+o.height-y+1,width:o.width-6,height:Math.max(0,y-4),rx:2,fill:p,opacity:r?.86:.46})]}),d&&Mt("g",{opacity:u?.28:1,children:[Dt("line",{x1:f-8,x2:f+14,y1:o.y+9,y2:o.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Dt("circle",{cx:f-8,cy:o.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),Mt("g",{onPointerDown:()=>l(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Dt("rect",{x:f,y:g,width:o.width,height:o.height,fill:"transparent"}),Dt("text",{x:o.x,y:o.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),Mt("text",{x:o.x,y:o.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-muted, #5f6b72)",children:[Math.round(100*e.progress),"% · ",r?"done":d?"blocked":n.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}import{jsx as Tt,jsxs as St}from"react/jsx-runtime";var Ct={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},$t=Ke(function(e,t){const{data:n,taskIDAccessor:s,labelAccessor:i,laneAccessor:o,dependencyAccessor:r,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:d,completionTimeAccessor:u,blockerAccessor:h,milestoneAccessor:m,mode:p="snapshot",insight:f="blocker-amplification",currentTime:g,controls:k=!1,selectedTaskIDs:x,onSelectionChange:b,onObservation:v,reducedMotion:w,seed:I=31,width:D=920,height:M=620,responsiveWidth:A,responsiveHeight:T,title:S="Dependency chain reaction",description:C,className:$,accessibleTable:E=!0,enableHover:N=!0}=e,j=tt(null),[R,P]=nt([]),W=x?Array.from(x):R,B=et(()=>new Set(W),[W]),F=gt(g,1/0),L="settle"===w,q=et(()=>lt({data:n,taskIDAccessor:s,labelAccessor:i,laneAccessor:o,dependencyAccessor:r,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:d,completionTimeAccessor:u,blockerAccessor:h,milestoneAccessor:m}),[n,s,i,o,r,a,c,l,d,u,h,m]),O=et(()=>dt(q,{width:D,height:M}),[q,D,M]),[z,H]=nt(()=>xt(q,p,F,L)),U=tt(z),Z=Qe(e=>{U.current=e,H(e)},[]),X=Qe(e=>v?.(e),[v]);Ve(()=>{const e=xt(q,p,F,L);j.current?.clear(),U.current=e,H(e)},[q,p,F,L]);const Y=Qe(e=>{const t=B.has(e)?W.filter(t=>t!==e):[e];x||P(t),b?.(t)},[x,b,B,W]),G=Qe(e=>{if(L)return;const t=bt(U.current),n=[];for(const s of q.outgoing.get(e)??[]){if(t.delivered.has(s.id)||t.inFlight.has(s.id))continue;const e=O.routeByEdgeID.get(s.id);e&&(t.inFlight.add(s.id),n.push(It(s,e)))}n.length&&(Z(t),j.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[Z,O,q,L]),J=Qe((e,t)=>{const n=q.byID.get(e),s=U.current;if(!n||s.completed.has(e))return;const i=bt(s);i.completed.add(e),i.blockers.delete(e),i.armed.add(e),null!=t&&(i.currentTime=t),Z(i),X({type:"task-completed",taskID:e,datum:n.datum}),G(e)},[Z,X,q,G]),K=Qe(e=>{const t=bt(U.current),n=[],s=[];for(const s of e){if(t.delivered.has(s))continue;const e=q.edges.find(e=>e.id===s);e&&(t.delivered.add(s),t.inFlight.delete(s),n.push(e))}for(const e of n){const n=q.byID.get(e.targetID);!n||t.blockers.has(n.id)||t.armed.has(n.id)||(q.incoming.get(n.id)??[]).every(e=>t.delivered.has(e.id))&&(t.armed.add(n.id),s.push(n.id))}if(n.length){Z(t);for(const e of n)X({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of s)X({type:"task-armed",taskID:e})}},[Z,X,q]),Q=Qe((e,t)=>{const n=[],s=[];for(const e of t.readBodies()){const t=vt(e);if(!t||U.current.delivered.has(t.edgeID))continue;const i=t.route[t.route.length-1];i&&9>=Math.hypot(e.x-i.x,e.y-i.y)&&(n.push(t.edgeID),s.push(e.id))}s.length&&t.remove(s),n.length&&K(n)},[K]),V=Qe(()=>{const e=bt(U.current);for(const t of q.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=kt(q,e.delivered,e.blockers,e.completed),e.playing=!1,j.current?.settle(),Z(e),X({type:"machine-settled"})},[Z,X,q]),_=Qe(()=>{const e=bt(U.current);e.playing=!1,Z(e)},[Z]),ee=Qe(()=>{const e=U.current,t=q.nodes.map(e=>({node:e,time:yt(e)})).filter(t=>null!=t.time&&t.time>e.currentTime&&!e.completed.has(t.node.id)).sort((e,t)=>e.time-t.time||e.node.index-t.node.index)[0];if(t)return void J(t.node.id,t.time);_();const n=[...e.blockers.keys()].map(t=>pt(q,t,{completedTaskIDs:e.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);n[0]&&X({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[X,q,_,J]),te=Qe(()=>{if(L)return void V();const e=bt(U.current);e.playing=!0,Z(e)},[Z,L,V]);Ve(()=>{if(!z.playing||"replay"!==p||L)return;const e=window.setInterval(ee,760);return()=>window.clearInterval(e)},[p,L,z.playing,ee]);const ne=Qe(()=>{j.current?.clear(),Z(xt(q,p,F,L))},[Z,q,p,F,L]),se=Qe(e=>{if(!q.byID.has(e))return;const t=bt(U.current);t.previewTaskID=e,Z(t);const n=pt(q,e,{completedTaskIDs:t.completed});X({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[Z,X,q]),ie=Qe(()=>{const e=bt(U.current);e.previewTaskID=null,Z(e)},[Z]),oe=Qe((e,t)=>{if(!q.byID.has(e))return;const n=bt(U.current);n.blockers.set(e,t),n.armed.delete(e),Z(n)},[Z,q]),re=Qe(e=>{if(!q.byID.has(e))return;const t=bt(U.current);t.blockers.delete(e),(q.incoming.get(e)??[]).every(e=>t.delivered.has(e.id))&&t.armed.add(e),Z(t)},[Z,q]),ae=Qe(e=>pt(q,e,{completedTaskIDs:U.current.completed}),[q]),ce=Qe(()=>{const e=U.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...W],tasks:q.nodes.map(t=>({taskID:t.id,completed:e.completed.has(t.id),armed:e.armed.has(t.id),blocked:e.blockers.has(t.id),blockerReason:e.blockers.get(t.id)})),dependencies:q.edges.map(t=>({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,state:e.delivered.has(t.id)?"delivered":e.inFlight.has(t.id)?"in-flight":"waiting"}))}},[q,W]);_e(t,()=>({play:te,pause:_,step:ee,reset:ne,settle:V,previewResolve:se,clearPreview:ie,completeTask:J,blockTask:oe,unblockTask:re,getAmplification:ae,getMachineState:ce}),[oe,ie,ae,ce,_,J,te,se,ne,V,ee,re]);const le=z.previewTaskID??W[0]??null,de=le?pt(q,le,{completedTaskIDs:z.completed}):null,ue=et(()=>new Set(de?.downstreamTaskIDs??[]),[de?.downstreamTaskIDs]),he=et(()=>function(e,t,n){return e.nodes.flatMap(s=>{const i=t.taskByID.get(s.id);if(!i)return[];const o=e.incoming.get(s.id)??[],r=o.filter(e=>n.delivered.has(e.id)).length,a=n.blockers.get(s.id),c=n.completed.has(s.id)?"completed":a?"blocked: "+a:n.armed.has(s.id)?"armed":"waiting";return[{id:s.id,label:`${s.label}, ${s.lane}, ${Math.round(100*s.progress)}%, ${c}`,description:`${r} of ${o.length} prerequisites delivered.`,datum:s.datum,x:i.x,y:i.y,width:i.width,height:i.height,shape:"rect",group:s.lane}]})}(q,O,z),[O,q,z]),me=et(()=>Tt(At,{machine:q,layout:O,runtime:z,downstreamSet:ue,selectedSet:B,width:D,height:M,seed:I,reduced:L,onSelectTask:Y}),[ue,M,O,q,L,z,I,Y,B,D]),pe=et(()=>{const e=[...z.blockers.keys()].map(e=>pt(q,e,{completedTaskIDs:z.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);return e.length?e.map(e=>`${q.byID.get(e.blockerID)?.label??e.blockerID} affects ${e.downstreamTaskCount} unfinished tasks across ${e.affectedLaneCount} lanes.`).join(" "):"No explicit blockers are active."},[q,z.blockers,z.completed]),fe=et(()=>[{id:"chain-left",shape:{type:"segment",x1:2,y1:0,x2:2,y2:M,thickness:4}},{id:"chain-right",shape:{type:"segment",x1:D-2,y1:0,x2:D-2,y2:M,thickness:4}},{id:"chain-top",shape:{type:"segment",x1:0,y1:2,x2:D,y2:2,thickness:4}},{id:"chain-bottom",shape:{type:"segment",x1:0,y1:M-2,x2:D,y2:M-2,thickness:4}}],[M,D]),ge=!0===k?["play","pause","step","reset","settle"]:k||[];return St("div",q.valid?{className:$,style:{width:D,maxWidth:"100%",position:"relative"},children:[ge.length>0&&Tt("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:ge.map(e=>Tt("button",{type:"button",onClick:"play"===e?te:"pause"===e?_:"step"===e?ee:"reset"===e?ne:V,"aria-pressed":"play"===e?z.playing:void 0,children:e[0].toUpperCase()+e.slice(1)},e))}),Tt(y,{ref:j,size:[D,M],responsiveWidth:A,responsiveHeight:T,title:S,description:C??"Tasks are arranged by workstream and dependency depth. Balls represent satisfied prerequisites; task completion remains an explicit data event.",summary:`${pe}${de&&"blocker-amplification"===f?` Selected task reaches ${de.downstreamTaskCount} unfinished tasks across ${de.affectedLaneCount} lanes.`:""}`,accessibleTable:!1,enableHover:N,initialSpawns:ft,bodyForces:wt,bodyStyle:{fill:"var(--semiotic-accent, #f0a329)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.25},bodySemanticItems:!1,semanticItems:he,onSemanticItemActivate:e=>e.id&&Y(e.id),foregroundGraphics:()=>me,paused:L,continuous:z.inFlight.size>0,onTick:Q,config:{bodyLimit:Math.max(16,q.edges.length+4),colliders:fe,settleStepLimit:2200,kernel:{seed:I,gravity:{x:0,y:7},fixedDt:1/60,cellSize:28,collisionIterations:2,velocityDamping:.992,restitution:.02,friction:.12,maxVelocity:150,sleepSpeed:1.1,sleepAfter:.8},observation:{chartType:"ChainReactionChart"}}}),E&&St("table",{style:Ct,children:[Tt("caption",{children:pe}),Tt("thead",{children:St("tr",{children:[Tt("th",{children:"Task"}),Tt("th",{children:"Lane"}),Tt("th",{children:"Progress"}),Tt("th",{children:"State"}),Tt("th",{children:"Waiting on"}),Tt("th",{children:"Downstream reach"})]})}),Tt("tbody",{children:q.nodes.map(e=>{const t=pt(q,e.id,{completedTaskIDs:z.completed});return St("tr",{children:[Tt("th",{scope:"row",children:e.label}),Tt("td",{children:e.lane}),St("td",{children:[Math.round(100*e.progress),"%"]}),Tt("td",{children:z.completed.has(e.id)?"Completed":z.blockers.has(e.id)?"Blocked":z.armed.has(e.id)?"Armed":"Waiting"}),Tt("td",{children:z.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!z.completed.has(e)).join(", ")||"None")}),St("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:$,role:"alert",style:{width:D,maxWidth:"100%"},children:[Tt("strong",{children:"ChainReactionChart could not compile this dependency graph."}),Tt("ul",{children:q.diagnostics.map((e,t)=>Tt("li",{children:e.message},`${e.code}-${t}`))})]})});$t.displayName="ChainReactionChart";var Et=y;export{s as BuiltInPhysicsEngineAdapter,$t as ChainReactionChart,i as CollisionSwarmChart,o as EventDropChart,r as GaltonBoardChart,a as GauntletChart,c as GuantletChart,l as PhysicalFlowChart,d as PhysicsCustomChart,u as PhysicsPileChart,h as PhysicsPipelineStore,m as PhysicsSVGOverlay,p as PhysicsSedimentAccumulator,f as ProcessFlowChart,g as StreamPhysicsFrame,k as absorbRegion,x as aggregateRegionCounts,Je as arrivalReplay,b as bodiesToAnnotationAnchors,v as bodyGroupSpec,w as buildCollisionSwarmPhysics,I as buildEventDropPhysics,D as buildGaltonBoardPhysics,M as buildPhysicalFlowPhysics,A as buildPhysicsAnnotationContext,T as buildPhysicsPile,S as buildProcessFlowPhysics,pt as calculateBlockerAmplification,C as capacitatedRegion,$ as chargeGateRegion,Ze as collidersFromScales,Le as comparePhysicsTrace,lt as compileDependencyMachine,pe as compileMotionEncoding,De as compilePhysicsEncoding,j as composePhysicsControllers,le as composeStyleRules,R as createCapacityQueueController,P as createDefaultPhysicsEngineAdapter,W as createDependencyGateController,ut as createLogicalJoin,Me as createPhysicsEncodingLayout,B as createPortalController,e as createProcessJourneyLedger,F as createServiceLevelController,L as createServiceResourcePoolController,Et as default,fe as deriveMotionVector,q as evaluatePhysicsBodyBudget,O as forceFieldRegion,Xe as galtonPegs,z as groupCompletionRows,ge as hatchFillId,ye as hatchPatternDef,ke as isHatchFill,de as makeRuleValueResolver,ue as matchesThreshold,H as membraneRegion,U as normalizePhysicsAnnotations,xe as opacityFromAge,Z as physicsProcessBoundaryColliders,X as physicsProcessGroupSemanticItems,Y as physicsProcessRegionSemanticItem,G as physicsProcessStageSemanticItems,Re as physicsReferenceEnvelope,J as planGauntletPropertyWork,K as portalRegion,Q as pressureFieldRegion,V as processChrome,t as processJourneyRows,_ as processLaneWalls,ee as processStageLayout,te as processStageRegions,ne as processVolumePolygons,se as regionCountsToProjectionRows,ie as replaceGauntletNegative,mt as replayStateTransitions,be as resolveMotionAccessor,ve as resolveMotionAge,we as resolveMotionVector,he as resolveStyleRules,Ie as resolveSvgFill,dt as routeDependencyTracks,oe as routeSurfaceRegion,me as ruleMatches,Ge as sedimentBake,re as sedimentHeightfield,Ye as spawnFromTokens,ae as stageTargetInVolume,n as updateProcessJourney};