semiotic 3.8.4 → 3.8.5

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 (140) hide show
  1. package/CLAUDE.md +6 -3
  2. package/README.md +44 -38
  3. package/ai/componentMetadata.cjs +1 -1
  4. package/ai/dist/mcp-server.js +4 -2
  5. package/ai/examples.md +167 -0
  6. package/ai/schema.json +1004 -1
  7. package/ai/surface-manifest.json +6 -4
  8. package/ai/system-prompt.md +1 -1
  9. package/dist/chunk-chartContainerDataAudit-74TLKIP6.module.min.js +2 -0
  10. package/dist/{chunk-chunk-LQBSXO7K.module.min.js → chunk-chunk-4AANPFOX.module.min.js} +1 -1
  11. package/dist/{chunk-chunk-N6VKKF3A.module.min.js → chunk-chunk-5I3UZV4Q.module.min.js} +1 -1
  12. package/dist/chunk-chunk-74CCPVXB.module.min.js +1 -0
  13. package/dist/{chunk-chunk-6TPGFL7M.module.min.js → chunk-chunk-BANTPINB.module.min.js} +1 -1
  14. package/dist/chunk-chunk-CKMD5NV3.module.min.js +2 -0
  15. package/dist/chunk-chunk-CO5KQMGH.module.min.js +1 -0
  16. package/dist/{chunk-chunk-BFHUYEOS.module.min.js → chunk-chunk-CWQ5YIHX.module.min.js} +1 -1
  17. package/dist/chunk-chunk-E6TXX6MI.module.min.js +1 -0
  18. package/dist/{chunk-chunk-JDXT6ORT.module.min.js → chunk-chunk-I36PJ4OC.module.min.js} +1 -1
  19. package/dist/chunk-chunk-K3DMEW22.module.min.js +1 -0
  20. package/dist/chunk-chunk-KT2VAZMZ.module.min.js +1 -0
  21. package/dist/{chunk-chunk-AQPQN2HH.module.min.js → chunk-chunk-L6EA5V3G.module.min.js} +1 -1
  22. package/dist/{chunk-chunk-FBGHXL72.module.min.js → chunk-chunk-LJLS6DY7.module.min.js} +1 -1
  23. package/dist/chunk-chunk-LJPCLYSC.module.min.js +2 -0
  24. package/dist/{chunk-chunk-7RYBCTK5.module.min.js → chunk-chunk-N5DDKCCF.module.min.js} +1 -1
  25. package/dist/chunk-chunk-NLO44TOS.module.min.js +2 -0
  26. package/dist/{chunk-chunk-F5V4UIE6.module.min.js → chunk-chunk-PZJ2SBLL.module.min.js} +1 -1
  27. package/dist/chunk-chunk-QUJ6TTLY.module.min.js +1 -0
  28. package/dist/chunk-chunk-RBIDBUT4.module.min.js +2 -0
  29. package/dist/chunk-chunk-RFLAG356.module.min.js +1 -0
  30. package/dist/{chunk-chunk-7KZJUTKP.module.min.js → chunk-chunk-RPU4IZAV.module.min.js} +1 -1
  31. package/dist/{chunk-chunk-PLIDPQNG.module.min.js → chunk-chunk-SKMBCFIL.module.min.js} +1 -1
  32. package/dist/{chunk-chunk-SR4ZXOWR.module.min.js → chunk-chunk-TAE7W424.module.min.js} +1 -1
  33. package/dist/{chunk-chunk-KQ546MKE.module.min.js → chunk-chunk-TMWIZL3K.module.min.js} +1 -1
  34. package/dist/chunk-chunk-TUBMTZMU.module.min.js +2 -0
  35. package/dist/chunk-chunk-UFFEXJQY.module.min.js +1 -0
  36. package/dist/chunk-chunk-XSCHTS4D.module.min.js +2 -0
  37. package/dist/{chunk-chunk-F7WFPD4O.module.min.js → chunk-chunk-XXWSHGPL.module.min.js} +1 -1
  38. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +2 -0
  39. package/dist/components/ChartContainer.d.ts +10 -0
  40. package/dist/components/ai/chartCapabilities.d.ts +2 -1
  41. package/dist/components/ai/chartCapabilityTypes.d.ts +14 -0
  42. package/dist/components/chartContainerDataAudit.d.ts +10 -0
  43. package/dist/components/charts/geo/DistanceCartogram.d.ts +29 -3
  44. package/dist/components/charts/index.d.ts +1 -0
  45. package/dist/components/charts/network/ForceDirectedGraph.d.ts +36 -1
  46. package/dist/components/charts/physics/CrucibleChart.capability.d.ts +8 -0
  47. package/dist/components/charts/physics/CrucibleChart.d.ts +63 -0
  48. package/dist/components/charts/physics/crucibleBodyRenderers.d.ts +27 -0
  49. package/dist/components/charts/physics/crucibleChartProps.d.ts +90 -0
  50. package/dist/components/charts/physics/crucibleChrome.d.ts +47 -0
  51. package/dist/components/charts/physics/crucibleController.d.ts +59 -0
  52. package/dist/components/charts/physics/crucibleEffects.d.ts +30 -0
  53. package/dist/components/charts/physics/cruciblePhysics.d.ts +54 -0
  54. package/dist/components/charts/physics/crucibleProgram.d.ts +38 -0
  55. package/dist/components/charts/physics/crucibleTypes.d.ts +415 -0
  56. package/dist/components/charts/shared/chartSpecCore.d.ts +8 -0
  57. package/dist/components/charts/shared/crucibleWireSchema.d.ts +5 -0
  58. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  59. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  60. package/dist/components/data/auditData.d.ts +51 -0
  61. package/dist/components/data/dataAuditPresentation.d.ts +18 -0
  62. package/dist/components/data/dataAuditSources.d.ts +9 -0
  63. package/dist/components/data/numericContracts.d.ts +59 -0
  64. package/dist/components/data/numericFieldProfiler.d.ts +23 -0
  65. package/dist/components/recipes/netEnsembleLayout.d.ts +167 -0
  66. package/dist/components/recipes/netEnsembleOverlays.d.ts +20 -0
  67. package/dist/components/recipes/wordTrails.d.ts +156 -0
  68. package/dist/components/recipes/wordTrailsProgressiveReveal.d.ts +42 -0
  69. package/dist/components/semiotic-ai-core.d.ts +3 -0
  70. package/dist/components/semiotic-ai-data-audit.d.ts +4 -0
  71. package/dist/components/semiotic-ai.d.ts +7 -5
  72. package/dist/components/semiotic-physics.d.ts +1 -0
  73. package/dist/components/semiotic-recipes-core.d.ts +4 -0
  74. package/dist/components/semiotic-utils-core.d.ts +3 -0
  75. package/dist/components/semiotic.d.ts +1 -1
  76. package/dist/components/server/renderEvidence.d.ts +27 -0
  77. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  78. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  79. package/dist/components/server/staticAnnotations.d.ts +12 -0
  80. package/dist/components/stream/GeoPipelineStore.d.ts +1 -0
  81. package/dist/components/stream/GeoSVGOverlay.d.ts +7 -0
  82. package/dist/components/stream/geoCartogram.d.ts +7 -0
  83. package/dist/components/stream/geoTypes.d.ts +17 -2
  84. package/dist/components/stream/networkFrameHandleTypes.d.ts +4 -0
  85. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +8 -0
  86. package/dist/components/useChartContainerDataAudit.d.ts +7 -0
  87. package/dist/geo.min.js +1 -1
  88. package/dist/geo.module.min.js +1 -1
  89. package/dist/network.min.js +1 -1
  90. package/dist/network.module.min.js +1 -1
  91. package/dist/ordinal.module.min.js +1 -1
  92. package/dist/physics.min.js +1 -1
  93. package/dist/physics.module.min.js +1 -1
  94. package/dist/realtime.min.js +1 -1
  95. package/dist/realtime.module.min.js +1 -1
  96. package/dist/semiotic-ai-core.d.ts +3 -0
  97. package/dist/semiotic-ai-core.min.js +1 -1
  98. package/dist/semiotic-ai-core.module.min.js +1 -1
  99. package/dist/semiotic-ai.d.ts +7 -5
  100. package/dist/semiotic-ai.min.js +1 -1
  101. package/dist/semiotic-ai.module.min.js +1 -1
  102. package/dist/semiotic-experimental.min.js +1 -1
  103. package/dist/semiotic-experimental.module.min.js +1 -1
  104. package/dist/semiotic-physics.d.ts +1 -0
  105. package/dist/semiotic-realtime-core.min.js +1 -1
  106. package/dist/semiotic-realtime-core.module.min.js +1 -1
  107. package/dist/semiotic-recipes-core.d.ts +4 -0
  108. package/dist/semiotic-recipes-core.min.js +1 -1
  109. package/dist/semiotic-recipes-core.module.min.js +1 -1
  110. package/dist/semiotic-recipes.min.js +1 -1
  111. package/dist/semiotic-recipes.module.min.js +1 -1
  112. package/dist/semiotic-server-edge.min.js +1 -1
  113. package/dist/semiotic-server-edge.module.min.js +1 -1
  114. package/dist/semiotic-server-node.min.js +1 -1
  115. package/dist/semiotic-server-node.module.min.js +1 -1
  116. package/dist/semiotic-utils-core.d.ts +3 -0
  117. package/dist/semiotic-utils-core.min.js +1 -1
  118. package/dist/semiotic-utils-core.module.min.js +1 -1
  119. package/dist/semiotic-utils.min.js +1 -1
  120. package/dist/semiotic-utils.module.min.js +1 -1
  121. package/dist/semiotic.d.ts +1 -1
  122. package/dist/semiotic.min.js +1 -1
  123. package/dist/semiotic.module.min.js +1 -1
  124. package/dist/server.min.js +1 -1
  125. package/dist/server.module.min.js +1 -1
  126. package/dist/xy.module.min.js +1 -1
  127. package/package.json +2 -2
  128. package/dist/chunk-chunk-3ILKBVVQ.module.min.js +0 -1
  129. package/dist/chunk-chunk-ASKSE5F5.module.min.js +0 -1
  130. package/dist/chunk-chunk-B3DRZPBK.module.min.js +0 -2
  131. package/dist/chunk-chunk-FP44FHFO.module.min.js +0 -2
  132. package/dist/chunk-chunk-HKXUAEPJ.module.min.js +0 -2
  133. package/dist/chunk-chunk-ICEXPNDC.module.min.js +0 -2
  134. package/dist/chunk-chunk-JMVEIZXP.module.min.js +0 -1
  135. package/dist/chunk-chunk-KHCOJMGK.module.min.js +0 -1
  136. package/dist/chunk-chunk-MFHF4J2Z.module.min.js +0 -1
  137. package/dist/chunk-chunk-NKZ75IM5.module.min.js +0 -2
  138. package/dist/chunk-chunk-QGZGZI4X.module.min.js +0 -1
  139. package/dist/chunk-chunk-RP7WTID5.module.min.js +0 -1
  140. package/dist/chunk-chunk-S7KLNUO6.module.min.js +0 -1
@@ -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 B,createDependencyGateController as P,createPortalController as W,createServiceLevelController as F,createServiceResourcePoolController as L,evaluatePhysicsBodyBudget as q,forceFieldRegion as O,groupCompletionRows as z,membraneRegion as H,normalizePhysicsAnnotations as U,physicsProcessBoundaryColliders as X,physicsProcessGroupSemanticItems as Y,physicsProcessRegionSemanticItem as J,physicsProcessStageSemanticItems as Z,planGauntletPropertyWork as G,portalRegion as K,pressureFieldRegion as V,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-HKXUAEPJ.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-FBGHXL72.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-BFHUYEOS.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-ACLDBMRH.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 Be(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Pe(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 We(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=We(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??Be(t,"lower"),a=n.upper??Be(t,"upper"),c=t.points.map(e=>{const t=Ne(o,e.time,s,i),n=Pe(e,r),c=Pe(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":We(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 Xe(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 Ye(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 Je(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 Ze(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 Ge(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 Ve,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=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,B]=nt([]),P=x?Array.from(x):R,W=et(()=>new Set(P),[P]),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),X=Ve(e=>{U.current=e,H(e)},[]),Y=Ve(e=>v?.(e),[v]);Qe(()=>{const e=xt(q,p,F,L);j.current?.clear(),U.current=e,H(e)},[q,p,F,L]);const J=Ve(e=>{const t=W.has(e)?P.filter(t=>t!==e):[e];x||B(t),b?.(t)},[x,b,W,P]),Z=Ve(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&&(X(t),j.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[X,O,q,L]),G=Ve((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),X(i),Y({type:"task-completed",taskID:e,datum:n.datum}),Z(e)},[X,Y,q,Z]),K=Ve(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){X(t);for(const e of n)Y({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of s)Y({type:"task-armed",taskID:e})}},[X,Y,q]),V=Ve((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]),Q=Ve(()=>{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(),X(e),Y({type:"machine-settled"})},[X,Y,q]),_=Ve(()=>{const e=bt(U.current);e.playing=!1,X(e)},[X]),ee=Ve(()=>{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 G(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]&&Y({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[Y,q,_,G]),te=Ve(()=>{if(L)return void Q();const e=bt(U.current);e.playing=!0,X(e)},[X,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=Ve(()=>{j.current?.clear(),X(xt(q,p,F,L))},[X,q,p,F,L]),se=Ve(e=>{if(!q.byID.has(e))return;const t=bt(U.current);t.previewTaskID=e,X(t);const n=pt(q,e,{completedTaskIDs:t.completed});Y({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[X,Y,q]),ie=Ve(()=>{const e=bt(U.current);e.previewTaskID=null,X(e)},[X]),oe=Ve((e,t)=>{if(!q.byID.has(e))return;const n=bt(U.current);n.blockers.set(e,t),n.armed.delete(e),X(n)},[X,q]),re=Ve(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),X(t)},[X,q]),ae=Ve(e=>pt(q,e,{completedTaskIDs:U.current.completed}),[q]),ce=Ve(()=>{const e=U.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...P],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,P]);_e(t,()=>({play:te,pause:_,step:ee,reset:ne,settle:Q,previewResolve:se,clearPreview:ie,completeTask:G,blockTask:oe,unblockTask:re,getAmplification:ae,getMachineState:ce}),[oe,ie,ae,ce,_,G,te,se,ne,Q,ee,re]);const le=z.previewTaskID??P[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:W,width:D,height:M,seed:I,reduced:L,onSelectTask:J}),[ue,M,O,q,L,z,I,J,W,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&&J(e.id),foregroundGraphics:()=>me,paused:L,continuous:z.inFlight.size>0,onTick:V,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,Ge 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,Xe as collidersFromScales,Le as comparePhysicsTrace,lt as compileDependencyMachine,pe as compileMotionEncoding,De as compilePhysicsEncoding,j as composePhysicsControllers,le as composeStyleRules,R as createCapacityQueueController,B as createDefaultPhysicsEngineAdapter,P as createDependencyGateController,ut as createLogicalJoin,Me as createPhysicsEncodingLayout,W as createPortalController,e as createProcessJourneyLedger,F as createServiceLevelController,L as createServiceResourcePoolController,Et as default,fe as deriveMotionVector,q as evaluatePhysicsBodyBudget,O as forceFieldRegion,Ye 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,X as physicsProcessBoundaryColliders,Y as physicsProcessGroupSemanticItems,J as physicsProcessRegionSemanticItem,Z as physicsProcessStageSemanticItems,Re as physicsReferenceEnvelope,G as planGauntletPropertyWork,K as portalRegion,V 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,Ze as sedimentBake,re as sedimentHeightfield,Je 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,CrucibleChart as o,DEFAULT_CRUCIBLE_HEIGHT as r,DEFAULT_CRUCIBLE_OUTLETS as a,DEFAULT_CRUCIBLE_SIZE as c,DEFAULT_CRUCIBLE_WIDTH as l,EventDropChart as d,GaltonBoardChart as u,GauntletChart as h,GuantletChart as m,PhysicalFlowChart as p,PhysicsCustomChart as f,PhysicsPileChart as g,PhysicsPipelineStore as y,PhysicsSVGOverlay as k,PhysicsSedimentAccumulator as x,ProcessFlowChart as b,StreamPhysicsFrame as v,StreamPhysicsFrame_default as w,absorbRegion as I,aggregateRegionCounts as D,applyCrucibleEvent as M,bodiesToAnnotationAnchors as A,bodyGroupSpec as T,buildCollisionSwarmPhysics as S,buildCrucibleEvidence as C,buildCrucibleInitialSpawns as $,buildCrucibleLayout as E,buildCruciblePhysicsConfig as N,buildCrucibleProductEvents as j,buildCrucibleProjection as R,buildCrucibleStateSpawns as W,buildCrucibleTerminalSpawns as P,buildEventDropPhysics as B,buildGaltonBoardPhysics as F,buildPhysicalFlowPhysics as L,buildPhysicsAnnotationContext as q,buildPhysicsPile as O,buildProcessFlowPhysics as z,capacitatedRegion as H,chargeGateRegion as X,cloneCrucibleState as U,collidersFromPlotBounds as Y,collidersFromXScaleBins as J,compileCruciblePlan as Z,composePhysicsControllers as G,createCapacityQueueController as K,createDefaultPhysicsEngineAdapter as Q,createDependencyGateController as V,createInitialCrucibleState as _,createPortalController as ee,createServiceLevelController as te,createServiceResourcePoolController as ne,crucibleBondId as se,crucibleBoundaryColliders as ie,crucibleComponentBodyId as oe,crucibleProductBodyId as re,crucibleProjectionRows as ae,crucibleSemanticKey as ce,evaluateCrucibleConservation as le,evaluatePhysicsBodyBudget as de,forceFieldRegion as ue,groupCompletionRows as he,membraneRegion as me,normalizePhysicsAnnotations as pe,physicsProcessBoundaryColliders as fe,physicsProcessGroupSemanticItems as ge,physicsProcessRegionSemanticItem as ye,physicsProcessStageSemanticItems as ke,planGauntletPropertyWork as xe,portalRegion as be,pressureFieldRegion as ve,processChrome as we,processLaneWalls as Ie,processStageLayout as De,processStageRegions as Me,processVolumePolygons as Ae,regionCountsToProjectionRows as Te,replaceGauntletNegative as Se,replayCruciblePlan as Ce,resolveCrucibleSelector as $e,resolveCrucibleSnapshotAt as Ee,resolveCrucibleTime as Ne,routeSurfaceRegion as je,sedimentHeightfield as Re,stageTargetInVolume as We}from"./chunk-chunk-XSCHTS4D.module.min.js";import{mulberry32 as Pe}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as Be,makeRuleValueResolver as Fe,matchesThreshold as Le,resolveStyleRules as qe,ruleMatches as Oe}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-LJLS6DY7.module.min.js";import{compileMotionEncoding as ze,deriveMotionVector as He,hatchFillId as Xe,hatchPatternDef as Ue,isHatchFill as Ye,opacityFromAge as Je,resolveMotionAccessor as Ze,resolveMotionAge as Ge,resolveMotionVector as Ke,resolveSvgFill as Qe}from"./chunk-chunk-CWQ5YIHX.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-ACLDBMRH.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";function Ve(e){const{data:t,encoding:n,defaults:s={},scales:i}=e,o=ze({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,Ze(n.appearance?.size,u,t)??s.size??6),m=Ze(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=Ze(n.appearance?.color,u,t)??s.color,x=Ze(n.appearance?.opacity,u,t)??s.opacity,b=Ze(n.appearance?.stroke,u,t)??s.stroke,v=Ze(n.appearance?.strokeWidth,u,t)??s.strokeWidth,w=Ze(n.time?.spawnAt,u,t)??e.time.arrival,I=e.kinematics.velocityX,D=e.kinematics.velocityY,M=Ze(n.dynamics?.mass,u,t)??s.mass??1,A=Ze(n.dynamics?.friction,u,t),T=Ze(n.dynamics?.restitution,u,t),S=Ze(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 _e(e){return t=>{const n=Ve({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 et=[.1,.5,.9],tt=1e6;function nt(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function st(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 it(e){const t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function ot(e,t,n,s){const i=e.flatMap((e,i)=>{const o=nt(st(e,i,t,n,"time")),r=nt(st(e,i,t,s,"value"));return null==o||null==r?[]:[{time:it(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 rt(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 at(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 ct(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",s=function(e){const t=(e??et).map(e=>{const t=nt(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return it(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),i=function(e){if(Array.isArray(e)){if(e.length>tt)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(e.map(nt).filter(e=>null!=e).map(it))).sort((e,t)=>e-t)}const t=e,n=nt(t.start),s=nt(t.end),i=nt(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>tt)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(it(Math.min(t,s)))}if(r.length&&a>=Math.abs(r[r.length-1]-s)||r.push(it(s)),r.length>tt)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=>ot(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:i.map(e=>{const i=o.map(s=>rt(s,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),r={};for(const e of s)r[e]=i.length?at(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?at(i,.5):null,quantiles:r}}),quantiles:s,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function lt(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function dt(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=nt(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const s=it(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 ut(e,t,n){return t>e?"below":e>n?"above":"inside"}function ht(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=ut(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 mt(e,t,n={}){const s=n.interpolation??t.interpolation,i=n.outsideDomain??t.outsideDomain,o=ot(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),r=n.lower??lt(t,"lower"),a=n.upper??lt(t,"upper"),c=t.points.map(e=>{const t=rt(o,e.time,s,i),n=dt(e,r),c=dt(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":ut(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=ht(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 pt(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function ft(e,t,n,s){const i="function"==typeof e?e(t,n):e;return Number.isFinite(i)?Number(i):s}function gt(e,t,n){return pt(e[t])??n}function yt(e,t){return"number"==typeof e?e:e?.[t]??0}function kt(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 xt(e){const{plot:t,idPrefix:n="physics-scale",bounds:s={},xBins:i,xBands:o,yBands:r}=e,a=[];if(!1!==s&&a.push(...Y(t,{idPrefix:n,...s})),i){const{idPrefix:e,yTop:s,yBottom:o,...r}=i;a.push(...J({...r,idPrefix:e??n+"-xbin",yTop:s??t.y,yBottom:o??t.y+t.height}))}return o&&a.push(...kt({band:o,idPrefix:o.idPrefix??n+"-xband",plot:t,projection:"x"})),r&&a.push(...kt({band:r,idPrefix:r.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function bt(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 vt(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=Pe(l),m=yt(d,"x"),p=yt(d,"y");return e.map((e,l)=>{const d=ft(t.x,e,l,gt(e,"x",0)),f=ft(t.y,e,l,gt(e,"y",0)),g=ft(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:ft(r,e,l,0),vy:ft(a,e,l,0),mass:ft(o,e,l,1),spawnAt:ft(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 wt(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 It(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 pt("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 Dt,useCallback as Mt,useEffect as At,useImperativeHandle as Tt,useMemo as St,useRef as Ct,useState as $t}from"react";function Et(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 Nt(e,t,n){return Ze(n,e,t)}function jt(e,t){return t>e?-1:e>t?1:0}function Rt(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Wt(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function Pt(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function Bt(e){const t=[],n=new Map,s=[],i=new Set;e.data.forEach((o,r)=>{const a=(Nt(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=(Nt(o,r,e.laneAccessor)??"Unassigned")+"";i.has(c)||(i.add(c),s.push(c));const l=Nt(o,r,e.dependencyAccessor)??[],d=Array.from(new Set(Array.from(l,e=>e+""))).sort(jt),u=Nt(o,r,e.blockerAccessor),h=Nt(o,r,e.statusAccessor)??(u?"blocked":"waiting");n.set(a,{id:a,label:(Nt(o,r,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:r,datum:o,dependencyIDs:d,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:Nt(o,r,e.startAccessor),end:Nt(o,r,e.endAccessor),progress:Pt(Nt(o,r,e.progressAccessor)),status:h,completionTime:Nt(o,r,e.completionTimeAccessor),blockerReason:u||void 0,milestone:!!Nt(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:Wt(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)=>jt(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=Wt(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>jt(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(jt);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(jt);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 Ft(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)=>jt(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 Lt(e,t,n="all"){const s=Array.from(new Set(t)).sort(jt),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(jt),satisfied:o()})}}function qt(e){return e instanceof Date?e.getTime():Number(e)}function Ot(e,t){const n=qt("object"!=typeof t||t instanceof Date?t:t.currentTime),s=e.map((e,t)=>({event:e,index:t,time:qt(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 zt(e,t,n={}){const s=new Set(n.completedTaskIDs??[]),i=[...Et(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 Ht=[];function Xt(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function Ut(e){if(null==e.completionTime)return null;const t=Xt(e.completionTime,NaN);return Number.isFinite(t)?t:null}function Yt(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 Jt(e,t,n,s){const i=e.nodes.map(Ut).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=Ut(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:Yt(e,l,c,a),blockers:c,previewTaskID:null}}function Zt(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 Gt(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function Kt(e){const t=Gt(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 Qt(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 Vt,jsxs as _t}from"react/jsx-runtime";function en({machine:e,layout:t,runtime:n,downstreamSet:s,selectedSet:i,width:o,height:r,seed:a,reduced:c,onSelectTask:l}){return _t("svg",{"aria-hidden":"true",width:o,height:r,viewBox:`0 0 ${o} ${r}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Vt("defs",{children:Vt("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Vt("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 _t("g",{children:[Vt("line",{x1:i,x2:i,y1:32,y2:r-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Vt("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 Vt("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 _t("g",{children:[Vt("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&&Vt("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 _t("g",{children:[_t("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:[Vt("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}),Vt("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&&_t("g",{opacity:u?.28:1,children:[Vt("line",{x1:f-8,x2:f+14,y1:o.y+9,y2:o.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Vt("circle",{cx:f-8,cy:o.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),_t("g",{onPointerDown:()=>l(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Vt("rect",{x:f,y:g,width:o.width,height:o.height,fill:"transparent"}),Vt("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}),_t("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 tn,jsxs as nn}from"react/jsx-runtime";var sn={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},on=Dt(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:y=!1,selectedTaskIDs:k,onSelectionChange:x,onObservation:b,reducedMotion:v,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=Ct(null),[R,W]=$t([]),P=k?Array.from(k):R,B=St(()=>new Set(P),[P]),F=Xt(g,1/0),L="settle"===v,q=St(()=>Bt({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=St(()=>Ft(q,{width:D,height:M}),[q,D,M]),[z,H]=$t(()=>Jt(q,p,F,L)),X=Ct(z),U=Mt(e=>{X.current=e,H(e)},[]),Y=Mt(e=>b?.(e),[b]);At(()=>{const e=Jt(q,p,F,L);j.current?.clear(),X.current=e,H(e)},[q,p,F,L]);const J=Mt(e=>{const t=B.has(e)?P.filter(t=>t!==e):[e];k||W(t),x?.(t)},[k,x,B,P]),Z=Mt(e=>{if(L)return;const t=Zt(X.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(Qt(s,e)))}n.length&&(U(t),j.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[U,O,q,L]),G=Mt((e,t)=>{const n=q.byID.get(e),s=X.current;if(!n||s.completed.has(e))return;const i=Zt(s);i.completed.add(e),i.blockers.delete(e),i.armed.add(e),null!=t&&(i.currentTime=t),U(i),Y({type:"task-completed",taskID:e,datum:n.datum}),Z(e)},[U,Y,q,Z]),K=Mt(e=>{const t=Zt(X.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){U(t);for(const e of n)Y({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of s)Y({type:"task-armed",taskID:e})}},[U,Y,q]),Q=Mt((e,t)=>{const n=[],s=[];for(const e of t.readBodies()){const t=Gt(e);if(!t||X.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=Mt(()=>{const e=Zt(X.current);for(const t of q.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=Yt(q,e.delivered,e.blockers,e.completed),e.playing=!1,j.current?.settle(),U(e),Y({type:"machine-settled"})},[U,Y,q]),_=Mt(()=>{const e=Zt(X.current);e.playing=!1,U(e)},[U]),ee=Mt(()=>{const e=X.current,t=q.nodes.map(e=>({node:e,time:Ut(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 G(t.node.id,t.time);_();const n=[...e.blockers.keys()].map(t=>zt(q,t,{completedTaskIDs:e.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);n[0]&&Y({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[Y,q,_,G]),te=Mt(()=>{if(L)return void V();const e=Zt(X.current);e.playing=!0,U(e)},[U,L,V]);At(()=>{if(!z.playing||"replay"!==p||L)return;const e=window.setInterval(ee,760);return()=>window.clearInterval(e)},[p,L,z.playing,ee]);const ne=Mt(()=>{j.current?.clear(),U(Jt(q,p,F,L))},[U,q,p,F,L]),se=Mt(e=>{if(!q.byID.has(e))return;const t=Zt(X.current);t.previewTaskID=e,U(t);const n=zt(q,e,{completedTaskIDs:t.completed});Y({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[U,Y,q]),ie=Mt(()=>{const e=Zt(X.current);e.previewTaskID=null,U(e)},[U]),oe=Mt((e,t)=>{if(!q.byID.has(e))return;const n=Zt(X.current);n.blockers.set(e,t),n.armed.delete(e),U(n)},[U,q]),re=Mt(e=>{if(!q.byID.has(e))return;const t=Zt(X.current);t.blockers.delete(e),(q.incoming.get(e)??[]).every(e=>t.delivered.has(e.id))&&t.armed.add(e),U(t)},[U,q]),ae=Mt(e=>zt(q,e,{completedTaskIDs:X.current.completed}),[q]),ce=Mt(()=>{const e=X.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...P],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,P]);Tt(t,()=>({play:te,pause:_,step:ee,reset:ne,settle:V,previewResolve:se,clearPreview:ie,completeTask:G,blockTask:oe,unblockTask:re,getAmplification:ae,getMachineState:ce}),[oe,ie,ae,ce,_,G,te,se,ne,V,ee,re]);const le=z.previewTaskID??P[0]??null,de=le?zt(q,le,{completedTaskIDs:z.completed}):null,ue=St(()=>new Set(de?.downstreamTaskIDs??[]),[de?.downstreamTaskIDs]),he=St(()=>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=St(()=>tn(en,{machine:q,layout:O,runtime:z,downstreamSet:ue,selectedSet:B,width:D,height:M,seed:I,reduced:L,onSelectTask:J}),[ue,M,O,q,L,z,I,J,B,D]),pe=St(()=>{const e=[...z.blockers.keys()].map(e=>zt(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=St(()=>[{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===y?["play","pause","step","reset","settle"]:y||[];return nn("div",q.valid?{className:$,style:{width:D,maxWidth:"100%",position:"relative"},children:[ge.length>0&&tn("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:ge.map(e=>tn("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))}),tn(w,{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:Ht,bodyForces:Kt,bodyStyle:{fill:"var(--semiotic-accent, #f0a329)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.25},bodySemanticItems:!1,semanticItems:he,onSemanticItemActivate:e=>e.id&&J(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&&nn("table",{style:sn,children:[tn("caption",{children:pe}),tn("thead",{children:nn("tr",{children:[tn("th",{children:"Task"}),tn("th",{children:"Lane"}),tn("th",{children:"Progress"}),tn("th",{children:"State"}),tn("th",{children:"Waiting on"}),tn("th",{children:"Downstream reach"})]})}),tn("tbody",{children:q.nodes.map(e=>{const t=zt(q,e.id,{completedTaskIDs:z.completed});return nn("tr",{children:[tn("th",{scope:"row",children:e.label}),tn("td",{children:e.lane}),nn("td",{children:[Math.round(100*e.progress),"%"]}),tn("td",{children:z.completed.has(e.id)?"Completed":z.blockers.has(e.id)?"Blocked":z.armed.has(e.id)?"Armed":"Waiting"}),tn("td",{children:z.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!z.completed.has(e)).join(", ")||"None")}),nn("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:$,role:"alert",style:{width:D,maxWidth:"100%"},children:[tn("strong",{children:"ChainReactionChart could not compile this dependency graph."}),tn("ul",{children:q.diagnostics.map((e,t)=>tn("li",{children:e.message},`${e.code}-${t}`))})]})});on.displayName="ChainReactionChart";var rn=w;export{s as BuiltInPhysicsEngineAdapter,on as ChainReactionChart,i as CollisionSwarmChart,o as CrucibleChart,r as DEFAULT_CRUCIBLE_HEIGHT,a as DEFAULT_CRUCIBLE_OUTLETS,c as DEFAULT_CRUCIBLE_SIZE,l as DEFAULT_CRUCIBLE_WIDTH,d as EventDropChart,u as GaltonBoardChart,h as GauntletChart,m as GuantletChart,p as PhysicalFlowChart,f as PhysicsCustomChart,g as PhysicsPileChart,y as PhysicsPipelineStore,k as PhysicsSVGOverlay,x as PhysicsSedimentAccumulator,b as ProcessFlowChart,v as StreamPhysicsFrame,I as absorbRegion,D as aggregateRegionCounts,M as applyCrucibleEvent,It as arrivalReplay,A as bodiesToAnnotationAnchors,T as bodyGroupSpec,S as buildCollisionSwarmPhysics,C as buildCrucibleEvidence,$ as buildCrucibleInitialSpawns,E as buildCrucibleLayout,N as buildCruciblePhysicsConfig,j as buildCrucibleProductEvents,R as buildCrucibleProjection,W as buildCrucibleStateSpawns,P as buildCrucibleTerminalSpawns,B as buildEventDropPhysics,F as buildGaltonBoardPhysics,L as buildPhysicalFlowPhysics,q as buildPhysicsAnnotationContext,O as buildPhysicsPile,z as buildProcessFlowPhysics,zt as calculateBlockerAmplification,H as capacitatedRegion,X as chargeGateRegion,U as cloneCrucibleState,xt as collidersFromScales,mt as comparePhysicsTrace,Z as compileCruciblePlan,Bt as compileDependencyMachine,ze as compileMotionEncoding,Ve as compilePhysicsEncoding,G as composePhysicsControllers,Be as composeStyleRules,K as createCapacityQueueController,Q as createDefaultPhysicsEngineAdapter,V as createDependencyGateController,_ as createInitialCrucibleState,Lt as createLogicalJoin,_e as createPhysicsEncodingLayout,ee as createPortalController,e as createProcessJourneyLedger,te as createServiceLevelController,ne as createServiceResourcePoolController,se as crucibleBondId,ie as crucibleBoundaryColliders,oe as crucibleComponentBodyId,re as crucibleProductBodyId,ae as crucibleProjectionRows,ce as crucibleSemanticKey,rn as default,He as deriveMotionVector,le as evaluateCrucibleConservation,de as evaluatePhysicsBodyBudget,ue as forceFieldRegion,bt as galtonPegs,he as groupCompletionRows,Xe as hatchFillId,Ue as hatchPatternDef,Ye as isHatchFill,Fe as makeRuleValueResolver,Le as matchesThreshold,me as membraneRegion,pe as normalizePhysicsAnnotations,Je as opacityFromAge,fe as physicsProcessBoundaryColliders,ge as physicsProcessGroupSemanticItems,ye as physicsProcessRegionSemanticItem,ke as physicsProcessStageSemanticItems,ct as physicsReferenceEnvelope,xe as planGauntletPropertyWork,be as portalRegion,ve as pressureFieldRegion,we as processChrome,t as processJourneyRows,Ie as processLaneWalls,De as processStageLayout,Me as processStageRegions,Ae as processVolumePolygons,Te as regionCountsToProjectionRows,Se as replaceGauntletNegative,Ce as replayCruciblePlan,Ot as replayStateTransitions,$e as resolveCrucibleSelector,Ee as resolveCrucibleSnapshotAt,Ne as resolveCrucibleTime,Ze as resolveMotionAccessor,Ge as resolveMotionAge,Ke as resolveMotionVector,qe as resolveStyleRules,Qe as resolveSvgFill,Ft as routeDependencyTracks,je as routeSurfaceRegion,Oe as ruleMatches,wt as sedimentBake,Re as sedimentHeightfield,vt as spawnFromTokens,We as stageTargetInVolume,n as updateProcessJourney};