transone-chart 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,6 +43,8 @@ class MyPage extends Component {
43
43
  ```
44
44
 
45
45
  `TcChart` 是**受控组件**:`option` 由父级传入,数据变化自动 `setOption + render`;组件卸载自动销毁。
46
+ 尺寸变化(容器宽度 / 窗口横竖屏)自动**防抖重绘(150ms)**:Web 用 ResizeObserver 增量 `resize + render`,
47
+ 小程序端用窗口尺寸回调重建,无需手动调用。
46
48
 
47
49
  ### 方式二:引擎直用(无框架场景)
48
50
 
@@ -71,7 +73,7 @@ chart3.render();
71
73
  |---|---|---|
72
74
  | 折线 | `LineChartOption` | `smooth` 平滑曲线、`area` 面积填充、`showSymbol` 数据点、`startFromZero` |
73
75
  | 柱状 | `BarChartOption` | `stack` 堆叠分组、`horizontal` 横向、`borderRadius` 圆角、`barWidth` |
74
- | 饼图 | `PieChartOption` | `radius / innerRadius`(环形)、`startAngle`、扇区百分比标签 |
76
+ | 饼图 | `PieChartOption` | `radius / innerRadius`(环形)、`startAngle`、`labelPosition: 'outside'` 引线外置标签 |
75
77
  | 雷达 | `RadarChartOption` | `indicators[].max` 归一化、`splitCount` 网格层、`area` 多边形填充 |
76
78
 
77
79
  完整字段见 [`lib/types.ts`](./lib/types.ts)(每个字段均带中文注释)。
@@ -157,7 +159,7 @@ save → scale(dpr) → clear → 背景 → 布局(title/legend/轴区逐层扣
157
159
  ## 开发
158
160
 
159
161
  ```bash
160
- bun test # 46 个单测(mock canvas 断言绘制命令)
162
+ bun test # 53 个单测(mock canvas 断言绘制命令 + 防抖 / resize)
161
163
  bun run build # tsc 声明 + Bun.build(minify, ESM)
162
164
  bun run --cwd ../../playground/chart-demo build:web # 演示项目构建
163
165
  ```
@@ -167,7 +169,7 @@ bun run --cwd ../../playground/chart-demo build:web # 演示项目构建
167
169
  ```
168
170
  packages/transone-chart/
169
171
  ├── lib/ # 源码(core / charts / adapters / factory / component / types)
170
- ├── tests/ # 单测(scale / layout / line / bar / pie / radar / factory)
172
+ ├── tests/ # 单测(scale / layout / line / bar / pie / radar / factory / debounce / resize
171
173
  ├── scripts/build.ts # 构建脚本
172
174
  └── playground 演示:playground/chart-demo(城市指数场景,五种图表卡片)
173
175
  ```
@@ -7,7 +7,10 @@
7
7
  * - 未来原生:通过 resolve 注入自定义解析器
8
8
  *
9
9
  * 组件本身是薄壳:状态由父级以 option 传入(完全受控),
10
- * 数据变化时自动 setOption + render
10
+ * 数据变化时自动 setOption + render
11
+ * 容器 / 窗口尺寸变化时防抖(150ms)自动重绘:
12
+ * - Web:ResizeObserver 观察 canvas,重测 clientWidth/Height 后增量 resize + render
13
+ * - 小程序:平台窗口尺寸回调触发后重建图表(SelectorQuery 取最新节点尺寸)
11
14
  */
12
15
  import { Component, type VNode } from 'transone';
13
16
  import type { ChartRenderContext, ChartOption } from './types';
@@ -25,6 +28,9 @@ interface TcChartState {
25
28
  export declare class TcChart extends Component<TcChartProps, TcChartState> {
26
29
  private chart;
27
30
  private destroyed;
31
+ private resizeDebounced;
32
+ private resizeObserver;
33
+ private mpResizeHandler;
28
34
  protected initState(): TcChartState;
29
35
  protected initStyles(): void;
30
36
  protected render(): VNode;
@@ -36,6 +42,9 @@ export declare class TcChart extends Component<TcChartProps, TcChartState> {
36
42
  private attachChart;
37
43
  /** 组件根元素(canvas)。Web 端用于解析渲染上下文;小程序端经 SelectorQuery .in(实例) 查询,不依赖此方法。 */
38
44
  getElement(): HTMLCanvasElement | null;
45
+ private setupAutoResize;
46
+ private teardownAutoResize;
47
+ private handleResize;
39
48
  private resolveContext;
40
49
  }
41
50
  export {};
@@ -38,7 +38,7 @@ export declare abstract class ChartBase<T extends ChartOption> {
38
38
  private destroyed;
39
39
  constructor(context: ChartRenderContext, option: T);
40
40
  setOption(option: Partial<T>): this;
41
- resize(width: number, height: number): this;
41
+ resize(width: number, height: number, dpr?: number): this;
42
42
  render(): this;
43
43
  destroy(): void;
44
44
  isDestroyed(): boolean;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 零依赖防抖工具。
3
+ *
4
+ * 用于高频触发场景(如窗口 / 容器尺寸变化)的合并调度:
5
+ * 连续调用只会在停止触发 delay 毫秒后执行一次。
6
+ */
7
+ export interface Debounced<T extends (...args: never[]) => unknown> {
8
+ /** 触发一次;若已有待执行调用则重置计时器(合并连续触发)。 */
9
+ run: (...args: Parameters<T>) => void;
10
+ /** 取消尚未执行的调用。 */
11
+ cancel: () => void;
12
+ /** 是否已有待执行的调用。 */
13
+ pending: () => boolean;
14
+ }
15
+ type AnyFunction = (...args: any[]) => unknown;
16
+ export declare function debounce<T extends AnyFunction>(fn: T, delay: number): Debounced<T>;
17
+ export {};
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ export { LinearScale, CategoryScale, niceTicks } from './core/scale';
16
16
  export type { LinearScaleOptions, ScaleResult } from './core/scale';
17
17
  export { computeLayout } from './core/layout';
18
18
  export type { Box, LayoutInput, LayoutResult, Padding } from './core/layout';
19
+ export { debounce } from './core/debounce';
20
+ export type { Debounced } from './core/debounce';
19
21
  export { ChartBase } from './core/chart';
20
22
  export type { CartesianScales } from './core/chart';
21
23
  export { LineChart } from './charts/line';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- var ke=["#1677ff","#00b578","#ff8f1f","#ff3141","#eb2f96","#722ed1","#13c2c2","#faad14","#2f54eb","#a0d911"],V="#323233",Ne="#c8c9cc",ge="#ebedf0",Q="-apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif";function ut(e){return typeof e==="object"&&e!==null&&typeof e.save==="function"&&typeof e.beginPath==="function"&&typeof e.fill==="function"&&typeof e.stroke==="function"&&typeof e.fillText==="function"}function Oe(e,t,n=5){let r=e,o=t;if(!Number.isFinite(r)||!Number.isFinite(o))throw Error("niceTicks: domain must be finite numbers");if(r===o){let u=Math.abs(r)>1?Math.abs(r)*0.1:1;r-=u,o+=u}if(r>o)[r,o]=[o,r];let s=(o-r)/Math.max(1,n),a=pt(s),l=Math.floor(r/a)*a,c=Math.ceil(o/a)*a,p=[];for(let u=l;u<=c+a*0.000000001;u+=a)p.push(ct(u,a));return{min:l,max:c,step:a,ticks:p}}function pt(e){let t=Math.pow(10,Math.floor(Math.log10(e))),n=e/t,r;if(n<=1)r=1;else if(n<=2)r=2;else if(n<=5)r=5;else r=10;return r*t}function ct(e,t){let n=Math.max(0,-Math.floor(Math.log10(t))+1);return Number(e.toFixed(n))}class W{min;max;ticks;step;rangeStart;rangeEnd;constructor(e,t,n,r,o={}){let{min:i,max:s,splitCount:a=5}=o,l=i,c=s;if(l===void 0||c===void 0){let p=Oe(e,t,a);l=l??p.min,c=c??p.max,this.ticks=p.ticks,this.step=p.step}else{this.step=(c-l)/Math.max(1,a),this.ticks=[];for(let p=0;p<=a;p+=1)this.ticks.push(l+p*this.step)}this.min=l,this.max=c,this.rangeStart=n,this.rangeEnd=r}scale(e){let t=(e-this.min)/(this.max-this.min);return this.rangeStart+t*(this.rangeEnd-this.rangeStart)}}class J{categories;bandWidth;innerGapRatio;rangeStart;constructor(e,t,n,r=0.35){this.categories=e;this.innerGapRatio=r,this.rangeStart=t;let o=Math.max(1,e.length);this.bandWidth=(n-t)/o}bandStart(e){return this.rangeStart+this.bandWidth*e}center(e){return this.bandStart(e)+this.bandWidth/2}innerWidth(){return this.bandWidth*(1-this.innerGapRatio)}groupInnerWidth(e){return this.innerWidth()/Math.max(1,e)*0.8}}var dt={top:12,right:16,bottom:12,left:16};function ht(e,t){let{legend:n}=e,r=e.legendItems??[],o=n?.fontSize??12,i=n?.itemGap??16,s=n?.markerSize??12;if(n?.position==="right"){let l=0;for(let c of r){let p=s+6+t(c);if(p>l)l=p}return{width:l+12,height:Math.max(r.length*(o+8)+12,0)}}let a=0;for(let l of r)a+=s+6+t(l)+i;if(a>0)a-=i;return{width:a,height:o+12+4}}function ye(e,t){let n={...dt,...e.basePadding},r=n.top,o=n.bottom,i=n.left,s=n.right,a=null;if(e.title?.text){let b=e.title.fontSize??16;a={x:0,y:0,width:e.width,height:b},r+=b+(e.title.padding??16)}let l=null,c=e.legend;if(c&&c.show!==!1&&(e.legendItems?.length??0)>0){let b=ht(e,t),T=c.position??"top";if(T==="top")l={x:0,y:a?a.height:0,width:e.width,height:b.height},r+=b.height;else if(T==="bottom")l={x:0,y:e.height-b.height,width:e.width,height:b.height},o+=b.height;else l={x:e.width-b.width,y:r,width:b.width,height:Math.max(0,e.height-r-o)},s+=b.width}let p=11,u=0,d=0,h=0,m=0,R=e.valueLabels??[],g=e.categoryLabels??[];if(e.horizontal){if(g.length>0){for(let b of g){let T=t(b);if(T>m)m=T}m+=16,i+=m}if(R.length>0)h=p+16,o+=h}else{if(R.length>0){for(let b of R){let T=t(b);if(T>u)u=T}u+=16,i+=u}if(g.length>0)d=p+16,o+=d}let y=Math.max(0,e.width-i-s),C=Math.max(0,e.height-r-o),v={x:i,y:r,width:y,height:C},k=e.horizontal?{x:v.x,y:v.y+v.height,width:y,height:h}:{x:v.x-u,y:r,width:u,height:C},w=e.horizontal?{x:v.x-m,y:r,width:m,height:C}:{x:i,y:v.y+C,width:y,height:d};return{plot:v,valueAxisBox:k,categoryAxisBox:w,titleBox:a,legendBox:l,padding:n}}function mt(e,t=Q){return`${e}px ${t}`}function P(e,t,n=Q){let r=mt(t,n);return e.font=r,r}function z(e,t,n,r=Q){return P(e,n,r),e.measureText(t).width}class be{ctx;constructor(e){this.ctx=e}drawValueAxis(e){let{plot:t,scale:n,labels:r,horizontal:o=!1,labelFontSize:i=11,labelColor:s=V,gridColor:a=ge,gridLineWidth:l=1,gridLineDash:c,showGrid:p=!0}=e,u=n.ticks,{ctx:d}=this;for(let h=0;h<u.length;h+=1){let m=n.scale(u[h]),R=r[h]??String(u[h]);if(p){if(d.save(),d.strokeStyle=a,d.lineWidth=l,c&&c.length>0)d.setLineDash(c);if(d.beginPath(),o)d.moveTo(t.x,m),d.lineTo(t.x+t.width,m);else d.moveTo(t.x,m),d.lineTo(t.x+t.width,m);d.stroke(),d.restore()}if(P(d,i),d.fillStyle=s,d.textBaseline="middle",o)d.textAlign="center",d.fillText(R,m,t.y+t.height+8);else d.textAlign="right",d.fillText(R,t.x-8,m)}}drawCategoryAxis(e){let{plot:t,scale:n,labels:r,horizontal:o=!1,axisColor:i=Ne,labelFontSize:s=11,labelColor:a=V,gridColor:l=ge,gridLineWidth:c=1,showGrid:p=!1}=e,{ctx:u}=this,d=r.length;if(p){u.save(),u.strokeStyle=l,u.lineWidth=c,u.beginPath();for(let h=0;h<d;h+=1){let m=n.center(h);if(o)u.moveTo(t.x,m),u.lineTo(t.x+t.width,m);else u.moveTo(m,t.y),u.lineTo(m,t.y+t.height)}u.stroke(),u.restore()}P(u,s),u.fillStyle=a,u.textBaseline="middle";for(let h=0;h<d;h+=1){let m=n.center(h);if(o)u.textAlign="right",u.fillText(r[h],t.x-8,m);else u.textAlign="center",u.fillText(r[h],m,t.y+t.height+8)}if(u.save(),u.strokeStyle=i,u.lineWidth=1,u.beginPath(),o)u.moveTo(t.x,t.y),u.lineTo(t.x,t.y+t.height);else u.moveTo(t.x,t.y+t.height),u.lineTo(t.x+t.width,t.y+t.height);u.stroke(),u.restore()}}class ve{ctx;constructor(e){this.ctx=e}draw(e){let{box:t,items:n,position:r="top",fontSize:o=12,color:i=V,markerSize:s=12,itemGap:a=16}=e;if(n.length===0)return;let{ctx:l}=this;if(P(l,o),r==="right"){let d=t.y+o/2+4;for(let h of n)this.drawItem(h,t.x,d,o,s,i),d+=o+8;return}let c=0;for(let d of n)c+=s+6+z(l,d.name,o)+a;c-=a;let p=t.x+(t.width-c)/2,u=t.y+t.height/2;for(let d of n)this.drawItem(d,p,u,o,s,i),p+=s+6+z(l,d.name,o)+a}drawItem(e,t,n,r,o,i){let{ctx:s}=this;s.fillStyle=e.color,s.beginPath(),s.rect(t,n-o/2,o,o),s.fill(),s.fillStyle=i,s.textAlign="left",s.textBaseline="middle",s.fillText(e.name,t+o+6,n)}}class A{ctx;option;width;height;dpr;palette;cartesian=null;destroyed=!1;constructor(e,t){this.ctx=e.ctx,this.option=t,this.width=e.width,this.height=e.height,this.dpr=e.dpr,this.palette=e.palette??ke}setOption(e){return this.option={...this.option,...e},this}resize(e,t){return this.width=Math.max(0,e),this.height=Math.max(0,t),this}render(){if(this.destroyed)return this;let{ctx:e,width:t,height:n,dpr:r}=this;e.save(),e.scale(r,r),e.clearRect(0,0,t,n);let o=this.getBackgroundColor();if(o)e.fillStyle=o,e.fillRect(0,0,t,n);let i=this.computeLayout();if(this.drawTitle(i),this.drawLegend(i),this.hasCartesianAxis())this.cartesian=this.buildCartesianScales(i),this.drawCartesianAxis(i);else this.cartesian=null;return this.drawSeries(e,i,this.option),e.restore(),this}destroy(){this.destroyed=!0}isDestroyed(){return this.destroyed}hasCartesianAxis(){return!0}getValueDomain(){return{min:0,max:1}}getCategoryLabels(){return[]}isHorizontal(){return!1}getBackgroundColor(){return this.option.backgroundColor}getTitle(){return this.option.title}getLegend(){let e=this.option.legend;if(e)return e;return this.getLegendItems().length>0?{position:"top"}:void 0}getLegendItems(){return[]}getValueAxis(){return this.option.yAxis}getCategoryAxis(){return this.option.xAxis}computeLayout(){let e=this.buildLayoutInput();return ye(e,(n)=>z(this.ctx,n,11))}buildLayoutInput(){let e=this.isHorizontal(),t=this.hasCartesianAxis();return{width:this.width,height:this.height,title:this.getTitle(),legend:this.getLegend(),legendItems:this.getLegendItems().map((n)=>n.name),valueLabels:t&&!e?this.computeValueLabels():void 0,categoryLabels:t?this.getCategoryLabels():void 0,horizontal:e}}computeValueLabels(){let e=this.getValueDomain(),t=this.getValueAxis();return new W(e.min,e.max,0,1,{min:t?.min,max:t?.max,splitCount:t?.splitCount}).ticks.map((r)=>t?.format?t.format(r):String(r))}drawTitle(e){let t=this.getTitle();if(!t?.text||!e.titleBox)return;let{ctx:n}=this;P(n,t.fontSize??16),n.fillStyle=t.color??"#323233",n.textAlign="center",n.textBaseline="top",n.fillText(t.text,this.width/2,e.titleBox.y)}drawLegend(e){let t=this.getLegend();if(t?.show===!1||!e.legendBox)return;let n=this.getLegendItems();if(n.length===0)return;new ve(this.ctx).draw({box:e.legendBox,items:n,position:t?.position??"top",fontSize:t?.fontSize,color:t?.color,markerSize:t?.markerSize,itemGap:t?.itemGap})}buildCartesianScales(e){let{plot:t}=e,n=this.isHorizontal(),r=this.getValueDomain(),o=this.getCategoryLabels(),i=this.getValueAxis(),s=new W(r.min,r.max,n?t.x:t.y+t.height,n?t.x+t.width:t.y,{min:i?.min,max:i?.max,splitCount:i?.splitCount}),a=new J(o,n?t.y:t.x,n?t.y+t.height:t.x+t.width);return{value:s,category:a}}drawCartesianAxis(e){let t=this.cartesian;if(!t)return;let{ctx:n}=this,{plot:r}=e,o=this.isHorizontal(),i=this.getValueAxis(),s=this.getCategoryAxis(),a=this.getCategoryLabels(),l=new be(n),c=t.value.ticks.map((p)=>i?.format?i.format(p):String(p));l.drawValueAxis({plot:r,scale:t.value,labels:c,horizontal:o,labelFontSize:i?.labelFontSize,labelColor:i?.labelColor,gridColor:i?.gridColor,gridLineWidth:i?.gridLineWidth,gridLineDash:i?.gridLineDash,showGrid:i?.showGrid??!0}),l.drawCategoryAxis({plot:r,scale:t.category,labels:a,horizontal:o,labelFontSize:s?.labelFontSize,labelColor:s?.labelColor,gridColor:s?.gridColor,gridLineWidth:s?.gridLineWidth,showGrid:s?.showGrid??!1})}seriesColor(e,t){return t??this.palette[e%this.palette.length]}}class Z extends A{getValueDomain(){let{series:e,yAxis:t,startFromZero:n=!1}=this.option,r=1/0,o=-1/0;for(let i of e)for(let s of i.data){if(s<r)r=s;if(s>o)o=s}if(!Number.isFinite(r)||!Number.isFinite(o))return{min:0,max:1};if(n&&r>0)r=0;if(t?.min!==void 0)r=Math.min(r,t.min);if(t?.max!==void 0)o=Math.max(o,t.max);return{min:r,max:o}}getCategoryLabels(){return this.option.xAxis.labels}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let r=this.cartesian;if(!r)return;let{plot:o}=t,{value:i,category:s}=r,a=n.series.map((l)=>l.data.map((c,p)=>({x:s.center(p),y:i.scale(c)})));n.series.forEach((l,c)=>{let p=a[c];if(p.length===0)return;let u=this.seriesColor(c,l.color),d=l.lineWidth??2;if(l.area)e.save(),e.fillStyle=u,e.globalAlpha=0.15,e.beginPath(),this.tracePath(e,p,l.smooth??!1),e.lineTo(p[p.length-1].x,o.y+o.height),e.lineTo(p[0].x,o.y+o.height),e.closePath(),e.fill(),e.restore();if(e.save(),e.strokeStyle=u,e.lineWidth=d,e.lineJoin="round",e.lineCap="round",e.beginPath(),this.tracePath(e,p,l.smooth??!1),e.stroke(),e.restore(),l.showSymbol!==!1){e.save(),e.fillStyle=u;for(let h of p)e.beginPath(),e.arc(h.x,h.y,Math.max(2.5,d+0.5),0,Math.PI*2),e.fill();e.restore()}})}tracePath(e,t,n){if(t.length===0)return;if(e.moveTo(t[0].x,t[0].y),!n||t.length<3){for(let r=1;r<t.length;r+=1)e.lineTo(t[r].x,t[r].y);return}for(let r=0;r<t.length-1;r+=1){let o=t[Math.max(0,r-1)],i=t[r],s=t[r+1],a=t[Math.min(t.length-1,r+2)],l=i.x+(s.x-o.x)/6,c=i.y+(s.y-o.y)/6,p=s.x-(a.x-i.x)/6,u=s.y-(a.y-i.y)/6;e.bezierCurveTo(l,c,p,u,s.x,s.y)}}}class ee extends A{isHorizontal(){return this.option.horizontal??!1}getValueDomain(){let{series:e,yAxis:t}=this.option,n=0,r=0,o=De(e),i=Math.max(0,...e.map((s)=>s.data.length));for(let s=0;s<i;s+=1)for(let a of o){let l=0,c=0;for(let p of a){let u=p.data[s]??0;if(u>=0)l+=u;else c+=u}if(l>n)n=l;if(c<r)r=c}if(t?.min!==void 0)r=Math.min(r,t.min);if(t?.max!==void 0)n=Math.max(n,t.max);return{min:r,max:n}}getCategoryLabels(){return this.option.xAxis.labels}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let r=this.cartesian;if(!r)return;let{value:o,category:i}=r,s=n.horizontal??!1,a=De(n.series),l=n.xAxis.labels.length;for(let c=0;c<l;c+=1){let p=a,u=p.length,d=n.series.map((m)=>m.barWidth).find((m)=>m!==void 0&&m>0),h=this.computeSlot(i,u,d);p.forEach((m,R)=>{let g=h.offset+R*h.size,y=0;m.forEach((C)=>{let v=C.data[c]??0,k=this.seriesColor(n.series.indexOf(C),C.color);if(s){let w=o.scale(0),b=o.scale(y+v),T=Math.min(w,b),F=Math.abs(b-w),fe=i.bandStart(c)+g;this.drawBar(e,{x:T,y:fe,width:F,height:h.size,radius:C.borderRadius??0,color:k,roundSide:v>=0?"right":"left"})}else{let w=o.scale(y),b=o.scale(y+v),T=Math.min(w,b),F=Math.abs(b-w),fe=i.bandStart(c)+g;this.drawBar(e,{x:fe,y:T,width:h.size,height:F,radius:C.borderRadius??0,color:k,roundSide:v>=0?"top":"bottom"})}y+=v})})}}computeSlot(e,t,n){if(n!==void 0)return{offset:(e.innerWidth()-n)/2,size:n};let r=e.innerWidth()/Math.max(1,t)*0.8;return{offset:(e.innerWidth()-r*t)/2,size:r}}drawBar(e,t){if(t.width<=0||t.height<=0)return;e.save(),e.fillStyle=t.color,e.beginPath(),ft(e,t,t.radius,t.roundSide),e.fill(),e.restore()}}function De(e){let t=[],n=new Map;for(let r of e)if(r.stack){let o=n.get(r.stack);if(!o)o=[],n.set(r.stack,o),t.push(o);o.push(r)}else t.push([r]);return t}function ft(e,t,n,r){let{x:o,y:i,width:s,height:a}=t,l=Math.min(n,s/2,a/2);if(l<=0){e.rect(o,i,s,a);return}let c=r==="top"||r==="left",p=r==="top"||r==="right",u=r==="bottom"||r==="left",d=r==="bottom"||r==="right";if(e.moveTo(o+(c?l:0),i),e.lineTo(o+s-(p?l:0),i),p)e.arcTo(o+s,i,o+s,i+l,l);else e.lineTo(o+s,i);if(e.lineTo(o+s,i+a-(d?l:0)),d)e.arcTo(o+s,i+a,o+s-l,i+a,l);else e.lineTo(o+s,i+a);if(e.lineTo(o+(u?l:0),i+a),u)e.arcTo(o,i+a,o,i+a-l,l);else e.lineTo(o,i+a);if(e.lineTo(o,i+(c?l:0)),c)e.arcTo(o,i,o+l,i,l);else e.lineTo(o,i);e.closePath()}var gt=Math.PI*2;class te extends A{hasCartesianAxis(){return!1}getLegendItems(){return this.option.data.map((e,t)=>({name:e.name,color:e.color??this.seriesColor(t)}))}drawSeries(e,t,n){let{plot:r}=t,o=r.x+r.width/2,i=r.y+r.height/2,s=Math.min(r.width,r.height)/2,a=He(n.radius??"60%",s),l=He(n.innerRadius??0,s),c=n.startAngle??-Math.PI/2,p=n.data.filter((h)=>h.value>0),u=p.reduce((h,m)=>h+m.value,0);if(u<=0||a<=0)return;let d=c;p.forEach((h,m)=>{let R=h.value/u*gt,g=h.color??this.seriesColor(m);if(e.save(),e.fillStyle=g,e.beginPath(),l>0)e.arc(o,i,a,d,d+R),e.arc(o,i,l,d+R,d,!0);else e.arc(o,i,a,d,d+R),e.lineTo(o,i);if(e.closePath(),e.fill(),e.strokeStyle="#ffffff",e.lineWidth=1,e.stroke(),e.restore(),n.showLabel!==!1){let y=d+R/2,C=(a+(l>0?l:0))/2*0.85,v=o+Math.cos(y)*C,k=i+Math.sin(y)*C,w=u>0?Math.round(h.value/u*100):0;P(e,n.labelFontSize??10),e.fillStyle=n.labelColor??"#ffffff",e.textAlign="center",e.textBaseline="middle",e.fillText(`${h.name} ${w}%`,v,k)}d+=R})}}function He(e,t){if(typeof e==="number")return Math.max(0,e);let n=/^(\d+(?:\.\d+)?)%$/.exec(e);if(!n)return t;return Number(n[1])/100*t}class ne extends A{hasCartesianAxis(){return!1}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let{plot:r}=t,o=r.x+r.width/2,i=r.y+r.height/2,s=n.radius??Math.min(r.width,r.height)/2*0.6,a=n.indicators.length;if(a===0||s<=0)return;let l=n.startAngle??-Math.PI/2,c=yt/a,p=Math.max(1,n.splitCount??5),u=n.gridColor??"#ebedf0",d=n.gridLineWidth??1,h=(g)=>l+g*c,m=(g,y)=>({x:o+Math.cos(g)*y,y:i+Math.sin(g)*y});for(let g=1;g<=p;g+=1){let y=s*g/p;e.save(),e.strokeStyle=u,e.lineWidth=d,e.beginPath();for(let C=0;C<a;C+=1){let v=m(h(C),y);if(C===0)e.moveTo(v.x,v.y);else e.lineTo(v.x,v.y)}e.closePath(),e.stroke(),e.restore()}e.save(),e.strokeStyle=u,e.lineWidth=d,e.beginPath();for(let g=0;g<a;g+=1){let y=m(h(g),s);e.moveTo(o,i),e.lineTo(y.x,y.y)}e.stroke(),e.restore();let R=n.labelFontSize??11;P(e,R),e.fillStyle=n.labelColor??"#323233";for(let g=0;g<a;g+=1){let y=m(h(g),s+12);e.textAlign=Math.abs(y.x-o)<1?"center":y.x>o?"left":"right",e.textBaseline=Math.abs(y.y-i)<1?"middle":y.y>i?"top":"bottom",e.fillText(n.indicators[g].name,y.x,y.y)}n.series.forEach((g,y)=>{let C=this.seriesColor(y,g.color),v=n.indicators.map((k,w)=>{let b=k.max??this.indicatorMax(n,w),T=g.data[w]??0,F=b>0?Math.max(0,Math.min(1,T/b)):0;return m(h(w),s*F)});if(g.area!==!1)e.save(),e.fillStyle=C,e.globalAlpha=0.2,e.beginPath(),this.tracePolygon(e,v),e.closePath(),e.fill(),e.restore();e.save(),e.strokeStyle=C,e.lineWidth=g.lineWidth??2,e.lineJoin="round",e.beginPath(),this.tracePolygon(e,v),e.closePath(),e.stroke(),e.restore()})}indicatorMax(e,t){let n=0;for(let r of e.series){let o=r.data[t]??0;if(o>n)n=o}return n}tracePolygon(e,t){if(t.length===0)return;e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n+=1)e.lineTo(t[n].x,t[n].y)}}var yt=Math.PI*2;function q(){let e=bt();if(typeof e.devicePixelRatio==="number"&&e.devicePixelRatio>0)return e.devicePixelRatio;return 1}function bt(){if(typeof globalThis<"u")return globalThis;return{}}function D(e){let n=vt()[e];return typeof n==="object"&&n!==null?n:null}function re(e){let t=e.platform??oe()??"wx",n=D(t),r=n?.createSelectorQuery;if(typeof r!=="function")return Promise.reject(Error(`getMiniProgramCanvasNode: ${t}.createSelectorQuery is not available`));return new Promise((o,i)=>{let s=r.call(n);if(e.instance&&typeof s.in==="function")s=s.in(e.instance);if(typeof s.select!=="function"){i(Error(`${t}.createSelectorQuery().select is not available`));return}s.select(e.selector).fields({node:!0,size:!0}).exec((a)=>{let c=(Array.isArray(a)?a[0]:void 0)?.node;if(!c||typeof c.getContext!=="function"){i(Error(`getMiniProgramCanvasNode: canvas node not found for "${e.selector}"`));return}o(c)})})}function oe(){if(D("wx"))return"wx";if(D("my"))return"my";if(D("tt"))return"tt";return null}function Ce(e){let t=e??oe()??"wx",n=D(t),r=n?.getSystemInfoSync;if(typeof r==="function")try{let o=r.call(n);if(typeof o.pixelRatio==="number"&&o.pixelRatio>0)return o.pixelRatio}catch{}return q()}function B(e,t={}){let n=e.getContext("2d");if(!n)throw Error("resolveMiniProgramCanvas: 2d context is not available");let r=t.dpr??Ce(),o=t.width??e.width,i=t.height??e.height;return{ctx:n,width:o,height:i,dpr:r,palette:t.palette}}function vt(){if(typeof globalThis<"u")return globalThis;return{}}function j(e,t={}){if(!e)throw Error("resolveWebCanvas: canvas element is required");let n=e.getContext("2d");if(!n)throw Error("resolveWebCanvas: 2d context is not available");let r=t.dpr??q(),o=t.width??(e.clientWidth||e.width),i=t.height??(e.clientHeight||e.height);return e.width=Math.round(o*r),e.height=Math.round(i*r),{ctx:n,width:o,height:i,dpr:r,palette:t.palette}}function U(e,t){switch(t.type){case"line":return new Z(e,t);case"bar":return new ee(e,t);case"pie":return new te(e,t);case"radar":return new ne(e,t);default:throw Error(`createChart: unsupported chart type "${t.type}"`)}}function Ct(e,t,n={}){return U(j(e,n),t)}function Rt(e,t,n={}){return U(B(e,n),t)}function qe(e){throw Error("resolveNativeCanvas is not implemented yet. Native app support (iOS/Android/HarmonyOS) is planned for a future phase; implement ICanvas2D on the host side and fill in this resolver.")}function M(e){if(e===void 0||e===null)return[];return Array.isArray(e)?e:[e]}function Be(e){return typeof e==="object"&&e!==null&&"component"in e}function je(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag!=="slot"}function _e(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag==="slot"}function Fe(e,t,n,r,o,i){return{tag:e,props:t,children:n,listeners:r,key:o,directions:i}}function xt(e,t={}){return{tag:e,...t}}function f(e){return(t={})=>xt(e,t)}var Tt=f("div"),$n=f("span"),zn=f("p"),Un=f("button"),Gn=f("input"),Kn=f("section"),Xn=f("main"),Yn=f("header"),Qn=f("footer"),Jn=f("nav"),Zn=f("article"),er=f("aside"),tr=f("h1"),nr=f("h2"),rr=f("h3"),or=f("h4"),ir=f("h5"),sr=f("h6"),ar=f("strong"),lr=f("em"),ur=f("small"),pr=f("pre"),cr=f("code"),dr=f("blockquote"),hr=f("ul"),mr=f("ol"),fr=f("li"),gr=f("a"),yr=f("img"),br=f("form"),vr=f("label"),Cr=f("textarea"),Rr=f("select"),xr=f("option"),Tr=f("table"),wr=f("thead"),Er=f("tbody"),Sr=f("tr"),Pr=f("th"),Lr=f("td");var H=Symbol("is_reactive"),E=Symbol("is_readonly"),wt=Symbol("is_ref"),Ve=["push","pop","shift","unshift","splice","sort","reverse"];function S(e,t){return Boolean(Reflect.get(e,t))}function I(e){return e!==null&&typeof e==="object"}class Re{pending=new Set;flushing=!1;flushPromise=null;flushResolve=null;enqueue(e){if(this.pending.has(e))return;if(this.pending.add(e),!this.flushing)queueMicrotask(()=>this.flush())}flush(){if(this.flushing)return;this.flushing=!0;try{while(this.pending.size>0){let e=Array.from(this.pending);this.pending.clear();for(let t of e)if(t.active)t()}}finally{this.flushing=!1;let e=this.flushResolve;this.flushResolve=null,this.flushPromise=null,e?.()}}nextTick(){if(!this.flushing&&this.pending.size===0)return Promise.resolve();if(this.flushPromise)return this.flushPromise;return this.flushPromise=new Promise((e)=>{this.flushResolve=e}),this.flushPromise}}var Et=0,xe=new Re;class L{static instance;activeEffect=null;effectStack=[];targetMap=new WeakMap;reactiveMap=new WeakMap;readonlyMap=new WeakMap;proxyMap=new WeakMap;constructor(){}static getInstance(){if(!L.instance)L.instance=new L;return L.instance}reactive(e){if(!I(e))return console.warn("reactive: target must be an object"),e;if(St(e))return e;if(this.reactiveMap.has(e))return this.reactiveMap.get(e);if(Array.isArray(e))return this.createReactiveArray(e);let t=new Proxy(e,{get:(n,r)=>{if(r===H)return!0;if(r===E)return!1;this.track(n,r);let o=Reflect.get(n,r);if(I(o)&&!S(o,E))return this.reactive(o);return o},set:(n,r,o)=>{if(S(n,E))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(I(o)&&!S(o,H)&&!S(o,E))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o)this.trigger(n,r);return s},deleteProperty:(n,r)=>{if(S(n,E))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r);return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}toRawValue(e){if(I(e)&&this.proxyMap.has(e))return this.proxyMap.get(e);return e}createReactiveArray(e){if(this.reactiveMap.has(e))return this.reactiveMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===H)return!0;if(r===E)return!1;this.track(n,r);let o=Reflect.get(n,r);if(typeof r==="string"&&(r==="includes"||r==="indexOf"||r==="lastIndexOf")){this.track(n,"length");for(let s=0;s<n.length;s++)this.track(n,String(s));let i=o;return(...s)=>{let a=i.apply(n,s);if(a===!1||a===-1){let l=n.map((p)=>this.toRawValue(p));return l[r].apply(l,s.map((p)=>this.toRawValue(p)))}return a}}if(typeof r==="string"&&Ve.includes(r))return(...i)=>{let a=o.apply(n,i);return this.trigger(n,"length"),this.trigger(n,r),a};if(I(o)&&!S(o,E))return this.reactive(o);return o},set:(n,r,o)=>{if(S(n,E))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(I(o)&&!S(o,H)&&!S(o,E))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o){if(this.trigger(n,r),typeof r==="string"&&!isNaN(Number(r)))this.trigger(n,"length")}return s},deleteProperty:(n,r)=>{if(S(n,E))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r),this.trigger(n,"length");return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}readonly(e){if(!I(e))return console.warn("readonly: target must be an object"),e;if(S(e,E))return e;if(this.readonlyMap.has(e))return this.readonlyMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===H)return!1;if(r===E)return!0;let o=Reflect.get(n,r);if(I(o))return this.readonly(o);return o},set:()=>(console.warn("Cannot set property on readonly object"),!1),deleteProperty:()=>(console.warn("Cannot delete property on readonly object"),!1)});return this.readonlyMap.set(e,t),t}effect(e,t){let{lazy:n=!1,scheduler:r,throwOnError:o=!1}=t||{},i=()=>{if(!i.active)return e();try{return this.cleanup(i),this.effectStack.push(i),this.activeEffect=i,e()}catch(s){if(o)throw s;console.error("Effect error:",s);return}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}};if(i.id=Et++,i.deps=[],i.active=!0,i.scheduler=r,!n)i();return i}runWithEffect(e,t){this.effectStack.push(e),this.activeEffect=e;try{return t()}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}}computed(e){let t=!0,n,r={},o=()=>{this.track(r,"value")},i=this.effect(()=>{n=e(),t=!1},{lazy:!0,scheduler:()=>{if(!t)t=!0,this.trigger(r,"value")}});return{get value(){if(t)i();return o(),n}}}cleanup(e){e.deps.forEach((t)=>{t.delete(e)}),e.deps.length=0}track(e,t){if(!this.activeEffect||!this.activeEffect.active)return;let n=this.targetMap.get(e);if(!n)n=new Map,this.targetMap.set(e,n);let r=n.get(t);if(!r)r=new Set,n.set(t,r);if(!r.has(this.activeEffect))r.add(this.activeEffect),this.activeEffect.deps.push(r)}trigger(e,t){let n=this.targetMap.get(e);if(!n)return;let r=n.get(t);if(!r)return;new Set(r).forEach((i)=>{if(i.active)if(i.scheduler)i.scheduler(i);else i()})}stop(e){if(e.active)this.cleanup(e),e.active=!1}}function We(e){return L.getInstance().reactive(e)}function N(e,t){return L.getInstance().effect(e,t)}function O(e){L.getInstance().stop(e)}function St(e){return I(e)&&S(e,H)}function $e(e){let t=e.split(".");if(e.length===0||t.some((n)=>n.length===0||n==="__proto__"||n==="prototype"||n==="constructor"))throw Error(`Invalid model path "${e}"`);return t}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ze(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Pt(e){return typeof e==="string"?e:e.path}function Ee(e,t){let n=e;for(let r of $e(t)){if(!we(n))throw Error(`Invalid model path "${t}"`);if(!ze(n,r)){if(r in n)throw Error(`Invalid model path "${t}"`);return}n=n[r]}return n}function Lt(e,t,n){let r=$e(t),o=e;for(let s of r.slice(0,-1)){if(!ze(o,s)){if(s in o)throw Error(`Invalid model path "${t}"`);o[s]={}}else if(!we(o[s]))throw Error(`Invalid model path "${t}"`);let a=o[s];if(!we(a))throw Error(`Invalid model path "${t}"`);o=a}let i=r[r.length-1];o[i]=n}function Te(e,t){if(typeof e!=="string"&&e.format)return e.format(t);return t===void 0||t===null?"":String(t)}function At(e,t){if(typeof e!=="string"&&e.parse)return e.parse(t);return t}function Mt(e,t,n){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){e.checked=Array.isArray(n)?n.some((r)=>String(r)===e.value):Boolean(n);return}if(e.type==="radio"){e.checked=n===e.value;return}e.value=Te(t,n);return}if(e instanceof HTMLTextAreaElement){e.value=Te(t,n);return}if(e instanceof HTMLSelectElement){if(e.multiple){let r=Array.isArray(n)?new Set(n.map(String)):new Set;for(let o=0;o<e.options.length;o+=1){let i=e.options.item(o);if(!i)continue;i.selected=r.has(i.value)}return}e.value=Te(t,n)}}function It(e,t){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){if(Array.isArray(t)){let n=t.filter((r)=>String(r)!==e.value);return e.checked?[...n,e.value]:n}return e.checked}if(e.type==="radio")return e.checked?e.value:t;return e.value}if(e instanceof HTMLTextAreaElement)return e.value;if(e instanceof HTMLSelectElement){if(!e.multiple)return e.value;let n=[];for(let r=0;r<e.selectedOptions.length;r+=1){let o=e.selectedOptions.item(r);if(o)n.push(o.value)}return n}return}class Se{bindings=new WeakMap;bind(e,t,n){if(!this.isSupportedControl(e))return;let r=this.bindings.get(e);if(r&&this.sameBinding(r,t))return;this.cleanup(e);let o=Pt(t),i=()=>Mt(e,t,Ee(n,o)),s=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["checkbox","radio"].includes(e.type)?"input":"change",a=()=>{let c=Ee(n,o);Lt(n,o,At(t,It(e,c)))};e.addEventListener(s,a);let l=N(i);this.bindings.set(e,{binding:t,path:o,parse:typeof t==="string"?void 0:t.parse,format:typeof t==="string"?void 0:t.format,eventName:s,listener:a,effect:l})}cleanup(e){let t=this.bindings.get(e);if(!t)return;e.removeEventListener(t.eventName,t.listener),O(t.effect),this.bindings.delete(e)}isSupportedControl(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}sameBinding(e,t){if(typeof e.binding==="string"||typeof t==="string")return e.binding===t;return e.path===t.path&&e.parse===t.parse&&e.format===t.format}}var Ue=":root{--tu-rpx:calc(min(100vw, 750px) / 750);}",kt=/(-?\d+(?:\.\d+)?)rpx/g;function ie(e){return String(e).replace(kt,(t,n)=>`calc(${n} * var(--tu-rpx))`)}function se(e){return/^on[A-Z]/.test(e)||/^on[a-z]/.test(e)}function Ge(e){return e.slice(2).toLowerCase()}function Ke(e){let[t,...n]=e.split(".");return{eventName:t,modifiers:new Set(n)}}function Xe(e,t){let n=(r)=>{if(t.has("stop"))r.stopPropagation();if(t.has("prevent"))r.preventDefault();if(t.has("self")&&r.currentTarget!==r.target)return;if(t.has("once"))r.currentTarget.removeEventListener(r.type,n);e(r)};return n}function Ye(e,t,n){let r=t.includes("-")?t:t.replace(/[A-Z]/g,(o)=>`-${o.toLowerCase()}`);e.setProperty(r,ie(n))}class Pe{styleElement=null;styles=new Map;constructor(){}addStyle(e,t){this.styles.set(e,t),this.updateStyles()}removeStyle(e){this.styles.delete(e),this.updateStyles()}clearStyles(){if(this.styles.clear(),this.styleElement)this.styleElement.textContent=""}destroy(){if(this.clearStyles(),this.styleElement)this.styleElement.remove(),this.styleElement=null}ensureStyleElement(){if(!this.styleElement){let e=document.createElement("style");document.head.appendChild(e),this.styleElement=e}return this.styleElement}convertToCSS(e){return Object.entries(e).map(([t,n])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${ie(n)};`).join(`
2
- `)}updateStyles(){if(this.styles.size===0){if(this.styleElement)this.styleElement.textContent="";return}let e=this.ensureStyleElement(),t=Ue+`
1
+ var Be=["#1677ff","#00b578","#ff8f1f","#ff3141","#eb2f96","#722ed1","#13c2c2","#faad14","#2f54eb","#a0d911"],W="#323233",je="#c8c9cc",ge="#ebedf0",Z="-apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif";function mt(e){return typeof e==="object"&&e!==null&&typeof e.save==="function"&&typeof e.beginPath==="function"&&typeof e.fill==="function"&&typeof e.stroke==="function"&&typeof e.fillText==="function"}function _e(e,t,n=5){let r=e,o=t;if(!Number.isFinite(r)||!Number.isFinite(o))throw Error("niceTicks: domain must be finite numbers");if(r===o){let u=Math.abs(r)>1?Math.abs(r)*0.1:1;r-=u,o+=u}if(r>o)[r,o]=[o,r];let s=(o-r)/Math.max(1,n),a=gt(s),l=Math.floor(r/a)*a,c=Math.ceil(o/a)*a,p=[];for(let u=l;u<=c+a*0.000000001;u+=a)p.push(yt(u,a));return{min:l,max:c,step:a,ticks:p}}function gt(e){let t=Math.pow(10,Math.floor(Math.log10(e))),n=e/t,r;if(n<=1)r=1;else if(n<=2)r=2;else if(n<=5)r=5;else r=10;return r*t}function yt(e,t){let n=Math.max(0,-Math.floor(Math.log10(t))+1);return Number(e.toFixed(n))}class U{min;max;ticks;step;rangeStart;rangeEnd;constructor(e,t,n,r,o={}){let{min:i,max:s,splitCount:a=5}=o,l=i,c=s;if(l===void 0||c===void 0){let p=_e(e,t,a);l=l??p.min,c=c??p.max,this.ticks=p.ticks,this.step=p.step}else{this.step=(c-l)/Math.max(1,a),this.ticks=[];for(let p=0;p<=a;p+=1)this.ticks.push(l+p*this.step)}this.min=l,this.max=c,this.rangeStart=n,this.rangeEnd=r}scale(e){let t=(e-this.min)/(this.max-this.min);return this.rangeStart+t*(this.rangeEnd-this.rangeStart)}}class ee{categories;bandWidth;innerGapRatio;rangeStart;constructor(e,t,n,r=0.35){this.categories=e;this.innerGapRatio=r,this.rangeStart=t;let o=Math.max(1,e.length);this.bandWidth=(n-t)/o}bandStart(e){return this.rangeStart+this.bandWidth*e}center(e){return this.bandStart(e)+this.bandWidth/2}innerWidth(){return this.bandWidth*(1-this.innerGapRatio)}groupInnerWidth(e){return this.innerWidth()/Math.max(1,e)*0.8}}var bt={top:12,right:16,bottom:12,left:16};function vt(e,t){let{legend:n}=e,r=e.legendItems??[],o=n?.fontSize??12,i=n?.itemGap??16,s=n?.markerSize??12;if(n?.position==="right"){let l=0;for(let c of r){let p=s+6+t(c);if(p>l)l=p}return{width:l+12,height:Math.max(r.length*(o+8)+12,0)}}let a=0;for(let l of r)a+=s+6+t(l)+i;if(a>0)a-=i;return{width:a,height:o+12+4}}function ye(e,t){let n={...bt,...e.basePadding},r=n.top,o=n.bottom,i=n.left,s=n.right,a=null;if(e.title?.text){let b=e.title.fontSize??16;a={x:0,y:0,width:e.width,height:b},r+=b+(e.title.padding??16)}let l=null,c=e.legend;if(c&&c.show!==!1&&(e.legendItems?.length??0)>0){let b=vt(e,t),R=c.position??"top";if(R==="top")l={x:0,y:a?a.height:0,width:e.width,height:b.height},r+=b.height;else if(R==="bottom")l={x:0,y:e.height-b.height,width:e.width,height:b.height},o+=b.height;else l={x:e.width-b.width,y:r,width:b.width,height:Math.max(0,e.height-r-o)},s+=b.width}let p=11,u=0,d=0,h=0,f=0,x=e.valueLabels??[],g=e.categoryLabels??[];if(e.horizontal){if(g.length>0){for(let b of g){let R=t(b);if(R>f)f=R}f+=16,i+=f}if(x.length>0)h=p+16,o+=h}else{if(x.length>0){for(let b of x){let R=t(b);if(R>u)u=R}u+=16,i+=u}if(g.length>0)d=p+16,o+=d}let y=Math.max(0,e.width-i-s),C=Math.max(0,e.height-r-o),v={x:i,y:r,width:y,height:C},L=e.horizontal?{x:v.x,y:v.y+v.height,width:y,height:h}:{x:v.x-u,y:r,width:u,height:C},w=e.horizontal?{x:v.x-f,y:r,width:f,height:C}:{x:i,y:v.y+C,width:y,height:d};return{plot:v,valueAxisBox:L,categoryAxisBox:w,titleBox:a,legendBox:l,padding:n}}function be(e,t){let n=null,r=null;return{run(...o){if(r=o,n!==null)clearTimeout(n);n=setTimeout(()=>{if(n=null,r!==null){let i=r;r=null,e(...i)}},t)},cancel(){if(n!==null)clearTimeout(n),n=null;r=null},pending(){return n!==null}}}function Ct(e,t=Z){return`${e}px ${t}`}function E(e,t,n=Z){let r=Ct(t,n);return e.font=r,r}function G(e,t,n,r=Z){return E(e,n,r),e.measureText(t).width}class ve{ctx;constructor(e){this.ctx=e}drawValueAxis(e){let{plot:t,scale:n,labels:r,horizontal:o=!1,labelFontSize:i=11,labelColor:s=W,gridColor:a=ge,gridLineWidth:l=1,gridLineDash:c,showGrid:p=!0}=e,u=n.ticks,{ctx:d}=this;for(let h=0;h<u.length;h+=1){let f=n.scale(u[h]),x=r[h]??String(u[h]);if(p){if(d.save(),d.strokeStyle=a,d.lineWidth=l,c&&c.length>0)d.setLineDash(c);if(d.beginPath(),o)d.moveTo(t.x,f),d.lineTo(t.x+t.width,f);else d.moveTo(t.x,f),d.lineTo(t.x+t.width,f);d.stroke(),d.restore()}if(E(d,i),d.fillStyle=s,d.textBaseline="middle",o)d.textAlign="center",d.fillText(x,f,t.y+t.height+8);else d.textAlign="right",d.fillText(x,t.x-8,f)}}drawCategoryAxis(e){let{plot:t,scale:n,labels:r,horizontal:o=!1,axisColor:i=je,labelFontSize:s=11,labelColor:a=W,gridColor:l=ge,gridLineWidth:c=1,showGrid:p=!1}=e,{ctx:u}=this,d=r.length;if(p){u.save(),u.strokeStyle=l,u.lineWidth=c,u.beginPath();for(let h=0;h<d;h+=1){let f=n.center(h);if(o)u.moveTo(t.x,f),u.lineTo(t.x+t.width,f);else u.moveTo(f,t.y),u.lineTo(f,t.y+t.height)}u.stroke(),u.restore()}E(u,s),u.fillStyle=a,u.textBaseline="middle";for(let h=0;h<d;h+=1){let f=n.center(h);if(o)u.textAlign="right",u.fillText(r[h],t.x-8,f);else u.textAlign="center",u.fillText(r[h],f,t.y+t.height+8)}if(u.save(),u.strokeStyle=i,u.lineWidth=1,u.beginPath(),o)u.moveTo(t.x,t.y),u.lineTo(t.x,t.y+t.height);else u.moveTo(t.x,t.y+t.height),u.lineTo(t.x+t.width,t.y+t.height);u.stroke(),u.restore()}}class Ce{ctx;constructor(e){this.ctx=e}draw(e){let{box:t,items:n,position:r="top",fontSize:o=12,color:i=W,markerSize:s=12,itemGap:a=16}=e;if(n.length===0)return;let{ctx:l}=this;if(E(l,o),r==="right"){let d=t.y+o/2+4;for(let h of n)this.drawItem(h,t.x,d,o,s,i),d+=o+8;return}let c=0;for(let d of n)c+=s+6+G(l,d.name,o)+a;c-=a;let p=t.x+(t.width-c)/2,u=t.y+t.height/2;for(let d of n)this.drawItem(d,p,u,o,s,i),p+=s+6+G(l,d.name,o)+a}drawItem(e,t,n,r,o,i){let{ctx:s}=this;s.fillStyle=e.color,s.beginPath(),s.rect(t,n-o/2,o,o),s.fill(),s.fillStyle=i,s.textAlign="left",s.textBaseline="middle",s.fillText(e.name,t+o+6,n)}}class M{ctx;option;width;height;dpr;palette;cartesian=null;destroyed=!1;constructor(e,t){this.ctx=e.ctx,this.option=t,this.width=e.width,this.height=e.height,this.dpr=e.dpr,this.palette=e.palette??Be}setOption(e){return this.option={...this.option,...e},this}resize(e,t,n){if(this.width=Math.max(0,e),this.height=Math.max(0,t),n!==void 0&&Number.isFinite(n)&&n>0)this.dpr=n;return this}render(){if(this.destroyed)return this;let{ctx:e,width:t,height:n,dpr:r}=this;e.save(),e.scale(r,r),e.clearRect(0,0,t,n);let o=this.getBackgroundColor();if(o)e.fillStyle=o,e.fillRect(0,0,t,n);let i=this.computeLayout();if(this.drawTitle(i),this.drawLegend(i),this.hasCartesianAxis())this.cartesian=this.buildCartesianScales(i),this.drawCartesianAxis(i);else this.cartesian=null;return this.drawSeries(e,i,this.option),e.restore(),this}destroy(){this.destroyed=!0}isDestroyed(){return this.destroyed}hasCartesianAxis(){return!0}getValueDomain(){return{min:0,max:1}}getCategoryLabels(){return[]}isHorizontal(){return!1}getBackgroundColor(){return this.option.backgroundColor}getTitle(){return this.option.title}getLegend(){let e=this.option.legend;if(e)return e;return this.getLegendItems().length>0?{position:"top"}:void 0}getLegendItems(){return[]}getValueAxis(){return this.option.yAxis}getCategoryAxis(){return this.option.xAxis}computeLayout(){let e=this.buildLayoutInput();return ye(e,(n)=>G(this.ctx,n,11))}buildLayoutInput(){let e=this.isHorizontal(),t=this.hasCartesianAxis();return{width:this.width,height:this.height,title:this.getTitle(),legend:this.getLegend(),legendItems:this.getLegendItems().map((n)=>n.name),valueLabels:t&&!e?this.computeValueLabels():void 0,categoryLabels:t?this.getCategoryLabels():void 0,horizontal:e}}computeValueLabels(){let e=this.getValueDomain(),t=this.getValueAxis();return new U(e.min,e.max,0,1,{min:t?.min,max:t?.max,splitCount:t?.splitCount}).ticks.map((r)=>t?.format?t.format(r):String(r))}drawTitle(e){let t=this.getTitle();if(!t?.text||!e.titleBox)return;let{ctx:n}=this;E(n,t.fontSize??16),n.fillStyle=t.color??"#323233",n.textAlign="center",n.textBaseline="top",n.fillText(t.text,this.width/2,e.titleBox.y)}drawLegend(e){let t=this.getLegend();if(t?.show===!1||!e.legendBox)return;let n=this.getLegendItems();if(n.length===0)return;new Ce(this.ctx).draw({box:e.legendBox,items:n,position:t?.position??"top",fontSize:t?.fontSize,color:t?.color,markerSize:t?.markerSize,itemGap:t?.itemGap})}buildCartesianScales(e){let{plot:t}=e,n=this.isHorizontal(),r=this.getValueDomain(),o=this.getCategoryLabels(),i=this.getValueAxis(),s=new U(r.min,r.max,n?t.x:t.y+t.height,n?t.x+t.width:t.y,{min:i?.min,max:i?.max,splitCount:i?.splitCount}),a=new ee(o,n?t.y:t.x,n?t.y+t.height:t.x+t.width);return{value:s,category:a}}drawCartesianAxis(e){let t=this.cartesian;if(!t)return;let{ctx:n}=this,{plot:r}=e,o=this.isHorizontal(),i=this.getValueAxis(),s=this.getCategoryAxis(),a=this.getCategoryLabels(),l=new ve(n),c=t.value.ticks.map((p)=>i?.format?i.format(p):String(p));l.drawValueAxis({plot:r,scale:t.value,labels:c,horizontal:o,labelFontSize:i?.labelFontSize,labelColor:i?.labelColor,gridColor:i?.gridColor,gridLineWidth:i?.gridLineWidth,gridLineDash:i?.gridLineDash,showGrid:i?.showGrid??!0}),l.drawCategoryAxis({plot:r,scale:t.category,labels:a,horizontal:o,labelFontSize:s?.labelFontSize,labelColor:s?.labelColor,gridColor:s?.gridColor,gridLineWidth:s?.gridLineWidth,showGrid:s?.showGrid??!1})}seriesColor(e,t){return t??this.palette[e%this.palette.length]}}class te extends M{getValueDomain(){let{series:e,yAxis:t,startFromZero:n=!1}=this.option,r=1/0,o=-1/0;for(let i of e)for(let s of i.data){if(s<r)r=s;if(s>o)o=s}if(!Number.isFinite(r)||!Number.isFinite(o))return{min:0,max:1};if(n&&r>0)r=0;if(t?.min!==void 0)r=Math.min(r,t.min);if(t?.max!==void 0)o=Math.max(o,t.max);return{min:r,max:o}}getCategoryLabels(){return this.option.xAxis.labels}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let r=this.cartesian;if(!r)return;let{plot:o}=t,{value:i,category:s}=r,a=n.series.map((l)=>l.data.map((c,p)=>({x:s.center(p),y:i.scale(c)})));n.series.forEach((l,c)=>{let p=a[c];if(p.length===0)return;let u=this.seriesColor(c,l.color),d=l.lineWidth??2;if(l.area)e.save(),e.fillStyle=u,e.globalAlpha=0.15,e.beginPath(),this.tracePath(e,p,l.smooth??!1),e.lineTo(p[p.length-1].x,o.y+o.height),e.lineTo(p[0].x,o.y+o.height),e.closePath(),e.fill(),e.restore();if(e.save(),e.strokeStyle=u,e.lineWidth=d,e.lineJoin="round",e.lineCap="round",e.beginPath(),this.tracePath(e,p,l.smooth??!1),e.stroke(),e.restore(),l.showSymbol!==!1){e.save(),e.fillStyle=u;for(let h of p)e.beginPath(),e.arc(h.x,h.y,Math.max(2.5,d+0.5),0,Math.PI*2),e.fill();e.restore()}})}tracePath(e,t,n){if(t.length===0)return;if(e.moveTo(t[0].x,t[0].y),!n||t.length<3){for(let r=1;r<t.length;r+=1)e.lineTo(t[r].x,t[r].y);return}for(let r=0;r<t.length-1;r+=1){let o=t[Math.max(0,r-1)],i=t[r],s=t[r+1],a=t[Math.min(t.length-1,r+2)],l=i.x+(s.x-o.x)/6,c=i.y+(s.y-o.y)/6,p=s.x-(a.x-i.x)/6,u=s.y-(a.y-i.y)/6;e.bezierCurveTo(l,c,p,u,s.x,s.y)}}}class ne extends M{isHorizontal(){return this.option.horizontal??!1}getValueDomain(){let{series:e,yAxis:t}=this.option,n=0,r=0,o=ze(e),i=Math.max(0,...e.map((s)=>s.data.length));for(let s=0;s<i;s+=1)for(let a of o){let l=0,c=0;for(let p of a){let u=p.data[s]??0;if(u>=0)l+=u;else c+=u}if(l>n)n=l;if(c<r)r=c}if(t?.min!==void 0)r=Math.min(r,t.min);if(t?.max!==void 0)n=Math.max(n,t.max);return{min:r,max:n}}getCategoryLabels(){return this.option.xAxis.labels}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let r=this.cartesian;if(!r)return;let{value:o,category:i}=r,s=n.horizontal??!1,a=ze(n.series),l=n.xAxis.labels.length;for(let c=0;c<l;c+=1){let p=a,u=p.length,d=n.series.map((f)=>f.barWidth).find((f)=>f!==void 0&&f>0),h=this.computeSlot(i,u,d);p.forEach((f,x)=>{let g=h.offset+x*h.size,y=0;f.forEach((C)=>{let v=C.data[c]??0,L=this.seriesColor(n.series.indexOf(C),C.color);if(s){let w=o.scale(0),b=o.scale(y+v),R=Math.min(w,b),q=Math.abs(b-w),V=i.bandStart(c)+g;this.drawBar(e,{x:R,y:V,width:q,height:h.size,radius:C.borderRadius??0,color:L,roundSide:v>=0?"right":"left"})}else{let w=o.scale(y),b=o.scale(y+v),R=Math.min(w,b),q=Math.abs(b-w),V=i.bandStart(c)+g;this.drawBar(e,{x:V,y:R,width:h.size,height:q,radius:C.borderRadius??0,color:L,roundSide:v>=0?"top":"bottom"})}y+=v})})}}computeSlot(e,t,n){let r=e.bandWidth,o=e.innerWidth();if(n!==void 0)return{offset:(r-n*t)/2,size:n};let i=o/Math.max(1,t)*0.8,s=(r-o)/2,a=(o-i*t)/2;return{offset:s+a,size:i}}drawBar(e,t){if(t.width<=0||t.height<=0)return;e.save(),e.fillStyle=t.color,e.beginPath(),Rt(e,t,t.radius,t.roundSide),e.fill(),e.restore()}}function ze(e){let t=[],n=new Map;for(let r of e)if(r.stack){let o=n.get(r.stack);if(!o)o=[],n.set(r.stack,o),t.push(o);o.push(r)}else t.push([r]);return t}function Rt(e,t,n,r){let{x:o,y:i,width:s,height:a}=t,l=Math.min(n,s/2,a/2);if(l<=0){e.rect(o,i,s,a);return}let c=r==="top"||r==="left",p=r==="top"||r==="right",u=r==="bottom"||r==="left",d=r==="bottom"||r==="right";if(e.moveTo(o+(c?l:0),i),e.lineTo(o+s-(p?l:0),i),p)e.arcTo(o+s,i,o+s,i+l,l);else e.lineTo(o+s,i);if(e.lineTo(o+s,i+a-(d?l:0)),d)e.arcTo(o+s,i+a,o+s-l,i+a,l);else e.lineTo(o+s,i+a);if(e.lineTo(o+(u?l:0),i+a),u)e.arcTo(o,i+a,o,i+a-l,l);else e.lineTo(o,i+a);if(e.lineTo(o,i+(c?l:0)),c)e.arcTo(o,i,o+l,i,l);else e.lineTo(o,i);e.closePath()}var xt=Math.PI*2;class re extends M{hasCartesianAxis(){return!1}getLegendItems(){return this.option.data.map((e,t)=>({name:e.name,color:e.color??this.seriesColor(t)}))}drawSeries(e,t,n){let{plot:r}=t,o=r.x+r.width/2,i=r.y+r.height/2,s=Math.min(r.width,r.height)/2,a=Fe(n.radius??"60%",s),l=Fe(n.innerRadius??0,s),c=n.startAngle??-Math.PI/2,p=n.data.filter((h)=>h.value>0),u=p.reduce((h,f)=>h+f.value,0);if(u<=0||a<=0)return;let d=c;p.forEach((h,f)=>{let x=h.value/u*xt,g=h.color??this.seriesColor(f);if(e.save(),e.fillStyle=g,e.beginPath(),l>0)e.arc(o,i,a,d,d+x),e.arc(o,i,l,d+x,d,!0);else e.arc(o,i,a,d,d+x),e.lineTo(o,i);if(e.closePath(),e.fill(),e.strokeStyle="#ffffff",e.lineWidth=1,e.stroke(),e.restore(),n.showLabel!==!1){let y=d+x/2,C=u>0?Math.round(h.value/u*100):0,v=`${h.name} ${C}%`;if(n.labelPosition==="outside"){let L=n.labelLineLength??14,w=n.labelGap??6,b=Math.cos(y),R=Math.sin(y),q=o+b*a,V=i+R*a,Oe=o+b*(a+L),Ne=i+R*(a+L),De=b>=0?1:-1,He=Oe+De*w,qe=Ne;e.save(),e.strokeStyle=n.labelLineColor??"#c0c4cc",e.lineWidth=1,e.beginPath(),e.moveTo(q,V),e.lineTo(Oe,Ne),e.lineTo(He,qe),e.stroke(),e.restore(),E(e,n.labelFontSize??10),e.fillStyle=n.labelColor??"#323233",e.textAlign=De>0?"left":"right",e.textBaseline="middle",e.fillText(v,He,qe)}else{let L=(a+(l>0?l:0))/2*0.85,w=o+Math.cos(y)*L,b=i+Math.sin(y)*L;E(e,n.labelFontSize??10),e.fillStyle=n.labelColor??"#ffffff",e.textAlign="center",e.textBaseline="middle",e.fillText(v,w,b)}}d+=x})}}function Fe(e,t){if(typeof e==="number")return Math.max(0,e);let n=/^(\d+(?:\.\d+)?)%$/.exec(e);if(!n)return t;return Number(n[1])/100*t}class oe extends M{hasCartesianAxis(){return!1}getLegendItems(){return this.option.series.filter((e)=>e.name).map((e,t)=>({name:e.name,color:this.seriesColor(t,e.color)}))}drawSeries(e,t,n){let{plot:r}=t,o=r.x+r.width/2,i=r.y+r.height/2,s=n.radius??Math.min(r.width,r.height)/2*0.6,a=n.indicators.length;if(a===0||s<=0)return;let l=n.startAngle??-Math.PI/2,c=Tt/a,p=Math.max(1,n.splitCount??5),u=n.gridColor??"#ebedf0",d=n.gridLineWidth??1,h=(g)=>l+g*c,f=(g,y)=>({x:o+Math.cos(g)*y,y:i+Math.sin(g)*y});for(let g=1;g<=p;g+=1){let y=s*g/p;e.save(),e.strokeStyle=u,e.lineWidth=d,e.beginPath();for(let C=0;C<a;C+=1){let v=f(h(C),y);if(C===0)e.moveTo(v.x,v.y);else e.lineTo(v.x,v.y)}e.closePath(),e.stroke(),e.restore()}e.save(),e.strokeStyle=u,e.lineWidth=d,e.beginPath();for(let g=0;g<a;g+=1){let y=f(h(g),s);e.moveTo(o,i),e.lineTo(y.x,y.y)}e.stroke(),e.restore();let x=n.labelFontSize??11;E(e,x),e.fillStyle=n.labelColor??"#323233";for(let g=0;g<a;g+=1){let y=f(h(g),s+12);e.textAlign=Math.abs(y.x-o)<1?"center":y.x>o?"left":"right",e.textBaseline=Math.abs(y.y-i)<1?"middle":y.y>i?"top":"bottom",e.fillText(n.indicators[g].name,y.x,y.y)}n.series.forEach((g,y)=>{let C=this.seriesColor(y,g.color),v=n.indicators.map((L,w)=>{let b=L.max??this.indicatorMax(n,w),R=g.data[w]??0,q=b>0?Math.max(0,Math.min(1,R/b)):0;return f(h(w),s*q)});if(g.area!==!1)e.save(),e.fillStyle=C,e.globalAlpha=0.2,e.beginPath(),this.tracePolygon(e,v),e.closePath(),e.fill(),e.restore();e.save(),e.strokeStyle=C,e.lineWidth=g.lineWidth??2,e.lineJoin="round",e.beginPath(),this.tracePolygon(e,v),e.closePath(),e.stroke(),e.restore()})}indicatorMax(e,t){let n=0;for(let r of e.series){let o=r.data[t]??0;if(o>n)n=o}return n}tracePolygon(e,t){if(t.length===0)return;e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n+=1)e.lineTo(t[n].x,t[n].y)}}var Tt=Math.PI*2;function N(){let e=wt();if(typeof e.devicePixelRatio==="number"&&e.devicePixelRatio>0)return e.devicePixelRatio;return 1}function wt(){if(typeof globalThis<"u")return globalThis;return{}}function I(e){let n=Et()[e];return typeof n==="object"&&n!==null?n:null}function ie(e){let t=e.platform??B()??"wx",n=I(t),r=n?.createSelectorQuery;if(typeof r!=="function")return Promise.reject(Error(`getMiniProgramCanvasNode: ${t}.createSelectorQuery is not available`));return new Promise((o,i)=>{let s=r.call(n);if(e.instance&&typeof s.in==="function")s=s.in(e.instance);if(typeof s.select!=="function"){i(Error(`${t}.createSelectorQuery().select is not available`));return}s.select(e.selector).fields({node:!0,size:!0}).exec((a)=>{let c=(Array.isArray(a)?a[0]:void 0)?.node;if(!c||typeof c.getContext!=="function"){i(Error(`getMiniProgramCanvasNode: canvas node not found for "${e.selector}"`));return}o(c)})})}function B(){if(I("wx"))return"wx";if(I("my"))return"my";if(I("tt"))return"tt";return null}function Re(e){let t=e??B()??"wx",n=I(t),r=n?.getSystemInfoSync;if(typeof r==="function")try{let o=r.call(n);if(typeof o.pixelRatio==="number"&&o.pixelRatio>0)return o.pixelRatio}catch{}return N()}function _(e,t={}){let n=e.getContext("2d");if(!n)throw Error("resolveMiniProgramCanvas: 2d context is not available");let r=t.dpr??Re(),o=t.width??e.width,i=t.height??e.height;return{ctx:n,width:o,height:i,dpr:r,palette:t.palette}}function Et(){if(typeof globalThis<"u")return globalThis;return{}}function z(e,t={}){if(!e)throw Error("resolveWebCanvas: canvas element is required");let n=e.getContext("2d");if(!n)throw Error("resolveWebCanvas: 2d context is not available");let r=t.dpr??N(),o=t.width??(e.clientWidth||e.width),i=t.height??(e.clientHeight||e.height);return e.width=Math.round(o*r),e.height=Math.round(i*r),{ctx:n,width:o,height:i,dpr:r,palette:t.palette}}function K(e,t){switch(t.type){case"line":return new te(e,t);case"bar":return new ne(e,t);case"pie":return new re(e,t);case"radar":return new oe(e,t);default:throw Error(`createChart: unsupported chart type "${t.type}"`)}}function St(e,t,n={}){return K(z(e,n),t)}function Pt(e,t,n={}){return K(_(e,n),t)}function Ve(e){throw Error("resolveNativeCanvas is not implemented yet. Native app support (iOS/Android/HarmonyOS) is planned for a future phase; implement ICanvas2D on the host side and fill in this resolver.")}function k(e){if(e===void 0||e===null)return[];return Array.isArray(e)?e:[e]}function We(e){return typeof e==="object"&&e!==null&&"component"in e}function Ue(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag!=="slot"}function $e(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag==="slot"}function Ge(e,t,n,r,o,i){return{tag:e,props:t,children:n,listeners:r,key:o,directions:i}}function Lt(e,t={}){return{tag:e,...t}}function m(e){return(t={})=>Lt(e,t)}var At=m("div"),Jn=m("span"),Zn=m("p"),er=m("button"),tr=m("input"),nr=m("section"),rr=m("main"),or=m("header"),ir=m("footer"),sr=m("nav"),ar=m("article"),lr=m("aside"),ur=m("h1"),pr=m("h2"),cr=m("h3"),dr=m("h4"),hr=m("h5"),fr=m("h6"),mr=m("strong"),gr=m("em"),yr=m("small"),br=m("pre"),vr=m("code"),Cr=m("blockquote"),Rr=m("ul"),xr=m("ol"),Tr=m("li"),wr=m("a"),Er=m("img"),Sr=m("form"),Pr=m("label"),Lr=m("textarea"),Ar=m("select"),Mr=m("option"),Ir=m("table"),kr=m("thead"),Or=m("tbody"),Nr=m("tr"),Dr=m("th"),Hr=m("td");var j=Symbol("is_reactive"),S=Symbol("is_readonly"),Mt=Symbol("is_ref"),Ke=["push","pop","shift","unshift","splice","sort","reverse"];function P(e,t){return Boolean(Reflect.get(e,t))}function O(e){return e!==null&&typeof e==="object"}class xe{pending=new Set;flushing=!1;flushPromise=null;flushResolve=null;enqueue(e){if(this.pending.has(e))return;if(this.pending.add(e),!this.flushing)queueMicrotask(()=>this.flush())}flush(){if(this.flushing)return;this.flushing=!0;try{while(this.pending.size>0){let e=Array.from(this.pending);this.pending.clear();for(let t of e)if(t.active)t()}}finally{this.flushing=!1;let e=this.flushResolve;this.flushResolve=null,this.flushPromise=null,e?.()}}nextTick(){if(!this.flushing&&this.pending.size===0)return Promise.resolve();if(this.flushPromise)return this.flushPromise;return this.flushPromise=new Promise((e)=>{this.flushResolve=e}),this.flushPromise}}var It=0,Te=new xe;class A{static instance;activeEffect=null;effectStack=[];targetMap=new WeakMap;reactiveMap=new WeakMap;readonlyMap=new WeakMap;proxyMap=new WeakMap;constructor(){}static getInstance(){if(!A.instance)A.instance=new A;return A.instance}reactive(e){if(!O(e))return console.warn("reactive: target must be an object"),e;if(kt(e))return e;if(this.reactiveMap.has(e))return this.reactiveMap.get(e);if(Array.isArray(e))return this.createReactiveArray(e);let t=new Proxy(e,{get:(n,r)=>{if(r===j)return!0;if(r===S)return!1;this.track(n,r);let o=Reflect.get(n,r);if(O(o)&&!P(o,S))return this.reactive(o);return o},set:(n,r,o)=>{if(P(n,S))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(O(o)&&!P(o,j)&&!P(o,S))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o)this.trigger(n,r);return s},deleteProperty:(n,r)=>{if(P(n,S))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r);return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}toRawValue(e){if(O(e)&&this.proxyMap.has(e))return this.proxyMap.get(e);return e}createReactiveArray(e){if(this.reactiveMap.has(e))return this.reactiveMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===j)return!0;if(r===S)return!1;this.track(n,r);let o=Reflect.get(n,r);if(typeof r==="string"&&(r==="includes"||r==="indexOf"||r==="lastIndexOf")){this.track(n,"length");for(let s=0;s<n.length;s++)this.track(n,String(s));let i=o;return(...s)=>{let a=i.apply(n,s);if(a===!1||a===-1){let l=n.map((p)=>this.toRawValue(p));return l[r].apply(l,s.map((p)=>this.toRawValue(p)))}return a}}if(typeof r==="string"&&Ke.includes(r))return(...i)=>{let a=o.apply(n,i);return this.trigger(n,"length"),this.trigger(n,r),a};if(O(o)&&!P(o,S))return this.reactive(o);return o},set:(n,r,o)=>{if(P(n,S))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(O(o)&&!P(o,j)&&!P(o,S))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o){if(this.trigger(n,r),typeof r==="string"&&!isNaN(Number(r)))this.trigger(n,"length")}return s},deleteProperty:(n,r)=>{if(P(n,S))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r),this.trigger(n,"length");return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}readonly(e){if(!O(e))return console.warn("readonly: target must be an object"),e;if(P(e,S))return e;if(this.readonlyMap.has(e))return this.readonlyMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===j)return!1;if(r===S)return!0;let o=Reflect.get(n,r);if(O(o))return this.readonly(o);return o},set:()=>(console.warn("Cannot set property on readonly object"),!1),deleteProperty:()=>(console.warn("Cannot delete property on readonly object"),!1)});return this.readonlyMap.set(e,t),t}effect(e,t){let{lazy:n=!1,scheduler:r,throwOnError:o=!1}=t||{},i=()=>{if(!i.active)return e();try{return this.cleanup(i),this.effectStack.push(i),this.activeEffect=i,e()}catch(s){if(o)throw s;console.error("Effect error:",s);return}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}};if(i.id=It++,i.deps=[],i.active=!0,i.scheduler=r,!n)i();return i}runWithEffect(e,t){this.effectStack.push(e),this.activeEffect=e;try{return t()}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}}computed(e){let t=!0,n,r={},o=()=>{this.track(r,"value")},i=this.effect(()=>{n=e(),t=!1},{lazy:!0,scheduler:()=>{if(!t)t=!0,this.trigger(r,"value")}});return{get value(){if(t)i();return o(),n}}}cleanup(e){e.deps.forEach((t)=>{t.delete(e)}),e.deps.length=0}track(e,t){if(!this.activeEffect||!this.activeEffect.active)return;let n=this.targetMap.get(e);if(!n)n=new Map,this.targetMap.set(e,n);let r=n.get(t);if(!r)r=new Set,n.set(t,r);if(!r.has(this.activeEffect))r.add(this.activeEffect),this.activeEffect.deps.push(r)}trigger(e,t){let n=this.targetMap.get(e);if(!n)return;let r=n.get(t);if(!r)return;new Set(r).forEach((i)=>{if(i.active)if(i.scheduler)i.scheduler(i);else i()})}stop(e){if(e.active)this.cleanup(e),e.active=!1}}function Xe(e){return A.getInstance().reactive(e)}function D(e,t){return A.getInstance().effect(e,t)}function H(e){A.getInstance().stop(e)}function kt(e){return O(e)&&P(e,j)}function Ye(e){let t=e.split(".");if(e.length===0||t.some((n)=>n.length===0||n==="__proto__"||n==="prototype"||n==="constructor"))throw Error(`Invalid model path "${e}"`);return t}function Ee(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Qe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ot(e){return typeof e==="string"?e:e.path}function Se(e,t){let n=e;for(let r of Ye(t)){if(!Ee(n))throw Error(`Invalid model path "${t}"`);if(!Qe(n,r)){if(r in n)throw Error(`Invalid model path "${t}"`);return}n=n[r]}return n}function Nt(e,t,n){let r=Ye(t),o=e;for(let s of r.slice(0,-1)){if(!Qe(o,s)){if(s in o)throw Error(`Invalid model path "${t}"`);o[s]={}}else if(!Ee(o[s]))throw Error(`Invalid model path "${t}"`);let a=o[s];if(!Ee(a))throw Error(`Invalid model path "${t}"`);o=a}let i=r[r.length-1];o[i]=n}function we(e,t){if(typeof e!=="string"&&e.format)return e.format(t);return t===void 0||t===null?"":String(t)}function Dt(e,t){if(typeof e!=="string"&&e.parse)return e.parse(t);return t}function Ht(e,t,n){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){e.checked=Array.isArray(n)?n.some((r)=>String(r)===e.value):Boolean(n);return}if(e.type==="radio"){e.checked=n===e.value;return}e.value=we(t,n);return}if(e instanceof HTMLTextAreaElement){e.value=we(t,n);return}if(e instanceof HTMLSelectElement){if(e.multiple){let r=Array.isArray(n)?new Set(n.map(String)):new Set;for(let o=0;o<e.options.length;o+=1){let i=e.options.item(o);if(!i)continue;i.selected=r.has(i.value)}return}e.value=we(t,n)}}function qt(e,t){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){if(Array.isArray(t)){let n=t.filter((r)=>String(r)!==e.value);return e.checked?[...n,e.value]:n}return e.checked}if(e.type==="radio")return e.checked?e.value:t;return e.value}if(e instanceof HTMLTextAreaElement)return e.value;if(e instanceof HTMLSelectElement){if(!e.multiple)return e.value;let n=[];for(let r=0;r<e.selectedOptions.length;r+=1){let o=e.selectedOptions.item(r);if(o)n.push(o.value)}return n}return}class Pe{bindings=new WeakMap;bind(e,t,n){if(!this.isSupportedControl(e))return;let r=this.bindings.get(e);if(r&&this.sameBinding(r,t))return;this.cleanup(e);let o=Ot(t),i=()=>Ht(e,t,Se(n,o)),s=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["checkbox","radio"].includes(e.type)?"input":"change",a=()=>{let c=Se(n,o);Nt(n,o,Dt(t,qt(e,c)))};e.addEventListener(s,a);let l=D(i);this.bindings.set(e,{binding:t,path:o,parse:typeof t==="string"?void 0:t.parse,format:typeof t==="string"?void 0:t.format,eventName:s,listener:a,effect:l})}cleanup(e){let t=this.bindings.get(e);if(!t)return;e.removeEventListener(t.eventName,t.listener),H(t.effect),this.bindings.delete(e)}isSupportedControl(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}sameBinding(e,t){if(typeof e.binding==="string"||typeof t==="string")return e.binding===t;return e.path===t.path&&e.parse===t.parse&&e.format===t.format}}var Je=":root{--tu-rpx:calc(min(100vw, 750px) / 750);}",Bt=/(-?\d+(?:\.\d+)?)rpx/g;function se(e){return String(e).replace(Bt,(t,n)=>`calc(${n} * var(--tu-rpx))`)}function ae(e){return/^on[A-Z]/.test(e)||/^on[a-z]/.test(e)}function Ze(e){return e.slice(2).toLowerCase()}function et(e){let[t,...n]=e.split(".");return{eventName:t,modifiers:new Set(n)}}function tt(e,t){let n=(r)=>{if(t.has("stop"))r.stopPropagation();if(t.has("prevent"))r.preventDefault();if(t.has("self")&&r.currentTarget!==r.target)return;if(t.has("once"))r.currentTarget.removeEventListener(r.type,n);e(r)};return n}function nt(e,t,n){let r=t.includes("-")?t:t.replace(/[A-Z]/g,(o)=>`-${o.toLowerCase()}`);e.setProperty(r,se(n))}class Le{styleElement=null;styles=new Map;constructor(){}addStyle(e,t){this.styles.set(e,t),this.updateStyles()}removeStyle(e){this.styles.delete(e),this.updateStyles()}clearStyles(){if(this.styles.clear(),this.styleElement)this.styleElement.textContent=""}destroy(){if(this.clearStyles(),this.styleElement)this.styleElement.remove(),this.styleElement=null}ensureStyleElement(){if(!this.styleElement){let e=document.createElement("style");document.head.appendChild(e),this.styleElement=e}return this.styleElement}convertToCSS(e){return Object.entries(e).map(([t,n])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${se(n)};`).join(`
2
+ `)}updateStyles(){if(this.styles.size===0){if(this.styleElement)this.styleElement.textContent="";return}let e=this.ensureStyleElement(),t=Je+`
3
3
  `;this.styles.forEach((n)=>{if(t+=`${n.selector} {
4
4
  ${this.convertToCSS(n.properties)}
5
5
  }
@@ -11,7 +11,7 @@ ${n.selector} {
11
11
  ${this.convertToCSS(o)}
12
12
  }
13
13
  }
14
- `})}),e.textContent=t}}class G{state;bindings=[];templateRegex=/{{(.*?)}}/g;constructor(e){this.state=e;if(!e||typeof e!=="object")throw Error("TemplateEngine requires a valid state object")}parseTemplate(e){if(typeof e!=="string")e=String(e);let t=document.createTextNode("");this.templateRegex.lastIndex=0;let n=Array.from(e.matchAll(this.templateRegex));if(n&&n.length>0)this.setupReactiveBindings(t,e,n);else t.textContent=e;return t}setupReactiveBindings(e,t,n){let r=new Set,o=this.evaluateTemplate(t,n,r);e.textContent=o;let i=N(()=>{try{let s=this.evaluateTemplate(t,n,r);if(e.textContent!==s)e.textContent=s}catch(s){console.error("Template update error:",s),e.textContent=`Error: ${s instanceof Error?s.message:"Unknown error"}`}});this.bindings.push({node:e,originalText:t,effect:i})}evaluateTemplate(e,t,n){let r=e;return t.forEach((o)=>{let i=o[1]?.trim();if(i){n.add(i);let s=this.getValueFromState(i),a=s===void 0||s===null?"":String(s);r=r.replace(o[0],a)}}),r}getValueFromState(e){if(!e)return;let t=e.split("."),n=this.state;for(let r of t){if(!n||typeof n!=="object")return;n=n[r]}return n}clearBindings(){this.bindings.forEach((e)=>{O(e.effect)}),this.bindings=[]}getBindingCount(){return this.bindings.length}hasExpressions(e){return this.templateRegex.lastIndex=0,this.templateRegex.test(e)}extractKeys(e){let t=[],n,r=new RegExp(this.templateRegex,"g");while((n=r.exec(e))!==null){let o=n[1]?.trim();if(o)t.push(o)}return t}evaluateTemplateValue(e){this.templateRegex.lastIndex=0;let t=Array.from(e.matchAll(this.templateRegex));if(!t||t.length===0)return e;let n=new Set;return this.evaluateTemplate(e,t,n)}}class K{props;vnode=null;el=null;renderer=new ae;templateEngine;childComponents=new Set;eventListeners={};providers=new Map;updateEffect;appContext=null;parentComponent=null;elementChangeListener=null;styleManager;state;mounted=!1;constructor(e={}){this.props=e;this.styleManager=new Pe,this.state=We(this.initState()??{}),this.templateEngine=new G(this.state),this.initStyles(),this.updateEffect=N(()=>{if(this.mounted)try{this.update()}catch(t){if(!this.dispatchError(t))throw t}},{throwOnError:!0,scheduler:(t)=>{xe.enqueue(t)}})}mount(e){if(!e||!(e instanceof HTMLElement))throw Error("Invalid container element");try{e.appendChild(this.mountToNode())}catch(t){throw console.error("组件渲染错误:",t),t}}mountToNode(){if(this.mounted&&this.el)return this.el;return this.beforeMount(),this.el=L.getInstance().runWithEffect(this.updateEffect,()=>{try{return this.vnode=this.render(),this.renderer.mount(this.vnode,this.createRenderContext())}catch(e){if(this.dispatchError(e))return document.createComment("error-boundary");throw e}}),this.mounted=!0,this.onMounted(),this.el}update(){if(!this.el||!this.vnode)return;this.beforeUpdate();let e=this.vnode,t=this.el;if(this.el=L.getInstance().runWithEffect(this.updateEffect,()=>{let n=this.render(),r=this.renderer.patch(e,n,t,this.createRenderContext());return this.vnode=n,r}),t!==this.el)this.elementChangeListener?.(t,this.el);this.onUpdated(),this.onPropsChange()}unmount(){if(!this.mounted)return;if(this.beforeUnmount(),this.vnode&&this.el)this.renderer.unmount(this.vnode,this.el,this.createRenderContext());if(this.childComponents.clear(),Object.keys(this.eventListeners).forEach((e)=>{this.eventListeners[e].clear(),delete this.eventListeners[e]}),this.providers.clear(),this.parentComponent=null,this.elementChangeListener=null,this.templateEngine.clearBindings(),this.styleManager.destroy(),O(this.updateEffect),this.el?.parentNode)this.el.parentNode.removeChild(this.el);this.el=null,this.vnode=null,this.mounted=!1,this.onUnmounted()}setProps(e){if(this.props={...this.props,...e},this.mounted)xe.enqueue(this.updateEffect)}setState(e){Object.assign(this.state,e)}setAppContext(e){this.appContext=e,this.childComponents.forEach((t)=>{t.setAppContext?.(e)})}setParentComponent(e){this.parentComponent=e}getParentComponent(){return this.parentComponent}setElementChangeListener(e){this.elementChangeListener=e}provide(e,t){this.providers.set(e,t)}inject(e,t){let n=this.resolveInjection(e);return n.found?n.value:t}resolveInjection(e){if(this.providers.has(e))return{found:!0,value:this.providers.get(e)};if(this.parentComponent?.resolveInjection)return this.parentComponent.resolveInjection(e);return this.resolveAppInjection(e)}getElement(){return this.el}beforeMount(){}onMounted(){}beforeUpdate(){}onUpdated(){}onPropsChange(){}beforeUnmount(){}onUnmounted(){}dispatchError(e){let t=this.getParentComponent();while(t){let n=t;if(typeof n.onErrorCaptured==="function"){if(n.onErrorCaptured(e,this)===!1)return!0}t=t.getParentComponent?.()??null}return!1}getContext(){return this.appContext}get router(){return this.getRouterFrom(this.appContext)??this.getRouterFromGlobalApp()}emit(e,...t){this.eventListeners[e]?.forEach((n)=>{n(...t)})}on(e,t){if(!this.eventListeners[e])this.eventListeners[e]=new Set;return this.eventListeners[e].add(t),()=>this.off(e,t)}off(e,t){this.eventListeners[e]?.delete(t)}createRenderContext(){return{appContext:this.appContext,templateEngine:this.templateEngine,renderer:this.renderer,slots:this.collectSlots(),registerChild:(e)=>{this.childComponents.add(e),e.setParentComponent?.(this),e.setAppContext?.(this.appContext)},unregisterChild:(e)=>{this.childComponents.delete(e),e.setParentComponent?.(null)}}}collectSlots(){let e={default:[]};return M(this.props.children).forEach((n)=>{let r=this.getSlotName(n);if(!e[r])e[r]=[];e[r].push(this.normalizeSlotChild(n))}),e}getSlotName(e){if(typeof e==="string")return"default";return"slot"in e&&typeof e.slot==="string"?e.slot:"default"}normalizeSlotChild(e){if(typeof e==="string"||!("slot"in e))return e;let t={...e};return delete t.slot,t}getRouterFrom(e){if(!e||typeof e!=="object"||!("router"in e))return;return e.router}getRouterFromGlobalApp(){let e=globalThis.__APP__;return this.getRouterFrom(e)}resolveAppInjection(e){if(!this.appContext||typeof this.appContext!=="object")return{found:!1,value:void 0};return this.appContext.app?.resolveInjection?.(e)??{found:!1,value:void 0}}}var Nt=null;function Qe(){return Nt}var Je="http://www.w3.org/2000/svg",Ot=new Set(["svg","g","defs","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","use","symbol","marker","linearGradient","radialGradient","stop","pattern","mask","clipPath","foreignObject"]);class ue{listeners=new WeakMap;effects=new WeakMap;modelBindings=new Se;matches(e){return typeof e==="object"&&e!==null&&je(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=e.tag==="navigator",r=n?document.createElement("a"):Ot.has(e.tag)?document.createElementNS(Je,e.tag):document.createElement(e.tag),o=e.props??{};if(n){let{url:i,openType:s,...a}=o,l=typeof i==="string"?i:"#";r.setAttribute("href",l),r.addEventListener("click",(c)=>{let p=Qe();if(p)c.preventDefault(),p.push(r.getAttribute("href")??"#")}),this.applyProps(r,{},a,t)}else this.applyProps(r,{},o,t);return this.updateListeners(r,{},this.collectListeners(e)),this.mountChildren(r,e,t),this.applyDirections(r,void 0,e.directions,t),r}patch(e,t,n,r){if(e.tag!==t.tag||n.nodeType===Node.COMMENT_NODE){let i=this.mount(t,r);return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}if(!(n instanceof Element))return n;if(t.directions?.if===!1){let i=document.createComment("if");return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}if(t.tag==="navigator"||e.tag==="navigator"){let i=e.props??{},s=t.props??{},a=typeof i.url==="string"?i.url:"",l=typeof s.url==="string"?s.url:"";if(a!==l)n.setAttribute("href",l);let c={...s};delete c.url,delete c.openType,this.applyProps(n,i,c,r)}else this.applyProps(n,e.props??{},t.props??{},r);return this.updateListeners(n,this.collectListeners(e),this.collectListeners(t)),this.updateChildren(n,e,t,r),this.applyDirections(n,e.directions,t.directions,r),n}unmount(e,t,n){if(!(t instanceof Element))return;this.effects.get(t)?.forEach((r)=>O(r)),this.effects.delete(t),this.listeners.get(t)?.forEach(({eventName:r,listener:o})=>{t.removeEventListener(r,o)}),this.listeners.delete(t),this.modelBindings.cleanup(t),this.unmountChildren(t,e,n)}mountChildren(e,t,n){M(t.children).forEach((r)=>{e.appendChild(n.renderer.mount(r,n))})}updateChildren(e,t,n,r){this.updateOrdinaryChildren(e,M(t.children),M(n.children),r)}unmountChildren(e,t,n){M(t.children).forEach((r,o)=>{let i=e.childNodes[o];if(i)n.renderer.unmount(r,i,n)})}applyProps(e,t,n,r){Object.keys(t).forEach((o)=>{if(se(o)||o in n)return;if(o==="className"||o==="class")e.removeAttribute("class");else if(o==="style")e.removeAttribute("style");else if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e)e.value="";else e.removeAttribute(le(o))}),Object.entries(n).forEach(([o,i])=>{if(se(o))return;if(t[o]===i)return;if(o==="className"||o==="class"){if(e.namespaceURI===Je)e.setAttribute("class",String(i??""));else e.className=String(i??"");return}if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e){e.value=String(i??"");return}if(o==="style"&&typeof i==="object"&&i!==null){e.removeAttribute("style");let s=e.style;Object.entries(i).forEach(([a,l])=>{Ye(s,a,l)});return}if(i===!1||i===void 0||i===null){e.removeAttribute(le(o));return}if(i===!0){e.setAttribute(le(o),"");return}if(typeof i==="string"&&r.templateEngine.hasExpressions(i)){this.setupReactiveAttribute(e,o,i,r);return}e.setAttribute(le(o),String(i))})}applyDirections(e,t,n,r){if(n&&"show"in n)e.style.display=n.show?"":"none";else if(t&&"show"in t)e.style.display="";if(!n?.model){this.modelBindings.cleanup(e);return}this.modelBindings.bind(e,n.model,r.templateEngine.state)}updateOrdinaryChildren(e,t,n,r){if(this.assertNoDuplicateKeys(t),this.assertNoDuplicateKeys(n),this.hasOnlyKeyedChildren(t,n)){this.updateKeyedChildren(e,t,n,r);return}let o=Math.min(t.length,n.length);for(let i=0;i<o;i+=1){let s=e.childNodes[i];if(!s){e.appendChild(r.renderer.mount(n[i],r));continue}r.renderer.patch(t[i],n[i],s,r)}for(let i=o;i<n.length;i+=1)e.appendChild(r.renderer.mount(n[i],r));for(let i=t.length-1;i>=n.length;i-=1){let s=e.childNodes[i];if(s){if(r.renderer.unmount(t[i],s,r),s.parentNode===e)e.removeChild(s)}}}updateKeyedChildren(e,t,n,r){let o=t.map((a,l)=>({vnode:a,node:e.childNodes[l],index:l})),i=new Map,s=new Set;o.forEach((a)=>{let l=this.getVNodeKey(a.vnode);if(l!==void 0&&a.node)i.set(l,{vnode:a.vnode,node:a.node,index:a.index})}),n.forEach((a,l)=>{let c=this.getVNodeKey(a),p=c===void 0?void 0:i.get(c),u;if(p)u=r.renderer.patch(p.vnode,a,p.node,r),s.add(p.index);else u=r.renderer.mount(a,r);let d=e.childNodes[l]??null;if(u!==d)e.insertBefore(u,d)}),o.forEach((a)=>{if(!a.node||s.has(a.index))return;if(r.renderer.unmount(a.vnode,a.node,r),a.node.parentNode===e)e.removeChild(a.node)})}hasOnlyKeyedChildren(e,t){return[...e,...t].every((n)=>this.getVNodeKey(n)!==void 0)}assertNoDuplicateKeys(e){let t=new Set;e.forEach((n)=>{let r=this.getVNodeKey(n);if(r===void 0)return;if(t.has(r))throw Error(`Duplicate key "${r}"`);t.add(r)})}getVNodeKey(e){if(typeof e==="string")return;return e.key}collectListeners(e){let t={};return Object.entries(e.props??{}).forEach(([n,r])=>{if(se(n)&&typeof r==="function")t[Ge(n)]=r}),{...t,...e.listeners??{}}}updateListeners(e,t,n){let r=this.listeners.get(e)??new Map,o=new Set(Object.keys(t)),i=new Set(Object.keys(n));o.forEach((s)=>{if(!i.has(s)||t[s]!==n[s]){let a=r.get(s);if(a)e.removeEventListener(a.eventName,a.listener),r.delete(s)}}),i.forEach((s)=>{if(!o.has(s)||t[s]!==n[s]){let{eventName:a,modifiers:l}=Ke(s),c=typeof e.tagName==="string"&&e.tagName.toLowerCase()==="textarea",p=a==="confirm"&&!c?"keydown":a,u=Xe((d)=>{if(p==="keydown"){if(d.key!=="Enter")return}n[s](d)},l);e.addEventListener(p,u),r.set(s,{eventName:p,listener:u})}}),this.listeners.set(e,r)}setupReactiveAttribute(e,t,n,r){let o=N(()=>{e.setAttribute(t,r.templateEngine.evaluateTemplateValue(n))});this.trackEffect(e,o)}trackEffect(e,t){let n=this.effects.get(e)??new Set;n.add(t),this.effects.set(e,n)}}function le(e){if(e.startsWith("data")&&e.length>4)return`data${e.slice(4).replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}`;if(e==="tabIndex"||e==="colSpan"||e==="htmlFor")return e.toLowerCase();return e}class ae{strategies;constructor(){this.strategies=[new Ze,new et,new tt,new ue]}mount(e,t){return this.findStrategy(e).mount(e,t)}patch(e,t,n,r){let o=this.findStrategy(e),i=this.findStrategy(t);if(o!==i){let s=i.mount(t,r);return n.parentNode?.replaceChild(s,n),o.unmount(e,n,r),s}return o.patch(e,t,n,r)}unmount(e,t,n){this.findStrategy(e).unmount(e,t,n)}findStrategy(e){let t=this.strategies.find((n)=>n.matches(e));if(!t)throw Error("No render strategy found for vnode");return t}}class Ze{matches(e){return typeof e==="string"}mount(e,t){return t.templateEngine.parseTemplate(e)}patch(e,t,n,r){if(e===t)return n;let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}unmount(){}}class et{instances=new WeakMap;instanceNodes=new Map;emitterUnsubscribers=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&Be(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let r=new e.component(this.createProps(e));if(t.appContext&&r.setAppContext)r.setAppContext(t.appContext);this.syncEmitters(r,e.emitters??{}),t.registerChild(r);let o=r.mountToNode();return this.trackInstanceNode(r,o),r.setElementChangeListener?.((i,s)=>{this.trackInstanceNode(r,i),this.trackInstanceNode(r,s)}),o}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let s=this.mount(t,r);return n.parentNode?.replaceChild(s,n),s}if(t.directions?.if===!1){let s=document.createComment("if");return n.parentNode?.replaceChild(s,n),this.unmount(e,n,r),s}let o=this.instances.get(n);if(o&&e.component===t.component){this.syncEmitters(o,t.emitters??{}),o.setProps(this.createProps(t));let s=o.getElement()??n;return this.trackInstanceNode(o,s),s}let i=this.mount(t,r);return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}unmount(e,t,n){let r=this.instances.get(t);if(r)this.clearEmitters(r),r.unmount(),this.clearInstanceNodes(r),n.unregisterChild(r)}createProps(e){return{...e.props??{},children:M(e.children)}}syncEmitters(e,t){let n=this.emitterUnsubscribers.get(e)??new Map;n.forEach(({listener:r,unsubscribe:o},i)=>{let s=t[i];if(!s||s!==r)o(),n.delete(i)}),Object.entries(t).forEach(([r,o])=>{if(n.get(r)?.listener===o)return;n.set(r,{listener:o,unsubscribe:e.on(r,o)})}),this.emitterUnsubscribers.set(e,n)}clearEmitters(e){this.emitterUnsubscribers.get(e)?.forEach(({unsubscribe:t})=>{t()}),this.emitterUnsubscribers.delete(e)}trackInstanceNode(e,t){this.instances.set(t,e);let n=this.instanceNodes.get(e)??new Set;n.add(t),this.instanceNodes.set(e,n)}clearInstanceNodes(e){this.instanceNodes.get(e)?.forEach((t)=>{this.instances.delete(t)}),this.instanceNodes.delete(e)}}class tt{renderedChildren=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&_e(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=document.createElement("div");return n.setAttribute("data-slot",e.props.name),this.mountSlotChildren(n,this.resolveChildren(e,t),t),n}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}if(t.directions?.if===!1){let o=document.createComment("if");return n.parentNode?.replaceChild(o,n),this.unmount(e,n,r),o}if(n instanceof HTMLElement)n.setAttribute("data-slot",t.props.name),this.replaceSlotChildren(n,e,t,r);return n}unmount(e,t,n){if(!(t instanceof HTMLElement))return;this.unmountSlotChildren(t,n),this.renderedChildren.delete(t)}resolveChildren(e,t){return t.slots[e.props.name]??M(e.children)}replaceSlotChildren(e,t,n,r){let o=this.renderedChildren.get(e)??[],i=this.resolveChildren(n,r),s=Math.min(o.length,i.length);for(let a=0;a<s;a+=1){let l=e.childNodes[a];if(!l){e.appendChild(r.renderer.mount(i[a],r));continue}r.renderer.patch(o[a],i[a],l,r)}for(let a=s;a<i.length;a+=1)e.appendChild(r.renderer.mount(i[a],r));for(let a=o.length-1;a>=i.length;a-=1){let l=e.childNodes[a];if(l){if(r.renderer.unmount(o[a],l,r),l.parentNode===e)e.removeChild(l)}}this.renderedChildren.set(e,i)}mountSlotChildren(e,t,n){t.forEach((r)=>{e.appendChild(n.renderer.mount(r,n))}),this.renderedChildren.set(e,t)}unmountSlotChildren(e,t){(this.renderedChildren.get(e)??[]).forEach((r,o)=>{let i=e.childNodes[o];if(i)t.renderer.unmount(r,i,t)})}}class x extends Error{code;config;response;cause;constructor(e){super(e.message);this.name="RequestError",this.code=e.code,this.config=e.config,this.response=e.response,this.cause=e.cause}}var Ht=new Set(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]);function pe(e){if(e===void 0)return"GET";let t=e.toUpperCase();if(!Ht.has(t))throw Error(`Unsupported HTTP method: ${e}`);return t}var qt=/^[a-z][a-z\d+.-]*:\/\//i;function Bt(e){return qt.test(e)}function jt(e,t){if(!e||Bt(t))return t;return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function nt(e){if(e instanceof Date)return e.toISOString();if(typeof e==="object")return JSON.stringify(e);return String(e)}function _t(e){if(!e)return"";let t=[];return Object.keys(e).forEach((n)=>{let r=e[n];if(r===void 0||r===null)return;let o=encodeURIComponent(n);if(Array.isArray(r)){r.forEach((i)=>{if(i===void 0||i===null)return;t.push(`${o}=${encodeURIComponent(nt(i))}`)});return}t.push(`${o}=${encodeURIComponent(nt(r))}`)}),t.join("&")}function ce(e,t,n){let r=jt(e,t),o=_t(n);if(!o)return r;let i=r.includes("?")?"&":"?";return`${r}${i}${o}`}function Ft(e){if(e===void 0||e===null)return;return String(e)}function _(...e){let t={},n=new Map;return e.forEach((r)=>{if(!r)return;Object.keys(r).forEach((o)=>{let i=Ft(r[o]);if(i===void 0)return;let s=o.toLowerCase(),a=n.get(s);if(a!==void 0&&a!==o)delete t[a];n.set(s,o),t[o]=i})}),t}function Vt(e,t){return Object.keys(e).some((n)=>n.toLowerCase()===t.toLowerCase())}function rt(e,t,n){if(n==="GET"||n==="HEAD")return;if(e===void 0||e===null)return;if(typeof e==="string")return e;if(typeof FormData<"u"&&e instanceof FormData)return e;if(typeof Blob<"u"&&e instanceof Blob)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e;if(!Vt(t,"Content-Type"))t["Content-Type"]="application/json";return JSON.stringify(e)}class Le{platform="web";async request(e){let t=pe(e.method),n=ce(e.baseURL,e.url,e.params),r=_(e.headers),o=rt(e.data,r,t),i=new AbortController,s=!1,a=!1,l;if(e.signal)if(e.signal.aborted)a=!0,i.abort();else e.signal.addEventListener("abort",()=>{a=!0,i.abort()},{once:!0});if(typeof e.timeout==="number"&&e.timeout>0)l=setTimeout(()=>{s=!0,i.abort()},e.timeout);let c=e.credentials??(e.withCredentials===!0?"include":"same-origin");try{let p=await fetch(n,{method:t,headers:r,body:o,signal:i.signal,credentials:c}),u={};return p.headers.forEach((h,m)=>{u[m]=h}),{data:await Wt(p,e),statusCode:p.status,statusText:p.statusText,headers:u,config:e}}catch(p){if(s)throw new x({code:"TIMEOUT",message:`Request timeout after ${String(e.timeout)}ms`,config:e,cause:p});if(a||i.signal.aborted)throw new x({code:"ABORTED",message:"Request aborted",config:e,cause:p});throw new x({code:"NETWORK_ERROR",message:p instanceof Error?p.message:String(p),config:e,cause:p})}finally{if(l!==void 0)clearTimeout(l)}}}async function Wt(e,t){if(t.responseType==="arraybuffer")return e.arrayBuffer();let n=await e.text();if(t.dataType==="text"||!n)return n;try{return JSON.parse(n)}catch{return n}}function $t(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof global<"u")return global;return{}}function Me(e){let t=$t()[e];return typeof t==="object"&&t!==null?t:null}function de(){if(Ae("wx"))return"weixin";if(Ae("my"))return"alipay";if(Ae("tt"))return"bytedance";if(typeof fetch==="function")return"web";return"unknown"}function Ae(e){let t=Me(e);return t!==null&&typeof t.request==="function"}var ot={platform:"weixin",globalName:"wx",headerField:"header",statusField:"statusCode",responseHeaderField:"header"},it={platform:"alipay",globalName:"my",headerField:"headers",statusField:"status",responseHeaderField:"headers"},st={platform:"bytedance",globalName:"tt",headerField:"header",statusField:"statusCode",responseHeaderField:"header"};class X{dialect;platform;constructor(e){this.dialect=e;this.platform=e.platform}request(e){let t=Me(this.dialect.globalName);if(!t||typeof t.request!=="function")return Promise.reject(new x({code:"UNSUPPORTED_PLATFORM",message:`${this.dialect.globalName}.request is not available in current environment`,config:e}));let n=t.request;return new Promise((r,o)=>{let i=!1,s=!1,a,l,c=(u)=>{if(s)return;if(s=!0,l!==void 0)clearTimeout(l);u()},p={url:ce(e.baseURL,e.url,e.params),method:e.method??"GET",data:e.data,[this.dialect.headerField]:zt(e.headers),dataType:e.dataType??"json",...e.responseType!==void 0?{responseType:e.responseType}:{},...e.timeout!==void 0&&e.timeout>0?{timeout:e.timeout}:{},success:(u)=>{c(()=>{let d=u[this.dialect.statusField],h=Number(d??u.statusCode??0),m=Ut(u[this.dialect.responseHeaderField]);r({data:u.data,statusCode:h,headers:m,config:e,...Array.isArray(u.cookies)?{cookies:u.cookies}:{},...typeof u.errMsg==="string"?{errMsg:u.errMsg}:{}})})},fail:(u)=>{c(()=>{let d=Gt(u);o(new x({code:i?"TIMEOUT":Kt(d),message:d||"Network request failed",config:e,cause:u}))})}};if(e.timeout!==void 0&&e.timeout>0)l=setTimeout(()=>{i=!0,a?.abort?.()},e.timeout);if(a=n(p)??void 0,e.signal)if(e.signal.aborted)a?.abort?.();else e.signal.addEventListener("abort",()=>{a?.abort?.()},{once:!0})})}}function zt(e){return _(e)}function Ut(e){if(typeof e!=="object"||e===null)return{};let t={};return Object.keys(e).forEach((n)=>{let r=e[n];if(r!==void 0&&r!==null)t[n]=String(r)}),t}function Gt(e){if(typeof e.errMsg==="string")return e.errMsg;if(typeof e.errorMessage==="string")return e.errorMessage;if(typeof e.error==="string")return e.error;return""}function Kt(e){if(!e)return"UNKNOWN";if(/timeout/i.test(e))return"TIMEOUT";if(/abort/i.test(e))return"ABORTED";return"NETWORK_ERROR"}var at={web:new Le,weixin:new X(ot),alipay:new X(it),bytedance:new X(st)};function he(e){let t=at[e];if(!t)throw new x({code:"UNSUPPORTED_PLATFORM",message:`Unsupported request platform: ${String(e)}`,config:{url:""}});return t}async function Ie(e,t,n){if(e.platform!==void 0&&e.platform!=="auto")return he(e.platform);if(t!==void 0)return typeof t==="function"?await t(e):t;if(n!==void 0&&n!=="auto")return he(n);let r=de();if(r==="unknown")throw new x({code:"UNSUPPORTED_PLATFORM",message:"No supported request platform detected (web fetch / wx.request / my.request / tt.request)",config:e});return he(r)}class Y{handlers=[];use(e,t){return this.handlers.push({onFulfilled:e,onRejected:t}),this.handlers.length-1}eject(e){if(this.handlers[e]!==void 0)this.handlers[e]=null}clear(){this.handlers.length=0}forEach(e){this.handlers.forEach((t,n)=>{if(t!==null)e(t,n)})}}class me{interceptors={request:new Y,response:new Y};instanceDefaults;instanceAdapter;instancePlatform;constructor(e={}){let{adapter:t,platform:n,...r}=e;this.instanceAdapter=t,this.instancePlatform=n,this.instanceDefaults={...r}}request(e){let t;try{t=this.mergeConfig(e)}catch(i){return Promise.reject(i)}let n=[];this.interceptors.request.forEach((i)=>{n.push(i.onFulfilled,i.onRejected)}),n.push((i)=>this.dispatch(i),void 0);let r=[];this.interceptors.response.forEach((i)=>{r.push({onFulfilled:i.onFulfilled,onRejected:i.onRejected})});for(let i=r.length-1;i>=0;i-=1){let s=r[i];n.push(s.onFulfilled,s.onRejected)}let o=Promise.resolve(t);while(n.length>0){let i=n.shift(),s=n.shift();o=o.then(i,s)}return o}get(e,t){return this.request({...t,url:e,method:"GET"})}delete(e,t){return this.request({...t,url:e,method:"DELETE"})}head(e,t){return this.request({...t,url:e,method:"HEAD"})}options(e,t){return this.request({...t,url:e,method:"OPTIONS"})}post(e,t,n){return this.request({...n,url:e,method:"POST",data:t})}put(e,t,n){return this.request({...n,url:e,method:"PUT",data:t})}patch(e,t,n){return this.request({...n,url:e,method:"PATCH",data:t})}dispatch(e){return Ie(e,this.instanceAdapter,this.instancePlatform).then((t)=>t.request(e))}mergeConfig(e){if(!e||typeof e!=="object")throw new x({code:"BAD_REQUEST",message:"Request config must be an object",config:e});let t={...this.instanceDefaults,...e,headers:_(this.instanceDefaults.headers,e.headers),params:{...this.instanceDefaults.params,...e.params}};if(typeof t.url!=="string"||t.url.length===0)throw new x({code:"BAD_REQUEST",message:"Request url is required",config:t});try{t.method=pe(t.method)}catch(n){throw new x({code:"BAD_REQUEST",message:n.message,config:t,cause:n})}return t}}var Fi=new me;var Xt="tc-chart-canvas";class lt extends K{chart=null;destroyed=!1;initState(){return{canvasId:Xt}}initStyles(){this.styleManager.addStyle("tc-chart-canvas",{selector:".tc-chart__canvas",properties:{display:"block",height:"100%",width:"100%"}})}render(){return Fe("canvas",{id:this.state.canvasId,className:`tc-chart__canvas${this.props.className?` ${this.props.className}`:""}`,type:"2d"})}onMounted(){this.attachChart()}onUpdated(){if(this.chart&&!this.destroyed)this.chart.setOption(this.props.option).render();else if(!this.chart&&!this.destroyed)this.attachChart()}onUnmounted(){this.destroyed=!0,this.chart?.destroy(),this.chart=null}getChart(){return this.chart}attachChart(){if(this.destroyed)return;this.resolveContext().then((e)=>{if(this.destroyed)return;this.chart=U(e,this.props.option),this.chart.render()}).catch((e)=>{console.error("[TcChart] attach failed:",e)})}getElement(){return super.getElement()}resolveContext(){if(this.props.resolve)return Promise.resolve(this.props.resolve(this.getElement()));let e=oe();if(e){let t=`#${this.state.canvasId}`,n=(r)=>re({platform:e,instance:this,selector:t}).then((o)=>B(o)).catch((o)=>{if(r<=0)throw o;return new Promise((i)=>setTimeout(i,50)).then(()=>n(r-1))});return n(5)}return Promise.resolve(j(this.getElement()))}}export{ee as BarChart,J as CategoryScale,A as ChartBase,Ne as DEFAULT_AXIS_COLOR,Q as DEFAULT_FONT_FAMILY,ge as DEFAULT_GRID_COLOR,ke as DEFAULT_PALETTE,V as DEFAULT_TEXT_COLOR,Z as LineChart,W as LinearScale,te as PieChart,ne as RadarChart,lt as TcChart,ye as computeLayout,U as createChart,Rt as createMiniProgramChart,Ct as createWebChart,Ce as detectMiniProgramPixelRatio,q as detectPixelRatio,re as getMiniProgramCanvasNode,D as getMiniProgramGlobal,ut as isCanvas2DLike,Oe as niceTicks,B as resolveMiniProgramCanvas,qe as resolveNativeCanvas,j as resolveWebCanvas};
14
+ `})}),e.textContent=t}}class X{state;bindings=[];templateRegex=/{{(.*?)}}/g;constructor(e){this.state=e;if(!e||typeof e!=="object")throw Error("TemplateEngine requires a valid state object")}parseTemplate(e){if(typeof e!=="string")e=String(e);let t=document.createTextNode("");this.templateRegex.lastIndex=0;let n=Array.from(e.matchAll(this.templateRegex));if(n&&n.length>0)this.setupReactiveBindings(t,e,n);else t.textContent=e;return t}setupReactiveBindings(e,t,n){let r=new Set,o=this.evaluateTemplate(t,n,r);e.textContent=o;let i=D(()=>{try{let s=this.evaluateTemplate(t,n,r);if(e.textContent!==s)e.textContent=s}catch(s){console.error("Template update error:",s),e.textContent=`Error: ${s instanceof Error?s.message:"Unknown error"}`}});this.bindings.push({node:e,originalText:t,effect:i})}evaluateTemplate(e,t,n){let r=e;return t.forEach((o)=>{let i=o[1]?.trim();if(i){n.add(i);let s=this.getValueFromState(i),a=s===void 0||s===null?"":String(s);r=r.replace(o[0],a)}}),r}getValueFromState(e){if(!e)return;let t=e.split("."),n=this.state;for(let r of t){if(!n||typeof n!=="object")return;n=n[r]}return n}clearBindings(){this.bindings.forEach((e)=>{H(e.effect)}),this.bindings=[]}getBindingCount(){return this.bindings.length}hasExpressions(e){return this.templateRegex.lastIndex=0,this.templateRegex.test(e)}extractKeys(e){let t=[],n,r=new RegExp(this.templateRegex,"g");while((n=r.exec(e))!==null){let o=n[1]?.trim();if(o)t.push(o)}return t}evaluateTemplateValue(e){this.templateRegex.lastIndex=0;let t=Array.from(e.matchAll(this.templateRegex));if(!t||t.length===0)return e;let n=new Set;return this.evaluateTemplate(e,t,n)}}class Y{props;vnode=null;el=null;renderer=new le;templateEngine;childComponents=new Set;eventListeners={};providers=new Map;updateEffect;appContext=null;parentComponent=null;elementChangeListener=null;styleManager;state;mounted=!1;constructor(e={}){this.props=e;this.styleManager=new Le,this.state=Xe(this.initState()??{}),this.templateEngine=new X(this.state),this.initStyles(),this.updateEffect=D(()=>{if(this.mounted)try{this.update()}catch(t){if(!this.dispatchError(t))throw t}},{throwOnError:!0,scheduler:(t)=>{Te.enqueue(t)}})}mount(e){if(!e||!(e instanceof HTMLElement))throw Error("Invalid container element");try{e.appendChild(this.mountToNode())}catch(t){throw console.error("组件渲染错误:",t),t}}mountToNode(){if(this.mounted&&this.el)return this.el;return this.beforeMount(),this.el=A.getInstance().runWithEffect(this.updateEffect,()=>{try{return this.vnode=this.render(),this.renderer.mount(this.vnode,this.createRenderContext())}catch(e){if(this.dispatchError(e))return document.createComment("error-boundary");throw e}}),this.mounted=!0,this.onMounted(),this.el}update(){if(!this.el||!this.vnode)return;this.beforeUpdate();let e=this.vnode,t=this.el;if(this.el=A.getInstance().runWithEffect(this.updateEffect,()=>{let n=this.render(),r=this.renderer.patch(e,n,t,this.createRenderContext());return this.vnode=n,r}),t!==this.el)this.elementChangeListener?.(t,this.el);this.onUpdated(),this.onPropsChange()}unmount(){if(!this.mounted)return;if(this.beforeUnmount(),this.vnode&&this.el)this.renderer.unmount(this.vnode,this.el,this.createRenderContext());if(this.childComponents.clear(),Object.keys(this.eventListeners).forEach((e)=>{this.eventListeners[e].clear(),delete this.eventListeners[e]}),this.providers.clear(),this.parentComponent=null,this.elementChangeListener=null,this.templateEngine.clearBindings(),this.styleManager.destroy(),H(this.updateEffect),this.el?.parentNode)this.el.parentNode.removeChild(this.el);this.el=null,this.vnode=null,this.mounted=!1,this.onUnmounted()}setProps(e){if(this.props={...this.props,...e},this.mounted)Te.enqueue(this.updateEffect)}setState(e){Object.assign(this.state,e)}setAppContext(e){this.appContext=e,this.childComponents.forEach((t)=>{t.setAppContext?.(e)})}setParentComponent(e){this.parentComponent=e}getParentComponent(){return this.parentComponent}setElementChangeListener(e){this.elementChangeListener=e}provide(e,t){this.providers.set(e,t)}inject(e,t){let n=this.resolveInjection(e);return n.found?n.value:t}resolveInjection(e){if(this.providers.has(e))return{found:!0,value:this.providers.get(e)};if(this.parentComponent?.resolveInjection)return this.parentComponent.resolveInjection(e);return this.resolveAppInjection(e)}getElement(){return this.el}beforeMount(){}onMounted(){}beforeUpdate(){}onUpdated(){}onPropsChange(){}beforeUnmount(){}onUnmounted(){}dispatchError(e){let t=this.getParentComponent();while(t){let n=t;if(typeof n.onErrorCaptured==="function"){if(n.onErrorCaptured(e,this)===!1)return!0}t=t.getParentComponent?.()??null}return!1}getContext(){return this.appContext}get router(){return this.getRouterFrom(this.appContext)??this.getRouterFromGlobalApp()}emit(e,...t){this.eventListeners[e]?.forEach((n)=>{n(...t)})}on(e,t){if(!this.eventListeners[e])this.eventListeners[e]=new Set;return this.eventListeners[e].add(t),()=>this.off(e,t)}off(e,t){this.eventListeners[e]?.delete(t)}createRenderContext(){return{appContext:this.appContext,templateEngine:this.templateEngine,renderer:this.renderer,slots:this.collectSlots(),registerChild:(e)=>{this.childComponents.add(e),e.setParentComponent?.(this),e.setAppContext?.(this.appContext)},unregisterChild:(e)=>{this.childComponents.delete(e),e.setParentComponent?.(null)}}}collectSlots(){let e={default:[]};return k(this.props.children).forEach((n)=>{let r=this.getSlotName(n);if(!e[r])e[r]=[];e[r].push(this.normalizeSlotChild(n))}),e}getSlotName(e){if(typeof e==="string")return"default";return"slot"in e&&typeof e.slot==="string"?e.slot:"default"}normalizeSlotChild(e){if(typeof e==="string"||!("slot"in e))return e;let t={...e};return delete t.slot,t}getRouterFrom(e){if(!e||typeof e!=="object"||!("router"in e))return;return e.router}getRouterFromGlobalApp(){let e=globalThis.__APP__;return this.getRouterFrom(e)}resolveAppInjection(e){if(!this.appContext||typeof this.appContext!=="object")return{found:!1,value:void 0};return this.appContext.app?.resolveInjection?.(e)??{found:!1,value:void 0}}}var jt=null;function rt(){return jt}var ot="http://www.w3.org/2000/svg",_t=new Set(["svg","g","defs","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","use","symbol","marker","linearGradient","radialGradient","stop","pattern","mask","clipPath","foreignObject"]);class pe{listeners=new WeakMap;effects=new WeakMap;modelBindings=new Pe;matches(e){return typeof e==="object"&&e!==null&&Ue(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=e.tag==="navigator",r=n?document.createElement("a"):_t.has(e.tag)?document.createElementNS(ot,e.tag):document.createElement(e.tag),o=e.props??{};if(n){let{url:i,openType:s,...a}=o,l=typeof i==="string"?i:"#";r.setAttribute("href",l),r.addEventListener("click",(c)=>{let p=rt();if(p)c.preventDefault(),p.push(r.getAttribute("href")??"#")}),this.applyProps(r,{},a,t)}else this.applyProps(r,{},o,t);return this.updateListeners(r,{},this.collectListeners(e)),this.mountChildren(r,e,t),this.applyDirections(r,void 0,e.directions,t),r}patch(e,t,n,r){if(e.tag!==t.tag||n.nodeType===Node.COMMENT_NODE){let i=this.mount(t,r);return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}if(!(n instanceof Element))return n;if(t.directions?.if===!1){let i=document.createComment("if");return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}if(t.tag==="navigator"||e.tag==="navigator"){let i=e.props??{},s=t.props??{},a=typeof i.url==="string"?i.url:"",l=typeof s.url==="string"?s.url:"";if(a!==l)n.setAttribute("href",l);let c={...s};delete c.url,delete c.openType,this.applyProps(n,i,c,r)}else this.applyProps(n,e.props??{},t.props??{},r);return this.updateListeners(n,this.collectListeners(e),this.collectListeners(t)),this.updateChildren(n,e,t,r),this.applyDirections(n,e.directions,t.directions,r),n}unmount(e,t,n){if(!(t instanceof Element))return;this.effects.get(t)?.forEach((r)=>H(r)),this.effects.delete(t),this.listeners.get(t)?.forEach(({eventName:r,listener:o})=>{t.removeEventListener(r,o)}),this.listeners.delete(t),this.modelBindings.cleanup(t),this.unmountChildren(t,e,n)}mountChildren(e,t,n){k(t.children).forEach((r)=>{e.appendChild(n.renderer.mount(r,n))})}updateChildren(e,t,n,r){this.updateOrdinaryChildren(e,k(t.children),k(n.children),r)}unmountChildren(e,t,n){k(t.children).forEach((r,o)=>{let i=e.childNodes[o];if(i)n.renderer.unmount(r,i,n)})}applyProps(e,t,n,r){Object.keys(t).forEach((o)=>{if(ae(o)||o in n)return;if(o==="className"||o==="class")e.removeAttribute("class");else if(o==="style")e.removeAttribute("style");else if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e)e.value="";else e.removeAttribute(ue(o))}),Object.entries(n).forEach(([o,i])=>{if(ae(o))return;if(t[o]===i)return;if(o==="className"||o==="class"){if(e.namespaceURI===ot)e.setAttribute("class",String(i??""));else e.className=String(i??"");return}if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e){e.value=String(i??"");return}if(o==="style"&&typeof i==="object"&&i!==null){e.removeAttribute("style");let s=e.style;Object.entries(i).forEach(([a,l])=>{nt(s,a,l)});return}if(i===!1||i===void 0||i===null){e.removeAttribute(ue(o));return}if(i===!0){e.setAttribute(ue(o),"");return}if(typeof i==="string"&&r.templateEngine.hasExpressions(i)){this.setupReactiveAttribute(e,o,i,r);return}e.setAttribute(ue(o),String(i))})}applyDirections(e,t,n,r){if(n&&"show"in n)e.style.display=n.show?"":"none";else if(t&&"show"in t)e.style.display="";if(!n?.model){this.modelBindings.cleanup(e);return}this.modelBindings.bind(e,n.model,r.templateEngine.state)}updateOrdinaryChildren(e,t,n,r){if(this.assertNoDuplicateKeys(t),this.assertNoDuplicateKeys(n),this.hasOnlyKeyedChildren(t,n)){this.updateKeyedChildren(e,t,n,r);return}let o=Math.min(t.length,n.length);for(let i=0;i<o;i+=1){let s=e.childNodes[i];if(!s){e.appendChild(r.renderer.mount(n[i],r));continue}r.renderer.patch(t[i],n[i],s,r)}for(let i=o;i<n.length;i+=1)e.appendChild(r.renderer.mount(n[i],r));for(let i=t.length-1;i>=n.length;i-=1){let s=e.childNodes[i];if(s){if(r.renderer.unmount(t[i],s,r),s.parentNode===e)e.removeChild(s)}}}updateKeyedChildren(e,t,n,r){let o=t.map((a,l)=>({vnode:a,node:e.childNodes[l],index:l})),i=new Map,s=new Set;o.forEach((a)=>{let l=this.getVNodeKey(a.vnode);if(l!==void 0&&a.node)i.set(l,{vnode:a.vnode,node:a.node,index:a.index})}),n.forEach((a,l)=>{let c=this.getVNodeKey(a),p=c===void 0?void 0:i.get(c),u;if(p)u=r.renderer.patch(p.vnode,a,p.node,r),s.add(p.index);else u=r.renderer.mount(a,r);let d=e.childNodes[l]??null;if(u!==d)e.insertBefore(u,d)}),o.forEach((a)=>{if(!a.node||s.has(a.index))return;if(r.renderer.unmount(a.vnode,a.node,r),a.node.parentNode===e)e.removeChild(a.node)})}hasOnlyKeyedChildren(e,t){return[...e,...t].every((n)=>this.getVNodeKey(n)!==void 0)}assertNoDuplicateKeys(e){let t=new Set;e.forEach((n)=>{let r=this.getVNodeKey(n);if(r===void 0)return;if(t.has(r))throw Error(`Duplicate key "${r}"`);t.add(r)})}getVNodeKey(e){if(typeof e==="string")return;return e.key}collectListeners(e){let t={};return Object.entries(e.props??{}).forEach(([n,r])=>{if(ae(n)&&typeof r==="function")t[Ze(n)]=r}),{...t,...e.listeners??{}}}updateListeners(e,t,n){let r=this.listeners.get(e)??new Map,o=new Set(Object.keys(t)),i=new Set(Object.keys(n));o.forEach((s)=>{if(!i.has(s)||t[s]!==n[s]){let a=r.get(s);if(a)e.removeEventListener(a.eventName,a.listener),r.delete(s)}}),i.forEach((s)=>{if(!o.has(s)||t[s]!==n[s]){let{eventName:a,modifiers:l}=et(s),c=typeof e.tagName==="string"&&e.tagName.toLowerCase()==="textarea",p=a==="confirm"&&!c?"keydown":a,u=tt((d)=>{if(p==="keydown"){if(d.key!=="Enter")return}n[s](d)},l);e.addEventListener(p,u),r.set(s,{eventName:p,listener:u})}}),this.listeners.set(e,r)}setupReactiveAttribute(e,t,n,r){let o=D(()=>{e.setAttribute(t,r.templateEngine.evaluateTemplateValue(n))});this.trackEffect(e,o)}trackEffect(e,t){let n=this.effects.get(e)??new Set;n.add(t),this.effects.set(e,n)}}function ue(e){if(e.startsWith("data")&&e.length>4)return`data${e.slice(4).replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}`;if(e==="tabIndex"||e==="colSpan"||e==="htmlFor")return e.toLowerCase();return e}class le{strategies;constructor(){this.strategies=[new it,new st,new at,new pe]}mount(e,t){return this.findStrategy(e).mount(e,t)}patch(e,t,n,r){let o=this.findStrategy(e),i=this.findStrategy(t);if(o!==i){let s=i.mount(t,r);return n.parentNode?.replaceChild(s,n),o.unmount(e,n,r),s}return o.patch(e,t,n,r)}unmount(e,t,n){this.findStrategy(e).unmount(e,t,n)}findStrategy(e){let t=this.strategies.find((n)=>n.matches(e));if(!t)throw Error("No render strategy found for vnode");return t}}class it{matches(e){return typeof e==="string"}mount(e,t){return t.templateEngine.parseTemplate(e)}patch(e,t,n,r){if(e===t)return n;let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}unmount(){}}class st{instances=new WeakMap;instanceNodes=new Map;emitterUnsubscribers=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&We(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let r=new e.component(this.createProps(e));if(t.appContext&&r.setAppContext)r.setAppContext(t.appContext);this.syncEmitters(r,e.emitters??{}),t.registerChild(r);let o=r.mountToNode();return this.trackInstanceNode(r,o),r.setElementChangeListener?.((i,s)=>{this.trackInstanceNode(r,i),this.trackInstanceNode(r,s)}),o}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let s=this.mount(t,r);return n.parentNode?.replaceChild(s,n),s}if(t.directions?.if===!1){let s=document.createComment("if");return n.parentNode?.replaceChild(s,n),this.unmount(e,n,r),s}let o=this.instances.get(n);if(o&&e.component===t.component){this.syncEmitters(o,t.emitters??{}),o.setProps(this.createProps(t));let s=o.getElement()??n;return this.trackInstanceNode(o,s),s}let i=this.mount(t,r);return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}unmount(e,t,n){let r=this.instances.get(t);if(r)this.clearEmitters(r),r.unmount(),this.clearInstanceNodes(r),n.unregisterChild(r)}createProps(e){return{...e.props??{},children:k(e.children)}}syncEmitters(e,t){let n=this.emitterUnsubscribers.get(e)??new Map;n.forEach(({listener:r,unsubscribe:o},i)=>{let s=t[i];if(!s||s!==r)o(),n.delete(i)}),Object.entries(t).forEach(([r,o])=>{if(n.get(r)?.listener===o)return;n.set(r,{listener:o,unsubscribe:e.on(r,o)})}),this.emitterUnsubscribers.set(e,n)}clearEmitters(e){this.emitterUnsubscribers.get(e)?.forEach(({unsubscribe:t})=>{t()}),this.emitterUnsubscribers.delete(e)}trackInstanceNode(e,t){this.instances.set(t,e);let n=this.instanceNodes.get(e)??new Set;n.add(t),this.instanceNodes.set(e,n)}clearInstanceNodes(e){this.instanceNodes.get(e)?.forEach((t)=>{this.instances.delete(t)}),this.instanceNodes.delete(e)}}class at{renderedChildren=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&$e(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=document.createElement("div");return n.setAttribute("data-slot",e.props.name),this.mountSlotChildren(n,this.resolveChildren(e,t),t),n}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}if(t.directions?.if===!1){let o=document.createComment("if");return n.parentNode?.replaceChild(o,n),this.unmount(e,n,r),o}if(n instanceof HTMLElement)n.setAttribute("data-slot",t.props.name),this.replaceSlotChildren(n,e,t,r);return n}unmount(e,t,n){if(!(t instanceof HTMLElement))return;this.unmountSlotChildren(t,n),this.renderedChildren.delete(t)}resolveChildren(e,t){return t.slots[e.props.name]??k(e.children)}replaceSlotChildren(e,t,n,r){let o=this.renderedChildren.get(e)??[],i=this.resolveChildren(n,r),s=Math.min(o.length,i.length);for(let a=0;a<s;a+=1){let l=e.childNodes[a];if(!l){e.appendChild(r.renderer.mount(i[a],r));continue}r.renderer.patch(o[a],i[a],l,r)}for(let a=s;a<i.length;a+=1)e.appendChild(r.renderer.mount(i[a],r));for(let a=o.length-1;a>=i.length;a-=1){let l=e.childNodes[a];if(l){if(r.renderer.unmount(o[a],l,r),l.parentNode===e)e.removeChild(l)}}this.renderedChildren.set(e,i)}mountSlotChildren(e,t,n){t.forEach((r)=>{e.appendChild(n.renderer.mount(r,n))}),this.renderedChildren.set(e,t)}unmountSlotChildren(e,t){(this.renderedChildren.get(e)??[]).forEach((r,o)=>{let i=e.childNodes[o];if(i)t.renderer.unmount(r,i,t)})}}class T extends Error{code;config;response;cause;constructor(e){super(e.message);this.name="RequestError",this.code=e.code,this.config=e.config,this.response=e.response,this.cause=e.cause}}var Ft=new Set(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]);function ce(e){if(e===void 0)return"GET";let t=e.toUpperCase();if(!Ft.has(t))throw Error(`Unsupported HTTP method: ${e}`);return t}var Vt=/^[a-z][a-z\d+.-]*:\/\//i;function Wt(e){return Vt.test(e)}function Ut(e,t){if(!e||Wt(t))return t;return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function lt(e){if(e instanceof Date)return e.toISOString();if(typeof e==="object")return JSON.stringify(e);return String(e)}function $t(e){if(!e)return"";let t=[];return Object.keys(e).forEach((n)=>{let r=e[n];if(r===void 0||r===null)return;let o=encodeURIComponent(n);if(Array.isArray(r)){r.forEach((i)=>{if(i===void 0||i===null)return;t.push(`${o}=${encodeURIComponent(lt(i))}`)});return}t.push(`${o}=${encodeURIComponent(lt(r))}`)}),t.join("&")}function de(e,t,n){let r=Ut(e,t),o=$t(n);if(!o)return r;let i=r.includes("?")?"&":"?";return`${r}${i}${o}`}function Gt(e){if(e===void 0||e===null)return;return String(e)}function F(...e){let t={},n=new Map;return e.forEach((r)=>{if(!r)return;Object.keys(r).forEach((o)=>{let i=Gt(r[o]);if(i===void 0)return;let s=o.toLowerCase(),a=n.get(s);if(a!==void 0&&a!==o)delete t[a];n.set(s,o),t[o]=i})}),t}function Kt(e,t){return Object.keys(e).some((n)=>n.toLowerCase()===t.toLowerCase())}function ut(e,t,n){if(n==="GET"||n==="HEAD")return;if(e===void 0||e===null)return;if(typeof e==="string")return e;if(typeof FormData<"u"&&e instanceof FormData)return e;if(typeof Blob<"u"&&e instanceof Blob)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e;if(!Kt(t,"Content-Type"))t["Content-Type"]="application/json";return JSON.stringify(e)}class Ae{platform="web";async request(e){let t=ce(e.method),n=de(e.baseURL,e.url,e.params),r=F(e.headers),o=ut(e.data,r,t),i=new AbortController,s=!1,a=!1,l;if(e.signal)if(e.signal.aborted)a=!0,i.abort();else e.signal.addEventListener("abort",()=>{a=!0,i.abort()},{once:!0});if(typeof e.timeout==="number"&&e.timeout>0)l=setTimeout(()=>{s=!0,i.abort()},e.timeout);let c=e.credentials??(e.withCredentials===!0?"include":"same-origin");try{let p=await fetch(n,{method:t,headers:r,body:o,signal:i.signal,credentials:c}),u={};return p.headers.forEach((h,f)=>{u[f]=h}),{data:await Xt(p,e),statusCode:p.status,statusText:p.statusText,headers:u,config:e}}catch(p){if(s)throw new T({code:"TIMEOUT",message:`Request timeout after ${String(e.timeout)}ms`,config:e,cause:p});if(a||i.signal.aborted)throw new T({code:"ABORTED",message:"Request aborted",config:e,cause:p});throw new T({code:"NETWORK_ERROR",message:p instanceof Error?p.message:String(p),config:e,cause:p})}finally{if(l!==void 0)clearTimeout(l)}}}async function Xt(e,t){if(t.responseType==="arraybuffer")return e.arrayBuffer();let n=await e.text();if(t.dataType==="text"||!n)return n;try{return JSON.parse(n)}catch{return n}}function Yt(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof global<"u")return global;return{}}function Ie(e){let t=Yt()[e];return typeof t==="object"&&t!==null?t:null}function he(){if(Me("wx"))return"weixin";if(Me("my"))return"alipay";if(Me("tt"))return"bytedance";if(typeof fetch==="function")return"web";return"unknown"}function Me(e){let t=Ie(e);return t!==null&&typeof t.request==="function"}var pt={platform:"weixin",globalName:"wx",headerField:"header",statusField:"statusCode",responseHeaderField:"header"},ct={platform:"alipay",globalName:"my",headerField:"headers",statusField:"status",responseHeaderField:"headers"},dt={platform:"bytedance",globalName:"tt",headerField:"header",statusField:"statusCode",responseHeaderField:"header"};class Q{dialect;platform;constructor(e){this.dialect=e;this.platform=e.platform}request(e){let t=Ie(this.dialect.globalName);if(!t||typeof t.request!=="function")return Promise.reject(new T({code:"UNSUPPORTED_PLATFORM",message:`${this.dialect.globalName}.request is not available in current environment`,config:e}));let n=t.request;return new Promise((r,o)=>{let i=!1,s=!1,a,l,c=(u)=>{if(s)return;if(s=!0,l!==void 0)clearTimeout(l);u()},p={url:de(e.baseURL,e.url,e.params),method:e.method??"GET",data:e.data,[this.dialect.headerField]:Qt(e.headers),dataType:e.dataType??"json",...e.responseType!==void 0?{responseType:e.responseType}:{},...e.timeout!==void 0&&e.timeout>0?{timeout:e.timeout}:{},success:(u)=>{c(()=>{let d=u[this.dialect.statusField],h=Number(d??u.statusCode??0),f=Jt(u[this.dialect.responseHeaderField]);r({data:u.data,statusCode:h,headers:f,config:e,...Array.isArray(u.cookies)?{cookies:u.cookies}:{},...typeof u.errMsg==="string"?{errMsg:u.errMsg}:{}})})},fail:(u)=>{c(()=>{let d=Zt(u);o(new T({code:i?"TIMEOUT":en(d),message:d||"Network request failed",config:e,cause:u}))})}};if(e.timeout!==void 0&&e.timeout>0)l=setTimeout(()=>{i=!0,a?.abort?.()},e.timeout);if(a=n(p)??void 0,e.signal)if(e.signal.aborted)a?.abort?.();else e.signal.addEventListener("abort",()=>{a?.abort?.()},{once:!0})})}}function Qt(e){return F(e)}function Jt(e){if(typeof e!=="object"||e===null)return{};let t={};return Object.keys(e).forEach((n)=>{let r=e[n];if(r!==void 0&&r!==null)t[n]=String(r)}),t}function Zt(e){if(typeof e.errMsg==="string")return e.errMsg;if(typeof e.errorMessage==="string")return e.errorMessage;if(typeof e.error==="string")return e.error;return""}function en(e){if(!e)return"UNKNOWN";if(/timeout/i.test(e))return"TIMEOUT";if(/abort/i.test(e))return"ABORTED";return"NETWORK_ERROR"}var ht={web:new Ae,weixin:new Q(pt),alipay:new Q(ct),bytedance:new Q(dt)};function fe(e){let t=ht[e];if(!t)throw new T({code:"UNSUPPORTED_PLATFORM",message:`Unsupported request platform: ${String(e)}`,config:{url:""}});return t}async function ke(e,t,n){if(e.platform!==void 0&&e.platform!=="auto")return fe(e.platform);if(t!==void 0)return typeof t==="function"?await t(e):t;if(n!==void 0&&n!=="auto")return fe(n);let r=he();if(r==="unknown")throw new T({code:"UNSUPPORTED_PLATFORM",message:"No supported request platform detected (web fetch / wx.request / my.request / tt.request)",config:e});return fe(r)}class J{handlers=[];use(e,t){return this.handlers.push({onFulfilled:e,onRejected:t}),this.handlers.length-1}eject(e){if(this.handlers[e]!==void 0)this.handlers[e]=null}clear(){this.handlers.length=0}forEach(e){this.handlers.forEach((t,n)=>{if(t!==null)e(t,n)})}}class me{interceptors={request:new J,response:new J};instanceDefaults;instanceAdapter;instancePlatform;constructor(e={}){let{adapter:t,platform:n,...r}=e;this.instanceAdapter=t,this.instancePlatform=n,this.instanceDefaults={...r}}request(e){let t;try{t=this.mergeConfig(e)}catch(i){return Promise.reject(i)}let n=[];this.interceptors.request.forEach((i)=>{n.push(i.onFulfilled,i.onRejected)}),n.push((i)=>this.dispatch(i),void 0);let r=[];this.interceptors.response.forEach((i)=>{r.push({onFulfilled:i.onFulfilled,onRejected:i.onRejected})});for(let i=r.length-1;i>=0;i-=1){let s=r[i];n.push(s.onFulfilled,s.onRejected)}let o=Promise.resolve(t);while(n.length>0){let i=n.shift(),s=n.shift();o=o.then(i,s)}return o}get(e,t){return this.request({...t,url:e,method:"GET"})}delete(e,t){return this.request({...t,url:e,method:"DELETE"})}head(e,t){return this.request({...t,url:e,method:"HEAD"})}options(e,t){return this.request({...t,url:e,method:"OPTIONS"})}post(e,t,n){return this.request({...n,url:e,method:"POST",data:t})}put(e,t,n){return this.request({...n,url:e,method:"PUT",data:t})}patch(e,t,n){return this.request({...n,url:e,method:"PATCH",data:t})}dispatch(e){return ke(e,this.instanceAdapter,this.instancePlatform).then((t)=>t.request(e))}mergeConfig(e){if(!e||typeof e!=="object")throw new T({code:"BAD_REQUEST",message:"Request config must be an object",config:e});let t={...this.instanceDefaults,...e,headers:F(this.instanceDefaults.headers,e.headers),params:{...this.instanceDefaults.params,...e.params}};if(typeof t.url!=="string"||t.url.length===0)throw new T({code:"BAD_REQUEST",message:"Request url is required",config:t});try{t.method=ce(t.method)}catch(n){throw new T({code:"BAD_REQUEST",message:n.message,config:t,cause:n})}return t}}var Xi=new me;var tn="tc-chart-canvas",nn=150;class ft extends Y{chart=null;destroyed=!1;resizeDebounced=null;resizeObserver=null;mpResizeHandler=null;initState(){return{canvasId:tn}}initStyles(){this.styleManager.addStyle("tc-chart-canvas",{selector:".tc-chart__canvas",properties:{display:"block",height:"100%",width:"100%"}})}render(){return Ge("canvas",{id:this.state.canvasId,className:`tc-chart__canvas${this.props.className?` ${this.props.className}`:""}`,type:"2d"})}onMounted(){this.attachChart(),this.setupAutoResize()}onUpdated(){if(this.chart&&!this.destroyed)this.chart.setOption(this.props.option).render();else if(!this.chart&&!this.destroyed)this.attachChart()}onUnmounted(){this.teardownAutoResize(),this.destroyed=!0,this.chart?.destroy(),this.chart=null}getChart(){return this.chart}attachChart(){if(this.destroyed)return;this.resolveContext().then((e)=>{if(this.destroyed||!e)return;this.chart=K(e,this.props.option),this.chart.render()}).catch((e)=>{console.error("[TcChart] attach failed:",e)})}getElement(){return super.getElement()}setupAutoResize(){if(this.destroyed||this.resizeDebounced)return;this.resizeDebounced=be(()=>this.handleResize(),nn);let e=B();if(e){let n=I(e);if(n&&typeof n.onWindowResize==="function")this.mpResizeHandler=()=>this.resizeDebounced.run(),n.onWindowResize(this.mpResizeHandler);return}let t=this.getElement();if(t&&typeof t.getContext==="function"&&typeof ResizeObserver==="function")this.resizeObserver=new ResizeObserver(()=>this.resizeDebounced.run()),this.resizeObserver.observe(t)}teardownAutoResize(){if(this.resizeObserver?.disconnect(),this.resizeObserver=null,this.resizeDebounced?.cancel(),this.resizeDebounced=null,this.mpResizeHandler){let e=B(),t=e?I(e):null;if(t&&typeof t.offWindowResize==="function")t.offWindowResize(this.mpResizeHandler);this.mpResizeHandler=null}}handleResize(){if(this.destroyed)return;if(B()){this.chart?.destroy(),this.chart=null,this.attachChart();return}let e=this.getElement();if(!e||typeof e.getContext!=="function")return;let t=e.clientWidth||0,n=e.clientHeight||0;if(t<=0||n<=0)return;if(!this.chart){this.attachChart();return}let r=N();e.width=Math.round(t*r),e.height=Math.round(n*r),this.chart.resize(t,n,r).render()}resolveContext(){if(this.props.resolve)return Promise.resolve(this.props.resolve(this.getElement()));let e=B();if(e){let n=`#${this.state.canvasId}`,r=(o)=>ie({platform:e,instance:this,selector:n}).then((i)=>_(i)).catch((i)=>{if(o<=0)throw i;return new Promise((s)=>setTimeout(s,50)).then(()=>r(o-1))});return r(5)}let t=this.getElement();if(!t||typeof t.getContext!=="function")return Promise.resolve(null);return Promise.resolve(z(t))}}export{ne as BarChart,ee as CategoryScale,M as ChartBase,je as DEFAULT_AXIS_COLOR,Z as DEFAULT_FONT_FAMILY,ge as DEFAULT_GRID_COLOR,Be as DEFAULT_PALETTE,W as DEFAULT_TEXT_COLOR,te as LineChart,U as LinearScale,re as PieChart,oe as RadarChart,ft as TcChart,ye as computeLayout,K as createChart,Pt as createMiniProgramChart,St as createWebChart,be as debounce,Re as detectMiniProgramPixelRatio,N as detectPixelRatio,ie as getMiniProgramCanvasNode,I as getMiniProgramGlobal,mt as isCanvas2DLike,_e as niceTicks,_ as resolveMiniProgramCanvas,Ve as resolveNativeCanvas,z as resolveWebCanvas};
15
15
 
16
- //# debugId=71613FE96B28FF3C64756E2164756E21
16
+ //# debugId=C0BA9A665096526164756E2164756E21
17
17
  //# sourceMappingURL=index.js.map