sldeditor 0.10.0 → 0.10.1
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/sldeditor.cjs +46 -46
- package/dist/sldeditor.cjs.map +1 -1
- package/dist/sldeditor.js +3599 -3584
- package/dist/sldeditor.js.map +1 -1
- package/dist/store/prune-junctions.d.ts +13 -0
- package/dist/store/prune-junctions.d.ts.map +1 -0
- package/dist/store/store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/sldeditor.cjs
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Jw=Object.defineProperty;var Zw=(e,t,n)=>t in e?Jw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pt=(e,t,n)=>Zw(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),O=require("react"),Or=require("react-dom");function Qw(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 ke=Qw(O);/**
|
|
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 ev=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Br=(...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 tv={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 nv=O.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>O.createElement("svg",{ref:l,...tv,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Br("lucide",r),...a},[...i.map(([c,f])=>O.createElement(c,f)),...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 re=(e,t)=>{const n=O.forwardRef(({className:o,...r},s)=>O.createElement(
|
|
21
|
+
*/const re=(e,t)=>{const n=O.forwardRef(({className:o,...r},s)=>O.createElement(nv,{ref:s,iconNode:t,className:Br(`lucide-${ev(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 Lr=re("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 ov=re("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 rv=re("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
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 zr=re("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"}]]);/**
|
|
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 Rr=re("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"}]]);/**
|
|
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 sv=re("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"}]]);/**
|
|
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 An=re("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"}]]);/**
|
|
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 iv=re("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"}]]);/**
|
|
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 av=re("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"}]]);/**
|
|
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 lv=re("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"}]]);/**
|
|
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 cv=re("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"}]]);/**
|
|
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 Dr=re("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"}]]);/**
|
|
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 Mo=re("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"}]]);/**
|
|
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 dv=re("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"}]]);/**
|
|
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 uv=re("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"}]]);/**
|
|
97
97
|
* @license lucide-react v0.469.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
@@ -103,87 +103,87 @@
|
|
|
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 Fr=re("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"}]]);/**
|
|
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 fv=re("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"}]]);/**
|
|
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 Vn=re("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
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 mv=re("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"}]]);/**
|
|
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 hv=re("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"}]]);/**
|
|
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 pv=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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 Un=re("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"}]]);/**
|
|
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 Hr=re("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"}]]);/**
|
|
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 To=re("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"}]]);/**
|
|
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 Wr=re("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"}]]);/**
|
|
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 gv=re("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
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 qr=re("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"}]]);/**
|
|
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 yv=re("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"}]]);/**
|
|
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 xv=re("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"}]]);/**
|
|
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 Gr=re("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"}]]);/**
|
|
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 Xr=re("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"}]]);/**
|
|
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 Jn=re("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"}]]);/**
|
|
187
187
|
* @license lucide-react v0.469.0 - ISC
|
|
188
188
|
*
|
|
189
189
|
* This source code is licensed under the ISC license.
|
|
@@ -193,14 +193,14 @@
|
|
|
193
193
|
*
|
|
194
194
|
* This source code is licensed under the ISC license.
|
|
195
195
|
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const Jn=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Xr(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=Xr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Yr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Xr(e))&&(o&&(o+=" "),o+=t);return o}const Zn="-",xv=e=>{const t=wv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Zn);return a[0]===""&&a.length!==1&&a.shift(),Kr(a,t)||bv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Kr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Kr(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},To=/^\[(.+)\]$/,bv=e=>{if(To.test(e)){const t=To.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},wv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return kv(Object.entries(e.classGroups),n).forEach(([s,i])=>{An(i,o,s,t)}),o},An=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:Ao(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(vv(r)){An(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{An(i,Ao(t,s),n,o)})})},Ao=(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},vv=e=>e.isThemeGetter,kv=(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,_v=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)}}},Vr="!",$v=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,u=0,f;for(let b=0;b<a.length;b++){let $=a[b];if(c===0){if($===r&&(o||a.slice(b,b+s)===t)){l.push(a.slice(u,b)),u=b+s;continue}if($==="/"){f=b;continue}}$==="["?c++:$==="]"&&c--}const m=l.length===0?a:a.substring(u),p=m.startsWith(Vr),h=p?m.substring(1):m,g=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:g}};return n?a=>n({className:a,parseClassName:i}):i},Sv=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},jv=e=>({cache:_v(e.cacheSize),parseClassName:$v(e),...xv(e)}),Ev=/\s+/,Nv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(Ev);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:p}=n(c);let h=!!p,g=o(h?m.substring(0,p):m);if(!g){if(!h){a=c+(a.length>0?" "+a:a);continue}if(g=o(m),!g){a=c+(a.length>0?" "+a:a);continue}h=!1}const b=Sv(u).join(":"),$=f?b+Vr:b,k=$+g;if(s.includes(k))continue;s.push(k);const w=r(g,h);for(let M=0;M<w.length;++M){const B=w[M];s.push($+B)}a=c+(a.length>0?" "+a:a)}return a};function Mv(){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 Tv(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((u,f)=>f(u),e());return n=jv(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const u=Nv(l,n);return r(l,u),u}return function(){return s(Mv.apply(null,arguments))}}const me=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Jr=/^\[(?:([a-z-]+):)?(.+)\]$/i,Av=/^\d+\/\d+$/,Iv=new Set(["px","full","screen"]),Cv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Pv=/\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$/,Ov=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Bv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=e=>st(e)||Iv.has(e)||Av.test(e),He=e=>lt(e,"length",Gv),st=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>lt(e,"number",st),gt=e=>!!e&&Number.isInteger(Number(e)),zv=e=>e.endsWith("%")&&st(e.slice(0,-1)),te=e=>Jr.test(e),We=e=>Cv.test(e),Rv=new Set(["length","size","percentage"]),Dv=e=>lt(e,Rv,Zr),Fv=e=>lt(e,"position",Zr),Hv=new Set(["image","url"]),Wv=e=>lt(e,Hv,Yv),qv=e=>lt(e,"",Xv),yt=()=>!0,lt=(e,t,n)=>{const o=Jr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},Gv=e=>Pv.test(e)&&!Ov.test(e),Zr=()=>!1,Xv=e=>Bv.test(e),Yv=e=>Lv.test(e),Kv=()=>{const e=me("colors"),t=me("spacing"),n=me("blur"),o=me("brightness"),r=me("borderColor"),s=me("borderRadius"),i=me("borderSpacing"),a=me("borderWidth"),l=me("contrast"),c=me("grayscale"),u=me("hueRotate"),f=me("invert"),m=me("gap"),p=me("gradientColorStops"),h=me("gradientColorStopPositions"),g=me("inset"),b=me("margin"),$=me("opacity"),k=me("padding"),w=me("saturate"),M=me("scale"),B=me("sepia"),D=me("skew"),V=me("space"),J=me("translate"),ne=()=>["auto","contain","none"],G=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",te,t],F=()=>[te,t],le=()=>["",Le,He],ce=()=>["auto",st,te],he=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ye=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",te],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ne=()=>[st,te];return{cacheSize:500,separator:":",theme:{colors:[yt],spacing:[Le,He],blur:["none","",We,te],brightness:Ne(),borderColor:[e],borderRadius:["none","","full",We,te],borderSpacing:F(),borderWidth:le(),contrast:Ne(),grayscale:xe(),hueRotate:Ne(),invert:xe(),gap:F(),gradientColorStops:[e],gradientColorStopPositions:[zv,He],inset:P(),margin:P(),opacity:Ne(),padding:F(),saturate:Ne(),scale:Ne(),sepia:xe(),skew:Ne(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",te]}],container:["container"],columns:[{columns:[We]}],"break-after":[{"break-after":_e()}],"break-before":[{"break-before":_e()}],"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:[...he(),te]}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:ne()}],"overscroll-x":[{"overscroll-x":ne()}],"overscroll-y":[{"overscroll-y":ne()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",gt,te]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",te]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",gt,te]}],"grid-cols":[{"grid-cols":[yt]}],"col-start-end":[{col:["auto",{span:["full",gt,te]},te]}],"col-start":[{"col-start":ce()}],"col-end":[{"col-end":ce()}],"grid-rows":[{"grid-rows":[yt]}],"row-start-end":[{row:["auto",{span:[gt,te]},te]}],"row-start":[{"row-start":ce()}],"row-end":[{"row-end":ce()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",te]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...ye()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ye(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ye(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[k]}],px:[{px:[k]}],py:[{py:[k]}],ps:[{ps:[k]}],pe:[{pe:[k]}],pt:[{pt:[k]}],pr:[{pr:[k]}],pb:[{pb:[k]}],pl:[{pl:[k]}],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":[V]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[V]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",te,t]}],"min-w":[{"min-w":[te,t,"min","max","fit"]}],"max-w":[{"max-w":[te,t,"none","full","min","max","fit","prose",{screen:[We]},We]}],h:[{h:[te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",We,He]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",gn]}],"font-family":[{font:[yt]}],"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",te]}],"line-clamp":[{"line-clamp":["none",st,gn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Le,te]}],"list-image":[{"list-image":["none",te]}],"list-style-type":[{list:["none","disc","decimal",te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[$]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[$]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Le,He]}],"underline-offset":[{"underline-offset":["auto",Le,te]}],"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:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te]}],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",te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[$]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...he(),Fv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Dv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Wv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],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":[$]}],"border-style":[{border:[...oe(),"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":[$]}],"divide-style":[{divide:oe()}],"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:["",...oe()]}],"outline-offset":[{"outline-offset":[Le,te]}],"outline-w":[{outline:[Le,He]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:le()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[$]}],"ring-offset-w":[{"ring-offset":[Le,He]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",We,qv]}],"shadow-color":[{shadow:[yt]}],opacity:[{opacity:[$]}],"mix-blend":[{"mix-blend":[...se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":se()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",We,te]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[B]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[$]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[B]}],"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",te]}],duration:[{duration:Ne()}],ease:[{ease:["linear","in","out","in-out",te]}],delay:[{delay:Ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[M]}],"scale-x":[{"scale-x":[M]}],"scale-y":[{"scale-y":[M]}],rotate:[{rotate:[gt,te]}],"translate-x":[{"translate-x":[J]}],"translate-y":[{"translate-y":[J]}],"skew-x":[{"skew-x":[D]}],"skew-y":[{"skew-y":[D]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",te]}],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",te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"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",te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Le,He,gn]}],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"]}}},Vv=Tv(Kv);function Ee(...e){return Vv(Yr(e))}const Qr=O.createContext(null);function Uv(){const e=O.useContext(Qr);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Ot=8;function Jv({children:e}){const[t,n]=O.useState({open:!1,x:0,y:0,items:[]}),[o,r]=O.useState(null),s=O.useRef(null),i=O.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=O.useCallback((c,u,f)=>{r(null),n({open:!0,x:c,y:u,items:f})},[]),l=O.useMemo(()=>({open:a,close:i}),[a,i]);return O.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+c.width>window.innerWidth-Ot&&(u=Math.max(Ot,t.x-c.width)),f+c.height>window.innerHeight-Ot&&(f=Math.max(Ot,t.y-c.height)),r({left:u,top:f})},[t]),O.useEffect(()=>{if(!t.open)return;const c=p=>{s.current&&!s.current.contains(p.target)&&i()},u=p=>{p.key==="Escape"&&(p.preventDefault(),i())},f=()=>i(),m=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",m),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",m)}},[t.open,i]),d.jsxs(Qr.Provider,{value:l,children:[e,t.open&&d.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:c=>c.preventDefault(),children:t.items.map((c,u)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:Ee("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",c.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",c.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),c.onSelect()},children:[d.jsxs("span",{className:"flex items-center gap-2",children:[f?d.jsx(f,{className:"size-4"}):null,d.jsx("span",{children:c.label})]}),c.shortcut?d.jsx("span",{className:"text-xs text-muted-foreground",children:c.shortcut}):null]},`${c.label}-${u}`)})})]})}const Io=e=>{let t;const n=new Set,o=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const m=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,m))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,r,a);return a},Zv=(e=>e?Io(e):Io),Qv=e=>e;function e2(e,t=Qv){const n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),O.useCallback(()=>t(e.getInitialState()),[e,t]));return O.useDebugValue(n),n}const Co=e=>{const t=Zv(e),n=o=>e2(t,o);return Object.assign(n,t),n},en=(e=>e?Co(e):Co),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.junction":"接线柱","props.junctionPos":"位置","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.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","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":"切到 元件 工具(P),从左侧元件库选一种拖到画布","onboard.step2.title":"拉线连接","onboard.step2.body":"用 连线 工具(W)从一个引脚拖到另一个引脚;拖到空白处会自动新建接线柱","onboard.step3.title":"需要共用排时才用母线","onboard.step3.body":"多条回路共用一条母排时,用 母线 工具(B)画一段;普通点对点连线不需要母线","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.junction":"Junction","props.junctionPos":"Position","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 a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","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 a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and 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.junction":"Click the canvas to drop a junction","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":"Place a component","onboard.step1.body":"Pick the Place tool (P) and drag a kind from the library onto the canvas","onboard.step2.title":"Wire it up","onboard.step2.body":"Use the Wire tool (W): drag from one pin to another — drag into empty space to drop a junction","onboard.step3.title":"Busbars are for shared rails","onboard.step3.body":"When several circuits share one rail, draw a busbar (B); plain point-to-point wiring needs no bus","onboard.dismiss":"Got it"}},es="ole-locale";function t2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(es);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 Oo(e){try{window.localStorage.setItem(es,e)}catch{}}const At=en((e,t)=>({locale:t2(),setLocale:n=>{Oo(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Oo(n),e({locale:n})}}));function ts(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function ns(e,t){return Po[e][t]??Po.zh[t]??t}function we(e,t){return ts(ns(At.getState().locale,e),t)}function ae(){const e=At(t=>t.locale);return(t,n)=>ts(ns(e,t),n)}function os(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 In=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return In(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return In(o)(n)}}}},n2=(e,t)=>(n,o,r)=>{let s={storage:os(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,$)=>({...$,...b}),...t},i=!1,a=0;const l=new Set,c=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 f=()=>{const b=s.partialize({...o()});return u.setItem(s.name,{state:b,version:s.version})},m=r.setState;r.setState=(b,$)=>(m(b,$),f());const p=e((...b)=>(n(...b),f()),o,r);r.getInitialState=()=>p;let h;const g=()=>{var b,$;if(!u)return;const k=++a;i=!1,l.forEach(M=>{var B;return M((B=o())!=null?B:p)});const w=(($=s.onRehydrateStorage)==null?void 0:$.call(s,(b=o())!=null?b:p))||void 0;return In(u.getItem.bind(u))(s.name).then(M=>{if(M)if(typeof M.version=="number"&&M.version!==s.version){if(s.migrate){const B=s.migrate(M.state,M.version);return B instanceof Promise?B.then(D=>[!0,D]):[!0,B]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,M.state];return[!1,void 0]}).then(M=>{var B;if(k!==a)return;const[D,V]=M;if(h=s.merge(V,(B=o())!=null?B:p),n(h,!0),D)return f()}).then(()=>{k===a&&(w==null||w(o(),void 0),h=o(),i=!0,c.forEach(M=>M(h)))}).catch(M=>{k===a&&(w==null||w(void 0,M))})};return r.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},s.skipHydration||g(),h||p},o2=n2,ze=.5;function rs(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])<ze&&Math.abs(s[1]-e[r][1])<ze||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>ze&&l>ze){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<ze?"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])<ze&&Math.abs(i[0]-a[0])<ze,c=Math.abs(s[1]-i[1])<ze&&Math.abs(i[1]-a[1])<ze;l||c||o.push(i)}return o.push(n[n.length-1]),o}function ss(){return{elements:new Map,buses:new Map,junctions:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function is(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 Cn(e){return e===90||e===270?"y":"x"}function Pe(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 r2={n:"e",e:"s",s:"w",w:"n"},s2={n:"n",s:"s",e:"w",w:"e"};function $t(e,t){let n=t.mirror?s2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=r2[n];return n}function Pn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class as{constructor(){pt(this,"parent",new Map);pt(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 Bo=["n","e","s","w"],Lo={n:"s",s:"n",e:"w",w:"e"};function Bt(e,t){const n=Bo.indexOf(e),r=((Bo.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const yn=320,Lt=220,xt=260,xn=720,bt=30,zo=30,qe=80,Ro=10,i2=60,a2=520,l2=80,c2=80,Do=8,Fo=new Set(["source","renewable"]);function d2(e){var vo,ko,_o,$o,So,jo;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),u=new Map,f=new Set(i.keys()),m=new Set(a.keys()),p=new Map;for(const y of t)p.set(y.id,y);const h=new Map;for(const y of n)h.set(y.id,y);const g=y=>{const v=p.get(y);if(v)return s.get(v.kind)},b=new Set(n.map(y=>y.id)),$=y=>b.has(y),k=new Set(o.map(y=>y.id)),w=new Set(o.filter(y=>{var v;return(v=y.layout)==null?void 0:v.at}).map(y=>y.id)),M=new as;for(const y of r)M.add(y.ends[0]),M.add(y.ends[1]),M.union(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(v)for(const S of v.terminals)M.add(`${y.id}.${S.id}`)}for(const y of n)M.add(y.id);const B=[];for(const[,y]of M.groups())y.length>=2&&B.push(y);const D=new Map;for(const y of B)for(const v of y)D.set(v,[y]);const V=new Map;for(const y of B){const v=y.filter($);if(v.length!==0)for(const S of v){const E=y.filter(_=>_!==S),j=V.get(S)??[];j.push(...E),V.set(S,j)}}{const S=A=>p.has(A)&&!!g(A),E=A=>{if($(A))return null;if(k.has(A))return A;const N=A.indexOf(".");return N>0?A.slice(0,N):null},j=new Map,_=new Set,T=(A,N)=>{j.has(A)||j.set(A,new Set),j.has(N)||j.set(N,new Set),A!==N&&(j.get(A).add(N),j.get(N).add(A))};for(const A of B){const N=[];let L=!1;for(const W of A){if($(W)){L=!0;continue}const Z=E(W);Z&&N.push(Z)}const z=[...new Set(N)];for(const W of z)j.has(W)||j.set(W,new Set),L&&_.add(W);const H=z.filter(W=>k.has(W)),q=z.filter(W=>!k.has(W));if(H.length>0){for(const W of H)for(const Z of q)T(W,Z);for(let W=0;W<H.length;W++)for(let Z=W+1;Z<H.length;Z++)T(H[W],H[Z])}else for(let W=0;W<q.length;W++)for(let Z=W+1;Z<q.length;Z++)T(q[W],q[Z])}const R=(A,N)=>{const L=g(A);if(!L)return null;for(const z of L.terminals){const H=`${A}.${z.id}`;for(const q of D.get(H)??[])for(const W of q)if(E(W)===N)return z}return null},I=A=>{const N=K=>{var ee;return((ee=j.get(K))==null?void 0:ee.size)??0},L=K=>{var ee;return((ee=g(K))==null?void 0:ee.category)??""},z=K=>{const ee=L(K);return ee==="source"?0:ee==="renewable"?1:2+Math.min(N(K),9)/10},H=A.filter(S).sort((K,ee)=>z(K)-z(ee)||K.localeCompare(ee))[0];if(!H)return;const q=new Map([[H,null]]),W=new Map([[H,0]]),Z=new Map,Q=[],X=[H],Y=new Set([H]);for(;X.length;){const K=X.shift();Q.push(K);for(const ee of[...j.get(K)??[]].sort(($e,Se)=>$e.localeCompare(Se)))Y.has(ee)||(Y.add(ee),q.set(ee,K),W.set(ee,(W.get(K)??0)+1),Z.has(K)||Z.set(K,[]),Z.get(K).push(ee),X.push(ee))}let U=0;const de=new Map,be=K=>{const ee=Z.get(K)??[];if(ee.length===0){de.set(K,U++);return}for(const Se of ee)be(Se);const $e=ee.map(Se=>de.get(Se));de.set(K,$e.reduce((Se,Pt)=>Se+Pt,0)/$e.length)};be(H);for(const K of Q){const ee=pe(yn+(de.get(K)??0)*160),$e=pe(Lt+(W.get(K)??0)*140);if(k.has(K)){u.set(K,[ee,$e]);continue}let Se=0;const Pt=q.get(K)??null;if(Pt){const ht=R(K,Pt);ht&&(Se=Bt(ht.orientation,"n"))}else{const ht=(Z.get(K)??[])[0],Eo=ht?R(K,ht):null;Eo&&(Se=Bt(Eo.orientation,"s"))}l.set(K,{at:[ee,$e],rot:Se,mirror:!1}),f.add(K)}},C=new Set;for(const A of j.keys()){if(C.has(A))continue;const N=[],L=[A];for(C.add(A);L.length;){const z=L.pop();N.push(z);for(const H of j.get(z)??[])C.has(H)||(C.add(H),L.push(H))}N.length<2||N.some(z=>_.has(z))||N.some(z=>l.has(z)||w.has(z))||N.some(S)&&I(N)}}const J=new Map;for(const y of B){const v=y.filter($);if(v.length!==0)for(const S of y){if($(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=S.slice(E+1),T=J.get(j)??[];for(const R of v)T.some(I=>I.busId===R&&I.pin===_)||T.push({busId:R,pin:_});J.set(j,T)}}const ne=[],G=new Set;for(const[y,v]of J)if(new Set(v.map(E=>E.busId)).size>=2){const E=((ko=s.get(((vo=p.get(y))==null?void 0:vo.kind)??""))==null?void 0:ko.category)==="transformer"?"vertical":"horizontal";ne.push({elementId:y,attachments:v,orientation:E}),E==="vertical"&&G.add(y)}const P=new Map,F=(y,v)=>{y!==v&&(P.has(y)||P.set(y,new Set),P.has(v)||P.set(v,new Set),P.get(y).add(v),P.get(v).add(y))};for(const y of r)F(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(!v||v.terminals.length<2)continue;const S=v.terminals.map(E=>`${y.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)F(S[E],S[j])}for(const y of t){if(G.has(y.id))continue;const v=s.get(y.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const T=_.slice(y.id.length+1);E.set(T,new Set);const R=new Set(S.filter(A=>A!==_)),I=new Set([_]),C=[_];for(;C.length>0;){const A=C.shift();if($(A)){E.get(T).add(A);continue}const N=P.get(A);if(N)for(const L of N)I.has(L)||R.has(L)||(I.add(L),C.push(L))}}const j=new Set;for(const _ of E.values())for(const T of _)j.add(T);if(j.size>=2){const _=[];for(const[T,R]of E)for(const I of R)_.push({busId:I,pin:T});ne.push({elementId:y.id,attachments:_,orientation:"vertical"}),G.add(y.id)}}const le=(y,v)=>{var R;const S=g(v),E=S?S.terminals.map(I=>`${v}.${I.id}`):[],j=y,_=new Set([j,...E]),T=[j];for(;T.length>0;){const I=T.shift(),C=I.indexOf(".");if(C>0){const N=I.slice(0,C),L=p.get(N);if(L){const z=(R=s.get(L.kind))==null?void 0:R.category;if(z&&Fo.has(z))return!0}}const A=P.get(I);if(A)for(const N of A)_.has(N)||(_.add(N),T.push(N))}return!1};for(const y of ne){if(y.orientation!=="horizontal")continue;const v=new Set(y.attachments.map(E=>E.busId));let S=0;for(const E of v)le(E,y.elementId)&&S++;S===1&&(y.orientation="vertical",G.add(y.elementId))}for(const y of t){if(G.has(y.id)||y.kind!=="breaker")continue;const v=s.get(y.kind);if(!v||v.terminals.length!==2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const T=_.slice(y.id.length+1),R=new Set(S.filter(A=>A!==_)),I=new Set([_]),C=[_];for(;C.length>0;){const A=C.shift();if($(A)){E.set(T,A);break}const N=P.get(A);if(N)for(const L of N){if(I.has(L)||R.has(L))continue;const z=L.indexOf(".");if(z>0){const H=L.slice(0,z);if(H!==y.id){const q=p.get(H),W=q?s.get(q.kind):void 0;if((W==null?void 0:W.category)==="transformer")continue}}I.add(L),C.push(L)}}}if(new Set(E.values()).size>=2){const _=[];for(const[T,R]of E)_.push({busId:R,pin:T});ne.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ce=new Map;for(const y of n)ce.set(y.id,new Map);for(const y of ne){const v=Array.from(new Set(y.attachments.map(S=>S.busId)));for(const S of v)for(const E of v)S!==E&&((_o=ce.get(S))==null||_o.set(E,y))}const he=y=>{var S;const v=(S=s.get(y))==null?void 0:S.category;return v?Fo.has(v):!1},oe=[];for(const y of n){const v=V.get(y.id);if(v)for(const S of v){if($(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=p.get(j);if(_&&he(_.kind)){oe.push(y.id);break}}}oe.length===0&&n.length>0&&oe.push(n[0].id);const se=new Map;for(const y of oe)se.set(y,0);{const y=[...oe];for(;y.length>0;){const v=y.shift(),S=se.get(v),E=ce.get(v);if(E)for(const[j,_]of E){if(se.has(j))continue;const T=_.orientation==="horizontal"?S:S+1;se.set(j,T),y.push(j)}}}for(const y of n){if(se.has(y.id))continue;const v=se.size===0?-1:Math.max(...Array.from(se.values()));se.set(y.id,v+1)}const ye=new Map;for(const y of n){const v=se.get(y.id),S=ye.get(v)??[];S.push(y.id),ye.set(v,S)}const xe=[...ye.keys()].sort((y,v)=>y-v),_e=(y,v,S)=>{const E=`${y.elementId}.${S}`,j=v,_=g(y.elementId),T=new Set;if(_)for(const N of _.terminals)N.id!==S&&T.add(`${y.elementId}.${N.id}`);const R=new Set([E]),I=[{ref:E,dist:0}],C=new Map,A=(N,L,z,H)=>{R.add(N),C.set(N,L),I.push({ref:N,dist:H+z})};for(;I.length>0;){const{ref:N,dist:L}=I.shift();if(N===j){const W=C.get(j);let Z;if(W){const Q=W.indexOf(".");if(Q>0){const X=W.slice(0,Q);X!==y.elementId&&(Z=X)}}return{extent:L,head:Z}}const z=N.indexOf(".");if(z<0)continue;const H=N.slice(0,z),q=N.slice(z+1);if(!$(H)&&!G.has(H)){const W=g(H),Z=W==null?void 0:W.terminals.find(Q=>Q.id===q);if(W&&Z)for(const Q of W.terminals){if(Q.id===q)continue;const X=`${H}.${Q.id}`;R.has(X)||T.has(X)||A(X,N,Math.abs(Z.y-Q.y),L)}}for(const W of D.get(N)??[])for(const Z of W){if(Z===N||R.has(Z)||T.has(Z))continue;const Q=$(N)||$(Z);A(Z,N,Q?zo:bt,L)}}return{extent:0}},Ne=(y,v)=>{var N,L,z;const S=(N=ce.get(y))==null?void 0:N.get(v);if(!S||S.orientation==="horizontal")return xt;const E=g(S.elementId);if(!E)return xt;const j=(L=S.attachments.find(H=>H.busId===y))==null?void 0:L.pin,_=(z=S.attachments.find(H=>H.busId===v))==null?void 0:z.pin;if(!j||!_)return xt;const T=E.terminals.find(H=>H.id===j),R=E.terminals.find(H=>H.id===_);if(!T||!R)return xt;const I=Math.abs(R.y-T.y),C=_e(S,y,j).extent,A=_e(S,v,_).extent;return C+I+A},dn=new Map;for(const y of ne){if(y.orientation!=="vertical")continue;const v=y.attachments.slice().sort((R,I)=>(se.get(R.busId)??0)-(se.get(I.busId)??0));if(v.length<2)continue;const S=v[0].busId,E=v[1].busId,j=v[0].pin,T=_e(y,S,j).head??y.elementId;dn.set(T,{lowerBusId:E})}const ao=30,lo=y=>{const v=g(y);return Math.max((v==null?void 0:v.width)??qe,qe)},Dw=2,co=(y,v,S,E=0)=>{const j=g(v);let _=lo(v);if(j&&!S.has(v)&&E<Dw){S.add(v);let T=0;for(const R of j.terminals){const I=`${v}.${R.id}`;if(I!==y)for(const C of D.get(I)??[]){const A=new Set;let N=!1;for(const z of C){if(z===I)continue;if($(z)){N=!0;continue}const H=z.indexOf(".");if(H<0)continue;const q=z.slice(0,H);q===v||S.has(q)||G.has(q)||A.add(q)}if(N||A.size===0)continue;let L=0;for(const z of A){const H=[...C].find(q=>q.indexOf(".")>0&&q.slice(0,q.indexOf("."))===z);L+=(H?co(H,z,S,E+1):lo(z))+ao}T=Math.max(T,L-ao)}}S.delete(v),_=Math.max(_,T)}return _},ut=320,et=new Map,uo=(y,v)=>{if(!G.has(y))return!1;const S=ne.find(T=>T.elementId===y),E=S==null?void 0:S.attachments.find(T=>T.busId!==v);if(!E)return!1;const j=se.get(v)??0;return(se.get(E.busId)??0)<j},ft=(y,v,S)=>{const E=dn.get(y);if(E){const _=et.get(E.lowerBusId);if(_!==void 0)return Math.max(v,_+qe)}let j=0;return S&&(j=co(S,y,new Set)),Math.max(v,qe,j)},fo=(y,v)=>{if(et.has(y))return et.get(y);if(v.has(y))return ut;v.add(y);const S=V.get(y)??[];let E=0,j=0;for(const T of S){if($(T))continue;const R=T.indexOf(".");if(R<0)continue;const I=T.slice(0,R),C=T.slice(R+1);if(uo(I,y))continue;const A=g(I);if(!A)continue;const N=A.terminals.find(H=>H.id===C);if(!N)continue;const L=dn.get(I);L&&fo(L.lowerBusId,v);const z=ft(I,A.width,`${I}.${C}`);N.y>0?E+=z:j+=z}const _=Math.max(ut,Math.max(E,j)+qe);return et.set(y,_),v.delete(y),_};for(const y of n)fo(y.id,new Set);const Fe=new Map,Fw=(y,v,S)=>{const E=g(v);if(!E)return;const j=`${v}.${S}`,_=E.terminals.filter(I=>I.id!==S).map(I=>`${v}.${I.id}`);if(_.length===0)return;const T=new Set([j,..._]),R=_.slice();for(;R.length>0;){const I=R.shift();if($(I)&&I!==y){const A=c.get(I);return A?A.at[0]:void 0}for(const A of D.get(I)??[])for(const N of A)N===I||T.has(N)||(T.add(N),R.push(N));const C=I.indexOf(".");if(C>0){const A=I.slice(0,C);if(!$(A)){const N=g(A);if(N)for(const L of N.terminals){const z=`${A}.${L.id}`;T.has(z)||(T.add(z),R.push(z))}}}}},Hw=y=>{const v=V.get(y);if(!v||v.length===0)return;const S=c.get(y);if(!S)return;const E=v.flatMap(N=>{if($(N))return[];const L=N.indexOf(".");if(L<0)return[];const z=N.slice(0,L),H=N.slice(L+1);if(l.has(z))return[];if(uo(z,y))return[];const q=g(z);if(!q)return[];const W=q.terminals.find(Z=>Z.id===H);return W?[{elId:z,lib:q,localTerm:W,isLinker:G.has(z),busFacingRef:`${z}.${H}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const T=N=>N.reduce((L,z)=>L+ft(z.elId,z.lib.width,z.busFacingRef),0),R=Math.max(T(j),T(_))+qe,I=Math.max(S.span,R);I!==S.span&&!m.has(y)&&c.set(y,{...S,span:I});const C=c.get(y),A=(N,L)=>{if(N.length===0)return;const z=new Map;for(const Y of N){const U=Fw(y,Y.elId,Y.localTerm.id);U!==void 0&&z.set(Y.elId,U)}N.sort((Y,U)=>{const de=z.get(Y.elId)??C.at[0],be=z.get(U.elId)??C.at[0];if(de!==be)return de-be;const K=ft(Y.elId,Y.lib.width,Y.busFacingRef);return ft(U.elId,U.lib.width,U.busFacingRef)-K});const H=N.map(Y=>ft(Y.elId,Y.lib.width,Y.busFacingRef)),q=H.reduce((Y,U)=>Y+U,0),W=Math.max(I,q),Z=(W-q)/(N.length+1);let Q=C.at[0]-W/2+Z;const X=C.at[1]+L*zo;for(let Y=0;Y<N.length;Y++){const U=N[Y],de=H[Y],be=Q+de/2;U.isLinker?Fe.has(U.elId)||Fe.set(U.elId,be):l.set(U.elId,{at:[pe(be-U.localTerm.x),pe(X-U.localTerm.y)],rot:0,mirror:!1}),Q+=de+Z}};A(j,-1),A(_,1)},Ww=y=>{if(l.has(y.elementId)||y.orientation==="horizontal")return;const v=g(y.elementId);if(!v)return;const S=y.attachments.filter(Q=>c.has(Q.busId));if(S.length<2)return;const E=S.slice().sort((Q,X)=>(se.get(Q.busId)??0)-(se.get(X.busId)??0)),j=E[0].busId,_=c.get(j),T=E[0].pin,R=E[E.length-1].pin,I=v.terminals.find(Q=>Q.id===T),C=v.terminals.find(Q=>Q.id===R);if(!I||!C)return;const A=I.y<=C.y?0:180,N=se.get(j)??0,L=S.filter(Q=>(se.get(Q.busId)??0)===N),z=[];let H=0;for(const Q of L){const X=_e(y,Q.busId,Q.pin);H=Math.max(H,X.extent);const Y=X.head?l.get(X.head):void 0;Y?z.push(Y.at[0]):Fe.has(y.elementId)?z.push(Fe.get(y.elementId)):z.push(c.get(Q.busId).at[0])}let q;z.length>0?q=z.reduce((Q,X)=>Q+X,0)/z.length:Fe.has(y.elementId)?q=Fe.get(y.elementId):q=_.at[0];const W=_.at[1]+H,Z=A===0?[pe(q-I.x),pe(W-I.y)]:[pe(q+I.x),pe(W+I.y)];if(l.set(y.elementId,{at:Z,rot:A,mirror:!1}),L.length>1){const Q=l.get(y.elementId),X=Pe([I.x,I.y],Q),Y=$t(I.orientation,Q);qw(`${y.elementId}.${T}`,X,Y,q)}},qw=(y,v,S,E)=>{const j=new Set([y]);let _=y,T=v,R=S;for(;;){const I=D.get(_)??[];let C,A=!1;for(const ee of I){if(ee.length>=3){A=!0;break}const $e=ee.find(Se=>Se!==_);if(!(!$e||j.has($e))){if($($e)){A=!0;break}C=$e;break}}if(A||!C)break;const N=C.indexOf(".");if(N<0)break;const L=C.slice(0,N),z=C.slice(N+1);if($(L)||G.has(L)||l.has(L))break;const H=g(L);if(!H)break;const q=H.terminals.find(ee=>ee.id===z);if(!q)break;const W=Pn(R),Z=[T[0]+W[0]*bt,T[1]+W[1]*bt],Q=Lo[R],X=Bt(q.orientation,Q),Y=Pe([q.x,q.y],{at:[0,0],rot:X,mirror:!1}),U=[pe(E-Y[0]),pe(Z[1]-Y[1])];l.set(L,{at:U,rot:X,mirror:!1}),j.add(C);const de=H.terminals.find(ee=>ee.id!==z);if(!de)break;const be=`${L}.${de.id}`;j.add(be);const K={at:U,rot:X,mirror:!1};T=Pe([de.x,de.y],K),R=$t(de.orientation,K),_=be}},Gw=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const v=g(y.elementId);if(!v)return;const S=y.attachments.filter(L=>c.has(L.busId));if(S.length<2)return;const E=S.map(L=>{const z=_e(y,L.busId,L.pin),H=z.head?l.get(z.head):void 0,q=H?H.at[0]:c.get(L.busId).at[0];return{att:L,x:q,extent:z.extent}});E.sort((L,z)=>L.x-z.x);const j=E[0],_=E[E.length-1],T=v.terminals.find(L=>L.id===j.att.pin),R=v.terminals.find(L=>L.id===_.att.pin);if(!T||!R)return;const I=T.y<=R.y?270:90,C=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(y.elementId,{at:[pe(C),pe(N)],rot:I,mirror:!1})},mo=100;let Ct=Lt;for(let y=0;y<xe.length;y++){const v=xe[y],S=ye.get(v);let E;if(y===0)E=Lt;else{const _=ye.get(xe[y-1]);let T=0;for(const R of _)for(const I of S)($o=ce.get(R))!=null&&$o.get(I)&&(T=Math.max(T,Ne(R,I)));T===0&&(T=xt),E=Ct+T}Ct=E;let j=yn;for(const _ of S){if(c.has(_)){Ct=Math.max(Ct,c.get(_).at[1]);continue}let T;if(y>0){const I=ye.get(xe[y-1]),C=[];for(const A of I){const N=(So=ce.get(A))==null?void 0:So.get(_);if(!N||N.orientation!=="vertical")continue;const L=(jo=N.attachments.find(H=>H.busId===A))==null?void 0:jo.pin;if(!L)continue;const z=_e(N,A,L);z.head&&l.has(z.head)?C.push(l.get(z.head).at[0]):Fe.has(N.elementId)?C.push(Fe.get(N.elementId)):C.push(c.get(A).at[0])}C.length>0&&(T=C.reduce((A,N)=>A+N,0)/C.length)}if(T===void 0){const I=et.get(_)??xn;T=j+I/2,j+=I+mo}const R=et.get(_)??xn;c.set(_,{at:[pe(T),pe(E)],rot:0,span:R,axis:Cn(0)})}for(const _ of S)Hw(_);if(y>0)for(const _ of ne)l.has(_.elementId)||!_.attachments.some(R=>S.includes(R.busId))||Ww(_);for(const _ of ne)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(R=>S.includes(R.busId))||Gw(_)}if(n.length===0&&l.size<t.length){const y=j=>{const _=new Set,T=g(j);if(!T)return _;for(const R of T.terminals){const I=`${j}.${R.id}`;for(const C of D.get(I)??[])for(const A of C){if(A===I||$(A))continue;const N=A.indexOf(".");if(N<0)continue;const L=A.slice(0,N);L!==j&&_.add(L)}}return _},v=new Set,S=[];for(const j of t){if(v.has(j.id)||!g(j.id))continue;const _=[],T=[j.id];for(v.add(j.id);T.length>0;){const R=T.pop();_.push(R);for(const I of y(R))v.has(I)||(v.add(I),T.push(I))}_.length>=2&&S.push(_)}let E=yn;for(const j of S){if(j.some(C=>l.has(C)))continue;j.sort((C,A)=>{var q,W;const N=he(((q=p.get(C))==null?void 0:q.kind)??"")?0:1,L=he(((W=p.get(A))==null?void 0:W.kind)??"")?0:1;if(N!==L)return N-L;const z=y(C).size,H=y(A).size;return z!==H?z-H:C.localeCompare(A)});const _=j[0],T=g(_);if(!T)continue;const R=T.terminals.slice().sort((C,A)=>A.y-C.y)[0],I=R?Pe([R.x,R.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[pe(E-I[0]),pe(Lt-I[1])],rot:0,mirror:!1}),E+=Math.max(xn,j.length*qe)+mo}}const Xw=y=>{if($(y))return c.has(y);const v=y.indexOf(".");return v<0?!1:l.has(y.slice(0,v))};let un=!0,Yw=t.length+4;for(;un&&Yw-- >0;){un=!1;for(const y of B){if(y.length<2)continue;const v=[],S=new Map;for(const X of y){if($(X))continue;const Y=X.indexOf(".");if(Y<0)continue;const U=X.slice(0,Y),de=X.slice(Y+1);if(l.has(U)){v.push(X);continue}if(G.has(U)||S.has(U))continue;const be=g(U);if(!be)continue;const K=be.terminals.find(ee=>ee.id===de);K&&S.set(U,{ref:X,elId:U,lib:be,localTerm:K})}if(S.size===0||v.length===0)continue;const E=[...S.values()],j=new Map;for(const X of E)for(const Y of D.get(X.ref)??[])for(const U of Y){if(U===X.ref||$(U)||!Xw(U))continue;const de=U;j.set(de,(j.get(de)??0)+1)}let _;if(j.size>0){let X=-1;for(const[Y,U]of j)(U>X||U===X&&(_===void 0||Y<_))&&(X=U,_=Y)}if(_||(_=[...v].sort()[0]),!_)continue;const T=_.indexOf("."),R=_.slice(0,T),I=_.slice(T+1),C=g(R),A=l.get(R);if(!C||!A)continue;const N=C.terminals.find(X=>X.id===I);if(!N)continue;const L=Pe([N.x,N.y],A),z=$t(N.orientation,A),H=Pn(z),q=[-H[1],H[0]];E.sort((X,Y)=>X.elId.localeCompare(Y.elId));const W=E.map(X=>Math.max(X.lib.width,qe));let Q=-W.reduce((X,Y)=>X+Y,0)/2;for(let X=0;X<E.length;X++){const Y=E[X],U=W[X],de=Q+U/2;Q+=U;const be=Lo[z],K=Bt(Y.localTerm.orientation,be),ee=Pe([Y.localTerm.x,Y.localTerm.y],{at:[0,0],rot:K,mirror:!1}),$e=[L[0]+H[0]*bt+q[0]*de,L[1]+H[1]*bt+q[1]*de],Se=[pe($e[0]-ee[0]),pe($e[1]-ee[1])];l.set(Y.elId,{at:Se,rot:K,mirror:!1}),un=!0}}}const mt=y=>{const v=l.get(y),S=g(y);if(!v||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.width/2;return{min:v.at[0]-N,max:v.at[0]+N}}const[j,_,T,R]=E,I=[[j,_],[j+T,_],[j,_+R],[j+T,_+R]];let C=1/0,A=-1/0;for(const N of I){const L=Pe(N,v);C=Math.min(C,L[0]),A=Math.max(A,L[0])}return{min:C,max:A}},fn=y=>{const v=new Set,S=g(y);if(!S)return v;for(const E of S.terminals){const j=`${y}.${E.id}`;for(const _ of D.get(j)??[])for(const T of _){if(T===j||$(T))continue;const R=T.indexOf(".");if(R<0)continue;const I=T.slice(0,R);I!==y&&v.add(I)}}return v},ho=40,mn=y=>{const v=l.get(y),S=g(y);if(!v||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.height/2;return{min:v.at[1]-N,max:v.at[1]+N}}const[j,_,T,R]=E,I=[[j,_],[j+T,_],[j,_+R],[j+T,_+R]];let C=1/0,A=-1/0;for(const N of I){const L=Pe(N,v);C=Math.min(C,L[1]),A=Math.max(A,L[1])}return{min:C,max:A}},Kw=(y,v)=>{const S=new Set,E=[];for(const j of V.get(y)??[]){if($(j))continue;const _=j.indexOf(".");if(_<0)continue;const T=j.slice(0,_),R=l.get(T);!R||R.at[1]>=v-1||S.has(T)||(S.add(T),E.push(T))}for(;E.length>0;){const j=E.pop();for(const _ of fn(j)){if(S.has(_))continue;const T=l.get(_);!T||T.at[1]>=v-1||(S.add(_),E.push(_))}}return S},po=(y,v,S)=>{const E=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const T of fn(_))T===v||E.has(T)||!S.has(T)||(E.add(T),j.push(T))}return E},go=(y,v)=>{let S=y.length*y.length+8,E=!1,j=!0;for(;j&&S-- >0;){j=!1;for(let _=0;_<y.length&&!j;_++)for(let T=_+1;T<y.length;T++){const R=y[_],I=y[T],C=mt(R),A=mt(I),N=mn(R),L=mn(I);if(!C||!A||!N||!L)continue;const z=Math.min(C.max,A.max)-Math.max(C.min,A.min),H=Math.min(N.max,L.max)-Math.max(N.min,L.min);if(z<=0||H<=0)continue;const q=po(R,I,v),W=po(I,R,v);if(q.has(I)||W.has(R))continue;const Z=![...q].some(K=>f.has(K)),Q=![...W].some(K=>f.has(K));if(!Z&&!Q)continue;const X=(C.min+C.max)/2,Y=(A.min+A.max)/2;let U,de;Z&&(!Q||q.size<=W.size)?(U=q,de=X<=Y?-1:1):(U=W,de=Y<=X?-1:1);const be=pe(de*(z+ho));if(be!==0){for(const K of U){const ee=l.get(K);ee&&l.set(K,{...ee,at:[ee.at[0]+be,ee.at[1]]})}E=!0,j=!0;break}}}return E};for(const y of n){const v=c.get(y.id);if(!v)continue;const S=Kw(y.id,v.at[1]);if(S.size<2)continue;const E=[...S];if(go(E,S)){let _=1/0,T=-1/0;for(const R of E){const I=mt(R);I&&(_=Math.min(_,I.min),T=Math.max(T,I.max))}if(Number.isFinite(_)){const I=E.some(A=>f.has(A))?0:pe(v.at[0]-(_+T)/2);if(I!==0)for(const A of E){const N=l.get(A);N&&l.set(A,{...N,at:[N.at[0]+I,N.at[1]]})}const C=T-_+ho;if(C>v.span&&!m.has(y.id)){const A=c.get(y.id);c.set(y.id,{...A,span:C})}}}}const yo=()=>{const v=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:mt(E),y:mn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<v.length;E++)for(let j=E+1;j<v.length;j++){const _=Math.min(v[E].x.max,v[j].x.max)-Math.max(v[E].x.min,v[j].x.min),T=Math.min(v[E].y.max,v[j].y.max)-Math.max(v[E].y.min,v[j].y.min);_>1&&T>1&&S++}return S},Vw=yo(),xo=new Map;for(const[y,v]of l)xo.set(y,{...v,at:[...v.at]});const bo=new Map;for(const[y,v]of c)bo.set(y,{...v,at:[...v.at]});const hn=120,wo=new Map;{const y=new Map,v=new Map,S=[];for(const j of n)for(const _ of V.get(j.id)??[]){if($(_))continue;const T=_.indexOf(".");if(T<0)continue;const R=_.slice(0,T);l.has(R)&&S.push({el:R,bus:j.id,d:1})}S.sort((j,_)=>j.d-_.d);let E=0;for(;E<S.length;){const{el:j,bus:_,d:T}=S[E++],R=y.get(j);if(R===void 0)y.set(j,T),v.set(j,_);else if(T===R&&v.get(j)!==_){v.set(j,null);continue}else continue;for(const I of fn(j))l.has(I)&&(y.has(I)||S.push({el:I,bus:_,d:T+1}))}for(const[j,_]of v)_&&wo.set(j,_)}for(const y of xe){const v=(ye.get(y)??[]).filter(C=>c.has(C));if(v.length<2||v.some(C=>m.has(C)))continue;const S=[];let E=0;for(const C of v){const A=c.get(C),N=[];let L=1/0,z=-1/0;for(const[H,q]of wo){if(q!==C)continue;const W=mt(H);W&&(N.push(H),L=Math.min(L,W.min),z=Math.max(z,W.max))}Number.isFinite(L)||(L=A.at[0]-ut/2,z=A.at[0]+ut/2),S.push({busId:C,min:L,max:z,members:N}),E+=z-L}if(S.some(C=>C.members.some(A=>f.has(A))))continue;let j=1/0,_=-1/0;for(const C of S)j=Math.min(j,C.min),_=Math.max(_,C.max);const T=_-j,R=E+hn*(S.length-1);if(!(T>R+hn))continue;S.sort((C,A)=>(C.min+C.max)/2-(A.min+A.max)/2);let I=j;for(const C of S){const A=pe(I-C.min);if(A!==0){const N=c.get(C.busId);c.set(C.busId,{...N,at:[N.at[0]+A,N.at[1]]});for(const L of C.members){const z=l.get(L);z&&l.set(L,{...z,at:[z.at[0]+A,z.at[1]]})}C.min+=A,C.max+=A}I=C.max+hn}for(const C of S){const A=c.get(C.busId),N=Math.max(ut,C.max-C.min);N<A.span&&c.set(C.busId,{...A,span:N})}}{const y=t.map(S=>S.id).filter(S=>l.has(S)),v=new Set(y);go(y,v)}if(yo()>Vw){l.clear();for(const[y,v]of xo)l.set(y,v);c.clear();for(const[y,v]of bo)c.set(y,v)}let pn=0;for(const y of t){if(l.has(y.id))continue;const v=pn%Do,S=Math.floor(pn/Do);l.set(y.id,{at:[pe(i2+v*l2),pe(a2+S*c2)],rot:0,mirror:!1}),pn++}return{devices:l,buses:c,junctions:u}}function pe(e){return Math.round(e/Ro)*Ro}function u2(e,t){const n=e.ends[0],o=e.ends[1],r=Ho(n,t),s=Ho(o,t);if(r||s){const l=r?n:o,u=bn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:m,at:p,span:h}=f.geometry,g=h/2;let b;if(m==="x")b=[Xt(u[0],p[0]-g,p[0]+g),p[1]];else{const $=Xt(u[1],p[1]-g,p[1]+g);b=[p[0],$]}return{wireId:e.id,path:qo(u,b)}}const i=bn(n,t),a=bn(o,t);return!i||!a?null:{wireId:e.id,path:qo(i,a)}}function Ho(e,t){return!e.includes(".")&&t.buses.has(e)}function bn(e,t){if(!e.includes(".")){const o=t.buses.get(e);if(o)return o.geometry.at;const r=t.junctions.get(e);return r?r.world:null}const n=t.terminals.get(e);return n?n.world:null}function Wo(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const u=n.junctions.get(e);return u?[u.world[0],u.world[1]]: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[Xt(t[0],i[0]-l,i[0]+l),i[1]];const c=Xt(t[1],i[1]-l,i[1]+l);return[i[0],c]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function qo(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Xt(e,t,n){return e<t?t:e>n?n:e}const ls="ammeter",cs="电流表 (A)",ds="measurement",us="-22 -42 44 44",fs=44,ms=44,hs='<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>',ps=[{id:"t_top",x:0,y:-40,orientation:"n"}],gs={kind:"inline"},f2={id:ls,name:cs,category:ds,viewBox:us,width:fs,height:ms,svg:hs,terminals:ps,source:gs},m2=Object.freeze(Object.defineProperty({__proto__:null,category:ds,default:f2,height:ms,id:ls,name:cs,source:gs,svg:hs,terminals:ps,viewBox:us,width:fs},Symbol.toStringTag,{value:"Module"})),ys="arc-suppression-coil",xs="消弧线圈",bs="grounding",ws="中性点谐振接地:电感线圈连接到地",vs="-12 -32 24 67",ks=24,_s=67,$s='<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"/>',Ss=[{id:"t_top",x:0,y:-30,orientation:"n"}],js={kind:"inline"},h2={id:ys,name:xs,category:bs,description:ws,viewBox:vs,width:ks,height:_s,svg:$s,terminals:Ss,source:js},p2=Object.freeze(Object.defineProperty({__proto__:null,category:bs,default:h2,description:ws,height:_s,id:ys,name:xs,source:js,svg:$s,terminals:Ss,viewBox:vs,width:ks},Symbol.toStringTag,{value:"Module"})),Es="arrester",Ns="避雷器 (FBL)",Ms="protection",Ts="-7 -22 14 44",As=14,Is=44,Cs='<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"/>',Ps=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Os={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},g2={id:Es,name:Ns,category:Ms,viewBox:Ts,width:As,height:Is,svg:Cs,terminals:Ps,source:Os},y2=Object.freeze(Object.defineProperty({__proto__:null,category:Ms,default:g2,height:Is,id:Es,name:Ns,source:Os,svg:Cs,terminals:Ps,viewBox:Ts,width:As},Symbol.toStringTag,{value:"Module"})),Bs="async-motor",Ls="异步电动机",zs="load",Rs="-62 -82 64 84",Ds=64,Fs=84,Hs='<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"/>',Ws=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],qs={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"},x2={id:Bs,name:Ls,category:zs,viewBox:Rs,width:Ds,height:Fs,svg:Hs,terminals:Ws,source:qs},b2=Object.freeze(Object.defineProperty({__proto__:null,category:zs,default:x2,height:Fs,id:Bs,name:Ls,source:qs,svg:Hs,terminals:Ws,viewBox:Rs,width:Ds},Symbol.toStringTag,{value:"Module"})),Gs="autotransformer",Xs="自耦变压器",Ys="transformer",Ks="-62 -112 64 144",Vs=64,Us=144,Js='<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"/>',Zs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Qs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},w2={id:Gs,name:Xs,category:Ys,viewBox:Ks,width:Vs,height:Us,svg:Js,terminals:Zs,source:Qs},v2=Object.freeze(Object.defineProperty({__proto__:null,category:Ys,default:w2,height:Us,id:Gs,name:Xs,source:Qs,svg:Js,terminals:Zs,viewBox:Ks,width:Vs},Symbol.toStringTag,{value:"Module"})),ei="battery",ti="电池储能",ni="storage",oi="-12 -12 29 24",ri=29,si=24,ii='<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"/>',ai=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],li=[{name:"E",label:"容量",type:"number",unit:"kWh"}],ci={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},k2={id:ei,name:ti,category:ni,viewBox:oi,width:ri,height:si,svg:ii,terminals:ai,params:li,source:ci},_2=Object.freeze(Object.defineProperty({__proto__:null,category:ni,default:k2,height:si,id:ei,name:ti,params:li,source:ci,svg:ii,terminals:ai,viewBox:oi,width:ri},Symbol.toStringTag,{value:"Module"})),di="bell",ui="电铃 (HA)",fi="control",mi="信号电铃 / 警铃。",hi="-32 -32 44 44",pi=44,gi=44,yi='<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"/>',xi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],bi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},$2={id:di,name:ui,category:fi,description:mi,viewBox:hi,width:pi,height:gi,svg:yi,terminals:xi,source:bi},S2=Object.freeze(Object.defineProperty({__proto__:null,category:fi,default:$2,description:mi,height:gi,id:di,name:ui,source:bi,svg:yi,terminals:xi,viewBox:hi,width:pi},Symbol.toStringTag,{value:"Module"})),wi="break-contact",vi="常闭触点 (NC)",ki="control",_i="常闭辅助触点 (break contact)。",$i="-2 -42 14 64",Si=14,ji=64,Ei='<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"/>',Ni=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Mi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ti={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},j2={id:wi,name:vi,category:ki,description:_i,viewBox:$i,width:Si,height:ji,svg:Ei,terminals:Ni,state:Mi,source:Ti},E2=Object.freeze(Object.defineProperty({__proto__:null,category:ki,default:j2,description:_i,height:ji,id:wi,name:vi,source:Ti,state:Mi,svg:Ei,terminals:Ni,viewBox:$i,width:Si},Symbol.toStringTag,{value:"Module"})),Ai="breaker",Ii="断路器 (QF)",Ci="switching",Pi="-7 -22 15 46",Oi=15,Bi=46,Li='<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>',zi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ri=[{name:"open",type:"boolean",default:!1,label:"断开"}],Di={x:6,y:-2,anchor:"start"},Fi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},N2={id:Ai,name:Ii,category:Ci,viewBox:Pi,width:Oi,height:Bi,svg:Li,terminals:zi,state:Ri,label:Di,source:Fi},M2=Object.freeze(Object.defineProperty({__proto__:null,category:Ci,default:N2,height:Bi,id:Ai,label:Di,name:Ii,source:Fi,state:Ri,svg:Li,terminals:zi,viewBox:Pi,width:Oi},Symbol.toStringTag,{value:"Module"})),Hi="buchholz-relay",Wi="瓦斯继电器 (63)",qi="protection",Gi="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Xi="-22 -62 44 64",Yi=44,Ki=64,Vi='<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"}],Ji={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"},T2={id:Hi,name:Wi,category:qi,description:Gi,viewBox:Xi,width:Yi,height:Ki,svg:Vi,terminals:Ui,source:Ji},A2=Object.freeze(Object.defineProperty({__proto__:null,category:qi,default:T2,description:Gi,height:Ki,id:Hi,name:Wi,source:Ji,svg:Vi,terminals:Ui,viewBox:Xi,width:Yi},Symbol.toStringTag,{value:"Module"})),Zi="busbar",Qi="母线段",ea="busbar",ta="可拉伸单母线段,多设备挂接",na="-42 -4 84 8",oa=84,ra=8,sa='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',ia=[{id:"tap",x:0,y:0,orientation:"n"}],aa={axis:"x",minLength:20,naturalSpan:80},la=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],ca={x:0,y:-6,anchor:"middle"},da={kind:"inline"},I2={id:Zi,name:Qi,category:ea,description:ta,viewBox:na,width:oa,height:ra,svg:sa,terminals:ia,stretchable:aa,params:la,label:ca,source:da},C2=Object.freeze(Object.defineProperty({__proto__:null,category:ea,default:I2,description:ta,height:ra,id:Zi,label:ca,name:Qi,params:la,source:da,stretchable:aa,svg:sa,terminals:ia,viewBox:na,width:oa},Symbol.toStringTag,{value:"Module"})),ua="buzzer",fa="蜂鸣器 (HA)",ma="control",ha="信号蜂鸣器。",pa="-32 -52 44 64",ga=44,ya=64,xa='<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"/>',ba=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],wa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},P2={id:ua,name:fa,category:ma,description:ha,viewBox:pa,width:ga,height:ya,svg:xa,terminals:ba,source:wa},O2=Object.freeze(Object.defineProperty({__proto__:null,category:ma,default:P2,description:ha,height:ya,id:ua,name:fa,source:wa,svg:xa,terminals:ba,viewBox:pa,width:ga},Symbol.toStringTag,{value:"Module"})),va="capacitor",ka="电容 (C)",_a="passive",$a="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",Sa="-7 -23 14 27",ja=14,Ea=27,Na='<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"/>',Ma=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Ta=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Aa={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},B2={id:va,name:ka,category:_a,description:$a,viewBox:Sa,width:ja,height:Ea,svg:Na,terminals:Ma,params:Ta,source:Aa},L2=Object.freeze(Object.defineProperty({__proto__:null,category:_a,default:B2,description:$a,height:Ea,id:va,name:ka,params:Ta,source:Aa,svg:Na,terminals:Ma,viewBox:Sa,width:ja},Symbol.toStringTag,{value:"Module"})),Ia="contactor",Ca="接触器 (KM)",Pa="motor-control",Oa="主回路接触器, 通常配热继电器和电机使用。",Ba="-10 -42 15 64",La=15,za=64,Ra='<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"/>',Da=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Fa=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ha={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"},z2={id:Ia,name:Ca,category:Pa,description:Oa,viewBox:Ba,width:La,height:za,svg:Ra,terminals:Da,state:Fa,source:Ha},R2=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:z2,description:Oa,height:za,id:Ia,name:Ca,source:Ha,state:Fa,svg:Ra,terminals:Da,viewBox:Ba,width:La},Symbol.toStringTag,{value:"Module"})),Wa="converter-bidir",qa="双向变流器 (PCS)",Ga="renewable",Xa="储能变流器:双向 AC ↔ DC",Ya="-42 -42 44 48",Ka=44,Va=48,Ua='<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"/>',Ja=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Za=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Qa={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},D2={id:Wa,name:qa,category:Ga,description:Xa,viewBox:Ya,width:Ka,height:Va,svg:Ua,terminals:Ja,params:Za,source:Qa},F2=Object.freeze(Object.defineProperty({__proto__:null,category:Ga,default:D2,description:Xa,height:Va,id:Wa,name:qa,params:Za,source:Qa,svg:Ua,terminals:Ja,viewBox:Ya,width:Ka},Symbol.toStringTag,{value:"Module"})),el="ct",tl="电流互感器 (CT)",nl="instrument-transformer",ol="-42 -62 54 64",rl=54,sl=64,il='<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"/>',al=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],ll={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},H2={id:el,name:tl,category:nl,viewBox:ol,width:rl,height:sl,svg:il,terminals:al,source:ll},W2=Object.freeze(Object.defineProperty({__proto__:null,category:nl,default:H2,height:sl,id:el,name:tl,source:ll,svg:il,terminals:al,viewBox:ol,width:rl},Symbol.toStringTag,{value:"Module"})),cl="dc-combiner",dl="直流汇流箱",ul="renewable",fl="光伏组串汇流箱 (4 路输入示例)。",ml="-27 -32 54 64",hl=54,pl=64,gl='<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>',yl=[{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"}],xl={kind:"inline"},q2={id:cl,name:dl,category:ul,description:fl,viewBox:ml,width:hl,height:pl,svg:gl,terminals:yl,source:xl},G2=Object.freeze(Object.defineProperty({__proto__:null,category:ul,default:q2,description:fl,height:pl,id:cl,name:dl,source:xl,svg:gl,terminals:yl,viewBox:ml,width:hl},Symbol.toStringTag,{value:"Module"})),bl="dc-disconnector",wl="直流隔离开关",vl="switching",kl="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",_l="-12 -32 30 64",$l=30,Sl=64,jl='<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"/>',El=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Nl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ml={kind:"inline"},X2={id:bl,name:wl,category:vl,description:kl,viewBox:_l,width:$l,height:Sl,svg:jl,terminals:El,state:Nl,source:Ml},Y2=Object.freeze(Object.defineProperty({__proto__:null,category:vl,default:X2,description:kl,height:Sl,id:bl,name:wl,source:Ml,state:Nl,svg:jl,terminals:El,viewBox:_l,width:$l},Symbol.toStringTag,{value:"Module"})),Tl="dc-motor",Al="直流电机 (M)",Il="load",Cl="直流电动机 (串励通用符号)。",Pl="-72 -82 89 84",Ol=89,Bl=84,Ll='<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"/>',zl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Rl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},K2={id:Tl,name:Al,category:Il,description:Cl,viewBox:Pl,width:Ol,height:Bl,svg:Ll,terminals:zl,source:Rl},V2=Object.freeze(Object.defineProperty({__proto__:null,category:Il,default:K2,description:Cl,height:Bl,id:Tl,name:Al,source:Rl,svg:Ll,terminals:zl,viewBox:Pl,width:Ol},Symbol.toStringTag,{value:"Module"})),Dl="diode",Fl="二极管 (D)",Hl="passive",Wl="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",ql="-12 -42 24 44",Gl=24,Xl=44,Yl='<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"/>',Kl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Vl={x:6,y:-20,anchor:"start"},Ul={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},U2={id:Dl,name:Fl,category:Hl,description:Wl,viewBox:ql,width:Gl,height:Xl,svg:Yl,terminals:Kl,label:Vl,source:Ul},J2=Object.freeze(Object.defineProperty({__proto__:null,category:Hl,default:U2,description:Wl,height:Xl,id:Dl,label:Vl,name:Fl,source:Ul,svg:Yl,terminals:Kl,viewBox:ql,width:Gl},Symbol.toStringTag,{value:"Module"})),Jl="disconnector",Zl="隔离开关 (QS)",Ql="switching",ec="-10 -42 15 64",tc=15,nc=64,oc='<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"/>',rc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],sc=[{name:"open",type:"boolean",default:!1,label:"断开"}],ic={x:6,y:-10,anchor:"start"},ac={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},Z2={id:Jl,name:Zl,category:Ql,viewBox:ec,width:tc,height:nc,svg:oc,terminals:rc,state:sc,label:ic,source:ac},Q2=Object.freeze(Object.defineProperty({__proto__:null,category:Ql,default:Z2,height:nc,id:Jl,label:ic,name:Zl,source:ac,state:sc,svg:oc,terminals:rc,viewBox:ec,width:tc},Symbol.toStringTag,{value:"Module"})),lc="distance-relay",cc="距离继电器 (21)",dc="protection",uc="距离 / 低阻抗保护继电器 (ANSI 21)。",fc="-62 -42 64 44",mc=64,hc=44,pc='<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>',gc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],yc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},ek={id:lc,name:cc,category:dc,description:uc,viewBox:fc,width:mc,height:hc,svg:pc,terminals:gc,source:yc},tk=Object.freeze(Object.defineProperty({__proto__:null,category:dc,default:ek,description:uc,height:hc,id:lc,name:cc,source:yc,svg:pc,terminals:gc,viewBox:fc,width:mc},Symbol.toStringTag,{value:"Module"})),xc="earth",bc="接地",wc="busbar",vc="-12 -17 24 34",kc=24,_c=34,$c='<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"/>',Sc=[{id:"t1",x:0,y:-15,orientation:"n"}],jc={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"},nk={id:xc,name:bc,category:wc,viewBox:vc,width:kc,height:_c,svg:$c,terminals:Sc,source:jc},ok=Object.freeze(Object.defineProperty({__proto__:null,category:wc,default:nk,height:_c,id:xc,name:bc,source:jc,svg:$c,terminals:Sc,viewBox:vc,width:kc},Symbol.toStringTag,{value:"Module"})),Ec="earthing-switch",Nc="接地刀闸 (QE)",Mc="switching",Tc="隔离开关 + 接地连接,单端口",Ac="-12 -32 24 64",Ic=24,Cc=64,Pc='<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"/>',Oc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Bc=[{name:"open",type:"boolean",default:!0,label:"断开"}],Lc={x:12,y:-8,anchor:"start"},zc={kind:"inline"},rk={id:Ec,name:Nc,category:Mc,description:Tc,viewBox:Ac,width:Ic,height:Cc,svg:Pc,terminals:Oc,state:Bc,label:Lc,source:zc},sk=Object.freeze(Object.defineProperty({__proto__:null,category:Mc,default:rk,description:Tc,height:Cc,id:Ec,label:Lc,name:Nc,source:zc,state:Bc,svg:Pc,terminals:Oc,viewBox:Ac,width:Ic},Symbol.toStringTag,{value:"Module"})),Rc="energy-meter",Dc="电能表 (Wh)",Fc="measurement",Hc="有功电能表 (kWh) — 服务入口 / 子表。",Wc="-22 -36 44 72",qc=44,Gc=72,Xc='<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"/>',Yc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Kc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},ik={id:Rc,name:Dc,category:Fc,description:Hc,viewBox:Wc,width:qc,height:Gc,svg:Xc,terminals:Yc,source:Kc},ak=Object.freeze(Object.defineProperty({__proto__:null,category:Fc,default:ik,description:Hc,height:Gc,id:Rc,name:Dc,source:Kc,svg:Xc,terminals:Yc,viewBox:Wc,width:qc},Symbol.toStringTag,{value:"Module"})),Vc="ev-charger",Uc="EV 充电桩",Jc="load",Zc="电动汽车充电站 / 充电桩。",Qc="-17 -27 34 49",ed=34,td=49,nd='<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>',od=[{id:"t_top",x:0,y:-25,orientation:"n"}],rd={kind:"inline"},lk={id:Vc,name:Uc,category:Jc,description:Zc,viewBox:Qc,width:ed,height:td,svg:nd,terminals:od,source:rd},ck=Object.freeze(Object.defineProperty({__proto__:null,category:Jc,default:lk,description:Zc,height:td,id:Vc,name:Uc,source:rd,svg:nd,terminals:od,viewBox:Qc,width:ed},Symbol.toStringTag,{value:"Module"})),sd="frequency-meter",id="频率表 (Hz)",ad="measurement",ld="-22 -42 44 44",cd=44,dd=44,ud='<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>',fd=[{id:"t_top",x:0,y:-40,orientation:"n"}],md={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},dk={id:sd,name:id,category:ad,viewBox:ld,width:cd,height:dd,svg:ud,terminals:fd,source:md},uk=Object.freeze(Object.defineProperty({__proto__:null,category:ad,default:dk,height:dd,id:sd,name:id,source:md,svg:ud,terminals:fd,viewBox:ld,width:cd},Symbol.toStringTag,{value:"Module"})),hd="fuse-switch-disconnector",pd="熔断器式隔离开关",gd="switching",yd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",xd="-8 -32 12 64",bd=12,wd=64,vd='<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"/>',kd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],_d=[{name:"open",type:"boolean",default:!1,label:"断开"}],$d={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"},fk={id:hd,name:pd,category:gd,description:yd,viewBox:xd,width:bd,height:wd,svg:vd,terminals:kd,state:_d,source:$d},mk=Object.freeze(Object.defineProperty({__proto__:null,category:gd,default:fk,description:yd,height:wd,id:hd,name:pd,source:$d,state:_d,svg:vd,terminals:kd,viewBox:xd,width:bd},Symbol.toStringTag,{value:"Module"})),Sd="fuse",jd="熔断器 (FU)",Ed="switching",Nd="-7 -32 14 64",Md=14,Td=64,Ad='<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"/>',Id=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Cd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Pd={x:7,y:-2,anchor:"start"},Od={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},hk={id:Sd,name:jd,category:Ed,viewBox:Nd,width:Md,height:Td,svg:Ad,terminals:Id,state:Cd,label:Pd,source:Od},pk=Object.freeze(Object.defineProperty({__proto__:null,category:Ed,default:hk,height:Td,id:Sd,label:Pd,name:jd,source:Od,state:Cd,svg:Ad,terminals:Id,viewBox:Nd,width:Md},Symbol.toStringTag,{value:"Module"})),Bd="generator",Ld="发电机 (G)",zd="source",Rd="-42 -42 44 44",Dd=44,Fd=44,Hd='<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>',Wd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],qd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},gk={id:Bd,name:Ld,category:zd,viewBox:Rd,width:Dd,height:Fd,svg:Hd,terminals:Wd,source:qd},yk=Object.freeze(Object.defineProperty({__proto__:null,category:zd,default:gk,height:Fd,id:Bd,name:Ld,source:qd,svg:Hd,terminals:Wd,viewBox:Rd,width:Dd},Symbol.toStringTag,{value:"Module"})),Gd="genset",Xd="发电机组 (G)",Yd="source",Kd="柴油 / 燃气发电机组。",Vd="-28 -22 56 64",Ud=56,Jd=64,Zd='<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"/>',Qd=[{id:"t_out",x:0,y:40,orientation:"s"}],eu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],tu={kind:"inline"},xk={id:Gd,name:Xd,category:Yd,description:Kd,viewBox:Vd,width:Ud,height:Jd,svg:Zd,terminals:Qd,params:eu,source:tu},bk=Object.freeze(Object.defineProperty({__proto__:null,category:Yd,default:xk,description:Kd,height:Jd,id:Gd,name:Xd,params:eu,source:tu,svg:Zd,terminals:Qd,viewBox:Vd,width:Ud},Symbol.toStringTag,{value:"Module"})),nu="gfci-breaker",ou="GFCI 断路器 (RCBO)",ru="protection",su="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",iu="-18 -22 22 44",au=22,lu=44,cu='<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"/>',du=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],uu=[{name:"open",type:"boolean",default:!1,label:"断开"}],fu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],mu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},wk={id:nu,name:ou,category:ru,description:su,viewBox:iu,width:au,height:lu,svg:cu,terminals:du,state:uu,params:fu,source:mu},vk=Object.freeze(Object.defineProperty({__proto__:null,category:ru,default:wk,description:su,height:lu,id:nu,name:ou,params:fu,source:mu,state:uu,svg:cu,terminals:du,viewBox:iu,width:au},Symbol.toStringTag,{value:"Module"})),hu="grid-source",pu="系统电源",gu="source",yu="无穷大母线 / 外部电网",xu="-16 -31 32 53",bu=32,wu=53,vu='<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"/>',ku=[{id:"t_bottom",x:0,y:20,orientation:"s"}],_u={kind:"inline"},kk={id:hu,name:pu,category:gu,description:yu,viewBox:xu,width:bu,height:wu,svg:vu,terminals:ku,source:_u},_k=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:kk,description:yu,height:wu,id:hu,name:pu,source:_u,svg:vu,terminals:ku,viewBox:xu,width:bu},Symbol.toStringTag,{value:"Module"})),$u="grounding-transformer",Su="接地变 (Z形)",ju="grounding",Eu="星-曲折接线变压器,中性点接地用",Nu="-62 -152 64 164",Mu=64,Tu=164,Au='<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"/>',Iu=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Cu={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"},$k={id:$u,name:Su,category:ju,description:Eu,viewBox:Nu,width:Mu,height:Tu,svg:Au,terminals:Iu,source:Cu},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:ju,default:$k,description:Eu,height:Tu,id:$u,name:Su,source:Cu,svg:Au,terminals:Iu,viewBox:Nu,width:Mu},Symbol.toStringTag,{value:"Module"})),Pu="heater",Ou="电加热器 (EH)",Bu="load",Lu="电阻加热元件 / 电热负荷。",zu="-22 -7 54 14",Ru=54,Du=14,Fu='<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"/>',Hu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Wu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],qu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},jk={id:Pu,name:Ou,category:Bu,description:Lu,viewBox:zu,width:Ru,height:Du,svg:Fu,terminals:Hu,params:Wu,source:qu},Ek=Object.freeze(Object.defineProperty({__proto__:null,category:Bu,default:jk,description:Lu,height:Du,id:Pu,name:Ou,params:Wu,source:qu,svg:Fu,terminals:Hu,viewBox:zu,width:Ru},Symbol.toStringTag,{value:"Module"})),Gu="igbt",Xu="绝缘栅双极晶体管 (IGBT)",Yu="passive",Ku="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Vu="-32 -32 54 74",Uu=54,Ju=74,Zu='<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"/>',Qu=[{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"}],ef={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"},Nk={id:Gu,name:Xu,category:Yu,description:Ku,viewBox:Vu,width:Uu,height:Ju,svg:Zu,terminals:Qu,source:ef},Mk=Object.freeze(Object.defineProperty({__proto__:null,category:Yu,default:Nk,description:Ku,height:Ju,id:Gu,name:Xu,source:ef,svg:Zu,terminals:Qu,viewBox:Vu,width:Uu},Symbol.toStringTag,{value:"Module"})),tf="indicator-light",nf="指示灯 (HL)",of="control",rf="信号 / 状态指示灯。",sf="-12 -22 24 24",af=24,lf=24,cf='<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"/>',df=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],uf=[{name:"color",label:"颜色",type:"string"}],ff={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},Tk={id:tf,name:nf,category:of,description:rf,viewBox:sf,width:af,height:lf,svg:cf,terminals:df,params:uf,source:ff},Ak=Object.freeze(Object.defineProperty({__proto__:null,category:of,default:Tk,description:rf,height:lf,id:tf,name:nf,params:uf,source:ff,svg:cf,terminals:df,viewBox:sf,width:af},Symbol.toStringTag,{value:"Module"})),mf="inductor",hf="电感 (L)",pf="passive",gf="通用电感 / 线圈 / 扼流圈。",yf="-17 -32 34 64",xf=34,bf=64,wf='<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"/>',vf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],kf=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],_f={x:6,y:0,anchor:"start"},$f={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Ik={id:mf,name:hf,category:pf,description:gf,viewBox:yf,width:xf,height:bf,svg:wf,terminals:vf,params:kf,label:_f,source:$f},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:pf,default:Ik,description:gf,height:bf,id:mf,label:_f,name:hf,params:kf,source:$f,svg:wf,terminals:vf,viewBox:yf,width:xf},Symbol.toStringTag,{value:"Module"})),Sf="inverter",jf="逆变器 (DC→AC)",Ef="renewable",Nf="-42 -42 44 44",Mf=44,Tf=44,Af='<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"/>',If=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],Cf={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Pk={id:Sf,name:jf,category:Ef,viewBox:Nf,width:Mf,height:Tf,svg:Af,terminals:If,source:Cf},Ok=Object.freeze(Object.defineProperty({__proto__:null,category:Ef,default:Pk,height:Tf,id:Sf,name:jf,source:Cf,svg:Af,terminals:If,viewBox:Nf,width:Mf},Symbol.toStringTag,{value:"Module"})),Pf="limit-switch",Of="限位开关 (SQ)",Bf="control",Lf="行程 / 位置开关 (常开, 机械操作)。",zf="-10 -42 12 64",Rf=12,Df=64,Ff='<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"/>',Hf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Wf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],qf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Bk={id:Pf,name:Of,category:Bf,description:Lf,viewBox:zf,width:Rf,height:Df,svg:Ff,terminals:Hf,state:Wf,source:qf},Lk=Object.freeze(Object.defineProperty({__proto__:null,category:Bf,default:Bk,description:Lf,height:Df,id:Pf,name:Of,source:qf,state:Wf,svg:Ff,terminals:Hf,viewBox:zf,width:Rf},Symbol.toStringTag,{value:"Module"})),Gf="load-switch",Xf="负荷开关",Yf="switching",Kf="-10 -42 14 64",Vf=14,Uf=64,Jf='<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"/>',Zf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Qf=[{name:"open",type:"boolean",default:!1,label:"断开"}],em={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"},zk={id:Gf,name:Xf,category:Yf,viewBox:Kf,width:Vf,height:Uf,svg:Jf,terminals:Zf,state:Qf,source:em},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:Yf,default:zk,height:Uf,id:Gf,name:Xf,source:em,state:Qf,svg:Jf,terminals:Zf,viewBox:Kf,width:Vf},Symbol.toStringTag,{value:"Module"})),tm="load",nm="负荷",om="load",rm="抽象负荷(电流流出箭头)",sm="-8 -22 16 46",im=16,am=46,lm='<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"/>',cm=[{id:"t_top",x:0,y:-20,orientation:"n"}],dm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],um={x:6,y:0,anchor:"start"},fm={kind:"inline"},Dk={id:tm,name:nm,category:om,description:rm,viewBox:sm,width:im,height:am,svg:lm,terminals:cm,params:dm,label:um,source:fm},Fk=Object.freeze(Object.defineProperty({__proto__:null,category:om,default:Dk,description:rm,height:am,id:tm,label:um,name:nm,params:dm,source:fm,svg:lm,terminals:cm,viewBox:sm,width:im},Symbol.toStringTag,{value:"Module"})),mm="make-contact",hm="常开触点 (NO)",pm="control",gm="常开辅助触点 (make contact)。",ym="-10 -42 12 64",xm=12,bm=64,wm='<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"/>',vm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],km=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],_m={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"},Hk={id:mm,name:hm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,state:km,source:_m},Wk=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:Hk,description:gm,height:bm,id:mm,name:hm,source:_m,state:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),$m="motor-starter",Sm="电机启动器",jm="motor-control",Em="电机启动器 (IEC 60617 通用符号)。",Nm="-22 -27 44 54",Mm=44,Tm=54,Am='<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"/>',Im=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Cm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},qk={id:$m,name:Sm,category:jm,description:Em,viewBox:Nm,width:Mm,height:Tm,svg:Am,terminals:Im,source:Cm},Gk=Object.freeze(Object.defineProperty({__proto__:null,category:jm,default:qk,description:Em,height:Tm,id:$m,name:Sm,source:Cm,svg:Am,terminals:Im,viewBox:Nm,width:Mm},Symbol.toStringTag,{value:"Module"})),Pm="ngr",Om="中性点电阻 (NGR)",Bm="grounding",Lm="小电阻接地:连接变压器中性点到地",zm="-12 -32 24 62",Rm=24,Dm=62,Fm='<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"/>',Hm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Wm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],qm={kind:"inline"},Xk={id:Pm,name:Om,category:Bm,description:Lm,viewBox:zm,width:Rm,height:Dm,svg:Fm,terminals:Hm,params:Wm,source:qm},Yk=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:Xk,description:Lm,height:Dm,id:Pm,name:Om,params:Wm,source:qm,svg:Fm,terminals:Hm,viewBox:zm,width:Rm},Symbol.toStringTag,{value:"Module"})),Gm="overcurrent-relay",Xm="过流继电器 (50/51)",Ym="protection",Km="过电流保护继电器 (ANSI 50/51)。",Vm="-62 -62 64 64",Um=64,Jm=64,Zm='<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>',Qm=[{id:"t_top",x:-30,y:-60,orientation:"n"}],eh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Kk={id:Gm,name:Xm,category:Ym,description:Km,viewBox:Vm,width:Um,height:Jm,svg:Zm,terminals:Qm,source:eh},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:Ym,default:Kk,description:Km,height:Jm,id:Gm,name:Xm,source:eh,svg:Zm,terminals:Qm,viewBox:Vm,width:Um},Symbol.toStringTag,{value:"Module"})),th="phase-failure-relay",nh="断相继电器",oh="protection",rh="断相 / 缺相保护继电器。",sh="-62 -42 64 44",ih=64,ah=44,lh='<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>',ch=[{id:"t_top",x:-30,y:-40,orientation:"n"}],dh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Uk={id:th,name:nh,category:oh,description:rh,viewBox:sh,width:ih,height:ah,svg:lh,terminals:ch,source:dh},Jk=Object.freeze(Object.defineProperty({__proto__:null,category:oh,default:Uk,description:rh,height:ah,id:th,name:nh,source:dh,svg:lh,terminals:ch,viewBox:sh,width:ih},Symbol.toStringTag,{value:"Module"})),uh="plc",fh="PLC / 控制器",mh="control",hh="可编程逻辑控制器 (PLC)。",ph="-24 -42 48 84",gh=48,yh=84,xh='<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"/>',bh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],wh={kind:"inline"},Zk={id:uh,name:fh,category:mh,description:hh,viewBox:ph,width:gh,height:yh,svg:xh,terminals:bh,source:wh},Qk=Object.freeze(Object.defineProperty({__proto__:null,category:mh,default:Zk,description:hh,height:yh,id:uh,name:fh,source:wh,svg:xh,terminals:bh,viewBox:ph,width:gh},Symbol.toStringTag,{value:"Module"})),vh="power-factor-meter",kh="功率因数表 (cosφ)",_h="measurement",$h="功率因数表 (cosφ)。",Sh="-22 -42 44 44",jh=44,Eh=44,Nh='<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>',Mh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Th={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},e_={id:vh,name:kh,category:_h,description:$h,viewBox:Sh,width:jh,height:Eh,svg:Nh,terminals:Mh,source:Th},t_=Object.freeze(Object.defineProperty({__proto__:null,category:_h,default:e_,description:$h,height:Eh,id:vh,name:kh,source:Th,svg:Nh,terminals:Mh,viewBox:Sh,width:jh},Symbol.toStringTag,{value:"Module"})),Ah="power-supply",Ih="开关电源 (PS)",Ch="source",Ph="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Oh="-24 -42 48 84",Bh=48,Lh=84,zh='<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"/>',Rh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],Dh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Fh={kind:"inline"},n_={id:Ah,name:Ih,category:Ch,description:Ph,viewBox:Oh,width:Bh,height:Lh,svg:zh,terminals:Rh,params:Dh,source:Fh},o_=Object.freeze(Object.defineProperty({__proto__:null,category:Ch,default:n_,description:Ph,height:Lh,id:Ah,name:Ih,params:Dh,source:Fh,svg:zh,terminals:Rh,viewBox:Oh,width:Bh},Symbol.toStringTag,{value:"Module"})),Hh="protective-relay",Wh="保护继电器",qh="protection",Gh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Xh="-32 -42 64 44",Yh=64,Kh=44,Vh='<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"}],Jh={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"},r_={id:Hh,name:Wh,category:qh,description:Gh,viewBox:Xh,width:Yh,height:Kh,svg:Vh,terminals:Uh,source:Jh},s_=Object.freeze(Object.defineProperty({__proto__:null,category:qh,default:r_,description:Gh,height:Kh,id:Hh,name:Wh,source:Jh,svg:Vh,terminals:Uh,viewBox:Xh,width:Yh},Symbol.toStringTag,{value:"Module"})),Zh="proximity-switch",Qh="接近开关 (SQ)",e0="control",t0="接近传感器 / 无触点接近开关。",n0="-12 -32 24 64",o0=24,r0=64,s0='<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"/>',i0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],a0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},i_={id:Zh,name:Qh,category:e0,description:t0,viewBox:n0,width:o0,height:r0,svg:s0,terminals:i0,source:a0},a_=Object.freeze(Object.defineProperty({__proto__:null,category:e0,default:i_,description:t0,height:r0,id:Zh,name:Qh,source:a0,svg:s0,terminals:i0,viewBox:n0,width:o0},Symbol.toStringTag,{value:"Module"})),l0="pt",c0="电压互感器 (PT)",d0="instrument-transformer",u0="-22 -42 44 115",f0=44,m0=115,h0='<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"/>',p0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],g0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},l_={id:l0,name:c0,category:d0,viewBox:u0,width:f0,height:m0,svg:h0,terminals:p0,source:g0},c_=Object.freeze(Object.defineProperty({__proto__:null,category:d0,default:l_,height:m0,id:l0,name:c0,source:g0,svg:h0,terminals:p0,viewBox:u0,width:f0},Symbol.toStringTag,{value:"Module"})),y0="push-button",x0="按钮 (SB)",b0="control",w0="手动按钮, 自动复位 (常开 make)。",v0="-37 -42 39 64",k0=39,_0=64,$0='<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"/>',S0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],j0={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"},d_={id:y0,name:x0,category:b0,description:w0,viewBox:v0,width:k0,height:_0,svg:$0,terminals:S0,source:j0},u_=Object.freeze(Object.defineProperty({__proto__:null,category:b0,default:d_,description:w0,height:_0,id:y0,name:x0,source:j0,svg:$0,terminals:S0,viewBox:v0,width:k0},Symbol.toStringTag,{value:"Module"})),E0="pv",N0="光伏组件",M0="renewable",T0="-33 -22 85 64",A0=85,I0=64,C0='<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"/>',P0=[{id:"t_dc",x:50,y:10,orientation:"e"}],O0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},f_={id:E0,name:N0,category:M0,viewBox:T0,width:A0,height:I0,svg:C0,terminals:P0,source:O0},m_=Object.freeze(Object.defineProperty({__proto__:null,category:M0,default:f_,height:I0,id:E0,name:N0,source:O0,svg:C0,terminals:P0,viewBox:T0,width:A0},Symbol.toStringTag,{value:"Module"})),B0="rcd",L0="剩余电流装置 (RCD)",z0="protection",R0="不带过流保护的剩余电流断路器 (IEC 61008)。",D0="-12 -22 19 44",F0=19,H0=44,W0='<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"/>',q0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],G0=[{name:"open",type:"boolean",default:!1,label:"断开"}],X0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Y0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},h_={id:B0,name:L0,category:z0,description:R0,viewBox:D0,width:F0,height:H0,svg:W0,terminals:q0,state:G0,params:X0,source:Y0},p_=Object.freeze(Object.defineProperty({__proto__:null,category:z0,default:h_,description:R0,height:H0,id:B0,name:L0,params:X0,source:Y0,state:G0,svg:W0,terminals:q0,viewBox:D0,width:F0},Symbol.toStringTag,{value:"Module"})),K0="recloser",V0="重合闸 (Recloser)",U0="protection",J0="中压自动重合闸开关。",Z0="-12 -32 36 64",Q0=36,ep=64,tp='<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>',np=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],op=[{name:"open",type:"boolean",default:!1,label:"断开"}],rp={kind:"inline"},g_={id:K0,name:V0,category:U0,description:J0,viewBox:Z0,width:Q0,height:ep,svg:tp,terminals:np,state:op,source:rp},y_=Object.freeze(Object.defineProperty({__proto__:null,category:U0,default:g_,description:J0,height:ep,id:K0,name:V0,source:rp,state:op,svg:tp,terminals:np,viewBox:Z0,width:Q0},Symbol.toStringTag,{value:"Module"})),sp="rectifier",ip="整流器 (AC→DC)",ap="renewable",lp="-42 -42 44 44",cp=44,dp=44,up='<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"/>',fp=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],mp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},x_={id:sp,name:ip,category:ap,viewBox:lp,width:cp,height:dp,svg:up,terminals:fp,source:mp},b_=Object.freeze(Object.defineProperty({__proto__:null,category:ap,default:x_,height:dp,id:sp,name:ip,source:mp,svg:up,terminals:fp,viewBox:lp,width:cp},Symbol.toStringTag,{value:"Module"})),hp="relay-coil",pp="继电器线圈 (KA)",gp="control",yp="继电器 / 接触器操作线圈 (方框)。",xp="-22 -22 44 44",bp=44,wp=44,vp='<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"/>',kp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_p={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"},w_={id:hp,name:pp,category:gp,description:yp,viewBox:xp,width:bp,height:wp,svg:vp,terminals:kp,source:_p},v_=Object.freeze(Object.defineProperty({__proto__:null,category:gp,default:w_,description:yp,height:wp,id:hp,name:pp,source:_p,svg:vp,terminals:kp,viewBox:xp,width:bp},Symbol.toStringTag,{value:"Module"})),$p="resistor",Sp="电阻 (R)",jp="passive",Ep="通用电阻 / 限流 / 制动电阻。",Np="-6 -23 12 35",Mp=12,Tp=35,Ap='<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"/>',Ip=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Cp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Pp={x:6,y:0,anchor:"start"},Op={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},k_={id:$p,name:Sp,category:jp,description:Ep,viewBox:Np,width:Mp,height:Tp,svg:Ap,terminals:Ip,params:Cp,label:Pp,source:Op},__=Object.freeze(Object.defineProperty({__proto__:null,category:jp,default:k_,description:Ep,height:Tp,id:$p,label:Pp,name:Sp,params:Cp,source:Op,svg:Ap,terminals:Ip,viewBox:Np,width:Mp},Symbol.toStringTag,{value:"Module"})),Bp="reverse-power-relay",Lp="逆功率继电器 (32)",zp="protection",Rp="逆功率 / 逆流保护继电器 (ANSI 32)。",Dp="-62 -42 64 44",Fp=64,Hp=44,Wp='<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"/>',qp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Gp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},$_={id:Bp,name:Lp,category:zp,description:Rp,viewBox:Dp,width:Fp,height:Hp,svg:Wp,terminals:qp,source:Gp},S_=Object.freeze(Object.defineProperty({__proto__:null,category:zp,default:$_,description:Rp,height:Hp,id:Bp,name:Lp,source:Gp,svg:Wp,terminals:qp,viewBox:Dp,width:Fp},Symbol.toStringTag,{value:"Module"})),Xp="selector-switch",Yp="选择开关 (SA)",Kp="switching",Vp="转换 / 选择开关 (旋转操作, 保位)。",Up="-34 -42 36 64",Jp=36,Zp=64,Qp='<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"/>',eg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],tg=[{name:"open",type:"boolean",default:!1,label:"断开"}],ng={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"},j_={id:Xp,name:Yp,category:Kp,description:Vp,viewBox:Up,width:Jp,height:Zp,svg:Qp,terminals:eg,state:tg,source:ng},E_=Object.freeze(Object.defineProperty({__proto__:null,category:Kp,default:j_,description:Vp,height:Zp,id:Xp,name:Yp,source:ng,state:tg,svg:Qp,terminals:eg,viewBox:Up,width:Jp},Symbol.toStringTag,{value:"Module"})),og="series-reactor",rg="串联电抗器",sg="compensation",ig="与并联电抗器同符号;通过用法区分。",ag="-62 -82 64 104",lg=64,cg=104,dg='<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"/>',ug=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],fg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},N_={id:og,name:rg,category:sg,description:ig,viewBox:ag,width:lg,height:cg,svg:dg,terminals:ug,source:fg},M_=Object.freeze(Object.defineProperty({__proto__:null,category:sg,default:N_,description:ig,height:cg,id:og,name:rg,source:fg,svg:dg,terminals:ug,viewBox:ag,width:lg},Symbol.toStringTag,{value:"Module"})),mg="shunt-capacitor",hg="并联电容器",pg="compensation",gg="-7 -23 14 27",yg=14,xg=27,bg='<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"/>',wg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],vg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],kg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},T_={id:mg,name:hg,category:pg,viewBox:gg,width:yg,height:xg,svg:bg,terminals:wg,params:vg,source:kg},A_=Object.freeze(Object.defineProperty({__proto__:null,category:pg,default:T_,height:xg,id:mg,name:hg,params:vg,source:kg,svg:bg,terminals:wg,viewBox:gg,width:yg},Symbol.toStringTag,{value:"Module"})),_g="shunt-reactor",$g="并联电抗器",Sg="compensation",jg="-62 -82 64 104",Eg=64,Ng=104,Mg='<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"/>',Tg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Ag={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},I_={id:_g,name:$g,category:Sg,viewBox:jg,width:Eg,height:Ng,svg:Mg,terminals:Tg,source:Ag},C_=Object.freeze(Object.defineProperty({__proto__:null,category:Sg,default:I_,height:Ng,id:_g,name:$g,source:Ag,svg:Mg,terminals:Tg,viewBox:jg,width:Eg},Symbol.toStringTag,{value:"Module"})),Ig="siren",Cg="警笛 (HA)",Pg="control",Og="声响警笛 / 报警器。",Bg="-32 -42 44 54",Lg=44,zg=54,Rg='<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"/>',Dg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Fg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},P_={id:Ig,name:Cg,category:Pg,description:Og,viewBox:Bg,width:Lg,height:zg,svg:Rg,terminals:Dg,source:Fg},O_=Object.freeze(Object.defineProperty({__proto__:null,category:Pg,default:P_,description:Og,height:zg,id:Ig,name:Cg,source:Fg,svg:Rg,terminals:Dg,viewBox:Bg,width:Lg},Symbol.toStringTag,{value:"Module"})),Hg="socket-outlet",Wg="插座 / 连接器",qg="load",Gg="电源插座 / 多极连接器。",Xg="-7 -2 13 34",Yg=13,Kg=34,Vg='<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"}],Jg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
197
|
-
unifilar`},B_={id:Hg,name:Wg,category:qg,description:Gg,viewBox:Xg,width:Yg,height:Kg,svg:Vg,terminals:Ug,source:Jg},L_=Object.freeze(Object.defineProperty({__proto__:null,category:qg,default:B_,description:Gg,height:Kg,id:Hg,name:Wg,source:Jg,svg:Vg,terminals:Ug,viewBox:Xg,width:Yg},Symbol.toStringTag,{value:"Module"})),Zg="soft-starter",Qg="软启动器",e1="motor-control",t1="电机软启动器 (晶闸管降压启动)。",n1="-22 -42 44 84",o1=44,r1=84,s1='<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"/>',i1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],a1={kind:"inline"},z_={id:Zg,name:Qg,category:e1,description:t1,viewBox:n1,width:o1,height:r1,svg:s1,terminals:i1,source:a1},R_=Object.freeze(Object.defineProperty({__proto__:null,category:e1,default:z_,description:t1,height:r1,id:Zg,name:Qg,source:a1,svg:s1,terminals:i1,viewBox:n1,width:o1},Symbol.toStringTag,{value:"Module"})),l1="sync-motor",c1="同步电动机",d1="load",u1="-62 -82 64 114",f1=64,m1=114,h1='<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"/>',p1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],g1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},D_={id:l1,name:c1,category:d1,viewBox:u1,width:f1,height:m1,svg:h1,terminals:p1,source:g1},F_=Object.freeze(Object.defineProperty({__proto__:null,category:d1,default:D_,height:m1,id:l1,name:c1,source:g1,svg:h1,terminals:p1,viewBox:u1,width:f1},Symbol.toStringTag,{value:"Module"})),y1="synchronoscope",x1="同步表",b1="measurement",w1="同步指示器 / 同步表。",v1="-22 -42 44 44",k1=44,_1=44,$1='<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"/>',S1=[{id:"t_top",x:0,y:-40,orientation:"n"}],j1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},H_={id:y1,name:x1,category:b1,description:w1,viewBox:v1,width:k1,height:_1,svg:$1,terminals:S1,source:j1},W_=Object.freeze(Object.defineProperty({__proto__:null,category:b1,default:H_,description:w1,height:_1,id:y1,name:x1,source:j1,svg:$1,terminals:S1,viewBox:v1,width:k1},Symbol.toStringTag,{value:"Module"})),E1="terminal",N1="接线端子 / 节点 (X)",M1="busbar",T1="接线端子 / 接线盒 / 汇接节点。",A1="-5 -5 10 10",I1=10,C1=10,P1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',O1=[{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"}],B1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},q_={id:E1,name:N1,category:M1,description:T1,viewBox:A1,width:I1,height:C1,svg:P1,terminals:O1,source:B1},G_=Object.freeze(Object.defineProperty({__proto__:null,category:M1,default:q_,description:T1,height:C1,id:E1,name:N1,source:B1,svg:P1,terminals:O1,viewBox:A1,width:I1},Symbol.toStringTag,{value:"Module"})),L1="thermal-overload",z1="热过载继电器",R1="motor-control",D1="电机热过载保护继电器, 通常串接在接触器和电机之间。",F1="-9 -32 19 64",H1=19,W1=64,q1='<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"/>',G1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],X1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],Y1={kind:"inline"},X_={id:L1,name:z1,category:R1,description:D1,viewBox:F1,width:H1,height:W1,svg:q1,terminals:G1,state:X1,source:Y1},Y_=Object.freeze(Object.defineProperty({__proto__:null,category:R1,default:X_,description:D1,height:W1,id:L1,name:z1,source:Y1,state:X1,svg:q1,terminals:G1,viewBox:F1,width:H1},Symbol.toStringTag,{value:"Module"})),K1="thermocouple",V1="热电偶 (BT)",U1="measurement",J1="热电偶温度传感器。",Z1="-26 -42 52 46",Q1=52,ey=46,ty='<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"/>',ny=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],oy={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},K_={id:K1,name:V1,category:U1,description:J1,viewBox:Z1,width:Q1,height:ey,svg:ty,terminals:ny,source:oy},V_=Object.freeze(Object.defineProperty({__proto__:null,category:U1,default:K_,description:J1,height:ey,id:K1,name:V1,source:oy,svg:ty,terminals:ny,viewBox:Z1,width:Q1},Symbol.toStringTag,{value:"Module"})),ry="thyristor",sy="晶闸管 (V)",iy="passive",ay="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ly="-22 -42 34 44",cy=34,dy=44,uy='<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"/>',fy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],my={x:6,y:-20,anchor:"start"},hy={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)"},U_={id:ry,name:sy,category:iy,description:ay,viewBox:ly,width:cy,height:dy,svg:uy,terminals:fy,label:my,source:hy},J_=Object.freeze(Object.defineProperty({__proto__:null,category:iy,default:U_,description:ay,height:dy,id:ry,label:my,name:sy,source:hy,svg:uy,terminals:fy,viewBox:ly,width:cy},Symbol.toStringTag,{value:"Module"})),py="time-relay",gy="时间继电器 (KT)",yy="control",xy="延时 (缓动) 继电器线圈。",by="-32 -22 54 44",wy=54,vy=44,ky='<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"/>',_y=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],$y={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"},Z_={id:py,name:gy,category:yy,description:xy,viewBox:by,width:wy,height:vy,svg:ky,terminals:_y,source:$y},Q_=Object.freeze(Object.defineProperty({__proto__:null,category:yy,default:Z_,description:xy,height:vy,id:py,name:gy,source:$y,svg:ky,terminals:_y,viewBox:by,width:wy},Symbol.toStringTag,{value:"Module"})),Sy="transfer-switch",jy="切换开关 (ATS)",Ey="switching",Ny="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",My="-27 -32 51 64",Ty=51,Ay=64,Iy='<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"/>',Cy=[{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"}],Py=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Oy={kind:"inline"},e$={id:Sy,name:jy,category:Ey,description:Ny,viewBox:My,width:Ty,height:Ay,svg:Iy,terminals:Cy,state:Py,source:Oy},t$=Object.freeze(Object.defineProperty({__proto__:null,category:Ey,default:e$,description:Ny,height:Ay,id:Sy,name:jy,source:Oy,state:Py,svg:Iy,terminals:Cy,viewBox:My,width:Ty},Symbol.toStringTag,{value:"Module"})),By="transformer-2w",Ly="双绕组变压器",zy="transformer",Ry="-62 -142 64 144",Dy=64,Fy=144,Hy='<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"/>',Wy=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],qy=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],Gy={x:4,y:-68,anchor:"start"},Xy={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"},n$={id:By,name:Ly,category:zy,viewBox:Ry,width:Dy,height:Fy,svg:Hy,terminals:Wy,params:qy,label:Gy,source:Xy},o$=Object.freeze(Object.defineProperty({__proto__:null,category:zy,default:n$,height:Fy,id:By,label:Gy,name:Ly,params:qy,source:Xy,svg:Hy,terminals:Wy,viewBox:Ry,width:Dy},Symbol.toStringTag,{value:"Module"})),Yy="transformer-3w",Ky="三绕组变压器",Vy="transformer",Uy="-82 -131 114 133",Jy=114,Zy=133,Qy='<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"/>',ex=[{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"}],tx={x:4,y:-64,anchor:"start"},nx={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"},r$={id:Yy,name:Ky,category:Vy,viewBox:Uy,width:Jy,height:Zy,svg:Qy,terminals:ex,label:tx,source:nx},s$=Object.freeze(Object.defineProperty({__proto__:null,category:Vy,default:r$,height:Zy,id:Yy,label:tx,name:Ky,source:nx,svg:Qy,terminals:ex,viewBox:Uy,width:Jy},Symbol.toStringTag,{value:"Module"})),ox="triac",rx="双向晶闸管 (V)",sx="passive",ix="双向三极晶闸管 (TRIAC)。",ax="-22 -42 44 44",lx=44,cx=44,dx='<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"/>',ux=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fx={x:6,y:-20,anchor:"start"},mx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},i$={id:ox,name:rx,category:sx,description:ix,viewBox:ax,width:lx,height:cx,svg:dx,terminals:ux,label:fx,source:mx},a$=Object.freeze(Object.defineProperty({__proto__:null,category:sx,default:i$,description:ix,height:cx,id:ox,label:fx,name:rx,source:mx,svg:dx,terminals:ux,viewBox:ax,width:lx},Symbol.toStringTag,{value:"Module"})),hx="undervoltage-relay",px="欠压继电器 (27)",gx="protection",yx="欠电压保护继电器 (ANSI 27)。",xx="-62 -82 64 84",bx=64,wx=84,vx='<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>',kx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],_x={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},l$={id:hx,name:px,category:gx,description:yx,viewBox:xx,width:bx,height:wx,svg:vx,terminals:kx,source:_x},c$=Object.freeze(Object.defineProperty({__proto__:null,category:gx,default:l$,description:yx,height:wx,id:hx,name:px,source:_x,svg:vx,terminals:kx,viewBox:xx,width:bx},Symbol.toStringTag,{value:"Module"})),$x="ups",Sx="不间断电源 (UPS)",jx="source",Ex="在线 / 后备式不间断电源。",Nx="-26 -42 52 84",Mx=52,Tx=84,Ax='<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"/>',Ix=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Cx=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Px={kind:"inline"},d$={id:$x,name:Sx,category:jx,description:Ex,viewBox:Nx,width:Mx,height:Tx,svg:Ax,terminals:Ix,params:Cx,source:Px},u$=Object.freeze(Object.defineProperty({__proto__:null,category:jx,default:d$,description:Ex,height:Tx,id:$x,name:Sx,params:Cx,source:Px,svg:Ax,terminals:Ix,viewBox:Nx,width:Mx},Symbol.toStringTag,{value:"Module"})),Ox="varmeter",Bx="无功功率表 (var)",Lx="measurement",zx="无功功率表 (var)。",Rx="-22 -42 44 44",Dx=44,Fx=44,Hx='<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>',Wx=[{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_04.elmt",qetEnglishName:"Varmeter"},f$={id:Ox,name:Bx,category:Lx,description:zx,viewBox:Rx,width:Dx,height:Fx,svg:Hx,terminals:Wx,source:qx},m$=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:f$,description:zx,height:Fx,id:Ox,name:Bx,source:qx,svg:Hx,terminals:Wx,viewBox:Rx,width:Dx},Symbol.toStringTag,{value:"Module"})),Gx="vfd",Xx="变频器 (VFD)",Yx="motor-control",Kx="Variable Frequency Drive — 异步电动机调速。",Vx="-24 -42 48 84",Ux=48,Jx=84,Zx='<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"/>',Qx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],eb={kind:"inline"},h$={id:Gx,name:Xx,category:Yx,description:Kx,viewBox:Vx,width:Ux,height:Jx,svg:Zx,terminals:Qx,source:eb},p$=Object.freeze(Object.defineProperty({__proto__:null,category:Yx,default:h$,description:Kx,height:Jx,id:Gx,name:Xx,source:eb,svg:Zx,terminals:Qx,viewBox:Vx,width:Ux},Symbol.toStringTag,{value:"Module"})),tb="voltage-regulator",nb="调压器 (T)",ob="transformer",rb="可调感应调压器 / 自耦调压器。",sb="-17 -32 38 64",ib=38,ab=64,lb='<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"/>',cb=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],db=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],ub={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},g$={id:tb,name:nb,category:ob,description:rb,viewBox:sb,width:ib,height:ab,svg:lb,terminals:cb,params:db,source:ub},y$=Object.freeze(Object.defineProperty({__proto__:null,category:ob,default:g$,description:rb,height:ab,id:tb,name:nb,params:db,source:ub,svg:lb,terminals:cb,viewBox:sb,width:ib},Symbol.toStringTag,{value:"Module"})),fb="voltmeter",mb="电压表 (V)",hb="measurement",pb="-22 -42 44 44",gb=44,yb=44,xb='<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>',bb=[{id:"t_top",x:0,y:-40,orientation:"n"}],wb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},x$={id:fb,name:mb,category:hb,viewBox:pb,width:gb,height:yb,svg:xb,terminals:bb,source:wb},b$=Object.freeze(Object.defineProperty({__proto__:null,category:hb,default:x$,height:yb,id:fb,name:mb,source:wb,svg:xb,terminals:bb,viewBox:pb,width:gb},Symbol.toStringTag,{value:"Module"})),vb="wattmeter",kb="功率表 (W)",_b="measurement",$b="-22 -42 44 44",Sb=44,jb=44,Eb='<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>',Nb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Mb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},w$={id:vb,name:kb,category:_b,viewBox:$b,width:Sb,height:jb,svg:Eb,terminals:Nb,source:Mb},v$=Object.freeze(Object.defineProperty({__proto__:null,category:_b,default:w$,height:jb,id:vb,name:kb,source:Mb,svg:Eb,terminals:Nb,viewBox:$b,width:Sb},Symbol.toStringTag,{value:"Module"})),Tb="wind-turbine",Ab="风力发电机",Ib="renewable",Cb="风机:发电机 + 三叶轮标记",Pb="-22 -46 44 68",Ob=44,Bb=68,Lb='<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"/>',zb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Rb={kind:"inline"},k$={id:Tb,name:Ab,category:Ib,description:Cb,viewBox:Pb,width:Ob,height:Bb,svg:Lb,terminals:zb,source:Rb},_$=Object.freeze(Object.defineProperty({__proto__:null,category:Ib,default:k$,description:Cb,height:Bb,id:Tb,name:Ab,source:Rb,svg:Lb,terminals:zb,viewBox:Pb,width:Ob},Symbol.toStringTag,{value:"Module"})),Db="zener-diode",Fb="稳压二极管 (D)",Hb="passive",Wb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",qb="-12 -42 24 44",Gb=24,Xb=44,Yb='<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"/>',Kb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Vb={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"},$$={id:Db,name:Fb,category:Hb,description:Wb,viewBox:qb,width:Gb,height:Xb,svg:Yb,terminals:Kb,label:Vb,source:Ub},S$=Object.freeze(Object.defineProperty({__proto__:null,category:Hb,default:$$,description:Wb,height:Xb,id:Db,label:Vb,name:Fb,source:Ub,svg:Yb,terminals:Kb,viewBox:qb,width:Gb},Symbol.toStringTag,{value:"Module"})),j$=Object.assign({"./ammeter.json":m2,"./arc-suppression-coil.json":p2,"./arrester.json":y2,"./async-motor.json":b2,"./autotransformer.json":v2,"./battery.json":_2,"./bell.json":S2,"./break-contact.json":E2,"./breaker.json":M2,"./buchholz-relay.json":A2,"./busbar.json":C2,"./buzzer.json":O2,"./capacitor.json":L2,"./contactor.json":R2,"./converter-bidir.json":F2,"./ct.json":W2,"./dc-combiner.json":G2,"./dc-disconnector.json":Y2,"./dc-motor.json":V2,"./diode.json":J2,"./disconnector.json":Q2,"./distance-relay.json":tk,"./earth.json":ok,"./earthing-switch.json":sk,"./energy-meter.json":ak,"./ev-charger.json":ck,"./frequency-meter.json":uk,"./fuse-switch-disconnector.json":mk,"./fuse.json":pk,"./generator.json":yk,"./genset.json":bk,"./gfci-breaker.json":vk,"./grid-source.json":_k,"./grounding-transformer.json":Sk,"./heater.json":Ek,"./igbt.json":Mk,"./indicator-light.json":Ak,"./inductor.json":Ck,"./inverter.json":Ok,"./limit-switch.json":Lk,"./load-switch.json":Rk,"./load.json":Fk,"./make-contact.json":Wk,"./motor-starter.json":Gk,"./ngr.json":Yk,"./overcurrent-relay.json":Vk,"./phase-failure-relay.json":Jk,"./plc.json":Qk,"./power-factor-meter.json":t_,"./power-supply.json":o_,"./protective-relay.json":s_,"./proximity-switch.json":a_,"./pt.json":c_,"./push-button.json":u_,"./pv.json":m_,"./rcd.json":p_,"./recloser.json":y_,"./rectifier.json":b_,"./relay-coil.json":v_,"./resistor.json":__,"./reverse-power-relay.json":S_,"./selector-switch.json":E_,"./series-reactor.json":M_,"./shunt-capacitor.json":A_,"./shunt-reactor.json":C_,"./siren.json":O_,"./socket-outlet.json":L_,"./soft-starter.json":R_,"./sync-motor.json":F_,"./synchronoscope.json":W_,"./terminal.json":G_,"./thermal-overload.json":Y_,"./thermocouple.json":V_,"./thyristor.json":J_,"./time-relay.json":Q_,"./transfer-switch.json":t$,"./transformer-2w.json":o$,"./transformer-3w.json":s$,"./triac.json":a$,"./undervoltage-relay.json":c$,"./ups.json":u$,"./varmeter.json":m$,"./vfd.json":p$,"./voltage-regulator.json":y$,"./voltmeter.json":b$,"./wattmeter.json":v$,"./wind-turbine.json":_$,"./zener-diode.json":S$}),Jb=Object.values(j$).map(e=>e.default),Ke=Object.fromEntries(Jb.map(e=>[e.id,e])),Go=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],E$=(()=>{var t;const e={};for(const n of Jb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),On=new Map(Object.entries(Ke));function Zb(e){return Ke[e]}function N$(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 M$=320;function Ge(e){var h,g,b,$,k;const t=ss(),n=new Map;e.elements.forEach((w,M)=>{if(n.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/elements/${M}`});return}n.set(w.id,w);const B=On.get(w.kind);B||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:w.kind})} (id=${w.id})`,pointer:`/elements/${M}`}),t.elements.set(w.id,{element:w,libraryDef:B})});const o=new Map,r=new Map;(e.buses??[]).forEach((w,M)=>{if(n.has(w.id)||o.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/buses/${M}`});return}if(o.set(w.id,w),w.layout){const B=w.layout.rot??0;r.set(w.id,{at:w.layout.at,span:w.layout.span,rot:B,axis:Cn(B)})}});const s=new Map;(e.junctions??[]).forEach((w,M)=>{if(n.has(w.id)||o.has(w.id)||s.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/junctions/${M}`});return}s.set(w.id,w)});const i=w=>!w.includes(".")&&o.has(w),a=w=>!w.includes(".")&&s.has(w),l=(w,M)=>{if(i(w)||a(w))return!0;const B=w.indexOf(".");if(B<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:w}),pointer:M}),!1;const D=w.slice(0,B),V=w.slice(B+1),J=t.elements.get(D);if(!J)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:D}),pointer:M}),!1;if(!J.libraryDef)return!1;if(!J.libraryDef.terminals.find(ne=>ne.id===V)){const ne=J.libraryDef.terminals.map(G=>G.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:D,kind:J.element.kind,pin:V,available:ne}),pointer:M}),!1}return!0},c=[];(e.wires??[]).forEach((w,M)=>{const B=`/wires/${M}`,D=l(w.ends[0],B),V=l(w.ends[1],B);D&&V&&c.push(w)});const u=new Map;if(e.layout)for(const[w,M]of Object.entries(e.layout))t.elements.has(w)?u.set(w,is(M)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:w}),pointer:`/layout/${w}`});const f=d2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:On,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[w,M]of f.buses){const B=o.get(w);B&&t.buses.set(w,{bus:B,geometry:M})}for(const[w,M]of o)t.buses.has(w)||t.buses.set(w,{bus:M,geometry:{at:((h=M.layout)==null?void 0:h.at)??[0,0],span:((g=M.layout)==null?void 0:g.span)??M$,rot:((b=M.layout)==null?void 0:b.rot)??0,axis:Cn((($=M.layout)==null?void 0:$.rot)??0)}});for(const w of t.elements.values()){if(!w.libraryDef)continue;const M=t.layout.get(w.element.id);if(!M)continue;const B=[];for(const D of w.libraryDef.terminals){const V=`${w.element.id}.${D.id}`,J=Pe([D.x,D.y],M),ne=$t(D.orientation,M);t.terminals.set(V,{ref:V,elementId:w.element.id,pin:D.id,world:J,orientation:ne}),B.push(V)}t.elementToTerminals.set(w.element.id,B)}const m=w=>{if(!w.includes(".")){const B=t.buses.get(w);return B?B.geometry.at:null}const M=t.terminals.get(w);return M?M.world:null};for(const[w,M]of s){let B;if((k=M.layout)!=null&&k.at)B=[M.layout.at[0],M.layout.at[1]];else if(f.junctions.has(w))B=f.junctions.get(w);else{const D=[];for(const V of c){const[J,ne]=V.ends,G=J===w?ne:ne===w?J:null;if(G===null)continue;const P=m(G);P&&D.push(P)}B=D.length?[D.reduce((V,J)=>V+J[0],0)/D.length,D.reduce((V,J)=>V+J[1],0)/D.length]:[0,0]}t.junctions.set(w,{junction:M,world:B})}const p=new as;for(const w of c)p.add(w.ends[0]),p.add(w.ends[1]),p.union(w.ends[0],w.ends[1]);for(const[,w]of p.groups()){const M=N$(w);t.nodes.set(M,{id:M,terminals:w});for(const B of w)t.terminalToNode.set(B,M)}for(const w of t.elements.values()){const M=t.elementToTerminals.get(w.element.id)??[];if(M.length===0)continue;M.some(D=>t.terminalToNode.has(D))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w.element.id})})}for(const w of t.buses.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of t.junctions.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of c){if(w.path&&w.path.length>=2){const B=w.path,D=B.length>=2?B[1]:null,V=B.length>=2?B[B.length-2]:null,J=Wo(w.ends[0],D,t),ne=Wo(w.ends[1],V,t);if(J&&ne){const G=[[J[0],J[1]],...B.slice(1,-1).map(F=>[F[0],F[1]]),[ne[0],ne[1]]],P=rs(G);if(P.length>=2){t.wireRenders.set(w.id,{wireId:w.id,path:P,userEdited:!0});continue}}}const M=u2(w,t);M&&t.wireRenders.set(w.id,M)}return t}const T$={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"},Xo="B",Yo="J";function Qn(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Mt(e,t){const n=T$[t]??t,o=Qn(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Bn(e){const t=Qn(e);let n=1;for(;t.has(`${Xo}${n}`);)n++;return`${Xo}${n}`}function Ln(e){const t=Qn(e);let n=1;for(;t.has(`${Yo}${n}`);)n++;return`${Yo}${n}`}function A$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Je(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 Ko={version:"1",elements:[]},I$=100,Vo=20;function C$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=en()(o2((e,t)=>({diagram:Ko,internal:Ge(Ko),fileSession:null,activeTool:C$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom: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:Ge(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:Ge(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=I$?r.slice(1):r;e({diagram:s,internal:Ge(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:Ge(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom: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:Ge(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom: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,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:P$(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(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>s.has(p.id)).map(p=>{var g;const h=structuredClone(p);if(!h.layout){const b=(g=r.junctions.get(p.id))==null?void 0:g.world;b&&(h.layout={at:[b[0],b[1]]})}return h}),c={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const h=(m=o.layout)==null?void 0:m[p];if(h){c[p]=structuredClone(h);continue}const g=r.layout.get(p);g&&(c[p]=zt(g))}const u={};for(const p of n){const h=r.buses.get(p);h&&(u[p]=tt(h.geometry))}const f=(o.wires??[]).filter(p=>p.ends.every(h=>s.has(wn(h)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,junctions:l,placements:c,busLayouts:u,wires:f},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&&n.junctions.length===0)return;const s=o+1,i=Vo*s,a=Vo*s,l=new Map;let c=r;for(const f of n.elements){const m=Mt(c,f.kind);l.set(f.id,m),c={...c,elements:[...c.elements,{id:m,kind:f.kind}]}}for(const f of n.buses){const m=Bn(c);l.set(f.id,m),c={...c,buses:[...c.buses??[],{id:m}]}}for(const f of n.junctions){const m=Ln(c);l.set(f.id,m),c={...c,junctions:[...c.junctions??[],{id:m}]}}const u=f=>{const m=f.indexOf("."),p=m<0?f:f.slice(0,m),h=l.get(p);return h?m<0?h:`${h}${f.slice(m)}`:f};t().dispatch(f=>{const m=n.elements.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w}),p=n.buses.map(k=>{const w=structuredClone(k);w.id=l.get(k.id);const M=n.busLayouts[k.id];return M&&(w.layout={...M,at:[M.at[0]+i,M.at[1]+a]}),w}),h=n.junctions.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w.layout&&(w.layout={at:[w.layout.at[0]+i,w.layout.at[1]+a]}),w}),g={...f.layout??{}};for(const[k,w]of l){const M=n.placements[k];M&&(g[w]={...M,at:[M.at[0]+i,M.at[1]+a]})}const b=n.wires.map(k=>{const w=[u(k.ends[0]),u(k.ends[1])];return{id:Je(w[0],w[1]),ends:w}}),$=Uo(f.wires??[],b);return{...f,elements:[...f.elements,...m],buses:p.length?[...f.buses??[],...p]:f.buses,junctions:h.length?[...f.junctions??[],...h]:f.junctions,wires:$.length?$:void 0,layout:Object.keys(g).length?g: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(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:u,...f}=c;return f});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[c,u]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:u,...f}=c;return f}return c});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 c=n.layout.get(l.id);c&&(s[l.id]=zt(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,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 c=n.buses.get(l.id);return!l.layout&&c?{...l,layout:tt(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(c=r.buses)!=null&&c.find(m=>m.id===u&&m.layout)||a.set(u,tt(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=zt(f))}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,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const m=o.layout.get(u),p=s[u]??(m?zt(m):{at:[0,0]});s[u]={...p,at:[p.at[0]+f[0],p.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const m=u.layout??tt(o.buses.get(u.id).geometry);return{...u,layout:{...m,at:[m.at[0]+f[0],m.at[1]+f[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(u=>{var p,h;const f=a.get(u.id);if(!f)return u;const m=((p=u.layout)==null?void 0:p.at)??((h=o.junctions.get(u.id))==null?void 0:h.world)??[0,0];return{...u,layout:{at:[m[0]+f[0],m[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(u=>!o.has(u.id)),i=(r.buses??[]).filter(u=>!o.has(u.id)),a=(r.junctions??[]).filter(u=>!o.has(u.id)),l=(r.wires??[]).filter(u=>!o.has(wn(u.ends[0]))&&!o.has(wn(u.ends[1]))),c=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([u])=>!o.has(u))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:a.length?a:void 0,wires:l.length?l:void 0,layout:c&&Object.keys(c).length?c: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(c=>c.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const c of s){if(l[c])continue;const u=o.layout.get(c);if(!u)continue;const f={at:u.at};u.rot&&(f.rot=u.rot),u.mirror&&(f.mirror=u.mirror),l[c]=f}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 f=o.layout.get(u);if(!f)continue;const m={at:f.at};f.rot&&(m.rot=f.rot),f.mirror&&(m.mirror=f.mirror),l[u]=m}const c=(a.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...a,wires:c.length?c: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 c,u,f,m;const i={...s.layout??{}},a=new Map;for(const p of o){if(r.junctions.has(p))continue;if(r.buses.has(p)){const b=r.buses.get(p),k=(((((f=(u=(c=s.buses)==null?void 0:c.find(w=>w.id===p))==null?void 0:u.layout)==null?void 0:f.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(p,k);continue}const h=i[p]??{at:((m=r.layout.get(p))==null?void 0:m.at)??[0,0]},g=(((h.rot??0)+n)%360+360)%360;i[p]={...h,rot:g}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??tt(r.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.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)||o.junctions.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=Mt(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=Bn(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},addJunction:n=>{const o=Ln(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=Je(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]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(h=>h.id),...(s.buses??[]).map(h=>h.id),...(s.junctions??[]).map(h=>h.id)]),a=()=>{let h=1;for(;i.has(`J${h}`);)h++;const g=`J${h}`;return i.add(g),g},l=h=>{const g=a();return s={...s,junctions:[...s.junctions??[],{id:g,layout:{at:h}}]},g},c=h=>{if("end"in h)return h.end;if("junctionAt"in h)return l(h.junctionAt);const g=(s.wires??[]).find(w=>w.id===h.onWire),b=l(h.at);if(!g)return b;const $=(s.wires??[]).filter(w=>w.id!==h.onWire),k=(w,M)=>({id:Je(w,M),ends:[w,M]});return s={...s,wires:Uo($,[k(g.ends[0],b),k(b,g.ends[1])])},b},u=c(n),f=c(o);if(u===null||f===null||u===f)return s;const m=Je(u,f),p=s.wires??[];return p.some(h=>h.id===m)?s:{...s,wires:[...p,{id:m,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?rs(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:u,...f}=c;return f});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)?tt(a.buses.get(n).geometry):{at:[0,0],span:320}),c={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:c}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=A$(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:os(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=Ge(e.diagram))}}));function P$(e){return Array.from(new Set(e))}function wn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function Uo(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 zt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function tt(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Qb=null;function Jo(e){Qb=e}function Ze(){return Qb}const Yt=10;function ew(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function fe(e){return ew()?Math.round(e/Yt)*Yt:e}const O$=30,B$=144;function tw(e,t){const n=Ke[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=L$(r,t);if(!s){const g=nw(n),b=g?[fe(t[0])-g.x,fe(t[1])-g.y]:[fe(t[0]),fe(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=z$(n,l),u=Mt(r,e),f=n.terminals.find(g=>g.id===c),m=l==="x"?t[0]:a[0],p=l==="y"?t[1]:a[1],h=f?[fe(m)-f.x,fe(p)-f.y]:[fe(t[0]),fe(t[1])];return o.dispatch(g=>{const b={id:u,kind:e},$={at:h},k=`${u}.${c}`,w={id:Je(i,k),ends:[i,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],w],layout:{...g.layout??{},[u]:$}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function L$(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 c;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,m=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,p=Math.abs(t[1]-a[1]);c=Math.sqrt(m*m+p*p)}else{const u=a[1]-l/2,f=a[1]+l/2,m=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,p=Math.abs(t[0]-a[0]);c=Math.sqrt(p*p+m*m)}c<=O$&&(!o||c<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function z$(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 nw(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function ow(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 p=i[0]-a/2,h=i[0]+a/2,g=Math.max(p,Math.min(h,t[0])),b=i[1],$=t[1]>=b?"s":"n";return{ref:e,world:[g,b],orientation:$,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,u=Math.max(l,Math.min(c,t[1])),f=i[0],m=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:m,isBus:!0,busId:e}}if(!e.includes(".")&&n.junctions.has(e)){const r=n.junctions.get(e),[s,i]=r.world,a=t[0]-s,l=t[1]-i,c=Math.abs(a)>=Math.abs(l)?a>=0?"e":"w":l>=0?"s":"n";return{ref:e,world:[s,i],orientation:c,isBus:!1}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const R$={n:"s",s:"n",e:"w",w:"e"};function rw(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=R$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Zo(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],u=Zo(c,n,t.world);u<a&&(a=u,i=c)}return i}function Zo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function D$(e,t,n){const o=Ke[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=ow(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=B$,u=[fe(n[0]),fe(n[1])],f=rw(o,i,u),m=c?i.world:u,p=[fe(m[0]-f.x),fe(m[1]-f.y)],h=Mt(s,e);return r.dispatch(g=>{const b={id:h,kind:e},$={at:p},k=`${h}.${f.id}`,w=i.isBus&&i.busId?i.busId:t,M={id:Je(w,k),ends:[w,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],M],layout:{...g.layout??{},[h]:$}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const tn=9,Kt=7;function nn(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 on(e){const t=F$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function rn(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 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(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 d.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??on(r.libraryDef),a=rn(i,s),l=i.anchor??"start";if(o===r.element.id)return d.jsx(W$,{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 c=nn(r,n);return c.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:c.map((f,m)=>d.jsx("text",{x:0,y:m*tn,textAnchor:l,className:"ole-annotation-text",children:f},m))},r.element.id)})})}const vn=200,kn=9;function W$({elementId:e,currentName:t,world:n,anchor:o}){const r=O.useRef(null);O.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(c)},[e]);function s(){var m;const l=x.getState(),c=l.diagram.elements.find(p=>p.id===e);if(!c){l.setEditingElement(null);return}const u=(((m=r.current)==null?void 0:m.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==c.name&&l.updateElement(e,{name:f}),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-=vn/2:o==="end"&&(a-=vn),d.jsx("foreignObject",{x:a,y:n[1]-kn,width:vn,height:kn*2.2,className:"ole-element-name-editor",children:d.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${kn}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 sw=8,Vt=1.25;function q$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?d.jsx(X$,{ann:o},o.id):d.jsx(G$,{ann:o,isSelected:t===o.id},o.id))})}function G$({ann:e,isSelected:t}){const n=e.fontSize??sw,o=e.text===""?[""]:e.text.split(`
|
|
198
|
-
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Vt;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[d.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&&d.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)=>d.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Vt,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function X$({ann:e}){const t=O.useRef(null),n=e.fontSize??sw;O.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)},[e.id]);function o(){var c;const a=x.getState(),l=(((c=t.current)==null?void 0:c.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 d.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:d.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:Vt,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*Vt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const Y$=20;function K$(){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],c=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(Qo,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(Qo,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function Qo({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=O.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=x.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const m=s.screenToSvg(u.clientX,u.clientY),p=r==="x"?m[0]-f.startSvg[0]:m[1]-f.startSvg[1],h=ew()?Math.round(p/Yt)*Yt:p,g=f.startSpan+(o==="end"?h:-h);if(g<Y$)return;const b=r==="x"?[f.startAt[0]+h/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+h/2];x.getState().updateBus(n,{span:g,at:b})},c=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const zn=.5;function St(e,t){return Math.abs(e[1]-t[1])<zn?"h":"v"}function V$(){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=St(o[a-1],o[a]),c=St(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,m=u&&l==="v"||f&&c==="v",p=u&&l==="h"||f&&c==="h";m&&p||s.push(d.jsx(U$,{wireId:e,index:a,xLocked:m,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<zn&&Math.abs(l[1]-c[1])<zn||i.push(d.jsx(J$,{wireId:e,segIndex:a,axis:St(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function U$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=O.useRef(null),i=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!r))return;const g=x.getState().internal.wireRenders.get(e);g&&(s.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:r.screenToSvg(h.clientX,h.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,h.target.setPointerCapture(h.pointerId))},f=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId||!r)return;const b=r.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.index;if(k<=0||k>=$.length-1)return;const w=$[k],M=[g.xLocked?w[0]:fe(w[0]+(b[0]-g.startSvg[0])),g.yLocked?w[1]:fe(w[1]+(b[1]-g.startSvg[1]))];if(M[0]===w[0]&&M[1]===w[1])return;const B=$.map(J=>[J[0],J[1]]);B[k]=M;const D=St($[k-1],$[k]);k-1>0&&(D==="h"?B[k-1]=[$[k-1][0],M[1]]:B[k-1]=[M[0],$[k-1][1]]);const V=St($[k],$[k+1]);k+1<$.length-1&&(V==="h"?B[k+1]=[$[k+1][0],M[1]]:B[k+1]=[M[0],$[k+1][1]]),x.getState().updateWirePath(e,B)},m=h=>{const g=s.current;!g||h.pointerId!==g.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),s.current=null,document.body.style.cursor="")},p=h=>{h.stopPropagation(),h.preventDefault();const g=x.getState().internal.wireRenders.get(e);if(!g||g.path.length<=2||t<=0||t>=g.path.length-1)return;const b=g.path.filter(($,k)=>k!==t);x.getState().updateWirePath(e,b)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:u,onPointerMove:f,onPointerUp:m,onPointerCancel:m,onDoubleClick:p})}function J$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=O.useRef(null),s=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.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,c=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!o))return;const g=x.getState().internal.wireRenders.get(e);g&&(r.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:o.screenToSvg(h.clientX,h.clientY),axis:n,segIndex:t},document.body.style.cursor=u,h.currentTarget.setPointerCapture(h.pointerId))},m=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId||!o)return;const b=o.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.segIndex;if(k>=$.length-1)return;const w=$[k],M=$[k+1],B=[];for(let D=0;D<=k;D++)B.push($[D]);if(g.axis==="h"){const D=fe(w[1]+(b[1]-g.startSvg[1]));B.push([w[0],D]),B.push([M[0],D])}else{const D=fe(w[0]+(b[0]-g.startSvg[0]));B.push([D,w[1]]),B.push([D,M[1]])}for(let D=k+1;D<$.length;D++)B.push($[D]);x.getState().updateWirePath(e,B)},p=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId)return;const b=h.currentTarget;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:m,onPointerUp:p,onPointerCancel:p,children:[d.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:c,r:8}),d.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:c,r:3.5})]})}const Z$=3,_n=12;function Q$(){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(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:u,span:f}=l,m=f/2,p=c==="x"?u[0]-m:u[0],h=c==="x"?u[1]:u[1]-m,g=c==="x"?u[0]+m:u[0],b=c==="x"?u[1]:u[1]+m,$=s.has(a.id),k=i.has(a.id),w=r.get(a.id)??void 0,M=_n/2,B=c==="x"?u[0]-m:u[0]-M,D=c==="x"?u[1]-M:u[1]-m,V=c==="x"?f:_n,J=c==="x"?_n:f;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":w,"data-selected":$?"true":void 0,"data-node-related":k?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:B,y:D,width:V,height:J,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:b,stroke:"currentColor",strokeWidth:Z$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function eS(){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 d.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[d.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),d.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),d.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const tS=4,nS=9,oS=13,rS=-13,sS=4.5,iS=8;function aS(){const e=x(a=>a.internal.junctions),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)i.add(l)}return d.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l})=>{const c=r.get(a.id)??void 0,u=t.length===1&&t[0]===a.id,f=l[0]+oS,m=l[1]+rS;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":c,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[d.jsx("circle",{cx:l[0],cy:l[1],r:nS,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:tS,className:"ole-junction-dot"}),u&&d.jsxs("g",{className:"ole-junction-wire-handle-group",children:[d.jsx("line",{x1:l[0],y1:l[1],x2:f,y2:m,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:f,cy:m,r:iS,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:f,cy:m,r:sS,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function Ye(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 lS(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 cS({lib:e}){const t=lS(e.viewBox);return t?d.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function dS(){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 c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.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 c=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element",children:[d.jsx(cS,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element ole-element--unknown",children:[d.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),d.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let iw=null;const Rn=new Set;function Rt(e){iw=e;for(const t of Rn)t(e)}function uS(){return iw}function fS(e){return Rn.add(e),()=>{Rn.delete(e)}}function mS(){const[e,t]=O.useState(uS());return O.useEffect(()=>fS(t),[]),!e||e.w===0&&e.h===0?null:d.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function hS(){const e=x(c=>c.activeTool),t=x(c=>c.placeKind),n=x(c=>c.cursorSvg),o=x(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Zb(t);if(!r)return null;let s=null,i=null;if(o){const c=ow(o,n);c&&(s=rw(r,c,n),i={source:c.world,pin:n})}else s=nw(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return d.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),d.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),d.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:d.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function pS(){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:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:u,span:f}=s.geometry,m=f/2,p=c==="x"?u[0]-m:u[0]-4,h=c==="x"?u[1]-4:u[1]-m,g=c==="x"?f:8,b=c==="x"?8:f;return d.jsx("rect",{x:p,y:h,width:g,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=gS(i.libraryDef.viewBox);return l?d.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ye(a)},r):null})})}function gS(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 yS(){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 d.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,c=r.has(s.elementId);return d.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":c?"true":void 0,className:"ole-terminal"},s.ref)})})}const er=4;function xS(e,t,n,o){const r=t[0]-e[0],s=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=r*a-s*i;if(Math.abs(l)<1e-9)return null;const c=((n[0]-e[0])*a-(n[1]-e[1])*i)/l,u=((n[0]-e[0])*s-(n[1]-e[1])*r)/l,f=1e-6;return c<=f||c>=1-f||u<=f||u>=1-f?null:[e[0]+c*r,e[1]+c*s]}function bS(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],u=Math.hypot(l,c)||1,f=l/u,m=c/u,p=g=>(g[0]-s[0])*f+(g[1]-s[1])*m,h=a.slice().sort((g,b)=>p(g)-p(b));for(const g of h){const b=p(g),$=Math.max(0,b-er),k=Math.min(u,b+er);o.push([s[0]+f*$,s[1]+m*$]),n.push(o),o=[[s[0]+f*k,s[1]+m*k]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function wS(){const e=x(c=>c.internal.wireRenders),t=x(c=>c.internal.terminalToNode),n=x(c=>c.diagram.wires),o=x(c=>c.selectedWire),r=x(c=>c.selectedNode),s=new Map;for(const c of n??[]){const u=t.get(c.ends[0]);u&&s.set(c.id,u)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const u=s.get(c.wireId);for(let f=0;f<c.path.length-1;f++)a.push({wireId:c.wireId,node:u,i:f,a:c.path[f],b:c.path[f+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const f=a[c],m=a[u];if(f.wireId===m.wireId||!(f.node&&m.node&&f.node!==m.node))continue;const p=xS(f.a,f.b,m.a,m.b);if(!p)continue;const h=f.wireId<m.wireId?f:m;let g=l.get(h.wireId);g||(g=new Map,l.set(h.wireId,g));const b=g.get(h.i)??[];b.push(p),g.set(h.i,b)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const u=c.path,f=u.map(k=>`${k[0]},${k[1]}`).join(" "),m=s.get(c.wireId),p=o===c.wireId,h=r!=null&&r===m,g=p||h?"true":void 0,b=l.get(c.wireId),$=b?bS(u,b):[u];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,className:"ole-wire-hit",points:f},`hit-${c.wireId}`),...$.map((k,w)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,"data-manual":c.userEdited?"true":void 0,"data-selected":g,className:"ole-wire",points:k.map(M=>`${M[0]},${M[1]}`).join(" ")},`${c.wireId}-${w}`))]})})}let Ue=null;const Dn=new Set;function Xe(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 Dn)t(e)}}function vS(){return Ue}function kS(e){return Dn.add(e),()=>{Dn.delete(e)}}function _S(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=O.useState(vS());if(O.useEffect(()=>kS(o),[]),!e||!t)return null;const r=e.world,s=(n==null?void 0:n.world[0])??t[0],i=(n==null?void 0:n.world[1])??t[1],a=(n==null?void 0:n.create)==="junction";return d.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[d.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?7:8,className:"ole-wire-preview-target-ring","data-create":a?"true":void 0}),!a&&d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function Qe(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function at(e){var t;return((t=Qe(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function $S(e){var t;return((t=Qe(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function SS(e){var t;return((t=Qe(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function sn(e){var r;const t=(r=Qe(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=SS(e);if(n)return n;const o=$S(e);return o||null}function an(e){var t;return((t=Qe(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Fn(e){var t;return((t=Qe(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Ut(e){var t;return((t=Qe(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function aw(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function jS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function lw(){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==="junction"||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 ES(){O.useEffect(()=>{const e=t=>{if(jS(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"j":case"J":o.setActiveTool("junction");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":lw();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Hn=null;const Wn=new Set;function NS(e){if(e!==Hn){Hn=e;for(const t of Wn)t(e)}}function MS(){return Hn}function TS(e){return Wn.add(e),()=>{Wn.delete(e)}}const tr="ole-hover-element-host",AS="ole-hover-terminal-on",IS="ole-hover-node-on";function CS(e){O.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,m,p)=>{for(const h of f)h.classList.remove(p);f.clear();for(const h of m)h.classList.add(p),f.add(h)},a=f=>{var p,h;if(f===n)return;n&&((p=t.querySelector(`[data-element-id="${Dt(n)}"]`))==null||p.classList.remove(tr)),f&&((h=t.querySelector(`[data-element-id="${Dt(f)}"]`))==null||h.classList.add(tr));const m=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Dt(f)}"]`)):[];i(r,m,AS),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),NS(f)},l=f=>{if(f===o)return;const m=f?Array.from(t.querySelectorAll(`[data-node-id="${Dt(f)}"]`)):[];i(s,m,IS),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=f=>{a(at(f.target));const m=sn(f.target);let p=null;m?p=x.getState().internal.terminalToNode.get(m)??null:p=an(f.target),l(p)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function Dt(e){return e.replace(/(["\\])/g,"\\$1")}function PS(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const m=a[0]-l/2,p=a[0]+l/2,h=Math.max(m,Math.min(p,t[0]));return{ref:e,world:[h,a[1]],isBus:!0}}const c=a[1]-l/2,u=a[1]+l/2,f=Math.max(c,Math.min(u,t[1]));return{ref:e,world:[a[0],f],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const nr=10,Ft=e=>Math.round(e/nr)*nr,OS=16;function cw(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,u=l-i,f=c*c+u*u,m=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*u)/f)),p=s+m*c,h=i+m*u,g=(p-t[0])**2+(h-t[1])**2;g<o&&(o=g,n=[p,h])}return n}function Jt(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function BS(e,t){const n=x.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=cw(s.path,e),a=Math.hypot(i[0]-e[0],i[1]-e[1]);a<=r&&(r=a,o={wireId:s.wireId,at:i})}return o}function jt(e,t,n){const o=e?sn(e):null;if(o){const a=PS(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?Fn(e):null,s=null;if(r){const a=x.getState().internal.wireRenders.get(r);s=a?cw(a.path,t):t}else{const a=BS(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[Ft(s[0]),Ft(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Ft(t[0]),Ft(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Et(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+OS,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function dw(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function Zt(e,t){return e.ref&&t.ref?e.ref===t.ref:!e.ref&&!t.ref?e.world[0]===t.world[0]&&e.world[1]===t.world[1]:!1}const or=3;let ue=null,Me=null,je=null,ge=null;const LS={id:"select",cursor:"default",onPointerDown(e,t){var h,g,b,$,k,w,M,B,D,V,J,ne;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Ut(e.target);if(o){e.preventDefault(),e.stopPropagation();const G=(h=n.diagram.annotations)==null?void 0:h.find(P=>P.id===o);if(!G)return;n.setSelectedAnnotation(o),ge={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[G.at[0],G.at[1]],moved:!1};return}const r=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(r){const G=(g=r.closest("[data-junction-id]"))==null?void 0:g.getAttribute("data-junction-id");if(G){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&(($=(b=e.target).hasPointerCapture)!=null&&$.call(b,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(G);const P=(k=n.internal.junctions.get(G))==null?void 0:k.world;P&&n.setWireDragFrom({spec:{end:G},world:P,ref:G}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:G};return}}const i=(e.target instanceof Element?(w=e.target.closest("[data-terminal-id]"))==null?void 0:w.getAttribute("data-terminal-id"):null)?sn(e.target):null;if(i){const G=i.indexOf("."),P=G>0?i.slice(0,G):"";if(P&&n.selection.includes(P)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((B=(M=e.target).hasPointerCapture)!=null&&B.call(M,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const F=(D=n.internal.terminals.get(i))==null?void 0:D.world;F&&n.setWireDragFrom({spec:{end:i},world:F,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:i};return}}let a=at(e.target);if(!a){const G=Fn(e.target);if(G&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const F of P){const le=(J=(V=F.closest)==null?void 0:V.call(F,"[data-bus-id]"))==null?void 0:J.getAttribute("data-bus-id");if(!le)continue;const ce=(ne=n.diagram.wires)==null?void 0:ne.find(he=>he.id===G);ce&&(ce.ends[0]===le||ce.ends[1]===le)&&(a=le);break}}}if(!a){const G=Fn(e.target);if(G){if(e.preventDefault(),e.altKey){const P=an(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(G);return}e.shiftKey||n.clearSelection(),Me={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(a):l.includes(a)||n.setSelection([a]);const c=e.shiftKey?x.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const u=x.getState().internal,f=new Map,m=new Map,p=new Map;for(const G of c){const P=u.buses.get(G);if(P){m.set(G,[P.geometry.at[0],P.geometry.at[1]]);continue}const F=u.junctions.get(G);if(F){p.set(G,[F.world[0],F.world[1]]);continue}const le=u.layout.get(G);le&&f.set(G,{...le})}f.size===0&&m.size===0&&p.size===0||(ue={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:f,busOriginals:m,junctionOriginals:p,moved:!1},e.preventDefault())},onPointerMove(e,t){if(ge&&e.pointerId===ge.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ge.startSvg[0]),r=fe(n[1]-ge.startSvg[1]);!ge.moved&&(o!==0||r!==0)&&(ge.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=Jt(e.clientX,e.clientY),r=jt(o,n,Et(t,e.clientX,e.clientY)),s={spec:{end:je.fromRef},world:[0,0],ref:je.fromRef};Xe(Zt(s,r)?null:dw(r));return}if(ue&&e.pointerId===ue.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ue.startSvg[0]),r=fe(n[1]-ue.startSvg[1]);!ue.moved&&(o!==0||r!==0)&&(ue.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ue.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ye(l))}for(const s of ue.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of ue.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Me&&e.pointerId===Me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);Rt(rr(Me.startSvg,n));return}},onPointerUp(e,t){if(ge&&e.pointerId===ge.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ge.startSvg[0]),r=fe(n[1]-ge.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);s&&s.removeAttribute("transform"),ge.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(ge.id,{at:[ge.origin[0]+o,ge.origin[1]+r]}),ge=null;return}if(je&&e.pointerId===je.pointerId){const n=x.getState(),o=je.fromRef;je=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Xe(null);const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=Jt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=jt(s,r,Et(t,e.clientX,e.clientY));if(Zt({world:[0,0],ref:o},i))return;n.connectWire({end:o},i.spec);return}if(ue&&e.pointerId===ue.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ue.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ue.startSvg[0]),r=fe(n[1]-ue.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ue.originals.keys())s.set(i,[o,r]);for(const i of ue.busOriginals.keys())s.set(i,[o,r]);for(const i of ue.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ue.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}for(const s of ue.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}}ue=null;return}if(Me&&e.pointerId===Me.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=rr(Me.startSvg,n);if(o.w>=or||o.h>=or){const r=zS(o);if(Me.shiftKey){const s=new Set(Me.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}Rt(null),Me=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(ge&&e.pointerId===ge.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ge=null}if(ue&&e.pointerId===ue.pointerId){for(const[l,c]of ue.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",Ye(c))}for(const l of ue.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of ue.junctionOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ue=null}if(je&&e.pointerId===je.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setWireDragFrom(null),l.setCursorSvg(null),Xe(null),je=null}if(Me&&e.pointerId===Me.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}Rt(null),Me=null}},onDoubleClick(e){const t=x.getState(),n=Ut(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=at(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ue=null,Me=null,ge=null,je){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),Xe(null),je=null}Rt(null)}};function rr(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 zS(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=DS(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(([f,m])=>RS([f,m],r));let a=1/0,l=-1/0,c=1/0,u=-1/0;for(const[f,m]of i)f<a&&(a=f),f>l&&(l=f),m<c&&(c=m),m>u&&(u=m);l>=e.x&&a<=e.x+e.w&&u>=e.y&&c<=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,c=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,m=s==="x"?i[1]:i[1]+l;u>=e.x&&c<=e.x+e.w&&m>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=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 DS(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 Be(e){return e.replace(/(["\\])/g,"\\$1")}const FS=4;let ie=null;const HS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=at(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,c=new Map;for(const u of i){const f=a.buses.get(u);if(f){c.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const m=a.layout.get(u);m&&l.set(u,{...m})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}ie={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(!ie||e.pointerId!==ie.pointerId)return;const n=e.clientX-ie.startX,o=e.clientY-ie.startY;if(!ie.moved&&Math.hypot(n,o)>FS){ie.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(ie.moved){if(ie.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=fe(r[0]-ie.elementDrag.startSvg[0]),i=fe(r[1]-ie.elementDrag.startSvg[1]);for(const[a,l]of ie.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${wt(a)}"]`);if(!c)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",Ye(u))}for(const a of ie.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${wt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:ie.startTx+n,ty:ie.startTy+o})}},onPointerUp(e,t){if(!(!ie||e.pointerId!==ie.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",ie.elementDrag&&ie.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ie.elementDrag.startSvg[0]),r=fe(n[1]-ie.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ie.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of ie.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ie.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${wt(s)}"]`);i&&i.removeAttribute("transform")}}else ie.moved||WS(ie.startTarget);ie=null}},onPointerCancel(e,t){if(ie!=null&&ie.elementDrag){for(const[n,o]of ie.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${wt(n)}"]`);r&&r.setAttribute("transform",Ye(o))}for(const n of ie.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${wt(n)}"]`);o&&o.removeAttribute("transform")}}ie=null},onDeactivate(){ie=null}};function WS(e){if(!e)return;const t=x.getState(),n=Ut(e);if(n){t.setSelectedAnnotation(n);return}const o=at(e);if(o){t.setSelection([o]);return}const r=an(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function wt(e){return e.replace(/(["\\])/g,"\\$1")}const kt={tight:1024,compact:720,dense:520,mini:380},sr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return sr[e]>=sr[t]}function qS(e){return e>=kt.tight?"full":e>=kt.compact?"tight":e>=kt.dense?"compact":e>=kt.mini?"dense":"mini"}const uw=O.createContext("full");function Ve(){return O.useContext(uw)}function GS(e){const[t,n]=O.useState(null);return O.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 fw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<kt.dense}function ln(){fw()&&x.getState().setActiveTool("pan")}function XS(){fw()&&x.getState().setPlaceKind(null)}const YS={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.setWireDragFrom(null),t.setCursorSvg(null),Xe(null)},onPointerDown(e,t){var i,a;if(e.button!==0)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((a=(i=e.target).hasPointerCapture)!=null&&a.call(i,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Et(t,e.clientX,e.clientY),r=jt(e.target instanceof Element?e.target:null,n,o),s=x.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=Jt(e.clientX,e.clientY),i=jt(s,r,Et(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Xe(Zt(a,i)?null:dw(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Xe(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=Jt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=jt(s,r,Et(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Zt(a,i)||(n.connectWire(o.spec,i.spec),ln())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Xe(null)}},ir=10;let vt=!1;function ar(){setTimeout(()=>XS(),0)}const KS={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),vt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=sn(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);tw(n,r),vt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([lr(n[0]),lr(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);D$(r,o,s),ar();return}vt&&(vt=!1,ar())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),vt=!1}};function lr(e){return Math.round(e/ir)*ir}const cr=10,dr=20;function nt(e){return Math.round(e/cr)*cr}const VS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[nt(n[0]),nt(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([nt(n[0]),nt(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=nt(o[0]),s=nt(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,u,f;if(l){if(u=Math.abs(i),u<dr)return;c=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<dr)return;c=90,f=[n[0],(n[1]+s)/2]}x.getState().addBus(f,u,c),ln()},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)}},ur=10,fr=e=>Math.round(e/ur)*ur,US={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().addJunction([fr(n[0]),fr(n[1])]),ln()}},JS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Ut(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),ln()}},ZS={select:LS,pan:HS,wire:YS,place:KS,busbar:VS,junction:US,text:JS};function QS(e,t){const n=x(o=>o.activeTool);O.useEffect(()=>{var m;const o=e.current;if(!o)return;const r=ZS[n],s={viewport:t,hostEl:o};(m=r.onActivate)==null||m.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=p=>{var h;return(h=r.onPointerDown)==null?void 0:h.call(r,p,s)},a=p=>{var h;return(h=r.onPointerMove)==null?void 0:h.call(r,p,s)},l=p=>{var h;return(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},c=p=>{var h;return r.onPointerCancel?r.onPointerCancel(p,s):(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},u=p=>{var h;return(h=r.onPointerLeave)==null?void 0:h.call(r,p,s)},f=p=>{var h;return(h=r.onDoubleClick)==null?void 0:h.call(r,p,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",c),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",f),()=>{var p;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",c),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",f),(p=r.onDeactivate)==null||p.call(r,s),o.style.cursor=""}},[n,e,t])}let qn=1;const Gn=new Set;function e4(e){if(e!==qn){qn=e;for(const t of Gn)t(e)}}function t4(){return qn}function n4(e){return Gn.add(e),()=>{Gn.delete(e)}}const $n=.1,Sn=8,o4=1.0015,r4=1.02;function s4(e,t,n={tx:0,ty:0,scale:1}){const o=O.useRef({...n}),r=O.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)),e4(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return O.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,u=0,f=0,m=0,p=!1;const h=new Map;let g=null,b=!1;const $=()=>{if(h.size<2){g=null;return}const P=[...h.values()],F=P[1].x-P[0].x,le=P[1].y-P[0].y,ce=Math.hypot(F,le)||1,he=i.getBoundingClientRect();g={startDist:ce,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(P[0].x+P[1].x)/2-he.left,startMidY:(P[0].y+P[1].y)/2-he.top}},k=P=>{if(P.pointerType==="touch"){if(h.set(P.pointerId,{x:P.clientX,y:P.clientY}),h.size>=2&&!b){b=!0;for(const F of h.keys())F!==P.pointerId&&aw(i,F);$()}if(b){P.stopPropagation(),P.preventDefault();try{i.setPointerCapture(P.pointerId)}catch{}}}},w=P=>{if(P.pointerType!=="touch"||!h.has(P.pointerId)||(h.set(P.pointerId,{x:P.clientX,y:P.clientY}),!b||!g))return;P.stopPropagation();const F=[...h.values()];if(F.length<2)return;const le=F[1].x-F[0].x,ce=F[1].y-F[0].y,he=Math.hypot(le,ce)||1,oe=i.getBoundingClientRect(),se=(F[0].x+F[1].x)/2-oe.left,ye=(F[0].y+F[1].y)/2-oe.top,xe=he/g.startDist,_e=jn(g.startScale*xe,$n,Sn),Ne=_e/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*Ne+(se-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ne+(ye-g.startMidY),o.current.scale=_e,s()},M=P=>{var F;if(P.pointerType==="touch"&&h.has(P.pointerId)&&(h.delete(P.pointerId),b)){if(P.stopPropagation(),(F=i.hasPointerCapture)!=null&&F.call(i,P.pointerId))try{i.releasePointerCapture(P.pointerId)}catch{}h.size>=2?$():g=null,h.size===0&&(b=!1)}},B=P=>{P.preventDefault();const F=i.getBoundingClientRect(),le=P.clientX-F.left,ce=P.clientY-F.top,he=P.ctrlKey||P.metaKey;if(P.deltaX===0||he){const ye=Math.pow(he?r4:o4,-P.deltaY),xe=jn(o.current.scale*ye,$n,Sn),_e=xe/o.current.scale;o.current.tx=le-(le-o.current.tx)*_e,o.current.ty=ce-(ce-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=P.deltaX,o.current.ty-=P.deltaY;s()},D=P=>{const F=P.button===1,le=p&&P.button===0;!F&&!le||(P.preventDefault(),a=!0,l=P.pointerId,c=P.clientX,u=P.clientY,f=o.current.tx,m=o.current.ty,i.setPointerCapture(P.pointerId),i.style.cursor="grabbing")},V=P=>{!a||P.pointerId!==l||(o.current.tx=f+(P.clientX-c),o.current.ty=m+(P.clientY-u),s())},J=P=>{a&&P.pointerId===l&&(a=!1,i.releasePointerCapture(P.pointerId),i.style.cursor=p?"grab":"")},ne=P=>{if(P.code==="Space"&&!p){const F=P.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;p=!0,i.style.cursor="grab",P.preventDefault()}},G=P=>{P.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",B,{passive:!1}),i.addEventListener("pointerdown",D),i.addEventListener("pointermove",V),i.addEventListener("pointerup",J),i.addEventListener("pointercancel",J),i.addEventListener("pointerdown",k,{capture:!0}),i.addEventListener("pointermove",w,{capture:!0}),i.addEventListener("pointerup",M,{capture:!0}),i.addEventListener("pointercancel",M,{capture:!0}),window.addEventListener("keydown",ne),window.addEventListener("keyup",G),s(),()=>{i.removeEventListener("wheel",B),i.removeEventListener("pointerdown",D),i.removeEventListener("pointermove",V),i.removeEventListener("pointerup",J),i.removeEventListener("pointercancel",J),i.removeEventListener("pointerdown",k,{capture:!0}),i.removeEventListener("pointermove",w,{capture:!0}),i.removeEventListener("pointerup",M,{capture:!0}),i.removeEventListener("pointercancel",M,{capture:!0}),window.removeEventListener("keydown",ne),window.removeEventListener("keyup",G)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const c=l.getBoundingClientRect(),u=(i-c.left-o.current.tx)/o.current.scale,f=(a-c.top-o.current.ty)/o.current.scale;return[u,f]},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=jn(i.scale,$n,Sn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function jn(e,t,n){return e<t?t:e>n?n:e}const mw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ot=mw?"⌘":"Ctrl+",i4=mw?"⇧":"Shift+",En=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],a4=18;function l4(e){for(const t of En)if(t*e>=a4)return t;return En[En.length-1]}function c4(){const e=ae(),t=O.useRef(null),n=O.useRef(null),o=O.useRef(null),r=s4(t,n);QS(t,r),CS(t),O.useEffect(()=>(Jo(r),()=>Jo(null)),[r]),O.useEffect(()=>{const u=f=>{const m=o.current;if(!m)return;const h=l4(f.scale)*f.scale;m.setAttribute("width",String(h)),m.setAttribute("height",String(h)),m.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Uv(),i=O.useCallback((u,f,m)=>{const p=x.getState(),h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){lw();return}const g=at(m);if(g)p.selection.includes(g)||p.setSelection([g]);else{const D=an(m);D&&p.selectedNode!==D&&p.setSelectedNode(D)}const b=x.getState(),$=b.selection.length>0,k=b.selectedNode!=null,w=!!b.clipboard,M=b.diagram.elements.length>0,B=[{label:e("menu.undo"),shortcut:`${ot}Z`,icon:Un,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${ot}${i4}Z`,icon:Vn,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ot}X`,icon:Hr,onSelect:()=>x.getState().cutSelection(),disabled:!$},{label:e("menu.copy"),shortcut:`${ot}C`,icon:zr,onSelect:()=>x.getState().copySelection(),disabled:!$},{label:e("menu.paste"),shortcut:`${ot}V`,icon:Lr,onSelect:()=>x.getState().pasteClipboard(),disabled:!w},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Fr,onSelect:()=>x.getState().rotateSelection(90),disabled:!$},{label:e("menu.mirror"),shortcut:"M",icon:Rr,onSelect:()=>x.getState().mirrorSelection(),disabled:!$},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ot}A`,icon:yv,onSelect:()=>{const D=x.getState();D.setSelection(D.diagram.elements.map(V=>V.id))},disabled:!M},{type:"separator"},{label:e(k&&!$?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:qr,destructive:!0,onSelect:()=>k&&!$?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!$&&!k}];s.open(u,f,B)},[s,e]);O.useEffect(()=>{const u=t.current;if(!u)return;const f=700,m=4;let p,h=null;const g=()=>{p!==void 0&&window.clearTimeout(p),p=void 0,h=null},b=w=>{w.pointerType==="touch"&&(g(),h={pointerId:w.pointerId,x:w.clientX,y:w.clientY,target:w.target},p=window.setTimeout(()=>{const M=h;h=null,p=void 0,M&&(aw(u,M.pointerId),i(M.x,M.y,M.target))},f))},$=w=>{if(!h||w.pointerId!==h.pointerId)return;const M=w.clientX-h.x,B=w.clientY-h.y;Math.hypot(M,B)>m&&g()},k=w=>{!h||w.pointerId!==h.pointerId||g()};return u.addEventListener("pointerdown",b),u.addEventListener("pointermove",$),u.addEventListener("pointerup",k),u.addEventListener("pointercancel",k),()=>{g(),u.removeEventListener("pointerdown",b),u.removeEventListener("pointermove",$),u.removeEventListener("pointerup",k),u.removeEventListener("pointercancel",k)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const m=r.screenToSvg(u.clientX,u.clientY);tw(f,m)},c=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(Q$,{}),d.jsx(wS,{}),d.jsx(aS,{}),d.jsx(dS,{}),d.jsx(H$,{}),d.jsx(q$,{}),d.jsx(pS,{}),d.jsx(K$,{}),d.jsx(V$,{}),d.jsx(yS,{}),d.jsx(_S,{}),d.jsx(eS,{}),d.jsx(hS,{}),d.jsx(mS,{})]})]})})}const mr=60,d4=.1,u4=8,f4=8;function m4(e,t,n){return e<t?t:e>n?n:e}function h4(){return document.querySelector(".ole-canvas-root")}function eo(){const e=Ze(),t=h4();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 $ of o){const k=$.getBoundingClientRect();k.width===0&&k.height===0||(k.left<r&&(r=k.left),k.top<s&&(s=k.top),k.right>i&&(i=k.right),k.bottom>a&&(a=k.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[u,f]=e.screenToSvg(i,a),m=Math.max(u-l,1),p=Math.max(f-c,1),h=m4(Math.min((n.width-mr*2)/m,(n.height-mr*2)/p),d4,u4),g=(l+u)/2,b=(c+f)/2;return e.setViewport({tx:n.width/2-h*g,ty:n.height/2-h*b,scale:h}),!0}function to(){let e=f4;const t=()=>{eo()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const hr=10,p4=100;function g4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function y4(){const[e,t]=O.useState(MS()),[n,o]=O.useState(!1),[r,s]=O.useState(null),i=O.useRef(null),a=O.useRef(void 0),[l]=O.useState(g4);O.useEffect(()=>TS(h=>t(h)),[]),O.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),p4),()=>window.clearTimeout(a.current)},[e]);const c=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(O.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,b=-1;const $=()=>{const k=document.querySelector(`[data-element-id="${x4(e)}"]`),w=i.current;if(k&&w){const M=k.getBoundingClientRect();let B=M.bottom+hr;B+w.offsetHeight>window.innerHeight-4&&(B=M.top-w.offsetHeight-hr);let D=M.left+M.width/2-w.offsetWidth/2;D=Math.max(4,Math.min(D,window.innerWidth-w.offsetWidth-4)),(B!==g||D!==b)&&(s({top:B,left:D}),g=B,b=D)}h=requestAnimationFrame($)};return h=requestAnimationFrame($),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!c)return null;const u=Ke[c.kind],f=c.name??c.id,m=(u==null?void 0:u.name)??c.kind,p=c.name&&c.name!==c.id;return typeof document>"u"?null:Pr.createPortal(d.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:[d.jsx("span",{className:"font-medium text-foreground",children:f}),p&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id}),d.jsx("span",{className:"text-muted-foreground/80",children:"·"}),d.jsx("span",{className:"text-muted-foreground",children:m})]}),document.body)}function x4(e){return e.replace(/(["\\])/g,"\\$1")}function b4({width:e,children:t}){const n=e==null?"full":qS(e);return d.jsx(uw.Provider,{value:n,children:t})}function pr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function w4(...e){return t=>{let n=!1;const o=e.map(r=>{const s=pr(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():pr(e[r],null)}}}}var v4=Symbol.for("react.lazy"),Qt=ke[" use ".trim().toString()];function k4(e){return typeof e=="object"&&e!==null&&"then"in e}function hw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===v4&&"_payload"in e&&k4(e._payload)}function _4(e){const t=S4(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;hw(s)&&typeof Qt=="function"&&(s=Qt(s._payload));const a=ke.Children.toArray(s),l=a.find(E4);if(l){const c=l.props.children,u=a.map(f=>f===l?ke.Children.count(c)>1?ke.Children.only(null):ke.isValidElement(c)?c.props.children:null:f);return d.jsx(t,{...i,ref:r,children:ke.isValidElement(c)?ke.cloneElement(c,void 0,u):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var $4=_4("Slot");function S4(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(hw(r)&&typeof Qt=="function"&&(r=Qt(r._payload)),ke.isValidElement(r)){const i=M4(r),a=N4(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?w4(o,i):i),ke.cloneElement(r,a)}return ke.Children.count(r)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var j4=Symbol("radix.slottable");function E4(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j4}function N4(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 M4(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 gr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yr=Yr,T4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return yr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const u=n==null?void 0:n[c],f=s==null?void 0:s[c];if(u===null)return null;const m=gr(u)||gr(f);return r[c][m]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,m]=u;return m===void 0||(c[f]=m),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:m,...p}=u;return Object.entries(p).every(h=>{let[g,b]=h;return Array.isArray(b)?b.includes({...s,...a}[g]):{...s,...a}[g]===b})?[...c,f,m]:c},[]);return yr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},A4=T4("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"}}),Ae=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?$4:"button";return d.jsx(i,{className:Ee(A4({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const I4=350;function Ie({content:e,children:t,disabled:n,delayMs:o=I4}){const r=O.useRef(null),s=O.useRef(null),[i,a]=O.useState(!1),[l,c]=O.useState(null),u=O.useId(),f=O.useRef(void 0),m=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(f.current),a(!1)};O.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const $=r.current.getBoundingClientRect(),k=s.current.getBoundingClientRect(),w=8;let M="top",B=$.top-k.height-w;B<4&&(M="bottom",B=$.bottom+w);let D=$.left+$.width/2-k.width/2;D=Math.max(4,Math.min(D,window.innerWidth-k.width-4)),c({top:B,left:D,side:M})},[i,e]),O.useEffect(()=>()=>window.clearTimeout(f.current),[]),O.useEffect(()=>{if(!i)return;const $=w=>{w.key==="Escape"&&a(!1)},k=()=>a(!1);return window.addEventListener("keydown",$),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("keydown",$),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i]);const h=t,g=h.props,b=O.cloneElement(h,{ref:$=>{r.current=$;const k=h.ref;typeof k=="function"?k($):k&&typeof k=="object"&&(k.current=$)},onPointerEnter:$=>{var k;(k=g.onPointerEnter)==null||k.call(g,$),m()},onPointerLeave:$=>{var k;(k=g.onPointerLeave)==null||k.call(g,$),p()},onFocus:$=>{var k;(k=g.onFocus)==null||k.call(g,$),m()},onBlur:$=>{var k;(k=g.onBlur)==null||k.call(g,$),p()},"aria-describedby":i?u:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[b,i&&typeof document<"u"&&Pr.createPortal(d.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 xr=12,C4=56;function P4(){var $;const e=ae(),t=x(k=>k.selection),n=x(k=>k.selectedNode),o=x(k=>k.selectedWire),r=x(k=>k.activeTool),s=x(k=>k.rotateSelection),i=x(k=>k.mirrorSelection),a=x(k=>k.deleteSelection),l=x(k=>k.deleteSelectedNode),c=x(k=>k.deleteSelectedWire),u=x(k=>k.resetWirePath),f=x(k=>k.internal.wireRenders),m=o!=null&&(($=f.get(o))==null?void 0:$.userEdited)===!0,p=O.useRef(null);O.useEffect(()=>{const k=p.current;if(!k)return;const w=t.length>0,M=!w&&o!=null,B=!w&&!M&&n!=null;if(!((w||M||B)&&(r==="select"||r==="pan"))){k.style.display="none";return}k.style.display="flex";let V=0,J="";const ne=()=>{let G=1/0,P=-1/0,F=1/0,le=-1/0,ce=!1;const he=oe=>{oe.width===0&&oe.height===0||(oe.left<G&&(G=oe.left),oe.right>P&&(P=oe.right),oe.top<F&&(F=oe.top),oe.bottom>le&&(le=oe.bottom),ce=!0)};if(w)for(const oe of t){const se=document.querySelector(`[data-element-id="${CSS.escape(oe)}"]`);se&&he(se.getBoundingClientRect())}else if(M&&o){const oe=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);oe&&he(oe.getBoundingClientRect())}else if(B&&n){const oe=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const se of oe)he(se.getBoundingClientRect())}if(ce){const oe=(G+P)/2;let se=F-xr,ye="-100%";se<C4&&(se=le+xr,ye="0%");const xe=`translate3d(${oe}px, ${se}px, 0) translate(-50%, ${ye})`;xe!==J&&(k.style.transform=xe,J=xe)}V=requestAnimationFrame(ne)};return V=requestAnimationFrame(ne),()=>cancelAnimationFrame(V)},[t,n,o,r]);const h=t.length===0&&o!=null,g=t.length===0&&!h&&n!=null,b=g||h;return d.jsxs("div",{ref:p,role:"toolbar","aria-label":e(h?"ctx.ariaWire":g?"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:[h&&m&&o&&d.jsxs(d.Fragment,{children:[d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{children:d.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx(gv,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&d.jsxs(d.Fragment,{children:[d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:d.jsx(Fr,{})})}),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Rr,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.delete")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),d.jsx("div",{className:"text-muted-foreground",children:e(h?"ctx.deleteHintWire":g?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>h?c():g?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(qr,{})})})]})}function no({open:e,onOpenChange:t,trigger:n,children:o}){const r=O.useRef(null);return O.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]),d.jsxs("div",{ref:r,className:"relative",children:[n,e&&d.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 pw="ole-panel-open";function O4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(pw);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 br(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(pw,JSON.stringify(t))}catch{}}const Tt=en((e,t)=>({...O4(),setOutlineOpen:n=>{e({outlineOpen:n}),br(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),br(t())}})),qt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],gw=.1,yw=8,xw="ole-grid";function B4(){try{const e=window.localStorage.getItem(xw);return e==null?!0:e==="1"}catch{return!0}}function L4(e){try{window.localStorage.setItem(xw,e?"1":"0")}catch{}}function z4(e,t,n){return e<t?t:e>n?n:e}function bw(){return document.querySelector(".ole-canvas-root")}function oo(e){const t=Ze(),n=bw();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=z4(e,gw,yw),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function R4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=qt.find(o=>o>t+1e-6)??yw;oo(n)}function D4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=gw;for(let o=qt.length-1;o>=0;o--)if(qt[o]<t-1e-6){n=qt[o];break}oo(n)}const F4={off:"id",id:"all",all:"off"};function H4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=F4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function ww(){const[e,t]=O.useState(()=>B4());return O.useEffect(()=>{const n=bw();n==null||n.classList.toggle("hide-grid",!e),L4(e)},[e]),O.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 vw(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:D4,"aria-label":e("view.zoomOut"),children:d.jsx(Kn,{})})})}function kw(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:R4,"aria-label":e("view.zoomIn"),children:d.jsx(hv,{})})})}function _w(){const e=ae(),[t,n]=O.useState(t4);return O.useEffect(()=>n4(n),[]),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.reset")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:d.jsxs("button",{type:"button",onClick:()=>oo(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 $w(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.fit")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:eo,"aria-label":e("view.fit"),children:d.jsx(uv,{})})})}function Sw({grid:e,setGrid:t}){const n=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),d.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:Ee(!e&&"text-muted-foreground/60"),children:d.jsx(cv,{})})})}function jw(){const e=ae(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:H4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:Ee(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Gr,{})})})}function W4({stacked:e}={}){const t=ae(),[n,o]=O.useState(!1),[r,s]=ww(),i=d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:t("view.menu")}),d.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?d.jsx(Ie,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:Ee("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:[d.jsx(Tn,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Ie,{content:i,children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:d.jsx(Tn,{})})});return d.jsx(no,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(_w,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(vw,{}),d.jsx(kw,{})]}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx($w,{}),d.jsx(Sw,{grid:r,setGrid:s}),d.jsx(jw,{})]})]})})}function q4(){const e=Ve();return Oe(e,"dense")?null:d.jsx(G4,{tier:e})}function G4({tier:e}){const t=Oe(e,"tight"),[n,o]=ww();return d.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:d.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[d.jsx(vw,{}),!t&&d.jsx(_w,{}),d.jsx(kw,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx($w,{}),d.jsx(Sw,{grid:n,setGrid:o}),d.jsx(jw,{})]})})}const wr=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:fv,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:dv,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Kn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:ov,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Wr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Br,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Gr,switchTo:"text",iconOnly:!0}];function X4(){const e=ae(),t=x(u=>u.activeTool),n=x(u=>u.placeKind),o=x(u=>u.placeFromTerminal),r=x(u=>u.wireDragFrom),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"junction":a=e("mode.junction"),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 c=e(t==="select"?"mode.escSelect":"mode.escOther");return d.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:[d.jsx("span",{children:a}),l&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",c]})]})}function Y4(){const e=ae(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ve(),c=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),m=f?wr.filter(h=>h.id!=="select"&&h.id!=="text"):wr,p=h=>t===h.switchTo;return d.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&&d.jsx(X4,{}),d.jsxs("div",{className:Ee("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",f?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[f&&d.jsx(K4,{stacked:!0}),m.map(h=>{const g=h.icon,b=p(h),$=h.id==="place"&&b&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return d.jsxs(O.Fragment,{children:[d.jsx(it,{icon:g,label:e(h.labelKey),hotkey:h.hotkey,active:b,iconOnly:!f&&(h.iconOnly||c),stacked:f,description:$,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?d.jsx(U4,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(it,{icon:Un,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(it,{icon:Vn,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),d.jsx(V4,{iconOnly:c})]}),f&&d.jsx(W4,{stacked:!0})]})]})}function K4({stacked:e}){const t=ae(),n=Tt(r=>r.outlineOpen),o=Tt(r=>r.toggleOutline);return d.jsx(it,{icon:Dr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function it({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const c=d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:t}),n&&d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&d.jsx("div",{className:"text-muted-foreground",children:l})]});return d.jsx(Ie,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:Ee("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:[d.jsxs("span",{className:"relative inline-flex shrink-0",children:[d.jsx(e,{className:"size-4"}),n&&!i&&d.jsx("span",{"aria-hidden":!0,className:Ee("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?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function Ew(){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 V4({iconOnly:e}){const t=ae(),[n,o]=O.useState(!1),r=Ew(),s=i=>()=>{o(!1),i()};return d.jsxs(no,{open:n,onOpenChange:o,trigger:d.jsx(it,{icon:_t,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeAll()),icon:d.jsx(_t,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:d.jsx(_t,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Gt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Gt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function U4({stacked:e}){const t=ae(),[n,o]=O.useState(!1),r=x(m=>m.past.length),s=x(m=>m.future.length),i=x(m=>m.undo),a=x(m=>m.redo),l=x(m=>m.selection.length>0),c=x(m=>m.clipboard!=null),u=Ew(),f=m=>()=>{o(!1),m()};return d.jsxs(no,{open:n,onOpenChange:o,trigger:d.jsx(it,{icon:Tn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[d.jsx(Te,{onClick:f(i),icon:d.jsx(Un,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Te,{onClick:f(a),icon:d.jsx(Vn,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:f(()=>x.getState().cutSelection()),icon:d.jsx(Hr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Te,{onClick:f(()=>x.getState().copySelection()),icon:d.jsx(zr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Te,{onClick:f(()=>x.getState().pasteClipboard()),icon:d.jsx(Lr,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:f(()=>x.getState().autoArrangeAll()),icon:d.jsx(_t,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:f(()=>x.getState().autoArrangeSelection()),icon:d.jsx(_t,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Gt,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Gt,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Te({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:Ee("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,d.jsx("span",{className:"flex-1",children:e})]})}function J4(){const e=Tt(r=>r.outlineOpen),t=Tt(r=>r.setOutlineOpen),n=Ve();return Oe(n,"dense")?e?d.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:d.jsx(vr,{onClose:()=>t(!1),sheet:!0})}):null:d.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?d.jsx(vr,{onClose:()=>t(!1)}):d.jsx(Z4,{onClick:()=>t(!0)})})}function Z4({onClick:e}){const t=ae(),n=Ve(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:Ee("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:[d.jsx(Dr,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function vr({onClose:e,sheet:t}){const n=ae(),o=x(c=>c.diagram.elements),r=x(c=>c.activeTool==="place"),s=Ve(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:Ee("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:[d.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:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&d.jsx(ej,{children:o.length}),d.jsx(mv,{className:"size-3.5 text-muted-foreground"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?d.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):d.jsx("ul",{className:"space-y-px",children:o.map(c=>d.jsx(Q4,{element:c},c.id))})})]})}function Q4({element:e}){const t=Ke[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.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:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function ej({children:e}){return d.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 tj={"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":"剩余动作电流"},nj={"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"},kr={zh:tj,en:nj};function oj(e,t){return kr[e][t]??kr.zh[t]}function It(){const e=At(t=>t.locale);return(t,n)=>oj(e,t)??n??t}const Nw="ole-palette-collapsed",rj=new Set(["busbar"]),Nt=(()=>{const e={};for(const[t,n]of Object.entries(E$)){const o=n.filter(r=>!rj.has(r.id));o.length&&(e[t]=o)}return e})(),sj=(()=>{const e=new Set(Go),t=Object.keys(Nt).filter(n=>!e.has(n));return[...Go.filter(n=>{var o;return(o=Nt[n])==null?void 0:o.length}),...t]})();function ij(){try{const e=window.localStorage.getItem(Nw);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 aj(e){try{window.localStorage.setItem(Nw,JSON.stringify([...e]))}catch{}}function lj(){const e=ae(),t=x(f=>f.activeTool==="place"),n=x(f=>f.placeKind),o=x(f=>f.setActiveTool),r=Tt(f=>f.outlineOpen),s=Ve(),i=Oe(s,"dense"),a=68,c=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 d.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:d.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:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.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:d.jsx(Jn,{className:"size-3.5"})})]}),d.jsx(cj,{sheet:i})]})})}function cj({sheet:e}){const t=ae(),n=It(),[o,r]=O.useState(""),[s,i]=O.useState(()=>ij()),a=O.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return Nt;const m={};for(const[p,h]of Object.entries(Nt)){const g=h.filter(b=>{const $=n(`${b.id}.name`,b.name).toLowerCase(),k=n(`${b.id}.desc`,b.description??"").toLowerCase();return $.includes(f)||b.id.toLowerCase().includes(f)||k.includes(f)});g.length&&(m[p]=g)}return m},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=O.useCallback((f,m)=>{i(p=>{const h=new Set(p);return m?h.delete(f):h.add(f),aj(h),h})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(dj,{value:o,onChange:r})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:c?d.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):sj.map(f=>{var b;const m=a[f];if(!(m!=null&&m.length))return null;const p=((b=Nt[f])==null?void 0:b.length)??m.length,h=t(`cat.${f}`),g=l||!s.has(f);return d.jsxs("details",{open:g,className:"group mb-2 last:mb-0",onToggle:$=>{l||u(f,$.currentTarget.open)},children:[d.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:[d.jsx(nv,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:h}),d.jsx(fj,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map($=>d.jsx(uj,{entry:$,sheet:e},$.id))})]},f)})})]})}function dj({value:e,onChange:t}){const n=ae();return d.jsxs("div",{className:"relative",children:[d.jsx(pv,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),d.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&&d.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:d.jsx(Jn,{className:"size-3"})})]})}function uj({entry:e,sheet:t}){const n=ae(),o=It(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(f=>f.setActiveTool),a=x(f=>f.activeTool==="place"&&f.placeKind===e.id),l=x(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),c=O.useRef(null);O.useEffect(()=>{var f;l&&((f=c.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const m=document.createElement("div");m.className="ole-glass",m.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(";"),m.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(m),f.dataTransfer.setDragImage(m,32,32),setTimeout(()=>m.remove(),0)};return d.jsxs("li",{ref:c,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:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function fj({children:e}){return d.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 Xn="ole-onboarding-dismissed";function mj(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Xn)==="1"}catch{return!1}}function _r(e){try{e?window.localStorage.setItem(Xn,"1"):window.localStorage.removeItem(Xn)}catch{}}const $r=en(e=>({dismissed:mj(),dismiss:()=>{_r(!0),e({dismissed:!0})},reset:()=>{_r(!1),e({dismissed:!1})}}));function hj(){const e=ae(),t=$r(o=>o.dismissed),n=$r(o=>o.dismiss);return t?null:d.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:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),d.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:d.jsx(Jn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Nn,{n:1,icon:d.jsx(Wr,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Nn,{n:2,icon:d.jsx(Br,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Nn,{n:3,icon:d.jsx(Kn,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),d.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 Nn({n:e,icon:t,title:n,body:o}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[d.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}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),d.jsx("span",{children:n})]}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function pj(){const e=ae(),t=x(m=>m.selection),n=x(m=>m.diagram.elements),o=x(m=>m.diagram.buses),r=x(m=>m.diagram.junctions),s=x(m=>m.selectedNode),i=x(m=>m.selectedWire);if(i)return d.jsx(vj,{wireId:i});if(s)return d.jsx(_j,{nodeId:s});if(t.length===0)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const a=t[0],l=(o??[]).find(m=>m.id===a);if(l)return d.jsx(bj,{bus:l});const c=(r??[]).find(m=>m.id===a);if(c)return d.jsx(kj,{junction:c});const u=n.find(m=>m.id===a);if(!u)return null;const f=Ke[u.kind];return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(dt,{label:e("props.name"),value:u.name??"",placeholder:u.id,onCommit:m=>x.getState().updateElement(a,{name:m.trim()===""?void 0:m.trim()})}),d.jsx(ro,{label:e("props.note"),value:u.note??"",onCommit:m=>x.getState().updateElement(a,{note:m.trim()===""?void 0:m.trim()})}),(f==null?void 0:f.state)&&f.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:f.state.map(m=>d.jsx($j,{id:a,element:u,field:m},m.name))}),d.jsx(gj,{id:a,element:u,schema:(f==null?void 0:f.params)??[]})]})}function gj({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:d.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>d.jsx(yj,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(xj,{id:e,element:t,fieldKey:s,value:i},s))]})}function yj({id:e,element:t,field:n}){var l;const o=ae(),r=It(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const u={...t.params??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,x.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(ct,{label:i,children:d.jsx(so,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?d.jsx(cn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):d.jsx(dt,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function xj({id:e,element:t,fieldKey:n,value:o}){const r=ae(),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"?d.jsx(ct,{label:n,children:d.jsx(so,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(cn,{label:n,value:o,onCommit:s}):d.jsx(dt,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function bj({bus:e}){const t=ae(),n=e.id,o=r=>{const s=r.trim();Yn(n,{name:s===""?void 0:s})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(ro,{label:t("props.note"),value:e.note??"",onCommit:r=>Yn(n,{note:r.trim()===""?void 0:r.trim()})}),d.jsx(wj,{bus:e})]})}function wj({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Yn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.jsx(cn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Yn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function vj({wireId:e}){const t=ae(),n=x(b=>b.diagram.wires),o=x(b=>b.diagram.elements),r=x(b=>b.diagram.buses),s=x(b=>b.diagram.junctions),i=x(b=>b.internal.terminalToNode),a=x(b=>b.setSelectedNode),l=(n??[]).find(b=>b.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),u=new Map(o.map(b=>[b.id,b])),f=new Map((r??[]).map(b=>[b.id,b])),m=new Map((s??[]).map(b=>[b.id,b])),p=b=>{if(!b.includes(".")){const B=f.get(b);if(B)return{id:b,label:B.name??b};const D=m.get(b);return{id:b,label:(D==null?void 0:D.name)??b}}const $=b.indexOf("."),k=b.slice(0,$),w=b.slice($+1),M=u.get(k);return{id:k,label:(M==null?void 0:M.name)??k,pin:w}},h=p(l.ends[0]),g=p(l.ends[1]);return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),d.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((b,$)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([b.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:b.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:b.label}),b.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:b.pin})]},$))}),c&&d.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:()=>a(c),children:t("props.selectWholeNode")})]})}function kj({junction:e}){var r;const t=ae(),n=x(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),d.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),d.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>x.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(ro,{label:t("props.note"),value:e.note??"",onCommit:s=>x.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})}),o&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[d.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),d.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function _j({nodeId:e}){const t=ae(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return d.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 c=a.slice(0,l),u=a.slice(l+1),f=s.get(c)??[];f.push(u),s.set(c,f)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.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:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function ct({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function dt({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=O.useState(t),a=O.useRef(null);return O.useEffect(()=>i(t),[t]),d.jsx(ct,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:Ee("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&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function ro({label:e,value:t,onCommit:n}){const[o,r]=O.useState(t);return O.useEffect(()=>r(t),[t]),d.jsx(ct,{label:e,children:d.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 cn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=O.useState(String(t)),a=O.useRef(null);return O.useEffect(()=>i(String(t)),[t]),d.jsx(ct,{label:e,children:d.jsxs("div",{className:"relative",children:[d.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 c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:Ee("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&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function so({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:Ee("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 $j({id:e,element:t,field:n}){var l;const o=ae(),s=It()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const u={...t.state??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,x.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(ct,{label:s,children:d.jsx(so,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(cn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(dt,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function Sj(){const e=ae(),t=It(),n=x(f=>f.selection),o=x(f=>f.selectedNode),r=x(f=>f.selectedWire),s=x(f=>f.diagram.elements),i=x(f=>f.diagram.buses),a=Ve(),l=Oe(a,"dense");if(n.length===0&&!o&&!r)return null;let c=e("props.title"),u=null;if(r)c=e("props.wire");else if(o)c=e("props.node");else if(n.length===1){const f=n[0],m=(i??[]).find(p=>p.id===f);if(m)c=m.name??e("props.bus");else{const p=s.find(h=>h.id===f);if(p){const h=Ke[p.kind];c=h?t(`${h.id}.name`,h.name):p.kind}}}else u=n.length;return d.jsxs("aside",{className:Ee("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:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:c}),u!=null&&d.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})})]}),d.jsx(pj,{})]})}function jj(){O.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 Ej(){jj();const e=O.useRef(null),t=GS(e);return d.jsx(Jv,{children:d.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(b4,{width:t,children:[d.jsx(c4,{}),d.jsx(J4,{}),d.jsx(Sj,{}),d.jsx(Y4,{}),d.jsx(q4,{}),d.jsx(P4,{}),d.jsx(lj,{}),d.jsx(hj,{}),d.jsx(y4,{})]})})})}const Nj="ole-theme";function Mj(){try{const e=window.localStorage.getItem(Nj);return e==="light"||e==="dark"?e:null}catch{return null}}function Tj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function Aj(){return typeof window>"u"?"light":Mj()??(Tj()?"dark":"light")}function Mw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Ij({className:e,diagram:t,locale:n,theme:o}){return O.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),O.useEffect(()=>{n&&At.getState().setLocale(n)},[n]),O.useEffect(()=>{o&&Mw(o)},[o]),O.useEffect(()=>{to()},[]),ES(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(Ej,{})})}const Tw={"application/json":[".json"]},Aw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Iw=e=>e instanceof DOMException&&e.name==="AbortError";function Sr(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(we("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(we("io.notObject"));const n=t;if(n.version!=="1")throw new Error(we("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(we("io.elementsMissing"));return n}function Cj(e){return JSON.stringify(e,null,2)+`
|
|
199
|
-
`}async function
|
|
200
|
-
`);for(let a=0;a<i.length;a++){const[l,c]=Ce([r.at[0],r.at[1]+(a+1)*s*
|
|
196
|
+
*/const Zn=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Yr(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=Yr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Kr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Yr(e))&&(o&&(o+=" "),o+=t);return o}const Qn="-",bv=e=>{const t=vv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Qn);return a[0]===""&&a.length!==1&&a.shift(),Vr(a,t)||wv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Vr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Vr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(Qn);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},Ao=/^\[(.+)\]$/,wv=e=>{if(Ao.test(e)){const t=Ao.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},vv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return _v(Object.entries(e.classGroups),n).forEach(([s,i])=>{In(i,o,s,t)}),o},In=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:Io(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(kv(r)){In(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{In(i,Io(t,s),n,o)})})},Io=(e,t)=>{let n=e;return t.split(Qn).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},kv=e=>e.isThemeGetter,_v=(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,$v=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)}}},Ur="!",Sv=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,f=0,u;for(let b=0;b<a.length;b++){let $=a[b];if(c===0){if($===r&&(o||a.slice(b,b+s)===t)){l.push(a.slice(f,b)),f=b+s;continue}if($==="/"){u=b;continue}}$==="["?c++:$==="]"&&c--}const m=l.length===0?a:a.substring(f),p=m.startsWith(Ur),h=p?m.substring(1):m,g=u&&u>f?u-f:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:g}};return n?a=>n({className:a,parseClassName:i}):i},jv=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},Ev=e=>({cache:$v(e.cacheSize),parseClassName:Sv(e),...bv(e)}),Nv=/\s+/,Mv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(Nv);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:f,hasImportantModifier:u,baseClassName:m,maybePostfixModifierPosition:p}=n(c);let h=!!p,g=o(h?m.substring(0,p):m);if(!g){if(!h){a=c+(a.length>0?" "+a:a);continue}if(g=o(m),!g){a=c+(a.length>0?" "+a:a);continue}h=!1}const b=jv(f).join(":"),$=u?b+Ur:b,k=$+g;if(s.includes(k))continue;s.push(k);const w=r(g,h);for(let M=0;M<w.length;++M){const B=w[M];s.push($+B)}a=c+(a.length>0?" "+a:a)}return a};function Tv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Jr(t))&&(o&&(o+=" "),o+=n);return o}const Jr=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Jr(e[o]))&&(n&&(n+=" "),n+=t);return n};function Av(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((f,u)=>u(f),e());return n=Ev(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const f=Mv(l,n);return r(l,f),f}return function(){return s(Tv.apply(null,arguments))}}const me=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Zr=/^\[(?:([a-z-]+):)?(.+)\]$/i,Iv=/^\d+\/\d+$/,Cv=new Set(["px","full","screen"]),Pv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ov=/\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$/,Bv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Lv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=e=>st(e)||Cv.has(e)||Iv.test(e),He=e=>lt(e,"length",Xv),st=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>lt(e,"number",st),gt=e=>!!e&&Number.isInteger(Number(e)),Rv=e=>e.endsWith("%")&&st(e.slice(0,-1)),te=e=>Zr.test(e),We=e=>Pv.test(e),Dv=new Set(["length","size","percentage"]),Fv=e=>lt(e,Dv,Qr),Hv=e=>lt(e,"position",Qr),Wv=new Set(["image","url"]),qv=e=>lt(e,Wv,Kv),Gv=e=>lt(e,"",Yv),yt=()=>!0,lt=(e,t,n)=>{const o=Zr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},Xv=e=>Ov.test(e)&&!Bv.test(e),Qr=()=>!1,Yv=e=>Lv.test(e),Kv=e=>zv.test(e),Vv=()=>{const e=me("colors"),t=me("spacing"),n=me("blur"),o=me("brightness"),r=me("borderColor"),s=me("borderRadius"),i=me("borderSpacing"),a=me("borderWidth"),l=me("contrast"),c=me("grayscale"),f=me("hueRotate"),u=me("invert"),m=me("gap"),p=me("gradientColorStops"),h=me("gradientColorStopPositions"),g=me("inset"),b=me("margin"),$=me("opacity"),k=me("padding"),w=me("saturate"),M=me("scale"),B=me("sepia"),D=me("skew"),V=me("space"),J=me("translate"),ne=()=>["auto","contain","none"],G=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",te,t],F=()=>[te,t],le=()=>["",Le,He],ce=()=>["auto",st,te],he=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ye=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",te],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ne=()=>[st,te];return{cacheSize:500,separator:":",theme:{colors:[yt],spacing:[Le,He],blur:["none","",We,te],brightness:Ne(),borderColor:[e],borderRadius:["none","","full",We,te],borderSpacing:F(),borderWidth:le(),contrast:Ne(),grayscale:xe(),hueRotate:Ne(),invert:xe(),gap:F(),gradientColorStops:[e],gradientColorStopPositions:[Rv,He],inset:P(),margin:P(),opacity:Ne(),padding:F(),saturate:Ne(),scale:Ne(),sepia:xe(),skew:Ne(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",te]}],container:["container"],columns:[{columns:[We]}],"break-after":[{"break-after":_e()}],"break-before":[{"break-before":_e()}],"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:[...he(),te]}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:ne()}],"overscroll-x":[{"overscroll-x":ne()}],"overscroll-y":[{"overscroll-y":ne()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",gt,te]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",te]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",gt,te]}],"grid-cols":[{"grid-cols":[yt]}],"col-start-end":[{col:["auto",{span:["full",gt,te]},te]}],"col-start":[{"col-start":ce()}],"col-end":[{"col-end":ce()}],"grid-rows":[{"grid-rows":[yt]}],"row-start-end":[{row:["auto",{span:[gt,te]},te]}],"row-start":[{"row-start":ce()}],"row-end":[{"row-end":ce()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",te]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...ye()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ye(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ye(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[k]}],px:[{px:[k]}],py:[{py:[k]}],ps:[{ps:[k]}],pe:[{pe:[k]}],pt:[{pt:[k]}],pr:[{pr:[k]}],pb:[{pb:[k]}],pl:[{pl:[k]}],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":[V]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[V]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",te,t]}],"min-w":[{"min-w":[te,t,"min","max","fit"]}],"max-w":[{"max-w":[te,t,"none","full","min","max","fit","prose",{screen:[We]},We]}],h:[{h:[te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",We,He]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",gn]}],"font-family":[{font:[yt]}],"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",te]}],"line-clamp":[{"line-clamp":["none",st,gn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Le,te]}],"list-image":[{"list-image":["none",te]}],"list-style-type":[{list:["none","disc","decimal",te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[$]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[$]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Le,He]}],"underline-offset":[{"underline-offset":["auto",Le,te]}],"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:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te]}],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",te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[$]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...he(),Hv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Fv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},qv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],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":[$]}],"border-style":[{border:[...oe(),"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":[$]}],"divide-style":[{divide:oe()}],"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:["",...oe()]}],"outline-offset":[{"outline-offset":[Le,te]}],"outline-w":[{outline:[Le,He]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:le()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[$]}],"ring-offset-w":[{"ring-offset":[Le,He]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",We,Gv]}],"shadow-color":[{shadow:[yt]}],opacity:[{opacity:[$]}],"mix-blend":[{"mix-blend":[...se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":se()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",We,te]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[w]}],sepia:[{sepia:[B]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[$]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[B]}],"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",te]}],duration:[{duration:Ne()}],ease:[{ease:["linear","in","out","in-out",te]}],delay:[{delay:Ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[M]}],"scale-x":[{"scale-x":[M]}],"scale-y":[{"scale-y":[M]}],rotate:[{rotate:[gt,te]}],"translate-x":[{"translate-x":[J]}],"translate-y":[{"translate-y":[J]}],"skew-x":[{"skew-x":[D]}],"skew-y":[{"skew-y":[D]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",te]}],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",te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"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",te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Le,He,gn]}],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"]}}},Uv=Av(Vv);function Ee(...e){return Uv(Kr(e))}const es=O.createContext(null);function Jv(){const e=O.useContext(es);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Ot=8;function Zv({children:e}){const[t,n]=O.useState({open:!1,x:0,y:0,items:[]}),[o,r]=O.useState(null),s=O.useRef(null),i=O.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=O.useCallback((c,f,u)=>{r(null),n({open:!0,x:c,y:f,items:u})},[]),l=O.useMemo(()=>({open:a,close:i}),[a,i]);return O.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let f=t.x,u=t.y;f+c.width>window.innerWidth-Ot&&(f=Math.max(Ot,t.x-c.width)),u+c.height>window.innerHeight-Ot&&(u=Math.max(Ot,t.y-c.height)),r({left:f,top:u})},[t]),O.useEffect(()=>{if(!t.open)return;const c=p=>{s.current&&!s.current.contains(p.target)&&i()},f=p=>{p.key==="Escape"&&(p.preventDefault(),i())},u=()=>i(),m=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",f,!0),window.addEventListener("wheel",u,{passive:!0}),window.addEventListener("blur",m),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",f,!0),window.removeEventListener("wheel",u),window.removeEventListener("blur",m)}},[t.open,i]),d.jsxs(es.Provider,{value:l,children:[e,t.open&&d.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:c=>c.preventDefault(),children:t.items.map((c,f)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${f}`);const u=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:Ee("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",c.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",c.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),c.onSelect()},children:[d.jsxs("span",{className:"flex items-center gap-2",children:[u?d.jsx(u,{className:"size-4"}):null,d.jsx("span",{children:c.label})]}),c.shortcut?d.jsx("span",{className:"text-xs text-muted-foreground",children:c.shortcut}):null]},`${c.label}-${f}`)})})]})}const Co=e=>{let t;const n=new Set,o=(c,f)=>{const u=typeof c=="function"?c(t):c;if(!Object.is(u,t)){const m=t;t=f??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(p=>p(t,m))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,r,a);return a},Qv=(e=>e?Co(e):Co),e2=e=>e;function t2(e,t=e2){const n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),O.useCallback(()=>t(e.getInitialState()),[e,t]));return O.useDebugValue(n),n}const Po=e=>{const t=Qv(e),n=o=>t2(t,o);return Object.assign(n,t),n},en=(e=>e?Po(e):Po),Oo={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.junction":"接线柱","props.junctionPos":"位置","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.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","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":"切到 元件 工具(P),从左侧元件库选一种拖到画布","onboard.step2.title":"拉线连接","onboard.step2.body":"用 连线 工具(W)从一个引脚拖到另一个引脚;拖到空白处会自动新建接线柱","onboard.step3.title":"需要共用排时才用母线","onboard.step3.body":"多条回路共用一条母排时,用 母线 工具(B)画一段;普通点对点连线不需要母线","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.junction":"Junction","props.junctionPos":"Position","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 a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","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 a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and 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.junction":"Click the canvas to drop a junction","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":"Place a component","onboard.step1.body":"Pick the Place tool (P) and drag a kind from the library onto the canvas","onboard.step2.title":"Wire it up","onboard.step2.body":"Use the Wire tool (W): drag from one pin to another — drag into empty space to drop a junction","onboard.step3.title":"Busbars are for shared rails","onboard.step3.body":"When several circuits share one rail, draw a busbar (B); plain point-to-point wiring needs no bus","onboard.dismiss":"Got it"}},ts="ole-locale";function n2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(ts);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 Bo(e){try{window.localStorage.setItem(ts,e)}catch{}}const At=en((e,t)=>({locale:n2(),setLocale:n=>{Bo(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Bo(n),e({locale:n})}}));function ns(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function os(e,t){return Oo[e][t]??Oo.zh[t]??t}function we(e,t){return ns(os(At.getState().locale,e),t)}function ae(){const e=At(t=>t.locale);return(t,n)=>ns(os(e,t),n)}function rs(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 Cn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Cn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Cn(o)(n)}}}},o2=(e,t)=>(n,o,r)=>{let s={storage:rs(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,$)=>({...$,...b}),...t},i=!1,a=0;const l=new Set,c=new Set;let f=s.storage;if(!f)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 u=()=>{const b=s.partialize({...o()});return f.setItem(s.name,{state:b,version:s.version})},m=r.setState;r.setState=(b,$)=>(m(b,$),u());const p=e((...b)=>(n(...b),u()),o,r);r.getInitialState=()=>p;let h;const g=()=>{var b,$;if(!f)return;const k=++a;i=!1,l.forEach(M=>{var B;return M((B=o())!=null?B:p)});const w=(($=s.onRehydrateStorage)==null?void 0:$.call(s,(b=o())!=null?b:p))||void 0;return Cn(f.getItem.bind(f))(s.name).then(M=>{if(M)if(typeof M.version=="number"&&M.version!==s.version){if(s.migrate){const B=s.migrate(M.state,M.version);return B instanceof Promise?B.then(D=>[!0,D]):[!0,B]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,M.state];return[!1,void 0]}).then(M=>{var B;if(k!==a)return;const[D,V]=M;if(h=s.merge(V,(B=o())!=null?B:p),n(h,!0),D)return u()}).then(()=>{k===a&&(w==null||w(o(),void 0),h=o(),i=!0,c.forEach(M=>M(h)))}).catch(M=>{k===a&&(w==null||w(void 0,M))})};return r.persist={setOptions:b=>{s={...s,...b},b.storage&&(f=b.storage)},clearStorage:()=>{f==null||f.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},s.skipHydration||g(),h||p},r2=o2,ze=.5;function ss(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])<ze&&Math.abs(s[1]-e[r][1])<ze||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>ze&&l>ze){const f=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<ze?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(f)}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])<ze&&Math.abs(i[0]-a[0])<ze,c=Math.abs(s[1]-i[1])<ze&&Math.abs(i[1]-a[1])<ze;l||c||o.push(i)}return o.push(n[n.length-1]),o}function is(){return{elements:new Map,buses:new Map,junctions:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function as(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 Pn(e){return e===90||e===270?"y":"x"}function Pe(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 s2={n:"e",e:"s",s:"w",w:"n"},i2={n:"n",s:"s",e:"w",w:"e"};function $t(e,t){let n=t.mirror?i2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=s2[n];return n}function On(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class ls{constructor(){pt(this,"parent",new Map);pt(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 Lo=["n","e","s","w"],zo={n:"s",s:"n",e:"w",w:"e"};function Bt(e,t){const n=Lo.indexOf(e),r=((Lo.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const yn=320,Lt=220,xt=260,xn=720,bt=30,Ro=30,qe=80,Do=10,a2=60,l2=520,c2=80,d2=80,Fo=8,Ho=new Set(["source","renewable"]);function u2(e){var ko,_o,$o,So,jo,Eo;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),f=new Map,u=new Set(i.keys()),m=new Set(a.keys()),p=new Map;for(const y of t)p.set(y.id,y);const h=new Map;for(const y of n)h.set(y.id,y);const g=y=>{const v=p.get(y);if(v)return s.get(v.kind)},b=new Set(n.map(y=>y.id)),$=y=>b.has(y),k=new Set(o.map(y=>y.id)),w=new Set(o.filter(y=>{var v;return(v=y.layout)==null?void 0:v.at}).map(y=>y.id)),M=new ls;for(const y of r)M.add(y.ends[0]),M.add(y.ends[1]),M.union(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(v)for(const S of v.terminals)M.add(`${y.id}.${S.id}`)}for(const y of n)M.add(y.id);const B=[];for(const[,y]of M.groups())y.length>=2&&B.push(y);const D=new Map;for(const y of B)for(const v of y)D.set(v,[y]);const V=new Map;for(const y of B){const v=y.filter($);if(v.length!==0)for(const S of v){const E=y.filter(_=>_!==S),j=V.get(S)??[];j.push(...E),V.set(S,j)}}{const S=A=>p.has(A)&&!!g(A),E=A=>{if($(A))return null;if(k.has(A))return A;const N=A.indexOf(".");return N>0?A.slice(0,N):null},j=new Map,_=new Set,T=(A,N)=>{j.has(A)||j.set(A,new Set),j.has(N)||j.set(N,new Set),A!==N&&(j.get(A).add(N),j.get(N).add(A))};for(const A of B){const N=[];let L=!1;for(const W of A){if($(W)){L=!0;continue}const Z=E(W);Z&&N.push(Z)}const z=[...new Set(N)];for(const W of z)j.has(W)||j.set(W,new Set),L&&_.add(W);const H=z.filter(W=>k.has(W)),q=z.filter(W=>!k.has(W));if(H.length>0){for(const W of H)for(const Z of q)T(W,Z);for(let W=0;W<H.length;W++)for(let Z=W+1;Z<H.length;Z++)T(H[W],H[Z])}else for(let W=0;W<q.length;W++)for(let Z=W+1;Z<q.length;Z++)T(q[W],q[Z])}const R=(A,N)=>{const L=g(A);if(!L)return null;for(const z of L.terminals){const H=`${A}.${z.id}`;for(const q of D.get(H)??[])for(const W of q)if(E(W)===N)return z}return null},I=A=>{const N=K=>{var ee;return((ee=j.get(K))==null?void 0:ee.size)??0},L=K=>{var ee;return((ee=g(K))==null?void 0:ee.category)??""},z=K=>{const ee=L(K);return ee==="source"?0:ee==="renewable"?1:2+Math.min(N(K),9)/10},H=A.filter(S).sort((K,ee)=>z(K)-z(ee)||K.localeCompare(ee))[0];if(!H)return;const q=new Map([[H,null]]),W=new Map([[H,0]]),Z=new Map,Q=[],X=[H],Y=new Set([H]);for(;X.length;){const K=X.shift();Q.push(K);for(const ee of[...j.get(K)??[]].sort(($e,Se)=>$e.localeCompare(Se)))Y.has(ee)||(Y.add(ee),q.set(ee,K),W.set(ee,(W.get(K)??0)+1),Z.has(K)||Z.set(K,[]),Z.get(K).push(ee),X.push(ee))}let U=0;const de=new Map,be=K=>{const ee=Z.get(K)??[];if(ee.length===0){de.set(K,U++);return}for(const Se of ee)be(Se);const $e=ee.map(Se=>de.get(Se));de.set(K,$e.reduce((Se,Pt)=>Se+Pt,0)/$e.length)};be(H);for(const K of Q){const ee=pe(yn+(de.get(K)??0)*160),$e=pe(Lt+(W.get(K)??0)*140);if(k.has(K)){f.set(K,[ee,$e]);continue}let Se=0;const Pt=q.get(K)??null;if(Pt){const ht=R(K,Pt);ht&&(Se=Bt(ht.orientation,"n"))}else{const ht=(Z.get(K)??[])[0],No=ht?R(K,ht):null;No&&(Se=Bt(No.orientation,"s"))}l.set(K,{at:[ee,$e],rot:Se,mirror:!1}),u.add(K)}},C=new Set;for(const A of j.keys()){if(C.has(A))continue;const N=[],L=[A];for(C.add(A);L.length;){const z=L.pop();N.push(z);for(const H of j.get(z)??[])C.has(H)||(C.add(H),L.push(H))}N.length<2||N.some(z=>_.has(z))||N.some(z=>l.has(z)||w.has(z))||N.some(S)&&I(N)}}const J=new Map;for(const y of B){const v=y.filter($);if(v.length!==0)for(const S of y){if($(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=S.slice(E+1),T=J.get(j)??[];for(const R of v)T.some(I=>I.busId===R&&I.pin===_)||T.push({busId:R,pin:_});J.set(j,T)}}const ne=[],G=new Set;for(const[y,v]of J)if(new Set(v.map(E=>E.busId)).size>=2){const E=((_o=s.get(((ko=p.get(y))==null?void 0:ko.kind)??""))==null?void 0:_o.category)==="transformer"?"vertical":"horizontal";ne.push({elementId:y,attachments:v,orientation:E}),E==="vertical"&&G.add(y)}const P=new Map,F=(y,v)=>{y!==v&&(P.has(y)||P.set(y,new Set),P.has(v)||P.set(v,new Set),P.get(y).add(v),P.get(v).add(y))};for(const y of r)F(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(!v||v.terminals.length<2)continue;const S=v.terminals.map(E=>`${y.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)F(S[E],S[j])}for(const y of t){if(G.has(y.id))continue;const v=s.get(y.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const T=_.slice(y.id.length+1);E.set(T,new Set);const R=new Set(S.filter(A=>A!==_)),I=new Set([_]),C=[_];for(;C.length>0;){const A=C.shift();if($(A)){E.get(T).add(A);continue}const N=P.get(A);if(N)for(const L of N)I.has(L)||R.has(L)||(I.add(L),C.push(L))}}const j=new Set;for(const _ of E.values())for(const T of _)j.add(T);if(j.size>=2){const _=[];for(const[T,R]of E)for(const I of R)_.push({busId:I,pin:T});ne.push({elementId:y.id,attachments:_,orientation:"vertical"}),G.add(y.id)}}const le=(y,v)=>{var R;const S=g(v),E=S?S.terminals.map(I=>`${v}.${I.id}`):[],j=y,_=new Set([j,...E]),T=[j];for(;T.length>0;){const I=T.shift(),C=I.indexOf(".");if(C>0){const N=I.slice(0,C),L=p.get(N);if(L){const z=(R=s.get(L.kind))==null?void 0:R.category;if(z&&Ho.has(z))return!0}}const A=P.get(I);if(A)for(const N of A)_.has(N)||(_.add(N),T.push(N))}return!1};for(const y of ne){if(y.orientation!=="horizontal")continue;const v=new Set(y.attachments.map(E=>E.busId));let S=0;for(const E of v)le(E,y.elementId)&&S++;S===1&&(y.orientation="vertical",G.add(y.elementId))}for(const y of t){if(G.has(y.id)||y.kind!=="breaker")continue;const v=s.get(y.kind);if(!v||v.terminals.length!==2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const T=_.slice(y.id.length+1),R=new Set(S.filter(A=>A!==_)),I=new Set([_]),C=[_];for(;C.length>0;){const A=C.shift();if($(A)){E.set(T,A);break}const N=P.get(A);if(N)for(const L of N){if(I.has(L)||R.has(L))continue;const z=L.indexOf(".");if(z>0){const H=L.slice(0,z);if(H!==y.id){const q=p.get(H),W=q?s.get(q.kind):void 0;if((W==null?void 0:W.category)==="transformer")continue}}I.add(L),C.push(L)}}}if(new Set(E.values()).size>=2){const _=[];for(const[T,R]of E)_.push({busId:R,pin:T});ne.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ce=new Map;for(const y of n)ce.set(y.id,new Map);for(const y of ne){const v=Array.from(new Set(y.attachments.map(S=>S.busId)));for(const S of v)for(const E of v)S!==E&&(($o=ce.get(S))==null||$o.set(E,y))}const he=y=>{var S;const v=(S=s.get(y))==null?void 0:S.category;return v?Ho.has(v):!1},oe=[];for(const y of n){const v=V.get(y.id);if(v)for(const S of v){if($(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=p.get(j);if(_&&he(_.kind)){oe.push(y.id);break}}}oe.length===0&&n.length>0&&oe.push(n[0].id);const se=new Map;for(const y of oe)se.set(y,0);{const y=[...oe];for(;y.length>0;){const v=y.shift(),S=se.get(v),E=ce.get(v);if(E)for(const[j,_]of E){if(se.has(j))continue;const T=_.orientation==="horizontal"?S:S+1;se.set(j,T),y.push(j)}}}for(const y of n){if(se.has(y.id))continue;const v=se.size===0?-1:Math.max(...Array.from(se.values()));se.set(y.id,v+1)}const ye=new Map;for(const y of n){const v=se.get(y.id),S=ye.get(v)??[];S.push(y.id),ye.set(v,S)}const xe=[...ye.keys()].sort((y,v)=>y-v),_e=(y,v,S)=>{const E=`${y.elementId}.${S}`,j=v,_=g(y.elementId),T=new Set;if(_)for(const N of _.terminals)N.id!==S&&T.add(`${y.elementId}.${N.id}`);const R=new Set([E]),I=[{ref:E,dist:0}],C=new Map,A=(N,L,z,H)=>{R.add(N),C.set(N,L),I.push({ref:N,dist:H+z})};for(;I.length>0;){const{ref:N,dist:L}=I.shift();if(N===j){const W=C.get(j);let Z;if(W){const Q=W.indexOf(".");if(Q>0){const X=W.slice(0,Q);X!==y.elementId&&(Z=X)}}return{extent:L,head:Z}}const z=N.indexOf(".");if(z<0)continue;const H=N.slice(0,z),q=N.slice(z+1);if(!$(H)&&!G.has(H)){const W=g(H),Z=W==null?void 0:W.terminals.find(Q=>Q.id===q);if(W&&Z)for(const Q of W.terminals){if(Q.id===q)continue;const X=`${H}.${Q.id}`;R.has(X)||T.has(X)||A(X,N,Math.abs(Z.y-Q.y),L)}}for(const W of D.get(N)??[])for(const Z of W){if(Z===N||R.has(Z)||T.has(Z))continue;const Q=$(N)||$(Z);A(Z,N,Q?Ro:bt,L)}}return{extent:0}},Ne=(y,v)=>{var N,L,z;const S=(N=ce.get(y))==null?void 0:N.get(v);if(!S||S.orientation==="horizontal")return xt;const E=g(S.elementId);if(!E)return xt;const j=(L=S.attachments.find(H=>H.busId===y))==null?void 0:L.pin,_=(z=S.attachments.find(H=>H.busId===v))==null?void 0:z.pin;if(!j||!_)return xt;const T=E.terminals.find(H=>H.id===j),R=E.terminals.find(H=>H.id===_);if(!T||!R)return xt;const I=Math.abs(R.y-T.y),C=_e(S,y,j).extent,A=_e(S,v,_).extent;return C+I+A},dn=new Map;for(const y of ne){if(y.orientation!=="vertical")continue;const v=y.attachments.slice().sort((R,I)=>(se.get(R.busId)??0)-(se.get(I.busId)??0));if(v.length<2)continue;const S=v[0].busId,E=v[1].busId,j=v[0].pin,T=_e(y,S,j).head??y.elementId;dn.set(T,{lowerBusId:E})}const lo=30,co=y=>{const v=g(y);return Math.max((v==null?void 0:v.width)??qe,qe)},Fw=2,uo=(y,v,S,E=0)=>{const j=g(v);let _=co(v);if(j&&!S.has(v)&&E<Fw){S.add(v);let T=0;for(const R of j.terminals){const I=`${v}.${R.id}`;if(I!==y)for(const C of D.get(I)??[]){const A=new Set;let N=!1;for(const z of C){if(z===I)continue;if($(z)){N=!0;continue}const H=z.indexOf(".");if(H<0)continue;const q=z.slice(0,H);q===v||S.has(q)||G.has(q)||A.add(q)}if(N||A.size===0)continue;let L=0;for(const z of A){const H=[...C].find(q=>q.indexOf(".")>0&&q.slice(0,q.indexOf("."))===z);L+=(H?uo(H,z,S,E+1):co(z))+lo}T=Math.max(T,L-lo)}}S.delete(v),_=Math.max(_,T)}return _},ut=320,et=new Map,fo=(y,v)=>{if(!G.has(y))return!1;const S=ne.find(T=>T.elementId===y),E=S==null?void 0:S.attachments.find(T=>T.busId!==v);if(!E)return!1;const j=se.get(v)??0;return(se.get(E.busId)??0)<j},ft=(y,v,S)=>{const E=dn.get(y);if(E){const _=et.get(E.lowerBusId);if(_!==void 0)return Math.max(v,_+qe)}let j=0;return S&&(j=uo(S,y,new Set)),Math.max(v,qe,j)},mo=(y,v)=>{if(et.has(y))return et.get(y);if(v.has(y))return ut;v.add(y);const S=V.get(y)??[];let E=0,j=0;for(const T of S){if($(T))continue;const R=T.indexOf(".");if(R<0)continue;const I=T.slice(0,R),C=T.slice(R+1);if(fo(I,y))continue;const A=g(I);if(!A)continue;const N=A.terminals.find(H=>H.id===C);if(!N)continue;const L=dn.get(I);L&&mo(L.lowerBusId,v);const z=ft(I,A.width,`${I}.${C}`);N.y>0?E+=z:j+=z}const _=Math.max(ut,Math.max(E,j)+qe);return et.set(y,_),v.delete(y),_};for(const y of n)mo(y.id,new Set);const Fe=new Map,Hw=(y,v,S)=>{const E=g(v);if(!E)return;const j=`${v}.${S}`,_=E.terminals.filter(I=>I.id!==S).map(I=>`${v}.${I.id}`);if(_.length===0)return;const T=new Set([j,..._]),R=_.slice();for(;R.length>0;){const I=R.shift();if($(I)&&I!==y){const A=c.get(I);return A?A.at[0]:void 0}for(const A of D.get(I)??[])for(const N of A)N===I||T.has(N)||(T.add(N),R.push(N));const C=I.indexOf(".");if(C>0){const A=I.slice(0,C);if(!$(A)){const N=g(A);if(N)for(const L of N.terminals){const z=`${A}.${L.id}`;T.has(z)||(T.add(z),R.push(z))}}}}},Ww=y=>{const v=V.get(y);if(!v||v.length===0)return;const S=c.get(y);if(!S)return;const E=v.flatMap(N=>{if($(N))return[];const L=N.indexOf(".");if(L<0)return[];const z=N.slice(0,L),H=N.slice(L+1);if(l.has(z))return[];if(fo(z,y))return[];const q=g(z);if(!q)return[];const W=q.terminals.find(Z=>Z.id===H);return W?[{elId:z,lib:q,localTerm:W,isLinker:G.has(z),busFacingRef:`${z}.${H}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const T=N=>N.reduce((L,z)=>L+ft(z.elId,z.lib.width,z.busFacingRef),0),R=Math.max(T(j),T(_))+qe,I=Math.max(S.span,R);I!==S.span&&!m.has(y)&&c.set(y,{...S,span:I});const C=c.get(y),A=(N,L)=>{if(N.length===0)return;const z=new Map;for(const Y of N){const U=Hw(y,Y.elId,Y.localTerm.id);U!==void 0&&z.set(Y.elId,U)}N.sort((Y,U)=>{const de=z.get(Y.elId)??C.at[0],be=z.get(U.elId)??C.at[0];if(de!==be)return de-be;const K=ft(Y.elId,Y.lib.width,Y.busFacingRef);return ft(U.elId,U.lib.width,U.busFacingRef)-K});const H=N.map(Y=>ft(Y.elId,Y.lib.width,Y.busFacingRef)),q=H.reduce((Y,U)=>Y+U,0),W=Math.max(I,q),Z=(W-q)/(N.length+1);let Q=C.at[0]-W/2+Z;const X=C.at[1]+L*Ro;for(let Y=0;Y<N.length;Y++){const U=N[Y],de=H[Y],be=Q+de/2;U.isLinker?Fe.has(U.elId)||Fe.set(U.elId,be):l.set(U.elId,{at:[pe(be-U.localTerm.x),pe(X-U.localTerm.y)],rot:0,mirror:!1}),Q+=de+Z}};A(j,-1),A(_,1)},qw=y=>{if(l.has(y.elementId)||y.orientation==="horizontal")return;const v=g(y.elementId);if(!v)return;const S=y.attachments.filter(Q=>c.has(Q.busId));if(S.length<2)return;const E=S.slice().sort((Q,X)=>(se.get(Q.busId)??0)-(se.get(X.busId)??0)),j=E[0].busId,_=c.get(j),T=E[0].pin,R=E[E.length-1].pin,I=v.terminals.find(Q=>Q.id===T),C=v.terminals.find(Q=>Q.id===R);if(!I||!C)return;const A=I.y<=C.y?0:180,N=se.get(j)??0,L=S.filter(Q=>(se.get(Q.busId)??0)===N),z=[];let H=0;for(const Q of L){const X=_e(y,Q.busId,Q.pin);H=Math.max(H,X.extent);const Y=X.head?l.get(X.head):void 0;Y?z.push(Y.at[0]):Fe.has(y.elementId)?z.push(Fe.get(y.elementId)):z.push(c.get(Q.busId).at[0])}let q;z.length>0?q=z.reduce((Q,X)=>Q+X,0)/z.length:Fe.has(y.elementId)?q=Fe.get(y.elementId):q=_.at[0];const W=_.at[1]+H,Z=A===0?[pe(q-I.x),pe(W-I.y)]:[pe(q+I.x),pe(W+I.y)];if(l.set(y.elementId,{at:Z,rot:A,mirror:!1}),L.length>1){const Q=l.get(y.elementId),X=Pe([I.x,I.y],Q),Y=$t(I.orientation,Q);Gw(`${y.elementId}.${T}`,X,Y,q)}},Gw=(y,v,S,E)=>{const j=new Set([y]);let _=y,T=v,R=S;for(;;){const I=D.get(_)??[];let C,A=!1;for(const ee of I){if(ee.length>=3){A=!0;break}const $e=ee.find(Se=>Se!==_);if(!(!$e||j.has($e))){if($($e)){A=!0;break}C=$e;break}}if(A||!C)break;const N=C.indexOf(".");if(N<0)break;const L=C.slice(0,N),z=C.slice(N+1);if($(L)||G.has(L)||l.has(L))break;const H=g(L);if(!H)break;const q=H.terminals.find(ee=>ee.id===z);if(!q)break;const W=On(R),Z=[T[0]+W[0]*bt,T[1]+W[1]*bt],Q=zo[R],X=Bt(q.orientation,Q),Y=Pe([q.x,q.y],{at:[0,0],rot:X,mirror:!1}),U=[pe(E-Y[0]),pe(Z[1]-Y[1])];l.set(L,{at:U,rot:X,mirror:!1}),j.add(C);const de=H.terminals.find(ee=>ee.id!==z);if(!de)break;const be=`${L}.${de.id}`;j.add(be);const K={at:U,rot:X,mirror:!1};T=Pe([de.x,de.y],K),R=$t(de.orientation,K),_=be}},Xw=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const v=g(y.elementId);if(!v)return;const S=y.attachments.filter(L=>c.has(L.busId));if(S.length<2)return;const E=S.map(L=>{const z=_e(y,L.busId,L.pin),H=z.head?l.get(z.head):void 0,q=H?H.at[0]:c.get(L.busId).at[0];return{att:L,x:q,extent:z.extent}});E.sort((L,z)=>L.x-z.x);const j=E[0],_=E[E.length-1],T=v.terminals.find(L=>L.id===j.att.pin),R=v.terminals.find(L=>L.id===_.att.pin);if(!T||!R)return;const I=T.y<=R.y?270:90,C=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(y.elementId,{at:[pe(C),pe(N)],rot:I,mirror:!1})},ho=100;let Ct=Lt;for(let y=0;y<xe.length;y++){const v=xe[y],S=ye.get(v);let E;if(y===0)E=Lt;else{const _=ye.get(xe[y-1]);let T=0;for(const R of _)for(const I of S)(So=ce.get(R))!=null&&So.get(I)&&(T=Math.max(T,Ne(R,I)));T===0&&(T=xt),E=Ct+T}Ct=E;let j=yn;for(const _ of S){if(c.has(_)){Ct=Math.max(Ct,c.get(_).at[1]);continue}let T;if(y>0){const I=ye.get(xe[y-1]),C=[];for(const A of I){const N=(jo=ce.get(A))==null?void 0:jo.get(_);if(!N||N.orientation!=="vertical")continue;const L=(Eo=N.attachments.find(H=>H.busId===A))==null?void 0:Eo.pin;if(!L)continue;const z=_e(N,A,L);z.head&&l.has(z.head)?C.push(l.get(z.head).at[0]):Fe.has(N.elementId)?C.push(Fe.get(N.elementId)):C.push(c.get(A).at[0])}C.length>0&&(T=C.reduce((A,N)=>A+N,0)/C.length)}if(T===void 0){const I=et.get(_)??xn;T=j+I/2,j+=I+ho}const R=et.get(_)??xn;c.set(_,{at:[pe(T),pe(E)],rot:0,span:R,axis:Pn(0)})}for(const _ of S)Ww(_);if(y>0)for(const _ of ne)l.has(_.elementId)||!_.attachments.some(R=>S.includes(R.busId))||qw(_);for(const _ of ne)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(R=>S.includes(R.busId))||Xw(_)}if(n.length===0&&l.size<t.length){const y=j=>{const _=new Set,T=g(j);if(!T)return _;for(const R of T.terminals){const I=`${j}.${R.id}`;for(const C of D.get(I)??[])for(const A of C){if(A===I||$(A))continue;const N=A.indexOf(".");if(N<0)continue;const L=A.slice(0,N);L!==j&&_.add(L)}}return _},v=new Set,S=[];for(const j of t){if(v.has(j.id)||!g(j.id))continue;const _=[],T=[j.id];for(v.add(j.id);T.length>0;){const R=T.pop();_.push(R);for(const I of y(R))v.has(I)||(v.add(I),T.push(I))}_.length>=2&&S.push(_)}let E=yn;for(const j of S){if(j.some(C=>l.has(C)))continue;j.sort((C,A)=>{var q,W;const N=he(((q=p.get(C))==null?void 0:q.kind)??"")?0:1,L=he(((W=p.get(A))==null?void 0:W.kind)??"")?0:1;if(N!==L)return N-L;const z=y(C).size,H=y(A).size;return z!==H?z-H:C.localeCompare(A)});const _=j[0],T=g(_);if(!T)continue;const R=T.terminals.slice().sort((C,A)=>A.y-C.y)[0],I=R?Pe([R.x,R.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[pe(E-I[0]),pe(Lt-I[1])],rot:0,mirror:!1}),E+=Math.max(xn,j.length*qe)+ho}}const Yw=y=>{if($(y))return c.has(y);const v=y.indexOf(".");return v<0?!1:l.has(y.slice(0,v))};let un=!0,Kw=t.length+4;for(;un&&Kw-- >0;){un=!1;for(const y of B){if(y.length<2)continue;const v=[],S=new Map;for(const X of y){if($(X))continue;const Y=X.indexOf(".");if(Y<0)continue;const U=X.slice(0,Y),de=X.slice(Y+1);if(l.has(U)){v.push(X);continue}if(G.has(U)||S.has(U))continue;const be=g(U);if(!be)continue;const K=be.terminals.find(ee=>ee.id===de);K&&S.set(U,{ref:X,elId:U,lib:be,localTerm:K})}if(S.size===0||v.length===0)continue;const E=[...S.values()],j=new Map;for(const X of E)for(const Y of D.get(X.ref)??[])for(const U of Y){if(U===X.ref||$(U)||!Yw(U))continue;const de=U;j.set(de,(j.get(de)??0)+1)}let _;if(j.size>0){let X=-1;for(const[Y,U]of j)(U>X||U===X&&(_===void 0||Y<_))&&(X=U,_=Y)}if(_||(_=[...v].sort()[0]),!_)continue;const T=_.indexOf("."),R=_.slice(0,T),I=_.slice(T+1),C=g(R),A=l.get(R);if(!C||!A)continue;const N=C.terminals.find(X=>X.id===I);if(!N)continue;const L=Pe([N.x,N.y],A),z=$t(N.orientation,A),H=On(z),q=[-H[1],H[0]];E.sort((X,Y)=>X.elId.localeCompare(Y.elId));const W=E.map(X=>Math.max(X.lib.width,qe));let Q=-W.reduce((X,Y)=>X+Y,0)/2;for(let X=0;X<E.length;X++){const Y=E[X],U=W[X],de=Q+U/2;Q+=U;const be=zo[z],K=Bt(Y.localTerm.orientation,be),ee=Pe([Y.localTerm.x,Y.localTerm.y],{at:[0,0],rot:K,mirror:!1}),$e=[L[0]+H[0]*bt+q[0]*de,L[1]+H[1]*bt+q[1]*de],Se=[pe($e[0]-ee[0]),pe($e[1]-ee[1])];l.set(Y.elId,{at:Se,rot:K,mirror:!1}),un=!0}}}const mt=y=>{const v=l.get(y),S=g(y);if(!v||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.width/2;return{min:v.at[0]-N,max:v.at[0]+N}}const[j,_,T,R]=E,I=[[j,_],[j+T,_],[j,_+R],[j+T,_+R]];let C=1/0,A=-1/0;for(const N of I){const L=Pe(N,v);C=Math.min(C,L[0]),A=Math.max(A,L[0])}return{min:C,max:A}},fn=y=>{const v=new Set,S=g(y);if(!S)return v;for(const E of S.terminals){const j=`${y}.${E.id}`;for(const _ of D.get(j)??[])for(const T of _){if(T===j||$(T))continue;const R=T.indexOf(".");if(R<0)continue;const I=T.slice(0,R);I!==y&&v.add(I)}}return v},po=40,mn=y=>{const v=l.get(y),S=g(y);if(!v||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.height/2;return{min:v.at[1]-N,max:v.at[1]+N}}const[j,_,T,R]=E,I=[[j,_],[j+T,_],[j,_+R],[j+T,_+R]];let C=1/0,A=-1/0;for(const N of I){const L=Pe(N,v);C=Math.min(C,L[1]),A=Math.max(A,L[1])}return{min:C,max:A}},Vw=(y,v)=>{const S=new Set,E=[];for(const j of V.get(y)??[]){if($(j))continue;const _=j.indexOf(".");if(_<0)continue;const T=j.slice(0,_),R=l.get(T);!R||R.at[1]>=v-1||S.has(T)||(S.add(T),E.push(T))}for(;E.length>0;){const j=E.pop();for(const _ of fn(j)){if(S.has(_))continue;const T=l.get(_);!T||T.at[1]>=v-1||(S.add(_),E.push(_))}}return S},go=(y,v,S)=>{const E=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const T of fn(_))T===v||E.has(T)||!S.has(T)||(E.add(T),j.push(T))}return E},yo=(y,v)=>{let S=y.length*y.length+8,E=!1,j=!0;for(;j&&S-- >0;){j=!1;for(let _=0;_<y.length&&!j;_++)for(let T=_+1;T<y.length;T++){const R=y[_],I=y[T],C=mt(R),A=mt(I),N=mn(R),L=mn(I);if(!C||!A||!N||!L)continue;const z=Math.min(C.max,A.max)-Math.max(C.min,A.min),H=Math.min(N.max,L.max)-Math.max(N.min,L.min);if(z<=0||H<=0)continue;const q=go(R,I,v),W=go(I,R,v);if(q.has(I)||W.has(R))continue;const Z=![...q].some(K=>u.has(K)),Q=![...W].some(K=>u.has(K));if(!Z&&!Q)continue;const X=(C.min+C.max)/2,Y=(A.min+A.max)/2;let U,de;Z&&(!Q||q.size<=W.size)?(U=q,de=X<=Y?-1:1):(U=W,de=Y<=X?-1:1);const be=pe(de*(z+po));if(be!==0){for(const K of U){const ee=l.get(K);ee&&l.set(K,{...ee,at:[ee.at[0]+be,ee.at[1]]})}E=!0,j=!0;break}}}return E};for(const y of n){const v=c.get(y.id);if(!v)continue;const S=Vw(y.id,v.at[1]);if(S.size<2)continue;const E=[...S];if(yo(E,S)){let _=1/0,T=-1/0;for(const R of E){const I=mt(R);I&&(_=Math.min(_,I.min),T=Math.max(T,I.max))}if(Number.isFinite(_)){const I=E.some(A=>u.has(A))?0:pe(v.at[0]-(_+T)/2);if(I!==0)for(const A of E){const N=l.get(A);N&&l.set(A,{...N,at:[N.at[0]+I,N.at[1]]})}const C=T-_+po;if(C>v.span&&!m.has(y.id)){const A=c.get(y.id);c.set(y.id,{...A,span:C})}}}}const xo=()=>{const v=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:mt(E),y:mn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<v.length;E++)for(let j=E+1;j<v.length;j++){const _=Math.min(v[E].x.max,v[j].x.max)-Math.max(v[E].x.min,v[j].x.min),T=Math.min(v[E].y.max,v[j].y.max)-Math.max(v[E].y.min,v[j].y.min);_>1&&T>1&&S++}return S},Uw=xo(),bo=new Map;for(const[y,v]of l)bo.set(y,{...v,at:[...v.at]});const wo=new Map;for(const[y,v]of c)wo.set(y,{...v,at:[...v.at]});const hn=120,vo=new Map;{const y=new Map,v=new Map,S=[];for(const j of n)for(const _ of V.get(j.id)??[]){if($(_))continue;const T=_.indexOf(".");if(T<0)continue;const R=_.slice(0,T);l.has(R)&&S.push({el:R,bus:j.id,d:1})}S.sort((j,_)=>j.d-_.d);let E=0;for(;E<S.length;){const{el:j,bus:_,d:T}=S[E++],R=y.get(j);if(R===void 0)y.set(j,T),v.set(j,_);else if(T===R&&v.get(j)!==_){v.set(j,null);continue}else continue;for(const I of fn(j))l.has(I)&&(y.has(I)||S.push({el:I,bus:_,d:T+1}))}for(const[j,_]of v)_&&vo.set(j,_)}for(const y of xe){const v=(ye.get(y)??[]).filter(C=>c.has(C));if(v.length<2||v.some(C=>m.has(C)))continue;const S=[];let E=0;for(const C of v){const A=c.get(C),N=[];let L=1/0,z=-1/0;for(const[H,q]of vo){if(q!==C)continue;const W=mt(H);W&&(N.push(H),L=Math.min(L,W.min),z=Math.max(z,W.max))}Number.isFinite(L)||(L=A.at[0]-ut/2,z=A.at[0]+ut/2),S.push({busId:C,min:L,max:z,members:N}),E+=z-L}if(S.some(C=>C.members.some(A=>u.has(A))))continue;let j=1/0,_=-1/0;for(const C of S)j=Math.min(j,C.min),_=Math.max(_,C.max);const T=_-j,R=E+hn*(S.length-1);if(!(T>R+hn))continue;S.sort((C,A)=>(C.min+C.max)/2-(A.min+A.max)/2);let I=j;for(const C of S){const A=pe(I-C.min);if(A!==0){const N=c.get(C.busId);c.set(C.busId,{...N,at:[N.at[0]+A,N.at[1]]});for(const L of C.members){const z=l.get(L);z&&l.set(L,{...z,at:[z.at[0]+A,z.at[1]]})}C.min+=A,C.max+=A}I=C.max+hn}for(const C of S){const A=c.get(C.busId),N=Math.max(ut,C.max-C.min);N<A.span&&c.set(C.busId,{...A,span:N})}}{const y=t.map(S=>S.id).filter(S=>l.has(S)),v=new Set(y);yo(y,v)}if(xo()>Uw){l.clear();for(const[y,v]of bo)l.set(y,v);c.clear();for(const[y,v]of wo)c.set(y,v)}let pn=0;for(const y of t){if(l.has(y.id))continue;const v=pn%Fo,S=Math.floor(pn/Fo);l.set(y.id,{at:[pe(a2+v*c2),pe(l2+S*d2)],rot:0,mirror:!1}),pn++}return{devices:l,buses:c,junctions:f}}function pe(e){return Math.round(e/Do)*Do}function f2(e,t){const n=e.ends[0],o=e.ends[1],r=Wo(n,t),s=Wo(o,t);if(r||s){const l=r?n:o,f=bn(r?o:n,t);if(!f)return null;const u=t.buses.get(l);if(!u)return null;const{axis:m,at:p,span:h}=u.geometry,g=h/2;let b;if(m==="x")b=[Xt(f[0],p[0]-g,p[0]+g),p[1]];else{const $=Xt(f[1],p[1]-g,p[1]+g);b=[p[0],$]}return{wireId:e.id,path:Go(f,b)}}const i=bn(n,t),a=bn(o,t);return!i||!a?null:{wireId:e.id,path:Go(i,a)}}function Wo(e,t){return!e.includes(".")&&t.buses.has(e)}function bn(e,t){if(!e.includes(".")){const o=t.buses.get(e);if(o)return o.geometry.at;const r=t.junctions.get(e);return r?r.world:null}const n=t.terminals.get(e);return n?n.world:null}function qo(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const f=n.junctions.get(e);return f?[f.world[0],f.world[1]]: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[Xt(t[0],i[0]-l,i[0]+l),i[1]];const c=Xt(t[1],i[1]-l,i[1]+l);return[i[0],c]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function Go(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Xt(e,t,n){return e<t?t:e>n?n:e}const cs="ammeter",ds="电流表 (A)",us="measurement",fs="-22 -42 44 44",ms=44,hs=44,ps='<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>',gs=[{id:"t_top",x:0,y:-40,orientation:"n"}],ys={kind:"inline"},m2={id:cs,name:ds,category:us,viewBox:fs,width:ms,height:hs,svg:ps,terminals:gs,source:ys},h2=Object.freeze(Object.defineProperty({__proto__:null,category:us,default:m2,height:hs,id:cs,name:ds,source:ys,svg:ps,terminals:gs,viewBox:fs,width:ms},Symbol.toStringTag,{value:"Module"})),xs="arc-suppression-coil",bs="消弧线圈",ws="grounding",vs="中性点谐振接地:电感线圈连接到地",ks="-12 -32 24 67",_s=24,$s=67,Ss='<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"/>',js=[{id:"t_top",x:0,y:-30,orientation:"n"}],Es={kind:"inline"},p2={id:xs,name:bs,category:ws,description:vs,viewBox:ks,width:_s,height:$s,svg:Ss,terminals:js,source:Es},g2=Object.freeze(Object.defineProperty({__proto__:null,category:ws,default:p2,description:vs,height:$s,id:xs,name:bs,source:Es,svg:Ss,terminals:js,viewBox:ks,width:_s},Symbol.toStringTag,{value:"Module"})),Ns="arrester",Ms="避雷器 (FBL)",Ts="protection",As="-7 -22 14 44",Is=14,Cs=44,Ps='<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"/>',Os=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Bs={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},y2={id:Ns,name:Ms,category:Ts,viewBox:As,width:Is,height:Cs,svg:Ps,terminals:Os,source:Bs},x2=Object.freeze(Object.defineProperty({__proto__:null,category:Ts,default:y2,height:Cs,id:Ns,name:Ms,source:Bs,svg:Ps,terminals:Os,viewBox:As,width:Is},Symbol.toStringTag,{value:"Module"})),Ls="async-motor",zs="异步电动机",Rs="load",Ds="-62 -82 64 84",Fs=64,Hs=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"/>',qs=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Gs={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"},b2={id:Ls,name:zs,category:Rs,viewBox:Ds,width:Fs,height:Hs,svg:Ws,terminals:qs,source:Gs},w2=Object.freeze(Object.defineProperty({__proto__:null,category:Rs,default:b2,height:Hs,id:Ls,name:zs,source:Gs,svg:Ws,terminals:qs,viewBox:Ds,width:Fs},Symbol.toStringTag,{value:"Module"})),Xs="autotransformer",Ys="自耦变压器",Ks="transformer",Vs="-62 -112 64 144",Us=64,Js=144,Zs='<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"/>',Qs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],ei={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},v2={id:Xs,name:Ys,category:Ks,viewBox:Vs,width:Us,height:Js,svg:Zs,terminals:Qs,source:ei},k2=Object.freeze(Object.defineProperty({__proto__:null,category:Ks,default:v2,height:Js,id:Xs,name:Ys,source:ei,svg:Zs,terminals:Qs,viewBox:Vs,width:Us},Symbol.toStringTag,{value:"Module"})),ti="battery",ni="电池储能",oi="storage",ri="-12 -12 29 24",si=29,ii=24,ai='<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"/>',li=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],ci=[{name:"E",label:"容量",type:"number",unit:"kWh"}],di={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},_2={id:ti,name:ni,category:oi,viewBox:ri,width:si,height:ii,svg:ai,terminals:li,params:ci,source:di},$2=Object.freeze(Object.defineProperty({__proto__:null,category:oi,default:_2,height:ii,id:ti,name:ni,params:ci,source:di,svg:ai,terminals:li,viewBox:ri,width:si},Symbol.toStringTag,{value:"Module"})),ui="bell",fi="电铃 (HA)",mi="control",hi="信号电铃 / 警铃。",pi="-32 -32 44 44",gi=44,yi=44,xi='<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"/>',bi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],wi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},S2={id:ui,name:fi,category:mi,description:hi,viewBox:pi,width:gi,height:yi,svg:xi,terminals:bi,source:wi},j2=Object.freeze(Object.defineProperty({__proto__:null,category:mi,default:S2,description:hi,height:yi,id:ui,name:fi,source:wi,svg:xi,terminals:bi,viewBox:pi,width:gi},Symbol.toStringTag,{value:"Module"})),vi="break-contact",ki="常闭触点 (NC)",_i="control",$i="常闭辅助触点 (break contact)。",Si="-2 -42 14 64",ji=14,Ei=64,Ni='<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"/>',Mi=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ti=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ai={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},E2={id:vi,name:ki,category:_i,description:$i,viewBox:Si,width:ji,height:Ei,svg:Ni,terminals:Mi,state:Ti,source:Ai},N2=Object.freeze(Object.defineProperty({__proto__:null,category:_i,default:E2,description:$i,height:Ei,id:vi,name:ki,source:Ai,state:Ti,svg:Ni,terminals:Mi,viewBox:Si,width:ji},Symbol.toStringTag,{value:"Module"})),Ii="breaker",Ci="断路器 (QF)",Pi="switching",Oi="-7 -22 15 46",Bi=15,Li=46,zi='<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>',Ri=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Di=[{name:"open",type:"boolean",default:!1,label:"断开"}],Fi={x:6,y:-2,anchor:"start"},Hi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},M2={id:Ii,name:Ci,category:Pi,viewBox:Oi,width:Bi,height:Li,svg:zi,terminals:Ri,state:Di,label:Fi,source:Hi},T2=Object.freeze(Object.defineProperty({__proto__:null,category:Pi,default:M2,height:Li,id:Ii,label:Fi,name:Ci,source:Hi,state:Di,svg:zi,terminals:Ri,viewBox:Oi,width:Bi},Symbol.toStringTag,{value:"Module"})),Wi="buchholz-relay",qi="瓦斯继电器 (63)",Gi="protection",Xi="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Yi="-22 -62 44 64",Ki=44,Vi=64,Ui='<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"/>',Ji=[{id:"t_top",x:0,y:-60,orientation:"n"}],Zi={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:qi,category:Gi,description:Xi,viewBox:Yi,width:Ki,height:Vi,svg:Ui,terminals:Ji,source:Zi},I2=Object.freeze(Object.defineProperty({__proto__:null,category:Gi,default:A2,description:Xi,height:Vi,id:Wi,name:qi,source:Zi,svg:Ui,terminals:Ji,viewBox:Yi,width:Ki},Symbol.toStringTag,{value:"Module"})),Qi="busbar",ea="母线段",ta="busbar",na="可拉伸单母线段,多设备挂接",oa="-42 -4 84 8",ra=84,sa=8,ia='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',aa=[{id:"tap",x:0,y:0,orientation:"n"}],la={axis:"x",minLength:20,naturalSpan:80},ca=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],da={x:0,y:-6,anchor:"middle"},ua={kind:"inline"},C2={id:Qi,name:ea,category:ta,description:na,viewBox:oa,width:ra,height:sa,svg:ia,terminals:aa,stretchable:la,params:ca,label:da,source:ua},P2=Object.freeze(Object.defineProperty({__proto__:null,category:ta,default:C2,description:na,height:sa,id:Qi,label:da,name:ea,params:ca,source:ua,stretchable:la,svg:ia,terminals:aa,viewBox:oa,width:ra},Symbol.toStringTag,{value:"Module"})),fa="buzzer",ma="蜂鸣器 (HA)",ha="control",pa="信号蜂鸣器。",ga="-32 -52 44 64",ya=44,xa=64,ba='<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"/>',wa=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],va={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},O2={id:fa,name:ma,category:ha,description:pa,viewBox:ga,width:ya,height:xa,svg:ba,terminals:wa,source:va},B2=Object.freeze(Object.defineProperty({__proto__:null,category:ha,default:O2,description:pa,height:xa,id:fa,name:ma,source:va,svg:ba,terminals:wa,viewBox:ga,width:ya},Symbol.toStringTag,{value:"Module"})),ka="capacitor",_a="电容 (C)",$a="passive",Sa="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",ja="-7 -23 14 27",Ea=14,Na=27,Ma='<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"/>',Ta=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Aa=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Ia={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},L2={id:ka,name:_a,category:$a,description:Sa,viewBox:ja,width:Ea,height:Na,svg:Ma,terminals:Ta,params:Aa,source:Ia},z2=Object.freeze(Object.defineProperty({__proto__:null,category:$a,default:L2,description:Sa,height:Na,id:ka,name:_a,params:Aa,source:Ia,svg:Ma,terminals:Ta,viewBox:ja,width:Ea},Symbol.toStringTag,{value:"Module"})),Ca="contactor",Pa="接触器 (KM)",Oa="motor-control",Ba="主回路接触器, 通常配热继电器和电机使用。",La="-10 -42 15 64",za=15,Ra=64,Da='<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"/>',Fa=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ha=[{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"},R2={id:Ca,name:Pa,category:Oa,description:Ba,viewBox:La,width:za,height:Ra,svg:Da,terminals:Fa,state:Ha,source:Wa},D2=Object.freeze(Object.defineProperty({__proto__:null,category:Oa,default:R2,description:Ba,height:Ra,id:Ca,name:Pa,source:Wa,state:Ha,svg:Da,terminals:Fa,viewBox:La,width:za},Symbol.toStringTag,{value:"Module"})),qa="converter-bidir",Ga="双向变流器 (PCS)",Xa="renewable",Ya="储能变流器:双向 AC ↔ DC",Ka="-42 -42 44 48",Va=44,Ua=48,Ja='<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"/>',Za=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Qa=[{name:"S",label:"容量",type:"number",unit:"MVA"}],el={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},F2={id:qa,name:Ga,category:Xa,description:Ya,viewBox:Ka,width:Va,height:Ua,svg:Ja,terminals:Za,params:Qa,source:el},H2=Object.freeze(Object.defineProperty({__proto__:null,category:Xa,default:F2,description:Ya,height:Ua,id:qa,name:Ga,params:Qa,source:el,svg:Ja,terminals:Za,viewBox:Ka,width:Va},Symbol.toStringTag,{value:"Module"})),tl="ct",nl="电流互感器 (CT)",ol="instrument-transformer",rl="-42 -62 54 64",sl=54,il=64,al='<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"/>',ll=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],cl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},W2={id:tl,name:nl,category:ol,viewBox:rl,width:sl,height:il,svg:al,terminals:ll,source:cl},q2=Object.freeze(Object.defineProperty({__proto__:null,category:ol,default:W2,height:il,id:tl,name:nl,source:cl,svg:al,terminals:ll,viewBox:rl,width:sl},Symbol.toStringTag,{value:"Module"})),dl="dc-combiner",ul="直流汇流箱",fl="renewable",ml="光伏组串汇流箱 (4 路输入示例)。",hl="-27 -32 54 64",pl=54,gl=64,yl='<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>',xl=[{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"}],bl={kind:"inline"},G2={id:dl,name:ul,category:fl,description:ml,viewBox:hl,width:pl,height:gl,svg:yl,terminals:xl,source:bl},X2=Object.freeze(Object.defineProperty({__proto__:null,category:fl,default:G2,description:ml,height:gl,id:dl,name:ul,source:bl,svg:yl,terminals:xl,viewBox:hl,width:pl},Symbol.toStringTag,{value:"Module"})),wl="dc-disconnector",vl="直流隔离开关",kl="switching",_l="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",$l="-12 -32 30 64",Sl=30,jl=64,El='<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"/>',Nl=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Ml=[{name:"open",type:"boolean",default:!1,label:"断开"}],Tl={kind:"inline"},Y2={id:wl,name:vl,category:kl,description:_l,viewBox:$l,width:Sl,height:jl,svg:El,terminals:Nl,state:Ml,source:Tl},K2=Object.freeze(Object.defineProperty({__proto__:null,category:kl,default:Y2,description:_l,height:jl,id:wl,name:vl,source:Tl,state:Ml,svg:El,terminals:Nl,viewBox:$l,width:Sl},Symbol.toStringTag,{value:"Module"})),Al="dc-motor",Il="直流电机 (M)",Cl="load",Pl="直流电动机 (串励通用符号)。",Ol="-72 -82 89 84",Bl=89,Ll=84,zl='<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"/>',Rl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Dl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},V2={id:Al,name:Il,category:Cl,description:Pl,viewBox:Ol,width:Bl,height:Ll,svg:zl,terminals:Rl,source:Dl},U2=Object.freeze(Object.defineProperty({__proto__:null,category:Cl,default:V2,description:Pl,height:Ll,id:Al,name:Il,source:Dl,svg:zl,terminals:Rl,viewBox:Ol,width:Bl},Symbol.toStringTag,{value:"Module"})),Fl="diode",Hl="二极管 (D)",Wl="passive",ql="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Gl="-12 -42 24 44",Xl=24,Yl=44,Kl='<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"/>',Vl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ul={x:6,y:-20,anchor:"start"},Jl={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},J2={id:Fl,name:Hl,category:Wl,description:ql,viewBox:Gl,width:Xl,height:Yl,svg:Kl,terminals:Vl,label:Ul,source:Jl},Z2=Object.freeze(Object.defineProperty({__proto__:null,category:Wl,default:J2,description:ql,height:Yl,id:Fl,label:Ul,name:Hl,source:Jl,svg:Kl,terminals:Vl,viewBox:Gl,width:Xl},Symbol.toStringTag,{value:"Module"})),Zl="disconnector",Ql="隔离开关 (QS)",ec="switching",tc="-10 -42 15 64",nc=15,oc=64,rc='<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"/>',sc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ic=[{name:"open",type:"boolean",default:!1,label:"断开"}],ac={x:6,y:-10,anchor:"start"},lc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},Q2={id:Zl,name:Ql,category:ec,viewBox:tc,width:nc,height:oc,svg:rc,terminals:sc,state:ic,label:ac,source:lc},ek=Object.freeze(Object.defineProperty({__proto__:null,category:ec,default:Q2,height:oc,id:Zl,label:ac,name:Ql,source:lc,state:ic,svg:rc,terminals:sc,viewBox:tc,width:nc},Symbol.toStringTag,{value:"Module"})),cc="distance-relay",dc="距离继电器 (21)",uc="protection",fc="距离 / 低阻抗保护继电器 (ANSI 21)。",mc="-62 -42 64 44",hc=64,pc=44,gc='<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>',yc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],xc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},tk={id:cc,name:dc,category:uc,description:fc,viewBox:mc,width:hc,height:pc,svg:gc,terminals:yc,source:xc},nk=Object.freeze(Object.defineProperty({__proto__:null,category:uc,default:tk,description:fc,height:pc,id:cc,name:dc,source:xc,svg:gc,terminals:yc,viewBox:mc,width:hc},Symbol.toStringTag,{value:"Module"})),bc="earth",wc="接地",vc="busbar",kc="-12 -17 24 34",_c=24,$c=34,Sc='<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"/>',jc=[{id:"t1",x:0,y:-15,orientation:"n"}],Ec={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"},ok={id:bc,name:wc,category:vc,viewBox:kc,width:_c,height:$c,svg:Sc,terminals:jc,source:Ec},rk=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:ok,height:$c,id:bc,name:wc,source:Ec,svg:Sc,terminals:jc,viewBox:kc,width:_c},Symbol.toStringTag,{value:"Module"})),Nc="earthing-switch",Mc="接地刀闸 (QE)",Tc="switching",Ac="隔离开关 + 接地连接,单端口",Ic="-12 -32 24 64",Cc=24,Pc=64,Oc='<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"/>',Bc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Lc=[{name:"open",type:"boolean",default:!0,label:"断开"}],zc={x:12,y:-8,anchor:"start"},Rc={kind:"inline"},sk={id:Nc,name:Mc,category:Tc,description:Ac,viewBox:Ic,width:Cc,height:Pc,svg:Oc,terminals:Bc,state:Lc,label:zc,source:Rc},ik=Object.freeze(Object.defineProperty({__proto__:null,category:Tc,default:sk,description:Ac,height:Pc,id:Nc,label:zc,name:Mc,source:Rc,state:Lc,svg:Oc,terminals:Bc,viewBox:Ic,width:Cc},Symbol.toStringTag,{value:"Module"})),Dc="energy-meter",Fc="电能表 (Wh)",Hc="measurement",Wc="有功电能表 (kWh) — 服务入口 / 子表。",qc="-22 -36 44 72",Gc=44,Xc=72,Yc='<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"/>',Kc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Vc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},ak={id:Dc,name:Fc,category:Hc,description:Wc,viewBox:qc,width:Gc,height:Xc,svg:Yc,terminals:Kc,source:Vc},lk=Object.freeze(Object.defineProperty({__proto__:null,category:Hc,default:ak,description:Wc,height:Xc,id:Dc,name:Fc,source:Vc,svg:Yc,terminals:Kc,viewBox:qc,width:Gc},Symbol.toStringTag,{value:"Module"})),Uc="ev-charger",Jc="EV 充电桩",Zc="load",Qc="电动汽车充电站 / 充电桩。",ed="-17 -27 34 49",td=34,nd=49,od='<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>',rd=[{id:"t_top",x:0,y:-25,orientation:"n"}],sd={kind:"inline"},ck={id:Uc,name:Jc,category:Zc,description:Qc,viewBox:ed,width:td,height:nd,svg:od,terminals:rd,source:sd},dk=Object.freeze(Object.defineProperty({__proto__:null,category:Zc,default:ck,description:Qc,height:nd,id:Uc,name:Jc,source:sd,svg:od,terminals:rd,viewBox:ed,width:td},Symbol.toStringTag,{value:"Module"})),id="frequency-meter",ad="频率表 (Hz)",ld="measurement",cd="-22 -42 44 44",dd=44,ud=44,fd='<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>',md=[{id:"t_top",x:0,y:-40,orientation:"n"}],hd={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},uk={id,name:ad,category:ld,viewBox:cd,width:dd,height:ud,svg:fd,terminals:md,source:hd},fk=Object.freeze(Object.defineProperty({__proto__:null,category:ld,default:uk,height:ud,id,name:ad,source:hd,svg:fd,terminals:md,viewBox:cd,width:dd},Symbol.toStringTag,{value:"Module"})),pd="fuse-switch-disconnector",gd="熔断器式隔离开关",yd="switching",xd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",bd="-8 -32 12 64",wd=12,vd=64,kd='<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"/>',_d=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],$d=[{name:"open",type:"boolean",default:!1,label:"断开"}],Sd={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"},mk={id:pd,name:gd,category:yd,description:xd,viewBox:bd,width:wd,height:vd,svg:kd,terminals:_d,state:$d,source:Sd},hk=Object.freeze(Object.defineProperty({__proto__:null,category:yd,default:mk,description:xd,height:vd,id:pd,name:gd,source:Sd,state:$d,svg:kd,terminals:_d,viewBox:bd,width:wd},Symbol.toStringTag,{value:"Module"})),jd="fuse",Ed="熔断器 (FU)",Nd="switching",Md="-7 -32 14 64",Td=14,Ad=64,Id='<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"/>',Cd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Pd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Od={x:7,y:-2,anchor:"start"},Bd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},pk={id:jd,name:Ed,category:Nd,viewBox:Md,width:Td,height:Ad,svg:Id,terminals:Cd,state:Pd,label:Od,source:Bd},gk=Object.freeze(Object.defineProperty({__proto__:null,category:Nd,default:pk,height:Ad,id:jd,label:Od,name:Ed,source:Bd,state:Pd,svg:Id,terminals:Cd,viewBox:Md,width:Td},Symbol.toStringTag,{value:"Module"})),Ld="generator",zd="发电机 (G)",Rd="source",Dd="-42 -42 44 44",Fd=44,Hd=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>',qd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Gd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},yk={id:Ld,name:zd,category:Rd,viewBox:Dd,width:Fd,height:Hd,svg:Wd,terminals:qd,source:Gd},xk=Object.freeze(Object.defineProperty({__proto__:null,category:Rd,default:yk,height:Hd,id:Ld,name:zd,source:Gd,svg:Wd,terminals:qd,viewBox:Dd,width:Fd},Symbol.toStringTag,{value:"Module"})),Xd="genset",Yd="发电机组 (G)",Kd="source",Vd="柴油 / 燃气发电机组。",Ud="-28 -22 56 64",Jd=56,Zd=64,Qd='<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"/>',eu=[{id:"t_out",x:0,y:40,orientation:"s"}],tu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],nu={kind:"inline"},bk={id:Xd,name:Yd,category:Kd,description:Vd,viewBox:Ud,width:Jd,height:Zd,svg:Qd,terminals:eu,params:tu,source:nu},wk=Object.freeze(Object.defineProperty({__proto__:null,category:Kd,default:bk,description:Vd,height:Zd,id:Xd,name:Yd,params:tu,source:nu,svg:Qd,terminals:eu,viewBox:Ud,width:Jd},Symbol.toStringTag,{value:"Module"})),ou="gfci-breaker",ru="GFCI 断路器 (RCBO)",su="protection",iu="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",au="-18 -22 22 44",lu=22,cu=44,du='<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"/>',uu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],fu=[{name:"open",type:"boolean",default:!1,label:"断开"}],mu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],hu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},vk={id:ou,name:ru,category:su,description:iu,viewBox:au,width:lu,height:cu,svg:du,terminals:uu,state:fu,params:mu,source:hu},kk=Object.freeze(Object.defineProperty({__proto__:null,category:su,default:vk,description:iu,height:cu,id:ou,name:ru,params:mu,source:hu,state:fu,svg:du,terminals:uu,viewBox:au,width:lu},Symbol.toStringTag,{value:"Module"})),pu="grid-source",gu="系统电源",yu="source",xu="无穷大母线 / 外部电网",bu="-16 -31 32 53",wu=32,vu=53,ku='<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"/>',_u=[{id:"t_bottom",x:0,y:20,orientation:"s"}],$u={kind:"inline"},_k={id:pu,name:gu,category:yu,description:xu,viewBox:bu,width:wu,height:vu,svg:ku,terminals:_u,source:$u},$k=Object.freeze(Object.defineProperty({__proto__:null,category:yu,default:_k,description:xu,height:vu,id:pu,name:gu,source:$u,svg:ku,terminals:_u,viewBox:bu,width:wu},Symbol.toStringTag,{value:"Module"})),Su="grounding-transformer",ju="接地变 (Z形)",Eu="grounding",Nu="星-曲折接线变压器,中性点接地用",Mu="-62 -152 64 164",Tu=64,Au=164,Iu='<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"/>',Cu=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Pu={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"},Sk={id:Su,name:ju,category:Eu,description:Nu,viewBox:Mu,width:Tu,height:Au,svg:Iu,terminals:Cu,source:Pu},jk=Object.freeze(Object.defineProperty({__proto__:null,category:Eu,default:Sk,description:Nu,height:Au,id:Su,name:ju,source:Pu,svg:Iu,terminals:Cu,viewBox:Mu,width:Tu},Symbol.toStringTag,{value:"Module"})),Ou="heater",Bu="电加热器 (EH)",Lu="load",zu="电阻加热元件 / 电热负荷。",Ru="-22 -7 54 14",Du=54,Fu=14,Hu='<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"}],qu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Gu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},Ek={id:Ou,name:Bu,category:Lu,description:zu,viewBox:Ru,width:Du,height:Fu,svg:Hu,terminals:Wu,params:qu,source:Gu},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:Lu,default:Ek,description:zu,height:Fu,id:Ou,name:Bu,params:qu,source:Gu,svg:Hu,terminals:Wu,viewBox:Ru,width:Du},Symbol.toStringTag,{value:"Module"})),Xu="igbt",Yu="绝缘栅双极晶体管 (IGBT)",Ku="passive",Vu="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Uu="-32 -32 54 74",Ju=54,Zu=74,Qu='<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"/>',ef=[{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"}],tf={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"},Mk={id:Xu,name:Yu,category:Ku,description:Vu,viewBox:Uu,width:Ju,height:Zu,svg:Qu,terminals:ef,source:tf},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:Ku,default:Mk,description:Vu,height:Zu,id:Xu,name:Yu,source:tf,svg:Qu,terminals:ef,viewBox:Uu,width:Ju},Symbol.toStringTag,{value:"Module"})),nf="indicator-light",of="指示灯 (HL)",rf="control",sf="信号 / 状态指示灯。",af="-12 -22 24 24",lf=24,cf=24,df='<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"/>',uf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],ff=[{name:"color",label:"颜色",type:"string"}],mf={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:nf,name:of,category:rf,description:sf,viewBox:af,width:lf,height:cf,svg:df,terminals:uf,params:ff,source:mf},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:rf,default:Ak,description:sf,height:cf,id:nf,name:of,params:ff,source:mf,svg:df,terminals:uf,viewBox:af,width:lf},Symbol.toStringTag,{value:"Module"})),hf="inductor",pf="电感 (L)",gf="passive",yf="通用电感 / 线圈 / 扼流圈。",xf="-17 -32 34 64",bf=34,wf=64,vf='<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"/>',kf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],_f=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],$f={x:6,y:0,anchor:"start"},Sf={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Ck={id:hf,name:pf,category:gf,description:yf,viewBox:xf,width:bf,height:wf,svg:vf,terminals:kf,params:_f,label:$f,source:Sf},Pk=Object.freeze(Object.defineProperty({__proto__:null,category:gf,default:Ck,description:yf,height:wf,id:hf,label:$f,name:pf,params:_f,source:Sf,svg:vf,terminals:kf,viewBox:xf,width:bf},Symbol.toStringTag,{value:"Module"})),jf="inverter",Ef="逆变器 (DC→AC)",Nf="renewable",Mf="-42 -42 44 44",Tf=44,Af=44,If='<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"/>',Cf=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],Pf={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Ok={id:jf,name:Ef,category:Nf,viewBox:Mf,width:Tf,height:Af,svg:If,terminals:Cf,source:Pf},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:Nf,default:Ok,height:Af,id:jf,name:Ef,source:Pf,svg:If,terminals:Cf,viewBox:Mf,width:Tf},Symbol.toStringTag,{value:"Module"})),Of="limit-switch",Bf="限位开关 (SQ)",Lf="control",zf="行程 / 位置开关 (常开, 机械操作)。",Rf="-10 -42 12 64",Df=12,Ff=64,Hf='<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"/>',Wf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],qf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Gf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Lk={id:Of,name:Bf,category:Lf,description:zf,viewBox:Rf,width:Df,height:Ff,svg:Hf,terminals:Wf,state:qf,source:Gf},zk=Object.freeze(Object.defineProperty({__proto__:null,category:Lf,default:Lk,description:zf,height:Ff,id:Of,name:Bf,source:Gf,state:qf,svg:Hf,terminals:Wf,viewBox:Rf,width:Df},Symbol.toStringTag,{value:"Module"})),Xf="load-switch",Yf="负荷开关",Kf="switching",Vf="-10 -42 14 64",Uf=14,Jf=64,Zf='<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"/>',Qf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],em=[{name:"open",type:"boolean",default:!1,label:"断开"}],tm={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"},Rk={id:Xf,name:Yf,category:Kf,viewBox:Vf,width:Uf,height:Jf,svg:Zf,terminals:Qf,state:em,source:tm},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:Kf,default:Rk,height:Jf,id:Xf,name:Yf,source:tm,state:em,svg:Zf,terminals:Qf,viewBox:Vf,width:Uf},Symbol.toStringTag,{value:"Module"})),nm="load",om="负荷",rm="load",sm="抽象负荷(电流流出箭头)",im="-8 -22 16 46",am=16,lm=46,cm='<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"}],um=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],fm={x:6,y:0,anchor:"start"},mm={kind:"inline"},Fk={id:nm,name:om,category:rm,description:sm,viewBox:im,width:am,height:lm,svg:cm,terminals:dm,params:um,label:fm,source:mm},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:rm,default:Fk,description:sm,height:lm,id:nm,label:fm,name:om,params:um,source:mm,svg:cm,terminals:dm,viewBox:im,width:am},Symbol.toStringTag,{value:"Module"})),hm="make-contact",pm="常开触点 (NO)",gm="control",ym="常开辅助触点 (make contact)。",xm="-10 -42 12 64",bm=12,wm=64,vm='<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"/>',km=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_m=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],$m={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"},Wk={id:hm,name:pm,category:gm,description:ym,viewBox:xm,width:bm,height:wm,svg:vm,terminals:km,state:_m,source:$m},qk=Object.freeze(Object.defineProperty({__proto__:null,category:gm,default:Wk,description:ym,height:wm,id:hm,name:pm,source:$m,state:_m,svg:vm,terminals:km,viewBox:xm,width:bm},Symbol.toStringTag,{value:"Module"})),Sm="motor-starter",jm="电机启动器",Em="motor-control",Nm="电机启动器 (IEC 60617 通用符号)。",Mm="-22 -27 44 54",Tm=44,Am=54,Im='<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"/>',Cm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Pm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},Gk={id:Sm,name:jm,category:Em,description:Nm,viewBox:Mm,width:Tm,height:Am,svg:Im,terminals:Cm,source:Pm},Xk=Object.freeze(Object.defineProperty({__proto__:null,category:Em,default:Gk,description:Nm,height:Am,id:Sm,name:jm,source:Pm,svg:Im,terminals:Cm,viewBox:Mm,width:Tm},Symbol.toStringTag,{value:"Module"})),Om="ngr",Bm="中性点电阻 (NGR)",Lm="grounding",zm="小电阻接地:连接变压器中性点到地",Rm="-12 -32 24 62",Dm=24,Fm=62,Hm='<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"/>',Wm=[{id:"t_top",x:0,y:-30,orientation:"n"}],qm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Gm={kind:"inline"},Yk={id:Om,name:Bm,category:Lm,description:zm,viewBox:Rm,width:Dm,height:Fm,svg:Hm,terminals:Wm,params:qm,source:Gm},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:Lm,default:Yk,description:zm,height:Fm,id:Om,name:Bm,params:qm,source:Gm,svg:Hm,terminals:Wm,viewBox:Rm,width:Dm},Symbol.toStringTag,{value:"Module"})),Xm="overcurrent-relay",Ym="过流继电器 (50/51)",Km="protection",Vm="过电流保护继电器 (ANSI 50/51)。",Um="-62 -62 64 64",Jm=64,Zm=64,Qm='<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>',eh=[{id:"t_top",x:-30,y:-60,orientation:"n"}],th={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Vk={id:Xm,name:Ym,category:Km,description:Vm,viewBox:Um,width:Jm,height:Zm,svg:Qm,terminals:eh,source:th},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:Km,default:Vk,description:Vm,height:Zm,id:Xm,name:Ym,source:th,svg:Qm,terminals:eh,viewBox:Um,width:Jm},Symbol.toStringTag,{value:"Module"})),nh="phase-failure-relay",oh="断相继电器",rh="protection",sh="断相 / 缺相保护继电器。",ih="-62 -42 64 44",ah=64,lh=44,ch='<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>',dh=[{id:"t_top",x:-30,y:-40,orientation:"n"}],uh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Jk={id:nh,name:oh,category:rh,description:sh,viewBox:ih,width:ah,height:lh,svg:ch,terminals:dh,source:uh},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:rh,default:Jk,description:sh,height:lh,id:nh,name:oh,source:uh,svg:ch,terminals:dh,viewBox:ih,width:ah},Symbol.toStringTag,{value:"Module"})),fh="plc",mh="PLC / 控制器",hh="control",ph="可编程逻辑控制器 (PLC)。",gh="-24 -42 48 84",yh=48,xh=84,bh='<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"/>',wh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],vh={kind:"inline"},Qk={id:fh,name:mh,category:hh,description:ph,viewBox:gh,width:yh,height:xh,svg:bh,terminals:wh,source:vh},e_=Object.freeze(Object.defineProperty({__proto__:null,category:hh,default:Qk,description:ph,height:xh,id:fh,name:mh,source:vh,svg:bh,terminals:wh,viewBox:gh,width:yh},Symbol.toStringTag,{value:"Module"})),kh="power-factor-meter",_h="功率因数表 (cosφ)",$h="measurement",Sh="功率因数表 (cosφ)。",jh="-22 -42 44 44",Eh=44,Nh=44,Mh='<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>',Th=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ah={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},t_={id:kh,name:_h,category:$h,description:Sh,viewBox:jh,width:Eh,height:Nh,svg:Mh,terminals:Th,source:Ah},n_=Object.freeze(Object.defineProperty({__proto__:null,category:$h,default:t_,description:Sh,height:Nh,id:kh,name:_h,source:Ah,svg:Mh,terminals:Th,viewBox:jh,width:Eh},Symbol.toStringTag,{value:"Module"})),Ih="power-supply",Ch="开关电源 (PS)",Ph="source",Oh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Bh="-24 -42 48 84",Lh=48,zh=84,Rh='<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"/>',Dh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],Fh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Hh={kind:"inline"},o_={id:Ih,name:Ch,category:Ph,description:Oh,viewBox:Bh,width:Lh,height:zh,svg:Rh,terminals:Dh,params:Fh,source:Hh},r_=Object.freeze(Object.defineProperty({__proto__:null,category:Ph,default:o_,description:Oh,height:zh,id:Ih,name:Ch,params:Fh,source:Hh,svg:Rh,terminals:Dh,viewBox:Bh,width:Lh},Symbol.toStringTag,{value:"Module"})),Wh="protective-relay",qh="保护继电器",Gh="protection",Xh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Yh="-32 -42 64 44",Kh=64,Vh=44,Uh='<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"/>',Jh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Zh={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"},s_={id:Wh,name:qh,category:Gh,description:Xh,viewBox:Yh,width:Kh,height:Vh,svg:Uh,terminals:Jh,source:Zh},i_=Object.freeze(Object.defineProperty({__proto__:null,category:Gh,default:s_,description:Xh,height:Vh,id:Wh,name:qh,source:Zh,svg:Uh,terminals:Jh,viewBox:Yh,width:Kh},Symbol.toStringTag,{value:"Module"})),Qh="proximity-switch",e0="接近开关 (SQ)",t0="control",n0="接近传感器 / 无触点接近开关。",o0="-12 -32 24 64",r0=24,s0=64,i0='<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"/>',a0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],l0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},a_={id:Qh,name:e0,category:t0,description:n0,viewBox:o0,width:r0,height:s0,svg:i0,terminals:a0,source:l0},l_=Object.freeze(Object.defineProperty({__proto__:null,category:t0,default:a_,description:n0,height:s0,id:Qh,name:e0,source:l0,svg:i0,terminals:a0,viewBox:o0,width:r0},Symbol.toStringTag,{value:"Module"})),c0="pt",d0="电压互感器 (PT)",u0="instrument-transformer",f0="-22 -42 44 115",m0=44,h0=115,p0='<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"/>',g0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],y0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},c_={id:c0,name:d0,category:u0,viewBox:f0,width:m0,height:h0,svg:p0,terminals:g0,source:y0},d_=Object.freeze(Object.defineProperty({__proto__:null,category:u0,default:c_,height:h0,id:c0,name:d0,source:y0,svg:p0,terminals:g0,viewBox:f0,width:m0},Symbol.toStringTag,{value:"Module"})),x0="push-button",b0="按钮 (SB)",w0="control",v0="手动按钮, 自动复位 (常开 make)。",k0="-37 -42 39 64",_0=39,$0=64,S0='<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"/>',j0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],E0={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"},u_={id:x0,name:b0,category:w0,description:v0,viewBox:k0,width:_0,height:$0,svg:S0,terminals:j0,source:E0},f_=Object.freeze(Object.defineProperty({__proto__:null,category:w0,default:u_,description:v0,height:$0,id:x0,name:b0,source:E0,svg:S0,terminals:j0,viewBox:k0,width:_0},Symbol.toStringTag,{value:"Module"})),N0="pv",M0="光伏组件",T0="renewable",A0="-33 -22 85 64",I0=85,C0=64,P0='<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"/>',O0=[{id:"t_dc",x:50,y:10,orientation:"e"}],B0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},m_={id:N0,name:M0,category:T0,viewBox:A0,width:I0,height:C0,svg:P0,terminals:O0,source:B0},h_=Object.freeze(Object.defineProperty({__proto__:null,category:T0,default:m_,height:C0,id:N0,name:M0,source:B0,svg:P0,terminals:O0,viewBox:A0,width:I0},Symbol.toStringTag,{value:"Module"})),L0="rcd",z0="剩余电流装置 (RCD)",R0="protection",D0="不带过流保护的剩余电流断路器 (IEC 61008)。",F0="-12 -22 19 44",H0=19,W0=44,q0='<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"/>',G0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],X0=[{name:"open",type:"boolean",default:!1,label:"断开"}],Y0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],K0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},p_={id:L0,name:z0,category:R0,description:D0,viewBox:F0,width:H0,height:W0,svg:q0,terminals:G0,state:X0,params:Y0,source:K0},g_=Object.freeze(Object.defineProperty({__proto__:null,category:R0,default:p_,description:D0,height:W0,id:L0,name:z0,params:Y0,source:K0,state:X0,svg:q0,terminals:G0,viewBox:F0,width:H0},Symbol.toStringTag,{value:"Module"})),V0="recloser",U0="重合闸 (Recloser)",J0="protection",Z0="中压自动重合闸开关。",Q0="-12 -32 36 64",ep=36,tp=64,np='<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>',op=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],rp=[{name:"open",type:"boolean",default:!1,label:"断开"}],sp={kind:"inline"},y_={id:V0,name:U0,category:J0,description:Z0,viewBox:Q0,width:ep,height:tp,svg:np,terminals:op,state:rp,source:sp},x_=Object.freeze(Object.defineProperty({__proto__:null,category:J0,default:y_,description:Z0,height:tp,id:V0,name:U0,source:sp,state:rp,svg:np,terminals:op,viewBox:Q0,width:ep},Symbol.toStringTag,{value:"Module"})),ip="rectifier",ap="整流器 (AC→DC)",lp="renewable",cp="-42 -42 44 44",dp=44,up=44,fp='<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"/>',mp=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],hp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},b_={id:ip,name:ap,category:lp,viewBox:cp,width:dp,height:up,svg:fp,terminals:mp,source:hp},w_=Object.freeze(Object.defineProperty({__proto__:null,category:lp,default:b_,height:up,id:ip,name:ap,source:hp,svg:fp,terminals:mp,viewBox:cp,width:dp},Symbol.toStringTag,{value:"Module"})),pp="relay-coil",gp="继电器线圈 (KA)",yp="control",xp="继电器 / 接触器操作线圈 (方框)。",bp="-22 -22 44 44",wp=44,vp=44,kp='<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"/>',_p=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],$p={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"},v_={id:pp,name:gp,category:yp,description:xp,viewBox:bp,width:wp,height:vp,svg:kp,terminals:_p,source:$p},k_=Object.freeze(Object.defineProperty({__proto__:null,category:yp,default:v_,description:xp,height:vp,id:pp,name:gp,source:$p,svg:kp,terminals:_p,viewBox:bp,width:wp},Symbol.toStringTag,{value:"Module"})),Sp="resistor",jp="电阻 (R)",Ep="passive",Np="通用电阻 / 限流 / 制动电阻。",Mp="-6 -23 12 35",Tp=12,Ap=35,Ip='<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"/>',Cp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Pp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Op={x:6,y:0,anchor:"start"},Bp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},__={id:Sp,name:jp,category:Ep,description:Np,viewBox:Mp,width:Tp,height:Ap,svg:Ip,terminals:Cp,params:Pp,label:Op,source:Bp},$_=Object.freeze(Object.defineProperty({__proto__:null,category:Ep,default:__,description:Np,height:Ap,id:Sp,label:Op,name:jp,params:Pp,source:Bp,svg:Ip,terminals:Cp,viewBox:Mp,width:Tp},Symbol.toStringTag,{value:"Module"})),Lp="reverse-power-relay",zp="逆功率继电器 (32)",Rp="protection",Dp="逆功率 / 逆流保护继电器 (ANSI 32)。",Fp="-62 -42 64 44",Hp=64,Wp=44,qp='<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"/>',Gp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Xp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},S_={id:Lp,name:zp,category:Rp,description:Dp,viewBox:Fp,width:Hp,height:Wp,svg:qp,terminals:Gp,source:Xp},j_=Object.freeze(Object.defineProperty({__proto__:null,category:Rp,default:S_,description:Dp,height:Wp,id:Lp,name:zp,source:Xp,svg:qp,terminals:Gp,viewBox:Fp,width:Hp},Symbol.toStringTag,{value:"Module"})),Yp="selector-switch",Kp="选择开关 (SA)",Vp="switching",Up="转换 / 选择开关 (旋转操作, 保位)。",Jp="-34 -42 36 64",Zp=36,Qp=64,eg='<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"/>',tg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ng=[{name:"open",type:"boolean",default:!1,label:"断开"}],og={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"},E_={id:Yp,name:Kp,category:Vp,description:Up,viewBox:Jp,width:Zp,height:Qp,svg:eg,terminals:tg,state:ng,source:og},N_=Object.freeze(Object.defineProperty({__proto__:null,category:Vp,default:E_,description:Up,height:Qp,id:Yp,name:Kp,source:og,state:ng,svg:eg,terminals:tg,viewBox:Jp,width:Zp},Symbol.toStringTag,{value:"Module"})),rg="series-reactor",sg="串联电抗器",ig="compensation",ag="与并联电抗器同符号;通过用法区分。",lg="-62 -82 64 104",cg=64,dg=104,ug='<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"/>',fg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],mg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},M_={id:rg,name:sg,category:ig,description:ag,viewBox:lg,width:cg,height:dg,svg:ug,terminals:fg,source:mg},T_=Object.freeze(Object.defineProperty({__proto__:null,category:ig,default:M_,description:ag,height:dg,id:rg,name:sg,source:mg,svg:ug,terminals:fg,viewBox:lg,width:cg},Symbol.toStringTag,{value:"Module"})),hg="shunt-capacitor",pg="并联电容器",gg="compensation",yg="-7 -23 14 27",xg=14,bg=27,wg='<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"/>',vg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],kg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],_g={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},A_={id:hg,name:pg,category:gg,viewBox:yg,width:xg,height:bg,svg:wg,terminals:vg,params:kg,source:_g},I_=Object.freeze(Object.defineProperty({__proto__:null,category:gg,default:A_,height:bg,id:hg,name:pg,params:kg,source:_g,svg:wg,terminals:vg,viewBox:yg,width:xg},Symbol.toStringTag,{value:"Module"})),$g="shunt-reactor",Sg="并联电抗器",jg="compensation",Eg="-62 -82 64 104",Ng=64,Mg=104,Tg='<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"/>',Ag=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Ig={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:$g,name:Sg,category:jg,viewBox:Eg,width:Ng,height:Mg,svg:Tg,terminals:Ag,source:Ig},P_=Object.freeze(Object.defineProperty({__proto__:null,category:jg,default:C_,height:Mg,id:$g,name:Sg,source:Ig,svg:Tg,terminals:Ag,viewBox:Eg,width:Ng},Symbol.toStringTag,{value:"Module"})),Cg="siren",Pg="警笛 (HA)",Og="control",Bg="声响警笛 / 报警器。",Lg="-32 -42 44 54",zg=44,Rg=54,Dg='<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"/>',Fg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Hg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},O_={id:Cg,name:Pg,category:Og,description:Bg,viewBox:Lg,width:zg,height:Rg,svg:Dg,terminals:Fg,source:Hg},B_=Object.freeze(Object.defineProperty({__proto__:null,category:Og,default:O_,description:Bg,height:Rg,id:Cg,name:Pg,source:Hg,svg:Dg,terminals:Fg,viewBox:Lg,width:zg},Symbol.toStringTag,{value:"Module"})),Wg="socket-outlet",qg="插座 / 连接器",Gg="load",Xg="电源插座 / 多极连接器。",Yg="-7 -2 13 34",Kg=13,Vg=34,Ug='<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"/>',Jg=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Zg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
197
|
+
unifilar`},L_={id:Wg,name:qg,category:Gg,description:Xg,viewBox:Yg,width:Kg,height:Vg,svg:Ug,terminals:Jg,source:Zg},z_=Object.freeze(Object.defineProperty({__proto__:null,category:Gg,default:L_,description:Xg,height:Vg,id:Wg,name:qg,source:Zg,svg:Ug,terminals:Jg,viewBox:Yg,width:Kg},Symbol.toStringTag,{value:"Module"})),Qg="soft-starter",e1="软启动器",t1="motor-control",n1="电机软启动器 (晶闸管降压启动)。",o1="-22 -42 44 84",r1=44,s1=84,i1='<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"/>',a1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],l1={kind:"inline"},R_={id:Qg,name:e1,category:t1,description:n1,viewBox:o1,width:r1,height:s1,svg:i1,terminals:a1,source:l1},D_=Object.freeze(Object.defineProperty({__proto__:null,category:t1,default:R_,description:n1,height:s1,id:Qg,name:e1,source:l1,svg:i1,terminals:a1,viewBox:o1,width:r1},Symbol.toStringTag,{value:"Module"})),c1="sync-motor",d1="同步电动机",u1="load",f1="-62 -82 64 114",m1=64,h1=114,p1='<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"/>',g1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],y1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},F_={id:c1,name:d1,category:u1,viewBox:f1,width:m1,height:h1,svg:p1,terminals:g1,source:y1},H_=Object.freeze(Object.defineProperty({__proto__:null,category:u1,default:F_,height:h1,id:c1,name:d1,source:y1,svg:p1,terminals:g1,viewBox:f1,width:m1},Symbol.toStringTag,{value:"Module"})),x1="synchronoscope",b1="同步表",w1="measurement",v1="同步指示器 / 同步表。",k1="-22 -42 44 44",_1=44,$1=44,S1='<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"/>',j1=[{id:"t_top",x:0,y:-40,orientation:"n"}],E1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},W_={id:x1,name:b1,category:w1,description:v1,viewBox:k1,width:_1,height:$1,svg:S1,terminals:j1,source:E1},q_=Object.freeze(Object.defineProperty({__proto__:null,category:w1,default:W_,description:v1,height:$1,id:x1,name:b1,source:E1,svg:S1,terminals:j1,viewBox:k1,width:_1},Symbol.toStringTag,{value:"Module"})),N1="terminal",M1="接线端子 / 节点 (X)",T1="busbar",A1="接线端子 / 接线盒 / 汇接节点。",I1="-5 -5 10 10",C1=10,P1=10,O1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',B1=[{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"}],L1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},G_={id:N1,name:M1,category:T1,description:A1,viewBox:I1,width:C1,height:P1,svg:O1,terminals:B1,source:L1},X_=Object.freeze(Object.defineProperty({__proto__:null,category:T1,default:G_,description:A1,height:P1,id:N1,name:M1,source:L1,svg:O1,terminals:B1,viewBox:I1,width:C1},Symbol.toStringTag,{value:"Module"})),z1="thermal-overload",R1="热过载继电器",D1="motor-control",F1="电机热过载保护继电器, 通常串接在接触器和电机之间。",H1="-9 -32 19 64",W1=19,q1=64,G1='<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"/>',X1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Y1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],K1={kind:"inline"},Y_={id:z1,name:R1,category:D1,description:F1,viewBox:H1,width:W1,height:q1,svg:G1,terminals:X1,state:Y1,source:K1},K_=Object.freeze(Object.defineProperty({__proto__:null,category:D1,default:Y_,description:F1,height:q1,id:z1,name:R1,source:K1,state:Y1,svg:G1,terminals:X1,viewBox:H1,width:W1},Symbol.toStringTag,{value:"Module"})),V1="thermocouple",U1="热电偶 (BT)",J1="measurement",Z1="热电偶温度传感器。",Q1="-26 -42 52 46",ey=52,ty=46,ny='<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"/>',oy=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],ry={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},V_={id:V1,name:U1,category:J1,description:Z1,viewBox:Q1,width:ey,height:ty,svg:ny,terminals:oy,source:ry},U_=Object.freeze(Object.defineProperty({__proto__:null,category:J1,default:V_,description:Z1,height:ty,id:V1,name:U1,source:ry,svg:ny,terminals:oy,viewBox:Q1,width:ey},Symbol.toStringTag,{value:"Module"})),sy="thyristor",iy="晶闸管 (V)",ay="passive",ly="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",cy="-22 -42 34 44",dy=34,uy=44,fy='<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"/>',my=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],hy={x:6,y:-20,anchor:"start"},py={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)"},J_={id:sy,name:iy,category:ay,description:ly,viewBox:cy,width:dy,height:uy,svg:fy,terminals:my,label:hy,source:py},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:ay,default:J_,description:ly,height:uy,id:sy,label:hy,name:iy,source:py,svg:fy,terminals:my,viewBox:cy,width:dy},Symbol.toStringTag,{value:"Module"})),gy="time-relay",yy="时间继电器 (KT)",xy="control",by="延时 (缓动) 继电器线圈。",wy="-32 -22 54 44",vy=54,ky=44,_y='<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"/>',$y=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Sy={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"},Q_={id:gy,name:yy,category:xy,description:by,viewBox:wy,width:vy,height:ky,svg:_y,terminals:$y,source:Sy},e$=Object.freeze(Object.defineProperty({__proto__:null,category:xy,default:Q_,description:by,height:ky,id:gy,name:yy,source:Sy,svg:_y,terminals:$y,viewBox:wy,width:vy},Symbol.toStringTag,{value:"Module"})),jy="transfer-switch",Ey="切换开关 (ATS)",Ny="switching",My="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Ty="-27 -32 51 64",Ay=51,Iy=64,Cy='<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"/>',Py=[{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"}],Oy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],By={kind:"inline"},t$={id:jy,name:Ey,category:Ny,description:My,viewBox:Ty,width:Ay,height:Iy,svg:Cy,terminals:Py,state:Oy,source:By},n$=Object.freeze(Object.defineProperty({__proto__:null,category:Ny,default:t$,description:My,height:Iy,id:jy,name:Ey,source:By,state:Oy,svg:Cy,terminals:Py,viewBox:Ty,width:Ay},Symbol.toStringTag,{value:"Module"})),Ly="transformer-2w",zy="双绕组变压器",Ry="transformer",Dy="-62 -142 64 144",Fy=64,Hy=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"/>',qy=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Gy=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],Xy={x:4,y:-68,anchor:"start"},Yy={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"},o$={id:Ly,name:zy,category:Ry,viewBox:Dy,width:Fy,height:Hy,svg:Wy,terminals:qy,params:Gy,label:Xy,source:Yy},r$=Object.freeze(Object.defineProperty({__proto__:null,category:Ry,default:o$,height:Hy,id:Ly,label:Xy,name:zy,params:Gy,source:Yy,svg:Wy,terminals:qy,viewBox:Dy,width:Fy},Symbol.toStringTag,{value:"Module"})),Ky="transformer-3w",Vy="三绕组变压器",Uy="transformer",Jy="-82 -131 114 133",Zy=114,Qy=133,ex='<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"/>',tx=[{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"}],nx={x:4,y:-64,anchor:"start"},ox={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"},s$={id:Ky,name:Vy,category:Uy,viewBox:Jy,width:Zy,height:Qy,svg:ex,terminals:tx,label:nx,source:ox},i$=Object.freeze(Object.defineProperty({__proto__:null,category:Uy,default:s$,height:Qy,id:Ky,label:nx,name:Vy,source:ox,svg:ex,terminals:tx,viewBox:Jy,width:Zy},Symbol.toStringTag,{value:"Module"})),rx="triac",sx="双向晶闸管 (V)",ix="passive",ax="双向三极晶闸管 (TRIAC)。",lx="-22 -42 44 44",cx=44,dx=44,ux='<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"/>',fx=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],mx={x:6,y:-20,anchor:"start"},hx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},a$={id:rx,name:sx,category:ix,description:ax,viewBox:lx,width:cx,height:dx,svg:ux,terminals:fx,label:mx,source:hx},l$=Object.freeze(Object.defineProperty({__proto__:null,category:ix,default:a$,description:ax,height:dx,id:rx,label:mx,name:sx,source:hx,svg:ux,terminals:fx,viewBox:lx,width:cx},Symbol.toStringTag,{value:"Module"})),px="undervoltage-relay",gx="欠压继电器 (27)",yx="protection",xx="欠电压保护继电器 (ANSI 27)。",bx="-62 -82 64 84",wx=64,vx=84,kx='<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>',_x=[{id:"t_top",x:-30,y:-80,orientation:"n"}],$x={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},c$={id:px,name:gx,category:yx,description:xx,viewBox:bx,width:wx,height:vx,svg:kx,terminals:_x,source:$x},d$=Object.freeze(Object.defineProperty({__proto__:null,category:yx,default:c$,description:xx,height:vx,id:px,name:gx,source:$x,svg:kx,terminals:_x,viewBox:bx,width:wx},Symbol.toStringTag,{value:"Module"})),Sx="ups",jx="不间断电源 (UPS)",Ex="source",Nx="在线 / 后备式不间断电源。",Mx="-26 -42 52 84",Tx=52,Ax=84,Ix='<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"/>',Cx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Px=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Ox={kind:"inline"},u$={id:Sx,name:jx,category:Ex,description:Nx,viewBox:Mx,width:Tx,height:Ax,svg:Ix,terminals:Cx,params:Px,source:Ox},f$=Object.freeze(Object.defineProperty({__proto__:null,category:Ex,default:u$,description:Nx,height:Ax,id:Sx,name:jx,params:Px,source:Ox,svg:Ix,terminals:Cx,viewBox:Mx,width:Tx},Symbol.toStringTag,{value:"Module"})),Bx="varmeter",Lx="无功功率表 (var)",zx="measurement",Rx="无功功率表 (var)。",Dx="-22 -42 44 44",Fx=44,Hx=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>',qx=[{id:"t_top",x:0,y:-40,orientation:"n"}],Gx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},m$={id:Bx,name:Lx,category:zx,description:Rx,viewBox:Dx,width:Fx,height:Hx,svg:Wx,terminals:qx,source:Gx},h$=Object.freeze(Object.defineProperty({__proto__:null,category:zx,default:m$,description:Rx,height:Hx,id:Bx,name:Lx,source:Gx,svg:Wx,terminals:qx,viewBox:Dx,width:Fx},Symbol.toStringTag,{value:"Module"})),Xx="vfd",Yx="变频器 (VFD)",Kx="motor-control",Vx="Variable Frequency Drive — 异步电动机调速。",Ux="-24 -42 48 84",Jx=48,Zx=84,Qx='<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"/>',eb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],tb={kind:"inline"},p$={id:Xx,name:Yx,category:Kx,description:Vx,viewBox:Ux,width:Jx,height:Zx,svg:Qx,terminals:eb,source:tb},g$=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:p$,description:Vx,height:Zx,id:Xx,name:Yx,source:tb,svg:Qx,terminals:eb,viewBox:Ux,width:Jx},Symbol.toStringTag,{value:"Module"})),nb="voltage-regulator",ob="调压器 (T)",rb="transformer",sb="可调感应调压器 / 自耦调压器。",ib="-17 -32 38 64",ab=38,lb=64,cb='<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"/>',db=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ub=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],fb={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},y$={id:nb,name:ob,category:rb,description:sb,viewBox:ib,width:ab,height:lb,svg:cb,terminals:db,params:ub,source:fb},x$=Object.freeze(Object.defineProperty({__proto__:null,category:rb,default:y$,description:sb,height:lb,id:nb,name:ob,params:ub,source:fb,svg:cb,terminals:db,viewBox:ib,width:ab},Symbol.toStringTag,{value:"Module"})),mb="voltmeter",hb="电压表 (V)",pb="measurement",gb="-22 -42 44 44",yb=44,xb=44,bb='<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>',wb=[{id:"t_top",x:0,y:-40,orientation:"n"}],vb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},b$={id:mb,name:hb,category:pb,viewBox:gb,width:yb,height:xb,svg:bb,terminals:wb,source:vb},w$=Object.freeze(Object.defineProperty({__proto__:null,category:pb,default:b$,height:xb,id:mb,name:hb,source:vb,svg:bb,terminals:wb,viewBox:gb,width:yb},Symbol.toStringTag,{value:"Module"})),kb="wattmeter",_b="功率表 (W)",$b="measurement",Sb="-22 -42 44 44",jb=44,Eb=44,Nb='<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>',Mb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Tb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},v$={id:kb,name:_b,category:$b,viewBox:Sb,width:jb,height:Eb,svg:Nb,terminals:Mb,source:Tb},k$=Object.freeze(Object.defineProperty({__proto__:null,category:$b,default:v$,height:Eb,id:kb,name:_b,source:Tb,svg:Nb,terminals:Mb,viewBox:Sb,width:jb},Symbol.toStringTag,{value:"Module"})),Ab="wind-turbine",Ib="风力发电机",Cb="renewable",Pb="风机:发电机 + 三叶轮标记",Ob="-22 -46 44 68",Bb=44,Lb=68,zb='<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"/>',Rb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Db={kind:"inline"},_$={id:Ab,name:Ib,category:Cb,description:Pb,viewBox:Ob,width:Bb,height:Lb,svg:zb,terminals:Rb,source:Db},$$=Object.freeze(Object.defineProperty({__proto__:null,category:Cb,default:_$,description:Pb,height:Lb,id:Ab,name:Ib,source:Db,svg:zb,terminals:Rb,viewBox:Ob,width:Bb},Symbol.toStringTag,{value:"Module"})),Fb="zener-diode",Hb="稳压二极管 (D)",Wb="passive",qb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",Gb="-12 -42 24 44",Xb=24,Yb=44,Kb='<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"/>',Vb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ub={x:6,y:-20,anchor:"start"},Jb={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"},S$={id:Fb,name:Hb,category:Wb,description:qb,viewBox:Gb,width:Xb,height:Yb,svg:Kb,terminals:Vb,label:Ub,source:Jb},j$=Object.freeze(Object.defineProperty({__proto__:null,category:Wb,default:S$,description:qb,height:Yb,id:Fb,label:Ub,name:Hb,source:Jb,svg:Kb,terminals:Vb,viewBox:Gb,width:Xb},Symbol.toStringTag,{value:"Module"})),E$=Object.assign({"./ammeter.json":h2,"./arc-suppression-coil.json":g2,"./arrester.json":x2,"./async-motor.json":w2,"./autotransformer.json":k2,"./battery.json":$2,"./bell.json":j2,"./break-contact.json":N2,"./breaker.json":T2,"./buchholz-relay.json":I2,"./busbar.json":P2,"./buzzer.json":B2,"./capacitor.json":z2,"./contactor.json":D2,"./converter-bidir.json":H2,"./ct.json":q2,"./dc-combiner.json":X2,"./dc-disconnector.json":K2,"./dc-motor.json":U2,"./diode.json":Z2,"./disconnector.json":ek,"./distance-relay.json":nk,"./earth.json":rk,"./earthing-switch.json":ik,"./energy-meter.json":lk,"./ev-charger.json":dk,"./frequency-meter.json":fk,"./fuse-switch-disconnector.json":hk,"./fuse.json":gk,"./generator.json":xk,"./genset.json":wk,"./gfci-breaker.json":kk,"./grid-source.json":$k,"./grounding-transformer.json":jk,"./heater.json":Nk,"./igbt.json":Tk,"./indicator-light.json":Ik,"./inductor.json":Pk,"./inverter.json":Bk,"./limit-switch.json":zk,"./load-switch.json":Dk,"./load.json":Hk,"./make-contact.json":qk,"./motor-starter.json":Xk,"./ngr.json":Kk,"./overcurrent-relay.json":Uk,"./phase-failure-relay.json":Zk,"./plc.json":e_,"./power-factor-meter.json":n_,"./power-supply.json":r_,"./protective-relay.json":i_,"./proximity-switch.json":l_,"./pt.json":d_,"./push-button.json":f_,"./pv.json":h_,"./rcd.json":g_,"./recloser.json":x_,"./rectifier.json":w_,"./relay-coil.json":k_,"./resistor.json":$_,"./reverse-power-relay.json":j_,"./selector-switch.json":N_,"./series-reactor.json":T_,"./shunt-capacitor.json":I_,"./shunt-reactor.json":P_,"./siren.json":B_,"./socket-outlet.json":z_,"./soft-starter.json":D_,"./sync-motor.json":H_,"./synchronoscope.json":q_,"./terminal.json":X_,"./thermal-overload.json":K_,"./thermocouple.json":U_,"./thyristor.json":Z_,"./time-relay.json":e$,"./transfer-switch.json":n$,"./transformer-2w.json":r$,"./transformer-3w.json":i$,"./triac.json":l$,"./undervoltage-relay.json":d$,"./ups.json":f$,"./varmeter.json":h$,"./vfd.json":g$,"./voltage-regulator.json":x$,"./voltmeter.json":w$,"./wattmeter.json":k$,"./wind-turbine.json":$$,"./zener-diode.json":j$}),Zb=Object.values(E$).map(e=>e.default),Ke=Object.fromEntries(Zb.map(e=>[e.id,e])),Xo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],N$=(()=>{var t;const e={};for(const n of Zb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),Bn=new Map(Object.entries(Ke));function Qb(e){return Ke[e]}function M$(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 T$=320;function Ge(e){var h,g,b,$,k;const t=is(),n=new Map;e.elements.forEach((w,M)=>{if(n.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/elements/${M}`});return}n.set(w.id,w);const B=Bn.get(w.kind);B||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:w.kind})} (id=${w.id})`,pointer:`/elements/${M}`}),t.elements.set(w.id,{element:w,libraryDef:B})});const o=new Map,r=new Map;(e.buses??[]).forEach((w,M)=>{if(n.has(w.id)||o.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/buses/${M}`});return}if(o.set(w.id,w),w.layout){const B=w.layout.rot??0;r.set(w.id,{at:w.layout.at,span:w.layout.span,rot:B,axis:Pn(B)})}});const s=new Map;(e.junctions??[]).forEach((w,M)=>{if(n.has(w.id)||o.has(w.id)||s.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/junctions/${M}`});return}s.set(w.id,w)});const i=w=>!w.includes(".")&&o.has(w),a=w=>!w.includes(".")&&s.has(w),l=(w,M)=>{if(i(w)||a(w))return!0;const B=w.indexOf(".");if(B<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:w}),pointer:M}),!1;const D=w.slice(0,B),V=w.slice(B+1),J=t.elements.get(D);if(!J)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:D}),pointer:M}),!1;if(!J.libraryDef)return!1;if(!J.libraryDef.terminals.find(ne=>ne.id===V)){const ne=J.libraryDef.terminals.map(G=>G.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:D,kind:J.element.kind,pin:V,available:ne}),pointer:M}),!1}return!0},c=[];(e.wires??[]).forEach((w,M)=>{const B=`/wires/${M}`,D=l(w.ends[0],B),V=l(w.ends[1],B);D&&V&&c.push(w)});const f=new Map;if(e.layout)for(const[w,M]of Object.entries(e.layout))t.elements.has(w)?f.set(w,as(M)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:w}),pointer:`/layout/${w}`});const u=u2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:Bn,userLayout:f,userBusLayout:r});t.layout=u.devices;for(const[w,M]of u.buses){const B=o.get(w);B&&t.buses.set(w,{bus:B,geometry:M})}for(const[w,M]of o)t.buses.has(w)||t.buses.set(w,{bus:M,geometry:{at:((h=M.layout)==null?void 0:h.at)??[0,0],span:((g=M.layout)==null?void 0:g.span)??T$,rot:((b=M.layout)==null?void 0:b.rot)??0,axis:Pn((($=M.layout)==null?void 0:$.rot)??0)}});for(const w of t.elements.values()){if(!w.libraryDef)continue;const M=t.layout.get(w.element.id);if(!M)continue;const B=[];for(const D of w.libraryDef.terminals){const V=`${w.element.id}.${D.id}`,J=Pe([D.x,D.y],M),ne=$t(D.orientation,M);t.terminals.set(V,{ref:V,elementId:w.element.id,pin:D.id,world:J,orientation:ne}),B.push(V)}t.elementToTerminals.set(w.element.id,B)}const m=w=>{if(!w.includes(".")){const B=t.buses.get(w);return B?B.geometry.at:null}const M=t.terminals.get(w);return M?M.world:null};for(const[w,M]of s){let B;if((k=M.layout)!=null&&k.at)B=[M.layout.at[0],M.layout.at[1]];else if(u.junctions.has(w))B=u.junctions.get(w);else{const D=[];for(const V of c){const[J,ne]=V.ends,G=J===w?ne:ne===w?J:null;if(G===null)continue;const P=m(G);P&&D.push(P)}B=D.length?[D.reduce((V,J)=>V+J[0],0)/D.length,D.reduce((V,J)=>V+J[1],0)/D.length]:[0,0]}t.junctions.set(w,{junction:M,world:B})}const p=new ls;for(const w of c)p.add(w.ends[0]),p.add(w.ends[1]),p.union(w.ends[0],w.ends[1]);for(const[,w]of p.groups()){const M=M$(w);t.nodes.set(M,{id:M,terminals:w});for(const B of w)t.terminalToNode.set(B,M)}for(const w of t.elements.values()){const M=t.elementToTerminals.get(w.element.id)??[];if(M.length===0)continue;M.some(D=>t.terminalToNode.has(D))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w.element.id})})}for(const w of t.buses.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of t.junctions.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of c){if(w.path&&w.path.length>=2){const B=w.path,D=B.length>=2?B[1]:null,V=B.length>=2?B[B.length-2]:null,J=qo(w.ends[0],D,t),ne=qo(w.ends[1],V,t);if(J&&ne){const G=[[J[0],J[1]],...B.slice(1,-1).map(F=>[F[0],F[1]]),[ne[0],ne[1]]],P=ss(G);if(P.length>=2){t.wireRenders.set(w.id,{wireId:w.id,path:P,userEdited:!0});continue}}}const M=f2(w,t);M&&t.wireRenders.set(w.id,M)}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"},Yo="B",Ko="J";function eo(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Mt(e,t){const n=A$[t]??t,o=eo(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Ln(e){const t=eo(e);let n=1;for(;t.has(`${Yo}${n}`);)n++;return`${Yo}${n}`}function zn(e){const t=eo(e);let n=1;for(;t.has(`${Ko}${n}`);)n++;return`${Ko}${n}`}function I$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Je(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)}`}function wn(e,t,n){if(n.length===0)return n;const o=new Set(n.map(a=>a.id)),r=new Set(t.map(a=>a.id)),s=new Set;for(const a of e)if(!r.has(a.id))for(const l of a.ends)o.has(l)&&s.add(l);if(s.size===0)return n;const i=new Set;for(const a of t)for(const l of a.ends)s.has(l)&&i.add(l);return n.filter(a=>!s.has(a.id)||i.has(a.id))}const Vo={version:"1",elements:[]},C$=100,Uo=20;function P$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=en()(r2((e,t)=>({diagram:Vo,internal:Ge(Vo),fileSession:null,activeTool:P$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom: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:Ge(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:Ge(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,wireDragFrom: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:Ge(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:Ge(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom: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:Ge(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom: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,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:O$(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(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>s.has(p.id)).map(p=>{var g;const h=structuredClone(p);if(!h.layout){const b=(g=r.junctions.get(p.id))==null?void 0:g.world;b&&(h.layout={at:[b[0],b[1]]})}return h}),c={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const h=(m=o.layout)==null?void 0:m[p];if(h){c[p]=structuredClone(h);continue}const g=r.layout.get(p);g&&(c[p]=zt(g))}const f={};for(const p of n){const h=r.buses.get(p);h&&(f[p]=tt(h.geometry))}const u=(o.wires??[]).filter(p=>p.ends.every(h=>s.has(vn(h)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,junctions:l,placements:c,busLayouts:f,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&&n.junctions.length===0)return;const s=o+1,i=Uo*s,a=Uo*s,l=new Map;let c=r;for(const u of n.elements){const m=Mt(c,u.kind);l.set(u.id,m),c={...c,elements:[...c.elements,{id:m,kind:u.kind}]}}for(const u of n.buses){const m=Ln(c);l.set(u.id,m),c={...c,buses:[...c.buses??[],{id:m}]}}for(const u of n.junctions){const m=zn(c);l.set(u.id,m),c={...c,junctions:[...c.junctions??[],{id:m}]}}const f=u=>{const m=u.indexOf("."),p=m<0?u:u.slice(0,m),h=l.get(p);return h?m<0?h:`${h}${u.slice(m)}`:u};t().dispatch(u=>{const m=n.elements.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w}),p=n.buses.map(k=>{const w=structuredClone(k);w.id=l.get(k.id);const M=n.busLayouts[k.id];return M&&(w.layout={...M,at:[M.at[0]+i,M.at[1]+a]}),w}),h=n.junctions.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w.layout&&(w.layout={at:[w.layout.at[0]+i,w.layout.at[1]+a]}),w}),g={...u.layout??{}};for(const[k,w]of l){const M=n.placements[k];M&&(g[w]={...M,at:[M.at[0]+i,M.at[1]+a]})}const b=n.wires.map(k=>{const w=[f(k.ends[0]),f(k.ends[1])];return{id:Je(w[0],w[1]),ends:w}}),$=Jo(u.wires??[],b);return{...u,elements:[...u.elements,...m],buses:p.length?[...u.buses??[],...p]:u.buses,junctions:h.length?[...u.junctions??[],...h]:u.junctions,wires:$.length?$:void 0,layout:Object.keys(g).length?g: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(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:f,...u}=c;return u});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[c,f]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=f}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:f,...u}=c;return u}return c});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 c=n.layout.get(l.id);c&&(s[l.id]=zt(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,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 c=n.buses.get(l.id);return!l.layout&&c?{...l,layout:tt(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const f of n)if(o.buses.has(f)){const u=o.buses.get(f);(c=r.buses)!=null&&c.find(m=>m.id===f&&m.layout)||a.set(f,tt(u.geometry))}else{if(s[f])continue;const u=o.layout.get(f);u&&(i[f]=zt(u))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(f=>a.has(f.id)?{...f,layout:a.get(f.id)}:f)),{...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,a=new Map;for(const[f,u]of n){if(o.buses.has(f)){i.set(f,u);continue}if(o.junctions.has(f)){a.set(f,u);continue}const m=o.layout.get(f),p=s[f]??(m?zt(m):{at:[0,0]});s[f]={...p,at:[p.at[0]+u[0],p.at[1]+u[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(f=>{const u=i.get(f.id);if(!u)return f;const m=f.layout??tt(o.buses.get(f.id).geometry);return{...f,layout:{...m,at:[m.at[0]+u[0],m.at[1]+u[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(f=>{var p,h;const u=a.get(f.id);if(!u)return f;const m=((p=f.layout)==null?void 0:p.at)??((h=o.junctions.get(f.id))==null?void 0:h.world)??[0,0];return{...f,layout:{at:[m[0]+u[0],m[1]+u[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(u=>!o.has(u.id)),i=(r.buses??[]).filter(u=>!o.has(u.id)),a=(r.junctions??[]).filter(u=>!o.has(u.id)),l=(r.wires??[]).filter(u=>!o.has(vn(u.ends[0]))&&!o.has(vn(u.ends[1]))),c=wn(r.wires??[],l,a),f=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([u])=>!o.has(u))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:c.length?c:void 0,wires:l.length?l:void 0,layout:f&&Object.keys(f).length?f: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??[],l=a.filter(u=>u.id!==n);if(l.length===a.length)return i;const c={...i.layout??{}};for(const u of s){if(c[u])continue;const m=o.layout.get(u);if(!m)continue;const p={at:m.at};m.rot&&(p.rot=m.rot),m.mirror&&(p.mirror=m.mirror),c[u]=p}const f=wn(a,l,i.junctions??[]);return{...i,wires:l.length?l:void 0,junctions:f.length?f:void 0,layout:Object.keys(c).length?c: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 m of i){if(l[m])continue;const p=o.layout.get(m);if(!p)continue;const h={at:p.at};p.rot&&(h.rot=p.rot),p.mirror&&(h.mirror=p.mirror),l[m]=h}const c=a.wires??[],f=c.filter(m=>!s.has(m.ends[0])&&!s.has(m.ends[1])),u=wn(c,f,a.junctions??[]);return{...a,wires:f.length?f:void 0,junctions:u.length?u: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 c,f,u,m;const i={...s.layout??{}},a=new Map;for(const p of o){if(r.junctions.has(p))continue;if(r.buses.has(p)){const b=r.buses.get(p),k=(((((u=(f=(c=s.buses)==null?void 0:c.find(w=>w.id===p))==null?void 0:f.layout)==null?void 0:u.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(p,k);continue}const h=i[p]??{at:((m=r.layout.get(p))==null?void 0:m.at)??[0,0]},g=(((h.rot??0)+n)%360+360)%360;i[p]={...h,rot:g}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??tt(r.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.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)||o.junctions.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=Mt(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=Ln(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},addJunction:n=>{const o=zn(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=Je(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]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(h=>h.id),...(s.buses??[]).map(h=>h.id),...(s.junctions??[]).map(h=>h.id)]),a=()=>{let h=1;for(;i.has(`J${h}`);)h++;const g=`J${h}`;return i.add(g),g},l=h=>{const g=a();return s={...s,junctions:[...s.junctions??[],{id:g,layout:{at:h}}]},g},c=h=>{if("end"in h)return h.end;if("junctionAt"in h)return l(h.junctionAt);const g=(s.wires??[]).find(w=>w.id===h.onWire),b=l(h.at);if(!g)return b;const $=(s.wires??[]).filter(w=>w.id!==h.onWire),k=(w,M)=>({id:Je(w,M),ends:[w,M]});return s={...s,wires:Jo($,[k(g.ends[0],b),k(b,g.ends[1])])},b},f=c(n),u=c(o);if(f===null||u===null||f===u)return s;const m=Je(f,u),p=s.wires??[];return p.some(h=>h.id===m)?s:{...s,wires:[...p,{id:m,ends:[f,u]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?ss(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:f,...u}=c;return u});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)?tt(a.buses.get(n).geometry):{at:[0,0],span:320}),c={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:c}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=I$(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:rs(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=Ge(e.diagram))}}));function O$(e){return Array.from(new Set(e))}function vn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function Jo(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 zt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function tt(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let ew=null;function Zo(e){ew=e}function Ze(){return ew}const Yt=10;function tw(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function fe(e){return tw()?Math.round(e/Yt)*Yt:e}const B$=30,L$=144;function nw(e,t){const n=Ke[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=z$(r,t);if(!s){const g=ow(n),b=g?[fe(t[0])-g.x,fe(t[1])-g.y]:[fe(t[0]),fe(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=R$(n,l),f=Mt(r,e),u=n.terminals.find(g=>g.id===c),m=l==="x"?t[0]:a[0],p=l==="y"?t[1]:a[1],h=u?[fe(m)-u.x,fe(p)-u.y]:[fe(t[0]),fe(t[1])];return o.dispatch(g=>{const b={id:f,kind:e},$={at:h},k=`${f}.${c}`,w={id:Je(i,k),ends:[i,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],w],layout:{...g.layout??{},[f]:$}}}),o.setSelection([f]),{newElementId:f,attachedToBus:!0}}function z$(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 c;if(i==="x"){const f=a[0]-l/2,u=a[0]+l/2,m=t[0]<f?f-t[0]:t[0]>u?t[0]-u:0,p=Math.abs(t[1]-a[1]);c=Math.sqrt(m*m+p*p)}else{const f=a[1]-l/2,u=a[1]+l/2,m=t[1]<f?f-t[1]:t[1]>u?t[1]-u:0,p=Math.abs(t[0]-a[0]);c=Math.sqrt(p*p+m*m)}c<=B$&&(!o||c<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function R$(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 ow(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function rw(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 p=i[0]-a/2,h=i[0]+a/2,g=Math.max(p,Math.min(h,t[0])),b=i[1],$=t[1]>=b?"s":"n";return{ref:e,world:[g,b],orientation:$,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,f=Math.max(l,Math.min(c,t[1])),u=i[0],m=t[0]>=u?"e":"w";return{ref:e,world:[u,f],orientation:m,isBus:!0,busId:e}}if(!e.includes(".")&&n.junctions.has(e)){const r=n.junctions.get(e),[s,i]=r.world,a=t[0]-s,l=t[1]-i,c=Math.abs(a)>=Math.abs(l)?a>=0?"e":"w":l>=0?"s":"n";return{ref:e,world:[s,i],orientation:c,isBus:!1}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const D$={n:"s",s:"n",e:"w",w:"e"};function sw(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=D$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Qo(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],f=Qo(c,n,t.world);f<a&&(a=f,i=c)}return i}function Qo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function F$(e,t,n){const o=Ke[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=rw(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=L$,f=[fe(n[0]),fe(n[1])],u=sw(o,i,f),m=c?i.world:f,p=[fe(m[0]-u.x),fe(m[1]-u.y)],h=Mt(s,e);return r.dispatch(g=>{const b={id:h,kind:e},$={at:p},k=`${h}.${u.id}`,w=i.isBus&&i.busId?i.busId:t,M={id:Je(w,k),ends:[w,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],M],layout:{...g.layout??{},[h]:$}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const tn=9,Kt=7;function nn(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 on(e){const t=H$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function rn(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 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 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 d.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var f;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??on(r.libraryDef),a=rn(i,s),l=i.anchor??"start";if(o===r.element.id)return d.jsx(q$,{elementId:r.element.id,currentName:((f=r.element.name)==null?void 0:f.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const c=nn(r,n);return c.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:c.map((u,m)=>d.jsx("text",{x:0,y:m*tn,textAnchor:l,className:"ole-annotation-text",children:u},m))},r.element.id)})})}const kn=200,_n=9;function q$({elementId:e,currentName:t,world:n,anchor:o}){const r=O.useRef(null);O.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(c)},[e]);function s(){var m;const l=x.getState(),c=l.diagram.elements.find(p=>p.id===e);if(!c){l.setEditingElement(null);return}const f=(((m=r.current)==null?void 0:m.innerText)??"").replace(/\u00a0/g," ").trim(),u=f===""||f===e?void 0:f;u!==c.name&&l.updateElement(e,{name:u}),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-=kn/2:o==="end"&&(a-=kn),d.jsx("foreignObject",{x:a,y:n[1]-_n,width:kn,height:_n*2.2,className:"ole-element-name-editor",children:d.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${_n}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 iw=8,Vt=1.25;function G$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?d.jsx(Y$,{ann:o},o.id):d.jsx(X$,{ann:o,isSelected:t===o.id},o.id))})}function X$({ann:e,isSelected:t}){const n=e.fontSize??iw,o=e.text===""?[""]:e.text.split(`
|
|
198
|
+
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Vt;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[d.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&&d.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)=>d.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Vt,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function Y$({ann:e}){const t=O.useRef(null),n=e.fontSize??iw;O.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)},[e.id]);function o(){var c;const a=x.getState(),l=(((c=t.current)==null?void 0:c.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 d.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:d.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:Vt,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*Vt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const K$=20;function V$(){const e=x(f=>f.selection),t=x(f=>f.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],c=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(er,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(er,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function er({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=O.useRef(null),a=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!s))return;const u=x.getState().internal.buses.get(n);u&&(i.current={pointerId:f.pointerId,startSpan:u.geometry.span,startAt:[...u.geometry.at],startSvg:s.screenToSvg(f.clientX,f.clientY)},f.target.setPointerCapture(f.pointerId))},l=f=>{const u=i.current;if(!u||f.pointerId!==u.pointerId||!s)return;const m=s.screenToSvg(f.clientX,f.clientY),p=r==="x"?m[0]-u.startSvg[0]:m[1]-u.startSvg[1],h=tw()?Math.round(p/Yt)*Yt:p,g=u.startSpan+(o==="end"?h:-h);if(g<K$)return;const b=r==="x"?[u.startAt[0]+h/2,u.startAt[1]]:[u.startAt[0],u.startAt[1]+h/2];x.getState().updateBus(n,{span:g,at:b})},c=f=>{const u=i.current;!u||f.pointerId!==u.pointerId||(f.target.hasPointerCapture(f.pointerId)&&f.target.releasePointerCapture(f.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const Rn=.5;function St(e,t){return Math.abs(e[1]-t[1])<Rn?"h":"v"}function U$(){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=St(o[a-1],o[a]),c=St(o[a],o[a+1]),f=a-1===0,u=a+1===r-1,m=f&&l==="v"||u&&c==="v",p=f&&l==="h"||u&&c==="h";m&&p||s.push(d.jsx(J$,{wireId:e,index:a,xLocked:m,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<Rn&&Math.abs(l[1]-c[1])<Rn||i.push(d.jsx(Z$,{wireId:e,segIndex:a,axis:St(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function J$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=O.useRef(null),i=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",f=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!r))return;const g=x.getState().internal.wireRenders.get(e);g&&(s.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:r.screenToSvg(h.clientX,h.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,h.target.setPointerCapture(h.pointerId))},u=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId||!r)return;const b=r.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.index;if(k<=0||k>=$.length-1)return;const w=$[k],M=[g.xLocked?w[0]:fe(w[0]+(b[0]-g.startSvg[0])),g.yLocked?w[1]:fe(w[1]+(b[1]-g.startSvg[1]))];if(M[0]===w[0]&&M[1]===w[1])return;const B=$.map(J=>[J[0],J[1]]);B[k]=M;const D=St($[k-1],$[k]);k-1>0&&(D==="h"?B[k-1]=[$[k-1][0],M[1]]:B[k-1]=[M[0],$[k-1][1]]);const V=St($[k],$[k+1]);k+1<$.length-1&&(V==="h"?B[k+1]=[$[k+1][0],M[1]]:B[k+1]=[M[0],$[k+1][1]]),x.getState().updateWirePath(e,B)},m=h=>{const g=s.current;!g||h.pointerId!==g.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),s.current=null,document.body.style.cursor="")},p=h=>{h.stopPropagation(),h.preventDefault();const g=x.getState().internal.wireRenders.get(e);if(!g||g.path.length<=2||t<=0||t>=g.path.length-1)return;const b=g.path.filter(($,k)=>k!==t);x.getState().updateWirePath(e,b)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:f,onPointerMove:u,onPointerUp:m,onPointerCancel:m,onDoubleClick:p})}function Z$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=O.useRef(null),s=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.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,c=(i[1]+a[1])/2,f=n==="h"?"ns-resize":"ew-resize",u=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!o))return;const g=x.getState().internal.wireRenders.get(e);g&&(r.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:o.screenToSvg(h.clientX,h.clientY),axis:n,segIndex:t},document.body.style.cursor=f,h.currentTarget.setPointerCapture(h.pointerId))},m=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId||!o)return;const b=o.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.segIndex;if(k>=$.length-1)return;const w=$[k],M=$[k+1],B=[];for(let D=0;D<=k;D++)B.push($[D]);if(g.axis==="h"){const D=fe(w[1]+(b[1]-g.startSvg[1]));B.push([w[0],D]),B.push([M[0],D])}else{const D=fe(w[0]+(b[0]-g.startSvg[0]));B.push([D,w[1]]),B.push([D,M[1]])}for(let D=k+1;D<$.length;D++)B.push($[D]);x.getState().updateWirePath(e,B)},p=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId)return;const b=h.currentTarget;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:f},onPointerDown:u,onPointerMove:m,onPointerUp:p,onPointerCancel:p,children:[d.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:c,r:8}),d.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:c,r:3.5})]})}const Q$=3,$n=12;function eS(){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(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:f,span:u}=l,m=u/2,p=c==="x"?f[0]-m:f[0],h=c==="x"?f[1]:f[1]-m,g=c==="x"?f[0]+m:f[0],b=c==="x"?f[1]:f[1]+m,$=s.has(a.id),k=i.has(a.id),w=r.get(a.id)??void 0,M=$n/2,B=c==="x"?f[0]-m:f[0]-M,D=c==="x"?f[1]-M:f[1]-m,V=c==="x"?u:$n,J=c==="x"?$n:u;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":w,"data-selected":$?"true":void 0,"data-node-related":k?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:B,y:D,width:V,height:J,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:b,stroke:"currentColor",strokeWidth:Q$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function tS(){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 d.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[d.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),d.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),d.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const nS=4,oS=9,rS=13,sS=-13,iS=4.5,aS=8;function lS(){const e=x(a=>a.internal.junctions),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)i.add(l)}return d.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l})=>{const c=r.get(a.id)??void 0,f=t.length===1&&t[0]===a.id,u=l[0]+rS,m=l[1]+sS;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":c,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[d.jsx("circle",{cx:l[0],cy:l[1],r:oS,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:nS,className:"ole-junction-dot"}),f&&d.jsxs("g",{className:"ole-junction-wire-handle-group",children:[d.jsx("line",{x1:l[0],y1:l[1],x2:u,y2:m,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:u,cy:m,r:aS,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:u,cy:m,r:iS,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function Ye(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 cS(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 dS({lib:e}){const t=cS(e.viewBox);return t?d.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function uS(){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 c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.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 c=s.has(a.element.id),f=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":f?"true":void 0,transform:Ye(l),className:"ole-element",children:[d.jsx(dS,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":f?"true":void 0,transform:Ye(l),className:"ole-element ole-element--unknown",children:[d.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),d.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let aw=null;const Dn=new Set;function Rt(e){aw=e;for(const t of Dn)t(e)}function fS(){return aw}function mS(e){return Dn.add(e),()=>{Dn.delete(e)}}function hS(){const[e,t]=O.useState(fS());return O.useEffect(()=>mS(t),[]),!e||e.w===0&&e.h===0?null:d.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function pS(){const e=x(c=>c.activeTool),t=x(c=>c.placeKind),n=x(c=>c.cursorSvg),o=x(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Qb(t);if(!r)return null;let s=null,i=null;if(o){const c=rw(o,n);c&&(s=sw(r,c,n),i={source:c.world,pin:n})}else s=ow(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return d.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),d.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),d.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:d.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function gS(){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:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:f,span:u}=s.geometry,m=u/2,p=c==="x"?f[0]-m:f[0]-4,h=c==="x"?f[1]-4:f[1]-m,g=c==="x"?u:8,b=c==="x"?8:u;return d.jsx("rect",{x:p,y:h,width:g,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=yS(i.libraryDef.viewBox);return l?d.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ye(a)},r):null})})}function yS(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 xS(){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 d.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,c=r.has(s.elementId);return d.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":c?"true":void 0,className:"ole-terminal"},s.ref)})})}const tr=4;function bS(e,t,n,o){const r=t[0]-e[0],s=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=r*a-s*i;if(Math.abs(l)<1e-9)return null;const c=((n[0]-e[0])*a-(n[1]-e[1])*i)/l,f=((n[0]-e[0])*s-(n[1]-e[1])*r)/l,u=1e-6;return c<=u||c>=1-u||f<=u||f>=1-u?null:[e[0]+c*r,e[1]+c*s]}function wS(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],f=Math.hypot(l,c)||1,u=l/f,m=c/f,p=g=>(g[0]-s[0])*u+(g[1]-s[1])*m,h=a.slice().sort((g,b)=>p(g)-p(b));for(const g of h){const b=p(g),$=Math.max(0,b-tr),k=Math.min(f,b+tr);o.push([s[0]+u*$,s[1]+m*$]),n.push(o),o=[[s[0]+u*k,s[1]+m*k]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function vS(){const e=x(c=>c.internal.wireRenders),t=x(c=>c.internal.terminalToNode),n=x(c=>c.diagram.wires),o=x(c=>c.selectedWire),r=x(c=>c.selectedNode),s=new Map;for(const c of n??[]){const f=t.get(c.ends[0]);f&&s.set(c.id,f)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const f=s.get(c.wireId);for(let u=0;u<c.path.length-1;u++)a.push({wireId:c.wireId,node:f,i:u,a:c.path[u],b:c.path[u+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let f=c+1;f<a.length;f++){const u=a[c],m=a[f];if(u.wireId===m.wireId||!(u.node&&m.node&&u.node!==m.node))continue;const p=bS(u.a,u.b,m.a,m.b);if(!p)continue;const h=u.wireId<m.wireId?u:m;let g=l.get(h.wireId);g||(g=new Map,l.set(h.wireId,g));const b=g.get(h.i)??[];b.push(p),g.set(h.i,b)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const f=c.path,u=f.map(k=>`${k[0]},${k[1]}`).join(" "),m=s.get(c.wireId),p=o===c.wireId,h=r!=null&&r===m,g=p||h?"true":void 0,b=l.get(c.wireId),$=b?wS(f,b):[f];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,className:"ole-wire-hit",points:u},`hit-${c.wireId}`),...$.map((k,w)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,"data-manual":c.userEdited?"true":void 0,"data-selected":g,className:"ole-wire",points:k.map(M=>`${M[0]},${M[1]}`).join(" ")},`${c.wireId}-${w}`))]})})}let Ue=null;const Fn=new Set;function Xe(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 Fn)t(e)}}function kS(){return Ue}function _S(e){return Fn.add(e),()=>{Fn.delete(e)}}function $S(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=O.useState(kS());if(O.useEffect(()=>_S(o),[]),!e||!t)return null;const r=e.world,s=(n==null?void 0:n.world[0])??t[0],i=(n==null?void 0:n.world[1])??t[1],a=(n==null?void 0:n.create)==="junction";return d.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[d.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?7:8,className:"ole-wire-preview-target-ring","data-create":a?"true":void 0}),!a&&d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function Qe(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function at(e){var t;return((t=Qe(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function SS(e){var t;return((t=Qe(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function jS(e){var t;return((t=Qe(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function sn(e){var r;const t=(r=Qe(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=jS(e);if(n)return n;const o=SS(e);return o||null}function an(e){var t;return((t=Qe(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Hn(e){var t;return((t=Qe(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Ut(e){var t;return((t=Qe(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function lw(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function ES(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function cw(){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==="junction"||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 NS(){O.useEffect(()=>{const e=t=>{if(ES(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"j":case"J":o.setActiveTool("junction");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":cw();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Wn=null;const qn=new Set;function MS(e){if(e!==Wn){Wn=e;for(const t of qn)t(e)}}function TS(){return Wn}function AS(e){return qn.add(e),()=>{qn.delete(e)}}const nr="ole-hover-element-host",IS="ole-hover-terminal-on",CS="ole-hover-node-on";function PS(e){O.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(u,m,p)=>{for(const h of u)h.classList.remove(p);u.clear();for(const h of m)h.classList.add(p),u.add(h)},a=u=>{var p,h;if(u===n)return;n&&((p=t.querySelector(`[data-element-id="${Dt(n)}"]`))==null||p.classList.remove(nr)),u&&((h=t.querySelector(`[data-element-id="${Dt(u)}"]`))==null||h.classList.add(nr));const m=u?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Dt(u)}"]`)):[];i(r,m,IS),n=u,u?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),MS(u)},l=u=>{if(u===o)return;const m=u?Array.from(t.querySelectorAll(`[data-node-id="${Dt(u)}"]`)):[];i(s,m,CS),o=u,u?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=u=>{a(at(u.target));const m=sn(u.target);let p=null;m?p=x.getState().internal.terminalToNode.get(m)??null:p=an(u.target),l(p)},f=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",f),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",f),a(null),l(null)}},[e])}function Dt(e){return e.replace(/(["\\])/g,"\\$1")}function OS(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const m=a[0]-l/2,p=a[0]+l/2,h=Math.max(m,Math.min(p,t[0]));return{ref:e,world:[h,a[1]],isBus:!0}}const c=a[1]-l/2,f=a[1]+l/2,u=Math.max(c,Math.min(f,t[1]));return{ref:e,world:[a[0],u],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const or=10,Ft=e=>Math.round(e/or)*or,BS=16;function dw(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,f=l-i,u=c*c+f*f,m=u===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*f)/u)),p=s+m*c,h=i+m*f,g=(p-t[0])**2+(h-t[1])**2;g<o&&(o=g,n=[p,h])}return n}function Jt(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function LS(e,t){const n=x.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=dw(s.path,e),a=Math.hypot(i[0]-e[0],i[1]-e[1]);a<=r&&(r=a,o={wireId:s.wireId,at:i})}return o}function jt(e,t,n){const o=e?sn(e):null;if(o){const a=OS(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?Hn(e):null,s=null;if(r){const a=x.getState().internal.wireRenders.get(r);s=a?dw(a.path,t):t}else{const a=LS(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[Ft(s[0]),Ft(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Ft(t[0]),Ft(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Et(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+BS,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function uw(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function Zt(e,t){return e.ref&&t.ref?e.ref===t.ref:!e.ref&&!t.ref?e.world[0]===t.world[0]&&e.world[1]===t.world[1]:!1}const rr=3;let ue=null,Me=null,je=null,ge=null;const zS={id:"select",cursor:"default",onPointerDown(e,t){var h,g,b,$,k,w,M,B,D,V,J,ne;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Ut(e.target);if(o){e.preventDefault(),e.stopPropagation();const G=(h=n.diagram.annotations)==null?void 0:h.find(P=>P.id===o);if(!G)return;n.setSelectedAnnotation(o),ge={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[G.at[0],G.at[1]],moved:!1};return}const r=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(r){const G=(g=r.closest("[data-junction-id]"))==null?void 0:g.getAttribute("data-junction-id");if(G){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&(($=(b=e.target).hasPointerCapture)!=null&&$.call(b,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(G);const P=(k=n.internal.junctions.get(G))==null?void 0:k.world;P&&n.setWireDragFrom({spec:{end:G},world:P,ref:G}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:G};return}}const i=(e.target instanceof Element?(w=e.target.closest("[data-terminal-id]"))==null?void 0:w.getAttribute("data-terminal-id"):null)?sn(e.target):null;if(i){const G=i.indexOf("."),P=G>0?i.slice(0,G):"";if(P&&n.selection.includes(P)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((B=(M=e.target).hasPointerCapture)!=null&&B.call(M,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const F=(D=n.internal.terminals.get(i))==null?void 0:D.world;F&&n.setWireDragFrom({spec:{end:i},world:F,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:i};return}}let a=at(e.target);if(!a){const G=Hn(e.target);if(G&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const F of P){const le=(J=(V=F.closest)==null?void 0:V.call(F,"[data-bus-id]"))==null?void 0:J.getAttribute("data-bus-id");if(!le)continue;const ce=(ne=n.diagram.wires)==null?void 0:ne.find(he=>he.id===G);ce&&(ce.ends[0]===le||ce.ends[1]===le)&&(a=le);break}}}if(!a){const G=Hn(e.target);if(G){if(e.preventDefault(),e.altKey){const P=an(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(G);return}e.shiftKey||n.clearSelection(),Me={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(a):l.includes(a)||n.setSelection([a]);const c=e.shiftKey?x.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const f=x.getState().internal,u=new Map,m=new Map,p=new Map;for(const G of c){const P=f.buses.get(G);if(P){m.set(G,[P.geometry.at[0],P.geometry.at[1]]);continue}const F=f.junctions.get(G);if(F){p.set(G,[F.world[0],F.world[1]]);continue}const le=f.layout.get(G);le&&u.set(G,{...le})}u.size===0&&m.size===0&&p.size===0||(ue={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:m,junctionOriginals:p,moved:!1},e.preventDefault())},onPointerMove(e,t){if(ge&&e.pointerId===ge.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ge.startSvg[0]),r=fe(n[1]-ge.startSvg[1]);!ge.moved&&(o!==0||r!==0)&&(ge.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=Jt(e.clientX,e.clientY),r=jt(o,n,Et(t,e.clientX,e.clientY)),s={spec:{end:je.fromRef},world:[0,0],ref:je.fromRef};Xe(Zt(s,r)?null:uw(r));return}if(ue&&e.pointerId===ue.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ue.startSvg[0]),r=fe(n[1]-ue.startSvg[1]);!ue.moved&&(o!==0||r!==0)&&(ue.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ue.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ye(l))}for(const s of ue.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of ue.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Me&&e.pointerId===Me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);Rt(sr(Me.startSvg,n));return}},onPointerUp(e,t){if(ge&&e.pointerId===ge.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ge.startSvg[0]),r=fe(n[1]-ge.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);s&&s.removeAttribute("transform"),ge.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(ge.id,{at:[ge.origin[0]+o,ge.origin[1]+r]}),ge=null;return}if(je&&e.pointerId===je.pointerId){const n=x.getState(),o=je.fromRef;je=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Xe(null);const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=Jt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=jt(s,r,Et(t,e.clientX,e.clientY));if(Zt({world:[0,0],ref:o},i))return;n.connectWire({end:o},i.spec);return}if(ue&&e.pointerId===ue.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ue.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ue.startSvg[0]),r=fe(n[1]-ue.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ue.originals.keys())s.set(i,[o,r]);for(const i of ue.busOriginals.keys())s.set(i,[o,r]);for(const i of ue.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ue.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}for(const s of ue.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}}ue=null;return}if(Me&&e.pointerId===Me.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=sr(Me.startSvg,n);if(o.w>=rr||o.h>=rr){const r=RS(o);if(Me.shiftKey){const s=new Set(Me.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}Rt(null),Me=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(ge&&e.pointerId===ge.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ge=null}if(ue&&e.pointerId===ue.pointerId){for(const[l,c]of ue.originals){const f=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);f&&f.setAttribute("transform",Ye(c))}for(const l of ue.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of ue.junctionOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ue=null}if(je&&e.pointerId===je.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setWireDragFrom(null),l.setCursorSvg(null),Xe(null),je=null}if(Me&&e.pointerId===Me.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}Rt(null),Me=null}},onDoubleClick(e){const t=x.getState(),n=Ut(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=at(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ue=null,Me=null,ge=null,je){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),Xe(null),je=null}Rt(null)}};function sr(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 RS(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=FS(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(([u,m])=>DS([u,m],r));let a=1/0,l=-1/0,c=1/0,f=-1/0;for(const[u,m]of i)u<a&&(a=u),u>l&&(l=u),m<c&&(c=m),m>f&&(f=m);l>=e.x&&a<=e.x+e.w&&f>=e.y&&c<=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,c=s==="x"?i[0]-l:i[0],f=s==="x"?i[0]+l:i[0],u=s==="x"?i[1]:i[1]-l,m=s==="x"?i[1]:i[1]+l;f>=e.x&&c<=e.x+e.w&&m>=e.y&&u<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function DS(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 FS(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 Be(e){return e.replace(/(["\\])/g,"\\$1")}const HS=4;let ie=null;const WS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=at(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,c=new Map;for(const f of i){const u=a.buses.get(f);if(u){c.set(f,[u.geometry.at[0],u.geometry.at[1]]);continue}const m=a.layout.get(f);m&&l.set(f,{...m})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}ie={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(!ie||e.pointerId!==ie.pointerId)return;const n=e.clientX-ie.startX,o=e.clientY-ie.startY;if(!ie.moved&&Math.hypot(n,o)>HS){ie.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(ie.moved){if(ie.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=fe(r[0]-ie.elementDrag.startSvg[0]),i=fe(r[1]-ie.elementDrag.startSvg[1]);for(const[a,l]of ie.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${wt(a)}"]`);if(!c)continue;const f={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",Ye(f))}for(const a of ie.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${wt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:ie.startTx+n,ty:ie.startTy+o})}},onPointerUp(e,t){if(!(!ie||e.pointerId!==ie.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",ie.elementDrag&&ie.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=fe(n[0]-ie.elementDrag.startSvg[0]),r=fe(n[1]-ie.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ie.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of ie.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ie.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${wt(s)}"]`);i&&i.removeAttribute("transform")}}else ie.moved||qS(ie.startTarget);ie=null}},onPointerCancel(e,t){if(ie!=null&&ie.elementDrag){for(const[n,o]of ie.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${wt(n)}"]`);r&&r.setAttribute("transform",Ye(o))}for(const n of ie.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${wt(n)}"]`);o&&o.removeAttribute("transform")}}ie=null},onDeactivate(){ie=null}};function qS(e){if(!e)return;const t=x.getState(),n=Ut(e);if(n){t.setSelectedAnnotation(n);return}const o=at(e);if(o){t.setSelection([o]);return}const r=an(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function wt(e){return e.replace(/(["\\])/g,"\\$1")}const kt={tight:1024,compact:720,dense:520,mini:380},ir={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return ir[e]>=ir[t]}function GS(e){return e>=kt.tight?"full":e>=kt.compact?"tight":e>=kt.dense?"compact":e>=kt.mini?"dense":"mini"}const fw=O.createContext("full");function Ve(){return O.useContext(fw)}function XS(e){const[t,n]=O.useState(null);return O.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 mw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<kt.dense}function ln(){mw()&&x.getState().setActiveTool("pan")}function YS(){mw()&&x.getState().setPlaceKind(null)}const KS={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.setWireDragFrom(null),t.setCursorSvg(null),Xe(null)},onPointerDown(e,t){var i,a;if(e.button!==0)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((a=(i=e.target).hasPointerCapture)!=null&&a.call(i,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Et(t,e.clientX,e.clientY),r=jt(e.target instanceof Element?e.target:null,n,o),s=x.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=Jt(e.clientX,e.clientY),i=jt(s,r,Et(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Xe(Zt(a,i)?null:uw(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Xe(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=Jt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=jt(s,r,Et(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Zt(a,i)||(n.connectWire(o.spec,i.spec),ln())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Xe(null)}},ar=10;let vt=!1;function lr(){setTimeout(()=>YS(),0)}const VS={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),vt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=sn(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);nw(n,r),vt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([cr(n[0]),cr(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);F$(r,o,s),lr();return}vt&&(vt=!1,lr())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),vt=!1}};function cr(e){return Math.round(e/ar)*ar}const dr=10,ur=20;function nt(e){return Math.round(e/dr)*dr}const US={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[nt(n[0]),nt(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([nt(n[0]),nt(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=nt(o[0]),s=nt(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,f,u;if(l){if(f=Math.abs(i),f<ur)return;c=0,u=[(n[0]+r)/2,n[1]]}else{if(f=Math.abs(a),f<ur)return;c=90,u=[n[0],(n[1]+s)/2]}x.getState().addBus(u,f,c),ln()},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)}},fr=10,mr=e=>Math.round(e/fr)*fr,JS={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().addJunction([mr(n[0]),mr(n[1])]),ln()}},ZS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Ut(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),ln()}},QS={select:zS,pan:WS,wire:KS,place:VS,busbar:US,junction:JS,text:ZS};function e4(e,t){const n=x(o=>o.activeTool);O.useEffect(()=>{var m;const o=e.current;if(!o)return;const r=QS[n],s={viewport:t,hostEl:o};(m=r.onActivate)==null||m.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=p=>{var h;return(h=r.onPointerDown)==null?void 0:h.call(r,p,s)},a=p=>{var h;return(h=r.onPointerMove)==null?void 0:h.call(r,p,s)},l=p=>{var h;return(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},c=p=>{var h;return r.onPointerCancel?r.onPointerCancel(p,s):(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},f=p=>{var h;return(h=r.onPointerLeave)==null?void 0:h.call(r,p,s)},u=p=>{var h;return(h=r.onDoubleClick)==null?void 0:h.call(r,p,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",c),o.addEventListener("pointerleave",f),o.addEventListener("dblclick",u),()=>{var p;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",c),o.removeEventListener("pointerleave",f),o.removeEventListener("dblclick",u),(p=r.onDeactivate)==null||p.call(r,s),o.style.cursor=""}},[n,e,t])}let Gn=1;const Xn=new Set;function t4(e){if(e!==Gn){Gn=e;for(const t of Xn)t(e)}}function n4(){return Gn}function o4(e){return Xn.add(e),()=>{Xn.delete(e)}}const Sn=.1,jn=8,r4=1.0015,s4=1.02;function i4(e,t,n={tx:0,ty:0,scale:1}){const o=O.useRef({...n}),r=O.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)),t4(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return O.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,f=0,u=0,m=0,p=!1;const h=new Map;let g=null,b=!1;const $=()=>{if(h.size<2){g=null;return}const P=[...h.values()],F=P[1].x-P[0].x,le=P[1].y-P[0].y,ce=Math.hypot(F,le)||1,he=i.getBoundingClientRect();g={startDist:ce,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(P[0].x+P[1].x)/2-he.left,startMidY:(P[0].y+P[1].y)/2-he.top}},k=P=>{if(P.pointerType==="touch"){if(h.set(P.pointerId,{x:P.clientX,y:P.clientY}),h.size>=2&&!b){b=!0;for(const F of h.keys())F!==P.pointerId&&lw(i,F);$()}if(b){P.stopPropagation(),P.preventDefault();try{i.setPointerCapture(P.pointerId)}catch{}}}},w=P=>{if(P.pointerType!=="touch"||!h.has(P.pointerId)||(h.set(P.pointerId,{x:P.clientX,y:P.clientY}),!b||!g))return;P.stopPropagation();const F=[...h.values()];if(F.length<2)return;const le=F[1].x-F[0].x,ce=F[1].y-F[0].y,he=Math.hypot(le,ce)||1,oe=i.getBoundingClientRect(),se=(F[0].x+F[1].x)/2-oe.left,ye=(F[0].y+F[1].y)/2-oe.top,xe=he/g.startDist,_e=En(g.startScale*xe,Sn,jn),Ne=_e/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*Ne+(se-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ne+(ye-g.startMidY),o.current.scale=_e,s()},M=P=>{var F;if(P.pointerType==="touch"&&h.has(P.pointerId)&&(h.delete(P.pointerId),b)){if(P.stopPropagation(),(F=i.hasPointerCapture)!=null&&F.call(i,P.pointerId))try{i.releasePointerCapture(P.pointerId)}catch{}h.size>=2?$():g=null,h.size===0&&(b=!1)}},B=P=>{P.preventDefault();const F=i.getBoundingClientRect(),le=P.clientX-F.left,ce=P.clientY-F.top,he=P.ctrlKey||P.metaKey;if(P.deltaX===0||he){const ye=Math.pow(he?s4:r4,-P.deltaY),xe=En(o.current.scale*ye,Sn,jn),_e=xe/o.current.scale;o.current.tx=le-(le-o.current.tx)*_e,o.current.ty=ce-(ce-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=P.deltaX,o.current.ty-=P.deltaY;s()},D=P=>{const F=P.button===1,le=p&&P.button===0;!F&&!le||(P.preventDefault(),a=!0,l=P.pointerId,c=P.clientX,f=P.clientY,u=o.current.tx,m=o.current.ty,i.setPointerCapture(P.pointerId),i.style.cursor="grabbing")},V=P=>{!a||P.pointerId!==l||(o.current.tx=u+(P.clientX-c),o.current.ty=m+(P.clientY-f),s())},J=P=>{a&&P.pointerId===l&&(a=!1,i.releasePointerCapture(P.pointerId),i.style.cursor=p?"grab":"")},ne=P=>{if(P.code==="Space"&&!p){const F=P.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;p=!0,i.style.cursor="grab",P.preventDefault()}},G=P=>{P.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",B,{passive:!1}),i.addEventListener("pointerdown",D),i.addEventListener("pointermove",V),i.addEventListener("pointerup",J),i.addEventListener("pointercancel",J),i.addEventListener("pointerdown",k,{capture:!0}),i.addEventListener("pointermove",w,{capture:!0}),i.addEventListener("pointerup",M,{capture:!0}),i.addEventListener("pointercancel",M,{capture:!0}),window.addEventListener("keydown",ne),window.addEventListener("keyup",G),s(),()=>{i.removeEventListener("wheel",B),i.removeEventListener("pointerdown",D),i.removeEventListener("pointermove",V),i.removeEventListener("pointerup",J),i.removeEventListener("pointercancel",J),i.removeEventListener("pointerdown",k,{capture:!0}),i.removeEventListener("pointermove",w,{capture:!0}),i.removeEventListener("pointerup",M,{capture:!0}),i.removeEventListener("pointercancel",M,{capture:!0}),window.removeEventListener("keydown",ne),window.removeEventListener("keyup",G)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const c=l.getBoundingClientRect(),f=(i-c.left-o.current.tx)/o.current.scale,u=(a-c.top-o.current.ty)/o.current.scale;return[f,u]},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=En(i.scale,Sn,jn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function En(e,t,n){return e<t?t:e>n?n:e}const hw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ot=hw?"⌘":"Ctrl+",a4=hw?"⇧":"Shift+",Nn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],l4=18;function c4(e){for(const t of Nn)if(t*e>=l4)return t;return Nn[Nn.length-1]}function d4(){const e=ae(),t=O.useRef(null),n=O.useRef(null),o=O.useRef(null),r=i4(t,n);e4(t,r),PS(t),O.useEffect(()=>(Zo(r),()=>Zo(null)),[r]),O.useEffect(()=>{const f=u=>{const m=o.current;if(!m)return;const h=c4(u.scale)*u.scale;m.setAttribute("width",String(h)),m.setAttribute("height",String(h)),m.setAttribute("patternTransform",`translate(${u.tx} ${u.ty})`)};return f(r.getViewport()),r.subscribe(f)},[r]);const s=Jv(),i=O.useCallback((f,u,m)=>{const p=x.getState(),h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){cw();return}const g=at(m);if(g)p.selection.includes(g)||p.setSelection([g]);else{const D=an(m);D&&p.selectedNode!==D&&p.setSelectedNode(D)}const b=x.getState(),$=b.selection.length>0,k=b.selectedNode!=null,w=!!b.clipboard,M=b.diagram.elements.length>0,B=[{label:e("menu.undo"),shortcut:`${ot}Z`,icon:Jn,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${ot}${a4}Z`,icon:Un,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ot}X`,icon:Wr,onSelect:()=>x.getState().cutSelection(),disabled:!$},{label:e("menu.copy"),shortcut:`${ot}C`,icon:Rr,onSelect:()=>x.getState().copySelection(),disabled:!$},{label:e("menu.paste"),shortcut:`${ot}V`,icon:zr,onSelect:()=>x.getState().pasteClipboard(),disabled:!w},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Hr,onSelect:()=>x.getState().rotateSelection(90),disabled:!$},{label:e("menu.mirror"),shortcut:"M",icon:Dr,onSelect:()=>x.getState().mirrorSelection(),disabled:!$},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ot}A`,icon:xv,onSelect:()=>{const D=x.getState();D.setSelection(D.diagram.elements.map(V=>V.id))},disabled:!M},{type:"separator"},{label:e(k&&!$?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Gr,destructive:!0,onSelect:()=>k&&!$?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!$&&!k}];s.open(f,u,B)},[s,e]);O.useEffect(()=>{const f=t.current;if(!f)return;const u=700,m=4;let p,h=null;const g=()=>{p!==void 0&&window.clearTimeout(p),p=void 0,h=null},b=w=>{w.pointerType==="touch"&&(g(),h={pointerId:w.pointerId,x:w.clientX,y:w.clientY,target:w.target},p=window.setTimeout(()=>{const M=h;h=null,p=void 0,M&&(lw(f,M.pointerId),i(M.x,M.y,M.target))},u))},$=w=>{if(!h||w.pointerId!==h.pointerId)return;const M=w.clientX-h.x,B=w.clientY-h.y;Math.hypot(M,B)>m&&g()},k=w=>{!h||w.pointerId!==h.pointerId||g()};return f.addEventListener("pointerdown",b),f.addEventListener("pointermove",$),f.addEventListener("pointerup",k),f.addEventListener("pointercancel",k),()=>{g(),f.removeEventListener("pointerdown",b),f.removeEventListener("pointermove",$),f.removeEventListener("pointerup",k),f.removeEventListener("pointercancel",k)}},[i]);const a=f=>{f.dataTransfer.types.includes("application/x-oneline-kind")&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},l=f=>{const u=f.dataTransfer.getData("application/x-oneline-kind");if(!u)return;f.preventDefault();const m=r.screenToSvg(f.clientX,f.clientY);nw(u,m)},c=f=>{f.preventDefault(),i(f.clientX,f.clientY,f.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(eS,{}),d.jsx(vS,{}),d.jsx(lS,{}),d.jsx(uS,{}),d.jsx(W$,{}),d.jsx(G$,{}),d.jsx(gS,{}),d.jsx(V$,{}),d.jsx(U$,{}),d.jsx(xS,{}),d.jsx($S,{}),d.jsx(tS,{}),d.jsx(pS,{}),d.jsx(hS,{})]})]})})}const hr=60,u4=.1,f4=8,m4=8;function h4(e,t,n){return e<t?t:e>n?n:e}function p4(){return document.querySelector(".ole-canvas-root")}function to(){const e=Ze(),t=p4();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 $ of o){const k=$.getBoundingClientRect();k.width===0&&k.height===0||(k.left<r&&(r=k.left),k.top<s&&(s=k.top),k.right>i&&(i=k.right),k.bottom>a&&(a=k.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[f,u]=e.screenToSvg(i,a),m=Math.max(f-l,1),p=Math.max(u-c,1),h=h4(Math.min((n.width-hr*2)/m,(n.height-hr*2)/p),u4,f4),g=(l+f)/2,b=(c+u)/2;return e.setViewport({tx:n.width/2-h*g,ty:n.height/2-h*b,scale:h}),!0}function no(){let e=m4;const t=()=>{to()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const pr=10,g4=100;function y4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function x4(){const[e,t]=O.useState(TS()),[n,o]=O.useState(!1),[r,s]=O.useState(null),i=O.useRef(null),a=O.useRef(void 0),[l]=O.useState(y4);O.useEffect(()=>AS(h=>t(h)),[]),O.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),g4),()=>window.clearTimeout(a.current)},[e]);const c=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(O.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,b=-1;const $=()=>{const k=document.querySelector(`[data-element-id="${b4(e)}"]`),w=i.current;if(k&&w){const M=k.getBoundingClientRect();let B=M.bottom+pr;B+w.offsetHeight>window.innerHeight-4&&(B=M.top-w.offsetHeight-pr);let D=M.left+M.width/2-w.offsetWidth/2;D=Math.max(4,Math.min(D,window.innerWidth-w.offsetWidth-4)),(B!==g||D!==b)&&(s({top:B,left:D}),g=B,b=D)}h=requestAnimationFrame($)};return h=requestAnimationFrame($),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!c)return null;const f=Ke[c.kind],u=c.name??c.id,m=(f==null?void 0:f.name)??c.kind,p=c.name&&c.name!==c.id;return typeof document>"u"?null:Or.createPortal(d.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:[d.jsx("span",{className:"font-medium text-foreground",children:u}),p&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id}),d.jsx("span",{className:"text-muted-foreground/80",children:"·"}),d.jsx("span",{className:"text-muted-foreground",children:m})]}),document.body)}function b4(e){return e.replace(/(["\\])/g,"\\$1")}function w4({width:e,children:t}){const n=e==null?"full":GS(e);return d.jsx(fw.Provider,{value:n,children:t})}function gr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function v4(...e){return t=>{let n=!1;const o=e.map(r=>{const s=gr(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():gr(e[r],null)}}}}var k4=Symbol.for("react.lazy"),Qt=ke[" use ".trim().toString()];function _4(e){return typeof e=="object"&&e!==null&&"then"in e}function pw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===k4&&"_payload"in e&&_4(e._payload)}function $4(e){const t=j4(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;pw(s)&&typeof Qt=="function"&&(s=Qt(s._payload));const a=ke.Children.toArray(s),l=a.find(N4);if(l){const c=l.props.children,f=a.map(u=>u===l?ke.Children.count(c)>1?ke.Children.only(null):ke.isValidElement(c)?c.props.children:null:u);return d.jsx(t,{...i,ref:r,children:ke.isValidElement(c)?ke.cloneElement(c,void 0,f):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var S4=$4("Slot");function j4(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(pw(r)&&typeof Qt=="function"&&(r=Qt(r._payload)),ke.isValidElement(r)){const i=T4(r),a=M4(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?v4(o,i):i),ke.cloneElement(r,a)}return ke.Children.count(r)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var E4=Symbol("radix.slottable");function N4(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===E4}function M4(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 T4(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 yr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,xr=Kr,A4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return xr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const f=n==null?void 0:n[c],u=s==null?void 0:s[c];if(f===null)return null;const m=yr(f)||yr(u);return r[c][m]}),a=n&&Object.entries(n).reduce((c,f)=>{let[u,m]=f;return m===void 0||(c[u]=m),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,f)=>{let{class:u,className:m,...p}=f;return Object.entries(p).every(h=>{let[g,b]=h;return Array.isArray(b)?b.includes({...s,...a}[g]):{...s,...a}[g]===b})?[...c,u,m]:c},[]);return xr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},I4=A4("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"}}),Ae=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?S4:"button";return d.jsx(i,{className:Ee(I4({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const C4=350;function Ie({content:e,children:t,disabled:n,delayMs:o=C4}){const r=O.useRef(null),s=O.useRef(null),[i,a]=O.useState(!1),[l,c]=O.useState(null),f=O.useId(),u=O.useRef(void 0),m=()=>{n||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(u.current),a(!1)};O.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const $=r.current.getBoundingClientRect(),k=s.current.getBoundingClientRect(),w=8;let M="top",B=$.top-k.height-w;B<4&&(M="bottom",B=$.bottom+w);let D=$.left+$.width/2-k.width/2;D=Math.max(4,Math.min(D,window.innerWidth-k.width-4)),c({top:B,left:D,side:M})},[i,e]),O.useEffect(()=>()=>window.clearTimeout(u.current),[]),O.useEffect(()=>{if(!i)return;const $=w=>{w.key==="Escape"&&a(!1)},k=()=>a(!1);return window.addEventListener("keydown",$),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("keydown",$),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i]);const h=t,g=h.props,b=O.cloneElement(h,{ref:$=>{r.current=$;const k=h.ref;typeof k=="function"?k($):k&&typeof k=="object"&&(k.current=$)},onPointerEnter:$=>{var k;(k=g.onPointerEnter)==null||k.call(g,$),m()},onPointerLeave:$=>{var k;(k=g.onPointerLeave)==null||k.call(g,$),p()},onFocus:$=>{var k;(k=g.onFocus)==null||k.call(g,$),m()},onBlur:$=>{var k;(k=g.onBlur)==null||k.call(g,$),p()},"aria-describedby":i?f:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[b,i&&typeof document<"u"&&Or.createPortal(d.jsx("div",{ref:s,id:f,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 br=12,P4=56;function O4(){var $;const e=ae(),t=x(k=>k.selection),n=x(k=>k.selectedNode),o=x(k=>k.selectedWire),r=x(k=>k.activeTool),s=x(k=>k.rotateSelection),i=x(k=>k.mirrorSelection),a=x(k=>k.deleteSelection),l=x(k=>k.deleteSelectedNode),c=x(k=>k.deleteSelectedWire),f=x(k=>k.resetWirePath),u=x(k=>k.internal.wireRenders),m=o!=null&&(($=u.get(o))==null?void 0:$.userEdited)===!0,p=O.useRef(null);O.useEffect(()=>{const k=p.current;if(!k)return;const w=t.length>0,M=!w&&o!=null,B=!w&&!M&&n!=null;if(!((w||M||B)&&(r==="select"||r==="pan"))){k.style.display="none";return}k.style.display="flex";let V=0,J="";const ne=()=>{let G=1/0,P=-1/0,F=1/0,le=-1/0,ce=!1;const he=oe=>{oe.width===0&&oe.height===0||(oe.left<G&&(G=oe.left),oe.right>P&&(P=oe.right),oe.top<F&&(F=oe.top),oe.bottom>le&&(le=oe.bottom),ce=!0)};if(w)for(const oe of t){const se=document.querySelector(`[data-element-id="${CSS.escape(oe)}"]`);se&&he(se.getBoundingClientRect())}else if(M&&o){const oe=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);oe&&he(oe.getBoundingClientRect())}else if(B&&n){const oe=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const se of oe)he(se.getBoundingClientRect())}if(ce){const oe=(G+P)/2;let se=F-br,ye="-100%";se<P4&&(se=le+br,ye="0%");const xe=`translate3d(${oe}px, ${se}px, 0) translate(-50%, ${ye})`;xe!==J&&(k.style.transform=xe,J=xe)}V=requestAnimationFrame(ne)};return V=requestAnimationFrame(ne),()=>cancelAnimationFrame(V)},[t,n,o,r]);const h=t.length===0&&o!=null,g=t.length===0&&!h&&n!=null,b=g||h;return d.jsxs("div",{ref:p,role:"toolbar","aria-label":e(h?"ctx.ariaWire":g?"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:[h&&m&&o&&d.jsxs(d.Fragment,{children:[d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{children:d.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>f(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx(yv,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&d.jsxs(d.Fragment,{children:[d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:d.jsx(Hr,{})})}),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Dr,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.delete")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),d.jsx("div",{className:"text-muted-foreground",children:e(h?"ctx.deleteHintWire":g?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>h?c():g?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(Gr,{})})})]})}function oo({open:e,onOpenChange:t,trigger:n,children:o}){const r=O.useRef(null);return O.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]),d.jsxs("div",{ref:r,className:"relative",children:[n,e&&d.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 gw="ole-panel-open";function B4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(gw);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 wr(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(gw,JSON.stringify(t))}catch{}}const Tt=en((e,t)=>({...B4(),setOutlineOpen:n=>{e({outlineOpen:n}),wr(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),wr(t())}})),qt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],yw=.1,xw=8,bw="ole-grid";function L4(){try{const e=window.localStorage.getItem(bw);return e==null?!0:e==="1"}catch{return!0}}function z4(e){try{window.localStorage.setItem(bw,e?"1":"0")}catch{}}function R4(e,t,n){return e<t?t:e>n?n:e}function ww(){return document.querySelector(".ole-canvas-root")}function ro(e){const t=Ze(),n=ww();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=R4(e,yw,xw),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function D4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=qt.find(o=>o>t+1e-6)??xw;ro(n)}function F4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=yw;for(let o=qt.length-1;o>=0;o--)if(qt[o]<t-1e-6){n=qt[o];break}ro(n)}const H4={off:"id",id:"all",all:"off"};function W4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=H4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function vw(){const[e,t]=O.useState(()=>L4());return O.useEffect(()=>{const n=ww();n==null||n.classList.toggle("hide-grid",!e),z4(e)},[e]),O.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 kw(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:F4,"aria-label":e("view.zoomOut"),children:d.jsx(Vn,{})})})}function _w(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:D4,"aria-label":e("view.zoomIn"),children:d.jsx(pv,{})})})}function $w(){const e=ae(),[t,n]=O.useState(n4);return O.useEffect(()=>o4(n),[]),d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.reset")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:d.jsxs("button",{type:"button",onClick:()=>ro(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 Sw(){const e=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.fit")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:to,"aria-label":e("view.fit"),children:d.jsx(fv,{})})})}function jw({grid:e,setGrid:t}){const n=ae();return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),d.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:Ee(!e&&"text-muted-foreground/60"),children:d.jsx(dv,{})})})}function Ew(){const e=ae(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Ie,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:W4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:Ee(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Xr,{})})})}function q4({stacked:e}={}){const t=ae(),[n,o]=O.useState(!1),[r,s]=vw(),i=d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:t("view.menu")}),d.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?d.jsx(Ie,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:Ee("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:[d.jsx(An,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Ie,{content:i,children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:d.jsx(An,{})})});return d.jsx(oo,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx($w,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(kw,{}),d.jsx(_w,{})]}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Sw,{}),d.jsx(jw,{grid:r,setGrid:s}),d.jsx(Ew,{})]})]})})}function G4(){const e=Ve();return Oe(e,"dense")?null:d.jsx(X4,{tier:e})}function X4({tier:e}){const t=Oe(e,"tight"),[n,o]=vw();return d.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:d.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[d.jsx(kw,{}),!t&&d.jsx($w,{}),d.jsx(_w,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(Sw,{}),d.jsx(jw,{grid:n,setGrid:o}),d.jsx(Ew,{})]})})}const vr=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:mv,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:uv,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Vn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:rv,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:qr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Lr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Xr,switchTo:"text",iconOnly:!0}];function Y4(){const e=ae(),t=x(f=>f.activeTool),n=x(f=>f.placeKind),o=x(f=>f.placeFromTerminal),r=x(f=>f.wireDragFrom),s=x(f=>f.busbarDrawStart),i=x(f=>f.selection.length>0||f.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"junction":a=e("mode.junction"),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 c=e(t==="select"?"mode.escSelect":"mode.escOther");return d.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:[d.jsx("span",{children:a}),l&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",c]})]})}function K4(){const e=ae(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ve(),c=Oe(l,"tight"),f=!Oe(l,"dense"),u=Oe(l,"dense"),m=u?vr.filter(h=>h.id!=="select"&&h.id!=="text"):vr,p=h=>t===h.switchTo;return d.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:[f&&d.jsx(Y4,{}),d.jsxs("div",{className:Ee("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",u?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[u&&d.jsx(V4,{stacked:!0}),m.map(h=>{const g=h.icon,b=p(h),$=h.id==="place"&&b&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return d.jsxs(O.Fragment,{children:[d.jsx(it,{icon:g,label:e(h.labelKey),hotkey:h.hotkey,active:b,iconOnly:!u&&(h.iconOnly||c),stacked:u,description:$,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!u&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!u&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),u?d.jsx(J4,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(it,{icon:Jn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(it,{icon:Un,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),d.jsx(U4,{iconOnly:c})]}),u&&d.jsx(q4,{stacked:!0})]})]})}function V4({stacked:e}){const t=ae(),n=Tt(r=>r.outlineOpen),o=Tt(r=>r.toggleOutline);return d.jsx(it,{icon:Fr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function it({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const c=d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:t}),n&&d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&d.jsx("div",{className:"text-muted-foreground",children:l})]});return d.jsx(Ie,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:Ee("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:[d.jsxs("span",{className:"relative inline-flex shrink-0",children:[d.jsx(e,{className:"size-4"}),n&&!i&&d.jsx("span",{"aria-hidden":!0,className:Ee("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?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function Nw(){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 U4({iconOnly:e}){const t=ae(),[n,o]=O.useState(!1),r=Nw(),s=i=>()=>{o(!1),i()};return d.jsxs(oo,{open:n,onOpenChange:o,trigger:d.jsx(it,{icon:_t,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeAll()),icon:d.jsx(_t,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:d.jsx(_t,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Gt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Gt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function J4({stacked:e}){const t=ae(),[n,o]=O.useState(!1),r=x(m=>m.past.length),s=x(m=>m.future.length),i=x(m=>m.undo),a=x(m=>m.redo),l=x(m=>m.selection.length>0),c=x(m=>m.clipboard!=null),f=Nw(),u=m=>()=>{o(!1),m()};return d.jsxs(oo,{open:n,onOpenChange:o,trigger:d.jsx(it,{icon:An,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[d.jsx(Te,{onClick:u(i),icon:d.jsx(Jn,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Te,{onClick:u(a),icon:d.jsx(Un,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:u(()=>x.getState().cutSelection()),icon:d.jsx(Wr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Te,{onClick:u(()=>x.getState().copySelection()),icon:d.jsx(Rr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Te,{onClick:u(()=>x.getState().pasteClipboard()),icon:d.jsx(zr,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:u(()=>x.getState().autoArrangeAll()),icon:d.jsx(_t,{}),disabled:!f.hasAnyElement||!f.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:u(()=>x.getState().autoArrangeSelection()),icon:d.jsx(_t,{}),disabled:!f.hasSelection||!f.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Te,{onClick:u(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Gt,{}),disabled:!f.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:u(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Gt,{}),disabled:!f.hasSelection||!f.selectionHasGaps,children:t("layout.selFill")})]})}function Te({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:Ee("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,d.jsx("span",{className:"flex-1",children:e})]})}function Z4(){const e=Tt(r=>r.outlineOpen),t=Tt(r=>r.setOutlineOpen),n=Ve();return Oe(n,"dense")?e?d.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:d.jsx(kr,{onClose:()=>t(!1),sheet:!0})}):null:d.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?d.jsx(kr,{onClose:()=>t(!1)}):d.jsx(Q4,{onClick:()=>t(!0)})})}function Q4({onClick:e}){const t=ae(),n=Ve(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:Ee("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:[d.jsx(Fr,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function kr({onClose:e,sheet:t}){const n=ae(),o=x(c=>c.diagram.elements),r=x(c=>c.activeTool==="place"),s=Ve(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:Ee("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:[d.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:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&d.jsx(tj,{children:o.length}),d.jsx(hv,{className:"size-3.5 text-muted-foreground"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?d.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):d.jsx("ul",{className:"space-y-px",children:o.map(c=>d.jsx(ej,{element:c},c.id))})})]})}function ej({element:e}){const t=Ke[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.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:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function tj({children:e}){return d.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 nj={"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":"剩余动作电流"},oj={"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"},_r={zh:nj,en:oj};function rj(e,t){return _r[e][t]??_r.zh[t]}function It(){const e=At(t=>t.locale);return(t,n)=>rj(e,t)??n??t}const Mw="ole-palette-collapsed",sj=new Set(["busbar"]),Nt=(()=>{const e={};for(const[t,n]of Object.entries(N$)){const o=n.filter(r=>!sj.has(r.id));o.length&&(e[t]=o)}return e})(),ij=(()=>{const e=new Set(Xo),t=Object.keys(Nt).filter(n=>!e.has(n));return[...Xo.filter(n=>{var o;return(o=Nt[n])==null?void 0:o.length}),...t]})();function aj(){try{const e=window.localStorage.getItem(Mw);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 lj(e){try{window.localStorage.setItem(Mw,JSON.stringify([...e]))}catch{}}function cj(){const e=ae(),t=x(u=>u.activeTool==="place"),n=x(u=>u.placeKind),o=x(u=>u.setActiveTool),r=Tt(u=>u.outlineOpen),s=Ve(),i=Oe(s,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const f=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 d.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:f,role:"dialog","aria-label":e("library.title"),children:d.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:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.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:d.jsx(Zn,{className:"size-3.5"})})]}),d.jsx(dj,{sheet:i})]})})}function dj({sheet:e}){const t=ae(),n=It(),[o,r]=O.useState(""),[s,i]=O.useState(()=>aj()),a=O.useMemo(()=>{const u=o.trim().toLowerCase();if(!u)return Nt;const m={};for(const[p,h]of Object.entries(Nt)){const g=h.filter(b=>{const $=n(`${b.id}.name`,b.name).toLowerCase(),k=n(`${b.id}.desc`,b.description??"").toLowerCase();return $.includes(u)||b.id.toLowerCase().includes(u)||k.includes(u)});g.length&&(m[p]=g)}return m},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(u=>!(u!=null&&u.length)),f=O.useCallback((u,m)=>{i(p=>{const h=new Set(p);return m?h.delete(u):h.add(u),lj(h),h})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(uj,{value:o,onChange:r})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:c?d.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):ij.map(u=>{var b;const m=a[u];if(!(m!=null&&m.length))return null;const p=((b=Nt[u])==null?void 0:b.length)??m.length,h=t(`cat.${u}`),g=l||!s.has(u);return d.jsxs("details",{open:g,className:"group mb-2 last:mb-0",onToggle:$=>{l||f(u,$.currentTarget.open)},children:[d.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:[d.jsx(ov,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:h}),d.jsx(mj,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map($=>d.jsx(fj,{entry:$,sheet:e},$.id))})]},u)})})]})}function uj({value:e,onChange:t}){const n=ae();return d.jsxs("div",{className:"relative",children:[d.jsx(gv,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),d.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&&d.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:d.jsx(Zn,{className:"size-3"})})]})}function fj({entry:e,sheet:t}){const n=ae(),o=It(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(u=>u.setActiveTool),a=x(u=>u.activeTool==="place"&&u.placeKind===e.id),l=x(u=>t&&u.activeTool==="place"&&u.placeKind==null&&u.lastPlaceKind===e.id),c=O.useRef(null);O.useEffect(()=>{var u;l&&((u=c.current)==null||u.scrollIntoView({block:"nearest"}))},[l]);const f=u=>{u.dataTransfer.effectAllowed="copy",u.dataTransfer.setData("application/x-oneline-kind",e.id),u.dataTransfer.setData("text/plain",e.id);const m=document.createElement("div");m.className="ole-glass",m.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(";"),m.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(m),u.dataTransfer.setDragImage(m,32,32),setTimeout(()=>m.remove(),0)};return d.jsxs("li",{ref:c,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:f,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function mj({children:e}){return d.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 Yn="ole-onboarding-dismissed";function hj(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Yn)==="1"}catch{return!1}}function $r(e){try{e?window.localStorage.setItem(Yn,"1"):window.localStorage.removeItem(Yn)}catch{}}const Sr=en(e=>({dismissed:hj(),dismiss:()=>{$r(!0),e({dismissed:!0})},reset:()=>{$r(!1),e({dismissed:!1})}}));function pj(){const e=ae(),t=Sr(o=>o.dismissed),n=Sr(o=>o.dismiss);return t?null:d.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:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),d.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:d.jsx(Zn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Mn,{n:1,icon:d.jsx(qr,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Mn,{n:2,icon:d.jsx(Lr,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Mn,{n:3,icon:d.jsx(Vn,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),d.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 Mn({n:e,icon:t,title:n,body:o}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[d.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}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),d.jsx("span",{children:n})]}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function gj(){const e=ae(),t=x(m=>m.selection),n=x(m=>m.diagram.elements),o=x(m=>m.diagram.buses),r=x(m=>m.diagram.junctions),s=x(m=>m.selectedNode),i=x(m=>m.selectedWire);if(i)return d.jsx(kj,{wireId:i});if(s)return d.jsx($j,{nodeId:s});if(t.length===0)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const a=t[0],l=(o??[]).find(m=>m.id===a);if(l)return d.jsx(wj,{bus:l});const c=(r??[]).find(m=>m.id===a);if(c)return d.jsx(_j,{junction:c});const f=n.find(m=>m.id===a);if(!f)return null;const u=Ke[f.kind];return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(dt,{label:e("props.name"),value:f.name??"",placeholder:f.id,onCommit:m=>x.getState().updateElement(a,{name:m.trim()===""?void 0:m.trim()})}),d.jsx(so,{label:e("props.note"),value:f.note??"",onCommit:m=>x.getState().updateElement(a,{note:m.trim()===""?void 0:m.trim()})}),(u==null?void 0:u.state)&&u.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:u.state.map(m=>d.jsx(Sj,{id:a,element:f,field:m},m.name))}),d.jsx(yj,{id:a,element:f,schema:(u==null?void 0:u.params)??[]})]})}function yj({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:d.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>d.jsx(xj,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(bj,{id:e,element:t,fieldKey:s,value:i},s))]})}function xj({id:e,element:t,field:n}){var l;const o=ae(),r=It(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const f={...t.params??{}};c===void 0||c===n.default?delete f[n.name]:f[n.name]=c,x.getState().updateElement(e,{params:Object.keys(f).length>0?f:void 0})};return n.type==="boolean"?d.jsx(ct,{label:i,children:d.jsx(io,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?d.jsx(cn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):d.jsx(dt,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function bj({id:e,element:t,fieldKey:n,value:o}){const r=ae(),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"?d.jsx(ct,{label:n,children:d.jsx(io,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(cn,{label:n,value:o,onCommit:s}):d.jsx(dt,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function wj({bus:e}){const t=ae(),n=e.id,o=r=>{const s=r.trim();Kn(n,{name:s===""?void 0:s})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(so,{label:t("props.note"),value:e.note??"",onCommit:r=>Kn(n,{note:r.trim()===""?void 0:r.trim()})}),d.jsx(vj,{bus:e})]})}function vj({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Kn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.jsx(cn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Kn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function kj({wireId:e}){const t=ae(),n=x(b=>b.diagram.wires),o=x(b=>b.diagram.elements),r=x(b=>b.diagram.buses),s=x(b=>b.diagram.junctions),i=x(b=>b.internal.terminalToNode),a=x(b=>b.setSelectedNode),l=(n??[]).find(b=>b.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),f=new Map(o.map(b=>[b.id,b])),u=new Map((r??[]).map(b=>[b.id,b])),m=new Map((s??[]).map(b=>[b.id,b])),p=b=>{if(!b.includes(".")){const B=u.get(b);if(B)return{id:b,label:B.name??b};const D=m.get(b);return{id:b,label:(D==null?void 0:D.name)??b}}const $=b.indexOf("."),k=b.slice(0,$),w=b.slice($+1),M=f.get(k);return{id:k,label:(M==null?void 0:M.name)??k,pin:w}},h=p(l.ends[0]),g=p(l.ends[1]);return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),d.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((b,$)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([b.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:b.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:b.label}),b.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:b.pin})]},$))}),c&&d.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:()=>a(c),children:t("props.selectWholeNode")})]})}function _j({junction:e}){var r;const t=ae(),n=x(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),d.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),d.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>x.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(so,{label:t("props.note"),value:e.note??"",onCommit:s=>x.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})}),o&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[d.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),d.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function $j({nodeId:e}){const t=ae(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return d.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 c=a.slice(0,l),f=a.slice(l+1),u=s.get(c)??[];u.push(f),s.set(c,u)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.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:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function ct({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function dt({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=O.useState(t),a=O.useRef(null);return O.useEffect(()=>i(t),[t]),d.jsx(ct,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,f;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(f=a.current)==null||f.blur())},className:Ee("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&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function so({label:e,value:t,onCommit:n}){const[o,r]=O.useState(t);return O.useEffect(()=>r(t),[t]),d.jsx(ct,{label:e,children:d.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 cn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=O.useState(String(t)),a=O.useRef(null);return O.useEffect(()=>i(String(t)),[t]),d.jsx(ct,{label:e,children:d.jsxs("div",{className:"relative",children:[d.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 c,f;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(String(t)),(f=a.current)==null||f.blur())},min:n,className:Ee("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&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function io({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:Ee("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 Sj({id:e,element:t,field:n}){var l;const o=ae(),s=It()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const f={...t.state??{}};c===void 0||c===n.default?delete f[n.name]:f[n.name]=c,x.getState().updateElement(e,{state:Object.keys(f).length>0?f:void 0})};return n.type==="boolean"?d.jsx(ct,{label:s,children:d.jsx(io,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(cn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(dt,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function jj(){const e=ae(),t=It(),n=x(u=>u.selection),o=x(u=>u.selectedNode),r=x(u=>u.selectedWire),s=x(u=>u.diagram.elements),i=x(u=>u.diagram.buses),a=Ve(),l=Oe(a,"dense");if(n.length===0&&!o&&!r)return null;let c=e("props.title"),f=null;if(r)c=e("props.wire");else if(o)c=e("props.node");else if(n.length===1){const u=n[0],m=(i??[]).find(p=>p.id===u);if(m)c=m.name??e("props.bus");else{const p=s.find(h=>h.id===u);if(p){const h=Ke[p.kind];c=h?t(`${h.id}.name`,h.name):p.kind}}}else f=n.length;return d.jsxs("aside",{className:Ee("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:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:c}),f!=null&&d.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:f})})]}),d.jsx(gj,{})]})}function Ej(){O.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 Nj(){Ej();const e=O.useRef(null),t=XS(e);return d.jsx(Zv,{children:d.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(w4,{width:t,children:[d.jsx(d4,{}),d.jsx(Z4,{}),d.jsx(jj,{}),d.jsx(K4,{}),d.jsx(G4,{}),d.jsx(O4,{}),d.jsx(cj,{}),d.jsx(pj,{}),d.jsx(x4,{})]})})})}const Mj="ole-theme";function Tj(){try{const e=window.localStorage.getItem(Mj);return e==="light"||e==="dark"?e:null}catch{return null}}function Aj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function Ij(){return typeof window>"u"?"light":Tj()??(Aj()?"dark":"light")}function Tw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Cj({className:e,diagram:t,locale:n,theme:o}){return O.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),O.useEffect(()=>{n&&At.getState().setLocale(n)},[n]),O.useEffect(()=>{o&&Tw(o)},[o]),O.useEffect(()=>{no()},[]),NS(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(Nj,{})})}const Aw={"application/json":[".json"]},Iw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Cw=e=>e instanceof DOMException&&e.name==="AbortError";function jr(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(we("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(we("io.notObject"));const n=t;if(n.version!=="1")throw new Error(we("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(we("io.elementsMissing"));return n}function Pj(e){return JSON.stringify(e,null,2)+`
|
|
199
|
+
`}async function Oj(){if(Iw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:we("topbar.file.fileDescription"),accept:Aw}]})}catch(n){if(Cw(n))return null;throw n}const t=await e.getFile();return{diagram:jr(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:jr(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function Er(e,t,n={}){const o=Pj(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Iw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:we("topbar.file.fileDescription"),accept:Aw}]})}catch(l){if(Cw(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 Bj(){const e=ae(),t=x(u=>u.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=Lj(),[a,l]=O.useState(!1),c=O.useRef(null);O.useEffect(()=>{const u=m=>{if(!(m.metaKey||m.ctrlKey))return;const p=m.key.toLowerCase();p==="o"?(m.preventDefault(),r()):p==="s"&&(m.preventDefault(),m.shiftKey?i():s())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r,s,i]),O.useEffect(()=>{if(!a)return;const u=p=>{c.current&&!c.current.contains(p.target)&&l(!1)},m=p=>{p.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",m)}},[a]);const f=u=>()=>{l(!1),u()};return d.jsxs("div",{ref:c,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(u=>!u),children:[d.jsx(Mo,{}),e("topbar.file.label")]}),a&&d.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:[d.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),d.jsx(Ht,{onClick:f(o),icon:d.jsx(lv,{}),children:e("topbar.file.new")}),d.jsx(Ht,{onClick:f(r),icon:d.jsx(Mo,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(Ht,{onClick:f(s),icon:d.jsx(To,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(Ht,{onClick:f(i),icon:d.jsx(To,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function Ht({children:e,icon:t,hint:n,onClick:o}){return d.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,d.jsx("span",{className:"flex-1",children:e}),n&&d.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function Lj(){const e=ae(),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 Oj();l&&(t(l.diagram,l.session),no())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=x.getState(),f=await Er(l,c);f&&n(f)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:c}=x.getState(),f=await Er(l,c,{saveAs:!0});f&&n(f)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const Tn="WIRES",De="ELEMENTS",Nr="LABELS",Mr="ANNOTATIONS",Tr=32,Ar=64,zj=8,Rj=1.25,Dj=6;function Pw(e,t={}){const n=new Qj(t.precision??6);n.header(t.title),n.tables([{name:Tn,color:7},{name:De,color:7},{name:Nr,color:8},{name:Mr,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(Tn,r.path.map(Ce),!1);for(const{geometry:r}of e.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?[i[0]-l,i[1]]:[i[0],i[1]-l],f=s==="x"?[i[0]+l,i[1]]:[i[0],i[1]+l];n.lwpolyline(Tn,[c,f].map(Ce),!1)}for(const r of e.elements.values()){const s=e.layout.get(r.element.id),i=r.libraryDef;!s||!i||Fj(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=nn(r,o);if(i.length===0)continue;const a=r.libraryDef.label??on(r.libraryDef),[l,c]=rn(a,s);for(let f=0;f<i.length;f++){const[u,m]=Ce([l,c+f*tn]);n.text(Nr,[u,m],i[f],Kt,0,!1)}}for(const r of t.annotations??[]){if(!r.text)continue;const s=r.fontSize??zj,i=r.text.split(`
|
|
200
|
+
`);for(let a=0;a<i.length;a++){const[l,c]=Ce([r.at[0],r.at[1]+(a+1)*s*Rj]);n.text(Mr,[l,c],i[a],s,0,!1)}}return n.endEntities(),n.toString()}async function Ow(e,t="diagram.dxf",n){const o=Pw(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 Fj(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":Hj(e,i,n);break;case"polyline":Ir(e,i,n,!1);break;case"polygon":Ir(e,i,n,!0);break;case"rect":Wj(e,i,n);break;case"circle":qj(e,i,n);break;case"ellipse":Gj(e,i,n);break;case"path":Vj(e,i,n);break;case"text":Kj(e,i,n);break}}function Hj(e,t,n){const o=ve(t,"x1"),r=ve(t,"y1"),s=ve(t,"x2"),i=ve(t,"y2"),a=Ce(Re([o,r],n)),l=Ce(Re([s,i],n));e.line(De,a,l)}function Ir(e,t,n,o){const r=Zj(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>Ce(Re(i,n)));e.lwpolyline(De,s,o)}function Wj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=ve(t,"width"),i=ve(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(c=>Ce(Re(c,n)));e.lwpolyline(De,l,!0)}function qj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"r"),i=Ce(Re([o,r],n));e.circle(De,i,s)}function Gj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"rx"),i=ve(t,"ry");if(Math.abs(s-i)<1e-6){Xj(e,o,r,s,n);return}Yj(e,o,r,s,i,n)}function Xj(e,t,n,o,r){const s=Ce(Re([t,n],r));e.circle(De,s,o)}function Yj(e,t,n,o,r,s){const i=[];for(let a=0;a<Ar;a++){const l=a/Ar*Math.PI*2;i.push(Ce(Re([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(De,i,!0)}function Kj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||Dj,i=(t.textContent??"").trim();if(!i)return;const a=Ce(Re([o,r],n));e.text(De,a,i,s,n.rot,n.mirror)}function Vj(e,t,n){const o=t.getAttribute("d")??"",r=Uj(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(De,i.map(l=>Ce(Re(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[c,f,,u,m,p,h]=l.args,g=Jj(s,[p,h],c,f,u!==0,m!==0);if(g)for(let b=1;b<=Tr;b++){const $=g.theta1+g.delta*b/Tr;i.push([g.cx+c*Math.cos($),g.cy+f*Math.sin($)])}else i.push([p,h]);s=[p,h]}a()}function Uj(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 Jj(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,c]=t;if(i===l&&a===c)return null;const f=(i-l)/2,u=(a-c)/2;let m=Math.abs(n),p=Math.abs(o);const h=m*m,g=p*p,b=f*f/h+u*u/g;if(b>1){const F=Math.sqrt(b);m*=F,p*=F}const $=r===s?-1:1,k=m*m*p*p-m*m*u*u-p*p*f*f,w=m*m*u*u+p*p*f*f,M=$*Math.sqrt(Math.max(0,k/w)),B=M*(m*u)/p,D=M*-(p*f)/m,V=B+(i+l)/2,J=D+(a+c)/2,ne=(F,le,ce,he)=>{const oe=F*ce+le*he,se=Math.hypot(F,le)*Math.hypot(ce,he);let ye=Math.acos(Math.max(-1,Math.min(1,oe/se)));return F*he-le*ce<0&&(ye=-ye),ye},G=ne(1,0,(f-B)/m,(u-D)/p);let P=ne((f-B)/m,(u-D)/p,(-f-B)/m,(-u-D)/p);return!s&&P>0?P-=2*Math.PI:s&&P<0&&(P+=2*Math.PI),{cx:V,cy:J,theta1:G,delta:P}}function Re(e,t){return Pe(e,t)}function Ce(e){return[e[0],-e[1]]}function ve(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function Zj(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 Qj{constructor(t){pt(this,"out",[]);pt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
|
|
201
201
|
${this.fmt(n)}
|
|
202
|
-
`)}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,
|
|
203
|
-
`);for(let g=0;g<h.length;g++){const b=m.at[1]+p*.85+g*p*
|
|
204
|
-
`)}function
|
|
205
|
-
`),
|
|
202
|
+
`)}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,Cr(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,Cr(o)),s!==0&&this.g(50,s),i&&this.g(71,2)}}function Cr(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const e6="http://www.w3.org/2000/svg",Wt=24,Bw=8,Lw=1.25;function ao(e,t={}){const n=t6(e,t),o=Math.floor(n.minX-Wt),r=Math.floor(n.minY-Wt),s=Math.ceil(n.maxX+Wt)-o,i=Math.ceil(n.maxY+Wt)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${e6}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${rt(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 u of e.wireRenders.values()){if(u.path.length<2)continue;const m=u.path.map(([p,h])=>`${p},${h}`).join(" ");l.push(` <polyline points="${m}"/>`)}l.push(" </g>");for(const{bus:u,geometry:m}of e.buses.values()){const{axis:p,at:h,span:g}=m,b=g/2,$=p==="x"?h[0]-b:h[0],k=p==="x"?h[1]:h[1]-b,w=p==="x"?h[0]+b:h[0],M=p==="x"?h[1]:h[1]+b;l.push(` <line id="${rt(u.id)}" x1="${$}" y1="${k}" x2="${w}" y2="${M}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:u,world:m}of e.junctions.values())l.push(` <circle id="${rt(u.id)}" cx="${m[0]}" cy="${m[1]}" r="3.5" fill="black"/>`);for(const u of e.elements.values()){if(!u.libraryDef)continue;const m=e.layout.get(u.element.id);m&&(l.push(` <g id="${rt(u.element.id)}" transform="${Ye(m)}">`),l.push(` ${u.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const u=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Kt}" paint-order="stroke" stroke="${u}" stroke-width="2" stroke-linejoin="round">`);for(const m of e.elements.values()){const p=e.layout.get(m.element.id);if(!p||!m.libraryDef)continue;const h=nn(m,c);if(h.length===0)continue;const g=m.libraryDef.label??on(m.libraryDef),[b,$]=rn(g,p),k=g.anchor??"start";for(let w=0;w<h.length;w++)l.push(` <text x="${b}" y="${$+w*tn}" text-anchor="${k}">${rt(h[w])}</text>`)}l.push(" </g>")}const f=t.annotations??[];if(f.length>0){const u=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${u}" stroke-width="2" stroke-linejoin="round">`);for(const m of f){if(!m.text)continue;const p=m.fontSize??Bw,h=m.text.split(`
|
|
203
|
+
`);for(let g=0;g<h.length;g++){const b=m.at[1]+p*.85+g*p*Lw;l.push(` <text x="${m.at[0]}" y="${b}" font-size="${p}">${rt(h[g])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
|
|
204
|
+
`)}function t6(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(l,c)=>{l<n&&(n=l),l>r&&(r=l),c<o&&(o=c),c>s&&(s=c)};for(const l of e.terminals.values())i(l.world[0],l.world[1]);for(const l of e.junctions.values())i(l.world[0],l.world[1]);for(const l of e.elements.values()){const c=e.layout.get(l.element.id),f=l.libraryDef;if(!c||!f)continue;const u=n6(f.viewBox);if(!u){i(c.at[0],c.at[1]);continue}const m=[[u.x,u.y],[u.x+u.w,u.y],[u.x,u.y+u.h],[u.x+u.w,u.y+u.h]];for(const p of m){const[h,g]=Pe(p,c);i(h,g)}}for(const{geometry:l}of e.buses.values()){const{axis:c,at:f,span:u}=l,m=u/2;c==="x"?(i(f[0]-m,f[1]),i(f[0]+m,f[1])):(i(f[0],f[1]-m),i(f[0],f[1]+m))}for(const l of e.wireRenders.values())for(const[c,f]of l.path)i(c,f);const a=t.labelMode??"all";if(a!=="off")for(const l of e.elements.values()){const c=e.layout.get(l.element.id);if(!c||!l.libraryDef)continue;const f=nn(l,a);if(f.length===0)continue;const u=l.libraryDef.label??on(l.libraryDef),[m,p]=rn(u,c),h=Pr(f,Kt),g=f.length*tn,b=u.anchor??"start",$=b==="middle"?m-h/2:b==="end"?m-h:m;i($,p-Kt),i($+h,p+g)}for(const l of t.annotations??[]){if(!l.text)continue;const c=l.fontSize??Bw,f=l.text.split(`
|
|
205
|
+
`),u=Pr(f,c),m=f.length*c*Lw;i(l.at[0],l.at[1]),i(l.at[0]+u,l.at[1]+m)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function Pr(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 n6(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 rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function zw(e,t="diagram.svg",n){const o=ao(e,n);Dw(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function Rw(e,t="diagram.png",n){const o=ao(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 o6(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 c=await new Promise((f,u)=>{a.toBlob(m=>m?f(m):u(new Error("toBlob failed")),"image/png")});Dw(c,t)}finally{URL.revokeObjectURL(s)}}function o6(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 Dw(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function r6(){const e=ae(),[t,n]=O.useState(!1),o=O.useRef(null);O.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 u,m,p,h;n(!1);const{internal:i,diagram:a,fileSession:l}=x.getState(),c=((u=l==null?void 0:l.name)==null?void 0:u.replace(/\.json$/i,""))??((m=a.meta)==null?void 0:m.title)??"diagram",f={title:(p=a.meta)==null?void 0:p.title,labelMode:(h=a.meta)==null?void 0:h.labelMode,annotations:a.annotations};s==="svg"?zw(i,`${c}.svg`,f):s==="png"?Rw(i,`${c}.png`,{...f,scale:2}).catch(g=>{console.error(g),alert(e("topbar.export.pngFailed",{err:g.message}))}):Ow(i,`${c}.dxf`,f).catch(g=>{console.error(g),alert(e("topbar.export.dxfFailed",{err:g.message}))})};return d.jsxs("div",{ref:o,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[d.jsx(sv,{}),e("topbar.export.label")]}),t&&d.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:[d.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:[d.jsx(cv,{}),d.jsx("span",{className:"flex-1",children:"SVG"})]}),d.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:[d.jsx(av,{}),d.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),d.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:[d.jsx(iv,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=r6;exports.FileMenu=Bj;exports.LIBRARY=Bn;exports.OneLineEditor=Cj;exports.applyTheme=Tw;exports.buildExportDxf=Pw;exports.buildExportSvg=ao;exports.compile=Ge;exports.downloadDxf=Ow;exports.downloadPng=Rw;exports.downloadSvg=zw;exports.emptyInternalModel=is;exports.fitToContent=to;exports.fitToContentSoon=no;exports.getInitialTheme=Ij;exports.getLibraryEntry=Qb;exports.newBusId=Ln;exports.newElementId=Mt;exports.newJunctionId=zn;exports.orientationVec=On;exports.resolvePlacement=as;exports.transformOrientation=$t;exports.transformPoint=Pe;exports.useEditorStore=x;exports.useLocale=At;exports.wireIdFromEnds=Je;
|
|
206
206
|
//# sourceMappingURL=sldeditor.cjs.map
|