@theoremjs/studio 0.3.4-next.871.gea9bbcc → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/cookbooks/catalog.d.ts +1 -1
  3. package/cookbooks/catalog.js +1 -1
  4. package/guardrail-bench.d.ts +186 -0
  5. package/guardrail-bench.js +66 -0
  6. package/guardrail-probe.d.ts +4 -2
  7. package/guardrail-probe.js +23 -2
  8. package/origins.d.ts +1 -1
  9. package/origins.js +1 -1
  10. package/package.json +4 -4
  11. package/page/assets/BaseTypeahead-CHXE162p.js +1 -0
  12. package/page/assets/{BottomSheet-Ijd3-EiJ.js → BottomSheet-CKodmH_q.js} +1 -1
  13. package/page/assets/{CollapsibleGroup-BnWI_jMR.js → CollapsibleGroup-YxyQ-UXo.js} +1 -1
  14. package/page/assets/{ConsoleFrame-sl_08t-S.js → ConsoleFrame-CcHhIel7.js} +1 -1
  15. package/page/assets/{DateInput-3xmp6QyV.js → DateInput-C2P3VOWH.js} +1 -1
  16. package/page/assets/{MenuBottomSheet-bFIiEbF_.js → MenuBottomSheet-Be_iagz6.js} +1 -1
  17. package/page/assets/ProgressBarMarkTooltip-BCgy6kk7.js +1 -0
  18. package/page/assets/RankedBars-CmyHIG4-.js +1 -0
  19. package/page/assets/{SchemaFields-DHG2EecV.js → SchemaFields-DvkF1spJ.js} +1 -1
  20. package/page/assets/{SegmentedControlItem-CTVJbfcv.js → SegmentedControlItem-DRVmwW9x.js} +1 -1
  21. package/page/assets/{TokenizerBottomSheet-C7wWNjLf.js → TokenizerBottomSheet-BWGxcrKN.js} +1 -1
  22. package/page/assets/ToolResultCharts-BxJS3q9d.js +1 -0
  23. package/page/assets/{Toolbar-B0ZpvYnL.js → Toolbar-GwS1PT9V.js} +1 -1
  24. package/page/assets/TraceInspector-DVBDD7bH.js +1 -0
  25. package/page/assets/{TraceOverview-Yhf9L-7s.js → TraceOverview-CR3DRfnT.js} +34 -34
  26. package/page/assets/{_virtual_studio-type-sources-NQ8eY2_H.js → _virtual_studio-type-sources-DiOYmd5J.js} +128 -71
  27. package/page/assets/browser-engine-A-dNm9JC.js +16 -0
  28. package/page/assets/{browser-transport-BhFcGvWp.js → browser-transport-J8tzWJNv.js} +2 -2
  29. package/page/assets/{browserClickWait-F6QvgsDI.js → browserClickWait-BSA4ZCzN.js} +1 -1
  30. package/page/assets/{export-agent-C1LknzFc.js → export-agent-DdjcE8pP.js} +3 -3
  31. package/page/assets/getRadiusAndStrokeWidthFromDot-CfhyOFVb.js +1 -0
  32. package/page/assets/guardrail-health-DXmUdlna.js +3 -0
  33. package/page/assets/guardrail-tester-D2ym7K4B.js +9 -0
  34. package/page/assets/index-CkGFbd4l.css +1 -0
  35. package/page/assets/{index-Hix1w6kY.js → index-DeAchcs2.js} +45 -45
  36. package/page/assets/{json-code-B13g9rlg.js → json-code-Cxww5ME0.js} +1 -1
  37. package/page/assets/{prompt-row-DGE5h-0F.js → prompt-row-CKcdEaRi.js} +4 -4
  38. package/page/assets/registry-Cl2mlSuk.js +1 -0
  39. package/page/assets/{studio-code-pane-BpYrChnW.js → studio-code-pane-DblixGst.js} +3 -3
  40. package/page/assets/{studio-console-5ZwlH-1a.js → studio-console-BOmPVlqt.js} +1 -1
  41. package/page/assets/studio-decision-DVz4JS3y.js +1 -0
  42. package/page/assets/{studio-embedding-DCMMMVFw.js → studio-embedding-C706qky_.js} +1 -1
  43. package/page/assets/{studio-host-console-CVKWwl3t.js → studio-host-console-BSLhmC-T.js} +2 -2
  44. package/page/assets/{studio-labels-h-JoNVLI.js → studio-labels-tTkrGnDa.js} +1 -1
  45. package/page/assets/{studio-live-DqPhe9Gd.js → studio-live-CvkqZw8r.js} +3 -3
  46. package/page/assets/{studio-map-Dcz7oT-v.js → studio-map-Cel4mfgK.js} +1 -1
  47. package/page/assets/studio-trace-replay-BkdHAhIX.js +3 -0
  48. package/page/assets/{studio-type-checker-DDcpR_0b.js → studio-type-checker-v8KJwpOP.js} +1 -1
  49. package/page/assets/{use-one-call-Ds7HYrGe.js → use-one-call-C4FbV7xi.js} +1 -1
  50. package/page/assets/{useFocusLeavingChange-8rK2N7Tp.js → useFocusLeavingChange-CRkFJGdd.js} +1 -1
  51. package/page/assets/useHighlightedOptionScroll-C7rzQTVc.js +1 -0
  52. package/page/index.html +11 -11
  53. package/probe-battery.js +16 -0
  54. package/runtime-scope.d.ts +2 -0
  55. package/runtime-scope.js +1 -1
  56. package/server/bench.d.ts +7 -0
  57. package/server/bench.js +203 -0
  58. package/server/save-wire.d.ts +1 -1
  59. package/server/serve.js +2 -0
  60. package/ui/guardrail-charts.d.ts +15 -0
  61. package/ui/guardrail-charts.js +175 -0
  62. package/ui/guardrail-health.d.ts +10 -0
  63. package/ui/guardrail-health.js +395 -0
  64. package/ui/guardrail-matrix.d.ts +17 -0
  65. package/ui/guardrail-matrix.js +109 -0
  66. package/ui/guardrail-tester.d.ts +16 -2
  67. package/ui/guardrail-tester.js +6 -5
  68. package/ui/studio-screen.js +3 -3
  69. package/ui/studio.css +69 -0
  70. package/page/assets/BaseTypeahead-BM3FoulY.js +0 -1
  71. package/page/assets/ToolResultCharts-DFKefRvo.js +0 -1
  72. package/page/assets/TraceInspector-ep2qcy9_.js +0 -1
  73. package/page/assets/browser-engine-B9h8eThv.js +0 -16
  74. package/page/assets/guardrail-tester-C188dNNz.js +0 -9
  75. package/page/assets/index-YKE-6URE.css +0 -1
  76. package/page/assets/registry-Du0mj5wR.js +0 -1
  77. package/page/assets/studio-decision-DaWLDjAy.js +0 -1
  78. package/page/assets/studio-trace-replay-DLHxUh4T.js +0 -3
  79. package/page/assets/useHighlightedOptionScroll-Do3FP80C.js +0 -1
@@ -1 +1 @@
1
- import{l as e}from"./useHighlightedOptionScroll-Do3FP80C.js";import{a as t,i as n,l as r,o as i}from"./usePressFeedback-nkH67NDc.js";import{t as a}from"./createReactComponent-DVEyVJ-p.js";import{t as o}from"./isRtlElement-BG33-k_H.js";import{i as s,n as c,r as l}from"./useResolvedRequired-B-0WnbIo.js";import{t as u}from"./isApplePlatform-BSwFAKoe.js";import{_ as d,f,g as p,h as m,m as h,p as g}from"./BaseTypeahead-BM3FoulY.js";var ee=a(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),te={decelerationRate:{normal:.998,fast:.99},rubberBand:{coefficient:.55},bounce:{duration:.5,bounce:0},delaysContentTouchesMs:150,scrollToTopRate:.99035},_={allowableMovement:{value:45,unit:`px`},maximumIntervalBetweenTaps:{value:350,unit:`ms`},allowableSeparation:{value:45,unit:`px`},maximumTapDuration:{value:1500,unit:`ms`}},ne={minimumPressDuration:{value:500,unit:`ms`},allowableMovement:{value:10,unit:`px`}},v={hysteresis:{value:10,unit:`px`}},re={minimumDistance:{value:50,unit:`px`},maximumDuration:{value:500,unit:`ms`},maximumSecondaryMovement:{value:50,unit:`px`},minimumMovementDecay:{value:.06,unit:`ratio`}},ie={hysteresis:{value:8,unit:`px`}},ae={hysteresis:{value:.08726646259971647,unit:`rad`}},oe={edgeRegion:{value:40.2,unit:`px`},hysteresis:{value:15,unit:`px`}},y={trackingExpansion:{value:70,unit:`px`}},b={contentTouchDelay:{value:150,unit:`ms`},quickTapFlash:{value:100,unit:`ms`},slop:{value:10,unit:`px`},scrollBrake:{value:150,unit:`ms`},momentumMemory:{value:3e3,unit:`ms`}},x={currentWeight:{value:.2,unit:`ratio`},scrollReleaseWeight:{value:.25,unit:`ratio`},stillness:{value:40,unit:`ms`}},se={tap:_,longPress:ne,pan:v,swipe:re,pinch:ie,rotation:ae,screenEdgePan:oe,control:y,press:b,velocity:x},ce={selection:{value:[5],unit:`ms`},impactLight:{value:[8],unit:`ms`},impactMedium:{value:[12],unit:`ms`},impactHeavy:{value:[18],unit:`ms`},impactSoft:{value:[10],unit:`ms`},impactRigid:{value:[6],unit:`ms`},notificationSuccess:{value:[8,60,12],unit:`ms`},notificationWarning:{value:[12,80,12],unit:`ms`},notificationError:{value:[12,50,12,50,18],unit:`ms`}},le={viewportSize(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},isRtl(e){return typeof window>`u`||!(e instanceof Element)?!1:window.getComputedStyle(e).direction===`rtl`},viewRect(e){if(typeof Element>`u`||!(e instanceof Element))return null;let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}},ue=new Set([`began`,`changed`,`ended`,`cancelled`]),de={possible:[`began`,`ended`,`failed`],began:[`changed`,`ended`,`cancelled`],changed:[`changed`,`ended`,`cancelled`],ended:[`possible`],cancelled:[`possible`],failed:[`possible`]};function fe(e,t){return de[e].includes(t)}function S(e){return e===`ended`||e===`cancelled`||e===`failed`}function C(e){return e===`began`||e===`changed`}var pe={panX:!0,panY:!0,pinchZoom:!0,doubleTapZoom:!0},me={panX:!0,panY:!0,pinchZoom:!0,doubleTapZoom:!1},he=1,ge=class{id=he++;view=null;arena=null;pending=null;stateValue=`possible`;listeners=new Set;transitionListeners=new Set;failureRequirements=new Set;simultaneousWith=new Set;touches=new Map;seenTouchIds=new Set;lastLocation={x:0,y:0};constructor(e={}){this.options=e,this.name=e.name??this.constructor.name,this.isEnabled=e.isEnabled??!0,this.cancelsTouchesInView=e.cancelsTouchesInView??!0,this.selectionLock=e.selectionLock??null,this.delaysTouchesBegan=e.delaysTouchesBegan??!1,this.delaysTouchesEnded=e.delaysTouchesEnded??!0,this.allowedPointerTypes=e.allowedPointerTypes==null?null:new Set(e.allowedPointerTypes),this.allowedScrollTypes=new Set(e.allowedScrollTypes??this.defaultScrollTypes),this.requiresExclusiveTouchType=e.requiresExclusiveTouchType??!0}get isDiscrete(){return!1}get claimsTouches(){return this.options.claimsTouches??!0}get state(){return this.stateValue}get nativeTouchBehavior(){return pe}get acceptsTouchInput(){return this.allowedPointerTypes==null||this.allowedPointerTypes.has(`touch`)}get numberOfTouches(){return this.touches.size}get trackedTouches(){return[...this.touches.values()]}location(){if(this.touches.size===0)return this.lastLocation;let e=0,t=0;for(let n of this.touches.values())e+=n.x,t+=n.y;return this.lastLocation={x:e/this.touches.size,y:t/this.touches.size},this.lastLocation}get environment(){return this.arena?.environment??le}requireToFail(e){return this.failureRequirements.add(e),this}recognizeSimultaneouslyWith(...e){for(let t of e)this.simultaneousWith.add(t),t.simultaneousWith.add(this);return this}requiresFailureOf(e){return this.failureRequirements.has(e)||this.options.shouldRequireFailureOf?.(this,e)===!0||e.options.shouldBeRequiredToFailBy?.(e,this)===!0}allowsSimultaneous(e){return this.simultaneousWith.has(e)||this.options.shouldRecognizeSimultaneously?.(this,e)===!0&&e.options.shouldRecognizeSimultaneously?.(e,this)===!0}shouldBegin(){return this.options.shouldBegin?.(this)??!0}keepsTouch(e){return!1}canPrevent(e){return!0}canBePrevented(e){return!0}isInvolved(){return this.touches.size>0||this.pending!=null}addListener(e){let t=e;return this.listeners.add(t),()=>{this.listeners.delete(t)}}addTransitionListener(e){let t=e;return this.transitionListeners.add(t),()=>{this.transitionListeners.delete(t)}}touchesBegan(e,t){}touchesMoved(e,t){}touchesEnded(e,t){}touchesCancelled(e,t){C(this.state)?this.setState(`cancelled`):this.state===`possible`&&this.setState(`failed`)}touchesTakenByBrowser(e,t){return!this.claimsTouches||(this.touchesCancelled(e,t),!1)}touchBeganElsewhere(e,t){}reset(){}get defaultScrollTypes(){return[]}acceptsTouch(e){if(!this.isEnabled)return!1;if(e.scrollType!=null)return this.allowedScrollTypes.has(e.scrollType)&&(this.options.shouldReceiveTouch?.(this,e)??!0);if(this.allowedPointerTypes!=null&&!this.allowedPointerTypes.has(e.pointerType))return!1;if(this.requiresExclusiveTouchType){for(let t of this.touches.values())if(t.pointerType!==e.pointerType)return!1}return this.options.shouldReceiveTouch?.(this,e)??!0}setState(e){this.arena==null?this.applyState(e):this.arena.requestTransition(this,e)}setTimer(e,t){this.arena?.setTimer(this,e,t)}clearTimer(){this.arena?.clearTimer(this)}now(){return this.arena?.now()??0}wantsTouch(e){return this.state!==`possible`&&!C(this.state)||this.pending!=null?!1:this.acceptsTouch(e)}deliverBegan(e,t){for(let t of e)this.touches.set(t.id,t),this.seenTouchIds.add(t.id);this.location(),this.touchesBegan(e,t)}deliverBeganElsewhere(e,t){S(this.state)||this.touchBeganElsewhere(e,t)}deliverMoved(e,t){let n=e.filter(e=>this.touches.has(e.id));n.length===0||S(this.state)||(this.location(),this.touchesMoved(n,t))}deliverEnded(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0){this.location(),S(this.state)||this.touchesEnded(n,t);for(let e of n)this.touches.delete(e.id)}}deliverCancelled(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0){S(this.state)||this.touchesCancelled(n,t);for(let e of n)this.touches.delete(e.id)}}deliverTakenByBrowser(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0&&(S(this.state)||!this.touchesTakenByBrowser(n,t)))for(let e of n)this.touches.delete(e.id)}onEnabledChange=null;setEnabled(e){let t=this.isEnabled!==e;this.isEnabled=e,t&&this.onEnabledChange?.(),!e&&(this.state!==`possible`||this.isInvolved())&&this.cancel()}cancel(){this.arena==null?C(this.state)?this.applyState(`cancelled`):this.state===`possible`&&this.isInvolved()&&this.applyState(`failed`):this.arena.stop(this)}applyState(e){let t=this.stateValue;if((t!==e||e===`changed`)&&fe(t,e)){this.stateValue=e,e!==`possible`&&(this.pending=null);for(let n of[...this.transitionListeners])n(this,t,e);if(ue.has(e))for(let e of[...this.listeners])e(this)}}resetToPossible(){this.clearTimer(),this.pending=null,this.touches.clear(),this.seenTouchIds.clear(),this.reset(),this.applyState(`possible`)}};function w(e){return e}var _e={now:()=>typeof performance>`u`?Date.now():performance.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},ve=class{movingIds=new Set;records=new Map;active=[];timers=new Map;realTimer=null;realTimerDeadline=1/0;currentTime=null;latestTime=-1/0;depth=0;deferDepth=0;owesResolution=!1;constructor(e={}){this.options=e,this.clock=e.clock??_e,this.environment=e.environment??le}now(){return this.currentTime??Math.max(this.latestTime,this.clock.now())}isClaimed(e){return this.records.get(e)?.isClaimed===!0}consumerOf(e){return this.records.get(e)?.consumer??null}getTouch(e){return this.records.get(e)?.touch}participantsOf(e){return this.records.get(e)?.participants??[]}get touches(){return[...this.records.values()].map(e=>e.touch)}get involvedRecognizers(){return this.active}began(e){e.length!==0&&this.run(e[0].time,()=>{let t=new Map,n=[];for(let r of e){if(this.records.has(r.id))continue;let e=this.clampTime(r.time),i={x:r.x,y:r.y,time:e},a={id:r.id,pointerType:r.pointerType,phase:`began`,x:r.x,y:r.y,time:e,startX:r.x,startY:r.y,startTime:e,samples:[...r.history??[],i],target:r.target,scroll:r.scroll??null,takenByBrowser:!1,...r.scrollType==null?{}:{scrollType:r.scrollType}},o=[];for(let[e,n]of r.recognizers.entries()){if(!w(n).wantsTouch(a))continue;if(o.push(n),w(n).arena=this,!this.active.includes(n)){let t=this.active.findIndex(t=>r.recognizers.indexOf(t)>e);t===-1?this.active.push(n):this.active.splice(t,0,n)}let i=t.get(n)??[];i.push(a),t.set(n,i)}let s={touch:a,participants:o,consumer:r.consumer??null,view:`none`,isLifted:!1,isClaimed:!1,suppressClick:!1,deferredClick:!1};this.records.set(r.id,s),n.push(s)}let r=this.context();for(let e of[...this.active]){let n=t.get(e);n!=null&&w(e).deliverBegan(n,r)}for(let e of[...this.active]){let i=t.get(e),a=n.map(e=>e.touch).filter(e=>i==null||!i.includes(e));a.length>0&&e.numberOfTouches>0&&w(e).deliverBeganElsewhere(a,r)}for(let e of n)this.deliverViewBegan(e)})}untrackedBegan(e){this.active.some(e=>e.numberOfTouches>0)&&this.run(e.time,()=>{let t=this.clampTime(e.time),n={id:e.id,pointerType:e.pointerType,phase:`began`,x:e.x,y:e.y,time:t,startX:e.x,startY:e.y,startTime:t,samples:[{x:e.x,y:e.y,time:t}],target:e.target,scroll:e.scroll??null,takenByBrowser:!1},r=this.context();for(let e of[...this.active])e.numberOfTouches>0&&w(e).deliverBeganElsewhere([n],r)})}moved(e){e.length!==0&&this.run(e[0].time,()=>{let t=this.update(e,`moved`);if(t.length===0)return;let n=this.context(),r=this.movingIds;this.movingIds=new Set(t.map(e=>e.id));try{for(let e of[...this.active])w(e).deliverMoved(t,n)}finally{this.movingIds=r}for(let e of t){let t=this.records.get(e.id);t?.view===`delivered`&&t.consumer?.touchMoved(e)}})}ended(e){let t=new Map;return e.length===0||this.run(e[0].time,()=>{let n=this.update(e,`ended`),r=this.context();for(let e of[...this.active])w(e).deliverEnded(n,r);this.reviewPending();for(let e of n){let n=this.records.get(e.id);n!=null&&(n.isLifted=!0,t.set(e.id,this.resolveEnd(n)))}}),t}cancelled(e,t){this.run(t,()=>{let t=this.liveTouches(e);for(let e of t)e.phase=`cancelled`;let n=this.context();for(let e of[...this.active])w(e).deliverCancelled(t,n);for(let e of t){let t=this.records.get(e.id);t!=null&&(t.isLifted=!0,t.suppressClick=!0,this.cancelView(t))}})}browserTookOver(e,t){this.run(t,()=>{let t=this.liveTouches(e).filter(e=>!e.takenByBrowser);if(t.length===0)return;for(let e of t)e.takenByBrowser=!0;let n=this.context();for(let e of[...this.active])w(e).deliverTakenByBrowser(t,n);for(let e of t){let t=this.records.get(e.id);t!=null&&(t.suppressClick=!0,this.cancelView(t))}})}advanceTime(e){this.run(e,()=>{})}requestTransition(e,t){let n=e.state;t===`failed`?this.fail(e):(w(e).pending==null||t!==`began`&&t!==`ended`)&&(n===`possible`&&(t===`began`||t===`ended`)?this.attemptRecognition(e,t):C(n)&&(t===`changed`||t===`ended`)?this.apply(e,t):C(n)&&t===`cancelled`&&this.apply(e,`cancelled`))}setTimer(e,t,n){this.timers.set(e,{deadline:t,callback:n}),this.scheduleRealTimer()}clearTimer(e){this.timers.delete(e)&&this.scheduleRealTimer()}deferResolution(e){this.deferDepth+=1;try{e()}finally{--this.deferDepth}this.deferDepth===0&&this.owesResolution&&queueMicrotask(()=>{this.owesResolution&&this.deferDepth===0&&this.run(this.lastEventTime(),()=>{})})}lastEventTime(){return Number.isFinite(this.latestTime)?this.latestTime:this.clock.now()}stop(e){let t=this.currentTime??(Number.isFinite(this.latestTime)?this.latestTime:this.clock.now());this.run(t,()=>{C(e.state)?this.apply(e,`cancelled`):e.state===`possible`&&e.isInvolved()&&this.fail(e)})}attemptRecognition(e,t){if(!w(e).shouldBegin()||this.isVetoedByConsumer(e)||this.isRefusedByBrowser(e)){this.fail(e);return}let n=!1;for(let t of this.active)if(t!==e&&w(e).requiresFailureOf(t)&&t.state!==`failed`){if(t.state!==`possible`){this.fail(e);return}t.isInvolved()&&(n=!0)}if(n)w(e).pending=t,this.claim(e);else{for(let t of this.active)if(t!==e&&(C(t.state)||t.state===`ended`&&t.trackedTouches.length>0)&&this.conflicts(t,e)){this.fail(e);return}this.apply(e,t);for(let t of[...this.active])t!==e&&t.state===`possible`&&(w(t).requiresFailureOf(e)||this.conflicts(e,t))&&this.fail(t);this.claim(e),e.claimsTouches&&e.cancelsTouchesInView&&this.cancelViewTouchesOf(e)}}conflicts(e,t){return!ye(e,t)||w(e).allowsSimultaneous(t)||!e.claimsTouches||!t.claimsTouches?!1:e.canPrevent(t)&&t.canBePrevented(e)}isRefusedByBrowser(e){let t=this.options.refusesClaim;return t==null||!e.claimsTouches?!1:e.trackedTouches.some(e=>e.phase!==`ended`&&e.phase!==`cancelled`&&t(e))}isVetoedByConsumer(e){for(let t of w(e).seenTouchIds)if((this.records.get(t)?.consumer)?.allowsAncestorRecognizer?.(e)===!1)return!0;return!1}fail(e){S(e.state)||(C(e.state)?this.apply(e,`cancelled`):(w(e).pending=null,this.apply(e,`failed`),this.reviewPending()))}releaseClaim(e,t=new Set){let n=[];for(let r of e.trackedTouches){let i=this.records.get(r.id);i!=null&&i.isClaimed&&!t.has(r.id)&&(this.active.some(t=>t!==e&&t.claimsTouches&&(C(t.state)||t.state===`ended`||w(t).pending!=null)&&t.trackedTouches.some(e=>e.id===r.id))||(i.isClaimed=!1,n.push(r.id)))}n.length>0&&this.options.onRelease?.(n)}apply(e,t){let n=e.state;w(e).applyState(t),(e.state===t&&n!==t||t===`changed`&&n===`changed`)&&this.options.onTransition?.(e,n,t),S(t)&&this.clearTimer(e),t===`cancelled`?this.releaseClaim(e,this.movingIds):t===`failed`&&this.releaseClaim(e)}reviewPending(){if(this.deferDepth>0){this.owesResolution=!0;return}let e=!0;for(;e;){e=!1;for(let t of[...this.active]){let n=w(t).pending;n!=null&&t.state===`possible`&&(this.active.some(e=>e!==t&&w(t).requiresFailureOf(e)&&e.state===`possible`&&e.isInvolved())||(w(t).pending=null,this.attemptRecognition(t,n),e=!0))}}}claim(e){if(!e.claimsTouches)return;let t=[];for(let n of e.trackedTouches){let e=this.records.get(n.id);e!=null&&!e.isLifted&&!e.isClaimed&&!e.touch.takenByBrowser&&(e.isClaimed=!0,t.push(n.id))}t.length>0&&this.options.onClaim?.(t,e)}deliverViewBegan(e){e.consumer!=null&&e.view===`none`&&(e.suppressClick?e.view=`done`:this.beginDelayers(e)?e.view=`held`:(e.view=`delivered`,e.consumer.touchBegan(e.touch)))}resolveEnd(e){if(e.suppressClick)return`suppress`;let t=this.endDelayers(e);switch(e.view){case`delivered`:return t?(e.view=`endHeld`,e.deferredClick=!0,`defer`):(e.view=`done`,e.consumer?.touchEnded(e.touch),`allow`);case`held`:return this.beginDelayers(e)?(e.deferredClick=!0,`defer`):(e.view=`delivered`,e.consumer?.touchBegan(e.touch),this.resolveEnd(e));case`none`:case`endHeld`:case`done`:return t?(e.deferredClick=!0,`defer`):`allow`}}reviewHeld(){for(let e of this.records.values())e.view===`held`&&!this.beginDelayers(e)&&(e.suppressClick?e.view=`done`:(e.view=`delivered`,e.consumer?.touchBegan(e.touch),e.isLifted&&!this.endDelayers(e)?(e.view=`done`,e.consumer?.touchEnded(e.touch)):e.isLifted&&(e.view=`endHeld`))),e.view===`endHeld`&&!this.endDelayers(e)&&(e.view=`done`,e.suppressClick?e.consumer?.touchCancelled(e.touch):e.consumer?.touchEnded(e.touch)),e.deferredClick&&e.view!==`held`&&e.view!==`endHeld`&&!this.endDelayers(e)&&(e.deferredClick=!1,this.options.onDeferredClick?.(e.touch,!e.suppressClick))}beginDelayers(e){return e.participants.some(t=>t.delaysTouchesBegan&&t.state===`possible`&&t.isInvolved()&&w(t).seenTouchIds.has(e.touch.id))}endDelayers(e){return e.participants.some(t=>t.delaysTouchesEnded&&t.state===`possible`&&t.isInvolved()&&w(t).seenTouchIds.has(e.touch.id))}cancelViewTouchesOf(e){for(let t of w(e).seenTouchIds){let e=this.records.get(t);e!=null&&(e.suppressClick=!0,this.cancelView(e))}}cancelView(e){(e.view===`delivered`||e.view===`endHeld`)&&e.consumer?.touchCancelled(e.touch),(e.view!==`none`||e.consumer!=null)&&(e.view=`done`)}context(){return{time:this.now(),allTouches:[...this.records.values()].filter(e=>!e.isLifted).map(e=>e.touch)}}liveTouches(e){let t=[];for(let n of e){let e=this.records.get(n);e!=null&&!e.isLifted&&t.push(e.touch)}return t}update(e,t){let n=[];for(let r of e){let e=this.records.get(r.id);if(e==null||e.isLifted)continue;let i=this.clampTime(r.time),a=e.touch;a.samples=[...(r.history??[]).filter(e=>e.time>a.time&&e.time<i),{x:r.x,y:r.y,time:i}],a.x=r.x,a.y=r.y,a.time=i,a.phase=t,n.push(a)}return n}clampTime(e){let t=Math.max(e,this.latestTime);return this.latestTime=t,t}run(e,t){this.depth+=1;try{this.depth===1&&this.deferDepth===0&&this.owesResolution&&(this.owesResolution=!1,this.currentTime=this.clampTime(this.lastEventTime()),this.settle()),this.flushTimers(e),this.currentTime=this.clampTime(e),t(),this.depth===1&&(this.deferDepth>0?this.owesResolution=!0:(this.owesResolution=!1,this.settle()))}finally{--this.depth,this.depth===0&&(this.currentTime=null)}}flushTimers(e){for(;;){let t=null;for(let n of this.timers)n[1].deadline<=e&&(t==null||n[1].deadline<t[1].deadline||n[1].deadline===t[1].deadline&&this.rank(n[0])<this.rank(t[0]))&&(t=n);if(t==null)break;let[n,r]=t;this.timers.delete(n),this.currentTime=this.clampTime(r.deadline),r.callback(),this.depth<=1&&this.settle()}this.scheduleRealTimer()}rank(e){let t=this.active.indexOf(e);return t===-1?1/0:t}settle(){this.reviewPending(),this.reviewHeld();let e=!1;for(let t of[...this.active]){if(!(S(t.state)&&t.numberOfTouches===0||t.state===`possible`&&!t.isInvolved()))continue;this.active=this.active.filter(e=>e!==t);let n=t.state;w(t).resetToPossible(),e=!0,n!==`possible`&&this.options.onTransition?.(t,n,`possible`)}e&&this.reviewHeld();let t=!1;for(let[e,n]of this.records)n.isLifted&&n.view!==`held`&&n.view!==`endHeld`&&!n.deferredClick&&(this.records.delete(e),t=!0);t&&this.records.size===0&&this.options.onIdle?.()}scheduleRealTimer(){let e=1/0;for(let t of this.timers.values())e=Math.min(e,t.deadline);if(e===this.realTimerDeadline||(this.realTimer!=null&&(this.clock.clearTimeout(this.realTimer),this.realTimer=null),this.realTimerDeadline=e,e===1/0))return;let t=Math.max(0,e-this.clock.now()),n=t=>{this.realTimer=null,this.realTimerDeadline=1/0,t&&this.clock.now()>e?(this.realTimerDeadline=e,this.realTimer=this.clock.setTimeout(()=>n(!1),0)):this.advanceTime(e)};this.realTimer=this.clock.setTimeout(()=>n(!0),t)}};function ye(e,t){for(let n of w(e).seenTouchIds)if(w(t).seenTouchIds.has(n))return!0;return!1}function be(e){let t=e.trim().split(/\s+/);return t.includes(`auto`)||t.includes(`manipulation`)?{x:!0,y:!0}:t.includes(`none`)?{x:!1,y:!1}:{x:t.some(e=>e===`pan-x`||e===`pan-left`||e===`pan-right`),y:t.some(e=>e===`pan-y`||e===`pan-up`||e===`pan-down`)}}var T=new Set([`auto`,`scroll`,`overlay`]),E=1;function xe(e,t){let n=e.ownerDocument,r=n.defaultView;if(r==null)return{entries:[],allowsPan:!1};let i=n.scrollingElement??n.documentElement,a=[],s=!0,c=!0,l=!1,u=!1;for(let f=e;f!=null;f=d(f)){if(!(f instanceof Element))continue;let e=r.getComputedStyle(f);if(t){let t=be(e.touchAction||`auto`);s&&=t.x,c&&=t.y}let d=f===i||f===n.documentElement;d&&(l=!0);let p=d?D(n,`x`):e.overflowX,m=d?D(n,`y`):e.overflowY,h=T.has(p),g=T.has(m);if(h||g){let t=d?i:f,[n,r]=Se(e);a.push({element:t,x:h&&s,y:g&&c,isRtl:o(t),stopsX:n!==`auto`,stopsY:r!==`auto`,isBeyondFixed:u})}if(d)break;e.position===`fixed`&&(u=!0)}return!l&&i instanceof Element&&a.push({element:i,x:s&&T.has(D(n,`x`)),y:c&&T.has(D(n,`y`)),isRtl:!1,stopsX:!1,stopsY:!1,isBeyondFixed:u}),{entries:a,allowsPan:s||c}}function Se(e){let t=e.overscrollBehaviorX,n=e.overscrollBehaviorY;if(t!==``&&n!==``&&t!=null&&n!=null)return[t,n];let[r=`auto`,i=r]=(e.getPropertyValue(`overscroll-behavior`)||`auto`).trim().split(/\s+/);return[t||r,n||i]}function D(e,t){let n=e.defaultView;if(n==null)return`hidden`;for(let r of[e.documentElement,e.body]){if(r==null)continue;let e=n.getComputedStyle(r),i=t===`x`?e.overflowX:e.overflowY;if(i===`hidden`||i===`clip`)return`hidden`}return`auto`}function O(e,t){return e.scrollHeight-e.clientHeight<=E?!1:t>0?e.scrollTop>.5:e.scrollTop<e.scrollHeight-e.clientHeight-E+.5}function k(e,t){let{element:n}=e,r=n.scrollWidth-n.clientWidth;if(r<=E)return!1;let i=e.isRtl?-r:0,a=e.isRtl?0:r;return t>0?n.scrollLeft>i+E-.5:n.scrollLeft<a-E+.5}function Ce(e,t,n){let r=e.ownerDocument.defaultView;if(r==null)return!1;let i=r.getComputedStyle(e);return n!==0&&T.has(i.overflowY)&&O(e,n)?!0:t!==0&&T.has(i.overflowX)&&k({element:e,isRtl:o(e)},t)}function A(e,{readsTouchAction:t=!0}={}){let n=null,r=()=>(n??=e instanceof Element?xe(e,t):{entries:[],allowsPan:!1},n.entries);return{canScroll(e,t){let n=Math.abs(e),i=Math.abs(t),a=n>0&&n>=i/2,o=i>0&&i>=n/2;for(let n of r()){if(o&&n.y&&O(n.element,t)||a&&n.x&&k(n,e))return!0;if((!a||n.stopsX)&&(!o||n.stopsY)&&(n.stopsX||n.stopsY))return!1}return!1},get allowsNativePan(){return r(),n?.allowsPan===!0},get isInsideScroller(){return r().some(e=>!e.isBeyondFixed&&(e.y&&e.element.scrollHeight-e.element.clientHeight>E||e.x&&e.element.scrollWidth-e.element.clientWidth>E))}}}var we=50,Te=1.5,Ee=4,De=.8;function Oe(e){return e<=Te}var ke=class{gesture=0;phase=`finger`;last=-1/0;previous=0;sign=0;count=0;run=0;runStart=0;push(e,t,n){let r=Math.abs(t),i=Math.sign(t),a=e-this.last,o=this.count>0&&Oe(a),s=null;this.count===0?s=this.gesture===0?`first`:`idle`:this.phase===`finger`&&a>=n?s=`idle`:this.phase===`momentum`&&(i!==0&&this.sign!==0&&i!==this.sign?s=`reversal`:a>=we?s=`gap`:!o&&r>=2&&r>this.previous*1.3+.5&&(s=`jump`));let c=s==null&&o&&this.previous>0?Math.max(1,Math.round(r/this.previous)):1;s!=null&&(this.gesture+=1,this.phase=`finger`,this.count=0,this.run=0);let l=!1,u=!1;if(this.phase===`finger`&&this.count>=3&&r>0){let e=r/c;u=e<=this.previous*.995&&e>=this.previous*.5,u?(this.run===0&&(this.runStart=this.previous),this.run+=1):this.run=0,this.run>=Ee&&e<=this.runStart*De&&(this.phase=`momentum`,l=!0)}return this.count+=1,this.previous=r/c,i!==0&&(this.sign=i),this.last=e,{boundary:s,phase:this.phase,gesture:this.gesture,liftNow:l,decaying:u&&!l,bunched:s==null&&o}}end(){this.count=0}};function Ae(e){let t=!0,n=!0,r=!0,i=!0;for(let a of e){if(!w(a).acceptsTouchInput||!a.claimsTouches)continue;let e=a.nativeTouchBehavior;t&&=e.panX,n&&=e.panY,r&&=e.pinchZoom,i&&=e.doubleTapZoom}return{panX:t,panY:n,pinchZoom:r,doubleTapZoom:i}}function je(e){let t=Ae(e);if(t.panX&&t.panY&&t.pinchZoom&&t.doubleTapZoom)return null;if(t.panX&&t.panY&&t.pinchZoom)return`manipulation`;let n=[];return t.panX&&n.push(`pan-x`),t.panY&&n.push(`pan-y`),t.pinchZoom&&n.push(`pinch-zoom`),n.length===0?`none`:n.join(` `)}function Me(e){let t={},n=je(e);return n!=null&&(t.touchAction=n),t}var j=[`pan-left`,`pan-right`,`pan-up`,`pan-down`,`pinch-zoom`];function M(e){let t=e.trim().split(/\s+/).filter(e=>e!==``),n=new Set;t.length===0&&t.push(`auto`);for(let e of t)e===`auto`?(j.forEach(e=>n.add(e)),n.add(`double-tap-zoom`)):e===`manipulation`?j.forEach(e=>n.add(e)):e===`pan-x`?n.add(`pan-left`).add(`pan-right`):e===`pan-y`?n.add(`pan-up`).add(`pan-down`):j.includes(e)&&n.add(e);return n}function Ne(e,t){let n=M(t),r=new Set([...M(e)].filter(e=>n.has(e)));if(j.every(e=>r.has(e)))return r.has(`double-tap-zoom`)?`auto`:`manipulation`;let i=[];for(let[e,t,n]of[[`pan-x`,`pan-left`,`pan-right`],[`pan-y`,`pan-up`,`pan-down`]])r.has(t)&&r.has(n)?i.push(e):r.has(t)?i.push(t):r.has(n)&&i.push(n);return r.has(`pinch-zoom`)&&i.push(`pinch-zoom`),i.length===0?`none`:i.join(` `)}var N=`data-astryx-touch-action`,Pe=`reset`,P=new WeakMap,F=new WeakMap;function Fe(e){let t=P.get(e);if(t==null){let n=e.nodeType===9?e:e.ownerDocument,r,i,a=n?.defaultView?.CSSStyleSheet;if(typeof a==`function`&&`replaceSync`in a.prototype&&`adoptedStyleSheets`in e){let t=new a;e.adoptedStyleSheets=[...e.adoptedStyleSheets,t],r=e=>t.replaceSync(e),i=()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==t)}}else{let t=n?.createElement(`style`),a=e.nodeType===9?n?.head??n?.documentElement:e;t!=null&&a!=null&&(a.append(t),r=e=>{t.textContent=e},i=()=>t.remove())}if(r==null||i==null)return null;t={values:new Set,marked:new Set,css:``,write:r,remove:i},P.set(e,t)}return t}function Ie(e,t){let n=e.getRootNode(),r=e.isConnected&&(n.nodeType===9||`host`in n)?Fe(n):null;if(r==null)return!1;r.values.has(t)||(r.values.add(t),r.css+=`:where([${N}="${t}"]){touch-action:${t}}`,r.write(`@layer ${Pe}{${r.css}}`)),e.getAttribute(`data-astryx-touch-action`)!==t&&e.setAttribute(N,t);let i=F.get(e);return i!=null&&i!==n&&Le(e,i),r.marked.add(e),F.set(e,n),!0}function Le(e,t){let n=P.get(t);n!=null&&(n.marked.delete(e),n.marked.size===0&&(n.remove(),P.delete(t)))}function Re(e){e.removeAttribute(N);let t=F.get(e);t!=null&&(F.delete(e),Le(e,t))}function I(e){return e.button===0&&!(e.ctrlKey&&u())}var ze=[`-webkit-touch-callout`,`-webkit-user-select`,`user-select`],Be=new Set([`text`,`search`,`email`,`url`,`tel`,`password`,`number`]);function Ve(e){return e!==`mouse`}var L=new WeakMap;function He(e,t){let n=new Set(e);if(ot(t)&&[...n].some(e=>p(e,t))&&n.add(t),!r()){let e=e=>{z(e.target)||e.preventDefault()};for(let t of n)t.addEventListener(`selectstart`,e);let t=!0;return()=>{if(t){t=!1;for(let t of n)t.removeEventListener(`selectstart`,e)}}}return at(n)}function Ue(e,t,r,i){let a=t?.document??null,o=nt(r),s=()=>{let e=t?.getSelection();if(e==null||z(it(a)))return;let n=Ye(e,o);r.length===0?n.some(e=>!e.collapsed)&&e.removeAllRanges():!$e(n,r)&&r.every(Ze)&&et(e,r)};s();let c=new Set(e),l=e=>{z(e.target)||e.preventDefault()};for(let e of c)e.addEventListener(`selectstart`,l);let u=t==null?[]:[n(t,`selectstart`,l,{cancels:!0}),n(t,`selectionchange`,s)],d=at(c),f=`held`,p=null,m=()=>{if(f!==`done`){f=`done`,p!=null&&(t?.clearTimeout(p),p=null);try{s()}finally{for(let e of u)e();i?.()}}};return({isCancel:e=!1}={})=>{if(f===`held`){f=`lifted`;for(let e of c)e.removeEventListener(`selectstart`,l);d(),t==null||e?m():p=t.setTimeout(m,0)}else f===`lifted`&&e&&m()}}function We(e){let t=e?.getSelection();if(t==null)return[];let n=tt(t,[]);if(n!=null)return n.filter(e=>!e.collapsed).map(Xe);if(t.isCollapsed)return[];let r=[];for(let e=0;e<t.rangeCount;e++)r.push(t.getRangeAt(e).cloneRange());return r}function Ge(e,t,n,r){if(z(r))return!0;let i=qe(e,t,n,[...rt(r),...R(r)]);if(i==null)return!1;let{node:a,offset:o}=i;if(a.nodeType!==3||(a.textContent??``).trim()===``)return!1;let s=a.parentElement??(a.parentNode?.nodeType===11?a.parentNode.host:null);if(s==null||!Je(s)||Ke(a))return!1;let c=(a.textContent??``).length,l=e.createRange();if(typeof l.getClientRects!=`function`)return!1;for(let e of[o-1,o])if(!(e<0||e>=c)){l.setStart(a,e),l.setEnd(a,e+1);for(let e of Array.from(l.getClientRects()))if(t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom)return!0}return!1}function Ke(e){for(let t=e;t!=null;t=d(t))if(t.nodeType===1&&t.localName===`button`)return!0;return!1}function qe(e,t,n,r){let i=e;if(typeof i.caretPositionFromPoint==`function`){let e=r.length>0?i.caretPositionFromPoint(t,n,{shadowRoots:[...r]}):i.caretPositionFromPoint(t,n);return e==null?null:{node:e.offsetNode,offset:e.offset}}if(typeof i.caretRangeFromPoint==`function`){let e=i.caretRangeFromPoint(t,n);return e==null?null:{node:e.startContainer,offset:e.startOffset}}return null}function Je(e){let t=e.ownerDocument.defaultView?.getComputedStyle(e);return t!=null&&t.getPropertyValue(`user-select`)!==`none`&&t.getPropertyValue(`-webkit-user-select`)!==`none`}function Ye(e,t){let n=tt(e,t);if(n!=null)return n;let r=[];for(let t=0;t<e.rangeCount;t++)r.push(e.getRangeAt(t));return r}function Xe(e){let t=e.startContainer.ownerDocument?.createRange();return t==null||e.startContainer.getRootNode()!==e.endContainer.getRootNode()?e:(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),t)}function Ze(e){return Qe(e.startContainer,e.startOffset)&&Qe(e.endContainer,e.endOffset)}function Qe(e,t){let n=e.nodeType===3||e.nodeType===4||e.nodeType===8?e.length:e.childNodes.length;return e.isConnected&&t>=0&&t<=n}function $e(e,t){return e.length===t.length&&t.every((t,n)=>{let r=e[n];return r.startContainer===t.startContainer&&r.startOffset===t.startOffset&&r.endContainer===t.endContainer&&r.endOffset===t.endOffset})}function et(e,t){let[n]=t;if(t.length===1&&typeof e.setBaseAndExtent==`function`)e.setBaseAndExtent(n.startContainer,n.startOffset,n.endContainer,n.endOffset);else{e.removeAllRanges();for(let n of t){let t=n.startContainer.ownerDocument?.createRange();t!=null&&(t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset),e.addRange(t))}}}function tt(e,t){let n=e.getComposedRanges;if(typeof n!=`function`)return null;let r=t=>{try{return n.call(e,{shadowRoots:t})}catch{try{return n.call(e,...t)}catch{return null}}},i=[...t];for(;;){let e=r([...i]);if(e==null)return null;let t=new Set;for(let n of e)for(let[e,r]of[[n.startContainer,n.startOffset],[n.endContainer,n.endOffset]])for(let n of[e.childNodes[r],e.childNodes[r-1]]){let e=n?.nodeType===1?n.shadowRoot:null;e!=null&&!i.includes(e)&&t.add(e)}if(t.size===0)return e;i.push(...t)}}function nt(e){let t=new Set;for(let n of e)for(let e of[...R(n.startContainer),...R(n.endContainer)])t.add(e);return[...t]}function rt(e){let t=e?.nodeType===1?e.shadowRoot:null;return t==null?[]:[t]}function R(e){let t=[],n=e!=null&&typeof e.nodeType==`number`?e.getRootNode():null;for(;n!=null&&n.nodeType===11;){let e=n.host;if(e==null)break;n.mode===`open`&&t.push(n),n=e.getRootNode()}return t}function it(e){let t=e?.activeElement??null;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function at(e){let t=[];for(let n of e){let e=st(n);if(e==null)continue;t.push(n);let r=L.get(n);if(r!=null)r.count+=1;else{L.set(n,{count:1,saved:ze.map(t=>({name:t,value:e.getPropertyValue(t),priority:e.getPropertyPriority(t)}))});for(let t of ze)e.setProperty(t,`none`)}}let n=!1;return()=>{if(!n){n=!0;for(let e of t){let t=L.get(e);if(t==null||--t.count>0)continue;L.delete(e);let n=st(e);for(let{name:e,value:r,priority:i}of t.saved)r===``?n?.removeProperty(e):n?.setProperty(e,r,i)}}}}function ot(e){return e instanceof Element&&e.localName===`input`&&!Be.has(e.type)}function z(e){let t=e instanceof Element?e:e instanceof Node?e.parentElement:null;return t==null?!1:t.localName===`textarea`?!0:t.localName===`input`?Be.has(t.type):t.isContentEditable}function st(e){let t=e.style;return t instanceof Object?t:null}var ct=new WeakMap,B={touchAction:`touch-action`,WebkitTouchCallout:`-webkit-touch-callout`,WebkitUserSelect:`-webkit-user-select`,userSelect:`user-select`};function lt(e){return ut.has(e.trim().toLowerCase())}var ut=new Set([`initial`,`inherit`,`unset`,`revert`,`revert-layer`]);function dt(e,t){if(e!=null&&typeof e.requestAnimationFrame==`function`){let n=e.requestAnimationFrame(t);return()=>e.cancelAnimationFrame(n)}let n=setTimeout(t,0);return()=>clearTimeout(n)}var ft={capture:!0,passive:!0};function V(e){return e.claimsTouches&&w(e).acceptsTouchInput&&w(e).family!==`tap`}function pt(e){let t=e.allowedPointerTypes;return t==null||t.has(`touch`)||t.has(`pen`)}function mt(e){return w(e).family===`pan`}function H(e){return e.kind===`screenEdgePan`?e:null}function ht(e){return Y(e.changedTouches).some(e=>e.touchType===`stylus`)}var U=500,gt=8;function W(e,t){return e.target===t.target&&Math.abs(e.x-t.x)<=1&&Math.abs(e.y-t.y)<=1}function _t(e){return e===`touch`||e===`mouse`||e===`pen`}function G(e,t=e.target){return t===e.target?e.composedPath()[0]??t:t}var vt=100,yt=180,bt=220,xt=40,St=100;function Ct(e,t,n){return e===`pinch`||t!==`continuous`?vt:n?bt:yt}function wt(e,t){return Math.sign(e)*Math.max(0,Math.abs(e)-Math.abs(t)/2)}function Tt(e,t,n){e.readSpan<=0||(e.speedX=K(e.speedX,(t-e.readFromX)/e.readSpan,e.priorSpeedX),e.speedY=K(e.speedY,(n-e.readFromY)/e.readSpan,e.priorSpeedY))}function K(e,t,n){let r=Math.sign(t)*Math.min(Math.abs(t),Math.abs(n));return r*e>=0&&Math.abs(r)>Math.abs(e)?r:e}function Et(e,t,n){return n===0||(t-e)*Math.sign(n)>0?t:e}function Dt(e,t){return e.deltaMode===1?{dx:e.deltaX*xt,dy:e.deltaY*xt}:e.deltaMode===2?{dx:e.deltaX*(t?.innerWidth??0),dy:e.deltaY*(t?.innerHeight??0)}:{dx:e.deltaX,dy:e.deltaY}}function q(e){if(e.deltaMode!==0||e.shiftKey)return`discrete`;let t=e=>{let t=Math.abs(e-Math.round(e));return t>0&&t<.01};if(t(e.deltaX)||t(e.deltaY))return`discrete`;let n=e;if(typeof n.wheelDeltaY!=`number`||typeof n.wheelDeltaX!=`number`)return`discrete`;let r=(e,t)=>e===0?t===0:Math.abs(Math.abs(t)-3*Math.abs(e))<=Math.max(1.5,.05*Math.abs(e)*3);if(!r(e.deltaY,n.wheelDeltaY)||!r(e.deltaX,n.wheelDeltaX))return`discrete`;let i=(e,t)=>t!==0&&t%120==0&&e%40==0;return i(e.deltaY,n.wheelDeltaY)||i(e.deltaX,n.wheelDeltaX)?`discrete`:`continuous`}function Ot(e){return e.scrollEdge===!0}function kt(e,t,n){return(w(e).classify?.({x:t,y:n})??`begin`)===`begin`}function J(e){let t=e.timeStamp;return t>0xe8d4a51000&&typeof performance<`u`&&performance.timeOrigin>0?t-performance.timeOrigin:t}function Y(e){return e==null?[]:Array.from(e)}var At=class{registry=new Map;stopWatchingMovers=null;stopBlockingForMovers=null;pendingCallerReads=new Set;isCallerReadScheduled=!1;cancelCallerRead=null;lockedBy=new Map;pressSelections=new Map;selectingContacts=new Set;dragHolds=new Set;claimHolds=new Map;retargeted=new Map;touchIds=new Map;cancelledFingers=new Set;cancelledPointers=new Map;touchTargets=new Map;watched=new Map;blockingFingers=new Set;claimingFingers=new Set;processed=new WeakSet;pointerIds=new Map;pointerKinds=new Map;layoutWatched=new Set;layoutObserver=null;judgedUncancelable=new Set;fingerPointers=new Map;pendingPointers=new Map;claimedLifts=[];claimedLiftTimer=null;unpairedTouches=new Map;lastFed=new Map;pointerFed=new Set;lastTouch=null;ownedScrolls=new Map;ownScrollCalls=0;ownScrollFrames=new Map;lastScroll=null;touchGates=new Set;retainers=0;fingerListeners=new Set;fingerTargets=[];nextId=1;wheel=null;stopWheelLatch=null;segmenter=new ke;wheelSegment=null;wheelsSeen=new WeakSet;isInstalled=!1;isCoarse=!1;stopWatchingPointer=null;unsubscribers=[];armedElements=new Map;isArmedPress=!1;isClaimingInstalled=!1;claimingUnsubscribers=[];usesTouchEvents=!0;constructor(e,n={}){this.doc=e,this.inputMode=n.inputMode??`auto`,this.presentedHitTesting=n.presentedHitTesting??`auto`;let r={viewportSize:()=>({width:e.defaultView?.innerWidth??0,height:e.defaultView?.innerHeight??0}),isRtl:e=>e instanceof Element&&o(e),viewRect:e=>{if(!(e instanceof Element))return null;let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}};this.clock=n.clock??_e,this.arena=new ve({clock:this.clock,environment:r,onDeferredClick:(e,t)=>this.replayClick(e,t),onIdle:()=>this.releaseArmedPress(),onTransition:n.onTransition,onClaim:(e,t)=>this.lockClaimedDrags(e,t),onRelease:e=>this.releaseClaimedDrags(e),refusesClaim:e=>this.selectingContacts.has(e.id)&&(e.x!==e.startX||e.y!==e.startY)});let i=e.defaultView;this.followsPointer=n.isPrimaryPointerCoarse==null,this.isPrimaryPointerCoarse=n.isPrimaryPointerCoarse??(()=>t(i))}attach(e,t,n={}){let r=this.registrationFor(e);r.manageStyle=n.manageStyle??r.manageStyle;let i=n.actionGroup===!0;i&&(r.actionGroupAsks+=1,r.actionGroup=!0),t.view=e,r.recognizers.push(t),t.onEnabledChange=()=>{this.refresh(e,r),this.syncListeners()};let a=H(t);return a!=null&&(a.onTouchBehaviorChange=()=>{this.refresh(e,r),this.syncLayoutWatch()}),this.refresh(e,r),this.syncListeners(),()=>{t.onEnabledChange=null,i&&(--r.actionGroupAsks,r.actionGroup=r.actionGroupAsks>0),a!=null&&(a.onTouchBehaviorChange=null);let n=r.recognizers.indexOf(t);n>=0&&r.recognizers.splice(n,1),(t.state!==`possible`||t.isInvolved())&&t.cancel();let o=this.wheel;o!=null&&o.takers.includes(t)&&!this.wheelHasTaker(o)&&this.endWheel(o.last),this.refresh(e,r),this.syncListeners(),this.cleanup(e,r)}}syncLayoutWatch(){let e=new Set,t=!1;for(let[n,r]of this.registry)for(let i of r.recognizers){let r=H(i);r!=null&&r.isEnabled&&(e.add(n),t||=r.watchesViewport)}t&&e.add(this.doc.documentElement);for(let t of[...this.layoutWatched])e.has(t)||(this.layoutObserver?.unobserve(t),this.layoutWatched.delete(t));if(e.size===0){this.layoutObserver?.disconnect(),this.layoutObserver=null;return}let n=this.doc.defaultView;if(this.layoutObserver==null&&n!=null&&typeof n.ResizeObserver==`function`){this.layoutObserver=new n.ResizeObserver(this.onLayoutChange);for(let e of this.layoutWatched)this.layoutObserver.observe(e)}for(let t of e)this.layoutWatched.has(t)||(this.layoutObserver?.observe(t),this.layoutWatched.add(t))}onLayoutChange=()=>{for(let e of this.registry.values())for(let t of e.recognizers){let e=H(t);e!=null&&e.isEnabled&&e.layoutChanged()}};attachConsumer(e,t,n={}){let r=this.registrationFor(e);return r.consumer=t,this.refresh(e,r),this.syncListeners(),()=>{r.consumer===t&&(r.consumer=null),this.refresh(e,r),this.syncListeners(),this.cleanup(e,r)}}get document(){return this.doc}isTouchClaimed(e){let t=this.touchIds.get(e);return t!=null&&this.arena.isClaimed(t)}presentedRect(e){let t=e.getBoundingClientRect();if(!this.hitTestsLayout())return t;let{x:n,y:r}=g(e);return n===0&&r===0?t:{left:t.left+n,top:t.top+r,right:t.right+n,bottom:t.bottom+r}}hitTestsLayout(){return this.presentedHitTesting===`always`||this.presentedHitTesting===`auto`&&r(this.doc.defaultView)}presentedTarget(e,t,n,r){if(!this.hitTestsLayout())return e;let i=f().filter(e=>{if(!e.isConnected||e.ownerDocument!==this.doc)return!1;let{x:t,y:n}=g(e);return Math.abs(t)>=.5||Math.abs(n)>=.5});if(i.length===0)return e;h(i);let a=this.drawnAt(t,n),o=(this.doc.defaultView?.performance.now()??r)-r;if(o>0&&o<1e3){let e=e=>{let t=g(e,r);return Math.abs(t.x)>=.5||Math.abs(t.y)>=.5?t:null},o=a,s=o==null?void 0:i.find(e=>p(e,o)),c=!1;for(let r of i){let i=e(r);if(i==null)continue;let o=this.drawnAt(t-i.x,n-i.y);if(o!=null&&p(r,o)){a=o,c=!0;break}}!c&&s!=null&&e(s)!=null&&(a=this.drawnBeneath(t,n,i))}if(a==null||a===e)return e;let s=a,c=e instanceof Node?e:null;return i.some(e=>p(e,s)||c!=null&&p(e,c))?s:e}drawnBeneath(e,t,n){return typeof this.doc.elementsFromPoint==`function`?this.doc.elementsFromPoint(e,t).find(e=>!n.some(t=>p(t,e)))??null:null}drawnAt(e,t){let n=this.doc.elementFromPoint(e,t);for(;n?.shadowRoot!=null;){let r=n.shadowRoot.elementFromPoint(e,t);if(r==null||r===n)break;n=r}return n}browserTook(e,t){for(let t of e)this.retargeted.delete(t);this.arena.browserTookOver(e,t)}clickRetargeted(e,t,n,r){let i=this.doc.defaultView;e instanceof Element&&e.isConnected&&i!=null&&(c(this.doc,{takesLateMouse:r===`touch`}),e instanceof i.HTMLElement&&e.matches(`input, textarea, select, [contenteditable]`)&&e.focus(),s(()=>e.dispatchEvent(new i.MouseEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:1,clientX:t,clientY:n}))))}update(e){this.followsPointer||(this.isCoarse=this.isPrimaryPointerCoarse());let t=this.registry.get(e);t!=null&&this.refresh(e,t),this.syncListeners()}pointerIdOf(e){let t=typeof e==`number`?e:e.id;for(let[e,n]of this.fingerPointers)if(n===t)return e;for(let[e,n]of this.pointerIds)if(n===t)return e;return null}isScrollBraking(e,t=b.scrollBrake.value){let n=this.lastScroll;return n!=null&&this.arena.now()-n.time<t&&p(n.scroller,e)}retain(){this.retainers+=1,this.watchPointer(),this.syncListeners();let e=!0;return()=>{e&&(e=!1,--this.retainers,this.uninstallIfIdle())}}onFingersChange(e){return this.fingerListeners.add(e),()=>{this.fingerListeners.delete(e)}}isFingerDownIn(e){return this.fingerTargets.some(t=>p(e,t))}registrationFor(e){this.watchPointer();let t=this.registry.get(e);return t??(t={recognizers:[],consumer:null,hasTouchEndListener:!1,hasTouchMoveListener:!1,hasWheelListener:!1,savedStyle:new Map,authorTouchAction:null,manageStyle:!0,actionGroup:!1,actionGroupAsks:0},this.registry.set(e,t)),t}needsInput(){return this.registry.size>0||this.retainers>0}refresh(e,t){t.manageStyle&&e instanceof HTMLElement&&this.applyStyle(e,t),this.syncTouchMoveListener(e,t)}syncTouchMoveListener(e,t){let n=this.readsFingersFromPointerEvents()&&(this.isCoarse||this.sendsTouchEvents())&&t.recognizers.some(e=>e.isEnabled&&w(e).acceptsTouchInput);n&&!t.hasTouchEndListener?(e.addEventListener(`touchend`,this.onClaimedTouchEnd,{passive:!1}),t.hasTouchEndListener=!0):!n&&t.hasTouchEndListener&&(e.removeEventListener(`touchend`,this.onClaimedTouchEnd),t.hasTouchEndListener=!1);let r=t.recognizers.some(e=>e.isEnabled&&V(e))||t.consumer?.keepsTouch!=null&&t.consumer.isEnabled?.()!==!1&&(this.isCoarse||this.isArmedPress);r&&!t.hasTouchMoveListener?(e.addEventListener(`touchmove`,this.onBlockingTouchMove,{passive:!1}),t.hasTouchMoveListener=!0):!r&&t.hasTouchMoveListener&&(e.removeEventListener(`touchmove`,this.onBlockingTouchMove),t.hasTouchMoveListener=!1);let i=t.recognizers.some(e=>e.isEnabled&&e.claimsTouches&&e.allowedScrollTypes.size>0&&(w(e).family===`pan`||w(e).family===`pinch`));i&&!t.hasWheelListener?(e.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.hasWheelListener=!0):!i&&t.hasWheelListener&&(e.removeEventListener(`wheel`,this.onWheel),t.hasWheelListener=!1)}applyStyle(e,t){let n=t.recognizers.filter(e=>e.isEnabled),r=n.length>0?Me(n):{};r.touchAction==null&&t.consumer?.keepsTouch!=null&&(r={...r,touchAction:`manipulation`});for(let n of Object.keys(B)){let i=B[n],a=r[n];if(n===`touchAction`&&(a=this.touchActionToWrite(e,t,a)),a!=null)t.savedStyle.has(i)||t.savedStyle.set(i,e.style.getPropertyValue(i)),e.style.setProperty(i,a);else if(t.savedStyle.has(i)){let n=t.savedStyle.get(i)??``;t.savedStyle.delete(i),n===``?e.style.removeProperty(i):e.style.setProperty(i,n)}}}touchActionToWrite(e,t,n){if(n==null){Re(e),t.authorTouchAction=null;return}let r=B.touchAction,i=t.savedStyle.has(r)?t.savedStyle.get(r)??``:e.style.getPropertyValue(r);if(i!==``&&!lt(i))return Re(e),Ne(n,i);if(!Ie(e,n)){this.readCallerTouchActionInNextFrame(e);return}let a=t.authorTouchAction;if(a==null||a.derived!==n){this.readCallerTouchActionInNextFrame(e);return}if(a.author==null)return;let o=Ne(n,a.author);return o===a.author?void 0:o}readCallerTouchActionInNextFrame(e){this.pendingCallerReads.add(e),!this.isCallerReadScheduled&&(this.isCallerReadScheduled=!0,this.cancelCallerRead=dt(this.doc.defaultView,()=>{this.isCallerReadScheduled=!1,this.cancelCallerRead=null;let e=[];for(let t of this.pendingCallerReads){let n=this.registry.get(t);n!=null&&e.push([t,n])}this.pendingCallerReads.clear();let t=this.doc.defaultView;for(let[n,r]of e){let e=n.getAttribute(N);if(e==null||t==null)continue;let i=t.getComputedStyle(n).touchAction||`auto`;r.authorTouchAction={derived:e,author:i===e?null:i}}for(let[t,n]of e)this.applyStyle(t,n)}))}cleanup(e,t){t.recognizers.length>0||t.consumer!=null?this.syncListeners():(t.hasTouchEndListener&&=(e.removeEventListener(`touchend`,this.onClaimedTouchEnd),!1),t.hasTouchMoveListener&&e.removeEventListener(`touchmove`,this.onBlockingTouchMove),t.hasWheelListener&&e.removeEventListener(`wheel`,this.onWheel),this.registry.delete(e),this.uninstallIfIdle())}syncListeners(){this.syncLayoutWatch(),this.syncArmed(),this.shouldListen()?(this.install(),this.syncClaimingListeners()):this.uninstall(),this.syncMoverBlocking()}syncMoverBlocking(){let e=this.isInstalled&&this.hitTestsLayout();e&&this.stopWatchingMovers==null?this.stopWatchingMovers=m(()=>this.syncMoverBlocking()):!e&&this.stopWatchingMovers!=null&&(this.stopWatchingMovers(),this.stopWatchingMovers=null);let t=e&&f().some(e=>this.hasClaimingRecognizerAround(e));if(t===(this.stopBlockingForMovers!=null))return;let r=this.doc.defaultView;t&&r!=null?this.stopBlockingForMovers=n(r,`touchmove`,this.onBlockingTouchMove,{cancels:!0}):t||(this.stopBlockingForMovers?.(),this.stopBlockingForMovers=null)}hasClaimingRecognizerAround(e){if(!e.isConnected||e.ownerDocument!==this.doc)return!1;for(let[t,n]of this.registry)if((p(e,t)||p(t,e))&&n.recognizers.some(e=>e.isEnabled&&V(e)))return!0;return!1}syncArmed(){let e=new Set;if(!this.isCoarse)for(let[t,n]of this.registry){let r=n.consumer;(n.recognizers.some(e=>e.isEnabled&&(e.allowedPointerTypes==null||e.allowedPointerTypes.size>0))||r!=null&&r.isEnabled?.()!==!1)&&e.add(t)}for(let[t,n]of this.armedElements)e.has(t)||(n(),this.armedElements.delete(t));for(let t of e)this.armedElements.has(t)||(t.addEventListener(`pointerdown`,this.onArmedPress,ft),this.armedElements.set(t,()=>{t.removeEventListener(`pointerdown`,this.onArmedPress,ft)}));e.size===0&&this.isArmedPress&&(this.isArmedPress=!1,this.syncKeptPresses())}onArmedPress=e=>{let t=e;this.isInstalled||!_t(t.pointerType)||t.pointerType!==`touch`&&!I(t)||(this.isArmedPress=!0,this.syncKeptPresses(),this.install(),t.pointerType!==`mouse`&&this.syncClaimingListeners(),this.onPointerDown(t))};syncKeptPresses(){for(let[e,t]of this.registry)t.consumer?.keepsTouch!=null&&this.syncTouchMoveListener(e,t)}dropCancelledLifts(e){let t=e.pointerType===`touch`&&e.isPrimary===!1;for(let[n,r]of[...this.cancelledPointers])(n===e.pointerId||!(t&&r===`touch`))&&this.cancelledPointers.delete(n)}releaseArmedPress(){this.isArmedPress&&queueMicrotask(()=>{this.isArmedPress&&this.arena.touches.length===0&&this.cancelledPointers.size===0&&(this.isArmedPress=!1,this.syncKeptPresses(),this.syncListeners())})}uninstallIfIdle(){this.syncListeners(),this.registry.size===0&&this.retainers===0&&(this.uninstall(),this.stopWatchingPointer?.(),this.stopWatchingPointer=null,this.releaseWhenIdle())}releaseWhenIdle(){queueMicrotask(()=>{if(!(this.registry.size>0||this.retainers>0)){this.cancelledFingers.clear(),this.cancelledPointers.clear(),this.clearClaimedLifts(),this.cancelCallerRead?.(),this.cancelCallerRead=null,this.isCallerReadScheduled=!1,this.pendingCallerReads.clear();for(let e of this.ownScrollFrames.values())e();this.ownScrollFrames.clear(),this.ownedScrolls.clear();for(let e of[...this.dragHolds])e({isCancel:!0});this.pressSelections.clear(),this.selectingContacts.clear()}})}watchPointer(){if(this.stopWatchingPointer!=null)return;let e=this.doc.defaultView;this.isCoarse=this.isPrimaryPointerCoarse(),this.stopWatchingPointer=this.followsPointer?i(e,e=>this.pointerChanged(e)):()=>{}}pointerChanged(e){if(e!==this.isCoarse){this.isCoarse=e,e||this.cancelEverything(this.arena.now());for(let[e,t]of this.registry)this.refresh(e,t);this.syncListeners()}}hasClaimer(){for(let e of this.registry.values()){let t=e.consumer;if(t!=null&&t.isEnabled?.()!==!1||e.recognizers.some(e=>e.isEnabled&&e.claimsTouches&&pt(e)))return!0}return!1}syncClaimingListeners(){if(!this.isInstalled)return;let e=this.hasClaimer();if(e===this.isClaimingInstalled)return;let t=this.doc.defaultView;for(let e of this.claimingUnsubscribers.splice(0))e();t!=null&&(this.inputMode===`auto`&&this.claimingUnsubscribers.push(n(t,`touchend`,this.onTouchEnd,{cancels:e})),e&&this.claimingUnsubscribers.push(n(t,`contextmenu`,this.onContextMenu,{cancels:!0}))),this.isClaimingInstalled=e}shouldListen(){if(!this.needsInput())return!1;if(this.isCoarse&&this.retainers>0)return!0;let e=!1;for(let t of this.registry.values()){let n=t.consumer;if(n!=null&&n.isEnabled?.()!==!1||t.recognizers.some(e=>e.isEnabled)){e=!0;break}}return e&&(this.isCoarse||this.isArmedPress)}install(){if(this.watchPointer(),!this.needsInput()||this.isInstalled)return;let e=this.doc.defaultView;this.isInstalled=!0,this.usesTouchEvents=this.inputMode===`auto`&&e!=null&&`ontouchstart`in e,e!=null&&(this.unsubscribers=[...this.inputMode===`auto`?[n(e,`touchstart`,this.onTouchStart),n(e,`touchmove`,this.onTouchMove),n(e,`touchcancel`,this.onTouchCancel)]:[],n(e,`pointerdown`,this.onPointerDown),n(e,`pointermove`,this.onPointerMove),n(e,`pointerup`,this.onPointerUp),n(e,`pointercancel`,this.onPointerCancel),n(e,`scroll`,this.onScroll),n(e,`visibilitychange`,this.onVisibilityChange),n(e,`blur`,t=>{t.target instanceof e.Node||this.onBlur()})],this.isClaimingInstalled=!1,this.claimingUnsubscribers=this.inputMode===`auto`?[n(e,`touchend`,this.onTouchEnd)]:[])}uninstall(){if(this.isInstalled){this.isInstalled=!1,this.fingerTargets=[],this.isClaimingInstalled=!1;for(let e of[...this.unsubscribers.splice(0),...this.claimingUnsubscribers.splice(0)])e();this.cancelEverything(this.arena.now()),this.lastTouch=null,this.lastScroll=null}}participantsAt(e,t){let n=[],r=null,i=null;if(e instanceof Node&&[...this.touchGates].some(t=>t(e)))return{recognizers:n,consumer:r,consumerElement:i};let a=t==null;for(let o=e instanceof Node?e:null;o!=null;o=d(o)){if(!(o instanceof Element))continue;let e=this.registry.get(o);e!=null&&n.push(...e.recognizers),!(a||t==null)&&e?.consumer!=null&&(r=e.consumer,i=o,a=!0)}return{recognizers:n,consumer:r,consumerElement:i}}lockSelection(e,t,n,r,i){let a=e=>this.registry.get(e)?.manageStyle!==!1,o=new Map;for(let e of t){let t=e.selectionLock;if(t!=null&&e.view instanceof Element&&a(e.view)){let n=o.get(t)??new Set;n.add(e.view),o.set(t,n)}}let s=r?.selectionLock;if(s!=null&&i!=null&&a(i)){let e=o.get(s)??new Set;e.add(i),o.set(s,e)}if(o.size>0){let t=[...o].map(([e,t])=>e(t,n));this.lockedBy.set(e,()=>{for(let e of t)e()})}}onWheel=e=>{let t=e;if(this.wheelsSeen.has(t))return;this.wheelsSeen.add(t);let n=J(t),r=t.ctrlKey?`pinch`:`pan`,i=this.wheel;if(i!=null&&(i.kind!==r||n-i.last>=i.endMs)&&(this.endWheel(n),i=null),i!=null&&i.ids.length>0&&i.follow?.lifted!==!0&&!this.wheelHasTaker(i)){this.endWheel(i.last);let e=Dt(t,this.doc.defaultView);i={kind:r,scrollType:q(t),ids:[],x:t.clientX,y:t.clientY,span:St,last:n,endMs:Ct(r,q(t),Math.abs(e.dx)>Math.abs(e.dy)),timer:null,takers:[]},this.wheel=i}let{dx:a,dy:o}=Dt(t,this.doc.defaultView),s=Math.abs(a)>Math.abs(o),c=null;if(r===`pan`?c=this.segmenter.push(n,s?a:o,s?bt:yt):this.segmenter.end(),this.wheelSegment=c,c?.boundary!=null&&i!=null&&(this.endWheel(n),i=null),i??(i=this.beginWheel(t,r,a,o,n),this.wheel=i,i.ids.length>0&&this.latchWheel()),i.last=n,i.timer!=null&&this.clock.clearTimeout(i.timer),i.timer=this.clock.setTimeout(()=>{this.segmenter.end(),this.endWheel()},i.endMs),i.ids.length!==0){if(t.preventDefault(),i.kind===`pan`&&i.follow){let e=i.follow;if(e.lifted)return;if(this.wheelSegment?.liftNow===!0){this.followProvisionally(i,e,n),e.lifted=!0,this.arena.ended([{id:i.ids[0],x:i.x,y:i.y,time:n}]);return}if(this.wheelSegment?.decaying===!0){if(e.heldX+=a,e.heldY+=o,this.wheelSegment.bunched){let t=n-e.lastMove,r=e.speedX,i=e.speedY;Tt(e,e.trueX-e.heldX,e.trueY-e.heldY),e.baseX+=(r-e.speedX)*t,e.baseY+=(i-e.speedY)*t}else e.readSpan=0;this.followProvisionally(i,e,n);return}let t=e.trueX-e.heldX,r=e.trueY-e.heldY,s=wt(i.x-t,a),c=wt(i.y-r,o),l=t-a,u=r-o,d=n-e.lastMove;this.wheelSegment?.bunched===!0?Tt(e,l,u):d>0&&(e.priorSpeedX=e.speedX,e.priorSpeedY=e.speedY,e.readFromX=e.trueX,e.readFromY=e.trueY,e.readSpan=d,e.speedX=(l-e.trueX)/d,e.speedY=(u-e.trueY)/d),e.trueX=l,e.trueY=u,e.heldX=0,e.heldY=0,e.lastMove=n,i.x=l+s,i.y=u+c,e.baseX=i.x,e.baseY=i.y,this.arena.moved([{id:i.ids[0],x:i.x,y:i.y,time:n}])}else i.kind===`pan`?(i.x-=a,i.y-=o,this.arena.moved([{id:i.ids[0],x:i.x,y:i.y,time:n}])):(i.span*=Math.exp(-o/100),this.arena.moved(this.pinchContacts(i,n)))}};followProvisionally(e,t,n){let r=Math.max(0,n-t.lastMove),i=t.baseX+t.speedX*r,a=t.baseY+t.speedY*r;(i!==e.x||a!==e.y)&&(e.x=i,e.y=a,this.arena.moved([{id:e.ids[0],x:i,y:a,time:n}]))}beginWheel(e,t,n,r,i){let a=q(e),o=Math.abs(n)>Math.abs(r),s={kind:t,scrollType:a,ids:[],x:e.clientX,y:e.clientY,span:St,last:i,endMs:Ct(t,a,o),timer:null,takers:[]};if(this.arena.touches.length>0||n===0&&r===0||e.defaultPrevented||!e.cancelable)return s;let c=G(e),l=A(c,{readsTouchAction:!1}),u=[];for(let e=c instanceof Node?c:null;e!=null;e=d(e))if(e instanceof Element)for(let i of this.registry.get(e)?.recognizers??[])i.isEnabled&&i.claimsTouches&&i.allowedScrollTypes.has(a)&&w(i).family===t&&(t!==`pan`||a===`continuous`)&&(t===`pan`&&(!kt(i,-n,-r)||this.scrollerTakes(c,e,n,r,o)||Ot(i)&&l.canScroll(-n,-r))||u.push(i));if(u.length===0)return s;let f={pointerType:`mouse`,target:c,scroll:l,scrollType:a,recognizers:u,consumer:null},p=t===`pan`?[this.nextId++]:[this.nextId++,this.nextId++],m={...s,ids:p,takers:u};return t===`pan`&&a===`continuous`&&(m.follow={lifted:!1,heldX:0,heldY:0,lastMove:i,trueX:s.x,trueY:s.y,baseX:s.x,baseY:s.y,speedX:0,speedY:0,readFromX:s.x,readFromY:s.y,readSpan:0,priorSpeedX:0,priorSpeedY:0}),this.arena.began(t===`pan`?[{...f,id:p[0],x:e.clientX,y:e.clientY,time:i}]:this.pinchContacts(m,i).map(e=>({...f,...e}))),p.every(e=>this.arena.participantsOf(e).length===0)?(this.arena.cancelled(p,i),s):m}scrollerTakes(e,t,n,r,i){for(let a=e instanceof Node?e:null;a!=null;a=d(a)){if(a instanceof Element&&Ce(a,i?-n:0,i?0:-r))return!0;if(a===t)break}return!1}pinchContacts(e,t){return[{id:e.ids[0],x:e.x-e.span/2,y:e.y,time:t},{id:e.ids[1],x:e.x+e.span/2,y:e.y,time:t}]}wheelHasTaker(e){return e.takers.some(e=>{let{state:t}=e;return e.isEnabled&&(t===`began`||t===`changed`||t===`possible`&&e.isInvolved())})}latchWheel(){let e=this.doc.defaultView;if(this.stopWheelLatch==null&&e!=null){let t=()=>{let e=this.dropDrivenWheel();e.length>0&&this.arena.cancelled(e,this.arena.now())},r=[n(e,`wheel`,this.onWheel,{cancels:!0}),n(e,`blur`,n=>{n.target instanceof e.Node||t()}),n(e,`visibilitychange`,()=>{this.doc.visibilityState===`hidden`&&t()})];this.stopWheelLatch=()=>{for(let e of r)e()}}}lockClaimedDrags(e,t){for(let n of e){if(this.claimHolds.has(n))continue;let e=this.arena.touches.find(e=>e.id===n);if(e==null||e.pointerType===`touch`||e.scrollType!=null||e.phase===`ended`||e.phase===`cancelled`)continue;let r=new Set;for(let e of this.arena.participantsOf(n))(e.state===`began`||e.state===`changed`)&&e.view?.nodeType===1&&r.add(e.view);if(t.view?.nodeType===1&&r.add(t.view),r.size===0)continue;let i=Ue(r,this.doc.defaultView,this.pressSelections.get(n)??[],()=>{this.dragHolds.delete(i)});this.dragHolds.add(i),this.lockedBy.has(n)||this.lockedBy.set(n,i),this.claimHolds.set(n,i)}}releaseClaimedDrags(e){for(let t of e){let e=this.claimHolds.get(t);e!=null&&(this.claimHolds.delete(t),this.lockedBy.get(t)===e&&this.lockedBy.delete(t),e({isCancel:!0}))}}dropDrivenWheel(){let e=this.wheel;if(e==null||e.kind!==`pan`||e.ids.length===0||e.follow?.lifted===!0)return[];let t={...e,ids:[],takers:[]};return delete t.follow,this.wheel=t,this.stopWheelLatch?.(),this.stopWheelLatch=null,e.ids}endWheel(e){let t=this.wheel;if(this.stopWheelLatch?.(),this.stopWheelLatch=null,t==null||(this.wheel=null,t.timer!=null&&this.clock.clearTimeout(t.timer),t.ids.length===0||t.follow?.lifted))return;if(t.follow!=null){let e=t.follow,n=Et(t.x,e.trueX-e.heldX,e.speedX),r=Et(t.y,e.trueY-e.heldY,e.speedY);(n!==t.x||r!==t.y)&&(t.x=n,t.y=r,this.arena.moved([{id:t.ids[0],x:n,y:r,time:t.last}]))}let n=t.last+t.endMs,r=e==null?n:Math.max(t.last,Math.min(n,e));this.arena.ended(t.kind===`pan`?[{id:t.ids[0],x:t.x,y:t.y,time:r}]:this.pinchContacts(t,r))}noteSelectingPress(e,t,n,r){!this.lockedBy.has(e)&&Ge(this.doc,t,n,r)&&this.selectingContacts.add(e)}unlockSelection(e,t=!1){let n=this.lockedBy.get(e);n?.({isCancel:t});let r=this.claimHolds.get(e);r!=null&&r!==n&&r({isCancel:t}),this.lockedBy.delete(e),this.claimHolds.delete(e),this.pressSelections.delete(e),this.selectingContacts.delete(e)}addTouchGate(e){return this.touchGates.add(e),()=>{this.touchGates.delete(e)}}fingersDown(){return this.fingerTargets.length}takeEvent(e){return!this.processed.has(e)&&(this.processed.add(e),!0)}onTouchStart=e=>{if(this.endWheel(J(e)),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.fingerTargets.length>1&&this.failUnclaimedLoneFingerPans();let t=J(e),n=[],r=[],i=[],a=[];for(let o of Y(e.changedTouches)){if(o.touchType===`stylus`)continue;this.cancelledFingers.delete(o.identifier);let s=this.forgetFinger(o.identifier);s!=null&&i.push(s);let c=o.target instanceof Node?G(e,o.target):G(e),l=this.presentedTarget(c,o.clientX,o.clientY,e.timeStamp),{recognizers:u,consumer:d,consumerElement:f}=this.participantsAt(l,`touch`);if(u.length===0&&d==null){r.push({id:this.nextId++,x:o.clientX,y:o.clientY,time:t,pointerType:`touch`,target:l});continue}let p=this.nextId++;this.touchIds.set(o.identifier,p),Ve(`touch`)&&a.push({id:p,target:l,consumerElement:f}),this.watchTarget(o.identifier,c,u.some(e=>e.isEnabled&&V(e))||d?.keepsTouch!=null&&d.isEnabled?.()!==!1,d!=null&&d.isEnabled?.()!==!1||u.some(e=>e.isEnabled&&e.claimsTouches)),this.lastFed.set(p,{x:o.clientX,y:o.clientY,time:t}),this.pairTouch(p,{x:o.clientX,y:o.clientY,target:c}),l!==c&&l!=null&&this.retargeted.set(p,{x:o.clientX,y:o.clientY,target:l}),n.push({id:p,x:o.clientX,y:o.clientY,time:t,pointerType:`touch`,target:l,scroll:A(l),recognizers:u,consumer:d})}i.length>0&&this.arena.cancelled(i,t),this.arena.began(n);for(let{id:e,target:t,consumerElement:n}of a)this.lockSelection(e,this.arena.participantsOf(e),t,this.arena.consumerOf(e)??null,n);for(let e of r)this.arena.untrackedBegan(e);this.fingerTargets.length>1&&!this.isFingerClaimed()&&this.failUnclaimedLoneFingerPans();let o=G(e);o instanceof Node&&(this.lastTouch={target:o,time:t})};onTouchMove=e=>{if(this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.dropFingersNotDown(e);let t=J(e),n=[],r=[];for(let i of Y(e.changedTouches)){let e=this.touchIds.get(i.identifier);e!=null&&(n.push(e),r.push({id:e,x:i.clientX,y:i.clientY,time:t}))}if(r.length!==0){if(!e.cancelable){let e=new Map(r.map(e=>[e.id,e])),i=n.filter(t=>{let n=this.arena.getTouch(t);if(n==null||n.takenByBrowser||this.arena.isClaimed(t)||n.scroll?.allowsNativePan===!1||this.judgedUncancelable.has(t))return!1;this.judgedUncancelable.add(t);let r=e.get(t);if(r==null||n.scroll==null)return!0;let i=r.x-n.startX,a=r.y-n.startY;return Math.abs(i)>=Math.abs(a)?n.scroll.canScroll(i,0):n.scroll.canScroll(0,a)});i.length>0&&this.browserTook(i,t)}this.feedMoves(r.filter(e=>!this.pointerFed.has(e.id)))}};onBlockingTouchMove=e=>{this.cancelIfClaimed(e)};pointerFingerAt(e){let t=null,n=1/0;for(let r of this.arena.touches){if(r.pointerType!==`touch`||r.phase===`ended`||r.phase===`cancelled`||!(r.target instanceof Node)||!(e.target instanceof Node)||!(p(r.target,e.target)||p(e.target,r.target)))continue;let i=Math.hypot(r.x-e.clientX,r.y-e.clientY);i<n&&(t=r,n=i)}return t?.id}onClaimedTouchEnd=e=>{let t=e,n=J(t);for(let e=this.claimedLifts.length-1;e>=0;e--)n-this.claimedLifts[e].time>U&&this.claimedLifts.splice(e,1);if(t.cancelable&&!t.defaultPrevented)for(let e of Y(t.changedTouches)){let n=this.claimedLifts.findIndex(n=>W(n,{x:e.clientX,y:e.clientY,target:G(t,e.target)}));if(n>=0){this.claimedLifts.splice(n,1),this.claimedLifts.length===0&&this.clearClaimedLifts(),t.preventDefault();return}}};cancelIfClaimed(e){if(!e.cancelable||e.defaultPrevented)return;let t=Y(e.changedTouches);for(let n of t){let t=this.touchIds.get(n.identifier)??(this.usesTouchEvents?void 0:this.pointerFingerAt(n));if(t!=null&&(this.arena.isClaimed(t)||this.arena.consumerOf(t)?.keepsTouch?.(t)===!0||e.touches.length===1&&this.arena.participantsOf(t).some(e=>w(e).keepsTouch(t)))){e.preventDefault();return}}if(ht(e)){for(let t of this.pointerIds.values())if(this.arena.isClaimed(t)){e.preventDefault();return}}}onTouchEnd=e=>{if(this.releaseArmedPress(),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.dropFingersNotDown(e);let t=J(e),n=[],r=[],i=!1;for(let a of Y(e.changedTouches)){if(this.cancelledFingers.delete(a.identifier)){i=!0;continue}let e=this.touchIds.get(a.identifier),o=e==null?void 0:this.retargeted.get(e),s=this.forgetFinger(a.identifier);s!=null&&(n.push({id:s,x:a.clientX,y:a.clientY,time:t}),o!=null&&r.push({id:s,landed:o,x:a.clientX,y:a.clientY}))}let a=G(e);a instanceof Node&&(this.lastTouch={target:a,time:t});let o=n.length>0?this.arena.ended(n):new Map,s=i||X(o);for(let e of r)this.clickRetargetedTap(e.landed,e,o.get(e.id),`touch`)&&(s=!0);s&&(e.cancelable&&e.preventDefault(),c(this.doc,{takesLateMouse:!0}))};clickRetargetedTap(e,t,n,r){return e==null||n!==`allow`||Math.hypot(t.x-e.x,t.y-e.y)>_.allowableMovement.value?!1:(this.clickRetargeted(e.target,t.x,t.y,r),!0)}onTouchCancel=e=>{if(this.releaseArmedPress(),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;let t=Y(e.changedTouches),n=t.length>0?t.map(e=>e.identifier):[...this.touchIds.keys()];t.length===0&&this.cancelledFingers.clear();for(let e of n)this.cancelledFingers.delete(e);let r=[];for(let e of n){let t=this.forgetFinger(e);t!=null&&r.push(t)}r.length>0&&this.arena.cancelled(r,J(e))};onTargetTouchMove=e=>{this.onTouchMove(e),this.cancelIfClaimed(e)};onTargetTouchMovePassive=e=>{this.onTouchMove(e)};onTargetTouchEnd=e=>{this.onTouchEnd(e)};onTargetTouchEndPassive=e=>{this.onTouchEnd(e)};onTargetTouchCancel=e=>{this.onTouchCancel(e)};dropFingersNotDown(e){if(e.touches==null||this.touchIds.size===0&&this.cancelledFingers.size===0)return;let t=new Set;for(let n of Y(e.touches))t.add(n.identifier);for(let n of Y(e.changedTouches))t.add(n.identifier);for(let e of[...this.cancelledFingers])t.has(e)||this.cancelledFingers.delete(e);let n=[...this.touchIds.keys()].filter(e=>!t.has(e)),r=[];for(let e of n){let t=this.forgetFinger(e);t!=null&&r.push(t)}r.length>0&&this.arena.cancelled(r,J(e))}watchTarget(e,t,n,r){if(t==null||typeof t.addEventListener!=`function`)return;this.touchTargets.set(e,t);let i=this.watched.get(t);if(i==null){this.watched.set(t,{count:1,blocking:+!!n,claiming:+!!r}),n&&this.blockingFingers.add(e),r&&this.claimingFingers.add(e),t.addEventListener(`touchmove`,n?this.onTargetTouchMove:this.onTargetTouchMovePassive,{passive:!n}),t.addEventListener(`touchend`,r?this.onTargetTouchEnd:this.onTargetTouchEndPassive,{passive:!r}),t.addEventListener(`touchcancel`,this.onTargetTouchCancel,{passive:!0});return}let a=i.blocking>0,o=i.claiming>0;i.count+=1,n&&(i.blocking+=1,this.blockingFingers.add(e)),r&&(i.claiming+=1,this.claimingFingers.add(e)),this.swapTargetTouchMove(t,a,i.blocking>0),this.swapTargetTouchEnd(t,o,i.claiming>0)}unwatchTarget(e){let t=this.touchTargets.get(e);if(t==null)return;this.touchTargets.delete(e);let n=this.watched.get(t);if(n==null)return;let r=n.blocking>0,i=n.claiming>0;--n.count,this.blockingFingers.delete(e)&&--n.blocking,this.claimingFingers.delete(e)&&--n.claiming,n.count>0?(this.swapTargetTouchMove(t,r,n.blocking>0),this.swapTargetTouchEnd(t,i,n.claiming>0)):(this.watched.delete(t),t.removeEventListener(`touchmove`,r?this.onTargetTouchMove:this.onTargetTouchMovePassive),t.removeEventListener(`touchend`,i?this.onTargetTouchEnd:this.onTargetTouchEndPassive),t.removeEventListener(`touchcancel`,this.onTargetTouchCancel))}swapTargetTouchMove(e,t,n){t!==n&&(e.removeEventListener(`touchmove`,t?this.onTargetTouchMove:this.onTargetTouchMovePassive),e.addEventListener(`touchmove`,n?this.onTargetTouchMove:this.onTargetTouchMovePassive,{passive:!n}))}swapTargetTouchEnd(e,t,n){t!==n&&(e.removeEventListener(`touchend`,t?this.onTargetTouchEnd:this.onTargetTouchEndPassive),e.addEventListener(`touchend`,n?this.onTargetTouchEnd:this.onTargetTouchEndPassive,{passive:!n}))}forgetFinger(e){let t=this.touchIds.get(e);return this.touchIds.delete(e),this.unwatchTarget(e),t!=null&&this.forgetContact(t),t}pairTouch(e,t){for(let[n,r]of this.pendingPointers)if(W(r,t)){this.pendingPointers.delete(n),this.fingerPointers.set(n,e),this.pointerFed.add(e);return}this.unpairedTouches.set(e,t)}pairPointer(e,t){for(let[n,r]of this.unpairedTouches)if(W(r,t)){this.unpairedTouches.delete(n),this.fingerPointers.set(e,n),this.pointerFed.add(n);return}this.pendingPointers.set(e,t)}feedMoves(e){let t=e.filter(e=>{let t=this.lastFed.get(e.id);return t!=null&&e.time<t.time?!1:(this.lastFed.set(e.id,{x:e.x,y:e.y,time:e.time}),!0)});t.length>0&&this.arena.moved(t)}forgetContact(e){this.unlockSelection(e),this.retargeted.delete(e),this.lastFed.delete(e),this.pointerFed.delete(e),this.judgedUncancelable.delete(e),this.unpairedTouches.delete(e);for(let[t,n]of this.fingerPointers)n===e&&this.fingerPointers.delete(t)}onPointerDown=e=>{if(this.endWheel(J(e)),l(this.doc),!_t(e.pointerType))return;if(this.dropCancelledLifts(e),e.pointerType===`touch`&&this.usesTouchEvents){this.pairPointer(e.pointerId,{x:e.clientX,y:e.clientY,target:G(e)});return}if(e.pointerType===`touch`&&e.isPrimary===!1&&this.failUnclaimedLoneFingerPans(),e.pointerType!==`touch`&&!I(e))return;let t=G(e),n=this.presentedTarget(t,e.clientX,e.clientY,e.timeStamp),{recognizers:r,consumer:i,consumerElement:a}=this.participantsAt(n,e.pointerType);if(r.length===0&&i==null)return;let o=this.nextId++;this.pointerIds.set(e.pointerId,o),this.pointerKinds.set(e.pointerId,e.pointerType),n!==t&&n!=null&&this.retargeted.set(o,{x:e.clientX,y:e.clientY,target:n}),e.pointerType!==`touch`&&this.pressSelections.set(o,We(this.doc.defaultView)),this.arena.began([{id:o,x:e.clientX,y:e.clientY,time:J(e),pointerType:e.pointerType,target:n,scroll:A(n),recognizers:r,consumer:i}]),e.pointerType===`touch`&&e.isPrimary===!1&&!this.isFingerClaimed()&&this.failUnclaimedLoneFingerPans(),Ve(e.pointerType)&&this.lockSelection(o,this.arena.participantsOf(o),n,this.arena.consumerOf(o)??null,a),e.pointerType!==`touch`&&this.noteSelectingPress(o,e.clientX,e.clientY,t)};onPointerMove=e=>{if(e.pointerType===`touch`&&this.usesTouchEvents){let t=this.fingerPointers.get(e.pointerId);t!=null&&this.feedMoves([{id:t,x:e.clientX,y:e.clientY,time:J(e),history:jt(e)}]);return}let t=this.pointerIds.get(e.pointerId);t!=null&&this.arena.moved([{id:t,x:e.clientX,y:e.clientY,time:J(e),history:jt(e)}])};onPointerUp=e=>{if(this.releaseArmedPress(),e.pointerType===`touch`&&this.usesTouchEvents){this.fingerPointers.delete(e.pointerId),this.pendingPointers.delete(e.pointerId);return}let t=this.pointerIds.get(e.pointerId);if(t==null){this.cancelledPointers.delete(e.pointerId)&&this.refuseCancelledLift(e);return}this.pointerIds.delete(e.pointerId),this.pointerKinds.delete(e.pointerId),this.unlockSelection(t);let n=this.arena.ended([{id:t,x:e.clientX,y:e.clientY,time:J(e)}]),r=this.retargeted.get(t);this.retargeted.delete(t);let i=this.clickRetargetedTap(r,{x:e.clientX,y:e.clientY},n.get(t),e.pointerType);!i&&X(n)&&c(this.doc,{takesLateMouse:e.pointerType===`touch`}),e.pointerType===`touch`&&(i||X(n))&&this.noteClaimedLift(e)};noteClaimedLift(e){this.readsFingersFromPointerEvents()&&(this.isCoarse||this.sendsTouchEvents())&&(this.claimedLifts.push({x:e.clientX,y:e.clientY,target:G(e),time:J(e)}),this.claimedLifts.length>gt&&this.claimedLifts.shift(),this.armClaimedLiftTimer())}armClaimedLiftTimer(){if(this.claimedLiftTimer!=null||this.claimedLifts.length===0)return;let e=this.claimedLifts[0].time+U;this.claimedLiftTimer=this.clock.setTimeout(()=>{this.claimedLiftTimer=null;let e=this.clock.now();for(let t=this.claimedLifts.length-1;t>=0;t--)e-this.claimedLifts[t].time>=U&&this.claimedLifts.splice(t,1);this.armClaimedLiftTimer()},Math.max(0,e-this.clock.now()))}clearClaimedLifts(){this.claimedLifts.length=0,this.claimedLiftTimer!=null&&(this.clock.clearTimeout(this.claimedLiftTimer),this.claimedLiftTimer=null)}onPointerCancel=e=>{if(this.releaseArmedPress(),e.pointerType===`touch`&&this.usesTouchEvents){let t=this.fingerPointers.get(e.pointerId)??this.touchForCancelledPointer(e);this.fingerPointers.delete(e.pointerId),this.pendingPointers.delete(e.pointerId),t!=null&&(this.pointerFed.delete(t),this.browserTook([t],J(e)));return}this.cancelledPointers.delete(e.pointerId);let t=this.pointerIds.get(e.pointerId);t!=null&&(this.pointerIds.delete(e.pointerId),this.pointerKinds.delete(e.pointerId),this.unlockSelection(t,!0),this.retargeted.delete(t),this.arena.cancelled([t],J(e)))};touchForCancelledPointer(e){let t=null,n=1/0;for(let r of this.arena.touches){if(r.pointerType!==`touch`||r.phase===`ended`||r.phase===`cancelled`||r.target!==G(e))continue;let i=Math.hypot(r.x-e.clientX,r.y-e.clientY);i<n&&(t=r,n=i)}return t==null?this.touchIds.get(e.pointerId)??null:t.id}replayClick(e,t){if(!t)return;l(this.doc);let n=e.target,r=this.doc.defaultView;n instanceof Element&&n.isConnected&&r!=null&&s(()=>n.dispatchEvent(new r.MouseEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:1,clientX:e.x,clientY:e.y})))}onContextMenu=e=>{for(let t of this.arena.touches)if(this.arena.isClaimed(t.id)||this.arena.consumerOf(t.id)?.holdsContextMenu?.(t.id)===!0){e.preventDefault();return}};ownScroll(e){let t=++this.ownScrollCalls;this.ownedScrolls.set(e,t);let n=this.doc.defaultView;if(n==null)return;this.ownScrollFrames.get(e)?.();let r=0,i=n.requestAnimationFrame(()=>{r=n.requestAnimationFrame(()=>{this.ownScrollFrames.delete(e),this.ownedScrolls.get(e)===t&&this.ownedScrolls.delete(e)})});this.ownScrollFrames.set(e,()=>{n.cancelAnimationFrame(i),r!==0&&n.cancelAnimationFrame(r)})}isOwnScroll(e){return this.ownedScrolls.has(e)}onScroll=e=>{let t=J(e),n=e.target===this.doc?this.doc:e.target;if(!(n instanceof Node)||this.ownedScrolls.has(n))return;let r=this.lastTouch;r!=null&&t-r.time<b.momentumMemory.value&&p(n,r.target)&&(this.lastScroll={scroller:n,time:t});let i=[];for(let e of this.arena.touches)e.takenByBrowser||e.phase===`ended`||e.phase===`cancelled`||e.pointerType!==`touch`||this.arena.isClaimed(e.id)||e.target instanceof Node&&p(n,e.target)&&Math.hypot(e.x-e.startX,e.y-e.startY)>=b.slop.value&&i.push(e.id);i.length>0&&this.browserTook(i,t)};noteFingersDown(e){let t=[];for(let n of Y(e.touches))n.touchType!==`stylus`&&n.target instanceof Node&&t.push(n.target);this.fingerTargets=t;for(let e of[...this.fingerListeners])e()}failUnclaimedLoneFingerPans(){for(let e of[...this.arena.involvedRecognizers])mt(e)&&e.state===`possible`&&e.maximumNumberOfTouches===1&&e.trackedTouches.length>0&&e.trackedTouches.every(e=>e.pointerType===`touch`&&!this.arena.isClaimed(e.id))&&e.cancel()}isFingerClaimed(){return this.arena.touches.some(e=>e.pointerType===`touch`&&this.arena.isClaimed(e.id))}onVisibilityChange=()=>{this.doc.visibilityState===`hidden`&&(this.cancelEverything(this.arena.now()),this.releaseArmedPress())};onBlur=()=>{this.cancelEverything(this.arena.now()),this.releaseArmedPress()};sendsTouchEvents(){let e=this.doc.defaultView;return e!=null&&`ontouchstart`in e}readsFingersFromPointerEvents(){let e=this.doc.defaultView;return this.inputMode===`pointer-events`||e!=null&&!(`ontouchstart`in e)}refuseCancelledLift(e){c(this.doc,{takesLateMouse:e.pointerType===`touch`}),e.pointerType===`touch`&&this.noteClaimedLift(e)}cancelEverything(e){for(let[e,t]of this.pointerKinds)t!==`mouse`&&this.cancelledPointers.set(e,t);let t=[...this.pointerIds.values()];for(let e of t)this.unlockSelection(e,!0);for(let e of[...this.touchIds.keys()]){this.cancelledFingers.add(e);let n=this.forgetFinger(e);n!=null&&t.push(n)}this.pointerIds.clear(),this.pointerKinds.clear(),this.retargeted.clear(),this.fingerPointers.clear(),this.pendingPointers.clear(),this.unpairedTouches.clear(),this.lastFed.clear(),this.pointerFed.clear(),t.push(...this.dropDrivenWheel()),t.length>0&&this.arena.cancelled(t,e)}};function X(e){for(let t of e.values())if(t!==`allow`)return!0;return!1}function jt(e){return typeof e.getCoalescedEvents==`function`?e.getCoalescedEvents().slice(0,-1).map(e=>({x:e.clientX,y:e.clientY,time:J(e)})):[]}function Mt(e){let t=ct.get(e);return t??(t=new At(e),ct.set(e,t)),t}function Nt(e,t){let n=0,r=0,i=0;for(let a of e)t?.has(a.id)||(n+=a.x,r+=a.y,i+=1);return i===0?{x:0,y:0}:{x:n/i,y:r/i}}function Pt(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Z(e){return Math.hypot(e.x-e.startX,e.y-e.startY)}var Q=b,Ft={control:{highlightDelay:`inScrollers`,quickTapFlash:Q.quickTapFlash.value,releaseMs:e.press.highlightOutMs},cell:{highlightDelay:`inScrollers`,cancelTravel:v.hysteresis.value,quickTapFlash:0,releaseMs:e.press.highlightOutMs}};function It(e){if(e.kind!==`tap`)return!1;let t=e;return t.numberOfTapsRequired===1&&t.numberOfTouchesRequired===1}function Lt(e){let t=!1,n=null,r=null,i=null,a=null,o=!1,s={isHighlighted:!1,isTracking:!1,isTouchInside:!1},c=e=>{if(r==null)return!0;let t=h.trackingExpansion;return e.x>=r.left-t&&e.x<=r.right+t&&e.y>=r.top-t&&e.y<=r.bottom+t},l=(t,n)=>{e.onControlEvent?.(t,n)},u=r=>{r&&n!=null&&(t=!0),s.isHighlighted!==r&&(s.isHighlighted=r,e.onHighlightChange?.(r))},d=()=>{i!=null&&(clearTimeout(i),i=null)},f=()=>{a!=null&&(clearTimeout(a),a=null)},p=()=>{t=!1,n=null,s.isTracking=!1,s.isTouchInside=!1,r=null},m=e=>{e.id===n&&(t=!1,d(),l(`touchCancel`,e),u(!1),p())},h={get isHighlighted(){return s.isHighlighted},get isTracking(){return s.isTracking},get isTouchInside(){return s.isTouchInside},trackingExpansion:e.trackingExpansion??y.trackingExpansion.value,isEnabled(){return e.isEnabled?.()!==!1},holdsContextMenu(t){return e.holdsContextMenu?.(t)===!0},touchBegan(t){if(n!=null||e.isEnabled?.()===!1||t.pointerType===`touch`&&e.isBraking?.(t)===!0)return;f(),n=t.id,r=e.getBounds(),s.isTracking=!0,s.isTouchInside=!0,o=!1,l(`touchDown`,t);let a=e.highlightDelay??`inScrollers`;t.pointerType===`touch`&&(a===`always`||a===`inScrollers`&&t.scroll?.isInsideScroller===!0)?i=setTimeout(()=>{i=null,s.isTouchInside&&u(!0)},Q.contentTouchDelay.value):u(!0)},touchMoved(t){if(t.id!==n)return;let r=e.cancelTravel;if(r!=null&&Z(t)>r){m(t);return}i!=null&&Z(t)>Q.slop.value&&(clearTimeout(i),i=null,o=!0);let a=c(t);a!==s.isTouchInside&&(s.isTouchInside=a,l(a?`touchDragEnter`:`touchDragExit`,t),i==null&&!o&&u(a)),l(a?`touchDragInside`:`touchDragOutside`,t)},touchEnded(r){if(r.id!==n)return;t=!1;let o=c(r),s=i!=null;d(),l(o?`touchUpInside`:`touchUpOutside`,r);let f=e.quickTapFlash??Q.quickTapFlash.value;s&&o?(u(!0),f>0?a=setTimeout(()=>{a=null,u(!1)},f):u(!1)):u(!1),p()},touchCancelled:m,allowsAncestorRecognizer(t){let n=t;return n.view!=null&&n.view===e.view||!(e.vetoesAncestorRecognizer??It)(n)},dispose(){d(),f(),u(!1),p()},get selectionLock(){return e.selectionLock}};return e.keepsTouch===!0?Object.assign(h,{keepsTouch:e=>t&&n===e}):h}function Rt(e,{onClicked:t,onNoClick:r}){let i=e.ownerDocument.defaultView;if(i==null){let e=!1;return queueMicrotask(()=>{e||r()}),()=>{e=!0}}let a=!1,o=null,s=null,c=null,l=()=>{a=!0,c?.(),c=null,s!=null&&(i.clearTimeout(s),s=null)};return c=n(i,`click`,n=>{!a&&n.isTrusted&&e.contains(n.target)&&(l(),o=i.setTimeout(()=>{o=null,t(n.defaultPrevented)},0))}),s=i.setTimeout(()=>{a||(l(),r())},300),()=>{l(),o!=null&&(i.clearTimeout(o),o=null)}}function $(e){let t=e.ownerDocument.defaultView,n=null,r=t=>{n==null&&t.target===e&&(n=t)};t?.addEventListener(`click`,r,!0);try{e.click()}finally{t?.removeEventListener(`click`,r,!0)}return n?.defaultPrevented===!0}function zt(e){return c(e.ownerDocument),s(()=>$(e))}export{x as C,_ as S,ee as T,C as _,Lt as a,se as b,Pt as c,He as d,I as f,me as g,ge as h,Ft as i,Z as l,pe as m,$ as n,It as o,w as p,zt as r,Nt as s,Rt as t,Mt as u,ce as v,te as w,v as x,y};
1
+ import{l as e}from"./useHighlightedOptionScroll-C7rzQTVc.js";import{a as t,i as n,l as r,o as i}from"./usePressFeedback-nkH67NDc.js";import{t as a}from"./createReactComponent-DVEyVJ-p.js";import{t as o}from"./isRtlElement-BG33-k_H.js";import{i as s,n as c,r as l}from"./useResolvedRequired-B-0WnbIo.js";import{t as u}from"./isApplePlatform-BSwFAKoe.js";import{_ as d,f,g as p,h as m,m as h,p as g}from"./BaseTypeahead-CHXE162p.js";var ee=a(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),te={decelerationRate:{normal:.998,fast:.99},rubberBand:{coefficient:.55},bounce:{duration:.5,bounce:0},delaysContentTouchesMs:150,scrollToTopRate:.99035},_={allowableMovement:{value:45,unit:`px`},maximumIntervalBetweenTaps:{value:350,unit:`ms`},allowableSeparation:{value:45,unit:`px`},maximumTapDuration:{value:1500,unit:`ms`}},ne={minimumPressDuration:{value:500,unit:`ms`},allowableMovement:{value:10,unit:`px`}},v={hysteresis:{value:10,unit:`px`}},re={minimumDistance:{value:50,unit:`px`},maximumDuration:{value:500,unit:`ms`},maximumSecondaryMovement:{value:50,unit:`px`},minimumMovementDecay:{value:.06,unit:`ratio`}},ie={hysteresis:{value:8,unit:`px`}},ae={hysteresis:{value:.08726646259971647,unit:`rad`}},oe={edgeRegion:{value:40.2,unit:`px`},hysteresis:{value:15,unit:`px`}},y={trackingExpansion:{value:70,unit:`px`}},b={contentTouchDelay:{value:150,unit:`ms`},quickTapFlash:{value:100,unit:`ms`},slop:{value:10,unit:`px`},scrollBrake:{value:150,unit:`ms`},momentumMemory:{value:3e3,unit:`ms`}},x={currentWeight:{value:.2,unit:`ratio`},scrollReleaseWeight:{value:.25,unit:`ratio`},stillness:{value:40,unit:`ms`}},se={tap:_,longPress:ne,pan:v,swipe:re,pinch:ie,rotation:ae,screenEdgePan:oe,control:y,press:b,velocity:x},ce={selection:{value:[5],unit:`ms`},impactLight:{value:[8],unit:`ms`},impactMedium:{value:[12],unit:`ms`},impactHeavy:{value:[18],unit:`ms`},impactSoft:{value:[10],unit:`ms`},impactRigid:{value:[6],unit:`ms`},notificationSuccess:{value:[8,60,12],unit:`ms`},notificationWarning:{value:[12,80,12],unit:`ms`},notificationError:{value:[12,50,12,50,18],unit:`ms`}},le={viewportSize(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},isRtl(e){return typeof window>`u`||!(e instanceof Element)?!1:window.getComputedStyle(e).direction===`rtl`},viewRect(e){if(typeof Element>`u`||!(e instanceof Element))return null;let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}},ue=new Set([`began`,`changed`,`ended`,`cancelled`]),de={possible:[`began`,`ended`,`failed`],began:[`changed`,`ended`,`cancelled`],changed:[`changed`,`ended`,`cancelled`],ended:[`possible`],cancelled:[`possible`],failed:[`possible`]};function fe(e,t){return de[e].includes(t)}function S(e){return e===`ended`||e===`cancelled`||e===`failed`}function C(e){return e===`began`||e===`changed`}var pe={panX:!0,panY:!0,pinchZoom:!0,doubleTapZoom:!0},me={panX:!0,panY:!0,pinchZoom:!0,doubleTapZoom:!1},he=1,ge=class{id=he++;view=null;arena=null;pending=null;stateValue=`possible`;listeners=new Set;transitionListeners=new Set;failureRequirements=new Set;simultaneousWith=new Set;touches=new Map;seenTouchIds=new Set;lastLocation={x:0,y:0};constructor(e={}){this.options=e,this.name=e.name??this.constructor.name,this.isEnabled=e.isEnabled??!0,this.cancelsTouchesInView=e.cancelsTouchesInView??!0,this.selectionLock=e.selectionLock??null,this.delaysTouchesBegan=e.delaysTouchesBegan??!1,this.delaysTouchesEnded=e.delaysTouchesEnded??!0,this.allowedPointerTypes=e.allowedPointerTypes==null?null:new Set(e.allowedPointerTypes),this.allowedScrollTypes=new Set(e.allowedScrollTypes??this.defaultScrollTypes),this.requiresExclusiveTouchType=e.requiresExclusiveTouchType??!0}get isDiscrete(){return!1}get claimsTouches(){return this.options.claimsTouches??!0}get state(){return this.stateValue}get nativeTouchBehavior(){return pe}get acceptsTouchInput(){return this.allowedPointerTypes==null||this.allowedPointerTypes.has(`touch`)}get numberOfTouches(){return this.touches.size}get trackedTouches(){return[...this.touches.values()]}location(){if(this.touches.size===0)return this.lastLocation;let e=0,t=0;for(let n of this.touches.values())e+=n.x,t+=n.y;return this.lastLocation={x:e/this.touches.size,y:t/this.touches.size},this.lastLocation}get environment(){return this.arena?.environment??le}requireToFail(e){return this.failureRequirements.add(e),this}recognizeSimultaneouslyWith(...e){for(let t of e)this.simultaneousWith.add(t),t.simultaneousWith.add(this);return this}requiresFailureOf(e){return this.failureRequirements.has(e)||this.options.shouldRequireFailureOf?.(this,e)===!0||e.options.shouldBeRequiredToFailBy?.(e,this)===!0}allowsSimultaneous(e){return this.simultaneousWith.has(e)||this.options.shouldRecognizeSimultaneously?.(this,e)===!0&&e.options.shouldRecognizeSimultaneously?.(e,this)===!0}shouldBegin(){return this.options.shouldBegin?.(this)??!0}keepsTouch(e){return!1}canPrevent(e){return!0}canBePrevented(e){return!0}isInvolved(){return this.touches.size>0||this.pending!=null}addListener(e){let t=e;return this.listeners.add(t),()=>{this.listeners.delete(t)}}addTransitionListener(e){let t=e;return this.transitionListeners.add(t),()=>{this.transitionListeners.delete(t)}}touchesBegan(e,t){}touchesMoved(e,t){}touchesEnded(e,t){}touchesCancelled(e,t){C(this.state)?this.setState(`cancelled`):this.state===`possible`&&this.setState(`failed`)}touchesTakenByBrowser(e,t){return!this.claimsTouches||(this.touchesCancelled(e,t),!1)}touchBeganElsewhere(e,t){}reset(){}get defaultScrollTypes(){return[]}acceptsTouch(e){if(!this.isEnabled)return!1;if(e.scrollType!=null)return this.allowedScrollTypes.has(e.scrollType)&&(this.options.shouldReceiveTouch?.(this,e)??!0);if(this.allowedPointerTypes!=null&&!this.allowedPointerTypes.has(e.pointerType))return!1;if(this.requiresExclusiveTouchType){for(let t of this.touches.values())if(t.pointerType!==e.pointerType)return!1}return this.options.shouldReceiveTouch?.(this,e)??!0}setState(e){this.arena==null?this.applyState(e):this.arena.requestTransition(this,e)}setTimer(e,t){this.arena?.setTimer(this,e,t)}clearTimer(){this.arena?.clearTimer(this)}now(){return this.arena?.now()??0}wantsTouch(e){return this.state!==`possible`&&!C(this.state)||this.pending!=null?!1:this.acceptsTouch(e)}deliverBegan(e,t){for(let t of e)this.touches.set(t.id,t),this.seenTouchIds.add(t.id);this.location(),this.touchesBegan(e,t)}deliverBeganElsewhere(e,t){S(this.state)||this.touchBeganElsewhere(e,t)}deliverMoved(e,t){let n=e.filter(e=>this.touches.has(e.id));n.length===0||S(this.state)||(this.location(),this.touchesMoved(n,t))}deliverEnded(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0){this.location(),S(this.state)||this.touchesEnded(n,t);for(let e of n)this.touches.delete(e.id)}}deliverCancelled(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0){S(this.state)||this.touchesCancelled(n,t);for(let e of n)this.touches.delete(e.id)}}deliverTakenByBrowser(e,t){let n=e.filter(e=>this.touches.has(e.id));if(n.length!==0&&(S(this.state)||!this.touchesTakenByBrowser(n,t)))for(let e of n)this.touches.delete(e.id)}onEnabledChange=null;setEnabled(e){let t=this.isEnabled!==e;this.isEnabled=e,t&&this.onEnabledChange?.(),!e&&(this.state!==`possible`||this.isInvolved())&&this.cancel()}cancel(){this.arena==null?C(this.state)?this.applyState(`cancelled`):this.state===`possible`&&this.isInvolved()&&this.applyState(`failed`):this.arena.stop(this)}applyState(e){let t=this.stateValue;if((t!==e||e===`changed`)&&fe(t,e)){this.stateValue=e,e!==`possible`&&(this.pending=null);for(let n of[...this.transitionListeners])n(this,t,e);if(ue.has(e))for(let e of[...this.listeners])e(this)}}resetToPossible(){this.clearTimer(),this.pending=null,this.touches.clear(),this.seenTouchIds.clear(),this.reset(),this.applyState(`possible`)}};function w(e){return e}var _e={now:()=>typeof performance>`u`?Date.now():performance.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},ve=class{movingIds=new Set;records=new Map;active=[];timers=new Map;realTimer=null;realTimerDeadline=1/0;currentTime=null;latestTime=-1/0;depth=0;deferDepth=0;owesResolution=!1;constructor(e={}){this.options=e,this.clock=e.clock??_e,this.environment=e.environment??le}now(){return this.currentTime??Math.max(this.latestTime,this.clock.now())}isClaimed(e){return this.records.get(e)?.isClaimed===!0}consumerOf(e){return this.records.get(e)?.consumer??null}getTouch(e){return this.records.get(e)?.touch}participantsOf(e){return this.records.get(e)?.participants??[]}get touches(){return[...this.records.values()].map(e=>e.touch)}get involvedRecognizers(){return this.active}began(e){e.length!==0&&this.run(e[0].time,()=>{let t=new Map,n=[];for(let r of e){if(this.records.has(r.id))continue;let e=this.clampTime(r.time),i={x:r.x,y:r.y,time:e},a={id:r.id,pointerType:r.pointerType,phase:`began`,x:r.x,y:r.y,time:e,startX:r.x,startY:r.y,startTime:e,samples:[...r.history??[],i],target:r.target,scroll:r.scroll??null,takenByBrowser:!1,...r.scrollType==null?{}:{scrollType:r.scrollType}},o=[];for(let[e,n]of r.recognizers.entries()){if(!w(n).wantsTouch(a))continue;if(o.push(n),w(n).arena=this,!this.active.includes(n)){let t=this.active.findIndex(t=>r.recognizers.indexOf(t)>e);t===-1?this.active.push(n):this.active.splice(t,0,n)}let i=t.get(n)??[];i.push(a),t.set(n,i)}let s={touch:a,participants:o,consumer:r.consumer??null,view:`none`,isLifted:!1,isClaimed:!1,suppressClick:!1,deferredClick:!1};this.records.set(r.id,s),n.push(s)}let r=this.context();for(let e of[...this.active]){let n=t.get(e);n!=null&&w(e).deliverBegan(n,r)}for(let e of[...this.active]){let i=t.get(e),a=n.map(e=>e.touch).filter(e=>i==null||!i.includes(e));a.length>0&&e.numberOfTouches>0&&w(e).deliverBeganElsewhere(a,r)}for(let e of n)this.deliverViewBegan(e)})}untrackedBegan(e){this.active.some(e=>e.numberOfTouches>0)&&this.run(e.time,()=>{let t=this.clampTime(e.time),n={id:e.id,pointerType:e.pointerType,phase:`began`,x:e.x,y:e.y,time:t,startX:e.x,startY:e.y,startTime:t,samples:[{x:e.x,y:e.y,time:t}],target:e.target,scroll:e.scroll??null,takenByBrowser:!1},r=this.context();for(let e of[...this.active])e.numberOfTouches>0&&w(e).deliverBeganElsewhere([n],r)})}moved(e){e.length!==0&&this.run(e[0].time,()=>{let t=this.update(e,`moved`);if(t.length===0)return;let n=this.context(),r=this.movingIds;this.movingIds=new Set(t.map(e=>e.id));try{for(let e of[...this.active])w(e).deliverMoved(t,n)}finally{this.movingIds=r}for(let e of t){let t=this.records.get(e.id);t?.view===`delivered`&&t.consumer?.touchMoved(e)}})}ended(e){let t=new Map;return e.length===0||this.run(e[0].time,()=>{let n=this.update(e,`ended`),r=this.context();for(let e of[...this.active])w(e).deliverEnded(n,r);this.reviewPending();for(let e of n){let n=this.records.get(e.id);n!=null&&(n.isLifted=!0,t.set(e.id,this.resolveEnd(n)))}}),t}cancelled(e,t){this.run(t,()=>{let t=this.liveTouches(e);for(let e of t)e.phase=`cancelled`;let n=this.context();for(let e of[...this.active])w(e).deliverCancelled(t,n);for(let e of t){let t=this.records.get(e.id);t!=null&&(t.isLifted=!0,t.suppressClick=!0,this.cancelView(t))}})}browserTookOver(e,t){this.run(t,()=>{let t=this.liveTouches(e).filter(e=>!e.takenByBrowser);if(t.length===0)return;for(let e of t)e.takenByBrowser=!0;let n=this.context();for(let e of[...this.active])w(e).deliverTakenByBrowser(t,n);for(let e of t){let t=this.records.get(e.id);t!=null&&(t.suppressClick=!0,this.cancelView(t))}})}advanceTime(e){this.run(e,()=>{})}requestTransition(e,t){let n=e.state;t===`failed`?this.fail(e):(w(e).pending==null||t!==`began`&&t!==`ended`)&&(n===`possible`&&(t===`began`||t===`ended`)?this.attemptRecognition(e,t):C(n)&&(t===`changed`||t===`ended`)?this.apply(e,t):C(n)&&t===`cancelled`&&this.apply(e,`cancelled`))}setTimer(e,t,n){this.timers.set(e,{deadline:t,callback:n}),this.scheduleRealTimer()}clearTimer(e){this.timers.delete(e)&&this.scheduleRealTimer()}deferResolution(e){this.deferDepth+=1;try{e()}finally{--this.deferDepth}this.deferDepth===0&&this.owesResolution&&queueMicrotask(()=>{this.owesResolution&&this.deferDepth===0&&this.run(this.lastEventTime(),()=>{})})}lastEventTime(){return Number.isFinite(this.latestTime)?this.latestTime:this.clock.now()}stop(e){let t=this.currentTime??(Number.isFinite(this.latestTime)?this.latestTime:this.clock.now());this.run(t,()=>{C(e.state)?this.apply(e,`cancelled`):e.state===`possible`&&e.isInvolved()&&this.fail(e)})}attemptRecognition(e,t){if(!w(e).shouldBegin()||this.isVetoedByConsumer(e)||this.isRefusedByBrowser(e)){this.fail(e);return}let n=!1;for(let t of this.active)if(t!==e&&w(e).requiresFailureOf(t)&&t.state!==`failed`){if(t.state!==`possible`){this.fail(e);return}t.isInvolved()&&(n=!0)}if(n)w(e).pending=t,this.claim(e);else{for(let t of this.active)if(t!==e&&(C(t.state)||t.state===`ended`&&t.trackedTouches.length>0)&&this.conflicts(t,e)){this.fail(e);return}this.apply(e,t);for(let t of[...this.active])t!==e&&t.state===`possible`&&(w(t).requiresFailureOf(e)||this.conflicts(e,t))&&this.fail(t);this.claim(e),e.claimsTouches&&e.cancelsTouchesInView&&this.cancelViewTouchesOf(e)}}conflicts(e,t){return!ye(e,t)||w(e).allowsSimultaneous(t)||!e.claimsTouches||!t.claimsTouches?!1:e.canPrevent(t)&&t.canBePrevented(e)}isRefusedByBrowser(e){let t=this.options.refusesClaim;return t==null||!e.claimsTouches?!1:e.trackedTouches.some(e=>e.phase!==`ended`&&e.phase!==`cancelled`&&t(e))}isVetoedByConsumer(e){for(let t of w(e).seenTouchIds)if((this.records.get(t)?.consumer)?.allowsAncestorRecognizer?.(e)===!1)return!0;return!1}fail(e){S(e.state)||(C(e.state)?this.apply(e,`cancelled`):(w(e).pending=null,this.apply(e,`failed`),this.reviewPending()))}releaseClaim(e,t=new Set){let n=[];for(let r of e.trackedTouches){let i=this.records.get(r.id);i!=null&&i.isClaimed&&!t.has(r.id)&&(this.active.some(t=>t!==e&&t.claimsTouches&&(C(t.state)||t.state===`ended`||w(t).pending!=null)&&t.trackedTouches.some(e=>e.id===r.id))||(i.isClaimed=!1,n.push(r.id)))}n.length>0&&this.options.onRelease?.(n)}apply(e,t){let n=e.state;w(e).applyState(t),(e.state===t&&n!==t||t===`changed`&&n===`changed`)&&this.options.onTransition?.(e,n,t),S(t)&&this.clearTimer(e),t===`cancelled`?this.releaseClaim(e,this.movingIds):t===`failed`&&this.releaseClaim(e)}reviewPending(){if(this.deferDepth>0){this.owesResolution=!0;return}let e=!0;for(;e;){e=!1;for(let t of[...this.active]){let n=w(t).pending;n!=null&&t.state===`possible`&&(this.active.some(e=>e!==t&&w(t).requiresFailureOf(e)&&e.state===`possible`&&e.isInvolved())||(w(t).pending=null,this.attemptRecognition(t,n),e=!0))}}}claim(e){if(!e.claimsTouches)return;let t=[];for(let n of e.trackedTouches){let e=this.records.get(n.id);e!=null&&!e.isLifted&&!e.isClaimed&&!e.touch.takenByBrowser&&(e.isClaimed=!0,t.push(n.id))}t.length>0&&this.options.onClaim?.(t,e)}deliverViewBegan(e){e.consumer!=null&&e.view===`none`&&(e.suppressClick?e.view=`done`:this.beginDelayers(e)?e.view=`held`:(e.view=`delivered`,e.consumer.touchBegan(e.touch)))}resolveEnd(e){if(e.suppressClick)return`suppress`;let t=this.endDelayers(e);switch(e.view){case`delivered`:return t?(e.view=`endHeld`,e.deferredClick=!0,`defer`):(e.view=`done`,e.consumer?.touchEnded(e.touch),`allow`);case`held`:return this.beginDelayers(e)?(e.deferredClick=!0,`defer`):(e.view=`delivered`,e.consumer?.touchBegan(e.touch),this.resolveEnd(e));case`none`:case`endHeld`:case`done`:return t?(e.deferredClick=!0,`defer`):`allow`}}reviewHeld(){for(let e of this.records.values())e.view===`held`&&!this.beginDelayers(e)&&(e.suppressClick?e.view=`done`:(e.view=`delivered`,e.consumer?.touchBegan(e.touch),e.isLifted&&!this.endDelayers(e)?(e.view=`done`,e.consumer?.touchEnded(e.touch)):e.isLifted&&(e.view=`endHeld`))),e.view===`endHeld`&&!this.endDelayers(e)&&(e.view=`done`,e.suppressClick?e.consumer?.touchCancelled(e.touch):e.consumer?.touchEnded(e.touch)),e.deferredClick&&e.view!==`held`&&e.view!==`endHeld`&&!this.endDelayers(e)&&(e.deferredClick=!1,this.options.onDeferredClick?.(e.touch,!e.suppressClick))}beginDelayers(e){return e.participants.some(t=>t.delaysTouchesBegan&&t.state===`possible`&&t.isInvolved()&&w(t).seenTouchIds.has(e.touch.id))}endDelayers(e){return e.participants.some(t=>t.delaysTouchesEnded&&t.state===`possible`&&t.isInvolved()&&w(t).seenTouchIds.has(e.touch.id))}cancelViewTouchesOf(e){for(let t of w(e).seenTouchIds){let e=this.records.get(t);e!=null&&(e.suppressClick=!0,this.cancelView(e))}}cancelView(e){(e.view===`delivered`||e.view===`endHeld`)&&e.consumer?.touchCancelled(e.touch),(e.view!==`none`||e.consumer!=null)&&(e.view=`done`)}context(){return{time:this.now(),allTouches:[...this.records.values()].filter(e=>!e.isLifted).map(e=>e.touch)}}liveTouches(e){let t=[];for(let n of e){let e=this.records.get(n);e!=null&&!e.isLifted&&t.push(e.touch)}return t}update(e,t){let n=[];for(let r of e){let e=this.records.get(r.id);if(e==null||e.isLifted)continue;let i=this.clampTime(r.time),a=e.touch;a.samples=[...(r.history??[]).filter(e=>e.time>a.time&&e.time<i),{x:r.x,y:r.y,time:i}],a.x=r.x,a.y=r.y,a.time=i,a.phase=t,n.push(a)}return n}clampTime(e){let t=Math.max(e,this.latestTime);return this.latestTime=t,t}run(e,t){this.depth+=1;try{this.depth===1&&this.deferDepth===0&&this.owesResolution&&(this.owesResolution=!1,this.currentTime=this.clampTime(this.lastEventTime()),this.settle()),this.flushTimers(e),this.currentTime=this.clampTime(e),t(),this.depth===1&&(this.deferDepth>0?this.owesResolution=!0:(this.owesResolution=!1,this.settle()))}finally{--this.depth,this.depth===0&&(this.currentTime=null)}}flushTimers(e){for(;;){let t=null;for(let n of this.timers)n[1].deadline<=e&&(t==null||n[1].deadline<t[1].deadline||n[1].deadline===t[1].deadline&&this.rank(n[0])<this.rank(t[0]))&&(t=n);if(t==null)break;let[n,r]=t;this.timers.delete(n),this.currentTime=this.clampTime(r.deadline),r.callback(),this.depth<=1&&this.settle()}this.scheduleRealTimer()}rank(e){let t=this.active.indexOf(e);return t===-1?1/0:t}settle(){this.reviewPending(),this.reviewHeld();let e=!1;for(let t of[...this.active]){if(!(S(t.state)&&t.numberOfTouches===0||t.state===`possible`&&!t.isInvolved()))continue;this.active=this.active.filter(e=>e!==t);let n=t.state;w(t).resetToPossible(),e=!0,n!==`possible`&&this.options.onTransition?.(t,n,`possible`)}e&&this.reviewHeld();let t=!1;for(let[e,n]of this.records)n.isLifted&&n.view!==`held`&&n.view!==`endHeld`&&!n.deferredClick&&(this.records.delete(e),t=!0);t&&this.records.size===0&&this.options.onIdle?.()}scheduleRealTimer(){let e=1/0;for(let t of this.timers.values())e=Math.min(e,t.deadline);if(e===this.realTimerDeadline||(this.realTimer!=null&&(this.clock.clearTimeout(this.realTimer),this.realTimer=null),this.realTimerDeadline=e,e===1/0))return;let t=Math.max(0,e-this.clock.now()),n=t=>{this.realTimer=null,this.realTimerDeadline=1/0,t&&this.clock.now()>e?(this.realTimerDeadline=e,this.realTimer=this.clock.setTimeout(()=>n(!1),0)):this.advanceTime(e)};this.realTimer=this.clock.setTimeout(()=>n(!0),t)}};function ye(e,t){for(let n of w(e).seenTouchIds)if(w(t).seenTouchIds.has(n))return!0;return!1}function be(e){let t=e.trim().split(/\s+/);return t.includes(`auto`)||t.includes(`manipulation`)?{x:!0,y:!0}:t.includes(`none`)?{x:!1,y:!1}:{x:t.some(e=>e===`pan-x`||e===`pan-left`||e===`pan-right`),y:t.some(e=>e===`pan-y`||e===`pan-up`||e===`pan-down`)}}var T=new Set([`auto`,`scroll`,`overlay`]),E=1;function xe(e,t){let n=e.ownerDocument,r=n.defaultView;if(r==null)return{entries:[],allowsPan:!1};let i=n.scrollingElement??n.documentElement,a=[],s=!0,c=!0,l=!1,u=!1;for(let f=e;f!=null;f=d(f)){if(!(f instanceof Element))continue;let e=r.getComputedStyle(f);if(t){let t=be(e.touchAction||`auto`);s&&=t.x,c&&=t.y}let d=f===i||f===n.documentElement;d&&(l=!0);let p=d?D(n,`x`):e.overflowX,m=d?D(n,`y`):e.overflowY,h=T.has(p),g=T.has(m);if(h||g){let t=d?i:f,[n,r]=Se(e);a.push({element:t,x:h&&s,y:g&&c,isRtl:o(t),stopsX:n!==`auto`,stopsY:r!==`auto`,isBeyondFixed:u})}if(d)break;e.position===`fixed`&&(u=!0)}return!l&&i instanceof Element&&a.push({element:i,x:s&&T.has(D(n,`x`)),y:c&&T.has(D(n,`y`)),isRtl:!1,stopsX:!1,stopsY:!1,isBeyondFixed:u}),{entries:a,allowsPan:s||c}}function Se(e){let t=e.overscrollBehaviorX,n=e.overscrollBehaviorY;if(t!==``&&n!==``&&t!=null&&n!=null)return[t,n];let[r=`auto`,i=r]=(e.getPropertyValue(`overscroll-behavior`)||`auto`).trim().split(/\s+/);return[t||r,n||i]}function D(e,t){let n=e.defaultView;if(n==null)return`hidden`;for(let r of[e.documentElement,e.body]){if(r==null)continue;let e=n.getComputedStyle(r),i=t===`x`?e.overflowX:e.overflowY;if(i===`hidden`||i===`clip`)return`hidden`}return`auto`}function O(e,t){return e.scrollHeight-e.clientHeight<=E?!1:t>0?e.scrollTop>.5:e.scrollTop<e.scrollHeight-e.clientHeight-E+.5}function k(e,t){let{element:n}=e,r=n.scrollWidth-n.clientWidth;if(r<=E)return!1;let i=e.isRtl?-r:0,a=e.isRtl?0:r;return t>0?n.scrollLeft>i+E-.5:n.scrollLeft<a-E+.5}function Ce(e,t,n){let r=e.ownerDocument.defaultView;if(r==null)return!1;let i=r.getComputedStyle(e);return n!==0&&T.has(i.overflowY)&&O(e,n)?!0:t!==0&&T.has(i.overflowX)&&k({element:e,isRtl:o(e)},t)}function A(e,{readsTouchAction:t=!0}={}){let n=null,r=()=>(n??=e instanceof Element?xe(e,t):{entries:[],allowsPan:!1},n.entries);return{canScroll(e,t){let n=Math.abs(e),i=Math.abs(t),a=n>0&&n>=i/2,o=i>0&&i>=n/2;for(let n of r()){if(o&&n.y&&O(n.element,t)||a&&n.x&&k(n,e))return!0;if((!a||n.stopsX)&&(!o||n.stopsY)&&(n.stopsX||n.stopsY))return!1}return!1},get allowsNativePan(){return r(),n?.allowsPan===!0},get isInsideScroller(){return r().some(e=>!e.isBeyondFixed&&(e.y&&e.element.scrollHeight-e.element.clientHeight>E||e.x&&e.element.scrollWidth-e.element.clientWidth>E))}}}var we=50,Te=1.5,Ee=4,De=.8;function Oe(e){return e<=Te}var ke=class{gesture=0;phase=`finger`;last=-1/0;previous=0;sign=0;count=0;run=0;runStart=0;push(e,t,n){let r=Math.abs(t),i=Math.sign(t),a=e-this.last,o=this.count>0&&Oe(a),s=null;this.count===0?s=this.gesture===0?`first`:`idle`:this.phase===`finger`&&a>=n?s=`idle`:this.phase===`momentum`&&(i!==0&&this.sign!==0&&i!==this.sign?s=`reversal`:a>=we?s=`gap`:!o&&r>=2&&r>this.previous*1.3+.5&&(s=`jump`));let c=s==null&&o&&this.previous>0?Math.max(1,Math.round(r/this.previous)):1;s!=null&&(this.gesture+=1,this.phase=`finger`,this.count=0,this.run=0);let l=!1,u=!1;if(this.phase===`finger`&&this.count>=3&&r>0){let e=r/c;u=e<=this.previous*.995&&e>=this.previous*.5,u?(this.run===0&&(this.runStart=this.previous),this.run+=1):this.run=0,this.run>=Ee&&e<=this.runStart*De&&(this.phase=`momentum`,l=!0)}return this.count+=1,this.previous=r/c,i!==0&&(this.sign=i),this.last=e,{boundary:s,phase:this.phase,gesture:this.gesture,liftNow:l,decaying:u&&!l,bunched:s==null&&o}}end(){this.count=0}};function Ae(e){let t=!0,n=!0,r=!0,i=!0;for(let a of e){if(!w(a).acceptsTouchInput||!a.claimsTouches)continue;let e=a.nativeTouchBehavior;t&&=e.panX,n&&=e.panY,r&&=e.pinchZoom,i&&=e.doubleTapZoom}return{panX:t,panY:n,pinchZoom:r,doubleTapZoom:i}}function je(e){let t=Ae(e);if(t.panX&&t.panY&&t.pinchZoom&&t.doubleTapZoom)return null;if(t.panX&&t.panY&&t.pinchZoom)return`manipulation`;let n=[];return t.panX&&n.push(`pan-x`),t.panY&&n.push(`pan-y`),t.pinchZoom&&n.push(`pinch-zoom`),n.length===0?`none`:n.join(` `)}function Me(e){let t={},n=je(e);return n!=null&&(t.touchAction=n),t}var j=[`pan-left`,`pan-right`,`pan-up`,`pan-down`,`pinch-zoom`];function M(e){let t=e.trim().split(/\s+/).filter(e=>e!==``),n=new Set;t.length===0&&t.push(`auto`);for(let e of t)e===`auto`?(j.forEach(e=>n.add(e)),n.add(`double-tap-zoom`)):e===`manipulation`?j.forEach(e=>n.add(e)):e===`pan-x`?n.add(`pan-left`).add(`pan-right`):e===`pan-y`?n.add(`pan-up`).add(`pan-down`):j.includes(e)&&n.add(e);return n}function Ne(e,t){let n=M(t),r=new Set([...M(e)].filter(e=>n.has(e)));if(j.every(e=>r.has(e)))return r.has(`double-tap-zoom`)?`auto`:`manipulation`;let i=[];for(let[e,t,n]of[[`pan-x`,`pan-left`,`pan-right`],[`pan-y`,`pan-up`,`pan-down`]])r.has(t)&&r.has(n)?i.push(e):r.has(t)?i.push(t):r.has(n)&&i.push(n);return r.has(`pinch-zoom`)&&i.push(`pinch-zoom`),i.length===0?`none`:i.join(` `)}var N=`data-astryx-touch-action`,Pe=`reset`,P=new WeakMap,F=new WeakMap;function Fe(e){let t=P.get(e);if(t==null){let n=e.nodeType===9?e:e.ownerDocument,r,i,a=n?.defaultView?.CSSStyleSheet;if(typeof a==`function`&&`replaceSync`in a.prototype&&`adoptedStyleSheets`in e){let t=new a;e.adoptedStyleSheets=[...e.adoptedStyleSheets,t],r=e=>t.replaceSync(e),i=()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==t)}}else{let t=n?.createElement(`style`),a=e.nodeType===9?n?.head??n?.documentElement:e;t!=null&&a!=null&&(a.append(t),r=e=>{t.textContent=e},i=()=>t.remove())}if(r==null||i==null)return null;t={values:new Set,marked:new Set,css:``,write:r,remove:i},P.set(e,t)}return t}function Ie(e,t){let n=e.getRootNode(),r=e.isConnected&&(n.nodeType===9||`host`in n)?Fe(n):null;if(r==null)return!1;r.values.has(t)||(r.values.add(t),r.css+=`:where([${N}="${t}"]){touch-action:${t}}`,r.write(`@layer ${Pe}{${r.css}}`)),e.getAttribute(`data-astryx-touch-action`)!==t&&e.setAttribute(N,t);let i=F.get(e);return i!=null&&i!==n&&Le(e,i),r.marked.add(e),F.set(e,n),!0}function Le(e,t){let n=P.get(t);n!=null&&(n.marked.delete(e),n.marked.size===0&&(n.remove(),P.delete(t)))}function Re(e){e.removeAttribute(N);let t=F.get(e);t!=null&&(F.delete(e),Le(e,t))}function I(e){return e.button===0&&!(e.ctrlKey&&u())}var ze=[`-webkit-touch-callout`,`-webkit-user-select`,`user-select`],Be=new Set([`text`,`search`,`email`,`url`,`tel`,`password`,`number`]);function Ve(e){return e!==`mouse`}var L=new WeakMap;function He(e,t){let n=new Set(e);if(ot(t)&&[...n].some(e=>p(e,t))&&n.add(t),!r()){let e=e=>{z(e.target)||e.preventDefault()};for(let t of n)t.addEventListener(`selectstart`,e);let t=!0;return()=>{if(t){t=!1;for(let t of n)t.removeEventListener(`selectstart`,e)}}}return at(n)}function Ue(e,t,r,i){let a=t?.document??null,o=nt(r),s=()=>{let e=t?.getSelection();if(e==null||z(it(a)))return;let n=Ye(e,o);r.length===0?n.some(e=>!e.collapsed)&&e.removeAllRanges():!$e(n,r)&&r.every(Ze)&&et(e,r)};s();let c=new Set(e),l=e=>{z(e.target)||e.preventDefault()};for(let e of c)e.addEventListener(`selectstart`,l);let u=t==null?[]:[n(t,`selectstart`,l,{cancels:!0}),n(t,`selectionchange`,s)],d=at(c),f=`held`,p=null,m=()=>{if(f!==`done`){f=`done`,p!=null&&(t?.clearTimeout(p),p=null);try{s()}finally{for(let e of u)e();i?.()}}};return({isCancel:e=!1}={})=>{if(f===`held`){f=`lifted`;for(let e of c)e.removeEventListener(`selectstart`,l);d(),t==null||e?m():p=t.setTimeout(m,0)}else f===`lifted`&&e&&m()}}function We(e){let t=e?.getSelection();if(t==null)return[];let n=tt(t,[]);if(n!=null)return n.filter(e=>!e.collapsed).map(Xe);if(t.isCollapsed)return[];let r=[];for(let e=0;e<t.rangeCount;e++)r.push(t.getRangeAt(e).cloneRange());return r}function Ge(e,t,n,r){if(z(r))return!0;let i=qe(e,t,n,[...rt(r),...R(r)]);if(i==null)return!1;let{node:a,offset:o}=i;if(a.nodeType!==3||(a.textContent??``).trim()===``)return!1;let s=a.parentElement??(a.parentNode?.nodeType===11?a.parentNode.host:null);if(s==null||!Je(s)||Ke(a))return!1;let c=(a.textContent??``).length,l=e.createRange();if(typeof l.getClientRects!=`function`)return!1;for(let e of[o-1,o])if(!(e<0||e>=c)){l.setStart(a,e),l.setEnd(a,e+1);for(let e of Array.from(l.getClientRects()))if(t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom)return!0}return!1}function Ke(e){for(let t=e;t!=null;t=d(t))if(t.nodeType===1&&t.localName===`button`)return!0;return!1}function qe(e,t,n,r){let i=e;if(typeof i.caretPositionFromPoint==`function`){let e=r.length>0?i.caretPositionFromPoint(t,n,{shadowRoots:[...r]}):i.caretPositionFromPoint(t,n);return e==null?null:{node:e.offsetNode,offset:e.offset}}if(typeof i.caretRangeFromPoint==`function`){let e=i.caretRangeFromPoint(t,n);return e==null?null:{node:e.startContainer,offset:e.startOffset}}return null}function Je(e){let t=e.ownerDocument.defaultView?.getComputedStyle(e);return t!=null&&t.getPropertyValue(`user-select`)!==`none`&&t.getPropertyValue(`-webkit-user-select`)!==`none`}function Ye(e,t){let n=tt(e,t);if(n!=null)return n;let r=[];for(let t=0;t<e.rangeCount;t++)r.push(e.getRangeAt(t));return r}function Xe(e){let t=e.startContainer.ownerDocument?.createRange();return t==null||e.startContainer.getRootNode()!==e.endContainer.getRootNode()?e:(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),t)}function Ze(e){return Qe(e.startContainer,e.startOffset)&&Qe(e.endContainer,e.endOffset)}function Qe(e,t){let n=e.nodeType===3||e.nodeType===4||e.nodeType===8?e.length:e.childNodes.length;return e.isConnected&&t>=0&&t<=n}function $e(e,t){return e.length===t.length&&t.every((t,n)=>{let r=e[n];return r.startContainer===t.startContainer&&r.startOffset===t.startOffset&&r.endContainer===t.endContainer&&r.endOffset===t.endOffset})}function et(e,t){let[n]=t;if(t.length===1&&typeof e.setBaseAndExtent==`function`)e.setBaseAndExtent(n.startContainer,n.startOffset,n.endContainer,n.endOffset);else{e.removeAllRanges();for(let n of t){let t=n.startContainer.ownerDocument?.createRange();t!=null&&(t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset),e.addRange(t))}}}function tt(e,t){let n=e.getComposedRanges;if(typeof n!=`function`)return null;let r=t=>{try{return n.call(e,{shadowRoots:t})}catch{try{return n.call(e,...t)}catch{return null}}},i=[...t];for(;;){let e=r([...i]);if(e==null)return null;let t=new Set;for(let n of e)for(let[e,r]of[[n.startContainer,n.startOffset],[n.endContainer,n.endOffset]])for(let n of[e.childNodes[r],e.childNodes[r-1]]){let e=n?.nodeType===1?n.shadowRoot:null;e!=null&&!i.includes(e)&&t.add(e)}if(t.size===0)return e;i.push(...t)}}function nt(e){let t=new Set;for(let n of e)for(let e of[...R(n.startContainer),...R(n.endContainer)])t.add(e);return[...t]}function rt(e){let t=e?.nodeType===1?e.shadowRoot:null;return t==null?[]:[t]}function R(e){let t=[],n=e!=null&&typeof e.nodeType==`number`?e.getRootNode():null;for(;n!=null&&n.nodeType===11;){let e=n.host;if(e==null)break;n.mode===`open`&&t.push(n),n=e.getRootNode()}return t}function it(e){let t=e?.activeElement??null;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function at(e){let t=[];for(let n of e){let e=st(n);if(e==null)continue;t.push(n);let r=L.get(n);if(r!=null)r.count+=1;else{L.set(n,{count:1,saved:ze.map(t=>({name:t,value:e.getPropertyValue(t),priority:e.getPropertyPriority(t)}))});for(let t of ze)e.setProperty(t,`none`)}}let n=!1;return()=>{if(!n){n=!0;for(let e of t){let t=L.get(e);if(t==null||--t.count>0)continue;L.delete(e);let n=st(e);for(let{name:e,value:r,priority:i}of t.saved)r===``?n?.removeProperty(e):n?.setProperty(e,r,i)}}}}function ot(e){return e instanceof Element&&e.localName===`input`&&!Be.has(e.type)}function z(e){let t=e instanceof Element?e:e instanceof Node?e.parentElement:null;return t==null?!1:t.localName===`textarea`?!0:t.localName===`input`?Be.has(t.type):t.isContentEditable}function st(e){let t=e.style;return t instanceof Object?t:null}var ct=new WeakMap,B={touchAction:`touch-action`,WebkitTouchCallout:`-webkit-touch-callout`,WebkitUserSelect:`-webkit-user-select`,userSelect:`user-select`};function lt(e){return ut.has(e.trim().toLowerCase())}var ut=new Set([`initial`,`inherit`,`unset`,`revert`,`revert-layer`]);function dt(e,t){if(e!=null&&typeof e.requestAnimationFrame==`function`){let n=e.requestAnimationFrame(t);return()=>e.cancelAnimationFrame(n)}let n=setTimeout(t,0);return()=>clearTimeout(n)}var ft={capture:!0,passive:!0};function V(e){return e.claimsTouches&&w(e).acceptsTouchInput&&w(e).family!==`tap`}function pt(e){let t=e.allowedPointerTypes;return t==null||t.has(`touch`)||t.has(`pen`)}function mt(e){return w(e).family===`pan`}function H(e){return e.kind===`screenEdgePan`?e:null}function ht(e){return Y(e.changedTouches).some(e=>e.touchType===`stylus`)}var U=500,gt=8;function W(e,t){return e.target===t.target&&Math.abs(e.x-t.x)<=1&&Math.abs(e.y-t.y)<=1}function _t(e){return e===`touch`||e===`mouse`||e===`pen`}function G(e,t=e.target){return t===e.target?e.composedPath()[0]??t:t}var vt=100,yt=180,bt=220,xt=40,St=100;function Ct(e,t,n){return e===`pinch`||t!==`continuous`?vt:n?bt:yt}function wt(e,t){return Math.sign(e)*Math.max(0,Math.abs(e)-Math.abs(t)/2)}function Tt(e,t,n){e.readSpan<=0||(e.speedX=K(e.speedX,(t-e.readFromX)/e.readSpan,e.priorSpeedX),e.speedY=K(e.speedY,(n-e.readFromY)/e.readSpan,e.priorSpeedY))}function K(e,t,n){let r=Math.sign(t)*Math.min(Math.abs(t),Math.abs(n));return r*e>=0&&Math.abs(r)>Math.abs(e)?r:e}function Et(e,t,n){return n===0||(t-e)*Math.sign(n)>0?t:e}function Dt(e,t){return e.deltaMode===1?{dx:e.deltaX*xt,dy:e.deltaY*xt}:e.deltaMode===2?{dx:e.deltaX*(t?.innerWidth??0),dy:e.deltaY*(t?.innerHeight??0)}:{dx:e.deltaX,dy:e.deltaY}}function q(e){if(e.deltaMode!==0||e.shiftKey)return`discrete`;let t=e=>{let t=Math.abs(e-Math.round(e));return t>0&&t<.01};if(t(e.deltaX)||t(e.deltaY))return`discrete`;let n=e;if(typeof n.wheelDeltaY!=`number`||typeof n.wheelDeltaX!=`number`)return`discrete`;let r=(e,t)=>e===0?t===0:Math.abs(Math.abs(t)-3*Math.abs(e))<=Math.max(1.5,.05*Math.abs(e)*3);if(!r(e.deltaY,n.wheelDeltaY)||!r(e.deltaX,n.wheelDeltaX))return`discrete`;let i=(e,t)=>t!==0&&t%120==0&&e%40==0;return i(e.deltaY,n.wheelDeltaY)||i(e.deltaX,n.wheelDeltaX)?`discrete`:`continuous`}function Ot(e){return e.scrollEdge===!0}function kt(e,t,n){return(w(e).classify?.({x:t,y:n})??`begin`)===`begin`}function J(e){let t=e.timeStamp;return t>0xe8d4a51000&&typeof performance<`u`&&performance.timeOrigin>0?t-performance.timeOrigin:t}function Y(e){return e==null?[]:Array.from(e)}var At=class{registry=new Map;stopWatchingMovers=null;stopBlockingForMovers=null;pendingCallerReads=new Set;isCallerReadScheduled=!1;cancelCallerRead=null;lockedBy=new Map;pressSelections=new Map;selectingContacts=new Set;dragHolds=new Set;claimHolds=new Map;retargeted=new Map;touchIds=new Map;cancelledFingers=new Set;cancelledPointers=new Map;touchTargets=new Map;watched=new Map;blockingFingers=new Set;claimingFingers=new Set;processed=new WeakSet;pointerIds=new Map;pointerKinds=new Map;layoutWatched=new Set;layoutObserver=null;judgedUncancelable=new Set;fingerPointers=new Map;pendingPointers=new Map;claimedLifts=[];claimedLiftTimer=null;unpairedTouches=new Map;lastFed=new Map;pointerFed=new Set;lastTouch=null;ownedScrolls=new Map;ownScrollCalls=0;ownScrollFrames=new Map;lastScroll=null;touchGates=new Set;retainers=0;fingerListeners=new Set;fingerTargets=[];nextId=1;wheel=null;stopWheelLatch=null;segmenter=new ke;wheelSegment=null;wheelsSeen=new WeakSet;isInstalled=!1;isCoarse=!1;stopWatchingPointer=null;unsubscribers=[];armedElements=new Map;isArmedPress=!1;isClaimingInstalled=!1;claimingUnsubscribers=[];usesTouchEvents=!0;constructor(e,n={}){this.doc=e,this.inputMode=n.inputMode??`auto`,this.presentedHitTesting=n.presentedHitTesting??`auto`;let r={viewportSize:()=>({width:e.defaultView?.innerWidth??0,height:e.defaultView?.innerHeight??0}),isRtl:e=>e instanceof Element&&o(e),viewRect:e=>{if(!(e instanceof Element))return null;let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}};this.clock=n.clock??_e,this.arena=new ve({clock:this.clock,environment:r,onDeferredClick:(e,t)=>this.replayClick(e,t),onIdle:()=>this.releaseArmedPress(),onTransition:n.onTransition,onClaim:(e,t)=>this.lockClaimedDrags(e,t),onRelease:e=>this.releaseClaimedDrags(e),refusesClaim:e=>this.selectingContacts.has(e.id)&&(e.x!==e.startX||e.y!==e.startY)});let i=e.defaultView;this.followsPointer=n.isPrimaryPointerCoarse==null,this.isPrimaryPointerCoarse=n.isPrimaryPointerCoarse??(()=>t(i))}attach(e,t,n={}){let r=this.registrationFor(e);r.manageStyle=n.manageStyle??r.manageStyle;let i=n.actionGroup===!0;i&&(r.actionGroupAsks+=1,r.actionGroup=!0),t.view=e,r.recognizers.push(t),t.onEnabledChange=()=>{this.refresh(e,r),this.syncListeners()};let a=H(t);return a!=null&&(a.onTouchBehaviorChange=()=>{this.refresh(e,r),this.syncLayoutWatch()}),this.refresh(e,r),this.syncListeners(),()=>{t.onEnabledChange=null,i&&(--r.actionGroupAsks,r.actionGroup=r.actionGroupAsks>0),a!=null&&(a.onTouchBehaviorChange=null);let n=r.recognizers.indexOf(t);n>=0&&r.recognizers.splice(n,1),(t.state!==`possible`||t.isInvolved())&&t.cancel();let o=this.wheel;o!=null&&o.takers.includes(t)&&!this.wheelHasTaker(o)&&this.endWheel(o.last),this.refresh(e,r),this.syncListeners(),this.cleanup(e,r)}}syncLayoutWatch(){let e=new Set,t=!1;for(let[n,r]of this.registry)for(let i of r.recognizers){let r=H(i);r!=null&&r.isEnabled&&(e.add(n),t||=r.watchesViewport)}t&&e.add(this.doc.documentElement);for(let t of[...this.layoutWatched])e.has(t)||(this.layoutObserver?.unobserve(t),this.layoutWatched.delete(t));if(e.size===0){this.layoutObserver?.disconnect(),this.layoutObserver=null;return}let n=this.doc.defaultView;if(this.layoutObserver==null&&n!=null&&typeof n.ResizeObserver==`function`){this.layoutObserver=new n.ResizeObserver(this.onLayoutChange);for(let e of this.layoutWatched)this.layoutObserver.observe(e)}for(let t of e)this.layoutWatched.has(t)||(this.layoutObserver?.observe(t),this.layoutWatched.add(t))}onLayoutChange=()=>{for(let e of this.registry.values())for(let t of e.recognizers){let e=H(t);e!=null&&e.isEnabled&&e.layoutChanged()}};attachConsumer(e,t,n={}){let r=this.registrationFor(e);return r.consumer=t,this.refresh(e,r),this.syncListeners(),()=>{r.consumer===t&&(r.consumer=null),this.refresh(e,r),this.syncListeners(),this.cleanup(e,r)}}get document(){return this.doc}isTouchClaimed(e){let t=this.touchIds.get(e);return t!=null&&this.arena.isClaimed(t)}presentedRect(e){let t=e.getBoundingClientRect();if(!this.hitTestsLayout())return t;let{x:n,y:r}=g(e);return n===0&&r===0?t:{left:t.left+n,top:t.top+r,right:t.right+n,bottom:t.bottom+r}}hitTestsLayout(){return this.presentedHitTesting===`always`||this.presentedHitTesting===`auto`&&r(this.doc.defaultView)}presentedTarget(e,t,n,r){if(!this.hitTestsLayout())return e;let i=f().filter(e=>{if(!e.isConnected||e.ownerDocument!==this.doc)return!1;let{x:t,y:n}=g(e);return Math.abs(t)>=.5||Math.abs(n)>=.5});if(i.length===0)return e;h(i);let a=this.drawnAt(t,n),o=(this.doc.defaultView?.performance.now()??r)-r;if(o>0&&o<1e3){let e=e=>{let t=g(e,r);return Math.abs(t.x)>=.5||Math.abs(t.y)>=.5?t:null},o=a,s=o==null?void 0:i.find(e=>p(e,o)),c=!1;for(let r of i){let i=e(r);if(i==null)continue;let o=this.drawnAt(t-i.x,n-i.y);if(o!=null&&p(r,o)){a=o,c=!0;break}}!c&&s!=null&&e(s)!=null&&(a=this.drawnBeneath(t,n,i))}if(a==null||a===e)return e;let s=a,c=e instanceof Node?e:null;return i.some(e=>p(e,s)||c!=null&&p(e,c))?s:e}drawnBeneath(e,t,n){return typeof this.doc.elementsFromPoint==`function`?this.doc.elementsFromPoint(e,t).find(e=>!n.some(t=>p(t,e)))??null:null}drawnAt(e,t){let n=this.doc.elementFromPoint(e,t);for(;n?.shadowRoot!=null;){let r=n.shadowRoot.elementFromPoint(e,t);if(r==null||r===n)break;n=r}return n}browserTook(e,t){for(let t of e)this.retargeted.delete(t);this.arena.browserTookOver(e,t)}clickRetargeted(e,t,n,r){let i=this.doc.defaultView;e instanceof Element&&e.isConnected&&i!=null&&(c(this.doc,{takesLateMouse:r===`touch`}),e instanceof i.HTMLElement&&e.matches(`input, textarea, select, [contenteditable]`)&&e.focus(),s(()=>e.dispatchEvent(new i.MouseEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:1,clientX:t,clientY:n}))))}update(e){this.followsPointer||(this.isCoarse=this.isPrimaryPointerCoarse());let t=this.registry.get(e);t!=null&&this.refresh(e,t),this.syncListeners()}pointerIdOf(e){let t=typeof e==`number`?e:e.id;for(let[e,n]of this.fingerPointers)if(n===t)return e;for(let[e,n]of this.pointerIds)if(n===t)return e;return null}isScrollBraking(e,t=b.scrollBrake.value){let n=this.lastScroll;return n!=null&&this.arena.now()-n.time<t&&p(n.scroller,e)}retain(){this.retainers+=1,this.watchPointer(),this.syncListeners();let e=!0;return()=>{e&&(e=!1,--this.retainers,this.uninstallIfIdle())}}onFingersChange(e){return this.fingerListeners.add(e),()=>{this.fingerListeners.delete(e)}}isFingerDownIn(e){return this.fingerTargets.some(t=>p(e,t))}registrationFor(e){this.watchPointer();let t=this.registry.get(e);return t??(t={recognizers:[],consumer:null,hasTouchEndListener:!1,hasTouchMoveListener:!1,hasWheelListener:!1,savedStyle:new Map,authorTouchAction:null,manageStyle:!0,actionGroup:!1,actionGroupAsks:0},this.registry.set(e,t)),t}needsInput(){return this.registry.size>0||this.retainers>0}refresh(e,t){t.manageStyle&&e instanceof HTMLElement&&this.applyStyle(e,t),this.syncTouchMoveListener(e,t)}syncTouchMoveListener(e,t){let n=this.readsFingersFromPointerEvents()&&(this.isCoarse||this.sendsTouchEvents())&&t.recognizers.some(e=>e.isEnabled&&w(e).acceptsTouchInput);n&&!t.hasTouchEndListener?(e.addEventListener(`touchend`,this.onClaimedTouchEnd,{passive:!1}),t.hasTouchEndListener=!0):!n&&t.hasTouchEndListener&&(e.removeEventListener(`touchend`,this.onClaimedTouchEnd),t.hasTouchEndListener=!1);let r=t.recognizers.some(e=>e.isEnabled&&V(e))||t.consumer?.keepsTouch!=null&&t.consumer.isEnabled?.()!==!1&&(this.isCoarse||this.isArmedPress);r&&!t.hasTouchMoveListener?(e.addEventListener(`touchmove`,this.onBlockingTouchMove,{passive:!1}),t.hasTouchMoveListener=!0):!r&&t.hasTouchMoveListener&&(e.removeEventListener(`touchmove`,this.onBlockingTouchMove),t.hasTouchMoveListener=!1);let i=t.recognizers.some(e=>e.isEnabled&&e.claimsTouches&&e.allowedScrollTypes.size>0&&(w(e).family===`pan`||w(e).family===`pinch`));i&&!t.hasWheelListener?(e.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.hasWheelListener=!0):!i&&t.hasWheelListener&&(e.removeEventListener(`wheel`,this.onWheel),t.hasWheelListener=!1)}applyStyle(e,t){let n=t.recognizers.filter(e=>e.isEnabled),r=n.length>0?Me(n):{};r.touchAction==null&&t.consumer?.keepsTouch!=null&&(r={...r,touchAction:`manipulation`});for(let n of Object.keys(B)){let i=B[n],a=r[n];if(n===`touchAction`&&(a=this.touchActionToWrite(e,t,a)),a!=null)t.savedStyle.has(i)||t.savedStyle.set(i,e.style.getPropertyValue(i)),e.style.setProperty(i,a);else if(t.savedStyle.has(i)){let n=t.savedStyle.get(i)??``;t.savedStyle.delete(i),n===``?e.style.removeProperty(i):e.style.setProperty(i,n)}}}touchActionToWrite(e,t,n){if(n==null){Re(e),t.authorTouchAction=null;return}let r=B.touchAction,i=t.savedStyle.has(r)?t.savedStyle.get(r)??``:e.style.getPropertyValue(r);if(i!==``&&!lt(i))return Re(e),Ne(n,i);if(!Ie(e,n)){this.readCallerTouchActionInNextFrame(e);return}let a=t.authorTouchAction;if(a==null||a.derived!==n){this.readCallerTouchActionInNextFrame(e);return}if(a.author==null)return;let o=Ne(n,a.author);return o===a.author?void 0:o}readCallerTouchActionInNextFrame(e){this.pendingCallerReads.add(e),!this.isCallerReadScheduled&&(this.isCallerReadScheduled=!0,this.cancelCallerRead=dt(this.doc.defaultView,()=>{this.isCallerReadScheduled=!1,this.cancelCallerRead=null;let e=[];for(let t of this.pendingCallerReads){let n=this.registry.get(t);n!=null&&e.push([t,n])}this.pendingCallerReads.clear();let t=this.doc.defaultView;for(let[n,r]of e){let e=n.getAttribute(N);if(e==null||t==null)continue;let i=t.getComputedStyle(n).touchAction||`auto`;r.authorTouchAction={derived:e,author:i===e?null:i}}for(let[t,n]of e)this.applyStyle(t,n)}))}cleanup(e,t){t.recognizers.length>0||t.consumer!=null?this.syncListeners():(t.hasTouchEndListener&&=(e.removeEventListener(`touchend`,this.onClaimedTouchEnd),!1),t.hasTouchMoveListener&&e.removeEventListener(`touchmove`,this.onBlockingTouchMove),t.hasWheelListener&&e.removeEventListener(`wheel`,this.onWheel),this.registry.delete(e),this.uninstallIfIdle())}syncListeners(){this.syncLayoutWatch(),this.syncArmed(),this.shouldListen()?(this.install(),this.syncClaimingListeners()):this.uninstall(),this.syncMoverBlocking()}syncMoverBlocking(){let e=this.isInstalled&&this.hitTestsLayout();e&&this.stopWatchingMovers==null?this.stopWatchingMovers=m(()=>this.syncMoverBlocking()):!e&&this.stopWatchingMovers!=null&&(this.stopWatchingMovers(),this.stopWatchingMovers=null);let t=e&&f().some(e=>this.hasClaimingRecognizerAround(e));if(t===(this.stopBlockingForMovers!=null))return;let r=this.doc.defaultView;t&&r!=null?this.stopBlockingForMovers=n(r,`touchmove`,this.onBlockingTouchMove,{cancels:!0}):t||(this.stopBlockingForMovers?.(),this.stopBlockingForMovers=null)}hasClaimingRecognizerAround(e){if(!e.isConnected||e.ownerDocument!==this.doc)return!1;for(let[t,n]of this.registry)if((p(e,t)||p(t,e))&&n.recognizers.some(e=>e.isEnabled&&V(e)))return!0;return!1}syncArmed(){let e=new Set;if(!this.isCoarse)for(let[t,n]of this.registry){let r=n.consumer;(n.recognizers.some(e=>e.isEnabled&&(e.allowedPointerTypes==null||e.allowedPointerTypes.size>0))||r!=null&&r.isEnabled?.()!==!1)&&e.add(t)}for(let[t,n]of this.armedElements)e.has(t)||(n(),this.armedElements.delete(t));for(let t of e)this.armedElements.has(t)||(t.addEventListener(`pointerdown`,this.onArmedPress,ft),this.armedElements.set(t,()=>{t.removeEventListener(`pointerdown`,this.onArmedPress,ft)}));e.size===0&&this.isArmedPress&&(this.isArmedPress=!1,this.syncKeptPresses())}onArmedPress=e=>{let t=e;this.isInstalled||!_t(t.pointerType)||t.pointerType!==`touch`&&!I(t)||(this.isArmedPress=!0,this.syncKeptPresses(),this.install(),t.pointerType!==`mouse`&&this.syncClaimingListeners(),this.onPointerDown(t))};syncKeptPresses(){for(let[e,t]of this.registry)t.consumer?.keepsTouch!=null&&this.syncTouchMoveListener(e,t)}dropCancelledLifts(e){let t=e.pointerType===`touch`&&e.isPrimary===!1;for(let[n,r]of[...this.cancelledPointers])(n===e.pointerId||!(t&&r===`touch`))&&this.cancelledPointers.delete(n)}releaseArmedPress(){this.isArmedPress&&queueMicrotask(()=>{this.isArmedPress&&this.arena.touches.length===0&&this.cancelledPointers.size===0&&(this.isArmedPress=!1,this.syncKeptPresses(),this.syncListeners())})}uninstallIfIdle(){this.syncListeners(),this.registry.size===0&&this.retainers===0&&(this.uninstall(),this.stopWatchingPointer?.(),this.stopWatchingPointer=null,this.releaseWhenIdle())}releaseWhenIdle(){queueMicrotask(()=>{if(!(this.registry.size>0||this.retainers>0)){this.cancelledFingers.clear(),this.cancelledPointers.clear(),this.clearClaimedLifts(),this.cancelCallerRead?.(),this.cancelCallerRead=null,this.isCallerReadScheduled=!1,this.pendingCallerReads.clear();for(let e of this.ownScrollFrames.values())e();this.ownScrollFrames.clear(),this.ownedScrolls.clear();for(let e of[...this.dragHolds])e({isCancel:!0});this.pressSelections.clear(),this.selectingContacts.clear()}})}watchPointer(){if(this.stopWatchingPointer!=null)return;let e=this.doc.defaultView;this.isCoarse=this.isPrimaryPointerCoarse(),this.stopWatchingPointer=this.followsPointer?i(e,e=>this.pointerChanged(e)):()=>{}}pointerChanged(e){if(e!==this.isCoarse){this.isCoarse=e,e||this.cancelEverything(this.arena.now());for(let[e,t]of this.registry)this.refresh(e,t);this.syncListeners()}}hasClaimer(){for(let e of this.registry.values()){let t=e.consumer;if(t!=null&&t.isEnabled?.()!==!1||e.recognizers.some(e=>e.isEnabled&&e.claimsTouches&&pt(e)))return!0}return!1}syncClaimingListeners(){if(!this.isInstalled)return;let e=this.hasClaimer();if(e===this.isClaimingInstalled)return;let t=this.doc.defaultView;for(let e of this.claimingUnsubscribers.splice(0))e();t!=null&&(this.inputMode===`auto`&&this.claimingUnsubscribers.push(n(t,`touchend`,this.onTouchEnd,{cancels:e})),e&&this.claimingUnsubscribers.push(n(t,`contextmenu`,this.onContextMenu,{cancels:!0}))),this.isClaimingInstalled=e}shouldListen(){if(!this.needsInput())return!1;if(this.isCoarse&&this.retainers>0)return!0;let e=!1;for(let t of this.registry.values()){let n=t.consumer;if(n!=null&&n.isEnabled?.()!==!1||t.recognizers.some(e=>e.isEnabled)){e=!0;break}}return e&&(this.isCoarse||this.isArmedPress)}install(){if(this.watchPointer(),!this.needsInput()||this.isInstalled)return;let e=this.doc.defaultView;this.isInstalled=!0,this.usesTouchEvents=this.inputMode===`auto`&&e!=null&&`ontouchstart`in e,e!=null&&(this.unsubscribers=[...this.inputMode===`auto`?[n(e,`touchstart`,this.onTouchStart),n(e,`touchmove`,this.onTouchMove),n(e,`touchcancel`,this.onTouchCancel)]:[],n(e,`pointerdown`,this.onPointerDown),n(e,`pointermove`,this.onPointerMove),n(e,`pointerup`,this.onPointerUp),n(e,`pointercancel`,this.onPointerCancel),n(e,`scroll`,this.onScroll),n(e,`visibilitychange`,this.onVisibilityChange),n(e,`blur`,t=>{t.target instanceof e.Node||this.onBlur()})],this.isClaimingInstalled=!1,this.claimingUnsubscribers=this.inputMode===`auto`?[n(e,`touchend`,this.onTouchEnd)]:[])}uninstall(){if(this.isInstalled){this.isInstalled=!1,this.fingerTargets=[],this.isClaimingInstalled=!1;for(let e of[...this.unsubscribers.splice(0),...this.claimingUnsubscribers.splice(0)])e();this.cancelEverything(this.arena.now()),this.lastTouch=null,this.lastScroll=null}}participantsAt(e,t){let n=[],r=null,i=null;if(e instanceof Node&&[...this.touchGates].some(t=>t(e)))return{recognizers:n,consumer:r,consumerElement:i};let a=t==null;for(let o=e instanceof Node?e:null;o!=null;o=d(o)){if(!(o instanceof Element))continue;let e=this.registry.get(o);e!=null&&n.push(...e.recognizers),!(a||t==null)&&e?.consumer!=null&&(r=e.consumer,i=o,a=!0)}return{recognizers:n,consumer:r,consumerElement:i}}lockSelection(e,t,n,r,i){let a=e=>this.registry.get(e)?.manageStyle!==!1,o=new Map;for(let e of t){let t=e.selectionLock;if(t!=null&&e.view instanceof Element&&a(e.view)){let n=o.get(t)??new Set;n.add(e.view),o.set(t,n)}}let s=r?.selectionLock;if(s!=null&&i!=null&&a(i)){let e=o.get(s)??new Set;e.add(i),o.set(s,e)}if(o.size>0){let t=[...o].map(([e,t])=>e(t,n));this.lockedBy.set(e,()=>{for(let e of t)e()})}}onWheel=e=>{let t=e;if(this.wheelsSeen.has(t))return;this.wheelsSeen.add(t);let n=J(t),r=t.ctrlKey?`pinch`:`pan`,i=this.wheel;if(i!=null&&(i.kind!==r||n-i.last>=i.endMs)&&(this.endWheel(n),i=null),i!=null&&i.ids.length>0&&i.follow?.lifted!==!0&&!this.wheelHasTaker(i)){this.endWheel(i.last);let e=Dt(t,this.doc.defaultView);i={kind:r,scrollType:q(t),ids:[],x:t.clientX,y:t.clientY,span:St,last:n,endMs:Ct(r,q(t),Math.abs(e.dx)>Math.abs(e.dy)),timer:null,takers:[]},this.wheel=i}let{dx:a,dy:o}=Dt(t,this.doc.defaultView),s=Math.abs(a)>Math.abs(o),c=null;if(r===`pan`?c=this.segmenter.push(n,s?a:o,s?bt:yt):this.segmenter.end(),this.wheelSegment=c,c?.boundary!=null&&i!=null&&(this.endWheel(n),i=null),i??(i=this.beginWheel(t,r,a,o,n),this.wheel=i,i.ids.length>0&&this.latchWheel()),i.last=n,i.timer!=null&&this.clock.clearTimeout(i.timer),i.timer=this.clock.setTimeout(()=>{this.segmenter.end(),this.endWheel()},i.endMs),i.ids.length!==0){if(t.preventDefault(),i.kind===`pan`&&i.follow){let e=i.follow;if(e.lifted)return;if(this.wheelSegment?.liftNow===!0){this.followProvisionally(i,e,n),e.lifted=!0,this.arena.ended([{id:i.ids[0],x:i.x,y:i.y,time:n}]);return}if(this.wheelSegment?.decaying===!0){if(e.heldX+=a,e.heldY+=o,this.wheelSegment.bunched){let t=n-e.lastMove,r=e.speedX,i=e.speedY;Tt(e,e.trueX-e.heldX,e.trueY-e.heldY),e.baseX+=(r-e.speedX)*t,e.baseY+=(i-e.speedY)*t}else e.readSpan=0;this.followProvisionally(i,e,n);return}let t=e.trueX-e.heldX,r=e.trueY-e.heldY,s=wt(i.x-t,a),c=wt(i.y-r,o),l=t-a,u=r-o,d=n-e.lastMove;this.wheelSegment?.bunched===!0?Tt(e,l,u):d>0&&(e.priorSpeedX=e.speedX,e.priorSpeedY=e.speedY,e.readFromX=e.trueX,e.readFromY=e.trueY,e.readSpan=d,e.speedX=(l-e.trueX)/d,e.speedY=(u-e.trueY)/d),e.trueX=l,e.trueY=u,e.heldX=0,e.heldY=0,e.lastMove=n,i.x=l+s,i.y=u+c,e.baseX=i.x,e.baseY=i.y,this.arena.moved([{id:i.ids[0],x:i.x,y:i.y,time:n}])}else i.kind===`pan`?(i.x-=a,i.y-=o,this.arena.moved([{id:i.ids[0],x:i.x,y:i.y,time:n}])):(i.span*=Math.exp(-o/100),this.arena.moved(this.pinchContacts(i,n)))}};followProvisionally(e,t,n){let r=Math.max(0,n-t.lastMove),i=t.baseX+t.speedX*r,a=t.baseY+t.speedY*r;(i!==e.x||a!==e.y)&&(e.x=i,e.y=a,this.arena.moved([{id:e.ids[0],x:i,y:a,time:n}]))}beginWheel(e,t,n,r,i){let a=q(e),o=Math.abs(n)>Math.abs(r),s={kind:t,scrollType:a,ids:[],x:e.clientX,y:e.clientY,span:St,last:i,endMs:Ct(t,a,o),timer:null,takers:[]};if(this.arena.touches.length>0||n===0&&r===0||e.defaultPrevented||!e.cancelable)return s;let c=G(e),l=A(c,{readsTouchAction:!1}),u=[];for(let e=c instanceof Node?c:null;e!=null;e=d(e))if(e instanceof Element)for(let i of this.registry.get(e)?.recognizers??[])i.isEnabled&&i.claimsTouches&&i.allowedScrollTypes.has(a)&&w(i).family===t&&(t!==`pan`||a===`continuous`)&&(t===`pan`&&(!kt(i,-n,-r)||this.scrollerTakes(c,e,n,r,o)||Ot(i)&&l.canScroll(-n,-r))||u.push(i));if(u.length===0)return s;let f={pointerType:`mouse`,target:c,scroll:l,scrollType:a,recognizers:u,consumer:null},p=t===`pan`?[this.nextId++]:[this.nextId++,this.nextId++],m={...s,ids:p,takers:u};return t===`pan`&&a===`continuous`&&(m.follow={lifted:!1,heldX:0,heldY:0,lastMove:i,trueX:s.x,trueY:s.y,baseX:s.x,baseY:s.y,speedX:0,speedY:0,readFromX:s.x,readFromY:s.y,readSpan:0,priorSpeedX:0,priorSpeedY:0}),this.arena.began(t===`pan`?[{...f,id:p[0],x:e.clientX,y:e.clientY,time:i}]:this.pinchContacts(m,i).map(e=>({...f,...e}))),p.every(e=>this.arena.participantsOf(e).length===0)?(this.arena.cancelled(p,i),s):m}scrollerTakes(e,t,n,r,i){for(let a=e instanceof Node?e:null;a!=null;a=d(a)){if(a instanceof Element&&Ce(a,i?-n:0,i?0:-r))return!0;if(a===t)break}return!1}pinchContacts(e,t){return[{id:e.ids[0],x:e.x-e.span/2,y:e.y,time:t},{id:e.ids[1],x:e.x+e.span/2,y:e.y,time:t}]}wheelHasTaker(e){return e.takers.some(e=>{let{state:t}=e;return e.isEnabled&&(t===`began`||t===`changed`||t===`possible`&&e.isInvolved())})}latchWheel(){let e=this.doc.defaultView;if(this.stopWheelLatch==null&&e!=null){let t=()=>{let e=this.dropDrivenWheel();e.length>0&&this.arena.cancelled(e,this.arena.now())},r=[n(e,`wheel`,this.onWheel,{cancels:!0}),n(e,`blur`,n=>{n.target instanceof e.Node||t()}),n(e,`visibilitychange`,()=>{this.doc.visibilityState===`hidden`&&t()})];this.stopWheelLatch=()=>{for(let e of r)e()}}}lockClaimedDrags(e,t){for(let n of e){if(this.claimHolds.has(n))continue;let e=this.arena.touches.find(e=>e.id===n);if(e==null||e.pointerType===`touch`||e.scrollType!=null||e.phase===`ended`||e.phase===`cancelled`)continue;let r=new Set;for(let e of this.arena.participantsOf(n))(e.state===`began`||e.state===`changed`)&&e.view?.nodeType===1&&r.add(e.view);if(t.view?.nodeType===1&&r.add(t.view),r.size===0)continue;let i=Ue(r,this.doc.defaultView,this.pressSelections.get(n)??[],()=>{this.dragHolds.delete(i)});this.dragHolds.add(i),this.lockedBy.has(n)||this.lockedBy.set(n,i),this.claimHolds.set(n,i)}}releaseClaimedDrags(e){for(let t of e){let e=this.claimHolds.get(t);e!=null&&(this.claimHolds.delete(t),this.lockedBy.get(t)===e&&this.lockedBy.delete(t),e({isCancel:!0}))}}dropDrivenWheel(){let e=this.wheel;if(e==null||e.kind!==`pan`||e.ids.length===0||e.follow?.lifted===!0)return[];let t={...e,ids:[],takers:[]};return delete t.follow,this.wheel=t,this.stopWheelLatch?.(),this.stopWheelLatch=null,e.ids}endWheel(e){let t=this.wheel;if(this.stopWheelLatch?.(),this.stopWheelLatch=null,t==null||(this.wheel=null,t.timer!=null&&this.clock.clearTimeout(t.timer),t.ids.length===0||t.follow?.lifted))return;if(t.follow!=null){let e=t.follow,n=Et(t.x,e.trueX-e.heldX,e.speedX),r=Et(t.y,e.trueY-e.heldY,e.speedY);(n!==t.x||r!==t.y)&&(t.x=n,t.y=r,this.arena.moved([{id:t.ids[0],x:n,y:r,time:t.last}]))}let n=t.last+t.endMs,r=e==null?n:Math.max(t.last,Math.min(n,e));this.arena.ended(t.kind===`pan`?[{id:t.ids[0],x:t.x,y:t.y,time:r}]:this.pinchContacts(t,r))}noteSelectingPress(e,t,n,r){!this.lockedBy.has(e)&&Ge(this.doc,t,n,r)&&this.selectingContacts.add(e)}unlockSelection(e,t=!1){let n=this.lockedBy.get(e);n?.({isCancel:t});let r=this.claimHolds.get(e);r!=null&&r!==n&&r({isCancel:t}),this.lockedBy.delete(e),this.claimHolds.delete(e),this.pressSelections.delete(e),this.selectingContacts.delete(e)}addTouchGate(e){return this.touchGates.add(e),()=>{this.touchGates.delete(e)}}fingersDown(){return this.fingerTargets.length}takeEvent(e){return!this.processed.has(e)&&(this.processed.add(e),!0)}onTouchStart=e=>{if(this.endWheel(J(e)),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.fingerTargets.length>1&&this.failUnclaimedLoneFingerPans();let t=J(e),n=[],r=[],i=[],a=[];for(let o of Y(e.changedTouches)){if(o.touchType===`stylus`)continue;this.cancelledFingers.delete(o.identifier);let s=this.forgetFinger(o.identifier);s!=null&&i.push(s);let c=o.target instanceof Node?G(e,o.target):G(e),l=this.presentedTarget(c,o.clientX,o.clientY,e.timeStamp),{recognizers:u,consumer:d,consumerElement:f}=this.participantsAt(l,`touch`);if(u.length===0&&d==null){r.push({id:this.nextId++,x:o.clientX,y:o.clientY,time:t,pointerType:`touch`,target:l});continue}let p=this.nextId++;this.touchIds.set(o.identifier,p),Ve(`touch`)&&a.push({id:p,target:l,consumerElement:f}),this.watchTarget(o.identifier,c,u.some(e=>e.isEnabled&&V(e))||d?.keepsTouch!=null&&d.isEnabled?.()!==!1,d!=null&&d.isEnabled?.()!==!1||u.some(e=>e.isEnabled&&e.claimsTouches)),this.lastFed.set(p,{x:o.clientX,y:o.clientY,time:t}),this.pairTouch(p,{x:o.clientX,y:o.clientY,target:c}),l!==c&&l!=null&&this.retargeted.set(p,{x:o.clientX,y:o.clientY,target:l}),n.push({id:p,x:o.clientX,y:o.clientY,time:t,pointerType:`touch`,target:l,scroll:A(l),recognizers:u,consumer:d})}i.length>0&&this.arena.cancelled(i,t),this.arena.began(n);for(let{id:e,target:t,consumerElement:n}of a)this.lockSelection(e,this.arena.participantsOf(e),t,this.arena.consumerOf(e)??null,n);for(let e of r)this.arena.untrackedBegan(e);this.fingerTargets.length>1&&!this.isFingerClaimed()&&this.failUnclaimedLoneFingerPans();let o=G(e);o instanceof Node&&(this.lastTouch={target:o,time:t})};onTouchMove=e=>{if(this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.dropFingersNotDown(e);let t=J(e),n=[],r=[];for(let i of Y(e.changedTouches)){let e=this.touchIds.get(i.identifier);e!=null&&(n.push(e),r.push({id:e,x:i.clientX,y:i.clientY,time:t}))}if(r.length!==0){if(!e.cancelable){let e=new Map(r.map(e=>[e.id,e])),i=n.filter(t=>{let n=this.arena.getTouch(t);if(n==null||n.takenByBrowser||this.arena.isClaimed(t)||n.scroll?.allowsNativePan===!1||this.judgedUncancelable.has(t))return!1;this.judgedUncancelable.add(t);let r=e.get(t);if(r==null||n.scroll==null)return!0;let i=r.x-n.startX,a=r.y-n.startY;return Math.abs(i)>=Math.abs(a)?n.scroll.canScroll(i,0):n.scroll.canScroll(0,a)});i.length>0&&this.browserTook(i,t)}this.feedMoves(r.filter(e=>!this.pointerFed.has(e.id)))}};onBlockingTouchMove=e=>{this.cancelIfClaimed(e)};pointerFingerAt(e){let t=null,n=1/0;for(let r of this.arena.touches){if(r.pointerType!==`touch`||r.phase===`ended`||r.phase===`cancelled`||!(r.target instanceof Node)||!(e.target instanceof Node)||!(p(r.target,e.target)||p(e.target,r.target)))continue;let i=Math.hypot(r.x-e.clientX,r.y-e.clientY);i<n&&(t=r,n=i)}return t?.id}onClaimedTouchEnd=e=>{let t=e,n=J(t);for(let e=this.claimedLifts.length-1;e>=0;e--)n-this.claimedLifts[e].time>U&&this.claimedLifts.splice(e,1);if(t.cancelable&&!t.defaultPrevented)for(let e of Y(t.changedTouches)){let n=this.claimedLifts.findIndex(n=>W(n,{x:e.clientX,y:e.clientY,target:G(t,e.target)}));if(n>=0){this.claimedLifts.splice(n,1),this.claimedLifts.length===0&&this.clearClaimedLifts(),t.preventDefault();return}}};cancelIfClaimed(e){if(!e.cancelable||e.defaultPrevented)return;let t=Y(e.changedTouches);for(let n of t){let t=this.touchIds.get(n.identifier)??(this.usesTouchEvents?void 0:this.pointerFingerAt(n));if(t!=null&&(this.arena.isClaimed(t)||this.arena.consumerOf(t)?.keepsTouch?.(t)===!0||e.touches.length===1&&this.arena.participantsOf(t).some(e=>w(e).keepsTouch(t)))){e.preventDefault();return}}if(ht(e)){for(let t of this.pointerIds.values())if(this.arena.isClaimed(t)){e.preventDefault();return}}}onTouchEnd=e=>{if(this.releaseArmedPress(),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;this.dropFingersNotDown(e);let t=J(e),n=[],r=[],i=!1;for(let a of Y(e.changedTouches)){if(this.cancelledFingers.delete(a.identifier)){i=!0;continue}let e=this.touchIds.get(a.identifier),o=e==null?void 0:this.retargeted.get(e),s=this.forgetFinger(a.identifier);s!=null&&(n.push({id:s,x:a.clientX,y:a.clientY,time:t}),o!=null&&r.push({id:s,landed:o,x:a.clientX,y:a.clientY}))}let a=G(e);a instanceof Node&&(this.lastTouch={target:a,time:t});let o=n.length>0?this.arena.ended(n):new Map,s=i||X(o);for(let e of r)this.clickRetargetedTap(e.landed,e,o.get(e.id),`touch`)&&(s=!0);s&&(e.cancelable&&e.preventDefault(),c(this.doc,{takesLateMouse:!0}))};clickRetargetedTap(e,t,n,r){return e==null||n!==`allow`||Math.hypot(t.x-e.x,t.y-e.y)>_.allowableMovement.value?!1:(this.clickRetargeted(e.target,t.x,t.y,r),!0)}onTouchCancel=e=>{if(this.releaseArmedPress(),this.noteFingersDown(e),!this.usesTouchEvents||!this.takeEvent(e))return;let t=Y(e.changedTouches),n=t.length>0?t.map(e=>e.identifier):[...this.touchIds.keys()];t.length===0&&this.cancelledFingers.clear();for(let e of n)this.cancelledFingers.delete(e);let r=[];for(let e of n){let t=this.forgetFinger(e);t!=null&&r.push(t)}r.length>0&&this.arena.cancelled(r,J(e))};onTargetTouchMove=e=>{this.onTouchMove(e),this.cancelIfClaimed(e)};onTargetTouchMovePassive=e=>{this.onTouchMove(e)};onTargetTouchEnd=e=>{this.onTouchEnd(e)};onTargetTouchEndPassive=e=>{this.onTouchEnd(e)};onTargetTouchCancel=e=>{this.onTouchCancel(e)};dropFingersNotDown(e){if(e.touches==null||this.touchIds.size===0&&this.cancelledFingers.size===0)return;let t=new Set;for(let n of Y(e.touches))t.add(n.identifier);for(let n of Y(e.changedTouches))t.add(n.identifier);for(let e of[...this.cancelledFingers])t.has(e)||this.cancelledFingers.delete(e);let n=[...this.touchIds.keys()].filter(e=>!t.has(e)),r=[];for(let e of n){let t=this.forgetFinger(e);t!=null&&r.push(t)}r.length>0&&this.arena.cancelled(r,J(e))}watchTarget(e,t,n,r){if(t==null||typeof t.addEventListener!=`function`)return;this.touchTargets.set(e,t);let i=this.watched.get(t);if(i==null){this.watched.set(t,{count:1,blocking:+!!n,claiming:+!!r}),n&&this.blockingFingers.add(e),r&&this.claimingFingers.add(e),t.addEventListener(`touchmove`,n?this.onTargetTouchMove:this.onTargetTouchMovePassive,{passive:!n}),t.addEventListener(`touchend`,r?this.onTargetTouchEnd:this.onTargetTouchEndPassive,{passive:!r}),t.addEventListener(`touchcancel`,this.onTargetTouchCancel,{passive:!0});return}let a=i.blocking>0,o=i.claiming>0;i.count+=1,n&&(i.blocking+=1,this.blockingFingers.add(e)),r&&(i.claiming+=1,this.claimingFingers.add(e)),this.swapTargetTouchMove(t,a,i.blocking>0),this.swapTargetTouchEnd(t,o,i.claiming>0)}unwatchTarget(e){let t=this.touchTargets.get(e);if(t==null)return;this.touchTargets.delete(e);let n=this.watched.get(t);if(n==null)return;let r=n.blocking>0,i=n.claiming>0;--n.count,this.blockingFingers.delete(e)&&--n.blocking,this.claimingFingers.delete(e)&&--n.claiming,n.count>0?(this.swapTargetTouchMove(t,r,n.blocking>0),this.swapTargetTouchEnd(t,i,n.claiming>0)):(this.watched.delete(t),t.removeEventListener(`touchmove`,r?this.onTargetTouchMove:this.onTargetTouchMovePassive),t.removeEventListener(`touchend`,i?this.onTargetTouchEnd:this.onTargetTouchEndPassive),t.removeEventListener(`touchcancel`,this.onTargetTouchCancel))}swapTargetTouchMove(e,t,n){t!==n&&(e.removeEventListener(`touchmove`,t?this.onTargetTouchMove:this.onTargetTouchMovePassive),e.addEventListener(`touchmove`,n?this.onTargetTouchMove:this.onTargetTouchMovePassive,{passive:!n}))}swapTargetTouchEnd(e,t,n){t!==n&&(e.removeEventListener(`touchend`,t?this.onTargetTouchEnd:this.onTargetTouchEndPassive),e.addEventListener(`touchend`,n?this.onTargetTouchEnd:this.onTargetTouchEndPassive,{passive:!n}))}forgetFinger(e){let t=this.touchIds.get(e);return this.touchIds.delete(e),this.unwatchTarget(e),t!=null&&this.forgetContact(t),t}pairTouch(e,t){for(let[n,r]of this.pendingPointers)if(W(r,t)){this.pendingPointers.delete(n),this.fingerPointers.set(n,e),this.pointerFed.add(e);return}this.unpairedTouches.set(e,t)}pairPointer(e,t){for(let[n,r]of this.unpairedTouches)if(W(r,t)){this.unpairedTouches.delete(n),this.fingerPointers.set(e,n),this.pointerFed.add(n);return}this.pendingPointers.set(e,t)}feedMoves(e){let t=e.filter(e=>{let t=this.lastFed.get(e.id);return t!=null&&e.time<t.time?!1:(this.lastFed.set(e.id,{x:e.x,y:e.y,time:e.time}),!0)});t.length>0&&this.arena.moved(t)}forgetContact(e){this.unlockSelection(e),this.retargeted.delete(e),this.lastFed.delete(e),this.pointerFed.delete(e),this.judgedUncancelable.delete(e),this.unpairedTouches.delete(e);for(let[t,n]of this.fingerPointers)n===e&&this.fingerPointers.delete(t)}onPointerDown=e=>{if(this.endWheel(J(e)),l(this.doc),!_t(e.pointerType))return;if(this.dropCancelledLifts(e),e.pointerType===`touch`&&this.usesTouchEvents){this.pairPointer(e.pointerId,{x:e.clientX,y:e.clientY,target:G(e)});return}if(e.pointerType===`touch`&&e.isPrimary===!1&&this.failUnclaimedLoneFingerPans(),e.pointerType!==`touch`&&!I(e))return;let t=G(e),n=this.presentedTarget(t,e.clientX,e.clientY,e.timeStamp),{recognizers:r,consumer:i,consumerElement:a}=this.participantsAt(n,e.pointerType);if(r.length===0&&i==null)return;let o=this.nextId++;this.pointerIds.set(e.pointerId,o),this.pointerKinds.set(e.pointerId,e.pointerType),n!==t&&n!=null&&this.retargeted.set(o,{x:e.clientX,y:e.clientY,target:n}),e.pointerType!==`touch`&&this.pressSelections.set(o,We(this.doc.defaultView)),this.arena.began([{id:o,x:e.clientX,y:e.clientY,time:J(e),pointerType:e.pointerType,target:n,scroll:A(n),recognizers:r,consumer:i}]),e.pointerType===`touch`&&e.isPrimary===!1&&!this.isFingerClaimed()&&this.failUnclaimedLoneFingerPans(),Ve(e.pointerType)&&this.lockSelection(o,this.arena.participantsOf(o),n,this.arena.consumerOf(o)??null,a),e.pointerType!==`touch`&&this.noteSelectingPress(o,e.clientX,e.clientY,t)};onPointerMove=e=>{if(e.pointerType===`touch`&&this.usesTouchEvents){let t=this.fingerPointers.get(e.pointerId);t!=null&&this.feedMoves([{id:t,x:e.clientX,y:e.clientY,time:J(e),history:jt(e)}]);return}let t=this.pointerIds.get(e.pointerId);t!=null&&this.arena.moved([{id:t,x:e.clientX,y:e.clientY,time:J(e),history:jt(e)}])};onPointerUp=e=>{if(this.releaseArmedPress(),e.pointerType===`touch`&&this.usesTouchEvents){this.fingerPointers.delete(e.pointerId),this.pendingPointers.delete(e.pointerId);return}let t=this.pointerIds.get(e.pointerId);if(t==null){this.cancelledPointers.delete(e.pointerId)&&this.refuseCancelledLift(e);return}this.pointerIds.delete(e.pointerId),this.pointerKinds.delete(e.pointerId),this.unlockSelection(t);let n=this.arena.ended([{id:t,x:e.clientX,y:e.clientY,time:J(e)}]),r=this.retargeted.get(t);this.retargeted.delete(t);let i=this.clickRetargetedTap(r,{x:e.clientX,y:e.clientY},n.get(t),e.pointerType);!i&&X(n)&&c(this.doc,{takesLateMouse:e.pointerType===`touch`}),e.pointerType===`touch`&&(i||X(n))&&this.noteClaimedLift(e)};noteClaimedLift(e){this.readsFingersFromPointerEvents()&&(this.isCoarse||this.sendsTouchEvents())&&(this.claimedLifts.push({x:e.clientX,y:e.clientY,target:G(e),time:J(e)}),this.claimedLifts.length>gt&&this.claimedLifts.shift(),this.armClaimedLiftTimer())}armClaimedLiftTimer(){if(this.claimedLiftTimer!=null||this.claimedLifts.length===0)return;let e=this.claimedLifts[0].time+U;this.claimedLiftTimer=this.clock.setTimeout(()=>{this.claimedLiftTimer=null;let e=this.clock.now();for(let t=this.claimedLifts.length-1;t>=0;t--)e-this.claimedLifts[t].time>=U&&this.claimedLifts.splice(t,1);this.armClaimedLiftTimer()},Math.max(0,e-this.clock.now()))}clearClaimedLifts(){this.claimedLifts.length=0,this.claimedLiftTimer!=null&&(this.clock.clearTimeout(this.claimedLiftTimer),this.claimedLiftTimer=null)}onPointerCancel=e=>{if(this.releaseArmedPress(),e.pointerType===`touch`&&this.usesTouchEvents){let t=this.fingerPointers.get(e.pointerId)??this.touchForCancelledPointer(e);this.fingerPointers.delete(e.pointerId),this.pendingPointers.delete(e.pointerId),t!=null&&(this.pointerFed.delete(t),this.browserTook([t],J(e)));return}this.cancelledPointers.delete(e.pointerId);let t=this.pointerIds.get(e.pointerId);t!=null&&(this.pointerIds.delete(e.pointerId),this.pointerKinds.delete(e.pointerId),this.unlockSelection(t,!0),this.retargeted.delete(t),this.arena.cancelled([t],J(e)))};touchForCancelledPointer(e){let t=null,n=1/0;for(let r of this.arena.touches){if(r.pointerType!==`touch`||r.phase===`ended`||r.phase===`cancelled`||r.target!==G(e))continue;let i=Math.hypot(r.x-e.clientX,r.y-e.clientY);i<n&&(t=r,n=i)}return t==null?this.touchIds.get(e.pointerId)??null:t.id}replayClick(e,t){if(!t)return;l(this.doc);let n=e.target,r=this.doc.defaultView;n instanceof Element&&n.isConnected&&r!=null&&s(()=>n.dispatchEvent(new r.MouseEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:1,clientX:e.x,clientY:e.y})))}onContextMenu=e=>{for(let t of this.arena.touches)if(this.arena.isClaimed(t.id)||this.arena.consumerOf(t.id)?.holdsContextMenu?.(t.id)===!0){e.preventDefault();return}};ownScroll(e){let t=++this.ownScrollCalls;this.ownedScrolls.set(e,t);let n=this.doc.defaultView;if(n==null)return;this.ownScrollFrames.get(e)?.();let r=0,i=n.requestAnimationFrame(()=>{r=n.requestAnimationFrame(()=>{this.ownScrollFrames.delete(e),this.ownedScrolls.get(e)===t&&this.ownedScrolls.delete(e)})});this.ownScrollFrames.set(e,()=>{n.cancelAnimationFrame(i),r!==0&&n.cancelAnimationFrame(r)})}isOwnScroll(e){return this.ownedScrolls.has(e)}onScroll=e=>{let t=J(e),n=e.target===this.doc?this.doc:e.target;if(!(n instanceof Node)||this.ownedScrolls.has(n))return;let r=this.lastTouch;r!=null&&t-r.time<b.momentumMemory.value&&p(n,r.target)&&(this.lastScroll={scroller:n,time:t});let i=[];for(let e of this.arena.touches)e.takenByBrowser||e.phase===`ended`||e.phase===`cancelled`||e.pointerType!==`touch`||this.arena.isClaimed(e.id)||e.target instanceof Node&&p(n,e.target)&&Math.hypot(e.x-e.startX,e.y-e.startY)>=b.slop.value&&i.push(e.id);i.length>0&&this.browserTook(i,t)};noteFingersDown(e){let t=[];for(let n of Y(e.touches))n.touchType!==`stylus`&&n.target instanceof Node&&t.push(n.target);this.fingerTargets=t;for(let e of[...this.fingerListeners])e()}failUnclaimedLoneFingerPans(){for(let e of[...this.arena.involvedRecognizers])mt(e)&&e.state===`possible`&&e.maximumNumberOfTouches===1&&e.trackedTouches.length>0&&e.trackedTouches.every(e=>e.pointerType===`touch`&&!this.arena.isClaimed(e.id))&&e.cancel()}isFingerClaimed(){return this.arena.touches.some(e=>e.pointerType===`touch`&&this.arena.isClaimed(e.id))}onVisibilityChange=()=>{this.doc.visibilityState===`hidden`&&(this.cancelEverything(this.arena.now()),this.releaseArmedPress())};onBlur=()=>{this.cancelEverything(this.arena.now()),this.releaseArmedPress()};sendsTouchEvents(){let e=this.doc.defaultView;return e!=null&&`ontouchstart`in e}readsFingersFromPointerEvents(){let e=this.doc.defaultView;return this.inputMode===`pointer-events`||e!=null&&!(`ontouchstart`in e)}refuseCancelledLift(e){c(this.doc,{takesLateMouse:e.pointerType===`touch`}),e.pointerType===`touch`&&this.noteClaimedLift(e)}cancelEverything(e){for(let[e,t]of this.pointerKinds)t!==`mouse`&&this.cancelledPointers.set(e,t);let t=[...this.pointerIds.values()];for(let e of t)this.unlockSelection(e,!0);for(let e of[...this.touchIds.keys()]){this.cancelledFingers.add(e);let n=this.forgetFinger(e);n!=null&&t.push(n)}this.pointerIds.clear(),this.pointerKinds.clear(),this.retargeted.clear(),this.fingerPointers.clear(),this.pendingPointers.clear(),this.unpairedTouches.clear(),this.lastFed.clear(),this.pointerFed.clear(),t.push(...this.dropDrivenWheel()),t.length>0&&this.arena.cancelled(t,e)}};function X(e){for(let t of e.values())if(t!==`allow`)return!0;return!1}function jt(e){return typeof e.getCoalescedEvents==`function`?e.getCoalescedEvents().slice(0,-1).map(e=>({x:e.clientX,y:e.clientY,time:J(e)})):[]}function Mt(e){let t=ct.get(e);return t??(t=new At(e),ct.set(e,t)),t}function Nt(e,t){let n=0,r=0,i=0;for(let a of e)t?.has(a.id)||(n+=a.x,r+=a.y,i+=1);return i===0?{x:0,y:0}:{x:n/i,y:r/i}}function Pt(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Z(e){return Math.hypot(e.x-e.startX,e.y-e.startY)}var Q=b,Ft={control:{highlightDelay:`inScrollers`,quickTapFlash:Q.quickTapFlash.value,releaseMs:e.press.highlightOutMs},cell:{highlightDelay:`inScrollers`,cancelTravel:v.hysteresis.value,quickTapFlash:0,releaseMs:e.press.highlightOutMs}};function It(e){if(e.kind!==`tap`)return!1;let t=e;return t.numberOfTapsRequired===1&&t.numberOfTouchesRequired===1}function Lt(e){let t=!1,n=null,r=null,i=null,a=null,o=!1,s={isHighlighted:!1,isTracking:!1,isTouchInside:!1},c=e=>{if(r==null)return!0;let t=h.trackingExpansion;return e.x>=r.left-t&&e.x<=r.right+t&&e.y>=r.top-t&&e.y<=r.bottom+t},l=(t,n)=>{e.onControlEvent?.(t,n)},u=r=>{r&&n!=null&&(t=!0),s.isHighlighted!==r&&(s.isHighlighted=r,e.onHighlightChange?.(r))},d=()=>{i!=null&&(clearTimeout(i),i=null)},f=()=>{a!=null&&(clearTimeout(a),a=null)},p=()=>{t=!1,n=null,s.isTracking=!1,s.isTouchInside=!1,r=null},m=e=>{e.id===n&&(t=!1,d(),l(`touchCancel`,e),u(!1),p())},h={get isHighlighted(){return s.isHighlighted},get isTracking(){return s.isTracking},get isTouchInside(){return s.isTouchInside},trackingExpansion:e.trackingExpansion??y.trackingExpansion.value,isEnabled(){return e.isEnabled?.()!==!1},holdsContextMenu(t){return e.holdsContextMenu?.(t)===!0},touchBegan(t){if(n!=null||e.isEnabled?.()===!1||t.pointerType===`touch`&&e.isBraking?.(t)===!0)return;f(),n=t.id,r=e.getBounds(),s.isTracking=!0,s.isTouchInside=!0,o=!1,l(`touchDown`,t);let a=e.highlightDelay??`inScrollers`;t.pointerType===`touch`&&(a===`always`||a===`inScrollers`&&t.scroll?.isInsideScroller===!0)?i=setTimeout(()=>{i=null,s.isTouchInside&&u(!0)},Q.contentTouchDelay.value):u(!0)},touchMoved(t){if(t.id!==n)return;let r=e.cancelTravel;if(r!=null&&Z(t)>r){m(t);return}i!=null&&Z(t)>Q.slop.value&&(clearTimeout(i),i=null,o=!0);let a=c(t);a!==s.isTouchInside&&(s.isTouchInside=a,l(a?`touchDragEnter`:`touchDragExit`,t),i==null&&!o&&u(a)),l(a?`touchDragInside`:`touchDragOutside`,t)},touchEnded(r){if(r.id!==n)return;t=!1;let o=c(r),s=i!=null;d(),l(o?`touchUpInside`:`touchUpOutside`,r);let f=e.quickTapFlash??Q.quickTapFlash.value;s&&o?(u(!0),f>0?a=setTimeout(()=>{a=null,u(!1)},f):u(!1)):u(!1),p()},touchCancelled:m,allowsAncestorRecognizer(t){let n=t;return n.view!=null&&n.view===e.view||!(e.vetoesAncestorRecognizer??It)(n)},dispose(){d(),f(),u(!1),p()},get selectionLock(){return e.selectionLock}};return e.keepsTouch===!0?Object.assign(h,{keepsTouch:e=>t&&n===e}):h}function Rt(e,{onClicked:t,onNoClick:r}){let i=e.ownerDocument.defaultView;if(i==null){let e=!1;return queueMicrotask(()=>{e||r()}),()=>{e=!0}}let a=!1,o=null,s=null,c=null,l=()=>{a=!0,c?.(),c=null,s!=null&&(i.clearTimeout(s),s=null)};return c=n(i,`click`,n=>{!a&&n.isTrusted&&e.contains(n.target)&&(l(),o=i.setTimeout(()=>{o=null,t(n.defaultPrevented)},0))}),s=i.setTimeout(()=>{a||(l(),r())},300),()=>{l(),o!=null&&(i.clearTimeout(o),o=null)}}function $(e){let t=e.ownerDocument.defaultView,n=null,r=t=>{n==null&&t.target===e&&(n=t)};t?.addEventListener(`click`,r,!0);try{e.click()}finally{t?.removeEventListener(`click`,r,!0)}return n?.defaultPrevented===!0}function zt(e){return c(e.ownerDocument),s(()=>$(e))}export{x as C,_ as S,ee as T,C as _,Lt as a,se as b,Pt as c,He as d,I as f,me as g,ge as h,Ft as i,Z as l,pe as m,$ as n,It as o,w as p,zt as r,Nt as s,Rt as t,Mt as u,ce as v,te as w,v as x,y};
@@ -1,9 +1,9 @@
1
- import{Ct as e,bt as t,s as n,xt as r}from"./index-Hix1w6kY.js";var i=`npm install ${[`@theoremjs/agents`,`@theoremjs/web`,`@theoremjs/react`,`zod`,`react`,`react-dom`,`@astryxdesign/core`,`@stylexjs/stylex`].join(` `)}`,a=`/api/theorem`,o=`/api/decision`,s=`/api/host`,c=`/api/embedding`;function l({profile:e}){return n(e.type)}function u(e){if(!e||typeof e!=`object`)return[];let{keySlot:t,fallbackKeySlot:n}=e;return[t,n].filter(e=>typeof e==`string`&&e!==``)}function d({profile:e}){let t=`models`in e?e.models:{};return[e,...t&&typeof t==`object`?Object.values(t):[]].flatMap(u)}function f(e){return`{ ${[...new Set(e.agents.flatMap(d))].map(e=>`${JSON.stringify(e)}: process.env.THEOREM_VAULT_${e.toUpperCase().replaceAll(`-`,`_`)}`).join(`, `)} }`}function p(e){return`{\n${[`vault: ${f(e)}`].map(e=>` ${e},`).join(`
2
- `)}\n }`}function m(e){return e.profile.type===`decision`?[`profile`,`questions`,...e.images?[`images`]:[]]:[`profile`]}function h(e,n,i,a,o){let s=r(t(e.agentId));return{path:`route.ts`,code:`${[`import { ${i} } from '@theoremjs/web/server';`,`import './theorem';`,`import { ${m(e).join(`, `)} } from '${s}';`,``,`/** ${a} */`,`export const ${n} = ${i}({`,...o.map(e=>` ${e},`),`});`].join(`
1
+ import{Ct as e,Et as t,s as n,wt as r}from"./index-DeAchcs2.js";var i=`npm install ${[`@theoremjs/agents`,`@theoremjs/web`,`@theoremjs/react`,`zod`,`react`,`react-dom`,`@astryxdesign/core`,`@stylexjs/stylex`].join(` `)}`,a=`/api/theorem`,o=`/api/decision`,s=`/api/host`,c=`/api/embedding`;function l({profile:e}){return n(e.type)}function u(e){if(!e||typeof e!=`object`)return[];let{keySlot:t,fallbackKeySlot:n}=e;return[t,n].filter(e=>typeof e==`string`&&e!==``)}function d({profile:e}){let t=`models`in e?e.models:{};return[e,...t&&typeof t==`object`?Object.values(t):[]].flatMap(u)}function f(e){return`{ ${[...new Set(e.agents.flatMap(d))].map(e=>`${JSON.stringify(e)}: process.env.THEOREM_VAULT_${e.toUpperCase().replaceAll(`-`,`_`)}`).join(`, `)} }`}function p(e){return`{\n${[`vault: ${f(e)}`].map(e=>` ${e},`).join(`
2
+ `)}\n }`}function m(e){return e.profile.type===`decision`?[`profile`,`questions`,...e.images?[`images`]:[]]:[`profile`]}function h(t,n,i,a,o){let s=r(e(t.agentId));return{path:`route.ts`,code:`${[`import { ${i} } from '@theoremjs/web/server';`,`import './theorem';`,`import { ${m(t).join(`, `)} } from '${s}';`,``,`/** ${a} */`,`export const ${n} = ${i}({`,...o.map(e=>` ${e},`),`});`].join(`
3
3
  `)}\n`}}function g(e,t,n,r,i,a=[]){let o=a.length===0?[` return <${n} endpoint="${r}" />;`]:[` return (`,` <${n}`,` endpoint="${r}"`,...a.map(e=>` ${e}`),` />`,` );`];return{path:e,what:i,code:`${[`import { ${n} } from '@theoremjs/react/ui';`,``,`export function ${t}() {`,...o,`}`].join(`
4
4
  `)}\n`}}function _({profile:e}){let t=`inputs`in e?e.inputs:void 0,n=t&&`options`in t?t.options??{}:{};return{options:Object.entries(n).map(([e,t])=>[e,t.choices.map(({value:e})=>e)]),from:(t&&`context`in t?t.context:void 0)?.from??[]}}function v(e){let t=e.customTools.flatMap(e=>e.type===`function`&&e.answeredBy===`page`?[e.name]:[]);return t.length===0?[]:[`// What this page does for each tool it answers, and the output it returns.`,`pageTools={{`,...t.map(e=>` ${JSON.stringify(e)}: (args) => ({ output: {} }),`),`}}`]}function y(e){let{options:t,from:n}=_(e),r=t.map(([e,t])=>`${JSON.stringify(e)}: ${JSON.stringify(t.at(0)??``)}`);return[...t.map(([e,t])=>`// ${e}: ${t.join(` | `)}`),...t.length>0?[`options={{ ${r.join(`, `)} }}`]:[],...n.includes(`client`)?[`// What this page tells the agent: any JSON.`,`context={{}}`]:[],...v(e)]}function b(e){return _(e).from.includes(`server`)?[`// What your server tells the agent with each request: any JSON.
5
5
  context: () => ({})`]:[]}function x(e,t){return{endpoint:o,route:h(t,`decision`,`createTheoremDecisionHandler`,`Mount at ${o} and ${o}/decide. The questions stay here; the browser sends only the state.`,[...m(t),`vault: ${f(e)}`]),ui:g(`AgentDecision.tsx`,`AgentDecision`,`TheoremDecision`,o,`the state field and the answers`)}}function S(e){return{endpoint:s,route:h(e,`host`,`createTheoremHostHandler`,`Mount at ${s}/*: it describes the tools, and answers /call and /invoke. No model runs.`,[`profile`]),ui:g(`AgentHost.tsx`,`AgentHost`,`TheoremHost`,s,`a form per tool and its result`)}}function C(e,t){return{endpoint:c,route:h(t,`embedding`,`createTheoremEmbeddingHandler`,`Mount at ${c} and ${c}/embed.`,[`profile`,`vault: ${f(e)}`]),ui:g(`AgentEmbedding.tsx`,`AgentEmbedding`,`TheoremEmbedding`,c,`the inputs and their vectors`)}}function w(e,t){return{endpoint:a,route:h(t,`theorem`,`createTheoremHandler`,`Mount at ${a}/*: it answers /turn, /invoke and /steer.`,[`profile`,`provider: ${p(e)}`,...b(t)]),ui:g(`AgentChat.tsx`,`AgentChat`,`TheoremChat`,a,`the chat`,y(t))}}function T(e,t){return t.profile.type===`decision`?x(e,t):t.profile.type===`host`?S(t):t.profile.type===`embedding`?C(e,t):l(t)?w(e,t):{}}function E(e,t,n){let r=e.filter(e=>e.path.startsWith(`agents/`)),a=[...e.some(e=>e.path===`tools.ts`)?["- `tools.ts` (server only): the tools the agents share."]:[],...r.map(e=>`- \`${e.path}\` (server only): one agent's profile. It registers nothing.`),"- `theorem.ts` (server only): registers every tool and agent, each after the agents it names. Import it once.",...n.route?[`- \`route.ts\` (server only): runs \`${t.agentId}\`, mounted at \`${n.endpoint??``}\`.`]:[],...n.ui?[`- \`${n.ui.path}\` (browser): ${n.ui.what}, pointed at that route.`]:[]];return`${[`# ${t.agentId}`,``,`Exported from the Theorem Studio: ${r.length===1?`one agent`:`${String(r.length)} agents`}${n.route?`, and the route and ${n.ui?`component`:`files`} for \`${t.agentId}\``:``}.`,``,...a,``,n.route?`The server-only files read your keys. Nothing in them may reach the browser.`:`\`${t.agentId}\` is a ${t.profile.type} agent: register it on your server, then run it through your own relay (see @theoremjs/react/live).`,``,"```bash",i,"```"].join(`
6
- `)}\n`}function D(t,n,r){let i=e(t,r).map(e=>e.path===`theorem.ts`?{...e,code:e.code.replace(`baseUrl: 'http://localhost:11434/v1'`,`baseUrl: (process.env.LOCAL_MODEL_URL ?? 'http://127.0.0.1:11434').replace(/\\/$/, '') + '/v1'`)}:e),a=T(t,n);return[{path:`README.md`,code:E(i,n,a)},...i,...a.route?[a.route]:[],...a.ui?[{path:a.ui.path,code:a.ui.code}]:[]]}function O(e){return e.map(e=>`// ─── ${e.path} ───\n\n${e.code.trimEnd()}\n`).join(`
6
+ `)}\n`}function D(e,n,r){let i=t(e,r).map(e=>e.path===`theorem.ts`?{...e,code:e.code.replace(`baseUrl: 'http://localhost:11434/v1'`,`baseUrl: (process.env.LOCAL_MODEL_URL ?? 'http://127.0.0.1:11434').replace(/\\/$/, '') + '/v1'`)}:e),a=T(e,n);return[{path:`README.md`,code:E(i,n,a)},...i,...a.route?[a.route]:[],...a.ui?[{path:a.ui.path,code:a.ui.code}]:[]]}function O(e){return e.map(e=>`// ─── ${e.path} ───\n\n${e.code.trimEnd()}\n`).join(`
7
7
  `)}function k(e,t){let n=e.profile.type;return n===`decision`?["- Where the state comes from: typed by a person in `TheoremDecision` (`AgentDecision.tsx`), or built by my own code, which then calls `runDecision` from `@theoremjs/agents` on the server and drops `route.ts` and `AgentDecision.tsx`.",`- Which framework this app uses, and where server routes live (so the handler mounts at \`${o}\`, or the path you pick).`,`- Where the model keys come from: environment variables or a secrets manager.`,`- Who may call the route, and how many decisions each caller may make: every decision spends a key.`]:n===`host`?["- Who calls the tools: a person in `TheoremHost` (`AgentHost.tsx`), an MCP client, or my own code, which then drops `AgentHost.tsx`.",`- Which framework this app uses, and where server routes live (so the handler mounts at \`${s}\`, or the path you pick).`,`- Where each tool's keys come from, if any need them.`,`- Who may call the route, and how often.`]:n===`embedding`?["- Where the inputs come from: typed by a person in `TheoremEmbedding` (`AgentEmbedding.tsx`), or sent by my own code, which then calls `runEmbedding` from `@theoremjs/agents` on the server and drops `route.ts` and `AgentEmbedding.tsx`.",`- Which framework this app uses, and where server routes live (so the handler mounts at \`${c}\`, or the path you pick).`,`- Where the model keys come from: environment variables or a secrets manager.`,`- Where the vectors go: the store or index that keeps them, and who may call the route: every request spends a key.`]:[...l(e)?[`- Whether I want a UI at all, since the answer decides what you install and build:`," - The package-prepared user interface (`TheoremChat`, in `AgentChat.tsx`);"," - my own UI on `useTheoremChat` from `@theoremjs/react`, which gives the conversation state without the styling;"," - or none: my server code calls `runTurn` from `@theoremjs/agents` directly, and `route.ts` and `AgentChat.tsx` are dropped."]:[],`- Which framework this app uses, and where server routes live (so the handler mounts at \`${a}\`, or the path you pick).`,`- Where model keys come from: environment variables, a secrets manager, or each user's own key.`,"- Who may use the agents: anyone, or only signed-in users (the handler takes a `session` resolver).","- Whether sessions must survive restarts or span several instances (then pass a shared atomic `sessionStore` with `load` and `compareAndSwap`; a separate read followed by a write is unsafe).",...t.length?[`- What each tool should really do: ${t.join(`, `)} return stand-in data today. Where does the real data come from, and what credentials does each need?`]:[],`- If I want a UI: where it should appear, and whether it should match an existing theme.`]}function A(e,t,n){let r=D(e,t,n),a=[...new Set(e.agents.flatMap(e=>e.customTools.filter(e=>e.type===`function`).map(e=>`\`${e.name}\``)))],o=l(t);return`# Add the Theorem agents to this app
8
8
 
9
9
  The files below were exported from the Theorem Studio: ${e.agents.map(e=>`\`${e.agentId}\``).join(`, `)}, the tools they share, the registration that wires them together${r.some(e=>e.path===`route.ts`)?`, and a server route and package-prepared user interface for \`${t.agentId}\``:``}. The README says what each file is. Wire them into this codebase.
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t}from"./themeProps-Bo2jNkIC.js";import{$r as n,Bn as r,Kt as i,Mr as a,Nt as o,Pr as s,Qr as c,Wt as l,Xr as u,kt as d,lt as f,qr as p,zr as m}from"./TraceOverview-CR3DRfnT.js";var h=e(t()),g=[`points`];function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?_(Object(n),!0).forEach(function(t){y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function y(e,t,n){return(t=b(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){var t=x(e,`string`);return typeof t==`symbol`?t:t+``}function x(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(null,arguments)}function C(e,t){if(e==null)return{};var n,r,i=w(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function w(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function T(e){var t=e.option,r=e.dotProps,i=e.className;if((0,h.isValidElement)(t))return(0,h.cloneElement)(t,r);if(typeof t==`function`)return t(r);var a=n(i,typeof t==`boolean`?``:t.className),s=r??{};s.points;var c=C(s,g);return h.createElement(o,S({},c,{className:a}))}function E(e,t){return e==null?!1:t?!0:e.length===1}function D(e){var t=e.points,n=e.dot,i=e.className,a=e.dotClassName,o=e.dataKey,s=e.baseProps,c=e.needClip,f=e.clipPathId,m=e.zIndex,g=m===void 0?r.scatter:m;if(!E(t,n))return null;var _=d(n),y=u(n),b=t.map((e,r)=>{var i=v(v(v({r:3},s),y),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:o,value:e.value,payload:e.payload,points:t});return h.createElement(T,{key:`dot-${r}`,option:n,dotProps:i,className:a})}),x={};return c&&f!=null&&(x.clipPath=`url(#clipPath-${_?``:`dots-`}${f})`),h.createElement(l,{zIndex:g},h.createElement(p,S({className:i},x),b))}function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?O(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function A(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e){var t=M(e,`string`);return typeof t==`symbol`?t:t+``}function M(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var N=e=>{var t=e.point,n=e.childIndex,r=e.mainColor,i=e.activeDot,a=e.dataKey,l=e.clipPath;if(i===!1||t.x==null||t.y==null)return null;var u=k(k(k({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),c(i)),s(i)),d=(0,h.isValidElement)(i)?(0,h.cloneElement)(i,u):typeof i==`function`?i(u):h.createElement(o,u);return h.createElement(p,{className:`recharts-active-dot`,clipPath:l},d)};function P(e){var t=e.points,n=e.mainColor,o=e.activeDot,s=e.itemDataKey,c=e.clipPath,u=e.zIndex,d=u===void 0?r.activeDot:u,p=a(i),g=f();if(t==null||g==null)return null;var _=t.find(e=>g.includes(e.payload));return m(_)?null:h.createElement(l,{zIndex:d},h.createElement(N,{point:_,childIndex:Number(p),mainColor:n,dataKey:s,activeDot:o,clipPath:c}))}function F(e){var t=c(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}export{P as n,D as r,F as t};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProgressBarMarkTooltip-BCgy6kk7.js","assets/themeProps-Bo2jNkIC.js","assets/rolldown-runtime-hePW80VL.js","assets/Tooltip-BO0yrDVt.js","assets/useLayerDismissal-CqRa7y6J.js","assets/devWarning-B-QAZEJI.js","assets/useTooltip-NPYEayzZ.js","assets/tokens.stylex-a4pw9QVe.js","assets/useIsHydrating-wiKgLSH8.js","assets/useMergedRefs-DJD-JnFZ.js","assets/useAnnounceRenderedText-BWNmfFlE.js","assets/useClickableContainer-dg6qYWze.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r,u as i}from"./themeProps-Bo2jNkIC.js";import{t as a}from"./mergeProps-ptS-gIMz.js";import{t as o}from"./StackItem-ClAjT294.js";import{C as s,S as c,T as l,t as u}from"./Icon-C9dlIB4I.js";import{l as d,x as f}from"./useHighlightedOptionScroll-C7rzQTVc.js";import{t as p}from"./Token-C0MCeuZZ.js";import{r as m}from"./sharedMutationObserver-BHa8gqlp.js";import{d as h}from"./fieldParts-DJZ7Rxcc.js";import{i as g,r as _}from"./focusOutline.stylex-LUQxyg0W.js";import{b as v,n as y,r as b,x}from"./SidePanel-7cMNIHsg.js";import{t as S}from"./Text-DfN1tSUL.js";import{t as C}from"./preload-helper-DpV6A1kQ.js";import{t as w}from"./VisuallyHidden-Dfmmn1_I.js";import{t as T}from"./Button-Cb-mh6ml.js";import{t as E}from"./Tooltip-BO0yrDVt.js";import{t as ee}from"./createReactComponent-DVEyVJ-p.js";import{a as D,i as O,n as te,o as k,s as ne,t as re}from"./guardrail-tester-D2ym7K4B.js";import{Hi as ie,Ji as ae,Ki as A,Ui as oe,ga as se}from"./shaped-data-BlRLB3TY.js";import{$n as ce,$r as j,$t as le,Ar as M,At as ue,B as de,Bn as fe,Bt as pe,Ct as me,Dn as he,Dr as ge,Dt as _e,En as ve,Er as ye,Et as be,F as xe,Fn as Se,Fr as Ce,Ft as we,Gn as Te,Gr as Ee,H as De,Hn as Oe,Hr as ke,Ht as Ae,I as je,In as Me,Ir as Ne,It as Pe,Jn as Fe,Jr as Ie,Jt as Le,Kn as Re,Kr as ze,Kt as Be,L as Ve,Ln as He,Mn as N,Mr as P,Mt as Ue,Nn as We,Nr as Ge,Nt as Ke,On as qe,Ot as Je,Pn as Ye,Qr as Xe,Qt as Ze,R as Qe,Rn as $e,Sn as et,Sr as tt,St as nt,Tn as rt,Tr as it,Tt as at,Ur as ot,Ut as st,V as ct,Vn as lt,Vt as ut,Wn as dt,Wt as ft,Xn as pt,Xt as mt,Yn as ht,Yr as gt,Yt as _t,Zr as vt,Zt as yt,_n as bt,_r as xt,an as St,ar as Ct,at as wt,cn as Tt,ct as Et,dr as Dt,en as Ot,er as kt,ft as At,gn as jt,gr as Mt,gt as Nt,hn as Pt,ht as Ft,in as It,it as Lt,jn as Rt,jr as zt,jt as Bt,kn as Vt,ln as Ht,lr as Ut,mn as F,n as I,nn as Wt,on as Gt,or as Kt,ot as qt,pr as Jt,pt as Yt,qn as Xt,qr as L,qt as Zt,rn as Qt,rt as $t,sn as en,sr as R,st as tn,t as nn,tn as rn,tr as an,un as on,vn as sn,vr as cn,wn as ln,wr as un,wt as dn,yn as fn,yr as pn,yt as mn,z as hn,zn as gn,zr as _n,zt as vn}from"./TraceOverview-CR3DRfnT.js";import{a as yn}from"./CheckboxInput-BrhD5W3u.js";import{t as z}from"./HStack-D3i0gAme.js";import{t as B}from"./VStack-BGVV0uKl.js";import{d as bn}from"./BaseTypeahead-CHXE162p.js";import{a as xn,c as Sn,i as Cn}from"./trace-patterns-YZSpKAfw.js";import{n as wn,r as Tn,t as En}from"./RankedBars-CmyHIG4-.js";import{n as Dn,t as V}from"./SegmentedControlItem-DRVmwW9x.js";import{C as On,D as kn,J as H,X as An,Y as jn,Yt as Mn,an as Nn,bt as Pn,it as Fn,rt as In,w as Ln}from"./index-DeAchcs2.js";var Rn=ee(`outline`,`heartbeat`,`Heartbeat`,[[`path`,{d:`M19.5 13.572l-7.5 7.428l-2.896 -2.868m-6.117 -8.104a5 5 0 0 1 9.013 -3.022a5 5 0 1 1 7.5 6.572`,key:`svg-0`}],[`path`,{d:`M3 13h2l2 3l2 -6l1 3h3`,key:`svg-1`}]]),U=e(t(),1);function zn(e){let t=(0,U.use)(s);return(0,U.useMemo)(()=>new Intl.Collator(t.locale,e),[t.locale,e])}var Bn={"@astryx.table.sort.ascending":`Sort ascending`,"@astryx.table.sort.clear":`Clear sort`,"@astryx.table.sort.descending":`Sort descending`,"@astryx.table.sort.priority":`Priority {rank, number} of {total, number}`},W=n();l(Bn);var Vn={button:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`xzye2dw`,kWkggS:`xjbqb8w`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kmVPX3:`x1717udv`,kogj98:`x1ghz6dp`,kkrTdU:`x1ypdohk x16khyan`,kVVagm:`xln7xf2`,kMwMTN:`x1heor9g`,kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,k9WMMc:`x16tdsg8`,kaIpWk:`xx3sua9`,$$css:!0},buttonAlignCenter:{kjj79g:`xl56j7k`,$$css:!0},buttonAlignEnd:{kjj79g:`x13a6bvl`,$$css:!0}};function Hn(e){let{sortable:t}=e;return t?t===!0?e.key:t.sortKey??e.key:null}function Un(e,t){return e==null?`ascending`:e===`ascending`?`descending`:t?null:`ascending`}function Wn({column:e,children:t,configRef:n}){let r=c(),i=n.current,a=Hn(e)??``,o=i.sort.findIndex(e=>e.sortKey===a),s=(o>=0?i.sort[o]:null)?.direction??null,l=i.isMultiSortEnabled===!0&&i.sort.length>1&&o>=0?o+1:null,d=s===`ascending`?`arrowUp`:s===`descending`?`arrowDown`:`arrowsUpDown`,f=(0,U.useId)(),p=e=>{let t=n.current,r=e.shiftKey&&t.isMultiSortEnabled,i=t.allowUnsortedState??!0;if(r){let e=t.sort.findIndex(e=>e.sortKey===a);if(e>=0){let n=Un(t.sort[e].direction,i);if(n==null){let n=[...t.sort];n.splice(e,1),t.onSortChange(n)}else{let r=[...t.sort];r[e]={...r[e],direction:n},t.onSortChange(r)}}else t.onSortChange([...t.sort,{sortKey:a,direction:`ascending`}])}else{let e=Un(t.sort.find(e=>e.sortKey===a)?.direction??null,i);e==null?t.onSortChange([]):t.onSortChange([{sortKey:a,direction:e}])}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{type:`button`,..._.focusVisible(Vn.button,e.align===`end`?Vn.buttonAlignEnd:e.align===`center`?Vn.buttonAlignCenter:null),"aria-describedby":l==null?void 0:f,onClick:p,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`span`,{...{0:{className:`x3nfvp2 x3onkmb xof6bs x25t5g8`},1:{className:`x3nfvp2`}}[s!=null|0],children:(0,W.jsx)(u,{icon:d,size:`xsm`,color:s==null?`secondary`:`accent`})}),l!=null&&(0,W.jsx)(`span`,{className:`x1k6wstc xo5v014 xqwr325`,"aria-hidden":`true`,children:l})]}),l!=null&&(0,W.jsx)(`span`,{id:f,hidden:!0,children:r(`@astryx.table.sort.priority`,{rank:l,total:i.sort.length})})]})}function Gn(e){let t=c(),n=(0,U.useRef)(e);return n.current=e,(0,U.useMemo)(()=>({transformHeaderCell(e,r){let i=Hn(r);if(i==null)return e;let a=n.current.sort.find(e=>e.sortKey===i),o=()=>{let e=n.current,r=e.sort.find(e=>e.sortKey===i)?.direction??null,a=[{id:`sort-asc`,group:`sort`,label:t(`@astryx.table.sort.ascending`),icon:(0,W.jsx)(u,{icon:`arrowUp`,size:`xsm`,"aria-hidden":!0}),checked:r===`ascending`,onSelect:()=>e.onSortChange([{sortKey:i,direction:`ascending`}])},{id:`sort-desc`,group:`sort`,label:t(`@astryx.table.sort.descending`),icon:(0,W.jsx)(u,{icon:`arrowDown`,size:`xsm`,"aria-hidden":!0}),checked:r===`descending`,onSelect:()=>e.onSortChange([{sortKey:i,direction:`descending`}])}];return r!=null&&a.push({id:`sort-clear`,group:`sort-clear`,label:t(`@astryx.table.sort.clear`),icon:(0,W.jsx)(u,{icon:`close`,size:`xsm`,"aria-hidden":!0}),onSelect:()=>e.onSortChange(e.sort.filter(e=>e.sortKey!==i))}),a},s=e.contextMenuActions;return{...e,htmlProps:{...e.htmlProps,...a==null?{}:{"aria-sort":a.direction}},content:(0,W.jsx)(Wn,{column:r,configRef:n,children:e.content}),contextMenuActions:()=>[...Fn(s),...o()]}}}),[t])}function Kn(e){return e instanceof Date?e.toISOString():typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):``}function qn(e,t,n,r){let i=e[n],a=t[n],o=i==null||typeof i==`number`&&Number.isNaN(i),s=a==null||typeof a==`number`&&Number.isNaN(a);return o&&s?0:o?1:s?-1:typeof i==`number`&&typeof a==`number`?i-a:r.compare(Kn(i),Kn(a))}function Jn(e,t,n,r){return t.length===0?e:[...e].sort((e,i)=>{for(let a of t){let{sortKey:t,direction:o}=a,s=n?.[t],c=s?s(e,i):qn(e,i,t,r);if(c!==0)return o===`ascending`?c:-c}return 0})}function Yn(e){let{data:t,defaultSort:n=[],sort:r,onSortChange:i,comparators:a,allowUnsortedState:o,isMultiSortEnabled:s}=e,c=zn({numeric:!0}),[l,u]=(0,U.useState)(n),d=r!==void 0,f=d?r:l,p=d?i??(()=>{}):u,m=(0,U.useRef)(a);m.current=a;let h=(0,U.useRef)(p);h.current=p;let g=(0,U.useMemo)(()=>Jn(t,f,m.current,c),[t,f,c]),_=(0,U.useCallback)(e=>Jn(e,f,m.current,c),[f,c]);return{sortedData:g,sort:f,sortConfig:(0,U.useMemo)(()=>({sort:f,onSortChange:h.current,allowUnsortedState:o,isMultiSortEnabled:s}),[f,o,s]),applySort:_}}var Xn=[`points`,`className`,`baseLinePoints`,`connectNulls`],Zn;function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},G.apply(null,arguments)}function Qn(e,t){if(e==null)return{};var n,r,i=$n(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $n(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function er(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var tr=e=>e!=null&&e.x===+e.x&&e.y===+e.y,nr=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[[]];e.forEach(e=>{var n=t[t.length-1];tr(e)?n&&n.push(e):n&&n.length>0&&t.push([])});var n=e[0],r=t[t.length-1];tr(n)&&r&&r.push(n);var i=t[t.length-1];return i&&i.length<=0&&(t=t.slice(0,-1)),t},rr=(e,t)=>{var n=nr(e);t&&(n=[n.reduce((e,t)=>[...e,...t],[])]);var r=n.map(e=>e.reduce((e,t,n)=>Ee(Zn||=er([``,``,``,`,`,``]),e,n===0?`M`:`L`,t.x,t.y),``)).join(``);return n.length===1?`${r}Z`:r},ir=(e,t,n)=>{var r=rr(e,n);return`${r.slice(-1)===`Z`?r.slice(0,-1):r}L${rr(Array.from(t).reverse(),n).slice(1)}`},ar=e=>{var t=e.points,n=e.className,r=e.baseLinePoints,i=e.connectNulls,a=Qn(e,Xn);if(!t||!t.length)return null;var o=j(`recharts-polygon`,n);if(r&&r.length){var s=a.stroke&&a.stroke!==`none`,c=ir(t,r,i);return U.createElement(`g`,{className:o},U.createElement(`path`,G({},gt(a),{fill:c.slice(-1)===`Z`?a.fill:`none`,stroke:`none`,d:c})),s?U.createElement(`path`,G({},gt(a),{fill:`none`,d:rr(t,i)})):null,s?U.createElement(`path`,G({},gt(a),{fill:`none`,d:rr(r,i)})):null)}var l=rr(t,i);return U.createElement(`path`,G({},gt(a),{fill:l.slice(-1)===`Z`?a.fill:`none`,className:o,d:l}))},or=e=>e.graphicalItems.polarItems,sr=M([N,Rt],Ht),cr=M([or,F,sr],St),lr=M([cr],It),ur=M([lr,Fe],rn),dr=M([ur,F,cr],mt);M([ur,F,cr],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:it(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:it(e,t.dataKey),errorDomain:[]})));var fr=()=>void 0,pr=M([ur,F,cr,on,N,ht],Wt),mr=M([F,Pt,jt,fr,pr,fr,R,N],en),hr=M([F,R,ur,dr,Xt,N,mr],yt),gr=M([hr,fn,sn],Gt),_r=M([F,hr,gr,N],Ze),vr=M([sn,_r],ve),yr=(e,t,n)=>{switch(t){case`angleAxis`:return We(e,n);case`radiusAxis`:return Me(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},br=(e,t,n)=>{switch(t){case`angleAxis`:return Ye(e,n);case`radiusAxis`:return He(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},xr=M([yr,sn,vr,br],ln),Sr=M([xr],he),Cr=M([R,dr,fn,N],Ot),wr=M([R,yr,sn,Sr,gr,br,bt,Cr,N],le),Tr=M([wr],e=>{if(e){var t=new Map;return e.forEach(e=>{var n=(e.coordinate+360)%360;t.has(n)||t.set(n,e)}),Array.from(t.values())}}),Er=M([R,yr,Sr,br,bt,Cr,N],Qt),Dr=[`children`,`type`],Or=[`ref`];function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function kr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kr(Object(n),!0).forEach(function(t){Ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ar(e,t,n){return(t=jr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jr(e){var t=Mr(e,`string`);return typeof t==`symbol`?t:t+``}function Mr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Nr(e,t){if(e==null)return{};var n,r,i=Pr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Pr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Fr=1e-5,Ir=Math.cos(kt(45)),Lr=`angleAxis`;function Rr(e){var t=zt(),n=Jt(),r=(0,U.useMemo)(()=>{e.children;var t=e.type,r=Nr(e,Dr),i=$e(n,`angleAxis`,t);if(i!=null)return q(q({},r),{},{type:i})},[e,n]),i=r===P(e=>We(e,r?.id));return(0,U.useEffect)(()=>r==null?ot:(t(Bt(r)),()=>{t(Ue(r))}),[t,r]),i?e.children:null}var zr=(e,t)=>{var n=t.cx,r=t.cy,i=t.radius,a=t.orientation,o=t.tickSize||8,s=an(n,r,i,e.coordinate),c=an(n,r,i+(a===`inner`?-1:1)*o,e.coordinate);return{x1:s.x,y1:s.y,x2:c.x,y2:c.y}},Br=(e,t)=>{var n=Math.cos(kt(-e.coordinate));return n>Fr?t===`outer`?`start`:`end`:n<-Fr?t===`outer`?`end`:`start`:`middle`},Vr=e=>{var t=Math.cos(kt(-e.coordinate)),n=Math.sin(kt(-e.coordinate));return Math.abs(t)<=Ir?n>0?`start`:`end`:`middle`},Hr=e=>{var t=e.cx,n=e.cy,r=e.radius,i=e.axisLineType,a=e.axisLine,o=e.ticks;if(!a)return null;var s=q(q({},vt(e)),{},{fill:`none`},vt(a));if(i===`circle`)return U.createElement(Ke,K({className:`recharts-polar-angle-axis-line`},s,{cx:t,cy:n,r}));var c=o.map(e=>an(t,n,r,e.coordinate));return U.createElement(ar,K({className:`recharts-polar-angle-axis-line`},s,{points:c}))},Ur=e=>{var t=e.tick,n=e.tickProps,r=e.value;return t?U.isValidElement(t)?U.cloneElement(t,n):typeof t==`function`?t(n):U.createElement(vn,K({},n,{className:`recharts-polar-angle-axis-tick-value`}),r):null},Wr=e=>{var t=e.tick,n=e.tickLine,r=e.tickFormatter,i=e.stroke,a=e.ticks,o=vt(e);o.ref;var s=Nr(o,Or),c=Xe(t),l=q(q({},s),{},{fill:`none`},vt(n)),u=a.map((a,o)=>{var u=zr(a,e),d=Br(a,e.orientation),f=Vr(a),p=q(q(q({},s),{},{textAnchor:d,verticalAnchor:f,stroke:`none`,fill:i},c),{},{index:o,payload:a,x:u.x2,y:u.y2});return U.createElement(L,K({className:j(`recharts-polar-angle-axis-tick`,ue(t)),key:`tick-${a.coordinate}`},Ce(e,a,o)),n&&U.createElement(`line`,K({className:`recharts-polar-angle-axis-tick-line`},l,u)),U.createElement(Ur,{tick:t,tickProps:p,value:r?r(a.value,o):a.value}))});return U.createElement(L,{className:`recharts-polar-angle-axis-ticks`},u)},Gr=e=>{var t=e.angleAxisId,n=P(Se),r=P(e=>Sr(e,`angleAxis`,t)),i=Mt(),a=P(e=>Tr(e,`angleAxis`,t,i));if(n==null||!a||!a.length||r==null)return null;var o=q(q(q({},e),{},{scale:r},n),{},{radius:n.outerRadius,ticks:a});return U.createElement(ft,{zIndex:o.zIndex},U.createElement(L,{className:j(`recharts-polar-angle-axis`,Lr,o.className)},U.createElement(Hr,o),U.createElement(Wr,o)))};function Kr(e){var t=Ge(e,gn);return U.createElement(Rr,{id:t.angleAxisId,scale:t.scale,type:t.type,dataKey:t.dataKey,unit:void 0,name:t.name,allowDuplicatedCategory:!1,allowDataOverflow:!1,reversed:t.reversed,includeHidden:!1,allowDecimals:t.allowDecimals,tickCount:t.tickCount,niceTicks:t.niceTicks??`auto`,ticks:t.ticks,tick:t.tick,domain:t.domain},U.createElement(Gr,t))}Kr.displayName=`PolarAngleAxis`;var qr=[`option`];function Jr(e,t){if(e==null)return{};var n,r,i=Yr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Yr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Xr=ce;function Zr(e){return typeof e==`string`?parseInt(e,10):e}function Qr(e){var t=e.option,n=Jr(e,qr);return U.createElement(_e,{option:t,DefaultShape:Xr,shapeProps:n})}function $r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ei(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?$r(Object(n),!0).forEach(function(t){ti(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ti(e,t,n){return(t=ni(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ni(e){var t=ri(e,`string`);return typeof t==`symbol`?t:t+``}function ri(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ii=M([(e,t)=>Me(e,t),(e,t)=>Sr(e,`radiusAxis`,t)],(e,t)=>{if(e!=null&&t!=null)return ei(ei({},e),{},{scale:t})}),ai=(e,t)=>Er(e,`radiusAxis`,t,!1),oi=M([(e,t,n)=>We(e,n),(e,t,n)=>Sr(e,`angleAxis`,n)],(e,t)=>{if(e!=null&&t!=null)return ei(ei({},e),{},{scale:t})}),si=(e,t,n)=>wr(e,`angleAxis`,n,!1),ci=M([or,(e,t,n,r)=>r],(e,t)=>{if(e.some(e=>e.type===`radialBar`&&t.dataKey===e.dataKey&&t.stackId===e.stackId))return t}),li=M([R,ii,ai,oi,si],(e,t,n,r,i)=>ye(e,`radiusAxis`)?xt(t,n,!1):xt(r,i,!1)),ui=M([oi,ii,R],(e,t,n)=>{var r=n===`radial`?e:t;if(r!=null&&r.scale!=null)return cn({numericAxis:r})}),di=(e,t,n,r,i)=>i,fi=(e,t,n,r,i)=>n,pi=(e,t,n,r,i)=>t,mi=(e,t,n,r,i)=>r.maxBarSize,hi=e=>e.type===`radialBar`,gi=M([R,or,fi,pi],(e,t,n,r)=>t.filter(t=>e===`centric`?t.angleAxisId===n:t.radiusAxisId===r).filter(e=>e.hide===!1).filter(hi)),_i=M([gi,Te,()=>void 0],Et),vi=M([R,Re,oi,si,ii,ai,mi],(e,t,n,r,i,a,o)=>{var s=_n(o)?t:o;return e===`centric`?xt(n,r,!0)??s??0:xt(i,a,!0)??s??0}),yi=M([_i,Re,Oe,lt,vi,li,mi],tn),bi=M([yi,ci],wt),xi=M([cr],e=>e.filter(hi).filter(qe)),Si=M([xi,Fe,et],Vt),Ci=M([Si,xi,Xt,dt],Tt),wi=M([(e,t,n)=>R(e)===`centric`?Ci(e,`radiusAxis`,t):Ci(e,`angleAxis`,n),ci],qt),Ti=M([oi,si,ii,ai,pt,ci,li,R,ui,Se,di,bi,wi],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var p=i.chartData,m=i.dataStartIndex,h=i.dataEndIndex;if(a==null||n==null||e==null||p==null||o==null||d==null||s!==`centric`&&s!==`radial`||r==null||l==null)return[];var g=a.dataKey,_=a.minPointSize,v=l.cx,y=l.cy,b=l.startAngle,x=l.endAngle;return qi({angleAxis:e,angleAxisTicks:t,bandSize:o,baseValue:c,cells:u,cx:v,cy:y,dataKey:g,dataStartIndex:m,displayedData:p.slice(m,h+1),endAngle:x,layout:s,minPointSize:_,pos:d,radiusAxis:n,radiusAxisTicks:r,stackedData:f,stackedDomain:f?(s===`centric`?n:e).scale.domain():null,startAngle:b})}),Ei=M([Fe,(e,t)=>t],(e,t)=>{var n=e.chartData,r=e.dataStartIndex,i=e.dataEndIndex;if(n==null)return[];var a=n.slice(r,i+1);return a.length===0?[]:a.map(e=>({type:t,value:e.name,color:e.fill,payload:e}))}),Di=[`shape`,`activeShape`,`cornerRadius`,`id`],Oi=[`onMouseEnter`,`onClick`,`onMouseLeave`],ki=[`value`,`background`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function Ai(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ai(Object(n),!0).forEach(function(t){ji(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ai(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ji(e,t,n){return(t=Mi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mi(e){var t=Ni(e,`string`);return typeof t==`symbol`?t:t+``}function Ni(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Pi(e,t){if(e==null)return{};var n,r,i=Fi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Fi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ii=[];function Li(e){var t=e.showLabels,n=e.sectors,r=e.children,i=n.map(e=>({value:e.value,payload:e.payload,parentViewBox:void 0,clockWise:!1,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill}));return U.createElement(Pe,{value:t?i:void 0},r)}function Ri(e){var t=e.sectors,n=e.allOtherRadialBarProps,r=e.showLabels,i=e.animationElapsedTime,a=e.isAnimating,o=e.isEntrance,s=n.shape,c=n.activeShape,l=n.cornerRadius,u=n.id,d=Pi(n,Di),f=vt(d),p=P(Be),m=n.onMouseEnter,h=n.onClick,g=n.onMouseLeave,_=Pi(n,Oi),v=at(m,n.dataKey,u),y=be(g),b=dn(h,n.dataKey,u);return t==null?null:U.createElement(Li,{showLabels:r,sectors:t},t.map((e,t)=>{var n=!!(c&&p===String(t)),r=v(e,t),u=y(e,t),m=b(e,t),h=Y(Y(Y(Y({},f),{},{cornerRadius:Zr(l)},e),Ce(_,e,t)),{},{onMouseEnter:r,onMouseLeave:u,onClick:m,className:`recharts-radial-bar-sector ${e.className}`,forceCornerRadius:d.forceCornerRadius,cornerIsExternal:d.cornerIsExternal,animationElapsedTime:i,isAnimating:a,isEntrance:o,isActive:n,option:n&&c!=null?c:s,index:t});return n?U.createElement(ft,{zIndex:fe.activeBar,key:`sector-${e.cx}-${e.cy}-${e.innerRadius}-${e.outerRadius}-${e.startAngle}-${e.endAngle}-${t}`},U.createElement(Qr,h)):U.createElement(Qr,J({key:`sector-${e.cx}-${e.cy}-${e.innerRadius}-${e.outerRadius}-${e.startAngle}-${e.endAngle}-${t}`},h))}),U.createElement(we,{label:n.label}),n.children)}var zi=(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`removed`?[]:e.status===`matched`?[Y(Y({},e.next),{},{startAngle:Ne(e.prev.startAngle,e.next.startAngle,t),endAngle:Ne(e.prev.endAngle,e.next.endAngle,t)})]:[Y(Y({},e.next),{},{endAngle:Ne(e.next.startAngle,e.next.endAngle,t)})]);function Bi(e){var t=e.props,n=e.previousSectorsRef,r=t.sectors,i=t.isAnimationActive,a=t.animationBegin,o=t.animationDuration,s=t.animationEasing,c=t.onAnimationStart,l=t.onAnimationEnd,u=Nt(c,l),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd,m=Jt();return m==null?null:U.createElement(Ft,{animationInput:t,animationIdPrefix:`recharts-radialbar-`,items:r,previousItemsRef:n,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:p,animationInterpolateFn:t.animationInterpolateFn,animationMatchBy:t.animationMatchBy,layout:m},(e,n,r)=>U.createElement(Ri,{sectors:e,allOtherRadialBarProps:t,showLabels:!d,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))}function Vi(e){var t=(0,U.useRef)(null);return U.createElement(Bi,{props:e,previousSectorsRef:t})}function Hi(e){var t=P(t=>Ei(t,e.legendType));return U.createElement(nt,{legendPayload:t??[]})}var Ui=U.memo(e=>{var t=e.dataKey,n=e.sectors,r=e.stroke,i=e.strokeWidth,a=e.name,o=e.hide,s=e.fill,c=e.tooltipType,l=e.formatter,u=e.id,d={dataDefinedOnItem:n,getPosition:ot,settings:{graphicalItemId:u,stroke:r,strokeWidth:i,fill:s,nameKey:void 0,dataKey:t,name:un(a,t),hide:o,type:c,color:s,unit:``,formatter:l}};return U.createElement(me,{tooltipEntrySettings:d})}),Wi=class extends U.PureComponent{renderBackground(e){if(e==null)return null;var t=this.props.cornerRadius,n=Xe(this.props.background);return U.createElement(ft,{zIndex:Lt(this.props.background,fe.barBackground)},e.map((e,r)=>{e.value;var i=e.background,a=Pi(e,ki);if(!i)return null;var o=Y(Y(Y(Y(Y({cornerRadius:Zr(t)},a),{},{fill:`#eee`},i),n),Ce(this.props,e,r)),{},{index:r,className:j(`recharts-radial-bar-background-sector`,String(n?.className)),option:i,isActive:!1});return U.createElement(Qr,J({key:`background-${a.cx}-${a.cy}-${a.innerRadius}-${a.outerRadius}-${a.startAngle}-${a.endAngle}-${r}`},o))}))}render(){var e=this.props,t=e.hide,n=e.sectors,r=e.className,i=e.background;if(t)return null;var a=j(`recharts-area`,r);return U.createElement(ft,{zIndex:this.props.zIndex},U.createElement(L,{className:a},i&&U.createElement(L,{className:`recharts-radial-bar-background`},this.renderBackground(n)),U.createElement(L,{className:`recharts-radial-bar-sectors`},U.createElement(Vi,this.props))))}};function Gi(e){var t=U.useMemo(()=>Je(e.children,pe),[e.children]),n=U.useMemo(()=>({data:void 0,hide:!1,id:e.id,dataKey:e.dataKey,minPointSize:e.minPointSize,stackId:tt(e.stackId),maxBarSize:e.maxBarSize,barSize:e.barSize,type:`radialBar`,angleAxisId:e.angleAxisId,radiusAxisId:e.radiusAxisId}),[e.id,e.dataKey,e.minPointSize,e.stackId,e.maxBarSize,e.barSize,e.angleAxisId,e.radiusAxisId]),r=P(r=>Ti(r,e.radiusAxisId,e.angleAxisId,n,t))??Ii;return U.createElement(U.Fragment,null,U.createElement(Ui,{dataKey:e.dataKey,sectors:r,stroke:e.stroke,strokeWidth:e.strokeWidth,name:e.name,hide:e.hide,fill:e.fill,tooltipType:e.tooltipType,formatter:e.formatter,id:e.id}),U.createElement(Wi,J({},e,{sectors:r})))}var Ki={angleAxisId:0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:mn,animationInterpolateFn:zi,background:!1,cornerIsExternal:!1,cornerRadius:0,forceCornerRadius:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:0,radiusAxisId:0,shape:Xr,zIndex:fe.bar};function qi(e){var t=e.displayedData,n=e.stackedData,r=e.dataStartIndex,i=e.stackedDomain,a=e.dataKey,o=e.baseValue,s=e.layout,c=e.radiusAxis,l=e.radiusAxisTicks,u=e.bandSize,d=e.pos,f=e.angleAxis,p=e.minPointSize,m=e.cx,h=e.cy,g=e.angleAxisTicks,_=e.cells,v=e.startAngle,y=e.endAngle;return g==null||l==null?Ii:(t??[]).map((e,t)=>{var b,x,S,C,w,T;if(n?b=ge(n[r+t],i):(b=it(e,a),Array.isArray(b)||(b=[o,b])),s===`radial`){if(C=f.scale.map(b[0])??v,w=f.scale.map(b[1])??y,x=pn({axis:c,ticks:l,bandSize:u,offset:d.offset,entry:e,index:t}),x!=null&&w!=null&&C!=null){S=x+d.size;var E=w-C;if(Math.abs(p)>0&&Math.abs(E)<Math.abs(p)){var ee=ke(E||p)*(Math.abs(p)-Math.abs(E));w+=ee}T={background:{cx:m,cy:h,innerRadius:x,outerRadius:S,startAngle:v,endAngle:y}}}}else if(x=c.scale.map(b[0]),S=c.scale.map(b[1]),C=pn({axis:f,ticks:g,bandSize:u,offset:d.offset,entry:e,index:t}),x!=null&&S!=null&&C!=null){w=C+d.size;var D=S-x;if(Math.abs(p)>0&&Math.abs(D)<Math.abs(p)){var O=ke(D||p)*(Math.abs(p)-Math.abs(D));S+=O}}return Y(Y(Y({},e),T),{},{payload:e,value:n?b:b[1],cx:m,cy:h,innerRadius:x,outerRadius:S,startAngle:C,endAngle:w},_&&_[t]&&_[t].props)})}function Ji(e){var t=Ge(e,Ki);return U.createElement(Yt,{id:t.id,type:`radialBar`},e=>U.createElement(U.Fragment,null,U.createElement(At,{type:`radialBar`,id:e,data:void 0,dataKey:t.dataKey,hide:t.hide??Ki.hide,angleAxisId:t.angleAxisId??Ki.angleAxisId,radiusAxisId:t.radiusAxisId??Ki.radiusAxisId,stackId:tt(t.stackId),barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize}),U.createElement(Hi,t),U.createElement(Gi,J({},t,{id:e}))))}Ji.displayName=`RadialBar`;function Yi(e){var t=zt();return(0,U.useEffect)(()=>{t(De(e))},[t,e]),null}var Xi=[`layout`];function Zi(){return Zi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zi.apply(null,arguments)}function Qi(e,t){if(e==null)return{};var n,r,i=$i(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $i(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ea(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ta(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ea(Object(n),!0).forEach(function(t){na(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ea(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function na(e,t,n){return(t=ra(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ra(e){var t=ia(e,`string`);return typeof t==`symbol`?t:t+``}function ia(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var aa=ta({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},ct),oa=(0,U.forwardRef)(function(e,t){var n=Ge(e.categoricalChartProps,aa),r=n.layout,i=Qi(n,Xi),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return U.createElement(de,{preloadedState:{options:o},reduxStoreName:n.id??a},U.createElement($t,{chartData:n.data}),U.createElement(hn,{layout:r,margin:n.margin}),U.createElement(Ve,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),U.createElement(Qe,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),U.createElement(Yi,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),U.createElement(xe,Zi({},i,{ref:t})))});function sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ca(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sa(Object(n),!0).forEach(function(t){la(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function la(e,t,n){return(t=ua(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ua(e){var t=da(e,`string`);return typeof t==`symbol`?t:t+``}function da(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var fa=[`axis`,`item`],pa=ca(ca({},aa),{},{layout:`radial`,startAngle:0,endAngle:360}),ma=(0,U.forwardRef)((e,t)=>{var n=Ge(e,pa);return U.createElement(oa,{chartName:`RadialBarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:fa,tooltipPayloadSearcher:Ae,categoricalChartProps:n,ref:t})});function ha(e,t){return ba(e)||ya(e,t)||_a(e,t)||ga()}function ga(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _a(e,t){if(e){if(typeof e==`string`)return va(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?va(e,t):void 0}}function va(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ya(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ba(e){if(Array.isArray(e))return e}function xa(){return xa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xa.apply(null,arguments)}function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ca(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Sa(Object(n),!0).forEach(function(t){wa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wa(e,t,n){return(t=Ta(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ta(e){var t=Ea(e,`string`);return typeof t==`symbol`?t:t+``}function Ea(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Da={fontWeight:`bold`,paintOrder:`stroke fill`,fontSize:`.75rem`,stroke:`#FFF`,fill:`black`,pointerEvents:`none`};function Oa(e){if(!e.children||e.children.length===0)return 1;var t=e.children.map(e=>Oa(e));return 1+Math.max(...t)}var ka=U.memo(e=>{var t=e.dataKey,n=e.nameKey,r=e.data,i=e.stroke,a=e.fill,o=e.positions,s=e.id,c={dataDefinedOnItem:r.children,getPosition:e=>o.get(e),settings:{stroke:i,strokeWidth:void 0,fill:a,nameKey:n,dataKey:t,name:n?void 0:t,hide:!1,type:void 0,color:a,unit:``,graphicalItemId:s}};return U.createElement(me,{tooltipEntrySettings:c})}),Aa={top:0,right:0,bottom:0,left:0},ja=(e,t)=>{if(t!=null)return ze(e,t)},Ma=function(e){return`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:``}children[${e}]`},Na={options:{validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,chartName:`Sunburst`,tooltipPayloadSearcher:ja,eventEmitter:void 0}},Pa=Ca({padding:2,dataKey:`value`,nameKey:`name`,ringPadding:2,innerRadius:50,fill:`#333`,stroke:`#FFF`,textOptions:Da,startAngle:0,endAngle:360,responsive:!1},ct),Fa=e=>{var t=e.className,n=e.data,r=e.children,i=e.padding,a=e.dataKey,o=e.nameKey,s=e.ringPadding,c=e.innerRadius,l=e.fill,u=e.stroke,d=e.textOptions,f=e.outerRadius,p=e.cx,m=e.cy,h=e.startAngle,g=e.endAngle,_=e.onClick,v=e.onMouseEnter,y=e.onMouseLeave,b=e.id,x=zt(),S=Dt(),C=Ut();if(S==null||C==null)return null;var w=f??Math.min(S,C)/2,T=p??S/2,E=m??C/2,ee=rt([0,n[a]],[0,g]),D=Oa(n),O=(w-c)/D,te=[],k=new Map([]);function ne(e,t){v&&v(e,t),x(_t({activeIndex:e.tooltipIndex,activeDataKey:a,activeCoordinate:k.get(e.name),activeGraphicalItemId:b}))}function re(e,t){y&&y(e,t),x(Zt())}function ie(e){_&&_(e),x(Le({activeIndex:e.tooltipIndex,activeDataKey:a,activeCoordinate:k.get(e.name),activeGraphicalItemId:b}))}function ae(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t.radius,o=t.innerR,c=t.initialAngle,f=t.childColor,p=t.nestedActiveTooltipIndex,m=c;e&&e.forEach((e,t)=>{var c=n===1?`[${t}]`:Ma(t,p),h=Ca(Ca({},e),{},{tooltipIndex:c}),g=ee(e[a]),_=m,v=e?.fill??f??l,y=an(0,0,o+r/2,-(_+g-g/2)),b=y.x,x=y.y;m+=g,te.push(U.createElement(`g`,{key:`sunburst-sector-${e.name}-${t}`},U.createElement(ce,{onClick:()=>ie(h),onMouseEnter:e=>ne(h,e),onMouseLeave:e=>re(h,e),fill:v,stroke:u,strokeWidth:i,startAngle:_,endAngle:_+g,innerRadius:o,outerRadius:o+r,cx:T,cy:E}),U.createElement(vn,xa({},d,{alignmentBaseline:`middle`,textAnchor:`middle`,x:b+T,y:E-x}),e[a])));var S=an(T,E,o+r/2,_),C=S.x,w=S.y;return k.set(e.name,{x:C,y:w}),ae(e.children,{radius:r,innerR:o+r+s,initialAngle:_,childColor:v,nestedActiveTooltipIndex:c},n+1)})}ae(n.children,{radius:O,innerR:c,initialAngle:h});var A=j(`recharts-sunburst`,t);return U.createElement(Ie,{width:S,height:C},U.createElement(L,{className:A},te),U.createElement(ka,{dataKey:a,nameKey:o,data:n,stroke:u,fill:l,positions:k,id:b}),r)},Ia=e=>{var t=Ge(e,Pa),n=t.className,r=t.width,i=t.height,a=t.responsive,o=t.style,s=t.id,c=t.throttleDelay,l=t.throttledEvents,u=ha((0,U.useState)(null),2),d=u[0],f=u[1];return U.createElement(de,{preloadedState:Na,reduxStoreName:n??`SunburstChart`},U.createElement(Kt,{width:r,height:i}),U.createElement(Ct,{margin:Aa}),U.createElement(Ve,{throttleDelay:c,throttledEvents:l}),U.createElement(st.Provider,{value:d},U.createElement(je,{className:n,width:r,height:i,responsive:a,style:o,ref:e=>{d==null&&e!=null&&f(e)},onMouseEnter:void 0,onMouseLeave:void 0,onClick:void 0,onMouseMove:void 0,onMouseDown:void 0,onMouseUp:void 0,onContextMenu:void 0,onDoubleClick:void 0,onTouchStart:void 0,onTouchMove:void 0,onTouchEnd:void 0},U.createElement(Yt,{id:s,type:`sunburst`},e=>U.createElement(Fa,xa({},t,{id:e}))))))},La=180,Ra=[`clear`,`shade1`,`shade2`,`shade3`];function za(e,t){return e??Ra[t%Ra.length]??`clear`}function Ba({paint:e}){return(0,W.jsx)(`svg`,{"aria-hidden":!0,width:10,height:10,style:{display:`block`,flexShrink:0},children:(0,W.jsx)(`rect`,{width:10,height:10,rx:2,fill:e})})}function Va({rows:e,format:t}){return(0,W.jsx)(B,{gap:1,children:e.map(e=>(0,W.jsxs)(z,{gap:2,align:`center`,justify:`between`,children:[(0,W.jsxs)(z,{gap:2,align:`center`,children:[(0,W.jsx)(Ba,{paint:e.paint}),(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:e.name})]}),(0,W.jsx)(S,{type:`supporting`,hasTabularNumbers:!0,children:t(e.value)})]},e.id))})}function Ha({chart:e,keyed:t}){return(0,W.jsxs)(z,{gap:4,align:`center`,wrap:`wrap`,children:[(0,W.jsx)(nn,{children:e}),(0,W.jsx)(`div`,{style:{flex:`1 1 140px`,minWidth:0},children:t})]})}function Ua({rows:e,format:t,max:n}){let r=e.map((e,t)=>({...e,paint:Tn(e,za(e.fill,t))})),i=[...r].reverse();return(0,W.jsx)(Ha,{chart:(0,W.jsxs)(ma,{width:La,height:La,data:i,innerRadius:`22%`,outerRadius:`100%`,startAngle:90,endAngle:-270,barCategoryGap:1,accessibilityLayer:!1,children:[(0,W.jsx)(Kr,{type:`number`,domain:[0,n??`auto`],tick:!1,axisLine:!1}),(0,W.jsx)(Ji,{dataKey:`value`,background:{fill:`var(--color-background-gray)`},cornerRadius:4,stroke:xn,isAnimationActive:!1,children:i.map(e=>(0,W.jsx)(pe,{fill:e.paint},e.id))}),(0,W.jsx)(ut,{content:e=>(0,W.jsx)(wn,{...e,format:t}),cursor:!1,isAnimationActive:!1})]}),keyed:(0,W.jsx)(Va,{rows:r,format:t})})}function Wa(e){return e.reduce((e,t)=>e+(t.value??0),0)}function Ga(e,t){let n=e.children?Ka(e.children,t):void 0;return{id:e.id,name:e.name,value:e.value??Wa(n??[]),fill:Sn(t),detail:e.detail,children:n}}function Ka(e,t){return e.map((e,n)=>Ga(e,e.fill??t??za(void 0,n)))}function qa({parts:e,format:t}){let n=Ka(e);return(0,W.jsx)(Ha,{chart:(0,W.jsx)(Ia,{width:La,height:La,data:{name:``,value:Wa(n),children:n},innerRadius:La*.11,ringPadding:2,stroke:xn,textOptions:{fill:`transparent`},children:(0,W.jsx)(ut,{content:e=>(0,W.jsx)(wn,{...e,format:t}),isAnimationActive:!1})}),keyed:(0,W.jsx)(Va,{rows:n.map(e=>({id:String(e.id),name:e.name,value:e.value??0,paint:String(e.fill)})),format:t})})}var Ja={fillTrackMs:1e3,curves:{fill:[0,0,1,1]},reducedMotionPulseMs:2e3,reducedMotionPulseFloor:.84,progressView:{heightPt:4,minimumFillHeights:2,emptyFillAlpha:0}},Ya=Ja.progressView.minimumFillHeights*8;function Xa(e,t){let[n,r]=(0,U.useState)({percentage:e,change:0,flip:0}),i=n.percentage!==e,a=i?Math.abs(e-n.percentage)/100:n.change,o=i?(n.flip+1)%3:n.flip;i&&r({percentage:e,change:a,flip:o});let{isTouch:s}=h(),c=s&&t,l=(0,U.useRef)(null),[u,d]=(0,U.useState)(0);(0,U.useEffect)(()=>{let e=l.current;if(c&&e!=null)return m(e,t=>{d(t.contentRect?.width??e.getBoundingClientRect().width)})},[c]);let p=c&&e>0&&u>0?Math.max(e,Ya/u*100):e,g=bn(null,Ja,`fillTrackMs`),_=bn(null,Ja.curves.fill);return{fillVars:{"--_progress-bar-move":`${Math.round(a*g*1e3)/1e3}ms`,"--_progress-bar-curve":f(`curve`,_),"--_progress-bar-flip":String(o),"--_progress-bar-min":`${Ya}px`},trackRef:l,drawnPercentage:p}}var Za=(0,U.lazy)(async()=>C(()=>import(`./ProgressBarMarkTooltip-BCgy6kk7.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),X={container:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`xzye2dw`,kzqmXN:`xh8yej3`,k7Eaqz:`x900493`,$$css:!0},fill:{kzqmXN:`xh8yej3 xtyencx x1j61smm`,kZKoxP:`x5yr21d`,kMeerF:`xcthrzx`,k3XXqK:`x815t2r`,kjBf7l:`x3teovq`,kInvED:`xvr1dqx`,kaIpWk:`xjspbzw`,k3aq6I:`x8mk83g x13s8k5t x1xwfpud x1ayxeub x1rvio82 x10rjfdt`,k6sLGO:`x1so62im x1mfxj9n`,k1ekBW:`x11xpdln x18hto2h`,kIyJzY:`x80gvsz x1k32oa2 x11y4s09 xo2sced x1r9o9eb`,kAMwcw:`xlr8y92 x1itqrb8`,$$css:!0},fillEmpty:{kSiTet:`x17di44q`,$$css:!0},indeterminateFill:{kZKoxP:`x5yr21d`,kMeerF:`xcthrzx`,k3XXqK:`x815t2r`,kjBf7l:`x3teovq`,kInvED:`xvr1dqx`,kzqmXN:`xz84dc7 xie2s74`,kaIpWk:`xjspbzw`,kKVMdj:`xozk8ic xfd3fxj x1a94pi7 xfqa98z`,k44tkh:`xmg6eyc x1p2ibn3`,kyAemX:`x4hg4is x10xcq22`,kILWW9:`x4q6aw4`,ko0y90:`xa4qsjk`,$$css:!0},mark:{kVAEAm:`x10l6tqk`,k87sOh:`xwa60dl`,kzqmXN:`x63cpjl`,kZKoxP:`xhovv34`,k3aq6I:`x11lhmoz xoffwj3`,$$css:!0}},Qa={accent:{kWkggS:`x1ewilqj`,$$css:!0},success:{kWkggS:`xdsz4j9`,$$css:!0},warning:{kWkggS:`x1q8g9m5`,$$css:!0},error:{kWkggS:`x1pjz0fi`,$$css:!0},neutral:{kWkggS:`x16fr6go`,$$css:!0},disabled:{kWkggS:`x16fr6go`,$$css:!0}},$a={accent:{kWkggS:`x1azo05`,$$css:!0},success:{kWkggS:`x9mohwv`,$$css:!0},warning:{kWkggS:`xmgwp2l`,$$css:!0},error:{kWkggS:`xfba6wv`,$$css:!0},neutral:{kWkggS:`x19aspcf`,$$css:!0},disabled:{kWkggS:`xdomwnj`,$$css:!0}},eo={track:{kWkggS:`x19aspcf`,$$css:!0},trackDisabled:{kWkggS:`xdomwnj`,$$css:!0}};function to(e){let t=bn(e,Ja,`reducedMotionPulseMs`),n=bn(e,d.curves.move);return{"--_progress-bar-pulse":`${t}ms`,"--_progress-bar-pulse-curve":f(`curve`,n),"--_progress-bar-pulse-floor":String(Ja.reducedMotionPulseFloor)}}function no(e,t){return`${t>0?Math.round(e/t*100):0}%`}function ro({value:e=0,max:t=100,label:n,isLabelHidden:o=!1,hasValueLabel:s=!1,formatValueLabel:c=no,variant:l=`accent`,isIndeterminate:u=!1,isDisabled:d=!1,marks:f,xstyle:p,className:m,style:h,"data-testid":_,ref:v,...y}){let b=(0,U.useId)(),x=Number.isFinite(e)?e:0,S=Number.isFinite(t)?t:0,C=Math.min(Math.max(0,x),S),T=S>0?C/S*100:0,E=c(C,S),ee=s&&!u,D=d?`disabled`:l,O=Xa(T,!u&&(f?.length??0)>0),te={"--_progress-bar-fill":`${T}%`,...O.fillVars},k=!u&&f?f.filter(e=>Number.isFinite(e.value)).map(e=>{let t=Math.min(Math.max(0,e.value),S),n=S>0?t/S*100:0;return{value:e.value,label:e.label,pct:n,isOnFill:T>0&&n<=O.drawnPercentage}}):[];return(0,W.jsxs)(`div`,{ref:v,...a(r(`progress-bar`,{variant:l}),i(X.container,p),m,h),"data-testid":_,...y,children:[!o||ee?(0,W.jsxs)(`div`,{className:`x78zum5 x1qughib x1pha0wt`,children:[(0,W.jsx)(`span`,{id:b,...{0:{className:`xjm74w1 xw6l6zx x1e4wzip x1tgivj0`},2:{className:`xjm74w1 xw6l6zx x1e4wzip x1tgivj0 x10l6tqk x1i1rx1s xjm9jq1 x1717udv xkdpibf xb3r6kr xzpqnlu xuxw1ft xc342km`},1:{className:`xjm74w1 xw6l6zx x1e4wzip xnbbluu`},3:{className:`xjm74w1 xw6l6zx x1e4wzip x10l6tqk x1i1rx1s xjm9jq1 x1717udv xkdpibf xb3r6kr xzpqnlu xuxw1ft xc342km xnbbluu`}}[!!o<<1|!!d],children:n}),ee&&(0,W.jsx)(`span`,{...{0:{className:`xjm74w1 xw6l6zx x1sodnla xv1l7n4`},1:{className:`xjm74w1 xw6l6zx x1sodnla xnbbluu`}}[!!d|0],children:E})]}):(0,W.jsx)(w,{id:b,children:n}),(0,W.jsxs)(`div`,{className:`x1n2onr6 xh8yej3`,children:[(0,W.jsx)(`div`,{role:`progressbar`,"aria-valuenow":u?void 0:C,"aria-valuemin":u?void 0:0,"aria-valuemax":u?void 0:S,"aria-labelledby":b,"aria-valuetext":u?void 0:E,ref:O.trackRef,...a(r(`progress-bar-track`),{className:`xh8yej3 xdk7pt xwmxj5m xjspbzw xb3r6kr`}),children:u?(0,W.jsx)(`div`,{...a(r(`progress-bar-fill`,{variant:D}),i(X.indeterminateFill,Qa[D])),style:to(null)}):(0,W.jsx)(`div`,{...a(r(`progress-bar-fill`,{variant:D}),i(X.fill,T===0&&X.fillEmpty,Qa[D])),style:te})}),k.map(e=>{let t=(0,W.jsx)(`span`,{role:`img`,"aria-label":e.label,tabIndex:0,...a(r(`progress-bar-mark`,{variant:D,placement:e.isOnFill?`fill`:`track`}),i(g.focusVisible,X.mark,e.isOnFill?$a[D]:d?eo.trackDisabled:eo.track)),style:{insetInlineStart:`${e.pct}%`}});return(0,W.jsx)(U.Suspense,{fallback:t,children:(0,W.jsx)(Za,{content:e.label,children:t})},`${e.value}:${e.label}`)})]})]})}ro.displayName=`ProgressBar`;var io=[`train`,`validate`,`test`,`holdout`],ao=[`false_alarm`,`missed`,`caught`],oo=8;function so(e){return 2**((e+.5)/oo)/1e3}function co(e){let t=0,n=0,r=new Map;for(let i of e){if(i.mean===void 0||i.n===void 0||!i.buckets)return;t+=i.n,n+=i.mean*i.n;for(let[e,t]of Object.entries(i.buckets))r.set(Number(e),(r.get(Number(e))??0)+t)}if(t===0)return;let i=0;for(let e of[...r.keys()].sort((e,t)=>e-t))if(i+=r.get(e)??0,i*2>=t)return{mean:n/t,median:so(e)}}var lo=[`recall`,`falseAlarms`,`p95`],uo={recall:`Recall`,falseAlarms:`False alarms`,p95:`p95 time`},fo={recall:{worst:0,ends:[`0%`,`50%`,`100%`]},falseAlarms:{worst:.1,ends:[`10% or more`,`5%`,`0%`]},p95:{worst:10,ends:[`10 ms or more`,`5 ms`,`0 ms`],note:`Each cell is its slowest dataset.`}};function po(e,t,n,r){let i=e.filter(e=>e.boundary===t).flatMap(e=>e.detectors.filter(e=>e.detector===n));if(r===`recall`){let e=i.filter(e=>e.attacks),t=e.reduce((e,t)=>e+(t.attacks??0),0);if(t===0)return;let n=e.reduce((e,t)=>e+(t.caught??0),0),r=n/t;return{value:r,goodness:r,datasets:e.length,of:`${n} of ${t} attacks`}}if(r===`falseAlarms`){let e=i.reduce((e,t)=>e+t.benign,0);if(e===0)return;let t=i.reduce((e,t)=>e+t.falseAlarms,0),n=t/e;return{value:n,goodness:1-Math.min(1,n/fo.falseAlarms.worst),datasets:i.length,of:`${t} of ${e} benign texts`}}let a=i.flatMap(e=>e.ms?[e.ms.p95]:[]);if(a.length===0)return;let o=Math.max(...a);return{value:o,goodness:1-Math.min(1,o/fo.p95.worst),datasets:a.length,of:`the slowest dataset`}}function mo(e,t){return e===`p95`?`${t.toFixed(1)}`:`${(t*100).toFixed(0)}`}function ho(e){return`color-mix(in srgb, ${e>=.5?`var(--color-text-blue)`:`var(--color-text-gray)`} ${String(go(e))}%, var(--color-background-surface))`}function go(e){return Math.round(Math.abs(e-.5)*2*85)}function _o(e){return{background:ho(e),color:go(e)>50?`var(--color-background-surface)`:`var(--color-text-primary)`}}function vo(e,t){return oe[t].includes(ne[e])}function yo({scores:e,boundary:t,detector:n,figure:r,onOpen:i}){let a=po(e,t,n,r),o=`${A[n].label} at ${k[t].label}`;if(!a){let e=!vo(t,n);return(0,W.jsx)(E,{content:`${o}: ${e?`it does not read this boundary`:`no dataset scores it here`}`,children:(0,W.jsx)(`span`,{className:`studio-bench-cell ${e?`studio-bench-cell-off`:`studio-bench-cell-empty`}`})})}return(0,W.jsx)(E,{content:`${o}: ${mo(r,a.value)}${r===`p95`?` ms`:`%`}, ${a.of}, over ${String(a.datasets)} datasets`,children:(0,W.jsx)(`button`,{type:`button`,className:`studio-bench-cell`,style:_o(a.goodness),onClick:()=>{i(t,n)},children:mo(r,a.value)})})}function bo({figure:e}){let{ends:t,note:n}=fo[e],r=uo[e];return(0,W.jsxs)(B,{gap:1,children:[(0,W.jsx)(`div`,{role:`img`,"aria-label":`${r} scale: ${t[0]} is the darkest grey, ${t[1]} white, ${t[2]} the darkest blue.`,className:`studio-bench-strip`,style:{background:`linear-gradient(to right, ${ho(0)}, ${ho(.5)}, ${ho(1)})`}}),(0,W.jsx)(z,{justify:`between`,children:t.map(e=>(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:e},e))}),(0,W.jsxs)(z,{gap:3,align:`center`,wrap:`wrap`,children:[(0,W.jsxs)(z,{gap:1,align:`center`,children:[(0,W.jsx)(`span`,{className:`studio-bench-cell studio-bench-cell-empty studio-bench-key`}),(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:`No dataset scores it`})]}),(0,W.jsxs)(z,{gap:1,align:`center`,children:[(0,W.jsx)(`span`,{className:`studio-bench-cell studio-bench-cell-off studio-bench-key`}),(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:`Does not read here`})]}),n&&(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:n})]})]})}function xo({scores:e,figure:t,onOpen:n}){return(0,W.jsxs)(B,{gap:3,children:[(0,W.jsx)(`div`,{className:`studio-bench-matrix-scroll`,children:(0,W.jsxs)(`div`,{className:`studio-bench-matrix`,style:{gridTemplateColumns:`max-content repeat(${String(ie.length)}, 44px)`},children:[(0,W.jsx)(`span`,{}),ie.map(e=>(0,W.jsx)(`span`,{className:`studio-bench-matrix-head`,children:(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:A[e].label})},e)),D.map(r=>[(0,W.jsx)(S,{type:`supporting`,children:k[r].label},r),...ie.map(i=>(0,W.jsx)(yo,{scores:e,boundary:r,detector:i,figure:t,onOpen:n},i))])]})}),(0,W.jsx)(`div`,{className:`studio-bench-legend`,children:(0,W.jsx)(bo,{figure:t})})]})}var So=new Intl.NumberFormat(void 0,{style:`percent`,maximumFractionDigits:1});function Z(e){return`${e.toFixed(2)} ms`}function Co(e,t){if(e===void 0||t===void 0)return;let n=(e-t)*100;return`${n>0?`+`:``}${n.toFixed(1)} pts since the run before`}function wo(e){let t=e.flatMap(e=>e.ms?[e.ms]:[]),n=e.reduce((e,t)=>(t.ms?.p95??-1)>(e?.ms?.p95??-1)?t:e,void 0);return{attacks:e.reduce((e,t)=>e+(t.attacks??0),0),caught:e.reduce((e,t)=>e+(t.caught??0),0),benign:e.reduce((e,t)=>e+t.benign,0),fired:e.reduce((e,t)=>e+t.falseAlarms,0),...n?.ms&&{p95:n.ms.p95,slowest:n.detector},times:t,texts:0}}function To(e){return{...wo(e.flatMap(e=>e.detectors)),texts:e.reduce((e,t)=>e+t.samples,0)}}function Q(e,t){return t===0?void 0:e/t}function Eo(e){return ie.flatMap(t=>{let n=e.flatMap(e=>e.detectors.filter(e=>e.detector===t));return n.length===0?[]:[{detector:t,pool:wo(n)}]})}function Do(e,t,n,r){return e.flatMap(({detector:e,pool:i})=>{let a=t(i);return a===void 0?[]:[{id:e,name:A[e].label,value:a,detail:n(i),...r&&{fill:r}}]}).sort((e,t)=>t.value-e.value)}function Oo(e,t){return e===void 0?`—`:t(e)}function ko(e){let t=co(e.times);return[e.slowest?`${A[e.slowest].label}, the slowest detector`:``,t?`Median ≈ ${Z(t.median)} · mean ${Z(t.mean)}`:`This run kept no median or mean`]}function Ao(e){return D.flatMap(t=>{let n=e.filter(e=>e.boundary===t);if(n.length===0)return[];let r=n.reduce((e,t)=>e+t.samples,0);return[{id:t,name:k[t].label,detail:`${String(n.length)} datasets`,children:n.map(e=>({id:e.dataset,name:e.dataset,value:e.samples,detail:`${So.format(e.samples/r)} of this boundary`}))}]})}var jo=e=>`${e.toLocaleString()} texts`;function Mo({now:e,before:t,datasets:n}){let r=Q(e.caught,e.attacks),i=Q(e.fired,e.benign);return(0,W.jsxs)(Ln,{columns:{minWidth:140,repeat:`fit`},gap:2,children:[(0,W.jsx)(I,{label:`Recall`,value:Oo(r,e=>So.format(e)),detail:[`${e.caught.toLocaleString()} of ${e.attacks.toLocaleString()} attacks`,Co(r,t&&Q(t.caught,t.attacks))]}),(0,W.jsx)(I,{label:`False alarms`,value:Oo(i,e=>So.format(e)),detail:[`${e.fired.toLocaleString()} of ${e.benign.toLocaleString()} benign texts`,Co(i,t&&Q(t.fired,t.benign))]}),(0,W.jsx)(I,{label:`Detector time, p95`,value:Oo(e.p95,Z),detail:ko(e)}),(0,W.jsx)(I,{label:`Texts read`,value:e.texts.toLocaleString(),detail:`${String(n)} datasets`})]})}function No({title:e,lead:t,rows:n,format:r,max:i}){let a=n[0];return a?(0,W.jsx)(Cn,{title:e,value:r(a.value),note:`${a.name}, the ${t}`,children:(0,W.jsx)(En,{rows:n,format:r,...i!==void 0&&{max:i}})}):null}var $=e=>So.format(e);function Po({rows:e}){let t=e[0];return t?(0,W.jsx)(Cn,{title:`Recall by detector`,value:$(t.value),note:`${t.name}, the lowest`,children:(0,W.jsx)(Ua,{rows:e.map(e=>({...e,color:ho(e.value)})),format:$,max:1})}):null}function Fo({scores:e}){let t=Ao(e);if(t.length===0)return null;let n=e.reduce((e,t)=>e+t.samples,0);return(0,W.jsx)(Cn,{title:`Where the texts come from`,value:n.toLocaleString(),note:`texts at ${String(t.length)} ${t.length===1?`boundary`:`boundaries`}`,children:(0,W.jsx)(qa,{parts:t,format:jo})})}var Io={minWidth:360,repeat:`fit`};function Lo({scores:e}){let t=Eo(e);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ln,{columns:Io,gap:2,children:[(0,W.jsx)(Po,{rows:Do(t,e=>Q(e.caught,e.attacks),e=>`${String(e.caught)} of ${String(e.attacks)} attacks`).reverse()}),(0,W.jsx)(Fo,{scores:e})]}),(0,W.jsxs)(Ln,{columns:Io,gap:2,children:[(0,W.jsx)(No,{title:`False alarms by detector`,lead:`highest`,rows:Do(t,e=>Q(e.fired,e.benign),e=>`${String(e.fired)} of ${String(e.benign)} benign texts`,`shade1`),format:$}),(0,W.jsx)(No,{title:`Time by detector, p95`,lead:`slowest`,rows:Do(t,e=>e.p95,()=>`On its slowest dataset`,`shade2`),format:Z})]})]})}function Ro({scores:e,previous:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Mo,{now:To(e),...t&&{before:To(t)},datasets:e.length}),(0,W.jsx)(Lo,{scores:e})]})}function zo({score:e}){return(0,W.jsxs)(Ln,{columns:{minWidth:140,repeat:`fit`},gap:2,children:[(0,W.jsx)(I,{label:`Recall`,value:Oo(e.recall,$),detail:e.attacks===void 0?`This dataset does not label what it looks for`:`${String(e.caught)} of ${String(e.attacks)} attacks`}),(0,W.jsx)(I,{label:`False alarms`,value:Oo(e.falseAlarmRate,$),detail:`${String(e.falseAlarms)} of ${String(e.benign)} benign texts`}),(0,W.jsx)(I,{label:`p95 time alone`,value:e.ms?Z(e.ms.p95):`—`,detail:e.ms?[`p50 ${Z(e.ms.p50)}`,`max ${Z(e.ms.max)}`]:`Timed only inside a probe turn`})]})}function Bo({score:e,outcome:t}){if(t===`caught`)return null;let n=t===`missed`,r=(n?e.attacksByCategory.map(e=>({...e,count:e.samples-e.fired})):e.byCategory.map(e=>({...e,count:e.fired}))).filter(e=>e.count>0).map(e=>({id:e.category,name:e.category,value:e.count/e.samples,detail:`${String(e.count)} of ${String(e.samples)}`,fill:n?`clear`:`shade1`})).sort((e,t)=>t.value-e.value).slice(0,8);return(0,W.jsx)(No,{title:n?`Missed, by category`:`False alarms, by category`,lead:`highest`,rows:r,format:$,max:1})}var Vo={false_alarm:`False alarms`,missed:`Missed`,caught:`Caught`},Ho={train:`Train`,validate:`Validate`,test:`Test`,holdout:`Hold-out`};function Uo(e){return e===void 0?`—`:`${(e*100).toFixed(1)}%`}function Wo(e){return e===void 0?`—`:`${e.toFixed(2)} ms`}function Go(e,t){if(e===void 0||t===void 0)return``;let n=(e-t)*100;return Math.abs(n)<.05?`±0`:`${n>0?`+`:``}${n.toFixed(1)}`}function Ko(e,t,n){let r=new Map((t?.scores??[]).flatMap(e=>e.detectors.map(e=>[`${e.dataset}/${e.detector}`,e])));return e.flatMap(e=>e.detectors.map(e=>{let t=`${e.dataset}/${e.detector}`,i=r.get(t);return{id:t,dataset:e.dataset,role:e.role,boundary:e.boundary,detector:e.detector,recall:e.recall,falseAlarmRate:e.falseAlarmRate,p50:e.ms?.p50,p95:e.ms?.p95,recallBefore:i?.recall,falseAlarmBefore:i?.falseAlarmRate,thin:e.thin,running:e.dataset===n,score:e}}))}function qo(e){return e.startsWith(`other`)?`Other`:e}function Jo({id:e,facts:t}){return(0,W.jsxs)(z,{gap:1,align:`center`,wrap:`wrap`,children:[t?.source?(0,W.jsx)(An,{href:t.source,isExternalLink:!0,label:e}):(0,W.jsx)(S,{type:`supporting`,children:e}),t?.license&&(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:qo(t.license)})]})}function Yo({now:e,before:t}){let n=Go(e,t);return(0,W.jsxs)(z,{gap:1,align:`center`,children:[(0,W.jsx)(S,{type:`supporting`,children:Uo(e)}),n&&(0,W.jsx)(S,{type:`supporting`,color:`secondary`,children:n})]})}function Xo({rows:e,facts:t,onOpen:n}){let{sortedData:r,sortConfig:i}=Yn({data:e,defaultSort:[{sortKey:`falseAlarmRate`,direction:`descending`}]}),a=Gn(i);return(0,W.jsx)(In,{density:`compact`,dividers:`rows`,hasHover:!0,idKey:`id`,data:r,plugins:{sortable:a},columns:[{key:`detector`,header:`Detector`,width:x(1,{minWidth:120}),sortable:!0,renderCell:e=>(0,W.jsx)(T,{label:A[e.detector].label,variant:`ghost`,size:`sm`,onClick:()=>{n(e)}})},{key:`dataset`,header:`Dataset`,width:x(1,{minWidth:180}),sortable:!0,renderCell:e=>(0,W.jsxs)(z,{gap:1,align:`center`,wrap:`wrap`,children:[(0,W.jsx)(Jo,{id:e.dataset,facts:t.get(e.dataset)}),e.running&&(0,W.jsx)(p,{label:`Running`,size:`sm`,color:`blue`}),e.thin&&!e.running&&(0,W.jsx)(p,{label:`Few rows`,size:`sm`,color:`gray`})]})},{key:`recall`,header:`Recall`,width:v(110),sortable:!0,renderCell:e=>(0,W.jsx)(Yo,{now:e.recall,before:e.recallBefore})},{key:`falseAlarmRate`,header:`False alarms`,width:v(120),sortable:!0,renderCell:e=>(0,W.jsx)(Yo,{now:e.falseAlarmRate,before:e.falseAlarmBefore})},{key:`p50`,header:`p50`,width:v(90),sortable:!0,renderCell:e=>(0,W.jsx)(S,{type:`supporting`,children:Wo(e.p50)})},{key:`p95`,header:`p95`,width:v(90),sortable:!0,renderCell:e=>(0,W.jsx)(S,{type:`supporting`,children:Wo(e.p95)})}]})}function Zo(e){let t=Math.floor(e/60);return t>0?`${String(t)} min ${(e%60).toFixed(0)} s`:`${e.toFixed(0)} s`}function Qo(e){let t=Math.floor(e),n=e=>String(e).padStart(2,`0`),r=Math.floor(t/3600),i=Math.floor(t%3600/60),a=`${n(i)}:${n(t%60)}`;return r>0?`${String(r)}:${a}`:`${String(i)}:${n(t%60)}`}function $o({skipped:e}){return e.length===0?null:(0,W.jsx)(On,{status:`warning`,title:`${String(e.length)} datasets not run`,description:e.map(e=>e.dataset).join(`, `)})}var es=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function ts(e){let[t=``,n=``]=e.split(`T`),r=new Date(`${t}T${n.replace(/-/g,`:`)}`);return Number.isNaN(r.getTime())?e:es.format(r)}function ns({summary:e,previous:t}){return(0,W.jsxs)(B,{gap:2,children:[(0,W.jsxs)(jn,{columns:2,children:[(0,W.jsx)(H,{label:`Run`,children:ts(e.run)}),(0,W.jsx)(H,{label:`Commit`,children:e.commit.slice(0,8)}),(0,W.jsx)(H,{label:`Took`,children:Zo(e.seconds)}),(0,W.jsx)(H,{label:`Compared with`,children:t?ts(t.run):`—`})]}),(0,W.jsx)($o,{skipped:e.skipped})]})}function rs({live:e,previous:t}){let n=e.scores.length-+!!e.current+e.skipped.length,r=e.current?` · currently on ${e.current.dataset} · ${e.current.rows.toLocaleString()} rows`:``;return(0,W.jsxs)(B,{gap:2,children:[(0,W.jsx)(ro,{label:`${String(n)} of ${String(e.datasets.length)} datasets${r}`,value:n,max:e.datasets.length,hasValueLabel:!0,formatValueLabel:(t,n)=>`${String(Math.round(t/n*100))}% · ${Qo(e.seconds)}`}),(0,W.jsxs)(jn,{columns:2,children:[(0,W.jsx)(H,{label:`Run`,children:ts(e.run)}),(0,W.jsx)(H,{label:`Compared with`,children:t?ts(t.run):`—`})]}),(0,W.jsx)($o,{skipped:e.skipped})]})}function is({text:e,matches:t}){let n=t.filter(e=>e.length>0);if(n.length===0)return e;let r=[],i=0;for(;i<e.length;){let t=-1,a=``;for(let r of n){let n=e.indexOf(r,i);n>=0&&(t<0||n<t)&&(t=n,a=r)}if(t<0)break;r.push(e.slice(i,t)),r.push((0,W.jsx)(`mark`,{className:`studio-bench-mark`,children:a},t)),i=t+a.length}return r.push(e.slice(i)),r}function as(e,t){let n=se[t];return(e.events??[]).flatMap(e=>e.hits.flatMap(e=>e.rule===n&&e.match?[e.match]:[]))}function os(e){if(e.text===void 0)return`The run kept no text for this row.`;if(e.text.length>8e3)return`Longer than the probe takes.`}function ss({row:e,detector:t,payload:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),s=os(e),c=a?.answers?.find(t=>t.boundary===e.boundary);return(0,W.jsx)(b,{title:`${e.category} · ${e.id}`,children:(0,W.jsxs)(B,{gap:2,children:[(0,W.jsx)(S,{type:`supporting`,maxLines:8,children:e.text===void 0?`—`:(0,W.jsx)(is,{text:e.text,matches:as(e,t)})}),(0,W.jsxs)(z,{gap:2,align:`center`,wrap:`wrap`,children:[(0,W.jsx)(T,{label:`Probe the draft`,size:`sm`,variant:`ghost`,tooltip:s,isLoading:r,isDisabled:s!==void 0,onClick:()=>{e.text!==void 0&&(i(!0),O(n,e.text,t).then(e=>{o(e),i(!1)}))}}),c&&(0,W.jsx)(te,{answer:c}),a?.error&&(0,W.jsx)(S,{color:`secondary`,children:a.error})]})]})})}function cs(e,t,n,r){let[i,a]=(0,U.useState)(null),o=new URLSearchParams({run:t,dataset:n.dataset,detector:n.detector,outcome:r}).toString();return(0,U.useEffect)(()=>{let t=!0;return fetch(`${e}/bench/rows?${o}`).then(e=>e.ok?e.json():null).then(e=>{t&&a({key:o,rows:e?.rows??`failed`})}).catch(()=>{t&&a({key:o,rows:`failed`})}),()=>{t=!1}},[e,o]),i?.key===o?i.rows:void 0}function ls({endpoint:e,run:t,score:n,outcome:r,payload:i}){let a=cs(e,t,n,r);return a===void 0?null:a===`failed`?(0,W.jsx)(On,{status:`error`,title:`Couldn't read the run's rows.`}):a.length===0?(0,W.jsx)(S,{color:`secondary`,children:`None.`}):(0,W.jsx)(B,{gap:3,children:a.map(e=>(0,W.jsx)(ss,{row:e,detector:n.detector,payload:i},e.id))})}function us({row:e,facts:t,run:n,endpoint:r,payload:i,isClose:a,onBack:o}){let{score:s}=e,c=ao.filter(e=>e===`false_alarm`||s.attacks),[l,d]=(0,U.useState)(`false_alarm`);return(0,W.jsxs)(B,{gap:4,padding:4,children:[(0,W.jsx)(z,{children:(0,W.jsx)(T,{label:a?`Close`:`Back`,variant:`ghost`,size:`sm`,icon:(0,W.jsx)(u,{icon:Nn}),onClick:o})}),(0,W.jsx)(yn,{label:(0,W.jsx)(S,{weight:`semibold`,children:A[s.detector].label}),description:A[s.detector].doc,align:`start`}),(0,W.jsxs)(jn,{children:[(0,W.jsx)(H,{label:`Dataset`,children:(0,W.jsx)(Jo,{id:s.dataset,facts:t})}),(0,W.jsx)(H,{label:`Boundary`,children:k[s.boundary].label}),(0,W.jsx)(H,{label:`Default action`,children:ae[s.defaultAction].label})]}),(0,W.jsx)(zo,{score:s}),(0,W.jsx)(Dn,{label:`Rows`,size:`sm`,value:l,onChange:e=>{d(c.find(t=>t===e)??`false_alarm`)},children:c.map(e=>(0,W.jsx)(V,{value:e,label:Vo[e]},e))}),(0,W.jsx)(Bo,{score:s,outcome:l}),(0,W.jsx)(ls,{endpoint:r,run:n,score:s,outcome:l,payload:i})]})}function ds(e){return io.filter(t=>e.some(e=>e.role===t))}function fs(e){let{live:t,summary:n}=e;return{previous:t?n:e.previous,scores:t?.scores??n?.scores??[],run:t?.run??n?.run??``,facts:new Map([...n?.datasets??[],...t?.datasets??[]].map(e=>[e.id,e]))}}function ps({roles:e,role:t,onChange:n}){return(0,W.jsxs)(Dn,{label:`Datasets`,size:`sm`,value:t,onChange:t=>{n(e.find(e=>e===t)??`all`)},children:[(0,W.jsx)(V,{value:`all`,label:`All`}),e.map(e=>(0,W.jsx)(V,{value:e,label:Ho[e]},e))]})}function ms({view:e,figure:t,place:n,onView:r,onFigure:i,onClear:a}){return(0,W.jsxs)(z,{gap:2,align:`center`,wrap:`wrap`,children:[(0,W.jsxs)(Dn,{label:`View`,size:`sm`,value:e,onChange:e=>{r(e===`matrix`?`matrix`:`table`)},children:[(0,W.jsx)(V,{value:`table`,label:`Table`}),(0,W.jsx)(V,{value:`matrix`,label:`Matrix`})]}),e===`matrix`&&(0,W.jsx)(Dn,{label:`Shaded by`,size:`sm`,value:t,onChange:e=>{i(lo.find(t=>t===e)??`recall`)},children:lo.map(e=>(0,W.jsx)(V,{value:e,label:uo[e]},e))}),e===`table`&&n&&(0,W.jsx)(p,{size:`sm`,label:`${A[n.detector].label} at ${k[n.boundary].label}`,onRemove:a})]})}function hs({answer:e,endpoint:t,payload:n,isWide:r,aside:i}){let{previous:a,scores:s,run:c,facts:l}=fs(e),[u,d]=(0,U.useState)(`all`),[f,p]=(0,U.useState)(`table`),[m,h]=(0,U.useState)(`recall`),[g,_]=(0,U.useState)(null),[v,b]=(0,U.useState)(null),x=s.filter(e=>u===`all`||e.role===u),C=Ko(x,a,e.live?.current?.dataset).filter(e=>!g||e.boundary===g.boundary&&e.detector===g.detector),w=(0,W.jsxs)(B,{gap:4,padding:4,children:[(0,W.jsxs)(z,{gap:3,align:`center`,children:[(0,W.jsx)(o,{size:`fill`,children:(0,W.jsx)(S,{weight:`semibold`,children:`Guardrails health`})}),i]}),e.live?(0,W.jsx)(rs,{live:e.live,previous:a}):e.summary&&(0,W.jsx)(ns,{summary:e.summary,previous:a}),(0,W.jsx)(ps,{roles:ds(s),role:u,onChange:d}),(0,W.jsx)(Ro,{scores:x,previous:a?.scores.filter(e=>u===`all`||e.role===u)}),(0,W.jsx)(ms,{view:f,figure:m,place:g,onView:p,onFigure:h,onClear:()=>{_(null)}}),f===`matrix`?(0,W.jsx)(xo,{scores:x,figure:m,onOpen:(e,t)=>{_({boundary:e,detector:t}),p(`table`)}}):(0,W.jsx)(Xo,{rows:C,facts:l,onOpen:b})]});return(0,W.jsx)(y,{isWide:r,label:`Guardrails health`,detailLabel:v?A[v.detector].label:``,overview:w,detail:v&&(0,W.jsx)(us,{row:v,facts:l.get(v.dataset),run:c,endpoint:t,payload:n,isClose:r,onBack:()=>{b(null)}},v.id)})}function gs(e){return fetch(`${e}/bench`).then(e=>e.ok?e.json():null).catch(()=>null)}function _s(e){let[t,n]=(0,U.useState)(e?void 0:null);(0,U.useEffect)(()=>{if(!e)return;let t=!0;return gs(e).then(e=>{t&&n(e)}),()=>{t=!1}},[e]);let r=t?.live?.run;return(0,U.useEffect)(()=>{if(!e||!r||typeof EventSource>`u`)return;let t=new EventSource(`${e}/bench/live?run=${encodeURIComponent(r)}`);return t.onmessage=e=>{try{let t=JSON.parse(e.data);n(e=>e&&{...e,live:t})}catch{}},t.addEventListener(`ended`,()=>{t.close(),gs(e).then(n)}),()=>{t.close()}},[e,r]),t}function vs({payload:e,isWide:t}){let n=Pn()?.endpoint,r=_s(n),[i,a]=(0,U.useState)(`test`);if(!r||!n)return(0,W.jsx)(re,{payload:e,isWide:t});let o=(0,W.jsxs)(Dn,{label:`Guardrails`,size:`sm`,value:i,onChange:e=>{a(e===`health`?`health`:`test`)},children:[(0,W.jsx)(V,{value:`test`,label:`Test`,icon:(0,W.jsx)(u,{icon:Mn,size:`sm`})}),(0,W.jsx)(V,{value:`health`,label:`Health`,icon:(0,W.jsx)(u,{icon:Rn,size:`sm`})})]});return i===`test`?(0,W.jsx)(re,{payload:e,isWide:t,aside:o}):(r.live?.scores??r.summary?.scores??[]).length===0?(0,W.jsxs)(B,{gap:4,padding:4,children:[(0,W.jsx)(z,{hAlign:`end`,children:o}),(0,W.jsx)(kn,{icon:(0,W.jsx)(u,{icon:Rn,size:`lg`,color:`secondary`}),title:r.live?`The bench run is starting.`:`The last bench run scored nothing.`})]}):(0,W.jsx)(hs,{answer:r,endpoint:n,payload:e,isWide:t,aside:o})}export{vs as GuardrailPane};