sldeditor 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/auto-layout.d.ts.map +1 -1
- package/dist/i18n/library.d.ts.map +1 -1
- package/dist/sldeditor.cjs +47 -47
- package/dist/sldeditor.cjs.map +1 -1
- package/dist/sldeditor.js +5657 -5210
- package/dist/sldeditor.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/sldeditor.cjs
CHANGED
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Nw=Object.defineProperty;var Mw=(e,t,n)=>t in e?Nw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var dt=(e,t,n)=>Mw(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),I=require("react"),mr=require("react-dom");function Tw(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const we=Tw(I);/**
|
|
2
2
|
* @license lucide-react v0.469.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Aw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),fr=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.469.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var
|
|
11
|
+
*/var Cw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
12
12
|
* @license lucide-react v0.469.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Iw=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>I.createElement("svg",{ref:l,...Cw,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:fr("lucide",r),...a},[...i.map(([d,u])=>I.createElement(d,u)),...Array.isArray(s)?s:[s]]));/**
|
|
17
17
|
* @license lucide-react v0.469.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Q=(e,t)=>{const n=I.forwardRef(({className:o,...r},s)=>I.createElement(Iw,{ref:s,iconNode:t,className:fr(`lucide-${Aw(e)}`,o),...r}));return n.displayName=`${e}`,n};/**
|
|
22
22
|
* @license lucide-react v0.469.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const hr=Q("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/**
|
|
27
27
|
* @license lucide-react v0.469.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Pw=Q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
32
32
|
* @license lucide-react v0.469.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const pr=Q("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
37
37
|
* @license lucide-react v0.469.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const gr=Q("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
42
42
|
* @license lucide-react v0.469.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Ow=Q("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
47
47
|
* @license lucide-react v0.469.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const xn=Q("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
52
52
|
* @license lucide-react v0.469.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const Bw=Q("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/**
|
|
57
57
|
* @license lucide-react v0.469.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const Lw=Q("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
|
|
62
62
|
* @license lucide-react v0.469.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const zw=Q("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
|
|
67
67
|
* @license lucide-react v0.469.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const Rw=Q("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
|
|
72
72
|
* @license lucide-react v0.469.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const yr=Q("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/**
|
|
77
77
|
* @license lucide-react v0.469.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const lo=Q("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
|
82
82
|
* @license lucide-react v0.469.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const Dw=Q("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
|
|
87
87
|
* @license lucide-react v0.469.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const Fw=Q("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
|
|
92
92
|
* @license lucide-react v0.469.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
96
|
+
*/const Lt=Q("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
97
97
|
* @license lucide-react v0.469.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const xr=Q("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
|
|
102
102
|
* @license lucide-react v0.469.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const Hw=Q("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
107
107
|
* @license lucide-react v0.469.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const Pn=Q("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
112
112
|
* @license lucide-react v0.469.0 - ISC
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
116
|
+
*/const Ww=Q("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
|
|
117
117
|
* @license lucide-react v0.469.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const qw=Q("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/**
|
|
122
122
|
* @license lucide-react v0.469.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
125
125
|
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const
|
|
126
|
+
*/const Gw=Q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
127
127
|
* @license lucide-react v0.469.0 - ISC
|
|
128
128
|
*
|
|
129
129
|
* This source code is licensed under the ISC license.
|
|
130
130
|
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const
|
|
131
|
+
*/const On=Q("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
|
|
132
132
|
* @license lucide-react v0.469.0 - ISC
|
|
133
133
|
*
|
|
134
134
|
* This source code is licensed under the ISC license.
|
|
135
135
|
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const
|
|
136
|
+
*/const br=Q("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
137
137
|
* @license lucide-react v0.469.0 - ISC
|
|
138
138
|
*
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
140
140
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const
|
|
141
|
+
*/const co=Q("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
|
142
142
|
* @license lucide-react v0.469.0 - ISC
|
|
143
143
|
*
|
|
144
144
|
* This source code is licensed under the ISC license.
|
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const
|
|
146
|
+
*/const wr=Q("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
|
|
147
147
|
* @license lucide-react v0.469.0 - ISC
|
|
148
148
|
*
|
|
149
149
|
* This source code is licensed under the ISC license.
|
|
150
150
|
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const
|
|
151
|
+
*/const Kw=Q("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
152
152
|
* @license lucide-react v0.469.0 - ISC
|
|
153
153
|
*
|
|
154
154
|
* This source code is licensed under the ISC license.
|
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const
|
|
156
|
+
*/const vr=Q("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
|
|
157
157
|
* @license lucide-react v0.469.0 - ISC
|
|
158
158
|
*
|
|
159
159
|
* This source code is licensed under the ISC license.
|
|
160
160
|
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const
|
|
161
|
+
*/const Xw=Q("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
|
|
162
162
|
* @license lucide-react v0.469.0 - ISC
|
|
163
163
|
*
|
|
164
164
|
* This source code is licensed under the ISC license.
|
|
165
165
|
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const
|
|
166
|
+
*/const Vw=Q("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/**
|
|
167
167
|
* @license lucide-react v0.469.0 - ISC
|
|
168
168
|
*
|
|
169
169
|
* This source code is licensed under the ISC license.
|
|
170
170
|
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const
|
|
171
|
+
*/const kr=Q("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
172
172
|
* @license lucide-react v0.469.0 - ISC
|
|
173
173
|
*
|
|
174
174
|
* This source code is licensed under the ISC license.
|
|
175
175
|
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const
|
|
176
|
+
*/const _r=Q("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
|
177
177
|
* @license lucide-react v0.469.0 - ISC
|
|
178
178
|
*
|
|
179
179
|
* This source code is licensed under the ISC license.
|
|
180
180
|
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const
|
|
181
|
+
*/const Bn=Q("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
|
182
182
|
* @license lucide-react v0.469.0 - ISC
|
|
183
183
|
*
|
|
184
184
|
* This source code is licensed under the ISC license.
|
|
185
185
|
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const
|
|
186
|
+
*/const bt=Q("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
|
|
187
187
|
* @license lucide-react v0.469.0 - ISC
|
|
188
188
|
*
|
|
189
189
|
* This source code is licensed under the ISC license.
|
|
190
190
|
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const Tn=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function lr(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=lr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function ar(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=lr(e))&&(o&&(o+=" "),o+=t);return o}const Mn="-",Aw=e=>{const t=Iw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const l=i.split(Mn);return l[0]===""&&l.length!==1&&l.shift(),cr(l,t)||Cw(i)},getConflictingClassGroupIds:(i,l)=>{const a=n[i]||[];return l&&o[i]?[...a,...o[i]]:a}}},cr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?cr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(Mn);return(i=t.validators.find(({validator:l})=>l(s)))==null?void 0:i.classGroupId},Yn=/^\[(.+)\]$/,Cw=e=>{if(Yn.test(e)){const t=Yn.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Iw=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return Pw(Object.entries(e.classGroups),n).forEach(([s,i])=>{un(i,o,s,t)}),o},un=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:Kn(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(Ow(r)){un(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{un(i,Kn(t,s),n,o)})})},Kn=(e,t)=>{let n=e;return t.split(Mn).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},Ow=e=>e.isThemeGetter,Pw=(e,t)=>t?e.map(([n,o])=>{const r=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,l])=>[t+i,l])):s);return[n,r]}):e,Bw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return r(s,i),i},set(s,i){n.has(s)?n.set(s,i):r(s,i)}}},dr="!",Lw=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=l=>{const a=[];let d=0,u=0,m;for(let x=0;x<l.length;x++){let v=l[x];if(d===0){if(v===r&&(o||l.slice(x,x+s)===t)){a.push(l.slice(u,x)),u=x+s;continue}if(v==="/"){m=x;continue}}v==="["?d++:v==="]"&&d--}const h=a.length===0?l:l.substring(u),g=h.startsWith(dr),f=g?h.substring(1):h,p=m&&m>u?m-u:void 0;return{modifiers:a,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:p}};return n?l=>n({className:l,parseClassName:i}):i},zw=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},Rw=e=>({cache:Bw(e.cacheSize),parseClassName:Lw(e),...Aw(e)}),Dw=/\s+/,Fw=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(Dw);let l="";for(let a=i.length-1;a>=0;a-=1){const d=i[a],{modifiers:u,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:g}=n(d);let f=!!g,p=o(f?h.substring(0,g):h);if(!p){if(!f){l=d+(l.length>0?" "+l:l);continue}if(p=o(h),!p){l=d+(l.length>0?" "+l:l);continue}f=!1}const x=zw(u).join(":"),v=m?x+dr:x,b=v+p;if(s.includes(b))continue;s.push(b);const k=r(p,f);for(let $=0;$<k.length;++$){const M=k[$];s.push(v+M)}l=d+(l.length>0?" "+l:l)}return l};function Hw(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=ur(t))&&(o&&(o+=" "),o+=n);return o}const ur=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=ur(e[o]))&&(n&&(n+=" "),n+=t);return n};function Ww(e,...t){let n,o,r,s=i;function i(a){const d=t.reduce((u,m)=>m(u),e());return n=Rw(d),o=n.cache.get,r=n.cache.set,s=l,l(a)}function l(a){const d=o(a);if(d)return d;const u=Fw(a,n);return r(a,u),u}return function(){return s(Hw.apply(null,arguments))}}const re=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},mr=/^\[(?:([a-z-]+):)?(.+)\]$/i,qw=/^\d+\/\d+$/,Gw=new Set(["px","full","screen"]),Yw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Kw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Xw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Vw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Uw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oe=e=>et(e)||Gw.has(e)||qw.test(e),De=e=>ot(e,"length",r2),et=e=>!!e&&!Number.isNaN(Number(e)),Zt=e=>ot(e,"number",et),lt=e=>!!e&&Number.isInteger(Number(e)),Zw=e=>e.endsWith("%")&&et(e.slice(0,-1)),G=e=>mr.test(e),Fe=e=>Yw.test(e),Qw=new Set(["length","size","percentage"]),Jw=e=>ot(e,Qw,fr),e2=e=>ot(e,"position",fr),t2=new Set(["image","url"]),n2=e=>ot(e,t2,i2),o2=e=>ot(e,"",s2),at=()=>!0,ot=(e,t,n)=>{const o=mr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},r2=e=>Kw.test(e)&&!Xw.test(e),fr=()=>!1,s2=e=>Vw.test(e),i2=e=>Uw.test(e),l2=()=>{const e=re("colors"),t=re("spacing"),n=re("blur"),o=re("brightness"),r=re("borderColor"),s=re("borderRadius"),i=re("borderSpacing"),l=re("borderWidth"),a=re("contrast"),d=re("grayscale"),u=re("hueRotate"),m=re("invert"),h=re("gap"),g=re("gradientColorStops"),f=re("gradientColorStopPositions"),p=re("inset"),x=re("margin"),v=re("opacity"),b=re("padding"),k=re("saturate"),$=re("scale"),M=re("sepia"),B=re("skew"),te=re("space"),J=re("translate"),ve=()=>["auto","contain","none"],fe=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto",G,t],I=()=>[G,t],se=()=>["",Oe,De],oe=()=>["auto",et,G],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],X=()=>["solid","dashed","dotted","double","none"],ue=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>["start","end","center","between","around","evenly","stretch"],he=()=>["","0",G],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],xe=()=>[et,G];return{cacheSize:500,separator:":",theme:{colors:[at],spacing:[Oe,De],blur:["none","",Fe,G],brightness:xe(),borderColor:[e],borderRadius:["none","","full",Fe,G],borderSpacing:I(),borderWidth:se(),contrast:xe(),grayscale:he(),hueRotate:xe(),invert:he(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Zw,De],inset:N(),margin:N(),opacity:xe(),padding:I(),saturate:xe(),scale:xe(),sepia:he(),skew:xe(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",G]}],container:["container"],columns:[{columns:[Fe]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...de(),G]}],overflow:[{overflow:fe()}],"overflow-x":[{"overflow-x":fe()}],"overflow-y":[{"overflow-y":fe()}],overscroll:[{overscroll:ve()}],"overscroll-x":[{"overscroll-x":ve()}],"overscroll-y":[{"overscroll-y":ve()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",lt,G]}],basis:[{basis:N()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",G]}],grow:[{grow:he()}],shrink:[{shrink:he()}],order:[{order:["first","last","none",lt,G]}],"grid-cols":[{"grid-cols":[at]}],"col-start-end":[{col:["auto",{span:["full",lt,G]},G]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[at]}],"row-start-end":[{row:["auto",{span:[lt,G]},G]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",G]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",G]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...ae()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ae(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ae(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[te]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[te]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",G,t]}],"min-w":[{"min-w":[G,t,"min","max","fit"]}],"max-w":[{"max-w":[G,t,"none","full","min","max","fit","prose",{screen:[Fe]},Fe]}],h:[{h:[G,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[G,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[G,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[G,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Fe,De]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Zt]}],"font-family":[{font:[at]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",G]}],"line-clamp":[{"line-clamp":["none",et,Zt]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oe,G]}],"list-image":[{"list-image":["none",G]}],"list-style-type":[{list:["none","disc","decimal",G]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oe,De]}],"underline-offset":[{"underline-offset":["auto",Oe,G]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",G]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",G]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...de(),e2]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Jw]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},n2]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[f]}],"gradient-via-pos":[{via:[f]}],"gradient-to-pos":[{to:[f]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...X(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:X()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...X()]}],"outline-offset":[{"outline-offset":[Oe,G]}],"outline-w":[{outline:[Oe,De]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Oe,De]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Fe,o2]}],"shadow-color":[{shadow:[at]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...ue(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ue()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Fe,G]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[m]}],saturate:[{saturate:[k]}],sepia:[{sepia:[M]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[M]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",G]}],duration:[{duration:xe()}],ease:[{ease:["linear","in","out","in-out",G]}],delay:[{delay:xe()}],animate:[{animate:["none","spin","ping","pulse","bounce",G]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[$]}],"scale-x":[{"scale-x":[$]}],"scale-y":[{"scale-y":[$]}],rotate:[{rotate:[lt,G]}],"translate-x":[{"translate-x":[J]}],"translate-y":[{"translate-y":[J]}],"skew-x":[{"skew-x":[B]}],"skew-y":[{"skew-y":[B]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",G]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",G]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",G]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Oe,De,Zt]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},a2=Ww(l2);function we(...e){return a2(ar(e))}const hr=S.createContext(null);function c2(){const e=S.useContext(hr);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Et=8;function d2({children:e}){const[t,n]=S.useState({open:!1,x:0,y:0,items:[]}),[o,r]=S.useState(null),s=S.useRef(null),i=S.useCallback(()=>{n(d=>d.open?{...d,open:!1}:d)},[]),l=S.useCallback((d,u,m)=>{r(null),n({open:!0,x:d,y:u,items:m})},[]),a=S.useMemo(()=>({open:l,close:i}),[l,i]);return S.useLayoutEffect(()=>{if(!t.open||!s.current)return;const d=s.current.getBoundingClientRect();let u=t.x,m=t.y;u+d.width>window.innerWidth-Et&&(u=Math.max(Et,t.x-d.width)),m+d.height>window.innerHeight-Et&&(m=Math.max(Et,t.y-d.height)),r({left:u,top:m})},[t]),S.useEffect(()=>{if(!t.open)return;const d=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},m=()=>i(),h=()=>i();return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",m,{passive:!0}),window.addEventListener("blur",h),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",m),window.removeEventListener("blur",h)}},[t.open,i]),c.jsxs(hr.Provider,{value:a,children:[e,t.open&&c.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:d=>d.preventDefault(),children:t.items.map((d,u)=>{if(d.type==="separator")return c.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const m=d.icon;return c.jsxs("button",{type:"button",role:"menuitem",disabled:d.disabled,className:we("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",d.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",d.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),d.onSelect()},children:[c.jsxs("span",{className:"flex items-center gap-2",children:[m?c.jsx(m,{className:"size-4"}):null,c.jsx("span",{children:d.label})]}),d.shortcut?c.jsx("span",{className:"text-xs text-muted-foreground",children:d.shortcut}):null]},`${d.label}-${u}`)})})]})}const Xn=e=>{let t;const n=new Set,o=(d,u)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const h=t;t=u??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>a,subscribe:d=>(n.add(d),()=>n.delete(d))},a=t=e(o,r,l);return l},u2=(e=>e?Xn(e):Xn),m2=e=>e;function f2(e,t=m2){const n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}const Vn=e=>{const t=u2(e),n=o=>f2(t,o);return Object.assign(n,t),n},Ft=(e=>e?Vn(e):Vn),Un={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从一个端子拖动到另一个端子完成连线","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到另一个端子或母线上释放完成连线","mode.wireInit":"从端子按下,拖动到另一个端子或母线上释放","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"画母线","onboard.step1.body":"选择 母线 工具(B),在画布上按下拖动","onboard.step2.title":"从母线拖出元件","onboard.step2.body":"切到 元件(P)选一种,按住母线拖到目标位置 — 自动连接","onboard.step3.title":"继续串接","onboard.step3.body":"从任意端子拖出,落到目标即与该端子相连","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from one terminal to another to wire","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on another terminal or busbar to complete the wire","mode.wireInit":"Press on a terminal, drag to another terminal or busbar, release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Draw a busbar","onboard.step1.body":"Pick the busbar tool (B), then press and drag on the canvas","onboard.step2.title":"Drag elements from the bus","onboard.step2.body":"Switch to Place (P), pick a kind, then drag from the bus — it auto-connects","onboard.step3.title":"Chain the next one","onboard.step3.body":"Drag from any terminal — the new element drops pre-connected","onboard.dismiss":"Got it"}},pr="ole-locale";function h2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(pr);if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&typeof navigator.language=="string"?navigator.language.toLowerCase().startsWith("zh")?"zh":"en":"zh"}function Zn(e){try{window.localStorage.setItem(pr,e)}catch{}}const _t=Ft((e,t)=>({locale:h2(),setLocale:n=>{Zn(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Zn(n),e({locale:n})}}));function gr(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function yr(e,t){return Un[e][t]??Un.zh[t]??t}function be(e,t){return gr(yr(_t.getState().locale,e),t)}function Z(){const e=_t(t=>t.locale);return(t,n)=>gr(yr(e,t),n)}function xr(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var s;const i=a=>a===null?null:JSON.parse(a,void 0),l=(s=n.getItem(r))!=null?s:null;return l instanceof Promise?l.then(i):i(l)},setItem:(r,s)=>n.setItem(r,JSON.stringify(s,void 0)),removeItem:r=>n.removeItem(r)}}const mn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return mn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return mn(o)(n)}}}},p2=(e,t)=>(n,o,r)=>{let s={storage:xr(()=>window.localStorage),partialize:x=>x,version:0,merge:(x,v)=>({...v,...x}),...t},i=!1,l=0;const a=new Set,d=new Set;let u=s.storage;if(!u)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...x)},o,r);const m=()=>{const x=s.partialize({...o()});return u.setItem(s.name,{state:x,version:s.version})},h=r.setState;r.setState=(x,v)=>(h(x,v),m());const g=e((...x)=>(n(...x),m()),o,r);r.getInitialState=()=>g;let f;const p=()=>{var x,v;if(!u)return;const b=++l;i=!1,a.forEach($=>{var M;return $((M=o())!=null?M:g)});const k=((v=s.onRehydrateStorage)==null?void 0:v.call(s,(x=o())!=null?x:g))||void 0;return mn(u.getItem.bind(u))(s.name).then($=>{if($)if(typeof $.version=="number"&&$.version!==s.version){if(s.migrate){const M=s.migrate($.state,$.version);return M instanceof Promise?M.then(B=>[!0,B]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,$.state];return[!1,void 0]}).then($=>{var M;if(b!==l)return;const[B,te]=$;if(f=s.merge(te,(M=o())!=null?M:g),n(f,!0),B)return m()}).then(()=>{b===l&&(k==null||k(o(),void 0),f=o(),i=!0,d.forEach($=>$(f)))}).catch($=>{b===l&&(k==null||k(void 0,$))})};return r.persist={setOptions:x=>{s={...s,...x},x.storage&&(u=x.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>p(),hasHydrated:()=>i,onHydrate:x=>(a.add(x),()=>{a.delete(x)}),onFinishHydration:x=>(d.add(x),()=>{d.delete(x)})},s.skipHydration||p(),f||g},g2=p2,Pe=.5;function br(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<Pe&&Math.abs(s[1]-e[r][1])<Pe||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],l=Math.abs(s[0]-i[0]),a=Math.abs(s[1]-i[1]);if(l>Pe&&a>Pe){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Pe?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],l=n[r+1],a=Math.abs(s[0]-i[0])<Pe&&Math.abs(i[0]-l[0])<Pe,d=Math.abs(s[1]-i[1])<Pe&&Math.abs(i[1]-l[1])<Pe;a||d||o.push(i)}return o.push(n[n.length-1]),o}function wr(){return{elements:new Map,buses:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function vr(e){return{at:(e==null?void 0:e.at)??[0,0],rot:(e==null?void 0:e.rot)??0,mirror:(e==null?void 0:e.mirror)??!1}}function fn(e){return e===90||e===270?"y":"x"}function Be(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const y2={n:"e",e:"s",s:"w",w:"n"},x2={n:"n",s:"s",e:"w",w:"e"};function yt(e,t){let n=t.mirror?x2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=y2[n];return n}function hn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class kr{constructor(){it(this,"parent",new Map);it(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const Qn=["n","e","s","w"],Jn={n:"s",s:"n",e:"w",w:"e"};function eo(e,t){const n=Qn.indexOf(e),r=((Qn.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const b2=320,to=220,ct=260,no=720,dt=30,oo=30,ut=80,ro=10,w2=60,v2=520,k2=80,_2=80,so=8,io=new Set(["source","renewable"]);function $2(e){var zn,Rn,Dn,Fn,Hn,Wn;const{elements:t,buses:n,wires:o,library:r,userLayout:s,userBusLayout:i}=e,l=new Map(s),a=new Map(i),d=new Map;for(const w of t)d.set(w.id,w);const u=new Map;for(const w of n)u.set(w.id,w);const m=w=>{const _=d.get(w);if(_)return r.get(_.kind)},h=new Set(n.map(w=>w.id)),g=w=>h.has(w),f=new kr;for(const w of o)f.add(w.ends[0]),f.add(w.ends[1]),f.union(w.ends[0],w.ends[1]);for(const w of t){const _=r.get(w.kind);if(_)for(const j of _.terminals)f.add(`${w.id}.${j.id}`)}for(const w of n)f.add(w.id);const p=[];for(const[,w]of f.groups())w.length>=2&&p.push(w);const x=new Map;for(const w of p)for(const _ of w)x.set(_,[w]);const v=new Map;for(const w of p){const _=w.filter(g);if(_.length!==0)for(const j of _){const T=w.filter(E=>E!==j),L=v.get(j)??[];L.push(...T),v.set(j,L)}}const b=new Map;for(const w of p){const _=w.filter(g);if(_.length!==0)for(const j of w){if(g(j))continue;const T=j.indexOf(".");if(T<0)continue;const L=j.slice(0,T),E=j.slice(T+1),C=b.get(L)??[];for(const R of _)C.some(O=>O.busId===R&&O.pin===E)||C.push({busId:R,pin:E});b.set(L,C)}}const k=[],$=new Set;for(const[w,_]of b)if(new Set(_.map(T=>T.busId)).size>=2){const T=((Rn=r.get(((zn=d.get(w))==null?void 0:zn.kind)??""))==null?void 0:Rn.category)==="transformer"?"vertical":"horizontal";k.push({elementId:w,attachments:_,orientation:T}),T==="vertical"&&$.add(w)}const M=new Map,B=(w,_)=>{w!==_&&(M.has(w)||M.set(w,new Set),M.has(_)||M.set(_,new Set),M.get(w).add(_),M.get(_).add(w))};for(const w of o)B(w.ends[0],w.ends[1]);for(const w of t){const _=r.get(w.kind);if(!_||_.terminals.length<2)continue;const j=_.terminals.map(T=>`${w.id}.${T.id}`);for(let T=0;T<j.length;T++)for(let L=T+1;L<j.length;L++)B(j[T],j[L])}for(const w of t){if($.has(w.id))continue;const _=r.get(w.kind);if(!_||_.category!=="transformer"||_.terminals.length<2)continue;const j=_.terminals.map(E=>`${w.id}.${E.id}`),T=new Map;for(const E of j){const C=E.slice(w.id.length+1);T.set(C,new Set);const R=new Set(j.filter(D=>D!==E)),O=new Set([E]),H=[E];for(;H.length>0;){const D=H.shift();if(g(D)){T.get(C).add(D);continue}const A=M.get(D);if(A)for(const P of A)O.has(P)||R.has(P)||(O.add(P),H.push(P))}}const L=new Set;for(const E of T.values())for(const C of E)L.add(C);if(L.size>=2){const E=[];for(const[C,R]of T)for(const O of R)E.push({busId:O,pin:C});k.push({elementId:w.id,attachments:E,orientation:"vertical"}),$.add(w.id)}}const te=(w,_)=>{var R;const j=m(_),T=j?j.terminals.map(O=>`${_}.${O.id}`):[],L=w,E=new Set([L,...T]),C=[L];for(;C.length>0;){const O=C.shift(),H=O.indexOf(".");if(H>0){const A=O.slice(0,H),P=d.get(A);if(P){const z=(R=r.get(P.kind))==null?void 0:R.category;if(z&&io.has(z))return!0}}const D=M.get(O);if(D)for(const A of D)E.has(A)||(E.add(A),C.push(A))}return!1};for(const w of k){if(w.orientation!=="horizontal")continue;const _=new Set(w.attachments.map(T=>T.busId));let j=0;for(const T of _)te(T,w.elementId)&&j++;j===1&&(w.orientation="vertical",$.add(w.elementId))}for(const w of t){if($.has(w.id)||w.kind!=="breaker")continue;const _=r.get(w.kind);if(!_||_.terminals.length!==2)continue;const j=_.terminals.map(E=>`${w.id}.${E.id}`),T=new Map;for(const E of j){const C=E.slice(w.id.length+1),R=new Set(j.filter(D=>D!==E)),O=new Set([E]),H=[E];for(;H.length>0;){const D=H.shift();if(g(D)){T.set(C,D);break}const A=M.get(D);if(A)for(const P of A){if(O.has(P)||R.has(P))continue;const z=P.indexOf(".");if(z>0){const q=P.slice(0,z);if(q!==w.id){const ee=d.get(q),Q=ee?r.get(ee.kind):void 0;if((Q==null?void 0:Q.category)==="transformer")continue}}O.add(P),H.push(P)}}}if(new Set(T.values()).size>=2){const E=[];for(const[C,R]of T)E.push({busId:R,pin:C});k.push({elementId:w.id,attachments:E,orientation:"horizontal"})}}const J=new Map;for(const w of n)J.set(w.id,new Map);for(const w of k){const _=Array.from(new Set(w.attachments.map(j=>j.busId)));for(const j of _)for(const T of _)j!==T&&((Dn=J.get(j))==null||Dn.set(T,w))}const ve=w=>{var j;const _=(j=r.get(w))==null?void 0:j.category;return _?io.has(_):!1},fe=[];for(const w of n){const _=v.get(w.id);if(_)for(const j of _){if(g(j))continue;const T=j.indexOf(".");if(T<0)continue;const L=j.slice(0,T),E=d.get(L);if(E&&ve(E.kind)){fe.push(w.id);break}}}fe.length===0&&n.length>0&&fe.push(n[0].id);const N=new Map;for(const w of fe)N.set(w,0);{const w=[...fe];for(;w.length>0;){const _=w.shift(),j=N.get(_),T=J.get(_);if(T)for(const[L,E]of T){if(N.has(L))continue;const C=E.orientation==="horizontal"?j:j+1;N.set(L,C),w.push(L)}}}for(const w of n){if(N.has(w.id))continue;const _=N.size===0?-1:Math.max(...Array.from(N.values()));N.set(w.id,_+1)}const I=new Map;for(const w of n){const _=N.get(w.id),j=I.get(_)??[];j.push(w.id),I.set(_,j)}const se=[...I.keys()].sort((w,_)=>w-_),oe=(w,_,j)=>{const T=`${w.elementId}.${j}`,L=_,E=m(w.elementId),C=new Set;if(E)for(const A of E.terminals)A.id!==j&&C.add(`${w.elementId}.${A.id}`);const R=new Set([T]),O=[{ref:T,dist:0}],H=new Map,D=(A,P,z,q)=>{R.add(A),H.set(A,P),O.push({ref:A,dist:q+z})};for(;O.length>0;){const{ref:A,dist:P}=O.shift();if(A===L){const Q=H.get(L);let ce;if(Q){const Y=Q.indexOf(".");if(Y>0){const F=Q.slice(0,Y);F!==w.elementId&&(ce=F)}}return{extent:P,head:ce}}const z=A.indexOf(".");if(z<0)continue;const q=A.slice(0,z),ee=A.slice(z+1);if(!g(q)&&!$.has(q)){const Q=m(q),ce=Q==null?void 0:Q.terminals.find(Y=>Y.id===ee);if(Q&&ce)for(const Y of Q.terminals){if(Y.id===ee)continue;const F=`${q}.${Y.id}`;R.has(F)||C.has(F)||D(F,A,Math.abs(ce.y-Y.y),P)}}for(const Q of x.get(A)??[])for(const ce of Q){if(ce===A||R.has(ce)||C.has(ce))continue;const Y=g(A)||g(ce);D(ce,A,Y?oo:dt,P)}}return{extent:0}},de=(w,_)=>{var A,P,z;const j=(A=J.get(w))==null?void 0:A.get(_);if(!j||j.orientation==="horizontal")return ct;const T=m(j.elementId);if(!T)return ct;const L=(P=j.attachments.find(q=>q.busId===w))==null?void 0:P.pin,E=(z=j.attachments.find(q=>q.busId===_))==null?void 0:z.pin;if(!L||!E)return ct;const C=T.terminals.find(q=>q.id===L),R=T.terminals.find(q=>q.id===E);if(!C||!R)return ct;const O=Math.abs(R.y-C.y),H=oe(j,w,L).extent,D=oe(j,_,E).extent;return H+O+D},X=new Map;for(const w of k){if(w.orientation!=="vertical")continue;const _=w.attachments.slice().sort((R,O)=>(N.get(R.busId)??0)-(N.get(O.busId)??0));if(_.length<2)continue;const j=_[0].busId,T=_[1].busId,L=_[0].pin,C=oe(w,j,L).head??w.elementId;X.set(C,{lowerBusId:T})}const ue=320,ae=new Map,he=(w,_)=>{if(!$.has(w))return!1;const j=k.find(C=>C.elementId===w),T=j==null?void 0:j.attachments.find(C=>C.busId!==_);if(!T)return!1;const L=N.get(_)??0;return(N.get(T.busId)??0)<L},ke=(w,_)=>{const j=X.get(w);if(j){const T=ae.get(j.lowerBusId);if(T!==void 0)return Math.max(_,T+ut)}return Math.max(_,ut)},xe=(w,_)=>{if(ae.has(w))return ae.get(w);if(_.has(w))return ue;_.add(w);const j=v.get(w)??[];let T=0,L=0;for(const C of j){if(g(C))continue;const R=C.indexOf(".");if(R<0)continue;const O=C.slice(0,R),H=C.slice(R+1);if(he(O,w))continue;const D=m(O);if(!D)continue;const A=D.terminals.find(q=>q.id===H);if(!A)continue;const P=X.get(O);P&&xe(P.lowerBusId,_);const z=ke(O,D.width);A.y>0?T+=z:L+=z}const E=Math.max(ue,Math.max(T,L)+ut);return ae.set(w,E),_.delete(w),E};for(const w of n)xe(w.id,new Set);const Re=new Map,nw=(w,_,j)=>{const T=m(_);if(!T)return;const L=`${_}.${j}`,E=T.terminals.filter(O=>O.id!==j).map(O=>`${_}.${O.id}`);if(E.length===0)return;const C=new Set([L,...E]),R=E.slice();for(;R.length>0;){const O=R.shift();if(g(O)&&O!==w){const D=a.get(O);return D?D.at[0]:void 0}for(const D of x.get(O)??[])for(const A of D)A===O||C.has(A)||(C.add(A),R.push(A));const H=O.indexOf(".");if(H>0){const D=O.slice(0,H);if(!g(D)){const A=m(D);if(A)for(const P of A.terminals){const z=`${D}.${P.id}`;C.has(z)||(C.add(z),R.push(z))}}}}},ow=w=>{const _=v.get(w);if(!_||_.length===0)return;const j=a.get(w);if(!j)return;const T=_.flatMap(A=>{if(g(A))return[];const P=A.indexOf(".");if(P<0)return[];const z=A.slice(0,P),q=A.slice(P+1);if(l.has(z))return[];if(he(z,w))return[];const ee=m(z);if(!ee)return[];const Q=ee.terminals.find(ce=>ce.id===q);return Q?[{elId:z,lib:ee,localTerm:Q,isLinker:$.has(z)}]:[]});if(T.length===0)return;const L=[],E=[];for(const A of T)A.localTerm.y>0?L.push(A):E.push(A);const C=A=>A.reduce((P,z)=>P+ke(z.elId,z.lib.width),0),R=Math.max(C(L),C(E))+ut,O=Math.max(j.span,R);O!==j.span&&a.set(w,{...j,span:O});const H=a.get(w),D=(A,P)=>{if(A.length===0)return;const z=new Map;for(const W of A){const K=nw(w,W.elId,W.localTerm.id);K!==void 0&&z.set(W.elId,K)}A.sort((W,K)=>{const me=z.get(W.elId)??H.at[0],_e=z.get(K.elId)??H.at[0];if(me!==_e)return me-_e;const Ce=ke(W.elId,W.lib.width);return ke(K.elId,K.lib.width)-Ce});const q=A.map(W=>ke(W.elId,W.lib.width)),ee=q.reduce((W,K)=>W+K,0),Q=Math.max(O,ee),ce=(Q-ee)/(A.length+1);let Y=H.at[0]-Q/2+ce;const F=H.at[1]+P*oo;for(let W=0;W<A.length;W++){const K=A[W],me=q[W],_e=Y+me/2;K.isLinker?Re.has(K.elId)||Re.set(K.elId,_e):l.set(K.elId,{at:[ge(_e-K.localTerm.x),ge(F-K.localTerm.y)],rot:0,mirror:!1}),Y+=me+ce}};D(L,-1),D(E,1)},rw=w=>{if(l.has(w.elementId)||w.orientation==="horizontal")return;const _=m(w.elementId);if(!_)return;const j=w.attachments.filter(Y=>a.has(Y.busId));if(j.length<2)return;const T=j.slice().sort((Y,F)=>(N.get(Y.busId)??0)-(N.get(F.busId)??0)),L=T[0].busId,E=a.get(L),C=T[0].pin,R=T[T.length-1].pin,O=_.terminals.find(Y=>Y.id===C),H=_.terminals.find(Y=>Y.id===R);if(!O||!H)return;const D=O.y<=H.y?0:180,A=N.get(L)??0,P=j.filter(Y=>(N.get(Y.busId)??0)===A),z=[];let q=0;for(const Y of P){const F=oe(w,Y.busId,Y.pin);q=Math.max(q,F.extent);const W=F.head?l.get(F.head):void 0;W?z.push(W.at[0]):Re.has(w.elementId)?z.push(Re.get(w.elementId)):z.push(a.get(Y.busId).at[0])}let ee;z.length>0?ee=z.reduce((Y,F)=>Y+F,0)/z.length:Re.has(w.elementId)?ee=Re.get(w.elementId):ee=E.at[0];const Q=E.at[1]+q,ce=D===0?[ge(ee-O.x),ge(Q-O.y)]:[ge(ee+O.x),ge(Q+O.y)];if(l.set(w.elementId,{at:ce,rot:D,mirror:!1}),P.length>1){const Y=l.get(w.elementId),F=Be([O.x,O.y],Y),W=yt(O.orientation,Y);sw(`${w.elementId}.${C}`,F,W,ee)}},sw=(w,_,j,T)=>{const L=new Set([w]);let E=w,C=_,R=j;for(;;){const O=x.get(E)??[];let H,D=!1;for(const Me of O){if(Me.length>=3){D=!0;break}const Xe=Me.find(Ut=>Ut!==E);if(!(!Xe||L.has(Xe))){if(g(Xe)){D=!0;break}H=Xe;break}}if(D||!H)break;const A=H.indexOf(".");if(A<0)break;const P=H.slice(0,A),z=H.slice(A+1);if(g(P)||$.has(P)||l.has(P))break;const q=m(P);if(!q)break;const ee=q.terminals.find(Me=>Me.id===z);if(!ee)break;const Q=hn(R),ce=[C[0]+Q[0]*dt,C[1]+Q[1]*dt],Y=Jn[R],F=eo(ee.orientation,Y),W=Be([ee.x,ee.y],{at:[0,0],rot:F,mirror:!1}),K=[ge(T-W[0]),ge(ce[1]-W[1])];l.set(P,{at:K,rot:F,mirror:!1}),L.add(H);const me=q.terminals.find(Me=>Me.id!==z);if(!me)break;const _e=`${P}.${me.id}`;L.add(_e);const Ce={at:K,rot:F,mirror:!1};C=Be([me.x,me.y],Ce),R=yt(me.orientation,Ce),E=_e}},iw=w=>{if(l.has(w.elementId)||w.orientation!=="horizontal")return;const _=m(w.elementId);if(!_)return;const j=w.attachments.filter(P=>a.has(P.busId));if(j.length<2)return;const T=j.map(P=>{const z=oe(w,P.busId,P.pin),q=z.head?l.get(z.head):void 0,ee=q?q.at[0]:a.get(P.busId).at[0];return{att:P,x:ee,extent:z.extent}});T.sort((P,z)=>P.x-z.x);const L=T[0],E=T[T.length-1],C=_.terminals.find(P=>P.id===L.att.pin),R=_.terminals.find(P=>P.id===E.att.pin);if(!C||!R)return;const O=C.y<=R.y?270:90,H=(L.x+E.x)/2,A=a.get(L.att.busId).at[1]+Math.max(L.extent,E.extent);l.set(w.elementId,{at:[ge(H),ge(A)],rot:O,mirror:!1})},lw=100;let jt=to;for(let w=0;w<se.length;w++){const _=se[w],j=I.get(_);let T;if(w===0)T=to;else{const E=I.get(se[w-1]);let C=0;for(const R of E)for(const O of j)(Fn=J.get(R))!=null&&Fn.get(O)&&(C=Math.max(C,de(R,O)));C===0&&(C=ct),T=jt+C}jt=T;let L=b2;for(const E of j){if(a.has(E)){jt=Math.max(jt,a.get(E).at[1]);continue}let C;if(w>0){const O=I.get(se[w-1]),H=[];for(const D of O){const A=(Hn=J.get(D))==null?void 0:Hn.get(E);if(!A||A.orientation!=="vertical")continue;const P=(Wn=A.attachments.find(q=>q.busId===D))==null?void 0:Wn.pin;if(!P)continue;const z=oe(A,D,P);z.head&&l.has(z.head)?H.push(l.get(z.head).at[0]):Re.has(A.elementId)?H.push(Re.get(A.elementId)):H.push(a.get(D).at[0])}H.length>0&&(C=H.reduce((D,A)=>D+A,0)/H.length)}if(C===void 0){const O=ae.get(E)??no;C=L+O/2,L+=O+lw}const R=ae.get(E)??no;a.set(E,{at:[ge(C),ge(T)],rot:0,span:R,axis:fn(0)})}for(const E of j)ow(E);if(w>0)for(const E of k)l.has(E.elementId)||!E.attachments.some(R=>j.includes(R.busId))||rw(E);for(const E of k)E.orientation!=="horizontal"||l.has(E.elementId)||!E.attachments.every(R=>j.includes(R.busId))||iw(E)}const aw=w=>{if(g(w))return a.has(w);const _=w.indexOf(".");return _<0?!1:l.has(w.slice(0,_))};let Xt=!0,cw=t.length+4;for(;Xt&&cw-- >0;){Xt=!1;for(const w of p){if(w.length<2)continue;const _=[],j=new Map;for(const F of w){if(g(F))continue;const W=F.indexOf(".");if(W<0)continue;const K=F.slice(0,W),me=F.slice(W+1);if(l.has(K)){_.push(F);continue}if($.has(K)||j.has(K))continue;const _e=m(K);if(!_e)continue;const Ce=_e.terminals.find(Me=>Me.id===me);Ce&&j.set(K,{ref:F,elId:K,lib:_e,localTerm:Ce})}if(j.size===0||_.length===0)continue;const T=[...j.values()],L=new Map;for(const F of T)for(const W of x.get(F.ref)??[])for(const K of W){if(K===F.ref||g(K)||!aw(K))continue;const me=K;L.set(me,(L.get(me)??0)+1)}let E;if(L.size>0){let F=-1;for(const[W,K]of L)(K>F||K===F&&(E===void 0||W<E))&&(F=K,E=W)}if(E||(E=[..._].sort()[0]),!E)continue;const C=E.indexOf("."),R=E.slice(0,C),O=E.slice(C+1),H=m(R),D=l.get(R);if(!H||!D)continue;const A=H.terminals.find(F=>F.id===O);if(!A)continue;const P=Be([A.x,A.y],D),z=yt(A.orientation,D),q=hn(z),ee=[-q[1],q[0]];T.sort((F,W)=>F.elId.localeCompare(W.elId));const Q=T.map(F=>Math.max(F.lib.width,ut));let Y=-Q.reduce((F,W)=>F+W,0)/2;for(let F=0;F<T.length;F++){const W=T[F],K=Q[F],me=Y+K/2;Y+=K;const _e=Jn[z],Ce=eo(W.localTerm.orientation,_e),Me=Be([W.localTerm.x,W.localTerm.y],{at:[0,0],rot:Ce,mirror:!1}),Xe=[P[0]+q[0]*dt+ee[0]*me,P[1]+q[1]*dt+ee[1]*me],Ut=[ge(Xe[0]-Me[0]),ge(Xe[1]-Me[1])];l.set(W.elId,{at:Ut,rot:Ce,mirror:!1}),Xt=!0}}}let Vt=0;for(const w of t){if(l.has(w.id))continue;const _=Vt%so,j=Math.floor(Vt/so);l.set(w.id,{at:[ge(w2+_*k2),ge(v2+j*_2)],rot:0,mirror:!1}),Vt++}return{devices:l,buses:a}}function ge(e){return Math.round(e/ro)*ro}function S2(e,t){const n=e.ends[0],o=e.ends[1],r=lo(n,t),s=lo(o,t);if(r||s){const a=r?n:o,u=Qt(r?o:n,t);if(!u)return null;const m=t.buses.get(a);if(!m)return null;const{axis:h,at:g,span:f}=m.geometry,p=f/2;let x;if(h==="x")x=[Pt(u[0],g[0]-p,g[0]+p),g[1]];else{const v=Pt(u[1],g[1]-p,g[1]+p);x=[g[0],v]}return{wireId:e.id,path:co(u,x)}}const i=Qt(n,t),l=Qt(o,t);return!i||!l?null:{wireId:e.id,path:co(i,l)}}function lo(e,t){return!e.includes(".")&&t.buses.has(e)}function Qt(e,t){if(!e.includes(".")){const o=t.buses.get(e);return o?o.geometry.at:null}const n=t.terminals.get(e);return n?n.world:null}function ao(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r)return null;const{axis:s,at:i,span:l}=r.geometry;if(!t)return[i[0],i[1]];const a=l/2;if(s==="x")return[Pt(t[0],i[0]-a,i[0]+a),i[1]];const d=Pt(t[1],i[1]-a,i[1]+a);return[i[0],d]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function co(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Pt(e,t,n){return e<t?t:e>n?n:e}const _r="ammeter",$r="电流表 (A)",Sr="measurement",jr="-22 -42 44 44",Er=44,Nr=44,Tr='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-15" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">A</text>',Mr=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ar={kind:"inline"},j2={id:_r,name:$r,category:Sr,viewBox:jr,width:Er,height:Nr,svg:Tr,terminals:Mr,source:Ar},E2=Object.freeze(Object.defineProperty({__proto__:null,category:Sr,default:j2,height:Nr,id:_r,name:$r,source:Ar,svg:Tr,terminals:Mr,viewBox:jr,width:Er},Symbol.toStringTag,{value:"Module"})),Cr="arc-suppression-coil",Ir="消弧线圈",Or="grounding",Pr="中性点谐振接地:电感线圈连接到地",Br="-12 -32 24 67",Lr=24,zr=67,Rr='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',Dr=[{id:"t_top",x:0,y:-30,orientation:"n"}],Fr={kind:"inline"},N2={id:Cr,name:Ir,category:Or,description:Pr,viewBox:Br,width:Lr,height:zr,svg:Rr,terminals:Dr,source:Fr},T2=Object.freeze(Object.defineProperty({__proto__:null,category:Or,default:N2,description:Pr,height:zr,id:Cr,name:Ir,source:Fr,svg:Rr,terminals:Dr,viewBox:Br,width:Lr},Symbol.toStringTag,{value:"Module"})),Hr="arrester",Wr="避雷器 (FBL)",qr="protection",Gr="-7 -22 14 44",Yr=14,Kr=44,Xr='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Vr=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ur={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},M2={id:Hr,name:Wr,category:qr,viewBox:Gr,width:Yr,height:Kr,svg:Xr,terminals:Vr,source:Ur},A2=Object.freeze(Object.defineProperty({__proto__:null,category:qr,default:M2,height:Kr,id:Hr,name:Wr,source:Ur,svg:Xr,terminals:Vr,viewBox:Gr,width:Yr},Symbol.toStringTag,{value:"Module"})),Zr="async-motor",Qr="异步电动机",Jr="load",es="-62 -82 64 84",ts=64,ns=84,os='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',rs=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],ss={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},C2={id:Zr,name:Qr,category:Jr,viewBox:es,width:ts,height:ns,svg:os,terminals:rs,source:ss},I2=Object.freeze(Object.defineProperty({__proto__:null,category:Jr,default:C2,height:ns,id:Zr,name:Qr,source:ss,svg:os,terminals:rs,viewBox:es,width:ts},Symbol.toStringTag,{value:"Module"})),is="autotransformer",ls="自耦变压器",as="transformer",cs="-62 -112 64 144",ds=64,us=144,ms='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-110" x2="-30" y2="-90" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -30 A 30 60 0 0 0 -30 -90" fill="none" stroke="black" stroke-width="1"/>',fs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],hs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},O2={id:is,name:ls,category:as,viewBox:cs,width:ds,height:us,svg:ms,terminals:fs,source:hs},P2=Object.freeze(Object.defineProperty({__proto__:null,category:as,default:O2,height:us,id:is,name:ls,source:hs,svg:ms,terminals:fs,viewBox:cs,width:ds},Symbol.toStringTag,{value:"Module"})),ps="battery",gs="电池储能",ys="storage",xs="-12 -12 29 24",bs=29,ws=24,vs='<line x1="-10" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-10" x2="5" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="0" x2="15" y2="0" fill="none" stroke="black" stroke-width="1"/>',ks=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],_s=[{name:"E",label:"容量",type:"number",unit:"kWh"}],$s={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},B2={id:ps,name:gs,category:ys,viewBox:xs,width:bs,height:ws,svg:vs,terminals:ks,params:_s,source:$s},L2=Object.freeze(Object.defineProperty({__proto__:null,category:ys,default:B2,height:ws,id:ps,name:gs,params:_s,source:$s,svg:vs,terminals:ks,viewBox:xs,width:bs},Symbol.toStringTag,{value:"Module"})),Ss="bell",js="电铃 (HA)",Es="control",Ns="信号电铃 / 警铃。",Ts="-32 -32 44 44",Ms=44,As=44,Cs='<line x1="-30" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -10 A 20 20 0 0 0 -30 -10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',Is=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Os={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},z2={id:Ss,name:js,category:Es,description:Ns,viewBox:Ts,width:Ms,height:As,svg:Cs,terminals:Is,source:Os},R2=Object.freeze(Object.defineProperty({__proto__:null,category:Es,default:z2,description:Ns,height:As,id:Ss,name:js,source:Os,svg:Cs,terminals:Is,viewBox:Ts,width:Ms},Symbol.toStringTag,{value:"Module"})),Ps="break-contact",Bs="常闭触点 (NC)",Ls="control",zs="常闭辅助触点 (break contact)。",Rs="-2 -42 14 64",Ds=14,Fs=64,Hs='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',Ws=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],qs=[{name:"open",type:"boolean",default:!1,label:"断开"}],Gs={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},D2={id:Ps,name:Bs,category:Ls,description:zs,viewBox:Rs,width:Ds,height:Fs,svg:Hs,terminals:Ws,state:qs,source:Gs},F2=Object.freeze(Object.defineProperty({__proto__:null,category:Ls,default:D2,description:zs,height:Fs,id:Ps,name:Bs,source:Gs,state:qs,svg:Hs,terminals:Ws,viewBox:Rs,width:Ds},Symbol.toStringTag,{value:"Module"})),Ys="breaker",Ks="断路器 (QF)",Xs="switching",Vs="-7 -22 15 46",Us=15,Zs=46,Qs='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',Js=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ei=[{name:"open",type:"boolean",default:!1,label:"断开"}],ti={x:6,y:-2,anchor:"start"},ni={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},H2={id:Ys,name:Ks,category:Xs,viewBox:Vs,width:Us,height:Zs,svg:Qs,terminals:Js,state:ei,label:ti,source:ni},W2=Object.freeze(Object.defineProperty({__proto__:null,category:Xs,default:H2,height:Zs,id:Ys,label:ti,name:Ks,source:ni,state:ei,svg:Qs,terminals:Js,viewBox:Vs,width:Us},Symbol.toStringTag,{value:"Module"})),oi="buchholz-relay",ri="瓦斯继电器 (63)",si="protection",ii="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",li="-22 -62 44 64",ai=44,ci=64,di='<rect x="-20" y="-60" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-20" width="10" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-55" x2="0" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -50 A 10 5 0 0 0 0 -40" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -40 A 10 5 0 0 0 0 -50" fill="none" stroke="black" stroke-width="1"/>',ui=[{id:"t_top",x:0,y:-60,orientation:"n"}],mi={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_18/en_60617_07_18_01.elmt",qetEnglishName:"Buchholz protective device; Gas relay"},q2={id:oi,name:ri,category:si,description:ii,viewBox:li,width:ai,height:ci,svg:di,terminals:ui,source:mi},G2=Object.freeze(Object.defineProperty({__proto__:null,category:si,default:q2,description:ii,height:ci,id:oi,name:ri,source:mi,svg:di,terminals:ui,viewBox:li,width:ai},Symbol.toStringTag,{value:"Module"})),fi="busbar",hi="母线段",pi="busbar",gi="可拉伸单母线段,多设备挂接",yi="-42 -4 84 8",xi=84,bi=8,wi='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',vi=[{id:"tap",x:0,y:0,orientation:"n"}],ki={axis:"x",minLength:20,naturalSpan:80},_i=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],$i={x:0,y:-6,anchor:"middle"},Si={kind:"inline"},Y2={id:fi,name:hi,category:pi,description:gi,viewBox:yi,width:xi,height:bi,svg:wi,terminals:vi,stretchable:ki,params:_i,label:$i,source:Si},K2=Object.freeze(Object.defineProperty({__proto__:null,category:pi,default:Y2,description:gi,height:bi,id:fi,label:$i,name:hi,params:_i,source:Si,stretchable:ki,svg:wi,terminals:vi,viewBox:yi,width:xi},Symbol.toStringTag,{value:"Module"})),ji="buzzer",Ei="蜂鸣器 (HA)",Ni="control",Ti="信号蜂鸣器。",Mi="-32 -52 44 64",Ai=44,Ci=64,Ii='<line x1="-30" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><path d="M -30 -30 A 20 20 0 0 0 10 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-12" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-12" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',Oi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Pi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},X2={id:ji,name:Ei,category:Ni,description:Ti,viewBox:Mi,width:Ai,height:Ci,svg:Ii,terminals:Oi,source:Pi},V2=Object.freeze(Object.defineProperty({__proto__:null,category:Ni,default:X2,description:Ti,height:Ci,id:ji,name:Ei,source:Pi,svg:Ii,terminals:Oi,viewBox:Mi,width:Ai},Symbol.toStringTag,{value:"Module"})),Bi="capacitor",Li="电容 (C)",zi="passive",Ri="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",Di="-7 -23 14 27",Fi=14,Hi=27,Wi='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',qi=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Gi=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Yi={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},U2={id:Bi,name:Li,category:zi,description:Ri,viewBox:Di,width:Fi,height:Hi,svg:Wi,terminals:qi,params:Gi,source:Yi},Z2=Object.freeze(Object.defineProperty({__proto__:null,category:zi,default:U2,description:Ri,height:Hi,id:Bi,name:Li,params:Gi,source:Yi,svg:Wi,terminals:qi,viewBox:Di,width:Fi},Symbol.toStringTag,{value:"Module"})),Ki="contactor",Xi="接触器 (KM)",Vi="motor-control",Ui="主回路接触器, 通常配热继电器和电机使用。",Zi="-10 -42 15 64",Qi=15,Ji=64,el='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',tl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],nl=[{name:"open",type:"boolean",default:!0,label:"断开"}],ol={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_02.elmt",qetEnglishName:"Contactor; Main make contact of a contactor"},Q2={id:Ki,name:Xi,category:Vi,description:Ui,viewBox:Zi,width:Qi,height:Ji,svg:el,terminals:tl,state:nl,source:ol},J2=Object.freeze(Object.defineProperty({__proto__:null,category:Vi,default:Q2,description:Ui,height:Ji,id:Ki,name:Xi,source:ol,state:nl,svg:el,terminals:tl,viewBox:Zi,width:Qi},Symbol.toStringTag,{value:"Module"})),rl="converter-bidir",sl="双向变流器 (PCS)",il="renewable",ll="储能变流器:双向 AC ↔ DC",al="-42 -42 44 48",cl=44,dl=48,ul='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-6" x2="-14" y2="-6" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-6" x2="-4" y2="-6" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/><polyline points="-28,-4 -32,0 -28,4" fill="none" stroke="black" stroke-width="1"/><polyline points="-16,-4 -12,0 -16,4" fill="none" stroke="black" stroke-width="1"/>',ml=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],fl=[{name:"S",label:"容量",type:"number",unit:"MVA"}],hl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},ev={id:rl,name:sl,category:il,description:ll,viewBox:al,width:cl,height:dl,svg:ul,terminals:ml,params:fl,source:hl},tv=Object.freeze(Object.defineProperty({__proto__:null,category:il,default:ev,description:ll,height:dl,id:rl,name:sl,params:fl,source:hl,svg:ul,terminals:ml,viewBox:al,width:cl},Symbol.toStringTag,{value:"Module"})),pl="ct",gl="电流互感器 (CT)",yl="instrument-transformer",xl="-42 -62 54 64",bl=54,wl=64,vl='<line x1="-30" y1="-60" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-30" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-20" x2="5" y2="-40" fill="none" stroke="black" stroke-width="1"/>',kl=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-60,orientation:"n"}],_l={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},nv={id:pl,name:gl,category:yl,viewBox:xl,width:bl,height:wl,svg:vl,terminals:kl,source:_l},ov=Object.freeze(Object.defineProperty({__proto__:null,category:yl,default:nv,height:wl,id:pl,name:gl,source:_l,svg:vl,terminals:kl,viewBox:xl,width:bl},Symbol.toStringTag,{value:"Module"})),$l="dc-combiner",Sl="直流汇流箱",jl="renewable",El="光伏组串汇流箱 (4 路输入示例)。",Nl="-27 -32 54 64",Tl=54,Ml=64,Al='<rect x="-25" y="-15" width="50" height="30" fill="none" stroke="black" stroke-width="1"/><line x1="-18" y1="-30" x2="-18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="-6" y1="-30" x2="-6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-30" x2="6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="18" y1="-30" x2="18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><text x="-9" y="5" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">DC</text>',Cl=[{id:"t_s1",x:-18,y:-30,orientation:"n"},{id:"t_s2",x:-6,y:-30,orientation:"n"},{id:"t_s3",x:6,y:-30,orientation:"n"},{id:"t_s4",x:18,y:-30,orientation:"n"},{id:"t_dc",x:0,y:30,orientation:"s"}],Il={kind:"inline"},rv={id:$l,name:Sl,category:jl,description:El,viewBox:Nl,width:Tl,height:Ml,svg:Al,terminals:Cl,source:Il},sv=Object.freeze(Object.defineProperty({__proto__:null,category:jl,default:rv,description:El,height:Ml,id:$l,name:Sl,source:Il,svg:Al,terminals:Cl,viewBox:Nl,width:Tl},Symbol.toStringTag,{value:"Module"})),Ol="dc-disconnector",Pl="直流隔离开关",Bl="switching",Ll="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",zl="-12 -32 30 64",Rl=30,Dl=64,Fl='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-4" x2="14" y2="-4" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-1" x2="9" y2="-1" stroke="black" stroke-width="0.8" fill="none"/><line x1="11" y1="-1" x2="14" y2="-1" stroke="black" stroke-width="0.8" fill="none"/>',Hl=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Wl=[{name:"open",type:"boolean",default:!1,label:"断开"}],ql={kind:"inline"},iv={id:Ol,name:Pl,category:Bl,description:Ll,viewBox:zl,width:Rl,height:Dl,svg:Fl,terminals:Hl,state:Wl,source:ql},lv=Object.freeze(Object.defineProperty({__proto__:null,category:Bl,default:iv,description:Ll,height:Dl,id:Ol,name:Pl,source:ql,state:Wl,svg:Fl,terminals:Hl,viewBox:zl,width:Rl},Symbol.toStringTag,{value:"Module"})),Gl="dc-motor",Yl="直流电机 (M)",Kl="load",Xl="直流电动机 (串励通用符号)。",Vl="-72 -82 89 84",Ul=89,Zl=84,Ql='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',Jl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],ea={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},av={id:Gl,name:Yl,category:Kl,description:Xl,viewBox:Vl,width:Ul,height:Zl,svg:Ql,terminals:Jl,source:ea},cv=Object.freeze(Object.defineProperty({__proto__:null,category:Kl,default:av,description:Xl,height:Zl,id:Gl,name:Yl,source:ea,svg:Ql,terminals:Jl,viewBox:Vl,width:Ul},Symbol.toStringTag,{value:"Module"})),ta="diode",na="二极管 (D)",oa="passive",ra="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",sa="-12 -42 24 44",ia=24,la=44,aa='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/>',ca=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],da={x:6,y:-20,anchor:"start"},ua={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},dv={id:ta,name:na,category:oa,description:ra,viewBox:sa,width:ia,height:la,svg:aa,terminals:ca,label:da,source:ua},uv=Object.freeze(Object.defineProperty({__proto__:null,category:oa,default:dv,description:ra,height:la,id:ta,label:da,name:na,source:ua,svg:aa,terminals:ca,viewBox:sa,width:ia},Symbol.toStringTag,{value:"Module"})),ma="disconnector",fa="隔离开关 (QS)",ha="switching",pa="-10 -42 15 64",ga=15,ya=64,xa='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="-20" x2="3" y2="-20" fill="none" stroke="black" stroke-width="1"/>',ba=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],wa=[{name:"open",type:"boolean",default:!1,label:"断开"}],va={x:6,y:-10,anchor:"start"},ka={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},mv={id:ma,name:fa,category:ha,viewBox:pa,width:ga,height:ya,svg:xa,terminals:ba,state:wa,label:va,source:ka},fv=Object.freeze(Object.defineProperty({__proto__:null,category:ha,default:mv,height:ya,id:ma,label:va,name:fa,source:ka,state:wa,svg:xa,terminals:ba,viewBox:pa,width:ga},Symbol.toStringTag,{value:"Module"})),_a="distance-relay",$a="距离继电器 (21)",Sa="protection",ja="距离 / 低阻抗保护继电器 (ANSI 21)。",Ea="-62 -42 64 44",Na=64,Ta=44,Ma='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-42" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Z <</text>',Aa=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Ca={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},hv={id:_a,name:$a,category:Sa,description:ja,viewBox:Ea,width:Na,height:Ta,svg:Ma,terminals:Aa,source:Ca},pv=Object.freeze(Object.defineProperty({__proto__:null,category:Sa,default:hv,description:ja,height:Ta,id:_a,name:$a,source:Ca,svg:Ma,terminals:Aa,viewBox:Ea,width:Na},Symbol.toStringTag,{value:"Module"})),Ia="earth",Oa="接地",Pa="busbar",Ba="-12 -17 24 34",La=24,za=34,Ra='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',Da=[{id:"t1",x:0,y:-15,orientation:"n"}],Fa={kind:"elmt",path:"91_en_60617/en_60617_02/en_60617_02_15/en_60617_02_15_01.elmt",qetEnglishName:"Earth or ground, general symbol"},gv={id:Ia,name:Oa,category:Pa,viewBox:Ba,width:La,height:za,svg:Ra,terminals:Da,source:Fa},yv=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:gv,height:za,id:Ia,name:Oa,source:Fa,svg:Ra,terminals:Da,viewBox:Ba,width:La},Symbol.toStringTag,{value:"Module"})),Ha="earthing-switch",Wa="接地刀闸 (QE)",qa="switching",Ga="隔离开关 + 接地连接,单端口",Ya="-12 -32 24 64",Ka=24,Xa=64,Va='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="-12" x2="-9" y2="9" stroke="black" stroke-width="1" fill="none"/><line x1="-3" y1="-12" x2="3" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-10" y1="14" x2="10" y2="14" stroke="black" stroke-width="1" fill="none"/><line x1="-7" y1="19" x2="7" y2="19" stroke="black" stroke-width="1" fill="none"/><line x1="-4" y1="24" x2="4" y2="24" stroke="black" stroke-width="1" fill="none"/><line x1="-1.5" y1="29" x2="1.5" y2="29" stroke="black" stroke-width="1" fill="none"/>',Ua=[{id:"t_top",x:0,y:-30,orientation:"n"}],Za=[{name:"open",type:"boolean",default:!0,label:"断开"}],Qa={x:12,y:-8,anchor:"start"},Ja={kind:"inline"},xv={id:Ha,name:Wa,category:qa,description:Ga,viewBox:Ya,width:Ka,height:Xa,svg:Va,terminals:Ua,state:Za,label:Qa,source:Ja},bv=Object.freeze(Object.defineProperty({__proto__:null,category:qa,default:xv,description:Ga,height:Xa,id:Ha,label:Qa,name:Wa,source:Ja,state:Za,svg:Va,terminals:Ua,viewBox:Ya,width:Ka},Symbol.toStringTag,{value:"Module"})),ec="energy-meter",tc="电能表 (Wh)",nc="measurement",oc="有功电能表 (kWh) — 服务入口 / 子表。",rc="-22 -36 44 72",sc=44,ic=72,lc='<text x="-10" y="19.2" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Wh</text><rect x="-20" y="-10" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',ac=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],cc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},wv={id:ec,name:tc,category:nc,description:oc,viewBox:rc,width:sc,height:ic,svg:lc,terminals:ac,source:cc},vv=Object.freeze(Object.defineProperty({__proto__:null,category:nc,default:wv,description:oc,height:ic,id:ec,name:tc,source:cc,svg:lc,terminals:ac,viewBox:rc,width:sc},Symbol.toStringTag,{value:"Module"})),dc="ev-charger",uc="EV 充电桩",mc="load",fc="电动汽车充电站 / 充电桩。",hc="-17 -27 34 49",pc=34,gc=49,yc='<line x1="0" y1="-25" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-15" y="-15" width="30" height="35" fill="none" stroke="black" stroke-width="1"/><rect x="-9" y="-8" width="14" height="6" fill="none" stroke="black" stroke-width="0.8"/><rect x="5" y="-7" width="2" height="4" fill="black"/><text x="-9" y="13" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">EV</text>',xc=[{id:"t_top",x:0,y:-25,orientation:"n"}],bc={kind:"inline"},kv={id:dc,name:uc,category:mc,description:fc,viewBox:hc,width:pc,height:gc,svg:yc,terminals:xc,source:bc},_v=Object.freeze(Object.defineProperty({__proto__:null,category:mc,default:kv,description:fc,height:gc,id:dc,name:uc,source:bc,svg:yc,terminals:xc,viewBox:hc,width:pc},Symbol.toStringTag,{value:"Module"})),wc="frequency-meter",vc="频率表 (Hz)",kc="measurement",_c="-22 -42 44 44",$c=44,Sc=44,jc='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Hz</text>',Ec=[{id:"t_top",x:0,y:-40,orientation:"n"}],Nc={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},$v={id:wc,name:vc,category:kc,viewBox:_c,width:$c,height:Sc,svg:jc,terminals:Ec,source:Nc},Sv=Object.freeze(Object.defineProperty({__proto__:null,category:kc,default:$v,height:Sc,id:wc,name:vc,source:Nc,svg:jc,terminals:Ec,viewBox:_c,width:$c},Symbol.toStringTag,{value:"Module"})),Tc="fuse-switch-disconnector",Mc="熔断器式隔离开关",Ac="switching",Cc="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",Ic="-8 -32 12 64",Oc=12,Pc=64,Bc='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',Lc=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],zc=[{name:"open",type:"boolean",default:!1,label:"断开"}],Rc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},jv={id:Tc,name:Mc,category:Ac,description:Cc,viewBox:Ic,width:Oc,height:Pc,svg:Bc,terminals:Lc,state:zc,source:Rc},Ev=Object.freeze(Object.defineProperty({__proto__:null,category:Ac,default:jv,description:Cc,height:Pc,id:Tc,name:Mc,source:Rc,state:zc,svg:Bc,terminals:Lc,viewBox:Ic,width:Oc},Symbol.toStringTag,{value:"Module"})),Dc="fuse",Fc="熔断器 (FU)",Hc="switching",Wc="-7 -32 14 64",qc=14,Gc=64,Yc='<line x1="0" y1="-30" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-15" width="10" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Kc=[{id:"t1",x:0,y:30,orientation:"s"},{id:"t2",x:0,y:-30,orientation:"n"}],Xc=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Vc={x:7,y:-2,anchor:"start"},Uc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},Nv={id:Dc,name:Fc,category:Hc,viewBox:Wc,width:qc,height:Gc,svg:Yc,terminals:Kc,state:Xc,label:Vc,source:Uc},Tv=Object.freeze(Object.defineProperty({__proto__:null,category:Hc,default:Nv,height:Gc,id:Dc,label:Vc,name:Fc,source:Uc,state:Xc,svg:Yc,terminals:Kc,viewBox:Wc,width:qc},Symbol.toStringTag,{value:"Module"})),Zc="generator",Qc="发电机 (G)",Jc="source",ed="-42 -42 44 44",td=44,nd=44,od='<rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-24" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text>',rd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],sd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},Mv={id:Zc,name:Qc,category:Jc,viewBox:ed,width:td,height:nd,svg:od,terminals:rd,source:sd},Av=Object.freeze(Object.defineProperty({__proto__:null,category:Jc,default:Mv,height:nd,id:Zc,name:Qc,source:sd,svg:od,terminals:rd,viewBox:ed,width:td},Symbol.toStringTag,{value:"Module"})),id="genset",ld="发电机组 (G)",ad="source",cd="柴油 / 燃气发电机组。",dd="-28 -22 56 64",ud=56,md=64,fd='<rect x="-26" y="-20" width="52" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">GEN</text><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',hd=[{id:"t_out",x:0,y:40,orientation:"s"}],pd=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],gd={kind:"inline"},Cv={id,name:ld,category:ad,description:cd,viewBox:dd,width:ud,height:md,svg:fd,terminals:hd,params:pd,source:gd},Iv=Object.freeze(Object.defineProperty({__proto__:null,category:ad,default:Cv,description:cd,height:md,id,name:ld,params:pd,source:gd,svg:fd,terminals:hd,viewBox:dd,width:ud},Symbol.toStringTag,{value:"Module"})),yd="gfci-breaker",xd="GFCI 断路器 (RCBO)",bd="protection",wd="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",vd="-18 -22 22 44",kd=22,_d=44,$d='<text x="-14" y="13.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">IΔ</text><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="-5,-10 0,10 0,20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-4" x2="-8" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="-4" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="-4" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><path d="M -8 1 A 2.5 3.5 0 0 0 -13 1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="1" x2="-2" y2="1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="1" x2="-13" y2="1" fill="none" stroke="black" stroke-width="0.4"/>',Sd=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],jd=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ed=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Nd={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Ov={id:yd,name:xd,category:bd,description:wd,viewBox:vd,width:kd,height:_d,svg:$d,terminals:Sd,state:jd,params:Ed,source:Nd},Pv=Object.freeze(Object.defineProperty({__proto__:null,category:bd,default:Ov,description:wd,height:_d,id:yd,name:xd,params:Ed,source:Nd,state:jd,svg:$d,terminals:Sd,viewBox:vd,width:kd},Symbol.toStringTag,{value:"Module"})),Td="grid-source",Md="系统电源",Ad="source",Cd="无穷大母线 / 外部电网",Id="-16 -31 32 53",Od=32,Pd=53,Bd='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',Ld=[{id:"t_bottom",x:0,y:20,orientation:"s"}],zd={kind:"inline"},Bv={id:Td,name:Md,category:Ad,description:Cd,viewBox:Id,width:Od,height:Pd,svg:Bd,terminals:Ld,source:zd},Lv=Object.freeze(Object.defineProperty({__proto__:null,category:Ad,default:Bv,description:Cd,height:Pd,id:Td,name:Md,source:zd,svg:Bd,terminals:Ld,viewBox:Id,width:Od},Symbol.toStringTag,{value:"Module"})),Rd="grounding-transformer",Dd="接地变 (Z形)",Fd="grounding",Hd="星-曲折接线变压器,中性点接地用",Wd="-62 -152 64 164",qd=64,Gd=164,Yd='<line x1="-30" y1="-40" x2="-35" y2="-35" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-25" y2="-35" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-35" x2="-40" y2="-38" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-150" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-35" x2="-25" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-30" y2="-45" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-45" x2="-25" y2="-48" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-130" x2="-20" y2="-140" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-135" x2="-20" y2="-145" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="5" x2="-20" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-85" x2="-30" y2="-95" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-20" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-40" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-40" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/>',Kd=[{id:"t1",x:-30,y:10,orientation:"s"},{id:"t2",x:-30,y:-150,orientation:"n"}],Xd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},zv={id:Rd,name:Dd,category:Fd,description:Hd,viewBox:Wd,width:qd,height:Gd,svg:Yd,terminals:Kd,source:Xd},Rv=Object.freeze(Object.defineProperty({__proto__:null,category:Fd,default:zv,description:Hd,height:Gd,id:Rd,name:Dd,source:Xd,svg:Yd,terminals:Kd,viewBox:Wd,width:qd},Symbol.toStringTag,{value:"Module"})),Vd="heater",Ud="电加热器 (EH)",Zd="load",Qd="电阻加热元件 / 电热负荷。",Jd="-22 -7 54 14",eu=54,tu=14,nu='<line x1="-20" y1="0" x2="-10" y2="0" fill="none" stroke="black" stroke-width="1"/><rect x="-10" y="-5" width="30" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="0" x2="30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-5" x2="-5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-5" x2="5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="15" y1="-5" x2="15" y2="5" fill="none" stroke="black" stroke-width="1"/>',ou=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],ru=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],su={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},Dv={id:Vd,name:Ud,category:Zd,description:Qd,viewBox:Jd,width:eu,height:tu,svg:nu,terminals:ou,params:ru,source:su},Fv=Object.freeze(Object.defineProperty({__proto__:null,category:Zd,default:Dv,description:Qd,height:tu,id:Vd,name:Ud,params:ru,source:su,svg:nu,terminals:ou,viewBox:Jd,width:eu},Symbol.toStringTag,{value:"Module"})),iu="igbt",lu="绝缘栅双极晶体管 (IGBT)",au="passive",cu="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",du="-32 -32 54 74",uu=54,mu=74,fu='<line x1="0" y1="25" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polyline points="-30,20 -5,20 -5,-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="20" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="20" y2="40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="15" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-25" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-8" x2="0" y2="8" fill="none" stroke="black" stroke-width="1"/><polyline points="10,-24 8,-21 12,-22" fill="none" stroke="black" stroke-width="1"/><polyline points="10,25 11,29 8,27" fill="none" stroke="black" stroke-width="1"/>',hu=[{id:"t1",x:20,y:-30,orientation:"n"},{id:"t2",x:20,y:40,orientation:"s"},{id:"t_g",x:-30,y:20,orientation:"w"}],pu={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_05/en_60617_05_05_19.elmt",qetEnglishName:"Insulated-gate bipolar transistor (IGBT) enhancement type, N channel"},Hv={id:iu,name:lu,category:au,description:cu,viewBox:du,width:uu,height:mu,svg:fu,terminals:hu,source:pu},Wv=Object.freeze(Object.defineProperty({__proto__:null,category:au,default:Hv,description:cu,height:mu,id:iu,name:lu,source:pu,svg:fu,terminals:hu,viewBox:du,width:uu},Symbol.toStringTag,{value:"Module"})),gu="indicator-light",yu="指示灯 (HL)",xu="control",bu="信号 / 状态指示灯。",wu="-12 -22 24 24",vu=24,ku=24,_u='<ellipse cx="0" cy="-10" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-3" x2="7" y2="-17" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-17" x2="7" y2="-3" fill="none" stroke="black" stroke-width="1"/>',$u=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Su=[{name:"color",label:"颜色",type:"string"}],ju={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},qv={id:gu,name:yu,category:xu,description:bu,viewBox:wu,width:vu,height:ku,svg:_u,terminals:$u,params:Su,source:ju},Gv=Object.freeze(Object.defineProperty({__proto__:null,category:xu,default:qv,description:bu,height:ku,id:gu,name:yu,params:Su,source:ju,svg:_u,terminals:$u,viewBox:wu,width:vu},Symbol.toStringTag,{value:"Module"})),Eu="inductor",Nu="电感 (L)",Tu="passive",Mu="通用电感 / 线圈 / 扼流圈。",Au="-17 -32 34 64",Cu=34,Iu=64,Ou='<line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><path d="M 0 15 A 15 15 0 1 0 -15 0" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',Pu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Bu=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],Lu={x:6,y:0,anchor:"start"},zu={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Yv={id:Eu,name:Nu,category:Tu,description:Mu,viewBox:Au,width:Cu,height:Iu,svg:Ou,terminals:Pu,params:Bu,label:Lu,source:zu},Kv=Object.freeze(Object.defineProperty({__proto__:null,category:Tu,default:Yv,description:Mu,height:Iu,id:Eu,label:Lu,name:Nu,params:Bu,source:zu,svg:Ou,terminals:Pu,viewBox:Au,width:Cu},Symbol.toStringTag,{value:"Module"})),Ru="inverter",Du="逆变器 (DC→AC)",Fu="renewable",Hu="-42 -42 44 44",Wu=44,qu=44,Gu='<path d="M -15 -8 A 5 2.5 0 0 0 -25 -8" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><path d="M -15 -8 A 5 2.5 0 0 0 -5 -8" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/>',Yu=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],Ku={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Xv={id:Ru,name:Du,category:Fu,viewBox:Hu,width:Wu,height:qu,svg:Gu,terminals:Yu,source:Ku},Vv=Object.freeze(Object.defineProperty({__proto__:null,category:Fu,default:Xv,height:qu,id:Ru,name:Du,source:Ku,svg:Gu,terminals:Yu,viewBox:Hu,width:Wu},Symbol.toStringTag,{value:"Module"})),Xu="limit-switch",Vu="限位开关 (SQ)",Uu="control",Zu="行程 / 位置开关 (常开, 机械操作)。",Qu="-10 -42 12 64",Ju=12,em=64,tm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-13" x2="-7" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-12" x2="-3" y2="-8" fill="none" stroke="black" stroke-width="1"/>',nm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],om=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],rm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Uv={id:Xu,name:Vu,category:Uu,description:Zu,viewBox:Qu,width:Ju,height:em,svg:tm,terminals:nm,state:om,source:rm},Zv=Object.freeze(Object.defineProperty({__proto__:null,category:Uu,default:Uv,description:Zu,height:em,id:Xu,name:Vu,source:rm,state:om,svg:tm,terminals:nm,viewBox:Qu,width:Ju},Symbol.toStringTag,{value:"Module"})),sm="load-switch",im="负荷开关",lm="switching",am="-10 -42 14 64",cm=14,dm=64,um='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',mm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],fm=[{name:"open",type:"boolean",default:!1,label:"断开"}],hm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},Qv={id:sm,name:im,category:lm,viewBox:am,width:cm,height:dm,svg:um,terminals:mm,state:fm,source:hm},Jv=Object.freeze(Object.defineProperty({__proto__:null,category:lm,default:Qv,height:dm,id:sm,name:im,source:hm,state:fm,svg:um,terminals:mm,viewBox:am,width:cm},Symbol.toStringTag,{value:"Module"})),pm="load",gm="负荷",ym="load",xm="抽象负荷(电流流出箭头)",bm="-8 -22 16 46",wm=16,vm=46,km='<line x1="0" y1="-20" x2="0" y2="10" stroke="black" stroke-width="1" fill="none"/><polygon points="-6,10 6,10 0,22" fill="black" stroke="black" stroke-width="1"/>',_m=[{id:"t_top",x:0,y:-20,orientation:"n"}],$m=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],Sm={x:6,y:0,anchor:"start"},jm={kind:"inline"},ek={id:pm,name:gm,category:ym,description:xm,viewBox:bm,width:wm,height:vm,svg:km,terminals:_m,params:$m,label:Sm,source:jm},tk=Object.freeze(Object.defineProperty({__proto__:null,category:ym,default:ek,description:xm,height:vm,id:pm,label:Sm,name:gm,params:$m,source:jm,svg:km,terminals:_m,viewBox:bm,width:wm},Symbol.toStringTag,{value:"Module"})),Em="make-contact",Nm="常开触点 (NO)",Tm="control",Mm="常开辅助触点 (make contact)。",Am="-10 -42 12 64",Cm=12,Im=64,Om='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',Pm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Bm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Lm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_01.elmt",qetEnglishName:"Make contact, general symbol; Switch, general symbol"},nk={id:Em,name:Nm,category:Tm,description:Mm,viewBox:Am,width:Cm,height:Im,svg:Om,terminals:Pm,state:Bm,source:Lm},ok=Object.freeze(Object.defineProperty({__proto__:null,category:Tm,default:nk,description:Mm,height:Im,id:Em,name:Nm,source:Lm,state:Bm,svg:Om,terminals:Pm,viewBox:Am,width:Cm},Symbol.toStringTag,{value:"Module"})),zm="motor-starter",Rm="电机启动器",Dm="motor-control",Fm="电机启动器 (IEC 60617 通用符号)。",Hm="-22 -27 44 54",Wm=44,qm=54,Gm='<rect x="-20" y="-20" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,-20 0,-10 20,-20" fill="none" stroke="black" stroke-width="1"/>',Ym=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Km={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},rk={id:zm,name:Rm,category:Dm,description:Fm,viewBox:Hm,width:Wm,height:qm,svg:Gm,terminals:Ym,source:Km},sk=Object.freeze(Object.defineProperty({__proto__:null,category:Dm,default:rk,description:Fm,height:qm,id:zm,name:Rm,source:Km,svg:Gm,terminals:Ym,viewBox:Hm,width:Wm},Symbol.toStringTag,{value:"Module"})),Xm="ngr",Vm="中性点电阻 (NGR)",Um="grounding",Zm="小电阻接地:连接变压器中性点到地",Qm="-12 -32 24 62",Jm=24,ef=62,tf='<line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><rect x="-6" y="-15" width="12" height="22" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="7" x2="0" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="15" x2="10" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="19" x2="7" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="23" x2="4" y2="23" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="27" x2="1.5" y2="27" fill="none" stroke="black" stroke-width="1"/>',nf=[{id:"t_top",x:0,y:-30,orientation:"n"}],of=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],rf={kind:"inline"},ik={id:Xm,name:Vm,category:Um,description:Zm,viewBox:Qm,width:Jm,height:ef,svg:tf,terminals:nf,params:of,source:rf},lk=Object.freeze(Object.defineProperty({__proto__:null,category:Um,default:ik,description:Zm,height:ef,id:Xm,name:Vm,params:of,source:rf,svg:tf,terminals:nf,viewBox:Qm,width:Jm},Symbol.toStringTag,{value:"Module"})),sf="overcurrent-relay",lf="过流继电器 (50/51)",af="protection",cf="过电流保护继电器 (ANSI 50/51)。",df="-62 -62 64 64",uf=64,mf=64,ff='<rect x="-60" y="-60" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-48" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">5...10A</text>',hf=[{id:"t_top",x:-30,y:-60,orientation:"n"}],pf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},ak={id:sf,name:lf,category:af,description:cf,viewBox:df,width:uf,height:mf,svg:ff,terminals:hf,source:pf},ck=Object.freeze(Object.defineProperty({__proto__:null,category:af,default:ak,description:cf,height:mf,id:sf,name:lf,source:pf,svg:ff,terminals:hf,viewBox:df,width:uf},Symbol.toStringTag,{value:"Module"})),gf="phase-failure-relay",yf="断相继电器",xf="protection",bf="断相 / 缺相保护继电器。",wf="-62 -42 64 44",vf=64,kf=44,_f='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">m < 3</text>',$f=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Sf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},dk={id:gf,name:yf,category:xf,description:bf,viewBox:wf,width:vf,height:kf,svg:_f,terminals:$f,source:Sf},uk=Object.freeze(Object.defineProperty({__proto__:null,category:xf,default:dk,description:bf,height:kf,id:gf,name:yf,source:Sf,svg:_f,terminals:$f,viewBox:wf,width:vf},Symbol.toStringTag,{value:"Module"})),jf="plc",Ef="PLC / 控制器",Nf="control",Tf="可编程逻辑控制器 (PLC)。",Mf="-24 -42 48 84",Af=48,Cf=84,If='<rect x="-22" y="-22" width="44" height="44" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">PLC</text><line x1="0" y1="-40" x2="0" y2="-22" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="22" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Of=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],Pf={kind:"inline"},mk={id:jf,name:Ef,category:Nf,description:Tf,viewBox:Mf,width:Af,height:Cf,svg:If,terminals:Of,source:Pf},fk=Object.freeze(Object.defineProperty({__proto__:null,category:Nf,default:mk,description:Tf,height:Cf,id:jf,name:Ef,source:Pf,svg:If,terminals:Of,viewBox:Mf,width:Af},Symbol.toStringTag,{value:"Module"})),Bf="power-factor-meter",Lf="功率因数表 (cosφ)",zf="measurement",Rf="功率因数表 (cosφ)。",Df="-22 -42 44 44",Ff=44,Hf=44,Wf='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-14" y="-6.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">cos φ</text>',qf=[{id:"t_top",x:0,y:-40,orientation:"n"}],Gf={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},hk={id:Bf,name:Lf,category:zf,description:Rf,viewBox:Df,width:Ff,height:Hf,svg:Wf,terminals:qf,source:Gf},pk=Object.freeze(Object.defineProperty({__proto__:null,category:zf,default:hk,description:Rf,height:Hf,id:Bf,name:Lf,source:Gf,svg:Wf,terminals:qf,viewBox:Df,width:Ff},Symbol.toStringTag,{value:"Module"})),Yf="power-supply",Kf="开关电源 (PS)",Xf="source",Vf="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Uf="-24 -42 48 84",Zf=48,Qf=84,Jf='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="8" y="15" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">=</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',eh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],th=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],nh={kind:"inline"},gk={id:Yf,name:Kf,category:Xf,description:Vf,viewBox:Uf,width:Zf,height:Qf,svg:Jf,terminals:eh,params:th,source:nh},yk=Object.freeze(Object.defineProperty({__proto__:null,category:Xf,default:gk,description:Vf,height:Qf,id:Yf,name:Kf,params:th,source:nh,svg:Jf,terminals:eh,viewBox:Uf,width:Zf},Symbol.toStringTag,{value:"Module"})),oh="protective-relay",rh="保护继电器",sh="protection",ih="测量继电器 / 保护继电器通用符号 (IEC 60617)。",lh="-32 -42 64 44",ah=64,ch=44,dh='<polygon points="-2,-22 2,-22 0,-25" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-22 -2,-19 -6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="2,-22 2,-19 6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-19 0,-17 -3,-15" fill="black" stroke="black" stroke-width="1"/><polygon points="0,-17 2,-19 4,-15" fill="black" stroke="black" stroke-width="1"/><rect x="-2" y="-22" width="4" height="4" rx="0" ry="0" fill="black" stroke="black" stroke-width="1"/><rect x="-30" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',uh=[{id:"t_top",x:0,y:-40,orientation:"n"}],mh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_16/en_60617_07_16_01.elmt",qetEnglishName:"Measuring relay; Device related to a measuring relay"},xk={id:oh,name:rh,category:sh,description:ih,viewBox:lh,width:ah,height:ch,svg:dh,terminals:uh,source:mh},bk=Object.freeze(Object.defineProperty({__proto__:null,category:sh,default:xk,description:ih,height:ch,id:oh,name:rh,source:mh,svg:dh,terminals:uh,viewBox:lh,width:ah},Symbol.toStringTag,{value:"Module"})),fh="proximity-switch",hh="接近开关 (SQ)",ph="control",gh="接近传感器 / 无触点接近开关。",yh="-12 -32 24 64",xh=24,bh=64,wh='<line x1="0" y1="-30" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 -10,0 0,10 10,0" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-6" x2="-4" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-6" x2="4" y2="6" fill="none" stroke="black" stroke-width="1"/>',vh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],kh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},wk={id:fh,name:hh,category:ph,description:gh,viewBox:yh,width:xh,height:bh,svg:wh,terminals:vh,source:kh},vk=Object.freeze(Object.defineProperty({__proto__:null,category:ph,default:wk,description:gh,height:bh,id:fh,name:hh,source:kh,svg:wh,terminals:vh,viewBox:yh,width:xh},Symbol.toStringTag,{value:"Module"})),_h="pt",$h="电压互感器 (PT)",Sh="instrument-transformer",jh="-22 -42 44 115",Eh=44,Nh=115,Th='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',Mh=[{id:"t1",x:0,y:71,orientation:"s"},{id:"t2",x:0,y:-40,orientation:"n"}],Ah={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},kk={id:_h,name:$h,category:Sh,viewBox:jh,width:Eh,height:Nh,svg:Th,terminals:Mh,source:Ah},_k=Object.freeze(Object.defineProperty({__proto__:null,category:Sh,default:kk,height:Nh,id:_h,name:$h,source:Ah,svg:Th,terminals:Mh,viewBox:jh,width:Eh},Symbol.toStringTag,{value:"Module"})),Ch="push-button",Ih="按钮 (SB)",Oh="control",Ph="手动按钮, 自动复位 (常开 make)。",Bh="-37 -42 39 64",Lh=39,zh=64,Rh='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',Dh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Fh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_02.elmt",qetEnglishName:"Switch, manually operated, push-button, automatic return"},$k={id:Ch,name:Ih,category:Oh,description:Ph,viewBox:Bh,width:Lh,height:zh,svg:Rh,terminals:Dh,source:Fh},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:Oh,default:$k,description:Ph,height:zh,id:Ch,name:Ih,source:Fh,svg:Rh,terminals:Dh,viewBox:Bh,width:Lh},Symbol.toStringTag,{value:"Module"})),Hh="pv",Wh="光伏组件",qh="renewable",Gh="-33 -22 85 64",Yh=85,Kh=64,Xh='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',Vh=[{id:"t_dc",x:50,y:10,orientation:"e"}],Uh={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},jk={id:Hh,name:Wh,category:qh,viewBox:Gh,width:Yh,height:Kh,svg:Xh,terminals:Vh,source:Uh},Ek=Object.freeze(Object.defineProperty({__proto__:null,category:qh,default:jk,height:Kh,id:Hh,name:Wh,source:Uh,svg:Xh,terminals:Vh,viewBox:Gh,width:Yh},Symbol.toStringTag,{value:"Module"})),Zh="rcd",Qh="剩余电流装置 (RCD)",Jh="protection",e0="不带过流保护的剩余电流断路器 (IEC 61008)。",t0="-12 -22 19 44",n0=19,o0=44,r0='<line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="0,20 0,10 -7,-9" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="13" rx="4.5" ry="2" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,0 -10,0 -10,13 -5,13" fill="none" stroke="black" stroke-width="0.4" stroke-dasharray="4 2"/>',s0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],i0=[{name:"open",type:"boolean",default:!1,label:"断开"}],l0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],a0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Nk={id:Zh,name:Qh,category:Jh,description:e0,viewBox:t0,width:n0,height:o0,svg:r0,terminals:s0,state:i0,params:l0,source:a0},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:Jh,default:Nk,description:e0,height:o0,id:Zh,name:Qh,params:l0,source:a0,state:i0,svg:r0,terminals:s0,viewBox:t0,width:n0},Symbol.toStringTag,{value:"Module"})),c0="recloser",d0="重合闸 (Recloser)",u0="protection",m0="中压自动重合闸开关。",f0="-12 -32 36 64",h0=36,p0=64,g0='<line x1="0" y1="-30" x2="0" y2="-10" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-13" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-8" x2="2" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-12" x2="2" y2="-8" stroke="black" stroke-width="1" fill="none"/><path d="M 13 -12 A 7 7 0 1 1 6 -5" fill="none" stroke="black" stroke-width="0.8"/><polygon points="4,-7 6,-5 8,-3" fill="black"/><text x="14" y="6" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">AR</text>',y0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],x0=[{name:"open",type:"boolean",default:!1,label:"断开"}],b0={kind:"inline"},Mk={id:c0,name:d0,category:u0,description:m0,viewBox:f0,width:h0,height:p0,svg:g0,terminals:y0,state:x0,source:b0},Ak=Object.freeze(Object.defineProperty({__proto__:null,category:u0,default:Mk,description:m0,height:p0,id:c0,name:d0,source:b0,state:x0,svg:g0,terminals:y0,viewBox:f0,width:h0},Symbol.toStringTag,{value:"Module"})),w0="rectifier",v0="整流器 (AC→DC)",k0="renewable",_0="-42 -42 44 44",$0=44,S0=44,j0='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/>',E0=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],N0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},Ck={id:w0,name:v0,category:k0,viewBox:_0,width:$0,height:S0,svg:j0,terminals:E0,source:N0},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:k0,default:Ck,height:S0,id:w0,name:v0,source:N0,svg:j0,terminals:E0,viewBox:_0,width:$0},Symbol.toStringTag,{value:"Module"})),T0="relay-coil",M0="继电器线圈 (KA)",A0="control",C0="继电器 / 接触器操作线圈 (方框)。",I0="-22 -22 44 44",O0=44,P0=44,B0='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/>',L0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],z0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_01.elmt",qetEnglishName:"Operating device, general symbol; Relay coil, general symbol"},Ok={id:T0,name:M0,category:A0,description:C0,viewBox:I0,width:O0,height:P0,svg:B0,terminals:L0,source:z0},Pk=Object.freeze(Object.defineProperty({__proto__:null,category:A0,default:Ok,description:C0,height:P0,id:T0,name:M0,source:z0,svg:B0,terminals:L0,viewBox:I0,width:O0},Symbol.toStringTag,{value:"Module"})),R0="resistor",D0="电阻 (R)",F0="passive",H0="通用电阻 / 限流 / 制动电阻。",W0="-6 -23 12 35",q0=12,G0=35,Y0='<line x1="0" y1="-10" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="10" x2="4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-10" x2="-4" y2="10" fill="none" stroke="black" stroke-width="1"/>',K0=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],X0=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],V0={x:6,y:0,anchor:"start"},U0={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},Bk={id:R0,name:D0,category:F0,description:H0,viewBox:W0,width:q0,height:G0,svg:Y0,terminals:K0,params:X0,label:V0,source:U0},Lk=Object.freeze(Object.defineProperty({__proto__:null,category:F0,default:Bk,description:H0,height:G0,id:R0,label:V0,name:D0,params:X0,source:U0,svg:Y0,terminals:K0,viewBox:W0,width:q0},Symbol.toStringTag,{value:"Module"})),Z0="reverse-power-relay",Q0="逆功率继电器 (32)",J0="protection",ep="逆功率 / 逆流保护继电器 (ANSI 32)。",tp="-62 -42 64 44",np=64,op=44,rp='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">I</text><polygon points="-15,-20 -30,-20 -24,-22 -24,-18 -30,-20 -24,-20" fill="black" stroke="black" stroke-width="1"/>',sp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],ip={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},zk={id:Z0,name:Q0,category:J0,description:ep,viewBox:tp,width:np,height:op,svg:rp,terminals:sp,source:ip},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:J0,default:zk,description:ep,height:op,id:Z0,name:Q0,source:ip,svg:rp,terminals:sp,viewBox:tp,width:np},Symbol.toStringTag,{value:"Module"})),lp="selector-switch",ap="选择开关 (SA)",cp="switching",dp="转换 / 选择开关 (旋转操作, 保位)。",up="-34 -42 36 64",mp=36,fp=64,hp='<line x1="-32" y1="-10" x2="-2" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-32" y1="-15" x2="-32" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',pp=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],gp=[{name:"open",type:"boolean",default:!1,label:"断开"}],yp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_04.elmt",qetEnglishName:"Switch, manually operated, turning, stay-put"},Dk={id:lp,name:ap,category:cp,description:dp,viewBox:up,width:mp,height:fp,svg:hp,terminals:pp,state:gp,source:yp},Fk=Object.freeze(Object.defineProperty({__proto__:null,category:cp,default:Dk,description:dp,height:fp,id:lp,name:ap,source:yp,state:gp,svg:hp,terminals:pp,viewBox:up,width:mp},Symbol.toStringTag,{value:"Module"})),xp="series-reactor",bp="串联电抗器",wp="compensation",vp="与并联电抗器同符号;通过用法区分。",kp="-62 -82 64 104",_p=64,$p=104,Sp='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',jp=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Ep={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},Hk={id:xp,name:bp,category:wp,description:vp,viewBox:kp,width:_p,height:$p,svg:Sp,terminals:jp,source:Ep},Wk=Object.freeze(Object.defineProperty({__proto__:null,category:wp,default:Hk,description:vp,height:$p,id:xp,name:bp,source:Ep,svg:Sp,terminals:jp,viewBox:kp,width:_p},Symbol.toStringTag,{value:"Module"})),Np="shunt-capacitor",Tp="并联电容器",Mp="compensation",Ap="-7 -23 14 27",Cp=14,Ip=27,Op='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',Pp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Bp=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],Lp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},qk={id:Np,name:Tp,category:Mp,viewBox:Ap,width:Cp,height:Ip,svg:Op,terminals:Pp,params:Bp,source:Lp},Gk=Object.freeze(Object.defineProperty({__proto__:null,category:Mp,default:qk,height:Ip,id:Np,name:Tp,params:Bp,source:Lp,svg:Op,terminals:Pp,viewBox:Ap,width:Cp},Symbol.toStringTag,{value:"Module"})),zp="shunt-reactor",Rp="并联电抗器",Dp="compensation",Fp="-62 -82 64 104",Hp=64,Wp=104,qp='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',Gp=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Yp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},Yk={id:zp,name:Rp,category:Dp,viewBox:Fp,width:Hp,height:Wp,svg:qp,terminals:Gp,source:Yp},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:Dp,default:Yk,height:Wp,id:zp,name:Rp,source:Yp,svg:qp,terminals:Gp,viewBox:Fp,width:Hp},Symbol.toStringTag,{value:"Module"})),Kp="siren",Xp="警笛 (HA)",Vp="control",Up="声响警笛 / 报警器。",Zp="-32 -42 44 54",Qp=44,Jp=54,eg='<line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="10,-10 -30,-10 -10,-40" fill="none" stroke="black" stroke-width="1"/>',tg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ng={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},Xk={id:Kp,name:Xp,category:Vp,description:Up,viewBox:Zp,width:Qp,height:Jp,svg:eg,terminals:tg,source:ng},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:Vp,default:Xk,description:Up,height:Jp,id:Kp,name:Xp,source:ng,svg:eg,terminals:tg,viewBox:Zp,width:Qp},Symbol.toStringTag,{value:"Module"})),og="socket-outlet",rg="插座 / 连接器",sg="load",ig="电源插座 / 多极连接器。",lg="-7 -2 13 34",ag=13,cg=34,dg='<line x1="-5" y1="13" x2="4" y2="20" fill="none" stroke="black" stroke-width="0.4"/><line x1="-1" y1="12" x2="-1" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="9" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="12" x2="1" y2="19" fill="none" stroke="black" stroke-width="1"/><path d="M 3 13 A 3 3 0 0 0 -3 13" fill="none" stroke="black" stroke-width="1"/>',ug=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],mg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
192
|
-
unifilar`},Uk={id:og,name:rg,category:sg,description:ig,viewBox:lg,width:ag,height:cg,svg:dg,terminals:ug,source:mg},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:sg,default:Uk,description:ig,height:cg,id:og,name:rg,source:mg,svg:dg,terminals:ug,viewBox:lg,width:ag},Symbol.toStringTag,{value:"Module"})),fg="soft-starter",hg="软启动器",pg="motor-control",gg="电机软启动器 (晶闸管降压启动)。",yg="-22 -42 44 84",xg=44,bg=84,wg='<rect x="-20" y="-20" width="40" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-12" y1="-12" x2="12" y2="12" stroke="black" stroke-width="1" fill="none"/><polygon points="4,8 12,12 8,4" fill="none" stroke="black" stroke-width="1"/><text x="-12" y="-2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">SS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',vg=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],kg={kind:"inline"},Qk={id:fg,name:hg,category:pg,description:gg,viewBox:yg,width:xg,height:bg,svg:wg,terminals:vg,source:kg},Jk=Object.freeze(Object.defineProperty({__proto__:null,category:pg,default:Qk,description:gg,height:bg,id:fg,name:hg,source:kg,svg:wg,terminals:vg,viewBox:yg,width:xg},Symbol.toStringTag,{value:"Module"})),_g="sync-motor",$g="同步电动机",Sg="load",jg="-62 -82 64 114",Eg=64,Ng=114,Tg='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',Mg=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],Ag={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},e_={id:_g,name:$g,category:Sg,viewBox:jg,width:Eg,height:Ng,svg:Tg,terminals:Mg,source:Ag},t_=Object.freeze(Object.defineProperty({__proto__:null,category:Sg,default:e_,height:Ng,id:_g,name:$g,source:Ag,svg:Tg,terminals:Mg,viewBox:jg,width:Eg},Symbol.toStringTag,{value:"Module"})),Cg="synchronoscope",Ig="同步表",Og="measurement",Pg="同步指示器 / 同步表。",Bg="-22 -42 44 44",Lg=44,zg=44,Rg='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',Dg=[{id:"t_top",x:0,y:-40,orientation:"n"}],Fg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},n_={id:Cg,name:Ig,category:Og,description:Pg,viewBox:Bg,width:Lg,height:zg,svg:Rg,terminals:Dg,source:Fg},o_=Object.freeze(Object.defineProperty({__proto__:null,category:Og,default:n_,description:Pg,height:zg,id:Cg,name:Ig,source:Fg,svg:Rg,terminals:Dg,viewBox:Bg,width:Lg},Symbol.toStringTag,{value:"Module"})),Hg="terminal",Wg="接线端子 / 节点 (X)",qg="busbar",Gg="接线端子 / 接线盒 / 汇接节点。",Yg="-5 -5 10 10",Kg=10,Xg=10,Vg='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',Ug=[{id:"t_top",x:0,y:-2.5,orientation:"n"},{id:"t_bottom",x:0,y:2.5,orientation:"s"},{id:"t_left",x:-2.5,y:0,orientation:"w"},{id:"t_right",x:2.5,y:0,orientation:"e"}],Zg={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},r_={id:Hg,name:Wg,category:qg,description:Gg,viewBox:Yg,width:Kg,height:Xg,svg:Vg,terminals:Ug,source:Zg},s_=Object.freeze(Object.defineProperty({__proto__:null,category:qg,default:r_,description:Gg,height:Xg,id:Hg,name:Wg,source:Zg,svg:Vg,terminals:Ug,viewBox:Yg,width:Kg},Symbol.toStringTag,{value:"Module"})),Qg="thermal-overload",Jg="热过载继电器",e1="motor-control",t1="电机热过载保护继电器, 通常串接在接触器和电机之间。",n1="-9 -32 19 64",o1=19,r1=64,s1='<line x1="0" y1="-30" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-7" y="-15" width="14" height="30" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,-10 -1,-5 -4,0 -1,5 -4,10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',i1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],l1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],a1={kind:"inline"},i_={id:Qg,name:Jg,category:e1,description:t1,viewBox:n1,width:o1,height:r1,svg:s1,terminals:i1,state:l1,source:a1},l_=Object.freeze(Object.defineProperty({__proto__:null,category:e1,default:i_,description:t1,height:r1,id:Qg,name:Jg,source:a1,state:l1,svg:s1,terminals:i1,viewBox:n1,width:o1},Symbol.toStringTag,{value:"Module"})),c1="thermocouple",d1="热电偶 (BT)",u1="measurement",m1="热电偶温度传感器。",f1="-26 -42 52 46",h1=52,p1=46,g1='<ellipse cx="0" cy="0" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/><polyline points="-10,-40 -10,-15 0,0 10,-15 10,-40" fill="none" stroke="black" stroke-width="1"/><line x1="-24" y1="-16" x2="-16" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="16" y1="-16" x2="24" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-20" x2="20" y2="-12" fill="none" stroke="black" stroke-width="1"/>',y1=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],x1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},a_={id:c1,name:d1,category:u1,description:m1,viewBox:f1,width:h1,height:p1,svg:g1,terminals:y1,source:x1},c_=Object.freeze(Object.defineProperty({__proto__:null,category:u1,default:a_,description:m1,height:p1,id:c1,name:d1,source:x1,svg:g1,terminals:y1,viewBox:f1,width:h1},Symbol.toStringTag,{value:"Module"})),b1="thyristor",w1="晶闸管 (V)",v1="passive",k1="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",_1="-22 -42 34 44",$1=34,S1=44,j1='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-20" x2="-10" y2="-20" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,0 -7,0 -4,-10" fill="none" stroke="black" stroke-width="1"/>',E1=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],N1={x:6,y:-20,anchor:"start"},T1={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},d_={id:b1,name:w1,category:v1,description:k1,viewBox:_1,width:$1,height:S1,svg:j1,terminals:E1,label:N1,source:T1},u_=Object.freeze(Object.defineProperty({__proto__:null,category:v1,default:d_,description:k1,height:S1,id:b1,label:N1,name:w1,source:T1,svg:j1,terminals:E1,viewBox:_1,width:$1},Symbol.toStringTag,{value:"Module"})),M1="time-relay",A1="时间继电器 (KT)",C1="control",I1="延时 (缓动) 继电器线圈。",O1="-32 -22 54 44",P1=54,B1=44,L1='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><rect x="-30" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="10" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/>',z1=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],R1={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},m_={id:M1,name:A1,category:C1,description:I1,viewBox:O1,width:P1,height:B1,svg:L1,terminals:z1,source:R1},f_=Object.freeze(Object.defineProperty({__proto__:null,category:C1,default:m_,description:I1,height:B1,id:M1,name:A1,source:R1,svg:L1,terminals:z1,viewBox:O1,width:P1},Symbol.toStringTag,{value:"Module"})),D1="transfer-switch",F1="切换开关 (ATS)",H1="switching",W1="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",q1="-27 -32 51 64",G1=51,Y1=64,K1='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',X1=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],V1=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],U1={kind:"inline"},h_={id:D1,name:F1,category:H1,description:W1,viewBox:q1,width:G1,height:Y1,svg:K1,terminals:X1,state:V1,source:U1},p_=Object.freeze(Object.defineProperty({__proto__:null,category:H1,default:h_,description:W1,height:Y1,id:D1,name:F1,source:U1,state:V1,svg:K1,terminals:X1,viewBox:q1,width:G1},Symbol.toStringTag,{value:"Module"})),Z1="transformer-2w",Q1="双绕组变压器",J1="transformer",ey="-62 -142 64 144",ty=64,ny=144,oy='<ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-140" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/>',ry=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-140,orientation:"n"}],sy=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],iy={x:4,y:-68,anchor:"start"},ly={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_01.elmt",qetEnglishName:"Transformer with two windings, general symbol"},g_={id:Z1,name:Q1,category:J1,viewBox:ey,width:ty,height:ny,svg:oy,terminals:ry,params:sy,label:iy,source:ly},y_=Object.freeze(Object.defineProperty({__proto__:null,category:J1,default:g_,height:ny,id:Z1,label:iy,name:Q1,params:sy,source:ly,svg:oy,terminals:ry,viewBox:ey,width:ty},Symbol.toStringTag,{value:"Module"})),ay="transformer-3w",cy="三绕组变压器",dy="transformer",uy="-82 -131 114 133",my=114,fy=133,hy='<ellipse cx="-30" cy="-80" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-31" y1="-129" x2="-31" y2="-109" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-50" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-20" x2="-50" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',py=[{id:"t1",x:-31,y:-129,orientation:"n"},{id:"t_low_left",x:-50,y:0,orientation:"s"},{id:"t_low_right",x:0,y:0,orientation:"s"}],gy={x:4,y:-64,anchor:"start"},yy={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},x_={id:ay,name:cy,category:dy,viewBox:uy,width:my,height:fy,svg:hy,terminals:py,label:gy,source:yy},b_=Object.freeze(Object.defineProperty({__proto__:null,category:dy,default:x_,height:fy,id:ay,label:gy,name:cy,source:yy,svg:hy,terminals:py,viewBox:uy,width:my},Symbol.toStringTag,{value:"Module"})),xy="triac",by="双向晶闸管 (V)",wy="passive",vy="双向三极晶闸管 (TRIAC)。",ky="-22 -42 44 44",_y=44,$y=44,Sy='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,-30 0,-30 -10,-10" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-30" x2="-10" y2="-30" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 10,-30 20,-10" fill="none" stroke="black" stroke-width="1"/><polyline points="20,0 18,0 14,-10" fill="none" stroke="black" stroke-width="1"/>',jy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ey={x:6,y:-20,anchor:"start"},Ny={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},w_={id:xy,name:by,category:wy,description:vy,viewBox:ky,width:_y,height:$y,svg:Sy,terminals:jy,label:Ey,source:Ny},v_=Object.freeze(Object.defineProperty({__proto__:null,category:wy,default:w_,description:vy,height:$y,id:xy,label:Ey,name:by,source:Ny,svg:Sy,terminals:jy,viewBox:ky,width:_y},Symbol.toStringTag,{value:"Module"})),Ty="undervoltage-relay",My="欠压继电器 (27)",Ay="protection",Cy="欠电压保护继电器 (ANSI 27)。",Iy="-62 -82 64 84",Oy=64,Py=84,By='<rect x="-60" y="-80" width="60" height="80" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-49" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">130 %</text><text x="-55" y="-32.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">50...80 V</text><text x="-41" y="-53.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">U <</text>',Ly=[{id:"t_top",x:-30,y:-80,orientation:"n"}],zy={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},k_={id:Ty,name:My,category:Ay,description:Cy,viewBox:Iy,width:Oy,height:Py,svg:By,terminals:Ly,source:zy},__=Object.freeze(Object.defineProperty({__proto__:null,category:Ay,default:k_,description:Cy,height:Py,id:Ty,name:My,source:zy,svg:By,terminals:Ly,viewBox:Iy,width:Oy},Symbol.toStringTag,{value:"Module"})),Ry="ups",Dy="不间断电源 (UPS)",Fy="source",Hy="在线 / 后备式不间断电源。",Wy="-26 -42 52 84",qy=52,Gy=84,Yy='<rect x="-24" y="-20" width="48" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">UPS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Ky=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Xy=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Vy={kind:"inline"},$_={id:Ry,name:Dy,category:Fy,description:Hy,viewBox:Wy,width:qy,height:Gy,svg:Yy,terminals:Ky,params:Xy,source:Vy},S_=Object.freeze(Object.defineProperty({__proto__:null,category:Fy,default:$_,description:Hy,height:Gy,id:Ry,name:Dy,params:Xy,source:Vy,svg:Yy,terminals:Ky,viewBox:Wy,width:qy},Symbol.toStringTag,{value:"Module"})),Uy="varmeter",Zy="无功功率表 (var)",Qy="measurement",Jy="无功功率表 (var)。",ex="-22 -42 44 44",tx=44,nx=44,ox='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">var</text>',rx=[{id:"t_top",x:0,y:-40,orientation:"n"}],sx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},j_={id:Uy,name:Zy,category:Qy,description:Jy,viewBox:ex,width:tx,height:nx,svg:ox,terminals:rx,source:sx},E_=Object.freeze(Object.defineProperty({__proto__:null,category:Qy,default:j_,description:Jy,height:nx,id:Uy,name:Zy,source:sx,svg:ox,terminals:rx,viewBox:ex,width:tx},Symbol.toStringTag,{value:"Module"})),ix="vfd",lx="变频器 (VFD)",ax="motor-control",cx="Variable Frequency Drive — 异步电动机调速。",dx="-24 -42 48 84",ux=48,mx=84,fx='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="6" y="14" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~f</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',hx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],px={kind:"inline"},N_={id:ix,name:lx,category:ax,description:cx,viewBox:dx,width:ux,height:mx,svg:fx,terminals:hx,source:px},T_=Object.freeze(Object.defineProperty({__proto__:null,category:ax,default:N_,description:cx,height:mx,id:ix,name:lx,source:px,svg:fx,terminals:hx,viewBox:dx,width:ux},Symbol.toStringTag,{value:"Module"})),gx="voltage-regulator",yx="调压器 (T)",xx="transformer",bx="可调感应调压器 / 自耦调压器。",wx="-17 -32 38 64",vx=38,kx=64,_x='<line x1="-5" y1="21" x2="5" y2="17" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-16.05" x2="4.95" y2="-20.05" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-5" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="0" rx="15" ry="15" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-20.05" x2="4.95" y2="-24.05" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="23" x2="5" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-18.05" x2="4.95" y2="-22.05" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="25" x2="5" y2="21" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="15" x2="15" y2="-15" fill="none" stroke="black" stroke-width="1"/><polygon points="13,-16 16,-13 19,-19" fill="black" stroke="black" stroke-width="0.4"/>',$x=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Sx=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],jx={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},M_={id:gx,name:yx,category:xx,description:bx,viewBox:wx,width:vx,height:kx,svg:_x,terminals:$x,params:Sx,source:jx},A_=Object.freeze(Object.defineProperty({__proto__:null,category:xx,default:M_,description:bx,height:kx,id:gx,name:yx,params:Sx,source:jx,svg:_x,terminals:$x,viewBox:wx,width:vx},Symbol.toStringTag,{value:"Module"})),Ex="voltmeter",Nx="电压表 (V)",Tx="measurement",Mx="-22 -42 44 44",Ax=44,Cx=44,Ix='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-4" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">V</text>',Ox=[{id:"t_top",x:0,y:-40,orientation:"n"}],Px={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},C_={id:Ex,name:Nx,category:Tx,viewBox:Mx,width:Ax,height:Cx,svg:Ix,terminals:Ox,source:Px},I_=Object.freeze(Object.defineProperty({__proto__:null,category:Tx,default:C_,height:Cx,id:Ex,name:Nx,source:Px,svg:Ix,terminals:Ox,viewBox:Mx,width:Ax},Symbol.toStringTag,{value:"Module"})),Bx="wattmeter",Lx="功率表 (W)",zx="measurement",Rx="-22 -42 44 44",Dx=44,Fx=44,Hx='<rect x="-20" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-6" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">W</text>',Wx=[{id:"t_top",x:0,y:-40,orientation:"n"}],qx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},O_={id:Bx,name:Lx,category:zx,viewBox:Rx,width:Dx,height:Fx,svg:Hx,terminals:Wx,source:qx},P_=Object.freeze(Object.defineProperty({__proto__:null,category:zx,default:O_,height:Fx,id:Bx,name:Lx,source:qx,svg:Hx,terminals:Wx,viewBox:Rx,width:Dx},Symbol.toStringTag,{value:"Module"})),Gx="wind-turbine",Yx="风力发电机",Kx="renewable",Xx="风机:发电机 + 三叶轮标记",Vx="-22 -46 44 68",Ux=44,Zx=68,Qx='<circle cx="0" cy="0" r="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="16">G</text><line x1="0" y1="-20" x2="0" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-32" x2="-10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="0" y2="-44" fill="none" stroke="black" stroke-width="1.5"/>',Jx=[{id:"t_bottom",x:0,y:20,orientation:"s"}],eb={kind:"inline"},B_={id:Gx,name:Yx,category:Kx,description:Xx,viewBox:Vx,width:Ux,height:Zx,svg:Qx,terminals:Jx,source:eb},L_=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:B_,description:Xx,height:Zx,id:Gx,name:Yx,source:eb,svg:Qx,terminals:Jx,viewBox:Vx,width:Ux},Symbol.toStringTag,{value:"Module"})),tb="zener-diode",nb="稳压二极管 (D)",ob="passive",rb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",sb="-12 -42 24 44",ib=24,lb=44,ab='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-15" x2="-10" y2="-10" fill="none" stroke="black" stroke-width="1"/>',cb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],db={x:6,y:-20,anchor:"start"},ub={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},z_={id:tb,name:nb,category:ob,description:rb,viewBox:sb,width:ib,height:lb,svg:ab,terminals:cb,label:db,source:ub},R_=Object.freeze(Object.defineProperty({__proto__:null,category:ob,default:z_,description:rb,height:lb,id:tb,label:db,name:nb,source:ub,svg:ab,terminals:cb,viewBox:sb,width:ib},Symbol.toStringTag,{value:"Module"})),D_=Object.assign({"./ammeter.json":E2,"./arc-suppression-coil.json":T2,"./arrester.json":A2,"./async-motor.json":I2,"./autotransformer.json":P2,"./battery.json":L2,"./bell.json":R2,"./break-contact.json":F2,"./breaker.json":W2,"./buchholz-relay.json":G2,"./busbar.json":K2,"./buzzer.json":V2,"./capacitor.json":Z2,"./contactor.json":J2,"./converter-bidir.json":tv,"./ct.json":ov,"./dc-combiner.json":sv,"./dc-disconnector.json":lv,"./dc-motor.json":cv,"./diode.json":uv,"./disconnector.json":fv,"./distance-relay.json":pv,"./earth.json":yv,"./earthing-switch.json":bv,"./energy-meter.json":vv,"./ev-charger.json":_v,"./frequency-meter.json":Sv,"./fuse-switch-disconnector.json":Ev,"./fuse.json":Tv,"./generator.json":Av,"./genset.json":Iv,"./gfci-breaker.json":Pv,"./grid-source.json":Lv,"./grounding-transformer.json":Rv,"./heater.json":Fv,"./igbt.json":Wv,"./indicator-light.json":Gv,"./inductor.json":Kv,"./inverter.json":Vv,"./limit-switch.json":Zv,"./load-switch.json":Jv,"./load.json":tk,"./make-contact.json":ok,"./motor-starter.json":sk,"./ngr.json":lk,"./overcurrent-relay.json":ck,"./phase-failure-relay.json":uk,"./plc.json":fk,"./power-factor-meter.json":pk,"./power-supply.json":yk,"./protective-relay.json":bk,"./proximity-switch.json":vk,"./pt.json":_k,"./push-button.json":Sk,"./pv.json":Ek,"./rcd.json":Tk,"./recloser.json":Ak,"./rectifier.json":Ik,"./relay-coil.json":Pk,"./resistor.json":Lk,"./reverse-power-relay.json":Rk,"./selector-switch.json":Fk,"./series-reactor.json":Wk,"./shunt-capacitor.json":Gk,"./shunt-reactor.json":Kk,"./siren.json":Vk,"./socket-outlet.json":Zk,"./soft-starter.json":Jk,"./sync-motor.json":t_,"./synchronoscope.json":o_,"./terminal.json":s_,"./thermal-overload.json":l_,"./thermocouple.json":c_,"./thyristor.json":u_,"./time-relay.json":f_,"./transfer-switch.json":p_,"./transformer-2w.json":y_,"./transformer-3w.json":b_,"./triac.json":v_,"./undervoltage-relay.json":__,"./ups.json":S_,"./varmeter.json":E_,"./vfd.json":T_,"./voltage-regulator.json":A_,"./voltmeter.json":I_,"./wattmeter.json":P_,"./wind-turbine.json":L_,"./zener-diode.json":R_}),mb=Object.values(D_).map(e=>e.default),Ye=Object.fromEntries(mb.map(e=>[e.id,e])),uo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],F_=(()=>{var t;const e={};for(const n of mb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),pn=new Map(Object.entries(Ye));function fb(e){return Ye[e]}function H_(e){const n=[...e].sort().join("|");let o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const W_=320;function We(e){var m,h,g,f;const t=wr(),n=new Map;e.elements.forEach((p,x)=>{if(n.has(p.id)){t.diagnostics.push({code:"E001",severity:"error",message:be("compile.duplicateId",{id:p.id}),pointer:`/elements/${x}`});return}n.set(p.id,p);const v=pn.get(p.kind);v||t.diagnostics.push({code:"E003",severity:"error",message:`${be("compile.unknownKind",{kind:p.kind})} (id=${p.id})`,pointer:`/elements/${x}`}),t.elements.set(p.id,{element:p,libraryDef:v})});const o=new Map,r=new Map;(e.buses??[]).forEach((p,x)=>{if(n.has(p.id)||o.has(p.id)){t.diagnostics.push({code:"E001",severity:"error",message:be("compile.duplicateId",{id:p.id}),pointer:`/buses/${x}`});return}if(o.set(p.id,p),p.layout){const v=p.layout.rot??0;r.set(p.id,{at:p.layout.at,span:p.layout.span,rot:v,axis:fn(v)})}});const s=p=>!p.includes(".")&&o.has(p),i=(p,x)=>{if(s(p))return!0;const v=p.indexOf(".");if(v<=0)return t.diagnostics.push({code:"E003",severity:"error",message:be("compile.invalidTermRef",{ref:p}),pointer:x}),!1;const b=p.slice(0,v),k=p.slice(v+1),$=t.elements.get(b);if(!$)return t.diagnostics.push({code:"E002",severity:"error",message:be("compile.elementMissing",{id:b}),pointer:x}),!1;if(!$.libraryDef)return!1;if(!$.libraryDef.terminals.find(M=>M.id===k)){const M=$.libraryDef.terminals.map(B=>B.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:be("compile.missingPin",{id:b,kind:$.element.kind,pin:k,available:M}),pointer:x}),!1}return!0},l=[];(e.wires??[]).forEach((p,x)=>{const v=`/wires/${x}`,b=i(p.ends[0],v),k=i(p.ends[1],v);b&&k&&l.push(p)});const a=new Map;if(e.layout)for(const[p,x]of Object.entries(e.layout))t.elements.has(p)?a.set(p,vr(x)):t.diagnostics.push({code:"E004",severity:"error",message:be("compile.layoutMissingElement",{id:p}),pointer:`/layout/${p}`});const d=$2({elements:e.elements,buses:e.buses??[],wires:l,library:pn,userLayout:a,userBusLayout:r});t.layout=d.devices;for(const[p,x]of d.buses){const v=o.get(p);v&&t.buses.set(p,{bus:v,geometry:x})}for(const[p,x]of o)t.buses.has(p)||t.buses.set(p,{bus:x,geometry:{at:((m=x.layout)==null?void 0:m.at)??[0,0],span:((h=x.layout)==null?void 0:h.span)??W_,rot:((g=x.layout)==null?void 0:g.rot)??0,axis:fn(((f=x.layout)==null?void 0:f.rot)??0)}});for(const p of t.elements.values()){if(!p.libraryDef)continue;const x=t.layout.get(p.element.id);if(!x)continue;const v=[];for(const b of p.libraryDef.terminals){const k=`${p.element.id}.${b.id}`,$=Be([b.x,b.y],x),M=yt(b.orientation,x);t.terminals.set(k,{ref:k,elementId:p.element.id,pin:b.id,world:$,orientation:M}),v.push(k)}t.elementToTerminals.set(p.element.id,v)}const u=new kr;for(const p of l)u.add(p.ends[0]),u.add(p.ends[1]),u.union(p.ends[0],p.ends[1]);for(const[,p]of u.groups()){const x=H_(p);t.nodes.set(x,{id:x,terminals:p});for(const v of p)t.terminalToNode.set(v,x)}for(const p of t.elements.values()){const x=t.elementToTerminals.get(p.element.id)??[];if(x.length===0)continue;x.some(b=>t.terminalToNode.has(b))||t.diagnostics.push({code:"W001",severity:"warning",message:be("compile.elementUnconnected",{id:p.element.id})})}for(const p of t.buses.keys())t.terminalToNode.has(p)||t.diagnostics.push({code:"W001",severity:"warning",message:be("compile.elementUnconnected",{id:p})});for(const p of l){if(p.path&&p.path.length>=2){const v=p.path,b=v.length>=2?v[1]:null,k=v.length>=2?v[v.length-2]:null,$=ao(p.ends[0],b,t),M=ao(p.ends[1],k,t);if($&&M){const B=[[$[0],$[1]],...v.slice(1,-1).map(J=>[J[0],J[1]]),[M[0],M[1]]],te=br(B);if(te.length>=2){t.wireRenders.set(p.id,{wireId:p.id,path:te,userEdited:!0});continue}}}const x=S2(p,t);x&&t.wireRenders.set(p.id,x)}return t}const q_={earth:"GND",breaker:"QF",disconnector:"QS","earthing-switch":"QE","load-switch":"QL",fuse:"FU","transformer-2w":"T","transformer-3w":"T",autotransformer:"AT",ct:"CT",pt:"PT",generator:"G","sync-motor":"M","async-motor":"M","grid-source":"L",load:"L",battery:"BAT","shunt-reactor":"LR","series-reactor":"LR","shunt-capacitor":"C",arrester:"FBL","grounding-transformer":"TG",ngr:"NGR","arc-suppression-coil":"ASC",pv:"PV","wind-turbine":"WT",rectifier:"RT",inverter:"INV","converter-bidir":"PCS"},mo="B";function hb(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id)])}function wt(e,t){const n=q_[t]??t,o=hb(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function gn(e){const t=hb(e);let n=1;for(;t.has(`${mo}${n}`);)n++;return`${mo}${n}`}function G_(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function vt(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}const fo={version:"1",elements:[]},Y_=100,ho=20;function K_(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const y=Ft()(g2((e,t)=>({diagram:fo,internal:We(fo),fileSession:null,activeTool:K_(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:We(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:We(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=Y_?r.slice(1):r;e({diagram:s,internal:We(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:We(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,placeFromTerminal:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:We(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,placeFromTerminal:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:X_(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var m;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(h=>s.has(h.id)).map(h=>structuredClone(h)),l=(o.buses??[]).filter(h=>s.has(h.id)).map(h=>structuredClone(h)),a={};for(const h of n)if(s.has(h)&&!r.buses.has(h)){const g=(m=o.layout)==null?void 0:m[h];if(g){a[h]=structuredClone(g);continue}const f=r.layout.get(h);f&&(a[h]=Nt(f))}const d={};for(const h of n){const g=r.buses.get(h);g&&(d[h]=Ze(g.geometry))}const u=(o.wires??[]).filter(h=>h.ends.every(g=>s.has(Jt(g)))).map(h=>structuredClone(h));e({clipboard:{elements:i,buses:l,placements:a,busLayouts:d,wires:u},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0)return;const s=o+1,i=ho*s,l=ho*s,a=new Map;let d=r;for(const m of n.elements){const h=wt(d,m.kind);a.set(m.id,h),d={...d,elements:[...d.elements,{id:h,kind:m.kind}]}}for(const m of n.buses){const h=gn(d);a.set(m.id,h),d={...d,buses:[...d.buses??[],{id:h}]}}const u=m=>{const h=m.indexOf("."),g=h<0?m:m.slice(0,h),f=a.get(g);return f?h<0?f:`${f}${m.slice(h)}`:m};t().dispatch(m=>{const h=n.elements.map(v=>{const b=structuredClone(v);return b.id=a.get(v.id),b}),g=n.buses.map(v=>{const b=structuredClone(v);b.id=a.get(v.id);const k=n.busLayouts[v.id];return k&&(b.layout={...k,at:[k.at[0]+i,k.at[1]+l]}),b}),f={...m.layout??{}};for(const[v,b]of a){const k=n.placements[v];k&&(f[b]={...k,at:[k.at[0]+i,k.at[1]+l]})}const p=n.wires.map(v=>{const b=[u(v.ends[0]),u(v.ends[1])];return{id:vt(b[0],b[1]),ends:b}}),x=V_(m.wires??[],p);return{...m,elements:[...m.elements,...h],buses:g.length?[...m.buses??[],...g]:m.buses,wires:x.length?x:void 0,layout:Object.keys(f).length?f:void 0}}),e({selection:Array.from(a.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var a;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(d=>d.layout);if(!o&&!r)return n;const{layout:s,...i}=n,l=(a=n.buses)==null?void 0:a.map(d=>{const{layout:u,...m}=d;return m});return{...i,buses:l}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const a={};for(const[d,u]of Object.entries(i)){if(o.has(d)){s=!0;continue}a[d]=u}s&&(i=Object.keys(a).length?a:void 0)}let l=r.buses;if(l){const a=l.map(d=>{if(o.has(d.id)&&d.layout){s=!0;const{layout:u,...m}=d;return m}return d});s&&(l=a)}return s?{...r,layout:i,buses:l}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const a of o.elements){if(r[a.id])continue;const d=n.layout.get(a.id);d&&(s[a.id]=Nt(d))}const i=[];if((o.buses??[]).forEach((a,d)=>{a.layout||n.buses.has(a.id)&&i.push({idx:d,bus:a})}),Object.keys(s).length===0&&i.length===0)return o;let l=o.buses;return i.length>0&&l&&(l=l.map(a=>{const d=n.buses.get(a.id);return!a.layout&&d?{...a,layout:Ze(d.geometry)}:a})),{...o,layout:{...r,...s},buses:l}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var d;const s=r.layout??{},i={},l=new Map;for(const u of n)if(o.buses.has(u)){const m=o.buses.get(u);(d=r.buses)!=null&&d.find(h=>h.id===u&&h.layout)||l.set(u,Ze(m.geometry))}else{if(s[u])continue;const m=o.layout.get(u);m&&(i[u]=Nt(m))}if(Object.keys(i).length===0&&l.size===0)return r;let a=r.buses;return l.size>0&&a&&(a=a.map(u=>l.has(u.id)?{...u,layout:l.get(u.id)}:u)),{...r,layout:{...s,...i},buses:a}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map;for(const[a,d]of n){if(o.buses.has(a)){i.set(a,d);continue}const u=o.layout.get(a),m=s[a]??(u?Nt(u):{at:[0,0]});s[a]={...m,at:[m.at[0]+d[0],m.at[1]+d[1]]}}let l=r.buses;return i.size>0&&(l=(r.buses??[]).map(a=>{const d=i.get(a.id);if(!d)return a;const u=a.layout??Ze(o.buses.get(a.id).geometry);return{...a,layout:{...u,at:[u.at[0]+d[0],u.at[1]+d[1]]}}})),{...r,layout:s,buses:l}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(d=>!o.has(d.id)),i=(r.buses??[]).filter(d=>!o.has(d.id)),l=(r.wires??[]).filter(d=>!o.has(Jt(d.ends[0]))&&!o.has(Jt(d.ends[1]))),a=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([d])=>!o.has(d))):void 0;return{...r,elements:s,buses:i.length?i:void 0,wires:l.length?l:void 0,layout:a&&Object.keys(a).length?a:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const l=i.indexOf(".");l>0&&s.add(i.slice(0,l))}t().dispatch(i=>{const l=(i.wires??[]).filter(d=>d.id!==n);if(l.length===(i.wires??[]).length)return i;const a={...i.layout??{}};for(const d of s){if(a[d])continue;const u=o.layout.get(d);if(!u)continue;const m={at:u.at};u.rot&&(m.rot=u.rot),u.mirror&&(m.mirror=u.mirror),a[d]=m}return{...i,wires:l.length?l:void 0,layout:Object.keys(a).length?a:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const l of r.terminals){const a=l.indexOf(".");a>0&&i.add(l.slice(0,a))}t().dispatch(l=>{const a={...l.layout??{}};for(const u of i){if(a[u])continue;const m=o.layout.get(u);if(!m)continue;const h={at:m.at};m.rot&&(h.rot=m.rot),m.mirror&&(h.mirror=m.mirror),a[u]=h}const d=(l.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...l,wires:d.length?d:void 0,layout:Object.keys(a).length?a:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var d,u,m,h;const i={...s.layout??{}},l=new Map;for(const g of o){if(r.buses.has(g)){const x=r.buses.get(g),b=(((((m=(u=(d=s.buses)==null?void 0:d.find(k=>k.id===g))==null?void 0:u.layout)==null?void 0:m.rot)??x.geometry.rot??0)+n)%360+360)%360;l.set(g,b);continue}const f=i[g]??{at:((h=r.layout.get(g))==null?void 0:h.at)??[0,0]},p=(((f.rot??0)+n)%360+360)%360;i[g]={...f,rot:p}}let a=s.buses;return l.size>0&&(a=(s.buses??[]).map(g=>{if(!l.has(g.id))return g;const f=g.layout??Ze(r.buses.get(g.id).geometry);return{...g,layout:{...f,rot:l.get(g.id)}}})),{...s,layout:i,buses:a}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const l of n){if(o.buses.has(l))continue;const a=s[l]??{at:((i=o.layout.get(l))==null?void 0:i.at)??[0,0]};s[l]={...a,mirror:!(a.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=wt(t().diagram,n);return t().dispatch(i=>{const l={id:s,kind:n,...r??{}};return{...i,elements:[...i.elements,l],layout:{...i.layout??{},[s]:{at:o}}}}),e({selection:[s]}),s},addBus:(n,o,r)=>{const s=gn(t().diagram);return t().dispatch(i=>{const l={id:s,layout:r!==void 0?{at:n,span:o,rot:r}:{at:n,span:o}};return{...i,buses:[...i.buses??[],l]}}),e({selection:[s]}),s},addWire:(n,o)=>{if(n===o)return;const r=vt(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(l=>l.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(d=>d.id===n))return r;const i=o&&o.length>=2?br(o):null,l=i&&i.length>=2?i:null,a=s.map(d=>{if(d.id!==n)return d;if(l)return{...d,path:l};const{path:u,...m}=d;return m});return{...r,wires:a}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var l;const s=((l=r.layout)==null?void 0:l[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const l=t().internal,a=i.layout??(l.buses.has(n)?Ze(l.buses.get(n).geometry):{at:[0,0],span:320}),d={at:o.at??a.at,span:o.span??a.span,...o.rot!==void 0?{rot:o.rot}:a.rot?{rot:a.rot}:{}};return{...i,layout:d}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=G_(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const l=s.map(a=>a.id!==n?a:(i=!0,{...a,...o,id:a.id}));return i?{...r,annotations:l}:r})},deleteAnnotation:n=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:xr(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=We(e.diagram))}}));function X_(e){return Array.from(new Set(e))}function Jt(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function V_(e,t){const n=new Set(e.map(r=>r.id)),o=e.slice();for(const r of t)n.has(r.id)||(n.add(r.id),o.push(r));return o}function Nt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function Ze(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let pb=null;function po(e){pb=e}function Ue(){return pb}const Bt=10;function gb(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function ne(e){return gb()?Math.round(e/Bt)*Bt:e}const U_=30,Z_=144;function yb(e,t){const n=Ye[e],o=y.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=Q_(r,t);if(!s){const p=xb(n),x=p?[ne(t[0])-p.x,ne(t[1])-p.y]:[ne(t[0]),ne(t[1])];return{newElementId:o.addElement(e,x),attachedToBus:!1}}const{busId:i,busAt:l,axis:a}=s,d=J_(n,a),u=wt(r,e),m=n.terminals.find(p=>p.id===d),h=a==="x"?t[0]:l[0],g=a==="y"?t[1]:l[1],f=m?[ne(h)-m.x,ne(g)-m.y]:[ne(t[0]),ne(t[1])];return o.dispatch(p=>{const x={id:u,kind:e},v={at:f},b=`${u}.${d}`,k={id:vt(i,b),ends:[i,b]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],k],layout:{...p.layout??{},[u]:v}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function Q_(e,t){const n=y.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:l,span:a}=s.geometry;let d;if(i==="x"){const u=l[0]-a/2,m=l[0]+a/2,h=t[0]<u?u-t[0]:t[0]>m?t[0]-m:0,g=Math.abs(t[1]-l[1]);d=Math.sqrt(h*h+g*g)}else{const u=l[1]-a/2,m=l[1]+a/2,h=t[1]<u?u-t[1]:t[1]>m?t[1]-m:0,g=Math.abs(t[0]-l[0]);d=Math.sqrt(g*g+h*h)}d<=U_&&(!o||d<o.dist)&&(o={busId:r.id,busAt:[l[0],l[1]],axis:i,dist:d})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function J_(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,r)=>t==="x"?o.y-r.y:o.x-r.x)[0].id}function xb(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function bb(e,t){const n=y.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:l}=r.geometry;if(s==="x"){const g=i[0]-l/2,f=i[0]+l/2,p=Math.max(g,Math.min(f,t[0])),x=i[1],v=t[1]>=x?"s":"n";return{ref:e,world:[p,x],orientation:v,isBus:!0,busId:e}}const a=i[1]-l/2,d=i[1]+l/2,u=Math.max(a,Math.min(d,t[1])),m=i[0],h=t[0]>=m?"e":"w";return{ref:e,world:[m,u],orientation:h,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const e$={n:"s",s:"n",e:"w",w:"e"};function wb(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=e$[t.orientation],r=e.terminals.filter(a=>a.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],l=go(i,n,t.world);for(let a=1;a<s.length;a++){const d=s[a],u=go(d,n,t.world);u<l&&(l=u,i=d)}return i}function go(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function t$(e,t,n){const o=Ye[e],r=y.getState(),s=r.diagram;if(!o)return null;const i=bb(t,n);if(!i)return null;const l=n[0]-i.world[0],a=n[1]-i.world[1],d=l*l+a*a<=Z_,u=[ne(n[0]),ne(n[1])],m=wb(o,i,u),h=d?i.world:u,g=[ne(h[0]-m.x),ne(h[1]-m.y)],f=wt(s,e);return r.dispatch(p=>{const x={id:f,kind:e},v={at:g},b=`${f}.${m.id}`,k=i.isBus&&i.busId?i.busId:t,$={id:vt(k,b),ends:[k,b]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],$],layout:{...p.layout??{},[f]:v}}}),r.setSelection([f]),{newElementId:f,attachedToBus:i.isBus}}const Ht=9,Lt=7;function Wt(e,t){var s,i;const n=[],o=((s=e.element.name)==null?void 0:s.trim())||e.element.id;if(o&&n.push(o),t!=="all"||!((i=e.libraryDef)!=null&&i.params))return n;const r=e.element.params??{};for(const l of e.libraryDef.params){if(!l.showOnCanvas)continue;const a=r[l.name];a==null||a===""||n.push(`${a}${l.unit??""}`)}return n}function qt(e){const t=n$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Gt(e,t){let n=e.x,o=e.y;switch(t.mirror&&(n=-n),t.rot){case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function n$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function o$(){const e=y(r=>r.internal.elements),t=y(r=>r.internal.layout),n=y(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=y(r=>r.editingElement);return c.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var u;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??qt(r.libraryDef),l=Gt(i,s),a=i.anchor??"start";if(o===r.element.id)return c.jsx(r$,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:l,anchor:a},r.element.id);if(n==="off")return null;const d=Wt(r,n);return d.length===0?null:c.jsx("g",{className:"ole-annotation",transform:`translate(${l[0]} ${l[1]})`,children:d.map((m,h)=>c.jsx("text",{x:0,y:h*Ht,textAnchor:a,className:"ole-annotation-text",children:m},h))},r.element.id)})})}const en=200,tn=9;function r$({elementId:e,currentName:t,world:n,anchor:o}){const r=S.useRef(null);S.useEffect(()=>{const a=r.current;if(!a)return;a.focus();const d=document.createRange();d.selectNodeContents(a);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(d)},[e]);function s(){var h;const a=y.getState(),d=a.diagram.elements.find(g=>g.id===e);if(!d){a.setEditingElement(null);return}const u=(((h=r.current)==null?void 0:h.innerText)??"").replace(/\u00a0/g," ").trim(),m=u===""||u===e?void 0:u;m!==d.name&&a.updateElement(e,{name:m}),a.setEditingElement(null)}function i(a){if(a.key==="Escape"||a.key==="Enter"&&!a.shiftKey){a.preventDefault(),s();return}a.stopPropagation()}let l=n[0];return o==="middle"?l-=en/2:o==="end"&&(l-=en),c.jsx("foreignObject",{x:l,y:n[1]-tn,width:en,height:tn*2.2,className:"ole-element-name-editor",children:c.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${tn}px`,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",display:"inline-block",minWidth:"20px",lineHeight:1.1,textAlign:o==="middle"?"center":o==="end"?"right":"left",whiteSpace:"nowrap",cursor:"text"},children:t})})}const vb=8,zt=1.25;function s$(){const e=y(o=>o.diagram.annotations),t=y(o=>o.selectedAnnotation),n=y(o=>o.editingAnnotation);return!e||e.length===0?null:c.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?c.jsx(l$,{ann:o},o.id):c.jsx(i$,{ann:o,isSelected:t===o.id},o.id))})}function i$({ann:e,isSelected:t}){const n=e.fontSize??vb,o=e.text===""?[""]:e.text.split(`
|
|
193
|
-
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*zt;return c.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,className:"ole-free-annotation-halo"}),o.map((i,l)=>c.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+l*n*zt,fontSize:n,className:"ole-free-annotation-text",children:i},l))]})}function l$({ann:e}){const t=S.useRef(null),n=e.fontSize??vb;S.useEffect(()=>{const l=t.current;if(!l)return;l.focus();const a=document.createRange();a.selectNodeContents(l);const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(a)},[e.id]);function o(){var d;const l=y.getState(),a=(((d=t.current)==null?void 0:d.innerText)??"").replace(/\u00a0/g," ").trimEnd();a===""?l.deleteAnnotation(e.id):a!==e.text&&l.updateAnnotation(e.id,{text:a}),l.setEditingAnnotation(null),a!==""&&l.setSelectedAnnotation(e.id),l.activeTool==="text"&&l.setActiveTool("select")}function r(l){if(l.key==="Escape"){l.preventDefault(),o();return}if(l.key==="Enter"&&!l.shiftKey){l.preventDefault(),o();return}l.stopPropagation()}return c.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:c.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:zt,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",minWidth:`${n}px`,minHeight:`${n*zt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const a$=20;function c$(){const e=y(u=>u.selection),t=y(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,l=i/2,a=r==="x"?[s[0]-l,s[1]]:[s[0],s[1]-l],d=r==="x"?[s[0]+l,s[1]]:[s[0],s[1]+l];return c.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[c.jsx(yo,{x:a[0],y:a[1],busId:n,side:"start",axis:r}),c.jsx(yo,{x:d[0],y:d[1],busId:n,side:"end",axis:r})]})}function yo({x:e,y:t,busId:n,side:o,axis:r}){const s=Ue(),i=S.useRef(null),l=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const m=y.getState().internal.buses.get(n);m&&(i.current={pointerId:u.pointerId,startSpan:m.geometry.span,startAt:[...m.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},a=u=>{const m=i.current;if(!m||u.pointerId!==m.pointerId||!s)return;const h=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?h[0]-m.startSvg[0]:h[1]-m.startSvg[1],f=gb()?Math.round(g/Bt)*Bt:g,p=m.startSpan+(o==="end"?f:-f);if(p<a$)return;const x=r==="x"?[m.startAt[0]+f/2,m.startAt[1]]:[m.startAt[0],m.startAt[1]+f/2];y.getState().updateBus(n,{span:p,at:x})},d=u=>{const m=i.current;!m||u.pointerId!==m.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return c.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:l,onPointerMove:a,onPointerUp:d,onPointerCancel:d})}const yn=.5;function xt(e,t){return Math.abs(e[1]-t[1])<yn?"h":"v"}function d$(){const e=y(l=>l.selectedWire),t=y(l=>l.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let l=1;l<r-1;l++){const a=xt(o[l-1],o[l]),d=xt(o[l],o[l+1]),u=l-1===0,m=l+1===r-1,h=u&&a==="v"||m&&d==="v",g=u&&a==="h"||m&&d==="h";h&&g||s.push(c.jsx(u$,{wireId:e,index:l,xLocked:h,yLocked:g},`v-${l}`))}const i=[];for(let l=0;l<r-1;l++){const a=o[l],d=o[l+1];Math.abs(a[0]-d[0])<yn&&Math.abs(a[1]-d[1])<yn||i.push(c.jsx(m$,{wireId:e,segIndex:l,axis:xt(a,d)},`m-${l}`))}return c.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function u$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ue(),s=S.useRef(null),i=y(f=>{var p;return(p=f.internal.wireRenders.get(e))==null?void 0:p.path});if(!i||t<=0||t>=i.length-1)return null;const[l,a]=i[t],d=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!r))return;const p=y.getState().internal.wireRenders.get(e);p&&(s.current={pointerId:f.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:r.screenToSvg(f.clientX,f.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=d,f.target.setPointerCapture(f.pointerId))},m=f=>{const p=s.current;if(!p||f.pointerId!==p.pointerId||!r)return;const x=r.screenToSvg(f.clientX,f.clientY),v=p.startPath,b=p.index;if(b<=0||b>=v.length-1)return;const k=v[b],$=[p.xLocked?k[0]:ne(k[0]+(x[0]-p.startSvg[0])),p.yLocked?k[1]:ne(k[1]+(x[1]-p.startSvg[1]))];if($[0]===k[0]&&$[1]===k[1])return;const M=v.map(J=>[J[0],J[1]]);M[b]=$;const B=xt(v[b-1],v[b]);b-1>0&&(B==="h"?M[b-1]=[v[b-1][0],$[1]]:M[b-1]=[$[0],v[b-1][1]]);const te=xt(v[b],v[b+1]);b+1<v.length-1&&(te==="h"?M[b+1]=[v[b+1][0],$[1]]:M[b+1]=[$[0],v[b+1][1]]),y.getState().updateWirePath(e,M)},h=f=>{const p=s.current;!p||f.pointerId!==p.pointerId||(f.target.hasPointerCapture(f.pointerId)&&f.target.releasePointerCapture(f.pointerId),s.current=null,document.body.style.cursor="")},g=f=>{f.stopPropagation(),f.preventDefault();const p=y.getState().internal.wireRenders.get(e);if(!p||p.path.length<=2||t<=0||t>=p.path.length-1)return;const x=p.path.filter((v,b)=>b!==t);y.getState().updateWirePath(e,x)};return c.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:l,cy:a,r:5,style:{cursor:d},onPointerDown:u,onPointerMove:m,onPointerUp:h,onPointerCancel:h,onDoubleClick:g})}function m$({wireId:e,segIndex:t,axis:n}){const o=Ue(),r=S.useRef(null),s=y(f=>{var p;return(p=f.internal.wireRenders.get(e))==null?void 0:p.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],l=s[t+1],a=(i[0]+l[0])/2,d=(i[1]+l[1])/2,u=n==="h"?"ns-resize":"ew-resize",m=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!o))return;const p=y.getState().internal.wireRenders.get(e);p&&(r.current={pointerId:f.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:o.screenToSvg(f.clientX,f.clientY),axis:n,segIndex:t},document.body.style.cursor=u,f.currentTarget.setPointerCapture(f.pointerId))},h=f=>{const p=r.current;if(!p||f.pointerId!==p.pointerId||!o)return;const x=o.screenToSvg(f.clientX,f.clientY),v=p.startPath,b=p.segIndex;if(b>=v.length-1)return;const k=v[b],$=v[b+1],M=[];for(let B=0;B<=b;B++)M.push(v[B]);if(p.axis==="h"){const B=ne(k[1]+(x[1]-p.startSvg[1]));M.push([k[0],B]),M.push([$[0],B])}else{const B=ne(k[0]+(x[0]-p.startSvg[0]));M.push([B,k[1]]),M.push([B,$[1]])}for(let B=b+1;B<v.length;B++)M.push(v[B]);y.getState().updateWirePath(e,M)},g=f=>{const p=r.current;if(!p||f.pointerId!==p.pointerId)return;const x=f.currentTarget;x.hasPointerCapture(f.pointerId)&&x.releasePointerCapture(f.pointerId),r.current=null,document.body.style.cursor=""};return c.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,children:[c.jsx("circle",{className:"ole-wire-midpoint-hit",cx:a,cy:d,r:8}),c.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:a,cy:d,r:3.5})]})}const f$=3,nn=12;function h$(){const e=y(l=>l.internal.buses),t=y(l=>l.selection),n=y(l=>l.selectedNode),o=y(l=>l.internal.nodes),r=y(l=>l.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const l=o.get(n);if(l)for(const a of l.terminals)a.includes(".")||i.add(a)}return c.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:l,geometry:a})=>{const{axis:d,at:u,span:m}=a,h=m/2,g=d==="x"?u[0]-h:u[0],f=d==="x"?u[1]:u[1]-h,p=d==="x"?u[0]+h:u[0],x=d==="x"?u[1]:u[1]+h,v=s.has(l.id),b=i.has(l.id),k=r.get(l.id)??void 0,$=nn/2,M=d==="x"?u[0]-h:u[0]-$,B=d==="x"?u[1]-$:u[1]-h,te=d==="x"?m:nn,J=d==="x"?nn:m;return c.jsxs("g",{"data-bus-id":l.id,"data-element-id":l.id,"data-node-id":k,"data-selected":v?"true":void 0,"data-node-related":b?"true":void 0,className:"ole-bus",children:[c.jsx("rect",{x:M,y:B,width:te,height:J,fill:"transparent",className:"ole-bus-hit"}),c.jsx("line",{x1:g,y1:f,x2:p,y2:x,stroke:"currentColor",strokeWidth:f$,strokeLinecap:"round",fill:"none"})]},l.id)})})}function p$(){const e=y(l=>l.busbarDrawStart),t=y(l=>l.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return c.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[c.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),c.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),c.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}function Ge(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function g$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function y$({lib:e}){const t=g$(e.viewBox);return t?c.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function x$(){const e=y(l=>l.internal.elements),t=y(l=>l.internal.layout),n=y(l=>l.selection),o=y(l=>l.selectedNode),r=y(l=>l.internal.nodes),s=new Set(n),i=new Set;if(o){const l=r.get(o);if(l)for(const a of l.terminals){const d=a.indexOf(".");d>0&&i.add(a.slice(0,d))}}return c.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(l=>{const a=t.get(l.element.id);if(!a)return null;const d=s.has(l.element.id),u=i.has(l.element.id);return l.libraryDef?c.jsxs("g",{"data-element-id":l.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ge(a),className:"ole-element",children:[c.jsx(y$,{lib:l.libraryDef}),c.jsx("g",{dangerouslySetInnerHTML:{__html:l.libraryDef.svg}})]},l.element.id):c.jsxs("g",{"data-element-id":l.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ge(a),className:"ole-element ole-element--unknown",children:[c.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),c.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},l.element.id)})})}let kb=null;const xn=new Set;function Tt(e){kb=e;for(const t of xn)t(e)}function b$(){return kb}function w$(e){return xn.add(e),()=>{xn.delete(e)}}function v$(){const[e,t]=S.useState(b$());return S.useEffect(()=>w$(t),[]),!e||e.w===0&&e.h===0?null:c.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function k$(){const e=y(d=>d.activeTool),t=y(d=>d.placeKind),n=y(d=>d.cursorSvg),o=y(d=>d.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=fb(t);if(!r)return null;let s=null,i=null;if(o){const d=bb(o,n);d&&(s=wb(r,d,n),i={source:d.world,pin:n})}else s=xb(r);const l=n[0]-((s==null?void 0:s.x)??0),a=n[1]-((s==null?void 0:s.y)??0);return c.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),c.jsx("g",{className:"ole-place-ghost",transform:`translate(${l} ${a})`,opacity:.5,children:c.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function _$(){const e=y(r=>r.selection),t=y(r=>r.internal.elements),n=y(r=>r.internal.layout),o=y(r=>r.internal.buses);return e.length===0?null:c.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:d,at:u,span:m}=s.geometry,h=m/2,g=d==="x"?u[0]-h:u[0]-4,f=d==="x"?u[1]-4:u[1]-h,p=d==="x"?m:8,x=d==="x"?8:m;return c.jsx("rect",{x:g,y:f,width:p,height:x,fill:"none",className:"ole-selection-rect"},r)}const i=t.get(r),l=n.get(r);if(!(i!=null&&i.libraryDef)||!l)return null;const a=$$(i.libraryDef.viewBox);return a?c.jsx("rect",{x:a.x,y:a.y,width:a.w,height:a.h,fill:"none",className:"ole-selection-rect",transform:Ge(l)},r):null})})}function $$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function S$(){const e=y(s=>s.internal.terminals),t=y(s=>s.internal.terminalToNode),n=y(s=>s.wireFromTerminal),o=y(s=>s.selection),r=new Set(o);return c.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),l=i!==void 0,a=n===s.ref,d=r.has(s.elementId);return c.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":l?"true":"false","data-active":a?"true":void 0,"data-on-selected":d?"true":void 0,className:"ole-terminal"},s.ref)})})}function j$(){const e=y(i=>i.internal.wireRenders),t=y(i=>i.internal.terminalToNode),n=y(i=>i.diagram.wires),o=y(i=>i.selectedWire),r=y(i=>i.selectedNode),s=new Map;for(const i of n??[]){const l=t.get(i.ends[0]);l&&s.set(i.id,l)}return c.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:Array.from(e.values()).flatMap(i=>{const l=i.path;if(l.length<2)return[];const a=l.map(h=>`${h[0]},${h[1]}`).join(" "),d=s.get(i.wireId),u=o===i.wireId,m=r!=null&&r===d;return[c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,className:"ole-wire-hit",points:a},`hit-${i.wireId}`),c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,"data-manual":i.userEdited?"true":void 0,"data-selected":u||m?"true":void 0,className:"ole-wire",points:a},i.wireId)]})})}let Ve=null;const bn=new Set;function Ie(e){if(!(e===null&&Ve===null||e&&Ve&&e.ref===Ve.ref&&e.world[0]===Ve.world[0]&&e.world[1]===Ve.world[1])){Ve=e;for(const t of bn)t(e)}}function E$(){return Ve}function N$(e){return bn.add(e),()=>{bn.delete(e)}}function T$(){var d,u;const e=y(m=>m.wireFromTerminal),t=y(m=>m.cursorSvg),n=y(m=>m.internal.terminals),[o,r]=S.useState(E$());S.useEffect(()=>N$(r),[]);const s=y(m=>m.internal.buses);if(!e||!t)return null;let i;if(e.includes(".")?i=(d=n.get(e))==null?void 0:d.world:i=(u=s.get(e))==null?void 0:u.geometry.at,!i)return null;const l=(o==null?void 0:o.world[0])??t[0],a=(o==null?void 0:o.world[1])??t[1];return c.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[c.jsx("line",{x1:i[0],y1:i[1],x2:l,y2:a,className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i[0],cy:i[1],r:4,className:"ole-wire-preview-anchor"}),o&&c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?7:8,className:"ole-wire-preview-target-ring"}),c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function rt(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function nt(e){var t;return((t=rt(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function M$(e){var t;return((t=rt(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function qe(e){var o;const t=(o=rt(e,"data-terminal-id"))==null?void 0:o.getAttribute("data-terminal-id");if(t)return t;const n=M$(e);return n||null}function Yt(e){var t;return((t=rt(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function xo(e){var t;return((t=rt(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Rt(e){var t;return((t=rt(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function _b(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function A$(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function $b(){const e=y.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="text"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function C$(){S.useEffect(()=>{const e=t=>{if(A$(t.target))return;const n=t.metaKey||t.ctrlKey,o=y.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=y.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":$b();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let wn=null;const vn=new Set;function I$(e){if(e!==wn){wn=e;for(const t of vn)t(e)}}function O$(){return wn}function P$(e){return vn.add(e),()=>{vn.delete(e)}}const bo="ole-hover-element-host",B$="ole-hover-terminal-on",L$="ole-hover-node-on";function z$(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(m,h,g)=>{for(const f of m)f.classList.remove(g);m.clear();for(const f of h)f.classList.add(g),m.add(f)},l=m=>{var g,f;if(m===n)return;n&&((g=t.querySelector(`[data-element-id="${Mt(n)}"]`))==null||g.classList.remove(bo)),m&&((f=t.querySelector(`[data-element-id="${Mt(m)}"]`))==null||f.classList.add(bo));const h=m?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Mt(m)}"]`)):[];i(r,h,B$),n=m,m?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),I$(m)},a=m=>{if(m===o)return;const h=m?Array.from(t.querySelectorAll(`[data-node-id="${Mt(m)}"]`)):[];i(s,h,L$),o=m,m?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},d=m=>{l(nt(m.target));const h=qe(m.target);let g=null;h?g=y.getState().internal.terminalToNode.get(h)??null:g=Yt(m.target),a(g)},u=()=>{l(null),a(null)};return t.addEventListener("pointermove",d),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",d),t.removeEventListener("pointerleave",u),l(null),a(null)}},[e])}function Mt(e){return e.replace(/(["\\])/g,"\\$1")}function Sb(e,t){const n=y.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(!r)return null;const{axis:s,at:i,span:l}=r.geometry;if(s==="x"){const m=i[0]-l/2,h=i[0]+l/2,g=Math.max(m,Math.min(h,t[0]));return{ref:e,world:[g,i[1]],isBus:!0}}const a=i[1]-l/2,d=i[1]+l/2,u=Math.max(a,Math.min(d,t[1]));return{ref:e,world:[i[0],u],isBus:!0}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const wo=3;let ie=null,$e=null,Se=null,le=null;const R$={id:"select",cursor:"default",onPointerDown(e,t){var h,g,f,p,x,v,b;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=y.getState(),o=Rt(e.target);if(o){e.preventDefault(),e.stopPropagation();const k=(h=n.diagram.annotations)==null?void 0:h.find($=>$.id===o);if(!k)return;n.setSelectedAnnotation(o),le={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[k.at[0],k.at[1]],moved:!1};return}const s=(e.target instanceof Element?(g=e.target.closest("[data-terminal-id]"))==null?void 0:g.getAttribute("data-terminal-id"):null)?qe(e.target):null;if(s){const k=s.indexOf("."),$=k>0?s.slice(0,k):"";if($&&n.selection.includes($)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((p=(f=e.target).hasPointerCapture)!=null&&p.call(f,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Se={pointerId:e.pointerId,fromRef:s};return}}let i=nt(e.target);if(!i){const k=xo(e.target);if(k&&typeof document<"u"){const $=document.elementsFromPoint(e.clientX,e.clientY);for(const M of $){const B=(v=(x=M.closest)==null?void 0:x.call(M,"[data-bus-id]"))==null?void 0:v.getAttribute("data-bus-id");if(!B)continue;const te=(b=n.diagram.wires)==null?void 0:b.find(J=>J.id===k);te&&(te.ends[0]===B||te.ends[1]===B)&&(i=B);break}}}if(!i){const k=xo(e.target);if(k){if(e.preventDefault(),e.altKey){const $=Yt(e.target);if($){n.setSelectedNode($);return}}n.setSelectedWire(k);return}e.shiftKey||n.clearSelection(),$e={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const l=n.selection;e.shiftKey?n.toggleInSelection(i):l.includes(i)||n.setSelection([i]);const a=e.shiftKey?y.getState().selection:l.includes(i)?l:[i];if(a.length===0)return;const d=y.getState().internal,u=new Map,m=new Map;for(const k of a){const $=d.buses.get(k);if($){m.set(k,[$.geometry.at[0],$.geometry.at[1]]);continue}const M=d.layout.get(k);M&&u.set(k,{...M})}u.size===0&&m.size===0||(ie={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:m,moved:!1},e.preventDefault())},onPointerMove(e,t){if(le&&e.pointerId===le.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]);!le.moved&&(o!==0||r!==0)&&(le.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${He(le.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Se&&e.pointerId===Se.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?qe(o):null;if(!r||r===Se.fromRef){Ie(null);return}Ie(Sb(r,n));return}if(ie&&e.pointerId===ie.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-ie.startSvg[0]),r=ne(n[1]-ie.startSvg[1]);!ie.moved&&(o!==0||r!==0)&&(ie.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ie.originals){const l=t.hostEl.querySelector(`[data-element-id="${He(s)}"]`);if(!l)continue;const a={...i,at:[i.at[0]+o,i.at[1]+r]};l.setAttribute("transform",Ge(a))}for(const s of ie.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${He(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if($e&&e.pointerId===$e.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);Tt(vo($e.startSvg,n));return}},onPointerUp(e,t){if(le&&e.pointerId===le.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${He(le.id)}"]`);s&&s.removeAttribute("transform"),le.moved&&(o!==0||r!==0)&&y.getState().updateAnnotation(le.id,{at:[le.origin[0]+o,le.origin[1]+r]}),le=null;return}if(Se&&e.pointerId===Se.pointerId){const n=y.getState(),o=Se.fromRef;Se=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Ie(null);const r=qe(e.target);r&&r!==o&&n.addWire(o,r);return}if(ie&&e.pointerId===ie.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ie.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-ie.startSvg[0]),r=ne(n[1]-ie.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ie.originals.keys())s.set(i,[o,r]);for(const i of ie.busOriginals.keys())s.set(i,[o,r]);y.getState().moveElements(s)}for(const s of ie.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${He(s)}"]`);i&&i.removeAttribute("transform")}}ie=null;return}if($e&&e.pointerId===$e.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=vo($e.startSvg,n);if(o.w>=wo||o.h>=wo){const r=D$(o);if($e.shiftKey){const s=new Set($e.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);y.getState().setSelection([...s])}else y.getState().setSelection(r)}Tt(null),$e=null}},onPointerCancel(e,t){var n,o,r,s,i,l;if(le&&e.pointerId===le.pointerId){const a=t.hostEl.querySelector(`[data-annotation-id="${He(le.id)}"]`);if(a&&a.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}le=null}if(ie&&e.pointerId===ie.pointerId){for(const[a,d]of ie.originals){const u=t.hostEl.querySelector(`[data-element-id="${He(a)}"]`);u&&u.setAttribute("transform",Ge(d))}for(const a of ie.busOriginals.keys()){const d=t.hostEl.querySelector(`[data-element-id="${He(a)}"]`);d&&d.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ie=null}if(Se&&e.pointerId===Se.pointerId){t.hostEl.classList.remove("tool-wire");const a=y.getState();a.setWireFromTerminal(null),a.setCursorSvg(null),Ie(null),Se=null}if($e&&e.pointerId===$e.pointerId){if((l=(i=t.hostEl).hasPointerCapture)!=null&&l.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}Tt(null),$e=null}},onDoubleClick(e){const t=y.getState(),n=Rt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=nt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ie=null,$e=null,le=null,Se){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Ie(null),Se=null}Tt(null)}};function vo(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),r=Math.abs(t[0]-e[0]),s=Math.abs(t[1]-e[1]);return{x:n,y:o,w:r,h:s}}function D$(e){const{internal:t}=y.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=H$(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([m,h])=>F$([m,h],r));let l=1/0,a=-1/0,d=1/0,u=-1/0;for(const[m,h]of i)m<l&&(l=m),m>a&&(a=m),h<d&&(d=h),h>u&&(u=h);a>=e.x&&l<=e.x+e.w&&u>=e.y&&d<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:l}=r,a=l/2,d=s==="x"?i[0]-a:i[0],u=s==="x"?i[0]+a:i[0],m=s==="x"?i[1]:i[1]-a,h=s==="x"?i[1]:i[1]+a;u>=e.x&&d<=e.x+e.w&&h>=e.y&&m<=e.y+e.h&&n.push(o.id)}return n}function F$(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function H$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function He(e){return e.replace(/(["\\])/g,"\\$1")}const W$=4;let V=null;const q$={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=nt(e.target);let r=null;if(o){const s=y.getState();s.selection.includes(o)||s.setSelection([o]);const i=y.getState().selection,l=y.getState().internal,a=new Map,d=new Map;for(const u of i){const m=l.buses.get(u);if(m){d.set(u,[m.geometry.at[0],m.geometry.at[1]]);continue}const h=l.layout.get(u);h&&a.set(u,{...h})}(a.size>0||d.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:a,busOriginals:d})}V={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTx:n.tx,startTy:n.ty,startTarget:e.target,moved:!1,elementDrag:r},t.hostEl.style.cursor="grabbing",e.preventDefault()},onPointerMove(e,t){if(!V||e.pointerId!==V.pointerId)return;const n=e.clientX-V.startX,o=e.clientY-V.startY;if(!V.moved&&Math.hypot(n,o)>W$){V.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(V.moved){if(V.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=ne(r[0]-V.elementDrag.startSvg[0]),i=ne(r[1]-V.elementDrag.startSvg[1]);for(const[l,a]of V.elementDrag.originals){const d=t.hostEl.querySelector(`[data-element-id="${mt(l)}"]`);if(!d)continue;const u={...a,at:[a.at[0]+s,a.at[1]+i]};d.setAttribute("transform",Ge(u))}for(const l of V.elementDrag.busOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${mt(l)}"]`);a&&a.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:V.startTx+n,ty:V.startTy+o})}},onPointerUp(e,t){if(!(!V||e.pointerId!==V.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",V.elementDrag&&V.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-V.elementDrag.startSvg[0]),r=ne(n[1]-V.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of V.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of V.elementDrag.busOriginals.keys())s.set(i,[o,r]);y.getState().moveElements(s)}for(const s of V.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${mt(s)}"]`);i&&i.removeAttribute("transform")}}else V.moved||G$(V.startTarget);V=null}},onPointerCancel(e,t){if(V!=null&&V.elementDrag){for(const[n,o]of V.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${mt(n)}"]`);r&&r.setAttribute("transform",Ge(o))}for(const n of V.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${mt(n)}"]`);o&&o.removeAttribute("transform")}}V=null},onDeactivate(){V=null}};function G$(e){if(!e)return;const t=y.getState(),n=Rt(e);if(n){t.setSelectedAnnotation(n);return}const o=nt(e);if(o){t.setSelection([o]);return}const r=Yt(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function mt(e){return e.replace(/(["\\])/g,"\\$1")}const pt={tight:1024,compact:720,dense:520,mini:380},ko={full:0,tight:1,compact:2,dense:3,mini:4};function Ae(e,t){return ko[e]>=ko[t]}function Y$(e){return e>=pt.tight?"full":e>=pt.compact?"tight":e>=pt.dense?"compact":e>=pt.mini?"dense":"mini"}const jb=S.createContext("full");function Ke(){return S.useContext(jb)}function K$(e){const[t,n]=S.useState(null);return S.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(l=>l===i?l:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function Eb(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<pt.dense}function An(){Eb()&&y.getState().setActiveTool("pan")}function X$(){Eb()&&y.getState().setPlaceKind(null)}const V$={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Ie(null)},onPointerDown(e,t){var r,s;if(e.button!==0)return;const n=qe(e.target);if(!n)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((s=(r=e.target).hasPointerCapture)!=null&&s.call(r,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const o=y.getState();o.setWireFromTerminal(n),o.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY))},onPointerMove(e,t){const n=y.getState().wireFromTerminal;if(!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg(o);const r=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,s=r?qe(r):null;if(!s||s===n){Ie(null);return}Ie(Sb(s,o))},onPointerUp(e){const t=y.getState(),n=t.wireFromTerminal;if(!n)return;t.setWireFromTerminal(null),t.setCursorSvg(null),Ie(null);const o=qe(e.target);!o||o===n||(t.addWire(n,o),An())},onPointerLeave(){const e=y.getState();e.setWireFromTerminal(null),e.setCursorSvg(null),Ie(null)}},_o=10;let ft=!1;function $o(){setTimeout(()=>X$(),0)}const U$={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=y.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),ft=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=y.getState();if(!n)return;e.preventDefault();const o=qe(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const l=y.getState();l.setPlaceFromTerminal(o),l.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);yb(n,r),ft=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([So(n[0]),So(n[1])])},onPointerUp(e,t){const n=y.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);t$(r,o,s),$o();return}ft&&(ft=!1,$o())},onPointerLeave(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),ft=!1}};function So(e){return Math.round(e/_o)*_o}const jo=10,Eo=20;function Qe(e){return Math.round(e/jo)*jo}const Z$={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[Qe(n[0]),Qe(n[1])];y.getState().setBusbarDrawStart(o),y.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([Qe(n[0]),Qe(n[1])])},onPointerUp(e,t){const n=y.getState().busbarDrawStart;if(y.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=Qe(o[0]),s=Qe(o[1]),i=r-n[0],l=s-n[1],a=Math.abs(i)>=Math.abs(l);let d,u,m;if(a){if(u=Math.abs(i),u<Eo)return;d=0,m=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(l),u<Eo)return;d=90,m=[n[0],(n[1]+s)/2]}y.getState().addBus(m,u,d),An()},onPointerLeave(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},Q$={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=y.getState(),o=Rt(e.target);if(o){e.preventDefault(),e.stopPropagation(),n.setActiveTool("select"),n.setSelectedAnnotation(o);return}e.preventDefault();const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=n.addAnnotation([r[0],r[1]],"");n.setEditingAnnotation(s),An()}},J$={select:R$,pan:q$,wire:V$,place:U$,busbar:Z$,text:Q$};function eS(e,t){const n=y(o=>o.activeTool);S.useEffect(()=>{var h;const o=e.current;if(!o)return;const r=J$[n],s={viewport:t,hostEl:o};(h=r.onActivate)==null||h.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=g=>{var f;return(f=r.onPointerDown)==null?void 0:f.call(r,g,s)},l=g=>{var f;return(f=r.onPointerMove)==null?void 0:f.call(r,g,s)},a=g=>{var f;return(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},d=g=>{var f;return r.onPointerCancel?r.onPointerCancel(g,s):(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},u=g=>{var f;return(f=r.onPointerLeave)==null?void 0:f.call(r,g,s)},m=g=>{var f;return(f=r.onDoubleClick)==null?void 0:f.call(r,g,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",l),o.addEventListener("pointerup",a),o.addEventListener("pointercancel",d),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",m),()=>{var g;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",l),o.removeEventListener("pointerup",a),o.removeEventListener("pointercancel",d),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",m),(g=r.onDeactivate)==null||g.call(r,s),o.style.cursor=""}},[n,e,t])}let kn=1;const _n=new Set;function tS(e){if(e!==kn){kn=e;for(const t of _n)t(e)}}function nS(){return kn}function oS(e){return _n.add(e),()=>{_n.delete(e)}}const on=.1,rn=8,rS=1.0015,sS=1.02;function iS(e,t,n={tx:0,ty:0,scale:1}){const o=S.useRef({...n}),r=S.useRef(new Set),s=()=>{const i=t.current,l=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),l&&l.style.setProperty("--canvas-scale",String(o.current.scale)),tS(o.current.scale),r.current.size>0){const a={...o.current};for(const d of r.current)d(a)}};return S.useEffect(()=>{const i=e.current;if(!i)return;let l=!1,a=-1,d=0,u=0,m=0,h=0,g=!1;const f=new Map;let p=null,x=!1;const v=()=>{if(f.size<2){p=null;return}const N=[...f.values()],I=N[1].x-N[0].x,se=N[1].y-N[0].y,oe=Math.hypot(I,se)||1,de=i.getBoundingClientRect();p={startDist:oe,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(N[0].x+N[1].x)/2-de.left,startMidY:(N[0].y+N[1].y)/2-de.top}},b=N=>{if(N.pointerType==="touch"){if(f.set(N.pointerId,{x:N.clientX,y:N.clientY}),f.size>=2&&!x){x=!0;for(const I of f.keys())I!==N.pointerId&&_b(i,I);v()}if(x){N.stopPropagation(),N.preventDefault();try{i.setPointerCapture(N.pointerId)}catch{}}}},k=N=>{if(N.pointerType!=="touch"||!f.has(N.pointerId)||(f.set(N.pointerId,{x:N.clientX,y:N.clientY}),!x||!p))return;N.stopPropagation();const I=[...f.values()];if(I.length<2)return;const se=I[1].x-I[0].x,oe=I[1].y-I[0].y,de=Math.hypot(se,oe)||1,X=i.getBoundingClientRect(),ue=(I[0].x+I[1].x)/2-X.left,ae=(I[0].y+I[1].y)/2-X.top,he=de/p.startDist,ke=sn(p.startScale*he,on,rn),xe=ke/p.startScale;o.current.tx=p.startMidX-(p.startMidX-p.startTx)*xe+(ue-p.startMidX),o.current.ty=p.startMidY-(p.startMidY-p.startTy)*xe+(ae-p.startMidY),o.current.scale=ke,s()},$=N=>{var I;if(N.pointerType==="touch"&&f.has(N.pointerId)&&(f.delete(N.pointerId),x)){if(N.stopPropagation(),(I=i.hasPointerCapture)!=null&&I.call(i,N.pointerId))try{i.releasePointerCapture(N.pointerId)}catch{}f.size>=2?v():p=null,f.size===0&&(x=!1)}},M=N=>{N.preventDefault();const I=i.getBoundingClientRect(),se=N.clientX-I.left,oe=N.clientY-I.top,de=N.ctrlKey||N.metaKey;if(N.deltaX===0||de){const ae=Math.pow(de?sS:rS,-N.deltaY),he=sn(o.current.scale*ae,on,rn),ke=he/o.current.scale;o.current.tx=se-(se-o.current.tx)*ke,o.current.ty=oe-(oe-o.current.ty)*ke,o.current.scale=he}else o.current.tx-=N.deltaX,o.current.ty-=N.deltaY;s()},B=N=>{const I=N.button===1,se=g&&N.button===0;!I&&!se||(N.preventDefault(),l=!0,a=N.pointerId,d=N.clientX,u=N.clientY,m=o.current.tx,h=o.current.ty,i.setPointerCapture(N.pointerId),i.style.cursor="grabbing")},te=N=>{!l||N.pointerId!==a||(o.current.tx=m+(N.clientX-d),o.current.ty=h+(N.clientY-u),s())},J=N=>{l&&N.pointerId===a&&(l=!1,i.releasePointerCapture(N.pointerId),i.style.cursor=g?"grab":"")},ve=N=>{if(N.code==="Space"&&!g){const I=N.target;if(I&&(I.tagName==="INPUT"||I.tagName==="TEXTAREA"||I.isContentEditable))return;g=!0,i.style.cursor="grab",N.preventDefault()}},fe=N=>{N.code==="Space"&&(g=!1,l||(i.style.cursor=""))};return i.addEventListener("wheel",M,{passive:!1}),i.addEventListener("pointerdown",B),i.addEventListener("pointermove",te),i.addEventListener("pointerup",J),i.addEventListener("pointercancel",J),i.addEventListener("pointerdown",b,{capture:!0}),i.addEventListener("pointermove",k,{capture:!0}),i.addEventListener("pointerup",$,{capture:!0}),i.addEventListener("pointercancel",$,{capture:!0}),window.addEventListener("keydown",ve),window.addEventListener("keyup",fe),s(),()=>{i.removeEventListener("wheel",M),i.removeEventListener("pointerdown",B),i.removeEventListener("pointermove",te),i.removeEventListener("pointerup",J),i.removeEventListener("pointercancel",J),i.removeEventListener("pointerdown",b,{capture:!0}),i.removeEventListener("pointermove",k,{capture:!0}),i.removeEventListener("pointerup",$,{capture:!0}),i.removeEventListener("pointercancel",$,{capture:!0}),window.removeEventListener("keydown",ve),window.removeEventListener("keyup",fe)}},[]),{screenToSvg(i,l){const a=e.current;if(!a)return[i,l];const d=a.getBoundingClientRect(),u=(i-d.left-o.current.tx)/o.current.scale,m=(l-d.top-o.current.ty)/o.current.scale;return[u,m]},getViewport(){return{...o.current}},setViewport(i){i.tx!==void 0&&(o.current.tx=i.tx),i.ty!==void 0&&(o.current.ty=i.ty),i.scale!==void 0&&(o.current.scale=sn(i.scale,on,rn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function sn(e,t,n){return e<t?t:e>n?n:e}const Nb=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),Je=Nb?"⌘":"Ctrl+",lS=Nb?"⇧":"Shift+",ln=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],aS=18;function cS(e){for(const t of ln)if(t*e>=aS)return t;return ln[ln.length-1]}function dS(){const e=Z(),t=S.useRef(null),n=S.useRef(null),o=S.useRef(null),r=iS(t,n);eS(t,r),z$(t),S.useEffect(()=>(po(r),()=>po(null)),[r]),S.useEffect(()=>{const u=m=>{const h=o.current;if(!h)return;const f=cS(m.scale)*m.scale;h.setAttribute("width",String(f)),h.setAttribute("height",String(f)),h.setAttribute("patternTransform",`translate(${m.tx} ${m.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=c2(),i=S.useCallback((u,m,h)=>{const g=y.getState(),f=g.activeTool;if(f==="wire"||f==="busbar"||f==="place"){$b();return}const p=nt(h);if(p)g.selection.includes(p)||g.setSelection([p]);else{const B=Yt(h);B&&g.selectedNode!==B&&g.setSelectedNode(B)}const x=y.getState(),v=x.selection.length>0,b=x.selectedNode!=null,k=!!x.clipboard,$=x.diagram.elements.length>0,M=[{label:e("menu.undo"),shortcut:`${Je}Z`,icon:Nn,onSelect:()=>y.getState().undo(),disabled:x.past.length===0},{label:e("menu.redo"),shortcut:`${Je}${lS}Z`,icon:En,onSelect:()=>y.getState().redo(),disabled:x.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${Je}X`,icon:or,onSelect:()=>y.getState().cutSelection(),disabled:!v},{label:e("menu.copy"),shortcut:`${Je}C`,icon:Jo,onSelect:()=>y.getState().copySelection(),disabled:!v},{label:e("menu.paste"),shortcut:`${Je}V`,icon:Qo,onSelect:()=>y.getState().pasteClipboard(),disabled:!k},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:nr,onSelect:()=>y.getState().rotateSelection(90),disabled:!v},{label:e("menu.mirror"),shortcut:"M",icon:er,onSelect:()=>y.getState().mirrorSelection(),disabled:!v},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${Je}A`,icon:Mw,onSelect:()=>{const B=y.getState();B.setSelection(B.diagram.elements.map(te=>te.id))},disabled:!$},{type:"separator"},{label:e(b&&!v?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:sr,destructive:!0,onSelect:()=>b&&!v?y.getState().deleteSelectedNode():y.getState().deleteSelection(),disabled:!v&&!b}];s.open(u,m,M)},[s,e]);S.useEffect(()=>{const u=t.current;if(!u)return;const m=700,h=4;let g,f=null;const p=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,f=null},x=k=>{k.pointerType==="touch"&&(p(),f={pointerId:k.pointerId,x:k.clientX,y:k.clientY,target:k.target},g=window.setTimeout(()=>{const $=f;f=null,g=void 0,$&&(_b(u,$.pointerId),i($.x,$.y,$.target))},m))},v=k=>{if(!f||k.pointerId!==f.pointerId)return;const $=k.clientX-f.x,M=k.clientY-f.y;Math.hypot($,M)>h&&p()},b=k=>{!f||k.pointerId!==f.pointerId||p()};return u.addEventListener("pointerdown",x),u.addEventListener("pointermove",v),u.addEventListener("pointerup",b),u.addEventListener("pointercancel",b),()=>{p(),u.removeEventListener("pointerdown",x),u.removeEventListener("pointermove",v),u.removeEventListener("pointerup",b),u.removeEventListener("pointercancel",b)}},[i]);const l=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},a=u=>{const m=u.dataTransfer.getData("application/x-oneline-kind");if(!m)return;u.preventDefault();const h=r.screenToSvg(u.clientX,u.clientY);yb(m,h)},d=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return c.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:l,onDrop:a,onContextMenu:d,children:c.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("defs",{children:c.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:c.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),c.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),c.jsxs("g",{ref:n,className:"ole-viewport",children:[c.jsx(h$,{}),c.jsx(j$,{}),c.jsx(x$,{}),c.jsx(o$,{}),c.jsx(s$,{}),c.jsx(_$,{}),c.jsx(c$,{}),c.jsx(d$,{}),c.jsx(S$,{}),c.jsx(T$,{}),c.jsx(p$,{}),c.jsx(k$,{}),c.jsx(v$,{})]})]})})}const No=60,uS=.1,mS=8,fS=8;function hS(e,t,n){return e<t?t:e>n?n:e}function pS(){return document.querySelector(".ole-canvas-root")}function Cn(){const e=Ue(),t=pS();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,l=-1/0;for(const v of o){const b=v.getBoundingClientRect();b.width===0&&b.height===0||(b.left<r&&(r=b.left),b.top<s&&(s=b.top),b.right>i&&(i=b.right),b.bottom>l&&(l=b.bottom))}if(r===1/0)return!1;const[a,d]=e.screenToSvg(r,s),[u,m]=e.screenToSvg(i,l),h=Math.max(u-a,1),g=Math.max(m-d,1),f=hS(Math.min((n.width-No*2)/h,(n.height-No*2)/g),uS,mS),p=(a+u)/2,x=(d+m)/2;return e.setViewport({tx:n.width/2-f*p,ty:n.height/2-f*x,scale:f}),!0}function In(){let e=fS;const t=()=>{Cn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const To=10,gS=100;function yS(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function xS(){const[e,t]=S.useState(O$()),[n,o]=S.useState(!1),[r,s]=S.useState(null),i=S.useRef(null),l=S.useRef(void 0),[a]=S.useState(yS);S.useEffect(()=>P$(f=>t(f)),[]),S.useEffect(()=>{if(window.clearTimeout(l.current),o(!1),s(null),!!e)return l.current=window.setTimeout(()=>o(!0),gS),()=>window.clearTimeout(l.current)},[e]);const d=y(f=>e?f.diagram.elements.find(p=>p.id===e)??null:null);if(S.useLayoutEffect(()=>{if(!n||!e)return;let f=0,p=-1,x=-1;const v=()=>{const b=document.querySelector(`[data-element-id="${bS(e)}"]`),k=i.current;if(b&&k){const $=b.getBoundingClientRect();let M=$.bottom+To;M+k.offsetHeight>window.innerHeight-4&&(M=$.top-k.offsetHeight-To);let B=$.left+$.width/2-k.offsetWidth/2;B=Math.max(4,Math.min(B,window.innerWidth-k.offsetWidth-4)),(M!==p||B!==x)&&(s({top:M,left:B}),p=M,x=B)}f=requestAnimationFrame(v)};return f=requestAnimationFrame(v),()=>cancelAnimationFrame(f)},[n,e]),a||!n||!e||!d)return null;const u=Ye[d.kind],m=d.name??d.id,h=(u==null?void 0:u.name)??d.kind,g=d.name&&d.name!==d.id;return typeof document>"u"?null:Vo.createPortal(c.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[c.jsx("span",{className:"font-medium text-foreground",children:m}),g&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:d.id}),c.jsx("span",{className:"text-muted-foreground/80",children:"·"}),c.jsx("span",{className:"text-muted-foreground",children:h})]}),document.body)}function bS(e){return e.replace(/(["\\])/g,"\\$1")}function wS({width:e,children:t}){const n=e==null?"full":Y$(e);return c.jsx(jb.Provider,{value:n,children:t})}function Mo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vS(...e){return t=>{let n=!1;const o=e.map(r=>{const s=Mo(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<o.length;r++){const s=o[r];typeof s=="function"?s():Mo(e[r],null)}}}}var kS=Symbol.for("react.lazy"),Dt=ye[" use ".trim().toString()];function _S(e){return typeof e=="object"&&e!==null&&"then"in e}function Tb(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===kS&&"_payload"in e&&_S(e._payload)}function $S(e){const t=jS(e),n=ye.forwardRef((o,r)=>{let{children:s,...i}=o;Tb(s)&&typeof Dt=="function"&&(s=Dt(s._payload));const l=ye.Children.toArray(s),a=l.find(NS);if(a){const d=a.props.children,u=l.map(m=>m===a?ye.Children.count(d)>1?ye.Children.only(null):ye.isValidElement(d)?d.props.children:null:m);return c.jsx(t,{...i,ref:r,children:ye.isValidElement(d)?ye.cloneElement(d,void 0,u):null})}return c.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var SS=$S("Slot");function jS(e){const t=ye.forwardRef((n,o)=>{let{children:r,...s}=n;if(Tb(r)&&typeof Dt=="function"&&(r=Dt(r._payload)),ye.isValidElement(r)){const i=MS(r),l=TS(s,r.props);return r.type!==ye.Fragment&&(l.ref=o?vS(o,i):i),ye.cloneElement(r,l)}return ye.Children.count(r)>1?ye.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ES=Symbol("radix.slottable");function NS(e){return ye.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ES}function TS(e,t){const n={...t};for(const o in t){const r=e[o],s=t[o];/^on[A-Z]/.test(o)?r&&s?n[o]=(...l)=>{const a=s(...l);return r(...l),a}:r&&(n[o]=r):o==="style"?n[o]={...r,...s}:o==="className"&&(n[o]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}function MS(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Ao=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Co=ar,AS=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return Co(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(d=>{const u=n==null?void 0:n[d],m=s==null?void 0:s[d];if(u===null)return null;const h=Ao(u)||Ao(m);return r[d][h]}),l=n&&Object.entries(n).reduce((d,u)=>{let[m,h]=u;return h===void 0||(d[m]=h),d},{}),a=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,u)=>{let{class:m,className:h,...g}=u;return Object.entries(g).every(f=>{let[p,x]=f;return Array.isArray(x)?x.includes({...s,...l}[p]):{...s,...l}[p]===x})?[...d,m,h]:d},[]);return Co(e,i,a,n==null?void 0:n.class,n==null?void 0:n.className)},CS=AS("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ee=ye.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?SS:"button";return c.jsx(i,{className:we(CS({variant:t,size:n,className:e})),ref:s,...r})});Ee.displayName="Button";const IS=350;function Ne({content:e,children:t,disabled:n,delayMs:o=IS}){const r=S.useRef(null),s=S.useRef(null),[i,l]=S.useState(!1),[a,d]=S.useState(null),u=S.useId(),m=S.useRef(void 0),h=()=>{n||(window.clearTimeout(m.current),m.current=window.setTimeout(()=>l(!0),o))},g=()=>{window.clearTimeout(m.current),l(!1)};S.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const v=r.current.getBoundingClientRect(),b=s.current.getBoundingClientRect(),k=8;let $="top",M=v.top-b.height-k;M<4&&($="bottom",M=v.bottom+k);let B=v.left+v.width/2-b.width/2;B=Math.max(4,Math.min(B,window.innerWidth-b.width-4)),d({top:M,left:B,side:$})},[i,e]),S.useEffect(()=>()=>window.clearTimeout(m.current),[]),S.useEffect(()=>{if(!i)return;const v=k=>{k.key==="Escape"&&l(!1)},b=()=>l(!1);return window.addEventListener("keydown",v),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("keydown",v),window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[i]);const f=t,p=f.props,x=S.cloneElement(f,{ref:v=>{r.current=v;const b=f.ref;typeof b=="function"?b(v):b&&typeof b=="object"&&(b.current=v)},onPointerEnter:v=>{var b;(b=p.onPointerEnter)==null||b.call(p,v),h()},onPointerLeave:v=>{var b;(b=p.onPointerLeave)==null||b.call(p,v),g()},onFocus:v=>{var b;(b=p.onFocus)==null||b.call(p,v),h()},onBlur:v=>{var b;(b=p.onBlur)==null||b.call(p,v),g()},"aria-describedby":i?u:p["aria-describedby"]});return c.jsxs(c.Fragment,{children:[x,i&&typeof document<"u"&&Vo.createPortal(c.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(a==null?void 0:a.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(a==null?void 0:a.top)??-9999,left:(a==null?void 0:a.left)??-9999,opacity:a?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const Io=12,OS=56;function PS(){var v;const e=Z(),t=y(b=>b.selection),n=y(b=>b.selectedNode),o=y(b=>b.selectedWire),r=y(b=>b.activeTool),s=y(b=>b.rotateSelection),i=y(b=>b.mirrorSelection),l=y(b=>b.deleteSelection),a=y(b=>b.deleteSelectedNode),d=y(b=>b.deleteSelectedWire),u=y(b=>b.resetWirePath),m=y(b=>b.internal.wireRenders),h=o!=null&&((v=m.get(o))==null?void 0:v.userEdited)===!0,g=S.useRef(null);S.useEffect(()=>{const b=g.current;if(!b)return;const k=t.length>0,$=!k&&o!=null,M=!k&&!$&&n!=null;if(!((k||$||M)&&(r==="select"||r==="pan"))){b.style.display="none";return}b.style.display="flex";let te=0,J="";const ve=()=>{let fe=1/0,N=-1/0,I=1/0,se=-1/0,oe=!1;const de=X=>{X.width===0&&X.height===0||(X.left<fe&&(fe=X.left),X.right>N&&(N=X.right),X.top<I&&(I=X.top),X.bottom>se&&(se=X.bottom),oe=!0)};if(k)for(const X of t){const ue=document.querySelector(`[data-element-id="${CSS.escape(X)}"]`);ue&&de(ue.getBoundingClientRect())}else if($&&o){const X=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);X&&de(X.getBoundingClientRect())}else if(M&&n){const X=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const ue of X)de(ue.getBoundingClientRect())}if(oe){const X=(fe+N)/2;let ue=I-Io,ae="-100%";ue<OS&&(ue=se+Io,ae="0%");const he=`translate3d(${X}px, ${ue}px, 0) translate(-50%, ${ae})`;he!==J&&(b.style.transform=he,J=he)}te=requestAnimationFrame(ve)};return te=requestAnimationFrame(ve),()=>cancelAnimationFrame(te)},[t,n,o,r]);const f=t.length===0&&o!=null,p=t.length===0&&!f&&n!=null,x=p||f;return c.jsxs("div",{ref:g,role:"toolbar","aria-label":e(f?"ctx.ariaWire":p?"ctx.ariaNode":"ctx.ariaElement"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-30 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[f&&h&&o&&c.jsxs(c.Fragment,{children:[c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{children:c.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:c.jsx(Tw,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!x&&c.jsxs(c.Fragment,{children:[c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:c.jsx(nr,{})})}),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:c.jsx(er,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.delete")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),c.jsx("div",{className:"text-muted-foreground",children:e(f?"ctx.deleteHintWire":p?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>f?d():p?a():l(),"aria-label":e("ctx.delete"),children:c.jsx(sr,{})})})]})}function On({open:e,onOpenChange:t,trigger:n,children:o}){const r=S.useRef(null);return S.useEffect(()=>{if(!e)return;const s=l=>{r.current&&!r.current.contains(l.target)&&t(!1)},i=l=>{l.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),c.jsxs("div",{ref:r,className:"relative",children:[n,e&&c.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const Mb="ole-panel-open";function BS(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Mb);if(!e)return{outlineOpen:!1};const t=JSON.parse(e);return typeof t!="object"||t===null?{outlineOpen:!1}:{outlineOpen:t.outline===!0}}catch{return{outlineOpen:!1}}}function Oo(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Mb,JSON.stringify(t))}catch{}}const kt=Ft((e,t)=>({...BS(),setOutlineOpen:n=>{e({outlineOpen:n}),Oo(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),Oo(t())}})),It=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Ab=.1,Cb=8,Ib="ole-grid";function LS(){try{const e=window.localStorage.getItem(Ib);return e==null?!0:e==="1"}catch{return!0}}function zS(e){try{window.localStorage.setItem(Ib,e?"1":"0")}catch{}}function RS(e,t,n){return e<t?t:e>n?n:e}function Ob(){return document.querySelector(".ole-canvas-root")}function Pn(e){const t=Ue(),n=Ob();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),l=RS(e,Ab,Cb),a=l/i.scale;t.setViewport({tx:r-(r-i.tx)*a,ty:s-(s-i.ty)*a,scale:l})}function DS(){const e=Ue();if(!e)return;const t=e.getViewport().scale,n=It.find(o=>o>t+1e-6)??Cb;Pn(n)}function FS(){const e=Ue();if(!e)return;const t=e.getViewport().scale;let n=Ab;for(let o=It.length-1;o>=0;o--)if(It[o]<t-1e-6){n=It[o];break}Pn(n)}const HS={off:"id",id:"all",all:"off"};function WS(){var o;const e=y.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=HS[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Pb(){const[e,t]=S.useState(()=>LS());return S.useEffect(()=>{const n=Ob();n==null||n.classList.toggle("hide-grid",!e),zS(e)},[e]),S.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Bb(){const e=Z();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:FS,"aria-label":e("view.zoomOut"),children:c.jsx(jn,{})})})}function Lb(){const e=Z();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:DS,"aria-label":e("view.zoomIn"),children:c.jsx(Ew,{})})})}function zb(){const e=Z(),[t,n]=S.useState(nS);return S.useEffect(()=>oS(n),[]),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.reset")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:c.jsxs("button",{type:"button",onClick:()=>Pn(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function Rb(){const e=Z();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.fit")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:Cn,"aria-label":e("view.fit"),children:c.jsx($w,{})})})}function Db({grid:e,setGrid:t}){const n=Z();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),c.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:we(!e&&"text-muted-foreground/60"),children:c.jsx(kw,{})})})}function Fb(){const e=Z(),t=y(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:WS,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:we(t==="off"&&"text-muted-foreground/60"),children:c.jsx(ir,{})})})}function qS({stacked:e}={}){const t=Z(),[n,o]=S.useState(!1),[r,s]=Pb(),i=c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:t("view.menu")}),c.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),l=e?c.jsx(Ne,{content:i,children:c.jsxs("button",{type:"button",onClick:()=>o(a=>!a),"aria-label":t("view.menu"),"aria-pressed":n,className:we("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[c.jsx(dn,{className:"size-4"}),c.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):c.jsx(Ne,{content:i,children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:()=>o(a=>!a),"aria-label":t("view.menu"),"aria-pressed":n,children:c.jsx(dn,{})})});return c.jsx(On,{open:n,onOpenChange:o,trigger:l,children:c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx(zb,{}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(Bb,{}),c.jsx(Lb,{})]}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(Rb,{}),c.jsx(Db,{grid:r,setGrid:s}),c.jsx(Fb,{})]})]})})}function GS(){const e=Ke();return Ae(e,"dense")?null:c.jsx(YS,{tier:e})}function YS({tier:e}){const t=Ae(e,"tight"),[n,o]=Pb();return c.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:c.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[c.jsx(Bb,{}),!t&&c.jsx(zb,{}),c.jsx(Lb,{}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),c.jsx(Rb,{}),c.jsx(Db,{grid:n,setGrid:o}),c.jsx(Fb,{})]})})}const Po=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:Sw,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:_w,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:jn,switchTo:"busbar"},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:rr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Zo,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:ir,switchTo:"text",iconOnly:!0}];function KS(){const e=Z(),t=y(u=>u.activeTool),n=y(u=>u.placeKind),o=y(u=>u.placeFromTerminal),r=y(u=>u.wireFromTerminal),s=y(u=>u.busbarDrawStart),i=y(u=>u.selection.length>0||u.selectedNode!=null);let l=null,a=!1;switch(t){case"select":l=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(a=!0);break;case"pan":l=e("mode.pan");break;case"wire":l=e(r?"mode.wireDragging":"mode.wireInit"),a=!0;break;case"busbar":l=e(s?"mode.busDragging":"mode.busInit"),a=!0;break;case"place":n?o?l=e("mode.placeFromTerm"):l=e("mode.placeNormal"):l=e("mode.placeNoKind"),a=!0;break;case"text":l=e("mode.text"),a=!0;break}if(!l)return null;const d=e(t==="select"?"mode.escSelect":"mode.escOther");return c.jsxs("div",{className:"ole-glass pointer-events-none flex items-center gap-2 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground shadow-sm",children:[c.jsx("span",{children:l}),a&&c.jsxs("span",{className:"text-muted-foreground/70",children:["· ",d]})]})}function XS(){const e=Z(),t=y(f=>f.activeTool),n=y(f=>f.placeKind),o=y(f=>f.setActiveTool),r=y(f=>f.past.length),s=y(f=>f.future.length),i=y(f=>f.undo),l=y(f=>f.redo),a=Ke(),d=Ae(a,"tight"),u=!Ae(a,"dense"),m=Ae(a,"dense"),h=m?Po.filter(f=>f.id!=="select"&&f.id!=="text"):Po,g=f=>t===f.switchTo;return c.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))"},children:[u&&c.jsx(KS,{}),c.jsxs("div",{className:we("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",m?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[m&&c.jsx(VS,{stacked:!0}),h.map(f=>{const p=f.icon,x=g(f),v=f.id==="place"&&x&&n==null?e("tool.placeNoKindTooltip"):e(f.descriptionKey);return c.jsxs(S.Fragment,{children:[c.jsx(tt,{icon:p,label:e(f.labelKey),hotkey:f.hotkey,active:x,iconOnly:!m&&(f.iconOnly||d),stacked:m,description:v,onClick:()=>{o(f.switchTo,{placeKind:f.presetPlaceKind!==void 0?f.presetPlaceKind:void 0})}}),f.groupBreakAfter&&!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},f.id)}),!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),m?c.jsx(ZS,{stacked:!0}):c.jsxs(c.Fragment,{children:[c.jsx(tt,{icon:Nn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),c.jsx(tt,{icon:En,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:l}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),c.jsx(US,{iconOnly:d})]}),m&&c.jsx(qS,{stacked:!0})]})]})}function VS({stacked:e}){const t=Z(),n=kt(r=>r.outlineOpen),o=kt(r=>r.toggleOutline);return c.jsx(tt,{icon:tr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function tt({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:l,description:a}){const d=c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:t}),n&&c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),a&&c.jsx("div",{className:"text-muted-foreground",children:a})]});return c.jsx(Ne,{content:d,disabled:r,children:c.jsxs("button",{type:"button",onClick:l,disabled:r,"aria-label":t,"aria-pressed":o,className:we("rounded-md font-medium transition-colors",i?"flex h-12 w-12 flex-col items-center justify-center gap-0.5 text-[10px] leading-tight":"flex h-9 items-center gap-1.5 text-xs",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[c.jsxs("span",{className:"relative inline-flex shrink-0",children:[c.jsx(e,{className:"size-4"}),n&&!i&&c.jsx("span",{"aria-hidden":!0,className:we("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?c.jsx("span",{className:"max-w-full truncate",children:t}):!s&&c.jsx("span",{children:t})]})})}function Hb(){const e=y(r=>r.diagram.elements),t=y(r=>r.diagram.layout),n=y(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function US({iconOnly:e}){const t=Z(),[n,o]=S.useState(!1),r=Hb(),s=i=>()=>{o(!1),i()};return c.jsxs(On,{open:n,onOpenChange:o,trigger:c.jsx(tt,{icon:gt,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[c.jsx(je,{onClick:s(()=>y.getState().autoArrangeAll()),icon:c.jsx(gt,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(je,{onClick:s(()=>y.getState().autoArrangeSelection()),icon:c.jsx(gt,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:s(()=>y.getState().fillUnplacedAll()),icon:c.jsx(Ot,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),c.jsx(je,{onClick:s(()=>y.getState().fillUnplacedSelection()),icon:c.jsx(Ot,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function ZS({stacked:e}){const t=Z(),[n,o]=S.useState(!1),r=y(h=>h.past.length),s=y(h=>h.future.length),i=y(h=>h.undo),l=y(h=>h.redo),a=y(h=>h.selection.length>0),d=y(h=>h.clipboard!=null),u=Hb(),m=h=>()=>{o(!1),h()};return c.jsxs(On,{open:n,onOpenChange:o,trigger:c.jsx(tt,{icon:dn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(h=>!h)}),children:[c.jsx(je,{onClick:m(i),icon:c.jsx(Nn,{}),disabled:r===0,children:t("tool.undo")}),c.jsx(je,{onClick:m(l),icon:c.jsx(En,{}),disabled:s===0,children:t("tool.redo")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:m(()=>y.getState().cutSelection()),icon:c.jsx(or,{}),disabled:!a,children:t("menu.cut")}),c.jsx(je,{onClick:m(()=>y.getState().copySelection()),icon:c.jsx(Jo,{}),disabled:!a,children:t("menu.copy")}),c.jsx(je,{onClick:m(()=>y.getState().pasteClipboard()),icon:c.jsx(Qo,{}),disabled:!d,children:t("menu.paste")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:m(()=>y.getState().autoArrangeAll()),icon:c.jsx(gt,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(je,{onClick:m(()=>y.getState().autoArrangeSelection()),icon:c.jsx(gt,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),c.jsx(je,{onClick:m(()=>y.getState().fillUnplacedAll()),icon:c.jsx(Ot,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),c.jsx(je,{onClick:m(()=>y.getState().fillUnplacedSelection()),icon:c.jsx(Ot,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function je({children:e,icon:t,onClick:n,disabled:o}){return c.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:we("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,c.jsx("span",{className:"flex-1",children:e})]})}function QS(){const e=kt(r=>r.outlineOpen),t=kt(r=>r.setOutlineOpen),n=Ke();return Ae(n,"dense")?e?c.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:c.jsx(Bo,{onClose:()=>t(!1),sheet:!0})}):null:c.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?c.jsx(Bo,{onClose:()=>t(!1)}):c.jsx(JS,{onClick:()=>t(!0)})})}function JS({onClick:e}){const t=Z(),n=Ke(),o=Ae(n,"compact");return c.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:we("ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",o?"w-12 justify-center":"gap-2 px-3"),children:[c.jsx(tr,{className:"size-4 shrink-0"}),!o&&c.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function Bo({onClose:e,sheet:t}){const n=Z(),o=y(d=>d.diagram.elements),r=y(d=>d.activeTool==="place"),s=Ke(),i=Ae(s,"compact"),l=Ae(s,"dense"),a=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return c.jsxs("aside",{className:we("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:a},children:[c.jsxs("button",{type:"button",onClick:e,"aria-label":n("outline.collapseAria"),title:n("outline.collapse"),className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-muted/40",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!l&&c.jsx(t4,{children:o.length}),c.jsx(jw,{className:"size-3.5 text-muted-foreground"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?c.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):c.jsx("ul",{className:"space-y-px",children:o.map(d=>c.jsx(e4,{element:d},d.id))})})]})}function e4({element:e}){const t=Ye[e.kind],n=y(a=>a.selection.includes(e.id)),o=y(a=>a.setSelection),r=y(a=>a.toggleInSelection),s=Ke(),i=!Ae(s,"compact"),l=a=>{a.shiftKey||a.metaKey||a.ctrlKey?r(e.id):o([e.id])};return c.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:l,children:[c.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&c.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),c.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function t4({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const n4={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},o4={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current"},Lo={zh:n4,en:o4};function r4(e,t){return Lo[e][t]??Lo.zh[t]}function $t(){const e=_t(t=>t.locale);return(t,n)=>r4(e,t)??n??t}const Wb="ole-palette-collapsed",s4=new Set(["busbar"]),bt=(()=>{const e={};for(const[t,n]of Object.entries(F_)){const o=n.filter(r=>!s4.has(r.id));o.length&&(e[t]=o)}return e})(),i4=(()=>{const e=new Set(uo),t=Object.keys(bt).filter(n=>!e.has(n));return[...uo.filter(n=>{var o;return(o=bt[n])==null?void 0:o.length}),...t]})();function l4(){try{const e=window.localStorage.getItem(Wb);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function a4(e){try{window.localStorage.setItem(Wb,JSON.stringify([...e]))}catch{}}function c4(){const e=Z(),t=y(m=>m.activeTool==="place"),n=y(m=>m.placeKind),o=y(m=>m.setActiveTool),r=kt(m=>m.outlineOpen),s=Ke(),i=Ae(s,"dense"),l=68,d=i?void 0:`calc(100vh - ${l}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${l}px + var(--ole-top-inset, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:l};return c.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:c.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:d?{maxHeight:d}:void 0,children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),c.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:c.jsx(Tn,{className:"size-3.5"})})]}),c.jsx(d4,{sheet:i})]})})}function d4({sheet:e}){const t=Z(),n=$t(),[o,r]=S.useState(""),[s,i]=S.useState(()=>l4()),l=S.useMemo(()=>{const m=o.trim().toLowerCase();if(!m)return bt;const h={};for(const[g,f]of Object.entries(bt)){const p=f.filter(x=>{const v=n(`${x.id}.name`,x.name).toLowerCase(),b=n(`${x.id}.desc`,x.description??"").toLowerCase();return v.includes(m)||x.id.toLowerCase().includes(m)||b.includes(m)});p.length&&(h[g]=p)}return h},[o,n]),a=o.trim().length>0,d=a&&Object.values(l).every(m=>!(m!=null&&m.length)),u=S.useCallback((m,h)=>{i(g=>{const f=new Set(g);return h?f.delete(m):f.add(m),a4(f),f})},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-2 pb-1.5 pt-2",children:c.jsx(u4,{value:o,onChange:r})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:d?c.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):i4.map(m=>{var x;const h=l[m];if(!(h!=null&&h.length))return null;const g=((x=bt[m])==null?void 0:x.length)??h.length,f=t(`cat.${m}`),p=a||!s.has(m);return c.jsxs("details",{open:p,className:"group mb-2 last:mb-0",onToggle:v=>{a||u(m,v.currentTarget.open)},children:[c.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:[c.jsx(gw,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),c.jsx("span",{className:"flex-1",children:f}),c.jsx(f4,{children:a&&h.length!==g?`${h.length}/${g}`:g})]}),c.jsx("ul",{className:"mt-0.5 space-y-px",children:h.map(v=>c.jsx(m4,{entry:v,sheet:e},v.id))})]},m)})})]})}function u4({value:e,onChange:t}){const n=Z();return c.jsxs("div",{className:"relative",children:[c.jsx(Nw,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),c.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&c.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Tn,{className:"size-3"})})]})}function m4({entry:e,sheet:t}){const n=Z(),o=$t(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=y(m=>m.setActiveTool),l=y(m=>m.activeTool==="place"&&m.placeKind===e.id),a=y(m=>t&&m.activeTool==="place"&&m.placeKind==null&&m.lastPlaceKind===e.id),d=S.useRef(null);S.useEffect(()=>{var m;a&&((m=d.current)==null||m.scrollIntoView({block:"nearest"}))},[a]);const u=m=>{m.dataTransfer.effectAllowed="copy",m.dataTransfer.setData("application/x-oneline-kind",e.id),m.dataTransfer.setData("text/plain",e.id);const h=document.createElement("div");h.className="ole-glass",h.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),h.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(h),m.dataTransfer.setDragImage(h,32,32),setTimeout(()=>h.remove(),0)};return c.jsxs("li",{ref:d,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${l?"bg-accent ring-1 ring-[var(--selection)]/60":a?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[c.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:c.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),c.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function f4({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const $n="ole-onboarding-dismissed";function h4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem($n)==="1"}catch{return!1}}function zo(e){try{e?window.localStorage.setItem($n,"1"):window.localStorage.removeItem($n)}catch{}}const Ro=Ft(e=>({dismissed:h4(),dismiss:()=>{zo(!0),e({dismissed:!0})},reset:()=>{zo(!1),e({dismissed:!1})}}));function p4(){const e=Z(),t=Ro(o=>o.dismissed),n=Ro(o=>o.dismiss);return t?null:c.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),c.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Tn,{className:"size-3.5"})})]}),c.jsxs("ol",{className:"mt-3 space-y-2.5",children:[c.jsx(an,{n:1,icon:c.jsx(jn,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),c.jsx(an,{n:2,icon:c.jsx(rr,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),c.jsx(an,{n:3,icon:c.jsx(Zo,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),c.jsx("button",{type:"button",onClick:n,className:"pointer-events-auto mt-4 w-full rounded-md bg-primary py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("onboard.dismiss")})]})}function an({n:e,icon:t,title:n,body:o}){return c.jsxs("li",{className:"flex items-start gap-2.5",children:[c.jsx("span",{className:"mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklch,var(--selection)_18%,transparent)] font-mono text-[10px] font-semibold tabular-nums text-[var(--selection)]","aria-hidden":!0,children:e}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[c.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),c.jsx("span",{children:n})]}),c.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function g4(){const e=Z(),t=y(u=>u.selection),n=y(u=>u.diagram.elements),o=y(u=>u.diagram.buses),r=y(u=>u.selectedNode),s=y(u=>u.selectedWire);if(s)return c.jsx(k4,{wireId:s});if(r)return c.jsx(_4,{nodeId:r});if(t.length===0)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const i=t[0],l=(o??[]).find(u=>u.id===i);if(l)return c.jsx(w4,{bus:l});const a=n.find(u=>u.id===i);if(!a)return null;const d=Ye[a.kind];return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(St,{label:e("props.name"),value:a.name??"",placeholder:a.id,onCommit:u=>y.getState().updateElement(i,{name:u.trim()===""?void 0:u.trim()})}),c.jsx(qb,{label:e("props.note"),value:a.note??"",onCommit:u=>y.getState().updateElement(i,{note:u.trim()===""?void 0:u.trim()})}),(d==null?void 0:d.state)&&d.state.length>0&&c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.state.map(u=>c.jsx($4,{id:i,element:a,field:u},u.name))}),c.jsx(y4,{id:i,element:a,schema:(d==null?void 0:d.params)??[]})]})}function y4({id:e,element:t,schema:n}){const o=new Set(n.map(s=>s.name)),r=t.params?Object.entries(t.params).filter(([s])=>!o.has(s)):[];return n.length===0&&r.length===0?null:c.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>c.jsx(x4,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>c.jsx(b4,{id:e,element:t,fieldKey:s,value:i},s))]})}function x4({id:e,element:t,field:n}){var a;const o=Z(),r=$t(),s=((a=t.params)==null?void 0:a[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),l=d=>{const u={...t.params??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,y.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(st,{label:i,children:c.jsx(Bn,{active:!!s,onClick:()=>l(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Kt,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:l}):c.jsx(St,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:d=>l(d.trim()===""?void 0:d)})}function b4({id:e,element:t,fieldKey:n,value:o}){const r=Z(),s=i=>{const l={...t.params??{}};i===void 0?delete l[n]:l[n]=i,y.getState().updateElement(e,{params:Object.keys(l).length>0?l:void 0})};return typeof o=="boolean"?c.jsx(st,{label:n,children:c.jsx(Bn,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?c.jsx(Kt,{label:n,value:o,onCommit:s}):c.jsx(St,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function w4({bus:e}){const t=Z(),n=e.id,o=r=>{const s=r.trim();Sn(n,{name:s===""?void 0:s})};return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(St,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),c.jsx(qb,{label:t("props.note"),value:e.note??"",onCommit:r=>Sn(n,{note:r.trim()===""?void 0:r.trim()})}),c.jsx(v4,{bus:e})]})}function v4({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Sn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:c.jsx(Kt,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Sn(e,t){y.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function k4({wireId:e}){const t=Z(),n=y(f=>f.diagram.wires),o=y(f=>f.diagram.elements),r=y(f=>f.diagram.buses),s=y(f=>f.internal.terminalToNode),i=y(f=>f.setSelectedNode),l=(n??[]).find(f=>f.id===e);if(!l)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const a=s.get(l.ends[0]),d=new Map(o.map(f=>[f.id,f])),u=new Map((r??[]).map(f=>[f.id,f])),m=f=>{if(!f.includes(".")){const k=u.get(f);return{id:f,label:(k==null?void 0:k.name)??f}}const p=f.indexOf("."),x=f.slice(0,p),v=f.slice(p+1),b=d.get(x);return{id:x,label:(b==null?void 0:b.name)??x,pin:v}},h=m(l.ends[0]),g=m(l.ends[1]);return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),c.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((f,p)=>c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>y.getState().setSelection([f.id]),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:f.id}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:f.label}),f.pin&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:f.pin})]},p))}),a&&c.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>i(a),children:t("props.selectWholeNode")})]})}function _4({nodeId:e}){const t=Z(),n=y(l=>l.internal.nodes.get(e)),o=y(l=>l.diagram.elements),r=y(l=>l.setSelection);if(!n)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const l of n.terminals){const a=l.indexOf(".");if(a<0)continue;const d=l.slice(0,a),u=l.slice(a+1),m=s.get(d)??[];m.push(u),s.set(d,m)}const i=new Map(o.map(l=>[l.id,l]));return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),c.jsx("div",{className:"font-mono text-[12px]",children:n.id}),c.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([l,a])=>{const d=i.get(l);return c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([l]),title:t("props.selectElement",{label:l}),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:l}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(d==null?void 0:d.name)??""}),c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:a.join(", ")})]},l)})})]})}function st({label:e,children:t}){return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),c.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function St({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=S.useState(t),l=S.useRef(null);return S.useEffect(()=>i(t),[t]),c.jsx(st,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:l,type:"text",value:s,placeholder:n,onChange:a=>i(a.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:a=>{var d,u;a.key==="Enter"&&((d=l.current)==null||d.blur()),a.key==="Escape"&&(i(t),(u=l.current)==null||u.blur())},className:we("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function qb({label:e,value:t,onCommit:n}){const[o,r]=S.useState(t);return S.useEffect(()=>r(t),[t]),c.jsx(st,{label:e,children:c.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function Kt({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=S.useState(String(t)),l=S.useRef(null);return S.useEffect(()=>i(String(t)),[t]),c.jsx(st,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:l,type:"number",value:s,onChange:a=>i(a.target.value),onBlur:()=>{const a=Number(s);Number.isFinite(a)&&a!==t?r(a):i(String(t))},onKeyDown:a=>{var d,u;a.key==="Enter"&&((d=l.current)==null||d.blur()),a.key==="Escape"&&(i(String(t)),(u=l.current)==null||u.blur())},min:n,className:we("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 font-mono text-[11px] tabular-nums focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Bn({active:e,onClick:t,children:n}){return c.jsx("button",{type:"button",onClick:t,className:we("flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",e?"border-[var(--selection)] bg-[var(--selection)]/15 text-foreground":"border-border/60 text-muted-foreground hover:bg-accent"),"aria-pressed":e,children:n})}function $4({id:e,element:t,field:n}){var a;const o=Z(),s=$t()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((a=t.state)==null?void 0:a[n.name])??n.default,l=d=>{const u={...t.state??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,y.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(st,{label:s,children:c.jsx(Bn,{active:!!i,onClick:()=>l(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Kt,{label:s,value:typeof i=="number"?i:0,onCommit:l}):c.jsx(St,{label:s,value:typeof i=="string"?i:"",onCommit:d=>l(d.trim()===""?void 0:d)})}function S4(){const e=Z(),t=$t(),n=y(m=>m.selection),o=y(m=>m.selectedNode),r=y(m=>m.selectedWire),s=y(m=>m.diagram.elements),i=y(m=>m.diagram.buses),l=Ke(),a=Ae(l,"dense");if(n.length===0&&!o&&!r)return null;let d=e("props.title"),u=null;if(r)d=e("props.wire");else if(o)d=e("props.node");else if(n.length===1){const m=n[0],h=(i??[]).find(g=>g.id===m);if(h)d=h.name??e("props.bus");else{const g=s.find(f=>f.id===m);if(g){const f=Ye[g.kind];d=f?t(`${f.id}.name`,f.name):g.kind}}}else u=n.length;return c.jsxs("aside",{className:we("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",a?"w-48":"w-56"),style:{top:`calc(${a?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${a?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:d}),u!=null&&c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e("props.nSelected",{n:u})})]}),c.jsx(g4,{})]})}function j4(){S.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function E4(){j4();const e=S.useRef(null),t=K$(e);return c.jsx(d2,{children:c.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:c.jsxs(wS,{width:t,children:[c.jsx(dS,{}),c.jsx(QS,{}),c.jsx(S4,{}),c.jsx(XS,{}),c.jsx(GS,{}),c.jsx(PS,{}),c.jsx(c4,{}),c.jsx(p4,{}),c.jsx(xS,{})]})})})}const N4="ole-theme";function T4(){try{const e=window.localStorage.getItem(N4);return e==="light"||e==="dark"?e:null}catch{return null}}function M4(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function A4(){return typeof window>"u"?"light":T4()??(M4()?"dark":"light")}function Gb(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function C4({className:e,diagram:t,locale:n,theme:o}){return S.useEffect(()=>{if(!t)return;y.getState().diagram.elements.length===0&&y.getState().setDiagram(t)},[t]),S.useEffect(()=>{n&&_t.getState().setLocale(n)},[n]),S.useEffect(()=>{o&&Gb(o)},[o]),S.useEffect(()=>{In()},[]),C$(),c.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:c.jsx(E4,{})})}const Yb={"application/json":[".json"]},Kb=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Xb=e=>e instanceof DOMException&&e.name==="AbortError";function Do(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(be("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(be("io.notObject"));const n=t;if(n.version!=="1")throw new Error(be("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(be("io.elementsMissing"));return n}function I4(e){return JSON.stringify(e,null,2)+`
|
|
194
|
-
`}async function
|
|
195
|
-
`);for(let
|
|
191
|
+
*/const Ln=Q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function $r(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=$r(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Sr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=$r(e))&&(o&&(o+=" "),o+=t);return o}const zn="-",Yw=e=>{const t=Zw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(zn);return a[0]===""&&a.length!==1&&a.shift(),jr(a,t)||Uw(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},jr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?jr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(zn);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},uo=/^\[(.+)\]$/,Uw=e=>{if(uo.test(e)){const t=uo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Zw=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return Jw(Object.entries(e.classGroups),n).forEach(([s,i])=>{bn(i,o,s,t)}),o},bn=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:mo(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(Qw(r)){bn(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{bn(i,mo(t,s),n,o)})})},mo=(e,t)=>{let n=e;return t.split(zn).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},Qw=e=>e.isThemeGetter,Jw=(e,t)=>t?e.map(([n,o])=>{const r=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,a])=>[t+i,a])):s);return[n,r]}):e,ev=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return r(s,i),i},set(s,i){n.has(s)?n.set(s,i):r(s,i)}}},Er="!",tv=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let d=0,u=0,m;for(let b=0;b<a.length;b++){let k=a[b];if(d===0){if(k===r&&(o||a.slice(b,b+s)===t)){l.push(a.slice(u,b)),u=b+s;continue}if(k==="/"){m=b;continue}}k==="["?d++:k==="]"&&d--}const h=l.length===0?a:a.substring(u),g=h.startsWith(Er),f=g?h.substring(1):h,p=m&&m>u?m-u:void 0;return{modifiers:l,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:i}):i},nv=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},ov=e=>({cache:ev(e.cacheSize),parseClassName:tv(e),...Yw(e)}),rv=/\s+/,sv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(rv);let a="";for(let l=i.length-1;l>=0;l-=1){const d=i[l],{modifiers:u,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:g}=n(d);let f=!!g,p=o(f?h.substring(0,g):h);if(!p){if(!f){a=d+(a.length>0?" "+a:a);continue}if(p=o(h),!p){a=d+(a.length>0?" "+a:a);continue}f=!1}const b=nv(u).join(":"),k=m?b+Er:b,v=k+p;if(s.includes(v))continue;s.push(v);const N=r(p,f);for(let A=0;A<N.length;++A){const R=N[A];s.push(k+R)}a=d+(a.length>0?" "+a:a)}return a};function iv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Nr(t))&&(o&&(o+=" "),o+=n);return o}const Nr=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Nr(e[o]))&&(n&&(n+=" "),n+=t);return n};function av(e,...t){let n,o,r,s=i;function i(l){const d=t.reduce((u,m)=>m(u),e());return n=ov(d),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const d=o(l);if(d)return d;const u=sv(l,n);return r(l,u),u}return function(){return s(iv.apply(null,arguments))}}const se=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Mr=/^\[(?:([a-z-]+):)?(.+)\]$/i,lv=/^\d+\/\d+$/,cv=new Set(["px","full","screen"]),dv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,mv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oe=e=>nt(e)||cv.has(e)||lv.test(e),De=e=>st(e,"length",kv),nt=e=>!!e&&!Number.isNaN(Number(e)),on=e=>st(e,"number",nt),ut=e=>!!e&&Number.isInteger(Number(e)),pv=e=>e.endsWith("%")&&nt(e.slice(0,-1)),X=e=>Mr.test(e),Fe=e=>dv.test(e),gv=new Set(["length","size","percentage"]),yv=e=>st(e,gv,Tr),xv=e=>st(e,"position",Tr),bv=new Set(["image","url"]),wv=e=>st(e,bv,$v),vv=e=>st(e,"",_v),mt=()=>!0,st=(e,t,n)=>{const o=Mr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},kv=e=>uv.test(e)&&!mv.test(e),Tr=()=>!1,_v=e=>fv.test(e),$v=e=>hv.test(e),Sv=()=>{const e=se("colors"),t=se("spacing"),n=se("blur"),o=se("brightness"),r=se("borderColor"),s=se("borderRadius"),i=se("borderSpacing"),a=se("borderWidth"),l=se("contrast"),d=se("grayscale"),u=se("hueRotate"),m=se("invert"),h=se("gap"),g=se("gradientColorStops"),f=se("gradientColorStopPositions"),p=se("inset"),b=se("margin"),k=se("opacity"),v=se("padding"),N=se("saturate"),A=se("scale"),R=se("sepia"),F=se("skew"),te=se("space"),ee=se("translate"),xe=()=>["auto","contain","none"],fe=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto",X,t],D=()=>[X,t],oe=()=>["",Oe,De],re=()=>["auto",nt,X],ue=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],pe=()=>["start","end","center","between","around","evenly","stretch"],be=()=>["","0",X],Ie=()=>["auto","avoid","all","avoid-page","page","left","right","column"],he=()=>[nt,X];return{cacheSize:500,separator:":",theme:{colors:[mt],spacing:[Oe,De],blur:["none","",Fe,X],brightness:he(),borderColor:[e],borderRadius:["none","","full",Fe,X],borderSpacing:D(),borderWidth:oe(),contrast:he(),grayscale:be(),hueRotate:he(),invert:be(),gap:D(),gradientColorStops:[e],gradientColorStopPositions:[pv,De],inset:B(),margin:B(),opacity:he(),padding:D(),saturate:he(),scale:he(),sepia:be(),skew:he(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",X]}],container:["container"],columns:[{columns:[Fe]}],"break-after":[{"break-after":Ie()}],"break-before":[{"break-before":Ie()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ue(),X]}],overflow:[{overflow:fe()}],"overflow-x":[{"overflow-x":fe()}],"overflow-y":[{"overflow-y":fe()}],overscroll:[{overscroll:xe()}],"overscroll-x":[{"overscroll-x":xe()}],"overscroll-y":[{"overscroll-y":xe()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ut,X]}],basis:[{basis:B()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",X]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",ut,X]}],"grid-cols":[{"grid-cols":[mt]}],"col-start-end":[{col:["auto",{span:["full",ut,X]},X]}],"col-start":[{"col-start":re()}],"col-end":[{"col-end":re()}],"grid-rows":[{"grid-rows":[mt]}],"row-start-end":[{row:["auto",{span:[ut,X]},X]}],"row-start":[{"row-start":re()}],"row-end":[{"row-end":re()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",X]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",X]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...pe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...pe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...pe(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[te]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[te]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",X,t]}],"min-w":[{"min-w":[X,t,"min","max","fit"]}],"max-w":[{"max-w":[X,t,"none","full","min","max","fit","prose",{screen:[Fe]},Fe]}],h:[{h:[X,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[X,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Fe,De]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",on]}],"font-family":[{font:[mt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",X]}],"line-clamp":[{"line-clamp":["none",nt,on]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oe,X]}],"list-image":[{"list-image":["none",X]}],"list-style-type":[{list:["none","disc","decimal",X]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oe,De]}],"underline-offset":[{"underline-offset":["auto",Oe,X]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",X]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",X]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ue(),xv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",yv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},wv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[f]}],"gradient-via-pos":[{via:[f]}],"gradient-to-pos":[{to:[f]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:U()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[Oe,X]}],"outline-w":[{outline:[Oe,De]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Oe,De]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Fe,vv]}],"shadow-color":[{shadow:[mt]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...me(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":me()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Fe,X]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[m]}],saturate:[{saturate:[N]}],sepia:[{sepia:[R]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",X]}],duration:[{duration:he()}],ease:[{ease:["linear","in","out","in-out",X]}],delay:[{delay:he()}],animate:[{animate:["none","spin","ping","pulse","bounce",X]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[A]}],"scale-x":[{"scale-x":[A]}],"scale-y":[{"scale-y":[A]}],rotate:[{rotate:[ut,X]}],"translate-x":[{"translate-x":[ee]}],"translate-y":[{"translate-y":[ee]}],"skew-x":[{"skew-x":[F]}],"skew-y":[{"skew-y":[F]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",X]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",X]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",X]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Oe,De,on]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},jv=av(Sv);function _e(...e){return jv(Sr(e))}const Ar=I.createContext(null);function Ev(){const e=I.useContext(Ar);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Tt=8;function Nv({children:e}){const[t,n]=I.useState({open:!1,x:0,y:0,items:[]}),[o,r]=I.useState(null),s=I.useRef(null),i=I.useCallback(()=>{n(d=>d.open?{...d,open:!1}:d)},[]),a=I.useCallback((d,u,m)=>{r(null),n({open:!0,x:d,y:u,items:m})},[]),l=I.useMemo(()=>({open:a,close:i}),[a,i]);return I.useLayoutEffect(()=>{if(!t.open||!s.current)return;const d=s.current.getBoundingClientRect();let u=t.x,m=t.y;u+d.width>window.innerWidth-Tt&&(u=Math.max(Tt,t.x-d.width)),m+d.height>window.innerHeight-Tt&&(m=Math.max(Tt,t.y-d.height)),r({left:u,top:m})},[t]),I.useEffect(()=>{if(!t.open)return;const d=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},m=()=>i(),h=()=>i();return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",m,{passive:!0}),window.addEventListener("blur",h),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",m),window.removeEventListener("blur",h)}},[t.open,i]),c.jsxs(Ar.Provider,{value:l,children:[e,t.open&&c.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:d=>d.preventDefault(),children:t.items.map((d,u)=>{if(d.type==="separator")return c.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const m=d.icon;return c.jsxs("button",{type:"button",role:"menuitem",disabled:d.disabled,className:_e("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",d.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",d.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),d.onSelect()},children:[c.jsxs("span",{className:"flex items-center gap-2",children:[m?c.jsx(m,{className:"size-4"}):null,c.jsx("span",{children:d.label})]}),d.shortcut?c.jsx("span",{className:"text-xs text-muted-foreground",children:d.shortcut}):null]},`${d.label}-${u}`)})})]})}const fo=e=>{let t;const n=new Set,o=(d,u)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const h=t;t=u??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,h))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(o,r,a);return a},Mv=(e=>e?fo(e):fo),Tv=e=>e;function Av(e,t=Tv){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const ho=e=>{const t=Mv(e),n=o=>Av(t,o);return Object.assign(n,t),n},qt=(e=>e?ho(e):ho),po={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从一个端子拖动到另一个端子完成连线","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到另一个端子或母线上释放完成连线","mode.wireInit":"从端子按下,拖动到另一个端子或母线上释放","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"画母线","onboard.step1.body":"选择 母线 工具(B),在画布上按下拖动","onboard.step2.title":"从母线拖出元件","onboard.step2.body":"切到 元件(P)选一种,按住母线拖到目标位置 — 自动连接","onboard.step3.title":"继续串接","onboard.step3.body":"从任意端子拖出,落到目标即与该端子相连","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from one terminal to another to wire","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on another terminal or busbar to complete the wire","mode.wireInit":"Press on a terminal, drag to another terminal or busbar, release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Draw a busbar","onboard.step1.body":"Pick the busbar tool (B), then press and drag on the canvas","onboard.step2.title":"Drag elements from the bus","onboard.step2.body":"Switch to Place (P), pick a kind, then drag from the bus — it auto-connects","onboard.step3.title":"Chain the next one","onboard.step3.body":"Drag from any terminal — the new element drops pre-connected","onboard.dismiss":"Got it"}},Cr="ole-locale";function Cv(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Cr);if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&typeof navigator.language=="string"?navigator.language.toLowerCase().startsWith("zh")?"zh":"en":"zh"}function go(e){try{window.localStorage.setItem(Cr,e)}catch{}}const jt=qt((e,t)=>({locale:Cv(),setLocale:n=>{go(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";go(n),e({locale:n})}}));function Ir(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function Pr(e,t){return po[e][t]??po.zh[t]??t}function ke(e,t){return Ir(Pr(jt.getState().locale,e),t)}function J(){const e=jt(t=>t.locale);return(t,n)=>Ir(Pr(e,t),n)}function Or(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var s;const i=l=>l===null?null:JSON.parse(l,void 0),a=(s=n.getItem(r))!=null?s:null;return a instanceof Promise?a.then(i):i(a)},setItem:(r,s)=>n.setItem(r,JSON.stringify(s,void 0)),removeItem:r=>n.removeItem(r)}}const wn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return wn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return wn(o)(n)}}}},Iv=(e,t)=>(n,o,r)=>{let s={storage:Or(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,k)=>({...k,...b}),...t},i=!1,a=0;const l=new Set,d=new Set;let u=s.storage;if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...b)},o,r);const m=()=>{const b=s.partialize({...o()});return u.setItem(s.name,{state:b,version:s.version})},h=r.setState;r.setState=(b,k)=>(h(b,k),m());const g=e((...b)=>(n(...b),m()),o,r);r.getInitialState=()=>g;let f;const p=()=>{var b,k;if(!u)return;const v=++a;i=!1,l.forEach(A=>{var R;return A((R=o())!=null?R:g)});const N=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(b=o())!=null?b:g))||void 0;return wn(u.getItem.bind(u))(s.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==s.version){if(s.migrate){const R=s.migrate(A.state,A.version);return R instanceof Promise?R.then(F=>[!0,F]):[!0,R]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var R;if(v!==a)return;const[F,te]=A;if(f=s.merge(te,(R=o())!=null?R:g),n(f,!0),F)return m()}).then(()=>{v===a&&(N==null||N(o(),void 0),f=o(),i=!0,d.forEach(A=>A(f)))}).catch(A=>{v===a&&(N==null||N(void 0,A))})};return r.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>p(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(d.add(b),()=>{d.delete(b)})},s.skipHydration||p(),f||g},Pv=Iv,Be=.5;function Br(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<Be&&Math.abs(s[1]-e[r][1])<Be||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],a=Math.abs(s[0]-i[0]),l=Math.abs(s[1]-i[1]);if(a>Be&&l>Be){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Be?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<Be&&Math.abs(i[0]-a[0])<Be,d=Math.abs(s[1]-i[1])<Be&&Math.abs(i[1]-a[1])<Be;l||d||o.push(i)}return o.push(n[n.length-1]),o}function Lr(){return{elements:new Map,buses:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function zr(e){return{at:(e==null?void 0:e.at)??[0,0],rot:(e==null?void 0:e.rot)??0,mirror:(e==null?void 0:e.mirror)??!1}}function vn(e){return e===90||e===270?"y":"x"}function Ae(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const Ov={n:"e",e:"s",s:"w",w:"n"},Bv={n:"n",s:"s",e:"w",w:"e"};function wt(e,t){let n=t.mirror?Bv[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=Ov[n];return n}function kn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class Rr{constructor(){dt(this,"parent",new Map);dt(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const yo=["n","e","s","w"],xo={n:"s",s:"n",e:"w",w:"e"};function bo(e,t){const n=yo.indexOf(e),r=((yo.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const wo=320,rn=220,ft=260,sn=720,ht=30,vo=30,He=80,ko=10,Lv=60,zv=520,Rv=80,Dv=80,_o=8,$o=new Set(["source","renewable"]);function Fv(e){var no,oo,ro,so,io,ao;const{elements:t,buses:n,wires:o,library:r,userLayout:s,userBusLayout:i}=e,a=new Map(s),l=new Map(i),d=new Map;for(const y of t)d.set(y.id,y);const u=new Map;for(const y of n)u.set(y.id,y);const m=y=>{const w=d.get(y);if(w)return r.get(w.kind)},h=new Set(n.map(y=>y.id)),g=y=>h.has(y),f=new Rr;for(const y of o)f.add(y.ends[0]),f.add(y.ends[1]),f.union(y.ends[0],y.ends[1]);for(const y of t){const w=r.get(y.kind);if(w)for(const $ of w.terminals)f.add(`${y.id}.${$.id}`)}for(const y of n)f.add(y.id);const p=[];for(const[,y]of f.groups())y.length>=2&&p.push(y);const b=new Map;for(const y of p)for(const w of y)b.set(w,[y]);const k=new Map;for(const y of p){const w=y.filter(g);if(w.length!==0)for(const $ of w){const S=y.filter(_=>_!==$),j=k.get($)??[];j.push(...S),k.set($,j)}}const v=new Map;for(const y of p){const w=y.filter(g);if(w.length!==0)for(const $ of y){if(g($))continue;const S=$.indexOf(".");if(S<0)continue;const j=$.slice(0,S),_=$.slice(S+1),E=v.get(j)??[];for(const O of w)E.some(T=>T.busId===O&&T.pin===_)||E.push({busId:O,pin:_});v.set(j,E)}}const N=[],A=new Set;for(const[y,w]of v)if(new Set(w.map(S=>S.busId)).size>=2){const S=((oo=r.get(((no=d.get(y))==null?void 0:no.kind)??""))==null?void 0:oo.category)==="transformer"?"vertical":"horizontal";N.push({elementId:y,attachments:w,orientation:S}),S==="vertical"&&A.add(y)}const R=new Map,F=(y,w)=>{y!==w&&(R.has(y)||R.set(y,new Set),R.has(w)||R.set(w,new Set),R.get(y).add(w),R.get(w).add(y))};for(const y of o)F(y.ends[0],y.ends[1]);for(const y of t){const w=r.get(y.kind);if(!w||w.terminals.length<2)continue;const $=w.terminals.map(S=>`${y.id}.${S.id}`);for(let S=0;S<$.length;S++)for(let j=S+1;j<$.length;j++)F($[S],$[j])}for(const y of t){if(A.has(y.id))continue;const w=r.get(y.kind);if(!w||w.category!=="transformer"||w.terminals.length<2)continue;const $=w.terminals.map(_=>`${y.id}.${_.id}`),S=new Map;for(const _ of $){const E=_.slice(y.id.length+1);S.set(E,new Set);const O=new Set($.filter(P=>P!==_)),T=new Set([_]),C=[_];for(;C.length>0;){const P=C.shift();if(g(P)){S.get(E).add(P);continue}const M=R.get(P);if(M)for(const L of M)T.has(L)||O.has(L)||(T.add(L),C.push(L))}}const j=new Set;for(const _ of S.values())for(const E of _)j.add(E);if(j.size>=2){const _=[];for(const[E,O]of S)for(const T of O)_.push({busId:T,pin:E});N.push({elementId:y.id,attachments:_,orientation:"vertical"}),A.add(y.id)}}const te=(y,w)=>{var O;const $=m(w),S=$?$.terminals.map(T=>`${w}.${T.id}`):[],j=y,_=new Set([j,...S]),E=[j];for(;E.length>0;){const T=E.shift(),C=T.indexOf(".");if(C>0){const M=T.slice(0,C),L=d.get(M);if(L){const z=(O=r.get(L.kind))==null?void 0:O.category;if(z&&$o.has(z))return!0}}const P=R.get(T);if(P)for(const M of P)_.has(M)||(_.add(M),E.push(M))}return!1};for(const y of N){if(y.orientation!=="horizontal")continue;const w=new Set(y.attachments.map(S=>S.busId));let $=0;for(const S of w)te(S,y.elementId)&&$++;$===1&&(y.orientation="vertical",A.add(y.elementId))}for(const y of t){if(A.has(y.id)||y.kind!=="breaker")continue;const w=r.get(y.kind);if(!w||w.terminals.length!==2)continue;const $=w.terminals.map(_=>`${y.id}.${_.id}`),S=new Map;for(const _ of $){const E=_.slice(y.id.length+1),O=new Set($.filter(P=>P!==_)),T=new Set([_]),C=[_];for(;C.length>0;){const P=C.shift();if(g(P)){S.set(E,P);break}const M=R.get(P);if(M)for(const L of M){if(T.has(L)||O.has(L))continue;const z=L.indexOf(".");if(z>0){const H=L.slice(0,z);if(H!==y.id){const G=d.get(H),K=G?r.get(G.kind):void 0;if((K==null?void 0:K.category)==="transformer")continue}}T.add(L),C.push(L)}}}if(new Set(S.values()).size>=2){const _=[];for(const[E,O]of S)_.push({busId:O,pin:E});N.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ee=new Map;for(const y of n)ee.set(y.id,new Map);for(const y of N){const w=Array.from(new Set(y.attachments.map($=>$.busId)));for(const $ of w)for(const S of w)$!==S&&((ro=ee.get($))==null||ro.set(S,y))}const xe=y=>{var $;const w=($=r.get(y))==null?void 0:$.category;return w?$o.has(w):!1},fe=[];for(const y of n){const w=k.get(y.id);if(w)for(const $ of w){if(g($))continue;const S=$.indexOf(".");if(S<0)continue;const j=$.slice(0,S),_=d.get(j);if(_&&xe(_.kind)){fe.push(y.id);break}}}fe.length===0&&n.length>0&&fe.push(n[0].id);const B=new Map;for(const y of fe)B.set(y,0);{const y=[...fe];for(;y.length>0;){const w=y.shift(),$=B.get(w),S=ee.get(w);if(S)for(const[j,_]of S){if(B.has(j))continue;const E=_.orientation==="horizontal"?$:$+1;B.set(j,E),y.push(j)}}}for(const y of n){if(B.has(y.id))continue;const w=B.size===0?-1:Math.max(...Array.from(B.values()));B.set(y.id,w+1)}const D=new Map;for(const y of n){const w=B.get(y.id),$=D.get(w)??[];$.push(y.id),D.set(w,$)}const oe=[...D.keys()].sort((y,w)=>y-w),re=(y,w,$)=>{const S=`${y.elementId}.${$}`,j=w,_=m(y.elementId),E=new Set;if(_)for(const M of _.terminals)M.id!==$&&E.add(`${y.elementId}.${M.id}`);const O=new Set([S]),T=[{ref:S,dist:0}],C=new Map,P=(M,L,z,H)=>{O.add(M),C.set(M,L),T.push({ref:M,dist:H+z})};for(;T.length>0;){const{ref:M,dist:L}=T.shift();if(M===j){const K=C.get(j);let ie;if(K){const V=K.indexOf(".");if(V>0){const W=K.slice(0,V);W!==y.elementId&&(ie=W)}}return{extent:L,head:ie}}const z=M.indexOf(".");if(z<0)continue;const H=M.slice(0,z),G=M.slice(z+1);if(!g(H)&&!A.has(H)){const K=m(H),ie=K==null?void 0:K.terminals.find(V=>V.id===G);if(K&&ie)for(const V of K.terminals){if(V.id===G)continue;const W=`${H}.${V.id}`;O.has(W)||E.has(W)||P(W,M,Math.abs(ie.y-V.y),L)}}for(const K of b.get(M)??[])for(const ie of K){if(ie===M||O.has(ie)||E.has(ie))continue;const V=g(M)||g(ie);P(ie,M,V?vo:ht,L)}}return{extent:0}},ue=(y,w)=>{var M,L,z;const $=(M=ee.get(y))==null?void 0:M.get(w);if(!$||$.orientation==="horizontal")return ft;const S=m($.elementId);if(!S)return ft;const j=(L=$.attachments.find(H=>H.busId===y))==null?void 0:L.pin,_=(z=$.attachments.find(H=>H.busId===w))==null?void 0:z.pin;if(!j||!_)return ft;const E=S.terminals.find(H=>H.id===j),O=S.terminals.find(H=>H.id===_);if(!E||!O)return ft;const T=Math.abs(O.y-E.y),C=re($,y,j).extent,P=re($,w,_).extent;return C+T+P},U=new Map;for(const y of N){if(y.orientation!=="vertical")continue;const w=y.attachments.slice().sort((O,T)=>(B.get(O.busId)??0)-(B.get(T.busId)??0));if(w.length<2)continue;const $=w[0].busId,S=w[1].busId,j=w[0].pin,E=re(y,$,j).head??y.elementId;U.set(E,{lowerBusId:S})}const me=30,pe=y=>{const w=m(y);return Math.max((w==null?void 0:w.width)??He,He)},be=2,Ie=(y,w,$,S=0)=>{const j=m(w);let _=pe(w);if(j&&!$.has(w)&&S<be){$.add(w);let E=0;for(const O of j.terminals){const T=`${w}.${O.id}`;if(T!==y)for(const C of b.get(T)??[]){const P=new Set;let M=!1;for(const z of C){if(z===T)continue;if(g(z)){M=!0;continue}const H=z.indexOf(".");if(H<0)continue;const G=z.slice(0,H);G===w||$.has(G)||A.has(G)||P.add(G)}if(M||P.size===0)continue;let L=0;for(const z of P){const H=[...C].find(G=>G.indexOf(".")>0&&G.slice(0,G.indexOf("."))===z);L+=(H?Ie(H,z,$,S+1):pe(z))+me}E=Math.max(E,L-me)}}$.delete(w),_=Math.max(_,E)}return _},he=320,Qe=new Map,Kn=(y,w)=>{if(!A.has(y))return!1;const $=N.find(E=>E.elementId===y),S=$==null?void 0:$.attachments.find(E=>E.busId!==w);if(!S)return!1;const j=B.get(w)??0;return(B.get(S.busId)??0)<j},lt=(y,w,$)=>{const S=U.get(y);if(S){const _=Qe.get(S.lowerBusId);if(_!==void 0)return Math.max(w,_+He)}let j=0;return $&&(j=Ie($,y,new Set)),Math.max(w,He,j)},Xn=(y,w)=>{if(Qe.has(y))return Qe.get(y);if(w.has(y))return he;w.add(y);const $=k.get(y)??[];let S=0,j=0;for(const E of $){if(g(E))continue;const O=E.indexOf(".");if(O<0)continue;const T=E.slice(0,O),C=E.slice(O+1);if(Kn(T,y))continue;const P=m(T);if(!P)continue;const M=P.terminals.find(H=>H.id===C);if(!M)continue;const L=U.get(T);L&&Xn(L.lowerBusId,w);const z=lt(T,P.width,`${T}.${C}`);M.y>0?S+=z:j+=z}const _=Math.max(he,Math.max(S,j)+He);return Qe.set(y,_),w.delete(y),_};for(const y of n)Xn(y.id,new Set);const Re=new Map,bw=(y,w,$)=>{const S=m(w);if(!S)return;const j=`${w}.${$}`,_=S.terminals.filter(T=>T.id!==$).map(T=>`${w}.${T.id}`);if(_.length===0)return;const E=new Set([j,..._]),O=_.slice();for(;O.length>0;){const T=O.shift();if(g(T)&&T!==y){const P=l.get(T);return P?P.at[0]:void 0}for(const P of b.get(T)??[])for(const M of P)M===T||E.has(M)||(E.add(M),O.push(M));const C=T.indexOf(".");if(C>0){const P=T.slice(0,C);if(!g(P)){const M=m(P);if(M)for(const L of M.terminals){const z=`${P}.${L.id}`;E.has(z)||(E.add(z),O.push(z))}}}}},ww=y=>{const w=k.get(y);if(!w||w.length===0)return;const $=l.get(y);if(!$)return;const S=w.flatMap(M=>{if(g(M))return[];const L=M.indexOf(".");if(L<0)return[];const z=M.slice(0,L),H=M.slice(L+1);if(a.has(z))return[];if(Kn(z,y))return[];const G=m(z);if(!G)return[];const K=G.terminals.find(ie=>ie.id===H);return K?[{elId:z,lib:G,localTerm:K,isLinker:A.has(z),busFacingRef:`${z}.${H}`}]:[]});if(S.length===0)return;const j=[],_=[];for(const M of S)M.localTerm.y>0?j.push(M):_.push(M);const E=M=>M.reduce((L,z)=>L+lt(z.elId,z.lib.width,z.busFacingRef),0),O=Math.max(E(j),E(_))+He,T=Math.max($.span,O);T!==$.span&&l.set(y,{...$,span:T});const C=l.get(y),P=(M,L)=>{if(M.length===0)return;const z=new Map;for(const q of M){const Y=bw(y,q.elId,q.localTerm.id);Y!==void 0&&z.set(q.elId,Y)}M.sort((q,Y)=>{const ce=z.get(q.elId)??C.at[0],ge=z.get(Y.elId)??C.at[0];if(ce!==ge)return ce-ge;const ve=lt(q.elId,q.lib.width,q.busFacingRef);return lt(Y.elId,Y.lib.width,Y.busFacingRef)-ve});const H=M.map(q=>lt(q.elId,q.lib.width,q.busFacingRef)),G=H.reduce((q,Y)=>q+Y,0),K=Math.max(T,G),ie=(K-G)/(M.length+1);let V=C.at[0]-K/2+ie;const W=C.at[1]+L*vo;for(let q=0;q<M.length;q++){const Y=M[q],ce=H[q],ge=V+ce/2;Y.isLinker?Re.has(Y.elId)||Re.set(Y.elId,ge):a.set(Y.elId,{at:[de(ge-Y.localTerm.x),de(W-Y.localTerm.y)],rot:0,mirror:!1}),V+=ce+ie}};P(j,-1),P(_,1)},vw=y=>{if(a.has(y.elementId)||y.orientation==="horizontal")return;const w=m(y.elementId);if(!w)return;const $=y.attachments.filter(V=>l.has(V.busId));if($.length<2)return;const S=$.slice().sort((V,W)=>(B.get(V.busId)??0)-(B.get(W.busId)??0)),j=S[0].busId,_=l.get(j),E=S[0].pin,O=S[S.length-1].pin,T=w.terminals.find(V=>V.id===E),C=w.terminals.find(V=>V.id===O);if(!T||!C)return;const P=T.y<=C.y?0:180,M=B.get(j)??0,L=$.filter(V=>(B.get(V.busId)??0)===M),z=[];let H=0;for(const V of L){const W=re(y,V.busId,V.pin);H=Math.max(H,W.extent);const q=W.head?a.get(W.head):void 0;q?z.push(q.at[0]):Re.has(y.elementId)?z.push(Re.get(y.elementId)):z.push(l.get(V.busId).at[0])}let G;z.length>0?G=z.reduce((V,W)=>V+W,0)/z.length:Re.has(y.elementId)?G=Re.get(y.elementId):G=_.at[0];const K=_.at[1]+H,ie=P===0?[de(G-T.x),de(K-T.y)]:[de(G+T.x),de(K+T.y)];if(a.set(y.elementId,{at:ie,rot:P,mirror:!1}),L.length>1){const V=a.get(y.elementId),W=Ae([T.x,T.y],V),q=wt(T.orientation,V);kw(`${y.elementId}.${E}`,W,q,G)}},kw=(y,w,$,S)=>{const j=new Set([y]);let _=y,E=w,O=$;for(;;){const T=b.get(_)??[];let C,P=!1;for(const Te of T){if(Te.length>=3){P=!0;break}const Ye=Te.find(nn=>nn!==_);if(!(!Ye||j.has(Ye))){if(g(Ye)){P=!0;break}C=Ye;break}}if(P||!C)break;const M=C.indexOf(".");if(M<0)break;const L=C.slice(0,M),z=C.slice(M+1);if(g(L)||A.has(L)||a.has(L))break;const H=m(L);if(!H)break;const G=H.terminals.find(Te=>Te.id===z);if(!G)break;const K=kn(O),ie=[E[0]+K[0]*ht,E[1]+K[1]*ht],V=xo[O],W=bo(G.orientation,V),q=Ae([G.x,G.y],{at:[0,0],rot:W,mirror:!1}),Y=[de(S-q[0]),de(ie[1]-q[1])];a.set(L,{at:Y,rot:W,mirror:!1}),j.add(C);const ce=H.terminals.find(Te=>Te.id!==z);if(!ce)break;const ge=`${L}.${ce.id}`;j.add(ge);const ve={at:Y,rot:W,mirror:!1};E=Ae([ce.x,ce.y],ve),O=wt(ce.orientation,ve),_=ge}},_w=y=>{if(a.has(y.elementId)||y.orientation!=="horizontal")return;const w=m(y.elementId);if(!w)return;const $=y.attachments.filter(L=>l.has(L.busId));if($.length<2)return;const S=$.map(L=>{const z=re(y,L.busId,L.pin),H=z.head?a.get(z.head):void 0,G=H?H.at[0]:l.get(L.busId).at[0];return{att:L,x:G,extent:z.extent}});S.sort((L,z)=>L.x-z.x);const j=S[0],_=S[S.length-1],E=w.terminals.find(L=>L.id===j.att.pin),O=w.terminals.find(L=>L.id===_.att.pin);if(!E||!O)return;const T=E.y<=O.y?270:90,C=(j.x+_.x)/2,M=l.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);a.set(y.elementId,{at:[de(C),de(M)],rot:T,mirror:!1})},Vn=100;let Mt=rn;for(let y=0;y<oe.length;y++){const w=oe[y],$=D.get(w);let S;if(y===0)S=rn;else{const _=D.get(oe[y-1]);let E=0;for(const O of _)for(const T of $)(so=ee.get(O))!=null&&so.get(T)&&(E=Math.max(E,ue(O,T)));E===0&&(E=ft),S=Mt+E}Mt=S;let j=wo;for(const _ of $){if(l.has(_)){Mt=Math.max(Mt,l.get(_).at[1]);continue}let E;if(y>0){const T=D.get(oe[y-1]),C=[];for(const P of T){const M=(io=ee.get(P))==null?void 0:io.get(_);if(!M||M.orientation!=="vertical")continue;const L=(ao=M.attachments.find(H=>H.busId===P))==null?void 0:ao.pin;if(!L)continue;const z=re(M,P,L);z.head&&a.has(z.head)?C.push(a.get(z.head).at[0]):Re.has(M.elementId)?C.push(Re.get(M.elementId)):C.push(l.get(P).at[0])}C.length>0&&(E=C.reduce((P,M)=>P+M,0)/C.length)}if(E===void 0){const T=Qe.get(_)??sn;E=j+T/2,j+=T+Vn}const O=Qe.get(_)??sn;l.set(_,{at:[de(E),de(S)],rot:0,span:O,axis:vn(0)})}for(const _ of $)ww(_);if(y>0)for(const _ of N)a.has(_.elementId)||!_.attachments.some(O=>$.includes(O.busId))||vw(_);for(const _ of N)_.orientation!=="horizontal"||a.has(_.elementId)||!_.attachments.every(O=>$.includes(O.busId))||_w(_)}if(n.length===0&&a.size<t.length){const y=j=>{const _=new Set,E=m(j);if(!E)return _;for(const O of E.terminals){const T=`${j}.${O.id}`;for(const C of b.get(T)??[])for(const P of C){if(P===T||g(P))continue;const M=P.indexOf(".");if(M<0)continue;const L=P.slice(0,M);L!==j&&_.add(L)}}return _},w=new Set,$=[];for(const j of t){if(w.has(j.id)||!m(j.id))continue;const _=[],E=[j.id];for(w.add(j.id);E.length>0;){const O=E.pop();_.push(O);for(const T of y(O))w.has(T)||(w.add(T),E.push(T))}_.length>=2&&$.push(_)}let S=wo;for(const j of $){if(j.some(C=>a.has(C)))continue;j.sort((C,P)=>{var G,K;const M=xe(((G=d.get(C))==null?void 0:G.kind)??"")?0:1,L=xe(((K=d.get(P))==null?void 0:K.kind)??"")?0:1;if(M!==L)return M-L;const z=y(C).size,H=y(P).size;return z!==H?z-H:C.localeCompare(P)});const _=j[0],E=m(_);if(!E)continue;const O=E.terminals.slice().sort((C,P)=>P.y-C.y)[0],T=O?Ae([O.x,O.y],{at:[0,0],rot:0,mirror:!1}):[0,0];a.set(_,{at:[de(S-T[0]),de(rn-T[1])],rot:0,mirror:!1}),S+=Math.max(sn,j.length*He)+Vn}}const $w=y=>{if(g(y))return l.has(y);const w=y.indexOf(".");return w<0?!1:a.has(y.slice(0,w))};let Zt=!0,Sw=t.length+4;for(;Zt&&Sw-- >0;){Zt=!1;for(const y of p){if(y.length<2)continue;const w=[],$=new Map;for(const W of y){if(g(W))continue;const q=W.indexOf(".");if(q<0)continue;const Y=W.slice(0,q),ce=W.slice(q+1);if(a.has(Y)){w.push(W);continue}if(A.has(Y)||$.has(Y))continue;const ge=m(Y);if(!ge)continue;const ve=ge.terminals.find(Te=>Te.id===ce);ve&&$.set(Y,{ref:W,elId:Y,lib:ge,localTerm:ve})}if($.size===0||w.length===0)continue;const S=[...$.values()],j=new Map;for(const W of S)for(const q of b.get(W.ref)??[])for(const Y of q){if(Y===W.ref||g(Y)||!$w(Y))continue;const ce=Y;j.set(ce,(j.get(ce)??0)+1)}let _;if(j.size>0){let W=-1;for(const[q,Y]of j)(Y>W||Y===W&&(_===void 0||q<_))&&(W=Y,_=q)}if(_||(_=[...w].sort()[0]),!_)continue;const E=_.indexOf("."),O=_.slice(0,E),T=_.slice(E+1),C=m(O),P=a.get(O);if(!C||!P)continue;const M=C.terminals.find(W=>W.id===T);if(!M)continue;const L=Ae([M.x,M.y],P),z=wt(M.orientation,P),H=kn(z),G=[-H[1],H[0]];S.sort((W,q)=>W.elId.localeCompare(q.elId));const K=S.map(W=>Math.max(W.lib.width,He));let V=-K.reduce((W,q)=>W+q,0)/2;for(let W=0;W<S.length;W++){const q=S[W],Y=K[W],ce=V+Y/2;V+=Y;const ge=xo[z],ve=bo(q.localTerm.orientation,ge),Te=Ae([q.localTerm.x,q.localTerm.y],{at:[0,0],rot:ve,mirror:!1}),Ye=[L[0]+H[0]*ht+G[0]*ce,L[1]+H[1]*ht+G[1]*ce],nn=[de(Ye[0]-Te[0]),de(Ye[1]-Te[1])];a.set(q.elId,{at:nn,rot:ve,mirror:!1}),Zt=!0}}}const ct=y=>{const w=a.get(y),$=m(y);if(!w||!$)return null;const S=$.viewBox.split(/\s+/).map(Number);if(S.length<4||S.some(M=>Number.isNaN(M))){const M=$.width/2;return{min:w.at[0]-M,max:w.at[0]+M}}const[j,_,E,O]=S,T=[[j,_],[j+E,_],[j,_+O],[j+E,_+O]];let C=1/0,P=-1/0;for(const M of T){const L=Ae(M,w);C=Math.min(C,L[0]),P=Math.max(P,L[0])}return{min:C,max:P}},Qt=y=>{const w=new Set,$=m(y);if(!$)return w;for(const S of $.terminals){const j=`${y}.${S.id}`;for(const _ of b.get(j)??[])for(const E of _){if(E===j||g(E))continue;const O=E.indexOf(".");if(O<0)continue;const T=E.slice(0,O);T!==y&&w.add(T)}}return w},Yn=40,Jt=y=>{const w=a.get(y),$=m(y);if(!w||!$)return null;const S=$.viewBox.split(/\s+/).map(Number);if(S.length<4||S.some(M=>Number.isNaN(M))){const M=$.height/2;return{min:w.at[1]-M,max:w.at[1]+M}}const[j,_,E,O]=S,T=[[j,_],[j+E,_],[j,_+O],[j+E,_+O]];let C=1/0,P=-1/0;for(const M of T){const L=Ae(M,w);C=Math.min(C,L[1]),P=Math.max(P,L[1])}return{min:C,max:P}},jw=(y,w)=>{const $=new Set,S=[];for(const j of k.get(y)??[]){if(g(j))continue;const _=j.indexOf(".");if(_<0)continue;const E=j.slice(0,_),O=a.get(E);!O||O.at[1]>=w-1||$.has(E)||($.add(E),S.push(E))}for(;S.length>0;){const j=S.pop();for(const _ of Qt(j)){if($.has(_))continue;const E=a.get(_);!E||E.at[1]>=w-1||($.add(_),S.push(_))}}return $},Un=(y,w,$)=>{const S=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const E of Qt(_))E===w||S.has(E)||!$.has(E)||(S.add(E),j.push(E))}return S},Zn=(y,w)=>{let $=y.length*y.length+8,S=!1,j=!0;for(;j&&$-- >0;){j=!1;for(let _=0;_<y.length&&!j;_++)for(let E=_+1;E<y.length;E++){const O=y[_],T=y[E],C=ct(O),P=ct(T),M=Jt(O),L=Jt(T);if(!C||!P||!M||!L)continue;const z=Math.min(C.max,P.max)-Math.max(C.min,P.min),H=Math.min(M.max,L.max)-Math.max(M.min,L.min);if(z<=0||H<=0)continue;const G=Un(O,T,w),K=Un(T,O,w);if(G.has(T)||K.has(O))continue;const ie=(C.min+C.max)/2,V=(P.min+P.max)/2;let W,q;G.size<=K.size?(W=G,q=ie<=V?-1:1):(W=K,q=V<=ie?-1:1);const Y=Math.max(C.max,P.max)-Math.min(C.min,P.min),ce=de(q*(Y+Yn));if(ce!==0){for(const ge of W){const ve=a.get(ge);ve&&a.set(ge,{...ve,at:[ve.at[0]+ce,ve.at[1]]})}S=!0,j=!0;break}}}return S};for(const y of n){const w=l.get(y.id);if(!w)continue;const $=jw(y.id,w.at[1]);if($.size<2)continue;const S=[...$];if(Zn(S,$)){let _=1/0,E=-1/0;for(const O of S){const T=ct(O);T&&(_=Math.min(_,T.min),E=Math.max(E,T.max))}if(Number.isFinite(_)){const O=de(w.at[0]-(_+E)/2);if(O!==0)for(const C of S){const P=a.get(C);P&&a.set(C,{...P,at:[P.at[0]+O,P.at[1]]})}const T=E-_+Yn;if(T>w.span){const C=l.get(y.id);l.set(y.id,{...C,span:T})}}}}const Qn=()=>{const w=t.map(S=>S.id).filter(S=>a.has(S)).map(S=>({x:ct(S),y:Jt(S)})).filter(S=>S.x&&S.y);let $=0;for(let S=0;S<w.length;S++)for(let j=S+1;j<w.length;j++){const _=Math.min(w[S].x.max,w[j].x.max)-Math.max(w[S].x.min,w[j].x.min),E=Math.min(w[S].y.max,w[j].y.max)-Math.max(w[S].y.min,w[j].y.min);_>1&&E>1&&$++}return $},Ew=Qn(),Jn=new Map;for(const[y,w]of a)Jn.set(y,{...w,at:[...w.at]});const eo=new Map;for(const[y,w]of l)eo.set(y,{...w,at:[...w.at]});const en=120,to=new Map;{const y=new Map,w=new Map,$=[];for(const j of n)for(const _ of k.get(j.id)??[]){if(g(_))continue;const E=_.indexOf(".");if(E<0)continue;const O=_.slice(0,E);a.has(O)&&$.push({el:O,bus:j.id,d:1})}$.sort((j,_)=>j.d-_.d);let S=0;for(;S<$.length;){const{el:j,bus:_,d:E}=$[S++],O=y.get(j);if(O===void 0)y.set(j,E),w.set(j,_);else if(E===O&&w.get(j)!==_){w.set(j,null);continue}else continue;for(const T of Qt(j))a.has(T)&&(y.has(T)||$.push({el:T,bus:_,d:E+1}))}for(const[j,_]of w)_&&to.set(j,_)}for(const y of oe){const w=(D.get(y)??[]).filter(C=>l.has(C));if(w.length<2)continue;const $=[];let S=0;for(const C of w){const P=l.get(C),M=[];let L=1/0,z=-1/0;for(const[H,G]of to){if(G!==C)continue;const K=ct(H);K&&(M.push(H),L=Math.min(L,K.min),z=Math.max(z,K.max))}Number.isFinite(L)||(L=P.at[0]-he/2,z=P.at[0]+he/2),$.push({busId:C,min:L,max:z,members:M}),S+=z-L}let j=1/0,_=-1/0;for(const C of $)j=Math.min(j,C.min),_=Math.max(_,C.max);const E=_-j,O=S+en*($.length-1);if(!(E>O+en))continue;$.sort((C,P)=>(C.min+C.max)/2-(P.min+P.max)/2);let T=j;for(const C of $){const P=de(T-C.min);if(P!==0){const M=l.get(C.busId);l.set(C.busId,{...M,at:[M.at[0]+P,M.at[1]]});for(const L of C.members){const z=a.get(L);z&&a.set(L,{...z,at:[z.at[0]+P,z.at[1]]})}C.min+=P,C.max+=P}T=C.max+en}for(const C of $){const P=l.get(C.busId),M=Math.max(he,C.max-C.min);M<P.span&&l.set(C.busId,{...P,span:M})}}{const y=t.map($=>$.id).filter($=>a.has($)),w=new Set(y);Zn(y,w)}if(Qn()>Ew){a.clear();for(const[y,w]of Jn)a.set(y,w);l.clear();for(const[y,w]of eo)l.set(y,w)}let tn=0;for(const y of t){if(a.has(y.id))continue;const w=tn%_o,$=Math.floor(tn/_o);a.set(y.id,{at:[de(Lv+w*Rv),de(zv+$*Dv)],rot:0,mirror:!1}),tn++}return{devices:a,buses:l}}function de(e){return Math.round(e/ko)*ko}function Hv(e,t){const n=e.ends[0],o=e.ends[1],r=So(n,t),s=So(o,t);if(r||s){const l=r?n:o,u=an(r?o:n,t);if(!u)return null;const m=t.buses.get(l);if(!m)return null;const{axis:h,at:g,span:f}=m.geometry,p=f/2;let b;if(h==="x")b=[zt(u[0],g[0]-p,g[0]+p),g[1]];else{const k=zt(u[1],g[1]-p,g[1]+p);b=[g[0],k]}return{wireId:e.id,path:Eo(u,b)}}const i=an(n,t),a=an(o,t);return!i||!a?null:{wireId:e.id,path:Eo(i,a)}}function So(e,t){return!e.includes(".")&&t.buses.has(e)}function an(e,t){if(!e.includes(".")){const o=t.buses.get(e);return o?o.geometry.at:null}const n=t.terminals.get(e);return n?n.world:null}function jo(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r)return null;const{axis:s,at:i,span:a}=r.geometry;if(!t)return[i[0],i[1]];const l=a/2;if(s==="x")return[zt(t[0],i[0]-l,i[0]+l),i[1]];const d=zt(t[1],i[1]-l,i[1]+l);return[i[0],d]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function Eo(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function zt(e,t,n){return e<t?t:e>n?n:e}const Dr="ammeter",Fr="电流表 (A)",Hr="measurement",Wr="-22 -42 44 44",qr=44,Gr=44,Kr='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-15" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">A</text>',Xr=[{id:"t_top",x:0,y:-40,orientation:"n"}],Vr={kind:"inline"},Wv={id:Dr,name:Fr,category:Hr,viewBox:Wr,width:qr,height:Gr,svg:Kr,terminals:Xr,source:Vr},qv=Object.freeze(Object.defineProperty({__proto__:null,category:Hr,default:Wv,height:Gr,id:Dr,name:Fr,source:Vr,svg:Kr,terminals:Xr,viewBox:Wr,width:qr},Symbol.toStringTag,{value:"Module"})),Yr="arc-suppression-coil",Ur="消弧线圈",Zr="grounding",Qr="中性点谐振接地:电感线圈连接到地",Jr="-12 -32 24 67",es=24,ts=67,ns='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',os=[{id:"t_top",x:0,y:-30,orientation:"n"}],rs={kind:"inline"},Gv={id:Yr,name:Ur,category:Zr,description:Qr,viewBox:Jr,width:es,height:ts,svg:ns,terminals:os,source:rs},Kv=Object.freeze(Object.defineProperty({__proto__:null,category:Zr,default:Gv,description:Qr,height:ts,id:Yr,name:Ur,source:rs,svg:ns,terminals:os,viewBox:Jr,width:es},Symbol.toStringTag,{value:"Module"})),ss="arrester",is="避雷器 (FBL)",as="protection",ls="-7 -22 14 44",cs=14,ds=44,us='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',ms=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],fs={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},Xv={id:ss,name:is,category:as,viewBox:ls,width:cs,height:ds,svg:us,terminals:ms,source:fs},Vv=Object.freeze(Object.defineProperty({__proto__:null,category:as,default:Xv,height:ds,id:ss,name:is,source:fs,svg:us,terminals:ms,viewBox:ls,width:cs},Symbol.toStringTag,{value:"Module"})),hs="async-motor",ps="异步电动机",gs="load",ys="-62 -82 64 84",xs=64,bs=84,ws='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',vs=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],ks={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},Yv={id:hs,name:ps,category:gs,viewBox:ys,width:xs,height:bs,svg:ws,terminals:vs,source:ks},Uv=Object.freeze(Object.defineProperty({__proto__:null,category:gs,default:Yv,height:bs,id:hs,name:ps,source:ks,svg:ws,terminals:vs,viewBox:ys,width:xs},Symbol.toStringTag,{value:"Module"})),_s="autotransformer",$s="自耦变压器",Ss="transformer",js="-62 -112 64 144",Es=64,Ns=144,Ms='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-110" x2="-30" y2="-90" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -30 A 30 60 0 0 0 -30 -90" fill="none" stroke="black" stroke-width="1"/>',Ts=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],As={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},Zv={id:_s,name:$s,category:Ss,viewBox:js,width:Es,height:Ns,svg:Ms,terminals:Ts,source:As},Qv=Object.freeze(Object.defineProperty({__proto__:null,category:Ss,default:Zv,height:Ns,id:_s,name:$s,source:As,svg:Ms,terminals:Ts,viewBox:js,width:Es},Symbol.toStringTag,{value:"Module"})),Cs="battery",Is="电池储能",Ps="storage",Os="-12 -12 29 24",Bs=29,Ls=24,zs='<line x1="-10" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-10" x2="5" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="0" x2="15" y2="0" fill="none" stroke="black" stroke-width="1"/>',Rs=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],Ds=[{name:"E",label:"容量",type:"number",unit:"kWh"}],Fs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},Jv={id:Cs,name:Is,category:Ps,viewBox:Os,width:Bs,height:Ls,svg:zs,terminals:Rs,params:Ds,source:Fs},e2=Object.freeze(Object.defineProperty({__proto__:null,category:Ps,default:Jv,height:Ls,id:Cs,name:Is,params:Ds,source:Fs,svg:zs,terminals:Rs,viewBox:Os,width:Bs},Symbol.toStringTag,{value:"Module"})),Hs="bell",Ws="电铃 (HA)",qs="control",Gs="信号电铃 / 警铃。",Ks="-32 -32 44 44",Xs=44,Vs=44,Ys='<line x1="-30" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -10 A 20 20 0 0 0 -30 -10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',Us=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Zs={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},t2={id:Hs,name:Ws,category:qs,description:Gs,viewBox:Ks,width:Xs,height:Vs,svg:Ys,terminals:Us,source:Zs},n2=Object.freeze(Object.defineProperty({__proto__:null,category:qs,default:t2,description:Gs,height:Vs,id:Hs,name:Ws,source:Zs,svg:Ys,terminals:Us,viewBox:Ks,width:Xs},Symbol.toStringTag,{value:"Module"})),Qs="break-contact",Js="常闭触点 (NC)",ei="control",ti="常闭辅助触点 (break contact)。",ni="-2 -42 14 64",oi=14,ri=64,si='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',ii=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ai=[{name:"open",type:"boolean",default:!1,label:"断开"}],li={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},o2={id:Qs,name:Js,category:ei,description:ti,viewBox:ni,width:oi,height:ri,svg:si,terminals:ii,state:ai,source:li},r2=Object.freeze(Object.defineProperty({__proto__:null,category:ei,default:o2,description:ti,height:ri,id:Qs,name:Js,source:li,state:ai,svg:si,terminals:ii,viewBox:ni,width:oi},Symbol.toStringTag,{value:"Module"})),ci="breaker",di="断路器 (QF)",ui="switching",mi="-7 -22 15 46",fi=15,hi=46,pi='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',gi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],yi=[{name:"open",type:"boolean",default:!1,label:"断开"}],xi={x:6,y:-2,anchor:"start"},bi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},s2={id:ci,name:di,category:ui,viewBox:mi,width:fi,height:hi,svg:pi,terminals:gi,state:yi,label:xi,source:bi},i2=Object.freeze(Object.defineProperty({__proto__:null,category:ui,default:s2,height:hi,id:ci,label:xi,name:di,source:bi,state:yi,svg:pi,terminals:gi,viewBox:mi,width:fi},Symbol.toStringTag,{value:"Module"})),wi="buchholz-relay",vi="瓦斯继电器 (63)",ki="protection",_i="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",$i="-22 -62 44 64",Si=44,ji=64,Ei='<rect x="-20" y="-60" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-20" width="10" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-55" x2="0" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -50 A 10 5 0 0 0 0 -40" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -40 A 10 5 0 0 0 0 -50" fill="none" stroke="black" stroke-width="1"/>',Ni=[{id:"t_top",x:0,y:-60,orientation:"n"}],Mi={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_18/en_60617_07_18_01.elmt",qetEnglishName:"Buchholz protective device; Gas relay"},a2={id:wi,name:vi,category:ki,description:_i,viewBox:$i,width:Si,height:ji,svg:Ei,terminals:Ni,source:Mi},l2=Object.freeze(Object.defineProperty({__proto__:null,category:ki,default:a2,description:_i,height:ji,id:wi,name:vi,source:Mi,svg:Ei,terminals:Ni,viewBox:$i,width:Si},Symbol.toStringTag,{value:"Module"})),Ti="busbar",Ai="母线段",Ci="busbar",Ii="可拉伸单母线段,多设备挂接",Pi="-42 -4 84 8",Oi=84,Bi=8,Li='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',zi=[{id:"tap",x:0,y:0,orientation:"n"}],Ri={axis:"x",minLength:20,naturalSpan:80},Di=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],Fi={x:0,y:-6,anchor:"middle"},Hi={kind:"inline"},c2={id:Ti,name:Ai,category:Ci,description:Ii,viewBox:Pi,width:Oi,height:Bi,svg:Li,terminals:zi,stretchable:Ri,params:Di,label:Fi,source:Hi},d2=Object.freeze(Object.defineProperty({__proto__:null,category:Ci,default:c2,description:Ii,height:Bi,id:Ti,label:Fi,name:Ai,params:Di,source:Hi,stretchable:Ri,svg:Li,terminals:zi,viewBox:Pi,width:Oi},Symbol.toStringTag,{value:"Module"})),Wi="buzzer",qi="蜂鸣器 (HA)",Gi="control",Ki="信号蜂鸣器。",Xi="-32 -52 44 64",Vi=44,Yi=64,Ui='<line x1="-30" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><path d="M -30 -30 A 20 20 0 0 0 10 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-12" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-12" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',Zi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Qi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},u2={id:Wi,name:qi,category:Gi,description:Ki,viewBox:Xi,width:Vi,height:Yi,svg:Ui,terminals:Zi,source:Qi},m2=Object.freeze(Object.defineProperty({__proto__:null,category:Gi,default:u2,description:Ki,height:Yi,id:Wi,name:qi,source:Qi,svg:Ui,terminals:Zi,viewBox:Xi,width:Vi},Symbol.toStringTag,{value:"Module"})),Ji="capacitor",ea="电容 (C)",ta="passive",na="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",oa="-7 -23 14 27",ra=14,sa=27,ia='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',aa=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],la=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],ca={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},f2={id:Ji,name:ea,category:ta,description:na,viewBox:oa,width:ra,height:sa,svg:ia,terminals:aa,params:la,source:ca},h2=Object.freeze(Object.defineProperty({__proto__:null,category:ta,default:f2,description:na,height:sa,id:Ji,name:ea,params:la,source:ca,svg:ia,terminals:aa,viewBox:oa,width:ra},Symbol.toStringTag,{value:"Module"})),da="contactor",ua="接触器 (KM)",ma="motor-control",fa="主回路接触器, 通常配热继电器和电机使用。",ha="-10 -42 15 64",pa=15,ga=64,ya='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',xa=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ba=[{name:"open",type:"boolean",default:!0,label:"断开"}],wa={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_02.elmt",qetEnglishName:"Contactor; Main make contact of a contactor"},p2={id:da,name:ua,category:ma,description:fa,viewBox:ha,width:pa,height:ga,svg:ya,terminals:xa,state:ba,source:wa},g2=Object.freeze(Object.defineProperty({__proto__:null,category:ma,default:p2,description:fa,height:ga,id:da,name:ua,source:wa,state:ba,svg:ya,terminals:xa,viewBox:ha,width:pa},Symbol.toStringTag,{value:"Module"})),va="converter-bidir",ka="双向变流器 (PCS)",_a="renewable",$a="储能变流器:双向 AC ↔ DC",Sa="-42 -42 44 48",ja=44,Ea=48,Na='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-6" x2="-14" y2="-6" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-6" x2="-4" y2="-6" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/><polyline points="-28,-4 -32,0 -28,4" fill="none" stroke="black" stroke-width="1"/><polyline points="-16,-4 -12,0 -16,4" fill="none" stroke="black" stroke-width="1"/>',Ma=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Ta=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Aa={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},y2={id:va,name:ka,category:_a,description:$a,viewBox:Sa,width:ja,height:Ea,svg:Na,terminals:Ma,params:Ta,source:Aa},x2=Object.freeze(Object.defineProperty({__proto__:null,category:_a,default:y2,description:$a,height:Ea,id:va,name:ka,params:Ta,source:Aa,svg:Na,terminals:Ma,viewBox:Sa,width:ja},Symbol.toStringTag,{value:"Module"})),Ca="ct",Ia="电流互感器 (CT)",Pa="instrument-transformer",Oa="-42 -62 54 64",Ba=54,La=64,za='<line x1="-30" y1="-60" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-30" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-20" x2="5" y2="-40" fill="none" stroke="black" stroke-width="1"/>',Ra=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-60,orientation:"n"}],Da={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},b2={id:Ca,name:Ia,category:Pa,viewBox:Oa,width:Ba,height:La,svg:za,terminals:Ra,source:Da},w2=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:b2,height:La,id:Ca,name:Ia,source:Da,svg:za,terminals:Ra,viewBox:Oa,width:Ba},Symbol.toStringTag,{value:"Module"})),Fa="dc-combiner",Ha="直流汇流箱",Wa="renewable",qa="光伏组串汇流箱 (4 路输入示例)。",Ga="-27 -32 54 64",Ka=54,Xa=64,Va='<rect x="-25" y="-15" width="50" height="30" fill="none" stroke="black" stroke-width="1"/><line x1="-18" y1="-30" x2="-18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="-6" y1="-30" x2="-6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-30" x2="6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="18" y1="-30" x2="18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><text x="-9" y="5" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">DC</text>',Ya=[{id:"t_s1",x:-18,y:-30,orientation:"n"},{id:"t_s2",x:-6,y:-30,orientation:"n"},{id:"t_s3",x:6,y:-30,orientation:"n"},{id:"t_s4",x:18,y:-30,orientation:"n"},{id:"t_dc",x:0,y:30,orientation:"s"}],Ua={kind:"inline"},v2={id:Fa,name:Ha,category:Wa,description:qa,viewBox:Ga,width:Ka,height:Xa,svg:Va,terminals:Ya,source:Ua},k2=Object.freeze(Object.defineProperty({__proto__:null,category:Wa,default:v2,description:qa,height:Xa,id:Fa,name:Ha,source:Ua,svg:Va,terminals:Ya,viewBox:Ga,width:Ka},Symbol.toStringTag,{value:"Module"})),Za="dc-disconnector",Qa="直流隔离开关",Ja="switching",el="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",tl="-12 -32 30 64",nl=30,ol=64,rl='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-4" x2="14" y2="-4" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-1" x2="9" y2="-1" stroke="black" stroke-width="0.8" fill="none"/><line x1="11" y1="-1" x2="14" y2="-1" stroke="black" stroke-width="0.8" fill="none"/>',sl=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],il=[{name:"open",type:"boolean",default:!1,label:"断开"}],al={kind:"inline"},_2={id:Za,name:Qa,category:Ja,description:el,viewBox:tl,width:nl,height:ol,svg:rl,terminals:sl,state:il,source:al},$2=Object.freeze(Object.defineProperty({__proto__:null,category:Ja,default:_2,description:el,height:ol,id:Za,name:Qa,source:al,state:il,svg:rl,terminals:sl,viewBox:tl,width:nl},Symbol.toStringTag,{value:"Module"})),ll="dc-motor",cl="直流电机 (M)",dl="load",ul="直流电动机 (串励通用符号)。",ml="-72 -82 89 84",fl=89,hl=84,pl='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',gl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],yl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},S2={id:ll,name:cl,category:dl,description:ul,viewBox:ml,width:fl,height:hl,svg:pl,terminals:gl,source:yl},j2=Object.freeze(Object.defineProperty({__proto__:null,category:dl,default:S2,description:ul,height:hl,id:ll,name:cl,source:yl,svg:pl,terminals:gl,viewBox:ml,width:fl},Symbol.toStringTag,{value:"Module"})),xl="diode",bl="二极管 (D)",wl="passive",vl="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",kl="-12 -42 24 44",_l=24,$l=44,Sl='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/>',jl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],El={x:6,y:-20,anchor:"start"},Nl={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},E2={id:xl,name:bl,category:wl,description:vl,viewBox:kl,width:_l,height:$l,svg:Sl,terminals:jl,label:El,source:Nl},N2=Object.freeze(Object.defineProperty({__proto__:null,category:wl,default:E2,description:vl,height:$l,id:xl,label:El,name:bl,source:Nl,svg:Sl,terminals:jl,viewBox:kl,width:_l},Symbol.toStringTag,{value:"Module"})),Ml="disconnector",Tl="隔离开关 (QS)",Al="switching",Cl="-10 -42 15 64",Il=15,Pl=64,Ol='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="-20" x2="3" y2="-20" fill="none" stroke="black" stroke-width="1"/>',Bl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ll=[{name:"open",type:"boolean",default:!1,label:"断开"}],zl={x:6,y:-10,anchor:"start"},Rl={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},M2={id:Ml,name:Tl,category:Al,viewBox:Cl,width:Il,height:Pl,svg:Ol,terminals:Bl,state:Ll,label:zl,source:Rl},T2=Object.freeze(Object.defineProperty({__proto__:null,category:Al,default:M2,height:Pl,id:Ml,label:zl,name:Tl,source:Rl,state:Ll,svg:Ol,terminals:Bl,viewBox:Cl,width:Il},Symbol.toStringTag,{value:"Module"})),Dl="distance-relay",Fl="距离继电器 (21)",Hl="protection",Wl="距离 / 低阻抗保护继电器 (ANSI 21)。",ql="-62 -42 64 44",Gl=64,Kl=44,Xl='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-42" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Z <</text>',Vl=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Yl={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},A2={id:Dl,name:Fl,category:Hl,description:Wl,viewBox:ql,width:Gl,height:Kl,svg:Xl,terminals:Vl,source:Yl},C2=Object.freeze(Object.defineProperty({__proto__:null,category:Hl,default:A2,description:Wl,height:Kl,id:Dl,name:Fl,source:Yl,svg:Xl,terminals:Vl,viewBox:ql,width:Gl},Symbol.toStringTag,{value:"Module"})),Ul="earth",Zl="接地",Ql="busbar",Jl="-12 -17 24 34",ec=24,tc=34,nc='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',oc=[{id:"t1",x:0,y:-15,orientation:"n"}],rc={kind:"elmt",path:"91_en_60617/en_60617_02/en_60617_02_15/en_60617_02_15_01.elmt",qetEnglishName:"Earth or ground, general symbol"},I2={id:Ul,name:Zl,category:Ql,viewBox:Jl,width:ec,height:tc,svg:nc,terminals:oc,source:rc},P2=Object.freeze(Object.defineProperty({__proto__:null,category:Ql,default:I2,height:tc,id:Ul,name:Zl,source:rc,svg:nc,terminals:oc,viewBox:Jl,width:ec},Symbol.toStringTag,{value:"Module"})),sc="earthing-switch",ic="接地刀闸 (QE)",ac="switching",lc="隔离开关 + 接地连接,单端口",cc="-12 -32 24 64",dc=24,uc=64,mc='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="-12" x2="-9" y2="9" stroke="black" stroke-width="1" fill="none"/><line x1="-3" y1="-12" x2="3" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-10" y1="14" x2="10" y2="14" stroke="black" stroke-width="1" fill="none"/><line x1="-7" y1="19" x2="7" y2="19" stroke="black" stroke-width="1" fill="none"/><line x1="-4" y1="24" x2="4" y2="24" stroke="black" stroke-width="1" fill="none"/><line x1="-1.5" y1="29" x2="1.5" y2="29" stroke="black" stroke-width="1" fill="none"/>',fc=[{id:"t_top",x:0,y:-30,orientation:"n"}],hc=[{name:"open",type:"boolean",default:!0,label:"断开"}],pc={x:12,y:-8,anchor:"start"},gc={kind:"inline"},O2={id:sc,name:ic,category:ac,description:lc,viewBox:cc,width:dc,height:uc,svg:mc,terminals:fc,state:hc,label:pc,source:gc},B2=Object.freeze(Object.defineProperty({__proto__:null,category:ac,default:O2,description:lc,height:uc,id:sc,label:pc,name:ic,source:gc,state:hc,svg:mc,terminals:fc,viewBox:cc,width:dc},Symbol.toStringTag,{value:"Module"})),yc="energy-meter",xc="电能表 (Wh)",bc="measurement",wc="有功电能表 (kWh) — 服务入口 / 子表。",vc="-22 -36 44 72",kc=44,_c=72,$c='<text x="-10" y="19.2" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Wh</text><rect x="-20" y="-10" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Sc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],jc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},L2={id:yc,name:xc,category:bc,description:wc,viewBox:vc,width:kc,height:_c,svg:$c,terminals:Sc,source:jc},z2=Object.freeze(Object.defineProperty({__proto__:null,category:bc,default:L2,description:wc,height:_c,id:yc,name:xc,source:jc,svg:$c,terminals:Sc,viewBox:vc,width:kc},Symbol.toStringTag,{value:"Module"})),Ec="ev-charger",Nc="EV 充电桩",Mc="load",Tc="电动汽车充电站 / 充电桩。",Ac="-17 -27 34 49",Cc=34,Ic=49,Pc='<line x1="0" y1="-25" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-15" y="-15" width="30" height="35" fill="none" stroke="black" stroke-width="1"/><rect x="-9" y="-8" width="14" height="6" fill="none" stroke="black" stroke-width="0.8"/><rect x="5" y="-7" width="2" height="4" fill="black"/><text x="-9" y="13" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">EV</text>',Oc=[{id:"t_top",x:0,y:-25,orientation:"n"}],Bc={kind:"inline"},R2={id:Ec,name:Nc,category:Mc,description:Tc,viewBox:Ac,width:Cc,height:Ic,svg:Pc,terminals:Oc,source:Bc},D2=Object.freeze(Object.defineProperty({__proto__:null,category:Mc,default:R2,description:Tc,height:Ic,id:Ec,name:Nc,source:Bc,svg:Pc,terminals:Oc,viewBox:Ac,width:Cc},Symbol.toStringTag,{value:"Module"})),Lc="frequency-meter",zc="频率表 (Hz)",Rc="measurement",Dc="-22 -42 44 44",Fc=44,Hc=44,Wc='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Hz</text>',qc=[{id:"t_top",x:0,y:-40,orientation:"n"}],Gc={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},F2={id:Lc,name:zc,category:Rc,viewBox:Dc,width:Fc,height:Hc,svg:Wc,terminals:qc,source:Gc},H2=Object.freeze(Object.defineProperty({__proto__:null,category:Rc,default:F2,height:Hc,id:Lc,name:zc,source:Gc,svg:Wc,terminals:qc,viewBox:Dc,width:Fc},Symbol.toStringTag,{value:"Module"})),Kc="fuse-switch-disconnector",Xc="熔断器式隔离开关",Vc="switching",Yc="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",Uc="-8 -32 12 64",Zc=12,Qc=64,Jc='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',ed=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],td=[{name:"open",type:"boolean",default:!1,label:"断开"}],nd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},W2={id:Kc,name:Xc,category:Vc,description:Yc,viewBox:Uc,width:Zc,height:Qc,svg:Jc,terminals:ed,state:td,source:nd},q2=Object.freeze(Object.defineProperty({__proto__:null,category:Vc,default:W2,description:Yc,height:Qc,id:Kc,name:Xc,source:nd,state:td,svg:Jc,terminals:ed,viewBox:Uc,width:Zc},Symbol.toStringTag,{value:"Module"})),od="fuse",rd="熔断器 (FU)",sd="switching",id="-7 -32 14 64",ad=14,ld=64,cd='<line x1="0" y1="-30" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-15" width="10" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',dd=[{id:"t1",x:0,y:30,orientation:"s"},{id:"t2",x:0,y:-30,orientation:"n"}],ud=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],md={x:7,y:-2,anchor:"start"},fd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},G2={id:od,name:rd,category:sd,viewBox:id,width:ad,height:ld,svg:cd,terminals:dd,state:ud,label:md,source:fd},K2=Object.freeze(Object.defineProperty({__proto__:null,category:sd,default:G2,height:ld,id:od,label:md,name:rd,source:fd,state:ud,svg:cd,terminals:dd,viewBox:id,width:ad},Symbol.toStringTag,{value:"Module"})),hd="generator",pd="发电机 (G)",gd="source",yd="-42 -42 44 44",xd=44,bd=44,wd='<rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-24" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text>',vd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],kd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},X2={id:hd,name:pd,category:gd,viewBox:yd,width:xd,height:bd,svg:wd,terminals:vd,source:kd},V2=Object.freeze(Object.defineProperty({__proto__:null,category:gd,default:X2,height:bd,id:hd,name:pd,source:kd,svg:wd,terminals:vd,viewBox:yd,width:xd},Symbol.toStringTag,{value:"Module"})),_d="genset",$d="发电机组 (G)",Sd="source",jd="柴油 / 燃气发电机组。",Ed="-28 -22 56 64",Nd=56,Md=64,Td='<rect x="-26" y="-20" width="52" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">GEN</text><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Ad=[{id:"t_out",x:0,y:40,orientation:"s"}],Cd=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Id={kind:"inline"},Y2={id:_d,name:$d,category:Sd,description:jd,viewBox:Ed,width:Nd,height:Md,svg:Td,terminals:Ad,params:Cd,source:Id},U2=Object.freeze(Object.defineProperty({__proto__:null,category:Sd,default:Y2,description:jd,height:Md,id:_d,name:$d,params:Cd,source:Id,svg:Td,terminals:Ad,viewBox:Ed,width:Nd},Symbol.toStringTag,{value:"Module"})),Pd="gfci-breaker",Od="GFCI 断路器 (RCBO)",Bd="protection",Ld="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",zd="-18 -22 22 44",Rd=22,Dd=44,Fd='<text x="-14" y="13.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">IΔ</text><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="-5,-10 0,10 0,20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-4" x2="-8" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="-4" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="-4" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><path d="M -8 1 A 2.5 3.5 0 0 0 -13 1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="1" x2="-2" y2="1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="1" x2="-13" y2="1" fill="none" stroke="black" stroke-width="0.4"/>',Hd=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Wd=[{name:"open",type:"boolean",default:!1,label:"断开"}],qd=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Gd={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Z2={id:Pd,name:Od,category:Bd,description:Ld,viewBox:zd,width:Rd,height:Dd,svg:Fd,terminals:Hd,state:Wd,params:qd,source:Gd},Q2=Object.freeze(Object.defineProperty({__proto__:null,category:Bd,default:Z2,description:Ld,height:Dd,id:Pd,name:Od,params:qd,source:Gd,state:Wd,svg:Fd,terminals:Hd,viewBox:zd,width:Rd},Symbol.toStringTag,{value:"Module"})),Kd="grid-source",Xd="系统电源",Vd="source",Yd="无穷大母线 / 外部电网",Ud="-16 -31 32 53",Zd=32,Qd=53,Jd='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',eu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],tu={kind:"inline"},J2={id:Kd,name:Xd,category:Vd,description:Yd,viewBox:Ud,width:Zd,height:Qd,svg:Jd,terminals:eu,source:tu},ek=Object.freeze(Object.defineProperty({__proto__:null,category:Vd,default:J2,description:Yd,height:Qd,id:Kd,name:Xd,source:tu,svg:Jd,terminals:eu,viewBox:Ud,width:Zd},Symbol.toStringTag,{value:"Module"})),nu="grounding-transformer",ou="接地变 (Z形)",ru="grounding",su="星-曲折接线变压器,中性点接地用",iu="-62 -152 64 164",au=64,lu=164,cu='<line x1="-30" y1="-40" x2="-35" y2="-35" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-25" y2="-35" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-35" x2="-40" y2="-38" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-150" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-35" x2="-25" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-30" y2="-45" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-45" x2="-25" y2="-48" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-130" x2="-20" y2="-140" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-135" x2="-20" y2="-145" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="5" x2="-20" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-85" x2="-30" y2="-95" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-20" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-40" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-40" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/>',du=[{id:"t1",x:-30,y:10,orientation:"s"},{id:"t2",x:-30,y:-150,orientation:"n"}],uu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},tk={id:nu,name:ou,category:ru,description:su,viewBox:iu,width:au,height:lu,svg:cu,terminals:du,source:uu},nk=Object.freeze(Object.defineProperty({__proto__:null,category:ru,default:tk,description:su,height:lu,id:nu,name:ou,source:uu,svg:cu,terminals:du,viewBox:iu,width:au},Symbol.toStringTag,{value:"Module"})),mu="heater",fu="电加热器 (EH)",hu="load",pu="电阻加热元件 / 电热负荷。",gu="-22 -7 54 14",yu=54,xu=14,bu='<line x1="-20" y1="0" x2="-10" y2="0" fill="none" stroke="black" stroke-width="1"/><rect x="-10" y="-5" width="30" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="0" x2="30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-5" x2="-5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-5" x2="5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="15" y1="-5" x2="15" y2="5" fill="none" stroke="black" stroke-width="1"/>',wu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],vu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],ku={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},ok={id:mu,name:fu,category:hu,description:pu,viewBox:gu,width:yu,height:xu,svg:bu,terminals:wu,params:vu,source:ku},rk=Object.freeze(Object.defineProperty({__proto__:null,category:hu,default:ok,description:pu,height:xu,id:mu,name:fu,params:vu,source:ku,svg:bu,terminals:wu,viewBox:gu,width:yu},Symbol.toStringTag,{value:"Module"})),_u="igbt",$u="绝缘栅双极晶体管 (IGBT)",Su="passive",ju="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Eu="-32 -32 54 74",Nu=54,Mu=74,Tu='<line x1="0" y1="25" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polyline points="-30,20 -5,20 -5,-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="20" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="20" y2="40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="15" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-25" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-8" x2="0" y2="8" fill="none" stroke="black" stroke-width="1"/><polyline points="10,-24 8,-21 12,-22" fill="none" stroke="black" stroke-width="1"/><polyline points="10,25 11,29 8,27" fill="none" stroke="black" stroke-width="1"/>',Au=[{id:"t1",x:20,y:-30,orientation:"n"},{id:"t2",x:20,y:40,orientation:"s"},{id:"t_g",x:-30,y:20,orientation:"w"}],Cu={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_05/en_60617_05_05_19.elmt",qetEnglishName:"Insulated-gate bipolar transistor (IGBT) enhancement type, N channel"},sk={id:_u,name:$u,category:Su,description:ju,viewBox:Eu,width:Nu,height:Mu,svg:Tu,terminals:Au,source:Cu},ik=Object.freeze(Object.defineProperty({__proto__:null,category:Su,default:sk,description:ju,height:Mu,id:_u,name:$u,source:Cu,svg:Tu,terminals:Au,viewBox:Eu,width:Nu},Symbol.toStringTag,{value:"Module"})),Iu="indicator-light",Pu="指示灯 (HL)",Ou="control",Bu="信号 / 状态指示灯。",Lu="-12 -22 24 24",zu=24,Ru=24,Du='<ellipse cx="0" cy="-10" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-3" x2="7" y2="-17" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-17" x2="7" y2="-3" fill="none" stroke="black" stroke-width="1"/>',Fu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Hu=[{name:"color",label:"颜色",type:"string"}],Wu={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},ak={id:Iu,name:Pu,category:Ou,description:Bu,viewBox:Lu,width:zu,height:Ru,svg:Du,terminals:Fu,params:Hu,source:Wu},lk=Object.freeze(Object.defineProperty({__proto__:null,category:Ou,default:ak,description:Bu,height:Ru,id:Iu,name:Pu,params:Hu,source:Wu,svg:Du,terminals:Fu,viewBox:Lu,width:zu},Symbol.toStringTag,{value:"Module"})),qu="inductor",Gu="电感 (L)",Ku="passive",Xu="通用电感 / 线圈 / 扼流圈。",Vu="-17 -32 34 64",Yu=34,Uu=64,Zu='<line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><path d="M 0 15 A 15 15 0 1 0 -15 0" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',Qu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Ju=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],em={x:6,y:0,anchor:"start"},tm={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},ck={id:qu,name:Gu,category:Ku,description:Xu,viewBox:Vu,width:Yu,height:Uu,svg:Zu,terminals:Qu,params:Ju,label:em,source:tm},dk=Object.freeze(Object.defineProperty({__proto__:null,category:Ku,default:ck,description:Xu,height:Uu,id:qu,label:em,name:Gu,params:Ju,source:tm,svg:Zu,terminals:Qu,viewBox:Vu,width:Yu},Symbol.toStringTag,{value:"Module"})),nm="inverter",om="逆变器 (DC→AC)",rm="renewable",sm="-42 -42 44 44",im=44,am=44,lm='<path d="M -15 -8 A 5 2.5 0 0 0 -25 -8" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><path d="M -15 -8 A 5 2.5 0 0 0 -5 -8" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/>',cm=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],dm={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},uk={id:nm,name:om,category:rm,viewBox:sm,width:im,height:am,svg:lm,terminals:cm,source:dm},mk=Object.freeze(Object.defineProperty({__proto__:null,category:rm,default:uk,height:am,id:nm,name:om,source:dm,svg:lm,terminals:cm,viewBox:sm,width:im},Symbol.toStringTag,{value:"Module"})),um="limit-switch",mm="限位开关 (SQ)",fm="control",hm="行程 / 位置开关 (常开, 机械操作)。",pm="-10 -42 12 64",gm=12,ym=64,xm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-13" x2="-7" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-12" x2="-3" y2="-8" fill="none" stroke="black" stroke-width="1"/>',bm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],wm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],vm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},fk={id:um,name:mm,category:fm,description:hm,viewBox:pm,width:gm,height:ym,svg:xm,terminals:bm,state:wm,source:vm},hk=Object.freeze(Object.defineProperty({__proto__:null,category:fm,default:fk,description:hm,height:ym,id:um,name:mm,source:vm,state:wm,svg:xm,terminals:bm,viewBox:pm,width:gm},Symbol.toStringTag,{value:"Module"})),km="load-switch",_m="负荷开关",$m="switching",Sm="-10 -42 14 64",jm=14,Em=64,Nm='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',Mm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Tm=[{name:"open",type:"boolean",default:!1,label:"断开"}],Am={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},pk={id:km,name:_m,category:$m,viewBox:Sm,width:jm,height:Em,svg:Nm,terminals:Mm,state:Tm,source:Am},gk=Object.freeze(Object.defineProperty({__proto__:null,category:$m,default:pk,height:Em,id:km,name:_m,source:Am,state:Tm,svg:Nm,terminals:Mm,viewBox:Sm,width:jm},Symbol.toStringTag,{value:"Module"})),Cm="load",Im="负荷",Pm="load",Om="抽象负荷(电流流出箭头)",Bm="-8 -22 16 46",Lm=16,zm=46,Rm='<line x1="0" y1="-20" x2="0" y2="10" stroke="black" stroke-width="1" fill="none"/><polygon points="-6,10 6,10 0,22" fill="black" stroke="black" stroke-width="1"/>',Dm=[{id:"t_top",x:0,y:-20,orientation:"n"}],Fm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],Hm={x:6,y:0,anchor:"start"},Wm={kind:"inline"},yk={id:Cm,name:Im,category:Pm,description:Om,viewBox:Bm,width:Lm,height:zm,svg:Rm,terminals:Dm,params:Fm,label:Hm,source:Wm},xk=Object.freeze(Object.defineProperty({__proto__:null,category:Pm,default:yk,description:Om,height:zm,id:Cm,label:Hm,name:Im,params:Fm,source:Wm,svg:Rm,terminals:Dm,viewBox:Bm,width:Lm},Symbol.toStringTag,{value:"Module"})),qm="make-contact",Gm="常开触点 (NO)",Km="control",Xm="常开辅助触点 (make contact)。",Vm="-10 -42 12 64",Ym=12,Um=64,Zm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',Qm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Jm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],ef={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_01.elmt",qetEnglishName:"Make contact, general symbol; Switch, general symbol"},bk={id:qm,name:Gm,category:Km,description:Xm,viewBox:Vm,width:Ym,height:Um,svg:Zm,terminals:Qm,state:Jm,source:ef},wk=Object.freeze(Object.defineProperty({__proto__:null,category:Km,default:bk,description:Xm,height:Um,id:qm,name:Gm,source:ef,state:Jm,svg:Zm,terminals:Qm,viewBox:Vm,width:Ym},Symbol.toStringTag,{value:"Module"})),tf="motor-starter",nf="电机启动器",of="motor-control",rf="电机启动器 (IEC 60617 通用符号)。",sf="-22 -27 44 54",af=44,lf=54,cf='<rect x="-20" y="-20" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,-20 0,-10 20,-20" fill="none" stroke="black" stroke-width="1"/>',df=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],uf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},vk={id:tf,name:nf,category:of,description:rf,viewBox:sf,width:af,height:lf,svg:cf,terminals:df,source:uf},kk=Object.freeze(Object.defineProperty({__proto__:null,category:of,default:vk,description:rf,height:lf,id:tf,name:nf,source:uf,svg:cf,terminals:df,viewBox:sf,width:af},Symbol.toStringTag,{value:"Module"})),mf="ngr",ff="中性点电阻 (NGR)",hf="grounding",pf="小电阻接地:连接变压器中性点到地",gf="-12 -32 24 62",yf=24,xf=62,bf='<line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><rect x="-6" y="-15" width="12" height="22" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="7" x2="0" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="15" x2="10" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="19" x2="7" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="23" x2="4" y2="23" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="27" x2="1.5" y2="27" fill="none" stroke="black" stroke-width="1"/>',wf=[{id:"t_top",x:0,y:-30,orientation:"n"}],vf=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],kf={kind:"inline"},_k={id:mf,name:ff,category:hf,description:pf,viewBox:gf,width:yf,height:xf,svg:bf,terminals:wf,params:vf,source:kf},$k=Object.freeze(Object.defineProperty({__proto__:null,category:hf,default:_k,description:pf,height:xf,id:mf,name:ff,params:vf,source:kf,svg:bf,terminals:wf,viewBox:gf,width:yf},Symbol.toStringTag,{value:"Module"})),_f="overcurrent-relay",$f="过流继电器 (50/51)",Sf="protection",jf="过电流保护继电器 (ANSI 50/51)。",Ef="-62 -62 64 64",Nf=64,Mf=64,Tf='<rect x="-60" y="-60" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-48" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">5...10A</text>',Af=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Cf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Sk={id:_f,name:$f,category:Sf,description:jf,viewBox:Ef,width:Nf,height:Mf,svg:Tf,terminals:Af,source:Cf},jk=Object.freeze(Object.defineProperty({__proto__:null,category:Sf,default:Sk,description:jf,height:Mf,id:_f,name:$f,source:Cf,svg:Tf,terminals:Af,viewBox:Ef,width:Nf},Symbol.toStringTag,{value:"Module"})),If="phase-failure-relay",Pf="断相继电器",Of="protection",Bf="断相 / 缺相保护继电器。",Lf="-62 -42 64 44",zf=64,Rf=44,Df='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">m < 3</text>',Ff=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Hf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Ek={id:If,name:Pf,category:Of,description:Bf,viewBox:Lf,width:zf,height:Rf,svg:Df,terminals:Ff,source:Hf},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:Of,default:Ek,description:Bf,height:Rf,id:If,name:Pf,source:Hf,svg:Df,terminals:Ff,viewBox:Lf,width:zf},Symbol.toStringTag,{value:"Module"})),Wf="plc",qf="PLC / 控制器",Gf="control",Kf="可编程逻辑控制器 (PLC)。",Xf="-24 -42 48 84",Vf=48,Yf=84,Uf='<rect x="-22" y="-22" width="44" height="44" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">PLC</text><line x1="0" y1="-40" x2="0" y2="-22" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="22" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Zf=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],Qf={kind:"inline"},Mk={id:Wf,name:qf,category:Gf,description:Kf,viewBox:Xf,width:Vf,height:Yf,svg:Uf,terminals:Zf,source:Qf},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:Gf,default:Mk,description:Kf,height:Yf,id:Wf,name:qf,source:Qf,svg:Uf,terminals:Zf,viewBox:Xf,width:Vf},Symbol.toStringTag,{value:"Module"})),Jf="power-factor-meter",eh="功率因数表 (cosφ)",th="measurement",nh="功率因数表 (cosφ)。",oh="-22 -42 44 44",rh=44,sh=44,ih='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-14" y="-6.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">cos φ</text>',ah=[{id:"t_top",x:0,y:-40,orientation:"n"}],lh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},Ak={id:Jf,name:eh,category:th,description:nh,viewBox:oh,width:rh,height:sh,svg:ih,terminals:ah,source:lh},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:th,default:Ak,description:nh,height:sh,id:Jf,name:eh,source:lh,svg:ih,terminals:ah,viewBox:oh,width:rh},Symbol.toStringTag,{value:"Module"})),ch="power-supply",dh="开关电源 (PS)",uh="source",mh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",fh="-24 -42 48 84",hh=48,ph=84,gh='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="8" y="15" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">=</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',yh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],xh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],bh={kind:"inline"},Ik={id:ch,name:dh,category:uh,description:mh,viewBox:fh,width:hh,height:ph,svg:gh,terminals:yh,params:xh,source:bh},Pk=Object.freeze(Object.defineProperty({__proto__:null,category:uh,default:Ik,description:mh,height:ph,id:ch,name:dh,params:xh,source:bh,svg:gh,terminals:yh,viewBox:fh,width:hh},Symbol.toStringTag,{value:"Module"})),wh="protective-relay",vh="保护继电器",kh="protection",_h="测量继电器 / 保护继电器通用符号 (IEC 60617)。",$h="-32 -42 64 44",Sh=64,jh=44,Eh='<polygon points="-2,-22 2,-22 0,-25" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-22 -2,-19 -6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="2,-22 2,-19 6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-19 0,-17 -3,-15" fill="black" stroke="black" stroke-width="1"/><polygon points="0,-17 2,-19 4,-15" fill="black" stroke="black" stroke-width="1"/><rect x="-2" y="-22" width="4" height="4" rx="0" ry="0" fill="black" stroke="black" stroke-width="1"/><rect x="-30" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Nh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Mh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_16/en_60617_07_16_01.elmt",qetEnglishName:"Measuring relay; Device related to a measuring relay"},Ok={id:wh,name:vh,category:kh,description:_h,viewBox:$h,width:Sh,height:jh,svg:Eh,terminals:Nh,source:Mh},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:kh,default:Ok,description:_h,height:jh,id:wh,name:vh,source:Mh,svg:Eh,terminals:Nh,viewBox:$h,width:Sh},Symbol.toStringTag,{value:"Module"})),Th="proximity-switch",Ah="接近开关 (SQ)",Ch="control",Ih="接近传感器 / 无触点接近开关。",Ph="-12 -32 24 64",Oh=24,Bh=64,Lh='<line x1="0" y1="-30" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 -10,0 0,10 10,0" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-6" x2="-4" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-6" x2="4" y2="6" fill="none" stroke="black" stroke-width="1"/>',zh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Rh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},Lk={id:Th,name:Ah,category:Ch,description:Ih,viewBox:Ph,width:Oh,height:Bh,svg:Lh,terminals:zh,source:Rh},zk=Object.freeze(Object.defineProperty({__proto__:null,category:Ch,default:Lk,description:Ih,height:Bh,id:Th,name:Ah,source:Rh,svg:Lh,terminals:zh,viewBox:Ph,width:Oh},Symbol.toStringTag,{value:"Module"})),Dh="pt",Fh="电压互感器 (PT)",Hh="instrument-transformer",Wh="-22 -42 44 115",qh=44,Gh=115,Kh='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',Xh=[{id:"t1",x:0,y:71,orientation:"s"},{id:"t2",x:0,y:-40,orientation:"n"}],Vh={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},Rk={id:Dh,name:Fh,category:Hh,viewBox:Wh,width:qh,height:Gh,svg:Kh,terminals:Xh,source:Vh},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:Hh,default:Rk,height:Gh,id:Dh,name:Fh,source:Vh,svg:Kh,terminals:Xh,viewBox:Wh,width:qh},Symbol.toStringTag,{value:"Module"})),Yh="push-button",Uh="按钮 (SB)",Zh="control",Qh="手动按钮, 自动复位 (常开 make)。",Jh="-37 -42 39 64",e0=39,t0=64,n0='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',o0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],r0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_02.elmt",qetEnglishName:"Switch, manually operated, push-button, automatic return"},Fk={id:Yh,name:Uh,category:Zh,description:Qh,viewBox:Jh,width:e0,height:t0,svg:n0,terminals:o0,source:r0},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:Zh,default:Fk,description:Qh,height:t0,id:Yh,name:Uh,source:r0,svg:n0,terminals:o0,viewBox:Jh,width:e0},Symbol.toStringTag,{value:"Module"})),s0="pv",i0="光伏组件",a0="renewable",l0="-33 -22 85 64",c0=85,d0=64,u0='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',m0=[{id:"t_dc",x:50,y:10,orientation:"e"}],f0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},Wk={id:s0,name:i0,category:a0,viewBox:l0,width:c0,height:d0,svg:u0,terminals:m0,source:f0},qk=Object.freeze(Object.defineProperty({__proto__:null,category:a0,default:Wk,height:d0,id:s0,name:i0,source:f0,svg:u0,terminals:m0,viewBox:l0,width:c0},Symbol.toStringTag,{value:"Module"})),h0="rcd",p0="剩余电流装置 (RCD)",g0="protection",y0="不带过流保护的剩余电流断路器 (IEC 61008)。",x0="-12 -22 19 44",b0=19,w0=44,v0='<line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="0,20 0,10 -7,-9" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="13" rx="4.5" ry="2" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,0 -10,0 -10,13 -5,13" fill="none" stroke="black" stroke-width="0.4" stroke-dasharray="4 2"/>',k0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_0=[{name:"open",type:"boolean",default:!1,label:"断开"}],$0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],S0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Gk={id:h0,name:p0,category:g0,description:y0,viewBox:x0,width:b0,height:w0,svg:v0,terminals:k0,state:_0,params:$0,source:S0},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:g0,default:Gk,description:y0,height:w0,id:h0,name:p0,params:$0,source:S0,state:_0,svg:v0,terminals:k0,viewBox:x0,width:b0},Symbol.toStringTag,{value:"Module"})),j0="recloser",E0="重合闸 (Recloser)",N0="protection",M0="中压自动重合闸开关。",T0="-12 -32 36 64",A0=36,C0=64,I0='<line x1="0" y1="-30" x2="0" y2="-10" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-13" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-8" x2="2" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-12" x2="2" y2="-8" stroke="black" stroke-width="1" fill="none"/><path d="M 13 -12 A 7 7 0 1 1 6 -5" fill="none" stroke="black" stroke-width="0.8"/><polygon points="4,-7 6,-5 8,-3" fill="black"/><text x="14" y="6" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">AR</text>',P0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],O0=[{name:"open",type:"boolean",default:!1,label:"断开"}],B0={kind:"inline"},Xk={id:j0,name:E0,category:N0,description:M0,viewBox:T0,width:A0,height:C0,svg:I0,terminals:P0,state:O0,source:B0},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:N0,default:Xk,description:M0,height:C0,id:j0,name:E0,source:B0,state:O0,svg:I0,terminals:P0,viewBox:T0,width:A0},Symbol.toStringTag,{value:"Module"})),L0="rectifier",z0="整流器 (AC→DC)",R0="renewable",D0="-42 -42 44 44",F0=44,H0=44,W0='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/>',q0=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],G0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},Yk={id:L0,name:z0,category:R0,viewBox:D0,width:F0,height:H0,svg:W0,terminals:q0,source:G0},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:R0,default:Yk,height:H0,id:L0,name:z0,source:G0,svg:W0,terminals:q0,viewBox:D0,width:F0},Symbol.toStringTag,{value:"Module"})),K0="relay-coil",X0="继电器线圈 (KA)",V0="control",Y0="继电器 / 接触器操作线圈 (方框)。",U0="-22 -22 44 44",Z0=44,Q0=44,J0='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/>',ep=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],tp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_01.elmt",qetEnglishName:"Operating device, general symbol; Relay coil, general symbol"},Zk={id:K0,name:X0,category:V0,description:Y0,viewBox:U0,width:Z0,height:Q0,svg:J0,terminals:ep,source:tp},Qk=Object.freeze(Object.defineProperty({__proto__:null,category:V0,default:Zk,description:Y0,height:Q0,id:K0,name:X0,source:tp,svg:J0,terminals:ep,viewBox:U0,width:Z0},Symbol.toStringTag,{value:"Module"})),np="resistor",op="电阻 (R)",rp="passive",sp="通用电阻 / 限流 / 制动电阻。",ip="-6 -23 12 35",ap=12,lp=35,cp='<line x1="0" y1="-10" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="10" x2="4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-10" x2="-4" y2="10" fill="none" stroke="black" stroke-width="1"/>',dp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],up=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],mp={x:6,y:0,anchor:"start"},fp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},Jk={id:np,name:op,category:rp,description:sp,viewBox:ip,width:ap,height:lp,svg:cp,terminals:dp,params:up,label:mp,source:fp},e_=Object.freeze(Object.defineProperty({__proto__:null,category:rp,default:Jk,description:sp,height:lp,id:np,label:mp,name:op,params:up,source:fp,svg:cp,terminals:dp,viewBox:ip,width:ap},Symbol.toStringTag,{value:"Module"})),hp="reverse-power-relay",pp="逆功率继电器 (32)",gp="protection",yp="逆功率 / 逆流保护继电器 (ANSI 32)。",xp="-62 -42 64 44",bp=64,wp=44,vp='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">I</text><polygon points="-15,-20 -30,-20 -24,-22 -24,-18 -30,-20 -24,-20" fill="black" stroke="black" stroke-width="1"/>',kp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],_p={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},t_={id:hp,name:pp,category:gp,description:yp,viewBox:xp,width:bp,height:wp,svg:vp,terminals:kp,source:_p},n_=Object.freeze(Object.defineProperty({__proto__:null,category:gp,default:t_,description:yp,height:wp,id:hp,name:pp,source:_p,svg:vp,terminals:kp,viewBox:xp,width:bp},Symbol.toStringTag,{value:"Module"})),$p="selector-switch",Sp="选择开关 (SA)",jp="switching",Ep="转换 / 选择开关 (旋转操作, 保位)。",Np="-34 -42 36 64",Mp=36,Tp=64,Ap='<line x1="-32" y1="-10" x2="-2" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-32" y1="-15" x2="-32" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',Cp=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ip=[{name:"open",type:"boolean",default:!1,label:"断开"}],Pp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_04.elmt",qetEnglishName:"Switch, manually operated, turning, stay-put"},o_={id:$p,name:Sp,category:jp,description:Ep,viewBox:Np,width:Mp,height:Tp,svg:Ap,terminals:Cp,state:Ip,source:Pp},r_=Object.freeze(Object.defineProperty({__proto__:null,category:jp,default:o_,description:Ep,height:Tp,id:$p,name:Sp,source:Pp,state:Ip,svg:Ap,terminals:Cp,viewBox:Np,width:Mp},Symbol.toStringTag,{value:"Module"})),Op="series-reactor",Bp="串联电抗器",Lp="compensation",zp="与并联电抗器同符号;通过用法区分。",Rp="-62 -82 64 104",Dp=64,Fp=104,Hp='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',Wp=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],qp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},s_={id:Op,name:Bp,category:Lp,description:zp,viewBox:Rp,width:Dp,height:Fp,svg:Hp,terminals:Wp,source:qp},i_=Object.freeze(Object.defineProperty({__proto__:null,category:Lp,default:s_,description:zp,height:Fp,id:Op,name:Bp,source:qp,svg:Hp,terminals:Wp,viewBox:Rp,width:Dp},Symbol.toStringTag,{value:"Module"})),Gp="shunt-capacitor",Kp="并联电容器",Xp="compensation",Vp="-7 -23 14 27",Yp=14,Up=27,Zp='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',Qp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Jp=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],eg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},a_={id:Gp,name:Kp,category:Xp,viewBox:Vp,width:Yp,height:Up,svg:Zp,terminals:Qp,params:Jp,source:eg},l_=Object.freeze(Object.defineProperty({__proto__:null,category:Xp,default:a_,height:Up,id:Gp,name:Kp,params:Jp,source:eg,svg:Zp,terminals:Qp,viewBox:Vp,width:Yp},Symbol.toStringTag,{value:"Module"})),tg="shunt-reactor",ng="并联电抗器",og="compensation",rg="-62 -82 64 104",sg=64,ig=104,ag='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',lg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],cg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},c_={id:tg,name:ng,category:og,viewBox:rg,width:sg,height:ig,svg:ag,terminals:lg,source:cg},d_=Object.freeze(Object.defineProperty({__proto__:null,category:og,default:c_,height:ig,id:tg,name:ng,source:cg,svg:ag,terminals:lg,viewBox:rg,width:sg},Symbol.toStringTag,{value:"Module"})),dg="siren",ug="警笛 (HA)",mg="control",fg="声响警笛 / 报警器。",hg="-32 -42 44 54",pg=44,gg=54,yg='<line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="10,-10 -30,-10 -10,-40" fill="none" stroke="black" stroke-width="1"/>',xg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],bg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},u_={id:dg,name:ug,category:mg,description:fg,viewBox:hg,width:pg,height:gg,svg:yg,terminals:xg,source:bg},m_=Object.freeze(Object.defineProperty({__proto__:null,category:mg,default:u_,description:fg,height:gg,id:dg,name:ug,source:bg,svg:yg,terminals:xg,viewBox:hg,width:pg},Symbol.toStringTag,{value:"Module"})),wg="socket-outlet",vg="插座 / 连接器",kg="load",_g="电源插座 / 多极连接器。",$g="-7 -2 13 34",Sg=13,jg=34,Eg='<line x1="-5" y1="13" x2="4" y2="20" fill="none" stroke="black" stroke-width="0.4"/><line x1="-1" y1="12" x2="-1" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="9" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="12" x2="1" y2="19" fill="none" stroke="black" stroke-width="1"/><path d="M 3 13 A 3 3 0 0 0 -3 13" fill="none" stroke="black" stroke-width="1"/>',Ng=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Mg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
192
|
+
unifilar`},f_={id:wg,name:vg,category:kg,description:_g,viewBox:$g,width:Sg,height:jg,svg:Eg,terminals:Ng,source:Mg},h_=Object.freeze(Object.defineProperty({__proto__:null,category:kg,default:f_,description:_g,height:jg,id:wg,name:vg,source:Mg,svg:Eg,terminals:Ng,viewBox:$g,width:Sg},Symbol.toStringTag,{value:"Module"})),Tg="soft-starter",Ag="软启动器",Cg="motor-control",Ig="电机软启动器 (晶闸管降压启动)。",Pg="-22 -42 44 84",Og=44,Bg=84,Lg='<rect x="-20" y="-20" width="40" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-12" y1="-12" x2="12" y2="12" stroke="black" stroke-width="1" fill="none"/><polygon points="4,8 12,12 8,4" fill="none" stroke="black" stroke-width="1"/><text x="-12" y="-2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">SS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',zg=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Rg={kind:"inline"},p_={id:Tg,name:Ag,category:Cg,description:Ig,viewBox:Pg,width:Og,height:Bg,svg:Lg,terminals:zg,source:Rg},g_=Object.freeze(Object.defineProperty({__proto__:null,category:Cg,default:p_,description:Ig,height:Bg,id:Tg,name:Ag,source:Rg,svg:Lg,terminals:zg,viewBox:Pg,width:Og},Symbol.toStringTag,{value:"Module"})),Dg="sync-motor",Fg="同步电动机",Hg="load",Wg="-62 -82 64 114",qg=64,Gg=114,Kg='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',Xg=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],Vg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},y_={id:Dg,name:Fg,category:Hg,viewBox:Wg,width:qg,height:Gg,svg:Kg,terminals:Xg,source:Vg},x_=Object.freeze(Object.defineProperty({__proto__:null,category:Hg,default:y_,height:Gg,id:Dg,name:Fg,source:Vg,svg:Kg,terminals:Xg,viewBox:Wg,width:qg},Symbol.toStringTag,{value:"Module"})),Yg="synchronoscope",Ug="同步表",Zg="measurement",Qg="同步指示器 / 同步表。",Jg="-22 -42 44 44",e1=44,t1=44,n1='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',o1=[{id:"t_top",x:0,y:-40,orientation:"n"}],r1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},b_={id:Yg,name:Ug,category:Zg,description:Qg,viewBox:Jg,width:e1,height:t1,svg:n1,terminals:o1,source:r1},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Zg,default:b_,description:Qg,height:t1,id:Yg,name:Ug,source:r1,svg:n1,terminals:o1,viewBox:Jg,width:e1},Symbol.toStringTag,{value:"Module"})),s1="terminal",i1="接线端子 / 节点 (X)",a1="busbar",l1="接线端子 / 接线盒 / 汇接节点。",c1="-5 -5 10 10",d1=10,u1=10,m1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',f1=[{id:"t_top",x:0,y:-2.5,orientation:"n"},{id:"t_bottom",x:0,y:2.5,orientation:"s"},{id:"t_left",x:-2.5,y:0,orientation:"w"},{id:"t_right",x:2.5,y:0,orientation:"e"}],h1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},v_={id:s1,name:i1,category:a1,description:l1,viewBox:c1,width:d1,height:u1,svg:m1,terminals:f1,source:h1},k_=Object.freeze(Object.defineProperty({__proto__:null,category:a1,default:v_,description:l1,height:u1,id:s1,name:i1,source:h1,svg:m1,terminals:f1,viewBox:c1,width:d1},Symbol.toStringTag,{value:"Module"})),p1="thermal-overload",g1="热过载继电器",y1="motor-control",x1="电机热过载保护继电器, 通常串接在接触器和电机之间。",b1="-9 -32 19 64",w1=19,v1=64,k1='<line x1="0" y1="-30" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-7" y="-15" width="14" height="30" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,-10 -1,-5 -4,0 -1,5 -4,10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',_1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],$1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],S1={kind:"inline"},__={id:p1,name:g1,category:y1,description:x1,viewBox:b1,width:w1,height:v1,svg:k1,terminals:_1,state:$1,source:S1},$_=Object.freeze(Object.defineProperty({__proto__:null,category:y1,default:__,description:x1,height:v1,id:p1,name:g1,source:S1,state:$1,svg:k1,terminals:_1,viewBox:b1,width:w1},Symbol.toStringTag,{value:"Module"})),j1="thermocouple",E1="热电偶 (BT)",N1="measurement",M1="热电偶温度传感器。",T1="-26 -42 52 46",A1=52,C1=46,I1='<ellipse cx="0" cy="0" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/><polyline points="-10,-40 -10,-15 0,0 10,-15 10,-40" fill="none" stroke="black" stroke-width="1"/><line x1="-24" y1="-16" x2="-16" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="16" y1="-16" x2="24" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-20" x2="20" y2="-12" fill="none" stroke="black" stroke-width="1"/>',P1=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],O1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},S_={id:j1,name:E1,category:N1,description:M1,viewBox:T1,width:A1,height:C1,svg:I1,terminals:P1,source:O1},j_=Object.freeze(Object.defineProperty({__proto__:null,category:N1,default:S_,description:M1,height:C1,id:j1,name:E1,source:O1,svg:I1,terminals:P1,viewBox:T1,width:A1},Symbol.toStringTag,{value:"Module"})),B1="thyristor",L1="晶闸管 (V)",z1="passive",R1="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",D1="-22 -42 34 44",F1=34,H1=44,W1='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-20" x2="-10" y2="-20" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,0 -7,0 -4,-10" fill="none" stroke="black" stroke-width="1"/>',q1=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],G1={x:6,y:-20,anchor:"start"},K1={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},E_={id:B1,name:L1,category:z1,description:R1,viewBox:D1,width:F1,height:H1,svg:W1,terminals:q1,label:G1,source:K1},N_=Object.freeze(Object.defineProperty({__proto__:null,category:z1,default:E_,description:R1,height:H1,id:B1,label:G1,name:L1,source:K1,svg:W1,terminals:q1,viewBox:D1,width:F1},Symbol.toStringTag,{value:"Module"})),X1="time-relay",V1="时间继电器 (KT)",Y1="control",U1="延时 (缓动) 继电器线圈。",Z1="-32 -22 54 44",Q1=54,J1=44,ey='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><rect x="-30" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="10" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/>',ty=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ny={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},M_={id:X1,name:V1,category:Y1,description:U1,viewBox:Z1,width:Q1,height:J1,svg:ey,terminals:ty,source:ny},T_=Object.freeze(Object.defineProperty({__proto__:null,category:Y1,default:M_,description:U1,height:J1,id:X1,name:V1,source:ny,svg:ey,terminals:ty,viewBox:Z1,width:Q1},Symbol.toStringTag,{value:"Module"})),oy="transfer-switch",ry="切换开关 (ATS)",sy="switching",iy="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",ay="-27 -32 51 64",ly=51,cy=64,dy='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',uy=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],my=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],fy={kind:"inline"},A_={id:oy,name:ry,category:sy,description:iy,viewBox:ay,width:ly,height:cy,svg:dy,terminals:uy,state:my,source:fy},C_=Object.freeze(Object.defineProperty({__proto__:null,category:sy,default:A_,description:iy,height:cy,id:oy,name:ry,source:fy,state:my,svg:dy,terminals:uy,viewBox:ay,width:ly},Symbol.toStringTag,{value:"Module"})),hy="transformer-2w",py="双绕组变压器",gy="transformer",yy="-62 -142 64 144",xy=64,by=144,wy='<ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-140" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/>',vy=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-140,orientation:"n"}],ky=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],_y={x:4,y:-68,anchor:"start"},$y={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_01.elmt",qetEnglishName:"Transformer with two windings, general symbol"},I_={id:hy,name:py,category:gy,viewBox:yy,width:xy,height:by,svg:wy,terminals:vy,params:ky,label:_y,source:$y},P_=Object.freeze(Object.defineProperty({__proto__:null,category:gy,default:I_,height:by,id:hy,label:_y,name:py,params:ky,source:$y,svg:wy,terminals:vy,viewBox:yy,width:xy},Symbol.toStringTag,{value:"Module"})),Sy="transformer-3w",jy="三绕组变压器",Ey="transformer",Ny="-82 -131 114 133",My=114,Ty=133,Ay='<ellipse cx="-30" cy="-80" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-31" y1="-129" x2="-31" y2="-109" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-50" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-20" x2="-50" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',Cy=[{id:"t1",x:-31,y:-129,orientation:"n"},{id:"t_low_left",x:-50,y:0,orientation:"s"},{id:"t_low_right",x:0,y:0,orientation:"s"}],Iy={x:4,y:-64,anchor:"start"},Py={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},O_={id:Sy,name:jy,category:Ey,viewBox:Ny,width:My,height:Ty,svg:Ay,terminals:Cy,label:Iy,source:Py},B_=Object.freeze(Object.defineProperty({__proto__:null,category:Ey,default:O_,height:Ty,id:Sy,label:Iy,name:jy,source:Py,svg:Ay,terminals:Cy,viewBox:Ny,width:My},Symbol.toStringTag,{value:"Module"})),Oy="triac",By="双向晶闸管 (V)",Ly="passive",zy="双向三极晶闸管 (TRIAC)。",Ry="-22 -42 44 44",Dy=44,Fy=44,Hy='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,-30 0,-30 -10,-10" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-30" x2="-10" y2="-30" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 10,-30 20,-10" fill="none" stroke="black" stroke-width="1"/><polyline points="20,0 18,0 14,-10" fill="none" stroke="black" stroke-width="1"/>',Wy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],qy={x:6,y:-20,anchor:"start"},Gy={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},L_={id:Oy,name:By,category:Ly,description:zy,viewBox:Ry,width:Dy,height:Fy,svg:Hy,terminals:Wy,label:qy,source:Gy},z_=Object.freeze(Object.defineProperty({__proto__:null,category:Ly,default:L_,description:zy,height:Fy,id:Oy,label:qy,name:By,source:Gy,svg:Hy,terminals:Wy,viewBox:Ry,width:Dy},Symbol.toStringTag,{value:"Module"})),Ky="undervoltage-relay",Xy="欠压继电器 (27)",Vy="protection",Yy="欠电压保护继电器 (ANSI 27)。",Uy="-62 -82 64 84",Zy=64,Qy=84,Jy='<rect x="-60" y="-80" width="60" height="80" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-49" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">130 %</text><text x="-55" y="-32.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">50...80 V</text><text x="-41" y="-53.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">U <</text>',ex=[{id:"t_top",x:-30,y:-80,orientation:"n"}],tx={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},R_={id:Ky,name:Xy,category:Vy,description:Yy,viewBox:Uy,width:Zy,height:Qy,svg:Jy,terminals:ex,source:tx},D_=Object.freeze(Object.defineProperty({__proto__:null,category:Vy,default:R_,description:Yy,height:Qy,id:Ky,name:Xy,source:tx,svg:Jy,terminals:ex,viewBox:Uy,width:Zy},Symbol.toStringTag,{value:"Module"})),nx="ups",ox="不间断电源 (UPS)",rx="source",sx="在线 / 后备式不间断电源。",ix="-26 -42 52 84",ax=52,lx=84,cx='<rect x="-24" y="-20" width="48" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">UPS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',dx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],ux=[{name:"S",label:"容量",type:"number",unit:"kVA"}],mx={kind:"inline"},F_={id:nx,name:ox,category:rx,description:sx,viewBox:ix,width:ax,height:lx,svg:cx,terminals:dx,params:ux,source:mx},H_=Object.freeze(Object.defineProperty({__proto__:null,category:rx,default:F_,description:sx,height:lx,id:nx,name:ox,params:ux,source:mx,svg:cx,terminals:dx,viewBox:ix,width:ax},Symbol.toStringTag,{value:"Module"})),fx="varmeter",hx="无功功率表 (var)",px="measurement",gx="无功功率表 (var)。",yx="-22 -42 44 44",xx=44,bx=44,wx='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">var</text>',vx=[{id:"t_top",x:0,y:-40,orientation:"n"}],kx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},W_={id:fx,name:hx,category:px,description:gx,viewBox:yx,width:xx,height:bx,svg:wx,terminals:vx,source:kx},q_=Object.freeze(Object.defineProperty({__proto__:null,category:px,default:W_,description:gx,height:bx,id:fx,name:hx,source:kx,svg:wx,terminals:vx,viewBox:yx,width:xx},Symbol.toStringTag,{value:"Module"})),_x="vfd",$x="变频器 (VFD)",Sx="motor-control",jx="Variable Frequency Drive — 异步电动机调速。",Ex="-24 -42 48 84",Nx=48,Mx=84,Tx='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="6" y="14" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~f</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Ax=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Cx={kind:"inline"},G_={id:_x,name:$x,category:Sx,description:jx,viewBox:Ex,width:Nx,height:Mx,svg:Tx,terminals:Ax,source:Cx},K_=Object.freeze(Object.defineProperty({__proto__:null,category:Sx,default:G_,description:jx,height:Mx,id:_x,name:$x,source:Cx,svg:Tx,terminals:Ax,viewBox:Ex,width:Nx},Symbol.toStringTag,{value:"Module"})),Ix="voltage-regulator",Px="调压器 (T)",Ox="transformer",Bx="可调感应调压器 / 自耦调压器。",Lx="-17 -32 38 64",zx=38,Rx=64,Dx='<line x1="-5" y1="21" x2="5" y2="17" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-16.05" x2="4.95" y2="-20.05" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-5" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="0" rx="15" ry="15" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-20.05" x2="4.95" y2="-24.05" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="23" x2="5" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-18.05" x2="4.95" y2="-22.05" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="25" x2="5" y2="21" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="15" x2="15" y2="-15" fill="none" stroke="black" stroke-width="1"/><polygon points="13,-16 16,-13 19,-19" fill="black" stroke="black" stroke-width="0.4"/>',Fx=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Hx=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],Wx={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},X_={id:Ix,name:Px,category:Ox,description:Bx,viewBox:Lx,width:zx,height:Rx,svg:Dx,terminals:Fx,params:Hx,source:Wx},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Ox,default:X_,description:Bx,height:Rx,id:Ix,name:Px,params:Hx,source:Wx,svg:Dx,terminals:Fx,viewBox:Lx,width:zx},Symbol.toStringTag,{value:"Module"})),qx="voltmeter",Gx="电压表 (V)",Kx="measurement",Xx="-22 -42 44 44",Vx=44,Yx=44,Ux='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-4" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">V</text>',Zx=[{id:"t_top",x:0,y:-40,orientation:"n"}],Qx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},Y_={id:qx,name:Gx,category:Kx,viewBox:Xx,width:Vx,height:Yx,svg:Ux,terminals:Zx,source:Qx},U_=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:Y_,height:Yx,id:qx,name:Gx,source:Qx,svg:Ux,terminals:Zx,viewBox:Xx,width:Vx},Symbol.toStringTag,{value:"Module"})),Jx="wattmeter",eb="功率表 (W)",tb="measurement",nb="-22 -42 44 44",ob=44,rb=44,sb='<rect x="-20" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-6" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">W</text>',ib=[{id:"t_top",x:0,y:-40,orientation:"n"}],ab={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},Z_={id:Jx,name:eb,category:tb,viewBox:nb,width:ob,height:rb,svg:sb,terminals:ib,source:ab},Q_=Object.freeze(Object.defineProperty({__proto__:null,category:tb,default:Z_,height:rb,id:Jx,name:eb,source:ab,svg:sb,terminals:ib,viewBox:nb,width:ob},Symbol.toStringTag,{value:"Module"})),lb="wind-turbine",cb="风力发电机",db="renewable",ub="风机:发电机 + 三叶轮标记",mb="-22 -46 44 68",fb=44,hb=68,pb='<circle cx="0" cy="0" r="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="16">G</text><line x1="0" y1="-20" x2="0" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-32" x2="-10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="0" y2="-44" fill="none" stroke="black" stroke-width="1.5"/>',gb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],yb={kind:"inline"},J_={id:lb,name:cb,category:db,description:ub,viewBox:mb,width:fb,height:hb,svg:pb,terminals:gb,source:yb},e$=Object.freeze(Object.defineProperty({__proto__:null,category:db,default:J_,description:ub,height:hb,id:lb,name:cb,source:yb,svg:pb,terminals:gb,viewBox:mb,width:fb},Symbol.toStringTag,{value:"Module"})),xb="zener-diode",bb="稳压二极管 (D)",wb="passive",vb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",kb="-12 -42 24 44",_b=24,$b=44,Sb='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-15" x2="-10" y2="-10" fill="none" stroke="black" stroke-width="1"/>',jb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Eb={x:6,y:-20,anchor:"start"},Nb={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},t$={id:xb,name:bb,category:wb,description:vb,viewBox:kb,width:_b,height:$b,svg:Sb,terminals:jb,label:Eb,source:Nb},n$=Object.freeze(Object.defineProperty({__proto__:null,category:wb,default:t$,description:vb,height:$b,id:xb,label:Eb,name:bb,source:Nb,svg:Sb,terminals:jb,viewBox:kb,width:_b},Symbol.toStringTag,{value:"Module"})),o$=Object.assign({"./ammeter.json":qv,"./arc-suppression-coil.json":Kv,"./arrester.json":Vv,"./async-motor.json":Uv,"./autotransformer.json":Qv,"./battery.json":e2,"./bell.json":n2,"./break-contact.json":r2,"./breaker.json":i2,"./buchholz-relay.json":l2,"./busbar.json":d2,"./buzzer.json":m2,"./capacitor.json":h2,"./contactor.json":g2,"./converter-bidir.json":x2,"./ct.json":w2,"./dc-combiner.json":k2,"./dc-disconnector.json":$2,"./dc-motor.json":j2,"./diode.json":N2,"./disconnector.json":T2,"./distance-relay.json":C2,"./earth.json":P2,"./earthing-switch.json":B2,"./energy-meter.json":z2,"./ev-charger.json":D2,"./frequency-meter.json":H2,"./fuse-switch-disconnector.json":q2,"./fuse.json":K2,"./generator.json":V2,"./genset.json":U2,"./gfci-breaker.json":Q2,"./grid-source.json":ek,"./grounding-transformer.json":nk,"./heater.json":rk,"./igbt.json":ik,"./indicator-light.json":lk,"./inductor.json":dk,"./inverter.json":mk,"./limit-switch.json":hk,"./load-switch.json":gk,"./load.json":xk,"./make-contact.json":wk,"./motor-starter.json":kk,"./ngr.json":$k,"./overcurrent-relay.json":jk,"./phase-failure-relay.json":Nk,"./plc.json":Tk,"./power-factor-meter.json":Ck,"./power-supply.json":Pk,"./protective-relay.json":Bk,"./proximity-switch.json":zk,"./pt.json":Dk,"./push-button.json":Hk,"./pv.json":qk,"./rcd.json":Kk,"./recloser.json":Vk,"./rectifier.json":Uk,"./relay-coil.json":Qk,"./resistor.json":e_,"./reverse-power-relay.json":n_,"./selector-switch.json":r_,"./series-reactor.json":i_,"./shunt-capacitor.json":l_,"./shunt-reactor.json":d_,"./siren.json":m_,"./socket-outlet.json":h_,"./soft-starter.json":g_,"./sync-motor.json":x_,"./synchronoscope.json":w_,"./terminal.json":k_,"./thermal-overload.json":$_,"./thermocouple.json":j_,"./thyristor.json":N_,"./time-relay.json":T_,"./transfer-switch.json":C_,"./transformer-2w.json":P_,"./transformer-3w.json":B_,"./triac.json":z_,"./undervoltage-relay.json":D_,"./ups.json":H_,"./varmeter.json":q_,"./vfd.json":K_,"./voltage-regulator.json":V_,"./voltmeter.json":U_,"./wattmeter.json":Q_,"./wind-turbine.json":e$,"./zener-diode.json":n$}),Mb=Object.values(o$).map(e=>e.default),Xe=Object.fromEntries(Mb.map(e=>[e.id,e])),No=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],r$=(()=>{var t;const e={};for(const n of Mb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),_n=new Map(Object.entries(Xe));function Tb(e){return Xe[e]}function s$(e){const n=[...e].sort().join("|");let o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const i$=320;function qe(e){var m,h,g,f;const t=Lr(),n=new Map;e.elements.forEach((p,b)=>{if(n.has(p.id)){t.diagnostics.push({code:"E001",severity:"error",message:ke("compile.duplicateId",{id:p.id}),pointer:`/elements/${b}`});return}n.set(p.id,p);const k=_n.get(p.kind);k||t.diagnostics.push({code:"E003",severity:"error",message:`${ke("compile.unknownKind",{kind:p.kind})} (id=${p.id})`,pointer:`/elements/${b}`}),t.elements.set(p.id,{element:p,libraryDef:k})});const o=new Map,r=new Map;(e.buses??[]).forEach((p,b)=>{if(n.has(p.id)||o.has(p.id)){t.diagnostics.push({code:"E001",severity:"error",message:ke("compile.duplicateId",{id:p.id}),pointer:`/buses/${b}`});return}if(o.set(p.id,p),p.layout){const k=p.layout.rot??0;r.set(p.id,{at:p.layout.at,span:p.layout.span,rot:k,axis:vn(k)})}});const s=p=>!p.includes(".")&&o.has(p),i=(p,b)=>{if(s(p))return!0;const k=p.indexOf(".");if(k<=0)return t.diagnostics.push({code:"E003",severity:"error",message:ke("compile.invalidTermRef",{ref:p}),pointer:b}),!1;const v=p.slice(0,k),N=p.slice(k+1),A=t.elements.get(v);if(!A)return t.diagnostics.push({code:"E002",severity:"error",message:ke("compile.elementMissing",{id:v}),pointer:b}),!1;if(!A.libraryDef)return!1;if(!A.libraryDef.terminals.find(R=>R.id===N)){const R=A.libraryDef.terminals.map(F=>F.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:ke("compile.missingPin",{id:v,kind:A.element.kind,pin:N,available:R}),pointer:b}),!1}return!0},a=[];(e.wires??[]).forEach((p,b)=>{const k=`/wires/${b}`,v=i(p.ends[0],k),N=i(p.ends[1],k);v&&N&&a.push(p)});const l=new Map;if(e.layout)for(const[p,b]of Object.entries(e.layout))t.elements.has(p)?l.set(p,zr(b)):t.diagnostics.push({code:"E004",severity:"error",message:ke("compile.layoutMissingElement",{id:p}),pointer:`/layout/${p}`});const d=Fv({elements:e.elements,buses:e.buses??[],wires:a,library:_n,userLayout:l,userBusLayout:r});t.layout=d.devices;for(const[p,b]of d.buses){const k=o.get(p);k&&t.buses.set(p,{bus:k,geometry:b})}for(const[p,b]of o)t.buses.has(p)||t.buses.set(p,{bus:b,geometry:{at:((m=b.layout)==null?void 0:m.at)??[0,0],span:((h=b.layout)==null?void 0:h.span)??i$,rot:((g=b.layout)==null?void 0:g.rot)??0,axis:vn(((f=b.layout)==null?void 0:f.rot)??0)}});for(const p of t.elements.values()){if(!p.libraryDef)continue;const b=t.layout.get(p.element.id);if(!b)continue;const k=[];for(const v of p.libraryDef.terminals){const N=`${p.element.id}.${v.id}`,A=Ae([v.x,v.y],b),R=wt(v.orientation,b);t.terminals.set(N,{ref:N,elementId:p.element.id,pin:v.id,world:A,orientation:R}),k.push(N)}t.elementToTerminals.set(p.element.id,k)}const u=new Rr;for(const p of a)u.add(p.ends[0]),u.add(p.ends[1]),u.union(p.ends[0],p.ends[1]);for(const[,p]of u.groups()){const b=s$(p);t.nodes.set(b,{id:b,terminals:p});for(const k of p)t.terminalToNode.set(k,b)}for(const p of t.elements.values()){const b=t.elementToTerminals.get(p.element.id)??[];if(b.length===0)continue;b.some(v=>t.terminalToNode.has(v))||t.diagnostics.push({code:"W001",severity:"warning",message:ke("compile.elementUnconnected",{id:p.element.id})})}for(const p of t.buses.keys())t.terminalToNode.has(p)||t.diagnostics.push({code:"W001",severity:"warning",message:ke("compile.elementUnconnected",{id:p})});for(const p of a){if(p.path&&p.path.length>=2){const k=p.path,v=k.length>=2?k[1]:null,N=k.length>=2?k[k.length-2]:null,A=jo(p.ends[0],v,t),R=jo(p.ends[1],N,t);if(A&&R){const F=[[A[0],A[1]],...k.slice(1,-1).map(ee=>[ee[0],ee[1]]),[R[0],R[1]]],te=Br(F);if(te.length>=2){t.wireRenders.set(p.id,{wireId:p.id,path:te,userEdited:!0});continue}}}const b=Hv(p,t);b&&t.wireRenders.set(p.id,b)}return t}const a$={earth:"GND",breaker:"QF",disconnector:"QS","earthing-switch":"QE","load-switch":"QL",fuse:"FU","transformer-2w":"T","transformer-3w":"T",autotransformer:"AT",ct:"CT",pt:"PT",generator:"G","sync-motor":"M","async-motor":"M","grid-source":"L",load:"L",battery:"BAT","shunt-reactor":"LR","series-reactor":"LR","shunt-capacitor":"C",arrester:"FBL","grounding-transformer":"TG",ngr:"NGR","arc-suppression-coil":"ASC",pv:"PV","wind-turbine":"WT",rectifier:"RT",inverter:"INV","converter-bidir":"PCS"},Mo="B";function Ab(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id)])}function _t(e,t){const n=a$[t]??t,o=Ab(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function $n(e){const t=Ab(e);let n=1;for(;t.has(`${Mo}${n}`);)n++;return`${Mo}${n}`}function l$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function $t(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}const To={version:"1",elements:[]},c$=100,Ao=20;function d$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=qt()(Pv((e,t)=>({diagram:To,internal:qe(To),fileSession:null,activeTool:d$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:qe(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:qe(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=c$?r.slice(1):r;e({diagram:s,internal:qe(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:qe(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,placeFromTerminal:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:qe(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,placeFromTerminal:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:u$(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var m;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(h=>s.has(h.id)).map(h=>structuredClone(h)),a=(o.buses??[]).filter(h=>s.has(h.id)).map(h=>structuredClone(h)),l={};for(const h of n)if(s.has(h)&&!r.buses.has(h)){const g=(m=o.layout)==null?void 0:m[h];if(g){l[h]=structuredClone(g);continue}const f=r.layout.get(h);f&&(l[h]=At(f))}const d={};for(const h of n){const g=r.buses.get(h);g&&(d[h]=Je(g.geometry))}const u=(o.wires??[]).filter(h=>h.ends.every(g=>s.has(ln(g)))).map(h=>structuredClone(h));e({clipboard:{elements:i,buses:a,placements:l,busLayouts:d,wires:u},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0)return;const s=o+1,i=Ao*s,a=Ao*s,l=new Map;let d=r;for(const m of n.elements){const h=_t(d,m.kind);l.set(m.id,h),d={...d,elements:[...d.elements,{id:h,kind:m.kind}]}}for(const m of n.buses){const h=$n(d);l.set(m.id,h),d={...d,buses:[...d.buses??[],{id:h}]}}const u=m=>{const h=m.indexOf("."),g=h<0?m:m.slice(0,h),f=l.get(g);return f?h<0?f:`${f}${m.slice(h)}`:m};t().dispatch(m=>{const h=n.elements.map(k=>{const v=structuredClone(k);return v.id=l.get(k.id),v}),g=n.buses.map(k=>{const v=structuredClone(k);v.id=l.get(k.id);const N=n.busLayouts[k.id];return N&&(v.layout={...N,at:[N.at[0]+i,N.at[1]+a]}),v}),f={...m.layout??{}};for(const[k,v]of l){const N=n.placements[k];N&&(f[v]={...N,at:[N.at[0]+i,N.at[1]+a]})}const p=n.wires.map(k=>{const v=[u(k.ends[0]),u(k.ends[1])];return{id:$t(v[0],v[1]),ends:v}}),b=m$(m.wires??[],p);return{...m,elements:[...m.elements,...h],buses:g.length?[...m.buses??[],...g]:m.buses,wires:b.length?b:void 0,layout:Object.keys(f).length?f:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(d=>d.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(d=>{const{layout:u,...m}=d;return m});return{...i,buses:a}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const l={};for(const[d,u]of Object.entries(i)){if(o.has(d)){s=!0;continue}l[d]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(d=>{if(o.has(d.id)&&d.layout){s=!0;const{layout:u,...m}=d;return m}return d});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const d=n.layout.get(l.id);d&&(s[l.id]=At(d))}const i=[];if((o.buses??[]).forEach((l,d)=>{l.layout||n.buses.has(l.id)&&i.push({idx:d,bus:l})}),Object.keys(s).length===0&&i.length===0)return o;let a=o.buses;return i.length>0&&a&&(a=a.map(l=>{const d=n.buses.get(l.id);return!l.layout&&d?{...l,layout:Je(d.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var d;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const m=o.buses.get(u);(d=r.buses)!=null&&d.find(h=>h.id===u&&h.layout)||a.set(u,Je(m.geometry))}else{if(s[u])continue;const m=o.layout.get(u);m&&(i[u]=At(m))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map;for(const[l,d]of n){if(o.buses.has(l)){i.set(l,d);continue}const u=o.layout.get(l),m=s[l]??(u?At(u):{at:[0,0]});s[l]={...m,at:[m.at[0]+d[0],m.at[1]+d[1]]}}let a=r.buses;return i.size>0&&(a=(r.buses??[]).map(l=>{const d=i.get(l.id);if(!d)return l;const u=l.layout??Je(o.buses.get(l.id).geometry);return{...l,layout:{...u,at:[u.at[0]+d[0],u.at[1]+d[1]]}}})),{...r,layout:s,buses:a}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(d=>!o.has(d.id)),i=(r.buses??[]).filter(d=>!o.has(d.id)),a=(r.wires??[]).filter(d=>!o.has(ln(d.ends[0]))&&!o.has(ln(d.ends[1]))),l=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([d])=>!o.has(d))):void 0;return{...r,elements:s,buses:i.length?i:void 0,wires:a.length?a:void 0,layout:l&&Object.keys(l).length?l:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const a=i.indexOf(".");a>0&&s.add(i.slice(0,a))}t().dispatch(i=>{const a=(i.wires??[]).filter(d=>d.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const d of s){if(l[d])continue;const u=o.layout.get(d);if(!u)continue;const m={at:u.at};u.rot&&(m.rot=u.rot),u.mirror&&(m.mirror=u.mirror),l[d]=m}return{...i,wires:a.length?a:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const a of r.terminals){const l=a.indexOf(".");l>0&&i.add(a.slice(0,l))}t().dispatch(a=>{const l={...a.layout??{}};for(const u of i){if(l[u])continue;const m=o.layout.get(u);if(!m)continue;const h={at:m.at};m.rot&&(h.rot=m.rot),m.mirror&&(h.mirror=m.mirror),l[u]=h}const d=(a.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...a,wires:d.length?d:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var d,u,m,h;const i={...s.layout??{}},a=new Map;for(const g of o){if(r.buses.has(g)){const b=r.buses.get(g),v=(((((m=(u=(d=s.buses)==null?void 0:d.find(N=>N.id===g))==null?void 0:u.layout)==null?void 0:m.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(g,v);continue}const f=i[g]??{at:((h=r.layout.get(g))==null?void 0:h.at)??[0,0]},p=(((f.rot??0)+n)%360+360)%360;i[g]={...f,rot:p}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(g=>{if(!a.has(g.id))return g;const f=g.layout??Je(r.buses.get(g.id).geometry);return{...g,layout:{...f,rot:a.get(g.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a))continue;const l=s[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};s[a]={...l,mirror:!(l.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=_t(t().diagram,n);return t().dispatch(i=>{const a={id:s,kind:n,...r??{}};return{...i,elements:[...i.elements,a],layout:{...i.layout??{},[s]:{at:o}}}}),e({selection:[s]}),s},addBus:(n,o,r)=>{const s=$n(t().diagram);return t().dispatch(i=>{const a={id:s,layout:r!==void 0?{at:n,span:o,rot:r}:{at:n,span:o}};return{...i,buses:[...i.buses??[],a]}}),e({selection:[s]}),s},addWire:(n,o)=>{if(n===o)return;const r=$t(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(a=>a.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(d=>d.id===n))return r;const i=o&&o.length>=2?Br(o):null,a=i&&i.length>=2?i:null,l=s.map(d=>{if(d.id!==n)return d;if(a)return{...d,path:a};const{path:u,...m}=d;return m});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var a;const s=((a=r.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?Je(a.buses.get(n).geometry):{at:[0,0],span:320}),d={at:o.at??l.at,span:o.span??l.span,...o.rot!==void 0?{rot:o.rot}:l.rot?{rot:l.rot}:{}};return{...i,layout:d}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=l$(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const a=s.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...r,annotations:a}:r})},deleteAnnotation:n=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:Or(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=qe(e.diagram))}}));function u$(e){return Array.from(new Set(e))}function ln(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function m$(e,t){const n=new Set(e.map(r=>r.id)),o=e.slice();for(const r of t)n.has(r.id)||(n.add(r.id),o.push(r));return o}function At(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function Je(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Cb=null;function Co(e){Cb=e}function Ze(){return Cb}const Rt=10;function Ib(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function ne(e){return Ib()?Math.round(e/Rt)*Rt:e}const f$=30,h$=144;function Pb(e,t){const n=Xe[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=p$(r,t);if(!s){const p=Ob(n),b=p?[ne(t[0])-p.x,ne(t[1])-p.y]:[ne(t[0]),ne(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,d=g$(n,l),u=_t(r,e),m=n.terminals.find(p=>p.id===d),h=l==="x"?t[0]:a[0],g=l==="y"?t[1]:a[1],f=m?[ne(h)-m.x,ne(g)-m.y]:[ne(t[0]),ne(t[1])];return o.dispatch(p=>{const b={id:u,kind:e},k={at:f},v=`${u}.${d}`,N={id:$t(i,v),ends:[i,v]};return{...p,elements:[...p.elements,b],wires:[...p.wires??[],N],layout:{...p.layout??{},[u]:k}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function p$(e,t){const n=x.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let d;if(i==="x"){const u=a[0]-l/2,m=a[0]+l/2,h=t[0]<u?u-t[0]:t[0]>m?t[0]-m:0,g=Math.abs(t[1]-a[1]);d=Math.sqrt(h*h+g*g)}else{const u=a[1]-l/2,m=a[1]+l/2,h=t[1]<u?u-t[1]:t[1]>m?t[1]-m:0,g=Math.abs(t[0]-a[0]);d=Math.sqrt(g*g+h*h)}d<=f$&&(!o||d<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:d})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function g$(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,r)=>t==="x"?o.y-r.y:o.x-r.x)[0].id}function Ob(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function Bb(e,t){const n=x.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const g=i[0]-a/2,f=i[0]+a/2,p=Math.max(g,Math.min(f,t[0])),b=i[1],k=t[1]>=b?"s":"n";return{ref:e,world:[p,b],orientation:k,isBus:!0,busId:e}}const l=i[1]-a/2,d=i[1]+a/2,u=Math.max(l,Math.min(d,t[1])),m=i[0],h=t[0]>=m?"e":"w";return{ref:e,world:[m,u],orientation:h,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const y$={n:"s",s:"n",e:"w",w:"e"};function Lb(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=y$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Io(i,n,t.world);for(let l=1;l<s.length;l++){const d=s[l],u=Io(d,n,t.world);u<a&&(a=u,i=d)}return i}function Io(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function x$(e,t,n){const o=Xe[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=Bb(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],d=a*a+l*l<=h$,u=[ne(n[0]),ne(n[1])],m=Lb(o,i,u),h=d?i.world:u,g=[ne(h[0]-m.x),ne(h[1]-m.y)],f=_t(s,e);return r.dispatch(p=>{const b={id:f,kind:e},k={at:g},v=`${f}.${m.id}`,N=i.isBus&&i.busId?i.busId:t,A={id:$t(N,v),ends:[N,v]};return{...p,elements:[...p.elements,b],wires:[...p.wires??[],A],layout:{...p.layout??{},[f]:k}}}),r.setSelection([f]),{newElementId:f,attachedToBus:i.isBus}}const Gt=9,Dt=7;function Kt(e,t){var s,i;const n=[],o=((s=e.element.name)==null?void 0:s.trim())||e.element.id;if(o&&n.push(o),t!=="all"||!((i=e.libraryDef)!=null&&i.params))return n;const r=e.element.params??{};for(const a of e.libraryDef.params){if(!a.showOnCanvas)continue;const l=r[a.name];l==null||l===""||n.push(`${l}${a.unit??""}`)}return n}function Xt(e){const t=b$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Vt(e,t){let n=e.x,o=e.y;switch(t.mirror&&(n=-n),t.rot){case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function b$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function w$(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=x(r=>r.editingElement);return c.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var u;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??Xt(r.libraryDef),a=Vt(i,s),l=i.anchor??"start";if(o===r.element.id)return c.jsx(v$,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const d=Kt(r,n);return d.length===0?null:c.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:d.map((m,h)=>c.jsx("text",{x:0,y:h*Gt,textAnchor:l,className:"ole-annotation-text",children:m},h))},r.element.id)})})}const cn=200,dn=9;function v$({elementId:e,currentName:t,world:n,anchor:o}){const r=I.useRef(null);I.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const d=document.createRange();d.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(d)},[e]);function s(){var h;const l=x.getState(),d=l.diagram.elements.find(g=>g.id===e);if(!d){l.setEditingElement(null);return}const u=(((h=r.current)==null?void 0:h.innerText)??"").replace(/\u00a0/g," ").trim(),m=u===""||u===e?void 0:u;m!==d.name&&l.updateElement(e,{name:m}),l.setEditingElement(null)}function i(l){if(l.key==="Escape"||l.key==="Enter"&&!l.shiftKey){l.preventDefault(),s();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=cn/2:o==="end"&&(a-=cn),c.jsx("foreignObject",{x:a,y:n[1]-dn,width:cn,height:dn*2.2,className:"ole-element-name-editor",children:c.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${dn}px`,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",display:"inline-block",minWidth:"20px",lineHeight:1.1,textAlign:o==="middle"?"center":o==="end"?"right":"left",whiteSpace:"nowrap",cursor:"text"},children:t})})}const zb=8,Ft=1.25;function k$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:c.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?c.jsx($$,{ann:o},o.id):c.jsx(_$,{ann:o,isSelected:t===o.id},o.id))})}function _$({ann:e,isSelected:t}){const n=e.fontSize??zb,o=e.text===""?[""]:e.text.split(`
|
|
193
|
+
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Ft;return c.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,className:"ole-free-annotation-halo"}),o.map((i,a)=>c.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Ft,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function $$({ann:e}){const t=I.useRef(null),n=e.fontSize??zb;I.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(l)},[e.id]);function o(){var d;const a=x.getState(),l=(((d=t.current)==null?void 0:d.innerText)??"").replace(/\u00a0/g," ").trimEnd();l===""?a.deleteAnnotation(e.id):l!==e.text&&a.updateAnnotation(e.id,{text:l}),a.setEditingAnnotation(null),l!==""&&a.setSelectedAnnotation(e.id),a.activeTool==="text"&&a.setActiveTool("select")}function r(a){if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return c.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:c.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:Ft,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",minWidth:`${n}px`,minHeight:`${n*Ft}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const S$=20;function j$(){const e=x(u=>u.selection),t=x(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,a=i/2,l=r==="x"?[s[0]-a,s[1]]:[s[0],s[1]-a],d=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return c.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[c.jsx(Po,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),c.jsx(Po,{x:d[0],y:d[1],busId:n,side:"end",axis:r})]})}function Po({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=I.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const m=x.getState().internal.buses.get(n);m&&(i.current={pointerId:u.pointerId,startSpan:m.geometry.span,startAt:[...m.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const m=i.current;if(!m||u.pointerId!==m.pointerId||!s)return;const h=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?h[0]-m.startSvg[0]:h[1]-m.startSvg[1],f=Ib()?Math.round(g/Rt)*Rt:g,p=m.startSpan+(o==="end"?f:-f);if(p<S$)return;const b=r==="x"?[m.startAt[0]+f/2,m.startAt[1]]:[m.startAt[0],m.startAt[1]+f/2];x.getState().updateBus(n,{span:p,at:b})},d=u=>{const m=i.current;!m||u.pointerId!==m.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return c.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:d,onPointerCancel:d})}const Sn=.5;function vt(e,t){return Math.abs(e[1]-t[1])<Sn?"h":"v"}function E$(){const e=x(a=>a.selectedWire),t=x(a=>a.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let a=1;a<r-1;a++){const l=vt(o[a-1],o[a]),d=vt(o[a],o[a+1]),u=a-1===0,m=a+1===r-1,h=u&&l==="v"||m&&d==="v",g=u&&l==="h"||m&&d==="h";h&&g||s.push(c.jsx(N$,{wireId:e,index:a,xLocked:h,yLocked:g},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],d=o[a+1];Math.abs(l[0]-d[0])<Sn&&Math.abs(l[1]-d[1])<Sn||i.push(c.jsx(M$,{wireId:e,segIndex:a,axis:vt(l,d)},`m-${a}`))}return c.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function N$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=I.useRef(null),i=x(f=>{var p;return(p=f.internal.wireRenders.get(e))==null?void 0:p.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],d=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!r))return;const p=x.getState().internal.wireRenders.get(e);p&&(s.current={pointerId:f.pointerId,startPath:p.path.map(b=>[b[0],b[1]]),startSvg:r.screenToSvg(f.clientX,f.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=d,f.target.setPointerCapture(f.pointerId))},m=f=>{const p=s.current;if(!p||f.pointerId!==p.pointerId||!r)return;const b=r.screenToSvg(f.clientX,f.clientY),k=p.startPath,v=p.index;if(v<=0||v>=k.length-1)return;const N=k[v],A=[p.xLocked?N[0]:ne(N[0]+(b[0]-p.startSvg[0])),p.yLocked?N[1]:ne(N[1]+(b[1]-p.startSvg[1]))];if(A[0]===N[0]&&A[1]===N[1])return;const R=k.map(ee=>[ee[0],ee[1]]);R[v]=A;const F=vt(k[v-1],k[v]);v-1>0&&(F==="h"?R[v-1]=[k[v-1][0],A[1]]:R[v-1]=[A[0],k[v-1][1]]);const te=vt(k[v],k[v+1]);v+1<k.length-1&&(te==="h"?R[v+1]=[k[v+1][0],A[1]]:R[v+1]=[A[0],k[v+1][1]]),x.getState().updateWirePath(e,R)},h=f=>{const p=s.current;!p||f.pointerId!==p.pointerId||(f.target.hasPointerCapture(f.pointerId)&&f.target.releasePointerCapture(f.pointerId),s.current=null,document.body.style.cursor="")},g=f=>{f.stopPropagation(),f.preventDefault();const p=x.getState().internal.wireRenders.get(e);if(!p||p.path.length<=2||t<=0||t>=p.path.length-1)return;const b=p.path.filter((k,v)=>v!==t);x.getState().updateWirePath(e,b)};return c.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:d},onPointerDown:u,onPointerMove:m,onPointerUp:h,onPointerCancel:h,onDoubleClick:g})}function M$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=I.useRef(null),s=x(f=>{var p;return(p=f.internal.wireRenders.get(e))==null?void 0:p.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,d=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",m=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!o))return;const p=x.getState().internal.wireRenders.get(e);p&&(r.current={pointerId:f.pointerId,startPath:p.path.map(b=>[b[0],b[1]]),startSvg:o.screenToSvg(f.clientX,f.clientY),axis:n,segIndex:t},document.body.style.cursor=u,f.currentTarget.setPointerCapture(f.pointerId))},h=f=>{const p=r.current;if(!p||f.pointerId!==p.pointerId||!o)return;const b=o.screenToSvg(f.clientX,f.clientY),k=p.startPath,v=p.segIndex;if(v>=k.length-1)return;const N=k[v],A=k[v+1],R=[];for(let F=0;F<=v;F++)R.push(k[F]);if(p.axis==="h"){const F=ne(N[1]+(b[1]-p.startSvg[1]));R.push([N[0],F]),R.push([A[0],F])}else{const F=ne(N[0]+(b[0]-p.startSvg[0]));R.push([F,N[1]]),R.push([F,A[1]])}for(let F=v+1;F<k.length;F++)R.push(k[F]);x.getState().updateWirePath(e,R)},g=f=>{const p=r.current;if(!p||f.pointerId!==p.pointerId)return;const b=f.currentTarget;b.hasPointerCapture(f.pointerId)&&b.releasePointerCapture(f.pointerId),r.current=null,document.body.style.cursor=""};return c.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,children:[c.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:d,r:8}),c.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:d,r:3.5})]})}const T$=3,un=12;function A$(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)l.includes(".")||i.add(l)}return c.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:d,at:u,span:m}=l,h=m/2,g=d==="x"?u[0]-h:u[0],f=d==="x"?u[1]:u[1]-h,p=d==="x"?u[0]+h:u[0],b=d==="x"?u[1]:u[1]+h,k=s.has(a.id),v=i.has(a.id),N=r.get(a.id)??void 0,A=un/2,R=d==="x"?u[0]-h:u[0]-A,F=d==="x"?u[1]-A:u[1]-h,te=d==="x"?m:un,ee=d==="x"?un:m;return c.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":N,"data-selected":k?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[c.jsx("rect",{x:R,y:F,width:te,height:ee,fill:"transparent",className:"ole-bus-hit"}),c.jsx("line",{x1:g,y1:f,x2:p,y2:b,stroke:"currentColor",strokeWidth:T$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function C$(){const e=x(a=>a.busbarDrawStart),t=x(a=>a.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return c.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[c.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),c.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),c.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}function Ke(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function I$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function P$({lib:e}){const t=I$(e.viewBox);return t?c.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function O$(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),r=x(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const d=l.indexOf(".");d>0&&i.add(l.slice(0,d))}}return c.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const d=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ke(l),className:"ole-element",children:[c.jsx(P$,{lib:a.libraryDef}),c.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ke(l),className:"ole-element ole-element--unknown",children:[c.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),c.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let Rb=null;const jn=new Set;function Ct(e){Rb=e;for(const t of jn)t(e)}function B$(){return Rb}function L$(e){return jn.add(e),()=>{jn.delete(e)}}function z$(){const[e,t]=I.useState(B$());return I.useEffect(()=>L$(t),[]),!e||e.w===0&&e.h===0?null:c.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function R$(){const e=x(d=>d.activeTool),t=x(d=>d.placeKind),n=x(d=>d.cursorSvg),o=x(d=>d.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Tb(t);if(!r)return null;let s=null,i=null;if(o){const d=Bb(o,n);d&&(s=Lb(r,d,n),i={source:d.world,pin:n})}else s=Ob(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return c.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),c.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:c.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function D$(){const e=x(r=>r.selection),t=x(r=>r.internal.elements),n=x(r=>r.internal.layout),o=x(r=>r.internal.buses);return e.length===0?null:c.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:d,at:u,span:m}=s.geometry,h=m/2,g=d==="x"?u[0]-h:u[0]-4,f=d==="x"?u[1]-4:u[1]-h,p=d==="x"?m:8,b=d==="x"?8:m;return c.jsx("rect",{x:g,y:f,width:p,height:b,fill:"none",className:"ole-selection-rect"},r)}const i=t.get(r),a=n.get(r);if(!(i!=null&&i.libraryDef)||!a)return null;const l=F$(i.libraryDef.viewBox);return l?c.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ke(a)},r):null})})}function F$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function H$(){const e=x(s=>s.internal.terminals),t=x(s=>s.internal.terminalToNode),n=x(s=>s.wireFromTerminal),o=x(s=>s.selection),r=new Set(o);return c.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),a=i!==void 0,l=n===s.ref,d=r.has(s.elementId);return c.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":a?"true":"false","data-active":l?"true":void 0,"data-on-selected":d?"true":void 0,className:"ole-terminal"},s.ref)})})}function W$(){const e=x(i=>i.internal.wireRenders),t=x(i=>i.internal.terminalToNode),n=x(i=>i.diagram.wires),o=x(i=>i.selectedWire),r=x(i=>i.selectedNode),s=new Map;for(const i of n??[]){const a=t.get(i.ends[0]);a&&s.set(i.id,a)}return c.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:Array.from(e.values()).flatMap(i=>{const a=i.path;if(a.length<2)return[];const l=a.map(h=>`${h[0]},${h[1]}`).join(" "),d=s.get(i.wireId),u=o===i.wireId,m=r!=null&&r===d;return[c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,className:"ole-wire-hit",points:l},`hit-${i.wireId}`),c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,"data-manual":i.userEdited?"true":void 0,"data-selected":u||m?"true":void 0,className:"ole-wire",points:l},i.wireId)]})})}let Ue=null;const En=new Set;function Pe(e){if(!(e===null&&Ue===null||e&&Ue&&e.ref===Ue.ref&&e.world[0]===Ue.world[0]&&e.world[1]===Ue.world[1])){Ue=e;for(const t of En)t(e)}}function q$(){return Ue}function G$(e){return En.add(e),()=>{En.delete(e)}}function K$(){var d,u;const e=x(m=>m.wireFromTerminal),t=x(m=>m.cursorSvg),n=x(m=>m.internal.terminals),[o,r]=I.useState(q$());I.useEffect(()=>G$(r),[]);const s=x(m=>m.internal.buses);if(!e||!t)return null;let i;if(e.includes(".")?i=(d=n.get(e))==null?void 0:d.world:i=(u=s.get(e))==null?void 0:u.geometry.at,!i)return null;const a=(o==null?void 0:o.world[0])??t[0],l=(o==null?void 0:o.world[1])??t[1];return c.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[c.jsx("line",{x1:i[0],y1:i[1],x2:a,y2:l,className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i[0],cy:i[1],r:4,className:"ole-wire-preview-anchor"}),o&&c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?7:8,className:"ole-wire-preview-target-ring"}),c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function it(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function rt(e){var t;return((t=it(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function X$(e){var t;return((t=it(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function Ge(e){var o;const t=(o=it(e,"data-terminal-id"))==null?void 0:o.getAttribute("data-terminal-id");if(t)return t;const n=X$(e);return n||null}function Yt(e){var t;return((t=it(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Oo(e){var t;return((t=it(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Ht(e){var t;return((t=it(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function Db(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function V$(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Fb(){const e=x.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="text"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function Y$(){I.useEffect(()=>{const e=t=>{if(V$(t.target))return;const n=t.metaKey||t.ctrlKey,o=x.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=x.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":Fb();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Nn=null;const Mn=new Set;function U$(e){if(e!==Nn){Nn=e;for(const t of Mn)t(e)}}function Z$(){return Nn}function Q$(e){return Mn.add(e),()=>{Mn.delete(e)}}const Bo="ole-hover-element-host",J$="ole-hover-terminal-on",eS="ole-hover-node-on";function tS(e){I.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(m,h,g)=>{for(const f of m)f.classList.remove(g);m.clear();for(const f of h)f.classList.add(g),m.add(f)},a=m=>{var g,f;if(m===n)return;n&&((g=t.querySelector(`[data-element-id="${It(n)}"]`))==null||g.classList.remove(Bo)),m&&((f=t.querySelector(`[data-element-id="${It(m)}"]`))==null||f.classList.add(Bo));const h=m?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${It(m)}"]`)):[];i(r,h,J$),n=m,m?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),U$(m)},l=m=>{if(m===o)return;const h=m?Array.from(t.querySelectorAll(`[data-node-id="${It(m)}"]`)):[];i(s,h,eS),o=m,m?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},d=m=>{a(rt(m.target));const h=Ge(m.target);let g=null;h?g=x.getState().internal.terminalToNode.get(h)??null:g=Yt(m.target),l(g)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",d),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",d),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function It(e){return e.replace(/(["\\])/g,"\\$1")}function Hb(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(!r)return null;const{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const m=i[0]-a/2,h=i[0]+a/2,g=Math.max(m,Math.min(h,t[0]));return{ref:e,world:[g,i[1]],isBus:!0}}const l=i[1]-a/2,d=i[1]+a/2,u=Math.max(l,Math.min(d,t[1]));return{ref:e,world:[i[0],u],isBus:!0}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const Lo=3;let ae=null,$e=null,Se=null,le=null;const nS={id:"select",cursor:"default",onPointerDown(e,t){var h,g,f,p,b,k,v;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Ht(e.target);if(o){e.preventDefault(),e.stopPropagation();const N=(h=n.diagram.annotations)==null?void 0:h.find(A=>A.id===o);if(!N)return;n.setSelectedAnnotation(o),le={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[N.at[0],N.at[1]],moved:!1};return}const s=(e.target instanceof Element?(g=e.target.closest("[data-terminal-id]"))==null?void 0:g.getAttribute("data-terminal-id"):null)?Ge(e.target):null;if(s){const N=s.indexOf("."),A=N>0?s.slice(0,N):"";if(A&&n.selection.includes(A)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((p=(f=e.target).hasPointerCapture)!=null&&p.call(f,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Se={pointerId:e.pointerId,fromRef:s};return}}let i=rt(e.target);if(!i){const N=Oo(e.target);if(N&&typeof document<"u"){const A=document.elementsFromPoint(e.clientX,e.clientY);for(const R of A){const F=(k=(b=R.closest)==null?void 0:b.call(R,"[data-bus-id]"))==null?void 0:k.getAttribute("data-bus-id");if(!F)continue;const te=(v=n.diagram.wires)==null?void 0:v.find(ee=>ee.id===N);te&&(te.ends[0]===F||te.ends[1]===F)&&(i=F);break}}}if(!i){const N=Oo(e.target);if(N){if(e.preventDefault(),e.altKey){const A=Yt(e.target);if(A){n.setSelectedNode(A);return}}n.setSelectedWire(N);return}e.shiftKey||n.clearSelection(),$e={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const a=n.selection;e.shiftKey?n.toggleInSelection(i):a.includes(i)||n.setSelection([i]);const l=e.shiftKey?x.getState().selection:a.includes(i)?a:[i];if(l.length===0)return;const d=x.getState().internal,u=new Map,m=new Map;for(const N of l){const A=d.buses.get(N);if(A){m.set(N,[A.geometry.at[0],A.geometry.at[1]]);continue}const R=d.layout.get(N);R&&u.set(N,{...R})}u.size===0&&m.size===0||(ae={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:m,moved:!1},e.preventDefault())},onPointerMove(e,t){if(le&&e.pointerId===le.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]);!le.moved&&(o!==0||r!==0)&&(le.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${We(le.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Se&&e.pointerId===Se.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?Ge(o):null;if(!r||r===Se.fromRef){Pe(null);return}Pe(Hb(r,n));return}if(ae&&e.pointerId===ae.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-ae.startSvg[0]),r=ne(n[1]-ae.startSvg[1]);!ae.moved&&(o!==0||r!==0)&&(ae.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ae.originals){const a=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ke(l))}for(const s of ae.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if($e&&e.pointerId===$e.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);Ct(zo($e.startSvg,n));return}},onPointerUp(e,t){if(le&&e.pointerId===le.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${We(le.id)}"]`);s&&s.removeAttribute("transform"),le.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(le.id,{at:[le.origin[0]+o,le.origin[1]+r]}),le=null;return}if(Se&&e.pointerId===Se.pointerId){const n=x.getState(),o=Se.fromRef;Se=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Pe(null);const r=Ge(e.target);r&&r!==o&&n.addWire(o,r);return}if(ae&&e.pointerId===ae.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ae.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-ae.startSvg[0]),r=ne(n[1]-ae.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ae.originals.keys())s.set(i,[o,r]);for(const i of ae.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ae.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);i&&i.removeAttribute("transform")}}ae=null;return}if($e&&e.pointerId===$e.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=zo($e.startSvg,n);if(o.w>=Lo||o.h>=Lo){const r=oS(o);if($e.shiftKey){const s=new Set($e.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}Ct(null),$e=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(le&&e.pointerId===le.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${We(le.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}le=null}if(ae&&e.pointerId===ae.pointerId){for(const[l,d]of ae.originals){const u=t.hostEl.querySelector(`[data-element-id="${We(l)}"]`);u&&u.setAttribute("transform",Ke(d))}for(const l of ae.busOriginals.keys()){const d=t.hostEl.querySelector(`[data-element-id="${We(l)}"]`);d&&d.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ae=null}if(Se&&e.pointerId===Se.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setCursorSvg(null),Pe(null),Se=null}if($e&&e.pointerId===$e.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}Ct(null),$e=null}},onDoubleClick(e){const t=x.getState(),n=Ht(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=rt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ae=null,$e=null,le=null,Se){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null),Se=null}Ct(null)}};function zo(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),r=Math.abs(t[0]-e[0]),s=Math.abs(t[1]-e[1]);return{x:n,y:o,w:r,h:s}}function oS(e){const{internal:t}=x.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=sS(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([m,h])=>rS([m,h],r));let a=1/0,l=-1/0,d=1/0,u=-1/0;for(const[m,h]of i)m<a&&(a=m),m>l&&(l=m),h<d&&(d=h),h>u&&(u=h);l>=e.x&&a<=e.x+e.w&&u>=e.y&&d<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,d=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],m=s==="x"?i[1]:i[1]-l,h=s==="x"?i[1]:i[1]+l;u>=e.x&&d<=e.x+e.w&&h>=e.y&&m<=e.y+e.h&&n.push(o.id)}return n}function rS(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function sS(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function We(e){return e.replace(/(["\\])/g,"\\$1")}const iS=4;let Z=null;const aS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=rt(e.target);let r=null;if(o){const s=x.getState();s.selection.includes(o)||s.setSelection([o]);const i=x.getState().selection,a=x.getState().internal,l=new Map,d=new Map;for(const u of i){const m=a.buses.get(u);if(m){d.set(u,[m.geometry.at[0],m.geometry.at[1]]);continue}const h=a.layout.get(u);h&&l.set(u,{...h})}(l.size>0||d.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:d})}Z={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTx:n.tx,startTy:n.ty,startTarget:e.target,moved:!1,elementDrag:r},t.hostEl.style.cursor="grabbing",e.preventDefault()},onPointerMove(e,t){if(!Z||e.pointerId!==Z.pointerId)return;const n=e.clientX-Z.startX,o=e.clientY-Z.startY;if(!Z.moved&&Math.hypot(n,o)>iS){Z.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(Z.moved){if(Z.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=ne(r[0]-Z.elementDrag.startSvg[0]),i=ne(r[1]-Z.elementDrag.startSvg[1]);for(const[a,l]of Z.elementDrag.originals){const d=t.hostEl.querySelector(`[data-element-id="${pt(a)}"]`);if(!d)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};d.setAttribute("transform",Ke(u))}for(const a of Z.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${pt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:Z.startTx+n,ty:Z.startTy+o})}},onPointerUp(e,t){if(!(!Z||e.pointerId!==Z.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",Z.elementDrag&&Z.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-Z.elementDrag.startSvg[0]),r=ne(n[1]-Z.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of Z.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of Z.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of Z.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${pt(s)}"]`);i&&i.removeAttribute("transform")}}else Z.moved||lS(Z.startTarget);Z=null}},onPointerCancel(e,t){if(Z!=null&&Z.elementDrag){for(const[n,o]of Z.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${pt(n)}"]`);r&&r.setAttribute("transform",Ke(o))}for(const n of Z.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${pt(n)}"]`);o&&o.removeAttribute("transform")}}Z=null},onDeactivate(){Z=null}};function lS(e){if(!e)return;const t=x.getState(),n=Ht(e);if(n){t.setSelectedAnnotation(n);return}const o=rt(e);if(o){t.setSelection([o]);return}const r=Yt(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function pt(e){return e.replace(/(["\\])/g,"\\$1")}const xt={tight:1024,compact:720,dense:520,mini:380},Ro={full:0,tight:1,compact:2,dense:3,mini:4};function Ce(e,t){return Ro[e]>=Ro[t]}function cS(e){return e>=xt.tight?"full":e>=xt.compact?"tight":e>=xt.dense?"compact":e>=xt.mini?"dense":"mini"}const Wb=I.createContext("full");function Ve(){return I.useContext(Wb)}function dS(e){const[t,n]=I.useState(null);return I.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function qb(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<xt.dense}function Rn(){qb()&&x.getState().setActiveTool("pan")}function uS(){qb()&&x.getState().setPlaceKind(null)}const mS={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null)},onPointerDown(e,t){var r,s;if(e.button!==0)return;const n=Ge(e.target);if(!n)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((s=(r=e.target).hasPointerCapture)!=null&&s.call(r,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const o=x.getState();o.setWireFromTerminal(n),o.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY))},onPointerMove(e,t){const n=x.getState().wireFromTerminal;if(!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(o);const r=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,s=r?Ge(r):null;if(!s||s===n){Pe(null);return}Pe(Hb(s,o))},onPointerUp(e){const t=x.getState(),n=t.wireFromTerminal;if(!n)return;t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null);const o=Ge(e.target);!o||o===n||(t.addWire(n,o),Rn())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setCursorSvg(null),Pe(null)}},Do=10;let gt=!1;function Fo(){setTimeout(()=>uS(),0)}const fS={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=x.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),gt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=Ge(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const a=x.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);Pb(n,r),gt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([Ho(n[0]),Ho(n[1])])},onPointerUp(e,t){const n=x.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);x$(r,o,s),Fo();return}gt&&(gt=!1,Fo())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),gt=!1}};function Ho(e){return Math.round(e/Do)*Do}const Wo=10,qo=20;function et(e){return Math.round(e/Wo)*Wo}const hS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[et(n[0]),et(n[1])];x.getState().setBusbarDrawStart(o),x.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([et(n[0]),et(n[1])])},onPointerUp(e,t){const n=x.getState().busbarDrawStart;if(x.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=et(o[0]),s=et(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let d,u,m;if(l){if(u=Math.abs(i),u<qo)return;d=0,m=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<qo)return;d=90,m=[n[0],(n[1]+s)/2]}x.getState().addBus(m,u,d),Rn()},onPointerLeave(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},pS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Ht(e.target);if(o){e.preventDefault(),e.stopPropagation(),n.setActiveTool("select"),n.setSelectedAnnotation(o);return}e.preventDefault();const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=n.addAnnotation([r[0],r[1]],"");n.setEditingAnnotation(s),Rn()}},gS={select:nS,pan:aS,wire:mS,place:fS,busbar:hS,text:pS};function yS(e,t){const n=x(o=>o.activeTool);I.useEffect(()=>{var h;const o=e.current;if(!o)return;const r=gS[n],s={viewport:t,hostEl:o};(h=r.onActivate)==null||h.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=g=>{var f;return(f=r.onPointerDown)==null?void 0:f.call(r,g,s)},a=g=>{var f;return(f=r.onPointerMove)==null?void 0:f.call(r,g,s)},l=g=>{var f;return(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},d=g=>{var f;return r.onPointerCancel?r.onPointerCancel(g,s):(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},u=g=>{var f;return(f=r.onPointerLeave)==null?void 0:f.call(r,g,s)},m=g=>{var f;return(f=r.onDoubleClick)==null?void 0:f.call(r,g,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",d),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",m),()=>{var g;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",d),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",m),(g=r.onDeactivate)==null||g.call(r,s),o.style.cursor=""}},[n,e,t])}let Tn=1;const An=new Set;function xS(e){if(e!==Tn){Tn=e;for(const t of An)t(e)}}function bS(){return Tn}function wS(e){return An.add(e),()=>{An.delete(e)}}const mn=.1,fn=8,vS=1.0015,kS=1.02;function _S(e,t,n={tx:0,ty:0,scale:1}){const o=I.useRef({...n}),r=I.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),xS(o.current.scale),r.current.size>0){const l={...o.current};for(const d of r.current)d(l)}};return I.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,d=0,u=0,m=0,h=0,g=!1;const f=new Map;let p=null,b=!1;const k=()=>{if(f.size<2){p=null;return}const B=[...f.values()],D=B[1].x-B[0].x,oe=B[1].y-B[0].y,re=Math.hypot(D,oe)||1,ue=i.getBoundingClientRect();p={startDist:re,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(B[0].x+B[1].x)/2-ue.left,startMidY:(B[0].y+B[1].y)/2-ue.top}},v=B=>{if(B.pointerType==="touch"){if(f.set(B.pointerId,{x:B.clientX,y:B.clientY}),f.size>=2&&!b){b=!0;for(const D of f.keys())D!==B.pointerId&&Db(i,D);k()}if(b){B.stopPropagation(),B.preventDefault();try{i.setPointerCapture(B.pointerId)}catch{}}}},N=B=>{if(B.pointerType!=="touch"||!f.has(B.pointerId)||(f.set(B.pointerId,{x:B.clientX,y:B.clientY}),!b||!p))return;B.stopPropagation();const D=[...f.values()];if(D.length<2)return;const oe=D[1].x-D[0].x,re=D[1].y-D[0].y,ue=Math.hypot(oe,re)||1,U=i.getBoundingClientRect(),me=(D[0].x+D[1].x)/2-U.left,pe=(D[0].y+D[1].y)/2-U.top,be=ue/p.startDist,Ie=hn(p.startScale*be,mn,fn),he=Ie/p.startScale;o.current.tx=p.startMidX-(p.startMidX-p.startTx)*he+(me-p.startMidX),o.current.ty=p.startMidY-(p.startMidY-p.startTy)*he+(pe-p.startMidY),o.current.scale=Ie,s()},A=B=>{var D;if(B.pointerType==="touch"&&f.has(B.pointerId)&&(f.delete(B.pointerId),b)){if(B.stopPropagation(),(D=i.hasPointerCapture)!=null&&D.call(i,B.pointerId))try{i.releasePointerCapture(B.pointerId)}catch{}f.size>=2?k():p=null,f.size===0&&(b=!1)}},R=B=>{B.preventDefault();const D=i.getBoundingClientRect(),oe=B.clientX-D.left,re=B.clientY-D.top,ue=B.ctrlKey||B.metaKey;if(B.deltaX===0||ue){const pe=Math.pow(ue?kS:vS,-B.deltaY),be=hn(o.current.scale*pe,mn,fn),Ie=be/o.current.scale;o.current.tx=oe-(oe-o.current.tx)*Ie,o.current.ty=re-(re-o.current.ty)*Ie,o.current.scale=be}else o.current.tx-=B.deltaX,o.current.ty-=B.deltaY;s()},F=B=>{const D=B.button===1,oe=g&&B.button===0;!D&&!oe||(B.preventDefault(),a=!0,l=B.pointerId,d=B.clientX,u=B.clientY,m=o.current.tx,h=o.current.ty,i.setPointerCapture(B.pointerId),i.style.cursor="grabbing")},te=B=>{!a||B.pointerId!==l||(o.current.tx=m+(B.clientX-d),o.current.ty=h+(B.clientY-u),s())},ee=B=>{a&&B.pointerId===l&&(a=!1,i.releasePointerCapture(B.pointerId),i.style.cursor=g?"grab":"")},xe=B=>{if(B.code==="Space"&&!g){const D=B.target;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"||D.isContentEditable))return;g=!0,i.style.cursor="grab",B.preventDefault()}},fe=B=>{B.code==="Space"&&(g=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",R,{passive:!1}),i.addEventListener("pointerdown",F),i.addEventListener("pointermove",te),i.addEventListener("pointerup",ee),i.addEventListener("pointercancel",ee),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",N,{capture:!0}),i.addEventListener("pointerup",A,{capture:!0}),i.addEventListener("pointercancel",A,{capture:!0}),window.addEventListener("keydown",xe),window.addEventListener("keyup",fe),s(),()=>{i.removeEventListener("wheel",R),i.removeEventListener("pointerdown",F),i.removeEventListener("pointermove",te),i.removeEventListener("pointerup",ee),i.removeEventListener("pointercancel",ee),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",N,{capture:!0}),i.removeEventListener("pointerup",A,{capture:!0}),i.removeEventListener("pointercancel",A,{capture:!0}),window.removeEventListener("keydown",xe),window.removeEventListener("keyup",fe)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const d=l.getBoundingClientRect(),u=(i-d.left-o.current.tx)/o.current.scale,m=(a-d.top-o.current.ty)/o.current.scale;return[u,m]},getViewport(){return{...o.current}},setViewport(i){i.tx!==void 0&&(o.current.tx=i.tx),i.ty!==void 0&&(o.current.ty=i.ty),i.scale!==void 0&&(o.current.scale=hn(i.scale,mn,fn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function hn(e,t,n){return e<t?t:e>n?n:e}const Gb=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),tt=Gb?"⌘":"Ctrl+",$S=Gb?"⇧":"Shift+",pn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],SS=18;function jS(e){for(const t of pn)if(t*e>=SS)return t;return pn[pn.length-1]}function ES(){const e=J(),t=I.useRef(null),n=I.useRef(null),o=I.useRef(null),r=_S(t,n);yS(t,r),tS(t),I.useEffect(()=>(Co(r),()=>Co(null)),[r]),I.useEffect(()=>{const u=m=>{const h=o.current;if(!h)return;const f=jS(m.scale)*m.scale;h.setAttribute("width",String(f)),h.setAttribute("height",String(f)),h.setAttribute("patternTransform",`translate(${m.tx} ${m.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Ev(),i=I.useCallback((u,m,h)=>{const g=x.getState(),f=g.activeTool;if(f==="wire"||f==="busbar"||f==="place"){Fb();return}const p=rt(h);if(p)g.selection.includes(p)||g.setSelection([p]);else{const F=Yt(h);F&&g.selectedNode!==F&&g.setSelectedNode(F)}const b=x.getState(),k=b.selection.length>0,v=b.selectedNode!=null,N=!!b.clipboard,A=b.diagram.elements.length>0,R=[{label:e("menu.undo"),shortcut:`${tt}Z`,icon:Bn,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${tt}${$S}Z`,icon:On,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${tt}X`,icon:wr,onSelect:()=>x.getState().cutSelection(),disabled:!k},{label:e("menu.copy"),shortcut:`${tt}C`,icon:gr,onSelect:()=>x.getState().copySelection(),disabled:!k},{label:e("menu.paste"),shortcut:`${tt}V`,icon:pr,onSelect:()=>x.getState().pasteClipboard(),disabled:!N},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:br,onSelect:()=>x.getState().rotateSelection(90),disabled:!k},{label:e("menu.mirror"),shortcut:"M",icon:yr,onSelect:()=>x.getState().mirrorSelection(),disabled:!k},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${tt}A`,icon:Vw,onSelect:()=>{const F=x.getState();F.setSelection(F.diagram.elements.map(te=>te.id))},disabled:!A},{type:"separator"},{label:e(v&&!k?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:kr,destructive:!0,onSelect:()=>v&&!k?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!k&&!v}];s.open(u,m,R)},[s,e]);I.useEffect(()=>{const u=t.current;if(!u)return;const m=700,h=4;let g,f=null;const p=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,f=null},b=N=>{N.pointerType==="touch"&&(p(),f={pointerId:N.pointerId,x:N.clientX,y:N.clientY,target:N.target},g=window.setTimeout(()=>{const A=f;f=null,g=void 0,A&&(Db(u,A.pointerId),i(A.x,A.y,A.target))},m))},k=N=>{if(!f||N.pointerId!==f.pointerId)return;const A=N.clientX-f.x,R=N.clientY-f.y;Math.hypot(A,R)>h&&p()},v=N=>{!f||N.pointerId!==f.pointerId||p()};return u.addEventListener("pointerdown",b),u.addEventListener("pointermove",k),u.addEventListener("pointerup",v),u.addEventListener("pointercancel",v),()=>{p(),u.removeEventListener("pointerdown",b),u.removeEventListener("pointermove",k),u.removeEventListener("pointerup",v),u.removeEventListener("pointercancel",v)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{const m=u.dataTransfer.getData("application/x-oneline-kind");if(!m)return;u.preventDefault();const h=r.screenToSvg(u.clientX,u.clientY);Pb(m,h)},d=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return c.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:d,children:c.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("defs",{children:c.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:c.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),c.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),c.jsxs("g",{ref:n,className:"ole-viewport",children:[c.jsx(A$,{}),c.jsx(W$,{}),c.jsx(O$,{}),c.jsx(w$,{}),c.jsx(k$,{}),c.jsx(D$,{}),c.jsx(j$,{}),c.jsx(E$,{}),c.jsx(H$,{}),c.jsx(K$,{}),c.jsx(C$,{}),c.jsx(R$,{}),c.jsx(z$,{})]})]})})}const Go=60,NS=.1,MS=8,TS=8;function AS(e,t,n){return e<t?t:e>n?n:e}function CS(){return document.querySelector(".ole-canvas-root")}function Dn(){const e=Ze(),t=CS();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,a=-1/0;for(const k of o){const v=k.getBoundingClientRect();v.width===0&&v.height===0||(v.left<r&&(r=v.left),v.top<s&&(s=v.top),v.right>i&&(i=v.right),v.bottom>a&&(a=v.bottom))}if(r===1/0)return!1;const[l,d]=e.screenToSvg(r,s),[u,m]=e.screenToSvg(i,a),h=Math.max(u-l,1),g=Math.max(m-d,1),f=AS(Math.min((n.width-Go*2)/h,(n.height-Go*2)/g),NS,MS),p=(l+u)/2,b=(d+m)/2;return e.setViewport({tx:n.width/2-f*p,ty:n.height/2-f*b,scale:f}),!0}function Fn(){let e=TS;const t=()=>{Dn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const Ko=10,IS=100;function PS(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function OS(){const[e,t]=I.useState(Z$()),[n,o]=I.useState(!1),[r,s]=I.useState(null),i=I.useRef(null),a=I.useRef(void 0),[l]=I.useState(PS);I.useEffect(()=>Q$(f=>t(f)),[]),I.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),IS),()=>window.clearTimeout(a.current)},[e]);const d=x(f=>e?f.diagram.elements.find(p=>p.id===e)??null:null);if(I.useLayoutEffect(()=>{if(!n||!e)return;let f=0,p=-1,b=-1;const k=()=>{const v=document.querySelector(`[data-element-id="${BS(e)}"]`),N=i.current;if(v&&N){const A=v.getBoundingClientRect();let R=A.bottom+Ko;R+N.offsetHeight>window.innerHeight-4&&(R=A.top-N.offsetHeight-Ko);let F=A.left+A.width/2-N.offsetWidth/2;F=Math.max(4,Math.min(F,window.innerWidth-N.offsetWidth-4)),(R!==p||F!==b)&&(s({top:R,left:F}),p=R,b=F)}f=requestAnimationFrame(k)};return f=requestAnimationFrame(k),()=>cancelAnimationFrame(f)},[n,e]),l||!n||!e||!d)return null;const u=Xe[d.kind],m=d.name??d.id,h=(u==null?void 0:u.name)??d.kind,g=d.name&&d.name!==d.id;return typeof document>"u"?null:mr.createPortal(c.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[c.jsx("span",{className:"font-medium text-foreground",children:m}),g&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:d.id}),c.jsx("span",{className:"text-muted-foreground/80",children:"·"}),c.jsx("span",{className:"text-muted-foreground",children:h})]}),document.body)}function BS(e){return e.replace(/(["\\])/g,"\\$1")}function LS({width:e,children:t}){const n=e==null?"full":cS(e);return c.jsx(Wb.Provider,{value:n,children:t})}function Xo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function zS(...e){return t=>{let n=!1;const o=e.map(r=>{const s=Xo(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<o.length;r++){const s=o[r];typeof s=="function"?s():Xo(e[r],null)}}}}var RS=Symbol.for("react.lazy"),Wt=we[" use ".trim().toString()];function DS(e){return typeof e=="object"&&e!==null&&"then"in e}function Kb(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===RS&&"_payload"in e&&DS(e._payload)}function FS(e){const t=WS(e),n=we.forwardRef((o,r)=>{let{children:s,...i}=o;Kb(s)&&typeof Wt=="function"&&(s=Wt(s._payload));const a=we.Children.toArray(s),l=a.find(GS);if(l){const d=l.props.children,u=a.map(m=>m===l?we.Children.count(d)>1?we.Children.only(null):we.isValidElement(d)?d.props.children:null:m);return c.jsx(t,{...i,ref:r,children:we.isValidElement(d)?we.cloneElement(d,void 0,u):null})}return c.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var HS=FS("Slot");function WS(e){const t=we.forwardRef((n,o)=>{let{children:r,...s}=n;if(Kb(r)&&typeof Wt=="function"&&(r=Wt(r._payload)),we.isValidElement(r)){const i=XS(r),a=KS(s,r.props);return r.type!==we.Fragment&&(a.ref=o?zS(o,i):i),we.cloneElement(r,a)}return we.Children.count(r)>1?we.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qS=Symbol("radix.slottable");function GS(e){return we.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qS}function KS(e,t){const n={...t};for(const o in t){const r=e[o],s=t[o];/^on[A-Z]/.test(o)?r&&s?n[o]=(...a)=>{const l=s(...a);return r(...a),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...s}:o==="className"&&(n[o]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}function XS(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Vo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yo=Sr,VS=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return Yo(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(d=>{const u=n==null?void 0:n[d],m=s==null?void 0:s[d];if(u===null)return null;const h=Vo(u)||Vo(m);return r[d][h]}),a=n&&Object.entries(n).reduce((d,u)=>{let[m,h]=u;return h===void 0||(d[m]=h),d},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,u)=>{let{class:m,className:h,...g}=u;return Object.entries(g).every(f=>{let[p,b]=f;return Array.isArray(b)?b.includes({...s,...a}[p]):{...s,...a}[p]===b})?[...d,m,h]:d},[]);return Yo(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},YS=VS("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ee=we.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?HS:"button";return c.jsx(i,{className:_e(YS({variant:t,size:n,className:e})),ref:s,...r})});Ee.displayName="Button";const US=350;function Ne({content:e,children:t,disabled:n,delayMs:o=US}){const r=I.useRef(null),s=I.useRef(null),[i,a]=I.useState(!1),[l,d]=I.useState(null),u=I.useId(),m=I.useRef(void 0),h=()=>{n||(window.clearTimeout(m.current),m.current=window.setTimeout(()=>a(!0),o))},g=()=>{window.clearTimeout(m.current),a(!1)};I.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const k=r.current.getBoundingClientRect(),v=s.current.getBoundingClientRect(),N=8;let A="top",R=k.top-v.height-N;R<4&&(A="bottom",R=k.bottom+N);let F=k.left+k.width/2-v.width/2;F=Math.max(4,Math.min(F,window.innerWidth-v.width-4)),d({top:R,left:F,side:A})},[i,e]),I.useEffect(()=>()=>window.clearTimeout(m.current),[]),I.useEffect(()=>{if(!i)return;const k=N=>{N.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",k),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",k),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const f=t,p=f.props,b=I.cloneElement(f,{ref:k=>{r.current=k;const v=f.ref;typeof v=="function"?v(k):v&&typeof v=="object"&&(v.current=k)},onPointerEnter:k=>{var v;(v=p.onPointerEnter)==null||v.call(p,k),h()},onPointerLeave:k=>{var v;(v=p.onPointerLeave)==null||v.call(p,k),g()},onFocus:k=>{var v;(v=p.onFocus)==null||v.call(p,k),h()},onBlur:k=>{var v;(v=p.onBlur)==null||v.call(p,k),g()},"aria-describedby":i?u:p["aria-describedby"]});return c.jsxs(c.Fragment,{children:[b,i&&typeof document<"u"&&mr.createPortal(c.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const Uo=12,ZS=56;function QS(){var k;const e=J(),t=x(v=>v.selection),n=x(v=>v.selectedNode),o=x(v=>v.selectedWire),r=x(v=>v.activeTool),s=x(v=>v.rotateSelection),i=x(v=>v.mirrorSelection),a=x(v=>v.deleteSelection),l=x(v=>v.deleteSelectedNode),d=x(v=>v.deleteSelectedWire),u=x(v=>v.resetWirePath),m=x(v=>v.internal.wireRenders),h=o!=null&&((k=m.get(o))==null?void 0:k.userEdited)===!0,g=I.useRef(null);I.useEffect(()=>{const v=g.current;if(!v)return;const N=t.length>0,A=!N&&o!=null,R=!N&&!A&&n!=null;if(!((N||A||R)&&(r==="select"||r==="pan"))){v.style.display="none";return}v.style.display="flex";let te=0,ee="";const xe=()=>{let fe=1/0,B=-1/0,D=1/0,oe=-1/0,re=!1;const ue=U=>{U.width===0&&U.height===0||(U.left<fe&&(fe=U.left),U.right>B&&(B=U.right),U.top<D&&(D=U.top),U.bottom>oe&&(oe=U.bottom),re=!0)};if(N)for(const U of t){const me=document.querySelector(`[data-element-id="${CSS.escape(U)}"]`);me&&ue(me.getBoundingClientRect())}else if(A&&o){const U=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);U&&ue(U.getBoundingClientRect())}else if(R&&n){const U=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const me of U)ue(me.getBoundingClientRect())}if(re){const U=(fe+B)/2;let me=D-Uo,pe="-100%";me<ZS&&(me=oe+Uo,pe="0%");const be=`translate3d(${U}px, ${me}px, 0) translate(-50%, ${pe})`;be!==ee&&(v.style.transform=be,ee=be)}te=requestAnimationFrame(xe)};return te=requestAnimationFrame(xe),()=>cancelAnimationFrame(te)},[t,n,o,r]);const f=t.length===0&&o!=null,p=t.length===0&&!f&&n!=null,b=p||f;return c.jsxs("div",{ref:g,role:"toolbar","aria-label":e(f?"ctx.ariaWire":p?"ctx.ariaNode":"ctx.ariaElement"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-30 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[f&&h&&o&&c.jsxs(c.Fragment,{children:[c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{children:c.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:c.jsx(Xw,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&c.jsxs(c.Fragment,{children:[c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:c.jsx(br,{})})}),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:c.jsx(yr,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.delete")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),c.jsx("div",{className:"text-muted-foreground",children:e(f?"ctx.deleteHintWire":p?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>f?d():p?l():a(),"aria-label":e("ctx.delete"),children:c.jsx(kr,{})})})]})}function Hn({open:e,onOpenChange:t,trigger:n,children:o}){const r=I.useRef(null);return I.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),c.jsxs("div",{ref:r,className:"relative",children:[n,e&&c.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const Xb="ole-panel-open";function JS(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Xb);if(!e)return{outlineOpen:!1};const t=JSON.parse(e);return typeof t!="object"||t===null?{outlineOpen:!1}:{outlineOpen:t.outline===!0}}catch{return{outlineOpen:!1}}}function Zo(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Xb,JSON.stringify(t))}catch{}}const St=qt((e,t)=>({...JS(),setOutlineOpen:n=>{e({outlineOpen:n}),Zo(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),Zo(t())}})),Bt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Vb=.1,Yb=8,Ub="ole-grid";function e4(){try{const e=window.localStorage.getItem(Ub);return e==null?!0:e==="1"}catch{return!0}}function t4(e){try{window.localStorage.setItem(Ub,e?"1":"0")}catch{}}function n4(e,t,n){return e<t?t:e>n?n:e}function Zb(){return document.querySelector(".ole-canvas-root")}function Wn(e){const t=Ze(),n=Zb();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=n4(e,Vb,Yb),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function o4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=Bt.find(o=>o>t+1e-6)??Yb;Wn(n)}function r4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=Vb;for(let o=Bt.length-1;o>=0;o--)if(Bt[o]<t-1e-6){n=Bt[o];break}Wn(n)}const s4={off:"id",id:"all",all:"off"};function i4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=s4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Qb(){const[e,t]=I.useState(()=>e4());return I.useEffect(()=>{const n=Zb();n==null||n.classList.toggle("hide-grid",!e),t4(e)},[e]),I.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Jb(){const e=J();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:r4,"aria-label":e("view.zoomOut"),children:c.jsx(Pn,{})})})}function ew(){const e=J();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:o4,"aria-label":e("view.zoomIn"),children:c.jsx(Gw,{})})})}function tw(){const e=J(),[t,n]=I.useState(bS);return I.useEffect(()=>wS(n),[]),c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.reset")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:c.jsxs("button",{type:"button",onClick:()=>Wn(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function nw(){const e=J();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.fit")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:Dn,"aria-label":e("view.fit"),children:c.jsx(Hw,{})})})}function ow({grid:e,setGrid:t}){const n=J();return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),c.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:_e(!e&&"text-muted-foreground/60"),children:c.jsx(Dw,{})})})}function rw(){const e=J(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return c.jsx(Ne,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:i4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:_e(t==="off"&&"text-muted-foreground/60"),children:c.jsx(_r,{})})})}function a4({stacked:e}={}){const t=J(),[n,o]=I.useState(!1),[r,s]=Qb(),i=c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:t("view.menu")}),c.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?c.jsx(Ne,{content:i,children:c.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:_e("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[c.jsx(xn,{className:"size-4"}),c.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):c.jsx(Ne,{content:i,children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:c.jsx(xn,{})})});return c.jsx(Hn,{open:n,onOpenChange:o,trigger:a,children:c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx(tw,{}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(Jb,{}),c.jsx(ew,{})]}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(nw,{}),c.jsx(ow,{grid:r,setGrid:s}),c.jsx(rw,{})]})]})})}function l4(){const e=Ve();return Ce(e,"dense")?null:c.jsx(c4,{tier:e})}function c4({tier:e}){const t=Ce(e,"tight"),[n,o]=Qb();return c.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:c.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[c.jsx(Jb,{}),!t&&c.jsx(tw,{}),c.jsx(ew,{}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),c.jsx(nw,{}),c.jsx(ow,{grid:n,setGrid:o}),c.jsx(rw,{})]})})}const Qo=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:Ww,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:Fw,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Pn,switchTo:"busbar"},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:vr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:hr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:_r,switchTo:"text",iconOnly:!0}];function d4(){const e=J(),t=x(u=>u.activeTool),n=x(u=>u.placeKind),o=x(u=>u.placeFromTerminal),r=x(u=>u.wireFromTerminal),s=x(u=>u.busbarDrawStart),i=x(u=>u.selection.length>0||u.selectedNode!=null);let a=null,l=!1;switch(t){case"select":a=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(l=!0);break;case"pan":a=e("mode.pan");break;case"wire":a=e(r?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(s?"mode.busDragging":"mode.busInit"),l=!0;break;case"place":n?o?a=e("mode.placeFromTerm"):a=e("mode.placeNormal"):a=e("mode.placeNoKind"),l=!0;break;case"text":a=e("mode.text"),l=!0;break}if(!a)return null;const d=e(t==="select"?"mode.escSelect":"mode.escOther");return c.jsxs("div",{className:"ole-glass pointer-events-none flex items-center gap-2 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground shadow-sm",children:[c.jsx("span",{children:a}),l&&c.jsxs("span",{className:"text-muted-foreground/70",children:["· ",d]})]})}function u4(){const e=J(),t=x(f=>f.activeTool),n=x(f=>f.placeKind),o=x(f=>f.setActiveTool),r=x(f=>f.past.length),s=x(f=>f.future.length),i=x(f=>f.undo),a=x(f=>f.redo),l=Ve(),d=Ce(l,"tight"),u=!Ce(l,"dense"),m=Ce(l,"dense"),h=m?Qo.filter(f=>f.id!=="select"&&f.id!=="text"):Qo,g=f=>t===f.switchTo;return c.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))"},children:[u&&c.jsx(d4,{}),c.jsxs("div",{className:_e("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",m?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[m&&c.jsx(m4,{stacked:!0}),h.map(f=>{const p=f.icon,b=g(f),k=f.id==="place"&&b&&n==null?e("tool.placeNoKindTooltip"):e(f.descriptionKey);return c.jsxs(I.Fragment,{children:[c.jsx(ot,{icon:p,label:e(f.labelKey),hotkey:f.hotkey,active:b,iconOnly:!m&&(f.iconOnly||d),stacked:m,description:k,onClick:()=>{o(f.switchTo,{placeKind:f.presetPlaceKind!==void 0?f.presetPlaceKind:void 0})}}),f.groupBreakAfter&&!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},f.id)}),!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),m?c.jsx(h4,{stacked:!0}):c.jsxs(c.Fragment,{children:[c.jsx(ot,{icon:Bn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),c.jsx(ot,{icon:On,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),c.jsx(f4,{iconOnly:d})]}),m&&c.jsx(a4,{stacked:!0})]})]})}function m4({stacked:e}){const t=J(),n=St(r=>r.outlineOpen),o=St(r=>r.toggleOutline);return c.jsx(ot,{icon:xr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function ot({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const d=c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:t}),n&&c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&c.jsx("div",{className:"text-muted-foreground",children:l})]});return c.jsx(Ne,{content:d,disabled:r,children:c.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:_e("rounded-md font-medium transition-colors",i?"flex h-12 w-12 flex-col items-center justify-center gap-0.5 text-[10px] leading-tight":"flex h-9 items-center gap-1.5 text-xs",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[c.jsxs("span",{className:"relative inline-flex shrink-0",children:[c.jsx(e,{className:"size-4"}),n&&!i&&c.jsx("span",{"aria-hidden":!0,className:_e("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?c.jsx("span",{className:"max-w-full truncate",children:t}):!s&&c.jsx("span",{children:t})]})})}function sw(){const e=x(r=>r.diagram.elements),t=x(r=>r.diagram.layout),n=x(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function f4({iconOnly:e}){const t=J(),[n,o]=I.useState(!1),r=sw(),s=i=>()=>{o(!1),i()};return c.jsxs(Hn,{open:n,onOpenChange:o,trigger:c.jsx(ot,{icon:bt,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[c.jsx(je,{onClick:s(()=>x.getState().autoArrangeAll()),icon:c.jsx(bt,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(je,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:c.jsx(bt,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:c.jsx(Lt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),c.jsx(je,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(Lt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function h4({stacked:e}){const t=J(),[n,o]=I.useState(!1),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=x(h=>h.selection.length>0),d=x(h=>h.clipboard!=null),u=sw(),m=h=>()=>{o(!1),h()};return c.jsxs(Hn,{open:n,onOpenChange:o,trigger:c.jsx(ot,{icon:xn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(h=>!h)}),children:[c.jsx(je,{onClick:m(i),icon:c.jsx(Bn,{}),disabled:r===0,children:t("tool.undo")}),c.jsx(je,{onClick:m(a),icon:c.jsx(On,{}),disabled:s===0,children:t("tool.redo")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:m(()=>x.getState().cutSelection()),icon:c.jsx(wr,{}),disabled:!l,children:t("menu.cut")}),c.jsx(je,{onClick:m(()=>x.getState().copySelection()),icon:c.jsx(gr,{}),disabled:!l,children:t("menu.copy")}),c.jsx(je,{onClick:m(()=>x.getState().pasteClipboard()),icon:c.jsx(pr,{}),disabled:!d,children:t("menu.paste")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(je,{onClick:m(()=>x.getState().autoArrangeAll()),icon:c.jsx(bt,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(je,{onClick:m(()=>x.getState().autoArrangeSelection()),icon:c.jsx(bt,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),c.jsx(je,{onClick:m(()=>x.getState().fillUnplacedAll()),icon:c.jsx(Lt,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),c.jsx(je,{onClick:m(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(Lt,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function je({children:e,icon:t,onClick:n,disabled:o}){return c.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:_e("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,c.jsx("span",{className:"flex-1",children:e})]})}function p4(){const e=St(r=>r.outlineOpen),t=St(r=>r.setOutlineOpen),n=Ve();return Ce(n,"dense")?e?c.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:c.jsx(Jo,{onClose:()=>t(!1),sheet:!0})}):null:c.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?c.jsx(Jo,{onClose:()=>t(!1)}):c.jsx(g4,{onClick:()=>t(!0)})})}function g4({onClick:e}){const t=J(),n=Ve(),o=Ce(n,"compact");return c.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:_e("ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",o?"w-12 justify-center":"gap-2 px-3"),children:[c.jsx(xr,{className:"size-4 shrink-0"}),!o&&c.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function Jo({onClose:e,sheet:t}){const n=J(),o=x(d=>d.diagram.elements),r=x(d=>d.activeTool==="place"),s=Ve(),i=Ce(s,"compact"),a=Ce(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return c.jsxs("aside",{className:_e("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:l},children:[c.jsxs("button",{type:"button",onClick:e,"aria-label":n("outline.collapseAria"),title:n("outline.collapse"),className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-muted/40",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&c.jsx(x4,{children:o.length}),c.jsx(qw,{className:"size-3.5 text-muted-foreground"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?c.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):c.jsx("ul",{className:"space-y-px",children:o.map(d=>c.jsx(y4,{element:d},d.id))})})]})}function y4({element:e}){const t=Xe[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Ce(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return c.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[c.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&c.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),c.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function x4({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const b4={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},w4={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current","resistor.name":"Resistor (R)","capacitor.name":"Capacitor (C)","diode.name":"Diode (D)","indicator-light.name":"Indicator light (HL)","push-button.name":"Push-button (SB)","relay-coil.name":"Relay coil (KA)","make-contact.name":"NO contact (NO)","break-contact.name":"NC contact (NC)","bell.name":"Bell (HA)","terminal.name":"Terminal / junction (X)","fuse-switch-disconnector.name":"Fuse switch-disconnector","socket-outlet.name":"Socket outlet / connector","inductor.name":"Inductor (L)","voltage-regulator.name":"Voltage regulator (T)","dc-motor.name":"DC motor (M)","heater.name":"Heating element (EH)","selector-switch.name":"Selector switch (SA)","limit-switch.name":"Limit switch (SQ)","proximity-switch.name":"Proximity switch (SQ)","time-relay.name":"Time relay (KT)","buzzer.name":"Buzzer (HA)","siren.name":"Siren (HA)","thermocouple.name":"Thermocouple (BT)","thyristor.name":"Thyristor / SCR (V)","triac.name":"Triac (V)","zener-diode.name":"Zener diode (D)","igbt.name":"IGBT","plc.name":"PLC / controller","ups.name":"UPS","power-supply.name":"Power supply (PS)","genset.name":"Generator set (G)","protective-relay.name":"Protective relay","overcurrent-relay.name":"Overcurrent relay (50/51)","undervoltage-relay.name":"Undervoltage relay (27)","reverse-power-relay.name":"Reverse-power relay (32)","distance-relay.name":"Distance relay (21)","phase-failure-relay.name":"Phase-failure relay","buchholz-relay.name":"Buchholz relay (63)","power-factor-meter.name":"Power-factor meter (cosφ)","synchronoscope.name":"Synchronoscope","varmeter.name":"Varmeter (var)","resistor.desc":"General resistor / current-limiting / braking resistor.","capacitor.desc":"General / filter / DC-bus capacitor. Use shunt capacitor for PF correction.","diode.desc":"Rectifier / freewheeling / protection diode. t1 = anode (top), t2 = cathode (bottom).","indicator-light.desc":"Signal / status indicator light.","push-button.desc":"Manual push-button, automatic return (NO make).","relay-coil.desc":"Relay / contactor operating coil (box).","make-contact.desc":"Normally-open auxiliary contact (make).","break-contact.desc":"Normally-closed auxiliary contact (break).","bell.desc":"Signal bell / alarm bell.","terminal.desc":"Terminal / junction box / connection node.","fuse-switch-disconnector.desc":"On-load fuse switch-disconnector.","socket-outlet.desc":"Power socket outlet / multipole connector.","inductor.desc":"General inductor / coil / choke.","voltage-regulator.desc":"Adjustable induction / autotransformer voltage regulator.","dc-motor.desc":"DC motor (series-field general symbol).","heater.desc":"Resistive heating element / heating load.","selector-switch.desc":"Selector / changeover switch (rotary, stay-put).","limit-switch.desc":"Travel / position switch (NO, mechanically operated).","proximity-switch.desc":"Proximity sensor / contactless proximity switch.","time-relay.desc":"Time-delay (slow-operating) relay coil.","buzzer.desc":"Signal buzzer.","siren.desc":"Audible siren / alarm.","thermocouple.desc":"Thermocouple temperature sensor.","thyristor.desc":"Reverse-blocking triode thyristor / SCR. t1 = anode (top), t2 = cathode (bottom).","triac.desc":"Bidirectional triode thyristor (TRIAC).","zener-diode.desc":"Zener / voltage-regulator diode. t1 = anode (top), t2 = cathode (bottom).","igbt.desc":"N-channel enhancement IGBT. t1 = collector (top), t2 = emitter (bottom), t_g = gate.","plc.desc":"Programmable logic controller (PLC).","ups.desc":"Online / standby uninterruptible power supply.","power-supply.desc":"AC→DC switched-mode / DC power supply. t_ac top (~), t_dc bottom (=).","genset.desc":"Diesel / gas generator set.","protective-relay.desc":"Measuring / protective relay, general symbol (IEC 60617).","overcurrent-relay.desc":"Overcurrent protection relay (ANSI 50/51).","undervoltage-relay.desc":"Undervoltage protection relay (ANSI 27).","reverse-power-relay.desc":"Reverse-power / reverse-current protection relay (ANSI 32).","distance-relay.desc":"Distance / under-impedance protection relay (ANSI 21).","phase-failure-relay.desc":"Phase-failure / phase-loss protection relay.","buchholz-relay.desc":"Buchholz / gas relay (ANSI 63).","power-factor-meter.desc":"Power-factor meter (cosφ).","synchronoscope.desc":"Synchronizing indicator / synchronoscope.","varmeter.desc":"Reactive-power meter (var).","make-contact.state.closed":"Closed","break-contact.state.open":"Open","fuse-switch-disconnector.state.open":"Open","selector-switch.state.open":"Open","limit-switch.state.closed":"Closed","resistor.param.R":"Resistance","resistor.param.P":"Rated power","capacitor.param.C":"Capacitance","capacitor.param.Un":"Rated voltage","indicator-light.param.color":"Color","inductor.param.L":"Inductance","inductor.param.In":"Rated current","voltage-regulator.param.ratio":"Regulation range","heater.param.P":"Power","ups.param.S":"Capacity","power-supply.param.Vdc":"Output voltage","genset.param.P":"Power"},er={zh:b4,en:w4};function v4(e,t){return er[e][t]??er.zh[t]}function Et(){const e=jt(t=>t.locale);return(t,n)=>v4(e,t)??n??t}const iw="ole-palette-collapsed",k4=new Set(["busbar"]),kt=(()=>{const e={};for(const[t,n]of Object.entries(r$)){const o=n.filter(r=>!k4.has(r.id));o.length&&(e[t]=o)}return e})(),_4=(()=>{const e=new Set(No),t=Object.keys(kt).filter(n=>!e.has(n));return[...No.filter(n=>{var o;return(o=kt[n])==null?void 0:o.length}),...t]})();function $4(){try{const e=window.localStorage.getItem(iw);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function S4(e){try{window.localStorage.setItem(iw,JSON.stringify([...e]))}catch{}}function j4(){const e=J(),t=x(m=>m.activeTool==="place"),n=x(m=>m.placeKind),o=x(m=>m.setActiveTool),r=St(m=>m.outlineOpen),s=Ve(),i=Ce(s,"dense"),a=68,d=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:a};return c.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:c.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:d?{maxHeight:d}:void 0,children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),c.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:c.jsx(Ln,{className:"size-3.5"})})]}),c.jsx(E4,{sheet:i})]})})}function E4({sheet:e}){const t=J(),n=Et(),[o,r]=I.useState(""),[s,i]=I.useState(()=>$4()),a=I.useMemo(()=>{const m=o.trim().toLowerCase();if(!m)return kt;const h={};for(const[g,f]of Object.entries(kt)){const p=f.filter(b=>{const k=n(`${b.id}.name`,b.name).toLowerCase(),v=n(`${b.id}.desc`,b.description??"").toLowerCase();return k.includes(m)||b.id.toLowerCase().includes(m)||v.includes(m)});p.length&&(h[g]=p)}return h},[o,n]),l=o.trim().length>0,d=l&&Object.values(a).every(m=>!(m!=null&&m.length)),u=I.useCallback((m,h)=>{i(g=>{const f=new Set(g);return h?f.delete(m):f.add(m),S4(f),f})},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-2 pb-1.5 pt-2",children:c.jsx(N4,{value:o,onChange:r})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:d?c.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):_4.map(m=>{var b;const h=a[m];if(!(h!=null&&h.length))return null;const g=((b=kt[m])==null?void 0:b.length)??h.length,f=t(`cat.${m}`),p=l||!s.has(m);return c.jsxs("details",{open:p,className:"group mb-2 last:mb-0",onToggle:k=>{l||u(m,k.currentTarget.open)},children:[c.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:[c.jsx(Pw,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),c.jsx("span",{className:"flex-1",children:f}),c.jsx(T4,{children:l&&h.length!==g?`${h.length}/${g}`:g})]}),c.jsx("ul",{className:"mt-0.5 space-y-px",children:h.map(k=>c.jsx(M4,{entry:k,sheet:e},k.id))})]},m)})})]})}function N4({value:e,onChange:t}){const n=J();return c.jsxs("div",{className:"relative",children:[c.jsx(Kw,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),c.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&c.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Ln,{className:"size-3"})})]})}function M4({entry:e,sheet:t}){const n=J(),o=Et(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(m=>m.setActiveTool),a=x(m=>m.activeTool==="place"&&m.placeKind===e.id),l=x(m=>t&&m.activeTool==="place"&&m.placeKind==null&&m.lastPlaceKind===e.id),d=I.useRef(null);I.useEffect(()=>{var m;l&&((m=d.current)==null||m.scrollIntoView({block:"nearest"}))},[l]);const u=m=>{m.dataTransfer.effectAllowed="copy",m.dataTransfer.setData("application/x-oneline-kind",e.id),m.dataTransfer.setData("text/plain",e.id);const h=document.createElement("div");h.className="ole-glass",h.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),h.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(h),m.dataTransfer.setDragImage(h,32,32),setTimeout(()=>h.remove(),0)};return c.jsxs("li",{ref:d,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[c.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:c.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),c.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function T4({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const Cn="ole-onboarding-dismissed";function A4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Cn)==="1"}catch{return!1}}function tr(e){try{e?window.localStorage.setItem(Cn,"1"):window.localStorage.removeItem(Cn)}catch{}}const nr=qt(e=>({dismissed:A4(),dismiss:()=>{tr(!0),e({dismissed:!0})},reset:()=>{tr(!1),e({dismissed:!1})}}));function C4(){const e=J(),t=nr(o=>o.dismissed),n=nr(o=>o.dismiss);return t?null:c.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),c.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Ln,{className:"size-3.5"})})]}),c.jsxs("ol",{className:"mt-3 space-y-2.5",children:[c.jsx(gn,{n:1,icon:c.jsx(Pn,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),c.jsx(gn,{n:2,icon:c.jsx(vr,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),c.jsx(gn,{n:3,icon:c.jsx(hr,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),c.jsx("button",{type:"button",onClick:n,className:"pointer-events-auto mt-4 w-full rounded-md bg-primary py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("onboard.dismiss")})]})}function gn({n:e,icon:t,title:n,body:o}){return c.jsxs("li",{className:"flex items-start gap-2.5",children:[c.jsx("span",{className:"mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklch,var(--selection)_18%,transparent)] font-mono text-[10px] font-semibold tabular-nums text-[var(--selection)]","aria-hidden":!0,children:e}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[c.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),c.jsx("span",{children:n})]}),c.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function I4(){const e=J(),t=x(u=>u.selection),n=x(u=>u.diagram.elements),o=x(u=>u.diagram.buses),r=x(u=>u.selectedNode),s=x(u=>u.selectedWire);if(s)return c.jsx(R4,{wireId:s});if(r)return c.jsx(D4,{nodeId:r});if(t.length===0)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const i=t[0],a=(o??[]).find(u=>u.id===i);if(a)return c.jsx(L4,{bus:a});const l=n.find(u=>u.id===i);if(!l)return null;const d=Xe[l.kind];return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(Nt,{label:e("props.name"),value:l.name??"",placeholder:l.id,onCommit:u=>x.getState().updateElement(i,{name:u.trim()===""?void 0:u.trim()})}),c.jsx(aw,{label:e("props.note"),value:l.note??"",onCommit:u=>x.getState().updateElement(i,{note:u.trim()===""?void 0:u.trim()})}),(d==null?void 0:d.state)&&d.state.length>0&&c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.state.map(u=>c.jsx(F4,{id:i,element:l,field:u},u.name))}),c.jsx(P4,{id:i,element:l,schema:(d==null?void 0:d.params)??[]})]})}function P4({id:e,element:t,schema:n}){const o=new Set(n.map(s=>s.name)),r=t.params?Object.entries(t.params).filter(([s])=>!o.has(s)):[];return n.length===0&&r.length===0?null:c.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>c.jsx(O4,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>c.jsx(B4,{id:e,element:t,fieldKey:s,value:i},s))]})}function O4({id:e,element:t,field:n}){var l;const o=J(),r=Et(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=d=>{const u={...t.params??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(at,{label:i,children:c.jsx(qn,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Ut,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):c.jsx(Nt,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:d=>a(d.trim()===""?void 0:d)})}function B4({id:e,element:t,fieldKey:n,value:o}){const r=J(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,x.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?c.jsx(at,{label:n,children:c.jsx(qn,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?c.jsx(Ut,{label:n,value:o,onCommit:s}):c.jsx(Nt,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function L4({bus:e}){const t=J(),n=e.id,o=r=>{const s=r.trim();In(n,{name:s===""?void 0:s})};return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(Nt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),c.jsx(aw,{label:t("props.note"),value:e.note??"",onCommit:r=>In(n,{note:r.trim()===""?void 0:r.trim()})}),c.jsx(z4,{bus:e})]})}function z4({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,In(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:c.jsx(Ut,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function In(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function R4({wireId:e}){const t=J(),n=x(f=>f.diagram.wires),o=x(f=>f.diagram.elements),r=x(f=>f.diagram.buses),s=x(f=>f.internal.terminalToNode),i=x(f=>f.setSelectedNode),a=(n??[]).find(f=>f.id===e);if(!a)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const l=s.get(a.ends[0]),d=new Map(o.map(f=>[f.id,f])),u=new Map((r??[]).map(f=>[f.id,f])),m=f=>{if(!f.includes(".")){const N=u.get(f);return{id:f,label:(N==null?void 0:N.name)??f}}const p=f.indexOf("."),b=f.slice(0,p),k=f.slice(p+1),v=d.get(b);return{id:b,label:(v==null?void 0:v.name)??b,pin:k}},h=m(a.ends[0]),g=m(a.ends[1]);return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),c.jsx("div",{className:"font-mono text-[12px]",children:a.id})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((f,p)=>c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([f.id]),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:f.id}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:f.label}),f.pin&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:f.pin})]},p))}),l&&c.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>i(l),children:t("props.selectWholeNode")})]})}function D4({nodeId:e}){const t=J(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const d=a.slice(0,l),u=a.slice(l+1),m=s.get(d)??[];m.push(u),s.set(d,m)}const i=new Map(o.map(a=>[a.id,a]));return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),c.jsx("div",{className:"font-mono text-[12px]",children:n.id}),c.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const d=i.get(a);return c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(d==null?void 0:d.name)??""}),c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function at({label:e,children:t}){return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),c.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Nt({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>i(t),[t]),c.jsx(at,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:_e("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function aw({label:e,value:t,onCommit:n}){const[o,r]=I.useState(t);return I.useEffect(()=>r(t),[t]),c.jsx(at,{label:e,children:c.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function Ut({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=I.useState(String(t)),a=I.useRef(null);return I.useEffect(()=>i(String(t)),[t]),c.jsx(at,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:_e("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 font-mono text-[11px] tabular-nums focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function qn({active:e,onClick:t,children:n}){return c.jsx("button",{type:"button",onClick:t,className:_e("flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",e?"border-[var(--selection)] bg-[var(--selection)]/15 text-foreground":"border-border/60 text-muted-foreground hover:bg-accent"),"aria-pressed":e,children:n})}function F4({id:e,element:t,field:n}){var l;const o=J(),s=Et()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=d=>{const u={...t.state??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(at,{label:s,children:c.jsx(qn,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Ut,{label:s,value:typeof i=="number"?i:0,onCommit:a}):c.jsx(Nt,{label:s,value:typeof i=="string"?i:"",onCommit:d=>a(d.trim()===""?void 0:d)})}function H4(){const e=J(),t=Et(),n=x(m=>m.selection),o=x(m=>m.selectedNode),r=x(m=>m.selectedWire),s=x(m=>m.diagram.elements),i=x(m=>m.diagram.buses),a=Ve(),l=Ce(a,"dense");if(n.length===0&&!o&&!r)return null;let d=e("props.title"),u=null;if(r)d=e("props.wire");else if(o)d=e("props.node");else if(n.length===1){const m=n[0],h=(i??[]).find(g=>g.id===m);if(h)d=h.name??e("props.bus");else{const g=s.find(f=>f.id===m);if(g){const f=Xe[g.kind];d=f?t(`${f.id}.name`,f.name):g.kind}}}else u=n.length;return c.jsxs("aside",{className:_e("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",l?"w-48":"w-56"),style:{top:`calc(${l?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:d}),u!=null&&c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e("props.nSelected",{n:u})})]}),c.jsx(I4,{})]})}function W4(){I.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function q4(){W4();const e=I.useRef(null),t=dS(e);return c.jsx(Nv,{children:c.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:c.jsxs(LS,{width:t,children:[c.jsx(ES,{}),c.jsx(p4,{}),c.jsx(H4,{}),c.jsx(u4,{}),c.jsx(l4,{}),c.jsx(QS,{}),c.jsx(j4,{}),c.jsx(C4,{}),c.jsx(OS,{})]})})})}const G4="ole-theme";function K4(){try{const e=window.localStorage.getItem(G4);return e==="light"||e==="dark"?e:null}catch{return null}}function X4(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function V4(){return typeof window>"u"?"light":K4()??(X4()?"dark":"light")}function lw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Y4({className:e,diagram:t,locale:n,theme:o}){return I.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),I.useEffect(()=>{n&&jt.getState().setLocale(n)},[n]),I.useEffect(()=>{o&&lw(o)},[o]),I.useEffect(()=>{Fn()},[]),Y$(),c.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:c.jsx(q4,{})})}const cw={"application/json":[".json"]},dw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",uw=e=>e instanceof DOMException&&e.name==="AbortError";function or(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(ke("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(ke("io.notObject"));const n=t;if(n.version!=="1")throw new Error(ke("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(ke("io.elementsMissing"));return n}function U4(e){return JSON.stringify(e,null,2)+`
|
|
194
|
+
`}async function Z4(){if(dw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:ke("topbar.file.fileDescription"),accept:cw}]})}catch(n){if(uw(n))return null;throw n}const t=await e.getFile();return{diagram:or(await t.text()),session:{handle:e,name:t.name}}}return new Promise((e,t)=>{const n=document.createElement("input");n.type="file",n.accept=".json,application/json",n.addEventListener("change",async()=>{var r;const o=(r=n.files)==null?void 0:r[0];if(!o)return e(null);try{e({diagram:or(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function rr(e,t,n={}){const o=U4(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(dw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:ke("topbar.file.fileDescription"),accept:cw}]})}catch(l){if(uw(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const r=URL.createObjectURL(new Blob([o],{type:"application/json"})),s=document.createElement("a");return s.href=r,s.download=(t==null?void 0:t.name)??"diagram.json",s.click(),URL.revokeObjectURL(r),t??{name:"diagram.json"}}function Q4(){const e=J(),t=x(m=>m.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=J4(),[a,l]=I.useState(!1),d=I.useRef(null);I.useEffect(()=>{const m=h=>{if(!(h.metaKey||h.ctrlKey))return;const g=h.key.toLowerCase();g==="o"?(h.preventDefault(),r()):g==="s"&&(h.preventDefault(),h.shiftKey?i():s())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,s,i]),I.useEffect(()=>{if(!a)return;const m=g=>{d.current&&!d.current.contains(g.target)&&l(!1)},h=g=>{g.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",m),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",m),window.removeEventListener("keydown",h)}},[a]);const u=m=>()=>{l(!1),m()};return c.jsxs("div",{ref:d,className:"relative",children:[c.jsxs(Ee,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(m=>!m),children:[c.jsx(lo,{}),e("topbar.file.label")]}),a&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-44 rounded-md border border-border p-1 shadow-md",children:[c.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),c.jsx(Pt,{onClick:u(o),icon:c.jsx(zw,{}),children:e("topbar.file.new")}),c.jsx(Pt,{onClick:u(r),icon:c.jsx(lo,{}),hint:"⌘O",children:e("topbar.file.open")}),c.jsx(Pt,{onClick:u(s),icon:c.jsx(co,{}),hint:"⌘S",children:e("topbar.file.save")}),c.jsx(Pt,{onClick:u(i),icon:c.jsx(co,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function Pt({children:e,icon:t,hint:n,onClick:o}){return c.jsxs("button",{type:"button",role:"menuitem",onClick:o,className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[t,c.jsx("span",{className:"flex-1",children:e}),n&&c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function J4(){const e=J(),t=x(l=>l.loadDiagramFromFile),n=x(l=>l.setFileSession),o=x(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=x.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await Z4();l&&(t(l.diagram,l.session),Fn())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:d}=x.getState(),u=await rr(l,d);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:d}=x.getState(),u=await rr(l,d,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const yn="WIRES",ze="ELEMENTS",sr="LABELS",ir="ANNOTATIONS",ar=32,lr=64,e6=8,t6=1.25,n6=6;function mw(e,t={}){const n=new p6(t.precision??6);n.header(t.title),n.tables([{name:yn,color:7},{name:ze,color:7},{name:sr,color:8},{name:ir,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(yn,r.path.map(Me),!1);for(const{geometry:r}of e.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,d=s==="x"?[i[0]-l,i[1]]:[i[0],i[1]-l],u=s==="x"?[i[0]+l,i[1]]:[i[0],i[1]+l];n.lwpolyline(yn,[d,u].map(Me),!1)}for(const r of e.elements.values()){const s=e.layout.get(r.element.id),i=r.libraryDef;!s||!i||o6(n,i.svg,s)}const o=t.labelMode??"all";if(o!=="off")for(const r of e.elements.values()){const s=e.layout.get(r.element.id);if(!s||!r.libraryDef)continue;const i=Kt(r,o);if(i.length===0)continue;const a=r.libraryDef.label??Xt(r.libraryDef),[l,d]=Vt(a,s);for(let u=0;u<i.length;u++){const[m,h]=Me([l,d+u*Gt]);n.text(sr,[m,h],i[u],Dt,0,!1)}}for(const r of t.annotations??[]){if(!r.text)continue;const s=r.fontSize??e6,i=r.text.split(`
|
|
195
|
+
`);for(let a=0;a<i.length;a++){const[l,d]=Me([r.at[0],r.at[1]+(a+1)*s*t6]);n.text(ir,[l,d],i[a],s,0,!1)}}return n.endEntities(),n.toString()}async function fw(e,t="diagram.dxf",n){const o=mw(e,n),r=URL.createObjectURL(new Blob([o],{type:"application/dxf;charset=utf-8"})),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}function o6(e,t,n){const o=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,s=new DOMParser().parseFromString(o,"image/svg+xml").documentElement;if(!(!s||s.querySelector("parsererror")))for(const i of Array.from(s.children))switch(i.tagName.toLowerCase()){case"line":r6(e,i,n);break;case"polyline":cr(e,i,n,!1);break;case"polygon":cr(e,i,n,!0);break;case"rect":s6(e,i,n);break;case"circle":i6(e,i,n);break;case"ellipse":a6(e,i,n);break;case"path":u6(e,i,n);break;case"text":d6(e,i,n);break}}function r6(e,t,n){const o=ye(t,"x1"),r=ye(t,"y1"),s=ye(t,"x2"),i=ye(t,"y2"),a=Me(Le([o,r],n)),l=Me(Le([s,i],n));e.line(ze,a,l)}function cr(e,t,n,o){const r=h6(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>Me(Le(i,n)));e.lwpolyline(ze,s,o)}function s6(e,t,n){const o=ye(t,"x"),r=ye(t,"y"),s=ye(t,"width"),i=ye(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(d=>Me(Le(d,n)));e.lwpolyline(ze,l,!0)}function i6(e,t,n){const o=ye(t,"cx"),r=ye(t,"cy"),s=ye(t,"r"),i=Me(Le([o,r],n));e.circle(ze,i,s)}function a6(e,t,n){const o=ye(t,"cx"),r=ye(t,"cy"),s=ye(t,"rx"),i=ye(t,"ry");if(Math.abs(s-i)<1e-6){l6(e,o,r,s,n);return}c6(e,o,r,s,i,n)}function l6(e,t,n,o,r){const s=Me(Le([t,n],r));e.circle(ze,s,o)}function c6(e,t,n,o,r,s){const i=[];for(let a=0;a<lr;a++){const l=a/lr*Math.PI*2;i.push(Me(Le([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(ze,i,!0)}function d6(e,t,n){const o=ye(t,"x"),r=ye(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||n6,i=(t.textContent??"").trim();if(!i)return;const a=Me(Le([o,r],n));e.text(ze,a,i,s,n.rot,n.mirror)}function u6(e,t,n){const o=t.getAttribute("d")??"",r=m6(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(ze,i.map(l=>Me(Le(l,n))),!1),i=[]};for(const l of r)if(l.cmd==="M")a(),s=[l.args[0],l.args[1]],i.push(s);else if(l.cmd==="A"&&s){const[d,u,,m,h,g,f]=l.args,p=f6(s,[g,f],d,u,m!==0,h!==0);if(p)for(let b=1;b<=ar;b++){const k=p.theta1+p.delta*b/ar;i.push([p.cx+d*Math.cos(k),p.cy+u*Math.sin(k)])}else i.push([g,f]);s=[g,f]}a()}function m6(e){const t=[],n=/([MmAa])([^MmAa]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1].toUpperCase(),s=o[2].trim().split(/[\s,]+/).filter(i=>i.length>0).map(Number);t.push({cmd:r,args:s})}return t}function f6(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,d]=t;if(i===l&&a===d)return null;const u=(i-l)/2,m=(a-d)/2;let h=Math.abs(n),g=Math.abs(o);const f=h*h,p=g*g,b=u*u/f+m*m/p;if(b>1){const D=Math.sqrt(b);h*=D,g*=D}const k=r===s?-1:1,v=h*h*g*g-h*h*m*m-g*g*u*u,N=h*h*m*m+g*g*u*u,A=k*Math.sqrt(Math.max(0,v/N)),R=A*(h*m)/g,F=A*-(g*u)/h,te=R+(i+l)/2,ee=F+(a+d)/2,xe=(D,oe,re,ue)=>{const U=D*re+oe*ue,me=Math.hypot(D,oe)*Math.hypot(re,ue);let pe=Math.acos(Math.max(-1,Math.min(1,U/me)));return D*ue-oe*re<0&&(pe=-pe),pe},fe=xe(1,0,(u-R)/h,(m-F)/g);let B=xe((u-R)/h,(m-F)/g,(-u-R)/h,(-m-F)/g);return!s&&B>0?B-=2*Math.PI:s&&B<0&&(B+=2*Math.PI),{cx:te,cy:ee,theta1:fe,delta:B}}function Le(e,t){return Ae(e,t)}function Me(e){return[e[0],-e[1]]}function ye(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function h6(e){const t=e.trim().split(/[\s,]+/).map(Number).filter(o=>Number.isFinite(o)),n=[];for(let o=0;o+1<t.length;o+=2)n.push([t[o],t[o+1]]);return n}class p6{constructor(t){dt(this,"out",[]);dt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
|
|
196
196
|
${this.fmt(n)}
|
|
197
|
-
`)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,
|
|
198
|
-
`);for(let p=0;p<f.length;p++){const
|
|
199
|
-
`)}function
|
|
200
|
-
`),m=
|
|
197
|
+
`)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,dr(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i){this.g(0,"TEXT"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,dr(o)),s!==0&&this.g(50,s),i&&this.g(71,2)}}function dr(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const g6="http://www.w3.org/2000/svg",Ot=24,hw=8,pw=1.25;function Gn(e,t={}){const n=y6(e,t),o=Math.floor(n.minX-Ot),r=Math.floor(n.minY-Ot),s=Math.ceil(n.maxX+Ot)-o,i=Math.ceil(n.maxY+Ot)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${g6}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${yt(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const m of e.wireRenders.values()){if(m.path.length<2)continue;const h=m.path.map(([g,f])=>`${g},${f}`).join(" ");l.push(` <polyline points="${h}"/>`)}l.push(" </g>");for(const{bus:m,geometry:h}of e.buses.values()){const{axis:g,at:f,span:p}=h,b=p/2,k=g==="x"?f[0]-b:f[0],v=g==="x"?f[1]:f[1]-b,N=g==="x"?f[0]+b:f[0],A=g==="x"?f[1]:f[1]+b;l.push(` <line id="${yt(m.id)}" x1="${k}" y1="${v}" x2="${N}" y2="${A}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const m of e.elements.values()){if(!m.libraryDef)continue;const h=e.layout.get(m.element.id);h&&(l.push(` <g id="${yt(m.element.id)}" transform="${Ke(h)}">`),l.push(` ${m.libraryDef.svg}`),l.push(" </g>"))}const d=t.labelMode??"all";if(d!=="off"){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Dt}" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const h of e.elements.values()){const g=e.layout.get(h.element.id);if(!g||!h.libraryDef)continue;const f=Kt(h,d);if(f.length===0)continue;const p=h.libraryDef.label??Xt(h.libraryDef),[b,k]=Vt(p,g),v=p.anchor??"start";for(let N=0;N<f.length;N++)l.push(` <text x="${b}" y="${k+N*Gt}" text-anchor="${v}">${yt(f[N])}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const h of u){if(!h.text)continue;const g=h.fontSize??hw,f=h.text.split(`
|
|
198
|
+
`);for(let p=0;p<f.length;p++){const b=h.at[1]+g*.85+p*g*pw;l.push(` <text x="${h.at[0]}" y="${b}" font-size="${g}">${yt(f[p])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
|
|
199
|
+
`)}function y6(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(l,d)=>{l<n&&(n=l),l>r&&(r=l),d<o&&(o=d),d>s&&(s=d)};for(const l of e.terminals.values())i(l.world[0],l.world[1]);for(const l of e.elements.values()){const d=e.layout.get(l.element.id),u=l.libraryDef;if(!d||!u)continue;const m=x6(u.viewBox);if(!m){i(d.at[0],d.at[1]);continue}const h=[[m.x,m.y],[m.x+m.w,m.y],[m.x,m.y+m.h],[m.x+m.w,m.y+m.h]];for(const g of h){const[f,p]=Ae(g,d);i(f,p)}}for(const{geometry:l}of e.buses.values()){const{axis:d,at:u,span:m}=l,h=m/2;d==="x"?(i(u[0]-h,u[1]),i(u[0]+h,u[1])):(i(u[0],u[1]-h),i(u[0],u[1]+h))}for(const l of e.wireRenders.values())for(const[d,u]of l.path)i(d,u);const a=t.labelMode??"all";if(a!=="off")for(const l of e.elements.values()){const d=e.layout.get(l.element.id);if(!d||!l.libraryDef)continue;const u=Kt(l,a);if(u.length===0)continue;const m=l.libraryDef.label??Xt(l.libraryDef),[h,g]=Vt(m,d),f=ur(u,Dt),p=u.length*Gt,b=m.anchor??"start",k=b==="middle"?h-f/2:b==="end"?h-f:h;i(k,g-Dt),i(k+f,g+p)}for(const l of t.annotations??[]){if(!l.text)continue;const d=l.fontSize??hw,u=l.text.split(`
|
|
200
|
+
`),m=ur(u,d),h=u.length*d*pw;i(l.at[0],l.at[1]),i(l.at[0]+m,l.at[1]+h)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function ur(e,t){let n=0;for(const o of e){const r=o.length*t*.55;r>n&&(n=r)}return Math.max(20,n)}function x6(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function yt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function gw(e,t="diagram.svg",n){const o=Gn(e,n);xw(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function yw(e,t="diagram.png",n){const o=Gn(e,n),r=(n==null?void 0:n.scale)??2,s=URL.createObjectURL(new Blob([o],{type:"image/svg+xml;charset=utf-8"}));try{const i=await b6(s),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*r),a.height=Math.round(i.naturalHeight*r);const l=a.getContext("2d");if(!l)throw new Error("canvas 2d context unavailable");n!=null&&n.background&&n.background!=="transparent"&&(l.fillStyle=n.background,l.fillRect(0,0,a.width,a.height)),l.drawImage(i,0,0,a.width,a.height);const d=await new Promise((u,m)=>{a.toBlob(h=>h?u(h):m(new Error("toBlob failed")),"image/png")});xw(d,t)}finally{URL.revokeObjectURL(s)}}function b6(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>n(new Error("failed to load SVG into image")),o.src=e})}function xw(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function w6(){const e=J(),[t,n]=I.useState(!1),o=I.useRef(null);I.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var m,h,g,f;n(!1);const{internal:i,diagram:a,fileSession:l}=x.getState(),d=((m=l==null?void 0:l.name)==null?void 0:m.replace(/\.json$/i,""))??((h=a.meta)==null?void 0:h.title)??"diagram",u={title:(g=a.meta)==null?void 0:g.title,labelMode:(f=a.meta)==null?void 0:f.labelMode,annotations:a.annotations};s==="svg"?gw(i,`${d}.svg`,u):s==="png"?yw(i,`${d}.png`,{...u,scale:2}).catch(p=>{console.error(p),alert(e("topbar.export.pngFailed",{err:p.message}))}):fw(i,`${d}.dxf`,u).catch(p=>{console.error(p),alert(e("topbar.export.dxfFailed",{err:p.message}))})};return c.jsxs("div",{ref:o,className:"relative",children:[c.jsxs(Ee,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[c.jsx(Ow,{}),e("topbar.export.label")]}),t&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Rw,{}),c.jsx("span",{className:"flex-1",children:"SVG"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Lw,{}),c.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Bw,{}),c.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=w6;exports.FileMenu=Q4;exports.LIBRARY=_n;exports.OneLineEditor=Y4;exports.applyTheme=lw;exports.buildExportDxf=mw;exports.buildExportSvg=Gn;exports.compile=qe;exports.downloadDxf=fw;exports.downloadPng=yw;exports.downloadSvg=gw;exports.emptyInternalModel=Lr;exports.fitToContent=Dn;exports.fitToContentSoon=Fn;exports.getInitialTheme=V4;exports.getLibraryEntry=Tb;exports.newBusId=$n;exports.newElementId=_t;exports.orientationVec=kn;exports.resolvePlacement=zr;exports.transformOrientation=wt;exports.transformPoint=Ae;exports.useEditorStore=x;exports.useLocale=jt;exports.wireIdFromEnds=$t;
|
|
201
201
|
//# sourceMappingURL=sldeditor.cjs.map
|