semiotic 3.8.8 → 3.8.9

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 (104) hide show
  1. package/CLAUDE.md +5 -4
  2. package/README.md +44 -44
  3. package/ai/schema.json +263 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/chunk-chunk-2X3FJCME.module.min.js +1 -0
  7. package/dist/{chunk-chunk-UEZ6SHW5.module.min.js → chunk-chunk-2ZHHWZQM.module.min.js} +1 -1
  8. package/dist/chunk-chunk-5ZON5NMV.module.min.js +2 -0
  9. package/dist/{chunk-chunk-L6FFYGYS.module.min.js → chunk-chunk-6S3YGYW7.module.min.js} +1 -1
  10. package/dist/chunk-chunk-7C5EDZ3Z.module.min.js +2 -0
  11. package/dist/chunk-chunk-A3I4HBD5.module.min.js +1 -0
  12. package/dist/{chunk-chunk-4MLLQUGW.module.min.js → chunk-chunk-AFQHURLO.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-OG3TTJGJ.module.min.js → chunk-chunk-DDB4TLQG.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-W5HWGQMD.module.min.js → chunk-chunk-DTH3SUOU.module.min.js} +1 -1
  15. package/dist/{chunk-chunk-H5IFO6CU.module.min.js → chunk-chunk-DVCWU7MT.module.min.js} +1 -1
  16. package/dist/{chunk-chunk-JRHXQGEV.module.min.js → chunk-chunk-FSIHAW6L.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-BWV55BZK.module.min.js → chunk-chunk-G2RGVEYY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-HAJVODLO.module.min.js +2 -0
  19. package/dist/{chunk-chunk-BZNOAHJV.module.min.js → chunk-chunk-HIV7AW2V.module.min.js} +1 -1
  20. package/dist/{chunk-chunk-LJDH3WV3.module.min.js → chunk-chunk-JZAMMSQQ.module.min.js} +1 -1
  21. package/dist/{chunk-chunk-VUWYT7DY.module.min.js → chunk-chunk-MXMRXSCI.module.min.js} +1 -1
  22. package/dist/chunk-chunk-MXVBXFKW.module.min.js +2 -0
  23. package/dist/{chunk-chunk-7LE56WAE.module.min.js → chunk-chunk-OFAP623Y.module.min.js} +1 -1
  24. package/dist/{chunk-chunk-SFLUSZ73.module.min.js → chunk-chunk-OHLRAEQZ.module.min.js} +1 -1
  25. package/dist/{chunk-chunk-CD6PVVS3.module.min.js → chunk-chunk-PRNXOCYZ.module.min.js} +1 -1
  26. package/dist/chunk-chunk-RLKZVJMQ.module.min.js +2 -0
  27. package/dist/chunk-chunk-SK2TQMG4.module.min.js +2 -0
  28. package/dist/chunk-chunk-SKLYXNYW.module.min.js +2 -0
  29. package/dist/{chunk-chunk-57RBPDBQ.module.min.js → chunk-chunk-U4NZCU5T.module.min.js} +1 -1
  30. package/dist/{chunk-chunk-QQJNG23C.module.min.js → chunk-chunk-VKL6DI43.module.min.js} +1 -1
  31. package/dist/chunk-chunk-W62673ZE.module.min.js +1 -0
  32. package/dist/{chunk-chunk-WSDJFBKX.module.min.js → chunk-chunk-XCC25CZZ.module.min.js} +1 -1
  33. package/dist/{chunk-chunk-AF53TBSN.module.min.js → chunk-chunk-XECNOUZY.module.min.js} +1 -1
  34. package/dist/{chunk-chunk-FC3NZWYR.module.min.js → chunk-chunk-XYZDTYAF.module.min.js} +1 -1
  35. package/dist/components/Tooltip/Tooltip.d.ts +54 -1
  36. package/dist/components/charts/physics/chainReactionTypes.d.ts +1 -0
  37. package/dist/components/charts/physics/physicsHocUtils.d.ts +1 -1
  38. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  40. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  41. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  42. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  43. package/dist/components/charts/shared/formatUtils.d.ts +40 -9
  44. package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -0
  45. package/dist/components/charts/shared/types.d.ts +8 -1
  46. package/dist/components/semiotic-utils-core.d.ts +1 -0
  47. package/dist/components/semiotic.d.ts +4 -3
  48. package/dist/components/stream/GeoTileRenderer.d.ts +1 -0
  49. package/dist/components/stream/canvasSetup.d.ts +15 -4
  50. package/dist/components/stream/geoTypes.d.ts +2 -0
  51. package/dist/components/stream/networkFramePaint.d.ts +8 -0
  52. package/dist/components/stream/networkTypes.d.ts +2 -0
  53. package/dist/components/stream/ordinalTypes.d.ts +2 -0
  54. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -0
  55. package/dist/components/stream/pipelineConfig.d.ts +2 -0
  56. package/dist/components/stream/pipelineDomainResolution.d.ts +1 -1
  57. package/dist/components/stream/types.d.ts +8 -1
  58. package/dist/components/stream/useCanvasFrameHost.d.ts +9 -0
  59. package/dist/components/stream/xyFrameAxisTypes.d.ts +5 -0
  60. package/dist/geo.min.js +1 -1
  61. package/dist/geo.module.min.js +1 -1
  62. package/dist/network.min.js +1 -1
  63. package/dist/network.module.min.js +1 -1
  64. package/dist/ordinal.min.js +1 -1
  65. package/dist/ordinal.module.min.js +1 -1
  66. package/dist/physics.min.js +1 -1
  67. package/dist/physics.module.min.js +1 -1
  68. package/dist/realtime.min.js +1 -1
  69. package/dist/realtime.module.min.js +1 -1
  70. package/dist/semiotic-ai-core.min.js +1 -1
  71. package/dist/semiotic-ai-core.module.min.js +1 -1
  72. package/dist/semiotic-ai.min.js +1 -1
  73. package/dist/semiotic-ai.module.min.js +1 -1
  74. package/dist/semiotic-experimental.min.js +1 -1
  75. package/dist/semiotic-experimental.module.min.js +1 -1
  76. package/dist/semiotic-realtime-core.min.js +1 -1
  77. package/dist/semiotic-realtime-core.module.min.js +1 -1
  78. package/dist/semiotic-server-edge.min.js +1 -1
  79. package/dist/semiotic-server-edge.module.min.js +1 -1
  80. package/dist/semiotic-server-node.min.js +1 -1
  81. package/dist/semiotic-server-node.module.min.js +1 -1
  82. package/dist/semiotic-utils-core.d.ts +1 -0
  83. package/dist/semiotic-utils-core.min.js +1 -1
  84. package/dist/semiotic-utils-core.module.min.js +1 -1
  85. package/dist/semiotic-utils.min.js +1 -1
  86. package/dist/semiotic-utils.module.min.js +1 -1
  87. package/dist/semiotic.d.ts +4 -3
  88. package/dist/semiotic.min.js +1 -1
  89. package/dist/semiotic.module.min.js +1 -1
  90. package/dist/server.min.js +1 -1
  91. package/dist/server.module.min.js +1 -1
  92. package/dist/xy.min.js +1 -1
  93. package/dist/xy.module.min.js +1 -1
  94. package/package.json +1 -1
  95. package/dist/chunk-chunk-3GCILWPB.module.min.js +0 -2
  96. package/dist/chunk-chunk-46KRGJQP.module.min.js +0 -1
  97. package/dist/chunk-chunk-7T25U75Z.module.min.js +0 -2
  98. package/dist/chunk-chunk-BTZYH2IE.module.min.js +0 -1
  99. package/dist/chunk-chunk-FRGBMTZR.module.min.js +0 -1
  100. package/dist/chunk-chunk-HCNDE26Q.module.min.js +0 -2
  101. package/dist/chunk-chunk-JJ4BSUYL.module.min.js +0 -2
  102. package/dist/chunk-chunk-N3Q33XCB.module.min.js +0 -2
  103. package/dist/chunk-chunk-RGJ6TKAH.module.min.js +0 -2
  104. package/dist/chunk-chunk-WGROBM3I.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{ChainReactionChart as i,calculateBlockerAmplification as o,compileDependencyMachine as r,createLogicalJoin as s,replayStateTransitions as a,routeDependencyTracks as l}from"./chunk-chunk-BZNOAHJV.module.min.js";import{CollisionSwarmChart as u,CrucibleChart as c,DEFAULT_CRUCIBLE_HEIGHT as p,DEFAULT_CRUCIBLE_OUTLETS as h,DEFAULT_CRUCIBLE_SIZE as m,DEFAULT_CRUCIBLE_WIDTH as d,EventDropChart as f,GaltonBoardChart as y,GauntletChart as w,GuantletChart as g,PacketFlowChart as x,PhysicalFlowChart as b,PhysicsPileChart as v,ProcessFlowChart as k,UnitPileChart as M,applyCrucibleEvent as A,applyGauntletEffect as P,buildCrucibleEvidence as j,buildCrucibleInitialSpawns as E,buildCrucibleLayout as S,buildCruciblePhysicsConfig as $,buildCrucibleProductEvents as N,buildCrucibleProjection as R,buildCrucibleStateSpawns as D,buildCrucibleTerminalSpawns as I,cloneCrucibleState as q,compileCruciblePlan as B,createInitialCrucibleState as Y,crucibleBondId as W,crucibleBoundaryColliders as F,crucibleComponentBodyId as T,crucibleProductBodyId as X,crucibleProjectionRows as C,crucibleSemanticKey as L,defaultViability as O,evaluateCrucibleConservation as Z,eventLogItem as H,physicsProcessBoundaryColliders as J,physicsProcessGroupSemanticItems as z,physicsProcessRegionSemanticItem as U,physicsProcessStageSemanticItems as V,planGauntletPropertyWork as K,processChrome as Q,recordGauntletEvent as G,replaceGauntletNegative as _,replayCruciblePlan as ee,resolveCrucibleSelector as te,resolveCrucibleSnapshotAt as ne,resolveCrucibleTime as ie}from"./chunk-chunk-LJDH3WV3.module.min.js";import{BuiltInPhysicsEngineAdapter as oe,PhysicsCustomChart as re,PhysicsPipelineStore as se,PhysicsSVGOverlay as ae,PhysicsSedimentAccumulator as le,StreamPhysicsFrame as ue,StreamPhysicsFrame_default as ce,absorbRegion as pe,aggregateRegionCounts as he,bodiesToAnnotationAnchors as me,bodyGroupSpec as de,buildCollisionSwarmPhysics as fe,buildEventDropPhysics as ye,buildGaltonBoardPhysics as we,buildPhysicalFlowPhysics as ge,buildPhysicsAnnotationContext as xe,buildPhysicsPile as be,buildProcessFlowPhysics as ve,capacitatedRegion as ke,chargeGateRegion as Me,collidersFromPlotBounds as Ae,collidersFromXScaleBins as Pe,composePhysicsControllers as je,createCapacityQueueController as Ee,createDefaultPhysicsEngineAdapter as Se,createDependencyGateController as $e,createPortalController as Ne,createServiceLevelController as Re,createServiceResourcePoolController as De,evaluatePhysicsBodyBudget as Ie,forceFieldRegion as qe,groupCompletionRows as Be,membraneRegion as Ye,normalizePhysicsAnnotations as We,portalRegion as Fe,pressureFieldRegion as Te,processLaneWalls as Xe,processStageLayout as Ce,processStageRegions as Le,processVolumePolygons as Oe,regionCountsToProjectionRows as Ze,routeSurfaceRegion as He,sedimentHeightfield as Je,stageTargetInVolume as ze}from"./chunk-chunk-JJ4BSUYL.module.min.js";import{mulberry32 as Ue}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as Ve,makeRuleValueResolver as Ke,matchesThreshold as Qe,resolveStyleRules as Ge,ruleMatches as _e}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-SFLUSZ73.module.min.js";import{compileMotionEncoding as et,deriveMotionVector as tt,opacityFromAge as nt,resolveMotionAccessor as it,resolveMotionAge as ot,resolveMotionVector as rt}from"./chunk-chunk-4MLLQUGW.module.min.js";import{hatchFillId as st,hatchPatternDef as at,isHatchFill as lt,resolveSvgFill as ut}from"./chunk-chunk-HCNDE26Q.module.min.js";import"./chunk-chunk-2NVFEB7P.module.min.js";import"./chunk-chunk-PMR47KRY.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 ct(e){const{data:t,encoding:n,defaults:i={},scales:o}=e,r=et({data:t,encoding:n}),s=[],a=new Map,l=[],u=[],c=new Map;return r.rows.forEach((e,t)=>{const{id:r,datum:p}=e,h=Math.max(0,it(n.appearance?.size,p,t)??i.size??6),m=it(n.appearance?.shape,p,t)??i.shape??{type:"circle",radius:h},d=e.placement.x??i.x??0,f=e.placement.y??i.y??0,y=o?.x?o.x(d):d,w=o?.y?o.y(f):f,g=it(n.appearance?.color,p,t)??i.color,x=it(n.appearance?.opacity,p,t)??i.opacity,b=it(n.appearance?.stroke,p,t)??i.stroke,v=it(n.appearance?.strokeWidth,p,t)??i.strokeWidth,k=it(n.time?.spawnAt,p,t)??e.time.arrival,M=e.kinematics.velocityX,A=e.kinematics.velocityY,P=it(n.dynamics?.mass,p,t)??i.mass??1,j=it(n.dynamics?.friction,p,t),E=it(n.dynamics?.restitution,p,t),S=it(n.dynamics?.bodyCollisions,p,t),$={id:r,x:y,y:w,mass:P,shape:{...m},datum:p,...null!=k&&{spawnAt:k},...null!=M&&{vx:M},...null!=A&&{vy:A},...null!=j&&{friction:j},...null!=E&&{restitution:E},...null!=S&&{bodyCollisions:S}},N={...null!=g&&{fill:g},...null!=x&&{opacity:x},...null!=b&&{stroke:b},...null!=v&&{strokeWidth:v}},R={id:r,datum:p,appearance:{color:g,opacity:x,shape:m,size:h,stroke:b,strokeWidth:v},placement:{x:y,y:w,lane:e.placement.lane,space:n.placement?.space??"world"},time:{arrival:k,spawnAt:k,basis:n.time?.basis??"simulation",unit:n.time?.unit},kinematics:{velocityX:M,velocityY:A,space:n.kinematics?.space??"world"},dynamics:{bodyCollisions:S,friction:j,mass:P,restitution:E},process:e.process,evidence:e.evidence,accessible:e.accessible,spawn:$};s.push(R),a.set(r,R),l.push($),c.set(r,N),u.push({id:r,bodyId:r,label:e.accessible.label,description:e.accessible.description,datum:p,x:y,y:w,group:e.accessible.group})}),{rows:s,byId:a,spawns:l,semanticItems:u,bodyStyle:e=>c.get(e.id)??{}}}function pt(e){return t=>{const n=ct({data:t.data,encoding:e.encoding,defaults:e.defaults,scales:t.scales}),i=e.extend?.(t,n)??{};return{...i,initialSpawns:n.spawns,bodyStyle:n.bodyStyle,semanticItems:[...n.semanticItems,...i.semanticItems??[]]}}}function ht(e,t){const{layout:n,positiveProperties:i,negativeProperties:o,viability:r,outcome:s}=t,a=function(e){return new Map(e.gates.map(e=>[e.id,e]))}(n),l=[...("function"==typeof t.events?t.events(e,n):t.events)??[]].sort((e,t)=>e.time-t.time);let u=e;for(const e of l){const t=e.gateId?a.get(e.gateId):void 0,l=e.effects??[],c={...H(e,l),appliedAt:e.time},p=G(u,c);if(p!==u){u=p;for(const n of l){const r={event:e,gate:t,negativeProperties:o,positiveProperties:i,project:u};n.when&&!n.when(r)||(u=P(u,n,r))}u={...u,viability:r?.(u,{negativeProperties:o,positiveProperties:i})??O(u,i,o)},e.final&&(u={...u,outcome:e.outcome??s?.(u,{layout:n,negativeProperties:o,positiveProperties:i})??(u.viability>20?"built":"approved_not_built")})}}return u}function mt(e){return e.projects.map(t=>ht(t,e))}var dt=[.1,.5,.9],ft=1e6;function yt(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function wt(e,t,n,i,o){return"function"==typeof i?i(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,i??o)}function gt(e){const t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function xt(e,t,n,i){const o=e.flatMap((e,o)=>{const r=yt(wt(e,o,t,n,"time")),s=yt(wt(e,o,t,i,"value"));return null==r||null==s?[]:[{time:gt(r),value:s,index:o}]});o.sort((e,t)=>e.time-t.time||e.index-t.index);const r=[];for(const e of o){const t=r[r.length-1];t?.time===e.time?t.value=e.value:r.push({time:e.time,value:e.value})}return r}function bt(e,t,n,i){if(!e.length)return null;const o=e[0],r=e[e.length-1];if(o.time>t)return"clamp"===i?o.value:null;if(t>r.time)return"clamp"===i?r.value:null;const s=function(e,t){let n=0,i=e.length;for(;i>n;){const o=n+i>>>1;t>e[o].time?n=o+1:i=o}return n}(e,t),a=e[s];if(a?.time===t)return a.value;const l=e[Math.max(0,s-1)];return"step"!==n&&a&&a.time!==l.time?l.value+(t-l.time)/(a.time-l.time)*(a.value-l.value):l.value}function vt(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,i=Math.floor(n),o=Math.ceil(n);return i===o?e[i]:e[i]+(e[o]-e[i])*(n-i)}function kt(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",i=function(e){const t=(e??dt).map(e=>{const t=yt(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return gt(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),o=function(e){if(Array.isArray(e)){if(e.length>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(e.map(yt).filter(e=>null!=e).map(gt))).sort((e,t)=>e-t)}const t=e,n=yt(t.start),i=yt(t.end),o=yt(t.step);if(null==n||null==i||null==o||0>=o||n>i)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const r=Math.floor((i-n)/o)+1;if(r>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const s=[],a=1e-10*Math.max(1,Math.abs(i),Math.abs(n));for(let e=0;r>e;e+=1){const t=n+e*o;if(t>i+a)break;s.push(gt(Math.min(t,i)))}if(s.length&&a>=Math.abs(s[s.length-1]-i)||s.push(gt(i)),s.length>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(s)).sort((e,t)=>e-t)}(e.sampleAt),r=e.runs.map(t=>xt(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:o.map(e=>{const o=r.map(i=>bt(i,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of i)s[e]=o.length?vt(o,e):null;return{time:e,count:o.length,min:o.length?o[0]:null,max:o.length?o[o.length-1]:null,median:o.length?vt(o,.5):null,quantiles:s}}),quantiles:i,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Mt(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function At(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=yt(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const i=gt(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,i))throw Error(`comparePhysicsTrace could not find quantile ${i} in the reference envelope`);return e.quantiles[i]??null}function Pt(e,t,n){return t>e?"below":e>n?"above":"inside"}function jt(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 i=e.value-e.lower,o=t.value-t.lower,r=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[i,o],[r,s]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let l=0,u=0,c=0;for(let i=0;a.length-1>i;i+=1){const o=a[i],r=a[i+1];if(o>=r)continue;const s=(o+r)/2,p=(r-o)*n,h=Pt(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?l+=p:"above"===h?c+=p:u+=p}return{below:l,inside:u,above:c,observed:n}}function Et(e,t,n={}){const i=n.interpolation??t.interpolation,o=n.outsideDomain??t.outsideDomain,r=xt(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Mt(t,"lower"),a=n.upper??Mt(t,"upper"),l=t.points.map(e=>{const t=bt(r,e.time,i,o),n=At(e,s),l=At(e,a);if(null!=n&&null!=l&&n>l)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:l,status:null==t||null==n||null==l?"unobserved":Pt(t,n,l)}});let u=0,c=0,p=0,h=0,m=null,d=0,f=null;for(const e of l){if("below"===e.status?u+=1:"inside"===e.status?c+=1:"above"===e.status&&(p+=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>d&&(d=n,f=e.time)}let y=0,w=0,g=0,x=0;for(let e=0;l.length-1>e;e+=1){const t=l[e],n=l[e+1],o=Math.max(0,n.time-t.time);if(o>0){if("linear"===i){const e=jt(t,n);y+=e.below,w+=e.inside,g+=e.above,x+=e.observed;continue}"unobserved"!==t.status&&(x+=o,"below"===t.status?y+=o:"above"===t.status?g+=o:w+=o)}}const b=l[0]?.time,v=l[l.length-1]?.time,k=null==b||null==v?0:Math.max(0,v-b);return{points:l,sampleCount:l.length,observedSamples:u+c+p,belowSamples:u,insideSamples:c,aboveSamples:p,totalDuration:k,observedDuration:x,unobservedDuration:Math.max(0,k-x),belowDuration:y,insideDuration:w,aboveDuration:g,peakExcess:h,peakExcessAt:m,peakDeficit:d,peakDeficitAt:f}}function St(e){const[t,n]=e.size,i=e.flow??"down",o=null==(v=e.padding)?{top:24,right:24,bottom:24,left:24}:"number"==typeof v?{top:v,right:v,bottom:v,left:v}:{top:v.top??0,right:v.right??0,bottom:v.bottom??0,left:v.left??0},r=Math.max(.05,Math.min(1,e.channelRatio??1)),s={x:o.left,y:o.top,width:Math.max(1,t-o.left-o.right),height:Math.max(1,n-o.top-o.bottom)},a="down"===i?s.height:s.width,l=a*Math.max(0,e.chargeExtent??.12),u=a*Math.max(0,e.projectionExtent??0),c=a*Math.max(0,e.destinationExtent??.55),p=Math.max(0,a-l-c-u),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),m=("down"===i?s.width:s.height)/h.length,d="down"===i?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),f=d(0,l),y=d(l,p),w=l+p,g=d(w,c),x=d(w+c,u),b=h.map((e,t)=>{const n=t*m,o=m*r,a=(m-o)/2;return"down"===i?{id:e.id,label:e.label,order:t,x:s.x+n+a,y:g.y,width:o,height:g.height,centerX:s.x+(t+.5)*m,centerY:g.y+g.height/2}:{id:e.id,label:e.label,order:t,x:g.x,y:s.y+n+a,width:g.width,height:o,centerX:g.x+g.width/2,centerY:s.y+(t+.5)*m}});var v;return{width:t,height:n,flow:i,charge:f,apparatus:y,destinations:b,projection:x}}function $t(e,t){return e.destinations.find(e=>e.id===t)}function Nt(e,t,n){const{charge:i,flow:o}=e,r=Math.max(1,n),s=(t%r+.5)/r;return"down"===o?{x:i.x+i.width*s,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y+i.height*s}}function Rt(e,t={}){const n=t.thickness??4,i=t.idPrefix??"stage",{destinations:o,flow:r,width:s,height:a}=e,l=[];if(o.length>0){const t=o[0];if("down"===r){const r=t.y+t.height;l.push({id:i+"-floor",shape:{type:"segment",x1:e.charge.x,y1:r,x2:e.charge.x+e.charge.width,y2:r,thickness:n}});for(let e=1;o.length>e;e+=1){const s=o[e].centerX-(o[e].centerX-o[e-1].centerX)/2;l.push({id:`${i}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:r,thickness:n}})}}else{const r=t.x+t.width;l.push({id:i+"-floor",shape:{type:"segment",x1:r,y1:e.charge.y,x2:r,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;o.length>e;e+=1){const s=o[e].centerY-(o[e].centerY-o[e-1].centerY)/2;l.push({id:`${i}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:r,y2:s,thickness:n}})}}}return!1!==t.walls&&l.push({id:i+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:i+"-wall-right",shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),l}function Dt(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function It(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function qt(e,t,n,i){const o="function"==typeof e?e(t,n):e;return Number.isFinite(o)?Number(o):i}function Bt(e,t,n){return It(e[t])??n}function Yt(e,t){return"number"==typeof e?e:e?.[t]??0}function Wt(e){const{band:t,idPrefix:n,plot:i,projection:o}=e,{includeBoundaryWalls:r=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,l=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const i of e.values){const o=e.scale(i);Number.isFinite(o)&&(n.add(Number(o)),n.add(Number(o)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>l.length)return[];const u=r?l.length-1:l.length-2,c=[];for(let e=r?0:1;u>=e;e+=1){if(!s&&e>0&&l.length-1>e)continue;const t=l[e];c.push({id:`${n}-wall-${e}`,shape:"x"===o?{type:"aabb",x:t,y:i.y+i.height/2,width:a,height:i.height}:{type:"aabb",x:i.x+i.width/2,y:t,width:i.width,height:a}})}return c}function Ft(e){const{plot:t,idPrefix:n="physics-scale",bounds:i={},xBins:o,xBands:r,yBands:s}=e,a=[];if(!1!==i&&a.push(...Ae(t,{idPrefix:n,...i})),o){const{idPrefix:e,yTop:i,yBottom:r,...s}=o;a.push(...Pe({...s,idPrefix:e??n+"-xbin",yTop:i??t.y,yBottom:r??t.y+t.height}))}return r&&a.push(...Wt({band:r,idPrefix:r.idPrefix??n+"-xband",plot:t,projection:"x"})),s&&a.push(...Wt({band:s,idPrefix:s.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function Tt(e){const{plot:t,rows:n,columns:i=n+1,pegRadius:o=3,idPrefix:r="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:l=!0,restitution:u=.2,friction:c=.04}=e,p=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(i));if(0===p)return[];const m=p>1?(a-s)/(p-1):0,d=t.width/h,f=[];for(let e=0;p>e;e+=1){const n=l&&e%2==1?d/2:0;for(let i=0;h>i;i+=1){const a=t.x+d*(i+.5)+n;t.x+o>a||a>t.x+t.width-o||f.push({id:`${r}-${e}-${i}`,shape:{type:"aabb",x:a,y:s+e*m,width:2*o,height:2*o},restitution:u,friction:c})}}return f}function Xt(e,t={}){const{idPrefix:n="physics-token",radius:i=5,shape:o,mass:r,vx:s,vy:a,spawnAt:l,seed:u=1,jitter:c,datum:p}=t,h=Ue(u),m=Yt(c,"x"),d=Yt(c,"y");return e.map((e,u)=>{const c=qt(t.x,e,u,Bt(e,"x",0)),f=qt(t.y,e,u,Bt(e,"y",0)),y=qt(i,e,u,5),w="function"==typeof o?o(e,u):o??{type:"circle",radius:y};return{id:`${n}-${e.index??u}`,x:c+(h()-.5)*m,y:f+(h()-.5)*d,vx:qt(s,e,u,0),vy:qt(a,e,u,0),mass:qt(r,e,u,1),spawnAt:qt(l,e,u,void 0),shape:w,datum:p?p(e,u):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Ct(e,t={}){const{idPrefix:n="sediment",collider:i=!0,colliderThickness:o=1,restitution:r=.05,friction:s=.2,...a}=t,l=Je(e,a),u=i?l.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+o/2,width:e.width,height:o},restitution:r,friction:s})):[];return{columns:l,colliders:u}}function Lt(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:i=1,startAt:o=0,rebase:r=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return It("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),l=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:o+(r?t-l:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:o,timeAccessor:"spawnAt",timeScale:i}}}var Ot=ce;export{oe as BuiltInPhysicsEngineAdapter,i as ChainReactionChart,u as CollisionSwarmChart,c as CrucibleChart,p as DEFAULT_CRUCIBLE_HEIGHT,h as DEFAULT_CRUCIBLE_OUTLETS,m as DEFAULT_CRUCIBLE_SIZE,d as DEFAULT_CRUCIBLE_WIDTH,f as EventDropChart,y as GaltonBoardChart,w as GauntletChart,g as GuantletChart,x as PacketFlowChart,b as PhysicalFlowChart,re as PhysicsCustomChart,v as PhysicsPileChart,se as PhysicsPipelineStore,ae as PhysicsSVGOverlay,le as PhysicsSedimentAccumulator,k as ProcessFlowChart,ue as StreamPhysicsFrame,M as UnitPileChart,pe as absorbRegion,he as aggregateRegionCounts,A as applyCrucibleEvent,Lt as arrivalReplay,me as bodiesToAnnotationAnchors,de as bodyGroupSpec,fe as buildCollisionSwarmPhysics,j as buildCrucibleEvidence,E as buildCrucibleInitialSpawns,S as buildCrucibleLayout,$ as buildCruciblePhysicsConfig,N as buildCrucibleProductEvents,R as buildCrucibleProjection,D as buildCrucibleStateSpawns,I as buildCrucibleTerminalSpawns,ye as buildEventDropPhysics,we as buildGaltonBoardPhysics,ge as buildPhysicalFlowPhysics,xe as buildPhysicsAnnotationContext,be as buildPhysicsPile,ve as buildProcessFlowPhysics,o as calculateBlockerAmplification,ke as capacitatedRegion,Me as chargeGateRegion,q as cloneCrucibleState,Ft as collidersFromScales,Et as comparePhysicsTrace,B as compileCruciblePlan,r as compileDependencyMachine,et as compileMotionEncoding,ct as compilePhysicsEncoding,je as composePhysicsControllers,Ve as composeStyleRules,Ee as createCapacityQueueController,Se as createDefaultPhysicsEngineAdapter,$e as createDependencyGateController,Y as createInitialCrucibleState,s as createLogicalJoin,pt as createPhysicsEncodingLayout,Ne as createPortalController,e as createProcessJourneyLedger,Re as createServiceLevelController,De as createServiceResourcePoolController,W as crucibleBondId,F as crucibleBoundaryColliders,T as crucibleComponentBodyId,X as crucibleProductBodyId,C as crucibleProjectionRows,L as crucibleSemanticKey,Ot as default,tt as deriveMotionVector,Dt as describePhysicsStageGeography,Z as evaluateCrucibleConservation,Ie as evaluatePhysicsBodyBudget,qe as forceFieldRegion,Tt as galtonPegs,Be as groupCompletionRows,st as hatchFillId,at as hatchPatternDef,lt as isHatchFill,Ke as makeRuleValueResolver,Qe as matchesThreshold,Ye as membraneRegion,We as normalizePhysicsAnnotations,nt as opacityFromAge,Nt as physicsChargePoint,$t as physicsDestination,J as physicsProcessBoundaryColliders,z as physicsProcessGroupSemanticItems,U as physicsProcessRegionSemanticItem,V as physicsProcessStageSemanticItems,kt as physicsReferenceEnvelope,Rt as physicsStageColliders,St as physicsStageGeography,K as planGauntletPropertyWork,Fe as portalRegion,Te as pressureFieldRegion,Q as processChrome,t as processJourneyRows,Xe as processLaneWalls,Ce as processStageLayout,Le as processStageRegions,Oe as processVolumePolygons,Ze as regionCountsToProjectionRows,_ as replaceGauntletNegative,ee as replayCruciblePlan,a as replayStateTransitions,te as resolveCrucibleSelector,ne as resolveCrucibleSnapshotAt,ie as resolveCrucibleTime,ht as resolveGauntletTerminalState,mt as resolveGauntletTerminalStates,it as resolveMotionAccessor,ot as resolveMotionAge,rt as resolveMotionVector,Ge as resolveStyleRules,ut as resolveSvgFill,l as routeDependencyTracks,He as routeSurfaceRegion,_e as ruleMatches,Ct as sedimentBake,Je as sedimentHeightfield,Xt as spawnFromTokens,ze as stageTargetInVolume,n as updateProcessJourney};
2
+ import{createProcessJourneyLedger as e,processJourneyRows as t,updateProcessJourney as n}from"./chunk-chunk-YWZB3KPI.module.min.js";import{ChainReactionChart as i,calculateBlockerAmplification as o,compileDependencyMachine as r,createLogicalJoin as s,replayStateTransitions as a,routeDependencyTracks as l}from"./chunk-chunk-HIV7AW2V.module.min.js";import{CollisionSwarmChart as u,CrucibleChart as c,DEFAULT_CRUCIBLE_HEIGHT as p,DEFAULT_CRUCIBLE_OUTLETS as h,DEFAULT_CRUCIBLE_SIZE as m,DEFAULT_CRUCIBLE_WIDTH as d,EventDropChart as f,GaltonBoardChart as y,GauntletChart as w,GuantletChart as g,PacketFlowChart as x,PhysicalFlowChart as b,PhysicsPileChart as v,ProcessFlowChart as k,UnitPileChart as M,applyCrucibleEvent as A,applyGauntletEffect as P,buildCrucibleEvidence as j,buildCrucibleInitialSpawns as E,buildCrucibleLayout as S,buildCruciblePhysicsConfig as $,buildCrucibleProductEvents as R,buildCrucibleProjection as N,buildCrucibleStateSpawns as D,buildCrucibleTerminalSpawns as I,cloneCrucibleState as q,compileCruciblePlan as Y,createInitialCrucibleState as B,crucibleBondId as T,crucibleBoundaryColliders as F,crucibleComponentBodyId as W,crucibleProductBodyId as X,crucibleProjectionRows as C,crucibleSemanticKey as Z,defaultViability as O,evaluateCrucibleConservation as Q,eventLogItem as H,physicsProcessBoundaryColliders as z,physicsProcessGroupSemanticItems as K,physicsProcessRegionSemanticItem as V,physicsProcessStageSemanticItems as L,planGauntletPropertyWork as G,processChrome as J,recordGauntletEvent as U,replaceGauntletNegative as _,replayCruciblePlan as ee,resolveCrucibleSelector as te,resolveCrucibleSnapshotAt as ne,resolveCrucibleTime as ie}from"./chunk-chunk-JZAMMSQQ.module.min.js";import{BuiltInPhysicsEngineAdapter as oe,PhysicsCustomChart as re,PhysicsPipelineStore as se,PhysicsSVGOverlay as ae,PhysicsSedimentAccumulator as le,StreamPhysicsFrame as ue,StreamPhysicsFrame_default as ce,absorbRegion as pe,aggregateRegionCounts as he,bodiesToAnnotationAnchors as me,bodyGroupSpec as de,buildCollisionSwarmPhysics as fe,buildEventDropPhysics as ye,buildGaltonBoardPhysics as we,buildPhysicalFlowPhysics as ge,buildPhysicsAnnotationContext as xe,buildPhysicsPile as be,buildProcessFlowPhysics as ve,capacitatedRegion as ke,chargeGateRegion as Me,collidersFromPlotBounds as Ae,collidersFromXScaleBins as Pe,composePhysicsControllers as je,createCapacityQueueController as Ee,createDefaultPhysicsEngineAdapter as Se,createDependencyGateController as $e,createPortalController as Re,createServiceLevelController as Ne,createServiceResourcePoolController as De,evaluatePhysicsBodyBudget as Ie,forceFieldRegion as qe,groupCompletionRows as Ye,membraneRegion as Be,normalizePhysicsAnnotations as Te,portalRegion as Fe,pressureFieldRegion as We,processLaneWalls as Xe,processStageLayout as Ce,processStageRegions as Ze,processVolumePolygons as Oe,regionCountsToProjectionRows as Qe,routeSurfaceRegion as He,sedimentHeightfield as ze,stageTargetInVolume as Ke}from"./chunk-chunk-7C5EDZ3Z.module.min.js";import{mulberry32 as Ve}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as Le,makeRuleValueResolver as Ge,matchesThreshold as Je,resolveStyleRules as Ue,ruleMatches as _e}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-OHLRAEQZ.module.min.js";import{compileMotionEncoding as et,deriveMotionVector as tt,opacityFromAge as nt,resolveMotionAccessor as it,resolveMotionAge as ot,resolveMotionVector as rt}from"./chunk-chunk-AFQHURLO.module.min.js";import{hatchFillId as st,hatchPatternDef as at,isHatchFill as lt,resolveSvgFill as ut}from"./chunk-chunk-SK2TQMG4.module.min.js";import"./chunk-chunk-2NVFEB7P.module.min.js";import"./chunk-chunk-PMR47KRY.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 ct(e){const{data:t,encoding:n,defaults:i={},scales:o}=e,r=et({data:t,encoding:n}),s=[],a=new Map,l=[],u=[],c=new Map;return r.rows.forEach((e,t)=>{const{id:r,datum:p}=e,h=Math.max(0,it(n.appearance?.size,p,t)??i.size??6),m=it(n.appearance?.shape,p,t)??i.shape??{type:"circle",radius:h},d=e.placement.x??i.x??0,f=e.placement.y??i.y??0,y=o?.x?o.x(d):d,w=o?.y?o.y(f):f,g=it(n.appearance?.color,p,t)??i.color,x=it(n.appearance?.opacity,p,t)??i.opacity,b=it(n.appearance?.stroke,p,t)??i.stroke,v=it(n.appearance?.strokeWidth,p,t)??i.strokeWidth,k=it(n.time?.spawnAt,p,t)??e.time.arrival,M=e.kinematics.velocityX,A=e.kinematics.velocityY,P=it(n.dynamics?.mass,p,t)??i.mass??1,j=it(n.dynamics?.friction,p,t),E=it(n.dynamics?.restitution,p,t),S=it(n.dynamics?.bodyCollisions,p,t),$={id:r,x:y,y:w,mass:P,shape:{...m},datum:p,...null!=k&&{spawnAt:k},...null!=M&&{vx:M},...null!=A&&{vy:A},...null!=j&&{friction:j},...null!=E&&{restitution:E},...null!=S&&{bodyCollisions:S}},R={...null!=g&&{fill:g},...null!=x&&{opacity:x},...null!=b&&{stroke:b},...null!=v&&{strokeWidth:v}},N={id:r,datum:p,appearance:{color:g,opacity:x,shape:m,size:h,stroke:b,strokeWidth:v},placement:{x:y,y:w,lane:e.placement.lane,space:n.placement?.space??"world"},time:{arrival:k,spawnAt:k,basis:n.time?.basis??"simulation",unit:n.time?.unit},kinematics:{velocityX:M,velocityY:A,space:n.kinematics?.space??"world"},dynamics:{bodyCollisions:S,friction:j,mass:P,restitution:E},process:e.process,evidence:e.evidence,accessible:e.accessible,spawn:$};s.push(N),a.set(r,N),l.push($),c.set(r,R),u.push({id:r,bodyId:r,label:e.accessible.label,description:e.accessible.description,datum:p,x:y,y:w,group:e.accessible.group})}),{rows:s,byId:a,spawns:l,semanticItems:u,bodyStyle:e=>c.get(e.id)??{}}}function pt(e){return t=>{const n=ct({data:t.data,encoding:e.encoding,defaults:e.defaults,scales:t.scales}),i=e.extend?.(t,n)??{};return{...i,initialSpawns:n.spawns,bodyStyle:n.bodyStyle,semanticItems:[...n.semanticItems,...i.semanticItems??[]]}}}function ht(e,t){const{layout:n,positiveProperties:i,negativeProperties:o,viability:r,outcome:s}=t,a=function(e){return new Map(e.gates.map(e=>[e.id,e]))}(n),l=[...("function"==typeof t.events?t.events(e,n):t.events)??[]].sort((e,t)=>e.time-t.time);let u=e;for(const e of l){const t=e.gateId?a.get(e.gateId):void 0,l=e.effects??[],c={...H(e,l),appliedAt:e.time},p=U(u,c);if(p!==u){u=p;for(const n of l){const r={event:e,gate:t,negativeProperties:o,positiveProperties:i,project:u};n.when&&!n.when(r)||(u=P(u,n,r))}u={...u,viability:r?.(u,{negativeProperties:o,positiveProperties:i})??O(u,i,o)},e.final&&(u={...u,outcome:e.outcome??s?.(u,{layout:n,negativeProperties:o,positiveProperties:i})??(u.viability>20?"built":"approved_not_built")})}}return u}function mt(e){return e.projects.map(t=>ht(t,e))}var dt=[.1,.5,.9],ft=1e6;function yt(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function wt(e,t,n,i,o){return"function"==typeof i?i(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,i??o)}function gt(e){const t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function xt(e,t,n,i){const o=e.flatMap((e,o)=>{const r=yt(wt(e,o,t,n,"time")),s=yt(wt(e,o,t,i,"value"));return null==r||null==s?[]:[{time:gt(r),value:s,index:o}]});o.sort((e,t)=>e.time-t.time||e.index-t.index);const r=[];for(const e of o){const t=r[r.length-1];t?.time===e.time?t.value=e.value:r.push({time:e.time,value:e.value})}return r}function bt(e,t,n,i){if(!e.length)return null;const o=e[0],r=e[e.length-1];if(o.time>t)return"clamp"===i?o.value:null;if(t>r.time)return"clamp"===i?r.value:null;const s=function(e,t){let n=0,i=e.length;for(;i>n;){const o=n+i>>>1;t>e[o].time?n=o+1:i=o}return n}(e,t),a=e[s];if(a?.time===t)return a.value;const l=e[Math.max(0,s-1)];return"step"!==n&&a&&a.time!==l.time?l.value+(t-l.time)/(a.time-l.time)*(a.value-l.value):l.value}function vt(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,i=Math.floor(n),o=Math.ceil(n);return i===o?e[i]:e[i]+(e[o]-e[i])*(n-i)}function kt(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",i=function(e){const t=(e??dt).map(e=>{const t=yt(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return gt(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),o=function(e){if(Array.isArray(e)){if(e.length>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(e.map(yt).filter(e=>null!=e).map(gt))).sort((e,t)=>e-t)}const t=e,n=yt(t.start),i=yt(t.end),o=yt(t.step);if(null==n||null==i||null==o||0>=o||n>i)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const r=Math.floor((i-n)/o)+1;if(r>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const s=[],a=1e-10*Math.max(1,Math.abs(i),Math.abs(n));for(let e=0;r>e;e+=1){const t=n+e*o;if(t>i+a)break;s.push(gt(Math.min(t,i)))}if(s.length&&a>=Math.abs(s[s.length-1]-i)||s.push(gt(i)),s.length>ft)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(s)).sort((e,t)=>e-t)}(e.sampleAt),r=e.runs.map(t=>xt(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:o.map(e=>{const o=r.map(i=>bt(i,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of i)s[e]=o.length?vt(o,e):null;return{time:e,count:o.length,min:o.length?o[0]:null,max:o.length?o[o.length-1]:null,median:o.length?vt(o,.5):null,quantiles:s}}),quantiles:i,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Mt(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function At(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=yt(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const i=gt(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,i))throw Error(`comparePhysicsTrace could not find quantile ${i} in the reference envelope`);return e.quantiles[i]??null}function Pt(e,t,n){return t>e?"below":e>n?"above":"inside"}function jt(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 i=e.value-e.lower,o=t.value-t.lower,r=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[i,o],[r,s]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let l=0,u=0,c=0;for(let i=0;a.length-1>i;i+=1){const o=a[i],r=a[i+1];if(o>=r)continue;const s=(o+r)/2,p=(r-o)*n,h=Pt(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?l+=p:"above"===h?c+=p:u+=p}return{below:l,inside:u,above:c,observed:n}}function Et(e,t,n={}){const i=n.interpolation??t.interpolation,o=n.outsideDomain??t.outsideDomain,r=xt(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Mt(t,"lower"),a=n.upper??Mt(t,"upper"),l=t.points.map(e=>{const t=bt(r,e.time,i,o),n=At(e,s),l=At(e,a);if(null!=n&&null!=l&&n>l)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:l,status:null==t||null==n||null==l?"unobserved":Pt(t,n,l)}});let u=0,c=0,p=0,h=0,m=null,d=0,f=null;for(const e of l){if("below"===e.status?u+=1:"inside"===e.status?c+=1:"above"===e.status&&(p+=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>d&&(d=n,f=e.time)}let y=0,w=0,g=0,x=0;for(let e=0;l.length-1>e;e+=1){const t=l[e],n=l[e+1],o=Math.max(0,n.time-t.time);if(o>0){if("linear"===i){const e=jt(t,n);y+=e.below,w+=e.inside,g+=e.above,x+=e.observed;continue}"unobserved"!==t.status&&(x+=o,"below"===t.status?y+=o:"above"===t.status?g+=o:w+=o)}}const b=l[0]?.time,v=l[l.length-1]?.time,k=null==b||null==v?0:Math.max(0,v-b);return{points:l,sampleCount:l.length,observedSamples:u+c+p,belowSamples:u,insideSamples:c,aboveSamples:p,totalDuration:k,observedDuration:x,unobservedDuration:Math.max(0,k-x),belowDuration:y,insideDuration:w,aboveDuration:g,peakExcess:h,peakExcessAt:m,peakDeficit:d,peakDeficitAt:f}}function St(e){const[t,n]=e.size,i=e.flow??"down",o=null==(v=e.padding)?{top:24,right:24,bottom:24,left:24}:"number"==typeof v?{top:v,right:v,bottom:v,left:v}:{top:v.top??0,right:v.right??0,bottom:v.bottom??0,left:v.left??0},r=Math.max(.05,Math.min(1,e.channelRatio??1)),s={x:o.left,y:o.top,width:Math.max(1,t-o.left-o.right),height:Math.max(1,n-o.top-o.bottom)},a="down"===i?s.height:s.width,l=a*Math.max(0,e.chargeExtent??.12),u=a*Math.max(0,e.projectionExtent??0),c=a*Math.max(0,e.destinationExtent??.55),p=Math.max(0,a-l-c-u),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),m=("down"===i?s.width:s.height)/h.length,d="down"===i?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),f=d(0,l),y=d(l,p),w=l+p,g=d(w,c),x=d(w+c,u),b=h.map((e,t)=>{const n=t*m,o=m*r,a=(m-o)/2;return"down"===i?{id:e.id,label:e.label,order:t,x:s.x+n+a,y:g.y,width:o,height:g.height,centerX:s.x+(t+.5)*m,centerY:g.y+g.height/2}:{id:e.id,label:e.label,order:t,x:g.x,y:s.y+n+a,width:g.width,height:o,centerX:g.x+g.width/2,centerY:s.y+(t+.5)*m}});var v;return{width:t,height:n,flow:i,charge:f,apparatus:y,destinations:b,projection:x}}function $t(e,t){return e.destinations.find(e=>e.id===t)}function Rt(e,t,n){const{charge:i,flow:o}=e,r=Math.max(1,n),s=(t%r+.5)/r;return"down"===o?{x:i.x+i.width*s,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y+i.height*s}}function Nt(e,t={}){const n=t.thickness??4,i=t.idPrefix??"stage",{destinations:o,flow:r,width:s,height:a}=e,l=[];if(o.length>0){const t=o[0];if("down"===r){const r=t.y+t.height;l.push({id:i+"-floor",shape:{type:"segment",x1:e.charge.x,y1:r,x2:e.charge.x+e.charge.width,y2:r,thickness:n}});for(let e=1;o.length>e;e+=1){const s=o[e].centerX-(o[e].centerX-o[e-1].centerX)/2;l.push({id:`${i}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:r,thickness:n}})}}else{const r=t.x+t.width;l.push({id:i+"-floor",shape:{type:"segment",x1:r,y1:e.charge.y,x2:r,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;o.length>e;e+=1){const s=o[e].centerY-(o[e].centerY-o[e-1].centerY)/2;l.push({id:`${i}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:r,y2:s,thickness:n}})}}}return!1!==t.walls&&l.push({id:i+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:i+"-wall-right",shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),l}function Dt(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function It(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function qt(e,t,n,i){const o="function"==typeof e?e(t,n):e;return Number.isFinite(o)?Number(o):i}function Yt(e,t,n){return It(e[t])??n}function Bt(e,t){return"number"==typeof e?e:e?.[t]??0}function Tt(e){const{band:t,idPrefix:n,plot:i,projection:o}=e,{includeBoundaryWalls:r=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,l=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const i of e.values){const o=e.scale(i);Number.isFinite(o)&&(n.add(Number(o)),n.add(Number(o)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>l.length)return[];const u=r?l.length-1:l.length-2,c=[];for(let e=r?0:1;u>=e;e+=1){if(!s&&e>0&&l.length-1>e)continue;const t=l[e];c.push({id:`${n}-wall-${e}`,shape:"x"===o?{type:"aabb",x:t,y:i.y+i.height/2,width:a,height:i.height}:{type:"aabb",x:i.x+i.width/2,y:t,width:i.width,height:a}})}return c}function Ft(e){const{plot:t,idPrefix:n="physics-scale",bounds:i={},xBins:o,xBands:r,yBands:s}=e,a=[];if(!1!==i&&a.push(...Ae(t,{idPrefix:n,...i})),o){const{idPrefix:e,yTop:i,yBottom:r,...s}=o;a.push(...Pe({...s,idPrefix:e??n+"-xbin",yTop:i??t.y,yBottom:r??t.y+t.height}))}return r&&a.push(...Tt({band:r,idPrefix:r.idPrefix??n+"-xband",plot:t,projection:"x"})),s&&a.push(...Tt({band:s,idPrefix:s.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function Wt(e){const{plot:t,rows:n,columns:i=n+1,pegRadius:o=3,idPrefix:r="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:l=!0,restitution:u=.2,friction:c=.04}=e,p=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(i));if(0===p)return[];const m=p>1?(a-s)/(p-1):0,d=t.width/h,f=[];for(let e=0;p>e;e+=1){const n=l&&e%2==1?d/2:0;for(let i=0;h>i;i+=1){const a=t.x+d*(i+.5)+n;t.x+o>a||a>t.x+t.width-o||f.push({id:`${r}-${e}-${i}`,shape:{type:"aabb",x:a,y:s+e*m,width:2*o,height:2*o},restitution:u,friction:c})}}return f}function Xt(e,t={}){const{idPrefix:n="physics-token",radius:i=5,shape:o,mass:r,vx:s,vy:a,spawnAt:l,seed:u=1,jitter:c,datum:p}=t,h=Ve(u),m=Bt(c,"x"),d=Bt(c,"y");return e.map((e,u)=>{const c=qt(t.x,e,u,Yt(e,"x",0)),f=qt(t.y,e,u,Yt(e,"y",0)),y=qt(i,e,u,5),w="function"==typeof o?o(e,u):o??{type:"circle",radius:y};return{id:`${n}-${e.index??u}`,x:c+(h()-.5)*m,y:f+(h()-.5)*d,vx:qt(s,e,u,0),vy:qt(a,e,u,0),mass:qt(r,e,u,1),spawnAt:qt(l,e,u,void 0),shape:w,datum:p?p(e,u):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Ct(e,t={}){const{idPrefix:n="sediment",collider:i=!0,colliderThickness:o=1,restitution:r=.05,friction:s=.2,...a}=t,l=ze(e,a),u=i?l.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+o/2,width:e.width,height:o},restitution:r,friction:s})):[];return{columns:l,colliders:u}}function Zt(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:i=1,startAt:o=0,rebase:r=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return It("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),l=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:o+(r?t-l:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:o,timeAccessor:"spawnAt",timeScale:i}}}var Ot=ce;export{oe as BuiltInPhysicsEngineAdapter,i as ChainReactionChart,u as CollisionSwarmChart,c as CrucibleChart,p as DEFAULT_CRUCIBLE_HEIGHT,h as DEFAULT_CRUCIBLE_OUTLETS,m as DEFAULT_CRUCIBLE_SIZE,d as DEFAULT_CRUCIBLE_WIDTH,f as EventDropChart,y as GaltonBoardChart,w as GauntletChart,g as GuantletChart,x as PacketFlowChart,b as PhysicalFlowChart,re as PhysicsCustomChart,v as PhysicsPileChart,se as PhysicsPipelineStore,ae as PhysicsSVGOverlay,le as PhysicsSedimentAccumulator,k as ProcessFlowChart,ue as StreamPhysicsFrame,M as UnitPileChart,pe as absorbRegion,he as aggregateRegionCounts,A as applyCrucibleEvent,Zt as arrivalReplay,me as bodiesToAnnotationAnchors,de as bodyGroupSpec,fe as buildCollisionSwarmPhysics,j as buildCrucibleEvidence,E as buildCrucibleInitialSpawns,S as buildCrucibleLayout,$ as buildCruciblePhysicsConfig,R as buildCrucibleProductEvents,N as buildCrucibleProjection,D as buildCrucibleStateSpawns,I as buildCrucibleTerminalSpawns,ye as buildEventDropPhysics,we as buildGaltonBoardPhysics,ge as buildPhysicalFlowPhysics,xe as buildPhysicsAnnotationContext,be as buildPhysicsPile,ve as buildProcessFlowPhysics,o as calculateBlockerAmplification,ke as capacitatedRegion,Me as chargeGateRegion,q as cloneCrucibleState,Ft as collidersFromScales,Et as comparePhysicsTrace,Y as compileCruciblePlan,r as compileDependencyMachine,et as compileMotionEncoding,ct as compilePhysicsEncoding,je as composePhysicsControllers,Le as composeStyleRules,Ee as createCapacityQueueController,Se as createDefaultPhysicsEngineAdapter,$e as createDependencyGateController,B as createInitialCrucibleState,s as createLogicalJoin,pt as createPhysicsEncodingLayout,Re as createPortalController,e as createProcessJourneyLedger,Ne as createServiceLevelController,De as createServiceResourcePoolController,T as crucibleBondId,F as crucibleBoundaryColliders,W as crucibleComponentBodyId,X as crucibleProductBodyId,C as crucibleProjectionRows,Z as crucibleSemanticKey,Ot as default,tt as deriveMotionVector,Dt as describePhysicsStageGeography,Q as evaluateCrucibleConservation,Ie as evaluatePhysicsBodyBudget,qe as forceFieldRegion,Wt as galtonPegs,Ye as groupCompletionRows,st as hatchFillId,at as hatchPatternDef,lt as isHatchFill,Ge as makeRuleValueResolver,Je as matchesThreshold,Be as membraneRegion,Te as normalizePhysicsAnnotations,nt as opacityFromAge,Rt as physicsChargePoint,$t as physicsDestination,z as physicsProcessBoundaryColliders,K as physicsProcessGroupSemanticItems,V as physicsProcessRegionSemanticItem,L as physicsProcessStageSemanticItems,kt as physicsReferenceEnvelope,Nt as physicsStageColliders,St as physicsStageGeography,G as planGauntletPropertyWork,Fe as portalRegion,We as pressureFieldRegion,J as processChrome,t as processJourneyRows,Xe as processLaneWalls,Ce as processStageLayout,Ze as processStageRegions,Oe as processVolumePolygons,Qe as regionCountsToProjectionRows,_ as replaceGauntletNegative,ee as replayCruciblePlan,a as replayStateTransitions,te as resolveCrucibleSelector,ne as resolveCrucibleSnapshotAt,ie as resolveCrucibleTime,ht as resolveGauntletTerminalState,mt as resolveGauntletTerminalStates,it as resolveMotionAccessor,ot as resolveMotionAge,rt as resolveMotionVector,Ue as resolveStyleRules,ut as resolveSvgFill,l as routeDependencyTracks,He as routeSurfaceRegion,_e as ruleMatches,Ct as sedimentBake,ze as sedimentHeightfield,Xt as spawnFromTokens,Ke as stageTargetInVolume,n as updateProcessJourney};