@rfkit/charts 1.12.1 → 1.13.0
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.
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { RendererType } from '@rfkit/renderer';
|
|
1
2
|
import type React from 'react';
|
|
2
3
|
import type { ParamsProps } from '../../types';
|
|
3
4
|
export interface Props extends ParamsProps {
|
|
4
5
|
heatmapDefaultData?: Array<Array<number>>;
|
|
6
|
+
renderer?: RendererType;
|
|
5
7
|
}
|
|
6
8
|
declare const Chart: React.FC<Props>;
|
|
7
9
|
export default Chart;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererType } from '@rfkit/renderer';
|
|
1
2
|
import type { ProcessingOptions } from '@rfkit/spectrum-analyzer';
|
|
2
3
|
import { type UseSpectrumChartTypeProps as SpectrumChartTypeProps } from '../../hooks/spectrum';
|
|
3
4
|
import { type OccupancyPortalProps } from '../../modules/OccupancyPortal';
|
|
@@ -6,6 +7,7 @@ export interface Props extends SpectrumChartTypeProps, ParamsProps, OccupancyPor
|
|
|
6
7
|
children?: React.ReactNode;
|
|
7
8
|
touch?: boolean;
|
|
8
9
|
processing?: Partial<ProcessingOptions>;
|
|
10
|
+
renderer?: RendererType;
|
|
9
11
|
}
|
|
10
12
|
declare const Chart: React.FC<Props>;
|
|
11
13
|
export default Chart;
|
package/index.js
CHANGED
|
@@ -3562,7 +3562,7 @@ ${buildRule(` ${t.systemDark}`,n)}
|
|
|
3562
3562
|
*
|
|
3563
3563
|
* This source code is licensed under the ISC license.
|
|
3564
3564
|
* See the LICENSE file in the root directory of this source tree.
|
|
3565
|
-
*/let hasA11yProp=e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},LucideContext=createContext({});function LucideProvider({children:e,size:t,color:r,strokeWidth:n,absoluteStrokeWidth:a,className:i}){let o=useMemo(()=>({size:t,color:r,strokeWidth:n,absoluteStrokeWidth:a,className:i}),[t,r,n,a,i]);return createElement(LucideContext.Provider,{value:o},e)}let useLucideContext=()=>useContext(LucideContext),Icon_Icon=forwardRef(({color:e,size:t,strokeWidth:r,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...l},s)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:h="currentColor",className:p=""}=useLucideContext()??{},f=n??d?24*Number(r??u)/Number(t??c):r??u;return external_react_createElement("svg",{ref:s,...defaultAttributes,width:t??c??defaultAttributes.width,height:t??c??defaultAttributes.height,stroke:e??h,strokeWidth:f,className:mergeClasses("lucide",p,a),...!i&&!hasA11yProp(l)&&{"aria-hidden":"true"},...l},[...o.map(([e,t])=>external_react_createElement(e,t)),...Array.isArray(i)?i:[i]])}),createLucideIcon=(e,t)=>{let r=forwardRef(({className:r,...n},a)=>external_react_createElement(Icon_Icon,{ref:a,iconNode:t,className:mergeClasses(`lucide-${toKebabCase(toPascalCase(e))}`,`lucide-${e}`,r),...n}));return r.displayName=toPascalCase(e),r},__iconNode=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],Move=createLucideIcon("move",__iconNode),DEFAULT_CONFIG={enabled:!0,defaultRect:{position:70,height:30,leftPosition:0,width:100},minSize:0,maxSize:100,snapThreshold:2,onChange:()=>{},onDragEnd:()=>{},preserveDefaultRect:!1,bounds:{bottom:100,left:0,right:100,top:0}},useDragSelect=(e={})=>{let{enabled:t,defaultRect:r,minSize:n,minWidth:a,minHeight:i,maxSize:o,snapThreshold:l,onChange:s,onDragEnd:c,preserveDefaultRect:u,bounds:d}={...DEFAULT_CONFIG,...e},h=a??n,p=i??n,[f,m]=external_react_useState({position:r.position??DEFAULT_CONFIG.defaultRect.position,height:u?r.height??DEFAULT_CONFIG.defaultRect.height:Math.min(r.height??DEFAULT_CONFIG.defaultRect.height,o),leftPosition:r.leftPosition??DEFAULT_CONFIG.defaultRect.leftPosition,width:r.width??DEFAULT_CONFIG.defaultRect.width}),[g,b]=external_react_useState(!1),[v,w]=external_react_useState(null),y=external_react_useRef(null),x=external_react_useRef({x:0,y:0,rect:f}),k=external_react_useRef(f);k.current=f,external_react_useEffect(()=>{if(!g&&r){let e={position:r.position??f.position,height:void 0!==r.height?u?r.height:Math.min(r.height,o):f.height,leftPosition:r.leftPosition??f.leftPosition,width:r.width??f.width};(Math.abs(e.position-f.position)>.01||Math.abs(e.height-f.height)>.01||Math.abs(e.leftPosition-f.leftPosition)>.01||Math.abs(e.width-f.width)>.01)&&m(e)}},[r?.position,r?.height,r?.leftPosition,r?.width,g,o,u]);let S=external_react_useCallback((e,r,n=f)=>{t&&(e.preventDefault(),b(!0),w(r),x.current={x:e.clientX,y:e.clientY,rect:{...n}})},[t,f]),D=external_react_useCallback(e=>{if(!g||!y.current)return;let t=y.current,{x:r,y:n,rect:a}=x.current,i=(e.clientY-n)/t.clientHeight*100,c=(e.clientX-r)/t.clientWidth*100,{position:u,height:f,leftPosition:b,width:w}=a;switch(v){case"top":{let e=a.position+a.height;u=Math.max(d.top,Math.min(a.position+i,e-p)),(f=e-u)>o&&(f=o,u=e-o);break}case"bottom":f=Math.max(p,Math.min(o,a.height+i,d.bottom-a.position));break;case"left":{let e=a.leftPosition+a.width;b=Math.max(d.left,Math.min(a.leftPosition+c,e-h)),(w=e-b)>o&&(w=o,b=e-o);break}case"right":w=Math.max(h,Math.min(o,a.width+c,d.right-a.leftPosition));break;case"middle":u=Math.max(d.top,Math.min(a.position+i,d.bottom-a.height)),b=Math.max(d.left,Math.min(a.leftPosition+c,d.right-a.width))}u<d.top+l&&(u=d.top),u+f>d.bottom-l&&(u=d.bottom-f),b<d.left+l&&(b=d.left),b+w>d.right-l&&(b=d.right-w);let S={position:u,height:f,leftPosition:b,width:w};k.current=S,m(S),s(S)},[g,v,h,p,o,l,d.top,d.bottom,d.left,d.right,s]),M=external_react_useCallback(()=>{g&&c(k.current),b(!1),w(null)},[g,c]);external_react_useEffect(()=>{if(t&&g)return document.addEventListener("mousemove",D),document.addEventListener("mouseup",M),document.addEventListener("mouseleave",M),window.addEventListener("blur",M),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",M),document.removeEventListener("mouseleave",M),window.removeEventListener("blur",M)}},[t,g,D,M]);let F=external_react_useCallback(e=>{let t={...f,...e};m(t),s(t)},[f,s]);return{rect:f,isDragging:g,dragType:v,containerRef:y,handleMouseDown:S,resetRect:F,setRect:e=>{m(e),s(e)}}},SURFACE_GAP=4,MIN_VISUAL_SPAN=14,HANDLE_HIT_SIZE=10,VIEWPORT_BOUNDS={bottom:100,left:0,right:100,top:0},PROJECTED_EDGE_HANDLE_CLASS="pointer-events-auto absolute z-[2] appearance-none rounded-[3px] border-0 p-0 transition-[background-color,box-shadow] duration-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring [background:var(--mix-foreground-18)] [box-shadow:inset_0_0_0_1px_var(--mix-background-72),0_1px_3px_var(--mix-foreground-28)] hover:[background:var(--mix-foreground-32)] hover:[box-shadow:inset_0_0_0_1px_var(--mix-background-86),0_1px_4px_var(--mix-foreground-42)]",PROJECTED_MOVE_HANDLE_CLASS="pointer-events-auto absolute z-[3] flex size-5 -translate-x-1/2 -translate-y-1/2 cursor-move items-center justify-center appearance-none rounded-sm border-0 p-0 text-foreground outline-none transition-[background-color,box-shadow] duration-100 focus-visible:ring-1 focus-visible:ring-ring [background:var(--mix-bg76-fg24)] [box-shadow:0_0_0_1px_var(--mix-background-82),0_1px_4px_var(--mix-foreground-32)] hover:[background:var(--mix-bg64-fg36)]",ProjectedEdgeHandle=({ariaLabel:e,className:t,direction:r,onMouseDown:n,style:a})=>/*#__PURE__*/jsx_runtime_jsx("button",{type:"button",tabIndex:-1,"aria-label":e,className:cn_cn(PROJECTED_EDGE_HANDLE_CLASS,t),style:a,onMouseDown:n,children:/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:cn_cn("pointer-events-none absolute left-1/2 top-1/2 rounded-full bg-foreground/85","horizontal"===r?"h-[2px] -translate-x-1/2 -translate-y-1/2":"w-[2px] -translate-x-1/2 -translate-y-1/2"),style:"horizontal"===r?{width:"clamp(10px, 18%, 24px)"}:{height:"clamp(10px, 18%, 24px)"}})}),DragSelectBox_clamp=(e,t,r)=>Math.min(Math.max(e,t),r),isComparableLabelValue=e=>"string"==typeof e||"number"==typeof e,normalizeLabels=e=>{if(!e)return e;let t={...e};return isComparableLabelValue(t.left)&&isComparableLabelValue(t.right)&&String(t.left)===String(t.right)&&(t.right=void 0),isComparableLabelValue(t.top)&&isComparableLabelValue(t.bottom)&&String(t.top)===String(t.bottom)&&(t.top=void 0),t},getDisplaySpan=({start:e,length:t,minLength:r,maxLength:n})=>{let a=Math.max(0,t),i=Math.min(Math.max(a,r),n),o=e+a/2,l=o-i/2,s=o+i/2;l<0&&(s=Math.min(n,s-l),l=0),s>n&&(l=Math.max(0,l-(s-n)),s=n);let c=s-l;return{start:l,end:s,length:c}},getProjectedDisplaySpan=({start:e,length:t,minLength:r})=>{let n=Math.max(0,t),a=Math.max(n,r),i=e+n/2-a/2;return{start:i,end:i+a,length:a}},getDisplayRectBox=({rect:e,containerWidth:t,containerHeight:r,variant:n="contained"})=>{let a=e.leftPosition/100*t,i=e.position/100*r,o=e.width/100*t,l=e.height/100*r;if("projected"===n){let e=getProjectedDisplaySpan({start:a,length:o,minLength:MIN_VISUAL_SPAN}),t=getProjectedDisplaySpan({start:i,length:l,minLength:MIN_VISUAL_SPAN});return{left:e.start,top:t.start,width:e.length,height:t.length,right:e.end,bottom:t.end,centerX:e.start+e.length/2,centerY:t.start+t.length/2}}let s=getDisplaySpan({start:a,length:o,minLength:MIN_VISUAL_SPAN,maxLength:t}),c=getDisplaySpan({start:i,length:l,minLength:MIN_VISUAL_SPAN,maxLength:r});return{left:s.start,top:c.start,width:s.length,height:c.length,right:s.end,bottom:c.end,centerX:s.start+s.length/2,centerY:c.start+c.length/2}},getOverlapArea=(e,t)=>Math.max(0,Math.min(e.left+e.width,t.left+t.width)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.top+e.height,t.top+t.height)-Math.max(e.top,t.top)),placementsEqual=(e,t)=>Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(r=>{let n=e[r],a=t[r];return n&&a&&.5>Math.abs(n.left-a.left)&&.5>Math.abs(n.top-a.top)}),createOverlayBox=({left:e,top:t,size:r,containerWidth:n,containerHeight:a,score:i})=>{let o=Math.max(0,n-r.width),l=Math.max(0,a-r.height),s=DragSelectBox_clamp(e,0,o),c=DragSelectBox_clamp(t,0,l),u=Math.abs(s-e)+Math.abs(c-t);return{left:s,top:c,width:r.width,height:r.height,score:i+2*u}},getCandidateBoxes=({key:e,size:t,rectBox:r,containerWidth:n,containerHeight:a})=>{let i=[],o="middle"===e&&(r.width<=t.width+2*SURFACE_GAP||r.height<=t.height+2*SURFACE_GAP),l=(e,r,o)=>{i.push(createOverlayBox({left:e,top:r,size:t,containerWidth:n,containerHeight:a,score:o}))},s=r.left-t.width-SURFACE_GAP,c=r.right+SURFACE_GAP,u=r.top-t.height-SURFACE_GAP,d=r.bottom+SURFACE_GAP,h=r.left+SURFACE_GAP,p=r.right-t.width-SURFACE_GAP,f=r.top+SURFACE_GAP,m=r.bottom-t.height-SURFACE_GAP,g=r.centerX-t.width/2,b=r.centerY-t.height/2;switch(e){case"left":l(s,b,0),l(h,b,6),l(s,r.top,10),l(s,r.bottom-t.height,11),l(h,r.top,16),l(h,r.bottom-t.height,17),l(r.left,u,22),l(r.left,d,24);break;case"right":l(c,b,0),l(p,b,6),l(c,r.top,10),l(c,r.bottom-t.height,11),l(p,r.top,16),l(p,r.bottom-t.height,17),l(r.right-t.width,u,22),l(r.right-t.width,d,24);break;case"top":l(g,u,0),l(g,f,6),l(r.left,u,10),l(r.right-t.width,u,11),l(r.left+SURFACE_GAP,f,16),l(r.right-t.width-SURFACE_GAP,f,17),l(s,r.top,24),l(c,r.top,25);break;case"bottom":l(g,d,0),l(g,m,6),l(r.left,d,10),l(r.right-t.width,d,11),l(r.left+SURFACE_GAP,m,16),l(r.right-t.width-SURFACE_GAP,m,17),l(s,r.bottom-t.height,24),l(c,r.bottom-t.height,25);break;case"middle":o?(l(g,u,0),l(g,d,1),l(c,b,2),l(s,b,3),l(c,u,4),l(c,d,5),l(s,u,6),l(s,d,7),l(g,b,12)):(l(g,b,0),l(g,u,8),l(g,d,9),l(c,b,10),l(s,b,11),l(r.left,u,14),l(r.right-t.width,u,15),l(r.left,d,16),l(r.right-t.width,d,17))}return i},DragSelectBox=({enabled:e,defaultRect:t,minSize:r=0,minWidth:n,minHeight:a,maxSize:i=100,snapThreshold:o=2,onChange:l,onDragStart:s,onDragEnd:c,children:u,labels:d,className:h="",zIndex:p=7,showBoundaryLines:f=!1,variant:m="contained",interactionBounds:g=VIEWPORT_BOUNDS})=>{let b=external_react_useMemo(()=>normalizeLabels(d),[d?.top,d?.bottom,d?.left,d?.right]),{rect:v,containerRef:w,handleMouseDown:y}=useDragSelect({enabled:e,defaultRect:t,minSize:r,minWidth:n,minHeight:a,maxSize:"projected"===m?Math.max(i,g.right-g.left,g.bottom-g.top):i,snapThreshold:o,onChange:l,onDragEnd:c,preserveDefaultRect:"projected"===m,bounds:g}),x=v.leftPosition+Math.max(0,v.width),k=v.position+Math.max(0,v.height),S="projected"!==m||x>0&&v.leftPosition<100&&k>0&&v.position<100,D=DragSelectBox_clamp(v.leftPosition,0,100),M=DragSelectBox_clamp(x,0,100),F=DragSelectBox_clamp(v.position,0,100),C=DragSelectBox_clamp(k,0,100),E=M>D,N=C>F,A="projected"===m&&(v.leftPosition<VIEWPORT_BOUNDS.left||x>VIEWPORT_BOUNDS.right||v.position<VIEWPORT_BOUNDS.top||k>VIEWPORT_BOUNDS.bottom),T={left:(D+M)/2,top:(F+C)/2},[I,P]=external_react_useState(0),[z,L]=external_react_useState({width:0,height:0}),[O,q]=external_react_useState({}),_=external_react_useRef(null),$=external_react_useRef(null),j=external_react_useRef(null),H=external_react_useRef(null),B=external_react_useRef(null);external_react_useEffect(()=>{if(!e||!S||"u"<typeof ResizeObserver)return;let t=new ResizeObserver(()=>{P(e=>e+1)});return[w.current,_.current,$.current,j.current,H.current,B.current].filter(e=>null!==e).forEach(e=>{t.observe(e)}),()=>t.disconnect()},[e,S,!!b?.top,!!b?.bottom,!!b?.left,!!b?.right,!!u]),useLayoutEffect(()=>{let t=w.current;if(!e||!S||!t)return void q(e=>Object.keys(e).length>0?{}:e);let r=t.clientWidth,n=t.clientHeight;if(r<=0||n<=0)return;L(e=>e.width===r&&e.height===n?e:{width:r,height:n});let a=[["top",_.current],["bottom",$.current],["left",j.current],["right",H.current],["middle",B.current]].reduce((e,[t,r])=>(r&&(e[t]={width:r.offsetWidth,height:r.offsetHeight}),e),{}),i=getDisplayRectBox({rect:v,containerWidth:r,containerHeight:n,variant:m}),o={middle:4,bottom:3,left:2,right:2,top:1},l=["top","bottom","left","right","middle"].filter(e=>a[e]).sort((e,t)=>{let r=o[t]-o[e];if(0!==r)return r;let n=(a[e]?.width??0)*(a[e]?.height??0);return(a[t]?.width??0)*(a[t]?.height??0)-n}),s=[],c={};l.forEach(e=>{let t=a[e];if(!t)return;let o=getCandidateBoxes({key:e,size:t,rectBox:i,containerWidth:r,containerHeight:n}).map(e=>{let t=s.reduce((t,r)=>t+getOverlapArea(e,r),0),r=e.score+(t>0?2e4+10*t:0),n=Math.max(1,e.width*e.height);return{...e,overlapArea:t,overlapRatio:t/n,totalScore:r}}),l=o.filter(e=>0===e.overlapArea).sort((e,t)=>e.totalScore-t.totalScore)[0]??null??o.sort((e,t)=>e.totalScore-t.totalScore)[0]??null;!l||"middle"!==e&&l.overlapRatio>.2||(c[e]={left:l.left,top:l.top},s.push(l))}),q(e=>placementsEqual(e,c)?e:c)},[e,S,v.position,v.height,v.leftPosition,v.width,I,!!b?.top,!!b?.bottom,!!b?.left,!!b?.right,!!u,m]);let G={fontSize:"var(--size-font-second)",color:"var(--foreground)",border:"1px solid var(--border)",borderRadius:"var(--radius-control)",background:"var(--mix-background-80)"},U=e=>{let t=O[e];return{left:t?.left??0,top:t?.top??0,visibility:t?"visible":"hidden"}},W=external_react_useMemo(()=>z.width<=0||z.height<=0?null:getDisplayRectBox({rect:v,containerWidth:z.width,containerHeight:z.height,variant:m}),[v.position,v.height,v.leftPosition,v.width,z.width,z.height,m]),V=W?Math.max(0,Math.min(6,W.width/4)):6,Y=W?Math.max(0,Math.min(6,W.height/4)):6,X=W?{top:W.top,height:W.height,left:W.left,width:W.width}:{top:`${v.position}%`,height:`${v.height}%`,left:`${v.leftPosition}%`,width:`${v.width}%`},K=e=>{let t={...v};switch(e){case"top":v.position<VIEWPORT_BOUNDS.top&&(t.position=VIEWPORT_BOUNDS.top,t.height=Math.max(0,v.position+v.height-VIEWPORT_BOUNDS.top));break;case"bottom":k>VIEWPORT_BOUNDS.bottom&&(t.height=Math.max(0,VIEWPORT_BOUNDS.bottom-v.position));break;case"left":v.leftPosition<VIEWPORT_BOUNDS.left&&(t.leftPosition=VIEWPORT_BOUNDS.left,t.width=Math.max(0,x-VIEWPORT_BOUNDS.left));break;case"right":x>VIEWPORT_BOUNDS.right&&(t.width=Math.max(0,VIEWPORT_BOUNDS.right-v.leftPosition))}return t},Q=(e,t,r)=>{s?.(t)!==!1&&(e.preventDefault(),e.stopPropagation(),y(e,t,r))};return e?/*#__PURE__*/jsxs(Zoom_ZoomViewportLayer,{className:cn_cn("left-0 top-0 h-full w-full overflow-hidden",h),ref:w,style:{zIndex:p},children:[f&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 h-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 top-0 w-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 right-0 top-0 w-px bg-border"})]}),S&&/*#__PURE__*/jsxs("div",{className:"group pointer-events-none absolute box-border",style:X,children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 border-[2px] border-dashed border-foreground group-hover:border-[4px]"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute left-0 w-full cursor-ns-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{top:-HANDLE_HIT_SIZE/2,height:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"top")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute left-0 w-full cursor-ns-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{bottom:-HANDLE_HIT_SIZE/2,height:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"bottom")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute top-0 h-full cursor-ew-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{left:-HANDLE_HIT_SIZE/2,width:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"left")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute top-0 h-full cursor-ew-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{right:-HANDLE_HIT_SIZE/2,width:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"right")}),!A&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute cursor-move [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-20)]",style:{top:Y,bottom:Y,left:V,right:V},onMouseDown:e=>Q(e,"middle")})]}),A&&S&&E&&N&&/*#__PURE__*/jsx_runtime_jsx("button",{type:"button",tabIndex:-1,"aria-label":"移动框选范围",title:"移动框选范围",className:PROJECTED_MOVE_HANDLE_CLASS,style:{left:`clamp(10px, ${T.left}%, calc(100% - 10px))`,top:`clamp(10px, ${T.top}%, calc(100% - 10px))`},onMouseDown:e=>Q(e,"middle"),children:/*#__PURE__*/jsx_runtime_jsx(Move,{"aria-hidden":"true",className:"pointer-events-none size-3",strokeWidth:1.75})}),"projected"===m&&S&&/*#__PURE__*/jsxs(Fragment,{children:[v.position<0&&E&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选上边界",direction:"horizontal",className:"top-0 h-[10px] cursor-ns-resize",style:{left:`${D}%`,minWidth:HANDLE_HIT_SIZE,width:`${M-D}%`},onMouseDown:e=>Q(e,"top",K("top"))}),k>100&&E&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选下边界",direction:"horizontal",className:"bottom-0 h-[10px] cursor-ns-resize",style:{left:`${D}%`,minWidth:HANDLE_HIT_SIZE,width:`${M-D}%`},onMouseDown:e=>Q(e,"bottom",K("bottom"))}),v.leftPosition<0&&N&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选左边界",direction:"vertical",className:"left-0 w-[10px] cursor-ew-resize",style:{height:`${C-F}%`,minHeight:HANDLE_HIT_SIZE,top:`${F}%`},onMouseDown:e=>Q(e,"left",K("left"))}),x>100&&N&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选右边界",direction:"vertical",className:"right-0 w-[10px] cursor-ew-resize",style:{height:`${C-F}%`,minHeight:HANDLE_HIT_SIZE,top:`${F}%`},onMouseDown:e=>Q(e,"right",K("right"))})]}),S&&u&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:B,className:"pointer-events-none absolute",style:U("middle"),children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"flex items-start gap-0.5 whitespace-nowrap p-[var(--size-gap-base)]",style:{fontSize:"var(--size-font-second)",color:"var(--foreground)",border:"1px solid var(--border)",borderRadius:"var(--radius-control)",background:"var(--mix-secondary-80)"},children:u})}),S&&b?.left&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:j,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("left")},children:b.left}),S&&b?.right&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:H,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("right")},children:b.right}),S&&b?.top&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:_,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("top")},children:b.top}),S&&b?.bottom&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:$,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("bottom")},children:b.bottom})]}):null},components_DragSelectBox=DragSelectBox,sliderInfo_PRECISION=1e6,sliderInfo_clamp=(e,t,r)=>Math.min(r,Math.max(t,e)),resolveFrequencyExtent=e=>{if(!e)return null;let t=Number(e(0)),r=Number(e(100));return Number.isFinite(t)&&Number.isFinite(r)&&t!==r?[t,r]:null},resolveContinuousFrequencyFromSegments=(e,t,r)=>{if(!t?.length)return null;let n=100*sliderInfo_clamp(e,0,1),a=t.length-1;for(let e=0;e<t.length;e+=1){let i=t[e],o=Math.min(i.progress[0],i.progress[1]),l=Math.max(i.progress[0],i.progress[1]);if(!("start"===r?n>=o&&(n<l||e===a&&n<=l):(n>o||0===e)&&n<=l))continue;let s=l-o,c=s?(n-o)/s:0;return i.start+(i.stop-i.start)*c}return null},resolveFrequencyFromRatio=(e,t,r,n)=>{let a=r?.(100*sliderInfo_clamp(e,0,1)),i=void 0===a?0/0:Number(a);return Number.isFinite(i)?i:resolveContinuousFrequencyFromSegments(e,t,n)},resolveRatioFromFrequency=(e,t,r)=>{if(t?.length){let r=null;for(let n of t){let t=n.start,a=n.stop,i=Math.min(t,a),o=Math.max(t,a),l=n.progress[0]/100,s=n.progress[1]/100;if(e>=i&&e<=o){let r=a-t;return sliderInfo_clamp(l+(s-l)*(r?(e-t)/r:0),0,1)}for(let n of[{distance:Math.abs(e-t),ratio:l},{distance:Math.abs(e-a),ratio:s}])(!r||n.distance<r.distance)&&(r=n)}if(r)return sliderInfo_clamp(r.ratio,0,1)}let n=resolveFrequencyExtent(r);return n?sliderInfo_clamp((e-n[0])/(n[1]-n[0]),0,1):null},resolveHeatmapSliderFrequencyRatioRange=({frequencyFormat:e,frequencyRange:t,segments:r})=>{let n=resolveRatioFromFrequency(t[0],r,e),a=resolveRatioFromFrequency(t[1],r,e);return null===n||null===a?null:[Math.min(n,a),Math.max(n,a)]},resolveFrequencyRangeFromRatios=(e,t,r)=>{let n=resolveFrequencyFromRatio(e[0],t,r,"start"),a=resolveFrequencyFromRatio(e[1],t,r,"end");return null===n||null===a?null:[Math.min(n,a),Math.max(n,a)]},resolveHeatmapSliderSelectionFromRect=({frequencyFormat:e,rect:t,segments:r,waterfallSnapshot:n})=>{let a=resolveHeatmapProjectedContinuousSourceRange(n,{startLeft:t.leftPosition,endLeft:t.leftPosition+t.width,startTop:t.position+t.height,endTop:t.position});if(!a||n.sourceSize.width<=0)return null;let i=[a.x[0]/n.sourceSize.width,a.x[1]/n.sourceSize.width];return{frequency:resolveFrequencyRangeFromRatios(i,r,e),x:i,y:a.y}},resolveHeatmapSliderSelectionFromInteraction=({dragType:e,frequencyFormat:t,rect:r,segments:n,startSelection:a,waterfallSnapshot:i})=>{let o=resolveHeatmapSliderSelectionFromRect({frequencyFormat:t,rect:r,segments:n,waterfallSnapshot:i});if(!o||!a)return o;switch(e){case"left":return{frequency:o.frequency&&a.frequency?[o.frequency[0],a.frequency[1]]:o.frequency,x:[o.x[0],a.x[1]],y:a.y};case"right":return{frequency:o.frequency&&a.frequency?[a.frequency[0],o.frequency[1]]:o.frequency,x:[a.x[0],o.x[1]],y:a.y};case"top":return{frequency:a.frequency,x:a.x,y:[a.y[0],o.y[1]]};case"bottom":return{frequency:a.frequency,x:a.x,y:[o.y[0],a.y[1]]};case"middle":return o}},resolveHeatmapSliderSelectionSourceRange=({selection:e,waterfallSnapshot:t})=>{let{sourceSize:r}=t;if(r.width<=0||r.height<=0)return null;let n=sliderInfo_clamp(Math.min(e.x[0],e.x[1]),0,1),a=sliderInfo_clamp(Math.max(e.x[0],e.x[1]),n,1),i=sliderInfo_clamp(Math.min(e.y[0],e.y[1]),0,r.height),o=sliderInfo_clamp(Math.max(e.y[0],e.y[1]),i,r.height);return{x:[n*r.width,a*r.width],y:[i,o]}},calculateHeatmapSliderInfo=({formatBandwidth:e,frequencyFormat:t,heatmapData:r,rect:n,segments:a,selectionOverride:i,sourceRangeOverride:o,waterfallSnapshot:l})=>{let s=r.length;if(s<=0)return null;let{position:c,height:u,leftPosition:d,width:h}=n,p=l&&i?resolveHeatmapSliderSelectionSourceRange({selection:i,waterfallSnapshot:l}):null,f=o??(l&&p?quantizeHeatmapContinuousSourceRange(l,p):null)??(l?resolveHeatmapProjectedSourceRange(l,{startLeft:d,endLeft:d+h,startTop:c+u,endTop:c}):null),m=f??resolveHeatmapRowRange(c+u,c,s);if(!m)return null;let{startIndex:g,endIndex:b}=m,v=String(r[g]?.timestamp??""),w=String(r[b]?.timestamp??""),y=dateTimeToTimestamp(v),x=dateTimeToTimestamp(w),k=y>0&&x>0?Math.abs(x-y):0,S=f??resolveHeatmapColumnRange(d,d+h,resolveHeatmapGridInfo(r).columnCount);if(!S)return null;let{startCol:D,endCol:M}=S,F=l?.sourceSize.width??0,C=resolveFrequencyRangeFromRatios([(i?100*i.x[0]:o&&F>0?100*D/F:l?resolveHeatmapSourceLeft(d,l):d)/100,(i?100*i.x[1]:o&&F>0?(M+1)*100/F:l?resolveHeatmapSourceLeft(d+h,l):d+h)/100],a,t),E=i?.frequency?.[0]??C?.[0],N=i?.frequency?.[1]??C?.[1],A=Number.isFinite(E)?Math.round(Number(E)*sliderInfo_PRECISION)/sliderInfo_PRECISION:0,T=Number.isFinite(N)?Math.round(Number(N)*sliderInfo_PRECISION)/sliderInfo_PRECISION:0,I=Math.abs(T-A);return{startIndex:g,endIndex:b,startTimestamp:v,endTimestamp:w,duration:k,startCol:D,endCol:M,startFrequency:A,startFrequencyFormat:String(A),endFrequency:T,endFrequencyFormat:String(T),bandwidth:I,bandwidthFormat:e(I)}},DEFAULT_HEIGHT=30,DEFAULT_POSITION=100-DEFAULT_HEIGHT,MAX_SIZE=100,MIN_SIZE=0,SNAP_THRESHOLD=2,DEFAULT_RECT={position:DEFAULT_POSITION,height:Math.min(DEFAULT_HEIGHT,MAX_SIZE),leftPosition:0,width:100},isRectEqual=(e,t)=>.01>=Math.abs(e.position-t.position)&&.01>=Math.abs(e.height-t.height)&&.01>=Math.abs(e.leftPosition-t.leftPosition)&&.01>=Math.abs(e.width-t.width),isBoundsEqual=(e,t)=>.01>=Math.abs(e.top-t.top)&&.01>=Math.abs(e.bottom-t.bottom)&&.01>=Math.abs(e.left-t.left)&&.01>=Math.abs(e.right-t.right),isSliderInfoEqual=(e,t)=>e.startIndex===t.startIndex&&e.endIndex===t.endIndex&&e.startTimestamp===t.startTimestamp&&e.endTimestamp===t.endTimestamp&&e.duration===t.duration&&e.startCol===t.startCol&&e.endCol===t.endCol&&e.startFrequency===t.startFrequency&&e.startFrequencyFormat===t.startFrequencyFormat&&e.endFrequency===t.endFrequency&&e.endFrequencyFormat===t.endFrequencyFormat&&e.bandwidth===t.bandwidth&&e.bandwidthFormat===t.bandwidthFormat,Slider=({id:e})=>{let{state:{globalID:t,heatmapCapture:{type:r,show:n,display:a,interval:i,onChange:o},axisX:{frequencyFormat:l,unit:s},segments:c}}=useStore_useStore(),u=external_react_useMemo(()=>r===heatmap_HeatmapCaptureType.Slider&&n&&a,[r,n,a]),[d,h]=external_react_useState(),p=external_react_useRef(void 0),f=external_react_useRef(null),[m,g]=external_react_useState(DEFAULT_RECT),[b,v]=external_react_useState(),w=external_react_useRef(m),y=external_react_useRef(null),x=external_react_useRef(null),k=external_react_useRef(null),S=external_react_useRef(null),D=external_react_useRef(l),M=external_react_useRef(c);D.current=l,M.current=c;let F=external_react_useCallback(e=>{w.current=e,g(t=>isRectEqual(t,e)?t:e)},[]),C=external_react_useCallback(e=>{v(t=>t&&e?isBoundsEqual(t,e)?t:e:t===e?t:e)},[]),E=external_react_useCallback(e=>{let r=getHeatmapWaterfallSnapshot(t),n=y.current,a=r&&n?resolveHeatmapSliderSelectionSourceRange({selection:n,waterfallSnapshot:r}):null;setHeatmapCaptureSelection(t,u&&e&&a?a:null)},[u,t]),N=external_react_useCallback((e,r)=>{p.current=e,h(e),E(e),r&&(f.current=getHeatmapWaterfallSnapshot(t)?.rawData??null,o?.(e))},[t,o,E]);external_react_useEffect(()=>{if(t)return E(u?p.current??null:null),()=>setHeatmapCaptureSelection(t,null)},[u,t,E]);let A=external_react_useCallback(()=>{let e=withDatabase(t).getAllRawData().waterfallData??[];return[e,e.length]},[t]),T=external_react_useCallback((e,r)=>{let[n]=A();return calculateHeatmapSliderInfo({formatBandwidth:getFrequencyToFixed,frequencyFormat:D.current,heatmapData:n,rect:e,segments:M.current,selectionOverride:r,waterfallSnapshot:getHeatmapWaterfallSnapshot(t)})},[A,t]),I=external_react_useCallback((e,r)=>{let n=getHeatmapWaterfallSnapshot(t);if(!n)return null;let a=r?resolveHeatmapSliderSelectionFromInteraction({dragType:r,frequencyFormat:D.current,rect:e,segments:M.current,startSelection:x.current,waterfallSnapshot:n}):resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:e,segments:M.current,waterfallSnapshot:n});return a&&(y.current=a),a},[t]),[P,z]=external_react_useState(0);external_react_useEffect(()=>{if(e&&t)return withUpdateData(e,"Slider",()=>z(e=>e+1))},[e,t]);let L=external_react_useCallback(e=>{let t=k.current;if(t&&isRectEqual(t,e))return;F(e);let r=I(e,S.current),n=T(e,r??void 0);n&&N(n,!1)},[T,F,N,I]),O=external_react_useCallback(t=>{let r=compareEventPriority(e,constants_ToolType.HeatmapCapture);return!1!==r&&(S.current=t,x.current=y.current,k.current=w.current,r)},[e]),q=external_react_useCallback(()=>{S.current=null,x.current=null,k.current=null,createMouseUpEventManager(getEID(e))(),resetEventLevel(e,constants_ToolType.HeatmapCapture)},[e]),_=external_react_useCallback(e=>{try{let t=y.current??I(e,null),r=T(e,t??void 0);r&&N(r,!0)}finally{q()}},[T,q,N,I]);external_react_useEffect(()=>q,[u,q]);let $=external_react_useCallback(e=>{let{startIndex:r,endIndex:n,startFrequency:a,endFrequency:i}=e,[o,s]=A(),c=getHeatmapWaterfallSnapshot(t),u=p.current,d=r===u?.startIndex&&n===u.endIndex,h=y.current?.frequency,f=void 0===a||void 0===i||1e-7>=Math.abs(Math.min(a,i)-(h?.[0]??0/0))&&1e-7>=Math.abs(Math.max(a,i)-(h?.[1]??0/0));if(d&&f)return;let m=w.current;if(c){let{sourceSize:e}=c;if(e.width<=0||e.height<=0)return;let t=s>0&&r>=0&&n<s&&n-r>=Math.ceil(MIN_SIZE*s/100),o=y.current??resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:m,segments:M.current,waterfallSnapshot:c}),l=void 0!==a&&void 0!==i?[Math.min(a,i),Math.max(a,i)]:null,d=l?resolveHeatmapSliderFrequencyRatioRange({frequencyFormat:D.current,frequencyRange:l,segments:M.current}):null;if(l&&!d)return;let h={frequency:l??o?.frequency??null,x:d??o?.x??[c.range.x[0]/e.width,c.range.x[1]/e.width],y:t?[Math.min(r,n),Math.max(r,n)+1]:o?.y??[u?.startIndex??c.range.y[0],(u?.endIndex??c.range.y[1]-1)+1]},p=resolveHeatmapSliderSelectionSourceRange({selection:h,waterfallSnapshot:c});if(!p)return;let f=resolveHeatmapContinuousSourceRangeScreenRect(c,p);if(!f)return;y.current=h,F(f);let g=T(f,h);g&&N(g,!0);return}let g=!d&&s>0&&r>=0&&n<s&&n-r>=Math.ceil(MIN_SIZE*s/100),b=!1,v=m.leftPosition,x=m.width;if(void 0!==a&&void 0!==i&&l){let e=l(0),t=l(100),r=e?Number(e):0,n=(t?Number(t):0)-r;if(n>0){let e=(a-r)/n*100,t=(i-r)/n*100,o=t-e;e>=0&&t<=100&&o>=MIN_SIZE&&(Math.abs(e-m.leftPosition)>.01||Math.abs(o-m.width)>.01)&&(b=!0,v=e,x=o)}}if(!g&&!b)return;let k={position:g?(1-n/s)*100:m.position,height:g?(n-r)/s*100:m.height,leftPosition:v,width:x};F(k);let S=T(k);S&&N(S,!0)},[A,t,l,T,F,N]);return(external_react_useEffect(()=>{i&&u&&$(i)},[i?.startIndex,i?.endIndex,i?.startFrequency,i?.endFrequency,u,P,$]),external_react_useEffect(()=>{if(!u||!t)return;let e=getHeatmapWaterfallSnapshot(t),r=p.current;if(e?.sourceSize.width&&e.sourceSize.height){let t=resolveHeatmapSourceRangeScreenRect(e,{endCol:e.sourceSize.width-1,endIndex:e.sourceSize.height-1,startCol:0,startIndex:0});C(t?{bottom:t.position+t.height,left:t.leftPosition,right:t.leftPosition+t.width,top:t.position}:void 0)}else C(void 0);if(!e){let e=T(w.current);e&&N(e,!0);return}let n=y.current??resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:w.current,segments:M.current,waterfallSnapshot:e});if(!n)return;if(n.frequency){let e=resolveHeatmapSliderFrequencyRatioRange({frequencyFormat:D.current,frequencyRange:n.frequency,segments:M.current});e&&(n={...n,x:e})}y.current=n;let a=resolveHeatmapSliderSelectionSourceRange({selection:n,waterfallSnapshot:e});if(!a)return;let i=resolveHeatmapContinuousSourceRangeScreenRect(e,a);i&&F(i);let o=T(i??w.current,n);if(!o)return;let l=!r||!isSliderInfoEqual(o,r),s=f.current!==e.rawData;(l||s)&&N(o,!0)},[P,l,c,u,t,T,F,C,N]),external_react_useEffect(()=>{t&&heatmapCaptureUpdate(t,e=>{e.interval&&u&&$(e.interval)})},[t,u,$]),u)?/*#__PURE__*/jsxs(components_DragSelectBox,{enabled:u,defaultRect:m,minSize:MIN_SIZE,maxSize:MAX_SIZE,snapThreshold:SNAP_THRESHOLD,onChange:L,onDragStart:O,onDragEnd:_,zIndex:6,showBoundaryLines:!0,variant:"projected",interactionBounds:b,labels:{left:d?.startFrequencyFormat?`${d.startFrequencyFormat}${s}`:"",right:d?.endFrequencyFormat?`${d.endFrequencyFormat}${s}`:"",top:d?.endTimestamp,bottom:d?.startTimestamp},children:[/*#__PURE__*/jsxs("div",{children:["带宽:",d?.bandwidth!==void 0?formatFrequencyUnit(1e3*d.bandwidth).formatted:""]}),/*#__PURE__*/jsxs("div",{children:["时长:",d?.duration!==void 0?(d.duration/1e3).toFixed(3):"","s"]})]}):null},Capture_Slider=Slider,HeatmapCapture=e=>{let{state:{heatmapCapture:t}}=useStore_useStore(),{show:r,type:n}=t;return r?n===heatmap_HeatmapCaptureType.Slider?/*#__PURE__*/jsx_runtime_jsx(Capture_Slider,{...e}):n===heatmap_HeatmapCaptureType.RowIndex?/*#__PURE__*/jsx_runtime_jsx(Capture_RowIndex,{...e}):/*#__PURE__*/jsx_runtime_jsx(Capture_Area,{...e}):null},Capture=HeatmapCapture;class render_Heatmap extends GradientRenderer{lastSeriesData=[];constructor(e){super({id:e.id,globalID:e.globalID,chart:null,realRange:e.realRange??constants_RANGE_DEFAULT,heatmapDefaultData:e.heatmapDefaultData??[]})}init(){let{id:e}=this.state;e&&(this.state.chart=new Heatmap({id:e,colors:this.getInitialColors(),renderer:RendererType.WebGL}),this.subscribeToColor("Heatmap-Render"),this.updateSeries(this.state.heatmapDefaultData),this.setRange())}updateSeries(e){Array.isArray(e)&&(this.lastSeriesData=e,this.state.chart?.render(e))}updateParams(e){let t=this.state.realRange,r=this.state.heatmapDefaultData;super.updateParams(e),e.heatmapDefaultData&&e.heatmapDefaultData!==r&&this.updateSeries(e.heatmapDefaultData),e.realRange&&(e.realRange[0]!==t[0]||e.realRange[1]!==t[1])&&this.setRange(e.realRange)}setRange(e=this.state.realRange){let{chart:t}=this.state,[r,n]=e;e&&void 0!==r&&void 0!==n&&t&&(this.state.realRange=e,t.setRange(e))}reset(){this.lastSeriesData=[],this.clear(),this.resize()}resize(){this.setRange(),this.state.chart?.resize(),this.lastSeriesData.length>0&&this.state.chart?.render(this.lastSeriesData)}}let useWaterfallZoomEvent_COMPONENT_KEY=constants_ToolType.Zoom;function useWaterfallZoomEvent(e,t){let r=useStore_useSelector(e=>e.globalID),n=external_react_useRef(null);external_react_useEffect(()=>{if(!t||!e||!r)return;let a=e=>{let t=withWaterfallAnalyzerSYNC(r),a=t?.getSnapshot();if(!a?.sourceSize.width||!a.sourceSize.height||"number"!=typeof e.left||"number"!=typeof e.top){n.current=null;return}n.current={start:{left:e.left,top:e.top},viewport:{range:a.range,sourceSize:a.sourceSize}}},i=createMouseDownEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,a),o=createWheelEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,(e,t)=>{let n=withWaterfallAnalyzerSYNC(r),a=n?.getSnapshot();if(!n||!a?.sourceSize.width||!a.sourceSize.height||"number"!=typeof t.left||"number"!=typeof t.top)return;let i=calculateHeatmapWheelRange(a,e,{left:t.left,top:t.top});isHeatmapViewportRangeEqual(a,i)||n.updateSamplingRange(toWaterfallSamplingOptions(i))}),l=createDoubleClickEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,()=>{if(!compareEventPriority(e,useWaterfallZoomEvent_COMPONENT_KEY))return!1;let t=resetHeatmapViewport(r);return resetEventLevel(e,useWaterfallZoomEvent_COMPONENT_KEY),t}),s=createDragEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,(t,i,o,l)=>{if(l||!t||!i||"number"!=typeof t.left||"number"!=typeof t.top||"number"!=typeof i.left||"number"!=typeof i.top||!compareEventPriority(e,useWaterfallZoomEvent_COMPONENT_KEY))return;let s=withWaterfallAnalyzerSYNC(r),c=s?.getSnapshot();if(!s||!c?.sourceSize.width||!c.sourceSize.height)return;n.current||a(t);let u=n.current;if(!u)return;if(u.viewport.sourceSize.width!==c.sourceSize.width||u.viewport.sourceSize.height!==c.sourceSize.height){n.current=null;return}let d=calculateHeatmapDragRangeFromCoordinates(u.viewport,u.start,{left:i.left,top:i.top});isHeatmapViewportRangeEqual(c,d)||s.updateSamplingRange(toWaterfallSamplingOptions(d))}),c=()=>{n.current=null,resetEventLevel(e,useWaterfallZoomEvent_COMPONENT_KEY)},u=createMouseUpEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,c),d=createMouseLeaveEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,c);return()=>{i?.(),o?.(),l?.(),s?.(),u?.(),d?.(),c()}},[t,r,e])}let Heatmap_Heatmap=e=>{let{heatmapDefaultData:t,onSubscriptionReadyChange:r,overview:n,zoomMode:a="disabled"}=e,i="independent-xy"===a,o=external_react_useRef(r);o.current=r;let{state:{axisY:{realRange:l},globalID:s}}=useStore_useStore(),{id:c,chart:u,Chart:d}=hooks_useChart({Render:render_Heatmap,params:{realRange:l,heatmapDefaultData:t,globalID:s}}),h=external_react_useMemo(()=>{let e=getEID(c);return throttle((t,r)=>{createWheelEventManager(e)(t,r)})},[c]),p=external_react_useCallback(e=>{e.stopPropagation(),h(-1*e.deltaY,calculateEventRelativePosition(e))},[h]);return useZoomEvent(c,constants_ModuleType.Heatmap,"linked-x"===a),useWaterfallZoomEvent(c,i),useModuleSubscription({moduleType:constants_ModuleType.Heatmap,chart:u,handleRender:(e,t)=>{t.updateSeries?.(e.data),withUpdateData(c)()},eventHandlers:{[constants_PSType.Option]:e=>{e.key===constants_OptionKey.HeatmapCapture&&heatmapCaptureUpdate(s)(e.data)}}}),external_react_useEffect(()=>{if(u&&s)return o.current?.(!0),()=>{o.current?.(!1)}},[u,s]),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(heatmap,{id:c,chart:u}),/*#__PURE__*/jsxs(components_PluginBox,{onWheelCapture:i?p:void 0,children:[/*#__PURE__*/jsx_runtime_jsx(GridLines_Boundary,{}),/*#__PURE__*/jsx_runtime_jsx(d,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:c}),/*#__PURE__*/jsx_runtime_jsx(Capture,{id:c}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:c,type:constants_ModuleType.Heatmap}),n]})]})},modules_Heatmap=Heatmap_Heatmap,DEFAULT_PALETTE=[{r:0,g:0,b:0,a:1},{r:0,g:0,b:255,a:1},{r:0,g:188,b:212,a:1},{r:45,g:179,b:51,a:1},{r:255,g:235,b:59,a:1},{r:255,g:0,b:0,a:1}],DEFAULT_OVERLAY_COLORS={selectionFill:"rgba(255, 210, 64, 0.08)",selectionStroke:"rgba(255, 210, 64, 0.95)",shadow:"rgba(0, 0, 0, 0.8)",viewportFill:"rgba(255, 255, 255, 0.14)",viewportStroke:"rgba(255, 255, 255, 0.95)"},MAX_BACKING_WIDTH=256,MAX_BACKING_HEIGHT=1024,MAX_DEVICE_PIXEL_RATIO=2,Overview_clamp=(e,t,r)=>Math.min(r,Math.max(t,e)),writePaletteColor=(e,t,r,n)=>{let a=Overview_clamp(n,0,1)*(r.length-1),i=Math.floor(a),o=Math.min(i+1,r.length-1),l=a-i,s=r[i],c=r[o];e[t]=Math.round(s.r+(c.r-s.r)*l),e[t+1]=Math.round(s.g+(c.g-s.g)*l),e[t+2]=Math.round(s.b+(c.b-s.b)*l),e[t+3]=Math.round(255*Overview_clamp(s.a+(c.a-s.a)*l,0,1))},normalizePalette=e=>{if(!Array.isArray(e)||e.length<2)return null;let t=[];for(let r of e){if(!r||"object"!=typeof r||!("r"in r)||!("g"in r)||!("b"in r))return null;let{r:e,g:n,b:a}=r,i="a"in r?r.a:1;if("number"!=typeof e||"number"!=typeof n||"number"!=typeof a||"number"!=typeof i||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(a)||!Number.isFinite(i))return null;t.push({r:Number(e),g:Number(n),b:Number(a),a:Number(i)})}return t},HeatmapOverview=/*#__PURE__*/forwardRef(({globalID:e,onResetViewport:t},r)=>{let n=useStore_useSelector(e=>e.axisY.realRange),a=external_react_useRef(null),i=external_react_useRef(null),o=external_react_useRef(null),l=external_react_useRef(null),s=external_react_useRef(null),c=external_react_useRef(DEFAULT_OVERLAY_COLORS),u=external_react_useRef(null),d=external_react_useRef(null),h=external_react_useRef(null),p=external_react_useRef(DEFAULT_PALETTE),f=external_react_useRef(constants_RANGE_DEFAULT),m=external_react_useRef(null),g=external_react_useRef(!0),b=external_react_useRef(null),v=external_react_useRef(void 0),w=external_react_useRef(null);f.current=[n?.[0]??constants_RANGE_DEFAULT["0"],n?.[1]??constants_RANGE_DEFAULT["1"]];let y=external_react_useCallback(()=>{let e=o.current,t=u.current;if(!e)return;let r=e.getContext("2d");if(!r)return;let{width:n,height:a}=e;if(r.clearRect(0,0,n,a),!t?.sourceSize.width||!t.sourceSize.height||n<=0||a<=0){h.current=t?.rawData??null;return}let[i,l]=f.current,c=Math.min(i,l),d=Math.max(i,l)-c||1,m=p.current,g=s.current;g&&g.width===n&&g.height===a||(s.current=g=r.createImageData(n,a));let b=g.data;for(let e=0;e<a;e++){let r=Overview_clamp(Math.floor((a-e-.5)*t.sourceSize.height/a),0,t.sourceSize.height-1),i=t.rawData[r];for(let r=0;r<n;r++){let a=Overview_clamp(Math.floor((r+.5)*t.sourceSize.width/n),0,t.sourceSize.width-1),o=i?.[a],l=(e*n+r)*4;if(!Number.isFinite(o)){b[l]=0,b[l+1]=0,b[l+2]=0,b[l+3]=0;continue}writePaletteColor(b,l,m,(o-c)/d)}}r.putImageData(g,0,0),h.current=t.rawData},[]),x=external_react_useCallback(()=>{let e=i.current??l.current;e&&(c.current={selectionFill:getThemeColor("--warning",.12,e)||DEFAULT_OVERLAY_COLORS.selectionFill,selectionStroke:getThemeColor("--warning",.95,e)||DEFAULT_OVERLAY_COLORS.selectionStroke,shadow:getThemeColor("--background",.86,e)||DEFAULT_OVERLAY_COLORS.shadow,viewportFill:getThemeColor("--background",.16,e)||DEFAULT_OVERLAY_COLORS.viewportFill,viewportStroke:getThemeColor("--foreground",.95,e)||DEFAULT_OVERLAY_COLORS.viewportStroke})},[]),k=external_react_useCallback(()=>{let e=l.current,t=u.current;if(!e)return;let r=e.getContext("2d");if(!r||(r.clearRect(0,0,e.width,e.height),!t?.sourceSize.width||!t.sourceSize.height))return;let{selectionFill:n,selectionStroke:a,shadow:i,viewportFill:o,viewportStroke:s}=c.current,h=resolveHeatmapOverviewViewportRect(t),p=Math.max(1,Math.min(window.devicePixelRatio||1,MAX_DEVICE_PIXEL_RATIO)),f=h.left*e.width,m=h.top*e.height,g=Math.max(h.width*e.width,2*p),b=Math.max(h.height*e.height,2*p);r.save(),r.fillStyle=o,r.strokeStyle=s,r.lineWidth=p,r.shadowColor=i,r.shadowBlur=2*p,r.fillRect(f,m,g,b),r.strokeRect(f+p/2,m+p/2,Math.max(0,Math.min(g-p,e.width-f-p)),Math.max(0,Math.min(b-p,e.height-m-p))),r.restore();let v=d.current;if(!v)return;let w=resolveHeatmapOverviewContinuousSourceRangeRect(t,v),y=w.left*e.width,x=w.top*e.height,k=Math.max(w.width*e.width,2*p),S=Math.max(w.height*e.height,2*p);r.save(),r.fillStyle=n,r.strokeStyle=a,r.lineWidth=p,r.setLineDash([3*p,2*p]),r.shadowColor=i,r.shadowBlur=2*p,r.fillRect(y,x,k,S),r.strokeRect(y+p/2,x+p/2,Math.max(0,Math.min(k-p,e.width-y-p)),Math.max(0,Math.min(S-p,e.height-x-p))),r.restore()},[]),S=external_react_useCallback(e=>{g.current||=e,a.current?.hidden||null===m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,g.current&&(g.current=!1,y()),k()}))},[y,k]),D=external_react_useCallback(()=>{let e=i.current,t=o.current,r=l.current;if(!e||!t||!r)return;let n=e.getBoundingClientRect(),a=Math.min(window.devicePixelRatio||1,MAX_DEVICE_PIXEL_RATIO),s=Math.max(1,Math.min(MAX_BACKING_WIDTH,Math.round(n.width*a))),c=Math.max(1,Math.min(MAX_BACKING_HEIGHT,Math.round(n.height*a)));(t.width!==s||t.height!==c||r.width!==s||r.height!==c)&&(t.width=s,t.height=c,r.width=s,r.height=c,S(!0))},[S]),M=external_react_useCallback(e=>{let t=h.current!==e.rawData;u.current=e;let r=isHeatmapViewportFullRange(e);if(a.current&&(a.current.hidden=r),r){g.current||=t,w.current=null,a.current?.removeAttribute("data-dragging"),v.current=void 0,null!==m.current&&(window.cancelAnimationFrame(m.current),m.current=null),null!==b.current&&(window.cancelAnimationFrame(b.current),b.current=null),l.current&&(l.current.style.cursor="grab");return}D(),S(t)},[D,S]);useImperativeHandle(r,()=>({update:M}),[M]),external_react_useEffect(()=>{let t=withWaterfallAnalyzerSYNC(e)?.getSnapshot();t&&M(t)},[e,M]),external_react_useEffect(()=>{S(!0)},[n,S]),external_react_useEffect(()=>(x(),subscribeChartsThemeChange(()=>{x(),S(!0)})),[S,x]),external_react_useEffect(()=>{let t=e=>{d.current=e,S(!1)},r=subscribeHeatmapCaptureSelection(e,t);return t(getHeatmapCaptureSelection(e)),r},[e,S]),external_react_useEffect(()=>{if(e)return handleColor(e,"HeatmapOverview",e=>{let t=normalizePalette(e);t&&(p.current=t,S(!0))})},[e,S]),external_react_useEffect(()=>{D();let e=i.current;if(!e||"u"<typeof ResizeObserver)return;let t=new ResizeObserver(D);return t.observe(e),()=>t.disconnect()},[D]),external_react_useEffect(()=>()=>{null!==m.current&&window.cancelAnimationFrame(m.current),null!==b.current&&window.cancelAnimationFrame(b.current)},[]);let F=external_react_useCallback(t=>{let r=withWaterfallAnalyzerSYNC(e),n=r?.getSnapshot();!r||!n||isHeatmapViewportRangeEqual(n,t)||r.updateSamplingRange(toWaterfallSamplingOptions(t))},[e]),C=external_react_useCallback(e=>{v.current=e,null===b.current&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=v.current;v.current=void 0,e&&F(e)}))},[F]),E=external_react_useCallback(e=>{let t=e.currentTarget.getBoundingClientRect();return{left:t.width?(e.clientX-t.left)/t.width:0,top:t.height?(e.clientY-t.top)/t.height:0}},[]),N=external_react_useCallback(e=>{if(0!==e.button)return;let t=u.current;if(!t?.sourceSize.width||!t.sourceSize.height)return;let r=E(e),n=resolveHeatmapOverviewSourcePoint(t,r),i=isHeatmapOverviewSourcePointInViewport(t,n),o=d.current;if(!i&&o&&!isHeatmapContinuousSourceRangeVisibleInViewport(t,o)){let r=e.currentTarget.getBoundingClientRect();if(isHeatmapOverviewSourcePointInContinuousRange(o,n,{x:r.width?6*t.sourceSize.width/r.width:0,y:r.height?6*t.sourceSize.height/r.height:0}))return void C(calculateHeatmapOverviewContinuousSourceRangeCenteredRange(t,o))}i?(w.current={pointerId:e.pointerId,grabOffset:{x:n.x-t.range.x[0],y:n.y-t.range.y[0]}},a.current?.setAttribute("data-dragging","true"),e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.style.cursor="grabbing",e.preventDefault()):C(calculateHeatmapOverviewCenteredRange(t,r))},[E,C]),A=external_react_useCallback(e=>{let t=w.current,r=u.current;t&&t.pointerId===e.pointerId&&r&&C(calculateHeatmapOverviewDragRange(r,E(e),t.grabOffset))},[E,C]),T=external_react_useCallback(e=>{w.current?.pointerId===e.pointerId&&(w.current=null,a.current?.removeAttribute("data-dragging"),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),e.currentTarget.style.cursor="grab")},[]);return /*#__PURE__*/jsx_runtime_jsx("aside",{ref:a,"aria-label":"瀑布图全景导航",className:"group absolute right-2 top-2 z-[6] isolate flex h-[14%] w-[14%] overflow-visible before:pointer-events-none before:absolute before:-inset-1 before:z-0 before:rounded-md before:bg-foreground/20 before:opacity-75 before:shadow-sm before:transition-opacity before:duration-100 hover:before:opacity-90 focus-within:before:opacity-90 data-[dragging=true]:before:opacity-100",hidden:!0,children:/*#__PURE__*/jsxs("div",{ref:i,className:"relative z-[1] h-full min-h-0 w-full overflow-hidden rounded-sm",children:[/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:o,className:"pointer-events-none absolute inset-0 h-full w-full opacity-60 transition-opacity duration-100 group-hover:opacity-90 group-focus-within:opacity-90 group-data-[dragging=true]:opacity-100"}),/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:l,className:"absolute inset-0 h-full w-full touch-none cursor-grab opacity-80 outline-none transition-opacity duration-100 group-hover:opacity-100 group-focus-within:opacity-100 group-data-[dragging=true]:opacity-100 focus-visible:ring-1 focus-visible:ring-ring","aria-label":"瀑布图全景;点击空白区域居中,点击框选范围定位,拖动视口框平移,双击恢复全景",tabIndex:0,onContextMenu:e=>e.preventDefault(),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),t()},onLostPointerCapture:T,onPointerCancel:T,onPointerDown:N,onPointerMove:A,onPointerUp:T})]})})});HeatmapOverview.displayName="HeatmapOverview";let Overview=HeatmapOverview,Heatmap_Chart_Chart=({publish:e,heatmapDefaultData:t})=>{let{state:{globalID:r,zoom:n},dispatch:a}=useStore_useStore(),i=!0===n.xy&&!1!==n.show,o=i&&n.overview?.show===!0,l=external_react_useRef(i),s=external_react_useRef(r),c=external_react_useRef(null),u=external_react_useRef(null),d=external_react_useRef(!1),h=external_react_useRef(!1),p=external_react_useRef(!1),f=external_react_useRef(t),m=external_react_useRef(convertToTimestampedArrays(t??[]));l.current=i,s.current=r;let g=external_react_useCallback(e=>{let t=s.current;if(!t)return;let r={range:{x:e.range.x,y:e.range.y},sourceSize:e.sourceSize},n=e.sourceSize.width>0?{start:e.range.x[0],end:e.range.x[1]-1}:{start:0,end:0};a({payload:t=>{let a=t.waterfallViewport,i=a.sourceSize.width!==e.sourceSize.width||a.sourceSize.height!==e.sourceSize.height||a.range.x[0]!==e.range.x[0]||a.range.x[1]!==e.range.x[1]||a.range.y[0]!==e.range.y[0]||a.range.y[1]!==e.range.y[1],o=t.zoom.interval.start!==n.start||t.zoom.interval.end!==n.end||null!==t.zoom.style;return i||o?{...i?{waterfallViewport:r}:{},...o?{zoom:{...t.zoom,interval:n,style:null,isScanSegmentsUpdateMagnify:!1}}:{}}:null}}),passThrough(t,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:e.data}),u.current?.update(e)},[a]),b=external_react_useCallback(e=>{if(d.current=e,!e||!l.current)return;let t=c.current,r=m.current;t&&r.length>0&&setHeatmapWaterfallData(t,r)},[]);external_react_useEffect(()=>{r&&(withDatabase(r).getAllRawData=e=>({...getDefaultData().getAllRawData(e),waterfallData:m.current}))},[r]),external_react_useEffect(()=>{if(!r)return;if(!i){if(c.current=null,withWaterfallAnalyzerSYNC(r,null),h.current){h.current=!1;let e=m.current.reduce((e,t)=>Math.max(e,t.length),0);e>0?a({payload:t=>({waterfallViewport:{range:{x:[0,0],y:[0,0]},sourceSize:{width:0,height:0}},zoom:{...t.zoom,interval:{start:0,end:e-1},style:null,isScanSegmentsUpdateMagnify:!1}})}):a({payload:{waterfallViewport:{range:{x:[0,0],y:[0,0]},sourceSize:{width:0,height:0}}}})}m.current.length>0&&passThrough(r,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:m.current});return}let e=new WaterfallAnalyzer({onWaterfallUpdate:g});return c.current=e,h.current=!0,withWaterfallAnalyzerSYNC(r,e),d.current&&m.current.length>0&&setHeatmapWaterfallData(e,m.current),()=>{c.current===e&&(c.current=null),withWaterfallAnalyzerSYNC(r,null)}},[a,r,g,i]),external_react_useEffect(()=>{if(Object.is(f.current,t))return;f.current=t,p.current=!1;let e=convertToTimestampedArrays(t??[]);m.current=e;let r=c.current;i&&d.current&&r&&setHeatmapWaterfallData(r,e)},[t,i]);let v=useSpectrumRule(constants_ChartType.Heatmap),w=external_react_useCallback(()=>{let e=s.current;e&&resetHeatmapViewport(e)},[]);publish_usePublish({publish:e,resetViewport:w,subscribe:e=>{v(e);let{pstype:t}=e;if(t===constants_PSType.Heatmap){let{data:t,timestamps:n}=e,a=convertToTimestampedArrays(t,n);m.current=a;let i=c.current;l.current?d.current&&i&&setHeatmapWaterfallData(i,a):passThrough(r,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:a})}if(t===constants_PSType.Reset||t===constants_PSType.Clear){p.current=!0,m.current=[],c.current?.setData([]),passThrough(r,constants_ModuleType.Heatmap)({pstype:constants_PSType.Reset}),t===constants_PSType.Reset&&passThrough(r,constants_PSType.Reset)(e),e.onFinally?.();return}passThrough(r,constants_ModuleType.Heatmap)(e)}});let y=!Object.is(f.current,t);return /*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Heatmap,{heatmapDefaultData:i||p.current&&!y?void 0:t,onSubscriptionReadyChange:b,overview:o?/*#__PURE__*/jsx_runtime_jsx(Overview,{ref:u,globalID:r,onResetViewport:w}):null,zoomMode:i?"independent-xy":"disabled"})}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:constants_ChartType.Heatmap})]})},Heatmap_Chart=Heatmap_Chart_Chart,HeatmapChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,children:/*#__PURE__*/jsx_runtime_jsx(Heatmap_Chart,{...e})}),charts_Heatmap_Heatmap=withChartPublisher(HeatmapChart,"Heatmap"),charts_Heatmap=charts_Heatmap_Heatmap;function IQEye_IQEye({type:e="iqEye"}){let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQEye,chart:t}),/*#__PURE__*/jsx_runtime_jsx(r,{})}let GridLinesSVG=({row:e=10,col:t=10,strokeColor:r="var(--chart-grid)",strokeWidth:n=1,strokeDasharray:a=4})=>{let i=external_react_useRef(null),[o,l]=external_react_useState([]),[s,c]=external_react_useState([]),u=()=>{let{width:o,height:s}=i.current?.getBoundingClientRect()??{width:0,height:0};if(o>0&&s>0&&e>0&&t>0){let i=[],u=[],d=o/t,h=s/e;for(let t=0;t<=e;t++){let e=Math.round(t*h);i.push(/*#__PURE__*/jsx_runtime_jsx("line",{x1:0,y1:e,x2:Math.round(o),y2:e,stroke:r,strokeWidth:n,strokeDasharray:a,vectorEffect:"non-scaling-stroke"},`h-${t}`))}for(let e=0;e<=t;e++){let t=Math.round(e*d);u.push(/*#__PURE__*/jsx_runtime_jsx("line",{x1:t,y1:0,x2:t,y2:Math.round(s),stroke:r,strokeWidth:n,strokeDasharray:a,vectorEffect:"non-scaling-stroke"},`v-${e}`))}l(i),c(u)}};return external_react_useEffect(()=>{let e=new ResizeObserver(()=>{u()});return i.current&&(e.observe(i.current),i.current.parentElement&&e.observe(i.current.parentElement)),u(),()=>{e.disconnect()}},[e,t,r,n]),/*#__PURE__*/jsxs("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",style:{width:"100%",height:"100%"},shapeRendering:"crispEdges",imageRendering:"pixelated",children:[o,s]})},GridLines_GridLinesSVG=GridLinesSVG,GridLines=()=>{let{state:{gridLines:e,segments:t,axisY:{range:r,step:n,restrict:a}}}=useStore_useStore(),i=external_react_useRef(null),[o,l]=external_react_useState({height:"0px",transform:"translateY(0px)",row:0,col:0});return(external_react_useEffect(()=>{if(!a||!r||!n)return;let[e,o]=a,s=o-e,[c,u]=r,d=u-c,h=i.current?.offsetHeight??0;l({height:`${s/d*h}px`,transform:`translateY(-${(o-u)/d*h}px)`,row:s/n,col:t.length>1?1:10})},[a,r,n,t.length,i.current]),e)?/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute right-0 top-0 z-[1] h-full w-full select-none overflow-hidden",ref:i,children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 flex h-full w-full items-center",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 top-0 h-full w-full box-border border-[color:var(--chart-grid)] [&>svg]:h-full [&>svg]:w-full",style:o,children:/*#__PURE__*/jsx_runtime_jsx(GridLines_GridLinesSVG,{col:o.col,row:o.row})})})}):null},components_GridLines=/*#__PURE__*/react.memo(GridLines);class Spectrum extends BaseRenderer{useRangeAutoFocus=()=>{};firstRenderAutoFocus=!1;constructor(e){super({chart:null,autoranging:!1,prevAutoRangeTime:0,id:"id",renderRange:constants_RANGE_DEFAULT,interval:1,series:{},globalID:"",...e})}init(){if(this.state.chart)return;let{id:e,renderRange:t,globalID:r}=this.state;e&&(this.trackCleanup(initSeriesSubscription(this)),this.state.chart=new Series({id:e,range:t}),this.initSeries(),this.useRangeAutoFocus=()=>{useRangeAutoFocus(r)()},this.trackCleanup(useRangeSet(r,e=>{this.setRange(e)})))}initSeries(){let{globalID:e}=this.state;if(!e)throw Error("globalID is required for series initialization");getSeriesWithGraphicType(e).forEach(e=>{this.setSeries(e,!0)}),this.state.chart?.draw()}updateSeries({data:e,extraData:t}){let{series:r,chart:n}=this.state;if(n){if(e){let t=Object.entries(r);for(let r=0;r<t.length;r+=1){let[a]=t[r],i=e[a];i&&SERIES_NAMES.includes(a)&&(n.render({name:a,data:i}),a===REAL_DATA_NAME&&this.updateMainSeries(i))}}if(t){let e=Object.entries(t);for(let t=0;t<e.length;t+=1){let[a,i]=e[t],o=r[a];i&&n.render({...o,name:a,data:i})}}}}updateMainSeries(e){let{autoranging:t,interval:r,prevAutoRangeTime:n,chart:a}=this.state;if(!a)return;let i=e.length;i!==r&&(this.state.interval=i,a.setIntervel(i));let o=Date.now();t&&o-n>1e3&&(this.state.prevAutoRangeTime=o,this.useRangeAutoFocus()),this.firstRenderAutoFocus||void 0===e.at(0)||(this.firstRenderAutoFocus=!0)}setSeries(e,t=!1){let{chart:r,series:n,globalID:a}=this.state,{name:i}=e;if(!r||!i||!e)return;let o={...n[i],...e},l=o.type;!e.type&&a&&(l=getCorrectSeriesType(a,i));let{color:s=SERIES[i]?.color,thickness:c=1,display:u=!1}=o,d={name:i,label:o.label,type:l||renderer_GraphicType.Line,color:s,thickness:c,display:u};if(this.state.series={...n,[i]:d},r.setSeries(d),!t&&a)try{updateSeries(a,{name:i,label:d.label||i,color:s,thickness:c,display:u,type:d.type})}catch(e){console.warn("Failed to update series in new management system:",e)}}setDisabledClearRect(e){this.state.chart?.updateProps({disabledClearRect:e})}setRange(e=this.state.renderRange){let{chart:t}=this.state,[r,n]=e;void 0!==r&&void 0!==n&&t&&(this.state.renderRange=e,t.setRange(e))}zoom(){let{chart:e,interval:t}=this.state;e&&e.setIntervel(t)}reset(){this.clear(),this.resize()}resize(){this.state.chart?this.hasRenderableContainerSize()&&(this.setRange(),this.zoom(),this.state.chart.resize()):this.initializeChartWhenReady()}clearChart(){this.clear()}}let IQLine=()=>{let{state:{axisY:{autoranging:e}}}=useStore_useStore(),{chart:t,Chart:r}=hooks_useChart({Render:Spectrum,params:{autoranging:e}});return external_react_useEffect(()=>{if(t){let{lineColor:e,pointColor:r}=getConfig("iq");t.setSeries({name:SERIES.realData.name,label:"IData",color:e}),t.setSeries({name:SERIES.maxData.name,label:"QData",color:r})}},[t]),useModuleSubscription({moduleType:constants_ModuleType.IQLine,chart:t,handleRender:(e,t)=>{let{IData:r,QData:n}=e;if(r&&n){let{min:e,max:a}=(0,array_0.jy)([...r,...n]),i=(a-e)/8;t.setRange?.([e-i,a+i]),t.updateSeries?.({data:{[SERIES.realData.name]:r,[SERIES.maxData.name]:n}})}},eventHandlers:{[constants_PSType.Reset]:(e,t)=>{t.reset()}}}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_GridLines,{}),/*#__PURE__*/jsx_runtime_jsx(r,{})]})},modules_IQLine=IQLine;function IQPlanisphere({type:e="iqPlanisphere"}){let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQPlanisphere,chart:t}),/*#__PURE__*/jsx_runtime_jsx(components_Square,{children:/*#__PURE__*/jsx_runtime_jsx(r,{})})}let IQStream=({type:e="iqStream"})=>{let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQStream,chart:t}),/*#__PURE__*/jsx_runtime_jsx(components_Square,{children:/*#__PURE__*/jsx_runtime_jsx(r,{})})},modules_IQStream=IQStream,IQ_Chart_Chart=e=>{let{type:t,publish:r}=e,{state:{globalID:n}}=useStore_useStore();return external_react_useEffect(()=>{n&&t===constants_ChartType.IQEye&&passThrough(n,constants_ModuleType.IQEye)({pstype:constants_PSType.Render})},[]),publish_usePublish({publish:r,subscribe:e=>{let r=normalizeRenderPublishEvent(e,{renderPSTypes:[constants_PSType.IQ]});switch(t){case constants_ChartType.IQEye:passThrough(n,constants_ModuleType.IQEye)(r);break;case constants_ChartType.IQLine:passThrough(n,constants_ModuleType.IQLine)(r);break;case constants_ChartType.IQPlanisphere:passThrough(n,constants_ModuleType.IQPlanisphere)(r);break;case constants_ChartType.IQStream:passThrough(n,constants_ModuleType.IQStream)(r)}}}),/*#__PURE__*/jsx_runtime_jsx(components_Container,{children:/*#__PURE__*/jsx_runtime_jsx(external_react_useMemo(()=>{switch(t){case constants_ChartType.IQEye:return IQEye_IQEye;case constants_ChartType.IQLine:return modules_IQLine;case constants_ChartType.IQPlanisphere:return IQPlanisphere;case constants_ChartType.IQStream:return modules_IQStream;default:return IQPlanisphere}},[t]),{})})},IQ_Chart=IQ_Chart_Chart,IQChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{system:{padding:!1,border:!1},...e,children:/*#__PURE__*/jsx_runtime_jsx(IQ_Chart,{...e})}),IQ_IQ=withChartPublisher(IQChart,"IQ"),charts_IQ=IQ_IQ,Reset_modes=Object.values(constants_ModuleType),Reset=()=>{let{state:{globalID:e,publish:t}}=useStore_useStore();return /*#__PURE__*/jsx_runtime_jsx(primitives_IconBox,{onClick:()=>{t?.({pstype:constants_PSType.Reset}),Reset_modes.forEach(t=>{passThrough(e,t)({pstype:constants_PSType.Reset})})},title:"重置",children:/*#__PURE__*/jsx_runtime_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M512 160c-141.6 0-265.6 76.8-332.8 192l-76.8-76.8v224h224l-89.6-89.6C288 307.2 390.4 240 512 240c159.2 0 288 128.8 288 288s-128.8 288-288 288c-115.2 0-214.4-67.2-262.4-164.8l-68.8 36.8C240 800 364.8 880 512 880c194.4 0 352-157.6 352-352S706.4 160 512 160z",fill:"currentColor"})})})},controls_Reset=Reset,SegmentsDisplayControl=()=>{let{state:{segments:e,globalID:t}}=useStore_useStore(),[r,n]=external_react_useState([]),[a,i]=external_react_useState(null),o=e.totalPoints??0;external_react_useEffect(()=>{n(e.map(e=>({display:!1,ratio:o>0?e.point/o:0})))},[e,o]);let l=external_react_useCallback(e=>{let a="number"==typeof e?e:null;n(r.map((e,t)=>({...e,display:t===a}))),i(a),SET_SEGMENTS_DISPLAY(t)(a??void 0)},[r,t]);return /*#__PURE__*/jsx_runtime_jsx(ToolbarDropdown,{value:a,options:[{value:null,label:"所有频段"},...e.map((e,t)=>({value:t,label:`频段 ${e.start} - ${e.stop}`}))],onChange:l})},controls_SegmentsDisplayControl=SegmentsDisplayControl,SeriesControl=({type:e})=>{let{state:{globalID:t}}=useStore_useStore(),{mode:r}=useSeriesManager(t),n=external_react_useCallback(()=>{e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360||t&&toggleSeriesMode(t)},[t,e]),a=external_react_useMemo(()=>e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360?"图形模式切换已禁用":`当前图形模式:${SERIES_MODES[r]?.label||r}`,[r,e]),i=e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360,o=external_react_useMemo(()=>()=>{switch(r){case"bar":return /*#__PURE__*/jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("rect",{x:"2",y:"8",width:"2",height:"6",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"5",y:"4",width:"2",height:"10",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"8",y:"6",width:"2",height:"8",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"11",y:"2",width:"2",height:"12",fill:"currentColor"})]});case"stepline":return /*#__PURE__*/jsx_runtime_jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12H4V8H6V8H8V4H10V4H12V2H14",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})});case"line":return /*#__PURE__*/jsx_runtime_jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})});case"area":return /*#__PURE__*/jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6V14H2V12Z",fill:"currentColor",opacity:"0.6"}),/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]});default:return null}},[r]);return /*#__PURE__*/jsx_runtime_jsx(primitives_IconBox,{title:a,disabled:i,onClick:i?void 0:n,className:cn_cn(i&&"text-muted-foreground"),children:o()})},controls_SeriesControl=SeriesControl,SeriesDisplayControl=()=>{let{state:{globalID:e,series:t}}=useStore_useStore(),r=useFilteredSeries(e);external_react_useEffect(()=>{if(!e||!t?.forceDisplay)return;let n=r.filter(e=>!e.display);n.length>0&&batchUpdateSeries(e,n.map(({name:e})=>({name:e,display:!0})))},[e,t?.forceDisplay,r.length]);let n=external_react_useCallback(t=>{e&&0!==t.length&&batchUpdateSeries(e,t)},[e]),a=external_react_useCallback((e,t)=>{n([{name:e,display:t}])},[n]),i=external_react_useCallback(e=>{let t=r.filter(t=>t.display!==e).map(t=>({name:t.name,display:e}));t.length>0&&n(t)},[r,n]),o=external_react_useMemo(()=>{let e=r.every(e=>e.display);return[{label:e?"全不选":"全选",value:"__toggle_all__",onSelect:()=>i(!e),render:()=>/*#__PURE__*/jsx_runtime_jsx("span",{className:"inline-flex w-full text-xs font-medium",children:e?"全不选":"全选"})},...r.map(e=>{let t=e.display?"text-foreground opacity-100":"font-normal text-muted-foreground opacity-70";return{label:e.label||e.name,value:e.name,onSelect:()=>a(e.name,!e.display),render:()=>/*#__PURE__*/jsxs("div",{className:"flex w-full min-w-0 items-center gap-[var(--size-gap-base)]",children:[/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:cn_cn("inline-flex h-3.5 w-3.5 shrink-0 rounded-[var(--radius-micro)] border transition-colors",e.display?"border-transparent":"border-border/70 bg-transparent opacity-55"),style:{backgroundColor:e.display?e.color:"transparent"}}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("min-w-0 truncate text-xs",t),children:e.label||e.name})]})}})]},[r,a,i]);return /*#__PURE__*/jsx_runtime_jsx(ToolbarIconDropdown,{value:external_react_useMemo(()=>{let e=r.filter(e=>e.display).length,t=r.length;return 0===e?"无选择":e===t?"全部":`${e}/${t}`},[r]),options:o,title:"系列显示控制",icon:/*#__PURE__*/jsxs("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("path",{d:"M930.909091 896H93.090909c-18.618182 0-34.909091-16.290909-34.909091-34.909091V162.909091c0-18.618182 16.290909-34.909091 34.909091-34.909091h837.818182c18.618182 0 34.909091 16.290909 34.909091 34.909091v698.181818c0 18.618182-16.290909 34.909091-34.909091 34.909091z m-802.909091-69.818182h770.327273v-628.363636H128v628.363636z",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("path",{d:"M232.727273 640c-4.654545 0-9.309091 0-13.963637-2.327273-16.290909-6.981818-25.6-27.927273-18.618181-44.218182l116.363636-279.272727c4.654545-11.636364 16.290909-20.945455 30.254545-20.945454 13.963636 0 25.6 4.654545 32.581819 16.290909l83.781818 146.618182H814.545455c18.618182 0 34.909091 16.290909 34.90909 34.90909s-16.290909 34.909091-34.90909 34.909091H442.181818c-11.636364 0-23.272727-6.981818-30.254545-16.290909l-58.181818-102.4-90.763637 216.436364c-4.654545 6.981818-16.290909 16.290909-30.254545 16.290909zM814.545455 663.272727H488.727273c-18.618182 0-34.909091-16.290909-34.909091-34.909091s16.290909-34.909091 34.909091-34.909091h325.818182c18.618182 0 34.909091 16.290909 34.90909 34.909091s-16.290909 34.909091-34.90909 34.909091z",fill:"currentColor"})]}),closeOnSelect:!1})},controls_SeriesDisplayControl=SeriesDisplayControl,ZoomSwitch=()=>{let{state:{zoom:e,segments:t},dispatch:r}=useStore_useStore(),{show:n,autoCloseTimeout:a,interval:{start:i,end:o}}=e,l=t.totalPoints??0,s=Math.max(l-1,0),[c,u]=external_react_useState(!0),d=external_react_useRef(null);external_react_useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),external_react_useEffect(()=>{d.current&&clearTimeout(d.current),u(!1),d.current=setTimeout(()=>{h()},a)},[i,o,a]);let h=external_react_useCallback(()=>{r({payload:{zoom:buildZoomFullRange(e,l)}}),u(!0)},[e,l,r]),p=external_react_useMemo(()=>l?{background:`linear-gradient(to right,
|
|
3565
|
+
*/let hasA11yProp=e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},LucideContext=createContext({});function LucideProvider({children:e,size:t,color:r,strokeWidth:n,absoluteStrokeWidth:a,className:i}){let o=useMemo(()=>({size:t,color:r,strokeWidth:n,absoluteStrokeWidth:a,className:i}),[t,r,n,a,i]);return createElement(LucideContext.Provider,{value:o},e)}let useLucideContext=()=>useContext(LucideContext),Icon_Icon=forwardRef(({color:e,size:t,strokeWidth:r,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...l},s)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:h="currentColor",className:p=""}=useLucideContext()??{},f=n??d?24*Number(r??u)/Number(t??c):r??u;return external_react_createElement("svg",{ref:s,...defaultAttributes,width:t??c??defaultAttributes.width,height:t??c??defaultAttributes.height,stroke:e??h,strokeWidth:f,className:mergeClasses("lucide",p,a),...!i&&!hasA11yProp(l)&&{"aria-hidden":"true"},...l},[...o.map(([e,t])=>external_react_createElement(e,t)),...Array.isArray(i)?i:[i]])}),createLucideIcon=(e,t)=>{let r=forwardRef(({className:r,...n},a)=>external_react_createElement(Icon_Icon,{ref:a,iconNode:t,className:mergeClasses(`lucide-${toKebabCase(toPascalCase(e))}`,`lucide-${e}`,r),...n}));return r.displayName=toPascalCase(e),r},__iconNode=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],Move=createLucideIcon("move",__iconNode),DEFAULT_CONFIG={enabled:!0,defaultRect:{position:70,height:30,leftPosition:0,width:100},minSize:0,maxSize:100,snapThreshold:2,onChange:()=>{},onDragEnd:()=>{},preserveDefaultRect:!1,bounds:{bottom:100,left:0,right:100,top:0}},useDragSelect=(e={})=>{let{enabled:t,defaultRect:r,minSize:n,minWidth:a,minHeight:i,maxSize:o,snapThreshold:l,onChange:s,onDragEnd:c,preserveDefaultRect:u,bounds:d}={...DEFAULT_CONFIG,...e},h=a??n,p=i??n,[f,m]=external_react_useState({position:r.position??DEFAULT_CONFIG.defaultRect.position,height:u?r.height??DEFAULT_CONFIG.defaultRect.height:Math.min(r.height??DEFAULT_CONFIG.defaultRect.height,o),leftPosition:r.leftPosition??DEFAULT_CONFIG.defaultRect.leftPosition,width:r.width??DEFAULT_CONFIG.defaultRect.width}),[g,b]=external_react_useState(!1),[v,w]=external_react_useState(null),y=external_react_useRef(null),x=external_react_useRef({x:0,y:0,rect:f}),k=external_react_useRef(f);k.current=f,external_react_useEffect(()=>{if(!g&&r){let e={position:r.position??f.position,height:void 0!==r.height?u?r.height:Math.min(r.height,o):f.height,leftPosition:r.leftPosition??f.leftPosition,width:r.width??f.width};(Math.abs(e.position-f.position)>.01||Math.abs(e.height-f.height)>.01||Math.abs(e.leftPosition-f.leftPosition)>.01||Math.abs(e.width-f.width)>.01)&&m(e)}},[r?.position,r?.height,r?.leftPosition,r?.width,g,o,u]);let S=external_react_useCallback((e,r,n=f)=>{t&&(e.preventDefault(),b(!0),w(r),x.current={x:e.clientX,y:e.clientY,rect:{...n}})},[t,f]),D=external_react_useCallback(e=>{if(!g||!y.current)return;let t=y.current,{x:r,y:n,rect:a}=x.current,i=(e.clientY-n)/t.clientHeight*100,c=(e.clientX-r)/t.clientWidth*100,{position:u,height:f,leftPosition:b,width:w}=a;switch(v){case"top":{let e=a.position+a.height;u=Math.max(d.top,Math.min(a.position+i,e-p)),(f=e-u)>o&&(f=o,u=e-o);break}case"bottom":f=Math.max(p,Math.min(o,a.height+i,d.bottom-a.position));break;case"left":{let e=a.leftPosition+a.width;b=Math.max(d.left,Math.min(a.leftPosition+c,e-h)),(w=e-b)>o&&(w=o,b=e-o);break}case"right":w=Math.max(h,Math.min(o,a.width+c,d.right-a.leftPosition));break;case"middle":u=Math.max(d.top,Math.min(a.position+i,d.bottom-a.height)),b=Math.max(d.left,Math.min(a.leftPosition+c,d.right-a.width))}u<d.top+l&&(u=d.top),u+f>d.bottom-l&&(u=d.bottom-f),b<d.left+l&&(b=d.left),b+w>d.right-l&&(b=d.right-w);let S={position:u,height:f,leftPosition:b,width:w};k.current=S,m(S),s(S)},[g,v,h,p,o,l,d.top,d.bottom,d.left,d.right,s]),M=external_react_useCallback(()=>{g&&c(k.current),b(!1),w(null)},[g,c]);external_react_useEffect(()=>{if(t&&g)return document.addEventListener("mousemove",D),document.addEventListener("mouseup",M),document.addEventListener("mouseleave",M),window.addEventListener("blur",M),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",M),document.removeEventListener("mouseleave",M),window.removeEventListener("blur",M)}},[t,g,D,M]);let F=external_react_useCallback(e=>{let t={...f,...e};m(t),s(t)},[f,s]);return{rect:f,isDragging:g,dragType:v,containerRef:y,handleMouseDown:S,resetRect:F,setRect:e=>{m(e),s(e)}}},SURFACE_GAP=4,MIN_VISUAL_SPAN=14,HANDLE_HIT_SIZE=10,VIEWPORT_BOUNDS={bottom:100,left:0,right:100,top:0},PROJECTED_EDGE_HANDLE_CLASS="pointer-events-auto absolute z-[2] appearance-none rounded-[3px] border-0 p-0 transition-[background-color,box-shadow] duration-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring [background:var(--mix-foreground-18)] [box-shadow:inset_0_0_0_1px_var(--mix-background-72),0_1px_3px_var(--mix-foreground-28)] hover:[background:var(--mix-foreground-32)] hover:[box-shadow:inset_0_0_0_1px_var(--mix-background-86),0_1px_4px_var(--mix-foreground-42)]",PROJECTED_MOVE_HANDLE_CLASS="pointer-events-auto absolute z-[3] flex size-5 -translate-x-1/2 -translate-y-1/2 cursor-move items-center justify-center appearance-none rounded-sm border-0 p-0 text-foreground outline-none transition-[background-color,box-shadow] duration-100 focus-visible:ring-1 focus-visible:ring-ring [background:var(--mix-bg76-fg24)] [box-shadow:0_0_0_1px_var(--mix-background-82),0_1px_4px_var(--mix-foreground-32)] hover:[background:var(--mix-bg64-fg36)]",ProjectedEdgeHandle=({ariaLabel:e,className:t,direction:r,onMouseDown:n,style:a})=>/*#__PURE__*/jsx_runtime_jsx("button",{type:"button",tabIndex:-1,"aria-label":e,className:cn_cn(PROJECTED_EDGE_HANDLE_CLASS,t),style:a,onMouseDown:n,children:/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:cn_cn("pointer-events-none absolute left-1/2 top-1/2 rounded-full bg-foreground/85","horizontal"===r?"h-[2px] -translate-x-1/2 -translate-y-1/2":"w-[2px] -translate-x-1/2 -translate-y-1/2"),style:"horizontal"===r?{width:"clamp(10px, 18%, 24px)"}:{height:"clamp(10px, 18%, 24px)"}})}),DragSelectBox_clamp=(e,t,r)=>Math.min(Math.max(e,t),r),isComparableLabelValue=e=>"string"==typeof e||"number"==typeof e,normalizeLabels=e=>{if(!e)return e;let t={...e};return isComparableLabelValue(t.left)&&isComparableLabelValue(t.right)&&String(t.left)===String(t.right)&&(t.right=void 0),isComparableLabelValue(t.top)&&isComparableLabelValue(t.bottom)&&String(t.top)===String(t.bottom)&&(t.top=void 0),t},getDisplaySpan=({start:e,length:t,minLength:r,maxLength:n})=>{let a=Math.max(0,t),i=Math.min(Math.max(a,r),n),o=e+a/2,l=o-i/2,s=o+i/2;l<0&&(s=Math.min(n,s-l),l=0),s>n&&(l=Math.max(0,l-(s-n)),s=n);let c=s-l;return{start:l,end:s,length:c}},getProjectedDisplaySpan=({start:e,length:t,minLength:r})=>{let n=Math.max(0,t),a=Math.max(n,r),i=e+n/2-a/2;return{start:i,end:i+a,length:a}},getDisplayRectBox=({rect:e,containerWidth:t,containerHeight:r,variant:n="contained"})=>{let a=e.leftPosition/100*t,i=e.position/100*r,o=e.width/100*t,l=e.height/100*r;if("projected"===n){let e=getProjectedDisplaySpan({start:a,length:o,minLength:MIN_VISUAL_SPAN}),t=getProjectedDisplaySpan({start:i,length:l,minLength:MIN_VISUAL_SPAN});return{left:e.start,top:t.start,width:e.length,height:t.length,right:e.end,bottom:t.end,centerX:e.start+e.length/2,centerY:t.start+t.length/2}}let s=getDisplaySpan({start:a,length:o,minLength:MIN_VISUAL_SPAN,maxLength:t}),c=getDisplaySpan({start:i,length:l,minLength:MIN_VISUAL_SPAN,maxLength:r});return{left:s.start,top:c.start,width:s.length,height:c.length,right:s.end,bottom:c.end,centerX:s.start+s.length/2,centerY:c.start+c.length/2}},getOverlapArea=(e,t)=>Math.max(0,Math.min(e.left+e.width,t.left+t.width)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.top+e.height,t.top+t.height)-Math.max(e.top,t.top)),placementsEqual=(e,t)=>Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(r=>{let n=e[r],a=t[r];return n&&a&&.5>Math.abs(n.left-a.left)&&.5>Math.abs(n.top-a.top)}),createOverlayBox=({left:e,top:t,size:r,containerWidth:n,containerHeight:a,score:i})=>{let o=Math.max(0,n-r.width),l=Math.max(0,a-r.height),s=DragSelectBox_clamp(e,0,o),c=DragSelectBox_clamp(t,0,l),u=Math.abs(s-e)+Math.abs(c-t);return{left:s,top:c,width:r.width,height:r.height,score:i+2*u}},getCandidateBoxes=({key:e,size:t,rectBox:r,containerWidth:n,containerHeight:a})=>{let i=[],o="middle"===e&&(r.width<=t.width+2*SURFACE_GAP||r.height<=t.height+2*SURFACE_GAP),l=(e,r,o)=>{i.push(createOverlayBox({left:e,top:r,size:t,containerWidth:n,containerHeight:a,score:o}))},s=r.left-t.width-SURFACE_GAP,c=r.right+SURFACE_GAP,u=r.top-t.height-SURFACE_GAP,d=r.bottom+SURFACE_GAP,h=r.left+SURFACE_GAP,p=r.right-t.width-SURFACE_GAP,f=r.top+SURFACE_GAP,m=r.bottom-t.height-SURFACE_GAP,g=r.centerX-t.width/2,b=r.centerY-t.height/2;switch(e){case"left":l(s,b,0),l(h,b,6),l(s,r.top,10),l(s,r.bottom-t.height,11),l(h,r.top,16),l(h,r.bottom-t.height,17),l(r.left,u,22),l(r.left,d,24);break;case"right":l(c,b,0),l(p,b,6),l(c,r.top,10),l(c,r.bottom-t.height,11),l(p,r.top,16),l(p,r.bottom-t.height,17),l(r.right-t.width,u,22),l(r.right-t.width,d,24);break;case"top":l(g,u,0),l(g,f,6),l(r.left,u,10),l(r.right-t.width,u,11),l(r.left+SURFACE_GAP,f,16),l(r.right-t.width-SURFACE_GAP,f,17),l(s,r.top,24),l(c,r.top,25);break;case"bottom":l(g,d,0),l(g,m,6),l(r.left,d,10),l(r.right-t.width,d,11),l(r.left+SURFACE_GAP,m,16),l(r.right-t.width-SURFACE_GAP,m,17),l(s,r.bottom-t.height,24),l(c,r.bottom-t.height,25);break;case"middle":o?(l(g,u,0),l(g,d,1),l(c,b,2),l(s,b,3),l(c,u,4),l(c,d,5),l(s,u,6),l(s,d,7),l(g,b,12)):(l(g,b,0),l(g,u,8),l(g,d,9),l(c,b,10),l(s,b,11),l(r.left,u,14),l(r.right-t.width,u,15),l(r.left,d,16),l(r.right-t.width,d,17))}return i},DragSelectBox=({enabled:e,defaultRect:t,minSize:r=0,minWidth:n,minHeight:a,maxSize:i=100,snapThreshold:o=2,onChange:l,onDragStart:s,onDragEnd:c,children:u,labels:d,className:h="",zIndex:p=7,showBoundaryLines:f=!1,variant:m="contained",interactionBounds:g=VIEWPORT_BOUNDS})=>{let b=external_react_useMemo(()=>normalizeLabels(d),[d?.top,d?.bottom,d?.left,d?.right]),{rect:v,containerRef:w,handleMouseDown:y}=useDragSelect({enabled:e,defaultRect:t,minSize:r,minWidth:n,minHeight:a,maxSize:"projected"===m?Math.max(i,g.right-g.left,g.bottom-g.top):i,snapThreshold:o,onChange:l,onDragEnd:c,preserveDefaultRect:"projected"===m,bounds:g}),x=v.leftPosition+Math.max(0,v.width),k=v.position+Math.max(0,v.height),S="projected"!==m||x>0&&v.leftPosition<100&&k>0&&v.position<100,D=DragSelectBox_clamp(v.leftPosition,0,100),M=DragSelectBox_clamp(x,0,100),F=DragSelectBox_clamp(v.position,0,100),C=DragSelectBox_clamp(k,0,100),E=M>D,N=C>F,A="projected"===m&&(v.leftPosition<VIEWPORT_BOUNDS.left||x>VIEWPORT_BOUNDS.right||v.position<VIEWPORT_BOUNDS.top||k>VIEWPORT_BOUNDS.bottom),T={left:(D+M)/2,top:(F+C)/2},[I,P]=external_react_useState(0),[z,L]=external_react_useState({width:0,height:0}),[O,q]=external_react_useState({}),_=external_react_useRef(null),$=external_react_useRef(null),j=external_react_useRef(null),H=external_react_useRef(null),B=external_react_useRef(null);external_react_useEffect(()=>{if(!e||!S||"u"<typeof ResizeObserver)return;let t=new ResizeObserver(()=>{P(e=>e+1)});return[w.current,_.current,$.current,j.current,H.current,B.current].filter(e=>null!==e).forEach(e=>{t.observe(e)}),()=>t.disconnect()},[e,S,!!b?.top,!!b?.bottom,!!b?.left,!!b?.right,!!u]),useLayoutEffect(()=>{let t=w.current;if(!e||!S||!t)return void q(e=>Object.keys(e).length>0?{}:e);let r=t.clientWidth,n=t.clientHeight;if(r<=0||n<=0)return;L(e=>e.width===r&&e.height===n?e:{width:r,height:n});let a=[["top",_.current],["bottom",$.current],["left",j.current],["right",H.current],["middle",B.current]].reduce((e,[t,r])=>(r&&(e[t]={width:r.offsetWidth,height:r.offsetHeight}),e),{}),i=getDisplayRectBox({rect:v,containerWidth:r,containerHeight:n,variant:m}),o={middle:4,bottom:3,left:2,right:2,top:1},l=["top","bottom","left","right","middle"].filter(e=>a[e]).sort((e,t)=>{let r=o[t]-o[e];if(0!==r)return r;let n=(a[e]?.width??0)*(a[e]?.height??0);return(a[t]?.width??0)*(a[t]?.height??0)-n}),s=[],c={};l.forEach(e=>{let t=a[e];if(!t)return;let o=getCandidateBoxes({key:e,size:t,rectBox:i,containerWidth:r,containerHeight:n}).map(e=>{let t=s.reduce((t,r)=>t+getOverlapArea(e,r),0),r=e.score+(t>0?2e4+10*t:0),n=Math.max(1,e.width*e.height);return{...e,overlapArea:t,overlapRatio:t/n,totalScore:r}}),l=o.filter(e=>0===e.overlapArea).sort((e,t)=>e.totalScore-t.totalScore)[0]??null??o.sort((e,t)=>e.totalScore-t.totalScore)[0]??null;!l||"middle"!==e&&l.overlapRatio>.2||(c[e]={left:l.left,top:l.top},s.push(l))}),q(e=>placementsEqual(e,c)?e:c)},[e,S,v.position,v.height,v.leftPosition,v.width,I,!!b?.top,!!b?.bottom,!!b?.left,!!b?.right,!!u,m]);let G={fontSize:"var(--size-font-second)",color:"var(--foreground)",border:"1px solid var(--border)",borderRadius:"var(--radius-control)",background:"var(--mix-background-80)"},U=e=>{let t=O[e];return{left:t?.left??0,top:t?.top??0,visibility:t?"visible":"hidden"}},W=external_react_useMemo(()=>z.width<=0||z.height<=0?null:getDisplayRectBox({rect:v,containerWidth:z.width,containerHeight:z.height,variant:m}),[v.position,v.height,v.leftPosition,v.width,z.width,z.height,m]),V=W?Math.max(0,Math.min(6,W.width/4)):6,Y=W?Math.max(0,Math.min(6,W.height/4)):6,X=W?{top:W.top,height:W.height,left:W.left,width:W.width}:{top:`${v.position}%`,height:`${v.height}%`,left:`${v.leftPosition}%`,width:`${v.width}%`},K=e=>{let t={...v};switch(e){case"top":v.position<VIEWPORT_BOUNDS.top&&(t.position=VIEWPORT_BOUNDS.top,t.height=Math.max(0,v.position+v.height-VIEWPORT_BOUNDS.top));break;case"bottom":k>VIEWPORT_BOUNDS.bottom&&(t.height=Math.max(0,VIEWPORT_BOUNDS.bottom-v.position));break;case"left":v.leftPosition<VIEWPORT_BOUNDS.left&&(t.leftPosition=VIEWPORT_BOUNDS.left,t.width=Math.max(0,x-VIEWPORT_BOUNDS.left));break;case"right":x>VIEWPORT_BOUNDS.right&&(t.width=Math.max(0,VIEWPORT_BOUNDS.right-v.leftPosition))}return t},Q=(e,t,r)=>{s?.(t)!==!1&&(e.preventDefault(),e.stopPropagation(),y(e,t,r))};return e?/*#__PURE__*/jsxs(Zoom_ZoomViewportLayer,{className:cn_cn("left-0 top-0 h-full w-full overflow-hidden",h),ref:w,style:{zIndex:p},children:[f&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 h-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 top-0 w-px bg-border"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute bottom-0 right-0 top-0 w-px bg-border"})]}),S&&/*#__PURE__*/jsxs("div",{className:"group pointer-events-none absolute box-border",style:X,children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 border-[2px] border-dashed border-foreground group-hover:border-[4px]"}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute left-0 w-full cursor-ns-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{top:-HANDLE_HIT_SIZE/2,height:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"top")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute left-0 w-full cursor-ns-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{bottom:-HANDLE_HIT_SIZE/2,height:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"bottom")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute top-0 h-full cursor-ew-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{left:-HANDLE_HIT_SIZE/2,width:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"left")}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute top-0 h-full cursor-ew-resize [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-40)]",style:{right:-HANDLE_HIT_SIZE/2,width:HANDLE_HIT_SIZE},onMouseDown:e=>Q(e,"right")}),!A&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute cursor-move [background:var(--mix-secondary-15)] hover:[background:var(--mix-secondary-20)]",style:{top:Y,bottom:Y,left:V,right:V},onMouseDown:e=>Q(e,"middle")})]}),A&&S&&E&&N&&/*#__PURE__*/jsx_runtime_jsx("button",{type:"button",tabIndex:-1,"aria-label":"移动框选范围",title:"移动框选范围",className:PROJECTED_MOVE_HANDLE_CLASS,style:{left:`clamp(10px, ${T.left}%, calc(100% - 10px))`,top:`clamp(10px, ${T.top}%, calc(100% - 10px))`},onMouseDown:e=>Q(e,"middle"),children:/*#__PURE__*/jsx_runtime_jsx(Move,{"aria-hidden":"true",className:"pointer-events-none size-3",strokeWidth:1.75})}),"projected"===m&&S&&/*#__PURE__*/jsxs(Fragment,{children:[v.position<0&&E&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选上边界",direction:"horizontal",className:"top-0 h-[10px] cursor-ns-resize",style:{left:`${D}%`,minWidth:HANDLE_HIT_SIZE,width:`${M-D}%`},onMouseDown:e=>Q(e,"top",K("top"))}),k>100&&E&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选下边界",direction:"horizontal",className:"bottom-0 h-[10px] cursor-ns-resize",style:{left:`${D}%`,minWidth:HANDLE_HIT_SIZE,width:`${M-D}%`},onMouseDown:e=>Q(e,"bottom",K("bottom"))}),v.leftPosition<0&&N&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选左边界",direction:"vertical",className:"left-0 w-[10px] cursor-ew-resize",style:{height:`${C-F}%`,minHeight:HANDLE_HIT_SIZE,top:`${F}%`},onMouseDown:e=>Q(e,"left",K("left"))}),x>100&&N&&/*#__PURE__*/jsx_runtime_jsx(ProjectedEdgeHandle,{ariaLabel:"调整框选右边界",direction:"vertical",className:"right-0 w-[10px] cursor-ew-resize",style:{height:`${C-F}%`,minHeight:HANDLE_HIT_SIZE,top:`${F}%`},onMouseDown:e=>Q(e,"right",K("right"))})]}),S&&u&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:B,className:"pointer-events-none absolute",style:U("middle"),children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"flex items-start gap-0.5 whitespace-nowrap p-[var(--size-gap-base)]",style:{fontSize:"var(--size-font-second)",color:"var(--foreground)",border:"1px solid var(--border)",borderRadius:"var(--radius-control)",background:"var(--mix-secondary-80)"},children:u})}),S&&b?.left&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:j,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("left")},children:b.left}),S&&b?.right&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:H,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("right")},children:b.right}),S&&b?.top&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:_,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("top")},children:b.top}),S&&b?.bottom&&/*#__PURE__*/jsx_runtime_jsx("div",{ref:$,className:"pointer-events-none absolute whitespace-nowrap p-[calc(var(--size-gap-base)/2)]",style:{...G,...U("bottom")},children:b.bottom})]}):null},components_DragSelectBox=DragSelectBox,sliderInfo_PRECISION=1e6,sliderInfo_clamp=(e,t,r)=>Math.min(r,Math.max(t,e)),resolveFrequencyExtent=e=>{if(!e)return null;let t=Number(e(0)),r=Number(e(100));return Number.isFinite(t)&&Number.isFinite(r)&&t!==r?[t,r]:null},resolveContinuousFrequencyFromSegments=(e,t,r)=>{if(!t?.length)return null;let n=100*sliderInfo_clamp(e,0,1),a=t.length-1;for(let e=0;e<t.length;e+=1){let i=t[e],o=Math.min(i.progress[0],i.progress[1]),l=Math.max(i.progress[0],i.progress[1]);if(!("start"===r?n>=o&&(n<l||e===a&&n<=l):(n>o||0===e)&&n<=l))continue;let s=l-o,c=s?(n-o)/s:0;return i.start+(i.stop-i.start)*c}return null},resolveFrequencyFromRatio=(e,t,r,n)=>{let a=r?.(100*sliderInfo_clamp(e,0,1)),i=void 0===a?0/0:Number(a);return Number.isFinite(i)?i:resolveContinuousFrequencyFromSegments(e,t,n)},resolveRatioFromFrequency=(e,t,r)=>{if(t?.length){let r=null;for(let n of t){let t=n.start,a=n.stop,i=Math.min(t,a),o=Math.max(t,a),l=n.progress[0]/100,s=n.progress[1]/100;if(e>=i&&e<=o){let r=a-t;return sliderInfo_clamp(l+(s-l)*(r?(e-t)/r:0),0,1)}for(let n of[{distance:Math.abs(e-t),ratio:l},{distance:Math.abs(e-a),ratio:s}])(!r||n.distance<r.distance)&&(r=n)}if(r)return sliderInfo_clamp(r.ratio,0,1)}let n=resolveFrequencyExtent(r);return n?sliderInfo_clamp((e-n[0])/(n[1]-n[0]),0,1):null},resolveHeatmapSliderFrequencyRatioRange=({frequencyFormat:e,frequencyRange:t,segments:r})=>{let n=resolveRatioFromFrequency(t[0],r,e),a=resolveRatioFromFrequency(t[1],r,e);return null===n||null===a?null:[Math.min(n,a),Math.max(n,a)]},resolveFrequencyRangeFromRatios=(e,t,r)=>{let n=resolveFrequencyFromRatio(e[0],t,r,"start"),a=resolveFrequencyFromRatio(e[1],t,r,"end");return null===n||null===a?null:[Math.min(n,a),Math.max(n,a)]},resolveHeatmapSliderSelectionFromRect=({frequencyFormat:e,rect:t,segments:r,waterfallSnapshot:n})=>{let a=resolveHeatmapProjectedContinuousSourceRange(n,{startLeft:t.leftPosition,endLeft:t.leftPosition+t.width,startTop:t.position+t.height,endTop:t.position});if(!a||n.sourceSize.width<=0)return null;let i=[a.x[0]/n.sourceSize.width,a.x[1]/n.sourceSize.width];return{frequency:resolveFrequencyRangeFromRatios(i,r,e),x:i,y:a.y}},resolveHeatmapSliderSelectionFromInteraction=({dragType:e,frequencyFormat:t,rect:r,segments:n,startSelection:a,waterfallSnapshot:i})=>{let o=resolveHeatmapSliderSelectionFromRect({frequencyFormat:t,rect:r,segments:n,waterfallSnapshot:i});if(!o||!a)return o;switch(e){case"left":return{frequency:o.frequency&&a.frequency?[o.frequency[0],a.frequency[1]]:o.frequency,x:[o.x[0],a.x[1]],y:a.y};case"right":return{frequency:o.frequency&&a.frequency?[a.frequency[0],o.frequency[1]]:o.frequency,x:[a.x[0],o.x[1]],y:a.y};case"top":return{frequency:a.frequency,x:a.x,y:[a.y[0],o.y[1]]};case"bottom":return{frequency:a.frequency,x:a.x,y:[o.y[0],a.y[1]]};case"middle":return o}},resolveHeatmapSliderSelectionSourceRange=({selection:e,waterfallSnapshot:t})=>{let{sourceSize:r}=t;if(r.width<=0||r.height<=0)return null;let n=sliderInfo_clamp(Math.min(e.x[0],e.x[1]),0,1),a=sliderInfo_clamp(Math.max(e.x[0],e.x[1]),n,1),i=sliderInfo_clamp(Math.min(e.y[0],e.y[1]),0,r.height),o=sliderInfo_clamp(Math.max(e.y[0],e.y[1]),i,r.height);return{x:[n*r.width,a*r.width],y:[i,o]}},calculateHeatmapSliderInfo=({formatBandwidth:e,frequencyFormat:t,heatmapData:r,rect:n,segments:a,selectionOverride:i,sourceRangeOverride:o,waterfallSnapshot:l})=>{let s=r.length;if(s<=0)return null;let{position:c,height:u,leftPosition:d,width:h}=n,p=l&&i?resolveHeatmapSliderSelectionSourceRange({selection:i,waterfallSnapshot:l}):null,f=o??(l&&p?quantizeHeatmapContinuousSourceRange(l,p):null)??(l?resolveHeatmapProjectedSourceRange(l,{startLeft:d,endLeft:d+h,startTop:c+u,endTop:c}):null),m=f??resolveHeatmapRowRange(c+u,c,s);if(!m)return null;let{startIndex:g,endIndex:b}=m,v=String(r[g]?.timestamp??""),w=String(r[b]?.timestamp??""),y=dateTimeToTimestamp(v),x=dateTimeToTimestamp(w),k=y>0&&x>0?Math.abs(x-y):0,S=f??resolveHeatmapColumnRange(d,d+h,resolveHeatmapGridInfo(r).columnCount);if(!S)return null;let{startCol:D,endCol:M}=S,F=l?.sourceSize.width??0,C=resolveFrequencyRangeFromRatios([(i?100*i.x[0]:o&&F>0?100*D/F:l?resolveHeatmapSourceLeft(d,l):d)/100,(i?100*i.x[1]:o&&F>0?(M+1)*100/F:l?resolveHeatmapSourceLeft(d+h,l):d+h)/100],a,t),E=i?.frequency?.[0]??C?.[0],N=i?.frequency?.[1]??C?.[1],A=Number.isFinite(E)?Math.round(Number(E)*sliderInfo_PRECISION)/sliderInfo_PRECISION:0,T=Number.isFinite(N)?Math.round(Number(N)*sliderInfo_PRECISION)/sliderInfo_PRECISION:0,I=Math.abs(T-A);return{startIndex:g,endIndex:b,startTimestamp:v,endTimestamp:w,duration:k,startCol:D,endCol:M,startFrequency:A,startFrequencyFormat:String(A),endFrequency:T,endFrequencyFormat:String(T),bandwidth:I,bandwidthFormat:e(I)}},DEFAULT_HEIGHT=30,DEFAULT_POSITION=100-DEFAULT_HEIGHT,MAX_SIZE=100,MIN_SIZE=0,SNAP_THRESHOLD=2,DEFAULT_RECT={position:DEFAULT_POSITION,height:Math.min(DEFAULT_HEIGHT,MAX_SIZE),leftPosition:0,width:100},isRectEqual=(e,t)=>.01>=Math.abs(e.position-t.position)&&.01>=Math.abs(e.height-t.height)&&.01>=Math.abs(e.leftPosition-t.leftPosition)&&.01>=Math.abs(e.width-t.width),isBoundsEqual=(e,t)=>.01>=Math.abs(e.top-t.top)&&.01>=Math.abs(e.bottom-t.bottom)&&.01>=Math.abs(e.left-t.left)&&.01>=Math.abs(e.right-t.right),isSliderInfoEqual=(e,t)=>e.startIndex===t.startIndex&&e.endIndex===t.endIndex&&e.startTimestamp===t.startTimestamp&&e.endTimestamp===t.endTimestamp&&e.duration===t.duration&&e.startCol===t.startCol&&e.endCol===t.endCol&&e.startFrequency===t.startFrequency&&e.startFrequencyFormat===t.startFrequencyFormat&&e.endFrequency===t.endFrequency&&e.endFrequencyFormat===t.endFrequencyFormat&&e.bandwidth===t.bandwidth&&e.bandwidthFormat===t.bandwidthFormat,Slider=({id:e})=>{let{state:{globalID:t,heatmapCapture:{type:r,show:n,display:a,interval:i,onChange:o},axisX:{frequencyFormat:l,unit:s},segments:c}}=useStore_useStore(),u=external_react_useMemo(()=>r===heatmap_HeatmapCaptureType.Slider&&n&&a,[r,n,a]),[d,h]=external_react_useState(),p=external_react_useRef(void 0),f=external_react_useRef(null),[m,g]=external_react_useState(DEFAULT_RECT),[b,v]=external_react_useState(),w=external_react_useRef(m),y=external_react_useRef(null),x=external_react_useRef(null),k=external_react_useRef(null),S=external_react_useRef(null),D=external_react_useRef(l),M=external_react_useRef(c);D.current=l,M.current=c;let F=external_react_useCallback(e=>{w.current=e,g(t=>isRectEqual(t,e)?t:e)},[]),C=external_react_useCallback(e=>{v(t=>t&&e?isBoundsEqual(t,e)?t:e:t===e?t:e)},[]),E=external_react_useCallback(e=>{let r=getHeatmapWaterfallSnapshot(t),n=y.current,a=r&&n?resolveHeatmapSliderSelectionSourceRange({selection:n,waterfallSnapshot:r}):null;setHeatmapCaptureSelection(t,u&&e&&a?a:null)},[u,t]),N=external_react_useCallback((e,r)=>{p.current=e,h(e),E(e),r&&(f.current=getHeatmapWaterfallSnapshot(t)?.rawData??null,o?.(e))},[t,o,E]);external_react_useEffect(()=>{if(t)return E(u?p.current??null:null),()=>setHeatmapCaptureSelection(t,null)},[u,t,E]);let A=external_react_useCallback(()=>{let e=withDatabase(t).getAllRawData().waterfallData??[];return[e,e.length]},[t]),T=external_react_useCallback((e,r)=>{let[n]=A();return calculateHeatmapSliderInfo({formatBandwidth:getFrequencyToFixed,frequencyFormat:D.current,heatmapData:n,rect:e,segments:M.current,selectionOverride:r,waterfallSnapshot:getHeatmapWaterfallSnapshot(t)})},[A,t]),I=external_react_useCallback((e,r)=>{let n=getHeatmapWaterfallSnapshot(t);if(!n)return null;let a=r?resolveHeatmapSliderSelectionFromInteraction({dragType:r,frequencyFormat:D.current,rect:e,segments:M.current,startSelection:x.current,waterfallSnapshot:n}):resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:e,segments:M.current,waterfallSnapshot:n});return a&&(y.current=a),a},[t]),[P,z]=external_react_useState(0);external_react_useEffect(()=>{if(e&&t)return withUpdateData(e,"Slider",()=>z(e=>e+1))},[e,t]);let L=external_react_useCallback(e=>{let t=k.current;if(t&&isRectEqual(t,e))return;F(e);let r=I(e,S.current),n=T(e,r??void 0);n&&N(n,!1)},[T,F,N,I]),O=external_react_useCallback(t=>{let r=compareEventPriority(e,constants_ToolType.HeatmapCapture);return!1!==r&&(S.current=t,x.current=y.current,k.current=w.current,r)},[e]),q=external_react_useCallback(()=>{S.current=null,x.current=null,k.current=null,createMouseUpEventManager(getEID(e))(),resetEventLevel(e,constants_ToolType.HeatmapCapture)},[e]),_=external_react_useCallback(e=>{try{let t=y.current??I(e,null),r=T(e,t??void 0);r&&N(r,!0)}finally{q()}},[T,q,N,I]);external_react_useEffect(()=>q,[u,q]);let $=external_react_useCallback(e=>{let{startIndex:r,endIndex:n,startFrequency:a,endFrequency:i}=e,[o,s]=A(),c=getHeatmapWaterfallSnapshot(t),u=p.current,d=r===u?.startIndex&&n===u.endIndex,h=y.current?.frequency,f=void 0===a||void 0===i||1e-7>=Math.abs(Math.min(a,i)-(h?.[0]??0/0))&&1e-7>=Math.abs(Math.max(a,i)-(h?.[1]??0/0));if(d&&f)return;let m=w.current;if(c){let{sourceSize:e}=c;if(e.width<=0||e.height<=0)return;let t=s>0&&r>=0&&n<s&&n-r>=Math.ceil(MIN_SIZE*s/100),o=y.current??resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:m,segments:M.current,waterfallSnapshot:c}),l=void 0!==a&&void 0!==i?[Math.min(a,i),Math.max(a,i)]:null,d=l?resolveHeatmapSliderFrequencyRatioRange({frequencyFormat:D.current,frequencyRange:l,segments:M.current}):null;if(l&&!d)return;let h={frequency:l??o?.frequency??null,x:d??o?.x??[c.range.x[0]/e.width,c.range.x[1]/e.width],y:t?[Math.min(r,n),Math.max(r,n)+1]:o?.y??[u?.startIndex??c.range.y[0],(u?.endIndex??c.range.y[1]-1)+1]},p=resolveHeatmapSliderSelectionSourceRange({selection:h,waterfallSnapshot:c});if(!p)return;let f=resolveHeatmapContinuousSourceRangeScreenRect(c,p);if(!f)return;y.current=h,F(f);let g=T(f,h);g&&N(g,!0);return}let g=!d&&s>0&&r>=0&&n<s&&n-r>=Math.ceil(MIN_SIZE*s/100),b=!1,v=m.leftPosition,x=m.width;if(void 0!==a&&void 0!==i&&l){let e=l(0),t=l(100),r=e?Number(e):0,n=(t?Number(t):0)-r;if(n>0){let e=(a-r)/n*100,t=(i-r)/n*100,o=t-e;e>=0&&t<=100&&o>=MIN_SIZE&&(Math.abs(e-m.leftPosition)>.01||Math.abs(o-m.width)>.01)&&(b=!0,v=e,x=o)}}if(!g&&!b)return;let k={position:g?(1-n/s)*100:m.position,height:g?(n-r)/s*100:m.height,leftPosition:v,width:x};F(k);let S=T(k);S&&N(S,!0)},[A,t,l,T,F,N]);return(external_react_useEffect(()=>{i&&u&&$(i)},[i?.startIndex,i?.endIndex,i?.startFrequency,i?.endFrequency,u,P,$]),external_react_useEffect(()=>{if(!u||!t)return;let e=getHeatmapWaterfallSnapshot(t),r=p.current;if(e?.sourceSize.width&&e.sourceSize.height){let t=resolveHeatmapSourceRangeScreenRect(e,{endCol:e.sourceSize.width-1,endIndex:e.sourceSize.height-1,startCol:0,startIndex:0});C(t?{bottom:t.position+t.height,left:t.leftPosition,right:t.leftPosition+t.width,top:t.position}:void 0)}else C(void 0);if(!e){let e=T(w.current);e&&N(e,!0);return}let n=y.current??resolveHeatmapSliderSelectionFromRect({frequencyFormat:D.current,rect:w.current,segments:M.current,waterfallSnapshot:e});if(!n)return;if(n.frequency){let e=resolveHeatmapSliderFrequencyRatioRange({frequencyFormat:D.current,frequencyRange:n.frequency,segments:M.current});e&&(n={...n,x:e})}y.current=n;let a=resolveHeatmapSliderSelectionSourceRange({selection:n,waterfallSnapshot:e});if(!a)return;let i=resolveHeatmapContinuousSourceRangeScreenRect(e,a);i&&F(i);let o=T(i??w.current,n);if(!o)return;let l=!r||!isSliderInfoEqual(o,r),s=f.current!==e.rawData;(l||s)&&N(o,!0)},[P,l,c,u,t,T,F,C,N]),external_react_useEffect(()=>{t&&heatmapCaptureUpdate(t,e=>{e.interval&&u&&$(e.interval)})},[t,u,$]),u)?/*#__PURE__*/jsxs(components_DragSelectBox,{enabled:u,defaultRect:m,minSize:MIN_SIZE,maxSize:MAX_SIZE,snapThreshold:SNAP_THRESHOLD,onChange:L,onDragStart:O,onDragEnd:_,zIndex:6,showBoundaryLines:!0,variant:"projected",interactionBounds:b,labels:{left:d?.startFrequencyFormat?`${d.startFrequencyFormat}${s}`:"",right:d?.endFrequencyFormat?`${d.endFrequencyFormat}${s}`:"",top:d?.endTimestamp,bottom:d?.startTimestamp},children:[/*#__PURE__*/jsxs("div",{children:["带宽:",d?.bandwidth!==void 0?formatFrequencyUnit(1e3*d.bandwidth).formatted:""]}),/*#__PURE__*/jsxs("div",{children:["时长:",d?.duration!==void 0?(d.duration/1e3).toFixed(3):"","s"]})]}):null},Capture_Slider=Slider,HeatmapCapture=e=>{let{state:{heatmapCapture:t}}=useStore_useStore(),{show:r,type:n}=t;return r?n===heatmap_HeatmapCaptureType.Slider?/*#__PURE__*/jsx_runtime_jsx(Capture_Slider,{...e}):n===heatmap_HeatmapCaptureType.RowIndex?/*#__PURE__*/jsx_runtime_jsx(Capture_RowIndex,{...e}):/*#__PURE__*/jsx_runtime_jsx(Capture_Area,{...e}):null},Capture=HeatmapCapture;class render_Heatmap extends GradientRenderer{lastSeriesData=[];constructor(e){super({id:e.id,globalID:e.globalID,chart:null,realRange:e.realRange??constants_RANGE_DEFAULT,heatmapDefaultData:e.heatmapDefaultData??[],renderer:e.renderer})}init(){let{id:e}=this.state;e&&(this.state.chart=new Heatmap({id:e,colors:this.getInitialColors(),renderer:this.state.renderer??RendererType.WebGL}),this.subscribeToColor("Heatmap-Render"),this.updateSeries(this.state.heatmapDefaultData),this.setRange())}updateSeries(e){Array.isArray(e)&&(this.lastSeriesData=e,this.state.chart?.render(e))}updateParams(e){let t=this.state.realRange,r=this.state.heatmapDefaultData;super.updateParams(e),e.heatmapDefaultData&&e.heatmapDefaultData!==r&&this.updateSeries(e.heatmapDefaultData),e.realRange&&(e.realRange[0]!==t[0]||e.realRange[1]!==t[1])&&this.setRange(e.realRange)}setRange(e=this.state.realRange){let{chart:t}=this.state,[r,n]=e;e&&void 0!==r&&void 0!==n&&t&&(this.state.realRange=e,t.setRange(e))}reset(){this.lastSeriesData=[],this.clear(),this.resize()}resize(){this.setRange(),this.state.chart?.resize(),this.lastSeriesData.length>0&&this.state.chart?.render(this.lastSeriesData)}}let useWaterfallZoomEvent_COMPONENT_KEY=constants_ToolType.Zoom;function useWaterfallZoomEvent(e,t){let r=useStore_useSelector(e=>e.globalID),n=external_react_useRef(null);external_react_useEffect(()=>{if(!t||!e||!r)return;let a=e=>{let t=withWaterfallAnalyzerSYNC(r),a=t?.getSnapshot();if(!a?.sourceSize.width||!a.sourceSize.height||"number"!=typeof e.left||"number"!=typeof e.top){n.current=null;return}n.current={start:{left:e.left,top:e.top},viewport:{range:a.range,sourceSize:a.sourceSize}}},i=createMouseDownEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,a),o=createWheelEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,(e,t)=>{let n=withWaterfallAnalyzerSYNC(r),a=n?.getSnapshot();if(!n||!a?.sourceSize.width||!a.sourceSize.height||"number"!=typeof t.left||"number"!=typeof t.top)return;let i=calculateHeatmapWheelRange(a,e,{left:t.left,top:t.top});isHeatmapViewportRangeEqual(a,i)||n.updateSamplingRange(toWaterfallSamplingOptions(i))}),l=createDoubleClickEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,()=>{if(!compareEventPriority(e,useWaterfallZoomEvent_COMPONENT_KEY))return!1;let t=resetHeatmapViewport(r);return resetEventLevel(e,useWaterfallZoomEvent_COMPONENT_KEY),t}),s=createDragEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,(t,i,o,l)=>{if(l||!t||!i||"number"!=typeof t.left||"number"!=typeof t.top||"number"!=typeof i.left||"number"!=typeof i.top||!compareEventPriority(e,useWaterfallZoomEvent_COMPONENT_KEY))return;let s=withWaterfallAnalyzerSYNC(r),c=s?.getSnapshot();if(!s||!c?.sourceSize.width||!c.sourceSize.height)return;n.current||a(t);let u=n.current;if(!u)return;if(u.viewport.sourceSize.width!==c.sourceSize.width||u.viewport.sourceSize.height!==c.sourceSize.height){n.current=null;return}let d=calculateHeatmapDragRangeFromCoordinates(u.viewport,u.start,{left:i.left,top:i.top});isHeatmapViewportRangeEqual(c,d)||s.updateSamplingRange(toWaterfallSamplingOptions(d))}),c=()=>{n.current=null,resetEventLevel(e,useWaterfallZoomEvent_COMPONENT_KEY)},u=createMouseUpEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,c),d=createMouseLeaveEventManager(e,useWaterfallZoomEvent_COMPONENT_KEY,c);return()=>{i?.(),o?.(),l?.(),s?.(),u?.(),d?.(),c()}},[t,r,e])}let Heatmap_Heatmap=e=>{let{heatmapDefaultData:t,onSubscriptionReadyChange:r,overview:n,zoomMode:a="disabled",renderer:i}=e,o="independent-xy"===a,l=external_react_useRef(r);l.current=r;let{state:{axisY:{realRange:s},globalID:c}}=useStore_useStore(),{id:u,chart:d,Chart:h}=hooks_useChart({Render:render_Heatmap,params:{realRange:s,heatmapDefaultData:t,globalID:c,renderer:i}}),p=external_react_useMemo(()=>{let e=getEID(u);return throttle((t,r)=>{createWheelEventManager(e)(t,r)})},[u]),f=external_react_useCallback(e=>{e.stopPropagation(),p(-1*e.deltaY,calculateEventRelativePosition(e))},[p]);return useZoomEvent(u,constants_ModuleType.Heatmap,"linked-x"===a),useWaterfallZoomEvent(u,o),useModuleSubscription({moduleType:constants_ModuleType.Heatmap,chart:d,handleRender:(e,t)=>{t.updateSeries?.(e.data),withUpdateData(u)()},eventHandlers:{[constants_PSType.Option]:e=>{e.key===constants_OptionKey.HeatmapCapture&&heatmapCaptureUpdate(c)(e.data)}}}),external_react_useEffect(()=>{if(d&&c)return l.current?.(!0),()=>{l.current?.(!1)}},[d,c]),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(heatmap,{id:u,chart:d}),/*#__PURE__*/jsxs(components_PluginBox,{onWheelCapture:o?f:void 0,children:[/*#__PURE__*/jsx_runtime_jsx(GridLines_Boundary,{}),/*#__PURE__*/jsx_runtime_jsx(h,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:u}),/*#__PURE__*/jsx_runtime_jsx(Capture,{id:u}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:u,type:constants_ModuleType.Heatmap}),n]})]})},modules_Heatmap=Heatmap_Heatmap,DEFAULT_PALETTE=[{r:0,g:0,b:0,a:1},{r:0,g:0,b:255,a:1},{r:0,g:188,b:212,a:1},{r:45,g:179,b:51,a:1},{r:255,g:235,b:59,a:1},{r:255,g:0,b:0,a:1}],DEFAULT_OVERLAY_COLORS={selectionFill:"rgba(255, 210, 64, 0.08)",selectionStroke:"rgba(255, 210, 64, 0.95)",shadow:"rgba(0, 0, 0, 0.8)",viewportFill:"rgba(255, 255, 255, 0.14)",viewportStroke:"rgba(255, 255, 255, 0.95)"},MAX_BACKING_WIDTH=256,MAX_BACKING_HEIGHT=1024,MAX_DEVICE_PIXEL_RATIO=2,Overview_clamp=(e,t,r)=>Math.min(r,Math.max(t,e)),writePaletteColor=(e,t,r,n)=>{let a=Overview_clamp(n,0,1)*(r.length-1),i=Math.floor(a),o=Math.min(i+1,r.length-1),l=a-i,s=r[i],c=r[o];e[t]=Math.round(s.r+(c.r-s.r)*l),e[t+1]=Math.round(s.g+(c.g-s.g)*l),e[t+2]=Math.round(s.b+(c.b-s.b)*l),e[t+3]=Math.round(255*Overview_clamp(s.a+(c.a-s.a)*l,0,1))},normalizePalette=e=>{if(!Array.isArray(e)||e.length<2)return null;let t=[];for(let r of e){if(!r||"object"!=typeof r||!("r"in r)||!("g"in r)||!("b"in r))return null;let{r:e,g:n,b:a}=r,i="a"in r?r.a:1;if("number"!=typeof e||"number"!=typeof n||"number"!=typeof a||"number"!=typeof i||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(a)||!Number.isFinite(i))return null;t.push({r:Number(e),g:Number(n),b:Number(a),a:Number(i)})}return t},HeatmapOverview=/*#__PURE__*/forwardRef(({globalID:e,onResetViewport:t},r)=>{let n=useStore_useSelector(e=>e.axisY.realRange),a=external_react_useRef(null),i=external_react_useRef(null),o=external_react_useRef(null),l=external_react_useRef(null),s=external_react_useRef(null),c=external_react_useRef(DEFAULT_OVERLAY_COLORS),u=external_react_useRef(null),d=external_react_useRef(null),h=external_react_useRef(null),p=external_react_useRef(DEFAULT_PALETTE),f=external_react_useRef(constants_RANGE_DEFAULT),m=external_react_useRef(null),g=external_react_useRef(!0),b=external_react_useRef(null),v=external_react_useRef(void 0),w=external_react_useRef(null);f.current=[n?.[0]??constants_RANGE_DEFAULT["0"],n?.[1]??constants_RANGE_DEFAULT["1"]];let y=external_react_useCallback(()=>{let e=o.current,t=u.current;if(!e)return;let r=e.getContext("2d");if(!r)return;let{width:n,height:a}=e;if(r.clearRect(0,0,n,a),!t?.sourceSize.width||!t.sourceSize.height||n<=0||a<=0){h.current=t?.rawData??null;return}let[i,l]=f.current,c=Math.min(i,l),d=Math.max(i,l)-c||1,m=p.current,g=s.current;g&&g.width===n&&g.height===a||(s.current=g=r.createImageData(n,a));let b=g.data;for(let e=0;e<a;e++){let r=Overview_clamp(Math.floor((a-e-.5)*t.sourceSize.height/a),0,t.sourceSize.height-1),i=t.rawData[r];for(let r=0;r<n;r++){let a=Overview_clamp(Math.floor((r+.5)*t.sourceSize.width/n),0,t.sourceSize.width-1),o=i?.[a],l=(e*n+r)*4;if(!Number.isFinite(o)){b[l]=0,b[l+1]=0,b[l+2]=0,b[l+3]=0;continue}writePaletteColor(b,l,m,(o-c)/d)}}r.putImageData(g,0,0),h.current=t.rawData},[]),x=external_react_useCallback(()=>{let e=i.current??l.current;e&&(c.current={selectionFill:getThemeColor("--warning",.12,e)||DEFAULT_OVERLAY_COLORS.selectionFill,selectionStroke:getThemeColor("--warning",.95,e)||DEFAULT_OVERLAY_COLORS.selectionStroke,shadow:getThemeColor("--background",.86,e)||DEFAULT_OVERLAY_COLORS.shadow,viewportFill:getThemeColor("--background",.16,e)||DEFAULT_OVERLAY_COLORS.viewportFill,viewportStroke:getThemeColor("--foreground",.95,e)||DEFAULT_OVERLAY_COLORS.viewportStroke})},[]),k=external_react_useCallback(()=>{let e=l.current,t=u.current;if(!e)return;let r=e.getContext("2d");if(!r||(r.clearRect(0,0,e.width,e.height),!t?.sourceSize.width||!t.sourceSize.height))return;let{selectionFill:n,selectionStroke:a,shadow:i,viewportFill:o,viewportStroke:s}=c.current,h=resolveHeatmapOverviewViewportRect(t),p=Math.max(1,Math.min(window.devicePixelRatio||1,MAX_DEVICE_PIXEL_RATIO)),f=h.left*e.width,m=h.top*e.height,g=Math.max(h.width*e.width,2*p),b=Math.max(h.height*e.height,2*p);r.save(),r.fillStyle=o,r.strokeStyle=s,r.lineWidth=p,r.shadowColor=i,r.shadowBlur=2*p,r.fillRect(f,m,g,b),r.strokeRect(f+p/2,m+p/2,Math.max(0,Math.min(g-p,e.width-f-p)),Math.max(0,Math.min(b-p,e.height-m-p))),r.restore();let v=d.current;if(!v)return;let w=resolveHeatmapOverviewContinuousSourceRangeRect(t,v),y=w.left*e.width,x=w.top*e.height,k=Math.max(w.width*e.width,2*p),S=Math.max(w.height*e.height,2*p);r.save(),r.fillStyle=n,r.strokeStyle=a,r.lineWidth=p,r.setLineDash([3*p,2*p]),r.shadowColor=i,r.shadowBlur=2*p,r.fillRect(y,x,k,S),r.strokeRect(y+p/2,x+p/2,Math.max(0,Math.min(k-p,e.width-y-p)),Math.max(0,Math.min(S-p,e.height-x-p))),r.restore()},[]),S=external_react_useCallback(e=>{g.current||=e,a.current?.hidden||null===m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,g.current&&(g.current=!1,y()),k()}))},[y,k]),D=external_react_useCallback(()=>{let e=i.current,t=o.current,r=l.current;if(!e||!t||!r)return;let n=e.getBoundingClientRect(),a=Math.min(window.devicePixelRatio||1,MAX_DEVICE_PIXEL_RATIO),s=Math.max(1,Math.min(MAX_BACKING_WIDTH,Math.round(n.width*a))),c=Math.max(1,Math.min(MAX_BACKING_HEIGHT,Math.round(n.height*a)));(t.width!==s||t.height!==c||r.width!==s||r.height!==c)&&(t.width=s,t.height=c,r.width=s,r.height=c,S(!0))},[S]),M=external_react_useCallback(e=>{let t=h.current!==e.rawData;u.current=e;let r=isHeatmapViewportFullRange(e);if(a.current&&(a.current.hidden=r),r){g.current||=t,w.current=null,a.current?.removeAttribute("data-dragging"),v.current=void 0,null!==m.current&&(window.cancelAnimationFrame(m.current),m.current=null),null!==b.current&&(window.cancelAnimationFrame(b.current),b.current=null),l.current&&(l.current.style.cursor="grab");return}D(),S(t)},[D,S]);useImperativeHandle(r,()=>({update:M}),[M]),external_react_useEffect(()=>{let t=withWaterfallAnalyzerSYNC(e)?.getSnapshot();t&&M(t)},[e,M]),external_react_useEffect(()=>{S(!0)},[n,S]),external_react_useEffect(()=>(x(),subscribeChartsThemeChange(()=>{x(),S(!0)})),[S,x]),external_react_useEffect(()=>{let t=e=>{d.current=e,S(!1)},r=subscribeHeatmapCaptureSelection(e,t);return t(getHeatmapCaptureSelection(e)),r},[e,S]),external_react_useEffect(()=>{if(e)return handleColor(e,"HeatmapOverview",e=>{let t=normalizePalette(e);t&&(p.current=t,S(!0))})},[e,S]),external_react_useEffect(()=>{D();let e=i.current;if(!e||"u"<typeof ResizeObserver)return;let t=new ResizeObserver(D);return t.observe(e),()=>t.disconnect()},[D]),external_react_useEffect(()=>()=>{null!==m.current&&window.cancelAnimationFrame(m.current),null!==b.current&&window.cancelAnimationFrame(b.current)},[]);let F=external_react_useCallback(t=>{let r=withWaterfallAnalyzerSYNC(e),n=r?.getSnapshot();!r||!n||isHeatmapViewportRangeEqual(n,t)||r.updateSamplingRange(toWaterfallSamplingOptions(t))},[e]),C=external_react_useCallback(e=>{v.current=e,null===b.current&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=v.current;v.current=void 0,e&&F(e)}))},[F]),E=external_react_useCallback(e=>{let t=e.currentTarget.getBoundingClientRect();return{left:t.width?(e.clientX-t.left)/t.width:0,top:t.height?(e.clientY-t.top)/t.height:0}},[]),N=external_react_useCallback(e=>{if(0!==e.button)return;let t=u.current;if(!t?.sourceSize.width||!t.sourceSize.height)return;let r=E(e),n=resolveHeatmapOverviewSourcePoint(t,r),i=isHeatmapOverviewSourcePointInViewport(t,n),o=d.current;if(!i&&o&&!isHeatmapContinuousSourceRangeVisibleInViewport(t,o)){let r=e.currentTarget.getBoundingClientRect();if(isHeatmapOverviewSourcePointInContinuousRange(o,n,{x:r.width?6*t.sourceSize.width/r.width:0,y:r.height?6*t.sourceSize.height/r.height:0}))return void C(calculateHeatmapOverviewContinuousSourceRangeCenteredRange(t,o))}i?(w.current={pointerId:e.pointerId,grabOffset:{x:n.x-t.range.x[0],y:n.y-t.range.y[0]}},a.current?.setAttribute("data-dragging","true"),e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.style.cursor="grabbing",e.preventDefault()):C(calculateHeatmapOverviewCenteredRange(t,r))},[E,C]),A=external_react_useCallback(e=>{let t=w.current,r=u.current;t&&t.pointerId===e.pointerId&&r&&C(calculateHeatmapOverviewDragRange(r,E(e),t.grabOffset))},[E,C]),T=external_react_useCallback(e=>{w.current?.pointerId===e.pointerId&&(w.current=null,a.current?.removeAttribute("data-dragging"),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),e.currentTarget.style.cursor="grab")},[]);return /*#__PURE__*/jsx_runtime_jsx("aside",{ref:a,"aria-label":"瀑布图全景导航",className:"group absolute right-2 top-2 z-[6] isolate flex h-[14%] w-[14%] overflow-visible before:pointer-events-none before:absolute before:-inset-1 before:z-0 before:rounded-md before:bg-foreground/20 before:opacity-75 before:shadow-sm before:transition-opacity before:duration-100 hover:before:opacity-90 focus-within:before:opacity-90 data-[dragging=true]:before:opacity-100",hidden:!0,children:/*#__PURE__*/jsxs("div",{ref:i,className:"relative z-[1] h-full min-h-0 w-full overflow-hidden rounded-sm",children:[/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:o,className:"pointer-events-none absolute inset-0 h-full w-full opacity-60 transition-opacity duration-100 group-hover:opacity-90 group-focus-within:opacity-90 group-data-[dragging=true]:opacity-100"}),/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:l,className:"absolute inset-0 h-full w-full touch-none cursor-grab opacity-80 outline-none transition-opacity duration-100 group-hover:opacity-100 group-focus-within:opacity-100 group-data-[dragging=true]:opacity-100 focus-visible:ring-1 focus-visible:ring-ring","aria-label":"瀑布图全景;点击空白区域居中,点击框选范围定位,拖动视口框平移,双击恢复全景",tabIndex:0,onContextMenu:e=>e.preventDefault(),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),t()},onLostPointerCapture:T,onPointerCancel:T,onPointerDown:N,onPointerMove:A,onPointerUp:T})]})})});HeatmapOverview.displayName="HeatmapOverview";let Overview=HeatmapOverview,Heatmap_Chart_Chart=({publish:e,heatmapDefaultData:t,renderer:r})=>{let{state:{globalID:n,zoom:a},dispatch:i}=useStore_useStore(),o=!0===a.xy&&!1!==a.show,l=o&&a.overview?.show===!0,s=external_react_useRef(o),c=external_react_useRef(n),u=external_react_useRef(null),d=external_react_useRef(null),h=external_react_useRef(!1),p=external_react_useRef(!1),f=external_react_useRef(!1),m=external_react_useRef(t),g=external_react_useRef(convertToTimestampedArrays(t??[]));s.current=o,c.current=n;let b=external_react_useCallback(e=>{let t=c.current;if(!t)return;let r={range:{x:e.range.x,y:e.range.y},sourceSize:e.sourceSize},n=e.sourceSize.width>0?{start:e.range.x[0],end:e.range.x[1]-1}:{start:0,end:0};i({payload:t=>{let a=t.waterfallViewport,i=a.sourceSize.width!==e.sourceSize.width||a.sourceSize.height!==e.sourceSize.height||a.range.x[0]!==e.range.x[0]||a.range.x[1]!==e.range.x[1]||a.range.y[0]!==e.range.y[0]||a.range.y[1]!==e.range.y[1],o=t.zoom.interval.start!==n.start||t.zoom.interval.end!==n.end||null!==t.zoom.style;return i||o?{...i?{waterfallViewport:r}:{},...o?{zoom:{...t.zoom,interval:n,style:null,isScanSegmentsUpdateMagnify:!1}}:{}}:null}}),passThrough(t,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:e.data}),d.current?.update(e)},[i]),v=external_react_useCallback(e=>{if(h.current=e,!e||!s.current)return;let t=u.current,r=g.current;t&&r.length>0&&setHeatmapWaterfallData(t,r)},[]);external_react_useEffect(()=>{n&&(withDatabase(n).getAllRawData=e=>({...getDefaultData().getAllRawData(e),waterfallData:g.current}))},[n]),external_react_useEffect(()=>{if(!n)return;if(!o){if(u.current=null,withWaterfallAnalyzerSYNC(n,null),p.current){p.current=!1;let e=g.current.reduce((e,t)=>Math.max(e,t.length),0);e>0?i({payload:t=>({waterfallViewport:{range:{x:[0,0],y:[0,0]},sourceSize:{width:0,height:0}},zoom:{...t.zoom,interval:{start:0,end:e-1},style:null,isScanSegmentsUpdateMagnify:!1}})}):i({payload:{waterfallViewport:{range:{x:[0,0],y:[0,0]},sourceSize:{width:0,height:0}}}})}g.current.length>0&&passThrough(n,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:g.current});return}let e=new WaterfallAnalyzer({onWaterfallUpdate:b});return u.current=e,p.current=!0,withWaterfallAnalyzerSYNC(n,e),h.current&&g.current.length>0&&setHeatmapWaterfallData(e,g.current),()=>{u.current===e&&(u.current=null),withWaterfallAnalyzerSYNC(n,null)}},[i,n,b,o]),external_react_useEffect(()=>{if(Object.is(m.current,t))return;m.current=t,f.current=!1;let e=convertToTimestampedArrays(t??[]);g.current=e;let r=u.current;o&&h.current&&r&&setHeatmapWaterfallData(r,e)},[t,o]);let w=useSpectrumRule(constants_ChartType.Heatmap),y=external_react_useCallback(()=>{let e=c.current;e&&resetHeatmapViewport(e)},[]);publish_usePublish({publish:e,resetViewport:y,subscribe:e=>{w(e);let{pstype:t}=e;if(t===constants_PSType.Heatmap){let{data:t,timestamps:r}=e,a=convertToTimestampedArrays(t,r);g.current=a;let i=u.current;s.current?h.current&&i&&setHeatmapWaterfallData(i,a):passThrough(n,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:a})}if(t===constants_PSType.Reset||t===constants_PSType.Clear){f.current=!0,g.current=[],u.current?.setData([]),passThrough(n,constants_ModuleType.Heatmap)({pstype:constants_PSType.Reset}),t===constants_PSType.Reset&&passThrough(n,constants_PSType.Reset)(e),e.onFinally?.();return}passThrough(n,constants_ModuleType.Heatmap)(e)}});let x=!Object.is(m.current,t);return /*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Heatmap,{renderer:r,heatmapDefaultData:o||f.current&&!x?void 0:t,onSubscriptionReadyChange:v,overview:l?/*#__PURE__*/jsx_runtime_jsx(Overview,{ref:d,globalID:n,onResetViewport:y}):null,zoomMode:o?"independent-xy":"disabled"})}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:constants_ChartType.Heatmap})]})},Heatmap_Chart=Heatmap_Chart_Chart,HeatmapChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,children:/*#__PURE__*/jsx_runtime_jsx(Heatmap_Chart,{...e})}),charts_Heatmap_Heatmap=withChartPublisher(HeatmapChart,"Heatmap"),charts_Heatmap=charts_Heatmap_Heatmap;function IQEye_IQEye({type:e="iqEye"}){let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQEye,chart:t}),/*#__PURE__*/jsx_runtime_jsx(r,{})}let GridLinesSVG=({row:e=10,col:t=10,strokeColor:r="var(--chart-grid)",strokeWidth:n=1,strokeDasharray:a=4})=>{let i=external_react_useRef(null),[o,l]=external_react_useState([]),[s,c]=external_react_useState([]),u=()=>{let{width:o,height:s}=i.current?.getBoundingClientRect()??{width:0,height:0};if(o>0&&s>0&&e>0&&t>0){let i=[],u=[],d=o/t,h=s/e;for(let t=0;t<=e;t++){let e=Math.round(t*h);i.push(/*#__PURE__*/jsx_runtime_jsx("line",{x1:0,y1:e,x2:Math.round(o),y2:e,stroke:r,strokeWidth:n,strokeDasharray:a,vectorEffect:"non-scaling-stroke"},`h-${t}`))}for(let e=0;e<=t;e++){let t=Math.round(e*d);u.push(/*#__PURE__*/jsx_runtime_jsx("line",{x1:t,y1:0,x2:t,y2:Math.round(s),stroke:r,strokeWidth:n,strokeDasharray:a,vectorEffect:"non-scaling-stroke"},`v-${e}`))}l(i),c(u)}};return external_react_useEffect(()=>{let e=new ResizeObserver(()=>{u()});return i.current&&(e.observe(i.current),i.current.parentElement&&e.observe(i.current.parentElement)),u(),()=>{e.disconnect()}},[e,t,r,n]),/*#__PURE__*/jsxs("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",style:{width:"100%",height:"100%"},shapeRendering:"crispEdges",imageRendering:"pixelated",children:[o,s]})},GridLines_GridLinesSVG=GridLinesSVG,GridLines=()=>{let{state:{gridLines:e,segments:t,axisY:{range:r,step:n,restrict:a}}}=useStore_useStore(),i=external_react_useRef(null),[o,l]=external_react_useState({height:"0px",transform:"translateY(0px)",row:0,col:0});return(external_react_useEffect(()=>{if(!a||!r||!n)return;let[e,o]=a,s=o-e,[c,u]=r,d=u-c,h=i.current?.offsetHeight??0;l({height:`${s/d*h}px`,transform:`translateY(-${(o-u)/d*h}px)`,row:s/n,col:t.length>1?1:10})},[a,r,n,t.length,i.current]),e)?/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute right-0 top-0 z-[1] h-full w-full select-none overflow-hidden",ref:i,children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 flex h-full w-full items-center",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 top-0 h-full w-full box-border border-[color:var(--chart-grid)] [&>svg]:h-full [&>svg]:w-full",style:o,children:/*#__PURE__*/jsx_runtime_jsx(GridLines_GridLinesSVG,{col:o.col,row:o.row})})})}):null},components_GridLines=/*#__PURE__*/react.memo(GridLines);class Spectrum extends BaseRenderer{useRangeAutoFocus=()=>{};firstRenderAutoFocus=!1;constructor(e){super({chart:null,autoranging:!1,prevAutoRangeTime:0,id:"id",renderRange:constants_RANGE_DEFAULT,interval:1,series:{},globalID:"",...e})}init(){if(this.state.chart)return;let{id:e,renderRange:t,globalID:r}=this.state;e&&(this.trackCleanup(initSeriesSubscription(this)),this.state.chart=new Series({id:e,range:t}),this.initSeries(),this.useRangeAutoFocus=()=>{useRangeAutoFocus(r)()},this.trackCleanup(useRangeSet(r,e=>{this.setRange(e)})))}initSeries(){let{globalID:e}=this.state;if(!e)throw Error("globalID is required for series initialization");getSeriesWithGraphicType(e).forEach(e=>{this.setSeries(e,!0)}),this.state.chart?.draw()}updateSeries({data:e,extraData:t}){let{series:r,chart:n}=this.state;if(n){if(e){let t=Object.entries(r);for(let r=0;r<t.length;r+=1){let[a]=t[r],i=e[a];i&&SERIES_NAMES.includes(a)&&(n.render({name:a,data:i}),a===REAL_DATA_NAME&&this.updateMainSeries(i))}}if(t){let e=Object.entries(t);for(let t=0;t<e.length;t+=1){let[a,i]=e[t],o=r[a];i&&n.render({...o,name:a,data:i})}}}}updateMainSeries(e){let{autoranging:t,interval:r,prevAutoRangeTime:n,chart:a}=this.state;if(!a)return;let i=e.length;i!==r&&(this.state.interval=i,a.setIntervel(i));let o=Date.now();t&&o-n>1e3&&(this.state.prevAutoRangeTime=o,this.useRangeAutoFocus()),this.firstRenderAutoFocus||void 0===e.at(0)||(this.firstRenderAutoFocus=!0)}setSeries(e,t=!1){let{chart:r,series:n,globalID:a}=this.state,{name:i}=e;if(!r||!i||!e)return;let o={...n[i],...e},l=o.type;!e.type&&a&&(l=getCorrectSeriesType(a,i));let{color:s=SERIES[i]?.color,thickness:c=1,display:u=!1}=o,d={name:i,label:o.label,type:l||renderer_GraphicType.Line,color:s,thickness:c,display:u};if(this.state.series={...n,[i]:d},r.setSeries(d),!t&&a)try{updateSeries(a,{name:i,label:d.label||i,color:s,thickness:c,display:u,type:d.type})}catch(e){console.warn("Failed to update series in new management system:",e)}}setDisabledClearRect(e){this.state.chart?.updateProps({disabledClearRect:e})}setRange(e=this.state.renderRange){let{chart:t}=this.state,[r,n]=e;void 0!==r&&void 0!==n&&t&&(this.state.renderRange=e,t.setRange(e))}zoom(){let{chart:e,interval:t}=this.state;e&&e.setIntervel(t)}reset(){this.clear(),this.resize()}resize(){this.state.chart?this.hasRenderableContainerSize()&&(this.setRange(),this.zoom(),this.state.chart.resize()):this.initializeChartWhenReady()}clearChart(){this.clear()}}let IQLine=()=>{let{state:{axisY:{autoranging:e}}}=useStore_useStore(),{chart:t,Chart:r}=hooks_useChart({Render:Spectrum,params:{autoranging:e}});return external_react_useEffect(()=>{if(t){let{lineColor:e,pointColor:r}=getConfig("iq");t.setSeries({name:SERIES.realData.name,label:"IData",color:e}),t.setSeries({name:SERIES.maxData.name,label:"QData",color:r})}},[t]),useModuleSubscription({moduleType:constants_ModuleType.IQLine,chart:t,handleRender:(e,t)=>{let{IData:r,QData:n}=e;if(r&&n){let{min:e,max:a}=(0,array_0.jy)([...r,...n]),i=(a-e)/8;t.setRange?.([e-i,a+i]),t.updateSeries?.({data:{[SERIES.realData.name]:r,[SERIES.maxData.name]:n}})}},eventHandlers:{[constants_PSType.Reset]:(e,t)=>{t.reset()}}}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_GridLines,{}),/*#__PURE__*/jsx_runtime_jsx(r,{})]})},modules_IQLine=IQLine;function IQPlanisphere({type:e="iqPlanisphere"}){let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQPlanisphere,chart:t}),/*#__PURE__*/jsx_runtime_jsx(components_Square,{children:/*#__PURE__*/jsx_runtime_jsx(r,{})})}let IQStream=({type:e="iqStream"})=>{let{chart:t,Chart:r}=hooks_useChart({Render:external_react_useMemo(()=>class extends IQRenderer{constructor(t){super({...t,type:e})}},[e])});return useModuleSubscription({moduleType:constants_ModuleType.IQStream,chart:t}),/*#__PURE__*/jsx_runtime_jsx(components_Square,{children:/*#__PURE__*/jsx_runtime_jsx(r,{})})},modules_IQStream=IQStream,IQ_Chart_Chart=e=>{let{type:t,publish:r}=e,{state:{globalID:n}}=useStore_useStore();return external_react_useEffect(()=>{n&&t===constants_ChartType.IQEye&&passThrough(n,constants_ModuleType.IQEye)({pstype:constants_PSType.Render})},[]),publish_usePublish({publish:r,subscribe:e=>{let r=normalizeRenderPublishEvent(e,{renderPSTypes:[constants_PSType.IQ]});switch(t){case constants_ChartType.IQEye:passThrough(n,constants_ModuleType.IQEye)(r);break;case constants_ChartType.IQLine:passThrough(n,constants_ModuleType.IQLine)(r);break;case constants_ChartType.IQPlanisphere:passThrough(n,constants_ModuleType.IQPlanisphere)(r);break;case constants_ChartType.IQStream:passThrough(n,constants_ModuleType.IQStream)(r)}}}),/*#__PURE__*/jsx_runtime_jsx(components_Container,{children:/*#__PURE__*/jsx_runtime_jsx(external_react_useMemo(()=>{switch(t){case constants_ChartType.IQEye:return IQEye_IQEye;case constants_ChartType.IQLine:return modules_IQLine;case constants_ChartType.IQPlanisphere:return IQPlanisphere;case constants_ChartType.IQStream:return modules_IQStream;default:return IQPlanisphere}},[t]),{})})},IQ_Chart=IQ_Chart_Chart,IQChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{system:{padding:!1,border:!1},...e,children:/*#__PURE__*/jsx_runtime_jsx(IQ_Chart,{...e})}),IQ_IQ=withChartPublisher(IQChart,"IQ"),charts_IQ=IQ_IQ,Reset_modes=Object.values(constants_ModuleType),Reset=()=>{let{state:{globalID:e,publish:t}}=useStore_useStore();return /*#__PURE__*/jsx_runtime_jsx(primitives_IconBox,{onClick:()=>{t?.({pstype:constants_PSType.Reset}),Reset_modes.forEach(t=>{passThrough(e,t)({pstype:constants_PSType.Reset})})},title:"重置",children:/*#__PURE__*/jsx_runtime_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M512 160c-141.6 0-265.6 76.8-332.8 192l-76.8-76.8v224h224l-89.6-89.6C288 307.2 390.4 240 512 240c159.2 0 288 128.8 288 288s-128.8 288-288 288c-115.2 0-214.4-67.2-262.4-164.8l-68.8 36.8C240 800 364.8 880 512 880c194.4 0 352-157.6 352-352S706.4 160 512 160z",fill:"currentColor"})})})},controls_Reset=Reset,SegmentsDisplayControl=()=>{let{state:{segments:e,globalID:t}}=useStore_useStore(),[r,n]=external_react_useState([]),[a,i]=external_react_useState(null),o=e.totalPoints??0;external_react_useEffect(()=>{n(e.map(e=>({display:!1,ratio:o>0?e.point/o:0})))},[e,o]);let l=external_react_useCallback(e=>{let a="number"==typeof e?e:null;n(r.map((e,t)=>({...e,display:t===a}))),i(a),SET_SEGMENTS_DISPLAY(t)(a??void 0)},[r,t]);return /*#__PURE__*/jsx_runtime_jsx(ToolbarDropdown,{value:a,options:[{value:null,label:"所有频段"},...e.map((e,t)=>({value:t,label:`频段 ${e.start} - ${e.stop}`}))],onChange:l})},controls_SegmentsDisplayControl=SegmentsDisplayControl,SeriesControl=({type:e})=>{let{state:{globalID:t}}=useStore_useStore(),{mode:r}=useSeriesManager(t),n=external_react_useCallback(()=>{e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360||t&&toggleSeriesMode(t)},[t,e]),a=external_react_useMemo(()=>e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360?"图形模式切换已禁用":`当前图形模式:${SERIES_MODES[r]?.label||r}`,[r,e]),i=e===constants_ChartType.MScan||e===constants_ChartType.ScanDF360,o=external_react_useMemo(()=>()=>{switch(r){case"bar":return /*#__PURE__*/jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("rect",{x:"2",y:"8",width:"2",height:"6",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"5",y:"4",width:"2",height:"10",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"8",y:"6",width:"2",height:"8",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("rect",{x:"11",y:"2",width:"2",height:"12",fill:"currentColor"})]});case"stepline":return /*#__PURE__*/jsx_runtime_jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12H4V8H6V8H8V4H10V4H12V2H14",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})});case"line":return /*#__PURE__*/jsx_runtime_jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})});case"area":return /*#__PURE__*/jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6V14H2V12Z",fill:"currentColor",opacity:"0.6"}),/*#__PURE__*/jsx_runtime_jsx("path",{d:"M2 12L5 8L8 10L11 4L14 6",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]});default:return null}},[r]);return /*#__PURE__*/jsx_runtime_jsx(primitives_IconBox,{title:a,disabled:i,onClick:i?void 0:n,className:cn_cn(i&&"text-muted-foreground"),children:o()})},controls_SeriesControl=SeriesControl,SeriesDisplayControl=()=>{let{state:{globalID:e,series:t}}=useStore_useStore(),r=useFilteredSeries(e);external_react_useEffect(()=>{if(!e||!t?.forceDisplay)return;let n=r.filter(e=>!e.display);n.length>0&&batchUpdateSeries(e,n.map(({name:e})=>({name:e,display:!0})))},[e,t?.forceDisplay,r.length]);let n=external_react_useCallback(t=>{e&&0!==t.length&&batchUpdateSeries(e,t)},[e]),a=external_react_useCallback((e,t)=>{n([{name:e,display:t}])},[n]),i=external_react_useCallback(e=>{let t=r.filter(t=>t.display!==e).map(t=>({name:t.name,display:e}));t.length>0&&n(t)},[r,n]),o=external_react_useMemo(()=>{let e=r.every(e=>e.display);return[{label:e?"全不选":"全选",value:"__toggle_all__",onSelect:()=>i(!e),render:()=>/*#__PURE__*/jsx_runtime_jsx("span",{className:"inline-flex w-full text-xs font-medium",children:e?"全不选":"全选"})},...r.map(e=>{let t=e.display?"text-foreground opacity-100":"font-normal text-muted-foreground opacity-70";return{label:e.label||e.name,value:e.name,onSelect:()=>a(e.name,!e.display),render:()=>/*#__PURE__*/jsxs("div",{className:"flex w-full min-w-0 items-center gap-[var(--size-gap-base)]",children:[/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:cn_cn("inline-flex h-3.5 w-3.5 shrink-0 rounded-[var(--radius-micro)] border transition-colors",e.display?"border-transparent":"border-border/70 bg-transparent opacity-55"),style:{backgroundColor:e.display?e.color:"transparent"}}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("min-w-0 truncate text-xs",t),children:e.label||e.name})]})}})]},[r,a,i]);return /*#__PURE__*/jsx_runtime_jsx(ToolbarIconDropdown,{value:external_react_useMemo(()=>{let e=r.filter(e=>e.display).length,t=r.length;return 0===e?"无选择":e===t?"全部":`${e}/${t}`},[r]),options:o,title:"系列显示控制",icon:/*#__PURE__*/jsxs("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/jsx_runtime_jsx("path",{d:"M930.909091 896H93.090909c-18.618182 0-34.909091-16.290909-34.909091-34.909091V162.909091c0-18.618182 16.290909-34.909091 34.909091-34.909091h837.818182c18.618182 0 34.909091 16.290909 34.909091 34.909091v698.181818c0 18.618182-16.290909 34.909091-34.909091 34.909091z m-802.909091-69.818182h770.327273v-628.363636H128v628.363636z",fill:"currentColor"}),/*#__PURE__*/jsx_runtime_jsx("path",{d:"M232.727273 640c-4.654545 0-9.309091 0-13.963637-2.327273-16.290909-6.981818-25.6-27.927273-18.618181-44.218182l116.363636-279.272727c4.654545-11.636364 16.290909-20.945455 30.254545-20.945454 13.963636 0 25.6 4.654545 32.581819 16.290909l83.781818 146.618182H814.545455c18.618182 0 34.909091 16.290909 34.90909 34.90909s-16.290909 34.909091-34.90909 34.909091H442.181818c-11.636364 0-23.272727-6.981818-30.254545-16.290909l-58.181818-102.4-90.763637 216.436364c-4.654545 6.981818-16.290909 16.290909-30.254545 16.290909zM814.545455 663.272727H488.727273c-18.618182 0-34.909091-16.290909-34.909091-34.909091s16.290909-34.909091 34.909091-34.909091h325.818182c18.618182 0 34.909091 16.290909 34.90909 34.909091s-16.290909 34.909091-34.90909 34.909091z",fill:"currentColor"})]}),closeOnSelect:!1})},controls_SeriesDisplayControl=SeriesDisplayControl,ZoomSwitch=()=>{let{state:{zoom:e,segments:t},dispatch:r}=useStore_useStore(),{show:n,autoCloseTimeout:a,interval:{start:i,end:o}}=e,l=t.totalPoints??0,s=Math.max(l-1,0),[c,u]=external_react_useState(!0),d=external_react_useRef(null);external_react_useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),external_react_useEffect(()=>{d.current&&clearTimeout(d.current),u(!1),d.current=setTimeout(()=>{h()},a)},[i,o,a]);let h=external_react_useCallback(()=>{r({payload:{zoom:buildZoomFullRange(e,l)}}),u(!0)},[e,l,r]),p=external_react_useMemo(()=>l?{background:`linear-gradient(to right,
|
|
3566
3566
|
transparent ${(i+1)/l*100}%,
|
|
3567
3567
|
var(--chart-grid-strong) ${(i+1)/l*100}%,
|
|
3568
3568
|
var(--chart-grid-strong) ${(o+1)/l*100}%,
|
|
@@ -3581,4 +3581,4 @@ ${buildRule(` ${t.systemDark}`,n)}
|
|
|
3581
3581
|
*
|
|
3582
3582
|
* This source code is licensed under the ISC license.
|
|
3583
3583
|
* See the LICENSE file in the root directory of this source tree.
|
|
3584
|
-
*/let minus_iconNode=[["path",{d:"M5 12h14",key:"1ays0h"}]],Minus=createLucideIcon("minus",minus_iconNode),check_iconNode=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Check=createLucideIcon("check",check_iconNode),checkbox_Checkbox=/*#__PURE__*/__rspack_external_react.forwardRef(({className:e,...t},r)=>/*#__PURE__*/jsx_runtime_jsx(Checkbox,{ref:r,"data-slot":"checkbox",className:cn_cn("peer inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--radius-micro)] border border-border bg-background text-primary shadow-xs transition-colors outline-none","focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground","data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",e),...t,children:/*#__PURE__*/jsx_runtime_jsx(CheckboxIndicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current",children:"indeterminate"===t.checked?/*#__PURE__*/jsx_runtime_jsx(Minus,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(Check,{className:"size-3.5"})})}));checkbox_Checkbox.displayName=Checkbox.displayName;let toCheckboxValue=e=>"checked"===e||"indeterminate"===e&&"indeterminate",SignalNodeCount=({count:e,show:t,testId:r})=>t?/*#__PURE__*/jsxs("span",{className:"shrink-0 tabular-nums text-[11px] font-normal text-muted-foreground","data-testid":r,children:["(",e,")"]}):null,SignalTypeRow=({source:e,type:t,leafKeysWithData:r,hiddenKeys:n,showCount:a,expanded:i,onToggleExpanded:o,onToggleNode:l})=>{let s=resolveNodeCheckState(r,n,t.leafKeys),c=`signal-tree-type-checkbox-${e.source}-${t.signalType}`,u=t.levels.length>0,d=u?void 0:t.color??SIGNAL_TYPE_MAP[t.signalType].color;return /*#__PURE__*/jsxs("div",{children:[/*#__PURE__*/jsxs("div",{className:"group flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-type-${e.source}-${t.signalType}`,children:[u?/*#__PURE__*/jsx_runtime_jsx("button",{type:"button","aria-label":i?"折叠信号类型":"展开信号类型",className:"flex size-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,children:i?/*#__PURE__*/jsx_runtime_jsx(ChevronDown,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(ChevronRight,{className:"size-3.5"})}):/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}),/*#__PURE__*/jsxs("label",{htmlFor:c,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===s?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:c,"aria-label":`${e.label} ${t.label}`,checked:toCheckboxValue(s),disabled:"disabled"===s,onCheckedChange:()=>l(t.leafKeys)}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("min-w-0 truncate text-xs font-medium","disabled"===s?"text-muted-foreground":"text-foreground/90"),"data-testid":`signal-tree-type-color-${e.source}-${t.signalType}`,style:"disabled"===s||null==d?void 0:{color:toOpaqueCssColor(d)},children:t.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:t.count,show:a,testId:`signal-tree-type-count-${e.source}-${t.signalType}`})]})]}),i&&u?/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative ml-6 border-l border-border/60 pl-1",children:t.levels.map(i=>/*#__PURE__*/jsx_runtime_jsx(SignalLevelRow,{source:e.source,signalType:t.signalType,level:i,leafKeysWithData:r,hiddenKeys:n,showCount:a,onToggleNode:l},i.leafKey))}):null]},t.signalType)},SignalLevelRow=({source:e,signalType:t,level:r,leafKeysWithData:n,hiddenKeys:a,showCount:i,onToggleNode:o})=>{let l=resolveNodeCheckState(n,a,[r.leafKey]),s=`signal-tree-level-checkbox-${e}-${t}-${r.level}`;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"group flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-level-${e}-${t}-${r.level}`,children:/*#__PURE__*/jsxs("label",{htmlFor:s,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===l?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:s,"aria-label":`${t} ${r.label}`,checked:toCheckboxValue(l),disabled:"disabled"===l,onCheckedChange:()=>o([r.leafKey])}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("text-xs font-medium","disabled"===l?"text-muted-foreground":"text-foreground/80"),"data-testid":`signal-tree-level-color-${e}-${t}-${r.level}`,style:"disabled"===l?void 0:{color:toOpaqueCssColor(r.color??SIGNAL_LEVEL_MAP[r.level].color)},children:r.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:r.count,show:i,testId:`signal-tree-level-count-${e}-${t}-${r.level}`})]})})},SignalAnnotationTree=({tree:e,leafKeysWithData:t,hiddenKeys:r,showCount:n,onToggleNode:a})=>{let[i,o]=external_react_useState(()=>new Set),[l,s]=external_react_useState(()=>new Set),c=external_react_useCallback(e=>{o(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),u=external_react_useCallback(e=>{s(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]);return /*#__PURE__*/jsx_runtime_jsx(scroll_area_ScrollArea,{viewportClassName:"h-auto max-h-[var(--radix-dropdown-menu-content-available-height)]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"p-[calc(var(--size-gap-base)/2)]",children:e.sources.map((e,o)=>{let s=resolveNodeCheckState(t,r,e.leafKeys),d=`signal-tree-source-checkbox-${e.source}`;return /*#__PURE__*/jsxs("div",{className:cn_cn(o>0&&"mt-[calc(var(--size-gap-base)/2)] border-t border-border/60 pt-[calc(var(--size-gap-base)/2)]"),"data-testid":`signal-tree-source-${e.source}`,children:[/*#__PURE__*/jsxs("div",{className:"flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-source-row-${e.source}`,children:[e.types.length>0?/*#__PURE__*/jsx_runtime_jsx("button",{type:"button","aria-label":l.has(e.source)?"展开数据来源":"折叠数据来源",className:"flex size-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:()=>u(e.source),children:l.has(e.source)?/*#__PURE__*/jsx_runtime_jsx(ChevronRight,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(ChevronDown,{className:"size-3.5"})}):/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}),/*#__PURE__*/jsxs("label",{htmlFor:d,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===s?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:d,"aria-label":`${e.label}筛选`,checked:toCheckboxValue(s),disabled:"disabled"===s,onCheckedChange:()=>a(e.leafKeys)}),/*#__PURE__*/jsx_runtime_jsx("span",{className:"text-xs font-medium text-foreground",children:e.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:e.count,show:n,testId:`signal-tree-source-count-${e.source}`})]})]}),l.has(e.source)?null:/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-4 divide-y divide-border/40 border-l border-border/60 pl-1",children:e.types.map(o=>/*#__PURE__*/jsx_runtime_jsx(SignalTypeRow,{source:e,type:o,leafKeysWithData:t,hiddenKeys:r,showCount:n,expanded:!i.has(`${e.source}:${o.signalType}`),onToggleExpanded:()=>c(`${e.source}:${o.signalType}`),onToggleNode:a},o.signalType))})]},e.source)})})})},Signal_Switch_Switch=()=>{let{state:{signal:e},dispatch:t}=useStore_useStore(),r=e.display,n=e.show,a=useUnifiedSignals({respectVisibility:!1,filterHidden:!1}),i=external_react_useMemo(()=>buildSignalTree(a),[a]),o=external_react_useMemo(()=>new Set(i.sources.flatMap(e=>e.dataLeafKeys)),[i]),l=external_react_useMemo(()=>new Set(e.hiddenCategoryKeys??[]),[e.hiddenCategoryKeys]),s=(e.hiddenCategoryKeys?.length??0)>0,c=external_react_useCallback(r=>{t({payload:{signal:{...e,display:r}}})},[e,t]),u=external_react_useCallback(r=>{let n=toggleNodeHiddenKeys(e.hiddenCategoryKeys??[],r,o);t({payload:{signal:{...e,hiddenCategoryKeys:n}}})},[e,o,t]);return n?/*#__PURE__*/jsx_runtime_jsx(ToolbarDropdownGroup,{leading:/*#__PURE__*/jsx_runtime_jsx(primitives_ToolbarGroupIconBox,{active:r,tone:"primary",onClick:()=>{c(!r)},title:`全部信号标注:${r?"显示":"隐藏"}`,children:/*#__PURE__*/jsx_runtime_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{fill:"currentColor",d:"M563.072 376.48a79.456 79.456 0 0 0 28.928-61.12 80 80 0 1 0-160 0c0 24.672 11.392 46.432 28.928 61.12l-202.88 540.256a32 32 0 1 0 59.904 22.496l49.28-131.264h289.504l49.28 131.264a32.064 32.064 0 0 0 41.248 18.752c16.544-6.208 24.896-24.672 18.72-41.216l-202.912-540.288z m-1.312 178.624h-99.552L512 422.56l49.76 132.544z m-170.464 188.896l46.912-124.896h147.616l46.912 124.896h-241.44zM662.464 417.408a32 32 0 1 0 53.12 35.648 254.72 254.72 0 0 0 43.136-142.304 255.04 255.04 0 0 0-43.136-142.304 32 32 0 1 0-53.12 35.68 190.944 190.944 0 0 1 32.288 106.624 190.816 190.816 0 0 1-32.288 106.656zM289.888 453.024a32 32 0 1 0 53.184-35.616 191.36 191.36 0 0 1-32.32-106.656 191.328 191.328 0 0 1 32.32-106.656 32.064 32.064 0 0 0-8.768-44.416 32.096 32.096 0 0 0-44.416 8.768 254.976 254.976 0 0 0-43.136 142.304 254.976 254.976 0 0 0 43.136 142.272zM210.656 117.12A32 32 0 1 0 157.44 81.536a420.032 420.032 0 0 0-70.848 233.824 419.744 419.744 0 0 0 70.88 233.856 31.936 31.936 0 0 0 44.416 8.768 32 32 0 0 0 8.768-44.416 355.168 355.168 0 0 1-60.032-198.24A355.36 355.36 0 0 1 210.656 117.12zM896.224 154.304a416.96 416.96 0 0 0-38.912-72.768 32 32 0 1 0-53.184 35.584 354.912 354.912 0 0 1 60.064 198.24 355.2 355.2 0 0 1-60.064 198.208 32.032 32.032 0 0 0 53.184 35.648 418.816 418.816 0 0 0 70.88-233.856c0-55.68-10.752-109.856-31.968-161.056z"})})}),value:null,options:[],triggerTitle:`筛选信号标注类别${s?"(已应用筛选)":""}`,triggerTestId:"signal-tree-trigger",triggerContent:/*#__PURE__*/jsx_runtime_jsx("span",{className:"sr-only",children:s?"信号标注类别筛选(已应用)":"信号标注类别筛选"}),customContent:/*#__PURE__*/jsx_runtime_jsx("div",{"data-testid":"signal-tree-popover",children:/*#__PURE__*/jsx_runtime_jsx(SignalAnnotationTree,{tree:i,leafKeysWithData:o,hiddenKeys:l,showCount:!1!==e.showCount,onToggleNode:u})}),contentClassName:"w-max max-w-[calc(100vw-1rem)] p-0",triggerClassName:cn_cn("justify-center [&>span:last-child]:ml-0",s&&"bg-accent/72 shadow-[inset_0_0_0_1px_var(--mix-primary-28)] [&>span:last-child]:text-primary")}):null},Signal_Switch=Signal_Switch_Switch,TOOLBAR_ITEM_CONFIGS=[{component:controls_AutorangingControl,toolType:constants_ToolbarItemType.AutorangingSwitch,supportedCharts:[],excludedCharts:[constants_ChartType.Heatmap,constants_ChartType.ScanDF360,constants_ChartType.LevelStream,constants_ChartType.LiteNormalized]},{component:controls_UnitControl,toolType:constants_ToolbarItemType.UnitSwitch,supportedCharts:[],excludedCharts:[constants_ChartType.ScanDF360,constants_ChartType.LevelStream]},{component:decorations_GradientRibbon,toolType:constants_ToolbarItemType.GradientRibbon,supportedCharts:[constants_ChartType.Heatmap]},{component:decorations_SpacerLine,toolType:constants_ToolbarItemType.SpacerLine,supportedCharts:[],excludedCharts:[constants_ChartType.ScanDF360,constants_ChartType.LevelStream]},{component:controls_Reset,toolType:constants_ToolbarItemType.Reset,supportedCharts:[],excludedCharts:[constants_ChartType.LiteNormalized]},{component:Signal_Switch,toolType:constants_ToolbarItemType.StationAllocationSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.DDC]},{component:controls_SeriesControl,toolType:constants_ToolbarItemType.SeriesControl,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan],props:{type:"dynamic"}},{component:FrequencyAllocation_Switch,toolType:constants_ToolbarItemType.FrequencyAllocationSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.LiteNormalized]},{component:Switch,toolType:constants_ToolbarItemType.ZoomSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.LiteNormalized]},{component:Limit_Switch,toolType:constants_ToolbarItemType.LimitSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan]},{component:Markers_Switch,toolType:constants_ToolbarItemType.MarkersSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan]},{component:controls_SegmentsDisplayControl,toolType:constants_ToolbarItemType.SegmentsDisplayControl,supportedCharts:[constants_ChartType.Scan]},{component:Capture_Switch,toolType:constants_ToolbarItemType.HeatmapCaptureSwitch,supportedCharts:[constants_ChartType.Heatmap]},{component:TimeRange_Switch,toolType:constants_ToolbarItemType.TimeRangeSwitch,supportedCharts:[constants_ChartType.Heatmap]},{component:controls_SeriesDisplayControl,toolType:constants_ToolbarItemType.SeriesDisplayControl,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.LiteNormalized,constants_ChartType.MScan]},{component:Fluorescence_Switch,toolType:constants_ToolbarItemType.FluorescenceSwitch,supportedCharts:[constants_ChartType.SingleFrequency]},{component:DeltaMeasurement_Switch,toolType:constants_ToolbarItemType.DeltaMeasurementSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan]}],isToolbarItemVisible=(e,t,r=[])=>!new Set(r).has(e.toolType)&&(e.supportedCharts.length>0?!!t&&e.supportedCharts.includes(t):!e.excludedCharts||!(e.excludedCharts.length>0)||!t||!e.excludedCharts.includes(t)),resolveToolbarItemProps=(e,t)=>e.props?"dynamic"===e.props.type?{...e.props,type:t}:e.props:{},Toolbar=({type:e})=>{let t=useStore_useSelector(e=>e.toolbar.show),r=useStore_useSelector(e=>e.toolbar.hiddenTools??[]),{width:n,pluginBoxWidth:a}=useAxisYWidth_useAxisYWidth(),i=external_react_useMemo(()=>({marginLeft:n,width:a,...TOOLBAR_SHELL_STYLE}),[n,a]),o=external_react_useMemo(()=>TOOLBAR_ITEM_CONFIGS.filter(t=>isToolbarItemVisible(t,e,r)).map(t=>/*#__PURE__*/jsx_runtime_jsx(t.component,{...resolveToolbarItemProps(t,e)},t.toolType)),[r,e]);return e!==constants_ChartType.Occupancy&&t?/*#__PURE__*/jsx_runtime_jsx("div",{className:TOOLBAR_SHELL_CLASS_NAME,style:i,children:/*#__PURE__*/jsx_runtime_jsx("div",{className:TOOLBAR_ITEMS_CLASS_NAME,children:o})}):null},components_Toolbar=/*#__PURE__*/memo(Toolbar);function useLevelStreamAnalyzer(){let{state:{globalID:e,axisY:t,levelStream:r}}=useStore_useStore(),n=t.range??constants_RANGE_DEFAULT,{cacheTime:a=2e4,granularity:i=1,maxPoints:o=500}=r??{},l=external_react_useRef(null),s=external_react_useRef(e),c=external_react_useCallback(e=>{passThrough(s.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,data:{[REAL_DATA_NAME]:e.spectrumData}}),passThrough(s.current,constants_ModuleType.LevelStream)({pstype:constants_PSType.Render,data:e.probabilityRangeData})},[]),u=external_react_useCallback(e=>{let{probabilityRangeData:t,spectrumData:r}=e;withDatabase(s.current).getAllRawData=t=>({...getDefaultData().getAllRawData(t),levelStreamData:e}),c({probabilityRangeData:t,spectrumData:r})},[c]);if(external_react_useEffect(()=>{s.current=e},[e]),!l.current&&e){l.current=new LevelStreamAnalyzer({range:n,cacheTime:a,granularity:i,maxPoints:o,onLevelStreamUpdate:u});let{line:t}=getConfig("levelStream");passThrough(e,constants_ModuleType.Spectrum)({pstype:constants_PSType.Series,name:REAL_DATA_NAME,color:t})}return external_react_useEffect(()=>{l.current?.setConfig({range:n})},[n]),external_react_useEffect(()=>{l.current?.setConfig({cacheTime:a})},[a]),external_react_useEffect(()=>{l.current?.setConfig({granularity:i})},[i]),external_react_useEffect(()=>{l.current?.setConfig({onLevelStreamUpdate:u})},[u]),{analyzer:l.current,updateLevelStreamData:c}}class Occupancy extends BaseRenderer{constructor(e){super({id:e.id,chart:null,orientation:e.orientation??renderer_OrientationType.Vertical})}init(){let{id:e,orientation:t}=this.state,r=[...getGradient()].reverse().map(e=>hexToRGBA(e));this.state.chart=new Series({id:e,series:[{name:"bar",type:renderer_GraphicType.Bar,display:!0,color:getConfig("bar"),orientation:t}],range:[0,100],barValue2Color:!0,colors:r})}updateSeries(e){this.state.chart?.render({name:"bar",data:e})}}let Level=e=>{let{opacity:t}=e,{chart:r,Chart:n}=hooks_useChart({Render:Occupancy,params:{orientation:renderer_OrientationType.Horizontal}});return useModuleSubscription({moduleType:constants_ModuleType.LevelStream,chart:r,extractData:e=>e.data}),/*#__PURE__*/jsx_runtime_jsx(n,{style:external_react_useMemo(()=>({opacity:t,zIndex:1}),[t])})},modules_Level=Level,MAJOR_TICK_LENGTH=6,MINOR_TICK_LENGTH=4,TEXT_OFFSET=8,resolveAxisYCanvasHorizontalLayout=({axisLineWidth:e,inside:t,width:r})=>t?{axisX:e,majorTickEndX:MAJOR_TICK_LENGTH,majorTickStartX:0,minorTickEndX:MINOR_TICK_LENGTH,minorTickStartX:0,textAlign:"left",textX:TEXT_OFFSET}:{axisX:r-e,majorTickEndX:r,majorTickStartX:r-MAJOR_TICK_LENGTH,minorTickEndX:r,minorTickStartX:r-MINOR_TICK_LENGTH,textAlign:"right",textX:r-TEXT_OFFSET},LINE_WIDTH_BASE=.5,MINOR_TICK_DIVISIONS=2,MIN_TICK_SPACING=4,MIN_CONTAINER_HEIGHT=100,IDEAL_TICK_COUNT=7,MIN_RANGE_SPAN=.5,MAJOR_TICK_LINE_WIDTH=2*LINE_WIDTH_BASE,MINOR_TICK_LINE_WIDTH=LINE_WIDTH_BASE,AXIS_LINE_WIDTH=LINE_WIDTH_BASE;function useCanvasAxisY(e){let{ranging:t}=e,{range:r,disabled:n,placement:a,show:i}=useStore_useSelector(e=>e.axisY),o="inside"===a,l=external_react_useRef(null),s=external_react_useRef(null),[c,u]=external_react_useState(0),[d,h]=external_react_useState(window.devicePixelRatio||1),[p,f]=external_react_useState(!1),[m,g]=external_react_useState(0),b=external_react_useCallback((e,t)=>{let r=.5*(Math.max(1,Math.round(t*d))%2!=0);return(Math.round(e*d-r)+r)/d},[d]),v=external_react_useCallback((e,t,r)=>{let n=r/2;return Math.min(t-n,Math.max(n,e))},[]),w=external_react_useMemo(()=>{let[e,t]=r;return{min:e,max:t}},[r]);external_react_useEffect(()=>{let e=window.matchMedia(`(resolution: ${d}dppx)`),t=()=>h(window.devicePixelRatio||1);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[d]),external_react_useEffect(()=>{let e=s.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];t&&u(t.contentRect.height)});return t.observe(e),()=>t.disconnect()},[i]);let y=external_react_useCallback((e,t)=>{if(t.useScientific)return e.toExponential(1);if(t.useKFormat){let r=e/1e3;return t.useDecimals?`${r.toFixed(1)}k`:`${Math.round(r)}k`}return t.useDecimals?e.toFixed(1):Math.round(e).toString()},[]),x=external_react_useMemo(()=>{let e;if(0===c)return{majorTicks:[],minorTicks:[]};let t=w.max-w.min,r=t/IDEAL_TICK_COUNT,n=10**Math.floor(Math.log10(r)),a=r/n;e=Math.max(e=a<=1?n:a<=2?2*n:a<=5?5*n:a<=6?6*n:10*n,MIN_RANGE_SPAN/(2*IDEAL_TICK_COUNT));let i=[],o=Math.ceil(w.min/e)*e,l=w.max+1e-6*e;for(let t=o;t<=l;t+=e)i.push(t);let s=i.some(e=>Math.abs(e)>=1e3),u=i.some(e=>.01>Math.abs(e)&&0!==e),d={useScientific:u,useKFormat:s&&!u,useDecimals:i.some(e=>e%1!=0)},h=[];for(let r=o;r<=l;r+=e){let e=(w.max-r)/t*c,n=e,a=!0,i=!1,o=c-5,l=.3*c;e<-l||e>c+l?a=!1:e<5?(n=5,i=!0):e>o&&(n=o,i=!0),a&&h.push({value:r,position:e,textPosition:n,label:y(r,d),isAdjusted:i})}let p=[],f=e/MINOR_TICK_DIVISIONS,m=f/t*c,g=t<1;if(m>=(g?2*MIN_TICK_SPACING:MIN_TICK_SPACING)&&c>MIN_CONTAINER_HEIGHT&&!g){let r=Math.ceil(w.min/f)*f;for(let n=r;n<=w.max;n+=f){if(Math.abs(n%e)<.1*f)continue;let r=(w.max-n)/t*c;r>=0&&r<=c&&p.push({value:n,position:r,textPosition:r,label:""})}}return{majorTicks:h,minorTicks:p}},[w,c,y]),k=external_react_useCallback(()=>{let e=l.current;if(!e||0===c)return;let t=e.getContext("2d");if(!t)return;let r=e.getBoundingClientRect().width,n=resolveAxisYCanvasHorizontalLayout({axisLineWidth:AXIS_LINE_WIDTH,inside:o,width:r});e.width=r*d,e.height=c*d,e.style.width=`${r}px`,e.style.height=`${c}px`,t.setTransform(d,0,0,d,0,0),t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.clearRect(0,0,r,c),t.font="12px -apple-system, BlinkMacSystemFont, sans-serif",t.textAlign=n.textAlign,t.textBaseline="middle",t.lineWidth=MAJOR_TICK_LINE_WIDTH;let a=getThemeColor("--foreground",.5,s.current);x.majorTicks.forEach(e=>{t.fillStyle=a,t.strokeStyle=a,t.fillText(e.label,n.textX,e.textPosition),t.beginPath();let r=b(v(e.position,c,MAJOR_TICK_LINE_WIDTH),MAJOR_TICK_LINE_WIDTH);t.moveTo(n.majorTickStartX,r),t.lineTo(n.majorTickEndX,r),t.stroke()}),t.strokeStyle=a,t.lineWidth=MINOR_TICK_LINE_WIDTH,x.minorTicks.forEach(e=>{t.beginPath();let r=b(v(e.position,c,MINOR_TICK_LINE_WIDTH),MINOR_TICK_LINE_WIDTH);t.moveTo(n.minorTickStartX,r),t.lineTo(n.minorTickEndX,r),t.stroke()}),t.strokeStyle=a,t.lineWidth=AXIS_LINE_WIDTH,t.beginPath();let i=b(n.axisX,AXIS_LINE_WIDTH);t.moveTo(i,0),t.lineTo(i,c),t.stroke()},[x,c,d,o,b,v]);external_react_useEffect(()=>{!1!==i&&k()},[k,i]),external_react_useEffect(()=>subscribeChartsThemeChange(()=>{k()}),[k]);let S=external_react_useCallback(e=>{n||(f(!0),g(e.clientY))},[n]),D=external_react_useCallback(e=>{n||t.moveWheel?.(e)},[t,n]),M=external_react_useCallback(e=>{if(n||!p||!s.current)return;let r=(e.clientY-m)/s.current.offsetHeight;Math.abs(r)>(w.max-w.min<1?.005:.01)&&(t.move?.(r),g(e.clientY))},[n,p,m,t,w]);return{canvasRef:l,containerRef:s,isDragging:p,range:w,handleMouseDown:S,handleMouseMove:M,handleMouseUp:external_react_useCallback(()=>{n||f(!1)},[n]),handleMouseLeave:external_react_useCallback(()=>{n||f(!1)},[n]),handleWheel:D,ticksData:x}}function AxisYCanvas(e){let{chart:t}=e,{state:{axisY:r}}=useStore_useStore(),{show:n}=r,a=spectrum_useRanging({chart:t}),{axisYWidth:i,inside:o,marginLeft:l}=useAxisYWidth_useAxisYWidth(),{canvasRef:s,containerRef:c,isDragging:u,handleMouseDown:d,handleMouseMove:h,handleMouseUp:p,handleMouseLeave:f,handleWheel:m}=useCanvasAxisY({ranging:a});return!1===n?null:/*#__PURE__*/jsx_runtime_jsx("div",{ref:c,className:cn_cn("h-full select-none",o?"absolute left-0 top-0 z-[7]":"relative",u?"cursor-grabbing":"cursor-ns-resize"),style:{width:i,marginLeft:l},onMouseDown:d,onMouseMove:h,onMouseUp:p,onMouseLeave:f,onWheel:m,onDoubleClick:()=>{let e=tools_getAxisYDoubleClickResetRange(r.restrict);a.setAxisY?.({realRange:e}),a.onChange?.()},children:/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:s,className:"pointer-events-none absolute left-0 top-0 h-full w-full"})})}let EPSILON=1e-9,getDistinctPrecision=(e,t,r,n,a)=>{for(let i=n;i<=a;i+=1)if(r(e,i)!==r(t,i))return i;return a},DEFAULT_MEASUREMENT_RECT={position:40,height:20,leftPosition:40,width:20},DeltaMeasurement=()=>{let{state:{deltaMeasurement:{show:e,display:t,onChange:r},axisX:{frequencyFormat:n},axisY:{unit:a,range:i},segments:o}}=useStore_useStore(),[l,s]=external_react_useState(null),[c,u]=external_react_useState(DEFAULT_MEASUREMENT_RECT),d=external_react_useCallback(e=>{if(!n||!o?.length)return null;let{leftPosition:t,width:r,position:a,height:l}=e,s=n(t),c=n(t+r),u=s?Number(s):0,d=c?Number(c):0,[h,p]=i||[-120,0],f=p-h,m=p-a/100*f,g=p-(a+l)/100*f;return{deltaX:Math.abs(d-u),deltaY:Math.abs(m-g),centerFrequency:(u+d)/2,startFrequency:u,endFrequency:d,startAmplitude:g,endAmplitude:m}},[n,o,i]),h=external_react_useCallback(e=>{u(e);let t=d(e);t&&s(t)},[d]),p=external_react_useCallback(e=>{u(e);let t=d(e);t&&(s(t),r?.(t))},[d,r]);external_react_useEffect(()=>{if(t){u(DEFAULT_MEASUREMENT_RECT);let e=d(DEFAULT_MEASUREMENT_RECT);e&&s(e)}else s(null),r?.(null)},[t,d,r]);let f=(e,t=3)=>formatFrequencyUnitFromMHz(e,t).formatted,m=(e,t=2)=>{let r=Number.parseFloat(e.toFixed(t));return`${r} ${a}`},g=external_react_useMemo(()=>{if(!l)return{labels:void 0,middleContent:null};let e=l.deltaX<=EPSILON,t=l.deltaY<=EPSILON,r=e?3:getDistinctPrecision(l.startFrequency,l.endFrequency,f,3,6),n=t?2:getDistinctPrecision(l.startAmplitude,l.endAmplitude,m,2,4),i=f(l.startFrequency,r),o=f(l.endFrequency,r),s=m(l.endAmplitude,n),c=m(l.startAmplitude,n),u=f(l.deltaX,r),d=`${Number.parseFloat(l.deltaY.toFixed(n))} ${a}`,h=f(l.centerFrequency,r);return{labels:{left:e?void 0:i,right:e?void 0:o,top:t?void 0:s,bottom:t?void 0:c},middleContent:/*#__PURE__*/jsxs("div",{className:"grid gap-0.5",children:[/*#__PURE__*/jsx_runtime_jsx("div",{children:e?`频点: ${i}`:`ΔX: ${u}`}),/*#__PURE__*/jsx_runtime_jsx("div",{children:t?`幅度: ${c}`:`ΔY: ${d}`}),!e&&/*#__PURE__*/jsxs("div",{children:["中心: ",h]})]})}},[l,a]);return /*#__PURE__*/jsx_runtime_jsx(components_DragSelectBox,{enabled:e&&t,defaultRect:c,minSize:0,minWidth:0,minHeight:0,onChange:h,onDragEnd:p,zIndex:7,labels:g.labels,children:g.middleContent})},Spectrum_DeltaMeasurement=DeltaMeasurement,maxIndexSegments2FrequencyBandwidth=({frequencyLeft:e,segments:t})=>leftSegments2frequency(t)(e),startEnd2AnalyseFrequencyBandwidth=({e,zoom:t,segments:r,onChange:n,globalID:a})=>{let{realData:i}=withDatabase(a).getAllRawData();if(!i)return;let o=i.length,{interval:{start:l,end:s}}=t,{left:c}=e,u=e.left+e.width,d=convertCoordToVisualLeft({coord:e,segments:r,zoom:t}),h=convertCoordToVisualLeft({coord:{left:u},segments:r,zoom:t}),p=Math.max(0,Math.ceil(o*d/100)-1),f=Math.ceil(o*h/100),{maxIndex:m}=(0,array_0.jy)(Array.from(i.slice(p,f)));n({frequency:maxIndexSegments2FrequencyBandwidth({frequencyLeft:(l+(p+m+1)/o*(s-l))*100/r.totalPoints,segments:r}),bandwidth:Math.round(1e3*scopeLeftSegments2bandwidth({segments:r,endLeft:u,startLeft:c})),left:d,right:h})},DragFrame_COMPONENT_KEY=constants_ToolType.DragFrame,DragFrame=({id:e})=>{let{state:{zoom:t,segments:r,signalAnalysis:n,globalID:a},dispatch:i}=useStore_useStore(),[o,l]=external_react_useState(null),s=external_react_useCallback((e,o=!1)=>{n.show&&n.display&&o?startEnd2AnalyseFrequencyBandwidth({e,zoom:t,segments:r,onChange:n.onChange,globalID:a}):i({payload:{zoom:{...t,interval:e.interval,isScanSegmentsUpdateMagnify:e.isScanSegmentsUpdateMagnify}}})},[n,t,r,a]),c=external_react_useCallback((e,t,r,n)=>{if(e&&t&&n){let r=e.left,n=t.left,a=n-r;l({diffX:a,left:a>0?r:n,width:Math.abs(a),isScanSegmentsUpdateMagnify:a>0})}},[]),u=external_react_useCallback(()=>{if(!o)return;let{left:e,width:t,isScanSegmentsUpdateMagnify:n,diffX:a}=o,{totalPoints:i}=r;if(n&&a>0){let r=createSelectedXZoomInterval({startPercent:e,endPercent:e+t,totalPoints:i}),a=r?r.end-r.start+1:0;r&&a>UI_CONFIG.ZOOM_MIN_RANGE&&s({interval:r,isScanSegmentsUpdateMagnify:n,left:e,width:t},!0)}a<0&&s({interval:{start:0,end:i-1},isScanSegmentsUpdateMagnify:n,left:e,width:t})},[o,r,t.interval.end,s]);return(external_react_useEffect(()=>{if(t.show){let t=()=>{l(null),resetEventLevel(e,DragFrame_COMPONENT_KEY)};createMouseDownEventManager(e,DragFrame_COMPONENT_KEY,t),createMouseUpEventManager(e,DragFrame_COMPONENT_KEY,()=>{u(),t()}),createMouseLeaveEventManager(e,DragFrame_COMPONENT_KEY,t),createDragEventManager(e,DragFrame_COMPONENT_KEY,(...t)=>{compareEventPriority(e,DragFrame_COMPONENT_KEY)&&c(t[0],t[1],t[2],t[3])})}},[t.show,e,u,c]),external_react_useEffect(()=>{o||resetEventLevel(e,DragFrame_COMPONENT_KEY)},[o,e]),t.show)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-[-100%] top-0 h-full w-0 box-border border-2 border-dashed border-chart-grid-strong bg-chart-surface opacity-40",style:o?{left:`${o.left}%`,width:`${o.width}%`}:{},children:o&&!o.isScanSegmentsUpdateMagnify&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 opacity-20",style:{background:"linear-gradient(to top right, transparent, transparent calc(50% - 1px), var(--chart-grid-strong), transparent calc(50% + 1px), transparent)"}}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 opacity-20",style:{background:"linear-gradient(to bottom right, transparent, transparent calc(50% - 1px), var(--chart-grid-strong), transparent calc(50% + 1px), transparent)"}})]})})}):null},Spectrum_DragFrame=/*#__PURE__*/memo(DragFrame),FREQUENCY_ALLOCATION_LANE_HEIGHT=14,FREQUENCY_ALLOCATION_COMPACT_LANE_HEIGHT=5,FREQUENCY_ALLOCATION_COMPACT_THRESHOLD=4,resolveFrequencyAllocationDensity=({density:e="auto",channelCount:t})=>{let r="compact"===e||"auto"===e&&t>FREQUENCY_ALLOCATION_COMPACT_THRESHOLD;return{compact:r,laneHeight:r?FREQUENCY_ALLOCATION_COMPACT_LANE_HEIGHT:FREQUENCY_ALLOCATION_LANE_HEIGHT,showLabels:!r}},optimizedColors=null,originalColors=["#B22222","#CD5C5C","#FF6347","#FA8072","#F08080","#A0522D","#FF4500","#FF7F50","#B8860B","#FFA500","#808000","#9ACD32","#32CD32","#8FBC8F","#2E8B57","#3CB371","#00FA9A","#66CDAA","#7FFFD4","#2F4F4F","#008080","#00CED1","#20B2AA","#48D1CC","#4682B4","#778899","#87CEFA","#4169E1","#4169E1","#6495ED","#483D8B","#6A5ACD","#7B68EE","#9370DB","#9370DB","#9932CC","#8A2BE2","#BA55D3","#800080","#DDA0DD","#C71585","#DC143C"];function hexToHsl(e){let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,n=parseInt(e.slice(5,7),16)/255,a=Math.max(t,r,n),i=Math.min(t,r,n),o=0,l=0,s=(a+i)/2;if(a!==i){let e=a-i;switch(l=s>.5?e/(2-a-i):e/(a+i),a){case t:o=(r-n)/e+6*(r<n);break;case r:o=(n-t)/e+2;break;case n:o=(t-r)/e+4}o/=6}return{h:360*o,s:100*l,l:100*s}}let sortedColors=[...originalColors].map(e=>({color:e,hsl:hexToHsl(e)})).sort((e,t)=>Math.abs(e.hsl.h-t.hsl.h)>10?e.hsl.h-t.hsl.h:e.hsl.l-t.hsl.l).map(e=>e.color);function sortAndRecolorFrequencyAllocationData(e){let t=[...e].sort((e,t)=>Number(e.startFrequency)-Number(t.startFrequency));return t.map((e,r)=>{let n=t.length,a=sortedColors.length,i=Math.floor(r/n*a),o=Math.floor((r+1)/n*a),l=sortedColors[Math.min(i,a-1)],s=sortedColors[Math.min(o,a-1)],c=r===n-1?sortedColors[a-1]:s;return{...e,color:l,gradientColors:[l,c]}})}let FrequencyAllocation_data=[{startFrequency:87,stopFrequency:108,stepFrequency:100,bandwidth:150,modulation:"AM",demodulation:"不解调",status:"合法",title:"FM广播",description:"FM调频广播频段,用于音频广播服务"},{startFrequency:108,stopFrequency:118,stepFrequency:50,bandwidth:100,modulation:"FM",demodulation:"解调",status:"合法",title:"航空导航",description:"航空无线电导航频段,用于仪表着陆系统等"},{startFrequency:118,stopFrequency:137,stepFrequency:25,bandwidth:50,modulation:"AM",demodulation:"解调",status:"合法",title:"航空语音通信",description:"民用航空语音通信频段"},{startFrequency:121,stopFrequency:122,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"紧急通信",description:"紧急情况通信专用频段"},{startFrequency:136,stopFrequency:174,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"对讲通信",description:"专业无线对讲通信频段"},{startFrequency:161,stopFrequency:162,stepFrequency:25,bandwidth:50,modulation:"GMSK",demodulation:"解调",status:"合法",title:"AIS船舶通信",description:"船舶自动识别系统(AIS)专用频段"},{startFrequency:351,stopFrequency:400,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"集群通信",description:"专业集群通信系统频段"},{startFrequency:400,stopFrequency:470,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"专业对讲",description:"专业无线对讲通信频段"},{startFrequency:534,stopFrequency:542,stepFrequency:100,bandwidth:8e3,modulation:"OFDM",demodulation:"解调",status:"合法",title:"数字电视",description:"数字电视广播频段"},{startFrequency:622,stopFrequency:630,stepFrequency:100,bandwidth:8e3,modulation:"OFDM",demodulation:"解调",status:"合法",title:"数字电视",description:"数字电视广播频段"},{startFrequency:703,stopFrequency:733,stepFrequency:100,bandwidth:3e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G上行(广电/移动)",description:"广电和移动5G网络上行频段"},{startFrequency:758,stopFrequency:788,stepFrequency:100,bandwidth:3e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G下行(广电/移动)",description:"广电和移动5G网络下行频段"},{startFrequency:806,stopFrequency:821,stepFrequency:25,bandwidth:50,modulation:"π/4DQPSK",demodulation:"解调",status:"合法",title:"数字集群上行",description:"数字集群通信系统(TETRA)上行频段"},{startFrequency:824,stopFrequency:835,stepFrequency:100,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"电信3G/4G/5G上行",description:"中国电信3G/4G/5G网络上行频段"},{startFrequency:851,stopFrequency:866,stepFrequency:25,bandwidth:50,modulation:"π/4DQPSK",demodulation:"解调",status:"合法",title:"数字集群下行",description:"数字集群通信系统(TETRA)下行频段"},{startFrequency:869,stopFrequency:880,stepFrequency:100,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"电信3G/4G/5G下行",description:"中国电信3G/4G/5G网络下行频段"},{startFrequency:885,stopFrequency:889,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"GSM-R上行",description:"铁路专用GSM-R网络上行频段"},{startFrequency:889,stopFrequency:904,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"移动2G/4G上行",description:"中国移动2G/4G网络上行频段"},{startFrequency:904,stopFrequency:915,stepFrequency:200,bandwidth:200,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/3/4/5G上行",description:"中国联通2G/3G/4G/5G网络上行频段"},{startFrequency:930,stopFrequency:934,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"GSM-R下行",description:"铁路专用GSM-R网络下行频段"},{startFrequency:934,stopFrequency:949,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"移动2G/4G下行",description:"中国移动2G/4G网络下行频段"},{startFrequency:949,stopFrequency:960,stepFrequency:200,bandwidth:200,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/3/4/5G下行",description:"中国联通2G/3G/4G/5G网络下行频段"},{startFrequency:1164,stopFrequency:1189,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L5频段",description:"全球定位系统GPS L5频段"},{startFrequency:1215,stopFrequency:1234,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L2频段",description:"全球定位系统GPS L2频段"},{startFrequency:1447,stopFrequency:1467,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"政务公安专网",description:"政务和公安专用LTE网络频段"},{startFrequency:1563,stopFrequency:1587,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L1频段",description:"全球定位系统GPS L1频段"},{startFrequency:1710,stopFrequency:1735,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"移动2G/4G上行",description:"中国移动2G/4G网络上行频段"},{startFrequency:1735,stopFrequency:1765,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/4G上行",description:"中国联通2G/4G网络上行频段"},{startFrequency:1805,stopFrequency:1830,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"移动2G/4G下行",description:"中国移动2G/4G网络下行频段"},{startFrequency:1830,stopFrequency:1860,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/4G下行",description:"中国联通2G/4G网络下行频段"},{startFrequency:1885,stopFrequency:1915,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动4G",description:"中国移动4G网络频段"},{startFrequency:1920,stopFrequency:1940,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"电信/联通5G上行",description:"中国电信/联通5G网络上行频段"},{startFrequency:1940,stopFrequency:1965,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"联通3/4/5G上行",description:"中国联通3G/4G/5G网络上行频段"},{startFrequency:2110,stopFrequency:2130,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"电信/联通5G下行",description:"中国电信/联通5G网络下行频段"},{startFrequency:2300,stopFrequency:2320,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"联通4G",description:"中国联通4G网络频段"},{startFrequency:2320,stopFrequency:2370,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动4G",description:"中国移动4G网络频段"},{startFrequency:2400,stopFrequency:2500,stepFrequency:1,bandwidth:20,modulation:"OFDM",demodulation:"解调",status:"合法",title:"ISM 2.4GHz",description:"WIFI、蓝牙、无人机等使用频段"},{startFrequency:2515,stopFrequency:2675,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动5G/4G",description:"中国移动5G和4G网络频段"},{startFrequency:3300,stopFrequency:3600,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G频段",description:"电信、联通、广电5G网络频段"},{startFrequency:4800,stopFrequency:4900,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动5G",description:"中国移动5G网络频段"},{startFrequency:4900,stopFrequency:4960,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"广电5G",description:"中国广电5G网络频段"},{startFrequency:5725,stopFrequency:5875.5,stepFrequency:5,bandwidth:20,modulation:"OFDM",demodulation:"解调",status:"合法",title:"ISM 5GHz",description:"WIFI、无人机等使用频段"}],STORAGE_KEY="rfkit-charts-frequency-allocation",isFrequencyAllocationChannelCache=e=>!!e&&"object"==typeof e&&2===e.version&&Array.isArray(e.channels),readFrequencyAllocationCache=()=>{let e=localStorage.getItem(STORAGE_KEY);if(!e)return null;let t=JSON.parse(e);return Array.isArray(t)||isFrequencyAllocationChannelCache(t)?t:null},getFrequencyAllocationFromCache=()=>{let e=readFrequencyAllocationCache();return Array.isArray(e)?e:null},getFrequencyAllocationChannelsFromCache=()=>{let e=readFrequencyAllocationCache();return isFrequencyAllocationChannelCache(e)?e.channels:null},setFrequencyAllocationToCache=e=>{localStorage.setItem(STORAGE_KEY,JSON.stringify(e))},setFrequencyAllocationChannelsToCache=e=>{localStorage.setItem(STORAGE_KEY,JSON.stringify({version:2,channels:e}))},clearFrequencyAllocationCache=()=>{localStorage.removeItem(STORAGE_KEY)},hasFrequencyAllocationCache=()=>null!==localStorage.getItem(STORAGE_KEY),DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID="default",resolveChannelId=(e,t)=>e.id||e.title||`${DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID}-${t}`,normalizeChannels=(e,t)=>e.map((e,r)=>({id:resolveChannelId(e,r),title:e.title,data:t(e.data??[])})).filter(e=>e.data.length>0),normalizeSingleChannel=(e,t)=>[{id:DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID,data:t(e)}];function resolveFrequencyAllocationChannelModel({data:e,channels:t,cachedData:r,cachedChannels:n,presetData:a,normalizeData:i}){if(t)return t.length?normalizeChannels(t,i):normalizeSingleChannel(e?.length?e:a,i);if(n?.length)return normalizeChannels(n,i);let o=e??[];return normalizeSingleChannel(r&&r.length>0?r:o.length>0?o:a,i)}function resolveFrequencyAllocationChannels({data:e,channels:t}){return resolveFrequencyAllocationChannelModel({data:e,channels:t,cachedData:getFrequencyAllocationFromCache(),cachedChannels:getFrequencyAllocationChannelsFromCache(),presetData:FrequencyAllocation_data,normalizeData:sortAndRecolorFrequencyAllocationData})}function resolveFrequencyAllocationData_resolveFrequencyAllocationData(e){return resolveFrequencyAllocationChannels({data:e})[0]?.data??[]}let resolveFrequencyAllocationRange=e=>{if(null!=e.startFrequency&&null!=e.stopFrequency){let t=frequencyCalculation_calculateFrequencyRange({startFrequency:Number(e.startFrequency),stopFrequency:Number(e.stopFrequency)});if(t)return{start:t.startFreq,stop:t.stopFreq,type:"range"}}return null},resolveFrequencyAllocationSegments=({segments:e,allocations:t,channelIndex:r,channelTitle:n})=>{if(!e.length||!t.length)return[];let a=e.reduce((e,t)=>e+t.point,0);return e.map((i,o)=>{let l=t.map(e=>{let t=resolveFrequencyAllocationRange(e);if(!t||t.stop<i.start||t.start>i.stop)return null;let{left:a,width:o}=calculatePositionFromFrequencyRange({startFreq:t.start,stopFreq:t.stop},i);return{band:e,range:t,channelIndex:r??0,channelTitle:n,position:{left:`${a}%`,width:`${o}%`}}}).filter(e=>null!==e),s=i.point/a*100,c=e.slice(0,o).reduce((e,t)=>e+t.point/a*100,0);return{segment:i,segmentIndex:o,bandPositions:l,style:{left:`${c}%`,width:`${s}%`}}})},resolveFrequencyAllocationLanes=({segments:e,channels:t})=>t.map((t,r)=>({channel:t,channelIndex:r,segmentData:resolveFrequencyAllocationSegments({segments:e,allocations:t.data,channelIndex:r,channelTitle:t.title})})).filter(e=>e.segmentData.some(e=>e.bandPositions.length>0)),resolver_createFrequencyAllocationRangeIndex=e=>e.map(e=>{let t=calculateFrequencyRange({frequency:null!=e.centerFrequency?Number(e.centerFrequency):void 0,bandwidth:null!=e.bandwidth?Number(e.bandwidth):void 0,startFrequency:null!=e.startFrequency?Number(e.startFrequency):void 0,stopFrequency:null!=e.stopFrequency?Number(e.stopFrequency):void 0});return t?{item:e,range:t,width:Math.abs(t.stopFreq-t.startFreq),center:(t.startFreq+t.stopFreq)/2,title:String(e.title??"")}:null}).filter(e=>null!==e),resolver_findFrequencyAllocationInRangeIndex=({rangeIndex:e,frequency:t})=>{let r;if(Number.isFinite(t)&&e.length){for(let n of e){let{range:e}=n;if(t<e.startFreq||t>e.stopFreq)continue;if(!r){r=n;continue}let a=n.width-r.width;if(a<0){r=n;continue}if(a>0)continue;let i=Math.abs(n.center-t)-Math.abs(r.center-t);if(i<0){r=n;continue}!(i>0)&&0>n.title.localeCompare(r.title)&&(r=n)}return r?.item}},findFrequencyAllocationAtCursor=({allocations:e,frequency:t})=>resolver_findFrequencyAllocationInRangeIndex({rangeIndex:resolver_createFrequencyAllocationRangeIndex(e),frequency:t});function useFrequencyAllocationData_useFrequencyAllocationData(){let e=useSelector(e=>e.frequencyAllocation.data);return useMemo(()=>resolveFrequencyAllocationData(e),[e])}function useFrequencyAllocationChannels(){let e=useStore_useSelector(e=>e.frequencyAllocation.data),t=useStore_useSelector(e=>e.frequencyAllocation.channels);return external_react_useMemo(()=>resolveFrequencyAllocationChannels({data:e,channels:t}),[e,t])}function useAllocationAtCursor({frequency:e,cursorSample:t}){let r=useSelector(e=>e.cursor),n=useSelector(e=>e.segments),a=useSelector(e=>e.frequencyAllocation.display),i=useSelector(e=>e.frequencyAllocation.show),o=t?.coord.left??r.coord.left,l=useFrequencyAllocationData(),s=useMemo(()=>createFrequencyAllocationRangeIndex(l),[l]),c=useMemo(()=>!!t||hasActiveSpectrumCursor(r),[r,t]),u=useMemo(()=>c&&"number"==typeof o?calculateCursorPosition(o,n):{segmentIndex:-1,pointIndex:-1},[c,o,n]);return useMemo(()=>{if(!i||!a||!e||!n?.length||!c||!n[u.segmentIndex])return;let t=getCursorFrequencyAtPosition(n,u),r=Number.isFinite(t)?t:Number(e);if(Number.isFinite(r))return findFrequencyAllocationInRangeIndex({rangeIndex:s,frequency:r})},[s,u.segmentIndex,a,e,c,n,i])}let useAllocationFinder=null,AllocationInfo=({allocationInfo:e,variant:t="default"})=>{if(!e)return null;let{title:r,description:n,startFrequency:a,stopFrequency:i,centerFrequency:o,stepFrequency:l,bandwidth:s,modulation:c,channelTitle:u}=e;return /*#__PURE__*/jsxs("div",{className:cn_cn("text-xs leading-5 text-popover-foreground","board"===t&&"mt-[calc(var(--size-gap-base)/2)] border-t border-dashed border-border pt-[calc(var(--size-gap-base)/2)]"),children:[r?/*#__PURE__*/jsx_runtime_jsx("div",{className:"mb-1 font-bold",children:r}):null,/*#__PURE__*/jsxs("div",{className:"mb-1 text-primary",children:[u?/*#__PURE__*/jsxs("div",{children:["通道:",u]}):null,a&&i&&/*#__PURE__*/jsxs("div",{children:["频率范围:",a," - ",i]}),o?/*#__PURE__*/jsxs("div",{children:["中心频率:",o," MHz"]}):null,l?/*#__PURE__*/jsxs("div",{children:["步进:",l," kHz"]}):null,s?/*#__PURE__*/jsxs("div",{children:["带宽:",s," MHz"]}):null,c?/*#__PURE__*/jsxs("div",{children:["调制方式:",c]}):null]}),n?/*#__PURE__*/jsx_runtime_jsx("div",{className:"leading-5 opacity-85",children:n}):null]})},presenters_AllocationInfo=/*#__PURE__*/react.memo(AllocationInfo),AllocationSegments=/*#__PURE__*/memo(({style:e,bandPositions:t,showLabels:r,onMouseEnter:n,onMouseMove:a,onMouseLeave:i})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute top-0 h-full [contain:layout]",style:e,children:t.map(e=>{let{band:t,channelIndex:o,range:l,position:s}=e;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute flex h-full items-center justify-center overflow-hidden px-1 text-xs text-foreground/90 opacity-60 backdrop-blur-sm transition-[opacity,box-shadow] duration-200 hover:z-[1] hover:opacity-100 hover:shadow-lg",style:{...t.gradientColors?{backgroundImage:`linear-gradient(to right, ${t.gradientColors[0]}, ${t.gradientColors[1]})`}:{backgroundColor:t.color||"var(--primary)"},left:s.left,width:s.width},onMouseEnter:n(e),onMouseMove:a,onMouseLeave:i,children:r?/*#__PURE__*/jsx_runtime_jsx("span",{className:"truncate",children:t.title}):null},`band-${o??0}-${t.title}-${l.start}-${l.stop}-${s.left}`)})})),presenters_AllocationSegments=AllocationSegments,overlays_Tooltip_Tooltip=({title:e,description:t,visible:r,x:n,y:a,startFrequency:i,stopFrequency:o,centerFrequency:l,stepFrequency:s,bandwidth:c,modulation:u,channelTitle:d,positionRef:h,scheduleRef:p})=>{let f=external_react_useRef(null),m=external_react_useRef(null),g=external_react_useCallback(()=>{if(!r||!f.current)return;let e=f.current,t=e.offsetWidth,i=e.offsetHeight,o=window.innerWidth,l=window.innerHeight,s=h.current??{x:n,y:a},c=s.x,u=s.y,d=Math.max(12,Math.min(c+t>o-12?c-t-10:c,o-t-12)),p=Math.max(12,Math.min(u+i>l-12?u-i-10:u,l-i-12));e.style.transform=`translate3d(${d}px, ${p}px, 0)`},[h,r,n,a]),b=external_react_useCallback(()=>{r&&null===m.current&&(m.current=requestAnimationFrame(()=>{m.current=null,g()}))},[g,r]);return(external_react_useEffect(()=>(p.current=b,()=>{p.current===b&&(p.current=null)}),[b,p]),external_react_useEffect(()=>{if(r)return b(),()=>{null!==m.current&&(cancelAnimationFrame(m.current),m.current=null)}},[b,r]),r)?/*#__PURE__*/jsx_runtime_jsx("div",{ref:f,className:"pointer-events-none fixed z-[1000] max-w-[300px] rounded-[var(--radius-surface)] border border-border/70 bg-chart-panel/95 p-[var(--size-gap-base)] text-chart-panel-foreground shadow-lg backdrop-blur-md",style:{left:0,top:0,transform:`translate3d(${n}px, ${a}px, 0)`},children:/*#__PURE__*/jsx_runtime_jsx(presenters_AllocationInfo,{allocationInfo:{title:e,description:t,startFrequency:i,stopFrequency:o,centerFrequency:l,stepFrequency:s,bandwidth:c,modulation:u,channelTitle:d}})}):null},overlays_Tooltip=overlays_Tooltip_Tooltip,FrequencyAllocation=()=>{let e=useStore_useSelector(e=>e.axisX.unit),t=useStore_useSelector(e=>e.segments),r=useStore_useSelector(e=>e.frequencyAllocation.display),n=useStore_useSelector(e=>e.frequencyAllocation.show),a=useStore_useSelector(e=>e.frequencyAllocation.density),i=useStore_useSelector(e=>e.zoom.style),o=useFrequencyAllocationChannels(),[l,s]=external_react_useState({visible:!1,x:0,y:0}),c=external_react_useRef({x:0,y:0}),u=external_react_useRef(null),d=external_react_useCallback(e=>{c.current={x:e.clientX+10,y:e.clientY+10},u.current?.()},[]),h=external_react_useMemo(()=>resolveFrequencyAllocationLanes({segments:t,channels:o}),[t,o]),{laneHeight:p,showLabels:f}=resolveFrequencyAllocationDensity({density:a,channelCount:h.length}),m=Math.max(p,h.length*p),g=external_react_useCallback(e=>{s(t=>({...t,...e}))},[]),b=external_react_useCallback(({band:t,channelTitle:r,range:n})=>a=>{d(a);let i={...t,visible:!0,x:c.current.x,y:c.current.y,channelTitle:r,startFrequency:`${n.start}${e}`,stopFrequency:`${n.stop}${e}`};"centerBandwidth"===n.type&&null!=n.frequency&&null!=n.bandwidth&&(i.centerFrequency=`${n.frequency}${e}`,i.bandwidth=`${n.bandwidth}${e}`),g(i)},[e,g,d]),v=external_react_useCallback(e=>{d(e)},[d]),w=external_react_useCallback(()=>{g({visible:!1})},[g]);return n&&r&&0!==h.length?/*#__PURE__*/jsxs("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-[5] flex w-full select-none items-center overflow-hidden",style:{height:m,backgroundColor:"var(--mix-chart-surface-12)"},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 h-full w-full will-change-transform",style:i??void 0,children:h.map(({channel:e,channelIndex:t,segmentData:r})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 w-full",style:{bottom:t*p,height:p},children:r.map(({segmentIndex:t,bandPositions:r,style:n})=>/*#__PURE__*/jsx_runtime_jsx(presenters_AllocationSegments,{style:n,bandPositions:r,showLabels:f,onMouseEnter:b,onMouseMove:v,onMouseLeave:w},`channel-${e.id}-segment-${t}`))},`channel-${e.id}`))}),/*#__PURE__*/jsx_runtime_jsx(overlays_Tooltip,{...l,positionRef:c,scheduleRef:u})]}):null},Spectrum_FrequencyAllocation=FrequencyAllocation,useUpdateKey=e=>{let[t,r]=external_react_useState(0);return external_react_useEffect(()=>{if(!e)return;let t=withUpdateData(e,"FrequencyTagLineBoard",()=>{r(e=>e+1)});return()=>{t?.()}},[e]),t},Board=({id:e})=>{let{state:{frequencyTagLine:t,cursor:r}}=useStore_useStore(),{show:n,display:a,left:i,onChange:o}=t,l=useUpdateKey(e),s=r.show&&r.active&&r.event?.sourceType===constants_ModuleType.Spectrum,c=external_react_useCallback(e=>{if(!e)return;let{index:t,frequency:r}=e;(0,array_0.Ub)(r)&&o({index:t,frequency:r})},[o]);return n&&a&&!s?/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute bottom-5 right-[34px] z-[6] h-auto w-auto",children:/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyDataBoard,{left:i,updateKey:l,onChange:c,showSignalInfo:!1})}):null},FrequencyTagLine_Board=/*#__PURE__*/react.memo(Board),FrequencyTagLine_Switch_Switch=()=>{let{state:{frequencyTagLine:e},dispatch:t}=useStore(),{display:r,show:n}=e,a=useCallback(r=>{t({payload:{frequencyTagLine:{...e,display:!!r}}})},[e]),i=useMemo(()=>/*#__PURE__*/_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",children:/*#__PURE__*/_jsx("path",{d:"M288 128H896l-120 256L896 640H288v320H192v-896h96V128z",fillOpacity:".65",fill:"currentColor",style:{transition:"fill 0.2s ease"}})}),[r]);return n?/*#__PURE__*/_jsx(IconBox,{active:r,tone:"primary",onClick:()=>a(!r),title:"频率标记线显示控制",children:i}):null},FrequencyTagLine_Switch=/*#__PURE__*/null,FrequencyTagLine_COMPONENT_KEY=constants_ToolType.FrequencyTagLine,FrequencyTagLine=e=>{let{state:{frequencyTagLine:t},dispatch:r}=useStore_useStore(),{show:n,display:a,left:i,onChange:o}=t,{id:l}=e,s=external_react_useRef(t);return(external_react_useEffect(()=>{s.current=t},[t]),external_react_useEffect(()=>{let e=createMouseUpEventManager(l,FrequencyTagLine_COMPONENT_KEY,()=>{n&&a&&resetEventLevel(l,FrequencyTagLine_COMPONENT_KEY)}),t=createMouseLeaveEventManager(l,FrequencyTagLine_COMPONENT_KEY,()=>{n&&a&&resetEventLevel(l,FrequencyTagLine_COMPONENT_KEY)});return()=>{e?.(),t?.()}},[l,n,a,o]),external_react_useEffect(()=>{let e=createMouseDownEventManager(l,FrequencyTagLine_COMPONENT_KEY,e=>{n&&a&&r({payload:{frequencyTagLine:{...s.current,...e,id:l}}})}),t=createDragEventManager(l,FrequencyTagLine_COMPONENT_KEY,(e,t)=>{n&&a&&(compareEventPriority(l,FrequencyTagLine_COMPONENT_KEY),r({payload:{frequencyTagLine:{...s.current,...t,id:l}}}))});return()=>{e?.(),t?.()}},[l,n,a,r]),external_react_useEffect(()=>{r({payload:{frequencyTagLine:{...t,left:-100}}})},[n]),n&&a)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-px border-l border-dashed border-chart-highlight/80 opacity-80",style:{left:`${i}%`}})}):null},Spectrum_FrequencyTagLine=/*#__PURE__*/react.memo(FrequencyTagLine),LIMIT_THRESHOLD_TEXT_STYLE={color:SPECTRUM_THRESHOLD_COLOR},LIMIT_THRESHOLD_LINE_STYLE={borderColor:SPECTRUM_THRESHOLD_COLOR},Item_Item=({value:e,onChange:t,dragging:r})=>{let{state:{axisY:n,limit:a}}=useStore_useStore(),{label:i,disabled:o}=a,{unit:l="",range:s=constants_RANGE_DEFAULT,step:c=constants_stepDefault}=n,[u,d]=s,h=external_react_useMemo(()=>isdBm(l)?dBuV2dBm(0):0,[l]),p=external_react_useCallback(e=>(d-e-h)/(d-u)*100,[d,h,u]),f=external_react_useMemo(()=>p(e),[p,e]),m=external_react_useMemo(()=>Math.round(h+e),[h,e]),[g,b]=external_react_useState(!1),v=external_react_useRef(null),w=external_react_useCallback(e=>{switch(e.key){case"Enter":{if(!v.current){b(!1);break}let e=Number(v.current.value);!Number.isNaN(e)&&e>=u&&e<=d&&(t?.(Math.floor(e-h)),v.current.blur()),b(!1);break}case"Escape":b(!1)}},[v,s,h,t]);return /*#__PURE__*/jsx_runtime_jsx("div",{className:"relative h-full w-full",children:/*#__PURE__*/jsxs("div",{className:"absolute right-0 h-0 w-full",style:{top:`${f}%`},children:[!g||o?/*#__PURE__*/jsxs("button",{type:"button",disabled:o,className:`${r?"pointer-events-none":"pointer-events-auto"} absolute right-7 top-[-28px] z-[8] flex h-6 appearance-none items-center justify-center rounded-[var(--radius-control)] border-0 bg-secondary px-2 text-xs text-foreground`,style:LIMIT_THRESHOLD_TEXT_STYLE,onClick:()=>b(!0),children:[i," ",m,l]}):/*#__PURE__*/jsxs("div",{className:"pointer-events-auto absolute right-7 top-[-28px] z-[8] flex h-6 items-center justify-between bg-secondary px-2 text-xs text-foreground",style:LIMIT_THRESHOLD_TEXT_STYLE,children:[i," ",/*#__PURE__*/jsx_runtime_jsx("input",{ref:v,type:"number","aria-label":`${i}${l}门限值`,defaultValue:m,min:u,max:d,step:c/5,className:"h-auto w-14 border-none bg-transparent p-0 text-center outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",style:LIMIT_THRESHOLD_TEXT_STYLE,onKeyDown:w}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"flex items-center",children:l})]}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-[-0.5px] z-[8] h-0 w-full border-b border-dashed",style:LIMIT_THRESHOLD_LINE_STYLE})]})})},Limit_Item=Item_Item,COMPONENT_NAME=constants_ToolType.Limit,HIT_SLOP_PX=10,Limit=({id:e})=>{let{state:{limit:t,segments:r,axisY:n,system:a},dispatch:i}=useStore_useStore(),{show:o,active:l,disabled:s,value:c,onChange:u,unified:d}=t,[h,p]=n.range,{totalPoints:f}=r,m=external_react_useMemo(()=>o&&l,[o,l]),[g,b]=external_react_useState(0/0),v=external_react_useRef(null),w=external_react_useRef(!1),y=external_react_useRef(t);external_react_useEffect(()=>{y.current=t},[t]);let x=external_react_useCallback((e,t)=>{let r,n=d?[t]:((r=[...y.current.value])[e]=t,r);i({payload:{limit:{...y.current,value:n}}})},[i,d]),k=external_react_useCallback(()=>{u(d?Array.from({length:r.length},()=>y.current.value[0]):y.current.value)},[u,d,r.length]);return(external_react_useEffect(()=>{createMouseDownEventManager(e,COMPONENT_NAME,e=>{if(!m||s||!e?.left||!e?.top)return;let t=e.left,i=d?0:r.findIndex(e=>e.progress[0]<=t&&t<e.progress[1]);if(!Number.isFinite(i)||i<0){b(0/0),v.current=null,w.current=!1;return}let o=p-h;if(!Number.isFinite(o)||0===o)return;let l=isdBm(n.unit)?dBuV2dBm(0):0,c=y.current.value[i],u=(p-c-l)/o*100,f=Math.max(1.2,HIT_SLOP_PX/Math.max(1,a.height||1)*100);if(Math.abs(e.top-u)>f){b(0/0),v.current=null,w.current=!1;return}b(i),v.current=c,w.current=!0}),createMouseLeaveEventManager(e,COMPONENT_NAME,()=>{m&&!s&&(w.current&&k(),b(0/0),v.current=null,w.current=!1,resetEventLevel(e,COMPONENT_NAME))}),createMouseUpEventManager(e,COMPONENT_NAME,()=>{m&&!s&&(w.current&&k(),b(0/0),v.current=null,w.current=!1,resetEventLevel(e,COMPONENT_NAME))}),createDragEventManager(e,COMPONENT_NAME,(t,r,n)=>{if(m&&!s&&(0,array_0.Ub)(g)&&compareEventPriority(e,COMPONENT_NAME)&&n?.top){let e=p-h;if(!Number.isFinite(e)||0===e)return;let t=(v.current??y.current.value[g])-n.top*e;v.current=t,x(g,t)}})},[m,s,g,r,e,x,k,d,h,p,n.unit,a.height]),m)?d?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[7]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full w-full",style:{opacity:+!!(0,array_0.Ub)(c[0])},children:/*#__PURE__*/jsx_runtime_jsx(Limit_Item,{id:e,value:c[0],onChange:e=>x(0,e),dragging:(0,array_0.Ub)(g)})})}):/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[7]",children:r?.map((t,r)=>/*#__PURE__*/jsx_runtime_jsx("div",{style:{width:`${100*t.point/f}%`,opacity:+!!(0,array_0.Ub)(c[r])},className:"h-full w-[30%]",children:/*#__PURE__*/jsx_runtime_jsx(Limit_Item,{id:e,value:c[r],onChange:e=>x(r,e),dragging:(0,array_0.Ub)(g)},t.index)},t.index))}):null},Spectrum_Limit=Limit,useMarkerEvents_COMPONENT_KEY=constants_ToolType.Markers,MARKER_HIT_PX=6,MARKER_HOVER_PX=8,useMarkerEvents=e=>{let{id:t,markers:r,display:n,fixed:a,readonly:i,onCreateMarker:o,onDeleteMarker:l,onUpdateMarker:s,onToggleSelect:c,onHover:u,onResetHover:d}=e,h=external_react_useRef({isDown:null,dragStart:null,isHover:"",hoverId:null}),p=external_react_useCallback(()=>document.getElementById(getEID(t))??document.getElementById(t),[t]),f=external_react_useCallback(e=>{if(!e||!r||0===r.length)return null;let{left:t}=e;if(void 0===t)return null;let n=p();if(!n)return null;let{width:a}=n.getBoundingClientRect();for(let e=0;e<r.length;e+=1){let n=r[e];if(n&&Math.abs(t-n.left)*a/100<=MARKER_HIT_PX)return{...n,index:e}}return null},[p,r]),m=external_react_useCallback(e=>{let t=p();if(!t)return"";let n=t.getBoundingClientRect().width,a="";for(let t=0;t<r.length;t+=1){let i=r[t];if(i&&Math.abs(e.left-i.left)*n/100<=MARKER_HOVER_PX){a={...i,index:t};break}}return a},[p,r]);return external_react_useEffect(()=>{if(i)return;let e=createMoveEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,t)=>{if(n&&void 0!==t.left){let e=m({left:t.left}),r="object"==typeof e?e.id:null;if(h.current.hoverId===r){h.current.isHover=e;return}h.current.isHover=e,h.current.hoverId=r,u({left:t.left})}}),r=createDragEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{let{isDown:i}=h.current;n&&i&&compareEventPriority(t,useMarkerEvents_COMPONENT_KEY)&&!a&&s(i.id,{left:r.left,top:r.top})}),p=createMouseDownEventManager(t,useMarkerEvents_COMPONENT_KEY,e=>{if(!n)return;let t=f(e)||("object"==typeof h.current.isHover?h.current.isHover:null);t&&!a&&(h.current.isDown=t)}),g=createMouseUpEventManager(t,useMarkerEvents_COMPONENT_KEY,()=>{n&&(h.current.isDown=null,resetEventLevel(t,useMarkerEvents_COMPONENT_KEY))}),b=createMouseLeaveEventManager(t,useMarkerEvents_COMPONENT_KEY,()=>{if(!n)return;let e=null!==h.current.hoverId;h.current.isDown=null,h.current.isHover="",h.current.hoverId=null,resetEventLevel(t,useMarkerEvents_COMPONENT_KEY),e&&d()}),v=createLongPressEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{if(!n||!compareEventPriority(t,useMarkerEvents_COMPONENT_KEY))return;let a=f(r)||("object"==typeof h.current.isHover?h.current.isHover:null);a?.id&&c(a.id)}),w=createDoubleClickEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{if(!n||!compareEventPriority(t,useMarkerEvents_COMPONENT_KEY)||void 0===r.left)return!1;let a=m({left:r.left});return a&&"object"==typeof a&&a.id?l(a.id):o({left:r.left}),!0});return()=>{e?.(),r?.(),p?.(),g?.(),b?.(),v?.(),w?.()}},[t,n,r,a,i,o,l,s,c,u,d,f,m]),{isDown:h.current.isDown}},markerColors=getConfig("marker"),getRequiredGlobalStoreState=e=>getGlobalStoreState(e);function getPeaksFromDatabase(e,t,r){let{needsMaxPeak:n=!1,needsTopPeaks:a=!1}=r||{},i=null,o=null;try{let t=withDatabase(e).getAllRawData()[REAL_DATA_NAME];if(t?.peaks?.peaks&&Array.isArray(t.peaks.peaks)){let e=t.peaks.peaks;return n&&e.length>0&&(i=e[0]),a&&(o=e),{maxPeak:i,topPeaks:o}}}catch(e){console.warn("[useMarkers] Failed to get precomputed peaks:",e)}return n&&(i=findMaxPeak(t)),a&&(o=findTopPeaks(t,2)),{maxPeak:i,topPeaks:o}}let useMarkers=e=>{let{id:t,globalID:r,onChange:n}=e,[a,i]=external_react_useState({markers:[],colorIndex:0,isDown:null,isHover:"",peak:null,hasPeak:!1}),o=external_react_useRef(new Float32Array),l=external_react_useCallback((e,t)=>{let{axisY:{unit:n},axisX:{frequencyFormat:a}}=getRequiredGlobalStoreState(r),i=e.left,{peak:l}=e,s=t?.data??o.current;s&&0!==s.length||(s=withDatabase(r).getAllRawData()[REAL_DATA_NAME]),o.current=s;let c=splitZoomLeft({left:i,globalID:r}),{outsideLeft:u,multiple:d}=c,{insideLeft:h}=c,p=s.length,f=Math.floor(p*h/100);if(100===h&&(f=p-1),"mainSecondary"===e.peakTracking&&"number"==typeof e.peakRank){let n=t?.topPeaks;n||(n=getPeaksFromDatabase(r,s,{needsTopPeaks:!0}).topPeaks);let a=n?.[e.peakRank];a&&(h=((f=a.index)+.5)*100/p)}else if(l){let e=t?.maxPeak;e||(e=getPeaksFromDatabase(r,s,{needsMaxPeak:!0}).maxPeak),e&&(h=((f=e.index)+.5)*100/p)}let m=parseFloat(a(i=u+h/d)),g=s[f];return void 0===g||Number.isNaN(g)||(e.level=parseFloat(getVirtualLevel(n,g).toFixed(1))),{...e,left:i,frequency:m}},[r]),s=external_react_useCallback((e,t=!1)=>{0!==o.current.length&&i(a=>{let{marker:{maxCount:i}}=getRequiredGlobalStoreState(r);if(a.markers.length>=i)return a;let o=createGUID(),s=markerColors[a.colorIndex%20],c={...l({...e,id:o,color:s,select:!1,peak:!1,frequency:0,hover:!1}),id:o,color:s,select:!t,peak:!1,hover:!1},u=[...t?a.markers:a.markers.map(e=>({...e,select:!1})),c];return t||setTimeout(()=>{n?.(constants_MarkerEventType.Add,u)},0),{...a,markers:u,colorIndex:a.colorIndex+1}})},[l,n]),c=external_react_useCallback(({event:e,marker:t,frequencies:a,silent:s=!1})=>{i(i=>{let c=[...i.markers],u=constants_MarkerEventType.Update,{id:d,peak:h,select:p,frequency:f,left:m,top:g}=t||{},b=m;if(e===constants_MarkerEventType.Update&&void 0!==f){let e=getGlobalStoreState(r),t=(e?.segments||{totalPoints:0})[0];if(t&&d){let{start:e,stop:r}=t,n=r-e;if(void 0!==n&&f<r&&f>e)b=(f-e)*100/n;else{let e=c.findIndex(e=>e.id===d);-1!==e&&(c.splice(e,1),u=constants_MarkerEventType.Del)}}}if(e===constants_MarkerEventType.Add&&a?.length){let e=getGlobalStoreState(r),t=(e?.segments||{totalPoints:0})[0];if(t){let{start:e,stop:r}=t,n=r-e;if(void 0!==n){let t=[];for(let i=0;i<a.length;i+=1){let o=a[i];o>=e&&o<=r&&t.push((o-e)*100/n)}t.length>0&&(a=t)}}}if(e===constants_MarkerEventType.Add&&a?.length){let{marker:{maxCount:e}}=getRequiredGlobalStoreState(r),t=e-c.length,n=Math.min(a.length,t);c=c.map(e=>({...e,select:!1}));for(let e=0;e<n;e+=1){let t=createGUID(),r=markerColors[(i.colorIndex+e)%20],s=!1;if(o.current&&o.current.length>0){let t=-1/0,r=0;for(let e=0;e<o.current.length;e++)o.current[e]>t&&(t=o.current[e],r=e);Math.abs(Math.floor(o.current.length*a[e]/100)-r)<=Math.max(1,Math.floor(.01*o.current.length))&&(s=!0)}let u=l({left:a[e],id:t,color:r,select:!1,peak:s,frequency:0,hover:!1});c.push({...u,id:t,color:r,select:e===n-1,peak:s,hover:!1})}u=constants_MarkerEventType.Add}if(e===constants_MarkerEventType.Del){let e=c.findIndex(e=>e.id===d);-1!==e&&(c.splice(e,1),u=constants_MarkerEventType.Del)}return e===constants_MarkerEventType.Clear&&(c=[],u=constants_MarkerEventType.Clear),e===constants_MarkerEventType.Update&&(u=constants_MarkerEventType.Update,c=c.map(e=>(void 0!==h&&(e.peak=!1),void 0!==p&&e.id!==d&&(e.select=!1),e.id===d&&(void 0!==b&&(e=l({...e,left:b,top:g||e.top})),void 0!==p&&(e.select=p),void 0!==h&&(e.peak=h,h&&void 0===p&&(e.select=!0))),e.peak,e))),s||setTimeout(()=>{n?.(u,c)},0),{...i,markers:c,colorIndex:e===constants_MarkerEventType.Clear?0:i.colorIndex}})},[l,n]),u=external_react_useCallback(()=>{i(e=>({...e,markers:[],colorIndex:0})),setTimeout(()=>{n?.(constants_MarkerEventType.Clear,[])},0)},[n]),d=external_react_useCallback(e=>{e&&(o.current=e),i(t=>{if(0===t.markers.length)return t;let a=t.markers.some(e=>e.peak&&"mainSecondary"!==e.peakTracking),i=t.markers.some(e=>"mainSecondary"===e.peakTracking&&"number"==typeof e.peakRank),s=e??o.current??new Float32Array,{maxPeak:c,topPeaks:u}=getPeaksFromDatabase(r,s,{needsMaxPeak:a,needsTopPeaks:i}),d=t.markers.map(e=>l(e,{data:s,maxPeak:c,topPeaks:u}));return d.some((e,r)=>{let n=t.markers[r];return n&&(Math.abs(e.frequency-n.frequency)>.001||Math.abs(e.level-n.level)>.001)})&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,d)},0),{...t,markers:d}})},[l,n]),h=external_react_useCallback(e=>{let a=document.getElementById(t);if(!a)return"";let o=a.getBoundingClientRect(),{zoom:{interval:{start:l,end:s}},segments:c}=getRequiredGlobalStoreState(r),u=c.totalPoints/(s-l+1),d=o.width*u/100,h="",p=!1;return i(t=>{let r=t.markers.map((t,r)=>{let n=Math.abs(e.left-t.left)*d<=16;return t.hover!==n&&(p=!0),n&&(h={...t,index:r}),{...t,hover:n}});return p&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,r)},0),{...t,markers:r,isHover:h}}),h},[t,r,n]),p=external_react_useCallback(()=>{i(e=>{let t=!1,r=e.markers.map(e=>(e.hover&&(t=!0),{...e,hover:!1}));return t&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,r)},0),{...e,markers:r,isHover:""}})},[n]),f=external_react_useRef(null),m=external_react_useRef(null),g=external_react_useCallback(()=>{i(e=>{if(e.markers.some(e=>"mainSecondary"===e.peakTracking)){let t=e.markers.filter(e=>"mainSecondary"!==e.peakTracking),r=f.current;if(r){let e=t.findIndex(e=>e.id===r);-1!==e&&(t[e]={...t[e],select:!0})}return f.current=null,setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}}let{marker:t}=getRequiredGlobalStoreState(r);if(t.maxCount-e.markers.length<2)return e;f.current=e.markers.find(e=>e.select)?.id??null;let a=[],i=e.colorIndex,s=e=>{let t=createGUID(),r=markerColors[i%20];i+=1;let n=l({left:50,id:t,color:r,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:e,frequency:0,hover:!1});a.push({...n,id:t,color:r,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:e,hover:!1})};s(0),s(1);let c=[...e.markers,...a.map(e=>({...e,select:!1}))].map(e=>l(e,{data:o.current}));return setTimeout(()=>{n?.(constants_MarkerEventType.Update,c)},0),{...e,markers:c,colorIndex:i}})},[l,r,n]),b=external_react_useCallback(()=>{i(e=>{if(e.markers.some(e=>"mainSecondary"===e.peakTracking&&0===e.peakRank)){let t=e.markers.filter(e=>"mainSecondary"!==e.peakTracking||0!==e.peakRank),r=m.current;if(r){let e=t.findIndex(e=>e.id===r);-1!==e&&(t[e]={...t[e],select:!0})}return m.current=null,setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}}let{marker:t}=getRequiredGlobalStoreState(r);if(t.maxCount-e.markers.length<1)return e;m.current=e.markers.find(e=>e.select)?.id??null;let a=createGUID(),i=markerColors[e.colorIndex%20],s={...l({left:50,id:a,color:i,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:0,frequency:0,hover:!1}),id:a,color:i,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:0,hover:!1},c=[...e.markers,s].map(e=>l(e,{data:o.current}));return setTimeout(()=>{n?.(constants_MarkerEventType.Update,c)},0),{...e,markers:c,colorIndex:e.colorIndex+1}})},[l,r,n]),v=external_react_useCallback((e,t)=>{i(a=>{let i=a.markers.find(e=>e.id===t);if(!i)return a;let s=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!s||s.length<3)return a;o.current=s;let{zoom:c,segments:u}=getRequiredGlobalStoreState(r),d=s.length,h=u.totalPoints||d,p=c.interval.end-c.interval.start+1,f=(i.left*h/100-c.interval.start)*100/p,m=Math.floor(d*f/100);100===f&&(m=d-1);let g=-1;if(s.peaks?.peaks&&Array.isArray(s.peaks.peaks)){let t=s.peaks.peaks;if("left"===e){let e=1/0;for(let r of t)if(r.index<m){let t=m-r.index;t<e&&(e=t,g=r.index)}}else{let e=1/0;for(let r of t)if(r.index>m){let t=r.index-m;t<e&&(e=t,g=r.index)}}}if(-1===g){let t=e=>{if(e<=0||e>=d-1)return!1;let t=s[e];return t>s[e-1]&&t>s[e+1]};if("left"===e){for(let e=m-1;e>0;e-=1)if(t(e)){g=e;break}}else for(let e=m+1;e<d-1;e+=1)if(t(e)){g=e;break}}if(-1===g)return a;let b=((g+.5)*100/d*p/100+c.interval.start)*(100/h),v=a.markers.map(e=>{if(e.id!==t)return{...e,select:!1};let{peakTracking:r,peakRank:n,...a}=e;return l({...a,left:b,select:!0,peak:!1},{data:s})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,v)},0),{...a,markers:v}})},[l,r,n]),w=external_react_useCallback(e=>{i(t=>{if(!t.markers.find(t=>t.id===e))return t;let a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<1)return t;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=(100*d/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),f=t.markers.map(t=>{if(t.id!==e)return{...t,select:!1};let{peakTracking:r,peakRank:n,...i}=t;return l({...i,left:p,select:!0,peak:!1},{data:a})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,f)},0),{...t,markers:f}})},[l,r,n]),y=external_react_useCallback(e=>{i(t=>{if(!t.markers.find(t=>t.id===e))return t;let a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<3)return t;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=Math.max(2,Math.floor(.1*c)),f=-1,m=-1/0;for(let e=1;e<c-1;e+=1){if(Math.abs(e-d)<p)continue;let t=a[e],r=a[e-1],n=a[e+1];t>r&&t>n&&t>m&&(m=t,f=e)}if(-1===f)return t;let g=(100*f/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),b=t.markers.map(t=>{if(t.id!==e)return{...t,select:!1};let{peakTracking:r,peakRank:n,...i}=t;return l({...i,left:g,select:!0,peak:!1},{data:a})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,b)},0),{...t,markers:b}})},[l,r,n]),x=external_react_useCallback((e,t)=>{i(a=>{let i,s=a.markers.find(e=>e.id===t);if(!s)return a;let c=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!c||c.length<2)return a;o.current=c;let{zoom:u,segments:d}=getRequiredGlobalStoreState(r),h=c.length,p=d.totalPoints||h,f=u.interval.end-u.interval.start+1,m=Math.round((h-1)*((s.left*p/100-u.interval.start)*100/f)/100);if((i="left"===e?Math.max(0,m-1):Math.min(h-1,m+1))===m)return a;let g=(100*i/(h-1)*f/100+u.interval.start)*(100/p),b=a.markers.map(e=>{if(e.id!==t)return{...e,select:!1};let{peakTracking:r,peakRank:n,...a}=e;return l({...a,left:g,select:!0,peak:!1},{data:c})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,b)},0),{...a,markers:b}})},[l,r,n]),k="#F98116",S="#AA74E8",D=external_react_useCallback(()=>{i(e=>{let t,a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<1)return e;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=(100*d/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),f=e.markers.find(e=>e.color===k);if(f)t=e.markers.map(e=>e.id===f.id?l({...e,left:p},{data:a}):e);else{let{marker:n}=getRequiredGlobalStoreState(r),i=n.maxCount;if(e.markers.length>=i)return e;let o=l({left:p,id:createGUID(),color:k,select:!1,peak:!1,hover:!1},{data:a});t=[...e.markers,o]}return setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}})},[l,r,n]),M=external_react_useCallback(()=>{i(e=>{let t,a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<3)return e;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=Math.max(2,Math.floor(.1*c)),f=-1,m=-1/0;for(let e=1;e<c-1;e+=1){if(Math.abs(e-d)<p)continue;let t=a[e],r=a[e-1],n=a[e+1];t>r&&t>n&&t>m&&(m=t,f=e)}if(-1===f)return e;let g=(100*f/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),b=e.markers.find(e=>e.color===S);if(b)t=e.markers.map(e=>e.id===b.id?l({...e,left:g},{data:a}):e);else{let{marker:n}=getRequiredGlobalStoreState(r),i=n.maxCount;if(e.markers.length>=i)return e;let o=l({left:g,id:createGUID(),color:S,select:!1,peak:!1,hover:!1},{data:a});t=[...e.markers,o]}return setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}})},[l,r,n]);return{markers:a.markers,isDown:a.isDown,isHover:a.isHover,createMarker:s,updateMarkerAttribute:c,resetMarkers:u,updateByData:d,handleHover:h,resetHover:p,toggleMainSecondaryPeaks:g,toggleMainPeak:b,moveToAdjacentPeak:v,findMainPeak:w,findSecondaryPeak:y,moveToStep:x,createMainPeakMarker:D,createSecondaryPeakMarker:M,setState:i}},Dashed=e=>{let{top:t,left:r,color:n="transparent",x:a=!0,y:i=!0,lineWidth:o=1}=e;return /*#__PURE__*/jsxs(Fragment,{children:[a&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 top-[-200%] z-[5] w-full border-t border-dashed",style:{top:t,borderColor:n,borderTopWidth:`${o}px`}}),i&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-[-200%] top-0 z-[5] h-full border-l border-dashed",style:{left:r,borderColor:n,borderLeftWidth:`${o}px`}})]})},components_Dashed=Dashed,MarkerItem=({marker:e})=>{let{state:{axisX:t,axisY:r}}=useStore_useStore(),n=external_react_useRef(null),a=external_react_useRef(null),[i,o]=external_react_useState(0),[l,s]=external_react_useState(0);external_react_useEffect(()=>{let e=()=>{n.current&&o(n.current.offsetWidth),a.current&&s(a.current.offsetWidth)};e();let t=new ResizeObserver(()=>{e()});return n.current&&t.observe(n.current),a.current&&t.observe(a.current),()=>{t.disconnect()}},[e.frequency,e.level]);let c=external_react_useMemo(()=>{let t=e.left/100*i,r=i>0&&l>0&&t+l+10>i-20;return{left:`${e.left}%`,color:e.color,opacity:e.hover?1:.68,fontWeight:e.hover?500:"normal",transform:r?"translateX(-100%)":"translateX(0)",marginLeft:r?"-10px":"10px"}},[e.left,e.hover,e.color,i,l]);return /*#__PURE__*/jsxs("div",{ref:n,className:"absolute left-0 top-0 h-full w-full",id:e.id,title:`${e.frequency}${t.unit} / ${e.level}${r.unit}`,children:[/*#__PURE__*/jsxs("div",{ref:a,className:"absolute top-[10px] z-[5] whitespace-nowrap text-[12px] leading-4 transition-[opacity,font-weight,transform,margin-left,color]",style:c,children:[/*#__PURE__*/jsxs("div",{children:[e.frequency,t.unit]}),void 0!==e.level&&/*#__PURE__*/jsxs("div",{children:[e.level,r.unit]})]}),/*#__PURE__*/jsx_runtime_jsx(components_Dashed,{x:!1,left:`${e.left}%`,top:`${e.top}%`,color:e.color,lineWidth:e.select?2:1})]},e.id)},Markers_MarkerItem=/*#__PURE__*/react.memo(MarkerItem),Markers=({id:e})=>{let{state:{marker:t,globalID:r}}=useStore_useStore(),{enabled:n,visible:a,fixed:i,readonly:o,maxCount:l,onChange:s}=t,c=external_react_useCallback((e,t)=>{s?.(e,t),MARKER_COUNT_CHANGE(r)({count:t.length,maxCount:l});let n=t.find(e=>e.select)?.id??null;MARKER_SELECTION_CHANGE(r)({selectedId:n})},[s,r,l]),u=external_react_useMemo(()=>n&&a,[n,a,t.enabled,t.visible]),d=external_react_useMemo(()=>getEID(e),[e]),{markers:h,createMarker:p,updateMarkerAttribute:f,resetMarkers:m,updateByData:g,handleHover:b,resetHover:v,toggleMainSecondaryPeaks:w,toggleMainPeak:y,moveToAdjacentPeak:x,findMainPeak:k,findSecondaryPeak:S,createMainPeakMarker:D,createSecondaryPeakMarker:M}=useMarkers({id:e,globalID:r,display:a,onChange:c});external_react_useEffect(()=>{if(!r||!d||!u||o)return;let e=useKeyEvent_subscriptionKeyBus(r,d,e=>{let t=e.key.toLowerCase();if(!["a","d","w","s"].includes(t))return;if("w"===t){if(e.repeat)return;e.preventDefault(),D();return}if("s"===t){if(e.repeat)return;e.preventDefault(),M();return}let r=h.find(e=>e.select)?.id;r&&(e.preventDefault(),x("a"===t?"left":"right",r))});return()=>{e?.()}},[d,r,h,x,u,o,D,M]);let F=external_react_useCallback(e=>{let t=h.find(t=>t.id===e),r=!t?.select;f({event:constants_MarkerEventType.Update,marker:{id:e,select:r}})},[h,f]),C=external_react_useCallback((e,t)=>{f({event:constants_MarkerEventType.Update,marker:{id:e,left:t.left,top:t.top}})},[f]);useMarkerEvents({id:e,markers:h,display:u,fixed:i,readonly:o,onCreateMarker:p,onDeleteMarker:external_react_useCallback(e=>{f({event:constants_MarkerEventType.Del,marker:{id:e}})},[f]),onUpdateMarker:C,onToggleSelect:F,onHover:b,onResetHover:v});let E=external_react_useRef(null);return(external_react_useEffect(()=>{r&&e&&withUpdateData(e,"Marker",()=>{let{realData:e}=withDatabase(r).getAllRawData();E.current=e??null,g(e)})},[r,e,g]),external_react_useEffect(()=>{r&&e&&MARKER_UPDATE_ATTRIBUTE(r,e=>{f(e)})},[r,e,f,m]),external_react_useEffect(()=>{r&&e&&MARKER_COMMAND(r,e=>{if(e?.type){if("main-secondary-peaks"===e.type)return void w();if("main-peak"===e.type)return void y();if("left-peak"===e.type)return void x("left",e.selectedId);if("right-peak"===e.type)return void x("right",e.selectedId);if("find-main-peak"===e.type)return void k(e.selectedId);if("find-secondary-peak"===e.type)return void S(e.selectedId);if("create-main-peak"===e.type)return void D();if("create-secondary-peak"===e.type)return void M();if("clear-all"===e.type)return void m()}})},[r,e,x,w,y,k,S,D,M,m]),u)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[5]",children:h.map(e=>/*#__PURE__*/jsx_runtime_jsx(Markers_MarkerItem,{marker:e},e.id))}):null},Spectrum_Markers=Markers,infoSegments2Scope=({segments:e,index:t,frequency:r,bandwidth:n})=>{if(!r||!n||!e||!e[t])return{left:0,width:0};let a=e[t],i=e.reduce((e,t)=>e+t.point,0),{left:o,width:l}=calculatePositionFromFrequencyRange({startFreq:r-n/2e3,stopFreq:r+n/2e3},a),s=e.slice(0,t).reduce((e,t)=>e+t.point/i*100,0),c=a.point/i*100;return{left:s+o/100*c,width:l/100*c}};function useScope_useScope(){let{state:{scope:e,segments:t},dispatch:r}=useStore_useStore();return external_react_useCallback(n=>{let{frequency:a,bandwidth:i,index:o=0}=n,{left:l,width:s}=infoSegments2Scope({segments:t,index:o,frequency:a,bandwidth:i});r({payload:{scope:{...e,left:l,width:s}}})},[t,e])}let Scope=()=>{let{state:{scope:{show:e,left:t,width:r}}}=useStore_useStore();return e?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-0 box-border border-y border-dashed border-chart-grid bg-chart-surface opacity-50",style:{width:`${r}%`,left:`${t}%`}})}):null},Spectrum_Scope=Scope,SignalSegments=/*#__PURE__*/memo(({style:e,signalPositions:t,activeSignalKey:r,segmentIndex:n})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute h-full box-border",style:e,children:t.map(({item:e,key:t,position:a,color:i,tooltip:o})=>{let l=r===t,s={left:a.left,width:a.width,minWidth:"1px",backgroundColor:i,height:l?"100%":"8px",opacity:l?.5:1};return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute top-0 flex min-w-px items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap text-center text-xs text-foreground","data-signal-active":l?"true":"false","data-signal-key":t,"data-signal-source":resolveSignalSource(e),"data-testid":"signal-annotation",style:s,title:o},`segment-${n}-signal-${t}`)})})),presenters_SignalSegments=SignalSegments;function useSignalDataManager(){let{state:e,dispatch:t}=useStore_useStore(),r=external_react_useRef(e.globalID),n=external_react_useRef(e.signal),a=external_react_useRef({});return external_react_useEffect(()=>{r.current=e.globalID,n.current=e.signal},[e.globalID,e.signal]),external_react_useEffect(()=>{if(!e.globalID)return;let r=a.current.station,i=a.current.simple;void 0!==r&&(STATION_DATA(e.globalID,r),a.current.station=void 0),void 0!==i&&(t({payload:{signal:{...n.current,data:i}}}),a.current.simple=void 0)},[t,e.globalID]),{updateSignalData:external_react_useCallback(e=>{let{type:i,data:o}=e;if(Array.isArray(o)){if("station"===i){if(!r.current){a.current.station=o;return}STATION_DATA(r.current,o)}else if("simple"===i){if(!r.current){a.current.simple=o;return}t({payload:{signal:{...n.current,data:o}}})}}},[t])}}let Signal=({id:e,show:t=!0,display:r=!0})=>{let n=useStore_useSelector(e=>e.segments),a=useStore_useSelector(e=>e.zoom.style),i=useStore_useSelector(e=>e.signal),o=useCursorSample(e),l=o?.coord.left,s=useUnifiedSignals({respectVisibility:!0}),c=i.show&&i.display&&r,u=!!o,d=external_react_useMemo(()=>u&&"number"==typeof l?frequencyCalculation_calculateCursorPosition(l,n):{segmentIndex:-1,pointIndex:-1},[u,n,l]),h=external_react_useMemo(()=>u?frequencyCalculation_getCursorFrequencyAtPosition(n,d):0/0,[d,u,n]),p=external_react_useMemo(()=>resolveStaticSignalSegments({segments:n,signalItems:s}),[n,s]),f=external_react_useMemo(()=>resolveActiveSignalKey({segmentData:p,isCursorActive:u,currentFrequency:h,currentPosition:d}),[h,d,u,p]);return t&&c?/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 z-[4] flex h-full w-full select-none items-center overflow-hidden bg-transparent",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 flex h-full w-full",style:a??void 0,children:p.map(({segmentIndex:e,signalPositions:t,style:r})=>/*#__PURE__*/jsx_runtime_jsx(presenters_SignalSegments,{style:r,signalPositions:t,activeSignalKey:d.segmentIndex===e?f:void 0,segmentIndex:e},`segment-${e}`))})}):null},Spectrum_Signal=Signal,StripeSwitch=()=>{let{state:{stripe:e},dispatch:t}=useStore(),{display:r,show:n}=e,a=useCallback(r=>{t({payload:{stripe:{...e,display:!!r}}})},[e]);return n?/*#__PURE__*/_jsx(IconBox,{active:r,tone:"primary",onClick:()=>{a(!r)},title:"频谱框选",children:/*#__PURE__*/_jsxs("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/_jsx("path",{d:"M835.4 757.7h-69.9v-51h18.9v-18.8h51zM713.1 757.7h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0H220v-51h83.9v51zM167.5 757.7H97.6v-69.8h51v18.8h18.9zM148.6 637.5h-51V557h51v80.5z m0-130.7h-51v-80.5h51v80.5z m0-130.8h-51v-80.5h51V376zM148.6 245.2h-51v-69.9h69.9v51h-18.9zM713.1 226.3h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0H220v-51h83.9v51zM835.4 245.2h-51v-18.9h-18.9v-51h69.9zM835.4 637.5h-51V557h51v80.5z m0-130.7h-51v-80.5h51v80.5z m0-130.8h-51v-80.5h51V376z",fill:"currentColor"}),/*#__PURE__*/_jsx("path",{d:"M784.4 615.7h51v233h-51z",fill:"currentColor"}),/*#__PURE__*/_jsx("path",{d:"M693.4 706.7h233v51h-233z",fill:"currentColor"})]})}):null},Stripe_Switch=null,Stripe_COMPONENT_KEY=constants_ToolType.Stripe,EDGE_HIT_SLOP=1.5,Stripe_clampPercent=e=>Math.max(0,Math.min(100,e)),resolveDragMode=({cursor:e,left:t,right:r})=>{let n=Math.abs(e-t),a=Math.abs(e-r);return n<=EDGE_HIT_SLOP?"left":a<=EDGE_HIT_SLOP?"right":e>t&&e<r?"move":n<=a?"left":"right"},Stripe=({id:e})=>{let{state:{stripe:t,axisX:{frequencyFormat:r,unit:n}},dispatch:a}=useStore_useStore(),{show:i,display:o,left:l,right:s,defaultLeft:c,defaultRight:u,onChange:d}=t,h=external_react_useRef(t),p=external_react_useRef(null),f=external_react_useRef(r),m=external_react_useRef(n),g=external_react_useRef(d);external_react_useEffect(()=>{h.current=t,f.current=r,m.current=n,g.current=d},[t,r,n,d]),external_react_useEffect(()=>{a({payload:{stripe:{...t,left:c,right:u}}})},[c,u]);let b=external_react_useCallback(e=>{let t=p.current;if(!t||!Number.isFinite(e?.left))return;let r=Stripe_clampPercent(e.left),n=h.current,{mode:i,startCursor:o,startLeft:l,startRight:s}=t,c=l,u=s;if("move"===i){let e=s-l;(u=(c=Stripe_clampPercent(l+(r-o)))+e)>100&&(c=Math.max(0,(u=100)-e))}"left"===i&&(c=Math.min(r,s)),"right"===i&&(u=Math.max(r,l)),a({payload:{stripe:{...n,left:c,right:u}}})},[a]),v=external_react_useCallback(()=>{let{left:e,right:t}=h.current,r=Math.round(10*e)/10,n=Math.round(10*t)/10,a=f.current?.(r)??"",i=f.current?.(n)??"",o=n-r,l=Number(i)-Number(a);g.current({left:r,right:n,width:o,start:a,end:i,bandwidth:l,unit:m.current})},[]);return(external_react_useEffect(()=>{createMouseDownEventManager(e,Stripe_COMPONENT_KEY,t=>{if(!i||!o||!Number.isFinite(t?.left))return;let r=h.current,n=Stripe_clampPercent(t.left);p.current={mode:resolveDragMode({cursor:n,left:r.left,right:r.right}),startCursor:n,startLeft:r.left,startRight:r.right},compareEventPriority(e,Stripe_COMPONENT_KEY)}),createMouseUpEventManager(e,Stripe_COMPONENT_KEY,()=>{i&&o&&p.current&&(p.current=null,resetEventLevel(e,Stripe_COMPONENT_KEY),v())}),createMouseLeaveEventManager(e,Stripe_COMPONENT_KEY,()=>{i&&o&&p.current&&(p.current=null,resetEventLevel(e,Stripe_COMPONENT_KEY),v())}),createMoveEventManager(e,Stripe_COMPONENT_KEY,(e,t)=>{i&&o&&p.current&&b(t)})},[e,i,o,b,v]),i&&l-s!=0&&o)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-px box-border border-x-2 border-dashed border-y-0 border-chart-grid-strong bg-chart-surface opacity-40",style:{left:`${l}%`,width:`${s-l}%`}})}):null},Spectrum_Stripe=Stripe;function resolveBandPositions(e,t){if(!e.show)return[];if(e.kind===BandKind.Position)return[{key:BandKind.Position,left:e.left??50-e.width/2,width:e.width}];let r=frequencyCalculation_calculateFrequencyRange(e);if(!r||!t.length)return[];let n=t.reduce((e,t)=>e+Math.max(0,t.point),0);if(n<=0)return[];let a=[],i=0;return t.forEach((e,t)=>{let o=Math.max(0,e.point)/n*100;if(e.point>0&&e.frequencyCache?.length&&isRangeIntersectSegment(r,e)){let n=calculatePositionFromFrequencyRange(r,e);a.push({key:`frequency-${t}`,left:i+n.left/100*o,width:n.width/100*o})}i+=o}),a}function useBandLayerController(){let{dispatch:e,store:t}=useStoreApi();return external_react_useCallback(r=>{let n=t.getState().band,a=resolveBandState(r,n,"replace");a!==n&&e({payload:{band:a}})},[e,t])}let BandLayer=()=>{let e=useStore_useSelector(e=>e.band),t=useStore_useSelector(e=>e.segments),r=external_react_useMemo(()=>resolveBandPositions(e,t),[e,t]);return r.length?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:r.map(t=>/*#__PURE__*/jsx_runtime_jsx("div",{"data-testid":"spectrum-band","data-band-kind":e.kind,"data-band-key":t.key,className:"absolute flex h-full w-0 box-border border-y border-dashed opacity-50",style:{left:`${t.left}%`,width:`${t.width}%`,backgroundColor:e.color?`${e.color}40`:void 0,borderColor:e.color}},t.key))}):null},Spectrum_BandLayer=BandLayer,TAP_SLOP_PX=10,TAP_MAX_DURATION_MS=300,TWO_FINGER_TAP_MS=300,PINCH_AXIS_X_DEG=30,PINCH_AXIS_Y_DEG=60,createIdleGesture=()=>({mode:"idle",startX:0,startY:0,startTime:0,lastX:0,lastY:0,startCoord:null,pinchBase:null}),TouchBus_clamp=(e,t,r)=>Math.max(t,Math.min(e,r)),TouchBus=({id:e})=>{let{state:{zoom:t,segments:r,axisY:n,globalID:a},dispatch:i}=useStore_useStore(),o=getEID(e),l=external_react_useRef(null),s=external_react_useRef(createIdleGesture()),c=external_react_useRef(t),u=external_react_useRef(r.totalPoints),d=external_react_useRef(n);external_react_useEffect(()=>{c.current=t},[t]),external_react_useEffect(()=>{u.current=r.totalPoints},[r]),external_react_useEffect(()=>{d.current=n},[n]);let h=external_react_useCallback((e,t,r)=>({currentTarget:e,clientX:t,clientY:r}),[]),p=external_react_useCallback(e=>{let t=Array.from(e.touches).map(e=>({x:e.clientX,y:e.clientY})),r=t.length,n=0,a=0,i=0;if(2===r){let[e,r]=t;n=Math.hypot(r.x-e.x,r.y-e.y),a=(e.x+r.x)/2,i=(e.y+r.y)/2}else 1===r&&(a=t[0].x,i=t[0].y);return{count:r,points:t,distance:n,midX:a,midY:i}},[]),f=external_react_useCallback((e,t,r)=>{let n=h(e,t,r),a=calculateEventRelativePosition(n);createMouseEnterEventManager(o)(),createMoveEventManager(o)(n,a)},[o,h]),m=external_react_useCallback(e=>{let t=s.current.pinchBase,r=u.current;if(!t||t.distance<=0||e<=0)return;let n=e/t.distance;if(("x"===t.axisMode||"xy"===t.axisMode)&&c.current.show&&r){let e=calculateAnchoredXZoomInterval({anchorPercent:t.anchorPercent,interval:t.interval,scale:1/n,totalPoints:r});i({payload:t=>t.zoom.interval.start===e.start&&t.zoom.interval.end===e.end?null:{zoom:{...t.zoom,interval:e,isScanSegmentsUpdateMagnify:!1}}})}("y"===t.axisMode||"xy"===t.axisMode)&&a&&(useRangeZoom(a)(t.lastScale/n,t.yAnchorValue),t.lastScale=n)},[i,a]),g=external_react_useRef(m);g.current=m;let b=external_react_useCallback(e=>{let t=l.current,r=s.current;if(t&&0!==e.touches.length){if(1===e.touches.length){let{clientX:n,clientY:a}=e.touches[0];r.mode="pending",r.startX=n,r.startY=a,r.startTime=Date.now(),r.lastX=n,r.lastY=a,r.startCoord=calculateEventRelativePosition(h(t,n,a));return}if(2===e.touches.length){r.mode="pinch",r.startTime=Date.now();let n=c.current,a=p(e),[i,o]=a.points,l=Math.abs(o.x-i.x),s=180*Math.atan2(Math.abs(o.y-i.y),l)/Math.PI,{start:u,end:f}=n.interval,m=calculateEventRelativePosition(h(t,a.midX,a.midY)).left??0,g=t.getBoundingClientRect();if(g.height<=0||a.distance<=0){r.pinchBase=null;return}let[b,v]=d.current.realRange??[0,1],w=TouchBus_clamp((a.midY-g.top)/g.height,0,1);r.pinchBase={distance:a.distance,lastScale:1,interval:{start:u,end:f},anchorPercent:TouchBus_clamp(m,0,100),axisMode:s<PINCH_AXIS_X_DEG?"x":s>PINCH_AXIS_Y_DEG?"y":"xy",yAnchorValue:v-w*(v-b),startPoints:a.points,pinchMoved:!1}}}},[p,h]),v=external_react_useRef(throttleRequestAnimationFrame(e=>{if(!e||!("count"in e))return;let t=l.current,r=s.current;if(!t)return;let{count:n,points:a,distance:i}=e;if(2===n){if("pinch"===r.mode&&r.pinchBase){let e=r.pinchBase;if(!e.pinchMoved){let t={x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2},r={x:(e.startPoints[0].x+e.startPoints[1].x)/2,y:(e.startPoints[0].y+e.startPoints[1].y)/2};(Math.abs(i-e.distance)>TAP_SLOP_PX||Math.hypot(t.x-r.x,t.y-r.y)>TAP_SLOP_PX)&&(e.pinchMoved=!0)}g.current(i)}return}if(1!==n)return;let c=a[0];if("pending"===r.mode){let e=c.x-r.startX,t=c.y-r.startY;if(e*e+t*t<=TAP_SLOP_PX**2)return;r.mode="drag"}if("drag"!==r.mode)return;let u=t.getBoundingClientRect(),d={left:(c.x-r.lastX)/u.width,top:(c.y-r.lastY)/u.height},p=h(t,c.x,c.y),f=calculateEventRelativePosition(p);createMoveEventManager(o)(p,f),createDragEventManager(o)(r.startCoord,f,d,!1),r.lastX=c.x,r.lastY=c.y})).current,w=external_react_useCallback(e=>{v(p(e))},[p,v]),y=external_react_useCallback(e=>{let t=l.current,r=s.current;if(!t)return;let n=e.changedTouches[0],a=n?.clientX??r.lastX,i=n?.clientY??r.lastY;if("pending"===r.mode){let e=Date.now()-r.startTime,n=a-r.startX,o=i-r.startY;n*n+o*o<=TAP_SLOP_PX**2&&e<=TAP_MAX_DURATION_MS&&f(t,a,i)}if(1===e.touches.length){let n=e.touches[0];r.mode="drag",r.startX=n.clientX,r.startY=n.clientY,r.lastX=n.clientX,r.lastY=n.clientY,r.pinchBase=null,r.startCoord=calculateEventRelativePosition(h(t,n.clientX,n.clientY))}else 0===e.touches.length&&("pinch"===r.mode&&r.pinchBase&&!r.pinchBase.pinchMoved&&Date.now()-r.startTime<=TWO_FINGER_TAP_MS&&createMouseLeaveEventManager(o)(),r.mode="idle",r.pinchBase=null,createMouseUpEventManager(o)())},[o,f,h]),x=external_react_useCallback(()=>{let e=s.current;e.mode="idle",e.pinchBase=null,createMouseLeaveEventManager(o)()},[o]),k=external_react_useCallback(e=>{e.preventDefault()},[]);return external_react_useEffect(()=>()=>{createMouseLeaveEventManager(o)()},[o]),external_react_useEffect(()=>{l.current&&(l.current.id=o)},[o]),/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[5] pointer-events-auto",children:/*#__PURE__*/jsx_runtime_jsx("button",{ref:l,type:"button",className:cn_cn("absolute right-0 top-0 h-full w-full appearance-none border-0 bg-transparent p-0 outline-none","touch-none select-none"),"aria-label":"Touch bus",onContextMenu:k,onTouchStart:b,onTouchMove:w,onTouchEnd:y,onTouchCancel:x})})},Spectrum_TouchBus=TouchBus,Spectrum_Spectrum=e=>{let{children:t,touch:r}=e,{state:{axisY:{autoranging:n},series:{enableLengthSyncFastMode:a},globalID:i}}=useStore_useStore(),{id:o,chart:l,Chart:s}=hooks_useChart({Render:Spectrum,params:{autoranging:n,enableLengthSyncFastMode:a}});useZoomEvent(o,constants_ModuleType.Spectrum);let c=useBandLayerController(),u=useScope_useScope(),d=usePoints();return external_react_useEffect(()=>{if(i&&l)return setScanDF360Prob(i,e=>{l?.setDisabledClearRect(e)})},[i,l]),useModuleSubscription({moduleType:constants_ModuleType.Spectrum,chart:l,handleRender:(e,t)=>{t.updateSeries?.({data:e.data,extraData:e.extraData}),withUpdateData(o)()},eventHandlers:{autoranging:(e,t)=>{t.useRangeAutoFocus?.()},points:e=>{d(e.data)},[constants_PSType.Series]:(e,t)=>{t.setSeries?.(e)},band:e=>{c(e)},scope:e=>{u(e)}}}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(AxisYCanvas,{chart:l}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_GridLines,{}),/*#__PURE__*/jsx_runtime_jsx(s,{}),t,/*#__PURE__*/jsx_runtime_jsx(FrequencyTagLine_Board,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Markers,{id:o}),r?/*#__PURE__*/jsx_runtime_jsx(Spectrum_TouchBus,{id:o}):/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Limit,{id:o}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:o,type:constants_ModuleType.Spectrum}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Signal,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_DragFrame,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_BandLayer,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Scope,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Stripe,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyTagLine,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyAllocation,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_DeltaMeasurement,{})]})]})},modules_Spectrum=Spectrum_Spectrum,LevelStream_Chart_Chart=e=>{let{state:{cursor:t},dispatch:r}=useStore_useStore(),{publish:n}=e,{analyzer:a}=useLevelStreamAnalyzer();return publish_usePublish({publish:n,subscribe:e=>{let{pstype:t}=e;t===constants_PSType.Reset&&a?.reset(),t===constants_PSType.LevelStream&&a?.process(e.data,dateTimeToTimestamp(e.timestamp))}}),external_react_useEffect(()=>{t.mode!==constants_ModuleType.LevelStream&&r({payload:{cursor:{...t,mode:constants_ModuleType.LevelStream}}})},[t,r]),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.LevelStream}),/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Spectrum,{children:/*#__PURE__*/jsx_runtime_jsx(components_PluginBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Level,{opacity:.5})})})})]})},LevelStream_Chart=LevelStream_Chart_Chart,LevelStreamChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,cursor:{show:!0},zoom:{show:!1},signal:{show:!1},children:/*#__PURE__*/jsx_runtime_jsx(LevelStream_Chart,{...e})}),LevelStream=withChartPublisher(LevelStreamChart,"LevelStream"),charts_LevelStream=LevelStream,Ticks_ticks=["100%","75%","50%","25%","0%"],components_Ticks_Ticks=e=>{let{inside:t=!1}=e;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none relative z-[2] flex h-full w-full flex-col justify-between text-xs text-foreground opacity-50",style:{alignItems:t?"flex-start":"flex-end"},children:Ticks_ticks.map(e=>/*#__PURE__*/jsx_runtime_jsx("div",{className:cn_cn("flex justify-start box-border",t?"pl-0.5 pr-0":"pr-0.5"),children:e},e))})},occupancy_components_Ticks=components_Ticks_Ticks,StandardOccupancyAxisYVariant=e=>{let{inside:t=!1}=e,{axisYWidth:r,marginLeft:n}=useAxisYWidth_useAxisYWidth();return /*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-auto",style:{width:r,marginLeft:n,justifyContent:t?"flex-start":"flex-end"},children:/*#__PURE__*/jsx_runtime_jsx(occupancy_components_Ticks,{inside:t})})},variants_standard=/*#__PURE__*/react.memo(StandardOccupancyAxisYVariant),AxisYOccupancy=e=>{let{disabled:t,inside:r}=e,{state:{axisY:n}}=useStore_useStore(),{show:a}=n;return!1===a||t?null:/*#__PURE__*/jsx_runtime_jsx(variants_standard,{inside:r})},occupancy=AxisYOccupancy,OccupancyDashed_Dashed=()=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-0 w-full flex-1 border-t [border-color:var(--chart-grid)] first:border-t-0"}),OccupancyDashed=()=>{let{state:{gridLines:e}}=useStore_useStore();return e&&/*#__PURE__*/jsxs("div",{className:"pointer-events-none absolute right-0 top-0 z-[1] flex h-full w-full select-none flex-col border [border-color:var(--chart-grid)] bg-transparent",children:[/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{})]})},GridLines_OccupancyDashed=OccupancyDashed,TOTAL_LINE_HIDDEN_OFFSET=-200,getOccupancyTotalLineRuntimeId=e=>`occupancy-total-line-${e}`,applyOccupancyTotalLineValue=(e,t,r=0)=>{e&&t&&(e.style.bottom=`${r||TOTAL_LINE_HIDDEN_OFFSET}%`,t.textContent=String(r))},withOccupancyTotalLine=(e,t,r)=>subscription_createSubscriptionManager(getOccupancyTotalLineRuntimeId(e),t,r,e),publishOccupancyTotalLine=(e,t=0)=>{withOccupancyTotalLine(e)(t)},TotalLine=({id:e})=>{let t=external_react_useRef(null),r=external_react_useRef(null),n=external_react_useRef(`OccupancyTotalLine-${Math.random().toString(36).slice(2)}`);return external_react_useEffect(()=>(applyOccupancyTotalLineValue(t.current,r.current),withOccupancyTotalLine(e,n.current,e=>{applyOccupancyTotalLineValue(t.current,r.current,e)})),[e]),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute z-[4] h-full w-full",children:/*#__PURE__*/jsxs("div",{ref:t,className:"absolute left-0 w-full opacity-50",style:{bottom:"-200%"},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute h-0 w-full border-b border-dashed border-foreground/80",style:{marginTop:"-0.5px"}}),/*#__PURE__*/jsx_runtime_jsx("div",{ref:r,className:"absolute right-7 -mt-7 flex h-6 items-center justify-center rounded-[var(--radius-control)] bg-secondary px-2 text-xs text-foreground",children:"0"})]})})},Occupancy_TotalLine=TotalLine,Occupancy_Occupancy=e=>{let{occupancyAxisYDisabled:t}=e,{id:r,chart:n,Chart:a}=hooks_useChart({Render:Occupancy});return(useModuleSubscription({moduleType:constants_ModuleType.Occupancy,chart:n,handleRender:(e,t)=>{let{data:n,totalOccupancy:a}=e;n&&t.updateSeries?.(n),void 0!==a&&publishOccupancyTotalLine(r,a)},eventHandlers:{[constants_PSType.Reset]:(e,t)=>{t.reset(),publishOccupancyTotalLine(r)}}}),useZoomEvent(r,constants_ModuleType.Occupancy),t)?/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full w-full",style:{...CHARTS_SCOPE_STYLE_VARS},[CHARTS_STYLE_SCOPE_ATTRIBUTE]:"true",children:/*#__PURE__*/jsxs("div",{className:"relative z-[0] h-full w-full",children:[/*#__PURE__*/jsx_runtime_jsx(a,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:r}),/*#__PURE__*/jsx_runtime_jsx(Occupancy_TotalLine,{id:r})]})}):/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(occupancy,{disabled:t}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(GridLines_OccupancyDashed,{}),/*#__PURE__*/jsx_runtime_jsx(a,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:r}),/*#__PURE__*/jsx_runtime_jsx(Occupancy_TotalLine,{id:r}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:r,type:constants_ModuleType.Occupancy})]})]})},modules_Occupancy=Occupancy_Occupancy,Occupancy_Chart_Chart=e=>{let{publish:t}=e,{state:{globalID:r}}=useStore_useStore(),n=useSpectrumRule(constants_ChartType.Scan);return publish_usePublish({publish:t,subscribe:e=>{n(e),e.pstype===constants_PSType.Occupancy&&(e.data&&(withDatabase(r).getAllRawData=t=>({...getDefaultData().getAllRawData(t),occupancyData:e.data})),passThrough(r,constants_ModuleType.Occupancy)({...e,pstype:constants_PSType.Render}))}}),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{})}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:constants_ChartType.Scan})]})},Occupancy_Chart=Occupancy_Chart_Chart,OccupancyChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,zoom:{show:!1},children:/*#__PURE__*/jsx_runtime_jsx(Occupancy_Chart,{...e})}),charts_Occupancy_Occupancy=withChartPublisher(OccupancyChart,"Occupancy"),charts_Occupancy=charts_Occupancy_Occupancy,Zoom=()=>{let e=useStoreDispatch(),t=useStore_useSelector(e=>e.zoom),r=useStore_useSelector(e=>e.segments.totalPoints)??0,n=useStore_useSelector(e=>e.axisX.frequencyFormat),{interval:{start:a,end:i},onChange:o}=t,l=external_react_useMemo(()=>r&&n?[n((100*a+1)/r),n((100*i+1)/r)]:["",""],[a,i,r,n]);return external_react_useEffect(()=>{r&&void 0!==l[0]&&void 0!==l[1]&&o(l,{start:a,end:i})},[l,o,r]),external_react_useEffect(()=>{if(!r)return;let t=i-a+1,n=r/t,o=`-${a/t*100}%`,l=`${100*n}%`;e({payload:e=>({zoom:{...e.zoom,style:{left:o,width:l}}})})},[e,i,a,r]),null},components_Zoom=Zoom;class FluorescenceRender extends GradientRenderer{constructor(e){super({id:e.id,globalID:e.globalID,chart:null,renderMode:e.renderMode})}init(){let{id:e,renderMode:t}=this.state;e&&(this.state.chart=new Fluorescence({id:e,colors:this.getInitialColors(),ignoreValue:0,fluorescenceRenderMode:t}),this.subscribeToColor("Fluorescence-Render"))}updateProps(e){void 0!==e.renderMode&&(this.state.renderMode=e.renderMode),this.state.chart?.updateProps(e)}updateSeries(e){this.state.chart&&e&&this.state.chart.render(e)}setRenderMode(e){this.state.renderMode=e,this.state.chart?.setRenderMode(e)}}let Fluorescence_Fluorescence=()=>{let{state:{axisY:{range:e},fluorescence:{display:t,renderMode:r}}}=useStore_useStore(),{chart:n,Chart:a}=hooks_useChart({Render:FluorescenceRender,params:{renderMode:r}});external_react_useEffect(()=>{n?.updateProps({range:e})},[n,e]),external_react_useEffect(()=>{n&&n.setRenderMode(r)},[r]),useModuleSubscription({moduleType:constants_ModuleType.Fluorescence,chart:n,renderPSTypes:[constants_PSType.Fluorescence],extractData:e=>e.data});let i=external_react_useMemo(()=>({height:"100%",width:"100%",display:"flex",visibility:t?"visible":"hidden"}),[t]);return external_react_useEffect(()=>{n&&n.updateProps({display:t})},[n,t]),/*#__PURE__*/jsx_runtime_jsx("div",{style:i,children:/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(a,{})})})},modules_Fluorescence=Fluorescence_Fluorescence,HeatmapPortal_Chart=e=>{let{type:t,heatmapElementID:r}=e;return /*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:r,children:/*#__PURE__*/jsxs(components_Background,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.Heatmap}),/*#__PURE__*/jsx_runtime_jsx(modules_Heatmap,{zoomMode:"linked-x"}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:t})]})})},HeatmapPortal=HeatmapPortal_Chart,OccupancyPortal_Chart=e=>{let{occupancyElementID:t,occupancyAxisYElementID:r,type:n}=e;return /*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:t,children:r?/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{occupancyAxisYDisabled:!0}):/*#__PURE__*/jsxs(components_Background,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.Occupancy}),/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:n})]})}),/*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:r,children:/*#__PURE__*/jsx_runtime_jsx(occupancy,{inside:!0})})]})},OccupancyPortal=OccupancyPortal_Chart,BLAZE_PROGRESS=(e,t)=>subscription_createSubscriptionManager(`BLAZE_PROGRESS-${e}`,"0",t,e),Blaze=()=>{let{state:{blaze:{show:e},segments:t,globalID:r}}=useStore_useStore(),[n,a]=external_react_useState(""),i=external_react_useMemo(()=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];n.progress&&e.push(...n.progress)}return e},[t]);return(external_react_useEffect(()=>{e&&r&&BLAZE_PROGRESS(r,e=>{a(i.includes(e)?void 0:`${100*e}%`)})},[e,r]),e)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:/*#__PURE__*/jsxs("div",{className:"absolute left-[-100%] top-0 flex h-full w-0 opacity-50",style:{left:n},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-[-0.5px] opacity-50",style:{borderRight:"0.5px solid var(--chart-grid-strong)"}}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-[-31px] w-[30px] opacity-20",style:{background:"linear-gradient(90deg, transparent, var(--chart-grid-strong))"}})]})}):null},Spectrum_Blaze=/*#__PURE__*/react.memo(Blaze),Legend=()=>{let{state:{legend:{children:e}}}=useStore_useStore();return /*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-5 top-5 z-[6] flex h-auto w-auto items-center",children:e})},Spectrum_Legend=Legend,SegmentsZebra=()=>{let{state:{segments:e}}=useStore_useStore(),t=e.totalPoints??0;return /*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[0]",children:e.map((e,r)=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full border-x",style:{width:t>0?`${100*e.point/t}%`:0,borderColor:r%2==1?"var(--chart-grid)":"transparent",background:r%2==1?"var(--chart-surface)":"transparent",opacity:r%2==1?.4:1}},`${e.start}_${e.stop}_${e.index}`))})},Spectrum_SegmentsZebra=SegmentsZebra,useMarkerPublish=({globalID:e})=>({handleMarkerPublish:external_react_useCallback(t=>{if(e)switch(t.pstype){case constants_PSType.Marker:MARKER_UPDATE_ATTRIBUTE(e)(t);break;case constants_PSType.Reset:MARKER_UPDATE_ATTRIBUTE(e)({type:constants_MarkerEventType.Clear})}},[e])}),Spectrum_useMarkerPublish=useMarkerPublish;function resolveThresholdDataOptions({segmentOffset:e,offset:t}){let r={};return void 0!==e&&(r.segmentOffset=e),void 0!==t&&(r.offset=t),void 0!==r.segmentOffset||void 0!==r.offset?r:void 0}function setAnalyzerThresholdData(e,t){"thresholdData"in t&&e.setThresholdData(t.thresholdData,resolveThresholdDataOptions(t))}function useTemplateComparison(){let{state:{globalID:e,axisX:{frequencyFormat:t},signal:{onChange:r}}}=useStore_useStore(),n=external_react_useRef(t),a=external_react_useRef(r);external_react_useEffect(()=>{n.current=t,a.current=r},[e,t,r]);let i=external_react_useCallback(e=>{if(!e||0===e.length)return[];let t=[],r=Date.now();return e.forEach(a=>{let i=n.current,{startIndex:o,endIndex:l}=a,s=e.length,c=i((o+.5)*100/s),u=i((l+.5)*100/s),d=i((o+l)/2*100/s);c!==u&&t.push({...a,frequency:d,bandwidth:(u-c)*1e3,timestamp:r})}),t},[]);return{updateTemplateOverData:external_react_useCallback(e=>{if(e){let t=i(e);a.current(t)}},[i])}}function useSpectrumAnalyzer(e){let{state:{globalID:t,series:{enableMetrics:r,enableWaterfall:n},fluorescence:{show:a},axisY:{unit:i},zoom:{interval:o},heatmapCapture:{display:l},system:{width:s},marker:c}}=useStore_useStore(),u=external_react_useRef(null),d=external_react_useRef(t),h=external_react_useRef(o),p=external_react_useRef(0),f=external_react_useRef(null),{updateSignalData:m}=useSignalDataManager(),g=external_react_useRef(l);external_react_useEffect(()=>{g.current=l},[l]);let b=external_react_useCallback(e=>{passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,data:e})},[]),v=external_react_useCallback(e=>{passThrough(d.current,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:e})},[]),w=external_react_useCallback(e=>{BLAZE_PROGRESS(d.current)?.(e)},[]),{updateTemplateOverData:y}=useTemplateComparison(),x=external_react_useCallback(e=>{(e.realData||e.templateData||e.backgroundNoiseData||"thresholdData"in e)&&b({minData:e.minData,maxData:e.maxData,avgData:e.avgData,thresholdData:e.thresholdData,backgroundNoiseData:e.backgroundNoiseData,realData:e.realData,templateData:e.templateData}),e.scanProgress&&w(e.scanProgress),e.templateOverData&&y(e.templateOverData),e.waterfallData&&v(e.waterfallData),e.fluorescenceData&&passThrough(d.current,constants_ModuleType.Fluorescence)({pstype:constants_PSType.Fluorescence,data:{fluorescenceData:e.fluorescenceData,fluorescenceMaxCount:e.fluorescenceMaxCount}}),e.occupancyData&&passThrough(d.current,constants_ModuleType.Occupancy)({pstype:constants_PSType.Render,data:e.occupancyData,totalOccupancy:p.current}),e.extraData&&passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,extraData:e.extraData})},[b,v,w,y]);external_react_useEffect(()=>{d.current=t},[t]);let k=(e,t)=>!1!==e&&(t??!0);if(!u.current&&t){let i=Math.min(1|Math.floor(2*s),1001);u.current=new SpectrumAnalyzer({...e,outputPoints:i,processing:{...e?.processing,enableMetrics:k(r,e?.processing?.enableMetrics),enableWaterfall:k(n,e?.processing?.enableWaterfall),enableFluorescence:a,enablePeakStats:!!c?.enabled},onSpectrumUpdate:x});let o=withDatabase(t),l=u.current;o.getAllRawData=e=>l.getAllRawData(e),withSpectrumAnalyzerSYNC(t,u.current)}external_react_useEffect(()=>{let e=Math.floor(o.start),t=Math.ceil(o.end),r=Math.floor(h.current.start),n=Math.ceil(h.current.end);(e!==r||t!==n)&&u.current&&(h.current=o,u.current.updateSamplingRange(e,t+1))},[o]);let S=external_react_useCallback(async(e=!1)=>{setTimeout(()=>{passThrough(d.current,constants_ModuleType.Heatmap)({pstype:constants_PSType.Reset}),passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Reset}),passThrough(d.current,constants_ModuleType.Occupancy)({pstype:constants_PSType.Reset}),e&&resetSeries(d.current)},1)},[]),D=external_react_useCallback(async e=>{if(u.current)switch(e.pstype){case constants_PSType.AntennaFactor:u.current.setAntennaFactor(e.data);break;case constants_PSType.Signal:m({type:e.type,data:e.data});break;case constants_PSType.Spectrum:e.data&&u.current.process(e),setAnalyzerThresholdData(u.current,e),e.maxData&&u.current.setMaxData(e.maxData),e.minData&&u.current.setMinData(e.minData),e.avgData&&u.current.setAvgData(e.avgData),e.templateData&&u.current.setTemplateData(e.templateData,e.templateTolerance),e.backgroundNoiseData&&u.current.setBackgroundNoiseData(e.backgroundNoiseData),e.extraData&&u.current.setExtraData(e.extraData,types_ExtraDataMode.MERGE,e.segmentedExtraData?{segmentOffset:e.segmentOffset,offset:e.offset}:void 0);break;case constants_PSType.Fluorescence:e.data&&u.current&&u.current.setFluorescenceData(e.data.fluorescenceData,e.data.fluorescenceMaxCount);break;case constants_PSType.Heatmap:if(e.data){let{data:t,timestamps:r}=e,n=convertToTimestampedArrays(t,r);u.current.setWaterfallData(n)}break;case constants_PSType.Occupancy:u.current?.setOccupancyData(e.data),p.current=e.totalOccupancy;break;case constants_PSType.Segments:u.current.initializeSegments(e.data),await S(),e.onFinally?.();break;case constants_PSType.SpectrumBandwidth:u.current.reset();break;case constants_PSType.Series:updateSeries(d.current,e);break;case constants_PSType.Reset:u.current.reset(),await S(!0),e.onFinally?.();break;case constants_PSType.Clear:u.current.reset(),await S(!1),e.onFinally?.()}},[m,updateSeries,S]);return external_react_useEffect(()=>{let e=i.includes("/m");u.current?.setAntennaFactorSwitch(e)},[i]),external_react_useEffect(()=>{if(!u.current)return;let t=k(r,e?.processing?.enableMetrics);t!==f.current&&(u.current.updateProcessing({enableMetrics:t}),f.current=t)},[r,e?.processing?.enableMetrics]),D}let Spectrum_Chart_Chart=e=>{let{state:{globalID:t}}=useStore_useStore(),r=external_react_useRef([]),n=external_react_useRef(""),{type:a=constants_ChartType.SingleFrequency,publish:i,heatmapElementID:o,occupancyElementID:l,occupancyAxisYElementID:s,touch:c,children:u,processing:d}=e,{enableMetrics:h,enableWaterfall:p}=useSpectrumChartType({type:a,heatmapElementID:o}),f=useSpectrumAnalyzer({processing:{enableWaterfall:p,enableMetrics:h,...d}}),m=useSpectrumRule(a);useTouchMode(c);let{handleMarkerPublish:g}=Spectrum_useMarkerPublish({globalID:t});return publish_usePublish({publish:i,subscribe:e=>{if(f(e),g(e),m(e),e.pstype===constants_PSType.Heatmap){let{data:a,timestamps:i}=e;if(r.current=convertToTimestampedArrays(a,i),n.current!==t){let e=withDatabase(t),a=e.getAllRawData;e.getAllRawData=e=>({...a(e),waterfallData:r.current}),n.current=t}}passThrough(t,constants_ModuleType.Spectrum)(e),passThrough(t,constants_ModuleType.Heatmap)(e),passThrough(t,constants_ModuleType.Occupancy)(e),passThrough(t,constants_ModuleType.Fluorescence)(e)}}),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:a}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(modules_Spectrum,{touch:c,children:u||/*#__PURE__*/jsx_runtime_jsx(modules_Fluorescence,{})}),/*#__PURE__*/jsx_runtime_jsx(HeatmapPortal,{type:a,heatmapElementID:o}),/*#__PURE__*/jsx_runtime_jsx(OccupancyPortal,{type:a,occupancyElementID:l,occupancyAxisYElementID:s}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Zoom,{}),a===constants_ChartType.Scan&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx(Spectrum_SegmentsZebra,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Blaze,{})]}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Legend,{})]})]}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:a})]})},Spectrum_Chart=Spectrum_Chart_Chart,heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE="singleFrequency",DEFAULT_HEATMAP_CAPTURE_TYPE="slider",withSpectrumHeatmapCaptureDefaults=e=>{let t=e.type??heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE;return e.heatmapElementID&&(t===heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE||"scan"===t||"mscan"===t)?{...e,heatmapCapture:{show:!0,display:!1,type:DEFAULT_HEATMAP_CAPTURE_TYPE,toolbarVariant:"deltaMeasurement",...e.heatmapCapture}}:e},SpectrumChart=e=>{let t=withSpectrumHeatmapCaptureDefaults(e);return /*#__PURE__*/jsx_runtime_jsx(src_store,{...t,children:/*#__PURE__*/jsx_runtime_jsx(Spectrum_Chart,{...t})})},charts_Spectrum_Spectrum=withChartPublisher(SpectrumChart,"Spectrum"),charts_Spectrum=charts_Spectrum_Spectrum;function initChartsTheme(e={}){let{onChange:t,sizes:r,tokens:n}=e;initializeChartsThemeEnvironment({sizes:r,tokens:n});let a=getChartsThemeState();return{cleanup:t?subscribeChartsThemeChange(e=>t(e)):void 0,...a}}var signal_SignalDataType=/*#__PURE__*/function(e){return e.Station="station",e.Simple="simple",e}({});initializeChartsThemeEnvironment();export{charts_Dial as Dial,charts_Gauge as Gauge,charts_Heatmap as Heatmap,charts_IQ as IQ,charts_LevelStream as LevelStream,charts_Occupancy as Occupancy,charts_Spectrum as Spectrum,constants_AxisPlacement as AxisPlacement,constants_ChartType as ChartType,constants_FrequencyUnit as FrequencyUnit,constants_MarkerEventType as MarkerEventType,constants_ModuleType as ModuleType,constants_OptionKey as OptionKey,constants_PSType as PSType,constants_SegmentsEvent as SegmentsEvent,constants_SeriesType as SeriesType,constants_ToolType as ToolType,constants_ToolbarItemType as ToolbarItemType,formatFrequencyUnit,formatFrequencyUnitFromHz,formatFrequencyUnitFromMHz,getChartsThemeState,heatmap_HeatmapCaptureType as HeatmapCaptureType,initChartsTheme,marker_MarkerMode as MarkerMode,setFrequencyAllocationChannelsToCache,setFrequencyAllocationToCache,signal_SignalDataType as SignalDataType,subscribeChartsThemeChange,useSafePublish,withChartPublisher};
|
|
3584
|
+
*/let minus_iconNode=[["path",{d:"M5 12h14",key:"1ays0h"}]],Minus=createLucideIcon("minus",minus_iconNode),check_iconNode=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Check=createLucideIcon("check",check_iconNode),checkbox_Checkbox=/*#__PURE__*/__rspack_external_react.forwardRef(({className:e,...t},r)=>/*#__PURE__*/jsx_runtime_jsx(Checkbox,{ref:r,"data-slot":"checkbox",className:cn_cn("peer inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--radius-micro)] border border-border bg-background text-primary shadow-xs transition-colors outline-none","focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground","data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",e),...t,children:/*#__PURE__*/jsx_runtime_jsx(CheckboxIndicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current",children:"indeterminate"===t.checked?/*#__PURE__*/jsx_runtime_jsx(Minus,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(Check,{className:"size-3.5"})})}));checkbox_Checkbox.displayName=Checkbox.displayName;let toCheckboxValue=e=>"checked"===e||"indeterminate"===e&&"indeterminate",SignalNodeCount=({count:e,show:t,testId:r})=>t?/*#__PURE__*/jsxs("span",{className:"shrink-0 tabular-nums text-[11px] font-normal text-muted-foreground","data-testid":r,children:["(",e,")"]}):null,SignalTypeRow=({source:e,type:t,leafKeysWithData:r,hiddenKeys:n,showCount:a,expanded:i,onToggleExpanded:o,onToggleNode:l})=>{let s=resolveNodeCheckState(r,n,t.leafKeys),c=`signal-tree-type-checkbox-${e.source}-${t.signalType}`,u=t.levels.length>0,d=u?void 0:t.color??SIGNAL_TYPE_MAP[t.signalType].color;return /*#__PURE__*/jsxs("div",{children:[/*#__PURE__*/jsxs("div",{className:"group flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-type-${e.source}-${t.signalType}`,children:[u?/*#__PURE__*/jsx_runtime_jsx("button",{type:"button","aria-label":i?"折叠信号类型":"展开信号类型",className:"flex size-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,children:i?/*#__PURE__*/jsx_runtime_jsx(ChevronDown,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(ChevronRight,{className:"size-3.5"})}):/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}),/*#__PURE__*/jsxs("label",{htmlFor:c,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===s?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:c,"aria-label":`${e.label} ${t.label}`,checked:toCheckboxValue(s),disabled:"disabled"===s,onCheckedChange:()=>l(t.leafKeys)}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("min-w-0 truncate text-xs font-medium","disabled"===s?"text-muted-foreground":"text-foreground/90"),"data-testid":`signal-tree-type-color-${e.source}-${t.signalType}`,style:"disabled"===s||null==d?void 0:{color:toOpaqueCssColor(d)},children:t.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:t.count,show:a,testId:`signal-tree-type-count-${e.source}-${t.signalType}`})]})]}),i&&u?/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative ml-6 border-l border-border/60 pl-1",children:t.levels.map(i=>/*#__PURE__*/jsx_runtime_jsx(SignalLevelRow,{source:e.source,signalType:t.signalType,level:i,leafKeysWithData:r,hiddenKeys:n,showCount:a,onToggleNode:l},i.leafKey))}):null]},t.signalType)},SignalLevelRow=({source:e,signalType:t,level:r,leafKeysWithData:n,hiddenKeys:a,showCount:i,onToggleNode:o})=>{let l=resolveNodeCheckState(n,a,[r.leafKey]),s=`signal-tree-level-checkbox-${e}-${t}-${r.level}`;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"group flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-level-${e}-${t}-${r.level}`,children:/*#__PURE__*/jsxs("label",{htmlFor:s,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===l?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:s,"aria-label":`${t} ${r.label}`,checked:toCheckboxValue(l),disabled:"disabled"===l,onCheckedChange:()=>o([r.leafKey])}),/*#__PURE__*/jsx_runtime_jsx("span",{className:cn_cn("text-xs font-medium","disabled"===l?"text-muted-foreground":"text-foreground/80"),"data-testid":`signal-tree-level-color-${e}-${t}-${r.level}`,style:"disabled"===l?void 0:{color:toOpaqueCssColor(r.color??SIGNAL_LEVEL_MAP[r.level].color)},children:r.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:r.count,show:i,testId:`signal-tree-level-count-${e}-${t}-${r.level}`})]})})},SignalAnnotationTree=({tree:e,leafKeysWithData:t,hiddenKeys:r,showCount:n,onToggleNode:a})=>{let[i,o]=external_react_useState(()=>new Set),[l,s]=external_react_useState(()=>new Set),c=external_react_useCallback(e=>{o(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),u=external_react_useCallback(e=>{s(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]);return /*#__PURE__*/jsx_runtime_jsx(scroll_area_ScrollArea,{viewportClassName:"h-auto max-h-[var(--radix-dropdown-menu-content-available-height)]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"p-[calc(var(--size-gap-base)/2)]",children:e.sources.map((e,o)=>{let s=resolveNodeCheckState(t,r,e.leafKeys),d=`signal-tree-source-checkbox-${e.source}`;return /*#__PURE__*/jsxs("div",{className:cn_cn(o>0&&"mt-[calc(var(--size-gap-base)/2)] border-t border-border/60 pt-[calc(var(--size-gap-base)/2)]"),"data-testid":`signal-tree-source-${e.source}`,children:[/*#__PURE__*/jsxs("div",{className:"flex items-center gap-1.5 rounded-[var(--radius-control)] px-[var(--size-gap-base)] py-[calc(var(--size-gap-base)/2)] transition-colors hover:bg-accent/80","data-testid":`signal-tree-source-row-${e.source}`,children:[e.types.length>0?/*#__PURE__*/jsx_runtime_jsx("button",{type:"button","aria-label":l.has(e.source)?"展开数据来源":"折叠数据来源",className:"flex size-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:()=>u(e.source),children:l.has(e.source)?/*#__PURE__*/jsx_runtime_jsx(ChevronRight,{className:"size-3.5"}):/*#__PURE__*/jsx_runtime_jsx(ChevronDown,{className:"size-3.5"})}):/*#__PURE__*/jsx_runtime_jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}),/*#__PURE__*/jsxs("label",{htmlFor:d,className:cn_cn("flex min-w-0 flex-1 items-center gap-1.5","disabled"===s?"cursor-not-allowed":"cursor-pointer"),children:[/*#__PURE__*/jsx_runtime_jsx(checkbox_Checkbox,{id:d,"aria-label":`${e.label}筛选`,checked:toCheckboxValue(s),disabled:"disabled"===s,onCheckedChange:()=>a(e.leafKeys)}),/*#__PURE__*/jsx_runtime_jsx("span",{className:"text-xs font-medium text-foreground",children:e.label}),/*#__PURE__*/jsx_runtime_jsx(SignalNodeCount,{count:e.count,show:n,testId:`signal-tree-source-count-${e.source}`})]})]}),l.has(e.source)?null:/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-4 divide-y divide-border/40 border-l border-border/60 pl-1",children:e.types.map(o=>/*#__PURE__*/jsx_runtime_jsx(SignalTypeRow,{source:e,type:o,leafKeysWithData:t,hiddenKeys:r,showCount:n,expanded:!i.has(`${e.source}:${o.signalType}`),onToggleExpanded:()=>c(`${e.source}:${o.signalType}`),onToggleNode:a},o.signalType))})]},e.source)})})})},Signal_Switch_Switch=()=>{let{state:{signal:e},dispatch:t}=useStore_useStore(),r=e.display,n=e.show,a=useUnifiedSignals({respectVisibility:!1,filterHidden:!1}),i=external_react_useMemo(()=>buildSignalTree(a),[a]),o=external_react_useMemo(()=>new Set(i.sources.flatMap(e=>e.dataLeafKeys)),[i]),l=external_react_useMemo(()=>new Set(e.hiddenCategoryKeys??[]),[e.hiddenCategoryKeys]),s=(e.hiddenCategoryKeys?.length??0)>0,c=external_react_useCallback(r=>{t({payload:{signal:{...e,display:r}}})},[e,t]),u=external_react_useCallback(r=>{let n=toggleNodeHiddenKeys(e.hiddenCategoryKeys??[],r,o);t({payload:{signal:{...e,hiddenCategoryKeys:n}}})},[e,o,t]);return n?/*#__PURE__*/jsx_runtime_jsx(ToolbarDropdownGroup,{leading:/*#__PURE__*/jsx_runtime_jsx(primitives_ToolbarGroupIconBox,{active:r,tone:"primary",onClick:()=>{c(!r)},title:`全部信号标注:${r?"显示":"隐藏"}`,children:/*#__PURE__*/jsx_runtime_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/jsx_runtime_jsx("path",{fill:"currentColor",d:"M563.072 376.48a79.456 79.456 0 0 0 28.928-61.12 80 80 0 1 0-160 0c0 24.672 11.392 46.432 28.928 61.12l-202.88 540.256a32 32 0 1 0 59.904 22.496l49.28-131.264h289.504l49.28 131.264a32.064 32.064 0 0 0 41.248 18.752c16.544-6.208 24.896-24.672 18.72-41.216l-202.912-540.288z m-1.312 178.624h-99.552L512 422.56l49.76 132.544z m-170.464 188.896l46.912-124.896h147.616l46.912 124.896h-241.44zM662.464 417.408a32 32 0 1 0 53.12 35.648 254.72 254.72 0 0 0 43.136-142.304 255.04 255.04 0 0 0-43.136-142.304 32 32 0 1 0-53.12 35.68 190.944 190.944 0 0 1 32.288 106.624 190.816 190.816 0 0 1-32.288 106.656zM289.888 453.024a32 32 0 1 0 53.184-35.616 191.36 191.36 0 0 1-32.32-106.656 191.328 191.328 0 0 1 32.32-106.656 32.064 32.064 0 0 0-8.768-44.416 32.096 32.096 0 0 0-44.416 8.768 254.976 254.976 0 0 0-43.136 142.304 254.976 254.976 0 0 0 43.136 142.272zM210.656 117.12A32 32 0 1 0 157.44 81.536a420.032 420.032 0 0 0-70.848 233.824 419.744 419.744 0 0 0 70.88 233.856 31.936 31.936 0 0 0 44.416 8.768 32 32 0 0 0 8.768-44.416 355.168 355.168 0 0 1-60.032-198.24A355.36 355.36 0 0 1 210.656 117.12zM896.224 154.304a416.96 416.96 0 0 0-38.912-72.768 32 32 0 1 0-53.184 35.584 354.912 354.912 0 0 1 60.064 198.24 355.2 355.2 0 0 1-60.064 198.208 32.032 32.032 0 0 0 53.184 35.648 418.816 418.816 0 0 0 70.88-233.856c0-55.68-10.752-109.856-31.968-161.056z"})})}),value:null,options:[],triggerTitle:`筛选信号标注类别${s?"(已应用筛选)":""}`,triggerTestId:"signal-tree-trigger",triggerContent:/*#__PURE__*/jsx_runtime_jsx("span",{className:"sr-only",children:s?"信号标注类别筛选(已应用)":"信号标注类别筛选"}),customContent:/*#__PURE__*/jsx_runtime_jsx("div",{"data-testid":"signal-tree-popover",children:/*#__PURE__*/jsx_runtime_jsx(SignalAnnotationTree,{tree:i,leafKeysWithData:o,hiddenKeys:l,showCount:!1!==e.showCount,onToggleNode:u})}),contentClassName:"w-max max-w-[calc(100vw-1rem)] p-0",triggerClassName:cn_cn("justify-center [&>span:last-child]:ml-0",s&&"bg-accent/72 shadow-[inset_0_0_0_1px_var(--mix-primary-28)] [&>span:last-child]:text-primary")}):null},Signal_Switch=Signal_Switch_Switch,TOOLBAR_ITEM_CONFIGS=[{component:controls_AutorangingControl,toolType:constants_ToolbarItemType.AutorangingSwitch,supportedCharts:[],excludedCharts:[constants_ChartType.Heatmap,constants_ChartType.ScanDF360,constants_ChartType.LevelStream,constants_ChartType.LiteNormalized]},{component:controls_UnitControl,toolType:constants_ToolbarItemType.UnitSwitch,supportedCharts:[],excludedCharts:[constants_ChartType.ScanDF360,constants_ChartType.LevelStream]},{component:decorations_GradientRibbon,toolType:constants_ToolbarItemType.GradientRibbon,supportedCharts:[constants_ChartType.Heatmap]},{component:decorations_SpacerLine,toolType:constants_ToolbarItemType.SpacerLine,supportedCharts:[],excludedCharts:[constants_ChartType.ScanDF360,constants_ChartType.LevelStream]},{component:controls_Reset,toolType:constants_ToolbarItemType.Reset,supportedCharts:[],excludedCharts:[constants_ChartType.LiteNormalized]},{component:Signal_Switch,toolType:constants_ToolbarItemType.StationAllocationSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.DDC]},{component:controls_SeriesControl,toolType:constants_ToolbarItemType.SeriesControl,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan],props:{type:"dynamic"}},{component:FrequencyAllocation_Switch,toolType:constants_ToolbarItemType.FrequencyAllocationSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.LiteNormalized]},{component:Switch,toolType:constants_ToolbarItemType.ZoomSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan,constants_ChartType.LiteNormalized]},{component:Limit_Switch,toolType:constants_ToolbarItemType.LimitSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan]},{component:Markers_Switch,toolType:constants_ToolbarItemType.MarkersSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.MScan]},{component:controls_SegmentsDisplayControl,toolType:constants_ToolbarItemType.SegmentsDisplayControl,supportedCharts:[constants_ChartType.Scan]},{component:Capture_Switch,toolType:constants_ToolbarItemType.HeatmapCaptureSwitch,supportedCharts:[constants_ChartType.Heatmap]},{component:TimeRange_Switch,toolType:constants_ToolbarItemType.TimeRangeSwitch,supportedCharts:[constants_ChartType.Heatmap]},{component:controls_SeriesDisplayControl,toolType:constants_ToolbarItemType.SeriesDisplayControl,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan,constants_ChartType.LiteNormalized,constants_ChartType.MScan]},{component:Fluorescence_Switch,toolType:constants_ToolbarItemType.FluorescenceSwitch,supportedCharts:[constants_ChartType.SingleFrequency]},{component:DeltaMeasurement_Switch,toolType:constants_ToolbarItemType.DeltaMeasurementSwitch,supportedCharts:[constants_ChartType.SingleFrequency,constants_ChartType.Scan]}],isToolbarItemVisible=(e,t,r=[])=>!new Set(r).has(e.toolType)&&(e.supportedCharts.length>0?!!t&&e.supportedCharts.includes(t):!e.excludedCharts||!(e.excludedCharts.length>0)||!t||!e.excludedCharts.includes(t)),resolveToolbarItemProps=(e,t)=>e.props?"dynamic"===e.props.type?{...e.props,type:t}:e.props:{},Toolbar=({type:e})=>{let t=useStore_useSelector(e=>e.toolbar.show),r=useStore_useSelector(e=>e.toolbar.hiddenTools??[]),{width:n,pluginBoxWidth:a}=useAxisYWidth_useAxisYWidth(),i=external_react_useMemo(()=>({marginLeft:n,width:a,...TOOLBAR_SHELL_STYLE}),[n,a]),o=external_react_useMemo(()=>TOOLBAR_ITEM_CONFIGS.filter(t=>isToolbarItemVisible(t,e,r)).map(t=>/*#__PURE__*/jsx_runtime_jsx(t.component,{...resolveToolbarItemProps(t,e)},t.toolType)),[r,e]);return e!==constants_ChartType.Occupancy&&t?/*#__PURE__*/jsx_runtime_jsx("div",{className:TOOLBAR_SHELL_CLASS_NAME,style:i,children:/*#__PURE__*/jsx_runtime_jsx("div",{className:TOOLBAR_ITEMS_CLASS_NAME,children:o})}):null},components_Toolbar=/*#__PURE__*/memo(Toolbar);function useLevelStreamAnalyzer(){let{state:{globalID:e,axisY:t,levelStream:r}}=useStore_useStore(),n=t.range??constants_RANGE_DEFAULT,{cacheTime:a=2e4,granularity:i=1,maxPoints:o=500}=r??{},l=external_react_useRef(null),s=external_react_useRef(e),c=external_react_useCallback(e=>{passThrough(s.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,data:{[REAL_DATA_NAME]:e.spectrumData}}),passThrough(s.current,constants_ModuleType.LevelStream)({pstype:constants_PSType.Render,data:e.probabilityRangeData})},[]),u=external_react_useCallback(e=>{let{probabilityRangeData:t,spectrumData:r}=e;withDatabase(s.current).getAllRawData=t=>({...getDefaultData().getAllRawData(t),levelStreamData:e}),c({probabilityRangeData:t,spectrumData:r})},[c]);if(external_react_useEffect(()=>{s.current=e},[e]),!l.current&&e){l.current=new LevelStreamAnalyzer({range:n,cacheTime:a,granularity:i,maxPoints:o,onLevelStreamUpdate:u});let{line:t}=getConfig("levelStream");passThrough(e,constants_ModuleType.Spectrum)({pstype:constants_PSType.Series,name:REAL_DATA_NAME,color:t})}return external_react_useEffect(()=>{l.current?.setConfig({range:n})},[n]),external_react_useEffect(()=>{l.current?.setConfig({cacheTime:a})},[a]),external_react_useEffect(()=>{l.current?.setConfig({granularity:i})},[i]),external_react_useEffect(()=>{l.current?.setConfig({onLevelStreamUpdate:u})},[u]),{analyzer:l.current,updateLevelStreamData:c}}class Occupancy extends BaseRenderer{constructor(e){super({id:e.id,chart:null,orientation:e.orientation??renderer_OrientationType.Vertical})}init(){let{id:e,orientation:t}=this.state,r=[...getGradient()].reverse().map(e=>hexToRGBA(e));this.state.chart=new Series({id:e,series:[{name:"bar",type:renderer_GraphicType.Bar,display:!0,color:getConfig("bar"),orientation:t}],range:[0,100],barValue2Color:!0,colors:r})}updateSeries(e){this.state.chart?.render({name:"bar",data:e})}}let Level=e=>{let{opacity:t}=e,{chart:r,Chart:n}=hooks_useChart({Render:Occupancy,params:{orientation:renderer_OrientationType.Horizontal}});return useModuleSubscription({moduleType:constants_ModuleType.LevelStream,chart:r,extractData:e=>e.data}),/*#__PURE__*/jsx_runtime_jsx(n,{style:external_react_useMemo(()=>({opacity:t,zIndex:1}),[t])})},modules_Level=Level,MAJOR_TICK_LENGTH=6,MINOR_TICK_LENGTH=4,TEXT_OFFSET=8,resolveAxisYCanvasHorizontalLayout=({axisLineWidth:e,inside:t,width:r})=>t?{axisX:e,majorTickEndX:MAJOR_TICK_LENGTH,majorTickStartX:0,minorTickEndX:MINOR_TICK_LENGTH,minorTickStartX:0,textAlign:"left",textX:TEXT_OFFSET}:{axisX:r-e,majorTickEndX:r,majorTickStartX:r-MAJOR_TICK_LENGTH,minorTickEndX:r,minorTickStartX:r-MINOR_TICK_LENGTH,textAlign:"right",textX:r-TEXT_OFFSET},LINE_WIDTH_BASE=.5,MINOR_TICK_DIVISIONS=2,MIN_TICK_SPACING=4,MIN_CONTAINER_HEIGHT=100,IDEAL_TICK_COUNT=7,MIN_RANGE_SPAN=.5,MAJOR_TICK_LINE_WIDTH=2*LINE_WIDTH_BASE,MINOR_TICK_LINE_WIDTH=LINE_WIDTH_BASE,AXIS_LINE_WIDTH=LINE_WIDTH_BASE;function useCanvasAxisY(e){let{ranging:t}=e,{range:r,disabled:n,placement:a,show:i}=useStore_useSelector(e=>e.axisY),o="inside"===a,l=external_react_useRef(null),s=external_react_useRef(null),[c,u]=external_react_useState(0),[d,h]=external_react_useState(window.devicePixelRatio||1),[p,f]=external_react_useState(!1),[m,g]=external_react_useState(0),b=external_react_useCallback((e,t)=>{let r=.5*(Math.max(1,Math.round(t*d))%2!=0);return(Math.round(e*d-r)+r)/d},[d]),v=external_react_useCallback((e,t,r)=>{let n=r/2;return Math.min(t-n,Math.max(n,e))},[]),w=external_react_useMemo(()=>{let[e,t]=r;return{min:e,max:t}},[r]);external_react_useEffect(()=>{let e=window.matchMedia(`(resolution: ${d}dppx)`),t=()=>h(window.devicePixelRatio||1);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[d]),external_react_useEffect(()=>{let e=s.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];t&&u(t.contentRect.height)});return t.observe(e),()=>t.disconnect()},[i]);let y=external_react_useCallback((e,t)=>{if(t.useScientific)return e.toExponential(1);if(t.useKFormat){let r=e/1e3;return t.useDecimals?`${r.toFixed(1)}k`:`${Math.round(r)}k`}return t.useDecimals?e.toFixed(1):Math.round(e).toString()},[]),x=external_react_useMemo(()=>{let e;if(0===c)return{majorTicks:[],minorTicks:[]};let t=w.max-w.min,r=t/IDEAL_TICK_COUNT,n=10**Math.floor(Math.log10(r)),a=r/n;e=Math.max(e=a<=1?n:a<=2?2*n:a<=5?5*n:a<=6?6*n:10*n,MIN_RANGE_SPAN/(2*IDEAL_TICK_COUNT));let i=[],o=Math.ceil(w.min/e)*e,l=w.max+1e-6*e;for(let t=o;t<=l;t+=e)i.push(t);let s=i.some(e=>Math.abs(e)>=1e3),u=i.some(e=>.01>Math.abs(e)&&0!==e),d={useScientific:u,useKFormat:s&&!u,useDecimals:i.some(e=>e%1!=0)},h=[];for(let r=o;r<=l;r+=e){let e=(w.max-r)/t*c,n=e,a=!0,i=!1,o=c-5,l=.3*c;e<-l||e>c+l?a=!1:e<5?(n=5,i=!0):e>o&&(n=o,i=!0),a&&h.push({value:r,position:e,textPosition:n,label:y(r,d),isAdjusted:i})}let p=[],f=e/MINOR_TICK_DIVISIONS,m=f/t*c,g=t<1;if(m>=(g?2*MIN_TICK_SPACING:MIN_TICK_SPACING)&&c>MIN_CONTAINER_HEIGHT&&!g){let r=Math.ceil(w.min/f)*f;for(let n=r;n<=w.max;n+=f){if(Math.abs(n%e)<.1*f)continue;let r=(w.max-n)/t*c;r>=0&&r<=c&&p.push({value:n,position:r,textPosition:r,label:""})}}return{majorTicks:h,minorTicks:p}},[w,c,y]),k=external_react_useCallback(()=>{let e=l.current;if(!e||0===c)return;let t=e.getContext("2d");if(!t)return;let r=e.getBoundingClientRect().width,n=resolveAxisYCanvasHorizontalLayout({axisLineWidth:AXIS_LINE_WIDTH,inside:o,width:r});e.width=r*d,e.height=c*d,e.style.width=`${r}px`,e.style.height=`${c}px`,t.setTransform(d,0,0,d,0,0),t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.clearRect(0,0,r,c),t.font="12px -apple-system, BlinkMacSystemFont, sans-serif",t.textAlign=n.textAlign,t.textBaseline="middle",t.lineWidth=MAJOR_TICK_LINE_WIDTH;let a=getThemeColor("--foreground",.5,s.current);x.majorTicks.forEach(e=>{t.fillStyle=a,t.strokeStyle=a,t.fillText(e.label,n.textX,e.textPosition),t.beginPath();let r=b(v(e.position,c,MAJOR_TICK_LINE_WIDTH),MAJOR_TICK_LINE_WIDTH);t.moveTo(n.majorTickStartX,r),t.lineTo(n.majorTickEndX,r),t.stroke()}),t.strokeStyle=a,t.lineWidth=MINOR_TICK_LINE_WIDTH,x.minorTicks.forEach(e=>{t.beginPath();let r=b(v(e.position,c,MINOR_TICK_LINE_WIDTH),MINOR_TICK_LINE_WIDTH);t.moveTo(n.minorTickStartX,r),t.lineTo(n.minorTickEndX,r),t.stroke()}),t.strokeStyle=a,t.lineWidth=AXIS_LINE_WIDTH,t.beginPath();let i=b(n.axisX,AXIS_LINE_WIDTH);t.moveTo(i,0),t.lineTo(i,c),t.stroke()},[x,c,d,o,b,v]);external_react_useEffect(()=>{!1!==i&&k()},[k,i]),external_react_useEffect(()=>subscribeChartsThemeChange(()=>{k()}),[k]);let S=external_react_useCallback(e=>{n||(f(!0),g(e.clientY))},[n]),D=external_react_useCallback(e=>{n||t.moveWheel?.(e)},[t,n]),M=external_react_useCallback(e=>{if(n||!p||!s.current)return;let r=(e.clientY-m)/s.current.offsetHeight;Math.abs(r)>(w.max-w.min<1?.005:.01)&&(t.move?.(r),g(e.clientY))},[n,p,m,t,w]);return{canvasRef:l,containerRef:s,isDragging:p,range:w,handleMouseDown:S,handleMouseMove:M,handleMouseUp:external_react_useCallback(()=>{n||f(!1)},[n]),handleMouseLeave:external_react_useCallback(()=>{n||f(!1)},[n]),handleWheel:D,ticksData:x}}function AxisYCanvas(e){let{chart:t}=e,{state:{axisY:r}}=useStore_useStore(),{show:n}=r,a=spectrum_useRanging({chart:t}),{axisYWidth:i,inside:o,marginLeft:l}=useAxisYWidth_useAxisYWidth(),{canvasRef:s,containerRef:c,isDragging:u,handleMouseDown:d,handleMouseMove:h,handleMouseUp:p,handleMouseLeave:f,handleWheel:m}=useCanvasAxisY({ranging:a});return!1===n?null:/*#__PURE__*/jsx_runtime_jsx("div",{ref:c,className:cn_cn("h-full select-none",o?"absolute left-0 top-0 z-[7]":"relative",u?"cursor-grabbing":"cursor-ns-resize"),style:{width:i,marginLeft:l},onMouseDown:d,onMouseMove:h,onMouseUp:p,onMouseLeave:f,onWheel:m,onDoubleClick:()=>{let e=tools_getAxisYDoubleClickResetRange(r.restrict);a.setAxisY?.({realRange:e}),a.onChange?.()},children:/*#__PURE__*/jsx_runtime_jsx("canvas",{ref:s,className:"pointer-events-none absolute left-0 top-0 h-full w-full"})})}let EPSILON=1e-9,getDistinctPrecision=(e,t,r,n,a)=>{for(let i=n;i<=a;i+=1)if(r(e,i)!==r(t,i))return i;return a},DEFAULT_MEASUREMENT_RECT={position:40,height:20,leftPosition:40,width:20},DeltaMeasurement=()=>{let{state:{deltaMeasurement:{show:e,display:t,onChange:r},axisX:{frequencyFormat:n},axisY:{unit:a,range:i},segments:o}}=useStore_useStore(),[l,s]=external_react_useState(null),[c,u]=external_react_useState(DEFAULT_MEASUREMENT_RECT),d=external_react_useCallback(e=>{if(!n||!o?.length)return null;let{leftPosition:t,width:r,position:a,height:l}=e,s=n(t),c=n(t+r),u=s?Number(s):0,d=c?Number(c):0,[h,p]=i||[-120,0],f=p-h,m=p-a/100*f,g=p-(a+l)/100*f;return{deltaX:Math.abs(d-u),deltaY:Math.abs(m-g),centerFrequency:(u+d)/2,startFrequency:u,endFrequency:d,startAmplitude:g,endAmplitude:m}},[n,o,i]),h=external_react_useCallback(e=>{u(e);let t=d(e);t&&s(t)},[d]),p=external_react_useCallback(e=>{u(e);let t=d(e);t&&(s(t),r?.(t))},[d,r]);external_react_useEffect(()=>{if(t){u(DEFAULT_MEASUREMENT_RECT);let e=d(DEFAULT_MEASUREMENT_RECT);e&&s(e)}else s(null),r?.(null)},[t,d,r]);let f=(e,t=3)=>formatFrequencyUnitFromMHz(e,t).formatted,m=(e,t=2)=>{let r=Number.parseFloat(e.toFixed(t));return`${r} ${a}`},g=external_react_useMemo(()=>{if(!l)return{labels:void 0,middleContent:null};let e=l.deltaX<=EPSILON,t=l.deltaY<=EPSILON,r=e?3:getDistinctPrecision(l.startFrequency,l.endFrequency,f,3,6),n=t?2:getDistinctPrecision(l.startAmplitude,l.endAmplitude,m,2,4),i=f(l.startFrequency,r),o=f(l.endFrequency,r),s=m(l.endAmplitude,n),c=m(l.startAmplitude,n),u=f(l.deltaX,r),d=`${Number.parseFloat(l.deltaY.toFixed(n))} ${a}`,h=f(l.centerFrequency,r);return{labels:{left:e?void 0:i,right:e?void 0:o,top:t?void 0:s,bottom:t?void 0:c},middleContent:/*#__PURE__*/jsxs("div",{className:"grid gap-0.5",children:[/*#__PURE__*/jsx_runtime_jsx("div",{children:e?`频点: ${i}`:`ΔX: ${u}`}),/*#__PURE__*/jsx_runtime_jsx("div",{children:t?`幅度: ${c}`:`ΔY: ${d}`}),!e&&/*#__PURE__*/jsxs("div",{children:["中心: ",h]})]})}},[l,a]);return /*#__PURE__*/jsx_runtime_jsx(components_DragSelectBox,{enabled:e&&t,defaultRect:c,minSize:0,minWidth:0,minHeight:0,onChange:h,onDragEnd:p,zIndex:7,labels:g.labels,children:g.middleContent})},Spectrum_DeltaMeasurement=DeltaMeasurement,maxIndexSegments2FrequencyBandwidth=({frequencyLeft:e,segments:t})=>leftSegments2frequency(t)(e),startEnd2AnalyseFrequencyBandwidth=({e,zoom:t,segments:r,onChange:n,globalID:a})=>{let{realData:i}=withDatabase(a).getAllRawData();if(!i)return;let o=i.length,{interval:{start:l,end:s}}=t,{left:c}=e,u=e.left+e.width,d=convertCoordToVisualLeft({coord:e,segments:r,zoom:t}),h=convertCoordToVisualLeft({coord:{left:u},segments:r,zoom:t}),p=Math.max(0,Math.ceil(o*d/100)-1),f=Math.ceil(o*h/100),{maxIndex:m}=(0,array_0.jy)(Array.from(i.slice(p,f)));n({frequency:maxIndexSegments2FrequencyBandwidth({frequencyLeft:(l+(p+m+1)/o*(s-l))*100/r.totalPoints,segments:r}),bandwidth:Math.round(1e3*scopeLeftSegments2bandwidth({segments:r,endLeft:u,startLeft:c})),left:d,right:h})},DragFrame_COMPONENT_KEY=constants_ToolType.DragFrame,DragFrame=({id:e})=>{let{state:{zoom:t,segments:r,signalAnalysis:n,globalID:a},dispatch:i}=useStore_useStore(),[o,l]=external_react_useState(null),s=external_react_useCallback((e,o=!1)=>{n.show&&n.display&&o?startEnd2AnalyseFrequencyBandwidth({e,zoom:t,segments:r,onChange:n.onChange,globalID:a}):i({payload:{zoom:{...t,interval:e.interval,isScanSegmentsUpdateMagnify:e.isScanSegmentsUpdateMagnify}}})},[n,t,r,a]),c=external_react_useCallback((e,t,r,n)=>{if(e&&t&&n){let r=e.left,n=t.left,a=n-r;l({diffX:a,left:a>0?r:n,width:Math.abs(a),isScanSegmentsUpdateMagnify:a>0})}},[]),u=external_react_useCallback(()=>{if(!o)return;let{left:e,width:t,isScanSegmentsUpdateMagnify:n,diffX:a}=o,{totalPoints:i}=r;if(n&&a>0){let r=createSelectedXZoomInterval({startPercent:e,endPercent:e+t,totalPoints:i}),a=r?r.end-r.start+1:0;r&&a>UI_CONFIG.ZOOM_MIN_RANGE&&s({interval:r,isScanSegmentsUpdateMagnify:n,left:e,width:t},!0)}a<0&&s({interval:{start:0,end:i-1},isScanSegmentsUpdateMagnify:n,left:e,width:t})},[o,r,t.interval.end,s]);return(external_react_useEffect(()=>{if(t.show){let t=()=>{l(null),resetEventLevel(e,DragFrame_COMPONENT_KEY)};createMouseDownEventManager(e,DragFrame_COMPONENT_KEY,t),createMouseUpEventManager(e,DragFrame_COMPONENT_KEY,()=>{u(),t()}),createMouseLeaveEventManager(e,DragFrame_COMPONENT_KEY,t),createDragEventManager(e,DragFrame_COMPONENT_KEY,(...t)=>{compareEventPriority(e,DragFrame_COMPONENT_KEY)&&c(t[0],t[1],t[2],t[3])})}},[t.show,e,u,c]),external_react_useEffect(()=>{o||resetEventLevel(e,DragFrame_COMPONENT_KEY)},[o,e]),t.show)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-[-100%] top-0 h-full w-0 box-border border-2 border-dashed border-chart-grid-strong bg-chart-surface opacity-40",style:o?{left:`${o.left}%`,width:`${o.width}%`}:{},children:o&&!o.isScanSegmentsUpdateMagnify&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 opacity-20",style:{background:"linear-gradient(to top right, transparent, transparent calc(50% - 1px), var(--chart-grid-strong), transparent calc(50% + 1px), transparent)"}}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 opacity-20",style:{background:"linear-gradient(to bottom right, transparent, transparent calc(50% - 1px), var(--chart-grid-strong), transparent calc(50% + 1px), transparent)"}})]})})}):null},Spectrum_DragFrame=/*#__PURE__*/memo(DragFrame),FREQUENCY_ALLOCATION_LANE_HEIGHT=14,FREQUENCY_ALLOCATION_COMPACT_LANE_HEIGHT=5,FREQUENCY_ALLOCATION_COMPACT_THRESHOLD=4,resolveFrequencyAllocationDensity=({density:e="auto",channelCount:t})=>{let r="compact"===e||"auto"===e&&t>FREQUENCY_ALLOCATION_COMPACT_THRESHOLD;return{compact:r,laneHeight:r?FREQUENCY_ALLOCATION_COMPACT_LANE_HEIGHT:FREQUENCY_ALLOCATION_LANE_HEIGHT,showLabels:!r}},optimizedColors=null,originalColors=["#B22222","#CD5C5C","#FF6347","#FA8072","#F08080","#A0522D","#FF4500","#FF7F50","#B8860B","#FFA500","#808000","#9ACD32","#32CD32","#8FBC8F","#2E8B57","#3CB371","#00FA9A","#66CDAA","#7FFFD4","#2F4F4F","#008080","#00CED1","#20B2AA","#48D1CC","#4682B4","#778899","#87CEFA","#4169E1","#4169E1","#6495ED","#483D8B","#6A5ACD","#7B68EE","#9370DB","#9370DB","#9932CC","#8A2BE2","#BA55D3","#800080","#DDA0DD","#C71585","#DC143C"];function hexToHsl(e){let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,n=parseInt(e.slice(5,7),16)/255,a=Math.max(t,r,n),i=Math.min(t,r,n),o=0,l=0,s=(a+i)/2;if(a!==i){let e=a-i;switch(l=s>.5?e/(2-a-i):e/(a+i),a){case t:o=(r-n)/e+6*(r<n);break;case r:o=(n-t)/e+2;break;case n:o=(t-r)/e+4}o/=6}return{h:360*o,s:100*l,l:100*s}}let sortedColors=[...originalColors].map(e=>({color:e,hsl:hexToHsl(e)})).sort((e,t)=>Math.abs(e.hsl.h-t.hsl.h)>10?e.hsl.h-t.hsl.h:e.hsl.l-t.hsl.l).map(e=>e.color);function sortAndRecolorFrequencyAllocationData(e){let t=[...e].sort((e,t)=>Number(e.startFrequency)-Number(t.startFrequency));return t.map((e,r)=>{let n=t.length,a=sortedColors.length,i=Math.floor(r/n*a),o=Math.floor((r+1)/n*a),l=sortedColors[Math.min(i,a-1)],s=sortedColors[Math.min(o,a-1)],c=r===n-1?sortedColors[a-1]:s;return{...e,color:l,gradientColors:[l,c]}})}let FrequencyAllocation_data=[{startFrequency:87,stopFrequency:108,stepFrequency:100,bandwidth:150,modulation:"AM",demodulation:"不解调",status:"合法",title:"FM广播",description:"FM调频广播频段,用于音频广播服务"},{startFrequency:108,stopFrequency:118,stepFrequency:50,bandwidth:100,modulation:"FM",demodulation:"解调",status:"合法",title:"航空导航",description:"航空无线电导航频段,用于仪表着陆系统等"},{startFrequency:118,stopFrequency:137,stepFrequency:25,bandwidth:50,modulation:"AM",demodulation:"解调",status:"合法",title:"航空语音通信",description:"民用航空语音通信频段"},{startFrequency:121,stopFrequency:122,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"紧急通信",description:"紧急情况通信专用频段"},{startFrequency:136,stopFrequency:174,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"对讲通信",description:"专业无线对讲通信频段"},{startFrequency:161,stopFrequency:162,stepFrequency:25,bandwidth:50,modulation:"GMSK",demodulation:"解调",status:"合法",title:"AIS船舶通信",description:"船舶自动识别系统(AIS)专用频段"},{startFrequency:351,stopFrequency:400,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"集群通信",description:"专业集群通信系统频段"},{startFrequency:400,stopFrequency:470,stepFrequency:25,bandwidth:50,modulation:"FM",demodulation:"解调",status:"合法",title:"专业对讲",description:"专业无线对讲通信频段"},{startFrequency:534,stopFrequency:542,stepFrequency:100,bandwidth:8e3,modulation:"OFDM",demodulation:"解调",status:"合法",title:"数字电视",description:"数字电视广播频段"},{startFrequency:622,stopFrequency:630,stepFrequency:100,bandwidth:8e3,modulation:"OFDM",demodulation:"解调",status:"合法",title:"数字电视",description:"数字电视广播频段"},{startFrequency:703,stopFrequency:733,stepFrequency:100,bandwidth:3e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G上行(广电/移动)",description:"广电和移动5G网络上行频段"},{startFrequency:758,stopFrequency:788,stepFrequency:100,bandwidth:3e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G下行(广电/移动)",description:"广电和移动5G网络下行频段"},{startFrequency:806,stopFrequency:821,stepFrequency:25,bandwidth:50,modulation:"π/4DQPSK",demodulation:"解调",status:"合法",title:"数字集群上行",description:"数字集群通信系统(TETRA)上行频段"},{startFrequency:824,stopFrequency:835,stepFrequency:100,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"电信3G/4G/5G上行",description:"中国电信3G/4G/5G网络上行频段"},{startFrequency:851,stopFrequency:866,stepFrequency:25,bandwidth:50,modulation:"π/4DQPSK",demodulation:"解调",status:"合法",title:"数字集群下行",description:"数字集群通信系统(TETRA)下行频段"},{startFrequency:869,stopFrequency:880,stepFrequency:100,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"电信3G/4G/5G下行",description:"中国电信3G/4G/5G网络下行频段"},{startFrequency:885,stopFrequency:889,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"GSM-R上行",description:"铁路专用GSM-R网络上行频段"},{startFrequency:889,stopFrequency:904,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"移动2G/4G上行",description:"中国移动2G/4G网络上行频段"},{startFrequency:904,stopFrequency:915,stepFrequency:200,bandwidth:200,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/3/4/5G上行",description:"中国联通2G/3G/4G/5G网络上行频段"},{startFrequency:930,stopFrequency:934,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"GSM-R下行",description:"铁路专用GSM-R网络下行频段"},{startFrequency:934,stopFrequency:949,stepFrequency:200,bandwidth:200,modulation:"GMSK",demodulation:"解调",status:"合法",title:"移动2G/4G下行",description:"中国移动2G/4G网络下行频段"},{startFrequency:949,stopFrequency:960,stepFrequency:200,bandwidth:200,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/3/4/5G下行",description:"中国联通2G/3G/4G/5G网络下行频段"},{startFrequency:1164,stopFrequency:1189,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L5频段",description:"全球定位系统GPS L5频段"},{startFrequency:1215,stopFrequency:1234,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L2频段",description:"全球定位系统GPS L2频段"},{startFrequency:1447,stopFrequency:1467,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"政务公安专网",description:"政务和公安专用LTE网络频段"},{startFrequency:1563,stopFrequency:1587,stepFrequency:1e3,bandwidth:1e4,modulation:"BPSK",demodulation:"解调",status:"合法",title:"GPS L1频段",description:"全球定位系统GPS L1频段"},{startFrequency:1710,stopFrequency:1735,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"移动2G/4G上行",description:"中国移动2G/4G网络上行频段"},{startFrequency:1735,stopFrequency:1765,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/4G上行",description:"中国联通2G/4G网络上行频段"},{startFrequency:1805,stopFrequency:1830,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"移动2G/4G下行",description:"中国移动2G/4G网络下行频段"},{startFrequency:1830,stopFrequency:1860,stepFrequency:200,bandwidth:5e3,modulation:"QPSK",demodulation:"解调",status:"合法",title:"联通2/4G下行",description:"中国联通2G/4G网络下行频段"},{startFrequency:1885,stopFrequency:1915,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动4G",description:"中国移动4G网络频段"},{startFrequency:1920,stopFrequency:1940,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"电信/联通5G上行",description:"中国电信/联通5G网络上行频段"},{startFrequency:1940,stopFrequency:1965,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"联通3/4/5G上行",description:"中国联通3G/4G/5G网络上行频段"},{startFrequency:2110,stopFrequency:2130,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"电信/联通5G下行",description:"中国电信/联通5G网络下行频段"},{startFrequency:2300,stopFrequency:2320,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"联通4G",description:"中国联通4G网络频段"},{startFrequency:2320,stopFrequency:2370,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动4G",description:"中国移动4G网络频段"},{startFrequency:2400,stopFrequency:2500,stepFrequency:1,bandwidth:20,modulation:"OFDM",demodulation:"解调",status:"合法",title:"ISM 2.4GHz",description:"WIFI、蓝牙、无人机等使用频段"},{startFrequency:2515,stopFrequency:2675,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动5G/4G",description:"中国移动5G和4G网络频段"},{startFrequency:3300,stopFrequency:3600,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"5G频段",description:"电信、联通、广电5G网络频段"},{startFrequency:4800,stopFrequency:4900,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"移动5G",description:"中国移动5G网络频段"},{startFrequency:4900,stopFrequency:4960,stepFrequency:100,bandwidth:1e4,modulation:"OFDMA",demodulation:"解调",status:"合法",title:"广电5G",description:"中国广电5G网络频段"},{startFrequency:5725,stopFrequency:5875.5,stepFrequency:5,bandwidth:20,modulation:"OFDM",demodulation:"解调",status:"合法",title:"ISM 5GHz",description:"WIFI、无人机等使用频段"}],STORAGE_KEY="rfkit-charts-frequency-allocation",isFrequencyAllocationChannelCache=e=>!!e&&"object"==typeof e&&2===e.version&&Array.isArray(e.channels),readFrequencyAllocationCache=()=>{let e=localStorage.getItem(STORAGE_KEY);if(!e)return null;let t=JSON.parse(e);return Array.isArray(t)||isFrequencyAllocationChannelCache(t)?t:null},getFrequencyAllocationFromCache=()=>{let e=readFrequencyAllocationCache();return Array.isArray(e)?e:null},getFrequencyAllocationChannelsFromCache=()=>{let e=readFrequencyAllocationCache();return isFrequencyAllocationChannelCache(e)?e.channels:null},setFrequencyAllocationToCache=e=>{localStorage.setItem(STORAGE_KEY,JSON.stringify(e))},setFrequencyAllocationChannelsToCache=e=>{localStorage.setItem(STORAGE_KEY,JSON.stringify({version:2,channels:e}))},clearFrequencyAllocationCache=()=>{localStorage.removeItem(STORAGE_KEY)},hasFrequencyAllocationCache=()=>null!==localStorage.getItem(STORAGE_KEY),DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID="default",resolveChannelId=(e,t)=>e.id||e.title||`${DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID}-${t}`,normalizeChannels=(e,t)=>e.map((e,r)=>({id:resolveChannelId(e,r),title:e.title,data:t(e.data??[])})).filter(e=>e.data.length>0),normalizeSingleChannel=(e,t)=>[{id:DEFAULT_FREQUENCY_ALLOCATION_CHANNEL_ID,data:t(e)}];function resolveFrequencyAllocationChannelModel({data:e,channels:t,cachedData:r,cachedChannels:n,presetData:a,normalizeData:i}){if(t)return t.length?normalizeChannels(t,i):normalizeSingleChannel(e?.length?e:a,i);if(n?.length)return normalizeChannels(n,i);let o=e??[];return normalizeSingleChannel(r&&r.length>0?r:o.length>0?o:a,i)}function resolveFrequencyAllocationChannels({data:e,channels:t}){return resolveFrequencyAllocationChannelModel({data:e,channels:t,cachedData:getFrequencyAllocationFromCache(),cachedChannels:getFrequencyAllocationChannelsFromCache(),presetData:FrequencyAllocation_data,normalizeData:sortAndRecolorFrequencyAllocationData})}function resolveFrequencyAllocationData_resolveFrequencyAllocationData(e){return resolveFrequencyAllocationChannels({data:e})[0]?.data??[]}let resolveFrequencyAllocationRange=e=>{if(null!=e.startFrequency&&null!=e.stopFrequency){let t=frequencyCalculation_calculateFrequencyRange({startFrequency:Number(e.startFrequency),stopFrequency:Number(e.stopFrequency)});if(t)return{start:t.startFreq,stop:t.stopFreq,type:"range"}}return null},resolveFrequencyAllocationSegments=({segments:e,allocations:t,channelIndex:r,channelTitle:n})=>{if(!e.length||!t.length)return[];let a=e.reduce((e,t)=>e+t.point,0);return e.map((i,o)=>{let l=t.map(e=>{let t=resolveFrequencyAllocationRange(e);if(!t||t.stop<i.start||t.start>i.stop)return null;let{left:a,width:o}=calculatePositionFromFrequencyRange({startFreq:t.start,stopFreq:t.stop},i);return{band:e,range:t,channelIndex:r??0,channelTitle:n,position:{left:`${a}%`,width:`${o}%`}}}).filter(e=>null!==e),s=i.point/a*100,c=e.slice(0,o).reduce((e,t)=>e+t.point/a*100,0);return{segment:i,segmentIndex:o,bandPositions:l,style:{left:`${c}%`,width:`${s}%`}}})},resolveFrequencyAllocationLanes=({segments:e,channels:t})=>t.map((t,r)=>({channel:t,channelIndex:r,segmentData:resolveFrequencyAllocationSegments({segments:e,allocations:t.data,channelIndex:r,channelTitle:t.title})})).filter(e=>e.segmentData.some(e=>e.bandPositions.length>0)),resolver_createFrequencyAllocationRangeIndex=e=>e.map(e=>{let t=calculateFrequencyRange({frequency:null!=e.centerFrequency?Number(e.centerFrequency):void 0,bandwidth:null!=e.bandwidth?Number(e.bandwidth):void 0,startFrequency:null!=e.startFrequency?Number(e.startFrequency):void 0,stopFrequency:null!=e.stopFrequency?Number(e.stopFrequency):void 0});return t?{item:e,range:t,width:Math.abs(t.stopFreq-t.startFreq),center:(t.startFreq+t.stopFreq)/2,title:String(e.title??"")}:null}).filter(e=>null!==e),resolver_findFrequencyAllocationInRangeIndex=({rangeIndex:e,frequency:t})=>{let r;if(Number.isFinite(t)&&e.length){for(let n of e){let{range:e}=n;if(t<e.startFreq||t>e.stopFreq)continue;if(!r){r=n;continue}let a=n.width-r.width;if(a<0){r=n;continue}if(a>0)continue;let i=Math.abs(n.center-t)-Math.abs(r.center-t);if(i<0){r=n;continue}!(i>0)&&0>n.title.localeCompare(r.title)&&(r=n)}return r?.item}},findFrequencyAllocationAtCursor=({allocations:e,frequency:t})=>resolver_findFrequencyAllocationInRangeIndex({rangeIndex:resolver_createFrequencyAllocationRangeIndex(e),frequency:t});function useFrequencyAllocationData_useFrequencyAllocationData(){let e=useSelector(e=>e.frequencyAllocation.data);return useMemo(()=>resolveFrequencyAllocationData(e),[e])}function useFrequencyAllocationChannels(){let e=useStore_useSelector(e=>e.frequencyAllocation.data),t=useStore_useSelector(e=>e.frequencyAllocation.channels);return external_react_useMemo(()=>resolveFrequencyAllocationChannels({data:e,channels:t}),[e,t])}function useAllocationAtCursor({frequency:e,cursorSample:t}){let r=useSelector(e=>e.cursor),n=useSelector(e=>e.segments),a=useSelector(e=>e.frequencyAllocation.display),i=useSelector(e=>e.frequencyAllocation.show),o=t?.coord.left??r.coord.left,l=useFrequencyAllocationData(),s=useMemo(()=>createFrequencyAllocationRangeIndex(l),[l]),c=useMemo(()=>!!t||hasActiveSpectrumCursor(r),[r,t]),u=useMemo(()=>c&&"number"==typeof o?calculateCursorPosition(o,n):{segmentIndex:-1,pointIndex:-1},[c,o,n]);return useMemo(()=>{if(!i||!a||!e||!n?.length||!c||!n[u.segmentIndex])return;let t=getCursorFrequencyAtPosition(n,u),r=Number.isFinite(t)?t:Number(e);if(Number.isFinite(r))return findFrequencyAllocationInRangeIndex({rangeIndex:s,frequency:r})},[s,u.segmentIndex,a,e,c,n,i])}let useAllocationFinder=null,AllocationInfo=({allocationInfo:e,variant:t="default"})=>{if(!e)return null;let{title:r,description:n,startFrequency:a,stopFrequency:i,centerFrequency:o,stepFrequency:l,bandwidth:s,modulation:c,channelTitle:u}=e;return /*#__PURE__*/jsxs("div",{className:cn_cn("text-xs leading-5 text-popover-foreground","board"===t&&"mt-[calc(var(--size-gap-base)/2)] border-t border-dashed border-border pt-[calc(var(--size-gap-base)/2)]"),children:[r?/*#__PURE__*/jsx_runtime_jsx("div",{className:"mb-1 font-bold",children:r}):null,/*#__PURE__*/jsxs("div",{className:"mb-1 text-primary",children:[u?/*#__PURE__*/jsxs("div",{children:["通道:",u]}):null,a&&i&&/*#__PURE__*/jsxs("div",{children:["频率范围:",a," - ",i]}),o?/*#__PURE__*/jsxs("div",{children:["中心频率:",o," MHz"]}):null,l?/*#__PURE__*/jsxs("div",{children:["步进:",l," kHz"]}):null,s?/*#__PURE__*/jsxs("div",{children:["带宽:",s," MHz"]}):null,c?/*#__PURE__*/jsxs("div",{children:["调制方式:",c]}):null]}),n?/*#__PURE__*/jsx_runtime_jsx("div",{className:"leading-5 opacity-85",children:n}):null]})},presenters_AllocationInfo=/*#__PURE__*/react.memo(AllocationInfo),AllocationSegments=/*#__PURE__*/memo(({style:e,bandPositions:t,showLabels:r,onMouseEnter:n,onMouseMove:a,onMouseLeave:i})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute top-0 h-full [contain:layout]",style:e,children:t.map(e=>{let{band:t,channelIndex:o,range:l,position:s}=e;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-auto absolute flex h-full items-center justify-center overflow-hidden px-1 text-xs text-foreground/90 opacity-60 backdrop-blur-sm transition-[opacity,box-shadow] duration-200 hover:z-[1] hover:opacity-100 hover:shadow-lg",style:{...t.gradientColors?{backgroundImage:`linear-gradient(to right, ${t.gradientColors[0]}, ${t.gradientColors[1]})`}:{backgroundColor:t.color||"var(--primary)"},left:s.left,width:s.width},onMouseEnter:n(e),onMouseMove:a,onMouseLeave:i,children:r?/*#__PURE__*/jsx_runtime_jsx("span",{className:"truncate",children:t.title}):null},`band-${o??0}-${t.title}-${l.start}-${l.stop}-${s.left}`)})})),presenters_AllocationSegments=AllocationSegments,overlays_Tooltip_Tooltip=({title:e,description:t,visible:r,x:n,y:a,startFrequency:i,stopFrequency:o,centerFrequency:l,stepFrequency:s,bandwidth:c,modulation:u,channelTitle:d,positionRef:h,scheduleRef:p})=>{let f=external_react_useRef(null),m=external_react_useRef(null),g=external_react_useCallback(()=>{if(!r||!f.current)return;let e=f.current,t=e.offsetWidth,i=e.offsetHeight,o=window.innerWidth,l=window.innerHeight,s=h.current??{x:n,y:a},c=s.x,u=s.y,d=Math.max(12,Math.min(c+t>o-12?c-t-10:c,o-t-12)),p=Math.max(12,Math.min(u+i>l-12?u-i-10:u,l-i-12));e.style.transform=`translate3d(${d}px, ${p}px, 0)`},[h,r,n,a]),b=external_react_useCallback(()=>{r&&null===m.current&&(m.current=requestAnimationFrame(()=>{m.current=null,g()}))},[g,r]);return(external_react_useEffect(()=>(p.current=b,()=>{p.current===b&&(p.current=null)}),[b,p]),external_react_useEffect(()=>{if(r)return b(),()=>{null!==m.current&&(cancelAnimationFrame(m.current),m.current=null)}},[b,r]),r)?/*#__PURE__*/jsx_runtime_jsx("div",{ref:f,className:"pointer-events-none fixed z-[1000] max-w-[300px] rounded-[var(--radius-surface)] border border-border/70 bg-chart-panel/95 p-[var(--size-gap-base)] text-chart-panel-foreground shadow-lg backdrop-blur-md",style:{left:0,top:0,transform:`translate3d(${n}px, ${a}px, 0)`},children:/*#__PURE__*/jsx_runtime_jsx(presenters_AllocationInfo,{allocationInfo:{title:e,description:t,startFrequency:i,stopFrequency:o,centerFrequency:l,stepFrequency:s,bandwidth:c,modulation:u,channelTitle:d}})}):null},overlays_Tooltip=overlays_Tooltip_Tooltip,FrequencyAllocation=()=>{let e=useStore_useSelector(e=>e.axisX.unit),t=useStore_useSelector(e=>e.segments),r=useStore_useSelector(e=>e.frequencyAllocation.display),n=useStore_useSelector(e=>e.frequencyAllocation.show),a=useStore_useSelector(e=>e.frequencyAllocation.density),i=useStore_useSelector(e=>e.zoom.style),o=useFrequencyAllocationChannels(),[l,s]=external_react_useState({visible:!1,x:0,y:0}),c=external_react_useRef({x:0,y:0}),u=external_react_useRef(null),d=external_react_useCallback(e=>{c.current={x:e.clientX+10,y:e.clientY+10},u.current?.()},[]),h=external_react_useMemo(()=>resolveFrequencyAllocationLanes({segments:t,channels:o}),[t,o]),{laneHeight:p,showLabels:f}=resolveFrequencyAllocationDensity({density:a,channelCount:h.length}),m=Math.max(p,h.length*p),g=external_react_useCallback(e=>{s(t=>({...t,...e}))},[]),b=external_react_useCallback(({band:t,channelTitle:r,range:n})=>a=>{d(a);let i={...t,visible:!0,x:c.current.x,y:c.current.y,channelTitle:r,startFrequency:`${n.start}${e}`,stopFrequency:`${n.stop}${e}`};"centerBandwidth"===n.type&&null!=n.frequency&&null!=n.bandwidth&&(i.centerFrequency=`${n.frequency}${e}`,i.bandwidth=`${n.bandwidth}${e}`),g(i)},[e,g,d]),v=external_react_useCallback(e=>{d(e)},[d]),w=external_react_useCallback(()=>{g({visible:!1})},[g]);return n&&r&&0!==h.length?/*#__PURE__*/jsxs("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-[5] flex w-full select-none items-center overflow-hidden",style:{height:m,backgroundColor:"var(--mix-chart-surface-12)"},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 h-full w-full will-change-transform",style:i??void 0,children:h.map(({channel:e,channelIndex:t,segmentData:r})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 w-full",style:{bottom:t*p,height:p},children:r.map(({segmentIndex:t,bandPositions:r,style:n})=>/*#__PURE__*/jsx_runtime_jsx(presenters_AllocationSegments,{style:n,bandPositions:r,showLabels:f,onMouseEnter:b,onMouseMove:v,onMouseLeave:w},`channel-${e.id}-segment-${t}`))},`channel-${e.id}`))}),/*#__PURE__*/jsx_runtime_jsx(overlays_Tooltip,{...l,positionRef:c,scheduleRef:u})]}):null},Spectrum_FrequencyAllocation=FrequencyAllocation,useUpdateKey=e=>{let[t,r]=external_react_useState(0);return external_react_useEffect(()=>{if(!e)return;let t=withUpdateData(e,"FrequencyTagLineBoard",()=>{r(e=>e+1)});return()=>{t?.()}},[e]),t},Board=({id:e})=>{let{state:{frequencyTagLine:t,cursor:r}}=useStore_useStore(),{show:n,display:a,left:i,onChange:o}=t,l=useUpdateKey(e),s=r.show&&r.active&&r.event?.sourceType===constants_ModuleType.Spectrum,c=external_react_useCallback(e=>{if(!e)return;let{index:t,frequency:r}=e;(0,array_0.Ub)(r)&&o({index:t,frequency:r})},[o]);return n&&a&&!s?/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute bottom-5 right-[34px] z-[6] h-auto w-auto",children:/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyDataBoard,{left:i,updateKey:l,onChange:c,showSignalInfo:!1})}):null},FrequencyTagLine_Board=/*#__PURE__*/react.memo(Board),FrequencyTagLine_Switch_Switch=()=>{let{state:{frequencyTagLine:e},dispatch:t}=useStore(),{display:r,show:n}=e,a=useCallback(r=>{t({payload:{frequencyTagLine:{...e,display:!!r}}})},[e]),i=useMemo(()=>/*#__PURE__*/_jsx("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",children:/*#__PURE__*/_jsx("path",{d:"M288 128H896l-120 256L896 640H288v320H192v-896h96V128z",fillOpacity:".65",fill:"currentColor",style:{transition:"fill 0.2s ease"}})}),[r]);return n?/*#__PURE__*/_jsx(IconBox,{active:r,tone:"primary",onClick:()=>a(!r),title:"频率标记线显示控制",children:i}):null},FrequencyTagLine_Switch=/*#__PURE__*/null,FrequencyTagLine_COMPONENT_KEY=constants_ToolType.FrequencyTagLine,FrequencyTagLine=e=>{let{state:{frequencyTagLine:t},dispatch:r}=useStore_useStore(),{show:n,display:a,left:i,onChange:o}=t,{id:l}=e,s=external_react_useRef(t);return(external_react_useEffect(()=>{s.current=t},[t]),external_react_useEffect(()=>{let e=createMouseUpEventManager(l,FrequencyTagLine_COMPONENT_KEY,()=>{n&&a&&resetEventLevel(l,FrequencyTagLine_COMPONENT_KEY)}),t=createMouseLeaveEventManager(l,FrequencyTagLine_COMPONENT_KEY,()=>{n&&a&&resetEventLevel(l,FrequencyTagLine_COMPONENT_KEY)});return()=>{e?.(),t?.()}},[l,n,a,o]),external_react_useEffect(()=>{let e=createMouseDownEventManager(l,FrequencyTagLine_COMPONENT_KEY,e=>{n&&a&&r({payload:{frequencyTagLine:{...s.current,...e,id:l}}})}),t=createDragEventManager(l,FrequencyTagLine_COMPONENT_KEY,(e,t)=>{n&&a&&(compareEventPriority(l,FrequencyTagLine_COMPONENT_KEY),r({payload:{frequencyTagLine:{...s.current,...t,id:l}}}))});return()=>{e?.(),t?.()}},[l,n,a,r]),external_react_useEffect(()=>{r({payload:{frequencyTagLine:{...t,left:-100}}})},[n]),n&&a)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-px border-l border-dashed border-chart-highlight/80 opacity-80",style:{left:`${i}%`}})}):null},Spectrum_FrequencyTagLine=/*#__PURE__*/react.memo(FrequencyTagLine),LIMIT_THRESHOLD_TEXT_STYLE={color:SPECTRUM_THRESHOLD_COLOR},LIMIT_THRESHOLD_LINE_STYLE={borderColor:SPECTRUM_THRESHOLD_COLOR},Item_Item=({value:e,onChange:t,dragging:r})=>{let{state:{axisY:n,limit:a}}=useStore_useStore(),{label:i,disabled:o}=a,{unit:l="",range:s=constants_RANGE_DEFAULT,step:c=constants_stepDefault}=n,[u,d]=s,h=external_react_useMemo(()=>isdBm(l)?dBuV2dBm(0):0,[l]),p=external_react_useCallback(e=>(d-e-h)/(d-u)*100,[d,h,u]),f=external_react_useMemo(()=>p(e),[p,e]),m=external_react_useMemo(()=>Math.round(h+e),[h,e]),[g,b]=external_react_useState(!1),v=external_react_useRef(null),w=external_react_useCallback(e=>{switch(e.key){case"Enter":{if(!v.current){b(!1);break}let e=Number(v.current.value);!Number.isNaN(e)&&e>=u&&e<=d&&(t?.(Math.floor(e-h)),v.current.blur()),b(!1);break}case"Escape":b(!1)}},[v,s,h,t]);return /*#__PURE__*/jsx_runtime_jsx("div",{className:"relative h-full w-full",children:/*#__PURE__*/jsxs("div",{className:"absolute right-0 h-0 w-full",style:{top:`${f}%`},children:[!g||o?/*#__PURE__*/jsxs("button",{type:"button",disabled:o,className:`${r?"pointer-events-none":"pointer-events-auto"} absolute right-7 top-[-28px] z-[8] flex h-6 appearance-none items-center justify-center rounded-[var(--radius-control)] border-0 bg-secondary px-2 text-xs text-foreground`,style:LIMIT_THRESHOLD_TEXT_STYLE,onClick:()=>b(!0),children:[i," ",m,l]}):/*#__PURE__*/jsxs("div",{className:"pointer-events-auto absolute right-7 top-[-28px] z-[8] flex h-6 items-center justify-between bg-secondary px-2 text-xs text-foreground",style:LIMIT_THRESHOLD_TEXT_STYLE,children:[i," ",/*#__PURE__*/jsx_runtime_jsx("input",{ref:v,type:"number","aria-label":`${i}${l}门限值`,defaultValue:m,min:u,max:d,step:c/5,className:"h-auto w-14 border-none bg-transparent p-0 text-center outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",style:LIMIT_THRESHOLD_TEXT_STYLE,onKeyDown:w}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"flex items-center",children:l})]}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-[-0.5px] z-[8] h-0 w-full border-b border-dashed",style:LIMIT_THRESHOLD_LINE_STYLE})]})})},Limit_Item=Item_Item,COMPONENT_NAME=constants_ToolType.Limit,HIT_SLOP_PX=10,Limit=({id:e})=>{let{state:{limit:t,segments:r,axisY:n,system:a},dispatch:i}=useStore_useStore(),{show:o,active:l,disabled:s,value:c,onChange:u,unified:d}=t,[h,p]=n.range,{totalPoints:f}=r,m=external_react_useMemo(()=>o&&l,[o,l]),[g,b]=external_react_useState(0/0),v=external_react_useRef(null),w=external_react_useRef(!1),y=external_react_useRef(t);external_react_useEffect(()=>{y.current=t},[t]);let x=external_react_useCallback((e,t)=>{let r,n=d?[t]:((r=[...y.current.value])[e]=t,r);i({payload:{limit:{...y.current,value:n}}})},[i,d]),k=external_react_useCallback(()=>{u(d?Array.from({length:r.length},()=>y.current.value[0]):y.current.value)},[u,d,r.length]);return(external_react_useEffect(()=>{createMouseDownEventManager(e,COMPONENT_NAME,e=>{if(!m||s||!e?.left||!e?.top)return;let t=e.left,i=d?0:r.findIndex(e=>e.progress[0]<=t&&t<e.progress[1]);if(!Number.isFinite(i)||i<0){b(0/0),v.current=null,w.current=!1;return}let o=p-h;if(!Number.isFinite(o)||0===o)return;let l=isdBm(n.unit)?dBuV2dBm(0):0,c=y.current.value[i],u=(p-c-l)/o*100,f=Math.max(1.2,HIT_SLOP_PX/Math.max(1,a.height||1)*100);if(Math.abs(e.top-u)>f){b(0/0),v.current=null,w.current=!1;return}b(i),v.current=c,w.current=!0}),createMouseLeaveEventManager(e,COMPONENT_NAME,()=>{m&&!s&&(w.current&&k(),b(0/0),v.current=null,w.current=!1,resetEventLevel(e,COMPONENT_NAME))}),createMouseUpEventManager(e,COMPONENT_NAME,()=>{m&&!s&&(w.current&&k(),b(0/0),v.current=null,w.current=!1,resetEventLevel(e,COMPONENT_NAME))}),createDragEventManager(e,COMPONENT_NAME,(t,r,n)=>{if(m&&!s&&(0,array_0.Ub)(g)&&compareEventPriority(e,COMPONENT_NAME)&&n?.top){let e=p-h;if(!Number.isFinite(e)||0===e)return;let t=(v.current??y.current.value[g])-n.top*e;v.current=t,x(g,t)}})},[m,s,g,r,e,x,k,d,h,p,n.unit,a.height]),m)?d?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[7]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full w-full",style:{opacity:+!!(0,array_0.Ub)(c[0])},children:/*#__PURE__*/jsx_runtime_jsx(Limit_Item,{id:e,value:c[0],onChange:e=>x(0,e),dragging:(0,array_0.Ub)(g)})})}):/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[7]",children:r?.map((t,r)=>/*#__PURE__*/jsx_runtime_jsx("div",{style:{width:`${100*t.point/f}%`,opacity:+!!(0,array_0.Ub)(c[r])},className:"h-full w-[30%]",children:/*#__PURE__*/jsx_runtime_jsx(Limit_Item,{id:e,value:c[r],onChange:e=>x(r,e),dragging:(0,array_0.Ub)(g)},t.index)},t.index))}):null},Spectrum_Limit=Limit,useMarkerEvents_COMPONENT_KEY=constants_ToolType.Markers,MARKER_HIT_PX=6,MARKER_HOVER_PX=8,useMarkerEvents=e=>{let{id:t,markers:r,display:n,fixed:a,readonly:i,onCreateMarker:o,onDeleteMarker:l,onUpdateMarker:s,onToggleSelect:c,onHover:u,onResetHover:d}=e,h=external_react_useRef({isDown:null,dragStart:null,isHover:"",hoverId:null}),p=external_react_useCallback(()=>document.getElementById(getEID(t))??document.getElementById(t),[t]),f=external_react_useCallback(e=>{if(!e||!r||0===r.length)return null;let{left:t}=e;if(void 0===t)return null;let n=p();if(!n)return null;let{width:a}=n.getBoundingClientRect();for(let e=0;e<r.length;e+=1){let n=r[e];if(n&&Math.abs(t-n.left)*a/100<=MARKER_HIT_PX)return{...n,index:e}}return null},[p,r]),m=external_react_useCallback(e=>{let t=p();if(!t)return"";let n=t.getBoundingClientRect().width,a="";for(let t=0;t<r.length;t+=1){let i=r[t];if(i&&Math.abs(e.left-i.left)*n/100<=MARKER_HOVER_PX){a={...i,index:t};break}}return a},[p,r]);return external_react_useEffect(()=>{if(i)return;let e=createMoveEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,t)=>{if(n&&void 0!==t.left){let e=m({left:t.left}),r="object"==typeof e?e.id:null;if(h.current.hoverId===r){h.current.isHover=e;return}h.current.isHover=e,h.current.hoverId=r,u({left:t.left})}}),r=createDragEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{let{isDown:i}=h.current;n&&i&&compareEventPriority(t,useMarkerEvents_COMPONENT_KEY)&&!a&&s(i.id,{left:r.left,top:r.top})}),p=createMouseDownEventManager(t,useMarkerEvents_COMPONENT_KEY,e=>{if(!n)return;let t=f(e)||("object"==typeof h.current.isHover?h.current.isHover:null);t&&!a&&(h.current.isDown=t)}),g=createMouseUpEventManager(t,useMarkerEvents_COMPONENT_KEY,()=>{n&&(h.current.isDown=null,resetEventLevel(t,useMarkerEvents_COMPONENT_KEY))}),b=createMouseLeaveEventManager(t,useMarkerEvents_COMPONENT_KEY,()=>{if(!n)return;let e=null!==h.current.hoverId;h.current.isDown=null,h.current.isHover="",h.current.hoverId=null,resetEventLevel(t,useMarkerEvents_COMPONENT_KEY),e&&d()}),v=createLongPressEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{if(!n||!compareEventPriority(t,useMarkerEvents_COMPONENT_KEY))return;let a=f(r)||("object"==typeof h.current.isHover?h.current.isHover:null);a?.id&&c(a.id)}),w=createDoubleClickEventManager(t,useMarkerEvents_COMPONENT_KEY,(e,r)=>{if(!n||!compareEventPriority(t,useMarkerEvents_COMPONENT_KEY)||void 0===r.left)return!1;let a=m({left:r.left});return a&&"object"==typeof a&&a.id?l(a.id):o({left:r.left}),!0});return()=>{e?.(),r?.(),p?.(),g?.(),b?.(),v?.(),w?.()}},[t,n,r,a,i,o,l,s,c,u,d,f,m]),{isDown:h.current.isDown}},markerColors=getConfig("marker"),getRequiredGlobalStoreState=e=>getGlobalStoreState(e);function getPeaksFromDatabase(e,t,r){let{needsMaxPeak:n=!1,needsTopPeaks:a=!1}=r||{},i=null,o=null;try{let t=withDatabase(e).getAllRawData()[REAL_DATA_NAME];if(t?.peaks?.peaks&&Array.isArray(t.peaks.peaks)){let e=t.peaks.peaks;return n&&e.length>0&&(i=e[0]),a&&(o=e),{maxPeak:i,topPeaks:o}}}catch(e){console.warn("[useMarkers] Failed to get precomputed peaks:",e)}return n&&(i=findMaxPeak(t)),a&&(o=findTopPeaks(t,2)),{maxPeak:i,topPeaks:o}}let useMarkers=e=>{let{id:t,globalID:r,onChange:n}=e,[a,i]=external_react_useState({markers:[],colorIndex:0,isDown:null,isHover:"",peak:null,hasPeak:!1}),o=external_react_useRef(new Float32Array),l=external_react_useCallback((e,t)=>{let{axisY:{unit:n},axisX:{frequencyFormat:a}}=getRequiredGlobalStoreState(r),i=e.left,{peak:l}=e,s=t?.data??o.current;s&&0!==s.length||(s=withDatabase(r).getAllRawData()[REAL_DATA_NAME]),o.current=s;let c=splitZoomLeft({left:i,globalID:r}),{outsideLeft:u,multiple:d}=c,{insideLeft:h}=c,p=s.length,f=Math.floor(p*h/100);if(100===h&&(f=p-1),"mainSecondary"===e.peakTracking&&"number"==typeof e.peakRank){let n=t?.topPeaks;n||(n=getPeaksFromDatabase(r,s,{needsTopPeaks:!0}).topPeaks);let a=n?.[e.peakRank];a&&(h=((f=a.index)+.5)*100/p)}else if(l){let e=t?.maxPeak;e||(e=getPeaksFromDatabase(r,s,{needsMaxPeak:!0}).maxPeak),e&&(h=((f=e.index)+.5)*100/p)}let m=parseFloat(a(i=u+h/d)),g=s[f];return void 0===g||Number.isNaN(g)||(e.level=parseFloat(getVirtualLevel(n,g).toFixed(1))),{...e,left:i,frequency:m}},[r]),s=external_react_useCallback((e,t=!1)=>{0!==o.current.length&&i(a=>{let{marker:{maxCount:i}}=getRequiredGlobalStoreState(r);if(a.markers.length>=i)return a;let o=createGUID(),s=markerColors[a.colorIndex%20],c={...l({...e,id:o,color:s,select:!1,peak:!1,frequency:0,hover:!1}),id:o,color:s,select:!t,peak:!1,hover:!1},u=[...t?a.markers:a.markers.map(e=>({...e,select:!1})),c];return t||setTimeout(()=>{n?.(constants_MarkerEventType.Add,u)},0),{...a,markers:u,colorIndex:a.colorIndex+1}})},[l,n]),c=external_react_useCallback(({event:e,marker:t,frequencies:a,silent:s=!1})=>{i(i=>{let c=[...i.markers],u=constants_MarkerEventType.Update,{id:d,peak:h,select:p,frequency:f,left:m,top:g}=t||{},b=m;if(e===constants_MarkerEventType.Update&&void 0!==f){let e=getGlobalStoreState(r),t=(e?.segments||{totalPoints:0})[0];if(t&&d){let{start:e,stop:r}=t,n=r-e;if(void 0!==n&&f<r&&f>e)b=(f-e)*100/n;else{let e=c.findIndex(e=>e.id===d);-1!==e&&(c.splice(e,1),u=constants_MarkerEventType.Del)}}}if(e===constants_MarkerEventType.Add&&a?.length){let e=getGlobalStoreState(r),t=(e?.segments||{totalPoints:0})[0];if(t){let{start:e,stop:r}=t,n=r-e;if(void 0!==n){let t=[];for(let i=0;i<a.length;i+=1){let o=a[i];o>=e&&o<=r&&t.push((o-e)*100/n)}t.length>0&&(a=t)}}}if(e===constants_MarkerEventType.Add&&a?.length){let{marker:{maxCount:e}}=getRequiredGlobalStoreState(r),t=e-c.length,n=Math.min(a.length,t);c=c.map(e=>({...e,select:!1}));for(let e=0;e<n;e+=1){let t=createGUID(),r=markerColors[(i.colorIndex+e)%20],s=!1;if(o.current&&o.current.length>0){let t=-1/0,r=0;for(let e=0;e<o.current.length;e++)o.current[e]>t&&(t=o.current[e],r=e);Math.abs(Math.floor(o.current.length*a[e]/100)-r)<=Math.max(1,Math.floor(.01*o.current.length))&&(s=!0)}let u=l({left:a[e],id:t,color:r,select:!1,peak:s,frequency:0,hover:!1});c.push({...u,id:t,color:r,select:e===n-1,peak:s,hover:!1})}u=constants_MarkerEventType.Add}if(e===constants_MarkerEventType.Del){let e=c.findIndex(e=>e.id===d);-1!==e&&(c.splice(e,1),u=constants_MarkerEventType.Del)}return e===constants_MarkerEventType.Clear&&(c=[],u=constants_MarkerEventType.Clear),e===constants_MarkerEventType.Update&&(u=constants_MarkerEventType.Update,c=c.map(e=>(void 0!==h&&(e.peak=!1),void 0!==p&&e.id!==d&&(e.select=!1),e.id===d&&(void 0!==b&&(e=l({...e,left:b,top:g||e.top})),void 0!==p&&(e.select=p),void 0!==h&&(e.peak=h,h&&void 0===p&&(e.select=!0))),e.peak,e))),s||setTimeout(()=>{n?.(u,c)},0),{...i,markers:c,colorIndex:e===constants_MarkerEventType.Clear?0:i.colorIndex}})},[l,n]),u=external_react_useCallback(()=>{i(e=>({...e,markers:[],colorIndex:0})),setTimeout(()=>{n?.(constants_MarkerEventType.Clear,[])},0)},[n]),d=external_react_useCallback(e=>{e&&(o.current=e),i(t=>{if(0===t.markers.length)return t;let a=t.markers.some(e=>e.peak&&"mainSecondary"!==e.peakTracking),i=t.markers.some(e=>"mainSecondary"===e.peakTracking&&"number"==typeof e.peakRank),s=e??o.current??new Float32Array,{maxPeak:c,topPeaks:u}=getPeaksFromDatabase(r,s,{needsMaxPeak:a,needsTopPeaks:i}),d=t.markers.map(e=>l(e,{data:s,maxPeak:c,topPeaks:u}));return d.some((e,r)=>{let n=t.markers[r];return n&&(Math.abs(e.frequency-n.frequency)>.001||Math.abs(e.level-n.level)>.001)})&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,d)},0),{...t,markers:d}})},[l,n]),h=external_react_useCallback(e=>{let a=document.getElementById(t);if(!a)return"";let o=a.getBoundingClientRect(),{zoom:{interval:{start:l,end:s}},segments:c}=getRequiredGlobalStoreState(r),u=c.totalPoints/(s-l+1),d=o.width*u/100,h="",p=!1;return i(t=>{let r=t.markers.map((t,r)=>{let n=Math.abs(e.left-t.left)*d<=16;return t.hover!==n&&(p=!0),n&&(h={...t,index:r}),{...t,hover:n}});return p&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,r)},0),{...t,markers:r,isHover:h}}),h},[t,r,n]),p=external_react_useCallback(()=>{i(e=>{let t=!1,r=e.markers.map(e=>(e.hover&&(t=!0),{...e,hover:!1}));return t&&setTimeout(()=>{n?.(constants_MarkerEventType.Update,r)},0),{...e,markers:r,isHover:""}})},[n]),f=external_react_useRef(null),m=external_react_useRef(null),g=external_react_useCallback(()=>{i(e=>{if(e.markers.some(e=>"mainSecondary"===e.peakTracking)){let t=e.markers.filter(e=>"mainSecondary"!==e.peakTracking),r=f.current;if(r){let e=t.findIndex(e=>e.id===r);-1!==e&&(t[e]={...t[e],select:!0})}return f.current=null,setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}}let{marker:t}=getRequiredGlobalStoreState(r);if(t.maxCount-e.markers.length<2)return e;f.current=e.markers.find(e=>e.select)?.id??null;let a=[],i=e.colorIndex,s=e=>{let t=createGUID(),r=markerColors[i%20];i+=1;let n=l({left:50,id:t,color:r,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:e,frequency:0,hover:!1});a.push({...n,id:t,color:r,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:e,hover:!1})};s(0),s(1);let c=[...e.markers,...a.map(e=>({...e,select:!1}))].map(e=>l(e,{data:o.current}));return setTimeout(()=>{n?.(constants_MarkerEventType.Update,c)},0),{...e,markers:c,colorIndex:i}})},[l,r,n]),b=external_react_useCallback(()=>{i(e=>{if(e.markers.some(e=>"mainSecondary"===e.peakTracking&&0===e.peakRank)){let t=e.markers.filter(e=>"mainSecondary"!==e.peakTracking||0!==e.peakRank),r=m.current;if(r){let e=t.findIndex(e=>e.id===r);-1!==e&&(t[e]={...t[e],select:!0})}return m.current=null,setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}}let{marker:t}=getRequiredGlobalStoreState(r);if(t.maxCount-e.markers.length<1)return e;m.current=e.markers.find(e=>e.select)?.id??null;let a=createGUID(),i=markerColors[e.colorIndex%20],s={...l({left:50,id:a,color:i,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:0,frequency:0,hover:!1}),id:a,color:i,select:!1,peak:!0,peakTracking:"mainSecondary",peakRank:0,hover:!1},c=[...e.markers,s].map(e=>l(e,{data:o.current}));return setTimeout(()=>{n?.(constants_MarkerEventType.Update,c)},0),{...e,markers:c,colorIndex:e.colorIndex+1}})},[l,r,n]),v=external_react_useCallback((e,t)=>{i(a=>{let i=a.markers.find(e=>e.id===t);if(!i)return a;let s=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!s||s.length<3)return a;o.current=s;let{zoom:c,segments:u}=getRequiredGlobalStoreState(r),d=s.length,h=u.totalPoints||d,p=c.interval.end-c.interval.start+1,f=(i.left*h/100-c.interval.start)*100/p,m=Math.floor(d*f/100);100===f&&(m=d-1);let g=-1;if(s.peaks?.peaks&&Array.isArray(s.peaks.peaks)){let t=s.peaks.peaks;if("left"===e){let e=1/0;for(let r of t)if(r.index<m){let t=m-r.index;t<e&&(e=t,g=r.index)}}else{let e=1/0;for(let r of t)if(r.index>m){let t=r.index-m;t<e&&(e=t,g=r.index)}}}if(-1===g){let t=e=>{if(e<=0||e>=d-1)return!1;let t=s[e];return t>s[e-1]&&t>s[e+1]};if("left"===e){for(let e=m-1;e>0;e-=1)if(t(e)){g=e;break}}else for(let e=m+1;e<d-1;e+=1)if(t(e)){g=e;break}}if(-1===g)return a;let b=((g+.5)*100/d*p/100+c.interval.start)*(100/h),v=a.markers.map(e=>{if(e.id!==t)return{...e,select:!1};let{peakTracking:r,peakRank:n,...a}=e;return l({...a,left:b,select:!0,peak:!1},{data:s})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,v)},0),{...a,markers:v}})},[l,r,n]),w=external_react_useCallback(e=>{i(t=>{if(!t.markers.find(t=>t.id===e))return t;let a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<1)return t;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=(100*d/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),f=t.markers.map(t=>{if(t.id!==e)return{...t,select:!1};let{peakTracking:r,peakRank:n,...i}=t;return l({...i,left:p,select:!0,peak:!1},{data:a})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,f)},0),{...t,markers:f}})},[l,r,n]),y=external_react_useCallback(e=>{i(t=>{if(!t.markers.find(t=>t.id===e))return t;let a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<3)return t;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=Math.max(2,Math.floor(.1*c)),f=-1,m=-1/0;for(let e=1;e<c-1;e+=1){if(Math.abs(e-d)<p)continue;let t=a[e],r=a[e-1],n=a[e+1];t>r&&t>n&&t>m&&(m=t,f=e)}if(-1===f)return t;let g=(100*f/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),b=t.markers.map(t=>{if(t.id!==e)return{...t,select:!1};let{peakTracking:r,peakRank:n,...i}=t;return l({...i,left:g,select:!0,peak:!1},{data:a})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,b)},0),{...t,markers:b}})},[l,r,n]),x=external_react_useCallback((e,t)=>{i(a=>{let i,s=a.markers.find(e=>e.id===t);if(!s)return a;let c=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!c||c.length<2)return a;o.current=c;let{zoom:u,segments:d}=getRequiredGlobalStoreState(r),h=c.length,p=d.totalPoints||h,f=u.interval.end-u.interval.start+1,m=Math.round((h-1)*((s.left*p/100-u.interval.start)*100/f)/100);if((i="left"===e?Math.max(0,m-1):Math.min(h-1,m+1))===m)return a;let g=(100*i/(h-1)*f/100+u.interval.start)*(100/p),b=a.markers.map(e=>{if(e.id!==t)return{...e,select:!1};let{peakTracking:r,peakRank:n,...a}=e;return l({...a,left:g,select:!0,peak:!1},{data:c})});return setTimeout(()=>{n?.(constants_MarkerEventType.Update,b)},0),{...a,markers:b}})},[l,r,n]),k="#F98116",S="#AA74E8",D=external_react_useCallback(()=>{i(e=>{let t,a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<1)return e;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=(100*d/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),f=e.markers.find(e=>e.color===k);if(f)t=e.markers.map(e=>e.id===f.id?l({...e,left:p},{data:a}):e);else{let{marker:n}=getRequiredGlobalStoreState(r),i=n.maxCount;if(e.markers.length>=i)return e;let o=l({left:p,id:createGUID(),color:k,select:!1,peak:!1,hover:!1},{data:a});t=[...e.markers,o]}return setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}})},[l,r,n]),M=external_react_useCallback(()=>{i(e=>{let t,a=withDatabase(r).getAllRawData()[REAL_DATA_NAME];if(!a||a.length<3)return e;o.current=a;let{zoom:i,segments:s}=getRequiredGlobalStoreState(r),c=a.length,u=s.totalPoints||c,d=0,h=a[0];for(let e=1;e<c;e+=1)a[e]>h&&(h=a[e],d=e);let p=Math.max(2,Math.floor(.1*c)),f=-1,m=-1/0;for(let e=1;e<c-1;e+=1){if(Math.abs(e-d)<p)continue;let t=a[e],r=a[e-1],n=a[e+1];t>r&&t>n&&t>m&&(m=t,f=e)}if(-1===f)return e;let g=(100*f/(c-1)*(i.interval.end-i.interval.start+1)/100+i.interval.start)*(100/u),b=e.markers.find(e=>e.color===S);if(b)t=e.markers.map(e=>e.id===b.id?l({...e,left:g},{data:a}):e);else{let{marker:n}=getRequiredGlobalStoreState(r),i=n.maxCount;if(e.markers.length>=i)return e;let o=l({left:g,id:createGUID(),color:S,select:!1,peak:!1,hover:!1},{data:a});t=[...e.markers,o]}return setTimeout(()=>{n?.(constants_MarkerEventType.Update,t)},0),{...e,markers:t}})},[l,r,n]);return{markers:a.markers,isDown:a.isDown,isHover:a.isHover,createMarker:s,updateMarkerAttribute:c,resetMarkers:u,updateByData:d,handleHover:h,resetHover:p,toggleMainSecondaryPeaks:g,toggleMainPeak:b,moveToAdjacentPeak:v,findMainPeak:w,findSecondaryPeak:y,moveToStep:x,createMainPeakMarker:D,createSecondaryPeakMarker:M,setState:i}},Dashed=e=>{let{top:t,left:r,color:n="transparent",x:a=!0,y:i=!0,lineWidth:o=1}=e;return /*#__PURE__*/jsxs(Fragment,{children:[a&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-0 top-[-200%] z-[5] w-full border-t border-dashed",style:{top:t,borderColor:n,borderTopWidth:`${o}px`}}),i&&/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-[-200%] top-0 z-[5] h-full border-l border-dashed",style:{left:r,borderColor:n,borderLeftWidth:`${o}px`}})]})},components_Dashed=Dashed,MarkerItem=({marker:e})=>{let{state:{axisX:t,axisY:r}}=useStore_useStore(),n=external_react_useRef(null),a=external_react_useRef(null),[i,o]=external_react_useState(0),[l,s]=external_react_useState(0);external_react_useEffect(()=>{let e=()=>{n.current&&o(n.current.offsetWidth),a.current&&s(a.current.offsetWidth)};e();let t=new ResizeObserver(()=>{e()});return n.current&&t.observe(n.current),a.current&&t.observe(a.current),()=>{t.disconnect()}},[e.frequency,e.level]);let c=external_react_useMemo(()=>{let t=e.left/100*i,r=i>0&&l>0&&t+l+10>i-20;return{left:`${e.left}%`,color:e.color,opacity:e.hover?1:.68,fontWeight:e.hover?500:"normal",transform:r?"translateX(-100%)":"translateX(0)",marginLeft:r?"-10px":"10px"}},[e.left,e.hover,e.color,i,l]);return /*#__PURE__*/jsxs("div",{ref:n,className:"absolute left-0 top-0 h-full w-full",id:e.id,title:`${e.frequency}${t.unit} / ${e.level}${r.unit}`,children:[/*#__PURE__*/jsxs("div",{ref:a,className:"absolute top-[10px] z-[5] whitespace-nowrap text-[12px] leading-4 transition-[opacity,font-weight,transform,margin-left,color]",style:c,children:[/*#__PURE__*/jsxs("div",{children:[e.frequency,t.unit]}),void 0!==e.level&&/*#__PURE__*/jsxs("div",{children:[e.level,r.unit]})]}),/*#__PURE__*/jsx_runtime_jsx(components_Dashed,{x:!1,left:`${e.left}%`,top:`${e.top}%`,color:e.color,lineWidth:e.select?2:1})]},e.id)},Markers_MarkerItem=/*#__PURE__*/react.memo(MarkerItem),Markers=({id:e})=>{let{state:{marker:t,globalID:r}}=useStore_useStore(),{enabled:n,visible:a,fixed:i,readonly:o,maxCount:l,onChange:s}=t,c=external_react_useCallback((e,t)=>{s?.(e,t),MARKER_COUNT_CHANGE(r)({count:t.length,maxCount:l});let n=t.find(e=>e.select)?.id??null;MARKER_SELECTION_CHANGE(r)({selectedId:n})},[s,r,l]),u=external_react_useMemo(()=>n&&a,[n,a,t.enabled,t.visible]),d=external_react_useMemo(()=>getEID(e),[e]),{markers:h,createMarker:p,updateMarkerAttribute:f,resetMarkers:m,updateByData:g,handleHover:b,resetHover:v,toggleMainSecondaryPeaks:w,toggleMainPeak:y,moveToAdjacentPeak:x,findMainPeak:k,findSecondaryPeak:S,createMainPeakMarker:D,createSecondaryPeakMarker:M}=useMarkers({id:e,globalID:r,display:a,onChange:c});external_react_useEffect(()=>{if(!r||!d||!u||o)return;let e=useKeyEvent_subscriptionKeyBus(r,d,e=>{let t=e.key.toLowerCase();if(!["a","d","w","s"].includes(t))return;if("w"===t){if(e.repeat)return;e.preventDefault(),D();return}if("s"===t){if(e.repeat)return;e.preventDefault(),M();return}let r=h.find(e=>e.select)?.id;r&&(e.preventDefault(),x("a"===t?"left":"right",r))});return()=>{e?.()}},[d,r,h,x,u,o,D,M]);let F=external_react_useCallback(e=>{let t=h.find(t=>t.id===e),r=!t?.select;f({event:constants_MarkerEventType.Update,marker:{id:e,select:r}})},[h,f]),C=external_react_useCallback((e,t)=>{f({event:constants_MarkerEventType.Update,marker:{id:e,left:t.left,top:t.top}})},[f]);useMarkerEvents({id:e,markers:h,display:u,fixed:i,readonly:o,onCreateMarker:p,onDeleteMarker:external_react_useCallback(e=>{f({event:constants_MarkerEventType.Del,marker:{id:e}})},[f]),onUpdateMarker:C,onToggleSelect:F,onHover:b,onResetHover:v});let E=external_react_useRef(null);return(external_react_useEffect(()=>{r&&e&&withUpdateData(e,"Marker",()=>{let{realData:e}=withDatabase(r).getAllRawData();E.current=e??null,g(e)})},[r,e,g]),external_react_useEffect(()=>{r&&e&&MARKER_UPDATE_ATTRIBUTE(r,e=>{f(e)})},[r,e,f,m]),external_react_useEffect(()=>{r&&e&&MARKER_COMMAND(r,e=>{if(e?.type){if("main-secondary-peaks"===e.type)return void w();if("main-peak"===e.type)return void y();if("left-peak"===e.type)return void x("left",e.selectedId);if("right-peak"===e.type)return void x("right",e.selectedId);if("find-main-peak"===e.type)return void k(e.selectedId);if("find-secondary-peak"===e.type)return void S(e.selectedId);if("create-main-peak"===e.type)return void D();if("create-secondary-peak"===e.type)return void M();if("clear-all"===e.type)return void m()}})},[r,e,x,w,y,k,S,D,M,m]),u)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[5]",children:h.map(e=>/*#__PURE__*/jsx_runtime_jsx(Markers_MarkerItem,{marker:e},e.id))}):null},Spectrum_Markers=Markers,infoSegments2Scope=({segments:e,index:t,frequency:r,bandwidth:n})=>{if(!r||!n||!e||!e[t])return{left:0,width:0};let a=e[t],i=e.reduce((e,t)=>e+t.point,0),{left:o,width:l}=calculatePositionFromFrequencyRange({startFreq:r-n/2e3,stopFreq:r+n/2e3},a),s=e.slice(0,t).reduce((e,t)=>e+t.point/i*100,0),c=a.point/i*100;return{left:s+o/100*c,width:l/100*c}};function useScope_useScope(){let{state:{scope:e,segments:t},dispatch:r}=useStore_useStore();return external_react_useCallback(n=>{let{frequency:a,bandwidth:i,index:o=0}=n,{left:l,width:s}=infoSegments2Scope({segments:t,index:o,frequency:a,bandwidth:i});r({payload:{scope:{...e,left:l,width:s}}})},[t,e])}let Scope=()=>{let{state:{scope:{show:e,left:t,width:r}}}=useStore_useStore();return e?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-0 box-border border-y border-dashed border-chart-grid bg-chart-surface opacity-50",style:{width:`${r}%`,left:`${t}%`}})}):null},Spectrum_Scope=Scope,SignalSegments=/*#__PURE__*/memo(({style:e,signalPositions:t,activeSignalKey:r,segmentIndex:n})=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute h-full box-border",style:e,children:t.map(({item:e,key:t,position:a,color:i,tooltip:o})=>{let l=r===t,s={left:a.left,width:a.width,minWidth:"1px",backgroundColor:i,height:l?"100%":"8px",opacity:l?.5:1};return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute top-0 flex min-w-px items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap text-center text-xs text-foreground","data-signal-active":l?"true":"false","data-signal-key":t,"data-signal-source":resolveSignalSource(e),"data-testid":"signal-annotation",style:s,title:o},`segment-${n}-signal-${t}`)})})),presenters_SignalSegments=SignalSegments;function useSignalDataManager(){let{state:e,dispatch:t}=useStore_useStore(),r=external_react_useRef(e.globalID),n=external_react_useRef(e.signal),a=external_react_useRef({});return external_react_useEffect(()=>{r.current=e.globalID,n.current=e.signal},[e.globalID,e.signal]),external_react_useEffect(()=>{if(!e.globalID)return;let r=a.current.station,i=a.current.simple;void 0!==r&&(STATION_DATA(e.globalID,r),a.current.station=void 0),void 0!==i&&(t({payload:{signal:{...n.current,data:i}}}),a.current.simple=void 0)},[t,e.globalID]),{updateSignalData:external_react_useCallback(e=>{let{type:i,data:o}=e;if(Array.isArray(o)){if("station"===i){if(!r.current){a.current.station=o;return}STATION_DATA(r.current,o)}else if("simple"===i){if(!r.current){a.current.simple=o;return}t({payload:{signal:{...n.current,data:o}}})}}},[t])}}let Signal=({id:e,show:t=!0,display:r=!0})=>{let n=useStore_useSelector(e=>e.segments),a=useStore_useSelector(e=>e.zoom.style),i=useStore_useSelector(e=>e.signal),o=useCursorSample(e),l=o?.coord.left,s=useUnifiedSignals({respectVisibility:!0}),c=i.show&&i.display&&r,u=!!o,d=external_react_useMemo(()=>u&&"number"==typeof l?frequencyCalculation_calculateCursorPosition(l,n):{segmentIndex:-1,pointIndex:-1},[u,n,l]),h=external_react_useMemo(()=>u?frequencyCalculation_getCursorFrequencyAtPosition(n,d):0/0,[d,u,n]),p=external_react_useMemo(()=>resolveStaticSignalSegments({segments:n,signalItems:s}),[n,s]),f=external_react_useMemo(()=>resolveActiveSignalKey({segmentData:p,isCursorActive:u,currentFrequency:h,currentPosition:d}),[h,d,u,p]);return t&&c?/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute inset-0 z-[4] flex h-full w-full select-none items-center overflow-hidden bg-transparent",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute right-0 top-0 flex h-full w-full",style:a??void 0,children:p.map(({segmentIndex:e,signalPositions:t,style:r})=>/*#__PURE__*/jsx_runtime_jsx(presenters_SignalSegments,{style:r,signalPositions:t,activeSignalKey:d.segmentIndex===e?f:void 0,segmentIndex:e},`segment-${e}`))})}):null},Spectrum_Signal=Signal,StripeSwitch=()=>{let{state:{stripe:e},dispatch:t}=useStore(),{display:r,show:n}=e,a=useCallback(r=>{t({payload:{stripe:{...e,display:!!r}}})},[e]);return n?/*#__PURE__*/_jsx(IconBox,{active:r,tone:"primary",onClick:()=>{a(!r)},title:"频谱框选",children:/*#__PURE__*/_jsxs("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[/*#__PURE__*/_jsx("path",{d:"M835.4 757.7h-69.9v-51h18.9v-18.8h51zM713.1 757.7h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0H220v-51h83.9v51zM167.5 757.7H97.6v-69.8h51v18.8h18.9zM148.6 637.5h-51V557h51v80.5z m0-130.7h-51v-80.5h51v80.5z m0-130.8h-51v-80.5h51V376zM148.6 245.2h-51v-69.9h69.9v51h-18.9zM713.1 226.3h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0h-83.9v-51h83.9v51z m-136.4 0H220v-51h83.9v51zM835.4 245.2h-51v-18.9h-18.9v-51h69.9zM835.4 637.5h-51V557h51v80.5z m0-130.7h-51v-80.5h51v80.5z m0-130.8h-51v-80.5h51V376z",fill:"currentColor"}),/*#__PURE__*/_jsx("path",{d:"M784.4 615.7h51v233h-51z",fill:"currentColor"}),/*#__PURE__*/_jsx("path",{d:"M693.4 706.7h233v51h-233z",fill:"currentColor"})]})}):null},Stripe_Switch=null,Stripe_COMPONENT_KEY=constants_ToolType.Stripe,EDGE_HIT_SLOP=1.5,Stripe_clampPercent=e=>Math.max(0,Math.min(100,e)),resolveDragMode=({cursor:e,left:t,right:r})=>{let n=Math.abs(e-t),a=Math.abs(e-r);return n<=EDGE_HIT_SLOP?"left":a<=EDGE_HIT_SLOP?"right":e>t&&e<r?"move":n<=a?"left":"right"},Stripe=({id:e})=>{let{state:{stripe:t,axisX:{frequencyFormat:r,unit:n}},dispatch:a}=useStore_useStore(),{show:i,display:o,left:l,right:s,defaultLeft:c,defaultRight:u,onChange:d}=t,h=external_react_useRef(t),p=external_react_useRef(null),f=external_react_useRef(r),m=external_react_useRef(n),g=external_react_useRef(d);external_react_useEffect(()=>{h.current=t,f.current=r,m.current=n,g.current=d},[t,r,n,d]),external_react_useEffect(()=>{a({payload:{stripe:{...t,left:c,right:u}}})},[c,u]);let b=external_react_useCallback(e=>{let t=p.current;if(!t||!Number.isFinite(e?.left))return;let r=Stripe_clampPercent(e.left),n=h.current,{mode:i,startCursor:o,startLeft:l,startRight:s}=t,c=l,u=s;if("move"===i){let e=s-l;(u=(c=Stripe_clampPercent(l+(r-o)))+e)>100&&(c=Math.max(0,(u=100)-e))}"left"===i&&(c=Math.min(r,s)),"right"===i&&(u=Math.max(r,l)),a({payload:{stripe:{...n,left:c,right:u}}})},[a]),v=external_react_useCallback(()=>{let{left:e,right:t}=h.current,r=Math.round(10*e)/10,n=Math.round(10*t)/10,a=f.current?.(r)??"",i=f.current?.(n)??"",o=n-r,l=Number(i)-Number(a);g.current({left:r,right:n,width:o,start:a,end:i,bandwidth:l,unit:m.current})},[]);return(external_react_useEffect(()=>{createMouseDownEventManager(e,Stripe_COMPONENT_KEY,t=>{if(!i||!o||!Number.isFinite(t?.left))return;let r=h.current,n=Stripe_clampPercent(t.left);p.current={mode:resolveDragMode({cursor:n,left:r.left,right:r.right}),startCursor:n,startLeft:r.left,startRight:r.right},compareEventPriority(e,Stripe_COMPONENT_KEY)}),createMouseUpEventManager(e,Stripe_COMPONENT_KEY,()=>{i&&o&&p.current&&(p.current=null,resetEventLevel(e,Stripe_COMPONENT_KEY),v())}),createMouseLeaveEventManager(e,Stripe_COMPONENT_KEY,()=>{i&&o&&p.current&&(p.current=null,resetEventLevel(e,Stripe_COMPONENT_KEY),v())}),createMoveEventManager(e,Stripe_COMPONENT_KEY,(e,t)=>{i&&o&&p.current&&b(t)})},[e,i,o,b,v]),i&&l-s!=0&&o)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[3]",children:/*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-px box-border border-x-2 border-dashed border-y-0 border-chart-grid-strong bg-chart-surface opacity-40",style:{left:`${l}%`,width:`${s-l}%`}})}):null},Spectrum_Stripe=Stripe;function resolveBandPositions(e,t){if(!e.show)return[];if(e.kind===BandKind.Position)return[{key:BandKind.Position,left:e.left??50-e.width/2,width:e.width}];let r=frequencyCalculation_calculateFrequencyRange(e);if(!r||!t.length)return[];let n=t.reduce((e,t)=>e+Math.max(0,t.point),0);if(n<=0)return[];let a=[],i=0;return t.forEach((e,t)=>{let o=Math.max(0,e.point)/n*100;if(e.point>0&&e.frequencyCache?.length&&isRangeIntersectSegment(r,e)){let n=calculatePositionFromFrequencyRange(r,e);a.push({key:`frequency-${t}`,left:i+n.left/100*o,width:n.width/100*o})}i+=o}),a}function useBandLayerController(){let{dispatch:e,store:t}=useStoreApi();return external_react_useCallback(r=>{let n=t.getState().band,a=resolveBandState(r,n,"replace");a!==n&&e({payload:{band:a}})},[e,t])}let BandLayer=()=>{let e=useStore_useSelector(e=>e.band),t=useStore_useSelector(e=>e.segments),r=external_react_useMemo(()=>resolveBandPositions(e,t),[e,t]);return r.length?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:r.map(t=>/*#__PURE__*/jsx_runtime_jsx("div",{"data-testid":"spectrum-band","data-band-kind":e.kind,"data-band-key":t.key,className:"absolute flex h-full w-0 box-border border-y border-dashed opacity-50",style:{left:`${t.left}%`,width:`${t.width}%`,backgroundColor:e.color?`${e.color}40`:void 0,borderColor:e.color}},t.key))}):null},Spectrum_BandLayer=BandLayer,TAP_SLOP_PX=10,TAP_MAX_DURATION_MS=300,TWO_FINGER_TAP_MS=300,PINCH_AXIS_X_DEG=30,PINCH_AXIS_Y_DEG=60,createIdleGesture=()=>({mode:"idle",startX:0,startY:0,startTime:0,lastX:0,lastY:0,startCoord:null,pinchBase:null}),TouchBus_clamp=(e,t,r)=>Math.max(t,Math.min(e,r)),TouchBus=({id:e})=>{let{state:{zoom:t,segments:r,axisY:n,globalID:a},dispatch:i}=useStore_useStore(),o=getEID(e),l=external_react_useRef(null),s=external_react_useRef(createIdleGesture()),c=external_react_useRef(t),u=external_react_useRef(r.totalPoints),d=external_react_useRef(n);external_react_useEffect(()=>{c.current=t},[t]),external_react_useEffect(()=>{u.current=r.totalPoints},[r]),external_react_useEffect(()=>{d.current=n},[n]);let h=external_react_useCallback((e,t,r)=>({currentTarget:e,clientX:t,clientY:r}),[]),p=external_react_useCallback(e=>{let t=Array.from(e.touches).map(e=>({x:e.clientX,y:e.clientY})),r=t.length,n=0,a=0,i=0;if(2===r){let[e,r]=t;n=Math.hypot(r.x-e.x,r.y-e.y),a=(e.x+r.x)/2,i=(e.y+r.y)/2}else 1===r&&(a=t[0].x,i=t[0].y);return{count:r,points:t,distance:n,midX:a,midY:i}},[]),f=external_react_useCallback((e,t,r)=>{let n=h(e,t,r),a=calculateEventRelativePosition(n);createMouseEnterEventManager(o)(),createMoveEventManager(o)(n,a)},[o,h]),m=external_react_useCallback(e=>{let t=s.current.pinchBase,r=u.current;if(!t||t.distance<=0||e<=0)return;let n=e/t.distance;if(("x"===t.axisMode||"xy"===t.axisMode)&&c.current.show&&r){let e=calculateAnchoredXZoomInterval({anchorPercent:t.anchorPercent,interval:t.interval,scale:1/n,totalPoints:r});i({payload:t=>t.zoom.interval.start===e.start&&t.zoom.interval.end===e.end?null:{zoom:{...t.zoom,interval:e,isScanSegmentsUpdateMagnify:!1}}})}("y"===t.axisMode||"xy"===t.axisMode)&&a&&(useRangeZoom(a)(t.lastScale/n,t.yAnchorValue),t.lastScale=n)},[i,a]),g=external_react_useRef(m);g.current=m;let b=external_react_useCallback(e=>{let t=l.current,r=s.current;if(t&&0!==e.touches.length){if(1===e.touches.length){let{clientX:n,clientY:a}=e.touches[0];r.mode="pending",r.startX=n,r.startY=a,r.startTime=Date.now(),r.lastX=n,r.lastY=a,r.startCoord=calculateEventRelativePosition(h(t,n,a));return}if(2===e.touches.length){r.mode="pinch",r.startTime=Date.now();let n=c.current,a=p(e),[i,o]=a.points,l=Math.abs(o.x-i.x),s=180*Math.atan2(Math.abs(o.y-i.y),l)/Math.PI,{start:u,end:f}=n.interval,m=calculateEventRelativePosition(h(t,a.midX,a.midY)).left??0,g=t.getBoundingClientRect();if(g.height<=0||a.distance<=0){r.pinchBase=null;return}let[b,v]=d.current.realRange??[0,1],w=TouchBus_clamp((a.midY-g.top)/g.height,0,1);r.pinchBase={distance:a.distance,lastScale:1,interval:{start:u,end:f},anchorPercent:TouchBus_clamp(m,0,100),axisMode:s<PINCH_AXIS_X_DEG?"x":s>PINCH_AXIS_Y_DEG?"y":"xy",yAnchorValue:v-w*(v-b),startPoints:a.points,pinchMoved:!1}}}},[p,h]),v=external_react_useRef(throttleRequestAnimationFrame(e=>{if(!e||!("count"in e))return;let t=l.current,r=s.current;if(!t)return;let{count:n,points:a,distance:i}=e;if(2===n){if("pinch"===r.mode&&r.pinchBase){let e=r.pinchBase;if(!e.pinchMoved){let t={x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2},r={x:(e.startPoints[0].x+e.startPoints[1].x)/2,y:(e.startPoints[0].y+e.startPoints[1].y)/2};(Math.abs(i-e.distance)>TAP_SLOP_PX||Math.hypot(t.x-r.x,t.y-r.y)>TAP_SLOP_PX)&&(e.pinchMoved=!0)}g.current(i)}return}if(1!==n)return;let c=a[0];if("pending"===r.mode){let e=c.x-r.startX,t=c.y-r.startY;if(e*e+t*t<=TAP_SLOP_PX**2)return;r.mode="drag"}if("drag"!==r.mode)return;let u=t.getBoundingClientRect(),d={left:(c.x-r.lastX)/u.width,top:(c.y-r.lastY)/u.height},p=h(t,c.x,c.y),f=calculateEventRelativePosition(p);createMoveEventManager(o)(p,f),createDragEventManager(o)(r.startCoord,f,d,!1),r.lastX=c.x,r.lastY=c.y})).current,w=external_react_useCallback(e=>{v(p(e))},[p,v]),y=external_react_useCallback(e=>{let t=l.current,r=s.current;if(!t)return;let n=e.changedTouches[0],a=n?.clientX??r.lastX,i=n?.clientY??r.lastY;if("pending"===r.mode){let e=Date.now()-r.startTime,n=a-r.startX,o=i-r.startY;n*n+o*o<=TAP_SLOP_PX**2&&e<=TAP_MAX_DURATION_MS&&f(t,a,i)}if(1===e.touches.length){let n=e.touches[0];r.mode="drag",r.startX=n.clientX,r.startY=n.clientY,r.lastX=n.clientX,r.lastY=n.clientY,r.pinchBase=null,r.startCoord=calculateEventRelativePosition(h(t,n.clientX,n.clientY))}else 0===e.touches.length&&("pinch"===r.mode&&r.pinchBase&&!r.pinchBase.pinchMoved&&Date.now()-r.startTime<=TWO_FINGER_TAP_MS&&createMouseLeaveEventManager(o)(),r.mode="idle",r.pinchBase=null,createMouseUpEventManager(o)())},[o,f,h]),x=external_react_useCallback(()=>{let e=s.current;e.mode="idle",e.pinchBase=null,createMouseLeaveEventManager(o)()},[o]),k=external_react_useCallback(e=>{e.preventDefault()},[]);return external_react_useEffect(()=>()=>{createMouseLeaveEventManager(o)()},[o]),external_react_useEffect(()=>{l.current&&(l.current.id=o)},[o]),/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[5] pointer-events-auto",children:/*#__PURE__*/jsx_runtime_jsx("button",{ref:l,type:"button",className:cn_cn("absolute right-0 top-0 h-full w-full appearance-none border-0 bg-transparent p-0 outline-none","touch-none select-none"),"aria-label":"Touch bus",onContextMenu:k,onTouchStart:b,onTouchMove:w,onTouchEnd:y,onTouchCancel:x})})},Spectrum_TouchBus=TouchBus,Spectrum_Spectrum=e=>{let{children:t,touch:r}=e,{state:{axisY:{autoranging:n},series:{enableLengthSyncFastMode:a},globalID:i}}=useStore_useStore(),{id:o,chart:l,Chart:s}=hooks_useChart({Render:Spectrum,params:{autoranging:n,enableLengthSyncFastMode:a}});useZoomEvent(o,constants_ModuleType.Spectrum);let c=useBandLayerController(),u=useScope_useScope(),d=usePoints();return external_react_useEffect(()=>{if(i&&l)return setScanDF360Prob(i,e=>{l?.setDisabledClearRect(e)})},[i,l]),useModuleSubscription({moduleType:constants_ModuleType.Spectrum,chart:l,handleRender:(e,t)=>{t.updateSeries?.({data:e.data,extraData:e.extraData}),withUpdateData(o)()},eventHandlers:{autoranging:(e,t)=>{t.useRangeAutoFocus?.()},points:e=>{d(e.data)},[constants_PSType.Series]:(e,t)=>{t.setSeries?.(e)},band:e=>{c(e)},scope:e=>{u(e)}}}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(AxisYCanvas,{chart:l}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_GridLines,{}),/*#__PURE__*/jsx_runtime_jsx(s,{}),t,/*#__PURE__*/jsx_runtime_jsx(FrequencyTagLine_Board,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Markers,{id:o}),r?/*#__PURE__*/jsx_runtime_jsx(Spectrum_TouchBus,{id:o}):/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Limit,{id:o}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:o,type:constants_ModuleType.Spectrum}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Signal,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_DragFrame,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_BandLayer,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Scope,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Stripe,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyTagLine,{id:o}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_FrequencyAllocation,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_DeltaMeasurement,{})]})]})},modules_Spectrum=Spectrum_Spectrum,LevelStream_Chart_Chart=e=>{let{state:{cursor:t},dispatch:r}=useStore_useStore(),{publish:n}=e,{analyzer:a}=useLevelStreamAnalyzer();return publish_usePublish({publish:n,subscribe:e=>{let{pstype:t}=e;t===constants_PSType.Reset&&a?.reset(),t===constants_PSType.LevelStream&&a?.process(e.data,dateTimeToTimestamp(e.timestamp))}}),external_react_useEffect(()=>{t.mode!==constants_ModuleType.LevelStream&&r({payload:{cursor:{...t,mode:constants_ModuleType.LevelStream}}})},[t,r]),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.LevelStream}),/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Spectrum,{children:/*#__PURE__*/jsx_runtime_jsx(components_PluginBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Level,{opacity:.5})})})})]})},LevelStream_Chart=LevelStream_Chart_Chart,LevelStreamChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,cursor:{show:!0},zoom:{show:!1},signal:{show:!1},children:/*#__PURE__*/jsx_runtime_jsx(LevelStream_Chart,{...e})}),LevelStream=withChartPublisher(LevelStreamChart,"LevelStream"),charts_LevelStream=LevelStream,Ticks_ticks=["100%","75%","50%","25%","0%"],components_Ticks_Ticks=e=>{let{inside:t=!1}=e;return /*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none relative z-[2] flex h-full w-full flex-col justify-between text-xs text-foreground opacity-50",style:{alignItems:t?"flex-start":"flex-end"},children:Ticks_ticks.map(e=>/*#__PURE__*/jsx_runtime_jsx("div",{className:cn_cn("flex justify-start box-border",t?"pl-0.5 pr-0":"pr-0.5"),children:e},e))})},occupancy_components_Ticks=components_Ticks_Ticks,StandardOccupancyAxisYVariant=e=>{let{inside:t=!1}=e,{axisYWidth:r,marginLeft:n}=useAxisYWidth_useAxisYWidth();return /*#__PURE__*/jsx_runtime_jsx("div",{className:"relative flex h-full w-auto",style:{width:r,marginLeft:n,justifyContent:t?"flex-start":"flex-end"},children:/*#__PURE__*/jsx_runtime_jsx(occupancy_components_Ticks,{inside:t})})},variants_standard=/*#__PURE__*/react.memo(StandardOccupancyAxisYVariant),AxisYOccupancy=e=>{let{disabled:t,inside:r}=e,{state:{axisY:n}}=useStore_useStore(),{show:a}=n;return!1===a||t?null:/*#__PURE__*/jsx_runtime_jsx(variants_standard,{inside:r})},occupancy=AxisYOccupancy,OccupancyDashed_Dashed=()=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-0 w-full flex-1 border-t [border-color:var(--chart-grid)] first:border-t-0"}),OccupancyDashed=()=>{let{state:{gridLines:e}}=useStore_useStore();return e&&/*#__PURE__*/jsxs("div",{className:"pointer-events-none absolute right-0 top-0 z-[1] flex h-full w-full select-none flex-col border [border-color:var(--chart-grid)] bg-transparent",children:[/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{}),/*#__PURE__*/jsx_runtime_jsx(OccupancyDashed_Dashed,{})]})},GridLines_OccupancyDashed=OccupancyDashed,TOTAL_LINE_HIDDEN_OFFSET=-200,getOccupancyTotalLineRuntimeId=e=>`occupancy-total-line-${e}`,applyOccupancyTotalLineValue=(e,t,r=0)=>{e&&t&&(e.style.bottom=`${r||TOTAL_LINE_HIDDEN_OFFSET}%`,t.textContent=String(r))},withOccupancyTotalLine=(e,t,r)=>subscription_createSubscriptionManager(getOccupancyTotalLineRuntimeId(e),t,r,e),publishOccupancyTotalLine=(e,t=0)=>{withOccupancyTotalLine(e)(t)},TotalLine=({id:e})=>{let t=external_react_useRef(null),r=external_react_useRef(null),n=external_react_useRef(`OccupancyTotalLine-${Math.random().toString(36).slice(2)}`);return external_react_useEffect(()=>(applyOccupancyTotalLineValue(t.current,r.current),withOccupancyTotalLine(e,n.current,e=>{applyOccupancyTotalLineValue(t.current,r.current,e)})),[e]),/*#__PURE__*/jsx_runtime_jsx("div",{className:"pointer-events-none absolute z-[4] h-full w-full",children:/*#__PURE__*/jsxs("div",{ref:t,className:"absolute left-0 w-full opacity-50",style:{bottom:"-200%"},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute h-0 w-full border-b border-dashed border-foreground/80",style:{marginTop:"-0.5px"}}),/*#__PURE__*/jsx_runtime_jsx("div",{ref:r,className:"absolute right-7 -mt-7 flex h-6 items-center justify-center rounded-[var(--radius-control)] bg-secondary px-2 text-xs text-foreground",children:"0"})]})})},Occupancy_TotalLine=TotalLine,Occupancy_Occupancy=e=>{let{occupancyAxisYDisabled:t}=e,{id:r,chart:n,Chart:a}=hooks_useChart({Render:Occupancy});return(useModuleSubscription({moduleType:constants_ModuleType.Occupancy,chart:n,handleRender:(e,t)=>{let{data:n,totalOccupancy:a}=e;n&&t.updateSeries?.(n),void 0!==a&&publishOccupancyTotalLine(r,a)},eventHandlers:{[constants_PSType.Reset]:(e,t)=>{t.reset(),publishOccupancyTotalLine(r)}}}),useZoomEvent(r,constants_ModuleType.Occupancy),t)?/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full w-full",style:{...CHARTS_SCOPE_STYLE_VARS},[CHARTS_STYLE_SCOPE_ATTRIBUTE]:"true",children:/*#__PURE__*/jsxs("div",{className:"relative z-[0] h-full w-full",children:[/*#__PURE__*/jsx_runtime_jsx(a,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:r}),/*#__PURE__*/jsx_runtime_jsx(Occupancy_TotalLine,{id:r})]})}):/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(occupancy,{disabled:t}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(GridLines_OccupancyDashed,{}),/*#__PURE__*/jsx_runtime_jsx(a,{}),/*#__PURE__*/jsx_runtime_jsx(components_EventBus,{id:r}),/*#__PURE__*/jsx_runtime_jsx(Occupancy_TotalLine,{id:r}),/*#__PURE__*/jsx_runtime_jsx(components_Cursor,{id:r,type:constants_ModuleType.Occupancy})]})]})},modules_Occupancy=Occupancy_Occupancy,Occupancy_Chart_Chart=e=>{let{publish:t}=e,{state:{globalID:r}}=useStore_useStore(),n=useSpectrumRule(constants_ChartType.Scan);return publish_usePublish({publish:t,subscribe:e=>{n(e),e.pstype===constants_PSType.Occupancy&&(e.data&&(withDatabase(r).getAllRawData=t=>({...getDefaultData().getAllRawData(t),occupancyData:e.data})),passThrough(r,constants_ModuleType.Occupancy)({...e,pstype:constants_PSType.Render}))}}),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{})}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:constants_ChartType.Scan})]})},Occupancy_Chart=Occupancy_Chart_Chart,OccupancyChart=e=>/*#__PURE__*/jsx_runtime_jsx(src_store,{...e,zoom:{show:!1},children:/*#__PURE__*/jsx_runtime_jsx(Occupancy_Chart,{...e})}),charts_Occupancy_Occupancy=withChartPublisher(OccupancyChart,"Occupancy"),charts_Occupancy=charts_Occupancy_Occupancy,Zoom=()=>{let e=useStoreDispatch(),t=useStore_useSelector(e=>e.zoom),r=useStore_useSelector(e=>e.segments.totalPoints)??0,n=useStore_useSelector(e=>e.axisX.frequencyFormat),{interval:{start:a,end:i},onChange:o}=t,l=external_react_useMemo(()=>r&&n?[n((100*a+1)/r),n((100*i+1)/r)]:["",""],[a,i,r,n]);return external_react_useEffect(()=>{r&&void 0!==l[0]&&void 0!==l[1]&&o(l,{start:a,end:i})},[l,o,r]),external_react_useEffect(()=>{if(!r)return;let t=i-a+1,n=r/t,o=`-${a/t*100}%`,l=`${100*n}%`;e({payload:e=>({zoom:{...e.zoom,style:{left:o,width:l}}})})},[e,i,a,r]),null},components_Zoom=Zoom;class FluorescenceRender extends GradientRenderer{constructor(e){super({id:e.id,globalID:e.globalID,chart:null,renderMode:e.renderMode})}init(){let{id:e,renderMode:t}=this.state;e&&(this.state.chart=new Fluorescence({id:e,colors:this.getInitialColors(),ignoreValue:0,fluorescenceRenderMode:t}),this.subscribeToColor("Fluorescence-Render"))}updateProps(e){void 0!==e.renderMode&&(this.state.renderMode=e.renderMode),this.state.chart?.updateProps(e)}updateSeries(e){this.state.chart&&e&&this.state.chart.render(e)}setRenderMode(e){this.state.renderMode=e,this.state.chart?.setRenderMode(e)}}let Fluorescence_Fluorescence=()=>{let{state:{axisY:{range:e},fluorescence:{display:t,renderMode:r}}}=useStore_useStore(),{chart:n,Chart:a}=hooks_useChart({Render:FluorescenceRender,params:{renderMode:r}});external_react_useEffect(()=>{n?.updateProps({range:e})},[n,e]),external_react_useEffect(()=>{n&&n.setRenderMode(r)},[r]),useModuleSubscription({moduleType:constants_ModuleType.Fluorescence,chart:n,renderPSTypes:[constants_PSType.Fluorescence],extractData:e=>e.data});let i=external_react_useMemo(()=>({height:"100%",width:"100%",display:"flex",visibility:t?"visible":"hidden"}),[t]);return external_react_useEffect(()=>{n&&n.updateProps({display:t})},[n,t]),/*#__PURE__*/jsx_runtime_jsx("div",{style:i,children:/*#__PURE__*/jsx_runtime_jsx(components_FlexBox,{children:/*#__PURE__*/jsx_runtime_jsx(a,{})})})},modules_Fluorescence=Fluorescence_Fluorescence,HeatmapPortal_Chart=e=>{let{type:t,heatmapElementID:r,renderer:n}=e;return /*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:r,children:/*#__PURE__*/jsxs(components_Background,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.Heatmap}),/*#__PURE__*/jsx_runtime_jsx(modules_Heatmap,{renderer:n,zoomMode:"linked-x"}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:t})]})})},HeatmapPortal=HeatmapPortal_Chart,OccupancyPortal_Chart=e=>{let{occupancyElementID:t,occupancyAxisYElementID:r,type:n}=e;return /*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:t,children:r?/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{occupancyAxisYDisabled:!0}):/*#__PURE__*/jsxs(components_Background,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:constants_ChartType.Occupancy}),/*#__PURE__*/jsx_runtime_jsx(modules_Occupancy,{}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:n})]})}),/*#__PURE__*/jsx_runtime_jsx(Overlay_Portal,{id:r,children:/*#__PURE__*/jsx_runtime_jsx(occupancy,{inside:!0})})]})},OccupancyPortal=OccupancyPortal_Chart,BLAZE_PROGRESS=(e,t)=>subscription_createSubscriptionManager(`BLAZE_PROGRESS-${e}`,"0",t,e),Blaze=()=>{let{state:{blaze:{show:e},segments:t,globalID:r}}=useStore_useStore(),[n,a]=external_react_useState(""),i=external_react_useMemo(()=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];n.progress&&e.push(...n.progress)}return e},[t]);return(external_react_useEffect(()=>{e&&r&&BLAZE_PROGRESS(r,e=>{a(i.includes(e)?void 0:`${100*e}%`)})},[e,r]),e)?/*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{children:/*#__PURE__*/jsxs("div",{className:"absolute left-[-100%] top-0 flex h-full w-0 opacity-50",style:{left:n},children:[/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-[-0.5px] opacity-50",style:{borderRight:"0.5px solid var(--chart-grid-strong)"}}),/*#__PURE__*/jsx_runtime_jsx("div",{className:"ml-[-31px] w-[30px] opacity-20",style:{background:"linear-gradient(90deg, transparent, var(--chart-grid-strong))"}})]})}):null},Spectrum_Blaze=/*#__PURE__*/react.memo(Blaze),Legend=()=>{let{state:{legend:{children:e}}}=useStore_useStore();return /*#__PURE__*/jsx_runtime_jsx("div",{className:"absolute left-5 top-5 z-[6] flex h-auto w-auto items-center",children:e})},Spectrum_Legend=Legend,SegmentsZebra=()=>{let{state:{segments:e}}=useStore_useStore(),t=e.totalPoints??0;return /*#__PURE__*/jsx_runtime_jsx(Zoom_ZoomViewportLayer,{className:"z-[0]",children:e.map((e,r)=>/*#__PURE__*/jsx_runtime_jsx("div",{className:"h-full border-x",style:{width:t>0?`${100*e.point/t}%`:0,borderColor:r%2==1?"var(--chart-grid)":"transparent",background:r%2==1?"var(--chart-surface)":"transparent",opacity:r%2==1?.4:1}},`${e.start}_${e.stop}_${e.index}`))})},Spectrum_SegmentsZebra=SegmentsZebra,useMarkerPublish=({globalID:e})=>({handleMarkerPublish:external_react_useCallback(t=>{if(e)switch(t.pstype){case constants_PSType.Marker:MARKER_UPDATE_ATTRIBUTE(e)(t);break;case constants_PSType.Reset:MARKER_UPDATE_ATTRIBUTE(e)({type:constants_MarkerEventType.Clear})}},[e])}),Spectrum_useMarkerPublish=useMarkerPublish;function resolveThresholdDataOptions({segmentOffset:e,offset:t}){let r={};return void 0!==e&&(r.segmentOffset=e),void 0!==t&&(r.offset=t),void 0!==r.segmentOffset||void 0!==r.offset?r:void 0}function setAnalyzerThresholdData(e,t){"thresholdData"in t&&e.setThresholdData(t.thresholdData,resolveThresholdDataOptions(t))}function useTemplateComparison(){let{state:{globalID:e,axisX:{frequencyFormat:t},signal:{onChange:r}}}=useStore_useStore(),n=external_react_useRef(t),a=external_react_useRef(r);external_react_useEffect(()=>{n.current=t,a.current=r},[e,t,r]);let i=external_react_useCallback(e=>{if(!e||0===e.length)return[];let t=[],r=Date.now();return e.forEach(a=>{let i=n.current,{startIndex:o,endIndex:l}=a,s=e.length,c=i((o+.5)*100/s),u=i((l+.5)*100/s),d=i((o+l)/2*100/s);c!==u&&t.push({...a,frequency:d,bandwidth:(u-c)*1e3,timestamp:r})}),t},[]);return{updateTemplateOverData:external_react_useCallback(e=>{if(e){let t=i(e);a.current(t)}},[i])}}function useSpectrumAnalyzer(e){let{state:{globalID:t,series:{enableMetrics:r,enableWaterfall:n},fluorescence:{show:a},axisY:{unit:i},zoom:{interval:o},heatmapCapture:{display:l},system:{width:s},marker:c}}=useStore_useStore(),u=external_react_useRef(null),d=external_react_useRef(t),h=external_react_useRef(o),p=external_react_useRef(0),f=external_react_useRef(null),{updateSignalData:m}=useSignalDataManager(),g=external_react_useRef(l);external_react_useEffect(()=>{g.current=l},[l]);let b=external_react_useCallback(e=>{passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,data:e})},[]),v=external_react_useCallback(e=>{passThrough(d.current,constants_ModuleType.Heatmap)({pstype:constants_PSType.Render,data:e})},[]),w=external_react_useCallback(e=>{BLAZE_PROGRESS(d.current)?.(e)},[]),{updateTemplateOverData:y}=useTemplateComparison(),x=external_react_useCallback(e=>{(e.realData||e.templateData||e.backgroundNoiseData||"thresholdData"in e)&&b({minData:e.minData,maxData:e.maxData,avgData:e.avgData,thresholdData:e.thresholdData,backgroundNoiseData:e.backgroundNoiseData,realData:e.realData,templateData:e.templateData}),e.scanProgress&&w(e.scanProgress),e.templateOverData&&y(e.templateOverData),e.waterfallData&&v(e.waterfallData),e.fluorescenceData&&passThrough(d.current,constants_ModuleType.Fluorescence)({pstype:constants_PSType.Fluorescence,data:{fluorescenceData:e.fluorescenceData,fluorescenceMaxCount:e.fluorescenceMaxCount}}),e.occupancyData&&passThrough(d.current,constants_ModuleType.Occupancy)({pstype:constants_PSType.Render,data:e.occupancyData,totalOccupancy:p.current}),e.extraData&&passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Render,extraData:e.extraData})},[b,v,w,y]);external_react_useEffect(()=>{d.current=t},[t]);let k=(e,t)=>!1!==e&&(t??!0);if(!u.current&&t){let i=Math.min(1|Math.floor(2*s),1001);u.current=new SpectrumAnalyzer({...e,outputPoints:i,processing:{...e?.processing,enableMetrics:k(r,e?.processing?.enableMetrics),enableWaterfall:k(n,e?.processing?.enableWaterfall),enableFluorescence:a,enablePeakStats:!!c?.enabled},onSpectrumUpdate:x});let o=withDatabase(t),l=u.current;o.getAllRawData=e=>l.getAllRawData(e),withSpectrumAnalyzerSYNC(t,u.current)}external_react_useEffect(()=>{let e=Math.floor(o.start),t=Math.ceil(o.end),r=Math.floor(h.current.start),n=Math.ceil(h.current.end);(e!==r||t!==n)&&u.current&&(h.current=o,u.current.updateSamplingRange(e,t+1))},[o]);let S=external_react_useCallback(async(e=!1)=>{setTimeout(()=>{passThrough(d.current,constants_ModuleType.Heatmap)({pstype:constants_PSType.Reset}),passThrough(d.current,constants_ModuleType.Spectrum)({pstype:constants_PSType.Reset}),passThrough(d.current,constants_ModuleType.Occupancy)({pstype:constants_PSType.Reset}),e&&resetSeries(d.current)},1)},[]),D=external_react_useCallback(async e=>{if(u.current)switch(e.pstype){case constants_PSType.AntennaFactor:u.current.setAntennaFactor(e.data);break;case constants_PSType.Signal:m({type:e.type,data:e.data});break;case constants_PSType.Spectrum:e.data&&u.current.process(e),setAnalyzerThresholdData(u.current,e),e.maxData&&u.current.setMaxData(e.maxData),e.minData&&u.current.setMinData(e.minData),e.avgData&&u.current.setAvgData(e.avgData),e.templateData&&u.current.setTemplateData(e.templateData,e.templateTolerance),e.backgroundNoiseData&&u.current.setBackgroundNoiseData(e.backgroundNoiseData),e.extraData&&u.current.setExtraData(e.extraData,types_ExtraDataMode.MERGE,e.segmentedExtraData?{segmentOffset:e.segmentOffset,offset:e.offset}:void 0);break;case constants_PSType.Fluorescence:e.data&&u.current&&u.current.setFluorescenceData(e.data.fluorescenceData,e.data.fluorescenceMaxCount);break;case constants_PSType.Heatmap:if(e.data){let{data:t,timestamps:r}=e,n=convertToTimestampedArrays(t,r);u.current.setWaterfallData(n)}break;case constants_PSType.Occupancy:u.current?.setOccupancyData(e.data),p.current=e.totalOccupancy;break;case constants_PSType.Segments:u.current.initializeSegments(e.data),await S(),e.onFinally?.();break;case constants_PSType.SpectrumBandwidth:u.current.reset();break;case constants_PSType.Series:updateSeries(d.current,e);break;case constants_PSType.Reset:u.current.reset(),await S(!0),e.onFinally?.();break;case constants_PSType.Clear:u.current.reset(),await S(!1),e.onFinally?.()}},[m,updateSeries,S]);return external_react_useEffect(()=>{let e=i.includes("/m");u.current?.setAntennaFactorSwitch(e)},[i]),external_react_useEffect(()=>{if(!u.current)return;let t=k(r,e?.processing?.enableMetrics);t!==f.current&&(u.current.updateProcessing({enableMetrics:t}),f.current=t)},[r,e?.processing?.enableMetrics]),D}let Spectrum_Chart_Chart=e=>{let{state:{globalID:t}}=useStore_useStore(),r=external_react_useRef([]),n=external_react_useRef(""),{type:a=constants_ChartType.SingleFrequency,publish:i,heatmapElementID:o,occupancyElementID:l,occupancyAxisYElementID:s,touch:c,children:u,processing:d,renderer:h}=e,{enableMetrics:p,enableWaterfall:f}=useSpectrumChartType({type:a,heatmapElementID:o}),m=useSpectrumAnalyzer({processing:{enableWaterfall:f,enableMetrics:p,...d}}),g=useSpectrumRule(a);useTouchMode(c);let{handleMarkerPublish:b}=Spectrum_useMarkerPublish({globalID:t});return publish_usePublish({publish:i,subscribe:e=>{if(m(e),b(e),g(e),e.pstype===constants_PSType.Heatmap){let{data:a,timestamps:i}=e;if(r.current=convertToTimestampedArrays(a,i),n.current!==t){let e=withDatabase(t),a=e.getAllRawData;e.getAllRawData=e=>({...a(e),waterfallData:r.current}),n.current=t}}passThrough(t,constants_ModuleType.Spectrum)(e),passThrough(t,constants_ModuleType.Heatmap)(e),passThrough(t,constants_ModuleType.Occupancy)(e),passThrough(t,constants_ModuleType.Fluorescence)(e)}}),/*#__PURE__*/jsxs(components_Container,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Toolbar,{type:a}),/*#__PURE__*/jsxs(components_FlexBox,{children:[/*#__PURE__*/jsx_runtime_jsx(modules_Spectrum,{touch:c,children:u||/*#__PURE__*/jsx_runtime_jsx(modules_Fluorescence,{})}),/*#__PURE__*/jsx_runtime_jsx(HeatmapPortal,{type:a,heatmapElementID:o,renderer:h}),/*#__PURE__*/jsx_runtime_jsx(OccupancyPortal,{type:a,occupancyElementID:l,occupancyAxisYElementID:s}),/*#__PURE__*/jsxs(components_PluginBox,{children:[/*#__PURE__*/jsx_runtime_jsx(components_Zoom,{}),a===constants_ChartType.Scan&&/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx_runtime_jsx(Spectrum_SegmentsZebra,{}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Blaze,{})]}),/*#__PURE__*/jsx_runtime_jsx(Spectrum_Legend,{})]})]}),/*#__PURE__*/jsx_runtime_jsx(components_AxisX,{type:a})]})},Spectrum_Chart=Spectrum_Chart_Chart,heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE="singleFrequency",DEFAULT_HEATMAP_CAPTURE_TYPE="slider",withSpectrumHeatmapCaptureDefaults=e=>{let t=e.type??heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE;return e.heatmapElementID&&(t===heatmapCaptureDefaults_DEFAULT_SPECTRUM_TYPE||"scan"===t||"mscan"===t)?{...e,heatmapCapture:{show:!0,display:!1,type:DEFAULT_HEATMAP_CAPTURE_TYPE,toolbarVariant:"deltaMeasurement",...e.heatmapCapture}}:e},SpectrumChart=e=>{let t=withSpectrumHeatmapCaptureDefaults(e);return /*#__PURE__*/jsx_runtime_jsx(src_store,{...t,children:/*#__PURE__*/jsx_runtime_jsx(Spectrum_Chart,{...t})})},charts_Spectrum_Spectrum=withChartPublisher(SpectrumChart,"Spectrum"),charts_Spectrum=charts_Spectrum_Spectrum;function initChartsTheme(e={}){let{onChange:t,sizes:r,tokens:n}=e;initializeChartsThemeEnvironment({sizes:r,tokens:n});let a=getChartsThemeState();return{cleanup:t?subscribeChartsThemeChange(e=>t(e)):void 0,...a}}var signal_SignalDataType=/*#__PURE__*/function(e){return e.Station="station",e.Simple="simple",e}({});initializeChartsThemeEnvironment();export{charts_Dial as Dial,charts_Gauge as Gauge,charts_Heatmap as Heatmap,charts_IQ as IQ,charts_LevelStream as LevelStream,charts_Occupancy as Occupancy,charts_Spectrum as Spectrum,constants_AxisPlacement as AxisPlacement,constants_ChartType as ChartType,constants_FrequencyUnit as FrequencyUnit,constants_MarkerEventType as MarkerEventType,constants_ModuleType as ModuleType,constants_OptionKey as OptionKey,constants_PSType as PSType,constants_SegmentsEvent as SegmentsEvent,constants_SeriesType as SeriesType,constants_ToolType as ToolType,constants_ToolbarItemType as ToolbarItemType,formatFrequencyUnit,formatFrequencyUnitFromHz,formatFrequencyUnitFromMHz,getChartsThemeState,heatmap_HeatmapCaptureType as HeatmapCaptureType,initChartsTheme,marker_MarkerMode as MarkerMode,setFrequencyAllocationChannelsToCache,setFrequencyAllocationToCache,signal_SignalDataType as SignalDataType,subscribeChartsThemeChange,useSafePublish,withChartPublisher};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { RendererType } from '@rfkit/renderer';
|
|
1
2
|
import { type ReactNode } from 'react';
|
|
2
3
|
interface Props {
|
|
3
4
|
heatmapDefaultData?: Array<Array<number>>;
|
|
4
5
|
onSubscriptionReadyChange?: (ready: boolean) => void;
|
|
5
6
|
overview?: ReactNode;
|
|
6
7
|
zoomMode?: 'disabled' | 'independent-xy' | 'linked-x';
|
|
8
|
+
renderer?: RendererType;
|
|
7
9
|
}
|
|
8
10
|
declare const Heatmap: React.FC<Props>;
|
|
9
11
|
export default Heatmap;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { type IHeatmap } from '@rfkit/renderer';
|
|
1
|
+
import { type IHeatmap, RendererType } from '@rfkit/renderer';
|
|
2
2
|
import { GradientRenderer, type GradientRenderState } from '../base';
|
|
3
3
|
interface HeatmapRenderProps {
|
|
4
4
|
id: string;
|
|
5
5
|
globalID: string;
|
|
6
6
|
realRange?: [number, number];
|
|
7
7
|
heatmapDefaultData?: number[][];
|
|
8
|
+
renderer?: RendererType;
|
|
8
9
|
}
|
|
9
10
|
interface HeatmapRenderState extends GradientRenderState<IHeatmap> {
|
|
10
11
|
realRange: [number, number];
|
|
11
12
|
heatmapDefaultData: number[][];
|
|
13
|
+
renderer?: RendererType;
|
|
12
14
|
}
|
|
13
15
|
export default class Heatmap extends GradientRenderer<IHeatmap, HeatmapRenderState, number[][]> {
|
|
14
16
|
private lastSeriesData;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { RendererType } from '@rfkit/renderer';
|
|
1
2
|
import type React from 'react';
|
|
2
3
|
import { ChartType } from '../../config';
|
|
3
4
|
interface Props {
|
|
4
5
|
type: ChartType;
|
|
5
6
|
heatmapElementID?: string;
|
|
7
|
+
renderer?: RendererType;
|
|
6
8
|
}
|
|
7
9
|
declare const Chart: React.FC<Props>;
|
|
8
10
|
export default Chart;
|